Linux NFS development
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Su Hui <suhui@nfschina.com>
Cc: trond.myklebust@hammerspace.com, anna@kernel.org,
	jlayton@kernel.org, neilb@suse.de, kolga@netapp.com,
	Dai.Ngo@oracle.com, tom@talpey.com, nathan@kernel.org,
	ndesaulniers@google.com, trix@redhat.com, bfields@fieldses.org,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v2] fs: lockd: avoid possible wrong NULL parameter
Date: Fri, 4 Aug 2023 14:37:51 -0400	[thread overview]
Message-ID: <ZM1Ffz0UpI9ouaeC@tissot.1015granger.net> (raw)
In-Reply-To: <20230804012656.4091877-1-suhui@nfschina.com>

On Fri, Aug 04, 2023 at 09:26:57AM +0800, Su Hui wrote:
> clang's static analysis warning: fs/lockd/mon.c: line 293, column 2:
> Null pointer passed as 2nd argument to memory copy function.
> 
> Assuming 'hostname' is NULL and calling 'nsm_create_handle()', this will
> pass NULL as 2nd argument to memory copy function 'memcpy()'. So return
> NULL if 'hostname' is invalid.
> 
> Fixes: 77a3ef33e2de ("NSM: More clean up of nsm_get_handle()")
> Signed-off-by: Su Hui <suhui@nfschina.com>

Applied to nfsd-next (for v6.6).


> ---
> v2:
>  - move NULL check to the callee "nsm_create_handle()"
>  fs/lockd/mon.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
> index 1d9488cf0534..87a0f207df0b 100644
> --- a/fs/lockd/mon.c
> +++ b/fs/lockd/mon.c
> @@ -276,6 +276,9 @@ static struct nsm_handle *nsm_create_handle(const struct sockaddr *sap,
>  {
>  	struct nsm_handle *new;
>  
> +	if (!hostname)
> +		return NULL;
> +
>  	new = kzalloc(sizeof(*new) + hostname_len + 1, GFP_KERNEL);
>  	if (unlikely(new == NULL))
>  		return NULL;
> -- 
> 2.30.2
> 

-- 
Chuck Lever

      parent reply	other threads:[~2023-08-04 18:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04  1:26 [PATCH v2] fs: lockd: avoid possible wrong NULL parameter Su Hui
2023-08-04 10:14 ` Jeff Layton
2023-08-04 15:49 ` Nick Desaulniers
2023-08-04 18:37 ` Chuck Lever [this message]

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=ZM1Ffz0UpI9ouaeC@tissot.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=Dai.Ngo@oracle.com \
    --cc=anna@kernel.org \
    --cc=bfields@fieldses.org \
    --cc=jlayton@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kolga@netapp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=neilb@suse.de \
    --cc=suhui@nfschina.com \
    --cc=tom@talpey.com \
    --cc=trix@redhat.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