🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #3917

[PATCH net-next v7 2/4] gtp: hold RCU for the device lookup when adding a PDP context

#3917
From: Anil Kaushik
Date: Fri, 16 Oct 2026 09:32
41 lines
9839 bytes
gtp_genl_new_pdp() calls gtp_find_dev(), which looks the device up with
dev_get_by_index_rcu(). Since commit e2d1baca2b33 ("gtp: remove useless
rcu_read_lock()"), this only runs under the rtnl lock, and kernels with
CONFIG_PROVE_RCU_LIST warn:

  WARNING: suspicious RCU usage
  net/core/dev.c:1047 RCU-list traversed in non-reader section!!
  ...
   dev_get_by_index_rcu
   gtp_find_dev
   gtp_genl_new_pdp

Hold the RCU read lock around the lookup only: gtp_pdp_add() allocates
with GFP_KERNEL, and the rtnl lock keeps the device alive afterwards.

Found with the gtp selftest on a debug kernel.

Fixes: e2d1baca2b33 ("gtp: remove useless rcu_read_lock()")
Signed-off-by: Anil Kaushik <anilkaushikwireless@gmail.com>
---
 drivers/net/gtp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 99836b773e5c..15b5d845fc3b 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -2050,7 +2050,10 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)
 
 	rtnl_lock();
 
+	/* the rtnl lock keeps the device alive once found */
+	rcu_read_lock();
 	gtp = gtp_find_dev(sock_net(skb->sk), info->attrs);
+	rcu_read_unlock();
 	if (!gtp) {
 		err = -ENODEV;
 		goto out_unlock;
-- 
2.25.1
Technical Details
Message-ID: <20261016093225.1036375-3-anilkaushikwireless@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347217-linux-kernel-netdev=dewy.ru
References: <20261016093225.1036375-1-anilkaushikwireless@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347217-linux-kernel-netdev=dewy.ru
From: anilkaushikwireless@gmail.com (Anil Kaushik)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v7 2/4] gtp: hold RCU for the device lookup when adding a PDP context
Date: Fri, 16 Oct 2026 09:32:23 +0000
Organization: Usenet Network
Message-ID: <20261016093225.1036375-3-anilkaushikwireless@gmail.com>
References: <20261016093225.1036375-1-anilkaushikwireless@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2730056"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ICjjfwhiTWqYZg6N5Cef2f8DoDE= sha256:teEfNH/PRx6KtQp5k9nC/CeUMS50xkZkLJAaCVEb3kc=
	sha1:pV5S5N+G2gmaejf2nuri7CJ3qxY= sha256:E6DLOwvvdLBc82wCcxx4dVWtsnaPlCgdP2S5rybi7LA=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id B7FC31104C4; Fri, 16 Oct 2026 12:38:07 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 7x0csrcLomFw;
	Fri, 16 Oct 2026 12:38:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-347217-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 01AB41104C1; Fri, 16 Oct 2026 12:37:56 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by tor.lore.kernel.org (Postfix) with ESMTP id 4CAC3434DC; Fri, 16 Oct 2026 09:32:54 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E18047125F;
	Fri, 16 Oct 2026 09:32:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bHERSdA9"
X-Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D93D46EC69
	for <netdev@vger.kernel.org>; Fri, 16 Oct 2026 09:32:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.170
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792143166; cv=none; b=RYl8AxdYNz5K3lozF3zTCBQGt3WkDYWpYjgWvF4Ou98NiOKPDN2MvK6KM/aJYhOL0IOvLSPHO70lq3bRMtCyWqBOHiqKJA10QIbI1p4n3z3SG9F58wHSuoXmGi3E/qLpvb9b4Qs5giNzCGpkOmx0+/ofuSB/gaV8k2vUNowcX5s=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792143166; c=relaxed/simple;
	bh=Z9Mwbxdb/e66pqI6wraTgavodNtN8iMAFiUVb6k+BFQ=;
	h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:
	 MIME-Version; b=BNQ+WcRmmUIKxQe/3cELpdk2rJNXqRroo8QpWYSFHJYtpj1jX4GmUppeiucDEGmkcUg9036LdtgtOp/JCA1LAckz0bZrrNQ479GL54p0mu/RRoB0vnPAdrikdLiTJSGJ0hcemr/G3heK31wFaozc5ONpQo6S++v3rLEes2hm49E=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bHERSdA9; arc=none smtp.client-ip=74.125.82.170
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dy1-f170.google.com with SMTP id 5a478bee46e88-33bf40b0c8bso2288507eec.0
        for <netdev@vger.kernel.org>; Fri, 16 Oct 2026 02:32:45 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792143165; x=1792747965; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=XHmkv6BikJoFrn087jxAAKsWlqagsvtugyCffrxtj2U=;
        b=bHERSdA9g4cxrnlEyUlZpv50EfUtdP2CgtywULH7Y86PJg1PkvgbAYKt/r5Akzd5tF
         xJ0u0rCEoKruYyh4Gjg84HFbYdmPD8VJ02AMCONA/B3DLbI3NrhXC5A2Bx/EKvVEi/ZC
         v08zwYv1oGveh7VXBAsSl7fBQroVMwetkP1LCx9RfI/r9AMxC0/g7qpIbKp2tSFLeghq
         tnLm0YTh+06dsOt+Nuru3F22cxusAGVZUqVV5xxX68n5CGpTnKpCIA173KoDijwo4SWr
         k/A8wq8PGZFlKwLzifwbCWX2FmyWDeKUwsCQNvd5MOaVuXFOGm7ufaJEUettfoYRGz4D
         watw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792143165; x=1792747965;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=XHmkv6BikJoFrn087jxAAKsWlqagsvtugyCffrxtj2U=;
        b=J2M2C0z7dSzjwKuLD/1wiWDA0+U1ICjkXv/cx+8xUBkBXPW8OKLUr5Ndv0XYQFEJAZ
         1F4aA23nwcPJle92/1inoJudUL9ri5gBX9hQHlC3Mjv/OZD0tf6CSbp4DTeJ1ZcohEHk
         ZYC0BUOyoJO0l3Jns6D3/ZFDQ5gahpzchD7UDTVgnbttHQf7j7YtH7PFGYmui2XAAHbW
         HJLZb9/O9gFPkjT98t29N8EybHGhkmGJm8Zj9hDhWTofgOnkyCCXXVimXUNndUWribQf
         lBDyc2gCaIxD+ZSmpI5IPfDOE0BFSPq3D9MkErbnqCqIBWJlzVRKCy3m8xsPChDMNqI9
         Y7kA==
X-Forwarded-Encrypted: i=1; AKwUvBxBc2Q3q+iXwX83bPaw7Ib7DOsqNB2rOFKzlv02lXbt96rFKhzwtqZy9WvGOTVB7a7NMQC2ILo=@vger.kernel.org
X-Gm-Message-State: AFq9FYKhzzDWuT+gEWdseCsgB8r1ePpx7jVSjZMO/yjqDk8KU1PP5LNA
	QH3vGnLYgCU8okvBnUo0Gt6m7iqsbWEfHX1JL4uekcFBgZ3aVfqGPeC1
X-Gm-Gg: AYBFou2I3puhkv6z7nmdnL/fvwFtAAZA9GsoB5RArWtPTbyImVQph5QNYeAfh4vt85Z
	NLUgqG1A1/z0cBiCrYJ7YpG8UVZQ3v4nuz3/5Ner1x1Pm8QTVELu064VFRxspqnJB2jFi3br5aE
	1MprZbBWfGCjogQnEscBxEvpq+OZoI385KPS51kVQAHorHwMJH8I2VQah+LNNby26a51QRgk2kp
	V05fiSBkNcsQoSsduz3PJqRopvrdK43VRVCHAoPzH2Ix7uVrWky1Fg6CzIwzNRbrUsveaD3rGRi
	26atOqNQKOuyuNN7Ur7vtd39VzWI1iYK5OomKHk7k6JYD8d7N4EwXCu9P7qMl06yJ+6BIKzuz2y
	eEGXx/qfMwSt8m8z7Ps3vmlt5Gc4eebyTLUBRuMsJFlaQTUbYqYeyTaV7bwHUtcMl9s77vgXAHs
	6r94HEyZ8nMaoExs5G4fFkp1g5a0uZI+YHcTgyTlU8+e6lPwmDeQiax5bZE86A5hVEic8adWpti
	ZYdod5J7TU9ORt1+5Jo333hW3gn9UCgsAPu1RNuWrqKbjISIZ5gYrxb7JJkPBV3BglhbAVFmImF
	NIlR6WQn6JUshgWoaLD2wQEvIesOoh4IibxzqEb4Ja4=
X-Received: by 2002:a05:693c:401c:b0:35f:2349:a574 with SMTP id 5a478bee46e88-35f2349e961mr6538038eec.40.1792143164540;
        Fri, 16 Oct 2026 02:32:44 -0700 (PDT)
X-Received: from ramen-dev-security-2.asia-south1-c.c.ramen-dev-345017.internal (90.156.200.35.bc.googleusercontent.com. [35.200.156.90])
        by smtp.gmail.com with ESMTPSA id 5a478bee46e88-360820a79c7sm5157172eec.18.2026.10.16.02.32.39
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Fri, 16 Oct 2026 02:32:44 -0700 (PDT)
X-Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Shuah Khan <shuah@kernel.org>,
	Stanislav Fomichev <sdf.kernel@gmail.com>,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>,
	osmocom-net-gprs@lists.osmocom.org,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	Anil Kaushik <anilkaushikwireless@gmail.com>
X-Mailer: git-send-email 2.25.1
X-In-Reply-To: <20261016093225.1036375-1-anilkaushikwireless@gmail.com>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>