public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/mpls: fix missing NULL check in mpls_valid_fib_dump_req
@ 2026-03-23  7:15 sunichi
  2026-03-23  8:52 ` Nikolay Aleksandrov
  2026-03-26 10:25 ` Paolo Abeni
  0 siblings, 2 replies; 4+ messages in thread
From: sunichi @ 2026-03-23  7:15 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni
  Cc: horms, kuniyu, gnault, leitao, netdev, linux-kernel, sunichi

The attribute tb[RTA_OIF] is dereferenced without verifying if it is NULL.
If this attribute is missing in the user netlink message, it will cause a
NULL pointer dereference and kernel panic.

Add the necessary check before using the pointer to prevent the crash.

Signed-off-by: sunichi <sunyiqixm@gmail.com>
---
 net/mpls/af_mpls.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index d5417688f69e..28bbea30aae3 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -2174,6 +2174,8 @@ static int mpls_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,
 		int ifindex;
 
 		if (i == RTA_OIF) {
+			if (!tb[i])
+				return -EINVAL;
 			ifindex = nla_get_u32(tb[i]);
 			filter->dev = dev_get_by_index_rcu(net, ifindex);
 			if (!filter->dev)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-26 10:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23  7:15 [PATCH] net/mpls: fix missing NULL check in mpls_valid_fib_dump_req sunichi
2026-03-23  8:52 ` Nikolay Aleksandrov
2026-03-23 10:07   ` sunichi
2026-03-26 10:25 ` Paolo Abeni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox