From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08FEAC433E0 for ; Sun, 21 Feb 2021 19:42:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8E0DE64E4E for ; Sun, 21 Feb 2021 19:42:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E0DE64E4E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E27688D0001; Sun, 21 Feb 2021 14:42:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DD8266B0070; Sun, 21 Feb 2021 14:42:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CEFA18D0001; Sun, 21 Feb 2021 14:42:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id B88B56B006E for ; Sun, 21 Feb 2021 14:42:20 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7F14A813F for ; Sun, 21 Feb 2021 19:42:20 +0000 (UTC) X-FDA: 77843296440.10.2C59202 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id 16B59132 for ; Sun, 21 Feb 2021 19:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=u0pp3pCOXyFx4HcM+EazRcDG24U5Ejg58GS3gMTfMZ0=; b=C7jUF8JP2h9k8W51QsIx4q6vX4 qa/Q+Uu5XQyOpBukK6FV9xz5KloxPhZftUWmLRq8vLhouWFZRISg0yk9ckjHWwBpwMBatn9+REiGm LVEXLgQnraSbMBK6MtzYWlOitUDYvToe/GHuKth6CFAjDqLLEr7YjpTUvGICDOzb+G2yVWcS7nzyp ULfeTVRfelzRZ5bCEa8mE3mOCz2C0GjI/AxJ1L/Y4iNReUn6K3Fs5I3rUzVhbwlIHaI+pQUCsl5dq yv8DCgL+GVoMdMe4Kya9P9YS+vqlGm29zZQuTwuyJ8DvwTWEMZAjakv3QnMwa43v0Y1BRkj04ABoL X87w+kUw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lDucP-005fea-Qt; Sun, 21 Feb 2021 19:42:15 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, Michal Hocko Subject: [PATCH] mm: Use rcu_dereference in in_vfork Date: Sun, 21 Feb 2021 19:42:06 +0000 Message-Id: <20210221194207.1351703-1-willy@infradead.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 16B59132 X-Stat-Signature: r6wcyp16y4xjqpzs5be5hdhgwktdxpwf Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613936537-653013 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. Fixes: b18dc5f291c0 ("mm, oom: skip vforked tasks from being selected") Signed-off-by: Matthew Wilcox (Oracle) --- 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 =3D tsk->vfork_done && tsk->real_parent->mm =3D=3D tsk->mm; + ret =3D tsk->vfork_done && + rcu_dereference(tsk->real_parent)->mm =3D=3D tsk->mm; rcu_read_unlock(); =20 return ret; --=20 2.29.2