Re: [PATCH v4 2/3] audit: add support for the openat2 syscall

2022-02-09 Thread Paul Moore
On Wed, Feb 9, 2022 at 5:14 PM Richard Guy Briggs  wrote:
>
> On 2022-02-09 16:18, Paul Moore wrote:
> > On Wed, Feb 9, 2022 at 10:57 AM Paul Moore  wrote:
> > > On Tue, Feb 8, 2022 at 10:44 PM Jeff Mahoney  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 
> > > > > Link: 
> > > > > https://lore.kernel.org/r/f5f1a4d8699613f8c02ce762807228c841c2e26f.1621363275.git@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 
> > > > >  #include 
> > > > >  #include 
> > > > > +#include 
> > > > >
> > > > >  #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: 7fff961bbe70
> > >
> > > 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

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit



Re: [PATCH v4 2/3] audit: add support for the openat2 syscall

2022-02-09 Thread Paul Moore
On Wed, Feb 9, 2022 at 4:41 PM Richard Guy Briggs  wrote:
> On 2022-02-09 10:57, Paul Moore wrote:
> > On Tue, Feb 8, 2022 at 10:44 PM Jeff Mahoney  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 
> > > > Link: 
> > > > https://lore.kernel.org/r/f5f1a4d8699613f8c02ce762807228c841c2e26f.1621363275.git@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 
> > > >  #include 
> > > >  #include 
> > > > +#include 
> > > >
> > > >  #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: 7fff961bbe70
> >
> > 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.
>
> Agreed.  It would have been more awkward with the original order of the
> patches.
>
> The syscalls_file test in the audit-testsuite should have caught this.
> https://github.com/rgbriggs/audit-testsuite/commit/1c99021ae27ea23eccce2bb1861df4c9c665cd5b
> The test provided does essentially the same thing.

I would have thought so, but I've now run this multiple times on both
affected and patched kernels but I don't see the page fault on my test
system.

Anyway, that test has now been merged with the audit-testsuite as well
as some cleanup on top to test for the new OPENAT2 record when
applicable.

-- 
paul-moore.com

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit



Re: [PATCH v4 2/3] audit: add support for the openat2 syscall

2022-02-09 Thread Richard Guy Briggs
On 2022-02-09 16:18, Paul Moore wrote:
> On Wed, Feb 9, 2022 at 10:57 AM Paul Moore  wrote:
> > On Tue, Feb 8, 2022 at 10:44 PM Jeff Mahoney  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 
> > > > Link: 
> > > > https://lore.kernel.org/r/f5f1a4d8699613f8c02ce762807228c841c2e26f.1621363275.git@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 
> > > >  #include 
> > > >  #include 
> > > > +#include 
> > > >
> > > >  #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: 7fff961bbe70
> >
> > 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.

> https://lore.kernel.org/linux-audit/16111699.153511.15656610495968926251.stgit@olly/T/#u
> 
> -- 
> paul-moore.com
> 

- 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

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit



Re: [PATCH v4 2/3] audit: add support for the openat2 syscall

2022-02-09 Thread Richard Guy Briggs
On 2022-02-09 10:57, Paul Moore wrote:
> On Tue, Feb 8, 2022 at 10:44 PM Jeff Mahoney  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 
> > > Link: 
> > > https://lore.kernel.org/r/f5f1a4d8699613f8c02ce762807228c841c2e26f.1621363275.git@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 
> > >  #include 
> > >  #include 
> > > +#include 
> > >
> > >  #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: 7fff961bbe70
> 
> 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.

Agreed.  It would have been more awkward with the original order of the
patches.

The syscalls_file test in the audit-testsuite should have caught this.
https://github.com/rgbriggs/audit-testsuite/commit/1c99021ae27ea23eccce2bb1861df4c9c665cd5b
The test provided does essentially the same thing.

I should have a tested patch posted today.

> paul-moore.com

- 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

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit



Re: [PATCH v4 2/3] audit: add support for the openat2 syscall

2022-02-09 Thread Paul Moore
On Wed, Feb 9, 2022 at 10:57 AM Paul Moore  wrote:
> On Tue, Feb 8, 2022 at 10:44 PM Jeff Mahoney  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 
> > > Link: 
> > > https://lore.kernel.org/r/f5f1a4d8699613f8c02ce762807228c841c2e26f.1621363275.git@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 
> > >  #include 
> > >  #include 
> > > +#include 
> > >
> > >  #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: 7fff961bbe70
>
> 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 ...

https://lore.kernel.org/linux-audit/16111699.153511.15656610495968926251.stgit@olly/T/#u

-- 
paul-moore.com

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit



Re: [PATCH v4 2/3] audit: add support for the openat2 syscall

2022-02-09 Thread Paul Moore
On Tue, Feb 8, 2022 at 10:44 PM Jeff Mahoney  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 
> > Link: 
> > https://lore.kernel.org/r/f5f1a4d8699613f8c02ce762807228c841c2e26f.1621363275.git@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 
> >  #include 
> >  #include 
> > +#include 
> >
> >  #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: 7fff961bbe70

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.

-- 
paul-moore.com

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit



Re: [PATCH v4 2/3] audit: add support for the openat2 syscall

2021-05-24 Thread Paul Moore
On Thu, May 20, 2021 at 3:58 AM Christian Brauner
 wrote:
> On Wed, May 19, 2021 at 04:00:21PM -0400, 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 
> > Link: 
> > https://lore.kernel.org/r/f5f1a4d8699613f8c02ce762807228c841c2e26f.1621363275.git@redhat.com
> > ---
> >  arch/alpha/kernel/audit.c   | 2 ++
> >  arch/ia64/kernel/audit.c| 2 ++
> >  arch/parisc/kernel/audit.c  | 2 ++
> >  arch/parisc/kernel/compat_audit.c   | 2 ++
> >  arch/powerpc/kernel/audit.c | 2 ++
> >  arch/powerpc/kernel/compat_audit.c  | 2 ++
> >  arch/s390/kernel/audit.c| 2 ++
> >  arch/s390/kernel/compat_audit.c | 2 ++
> >  arch/sparc/kernel/audit.c   | 2 ++
> >  arch/sparc/kernel/compat_audit.c| 2 ++
> >  arch/x86/ia32/audit.c   | 2 ++
> >  arch/x86/kernel/audit_64.c  | 2 ++
> >  include/linux/auditsc_classmacros.h | 1 +
> >  kernel/auditsc.c| 3 +++
> >  lib/audit.c | 4 
> >  lib/compat_audit.c  | 4 
> >  16 files changed, 36 insertions(+)

...

> > 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 
> >  #include 
> >  #include 
> > +#include 
> >
> >  #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);
>
> That's a lot of dereferncing, casting and masking all at once. Maybe a
> small static inline helper would be good for the sake of legibility? Sm
> like:
>
> static inline u32 audit_openat2_acc(struct open_how *how, int mask)
> {
> u32 flags = how->flags;
> return mask & ACC_MODE(flags);
> }
>
> but not sure. Just seems more legible to me.
> Otherwise.

I'm on the fence about this.  I understand Christian's concern, but I
have a bit of hatred towards single caller functions like this.  Since
this function isn't really high-touch, and I don't expect that to
change in the near future, let's leave the casting mess as-is.

-- 
paul moore
www.paul-moore.com

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit



Re: [PATCH v4 2/3] audit: add support for the openat2 syscall

2021-05-20 Thread Christian Brauner
On Wed, May 19, 2021 at 04:00:21PM -0400, 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 
> Link: 
> https://lore.kernel.org/r/f5f1a4d8699613f8c02ce762807228c841c2e26f.1621363275.git@redhat.com
> ---
>  arch/alpha/kernel/audit.c   | 2 ++
>  arch/ia64/kernel/audit.c| 2 ++
>  arch/parisc/kernel/audit.c  | 2 ++
>  arch/parisc/kernel/compat_audit.c   | 2 ++
>  arch/powerpc/kernel/audit.c | 2 ++
>  arch/powerpc/kernel/compat_audit.c  | 2 ++
>  arch/s390/kernel/audit.c| 2 ++
>  arch/s390/kernel/compat_audit.c | 2 ++
>  arch/sparc/kernel/audit.c   | 2 ++
>  arch/sparc/kernel/compat_audit.c| 2 ++
>  arch/x86/ia32/audit.c   | 2 ++
>  arch/x86/kernel/audit_64.c  | 2 ++
>  include/linux/auditsc_classmacros.h | 1 +
>  kernel/auditsc.c| 3 +++
>  lib/audit.c | 4 
>  lib/compat_audit.c  | 4 
>  16 files changed, 36 insertions(+)
> 
> diff --git a/arch/alpha/kernel/audit.c b/arch/alpha/kernel/audit.c
> index 81cbd804e375..3ab04709784a 100644
> --- a/arch/alpha/kernel/audit.c
> +++ b/arch/alpha/kernel/audit.c
> @@ -42,6 +42,8 @@ int audit_classify_syscall(int abi, unsigned syscall)
>   return AUDITSC_OPENAT;
>   case __NR_execve:
>   return AUDITSC_EXECVE;
> + case __NR_openat2:
> + return AUDITSC_OPENAT2;
>   default:
>   return AUDITSC_NATIVE;
>   }
> diff --git a/arch/ia64/kernel/audit.c b/arch/ia64/kernel/audit.c
> index dba6a74c9ab3..ec61f20ca61f 100644
> --- a/arch/ia64/kernel/audit.c
> +++ b/arch/ia64/kernel/audit.c
> @@ -43,6 +43,8 @@ int audit_classify_syscall(int abi, unsigned syscall)
>   return AUDITSC_OPENAT;
>   case __NR_execve:
>   return AUDITSC_EXECVE;
> + case __NR_openat2:
> + return AUDITSC_OPENAT2;
>   default:
>   return AUDITSC_NATIVE;
>   }
> diff --git a/arch/parisc/kernel/audit.c b/arch/parisc/kernel/audit.c
> index 14244e83db75..f420b5552140 100644
> --- a/arch/parisc/kernel/audit.c
> +++ b/arch/parisc/kernel/audit.c
> @@ -52,6 +52,8 @@ int audit_classify_syscall(int abi, unsigned syscall)
>   return AUDITSC_OPENAT;
>   case __NR_execve:
>   return AUDITSC_EXECVE;
> + case __NR_openat2:
> + return AUDITSC_OPENAT2;
>   default:
>   return AUDITSC_NATIVE;
>   }
> diff --git a/arch/parisc/kernel/compat_audit.c 
> b/arch/parisc/kernel/compat_audit.c
> index 1d6347d37d92..3ec490c28656 100644
> --- a/arch/parisc/kernel/compat_audit.c
> +++ b/arch/parisc/kernel/compat_audit.c
> @@ -36,6 +36,8 @@ int parisc32_classify_syscall(unsigned syscall)
>   return AUDITSC_OPENAT;
>   case __NR_execve:
>   return AUDITSC_EXECVE;
> + case __NR_openat2:
> + return AUDITSC_OPENAT2;
>   default:
>   return AUDITSC_COMPAT;
>   }
> diff --git a/arch/powerpc/kernel/audit.c b/arch/powerpc/kernel/audit.c
> index 6eb18ef77dff..1bcfca5fdf67 100644
> --- a/arch/powerpc/kernel/audit.c
> +++ b/arch/powerpc/kernel/audit.c
> @@ -54,6 +54,8 @@ int audit_classify_syscall(int abi, unsigned syscall)
>   return AUDITSC_SOCKETCALL;
>   case __NR_execve:
>   return AUDITSC_EXECVE;
> + case __NR_openat2:
> + return AUDITSC_OPENAT2;
>   default:
>   return AUDITSC_NATIVE;
>   }
> diff --git a/arch/powerpc/kernel/compat_audit.c 
> b/arch/powerpc/kernel/compat_audit.c
> index b1dc2d1c4bad..251abf79d536 100644
> --- a/arch/powerpc/kernel/compat_audit.c
> +++ b/arch/powerpc/kernel/compat_audit.c
> @@ -39,6 +39,8 @@ int ppc32_classify_syscall(unsigned syscall)
>   return AUDITSC_SOCKETCALL;
>   case __NR_execve:
>   return AUDITSC_EXECVE;
> + case __NR_openat2:
> + return AUDITSC_OPENAT2;
>   default:
>   return AUDITSC_COMPAT;
>   }
> diff --git a/arch/s390/kernel/audit.c b/arch/s390/kernel/audit.c
> index 7e331e1831d4..02051a596b87 100644
> --- a/arch/s390/kernel/audit.c
> +++ b/arch/s390/kernel/audit.c
> @@ -54,6 +54,8 @@ int audit_classify_syscall(int abi, unsigned syscall)
>   return AUDITSC_SOCKETCALL;
>   case __NR_execve:
>   return AUDITSC_EXECVE;
> + case __NR_openat2:
> + return AUDITSC_OPENAT2;
>   default:
>   return AUDITSC_NATIVE;
>   }
> diff --git a/arch/s390/kernel/compat_audit.c b/arch/s390/kernel/compat_audit.c
> index fc3d1c7ad21c..4b3d463e7d97 100644
> --- a/arch/s390/kernel/compat_audit.c
> +++ b/arch/s390/kernel/compat_audit.c
> @@ -40,6 +40,8 @@ int 

[PATCH v4 2/3] audit: add support for the openat2 syscall

2021-05-19 Thread Richard Guy Briggs
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 
Link: 
https://lore.kernel.org/r/f5f1a4d8699613f8c02ce762807228c841c2e26f.1621363275.git@redhat.com
---
 arch/alpha/kernel/audit.c   | 2 ++
 arch/ia64/kernel/audit.c| 2 ++
 arch/parisc/kernel/audit.c  | 2 ++
 arch/parisc/kernel/compat_audit.c   | 2 ++
 arch/powerpc/kernel/audit.c | 2 ++
 arch/powerpc/kernel/compat_audit.c  | 2 ++
 arch/s390/kernel/audit.c| 2 ++
 arch/s390/kernel/compat_audit.c | 2 ++
 arch/sparc/kernel/audit.c   | 2 ++
 arch/sparc/kernel/compat_audit.c| 2 ++
 arch/x86/ia32/audit.c   | 2 ++
 arch/x86/kernel/audit_64.c  | 2 ++
 include/linux/auditsc_classmacros.h | 1 +
 kernel/auditsc.c| 3 +++
 lib/audit.c | 4 
 lib/compat_audit.c  | 4 
 16 files changed, 36 insertions(+)

diff --git a/arch/alpha/kernel/audit.c b/arch/alpha/kernel/audit.c
index 81cbd804e375..3ab04709784a 100644
--- a/arch/alpha/kernel/audit.c
+++ b/arch/alpha/kernel/audit.c
@@ -42,6 +42,8 @@ int audit_classify_syscall(int abi, unsigned syscall)
return AUDITSC_OPENAT;
case __NR_execve:
return AUDITSC_EXECVE;
+   case __NR_openat2:
+   return AUDITSC_OPENAT2;
default:
return AUDITSC_NATIVE;
}
diff --git a/arch/ia64/kernel/audit.c b/arch/ia64/kernel/audit.c
index dba6a74c9ab3..ec61f20ca61f 100644
--- a/arch/ia64/kernel/audit.c
+++ b/arch/ia64/kernel/audit.c
@@ -43,6 +43,8 @@ int audit_classify_syscall(int abi, unsigned syscall)
return AUDITSC_OPENAT;
case __NR_execve:
return AUDITSC_EXECVE;
+   case __NR_openat2:
+   return AUDITSC_OPENAT2;
default:
return AUDITSC_NATIVE;
}
diff --git a/arch/parisc/kernel/audit.c b/arch/parisc/kernel/audit.c
index 14244e83db75..f420b5552140 100644
--- a/arch/parisc/kernel/audit.c
+++ b/arch/parisc/kernel/audit.c
@@ -52,6 +52,8 @@ int audit_classify_syscall(int abi, unsigned syscall)
return AUDITSC_OPENAT;
case __NR_execve:
return AUDITSC_EXECVE;
+   case __NR_openat2:
+   return AUDITSC_OPENAT2;
default:
return AUDITSC_NATIVE;
}
diff --git a/arch/parisc/kernel/compat_audit.c 
b/arch/parisc/kernel/compat_audit.c
index 1d6347d37d92..3ec490c28656 100644
--- a/arch/parisc/kernel/compat_audit.c
+++ b/arch/parisc/kernel/compat_audit.c
@@ -36,6 +36,8 @@ int parisc32_classify_syscall(unsigned syscall)
return AUDITSC_OPENAT;
case __NR_execve:
return AUDITSC_EXECVE;
+   case __NR_openat2:
+   return AUDITSC_OPENAT2;
default:
return AUDITSC_COMPAT;
}
diff --git a/arch/powerpc/kernel/audit.c b/arch/powerpc/kernel/audit.c
index 6eb18ef77dff..1bcfca5fdf67 100644
--- a/arch/powerpc/kernel/audit.c
+++ b/arch/powerpc/kernel/audit.c
@@ -54,6 +54,8 @@ int audit_classify_syscall(int abi, unsigned syscall)
return AUDITSC_SOCKETCALL;
case __NR_execve:
return AUDITSC_EXECVE;
+   case __NR_openat2:
+   return AUDITSC_OPENAT2;
default:
return AUDITSC_NATIVE;
}
diff --git a/arch/powerpc/kernel/compat_audit.c 
b/arch/powerpc/kernel/compat_audit.c
index b1dc2d1c4bad..251abf79d536 100644
--- a/arch/powerpc/kernel/compat_audit.c
+++ b/arch/powerpc/kernel/compat_audit.c
@@ -39,6 +39,8 @@ int ppc32_classify_syscall(unsigned syscall)
return AUDITSC_SOCKETCALL;
case __NR_execve:
return AUDITSC_EXECVE;
+   case __NR_openat2:
+   return AUDITSC_OPENAT2;
default:
return AUDITSC_COMPAT;
}
diff --git a/arch/s390/kernel/audit.c b/arch/s390/kernel/audit.c
index 7e331e1831d4..02051a596b87 100644
--- a/arch/s390/kernel/audit.c
+++ b/arch/s390/kernel/audit.c
@@ -54,6 +54,8 @@ int audit_classify_syscall(int abi, unsigned syscall)
return AUDITSC_SOCKETCALL;
case __NR_execve:
return AUDITSC_EXECVE;
+   case __NR_openat2:
+   return AUDITSC_OPENAT2;
default:
return AUDITSC_NATIVE;
}
diff --git a/arch/s390/kernel/compat_audit.c b/arch/s390/kernel/compat_audit.c
index fc3d1c7ad21c..4b3d463e7d97 100644
--- a/arch/s390/kernel/compat_audit.c
+++ b/arch/s390/kernel/compat_audit.c
@@ -40,6 +40,8 @@ int s390_classify_syscall(unsigned syscall)
return AUDITSC_SOCKETCALL;
case __NR_execve:
return AUDITSC_EXECVE;
+   case __NR_openat2:
+   return AUDITSC_OPENAT2;