Switch to unsigned arithmetic to handle overflow not relying on -fwrap, and specially treat the case of length == 0 from posix_fadvise() which passes OFF_MAX as the end to VOP. There, roundup() overflows and -fwrap causes bend and endn become negative. Clamp them at OFF_MAX/bsize instead. Also remove locals with single use, and move calculations from under bo lock. Reported by: tmunro
Details
Details
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
sys/kern/vfs_default.c | ||
---|---|---|
1122 |
sys/kern/vfs_default.c | ||
---|---|---|
1119 | I don't think we need this "Restore length" hunk. The round_page() call always just adds one to OFF_MAX (0x7fffffffffffffff -> 0x8000000000000000), so the change to uintmax_t is enough to make the existing endn = bend / bsize produce a correct positive answer. |