Commit eb84a20e9e6b98dcb33023ad22241d79107a08a7
Committed by
Linus Torvalds
1 parent
5f412b2424
[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: Alan Cox <alan@redhat.com> Acked-by: Arjan 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: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 2 changed files with 10 additions and 1 deletions Side-by-side Diff
kernel/acct.c
... | ... | @@ -483,10 +483,14 @@ |
483 | 483 | ac.ac_ppid = current->parent->tgid; |
484 | 484 | #endif |
485 | 485 | |
486 | - read_lock(&tasklist_lock); /* pin current->signal */ | |
486 | + mutex_lock(&tty_mutex); | |
487 | + /* FIXME: Whoever is responsible for current->signal locking needs | |
488 | + to use the same locking all over the kernel and document it */ | |
489 | + read_lock(&tasklist_lock); | |
487 | 490 | ac.ac_tty = current->signal->tty ? |
488 | 491 | old_encode_dev(tty_devnum(current->signal->tty)) : 0; |
489 | 492 | read_unlock(&tasklist_lock); |
493 | + mutex_unlock(&tty_mutex); | |
490 | 494 | |
491 | 495 | spin_lock_irq(¤t->sighand->siglock); |
492 | 496 | ac.ac_utime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime))); |
kernel/auditsc.c
... | ... | @@ -817,6 +817,8 @@ |
817 | 817 | audit_log_format(ab, " success=%s exit=%ld", |
818 | 818 | (context->return_valid==AUDITSC_SUCCESS)?"yes":"no", |
819 | 819 | context->return_code); |
820 | + | |
821 | + mutex_lock(&tty_mutex); | |
820 | 822 | if (tsk->signal && tsk->signal->tty && tsk->signal->tty->name) |
821 | 823 | tty = tsk->signal->tty->name; |
822 | 824 | else |
... | ... | @@ -838,6 +840,9 @@ |
838 | 840 | context->gid, |
839 | 841 | context->euid, context->suid, context->fsuid, |
840 | 842 | context->egid, context->sgid, context->fsgid, tty); |
843 | + | |
844 | + mutex_unlock(&tty_mutex); | |
845 | + | |
841 | 846 | audit_log_task_info(ab, tsk); |
842 | 847 | if (context->filterkey) { |
843 | 848 | audit_log_format(ab, " key="); |