From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753600AbZLAS2a (ORCPT ); Tue, 1 Dec 2009 13:28:30 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753380AbZLAS23 (ORCPT ); Tue, 1 Dec 2009 13:28:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:64137 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752553AbZLAS23 (ORCPT ); Tue, 1 Dec 2009 13:28:29 -0500 Date: Tue, 1 Dec 2009 19:22:02 +0100 From: Oleg Nesterov To: Thomas Gleixner Cc: Linus Torvalds , Peter Zijlstra , Ingo Molnar , Christoph Hellwig , Nick Piggin , Linux Kernel Mailing List , Al Viro , James Morris Subject: Re: [PATCH] audit: Call tty_audit_push_task() outside preempt disabled region Message-ID: <20091201182202.GA12754@redhat.com> References: <20091130100041.GA29610@infradead.org> <20091130174638.GA9782@elte.hu> <1259616429.26472.499.camel@laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.