linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] mseal: fixing madvise for file-backed mapping and PROT_NONE
@ 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
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: jeffxu @ 2024-10-17  0:51 UTC (permalink / raw)
  To: akpm, keescook, torvalds, usama.anjum, corbet, Liam.Howlett,
	lorenzo.stoakes
  Cc: jeffxu, jorgelo, groeck, linux-kernel, linux-kselftest, linux-mm,
	jannh, sroettger, pedro.falcato, linux-hardening, willy, gregkh,
	deraadt, surenb, merimus, rdunlap

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.

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.

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



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-10-23 18:34 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-17  0:51 [PATCH v1 0/2] mseal: fixing madvise for file-backed mapping and PROT_NONE 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 ` [PATCH v1 0/2] mseal: fixing madvise for file-backed mapping and PROT_NONE Lorenzo Stoakes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox