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

2021-01-31 Thread Robert O'Callahan
On Mon, Feb 1, 2021 at 12:40 PM Andy Lutomirski wrote: > I admit that PTRACE_SINGLESTEP seems like an odd way to spell "advance > to the end of the syscall", but you're right, it should work. We don't know of any better way to advance to the end of the syscall without executing any userspace inst

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

2021-01-31 Thread Linus Torvalds
On Sun, Jan 31, 2021 at 3:35 PM Linus Torvalds wrote: > > I wonder if the simple solution is to just > > (a) always set one of the SYSCALL_WORK_EXIT bits on the child in > ptrace (exactly to catch the child on system call exit) > > (b) basically revert 299155244770 ("entry: Drop usage of TIF fla

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

2021-01-31 Thread Andy Lutomirski
On Sun, Jan 31, 2021 at 3:39 PM Kyle Huey wrote: > > On Sun, Jan 31, 2021 at 3:36 PM Andy Lutomirski wrote: > > > The odd system call tracing part I have no idea who depends on it > > > (apparently "rr", which I assume is some replay thing), and I suspect > > > our semantics for it has been basic

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

2021-01-31 Thread Kyle Huey
On Sun, Jan 31, 2021 at 3:36 PM Andy Lutomirski wrote: > > The odd system call tracing part I have no idea who depends on it > > (apparently "rr", which I assume is some replay thing), and I suspect > > our semantics for it has been basically random historical one, and > > it's apparently what cha

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

2021-01-31 Thread Andy Lutomirski
> On Jan 31, 2021, at 2:57 PM, Linus Torvalds > wrote: > > On Sun, Jan 31, 2021 at 2:20 PM Andy Lutomirski wrote: >> >> A smallish test that we could stick in selftests would be great if that’s >> straightforward. > > Side note: it would be good to have a test-case for the interaction >

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

2021-01-31 Thread Linus Torvalds
On Sun, Jan 31, 2021 at 3:18 PM Kyle Huey wrote: > > The key to triggering this bug is to enter a ptrace syscall stop and > then use PTRACE_SINGLESTEP to exit it. On a good kernel this will not > result in any userspace code execution in the tracee because on the > way out of the kernel's syscall

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

2021-01-31 Thread Kyle Huey
On Sun, Jan 31, 2021 at 2:27 PM Kyle Huey wrote: > > On Sun, Jan 31, 2021 at 2:20 PM Andy Lutomirski wrote: > > > > > > > > > On Jan 31, 2021, at 2:08 PM, Kyle Huey wrote: > > > > > > On Sun, Jan 31, 2021 at 2:04 PM Andy Lutomirski > > > wrote: > > >> Indeed, and I have tests for this. > > >

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

2021-01-31 Thread Linus Torvalds
On Sun, Jan 31, 2021 at 2:20 PM Andy Lutomirski wrote: > > A smallish test that we could stick in selftests would be great if that’s > straightforward. Side note: it would be good to have a test-case for the interaction with the "block step" code too. I hate our name for it ("block step"?), but

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

2021-01-31 Thread Kyle Huey
On Sun, Jan 31, 2021 at 2:20 PM Andy Lutomirski wrote: > > > > > On Jan 31, 2021, at 2:08 PM, Kyle Huey wrote: > > > > On Sun, Jan 31, 2021 at 2:04 PM Andy Lutomirski > > wrote: > >> Indeed, and I have tests for this. > > > > Do you mean you already have a test case or that you would like a >

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

2021-01-31 Thread Andy Lutomirski
> On Jan 31, 2021, at 2:08 PM, Kyle Huey wrote: > > On Sun, Jan 31, 2021 at 2:04 PM Andy Lutomirski wrote: >> Indeed, and I have tests for this. > > Do you mean you already have a test case or that you would like a > minimized test case? A smallish test that we could stick in selftests wou

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

2021-01-31 Thread Kyle Huey
On Sun, Jan 31, 2021 at 2:04 PM Andy Lutomirski wrote: > Indeed, and I have tests for this. Do you mean you already have a test case or that you would like a minimized test case? - Kyle

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

2021-01-31 Thread Andy Lutomirski
> On Jan 31, 2021, at 1:30 PM, Linus Torvalds > wrote: > > Btw Kyle, do you have a good simple test-case for this? Clearly this > is some weird special case use, and regular single-stepping works > fine. > > Indeed, and I have tests for this. TBH, the TIF_SINGLESTEP code makes no sense,

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

2021-01-31 Thread Linus Torvalds
Btw Kyle, do you have a good simple test-case for this? Clearly this is some weird special case use, and regular single-stepping works fine. Linus

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

2021-01-31 Thread Linus Torvalds
On Sun, Jan 31, 2021 at 12:20 PM Gabriel Krisman Bertazi wrote: > > > I think we should migrate TIF_SINGLESTEP to a SYSCALL_WORK flag as that > is just a simple refactor. That makes no sense at all to me. A single-step has absolutely nothing to do with system calls, and it's also not what any ot

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

2021-01-31 Thread Gabriel Krisman Bertazi
Linus Torvalds writes: > On Sun, Jan 31, 2021 at 10:54 AM Yuxuan Shui wrote: >> >> 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_SINGL

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

2021-01-31 Thread Linus Torvalds
On Sun, Jan 31, 2021 at 10:54 AM Yuxuan Shui wrote: > > 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

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

2021-01-31 Thread Yuxuan Shui
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

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

2021-01-30 Thread Kyle Huey
On Sat, Jan 30, 2021 at 5:56 PM Linus Torvalds wrote: > > On Sat, Jan 30, 2021 at 5:32 PM Kyle Huey wrote: > > > > I tested that with 2991552447707d791d9d81a5dc161f9e9e90b163 reverted > > and Yuxuan's patch applied to Linus's tip rr works and passes all > > tests. > > There's a patch in the -tip

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

2021-01-30 Thread Linus Torvalds
On Sat, Jan 30, 2021 at 5:32 PM Kyle Huey wrote: > > I tested that with 2991552447707d791d9d81a5dc161f9e9e90b163 reverted > and Yuxuan's patch applied to Linus's tip rr works and passes all > tests. There's a patch in the -tip tree that hasn't been merged yet: git://git.kernel.org/pub/scm/linu