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>] [day] [month] [year] [list]
Message-ID: <CACTFLAM9sqCAQusGXuA6_JVGZvFKp8pOgb9mbEP_aEzt9b80Uw@mail.gmail.com>
Date:	Fri, 12 Aug 2011 17:56:38 +0200
From:	Daniel Mack <zonque@...il.com>
To:	Adam Cozzette <acozzette@...hmc.edu>
Cc:	Josh Boyer <jwboyer@...hat.com>,
	edwin_rong <edwin_rong@...lsil.com.cn>,
	wwang <wei_wang@...lsil.com.cn>,
	Greg Kroah-Hartman <gregkh@...e.de>, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: ums-realtek driver uses stack memory for DMA

On Tue, Aug 2, 2011 at 7:04 AM, Adam Cozzette <acozzette@...hmc.edu> wrote:

> drivers/usb/storage/realtek_cr.c:419:40: warning: ‘buf[0]’ may be used uninitialized in this function [-Wuninitialized]
>
> It think they are harmless but I didn't see an obvious way to get rid of them,
> so if you have any suggestions I would be glad to hear them.
>
> This patch changed rts51x_read_mem, rts51x_write_mem, and rts51x_read_status to
> allocate temporary buffers with kmalloc. This way stack addresses are not used
> for DMA when these functions call rts51x_bulk_transport.
>
> Signed-off-by: Adam Cozzette <acozzette@...hmc.edu>
> ---
>  realtek_cr.c |   35 ++++++++++++++++++++++++++++++-----
>  1 file changed, 30 insertions(+), 5 deletions(-)

[...]

> @@ -342,6 +351,12 @@ static int rts51x_write_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
>  {
>        int retval;
>        u8 cmnd[12] = { 0 };
> +       u8 *buf;
> +
> +       buf = kmalloc(len, GFP_NOIO);
> +       if (buf == NULL)
> +               return USB_STOR_TRANSPORT_ERROR;
> +       memcpy(buf, data, len);

Your can simplify this with kmemdup().
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ