public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
From: Peter Hurley <peter@hurleysoftware.com>
To: Paul Moore <paul@paul-moore.com>, Richard Guy Briggs <rgb@redhat.com>
Cc: linux-audit@redhat.com, Paul Moore <pmoore@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH V4] audit: add tty field to LOGIN event
Date: Tue, 26 Apr 2016 17:57:56 -0700	[thread overview]
Message-ID: <57200E94.8010306@hurleysoftware.com> (raw)
In-Reply-To: <CAHC9VhTiY5s19_W22KpzMTrQG2Y0TethjTxeWFnSFY9PCNNwzg@mail.gmail.com>

On 04/26/2016 03:34 PM, Paul Moore wrote:
> On Fri, Apr 22, 2016 at 1:16 PM, Peter Hurley <peter@hurleysoftware.com> wrote:
>> On 04/21/2016 11:14 AM, Richard Guy Briggs wrote:
>>> diff --git a/include/linux/audit.h b/include/linux/audit.h
>>> index b40ed5d..32cdafb 100644
>>> --- a/include/linux/audit.h
>>> +++ b/include/linux/audit.h
>>> @@ -26,6 +26,7 @@
>>>  #include <linux/sched.h>
>>>  #include <linux/ptrace.h>
>>>  #include <uapi/linux/audit.h>
>>> +#include <linux/tty.h>
>>>
>>>  #define AUDIT_INO_UNSET ((unsigned long)-1)
>>>  #define AUDIT_DEV_UNSET ((dev_t)-1)
>>> @@ -343,6 +344,23 @@ static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
>>>       return tsk->sessionid;
>>>  }
>>>
>>> +static inline struct tty_struct *audit_get_tty(struct task_struct *tsk)
>>> +{
>>> +     struct tty_struct *tty = NULL;
>>> +     unsigned long flags;
>>> +
>>> +     spin_lock_irqsave(&tsk->sighand->siglock, flags);
>>> +     if (tsk->signal)
>>> +             tty = tty_kref_get(tsk->signal->tty);
>>> +     spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
> 
> I just merged Richard's patch, if nothing else it is better than it
> was.  However, I would like to talk about improving things, see below.
> 
>> Not that I'm objecting because I get that you're just refactoring
>> existing code, but I thought I'd point out some stuff.
>>
>> 1. There's no need to check if signal_struct is NULL (ie. tsk->signal)
>>    because if it is, this will blow up trying to dereference the
>>    sighand_struct (ie tsk->sighand).
>>
>> 2. The existing usage is always tsk==current
> 
> Yep, there is only one caller I found that even works on task_structs
> other than current (see audit_log_exit() via audit_free()), although
> even then when it ends up calling into audit_log_task_info() tsk
> should always be current.
> 
> I've got a patch compiling now to get rid of passing around current as
> a a task_struct argument, assuming nothing blows up in testing I'll
> post/merge it.
> 
>> 3. If the idea is to make this invulnerable to tsk being gone, then
>>    the usage is unsafe anyway.
> 
> I don't think that is our concern here.
> 
>> So ultimately (but not necessarily for this patch) I'd prefer that either
>> a. audit use existing tty api instead of open-coding, or
>> b. add any tty api functions required.
> 
> I'm open to suggestions, care to elaborate on either option?

So b) is only necessary if the answer to 3) was yes or if tsk != current.
Otherwise, the new audit_get_tty() is equivalent to get_current_tty()
which is the exported tty core interface for the identical operation.

I was only suggesting b) if get_current_tty() wasn't going to be
sufficient.

> Feel free to elaborate by patch too ;)

I can do that.

Regards,
Peter Hurley

  reply	other threads:[~2016-04-27  0:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21 18:14 [PATCH V4] audit: add tty field to LOGIN event Richard Guy Briggs
2016-04-22  1:29 ` Paul Moore
2016-04-22  3:50   ` Richard Guy Briggs
2016-04-22 15:02     ` Paul Moore
2016-04-22 13:13   ` Steve Grubb
2016-04-22 17:16 ` Peter Hurley
2016-04-26 22:34   ` Paul Moore
2016-04-27  0:57     ` Peter Hurley [this message]
2016-04-28  1:31   ` Richard Guy Briggs
2016-04-28  3:05     ` Peter Hurley
2016-04-28 19:28       ` Richard Guy Briggs
2016-04-28 19:32         ` Peter Hurley
2016-04-28 20:07     ` 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=57200E94.8010306@hurleysoftware.com \
    --to=peter@hurleysoftware.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=pmoore@redhat.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