From e8118014845adf098a333f8f2efcd1771b32f4c1 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Wed, 13 Jul 2016 11:44:54 +0100 Subject: [PATCH] netfilter: x_tables: check for size overflow Ben Hawkes says: integer overflow in xt_alloc_table_info, which on 32-bit systems can lead to small structure allocation and a copy_from_user based heap corruption. Reported-by: Ben Hawkes Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso (cherry picked from commit d157bd761585605b7882935ffb86286919f62ea1) CVE-2016-3135 BugLink: https://bugs.launchpad.net/bugs/1555353 Signed-off-by: Luis Henriques Acked-by: Tim Gardner Signed-off-by: Kamal Mostafa --- net/netfilter/x_tables.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 2e94272f7f85..d2671f6b2d7f 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -898,6 +898,9 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size) struct xt_table_info *info = NULL; size_t sz = sizeof(*info) + size; + if (sz < sizeof(*info)) + return NULL; + /* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */ if ((SMP_ALIGN(size) >> PAGE_SHIFT) + 2 > totalram_pages) return NULL; -- 2.39.5