From: FUJITA Tomonori 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 Acked-by: Borislav Petkov Cc: Bartlomiej Zolnierkiewicz Cc: Thomas Bogendoerfer Cc: Tejun Heo Cc: Jens Axboe Cc: James Bottomley Signed-off-by: Andrew Morton --- drivers/ide/ide-cd.c | 5 +++++ 1 file changed, 5 insertions(+) diff -puN drivers/ide/ide-cd.c~ide-avoid-dma-on-the-stack-for-req_type_ata_pc drivers/ide/ide-cd.c --- a/drivers/ide/ide-cd.c~ide-avoid-dma-on-the-stack-for-req_type_ata_pc +++ a/drivers/ide/ide-cd.c @@ -1195,6 +1195,7 @@ static ide_startstop_t cdrom_do_block_pc 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 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))) + info->dma = 0; } /* start sending the command to the drive */ _