From: Hannes Reinecke <hare@suse.de>
To: Bryan Gurney <bgurney@redhat.com>,
linux-nvme@lists.infradead.org, kbusch@kernel.org, hch@lst.de,
sagi@grimberg.me, axboe@kernel.dk
Cc: james.smart@broadcom.com, njavali@marvell.com,
linux-scsi@vger.kernel.org, linux-hardening@vger.kernel.org,
kees@kernel.org, gustavoars@kernel.org, jmeneghi@redhat.com,
emilne@redhat.com
Subject: Re: [PATCH v9 9/9] scsi: qla2xxx: Fix memcpy field-spanning write issue
Date: Mon, 18 Aug 2025 14:09:35 +0200 [thread overview]
Message-ID: <851fd010-60c5-42a5-8cda-3863b55e8d59@suse.de> (raw)
In-Reply-To: <20250813200744.17975-10-bgurney@redhat.com>
On 8/13/25 22:07, Bryan Gurney wrote:
> From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
>
> purex_item.iocb is defined as a 64-element u8 array, but 64 is the
> minimum size and it can be allocated larger. This makes it a standard
> empty flex array.
>
> This was motivated by field-spanning write warnings during FPIN testing.
> https://lore.kernel.org/linux-nvme/20250709211919.49100-1-bgurney@redhat.com/
>
> > kernel: memcpy: detected field-spanning write (size 60) of single field
> > "((uint8_t *)fpin_pkt + buffer_copy_offset)"
> > at drivers/scsi/qla2xxx/qla_isr.c:1221 (size 44)
>
> I removed the outer wrapper from the iocb flex array, so that it can be
> linked to `purex_item.size` with `__counted_by`.
>
> These changes remove the default minimum 64-byte allocation, requiring
> further changes.
>
> In `struct scsi_qla_host` the embedded `default_item` is now followed
> by `__default_item_iocb[QLA_DEFAULT_PAYLOAD_SIZE]` to reserve space
> that will be used as `default_item.iocb`. This is wrapped using the
> `TRAILING_OVERLAP()` macro helper, which effectively creates a union
> between flexible-array member `default_item.iocb` and `__default_item_iocb`.
>
> Since `struct pure_item` now contains a flexible-array member, the
> helper must be placed at the end of `struct scsi_qla_host` to prevent
> a `-Wflex-array-member-not-at-end` warning.
>
> `qla24xx_alloc_purex_item()` is adjusted to no longer expect the
> default minimum size to be part of `sizeof(struct purex_item)`,
> the entire flexible array size is added to the structure size for
> allocation.
>
> This also slightly changes the layout of the purex_item struct, as
> 2-bytes of padding are added between `size` and `iocb`. The resulting
> size is the same, but iocb is shifted 2-bytes (the original `purex_item`
> structure was padded at the end, after the 64-byte defined array size).
> I don't think this is a problem.
>
> Tested-by: Bryan Gurney <bgurney@redhat.com>
> Co-developed-by: Chris Leech <cleech@redhat.com>
> Signed-off-by: Chris Leech <cleech@redhat.com>
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
> drivers/scsi/qla2xxx/qla_def.h | 10 ++++++----
> drivers/scsi/qla2xxx/qla_isr.c | 17 ++++++++---------
> drivers/scsi/qla2xxx/qla_nvme.c | 2 +-
> drivers/scsi/qla2xxx/qla_os.c | 5 +++--
> 4 files changed, 18 insertions(+), 16 deletions(-)
>
Not sure if this shouldn't be a stand-alone patch, but anyway:
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
next prev parent reply other threads:[~2025-08-18 12:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 20:07 [PATCH v9 0/8] nvme-fc: FPIN link integrity handling Bryan Gurney
2025-08-13 20:07 ` [PATCH v9 1/9] fc_els: use 'union fc_tlv_desc' Bryan Gurney
2025-08-13 20:07 ` [PATCH v9 2/9] nvme: add NVME_CTRL_MARGINAL flag Bryan Gurney
2025-08-18 12:07 ` Hannes Reinecke
2025-08-13 20:07 ` [PATCH v9 3/9] nvme-fc: marginal path handling Bryan Gurney
2025-08-13 20:07 ` [PATCH v9 4/9] nvme-fc: nvme_fc_fpin_rcv() callback Bryan Gurney
2025-08-13 20:07 ` [PATCH v9 5/9] lpfc: enable FPIN notification for NVMe Bryan Gurney
2025-08-13 20:07 ` [PATCH v9 6/9] qla2xxx: " Bryan Gurney
2025-08-13 20:07 ` [PATCH v9 7/9] nvme: sysfs: emit the marginal path state in show_state() Bryan Gurney
2025-08-13 20:07 ` [PATCH v9 8/9] nvme-multipath: queue-depth support for marginal paths Bryan Gurney
2025-08-18 12:08 ` Hannes Reinecke
2025-08-13 20:07 ` [PATCH v9 9/9] scsi: qla2xxx: Fix memcpy field-spanning write issue Bryan Gurney
2025-08-18 12:09 ` Hannes Reinecke [this message]
2025-08-20 2:13 ` Martin K. Petersen
2025-08-20 2:18 ` [PATCH v9 0/8] nvme-fc: FPIN link integrity handling Martin K. Petersen
2025-08-26 2:33 ` (subset) " 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=851fd010-60c5-42a5-8cda-3863b55e8d59@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--cc=bgurney@redhat.com \
--cc=emilne@redhat.com \
--cc=gustavoars@kernel.org \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=jmeneghi@redhat.com \
--cc=kbusch@kernel.org \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=njavali@marvell.com \
--cc=sagi@grimberg.me \
/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;
as well as URLs for NNTP newsgroup(s).