lkml.org 
[lkml]   [2020]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 12/14] habanalabs/gaudi: Add ethtool support using coresight
On Mon, Sep 14, 2020 at 4:37 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> > +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?
Thanks for catching this, we will fix it.

>
> 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

Thanks for the pointer, we will take a look and fix it.
Oded

\
 
 \ /
  Last update: 2020-09-14 07:17    [W:0.084 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site