From: Andrey Zakharov <dedemorow@gmail.com>
To: dave.hansen@intel.com
Cc: x86@kernel.org, luto@kernel.org, tglx@kernel.org,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
hpa@zytor.com, peterz@infradead.org, kees@kernel.org,
brgerst@gmail.com, pawan.kumar.gupta@linux.intel.com,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/entry/32: Harden return-to-user
Date: Sat, 31 Oct 2026 14:25:10 +0300 [thread overview]
Message-ID: <20261031112510.105323-1-dedemorow@gmail.com> (raw)
In-Reply-To: <3d982c1c-4c97-4dbc-958a-4e71131c0020@intel.com>
Hi Dave,
Thanks for the pointers. I looked at the list in 4dab5fe58904 and at
kss-2026-10-23 (b6fa923e47fc). This is code reading and builds only: I
have no FRED hardware, so nothing below was run.
Build problems in kss-2026-10-23:
- "make defconfig" (X86_CET=y via X86_KERNEL_IBT, X86_USER_SHADOW_STACK
unset) fails in arch/x86/kernel/cet.c with gcc 16.2.1:
:277 no previous prototype for 'kshstk_build'
:330 redefinition of 'arch_kernel_stack_lock_current'
:351 'struct thread_struct' has no member named 'kshstk_ssp'
:351 implicit declaration of 'kshstk_enable_current'
cet.c has no #ifdef, while the declarations in asm/shstk.h sit under
CONFIG_X86_USER_SHADOW_STACK. Only cet.o was built for defconfig.
- With USER and KERN shadow stacks both =y, vmlinux.o gets an objtool
warning: kshstk_enable_current+0x3: call to kshstk_build() leaves
.noinstr.text section (it is in .entry.text, kshstk_build is in .text).
A question: PUSH/POP_KERNEL_EVENT_SSP in entry_64_fred.S are under
CONFIG_X86_USER_SHADOW_STACK, but regs_set_return_ip() depends on
X86_FEATURE_KERN_SHSTK. With KERN=y and USER=n no slot would be pushed,
and regs_set_return_ip() would read the word below pt_regs. Should the
macros depend on X86_KERN_SHADOW_STACK? That config does not build
today, so this is from reading only.
Direct writes to regs->ip in kernel-event paths, as far as I read them
(as I understand it, ERETS compares the shadow stack LIP with RIP on the
regular stack; please correct me if that is wrong):
- traps.c, handle_bug(): regs->ip += ud_len or = addr, so every handled
WARN() goes through it.
- alternative.c, FineIBT decoding (two places): regs->ip = *target.
- text-patching.h, int3_emulate_jmp(), used by int3_emulate_call/ret;
callers are in smp_text_poke_int3_handler() (ret, call, jmp, jcc).
int3_emulate_push/pop only touch regs->sp and the regular stack.
Emulation is reached from jump_label.c (JMP; NOP5 is emulated as
JMP32+0), ftrace.c (CALL/JMP32) and static_call.c.
- kgdb: kgdb_arch_set_pc(), the 'c'/'s' commands with an address,
kgdb_skipexception(), and dbg_set_reg(), which memcpy()s into
pt_regs (ip, cs, flags) through dbg_reg_def.
smp_text_poke_int3_handler() is noinstr and must not call out. cet.c has
no noinstr/notrace and is not removed from -pg in the Makefile, so
calling regs_set_return_ip() from there as it is looks unsafe.
I found no caller of arch_kernel_stack_lock_current() yet. If it ends up
before alternative_instructions(), int3_selftest() would run an emulated
call with shadow stacks on.
Not checked: runtime behaviour, whether these paths are reachable in
practice, other writers of regs->ip (tdx, vc-shared, mm/fault.c were not
read).
Thanks,
Andrey
prev parent reply other threads:[~2026-10-31 11:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 21:52 Andrey Zakharov
2026-10-27 22:01 ` Dave Hansen
2026-10-28 19:21 ` s1nkhole
2026-10-28 20:40 ` Borislav Petkov
2026-10-28 20:50 ` Dave Hansen
2026-10-31 11:25 ` Andrey Zakharov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261031112510.105323-1-dedemorow@gmail.com \
--to=dedemorow@gmail.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®