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

From: Oleg Nesterov
Date: Tue Dec 01 2009 - 13:28:41 EST


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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/