scsi: smartpqi: Replace one-element array with flexible-array member
Subsystems (2)
PATCH v3 1/1 scsi: smartpqi: Replace one-element array with flexible-array member
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct report_log_lun_list.
This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy().
---
Changes in v3:
- Amplify the existing comment instead of adding a new one. By Don Brace[1].
- Add Don's Acked-by tag to the changelog.
Changes in v2:
- In v1 we thought that the original code was allocating one too-many entries for the list. However, Don Brace commented that the allocation was actually intentional[2]. So, I added a code comment with his feedback.
drivers/scsi/smartpqi/smartpqi.h | 2 +- drivers/scsi/smartpqi/smartpqi_init.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/smartpqi/smartpqi.h +1 -1
@@ -954,7 +954,7 @@ struct report_log_lun {struct report_log_lun_list {struct report_lun_header header; -struct report_log_lun lun_entries[1 ]; +struct report_log_lun lun_entries[]; };struct report_phys_lun_8byte_wwid {
drivers/scsi/smartpqi/smartpqi_init.c +2 -1
@@ -1259,7 +1259,8 @@ static int pqi_get_device_lists(struct pqi_ctrl_info *ctrl_info, "report logical LUNs failed\n");/* -* Tack the controller itself onto the end of the logical device list. +* Tack the controller itself onto the end of the logical device list +* by adding a list entry that is all zeros. */ logdev_data = *logdev_list;
Signature · 1 line
2.34.1
Quoted 11 lines · Gustavo A. R. Silva
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct
report_log_lun_list.This helps with the ongoing efforts to tighten the
FORTIFY_SOURCEroutines onmemcpy().
Looks good to me -- both before and after, there is 1 extra all-zero entry at the end. But now the struct is using a flex array correctly.
-Kees
Quoted 50 lines
---
Changes in v3:
- Amplify the existing comment instead of adding a new one. By Don Brace[1].
- Add Don's Acked-by tag to the changelog.Changes in v2:
- In v1 we thought that the original code was allocating one too-many entries for the list. However, Don Brace commented that the allocation was actually intentional[2]. So, I added a code comment with his feedback.drivers/scsi/smartpqi/smartpqi.h | 2 +- drivers/scsi/smartpqi/smartpqi_init.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)drivers/scsi/smartpqi/smartpqi.h +1
-1@@ -954,7 +954,7 @@ struct report_log_lun {struct report_log_lun_list {struct report_lun_header header; -struct report_log_lun lun_entries[1 ]; +struct report_log_lun lun_entries[]; };struct report_phys_lun_8byte_wwid {drivers/scsi/smartpqi/smartpqi_init.c +2
-1@@ -1259,7 +1259,8 @@ static int pqi_get_device_lists(struct pqi_ctrl_info *ctrl_info, "report logical LUNs failed\n");/* -* Tack the controller itself onto the end of the logical device list. +* Tack the controller itself onto the end of the logical device list +* by adding a list entry that is all zeros. */ logdev_data = *logdev_list;Signature · 1 line
2.34.1
Signature · 1 line
Kees Cook
Quoted 8 lines · Kees Cook
Quoted 7 lines · Gustavo A. R. Silva
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct
report_log_lun_list.This helps with the ongoing efforts to tighten the
FORTIFY_SOURCEroutines onmemcpy().
Quoted 7 lines
Quoted 4 lines
Looks good to me -- both before and after, there is 1 extra all-zero entry at the end. But now the struct is using a flex array correctly.
Yep. :)
Quoted 2 lines
Reviewed-by Kees Cook <[email protected]>
Thanks!
--
Gustavo
Quoted 54 lines
-Kees
Quoted 50 lines
---
Changes in v3:
- Amplify the existing comment instead of adding a new one. By DonBrace[1]. - Add Don's Acked-by tag to the changelog. Link: https://lore.kernel.org/linux-hardening/[email protected]/ [1]Changes in v2:
- In v1 we thought that the original code was allocating one too-many entries for the list. However, Don Brace commented that the allocation was actually intentional[2]. So, I added a code comment with his feedback.drivers/scsi/smartpqi/smartpqi.h | 2 +- drivers/scsi/smartpqi/smartpqi_init.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)drivers/scsi/smartpqi/smartpqi.h +1
-1@@ -954,7 +954,7 @@ struct report_log_lun {struct report_log_lun_list {struct report_lun_header header; -struct report_log_lun lun_entries[1 ]; +struct report_log_lun lun_entries[]; };struct report_phys_lun_8byte_wwid {drivers/scsi/smartpqi/smartpqi_init.c +2
-1@@ -1259,7 +1259,8 @@ static int pqi_get_device_lists(struct pqi_ctrl_info *ctrl_info, "report logical LUNs failed\n");/* -* Tack the controller itself onto the end of the logical device list. +* Tack the controller itself onto the end of the logical device list +* by adding a list entry that is all zeros. */ logdev_data = *logdev_list;Signature · 1 line
2.34.1
Martin K. Petersen
AppliedGustavo,
Quoted 3 lines
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct
report_log_lun_list.
Applied to 6.3/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 8 lines · Gustavo A. R. Silva
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct
report_log_lun_list.This helps with the ongoing efforts to tighten the
FORTIFY_SOURCEroutines onmemcpy().[...]
Applied to 6.3/scsi-queue, thanks!
[1/1] scsi: smartpqi: Replace one-element array with flexible-array member
https://git.kernel.org/mkp/scsi/c/ead821268c14
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering