appneta / tcpreplay

Pcap editing and replay tools for *NIX and Windows - Users please download source from
http://tcpreplay.appneta.com/wiki/installation.html#downloads
1.16k stars 268 forks source link

Bus error when building on armhf #705

Closed cbiedl closed 2 years ago

cbiedl commented 2 years ago

The Debian buildd daemons report "Bus error" in the test suite when building on armhf https://buildd.debian.org/status/fetch.php?pkg=tcpreplay&arch=armhf&ver=4.4.0-1&stamp=1644098099&raw=0:

[tcpprep] Auto/Router mode test: /bin/bash: line 1: 2371998 Bus error               ../src/tcpprep --no-arg-comment --dbug=1 -i ./test.pcap -o test.auto_router1 -a router >> test.log 2>&1
make[2]: *** [Makefile:690: auto_router] Error 135

On my local boxes, I can confirm this behaviour.

Bisect led to

af0d523122ebdfb459eec9b9e1dd7dfedddc82cb is the first bad commit
commit af0d523122ebdfb459eec9b9e1dd7dfedddc82cb
Author: Fred Klassen <fklassen@appneta.com>
Date:   Thu Jan 27 14:26:32 2022 -0800

    Bug #695 remove FORCE_ALIGN

Backtrace, command was:

gdb --args ../src/tcpprep --no-arg-comment --dbug=1 -i ./test.pcap -o test.auto_router1 -a router
Program received signal SIGBUS, Bus error.
0x004050a8 in check_ip6_tree (mode=0, addr=0x448c76) at tree.c:296
296         finder->u.ip6 = *addr;
(gdb) bt
#0  0x004050a8 in check_ip6_tree (mode=0, addr=0x448c76) at tree.c:296
#1  0x0040375c in process_raw_packets (pcap=0x447f10) at tcpprep.c:497
#2  0x004029da in main (argc=9, argv=0xfffef4e4) at tcpprep.c:144

So I'd ask you to re-visit this issue and find a better solution for it.

Reverting that commit doesn't look like a good idea, and also introduces another issue, I haven't checked further:

I: [tcprewrite] L7 fuzzing test: make[2]: *** [Makefile:1062: rewrite_l7fuzzing] Error 1
fklassen commented 2 years ago

@cbiedl I had tested on armhf QEMU image but maybe my setup is different. I am running wheezy with libpcap 0.9.8. Can you help me understand your setup so I can reproduce?

The issue with reverting this commit, tests will fail on Apple M1.

root@debian-armhf:/home/user/tcpreplay-4.4.0# uname -a
Linux debian-armhf 3.2.0-4-vexpress #1 SMP Debian 3.2.51-1 armv7l GNU/Linux
root@debian-armhf:/home/user/tcpreplay-4.4.0# make test
echo Making test in ./test
Making test in ./test
cd ./test && make test
make[1]: Entering directory `/home/user/tcpreplay-4.4.0/test'
NOTICE: Tests must be run as root
Sending traffic on 'eth0' and 'eth0'
[tcpprep] Auto/Router mode test:        OK
[tcpprep] Auto/Bridge mode test:        OK
[tcpprep] Auto/Client mode test:        OK
[tcpprep] Auto/Server mode test:        OK
[tcpprep] Auto/First mode test:         OK
[tcpprep] CIDR mode test:           OK
[tcpprep] Regex mode test:          OK
[tcpprep] Port mode test:           OK
[tcpprep] MAC mode test:            OK
[tcpprep] Comment mode test:            OK
[tcpprep] Print info mode test:         OK
[tcpprep] Print comment mode test:      OK
[tcpprep] Config mode test:             OK
[tcpprep] MAC reverse mode test:        OK
[tcpprep] CIDR reverse mode test:       OK
[tcpprep] Regex reverse mode test:      OK
[tcpprep] exclude packets test:         OK
[tcpprep] include packets test:         OK
[tcpprep] include source test:          OK
[tcpprep] include destination test:         OK
[tcpreplay] Basic test:             OK
[tcpreplay] Cache test:             OK
[tcpreplay] Packets/sec test:           OK
[tcpreplay] Mbps test:              OK
[tcpreplay] Topspeed test:          OK
[tcpreplay] Config file/VLAN add test:      OK
[tcpreplay] Multiplier test:            OK
[tcpreplay] Packets/sec Multiplier test:    OK
[tcpreplay] Precache test:          OK
[tcpreplay] Statistics test:            OK
[tcpreplay] Dual file test:             OK
[tcpreplay] Maximum sleep test:         OK
[tcprewrite] Portmap test:          OK
[tcprewrite] Portmap range test:        OK
[tcprewrite] Endpoint test:             OK
[tcprewrite] Pseudo NAT test:           OK
[tcprewrite] Truncate test:             OK
[tcprewrite] Pad test:              OK
[tcprewrite] Seed IP test:          OK
[tcprewrite] Src/Dst MAC test:          OK
[tcprewrite] Layer2 test:           OK
[tcprewrite] Config/VLAN Add test:      OK
[tcprewrite] Skip bcast test:           OK
[tcprewrite] DLT User test:             OK
[tcprewrite] DLT Cisco HDLC test:       OK
[tcprewrite] VLAN 802.1ad test:         OK
[tcprewrite] VLAN Delete test:          OK
[tcprewrite] Remove EFCS:           OK
[tcprewrite] Force TTL:             OK
[tcprewrite] Increase TTL:          OK
[tcprewrite] Reduce TTL:            OK
[tcprewrite] TOS test:              OK
[tcprewrite] MTU Truncate test:         OK
[tcprewrite] Substitute Src/Dst MAC test:   OK
[tcprewrite] Seeded MAC test:           OK
[tcprewrite] Seeded Keep MAC test:      OK
[tcprewrite] L7 fuzzing test:           OK
[tcprewrite] TCP sequence test:         OK
[tcprewrite] Fix checksum test:         OK
[tcprewrite] Fix length and pad test:       OK
[tcprewrite] Fix length and truncate test:  OK
[tcprewrite] Fix length and delete test:    OK
make[1]: Leaving directory `/home/user/tcpreplay-4.4.0/test'
fklassen commented 2 years ago

Although I could not reproduce this on my armhf, I believe this will fix the issue on all Linux ARM devices

Main fix is to revert FORCE_ALIGN code, and improve the test for whether or not it is required. Also made some fixes around FORCED_ALIGN.

Don't do test for Apple devices - not required. Also do the test for other ARM devices.

Fixed in PR #707