audit: add tty field to LOGIN event
The tty field was missing from AUDIT_LOGIN events. Refactor code to create a new function audit_get_tty(), using it to replace the call in audit_log_task_info() and to add it to audit_log_set_loginuid(). Lock and bump the kref to protect it, adding audit_put_tty() alias to decrement it. Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
7ffb8e317b
commit
db0a6fb5d9
3 changed files with 35 additions and 15 deletions
|
@ -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);
|
||||
return tty;
|
||||
}
|
||||
|
||||
static inline void audit_put_tty(struct tty_struct *tty)
|
||||
{
|
||||
tty_kref_put(tty);
|
||||
}
|
||||
|
||||
extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
|
||||
extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, umode_t mode);
|
||||
extern void __audit_bprm(struct linux_binprm *bprm);
|
||||
|
@ -500,6 +518,12 @@ static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
static inline struct tty_struct *audit_get_tty(struct task_struct *tsk)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
static inline void audit_put_tty(struct tty_struct *tty)
|
||||
{ }
|
||||
static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
|
||||
{ }
|
||||
static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue