Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1327365pxf; Fri, 19 Mar 2021 04:57:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwePW50XaEkaNgokjY+ekWNnfefO8Lmx/WgwNMa6JFEpd//Thx0eJe1SepE6rAR07NRFkvN X-Received: by 2002:aa7:cb0a:: with SMTP id s10mr8950098edt.36.1616155047113; Fri, 19 Mar 2021 04:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616155047; cv=none; d=google.com; s=arc-20160816; b=I0w5S0a4yLgScyWrHr9APxiJVlVVioIJxoIR0YpboRI3HgJ9ToS2I1hV22/J/xnssQ DBhpUgpFFS1afwFimOx/nsZKAqea8F0dWhvFiQf20xlZh+5kMZMTgMyO81a8DqPpvfNn o4CZUD4hBKuyexLPYkhVVQGz/7ad3UT7kCfAc1CFL8P7rc+AvijyDujlDaVu0GzNRXt4 YcgnrFk9Utu/ZoBDwDZQR6CxmMJQ8gd1GENVfi3EEHcWQn9+AGGpwWx381N7I604JRQj kFPhWez14PhAhjA0gJnLOJZbqFj0iN3gohLAQL+Psy9AVlCmD58UMwFwixYbjzSbfYU9 LGMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Dq0ECfb7Q+tGNdUVaUk2BmyS8x3LEV0RL3ee3AfatKU=; b=KCmjabS2SVRrj9Cmt8bG7ba7Xt52NiaUeWMvf7ZlyvQkfP1zm8D2XXs/vjE3EKcOXr 3bti9AjaU5hSF+6Ev0nWgYPvuNnz7Dax7LYMcb2jCnTWvNFpEkAgzp5FWH5sxfLeC+Zw QYo6mQriNkH2q5s7iFOKISVOaQWk3lmIrAVOYin9503swkgOa2bkVt8KmH948FZwtxmD xUCMdG2YqFLfPK48oNffyB5EzFgWxVlBqFv6fSc0IE9KaJYlri1jCa289W22Xwll5lDp QYXJpbBEljorFW5Vk7Ug1kvzzo6nwdhBwnAoqf7izUYBooQMzLs7uRwO7vvKQ1aI10hZ OB8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="AvllA/pN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gv19si4118382ejc.109.2021.03.19.04.57.05; Fri, 19 Mar 2021 04:57:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="AvllA/pN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbhCSL4J (ORCPT + 99 others); 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