From patchwork Tue Sep 3 03:30:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787956 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33941CD3427 for ; Tue, 3 Sep 2024 03:31:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 902238D012D; Mon, 2 Sep 2024 23:31:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88C088D0119; Mon, 2 Sep 2024 23:31:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77AB28D012D; Mon, 2 Sep 2024 23:31:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 549CD8D0119 for ; Mon, 2 Sep 2024 23:31:24 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 111F21C4E32 for ; Tue, 3 Sep 2024 03:31:24 +0000 (UTC) X-FDA: 82522001688.08.1EC9F64 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf03.hostedemail.com (Postfix) with ESMTP id 87B1D20007 for ; Tue, 3 Sep 2024 03:31:21 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725334189; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9rk57q7UG5urcM2ZAYiXpyp7swA7U//KWTASEp+Wahs=; b=EZelARm73qjs9TJc7qFCobSqtwP4o4IVQcvlofqUgytjuYJJ+KA+IUh5xUuZKQrkqZ8RtX UsKdpx6iBAeTSYSy7srLmK4xpbuN9RrPodLIlEWpBKCo7zJNq5MhiG5krWqt+ufHL+qUlb UK+LsX6aFgdLaa7uDieINeGkrKIOt94= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334189; a=rsa-sha256; cv=none; b=29Gk5XAJRg2A+yjGz+TMKIRksXw/wriYXMT+bdk4rdaNzsP/bxjx56WiDksyQ+kBV/buMi d28YQZw68ris9YXzNQfYqjoM+snpB9YjX4Sgi+tVf3V89cJf7R4ABj3WD801W3jhbe4HRj 4ya9AUW8p2ifbXjKJmtxCLua/1uJglE= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WyWNG5PdYz14GB1; Tue, 3 Sep 2024 11:30:22 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 6917F1402D0; Tue, 3 Sep 2024 11:31:18 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 3 Sep 2024 11:31:15 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 07/15] security: min_addr: move sysctl into its own file Date: Tue, 3 Sep 2024 11:30:03 +0800 Message-ID: <20240903033011.2870608-8-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: 87B1D20007 X-Stat-Signature: r31n66nsnc4hiwhzujj7b6f857zrwehz X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1725334281-256374 X-HE-Meta: U2FsdGVkX1/+2L6uAOajtlJq7A/ntzuqZZ3tde4YzHlCtfJZvL0++S3gTEwIc5DAl/ot4YIuDXG2YSkHUDmCrOYSZyenznq6Pvxgm8pE6Bqvo6j7fyHru0RFJZM1cVC9Lvx3kEnuWYEmVgXoh3y6xoRwAxsa9oRMtKZU8D8fSB3Qj7YOaZxJsHmsAj9XISZZsxA2Hc1YygSBGBZsgUdZxqGQK6+OuTx7lRbac4tNJ0ItlfprfeMOT8Wtfjs0iXZsxFMd5eGSi0aO2bGCbLEULt/pA13o00ApkgwAiXJgLKQNKzHAw5dyPGu04x12dAbxT0R5+LQZKGpeoWNQyS4ZVpvTB2tuEDHzORr1e4+eIcMuh5GD2DZFbNy0CZfPogXqLa6QkH3oCyXJC7QfETEk1FB5Yt1r/7/s6C8gbA04hxR3sOPq0lGhOCBOU4DLdla8fQHMHFHuxYcZZICXP7lJ9CawpvkI6VBsxvIHM0d0JD1UrWVyQbAId3n+ocyxAZ3jMuNwoSXnGWMGBEzn69YHak1HYOCpxx6FK3OFoQP+kExvKyiW0xSyJmk9Tg4ee/4PmRfCJzCXjQDQxp8sj1kIpk2Swsvi772GgRLYrjStHQhl56z9YqdgfEG4WwBgGdbI+wk0OKgxPAzXu08BAnv7Jw6gRPTtyP3vhcES4FnViIs8caxH2GRQMe/kFVfvpOgMjY8fI3fswwMCworazC6L9hqL/wmHf6ARBlQyuCo5EpuIEiaV7D9qM8RE47ShzSQIS8YFjtv9/Bn53fK0X4Oe84qg8j3bt9eftRIIsXZ4ZjrV1qWa+fz7/6VvfXkgQcJOP4hIdXJ9+0LlnBo9Ajh4J/Xn0I31YRjUXTF0FrGxCh0GDZGLFbaVWNDlomKrDOBCi42CAIhMoEnoQnkZzMY4lxTjvhtrLQkHtYfVFdS2cGV3sjOlr41CJYcaVr39kPd4VN5dxa4Ta8u/wV8tQtV NAksTUEs Jb+rCetFWGu5qvnWgtNMhIEWBQ5t+l5LLVUsUviEuleIS9pK5u1DNcMUevX3myfy2Kb3PaTBJohPr2DcfTj6XZwgGtVlASAdKA/8MawTHq8/VjyF27ufWdWnuShNSj7iMfu5gxW7bgPMJUfpu9XTwIB05+TvWKguXXY8PKbERHDNv9qNRe0sK9Ao4LwHAbxkfxtSuoiDfHoG+5UIjVSN0uKvbXg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The dac_mmap_min_addr belongs to min_addr.c, move it into its own file from /kernel/sysctl.c. In the previous Linux kernel boot process, sysctl_init_bases needs to be executed before init_mmap_min_addr, So, register_sysctl_init should be executed before update_mmap_min_addr in init_mmap_min_addr. And according to the compilation condition in security/Makefile: obj-$(CONFIG_MMU) += min_addr.o if CONFIG_MMU is not defined, min_addr.c would not be included in the compilation process. So, drop the CONFIG_MMU check. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook Acked-by: Paul Moore --- v2: - update the changelog to explain why drop CONFIG_MMU check. --- kernel/sysctl.c | 9 --------- security/min_addr.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 41d4afc978e6..0c0bab3dad7d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2059,15 +2059,6 @@ static struct ctl_table vm_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, }, -#ifdef CONFIG_MMU - { - .procname = "mmap_min_addr", - .data = &dac_mmap_min_addr, - .maxlen = sizeof(unsigned long), - .mode = 0644, - .proc_handler = mmap_min_addr_handler, - }, -#endif #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) { diff --git a/security/min_addr.c b/security/min_addr.c index 0ce267c041ab..b2f61649e110 100644 --- a/security/min_addr.c +++ b/security/min_addr.c @@ -44,8 +44,19 @@ int mmap_min_addr_handler(const struct ctl_table *table, int write, return ret; } +static struct ctl_table min_addr_sysctl_table[] = { + { + .procname = "mmap_min_addr", + .data = &dac_mmap_min_addr, + .maxlen = sizeof(unsigned long), + .mode = 0644, + .proc_handler = mmap_min_addr_handler, + }, +}; + static int __init init_mmap_min_addr(void) { + register_sysctl_init("vm", min_addr_sysctl_table); update_mmap_min_addr(); return 0;