Re: [PATCH v2] x86/unwind/orc: Read the CS slot without KASAN checking
From: Josh Poimboeuf
Date: Wed Dec 02 2026 - 23:08:37 EST
On Thu, Dec 03, 2026 at 11:54:54AM +0800, Zhao Gongyi wrote:
> The end-of-stack check in unwind_next_frame() calls user_mode(), leaving
> the recovered CS read instrumented by KASAN. Commit e504e74cc3a2
> ("x86/unwind/orc: Disable KASAN checking in the ORC unwinder, part 2")
> converted other recovered register reads to READ_ONCE_NOCHECK(), but
> left this read unchanged. Best-effort unwinding can visit poisoned slots
> within a valid stack range.
>
> Reading /proc/<pid>/stack has reported a two-byte stack-out-of-bounds
> read at this check:
>
> BUG: KASAN: stack-out-of-bounds in user_mode [inline]
> unwind_next_frame
> arch_stack_walk
> stack_trace_save_tsk
> proc_pid_stack
>
> Read the CS slot with READ_ONCE_NOCHECK() as well. Use the word-sized csx
> member to satisfy the macro's size requirement, and test its low two bits
> to preserve the x86-64 user_mode() predicate. The existing stack range
> checks remain in place.
>
> Fixes: ee9f8fce9964 ("x86/unwind: Add the ORC unwinder")
> Signed-off-by: Zhao Gongyi <zhaogongyi@xxxxxxxxxxxxx>
> Link: https://syzkaller.appspot.com/bug?extid=d081d4f4ee906c359975
Acked-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
--
Josh