Netdev List
 help / color / mirror / Atom feed
* [PATCH net] gtp: serialize PDP deletion with link teardown
@ 2026-08-06  2:32 Qing Ming
  2026-08-07 13:13 ` Simon Horman
  2026-08-07 14:22 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 4+ messages in thread
From: Qing Ming @ 2026-08-06  2:32 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Harald Welte
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	osmocom-net-gprs, netdev, linux-kernel, Qing Ming

PDP contexts can be deleted through GTP_CMD_DELPDP or while the GTP
network device is being unregistered. The latter is serialized by RTNL,
but the generic-netlink delete path only holds RCU.

Running both paths concurrently can therefore make both paths delete the
same PDP context. On a KASAN-enabled kernel, a reproducer racing DELPDP
against RTM_DELLINK triggered:

  Oops: general protection fault, probably for non-canonical address
  KASAN: maybe wild-memory-access in range 
         [0xdead000000000120-0xdead000000000127]
  RIP: gtp_genl_del_pdp+0x1c1/0x420 [gtp]
  RBP: dead000000000122

The second deletion dereferenced the poisoned hlist pprev pointer.

Take RTNL around the DELPDP lookup and deletion so that PDP creation,
generic-netlink deletion and link teardown use the same serialization
domain.

Fixes: 459aa660eb1d ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)")
Signed-off-by: Qing Ming <a0yami@mailbox.org>
---
 drivers/net/gtp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 427b91aca50d..7c4a99e2fd52 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -2127,6 +2127,8 @@ static int gtp_genl_del_pdp(struct sk_buff *skb, struct genl_info *info)
 	if (!info->attrs[GTPA_VERSION])
 		return -EINVAL;
 
+	rtnl_lock();
+
 	rcu_read_lock();
 
 	pctx = gtp_find_pdp(sock_net(skb->sk), info->attrs);
@@ -2147,6 +2149,7 @@ static int gtp_genl_del_pdp(struct sk_buff *skb, struct genl_info *info)
 
 out_unlock:
 	rcu_read_unlock();
+	rtnl_unlock();
 	return err;
 }
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] gtp: serialize PDP deletion with link teardown
  2026-08-06  2:32 [PATCH net] gtp: serialize PDP deletion with link teardown Qing Ming
@ 2026-08-07 13:13 ` Simon Horman
  2026-08-07 14:11   ` Pablo Neira Ayuso
  2026-08-07 14:22 ` Pablo Neira Ayuso
  1 sibling, 1 reply; 4+ messages in thread
From: Simon Horman @ 2026-08-07 13:13 UTC (permalink / raw)
  To: Qing Ming
  Cc: Pablo Neira Ayuso, Harald Welte, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, osmocom-net-gprs, netdev,
	linux-kernel

On Thu, Aug 06, 2026 at 10:32:26AM +0800, Qing Ming wrote:
> PDP contexts can be deleted through GTP_CMD_DELPDP or while the GTP
> network device is being unregistered. The latter is serialized by RTNL,
> but the generic-netlink delete path only holds RCU.
> 
> Running both paths concurrently can therefore make both paths delete the
> same PDP context. On a KASAN-enabled kernel, a reproducer racing DELPDP
> against RTM_DELLINK triggered:
> 
>   Oops: general protection fault, probably for non-canonical address
>   KASAN: maybe wild-memory-access in range 
>          [0xdead000000000120-0xdead000000000127]
>   RIP: gtp_genl_del_pdp+0x1c1/0x420 [gtp]
>   RBP: dead000000000122
> 
> The second deletion dereferenced the poisoned hlist pprev pointer.
> 
> Take RTNL around the DELPDP lookup and deletion so that PDP creation,
> generic-netlink deletion and link teardown use the same serialization
> domain.
> 
> Fixes: 459aa660eb1d ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)")
> Signed-off-by: Qing Ming <a0yami@mailbox.org>

Hi,

I think it would be good to mention how this problem was found,
and to what extent it has been tested.

You may also want to consider adding an Assisted-by tag as appropriate.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] gtp: serialize PDP deletion with link teardown
  2026-08-07 13:13 ` Simon Horman
@ 2026-08-07 14:11   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2026-08-07 14:11 UTC (permalink / raw)
  To: Simon Horman
  Cc: Qing Ming, Harald Welte, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, osmocom-net-gprs, netdev,
	linux-kernel

Hi Simon,

On Fri, Aug 07, 2026 at 02:13:35PM +0100, Simon Horman wrote:
> On Thu, Aug 06, 2026 at 10:32:26AM +0800, Qing Ming wrote:
> > PDP contexts can be deleted through GTP_CMD_DELPDP or while the GTP
> > network device is being unregistered. The latter is serialized by RTNL,
> > but the generic-netlink delete path only holds RCU.
> > 
> > Running both paths concurrently can therefore make both paths delete the
> > same PDP context. On a KASAN-enabled kernel, a reproducer racing DELPDP
> > against RTM_DELLINK triggered:
> > 
> >   Oops: general protection fault, probably for non-canonical address
> >   KASAN: maybe wild-memory-access in range 
> >          [0xdead000000000120-0xdead000000000127]
> >   RIP: gtp_genl_del_pdp+0x1c1/0x420 [gtp]
> >   RBP: dead000000000122
> > 
> > The second deletion dereferenced the poisoned hlist pprev pointer.
> > 
> > Take RTNL around the DELPDP lookup and deletion so that PDP creation,
> > generic-netlink deletion and link teardown use the same serialization
> > domain.
> > 
> > Fixes: 459aa660eb1d ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)")
> > Signed-off-by: Qing Ming <a0yami@mailbox.org>
> 
> Hi,
> 
> I think it would be good to mention how this problem was found,
> and to what extent it has been tested.

I know what it is going on, I can take care of this, thanks!

> You may also want to consider adding an Assisted-by tag as appropriate.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] gtp: serialize PDP deletion with link teardown
  2026-08-06  2:32 [PATCH net] gtp: serialize PDP deletion with link teardown Qing Ming
  2026-08-07 13:13 ` Simon Horman
@ 2026-08-07 14:22 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2026-08-07 14:22 UTC (permalink / raw)
  To: Qing Ming
  Cc: Harald Welte, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, osmocom-net-gprs, netdev, linux-kernel, Simon Horman

Hi,

On Thu, Aug 06, 2026 at 10:32:26AM +0800, Qing Ming wrote:
> PDP contexts can be deleted through GTP_CMD_DELPDP or while the GTP
> network device is being unregistered. The latter is serialized by RTNL,
> but the generic-netlink delete path only holds RCU.
> 
> Running both paths concurrently can therefore make both paths delete the
> same PDP context. On a KASAN-enabled kernel, a reproducer racing DELPDP
> against RTM_DELLINK triggered:
> 
>   Oops: general protection fault, probably for non-canonical address
>   KASAN: maybe wild-memory-access in range 
>          [0xdead000000000120-0xdead000000000127]
>   RIP: gtp_genl_del_pdp+0x1c1/0x420 [gtp]
>   RBP: dead000000000122
> 
> The second deletion dereferenced the poisoned hlist pprev pointer.
> 
> Take RTNL around the DELPDP lookup and deletion so that PDP creation,
> generic-netlink deletion and link teardown use the same serialization
> domain.

Could please you instead add a mutex to a use it to protect PDP ctx
updates? genetlink mutex is not enough, and I'd prefer not to fix this
with the rtnl lock.

Please, use this new mutex from gtp_dellink() path to protect the
iteration over the hashtable.

gtp_genl_del_pdp() must use it too as well as gtp_pdp_add().

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-07 14:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-06  2:32 [PATCH net] gtp: serialize PDP deletion with link teardown Qing Ming
2026-08-07 13:13 ` Simon Horman
2026-08-07 14:11   ` Pablo Neira Ayuso
2026-08-07 14:22 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox