[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-id: <171919843728.14261.13994470964681717916@noble.neil.brown.name>
Date: Mon, 24 Jun 2024 13:07:17 +1000
From: "NeilBrown" <neilb@...e.de>
To: "Ma Ke" <make24@...as.ac.cn>
Cc: chuck.lever@...cle.com, jlayton@...nel.org, kolga@...app.com,
Dai.Ngo@...cle.com, tom@...pey.com, trondmy@...nel.org, anna@...nel.org,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
linux-nfs@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, "Ma Ke" <make24@...as.ac.cn>
Subject: Re: [PATCH] SUNRPC: check mlen in ip_map_parse()
On Mon, 24 Jun 2024, Ma Ke wrote:
> We should check the parameter mlen before using 'mlen - 1'
> expression for the 'mesg' array index.
There is no need. This function is only called from cache_do_downcall()
and that function already checks for zero.
That function is only called from cache_downcall() which checks the
size_t count is not >= 32768 so the fact that it is cast to an int for
the ->cache_parse function cannot cause and overflow.
I wouldn't object to ->cache_parse() and qword_get() and maybe others
having their len parameter changed from int to size_t.
But adding this extra test on mlen add no value.
Thanks,
NeilBrown
>
> Signed-off-by: Ma Ke <make24@...as.ac.cn>
> ---
> net/sunrpc/svcauth_unix.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
> index 04b45588ae6f..816bf56597dd 100644
> --- a/net/sunrpc/svcauth_unix.c
> +++ b/net/sunrpc/svcauth_unix.c
> @@ -196,7 +196,7 @@ static int ip_map_parse(struct cache_detail *cd,
> struct auth_domain *dom;
> time64_t expiry;
>
> - if (mesg[mlen-1] != '\n')
> + if (mlen && mesg[mlen - 1] != '\n')
> return -EINVAL;
> mesg[mlen-1] = 0;
>
> --
> 2.25.1
>
>
Powered by blists - more mailing lists