From patchwork Tue Jan 6 09:07:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jungseung Lee X-Patchwork-Id: 5572181 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 56CAABF6C3 for ; Tue, 6 Jan 2015 09:10:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 476F4201BC for ; Tue, 6 Jan 2015 09:10:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 601A120173 for ; Tue, 6 Jan 2015 09:10:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y8Q7u-0000UF-5P; Tue, 06 Jan 2015 09:08:34 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y8Q7q-0000N5-Qc for linux-arm-kernel@lists.infradead.org; Tue, 06 Jan 2015 09:08:31 +0000 Received: by mail-pa0-f42.google.com with SMTP id et14so30696595pad.1 for ; Tue, 06 Jan 2015 01:08:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=kMoE450WlPIC0pPp4uc8bdOpjJXR+WJ5TmJz5p6ITR4=; b=S2yNem0coaCzFGFu/18QGqd5kbW5G6tGKlISmQRuX+pGkqsyUxDWObyXWu+W6VOHla kpvE85Xiq5Dxj+UXJXjQFU0GQdnXH9jw40jLiffYGuiQCQIIEGIwxDifcEshx7Despm5 zvcZZA/ikwdobEmxevUz8umcKXngWoSfVJVTjrcOlRm9AxTdvZpXGIrMEF/CDRMlGicS xsij0mxXrtgZmfmmeHirLyyK9YZgO4c/OWwlGl7ojgvGVKcuI/jxh0S2m8QZ0WCVVJHH EFACbuNvyCssqbY8Z7fAa4iL5aszPn5beUp76m8/zaxJdJC9GX2xL4O28GH9QJltNQL7 yeUw== X-Received: by 10.66.224.201 with SMTP id re9mr157942931pac.138.1420535289273; Tue, 06 Jan 2015 01:08:09 -0800 (PST) Received: from localhost.localdomain ([165.132.120.48]) by mx.google.com with ESMTPSA id 9sm56405774pdg.38.2015.01.06.01.08.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jan 2015 01:08:08 -0800 (PST) From: Jungseung Lee To: Rusty Russell , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Russell King , Laura Abbott , Will Deacon , Andrew Morton Subject: [PATCH] kernel/module.c: Mark module state before set RO and NX regions Date: Tue, 6 Jan 2015 18:07:36 +0900 Message-Id: <1420535256-6091-1-git-send-email-js07.lee@gmail.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150106_010830_916146_2BD3C80A X-CRM114-Status: GOOD ( 12.06 ) X-Spam-Score: -0.8 (/) Cc: Jungseung Lee X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some architectures like arm/arm64, set_memory_*() check module address and state as well. Mark module state before set RO and NX regions for the routine is passed. It will fix wrong RO/NX protection for loadable kernel modules on arm/arm64. Signed-off-by: Jungseung Lee --- kernel/module.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 3965511..7e7cc9f 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -3152,6 +3152,10 @@ static int complete_formation(struct module *mod, struct load_info *info) /* This relies on module_mutex for list integrity. */ module_bug_finalize(info->hdr, info->sechdrs, mod); + /* Mark state as coming so strong_try_module_get() ignores us, + * but kallsyms etc. can see us. */ + mod->state = MODULE_STATE_COMING; + /* Set RO and NX regions for core */ set_section_ro_nx(mod->module_core, mod->core_text_size, @@ -3164,9 +3168,6 @@ static int complete_formation(struct module *mod, struct load_info *info) mod->init_ro_size, mod->init_size); - /* Mark state as coming so strong_try_module_get() ignores us, - * but kallsyms etc. can see us. */ - mod->state = MODULE_STATE_COMING; mutex_unlock(&module_mutex); blocking_notifier_call_chain(&module_notify_list,