From patchwork Mon Dec 23 14:15:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918960 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 CF7DBE7718B for ; Mon, 23 Dec 2024 14:20:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62F596B00BE; Mon, 23 Dec 2024 09:20:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 602776B00BF; Mon, 23 Dec 2024 09:20:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C9DE6B00C0; Mon, 23 Dec 2024 09:20:03 -0500 (EST) 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 30C506B00BE for ; Mon, 23 Dec 2024 09:20:03 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AA29B14161B for ; Mon, 23 Dec 2024 14:20:02 +0000 (UTC) X-FDA: 82926431574.06.C9A2EE8 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf19.hostedemail.com (Postfix) with ESMTP id 6CBF01A0019 for ; Mon, 23 Dec 2024 14:19:19 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 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=1734963583; 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=RSn4+mh+ppy/QEUOfzKwD5/IH7T1Mj0uVrWpluzsWIcVmtjhfDjVu6YRCUWPhTdx/zYYId g9HS/Z1wGgomt2CMIhaF68LeNfauIXIFpHKNqEqR3yPGtEHeEIGQwtfNCPHWAACvFQdp0W wW7l31nuGaqyCMBGqos4kR+FYI0dJE0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963583; a=rsa-sha256; cv=none; b=cK/PR77e+uPyi2QGpyBc/fdA1xCOTMxycuQ4LBtVtPD0UT9PZ0XZnT8KZ//QvyQ1ntyeWT d7pM5O9ApdjRQCMEMUxcCLlVXoFPo/LCNucN6OzTxecSG5O9n2WruYVppIPvzPlJAXos2y bAJjs8bufezgRSm+V7ANIL4I79a82aU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YH0TW251zzhZZ9; Mon, 23 Dec 2024 22:17:19 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 01A5C1800D1; Mon, 23 Dec 2024 22:19:57 +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:19:53 +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:26 +0800 Message-ID: <20241223141550.638616-8-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-Stat-Signature: on8t1ozcu5suc9dakhyk6mi9zrbbx7c1 X-Rspamd-Queue-Id: 6CBF01A0019 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734963559-509745 X-HE-Meta: U2FsdGVkX18XIihjUCht/8Ny8N60E63y50a/3oxe384GxzzauaupynklWr2t+mo9MPIDcS8LZ9hQZIo/abFtNz4yEi20Rb/ezU33By/zIQnGXR+bCghgJ14zk2CUEOH9Zd8GVOSfFWs/6GwW3Br/JwzrB0Vk0Aww+h2P+s7ekO6bA3gYgHXxmOXY7QgDo0VCFiVXSH9G2UoR0+SqFW5UVRaPhxw/s7z+qjmSDkVCXYnMJXFEjXrjwv3clAvHrAecaIcYCxVdPnoe4VcWIss0E4+dX33GVohLGXVToK99D/fg6qc5Ru6EFZ81croIy+Xrtqks04IMXAmedQXEBG9U2NlG41ngczvgYjJNbpgMBemuvaec2ApkpFYa0VMAmQka2uJXNJd7d+a0/F4QZwKlUBUITILu504AW/QH+RoCQOPenSQU5+S562xVpTcPLRU5tHf5r/+VR7LdUar/yNSbmk6NivuenSB8fFIStR5uhmGGMpA/hV/CYl3xeRUCn21WPo8QkTiqogq2Ind13wdjFf2PwQW8psDNZuLrTxe4vUHtFAYwB6LPzkQz2+PsrFSEdBnNe/j4j5vEUA0pvccEEaY4dlK3a7AcRZq+5hMUIlWBopIvySHKvLDHzMaoaFC2hEm1tKQ9UXg02OBL6VYMQ1xm1iscy4ZMA9mrCc1fKSlCDp5CmFnjiIYJRUcPE5+bmilo8vG+QhyDAhFKqCsC7It5k/9bdRhSHDdm4/8/Yb3fyTX2wcXTejxSm25GPjwIMXsUBsLr6yarlgpi/waX/IvlLpY4KfspZWf6DXT5widiR2LJGtxOTfrY+70QELgn6CuIDgSLGQPkQiJW8EH52uCNyetXJ56um215VgNzpUbfX5mQCkk+noCFgfgnl3nPyOVD3YdQQphzHy59Cg4ZN7H2Fy8H11DZnIfKVx5NG+1O6TKIFysl1G7mQCyIm1iXvBz7Ajf7nS1NMp/pk6L n3a7iUQQ DxfyolNvxc25mK0IzPZ+TnKm8C8K7OeknCUwfl08+YAjs3+RRROcymfwR3B0beVzXjO5qGECI0ZqsxifcdvRf3vFOKB17oE1plPz473S22EmtOpPE3uJC7oTyyHdV4AHdi2m7/KQZVdELSmyMOf/5B/Bub6pNyXfNPZ2IIoDgwkJdhhivK/JwGLT0Hhf6swvp8oLaOEkPB3hGVGLqOhfPgv0ruYOmjatMsgef+siUD1xErDK92mdfAq/VFRN8roUNsEvF3hZWllgHiDWNMc3xrH2jcA== 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;