From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Hurley Subject: [PATCH 05/15] tty: audit: Take siglock directly Date: Tue, 10 Nov 2015 21:05:50 -0500 Message-ID: <1447207560-16410-6-git-send-email-peter@hurleysoftware.com> References: <1447207560-16410-1-git-send-email-peter@hurleysoftware.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAB26NEN025596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 10 Nov 2015 21:06:23 -0500 Received: from mail-io0-f181.google.com (mail-io0-f181.google.com [209.85.223.181]) by mx1.redhat.com (Postfix) with ESMTPS id C4AFA8DA32 for ; Wed, 11 Nov 2015 02:06:22 +0000 (UTC) Received: by iofh3 with SMTP id h3so21204510iof.3 for ; Tue, 10 Nov 2015 18:06:22 -0800 (PST) In-Reply-To: <1447207560-16410-1-git-send-email-peter@hurleysoftware.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com To: Greg Kroah-Hartman Cc: linux-audit@redhat.com, Jiri Slaby , Peter Hurley List-Id: linux-audit@redhat.com lock_task_sighand() is for situations where the struct task_struct* may disappear while trying to deref the sighand; this never applies to 'current'. Signed-off-by: Peter Hurley --- drivers/tty/tty_audit.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c index 9effa81..5f65653 100644 --- a/drivers/tty/tty_audit.c +++ b/drivers/tty/tty_audit.c @@ -180,22 +180,19 @@ void tty_audit_tiocsti(struct tty_struct *tty, char ch) int tty_audit_push_current(void) { struct tty_audit_buf *buf = ERR_PTR(-EPERM); - struct task_struct *tsk = current; unsigned long flags; - if (!lock_task_sighand(tsk, &flags)) - return -ESRCH; - - if (tsk->signal->audit_tty) { - buf = tsk->signal->tty_audit_buf; + spin_lock_irqsave(¤t->sighand->siglock, flags); + if (current->signal->audit_tty) { + buf = current->signal->tty_audit_buf; if (buf) atomic_inc(&buf->count); } - unlock_task_sighand(tsk, &flags); + spin_unlock_irqrestore(¤t->sighand->siglock, flags); /* * Return 0 when signal->audit_tty set - * but tsk->signal->tty_audit_buf == NULL. + * but current->signal->tty_audit_buf == NULL. */ if (!buf || IS_ERR(buf)) return PTR_ERR(buf); -- 2.6.3