Message ID | CAH_kV5G07_ZL9O41OBYR8JrtxJsr56+Zi=65T_FkaQDefLU_DA@mail.gmail.com (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | ipv6: ip6_fib: fix null-pointer dereference in ipv6_route_native_seq_show() | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessing tree name failed - patch did not apply |
> 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. … > --- > net/ipv6/ip6_fib.c | 4 ++-- … It would have been more appropriate to add also a patch version description. See also: * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.12-rc5#n321 * https://lore.kernel.org/all/?q=%22This+looks+like+a+new+version+of+a+previously+submitted+patch%22 Regards, Markus
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 : "");
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(-) -- 2.44.0