public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Kees Cook <kees@kernel.org>,
	Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] scsi: aacraid: union aac_init: Replace 1-element array with flexible array
Date: Thu, 11 Jul 2024 12:04:32 -0600	[thread overview]
Message-ID: <bfcb72d7-bc3b-4398-be45-dabd60b73cf4@embeddedor.com> (raw)
In-Reply-To: <20240711174815.work.689-kees@kernel.org>



On 11/07/24 11:48, Kees Cook wrote:
> 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>
> ---
> Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: linux-scsi@vger.kernel.org
> ---
>   drivers/scsi/aacraid/aacraid.h | 2 +-
>   drivers/scsi/aacraid/src.c     | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
> index 7d5a155073c6..659e393c1033 100644
> --- a/drivers/scsi/aacraid/aacraid.h
> +++ b/drivers/scsi/aacraid/aacraid.h
> @@ -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;
>   };
>   
> diff --git a/drivers/scsi/aacraid/src.c b/drivers/scsi/aacraid/src.c
> index 11ef58204e96..28115ed637e8 100644
> --- a/drivers/scsi/aacraid/src.c
> +++ b/drivers/scsi/aacraid/src.c
> @@ -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),

struct_size_t() can be used here?

In any case:

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

>   			0, 0, 0, NULL, NULL, NULL, NULL, NULL);
>   	} else {
>   		init->r7.host_elapsed_seconds =

  reply	other threads:[~2024-07-11 18:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-11 17:48 [PATCH] scsi: aacraid: union aac_init: Replace 1-element array with flexible array Kees Cook
2024-07-11 18:04 ` Gustavo A. R. Silva [this message]
2024-08-03  1:28 ` Martin K. Petersen
2024-08-05 21:17 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bfcb72d7-bc3b-4398-be45-dabd60b73cf4@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=aacraid@microsemi.com \
    --cc=gustavoars@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox