From: mdshahid03@gmail.com
To: Jakub Kicinski <kuba@kernel.org>
Cc: mdshahid03@gmail.com, davem@davemloft.net, edumazet@kernel.org,
pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rtnetlink: fix NULL pointer dereference in rtnl_get_link()
Date: Sat, 21 Nov 2026 16:40:43 +0530 [thread overview]
Message-ID: <179525944307.361783.17801110279499293110.b4-reply@b4> (raw)
In-Reply-To: <20261120100415.363fcb19@kernel.org>
Hi Jakub,
I tested this issue on both original and patched kernels in qemu.
First, I used a test module to unregister all PF_UNSPEC handlers.
On the original kernel ,running ip link show caused a kernel crash
due to a NULL pointer dereference.
~ # ip link show
[ 84.803284][ T65] BUG: kernel NULL pointer dereference, address: 0000000000000010
[ 84.803926][ T65] #PF: supervisor read access in kernel mode
[ 84.804231][ T65] #PF: error_code(0x0000) - not-present page
[ 84.804698][ T65] PGD 4d55067 P4D 4d55067 PUD 4d56067 PMD 0
[ 84.805370][ T65] Oops: Oops: 0000 [#1] NOPTI
[ 84.806277][ T65] CPU: 0 UID: 0 PID: 65 Comm: ip Tainted: G OE 7.3.0-13253-gbc2a37970c19 #1 PREEMPT(lazy)
[ 84.807170][ T65] Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
[ 84.807477][ T65] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 84.808195][ T65] RIP: 0010:rtnetlink_rcv_msg+0xc1/0x350
[ 84.809058][ T65] Code: e5 f1 6a 01 4a 8b 44 f8 80 48 85 c0 74 09 4c 8b 68 08 4d 85 ed 75 2e 48 8b 05 cb f1 6a 01 48 85 c0 75 07 48 8b 05 bf f1 6a 01 <4a> 8b 44 f8 80 48 85 c0 0f 84 9d 01 00 00 4c 8b 68 08 4d 85 ed 0f
On the patched kernel, the same test did not cause a crash ,instead
the command returned "Operation not supported" ,which is expected
becasue no handler was avibale.
~ # insmod /modules/rtnl_unspec_trigger.ko
[ 71.413827][ T62] rtnl_unspec_trigger: loading out-of-tree module taints kernel.
[ 71.414093][ T62] rtnl_unspec_trigger: module verification failed: signature and/or required key missing - tainting kernel
[ 71.428825][ T62] rtnl_test: unregistering PF_UNSPEC handlers
[ 71.430356][ T62] rtnl_test: PF_UNSPEC handlers unregistered
~ # ip link show
ip: RTNETLINK answers: Operation not supported
ip: dump terminated
This confirms that the NULL check prevents the crash in this case.
I have collected the logs. BTW,This issue was reported by CLANG.
239873:net/core/rtnetlink.c:409:9: warning: Dereference of null pointer [clang-analyzer-core.NullDereference]
Thanks
Shahid.
On 2026-11-20 10:04 -0800, Jakub Kicinski wrote:
> On Fri, 20 Nov 2026 19:15:48 +0530 mdshahid03@gmail.com wrote:
> > 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.
>
> How can this happen? If you can't answer that - please do
> not submit any patches to Linux networking for at least
> 6 months.
>
> > 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]);
> > }
> >
>
>
>
next prev parent reply other threads:[~2026-11-21 11:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 13:45 mdshahid03
2026-11-20 13:49 ` netdev-bot+sinfo
2026-11-20 18:04 ` Jakub Kicinski
2026-11-21 11:10 ` mdshahid03 [this message]
2026-11-23 10:56 ` Paolo Abeni
2026-11-23 16:01 ` mdshahid03
2026-11-23 18:01 ` Eric Dumazet
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=179525944307.361783.17801110279499293110.b4-reply@b4 \
--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
all inboxes | Powered by JetHome®