From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org,
jens.axboe@oracle.com, tsbogend@alpha.franken.de,
bzolnier@gmail.com, petkovbb@gmail.com, jeff@garzik.org,
davem@davemloft.net, akpm@linux-foundation.org,
linux-arch@vger.kernel.org, Roman Zippel <zippel@linux-m68k.org>
Subject: Re: [PATCH v2 -mm 4/6] ide: avoid DMA on the stack for REQ_TYPE_ATA_PC
Date: Thu, 05 Jun 2008 11:10:48 -0500 [thread overview]
Message-ID: <1212682248.13549.48.camel@localhost.localdomain> (raw)
In-Reply-To: <1212389852-1277-5-git-send-email-fujita.tomonori@lab.ntt.co.jp>
On Mon, 2008-06-02 at 15:57 +0900, FUJITA Tomonori wrote:
> Some REQ_TYPE_ATA_PC commands uses the stack buffers for DMA, which
> leads to memory corruption on a non-coherent platform.
>
> With regard to alignment and padding, ide-cd has the the dma safe
> check for sg requests and REQ_TYPE_ATA_PC. This adds the stack buffer
> check to that check.
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> Cc: Borislav Petkov <petkovbb@gmail.com>
> Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> ---
> drivers/ide/ide-cd.c | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
> index e3f085c..e12d602 100644
> --- a/drivers/ide/ide-cd.c
> +++ b/drivers/ide/ide-cd.c
> @@ -1195,6 +1195,7 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
> struct request_queue *q = drive->queue;
> unsigned int alignment;
> unsigned long addr;
> + unsigned long stack_mask = ~(THREAD_SIZE - 1);
>
> if (rq->bio)
> addr = (unsigned long)bio_data(rq->bio);
> @@ -1212,6 +1213,10 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
> alignment = queue_dma_alignment(q) | q->dma_pad_mask;
> if (addr & alignment || rq->data_len & alignment)
> info->dma = 0;
> +
> + if (!((addr & stack_mask) ^
> + ((unsigned long)current->stack & stack_mask)))
That can basically become
if ((addr & stack_mask) == ((unsigned long)current->stack & stack_mask))
to be a bit clearer, can't it?
I'm also not keen on the use of current->stack. It looks like this
commit:
commit f7e4217b007d1f73e7e3cf10ba4fea4a608c603f
Author: Roman Zippel <zippel@linux-m68k.org>
Date: Wed May 9 02:35:17 2007 -0700
rename thread_info to stack
Introduced a task_stack_page() accessor to get this instead, so perhaps
we should use it (I've cc'd Roman and linux-arch for opinions).
> + info->dma = 0;
> }
>
> /* start sending the command to the drive */
James
next prev parent reply other threads:[~2008-06-05 16:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-02 6:57 [PATCH v2 -mm 0/6] revert the commit 22a9189f (cdrom: use kmalloced buffers instead of buffers on stack) FUJITA Tomonori
2008-06-02 6:57 ` [PATCH v2 -mm 1/6] block: add blk_queue_update_dma_pad FUJITA Tomonori
2008-06-02 6:57 ` [PATCH v2 -mm 2/6] ide: use the dma safe check for REQ_TYPE_ATA_PC FUJITA Tomonori
2008-06-02 6:57 ` [PATCH v2 -mm 3/6] block: blk_rq_map_kern uses the bounce buffers for stack buffers FUJITA Tomonori
2008-06-02 6:57 ` [PATCH v2 -mm 4/6] ide: avoid DMA on the stack for REQ_TYPE_ATA_PC FUJITA Tomonori
2008-06-02 6:57 ` [PATCH v2 -mm 5/6] scsi: sr avoids useless buffer allocation FUJITA Tomonori
2008-06-02 6:57 ` [PATCH v2 -mm 6/6] cdrom: revert commit 22a9189 (cdrom: use kmalloced buffers instead of buffers on stack) FUJITA Tomonori
2008-06-02 19:14 ` [PATCH v2 -mm 4/6] ide: avoid DMA on the stack for REQ_TYPE_ATA_PC Borislav Petkov
2008-06-05 16:10 ` James Bottomley [this message]
2008-06-05 19:14 ` Borislav Petkov
2008-06-07 4:45 ` FUJITA Tomonori
2008-06-09 17:44 ` Roman Zippel
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=1212682248.13549.48.camel@localhost.localdomain \
--to=james.bottomley@hansenpartnership.com \
--cc=akpm@linux-foundation.org \
--cc=bzolnier@gmail.com \
--cc=davem@davemloft.net \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=jeff@garzik.org \
--cc=jens.axboe@oracle.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=petkovbb@gmail.com \
--cc=tsbogend@alpha.franken.de \
--cc=zippel@linux-m68k.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