Re: [PATCH v2] rust: dma: return zero for Coherent reads past EOF

From: Alexandre Courbot

Date: Sat Aug 01 2026 - 02:02:41 EST


On Fri Jul 31, 2026 at 1:34 AM JST, Younes Akhouayri via B4 Relay wrote:
> From: Younes Akhouayri <git@xxxxxxxxx>
>
> Coherent<T>::write_to_slice() calculates a zero-byte copy when the file
> offset is beyond the allocation, but still calls
> UserSliceWriter::write_dma(). The latter rejects offsets beyond the
> allocation even when the copy length is zero, so a debugfs read past EOF
> returns -ERANGE.
>
> Return before calling write_dma() when the offset is at or beyond the
> allocation, matching simple_read_from_buffer() EOF semantics.
>
> Fixes: 016818513936 ("rust: dma: implement BinaryWriter for Coherent<[u8]>")
> Cc: stable@xxxxxxxxxxxxxxx
> Link: https://rust-for-linux.zulipchat.com/#narrow/channel/291566-Library/topic/.E2.9C.94.20Possible.20past-EOF.20bug.20in.20Coherent.3CT.3E.3A.3Awrite_to_slice/near/611677095
> Signed-off-by: Younes Akhouayri <git@xxxxxxxxx>

Reviewed-by: Alexandre Courbot <acourbot@xxxxxxxxxx>