From: Steffen Maier <maier@linux.ibm.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Hannes Reinecke <hare@suse.de>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org,
Kees Cook <keescook@chromium.org>,
Javed Hasan <jhasan@marvell.com>,
Himanshu Madhani <himanshu.madhani@oracle.com>,
Neerav Parikh <neerav.parikh@intel.com>,
Ross Brattain <ross.b.brattain@intel.com>,
Robert Love <robert.w.love@intel.com>
Subject: Re: [PATCH][next] scsi: Replace one-element arrays with flexible-array members
Date: Fri, 5 Nov 2021 12:24:13 +0100 [thread overview]
Message-ID: <22139a80-3f64-1f21-6b5c-65d250bafe09@linux.ibm.com> (raw)
In-Reply-To: <20211105091102.GA126301@embeddedor>
On 11/5/21 10:11, Gustavo A. R. Silva wrote:
> Use flexible-array members in struct fc_fdmi_attr_entry and
> fs_fdmi_attrs instead of one-element arrays, and refactor the
> code accordingly.
>
> Also, turn the one-element array _port_ in struct fc_fdmi_rpl
> into a simple object of type struct fc_fdmi_port_name, as it
> seems there is no more than just one port expected:
>
> $ git grep -nw numport drivers/scsi/
> drivers/scsi/csiostor/csio_lnode.c:447: reg_pl->numport = htonl(1);
> drivers/scsi/libfc/fc_encode.h:232: put_unaligned_be32(1, &ct->payload.rhba.port.numport);
>
> Also, this helps with the ongoing efforts to globally enable
> -Warray-bounds and get us closer to being able to tighten the
> FORTIFY_SOURCE routines on memcpy().
>
> https://github.com/KSPP/linux/issues/79
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
> drivers/scsi/csiostor/csio_lnode.c | 2 +-
> drivers/scsi/libfc/fc_encode.h | 4 ++--
> include/scsi/fc/fc_ms.h | 6 +++---
> 3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/csiostor/csio_lnode.c b/drivers/scsi/csiostor/csio_lnode.c
> index d5ac93897023..cf9dd79ee488 100644
> --- a/drivers/scsi/csiostor/csio_lnode.c
> +++ b/drivers/scsi/csiostor/csio_lnode.c
> @@ -445,7 +445,7 @@ csio_ln_fdmi_dprt_cbfn(struct csio_hw *hw, struct csio_ioreq *fdmi_req)
> /* Register one port per hba */
> reg_pl = (struct fc_fdmi_rpl *)pld;
> reg_pl->numport = htonl(1);
> - memcpy(®_pl->port[0].portname, csio_ln_wwpn(ln), 8);
> + memcpy(®_pl->port.portname, csio_ln_wwpn(ln), 8);
> pld += sizeof(*reg_pl);
>
> /* Start appending HBA attributes hba */
> diff --git a/drivers/scsi/libfc/fc_encode.h b/drivers/scsi/libfc/fc_encode.h
> index 74ae7fd15d8d..5806f99e4061 100644
> --- a/drivers/scsi/libfc/fc_encode.h
> +++ b/drivers/scsi/libfc/fc_encode.h
> @@ -232,7 +232,7 @@ static inline int fc_ct_ms_fill(struct fc_lport *lport,
> put_unaligned_be32(1, &ct->payload.rhba.port.numport);
> /* Port Name */
> put_unaligned_be64(lport->wwpn,
> - &ct->payload.rhba.port.port[0].portname);
> + &ct->payload.rhba.port.port.portname);
>
> /* HBA Attributes */
> put_unaligned_be32(numattrs,
> diff --git a/include/scsi/fc/fc_ms.h b/include/scsi/fc/fc_ms.h
> index 00191695233a..44fbe84fa664 100644
> --- a/include/scsi/fc/fc_ms.h
> +++ b/include/scsi/fc/fc_ms.h
> @@ -174,7 +174,7 @@ struct fs_fdmi_attrs {
/*
* Registered Port List
> */
> struct fc_fdmi_rpl {
> __be32 numport;
> - struct fc_fdmi_port_name port[1];
> + struct fc_fdmi_port_name port;
> } __attribute__((__packed__));
While I'm not affected by the change, it feels to me as if these are protocol
definitions originating in a T11 Fibre Channel standard FC-GS. It's a port
*list*. Can you "modify" the standard here?
The fact, that currently existing code users only ever seem to use one single
port in the list, would be an independent thing to me.
--
Mit freundlichen Gruessen / Kind regards
Steffen Maier
Linux on IBM Z and LinuxONE
https://www.ibm.com/privacy/us/en/
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
next prev parent reply other threads:[~2021-11-05 11:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-05 9:11 [PATCH][next] scsi: Replace one-element arrays with flexible-array members Gustavo A. R. Silva
2021-11-05 11:24 ` Steffen Maier [this message]
2021-12-02 19:23 ` Kees Cook
2021-12-02 19:40 ` Gustavo A. R. Silva
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=22139a80-3f64-1f21-6b5c-65d250bafe09@linux.ibm.com \
--to=maier@linux.ibm.com \
--cc=gustavoars@kernel.org \
--cc=hare@suse.de \
--cc=himanshu.madhani@oracle.com \
--cc=jejb@linux.ibm.com \
--cc=jhasan@marvell.com \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=neerav.parikh@intel.com \
--cc=robert.w.love@intel.com \
--cc=ross.b.brattain@intel.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