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]
Message-ID: <20230125140202.44744390@kernel.org>
Date:   Wed, 25 Jan 2023 14:02:02 -0800
From:   Jakub Kicinski <kuba@...nel.org>
To:     Vadim Fedorenko <vadfed@...a.com>
Cc:     Vadim Fedorenko <vfedorenko@...ek.ru>, Aya Levin <ayal@...dia.com>,
        Saeed Mahameed <saeedm@...dia.com>,
        Gal Pressman <gal@...dia.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH net v2 1/2] mlx5: fix possible ptp queue fifo overflow

On Tue, 24 Jan 2023 16:03:42 +0000 Vadim Fedorenko wrote:
> > Are you sure this works for all cases?
> > Directly comparing indexes of a ring buffer seems dangerous.
> > We'd need to compare like this:
> > 
> > 	(s16)(skb_cc - skb_id) < 0
> >  
> 
> Here I would like to count (and skip re-syncing) all the packets that 
> are not going to be in FIFO. Your suggestion will not work for the 
> simplest example. Imagine we have FIFO for 16 elements, and current 
> counters are:
>   (consumer) skb_cc = 13, (producer) skb_pc = 15, so 3 packets are in.
> Then skb_id = 10 arrives out-of-order. It will be counted because of 
> (skb_cc > skb_id), but will not be catched by (skb_cc - skb_id) < 0.

Oh, I may be confused about what the producer and consumer are.
The point I was trying to make is that comparing indexes on rings is
hard. Instead of writing:

	if (a < b)

you need to write:

	if ((signed)(a - b) < 0)

"mathematically" it's the same, but in "wrapping logic" it works
because if you're further than half a ring around then it counts 
as a second negation..

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ