Skip to content

Commit 748c90c

Browse files
rpedgecohansendc
authored andcommitted
x86/shstk: Remove useless clone error handling
When clone fails after the shadow stack is allocated, any allocated shadow stack is cleaned up in exit_thread() in copy_process(). So the logic in copy_thread() is unneeded, and also will not handle failures that happen outside of copy_thread(). In addition, since there is a second attempt to unmap the same shadow stack, there is a race where an newly mapped region could get unmapped. So remove the logic in copy_thread() and rely on exit_thread() to handle clone failure. Fixes: b2926a3 ("x86/shstk: Handle thread shadow stack") Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Tested-by: H.J. Lu <hjl.tools@gmail.com> Link: https://lore.kernel.org/all/20230908203655.543765-3-rick.p.edgecombe%40intel.com
1 parent 3319556 commit 748c90c

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

arch/x86/kernel/process.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,6 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
257257
if (!ret && unlikely(test_tsk_thread_flag(current, TIF_IO_BITMAP)))
258258
io_bitmap_share(p);
259259

260-
/*
261-
* If copy_thread() if failing, don't leak the shadow stack possibly
262-
* allocated in shstk_alloc_thread_stack() above.
263-
*/
264-
if (ret)
265-
shstk_free(p);
266-
267260
return ret;
268261
}
269262

0 commit comments

Comments
 (0)