From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
Pavel Emelyanov <xemul@openvz.org>,
Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] pids: document task_pgrp/task_session is not safe without tasklist/rcu
Date: Fri, 16 Jan 2009 06:55:13 +0100 [thread overview]
Message-ID: <20090116055513.GA28121@redhat.com> (raw)
Even if task == current, it is not safe to dereference the result of
task_pgrp/task_session. We can race with another thread which changes
the special pid via setpgid/setsid.
Document this. The next 2 patches give an example of the unsafe usage,
we have more bad users.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
--- CUR/include/linux/sched.h~SP_1_COMMENT 2009-01-12 23:07:48.000000000 +0100
+++ CUR/include/linux/sched.h 2009-01-16 02:13:50.000000000 +0100
@@ -1449,6 +1449,13 @@ static inline struct pid *task_tgid(stru
return task->group_leader->pids[PIDTYPE_PID].pid;
}
+/*
+ * Without tasklist or rcu lock it is not safe to dereference
+ * the result of task_pgrp/task_session even if task == current,
+ * we can race with another thread doing sys_setsid/sys_setpgid.
+ *
+ */
+
static inline struct pid *task_pgrp(struct task_struct *task)
{
return task->group_leader->pids[PIDTYPE_PGID].pid;
reply other threads:[~2009-01-16 5:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20090116055513.GA28121@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sukadev@linux.vnet.ibm.com \
--cc=xemul@openvz.org \
/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.