Skip to contentSkip to conversation

gtp: annotate PDP lookups under RTNL

PATCH Applied Runyu Xiao 5 participants 10 messages Jul 1 – Jul 9

Subsystems (3)
lore
Share & tools
lore

Runyu Xiao

author
#0 lore raw

PATCH 1/1 gtp: annotate PDP lookups under RTNL

The GTP PDP lookup helpers are shared by RCU-protected data and report paths and RTNL-protected control paths such as gtp_genl_new_pdp(). The helpers walk RCU hlists, but they do not currently pass the RTNL condition for the control-path lookups.

Pass lockdep_rtnl_is_held() to the PDP hlist iterators. Existing RCU-reader callers remain valid because the RCU-list macros also accept an active RCU read-side section; the added condition only documents the non-RCU protection already used by RTNL control paths.

This was found by our static analysis tool and then manually reviewed against the current tree. The dynamic triage evidence is a target-matched CONFIG_PROVE_RCU_LIST warning; the change is limited to documenting the existing protection contract.

This is a lockdep annotation cleanup. It does not change PDP lifetime or hash updates.

---
 drivers/net/gtp.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/gtp.c +8 -4
index 5cb59d72bc82..b94073c55f17 100644
@@ -151,7 +151,8 @@ static struct pdp_ctx *gtp0_pdp_find(struct gtp_dev *gtp, u64 tid, u16 family)
 
 	head = &gtp->tid_hash[gtp0_hashfn(tid) % gtp->hash_size];
 
-	hlist_for_each_entry_rcu(pdp, head, hlist_tid) {
+	hlist_for_each_entry_rcu(pdp, head, hlist_tid,
+				 lockdep_rtnl_is_held()) {
 		if (pdp->af == family &&
 		    pdp->gtp_version == GTP_V0 &&
 		    pdp->u.v0.tid == tid)
@@ -168,7 +169,8 @@ static struct pdp_ctx *gtp1_pdp_find(struct gtp_dev *gtp, u32 tid, u16 family)
 
 	head = &gtp->tid_hash[gtp1u_hashfn(tid) % gtp->hash_size];
 
-	hlist_for_each_entry_rcu(pdp, head, hlist_tid) {
+	hlist_for_each_entry_rcu(pdp, head, hlist_tid,
+				 lockdep_rtnl_is_held()) {
 		if (pdp->af == family &&
 		    pdp->gtp_version == GTP_V1 &&
 		    pdp->u.v1.i_tei == tid)
@@ -185,7 +187,8 @@ static struct pdp_ctx *ipv4_pdp_find(struct gtp_dev *gtp, __be32 ms_addr)
 
 	head = &gtp->addr_hash[ipv4_hashfn(ms_addr) % gtp->hash_size];
 
-	hlist_for_each_entry_rcu(pdp, head, hlist_addr) {
+	hlist_for_each_entry_rcu(pdp, head, hlist_addr,
+				 lockdep_rtnl_is_held()) {
 		if (pdp->af == AF_INET &&
 		    pdp->ms.addr.s_addr == ms_addr)
 			return pdp;
@@ -220,7 +223,8 @@ static struct pdp_ctx *ipv6_pdp_find(struct gtp_dev *gtp,
 
 	head = &gtp->addr_hash[ipv6_hashfn(ms_addr) % gtp->hash_size];
 
-	hlist_for_each_entry_rcu(pdp, head, hlist_addr) {
+	hlist_for_each_entry_rcu(pdp, head, hlist_addr,
+				 lockdep_rtnl_is_held()) {
 		if (pdp->af == AF_INET6 &&
 		    ipv6_pdp_addr_equal(&pdp->ms.addr6, ms_addr))
 			return pdp;
Signature · 1 line
2.34.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Runyu Xiao

The GTP PDP lookup helpers are shared by RCU-protected data and report paths and RTNL-protected control paths such as gtp_genl_new_pdp(). The helpers walk RCU hlists, but they do not currently pass the RTNL condition for the control-path lookups.

Pass lockdep_rtnl_is_held() to the PDP hlist iterators. Existing RCU-reader callers remain valid because the RCU-list macros also accept an active RCU read-side section; the added condition only documents the non-RCU protection already used by RTNL control paths.

This was found by our static analysis tool and then manually reviewed against the current tree. The dynamic triage evidence is a target-matched CONFIG_PROVE_RCU_LIST warning; the change is limited to documenting the existing protection contract.

Quoted 4 lines

This is a lockdep annotation cleanup. It does not change PDP lifetime or hash updates.

There is an AI-generated review of this patch available on sashko.dev. While I don't believe that the issues raised there should impede progress of this patch you may want to look into them as possible follow-up.

...

#2 lore raw

Hi Simon,

Quoted 19 lines · Simon Horman
Quoted 18 lines · Runyu Xiao

The GTP PDP lookup helpers are shared by RCU-protected data and report paths and RTNL-protected control paths such as gtp_genl_new_pdp(). The helpers walk RCU hlists, but they do not currently pass the RTNL condition for the control-path lookups.

Pass lockdep_rtnl_is_held() to the PDP hlist iterators. Existing RCU-reader callers remain valid because the RCU-list macros also accept an active RCU read-side section; the added condition only documents the non-RCU protection already used by RTNL control paths.

This was found by our static analysis tool and then manually reviewed against the current tree. The dynamic triage evidence is a target-matched CONFIG_PROVE_RCU_LIST warning; the change is limited to documenting the existing protection contract.

This is a lockdep annotation cleanup. It does not change PDP lifetime or hash updates.

Quoted 7 lines
Quoted 1 line

There is an AI-generated review of this patch available on sashko.dev. While I don't believe that the issues raised there should impede progress of this patch you may want to look into them as possible follow-up.

This patch refers to the rtnl_lock, but it is the genetlink mutex that protects updates on the PDP context list.

Then, from packet path, rcu lookups are performed.

I think this patch is not correct.

reviewer
#3 lore raw
Quoted 30 lines · Pablo Neira Ayuso

Hi Simon,

Quoted 19 lines · Simon Horman
Quoted 18 lines · Runyu Xiao

The GTP PDP lookup helpers are shared by RCU-protected data and report paths and RTNL-protected control paths such as gtp_genl_new_pdp(). The helpers walk RCU hlists, but they do not currently pass the RTNL condition for the control-path lookups.

Pass lockdep_rtnl_is_held() to the PDP hlist iterators. Existing RCU-reader callers remain valid because the RCU-list macros also accept an active RCU read-side section; the added condition only documents the non-RCU protection already used by RTNL control paths.

This was found by our static analysis tool and then manually reviewed against the current tree. The dynamic triage evidence is a target-matched CONFIG_PROVE_RCU_LIST warning; the change is limited to documenting the existing protection contract.

This is a lockdep annotation cleanup. It does not change PDP lifetime or hash updates.

Quoted 7 lines
Quoted 1 line

There is an AI-generated review of this patch available on sashko.dev. While I don't believe that the issues raised there should impede progress of this patch you may want to look into them as possible follow-up.

Quoted 6 lines

This patch refers to the rtnl_lock, but it is the genetlink mutex that protects updates on the PDP context list.

Then, from packet path, rcu lookups are performed.

I think this patch is not correct.

Hi Pablo,

Of course you are correct.
Sorry for not realising this earlier.

maintainer
#4 lore raw
Quoted 32 lines · Simon Horman
Quoted 31 lines · Pablo Neira Ayuso
Quoted 19 lines · Simon Horman
Quoted 18 lines · Runyu Xiao

The GTP PDP lookup helpers are shared by RCU-protected data and report paths and RTNL-protected control paths such as gtp_genl_new_pdp(). The helpers walk RCU hlists, but they do not currently pass the RTNL condition for the control-path lookups.

Pass lockdep_rtnl_is_held() to the PDP hlist iterators. Existing RCU-reader callers remain valid because the RCU-list macros also accept an active RCU read-side section; the added condition only documents the non-RCU protection already used by RTNL control paths.

This was found by our static analysis tool and then manually reviewed against the current tree. The dynamic triage evidence is a target-matched CONFIG_PROVE_RCU_LIST warning; the change is limited to documenting the existing protection contract.

This is a lockdep annotation cleanup. It does not change PDP lifetime or hash updates.

Quoted 7 lines
Quoted 1 line

There is an AI-generated review of this patch available on sashko.dev. While I don't believe that the issues raised there should impede progress of this patch you may want to look into them as possible follow-up.

This patch refers to the rtnl_lock, but it is the genetlink mutex that protects updates on the PDP context list.

Quoted 8 lines
Quoted 3 lines

Then, from packet path, rcu lookups are performed.

I think this patch is not correct.

Hi Pablo,

Of course you are correct.
Sorry for not realising this earlier.

Human slop here made me wrongly apply this patch. Could either of you please share a formal revert?

Thanks!

Paolo

reviewer
#5 lore raw
Quoted 37 lines · Paolo Abeni
Quoted 36 lines · Simon Horman
Quoted 34 lines · Pablo Neira Ayuso
Quoted 19 lines · Simon Horman
Quoted 18 lines · Runyu Xiao

The GTP PDP lookup helpers are shared by RCU-protected data and report paths and RTNL-protected control paths such as gtp_genl_new_pdp(). The helpers walk RCU hlists, but they do not currently pass the RTNL condition for the control-path lookups.

Pass lockdep_rtnl_is_held() to the PDP hlist iterators. Existing RCU-reader callers remain valid because the RCU-list macros also accept an active RCU read-side section; the added condition only documents the non-RCU protection already used by RTNL control paths.

This was found by our static analysis tool and then manually reviewed against the current tree. The dynamic triage evidence is a target-matched CONFIG_PROVE_RCU_LIST warning; the change is limited to documenting the existing protection contract.

This is a lockdep annotation cleanup. It does not change PDP lifetime or hash updates.

Quoted 7 lines
Quoted 1 line

There is an AI-generated review of this patch available on sashko.dev. While I don't believe that the issues raised there should impede progress of this patch you may want to look into them as possible follow-up.

This patch refers to the rtnl_lock, but it is the genetlink mutex that protects updates on the PDP context list.

Then, from packet path, rcu lookups are performed.

I think this patch is not correct.

Quoted 7 lines
Quoted 4 lines

Hi Pablo,

Of course you are correct.
Sorry for not realising this earlier.

Human slop here made me wrongly apply this patch. Could either of you please share a formal revert?

Sure, will do.

reviewer
#6 lore raw
Quoted 3 lines · Simon Horman
Quoted 2 lines · Paolo Abeni
Quoted 1 line · Simon Horman

On Tue, Jul 07, 2026 at 04:51:12PM +0200, Pablo Neira Ayuso wrote:

...

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
Quoted 1 line

I think this patch is not correct.

Hi Pablo,

Of course you are correct.
Sorry for not realising this earlier.

Human slop here made me wrongly apply this patch. Could either of you please share a formal revert?

Sure, will do.

- [PATCH net-next] Revert "gtp: annotate PDP lookups under RTNL"
https://lore.kernel.org/netdev/[email protected]/T/

maintainer
#7 lore raw
Quoted 14 lines · Simon Horman
Quoted 3 lines · Simon Horman
Quoted 2 lines · Paolo Abeni
Quoted 1 line · Simon Horman

On Tue, Jul 07, 2026 at 04:51:12PM +0200, Pablo Neira Ayuso wrote:

...

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 1 line

I think this patch is not correct.

Hi Pablo,

Of course you are correct.
Sorry for not realising this earlier.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Human slop here made me wrongly apply this patch. Could either of you please share a formal revert?

Sure, will do.

- [PATCH net-next] Revert "gtp: annotate PDP lookups under RTNL"
https://lore.kernel.org/netdev/[email protected]/T/

Thanks Simon!

/P

#8 lore raw
In reply to Runyu Xiao
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 11 lines · On Wed, 1 Jul 2026 20:39:25 +0800 you wrote:

The GTP PDP lookup helpers are shared by RCU-protected data and report paths and RTNL-protected control paths such as gtp_genl_new_pdp(). The helpers walk RCU hlists, but they do not currently pass the RTNL condition for the control-path lookups.

Pass lockdep_rtnl_is_held() to the PDP hlist iterators. Existing RCU-reader callers remain valid because the RCU-list macros also accept an active RCU read-side section; the added condition only documents the non-RCU protection already used by RTNL control paths.

[...]

Here is the summary with links:
- [net-next] gtp: annotate PDP lookups under RTNL

    https://git.kernel.org/netdev/net-next/c/0be5c3f0fbef

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#9 lore raw

Hi,

Quoted 16 lines · On Wed, Jul 08, 2026 at 08:20:09AM +0000, [email protected]…

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Wed, 1 Jul 2026 20:39:25 +0800 you wrote:

The GTP PDP lookup helpers are shared by RCU-protected data and report paths and RTNL-protected control paths such as gtp_genl_new_pdp(). The helpers walk RCU hlists, but they do not currently pass the RTNL condition for the control-path lookups.

Pass lockdep_rtnl_is_held() to the PDP hlist iterators. Existing RCU-reader callers remain valid because the RCU-list macros also accept an active RCU read-side section; the added condition only documents the non-RCU protection already used by RTNL control paths.

Quoted 5 lines
Quoted 1 line

[...]

Here is the summary with links:
- [net-next] gtp: annotate PDP lookups under RTNL

    https://git.kernel.org/netdev/net-next/c/0be5c3f0fbef

For the record, I think this patch was not OK.

PDP context hashtable is protected by the genl_mutex, not rtnl.

If I'm mistaken, please let know, thanks!