From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>,
Don Brace <don.brace@microchip.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
storagedev@microchip.com
Cc: linux-scsi@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org,
skhan@linuxfoundation.org, david.hunter.linux@gmail.com
Subject: Re: [PATCH] scsi: Use kmalloc_array to prevent overflow of dynamic size calculation
Date: Fri, 03 Oct 2025 10:53:05 -0400 [thread overview]
Message-ID: <7761904f64c554821e71e30b205e092fc2f8478e.camel@HansenPartnership.com> (raw)
In-Reply-To: <20251001113935.52596-1-bhanuseshukumar@gmail.com>
On Wed, 2025-10-01 at 17:09 +0530, Bhanu Seshu Kumar Valluri wrote:
> Use kmalloc_array to avoid potential overflow during dynamic size
> calculation inside kmalloc.
This description isn't correct.
>
> Signed-off-by: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
> ---
> drivers/scsi/smartpqi/smartpqi_init.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/smartpqi/smartpqi_init.c
> b/drivers/scsi/smartpqi/smartpqi_init.c
> index 125944941601..7ff39f1faf38 100644
> --- a/drivers/scsi/smartpqi/smartpqi_init.c
> +++ b/drivers/scsi/smartpqi/smartpqi_init.c
> @@ -8937,7 +8937,7 @@ static int pqi_host_alloc_mem(struct
> pqi_ctrl_info *ctrl_info,
> if (sg_count == 0 || sg_count > PQI_HOST_MAX_SG_DESCRIPTORS)
> goto out;
Given this check
>
> - host_memory_descriptor->host_chunk_virt_address =
> kmalloc(sg_count * sizeof(void *), GFP_KERNEL);
How is it possible that this allocation could ever overflow?
If you want to change the description to say using kmalloc_array is
better practice or something (and the maintainer concurs) that's fine,
but we can't have a false justification in the kernel git log.
Regards,
James
next prev parent reply other threads:[~2025-10-03 15:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-01 11:39 [PATCH] scsi: Use kmalloc_array to prevent overflow of dynamic size calculation Bhanu Seshu Kumar Valluri
2025-10-03 14:12 ` Don.Brace
2025-10-03 14:53 ` James Bottomley [this message]
2025-10-04 4:25 ` Bhanu Seshu Kumar Valluri
2025-10-06 11:28 ` Niklas Cassel
2025-10-07 6:18 ` Bhanu Seshu Kumar Valluri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7761904f64c554821e71e30b205e092fc2f8478e.camel@HansenPartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=bhanuseshukumar@gmail.com \
--cc=david.hunter.linux@gmail.com \
--cc=don.brace@microchip.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=skhan@linuxfoundation.org \
--cc=storagedev@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox