]> www.infradead.org Git - users/jedix/linux-maple.git/commit
nfsd: don't ignore the return code of svc_proc_register()
authorJeff Layton <jlayton@kernel.org>
Thu, 6 Feb 2025 18:12:13 +0000 (13:12 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 10 Mar 2025 13:10:59 +0000 (09:10 -0400)
commit930b64ca0c511521f0abdd1d57ce52b2a6e3476b
treefde44534c1981735fc1d20d752fafb970d0c270b
parent2ed4f6fe1555a8431c997a5446254ded963006ce
nfsd: don't ignore the return code of svc_proc_register()

Currently, nfsd_proc_stat_init() ignores the return value of
svc_proc_register(). If the procfile creation fails, then the kernel
will WARN when it tries to remove the entry later.

Fix nfsd_proc_stat_init() to return the same type of pointer as
svc_proc_register(), and fix up nfsd_net_init() to check that and fail
the nfsd_net construction if it occurs.

svc_proc_register() can fail if the dentry can't be allocated, or if an
identical dentry already exists. The second case is pretty unlikely in
the nfsd_net construction codepath, so if this happens, return -ENOMEM.

Reported-by: syzbot+e34ad04f27991521104c@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-nfs/67a47501.050a0220.19061f.05f9.GAE@google.com/
Cc: stable@vger.kernel.org # v6.9
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfsctl.c
fs/nfsd/stats.c
fs/nfsd/stats.h