summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2014-05-12 20:22:42 +0000
committertruckman <truckman@FreeBSD.org>2014-05-12 20:22:42 +0000
commitc9657637056025235092a022adfb75861f0d396e (patch)
tree877c7e8eaff7e8078d3435e14d4c65f53ae93f29 /sys/kern
parentbbaed970627ed6335b71de3e454d98d4709ccbe4 (diff)
downloadFreeBSD-src-c9657637056025235092a022adfb75861f0d396e.zip
FreeBSD-src-c9657637056025235092a022adfb75861f0d396e.tar.gz
Be even more paranoid about overflow.
Requested by: ache
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_rman.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index b53030a..4101c86 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -466,8 +466,8 @@ rman_reserve_resource_bound(struct rman *rm, u_long start, u_long end,
}
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;
}
@@ -487,8 +487,8 @@ rman_reserve_resource_bound(struct rman *rm, u_long start, u_long end,
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;
}
OpenPOWER on IntegriCloud