From: Kees Cook <kees@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Martin Uecker <uecker@tugraz.at>,
Erick Archer <erick.archer@outlook.com>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Liang, Kan" <kan.liang@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Matthew Wilcox <mawilcox@microsoft.com>,
x86@kernel.org, linux-perf-users@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
llvm@lists.linux.dev
Subject: Re: [PATCH v4 0/3] Hardening perf subsystem
Date: Thu, 20 Jun 2024 11:26:52 -0700 [thread overview]
Message-ID: <202406201120.C1629ACFE@keescook> (raw)
In-Reply-To: <20240618082242.GC31592@noisy.programming.kicks-ass.net>
On Tue, Jun 18, 2024 at 10:22:42AM +0200, Peter Zijlstra wrote:
> 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.
Well, we still disagree about this, but I guess we'll see how the size_t
work comes along. Maybe I will come to agree with you. :)
> 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?
Right. Currently this is being plumbed through the sanitizers, so the
type selection will happen there (for this version of it). The current
experiment is to basically tell the sanitizers to ignore all types
except a given list, and our initial list will be just size_t.
Before this, Justin is finishing up the initial set of idiom exclusions.
.e.g.:
size_t var, offset;
...
if (var + offset < var) { ... }
This will not freak out if "var + offset" wraps.
And "negative unsigned constants" will be ignored:
#define MASK -2ULL
...
size_t mask = MASK;
And loop post decrements wrapping will get ignored too:
size_t count = ...;
...
while (count--) { ... }
After we get it all nailed down, we'll see if anything new pops up. :)
--
Kees Cook
next prev parent reply other threads:[~2024-06-20 18:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-01 16:56 [PATCH v4 0/3] Hardening perf subsystem Erick Archer
2024-06-08 8:50 ` Erick Archer
2024-06-10 10:06 ` Peter Zijlstra
2024-06-10 17:28 ` Kees Cook
2024-06-10 20:05 ` Peter Zijlstra
2024-06-10 21:46 ` Kees Cook
2024-06-11 7:55 ` Peter Zijlstra
2024-06-12 19:01 ` Kees Cook
2024-06-12 22:08 ` Peter Zijlstra
2024-06-12 23:23 ` Kees Cook
2024-06-14 10:17 ` Peter Zijlstra
2024-06-15 16:09 ` Martin Uecker
2024-06-17 17:28 ` Kees Cook
2024-06-18 8:22 ` Peter Zijlstra
2024-06-20 18:26 ` Kees Cook [this message]
2024-06-17 17:19 ` Kees Cook
2024-06-18 8:28 ` Peter Zijlstra
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=202406201120.C1629ACFE@keescook \
--to=kees@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bp@alien8.de \
--cc=christophe.jaillet@wanadoo.fr \
--cc=dave.hansen@linux.intel.com \
--cc=erick.archer@outlook.com \
--cc=gustavoars@kernel.org \
--cc=hpa@zytor.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=justinstitt@google.com \
--cc=kan.liang@linux.intel.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=mawilcox@microsoft.com \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=namhyung@kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=uecker@tugraz.at \
--cc=x86@kernel.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 NNTP newsgroup(s).