netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Popov <dp@highloadlab.com>
To: Jan Engelhardt <jengelh@gmx.de>
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case).
Date: Sun, 5 May 2013 22:05:04 +0400	[thread overview]
Message-ID: <20130505220504.1a3f2380a1e798b37e628dd1@highloadlab.com> (raw)

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:

             reply	other threads:[~2013-05-05 18:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-05 18:05 Dmitry Popov [this message]
2013-05-05 18:24 ` [PATCH] xtables-addons: xt_RAWNAT: skb writable part might not include whole l4 header (ipv4 case) 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130505220504.1a3f2380a1e798b37e628dd1@highloadlab.com \
    --to=dp@highloadlab.com \
    --cc=jengelh@gmx.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).