mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-19 21:21:09 +00:00
flex_array: convert element_nr formals to unsigned
It's problematic to allow signed element_nr's or total's to be passed as part of the flex array API. flex_array_alloc() allows total_nr_elements to be set to a negative quantity, which is obviously erroneous. flex_array_get() and flex_array_put() allows negative array indices in dereferencing an array part, which could address memory mapped before struct flex_array. The fix is to convert all existing element_nr formals to be qualified as unsigned. Existing checks to compare it to total_nr_elements or the max array size based on element_size need not be changed. Signed-off-by: David Rientjes <rientjes@google.com> Cc: Dave Hansen <dave@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
8e7ee27095
commit
b62e408c05
2 changed files with 19 additions and 15 deletions
|
@ -36,12 +36,14 @@ struct flex_array {
|
|||
.total_nr_elements = (total), \
|
||||
} } }
|
||||
|
||||
struct flex_array *flex_array_alloc(int element_size, int total, gfp_t flags);
|
||||
int flex_array_prealloc(struct flex_array *fa, int start, int end, gfp_t flags);
|
||||
struct flex_array *flex_array_alloc(int element_size, unsigned int total,
|
||||
gfp_t flags);
|
||||
int flex_array_prealloc(struct flex_array *fa, unsigned int start,
|
||||
unsigned int end, gfp_t flags);
|
||||
void flex_array_free(struct flex_array *fa);
|
||||
void flex_array_free_parts(struct flex_array *fa);
|
||||
int flex_array_put(struct flex_array *fa, int element_nr, void *src,
|
||||
int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
|
||||
gfp_t flags);
|
||||
void *flex_array_get(struct flex_array *fa, int element_nr);
|
||||
void *flex_array_get(struct flex_array *fa, unsigned int element_nr);
|
||||
|
||||
#endif /* _FLEX_ARRAY_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue