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: <1325798396.2748.19.camel@edumazet-laptop>
Date:	Thu, 05 Jan 2012 22:19:56 +0100
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	"Yalagandula, Praveen" <praveen.yalagandula@...com>
Cc:	Alexey Kuznetsov <kuznet@....inr.ac.ru>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: bug in qavg calculation in include/net/red.h (resending as
 plain-text email)

Le jeudi 05 janvier 2012 à 21:13 +0100, Eric Dumazet a écrit :
> Le jeudi 05 janvier 2012 à 19:30 +0000, Yalagandula, Praveen a écrit :
> > (Resending as plain text)
> > 
> > Dear Alexey,
> > 
> > The code (see below) for computing the queue average for RED
> > implementation in Linux kernel has a bug. The return line should be
> > "return p->qavg + ((backlog - p->qavg) >> p->Wlog);". 
> > 
> > qavg = qavg*(1-W) + backlog*W
> > 
> >      = qavg + (backlog-qavg)*W
> > 
> > The current buggy code applies right shift to only the previous qavg,
> > where as it should be applied to (backlog - qavg). Hope you can get
> > this bug corrected.
> 
> Code is correct.
> 
> Please read the comment, it really explains the thing.
> 

I have more time to explain what's going on :

On input, "unsigned int backlog" is not yet scaled.
But qavg _is_ scaled by p->Wlog.

So we should first scale "backlog" by Wlog bits to the left :

backlog_scaled = backlog << p->Wlog;

Then we do our computation as you stated :

return p->qavg + ((backlog_scaled - p->qavg) >> p->Wlog);

Its equivalent to current code, but using a single shift to the right.

return p->qavg + (backlog - (p->qavg >> p->Wlog));


Hope this helps.


--
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