linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] mseal: fix mmap(FIXED) error code.
@ 2024-08-28 22:55 jeffxu
  2024-08-28 22:55 ` [PATCH v1 2/2] selftests/mm: mseal_test add more tests jeffxu
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: jeffxu @ 2024-08-28 22:55 UTC (permalink / raw)
  To: akpm
  Cc: linux-kselftest, linux-mm, linux-hardening, pedro.falcato,
	rientjes, keescook, Jeff Xu

From: Jeff Xu <jeffxu@chromium.org>

mmap(MAP_FIXED) should return EPERM when memory is sealed.

Fixes: 4205a39e06da ("mm/munmap: replace can_modify_mm with can_modify_vma")
Signed-off-by: Jeff Xu <jeffxu@chromium.org>
---
 mm/mmap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 80d70ed099cf..0cd0c0ef03c7 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1386,7 +1386,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
 		mt_on_stack(mt_detach);
 		mas_init(&mas_detach, &mt_detach, /* addr = */ 0);
 		/* Prepare to unmap any existing mapping in the area */
-		if (vms_gather_munmap_vmas(&vms, &mas_detach))
+		error = vms_gather_munmap_vmas(&vms, &mas_detach);
+		if (error == -EPERM)
+			return -EPERM;
+		if (error)
 			return -ENOMEM;
 
 		vmg.next = vms.next;
-- 
2.46.0.295.g3b9ea8a38a-goog



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

end of thread, other threads:[~2024-08-31 10:14 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-28 22:55 [PATCH v1 1/2] mseal: fix mmap(FIXED) error code jeffxu
2024-08-28 22:55 ` [PATCH v1 2/2] selftests/mm: mseal_test add more tests jeffxu
2024-08-29 14:45   ` Jeff Xu
2024-08-29 15:14     ` Lorenzo Stoakes
2024-08-29 15:30       ` Jeff Xu
2024-08-29 15:44         ` Lorenzo Stoakes
2024-08-29 19:54           ` Jeff Xu
2024-08-29 19:58             ` Matthew Wilcox
2024-08-29 21:34               ` Jeff Xu
2024-08-29 16:16   ` Mark Brown
2024-08-29 16:32     ` Lorenzo Stoakes
2024-08-29 19:40     ` Jeff Xu
2024-08-28 23:38 ` [PATCH v1 1/2] mseal: fix mmap(FIXED) error code Pedro Falcato
2024-08-29 14:03   ` Liam R. Howlett
2024-08-29 14:36     ` Jeff Xu
2024-08-29 14:32   ` Jeff Xu
2024-08-29 12:09 ` Lorenzo Stoakes
2024-08-29 14:34   ` Jeff Xu
2024-08-31  1:15   ` Andrew Morton
2024-08-31 10:14     ` Lorenzo Stoakes

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