Skip to content

Commit fe1e402

Browse files
Florian Westphalgregkh
authored andcommitted
netfilter: x_tables: don't reject valid target size on some architectures
commit 7b7eba0f3515fca3296b8881d583f7c1042f5226 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: 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> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent caa39a1 commit fe1e402

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

net/netfilter/x_tables.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ int xt_compat_check_entry_offsets(const void *base, const char *elems,
608608
return -EINVAL;
609609

610610
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0 &&
611-
target_offset + sizeof(struct compat_xt_standard_target) != next_offset)
611+
COMPAT_XT_ALIGN(target_offset + sizeof(struct compat_xt_standard_target)) != next_offset)
612612
return -EINVAL;
613613

614614
/* compat_xt_entry match has less strict aligment requirements,
@@ -690,7 +690,7 @@ int xt_check_entry_offsets(const void *base,
690690
return -EINVAL;
691691

692692
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0 &&
693-
target_offset + sizeof(struct xt_standard_target) != next_offset)
693+
XT_ALIGN(target_offset + sizeof(struct xt_standard_target)) != next_offset)
694694
return -EINVAL;
695695

696696
return xt_check_entry_match(elems, base + target_offset,

0 commit comments

Comments
 (0)