From: Stephen Hemminger <stephen@networkplumber.org>
To: 李子奥 <23110240084@m.fudan.edu.cn>
Cc: "netdev" <netdev@vger.kernel.org>
Subject: Re: [PATCH iproute2] nstat: Fix NULL Pointer Dereference
Date: Sat, 5 Apr 2025 08:34:34 -0700 [thread overview]
Message-ID: <20250405083434.1c5b329e@hermes.local> (raw)
In-Reply-To: <tencent_6D7BD943688C4B5A68509FED@qq.com>
On Sat, 5 Apr 2025 17:42:20 +0800
"李子奥" <23110240084@m.fudan.edu.cn> wrote:
> The vulnerability happens in load_ugly_table(), misc/nstat.c, in the latest version of iproute2.
> The vulnerability can be triggered by:
> 1. db is set to NULL at struct nstat_ent *db = NULL;
> 2. n is set to NULL at n = db;
> 3. NULL dereference of variable n happens at sscanf(p+1, "%llu", &n->val) != 1
>
> Subject: [PATCH] Fix Null Dereference when no entries are specified
>
> Signed-off-by: Ziao Li <leeziao0331@gmail.com>
> ---
> misc/nstat.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/misc/nstat.c b/misc/nstat.c
> index fce3e9c1..b2e19bde 100644
> --- a/misc/nstat.c
> +++ b/misc/nstat.c
> @@ -218,6 +218,10 @@ static void load_ugly_table(FILE *fp)
> p = next;
> }
> n = db;
> + if (n == NULL) {
> + fprintf(stderr, "Error: Invalid input – line has ':' but no entries. Add values after ':'.\n");
> + exit(-2);
> + }
> nread = getline(&buf, &buflen, fp);
> if (nread == -1) {
> fprintf(stderr, "%s:%d: error parsing history file\n",
> --
> 2.34.1
Better, but your mailer is still confusing the patch.
You may have to resort to using an attachment.
Also, iproute2 uses kernel coding style and indentation is done with
tabs not spaces.
If this is all too hard for you to fix, I can just do it manually.
next prev parent reply other threads:[~2025-04-05 15:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-05 9:42 [PATCH iproute2] nstat: Fix NULL Pointer Dereference 李子奥
2025-04-05 15:34 ` Stephen Hemminger [this message]
2025-04-09 11:20 ` ZiAo Li
-- strict thread matches above, loose matches on Subject: below --
2025-03-24 8:26 Ziao Li
2025-04-04 0:34 ` Stephen Hemminger
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=20250405083434.1c5b329e@hermes.local \
--to=stephen@networkplumber.org \
--cc=23110240084@m.fudan.edu.cn \
--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;
as well as URLs for NNTP newsgroup(s).