Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1052488pxv; Thu, 22 Jul 2021 20:59:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySkebn8TymCToPO3bZACBi1anXhwqAIfXoxac92MsScx4MUlGgQ1H0+nwQxxJWpEo+/o0F X-Received: by 2002:a50:fb95:: with SMTP id e21mr3331583edq.65.1627012767273; Thu, 22 Jul 2021 20:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627012767; cv=none; d=google.com; s=arc-20160816; b=CBcMpRAJ2OrdgVrMOgU78RNLLTfRS7QDgOuXKslCSe4IQIJOMSzwDTeUcF/COZj7/T csQStr2hVvp/HrdlHcwko+L42WHGMRaxR1N4snmDvfZdaPSVB4vm2w43Z4xqLLsIHMpY YbOHxzvnOZHBlXfxQA9L7iTgAvY7HuCGvlmJ/BWV0PUuZyDd1D4pcBlOU2crlYFZW1sW ImkHs9BB0u5VpJsZcgk9fySr33KQx/fiIL6ejn9zxc7wcoZv5iBWRdj1Gx6oZQ8UUjfg zJVrJidwPX9ofM0j57mn2AfxgnO10E6cASAPFGoL+l+xT/VQuDMgxK4PLfdL3+8w7/Q4 yyuQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=y+m2QnPKaCAFwZjZbBnMk/IVWTlBwVJM+ZRAGK66Xcw=; b=VAGr1prZVYMFQZ+aDGSV2t6Cs2poZCB2gmwCm2BpwcUmgp9PUv8D1O2DZZI6FHrep8 Ka404iZuQjtc732eQyouHZUQBGHsIHTtRr2C35D1aOiI2bQ1kGl9nW9k2twQPofYTd+d mYuRLozAMARIHbi/2QZRNIf8ca4xQxfpnqt86nwX2oThvJQfrYpclWS7ZL2jSwfP9iuq EhzQQyDr1LZc/fc+VUhIViFjFEjuENIItrwSgmx5g5KPFcpcDY15hwpC89pO4YUVJieB hSJhE/DQawlouZq6HhPqYcrGMv5/eJs/Ejq/aozyzN7UqK3auWRpMCPZ385KVnTRcgcz 0Waw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CbtuyjPP; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u15si1588325edt.211.2021.07.22.20.59.03; Thu, 22 Jul 2021 20:59:27 -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=@kernel.org header.s=k20201202 header.b=CbtuyjPP; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233726AbhGWDQ7 (ORCPT + 99 others); Thu, 22 Jul 2021 23:16:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:36952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233647AbhGWDQy (ORCPT ); Thu, 22 Jul 2021 23:16:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A6CCF60C41; Fri, 23 Jul 2021 03:57:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627012648; bh=k4wVrFHRjuYg0KjJM/VG6cSE88Yr5KP0/jeN4jS92Ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CbtuyjPPbsfGQSzzFzbhMXMvmvNAVRl7FqPZiKDyqwI9hGcxZDuvSgqMkLdQLNGo1 g4scH8WRQwJMtJo/GLHEb/LAImvJCB3sQD5vw5xDjXz5eL31o3eQnfkHAepkIKFpTL QdBVxNiAlA3Piu0J/3fsHUBGbhM5IT2O83uK564Cju2EJx8e0pROTXIpCaUuR7i/F7 8HGLD4AZM7h5/FatfOBJ/DKwyXbFlnDKn2wXXI4nbmRxNH8ejynpBiBFV1Gwy++u2D 1MiG2Z2c/r5LmGiU+7voKYfB3x068y0ys4NgLeBHd4GA8Yo7/K497a/ItuzFjFFf6R z7s/TMTC25L4A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Paul E. McKenney" , "Xu, Yanfei" , Sasha Levin , rcu@vger.kernel.org Subject: [PATCH AUTOSEL 5.13 05/19] rcu-tasks: Don't delete holdouts within trc_inspect_reader() Date: Thu, 22 Jul 2021 23:57:06 -0400 Message-Id: <20210723035721.531372-5-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210723035721.531372-1-sashal@kernel.org> References: <20210723035721.531372-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Paul E. McKenney" [ Upstream commit 1d10bf55d85d34eb73dd8263635f43fd72135d2d ] As Yanfei pointed out, although invoking trc_del_holdout() is safe from the viewpoint of the integrity of the holdout list itself, the put_task_struct() invoked by trc_del_holdout() can result in use-after-free errors due to later accesses to this task_struct structure by the RCU Tasks Trace grace-period kthread. This commit therefore removes this call to trc_del_holdout() from trc_inspect_reader() in favor of the grace-period thread's existing call to trc_del_holdout(), thus eliminating that particular class of use-after-free errors. Reported-by: "Xu, Yanfei" Signed-off-by: Paul E. McKenney Signed-off-by: Sasha Levin --- kernel/rcu/tasks.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h index 350ebf5051f9..71e9d625371a 100644 --- a/kernel/rcu/tasks.h +++ b/kernel/rcu/tasks.h @@ -908,10 +908,9 @@ static bool trc_inspect_reader(struct task_struct *t, void *arg) in_qs = likely(!t->trc_reader_nesting); } - // Mark as checked. Because this is called from the grace-period - // kthread, also remove the task from the holdout list. + // Mark as checked so that the grace-period kthread will + // remove it from the holdout list. t->trc_reader_checked = true; - trc_del_holdout(t); if (in_qs) return true; // Already in quiescent state, done!!! -- 2.30.2