nfsd-7.0 fixes:

NFSD fixes that arrived too late for the 7.0 merge window.
 
 Fixes for commits merged in 7.0:
 - Restore previous nfsd thread count reporting behavior
 
 Issues that need expedient stable backports:
 - Fix credential reference leaks in the NFSD netlink admin protocol
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEKLLlsBKG3yQ88j7+M2qzM29mf5cFAmmlmfQACgkQM2qzM29m
 f5ckDA//eSSeZG+Ld2MX+DrYH7aYUSQzlUJ7ENKpt904tw6qy8o3dPFg5gcF2ZKQ
 2cK05l0G96eaYYZu/nto3RdS7lx3iDgQuWq9KorQMYXoCad/tNl8RYC8HiuH+aDu
 Fir7RApMknXe54Mz7uiPaZBUZHkb+hqe9wHOVJkZyMlRMYNAtijsI4wfaY9a5ACK
 dh03lCMOJyU3emBXizNsZ9lysuRbPVpHQEmcZsJUTnA7f6xcCTF/CyEtxjCHX9Z5
 KZ0Ltb/kG9V1VFyuGAm1S0dQmAKbl2WUo5k5eslRXmHxFx072BFOpwXlr4qd4yWt
 zjY9VY5q0anXWNgwz1U897R5xDfx43C+OdnRcMxWF7bRnNmNyCNeXnYUgSuh4HYF
 Y2IHBJk9HXSlxeiSZAq45lDgNOfg5ZBgGVVfcuKqUxgcCqG5r56FqGFkJiPvuDiI
 CEW6dIn7OQuUzDnSK0vXWFR1KGu39nKaunJHAq2BTLxbW42K5EPDw+Vhibym2LQG
 uSsBNHtviWKMONkb3jrkK5sIZryL07M/fLsYKYkSmF/B1XVwtvZHGG2k7qCCCM7B
 5IKjAFeFCRqiyYO8lm3dhLz/SbH5jpqUb3V7OpxAytk8FAEsUGX5y8fu43rfQCZD
 g2spjlrtoAhg3dSsAmrw9bDSs2TdAagWkSj1NfNgbsJs2irEgyU=
 =kHSn
 -----END PGP SIGNATURE-----

Merge tag 'nfsd-7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux

Pull nfsd fixes from Chuck Lever:

 - Restore previous nfsd thread count reporting behavior

 - Fix credential reference leaks in the NFSD netlink admin protocol

* tag 'nfsd-7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux:
  nfsd: report the requested maximum number of threads instead of number running
  nfsd: Fix cred ref leak in nfsd_nl_listener_set_doit().
  nfsd: Fix cred ref leak in nfsd_nl_threads_set_doit().
This commit is contained in:
Linus Torvalds 2026-03-02 09:05:20 -08:00
commit 1b37ac211a
3 changed files with 17 additions and 16 deletions

View file

@ -152,7 +152,7 @@ operations:
- compound-ops
-
name: threads-set
doc: set the number of running threads
doc: set the maximum number of running threads
attribute-set: server
flags: [admin-perm]
do:
@ -165,7 +165,7 @@ operations:
- min-threads
-
name: threads-get
doc: get the number of running threads
doc: get the maximum number of running threads
attribute-set: server
do:
reply:

View file

@ -377,15 +377,15 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
}
/*
* write_threads - Start NFSD, or report the current number of running threads
* write_threads - Start NFSD, or report the configured number of threads
*
* Input:
* buf: ignored
* size: zero
* Output:
* On success: passed-in buffer filled with '\n'-terminated C
* string numeric value representing the number of
* running NFSD threads;
* string numeric value representing the configured
* number of NFSD threads;
* return code is the size in bytes of the string
* On error: return code is zero
*
@ -399,8 +399,8 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
* Output:
* On success: NFS service is started;
* passed-in buffer filled with '\n'-terminated C
* string numeric value representing the number of
* running NFSD threads;
* string numeric value representing the configured
* number of NFSD threads;
* return code is the size in bytes of the string
* On error: return code is zero or a negative errno value
*/
@ -430,7 +430,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
}
/*
* write_pool_threads - Set or report the current number of threads per pool
* write_pool_threads - Set or report the configured number of threads per pool
*
* Input:
* buf: ignored
@ -447,7 +447,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
* Output:
* On success: passed-in buffer filled with '\n'-terminated C
* string containing integer values representing the
* number of NFSD threads in each pool;
* configured number of NFSD threads in each pool;
* return code is the size in bytes of the string
* On error: return code is zero or a negative errno value
*/
@ -1647,7 +1647,7 @@ int nfsd_nl_threads_set_doit(struct sk_buff *skb, struct genl_info *info)
if (attr)
nn->min_threads = nla_get_u32(attr);
ret = nfsd_svc(nrpools, nthreads, net, get_current_cred(), scope);
ret = nfsd_svc(nrpools, nthreads, net, current_cred(), scope);
if (ret > 0)
ret = 0;
out_unlock:
@ -1657,7 +1657,7 @@ out_unlock:
}
/**
* nfsd_nl_threads_get_doit - get the number of running threads
* nfsd_nl_threads_get_doit - get the maximum number of running threads
* @skb: reply buffer
* @info: netlink metadata and command arguments
*
@ -1700,7 +1700,7 @@ int nfsd_nl_threads_get_doit(struct sk_buff *skb, struct genl_info *info)
struct svc_pool *sp = &nn->nfsd_serv->sv_pools[i];
err = nla_put_u32(skb, NFSD_A_SERVER_THREADS,
sp->sp_nrthreads);
sp->sp_nrthrmax);
if (err)
goto err_unlock;
}
@ -2000,7 +2000,7 @@ int nfsd_nl_listener_set_doit(struct sk_buff *skb, struct genl_info *info)
}
ret = svc_xprt_create_from_sa(serv, xcl_name, net, sa, 0,
get_current_cred());
current_cred());
/* always save the latest error */
if (ret < 0)
err = ret;

View file

@ -239,12 +239,13 @@ static void nfsd_net_free(struct percpu_ref *ref)
int nfsd_nrthreads(struct net *net)
{
int rv = 0;
int i, rv = 0;
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
mutex_lock(&nfsd_mutex);
if (nn->nfsd_serv)
rv = nn->nfsd_serv->sv_nrthreads;
for (i = 0; i < nn->nfsd_serv->sv_nrpools; ++i)
rv += nn->nfsd_serv->sv_pools[i].sp_nrthrmax;
mutex_unlock(&nfsd_mutex);
return rv;
}
@ -659,7 +660,7 @@ int nfsd_get_nrthreads(int n, int *nthreads, struct net *net)
if (serv)
for (i = 0; i < serv->sv_nrpools && i < n; i++)
nthreads[i] = serv->sv_pools[i].sp_nrthreads;
nthreads[i] = serv->sv_pools[i].sp_nrthrmax;
return 0;
}