Skip to content

Commit c21a368

Browse files
committed
nfsd: don't ignore the return code of svc_proc_register()
jira VULN-65895 cve CVE-2025-22026 commit-author Jeff Layton <jlayton@kernel.org> commit 930b64c upstream-diff | nfsd underwent considerable architectural changes related to the exposition of network stats in the user space since `ciqlts9_2' branched off, which are assumed by the upstream fix 930b64c to be in place - see patches d98416c, 93483ac, 4b14885, e41ee44, 16fb980. This backport addresses the core of the issue without pulling in all of these changes, which is checking the value returned by `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> (cherry picked from commit 930b64c) Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>
1 parent 0e2c8c1 commit c21a368

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/nfsd/stats.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ int nfsd_stat_init(void)
134134
if (err)
135135
return err;
136136

137-
svc_proc_register(&init_net, &nfsd_svcstats, &nfsd_proc_ops);
137+
if (!svc_proc_register(&init_net, &nfsd_svcstats, &nfsd_proc_ops)) {
138+
nfsd_stat_counters_destroy();
139+
return -ENOMEM;
140+
}
138141

139142
return 0;
140143
}

0 commit comments

Comments
 (0)