Re: [PATCH] audit: Call tty_audit_push_task() outside preempt disabled region

Oleg Nesterov
2009-12-01T18:28:30Z

On 12/01, Thomas Gleixner wrote:
>
> -void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid)
> +int tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid)
> {
> - struct tty_audit_buf *buf;
> + struct tty_audit_buf *buf = NULL;
> + unsigned long flags;
>
> - spin_lock_irq(&tsk->sighand->siglock);
> - buf = tsk->signal->tty_audit_buf;
> - if (buf)
> + if (!lock_task_sighand(tsk, &flags))
> + return -ESRCH;
> +
> + if (tsk->signal->audit_tty && tsk->signal->tty_audit_buf) {
> + buf = tsk->signal->tty_audit_buf;
> atomic_inc(&buf->count);
> - spin_unlock_irq(&tsk->sighand->siglock);
> + }
> + unlock_task_sighand(tsk, &flags);
> +
> if (!buf)
> - return;
> + return -EPERM;

I think the patch is correct, but it changes the behaviour of
audit_prepare_user_tty() a bit.

Suppose that signal->audit_tty != NULL but signal->tty_audit_buf
is not allocated yet. In this audit_prepare_user_tty() returns 0
before the patch and -EPERM after.

I do not know if this matters, just to be sure this is OK.

Oleg.