Re: [PATCH] x86/ptrace: Remove questionable TS_COMPAT usage in ptrace

From: Andy Lutomirski
Date: Mon Jun 20 2016 - 12:40:10 EST


On Mon, Jun 20, 2016 at 8:24 AM, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> On 06/19, Andy Lutomirski wrote:
>>
>> On Sat, Jun 18, 2016 at 10:02 AM, Andy Lutomirski <luto@xxxxxxxxxxxxxx> wrote:
>> Step 1: for 4.7 and for -stable, introduce TS_I386_REGS_POKED. Set it
>> in putreg32. Use it in syscall_get_error, get_nr_restart_syscall,
>> etc. Clear it in do_signal.
>
> do_signal() won't be necessarily called...

True. But I should have said "clear it in prepare_exit_to_usermode",
and the patch I'm just about to send does that.
>
>> I wonder if we could actually get away with doing syscall restart
>> processing before ptrace invocation.
>
> How? this doesn't look possible or I misunderstood.
>
> How about the simple change below for now? IIRC 32-bit task can't use
> "syscall" so if syscall_get_nr() >= 0 then even the wrong TS_COMPAT is
> not that bad, even if it "leaks" to user-mode.

Hmm. That should fix the minor security issue, but it will even
further break cross-arch tracing: now a 32-bit tracer tracing a 64-bit
task that does int $0x80 will malfunction even more than it would
have. Also, it relies on bizarre arch details IMO.

I think I prefer my version, coming momentarily.

--Andy