Skip to contentSkip to conversation

libata: zpodd: Fix small read overflow in zpodd_get_mech_type()

PATCH Applied Kees Cook 3 participants 5 messages Jul 29, 2019 – Jul 30, 2019 libata

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH v2 1/1 libata: zpodd: Fix small read overflow in zpodd_get_mech_type()

Jeffrin reported a KASAN issue:

  BUG: KASAN: global-out-of-bounds in ata_exec_internal_sg+0x50f/0xc70
  Read of size 16 at addr ffffffff91f41f80 by task scsi_eh_1/149
  ...
  The buggy address belongs to the variable:                 
    cdb.48319+0x0/0x40                                        

Much like commit 18c9a99bce2a ("libata: zpodd: small read overflow in eject_tray()"), this fixes a cdb[] buffer length, this time in zpodd_get_mech_type():

We read from the cdb[] buffer in ata_exec_internal_sg(). It has to be ATAPI_CDB_LEN (16) bytes long, but this buffer is only 12 bytes.

---
v2: added reported/tested-by and direct to Jens

---
 drivers/ata/libata-zpodd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-zpodd.c +1 -1
index 173e6f2dd9af..eefda51f97d3 100644
@@ -56,7 +56,7 @@ static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev)
 	unsigned int ret;
 	struct rm_feature_desc *desc;
 	struct ata_taskfile tf;
-	static const char cdb[] = {  GPCMD_GET_CONFIGURATION,
+	static const char cdb[ATAPI_CDB_LEN] = {  GPCMD_GET_CONFIGURATION,
 			2,      /* only 1 feature descriptor requested */
 			0, 3,   /* 3, removable medium feature */
 			0, 0, 0,/* reserved */
Signature · 5 lines
2.17.1


-- 
Kees Cook
Applied
#1 lore raw
Quoted 8 lines · Kees Cook

Jeffrin reported a KASAN issue:

   BUG: KASAN: global-out-of-bounds in ata_exec_internal_sg+0x50f/0xc70
   Read of size 16 at addr ffffffff91f41f80 by task scsi_eh_1/149
   ...
   The buggy address belongs to the variable:
     cdb.48319+0x0/0x40
Quoted 6 lines

Much like commit 18c9a99bce2a ("libata: zpodd: small read overflow in eject_tray()"), this fixes a cdb[] buffer length, this time in zpodd_get_mech_type():

We read from the cdb[] buffer in ata_exec_internal_sg(). It has to be ATAPI_CDB_LEN (16) bytes long, but this buffer is only 12 bytes.

Applied, thanks.

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 10 lines · Jens Axboe
Quoted 8 lines · Kees Cook

Jeffrin reported a KASAN issue:

   BUG: KASAN: global-out-of-bounds in ata_exec_internal_sg+0x50f/0xc70
   Read of size 16 at addr ffffffff91f41f80 by task scsi_eh_1/149
   ...
   The buggy address belongs to the variable:
     cdb.48319+0x0/0x40
Quoted 8 lines
Quoted 6 lines

Much like commit 18c9a99bce2a ("libata: zpodd: small read overflow in eject_tray()"), this fixes a cdb[] buffer length, this time in zpodd_get_mech_type():

We read from the cdb[] buffer in ata_exec_internal_sg(). It has to be ATAPI_CDB_LEN (16) bytes long, but this buffer is only 12 bytes.

Applied, thanks.

Dropped my reviewed by tag. :(
https://lkml.org/lkml/2019/7/22/865

Signature · 2 lines
Thanks,
~Nick Desaulniers
#3 lore raw
Quoted 15 lines · Nick Desaulniers
Quoted 14 lines · Jens Axboe
Quoted 12 lines · Kees Cook

Jeffrin reported a KASAN issue:

    BUG: KASAN: global-out-of-bounds in ata_exec_internal_sg+0x50f/0xc70
    Read of size 16 at addr ffffffff91f41f80 by task scsi_eh_1/149
    ...
    The buggy address belongs to the variable:
      cdb.48319+0x0/0x40

Much like commit 18c9a99bce2a ("libata: zpodd: small read overflow in eject_tray()"), this fixes a cdb[] buffer length, this time in zpodd_get_mech_type():

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

We read from the cdb[] buffer in ata_exec_internal_sg(). It has to be ATAPI_CDB_LEN (16) bytes long, but this buffer is only 12 bytes.

Applied, thanks.

Dropped my reviewed by tag. :(
https://lkml.org/lkml/2019/7/22/865

I'll add it.

Signature · 1 line
Jens Axboe
author
#4 lore raw
Quoted 16 lines · Jens Axboe
Quoted 15 lines · Nick Desaulniers
Quoted 14 lines · Jens Axboe
Quoted 12 lines · Kees Cook

Jeffrin reported a KASAN issue:

    BUG: KASAN: global-out-of-bounds in ata_exec_internal_sg+0x50f/0xc70
    Read of size 16 at addr ffffffff91f41f80 by task scsi_eh_1/149
    ...
    The buggy address belongs to the variable:
      cdb.48319+0x0/0x40

Much like commit 18c9a99bce2a ("libata: zpodd: small read overflow in eject_tray()"), this fixes a cdb[] buffer length, this time in zpodd_get_mech_type():

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

We read from the cdb[] buffer in ata_exec_internal_sg(). It has to be ATAPI_CDB_LEN (16) bytes long, but this buffer is only 12 bytes.

Applied, thanks.

Dropped my reviewed by tag. :(
https://lkml.org/lkml/2019/7/22/865

Argh, sorry!

Quoted 1 line

I'll add it.

Thanks! :)

Signature · 1 line
Kees Cook