]> err.no Git - linux-2.6/commit
pids: sys_getsid: fix unsafe *pid usage, fix possible 0 instead of -ESRCH
authorOleg Nesterov <oleg@tv-sign.ru>
Wed, 30 Apr 2008 07:54:28 +0000 (00:54 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 30 Apr 2008 15:29:49 +0000 (08:29 -0700)
commit1dd768c0815334d2319d6377f0750ace075b6142
tree13e3d42f3679ef1a50e276abdbeafccc9cfe1ed0
parent7d8da0962eaee30b4a380ded177349bfbdd6ac46
pids: sys_getsid: fix unsafe *pid usage, fix possible 0 instead of -ESRCH

1. sys_getsid() needs rcu_read_lock() to derive the session _nr, even if
   the task is current, otherwise we can race with another thread which
   does sys_setsid().

2. The task can exit between find_task_by_vpid() and task_session_vnr(),
   in that unlikely case sys_getsid() returns 0 instead of -ESRCH.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/sys.c