public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Kees Cook <keescook@chromium.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Will Deacon <will@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH 2/3] linux/compiler-clang.h: define function_nocfi
Date: Tue, 5 Apr 2022 17:16:02 +0100	[thread overview]
Message-ID: <YkxrQl4zDe6YSoNO@FVFF77S0Q05N> (raw)
In-Reply-To: <20220401201916.1487500-3-samitolvanen@google.com>

On Fri, Apr 01, 2022 at 01:19:15PM -0700, Sami Tolvanen wrote:
> Use __builtin_function_start() to implement the function_nocfi() macro
> when CONFIG_CFI_CLANG is selected.
> 
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> ---
>  include/linux/compiler-clang.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
> index babb1347148c..c84fec767445 100644
> --- a/include/linux/compiler-clang.h
> +++ b/include/linux/compiler-clang.h
> @@ -69,6 +69,16 @@
>  #define __nocfi		__attribute__((__no_sanitize__("cfi")))
>  #define __cficanonical	__attribute__((__cfi_canonical_jump_table__))
>  
> +#if defined(CONFIG_CFI_CLANG)
> +/*
> + * With CONFIG_CFI_CLANG, the compiler replaces function address
> + * references with the address of the function's CFI jump table
> + * entry. The function_nocfi macro always returns the address of the
> + * actual function instead.
> + */
> +#define function_nocfi(x)	__builtin_function_start(x)
> +#endif

As a heads-up, with patches 1 and 2 applied (but not patch 3), we have two
definitions of function_nocfi(), which casues the compiler to scream for every
object:

| In file included from <built-in>:3:
| In file included from ././include/linux/compiler_types.h:107:
| ./arch/arm64/include/asm/compiler.h:33:9: warning: 'function_nocfi' macro redefined [-Wmacro-redefined]
| #define function_nocfi(x) ({                                            \
|         ^
| ./include/linux/compiler-clang.h:79:9: note: previous definition is here
| #define function_nocfi(x)       __builtin_function_start(x)
|         ^
| 1 warning generated.

... which would be painful for bisection.

I suspect It's probably worth folding patches 2 and 3 together to avoid that?

Arguably we could fold the entire series together into one commit at that
point.

Thanks,
Mark.

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

  reply	other threads:[~2022-04-05 16:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-01 20:19 [PATCH 0/3] cfi: Use __builtin_function_start Sami Tolvanen
2022-04-01 20:19 ` [PATCH 1/3] kbuild: Change CFI_CLANG to depend on __builtin_function_start Sami Tolvanen
2022-04-02 13:31   ` Masahiro Yamada
2022-04-04 19:40     ` Sami Tolvanen
2022-04-04 22:52       ` Nathan Chancellor
2022-04-05  2:53         ` Kees Cook
2022-04-01 20:19 ` [PATCH 2/3] linux/compiler-clang.h: define function_nocfi Sami Tolvanen
2022-04-05 16:16   ` Mark Rutland [this message]
2022-04-01 20:19 ` [PATCH 3/3] arm64: Drop the inline assembly implementation of function_nocfi Sami Tolvanen
2022-04-04  9:03   ` Will Deacon
2022-04-05 16:23   ` Mark Rutland
2022-04-01 20:49 ` [PATCH 0/3] cfi: Use __builtin_function_start Nick Desaulniers

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=YkxrQl4zDe6YSoNO@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=keescook@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=samitolvanen@google.com \
    --cc=will@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