get_map_ranges: check for overflow
The kernel accepts u32 values, so make sure that userspace is not passing large values. Signed-off-by: Serge Hallyn <serge@hallyn.com>
This commit is contained in:
parent
9bf01bf010
commit
7f5a14817d
@ -83,6 +83,16 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
|
||||
free(mappings);
|
||||
return NULL;
|
||||
}
|
||||
if (mapping->upper > UINT_MAX ||
|
||||
mapping->lower > UINT_MAX ||
|
||||
mapping->count > UINT_MAX) {
|
||||
free(mappings);
|
||||
return NULL;
|
||||
}
|
||||
if (mapping->lower + mapping->count < mapping->lower) {
|
||||
free(mapping);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user