Skip to contentSkip to conversation

scsi: sd_zbc: Support disks with more than 2**32 logical blocks

PATCH Applied Bart Van Assche 6 participants 6 messages Sep 17, 2021 – Sep 22, 2021 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: sd_zbc: Support disks with more than 2**32 logical blocks

This patch addresses the following Coverity report about the zno * sdkp->zone_blocks expression:

CID 1475514 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression zno * sdkp->zone_blocks with type unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type sector_t (64 bits, unsigned).

Cc Johannes Thumshirn <[email protected]>
Cc Damien Le Moal <[email protected]>
Cc Hannes Reinecke <[email protected]>
Fixes 5795eb443060 ("scsi: sd_zbc: emulate ZONE_APPEND commands")
---
 drivers/scsi/sd_zbc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sd_zbc.c +1 -1
index b9757f24b0d6..ded4d7a070a0 100644
@@ -280,7 +280,7 @@ static void sd_zbc_update_wp_offset_workfn(struct work_struct *work)
 {
 	struct scsi_disk *sdkp;
 	unsigned long flags;
-	unsigned int zno;
+	sector_t zno;
 	int ret;
 
 	sdkp = container_of(work, struct scsi_disk, zone_wp_offset_work);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Bart Van Assche

This patch addresses the following Coverity report about the zno * sdkp->zone_blocks expression:

CID 1475514 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression zno * sdkp->zone_blocks with type unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type sector_t (64 bits, unsigned).

Cc Johannes Thumshirn <[email protected]>
Cc Damien Le Moal <[email protected]>
Cc Hannes Reinecke <[email protected]>
Fixes 5795eb443060 ("scsi: sd_zbc: emulate ZONE_APPEND commands")
---
 drivers/scsi/sd_zbc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sd_zbc.c +0 -0
index b9757f24b0d6..ded4d7a070a0 100644

drivers/scsi/sd_zbc.c static void sd_zbc_update_wp_offset_workfn(struct work_struct *work) · line 286

Quoted 8 lines
drivers/scsi/sd_zbc.c +1 -1
@@ -280,7 +280,7 @@ static void sd_zbc_update_wp_offset_workfn(struct work_struct *work)
 {
 	struct scsi_disk *sdkp;
 	unsigned long flags;
-	unsigned int zno;
+	sector_t zno;
 	int ret;
 
 	sdkp = container_of(work, struct scsi_disk, zone_wp_offset_work);

Looks good.

Signature · 2 lines
Damien Le Moal
Western Digital Research
Reviewed-by on v1 1/1
#2 lore raw
In reply to Bart Van Assche
Quoted 24 lines · Bart Van Assche

This patch addresses the following Coverity report about the zno * sdkp->zone_blocks expression:

CID 1475514 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression zno * sdkp->zone_blocks with type unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type sector_t (64 bits, unsigned).

Cc Johannes Thumshirn <[email protected]>
Cc Damien Le Moal <[email protected]>
Cc Hannes Reinecke <[email protected]>
Fixes 5795eb443060 ("scsi: sd_zbc: emulate ZONE_APPEND commands")
---
  drivers/scsi/sd_zbc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sd_zbc.c +0 -0
index b9757f24b0d6..ded4d7a070a0 100644

drivers/scsi/sd_zbc.c static void sd_zbc_update_wp_offset_workfn(struct work_struct *work) · line 286

Quoted 8 lines
drivers/scsi/sd_zbc.c +1 -1
@@ -280,7 +280,7 @@ static void sd_zbc_update_wp_offset_workfn(struct work_struct *work)
  {
  	struct scsi_disk *sdkp;
  	unsigned long flags;
-	unsigned int zno;
+	sector_t zno;
  	int ret;
 
  	sdkp = container_of(work, struct scsi_disk, zone_wp_offset_work);

Of course.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                Kernel Storage Architect
[email protected]                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Reviewed-by on v1 1/1
#4 lore raw
In reply to Bart Van Assche
Quoted 27 lines · Bart Van Assche

This patch addresses the following Coverity report about the zno * sdkp->zone_blocks expression:

CID 1475514 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression zno * sdkp->zone_blocks with type unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type sector_t (64 bits, unsigned).

Cc Johannes Thumshirn <[email protected]>
Cc Damien Le Moal <[email protected]>
Cc Hannes Reinecke <[email protected]>
Fixes 5795eb443060 ("scsi: sd_zbc: emulate ZONE_APPEND commands")

---
drivers/scsi/sd_zbc.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sd_zbc.c +0 -0
index b9757f24b0d6..ded4d7a070a0 100644

drivers/scsi/sd_zbc.c static void sd_zbc_update_wp_offset_workfn(struct work_struct *work) · line 286

Quoted 8 lines
drivers/scsi/sd_zbc.c +1 -1
@@ -280,7 +280,7 @@ static void sd_zbc_update_wp_offset_workfn(struct work_struct *work)
 {
 	struct scsi_disk *sdkp;
 	unsigned long flags;
-	unsigned int zno;
+	sector_t zno;
 	int ret;
 
 	sdkp = container_of(work, struct scsi_disk, zone_wp_offset_work);

Looks Good.

--
Himanshu Madhani Oracle Linux Engineering

#5 lore raw
In reply to Bart Van Assche
Quoted 10 lines · Bart Van Assche

This patch addresses the following Coverity report about the zno * sdkp->zone_blocks expression:

CID 1475514 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression zno * sdkp->zone_blocks with type unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type sector_t (64 bits, unsigned).

[...]

Applied to 5.15/scsi-fixes, thanks!

[1/1] scsi: sd_zbc: Support disks with more than 2**32 logical blocks

      https://git.kernel.org/mkp/scsi/c/1d479e6c9cb2
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering