Skip to contentSkip to conversation

tipc: fix UAF in tipc_l2_send_msg()

PATCH Applied Eric Dumazet 3 participants 5 messages Jun 12 – Jun 15

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tipc: fix UAF in tipc_l2_send_msg()

Syzbot reported a slab-use-after-free in ipvlan_hard_header() when called from tipc_l2_send_msg().

The root cause is that tipc_disable_l2_media() calls synchronize_net() while b->media_ptr is still valid. This allows concurrent RCU readers to obtain the device pointer after synchronize_net() has finished. The pointer is cleared later in bearer_disable(), but without any subsequent synchronization, allowing the device to be freed while still in use by readers.

Fix this by clearing b->media_ptr in tipc_disable_l2_media() before calling synchronize_net().

This is safe to do now because the call order in bearer_disable() was reversed in 0d051bf93c06 ("tipc: make bearer packet filtering generic") to call tipc_node_delete_links() (which needs the pointer) before disable_media().

Fixes 282b3a056225 ("tipc: send out RESET immediately when link goes down")

https://lore.kernel.org/netdev/[email protected]/T/#u

---
 net/tipc/bearer.c | 1 +
 1 file changed, 1 insertion(+)
net/tipc/bearer.c +1 -0
index a3bd1ef17558a37787bb92f2c3805c0fda874d8a..05dcd2f9e887a6e5ca6665ab41e4d5b5107f158c 100644
@@ -482,6 +482,7 @@ void tipc_disable_l2_media(struct tipc_bearer *b)
 	dev = (struct net_device *)rtnl_dereference(b->media_ptr);
 	dev_remove_pack(&b->pt);
 	RCU_INIT_POINTER(dev->tipc_ptr, NULL);
+	RCU_INIT_POINTER(b->media_ptr, NULL);
 	synchronize_net();
 	dev_put(dev);
 }
Signature · 1 line
2.54.0.1136.gdb2ca164c4-goog
#1 lore raw
Quoted 35 lines

Subject: [PATCH net] tipc: fix UAF in tipc_l2_send_msg()

Syzbot reported a slab-use-after-free in ipvlan_hard_header() when called from tipc_l2_send_msg().

The root cause is that tipc_disable_l2_media() calls synchronize_net() while b-

Quoted 1 line

media_ptr is still valid. This allows concurrent RCU readers to obtain the

device pointer after synchronize_net() has finished.
The pointer is cleared later in bearer_disable(), but without any subsequent synchronization, allowing the device to be freed while still in use by readers.

Fix this by clearing b->media_ptr in tipc_disable_l2_media() before calling synchronize_net().

This is safe to do now because the call order in bearer_disable() was reversed in 0d051bf93c06 ("tipc: make bearer packet filtering generic") to call tipc_node_delete_links() (which needs the pointer) before disable_media().

Fixes 282b3a056225 ("tipc: send out RESET immediately when link goes

down")
https://lore.kernel.org/netdev/[email protected]
om/T/#u

---
net/tipc/bearer.c | 1 +

1 file changed, 1 insertion(+)
net/tipc/bearer.c index renamed from net/tipc/bearer.c +0 -0

a3bd1ef17558a37787bb92f2c3805c0fda874d8a..05dcd2f9e887a6e5ca6665ab4 1e4d5b5107f158c 100644

net/tipc/bearer.c void tipc_disable_l2_media(struct tipc_bearer *b) · line 485

Quoted 4 lines
net/tipc/bearer.c +1 -0
@@ -482,6 +482,7 @@ void tipc_disable_l2_media(struct tipc_bearer *b)
 	dev = (struct net_device *)rtnl_dereference(b->media_ptr);
 	dev_remove_pack(&b->pt);
 	RCU_INIT_POINTER(dev->tipc_ptr, NULL);
+	RCU_INIT_POINTER(b->media_ptr, NULL);

Since 'b->media_ptr' is reset here, Should the same reset be removed in bearer_disable() ? bearer_disable()
{
...
RCU_INIT_POINTER(b->media_ptr, NULL);
...
}

Quoted 6 lines
net/tipc/bearer.c +0 -1
 	synchronize_net();
 	dev_put(dev);
 }
--

2.54.0.1136.gdb2ca164c4-goog

#2 lore raw
Quoted 41 lines · Tung Quang Nguyen
Quoted 36 lines

Subject: [PATCH net] tipc: fix UAF in tipc_l2_send_msg()

Syzbot reported a slab-use-after-free in ipvlan_hard_header() when called from tipc_l2_send_msg().

The root cause is that tipc_disable_l2_media() calls synchronize_net() while b-

Quoted 1 line

media_ptr is still valid. This allows concurrent RCU readers to obtain the

device pointer after synchronize_net() has finished.
The pointer is cleared later in bearer_disable(), but without any subsequent synchronization, allowing the device to be freed while still in use by readers.

Fix this by clearing b->media_ptr in tipc_disable_l2_media() before calling synchronize_net().

This is safe to do now because the call order in bearer_disable() was reversed in 0d051bf93c06 ("tipc: make bearer packet filtering generic") to call tipc_node_delete_links() (which needs the pointer) before disable_media().

Fixes 282b3a056225 ("tipc: send out RESET immediately when link goes

down")
https://lore.kernel.org/netdev/[email protected]
om/T/#u

---
net/tipc/bearer.c | 1 +

1 file changed, 1 insertion(+)
net/tipc/bearer.c index renamed from net/tipc/bearer.c +0 -0

a3bd1ef17558a37787bb92f2c3805c0fda874d8a..05dcd2f9e887a6e5ca6665ab4 1e4d5b5107f158c 100644

net/tipc/bearer.c void tipc_disable_l2_media(struct tipc_bearer *b) · line 485

Quoted 4 lines
net/tipc/bearer.c +1 -0
@@ -482,6 +482,7 @@ void tipc_disable_l2_media(struct tipc_bearer *b)
      dev = (struct net_device *)rtnl_dereference(b->media_ptr);
      dev_remove_pack(&b->pt);
      RCU_INIT_POINTER(dev->tipc_ptr, NULL);
+      RCU_INIT_POINTER(b->media_ptr, NULL);
Quoted 7 lines

Since 'b->media_ptr' is reset here, Should the same reset be removed in bearer_disable() ? bearer_disable()
{
...
RCU_INIT_POINTER(b->media_ptr, NULL);
...
}

We could, but we would have to add a reset in tipc_udp_disable().

I thoght it was a bit clearer (and less risky given bearer_disable() is called from many points)
to focus only on tipc_disable_l2_media()

maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Eric Dumazet
Quoted 43 lines

Subject: [PATCH net] tipc: fix UAF in tipc_l2_send_msg()

Syzbot reported a slab-use-after-free in ipvlan_hard_header() when called from tipc_l2_send_msg().

The root cause is that tipc_disable_l2_media() calls synchronize_net() while b-

Quoted 1 line

media_ptr is still valid. This allows concurrent RCU readers to obtain the

device pointer after synchronize_net() has finished.
The pointer is cleared later in bearer_disable(), but without any subsequent synchronization, allowing the device to be freed while still in use by readers.

Fix this by clearing b->media_ptr in tipc_disable_l2_media() before calling synchronize_net().

This is safe to do now because the call order in bearer_disable() was reversed in 0d051bf93c06 ("tipc: make bearer packet filtering generic") to call tipc_node_delete_links() (which needs the pointer) before disable_media().

Fixes 282b3a056225 ("tipc: send out RESET immediately when link goes

down")
https://lore.kernel.org/netdev/[email protected]
om/T/#u

---
net/tipc/bearer.c | 1 +

1 file changed, 1 insertion(+)
net/tipc/bearer.c index renamed from net/tipc/bearer.c +0 -0

a3bd1ef17558a37787bb92f2c3805c0fda874d8a..05dcd2f9e887a6e5ca6665ab4 1e4d5b5107f158c 100644

net/tipc/bearer.c +1 -1
@@ -482,6 +482,7 @@ void tipc_disable_l2_media(struct tipc_bearer *b)
 	dev = (struct net_device *)rtnl_dereference(b->media_ptr);
 	dev_remove_pack(&b->pt);
 	RCU_INIT_POINTER(dev->tipc_ptr, NULL);
+	RCU_INIT_POINTER(b->media_ptr, NULL);
 	synchronize_net();
 	dev_put(dev);
 }
--
Quoted 2 lines

2.54.0.1136.gdb2ca164c4-goog

#4 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Fri, 12 Jun 2026 13:59:49 +0000 you wrote:

Syzbot reported a slab-use-after-free in ipvlan_hard_header() when called from tipc_l2_send_msg().

The root cause is that tipc_disable_l2_media() calls synchronize_net() while b->media_ptr is still valid. This allows concurrent RCU readers to obtain the device pointer after synchronize_net() has finished. The pointer is cleared later in bearer_disable(), but without any subsequent synchronization, allowing the device to be freed while still in use by readers.

[...]

Here is the summary with links:
- [net] tipc: fix UAF in tipc_l2_send_msg()

    https://git.kernel.org/netdev/net/c/f4c3d89fc986

You are awesome, thank you!

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