OSDN Git Service

netfilter: x_tables: avoid stack-out-of-bounds read in xt_copy_counters_from_user
authorEric Dumazet <edumazet@google.com>
Thu, 5 Oct 2017 09:50:07 +0000 (02:50 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Sep 2018 20:48:59 +0000 (22:48 +0200)
commitf9845426f4427eb0031b562dfd5c0ffe99cba644
treeb9781aac456ff593f24f18a01135aaa086a8c5cd
parenta3b92ee6fc171d7c9d9b6b829b7fef169210440c
netfilter: x_tables: avoid stack-out-of-bounds read in xt_copy_counters_from_user

commit e466af75c074e76107ae1cd5a2823e9c61894ffb upstream.

syzkaller reports an out of bound read in strlcpy(), triggered
by xt_copy_counters_from_user()

Fix this by using memcpy(), then forcing a zero byte at the last position
of the destination, as Florian did for the non COMPAT code.

Fixes: d7591f0c41ce ("netfilter: x_tables: introduce and use xt_copy_counters_from_user")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netfilter/x_tables.c