Received: by 10.192.165.156 with SMTP id m28csp54070imm; Wed, 18 Apr 2018 17:12:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+JoIILYyRjWd6cB5sVLj4LAU7BFjgr/6zE8ea8j19YCUY0jx46l38W2GXVwLIbB1Xlb3u2 X-Received: by 2002:a17:902:f24:: with SMTP id 33-v6mr4005706ply.242.1524096776610; Wed, 18 Apr 2018 17:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524096776; cv=none; d=google.com; s=arc-20160816; b=BowBK9PqembJlRSZKp104vI3Qc793oWEBxnXwV4ryuqS/GyvwHCkaIUDgRKGMWvm1O /R9UZWrQG6X5c4FSmo4J8v99e1i3pyoPlrRKBwHD76/022mkvwSYXpO7Mmq9j4Sp8oai CeRRy5gib8/UeTKwUEMRVm9wKO2cMI/wdupkWZV2Lc3TlPa6847W5ghOTuzSH7KCJa8D 2KiB321pUktXl8x5UamsoB/6LBOzmGgKq68VQ4PU2DstA8ppun8dZqm7exHX5okfPMqi OSX968PzV2/Z9WaMIinkbWoBfBpjg2ZzUhFhZZc1+V+ox3oircY55SDmU4wJMAdkvAfy jztg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=VO0q58rcMKWkN/siwvvFa8/OMWdMmhJ6wuGLsi+zmHk=; b=BOZhXEvKzP7ywZXNdB2mN+52nqSFJGvv05iP97Bn2CYuZ+SWTX+oWT80WZax8uiyS5 t7zhG3s8gmEl35F8rM60urb1gOHgjVffYulD9VBxFlKyEuZxsXXklFsf0jaJTv1VZKlP L2BGf4iDdTXkHTzH7HNvCfSaVaHg4tnwbRA1lHJ83OPSKZoIaUK8pfPCXpRcbArNzWjz sc+vbBUeL6i8mabPsSqrhtPDGp7vjASOuhxxGaXEe5kuBz/YldDIRElTzMt4tVXNeR6d 5JMFrgq8fiGhHZxc+lHtx49kLXkYittDCicECPhgKs7aZ7rf6pMuko53MQGby2o8yOww w34A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=wkxzpr3L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg11-v6si2234548plb.171.2018.04.18.17.12.42; Wed, 18 Apr 2018 17:12:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=wkxzpr3L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752826AbeDSALf (ORCPT + 99 others); Wed, 18 Apr 2018 20:11:35 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:39878 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752514AbeDSALc (ORCPT ); Wed, 18 Apr 2018 20:11:32 -0400 Received: by mail-lf0-f66.google.com with SMTP id p142-v6so5155332lfd.6 for ; Wed, 18 Apr 2018 17:11:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VO0q58rcMKWkN/siwvvFa8/OMWdMmhJ6wuGLsi+zmHk=; b=wkxzpr3LQlI2HMMSsys9QSIYBhyFgOrq5OXJ+L7SbBdIfWbKjCAxRB3MyS5HOiVUSG v5nulX9+6Fab6LiVN0PGyCVNvgP7gRb3ny6bK4w+5kjSHaiwR36O6PrO8lAectCZmzRR 4F6J1Wa4LEZpCOIGxuk9nN74N3v4OWDzIu5UTR2XZh5SArUKPQDKzkGo0kH7A3mlGvsY KL3v5G6qIcqUSPK5W30r99Dqy7USUx/sHNR7ewkqZSCTAxKC8xTS5c9Xy8JAv7sBEYL6 zPzoxC4kydChtSYOAu9ND20/ZnQDYmr/E+nUTTpZd7aU8O87HIOveLz2ZXMiRfB3kTmd KKjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VO0q58rcMKWkN/siwvvFa8/OMWdMmhJ6wuGLsi+zmHk=; b=EfBgP6v3f9LzwkRVyKtp9j173FcHAr3+tBc0ztgJRILk9dycTjEH9NT9QZmiGJyVyu cxe5VcaQu5XaYgLu0hXpsWs6K7DEB46wsptzoXsrdKyajktfEiSJcZnujKxtNDKz6h6a 2SmCLUIa1pEfa1MW5jVHKam1NBZVePuwSekLT8QXCpOgIXa/LXj0+20UjQC3it5rXdc+ 3fkba/PlAVVWa5yWH8dfe1p4ZeR3SmmaxPqZAfehzp4ls72/EvBjYHjmuWOXrZGslgYA 0Bn2fDgWxVlItXjvZE2z1O81RKXIf1C4uW7QINlPikYi2+Uq7inTnXHqK3AxU+/oa0AV fWWQ== X-Gm-Message-State: ALQs6tAiwUC/v1wgEtj273oPf2iN3XDy1/w7S+yqw7kHOTQWmvSY7hFf NiXS3SXxCtAGnf859+iayioJEad3Y9KxpXkA+VCR X-Received: by 10.46.132.197 with SMTP id q5mr2593276ljh.14.1524096691420; Wed, 18 Apr 2018 17:11:31 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:a5c3:0:0:0:0:0 with HTTP; Wed, 18 Apr 2018 17:11:30 -0700 (PDT) X-Originating-IP: [108.20.156.165] In-Reply-To: <995b77557010b2f9aed0e10435f7b8536df7a5db.1521179281.git.rgb@redhat.com> References: <995b77557010b2f9aed0e10435f7b8536df7a5db.1521179281.git.rgb@redhat.com> From: Paul Moore Date: Wed, 18 Apr 2018 20:11:30 -0400 Message-ID: Subject: Re: [RFC PATCH ghak32 V2 02/13] audit: check children and threading before allowing containerid To: Richard Guy Briggs Cc: cgroups@vger.kernel.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org, Linux-Audit Mailing List , linux-fsdevel@vger.kernel.org, LKML , netdev@vger.kernel.org, ebiederm@xmission.com, luto@kernel.org, jlayton@redhat.com, carlos@redhat.com, dhowells@redhat.com, viro@zeniv.linux.org.uk, simo@redhat.com, Eric Paris , serge@hallyn.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 16, 2018 at 5:00 AM, Richard Guy Briggs wrote: > Check if a task has existing children or co-threads and refuse to set > the container ID if either are present. Failure to check this could > permit games where a child scratches its parent's back to work around > inheritance and double-setting policy. > > Signed-off-by: Richard Guy Briggs > --- > kernel/auditsc.c | 4 ++++ > 1 file changed, 4 insertions(+) I would just include this in patch 1/2 as I can't think of world where we wouldn't this check. > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > index 29c8482..a6b0a52 100644 > --- a/kernel/auditsc.c > +++ b/kernel/auditsc.c > @@ -2087,6 +2087,10 @@ static int audit_set_containerid_perm(struct task_struct *task, u64 containerid) > /* if we don't have caps, reject */ > if (!capable(CAP_AUDIT_CONTROL)) > return -EPERM; > + /* if task has children or is not single-threaded, deny */ > + if (!list_empty(&task->children) || > + !(thread_group_leader(task) && thread_group_empty(task))) > + return -EPERM; > /* if containerid is unset, allow */ > if (!audit_containerid_set(task)) > return 0; > -- > 1.8.3.1 -- paul moore www.paul-moore.com