> vhost_scsi_handle_vq() moves pi_bytesout or pi_bytesin into the
> protection sgl and subtracts those bytes from exp_data_len. The length
> passed to TCM is still exp_data_len + prot_bytes.
>
> prot_bytes comes from virtio_scsi_cmd_req_pi. With
> VIRTIO_SCSI_F_T10_PI negotiated, vhost reads that header and does not
> check that the CDB is a READ or WRITE. sbc_check_prot() replaces
> data_length from the CDB only when the protect field is non-zero.
> target_cmd_size_check() leaves a write's data_length unchanged when the
> CDB size is smaller, so a command that does not get that replacement
> keeps a data_length larger than the data sgl.
>
> The KASAN report is a MODE SELECT whose header had pi_bytesout set.
> The data sgl held only the parameter list. spc_emulate_modeselect()
> walked data_length and read the next physical page.
> [ ... ]
> ret_from_fork
> ret_from_fork_asm
>
> Fixes: 9f977ef7b671 ("vhost-scsi: Include prot_bytes into expected data
> transfer length")
> Signed-off-by: Jia Jia <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review ยท
https://sashiko.dev/#/patchset/[email protected]?part=1