Hello,
syzbot found the following crash on:
HEAD commit: f66ed1eb Merge tag 'iomap-5.7-fixes-1' of git://git.kernel..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13a4fa9c100000
kernel config: https://syzkaller.appspot.com/x/.config?x=5b075813ec8b93cd
dashboard link: https://syzkaller.appspot.com/bug?extid=22b5ef302c7c40d94ea8
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12315918100000
The bug was bisected to:
commit 7c4310ff56422ea43418305d22bbc5fe19150ec4
Author: NeilBrown <[email protected]>
Date: Fri Apr 3 03:33:41 2020 +0000
SUNRPC: defer slow parts of rpc_free_client() to a workqueue.
bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=12176e60100000
final crash: https://syzkaller.appspot.com/x/report.txt?x=11176e60100000
console output: https://syzkaller.appspot.com/x/log.txt?x=16176e60100000
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: [email protected]
Fixes: 7c4310ff5642 ("SUNRPC: defer slow parts of rpc_free_client() to a workqueue.")
IPv6: ADDRCONF(NETDEV_CHANGE): veth1_vlan: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth0_vlan: link becomes ready
==================================================================
BUG: KASAN: use-after-free in rpc_net_ns+0x222/0x230 net/sunrpc/clnt.c:1506
Read of size 8 at addr ffff8880a7c888d8 by task kworker/0:3/2690
CPU: 0 PID: 2690 Comm: kworker/0:3 Not tainted 5.7.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events rpc_free_client_work
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x188/0x20d lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xd3/0x315 mm/kasan/report.c:382
__kasan_report.cold+0x35/0x4d mm/kasan/report.c:511
kasan_report+0x33/0x50 mm/kasan/common.c:625
rpc_net_ns+0x222/0x230 net/sunrpc/clnt.c:1506
rpc_clnt_remove_pipedir net/sunrpc/clnt.c:111 [inline]
rpc_free_client_work+0x1a/0x60 net/sunrpc/clnt.c:892
process_one_work+0x965/0x16a0 kernel/workqueue.c:2268
worker_thread+0x96/0xe20 kernel/workqueue.c:2414
kthread+0x388/0x470 kernel/kthread.c:268
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
Allocated by task 8372:
save_stack+0x1b/0x40 mm/kasan/common.c:49
set_track mm/kasan/common.c:57 [inline]
__kasan_kmalloc mm/kasan/common.c:495 [inline]
__kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:468
__do_kmalloc mm/slab.c:3656 [inline]
__kmalloc+0x161/0x7a0 mm/slab.c:3665
kmalloc include/linux/slab.h:560 [inline]
kzalloc include/linux/slab.h:669 [inline]
xprt_alloc+0x2d/0x800 net/sunrpc/xprt.c:1658
xs_setup_xprt.part.0+0x56/0x2e0 net/sunrpc/xprtsock.c:2735
xs_setup_xprt net/sunrpc/xprtsock.c:2906 [inline]
xs_setup_udp+0x9e/0x890 net/sunrpc/xprtsock.c:2850
xprt_create_transport+0xf9/0x480 net/sunrpc/xprt.c:1905
rpc_create+0x282/0x680 net/sunrpc/clnt.c:581
nfs_create_rpc_client+0x4eb/0x680 fs/nfs/client.c:535
nfs_init_client fs/nfs/client.c:652 [inline]
nfs_init_client+0x6d/0xf0 fs/nfs/client.c:639
nfs_get_client+0x1098/0x1430 fs/nfs/client.c:429
nfs_init_server+0x305/0xf00 fs/nfs/client.c:691
nfs_create_server+0x15c/0x700 fs/nfs/client.c:978
nfs_try_get_tree+0x166/0x8d0 fs/nfs/super.c:922
nfs_get_tree+0x95a/0x13a0 fs/nfs/fs_context.c:1291
vfs_get_tree+0x89/0x2f0 fs/super.c:1547
do_new_mount fs/namespace.c:2816 [inline]
do_mount+0x1306/0x1b30 fs/namespace.c:3141
__do_sys_mount fs/namespace.c:3350 [inline]
__se_sys_mount fs/namespace.c:3327 [inline]
__x64_sys_mount+0x18f/0x230 fs/namespace.c:3327
do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
entry_SYSCALL_64_after_hwframe+0x49/0xb3
Freed by task 23:
save_stack+0x1b/0x40 mm/kasan/common.c:49
set_track mm/kasan/common.c:57 [inline]
kasan_set_free_info mm/kasan/common.c:317 [inline]
__kasan_slab_free+0xf7/0x140 mm/kasan/common.c:456
__cache_free mm/slab.c:3426 [inline]
kmem_cache_free_bulk+0x7d/0x280 mm/slab.c:3721
kfree_bulk include/linux/slab.h:412 [inline]
kfree_rcu_work+0x1a1/0x480 kernel/rcu/tree.c:2859
process_one_work+0x965/0x16a0 kernel/workqueue.c:2268
worker_thread+0x96/0xe20 kernel/workqueue.c:2414
kthread+0x388/0x470 kernel/kthread.c:268
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
The buggy address belongs to the object at ffff8880a7c88000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 2264 bytes inside of
4096-byte region [ffff8880a7c88000, ffff8880a7c89000)
The buggy address belongs to the page:
page:ffffea00029f2200 refcount:1 mapcount:0 mapping:00000000862db9cd index:0x0 head:ffffea00029f2200 order:1 compound_mapcount:0
flags: 0xfffe0000010200(slab|head)
raw: 00fffe0000010200 ffffea00029ca708 ffffea00029a1c88 ffff8880aa002000
raw: 0000000000000000 ffff8880a7c88000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8880a7c88780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a7c88800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a7c88880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880a7c88900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a7c88980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
---
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.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches
Parts of rpc_free_client() were recently moved to
a separate rpc_free_clent_work(). This introduced
a use-after-free as rpc_clnt_remove_pipedir() calls
rpc_net_ns(), and that uses clnt->cl_xprt which has already
been freed.
So move the call to xprt_put() after the call to
rpc_clnt_remove_pipedir().
Reported-by: [email protected]
Fixes: 7c4310ff5642 ("SUNRPC: defer slow parts of rpc_free_client() to a workqueue.")
Signed-off-by: NeilBrown <[email protected]>
---
net/sunrpc/clnt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 8350d3a2e9a7..8d3972ea688b 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -890,6 +890,7 @@ static void rpc_free_client_work(struct work_struct *work)
*/
rpc_clnt_debugfs_unregister(clnt);
rpc_clnt_remove_pipedir(clnt);
+ xprt_put(rcu_dereference_raw(clnt->cl_xprt));
kfree(clnt);
rpciod_down();
@@ -907,7 +908,6 @@ rpc_free_client(struct rpc_clnt *clnt)
rpc_unregister_client(clnt);
rpc_free_iostats(clnt->cl_metrics);
clnt->cl_metrics = NULL;
- xprt_put(rcu_dereference_raw(clnt->cl_xprt));
xprt_iter_destroy(&clnt->cl_xpi);
put_cred(clnt->cl_cred);
rpc_free_clid(clnt);
--
2.26.2