netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: hsr: prevent NULL pointer dereference in hsr_proxy_announce()
@ 2024-09-07 19:03 Jeongjun Park
  2024-09-09  8:40 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jeongjun Park @ 2024-09-07 19:03 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni
  Cc: horms, lukma, ricardo, m-karicheri2, n.zhandarovich, netdev,
	linux-kernel, syzbot+02a42d9b1bd395cbcab4, Jeongjun Park

In the function hsr_proxy_annouance() added in the previous commit 
5f703ce5c981 ("net: hsr: Send supervisory frames to HSR network 
with ProxyNodeTable data"), the return value of the hsr_port_get_hsr() 
function is not checked to be a NULL pointer, which causes a NULL 
pointer dereference.

To solve this, we need to add code to check whether the return value 
of hsr_port_get_hsr() is NULL.

Reported-by: syzbot+02a42d9b1bd395cbcab4@syzkaller.appspotmail.com
Fixes: 5f703ce5c981 ("net: hsr: Send supervisory frames to HSR network with ProxyNodeTable data")
Signed-off-by: Jeongjun Park <aha310510@gmail.com>
---
 net/hsr/hsr_device.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
index e4cc6b78dcfc..b3191968e53a 100644
--- a/net/hsr/hsr_device.c
+++ b/net/hsr/hsr_device.c
@@ -427,6 +427,9 @@ static void hsr_proxy_announce(struct timer_list *t)
 	 * of SAN nodes stored in ProxyNodeTable.
 	 */
 	interlink = hsr_port_get_hsr(hsr, HSR_PT_INTERLINK);
+	if (!interlink)
+		goto done;
+
 	list_for_each_entry_rcu(node, &hsr->proxy_node_db, mac_list) {
 		if (hsr_addr_is_redbox(hsr, node->macaddress_A))
 			continue;
@@ -441,6 +444,7 @@ static void hsr_proxy_announce(struct timer_list *t)
 		mod_timer(&hsr->announce_proxy_timer, jiffies + interval);
 	}
 
+done:
 	rcu_read_unlock();
 }
 
--

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

end of thread, other threads:[~2024-09-11 23:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-07 19:03 [PATCH net] net: hsr: prevent NULL pointer dereference in hsr_proxy_announce() Jeongjun Park
2024-09-09  8:40 ` Simon Horman
2024-09-09  8:58 ` Lukasz Majewski
2024-09-11  2:15   ` Jakub Kicinski
2024-09-11  8:00     ` Lukasz Majewski
2024-09-11  8:21       ` Simon Horman
2024-09-11 14:43       ` Jakub Kicinski
2024-09-11 23:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).