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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 712C8C433DB for ; Mon, 22 Feb 2021 08:30:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BEE1364E57 for ; Mon, 22 Feb 2021 08:30:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEE1364E57 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 165566B0006; Mon, 22 Feb 2021 03:30:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 116A66B006C; Mon, 22 Feb 2021 03:30:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02BA46B006E; Mon, 22 Feb 2021 03:30:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id E0B146B0006 for ; Mon, 22 Feb 2021 03:30:35 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A1F0C824805A for ; Mon, 22 Feb 2021 08:30:35 +0000 (UTC) X-FDA: 77845232430.11.F30F464 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf12.hostedemail.com (Postfix) with ESMTP id D5945130 for ; Mon, 22 Feb 2021 08:30:29 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1613982633; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zmWkGYIaCCw8mtQmi1p4MTfm8qVfNgEdPbexW0q29RI=; b=tnEsNhyRIjzJkTMRqIuFVbxRwqFGqW2Ix9CuVlIeg9mhaTDSqcB3pLKarLARUPu24SmjKn 1PYw2Bc7YKtKNy/rPni/YyBYrJsCxtDaP9H8QXWewiqA531v4pV6MyXBJOlSEtTqT+qf4B RfTLKj3qXLYIWsFyWSpiOXecE0yiYwE= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6D0AAAD73; Mon, 22 Feb 2021 08:30:33 +0000 (UTC) Date: Mon, 22 Feb 2021 09:30:27 +0100 From: Michal Hocko To: "Matthew Wilcox (Oracle)" Cc: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: Use rcu_dereference in in_vfork Message-ID: References: <20210221194207.1351703-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210221194207.1351703-1-willy@infradead.org> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D5945130 X-Stat-Signature: 7w6miops5s1ngom4nzdro5kbsrox4f93 Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613982629-863469 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: On Sun 21-02-21 19:42:06, Matthew Wilcox wrote: > 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) I must have missed the RCU part. Thanks! Acked-by: Michal Hocko > --- > 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.29.2 > -- Michal Hocko SUSE Labs