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

From: Florian Westphal
Date: Sat Jul 20 2019 - 20:27:14 EST


Wenwen Wang <wang6495@xxxxxxx> 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().
>
> Signed-off-by: Wenwen Wang <wenwen@xxxxxxxxxx>

Reviewed-by: Florian Westphal <fw@xxxxxxxxx>