[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230705213113.GC2813335@hirez.programming.kicks-ass.net>
Date: Wed, 5 Jul 2023 23:31:13 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Kees Cook <keescook@...omium.org>
Cc: Jann Horn <jannh@...gle.com>, Kees Cook <kees@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux LLVM <llvm@...ts.linux.dev>,
the arch/x86 maintainers <x86@...nel.org>
Subject: Re: CONFIG_UBSAN_TRAP #UD error message on x86 [was: Re:
[CRASH][BISECTED] 6.4.1 crash in boot]
On Wed, Jul 05, 2023 at 02:08:09PM -0700, Kees Cook wrote:
> > Even just a "WARNING: CONFIG_UBSAN_TRAP active, #UD might be caused by
> > that" on every #UD that does not come from a known BUG() location or
> > such might be better than nothing...
>
> I've considered it, but usually CONFIG_UBSAN_TRAP isn't accidentally
> set. Also, the crash info is something we can get help from on the
> compiler side, to mark up where the traps are, similar to what we do
> with KCFI, but it hasn't happened yet for x86. For example, arm64
> already encodes the details in the trap instruction itself:
> https://git.kernel.org/linus/25b84002afb9dc9a91a7ea67166879c13ad82422
Right, so you could easily use a different #UD instruction that has an
immediate, something like:
0f b9 40 ff ud1 -0x1(%rax),%rax
or even:
0f b9 80 00 ff ff ff ud1 -0x100(%rax),%rax
if you need a 32bit value.
It shouldn't be hard to fix up the #UD handler to decode the instruction
and obtain the displacement for a clue.
Typically we use ud2 because it's the smallest #UD instruction (2 bytes)
and that's enough, but if you want to provide additional clues, there's
options...
Powered by blists - more mailing lists