ARM/dma-mapping: use kvcalloc for fallback memory allocation need
PATCH v2 1/1 ARM/dma-mapping: use kvcalloc for fallback memory allocation need
Current conditional determination of whether to use kzalloc or vzalloc has known issues such as "indefinite retry" when less than PAGE_SIZE memory is needed, but is unavailable. This LWN article [1] describes these issues in greater detail. Use helper function kvcalloc() instead which is more efficient in terms of performance and security.
[1] https://lwn.net/Articles/711653/
This patch proposal is based on following Coccinelle warning using the kvmalloc.cocci semantic patch.
arch/arm/mm/dma-mapping.c:858:28-29: WARNING opportunity for kvmalloc
The semantic patch suggests using kvzalloc() helper function, however, this patch proposes to use kvcalloc instead. kvcalloc() helper function uses 2-factor argument form which is better from a security perspective as described in the following KSPP project commit.
Commit 4e3fd7217105 ("wireguard: ratelimiter: use kvcalloc() instead of kvzalloc()")
---
Changes in v2:
1. Update patch subject to use kvcalloc
2. Use kvcalloc instead of kvzalloc helper function. Revise the patch proposal and the patch description accordingly.
arch/arm/mm/dma-mapping.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
arch/arm/mm/dma-mapping.c +1 -5
@@ -851,14 +851,10 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, {struct page **pages;int count = size >>PAGE_SHIFT ; -int array_size = count *sizeof (struct page *);int i =0 ;int order_idx =0 ; -if (array_size <=PAGE_SIZE ) - pages =kzalloc (array_size,GFP_KERNEL ); -else - pages =vzalloc (array_size); + pages =kvcalloc (count,sizeof (struct page *),GFP_KERNEL );if (!pages)return NULL ;
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 12 lines · Deepak R Varma
Current conditional determination of whether to use kzalloc or vzalloc has known issues such as "indefinite retry" when less than
PAGE_SIZEmemory is needed, but is unavailable. This LWN article [1] describes these issues in greater detail. Use helper functionkvcalloc()instead which is more efficient in terms of performance and security.[1] https://lwn.net/Articles/711653/
This patch proposal is based on following Coccinelle warning using the
kvmalloc.coccisemantic patch.
arch/arm/mm/dma-mapping.c:858:28-29: WARNING opportunity for kvmalloc
Quoted 8 lines
The semantic patch suggests using
kvzalloc()helper function, however, this patch proposes to use kvcalloc instead.kvcalloc()helper function uses 2-factor argument form which is better from a security perspective as described in the following KSPP project commit.Commit
4e3fd7217105("wireguard: ratelimiter: usekvcalloc()instead ofkvzalloc()")Signed-off-by Deepak R Varma <[email protected]>
Hello,
May I please request a review and feedback on this patch proposal?
Thank you,
./drv
Quoted 34 lines
---
Changes in v2:
1. Update patch subject to use kvcalloc
2. Use kvcalloc instead of kvzalloc helper function. Revise the patch proposal and the patch description accordingly.arch/arm/mm/dma-mapping.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)arch/arm/mm/dma-mapping.c +1
-6@@ -851,14 +851,10 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, {struct page **pages;int count = size >>PAGE_SHIFT ; -int array_size = count *sizeof (struct page *);int i =0 ;int order_idx =0 ; -if (array_size <=PAGE_SIZE ) - pages =kzalloc (array_size,GFP_KERNEL ); -else - pages =vzalloc (array_size); + pages =kvcalloc (count,sizeof (struct page *),GFP_KERNEL );if (!pages)return NULL ; --2.34.1
Russell King (Oracle)
maintainerQuoted 18 lines · Deepak R Varma
Quoted 17 lines · Deepak R Varma
Current conditional determination of whether to use kzalloc or vzalloc has known issues such as "indefinite retry" when less than
PAGE_SIZEmemory is needed, but is unavailable. This LWN article [1] describes these issues in greater detail. Use helper functionkvcalloc()instead which is more efficient in terms of performance and security.[1] https://lwn.net/Articles/711653/
This patch proposal is based on following Coccinelle warning using the
kvmalloc.coccisemantic patch.
arch/arm/mm/dma-mapping.c:858:28-29: WARNING opportunity for kvmallocThe semantic patch suggests using
kvzalloc()helper function, however, this patch proposes to use kvcalloc instead.kvcalloc()helper function uses 2-factor argument form which is better from a security perspective as described in the following KSPP project commit.
Quoted 6 lines
Quoted 3 lines
Commit
4e3fd7217105("wireguard: ratelimiter: usekvcalloc()instead ofkvzalloc()")Signed-off-by Deepak R Varma <[email protected]>Hello,
May I please request a review and feedback on this patch proposal?
The DMA API on ARM has been maintained by others recently, so it's no longer up to me. Please include Christoph Hellwig <[email protected]> when sending changes for this. Thanks.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Quoted 21 lines · Russell King (Oracle)
Quoted 20 lines · Deepak R Varma
Quoted 19 lines · Deepak R Varma
Current conditional determination of whether to use kzalloc or vzalloc has known issues such as "indefinite retry" when less than
PAGE_SIZEmemory is needed, but is unavailable. This LWN article [1] describes these issues in greater detail. Use helper functionkvcalloc()instead which is more efficient in terms of performance and security.[1] https://lwn.net/Articles/711653/
This patch proposal is based on following Coccinelle warning using the
kvmalloc.coccisemantic patch.
arch/arm/mm/dma-mapping.c:858:28-29: WARNING opportunity for kvmallocThe semantic patch suggests using
kvzalloc()helper function, however, this patch proposes to use kvcalloc instead.kvcalloc()helper function uses 2-factor argument form which is better from a security perspective as described in the following KSPP project commit.Commit
4e3fd7217105("wireguard: ratelimiter: usekvcalloc()instead ofkvzalloc()")
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Deepak R Varma <[email protected]>Hello,
May I please request a review and feedback on this patch proposal?The DMA API on ARM has been maintained by others recently, so it's no longer up to me. Please include Christoph Hellwig <[email protected]> when sending changes for this. Thanks.
Sure. Actually the get_maintainer.pl scripts still returns yourself as the maintainer for this driver. Hence the email to you.
I will send a v3 and include the change you asked for. I will keep you in cc if you don't mind.
Also, let me know if I can help with getting the maintainer list updated for this core subsystem.
Thank you,
./drv
Quoted 4 lines
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!