All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: Alok Tiwari <alok.a.tiwari@oracle.com>,
	mst@redhat.com, jasowang@redhat.com, pbonzini@redhat.com,
	stefanha@redhat.com, eperezma@redhat.com,
	virtualization@lists.linux.dev, kvm@vger.kernel.org
Cc: darren.kenny@oracle.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vhost-scsi: Fix check for inline_sg_cnt exceeding preallocated limit
Date: Sat, 7 Jun 2025 15:30:24 -0500	[thread overview]
Message-ID: <6a6fee3e-989f-4259-a753-ecee3fddfa38@oracle.com> (raw)
In-Reply-To: <20250607194103.1770451-1-alok.a.tiwari@oracle.com>

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>

  reply	other threads:[~2025-06-07 20:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2025-06-09 13:49 ` Stefan Hajnoczi

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=6a6fee3e-989f-4259-a753-ecee3fddfa38@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=alok.a.tiwari@oracle.com \
    --cc=darren.kenny@oracle.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.