net: ethernet: Make sure Ethernet header is in the recv pkt

Check that Ethernet header is in the first net_buf fragment.
This is very unlikely to happen as device driver is expected
to only deliver proper Ethernet frames to upper stack.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2020-09-23 12:36:31 +03:00 committed by Jukka Rissanen
commit 3b64d57943

View file

@ -178,7 +178,12 @@ static enum net_verdict ethernet_recv(struct net_if *iface,
struct net_linkaddr *lladdr;
sa_family_t family;
if (hdr == NULL) {
/* This expects that the Ethernet header is in the first net_buf
* fragment. This is a safe expectation here as it would not make
* any sense to split the Ethernet header to two net_buf's by the
* Ethernet driver.
*/
if (hdr == NULL || pkt->buffer->len < hdr_len) {
goto drop;
}