From: Segher Boessenkool <segher@kernel.crashing.org>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Kees Cook <keescook@chromium.org>, Jason Gunthorpe <jgg@ziepe.ca>,
Leon Romanovsky <leon@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Matthew Wilcox <willy@infradead.org>,
linux-kernel@vger.kernel.org,
kernel-hardening@lists.openwall.com
Subject: Re: [RFC] saturate check_*_overflow() output?
Date: Wed, 5 Aug 2020 18:22:08 -0500 [thread overview]
Message-ID: <20200805232208.GT6753@gate.crashing.org> (raw)
In-Reply-To: <6d190601-68f1-c086-97ac-2ee1c08f5a34@rasmusvillemoes.dk>
Hi Rasmus,
On Wed, Aug 05, 2020 at 01:38:58PM +0200, Rasmus Villemoes wrote:
> I'm guessing gcc has some internal very early simplification that
> replaces single-expression statement-exprs with just that expression,
> and the warn-unused-result triggers later. But as soon as the
> statement-expr becomes a little non-trivial (e.g. above), my guess is
> that the whole thing gets assigned to some internal "variable"
> representing the result, and that assignment then counts as a use of the
> return value from must_check_overflow() - cc'ing Segher, as he usually
> knows these details.
A statement expression is not a statement (it's an expression), which
turns half of the world upside down. This GCC extension often has weird
(or at least non-intuitive) side effects, together with other extensions
(like attributes), etc.
This may be a convoluted way of saying "I don't know, look at c/c-decl.c
(and maybe c/c-parser.c) to see if you can find out" ;-)
> Anyway, we don't need to apply it to the last expression inside ({}), we
> can just pass the whole ({}) to must_check_overflow() as in
<snip>
Yes, much nicer :-) Crisis averted, etc.
Segher
prev parent reply other threads:[~2020-08-06 12:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-03 18:29 [RFC] saturate check_*_overflow() output? Kees Cook
2020-08-04 6:11 ` Rasmus Villemoes
2020-08-04 19:23 ` Kees Cook
2020-08-04 22:45 ` Matthew Wilcox
2020-08-05 11:38 ` Rasmus Villemoes
2020-08-05 20:50 ` Kees Cook
2020-08-05 23:22 ` Segher Boessenkool [this message]
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=20200805232208.GT6753@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=gustavoars@kernel.org \
--cc=jgg@ziepe.ca \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).