Re: [PATCH v1] vhost-scsi: do not validate vrings during endpoint teardown
From: Yuho Choi
Date: Mon Nov 23 2026 - 00:23:19 EST
Thanks for the review!
On Sun, 8 Nov 2026 at 14:05, Mike Christie <michael.christie@xxxxxxxxxx> wrote:
>
> Can you describe the bug a little more?
>
> If we have done vhost_scsi_set_endpoint successfully, are you saying a later
> call to vhost_scsi_clear_endpoint could fail the. vhost_vq_access_ok check
> and not teardown the endpoint?
Yes, the first case is what I meant. Sorry for not explaining the
failure path in the commit message.
Since a543346b96a1 ("vhost-scsi: reject delayed virtqueue setup"), I/O
virtqueues that are not configured when SET_ENDPOINT is called remain
without a backend.
VHOST_SET_LOG_BASE validates the new log base only for virtqueues with
a backend. Therefore, an invalid log base can be stored in an inactive
virtqueue even when the ioctl returns -EFAULT. A subsequent
CLEAR_ENDPOINT then fails vhost_vq_access_ok() and skips teardown.
I reproduced this on current mainline (8dac6df92a2e) with KASAN, with
the following sequence:
VHOST_SET_OWNER
VHOST_SET_FEATURES(VHOST_F_LOG_ALL)
VHOST_SET_MEM_TABLE
Set up vq 0, 1, and 2 only
VHOST_SCSI_SET_ENDPOINT -> 0
VHOST_SET_LOG_BASE(kernel address) -> -EFAULT
VHOST_SCSI_CLEAR_ENDPOINT -> -EFAULT
close()
After close(), tpg->vhost_scsi still points to the freed vs. Linking
another LUN triggers a KASAN use-after-free in vhost_scsi_do_plug().
I also reproduced the in-flight command UAF described in the commit
message. A delayed READ completion after close() triggers KASAN in
vhost_scsi_release_cmd(). The READ has to be queued after the
VHOST_SET_LOG_BASE call, because device ioctls flush in-flight
commands.
With the patch applied, both reproductions complete without KASAN
reports, and endpoint teardown succeeds.
Without a successful SET_ENDPOINT, no command can start, so the second
scenario you mentioned is not what I meant.
I can share the reproducer and full KASAN reports if useful. I'll
include the failure sequence in v2.
Thanks