Commit 8bdb7e5e authored by Florian Westphal's avatar Florian Westphal Committed by Jiri Slaby

netfilter: x_tables: make sure e->next_offset covers remaining blob size

commit 6e94e0cf upstream.

Otherwise this function may read data beyond the ruleset blob.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Cc: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent 9192d640
...@@ -558,7 +558,8 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e, ...@@ -558,7 +558,8 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e,
int err; int err;
if ((unsigned long)e % __alignof__(struct arpt_entry) != 0 || if ((unsigned long)e % __alignof__(struct arpt_entry) != 0 ||
(unsigned char *)e + sizeof(struct arpt_entry) >= limit) { (unsigned char *)e + sizeof(struct arpt_entry) >= limit ||
(unsigned char *)e + e->next_offset > limit) {
duprintf("Bad offset %p\n", e); duprintf("Bad offset %p\n", e);
return -EINVAL; return -EINVAL;
} }
...@@ -1218,7 +1219,8 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e, ...@@ -1218,7 +1219,8 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,
duprintf("check_compat_entry_size_and_hooks %p\n", e); duprintf("check_compat_entry_size_and_hooks %p\n", e);
if ((unsigned long)e % __alignof__(struct compat_arpt_entry) != 0 || if ((unsigned long)e % __alignof__(struct compat_arpt_entry) != 0 ||
(unsigned char *)e + sizeof(struct compat_arpt_entry) >= limit) { (unsigned char *)e + sizeof(struct compat_arpt_entry) >= limit ||
(unsigned char *)e + e->next_offset > limit) {
duprintf("Bad offset %p, limit = %p\n", e, limit); duprintf("Bad offset %p, limit = %p\n", e, limit);
return -EINVAL; return -EINVAL;
} }
......
...@@ -720,7 +720,8 @@ check_entry_size_and_hooks(struct ipt_entry *e, ...@@ -720,7 +720,8 @@ check_entry_size_and_hooks(struct ipt_entry *e,
int err; int err;
if ((unsigned long)e % __alignof__(struct ipt_entry) != 0 || if ((unsigned long)e % __alignof__(struct ipt_entry) != 0 ||
(unsigned char *)e + sizeof(struct ipt_entry) >= limit) { (unsigned char *)e + sizeof(struct ipt_entry) >= limit ||
(unsigned char *)e + e->next_offset > limit) {
duprintf("Bad offset %p\n", e); duprintf("Bad offset %p\n", e);
return -EINVAL; return -EINVAL;
} }
...@@ -1483,7 +1484,8 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e, ...@@ -1483,7 +1484,8 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e,
duprintf("check_compat_entry_size_and_hooks %p\n", e); duprintf("check_compat_entry_size_and_hooks %p\n", e);
if ((unsigned long)e % __alignof__(struct compat_ipt_entry) != 0 || if ((unsigned long)e % __alignof__(struct compat_ipt_entry) != 0 ||
(unsigned char *)e + sizeof(struct compat_ipt_entry) >= limit) { (unsigned char *)e + sizeof(struct compat_ipt_entry) >= limit ||
(unsigned char *)e + e->next_offset > limit) {
duprintf("Bad offset %p, limit = %p\n", e, limit); duprintf("Bad offset %p, limit = %p\n", e, limit);
return -EINVAL; return -EINVAL;
} }
......
...@@ -731,7 +731,8 @@ check_entry_size_and_hooks(struct ip6t_entry *e, ...@@ -731,7 +731,8 @@ check_entry_size_and_hooks(struct ip6t_entry *e,
int err; int err;
if ((unsigned long)e % __alignof__(struct ip6t_entry) != 0 || if ((unsigned long)e % __alignof__(struct ip6t_entry) != 0 ||
(unsigned char *)e + sizeof(struct ip6t_entry) >= limit) { (unsigned char *)e + sizeof(struct ip6t_entry) >= limit ||
(unsigned char *)e + e->next_offset > limit) {
duprintf("Bad offset %p\n", e); duprintf("Bad offset %p\n", e);
return -EINVAL; return -EINVAL;
} }
...@@ -1495,7 +1496,8 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e, ...@@ -1495,7 +1496,8 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e,
duprintf("check_compat_entry_size_and_hooks %p\n", e); duprintf("check_compat_entry_size_and_hooks %p\n", e);
if ((unsigned long)e % __alignof__(struct compat_ip6t_entry) != 0 || if ((unsigned long)e % __alignof__(struct compat_ip6t_entry) != 0 ||
(unsigned char *)e + sizeof(struct compat_ip6t_entry) >= limit) { (unsigned char *)e + sizeof(struct compat_ip6t_entry) >= limit ||
(unsigned char *)e + e->next_offset > limit) {
duprintf("Bad offset %p, limit = %p\n", e, limit); duprintf("Bad offset %p, limit = %p\n", e, limit);
return -EINVAL; return -EINVAL;
} }
......
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