bisecting cause commit starting from 1c273e10bc0cc7efb933e0ca10e260cdfc9f0b8c building syzkaller on 3d01c4de549b4e4bddba6102715c212bbcff2fbb testing commit 1c273e10bc0cc7efb933e0ca10e260cdfc9f0b8c with gcc (GCC) 10.2.1 20210217 kernel signature: 9b1d8cdc7a1ce5f21a0f021fa4fa04b3a2e53e419f7f384398a43fd0b62d4e11 all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs testing release v5.11 testing commit f40ddce88593482919761f74910f42f4b84c004b with gcc (GCC) 10.2.1 20210217 kernel signature: 556c68b2072c9c9b571946a03477c0a55df44b6e17fccdb20b8500bf088d912c all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs testing release v5.10 testing commit 2c85ebc57b3e1817b6ce1a6b703928e113a90442 with gcc (GCC) 10.2.1 20210217 kernel signature: 9f5e423a62fc392d4c1b8ef97fe93ea652337b553fc59b1b58676621fb7ff52a all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs testing release v5.9 testing commit bbf5c979011a099af5dc76498918ed7df445635b with gcc (GCC) 10.2.1 20210217 kernel signature: 1c7bb54746162e5eb2feea2d38f621b205ca6b8e4d3fa1b47ccdcfb9cc9359c3 all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs testing release v5.8 testing commit bcf876870b95592b52519ed4aafcf9d95999bc9c with gcc (GCC) 8.4.1 20210217 kernel signature: 007da52466eac5998870fadc0e1c033150bb5c4953ce96595214094ab6682d1d all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs testing release v5.7 testing commit 3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162 with gcc (GCC) 8.4.1 20210217 kernel signature: bf841806615eb564dbcf4e84dfaf850cb0d204d33db1acd3857062a53b3fdf6f all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs testing release v5.6 testing commit 7111951b8d4973bda27ff663f2cf18b663d15b48 with gcc (GCC) 8.4.1 20210217 kernel signature: 3f24a1af33c764e34bb6bd247a86cc552df2d9d55224fbc47bf5bf33283b305e all runs: OK # git bisect start 3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162 7111951b8d4973bda27ff663f2cf18b663d15b48 Bisecting: 7542 revisions left to test after this (roughly 13 steps) [50a5de895dbe5df947b3a695777db5b2c313e065] Merge tag 'for-linus-hmm' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma testing commit 50a5de895dbe5df947b3a695777db5b2c313e065 with gcc (GCC) 8.4.1 20210217 kernel signature: 97aa3ba683882f4d0ac63e6b81dcffa0b55bb607db151820208da2afcb2d6312 all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs # git bisect bad 50a5de895dbe5df947b3a695777db5b2c313e065 Bisecting: 4204 revisions left to test after this (roughly 12 steps) [56a451b780676bc1cdac011735fe2869fa2e9abf] Merge tag 'ntb-5.7' of git://github.com/jonmason/ntb testing commit 56a451b780676bc1cdac011735fe2869fa2e9abf with gcc (GCC) 8.4.1 20210217 kernel signature: 7f3877432927b32721837646094ba1660437050a096c35a94f370070d0f46511 all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs # git bisect bad 56a451b780676bc1cdac011735fe2869fa2e9abf Bisecting: 1643 revisions left to test after this (roughly 11 steps) [49835c15a55225e9b3ff9cc9317135b334ea2d49] Merge tag 'pm-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm testing commit 49835c15a55225e9b3ff9cc9317135b334ea2d49 with gcc (GCC) 8.4.1 20210217 kernel signature: 7fea24cad3a34a60d32f2480b4a63c625c3ca96646025291a8214a8d95765e4c all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs # git bisect bad 49835c15a55225e9b3ff9cc9317135b334ea2d49 Bisecting: 934 revisions left to test after this (roughly 10 steps) [063d1942247668eb0bb800aef5afbbef337344be] Merge tag 'media/v5.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media testing commit 063d1942247668eb0bb800aef5afbbef337344be with gcc (GCC) 8.4.1 20210217 kernel signature: 33124adfb0c4bbac4d61b3eb26a6068c272ebe207d15d6a2db3f7a004aa94635 all runs: OK # git bisect good 063d1942247668eb0bb800aef5afbbef337344be Bisecting: 516 revisions left to test after this (roughly 9 steps) [e681bb287f40e7a9dbcb04cef80fd87a2511ab86] staging: vt6656: Use DIV_ROUND_UP macro instead of specific code testing commit e681bb287f40e7a9dbcb04cef80fd87a2511ab86 with gcc (GCC) 8.4.1 20210217 kernel signature: e450d8a516fcd175a6b40061b4d4f4b6a1fd2082f374e0f334de9628fd8d0799 all runs: OK # git bisect good e681bb287f40e7a9dbcb04cef80fd87a2511ab86 Bisecting: 266 revisions left to test after this (roughly 8 steps) [db34c5ffee649e2c4c870d1031a996398a187cf5] Merge tag 'usb-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb testing commit db34c5ffee649e2c4c870d1031a996398a187cf5 with gcc (GCC) 8.4.1 20210217 kernel signature: 18ccde2b54a555e1fc54eda956ed9b88b2754f629d0a9ef94cac7c39eafe1f38 all runs: OK # git bisect good db34c5ffee649e2c4c870d1031a996398a187cf5 Bisecting: 136 revisions left to test after this (roughly 7 steps) [6dfae59d37aec535db5e462db1a1ff76c5e3fa25] Merge remote-tracking branch 'regulator/for-next' into tmp testing commit 6dfae59d37aec535db5e462db1a1ff76c5e3fa25 with gcc (GCC) 8.4.1 20210217 kernel signature: 380cc25edd1d6e1c3b8073443cd4850395280a6f10a204f543c6a7f903eb6877 all runs: OK # git bisect good 6dfae59d37aec535db5e462db1a1ff76c5e3fa25 Bisecting: 66 revisions left to test after this (roughly 6 steps) [ada0629bd3135504680fc787cb4dc79f43ff4441] Merge branches 'pm-core', 'pm-sleep', 'pm-acpi' and 'pm-domains' testing commit ada0629bd3135504680fc787cb4dc79f43ff4441 with gcc (GCC) 8.4.1 20210217 kernel signature: 31767436737152ed61f351c3e98e0fa0f1019260965d0a4290aab9f405e942b0 all runs: OK # git bisect good ada0629bd3135504680fc787cb4dc79f43ff4441 Bisecting: 33 revisions left to test after this (roughly 5 steps) [4445eb6d942a4ba0e6ac07ca555dec83577289e8] Merge tag 'stable-shared-branch-for-driver-tree' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi into driver-core-next testing commit 4445eb6d942a4ba0e6ac07ca555dec83577289e8 with gcc (GCC) 8.4.1 20210217 kernel signature: 65b056cb7e4056237d242c4ecb5ed7d8dc1b231fb019ca8a4d3c2c067ca2111a run #0: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs run #1: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs run #2: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs run #3: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs run #4: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs run #5: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs run #6: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs run #7: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs run #8: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs run #9: boot failed: can't ssh into the instance # git bisect bad 4445eb6d942a4ba0e6ac07ca555dec83577289e8 Bisecting: 16 revisions left to test after this (roughly 4 steps) [ab7789c5174cb12c9f9fb4f85efc6d18e7f04c2b] driver core: Add missing annotation for device_links_read_lock() testing commit ab7789c5174cb12c9f9fb4f85efc6d18e7f04c2b with gcc (GCC) 8.4.1 20210217 kernel signature: ebd8a9c6fb3435109d1df285ad9096b403302a00fff9587da161b5b92023c0c8 all runs: OK # git bisect good ab7789c5174cb12c9f9fb4f85efc6d18e7f04c2b Bisecting: 8 revisions left to test after this (roughly 3 steps) [4dfff3d55440a9f8726a0f7d62a9c33594b58b10] arch_topology: Fix putting invalid cpu clk testing commit 4dfff3d55440a9f8726a0f7d62a9c33594b58b10 with gcc (GCC) 8.4.1 20210217 kernel signature: e38ed6fc82e417392abdcb51d25c25bfdaec16d156cead56cef17a5ba011c424 run #0: OK run #1: OK run #2: OK run #3: OK run #4: OK run #5: OK run #6: OK run #7: OK run #8: OK run #9: boot failed: can't ssh into the instance # git bisect good 4dfff3d55440a9f8726a0f7d62a9c33594b58b10 Bisecting: 4 revisions left to test after this (roughly 2 steps) [14422f14da818a3f12344dceee47b4206870a24d] component: allow missing unbind callback testing commit 14422f14da818a3f12344dceee47b4206870a24d with gcc (GCC) 8.4.1 20210217 kernel signature: 56319f259eacb22b42a7237663aad83779326162219f43d9687180f7a8d5a670 all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs # git bisect bad 14422f14da818a3f12344dceee47b4206870a24d Bisecting: 1 revision left to test after this (roughly 1 step) [275678e7a9be6a0ea9c1bb493e48abf2f4a01be5] debugfs: Check module state before warning in {full/open}_proxy_open() testing commit 275678e7a9be6a0ea9c1bb493e48abf2f4a01be5 with gcc (GCC) 8.4.1 20210217 kernel signature: 1abf54d219eb339aa1daf300d923ad2ea075a5fd2855e2701d738aa2af1f6ea9 all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs # git bisect bad 275678e7a9be6a0ea9c1bb493e48abf2f4a01be5 Bisecting: 0 revisions left to test after this (roughly 0 steps) [bcfbd3523f3c6eea51a74d217a8ebc5463bcb7f4] firmware: fix a double abort case with fw_load_sysfs_fallback testing commit bcfbd3523f3c6eea51a74d217a8ebc5463bcb7f4 with gcc (GCC) 8.4.1 20210217 kernel signature: f8f303ca59dfe359e3a0fbb794c43fb57fb2682c800ffa47d5030eb325b482ac all runs: crashed: KASAN: use-after-free Read in firmware_fallback_sysfs # git bisect bad bcfbd3523f3c6eea51a74d217a8ebc5463bcb7f4 bcfbd3523f3c6eea51a74d217a8ebc5463bcb7f4 is the first bad commit commit bcfbd3523f3c6eea51a74d217a8ebc5463bcb7f4 Author: Junyong Sun Date: Tue Mar 3 10:36:08 2020 +0800 firmware: fix a double abort case with fw_load_sysfs_fallback fw_sysfs_wait_timeout may return err with -ENOENT at fw_load_sysfs_fallback and firmware is already in abort status, no need to abort again, so skip it. This issue is caused by concurrent situation like below: when thread 1# wait firmware loading, thread 2# may write -1 to abort loading and wakeup thread 1# before it timeout. so wait_for_completion_killable_timeout of thread 1# would return remaining time which is != 0 with fw_st->status FW_STATUS_ABORTED.And the results would be converted into err -ENOENT in __fw_state_wait_common and transfered to fw_load_sysfs_fallback in thread 1#. The -ENOENT means firmware status is already at ABORTED, so fw_load_sysfs_fallback no need to get mutex to abort again. ----------------------------- thread 1#,wait for loading fw_load_sysfs_fallback ->fw_sysfs_wait_timeout ->__fw_state_wait_common ->wait_for_completion_killable_timeout in __fw_state_wait_common, ... 93 ret = wait_for_completion_killable_timeout(&fw_st->completion, timeout); 94 if (ret != 0 && fw_st->status == FW_STATUS_ABORTED) 95 return -ENOENT; 96 if (!ret) 97 return -ETIMEDOUT; 98 99 return ret < 0 ? ret : 0; ----------------------------- thread 2#, write -1 to abort loading firmware_loading_store ->fw_load_abort ->__fw_load_abort ->fw_state_aborted ->__fw_state_set ->complete_all in __fw_state_set, ... 111 if (status == FW_STATUS_DONE || status == FW_STATUS_ABORTED) 112 complete_all(&fw_st->completion); ------------------------------------------- BTW,the double abort issue would not cause kernel panic or create an issue, but slow down it sometimes.The change is just a minor optimization. Signed-off-by: Junyong Sun Acked-by: Luis Chamberlain Link: https://lore.kernel.org/r/1583202968-28792-1-git-send-email-sunjunyong@xiaomi.com Signed-off-by: Greg Kroah-Hartman drivers/base/firmware_loader/fallback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) culprit signature: f8f303ca59dfe359e3a0fbb794c43fb57fb2682c800ffa47d5030eb325b482ac parent signature: e38ed6fc82e417392abdcb51d25c25bfdaec16d156cead56cef17a5ba011c424 revisions tested: 21, total time: 4h21m47.652681084s (build: 2h18m12.242037094s, test: 2h1m21.139504497s) first bad commit: bcfbd3523f3c6eea51a74d217a8ebc5463bcb7f4 firmware: fix a double abort case with fw_load_sysfs_fallback recipients (to): ["gregkh@linuxfoundation.org" "mcgrof@kernel.org" "sunjunyong@xiaomi.com" "sunjy516@gmail.com"] recipients (cc): [] crash: KASAN: use-after-free Read in firmware_fallback_sysfs platform regulatory.0: Falling back to sysfs fallback for: regulatory.db ================================================================== BUG: KASAN: use-after-free in __list_add_valid+0xab/0xf0 lib/list_debug.c:23 Read of size 8 at addr ffff8882374484b8 by task syz-executor.4/10990 CPU: 0 PID: 10990 Comm: syz-executor.4 Not tainted 5.6.0-rc5-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x96/0xe0 lib/dump_stack.c:118 print_address_description.constprop.4.cold.6+0x9/0x373 mm/kasan/report.c:374 __kasan_report.cold.7+0x7a/0x92 mm/kasan/report.c:506 kasan_report+0xe/0x20 mm/kasan/common.c:641 __list_add_valid+0xab/0xf0 lib/list_debug.c:23 __list_add include/linux/list.h:67 [inline] list_add include/linux/list.h:86 [inline] fw_load_sysfs_fallback drivers/base/firmware_loader/fallback.c:515 [inline] fw_load_from_user_helper drivers/base/firmware_loader/fallback.c:580 [inline] firmware_fallback_sysfs+0x386/0x9b8 drivers/base/firmware_loader/fallback.c:655 _request_firmware+0x53d/0xc20 drivers/base/firmware_loader/main.c:786 request_firmware+0x2d/0x40 drivers/base/firmware_loader/main.c:829 reg_reload_regdb+0x75/0x1e0 net/wireless/reg.c:1083 genl_family_rcv_msg_doit net/netlink/genetlink.c:673 [inline] genl_family_rcv_msg net/netlink/genetlink.c:718 [inline] genl_rcv_msg+0x5e7/0xf10 net/netlink/genetlink.c:735 netlink_rcv_skb+0x119/0x340 net/netlink/af_netlink.c:2478 genl_rcv+0x1f/0x30 net/netlink/genetlink.c:746 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline] netlink_unicast+0x434/0x630 net/netlink/af_netlink.c:1329 netlink_sendmsg+0x766/0xc10 net/netlink/af_netlink.c:1918 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg+0xac/0xf0 net/socket.c:672 ____sys_sendmsg+0x54e/0x760 net/socket.c:2343 ___sys_sendmsg+0xe4/0x160 net/socket.c:2397 __sys_sendmsg+0xce/0x170 net/socket.c:2430 do_syscall_64+0x98/0x560 arch/x86/entry/common.c:294 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x466459 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f8f7c32e188 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 000000000056c0b0 RCX: 0000000000466459 RDX: 0000000000000000 RSI: 0000000020000340 RDI: 0000000000000003 RBP: 00000000004bf9fb R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056c0b0 R13: 00007ffd39a5e9bf R14: 00007f8f7c32e300 R15: 0000000000022000 Allocated by task 10947: save_stack+0x19/0x80 mm/kasan/common.c:72 set_track mm/kasan/common.c:80 [inline] __kasan_kmalloc mm/kasan/common.c:515 [inline] __kasan_kmalloc.constprop.15+0xc1/0xd0 mm/kasan/common.c:488 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] __allocate_fw_priv drivers/base/firmware_loader/main.c:174 [inline] alloc_lookup_fw_priv drivers/base/firmware_loader/main.c:229 [inline] _request_firmware_prepare drivers/base/firmware_loader/main.c:708 [inline] _request_firmware+0x278/0xc20 drivers/base/firmware_loader/main.c:769 request_firmware+0x2d/0x40 drivers/base/firmware_loader/main.c:829 reg_reload_regdb+0x75/0x1e0 net/wireless/reg.c:1083 genl_family_rcv_msg_doit net/netlink/genetlink.c:673 [inline] genl_family_rcv_msg net/netlink/genetlink.c:718 [inline] genl_rcv_msg+0x5e7/0xf10 net/netlink/genetlink.c:735 netlink_rcv_skb+0x119/0x340 net/netlink/af_netlink.c:2478 genl_rcv+0x1f/0x30 net/netlink/genetlink.c:746 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline] netlink_unicast+0x434/0x630 net/netlink/af_netlink.c:1329 netlink_sendmsg+0x766/0xc10 net/netlink/af_netlink.c:1918 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg+0xac/0xf0 net/socket.c:672 ____sys_sendmsg+0x54e/0x760 net/socket.c:2343 ___sys_sendmsg+0xe4/0x160 net/socket.c:2397 __sys_sendmsg+0xce/0x170 net/socket.c:2430 do_syscall_64+0x98/0x560 arch/x86/entry/common.c:294 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 10947: save_stack+0x19/0x80 mm/kasan/common.c:72 set_track mm/kasan/common.c:80 [inline] kasan_set_free_info mm/kasan/common.c:337 [inline] __kasan_slab_free+0x124/0x170 mm/kasan/common.c:476 slab_free_hook mm/slub.c:1444 [inline] slab_free_freelist_hook+0x53/0x140 mm/slub.c:1477 slab_free mm/slub.c:3024 [inline] kfree+0xd6/0x3c0 mm/slub.c:3976 firmware_free_data drivers/base/firmware_loader/main.c:544 [inline] release_firmware.part.3+0xcb/0x130 drivers/base/firmware_loader/main.c:952 release_firmware drivers/base/firmware_loader/main.c:794 [inline] _request_firmware+0x5e2/0xc20 drivers/base/firmware_loader/main.c:793 request_firmware+0x2d/0x40 drivers/base/firmware_loader/main.c:829 reg_reload_regdb+0x75/0x1e0 net/wireless/reg.c:1083 genl_family_rcv_msg_doit net/netlink/genetlink.c:673 [inline] genl_family_rcv_msg net/netlink/genetlink.c:718 [inline] genl_rcv_msg+0x5e7/0xf10 net/netlink/genetlink.c:735 netlink_rcv_skb+0x119/0x340 net/netlink/af_netlink.c:2478 genl_rcv+0x1f/0x30 net/netlink/genetlink.c:746 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline] netlink_unicast+0x434/0x630 net/netlink/af_netlink.c:1329 netlink_sendmsg+0x766/0xc10 net/netlink/af_netlink.c:1918 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg+0xac/0xf0 net/socket.c:672 ____sys_sendmsg+0x54e/0x760 net/socket.c:2343 ___sys_sendmsg+0xe4/0x160 net/socket.c:2397 __sys_sendmsg+0xce/0x170 net/socket.c:2430 do_syscall_64+0x98/0x560 arch/x86/entry/common.c:294 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff888237448400 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 184 bytes inside of 256-byte region [ffff888237448400, ffff888237448500) The buggy address belongs to the page: page:ffffea0008dd1200 refcount:1 mapcount:0 mapping:ffff8880b5802780 index:0x0 compound_mapcount: 0 flags: 0x57ff00000010200(slab|head) raw: 057ff00000010200 ffffea0008e2d300 0000000200000002 ffff8880b5802780 raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888237448380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888237448400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888237448480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888237448500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888237448580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================