提交 b5b42231 编写于 作者: M Matthew Wilcox (Oracle) 提交者: Cheng Jian

include/linux/sched/mm.h: use rcu_dereference in in_vfork()

stable inclusion
from linux-4.19.181
commit 5bd7642bd62805a91f5e90d4af8b5465515273f5

--------------------------------

[ Upstream commit 149fc787 ]

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: b18dc5f2 ("mm, oom: skip vforked tasks from being selected")
Signed-off-by: NMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: NMiaohe Lin <linmiaohe@huawei.com>
Acked-by: NMichal Hocko <mhocko@suse.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 16301e18
...@@ -167,7 +167,8 @@ static inline bool in_vfork(struct task_struct *tsk) ...@@ -167,7 +167,8 @@ static inline bool in_vfork(struct task_struct *tsk)
* another oom-unkillable task does this it should blame itself. * another oom-unkillable task does this it should blame itself.
*/ */
rcu_read_lock(); 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(); rcu_read_unlock();
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册