Re: [PATCH v3] ata: libata-scsi: reject data-in commands with a data-out buffer

From: Niklas Cassel

Date: Sat Nov 07 2026 - 08:37:50 EST


On Wed, 04 Nov 2026 21:06:38 +0800, Zhao Gongyi wrote:
> SG_IO can submit a data-in SCSI command with DMA_TO_DEVICE. The
> scatterlist can then contain pages pinned without write access.
> ata_scsi_rbuf_fill() writes simulated replies to that scatterlist;
> in the reported case, the copy tried to write the shared zero page
> and faulted in the kernel.
>
> The same mismatch can affect SG_IO commands translated by libata.
> ZBC IN and GET PHYSICAL ELEMENT STATUS completion handlers can modify
> the receive buffer even if the drive aborts the command. For ATAPI,
> the successful INQUIRY completion also rewrites the buffer in
> atapi_fixup_inquiry().
>
> [...]

Applied to libata/linux.git (for-7.4-fixes), thanks!

[1/1] ata: libata-scsi: reject data-in commands with a data-out buffer
https://git.kernel.org/libata/linux/c/a4845f07

Kind regards,
Niklas