From patchwork Mon Aug 26 12:04:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13777708 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 3E5DEC5472C for ; Mon, 26 Aug 2024 12:05:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 306746B03C6; Mon, 26 Aug 2024 08:05:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2425F6B03C8; Mon, 26 Aug 2024 08:05:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01D2F6B03C3; Mon, 26 Aug 2024 08:05:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C9DF56B03BD for ; Mon, 26 Aug 2024 08:05:43 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 71D3B120FD7 for ; Mon, 26 Aug 2024 12:05:43 +0000 (UTC) X-FDA: 82494267366.29.85DCC00 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf25.hostedemail.com (Postfix) with ESMTP id D78E1A0007 for ; Mon, 26 Aug 2024 12:05:40 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.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=1724673857; 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=IVoE1vCPqxjqVVcdugPtOWbDhlwRYouX1AbyQSrHjOI=; b=x/Vbcv+1/YSDZmzGz9N3HJWIy0yTkl0oi9Iu4L6Vl5PNPsV2dng4XsqX5OddeSVGguPmLm 8u7RaCMR3FHbhZZHKkOc8uZpALLYXxiUhWsJiIt1E4cnZeVXwJ9+7QtPUorma1r3ZO8XxM AnyhAqnu5vZVh3KlRCsSuohwAoatMpY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724673857; a=rsa-sha256; cv=none; b=sBvKw93cib+D+d6YKISv3QqjVshWiTgjLYoCOvLha2Q54NBRkiDO2YnqEcsu8zbenXV6pB EVOYCr1jL9kigpAOc+h/3ZL0728f4R41cW8RGubpeaCq9sVIdVcEipAiCiInW1Fz6vhVFf QcfwWdDvMBTVocX3cRdY8fbRf1n++fA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.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.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Wsq9b1m3KzyQKg; Mon, 26 Aug 2024 20:04:51 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 1E7631800D0; Mon, 26 Aug 2024 20:05:37 +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, 26 Aug 2024 20:05:34 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 07/15] security: min_addr: move sysctl into its own file Date: Mon, 26 Aug 2024 20:04:41 +0800 Message-ID: <20240826120449.1666461-8-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240826120449.1666461-1-yukaixiong@huawei.com> References: <20240826120449.1666461-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: D78E1A0007 X-Stat-Signature: 1eoy73a75dorisjxyd3ge4jtar8wpihq X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724673940-877798 X-HE-Meta: U2FsdGVkX1+w3zGuwLNpa9TlKoHJ3EumPWMH/L8G+dS1taXARIi+RvsUdkmSYUbWwRAqnAzsgd0RM5lUlk9jk50W0DawVMjzTArHq333cTEQjLKEBHh3G7Mu8rQxULJbe4WRB0inIyw+3S2WFcNwBs/WjygzQW6tcuZBtmWTs0bjk+hzCfWsiMBxaDQ7efS0ZOiGHtbJGfNMATmQU41cJEWBGqg6eQdG5r+qTv2ptfhTF/FiPlXm+9K3FC98R8+kA6COwXfwmeOuGZvlzmhjttVvtR7oeX4ETrjcEbVhWUMpQEQSs9cE58R3r6QMa5SgYPzPINOhwpNxd8Fn6HR2v5JT7UdorO1okSNZa5aEywfl3ouBkdQtkZvMxnqSeg4Ou3GsIELSTwJxmkgUO0ijmldMQKqkPqw9u7OJs+hXpHyEN12eJW1fhcG+N9fAg7Siro4UT0VXZgTELd7raddXOcrADxpRvMGVSe+N7FnkxZA3x1jYGgvn1bCNLY04/2fAkLtyvhBxdt57m6/f3qAQWnRgiIpiIpQYwqS/6A9APCFDIz/SrIgCga5PpPsIencnoQ5MqTc+pYrHLGKpcjGAre1Afox5ycrv5PpjV9+7tEQ6x8pBK8zhSGBP4tmfoJ2nz/4yijHxs3d2HpcnzCQ4U3yzvMwRcv20ehOCumEcbebUEld2VnlnfY1vNxckGNKVZ0JHsX0z/nyK8+u2vhcHRQ6y6tT0w0C3jYt/eR00oPunAQ/NGmalWGIrshZPIWEq6Ln/0j3MAl2xMpC8ztZTQVz/sEYMgZhKpQR2FAyq7on6ENBPhO4g1HerydCkmrGwW9zUqxBSf6lyV5NKdCr+Jo/Kl5/u9oR6iAXpoJqLU/JtE7QkVFOsyrEIZXET7PkXVqjXeNT7BXXKFuMgGy1u3MyO5NGGMRD1rQess8SAw8ZZRjo5x17FqOxzgcolwNBpZE5xiSU1B0DgZ2Ek87P c1GjgViB t2OVTe9FIEsnbOtYj217UTBfize5BiQ5pv6dGjFKNho0QTeLz+IXksfCls5MWz5uhomPg0UU4lNFP1N7NHFtWakreg3TiZZ6HEUiXJrDWhJZ/nlcuBWLHr8fuwkdCrjA49ws1Jmy1dh6rn9URuUDdwD5i7Be6jxLwFx3WW/Ws8FJj8g40ueJVQcKB1SMOrS6/xqcS 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. Signed-off-by: Kaixiong Yu --- 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;