Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3529223pxf; Mon, 15 Mar 2021 11:35:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW8F7o79TKUP2vsGoyTAyv4r7qlebvKcwlyNkHbKTLa0Dv5Y6L/B6E33XIgy/VFpvloI3Y X-Received: by 2002:a17:906:23e9:: with SMTP id j9mr24587833ejg.78.1615833309558; Mon, 15 Mar 2021 11:35:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833309; cv=none; d=google.com; s=arc-20160816; b=jNzFFbtYvmyF0Y4GfUIMlsxg4ms1Q3ZnUSyRxsAUC2Qf6lkGT8AK1XZiivpioJ/mP7 8bDVVsz2rWXCd1kljTZ4K1UU7jmXgGhbyO0KMTAU25ZtiyLKdUB6c4nzCoPgdlEmxfAq hmRAuWb0M4qfj5iOw8WBEkQ5xA6entBq+TnaX/ezTsnRVe9TNHfS2C395gEs6gLCVpQw +h7C0pknoAb+nX1tfFYHjeauGFX9A+3SaEwjACkv7vpxeo4IFpglVu3kE1Nt8AmXoz99 aRjMAeFnxSqaeJGcPLE61omiECZVYJFe5jpHJeCRTR1Yy+37S0pE38/q4c6xZR1r1uFU qllw== 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=NnG/f4NHcBGEhDn7h19DgdEKySq5hbu5208wQ6MRjXI=; b=hmyKZAMicvPyD8t3MJ78rWhb1P16QMuv8LNT1enQSLiP4kw/RcGQwary0yefTieVbO KWVbo2rLJtTkM36CYv7vBunZpcYxCqooPzZj0nedLSWE34RZpv+9pdUKURsmo44LREG5 FLjCXG9rbXUeXbEaJ4lua4PJQpeTSq+TXjPshqqfQL6Q9uYEx3NtduZkDlI0Vz0f7Unn XC+57JpkXcgSEBxLPzg+dQELIFQPDXCMTvOKuX7Dfn+TuJe99kg27KbevhZhAcLgQSMW J5q1jE5fVS4SUJrKCpbfWXSLcP1Vpf19UhoJSPSOVGZw3wPALI2Y2bC1swhv2YJTL8Be Qvkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ByfJl7Hj; 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 m22si11168701ejr.463.2021.03.15.11.34.47; Mon, 15 Mar 2021 11:35:09 -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=ByfJl7Hj; 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 S238598AbhCOOor (ORCPT + 99 others); Mon, 15 Mar 2021 10:44:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:51040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233519AbhCOOEB (ORCPT ); Mon, 15 Mar 2021 10:04:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F00DA64F0A; Mon, 15 Mar 2021 14:03:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817040; bh=IVTg84+G1khuab8C13rVN6gswVwBOlr/7Nji6DjvZWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ByfJl7HjqkLKP3yojnfm8W3aBUyLq8aiOBpJlJlg8GDjuBpjFAOV/88K+bRAk5xMw UVAh3cyC3Hj/JJu1N4WmX71Ft0AChLvIxlnewMkrICTv1jaAFIYw0g5BIIduAYdSyf XjZXhyQuAcKqjJeLo35S85+jBOSrANG8XxSTCuZs= 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.10 259/290] include/linux/sched/mm.h: use rcu_dereference in in_vfork() Date: Mon, 15 Mar 2021 14:55:52 +0100 Message-Id: <20210315135550.766623942@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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 d5ece7a9a403..dc1f4dcd9a82 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