* [PATCH][next] scsi: smartpqi: Replace one-element arrays with flexible-array members
@ 2023-06-21 20:27 Gustavo A. R. Silva
2023-06-21 21:27 ` Kees Cook
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2023-06-21 20:27 UTC (permalink / raw)
To: Don Brace, James E.J. Bottomley, Martin K. Petersen
Cc: storagedev, linux-scsi, linux-kernel, Gustavo A. R. Silva,
linux-hardening
One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element arrays with flexible-array
members in a couple of structures, and refactor the rest of the code,
accordingly.
This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy().
This results in no differences in binary output.
Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/204
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/scsi/smartpqi/smartpqi.h | 4 ++--
drivers/scsi/smartpqi/smartpqi_init.c | 5 ++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
index f960b5095d09..e392eaf5b2bf 100644
--- a/drivers/scsi/smartpqi/smartpqi.h
+++ b/drivers/scsi/smartpqi/smartpqi.h
@@ -982,12 +982,12 @@ struct report_phys_lun_16byte_wwid {
struct report_phys_lun_8byte_wwid_list {
struct report_lun_header header;
- struct report_phys_lun_8byte_wwid lun_entries[1];
+ struct report_phys_lun_8byte_wwid lun_entries[];
};
struct report_phys_lun_16byte_wwid_list {
struct report_lun_header header;
- struct report_phys_lun_16byte_wwid lun_entries[1];
+ struct report_phys_lun_16byte_wwid lun_entries[];
};
struct raid_map_disk_data {
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 19af36e9a16d..6aaaa7ebca37 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -1203,7 +1203,6 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **b
unsigned int i;
u8 rpl_response_format;
u32 num_physicals;
- size_t rpl_16byte_wwid_list_length;
void *rpl_list;
struct report_lun_header *rpl_header;
struct report_phys_lun_8byte_wwid_list *rpl_8byte_wwid_list;
@@ -1232,9 +1231,9 @@ static inline int pqi_report_phys_luns(struct pqi_ctrl_info *ctrl_info, void **b
rpl_8byte_wwid_list = rpl_list;
num_physicals = get_unaligned_be32(&rpl_8byte_wwid_list->header.list_length) / sizeof(rpl_8byte_wwid_list->lun_entries[0]);
- rpl_16byte_wwid_list_length = sizeof(struct report_lun_header) + (num_physicals * sizeof(struct report_phys_lun_16byte_wwid));
- rpl_16byte_wwid_list = kmalloc(rpl_16byte_wwid_list_length, GFP_KERNEL);
+ rpl_16byte_wwid_list = kmalloc(struct_size(rpl_16byte_wwid_list, lun_entries,
+ num_physicals), GFP_KERNEL);
if (!rpl_16byte_wwid_list)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH][next] scsi: smartpqi: Replace one-element arrays with flexible-array members
2023-06-21 20:27 [PATCH][next] scsi: smartpqi: Replace one-element arrays with flexible-array members Gustavo A. R. Silva
@ 2023-06-21 21:27 ` Kees Cook
2023-06-22 1:16 ` Martin K. Petersen
2023-06-29 2:41 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2023-06-21 21:27 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Don Brace, James E.J. Bottomley, Martin K. Petersen, storagedev,
linux-scsi, linux-kernel, linux-hardening
On Wed, Jun 21, 2023 at 02:27:20PM -0600, Gustavo A. R. Silva wrote:
> One-element arrays are deprecated, and we are replacing them with flexible
> array members instead. So, replace one-element arrays with flexible-array
> members in a couple of structures, and refactor the rest of the code,
> accordingly.
>
> This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
> routines on memcpy().
>
> This results in no differences in binary output.
>
> Link: https://github.com/KSPP/linux/issues/79
> Link: https://github.com/KSPP/linux/issues/204
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] scsi: smartpqi: Replace one-element arrays with flexible-array members
2023-06-21 20:27 [PATCH][next] scsi: smartpqi: Replace one-element arrays with flexible-array members Gustavo A. R. Silva
2023-06-21 21:27 ` Kees Cook
@ 2023-06-22 1:16 ` Martin K. Petersen
2023-06-29 2:41 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2023-06-22 1:16 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Don Brace, James E.J. Bottomley, Martin K. Petersen, storagedev,
linux-scsi, linux-kernel, linux-hardening
Gustavo,
> One-element arrays are deprecated, and we are replacing them with
> flexible array members instead. So, replace one-element arrays with
> flexible-array members in a couple of structures, and refactor the
> rest of the code, accordingly.
Applied to 6.5/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] scsi: smartpqi: Replace one-element arrays with flexible-array members
2023-06-21 20:27 [PATCH][next] scsi: smartpqi: Replace one-element arrays with flexible-array members Gustavo A. R. Silva
2023-06-21 21:27 ` Kees Cook
2023-06-22 1:16 ` Martin K. Petersen
@ 2023-06-29 2:41 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2023-06-29 2:41 UTC (permalink / raw)
To: Don Brace, James E.J. Bottomley, Gustavo A. R. Silva
Cc: Martin K . Petersen, storagedev, linux-scsi, linux-kernel,
linux-hardening
On Wed, 21 Jun 2023 14:27:20 -0600, Gustavo A. R. Silva wrote:
> One-element arrays are deprecated, and we are replacing them with flexible
> array members instead. So, replace one-element arrays with flexible-array
> members in a couple of structures, and refactor the rest of the code,
> accordingly.
>
> This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
> routines on memcpy().
>
> [...]
Applied to 6.5/scsi-queue, thanks!
[1/1] scsi: smartpqi: Replace one-element arrays with flexible-array members
https://git.kernel.org/mkp/scsi/c/6f0a92fd7db1
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-29 2:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-21 20:27 [PATCH][next] scsi: smartpqi: Replace one-element arrays with flexible-array members Gustavo A. R. Silva
2023-06-21 21:27 ` Kees Cook
2023-06-22 1:16 ` Martin K. Petersen
2023-06-29 2:41 ` Martin K. Petersen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.