From: Segher Boessenkool <segher@kernel.crashing.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
Nick Desaulniers <ndesaulniers@google.com>,
Borislav Petkov <bp@alien8.de>,
Nathan Chancellor <nathan@kernel.org>, x86-ml <x86@kernel.org>,
lkml <linux-kernel@vger.kernel.org>,
llvm@lists.linux.dev, Josh Poimboeuf <jpoimboe@redhat.com>,
linux-toolchains@vger.kernel.org
Subject: Re: clang memcpy calls
Date: Mon, 28 Mar 2022 11:58:21 -0500 [thread overview]
Message-ID: <20220328165821.GL614@gate.crashing.org> (raw)
In-Reply-To: <YkHfZbCE0ycVWyxz@hirez.programming.kicks-ass.net>
On Mon, Mar 28, 2022 at 06:16:37PM +0200, Peter Zijlstra wrote:
> On Mon, Mar 28, 2022 at 10:59:57AM -0500, Segher Boessenkool wrote:
[ Context added back: ]
> > > My argument is: if the compiler is permitted to implictly and
> > > arbitrarily add calls to instrumented functions within a function marked
> > > with `no_sanitize_address`, the `no_sanitize_address` attribute is
> > > effectively useless, and therefore *something* needs to change.
> I do not see how that follows. Maybe that is obvious from how you look
> > at your use case, but it is not from the viewpoint of people who just
> > want to do sanitation.
>
> It's a substitution issue:
>
> either:
>
> memcpy() equals: "asan instrumentation" + "memcpy implementation"
>
> or:
>
> memcpy() equals: "memcpy implementation"
>
> It can not be both, since they're not equivalent.
Equivalent in what sense? ASAN (like any other sanitizer) does not
change the semantics of valid programs *at all*. And invalid programs
do not have semantics, of course.
> So if the compiler does the substitution, it needs some sense of
> equivalence. All we're asking is that it be consistent (my preference is
> for the latter).
If you want to never do sanitation, there is -fno-sanitize=all. But
that obviously is not what you want either.
> > So what is the goal here? Why do you need to
> > prevent sanitation on anything called from this function, at all cost?
>
> Kernel entry code might not have reached a point where instrumentation
> assumptions are valid yet. Consider calling into C before the kernel
> page-tables are swapped in. KASAN instrumentation would insta-explode
> simply because the environment it expects (the shadow data etc..) isn't
> there.
Ah. Something like the proposed global boolean flag would work fine for
that, afaics? Have all the asan implementation functions just return
until the "I am ready now" flag is set. This is trivial overhead,
compared to having asan at all!
Segher
prev parent reply other threads:[~2022-03-28 17:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <YjxTt3pFIcV3lt8I@zn.tnic>
[not found] ` <CAKwvOdkw0Bbm+=ZyViXQhBE1L6uSbvkstHJuHpQ21tzJRftgAw@mail.gmail.com>
[not found] ` <Yj2yYFloadFobRPx@lakrids>
2022-03-25 14:13 ` clang memcpy calls Peter Zijlstra
2022-03-25 15:12 ` Segher Boessenkool
2022-03-28 9:52 ` Mark Rutland
2022-03-28 10:20 ` Jakub Jelinek
2022-03-28 11:54 ` Peter Zijlstra
2022-03-28 12:55 ` Mark Rutland
2022-03-28 13:12 ` Jakub Jelinek
2022-03-28 13:44 ` Mark Rutland
2022-03-30 14:45 ` Marco Elver
2022-03-28 14:22 ` Segher Boessenkool
2022-03-28 14:58 ` Mark Rutland
2022-03-28 15:59 ` Segher Boessenkool
2022-03-28 16:16 ` Peter Zijlstra
2022-03-28 16:58 ` 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=20220328165821.GL614@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=bp@alien8.de \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-toolchains@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--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).