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-next>] [day] [month] [year] [list]
Date:	Wed,  5 Mar 2014 10:31:17 +0800
From:	Zhouyi Zhou <zhouzhouyi@...il.com>
To:	<joro@...tes.org>, <iommu@...ts.linux-foundation.org>,
	<linux-kernel@...r.kernel.org>
Cc:	Zhouyi Zhou <zhouzhouyi@...il.com>,
	Zhouyi Zhou <yizhouzhou@....ac.cn>
Subject: Re: Re: [PATCH] IOMMU: iommu module do not check NULL return of kmem_cache_zalloc

From: Zhouyi Zhou <zhouzhouyi@...il.com>

On Tue, 4 Mar 2014 16:41:18 +0100
Joerg Roedel <joro@...tes.org> wrote:

> On Tue, Feb 11, 2014 at 10:12:53AM +0800, Zhouyi Zhou wrote:
> > From: Zhouyi Zhou <yizhouzhou@....ac.cn>
> > 
> > The function iopte_alloc do not check NULL return of kmem_cache_zalloc,
> > call iopte_free with argument 0 will panic.
> > 
> > Signed-off-by: Zhouyi Zhou <yizhouzhou@....ac.cn>
> > ---
> >  drivers/iommu/omap-iommu.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
> > index bcd78a7..5155714 100644
> > --- a/drivers/iommu/omap-iommu.c
> > +++ b/drivers/iommu/omap-iommu.c
> > @@ -551,7 +551,8 @@ static u32 *iopte_alloc(struct omap_iommu *obj, u32 *iopgd, u32 da)
> >    	      dev_vdbg(obj->dev, "%s: a new pte:%p\n", __func__, iopte);
> >  	      } else {
> >  	      	/* We raced, free the reduniovant table */
> > -		   iopte_free(iopte);
> > +			if (iopte)
> > +				iopte_free(iopte);
> 
> Isn't it better to put the check into iopte_free?
> 
> 
>	Joerg
> 
> 
Thanks Joerg for reviewing
Checking the null pointer in iopte_free guarantees kmem_cache_free
is happy all the time.

Signed-off-by: Zhouyi Zhou <yizhouzhou@....ac.cn>
Signed-off-by: Joerg Roedel <joro@...tes.org>

---
 drivers/iommu/omap-iommu.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index bcd78a7..51211e8 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -523,7 +523,8 @@ static void flush_iopte_range(u32 *first, u32 *last)
 static void iopte_free(u32 *iopte)
 {
 	/* Note: freed iopte's must be clean ready for re-use */
-	kmem_cache_free(iopte_cachep, iopte);
+	if (iopte)
+		kmem_cache_free(iopte_cachep, iopte);
 }
 
 static u32 *iopte_alloc(struct omap_iommu *obj, u32 *iopgd, u32 da)


--
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