scsi: sd_zbc: Support disks with more than 2**32 logical blocks
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).
--- drivers/scsi/sd_zbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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);
Quoted 24 lines · Bart Van Assche
This patch addresses the following Coverity report about the zno *
sdkp->zone_blocksexpression:CID 1475514 (#1 of 1): Unintentional integer overflow (
OVERFLOW_BEFORE_WIDEN)overflow_before_widen: Potentially overflowing expression zno *sdkp->zone_blockswith type unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of typesector_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")Signed-off-by Bart Van Assche <[email protected]>--- drivers/scsi/sd_zbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/sd_zbc.c +0
-0
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
Quoted 24 lines · Bart Van Assche
This patch addresses the following Coverity report about the zno *
sdkp->zone_blocksexpression:CID 1475514 (#1 of 1): Unintentional integer overflow (
OVERFLOW_BEFORE_WIDEN)overflow_before_widen: Potentially overflowing expression zno *sdkp->zone_blockswith type unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of typesector_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")Signed-off-by Bart Van Assche <[email protected]>--- drivers/scsi/sd_zbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/sd_zbc.c +0
-0
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
Looks good,
Quoted 27 lines · Bart Van Assche
This patch addresses the following Coverity report about the zno *
sdkp->zone_blocksexpression:CID 1475514 (#1 of 1): Unintentional integer overflow (
OVERFLOW_BEFORE_WIDEN)overflow_before_widen: Potentially overflowing expression zno *sdkp->zone_blockswith type unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of typesector_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")Signed-off-by Bart Van Assche <[email protected]>---
drivers/scsi/sd_zbc.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/sd_zbc.c +0
-0
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
Martin K. Petersen
AppliedQuoted 10 lines · Bart Van Assche
This patch addresses the following Coverity report about the zno *
sdkp->zone_blocksexpression:CID 1475514 (#1 of 1): Unintentional integer overflow (
OVERFLOW_BEFORE_WIDEN)overflow_before_widen: Potentially overflowing expression zno *sdkp->zone_blockswith type unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of typesector_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