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-next>] [day] [month] [year] [list]
Message-ID: <547620E6.10306@oracle.com>
Date:	Wed, 26 Nov 2014 13:50:14 -0500
From:	Sasha Levin <sasha.levin@...cle.com>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
CC:	Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>, mingo@...nel.org
Subject: Re: [RFC 1/2] compiler: use compiler to detect integer overflows

On 11/26/2014 12:55 PM, Linus Torvalds wrote:
> On Nov 26, 2014 6:00 AM, "Sasha Levin" <sasha.levin@...cle.com <mailto:sasha.levin@...cle.com>> wrote:
>>
>> We've used to detect integer overflows by causing an overflow and testing the
>> result. For example, to test for addition overflow we would:
>>
>>         if (a + b < a)
>>                 /* Overflow detected */
>>
>> While it works, this is actually an undefined behaviour and we're not
>> guaranteed to have integers overflowing this way.
> 
> Bullshit.
> 
> Integer overflow is completely well defined in unsigned types.
> 
> Don't make up things like this.

Yes, I messed up and picked case where both types are unsigned in my example
patch. Apologies.

The kernel still has it's share of *signed* integer overflows. Example? fadvise64_64():

	loff_t offset, len;
	[...]
	loff_t endbyte;
	[...]
        /* Careful about overflows. Len == 0 means "as much as possible" */
        endbyte = offset + len;
        if (!len || endbyte < len)
                endbyte = -1;
        else
                endbyte--;              /* inclusive */


In essence, it's checking (offset + len < len), all of which are signed.


Thanks,
Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ