diff mbox series

[ovs-dev,v4,10/11] odp-execute: Check ARP header length in set_arp().

Message ID CAB8Pm=x3moZJSAbEwizsMHiibR0uuG03wggFBj_uG__71Mv8eA@mail.gmail.com
State New
Delegated to: aaron conole
Headers show
Series Fix header length checks in the userspace datapath. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_FreeBSD_Build_and_Test success github build: passed
ovsrobot/github-robot-_Build_and_Test fail github build: failed

Commit Message

Alejandro Pacheco Oct. 18, 2026, 5:45 a.m. UTC
From: Alejandro Pacheco <alepacheco99@gmail.com>
For ARP, nw_proto holds the opcode, so xlate commits a set(arp) action
even when flow extraction found the ARP header too short.  set_arp()
only asserts that the L3 offset is set, and then reads and writes the
ARP header past the end of the packet.  Leave such packets unchanged.

Fixes: f6c8a6b163af ("Add software switch support for modifying ARP headers in OpenFlow.")
Assisted-by: claude-opus-5-5, Claude Code
Signed-off-by: Alejandro Pacheco <alepacheco99@gmail.com>
---
 lib/odp-execute.c    |  4 +++-
 tests/dpif-netdev.at | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

Comments

Alejandro Pacheco Oct. 18, 2026, 10:50 a.m. UTC | #1
The 0-day Robot's Build and Test failure on this patch is a false
positive in the test suite, not caused by the series.  The only failing
job, "linux gcc dpdk check-system-tso", fails test 163 "conntrack - IPv6
ICMP6 Related with SNAT" at system-traffic.at:8800, which greps the
output of 'tcpdump -v icmp6' for 'wrong|bad'.  In the job's capture the
ICMPv6 error is "[icmp6 sum ok]", but its flow label is 0xbad6a and
tcpdump prints "flowlabel 0xbad6a", which the grep matches.  Patch
11/11, which contains this one, passed the same job.

Recheck-request: github-robot-_Build_and_Test
diff mbox series

Patch

diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index a1f338271..29691d5c2 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -304,7 +304,9 @@  set_arp(struct dp_packet *packet, const struct ovs_key_arp *key,
 {
     struct arp_eth_header *arp = dp_packet_l3(packet);
 
-    ovs_assert(arp);
+    if (!arp || dp_packet_l3_size(packet) < ARP_ETH_HEADER_LEN) {
+        return;
+    }
 
     if (!mask) {
         arp->ar_op = key->arp_op;
diff --git a/tests/dpif-netdev.at b/tests/dpif-netdev.at
index 6ca411460..1dabbcc5f 100644
--- a/tests/dpif-netdev.at
+++ b/tests/dpif-netdev.at
@@ -3819,3 +3819,22 @@  OVS_VSWITCHD_STOP(["dnl
   /.*failed to put.*$/d
   /.*failed to flow_del.*$/d"])
 AT_CLEANUP
+
+AT_SETUP([dpif-netdev - set field on truncated ARP header])
+OVS_VSWITCHD_START
+add_of_ports --pcap br0 1 2
+
+AT_CHECK([ovs-ofctl add-flow br0 "in_port=1,arp,actions=set_field:2->arp_op,2"])
+
+dnl ARP header with 10 of its 28 bytes.  It is forwarded unmodified.
+m4_define([ARP_SHORT_PKT], m4_join([],
+dnl eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:02,type=0x0806)
+[0000000000020000000000010806],
+dnl arp(htype=1,ptype=0x0800,hlen=6,plen=4,op=1), first 2 bytes of sha.
+[00010800060400010000]))
+
+AT_CHECK([ovs-appctl netdev-dummy/receive p1 ARP_SHORT_PKT])
+OVS_WAIT_UNTIL_EQUAL([ovs-pcap p2-tx.pcap], [ARP_SHORT_PKT])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP