Received: by 10.213.65.68 with SMTP id h4csp262062imn; Fri, 16 Mar 2018 02:13:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELuWIf8defNual7g2oKTSlkbLrCBB3beAOJB9Dj+Q0w9ClD8g5t7rZcCiB+7NC+eAlNlHmdz X-Received: by 2002:a17:902:2c43:: with SMTP id m61-v6mr1276925plb.387.1521191588691; Fri, 16 Mar 2018 02:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521191588; cv=none; d=google.com; s=arc-20160816; b=Q7BATRz+OPfBX64Jh4fhDezio6eBUQ1DHKkEsMSBlnBBK+kWLE55ClKjSmX4k753EX R4EjNAgVeC7ihLxwe0USbTYcEYfhh22ee4BlQ5Hcx2HvLj1deIOtNsvvYOf/Q5VjeHTU iWO52VZrhhuVQP/TguRFnYzWRqPsFLizwG65TGVptUCyO7jbOvr25WU38OEuRjWIp5iU iTtt6JmXKisiBnModwrAqyjapyLUMnJKt4KqhdrcfE0IsnAQ47DVuVbbmGWw5fa3V9Sg lcStLg7gnU48AZilnDq/PQKPagXwJEblckc+bOa6NzZ/tdH2ln0pX68jdkoAFblq65HJ 88AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XK9W5T39UiHTK2RBU4r5Ss4y19xDJhTv5Cg57iNhLbE=; b=F+UGH0Z2Z3MTN4NYcg4AQPdR5uZEGG6v6wEerli6EUwm6pQKemDB2up7hoxYg0XsWu 10oc5UpkrEaIP5LCKmi+C0nzplpscQjrtNeavkwH+7MbmOfe2oNdEsa9KIKfd8PVGiaw NTtPYMzqW/2Ab6ERWNrWZh/qN/5//CcQA7jvtOfEKNkVLXSL2SI2tviGP6odNclsBJTD D8+5/Y0I6S4Z5Sow99lVBPz/aJsj3wXLz/w1M5Y8qs73vSMA9n94KStK1qAB6RxUYJUH Gh0WO4WxjLuOcs89ck2x4UItcRzwM/KRTWeIz64OcR5lIMVXeOSN0s/tSB6x4o1+bFgm UtVQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1-v6si5834088pld.401.2018.03.16.02.12.54; Fri, 16 Mar 2018 02:13:08 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753443AbeCPJK4 (ORCPT + 99 others); Fri, 16 Mar 2018 05:10:56 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45046 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750847AbeCPJGO (ORCPT ); Fri, 16 Mar 2018 05:06:14 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4FF98185338; Fri, 16 Mar 2018 09:06:13 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-12.rdu2.redhat.com [10.10.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E40C10B0089; Fri, 16 Mar 2018 09:06:10 +0000 (UTC) From: Richard Guy Briggs To: 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 Cc: luto@kernel.org, jlayton@redhat.com, carlos@redhat.com, viro@zeniv.linux.org.uk, dhowells@redhat.com, simo@redhat.com, eparis@parisplace.org, serge@hallyn.com, ebiederm@xmission.com, madzcar@gmail.com, Richard Guy Briggs Subject: [RFC PATCH ghak32 V2 02/13] audit: check children and threading before allowing containerid Date: Fri, 16 Mar 2018 05:00:29 -0400 Message-Id: <995b77557010b2f9aed0e10435f7b8536df7a5db.1521179281.git.rgb@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 16 Mar 2018 09:06:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 16 Mar 2018 09:06:13 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rgb@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) 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