Skip to content

Commit f47e739

Browse files
committed
Merge: nfsd: don't ignore the return code of svc_proc_register()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7096 nfsd: don't ignore the return code of svc_proc_register() JIRA: https://issues.redhat.com/browse/RHEL-93612 CVE: CVE-2025-22026 Signed-off-by: Olga Kornievskaia <okorniev@redhat.com> Approved-by: Benjamin Coddington <bcodding@redhat.com> Approved-by: Scott Mayhew <smayhew@redhat.com> Approved-by: Jay Shin <jaeshin@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents 3a8723b + de3208f commit f47e739

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

fs/nfsd/nfsctl.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2236,19 +2236,25 @@ static __net_init int nfsd_net_init(struct net *net)
22362236
retval = nfsd_stat_counters_init(nn);
22372237
if (retval)
22382238
goto out_repcache_error;
2239+
22392240
memset(&nn->nfsd_svcstats, 0, sizeof(nn->nfsd_svcstats));
22402241
nn->nfsd_svcstats.program = &nfsd_program;
2242+
if (!nfsd_proc_stat_init(net)) {
2243+
retval = -ENOMEM;
2244+
goto out_proc_error;
2245+
}
22412246
nn->nfsd_versions = NULL;
22422247
nn->nfsd4_minorversions = NULL;
22432248
nn->nfsd_info.mutex = &nfsd_mutex;
22442249
nn->nfsd_serv = NULL;
22452250
nfsd4_init_leases_net(nn);
22462251
get_random_bytes(&nn->siphash_key, sizeof(nn->siphash_key));
22472252
seqlock_init(&nn->writeverf_lock);
2248-
nfsd_proc_stat_init(net);
22492253

22502254
return 0;
22512255

2256+
out_proc_error:
2257+
percpu_counter_destroy_many(nn->counter, NFSD_STATS_COUNTERS_NUM);
22522258
out_repcache_error:
22532259
nfsd_idmap_shutdown(net);
22542260
out_idmap_error:

fs/nfsd/stats.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ void nfsd_stat_counters_destroy(struct nfsd_net *nn)
115115
nfsd_percpu_counters_destroy(nn->counter, NFSD_STATS_COUNTERS_NUM);
116116
}
117117

118-
void nfsd_proc_stat_init(struct net *net)
118+
struct proc_dir_entry *nfsd_proc_stat_init(struct net *net)
119119
{
120120
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
121121

122-
svc_proc_register(net, &nn->nfsd_svcstats, &nfsd_proc_ops);
122+
return svc_proc_register(net, &nn->nfsd_svcstats, &nfsd_proc_ops);
123123
}
124124

125125
void nfsd_proc_stat_shutdown(struct net *net)

fs/nfsd/stats.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void nfsd_percpu_counters_reset(struct percpu_counter *counters, int num);
1515
void nfsd_percpu_counters_destroy(struct percpu_counter *counters, int num);
1616
int nfsd_stat_counters_init(struct nfsd_net *nn);
1717
void nfsd_stat_counters_destroy(struct nfsd_net *nn);
18-
void nfsd_proc_stat_init(struct net *net);
18+
struct proc_dir_entry *nfsd_proc_stat_init(struct net *net);
1919
void nfsd_proc_stat_shutdown(struct net *net);
2020

2121
static inline void nfsd_stats_rc_hits_inc(struct nfsd_net *nn)

0 commit comments

Comments
 (0)