NFS: map TCP_TLS to TCP for mountd transport
Subsystems (3)
PATCH 1/1 NFS: map TCP_TLS to TCP for mountd transport
From: Henry <[email protected]>
[ 202.116047] ------------[ cut here ]------------ [ 202.117481] kernel BUG at fs/nfs/client.c:512! [ 202.120419] Oops: invalid opcode: 0000 [#9] SMP KASAN NOPTI [ 202.122038] CPU: 0 UID: 0 PID: 407 Comm: poc Tainted: G D N 7.0.0-rc3 #4 PREEMPT(full) [ 202.125867] Tainted: [D]=DIE, [N]=TEST [ 202.126673] Hardware name: QEMU Ubuntu 24.04 PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 202.129634] RIP: 0010:nfs_init_timeout_values+0x235/0x27a [ 202.131128] Code: ff ff 37 00 48 c1 e0 2a 80 3c 02 00 74 09 48 8b 7d d0 e8 a0 e9 bc ff 48 c7 43 08 60 ea 00 00 41 b4 01 eb 08 e8 f1 06 8c ff 90 <0f> 0b e8 e9 06 8c ff 48 8d 7b 1c b8 ff ff 37 00 48 89 fa 48 c1 e0 [ 202.136017] RSP: 0018:ffffc90000b1f808 EFLAGS: 00010246 [ 202.137484] RAX: 0000000000000000 RBX: ffffc90000b1f8a0 RCX: ffffffff81d77b27 [ 202.140499] RDX: 0000000000000000 RSI: ffff88810da88000 RDI: 0000000000000002 [ 202.142664] RBP: ffffc90000b1f838 R08: 0000000000000010 R09: 0000000000000001 [ 202.145157] R10: ffff88810da1f8af R11: ffffed1021b43f15 R12: ffffffffffffff9c [ 202.147239] R13: 00000000ffffffff R14: 0000000000000000 R15: 00000000ffffffff [ 202.149156] FS: 00007f85976b7740(0000) GS:ffff888270a6b000(0000) knlGS:0000000000000000 [ 202.152515] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 202.153976] CR2: 00007fac4e3057e0 CR3: 000000010da6b000 CR4: 0000000000750ef0 [ 202.155319] PKRU: 55555554 [ 202.155848] Call Trace: [ 202.156321] <TASK> [ 202.156759] nfs_mount+0x4bc/0x93f [ 202.157485] ? __pfx_nfs_mount+0x10/0x10 [ 202.158238] ? __kmalloc_node_track_caller_noprof+0x336/0x37a [ 202.159951] ? kmemdup_nul+0x3d/0xa1 [ 202.161437] ? nfs_get_tree+0xae3/0x1442 [ 202.162622] ? srso_alias_return_thunk+0x5/0xfbef5 [ 202.165287] ? write_comp_data+0x2e/0x8e [ 202.166193] ? srso_alias_return_thunk+0x5/0xfbef5 [ 202.167766] ? write_comp_data+0x2e/0x8e [ 202.169683] nfs_request_mount.constprop.0+0x575/0x64e [ 202.171319] ? __pfx_nfs_request_mount.constprop.0+0x10/0x10 [ 202.172594] ? srso_alias_return_thunk+0x5/0xfbef5 [ 202.173908] ? write_comp_data+0x2e/0x8e [ 202.174687] nfs_try_get_tree+0x221/0xad3 [ 202.175585] ? __pfx_nfs_try_get_tree+0x10/0x10 [ 202.176927] ? kasan_save_track+0x18/0x32 [ 202.178446] ? srso_alias_return_thunk+0x5/0xfbef5 [ 202.179587] ? srso_alias_return_thunk+0x5/0xfbef5 [ 202.180655] ? poison_kmalloc_redzone+0x61/0x6e [ 202.181673] ? srso_alias_return_thunk+0x5/0xfbef5 [ 202.182746] ? __kasan_kmalloc+0x3e/0x4c [ 202.183637] ? srso_alias_return_thunk+0x5/0xfbef5 [ 202.184667] ? srso_alias_return_thunk+0x5/0xfbef5 [ 202.185713] ? write_comp_data+0x2e/0x8e [ 202.186842] nfs_get_tree+0x1415/0x1442 [ 202.187734] vfs_get_tree+0x9a/0x2a1 [ 202.188526] vfs_cmd_create+0xff/0x252 [ 202.189345] __do_sys_fsconfig+0x571/0x8e3 [ 202.190226] ? __pfx___do_sys_fsconfig+0x10/0x10 [ 202.191379] ? srso_alias_return_thunk+0x5/0xfbef5 [ 202.192436] ? write_comp_data+0x2e/0x8e [ 202.193428] ? srso_alias_return_thunk+0x5/0xfbef5 [ 202.195304] ? write_comp_data+0x2e/0x8e [ 202.196426] __x64_sys_fsconfig+0xdd/0xec [ 202.197673] x64_sys_call+0x1fa5/0x2105 [ 202.198835] do_syscall_64+0x1b3/0x420 [ 202.199946] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 202.201362] RIP: 0033:0x7f859752725d [ 202.202455] 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 8b bb 0d 00 f7 d8 64 89 01 48 [ 202.207616] RSP: 002b:00007ffc2b1e3bd8 EFLAGS: 00000246 ORIG_RAX: 00000000000001af [ 202.209855] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f859752725d [ 202.212372] RDX: 0000000000000000 RSI: 0000000000000006 RDI: 0000000000000003 [ 202.214434] RBP: 0000000000031491 R08: 0000000000000000 R09: 0000007500000019 [ 202.216521] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffc2b1e3bec [ 202.218776] R13: 431bde82d7b634db R14: 00005640cbc6ad28 R15: 00007f85976fe000 [ 202.220449] </TASK> [ 202.221106] Modules linked in: [ 202.222234] ---[ end trace 0000000000000000 ]---
xprtsec=tls upgrades nfs_server.protocol to XPRT_TRANSPORT_TCP_TLS. For NFSv3, nfs_set_mount_transport_protocol() does not handle XPRT_TRANSPORT_TCP_TLS, and mount_server.protocol can remain invalid.
The mount protocol client passes this value into nfs_init_timeout_values(), which can hit BUG() on an invalid protocol.
Handle XPRT_TRANSPORT_TCP_TLS like TCP/RDMA and map it to TCP for mountd transport setup.
Fixes c8407f2e560c ("NFS: Add an "xprtsec=" NFS mount option")
Signed-off-by Henry <[email protected]>
--- fs/nfs/fs_context.c | 1 + 1 file changed, 1 insertion(+)
fs/nfs/fs_context.c +1 -0
@@ -402,6 +402,7 @@ static void nfs_set_mount_transport_protocol(struct nfs_fs_context *ctx) ctx->mount_server.protocol =XPRT_TRANSPORT_UDP ;break ;case XPRT_TRANSPORT_TCP : +case XPRT_TRANSPORT_TCP_TLS :case XPRT_TRANSPORT_RDMA : ctx->mount_server.protocol =XPRT_TRANSPORT_TCP ; }
Signature · 1 line
2.43.0
Friendly ping.
I hit the same issue and was wondering whether this patch is the proper fix.
Thanks
Ran Hongyun