Skip to contentSkip to conversation

net: initialize local variables in net/ipv6/mcast.c and net/ipv4/igmp.c

PATCH New Phillip Potter 1 participant 1 message Apr 1, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 net: initialize local variables in net/ipv6/mcast.c and net/ipv4/igmp.c

Use memset to initialize two local buffers in net/ipv6/mcast.c, and another in net/ipv4/igmp.c. Fixes a KMSAN found uninit-value bug reported by syzbot at:
https://syzkaller.appspot.com/bug?id=0766d38c656abeace60621896d705743aeefed51

---
 net/ipv4/igmp.c  | 2 ++
 net/ipv6/mcast.c | 4 ++++
 2 files changed, 6 insertions(+)
net/ipv4/igmp.c +2 -0
index 7b272bbed2b4..bc8e358a9a2a 100644
@@ -1131,6 +1131,8 @@ static void ip_mc_filter_add(struct in_device *in_dev, __be32 addr)
 	char buf[MAX_ADDR_LEN];
 	struct net_device *dev = in_dev->dev;
 
+	memset(buf, 0, sizeof(buf));
+
 	/* Checking for IFF_MULTICAST here is WRONG-WRONG-WRONG.
 	   We will get multicast token leakage, when IFF_MULTICAST
 	   is changed. This check should be done in ndo_set_rx_mode
net/ipv6/mcast.c +4 -0
index 6c8604390266..ad90dc28f318 100644
@@ -658,6 +658,8 @@ static void igmp6_group_added(struct ifmcaddr6 *mc)
 	struct net_device *dev = mc->idev->dev;
 	char buf[MAX_ADDR_LEN];
 
+	memset(buf, 0, sizeof(buf));
+
 	if (IPV6_ADDR_MC_SCOPE(&mc->mca_addr) <
 	    IPV6_ADDR_SCOPE_LINKLOCAL)
 		return;
@@ -694,6 +696,8 @@ static void igmp6_group_dropped(struct ifmcaddr6 *mc)
 	struct net_device *dev = mc->idev->dev;
 	char buf[MAX_ADDR_LEN];
 
+	memset(buf, 0, sizeof(buf));
+
 	if (IPV6_ADDR_MC_SCOPE(&mc->mca_addr) <
 	    IPV6_ADDR_SCOPE_LINKLOCAL)
 		return;
Signature · 1 line
2.30.2