linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Tycho Andersen <tycho.andersen@canonical.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux API <linux-api@vger.kernel.org>,
	Andy Lutomirski <luto@amacapital.net>,
	Will Drewry <wad@chromium.org>,
	Roland McGrath <roland@hack.frob.com>,
	Pavel Emelyanov <xemul@parallels.com>,
	"Serge E. Hallyn" <serge.hallyn@ubuntu.com>
Subject: Re: [PATCH v2] seccomp: add ptrace options for suspend/resume
Date: Thu, 4 Jun 2015 11:10:43 -0700	[thread overview]
Message-ID: <CAGXu5jLM8BSwXu8XU9d4QU7mQ=oOh=dYKY3_DcBa_zjrGpK7dQ@mail.gmail.com> (raw)
In-Reply-To: <20150604180303.GA32421@redhat.com>

On Thu, Jun 4, 2015 at 11:03 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> On 06/04, Kees Cook wrote:
>>
>> On Wed, Jun 3, 2015 at 3:09 PM, Tycho Andersen
>> > @@ -556,6 +557,11 @@ static int ptrace_setoptions(struct task_struct *child, unsigned long data)
>> >         if (data & ~(unsigned long)PTRACE_O_MASK)
>> >                 return -EINVAL;
>> >
>> > +#ifdef CONFIG_CHECKPOINT_RESTORE
>> > +       if (data & PTRACE_O_SUSPEND_SECCOMP && !may_suspend_seccomp())
>> > +               return -EPERM;
>> > +#endif
>>
>> I'd like to avoid seeing any #ifdefs added to the .c files. Using a
>> static inline for may_suspend_seccomp() should cause this statement to
>> be eliminated by the compiler.
>
> Agreed, me too, but see below.
>
>> > @@ -590,6 +590,11 @@ void secure_computing_strict(int this_syscall)
>> >  {
>> >         int mode = current->seccomp.mode;
>> >
>> > +#ifdef CONFIG_CHECKPOINT_RESTORE
>> > +       if (unlikely(current->ptrace & PT_SUSPEND_SECCOMP))
>> > +               return;
>> > +#endif
>>
>> Could PT_SUSPEND_SECCOMP be defined to "0" with not
>> CONFIG_CHECKPOINT_RESTORE? Then this wouldn't need ifdefs, and should
>> be similarly eliminated by the compiler.
>
> Yes, but this way we add another ugly ifdef into .h, and if you read
> this code it is not clear that this check should be eliminated by gcc.
>
> I'd suggest
>
>         if (config_enabled(CONFIG_CHECKPOINT_RESTORE) &&
>             unlikely(current->ptrace & PT_SUSPEND_SECCOMP))
>                 return;

Ah! Yes, that makes things nicer.

-Kees

-- 
Kees Cook
Chrome OS Security

  reply	other threads:[~2015-06-04 18:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-03 22:09 [PATCH v2] seccomp: add ptrace options for suspend/resume Tycho Andersen
2015-06-04 16:44 ` Kees Cook
2015-06-04 17:15   ` Tycho Andersen
2015-06-04 18:12     ` Kees Cook
2015-06-04 18:03   ` Oleg Nesterov
2015-06-04 18:10     ` Kees Cook [this message]
2015-06-04 18:31 ` Oleg Nesterov
2015-06-04 21:05   ` Tycho Andersen
2015-06-05 21:16     ` Oleg Nesterov
2015-06-05 21:26       ` Tycho Andersen
2015-06-09 21:22       ` Tycho Andersen
2015-06-09 21:45         ` Kees Cook
2015-06-09 21:52           ` Tycho Andersen
2015-06-09 22:06             ` Kees Cook
2015-06-09 22:13               ` Tycho Andersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGXu5jLM8BSwXu8XU9d4QU7mQ=oOh=dYKY3_DcBa_zjrGpK7dQ@mail.gmail.com' \
    --to=keescook@chromium.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=oleg@redhat.com \
    --cc=roland@hack.frob.com \
    --cc=serge.hallyn@ubuntu.com \
    --cc=tycho.andersen@canonical.com \
    --cc=wad@chromium.org \
    --cc=xemul@parallels.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).