git.samba.org
/
sfrench
/
cifs-2.6.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
fd0cd05
)
params: Use size_add() for kmalloc()
author
Andy Shevchenko
<andriy.shevchenko@linux.intel.com>
Mon, 20 Nov 2023 15:11:44 +0000
(17:11 +0200)
committer
Kees Cook
<keescook@chromium.org>
Fri, 1 Dec 2023 17:51:43 +0000
(09:51 -0800)
Prevent allocations from integer overflow by using size_add().
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link:
https://lore.kernel.org/r/20231120151419.1661807-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Kees Cook <keescook@chromium.org>
kernel/params.c
patch
|
blob
|
history
diff --git
a/kernel/params.c
b/kernel/params.c
index f8e3c413985407cd2ff8e6088172727605d6ef8c..c3a029fe183d33ca085ff8aaaef07d0622ad6e18 100644
(file)
--- a/
kernel/params.c
+++ b/
kernel/params.c
@@
-11,6
+11,7
@@
#include <linux/moduleparam.h>
#include <linux/device.h>
#include <linux/err.h>
+#include <linux/overflow.h>
#include <linux/slab.h>
#include <linux/ctype.h>
#include <linux/security.h>
@@
-48,7
+49,7
@@
static void *kmalloc_parameter(unsigned int size)
{
struct kmalloced_param *p;
- p = kmalloc(size
of(*p) + size
, GFP_KERNEL);
+ p = kmalloc(size
_add(sizeof(*p), size)
, GFP_KERNEL);
if (!p)
return NULL;