public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: Oliver Neukum <oliver@neukum.org>
Cc: Boaz Harrosh <bharrosh@panasas.com>,
	axboe@kernel.dk,
	SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: memory allocation in sg_io()
Date: Thu, 10 Jan 2008 06:30:09 -0700	[thread overview]
Message-ID: <20080110133009.GB18741@parisc-linux.org> (raw)
In-Reply-To: <200801101419.09651.oliver@neukum.org>

On Thu, Jan 10, 2008 at 02:19:08PM +0100, Oliver Neukum wrote:
> Am Donnerstag, 10. Januar 2008 14:05:25 schrieb Boaz Harrosh:
> > On Thu, Jan 10 2008 at 14:33 +0200, Oliver Neukum <oliver@neukum.org> wrote:
> > > Hi,
> > > 
> > > could you explain to me why this code can get away with allocating the
> > > sense buffer on the stack?
> > > 
> > > static int sg_io(struct file *file, struct request_queue *q,
> > > 		struct gendisk *bd_disk, struct sg_io_hdr *hdr)
> > > {
> > > 	unsigned long start_time;
> > > 	int writing = 0, ret = 0, has_write_perm = 0;
> > > 	struct request *rq;
> > > 	char sense[SCSI_SENSE_BUFFERSIZE];
> 
> Yes, you are doing DMA on the stack.

Nobody does DMA to rq->sense.  ub does a memcpy to it.  cciss does a
memcpy to it.  scsi_lib assigns its own buffer to req->sense, ignoring
the one passed down.

That's how this code gets away with it.

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

      parent reply	other threads:[~2008-01-10 13:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-10 12:33 memory allocation in sg_io() Oliver Neukum
2008-01-10 13:05 ` Boaz Harrosh
2008-01-10 13:06   ` Jens Axboe
2008-01-10 13:14     ` Boaz Harrosh
2008-01-10 13:19   ` Oliver Neukum
2008-01-10 13:24     ` Jens Axboe
2008-01-10 13:30     ` Matthew Wilcox [this message]

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=20080110133009.GB18741@parisc-linux.org \
    --to=matthew@wil.cx \
    --cc=axboe@kernel.dk \
    --cc=bharrosh@panasas.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=oliver@neukum.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