Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp303095pxj; Fri, 7 May 2021 08:58:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpu0VZgjnU98ultY9iHVKSPXZUgX+lBkTCSa/n8tzW6Pkqpw2F2tNePbAr4Z3TcaAIcCwI X-Received: by 2002:aa7:cb89:: with SMTP id r9mr12339252edt.245.1620403094509; Fri, 07 May 2021 08:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620403094; cv=none; d=google.com; s=arc-20160816; b=LZsw/bxrC2DYfPcR7IGdn33Jh71Isbdzw+nYaIVUrJEkMRu9OzOXS6z5r5kviog3l6 actpIzHTDeU+iCVJlnfEpaTdcoqNLQb7S+XzYdgxTmGay6OdWNon9RMvaNowBxmQLcj4 oYlTdC+oJJhW0mwdNHGjVqFhg206rhllOkz/pQgm5vQXmYb+hLdY8SEJFd6SemoW/hmI 6zbSiQ2hQb59wowPXi/2aBMbG98bsQdLWjWuygIIajc2DIqzVC7Z7aT9vOOdVHOlk9Jl RcpNACV5KJp0SQsYLgWLFUmvzlB5EAx6vzglpX1idBLyE0VezYRVmbRsPUcBsO2xBbjN 6nKg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ZYHw38IvPyBQrlud8/YLLHrjhxUX6Loh7xCjhKW380I=; b=UwL0rzuD7mvjZtncNYvnEfmai3SxnQ3yTf5+U0592hK/wPtq1S6BJN6M8R8TiB9JXd ruH1gd51I+Hut/Y/gUQlhX685SrgKvFU48p06tXtAvhnS2HXup9xzRPaFgD7RtmKhuE1 fReUhFC0rPBzrK4YZWmbrmNBkrdEu99JS6C5m2r5P2hHEvhxkOVBjJEv7LtJZzr1qzW7 mJ4zhZt8sd/7RMhTmyxJy/VX1vgwRDNb2psa5itdFIqzgFd9d0ymuD38CIfhH9Ouw4Zl RchQNcLAmHF2OjukdeEplhLsm7gG8YHqwhCUzN5leaqWG5wvqTG/77CMpStidIZ8j3VA 3R9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MbqFpogP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f6si5353727ejt.379.2021.05.07.08.57.50; Fri, 07 May 2021 08:58:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MbqFpogP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234346AbhEGMVq (ORCPT + 99 others); Fri, 7 May 2021 08:21:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:49208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbhEGMVp (ORCPT ); Fri, 7 May 2021 08:21:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 862746144F; Fri, 7 May 2021 12:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620390045; bh=+UDEkNthDyGtOTchh5vC4lABQ4yWmQP1bEakFLVxwqA=; h=From:To:Cc:Subject:Date:From; b=MbqFpogPuHpoSOYx5L+TYLP/gBK2PW4sjx96WeYJoujBi7bdXbYX01kKDiAC/GPD9 DLtrqzWrigSSoIzGxB8DdvDiYyUjwEhDa8B6hnBpkd/N+NpQJ6nWlkqJtKrcXVZ45M uZdqldj0c5tYEwruktElmk/ysc76vPeIZ+BFSRD1mBlBQDBUQCHvlGR9I8lD10e0Ph nS6/KZC8nFYKXlol/QJ7lhG6Oul0jgvd9zbWWNjTxK/PRgV751384pZklx6iXDrEiN 5KfKu7aDADwP47esOLMeGYP7yFPIUZmAR91PhRMxUABomBZaRgNg/mRVFPtxhVG6Db HUiVgYHOReyxg== From: Jessica Yu To: Russell King Cc: Peter Zijlstra , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jessica Yu Subject: [PATCH] ARM: module: treat exit sections the same as init sections when !CONFIG_MODULE_UNLOAD Date: Fri, 7 May 2021 14:13:22 +0200 Message-Id: <20210507121322.6441-1-jeyu@kernel.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dynamic code patching (alternatives, jump_label and static_call) can have sites in __exit code, even if __exit is never executed. Therefore __exit must be present at runtime, at least for as long as __init code is. Additionally, for jump_label and static_call, the __exit sites must also identify as within_module_init(), such that the infrastructure is aware to never touch them after module init -- alternatives are only ran once at init and hence don't have this particular constraint. Previously, the module loader never loaded the exit sections in the first place when CONFIG_MODULE_UNLOAD=n. Commit 33121347fb1c ("module: treat exit sections the same as init sections when !CONFIG_MODULE_UNLOAD") addressed the issue by having the module loader load the exit sections and then making __exit identify as __init for !MODULE_UNLOAD. Then, since they are treated like init sections, they will be also discarded after init. That commit satisfied the above requirements for jump_labels and static_calls by modifying the checks in the core module_init_section() function in kernel/module.c to include exit sections. However, ARM overrides these and implements their own module_{init,exit}_section() functions. Add a similar check for exit sections to ARM's module_init_section() function so that all arches are on the same page. Fixes: 33121347fb1c ("module: treat exit sections the same as init sections when !CONFIG_MODULE_UNLOAD") Link: https://lore.kernel.org/lkml/YFiuphGw0RKehWsQ@gunter/ Link: https://lore.kernel.org/r/20210323142756.11443-1-jeyu@kernel.org Signed-off-by: Jessica Yu --- arch/arm/kernel/module.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c index beac45e89ba6..9d403fc1893b 100644 --- a/arch/arm/kernel/module.c +++ b/arch/arm/kernel/module.c @@ -56,9 +56,16 @@ void *module_alloc(unsigned long size) bool module_init_section(const char *name) { +#ifndef CONFIG_MODULE_UNLOAD + return strstarts(name, ".init") || + strstarts(name, ".ARM.extab.init") || + strstarts(name, ".ARM.exidx.init") || + module_exit_section(name); +#else return strstarts(name, ".init") || strstarts(name, ".ARM.extab.init") || strstarts(name, ".ARM.exidx.init"); +#endif } bool module_exit_section(const char *name) -- 2.31.1