From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: jeffxu@chromium.org
Cc: akpm@linux-foundation.org, keescook@chromium.org,
torvalds@linux-foundation.org, usama.anjum@collabora.com,
corbet@lwn.net, Liam.Howlett@oracle.com, jeffxu@google.com,
jorgelo@chromium.org, groeck@chromium.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-mm@kvack.org, jannh@google.com, sroettger@google.com,
pedro.falcato@gmail.com, linux-hardening@vger.kernel.org,
willy@infradead.org, gregkh@linuxfoundation.org,
deraadt@openbsd.org, surenb@google.com, merimus@google.com,
rdunlap@infradead.org
Subject: Re: [PATCH v1 0/2] mseal: fixing madvise for file-backed mapping and PROT_NONE
Date: Thu, 17 Oct 2024 09:38:41 +0100 [thread overview]
Message-ID: <c348bdfd-688b-4260-84e3-3c36a534c807@lucifer.local> (raw)
In-Reply-To: <20241017005105.3047458-1-jeffxu@chromium.org>
NACK.
On Thu, Oct 17, 2024 at 12:51:03AM +0000, jeffxu@chromium.org wrote:
> From: Jeff Xu <jeffxu@google.com>
>
> Two fixes for madvise(MADV_DONTNEED) when sealed.
>
> For PROT_NONE mappings, the previous blocking of
> madvise(MADV_DONTNEED) is unnecessary. As PROT_NONE already prohibits
> memory access, madvise(MADV_DONTNEED) should be allowed to proceed in
> order to free the page.
Except if they are VM_MAYWRITE...
>
> For file-backed, private, read-only memory mappings, we previously did
> not block the madvise(MADV_DONTNEED). This was based on
> the assumption that the memory's content, being file-backed, could be
> retrieved from the file if accessed again. However, this assumption
> failed to consider scenarios where a mapping is initially created as
> read-write, modified, and subsequently changed to read-only. The newly
> introduced VM_WASWRITE flag addresses this oversight.
There's no justification for adding a new VMA flag, especially given it
will break VMA merging for everyone.
This whole approach seems broken. What you seem to need is to check whether
a mapping _could_ be mapped writably at some stage.
The kernel doesn't need to keep track of all the times where it was
writable before or not but rather this.
Please look at VM_MAYWRITE and mapping_writably_mapped() (to account for
memfd seal behaviour).
Also you need to rewrite your tests to be readable.
>
> Jeff Xu (2):
> mseal: Two fixes for madvise(MADV_DONTNEED) when sealed
> selftest/mseal: Add tests for madvise
>
> include/linux/mm.h | 2 +
> mm/mprotect.c | 3 +
> mm/mseal.c | 42 +++++++--
> tools/testing/selftests/mm/mseal_test.c | 118 +++++++++++++++++++++++-
> 4 files changed, 157 insertions(+), 8 deletions(-)
>
> --
> 2.47.0.rc1.288.g06298d1525-goog
>
prev parent reply other threads:[~2024-10-17 8:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 0:51 jeffxu
2024-10-17 0:51 ` [PATCH v1 1/2] mseal: Two fixes for madvise(MADV_DONTNEED) when sealed jeffxu
2024-10-17 8:32 ` Lorenzo Stoakes
2024-10-17 19:37 ` Pedro Falcato
2024-10-17 20:34 ` Jeff Xu
2024-10-17 20:49 ` Pedro Falcato
2024-10-17 20:57 ` Jeff Xu
2024-10-22 15:55 ` Vlastimil Babka
2024-10-22 22:54 ` Theo de Raadt
2024-10-23 18:33 ` Jeff Xu
2024-10-20 9:20 ` kernel test robot
2024-10-20 9:20 ` kernel test robot
2024-10-17 0:51 ` [PATCH v1 2/2] selftest/mseal: Add tests for madvise fixes jeffxu
2024-10-17 8:35 ` Lorenzo Stoakes
2024-10-17 8:38 ` Lorenzo Stoakes [this message]
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=c348bdfd-688b-4260-84e3-3c36a534c807@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=deraadt@openbsd.org \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=jannh@google.com \
--cc=jeffxu@chromium.org \
--cc=jeffxu@google.com \
--cc=jorgelo@chromium.org \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=merimus@google.com \
--cc=pedro.falcato@gmail.com \
--cc=rdunlap@infradead.org \
--cc=sroettger@google.com \
--cc=surenb@google.com \
--cc=torvalds@linux-foundation.org \
--cc=usama.anjum@collabora.com \
--cc=willy@infradead.org \
/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