Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue,  9 Jan 2018 12:55:56 -0800
From: Kees Cook <>
Cc: Kees Cook <>,
	David Windsor <>,
	Ingo Molnar <>,
	Andrew Morton <>,
	Thomas Gleixner <>,
	Andy Lutomirski <>,
	Linus Torvalds <>,
	Alexander Viro <>,
	Christoph Hellwig <>,
	Christoph Lameter <>,
	"David S. Miller" <>,
	Laura Abbott <>,
	Mark Rutland <>,
	"Martin K. Petersen" <>,
	Paolo Bonzini <>,
	Christian Borntraeger <>,
	Christoffer Dall <>,
	Dave Kleikamp <>,
	Jan Kara <>,
	Luis de Bethencourt <>,
	Marc Zyngier <>,
	Rik van Riel <>,
	Matthew Garrett <>,,,,,
Subject: [PATCH 27/36] fork: Define usercopy region in thread_stack slab caches

From: David Windsor <>

In support of usercopy hardening, this patch defines a region in the
thread_stack slab caches in which userspace copy operations are allowed.
Since the entire thread_stack needs to be available to userspace, the
entire slab contents are whitelisted. Note that the slab-based thread
stack is only present on systems with THREAD_SIZE < PAGE_SIZE and

cache object allocation:
            return kmem_cache_alloc_node(thread_stack_cache, ...)

            stack = alloc_thread_stack_node(...)
            tsk->stack = stack;



This region is known as the slab cache's usercopy region. Slab caches
can now check that each dynamically sized copy operation involving
cache-managed memory falls entirely within the slab's usercopy region.

This patch is modified from Brad Spengler/PaX Team's PAX_USERCOPY
whitelisting code in the last public patch of grsecurity/PaX based on my
understanding of the code. Changes or omissions from the original code are
mine and don't reflect the original grsecurity/PaX code.

Signed-off-by: David Windsor <>
[kees: adjust commit log, split patch, provide usage trace]
Cc: Ingo Molnar <>
Cc: Andrew Morton <>
Cc: Thomas Gleixner <>
Cc: Andy Lutomirski <>
Signed-off-by: Kees Cook <>
Acked-by: Rik van Riel <>
 kernel/fork.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index 82f2a0441d3b..0e086af148f2 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -282,8 +282,9 @@ static void free_thread_stack(struct task_struct *tsk)
 void thread_stack_cache_init(void)
-	thread_stack_cache = kmem_cache_create("thread_stack", THREAD_SIZE,
-					      THREAD_SIZE, 0, NULL);
+	thread_stack_cache = kmem_cache_create_usercopy("thread_stack",
 	BUG_ON(thread_stack_cache == NULL);
 # endif

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.