Linux-audit Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Guy Briggs <rgb@redhat.com>
To: Eric Paris <eparis@redhat.com>
Cc: linux-audit@redhat.com, linux-kernel@vger.kernel.org,
	sgrubb@redhat.com, pmoore@redhat.com, v.rathor@gmail.com,
	ctcard@hotmail.com
Subject: Re: [PATCH V1] audit: add warning that an old auditd may be starved out by a new auditd
Date: Wed, 9 Sep 2015 02:31:54 -0400	[thread overview]
Message-ID: <20150909063154.GL8140@madcap2.tricolour.ca> (raw)
In-Reply-To: <1441724246.27892.89.camel@redhat.com>

On 15/09/08, Eric Paris wrote:
> This is already going to be in the audit log, right? We're going to
> send a CONFIG_CHANGE record with old_pid == the existing auditd. I bet
> it gets delivered to the old auditd.

Actually, delivered by the new auditd is what I'm seeing...  (Tested by
running "auditd -f" to have it show up in the debug output and not in
the log file.)  I did see it once as two seperate messages, one setting
to zero and the next to the new PID, but that may have been a testing
procedure error...

(Note: Why does auditd run in a terminal with -n or -f not respond to ^C?)

> But why is this a printk(KERN_WARN) ?

Because we're still trying to figure out what is going on...  But point
taken, we already should have that information.  If it is listed as a
warning it has a better chance of getting reported.  What do you suggest
instead?


Eric, thanks for taking the time to review this...


> On Mon, 2015-09-07 at 12:48 -0400, Richard Guy Briggs wrote:
> > Nothing prevents a new auditd starting up and replacing a valid
> > audit_pid when an old auditd is still running, effectively starving out
> > the old auditd since audit_pid no longer points to the old valid auditd.
> > 
> > There isn't an easy way to detect if an old auditd is still running on
> > the existing audit_pid other than attempting to send a message to see if
> > it fails.  If no message to auditd has been attempted since auditd died
> > unnaturally or got killed, audit_pid will still indicate it is alive.
> > 
> > Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
> > ---
> > Note: Would it be too bold to actually block the registration of a new
> > auditd if the netlink_getsockbyportid() call succeeded?  Would other
> > checks be appropriate?
> > 
> >  kernel/audit.c |    5 +++++
> >  1 files changed, 5 insertions(+), 0 deletions(-)
> > 
> > diff --git a/kernel/audit.c b/kernel/audit.c
> > index 18cdfe2..1fa1e0d 100644
> > --- a/kernel/audit.c
> > +++ b/kernel/audit.c
> > @@ -872,6 +872,11 @@ static int audit_receive_msg(struct sk_buff
> > *skb, struct nlmsghdr *nlh)
> >  		if (s.mask & AUDIT_STATUS_PID) {
> >  			int new_pid = s.pid;
> >  
> > +			if (audit_pid && new_pid &&
> > +			   !IS_ERR(netlink_getsockbyportid(audit_sock, audit_nlk_portid)))
> > +				pr_warn("auditd replaced by new auditd before normal shutdown: "
> > +					"(old)audit_pid=%d (by)pid=%d new_pid=%d",
> > +					audit_pid, pid, new_pid);
> >  			if ((!new_pid) && (task_tgid_vnr(current) != audit_pid))
> >  				return -EACCES;
> >  			if (audit_enabled != AUDIT_OFF)

- RGB

--
Richard Guy Briggs <rbriggs@redhat.com>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545

      reply	other threads:[~2015-09-09  6:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-07 16:48 [PATCH V1] audit: add warning that an old auditd may be starved out by a new auditd Richard Guy Briggs
2015-09-07 16:58 ` Richard Guy Briggs
2015-09-09 20:50   ` Paul Moore
2015-09-11 10:21     ` Richard Guy Briggs
2015-09-11 18:56       ` Paul Moore
2015-09-13 16:08         ` Richard Guy Briggs
2015-09-14 19:37           ` Paul Moore
2015-09-16 10:24             ` Richard Guy Briggs
2015-09-16 21:45               ` Paul Moore
2015-09-17 11:35                 ` Richard Guy Briggs
2015-09-17 22:40                   ` Paul Moore
2015-09-08 14:57 ` Eric Paris
2015-09-09  6:31   ` Richard Guy Briggs [this message]

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=20150909063154.GL8140@madcap2.tricolour.ca \
    --to=rgb@redhat.com \
    --cc=ctcard@hotmail.com \
    --cc=eparis@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmoore@redhat.com \
    --cc=sgrubb@redhat.com \
    --cc=v.rathor@gmail.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