Skip to contentSkip to conversation

memory leak in nci_send_cmd

syzbot syzbot 2 participants 3 messages Aug 30

Subsystems (4)
lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

Hello,

syzbot found the following issue on:

HEAD commit:    73ae59e97596 Merge tag 'erofs-for-7.3-rc1-2' of git://git...
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12e70d49580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=563582168294b9d9
dashboard link: https://syzkaller.appspot.com/bug?extid=b197a0fb4e741cc5030e
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=11df1625580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=148b6979580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/0e5c9cbfb31a/disk-73ae59e9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/481171cf3bc4/vmlinux-73ae59e9.xz
kernel image: https://storage.googleapis.com/syzbot-assets/9df84fec3c49/bzImage-73ae59e9.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]
BUG: memory leak
unreferenced object 0xffff88810a94e600 (size 240):
  comm "syz.6.23", pid 5954, jiffies 4294942380
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 40 38 2b 81 88 ff ff 00 00 00 00 00 00 00 00  .@8+............
  backtrace (crc 98a4d7):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4696 [inline]
    slab_alloc_node mm/slub.c:4996 [inline]
    kmem_cache_alloc_node_noprof+0x39f/0x440 mm/slub.c:5068
    __alloc_skb+0xdc/0x4e0 net/core/skbuff.c:704
    alloc_skb include/linux/skbuff.h:1384 [inline]
    nci_skb_alloc include/net/nfc/nci_core.h:330 [inline]
    nci_send_cmd+0x46/0x110 net/nfc/nci/core.c:1397
    nci_reset_req net/nfc/nci/core.c:167 [inline]
    __nci_request net/nfc/nci/core.c:108 [inline]
    nci_open_device net/nfc/nci/core.c:503 [inline]
    nci_dev_up+0x1b6/0x690 net/nfc/nci/core.c:643
    nfc_dev_up+0xca/0x160 net/nfc/core.c:118
    nfc_genl_dev_up+0x3d/0x70 net/nfc/netlink.c:775
    genl_family_rcv_msg_doit+0x12e/0x1a0 net/netlink/genetlink.c:1114
    genl_family_rcv_msg net/netlink/genetlink.c:1194 [inline]
    genl_rcv_msg+0x302/0x440 net/netlink/genetlink.c:1209
    netlink_rcv_skb+0x89/0x1c0 net/netlink/af_netlink.c:2556
    genl_rcv+0x28/0x40 net/netlink/genetlink.c:1218
    netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
    netlink_unicast+0x38f/0x4e0 net/netlink/af_netlink.c:1345
    netlink_sendmsg+0x335/0x690 net/netlink/af_netlink.c:1900
    sock_sendmsg_nosec net/socket.c:800 [inline]
    __sock_sendmsg net/socket.c:815 [inline]
    ____sys_sendmsg+0x54a/0x580 net/socket.c:2713
    ___sys_sendmsg+0x101/0x140 net/socket.c:2767
    __sys_sendmsg+0xcd/0x140 net/socket.c:2799
    do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
    do_syscall_64+0xe9/0x530 arch/x86/entry/syscall_64.c:84

BUG: memory leak
unreferenced object 0xffff888109c4bc80 (size 704):
  comm "syz.6.23", pid 5954, jiffies 4294942380
  hex dump (first 32 bytes):
    20 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00   ...............
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace (crc 40ddf9):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4696 [inline]
    slab_alloc_node mm/slub.c:4996 [inline]
    kmem_cache_alloc_node_noprof+0x39f/0x440 mm/slub.c:5068
    kmalloc_reserve+0xd2/0x1b0 net/core/skbuff.c:615
    __alloc_skb+0x15d/0x4e0 net/core/skbuff.c:715
    alloc_skb include/linux/skbuff.h:1384 [inline]
    nci_skb_alloc include/net/nfc/nci_core.h:330 [inline]
    nci_send_cmd+0x46/0x110 net/nfc/nci/core.c:1397
    nci_reset_req net/nfc/nci/core.c:167 [inline]
    __nci_request net/nfc/nci/core.c:108 [inline]
    nci_open_device net/nfc/nci/core.c:503 [inline]
    nci_dev_up+0x1b6/0x690 net/nfc/nci/core.c:643
    nfc_dev_up+0xca/0x160 net/nfc/core.c:118
    nfc_genl_dev_up+0x3d/0x70 net/nfc/netlink.c:775
    genl_family_rcv_msg_doit+0x12e/0x1a0 net/netlink/genetlink.c:1114
    genl_family_rcv_msg net/netlink/genetlink.c:1194 [inline]
    genl_rcv_msg+0x302/0x440 net/netlink/genetlink.c:1209
    netlink_rcv_skb+0x89/0x1c0 net/netlink/af_netlink.c:2556
    genl_rcv+0x28/0x40 net/netlink/genetlink.c:1218
    netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
    netlink_unicast+0x38f/0x4e0 net/netlink/af_netlink.c:1345
    netlink_sendmsg+0x335/0x690 net/netlink/af_netlink.c:1900
    sock_sendmsg_nosec net/socket.c:800 [inline]
    __sock_sendmsg net/socket.c:815 [inline]
    ____sys_sendmsg+0x54a/0x580 net/socket.c:2713
    ___sys_sendmsg+0x101/0x140 net/socket.c:2767
    __sys_sendmsg+0xcd/0x140 net/socket.c:2799

BUG: memory leak
unreferenced object 0xffff88810aa0d700 (size 240):
  comm "syz.0.26", pid 5976, jiffies 4294942681
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 a0 5b 28 81 88 ff ff 00 00 00 00 00 00 00 00  ..[(............
  backtrace (crc cdb4723c):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4696 [inline]
    slab_alloc_node mm/slub.c:4996 [inline]
    kmem_cache_alloc_node_noprof+0x39f/0x440 mm/slub.c:5068
    __alloc_skb+0xdc/0x4e0 net/core/skbuff.c:704
    alloc_skb include/linux/skbuff.h:1384 [inline]
    nci_skb_alloc include/net/nfc/nci_core.h:330 [inline]
    nci_send_cmd+0x46/0x110 net/nfc/nci/core.c:1397
    nci_reset_req net/nfc/nci/core.c:167 [inline]
    __nci_request net/nfc/nci/core.c:108 [inline]
    nci_open_device net/nfc/nci/core.c:503 [inline]
    nci_dev_up+0x1b6/0x690 net/nfc/nci/core.c:643
    nfc_dev_up+0xca/0x160 net/nfc/core.c:118
    nfc_genl_dev_up+0x3d/0x70 net/nfc/netlink.c:775
    genl_family_rcv_msg_doit+0x12e/0x1a0 net/netlink/genetlink.c:1114
    genl_family_rcv_msg net/netlink/genetlink.c:1194 [inline]
    genl_rcv_msg+0x302/0x440 net/netlink/genetlink.c:1209
    netlink_rcv_skb+0x89/0x1c0 net/netlink/af_netlink.c:2556
    genl_rcv+0x28/0x40 net/netlink/genetlink.c:1218
    netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
    netlink_unicast+0x38f/0x4e0 net/netlink/af_netlink.c:1345
    netlink_sendmsg+0x335/0x690 net/netlink/af_netlink.c:1900
    sock_sendmsg_nosec net/socket.c:800 [inline]
    __sock_sendmsg net/socket.c:815 [inline]
    ____sys_sendmsg+0x54a/0x580 net/socket.c:2713
    ___sys_sendmsg+0x101/0x140 net/socket.c:2767
    __sys_sendmsg+0xcd/0x140 net/socket.c:2799
    do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
    do_syscall_64+0xe9/0x530 arch/x86/entry/syscall_64.c:84

connection error: failed to recv *flatrpc.ExecutorMessageRawT: EOF

---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

#1 lore raw

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 73ae59e975966d24e32926247ddb45a537ebe184

drivers/nfc/nfcmrvl/usb.c +7 -2
index c7f2afe00b93..7a4094797ba4 100644
@@ -224,12 +224,16 @@ static int nfcmrvl_usb_nci_send(struct nfcmrvl_private *priv,
        unsigned int pipe;
        int err;
 
-       if (!drv_data->bulk_tx_ep)
+       if (!drv_data->bulk_tx_ep) {
+               kfree_skb(skb);
                return -ENODEV;
+       }
 
        urb = usb_alloc_urb(0, GFP_ATOMIC);
-       if (!urb)
+       if (!urb) {
+               kfree_skb(skb);
                return -ENOMEM;
+       }
 
        pipe = usb_sndbulkpipe(drv_data->udev,
                                drv_data->bulk_tx_ep->bEndpointAddress);
@@ -254,6 +258,7 @@ static int nfcmrvl_usb_nci_send(struct nfcmrvl_private *priv,
                                "urb %p submission failed (%d)\n", urb, -err);
                kfree(urb->setup_packet);
                usb_unanchor_urb(urb);
+               kfree_skb(skb);
        } else {
                usb_mark_last_busy(drv_data->udev);
        }
author syzbot Tested-by
#2 lore raw
syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Tested on:

commit:         73ae59e9 Merge tag 'erofs-for-7.3-rc1-2' of git://git...
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=13247379580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=563582168294b9d9
dashboard link: https://syzkaller.appspot.com/bug?extid=b197a0fb4e741cc5030e
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
patch:          https://syzkaller.appspot.com/x/patch.diff?x=14287379580000

Note: testing is done by a robot and is best-effort only.