[PATCH] batman-adv: mcast: fix memory leak on deleting a batman-adv interface

2024-01-16 Thread Linus Lüssing
The batman-adv multicast tracker TVLV handler is registered for the
new batman-adv multicast packet type upon creating a batman-adv interface,
but not unregistered again upon the interface's deletion, leading to a
memory leak.

Fix this memory leak by calling the according TVLV handler unregister
routine for the multicast tracker TVLV upon batman-adv interface
deletion.

Fixes: 8ed36122d709 ("batman-adv: mcast: implement multicast packet reception 
and forwarding")
Reported-by: syzbot+ebe64cc5950868e77...@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/beadc4060f0cb...@google.com/
Signed-off-by: Linus Lüssing 
---
 net/batman-adv/multicast.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index c8620905c2dc..38fab5e46ae2 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -2183,6 +2183,7 @@ void batadv_mcast_free(struct batadv_priv *bat_priv)
cancel_delayed_work_sync(_priv->mcast.work);
 
batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_MCAST, 2);
+   batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_MCAST_TRACKER, 1);
batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_MCAST, 2);
 
/* safely calling outside of worker, as worker was canceled above */
-- 
2.43.0



Re: [syzbot] [btrfs?] memory leak in corrupted

2024-01-16 Thread Sven Eckelmann
@Linus, this looks like something for you.

On Tuesday, 16 January 2024 10:27:20 CET syzbot wrote:
> syzbot found the following issue on:
> 
> HEAD commit:052d534373b7 Merge tag 'exfat-for-6.8-rc1' of git://git.ke..
> git tree:   upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=14620debe8
> kernel config:  https://syzkaller.appspot.com/x/.config?x=a7031f9e71583b4a
> dashboard link: https://syzkaller.appspot.com/bug?extid=ebe64cc5950868e77358
> compiler:   gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for 
> Debian) 2.40
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=16a344c1e8
> 
> Downloadable assets:
> disk image: 
> https://storage.googleapis.com/syzbot-assets/82a7201eef4c/disk-052d5343.raw.xz
> vmlinux: 
> https://storage.googleapis.com/syzbot-assets/ca12b4c31826/vmlinux-052d5343.xz
> kernel image: 
> https://storage.googleapis.com/syzbot-assets/3f07360ba5a8/bzImage-052d5343.xz
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+ebe64cc5950868e77...@syzkaller.appspotmail.com

The relevant line is the batadv_mcast_forw_tracker_tvlv_handler registration 
in batadv_mcast_init() which was introduced in
commit 07afe1ba288c ("batman-adv: mcast: implement multicast packet reception 
and forwarding")

And I can't find the batadv_tvlv_handler_unregister for 
BATADV_TVLV_MCAST_TRACKER in batadv_mcast_free()

Kind regards,
Sven

> 
> BUG: memory leak
> unreferenced object 0x88811c71a980 (size 64):
>   comm "syz-executor.7", pid 5063, jiffies 4294953937
>   hex dump (first 32 bytes):
> 00 00 00 00 00 00 00 00 20 8e 7e 1c 81 88 ff ff   .~.
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  
>   backtrace (crc 9f8721dd):
> [] kmemleak_alloc_recursive include/linux/kmemleak.h:42 
> [inline]
> [] slab_post_alloc_hook mm/slub.c:3817 [inline]
> [] slab_alloc_node mm/slub.c:3860 [inline]
> [] kmalloc_trace+0x283/0x330 mm/slub.c:4007
> [] kmalloc include/linux/slab.h:590 [inline]
> [] kzalloc include/linux/slab.h:711 [inline]
> [] batadv_tvlv_handler_register+0xf7/0x2a0 
> net/batman-adv/tvlv.c:560
> [] batadv_mcast_init+0x4f/0xc0 
> net/batman-adv/multicast.c:1926
> [] batadv_mesh_init+0x209/0x2f0 
> net/batman-adv/main.c:231
> [] batadv_softif_init_late+0x1f8/0x280 
> net/batman-adv/soft-interface.c:812
> [] register_netdevice+0x189/0xca0 net/core/dev.c:10188
> [] batadv_softif_newlink+0x55/0x70 
> net/batman-adv/soft-interface.c:1088
> [] rtnl_newlink_create net/core/rtnetlink.c:3515 
> [inline]
> [] __rtnl_newlink+0xb10/0xec0 net/core/rtnetlink.c:3735
> [] rtnl_newlink+0x4c/0x70 net/core/rtnetlink.c:3748
> [] rtnetlink_rcv_msg+0x22f/0x5b0 
> net/core/rtnetlink.c:6615
> [] netlink_rcv_skb+0x91/0x1d0 
> net/netlink/af_netlink.c:2543
> [] netlink_unicast_kernel net/netlink/af_netlink.c:1341 
> [inline]
> [] netlink_unicast+0x2c2/0x440 
> net/netlink/af_netlink.c:1367
> [] netlink_sendmsg+0x341/0x690 
> net/netlink/af_netlink.c:1908
> [] sock_sendmsg_nosec net/socket.c:730 [inline]
> [] __sock_sendmsg+0x52/0xa0 net/socket.c:745
> [] __sys_sendto+0x164/0x1e0 net/socket.c:2191
> [] __do_sys_sendto net/socket.c:2203 [inline]
> [] __se_sys_sendto net/socket.c:2199 [inline]
> [] __x64_sys_sendto+0x28/0x30 net/socket.c:2199



signature.asc
Description: This is a digitally signed message part.


[syzbot] [btrfs?] memory leak in corrupted

2024-01-16 Thread syzbot
Hello,

syzbot found the following issue on:

HEAD commit:052d534373b7 Merge tag 'exfat-for-6.8-rc1' of git://git.ke..
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14620debe8
kernel config:  https://syzkaller.appspot.com/x/.config?x=a7031f9e71583b4a
dashboard link: https://syzkaller.appspot.com/bug?extid=ebe64cc5950868e77358
compiler:   gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 
2.40
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=16a344c1e8

Downloadable assets:
disk image: 
https://storage.googleapis.com/syzbot-assets/82a7201eef4c/disk-052d5343.raw.xz
vmlinux: 
https://storage.googleapis.com/syzbot-assets/ca12b4c31826/vmlinux-052d5343.xz
kernel image: 
https://storage.googleapis.com/syzbot-assets/3f07360ba5a8/bzImage-052d5343.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+ebe64cc5950868e77...@syzkaller.appspotmail.com

BUG: memory leak
unreferenced object 0x88811c71a980 (size 64):
  comm "syz-executor.7", pid 5063, jiffies 4294953937
  hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 20 8e 7e 1c 81 88 ff ff   .~.
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  
  backtrace (crc 9f8721dd):
[] kmemleak_alloc_recursive include/linux/kmemleak.h:42 
[inline]
[] slab_post_alloc_hook mm/slub.c:3817 [inline]
[] slab_alloc_node mm/slub.c:3860 [inline]
[] kmalloc_trace+0x283/0x330 mm/slub.c:4007
[] kmalloc include/linux/slab.h:590 [inline]
[] kzalloc include/linux/slab.h:711 [inline]
[] batadv_tvlv_handler_register+0xf7/0x2a0 
net/batman-adv/tvlv.c:560
[] batadv_mcast_init+0x4f/0xc0 
net/batman-adv/multicast.c:1926
[] batadv_mesh_init+0x209/0x2f0 net/batman-adv/main.c:231
[] batadv_softif_init_late+0x1f8/0x280 
net/batman-adv/soft-interface.c:812
[] register_netdevice+0x189/0xca0 net/core/dev.c:10188
[] batadv_softif_newlink+0x55/0x70 
net/batman-adv/soft-interface.c:1088
[] rtnl_newlink_create net/core/rtnetlink.c:3515 [inline]
[] __rtnl_newlink+0xb10/0xec0 net/core/rtnetlink.c:3735
[] rtnl_newlink+0x4c/0x70 net/core/rtnetlink.c:3748
[] rtnetlink_rcv_msg+0x22f/0x5b0 net/core/rtnetlink.c:6615
[] netlink_rcv_skb+0x91/0x1d0 
net/netlink/af_netlink.c:2543
[] netlink_unicast_kernel net/netlink/af_netlink.c:1341 
[inline]
[] netlink_unicast+0x2c2/0x440 
net/netlink/af_netlink.c:1367
[] netlink_sendmsg+0x341/0x690 
net/netlink/af_netlink.c:1908
[] sock_sendmsg_nosec net/socket.c:730 [inline]
[] __sock_sendmsg+0x52/0xa0 net/socket.c:745
[] __sys_sendto+0x164/0x1e0 net/socket.c:2191
[] __do_sys_sendto net/socket.c:2203 [inline]
[] __se_sys_sendto net/socket.c:2199 [inline]
[] __x64_sys_sendto+0x28/0x30 net/socket.c:2199

BUG: memory leak
unreferenced object 0x88811c8561c0 (size 64):
  comm "syz-executor.0", pid 5062, jiffies 4294953941
  hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 20 ce 7e 1c 81 88 ff ff   .~.
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  
  backtrace (crc 7256c890):
[] kmemleak_alloc_recursive include/linux/kmemleak.h:42 
[inline]
[] slab_post_alloc_hook mm/slub.c:3817 [inline]
[] slab_alloc_node mm/slub.c:3860 [inline]
[] kmalloc_trace+0x283/0x330 mm/slub.c:4007
[] kmalloc include/linux/slab.h:590 [inline]
[] kzalloc include/linux/slab.h:711 [inline]
[] batadv_tvlv_handler_register+0xf7/0x2a0 
net/batman-adv/tvlv.c:560
[] batadv_mcast_init+0x4f/0xc0 
net/batman-adv/multicast.c:1926
[] batadv_mesh_init+0x209/0x2f0 net/batman-adv/main.c:231
[] batadv_softif_init_late+0x1f8/0x280 
net/batman-adv/soft-interface.c:812
[] register_netdevice+0x189/0xca0 net/core/dev.c:10188
[] batadv_softif_newlink+0x55/0x70 
net/batman-adv/soft-interface.c:1088
[] rtnl_newlink_create net/core/rtnetlink.c:3515 [inline]
[] __rtnl_newlink+0xb10/0xec0 net/core/rtnetlink.c:3735
[] rtnl_newlink+0x4c/0x70 net/core/rtnetlink.c:3748
[] rtnetlink_rcv_msg+0x22f/0x5b0 net/core/rtnetlink.c:6615
[] netlink_rcv_skb+0x91/0x1d0 
net/netlink/af_netlink.c:2543
[] netlink_unicast_kernel net/netlink/af_netlink.c:1341 
[inline]
[] netlink_unicast+0x2c2/0x440 
net/netlink/af_netlink.c:1367
[] netlink_sendmsg+0x341/0x690 
net/netlink/af_netlink.c:1908
[] sock_sendmsg_nosec net/socket.c:730 [inline]
[] __sock_sendmsg+0x52/0xa0 net/socket.c:745
[] __sys_sendto+0x164/0x1e0 net/socket.c:2191
[] __do_sys_sendto net/socket.c:2203 [inline]
[] __se_sys_sendto net/socket.c:2199 [inline]
[] __x64_sys_sendto+0x28/0x30 net/socket.c:2199

BUG: memory leak
unreferenced object 0x88811cd88cc0 (size 64):
  comm "syz-executor.5", pid 5078, jiffies 4294953981
  hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 20 8e 05 1d 81 88 ff ff   ...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00