Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528082pxf; Mon, 15 Mar 2021 11:33:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx918hTHELxVrfHk0p2bHJCsTT7xkqui9PpEd20DqpCSVIPfrEIe9QJhjKJSIQ9vpfvPET1 X-Received: by 2002:a50:fc94:: with SMTP id f20mr31669139edq.370.1615833211198; Mon, 15 Mar 2021 11:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833211; cv=none; d=google.com; s=arc-20160816; b=K5IVQOYSlWOgeW7f/E/gPias3HkDq6jNTo+250SxMWsx5+H9uiPKhl9QSLOe/xfzzK 7L9aAoEG/T2fv0kKW72L5kHdf9fmdbbnPgprRMPl0wJN13toom0ijt8Sjf2SJG+MUCGm YG+Nu2s3auuzTVowgKqorCWOrnjNvDlmS+g0Iwk18C+UOLxvDzVf5zg0DjbJlIIb3IY3 hc0ag1lUmV/ub1w48lMLPiRE87vXMk16+31GejVPkGNRj1zh1nlU2dZnOio63Nw1TYK5 YqbUGx/jeZJKNUsTVmtLGhQoDH00I2nRML06kawIK3J8MgxqRg1AzlAiwvuBvh2bT3B5 mpPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iGmpU4V2k+Mcw00TWUTlKQ1FNEI+3TfIxV7jPNnM6Dg=; b=NoaHpjlqMlDtWbn27WrOBdJ7NCDCFBMRK36b5ddMe3/SrTwc74Lkf5eNXOz9CMt997 YTZZefxB83GDExa1Go37yFTWXWPXk9Kb8BkGJvzwlgCPdQYW9eH4G3ziJqasFtgmZ9m+ HQCYZlVPIHzpocgIiCA5Rc65XjRletGWUjAkmsvZVduHJOwDuhV+FNsHOBS5XJWckPki z8LhynTiY/NjLT+VY+y0hJfxzklu1q18JIwdBeLDltXIJy7u0XH64Q/MMcnyWpJ10Q4l MEmPqCK8ptBg3ntZNtf6TkYTBgPOkC93clA00aFGfipoLKQvi32f2uC3qSlayTvZRJex td2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FFPYjRbb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t15si12155998ejx.751.2021.03.15.11.33.08; Mon, 15 Mar 2021 11:33:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FFPYjRbb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232842AbhCOOol (ORCPT + 99 others); Mon, 15 Mar 2021 10:44:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:50560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231781AbhCOODw (ORCPT ); Mon, 15 Mar 2021 10:03:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D8D9B64F02; Mon, 15 Mar 2021 14:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817031; bh=1cpXjPpo4Z5OBCeVk7aKUYLS5wTG3/dSdIXOKFik8Zg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FFPYjRbb/dxdWXKE9eCDERImmA9FBdFQAyVcylZIZiBIJsrxlod+qyC+LkHFG34WT jijabTZb4gBsgLvTL/FKj74ElT1C9E/sWn7GRziKpVmxQoSck1UvX2YGlrLBLxITqx tNIVcyz70cbyHxrheohYLrY2QDrX/a3qVfjAAWNw= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Matthew Wilcox (Oracle)" , Miaohe Lin , Michal Hocko , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.11 267/306] include/linux/sched/mm.h: use rcu_dereference in in_vfork() Date: Mon, 15 Mar 2021 14:55:30 +0100 Message-Id: <20210315135516.668510601@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Matthew Wilcox (Oracle) [ 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) Reviewed-by: Miaohe Lin Acked-by: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- include/linux/sched/mm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 1ae08b8462a4..90b2a0bce11c 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -140,7 +140,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; -- 2.30.1