* [patch] orangefs: silence harmless integer overflow warning
@ 2017-01-21 5:04 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2017-01-21 5:04 UTC (permalink / raw)
To: Mike Marshall; +Cc: linux-kernel, kernel-janitors
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>
diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c
index 75375e9..6333cbb 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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-01-21 5:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-21 5:04 [patch] orangefs: silence harmless integer overflow warning Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox