lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <17EC94B0A072C34B8DCF0D30AD16044A028EFC0B@BPXM09GP.gisp.nec.co.jp>
Date:   Tue, 11 Oct 2016 22:56:06 +0000
From:   Kosuke Tatsukawa <tatsu@...jp.nec.com>
To:     Mauro Carvalho Chehab <mchehab@...pensource.com>
CC:     Linux Media Mailing List <linux-media@...r.kernel.org>,
        "Mauro Carvalho Chehab" <mchehab@....samsung.com>,
        Mauro Carvalho Chehab <mchehab@...radead.org>,
        Andy Lutomirski <luto@...capital.net>,
        "Johannes Stezenbach" <js@...uxtv.org>,
        Jiri Kosina <jikos@...nel.org>,
        "Patrick Boettcher" <patrick.boettcher@...teo.de>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Andy Lutomirski <luto@...nel.org>,
        "Michael Krufky" <mkrufky@...uxtv.org>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        "jrg.otte@...il.com" <jrg.otte@...il.com>,
        Hans Verkuil <hans.verkuil@...co.com>,
        Wolfram Sang <wsa-dev@...g-engineering.com>
Subject: Re: [PATCH v2 28/31] cpia2_usb: don't use stack for DMA 

Hi,

> The USB control messages require DMA to work. We cannot pass
> a stack-allocated buffer, as it is not warranted that the
> stack would be into a DMA enabled area.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@....samsung.com>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@...pensource.com>
> ---
>  drivers/media/usb/cpia2/cpia2_usb.c | 32 +++++++++++++++++++++++++++++---
>  1 file changed, 29 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
> index 13620cdf0599..417d683b237d 100644
> --- a/drivers/media/usb/cpia2/cpia2_usb.c
> +++ b/drivers/media/usb/cpia2/cpia2_usb.c
> @@ -545,10 +545,19 @@ static void free_sbufs(struct camera_data *cam)
>  static int write_packet(struct usb_device *udev,
>  			u8 request, u8 * registers, u16 start, size_t size)
>  {
> +	unsigned char *buf;
> +	int ret;
> +
>  	if (!registers || size <= 0)
>  		return -EINVAL;
>  
> -	return usb_control_msg(udev,
> +	buf = kmalloc(size, GFP_KERNEL);
> +	if (!buf)
> +		return -ENOMEM;
> +
> +	memcpy(buf, registers, size);
> +
> +	ret = usb_control_msg(udev,
>  			       usb_sndctrlpipe(udev, 0),
>  			       request,
>  			       USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> @@ -557,6 +566,9 @@ static int write_packet(struct usb_device *udev,
>  			       registers,	/* buffer */
                               =========

I think you also want to change the argument to usb_control_msg() from
"registers" to "buf" in write_packet().


>  			       size,
>  			       HZ);
> +
> +	kfree(buf);
> +	return ret;
>  }
..
---
Kosuke TATSUKAWA  | 1st Platform Software Division
                  | NEC Solution Innovators
                  | tatsu@...jp.nec.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ