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

From: David S. Miller
Date: Fri Jun 11 2004 - 00:11:44 EST


On Wed, 9 Jun 2004 11:09:42 -0700 (PDT)
Christoph Lameter <clameter@xxxxxxx> 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@xxxxxxxxxxxxxxxxxx
# [IPV4]: Fix unaligned accesses in arp_tables.c
#
# net/ipv4/netfilter/arp_tables.c
# 2004/06/10 22:05:03-07:00 davem@xxxxxxxxxxxxxxxxxx +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)) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/