|
| 1 | +nfs: Handle error of rpc_proc_register() in nfs_net_init(). |
| 2 | + |
| 3 | +jira LE-3201 |
| 4 | +cve CVE-2024-36939 |
| 5 | +Rebuild_History Non-Buildable kernel-rt-4.18.0-553.22.1.rt7.363.el8_10 |
| 6 | +Rebuild_CHGLOG: - nfs: handle error of rpc_proc_register() in init_nfs_fs() (Scott Mayhew) [RHEL-39904] {CVE-2024-36939} |
| 7 | +Rebuild_FUZZ: 86.21% |
| 8 | +commit-author Kuniyuki Iwashima < [email protected]> |
| 9 | +commit 24457f1be29f1e7042e50a7749f5c2dde8c433c8 |
| 10 | +Empty-Commit: Cherry-Pick Conflicts during history rebuild. |
| 11 | +Will be included in final tarball splat. Ref for failed cherry-pick at: |
| 12 | +ciq/ciq_backports/kernel-rt-4.18.0-553.22.1.rt7.363.el8_10/24457f1b.failed |
| 13 | + |
| 14 | +syzkaller reported a warning [0] triggered while destroying immature |
| 15 | +netns. |
| 16 | + |
| 17 | +rpc_proc_register() was called in init_nfs_fs(), but its error |
| 18 | +has been ignored since at least the initial commit 1da177e4c3f4 |
| 19 | +("Linux-2.6.12-rc2"). |
| 20 | + |
| 21 | +Recently, commit d47151b79e32 ("nfs: expose /proc/net/sunrpc/nfs |
| 22 | +in net namespaces") converted the procfs to per-netns and made |
| 23 | +the problem more visible. |
| 24 | + |
| 25 | +Even when rpc_proc_register() fails, nfs_net_init() could succeed, |
| 26 | +and thus nfs_net_exit() will be called while destroying the netns. |
| 27 | + |
| 28 | +Then, remove_proc_entry() will be called for non-existing proc |
| 29 | +directory and trigger the warning below. |
| 30 | + |
| 31 | +Let's handle the error of rpc_proc_register() properly in nfs_net_init(). |
| 32 | + |
| 33 | +[0]: |
| 34 | +name 'nfs' |
| 35 | +WARNING: CPU: 1 PID: 1710 at fs/proc/generic.c:711 remove_proc_entry+0x1bb/0x2d0 fs/proc/generic.c:711 |
| 36 | +Modules linked in: |
| 37 | +CPU: 1 PID: 1710 Comm: syz-executor.2 Not tainted 6.8.0-12822-gcd51db110a7e #12 |
| 38 | +Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 |
| 39 | +RIP: 0010:remove_proc_entry+0x1bb/0x2d0 fs/proc/generic.c:711 |
| 40 | +Code: 41 5d 41 5e c3 e8 85 09 b5 ff 48 c7 c7 88 58 64 86 e8 09 0e 71 02 e8 74 09 b5 ff 4c 89 e6 48 c7 c7 de 1b 80 84 e8 c5 ad 97 ff <0f> 0b eb b1 e8 5c 09 b5 ff 48 c7 c7 88 58 64 86 e8 e0 0d 71 02 eb |
| 41 | +RSP: 0018:ffffc9000c6d7ce0 EFLAGS: 00010286 |
| 42 | +RAX: 0000000000000000 RBX: ffff8880422b8b00 RCX: ffffffff8110503c |
| 43 | +RDX: ffff888030652f00 RSI: ffffffff81105045 RDI: 0000000000000001 |
| 44 | +RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000 |
| 45 | +R10: 0000000000000001 R11: ffffffff81bb62cb R12: ffffffff84807ffc |
| 46 | +R13: ffff88804ad6fcc0 R14: ffffffff84807ffc R15: ffffffff85741ff8 |
| 47 | +FS: 00007f30cfba8640(0000) GS:ffff88807dd00000(0000) knlGS:0000000000000000 |
| 48 | +CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 |
| 49 | +CR2: 00007ff51afe8000 CR3: 000000005a60a005 CR4: 0000000000770ef0 |
| 50 | +DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 |
| 51 | +DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 |
| 52 | +PKRU: 55555554 |
| 53 | +Call Trace: |
| 54 | + <TASK> |
| 55 | + rpc_proc_unregister+0x64/0x70 net/sunrpc/stats.c:310 |
| 56 | + nfs_net_exit+0x1c/0x30 fs/nfs/inode.c:2438 |
| 57 | + ops_exit_list+0x62/0xb0 net/core/net_namespace.c:170 |
| 58 | + setup_net+0x46c/0x660 net/core/net_namespace.c:372 |
| 59 | + copy_net_ns+0x244/0x590 net/core/net_namespace.c:505 |
| 60 | + create_new_namespaces+0x2ed/0x770 kernel/nsproxy.c:110 |
| 61 | + unshare_nsproxy_namespaces+0xae/0x160 kernel/nsproxy.c:228 |
| 62 | + ksys_unshare+0x342/0x760 kernel/fork.c:3322 |
| 63 | + __do_sys_unshare kernel/fork.c:3393 [inline] |
| 64 | + __se_sys_unshare kernel/fork.c:3391 [inline] |
| 65 | + __x64_sys_unshare+0x1f/0x30 kernel/fork.c:3391 |
| 66 | + do_syscall_x64 arch/x86/entry/common.c:52 [inline] |
| 67 | + do_syscall_64+0x4f/0x110 arch/x86/entry/common.c:83 |
| 68 | + entry_SYSCALL_64_after_hwframe+0x46/0x4e |
| 69 | +RIP: 0033:0x7f30d0febe5d |
| 70 | +Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 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 8b 0d 73 9f 1b 00 f7 d8 64 89 01 48 |
| 71 | +RSP: 002b:00007f30cfba7cc8 EFLAGS: 00000246 ORIG_RAX: 0000000000000110 |
| 72 | +RAX: ffffffffffffffda RBX: 00000000004bbf80 RCX: 00007f30d0febe5d |
| 73 | +RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000006c020600 |
| 74 | +RBP: 00000000004bbf80 R08: 0000000000000000 R09: 0000000000000000 |
| 75 | +R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002 |
| 76 | +R13: 000000000000000b R14: 00007f30d104c530 R15: 0000000000000000 |
| 77 | + </TASK> |
| 78 | + |
| 79 | +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") |
| 80 | + Reported-by: syzkaller < [email protected]> |
| 81 | + Signed-off-by: Kuniyuki Iwashima < [email protected]> |
| 82 | + Signed-off-by: Trond Myklebust < [email protected]> |
| 83 | +(cherry picked from commit 24457f1be29f1e7042e50a7749f5c2dde8c433c8) |
| 84 | + Signed-off-by: Jonathan Maple < [email protected]> |
| 85 | + |
| 86 | +# Conflicts: |
| 87 | +# fs/nfs/inode.c |
| 88 | +diff --cc fs/nfs/inode.c |
| 89 | +index 912b54461f53,6fe4b47c3928..000000000000 |
| 90 | +--- a/fs/nfs/inode.c |
| 91 | ++++ b/fs/nfs/inode.c |
| 92 | +@@@ -2349,7 -2426,15 +2349,16 @@@ EXPORT_SYMBOL_GPL(nfs_net_id) |
| 93 | + |
| 94 | + static int nfs_net_init(struct net *net) |
| 95 | + { |
| 96 | + - struct nfs_net *nn = net_generic(net, nfs_net_id); |
| 97 | + - |
| 98 | + nfs_clients_init(net); |
| 99 | +++<<<<<<< HEAD |
| 100 | +++======= |
| 101 | ++ |
| 102 | ++ if (!rpc_proc_register(net, &nn->rpcstats)) { |
| 103 | ++ nfs_clients_exit(net); |
| 104 | ++ return -ENOMEM; |
| 105 | ++ } |
| 106 | ++ |
| 107 | +++>>>>>>> 24457f1be29f (nfs: Handle error of rpc_proc_register() in nfs_net_init().) |
| 108 | + return nfs_fs_proc_net_init(net); |
| 109 | + } |
| 110 | + |
| 111 | +* Unmerged path fs/nfs/inode.c |
0 commit comments