public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Paris <eparis@redhat.com>
To: Richard Guy Briggs <rgb@redhat.com>
Cc: linux-audit@redhat.com, linux-kernel@vger.kernel.org,
	Steve Grubb <sgrubb@redhat.com>
Subject: Re: [PATCH] audit: add arch field to seccomp event log
Date: Fri, 14 Feb 2014 16:12:02 -0500	[thread overview]
Message-ID: <1392412322.2760.21.camel@localhost> (raw)
In-Reply-To: <20140214205218.GG18807@madcap2.tricolour.ca>

On Fri, 2014-02-14 at 15:52 -0500, Richard Guy Briggs wrote:
> On 14/02/14, Richard Guy Briggs wrote:
> > On 14/02/14, Eric Paris wrote:
> > > On Fri, 2014-02-14 at 15:23 -0500, Richard Guy Briggs wrote:
> > > > The AUDIT_SECCOMP record looks something like this:
> > > > 
> > > > type=SECCOMP msg=audit(1373478171.953:32775): auid=4325 uid=4325 gid=4325 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0 pid=12381 comm="test" sig=31 syscall=231 compat=0 ip=0x39ea8bca89 code=0x0
> > > > 
> > > > In order to determine what syscall 231 maps to, we need to have the arch= field right before it.
> > > > 
> > > > To see the event, compile this test.c program:
> > > > 
> > > > =====
> > > > int main(void)
> > > > {
> > > >         return seccomp_load(seccomp_init(SCMP_ACT_KILL));
> > > > }
> > > > =====
> > > > 
> > > > gcc -g test.c -o test -lseccomp
> > > > 
> > > > After running the program, find the record by:  ausearch --start recent -m SECCOMP -i
> > > > ---
> > > >  kernel/auditsc.c |    1 +
> > > >  1 files changed, 1 insertions(+), 0 deletions(-)
> > > > 
> > > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > > > index 6874c1f..c464d44 100644
> > > > --- a/kernel/auditsc.c
> > > > +++ b/kernel/auditsc.c
> > > > @@ -2412,6 +2412,7 @@ void __audit_seccomp(unsigned long syscall, long signr, int code)
> > > >  		return;
> > > >  	audit_log_task(ab);
> > > >  	audit_log_format(ab, " sig=%ld", signr);
> > > > +	audit_log_format(ab, " arch=%x", current->audit_context->arch);
> > > 
> > > 
> > > What happens if the task does not have current->audit_context allocated?
> > > Seems possible if signr is non-zero...
> > 
> > I had assumed that since we got this far, that there was an audit
> > context.  This was my first patch:
> 
> Sorry, pulled the trigger too fast:
> 
> ---
>  kernel/auditsc.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 6874c1f..3023d03 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -2406,12 +2406,18 @@ void audit_core_dumps(long signr)
>  void __audit_seccomp(unsigned long syscall, long signr, int code)
>  {
>         struct audit_buffer *ab;
> +       struct audit_context *context audit_get_context(current, 0, 0);

missing '='   but this isn't what audit_get_context() does...   it's
crappy naming...    I'd think a combo of audit_dummy_context() and
current->audit_context would be most appropriate.

>         ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_SECCOMP);
>         if (unlikely(!ab))
>                 return;
>         audit_log_task(ab);
>         audit_log_format(ab, " sig=%ld", signr);
> +       audit_log_format(ab, " arch=");
> +       if (context)
> +               audit_log_format(ab, "(null)");
> +       else
> +               audit_log_format(ab, "%x", context->arch);
>         audit_log_format(ab, " syscall=%ld", syscall);
>         audit_log_format(ab, " compat=%d", is_compat_task());
>         audit_log_format(ab, " ip=0x%lx", KSTK_EIP(current));



  reply	other threads:[~2014-02-14 21:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-14 20:23 [PATCH] audit: add arch field to seccomp event log Richard Guy Briggs
2014-02-14 20:49 ` Eric Paris
2014-02-14 20:50   ` Richard Guy Briggs
2014-02-14 20:52     ` Richard Guy Briggs
2014-02-14 21:12       ` Eric Paris [this message]
2014-02-18 20:50         ` Richard Guy Briggs
2014-02-18 20:55           ` Eric Paris
2014-02-18 21:01           ` Steve Grubb
2014-02-19  3:15             ` Richard Guy Briggs
2014-02-19 19:37               ` Richard Guy Briggs
2014-02-21 23:32                 ` 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=1392412322.2760.21.camel@localhost \
    --to=eparis@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rgb@redhat.com \
    --cc=sgrubb@redhat.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