* [PATCH] scsi: hpsa: Make buff allocation type unsigned
@ 2026-09-17 21:11 Kees Cook
2026-09-26 2:35 ` Martin K. Petersen (Oracle)
2026-10-06 2:44 ` Martin K. Petersen (Oracle)
0 siblings, 2 replies; 3+ messages in thread
From: Kees Cook @ 2026-09-17 21:11 UTC (permalink / raw)
To: Don Brace
Cc: Kees Cook, Kees Cook, James E.J. Bottomley, Martin K. Petersen,
storagedev, linux-scsi, linux-kernel, linux-hardening
From: Kees Cook <kees+treewide@kernel.org>
In preparation for converting the kmalloc family of allocators to the
type-aware kmalloc_obj family, we need to make sure that the returned
type from the allocation matches the type of the variable being
assigned. (The kmalloc family returns "void *", which can be implicitly
cast to any pointer type.)
The assigned type is "unsigned char **", but the converted allocation
type would be "char **", whose elements point to a character type of a
different signedness, so the two pointer types are not compatible. Take
the size from the assignment target instead. No change in allocation
size results.
Build tested ARCH=x86_64 allmodconfig with GCC 16.2.0:
drivers/scsi/hpsa.o
Assisted-by: LLM coccinelle
Signed-off-by: Kees Cook <kees+treewide@kernel.org>
---
Cc: Don Brace <don.brace@microchip.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: "Martin K. Petersen" <mkp@kernel.org>
Cc: <storagedev@microchip.com>
Cc: <linux-scsi@vger.kernel.org>
---
drivers/scsi/hpsa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 8edad1830abe..364cff7671e5 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -6499,7 +6499,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h,
return -EINVAL;
if (ioc->buf_size > ioc->malloc_size * SG_ENTRIES_IN_CMD)
return -EINVAL;
- buff = kcalloc(SG_ENTRIES_IN_CMD, sizeof(char *), GFP_KERNEL);
+ buff = kcalloc(SG_ENTRIES_IN_CMD, sizeof(*buff), GFP_KERNEL);
if (!buff) {
status = -ENOMEM;
goto cleanup1;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: hpsa: Make buff allocation type unsigned
2026-09-17 21:11 [PATCH] scsi: hpsa: Make buff allocation type unsigned Kees Cook
@ 2026-09-26 2:35 ` Martin K. Petersen (Oracle)
2026-10-06 2:44 ` Martin K. Petersen (Oracle)
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen (Oracle) @ 2026-09-26 2:35 UTC (permalink / raw)
To: Kees Cook
Cc: Don Brace, Kees Cook, James E.J. Bottomley, Martin K. Petersen,
storagedev, linux-scsi, linux-kernel, linux-hardening
Kees,
> The assigned type is "unsigned char **", but the converted allocation
> type would be "char **", whose elements point to a character type of a
> different signedness, so the two pointer types are not compatible.
> Take the size from the assignment target instead. No change in
> allocation size results.
Applied to 7.4/scsi-staging, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: hpsa: Make buff allocation type unsigned
2026-09-17 21:11 [PATCH] scsi: hpsa: Make buff allocation type unsigned Kees Cook
2026-09-26 2:35 ` Martin K. Petersen (Oracle)
@ 2026-10-06 2:44 ` Martin K. Petersen (Oracle)
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen (Oracle) @ 2026-10-06 2:44 UTC (permalink / raw)
To: Don Brace, Kees Cook
Cc: Martin K . Petersen, Kees Cook, James E.J. Bottomley, storagedev,
linux-scsi, linux-kernel, linux-hardening
On Thu, 17 Sep 2026 14:11:38 -0700, Kees Cook wrote:
> In preparation for converting the kmalloc family of allocators to the
> type-aware kmalloc_obj family, we need to make sure that the returned
> type from the allocation matches the type of the variable being
> assigned. (The kmalloc family returns "void *", which can be implicitly
> cast to any pointer type.)
>
> The assigned type is "unsigned char **", but the converted allocation
> type would be "char **", whose elements point to a character type of a
> different signedness, so the two pointer types are not compatible. Take
> the size from the assignment target instead. No change in allocation
> size results.
>
> [...]
Applied to 7.4/scsi-queue, thanks!
[1/1] scsi: hpsa: Make buff allocation type unsigned
https://git.kernel.org/mkp/scsi/c/d0105247ca7e
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-06 2:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-17 21:11 [PATCH] scsi: hpsa: Make buff allocation type unsigned Kees Cook
2026-09-26 2:35 ` Martin K. Petersen (Oracle)
2026-10-06 2:44 ` Martin K. Petersen (Oracle)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox