From: Jeff Layton <jlayton@kernel.org>
To: Su Hui <suhui@nfschina.com>,
trond.myklebust@hammerspace.com, anna@kernel.org,
chuck.lever@oracle.com, neilb@suse.de, kolga@netapp.com,
Dai.Ngo@oracle.com, tom@talpey.com, nathan@kernel.org,
ndesaulniers@google.com, trix@redhat.com
Cc: 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, 04 Aug 2023 06:14:43 -0400 [thread overview]
Message-ID: <85f0d8cb35c8e8c64810f448bae27292703d66ed.camel@kernel.org> (raw)
In-Reply-To: <20230804012656.4091877-1-suhui@nfschina.com>
On Fri, 2023-08-04 at 09:26 +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>
> ---
> 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;
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2023-08-04 10:16 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 [this message]
2023-08-04 15:49 ` Nick Desaulniers
2023-08-04 18:37 ` 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=85f0d8cb35c8e8c64810f448bae27292703d66ed.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=anna@kernel.org \
--cc=bfields@fieldses.org \
--cc=chuck.lever@oracle.com \
--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