mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: jlayton@kernel.org, neilb@suse.de, kolga@netapp.com,
	Dai.Ngo@oracle.com, tom@talpey.com,
	trond.myklebust@hammerspace.com, anna@kernel.org,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, linux-nfs@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net v2] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr()
Date: Wed, 25 Oct 2023 10:30:51 -0400	[thread overview]
Message-ID: <ZTkmm/clAvIdr+6W@tissot.1015granger.net> (raw)
In-Reply-To: <31b27c8e54f131b7eabcbd78573f0b5bfe380d8c.1698184674.git.christophe.jaillet@wanadoo.fr>

On Tue, Oct 24, 2023 at 11:58:20PM +0200, Christophe JAILLET wrote:
> The intent is to check if the strings' are truncated or not. So, >= should
> be used instead of >, because strlcat() and snprintf() return the length of
> the output, excluding the trailing NULL.
> 
> Fixes: a02d69261134 ("SUNRPC: Provide functions for managing universal addresses")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Hi Christophe -

Should these two be taken via the NFS client tree or do you intend
to include them in some other tree?


> ---
> v2: Fix cut'n'paste typo in subject
>     Add net in [PATCH...]
> ---
>  net/sunrpc/addr.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c
> index d435bffc6199..97ff11973c49 100644
> --- a/net/sunrpc/addr.c
> +++ b/net/sunrpc/addr.c
> @@ -284,10 +284,10 @@ char *rpc_sockaddr2uaddr(const struct sockaddr *sap, gfp_t gfp_flags)
>  	}
>  
>  	if (snprintf(portbuf, sizeof(portbuf),
> -		     ".%u.%u", port >> 8, port & 0xff) > (int)sizeof(portbuf))
> +		     ".%u.%u", port >> 8, port & 0xff) >= (int)sizeof(portbuf))
>  		return NULL;
>  
> -	if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) > sizeof(addrbuf))
> +	if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) >= sizeof(addrbuf))
>  		return NULL;
>  
>  	return kstrdup(addrbuf, gfp_flags);
> -- 
> 2.32.0
> 

-- 
Chuck Lever

  parent reply	other threads:[~2023-10-25 14:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24 21:58 Christophe JAILLET
2023-10-25 12:35 ` Benjamin Coddington
2023-10-25 14:30 ` Chuck Lever [this message]
2023-10-25 16:28   ` Jakub Kicinski
2023-10-27 11:49     ` Dan Carpenter

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=ZTkmm/clAvIdr+6W@tissot.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=Dai.Ngo@oracle.com \
    --cc=anna@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jlayton@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kolga@netapp.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --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

all inboxes | Powered by JetHome®