Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754240AbbFJPTJ (ORCPT ); Wed, 10 Jun 2015 11:19:09 -0400 Received: from mail-ig0-f173.google.com ([209.85.213.173]:36057 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752144AbbFJPTE (ORCPT ); Wed, 10 Jun 2015 11:19:04 -0400 Date: Wed, 10 Jun 2015 09:19:00 -0600 From: Tycho Andersen To: Andy Lutomirski Cc: "linux-kernel@vger.kernel.org" , Linux API , Kees Cook , Will Drewry , Roland McGrath , Oleg Nesterov , Pavel Emelyanov , "Serge E. Hallyn" Subject: Re: [PATCH v4] seccomp: add ptrace options for suspend/resume Message-ID: <20150610151900.GB10632@hopstrocity> References: <1433897388-9567-1-git-send-email-tycho.andersen@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2876 Lines: 72 Hi Andy, On Tue, Jun 09, 2015 at 06:08:42PM -0700, Andy Lutomirski wrote: > > > + if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) { > > + if (!config_enabled(CONFIG_CHECKPOINT_RESTORE) || > > + !config_enabled(CONFIG_SECCOMP)) > > + return -EINVAL; > > + > > + if (!capable(CAP_SYS_ADMIN)) > > + return -EPERM; > > I tend to think that we should also require that current not be using > seccomp. Otherwise, in principle, there's a seccomp bypass for > privileged-but-seccomped programs. In any event, CRIU isn't going to > work well if you run the restorer under seccomp, since it'll start > nesting in a manner that probably isn't desirable. Ok, I can resend with that. (sorry Oleg :) > > + } > > + > > /* Avoid intermediate state when all opts are cleared */ > > flags = child->ptrace; > > flags &= ~(PTRACE_O_MASK << PT_OPT_FLAG_SHIFT); > > diff --git a/kernel/seccomp.c b/kernel/seccomp.c > > index 980fd26..645e42d 100644 > > --- a/kernel/seccomp.c > > +++ b/kernel/seccomp.c > > @@ -590,6 +590,10 @@ void secure_computing_strict(int this_syscall) > > { > > int mode = current->seccomp.mode; > > > > + if (config_enabled(CONFIG_CHECKPOINT_RESTORE) && > > + unlikely(current->ptrace & PT_SUSPEND_SECCOMP)) > > + return; > > + > > if (mode == 0) > > return; > > else if (mode == SECCOMP_MODE_STRICT) > > @@ -691,6 +695,10 @@ u32 seccomp_phase1(struct seccomp_data *sd) > > int this_syscall = sd ? sd->nr : > > syscall_get_nr(current, task_pt_regs(current)); > > > > + if (config_enabled(CONFIG_CHECKPOINT_RESTORE) && > > + unlikely(current->ptrace & PT_SUSPEND_SECCOMP)) > > + return SECCOMP_PHASE1_OK; > > + > > If it's not hard, it might still be nice to try to fold this into > mode. This code is rather hot. If it would be a mess, then don't > worry about it for now. The part I'm not immediately clear on is what to do when the tracer dies and the task is running. Oleg pointed out that we can't play with TIF_SECCOMP (or we could, but restoring it in this case is complicated), and I'm not sure if playing with ->seccomp.mode has any similar complications. I /think/ it should be ok to just re-enable it, but I'm not sure. I'd like to leave this patch as is (modulo the extra check) for now. I'm still looking at a way to export mode 2 filters, so there will hopefully be more patches in this area soon and we can reexamine then. Thanks for the review. Tycho -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/