summaryrefslogtreecommitdiffstats
path: root/net/bridge
diff options
context:
space:
mode:
authorWenwen Wang <wenwen@cs.uga.edu>2019-07-20 07:22:45 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-29 08:26:37 +0200
commitbdfb3b352767c98cefe6ca50ba4ed4b34d4aea20 (patch)
tree7b7b2566d0838742e77dd3a34a8de09246d5300b /net/bridge
parent5bb56df55934237ae7a35299fb17f231a46e3e31 (diff)
downloadlinux-stable-bdfb3b352767c98cefe6ca50ba4ed4b34d4aea20.tar.gz
linux-stable-bdfb3b352767c98cefe6ca50ba4ed4b34d4aea20.tar.bz2
linux-stable-bdfb3b352767c98cefe6ca50ba4ed4b34d4aea20.zip
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>
Diffstat (limited to 'net/bridge')
-rw-r--r--net/bridge/netfilter/ebtables.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index f9c6e8ca1fcb..100b4f88179a 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -2273,8 +2273,10 @@ static int compat_do_replace(struct net *net, void __user *user,
state.buf_kern_len = size64;
ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state);
- if (WARN_ON(ret < 0))
+ if (WARN_ON(ret < 0)) {
+ vfree(entries_tmp);
goto out_unlock;
+ }
vfree(entries_tmp);
tmp.entries_size = size64;