Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1783303rda; Tue, 24 Oct 2023 03:14:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4OJNH0nl33GDAzd1PTAAOVBWBDN2HWWYKkLPS/QR0QZcwF/GGKSRr/9ENr243H1gVpKfM X-Received: by 2002:a17:90a:56:b0:27d:1ec3:4367 with SMTP id 22-20020a17090a005600b0027d1ec34367mr9437678pjb.0.1698142451115; Tue, 24 Oct 2023 03:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698142451; cv=none; d=google.com; s=arc-20160816; b=jOa6neWu/9cctZ/ogE5/dPzJJm/q56Yqx0g+bGSOVe0R15bXe1ZJlSPRiC8bfKmhIR BjUA/SATvFohC0Bzs1/jVN+phKb1XBZhXBCLJWh8MmAUkZcCtqcdf0vB4Be+QIupeglV h1R5oQXzTbxDJTj1JvXolR9Yf42hPQcehwWX1BDq/9cji9kGgnxiD0WRLw6mFnNQcd2V vHbegoccA0bV5JkrH3GKcL2SJvtF5duMuuJE/OkR0f8YJZ7MFcN9qnTkFQR4bXSzwIeS KLDN6kdg4Oe9BKNaARsmbk1QcPhFMS6tgte37cD98B0hNLkNjtSs/h+CI5KoScVlHEMz k1fg== 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; bh=uI8UPpRpf0n0ud2nxtOPpYDZvbhnRAa95FFzR47fsBw=; fh=Y0oiXcsBROXqz8RXjXXWfkJkvIT3nQqdANzNfuO2KCk=; b=KVQq5bHA19wZLmt8Bk8rv3EK2dQKMiYMX+UDlsRshzaCpQUnkFAD8Q5w8TMI6ks87r 35rr9Uk4bbFj3XpokZ5tf1Y6x+ESfFBzDCjOh/l8RwSH/df6qOXewJkeAxmhrKCUs43S JJ8us2KhzFgwkGttvHWaek6V+avSgBTx8jEUY6Kka78gGXgw/L3OEZ1BafMpaNfptDPM nPVKi5dcqVDO7kHqacksaawmm3emRYGNUi6ZJBSN92vr/Z1uS6F96KvPl8n2p/B8EgGM Q/5XXwK8zLtX2g5CvJArIoTUB5XjQdzraefEhUqUEac0MOxRT5NwA1j3fRo8x02nNhGH nwPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id e6-20020a17090a728600b00277624ffa82si10529214pjg.86.2023.10.24.03.14.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 03:14:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B061680B993D; Tue, 24 Oct 2023 03:14:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234234AbjJXKOC (ORCPT + 99 others); Tue, 24 Oct 2023 06:14:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233942AbjJXKOB (ORCPT ); Tue, 24 Oct 2023 06:14:01 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AFA9B118; Tue, 24 Oct 2023 03:13:58 -0700 (PDT) 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231024010954.6768-1-quic_aiquny@quicinc.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 24 Oct 2023 03:14:08 -0700 (PDT) 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 >