From patchwork Thu Mar 2 20:28:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 6050 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp60624wrd; Thu, 2 Mar 2023 12:42:55 -0800 (PST) X-Google-Smtp-Source: AK7set9PD9ewyKo72LFNSDbpLbUL6yb0w26idT7amD6wjMllPam3ygUWgqBQ7Djhb9ZRP0xx4jnM X-Received: by 2002:a17:902:f7d2:b0:19e:6224:c1cc with SMTP id h18-20020a170902f7d200b0019e6224c1ccmr3966148plw.63.1677789775274; Thu, 02 Mar 2023 12:42:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677789775; cv=none; d=google.com; s=arc-20160816; b=p4b3fDnoCzTQ/NexTazQsC5IuDm2U0A+pa8dnnWL2JwUJTBBq2jRSoleNqmsbsViCu AFzY38IruS0ZCt9jLDOMnVLf0GoOCdhRLCPrWWUf9gZ5k6bMfmkdpsuJiE4CGnlWVKwu qaMID6xKKgxDfoiZ7SIRY/hNAoXWgh3tR+Ul5cmy/GMGKmjyIgWyOauDszScPrAfmmbQ WZmVlM1s4hZIzRE9o0TJkBlhHhGW1v04lC80Zjl7uVeOdmpBYASNkSqbffzziCCixYzl FPcME9qBc1yctlV5GZeC0aILpcZrYmk3Zpybvlpx0K5WlTvWATkzuvDOpWAk19T3BZnO qtFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9hzZZfqZBmriyiJaRRFgj4vKcu5VdE3XPsN3XWm1Rd4=; b=gjNeOyNIkw1XKrLxp/LqLPQ34IXjE6K3/N8HrE3roMzGMfUoC2pi5ZPygSRGCycbCn WYHrbzLt93ddNUeMcbhLZYvsfIts5t5QAcIvyPkNN2Sw7q0Itc9b7Z0sPVhrPbu5AZKH kPFpL4/1OGPhKsgOTArN32n7G/U6ncJZntK1ahnBMuwhcR2Wty8ZlF6kTRJPCZmedE8k rpQBHYqUlADfA5VMi8qFlWBkRTTZwsGy3tPGsyjuoIlFL9ptMmoG7qopPI0PKuMSUlCG XqUuRBsqMAKUvFW5vIhQbQeyB2NOVZMFBmHq1uv45WkoLX73ABX5fpJZTs4aONY+vobP LI+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=iSYMdzw9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v3-20020a1709028d8300b0019cac989c9dsi236540plo.403.2023.03.02.12.42.40; Thu, 02 Mar 2023 12:42:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=iSYMdzw9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230147AbjCBUaB (ORCPT + 99 others); Thu, 2 Mar 2023 15:30:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230086AbjCBU31 (ORCPT ); Thu, 2 Mar 2023 15:29:27 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9E5134C11; Thu, 2 Mar 2023 12:29:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=9hzZZfqZBmriyiJaRRFgj4vKcu5VdE3XPsN3XWm1Rd4=; b=iSYMdzw9ou8NMD1HPcMFyzy5s0 diTFd1Lfr6YcI+7S2P/PD9/rt8X7ZZ4aXtAwiDQQU9Czr8pgIG+sHmlxSSqSsRjZdmYUZa0wXhNWe PULqRYzYg75JdPSO4vpzSC4bGcyaKSyCCKBW9akOwd+CPv9rMlIVtAq1UqFJrHYTqWcxpV0eREHEe FGUh7U7G29xpuctqJE7lWEUkzHR03p77us1n7FYFRDiVCLQ807B3Dcq+amXQtS2jMa+I6JRVK8q2I Mivc/SWAWz04eHbs6YV6AXJr3XrqPmQIt2VZDbppPLcVdr6lkhshdKLuUH2DoTAaCmQYi5xdgM/vv yBkiKPFg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pXpXR-003Fx7-Pa; Thu, 02 Mar 2023 20:28:29 +0000 From: Luis Chamberlain To: ebiederm@xmission.com, keescook@chromium.org, yzaikin@google.com, john.johansen@canonical.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, luto@amacapital.net, wad@chromium.org, dverkamp@chromium.org, paulmck@kernel.org, baihaowen@meizu.com, frederic@kernel.org, jeffxu@google.com, ebiggers@kernel.org, tytso@mit.edu, guoren@kernel.org Cc: j.granados@samsung.com, zhangpeng362@huawei.com, tangmeng@uniontech.com, willy@infradead.org, nixiaoming@huawei.com, sujiaxun@uniontech.com, patches@lists.linux.dev, linux-fsdevel@vger.kernel.org, apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org, linux-csky@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 00/11] sysctl: deprecate register_sysctl_paths() Date: Thu, 2 Mar 2023 12:28:15 -0800 Message-Id: <20230302202826.776286-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Sender: Luis Chamberlain X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759290091334774872?= X-GMAIL-MSGID: =?utf-8?q?1759290091334774872?= As we trim down the insane kernel/sysctl.c large array and move sysctls out we're looking to optimize the way we do syctl registrations so we deal with just flat entries so to make the registration code much easier to maintain and so it does not recurse. In dealing with some of these things it reminded us that we will eventually get to the point of just passing in the ARRAY_SIZE() we want, to get there we should strive to move away from the older callers that do need the recursion. Turns out tons of users don't need the recursion already so we can start converting those over. register_sysctl_paths() can do recursion when its users have sysctl entries with directories and and then subdirectories with other entries. This *typically* was the use case in the large sysctl array in kernel/sysctl.c but as we trim that down we're phasing out the users that have subdirectories. This means that the code path that can do recursion is being mitigated over time and the code can be simplified as well. There are however many existing users of register_sysctl_paths() which don't need to deal with subdirectories, and register_sysctl() and the init version register_sysctl_init() (used when you don't care for the initial return value / need to de-register) can create subdirectories for you if you have no entries in between. So just convert these users to the simpler APIs and deprecate out register_sysctl_paths(). The next step after this is to to start deprecating slowly the callers of register_sysctl_table(). I'll send a out second batch for those that apply on top of this. Unless folks have an issue, I can offer to take these in the sysctl-next tree as we sweep these out, but I'm happy for folks to take these into their tree as well if they want. The only possible conflict would be timing, ie, if the final patch which removes the API call. That patch could also just wait another or two cycles later. Luis Chamberlain (11): proc_sysctl: update docs for __register_sysctl_table() proc_sysctl: move helper which creates required subdirectories sysctl: clarify register_sysctl_init() base directory order apparmor: simplify sysctls with register_sysctl_init() loadpin: simplify sysctls use with register_sysctl() yama: simplfy sysctls with register_sysctl() seccomp: simplify sysctls with register_sysctl_init() kernel: pid_namespace: simplify sysctls with register_sysctl() fs-verity: simplify sysctls with register_sysctl() csky: simplify alignment sysctl registration proc_sysctl: deprecate register_sysctl_paths() arch/csky/abiv1/alignment.c | 15 +----- fs/proc/proc_sysctl.c | 95 +++++++++++++++++++------------------ fs/verity/signature.c | 9 +--- include/linux/sysctl.h | 11 ----- kernel/pid_namespace.c | 3 +- kernel/pid_sysctl.h | 3 +- kernel/seccomp.c | 15 +----- security/apparmor/lsm.c | 8 +--- security/loadpin/loadpin.c | 8 +--- security/yama/yama_lsm.c | 8 +--- 10 files changed, 56 insertions(+), 119 deletions(-)