linux-yocto/net/tipc
Charalampos Mitrodimas acab7ca5ff net: tipc: fix refcount warning in tipc_aead_encrypt
[ Upstream commit f29ccaa07cf3d35990f4d25028cc55470d29372b ]

syzbot reported a refcount warning [1] caused by calling get_net() on
a network namespace that is being destroyed (refcount=0). This happens
when a TIPC discovery timer fires during network namespace cleanup.

The recently added get_net() call in commit e279024617134 ("net/tipc:
fix slab-use-after-free Read in tipc_aead_encrypt_done") attempts to
hold a reference to the network namespace. However, if the namespace
is already being destroyed, its refcount might be zero, leading to the
use-after-free warning.

Replace get_net() with maybe_get_net(), which safely checks if the
refcount is non-zero before incrementing it. If the namespace is being
destroyed, return -ENODEV early, after releasing the bearer reference.

[1]: https://lore.kernel.org/all/68342b55.a70a0220.253bc2.0091.GAE@google.com/T/#m12019cf9ae77e1954f666914640efa36d52704a2

Reported-by: syzbot+f0c4a4aba757549ae26c@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/68342b55.a70a0220.253bc2.0091.GAE@google.com/T/#m12019cf9ae77e1954f666914640efa36d52704a2
Fixes: e27902461713 ("net/tipc: fix slab-use-after-free Read in tipc_aead_encrypt_done")
Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
Reviewed-by: Tung Nguyen <tung.quang.nguyen@est.tech>
Link: https://patch.msgid.link/20250527-net-tipc-warning-v2-1-df3dc398a047@posteo.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-19 15:28:32 +02:00
..
addr.c
addr.h tipc: Remove unused function declarations 2023-08-03 12:51:45 +02:00
bcast.c net: tipc: avoid possible garbage value 2024-10-04 16:28:59 +02:00
bcast.h
bearer.c tipc: guard against string buffer overrun 2024-10-10 11:57:25 +02:00
bearer.h tipc: Remove unused function declarations 2023-08-03 12:51:45 +02:00
core.c tipc: fix use-after-free Read in tipc_named_reinit 2022-06-17 11:39:10 +01:00
core.h minmax: add in_range() macro 2023-08-24 16:20:18 -07:00
crypto.c net: tipc: fix refcount warning in tipc_aead_encrypt 2025-06-19 15:28:32 +02:00
crypto.h
diag.c sock_diag: add module pointer to "struct sock_diag_handler" 2024-12-09 10:32:09 +01:00
discover.c treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
discover.h
eth_media.c
group.c
group.h
ib_media.c
Kconfig
link.c tipc: fix memory leak in tipc_link_xmit 2025-04-25 10:45:06 +02:00
link.h tipc: Remove unused declaration tipc_link_build_bc_sync_msg() 2023-08-09 13:03:14 -07:00
Makefile
monitor.c tipc: fix NULL pointer dereference in tipc_mon_reinit_self() 2025-05-02 07:50:43 +02:00
monitor.h
msg.c tipc: fix UAF in error path 2024-05-17 12:02:32 +02:00
msg.h net: tipc: remove unused static inlines 2022-01-27 13:53:27 +00:00
name_distr.c net/tipc: Remove unused struct distr_queue_item 2022-09-29 18:48:32 -07:00
name_distr.h tipc: Remove unused function declarations 2023-08-03 12:51:45 +02:00
name_table.c tipc: cleanup unused function 2022-06-17 11:43:57 +01:00
name_table.h tipc: cleanup unused function 2022-06-17 11:43:57 +01:00
net.c
net.h tipc: Remove unused function declarations 2023-08-03 12:51:45 +02:00
netlink_compat.c tipc: Fix kernel-infoleak due to uninitialized TLV value 2023-11-28 17:19:51 +00:00
netlink.c tipc: Change nla_policy for bearer-related names to NLA_NUL_STRING 2023-11-20 11:59:34 +01:00
netlink.h
node.c tipc: force a dst refcount before doing decryption 2024-06-27 13:49:07 +02:00
node.h
socket.c genetlink: use attrs from struct genl_info 2023-08-15 15:00:45 -07:00
socket.h
subscr.c
subscr.h
sysctl.c
topsrv.c net/sock: Introduce trace_sk_data_ready() 2023-01-23 11:26:50 +00:00
topsrv.h
trace.c
trace.h
udp_media.c tipc: fix NULL deref in cleanup_bearer() 2024-12-19 18:11:27 +01:00
udp_media.h