* [PATCH nf] netfilter: x_tables: don't reject valid target size on some architectures
@ 2016-06-01 0:04 Florian Westphal
2016-06-02 12:10 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2016-06-01 0:04 UTC (permalink / raw)
To: netfilter-devel; +Cc: john.stultz, Florian Westphal
Quoting John Stultz:
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;
Where next_offset seems to be 4 bytes larger then the
offset + standard_target struct size.
next_offset needs to be aligned via XT_ALIGN (so we can access all members
of ip(6)t_entry struct).
This problem didn't show up on i686 as it only needs 4-byte alignment for
u64, but iptables userspace on other 32bit arches does insert extra padding.
Reported-by: John Stultz <john.stultz@linaro.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Fixes: 7ed2abddd20cf ("netfilter: x_tables: check standard target size too")
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/x_tables.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index c69c892..2675d58 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)
+ COMPAT_XT_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,
--
2.7.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nf] netfilter: x_tables: don't reject valid target size on some architectures
2016-06-01 0:04 [PATCH nf] netfilter: x_tables: don't reject valid target size on some architectures Florian Westphal
@ 2016-06-02 12:10 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2016-06-02 12:10 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel, john.stultz
On Wed, Jun 01, 2016 at 02:04:44AM +0200, Florian Westphal wrote:
> Quoting John Stultz:
> 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;
>
> Where next_offset seems to be 4 bytes larger then the
> offset + standard_target struct size.
>
> next_offset needs to be aligned via XT_ALIGN (so we can access all members
> of ip(6)t_entry struct).
>
> This problem didn't show up on i686 as it only needs 4-byte alignment for
> u64, but iptables userspace on other 32bit arches does insert extra padding.
Applied, thanks Florian.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-02 12:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-01 0:04 [PATCH nf] netfilter: x_tables: don't reject valid target size on some architectures Florian Westphal
2016-06-02 12:10 ` 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).