Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp630047pxb; Tue, 5 Apr 2022 16:33:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkfIi4MN3JA2NyCAvuF3gyDIk2BZhUtZ4Gi+T7+nFaGwgH0MsXbYTYb0ugnpqwNoUk9SA5 X-Received: by 2002:a17:90b:3c02:b0:1c9:8dbf:65d1 with SMTP id pb2-20020a17090b3c0200b001c98dbf65d1mr6759373pjb.217.1649201618637; Tue, 05 Apr 2022 16:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649201618; cv=none; d=google.com; s=arc-20160816; b=Y032st8XLMQ95WgA7cWVPMLV3rp3+6FNAJP/sJsbdq/SWMUh0c2sx5Mz2gTQGKegK5 TGgmBNj0K9iDjrhEOhXZTNymLJHtEEYV+BzKbAJNC/NDEek+f4AJqXtK4HGiF9HX3E98 DFBYcy1+PvAdjZ30IY+oFoRmZFx93xDg08cix7yL08xcM72QI4QSObsEh9XCkHrDeect vH2euhyrbtJP6lPn4eVDz5XUHmhP8RXjwRahnPsQGBAi1mqbdcaJuN6OeV0y1K1IgP0H dDLREIN/huLHFXwqSwmq+qVfKp/nW2CcJcFKTuAfsgOJ1ngntgQdzDF5CYVhDzbYRbgV B//A== 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=1pXhVtkeZdGhREPmJ4VErCbWWt6h50PMYPHvTdCGp0k=; b=EBOZHvVfl++r1qsG/gVXjparvwRMabX4wC9vx91pQV976sZlVLe521fOrYUUMdljGy KIm+qDnb1LaHtCuN2J/+Du77KMhIwSi46dc5uhkhywPzydET2lKxpoTN5V5+fckYQbVe 5NtCmQrFa/XsB/1umVuzsCyt9ktxDiK3bCmRBikCAHK66aGVthvqz6w6i3M+op1OK19C tmjBM/AvEq8FgoopFIOywqEABGAemaEbYNOjuB6TZ+JpQqc6IGVMjfGDoEZRY0UfWfZB qXzeDf1Q4CshfgH99bx4KU3/7vgN3dq9a8JOmaKx3TxlIxyenwsYsk9HFnz58j4MQnef 6CLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GhgcQPlI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id ip12-20020a17090b314c00b001c664d0720bsi3472150pjb.69.2022.04.05.16.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:33:38 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GhgcQPlI; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CEE6D205C0; Tue, 5 Apr 2022 16:18:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238161AbiDEMhE (ORCPT + 99 others); Tue, 5 Apr 2022 08:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236394AbiDEJCy (ORCPT ); Tue, 5 Apr 2022 05:02:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A46AF101E3; Tue, 5 Apr 2022 01:54:34 -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 3EBFB614E4; Tue, 5 Apr 2022 08:54:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48F6DC385A0; Tue, 5 Apr 2022 08:54:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148873; bh=I6VMpa5qO10NI83gO4a4CfkLjhd4lXYlFeykmMzwh50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GhgcQPlIXVsjh51kClNWNLgBQIA4VYrX3Fh22TGWND3cokYNUompw1CIPowPmU4+e U/50cReSbFn1PUr/piJ1d+KM0ueUKi56XAn26GItbtEmtaPidJLP5W9tNm1thi0S5p qQ2KjGPDV9Ozha+DwTqph1T5ArZG1ngdewysqMrU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Petr Mladek , Joe Lawrence , Miroslav Benes , Michael Ellerman , Sasha Levin Subject: [PATCH 5.16 0474/1017] livepatch: Fix build failure on 32 bits processors Date: Tue, 5 Apr 2022 09:23:07 +0200 Message-Id: <20220405070408.368745221@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Christophe Leroy [ Upstream commit 2f293651eca3eacaeb56747dede31edace7329d2 ] Trying to build livepatch on powerpc/32 results in: kernel/livepatch/core.c: In function 'klp_resolve_symbols': kernel/livepatch/core.c:221:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 221 | sym = (Elf64_Sym *)sechdrs[symndx].sh_addr + ELF_R_SYM(relas[i].r_info); | ^ kernel/livepatch/core.c:221:21: error: assignment to 'Elf32_Sym *' {aka 'struct elf32_sym *'} from incompatible pointer type 'Elf64_Sym *' {aka 'struct elf64_sym *'} [-Werror=incompatible-pointer-types] 221 | sym = (Elf64_Sym *)sechdrs[symndx].sh_addr + ELF_R_SYM(relas[i].r_info); | ^ kernel/livepatch/core.c: In function 'klp_apply_section_relocs': kernel/livepatch/core.c:312:35: error: passing argument 1 of 'klp_resolve_symbols' from incompatible pointer type [-Werror=incompatible-pointer-types] 312 | ret = klp_resolve_symbols(sechdrs, strtab, symndx, sec, sec_objname); | ^~~~~~~ | | | Elf32_Shdr * {aka struct elf32_shdr *} kernel/livepatch/core.c:193:44: note: expected 'Elf64_Shdr *' {aka 'struct elf64_shdr *'} but argument is of type 'Elf32_Shdr *' {aka 'struct elf32_shdr *'} 193 | static int klp_resolve_symbols(Elf64_Shdr *sechdrs, const char *strtab, | ~~~~~~~~~~~~^~~~~~~ Fix it by using the right types instead of forcing 64 bits types. Fixes: 7c8e2bdd5f0d ("livepatch: Apply vmlinux-specific KLP relocations early") Signed-off-by: Christophe Leroy Acked-by: Petr Mladek Acked-by: Joe Lawrence Acked-by: Miroslav Benes Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/5288e11b018a762ea3351cc8fb2d4f15093a4457.1640017960.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin --- kernel/livepatch/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 335d988bd811..c0789383807b 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -190,7 +190,7 @@ static int klp_find_object_symbol(const char *objname, const char *name, return -EINVAL; } -static int klp_resolve_symbols(Elf64_Shdr *sechdrs, const char *strtab, +static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab, unsigned int symndx, Elf_Shdr *relasec, const char *sec_objname) { @@ -218,7 +218,7 @@ static int klp_resolve_symbols(Elf64_Shdr *sechdrs, const char *strtab, relas = (Elf_Rela *) relasec->sh_addr; /* For each rela in this klp relocation section */ for (i = 0; i < relasec->sh_size / sizeof(Elf_Rela); i++) { - sym = (Elf64_Sym *)sechdrs[symndx].sh_addr + ELF_R_SYM(relas[i].r_info); + sym = (Elf_Sym *)sechdrs[symndx].sh_addr + ELF_R_SYM(relas[i].r_info); if (sym->st_shndx != SHN_LIVEPATCH) { pr_err("symbol %s is not marked as a livepatch symbol\n", strtab + sym->st_name); -- 2.34.1