From: Yi Zou <03zouyi09.25@gmail.com>
To: davem@davemloft.net
Cc: 21210240012@m.fudan.edu.cn, 21302010073@m.fudan.edu.cn,
dsahern@kernel.org, edumazet@google.com, pabeni@redhat.com,
Markus.Elfring@web.de, kuba@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Yi Zou <03zouyi09.25@gmail.com>
Subject: [PATCH] ipv6: ip6_fib: fix null-pointer dereference in ipv6_route_native_seq_show()
Date: Sun, 3 Nov 2024 04:08:20 +0800 [thread overview]
Message-ID: <20241102200820.1423-1-03zouyi09.25@gmail.com> (raw)
Check if fib6_nh is non-NULL before accessing fib6_nh->fib_nh_gw_family
in ipv6_route_native_seq_show() to prevent a null-pointer dereference.
Assign dev as dev = fib6_nh ? fib6_nh->fib_nh_dev : NULL to ensure safe
handling when nexthop_fib6_nh(rt->nh) returns NULL.
Fixes: 0379e8e6a9ef ("ipv6: ip6_fib: avoid NPD in ipv6_route_native_seq_show()")
Signed-off-by: Yi Zou <03zouyi09.25@gmail.com>
---
net/ipv6/ip6_fib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index eb111d20615c..6632ab65d206 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -2555,14 +2555,14 @@ static int ipv6_route_native_seq_show(struct seq_file *seq, void *v)
#else
seq_puts(seq, "00000000000000000000000000000000 00 ");
#endif
- if (fib6_nh->fib_nh_gw_family) {
+ if (fib6_nh && fib6_nh->fib_nh_gw_family) {
flags |= RTF_GATEWAY;
seq_printf(seq, "%pi6", &fib6_nh->fib_nh_gw6);
} else {
seq_puts(seq, "00000000000000000000000000000000");
}
- dev = fib6_nh->fib_nh_dev;
+ dev = fib6_nh ? fib6_nh->fib_nh_dev : NULL;
seq_printf(seq, " %08x %08x %08x %08x %8s\n",
rt->fib6_metric, refcount_read(&rt->fib6_ref), 0,
flags, dev ? dev->name : "");
--
2.44.0
next reply other threads:[~2024-11-02 20:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-02 20:08 Yi Zou [this message]
2024-11-03 15:56 ` Jakub Kicinski
2024-11-04 10:25 ` Eric Dumazet
2024-11-02 20:33 Yi Zou
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=20241102200820.1423-1-03zouyi09.25@gmail.com \
--to=03zouyi09.25@gmail.com \
--cc=21210240012@m.fudan.edu.cn \
--cc=21302010073@m.fudan.edu.cn \
--cc=Markus.Elfring@web.de \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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®