Skip to contentSkip to conversation

memory leak in kobject_set_name_vargs

PATCH New syzbot 2 participants 2 messages May 29, 2019 – Jun 10, 2019 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

Hello,

syzbot found the following crash on:

HEAD commit:    9fb67d64 Merge tag 'pinctrl-v5.2-2' of git://git.kernel.or..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11929a5ca00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=64479170dcaf0e11
dashboard link: https://syzkaller.appspot.com/bug?extid=7fddca22578bc67c3fe4
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1260e44aa00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13014582a00000

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

Reported-by [email protected]

ffffffffda RBX: 0000000000000003 RCX: 00000000004426c9

BUG: memory leak
unreferenced object 0xffff88811d8a84e0 (size 32):
  comm "syz-executor542", pid 6993, jiffies 4294943975 (age 8.330s)
  hex dump (first 32 bytes):
    70 68 79 33 00 74 61 73 6b 2f 36 39 39 33 00 de  phy3.task/6993..
    33 33 ff aa aa 28 00 00 00 00 00 00 00 00 00 00  33...(..........
  backtrace:
    [<000000007298dac3>] kmemleak_alloc_recursive  
include/linux/kmemleak.h:55 [inline]
    [<000000007298dac3>] slab_post_alloc_hook mm/slab.h:439 [inline]
    [<000000007298dac3>] slab_alloc mm/slab.c:3326 [inline]
    [<000000007298dac3>] __do_kmalloc mm/slab.c:3658 [inline]
    [<000000007298dac3>] __kmalloc_track_caller+0x15d/0x2c0 mm/slab.c:3675
    [<000000002d35f1ca>] kvasprintf+0x6d/0xe0 lib/kasprintf.c:25
    [<00000000a242e8c2>] kvasprintf_const+0x96/0xe0 lib/kasprintf.c:49
    [<000000009923ecab>] kobject_set_name_vargs+0x40/0xe0 lib/kobject.c:289
    [<0000000031da656f>] dev_set_name+0x63/0x90 drivers/base/core.c:1915
    [<00000000cb933060>] wiphy_new_nm+0x2d9/0x820 net/wireless/core.c:470
    [<00000000fe076c30>] ieee80211_alloc_hw_nm+0x158/0x770  
net/mac80211/main.c:551
    [<000000002d397aa1>] mac80211_hwsim_new_radio+0xad/0x1150  
drivers/net/wireless/mac80211_hwsim.c:2655
    [<00000000de4d0f50>] hwsim_new_radio_nl+0x369/0x50a  
drivers/net/wireless/mac80211_hwsim.c:3490
    [<00000000c2565b18>] genl_family_rcv_msg+0x2ab/0x5b0  
net/netlink/genetlink.c:629
    [<00000000dbd164a1>] genl_rcv_msg+0x54/0x9c net/netlink/genetlink.c:654
    [<00000000cfe4f152>] netlink_rcv_skb+0x61/0x170  
net/netlink/af_netlink.c:2486
    [<000000001803b485>] genl_rcv+0x29/0x40 net/netlink/genetlink.c:665
    [<000000008f236552>] netlink_unicast_kernel  
net/netlink/af_netlink.c:1311 [inline]
    [<000000008f236552>] netlink_unicast+0x1ec/0x2d0  
net/netlink/af_netlink.c:1337
    [<0000000030d22a07>] netlink_sendmsg+0x26a/0x480  
net/netlink/af_netlink.c:1926
    [<00000000b09b44f1>] sock_sendmsg_nosec net/socket.c:652 [inline]
    [<00000000b09b44f1>] sock_sendmsg+0x54/0x70 net/socket.c:671

---
This bug 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 bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot. syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

#1 lore raw

PATCH 1/1 cfg80211: fix memory leak of wiphy device name

From: Eric Biggers <[email protected]>

In wiphy_new_nm(), if an error occurs after dev_set_name() and device_initialize() have already been called, it's necessary to call put_device() (via wiphy_free()) to avoid a memory leak.

Reported-by [email protected]
Fixes 1f87f7d3a3b4 ("cfg80211: add rfkill support")
---
 net/wireless/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/core.c +1 -1
index 037816163e70d..458f5e0906875 100644
@@ -514,7 +514,7 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
 				   &rdev->rfkill_ops, rdev);
 
 	if (!rdev->rfkill) {
-		kfree(rdev);
+		wiphy_free(&rdev->wiphy);
 		return NULL;
 	}
 
Signature · 1 line
2.22.0.rc2.383.gf4fbbf30c2-goog