linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/2] mseal: allow noop mprotect
@ 2025-03-12  0:21 jeffxu
  2025-03-12  0:21 ` [RFC PATCH v1 1/2] selftests/mm: mseal_test: avoid using no-op mprotect jeffxu
  2025-03-12  0:21 ` [RFC PATCH v1 2/2] mseal: allow noop mprotect jeffxu
  0 siblings, 2 replies; 11+ messages in thread
From: jeffxu @ 2025-03-12  0:21 UTC (permalink / raw)
  To: akpm, vbabka, lorenzo.stoakes, Liam.Howlett, broonie, skhan
  Cc: linux-kernel, linux-hardening, linux-kselftest, linux-mm,
	jorgelo, keescook, pedro.falcato, rdunlap, jannh, Jeff Xu

From: Jeff Xu <jeffxu@chromium.org>

Initially, when mseal was introduced in 6.10, semantically, when a VMA
within the specified address range is sealed, the mprotect will be rejected,
leaving all of VMA unmodified. However, adding an extra loop to check the mseal
flag for every VMA slows things down a bit, therefore in 6.12, this issue was
solved by removing can_modify_mm and checking each VMA’s mseal flag directly
without an extra loop [1]. This is a semantic change, i.e. partial update is
allowed, VMAs can be updated until a sealed VMA is found.

The new semantic also means, we could allow mprotect on a sealed VMA if the new
attribute of VMA remains the same as the old one. Relaxing this avoids unnecessary
impacts for applications that want to seal a particular mapping. Doing this also
has no security impact.

The mseal_test is also modified by this patch to adapt to the new
semantic. Please note, mseal_test is currently undergoing refactoring,
and eventually will be replaced with a new memory sealing selftest.
In this patch, I only make a minimum change to make it pass. I considered
adding a new testcase in mseal_test to cover this new behavior, however, the
existing mseal_test is using wrong patterns and won’t pass the review.
Such a new test is better to be added in the new refactored memory sealing tests.
The refactoring is currently pending review [2].

[1] https://lore.kernel.org/all/20240817-mseal-depessimize-v3-0-d8d2e037df30@gmail.com/
[2] https://lore.kernel.org/all/20241211053311.245636-1-jeffxu@google.com/

Jeff Xu (2):
  selftests/mm: mseal_test: avoid using no-op mprotect
  mseal: allow noop mprotect

 mm/mprotect.c                           | 6 +++---
 tools/testing/selftests/mm/mseal_test.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

-- 
2.49.0.rc0.332.g42c0ae87b1-goog



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

end of thread, other threads:[~2025-03-13 22:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-12  0:21 [RFC PATCH v1 0/2] mseal: allow noop mprotect jeffxu
2025-03-12  0:21 ` [RFC PATCH v1 1/2] selftests/mm: mseal_test: avoid using no-op mprotect jeffxu
2025-03-12  0:21 ` [RFC PATCH v1 2/2] mseal: allow noop mprotect jeffxu
2025-03-12 13:49   ` Lorenzo Stoakes
2025-03-12 15:27     ` Kees Cook
2025-03-12 15:48       ` Pedro Falcato
2025-03-12 15:50       ` Lorenzo Stoakes
2025-03-12 16:45         ` Kees Cook
2025-03-12 23:29           ` Jeff Xu
2025-03-13  5:29             ` Lorenzo Stoakes
2025-03-13 22:50               ` Jeff Xu

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