Project

General

Profile

Bug #5471

Offset validation in zvol_read and zvol_write off by one

Added by Steven Hartland almost 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
zfs - Zettabyte File System
Start date:
2014-12-23
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage
Gerrit CR:

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

zvol_uio_loffset.patch (1.02 KB) zvol_uio_loffset.patch Steven Hartland, 2014-12-23 09:10 AM

No data to display

Also available in: Atom PDF