From 4ca3ec5918a2aa793ba6601d3cf2b74f3a32c1bd Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 13 Aug 2026 17:53:10 +0000 Subject: [PATCH] respond/reject: guard Ethernet setup against non-Ethernet packets When running with --reject-dev in autofp mode, the libnet context is cached thread-locally and t_inject_mode is latched to LIBNET_LINK on the first reject for an Ethernet packet. Subsequent rejects from different interfaces that hit the fast path reuse the cached ctx but incorrectly still call SetupEthernet(), which dereferences PacketGetEthernet() causing a crash. To address this check for if a packet is ethernet in all entry points. Ticket: #8832. --- src/respond-reject-libnet11.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/respond-reject-libnet11.c b/src/respond-reject-libnet11.c index 0ccba8e939..f2c8b907ba 100644 --- a/src/respond-reject-libnet11.c +++ b/src/respond-reject-libnet11.c @@ -249,6 +249,8 @@ static inline int BuildIPv6(libnet_t *c, Libnet11Packet *lpacket, const uint8_t static inline void SetupEthernet(Packet *p, Libnet11Packet *lpacket, enum RejectDirection dir) { + if (!PacketIsEthernet(p)) + return; const EthernetHdr *ethh = PacketGetEthernet(p); switch (dir) { case REJECT_DIR_SRC: @@ -328,7 +330,7 @@ int RejectSendLibnet11IPv4TCP(ThreadVars *tv, Packet *p, void *data, enum Reject if (BuildIPv4(c, &lpacket, IPPROTO_TCP) < 0) goto cleanup; - if (t_inject_mode == LIBNET_LINK) { + if (t_inject_mode == LIBNET_LINK && PacketIsEthernet(p)) { SetupEthernet(p, &lpacket, dir); if (p->vlan_idx == 1) { @@ -405,7 +407,7 @@ int RejectSendLibnet11IPv4ICMP(ThreadVars *tv, Packet *p, void *data, enum Rejec if (BuildIPv4(c, &lpacket, IPPROTO_ICMP) < 0) goto cleanup; - if (t_inject_mode == LIBNET_LINK) { + if (t_inject_mode == LIBNET_LINK && PacketIsEthernet(p)) { SetupEthernet(p, &lpacket, dir); if (p->vlan_idx == 1) { @@ -470,7 +472,7 @@ int RejectSendLibnet11IPv6TCP(ThreadVars *tv, Packet *p, void *data, enum Reject if (BuildIPv6(c, &lpacket, IPPROTO_TCP) < 0) goto cleanup; - if (t_inject_mode == LIBNET_LINK) { + if (t_inject_mode == LIBNET_LINK && PacketIsEthernet(p)) { SetupEthernet(p, &lpacket, dir); if (p->vlan_idx == 1) { if (BuildEthernetVLAN(c, &lpacket, ETHERNET_TYPE_IPV6, p->vlan_id[0]) < 0) @@ -547,7 +549,7 @@ int RejectSendLibnet11IPv6ICMP(ThreadVars *tv, Packet *p, void *data, enum Rejec if (BuildIPv6(c, &lpacket, IPPROTO_ICMPV6) < 0) goto cleanup; - if (t_inject_mode == LIBNET_LINK) { + if (t_inject_mode == LIBNET_LINK && PacketIsEthernet(p)) { SetupEthernet(p, &lpacket, dir); if (p->vlan_idx == 1) { if (BuildEthernetVLAN(c, &lpacket, ETHERNET_TYPE_IPV6, p->vlan_id[0]) < 0)