Bug #5471
openOffset validation in zvol_read and zvol_write off by one
0%
Description
The checks against uio_loffset in zvol_read and zvol_write are off by one, they should be uio_loffset > volsize instead of uio_loffset >= volsize.
The issue can be seen from a dd e.g.
zfs create -V 8192 tank/tvol
dd if=/dev/zero of=/dev/zvol/rdsk/tank/tvol
dd: writing to ?/dev/zvol/rdsk/tank/tvol?: I/O error
17+0 records in
16+0 records out
8192 bytes (8.2 kB) copied, 0.195952 s, 41.8 kB/s
Similar happens on read.
This was originally fixed by mav in FreeBSD by https://svnweb.freebsd.org/base?view=revision&revision=264145
The attached patch fixes this issue resulting in the correct behaviour:
dd if=/dev/zero of=/dev/zvol/rdsk/tank/tvol
dd: /dev/zvol/tank/tvol: end of device
17+0 records in
16+0 records out
8192 bytes transferred in 0.002732 secs (2998963 bytes/sec)
dd if=/dev/zvol/rdsk/tank/tvol of=/dev/null bs=16384
0+1 records in
0+1 records out
8192 bytes transferred in 0.000041 secs (198199942 bytes/sec)
Files
Updated by F. H. almost 2 years ago
Can't reproduce error from description with current OpenZFS release. Could be closed. zvol code changed a lot since 2014