Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3524893pxf; Mon, 15 Mar 2021 11:29:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRxcZPkcFDVIQdkbkBKMFtwdMwFqqGwNZvAesdSpzvpQyQuS9En8991Np6hFAIxncJWpK6 X-Received: by 2002:a05:6402:1051:: with SMTP id e17mr10378450edu.42.1615832957448; Mon, 15 Mar 2021 11:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832957; cv=none; d=google.com; s=arc-20160816; b=pQ8yhb/vdhjfjGghrJI3nysaJwsSzGCRsjtZVqlmEyRPAdPe9kBi9a0T2P+ig4+HJE snpQ08ApK8f+C1xhIdeBWm6REvpFnG5Q2iYw6gok/LNpVcq/IoCs1jgZCeYToTR9ltrD wqRByLxu89iPlywndz0XRurWPeUyfX/02b1ioGs/2o3OepyKTEulnnh498cTcPrtlrBW qe+oyUjuqa9kmmRxE4U05vTYGc97J+VTTkRaaut7upVGk61t5mEMqpo6304YN03GGulU SKtIRB4ERsY74iq5XZUJ0o8yM6wDnnYUp3zRFInl6XYFYFmh7Y4Iz7UWSf8QwhSENxFe vEcA== 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=39sOvtzdTSFlprYAD4iZClHx3q6+O66qnVGt4WrHtnw=; b=FiZTNo2BunEDvYsI+HnPlXmwGZg1svzbC2loWPjHjFq9ibwL5AJ0+Nxv7fw/+qNN9J fAgqYYV59njPPm5EGfqyZb9oEtCgKJEHv/xPJqaYz5TEhpR9prD1DGpmzaeZG7joKky+ 4sYne2uhkxjIi6doJCn/xb02jc05jGX65PqZaCMryJuoP0z//4k3+zumMpmUrKV4myOA grMrY4O3X9m2aOsKosTdbIbIiUvojPf+DkS/E2JrQDVTEw/EOHL3FmB1mRXA9vO2n9QQ j5yJLhkl6AqZGq4r0q7K4YRlx5zft8zu9gzSyyptg6vCI3BiIQuAADFQu/AKOIMf5EUe AMYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ysBAxdd7; 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 r25si11406187ejs.195.2021.03.15.11.28.47; Mon, 15 Mar 2021 11:29:17 -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=ysBAxdd7; 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 S239888AbhCOOdP (ORCPT + 99 others); Mon, 15 Mar 2021 10:33:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:37476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233272AbhCOOBV (ORCPT ); Mon, 15 Mar 2021 10:01:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BB3AE64F6E; Mon, 15 Mar 2021 14:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816856; bh=l3sIDKaoBXfVT2r26H/MhkciIgEcgQWWz+VuS4H84v0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ysBAxdd7rnfj2B4Yt02RNNTOLdNCvhAnxE7Wj83pVqZ5Gt0O4EAuZ7N5e/tMj+QUr atEzx3N5pDvLXdG4cWchU5zMHjkS3/NWRR8zFvq8uXMhzlS6ylw83Ee3AfcOXW17DM rLXhJ6zFu4XR3eluTyEpr3DzdRspd6xP0M6xK6Fc= 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.4 154/168] include/linux/sched/mm.h: use rcu_dereference in in_vfork() Date: Mon, 15 Mar 2021 14:56:26 +0100 Message-Id: <20210315135555.410453379@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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 a132d875d351..3a1d899019af 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