linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] iommu/dma: Use kvcalloc() instead of kvzalloc()
@ 2021-09-28 22:22 Gustavo A. R. Silva
  2021-10-21 17:01 ` Kees Cook
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2021-09-28 22:22 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon
  Cc: iommu, linux-kernel, Gustavo A. R. Silva, linux-hardening

Use 2-factor argument form kvcalloc() instead of kvzalloc().

Link: https://github.com/KSPP/linux/issues/162
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/iommu/dma-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 896bea04c347..18c6edbe5fbf 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -616,7 +616,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,
 	if (!order_mask)
 		return NULL;
 
-	pages = kvzalloc(count * sizeof(*pages), GFP_KERNEL);
+	pages = kvcalloc(count, sizeof(*pages), GFP_KERNEL);
 	if (!pages)
 		return NULL;
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH][next] iommu/dma: Use kvcalloc() instead of kvzalloc()
  2021-09-28 22:22 [PATCH][next] iommu/dma: Use kvcalloc() instead of kvzalloc() Gustavo A. R. Silva
@ 2021-10-21 17:01 ` Kees Cook
  2021-10-21 17:50 ` Robin Murphy
  2021-10-27  8:05 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2021-10-21 17:01 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Joerg Roedel, Will Deacon, iommu, linux-kernel, linux-hardening

On Tue, Sep 28, 2021 at 05:22:29PM -0500, Gustavo A. R. Silva wrote:
> Use 2-factor argument form kvcalloc() instead of kvzalloc().
> 
> Link: https://github.com/KSPP/linux/issues/162
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Looks right.

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][next] iommu/dma: Use kvcalloc() instead of kvzalloc()
  2021-09-28 22:22 [PATCH][next] iommu/dma: Use kvcalloc() instead of kvzalloc() Gustavo A. R. Silva
  2021-10-21 17:01 ` Kees Cook
@ 2021-10-21 17:50 ` Robin Murphy
  2021-10-27  8:05 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2021-10-21 17:50 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Joerg Roedel, Will Deacon
  Cc: iommu, linux-hardening, linux-kernel

On 2021-09-28 23:22, Gustavo A. R. Silva wrote:
> Use 2-factor argument form kvcalloc() instead of kvzalloc().

If we have a thing for that now, then sure, why not. FWIW this can't 
ever overflow due to where "count" comes from, but it has no reason to 
be special.

Acked-by: Robin Murphy <robin.murphy@arm.com>

> Link: https://github.com/KSPP/linux/issues/162
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
>   drivers/iommu/dma-iommu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 896bea04c347..18c6edbe5fbf 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -616,7 +616,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,
>   	if (!order_mask)
>   		return NULL;
>   
> -	pages = kvzalloc(count * sizeof(*pages), GFP_KERNEL);
> +	pages = kvcalloc(count, sizeof(*pages), GFP_KERNEL);
>   	if (!pages)
>   		return NULL;
>   
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][next] iommu/dma: Use kvcalloc() instead of kvzalloc()
  2021-09-28 22:22 [PATCH][next] iommu/dma: Use kvcalloc() instead of kvzalloc() Gustavo A. R. Silva
  2021-10-21 17:01 ` Kees Cook
  2021-10-21 17:50 ` Robin Murphy
@ 2021-10-27  8:05 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2021-10-27  8:05 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Will Deacon, iommu, linux-kernel, linux-hardening

On Tue, Sep 28, 2021 at 05:22:29PM -0500, Gustavo A. R. Silva wrote:
> Use 2-factor argument form kvcalloc() instead of kvzalloc().
> 
> Link: https://github.com/KSPP/linux/issues/162
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
>  drivers/iommu/dma-iommu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-27  8:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 22:22 [PATCH][next] iommu/dma: Use kvcalloc() instead of kvzalloc() Gustavo A. R. Silva
2021-10-21 17:01 ` Kees Cook
2021-10-21 17:50 ` Robin Murphy
2021-10-27  8:05 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).