* [PATCH] vhost-scsi: Fix check for inline_sg_cnt exceeding preallocated limit
@ 2025-06-07 19:40 Alok Tiwari
2025-06-07 20:30 ` Mike Christie
2025-06-09 13:49 ` Stefan Hajnoczi
0 siblings, 2 replies; 3+ messages in thread
From: Alok Tiwari @ 2025-06-07 19:40 UTC (permalink / raw)
To: mst, jasowang, michael.christie, pbonzini, stefanha, eperezma,
virtualization, kvm
Cc: alok.a.tiwari, darren.kenny, netdev, linux-kernel
The condition comparing ret to VHOST_SCSI_PREALLOC_SGLS was incorrect,
as ret holds the result of kstrtouint() (typically 0 on success),
not the parsed value. Update the check to use cnt, which contains the
actual user-provided value.
prevents silently accepting values exceeding the maximum inline_sg_cnt.
Fixes: bca939d5bcd0 ("vhost-scsi: Dynamically allocate scatterlists")
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
drivers/vhost/scsi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index c12a0d4e6386..8d655b2d15d9 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -71,7 +71,7 @@ static int vhost_scsi_set_inline_sg_cnt(const char *buf,
if (ret)
return ret;
- if (ret > VHOST_SCSI_PREALLOC_SGLS) {
+ if (cnt > VHOST_SCSI_PREALLOC_SGLS) {
pr_err("Max inline_sg_cnt is %u\n", VHOST_SCSI_PREALLOC_SGLS);
return -EINVAL;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost-scsi: Fix check for inline_sg_cnt exceeding preallocated limit
2025-06-07 19:40 [PATCH] vhost-scsi: Fix check for inline_sg_cnt exceeding preallocated limit Alok Tiwari
@ 2025-06-07 20:30 ` Mike Christie
2025-06-09 13:49 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Mike Christie @ 2025-06-07 20:30 UTC (permalink / raw)
To: Alok Tiwari, mst, jasowang, pbonzini, stefanha, eperezma,
virtualization, kvm
Cc: darren.kenny, linux-kernel
On 6/7/25 2:40 PM, Alok Tiwari wrote:
> The condition comparing ret to VHOST_SCSI_PREALLOC_SGLS was incorrect,
> as ret holds the result of kstrtouint() (typically 0 on success),
> not the parsed value. Update the check to use cnt, which contains the
> actual user-provided value.
>
> prevents silently accepting values exceeding the maximum inline_sg_cnt.
>
> Fixes: bca939d5bcd0 ("vhost-scsi: Dynamically allocate scatterlists")
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
> ---
> drivers/vhost/scsi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> index c12a0d4e6386..8d655b2d15d9 100644
> --- a/drivers/vhost/scsi.c
> +++ b/drivers/vhost/scsi.c
> @@ -71,7 +71,7 @@ static int vhost_scsi_set_inline_sg_cnt(const char *buf,
> if (ret)
> return ret;
>
> - if (ret > VHOST_SCSI_PREALLOC_SGLS) {
> + if (cnt > VHOST_SCSI_PREALLOC_SGLS) {
> pr_err("Max inline_sg_cnt is %u\n", VHOST_SCSI_PREALLOC_SGLS);
> return -EINVAL;
> }
Thanks.
Reviewed-by: Mike Christie <michael.christie@oracle.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost-scsi: Fix check for inline_sg_cnt exceeding preallocated limit
2025-06-07 19:40 [PATCH] vhost-scsi: Fix check for inline_sg_cnt exceeding preallocated limit Alok Tiwari
2025-06-07 20:30 ` Mike Christie
@ 2025-06-09 13:49 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2025-06-09 13:49 UTC (permalink / raw)
To: Alok Tiwari
Cc: mst, jasowang, michael.christie, pbonzini, eperezma,
virtualization, kvm, darren.kenny, netdev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 665 bytes --]
On Sat, Jun 07, 2025 at 12:40:29PM -0700, Alok Tiwari wrote:
> The condition comparing ret to VHOST_SCSI_PREALLOC_SGLS was incorrect,
> as ret holds the result of kstrtouint() (typically 0 on success),
> not the parsed value. Update the check to use cnt, which contains the
> actual user-provided value.
>
> prevents silently accepting values exceeding the maximum inline_sg_cnt.
>
> Fixes: bca939d5bcd0 ("vhost-scsi: Dynamically allocate scatterlists")
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
> ---
> drivers/vhost/scsi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-09 13:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-07 19:40 [PATCH] vhost-scsi: Fix check for inline_sg_cnt exceeding preallocated limit Alok Tiwari
2025-06-07 20:30 ` Mike Christie
2025-06-09 13:49 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).