[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240618082242.GC31592@noisy.programming.kicks-ass.net>
Date: Tue, 18 Jun 2024 10:22:42 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Kees Cook <kees@...nel.org>
Cc: Martin Uecker <uecker@...raz.at>,
Erick Archer <erick.archer@...look.com>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
"Liang, Kan" <kan.liang@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Bill Wendling <morbo@...gle.com>,
Justin Stitt <justinstitt@...gle.com>,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
Matthew Wilcox <mawilcox@...rosoft.com>, x86@...nel.org,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH v4 0/3] Hardening perf subsystem
On Mon, Jun 17, 2024 at 10:28:20AM -0700, Kees Cook wrote:
> But, using type attributes we have much more flexibility. Hence, the
> proposed "wraps" attribute:
> https://github.com/llvm/llvm-project/pull/86618
So I still think that's going about things backwards.
unsigned explicitly wraps. signed is UB.
When using -fwrapv signed is well defined as 2s complement, which takes
away the UB and makes it implicitly wrap.
When extending the language, it is important to not break existing code,
so the default must remain wrap. This in turn means you need to add a
'nowrap' thingy.
Also, I would very much not make this an attribute, but a full type
qualifier. Furthermore, add type promotion rules to ensure nowrap takes
precedence and is preserved throughout expressions. Such that:
'long' + 'nowrap int' -> 'nowrap long'
Then, once you have this, you can go do things like:
typedef nowrap unsigned long size_t;
#define sizeof(x) ((size_t)sizeof(x))
and things will just work. Hmm?
Powered by blists - more mailing lists