Page MenuHomeFreeBSD

Handle int rank issues in in vn_getsize_locked() and vn_seek()
ClosedPublic

Authored by kib on Jan 20 2023, 6:52 AM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 29 2024, 3:26 PM
Unknown Object (File)
Nov 26 2024, 7:27 AM
Unknown Object (File)
Oct 31 2024, 8:14 PM
Unknown Object (File)
Oct 4 2024, 7:44 PM
Unknown Object (File)
Sep 30 2024, 9:22 AM
Unknown Object (File)
Sep 22 2024, 2:28 PM
Unknown Object (File)
Sep 19 2024, 5:53 AM
Unknown Object (File)
Sep 18 2024, 3:40 PM
Subscribers

Details

Summary
In vn_getsize_locked(), when storing vattr.va_size of type u_quad_t into
off_t size, we must avoid overflow.

Then, the check for fsize < 0, introduced in the commit
f45feecfb27ca51067d6789eaa43547cadc4990b 'vfs: add vn_getsize', is nop [1].

Reported by:    jhb
Coverity CID:   1502346

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Jan 20 2023, 6:52 AM
jhb added inline comments.
sys/kern/vfs_subr.c
7133

Is this something we can assert should never happen?

This revision is now accepted and ready to land.Jan 20 2023, 5:44 PM
kib marked an inline comment as done.Jan 20 2023, 9:44 PM
kib added inline comments.
sys/kern/vfs_subr.c
7133

Sane filesystem would not do that indeed, but we did not required this before, and allowed full u_quad_t. My concern with adding the assert is that it would be hard to reach, esp. in non-targeted testing, so the assert would be a ticking bomb.

I prefer to have the check and error return, due to this.

This revision was automatically updated to reflect the committed changes.
kib marked an inline comment as done.