lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 9 Feb 2022 17:31:38 -0500
From:   Paul Moore <paul@...l-moore.com>
To:     Richard Guy Briggs <rgb@...hat.com>
Cc:     Jeff Mahoney <jeffm@...e.com>,
        Linux-Audit Mailing List <linux-audit@...hat.com>,
        LKML <linux-kernel@...r.kernel.org>,
        linux-fsdevel@...r.kernel.org, Eric Paris <eparis@...isplace.org>,
        Steve Grubb <sgrubb@...hat.com>,
        Alexander Viro <viro@...iv.linux.org.uk>,
        Eric Paris <eparis@...hat.com>, Tony Jones <tonyj@...e.de>
Subject: Re: [PATCH v4 2/3] audit: add support for the openat2 syscall

On Wed, Feb 9, 2022 at 5:14 PM Richard Guy Briggs <rgb@...hat.com> wrote:
>
> On 2022-02-09 16:18, Paul Moore wrote:
> > On Wed, Feb 9, 2022 at 10:57 AM Paul Moore <paul@...l-moore.com> wrote:
> > > On Tue, Feb 8, 2022 at 10:44 PM Jeff Mahoney <jeffm@...e.com> wrote:
> > > >
> > > > Hi Richard -
> > > >
> > > > On 5/19/21 16:00, Richard Guy Briggs wrote:
> > > > > The openat2(2) syscall was added in kernel v5.6 with commit fddb5d430ad9
> > > > > ("open: introduce openat2(2) syscall")
> > > > >
> > > > > Add the openat2(2) syscall to the audit syscall classifier.
> > > > >
> > > > > Link: https://github.com/linux-audit/audit-kernel/issues/67
> > > > > Signed-off-by: Richard Guy Briggs <rgb@...hat.com>
> > > > > Link: https://lore.kernel.org/r/f5f1a4d8699613f8c02ce762807228c841c2e26f.1621363275.git.rgb@redhat.com
> > > > > ---
> > > >
> > > > [...]
> > > >
> > > > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > > > > index d775ea16505b..3f59ab209dfd 100644
> > > > > --- a/kernel/auditsc.c
> > > > > +++ b/kernel/auditsc.c
> > > > > @@ -76,6 +76,7 @@
> > > > >  #include <linux/fsnotify_backend.h>
> > > > >  #include <uapi/linux/limits.h>
> > > > >  #include <uapi/linux/netfilter/nf_tables.h>
> > > > > +#include <uapi/linux/openat2.h>
> > > > >
> > > > >  #include "audit.h"
> > > > >
> > > > > @@ -196,6 +197,8 @@ static int audit_match_perm(struct audit_context *ctx, int mask)
> > > > >               return ((mask & AUDIT_PERM_WRITE) && ctx->argv[0] == SYS_BIND);
> > > > >       case AUDITSC_EXECVE:
> > > > >               return mask & AUDIT_PERM_EXEC;
> > > > > +     case AUDITSC_OPENAT2:
> > > > > +             return mask & ACC_MODE((u32)((struct open_how *)ctx->argv[2])->flags);
> > > > >       default:
> > > > >               return 0;
> > > > >       }
> > > >
> > > > ctx->argv[2] holds a userspace pointer and can't be dereferenced like this.
> > > >
> > > > I'm getting oopses, like so:
> > > > BUG: unable to handle page fault for address: 00007fff961bbe70
> > >
> > > Thanks Jeff.
> > >
> > > Yes, this is obviously the wrong thing to being doing; I remember
> > > checking to make sure we placed the audit_openat2_how() hook after the
> > > open_how was copied from userspace, but I missed the argv dereference
> > > in the syscall exit path when reviewing the code.
> > >
> > > Richard, as we are already copying the open_how info into
> > > audit_context::openat2 safely, the obvious fix is to convert
> > > audit_match_perm() to use the previously copied value instead of argv.
> > > If you can't submit a patch for this today please let me know.
> >
> > I haven't heard anything from Richard so I put together a patch which
> > should fix the problem (link below).  It's currently untested, but
> > I've got a kernel building now with the patch ...
>
> Well, the day wasn't over yet...  I've compiled and tested it.

Yes, I tested my patch too and everything looks good on my end.

For future reference, while I didn't explicitly ask you to acknowledge
this thread and that you were working on a patch (I probably should
have), it would have been nice if you could have sent a quick note to
the list.

-- 
paul-moore.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ