scsi: aacraid: union aac_init: Replace 1-element array with flexible array

BugLink: https://bugs.launchpad.net/bugs/2078038

Replace the deprecated[1] use of a 1-element array in union aac_init with a
modern flexible array.

Additionally add __counted_by annotation since rrq is only ever accessed
after rr_queue_count has been set (with the same value used to control the
loop):

                init->r8.rr_queue_count = cpu_to_le32(dev->max_msix);
		...
                for (i = 0; i < dev->max_msix; i++) {
                        addr = (u64)dev->host_rrq_pa + dev->vector_cap * i *
                                        sizeof(u32);
                        init->r8.rrq[i].host_addr_high = cpu_to_le32(
                                                upper_32_bits(addr));

No binary differences are present after this conversion.

Link: https://github.com/KSPP/linux/issues/79 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
Link: https://lore.kernel.org/r/20240711174815.work.689-kees@kernel.org
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 575b9be63684600e7e02517f0b647e5cb759120c)
Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
Acked-by: Ivan Hu <ivan.hu@canonical.com>
Acked-by: Guoqing Jiang <guoqing.jiang@canonical.com>
Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
This commit is contained in:
Kees Cook
2024-10-02 11:44:54 +02:00
committed by Mehmet Basaran
parent 7f9999709b
commit 1b0cb6bac3
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -873,7 +873,7 @@ union aac_init
__le16 element_count;
__le16 comp_thresh;
__le16 unused;
} rrq[1]; /* up to 64 RRQ addresses */
} rrq[] __counted_by_le(rr_queue_count); /* up to 64 RRQ addresses */
} r8;
};
+1 -1
View File
@@ -410,7 +410,7 @@ static void aac_src_start_adapter(struct aac_dev *dev)
lower_32_bits(dev->init_pa),
upper_32_bits(dev->init_pa),
sizeof(struct _r8) +
(AAC_MAX_HRRQ - 1) * sizeof(struct _rrq),
AAC_MAX_HRRQ * sizeof(struct _rrq),
0, 0, 0, NULL, NULL, NULL, NULL, NULL);
} else {
init->r7.host_elapsed_seconds =