All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Thomas Gleixner <tglx@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
	oleg@redhat.com, tglx@linutronix.de
Subject: [tip:core/urgent] signal: Fix racy access to __task_cred in kill_pid_info_as_uid()
Date: Thu, 10 Dec 2009 22:09:31 GMT	[thread overview]
Message-ID: <tip-14d8c9f3c09e7fd7b9af80904289fe204f5b93c6@git.kernel.org> (raw)
In-Reply-To: <20091210004703.232302055@linutronix.de>

Commit-ID:  14d8c9f3c09e7fd7b9af80904289fe204f5b93c6
Gitweb:     http://git.kernel.org/tip/14d8c9f3c09e7fd7b9af80904289fe204f5b93c6
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Thu, 10 Dec 2009 00:53:17 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 10 Dec 2009 23:04:11 +0100

signal: Fix racy access to __task_cred in kill_pid_info_as_uid()

kill_pid_info_as_uid() accesses __task_cred() without being in a RCU
read side critical section. tasklist_lock is not protecting that when
CONFIG_TREE_PREEMPT_RCU=y.

Convert the whole tasklist_lock section to rcu and use
lock_task_sighand to prevent the exit race.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
LKML-Reference: <20091210004703.232302055@linutronix.de>
Acked-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/signal.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 6b982f2..7331656 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1175,11 +1175,12 @@ int kill_pid_info_as_uid(int sig, struct siginfo *info, struct pid *pid,
 	int ret = -EINVAL;
 	struct task_struct *p;
 	const struct cred *pcred;
+	unsigned long flags;
 
 	if (!valid_signal(sig))
 		return ret;
 
-	read_lock(&tasklist_lock);
+	rcu_read_lock();
 	p = pid_task(pid, PIDTYPE_PID);
 	if (!p) {
 		ret = -ESRCH;
@@ -1196,14 +1197,16 @@ int kill_pid_info_as_uid(int sig, struct siginfo *info, struct pid *pid,
 	ret = security_task_kill(p, info, sig, secid);
 	if (ret)
 		goto out_unlock;
-	if (sig && p->sighand) {
-		unsigned long flags;
-		spin_lock_irqsave(&p->sighand->siglock, flags);
-		ret = __send_signal(sig, info, p, 1, 0);
-		spin_unlock_irqrestore(&p->sighand->siglock, flags);
+
+	if (sig) {
+		if (lock_task_sighand(p, &flags)) {
+			ret = __send_signal(sig, info, p, 1, 0);
+			unlock_task_sighand(p, &flags);
+		} else
+			ret = -ESRCH;
 	}
 out_unlock:
-	read_unlock(&tasklist_lock);
+	rcu_read_unlock();
 	return ret;
 }
 EXPORT_SYMBOL_GPL(kill_pid_info_as_uid);

  parent reply	other threads:[~2009-12-10 22:09 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-10  0:52 [patch 0/9] Fix various __task_cred related invalid RCU assumptions Thomas Gleixner
2009-12-10  0:52 ` [patch 1/9] sys: Fix missing rcu protection for __task_cred() access Thomas Gleixner
2009-12-10  1:25   ` Paul E. McKenney
2009-12-10  2:29     ` Tetsuo Handa
2009-12-10  2:43   ` Paul E. McKenney
2009-12-10 14:29     ` Oleg Nesterov
2009-12-10 14:44       ` Thomas Gleixner
2009-12-11 13:45       ` David Howells
2009-12-11 13:52         ` Thomas Gleixner
2009-12-10 14:20   ` Oleg Nesterov
2009-12-10 14:38     ` Thomas Gleixner
2009-12-10 15:08     ` [patch 1/9] sys: Fix missing rcu protection for __task_cred()access Tetsuo Handa
2009-12-10 21:17       ` Thomas Gleixner
2009-12-11  3:25         ` Tetsuo Handa
2010-02-08 12:30         ` [PATCH] Update comment on find_task_by_pid_ns Tetsuo Handa
2010-02-08 13:21           ` Oleg Nesterov
2010-02-08 17:07             ` Thomas Gleixner
2010-02-08 17:16               ` Oleg Nesterov
2010-02-08 21:42                 ` Tetsuo Handa
2010-02-09 22:08                   ` Andrew Morton
2010-02-10 16:30                     ` Serge E. Hallyn
2010-02-10 17:57                       ` Andrew Morton
2010-02-10 18:39                         ` Thomas Gleixner
2010-02-10 20:18                           ` Serge E. Hallyn
2010-02-10 20:30                             ` Paul E. McKenney
2010-02-11  1:21                     ` Tetsuo Handa
2010-02-11 12:04     ` [PATCH] sys: Fix missing rcu protection for sys_getpriority Tetsuo Handa
2010-02-12 14:22       ` Serge E. Hallyn
2009-12-10 22:09   ` [tip:core/urgent] sys: Fix missing rcu protection for __task_cred() access tip-bot for Thomas Gleixner
2009-12-10  0:52 ` [patch 2/9] fs: Add missing rcu protection for __task_cred() in sys_ioprio_get Thomas Gleixner
2009-12-10  0:53 ` [patch 3/9] proc: Add missing rcu protection for __task_cred() in task_sig() Thomas Gleixner
2009-12-10  0:53 ` [patch 4/9] oom: Add missing rcu protection of __task_cred() in dump_tasks Thomas Gleixner
2009-12-10  0:53   ` Thomas Gleixner
2009-12-10  1:57   ` KOSAKI Motohiro
2009-12-10  1:57     ` KOSAKI Motohiro
2009-12-10  0:53 ` [patch 5/9] security: Use get_task_cred() in keyctl_session_to_parent() Thomas Gleixner
2009-12-10  2:45   ` Paul E. McKenney
2009-12-10  0:53 ` [patch 6/9] signal: Fix racy access to __task_cred in kill_pid_info_as_uid() Thomas Gleixner
2009-12-10 15:11   ` Oleg Nesterov
2009-12-10 22:09   ` tip-bot for Thomas Gleixner [this message]
2009-12-10  0:53 ` [patch 7/9] signals: Fix more rcu assumptions Thomas Gleixner
2009-12-10 14:34   ` Oleg Nesterov
2009-12-10 14:45     ` Thomas Gleixner
2009-12-11 13:59     ` David Howells
2009-12-10 22:09   ` [tip:core/urgent] " tip-bot for Thomas Gleixner
2009-12-10  0:53 ` [patch 8/9] Documentation: Fix invalid " Thomas Gleixner
2009-12-10 23:55   ` Vegard Nossum
2009-12-11 21:28   ` Arnd Bergmann
2009-12-11 22:01     ` Paul E. McKenney
2009-12-10  0:53 ` [patch 9/9] security: Fix invalid rcu assumptions in comments Thomas Gleixner
2009-12-10  2:28 ` [patch 0/9] Fix various __task_cred related invalid RCU assumptions Paul E. McKenney
2009-12-10  3:15   ` Linus Torvalds
2009-12-10  5:13     ` Peter Zijlstra
2009-12-10  5:34       ` Paul E. McKenney
2009-12-13 18:56         ` Peter Zijlstra
2009-12-14  1:53           ` Paul E. McKenney
2009-12-14 10:17             ` Peter Zijlstra
2009-12-14 14:16               ` Paul E. McKenney
2009-12-14 14:30                 ` Peter Zijlstra
2009-12-15  1:23                   ` Paul E. McKenney
2009-12-11 13:39 ` David Howells
2009-12-11 16:35   ` Paul E. McKenney
2009-12-11 13:41 ` [patch 1/9] sys: Fix missing rcu protection for __task_cred() access David Howells
2009-12-11 13:46 ` [patch 2/9] fs: Add missing rcu protection for __task_cred() in sys_ioprio_get David Howells
2009-12-11 13:46 ` [patch 3/9] proc: Add missing rcu protection for __task_cred() in task_sig() David Howells
2009-12-11 13:49 ` [patch 4/9] oom: Add missing rcu protection of __task_cred() in dump_tasks David Howells
2009-12-11 13:49   ` David Howells
2009-12-11 13:52   ` Thomas Gleixner
2009-12-11 13:52     ` Thomas Gleixner
2009-12-11 13:52 ` [patch 5/9] security: Use get_task_cred() in keyctl_session_to_parent() David Howells
2009-12-11 13:53 ` [patch 6/9] signal: Fix racy access to __task_cred in kill_pid_info_as_uid() David Howells
2009-12-11 14:00 ` [patch 8/9] Documentation: Fix invalid rcu assumptions David Howells
2009-12-11 16:07   ` Linus Torvalds
2009-12-11 16:37     ` Paul E. McKenney
2009-12-11 18:08       ` Thomas Gleixner
2009-12-11 14:01 ` [patch 9/9] security: Fix invalid rcu assumptions in comments David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-14d8c9f3c09e7fd7b9af80904289fe204f5b93c6@git.kernel.org \
    --to=tglx@linutronix.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.