SUNRPC: Fix occasional warning when destroying gss_krb5_enctypes
authorChuck Lever <chuck.lever@oracle.com>
Sun, 5 Feb 2023 16:58:44 +0000 (11:58 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 20 Feb 2023 14:20:57 +0000 (09:20 -0500)
I'm guessing that the warning fired because there's some code path
that is called on module unload where the gss_krb5_enctypes file
was never set up.

name 'gss_krb5_enctypes'
WARNING: CPU: 0 PID: 6187 at fs/proc/generic.c:712 remove_proc_entry+0x38d/0x460 fs/proc/generic.c:712

destroy_krb5_enctypes_proc_entry net/sunrpc/auth_gss/svcauth_gss.c:1543 [inline]
gss_svc_shutdown_net+0x7d/0x2b0 net/sunrpc/auth_gss/svcauth_gss.c:2120
ops_exit_list+0xb0/0x170 net/core/net_namespace.c:169
setup_net+0x9bd/0xe60 net/core/net_namespace.c:356
copy_net_ns+0x320/0x6b0 net/core/net_namespace.c:483
create_new_namespaces+0x3f6/0xb20 kernel/nsproxy.c:110
copy_namespaces+0x410/0x500 kernel/nsproxy.c:179
copy_process+0x311d/0x76b0 kernel/fork.c:2272
kernel_clone+0xeb/0x9a0 kernel/fork.c:2684
__do_sys_clone+0xba/0x100 kernel/fork.c:2825
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Reported-by: syzbot+04a8437497bcfb4afa95@syzkaller.appspotmail.com
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/auth_gss/svcauth_gss.c
net/sunrpc/netns.h

index 19f0190a0b970f92d4e5670056c7aff9a696bf6c..9c843974bb48b2f59607f8afd18394171758244f 100644 (file)
@@ -1529,18 +1529,19 @@ static int create_krb5_enctypes_proc_entry(struct net *net)
 {
        struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
 
-       if (!proc_create_data("gss_krb5_enctypes", S_IFREG | 0444,
-                             sn->proc_net_rpc,
-                             &gss_krb5_enctypes_proc_ops, net))
-               return -ENOMEM;
-       return 0;
+       sn->gss_krb5_enctypes =
+               proc_create_data("gss_krb5_enctypes", S_IFREG | 0444,
+                                sn->proc_net_rpc, &gss_krb5_enctypes_proc_ops,
+                                net);
+       return sn->gss_krb5_enctypes ? 0 : -ENOMEM;
 }
 
 static void destroy_krb5_enctypes_proc_entry(struct net *net)
 {
        struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
 
-       remove_proc_entry("gss_krb5_enctypes", sn->proc_net_rpc);
+       if (sn->gss_krb5_enctypes)
+               remove_proc_entry("gss_krb5_enctypes", sn->proc_net_rpc);
 }
 
 #else /* CONFIG_PROC_FS */
index 7ec10b92bea149b2d1b15a150302621039182569..4efb5f28d881865693a539d0d1722a17054aa5a3 100644 (file)
@@ -33,6 +33,7 @@ struct sunrpc_net {
        int pipe_version;
        atomic_t pipe_users;
        struct proc_dir_entry *use_gssp_proc;
+       struct proc_dir_entry *gss_krb5_enctypes;
 };
 
 extern unsigned int sunrpc_net_id;