netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Oded Gabbay <oded.gabbay@gmail.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	SW_Drivers@habana.ai, gregkh@linuxfoundation.org,
	davem@davemloft.net, kuba@kernel.org, f.fainelli@gmail.com,
	Omer Shpigelman <oshpigelman@habana.ai>
Subject: Re: [PATCH v2 12/14] habanalabs/gaudi: Add ethtool support using coresight
Date: Mon, 14 Sep 2020 03:37:35 +0200	[thread overview]
Message-ID: <20200914013735.GC3463198@lunn.ch> (raw)
In-Reply-To: <20200912144106.11799-13-oded.gabbay@gmail.com>

> +static int gaudi_nic_get_module_eeprom(struct net_device *netdev,
> +					struct ethtool_eeprom *ee, u8 *data)
> +{
> +	struct gaudi_nic_device **ptr = netdev_priv(netdev);
> +	struct gaudi_nic_device *gaudi_nic = *ptr;
> +	struct hl_device *hdev = gaudi_nic->hdev;
> +
> +	if (!ee->len)
> +		return -EINVAL;
> +
> +	memset(data, 0, ee->len);
> +	memcpy(data, hdev->asic_prop.cpucp_nic_info.qsfp_eeprom, ee->len);
> +

You memset and then memcpy the same number of bytes?

You also need to validate ee->offset, and ee->len. Otherwise this is a
vector for user space to read kernel memory after
hdev->asic_prop.cpucp_nic_info.qsfp_eeprom. See drivers/net/phy/sfp.c:
sfp_module_eeprom() as a good example of this validation.

    Andrew

  parent reply	other threads:[~2020-09-14  1:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-12 14:40 [PATCH v2 00/14] Adding GAUDI NIC code to habanalabs driver Oded Gabbay
2020-09-12 14:40 ` [PATCH v2 01/14] habanalabs/gaudi: add NIC H/W and registers definitions Oded Gabbay
2020-09-12 14:40 ` [PATCH v2 02/14] habanalabs/gaudi: add NIC firmware-related definitions Oded Gabbay
2020-09-12 14:40 ` [PATCH v2 03/14] habanalabs/gaudi: add NIC security configuration Oded Gabbay
2020-09-12 14:40 ` [PATCH v2 04/14] habanalabs/gaudi: add support for NIC QMANs Oded Gabbay
2020-09-12 14:40 ` [PATCH v2 05/14] habanalabs/gaudi: add NIC Ethernet support Oded Gabbay
2020-09-12 14:40 ` [PATCH v2 06/14] habanalabs/gaudi: add NIC PHY code Oded Gabbay
2020-09-12 14:40 ` [PATCH v2 07/14] habanalabs/gaudi: allow user to get MAC addresses in INFO IOCTL Oded Gabbay
2020-09-12 14:41 ` [PATCH v2 08/14] habanalabs/gaudi: add a new IOCTL for NIC control operations Oded Gabbay
2020-09-12 15:07   ` Randy Dunlap
2020-09-12 15:19     ` Oded Gabbay
2020-09-12 15:23       ` Randy Dunlap
2020-09-12 14:41 ` [PATCH v2 09/14] habanalabs/gaudi: add CQ " Oded Gabbay
2020-09-12 14:41 ` [PATCH v2 10/14] habanalabs/gaudi: add WQ " Oded Gabbay
2020-09-12 14:41 ` [PATCH v2 11/14] habanalabs/gaudi: add QP error handling Oded Gabbay
2020-09-12 14:41 ` [PATCH v2 12/14] habanalabs/gaudi: Add ethtool support using coresight Oded Gabbay
2020-09-14  1:24   ` Andrew Lunn
2020-09-14 20:07     ` Jakub Kicinski
2020-09-14 20:53       ` Oded Gabbay
2020-09-14  1:37   ` Andrew Lunn [this message]
2020-09-14  5:15     ` Oded Gabbay
2020-09-14  1:39   ` Florian Fainelli
2020-09-14  5:14     ` Oded Gabbay
2020-09-12 14:41 ` [PATCH v2 13/14] habanalabs/gaudi: support DCB protocol Oded Gabbay
2020-09-12 14:41 ` [PATCH v2 14/14] habanalabs/gaudi: add NIC init/fini calls from common code Oded Gabbay

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=20200914013735.GC3463198@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=SW_Drivers@habana.ai \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oded.gabbay@gmail.com \
    --cc=oshpigelman@habana.ai \
    /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).