* [PATCH] ipv6: ip6_fib: fix null-pointer dereference in ipv6_route_native_seq_show()
@ 2024-11-02 20:08 Yi Zou
2024-11-03 15:56 ` Jakub Kicinski
2024-11-04 10:25 ` Eric Dumazet
0 siblings, 2 replies; 4+ messages in thread
From: Yi Zou @ 2024-11-02 20:08 UTC (permalink / raw)
To: davem
Cc: 21210240012, 21302010073, dsahern, edumazet, pabeni,
Markus.Elfring, kuba, netdev, linux-kernel, Yi Zou
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ipv6: ip6_fib: fix null-pointer dereference in ipv6_route_native_seq_show()
@ 2024-11-02 20:33 Yi Zou
0 siblings, 0 replies; 4+ messages in thread
From: Yi Zou @ 2024-11-02 20:33 UTC (permalink / raw)
To: Markus Elfring
Cc: David S. Miller, 21210240012, 21302010073, David Ahern,
Eric Dumazet, Jakub Kicinski, LKML, netdev, Paolo Abeni
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv6: ip6_fib: fix null-pointer dereference in ipv6_route_native_seq_show()
2024-11-02 20:08 [PATCH] ipv6: ip6_fib: fix null-pointer dereference in ipv6_route_native_seq_show() Yi Zou
@ 2024-11-03 15:56 ` Jakub Kicinski
2024-11-04 10:25 ` Eric Dumazet
1 sibling, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2024-11-03 15:56 UTC (permalink / raw)
To: Yi Zou
Cc: davem, 21210240012, 21302010073, dsahern, edumazet, pabeni,
Markus.Elfring, netdev, linux-kernel
On Sun, 3 Nov 2024 04:08:20 +0800 Yi Zou wrote:
> 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.
Are you just sending this patch because nexthop_fib6_nh() may return
NULL? Not sure it can happen since we know we're walking a v6-only
table here.
Please try to crash it and add a stack trace to the commit message.
BTW your last posting was white space damaged. Stick to git send-email
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipv6: ip6_fib: fix null-pointer dereference in ipv6_route_native_seq_show()
2024-11-02 20:08 [PATCH] ipv6: ip6_fib: fix null-pointer dereference in ipv6_route_native_seq_show() Yi Zou
2024-11-03 15:56 ` Jakub Kicinski
@ 2024-11-04 10:25 ` Eric Dumazet
1 sibling, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2024-11-04 10:25 UTC (permalink / raw)
To: Yi Zou
Cc: davem, 21210240012, 21302010073, dsahern, pabeni, Markus.Elfring,
kuba, netdev, linux-kernel
On Sat, Nov 2, 2024 at 9:08 PM Yi Zou <03zouyi09.25@gmail.com> wrote:
>
> 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()")
I could not find this commit in upstream trees.
Please make sure to sort out the details before sending a patch.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-04 10:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-02 20:08 [PATCH] ipv6: ip6_fib: fix null-pointer dereference in ipv6_route_native_seq_show() Yi Zou
2024-11-03 15:56 ` Jakub Kicinski
2024-11-04 10:25 ` Eric Dumazet
-- strict thread matches above, loose matches on Subject: below --
2024-11-02 20:33 Yi Zou
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).