Skip to content

Commit

Permalink
netfilter: Correct calculation using skb->tail and skb-network_header
Browse files Browse the repository at this point in the history
This corrects an regression introduced by "net: Use 16bits for *_headers
fields of struct skbuff" when NET_SKBUFF_DATA_USES_OFFSET is not set. In
that case skb->tail will be a pointer whereas skb->network_header
will be an offset from head. This is corrected by using wrappers that
ensure that calculations are always made using pointers.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Simon Horman authored and David S. Miller committed May 31, 2013
1 parent db8caf3 commit 938177e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/netfilter/nf_nat_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void mangle_contents(struct sk_buff *skb,
/* move post-replacement */
memmove(data + match_offset + rep_len,
data + match_offset + match_len,
skb->tail - (skb->network_header + dataoff +
skb_tail_pointer(skb) - (skb_network_header(skb) + dataoff +
match_offset + match_len));

/* insert data from buffer */
Expand Down

0 comments on commit 938177e

Please sign in to comment.