Linux-audit Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Grubb <sgrubb@redhat.com>
To: Paul Moore <paul@paul-moore.com>
Cc: rgb@redhat.com, Linux Audit <linux-audit@redhat.com>
Subject: Re: [PATCH v2] audit: Allow auditd to set pid to 0 to end auditing
Date: Wed, 18 Oct 2017 18:49:13 -0400	[thread overview]
Message-ID: <1783879.P869yhf1d1@x2> (raw)
In-Reply-To: <CAHC9VhS2bpckOA3Dm+w8gHXzmP8KH-hXK6+5Qc=_p2d8XEu3ng@mail.gmail.com>

On Wednesday, October 18, 2017 6:31:47 PM EDT Paul Moore wrote:
> > auditd_pid = auditd_pid_vnr();
> > -                       /* only the current auditd can unregister itself
> > */
> > -                       if ((!new_pid) && (new_pid != auditd_pid)) {
> > -                               audit_log_config_change("audit_pid",
> > new_pid, -                                                      
> > auditd_pid, 0); -                               return -EACCES;
> > -                       }
> > -                       /* replacing a healthy auditd is not allowed */
> > -                       if (auditd_pid && new_pid) {
> > -                               audit_log_config_change("audit_pid",
> > new_pid, -                                                      
> > auditd_pid, 0); -                               return -EEXIST;
> > +                       if (auditd_pid) {
> > +                               /* replacing a healthy auditd is not
> > allowed */ +                               if (new_pid) {
> > +                                      
> > audit_log_config_change("audit_pid", +                                   
> >                    new_pid, auditd_pid, 0); +                            
> >           return -EEXIST;
> > +                               }
> > +                               /* only current auditd can unregister
> > itself */ +                               if (pid_vnr(req_pid) !=
> > auditd_pid) { +                                      
> > audit_log_config_change("audit_pid", +                                   
> >                    new_pid, auditd_pid, 0); +                            
> >           return -EACCES;
> > +                               }
> 
> I realize that you reordered the checks to simplify the conditionals,
> but you did reorder the checks ... I'm thinking out loud right now
> trying to figure out if that really matters ... probably not,
> especially since the checks were broken anyway ... and you need
> CAP_AUDIT_CONTROL to even get this far ... we're probably okay.

Yes when refactoring as you suggested I realized that we can also remove some 
checks for new_pid == 0 because if its not, it takes the first "if" which 
returns. Therefore new_pid is guaranteed to be 0 and no check for that is 
needed.  :-)

-Steve

  reply	other threads:[~2017-10-18 22:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-17 22:29 [PATCH v2] audit: Allow auditd to set pid to 0 to end auditing Steve Grubb
2017-10-18 22:31 ` Paul Moore
2017-10-18 22:49   ` Steve Grubb [this message]
2017-10-19 15:39   ` Richard Guy Briggs
2017-10-19 17:45     ` Richard Guy Briggs
2017-10-19 19:39 ` 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=1783879.P869yhf1d1@x2 \
    --to=sgrubb@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=paul@paul-moore.com \
    --cc=rgb@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