Patch "nfsd: fix oops when reading pool_stats before server is started" has been added to the 6.9-stable tree
Quoted 7 lines · On Mon, 24 Jun 2024, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
nfsd: fix oops when reading
pool_statsbefore server is startedto the 6.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
Quoted 6 lines
The filename of the patch is:
nfsd-fix-oops-when-reading-pool_stats-before-server-.patch
and it can be found in the queue-6.9 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
I feel this should not be added to the stable tree.
It moves at test on a field protected by a mutex outside of the protection of that mutex, and so is obviously racey.
Depending on how the race goes, si->serv might be NULL when dereferenced in svc_pool_stats_start(), or svc_pool_stats_stop() might unlock a mutex that hadn't been locked.
I'll post a revert and a better fix for mainline.
Thanks,
NeilBrown
Quoted 54 lines
commit
388a527c6cf55bde74bc0891d0b4c38f50d896beAuthor: Jeff Layton <[email protected]> Date: Mon Jun 17 07:54:08 2024 -0400nfsd: fix oops when reading
pool_statsbefore server is started[ Upstream commit
8e948c365d9c10b685d1deb946bd833d6a9b43e0]Sourbh reported an oops that is triggerable by trying to read the
pool_statsprocfile before nfsd had been started. Move the check for a NULL serv insvc_pool_stats_startabove the mutex acquisition, and fix the stop routine not to unlock the mutex if there is no serv yet.Fixes 7b207ccd9833 ("svc: don't hold reference for poolstats, only mutex.")Reported-by Sourabh Jain <[email protected]>Signed-off-by Jeff Layton <[email protected]>Tested-by Sourabh Jain <[email protected]>Signed-off-by Chuck Lever <[email protected]>Signed-off-by Sasha Levin <[email protected]>net/sunrpc/svc_xprt.c +5
-3@@ -1371,12 +1371,13 @@ static void *svc_pool_stats_start(struct seq_file *m, loff_t *pos)dprintk ("svc_pool_stats_start, *pidx=%u\n" , pidx); +if (!si->serv) +return NULL ; +mutex_lock (si->mutex);if (!pidx)return SEQ_START_TOKEN ; -if (!si->serv) -return NULL ;return pidx > si->serv->sv_nrpools ?NULL : &si->serv->sv_pools[pidx -1 ]; }@@ -1408,7 +1409,8 @@ static void svc_pool_stats_stop(struct seq_file *m, void *p) {struct svc_info *si = m->private; -mutex_unlock (si->mutex); +if (si->serv) +mutex_unlock (si->mutex); }static int svc_pool_stats_show (struct seq_file *m,void *p)
Quoted 17 lines · NeilBrown
Quoted 7 lines · On Mon, 24 Jun 2024, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
nfsd: fix oops when reading
pool_statsbefore server is startedto the 6.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryQuoted 6 lines
The filename of the patch is:
nfsd-fix-oops-when-reading-pool_stats-before-server-.patch
and it can be found in the queue-6.9 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
I feel this should not be added to the stable tree.
Quoted 8 lines
It moves at test on a field protected by a mutex outside of the protection of that mutex, and so is obviously racey.
Depending on how the race goes,
si->servmight be NULL when dereferenced insvc_pool_stats_start(), orsvc_pool_stats_stop()might unlock a mutex that hadn't been locked.I'll post a revert and a better fix for mainline.
Now dropped, thanks!
greg k-h