From patchwork Wed Feb 1 09:13:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Johansen X-Patchwork-Id: 722417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3vCy9Q3b5Cz9s1h; Wed, 1 Feb 2017 20:13:46 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1cYqz1-0001mA-AV; Wed, 01 Feb 2017 09:13:43 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1cYqyn-0001g1-Sd for kernel-team@lists.ubuntu.com; Wed, 01 Feb 2017 09:13:29 +0000 Received: from static-50-53-52-155.bvtn.or.frontiernet.net ([50.53.52.155] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1cYqyn-0004Nk-A1 for kernel-team@lists.ubuntu.com; Wed, 01 Feb 2017 09:13:29 +0000 From: John Johansen To: kernel-team@lists.ubuntu.com Subject: [PATCH 05/14] UBUNTU: SAUCE: apparmor: Don't audit denied access of special apparmor .null file Date: Wed, 1 Feb 2017 01:13:01 -0800 Message-Id: <20170201091310.22695-6-john.johansen@canonical.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201091310.22695-1-john.johansen@canonical.com> References: <20170201091310.22695-1-john.johansen@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com When an fd is disallowed from being inherited during exec, instead of closed it is duped to a special apparmor/.null file. This prevents the fd from being reused by another file in case the application expects the original file on a give fd (eg stdin/stdout etc). This results in a denial message like [32375.561535] audit: type=1400 audit(1478825963.441:358): apparmor="DENIED" operation="file_inherit" namespace="root//lxd-t_" profile="/sbin/dhclient" name="/dev/pts/1" pid=16795 comm="dhclient" requested_mask="wr" denied_mask="wr" fsuid=165536 ouid=165536 Further access to the fd is resultin in the rather useless denial message of [32375.566820] audit: type=1400 audit(1478825963.445:359): apparmor="DENIED" operation="file_perm" namespace="root//lxd-t_" profile="/sbin/dhclient" name="/apparmor/.null" pid=16795 comm="dhclient" requested_mask="w" denied_mask="w" fsuid=165536 ouid=0 since we have the original denial, the noisy and useless .null based denials can be skipped. BugLink: http://bugs.launchpad.net/bugs/1660836 Signed-off-by: John Johansen --- security/apparmor/lsm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index 330437c..a93b701 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -443,6 +443,9 @@ static int common_file_perm(const char *op, struct file *file, u32 mask) struct aa_label *label; int error = 0; + if (file->f_path.dentry == aa_null.dentry) + return -EACCES; + label = aa_begin_current_label(NO_UPDATE); error = aa_file_perm(op, label, file, mask); aa_end_current_label(label);