Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1539220
| From | EunTaik Lee <eun.taik.lee@samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] sched/pid fix use-after free in task_tgid_vnr |
| Date | 2016-12-09 10:40 +0100 |
| Message-ID | <sMpOO-1yx-9@gated-at.bofh.it> (permalink) |
| References | <sMpOO-1yx-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
There is a use-after-free case with below call stack.
pid_nr_ns+0x10/0x38
cgroup_pidlist_start+0x144/0x400
cgroup_seqfile_start+0x1c/0x24
kernfs_seq_start+0x54/0x90
seq_read+0x15c/0x3a8
kernfs_fop_read+0x38/0x160
__vfs_read+0x28/0xc8
vfs_read+0x84/0xfc
A task in the cg_list was dying and the group_leader's
task struct was already freed.
To avoid this task_tgid_vnr needs to take the
rcu_read_lock and check for pid_alive.
Signed-off-by: Eun Taik Lee <eun.taik.lee@samsung.com>
---
include/linux/sched.h | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index e9c009d..ed567bc 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2118,14 +2118,21 @@ static inline pid_t task_tgid_nr(struct task_struct *tsk)
}
pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
+static inline int pid_alive(const struct task_struct *p);
static inline pid_t task_tgid_vnr(struct task_struct *tsk)
{
- return pid_vnr(task_tgid(tsk));
+ pid_t pid = 0;
+
+ rcu_read_lock();
+ if (pid_alive(tsk))
+ pid = pid_vnr(task_tgid(tsk));
+ rcu_read_unlock();
+
+ return pid;
}
-static inline int pid_alive(const struct task_struct *p);
static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_namespace *ns)
{
pid_t pid = 0;
--
1.9.1
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] sched/pid fix use-after free in task_tgid_vnr EunTaik Lee <eun.taik.lee@samsung.com> - 2016-12-09 10:40 +0100
Re: [PATCH] sched/pid fix use-after free in task_tgid_vnr Oleg Nesterov <oleg@redhat.com> - 2016-12-09 18:30 +0100
Re: [PATCH] sched/pid fix use-after free in task_tgid_vnr ebiederm@xmission.com (Eric W. Biederman) - 2016-12-09 23:30 +0100
csiph-web