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:	Mon, 13 Apr 2015 20:05:43 +0200
From:	Rafał Miłecki <zajec5@...il.com>
To:	Felix Fietkau <nbd@...nwrt.org>
Cc:	Network Development <netdev@...r.kernel.org>,
	Hauke Mehrtens <hauke@...ke-m.de>
Subject: Re: [PATCH v4 1/9] bgmac: simplify tx ring index handling

On 13 April 2015 at 17:01, Felix Fietkau <nbd@...nwrt.org> wrote:
> On 2015-04-13 16:21, Rafał Miłecki wrote:
>>> @@ -158,13 +157,7 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
>>>                 skb_checksum_help(skb);
>>>
>>>         nr_frags = skb_shinfo(skb)->nr_frags;
>>> -
>>> -       if (ring->start <= ring->end)
>>> -               free_slots = ring->start - ring->end + BGMAC_TX_RING_SLOTS;
>>> -       else
>>> -               free_slots = ring->start - ring->end;
>>> -
>>> -       if (free_slots <= nr_frags + 1) {
>>> +       if (ring->end - ring->start + nr_frags + 1 >= BGMAC_TX_RING_SLOTS) {
>>>                 bgmac_err(bgmac, "TX ring is full, queue should be stopped!\n");
>>>                 netif_stop_queue(net_dev);
>>>                 return NETDEV_TX_BUSY;
>>
>> How is this going to work with ring->end lower than ring->start? Let's
>> say you have 2 empty slots at the end of ring and 2 empty slots at the
>> beginning. In total 4 free slots. Doing ring->end - ring->start will
>> give you some big negative number (depending on the ring size), won't
>> it?
> It won't, because the resulting data type is limited to 32 bit. I'm
> pretty sure there are other places in the kernel that rely on the same
> behavior.

I'm not really sure about this.

I modified driver in the following way to test ring behavior better:
#define BGMAC_TX_RING_SLOTS 16
#define BGMAC_RX_RING_SLOTS 32
u8 start;
u8 end;

And then I added following code to bgmac.c for debugging:
if (ring->end < ring->start)
pr_info("ring->end:0x%08x ring->start:0x%02x (ring->end - ring->start
+ nr_frags + 1):%d\n", ring->end, ring->start, ring->end - ring->start
+ nr_frags + 1);

This is what I got:
[   35.516290] bgmac: ring->end:0x00000000 ring->start:0xfd (ring->end
- ring->start + nr_frags + 1):-252
[   58.058634] bgmac: ring->end:0x00000000 ring->start:0xff (ring->end
- ring->start + nr_frags + 1):-254
[   62.190323] bgmac: ring->end:0x00000000 ring->start:0xff (ring->end
- ring->start + nr_frags + 1):-254
[   71.659957] bgmac: ring->end:0x00000000 ring->start:0xff (ring->end
- ring->start + nr_frags + 1):-254
[   83.029964] bgmac: ring->end:0x00000000 ring->start:0xfe (ring->end
- ring->start + nr_frags + 1):-253
[   99.519693] bgmac: ring->end:0x00000000 ring->start:0xff (ring->end
- ring->start + nr_frags + 1):-254
[  105.751245] bgmac: ring->end:0x00000000 ring->start:0xfe (ring->end
- ring->start + nr_frags + 1):-253
[  139.006470] bgmac: ring->end:0x00000000 ring->start:0xfd (ring->end
- ring->start + nr_frags + 1):-252
[  143.496619] bgmac: ring->end:0x00000000 ring->start:0xfd (ring->end
- ring->start + nr_frags + 1):-252
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ