From patchwork Sat Jan 11 07:07:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13935838 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 8CE48E7719C for ; Sat, 11 Jan 2025 07:12:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2414F6B00A3; Sat, 11 Jan 2025 02:12:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CA316B00A6; Sat, 11 Jan 2025 02:12:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01CCE6B00A9; Sat, 11 Jan 2025 02:12:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D39E26B00A3 for ; Sat, 11 Jan 2025 02:12:49 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 56B1844278 for ; Sat, 11 Jan 2025 07:12:49 +0000 (UTC) X-FDA: 82994303658.18.E312B6E Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf11.hostedemail.com (Postfix) with ESMTP id E423940003 for ; Sat, 11 Jan 2025 07:12:46 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736579567; a=rsa-sha256; cv=none; b=ThhmyBDlCnY9x+1Pu5MonDRD4l6bO5ZVVJaCYKLaMmqLoBywXGs8jp/BhxJb34C4Rr05Tj lPfrR/wNVfqabVRh+n4Ryd+iPNz4lGq5Bp++TefrGXJqNWhHLKqKFn0BaJoTu45rpCs1N6 QzLM1FcdFUtYr8iFCKLKXLtubBGIzko= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 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=1736579567; 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=lksqqpUPzA0npWLt3gWf0LkugVgXNINHP1qqySPwUxaFSq0AfUkqcPHYFUCCjgEJSPlt8o e+koLD2laLZh2c4FbIsFelgPPMKy9vY5lTotISRV4B1wJZTA+I3uXQOOGqFZ53Gt/wHVhj eMm74DG4epqeACJ/LlYlf7wZpHxOyow= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4YVV692Jpyz22ktr; Sat, 11 Jan 2025 15:10:25 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 6C5F81402DE; Sat, 11 Jan 2025 15:12:43 +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; Sat, 11 Jan 2025 15:12:39 +0800 From: Kaixiong Yu To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 -next 07/16] security: min_addr: move sysctl to security/min_addr.c Date: Sat, 11 Jan 2025 15:07:42 +0800 Message-ID: <20250111070751.2588654-8-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111070751.2588654-1-yukaixiong@huawei.com> References: <20250111070751.2588654-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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: E423940003 X-Stat-Signature: w1kzjq6q136dmpks8xwndrumzcnag515 X-HE-Tag: 1736579566-195171 X-HE-Meta: U2FsdGVkX18MvVBazTYJiOD9N875hWQIOyRy3+Tv4lImQpKqFjAkmU/aJkEOajLLxXAMWCTTNFBkN9C94Ug293sHSV9u9qBVsemdJlTeSlzwCT42zv8a+nZpCK1rPzxv6Zur9fUX+7YjJ16I/tmFGI1I9WteqRuEuGsMPxpQtsYbe04LHNlO9T+2/NsgyJqbLMjRjLyGuB/x5W9T7nmLckFfsjs3SjEx5LyIp7wCjcAQaYxrsOxnaYqlpsTICV4YzYysE4yclnFNWeGtkw/qPslI1ioGZI35ToCvSDjzRsGpYGv4N1JH3tgFj3ONz9ncHHo8fw2YZiqQWcnTtPguwpJapWWlvS4gb7cDKT8MYFkOEk1XyRzJa1/0LNaR61qO2U3+fCSIDMnV8lfeaR/uFhVZSNznDfDGqZcb9sOssmVFZkDJT+XtpVNXCu7OBqBT3Rzjq7RCC4YzOx45Skx0g/uj+ewOiHv0oEv59bB5q7tYTw+uFwkm5dWOJBN4RStahe6nNeuwjKmMiKxll37ay3XbjtfovCQpUBK0H9SeA5Mpz+o24N+qdRZl7Kk+shYOm4SwU/jsKBSV2GsIXZ12h7hKMNhquMIj8uXCo/cArIY8tg7xKzhc/FGrnBmT86oLBVnZwbpp6ZtgJ33HdBGcjfZns/ZDSj+i59pNMwSEzd5EcvqOjzciknogOV6bav2/Y7iSuNZgLq6cYTn97kZwQKFgQfMe503bRzHLw9cVPUFa8grE/ZRHEEacv1iawVd7xDhO+HRA4GBV2Gr23gBP/rFhJrEVVeihXSRCTITnm6UQXEfDjhBPjEB+LL/1btgEXw1KJewBV/OD0x0FoVJBox+BeX134zcyacHOyQL2wdzgj4GjqWtGYEMUFqBRF6/5re4pNjw72br6nNtmoEwZkB5a8X9qKhYAjuEwQ8/86BWsuAXDEOsGAfEMaDWaPeAkxVe7wNBZ4s12G51M1Wn HXXN9seJ 0jRJ1pdStyAJP0zpUb4RaX/8gzxb8Ga76Q8tOyqAt5HQy+CW5H6OPipIjxhVDXCP8XrsvqAMJtZZAF8W5hJn/CEEjMMz96t6/g019OJmHJQ7y337VMwKipLW/yZQzy/R/bIiaaS2nxHWdz/5T0BJ+d4CWEYNCxvAYGov5lrVEfDUkQDau80cXZLrRvulE4YzR8OWHN9BJJOQB4ygWpw4rMplmjdLb/Oy5Zj9ytwAGtJj9z54HkdgK/tWjcOHGshUcTW7FXTZqD7KN47mJrKmj3Dg7oy0cttDgWOF2GfLQPL4seN+WLViP+mNY0mJQRYh0AfOp+m7Iifxi8IAyV2riTDu2zWIBrkdeI7FeuNvhtEs6zgo= 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;