From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3EF8C43381 for ; Fri, 19 Mar 2021 11:56:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C8F264F70 for ; Fri, 19 Mar 2021 11:56:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbhCSL4J (ORCPT ); Fri, 19 Mar 2021 07:56:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:51968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbhCSLzx (ORCPT ); Fri, 19 Mar 2021 07:55:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0932460233; Fri, 19 Mar 2021 11:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616154952; bh=xEggSgwLTsxsRSBCrktgETXhVT4kXbKFtICLOdi9pY4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AvllA/pNHM01eptUHALZqK7jqyXMvVBQyy3Hx/6pWSGz2zC6ZVyEFWmPuJSVPDd3R 6I77gkfy9yLXyZfPIB0HjJtdc62tYVEuDd1/RNd7GoPlKTTQRniu0+Gv41CynFYGdq 0DdY5Uh7Znaay4BVVuRq/Q79Ak9ueJzm9S6+Bvr8= Date: Fri, 19 Mar 2021 12:55:50 +0100 From: Greg Kroah-Hartman To: Alexandre Chartre Cc: Nicolas Boichat , stable@vger.kernel.org, Thomas Gleixner , Peter Zijlstra , Arnd Bergmann , Benjamin Herrenschmidt , Christopher Li , Daniel Axtens , Masahiro Yamada , Michael Ellerman , Michal Marek , "Naveen N. Rao" , Nicholas Piggin , Paul Mackerras , Sasha Levin , linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sparse@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [for-stable-4.19 PATCH 1/2] vmlinux.lds.h: Create section for protection against instrumentation Message-ID: References: <20210318235416.794798-1-drinkcat@chromium.org> <20210319075410.for-stable-4.19.1.I222f801866f71be9f7d85e5b10665cd4506d78ec@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 19, 2021 at 12:20:22PM +0100, Alexandre Chartre wrote: > > On 3/19/21 11:39 AM, Greg Kroah-Hartman wrote: > > On Fri, Mar 19, 2021 at 07:54:15AM +0800, Nicolas Boichat wrote: > > > From: Thomas Gleixner > > > > > > commit 6553896666433e7efec589838b400a2a652b3ffa upstream. > > > > > > Some code pathes, especially the low level entry code, must be protected > > > against instrumentation for various reasons: > > > > > > - Low level entry code can be a fragile beast, especially on x86. > > > > > > - With NO_HZ_FULL RCU state needs to be established before using it. > > > > > > Having a dedicated section for such code allows to validate with tooling > > > that no unsafe functions are invoked. > > > > > > Add the .noinstr.text section and the noinstr attribute to mark > > > functions. noinstr implies notrace. Kprobes will gain a section check > > > later. > > > > > > Provide also a set of markers: instrumentation_begin()/end() > > > > > > These are used to mark code inside a noinstr function which calls > > > into regular instrumentable text section as safe. > > > > > > The instrumentation markers are only active when CONFIG_DEBUG_ENTRY is > > > enabled as the end marker emits a NOP to prevent the compiler from merging > > > the annotation points. This means the objtool verification requires a > > > kernel compiled with this option. > > > > > > Signed-off-by: Thomas Gleixner > > > Reviewed-by: Alexandre Chartre > > > Acked-by: Peter Zijlstra > > > Link: https://lkml.kernel.org/r/20200505134100.075416272@linutronix.de > > > > > > [Nicolas: context conflicts in: > > > arch/powerpc/kernel/vmlinux.lds.S > > > include/asm-generic/vmlinux.lds.h > > > include/linux/compiler.h > > > include/linux/compiler_types.h] > > > Signed-off-by: Nicolas Boichat > > > > Did you build this on x86? > > > > I get the following build error: > > > > ld:./arch/x86/kernel/vmlinux.lds:20: syntax error > > > > And that line looks like: > > > > . = ALIGN(8); *(.text.hot .text.hot.*) *(.text .text.fixup) *(.text.unlikely .text.unlikely.*) *(.text.unknown .text.unknown.*) . = ALIGN(8); __noinstr_text_start = .; *(.__attribute__((noinline)) __attribute__((no_instrument_function)) __attribute((__section__(".noinstr.text"))).text) __noinstr_text_end = .; *(.text..refcount) *(.ref.text) *(.meminit.text*) *(.memexit.text*) > > > > In the NOINSTR_TEXT macro, noinstr is expanded with the value of the noinstr > macro from linux/compiler_types.h while it shouldn't. > > The problem is possibly that the noinstr macro is defined for assembly. Make > sure that the macro is not defined for assembly e.g.: > > #ifndef __ASSEMBLY__ > > /* Section for code which can't be instrumented at all */ > #define noinstr \ > noinline notrace __attribute((__section__(".noinstr.text"))) > > #endif This implies that the backport is incorrect, so I'll wait for an updated version... thanks, greg k-h From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A8B8C433E0 for ; Fri, 19 Mar 2021 11:56:24 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0F68964F65 for ; Fri, 19 Mar 2021 11:56:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F68964F65 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4F22RT26fkz3c5Z for ; Fri, 19 Mar 2021 22:56:21 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=AvllA/pN; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linuxfoundation.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=gregkh@linuxfoundation.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=AvllA/pN; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4F22R06zhPz2ym4 for ; Fri, 19 Mar 2021 22:55:55 +1100 (AEDT) Received: by mail.kernel.org (Postfix) with ESMTPSA id 0932460233; Fri, 19 Mar 2021 11:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616154952; bh=xEggSgwLTsxsRSBCrktgETXhVT4kXbKFtICLOdi9pY4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AvllA/pNHM01eptUHALZqK7jqyXMvVBQyy3Hx/6pWSGz2zC6ZVyEFWmPuJSVPDd3R 6I77gkfy9yLXyZfPIB0HjJtdc62tYVEuDd1/RNd7GoPlKTTQRniu0+Gv41CynFYGdq 0DdY5Uh7Znaay4BVVuRq/Q79Ak9ueJzm9S6+Bvr8= Date: Fri, 19 Mar 2021 12:55:50 +0100 From: Greg Kroah-Hartman To: Alexandre Chartre Subject: Re: [for-stable-4.19 PATCH 1/2] vmlinux.lds.h: Create section for protection against instrumentation Message-ID: References: <20210318235416.794798-1-drinkcat@chromium.org> <20210319075410.for-stable-4.19.1.I222f801866f71be9f7d85e5b10665cd4506d78ec@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , linux-arch@vger.kernel.org, Nicolas Boichat , Arnd Bergmann , linux-kbuild@vger.kernel.org, Peter Zijlstra , Christopher Li , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Masahiro Yamada , linux-sparse@vger.kernel.org, Michal Marek , Paul Mackerras , Nicholas Piggin , Thomas Gleixner , linuxppc-dev@lists.ozlabs.org, "Naveen N. Rao" , Daniel Axtens Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Mar 19, 2021 at 12:20:22PM +0100, Alexandre Chartre wrote: > > On 3/19/21 11:39 AM, Greg Kroah-Hartman wrote: > > On Fri, Mar 19, 2021 at 07:54:15AM +0800, Nicolas Boichat wrote: > > > From: Thomas Gleixner > > > > > > commit 6553896666433e7efec589838b400a2a652b3ffa upstream. > > > > > > Some code pathes, especially the low level entry code, must be protected > > > against instrumentation for various reasons: > > > > > > - Low level entry code can be a fragile beast, especially on x86. > > > > > > - With NO_HZ_FULL RCU state needs to be established before using it. > > > > > > Having a dedicated section for such code allows to validate with tooling > > > that no unsafe functions are invoked. > > > > > > Add the .noinstr.text section and the noinstr attribute to mark > > > functions. noinstr implies notrace. Kprobes will gain a section check > > > later. > > > > > > Provide also a set of markers: instrumentation_begin()/end() > > > > > > These are used to mark code inside a noinstr function which calls > > > into regular instrumentable text section as safe. > > > > > > The instrumentation markers are only active when CONFIG_DEBUG_ENTRY is > > > enabled as the end marker emits a NOP to prevent the compiler from merging > > > the annotation points. This means the objtool verification requires a > > > kernel compiled with this option. > > > > > > Signed-off-by: Thomas Gleixner > > > Reviewed-by: Alexandre Chartre > > > Acked-by: Peter Zijlstra > > > Link: https://lkml.kernel.org/r/20200505134100.075416272@linutronix.de > > > > > > [Nicolas: context conflicts in: > > > arch/powerpc/kernel/vmlinux.lds.S > > > include/asm-generic/vmlinux.lds.h > > > include/linux/compiler.h > > > include/linux/compiler_types.h] > > > Signed-off-by: Nicolas Boichat > > > > Did you build this on x86? > > > > I get the following build error: > > > > ld:./arch/x86/kernel/vmlinux.lds:20: syntax error > > > > And that line looks like: > > > > . = ALIGN(8); *(.text.hot .text.hot.*) *(.text .text.fixup) *(.text.unlikely .text.unlikely.*) *(.text.unknown .text.unknown.*) . = ALIGN(8); __noinstr_text_start = .; *(.__attribute__((noinline)) __attribute__((no_instrument_function)) __attribute((__section__(".noinstr.text"))).text) __noinstr_text_end = .; *(.text..refcount) *(.ref.text) *(.meminit.text*) *(.memexit.text*) > > > > In the NOINSTR_TEXT macro, noinstr is expanded with the value of the noinstr > macro from linux/compiler_types.h while it shouldn't. > > The problem is possibly that the noinstr macro is defined for assembly. Make > sure that the macro is not defined for assembly e.g.: > > #ifndef __ASSEMBLY__ > > /* Section for code which can't be instrumented at all */ > #define noinstr \ > noinline notrace __attribute((__section__(".noinstr.text"))) > > #endif This implies that the backport is incorrect, so I'll wait for an updated version... thanks, greg k-h