mbox series

[v3,0/3] Fixes for scsi_mode_sense/select()

Message ID 20210820070255.682775-1-damien.lemoal@wdc.com
Headers show
Series Fixes for scsi_mode_sense/select() | expand

Message

Damien Le Moal Aug. 20, 2021, 7:02 a.m. UTC
The first patch in this series is the formet standalone patch titled
"scsi: fix scsi_mode_sense()". Patch 2 fixes similar buffer length
handling problems found in scsi_mode_select().
Patch 3 fixes the use of scsi_mode_sense() in sd.c to ensure that calls
are issued with a sensible buffer size for devices that explicitly
requested the use of MODE SENSE 10 (e.g. SATA drives on AHCI).

Changes from v2:
* Added patch 3

Changes from v1:
* Patch 1:
  - Added check on the buffer length not being larger than 65535 bytes
    for the MODE SENSE 10 case.
  - Automatically try MODE SENSE 10 for large requests even if the
    device does not have use_10_for_ms set
* Added patch 2

Damien Le Moal (3):
  scsi: fix scsi_mode_sense() buffer length handling
  scsi: fix scsi_mode_select() buffer length handling
  scsi: sd: fix sd_do_mode_sense() buffer length handling

 drivers/scsi/scsi_lib.c | 46 +++++++++++++++++++++++++----------------
 drivers/scsi/sd.c       |  7 +++++++
 2 files changed, 35 insertions(+), 18 deletions(-)

Comments

Martin K. Petersen Sept. 29, 2021, 4:15 a.m. UTC | #1
Damien,

> The first patch in this series is the formet standalone patch titled

> "scsi: fix scsi_mode_sense()". Patch 2 fixes similar buffer length

> handling problems found in scsi_mode_select().

> Patch 3 fixes the use of scsi_mode_sense() in sd.c to ensure that calls

> are issued with a sensible buffer size for devices that explicitly

> requested the use of MODE SENSE 10 (e.g. SATA drives on AHCI).


Applied to 5.16/scsi-staging with some changes. There was some confusion
between SENSE vs. SELECT in patch #2 in particular.

I tried to clean up the dbd situation a while back but it fell by the
wayside:

https://lore.kernel.org/all/20200325222416.5094-1-martin.petersen@oracle.com/

-- 
Martin K. Petersen	Oracle Linux Engineering
Damien Le Moal Sept. 29, 2021, 6:02 a.m. UTC | #2
On 2021/09/29 13:15, Martin K. Petersen wrote:
> 
> Damien,
> 
>> The first patch in this series is the formet standalone patch titled
>> "scsi: fix scsi_mode_sense()". Patch 2 fixes similar buffer length
>> handling problems found in scsi_mode_select().
>> Patch 3 fixes the use of scsi_mode_sense() in sd.c to ensure that calls
>> are issued with a sensible buffer size for devices that explicitly
>> requested the use of MODE SENSE 10 (e.g. SATA drives on AHCI).
> 
> Applied to 5.16/scsi-staging with some changes. There was some confusion
> between SENSE vs. SELECT in patch #2 in particular.
> 
> I tried to clean up the dbd situation a while back but it fell by the
> wayside:
> 
> https://lore.kernel.org/all/20200325222416.5094-1-martin.petersen@oracle.com/

This one looks good to me. Repost it may be ?
I have more patches coming around mode sense to be able to handle sub-pages
(command duration limits and the new ata feature set subpages of the control page).
Martin K. Petersen Oct. 5, 2021, 4:34 a.m. UTC | #3
On Fri, 20 Aug 2021 16:02:52 +0900, Damien Le Moal wrote:

> The first patch in this series is the formet standalone patch titled

> "scsi: fix scsi_mode_sense()". Patch 2 fixes similar buffer length

> handling problems found in scsi_mode_select().

> Patch 3 fixes the use of scsi_mode_sense() in sd.c to ensure that calls

> are issued with a sensible buffer size for devices that explicitly

> requested the use of MODE SENSE 10 (e.g. SATA drives on AHCI).

> 

> [...]


Applied to 5.16/scsi-queue, thanks!

[1/3] scsi: fix scsi_mode_sense() buffer length handling
      https://git.kernel.org/mkp/scsi/c/17b49bcbf835
[2/3] scsi: fix scsi_mode_select() buffer length handling
      https://git.kernel.org/mkp/scsi/c/a7d6840bed0c
[3/3] scsi: sd: fix sd_do_mode_sense() buffer length handling
      https://git.kernel.org/mkp/scsi/c/c749301ebee8

-- 
Martin K. Petersen	Oracle Linux Engineering