netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Neukum <oliver@neukum.org>
To: Peter Korsgaard <jacmet@sunsite.dk>
Cc: jeff@garzik.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH RESEND] dm9601: don't do usb transfers of data on stack
Date: Fri, 11 Jul 2008 14:22:55 +0200	[thread overview]
Message-ID: <200807111422.56406.oliver@neukum.org> (raw)
In-Reply-To: <87vdzcehs9.fsf@macbook.be.48ers.dk>

Am Freitag 11 Juli 2008 14:17:58 schrieb Peter Korsgaard:
> >>>>> "Oliver" == Oliver Neukum <oliver@neukum.org> writes:
> 
>  >> dm_{read,write}_shared_word() were doing USB transfers of data on stack,
>  >> which isn't allowed. Fix it by using the usbnet->data area like in
>  >> dm9601_set_multicast().
> 
>  Oliver> You cannot do this. You've identified the bug correctly, but
>  Oliver> the fix is incorrect. Doing DMA on non coherent architectures
>  Oliver> means that any cacheline the buffer shares must not be
>  Oliver> touched while DMA may be running. If you embed the buffer
>  Oliver> into struct usbnet, how could you meet the guarantee?
> 
> Ahh. So kmalloc() / kfree() around the usb_control_msg isn dm_read /
> dm_write is the way to go?

The buffer should be allocated with kmalloc. That doesn't mean it has to
be allocated each time the function is called. If several drivers do this, the
best fix is to modify struct usbnet so that it contains only a pointer to the
buffer, not the buffer itself and modify drivers accordingly.

	Regards
		Oliver

  reply	other threads:[~2008-07-11 12:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-11 11:37 [PATCH RESEND] dm9601: don't do usb transfers of data on stack Peter Korsgaard
     [not found] ` <87mykoircs.fsf-uXGAPMMVk8amE9MCos8gUmSdvHPH+/yF@public.gmane.org>
2008-07-11 12:00   ` Oliver Neukum
     [not found]     ` <200807111400.38312.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-07-11 12:17       ` Peter Korsgaard
2008-07-11 12:22         ` Oliver Neukum [this message]
     [not found]           ` <200807111422.56406.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
2008-07-11 12:55             ` Peter Korsgaard
2008-07-11 12:57           ` Peter Korsgaard
     [not found]             ` <87mykoefy4.fsf-uXGAPMMVk8amE9MCos8gUmSdvHPH+/yF@public.gmane.org>
2008-07-11 22:02               ` David Brownell
     [not found]                 ` <200807111502.20507.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-07-14  7:07                   ` Peter Korsgaard
     [not found]                     ` <87wsjp9c5n.fsf-uXGAPMMVk8amE9MCos8gUmSdvHPH+/yF@public.gmane.org>
2008-07-30  8:48                       ` Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200807111422.56406.oliver@neukum.org \
    --to=oliver@neukum.org \
    --cc=jacmet@sunsite.dk \
    --cc=jeff@garzik.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).