linux-audit.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Richard Guy Briggs <rgb@redhat.com>
Cc: Linux-Audit Mailing List <linux-audit@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	sgrubb@redhat.com, omosnace@redhat.com,
	Eric Paris <eparis@parisplace.org>
Subject: Re: [PATCH ghak120] audit: trigger accompanying records when no rules present
Date: Thu, 27 Feb 2020 20:02:06 -0500	[thread overview]
Message-ID: <CAHC9VhTXFg_w8xJChPZZFY=HMpF722p-_NYy=06xjSkLFSCzbg@mail.gmail.com> (raw)
In-Reply-To: <e75e80e820f215d2311941e083580827f6c1dbb6.1582059594.git.rgb@redhat.com>

On Tue, Feb 18, 2020 at 4:01 PM Richard Guy Briggs <rgb@redhat.com> wrote:
>
> When there are no audit rules registered, mandatory records (config,
> etc.) are missing their accompanying records (syscall, proctitle, etc.).
>
> This is due to audit context dummy set on syscall entry based on absence
> of rules that signals that no other records are to be printed.
>
> Clear the dummy bit in auditsc_set_stamp() when the first record of an
> event is generated.
>
> Please see upstream github issue
> https://github.com/linux-audit/audit-kernel/issues/120
>
> Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
> ---
>  kernel/auditsc.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 4effe01ebbe2..31195d122344 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -2176,6 +2176,8 @@ int auditsc_get_stamp(struct audit_context *ctx,
>         t->tv_sec  = ctx->ctime.tv_sec;
>         t->tv_nsec = ctx->ctime.tv_nsec;
>         *serial    = ctx->serial;
> +       if (ctx->dummy)
> +               ctx->dummy = 0;

Two comments:

* Why even bother checking to see if ctx->dummy is true?  If it is
true you set it to false/0; if it is already false you leave it alone.
Either way ctx->dummy is going to be set to false when you are past
these two lines, might as well just always set ctx->dummy to false/0.

* Why are you setting ->dummy to false in auditsc_get_stamp() and not
someplace a bit more obvious like audit_log_start()?  Is it because
auditsc_get_stamp() only gets called once per event?  I'm willing to
take the "hit" of one extra assignment in audit_log_start() to keep
this in a more obvious place and not buried in auditsc_get_stamp().

-- 
paul moore
www.paul-moore.com

WARNING: multiple messages have this Message-ID (diff)
From: Paul Moore <paul@paul-moore.com>
To: Richard Guy Briggs <rgb@redhat.com>
Cc: Linux-Audit Mailing List <linux-audit@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Eric Paris <eparis@parisplace.org>
Subject: Re: [PATCH ghak120] audit: trigger accompanying records when no rules present
Date: Thu, 27 Feb 2020 20:02:06 -0500	[thread overview]
Message-ID: <CAHC9VhTXFg_w8xJChPZZFY=HMpF722p-_NYy=06xjSkLFSCzbg@mail.gmail.com> (raw)
Message-ID: <20200228010206.r1oYwo47L21KF86DwDqXOSEtPtuDfGlelPBsE2q1YCI@z> (raw)
In-Reply-To: <e75e80e820f215d2311941e083580827f6c1dbb6.1582059594.git.rgb@redhat.com>

On Tue, Feb 18, 2020 at 4:01 PM Richard Guy Briggs <rgb@redhat.com> wrote:
>
> When there are no audit rules registered, mandatory records (config,
> etc.) are missing their accompanying records (syscall, proctitle, etc.).
>
> This is due to audit context dummy set on syscall entry based on absence
> of rules that signals that no other records are to be printed.
>
> Clear the dummy bit in auditsc_set_stamp() when the first record of an
> event is generated.
>
> Please see upstream github issue
> https://github.com/linux-audit/audit-kernel/issues/120
>
> Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
> ---
>  kernel/auditsc.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 4effe01ebbe2..31195d122344 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -2176,6 +2176,8 @@ int auditsc_get_stamp(struct audit_context *ctx,
>         t->tv_sec  = ctx->ctime.tv_sec;
>         t->tv_nsec = ctx->ctime.tv_nsec;
>         *serial    = ctx->serial;
> +       if (ctx->dummy)
> +               ctx->dummy = 0;

Two comments:

* Why even bother checking to see if ctx->dummy is true?  If it is
true you set it to false/0; if it is already false you leave it alone.
Either way ctx->dummy is going to be set to false when you are past
these two lines, might as well just always set ctx->dummy to false/0.

* Why are you setting ->dummy to false in auditsc_get_stamp() and not
someplace a bit more obvious like audit_log_start()?  Is it because
auditsc_get_stamp() only gets called once per event?  I'm willing to
take the "hit" of one extra assignment in audit_log_start() to keep
this in a more obvious place and not buried in auditsc_get_stamp().

-- 
paul moore
www.paul-moore.com


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


  parent reply	other threads:[~2020-02-28  1:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18 21:00 [PATCH ghak120] audit: trigger accompanying records when no rules present Richard Guy Briggs
2020-02-18 21:00 ` Richard Guy Briggs
2020-02-28  1:02 ` Paul Moore [this message]
2020-02-28  1:02   ` Paul Moore
2020-03-09 20:31   ` Richard Guy Briggs
2020-03-09 23:55     ` Paul Moore
2020-03-10  0:58       ` Richard Guy Briggs
2020-03-10 12:08         ` Paul Moore

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='CAHC9VhTXFg_w8xJChPZZFY=HMpF722p-_NYy=06xjSkLFSCzbg@mail.gmail.com' \
    --to=paul@paul-moore.com \
    --cc=eparis@parisplace.org \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=omosnace@redhat.com \
    --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;
as well as URLs for NNTP newsgroup(s).