The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Sourabh Jain <sourabhjain@linux.ibm.com>
To: Jeff Layton <jlayton@kernel.org>,
	Chuck Lever <chuck.lever@oracle.com>, Neil Brown <neilb@suse.de>,
	Olga Kornievskaia <kolga@netapp.com>,
	Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna@kernel.org>,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nfsd: fix oops when reading pool_stats before server is started
Date: Mon, 17 Jun 2024 19:23:45 +0530	[thread overview]
Message-ID: <1786d5aa-2474-4bd3-92ee-c5a880a37728@linux.ibm.com> (raw)
In-Reply-To: <20240617-nfsd-next-v1-1-5833b297015a@kernel.org>

Hello Jeff,

With the below fix applied, the issue is not observed.
Tested-by: Sourabh Jain <sourabhjain@linux.ibm.com>

Thanks for the fix.

- Sourabh Jain

On 17/06/24 17:24, Jeff Layton wrote:
> Sourbh reported an oops that is triggerable by trying to read the
> pool_stats procfile before nfsd had been started. Move the check for a
> NULL serv in svc_pool_stats_start above 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 <sourabhjain@linux.ibm.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>   net/sunrpc/svc_xprt.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
> index d3735ab3e6d1..b757a8891813 100644
> --- a/net/sunrpc/svc_xprt.c
> +++ b/net/sunrpc/svc_xprt.c
> @@ -1422,12 +1422,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];
>   }
> @@ -1459,7 +1460,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)
>
> ---
> base-commit: 4ddfda417a50309f17aeb85f8d1a9a9efbc7d81c
> change-id: 20240617-nfsd-next-8593f73544f5
>
> Best regards,


  reply	other threads:[~2024-06-17 13:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17 11:54 [PATCH] nfsd: fix oops when reading pool_stats before server is started Jeff Layton
2024-06-17 13:53 ` Sourabh Jain [this message]
2024-06-17 14:21 ` Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1786d5aa-2474-4bd3-92ee-c5a880a37728@linux.ibm.com \
    --to=sourabhjain@linux.ibm.com \
    --cc=Dai.Ngo@oracle.com \
    --cc=anna@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=kolga@netapp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=tom@talpey.com \
    --cc=trond.myklebust@hammerspace.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox