* [PATCH net v2] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr()
@ 2023-10-24 21:58 Christophe JAILLET
2023-10-25 12:35 ` Benjamin Coddington
2023-10-25 14:30 ` Chuck Lever
0 siblings, 2 replies; 5+ messages in thread
From: Christophe JAILLET @ 2023-10-24 21:58 UTC (permalink / raw)
To: chuck.lever, jlayton, neilb, kolga, Dai.Ngo, tom, trond.myklebust,
anna, davem, edumazet, kuba, pabeni
Cc: linux-nfs, netdev, linux-kernel, kernel-janitors,
Christophe JAILLET
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>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr()
2023-10-24 21:58 [PATCH net v2] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() Christophe JAILLET
@ 2023-10-25 12:35 ` Benjamin Coddington
2023-10-25 14:30 ` Chuck Lever
1 sibling, 0 replies; 5+ messages in thread
From: Benjamin Coddington @ 2023-10-25 12:35 UTC (permalink / raw)
To: Christophe JAILLET
Cc: chuck.lever, jlayton, neilb, kolga, Dai.Ngo, tom, trond.myklebust,
anna, davem, edumazet, kuba, pabeni, linux-nfs, netdev,
linux-kernel, kernel-janitors
On 24 Oct 2023, at 17:58, 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>
> ---
> v2: Fix cut'n'paste typo in subject
> Add net in [PATCH...]
> ---
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Ben
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr()
2023-10-24 21:58 [PATCH net v2] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() Christophe JAILLET
2023-10-25 12:35 ` Benjamin Coddington
@ 2023-10-25 14:30 ` Chuck Lever
2023-10-25 16:28 ` Jakub Kicinski
1 sibling, 1 reply; 5+ messages in thread
From: Chuck Lever @ 2023-10-25 14:30 UTC (permalink / raw)
To: Christophe JAILLET
Cc: jlayton, neilb, kolga, Dai.Ngo, tom, trond.myklebust, anna, davem,
edumazet, kuba, pabeni, linux-nfs, netdev, linux-kernel,
kernel-janitors
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr()
2023-10-25 14:30 ` Chuck Lever
@ 2023-10-25 16:28 ` Jakub Kicinski
2023-10-27 11:49 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2023-10-25 16:28 UTC (permalink / raw)
To: Chuck Lever
Cc: Christophe JAILLET, jlayton, neilb, kolga, Dai.Ngo, tom,
trond.myklebust, anna, davem, edumazet, pabeni, linux-nfs, netdev,
linux-kernel, kernel-janitors
On Wed, 25 Oct 2023 10:30:51 -0400 Chuck Lever wrote:
> Should these two be taken via the NFS client tree or do you intend
> to include them in some other tree?
FWIW we're not intending to take these. If only get_maintainer
understood tree designations :(
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr()
2023-10-25 16:28 ` Jakub Kicinski
@ 2023-10-27 11:49 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2023-10-27 11:49 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Chuck Lever, Christophe JAILLET, jlayton, neilb, kolga, Dai.Ngo,
tom, trond.myklebust, anna, davem, edumazet, pabeni, linux-nfs,
netdev, linux-kernel, kernel-janitors
On Wed, Oct 25, 2023 at 09:28:29AM -0700, Jakub Kicinski wrote:
> On Wed, 25 Oct 2023 10:30:51 -0400 Chuck Lever wrote:
> > Should these two be taken via the NFS client tree or do you intend
> > to include them in some other tree?
>
> FWIW we're not intending to take these. If only get_maintainer
> understood tree designations :(
I accidentally markedt his NFS patch as net on Oct 11 as well. :/
https://lore.kernel.org/all/356fb42c-9cf1-45cd-9233-ac845c507fb7@moroto.mountain/
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-27 11:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-24 21:58 [PATCH net v2] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() Christophe JAILLET
2023-10-25 12:35 ` Benjamin Coddington
2023-10-25 14:30 ` Chuck Lever
2023-10-25 16:28 ` Jakub Kicinski
2023-10-27 11:49 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).