From: Stephen Hemminger <stephen@networkplumber.org>
To: Anton Moryakov <ant.v.moryakov@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2-next] ip: ipmaddr.c: Fix possible integer underflow in read_igmp()
Date: Sun, 20 Jul 2025 08:13:38 -0700 [thread overview]
Message-ID: <20250720081338.7c20d793@hermes.local> (raw)
In-Reply-To: <20250719155705.44929-1-ant.v.moryakov@gmail.com>
On Sat, 19 Jul 2025 18:57:05 +0300
Anton Moryakov <ant.v.moryakov@gmail.com> wrote:
> Static analyzer pointed out a potential error:
>
> Possible integer underflow: left operand is tainted. An integer underflow
> may occur due to arithmetic operation (unsigned subtraction) between variable
> 'len' and value '1', when 'len' is tainted { [0, 18446744073709551615] }
>
> The fix adds a check for 'len == 0' before accessing the last character of
> the name, and skips the current line in such cases to avoid the underflow.
>
> Reported-by: SVACE static analyzer
> Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
> ---
> ip/ipmaddr.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c
> index 2418b303..2feb916a 100644
> --- a/ip/ipmaddr.c
> +++ b/ip/ipmaddr.c
> @@ -150,6 +150,8 @@ static void read_igmp(struct ma_info **result_p)
>
> sscanf(buf, "%d%s", &m.index, m.name);
> len = strlen(m.name);
> + if(len == 0)
> + continue;
Need to follow kernel coding style, need space here.
if (len == 0)
not
if(len == 0)
prev parent reply other threads:[~2025-07-20 15:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-19 15:57 [PATCH iproute2-next] ip: ipmaddr.c: Fix possible integer underflow in read_igmp() Anton Moryakov
2025-07-20 15:13 ` Stephen Hemminger [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=20250720081338.7c20d793@hermes.local \
--to=stephen@networkplumber.org \
--cc=ant.v.moryakov@gmail.com \
--cc=netdev@vger.kernel.org \
/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