diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2021-03-12 21:08:03 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-03-17 16:34:35 +0100 |
commit | 997e68565f8dcfe2aa2a40a9e6fc38693f97d4dd (patch) | |
tree | 7f4ddd4456270b62830d6070b0558dce6691771b | |
parent | 44bd240d69668fb03aa2e0abb9b30a1b28d60002 (diff) | |
download | linux-stable-997e68565f8dcfe2aa2a40a9e6fc38693f97d4dd.tar.gz linux-stable-997e68565f8dcfe2aa2a40a9e6fc38693f97d4dd.tar.bz2 linux-stable-997e68565f8dcfe2aa2a40a9e6fc38693f97d4dd.zip |
include/linux/sched/mm.h: use rcu_dereference in in_vfork()
[ Upstream commit 149fc787353f65b7e72e05e7b75d34863266c3e2 ]
Fix a sparse warning by using rcu_dereference(). Technically this is a
bug and a sufficiently aggressive compiler could reload the `real_parent'
pointer outside the protection of the rcu lock (and access freed memory),
but I think it's pretty unlikely to happen.
Link: https://lkml.kernel.org/r/20210221194207.1351703-1-willy@infradead.org
Fixes: b18dc5f291c0 ("mm, oom: skip vforked tasks from being selected")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | include/linux/sched/mm.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index efb9e12e7f91..c16f927570b0 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -171,7 +171,8 @@ static inline bool in_vfork(struct task_struct *tsk) * another oom-unkillable task does this it should blame itself. */ rcu_read_lock(); - ret = tsk->vfork_done && tsk->real_parent->mm == tsk->mm; + ret = tsk->vfork_done && + rcu_dereference(tsk->real_parent)->mm == tsk->mm; rcu_read_unlock(); return ret; |