Re: Unaligned accesses in net/ipv4/netfilter/arp_tables.c:184

David S. Miller
2004-06-11T05:04:45Z

On Wed, 9 Jun 2004 11:09:42 -0700 (PDT)
Christoph Lameter <clameter@sgi.com> wrote:

> /* Look for ifname matches; this should unroll nicely. */
> for (i = 0, ret = 0; i < IFNAMSIZ/sizeof(unsigned long); i++) {
> ret |= (((const unsigned long *)indev)[i]
> ^ ((const unsigned long *)arpinfo->iniface)[i])
> & ((const unsigned long *)arpinfo->iniface_mask)[i];
> }

This is far from a critical code path, so this is how I'm
going to fix this.

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/06/10 22:05:19-07:00 davem@nuts.davemloft.net
# [IPV4]: Fix unaligned accesses in arp_tables.c
#
# net/ipv4/netfilter/arp_tables.c
# 2004/06/10 22:05:03-07:00 davem@nuts.davemloft.net +3 -4
# [IPV4]: Fix unaligned accesses in arp_tables.c
#
diff -Nru a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
--- a/net/ipv4/netfilter/arp_tables.c 2004-06-10 22:05:40 -07:00
+++ b/net/ipv4/netfilter/arp_tables.c 2004-06-10 22:05:40 -07:00
@@ -179,11 +179,10 @@
return 0;
}

- /* Look for ifname matches; this should unroll nicely. */
+ /* Look for ifname matches. */
for (i = 0, ret = 0; i < IFNAMSIZ/sizeof(unsigned long); i++) {
- ret |= (((const unsigned long *)indev)[i]
- ^ ((const unsigned long *)arpinfo->iniface)[i])
- & ((const unsigned long *)arpinfo->iniface_mask)[i];
+ ret |= (indev[i] ^ arpinfo->iniface[i])
+ & arpinfo->iniface_mask[i];
}

if (FWINV(ret != 0, ARPT_INV_VIA_IN)) {