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: <37d674eb-1173-52ec-3dc2-957e5161251b@aquantia.com>
Date:   Thu, 16 Feb 2017 00:50:32 +0300
From:   Pavel Belous <pavel.belous@...antia.com>
To:     Lino Sanfilippo <LinoSanfilippo@....de>,
        "David S . Miller" <davem@...emloft.net>
Cc:     netdev@...r.kernel.org,
        Simon Edelhaus <Simon.Edelhaus@...antia.com>,
        Alexey Andriyanov <Alexey.Andriyanov@...antia.com>
Subject: Re: [PATCH net-next 11/13] net: ethernet: aquantia: Refactoring
 buffers copying.

Thank you.

I will think about how to avoid copying..

Regards,
Pavel


On 16.02.2017 00:31, Lino Sanfilippo wrote:
> On 15.02.2017 21:01, Pavel Belous wrote:
>> From: Pavel Belous <pavel.belous@...antia.com>
>>
>> This fix simplified copying data to the ring buffer.
>> Also, there was an error in the code when the second memcpy
>> is called with zero length. It didn't break the driver, but it's bad.
>>
>> Signed-off-by: Pavel Belous <pavel.belous@...antia.com>
>> ---
>>  drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 25
>> ++++++++++++------------
>>  1 file changed, 13 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
>> b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
>> index 4c40644..8ebed0d 100644
>> --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
>> +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
>> @@ -108,18 +108,19 @@ void aq_ring_tx_append_buffs(struct aq_ring_s
>> *self,
>>                   struct aq_ring_buff_s *buffer,
>>                   unsigned int buffers)
>>  {
>> -    if (likely(self->sw_tail + buffers < self->size)) {
>> -        memcpy(&self->buff_ring[self->sw_tail], buffer,
>> -               sizeof(buffer[0]) * buffers);
>> -    } else {
>> -        unsigned int first_part = self->size - self->sw_tail;
>> -        unsigned int second_part = buffers - first_part;
>> -
>> -        memcpy(&self->buff_ring[self->sw_tail], buffer,
>> -               sizeof(buffer[0]) * first_part);
>> -
>> -        memcpy(&self->buff_ring[0], &buffer[first_part],
>> -               sizeof(buffer[0]) * second_part);
>> +    int buff_len = min(self->size - self->sw_tail, buffers);
>> +
>> +    memcpy(&self->buff_ring[self->sw_tail],
>> +           buffer,
>> +           sizeof(struct aq_ring_buff_s) * buff_len);
>> +
>> +    /* We are in the end of the ring.
>> +     *  Copy remains data to beginning of the ring
>> +     */
>> +    if (buffers > buff_len) {
>> +        memcpy(self->buff_ring,
>> +               &buffer[buff_len],
>> +               sizeof(struct aq_ring_buff_s) * (buffers - buff_len));
>>      }
>>  }
>
> Well, you should really try to avoid copying the tx buffers _at all_.
> E.g. by passing self->buff_ring to aq_ring_tx_append_buffs() instead of
> the temporary array.
>
> Regards,
> Lino
> buffer array.
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ