Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp881524pxb; Wed, 6 Apr 2022 03:06:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGLQex3NAHKrQq9mEpYRzvyfJHOWexNu7K22uJwpxQTzrLK8MXVxP3WoSjtGELeCtiXX99 X-Received: by 2002:a63:e051:0:b0:382:6aff:229a with SMTP id n17-20020a63e051000000b003826aff229amr6422824pgj.493.1649239564263; Wed, 06 Apr 2022 03:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649239564; cv=none; d=google.com; s=arc-20160816; b=z8gWSzUcu055xwX5G4JhddTofyB1HLp/2ScucQSqIJvngBNgluhJ0jXChf0Rcm9UCf YHGXqGmMSBupyHT1arkA1Cy/Ln7BAIjVfiUGXeCVmZVakx+zDH/0vaLs/GKPDiw49sTB PMEIXmPmAFBgA7lYsXz+fFzJPvg9A8svHGurpVSd7z4CaTOisLbVTvYYkmWMRtC9ZpV9 ETBtqMYpvq6L8H7XKzDaLOOMRKHyQwtlxIGcGjJhu0ZN/zmLhqjCNqmt4uH5v3I4g3yS JKr3av1uwK8NL8Ut6xkpGwAWtekrn4r+W+V7mp4kf6nEgdNYlKA4t04GVRBWXEaf95Kz cloA== 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=ODGHV7Xj4VS2Bex9s6UCmEuC2s/mjMNdErevEhV7/rJ/fRYMS+FvR4ty//YE/d+M+a R5FEXzkP4lEwkAyGbVik+dIKzo1rrKwlwuKOh9aMnan60qEh8uhgLKC0LSc2YUVAzQWW mwe/vC3TsqQ8ekoptO4qWHfoM+abRsDdeYoMQaJbP2JelWogIPNVawAS0NfTqnvsSxXk Y9uoDC6m4NcKHnFEBdCULsJe9cNjSb7ndr+9US00D8nmxGn4BHsuO1Z7n1RQQFEN1TCr zO1+URmwhR9IbVRvy/wzyQh9RRA1M/33OZI0WdcSGsW4YvDuaDOieg0coC3bg5/4p2fv knGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rXm0ifKP; 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 u11-20020a63f64b000000b003829d4ce902si14943156pgj.394.2022.04.06.03.06.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 03:06:04 -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=rXm0ifKP; 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 D72653F46A2; Wed, 6 Apr 2022 01:24:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344821AbiDFAMM (ORCPT + 99 others); Tue, 5 Apr 2022 20:12:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348953AbiDEJst (ORCPT ); Tue, 5 Apr 2022 05:48:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F38EA66C0; Tue, 5 Apr 2022 02:38:09 -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 0838561577; Tue, 5 Apr 2022 09:38:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17ED5C385A0; Tue, 5 Apr 2022 09:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151488; bh=I6VMpa5qO10NI83gO4a4CfkLjhd4lXYlFeykmMzwh50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rXm0ifKP2DSsgbnWZEj0KwTM7sm+eBYnKmIJN4Yud9y4s53GKGj63MPWDDM0N3u5G MswFhJSci6IhPRIE5bhgbFCUX5MxXUsZ9+mLS2SWo3R7wnwy6iLgOZG5mONAyWN59d Iha2AcFvn/8kePaQ5CIJuO0jeCgnJNTw66gDOTMU= 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.15 433/913] livepatch: Fix build failure on 32 bits processors Date: Tue, 5 Apr 2022 09:24:55 +0200 Message-Id: <20220405070352.824515747@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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