[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y8EkBKUCWKs2M7hk@hirez.programming.kicks-ass.net>
Date: Fri, 13 Jan 2023 10:27:32 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Sami Tolvanen <samitolvanen@...gle.com>
Cc: Masahiro Yamada <masahiroy@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Kees Cook <keescook@...omium.org>,
linux-kbuild@...r.kernel.org, llvm@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] kbuild: Fix CFI hash randomization with KASAN
On Thu, Jan 12, 2023 at 10:49:48PM +0000, Sami Tolvanen wrote:
> Clang emits a asan.module_ctor constructor to each object file
> when KASAN is enabled, and these functions are indirectly called
> in do_ctors. With CONFIG_CFI_CLANG, the compiler also emits a CFI
> type hash before each address-taken global function so they can
> pass indirect call checks.
>
> However, in commit 0c3e806ec0f9 ("x86/cfi: Add boot time hash
> randomization"), x86 implemented boot time hash randomization,
> which relies on the .cfi_sites section generated by objtool. As
> objtool is run against vmlinux.o instead of individual object
> files with X86_KERNEL_IBT (enabled by default), CFI types in
> object files that are not part of vmlinux.o end up not being
> included in .cfi_sites, and thus won't get randomized and trip
> CFI when called.
>
> Only .vmlinux.export.o and init/version-timestamp.o are linked
> into vmlinux separately from vmlinux.o. As these files don't
> contain any functions, disable KASAN for both of them to avoid
> breaking hash randomization.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1742
> Signed-off-by: Sami Tolvanen <samitolvanen@...gle.com>
Must've been 'fun' to figure out, Thanks!
Acked-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Powered by blists - more mailing lists