public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/msm: Adjust msm_iommu_pagetable_prealloc_allocate() allocation type
@ 2026-02-06 22:21 Kees Cook
  2026-02-07  9:13 ` Dmitry Baryshkov
  2026-02-24  4:05 ` Dmitry Baryshkov
  0 siblings, 2 replies; 3+ messages in thread
From: Kees Cook @ 2026-02-06 22:21 UTC (permalink / raw)
  To: Rob Clark
  Cc: Kees Cook, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
	Sean Paul, Marijn Suijten, David Airlie, Simona Vetter,
	linux-arm-msm, dri-devel, freedreno, linux-kernel,
	linux-hardening

In preparation for making the kmalloc family of allocators type aware,
we need to make sure that the returned type from the allocation matches
the type of the variable being assigned. (Before, the allocator would
always return "void *", which can be implicitly cast to any pointer type.)

The assigned type is "void **" but the returned type will be "void ***".
These are the same allocation size (pointer size), but the types do not
match. Adjust the allocation type to match the assignment.

Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Rob Clark <robin.clark@oss.qualcomm.com>
Cc: Dmitry Baryshkov <lumag@kernel.org>
Cc: Abhinav Kumar <abhinav.kumar@linux.dev>
Cc: Jessica Zhang <jesszhan0024@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Marijn Suijten <marijn.suijten@somainline.org>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Cc: <linux-arm-msm@vger.kernel.org>
Cc: <dri-devel@lists.freedesktop.org>
Cc: <freedreno@lists.freedesktop.org>
---
 drivers/gpu/drm/msm/msm_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
index d5dede4ff761..271baf4dc4e8 100644
--- a/drivers/gpu/drm/msm/msm_iommu.c
+++ b/drivers/gpu/drm/msm/msm_iommu.c
@@ -332,7 +332,7 @@ msm_iommu_pagetable_prealloc_allocate(struct msm_mmu *mmu, struct msm_mmu_preall
 	struct kmem_cache *pt_cache = get_pt_cache(mmu);
 	int ret;
 
-	p->pages = kvmalloc_array(p->count, sizeof(p->pages), GFP_KERNEL);
+	p->pages = kvmalloc_array(p->count, sizeof(*p->pages), GFP_KERNEL);
 	if (!p->pages)
 		return -ENOMEM;
 
-- 
2.34.1


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

* Re: [PATCH] drm/msm: Adjust msm_iommu_pagetable_prealloc_allocate() allocation type
  2026-02-06 22:21 [PATCH] drm/msm: Adjust msm_iommu_pagetable_prealloc_allocate() allocation type Kees Cook
@ 2026-02-07  9:13 ` Dmitry Baryshkov
  2026-02-24  4:05 ` Dmitry Baryshkov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2026-02-07  9:13 UTC (permalink / raw)
  To: Kees Cook
  Cc: Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
	Sean Paul, Marijn Suijten, David Airlie, Simona Vetter,
	linux-arm-msm, dri-devel, freedreno, linux-kernel,
	linux-hardening

On Fri, Feb 06, 2026 at 02:21:52PM -0800, Kees Cook wrote:
> In preparation for making the kmalloc family of allocators type aware,
> we need to make sure that the returned type from the allocation matches
> the type of the variable being assigned. (Before, the allocator would
> always return "void *", which can be implicitly cast to any pointer type.)
> 
> The assigned type is "void **" but the returned type will be "void ***".
> These are the same allocation size (pointer size), but the types do not
> match. Adjust the allocation type to match the assignment.
> 
> Signed-off-by: Kees Cook <kees@kernel.org>
> ---
> Cc: Rob Clark <robin.clark@oss.qualcomm.com>
> Cc: Dmitry Baryshkov <lumag@kernel.org>
> Cc: Abhinav Kumar <abhinav.kumar@linux.dev>
> Cc: Jessica Zhang <jesszhan0024@gmail.com>
> Cc: Sean Paul <sean@poorly.run>
> Cc: Marijn Suijten <marijn.suijten@somainline.org>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Simona Vetter <simona@ffwll.ch>
> Cc: <linux-arm-msm@vger.kernel.org>
> Cc: <dri-devel@lists.freedesktop.org>
> Cc: <freedreno@lists.freedesktop.org>
> ---
>  drivers/gpu/drm/msm/msm_iommu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

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

* Re: [PATCH] drm/msm: Adjust msm_iommu_pagetable_prealloc_allocate() allocation type
  2026-02-06 22:21 [PATCH] drm/msm: Adjust msm_iommu_pagetable_prealloc_allocate() allocation type Kees Cook
  2026-02-07  9:13 ` Dmitry Baryshkov
@ 2026-02-24  4:05 ` Dmitry Baryshkov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2026-02-24  4:05 UTC (permalink / raw)
  To: Rob Clark, Kees Cook
  Cc: Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm,
	dri-devel, freedreno, linux-kernel, linux-hardening

On Fri, 06 Feb 2026 14:21:52 -0800, Kees Cook wrote:
> In preparation for making the kmalloc family of allocators type aware,
> we need to make sure that the returned type from the allocation matches
> the type of the variable being assigned. (Before, the allocator would
> always return "void *", which can be implicitly cast to any pointer type.)
> 
> The assigned type is "void **" but the returned type will be "void ***".
> These are the same allocation size (pointer size), but the types do not
> match. Adjust the allocation type to match the assignment.
> 
> [...]

Applied to msm-fixes, thanks!

[1/1] drm/msm: Adjust msm_iommu_pagetable_prealloc_allocate() allocation type
      https://gitlab.freedesktop.org/lumag/msm/-/commit/6f6f3535192d

Best regards,
-- 
With best wishes
Dmitry



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

end of thread, other threads:[~2026-02-24  4:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-06 22:21 [PATCH] drm/msm: Adjust msm_iommu_pagetable_prealloc_allocate() allocation type Kees Cook
2026-02-07  9:13 ` Dmitry Baryshkov
2026-02-24  4:05 ` Dmitry Baryshkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox