Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3560825ybd; Tue, 25 Jun 2019 04:51:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxScFy317RY9vNrOigxCZ9jZvD/sStVB/ppXtRsmiFz4nOgEJhhFTiBplUFJU3jtMWqMZ/Z X-Received: by 2002:a17:90a:b104:: with SMTP id z4mr31321548pjq.102.1561463476356; Tue, 25 Jun 2019 04:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561463476; cv=none; d=google.com; s=arc-20160816; b=hxydY5d2OCzz56ZNHgEq4ZO9YaemJd3Uk7YB8Sdq221/0rSTIwC+E/lT5OY9CJVvmi cBoTvqmpGz8HOB1r36lPd9WJzgv4IvZBw1ZhzHUA2sBtaA2uSUcVLtpZvWYex6kJGotf xFxLTJBQ/nTWhfY5gzbUTJ4/K9p8ULHUCSgkzxRCdXcGhmWF8pcqAQWXNmxAZ1L2gwID /27zrXLD3e2UYSEPBVKO4l8E0q99GU7nTgoyh0+ohxDc5bJ5ewviDrnHtJ0Y+wgqYzj9 pB0Mlh1mbrzTwzxKP3wgvn9PzoabcW9f9F+0MnptVjPzZVUsNxks+IE99geFULig4Qcy exbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=VTL9DEiosu51d4J9PAKIUa9A4igl1j2GuzUrqP3l+ew=; b=A1MBANIt+sLqWzwQPe7Fn863VnNwedUuetqonnOLCUdpLdGQx9YRuBCvOoFWd4pNsf LLCHyK2NBs0B4q0nVvyKH7ryvpJheTWSm4N/danr9+oUHfe0/Vd9GXkfrtZJzvtzr2Es WzKyz+Cuu92GV14y4n4FfzuNaAkYiKe3yo3A3h7aV7afc2PtxiHR5FiWi0ga1C2XnHxy aPnzZA6sE2aJTKQRMQDkVnBsHWQ3Nw7tBfPMfwZ9RwHSHA1+KPZC1ri0YojiutNwOqxg kceIfOFwJOXdW/oBpspH7EjU8EBPRfJixKjI7+7VKA7f6hT7DJmrARfJvBuQMI+mkKUv +w5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b41si158614pla.409.2019.06.25.04.50.59; Tue, 25 Jun 2019 04:51:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731370AbfFYJVO (ORCPT + 99 others); Tue, 25 Jun 2019 05:21:14 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:19105 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731347AbfFYJVK (ORCPT ); Tue, 25 Jun 2019 05:21:10 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 2CB8F2A3234098BC61A5; Tue, 25 Jun 2019 17:21:05 +0800 (CST) Received: from huawei.com (10.175.101.78) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Jun 2019 17:20:54 +0800 From: Yang Yingliang To: , , CC: , , , , Subject: [PATCH] modules: fix compile error if don't have strict module rwx Date: Tue, 25 Jun 2019 17:40:28 +0800 Message-ID: <1561455628-50795-1-git-send-email-yangyingliang@huawei.com> X-Mailer: git-send-email 1.8.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.101.78] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If CONFIG_ARCH_HAS_STRICT_MODULE_RWX is not defined, we need stub for module_enable_nx() and module_enable_x(). If CONFIG_ARCH_HAS_STRICT_MODULE_RWX is defined, but CONFIG_STRICT_MODULE_RWX is disabled, we need stub for module_enable_nx. Move frob_text() outside of the CONFIG_STRICT_MODULE_RWX, because it is needed anyway. Signed-off-by: Yang Yingliang --- kernel/module.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index c3ae34c..cfff441 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1875,7 +1875,7 @@ static void mod_sysfs_teardown(struct module *mod) mod_sysfs_fini(mod); } -#ifdef CONFIG_STRICT_MODULE_RWX +#ifdef CONFIG_ARCH_HAS_STRICT_MODULE_RWX /* * LKM RO/NX protection: protect module's text/ro-data * from modification and any data from execution. @@ -1898,6 +1898,7 @@ static void frob_text(const struct module_layout *layout, layout->text_size >> PAGE_SHIFT); } +#ifdef CONFIG_STRICT_MODULE_RWX static void frob_rodata(const struct module_layout *layout, int (*set_memory)(unsigned long start, int num_pages)) { @@ -2010,15 +2011,19 @@ void set_all_modules_text_ro(void) } mutex_unlock(&module_mutex); } -#else +#else /* !CONFIG_STRICT_MODULE_RWX */ static void module_enable_nx(const struct module *mod) { } -#endif - +#endif /* CONFIG_STRICT_MODULE_RWX */ static void module_enable_x(const struct module *mod) { frob_text(&mod->core_layout, set_memory_x); frob_text(&mod->init_layout, set_memory_x); } +#else /* !CONFIG_ARCH_HAS_STRICT_MODULE_RWX */ +static void module_enable_nx(const struct module *mod) { } +static void module_enable_x(const struct module *mod) { } +#endif /* CONFIG_ARCH_HAS_STRICT_MODULE_RWX */ + #ifdef CONFIG_LIVEPATCH /* -- 1.8.3