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: <635275613c384fe381df4ae4ac30f380@AcuMS.aculab.com>
Date:   Fri, 23 Apr 2021 14:55:29 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Sergey Organov' <sorganov@...il.com>, Walter Harms <wharms@....de>
CC:     'Dan Carpenter' <dan.carpenter@...cle.com>,
        Joel Stanley <joel@....id.au>,
        Andrew Jeffery <andrew@...id.au>,
        "Chia-Wei, Wang" <chiawei_wang@...eedtech.com>,
        Jae Hyun Yoo <jae.hyun.yoo@...el.com>,
        "John Wang" <wangzhiqiang.bj@...edance.com>,
        Brad Bishop <bradleyb@...ziesquirrel.com>,
        Patrick Venture <venture@...gle.com>,
        Benjamin Fair <benjaminfair@...gle.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Robert Lippert <rlippert@...gle.com>,
        "linux-aspeed@...ts.ozlabs.org" <linux-aspeed@...ts.ozlabs.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>
Subject: RE: AW: [PATCH] soc: aspeed: fix a ternary sign expansion bug

From: Sergey Organov
> Sent: 23 April 2021 15:40
> 
> Walter Harms <wharms@....de> writes:
> 
> > as indepentent observer,
> > i would go for Dans solution:
> >
> > ret = kfifo_to_user();
> > /* if an error occurs just return */
> > if (ret)
> >    return ret;
> >
> > /* otherwise return the copied number of bytes */
> >
> > return copied;
> >
> > there is no need for any deeper language knowledge,
> 
> Yep, but this is not idiomatic C, so one looking at this code would
> tend to convert it back to ternary, and the actual problem here is that
> the type of 'copied' does not match the return type of the function.

Actually changing the type of 'ret' to ssize_t is probably
the safest change.

That works until someone tries to optimise out 'ret' by doing:

	return kfifo_to_user(...) ?: count;

Or rattle through and remove the 'pass by reference' 'count'
parameter from kfifo_to_user() in favour of returning the
value the callers want.

I need to stop looking at this code :-)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ