Commit eb84a20e authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] audit/accounting: tty locking

Add tty locking around the audit and accounting code.

The whole current->signal-> locking is all deeply strange but it's for
someone else to sort out.  Add rather than replace the lock for acct.c
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Acked-by: default avatarArjan van de Ven <arjan@linux.intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5f412b24
...@@ -483,10 +483,14 @@ static void do_acct_process(struct file *file) ...@@ -483,10 +483,14 @@ static void do_acct_process(struct file *file)
ac.ac_ppid = current->parent->tgid; ac.ac_ppid = current->parent->tgid;
#endif #endif
read_lock(&tasklist_lock); /* pin current->signal */ mutex_lock(&tty_mutex);
/* FIXME: Whoever is responsible for current->signal locking needs
to use the same locking all over the kernel and document it */
read_lock(&tasklist_lock);
ac.ac_tty = current->signal->tty ? ac.ac_tty = current->signal->tty ?
old_encode_dev(tty_devnum(current->signal->tty)) : 0; old_encode_dev(tty_devnum(current->signal->tty)) : 0;
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
mutex_unlock(&tty_mutex);
spin_lock_irq(&current->sighand->siglock); spin_lock_irq(&current->sighand->siglock);
ac.ac_utime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime))); ac.ac_utime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime)));
......
...@@ -817,6 +817,8 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts ...@@ -817,6 +817,8 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
audit_log_format(ab, " success=%s exit=%ld", audit_log_format(ab, " success=%s exit=%ld",
(context->return_valid==AUDITSC_SUCCESS)?"yes":"no", (context->return_valid==AUDITSC_SUCCESS)?"yes":"no",
context->return_code); context->return_code);
mutex_lock(&tty_mutex);
if (tsk->signal && tsk->signal->tty && tsk->signal->tty->name) if (tsk->signal && tsk->signal->tty && tsk->signal->tty->name)
tty = tsk->signal->tty->name; tty = tsk->signal->tty->name;
else else
...@@ -838,6 +840,9 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts ...@@ -838,6 +840,9 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
context->gid, context->gid,
context->euid, context->suid, context->fsuid, context->euid, context->suid, context->fsuid,
context->egid, context->sgid, context->fsgid, tty); context->egid, context->sgid, context->fsgid, tty);
mutex_unlock(&tty_mutex);
audit_log_task_info(ab, tsk); audit_log_task_info(ab, tsk);
if (context->filterkey) { if (context->filterkey) {
audit_log_format(ab, " key="); audit_log_format(ab, " key=");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment