mirror of
https://github.com/torvalds/linux
synced 2024-09-06 18:01:05 +00:00
params: Use size_add() for kmalloc()
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>
This commit is contained in:
parent
fd0cd057a1
commit
0fc79cbc93
|
@ -11,6 +11,7 @@
|
||||||
#include <linux/moduleparam.h>
|
#include <linux/moduleparam.h>
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
|
#include <linux/overflow.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
#include <linux/security.h>
|
#include <linux/security.h>
|
||||||
|
@ -48,7 +49,7 @@ static void *kmalloc_parameter(unsigned int size)
|
||||||
{
|
{
|
||||||
struct kmalloced_param *p;
|
struct kmalloced_param *p;
|
||||||
|
|
||||||
p = kmalloc(sizeof(*p) + size, GFP_KERNEL);
|
p = kmalloc(size_add(sizeof(*p), size), GFP_KERNEL);
|
||||||
if (!p)
|
if (!p)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue