Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4694268imw; Tue, 12 Jul 2022 12:34:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vwrbBbgeytuoc07isGSh5Cb1WG8/F9rs5EVYaztWb6pPO0K/PHCqwcxk7DHXXEGtp/s7qk X-Received: by 2002:a17:907:1c0a:b0:72b:378f:2fa1 with SMTP id nc10-20020a1709071c0a00b0072b378f2fa1mr19210797ejc.492.1657654476870; Tue, 12 Jul 2022 12:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657654476; cv=none; d=google.com; s=arc-20160816; b=TYdC6lUK2PAP1MfPi31a1l60tOL8Bn1/ceFiUbb3fJNH/iElp4N+6rNn7E+fwEXOn2 d6wtXmKsK/4DELSdOx7payJW19s+NumNVTtg1W+68SifFB/ocShkXVnaHlpXDa4xTmFP Vg5ozLugHYenC5HKpNhRrRSYTLkst9GHlRangJI+cD5f0QXCaJ9eordnHR8/MV4guiah lvIUeZXWcgTbJ8X7L2XQ5HuzheeRA7QSHtFXoH+sI/Ujfe+O0woltH3BgLe+LoTmUnMX MtFm6bzgUx1GyUdRAbTqVqMTiu2MCDJ8ssLZYvVplyuZTaQug1GEXUPEKe1Jn6LY7Qog XUrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bQIL7b7Q7JZ9h4FQfKHQMgOh/Ss0MUYUyTbl5eJdd5A=; b=VsyRXqjxwqLsc04ZxCK8OPo1xb2aryKDc4U0dlJwwxpO3h6C+5Plerq89dmf0TqTM1 N6yLcOao8O1Hvkhge9WVUgJdsv4Q9eRRJyaedCW3+3yyJOqgFLK4jMVT4te/nMi8mqY1 7k/ID/m4g4eRkrr/5tOrcoKGlZWAZxrbsqiOBoZjNE+msGG+3ADYVzGqdC4Uaprl9w8+ x1h61F8tSdMHyMfbzxjwDC5ecwgMr6m5Y3+XrXOgvmBpq6PTs8CpnqObI2jANnyL3oVX KbLSTeDqqQfQHMAojS5a9y692fxDjNDNWdqeaxItU6hh+9i5N4eVaUt2Y2oa7Sg1yxLs 3E+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s0im9JAt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb38-20020a170907962600b0072b8ac605e1si2111011ejc.267.2022.07.12.12.34.11; Tue, 12 Jul 2022 12:34: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=@linuxfoundation.org header.s=korg header.b=s0im9JAt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234451AbiGLSu7 (ORCPT + 99 others); Tue, 12 Jul 2022 14:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234399AbiGLSu0 (ORCPT ); Tue, 12 Jul 2022 14:50:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FF99E3C0A; Tue, 12 Jul 2022 11:44:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9AF0D6186E; Tue, 12 Jul 2022 18:43:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8272EC3411C; Tue, 12 Jul 2022 18:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657651434; bh=jvHwMZhTHBgi2667p9dTXzJhBqmd7pBBtH9FrE3/mks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s0im9JAtrGWsaxNC217gtOe199BoDwIP6utvJlfXbRD8SMRAsrunGMD53trt+QWIs zQtcGjNIm8+2saFFlOS/XbWX+RoWJTr848w5J9Hi2Ciy0+qdE/viarUPGHaQU4BDgv 4BuMj1LYl2vnADNLdm6pj0eyJ7rTXxjUg0xGK02Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joe Lawrence , Miroslav Benes , Josh Poimboeuf , Andy Lavr , Peter Zijlstra , x86@kernel.org, Ben Hutchings Subject: [PATCH 5.10 044/130] objtool: Make .altinstructions section entry size consistent Date: Tue, 12 Jul 2022 20:38:10 +0200 Message-Id: <20220712183248.440753569@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220712183246.394947160@linuxfoundation.org> References: <20220712183246.394947160@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Joe Lawrence commit dc02368164bd0ec603e3f5b3dd8252744a667b8a upstream. Commit e31694e0a7a7 ("objtool: Don't make .altinstructions writable") aligned objtool-created and kernel-created .altinstructions section flags, but there remains a minor discrepency in their use of a section entry size: objtool sets one while the kernel build does not. While sh_entsize of sizeof(struct alt_instr) seems intuitive, this small deviation can cause failures with external tooling (kpatch-build). Fix this by creating new .altinstructions sections with sh_entsize of 0 and then later updating sec->sh_size as alternatives are added to the section. An added benefit is avoiding the data descriptor and buffer created by elf_create_section(), but previously unused by elf_add_alternative(). Fixes: 9bc0bb50727c ("objtool/x86: Rewrite retpoline thunk calls") Signed-off-by: Joe Lawrence Reviewed-by: Miroslav Benes Signed-off-by: Josh Poimboeuf Link: https://lore.kernel.org/r/20210822225037.54620-2-joe.lawrence@redhat.com Cc: Andy Lavr Cc: Peter Zijlstra Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- tools/objtool/arch/x86/decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -611,7 +611,7 @@ static int elf_add_alternative(struct el sec = find_section_by_name(elf, ".altinstructions"); if (!sec) { sec = elf_create_section(elf, ".altinstructions", - SHF_ALLOC, size, 0); + SHF_ALLOC, 0, 0); if (!sec) { WARN_ELF("elf_create_section");