linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fork: zero vmap stack using clear_pages() instead of memset()
@ 2026-02-24 10:26 Linus Walleij
  0 siblings, 0 replies; only message in thread
From: Linus Walleij @ 2026-02-24 10:26 UTC (permalink / raw)
  To: Kees Cook, Ingo Molnar, Peter Zijlstra, Juri Lelli,
	Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
	Mel Gorman, Valentin Schneider, Andrew Morton, David Hildenbrand,
	Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko
  Cc: linux-mm, Mateusz Guzik, Pasha Tatashin, Linus Walleij

After the introduction of clear_pages() we exploit the
fact that the process vm_area is allocated in contiguous
pages to just clear them all in one swift operation.

Suggested-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://lore.kernel.org/linux-mm/dpnwsp7dl4535rd7qmszanw6u5an2p74uxfex4dh53frpb7pu3@2bnjjavjrepe/
Suggested-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Link: https://lore.kernel.org/20240311164638.2015063-7-pasha.tatashin@soleen.com
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
 kernel/fork.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index e832da9d15a4..88d78ccef245 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -345,7 +345,7 @@ static int alloc_thread_stack_node(struct task_struct *tsk, int node)
 		stack = kasan_reset_tag(vm_area->addr);
 
 		/* Clear stale pointers from reused stack. */
-		memset(stack, 0, THREAD_SIZE);
+		clear_pages(vm_area->addr, vm_area->nr_pages);
 
 		tsk->stack_vm_area = vm_area;
 		tsk->stack = stack;

---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20260224-mm-fork-clear-pages-ae7c52d12a93

Best regards,
-- 
Linus Walleij <linusw@kernel.org>



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-02-24 10:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-24 10:26 [PATCH] fork: zero vmap stack using clear_pages() instead of memset() Linus Walleij

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