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] [day] [month] [year] [list]
Date:	Tue, 13 Aug 2013 11:50:43 -0300
From:	Ezequiel Garcia <ezequiel.garcia@...e-electrons.com>
To:	Nilanjan Roychowdhury <nilanjan.roychowdhury@...il.com>
Cc:	linux-mtd@...ts.infradead.org,
	David Woodhouse <dwmw2@...radead.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] Resubmit mtd: mtdoops: fix for a potential memory
 leak in mtdoops_notify_remove

Hi Nilanjan,

On Mon, Aug 12, 2013 at 09:48:35PM -0700, Nilanjan Roychowdhury wrote:
> we are allocating cxt->oops_page_used using vmalloc in mtdoops_notify_add for
> every mtd_info addition but not freeing it in mtdoops_notify_remove. Also care is
> taken so that we do not free the same pointer again in module remove.
> 

Could you re-send this with a better commit message?

In particular we'd like to see why you're doing this, explaining
how the current implementation implies a possible leak, explaining under
what circumstance this leak.

I think it would be great if you could test the patch and also add
some information about the testing scenario.

Please note the subject should be "[PATCH v2] mtd: ...", with a
proper patch version number. The next patch will be v3 (and so on) which
should be stated in the subject.

Also...

> Signed-off-by: Nilanjan Roychowdhury <nilanjan.roychowdhury@...il.com>
> ---

In this place (between the "---" and the diffstat) you can put some
changelog information, like this:

Changes from v2:
 * Did this and that.

Changes from v1:
 * Added check to vfree() in remove function as suggested by Ezequiel.

>  drivers/mtd/mtdoops.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
> index 97bb8f6..4b8b621 100644
> --- a/drivers/mtd/mtdoops.c
> +++ b/drivers/mtd/mtdoops.c
> @@ -386,6 +386,8 @@ static void mtdoops_notify_remove(struct mtd_info *mtd)
>  	cxt->mtd = NULL;
>  	flush_work(&cxt->work_erase);
>  	flush_work(&cxt->work_write);
> +	vfree(cxt->oops_page_used);
> +	cxt->oops_page_used = NULL;
>  }
>  
>  
> @@ -439,7 +441,8 @@ static void __exit mtdoops_exit(void)
>  
>  	unregister_mtd_user(&mtdoops_notifier);
>  	vfree(cxt->oops_buf);
> -	vfree(cxt->oops_page_used);
> +	if (cxt->oops_page_used)
> +		vfree(cxt->oops_page_used);
>  }
>  
>  
> -- 
> 1.7.9.5
> 

Thanks!
-- 
Ezequiel GarcĂ­a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ