The patch titled Subject: fork,memcg: alloc_thread_stack_node needs to set tsk->stack has been added to the -mm tree. Its filename is forkmemcg-alloc_thread_stack_node-needs-to-set-tsk-stack.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/forkmemcg-alloc_thread_stack_node-needs-to-set-tsk-stack.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/forkmemcg-alloc_thread_stack_node-needs-to-set-tsk-stack.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Andrea Arcangeli <aarcange@xxxxxxxxxx> Subject: fork,memcg: alloc_thread_stack_node needs to set tsk->stack 5eed6f1dff87b ("fork,memcg: fix crash in free_thread_stack on memcg charge fail") corrected two instances, but there was a third instance of this bug. Without setting tsk->stack, if memcg_charge_kernel_stack fails, it'll execute free_thread_stack() on a dangling pointer. Enterprise kernels are compiled with VMAP_STACK=y so this isn't critical, but custom VMAP_STACK=n builds should have some performance advantage, with the drawback of risking to fail fork because compaction didn't succeed. So as long as VMAP_STACK=n is a supported option it's worth fixing it upstream. Link: http://lkml.kernel.org/r/20190619011450.28048-1-aarcange@xxxxxxxxxx Fixes: 9b6f7e163cd0 ("mm: rework memcg kernel stack accounting") Signed-off-by: Andrea Arcangeli <aarcange@xxxxxxxxxx> Reviewed-by: Rik van Riel <riel@xxxxxxxxxxx> Acked-by: Roman Gushchin <guro@xxxxxx> Acked-by: Michal Hocko <mhocko@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/fork.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/kernel/fork.c~forkmemcg-alloc_thread_stack_node-needs-to-set-tsk-stack +++ a/kernel/fork.c @@ -248,7 +248,11 @@ static unsigned long *alloc_thread_stack struct page *page = alloc_pages_node(node, THREADINFO_GFP, THREAD_SIZE_ORDER); - return page ? page_address(page) : NULL; + if (likely(page)) { + tsk->stack = page_address(page); + return tsk->stack; + } + return NULL; #endif } _ Patches currently in -mm which might be from aarcange@xxxxxxxxxx are forkmemcg-alloc_thread_stack_node-needs-to-set-tsk-stack.patch