Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Jul 2019 17:01:07 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350088 - head/sys/kern
Message-ID:  <201907171701.x6HH17p9006383@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Wed Jul 17 17:01:07 2019
New Revision: 350088
URL: https://svnweb.freebsd.org/changeset/base/350088

Log:
  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

Modified:
  head/sys/kern/vfs_vnops.c

Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c	Wed Jul 17 16:52:25 2019	(r350087)
+++ head/sys/kern/vfs_vnops.c	Wed Jul 17 17:01:07 2019	(r350088)
@@ -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);
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907171701.x6HH17p9006383>