On 2026-10-28T05:50:48, Ana Bobillo <[email protected]> wrote:
> ide: Refuse an ATAPI block size atapi_read() cannot read
>
> atapi_inquiry() takes the block size from the READ CAPACITY reply of an
> ATAPI device as it is, while atapi_read() asks the device for, and moves
> the buffer on by, ATAPI_READ_BLOCK_SIZE (2048) bytes for every block.
> With any other block size the callers' buffers, which are sized by
> blksz, do not match what atapi_read() writes into them: a 512-byte block
> size makes a read of several blocks write past the end of the buffer.
>
> Some CD drives report another block size although they read 2048-byte
> blocks: 2340 (HP 4020i CD-Recorder), 2352 (Philips CD-Writers) or 0.
> Take these as ATAPI_READ_BLOCK_SIZE, as Linux does in get_sectorsize(),
> so that a drive reporting 0, which ide_probe() skipped until now, is
> read with 2048-byte blocks too. Refuse any other value: a device
> reporting one is left with a zero block size, which ide_probe() skips,
> as for a drive without a medium. This refuses drives with 512-byte
> blocks, such as ZIP drives, whose reads of more than one block already
> overran the buffer; supporting them needs atapi_read() to use the block
> size of the device.
>
> Signed-off-by: Ana Bobillo <[email protected]>
>
>  drivers/block/ide.c | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <[email protected]>

Reply via email to