[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <34b8a5c3-d71a-3aba-c2ae-2b0a2798361c@embeddedor.com>
Date: Thu, 23 Aug 2018 12:42:27 -0500
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH] usb: iowarrior: replace kmalloc with kmalloc_array
Hi,
Please, drop this.
I'll align GFP_KERNEL and send v2.
Thanks
--
Gustavo
On 8/23/18 12:31 PM, Gustavo A. R. Silva wrote:
> A common flaw in the kernel is integer overflow during memory allocation
> size calculations. In an effort to reduce the frequency of these bugs,
> kmalloc_array was implemented, which allocates memory for an array,
> while at the same time detects integer overflow.
>
> This patch replaces cases of:
>
> kmalloc(a * b, gfp)
>
> with:
> kmalloc_array(a * b, gfp)
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@...eddedor.com>
> ---
> drivers/usb/misc/iowarrior.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
> index c2991b8..7a22400 100644
> --- a/drivers/usb/misc/iowarrior.c
> +++ b/drivers/usb/misc/iowarrior.c
> @@ -808,7 +808,7 @@ static int iowarrior_probe(struct usb_interface *interface,
> dev->int_in_endpoint->bInterval);
> /* create an internal buffer for interrupt data from the device */
> dev->read_queue =
> - kmalloc(((dev->report_size + 1) * MAX_INTERRUPT_BUFFER),
> + kmalloc_array(dev->report_size + 1, MAX_INTERRUPT_BUFFER,
> GFP_KERNEL);
> if (!dev->read_queue)
> goto error;
>
Powered by blists - more mailing lists