netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case).
@ 2013-05-05 18:05 Dmitry Popov
  2013-05-05 18:24 ` Dmitry Popov
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Popov @ 2013-05-05 18:05 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: netfilter-devel

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 <dp@highloadlab.com>
---
 extensions/xt_RAWNAT.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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:

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-05-15 15:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-05 18:05 [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case) Dmitry Popov
2013-05-05 18:24 ` Dmitry Popov
2013-05-08 11:32   ` Jan Engelhardt
2013-05-08 15:12     ` Dmitry Popov
2013-05-08 21:32       ` Jan Engelhardt
2013-05-13  9:50         ` Dmitry Popov
2013-05-15 15:04           ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).