On Wed, Apr 20, 2016 at 7:31 PM, Richard Guy Briggs <rgb(a)redhat.com> wrote:
diff --git a/include/linux/audit.h b/include/linux/audit.h
index b40ed5d..b00beef 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,18 @@ 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;
+}
I'll look at this patch closer tomorrow, but one thing jumped out at
me just now: we should probably have a audit_put_tty(...) to match the
audit_get_tty(...). It seems more obvious than trying to match
audit_get_tty() and tty_kref_put() in a function.
--
paul moore
www.paul-moore.com