From b70905e7cbc14c987eb5ced1c243de9c2f67fa6d Mon Sep 17 00:00:00 2001 From: Dmitry Popov Date: Sun, 5 May 2013 20:05:04 +0200 Subject: [PATCH] xt_RAWNAT: skb writable part might not include whole L4 header (IPv4 case) Consider TCP/IPv4 packet with IP options: sizeof(*iph) + sizeof(struct tcphdr) is not enough to include tcp checksum. It may hurt if this packet is fragmented. Therefore, we should use iph->ihl * 4 instead of sizeof(*iph). Signed-off-by: Dmitry Popov --- doc/changelog.txt | 2 ++ extensions/xt_RAWNAT.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/changelog.txt b/doc/changelog.txt index fd0989a..f39b119 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -1,6 +1,8 @@ HEAD ==== +Fixes: +- xt_RAWNAT: ensure correct operation in the presence of IPv4 options v2.2 (2013-03-31) diff --git a/extensions/xt_RAWNAT.c b/extensions/xt_RAWNAT.c index a52e614..858f911 100644 --- a/extensions/xt_RAWNAT.c +++ b/extensions/xt_RAWNAT.c @@ -109,7 +109,7 @@ static void rawnat4_update_l4(struct sk_buff *skb, __be32 oldip, __be32 newip) static unsigned int rawnat4_writable_part(const struct iphdr *iph) { - unsigned int wlen = sizeof(*iph); + unsigned int wlen = iph->ihl * 4; switch (iph->protocol) { case IPPROTO_TCP: