Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51155c79 authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman
Browse files

staging: gdm724x: check for overflow in gdm_lte_netif_rx()



[ Upstream commit 7002b526f4ff1f6da34356e67085caafa6be383a ]

This code assumes that "len" is at least 62 bytes, but we need a check
to prevent a read overflow.

Fixes: 61e12104 ("staging: gdm7240: adding LTE USB driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YMcoTPsCYlhh2TQo@mwanda


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 66a36e8a
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -624,10 +624,12 @@ static void gdm_lte_netif_rx(struct net_device *dev, char *buf,
						  * bytes (99,130,83,99 dec)
						  */
			} __packed;
			void *addr = buf + sizeof(struct iphdr) +
			int offset = sizeof(struct iphdr) +
				     sizeof(struct udphdr) +
				     offsetof(struct dhcp_packet, chaddr);
			ether_addr_copy(nic->dest_mac_addr, addr);
			if (offset + ETH_ALEN > len)
				return;
			ether_addr_copy(nic->dest_mac_addr, buf + offset);
		}
	}