mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-09-21 15:52:39 +02:00
F_READAHEAD: Fix r349248's overflow protection, broken by r349391
I accidentally broke the main point of r349248 when making stylistic changes in r349391. Restore the original behavior, and also fix an additional overflow that was possible when uio->uio_resid was nearly SSIZE_MAX. Reported by: cem Reviewed by: bde MFC after: 2 weeks MFC-With: 349248 Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
0660822abb
commit
0122532ee0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=350088
@ -499,8 +499,13 @@ sequential_heuristic(struct uio *uio, struct file *fp)
|
||||
* closely related to the best I/O size for real disks than
|
||||
* to any block size used by software.
|
||||
*/
|
||||
fp->f_seqcount += lmin(IO_SEQMAX,
|
||||
howmany(uio->uio_resid, 16384));
|
||||
if (uio->uio_resid >= IO_SEQMAX * 16384)
|
||||
fp->f_seqcount = IO_SEQMAX;
|
||||
else {
|
||||
fp->f_seqcount += howmany(uio->uio_resid, 16384);
|
||||
if (fp->f_seqcount > IO_SEQMAX)
|
||||
fp->f_seqcount = IO_SEQMAX;
|
||||
}
|
||||
return (fp->f_seqcount << IO_SEQSHIFT);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user