uname -a: FreeBSD p2 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r294499: Fri Jan 22 01:49:44 UTC 2016 root@releng2.nyi.freebsd.org:/usr/obj/arm.armv6/usr/src/sys/RPI2 arm gdb: .... pass in log quick on wlan0 inet proto tcp from any to (wlan0) port = 3333 flags S/SA keep state (source-track rule, max-src-conn 5, max-src-conn-rate 3/30, overload <bruteforce> flush global, src.track 30) pass in log quick on wlan0 inet proto tcp from any to (wlan0) port = 3333 flags S/SA keep state (source-track rule, max-src-conn 5, max-src-conn-rate 3/30, overload <bruteforce> flush global, src.track 30) STATES: all tcp 192.168.1.114:48865 -> 103.138.240.229:37005 TIME_WAIT:TIME_WAIT Program received signal SIGBUS, Bus error. 0x00021614 in print_host (addr=0x2065113e, port=45235, af=2 '\002', opts=1024) at /usr/src/sbin/pfctl/pf_print_state.c:178 178 /usr/src/sbin/pfctl/pf_print_state.c: No such file or directory. in /usr/src/sbin/pfctl/pf_print_state.c Current language: auto; currently minimal (gdb) bt #0 0x00021614 in print_host (addr=0x2065113e, port=45235, af=2 '\002', opts=1024) at /usr/src/sbin/pfctl/pf_print_state.c:178 #1 0x0002189c in print_state (s=0x206510f2, opts=1024) at /usr/src/sbin/pfctl/pf_print_state.c:236 #2 0x0000c35c in pfctl_show_states (dev=<value optimized out>, iface=0x0, opts=<value optimized out>) at /usr/src/sbin/pfctl/pfctl.c:1091 #3 0x0000f018 in $a.107 () at /usr/src/sbin/pfctl/pfctl.c:2241 #4 0x0000f018 in $a.107 () at /usr/src/sbin/pfctl/pfctl.c:2241
Created attachment 166167 [details] patch for unaligned struct copy Can you please try this patch? I have no way of testing it myself.
Created attachment 166309 [details] Patch submitted by guyyur@gmail.com via https://github.com/guyyur/freebsd-src_patches/blob/master/pfctl_arm_segbus__ver1_part1.patch The original patch I submitted failed to fix the problem due to clang's inlining of memcpy leading to essentially identical code as the struct-assignment code that failed originally. The changes that should have allowed that to work (such as casting away the alignment by casting the pointer to void* or char* in the memcpy() call, or tagging the pointer argument with __attribute__((aligned_value(1))) failed, apparently due to clang bugs. Guy Yur <guyyur@gmail.com> pointed out related PR 185617 and submitted a patch he uses to work around the problem, which I've now attached to this PR for completeness. I intend to commit something very close to this patch, with some changes to make it similar to the way the same problem was solved in the kernel pf code (conditional on __NO_STRICT_ALIGNMENT).
A commit references this bug: Author: ian Date: Sat Jan 30 22:03:15 UTC 2016 New revision: 295086 URL: https://svnweb.freebsd.org/changeset/base/295086 Log: Make pfctl(8) work on strict-alignment platforms, by copying a pair of embedded structures out of a packed, unaligned struct into local copies on the stack which are aligned. The original patch to do this was submitted by Guy Yur <guyyur@gmail.com>, and this is conceptually the same change, but restructured with the #ifndef __NO_STRICT_ALIGNMENT wrapper, similar to how the same issue is handled in the kernel pf code. PR: 185617 PR: 206658 Changes: head/sbin/pfctl/pf_print_state.c