From: mdshahid03@gmail.com
To: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Mohammad Shahid <mdshahid03@gmail.com>
Subject: [PATCH] rtnetlink: fix NULL pointer dereference in rtnl_get_link()
Date: Fri, 20 Nov 2026 19:15:48 +0530 [thread overview]
Message-ID: <20261120134548.214126-1-mdshahid03@gmail.com> (raw)
From: Mohammad Shahid <mdshahid03@gmail.com>
The rtnl_get_link() function falls back to the PF_UNSPEC
handler table when no handler table is registered for the
requested protocol.
However, the fallback table can also be NULL,for example
after rtnl_unregister_all(PF_UNSPEC) clears it.
In that cass, dereferencing tab[msgtyp] results in a NULL
pointer dereference.
Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
---
net/core/rtnetlink.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index e141340172ce..b552cbf17d76 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -406,6 +406,9 @@ static struct rtnl_link *rtnl_get_link(int protocol, int msgtype)
if (!tab)
tab = rcu_dereference_rtnl(rtnl_msg_handlers[PF_UNSPEC]);
+ if (!tab)
+ return NULL;
+
return rcu_dereference_rtnl(tab[msgtype]);
}
--
2.43.0
next reply other threads:[~2026-11-20 13:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 13:45 mdshahid03 [this message]
2026-11-20 13:49 ` [PATCH] rtnetlink: fix NULL pointer dereference in rtnl_get_link() netdev-bot+sinfo
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=20261120134548.214126-1-mdshahid03@gmail.com \
--to=mdshahid03@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--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