提交 0b6abc17 编写于 作者: F FUJITA Tomonori 提交者: Bartlomiej Zolnierkiewicz

ide: avoid DMA on the stack for REQ_TYPE_ATA_PC

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: NFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: NBorislav Petkov <petkovbb@gmail.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Tejun Heo <htejun@gmail.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
上级 84e0f3f6
...@@ -1195,6 +1195,7 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) ...@@ -1195,6 +1195,7 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
int mask = drive->queue->dma_alignment; int mask = drive->queue->dma_alignment;
unsigned long addr = unsigned long addr =
(unsigned long)page_address(bio_page(rq->bio)); (unsigned long)page_address(bio_page(rq->bio));
unsigned long stack_mask = ~(THREAD_SIZE - 1);
info->dma = drive->using_dma; info->dma = drive->using_dma;
...@@ -1206,6 +1207,10 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) ...@@ -1206,6 +1207,10 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
*/ */
if ((rq->data_len & 15) || (addr & mask)) if ((rq->data_len & 15) || (addr & mask))
info->dma = 0; info->dma = 0;
if (!((addr & stack_mask) ^
((unsigned long)current->stack & stack_mask)))
info->dma = 0;
} }
/* start sending the command to the drive */ /* start sending the command to the drive */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册