From: Sasha Levin <sasha.levin@oracle.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RFC v2 1/2] compiler: use compiler to detect integer overflows
Date: Sat, 29 Nov 2014 10:07:08 -0500 [thread overview]
Message-ID: <5479E11C.8080701@oracle.com> (raw)
In-Reply-To: <CA+55aFxx+Ye+v6bkK0TwzkAHxSEUc7e-EAW-1JD8mySE2nVq2w@mail.gmail.com>
On 11/26/2014 10:13 PM, Linus Torvalds wrote:
> .. which I didn't actually validate. And I suspect gcc won't be good
> enough to optimize, so it probably generates horrendous code.
That's correct. It's pretty bad.
> And the thing is, I think it's just *wrong* to do "overflow in signed
> type". The code that does it shouldn't be helped to do it, it should
> be fixed to use an unsigned type.
>
> In other words - in this case, the lofft_t should probably just be a u64.
In this case it's very tied to userspace. One caller is the space allocation
ioctl, which gets this from userspace:
struct space_resv {
[...]
__s64 l_start;
__s64 l_len; /* len == 0 means until end of file */
[...]
};
Since we can't just change those to unsigned, we'd still need to do an overflow
check with signed integers somewhere.
Thanks,
Sasha
next prev parent reply other threads:[~2014-11-29 15:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-26 23:58 [RFC v2 1/2] compiler: use compiler to detect integer overflows Sasha Levin
2014-11-26 23:58 ` [RFC v2 2/2] fs: correctly check for signed integer overflow in vfs_fallocate Sasha Levin
2014-11-27 0:33 ` [RFC v2 1/2] compiler: use compiler to detect integer overflows Linus Torvalds
2014-11-27 1:37 ` Sasha Levin
2014-11-27 3:13 ` Linus Torvalds
2014-11-29 15:07 ` Sasha Levin [this message]
2014-11-29 18:08 ` Linus Torvalds
2014-11-30 3:47 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5479E11C.8080701@oracle.com \
--to=sasha.levin@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.