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)
May 12 2024, 9:57 AM
Unknown Object (File)
Mar 18 2024, 4:30 PM
Unknown Object (File)
Feb 8 2024, 11:20 PM
Unknown Object (File)
Dec 23 2023, 2:18 AM
Unknown Object (File)
Dec 12 2023, 11:48 PM
Unknown Object (File)
Oct 28 2023, 1:35 AM
Unknown Object (File)
Sep 15 2023, 8:14 AM
Unknown Object (File)
Aug 14 2023, 11:28 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.