diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-01-21 06:04:45 +0100 |
---|---|---|
committer | Mike Marshall <hubcap@omnibond.com> | 2017-02-03 20:37:15 +0100 |
commit | eb82fbcf82965c18da11ada92b82f1400b36e0ad (patch) | |
tree | 6e40ff6afa5d91a42ec79f4a9390d304c0e7d547 /fs/orangefs | |
parent | Merge tag 'v4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/li... (diff) | |
download | linux-eb82fbcf82965c18da11ada92b82f1400b36e0ad.tar.xz linux-eb82fbcf82965c18da11ada92b82f1400b36e0ad.zip |
orangefs: silence harmless integer overflow warning
The issue here is that in orangefs_bufmap_alloc() we do:
bufmap->buffer_index_array =
kzalloc(DIV_ROUND_UP(bufmap->desc_count, BITS_PER_LONG), GFP_KERNEL);
If we choose a bufmap->desc_count like -31 then it means the
DIV_ROUND_UP ends up having an integer overflow. The result is that
kzalloc() returns the ZERO_SIZE_PTR and there is a static checker
warning.
But this bug is harmless because on the next lines we use ->desc_count
to do a kcalloc(). That has integer overflow checking built in so the
kcalloc() fails and we return an error code.
Anyway, it doesn't make sense to talk about negative sizes and blocking
them silences the static checker warning.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Diffstat (limited to 'fs/orangefs')
-rw-r--r-- | fs/orangefs/orangefs-bufmap.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c index 75375e90a63f..6333cbbdfef7 100644 --- a/fs/orangefs/orangefs-bufmap.c +++ b/fs/orangefs/orangefs-bufmap.c @@ -344,6 +344,11 @@ int orangefs_bufmap_initialize(struct ORANGEFS_dev_map_desc *user_desc) user_desc->size, user_desc->count); + if (user_desc->total_size < 0 || + user_desc->size < 0 || + user_desc->count < 0) + goto out; + /* * sanity check alignment and size of buffer that caller wants to * work with |