From: Florian Westphal <fw@strlen.de>
To: John Stultz <john.stultz@linaro.org>
Cc: Florian Westphal <fw@strlen.de>,
Pablo Neira Ayuso <pablo@netfilter.org>,
lkml <linux-kernel@vger.kernel.org>,
netfilter-devel@vger.kernel.org
Subject: Re: [Regression?] iptables broken on 32bit with pre-4.7-rc
Date: Thu, 26 May 2016 11:51:12 +0200 [thread overview]
Message-ID: <20160526095112.GA14828@breakpoint.cc> (raw)
In-Reply-To: <CALAqxLXgAA=zV_AAOTkWE3yFaxNJ02y0jGwVrdTW+rSCrSUMkg@mail.gmail.com>
John Stultz <john.stultz@linaro.org> wrote:
> In updating a 32bit arm device from 4.6 to Linus' current HEAD, I
> noticed I was having some trouble with networking, and realized that
> /proc/net/ip_tables_names was suddenly empty.
>
> Digging through the registration process, it seems we're catching on the:
>
> if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0 &&
> target_offset + sizeof(struct xt_standard_target) != next_offset)
> return -EINVAL;
>
> check added in 7ed2abddd20cf ("netfilter: x_tables: check standard
> target size too").
>
> Where next_offset seems to be 4 bytes larger then the the offset +
> standard_target struct size.
I guess its because arm32 needs 8 byte alignment for 64bit
quantities. So we can fix this either via XT_ALIGN()'ing the
target_offset + sizeof() result or by weakening the test to a '>'.
Since we already test proper alignment of start-of-rule in
check_entry_size_and_hooks() I'd suggest we just change the test
to fail only if the next offset is within the min size, i.e.:
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index c69c892..9643047 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -612,7 +612,7 @@ int xt_compat_check_entry_offsets(const void *base, const char *elems,
return -EINVAL;
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0 &&
- target_offset + sizeof(struct compat_xt_standard_target) != next_offset)
+ target_offset + sizeof(struct compat_xt_standard_target) > next_offset)
return -EINVAL;
/* compat_xt_entry match has less strict aligment requirements,
@@ -694,7 +694,7 @@ int xt_check_entry_offsets(const void *base,
return -EINVAL;
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0 &&
- target_offset + sizeof(struct xt_standard_target) != next_offset)
+ target_offset + sizeof(struct xt_standard_target) > next_offset)
return -EINVAL;
return xt_check_entry_match(elems, base + target_offset,
> I'm not exactly sure how the next_offset value is set, so I'm hoping
> the proper fix is more obvious to one of you.
Its the start of the next rule so it has to be properly aligned
via XT_ALIGN(). Only 32bit system I tested was plain x86 which
only needs 4byte alignment for u64...
Alternative would be something like this:
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index c69c892..ca16c26 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -612,7 +612,7 @@ int xt_compat_check_entry_offsets(const void *base, const char *elems,
return -EINVAL;
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0 &&
- target_offset + sizeof(struct compat_xt_standard_target) != next_offset)
+ XT_COMPAT_ALIGN(target_offset + sizeof(struct compat_xt_standard_target)) != next_offset)
return -EINVAL;
/* compat_xt_entry match has less strict aligment requirements,
@@ -694,7 +694,7 @@ int xt_check_entry_offsets(const void *base,
return -EINVAL;
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0 &&
- target_offset + sizeof(struct xt_standard_target) != next_offset)
+ XT_ALIGN(target_offset + sizeof(struct xt_standard_target)) != next_offset)
return -EINVAL;
return xt_check_entry_match(elems, base + target_offset,
but afaics the stricter check does not buy anything.
next prev parent reply other threads:[~2016-05-26 9:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-26 5:52 [Regression?] iptables broken on 32bit with pre-4.7-rc John Stultz
2016-05-26 9:51 ` Florian Westphal [this message]
2016-05-26 21:00 ` John Stultz
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=20160526095112.GA14828@breakpoint.cc \
--to=fw@strlen.de \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.