Re: augenrules: -F missing operation for -k

2021-05-20 Thread Steve Grubb
Hello,

On Thursday, May 20, 2021 12:08:56 PM EDT Steve Grubb wrote:
> On Thursday, May 20, 2021 10:56:00 AM EDT warron.french wrote:
> > Does anybody know what this error means?
> > augenrules: -F missing operation for -k
> > 
> > I cannot figure out what rule is causing this, so I need a little
> > more context to figure out what to look for in my *.rules files under
> > /etc/audit/rules.d.
> 
> It means there is no value associated with a -F name=value construct.

Actually, I misspoke. In the name=vale portion, it didn't find the '=' where 
one was expected. Since it mentions '-k', you might be mixing watch syntax 
with syscall syntax.  -k keyname is valid with watches.  For syscalls its -F 
key=keyname.

-Steve

> I am thinking syslog should have the line number in the rules where this
> comes from.  Do you a -k some where that doesn't look right?




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



Re: augenrules: -F missing operation for -k

2021-05-20 Thread Steve Grubb
On Thursday, May 20, 2021 10:56:00 AM EDT warron.french wrote:
> Does anybody know what this error means?
>   augenrules: -F missing operation for -k
> 
> I cannot figure out what rule is causing this, so I need a little
> more context to figure out what to look for in my *.rules files under
> /etc/audit/rules.d.

It means there is no value associated with a -F name=value construct. I am 
thinking syslog should have the line number in the rules where this comes 
from.  Do you a -k some where that doesn't look right?

-Steve


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



augenrules: -F missing operation for -k

2021-05-20 Thread warron.french
Does anybody know what this error means?
  augenrules: -F missing operation for -k

I cannot figure out what rule is causing this, so I need a little
more context to figure out what to look for in my *.rules files under
/etc/audit/rules.d.


Thanks in advance,
--
Warron French
--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit

Re: [PATCH v4 3/3] audit: add OPENAT2 record to list how

2021-05-20 Thread Christian Brauner
On Wed, May 19, 2021 at 04:00:22PM -0400, Richard Guy Briggs wrote:
> Since the openat2(2) syscall uses a struct open_how pointer to communicate
> its parameters they are not usefully recorded by the audit SYSCALL record's
> four existing arguments.
> 
> Add a new audit record type OPENAT2 that reports the parameters in its
> third argument, struct open_how with fields oflag, mode and resolve.
> 
> The new record in the context of an event would look like:
> time->Wed Mar 17 16:28:53 2021
> type=PROCTITLE msg=audit(1616012933.531:184): 
> proctitle=73797363616C6C735F66696C652F6F70656E617432002F746D702F61756469742D7465737473756974652D737641440066696C652D6F70656E617432
> type=PATH msg=audit(1616012933.531:184): item=1 name="file-openat2" inode=29 
> dev=00:1f mode=0100600 ouid=0 ogid=0 rdev=00:00 
> obj=unconfined_u:object_r:user_tmp_t:s0 nametype=CREATE cap_fp=0 cap_fi=0 
> cap_fe=0 cap_fver=0 cap_frootid=0
> type=PATH msg=audit(1616012933.531:184): item=0 
> name="/root/rgb/git/audit-testsuite/tests" inode=25 dev=00:1f mode=040700 
> ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 
> nametype=PARENT cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
> type=CWD msg=audit(1616012933.531:184): 
> cwd="/root/rgb/git/audit-testsuite/tests"
> type=OPENAT2 msg=audit(1616012933.531:184): oflag=0100302 mode=0600 
> resolve=0xa
> type=SYSCALL msg=audit(1616012933.531:184): arch=c03e syscall=437 
> success=yes exit=4 a0=3 a1=7ffe315f1c53 a2=7ffe315f1550 a3=18 items=2 
> ppid=528 pid=540 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 
> fsgid=0 tty=ttyS0 ses=1 comm="openat2" 
> exe="/root/rgb/git/audit-testsuite/tests/syscalls_file/openat2" 
> subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 
> key="testsuite-1616012933-bjAUcEPO"
> 
> Signed-off-by: Richard Guy Briggs 
> Link: 
> https://lore.kernel.org/r/d23fbb89186754487850367224b060e26f9b7181.1621363275.git@redhat.com
> ---
>  fs/open.c  |  2 ++
>  include/linux/audit.h  | 10 ++
>  include/uapi/linux/audit.h |  1 +
>  kernel/audit.h |  2 ++
>  kernel/auditsc.c   | 18 +-
>  5 files changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/open.c b/fs/open.c
> index e53af13b5835..2a15bec0cf6d 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -1235,6 +1235,8 @@ SYSCALL_DEFINE4(openat2, int, dfd, const char __user *, 
> filename,
>   if (err)
>   return err;
>  
> + audit_openat2_how();
> +
>   /* O_LARGEFILE is only allowed for non-O_PATH. */
>   if (!(tmp.flags & O_PATH) && force_o_largefile())
>   tmp.flags |= O_LARGEFILE;
> diff --git a/include/linux/audit.h b/include/linux/audit.h
> index 283bc91a6932..580a52caf16f 100644
> --- a/include/linux/audit.h
> +++ b/include/linux/audit.h
> @@ -399,6 +399,7 @@ extern int __audit_log_bprm_fcaps(struct linux_binprm 
> *bprm,
> const struct cred *old);
>  extern void __audit_log_capset(const struct cred *new, const struct cred 
> *old);
>  extern void __audit_mmap_fd(int fd, int flags);
> +extern void __audit_openat2_how(struct open_how *how);
>  extern void __audit_log_kern_module(char *name);
>  extern void __audit_fanotify(unsigned int response);
>  extern void __audit_tk_injoffset(struct timespec64 offset);
> @@ -495,6 +496,12 @@ static inline void audit_mmap_fd(int fd, int flags)
>   __audit_mmap_fd(fd, flags);
>  }
>  
> +static inline void audit_openat2_how(struct open_how *how)
> +{
> + if (unlikely(!audit_dummy_context()))
> + __audit_openat2_how(how);
> +}
> +
>  static inline void audit_log_kern_module(char *name)
>  {
>   if (!audit_dummy_context())
> @@ -646,6 +653,9 @@ static inline void audit_log_capset(const struct cred 
> *new,
>  static inline void audit_mmap_fd(int fd, int flags)
>  { }
>  
> +static inline void audit_openat2_how(struct open_how *how)
> +{ }
> +
>  static inline void audit_log_kern_module(char *name)
>  {
>  }
> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> index cd2d8279a5e4..67aea2370c6d 100644
> --- a/include/uapi/linux/audit.h
> +++ b/include/uapi/linux/audit.h
> @@ -118,6 +118,7 @@
>  #define AUDIT_TIME_ADJNTPVAL 1333/* NTP value adjustment */
>  #define AUDIT_BPF1334/* BPF subsystem */
>  #define AUDIT_EVENT_LISTENER 1335/* Task joined multicast read socket */
> +#define AUDIT_OPENAT21336/* Record showing openat2 how 
> args */
>  
>  #define AUDIT_AVC1400/* SE Linux avc denial or grant */
>  #define AUDIT_SELINUX_ERR1401/* Internal SE Linux Errors */
> diff --git a/kernel/audit.h b/kernel/audit.h
> index 1522e100fd17..c5af17905976 100644
> --- a/kernel/audit.h
> +++ b/kernel/audit.h
> @@ -11,6 +11,7 @@
>  #include 
>  #include 
>  #include 
> +#include  // struct open_how
>  
>  /* AUDIT_NAMES is the number of slots we reserve in the audit_context
>   * for saving names from 

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 

Re: [PATCH v4 1/3] audit: replace magic audit syscall class numbers with macros

2021-05-20 Thread Christian Brauner
On Wed, May 19, 2021 at 04:00:20PM -0400, Richard Guy Briggs wrote:
> Replace audit syscall class magic numbers with macros.
> 
> This required putting the macros into new header file
> include/linux/auditsc_classmacros.h since the syscall macros were
> included for both 64 bit and 32 bit in any compat code, causing
> redefinition warnings.
> 
> Signed-off-by: Richard Guy Briggs 
> Link: 
> https://lore.kernel.org/r/2300b1083a32aade7ae7efb95826e8f3f260b1df.1621363275.git@redhat.com

Looks good.
Acked-by: Christian Brauner 

Fwiw, I would explicitly number all enum values in auditsc_class_t not
just the first one.

> ---
>  MAINTAINERS |  1 +
>  arch/alpha/kernel/audit.c   |  8 
>  arch/ia64/kernel/audit.c|  8 
>  arch/parisc/kernel/audit.c  |  8 
>  arch/parisc/kernel/compat_audit.c   |  9 +
>  arch/powerpc/kernel/audit.c | 10 +-
>  arch/powerpc/kernel/compat_audit.c  | 11 ++-
>  arch/s390/kernel/audit.c| 10 +-
>  arch/s390/kernel/compat_audit.c | 11 ++-
>  arch/sparc/kernel/audit.c   | 10 +-
>  arch/sparc/kernel/compat_audit.c| 11 ++-
>  arch/x86/ia32/audit.c   | 11 ++-
>  arch/x86/kernel/audit_64.c  |  8 
>  include/linux/audit.h   |  1 +
>  include/linux/auditsc_classmacros.h | 23 +++
>  kernel/auditsc.c| 12 ++--
>  lib/audit.c | 10 +-
>  lib/compat_audit.c  | 11 ++-
>  18 files changed, 102 insertions(+), 71 deletions(-)
>  create mode 100644 include/linux/auditsc_classmacros.h
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index bd7aff0c120f..3348d12019f9 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3036,6 +3036,7 @@ W:  https://github.com/linux-audit
>  T:   git git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit.git
>  F:   include/asm-generic/audit_*.h
>  F:   include/linux/audit.h
> +F:   include/linux/auditsc_classmacros.h
>  F:   include/uapi/linux/audit.h
>  F:   kernel/audit*
>  F:   lib/*audit.c
> diff --git a/arch/alpha/kernel/audit.c b/arch/alpha/kernel/audit.c
> index 96a9d18ff4c4..81cbd804e375 100644
> --- a/arch/alpha/kernel/audit.c
> +++ b/arch/alpha/kernel/audit.c
> @@ -37,13 +37,13 @@ int audit_classify_syscall(int abi, unsigned syscall)
>  {
>   switch(syscall) {
>   case __NR_open:
> - return 2;
> + return AUDITSC_OPEN;
>   case __NR_openat:
> - return 3;
> + return AUDITSC_OPENAT;
>   case __NR_execve:
> - return 5;
> + return AUDITSC_EXECVE;
>   default:
> - return 0;
> + return AUDITSC_NATIVE;
>   }
>  }
>  
> diff --git a/arch/ia64/kernel/audit.c b/arch/ia64/kernel/audit.c
> index 5192ca899fe6..dba6a74c9ab3 100644
> --- a/arch/ia64/kernel/audit.c
> +++ b/arch/ia64/kernel/audit.c
> @@ -38,13 +38,13 @@ int audit_classify_syscall(int abi, unsigned syscall)
>  {
>   switch(syscall) {
>   case __NR_open:
> - return 2;
> + return AUDITSC_OPEN;
>   case __NR_openat:
> - return 3;
> + return AUDITSC_OPENAT;
>   case __NR_execve:
> - return 5;
> + return AUDITSC_EXECVE;
>   default:
> - return 0;
> + return AUDITSC_NATIVE;
>   }
>  }
>  
> diff --git a/arch/parisc/kernel/audit.c b/arch/parisc/kernel/audit.c
> index 9eb47b2225d2..14244e83db75 100644
> --- a/arch/parisc/kernel/audit.c
> +++ b/arch/parisc/kernel/audit.c
> @@ -47,13 +47,13 @@ int audit_classify_syscall(int abi, unsigned syscall)
>  #endif
>   switch (syscall) {
>   case __NR_open:
> - return 2;
> + return AUDITSC_OPEN;
>   case __NR_openat:
> - return 3;
> + return AUDITSC_OPENAT;
>   case __NR_execve:
> - return 5;
> + return AUDITSC_EXECVE;
>   default:
> - return 0;
> + return AUDITSC_NATIVE;
>   }
>  }
>  
> diff --git a/arch/parisc/kernel/compat_audit.c 
> b/arch/parisc/kernel/compat_audit.c
> index 20c39c9d86a9..1d6347d37d92 100644
> --- a/arch/parisc/kernel/compat_audit.c
> +++ b/arch/parisc/kernel/compat_audit.c
> @@ -1,4 +1,5 @@
>  // SPDX-License-Identifier: GPL-2.0
> +#include 
>  #include 
>  
>  unsigned int parisc32_dir_class[] = {
> @@ -30,12 +31,12 @@ int parisc32_classify_syscall(unsigned syscall)
>  {
>   switch (syscall) {
>   case __NR_open:
> - return 2;
> + return AUDITSC_OPEN;
>   case __NR_openat:
> - return 3;
> + return AUDITSC_OPENAT;
>   case __NR_execve:
> - return 5;
> + return AUDITSC_EXECVE;
>   default:
> - return 1;
> + return AUDITSC_COMPAT;
>   }
>  }
> diff --git