diff options
author | Bryan Cantrill <bryan@joyent.com> | 2012-09-12 10:54:28 -0400 |
---|---|---|
committer | Bryan Cantrill <bryan@joyent.com> | 2012-09-12 10:54:28 -0400 |
commit | 0ee475b2786654da9595a3fd630076f6521c6fb0 (patch) | |
tree | 962e4b4cf9b9a739a1c03cb404d02027110e7968 /usr/src | |
parent | fe7cd8aa86d5ba3fb4aa1d5fee460467fd4413c9 (diff) | |
download | illumos-joyent-0ee475b2786654da9595a3fd630076f6521c6fb0.tar.gz |
3179 vmem_xalloc needs to check for overflow
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/uts/common/os/vmem.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/usr/src/uts/common/os/vmem.c b/usr/src/uts/common/os/vmem.c index 056deed958..6946a35a38 100644 --- a/usr/src/uts/common/os/vmem.c +++ b/usr/src/uts/common/os/vmem.c @@ -25,6 +25,7 @@ /* * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2012, Joyent, Inc. All rights reserved. */ /* @@ -1065,6 +1066,21 @@ do_alloc: aneeded = MAX(size + aphase, vmp->vm_min_import); asize = P2ROUNDUP(aneeded, aquantum); + if (asize < size) { + /* + * The rounding induced overflow; return NULL + * if we are permitted to fail the allocation + * (and explicitly panic if we aren't). + */ + if ((vmflag & VM_NOSLEEP) && + !(vmflag & VM_PANIC)) { + mutex_exit(&vmp->vm_lock); + return (NULL); + } + + panic("vmem_xalloc(): size overflow"); + } + /* * Determine how many segment structures we'll consume. * The calculation must be precise because if we're |