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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 5 May 2020 15:37:00 +0200
From:   Pavel Machek <pavel@...x.de>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     Pavel Machek <pavel@...x.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Stable <stable@...r.kernel.org>,
        Dan Williams <dan.j.williams@...el.com>,
        Nicolas Ferre <nicolas.ferre@...rochip.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Vinod Koul <vkoul@...nel.org>
Subject: Re: [PATCH 4.19 28/37] dmaengine: dmatest: Fix iteration non-stop
 logic

On Tue 2020-05-05 16:19:11, Andy Shevchenko wrote:
> On Tue, May 5, 2020 at 3:58 PM Pavel Machek <pavel@...x.de> wrote:
> > On Tue 2020-05-05 15:51:16, Andy Shevchenko wrote:
> > > On Tue, May 5, 2020 at 3:37 PM Pavel Machek <pavel@...x.de> wrote:
> > > > > So, to the point, the conditional of checking the thread to be stopped being
> > > > > first part of conjunction logic prevents to check iterations. Thus, we have to
> > > > > always check both conditions to be able to stop after given
> > > > > iterations.
> > > >
> > > > I ... don't understand. AFAICT the code is equivalent. Both && and ||
> > > > operators permit "short" execution... but second part of expression
> > > > has no sideeffects, so...
> > >
> > > ..
> > >
> > > > You are changing !a & !b into !(a | b). But that's equivalent
> > > > expression. I hate to admit, but I had to draw truth table to prove
> > > > that.
> > ...
> > > > What am I missing?
> > >
> > > Basic stuff. Compiler doesn't consider second part of conjunction when
> > > first one (see operator precedence) is already false, so, it means:
> > >
> > > a & b
> > > 0   x -> false
> > > 1   0 -> false
> > > 1   1 -> true
> > >
> > > x is not being considered at all. So, logically it's equivalent,
> > > run-time it's not.
> >
> > Yeah, I pointed that out above. Both && and || permit short
> > execution. But that does not matter, as neither "params->iterations"
> > nor "total_tests >= params->iterations" have side effects.
> >
> > Where is the runtime difference?
> 
> We have to check *both* conditions. If we don't check iterations, we
> just wait indefinitely until somebody tells us to stop.
> Everything in the commit message and mentioned there commit IDs which
> you may check.

No.

If kthread_should_stop() is true, we break the loop. Both old code and
new code does that. Neither old nor new code checks the
"params->iterations && total_tests >=dparams->iterations" condition,
as both && and || do short execution).

If you wanted both conditions to always evaluate, you'd have to do

#       while (!kthread_should_stop()
#              & !(params->iterations && total_tests >=
#              params->iterations)) {

(note && -> &). But, again, there's no reason to do that, as second
part of expression does not have side effects.

> > -       while (!kthread_should_stop()
> > -              && !(params->iterations && total_tests >=
> > -              params->iterations)) {
> > +       while (!(kthread_should_stop() ||
> > +              (params->iterations && total_tests >= params->iterations))) {

Best regards,
								Pavel

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ