summaryrefslogtreecommitdiffstats
path: root/lib/test_kmod.c
diff options
context:
space:
mode:
authorShakeel Butt2019-02-01 23:20:54 +0100
committerLinus Torvalds2019-02-02 00:46:23 +0100
commitcefc7ef3c87d02fc9307835868ff721ea12cc597 (patch)
tree30f0e08427a5ee41babfa097ee6df4bf389c2659 /lib/test_kmod.c
parentmm/hotplug: invalid PFNs from pfn_to_online_page() (diff)
downloadkernel-qcow2-linux-cefc7ef3c87d02fc9307835868ff721ea12cc597.tar.gz
kernel-qcow2-linux-cefc7ef3c87d02fc9307835868ff721ea12cc597.tar.xz
kernel-qcow2-linux-cefc7ef3c87d02fc9307835868ff721ea12cc597.zip
mm, oom: fix use-after-free in oom_kill_process
Syzbot instance running on upstream kernel found a use-after-free bug in oom_kill_process. On further inspection it seems like the process selected to be oom-killed has exited even before reaching read_lock(&tasklist_lock) in oom_kill_process(). More specifically the tsk->usage is 1 which is due to get_task_struct() in oom_evaluate_task() and the put_task_struct within for_each_thread() frees the tsk and for_each_thread() tries to access the tsk. The easiest fix is to do get/put across the for_each_thread() on the selected task. Now the next question is should we continue with the oom-kill as the previously selected task has exited? However before adding more complexity and heuristics, let's answer why we even look at the children of oom-kill selected task? The select_bad_process() has already selected the worst process in the system/memcg. Due to race, the selected process might not be the worst at the kill time but does that matter? The userspace can use the oom_score_adj interface to prefer children to be killed before the parent. I looked at the history but it seems like this is there before git history. Link: http://lkml.kernel.org/r/20190121215850.221745-1-shakeelb@google.com Reported-by: syzbot+7fbbfa368521945f0e3d@syzkaller.appspotmail.com Fixes: 6b0c81b3be11 ("mm, oom: reduce dependency on tasklist_lock") Signed-off-by: Shakeel Butt <shakeelb@google.com> Reviewed-by: Roman Gushchin <guro@fb.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: David Rientjes <rientjes@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/test_kmod.c')
0 files changed, 0 insertions, 0 deletions