From: James Seo <james@equiv.tech>
To: Kees Cook <keescook@chromium.org>
Cc: Sathya Prakash <sathya.prakash@broadcom.com>,
Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 03/12] scsi: mpt3sas: Make MPI2_CONFIG_PAGE_RAID_VOL_0::PhysDisk[] a flexible array
Date: Sun, 27 Aug 2023 00:06:23 -0700 [thread overview]
Message-ID: <ZOr175KsKEoCss8U@equiv.tech> (raw)
In-Reply-To: <202308251357.38AF364@keescook>
On Fri, Aug 25, 2023 at 02:03:23PM -0700, Kees Cook wrote:
> On Sun, Aug 06, 2023 at 10:05:55AM -0700, James Seo wrote:
>> This terminal 1-length variable array can be directly converted into
>> a C99 flexible array member.
>>
>> As all users of MPI2_CONFIG_PAGE_RAID_VOL_0 (Mpi2RaidVolPage0_t)
>> either calculate its size without depending on its sizeof() or do not
>> use PhysDisk[], no further source changes are required:
>
> Tons of binary changes in this file too. I see this:
>
> Mpi2RaidVolPage0_t config_page;
> ...
> r = _config_request(ioc, &mpi_request, &mpi_reply,
> MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT, &config_page,
> sizeof(Mpi2RaidVolPage0_t));
>
> So it's already changing this size (and possibly under-allocating now).
Yes. I didn't explicitly identify _config_request() as a user of the
five structs for which I parted out changes into their own commits,
as it's a generalized helper indirectly called when working with
other config page structs as well. Rest assured that I took it into
account, and that the reduced struct sizes don't represent
under-allocations (see below).
>> - mpt3sas_config.c:mpt3sas_config_get_number_pds() fetches a
>> Mpi2RaidVolPage0_t for itself, but does not use PhysDisk[].
>
> Is it certain that _config_request()'s use of mpt3sas_wait_for_ioc()
> won't result in the hardware being upset that config_page_sz shrank?
Sorry if I missed it, but I don't see what config_page_sz has to do
with _config_request()'s use of mpt3sas_wait_for_ioc(). Could you
explain what you meant?
More generally, changes in config_page_sz shouldn't faze the hardware
because all usages of _config_request() occur in pairs - a
preparatory call that returns the actual size of a given config page
in mpi_reply, then a follow-up call during which a temporary
DMA-capable buffer is allocated per the size in mpi_reply and the
hardware reads/writes the entirety of this buffer. config_page_sz
just determines the number of bytes copied between config_page and
the temp buffer after a hardware read/before a hardware write.
Well, as far I can tell, anyway. Maybe Broadcom knows otherwise.
>> @@ -1826,8 +1823,7 @@ typedef struct _MPI2_CONFIG_PAGE_RAID_VOL_0 {
>> U8 Reserved2; /*0x25 */
>> U8 Reserved3; /*0x26 */
>> U8 InactiveStatus; /*0x27 */
>> - MPI2_RAIDVOL0_PHYS_DISK
>> - PhysDisk[MPI2_RAID_VOL_PAGE_0_PHYSDISK_MAX]; /*0x28 */
>> + MPI2_RAIDVOL0_PHYS_DISK PhysDisk[]; /*0x28 */
>> } MPI2_CONFIG_PAGE_RAID_VOL_0,
>
> Without the mpt3sas maintainers chiming in on this, I think the only
> safe changes to make here are those with 0 binary differences. So for
> things like this, it'll need to be:
>
> - MPI2_RAIDVOL0_PHYS_DISK
> - PhysDisk[MPI2_RAID_VOL_PAGE_0_PHYSDISK_MAX]; /*0x28 */
> + union {
> + MPI2_RAIDVOL0_PHYS_DISK legacy_padding; /*0x28 */
> + DECLARE_FLEX_ARRAY(MPI2_RAIDVOL0_PHYS_DISK, PhysDisk);
> + };
>
> --
> Kees Cook
Thanks for clearing that up. Here's hoping those mpt3sas maintainers
do chime in. I'll go with the union workaround if they don't.
James
next prev parent reply other threads:[~2023-08-27 7:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-06 17:05 [PATCH v2 00/12] scsi: mpt3sas: Use flexible arrays and do a few cleanups James Seo
2023-08-06 17:05 ` [PATCH v2 01/12] scsi: mpt3sas: Use flexible arrays when obviously possible James Seo
2023-08-06 17:05 ` [PATCH v2 02/12] scsi: mpt3sas: Make MPI2_CONFIG_PAGE_IO_UNIT_8::Sensor[] a flexible array James Seo
2023-08-25 20:37 ` Kees Cook
2023-08-27 7:05 ` James Seo
2023-08-06 17:05 ` [PATCH v2 03/12] scsi: mpt3sas: Make MPI2_CONFIG_PAGE_RAID_VOL_0::PhysDisk[] " James Seo
2023-08-25 21:03 ` Kees Cook
2023-08-27 7:06 ` James Seo [this message]
2023-08-06 17:05 ` [PATCH v2 04/12] scsi: mpt3sas: Make MPI2_CONFIG_PAGE_SASIOUNIT_0::PhyData[] " James Seo
2023-08-06 17:05 ` [PATCH v2 05/12] scsi: mpt3sas: Make MPI2_CONFIG_PAGE_SASIOUNIT_1::PhyData[] " James Seo
2023-08-06 17:05 ` [PATCH v2 06/12] scsi: mpt3sas: Make MPI26_CONFIG_PAGE_PIOUNIT_1::PhyData[] " James Seo
2023-08-06 17:05 ` [PATCH v2 07/12] scsi: mpt3sas: Use struct_size() for struct size calculations James Seo
2023-08-06 17:06 ` [PATCH v2 08/12] scsi: mpt3sas: Remove the iounit_pg8 member of the per-adapter struct James Seo
2023-08-06 17:06 ` [PATCH v2 09/12] scsi: mpt3sas: Fix an outdated comment James Seo
2023-08-06 17:06 ` [PATCH v2 10/12] scsi: mpt3sas: Fix typo of "TRIGGER" James Seo
2023-08-06 17:06 ` [PATCH v2 11/12] scsi: mpt3sas: Replace a dynamic allocation with a local variable James Seo
2023-08-06 17:06 ` [PATCH v2 12/12] scsi: mpt3sas: Replace dynamic allocations with local variables James Seo
2023-08-25 3:00 ` [PATCH v2 00/12] scsi: mpt3sas: Use flexible arrays and do a few cleanups Martin K. Petersen
2023-10-11 0:49 ` Kees Cook
2023-10-28 19:32 ` James Seo
2023-10-23 16:30 ` Kees Cook
2023-10-25 2:05 ` Martin K. Petersen
2023-10-25 22:33 ` Kees Cook
2023-11-15 13:54 ` Martin K. Petersen
2023-11-15 14:38 ` Kees Cook
2023-11-25 2:54 ` 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=ZOr175KsKEoCss8U@equiv.tech \
--to=james@equiv.tech \
--cc=MPT-FusionLinux.pdl@broadcom.com \
--cc=gustavoars@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=sathya.prakash@broadcom.com \
--cc=sreekanth.reddy@broadcom.com \
--cc=suganath-prabu.subramani@broadcom.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