Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2283841rwr; Fri, 28 Apr 2023 08:22:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4CuxkF7Y24uowFIQkNg9GVdK4cLlLx37wpPjEDBMcaeejcmNy76ESc7rau4Z/QSAs5n8iL X-Received: by 2002:a17:90a:5513:b0:247:2680:2ad with SMTP id b19-20020a17090a551300b00247268002admr5571403pji.33.1682695356400; Fri, 28 Apr 2023 08:22:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682695356; cv=none; d=google.com; s=arc-20160816; b=r5nGNBCgQE33PVE+aWhv/b21cCAmwlKyN7dvClrG8XezAJnGwmb7I3bEdUWZF7saA8 tBfjgSkyINykO7Lfx1Z3tT0UMmtL9BQSWMVyNarp2qEOh1JLtmpW8IWdNnur6AYkNq3f in16WnzrJce6Je2VlfgDEHEYAO88PH0YolJ3QrvTtKTStZNFKL4mZxNzELX74OFvrv0Z 1vKDU5QINdDJPrM0DY0H2ah8AQcoPAQr594ZIVO3yrZQdREez62xBnF+t2/6hOx4Cms2 6lqZ7dTfR6Y66/KpW/uNAnxykCSldXFCkUIfJI+74RvDYkfkZzlCXwfOsZ/xx2huCimJ vNfw== 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=1gWqmK1pf0FFJ4TSP7xU2y80RRLOAbNJTnqFlNM4mlc=; b=WgCxWWUtaU0umhoGxBoEGgHyxTFI9UpQZmY79moT7jsUGt3kEkh9LlppL59YEGRE9q bUaPgR4R64G2btohhd0ACGbDHpv+t0XwDuku09cF64ot34gvftciX2fSALqiu6dJvb82 47X2SoHPUt7VW+TAlOlbn09otbeVDyTt86hfNV0mEcxnmgwtlyO+ru6Kz9qCkHW60sAQ jTfmTLFPZpj5V/avfAZfqdldYCXAL+YidwSZJb4k2F1Q6Sw3IHcM/h8DVEBTMcGJN1oD bz8xz7WQF32VfLnNuh+j8VUgg+M9LZtDtByYRiSa7AlHHMRAlJvt8mEOiyllTFCkM51X 9oZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=mxOtYJeg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a17090ab70600b00235dc16de3asi23520097pjr.16.2023.04.28.08.22.22; Fri, 28 Apr 2023 08:22:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=mxOtYJeg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230397AbjD1PTW (ORCPT + 99 others); Fri, 28 Apr 2023 11:19:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjD1PTU (ORCPT ); Fri, 28 Apr 2023 11:19:20 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AF7B1FED for ; Fri, 28 Apr 2023 08:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=1gWqmK1pf0FFJ4TSP7xU2y80RRLOAbNJTnqFlNM4mlc=; b=mxOtYJegObyEWHQUWDnHdnqDV2 YfXcE224wfFB3l7fXDc6XtignNaOwjIpY5BuH2NVvfEPgPv0GxE9W0/Tw6Du5C7H+s7/bV4WIlsnX Fj4rJH5BcKmQP8DXrKgi8k3IOd+3+gUPu+PqRR37ZDM/PjBERIX6DwvAbl2o8CGF27vPoYEYLldDC xRmNJQb80K+npd79u48CI67ZT8v00ru6NZr3U/tpgYNIuGD1C5wsl1l7CmssmsMq+8qDtjNXF5iVc U9jEVOUmjsA7jrU0l6S0OnNqyH4sMGMFPHoTwGk8PBTPkIFa/If9tHi58I4OxNKCuLVTTDzboU73r 3ra7qnNw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1psPrr-00DMpp-1u; Fri, 28 Apr 2023 15:18:41 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 12697300300; Fri, 28 Apr 2023 17:18:38 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E8450241AEB03; Fri, 28 Apr 2023 17:18:37 +0200 (CEST) Date: Fri, 28 Apr 2023 17:18:37 +0200 From: Peter Zijlstra To: Hou Wenlong Cc: linux-kernel@vger.kernel.org, Thomas Garnier , Lai Jiangshan , Kees Cook , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Josh Poimboeuf , Christophe Leroy , Sathvika Vasireddy Subject: Re: [PATCH RFC 34/43] objtool: Adapt indirect call of __fentry__() for PIE support Message-ID: <20230428151837.GD1449475@hirez.programming.kicks-ass.net> References: <804a7d5a4ef939b767ae540ebbb24a811d99e100.1682673543.git.houwenlong.hwl@antgroup.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <804a7d5a4ef939b767ae540ebbb24a811d99e100.1682673543.git.houwenlong.hwl@antgroup.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 28, 2023 at 05:51:14PM +0800, Hou Wenlong wrote: > --- a/tools/objtool/arch/x86/decode.c > +++ b/tools/objtool/arch/x86/decode.c > @@ -747,15 +747,21 @@ void arch_initial_func_cfi_state(struct cfi_init_state *state) > > const char *arch_nop_insn(int len) > { > - static const char nops[5][5] = { > + static const char nops[6][6] = { > { BYTES_NOP1 }, > { BYTES_NOP2 }, > { BYTES_NOP3 }, > { BYTES_NOP4 }, > { BYTES_NOP5 }, > + /* > + * For PIE kernel, use a 5-byte nop > + * and 1-byte nop to keep the frace > + * hooking algorithm working correct. > + */ > + { BYTES_NOP5, BYTES_NOP1 }, > }; > - if (len < 1 || len > 5) { > + if (len < 1 || len > 6) { > WARN("invalid NOP size: %d\n", len); > return NULL; > } Like Steve already said, this is broken, we hard rely on these things being single instructions, this must absolutely be BYTES_NOP6. And yes, then you get to fix a whole lot more.