aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/connector
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2011-07-28 21:26:32 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-28 21:26:32 -0400
commit9e8f90dfe58eb19140bc66655170c7aef9eadbf2 (patch)
treeebb225345da45a1bdc2384367122aba97f11b308 /drivers/connector
parent177c27bf05d0ea508e65afdbe4b6998c81e46af5 (diff)
proc_fork_connector: a lockless ->real_parent usage is not safe
proc_fork_connector() uses ->real_parent lockless. This is not safe if copy_process() was called with CLONE_THREAD or CLONE_PARENT, in this case the parent != current can go away at any moment. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Vladimir Zapolskiy <vzapolskiy@gmail.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Evgeniy Polyakov <zbr@ioremap.net> Cc: Evgeniy Polyakov <johnpol@2ka.mipt.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/connector')
-rw-r--r--drivers/connector/cn_proc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index 3ee1fdb31ea7..e55814bc0d06 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -57,6 +57,7 @@ void proc_fork_connector(struct task_struct *task)
57 struct proc_event *ev; 57 struct proc_event *ev;
58 __u8 buffer[CN_PROC_MSG_SIZE]; 58 __u8 buffer[CN_PROC_MSG_SIZE];
59 struct timespec ts; 59 struct timespec ts;
60 struct task_struct *parent;
60 61
61 if (atomic_read(&proc_event_num_listeners) < 1) 62 if (atomic_read(&proc_event_num_listeners) < 1)
62 return; 63 return;
@@ -67,8 +68,11 @@ void proc_fork_connector(struct task_struct *task)
67 ktime_get_ts(&ts); /* get high res monotonic timestamp */ 68 ktime_get_ts(&ts); /* get high res monotonic timestamp */
68 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); 69 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
69 ev->what = PROC_EVENT_FORK; 70 ev->what = PROC_EVENT_FORK;
70 ev->event_data.fork.parent_pid = task->real_parent->pid; 71 rcu_read_lock();
71 ev->event_data.fork.parent_tgid = task->real_parent->tgid; 72 parent = rcu_dereference(task->real_parent);
73 ev->event_data.fork.parent_pid = parent->pid;
74 ev->event_data.fork.parent_tgid = parent->tgid;
75 rcu_read_unlock();
72 ev->event_data.fork.child_pid = task->pid; 76 ev->event_data.fork.child_pid = task->pid;
73 ev->event_data.fork.child_tgid = task->tgid; 77 ev->event_data.fork.child_tgid = task->tgid;
74 78