]> www.infradead.org Git - users/dwmw2/linux.git/commit
netfilter: ebtables: fix a memory leak bug in compat
authorWenwen Wang <wenwen@cs.uga.edu>
Sat, 20 Jul 2019 12:22:45 +0000 (07:22 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Aug 2019 06:29:51 +0000 (08:29 +0200)
commit8d376e73adf1d6a84a26bef2fba5a88775e2003a
tree62e428bf57daca72416712edd490a6b25d0f5c44
parent0ea8657938351d2c57126a13f99980ef556ef08c
netfilter: ebtables: fix a memory leak bug in compat

[ Upstream commit 15a78ba1844a8e052c1226f930133de4cef4e7ad ]

In compat_do_replace(), a temporary buffer is allocated through vmalloc()
to hold entries copied from the user space. The buffer address is firstly
saved to 'newinfo->entries', and later on assigned to 'entries_tmp'. Then
the entries in this temporary buffer is copied to the internal kernel
structure through compat_copy_entries(). If this copy process fails,
compat_do_replace() should be terminated. However, the allocated temporary
buffer is not freed on this path, leading to a memory leak.

To fix the bug, free the buffer before returning from compat_do_replace().

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bridge/netfilter/ebtables.c