Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f5be2da authored by Richard Guy Briggs's avatar Richard Guy Briggs Committed by Paul Moore
Browse files

audit: move audit_get_tty to reduce scope and kabi changes



The only users of audit_get_tty and audit_put_tty are internal to
audit, so move it out of include/linux/audit.h to kernel.h and create
a proper function rather than inlining it.  This also reduces kABI
changes.

Suggested-by: default avatarPaul Moore <pmoore@redhat.com>
Signed-off-by: default avatarRichard Guy Briggs <rgb@redhat.com>
[PM: line wrapped description]
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent 76a658c2
Loading
Loading
Loading
Loading
+0 −24
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@
#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)
@@ -344,23 +343,6 @@ 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);
@@ -518,12 +500,6 @@ 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,
+17 −0
Original line number Diff line number Diff line
@@ -1866,6 +1866,23 @@ void audit_log_d_path_exe(struct audit_buffer *ab,
	audit_log_format(ab, " exe=(null)");
}

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;
}

void audit_put_tty(struct tty_struct *tty)
{
	tty_kref_put(tty);
}

void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
{
	const struct cred *cred;
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <linux/audit.h>
#include <linux/skbuff.h>
#include <uapi/linux/mqueue.h>
#include <linux/tty.h>

/* AUDIT_NAMES is the number of slots we reserve in the audit_context
 * for saving names from getname().  If we get more names we will allocate
@@ -262,6 +263,9 @@ extern struct audit_entry *audit_dupe_rule(struct audit_krule *old);
extern void audit_log_d_path_exe(struct audit_buffer *ab,
				 struct mm_struct *mm);

extern struct tty_struct *audit_get_tty(struct task_struct *tsk);
extern void audit_put_tty(struct tty_struct *tty);

/* audit watch functions */
#ifdef CONFIG_AUDIT_WATCH
extern void audit_put_watch(struct audit_watch *watch);
+0 −1
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@
#include <asm/unistd.h>
#include <linux/security.h>
#include <linux/list.h>
#include <linux/tty.h>
#include <linux/binfmts.h>
#include <linux/highmem.h>
#include <linux/syscalls.h>