Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1460728

Re: [PATCH] seccomp: Fix tracer exit notifications during fatal signals

From Kees Cook <keescook@chromium.org>
Newsgroups linux.kernel
Subject Re: [PATCH] seccomp: Fix tracer exit notifications during fatal signals
Date 2016-08-11 20:20 +0200
Message-ID <s52Ke-7mc-9@gated-at.bofh.it> (permalink)
References <s4Lgm-3pe-17@gated-at.bofh.it> <s4ZW1-5uM-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Aug 11, 2016 at 8:12 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> On 08/10, Kees Cook wrote:
>>
>> This fixes a ptrace vs fatal pending signals bug as manifested in seccomp
>> now that ptrace was reordered to happen after ptrace. The short version is
>> that seccomp should not attempt to call do_exit() while fatal signals are
>> pending under a tracer. This was needlessly paranoid. Instead, the syscall
>> can just be skipped and normal signal handling, tracer notification, and
>> process death can happen.
>
> ACK.
>
> I think this change is fine in any case, but...
>
>> The bug happens because when __seccomp_filter() detects
>> fatal_signal_pending(), it calls do_exit() without dequeuing the fatal
>> signal. When do_exit() sends the PTRACE_EVENT_EXIT
>
> I _never_ understood what PTRACE_EVENT_EXIT should actually do. I mean,
> when it should actually stop. This was never defined.

Yeah, agreed. I spent some time reading through what should happen to
__TASK_TRACED during exit and my head spun. :)

>> notification and
>> that task is descheduled, __schedule() notices that there is a fatal
>> signal pending and changes its state from TASK_TRACED to TASK_RUNNING.
>
> And this can happen anyway, with or without this change, with or without
> seccomp. Because another fatal signal can be pending. So PTRACE_EVENT_EXIT
> actually depends on /dev/random.
>
> Perhaps we should finally define what it should do. Say, it should only
> stop if SIGKILL was sent "implicitely" by exit/exec. But as for exec,
> there are more (off-topic) complications, not sure we actually want this...
>
> Nevermind, the main problem is that _any_ change in this area can break
> something. This code is sooooooo old.
>
> But let me repeat, I think this change is fine anyway.
>
> Acked-by: Oleg Nesterov <oleg@redhat.com>

Awesome, thanks!

-Kees

-- 
Kees Cook
Nexus Security

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] seccomp: Fix tracer exit notifications during fatal signals Kees Cook <keescook@chromium.org> - 2016-08-11 01:40 +0200
  Re: [PATCH] seccomp: Fix tracer exit notifications during fatal signals Kyle Huey <me@kylehuey.com> - 2016-08-11 02:20 +0200
  Re: [PATCH] seccomp: Fix tracer exit notifications during fatal signals Andy Lutomirski <luto@amacapital.net> - 2016-08-11 09:30 +0200
    Re: [PATCH] seccomp: Fix tracer exit notifications during fatal signals Kees Cook <keescook@chromium.org> - 2016-08-11 20:10 +0200
  Re: [PATCH] seccomp: Fix tracer exit notifications during fatal  signals Oleg Nesterov <oleg@redhat.com> - 2016-08-11 17:20 +0200
    Re: [PATCH] seccomp: Fix tracer exit notifications during fatal signals Kees Cook <keescook@chromium.org> - 2016-08-11 20:20 +0200
      Re: [PATCH] seccomp: Fix tracer exit notifications during fatal signals Kyle Huey <me@kylehuey.com> - 2016-08-23 05:30 +0200
        Re: [PATCH] seccomp: Fix tracer exit notifications during fatal signals Kees Cook <keescook@chromium.org> - 2016-08-23 22:00 +0200
    Re: [PATCH] seccomp: Fix tracer exit notifications during fatal signals "Robert O'Callahan" <robert@ocallahan.org> - 2016-08-12 05:30 +0200

csiph-web