summaryrefslogtreecommitdiff
path: root/drivers/staging/gdm724x
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2021-06-14 12:58:36 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-06-14 17:39:33 +0300
commit7002b526f4ff1f6da34356e67085caafa6be383a (patch)
treeb10212e4d08cac4a8c49aca7119c25cbdaf4d0df /drivers/staging/gdm724x
parent4a36e160856db8a8ddd6a3d2e5db5a850ab87f82 (diff)
downloadlinux-7002b526f4ff1f6da34356e67085caafa6be383a.tar.xz
staging: gdm724x: check for overflow in gdm_lte_netif_rx()
This code assumes that "len" is at least 62 bytes, but we need a check to prevent a read overflow. Fixes: 61e121047645 ("staging: gdm7240: adding LTE USB driver") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Link: https://lore.kernel.org/r/YMcoTPsCYlhh2TQo@mwanda Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/gdm724x')
-rw-r--r--drivers/staging/gdm724x/gdm_lte.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c
index d4dfaead25da..e390c924ec1c 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -611,10 +611,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) +
- sizeof(struct udphdr) +
- offsetof(struct dhcp_packet, chaddr);
- ether_addr_copy(nic->dest_mac_addr, addr);
+ int offset = sizeof(struct iphdr) +
+ sizeof(struct udphdr) +
+ offsetof(struct dhcp_packet, chaddr);
+ if (offset + ETH_ALEN > len)
+ return;
+ ether_addr_copy(nic->dest_mac_addr, buf + offset);
}
}