* Re: [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree()
2025-08-10 13:34 [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree() Akhilesh Patil
@ 2025-08-10 17:53 ` Nicolin Chen
2025-08-15 10:06 ` Tian, Kevin
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Nicolin Chen @ 2025-08-10 17:53 UTC (permalink / raw)
To: Akhilesh Patil
Cc: jgg, kevin.tian, joro, will, robin.murphy, praan, baolu.lu, jgg,
iommu, linux-kernel, akhileshpatilvnit, skhan
On Sun, Aug 10, 2025 at 07:04:01PM +0530, Akhilesh Patil wrote:
> Use kvfree() instead of kfree() to free pages allocated by kvcalloc()
> in iommufs_hw_queue_alloc_phys() to fix potential memory corruption.
> Ensure the memory is properly freed, as kvcalloc may internally use
> vmalloc or kmalloc depending on available memory in the system.
>
> Fixes: 2238ddc2b056 ("iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl")
> Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread* RE: [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree()
2025-08-10 13:34 [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree() Akhilesh Patil
2025-08-10 17:53 ` Nicolin Chen
@ 2025-08-15 10:06 ` Tian, Kevin
2025-08-15 10:45 ` Pranjal Shrivastava
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Tian, Kevin @ 2025-08-15 10:06 UTC (permalink / raw)
To: Akhilesh Patil, jgg@ziepe.ca, joro@8bytes.org, will@kernel.org,
robin.murphy@arm.com, praan@google.com, baolu.lu@linux.intel.com,
nicolinc@nvidia.com, jgg@nvidia.com
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
akhileshpatilvnit@gmail.com, skhan@linuxfoundation.org
> From: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
> Sent: Sunday, August 10, 2025 9:34 PM
>
> Use kvfree() instead of kfree() to free pages allocated by kvcalloc()
> in iommufs_hw_queue_alloc_phys() to fix potential memory corruption.
> Ensure the memory is properly freed, as kvcalloc may internally use
> vmalloc or kmalloc depending on available memory in the system.
>
> Fixes: 2238ddc2b056 ("iommufd/viommu: Add
> IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl")
> Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree()
2025-08-10 13:34 [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree() Akhilesh Patil
2025-08-10 17:53 ` Nicolin Chen
2025-08-15 10:06 ` Tian, Kevin
@ 2025-08-15 10:45 ` Pranjal Shrivastava
2025-08-15 13:42 ` Markus Elfring
2025-08-18 14:14 ` Jason Gunthorpe
4 siblings, 0 replies; 8+ messages in thread
From: Pranjal Shrivastava @ 2025-08-15 10:45 UTC (permalink / raw)
To: Akhilesh Patil
Cc: jgg, kevin.tian, joro, will, robin.murphy, baolu.lu, nicolinc,
jgg, iommu, linux-kernel, akhileshpatilvnit, skhan
On Sun, Aug 10, 2025 at 07:04:01PM +0530, Akhilesh Patil wrote:
> Use kvfree() instead of kfree() to free pages allocated by kvcalloc()
> in iommufs_hw_queue_alloc_phys() to fix potential memory corruption.
> Ensure the memory is properly freed, as kvcalloc may internally use
> vmalloc or kmalloc depending on available memory in the system.
>
> Fixes: 2238ddc2b056 ("iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl")
> Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Thanks,
Praan
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree()
2025-08-10 13:34 [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree() Akhilesh Patil
` (2 preceding siblings ...)
2025-08-15 10:45 ` Pranjal Shrivastava
@ 2025-08-15 13:42 ` Markus Elfring
2025-08-15 14:15 ` Robin Murphy
2025-08-18 14:14 ` Jason Gunthorpe
4 siblings, 1 reply; 8+ messages in thread
From: Markus Elfring @ 2025-08-15 13:42 UTC (permalink / raw)
To: Akhilesh Patil, iommu
Cc: akhileshpatilvnit, LKML, Jason Gunthorpe, Jason Gunthorpe,
Jörg Rödel, Kevin Tian, Lu Baolu, Nicolin Chen,
Pranjal Shrivastava, Robin Murphy, Shuah Khan, Will Deacon
> Use kvfree() instead of kfree() to free pages allocated by kvcalloc()
> in iommufs_hw_queue_alloc_phys() to fix potential memory corruption.
> Ensure the memory is properly freed, as kvcalloc may internally use
> vmalloc or kmalloc depending on available memory in the system.
Will another bit of background information become helpful
for an improved change description?
Test command example:
Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> /usr/bin/spatch -D report scripts/coccinelle/api/kfree_mismatch.cocci drivers/iommu/iommufd/viommu.c
…
Regards,
Markus
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree()
2025-08-15 13:42 ` Markus Elfring
@ 2025-08-15 14:15 ` Robin Murphy
2025-08-15 14:52 ` Markus Elfring
0 siblings, 1 reply; 8+ messages in thread
From: Robin Murphy @ 2025-08-15 14:15 UTC (permalink / raw)
To: Markus Elfring, Akhilesh Patil, iommu
Cc: akhileshpatilvnit, LKML, Jason Gunthorpe, Jason Gunthorpe,
Jörg Rödel, Kevin Tian, Lu Baolu, Nicolin Chen,
Pranjal Shrivastava, Shuah Khan, Will Deacon
On 15/08/2025 2:42 pm, Markus Elfring wrote:
>> Use kvfree() instead of kfree() to free pages allocated by kvcalloc()
>> in iommufs_hw_queue_alloc_phys() to fix potential memory corruption.
>> Ensure the memory is properly freed, as kvcalloc may internally use
>> vmalloc or kmalloc depending on available memory in the system.
>
> Will another bit of background information become helpful
> for an improved change description?
No it will not. Please stop pointlessly nitpicking. A thing that is
allocated with kv*alloc() must be freed with kvfree(); that alone is all
that needs to be said to explain and justify any patch fixing this
particular bug.
Thanks,
Robin.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree()
2025-08-15 14:15 ` Robin Murphy
@ 2025-08-15 14:52 ` Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: Markus Elfring @ 2025-08-15 14:52 UTC (permalink / raw)
To: Robin Murphy, Akhilesh Patil, iommu
Cc: akhileshpatilvnit, LKML, Jason Gunthorpe, Jason Gunthorpe,
Jörg Rödel, Kevin Tian, Lu Baolu, Nicolin Chen,
Pranjal Shrivastava, Shuah Khan, Will Deacon
>> Will another bit of background information become helpful
>> for an improved change description?
>
> No it will not. Please stop pointlessly nitpicking. …
Do you care for help and further influence of automatic source code analysis tools?
Regards,
Markus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree()
2025-08-10 13:34 [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree() Akhilesh Patil
` (3 preceding siblings ...)
2025-08-15 13:42 ` Markus Elfring
@ 2025-08-18 14:14 ` Jason Gunthorpe
4 siblings, 0 replies; 8+ messages in thread
From: Jason Gunthorpe @ 2025-08-18 14:14 UTC (permalink / raw)
To: Akhilesh Patil
Cc: kevin.tian, joro, will, robin.murphy, praan, baolu.lu, nicolinc,
iommu, linux-kernel, akhileshpatilvnit, skhan
On Sun, Aug 10, 2025 at 07:04:01PM +0530, Akhilesh Patil wrote:
> Use kvfree() instead of kfree() to free pages allocated by kvcalloc()
> in iommufs_hw_queue_alloc_phys() to fix potential memory corruption.
> Ensure the memory is properly freed, as kvcalloc may internally use
> vmalloc or kmalloc depending on available memory in the system.
>
> Fixes: 2238ddc2b056 ("iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl")
> Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
> ---
> drivers/iommu/iommufd/viommu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to for-rc
Thanks,
Jason
^ permalink raw reply [flat|nested] 8+ messages in thread