lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <64876a57-9ac4-4725-8af3-67944ba6ea95@amd.com>
Date: Mon, 17 Jun 2024 09:24:44 -0700
From: Brett Creeley <bcreeley@....com>
To: David Laight <David.Laight@...LAB.COM>,
 'Shannon Nelson' <shannon.nelson@....com>,
 "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
 "davem@...emloft.net" <davem@...emloft.net>,
 "kuba@...nel.org" <kuba@...nel.org>,
 "edumazet@...gle.com" <edumazet@...gle.com>,
 "pabeni@...hat.com" <pabeni@...hat.com>
Cc: "brett.creeley@....com" <brett.creeley@....com>,
 "drivers@...sando.io" <drivers@...sando.io>
Subject: Re: [PATCH net-next 7/8] ionic: Use an u16 for rx_copybreak



On 6/15/2024 2:20 PM, David Laight wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> 
> 
> From: Shannon Nelson
>> Sent: 11 June 2024 00:07
>>
>> From: Brett Creeley <brett.creeley@....com>
>>
>> To make space for other data members on the first cache line reduce
>> rx_copybreak from an u32 to u16.  The max Rx buffer size we support
>> is (u16)-1 anyway so this makes sense.
>>
>> Signed-off-by: Brett Creeley <brett.creeley@....com>
>> Signed-off-by: Shannon Nelson <shannon.nelson@....com>
>> ---
>>   drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 10 +++++++++-
>>   drivers/net/ethernet/pensando/ionic/ionic_lif.h     |  2 +-
>>   2 files changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
>> b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
>> index 91183965a6b7..26acd82cf6bc 100644
>> --- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
>> +++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
>> @@ -872,10 +872,18 @@ static int ionic_set_tunable(struct net_device *dev,
>>                             const void *data)
>>   {
>>        struct ionic_lif *lif = netdev_priv(dev);
>> +     u32 rx_copybreak, max_rx_copybreak;
>>
>>        switch (tuna->id) {
>>        case ETHTOOL_RX_COPYBREAK:
>> -             lif->rx_copybreak = *(u32 *)data;
>> +             rx_copybreak = *(u32 *)data;
>> +             max_rx_copybreak = min_t(u32, U16_MAX, IONIC_MAX_BUF_LEN);
> 
> I doubt that needs to be min_t() or that you really need the temporary.

IMHO the temporary variable here makes it more readable than comparing 
directly to the casted/de-referenced opaque data pointer and then 
assigning to the rx_copybreak member if it's a valid value.

We can double check that min_t() is required.

> 
>> +             if (rx_copybreak > max_rx_copybreak) {
>> +                     netdev_err(dev, "Max supported rx_copybreak size: %u\n",
>> +                                max_rx_copybreak);
>> +                     return -EINVAL;
>> +             }
>> +             lif->rx_copybreak = (u16)rx_copybreak;
>>                break;
>>        default:
>>                return -EOPNOTSUPP;
>> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.h
>> b/drivers/net/ethernet/pensando/ionic/ionic_lif.h
>> index 40b28d0b858f..50fda9bdc4b8 100644
>> --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.h
>> +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.h
>> @@ -206,7 +206,7 @@ struct ionic_lif {
>>        unsigned int nxqs;
>>        unsigned int ntxq_descs;
>>        unsigned int nrxq_descs;
>> -     u32 rx_copybreak;
>> +     u16 rx_copybreak;
>>        u64 rxq_features;
>>        u16 rx_mode;
> 
> There seem to be 6 pad bytes here - why not just use them??

Thanks for pointing this out. It looks like I missed the differences 
between the OOT and upstream ionic_lif structure when reviewing this 
patch. We will take another look.

Thanks for the review,

Brett
> 
>>        u64 hw_features;
> 
>          David
> 
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ