Skip to content

Commit 149fc78

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
include/linux/sched/mm.h: use rcu_dereference in in_vfork()
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: b18dc5f ("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>
1 parent 0aa41ca commit 149fc78

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • include/linux/sched

include/linux/sched/mm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ static inline bool in_vfork(struct task_struct *tsk)
140140
* another oom-unkillable task does this it should blame itself.
141141
*/
142142
rcu_read_lock();
143-
ret = tsk->vfork_done && tsk->real_parent->mm == tsk->mm;
143+
ret = tsk->vfork_done &&
144+
rcu_dereference(tsk->real_parent)->mm == tsk->mm;
144145
rcu_read_unlock();
145146

146147
return ret;

0 commit comments

Comments
 (0)