Skip to content

Commit a5131c3

Browse files
committed
Merge tag 'x86-shstk-2024-05-13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 shadow stacks from Ingo Molnar: "Enable shadow stacks for x32. While we normally don't do such feature-enabling for 32-bit anymore, this change is small, straightforward & tested on upstream glibc" * tag 'x86-shstk-2024-05-13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/shstk: Enable shadow stacks for x32
2 parents 5f487cd + 2883f01 commit a5131c3

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

arch/x86/entry/syscalls/syscall_64.tbl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@
374374
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
375375
451 common cachestat sys_cachestat
376376
452 common fchmodat2 sys_fchmodat2
377-
453 64 map_shadow_stack sys_map_shadow_stack
377+
453 common map_shadow_stack sys_map_shadow_stack
378378
454 common futex_wake sys_futex_wake
379379
455 common futex_wait sys_futex_wait
380380
456 common futex_requeue sys_futex_requeue

arch/x86/kernel/shstk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ static int shstk_setup(void)
163163
if (features_enabled(ARCH_SHSTK_SHSTK))
164164
return 0;
165165

166-
/* Also not supported for 32 bit and x32 */
167-
if (!cpu_feature_enabled(X86_FEATURE_USER_SHSTK) || in_32bit_syscall())
166+
/* Also not supported for 32 bit */
167+
if (!cpu_feature_enabled(X86_FEATURE_USER_SHSTK) || in_ia32_syscall())
168168
return -EOPNOTSUPP;
169169

170170
size = adjust_shstk_size(0);

arch/x86/kernel/signal_64.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ int x32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
315315

316316
uc_flags = frame_uc_flags(regs);
317317

318+
if (setup_signal_shadow_stack(ksig))
319+
return -EFAULT;
320+
318321
if (!user_access_begin(frame, sizeof(*frame)))
319322
return -EFAULT;
320323

@@ -377,6 +380,9 @@ COMPAT_SYSCALL_DEFINE0(x32_rt_sigreturn)
377380
if (!restore_sigcontext(regs, &frame->uc.uc_mcontext, uc_flags))
378381
goto badframe;
379382

383+
if (restore_signal_shadow_stack())
384+
goto badframe;
385+
380386
if (compat_restore_altstack(&frame->uc.uc_stack))
381387
goto badframe;
382388

0 commit comments

Comments
 (0)