Re: [REGRESSION] x86/entry: TIF_SINGLESTEP handling is still broken

From: Yuxuan Shui
Date: Sun Jan 31 2021 - 15:26:17 EST



I didn't understand Kyle's point at first, so I asked for clarification
and will record my understanding below for posterity.

ARCH_SYSCALL_EXIT_WORK was a flag that was checked by various functions
(via SYSCALL_EXIT_WORK) before calling syscall_exit_work, which is what
reports single steps. This flag was supposed to be overridden by
architecture specific definitions. And indeed, x86 overrides it, to
TIF_SINGLESTEP.

However, commit 2991552447707d791d9d81a5dc161f9e9e90b163 renamed
ARCH_SYSCALL_EXIT_WORK to ARCH_SYSCALL_WORK_EXIT, thus x86's definition
no longer override it. Looks like there was an oversight the definition
in x86 wasn't updated.

But renaming the definition in x86 is not enough, as TIF_SINGLESTEP is
set in current_thread_info()->flags, and the same commit has removed the
code that checks those flags. We have to also migrate TIF_SINGLESTEP from
thread info flags to syscall work flags, to make the whole thing work again.