linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Kees Cook <keescook@chromium.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Joe Perches <joe@perches.com>, Hannes Reinecke <hare@suse.de>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-scsi@vger.kernel.org, linux-hardening@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] scsi: fcoe: Statically initialize flogi_maddr
Date: Wed, 2 Jun 2021 13:41:17 -0500	[thread overview]
Message-ID: <389cfd5c-ea78-2da9-9d00-8743eda8bb0d@embeddedor.com> (raw)
In-Reply-To: <20210602180000.3326448-1-keescook@chromium.org>



On 6/2/21 13:00, Kees Cook wrote:
> In preparation for FORTIFY_SOURCE performing compile-time and run-time
> field bounds checking for memcpy() avoid using an inline const buffer
> argument and instead just statically initialize the destination array
> directly.
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>

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

Thanks
--
Gustavo

> ---
> v2:
>  - use "static const" (Joe)
> v1: https://lore.kernel.org/lkml/20210528181337.792268-2-keescook@chromium.org/
> ---
>  drivers/scsi/fcoe/fcoe.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
> index 89ec735929c3..5ae6c207d3ac 100644
> --- a/drivers/scsi/fcoe/fcoe.c
> +++ b/drivers/scsi/fcoe/fcoe.c
> @@ -293,7 +293,7 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
>  	struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
>  	struct netdev_hw_addr *ha;
>  	struct net_device *real_dev;
> -	u8 flogi_maddr[ETH_ALEN];
> +	static const u8 flogi_maddr[ETH_ALEN] = FC_FCOE_FLOGI_MAC;
>  	const struct net_device_ops *ops;
>  
>  	fcoe->netdev = netdev;
> @@ -336,7 +336,6 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
>  	 * or enter promiscuous mode if not capable of listening
>  	 * for multiple unicast MACs.
>  	 */
> -	memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
>  	dev_uc_add(netdev, flogi_maddr);
>  	if (fip->spma)
>  		dev_uc_add(netdev, fip->ctl_src_addr);
> @@ -442,7 +441,7 @@ static void fcoe_interface_remove(struct fcoe_interface *fcoe)
>  {
>  	struct net_device *netdev = fcoe->netdev;
>  	struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
> -	u8 flogi_maddr[ETH_ALEN];
> +	static const u8 flogi_maddr[ETH_ALEN] = FC_FCOE_FLOGI_MAC;
>  	const struct net_device_ops *ops;
>  
>  	/*
> @@ -458,7 +457,6 @@ static void fcoe_interface_remove(struct fcoe_interface *fcoe)
>  	synchronize_net();
>  
>  	/* Delete secondary MAC addresses */
> -	memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
>  	dev_uc_del(netdev, flogi_maddr);
>  	if (fip->spma)
>  		dev_uc_del(netdev, fip->ctl_src_addr);
> 

  reply	other threads:[~2021-06-02 18:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 18:00 [PATCH v2] scsi: fcoe: Statically initialize flogi_maddr Kees Cook
2021-06-02 18:41 ` Gustavo A. R. Silva [this message]
2021-06-08  1:30 ` Martin K. Petersen
2021-06-16  3:49 ` 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=389cfd5c-ea78-2da9-9d00-8743eda8bb0d@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=gustavoars@kernel.org \
    --cc=hare@suse.de \
    --cc=jejb@linux.ibm.com \
    --cc=joe@perches.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 \
    /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).