pgcache read: protect against reads past end of the vm object size
If uio_offset is past end of the object size, calculated resid is negative. Delegate handling this case to the locked read, as any other non-trivial situation. PR: 253158 Reported by: Harald Schmalzbauer <bugzilla.freebsd@omnilan.de> Tested by: cy Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
184c1b9439
commit
c61fae1475
@ -950,6 +950,10 @@ vn_read_from_obj(struct vnode *vp, struct uio *uio)
|
||||
#else
|
||||
vsz = atomic_load_64(&obj->un_pager.vnp.vnp_size);
|
||||
#endif
|
||||
if (uio->uio_offset >= vsz) {
|
||||
error = EJUSTRETURN;
|
||||
goto out;
|
||||
}
|
||||
if (uio->uio_offset + resid > vsz)
|
||||
resid = vsz - uio->uio_offset;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user