Netdev List
 help / color / mirror / Atom feed
* [PATCH] rtnetlink: fix NULL pointer dereference in rtnl_get_link()
@ 2026-11-20 13:45 mdshahid03
  2026-11-20 13:49 ` netdev-bot+sinfo
  2026-11-20 18:04 ` Jakub Kicinski
  0 siblings, 2 replies; 5+ messages in thread
From: mdshahid03 @ 2026-11-20 13:45 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni; +Cc: netdev, linux-kernel, Mohammad Shahid

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


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

* Re: [PATCH] rtnetlink: fix NULL pointer dereference in rtnl_get_link()
  2026-11-20 13:45 [PATCH] rtnetlink: fix NULL pointer dereference in rtnl_get_link() mdshahid03
@ 2026-11-20 13:49 ` netdev-bot+sinfo
  2026-11-20 18:04 ` Jakub Kicinski
  1 sibling, 0 replies; 5+ messages in thread
From: netdev-bot+sinfo @ 2026-11-20 13:49 UTC (permalink / raw)
  To: mdshahid03; +Cc: davem, edumazet, kuba, pabeni, netdev, linux-kernel

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

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

* Re: [PATCH] rtnetlink: fix NULL pointer dereference in rtnl_get_link()
  2026-11-20 13:45 [PATCH] rtnetlink: fix NULL pointer dereference in rtnl_get_link() mdshahid03
  2026-11-20 13:49 ` netdev-bot+sinfo
@ 2026-11-20 18:04 ` Jakub Kicinski
  2026-11-21 11:10   ` mdshahid03
  1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2026-11-20 18:04 UTC (permalink / raw)
  To: mdshahid03; +Cc: davem, edumazet, pabeni, netdev, linux-kernel

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]);
>  }
>  


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

* Re: [PATCH] rtnetlink: fix NULL pointer dereference in rtnl_get_link()
  2026-11-20 18:04 ` Jakub Kicinski
@ 2026-11-21 11:10   ` mdshahid03
  2026-11-23 10:56     ` Paolo Abeni
  0 siblings, 1 reply; 5+ messages in thread
From: mdshahid03 @ 2026-11-21 11:10 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: mdshahid03, davem, edumazet, pabeni, netdev, linux-kernel

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]);
> >  }
> >  
> 
> 
> 



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

* Re: [PATCH] rtnetlink: fix NULL pointer dereference in rtnl_get_link()
  2026-11-21 11:10   ` mdshahid03
@ 2026-11-23 10:56     ` Paolo Abeni
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Abeni @ 2026-11-23 10:56 UTC (permalink / raw)
  To: mdshahid03, Jakub Kicinski; +Cc: davem, edumazet, netdev, linux-kernel

On 11/21/26 12:10, mdshahid03@gmail.com wrote:
> I tested this issue on both original and patched kernels in qemu.
> 
> First, I used a test module to unregister all PF_UNSPEC handlers.

Just in case the are any doubts on the poic: if you need a custom
OoO kernel module to trigger a 'bug', it's not a bug.

/P


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

end of thread, other threads:[~2026-11-23 10:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 13:45 [PATCH] rtnetlink: fix NULL pointer dereference in rtnl_get_link() mdshahid03
2026-11-20 13:49 ` netdev-bot+sinfo
2026-11-20 18:04 ` Jakub Kicinski
2026-11-21 11:10   ` mdshahid03
2026-11-23 10:56     ` Paolo Abeni

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