All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Kees Cook <keescook@chromium.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Will Deacon <will@kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	llvm@lists.linux.dev
Subject: Re: [PATCH 1/3] kbuild: Change CFI_CLANG to depend on __builtin_function_start
Date: Sat, 2 Apr 2022 22:31:03 +0900	[thread overview]
Message-ID: <CAK7LNAQoJWUscyxXVnOQ9924MYZwaZGgfBYSzmjJxKH_UC0Pkw@mail.gmail.com> (raw)
In-Reply-To: <20220401201916.1487500-2-samitolvanen@google.com>

On Sat, Apr 2, 2022 at 5:19 AM Sami Tolvanen <samitolvanen@google.com> wrote:
>
> Clang 14 added support for the __builtin_function_start()
> built-in function, which allows us to implement function_nocfi()
> without architecture-specific inline assembly. This patch changes
> CONFIG_CFI_CLANG to depend on the built-in and effectively upgrades
> the minimum supported compiler version for CFI to Clang 14.

From this description, I think the straight-forward change would be:

    depends on CLANG_VERSION >= 120000
-->
    depends on CLANG_VERSION >= 140000

Any reason to avoid this?


>
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> ---
>  arch/Kconfig | 5 +----
>  init/Kconfig | 3 +++
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 29b0167c088b..eecfc2809781 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -723,10 +723,7 @@ config ARCH_SUPPORTS_CFI_CLANG
>  config CFI_CLANG
>         bool "Use Clang's Control Flow Integrity (CFI)"
>         depends on LTO_CLANG && ARCH_SUPPORTS_CFI_CLANG
> -       # Clang >= 12:
> -       # - https://bugs.llvm.org/show_bug.cgi?id=46258
> -       # - https://bugs.llvm.org/show_bug.cgi?id=47479
> -       depends on CLANG_VERSION >= 120000
> +       depends on CC_HAS_BUILTIN_FUNCTION_START
>         select KALLSYMS
>         help
>           This option enables Clang’s forward-edge Control Flow Integrity
> diff --git a/init/Kconfig b/init/Kconfig
> index ddcbefe535e9..f024fd353373 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -86,6 +86,9 @@ config CC_HAS_ASM_INLINE
>  config CC_HAS_NO_PROFILE_FN_ATTR
>         def_bool $(success,echo '__attribute__((no_profile_instrument_function)) int x();' | $(CC) -x c - -c -o /dev/null -Werror)
>
> +config CC_HAS_BUILTIN_FUNCTION_START
> +       def_bool $(success,echo 'void f(void) {}; void *p = __builtin_function_start(f);' | $(CC) -x c - -c -o /dev/null)
> +
>  config PAHOLE_VERSION
>         int
>         default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
> --
> 2.35.0
>


--
Best Regards
Masahiro Yamada

WARNING: multiple messages have this Message-ID (diff)
From: Masahiro Yamada <masahiroy@kernel.org>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Kees Cook <keescook@chromium.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Will Deacon <will@kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	llvm@lists.linux.dev
Subject: Re: [PATCH 1/3] kbuild: Change CFI_CLANG to depend on __builtin_function_start
Date: Sat, 2 Apr 2022 22:31:03 +0900	[thread overview]
Message-ID: <CAK7LNAQoJWUscyxXVnOQ9924MYZwaZGgfBYSzmjJxKH_UC0Pkw@mail.gmail.com> (raw)
In-Reply-To: <20220401201916.1487500-2-samitolvanen@google.com>

On Sat, Apr 2, 2022 at 5:19 AM Sami Tolvanen <samitolvanen@google.com> wrote:
>
> Clang 14 added support for the __builtin_function_start()
> built-in function, which allows us to implement function_nocfi()
> without architecture-specific inline assembly. This patch changes
> CONFIG_CFI_CLANG to depend on the built-in and effectively upgrades
> the minimum supported compiler version for CFI to Clang 14.

From this description, I think the straight-forward change would be:

    depends on CLANG_VERSION >= 120000
-->
    depends on CLANG_VERSION >= 140000

Any reason to avoid this?


>
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> ---
>  arch/Kconfig | 5 +----
>  init/Kconfig | 3 +++
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 29b0167c088b..eecfc2809781 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -723,10 +723,7 @@ config ARCH_SUPPORTS_CFI_CLANG
>  config CFI_CLANG
>         bool "Use Clang's Control Flow Integrity (CFI)"
>         depends on LTO_CLANG && ARCH_SUPPORTS_CFI_CLANG
> -       # Clang >= 12:
> -       # - https://bugs.llvm.org/show_bug.cgi?id=46258
> -       # - https://bugs.llvm.org/show_bug.cgi?id=47479
> -       depends on CLANG_VERSION >= 120000
> +       depends on CC_HAS_BUILTIN_FUNCTION_START
>         select KALLSYMS
>         help
>           This option enables Clang’s forward-edge Control Flow Integrity
> diff --git a/init/Kconfig b/init/Kconfig
> index ddcbefe535e9..f024fd353373 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -86,6 +86,9 @@ config CC_HAS_ASM_INLINE
>  config CC_HAS_NO_PROFILE_FN_ATTR
>         def_bool $(success,echo '__attribute__((no_profile_instrument_function)) int x();' | $(CC) -x c - -c -o /dev/null -Werror)
>
> +config CC_HAS_BUILTIN_FUNCTION_START
> +       def_bool $(success,echo 'void f(void) {}; void *p = __builtin_function_start(f);' | $(CC) -x c - -c -o /dev/null)
> +
>  config PAHOLE_VERSION
>         int
>         default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
> --
> 2.35.0
>


--
Best Regards
Masahiro Yamada

_______________________________________________
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-02 13:38 UTC|newest]

Thread overview: 24+ 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 ` Sami Tolvanen
2022-04-01 20:19 ` [PATCH 1/3] kbuild: Change CFI_CLANG to depend on __builtin_function_start Sami Tolvanen
2022-04-01 20:19   ` Sami Tolvanen
2022-04-02 13:31   ` Masahiro Yamada [this message]
2022-04-02 13:31     ` Masahiro Yamada
2022-04-04 19:40     ` Sami Tolvanen
2022-04-04 19:40       ` Sami Tolvanen
2022-04-04 22:52       ` Nathan Chancellor
2022-04-04 22:52         ` Nathan Chancellor
2022-04-05  2:53         ` Kees Cook
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-01 20:19   ` Sami Tolvanen
2022-04-05 16:16   ` Mark Rutland
2022-04-05 16:16     ` Mark Rutland
2022-04-01 20:19 ` [PATCH 3/3] arm64: Drop the inline assembly implementation of function_nocfi Sami Tolvanen
2022-04-01 20:19   ` Sami Tolvanen
2022-04-04  9:03   ` Will Deacon
2022-04-04  9:03     ` Will Deacon
2022-04-05 16:23   ` Mark Rutland
2022-04-05 16:23     ` Mark Rutland
2022-04-01 20:49 ` [PATCH 0/3] cfi: Use __builtin_function_start Nick Desaulniers
2022-04-01 20:49   ` 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=CAK7LNAQoJWUscyxXVnOQ9924MYZwaZGgfBYSzmjJxKH_UC0Pkw@mail.gmail.com \
    --to=masahiroy@kernel.org \
    --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=mark.rutland@arm.com \
    --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 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.