From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753899AbbFDSKr (ORCPT ); Thu, 4 Jun 2015 14:10:47 -0400 Received: from mail-vn0-f48.google.com ([209.85.216.48]:43957 "EHLO mail-vn0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752184AbbFDSKo (ORCPT ); Thu, 4 Jun 2015 14:10:44 -0400 MIME-Version: 1.0 In-Reply-To: <20150604180303.GA32421@redhat.com> References: <1433369396-13360-1-git-send-email-tycho.andersen@canonical.com> <20150604180303.GA32421@redhat.com> Date: Thu, 4 Jun 2015 11:10:43 -0700 X-Google-Sender-Auth: jVSdzNEhkuHzD027O1COppoKsgU Message-ID: Subject: Re: [PATCH v2] seccomp: add ptrace options for suspend/resume From: Kees Cook To: Oleg Nesterov Cc: Tycho Andersen , LKML , Linux API , Andy Lutomirski , Will Drewry , Roland McGrath , Pavel Emelyanov , "Serge E. Hallyn" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 4, 2015 at 11:03 AM, Oleg Nesterov 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