Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 May 2014 07:49:13 +0000 (UTC)
From:      Don Lewis <truckman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r266433 - stable/9/sys/kern
Message-ID:  <201405190749.s4J7nD9E017524@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: truckman
Date: Mon May 19 07:49:13 2014
New Revision: 266433
URL: http://svnweb.freebsd.org/changeset/base/266433

Log:
  MFC r265931
  
  Be even more paranoid about overflow.
  
  Requested by:	ache

Modified:
  stable/9/sys/kern/subr_rman.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/subr_rman.c
==============================================================================
--- stable/9/sys/kern/subr_rman.c	Mon May 19 07:49:09 2014	(r266432)
+++ stable/9/sys/kern/subr_rman.c	Mon May 19 07:49:13 2014	(r266433)
@@ -461,8 +461,8 @@ rman_reserve_resource_bound(struct rman 
 	}
 
 	amask = (1ul << RF_ALIGNMENT(flags)) - 1;
-	if (start + amask < start) {
-		DPRINTF(("start+amask wrapped around\n"));
+	if (start > ULONG_MAX - amask) {
+		DPRINTF(("start+amask would wrap around\n"));
 		goto out;
 	}
 
@@ -482,8 +482,8 @@ rman_reserve_resource_bound(struct rman 
 			    s->r_start, end));
 			break;
 		}
-		if (s->r_start + amask < s->r_start) {
-			DPRINTF(("s->r_start (%#lx) + amask (%#lx) wrapped\n",
+		if (s->r_start > ULONG_MAX - amask) {
+			DPRINTF(("s->r_start (%#lx) + amask (%#lx) too large\n",
 			    s->r_start, amask));
 			break;
 		}



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