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:   Wed, 5 Apr 2023 13:55:19 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'chi wu' <wuchi.zero@...il.com>
CC:     Christoph Hellwig <hch@...radead.org>,
        "tytso@....edu" <tytso@....edu>,
        "adilger.kernel@...ger.ca" <adilger.kernel@...ger.ca>,
        "ojaswin@...ux.ibm.com" <ojaswin@...ux.ibm.com>,
        "ritesh.list@...il.com" <ritesh.list@...il.com>,
        "linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] ext4: simplify 32bit calculation of lblk

From: chi wu
> Sent: 05 April 2023 13:48
> 
> David Laight <David.Laight@...lab.com> 于2023年4月5日周三 19:43写道:
> >
> > From: chi wu
> > > Sent: 05 April 2023 09:48
> > >
> > > Christoph Hellwig <hch@...radead.org> 于2023年4月5日周三 13:40写道:
> > > >
> > > > On Mon, Apr 03, 2023 at 09:53:04PM +0800, wuchi wrote:
> > > > > -                     if (block > ext_block)
> > > > > -                             return ext_pblk + (block - ext_block);
> > > > > -                     else
> > > > > -                             return ext_pblk - (ext_block - block);
> > > > > +                     return ext_pblk + ((signed long long)block - (signed long
> long)ext_block);
> > > >
> > > > And what exactly is the value add here, except for turning an easy
> > > > to parse statement into a complex expression using casts?
> > > >
> > > Yes,it will be more complex. the original intention is to reduce the
> > > conditional branch.
> >
> > What is wrong with just:
> >         return ext_pblk + block - ext_block;
> > (64bit + 32bit - 32bit)
> >

> oh, It's my fault. I am trapped in that ext_pblk + block may overflow,
> but it is ok here. thanks.

That doesn't matter, it will 'un-overflow' when ext_block is subtracted.
You do need the '+' to happen before the '-', ok because +/- group
left to right in C.

	David

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

Powered by blists - more mailing lists