Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1603684

Re: [PATCH] scsi: sr: fix oob access in get_capabilities

From "Martin K. Petersen" <martin.petersen@oracle.com>
Newsgroups linux.kernel
Subject Re: [PATCH] scsi: sr: fix oob access in get_capabilities
Date 2017-03-18 02:00 +0100
Message-ID <tmaSR-6Db-15@gated-at.bofh.it> (permalink)
References <tgSDg-8hC-11@gated-at.bofh.it> <tlr9o-6R3-9@gated-at.bofh.it> <tlw93-1WG-13@gated-at.bofh.it>
Organization Oracle Corporation

Show all headers | View raw


Kefeng Wang <wangkefeng.wang@huawei.com> writes:

Kefeng,

> root@localhost ~]# sg_modes -p 0x2a /dev/sr0
>     QEMU      QEMU DVD-ROM      0.15   peripheral_type: cd/dvd [0x5]
> Mode parameter header from MODE SENSE(10):
> Invalid block descriptor length=512, ignore
>   Mode data length=36, medium type=0x70, specific param=0x00, longlba=0
>   Block descriptor length=0
>>> MM capabilities and mechanical status (obsolete), page_control: current
>  00     2a 12 00 00 71 60 29 00  02 c2 00 02 02 00 02 c2
>  10     00 00 00 00
> Unexpectedly received extra mode page responses, ignore

That looks pretty broken.

Could you try the following patch?

Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index f41e6b84a1bd..51a4ce094450 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2485,6 +2485,10 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 		goto retry;
 	}
 
+	if (data->length > len ||
+	    data->header_length + data->block_descriptor_length > data->length)
+		return 0;
+
 	return result;
 }
 EXPORT_SYMBOL(scsi_mode_sense);

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] scsi: sr: fix oob access in get_capabilities "Martin K. Petersen" <martin.petersen@oracle.com> - 2017-03-16 01:10 +0100
  Re: [PATCH] scsi: sr: fix oob access in get_capabilities Kefeng Wang <wangkefeng.wang@huawei.com> - 2017-03-16 06:30 +0100
    Re: [PATCH] scsi: sr: fix oob access in get_capabilities "Martin K. Petersen" <martin.petersen@oracle.com> - 2017-03-18 02:00 +0100
      Re: [PATCH] scsi: sr: fix oob access in get_capabilities Kefeng Wang <wangkefeng.wang@huawei.com> - 2017-03-20 07:10 +0100
        Re: [PATCH] scsi: sr: fix oob access in get_capabilities "Martin K. Petersen" <martin.petersen@oracle.com> - 2017-03-20 15:30 +0100
          Re: [PATCH] scsi: sr: fix oob access in get_capabilities Kefeng Wang <wangkefeng.wang@huawei.com> - 2017-03-21 03:40 +0100

csiph-web