Received: by 10.223.185.116 with SMTP id b49csp1054179wrg; Fri, 16 Feb 2018 11:34:14 -0800 (PST) X-Google-Smtp-Source: AH8x22776gNoSb7QZJCgfgauwMlPnslxshxYNN9NasyW0dw6XtU6vLtMNe1+Xz4Dv2FYCmrSSw8X X-Received: by 2002:a17:902:4003:: with SMTP id b3-v6mr6760823pld.154.1518809654551; Fri, 16 Feb 2018 11:34:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518809654; cv=none; d=google.com; s=arc-20160816; b=GHptmzJIzKuWVaYaV7bb3ku8cwwoo/jAvyBGO9isk+pi/wCN1AdKnnB+GzvbW77riG b4a5Tf8npHQBm+gf/UWgeZ/f7MlKZh3URvlpesHWiORSi/kY84V/PtHfMrLa3zxy3ZWe uDLlqiScC0JBdNuk8h5kT/Lt5szpYeA+qPsVeB8qD9n25I4Lfw0DgFj04Kl/XR744eNo q2KUvfW/pLfCbyLNRc1JXvBDDCnnojSdIQX6w/HADN7Pg0iW+/cyesU//iqhOICzy0+l 0qxc5mVfCf83LddCkukRT8OMNDvrzLbvno3Ttig15sgVSAoh83M2gRBQdjLH4Mh9xTj0 HqgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=m/DRaWcUiUZS86jWJOVtItLSo/6ijG87rECFVxZm3Xo=; b=podVqwlHBpW8ef7Pv9SG7Flfs+EkdmIkSS6A8+Xf8e16NWyvS58VKCv+fu4vrDCOl0 8R15MpgNHTcSBupJjh6ZkEaRgExd0uG1+t3yt6IrzvTfXZI2E9H0nHlo5Y9qFcgybhD1 JahXsSxnZEOtTW8FvKm/IPctRUX3H7RWpqzz5VX+W/whHTAQvchqSqWCxjJECDOovID3 ozC7S1qZZzgS1ZyhQAg3FlgmuITldoFCTz9zfCGkpUZxggaRLGaZ5uOdyVO61PkRUhP/ YLo2mr5xmiag7IGvT5hHiFr6D2tWJ7TzxFIVaEIHWB75V2X8p/w7ae69DG20Aednwxvi rMrQ== 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 i124si1638454pgc.589.2018.02.16.11.33.59; Fri, 16 Feb 2018 11:34:14 -0800 (PST) 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 S1757339AbeBPDDT (ORCPT + 99 others); Thu, 15 Feb 2018 22:03:19 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39402 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751050AbeBPDDS (ORCPT ); Thu, 15 Feb 2018 22:03:18 -0500 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 A64A94027E44; Fri, 16 Feb 2018 03:03:17 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-12.rdu2.redhat.com [10.10.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16B4C100F9D9; Fri, 16 Feb 2018 03:03:12 +0000 (UTC) Date: Thu, 15 Feb 2018 21:59:22 -0500 From: Richard Guy Briggs To: Paul Moore Cc: Linux-Audit Mailing List , LKML Subject: Re: [RFC PATCH ghak21 4/4] audit: add parent of refused symlink to audit_names Message-ID: <20180216025922.fmqxidvwk7qpq6gv@madcap2.tricolour.ca> References: <1c5184985e422774329484153b0147c2861e91a7.1518603831.git.rgb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171027 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.6]); Fri, 16 Feb 2018 03:03:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 16 Feb 2018 03:03:17 +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 On 2018-02-15 18:34, Paul Moore wrote: > On Wed, Feb 14, 2018 at 11:18 AM, Richard Guy Briggs wrote: > > Audit link denied events for symlinks were missing the parent PATH > > record. Add it. Since the full pathname may not be available, > > reconstruct it from the path in the nameidata supplied. > > > > See: https://github.com/linux-audit/audit-kernel/issues/21 > > Signed-off-by: Richard Guy Briggs > > --- > > fs/namei.c | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/fs/namei.c b/fs/namei.c > > index 0edf133..bf1c046b 100644 > > --- a/fs/namei.c > > +++ b/fs/namei.c > > @@ -923,6 +923,7 @@ static inline int may_follow_link(struct nameidata *nd) > > const struct inode *inode; > > const struct inode *parent; > > kuid_t puid; > > + char *pathname; > > > > if (!sysctl_protected_symlinks) > > return 0; > > @@ -945,6 +946,14 @@ static inline int may_follow_link(struct nameidata *nd) > > if (nd->flags & LOOKUP_RCU) > > return -ECHILD; > > > > + pathname = kmalloc(PATH_MAX + 1, GFP_KERNEL); > > + if (!pathname) > > + return -ENOMEM; > > + audit_inode(getname_kernel(d_absolute_path(&nd->stack[0].link, pathname, > > + PATH_MAX + 1)), > > + nd->stack[0].link.dentry, 0); > > Hmm, it's been a while since I've looked at the audit vfs/inode code, > but isn't the audit_inode() call directly above effectively a > duplicate of the audit_inode(nd->name, nd->stack[0].link.dentry, 0) > call you added in patch 3/4? It gets the full pathname string of the link, then converts it to a struct filename*, and then below, we feed it that struct filename* with the parent's dentry and the LOOKUP_PARENT flag to drop the last part of the pathname and set the filetype to PARENT. I didn't try, it, but I expect if I feed it parent's dentry above, I'd get only the parent pathname and when I feed it to audit_inode() below it would again drop the last part of the pathname when the LOOKUP_PARENT flag is included, or not label it as a filetype PARENT if we don't include the flag to get the full parent pathname. > > + audit_inode(nd->name, nd->stack[0].link.dentry->d_parent, LOOKUP_PARENT); > > + > > audit_inode(nd->name, nd->stack[0].link.dentry, 0); > > audit_log_link_denied("follow_link", &nd->stack[0].link); > > return -EACCES; > > -- > > 1.8.3.1 > > -- > paul moore > www.paul-moore.com > > -- > Linux-audit mailing list > Linux-audit@redhat.com > https://www.redhat.com/mailman/listinfo/linux-audit - RGB -- Richard Guy Briggs Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635