linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] execmem: enforce allocation size aligment to PAGE_SIZE
@ 2025-04-23 14:48 Mike Rapoport
  2025-04-23 14:56 ` Peter Zijlstra
  2025-04-23 21:36 ` Andrew Morton
  0 siblings, 2 replies; 5+ messages in thread
From: Mike Rapoport @ 2025-04-23 14:48 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Mike Rapoport, Peter Zijlstra, linux-mm, linux-kernel

From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>

Before introduction of ROX cache execmem allocation size was always
implicitly aligned to PAGE_SIZE inside vmalloc.

However, when allocation happens from the ROX cache, this is not
enforced.

Make sure that the allocation size is always consistently aligned to
PAGE_SIZE.

Fixes: 2e45474ab14f ("execmem: add support for cache of large ROX pages")
Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
 mm/execmem.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/execmem.c b/mm/execmem.c
index e6c4f5076ca8..2b683e7d864d 100644
--- a/mm/execmem.c
+++ b/mm/execmem.c
@@ -377,6 +377,8 @@ void *execmem_alloc(enum execmem_type type, size_t size)
 	pgprot_t pgprot = range->pgprot;
 	void *p;
 
+	size = PAGE_ALIGN(size);
+
 	if (use_cache)
 		p = execmem_cache_alloc(range, size);
 	else
-- 
2.47.2



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

end of thread, other threads:[~2025-04-24  8:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-23 14:48 [PATCH] execmem: enforce allocation size aligment to PAGE_SIZE Mike Rapoport
2025-04-23 14:56 ` Peter Zijlstra
2025-04-23 21:36 ` Andrew Morton
2025-04-24  5:50   ` Mike Rapoport
2025-04-24  8:53   ` Peter Zijlstra

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