From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC218C07545 for ; Tue, 24 Oct 2023 10:14:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qv0Iac7s4/0J90CbLSStohoUzgb7uKLLgb8tLdMp+qM=; b=kIvWg1h8ptWcWz aeOAXH3oluctMK2xL5tsY2KhAsx3z07luUYEnBmmwevsxcEVNx6JiWRqe+zYuc3l9XrSRyiMdLUh3 3X+CNHIej0wsJoRbgkNUhR94r7bhTyR0WbcKRPKZVqcvkOO206JR+EgxavoIiSzP3cD9M2vTvu7sJ R/179bX+KKrrP6UnfoAw4p0sRJkXkJYYOu8RVAoxn1jkLbqhP3BqEcXTb4QxSQRziqErMBVsH1jrf CLqOh8lNFnVMXlXI3rK8azrBO8xHmrKbD9bnq5t11is4IDx6lg2ygaN/y3dVx/S1hsQ7QSX4PQ95Y hREv7ER4kl8/2OL+95kA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvEQG-009P7S-3A; Tue, 24 Oct 2023 10:14:04 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvEQD-009P6T-1O for linux-arm-kernel@lists.infradead.org; Tue, 24 Oct 2023 10:14:03 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2845F2F4; Tue, 24 Oct 2023 03:14:39 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.68.12]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A36513F64C; Tue, 24 Oct 2023 03:13:56 -0700 (PDT) Date: Tue, 24 Oct 2023 11:13:47 +0100 From: Mark Rutland To: Maria Yu Cc: catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@quicinc.com, linux-arm-msm@vger.kernel.org, ardb@kernel.org Subject: Re: [PATCH v2] arm64: module: PLT allowed even !RANDOM_BASE Message-ID: References: <20231024010954.6768-1-quic_aiquny@quicinc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231024010954.6768-1-quic_aiquny@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231024_031401_541369_2E7647F2 X-CRM114-Status: GOOD ( 20.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Oct 24, 2023 at 09:09:54AM +0800, Maria Yu wrote: > Module PLT feature can be enabled even when RANDOM_BASE is disabled. > Break BLT entry counts of relocation types will make module plt entry > allocation fail and finally exec format error for even correct and plt > allocation available modules. The patch itself looks good; it would be better if we could make the commit message explicit that this is a fix. Could we please replace that with: | arm64: module: fix PLT counting when CONFIG_RANDOMIZE_BASE=n | | The counting of module PLTs has been broken when CONFIG_RANDOMIZE_BASE=n | since commit: | | 3e35d303ab7d22c4 ("arm64: module: rework module VA range selection") | | Prior to that commit, when CONFIG_RANDOMIZE_BASE=n, the kernel image and | all modules were placed within a 128M region, and no PLTs were necessary | for B or BL. Hence count_plts() and partition_branch_plt_relas() skipped | handling B and BL when CONFIG_RANDOMIZE_BASE=n. | | After that commit, modules can be placed anywhere within a 2G window | regardless of CONFIG_RANDOMIZE_BASE, and hence PLTs may be necessary for | B and BL even when CONFIG_RANDOMIZE_BASE=n. Unfortunately that commit | failed to update count_plts() and partition_branch_plt_relas() | accordingly. | | Due to this, module_emit_plt_entry() may fail if an insufficient number | of PLT entries have been reserved, resulting in modules failing to load | with -ENOEXEC. | | Fix this by counting PLTs regardless of CONFIG_RANDOMIZE_BASE in | count_plts() and partition_branch_plt_relas(). ... and add a fixes tag: Fixes: 3e35d303ab7d22c4 ("arm64: module: rework module VA range selection") With that: Reviewed-by: Mark Rutland Mark. > > Signed-off-by: Maria Yu > --- > arch/arm64/kernel/module-plts.c | 6 ------ > 1 file changed, 6 deletions(-) > > diff --git a/arch/arm64/kernel/module-plts.c b/arch/arm64/kernel/module-plts.c > index bd69a4e7cd60..79200f21e123 100644 > --- a/arch/arm64/kernel/module-plts.c > +++ b/arch/arm64/kernel/module-plts.c > @@ -167,9 +167,6 @@ static unsigned int count_plts(Elf64_Sym *syms, Elf64_Rela *rela, int num, > switch (ELF64_R_TYPE(rela[i].r_info)) { > case R_AARCH64_JUMP26: > case R_AARCH64_CALL26: > - if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE)) > - break; > - > /* > * We only have to consider branch targets that resolve > * to symbols that are defined in a different section. > @@ -269,9 +266,6 @@ static int partition_branch_plt_relas(Elf64_Sym *syms, Elf64_Rela *rela, > { > int i = 0, j = numrels - 1; > > - if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE)) > - return 0; > - > while (i < j) { > if (branch_rela_needs_plt(syms, &rela[i], dstidx)) > i++; > > base-commit: 05d3ef8bba77c1b5f98d941d8b2d4aeab8118ef1 > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel