An unligned memory access is possible in the following part of code: ====sys/netpfil/pf/if_pfsync.c, ~450 line================== if (PF_ANEQ(&sp->key[PF_SK_WIRE].addr[0], &sp->key[PF_SK_STACK].addr[0], sp->af) || PF_ANEQ(&sp->key[PF_SK_WIRE].addr[1], &sp->key[PF_SK_STACK].addr[1], sp->af) || sp->key[PF_SK_WIRE].port[0] != sp->key[PF_SK_STACK].port[0] || sp->key[PF_SK_WIRE].port[1] != sp->key[PF_SK_STACK].port[1]) { sks = uma_zalloc(V_pf_state_key_z, M_NOWAIT); if (sks == NULL) goto cleanup; } else sks = skw; ========================================================== once &sp->key[PF_SK_WIRE].addr is not an 32-bit aligned address (PF_ANEQ operates with uint32) How-To-Repeat: Setup a pfsync link between sparc64-based routers and wait some time until the problem is triggered.
Created attachment 144257 [details] Workable fix
Created attachment 144551 [details] revised patch Thanks, Boris! Can you please test revised version of the patch? I am about to commit it.
/usr/src/sys/netpfil/pf/if_pfsync.c: In function 'pfsync_state_import': /usr/src/sys/netpfil/pf/if_pfsync.c:458: error: incompatible types in assignment /usr/src/sys/netpfil/pf/if_pfsync.c:459: error: incompatible types in assignment *** Error code 1
Created attachment 144553 [details] revised patch sorry, corrected patch attached
Corrected one works fine.
A commit references this bug: Author: glebius Date: Thu Jul 10 12:41:58 UTC 2014 New revision: 268492 URL: http://svnweb.freebsd.org/changeset/base/268492 Log: On machines with strict alignment copy pfsync_state_key from packet on stack to avoid unaligned access. PR: 187381 Submitted by: Lytochkin Boris <lytboris gmail.com> Changes: head/sys/netpfil/pf/if_pfsync.c
A commit references this bug: Author: glebius Date: Fri Aug 22 13:39:56 UTC 2014 New revision: 270328 URL: http://svnweb.freebsd.org/changeset/base/270328 Log: Merge r268492: On machines with strict alignment copy pfsync_state_key from packet on stack to avoid unaligned access. PR: 187381 Changes: _U stable/10/ stable/10/sys/netpfil/pf/if_pfsync.c