Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3525950pxf; Mon, 15 Mar 2021 11:30:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw9ANxGiBF0MkwHLlB6sAXMZJHokCbIOhhIa0JSQhuGDQQxZ+wlFMj6xdoTexMcFhIHVvh X-Received: by 2002:a17:906:86c1:: with SMTP id j1mr26010040ejy.373.1615833043034; Mon, 15 Mar 2021 11:30:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833043; cv=none; d=google.com; s=arc-20160816; b=paDwxqVAklwBnwKCOUASM8w1kZwTI/OdCT0BKKJA/oTfuZI83xRVvvLNDcpkrCGUWr ZdZ5hc1y9MgPOIHrWAeK4x3WSKkYkkY9bCyyJoHHjTCYWwwTU7HJqfpQg1NHfZuEOVEh bZI8y7pLZql88gkWXtCOx9PK93bs7Q17WuRvkK0UCJFshkJH6MSmeoSDY9iicsCmV7SM ERONtzw7E0xXr2Gx0QIIMDJZUF2Kwf7atyFtF+ekBL+AEUscoqD+HgA6fTNi7fVchQsn DLpzB7Y6hsbbFpazQRfi0CUsaIPyQMXsHdi+d688pQSZzIklBkwKHDkLPZDOgV/gx9aX p61w== 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=XkjAq38034aw+Qej5FY/SuSUz1abQv+lgE22O99gKvI=; b=oES7cuH7QLJ4QS33UdnfDKWCGL2TsR8BAXsfcQ863CcUbeno71AdxmPfAqoieJqTsx lmAd7IYmJIJWtWPC756mviCW9AP8OuymlSulIWkXcWUJVZiSUnn08jSpyT9jKjS2UaL+ b1PuiT266PcGaPkvcHctKB48xXFjgLKWID/xMLLfoI7HBXH8hJAvLny0au0oi/PWpXBI w7U6ZrpsJih2EPvtTALTysU7GGOpdfJycQLi93AmaBbZ1w4XVt8sc+fTsrydvpRHcrzP q1sBRYF7rExXilSv1VJ4RSZXBV89aXQeyHzDoiRqe9rLr7GHrvPassEXzWbysk2sIRni OrEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FzgLbtEz; 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 s18si12435800ejj.88.2021.03.15.11.29.58; Mon, 15 Mar 2021 11:30:43 -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=FzgLbtEz; 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 S239635AbhCOOct (ORCPT + 99 others); Mon, 15 Mar 2021 10:32:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:35186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233256AbhCOOBO (ORCPT ); Mon, 15 Mar 2021 10:01:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5127364F6A; Mon, 15 Mar 2021 14:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816853; bh=S5ehvWn0HYDPK8sR9NnUSrF0Bdz7/l2F8kFmFfSL5nU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FzgLbtEzq0hsSF6Rs2RDMg9xzxk4OPh7vZpQib/B4zK9PjA2FbFfF4mMY4XHdL+lO sAqIa3/8eZGiMJNjerkATsg3jDiVeotzj0vUzhm/WU8tC40VD7vOqqalm8zVQAbnQO KvRaTxVez3gZqHJD36gnNYU7vrSxdE7f9Y44X60g= 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 4.19 111/120] include/linux/sched/mm.h: use rcu_dereference in in_vfork() Date: Mon, 15 Mar 2021 14:57:42 +0100 Message-Id: <20210315135723.623968305@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@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 8d3b7e731b74..ef54f4b3f1e4 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -167,7 +167,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