lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110508221055.GE15585@thunk.org>
Date:	Sun, 8 May 2011 18:10:55 -0400
From:	Ted Ts'o <tytso@....edu>
To:	Lukas Czerner <lczerner@...hat.com>
Cc:	linux-ext4@...r.kernel.org
Subject: Re: [PATCH] e2fsprogs: fix memory leak in
 ext2fs_free_generic_bmap()

On Mon, Mar 21, 2011 at 11:14:00AM +0100, Lukas Czerner wrote:
> In ext2fs_free_generic_bmap() when we are freeing 64-bit bitmap, we do
> call free_bmap() to free backend specific bitmap structures, however we
> should also free ext2fs_generic_bitmap structure as well. So this commit
> fixes that and removes unnecessary assignments.
> 
> Signed-off-by: Lukas Czerner <lczerner@...hat.com>
> ---
>  lib/ext2fs/gen_bitmap64.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
> index 8b9e4c5..f343cc7 100644
> --- a/lib/ext2fs/gen_bitmap64.c
> +++ b/lib/ext2fs/gen_bitmap64.c
> @@ -153,11 +153,11 @@ void ext2fs_free_generic_bmap(ext2fs_generic_bitmap bmap)
>  
>  	bmap->bitmap_ops->free_bmap(bmap);
>  
> -	if (bmap->description) {
> +	if (bmap->description)
>  		ext2fs_free_mem(&bmap->description);
> -		bmap->description = 0;
> -	}
> -	bmap->magic = 0;
> +
> +	ext2fs_free_mem(&bmap);
> +	bmap = NULL;

Setting bmap to NULL is pointless since C doesn't have
pass-by-reference ala C++ (i.e., it's not like this function parameter
is declared "ext2fs_generic_bitmap &bmap").

So it's actually a good idea to zap bmap->description, and especially
bmap->magic, since that will allow us to catch attempts to use the
bitmap after we free it.

I'll make the simplification of your patch which just adds the missing
"ext2fs_free_mem(&bmap)" call.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ