lkml.org 
[lkml]   [2015]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] groups: integer underflow in groups_alloc()
This is called from rsc_parse() with a use controlled value.  Say for
example that "gidsetsize" is negative, then we could end up allocating
less than sizeof(struct group_info) leading to memory corruption.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I copied the NGROUPS_MAX limit from the surrounding code, I'm not
absolutely that it's the correct limit to use.

diff --git a/kernel/groups.c b/kernel/groups.c
index 664411f..e9341b3 100644
--- a/kernel/groups.c
+++ b/kernel/groups.c
@@ -18,6 +18,9 @@ struct group_info *groups_alloc(int gidsetsize)
int nblocks;
int i;

+ if ((unsigned)gidsetsize > NGROUPS_MAX)
+ return NULL;
+
nblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) / NGROUPS_PER_BLOCK;
/* Make sure we always allocate at least one indirect block pointer */
nblocks = nblocks ? : 1;

\
 
 \ /
  Last update: 2015-02-23 17:01    [W:0.089 / U:0.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site