mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jim Ramsay <jim.ramsay@gmail.com>
To: linux-usb-users@lists.sourceforge.net,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Possible bug in usb storage (2.6.11 kernel)
Date: Thu, 8 Sep 2005 11:14:36 -0600	[thread overview]
Message-ID: <4789af9e05090810142bd3531d@mail.gmail.com> (raw)

I think I have found a possible bug:

In usb/storage/transport.c, the routine usb_stor_Bulk_transport (and
perhaps other releated routines as well) has the following in the
"DATA STAGE" (around line 1020 in my file):

result = usb_stor_bulk_transfer_sg(us, pipe,
                                        srb->request_buffer, transfer_length,
                                        srb->use_sg, &srb->resid);

This looks fine, except that there is no guarantee that
srb->request_buffer is page-aligned or cache-aligned, as is required
according to Documentation/DMA-API.txt

In fact, on my MIPS platform, I sometimes get odd hangs and panics
because the later call to "dma_map_single" on this buffer causes a
cache invalidation, and since this memory is not necessarily
cache-aligned, sometimes too much cache is invalidated, which causes
interesting (and annoying) memory corruptions.  Usually I've seen it
change the 'request' pointer in us->current_urb to something slightly
different, or zero, depending on the system's mood, but I'm sure there
are other possible ugly side-effects of this.

The solution, as suggested by Documentation/DMA-API.txt is to ensure
that all buffers passed into dma_map_single are always cache-aligned
(or at least page-aligned).

I would suggest this should be fixed by using a new buffer allocated
by the usb storage layer and then copying the result back into the
srb->request_buffer.

I suppose the scsi code could be changed to guarantee that
srb->request_buffer is page-aligned or cache-aligned, but that seems
like the wrong solution for this bug.

Questions?  Comments?  Is this the right way to fix it?

-- 
Jim Ramsay
"Me fail English?  That's unpossible!"

             reply	other threads:[~2005-09-08 17:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-08 17:14 Jim Ramsay [this message]
2005-09-08 17:58 ` [Linux-usb-users] " Matthew Dharm
2005-09-08 19:52   ` Jim Ramsay
2005-09-08 20:28     ` Jim Ramsay
2005-09-08 20:40       ` Alan Stern
2005-09-27 13:38         ` Atsushi Nemoto
2005-09-27 14:21           ` Alan Stern
2005-09-27 14:46             ` Atsushi Nemoto
2005-09-27 15:38               ` Alan Stern
2005-09-28 16:27                 ` Atsushi Nemoto
2005-09-30 16:48                   ` Ralf Baechle
2005-09-08 20:43       ` Matthew Dharm

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=4789af9e05090810142bd3531d@mail.gmail.com \
    --to=jim.ramsay@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-users@lists.sourceforge.net \
    /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

Powered by JetHome