Re: [PATCH] entry: Fix missed trap after single-step on system call return

From: Linus Torvalds
Date: Wed Feb 03 2021 - 13:11:54 EST


On Wed, Feb 3, 2021 at 10:00 AM Gabriel Krisman Bertazi
<krisman@xxxxxxxxxxxxx> wrote:
>
> Does the patch below follows your suggestion? I'm setting the
> SYSCALL_WORK shadowing TIF_SINGLESTEP every time, instead of only when
> the child is inside a system call. Is this acceptable?

Looks sane to me.

My main worry would be about "what about the next system call"? It's
not what Kyle's case cares about, but let me just give an example:

- task A traces task B, and starts single-stepping. Task B was *not*
in a system call at this point.

- task B happily executes one instruction at a time, takes a TF
fault, everything is good

- task B now does a system call. That will disable single-stepping
while in the kernel

- task B returns from the system call. TF will be set in eflags, but
the first instruction *after* the system call will execute unless we
go through the system call exit path

So I think the tracer basically misses one instruction when single-stepping.

I think your patch works for this case (because the SYSCALL_EXIT_TRAP
flag stays set until single-stepping is done), so I think it's all
good. But can you verify, just to allay my worry?

Linus