From patchwork Mon Dec 23 14:15:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918975 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 1C045E7718B for ; Mon, 23 Dec 2024 14:20:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FE406B00DF; Mon, 23 Dec 2024 09:20:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9ADE56B00E0; Mon, 23 Dec 2024 09:20:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84E186B00E1; Mon, 23 Dec 2024 09:20:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 625D16B00DF for ; Mon, 23 Dec 2024 09:20:56 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1E751C181D for ; Mon, 23 Dec 2024 14:20:56 +0000 (UTC) X-FDA: 82926434850.28.1AC9105 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf03.hostedemail.com (Postfix) with ESMTP id 613FD20007 for ; Mon, 23 Dec 2024 14:20:35 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734963629; 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=JmVbJ1u7I/fiM/mZTKbXVhm296hUyc9nVwr6w+TBxSU=; b=eTTJjShnkX4nwukPFP0q8rp6LktFQ42PPfpKV/mErgT+7QKjI28yLxgbZhf270sJZNvf4m ASQyhyHKLhyFCVMJOl9CNg++6uBSBJKyiCK1PPEuDNEyerqog6BtARAIKxt5b1Ywn/Fflr wiqGdvXUjwsaBkKggwnsKDdsH5eS6x4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963629; a=rsa-sha256; cv=none; b=H8tmKNCbOraIJoIPNVrI+sGXYMI2gnC6iC+WopedyOTbOSaO4YY+9B5CuxdFY2QZ7oyO+h 8/oa350WGKJUy7qVWD3mpcVwwLO2vZCiNoviU+afa3QVrSlc6rs7xePSUQLH+iZdJ9p0/1 fp+elYLJsHlgtXYnbUSOcJATRtiL/Co= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4YH0WJ1hDbzRk4y; Mon, 23 Dec 2024 22:18:52 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 62154180087; Mon, 23 Dec 2024 22:20:50 +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; Mon, 23 Dec 2024 22:20:47 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 07/15] security: min_addr: move sysctl to security/min_addr.c Date: Mon, 23 Dec 2024 22:15:42 +0800 Message-ID: <20241223141550.638616-24-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 613FD20007 X-Stat-Signature: on8t1ozcu5suc9dakhyk6mi9zrbbx7c1 X-Rspam-User: X-HE-Tag: 1734963635-946776 X-HE-Meta: U2FsdGVkX18xZ4g+Rejnn9z1XcfJWZqpci3lZXjhHbvxJ2imHFJRWSBA0mwp1kWguHpv+PpUGpeHFX9bR4k8QquxcXPKlnWGg/SLJ8CMJ0nGcpzC8NsiHYbfjH5eRRtioSVZdUQn34yni85BI1v2c3pdPO2zl/m85VWBg3lECLuFKfBi7evVQKbZw4tH0FTSNKkJ0VJjLnB/59bDK3GZB/2QC/5+NUMMj5mQjSDJHH/OIjafIXCrWgwjVkgqOV++PK6d9imMuMPS7CJq+fiFtQHWQE4NELFBbfrAObad7fyni+N6segKVezrrKi9//ewcyZaUMn5hkXvlPHH5kbWR+lz9hTvGPOeP0C4Lu/V7cvPWGS1mWuAnSiPFvAIhbco4tQflV5NM9HeUKNUtPbDg12I9oIT8CdBB78lqS060kClGPd4EWNoOX94vBQzI4Ab0jHwGSPKus8dfvvTGH3qsTw2Z3QeN+p0OwwAG5Yp4xc2A73RySh0u9p221+bgAU+PZ4x0rA+538BYI5feduI+8bxaye+p6ZGkNHmeC8kjwm4TgWqwUWcfLoYiWrMl1TetG83J6wMr0XrjvS39/Bigsslh0diJn1Ga6srkpO2phqDtuNd18Iy3UL2PoJGaYrRjE9kkMVUYD4qaWDXIdxZQoEafbZAqBQ4DJRMMthip8tW1Dk0ZLDhz11gT1WSkRAs5RNPIzbCg0PhOaePY57DwKFZ8GOYPDiWrXGUEpIsC0jBA+HLQYSvaeBhPy8OepjLcX3W6QBvxg8IeF46a3WINWUkTeung3j01zWz558mHWc8QCyr7y/+U2xxOOFbxDWqP3ALvWaphSgar1UJkkSQyci4XYKBKa7+7otPnTf/L47MVPN52iR/gio5ecePzvOlk4PnmG7DxN3WgHKni9IoYZWSfwqaQ33o9CeM+bfIo7w8R8eYhrWy6ubsD1Ubr42XGTu0dvusoGfTHX2AvJM KNSq6iI+ 59PLxs5hre66LuhCUPcFysQXQNMXTFMWqdhDalCmXp676uncKv+r0b5gIWX2XO70CaxC44n/qgbwOirrkvjIsZvaU8MVBaPD5hfj8BcG/olFazJxmku3QeNiBoapfmAiW3WFIGNxz76KQlOHEADCWkYkhGfxOgEM80icBwR09nUlJSkhHRK9p1az4wjYAqEWPdEVaDp9y0BnHis5J+erGfpz4Y4e37yMT1c1pN4giJmp8V6H+7S+Bv/VP5gmxdicH1pzspb1kV55/Vb7wdq95H7fE5g== 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 to min_addr.c 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 --- v4: - const qualify struct ctl_table min_addr_sysctl_table v3: - change the title 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 9c245898f535..62a58e417c40 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2049,15 +2049,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..df1bc643d886 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 const 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;