Skip to content

Commit b10252c

Browse files
asverdlinJ. Bruce Fields
authored andcommitted
nfsd: Fix nsfd startup race (again)
Commit bd5ae92 ("nfsd: register pernet ops last, unregister first") has re-opened rpc_pipefs_event() race against nfsd_net_id registration (register_pernet_subsys()) which has been fixed by commit bb7ffbf ("nfsd: fix nsfd startup race triggering BUG_ON"). Restore the order of register_pernet_subsys() vs register_cld_notifier(). Add WARN_ON() to prevent a future regression. Crash info: Unable to handle kernel NULL pointer dereference at virtual address 0000000000000012 CPU: 8 PID: 345 Comm: mount Not tainted 5.4.144-... #1 pc : rpc_pipefs_event+0x54/0x120 [nfsd] lr : rpc_pipefs_event+0x48/0x120 [nfsd] Call trace: rpc_pipefs_event+0x54/0x120 [nfsd] blocking_notifier_call_chain rpc_fill_super get_tree_keyed rpc_fs_get_tree vfs_get_tree do_mount ksys_mount __arm64_sys_mount el0_svc_handler el0_svc Fixes: bd5ae92 ("nfsd: register pernet ops last, unregister first") Cc: [email protected] Signed-off-by: Alexander Sverdlin <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 0fcfb00 commit b10252c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

fs/nfsd/nfs4recover.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,6 +2156,7 @@ static struct notifier_block nfsd4_cld_block = {
21562156
int
21572157
register_cld_notifier(void)
21582158
{
2159+
WARN_ON(!nfsd_net_id);
21592160
return rpc_pipefs_notifier_register(&nfsd4_cld_block);
21602161
}
21612162

fs/nfsd/nfsctl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,12 +1521,9 @@ static int __init init_nfsd(void)
15211521
int retval;
15221522
printk(KERN_INFO "Installing knfsd (copyright (C) 1996 [email protected]).\n");
15231523

1524-
retval = register_cld_notifier();
1525-
if (retval)
1526-
return retval;
15271524
retval = nfsd4_init_slabs();
15281525
if (retval)
1529-
goto out_unregister_notifier;
1526+
return retval;
15301527
retval = nfsd4_init_pnfs();
15311528
if (retval)
15321529
goto out_free_slabs;
@@ -1545,9 +1542,14 @@ static int __init init_nfsd(void)
15451542
goto out_free_exports;
15461543
retval = register_pernet_subsys(&nfsd_net_ops);
15471544
if (retval < 0)
1545+
goto out_free_filesystem;
1546+
retval = register_cld_notifier();
1547+
if (retval)
15481548
goto out_free_all;
15491549
return 0;
15501550
out_free_all:
1551+
unregister_pernet_subsys(&nfsd_net_ops);
1552+
out_free_filesystem:
15511553
unregister_filesystem(&nfsd_fs_type);
15521554
out_free_exports:
15531555
remove_proc_entry("fs/nfs/exports", NULL);
@@ -1561,13 +1563,12 @@ static int __init init_nfsd(void)
15611563
nfsd4_exit_pnfs();
15621564
out_free_slabs:
15631565
nfsd4_free_slabs();
1564-
out_unregister_notifier:
1565-
unregister_cld_notifier();
15661566
return retval;
15671567
}
15681568

15691569
static void __exit exit_nfsd(void)
15701570
{
1571+
unregister_cld_notifier();
15711572
unregister_pernet_subsys(&nfsd_net_ops);
15721573
nfsd_drc_slab_free();
15731574
remove_proc_entry("fs/nfs/exports", NULL);
@@ -1577,7 +1578,6 @@ static void __exit exit_nfsd(void)
15771578
nfsd4_free_slabs();
15781579
nfsd4_exit_pnfs();
15791580
unregister_filesystem(&nfsd_fs_type);
1580-
unregister_cld_notifier();
15811581
}
15821582

15831583
MODULE_AUTHOR("Olaf Kirch <[email protected]>");

0 commit comments

Comments
 (0)