]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
if_wg: use proper barriers around pkt->p_state
authorKyle Evans <kevans@FreeBSD.org>
Fri, 15 Mar 2024 01:19:18 +0000 (20:19 -0500)
committerKyle Evans <kevans@FreeBSD.org>
Fri, 15 Mar 2024 01:19:21 +0000 (20:19 -0500)
commit3705d679a6344c957cae7a1b6372a8bfb8c44f0e
treed4cd81f751a1c708cc0de26cd5f0dadc4e5fc570
parent89f1dcb3eb468e4cbaebd1ccde9a643d85f1282e
if_wg: use proper barriers around pkt->p_state

Without appropriate load-synchronization to pair with store barriers in
wg_encrypt() and wg_decrypt(), the compiler and hardware are often
allowed to reorder these loads in wg_deliver_out() and wg_deliver_in()
such that we end up with a garbage or intermediate mbuf that we try to
pass on.  The issue is particularly prevalent with the weaker
memory models of !x86 platforms.

Switch from the big-hammer wmb() to more explicit acq/rel atomics to
both make it obvious what we're syncing up with, and to avoid somewhat
hefty fences on platforms that don't necessarily need this.

With this patch, my dual-iperf3 reproducer is dramatically more stable
than it is without on aarch64.

PR: 264115
MFC after: 1 week
Reviewed by: andrew, zlei
Differential Revision: https://reviews.freebsd.org/D44283
sys/dev/wg/if_wg.c