]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC: r311817
authormarius <marius@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Wed, 10 May 2017 20:46:59 +0000 (20:46 +0000)
committermarius <marius@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Wed, 10 May 2017 20:46:59 +0000 (20:46 +0000)
commitec9acac256d1d9e8c01a4e27586390013af5cb6a
treebaa32a8094d93c992053ed5f20dbbea4bb0dffb0
parent43f5d64f124fa2b00fdf5648b8309c261eac6ef7
MFC: r311817

In dummynet(4), random chunks of memory are casted to struct dn_*,
potentially leading to fatal unaligned accesses on architectures with
strict alignment requirements. This change fixes dummynet(4) as far
as accesses to 64-bit members of struct dn_* are concerned, tripping
up on sparc64 with accesses to 32-bit members happening to be correctly
aligned there. In other words, this only fixes the tip of the iceberg;
larger parts of dummynet(4) still need to be rewritten in order to
properly work on all of !x86.
In principle, considering the amount of code in dummynet(4) that needs
this erroneous pattern corrected, an acceptable workaround would be to
declare all struct dn_* packed, forcing compilers to do byte-accesses
as a side-effect. However, given that the structs in question aren't
laid out well either, this would break ABI/KBI.
While at it, replace all existing bcopy(9) calls with memcpy(9) for
performance reasons, as there is no need to check for overlap in these
cases.

PR: 189219

git-svn-id: svn://svn.freebsd.org/base/stable/10@318155 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/netpfil/ipfw/ip_dummynet.c