Re: [PATCH] netfilter: ebtables: compat: fix a memory leak bug

From: Pablo Neira Ayuso
Date: Sun Jul 21 2019 - 14:59:56 EST

On Sat, Jul 20, 2019 at 07:22:45AM -0500, Wenwen Wang wrote:
> From: Wenwen Wang <wenwen@xxxxxxxxxx>
> 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().

Applied, thanks.