tipc: fix UAF in tipc_l2_send_msg()
Subsystems (3)
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().
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
@@ -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
Tung Quang Nguyen
maintainerQuoted 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 fromtipc_l2_send_msg().The root cause is that
tipc_disable_l2_media()callssynchronize_net()while b-Quoted 1 line
media_ptris still valid. This allows concurrent RCU readers to obtain thedevice pointer after
synchronize_net()has finished.
The pointer is cleared later inbearer_disable(), but without any subsequent synchronization, allowing the device to be freed while still in use by readers.Fix this by clearing
b->media_ptrintipc_disable_l2_media()before callingsynchronize_net().This is safe to do now because the call order in
bearer_disable()was reversed in0d051bf93c06("tipc: make bearer packet filtering generic") to calltipc_node_delete_links()(which needs the pointer) beforedisable_media().Fixes 282b3a056225 ("tipc: send out RESET immediately when link goesdown")
https://lore.kernel.org/netdev/[email protected]
om/T/#uReported-by [email protected]Signed-off-by Eric Dumazet <[email protected]>Cc Jon Maloy <[email protected]>---
net/tipc/bearer.c| 1 +1 file changed, 1 insertion(+)net/tipc/bearer.c index renamed from net/tipc/bearer.c +0
-0
a3bd1ef17558a37787bb92f2c3805c0fda874d8a..05dcd2f9e887a6e5ca6665ab41e4d5b5107f158c100644
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
-1synchronize_net ();dev_put (dev); } --2.54.0.1136.gdb2ca164c4-goog
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 fromtipc_l2_send_msg().The root cause is that
tipc_disable_l2_media()callssynchronize_net()while b-Quoted 1 line
media_ptris still valid. This allows concurrent RCU readers to obtain thedevice pointer after
synchronize_net()has finished.
The pointer is cleared later inbearer_disable(), but without any subsequent synchronization, allowing the device to be freed while still in use by readers.Fix this by clearing
b->media_ptrintipc_disable_l2_media()before callingsynchronize_net().This is safe to do now because the call order in
bearer_disable()was reversed in0d051bf93c06("tipc: make bearer packet filtering generic") to calltipc_node_delete_links()(which needs the pointer) beforedisable_media().Fixes 282b3a056225 ("tipc: send out RESET immediately when link goesdown")
https://lore.kernel.org/netdev/[email protected]
om/T/#uReported-by [email protected]Signed-off-by Eric Dumazet <[email protected]>Cc Jon Maloy <[email protected]>---
net/tipc/bearer.c| 1 +1 file changed, 1 insertion(+)net/tipc/bearer.c index renamed from net/tipc/bearer.c +0
-0
a3bd1ef17558a37787bb92f2c3805c0fda874d8a..05dcd2f9e887a6e5ca6665ab41e4d5b5107f158c100644net/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 inbearer_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()
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 fromtipc_l2_send_msg().The root cause is that
tipc_disable_l2_media()callssynchronize_net()while b-Quoted 1 line
media_ptris still valid. This allows concurrent RCU readers to obtain thedevice pointer after
synchronize_net()has finished.
The pointer is cleared later inbearer_disable(), but without any subsequent synchronization, allowing the device to be freed while still in use by readers.Fix this by clearing
b->media_ptrintipc_disable_l2_media()before callingsynchronize_net().This is safe to do now because the call order in
bearer_disable()was reversed in0d051bf93c06("tipc: make bearer packet filtering generic") to calltipc_node_delete_links()(which needs the pointer) beforedisable_media().Fixes 282b3a056225 ("tipc: send out RESET immediately when link goesdown")
https://lore.kernel.org/netdev/[email protected]
om/T/#uReported-by [email protected]Signed-off-by Eric Dumazet <[email protected]>Cc Jon Maloy <[email protected]>---
net/tipc/bearer.c| 1 +1 file changed, 1 insertion(+)net/tipc/bearer.c index renamed from net/tipc/bearer.c +0
-0
a3bd1ef17558a37787bb92f2c3805c0fda874d8a..05dcd2f9e887a6e5ca6665ab41e4d5b5107f158c100644net/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
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 fromtipc_l2_send_msg().The root cause is that
tipc_disable_l2_media()callssynchronize_net()whileb->media_ptris still valid. This allows concurrent RCU readers to obtain the device pointer aftersynchronize_net()has finished. The pointer is cleared later inbearer_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