[patch] Broken RLIMIT_FSIZE handling in ZFS
Mateusz Guzik
mjguzik at gmail.com
Sat May 19 20:22:28 UTC 2012
Hello,
vn_rlimit_fsize takes uio->uio_offset and uio->uio_resid into account
when determining whether given write would exceed RLIMIT_FSIZE.
When APPEND flag is specified, ZFS updates uio->uio_offset to point to the
end of file.
But this happens after a call to vn_rlimit_fsize, so vn_rlimit_fsize check
can be rendered ineffective by thread that opens some file with O_APPEND
and lseeks below RLIMIT_FSIZE before calling write.
This fixes the problem for me:
http://student.agh.edu.pl/~mjguzik/patches/zfs-rlimit-fsize.patch
Slightly modified testcase stolen from pr standards/164793:
http://student.agh.edu.pl/~mjguzik/patches/writelimit.c
Without the patch this testacase will just finish by producing 80000 bytes
file on ZFS.
On UFS it gives the following output:
failed when adding 27 bytes after 59994 bytes (error: File too large)
Same happens on ZFS with the patch.
--
Mateusz Guzik <mjguzik gmail.com>
More information about the freebsd-fs
mailing list