Commit a2a1d0f1 authored by Antti P. Miettinen's avatar Antti P. Miettinen Committed by David S. Miller

[NETFILTER]: Consistent IP address access in arp_tables.c

Use memcpy just like net/ipv4/arp.c does since
these u32 values can be arbitrarily aligned and
this is not exactly a hot code path.
Signed-off-by: default avatarAntti P Miettinen <apm@brigitte.dna.fi>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a6ee9b32
...@@ -106,7 +106,7 @@ static inline int arp_packet_match(const struct arphdr *arphdr, ...@@ -106,7 +106,7 @@ static inline int arp_packet_match(const struct arphdr *arphdr,
{ {
char *arpptr = (char *)(arphdr + 1); char *arpptr = (char *)(arphdr + 1);
char *src_devaddr, *tgt_devaddr; char *src_devaddr, *tgt_devaddr;
u32 *src_ipaddr, *tgt_ipaddr; u32 src_ipaddr, tgt_ipaddr;
int i, ret; int i, ret;
#define FWINV(bool,invflg) ((bool) ^ !!(arpinfo->invflags & invflg)) #define FWINV(bool,invflg) ((bool) ^ !!(arpinfo->invflags & invflg))
...@@ -145,11 +145,11 @@ static inline int arp_packet_match(const struct arphdr *arphdr, ...@@ -145,11 +145,11 @@ static inline int arp_packet_match(const struct arphdr *arphdr,
src_devaddr = arpptr; src_devaddr = arpptr;
arpptr += dev->addr_len; arpptr += dev->addr_len;
src_ipaddr = (u32 *) arpptr; memcpy(&src_ipaddr, arpptr, sizeof(u32));
arpptr += sizeof(u32); arpptr += sizeof(u32);
tgt_devaddr = arpptr; tgt_devaddr = arpptr;
arpptr += dev->addr_len; arpptr += dev->addr_len;
tgt_ipaddr = (u32 *) arpptr; memcpy(&tgt_ipaddr, arpptr, sizeof(u32));
if (FWINV(arp_devaddr_compare(&arpinfo->src_devaddr, src_devaddr, dev->addr_len), if (FWINV(arp_devaddr_compare(&arpinfo->src_devaddr, src_devaddr, dev->addr_len),
ARPT_INV_SRCDEVADDR) || ARPT_INV_SRCDEVADDR) ||
...@@ -160,19 +160,19 @@ static inline int arp_packet_match(const struct arphdr *arphdr, ...@@ -160,19 +160,19 @@ static inline int arp_packet_match(const struct arphdr *arphdr,
return 0; return 0;
} }
if (FWINV(((*src_ipaddr) & arpinfo->smsk.s_addr) != arpinfo->src.s_addr, if (FWINV((src_ipaddr & arpinfo->smsk.s_addr) != arpinfo->src.s_addr,
ARPT_INV_SRCIP) || ARPT_INV_SRCIP) ||
FWINV((((*tgt_ipaddr) & arpinfo->tmsk.s_addr) != arpinfo->tgt.s_addr), FWINV(((tgt_ipaddr & arpinfo->tmsk.s_addr) != arpinfo->tgt.s_addr),
ARPT_INV_TGTIP)) { ARPT_INV_TGTIP)) {
dprintf("Source or target IP address mismatch.\n"); dprintf("Source or target IP address mismatch.\n");
dprintf("SRC: %u.%u.%u.%u. Mask: %u.%u.%u.%u. Target: %u.%u.%u.%u.%s\n", dprintf("SRC: %u.%u.%u.%u. Mask: %u.%u.%u.%u. Target: %u.%u.%u.%u.%s\n",
NIPQUAD(*src_ipaddr), NIPQUAD(src_ipaddr),
NIPQUAD(arpinfo->smsk.s_addr), NIPQUAD(arpinfo->smsk.s_addr),
NIPQUAD(arpinfo->src.s_addr), NIPQUAD(arpinfo->src.s_addr),
arpinfo->invflags & ARPT_INV_SRCIP ? " (INV)" : ""); arpinfo->invflags & ARPT_INV_SRCIP ? " (INV)" : "");
dprintf("TGT: %u.%u.%u.%u Mask: %u.%u.%u.%u Target: %u.%u.%u.%u.%s\n", dprintf("TGT: %u.%u.%u.%u Mask: %u.%u.%u.%u Target: %u.%u.%u.%u.%s\n",
NIPQUAD(*tgt_ipaddr), NIPQUAD(tgt_ipaddr),
NIPQUAD(arpinfo->tmsk.s_addr), NIPQUAD(arpinfo->tmsk.s_addr),
NIPQUAD(arpinfo->tgt.s_addr), NIPQUAD(arpinfo->tgt.s_addr),
arpinfo->invflags & ARPT_INV_TGTIP ? " (INV)" : ""); arpinfo->invflags & ARPT_INV_TGTIP ? " (INV)" : "");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment