All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Sami Tolvanen <samitolvanen@google.com>,
	linux-kernel@vger.kernel.org, Kees Cook <keescook@chromium.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	x86@kernel.org, Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Joao Moreira <joao@overdrivepizza.com>,
	Sedat Dilek <sedat.dilek@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-hardening@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev
Subject: Re: [PATCH v5 00/22] KCFI support
Date: Tue, 27 Sep 2022 09:29:44 +0200	[thread overview]
Message-ID: <YzKmaCczYFk6k8S/@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CAMe9rOrHe9XD2D+pZJrKo1DxkLMQggDOFXQJfTgEO+xp0dybdw@mail.gmail.com>

On Mon, Sep 26, 2022 at 01:16:04PM -0700, H.J. Lu wrote:
> On Mon, Sep 26, 2022 at 5:39 AM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Thu, Sep 08, 2022 at 02:54:42PM -0700, Sami Tolvanen wrote:
> > > KCFI is a forward-edge control-flow integrity scheme in the upcoming
> > > Clang 16 release, which is more suitable for kernel use than the
> > > existing CFI scheme used by CONFIG_CFI_CLANG. KCFI doesn't require
> > > LTO, doesn't alter function references to point to a jump table, and
> > > won't break function address equality.
> > >
> > > This series replaces the current arm64 CFI implementation with KCFI
> > > and adds support for x86_64.
> > >
> > > KCFI requires assembly functions that are indirectly called from C
> > > code to be annotated with type identifiers. As type information is
> > > only available in C, the compiler emits expected type identifiers
> > > into the symbol table, so they can be referenced from assembly
> > > without having to hardcode type hashes. Patch 6 adds helper macros
> > > for annotating functions, and patches 9 and 20 add annotations.
> > >
> > > In case of a type mismatch, KCFI always traps. To support error
> > > handling, the compiler generates a .kcfi_traps section for x86_64,
> > > which contains the locations of each trap, and for arm64, encodes
> > > the necessary register information to the ESR. Patches 10 and 22 add
> > > arch-specific error handlers.
> > >
> > > To test this series, you'll need a ToT Clang toolchain. The series
> > > is also available pn GitHub:
> > >
> > >   https://github.com/samitolvanen/linux/commits/kcfi-v5
> >
> > As mentioned at plumbers, my only concern is somewhat excessive use of
> > CFI_CLANG as oposed to something more compiler neutral. But I suppose
> > that's something we can cleanup/fix when GCC grows support for this.
> >
> > Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > Tested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> >
> > (as in I ran kCFI + call-depth-tracking + FineIBT on a bunch of
> > hardware)
> >
> > HJL, can you look at adding kCFI support to GCC ?
> 
> Adding -fsanitize=kcfi to GCC is a big effort.  Please open a
> GCC bug:
> 
> https://gcc.gnu.org/bugzilla/enter_bug.cgi?product=gcc

Here goes:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107048

WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <peterz@infradead.org>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Sami Tolvanen <samitolvanen@google.com>,
	linux-kernel@vger.kernel.org, Kees Cook <keescook@chromium.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	x86@kernel.org, Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Joao Moreira <joao@overdrivepizza.com>,
	Sedat Dilek <sedat.dilek@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-hardening@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev
Subject: Re: [PATCH v5 00/22] KCFI support
Date: Tue, 27 Sep 2022 09:29:44 +0200	[thread overview]
Message-ID: <YzKmaCczYFk6k8S/@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CAMe9rOrHe9XD2D+pZJrKo1DxkLMQggDOFXQJfTgEO+xp0dybdw@mail.gmail.com>

On Mon, Sep 26, 2022 at 01:16:04PM -0700, H.J. Lu wrote:
> On Mon, Sep 26, 2022 at 5:39 AM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Thu, Sep 08, 2022 at 02:54:42PM -0700, Sami Tolvanen wrote:
> > > KCFI is a forward-edge control-flow integrity scheme in the upcoming
> > > Clang 16 release, which is more suitable for kernel use than the
> > > existing CFI scheme used by CONFIG_CFI_CLANG. KCFI doesn't require
> > > LTO, doesn't alter function references to point to a jump table, and
> > > won't break function address equality.
> > >
> > > This series replaces the current arm64 CFI implementation with KCFI
> > > and adds support for x86_64.
> > >
> > > KCFI requires assembly functions that are indirectly called from C
> > > code to be annotated with type identifiers. As type information is
> > > only available in C, the compiler emits expected type identifiers
> > > into the symbol table, so they can be referenced from assembly
> > > without having to hardcode type hashes. Patch 6 adds helper macros
> > > for annotating functions, and patches 9 and 20 add annotations.
> > >
> > > In case of a type mismatch, KCFI always traps. To support error
> > > handling, the compiler generates a .kcfi_traps section for x86_64,
> > > which contains the locations of each trap, and for arm64, encodes
> > > the necessary register information to the ESR. Patches 10 and 22 add
> > > arch-specific error handlers.
> > >
> > > To test this series, you'll need a ToT Clang toolchain. The series
> > > is also available pn GitHub:
> > >
> > >   https://github.com/samitolvanen/linux/commits/kcfi-v5
> >
> > As mentioned at plumbers, my only concern is somewhat excessive use of
> > CFI_CLANG as oposed to something more compiler neutral. But I suppose
> > that's something we can cleanup/fix when GCC grows support for this.
> >
> > Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > Tested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> >
> > (as in I ran kCFI + call-depth-tracking + FineIBT on a bunch of
> > hardware)
> >
> > HJL, can you look at adding kCFI support to GCC ?
> 
> Adding -fsanitize=kcfi to GCC is a big effort.  Please open a
> GCC bug:
> 
> https://gcc.gnu.org/bugzilla/enter_bug.cgi?product=gcc

Here goes:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107048

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-09-27  7:29 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 21:54 [PATCH v5 00/22] KCFI support Sami Tolvanen
2022-09-08 21:54 ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 01/22] treewide: Filter out CC_FLAGS_CFI Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 02/22] scripts/kallsyms: Ignore __kcfi_typeid_ Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 03/22] cfi: Remove CONFIG_CFI_CLANG_SHADOW Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 04/22] cfi: Drop __CFI_ADDRESSABLE Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 05/22] cfi: Switch to -fsanitize=kcfi Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 06/22] cfi: Add type helper macros Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 07/22] lkdtm: Emit an indirect call for CFI tests Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 08/22] psci: Fix the function type for psci_initcall_t Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 09/22] arm64: Add types to indirect called assembly functions Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 10/22] arm64: Add CFI error handling Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 11/22] arm64: Drop unneeded __nocfi attributes Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 12/22] init: Drop __nocfi from __init Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 13/22] treewide: Drop function_nocfi Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 14/22] treewide: Drop WARN_ON_FUNCTION_MISMATCH Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 15/22] treewide: Drop __cficanonical Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 16/22] objtool: Preserve special st_shndx indexes in elf_update_symbol Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:54 ` [PATCH v5 17/22] objtool: Disable CFI warnings Sami Tolvanen
2022-09-08 21:54   ` Sami Tolvanen
2022-09-08 21:55 ` [PATCH v5 18/22] kallsyms: Drop CONFIG_CFI_CLANG workarounds Sami Tolvanen
2022-09-08 21:55   ` Sami Tolvanen
2022-09-08 21:55 ` [PATCH v5 19/22] x86/tools/relocs: Ignore __kcfi_typeid_ relocations Sami Tolvanen
2022-09-08 21:55   ` Sami Tolvanen
2022-09-08 21:55 ` [PATCH v5 20/22] x86: Add types to indirectly called assembly functions Sami Tolvanen
2022-09-08 21:55   ` Sami Tolvanen
2022-09-08 21:55 ` [PATCH v5 21/22] x86/purgatory: Disable CFI Sami Tolvanen
2022-09-08 21:55   ` Sami Tolvanen
2022-09-08 21:55 ` [PATCH v5 22/22] x86: Add support for CONFIG_CFI_CLANG Sami Tolvanen
2022-09-08 21:55   ` Sami Tolvanen
2022-09-26 12:39 ` [PATCH v5 00/22] KCFI support Peter Zijlstra
2022-09-26 12:39   ` Peter Zijlstra
2022-09-26 20:16   ` H.J. Lu
2022-09-26 20:16     ` H.J. Lu
2022-09-27  7:29     ` Peter Zijlstra [this message]
2022-09-27  7:29       ` Peter Zijlstra
2022-09-26 17:20 ` Kees Cook
2022-09-26 17:20   ` Kees Cook
2022-09-28  9:01   ` Sedat Dilek
2022-09-28  9:01     ` Sedat Dilek

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=YzKmaCczYFk6k8S/@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=catalin.marinas@arm.com \
    --cc=hjl.tools@gmail.com \
    --cc=joao@overdrivepizza.com \
    --cc=jpoimboe@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=rostedt@goodmis.org \
    --cc=samitolvanen@google.com \
    --cc=sedat.dilek@gmail.com \
    --cc=will@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.