public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: sr: fix oob access in get_capabilities
@ 2017-03-03 10:17 Kefeng Wang
  2017-03-06  7:26 ` Kefeng Wang
  2017-03-16  0:07 ` Martin K. Petersen
  0 siblings, 2 replies; 8+ messages in thread
From: Kefeng Wang @ 2017-03-03 10:17 UTC (permalink / raw)
  To: Jens Axboe, James E.J. Bottomley, Martin K. Petersen
  Cc: linux-scsi, linux-kernel, Kefeng Wang

'n = header_length + block_descriptor_length' could be greater than 512,
and will lead to oob access, so enlarge transfer buffer to fix it.

===
BUG: KASAN: slab-out-of-bounds in sr_probe+0x570/0xcc0 at addr ffff88000009020e
Read of size 1 by task kworker/u48:2/188

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/scsi/sr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 0b29b93..5a80aa6 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -852,7 +852,7 @@ static void get_capabilities(struct scsi_cd *cd)
 
 
 	/* allocate transfer buffer */
-	buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
+	buffer = kmalloc(1024, GFP_KERNEL | GFP_DMA);
 	if (!buffer) {
 		sr_printk(KERN_ERR, cd, "out of memory.\n");
 		return;
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-03-21  2:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-03 10:17 [PATCH] scsi: sr: fix oob access in get_capabilities Kefeng Wang
2017-03-06  7:26 ` Kefeng Wang
2017-03-16  0:07 ` Martin K. Petersen
2017-03-16  5:21   ` Kefeng Wang
2017-03-17 23:29     ` Martin K. Petersen
2017-03-20  6:00       ` Kefeng Wang
2017-03-20 14:29         ` Martin K. Petersen
2017-03-21  2:20           ` Kefeng Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox