Commit f20f892e authored by Florian Westphal's avatar Florian Westphal Committed by Ben Hutchings

netfilter: x_tables: don't reject valid target size on some architectures

commit 7b7eba0f upstream.

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: default avatarJohn Stultz <john.stultz@linaro.org>
Tested-by: default avatarJohn Stultz <john.stultz@linaro.org>
Fixes: 7ed2abdd ("netfilter: x_tables: check standard target size too")
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 592d29f2
...@@ -628,7 +628,7 @@ int xt_compat_check_entry_offsets(const void *base, const char *elems, ...@@ -628,7 +628,7 @@ int xt_compat_check_entry_offsets(const void *base, const char *elems,
return -EINVAL; return -EINVAL;
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0 && 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; return -EINVAL;
/* compat_xt_entry match has less strict aligment requirements, /* compat_xt_entry match has less strict aligment requirements,
...@@ -710,7 +710,7 @@ int xt_check_entry_offsets(const void *base, ...@@ -710,7 +710,7 @@ int xt_check_entry_offsets(const void *base,
return -EINVAL; return -EINVAL;
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0 && 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 -EINVAL;
return xt_check_entry_match(elems, base + target_offset, return xt_check_entry_match(elems, base + target_offset,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment