From patchwork Thu Oct 10 15:22:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830198 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 1C614CF11F5 for ; Thu, 10 Oct 2024 14:12:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A24616B0098; Thu, 10 Oct 2024 10:11:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AF956B0099; Thu, 10 Oct 2024 10:11:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 875486B009A; Thu, 10 Oct 2024 10:11:59 -0400 (EDT) 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 667616B0098 for ; Thu, 10 Oct 2024 10:11:59 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A567840675 for ; Thu, 10 Oct 2024 14:11:56 +0000 (UTC) X-FDA: 82657881558.04.D33B66F Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf14.hostedemail.com (Postfix) with ESMTP id 196F410000C for ; Thu, 10 Oct 2024 14:11:54 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.32 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=1728569366; 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=Bx6aKZiFe76ydKrYGeXzEnl862q0yF//lZgdUVUUJU4=; b=pudBzYWbpNg6CTjnZphAeskrGfuomdzMcylmcOOjOiDVNabcdHNx4Sk8AjXM/jdsZlVwT4 LJIwNbkA8jL10r1JnTWwwRBXilZkWiR0MODpgCjqOvAKqrWvBEQheQeEm82byV5COg2L8K OHPbW9Luj0Tgvbny8i3EHfr049mbPoo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569366; a=rsa-sha256; cv=none; b=aBEy0yw6hZxqlwBg3ufJW8Q7OV2wrEnBKzhATNUiqBZeWRiY3/yg7UQr5YTxY+1Ox/BlbV zV1J2ByYoeDlA9C+jtydPbTYL8+eM1N8cTdU0w33AvHH+FhnO+iaERxUaGiU3DGJbKBCvy BAJFoUnnFYZrD9vmriftkr3pq6KNKxk= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4XPWsT6mQjz2KXx6; Thu, 10 Oct 2024 22:11:57 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 3D1631A016C; Thu, 10 Oct 2024 22:11:53 +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; Thu, 10 Oct 2024 22:11:49 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 07/15] security: min_addr: move sysctl to security/min_addr.c Date: Thu, 10 Oct 2024 23:22:07 +0800 Message-ID: <20241010152215.3025842-8-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 196F410000C X-Stat-Signature: hzx7syr9rd4echsmuosb9yu5d1yjex9t X-Rspam-User: X-HE-Tag: 1728569514-732414 X-HE-Meta: U2FsdGVkX180Xb6Y366q3AXjuXO1aOjG5kZx6rDQUmzxujhSOj43cZzEtfFpJq5qvnEGWM5uSZEUY8OWcR31+ikJsgaFVJK/CglZ9hpctH+84jUXNklIWmsQ421rvgtQDsP563hBbGWvlL0tETkR0ncPCWg/JBocPN+Qw2VGZTX3LwS+W9HVL7+j+i382UAz3aPOKITciqjIsJ9nZwHjule21YvTtXCHLMLUcSxIjdOK/2FlmbrzzePLBInin1GaVhlnq/vhtyNXqIEnp0KGUUcFrytLzMAEb7p25SyarRyS3/zhGffFoa+DY4pjfvfLNv9m4gu/zJ8roANwzb1zteP47vDA9Kr+4VY07gaOfT1GqxD+Hx1gZ+J2alXXM+PG8awTUkLeUZF+QkZ0W1jcTdxt/l29sqjfVLInUMuMPsPflfWGxQBGgMrlwBmh9YCn4xBzkeKD6UuC0PpfdKWV1wkaLmD+HyAG2A5AUvxkizYUOlP7aC2F2/bc/PFvVu43p5XMold9U3C03w03DuUJrXey7Kw0T3NZl3u4iv6ZqTZfDnZvaFS3i3JYR7VLU97EX2nBvo5NoIzJWGbXDapze0H7WBIqmCvF4PbrMMMBLq4UyekOG7IxJNIpbkORvF21XO0tX7H+RBwaoqWLbhY7q1NIjCRtqAWP5S3tUpogXfjQ0xgglGNfbGwMIjj1syjkcsyIJTUmNn38kJp36YRZfEReE77Fe9D89fCsrH3wSyY/VaqHvQ0dcJM2AcAqVbP4Os792gB/Exbu6gPYQufPtZGUHWpSg/dkqOelTJrbf3/tNODuOrBMNdTfUOz0xJFTn9qTpy4CAd7g6X0q4YqeYRQprbHxMDLk/QZyR4xVHzzVtgLJH9wg0nppuKLpR7ON2ohVPSoA1DIdYMeiS1GE/Ui+kjq2FviJTFv//5D2QAAlu4W247u1QGUbeUXLLFHPaG/f+EBNrTWZUngYg/U spnbvTvg Yz98TD3y20W7k9CWVnqMDUXWKSrBuxYh4oSzYTvEixdrhEdMrym4kQ3HZ/jN0E7hOH9hMzDL0BgnGcdPlr4moS+cGkj4aZZ8wPrWRIJ3yo5HLUdvWxswmHpfH97eP/ensuC95dj8DSQhRB0/4vlPmxMHLvBAVz6jWgdfOHpAUVd96lh30ZmDyuPkGRA16/t0avlfLSZe1CCyKP8tSIXKnP49LvYwjIvZbLYaoJPgDABowqhtBEvA5P0E7iomVlT2QpVNLiOXXpmHYpfY= 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 --- 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 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;