linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Guy Briggs <rgb@redhat.com>
To: Paul Moore <paul@paul-moore.com>
Cc: Linux-Audit Mailing List <linux-audit@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH ghak21 4/4] audit: add parent of refused symlink to audit_names
Date: Thu, 15 Feb 2018 21:59:22 -0500	[thread overview]
Message-ID: <20180216025922.fmqxidvwk7qpq6gv@madcap2.tricolour.ca> (raw)
In-Reply-To: <CAHC9VhR3u0n9ZSLHYcf0aJR=X=PLkSFPnYffz+=5v669QyasHg@mail.gmail.com>

On 2018-02-15 18:34, Paul Moore wrote:
> On Wed, Feb 14, 2018 at 11:18 AM, Richard Guy Briggs <rgb@redhat.com> 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 <rgb@redhat.com>
> > ---
> >  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 <rgb@redhat.com>
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

  reply	other threads:[~2018-02-16  3:03 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 16:18 [RFC PATCH ghak21 0/4] audit: address ANOM_LINK excess records Richard Guy Briggs
2018-02-14 16:18 ` [RFC PATCH ghak21 1/4] audit: make ANOM_LINK obey audit_enabled and audit_dummy_context Richard Guy Briggs
2018-02-14 17:51   ` Kees Cook
2018-02-15  2:33     ` Richard Guy Briggs
2018-02-15  6:16       ` Kees Cook
2018-02-15 22:51         ` Paul Moore
2018-03-09  0:23           ` Paul Moore
2018-02-14 16:18 ` [RFC PATCH ghak21 2/4] audit: link denied should not directly generate PATH record Richard Guy Briggs
2018-03-09  0:26   ` Paul Moore
2018-03-12  8:01     ` Richard Guy Briggs
2018-02-14 16:18 ` [RFC PATCH ghak21 3/4] audit: add refused symlink to audit_names Richard Guy Briggs
2018-03-09  0:30   ` Paul Moore
2018-03-09  0:33     ` Paul Moore
2018-02-14 16:18 ` [RFC PATCH ghak21 4/4] audit: add parent of " Richard Guy Briggs
2018-02-15 23:34   ` Paul Moore
2018-02-16  2:59     ` Richard Guy Briggs [this message]
2018-02-16 18:56       ` Paul Moore
2018-03-09  0:50   ` Paul Moore
2018-03-12  7:59     ` Richard Guy Briggs
2018-03-12 15:47       ` Paul Moore
2018-02-14 16:49 ` [RFC PATCH ghak21 0/4] audit: address ANOM_LINK excess records Steve Grubb
2018-02-15  3:46   ` Richard Guy Briggs
2018-03-08 11:47     ` Richard Guy Briggs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180216025922.fmqxidvwk7qpq6gv@madcap2.tricolour.ca \
    --to=rgb@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul@paul-moore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).