[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <yq1h7ka7q68.fsf@ca-mkp.ca.oracle.com>
Date: Tue, 13 Apr 2021 00:52:16 -0400
From: "Martin K. Petersen" <martin.petersen@...cle.com>
To: Kees Cook <keescook@...omium.org>
Cc: "Gustavo A. R. Silva" <gustavoars@...nel.org>,
Adaptec OEM Raid Solutions <aacraid@...rosemi.com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] scsi: aacraid: Replace one-element array with
flexible-array member
Hi Kees/Gustavo!
>> @@ -4020,7 +4020,8 @@ static int aac_convert_sgraw2(struct aac_raw_io2 *rio2, int pages, int nseg, int
>> }
>> }
>> sge[pos] = rio2->sge[nseg-1];
>> - memcpy(&rio2->sge[1], &sge[1], (nseg_new-1)*sizeof(struct sge_ieee1212));
>> + memcpy(&rio2->sge[1], &sge[1],
>> + flex_array_size(rio2, sge, nseg_new - 1));
>
> This was hard to validate,
... which is why I didn't apply this patch. I don't like changes which
make the reader have to jump through hoops to figure out what the code
actually does. I find the original much easier to understand.
Silencing analyzer warnings shouldn't be done at the expense of human
readers. If it is imperative to switch to flex_array_size() to quiesce
checker warnings, please add a comment in the code explaining that the
size evaluates to nseg_new-1 sge_ieee1212 structs.
--
Martin K. Petersen Oracle Linux Engineering
Powered by blists - more mailing lists