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] [day] [month] [year] [list]
Date:   Wed, 12 Apr 2023 15:47:30 +0000
From:   <Nicolas.Ferre@...rochip.com>
To:     <kuba@...nel.org>, <roman.gushchin@...ux.dev>,
        <Claudiu.Beznea@...rochip.com>
CC:     <lars@...afoo.de>, <netdev@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <rafalo@...ence.com>,
        <Conor.Dooley@...rochip.com>, <davem@...emloft.net>,
        <harini.katakam@...inx.com>
Subject: Re: [PATCH net] net: macb: fix a memory corruption in extended buffer
 descriptor mode

Jakub, Roman,

On 12/04/2023 at 06:13, Jakub Kicinski wrote:
> On Tue, 11 Apr 2023 20:48:50 -0700 Roman Gushchin wrote:
>>> diff --git a/drivers/net/ethernet/cadence/macb_main.c
>>> b/drivers/net/ethernet/cadence/macb_main.c
>>> index d13fb1d31821..1a40d5a26f36 100644
>>> --- a/drivers/net/ethernet/cadence/macb_main.c
>>> +++ b/drivers/net/ethernet/cadence/macb_main.c
>>> @@ -1042,6 +1042,10 @@ static dma_addr_t macb_get_addr(struct macb *bp,
>>> struct macb_dma_desc *desc)
>>>          }
>>>   #endif
>>>          addr |= MACB_BF(RX_WADDR, MACB_BFEXT(RX_WADDR, desc->addr));
>>> +#ifdef CONFIG_MACB_USE_HWSTAMP
>>> +       if (bp->hw_dma_cap & HW_DMA_CAP_PTP)
>>> +               addr &= ~GEM_BIT(DMA_RXVALID_OFFSET);
>>> +#endif
>>>          return addr;
>>>   }
>>
>> I think this version is slightly worse because it adds an unconditional
>> if statement, which can be removed with certain config options.
>> I can master a version with a helper function, if it's preferable.
>>
>> But if you like this one, it's fine too, let me know, I'll send an updated
>> version.
> 
> Yup, IMHO this looks better. More likely that someone reading the code
> will spot the trickiness.

Ok with this version, even if adding to the hot path is really a big 
concern for our low-end CPUs (ARM9 and Cortex-A5).

> I suspect we could clear that bit unconditionally, if the branch is
> a concern. The code seems to assume that buffers it gets are 8B aligned
> already, regardless of CONFIG_MACB_USE_HWSTAMP.
> 
> Drivers commonly save the DMA address to a SW ring (here I think
> rx_skbuff plays this role but only holds single ptr per entry)
> so that they don't have to access potentially uncached descriptor
> ring. But that'd be too large of a change for a fix.

Ok with that statement:

Acked-by: Nicolas Ferre <nicolas.ferre@...rochip.com>

Thanks, best regards,
   Nicolas

-- 
Nicolas Ferre

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ