From: Daniel Colascione <dancol@google.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Joel Fernandes <joel@joelfernandes.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
kernel-team@android.com, John Reck <jreck@google.com>,
John Stultz <john.stultz@linaro.org>,
Todd Kjos <tkjos@google.com>,
Greg KH <gregkh@linuxfoundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
"J. Bruce Fields" <bfields@fieldses.org>,
Jeff Layton <jlayton@kernel.org>,
Khalid Aziz <khalid.aziz@oracle.com>,
linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-mm <linux-mm@kvack.org>,
Mike Kravetz <mike.kravetz@oracle.com>,
Minchan Kim <minchan@google.com>, Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH v2 1/2] mm: Add an F_SEAL_FS_WRITE seal to memfd
Date: Wed, 17 Oct 2018 08:44:01 -0700 [thread overview]
Message-ID: <CAKOZuesr_8vrob-XfEpGmyeKFEhWWXZo4BEC0PixfjT2ibaRZQ@mail.gmail.com> (raw)
In-Reply-To: <20181017120829.GA19731@infradead.org>
On Wed, Oct 17, 2018 at 5:08 AM, Christoph Hellwig <hch@infradead.org> wrote:
> On Wed, Oct 17, 2018 at 03:39:58AM -0700, Joel Fernandes wrote:
>> > > This usecase cannot be implemented with the existing F_SEAL_WRITE seal.
>> > > To support the usecase, this patch adds a new F_SEAL_FS_WRITE seal which
>> > > prevents any future mmap and write syscalls from succeeding while
>> > > keeping the existing mmap active. The following program shows the seal
>> > > working in action:
>> >
>> > Where does the FS come from? I'd rather expect this to be implemented
>> > as a 'force' style flag that applies the seal even if the otherwise
>> > required precondition is not met.
>>
>> The "FS" was meant to convey that the seal is preventing writes at the VFS
>> layer itself, for example vfs_write checks FMODE_WRITE and does not proceed,
>> it instead returns an error if the flag is not set. I could not find a better
>> name for it, I could call it F_SEAL_VFS_WRITE if you prefer?
>
> I don't think there is anything VFS or FS about that - at best that
> is an implementation detail.
>
> Either do something like the force flag I suggested in the last mail,
> or give it a name that matches the intention, e.g F_SEAL_FUTURE_WRITE.
+1
>> > This seems to lack any synchronization for f_mode.
>>
>> The f_mode is set when the struct file is first created and then memfd sets
>> additional flags in memfd_create. Then later we are changing it here at the
>> time of setting the seal. I donot see any possiblity of a race since it is
>> impossible to set the seal before memfd_create returns. Could you provide
>> more details about what kind of synchronization is needed and what is the
>> race condition scenario you were thinking off?
>
> Even if no one changes these specific flags we still need a lock due
> to rmw cycles on the field. For example fadvise can set or clear
> FMODE_RANDOM. It seems to use file->f_lock for synchronization.
Compare-and-exchange will suffice, right?
next prev parent reply other threads:[~2018-10-17 15:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-09 22:20 Joel Fernandes (Google)
2018-10-09 22:20 ` [PATCH v2 2/2] selftests/memfd: Add tests for F_SEAL_FS_WRITE seal Joel Fernandes (Google)
2018-10-09 22:34 ` Joel Fernandes
2018-10-16 21:57 ` [PATCH v2 1/2] mm: Add an F_SEAL_FS_WRITE seal to memfd John Stultz
2018-10-17 9:51 ` Christoph Hellwig
2018-10-17 10:39 ` Joel Fernandes
2018-10-17 12:08 ` Christoph Hellwig
2018-10-17 15:44 ` Daniel Colascione [this message]
2018-10-17 16:19 ` Christoph Hellwig
2018-10-17 17:45 ` Joel Fernandes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKOZuesr_8vrob-XfEpGmyeKFEhWWXZo4BEC0PixfjT2ibaRZQ@mail.gmail.com \
--to=dancol@google.com \
--cc=akpm@linux-foundation.org \
--cc=bfields@fieldses.org \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=jlayton@kernel.org \
--cc=joel@joelfernandes.org \
--cc=john.stultz@linaro.org \
--cc=jreck@google.com \
--cc=kernel-team@android.com \
--cc=khalid.aziz@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=minchan@google.com \
--cc=shuah@kernel.org \
--cc=tkjos@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox