提交 258f2edb 编写于 作者: W Wenwen Wang 提交者: Xie XiuQi

netfilter: ebtables: fix a memory leak bug in compat

[ Upstream commit 15a78ba1 ]

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: NWenwen Wang <wenwen@cs.uga.edu>
Reviewed-by: NFlorian Westphal <fw@strlen.de>
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 c7a33d20
......@@ -2274,8 +2274,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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册