Skip to content

pids: initial fixes, unsafe dereference of the special pids

Oleg Nesterov lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2pids: sys_getsid: fix unsafe *pid usage, fix possible 0 instead of -ESRCHkernel/sys.c+20 -130 replies
2/2pids: sys_getpgid: fix unsafe *pid usage, s/tasklist/rcu/kernel/sys.c+21 -150 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] pids: initial fixes, unsafe dereference of the special pids

Without rcu ot tasklist lock held, it is not safe to dereference the result of task_session/task_pgrp. Even if the task == current.

Because we can race with another thread doing setpgrp/setsid, and use the already freed/reused/unmapped memory if preempted.

The problem is old, surprisingly it wasn't noticed before. Fortunately it is not very serious.

We have a lot of users which should be fixed. This series only fixes sys_getsid/sys_getpgid syscalls.

Perhaps we can (should) add rcu lock/unlock to task_xxx_vnr(), but I'm not sure. In any case, I think it is good to factor out pid_vnr() calls like these patches do.

Oleg.