mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
dpif-netdev: Tolerate undersized packets.
Actions that modify packets need to tolerate packets that are too small. Most of the actions already implicitly do this check, since they check for appropriate values in the flow key that would only be there if the corresponding data was present. But actions to modify the Ethernet header didn't have a guarantee that the packet was at least 14 bytes long, and actions to modify the VLAN didn't have such a guarantee either, so this adds appropriate checks. Problem found by code inspection.
This commit is contained in:
@@ -1017,6 +1017,9 @@ dp_netdev_port_input(struct dp_netdev *dp, struct dp_netdev_port *port,
|
||||
struct dp_netdev_flow *flow;
|
||||
flow_t key;
|
||||
|
||||
if (packet->size < ETH_HEADER_LEN) {
|
||||
return;
|
||||
}
|
||||
if (flow_extract(packet, 0, port->port_no, &key) && dp->drop_frags) {
|
||||
dp->n_frags++;
|
||||
return;
|
||||
@@ -1117,7 +1120,8 @@ static void
|
||||
dp_netdev_strip_vlan(struct ofpbuf *packet)
|
||||
{
|
||||
struct vlan_eth_header *veh = packet->l2;
|
||||
if (veh->veth_type == htons(ETH_TYPE_VLAN)) {
|
||||
if (packet->size >= sizeof *veh
|
||||
&& veh->veth_type == htons(ETH_TYPE_VLAN)) {
|
||||
struct eth_header tmp;
|
||||
|
||||
memcpy(tmp.eth_dst, veh->veth_dst, ETH_ADDR_LEN);
|
||||
|
Reference in New Issue
Block a user