From patchwork Wed Jun 21 09:09:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13286907 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3C72EB64D8 for ; Wed, 21 Jun 2023 09:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbjFUJKO (ORCPT ); Wed, 21 Jun 2023 05:10:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbjFUJKI (ORCPT ); Wed, 21 Jun 2023 05:10:08 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A85631BC for ; Wed, 21 Jun 2023 02:10:06 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230621091005euoutp012f9a0fc3181d64013c076cdd172a21c9~qoYWDTDri1411514115euoutp01O for ; Wed, 21 Jun 2023 09:10:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230621091005euoutp012f9a0fc3181d64013c076cdd172a21c9~qoYWDTDri1411514115euoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687338605; bh=FxyVOFyTHFtuUAVqnN0MhLQUu0/hLv8Fe5NlXqOf4FY=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=QKXiIykPOo6YENoZDCPepN7Tcz2fjjq1jLpHTB9X9LBFen8BVAJymIL7B7xQzbr5/ s0IcPJjbWAJTFzcD2BFIHP5nO9ayRkiH3VKO8iY9DYRmZXTfYqTVFciF+Kuhlhcb9r hjcHPqcknsKKTf8j3Uog63D0oc51PbqxZRJIB3as= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230621091005eucas1p222a9a1c2c24e02667da5c986e8d42516~qoYV4KXSZ2539725397eucas1p2r; Wed, 21 Jun 2023 09:10:05 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 51.74.37758.C6EB2946; Wed, 21 Jun 2023 10:10:04 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230621091004eucas1p2e53ad3001cdaef7b3c44555653bbec37~qoYVV9zXR2952429524eucas1p2k; Wed, 21 Jun 2023 09:10:04 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230621091004eusmtrp2914d66a59410a1e2d2a8e39aacb9e44e~qoYVVHJLe2182221822eusmtrp2r; Wed, 21 Jun 2023 09:10:04 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-15-6492be6c4aa7 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 42.0F.10549.C6EB2946; Wed, 21 Jun 2023 10:10:04 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230621091004eusmtip2fe807757ae6939c118df2a2567566edd~qoYVLt4xF1982119821eusmtip20; Wed, 21 Jun 2023 09:10:04 +0000 (GMT) Received: from localhost (106.210.248.248) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jun 2023 10:10:03 +0100 From: Joel Granados To: , Kees Cook , Iurii Zaikin CC: Joel Granados , , Subject: [PATCH 01/11] sysctl: Prefer ctl_table_header in proc_sysctl Date: Wed, 21 Jun 2023 11:09:50 +0200 Message-ID: <20230621091000.424843-2-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621091000.424843-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.248] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42LZduznOd2cfZNSDCZ9N7M4051rsWfvSRaL y7vmsFncmPCU0WLZTj8HVo/ZDRdZPBZsKvXYtKqTzePzJrkAligum5TUnMyy1CJ9uwSujKc9 z5gKpqpVLPv5j72B8YB8FyMnh4SAicTu1euYuxi5OIQEVjBKHGi4yAbhfGGUOPmglRHC+QyU 6bsFVMYB1rJ0ChdEfDmjRPuJi0xwRX+/trBDOFsZJa5cmcMGsoRNQEfi/Js7zCC2iEC8xOw1 2xlBbGaBXIlZy5eAxYUFXCXmXP3JCmKzCKhK/N7YD9bLK2Aj8f3rHFaIY+Ul2q5PB+vlFLCV OP/4PQtEjaDEyZlPWCBmyks0b53NDGFLSBx88YIZoldZ4vq+xWwQdq3EqS23wK6WELjAIbHn 6XGoIheJj3/uMEHYwhKvjm9hh7BlJP7vnA/VMJlRYv+/D+wQzmpGiWWNX6E6rCVarjyB6nCU +P30IyskwPgkbrwVhLiIT2LStunQcOSV6GgTmsCoMgvJD7OQ/DALyQ8LGJlXMYqnlhbnpqcW G+ellusVJ+YWl+al6yXn525iBKaT0/+Of93BuOLVR71DjEwcjIcYJTiYlUR4ZTdNShHiTUms rEotyo8vKs1JLT7EKM3BoiTOq217MllIID2xJDU7NbUgtQgmy8TBKdXANE/hE8v+p4zXtRin vJvwzvZL9f4ZZeWqYuuKhTl+mJ+X3dsQ99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2yjsUdfjG9 iys/mu1VnjLd0GfSvtnv3cozgwQ2bZi5SUHozKnIt8WPLUqrXlf/WVmya4qCNYOZf7vU+dP/ /+tyHF4ZGnxDaes6kXJRFwONIIXzRzy/yp1c9FLxUWiHhWO1vbi0XvHJRauqb+vu9HSMKPB9 ER9SMSftfo6l6wujy1tufp2gPHnv+fzQ0hez3jW3cOXcadhuVrdltfPc3JtZj3foBj29H/Bk KXveoo2r/+Qe+LzOc1NptH/coq4tvWufKAffvVv5cEVOyeyc2XMLl1d9u7Q0emvDmlQnv/0p zVqLTZRYijMSDbWYi4oTAWh2O4o9AwAA X-CMS-MailID: 20230621091004eucas1p2e53ad3001cdaef7b3c44555653bbec37 X-Msg-Generator: CA X-RootMTR: 20230621091004eucas1p2e53ad3001cdaef7b3c44555653bbec37 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230621091004eucas1p2e53ad3001cdaef7b3c44555653bbec37 References: <20230621091000.424843-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is a preparation commit to use ctl_table_header instead of ctl_table as the pointer that is passed around in proc_sysctl.c. This is necessary as the size of the ctl_table array moved from the ctl_table pointer to the ctl_table_header. The functions changed are sysctl_check_table, get_links and new_links. Signed-off-by: Joel Granados --- fs/proc/proc_sysctl.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index c4ea804d862b..1d9f42840518 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1125,11 +1125,11 @@ static int sysctl_check_table_array(const char *path, struct ctl_table *table) return err; } -static int sysctl_check_table(const char *path, struct ctl_table *table) +static int sysctl_check_table(const char *path, struct ctl_table_header *header) { struct ctl_table *entry; int err = 0; - list_for_each_table_entry(entry, table) { + list_for_each_table_entry(entry, header->ctl_table) { if ((entry->proc_handler == proc_dostring) || (entry->proc_handler == proc_dobool) || (entry->proc_handler == proc_dointvec) || @@ -1159,8 +1159,7 @@ static int sysctl_check_table(const char *path, struct ctl_table *table) return err; } -static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table, - struct ctl_table_root *link_root) +static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_header *head) { struct ctl_table *link_table, *entry, *link; struct ctl_table_header *links; @@ -1170,7 +1169,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table name_bytes = 0; nr_entries = 0; - list_for_each_table_entry(entry, table) { + list_for_each_table_entry(entry, head->ctl_table) { nr_entries++; name_bytes += strlen(entry->procname) + 1; } @@ -1189,12 +1188,12 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table link_name = (char *)&link_table[nr_entries + 1]; link = link_table; - list_for_each_table_entry(entry, table) { + list_for_each_table_entry(entry, head->ctl_table) { int len = strlen(entry->procname) + 1; memcpy(link_name, entry->procname, len); link->procname = link_name; link->mode = S_IFLNK|S_IRWXUGO; - link->data = link_root; + link->data = head->root; link_name += len; link++; } @@ -1205,15 +1204,16 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table } static bool get_links(struct ctl_dir *dir, - struct ctl_table *table, struct ctl_table_root *link_root) + struct ctl_table_header *header, + struct ctl_table_root *link_root) { - struct ctl_table_header *head; + struct ctl_table_header *tmp_head; struct ctl_table *entry, *link; /* Are there links available for every entry in table? */ - list_for_each_table_entry(entry, table) { + list_for_each_table_entry(entry, header->ctl_table) { const char *procname = entry->procname; - link = find_entry(&head, dir, procname, strlen(procname)); + link = find_entry(&tmp_head, dir, procname, strlen(procname)); if (!link) return false; if (S_ISDIR(link->mode) && S_ISDIR(entry->mode)) @@ -1224,10 +1224,10 @@ static bool get_links(struct ctl_dir *dir, } /* The checks passed. Increase the registration count on the links */ - list_for_each_table_entry(entry, table) { + list_for_each_table_entry(entry, header->ctl_table) { const char *procname = entry->procname; - link = find_entry(&head, dir, procname, strlen(procname)); - head->nreg++; + link = find_entry(&tmp_head, dir, procname, strlen(procname)); + tmp_head->nreg++; } return true; } @@ -1246,13 +1246,13 @@ static int insert_links(struct ctl_table_header *head) if (IS_ERR(core_parent)) return 0; - if (get_links(core_parent, head->ctl_table, head->root)) + if (get_links(core_parent, head, head->root)) return 0; core_parent->header.nreg++; spin_unlock(&sysctl_lock); - links = new_links(core_parent, head->ctl_table, head->root); + links = new_links(core_parent, head); spin_lock(&sysctl_lock); err = -ENOMEM; @@ -1260,7 +1260,7 @@ static int insert_links(struct ctl_table_header *head) goto out; err = 0; - if (get_links(core_parent, head->ctl_table, head->root)) { + if (get_links(core_parent, head, head->root)) { kfree(links); goto out; } @@ -1371,7 +1371,7 @@ struct ctl_table_header *__register_sysctl_table( node = (struct ctl_node *)(header + 1); init_header(header, root, set, node, table); - if (sysctl_check_table(path, table)) + if (sysctl_check_table(path, header)) goto fail; spin_lock(&sysctl_lock); From patchwork Wed Jun 21 09:09:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13286908 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DADDEB64D8 for ; Wed, 21 Jun 2023 09:10:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230449AbjFUJKQ (ORCPT ); Wed, 21 Jun 2023 05:10:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbjFUJKK (ORCPT ); Wed, 21 Jun 2023 05:10:10 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FB93E69 for ; Wed, 21 Jun 2023 02:10:08 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230621091007euoutp02ea37d24455004ae4db9223fa4a704921~qoYYfYznF1099310993euoutp02R for ; Wed, 21 Jun 2023 09:10:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230621091007euoutp02ea37d24455004ae4db9223fa4a704921~qoYYfYznF1099310993euoutp02R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687338607; bh=Oc8NXUYQnci0z8MHHacFs01L4f2k2FJZpxQf2DbJLIg=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=oF60GRFyLGioSYdHBD75k6ZdUU7iMlKwRgEYt94crclGVD57S7dTyydhs3IjDQfXX KclHb7wnR27A+mH9vtdnQYKGZTpC4/TfDAe/4rNpqZn2VhkytAbs3xrBji9wzy9K7k IPqv3BtRigv2BsTbQSYZxOZjI2Vpkp1REGcLaTbY= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230621091007eucas1p1501f747bc667f973f0ba906980aa1a8d~qoYYYuuHd3044930449eucas1p1B; Wed, 21 Jun 2023 09:10:07 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 2E.7E.11320.F6EB2946; Wed, 21 Jun 2023 10:10:07 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230621091007eucas1p2271595a5889075994e8dceb0c06ae7cc~qoYYCN1e70334003340eucas1p2B; Wed, 21 Jun 2023 09:10:07 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230621091007eusmtrp280b3641910623ae8b14f3a748d75609f~qoYX1LJzl2207922079eusmtrp2H; Wed, 21 Jun 2023 09:10:07 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-80-6492be6f72e2 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 35.0F.10549.E6EB2946; Wed, 21 Jun 2023 10:10:07 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230621091006eusmtip2bbde996bf92d6f74889637872fbdd379~qoYXpJ5FV1360013600eusmtip2f; Wed, 21 Jun 2023 09:10:06 +0000 (GMT) Received: from localhost (106.210.248.248) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jun 2023 10:10:06 +0100 From: Joel Granados To: , Kees Cook , Iurii Zaikin CC: Joel Granados , , Subject: [PATCH 02/11] sysctl: Use the ctl header in list ctl_table macro Date: Wed, 21 Jun 2023 11:09:51 +0200 Message-ID: <20230621091000.424843-3-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621091000.424843-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.248] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42LZduznOd38fZNSDB5OUbU4051rsWfvSRaL y7vmsFncmPCU0WLZTj8HVo/ZDRdZPBZsKvXYtKqTzePzJrkAligum5TUnMyy1CJ9uwSujOO3 1rIVLFCumPH3HmsD4zzZLkZODgkBE4lFty6zdDFycQgJrGCUmHp1BzOE84VRYtK6+ewQzmdG ifePHzPDtJzfOAuqZTmjxNKZk1ngqvYcPcsI4WxllDh5bzcTSAubgI7E+Td3wNpFB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MztEQkZi45errBC2sMSfa11sEEUfGSU2f7nLApIQEtjK KLH0vRuIzSagI3H+zR1mEFtEIF5i9prtjCA2s0CuxKzlS8DiwgKeEqvOHgSzWQRUJe5N+gdm 8wrYSPRNfQ21WF6i7fp0sF5OAVuJ84/fQ+2ykZj/4TIjRL2gxMmZT1gg5stLNG+dzQxhS0gc fPGCGWKOssT1fYvZIOxaic9/nzFOYBSZhaR9FpL2WUjaFzAyr2IUSS0tzk3PLTbUK07MLS7N S9dLzs/dxAiMtG3Hfm7ewTjv1Ue9Q4xMHIyHGCU4mJVEeGU3TUoR4k1JrKxKLcqPLyrNSS0+ xGgK9OdEZinR5HxgrOeVxBuaGZgamphZGphamhkrifN6FnQkCgmkJ5akZqemFqQWwfQxcXBK NTCdmGA3/5KC3cutB2490Wj9sGma/PK9kesjlmxW15fbu+S4ytTWz9c4fn5NEGIxchR5f+R9 nbHNzxdSLX/Xp/Zt2chZ7mayTJ6pInz9aj+NF/FP/3XfurHWcp1l4HvfqHs6X5cLVJ6/c5TX tdj8ouAZvq9Ghro7Txp+NvpWeLdxXRLfguIPjxT2BZZEps8TeXb6W2jEeTm1R3Ubnm5Y16u2 3NQzuGml4NadG1ZaH6nJPeUS8F/9Wr6a1lnX2ckJBw9fvqnTJz6hxN2ZN2h71cFoAZ7zk3vq Xk1au6F542QrnWuabuVVAnG3y0XDQzqLXx0PkAnnsVJv3H/g/DsP7elXmV8xfrKrT5y1uC5z /m5VJZbijERDLeai4kQAXbWZ1T0DAAA= X-CMS-MailID: 20230621091007eucas1p2271595a5889075994e8dceb0c06ae7cc X-Msg-Generator: CA X-RootMTR: 20230621091007eucas1p2271595a5889075994e8dceb0c06ae7cc X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230621091007eucas1p2271595a5889075994e8dceb0c06ae7cc References: <20230621091000.424843-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Now that the ctl_header is the preferred way of passing the ctl_table pointer around, we can just use it (the header) as input to the list ctl_table macro. Signed-off-by: Joel Granados --- fs/proc/proc_sysctl.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 1d9f42840518..93f50570eab4 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -19,8 +19,8 @@ #include #include "internal.h" -#define list_for_each_table_entry(entry, table) \ - for ((entry) = (table); (entry)->procname; (entry)++) +#define list_for_each_table_entry(entry, header) \ + for ((entry) = (header->ctl_table); (entry)->procname; (entry)++) static const struct dentry_operations proc_sys_dentry_operations; static const struct file_operations proc_sys_file_operations; @@ -204,7 +204,7 @@ static void init_header(struct ctl_table_header *head, if (node) { struct ctl_table *entry; - list_for_each_table_entry(entry, table) { + list_for_each_table_entry(entry, head) { node->header = head; node++; } @@ -215,7 +215,7 @@ static void erase_header(struct ctl_table_header *head) { struct ctl_table *entry; - list_for_each_table_entry(entry, head->ctl_table) + list_for_each_table_entry(entry, head) erase_entry(head, entry); } @@ -242,7 +242,7 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) err = insert_links(header); if (err) goto fail_links; - list_for_each_table_entry(entry, header->ctl_table) { + list_for_each_table_entry(entry, header) { err = insert_entry(header, entry); if (err) goto fail; @@ -1129,7 +1129,7 @@ static int sysctl_check_table(const char *path, struct ctl_table_header *header) { struct ctl_table *entry; int err = 0; - list_for_each_table_entry(entry, header->ctl_table) { + list_for_each_table_entry(entry, header) { if ((entry->proc_handler == proc_dostring) || (entry->proc_handler == proc_dobool) || (entry->proc_handler == proc_dointvec) || @@ -1169,7 +1169,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ name_bytes = 0; nr_entries = 0; - list_for_each_table_entry(entry, head->ctl_table) { + list_for_each_table_entry(entry, head) { nr_entries++; name_bytes += strlen(entry->procname) + 1; } @@ -1188,7 +1188,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ link_name = (char *)&link_table[nr_entries + 1]; link = link_table; - list_for_each_table_entry(entry, head->ctl_table) { + list_for_each_table_entry(entry, head) { int len = strlen(entry->procname) + 1; memcpy(link_name, entry->procname, len); link->procname = link_name; @@ -1211,7 +1211,7 @@ static bool get_links(struct ctl_dir *dir, struct ctl_table *entry, *link; /* Are there links available for every entry in table? */ - list_for_each_table_entry(entry, header->ctl_table) { + list_for_each_table_entry(entry, header) { const char *procname = entry->procname; link = find_entry(&tmp_head, dir, procname, strlen(procname)); if (!link) @@ -1224,7 +1224,7 @@ static bool get_links(struct ctl_dir *dir, } /* The checks passed. Increase the registration count on the links */ - list_for_each_table_entry(entry, header->ctl_table) { + list_for_each_table_entry(entry, header) { const char *procname = entry->procname; link = find_entry(&tmp_head, dir, procname, strlen(procname)); tmp_head->nreg++; @@ -1356,12 +1356,14 @@ struct ctl_table_header *__register_sysctl_table( { struct ctl_table_root *root = set->dir.header.root; struct ctl_table_header *header; + struct ctl_table_header h_tmp; struct ctl_dir *dir; struct ctl_table *entry; struct ctl_node *node; int nr_entries = 0; - list_for_each_table_entry(entry, table) + h_tmp.ctl_table = table; + list_for_each_table_entry(entry, (&h_tmp)) nr_entries++; header = kzalloc(sizeof(struct ctl_table_header) + @@ -1471,7 +1473,7 @@ static void put_links(struct ctl_table_header *header) if (IS_ERR(core_parent)) return; - list_for_each_table_entry(entry, header->ctl_table) { + list_for_each_table_entry(entry, header) { struct ctl_table_header *link_head; struct ctl_table *link; const char *name = entry->procname; From patchwork Wed Jun 21 09:09:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13286909 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DF57EB64D8 for ; Wed, 21 Jun 2023 09:10:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbjFUJKW (ORCPT ); Wed, 21 Jun 2023 05:10:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230303AbjFUJKM (ORCPT ); Wed, 21 Jun 2023 05:10:12 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6FE7E60 for ; Wed, 21 Jun 2023 02:10:10 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230621091009euoutp01414855c9150d6df69414892a6173bf5a~qoYaC9OOX1127311273euoutp01E for ; Wed, 21 Jun 2023 09:10:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230621091009euoutp01414855c9150d6df69414892a6173bf5a~qoYaC9OOX1127311273euoutp01E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687338609; bh=2vCkgLvpZCXFi6D3nJ5E3ic3+Plkyq+z4m9VdlmF+tc=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=p45yve07kwC68GtIMT5d4UuvqBOWu2cSFwoZ+ynWNWeyF94KAVcnnUOKpMasfav0J NM9OkqPVg7Ffa4vHM/Jjair7jLwFviLCYq93asj8ACGqif2BQ06zXYrwfY+wJ3/xpl FHLXcMpc3oSPrcrQw6bJZWow/cfpIN0AHIsbq5QY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230621091009eucas1p15b47d6bbe8cea318f99993a88cfe9fdc~qoYZ8Xc-m1959619596eucas1p1P; Wed, 21 Jun 2023 09:10:09 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 94.22.42423.17EB2946; Wed, 21 Jun 2023 10:10:09 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230621091009eucas1p1e4fa56beb44e49e4d1160bfac6eb59ec~qoYZmI4cE2902229022eucas1p1L; Wed, 21 Jun 2023 09:10:09 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230621091009eusmtrp255bd4fcf710e16ebcd0800c2e9b5b1b2~qoYZlkJ072182221822eusmtrp2A; Wed, 21 Jun 2023 09:10:09 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-23-6492be71e45a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0B.D1.14344.07EB2946; Wed, 21 Jun 2023 10:10:08 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230621091008eusmtip11efe1355c1286893018073e5816c5420~qoYZcDnZn2784427844eusmtip1L; Wed, 21 Jun 2023 09:10:08 +0000 (GMT) Received: from localhost (106.210.248.248) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jun 2023 10:10:08 +0100 From: Joel Granados To: , Kees Cook , Iurii Zaikin CC: Joel Granados , , Subject: [PATCH 03/11] sysctl: Add ctl_table_size to ctl_table_header Date: Wed, 21 Jun 2023 11:09:52 +0200 Message-ID: <20230621091000.424843-4-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621091000.424843-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.248] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002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nAqD6PN3edbA/Z/uXBFeEH0 jOlNfEosxRmJhlrMRcWJAGf+NPc+AwAA X-CMS-MailID: 20230621091009eucas1p1e4fa56beb44e49e4d1160bfac6eb59ec X-Msg-Generator: CA X-RootMTR: 20230621091009eucas1p1e4fa56beb44e49e4d1160bfac6eb59ec X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230621091009eucas1p1e4fa56beb44e49e4d1160bfac6eb59ec References: <20230621091000.424843-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The new ctl_table_size element will hold the size of the ctl_table contained in the header. This value is passed by the callers to the sysctl register infra. Add a new macro that uses the size to traverse the ctl_table in the header. This moves away from using the last empty element in the ctl_table array as a stop post Signed-off-by: Joel Granados --- include/linux/sysctl.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 59d451f455bf..33252ad58ebe 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -159,12 +159,22 @@ struct ctl_node { struct ctl_table_header *header; }; -/* struct ctl_table_header is used to maintain dynamic lists of - struct ctl_table trees. */ +/** + * struct ctl_table_header - maintains dynamic lists of struct ctl_table trees + * @ctl_table: pointer to the first element in ctl_table array + * @ctl_table_size: number of elements pointed by @ctl_table + * @used: The entry will never be touched when equal to 0. + * @count: Upped every time something is added to @inodes and downed every time + * something is removed from inodes + * @nreg: When nreg drops to 0 the ctl_table_header will be unregistered. + * @rcu: Delays the freeing of the inode. Introduced with "unfuck proc_sysctl ->d_compare()" + * + */ struct ctl_table_header { union { struct { struct ctl_table *ctl_table; + int ctl_table_size; int used; int count; int nreg; From patchwork Wed Jun 21 09:09:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13286910 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82812EB64DC for ; Wed, 21 Jun 2023 09:10:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231221AbjFUJKq (ORCPT ); Wed, 21 Jun 2023 05:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjFUJKU (ORCPT ); Wed, 21 Jun 2023 05:10:20 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74F0A1706 for ; Wed, 21 Jun 2023 02:10:13 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230621091012euoutp02191277d8f9eab32ff07761d7ce277fd9~qoYctmGdc0948409484euoutp02u for ; Wed, 21 Jun 2023 09:10:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230621091012euoutp02191277d8f9eab32ff07761d7ce277fd9~qoYctmGdc0948409484euoutp02u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687338612; bh=AoMNSAYFebvCfAbJVURrKKQ+f+N43EEZeoinYWLcJEA=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=dIPKQMmQ4d+pQvr+hJxudwI1UHUZ/+e3LofR3FGL74JltPYkvnSxQD0FGvLPxXkb1 elYxI6DFohWjICGwE8FphJF39tNmwBijuTD/A6/+ev3r7AbVl0pb55FVXI0lK2G5uk o/fk+Dl+lFXfliOHoYQotO18nnl/VSW53pZYWVDw= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230621091012eucas1p1a2f3a7d352129dc0f20ad47059407a53~qoYckoQDV1960419604eucas1p1G; Wed, 21 Jun 2023 09:10:12 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id E7.22.42423.47EB2946; Wed, 21 Jun 2023 10:10:12 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230621091011eucas1p2116c1fb8f406bec7ca9a831f66955724~qoYcQz0oP1816318163eucas1p2w; Wed, 21 Jun 2023 09:10:11 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230621091011eusmtrp295fa787611dfbbdf45e99ac95838ec76~qoYcQUW1K2182221822eusmtrp2G; Wed, 21 Jun 2023 09:10:11 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-2f-6492be741167 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0D.D1.14344.37EB2946; Wed, 21 Jun 2023 10:10:11 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230621091011eusmtip2f260d25450a384653ab6d488110306ff~qoYcDyeeq1998819988eusmtip2Z; Wed, 21 Jun 2023 09:10:11 +0000 (GMT) Received: from localhost (106.210.248.248) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jun 2023 10:10:11 +0100 From: Joel Granados To: , Kees Cook , Iurii Zaikin CC: Joel Granados , , Subject: [PATCH 04/11] sysctl: Add size argument to init_header Date: Wed, 21 Jun 2023 11:09:53 +0200 Message-ID: <20230621091000.424843-5-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621091000.424843-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.248] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkleLIzCtJLcpLzFFi42LZduzned2SfZNSDPqucVmc6c612LP3JIvF 5V1z2CxuTHjKaLFsp58Dq8fshossHgs2lXpsWtXJ5vF5k1wASxSXTUpqTmZZapG+XQJXRufe 38wFK4Qrbuw8zdbA2C/QxcjJISFgIrGkaS1TFyMXh5DACkaJxoet7BDOF0aJ1hOXoJzPjBK3 v/1l62LkAGs5/ZUFpFtIYDmjxLZj7hA2UM2DOQIQ9VsZJd7vv8kEkmAT0JE4/+YOM4gtIhAv MXvNdkYQm1kgV2LW8iVgcWEBe4kdj5+ygdgsAqoSv/Z+YAWxeQVsJN7+OsIKcaq8RNv16WC9 nAK2Eucfv2eBqBGUODnzCQvETHmJ5q2zmSFsCYmDL14wQ/QqS1zft5gNwq6VOLXlFtjLEgJX OCSW9u1hgki4SJxf+xSqSFji1fEt7BC2jMT/nfOhGiYzSuz/94EdwlnNKLGs8StUt7VEy5Un UB2OEvOmbmCGBBefxI23ghAX8UlM2jYdKswr0dEmNIFRZRaSH2Yh+WEWkh8WMDKvYhRPLS3O TU8tNsxLLdcrTswtLs1L10vOz93ECEwlp/8d/7SDce6rj3qHGJk4GA8xSnAwK4nwym6alCLE m5JYWZValB9fVJqTWnyIUZqDRUmcV9v2ZLKQQHpiSWp2ampBahFMlomDU6qByTrL84J4imFQ M7/shl+HS27OOdcv9LV6vXqXm8rC66fXTTwltGV13eWyR5FFQYJq5uLvm2R8spcH/s8u7N4x Naz8az/fhVpprj+7X9roHdu88uT53b+93V9fmvhsVs8ah3f/7WqvSrN/Db/n+myGtKSEUnfD ye17bCqV5HZWq94/cctT7WDhba/8fzJyrW/1tu0SecKYq8f/35LJc4HEde59xX/OF5pyM+Qd vXwxxv/E727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kxbr55RXTllWtV7ccM20ZAt+gdt0jad4Nhh m/3Xf93f+fnqWuu32e6xD1qVetd2K/sWlquCP4W95Fsyvxycus13/tYjc/MWvrQ88jmBxbr+ D4ORl4sSS3FGoqEWc1FxIgCCrsLJPQMAAA== X-CMS-MailID: 20230621091011eucas1p2116c1fb8f406bec7ca9a831f66955724 X-Msg-Generator: CA X-RootMTR: 20230621091011eucas1p2116c1fb8f406bec7ca9a831f66955724 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230621091011eucas1p2116c1fb8f406bec7ca9a831f66955724 References: <20230621091000.424843-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Pass the size of the ctl_table to properly initialize the ctl_table_header struct. This is a preparation commit for when we start traversing the ctl_table array with the size in ctl_table_header. In __register_sysctl_table we use a calculated size until we add the size argument to that function Signed-off-by: Joel Granados --- fs/proc/proc_sysctl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 93f50570eab4..09c09c373624 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -188,9 +188,10 @@ static void erase_entry(struct ctl_table_header *head, struct ctl_table *entry) static void init_header(struct ctl_table_header *head, struct ctl_table_root *root, struct ctl_table_set *set, - struct ctl_node *node, struct ctl_table *table) + struct ctl_node *node, struct ctl_table *table, size_t table_size) { head->ctl_table = table; + head->ctl_table_size = table_size; head->ctl_table_arg = table; head->used = 0; head->count = 1; @@ -973,7 +974,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set, memcpy(new_name, name, namelen); table[0].procname = new_name; table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO; - init_header(&new->header, set->dir.header.root, set, node, table); + init_header(&new->header, set->dir.header.root, set, node, table, 1); return new; } @@ -1197,7 +1198,8 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ link_name += len; link++; } - init_header(links, dir->header.root, dir->header.set, node, link_table); + init_header(links, dir->header.root, dir->header.set, node, link_table, + head->ctl_table_size); links->nreg = nr_entries; return links; @@ -1372,7 +1374,7 @@ struct ctl_table_header *__register_sysctl_table( return NULL; node = (struct ctl_node *)(header + 1); - init_header(header, root, set, node, table); + init_header(header, root, set, node, table, nr_entries); if (sysctl_check_table(path, header)) goto fail; @@ -1537,7 +1539,7 @@ void setup_sysctl_set(struct ctl_table_set *set, { memset(set, 0, sizeof(*set)); set->is_seen = is_seen; - init_header(&set->dir.header, root, set, NULL, root_table); + init_header(&set->dir.header, root, set, NULL, root_table, 1); } void retire_sysctl_set(struct ctl_table_set *set) From patchwork Wed Jun 21 09:09:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13286919 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9196EB64D7 for ; Wed, 21 Jun 2023 09:11:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbjFUJLS (ORCPT ); Wed, 21 Jun 2023 05:11:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230303AbjFUJKc (ORCPT ); Wed, 21 Jun 2023 05:10:32 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46DFB19AC for ; Wed, 21 Jun 2023 02:10:16 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230621091015euoutp01f2d6413b73cc7794fadbed7d50e68ac6~qoYfUQlYO1148511485euoutp01E for ; Wed, 21 Jun 2023 09:10:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230621091015euoutp01f2d6413b73cc7794fadbed7d50e68ac6~qoYfUQlYO1148511485euoutp01E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687338615; bh=OWywfsEHW6wNB9csZSR6nbz7s47Wj0frTeIAnopGDR4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=KSH/H253lKqtKFMDmm8dEdmUj6T6OKFK6Jk8h6UJtHuMTa3CciVENHtKMbLVYwTVd XfOJJdqx2xMDgqj3gTPSlO6avC/i7vleGoAbCN9HcZ3rhLBdLg4QxNeUPREFgUx3mn H3M/DG/ph+jBxp6owAHJ3aYJ1AymgZQIlf3RrZcY= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230621091014eucas1p1f04da8b1fb1dad1e10c0b30185138bc7~qoYez4JUH2864928649eucas1p1H; Wed, 21 Jun 2023 09:10:14 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 35.8E.11320.67EB2946; Wed, 21 Jun 2023 10:10:14 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230621091014eucas1p1a30430568d0f7fec5ccbed31cab73aa0~qoYeXJLcA3218932189eucas1p17; Wed, 21 Jun 2023 09:10:14 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230621091014eusmtrp258b508b40395627575162a2d27af0935~qoYeWjday2207922079eusmtrp2a; Wed, 21 Jun 2023 09:10:14 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-a5-6492be760730 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B9.0F.10549.67EB2946; Wed, 21 Jun 2023 10:10:14 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230621091013eusmtip175549cf05b6fa79e82b1c8d646058274~qoYeM01d-2702427024eusmtip1e; Wed, 21 Jun 2023 09:10:13 +0000 (GMT) Received: from localhost (106.210.248.248) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jun 2023 10:10:13 +0100 From: Joel Granados To: , Kees Cook , Iurii Zaikin , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni CC: Joel Granados , , , Subject: [PATCH 05/11] sysctl: Add a size arg to __register_sysctl_table Date: Wed, 21 Jun 2023 11:09:54 +0200 Message-ID: <20230621091000.424843-6-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621091000.424843-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.248] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGKsWRmVeSWpSXmKPExsWy7djP87pl+yalGNzqlLGYc76FxeLpsUfs Fme6cy0ubOtjtdiz9ySLxeVdc9gsbkx4ymhxbIGYxbfTbxgtlu30c+DymN1wkcVjy8qbTB4L NpV6bFrVyebxft9VNo/Pm+QC2KK4bFJSczLLUov07RK4Mp6ffM9SMFOzYvOptWwNjE1KXYyc HBICJhKTp21j6mLk4hASWMEocXHLbVYI5wujxNK/x9lAqoQEPjNKXD6uCNMxqeklG0TRckaJ 1f/PQzlARU+XbGeGcLYySmzaOAesnU1AR+L8mztgCRGQqsN/9zKBJJgF2hklTnzPA7GFBTwk Nj/YwAhisw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ASWMoo sez3PRaIhIzExi9XWSFsYYk/17qgij4ySszfPpMdwtnKKHHn6itGkCo2AR2J82/uMIMkRAQ+ M0oc/ruXCSTBLNDOKHHiex6ILSzgIbH5wQawBhYBVYnmY2/ZQWxeARuJeU1XmSDWyUu0XZ8O VsMpYCtx/vF7sJOEgGrmf7jMCFEvKHFy5hMWiPnyEs1bZzND2BISB1+8YIaYoyxxfd9iNgi7 VuLz32eMExhFZiFpn4WkfRaS9gWMzKsYRVJLi3PTc4sN9YoTc4tL89L1kvNzNzECI3bbsZ+b dzDOe/VR7xAjEwfjIUYJDmYlEV7ZTZNShHhTEiurUovy44tKc1KLDzGaAv05kVlKNDkfmDLy SuINzQxMDU3MLA1MLc2MlcR5PQs6EoUE0hNLUrNTUwtSi2D6mDg4pRqYpt4wcW7gbtvyd5XO knfBGX+mJNvEPG2y1Mralmmd17wpRfDAzh1Bl3x3/r/0+Z3G75zj0ZtqdSK2ejXffCORxx/v F/UjrnFShJve+t/SnjvmR0+cYpjo6v78rcenfS+9k22eum//xqyaMzMs1iXyKMP+U6F5cssf n1oSoO2+4dvxLwazY4NmfzkaK+36LsW/+4z20kg9hxneU9Tq10+qLP4mfeWy5LW4IxM+Zm/Q DjJpZE3Y9e5/b3L2zWeGteclTq6zuOD9Imz+TZPQH6cK+d+ErH+m1fQzyVo6bJOYonv3nryI U4d26Sp/snok5qak/68o46ZXpzG3m2hOnWthdmhR2zKFZ6b970NeR3YqsRRnJBpqMRcVJwIA PC6WYmEDAAA= X-CMS-MailID: 20230621091014eucas1p1a30430568d0f7fec5ccbed31cab73aa0 X-Msg-Generator: CA X-RootMTR: 20230621091014eucas1p1a30430568d0f7fec5ccbed31cab73aa0 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230621091014eucas1p1a30430568d0f7fec5ccbed31cab73aa0 References: <20230621091000.424843-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In order to remove the end element from the ctl_table struct arrays, we explicitly define the size when registering the targets. __register_sysctl_table is the first function to grow a size argument. For this commit to focus only on that function, we temporarily implement a size calculation in register_net_sysctl, which is an indirection call for all the network register calls. Signed-off-by: Joel Granados --- fs/proc/proc_sysctl.c | 22 +++++++++++----------- include/linux/sysctl.h | 2 +- ipc/ipc_sysctl.c | 4 +++- ipc/mq_sysctl.c | 4 +++- kernel/ucount.c | 3 ++- net/sysctl_net.c | 8 +++++++- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 09c09c373624..8c415048d540 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1354,27 +1354,20 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path) */ struct ctl_table_header *__register_sysctl_table( struct ctl_table_set *set, - const char *path, struct ctl_table *table) + const char *path, struct ctl_table *table, size_t table_size) { struct ctl_table_root *root = set->dir.header.root; struct ctl_table_header *header; - struct ctl_table_header h_tmp; struct ctl_dir *dir; - struct ctl_table *entry; struct ctl_node *node; - int nr_entries = 0; - - h_tmp.ctl_table = table; - list_for_each_table_entry(entry, (&h_tmp)) - nr_entries++; header = kzalloc(sizeof(struct ctl_table_header) + - sizeof(struct ctl_node)*nr_entries, GFP_KERNEL_ACCOUNT); + sizeof(struct ctl_node)*table_size, GFP_KERNEL_ACCOUNT); if (!header) return NULL; node = (struct ctl_node *)(header + 1); - init_header(header, root, set, node, table, nr_entries); + init_header(header, root, set, node, table, table_size); if (sysctl_check_table(path, header)) goto fail; @@ -1423,8 +1416,15 @@ struct ctl_table_header *__register_sysctl_table( */ struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table) { + int count = 0; + struct ctl_table *entry; + struct ctl_table_header t_hdr; + + t_hdr.ctl_table = table; + list_for_each_table_entry(entry, (&t_hdr)) + count++; return __register_sysctl_table(&sysctl_table_root.default_set, - path, table); + path, table, count); } EXPORT_SYMBOL(register_sysctl); diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 33252ad58ebe..0495c858989f 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -226,7 +226,7 @@ extern void retire_sysctl_set(struct ctl_table_set *set); struct ctl_table_header *__register_sysctl_table( struct ctl_table_set *set, - const char *path, struct ctl_table *table); + const char *path, struct ctl_table *table, size_t table_size); struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table); void unregister_sysctl_table(struct ctl_table_header * table); diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c index ef313ecfb53a..8c62e443f78b 100644 --- a/ipc/ipc_sysctl.c +++ b/ipc/ipc_sysctl.c @@ -259,7 +259,9 @@ bool setup_ipc_sysctls(struct ipc_namespace *ns) tbl[i].data = NULL; } - ns->ipc_sysctls = __register_sysctl_table(&ns->ipc_set, "kernel", tbl); + ns->ipc_sysctls = __register_sysctl_table(&ns->ipc_set, + "kernel", tbl, + ARRAY_SIZE(ipc_sysctls)); } if (!ns->ipc_sysctls) { kfree(tbl); diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c index fbf6a8b93a26..ebb5ed81c151 100644 --- a/ipc/mq_sysctl.c +++ b/ipc/mq_sysctl.c @@ -109,7 +109,9 @@ bool setup_mq_sysctls(struct ipc_namespace *ns) tbl[i].data = NULL; } - ns->mq_sysctls = __register_sysctl_table(&ns->mq_set, "fs/mqueue", tbl); + ns->mq_sysctls = __register_sysctl_table(&ns->mq_set, + "fs/mqueue", tbl, + ARRAY_SIZE(mq_sysctls)); } if (!ns->mq_sysctls) { kfree(tbl); diff --git a/kernel/ucount.c b/kernel/ucount.c index ee8e57fd6f90..2b80264bb79f 100644 --- a/kernel/ucount.c +++ b/kernel/ucount.c @@ -104,7 +104,8 @@ bool setup_userns_sysctls(struct user_namespace *ns) for (i = 0; i < UCOUNT_COUNTS; i++) { tbl[i].data = &ns->ucount_max[i]; } - ns->sysctls = __register_sysctl_table(&ns->set, "user", tbl); + ns->sysctls = __register_sysctl_table(&ns->set, "user", tbl, + ARRAY_SIZE(user_table)); } if (!ns->sysctls) { kfree(tbl); diff --git a/net/sysctl_net.c b/net/sysctl_net.c index 4b45ed631eb8..8ee4b74bc009 100644 --- a/net/sysctl_net.c +++ b/net/sysctl_net.c @@ -163,10 +163,16 @@ static void ensure_safe_net_sysctl(struct net *net, const char *path, struct ctl_table_header *register_net_sysctl(struct net *net, const char *path, struct ctl_table *table) { + int count = 0; + struct ctl_table *entry; + if (!net_eq(net, &init_net)) ensure_safe_net_sysctl(net, path, table); - return __register_sysctl_table(&net->sysctls, path, table); + for (entry = table; entry->procname; entry++) + count++; + + return __register_sysctl_table(&net->sysctls, path, table, count); } EXPORT_SYMBOL_GPL(register_net_sysctl); From patchwork Wed Jun 21 09:09:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13286920 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C423C001DB for ; Wed, 21 Jun 2023 09:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231534AbjFUJL5 (ORCPT ); Wed, 21 Jun 2023 05:11:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231731AbjFUJLO (ORCPT ); Wed, 21 Jun 2023 05:11:14 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23AA1FF2; Wed, 21 Jun 2023 02:10:33 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230621091030euoutp014ad40326cb733a0a56272604c4496620~qoYt05suO1148511485euoutp01L; Wed, 21 Jun 2023 09:10:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230621091030euoutp014ad40326cb733a0a56272604c4496620~qoYt05suO1148511485euoutp01L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687338630; bh=A9vJqtefMweXRl5hA0piF7XKpY7+Y1RrvCTm+EtEXlQ=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Ka4ZfoeHZ9KJZ0KIhhdzO1ExiUUNFd4pQTnInOxAgqyf0eUSdqf9fGf4ADqTzHos1 ywZFhN8UlbjrBOzPZnyD8ZTVyakxnTGgnKeSkWsclDeJldAylGgwILHjQdvJGQ1yCF Ta2ndNd0iIyvJvB9swtxZqirf7z/BsD/JzVDihvI= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230621091030eucas1p2b9431b5e8ae4acfd91cec8a259953008~qoYtbzuHT2538825388eucas1p2C; Wed, 21 Jun 2023 09:10:30 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 1D.84.37758.58EB2946; Wed, 21 Jun 2023 10:10:30 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230621091029eucas1p2f9fd694dae3dfbdfffd25dccf4fcb568~qoYsgN9G-1816318163eucas1p2-; Wed, 21 Jun 2023 09:10:29 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230621091029eusmtrp2a0edd6b63446d061037baf6b483c48bb~qoYsaZmkS2225722257eusmtrp2B; Wed, 21 Jun 2023 09:10:29 +0000 (GMT) X-AuditID: cbfec7f5-815ff7000002937e-7e-6492be85d3cb Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D9.E1.14344.48EB2946; Wed, 21 Jun 2023 10:10:28 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230621091028eusmtip2a2c40ec1c961aabd77e7ae0ea239ab31~qoYr28XcU1980519805eusmtip2i; Wed, 21 Jun 2023 09:10:28 +0000 (GMT) Received: from localhost (106.210.248.248) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jun 2023 10:10:27 +0100 From: Joel Granados To: , Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Gerald Schaefer , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , Herbert Xu , "David S. Miller" , Russ Weight , Greg Kroah-Hartman , Phillip Potter , Clemens Ladisch , Arnd Bergmann , Corey Minyard , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Benjamin Herrenschmidt , Song Liu , Robin Holt , Steve Wahl , Sudip Mukherjee , Mark Rutland , "James E.J. Bottomley" , "Martin K. Petersen" , Doug Gilbert , David Howells , Jan Harkes , , Alexander Viro , Christian Brauner , Chuck Lever , Jeff Layton , Trond Myklebust , Anna Schumaker , Jan Kara , Anton Altaparmakov , Mark Fasheh , Joel Becker , Joseph Qi , Kees Cook , Iurii Zaikin , Eric Biggers , "Theodore Y. Ts'o" , "Darrick J. Wong" , John Stultz , Eric Dumazet , Jakub Kicinski , Paolo Abeni , John Johansen , Paul Moore , James Morris , "Serge E. Hallyn" CC: Joel Granados , Nicholas Piggin , Christophe Leroy , Christian Borntraeger , Sven Schnelle , "H. Peter Anvin" , "Rafael J. Wysocki" , Mike Travis , Amir Goldstein , Matthew Bobrowski , Stephen Boyd , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH 07/11] sysctl: Add size to register_sysctl Date: Wed, 21 Jun 2023 11:09:56 +0200 Message-ID: <20230621091000.424843-8-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621091000.424843-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.248] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA01Te0xTdxTe797bewsRdi1m/AJsRBS26ETcWHLcREe26M10zswlW3xtBa5g pOBa1OkyQylvnNE6BgJDEOTRIoWKKAQ6x5CHbLxaqEzU8Iq1CK0iIg9hwmUL/33nfN93ft85 yU9MSvoYN/GhiCheHiEN96IdqcqGybZ18QZ1iF+MiYDylkc0NJkvEdBeqkUQVzVHQZW+QgTK hhwRvFQ3MGCPiSNh4GUdDWNlszQM//kUga3gNIJe9UMG5u49JCC/qY+A5yV3CIhWzdBgKUtA kNUWS4EhVo/AkH6FhtGYaQqMg85gGrfRcKVmhoShhn4GkvrnaLCpDkB7xnMRqPJ0NHRf52A4 W4MgxeoBv5a7QubZqwRkpqkIuHw3SQSFRh2CyQINA82tzyko1eUR0PQsjobaXAKKC14wMNNU TsNfKTJorzwjgkHtNQb0A90ieJJ/m4EH9ycJqKltpiD1nJ0Ge+KoCIzVWTS032wRQUJiFoKE i9UIzuaqSEgx33glOd1PQ/XMDQbqUmsRTE/Mij4O4Yym7dxE3BmKK8kuQZyxu4PkpqfUiMuI /pnmMqM7KE5bUk9yOfU7uPGeVoKrKO4huEuPoiluqONLTtejprmqjHsMV3nTe9eGPY6bQvjw Q8d4+frN3zmGJXbqyCMdvxE/jA6Pi6KR0YqSkYMYs/64vKiVSUaOYglbhHBL2zlynpCwzxBu N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8r2d8zX2cUnnhx0Px6HmxVfuGXcey3r95J2YiuGyM/Su5ePSiYMP 0kUBuvg3ufisM1/v35hwVlt2pT/Aq26/avZ4U6rH2NrD06HMwrkXnErKbHS5Gg/Nn8GJ8X67 Z7sCxN66wBtTlKHAIWZf1se+IqdD3/MIaYTA5TVcIhX8B9lnSFCdBAAA X-CMS-MailID: 20230621091029eucas1p2f9fd694dae3dfbdfffd25dccf4fcb568 X-Msg-Generator: CA X-RootMTR: 20230621091029eucas1p2f9fd694dae3dfbdfffd25dccf4fcb568 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230621091029eucas1p2f9fd694dae3dfbdfffd25dccf4fcb568 References: <20230621091000.424843-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In order to remove the end element from the ctl_table struct arrays, we explicitly define the size when registering the targes. We add a size argument to register_sysctl and change all the callers to pass the ARRAY_SIZE of their table arg. Signed-off-by: Joel Granados --- arch/arm/kernel/isa.c | 2 +- arch/arm64/kernel/armv8_deprecated.c | 2 +- arch/arm64/kernel/fpsimd.c | 6 +++-- arch/arm64/kernel/process.c | 3 ++- arch/ia64/kernel/crash.c | 3 ++- arch/powerpc/kernel/idle.c | 3 ++- arch/powerpc/platforms/pseries/mobility.c | 3 ++- arch/s390/appldata/appldata_base.c | 4 +++- arch/s390/kernel/debug.c | 3 ++- arch/s390/kernel/topology.c | 3 ++- arch/s390/mm/cmm.c | 3 ++- arch/s390/mm/pgalloc.c | 3 ++- arch/x86/entry/vdso/vdso32-setup.c | 2 +- arch/x86/kernel/itmt.c | 3 ++- crypto/fips.c | 3 ++- drivers/base/firmware_loader/fallback_table.c | 6 ++--- drivers/cdrom/cdrom.c | 3 ++- drivers/char/hpet.c | 3 ++- drivers/char/ipmi/ipmi_poweroff.c | 3 ++- drivers/gpu/drm/i915/i915_perf.c | 3 ++- drivers/hv/hv_common.c | 3 ++- drivers/macintosh/mac_hid.c | 3 ++- drivers/md/md.c | 3 ++- drivers/misc/sgi-xp/xpc_main.c | 6 +++-- drivers/parport/procfs.c | 11 +++++---- drivers/perf/arm_pmuv3.c | 3 ++- drivers/scsi/scsi_sysctl.c | 3 ++- drivers/scsi/sg.c | 3 ++- fs/cachefiles/error_inject.c | 3 ++- fs/coda/sysctl.c | 3 ++- fs/devpts/inode.c | 3 ++- fs/eventpoll.c | 2 +- fs/lockd/svc.c | 3 ++- fs/nfs/nfs4sysctl.c | 3 ++- fs/nfs/sysctl.c | 3 ++- fs/notify/fanotify/fanotify_user.c | 3 ++- fs/notify/inotify/inotify_user.c | 3 ++- fs/ntfs/sysctl.c | 3 ++- fs/ocfs2/stackglue.c | 3 ++- fs/proc/proc_sysctl.c | 23 ++++++++++--------- fs/verity/signature.c | 4 +++- fs/xfs/xfs_sysctl.c | 3 ++- include/linux/sysctl.h | 6 +++-- kernel/pid_sysctl.h | 2 +- kernel/time/timer.c | 2 +- kernel/ucount.c | 2 +- kernel/utsname_sysctl.c | 2 +- lib/test_sysctl.c | 9 +++++--- net/sunrpc/sysctl.c | 3 ++- net/sunrpc/xprtrdma/svc_rdma.c | 3 ++- net/sunrpc/xprtrdma/transport.c | 4 +++- net/sunrpc/xprtsock.c | 4 +++- net/sysctl_net.c | 2 +- security/apparmor/lsm.c | 3 ++- security/loadpin/loadpin.c | 3 ++- security/yama/yama_lsm.c | 3 ++- 56 files changed, 133 insertions(+), 76 deletions(-) diff --git a/arch/arm/kernel/isa.c b/arch/arm/kernel/isa.c index 20218876bef2..561432e3c55a 100644 --- a/arch/arm/kernel/isa.c +++ b/arch/arm/kernel/isa.c @@ -46,5 +46,5 @@ register_isa_ports(unsigned int membase, unsigned int portbase, unsigned int por isa_membase = membase; isa_portbase = portbase; isa_portshift = portshift; - isa_sysctl_header = register_sysctl("bus/isa", ctl_isa_vars); + isa_sysctl_header = register_sysctl("bus/isa", ctl_isa_vars, ARRAY_SIZE(ctl_isa_vars)); } diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c index 1febd412b4d2..68ed60a521a6 100644 --- a/arch/arm64/kernel/armv8_deprecated.c +++ b/arch/arm64/kernel/armv8_deprecated.c @@ -569,7 +569,7 @@ static void __init register_insn_emulation(struct insn_emulation *insn) sysctl->extra2 = &insn->max; sysctl->proc_handler = emulation_proc_handler; - register_sysctl("abi", sysctl); + register_sysctl("abi", sysctl, 1); } } diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 2fbafa5cc7ac..ecfb2ef6a036 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -595,7 +595,8 @@ static struct ctl_table sve_default_vl_table[] = { static int __init sve_sysctl_init(void) { if (system_supports_sve()) - if (!register_sysctl("abi", sve_default_vl_table)) + if (!register_sysctl("abi", sve_default_vl_table, + ARRAY_SIZE(sve_default_vl_table))) return -EINVAL; return 0; @@ -619,7 +620,8 @@ static struct ctl_table sme_default_vl_table[] = { static int __init sme_sysctl_init(void) { if (system_supports_sme()) - if (!register_sysctl("abi", sme_default_vl_table)) + if (!register_sysctl("abi", sme_default_vl_table, + ARRAY_SIZE(sme_default_vl_table))) return -EINVAL; return 0; diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 0fcc4eb1a7ab..cfe232960f2f 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -729,7 +729,8 @@ static struct ctl_table tagged_addr_sysctl_table[] = { static int __init tagged_addr_init(void) { - if (!register_sysctl("abi", tagged_addr_sysctl_table)) + if (!register_sysctl("abi", tagged_addr_sysctl_table, + ARRAY_SIZE(tagged_addr_sysctl_table))) return -EINVAL; return 0; } diff --git a/arch/ia64/kernel/crash.c b/arch/ia64/kernel/crash.c index 88b3ce3e66cd..66917b879b2a 100644 --- a/arch/ia64/kernel/crash.c +++ b/arch/ia64/kernel/crash.c @@ -248,7 +248,8 @@ machine_crash_setup(void) if((ret = register_die_notifier(&kdump_init_notifier_nb)) != 0) return ret; #ifdef CONFIG_SYSCTL - register_sysctl("kernel", kdump_ctl_table); + register_sysctl("kernel", kdump_ctl_table, + ARRAY_SIZE(kdump_ctl_table)); #endif return 0; } diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c index b1c0418b25c8..3807169fc7e7 100644 --- a/arch/powerpc/kernel/idle.c +++ b/arch/powerpc/kernel/idle.c @@ -111,7 +111,8 @@ static struct ctl_table powersave_nap_ctl_table[] = { static int __init register_powersave_nap_sysctl(void) { - register_sysctl("kernel", powersave_nap_ctl_table); + register_sysctl("kernel", powersave_nap_ctl_table, + ARRAY_SIZE(powersave_nap_ctl_table)); return 0; } diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c index 6f30113b5468..9fdbee8ee126 100644 --- a/arch/powerpc/platforms/pseries/mobility.c +++ b/arch/powerpc/platforms/pseries/mobility.c @@ -65,7 +65,8 @@ static struct ctl_table nmi_wd_lpm_factor_ctl_table[] = { static int __init register_nmi_wd_lpm_factor_sysctl(void) { - register_sysctl("kernel", nmi_wd_lpm_factor_ctl_table); + register_sysctl("kernel", nmi_wd_lpm_factor_ctl_table, + ARRAY_SIZE(nmi_wd_lpm_factor_ctl_table)); return 0; } diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c index b07b0610950e..54d8ed1c4518 100644 --- a/arch/s390/appldata/appldata_base.c +++ b/arch/s390/appldata/appldata_base.c @@ -408,7 +408,9 @@ static int __init appldata_init(void) appldata_wq = alloc_ordered_workqueue("appldata", 0); if (!appldata_wq) return -ENOMEM; - appldata_sysctl_header = register_sysctl(appldata_proc_name, appldata_table); + appldata_sysctl_header = register_sysctl(appldata_proc_name, + appldata_table, + ARRAY_SIZE(appldata_table)); return 0; } diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c index a85e0c3e7027..002f843e6523 100644 --- a/arch/s390/kernel/debug.c +++ b/arch/s390/kernel/debug.c @@ -1564,7 +1564,8 @@ static int debug_sprintf_format_fn(debug_info_t *id, struct debug_view *view, */ static int __init debug_init(void) { - s390dbf_sysctl_header = register_sysctl("s390dbf", s390dbf_table); + s390dbf_sysctl_header = register_sysctl("s390dbf", s390dbf_table, + ARRAY_SIZE(s390dbf_table)); mutex_lock(&debug_mutex); debug_debugfs_root_entry = debugfs_create_dir(DEBUG_DIR_ROOT, NULL); initialized = 1; diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c index 9fd19530c9a5..372d2c7c9a8e 100644 --- a/arch/s390/kernel/topology.c +++ b/arch/s390/kernel/topology.c @@ -647,7 +647,8 @@ static int __init topology_init(void) set_topology_timer(); else topology_update_polarization_simple(); - register_sysctl("s390", topology_ctl_table); + register_sysctl("s390", topology_ctl_table, + ARRAY_SIZE(topology_ctl_table)); dev_root = bus_get_dev_root(&cpu_subsys); if (dev_root) { diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c index 5300c6867d5e..918816dcb42a 100644 --- a/arch/s390/mm/cmm.c +++ b/arch/s390/mm/cmm.c @@ -379,7 +379,8 @@ static int __init cmm_init(void) { int rc = -ENOMEM; - cmm_sysctl_header = register_sysctl("vm", cmm_table); + cmm_sysctl_header = register_sysctl("vm", cmm_table, + ARRAY_SIZE(cmm_table)); if (!cmm_sysctl_header) goto out_sysctl; #ifdef CONFIG_CMM_IUCV diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c index 66ab68db9842..a723f1a8236a 100644 --- a/arch/s390/mm/pgalloc.c +++ b/arch/s390/mm/pgalloc.c @@ -35,7 +35,8 @@ static struct ctl_table page_table_sysctl[] = { static int __init page_table_register_sysctl(void) { - return register_sysctl("vm", page_table_sysctl) ? 0 : -ENOMEM; + return register_sysctl("vm", page_table_sysctl, + ARRAY_SIZE(page_table_sysctl)) ? 0 : -ENOMEM; } __initcall(page_table_register_sysctl); diff --git a/arch/x86/entry/vdso/vdso32-setup.c b/arch/x86/entry/vdso/vdso32-setup.c index f3b3cacbcbb0..e28cdba83e0e 100644 --- a/arch/x86/entry/vdso/vdso32-setup.c +++ b/arch/x86/entry/vdso/vdso32-setup.c @@ -72,7 +72,7 @@ static struct ctl_table abi_table2[] = { static __init int ia32_binfmt_init(void) { - register_sysctl("abi", abi_table2); + register_sysctl("abi", abi_table2, ARRAY_SIZE(abi_table2)); return 0; } __initcall(ia32_binfmt_init); diff --git a/arch/x86/kernel/itmt.c b/arch/x86/kernel/itmt.c index 670eb08b972a..58ec95fce798 100644 --- a/arch/x86/kernel/itmt.c +++ b/arch/x86/kernel/itmt.c @@ -105,7 +105,8 @@ int sched_set_itmt_support(void) return 0; } - itmt_sysctl_header = register_sysctl("kernel", itmt_kern_table); + itmt_sysctl_header = register_sysctl("kernel", itmt_kern_table, + ARRAY_SIZE(itmt_kern_table)); if (!itmt_sysctl_header) { mutex_unlock(&itmt_update_mutex); return -ENOMEM; diff --git a/crypto/fips.c b/crypto/fips.c index 92fd506abb21..05a251680700 100644 --- a/crypto/fips.c +++ b/crypto/fips.c @@ -70,7 +70,8 @@ static struct ctl_table_header *crypto_sysctls; static void crypto_proc_fips_init(void) { - crypto_sysctls = register_sysctl("crypto", crypto_sysctl_table); + crypto_sysctls = register_sysctl("crypto", crypto_sysctl_table, + ARRAY_SIZE(crypto_sysctl_table)); } static void crypto_proc_fips_exit(void) diff --git a/drivers/base/firmware_loader/fallback_table.c b/drivers/base/firmware_loader/fallback_table.c index e5ac098d0742..7a2d584233bb 100644 --- a/drivers/base/firmware_loader/fallback_table.c +++ b/drivers/base/firmware_loader/fallback_table.c @@ -50,9 +50,9 @@ static struct ctl_table firmware_config_table[] = { static struct ctl_table_header *firmware_config_sysct_table_header; int register_firmware_config_sysctl(void) { - firmware_config_sysct_table_header = - register_sysctl("kernel/firmware_config", - firmware_config_table); + firmware_config_sysct_table_header = register_sysctl("kernel/firmware_config", + firmware_config_table, + ARRAY_SIZE(firmware_config_table)); if (!firmware_config_sysct_table_header) return -ENOMEM; return 0; diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 416f723a2dbb..3855da76a16d 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -3680,7 +3680,8 @@ static void cdrom_sysctl_register(void) if (!atomic_add_unless(&initialized, 1, 1)) return; - cdrom_sysctl_header = register_sysctl("dev/cdrom", cdrom_table); + cdrom_sysctl_header = register_sysctl("dev/cdrom", cdrom_table, + ARRAY_SIZE(cdrom_table)); /* set the defaults */ cdrom_sysctl_settings.autoclose = autoclose; diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index ee71376f174b..bb1eb801b20c 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -1027,7 +1027,8 @@ static int __init hpet_init(void) if (result < 0) return -ENODEV; - sysctl_header = register_sysctl("dev/hpet", hpet_table); + sysctl_header = register_sysctl("dev/hpet", hpet_table, + ARRAY_SIZE(hpet_table)); result = acpi_bus_register_driver(&hpet_acpi_driver); if (result < 0) { diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c index 870659d91db2..46b1ea866da9 100644 --- a/drivers/char/ipmi/ipmi_poweroff.c +++ b/drivers/char/ipmi/ipmi_poweroff.c @@ -675,7 +675,8 @@ static int __init ipmi_poweroff_init(void) pr_info("Power cycle is enabled\n"); #ifdef CONFIG_PROC_FS - ipmi_table_header = register_sysctl("dev/ipmi", ipmi_table); + ipmi_table_header = register_sysctl("dev/ipmi", ipmi_table, + ARRAY_SIZE(ipmi_table)); if (!ipmi_table_header) { pr_err("Unable to register powercycle sysctl\n"); rv = -ENOMEM; diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 050b8ae7b8e7..f43950219ffc 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -5266,7 +5266,8 @@ static int destroy_config(int id, void *p, void *data) int i915_perf_sysctl_register(void) { - sysctl_header = register_sysctl("dev/i915", oa_table); + sysctl_header = register_sysctl("dev/i915", oa_table, + ARRAY_SIZE(oa_table)); return 0; } diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index 64f9ceca887b..dd751c391cf7 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -302,7 +302,8 @@ int __init hv_common_init(void) * message recording won't be available in isolated * guests should the following registration fail. */ - hv_ctl_table_hdr = register_sysctl("kernel", hv_ctl_table); + hv_ctl_table_hdr = register_sysctl("kernel", hv_ctl_table, + ARRAY_SIZE(hv_ctl_table)); if (!hv_ctl_table_hdr) pr_err("Hyper-V: sysctl table register error"); diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c index d8c4d5664145..5d433ef430fa 100644 --- a/drivers/macintosh/mac_hid.c +++ b/drivers/macintosh/mac_hid.c @@ -243,7 +243,8 @@ static struct ctl_table_header *mac_hid_sysctl_header; static int __init mac_hid_init(void) { - mac_hid_sysctl_header = register_sysctl("dev/mac_hid", mac_hid_files); + mac_hid_sysctl_header = register_sysctl("dev/mac_hid", mac_hid_files, + ARRAY_SIZE(mac_hid_files)); if (!mac_hid_sysctl_header) return -ENOMEM; diff --git a/drivers/md/md.c b/drivers/md/md.c index 8e344b4b3444..c10cc8ddd94d 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -9633,7 +9633,8 @@ static int __init md_init(void) mdp_major = ret; register_reboot_notifier(&md_notifier); - raid_table_header = register_sysctl("dev/raid", raid_table); + raid_table_header = register_sysctl("dev/raid", raid_table, + ARRAY_SIZE(raid_table)); md_geninit(); return 0; diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c index 6da509d692bb..264b919d0610 100644 --- a/drivers/misc/sgi-xp/xpc_main.c +++ b/drivers/misc/sgi-xp/xpc_main.c @@ -1236,8 +1236,10 @@ xpc_init(void) goto out_1; } - xpc_sysctl = register_sysctl("xpc", xpc_sys_xpc); - xpc_sysctl_hb = register_sysctl("xpc/hb", xpc_sys_xpc_hb); + xpc_sysctl = register_sysctl("xpc", xpc_sys_xpc, + ARRAY_SIZE(xpc_sys_xpc)); + xpc_sysctl_hb = register_sysctl("xpc/hb", xpc_sys_xpc_hb, + ARRAY_SIZE(xpc_sys_xpc_hb)); /* * Fill the partition reserved page with the information needed by diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index 4e5b972c3e26..16cee52f035f 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c @@ -464,7 +464,8 @@ int parport_proc_register(struct parport *port) err = -ENOENT; goto exit_free_tmp_dir_path; } - t->devices_header = register_sysctl(tmp_dir_path, t->device_dir); + t->devices_header = register_sysctl(tmp_dir_path, t->device_dir, + ARRAY_SIZE(t->device_dir)); if (t->devices_header == NULL) { err = -ENOENT; goto exit_free_tmp_dir_path; @@ -478,7 +479,8 @@ int parport_proc_register(struct parport *port) goto unregister_devices_h; } - t->port_header = register_sysctl(tmp_dir_path, t->vars); + t->port_header = register_sysctl(tmp_dir_path, t->vars, + ARRAY_SIZE(t->vars)); if (t->port_header == NULL) { err = -ENOENT; goto unregister_devices_h; @@ -544,7 +546,7 @@ int parport_device_proc_register(struct pardevice *device) t->vars[0].data = &device->timeslice; - t->sysctl_header = register_sysctl(tmp_dir_path, t->vars); + t->sysctl_header = register_sysctl(tmp_dir_path, t->vars, ARRAY_SIZE(t->vars)); if (t->sysctl_header == NULL) { kfree(t); t = NULL; @@ -579,7 +581,8 @@ static int __init parport_default_proc_register(void) int ret; parport_default_sysctl_table.sysctl_header = - register_sysctl("dev/parport/default", parport_default_sysctl_table.vars); + register_sysctl("dev/parport/default", parport_default_sysctl_table.vars, + ARRAY_SIZE(parport_default_sysctl_table.vars)); if (!parport_default_sysctl_table.sysctl_header) return -ENOMEM; ret = parport_bus_init(); diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index c98e4039386d..763f9c8acfbf 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -1188,7 +1188,8 @@ static void armv8_pmu_register_sysctl_table(void) static u32 tbl_registered = 0; if (!cmpxchg_relaxed(&tbl_registered, 0, 1)) - register_sysctl("kernel", armv8_pmu_sysctl_table); + register_sysctl("kernel", armv8_pmu_sysctl_table, + ARRAY_SIZE(armv8_pmu_sysctl_table)); } static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, diff --git a/drivers/scsi/scsi_sysctl.c b/drivers/scsi/scsi_sysctl.c index 7f0914ea168f..0378bd63fea4 100644 --- a/drivers/scsi/scsi_sysctl.c +++ b/drivers/scsi/scsi_sysctl.c @@ -25,7 +25,8 @@ static struct ctl_table_header *scsi_table_header; int __init scsi_init_sysctl(void) { - scsi_table_header = register_sysctl("dev/scsi", scsi_table); + scsi_table_header = register_sysctl("dev/scsi", scsi_table, + ARRAY_SIZE(scsi_table)); if (!scsi_table_header) return -ENOMEM; return 0; diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 037f8c98a6d3..d12cdf875b50 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1646,7 +1646,8 @@ static struct ctl_table_header *hdr; static void register_sg_sysctls(void) { if (!hdr) - hdr = register_sysctl("kernel", sg_sysctls); + hdr = register_sysctl("kernel", sg_sysctls, + ARRAY_SIZE(sg_sysctls)); } static void unregister_sg_sysctls(void) diff --git a/fs/cachefiles/error_inject.c b/fs/cachefiles/error_inject.c index 18de8a876b02..ea6bcce4f6f1 100644 --- a/fs/cachefiles/error_inject.c +++ b/fs/cachefiles/error_inject.c @@ -24,7 +24,8 @@ static struct ctl_table cachefiles_sysctls[] = { int __init cachefiles_register_error_injection(void) { - cachefiles_sysctl = register_sysctl("cachefiles", cachefiles_sysctls); + cachefiles_sysctl = register_sysctl("cachefiles", cachefiles_sysctls, + ARRAY_SIZE(cachefiles_sysctls)); if (!cachefiles_sysctl) return -ENOMEM; return 0; diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c index a247c14aaab7..16224a7c6691 100644 --- a/fs/coda/sysctl.c +++ b/fs/coda/sysctl.c @@ -42,7 +42,8 @@ static struct ctl_table coda_table[] = { void coda_sysctl_init(void) { if ( !fs_table_header ) - fs_table_header = register_sysctl("coda", coda_table); + fs_table_header = register_sysctl("coda", coda_table, + ARRAY_SIZE(coda_table)); } void coda_sysctl_clean(void) diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index fe3db0eda8e4..c17f971a8c4b 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c @@ -612,7 +612,8 @@ static int __init init_devpts_fs(void) { int err = register_filesystem(&devpts_fs_type); if (!err) { - register_sysctl("kernel/pty", pty_table); + register_sysctl("kernel/pty", pty_table, + ARRAY_SIZE(pty_table)); } return err; } diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 980483455cc0..e1a0e6a6d3de 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -327,7 +327,7 @@ static struct ctl_table epoll_table[] = { static void __init epoll_sysctls_init(void) { - register_sysctl("fs/epoll", epoll_table); + register_sysctl("fs/epoll", epoll_table, ARRAY_SIZE(epoll_table)); } #else #define epoll_sysctls_init() do { } while (0) diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index bb94949bc223..84736267f4e1 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -626,7 +626,8 @@ static int __init init_nlm(void) #ifdef CONFIG_SYSCTL err = -ENOMEM; - nlm_sysctl_table = register_sysctl("fs/nfs", nlm_sysctls); + nlm_sysctl_table = register_sysctl("fs/nfs", nlm_sysctls, + ARRAY_SIZE(nlm_sysctls)); if (nlm_sysctl_table == NULL) goto err_sysctl; #endif diff --git a/fs/nfs/nfs4sysctl.c b/fs/nfs/nfs4sysctl.c index e776200e9a11..4a542ee11e68 100644 --- a/fs/nfs/nfs4sysctl.c +++ b/fs/nfs/nfs4sysctl.c @@ -40,7 +40,8 @@ static struct ctl_table nfs4_cb_sysctls[] = { int nfs4_register_sysctl(void) { nfs4_callback_sysctl_table = register_sysctl("fs/nfs", - nfs4_cb_sysctls); + nfs4_cb_sysctls, + ARRAY_SIZE(nfs4_cb_sysctls)); if (nfs4_callback_sysctl_table == NULL) return -ENOMEM; return 0; diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c index f39e2089bc4c..9dafd44670e4 100644 --- a/fs/nfs/sysctl.c +++ b/fs/nfs/sysctl.c @@ -34,7 +34,8 @@ static struct ctl_table nfs_cb_sysctls[] = { int nfs_register_sysctl(void) { - nfs_callback_sysctl_table = register_sysctl("fs/nfs", nfs_cb_sysctls); + nfs_callback_sysctl_table = register_sysctl("fs/nfs", nfs_cb_sysctls, + ARRAY_SIZE(nfs_cb_sysctls)); if (nfs_callback_sysctl_table == NULL) return -ENOMEM; return 0; diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 22fb1cf7e1fc..78d3bf479f59 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -91,7 +91,8 @@ static struct ctl_table fanotify_table[] = { static void __init fanotify_sysctls_init(void) { - register_sysctl("fs/fanotify", fanotify_table); + register_sysctl("fs/fanotify", fanotify_table, + ARRAY_SIZE(fanotify_table)); } #else #define fanotify_sysctls_init() do { } while (0) diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 1c4bfdab008d..0ce25c4ddfec 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -90,7 +90,8 @@ static struct ctl_table inotify_table[] = { static void __init inotify_sysctls_init(void) { - register_sysctl("fs/inotify", inotify_table); + register_sysctl("fs/inotify", inotify_table, + ARRAY_SIZE(inotify_table)); } #else diff --git a/fs/ntfs/sysctl.c b/fs/ntfs/sysctl.c index 174fe536a1c0..2c48f48a0b80 100644 --- a/fs/ntfs/sysctl.c +++ b/fs/ntfs/sysctl.c @@ -44,7 +44,8 @@ int ntfs_sysctl(int add) { if (add) { BUG_ON(sysctls_root_table); - sysctls_root_table = register_sysctl("fs", ntfs_sysctls); + sysctls_root_table = register_sysctl("fs", ntfs_sysctls, + ARRAY_SIZE(ntfs_sysctls)); if (!sysctls_root_table) return -ENOMEM; } else { diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index a8d5ca98fa57..9a653875d1c5 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c @@ -673,7 +673,8 @@ static int __init ocfs2_stack_glue_init(void) strcpy(cluster_stack_name, OCFS2_STACK_PLUGIN_O2CB); - ocfs2_table_header = register_sysctl("fs/ocfs2/nm", ocfs2_nm_table); + ocfs2_table_header = register_sysctl("fs/ocfs2/nm", ocfs2_nm_table, + ARRAY_SIZE(ocfs2_nm_table)); if (!ocfs2_table_header) { printk(KERN_ERR "ocfs2 stack glue: unable to register sysctl\n"); diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 8c415048d540..66c9d7a07d2e 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -43,7 +43,7 @@ struct ctl_table sysctl_mount_point[] = { */ struct ctl_table_header *register_sysctl_mount_point(const char *path) { - return register_sysctl(path, sysctl_mount_point); + return register_sysctl(path, sysctl_mount_point, 0); } EXPORT_SYMBOL(register_sysctl_mount_point); @@ -1414,17 +1414,11 @@ struct ctl_table_header *__register_sysctl_table( * * See __register_sysctl_table for more details. */ -struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table) +struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table, + size_t table_size) { - int count = 0; - struct ctl_table *entry; - struct ctl_table_header t_hdr; - - t_hdr.ctl_table = table; - list_for_each_table_entry(entry, (&t_hdr)) - count++; return __register_sysctl_table(&sysctl_table_root.default_set, - path, table, count); + path, table, table_size); } EXPORT_SYMBOL(register_sysctl); @@ -1451,7 +1445,14 @@ EXPORT_SYMBOL(register_sysctl); void __init __register_sysctl_init(const char *path, struct ctl_table *table, const char *table_name) { - struct ctl_table_header *hdr = register_sysctl(path, table); + int count = 0; + struct ctl_table *entry; + struct ctl_table_header t_hdr, *hdr; + + t_hdr.ctl_table = table; + list_for_each_table_entry(entry, (&t_hdr)) + count++; + hdr = register_sysctl(path, table, count); if (unlikely(!hdr)) { pr_err("failed when register_sysctl %s to %s\n", table_name, path); diff --git a/fs/verity/signature.c b/fs/verity/signature.c index b8c51ad40d3a..f617c6a1f16c 100644 --- a/fs/verity/signature.c +++ b/fs/verity/signature.c @@ -103,7 +103,9 @@ static struct ctl_table fsverity_sysctl_table[] = { static int __init fsverity_sysctl_init(void) { - fsverity_sysctl_header = register_sysctl("fs/verity", fsverity_sysctl_table); + fsverity_sysctl_header = register_sysctl("fs/verity", + fsverity_sysctl_table, + ARRAY_SIZE(fsverity_sysctl_table)); if (!fsverity_sysctl_header) { pr_err("sysctl registration failed!\n"); return -ENOMEM; diff --git a/fs/xfs/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c index fade33735393..61075e9c9e37 100644 --- a/fs/xfs/xfs_sysctl.c +++ b/fs/xfs/xfs_sysctl.c @@ -213,7 +213,8 @@ static struct ctl_table xfs_table[] = { int xfs_sysctl_register(void) { - xfs_table_header = register_sysctl("fs/xfs", xfs_table); + xfs_table_header = register_sysctl("fs/xfs", xfs_table, + ARRAY_SIZE(xfs_table)); if (!xfs_table_header) return -ENOMEM; return 0; diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 0495c858989f..71d7935e50f0 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -227,7 +227,8 @@ extern void retire_sysctl_set(struct ctl_table_set *set); struct ctl_table_header *__register_sysctl_table( struct ctl_table_set *set, const char *path, struct ctl_table *table, size_t table_size); -struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table); +struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table, + size_t table_size); void unregister_sysctl_table(struct ctl_table_header * table); extern int sysctl_init_bases(void); @@ -262,7 +263,8 @@ static inline struct ctl_table_header *register_sysctl_mount_point(const char *p return NULL; } -static inline struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table) +static inline struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table, + size_t table_size) { return NULL; } diff --git a/kernel/pid_sysctl.h b/kernel/pid_sysctl.h index d67a4d45bb42..8b24744752cb 100644 --- a/kernel/pid_sysctl.h +++ b/kernel/pid_sysctl.h @@ -48,7 +48,7 @@ static struct ctl_table pid_ns_ctl_table_vm[] = { }; static inline void register_pid_ns_sysctl_table_vm(void) { - register_sysctl("vm", pid_ns_ctl_table_vm); + register_sysctl("vm", pid_ns_ctl_table_vm, ARRAY_SIZE(pid_ns_ctl_table_vm)); } #else static inline void initialize_memfd_noexec_scope(struct pid_namespace *ns) {} diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 63a8ce7177dd..de385b365a7a 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -265,7 +265,7 @@ static struct ctl_table timer_sysctl[] = { static int __init timer_sysctl_init(void) { - register_sysctl("kernel", timer_sysctl); + register_sysctl("kernel", timer_sysctl, ARRAY_SIZE(timer_sysctl)); return 0; } device_initcall(timer_sysctl_init); diff --git a/kernel/ucount.c b/kernel/ucount.c index 2b80264bb79f..59bf6983f1cf 100644 --- a/kernel/ucount.c +++ b/kernel/ucount.c @@ -365,7 +365,7 @@ static __init int user_namespace_sysctl_init(void) * default set so that registrations in the child sets work * properly. */ - user_header = register_sysctl("user", empty); + user_header = register_sysctl("user", empty, 0); kmemleak_ignore(user_header); BUG_ON(!user_header); BUG_ON(!setup_userns_sysctls(&init_user_ns)); diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c index 019e3a1566cf..24527b155538 100644 --- a/kernel/utsname_sysctl.c +++ b/kernel/utsname_sysctl.c @@ -138,7 +138,7 @@ void uts_proc_notify(enum uts_proc proc) static int __init utsname_sysctl_init(void) { - register_sysctl("kernel", uts_kern_table); + register_sysctl("kernel", uts_kern_table, ARRAY_SIZE(uts_kern_table)); return 0; } diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c index 8036aa91a1cb..83d37a163836 100644 --- a/lib/test_sysctl.c +++ b/lib/test_sysctl.c @@ -166,7 +166,8 @@ static int test_sysctl_setup_node_tests(void) test_data.bitmap_0001 = kzalloc(SYSCTL_TEST_BITMAP_SIZE/8, GFP_KERNEL); if (!test_data.bitmap_0001) return -ENOMEM; - sysctl_test_headers.test_h_setup_node = register_sysctl("debug/test_sysctl", test_table); + sysctl_test_headers.test_h_setup_node = register_sysctl("debug/test_sysctl", test_table, + ARRAY_SIZE(test_table)); if (!sysctl_test_headers.test_h_setup_node) { kfree(test_data.bitmap_0001); return -ENOMEM; @@ -192,7 +193,8 @@ static int test_sysctl_run_unregister_nested(void) struct ctl_table_header *unregister; unregister = register_sysctl("debug/test_sysctl/unregister_error", - test_table_unregister); + test_table_unregister, + ARRAY_SIZE(test_table_unregister)); if (!unregister) return -ENOMEM; @@ -209,7 +211,8 @@ static int test_sysctl_run_register_mount_point(void) sysctl_test_headers.test_h_mnterror = register_sysctl("debug/test_sysctl/mnt/mnt_error", - test_table_unregister); + test_table_unregister, + ARRAY_SIZE(test_table_unregister)); /* * Don't check the result.: * If it fails (expected behavior), return 0. diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c index 93941ab12549..61222addda7e 100644 --- a/net/sunrpc/sysctl.c +++ b/net/sunrpc/sysctl.c @@ -167,7 +167,8 @@ void rpc_register_sysctl(void) { if (!sunrpc_table_header) - sunrpc_table_header = register_sysctl("sunrpc", debug_table); + sunrpc_table_header = register_sysctl("sunrpc", debug_table, + ARRAY_SIZE(debug_table)); } void diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c index f0d5eeed4c88..df7fb9c8b785 100644 --- a/net/sunrpc/xprtrdma/svc_rdma.c +++ b/net/sunrpc/xprtrdma/svc_rdma.c @@ -246,7 +246,8 @@ static int svc_rdma_proc_init(void) goto out_err; svcrdma_table_header = register_sysctl("sunrpc/svc_rdma", - svcrdma_parm_table); + svcrdma_parm_table, + ARRAY_SIZE(svcrdma_parm_table)); return 0; out_err: diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c index 29b0562d62e7..bf43e05044a3 100644 --- a/net/sunrpc/xprtrdma/transport.c +++ b/net/sunrpc/xprtrdma/transport.c @@ -790,7 +790,9 @@ int xprt_rdma_init(void) #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) if (!sunrpc_table_header) - sunrpc_table_header = register_sysctl("sunrpc", xr_tunables_table); + sunrpc_table_header = register_sysctl("sunrpc", + xr_tunables_table, + ARRAY_SIZE(xr_tunables_table)); #endif return 0; } diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 5f9030b81c9e..7c3d5ed708be 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -3169,7 +3169,9 @@ static struct xprt_class xs_bc_tcp_transport = { int init_socket_xprt(void) { if (!sunrpc_table_header) - sunrpc_table_header = register_sysctl("sunrpc", xs_tunables_table); + sunrpc_table_header = register_sysctl("sunrpc", + xs_tunables_table, + ARRAY_SIZE(xs_tunables_table)); xprt_register_transport(&xs_local_transport); xprt_register_transport(&xs_udp_transport); diff --git a/net/sysctl_net.c b/net/sysctl_net.c index 1757c18ea065..f96e6633fdd3 100644 --- a/net/sysctl_net.c +++ b/net/sysctl_net.c @@ -101,7 +101,7 @@ __init int net_sysctl_init(void) * registering "/proc/sys/net" as an empty directory not in a * network namespace. */ - net_header = register_sysctl("net", empty); + net_header = register_sysctl("net", empty, 0); if (!net_header) goto out; ret = register_pernet_subsys(&sysctl_pernet_ops); diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index f431251ffb91..b77344506cf3 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -1785,7 +1785,8 @@ static struct ctl_table apparmor_sysctl_table[] = { static int __init apparmor_init_sysctl(void) { - return register_sysctl("kernel", apparmor_sysctl_table) ? 0 : -ENOMEM; + return register_sysctl("kernel", apparmor_sysctl_table, + ARRAY_SIZE(apparmor_sysctl_table)) ? 0 : -ENOMEM; } #else static inline int apparmor_init_sysctl(void) diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c index ebae964f7cc9..6f2cc827df41 100644 --- a/security/loadpin/loadpin.c +++ b/security/loadpin/loadpin.c @@ -256,7 +256,8 @@ static int __init loadpin_init(void) enforce ? "" : "not "); parse_exclude(); #ifdef CONFIG_SYSCTL - if (!register_sysctl("kernel/loadpin", loadpin_sysctl_table)) + if (!register_sysctl("kernel/loadpin", loadpin_sysctl_table, + ARRAY_SIZE(loadpin_sysctl_table))) pr_notice("sysctl registration failed!\n"); #endif security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin"); diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c index 2503cf153d4a..7b8164a4b504 100644 --- a/security/yama/yama_lsm.c +++ b/security/yama/yama_lsm.c @@ -461,7 +461,8 @@ static struct ctl_table yama_sysctl_table[] = { }; static void __init yama_init_sysctl(void) { - if (!register_sysctl("kernel/yama", yama_sysctl_table)) + if (!register_sysctl("kernel/yama", yama_sysctl_table, + ARRAY_SIZE(yama_sysctl_table))) panic("Yama: sysctl registration failed.\n"); } #else From patchwork Wed Jun 21 09:09:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13286921 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B53AEB64D7 for ; Wed, 21 Jun 2023 09:12:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbjFUJMW (ORCPT ); Wed, 21 Jun 2023 05:12:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbjFUJL2 (ORCPT ); Wed, 21 Jun 2023 05:11:28 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20D61211D; Wed, 21 Jun 2023 02:10:40 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230621091038euoutp01e123bf7eae2cf2239ff74cab5dc393bb~qoY0vfCZa1411914119euoutp01Y; Wed, 21 Jun 2023 09:10:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230621091038euoutp01e123bf7eae2cf2239ff74cab5dc393bb~qoY0vfCZa1411914119euoutp01Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687338638; bh=QatUAmwjfSE5CpygwEgoo8d+plIGyvB6WfjKfmq8pF4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=WBbh3ysmBwasQEKtTmaoGsleQTqlgmC4R8U/+mJGvSWtNFexng/wooaURelQr0+Ix 8bW/6HMQT73Ttuk4jBTTZ0Ql7yFJyGuRmdDguixw0HvwHLYcsOK8JUwaCs1YNo80PM 2YVN8Dq1QLsiAczxi+aWjbg8pywEOsXt/1a01AMI= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230621091037eucas1p17e649ac102168b47064feeb1a5d9d0d7~qoY0XqSpU2864928649eucas1p1t; Wed, 21 Jun 2023 09:10:37 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id B0.AE.11320.D8EB2946; Wed, 21 Jun 2023 10:10:37 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230621091037eucas1p188e11d8064526a5a0549217d5a419647~qoYzsEdLT3017130171eucas1p10; Wed, 21 Jun 2023 09:10:37 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230621091036eusmtrp23053e0e91e9e88b462059cc6e116b0c7~qoYzpFHdu2207922079eusmtrp2g; Wed, 21 Jun 2023 09:10:36 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-fb-6492be8d52ed Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 7D.1F.10549.C8EB2946; Wed, 21 Jun 2023 10:10:36 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230621091036eusmtip1064192b2f7098b941992ae887d268647~qoYzRi0Su1210112101eusmtip1N; Wed, 21 Jun 2023 09:10:36 +0000 (GMT) Received: from localhost (106.210.248.248) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jun 2023 10:10:35 +0100 From: Joel Granados To: , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , Theodore Ts'o , "Jason A. Donenfeld" , Greg Kroah-Hartman , Jiri Slaby , Juergen Gross , Stefano Stabellini , Benjamin LaHaise , Alexander Viro , Christian Brauner , Jeff Layton , Chuck Lever , Jan Kara , Kees Cook , Iurii Zaikin , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Balbir Singh , Eric Biederman , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Masami Hiramatsu , Peter Zijlstra , Will Deacon , Petr Mladek , Sergey Senozhatsky , Juri Lelli , Vincent Guittot , Steven Rostedt , Andrew Morton , Mike Kravetz , Muchun Song , Naoya Horiguchi , "Matthew Wilcox (Oracle)" , David Howells , Jarkko Sakkinen , Paul Moore , James Morris , "Serge E. Hallyn" CC: Joel Granados , "H. Peter Anvin" , Oleksandr Tyshchenko , Amir Goldstein , John Fastabend , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Waiman Long , Boqun Feng , John Ogness , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Andy Lutomirski , Will Drewry , Mark Rutland , Miaohe Lin , , , , , , , , , , Subject: [PATCH 08/11] sysctl: Add size to register_sysctl_init Date: Wed, 21 Jun 2023 11:09:57 +0200 Message-ID: <20230621091000.424843-9-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621091000.424843-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.248] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA01Ta0xTZxj2O+frOYUNUxDDF2Vh6TbH2NBpXPKqKC7Z5nFxUed0N5PJ5YQa BLQFNs3MoKDIVahIt4KjQigIKIiFwLgVZFYshtHJqHIHGSCIcrcDYcBhC/+e932e53uf58cn ph162HXi44HBvDzQ64SUscUld6yN7vFVKt/3TTEukFaQz8AfN/IQTM+k0lA+0IphwtrKQsyc HkO+PpyC8cI5BsbrjAwM3R5DYO5tZkA9GI4hbbCBhfn2fgoyr07RMFAYhSCtMRLDiHIGQ19i MQ3zJZEsRGQWMFBrrGYh5aYTpKojKFBZExF0Na+DtIdbYOSKM1h1uSzcKMikQFmaQ0HJg3QE dckaGtovXsbQEBsA5aZJCorblAz0V8VTED2dhSE5RYmgorIew5+/pTHQkT8vgudxPQzUFdzH YLpzF0P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G7EcQXCS+LAnz44hpke3DmXVz/PXfhwU8J/C9z7SxtuTZ2 9pa29nbWxqe0XfwieDpsT54//xc+348v+t+HsTT0QzDijXdB86ur31qcXq7tq68/Z63VF9j7 VaukxzTeuslGuzbRRXrV69Z3oQXRk2560pCd/I79d8vmWTzJnZhKVVqbWXCv8wm/HHP9xPWc augbYwRn1T13ZK1VXbym6ftzH+/XuP63zela79iUCtyvTCC9v67Eht/UdVgsOSsvxYtce0iz DknQ0meuN9rSFRYmjzn3LgwYyBSB7l/EOz9UqJSyrY3z80aBzReVI+wPNLRM19JWBKEOZqYj kq3x71FRRWklVzqMOS1/3V3ODpb1LrQFXRfYCPnFC4aXzmeuMNJOW+vNN4Zvtntnj4+ZtLg5 h5l/6SIcrBqs639gq0p5n3uu0ZgQe/G4ZrhIzPsXGRMQfZsEAAA= X-CMS-MailID: 20230621091037eucas1p188e11d8064526a5a0549217d5a419647 X-Msg-Generator: CA X-RootMTR: 20230621091037eucas1p188e11d8064526a5a0549217d5a419647 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230621091037eucas1p188e11d8064526a5a0549217d5a419647 References: <20230621091000.424843-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In order to remove the end element from the ctl_table struct arrays, we explicitly define the size when registering the targes. We add a size argument to the register_sysctl_init call and pass an ARRAY_SIZE for all the callers. Signed-off-by: Joel Granados --- arch/x86/kernel/cpu/intel.c | 2 +- drivers/char/random.c | 3 ++- drivers/tty/tty_io.c | 2 +- drivers/xen/balloon.c | 3 ++- fs/aio.c | 2 +- fs/coredump.c | 3 ++- fs/dcache.c | 3 ++- fs/exec.c | 3 ++- fs/file_table.c | 3 ++- fs/inode.c | 2 +- fs/locks.c | 2 +- fs/namei.c | 2 +- fs/namespace.c | 3 ++- fs/notify/dnotify/dnotify.c | 3 ++- fs/pipe.c | 3 ++- fs/proc/proc_sysctl.c | 11 ++--------- fs/quota/dquot.c | 3 ++- fs/sysctls.c | 3 ++- fs/userfaultfd.c | 3 ++- include/linux/sysctl.h | 8 +++++--- init/do_mounts_initrd.c | 3 ++- kernel/acct.c | 3 ++- kernel/bpf/syscall.c | 3 ++- kernel/delayacct.c | 3 ++- kernel/exit.c | 3 ++- kernel/hung_task.c | 3 ++- kernel/kexec_core.c | 3 ++- kernel/kprobes.c | 3 ++- kernel/latencytop.c | 3 ++- kernel/locking/lockdep.c | 3 ++- kernel/panic.c | 3 ++- kernel/pid_namespace.c | 3 ++- kernel/printk/sysctl.c | 3 ++- kernel/reboot.c | 3 ++- kernel/sched/autogroup.c | 3 ++- kernel/sched/core.c | 3 ++- kernel/sched/deadline.c | 3 ++- kernel/sched/fair.c | 3 ++- kernel/sched/rt.c | 3 ++- kernel/sched/topology.c | 3 ++- kernel/seccomp.c | 3 ++- kernel/signal.c | 3 ++- kernel/stackleak.c | 3 ++- kernel/sysctl.c | 4 ++-- kernel/trace/ftrace.c | 3 ++- kernel/trace/trace_events_user.c | 3 ++- kernel/umh.c | 3 ++- kernel/watchdog.c | 3 ++- mm/compaction.c | 2 +- mm/hugetlb.c | 2 +- mm/hugetlb_vmemmap.c | 3 ++- mm/memory-failure.c | 3 ++- mm/oom_kill.c | 3 ++- mm/page-writeback.c | 3 ++- security/keys/sysctl.c | 2 +- 55 files changed, 104 insertions(+), 66 deletions(-) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 1c4639588ff9..c77a3961443d 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -1195,7 +1195,7 @@ static struct ctl_table sld_sysctls[] = { static int __init sld_mitigate_sysctl_init(void) { - register_sysctl_init("kernel", sld_sysctls); + register_sysctl_init("kernel", sld_sysctls, ARRAY_SIZE(sld_sysctls)); return 0; } diff --git a/drivers/char/random.c b/drivers/char/random.c index 253f2ddb8913..8db2ea9e3d66 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1692,7 +1692,8 @@ static struct ctl_table random_table[] = { */ static int __init random_sysctls_init(void) { - register_sysctl_init("kernel/random", random_table); + register_sysctl_init("kernel/random", random_table, + ARRAY_SIZE(random_table)); return 0; } device_initcall(random_sysctls_init); diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index c84be40fb8df..63fb3c543b94 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3618,7 +3618,7 @@ static struct ctl_table tty_table[] = { */ int __init tty_init(void) { - register_sysctl_init("dev/tty", tty_table); + register_sysctl_init("dev/tty", tty_table, ARRAY_SIZE(tty_table)); cdev_init(&tty_cdev, &tty_fops); if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 586a1673459e..e4544262a429 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -729,7 +729,8 @@ static int __init balloon_init(void) #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG set_online_page_callback(&xen_online_page); register_memory_notifier(&xen_memory_nb); - register_sysctl_init("xen/balloon", balloon_table); + register_sysctl_init("xen/balloon", balloon_table, + ARRAY_SIZE(balloon_table)); #endif balloon_add_regions(); diff --git a/fs/aio.c b/fs/aio.c index b0b17bd098bb..b09abe7a14d3 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -244,7 +244,7 @@ static struct ctl_table aio_sysctls[] = { static void __init aio_sysctl_init(void) { - register_sysctl_init("fs", aio_sysctls); + register_sysctl_init("fs", aio_sysctls, ARRAY_SIZE(aio_sysctls)); } #else #define aio_sysctl_init() do { } while (0) diff --git a/fs/coredump.c b/fs/coredump.c index ece7badf701b..7e55428dce13 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -984,7 +984,8 @@ static struct ctl_table coredump_sysctls[] = { static int __init init_fs_coredump_sysctls(void) { - register_sysctl_init("kernel", coredump_sysctls); + register_sysctl_init("kernel", coredump_sysctls, + ARRAY_SIZE(coredump_sysctls)); return 0; } fs_initcall(init_fs_coredump_sysctls); diff --git a/fs/dcache.c b/fs/dcache.c index 52e6d5fdab6b..f02bfd383e66 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -196,7 +196,8 @@ static struct ctl_table fs_dcache_sysctls[] = { static int __init init_fs_dcache_sysctls(void) { - register_sysctl_init("fs", fs_dcache_sysctls); + register_sysctl_init("fs", fs_dcache_sysctls, + ARRAY_SIZE(fs_dcache_sysctls)); return 0; } fs_initcall(init_fs_dcache_sysctls); diff --git a/fs/exec.c b/fs/exec.c index a466e797c8e2..5572d148738b 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -2170,7 +2170,8 @@ static struct ctl_table fs_exec_sysctls[] = { static int __init init_fs_exec_sysctls(void) { - register_sysctl_init("fs", fs_exec_sysctls); + register_sysctl_init("fs", fs_exec_sysctls, + ARRAY_SIZE(fs_exec_sysctls)); return 0; } diff --git a/fs/file_table.c b/fs/file_table.c index 372653b92617..23a645521960 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -120,7 +120,8 @@ static struct ctl_table fs_stat_sysctls[] = { static int __init init_fs_stat_sysctls(void) { - register_sysctl_init("fs", fs_stat_sysctls); + register_sysctl_init("fs", fs_stat_sysctls, + ARRAY_SIZE(fs_stat_sysctls)); if (IS_ENABLED(CONFIG_BINFMT_MISC)) { struct ctl_table_header *hdr; hdr = register_sysctl_mount_point("fs/binfmt_misc"); diff --git a/fs/inode.c b/fs/inode.c index 577799b7855f..0a0ad1a2a5d2 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -135,7 +135,7 @@ static struct ctl_table inodes_sysctls[] = { static int __init init_fs_inode_sysctls(void) { - register_sysctl_init("fs", inodes_sysctls); + register_sysctl_init("fs", inodes_sysctls, ARRAY_SIZE(inodes_sysctls)); return 0; } early_initcall(init_fs_inode_sysctls); diff --git a/fs/locks.c b/fs/locks.c index df8b26a42524..ce5733480aa6 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -116,7 +116,7 @@ static struct ctl_table locks_sysctls[] = { static int __init init_fs_locks_sysctls(void) { - register_sysctl_init("fs", locks_sysctls); + register_sysctl_init("fs", locks_sysctls, ARRAY_SIZE(locks_sysctls)); return 0; } early_initcall(init_fs_locks_sysctls); diff --git a/fs/namei.c b/fs/namei.c index e4fe0879ae55..9b567af081af 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1073,7 +1073,7 @@ static struct ctl_table namei_sysctls[] = { static int __init init_fs_namei_sysctls(void) { - register_sysctl_init("fs", namei_sysctls); + register_sysctl_init("fs", namei_sysctls, ARRAY_SIZE(namei_sysctls)); return 0; } fs_initcall(init_fs_namei_sysctls); diff --git a/fs/namespace.c b/fs/namespace.c index 54847db5b819..e7f251e40485 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4715,7 +4715,8 @@ static struct ctl_table fs_namespace_sysctls[] = { static int __init init_fs_namespace_sysctls(void) { - register_sysctl_init("fs", fs_namespace_sysctls); + register_sysctl_init("fs", fs_namespace_sysctls, + ARRAY_SIZE(fs_namespace_sysctls)); return 0; } fs_initcall(init_fs_namespace_sysctls); diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c index 190aa717fa32..2c6fe98d6fe1 100644 --- a/fs/notify/dnotify/dnotify.c +++ b/fs/notify/dnotify/dnotify.c @@ -33,7 +33,8 @@ static struct ctl_table dnotify_sysctls[] = { }; static void __init dnotify_sysctl_init(void) { - register_sysctl_init("fs", dnotify_sysctls); + register_sysctl_init("fs", dnotify_sysctls, + ARRAY_SIZE(dnotify_sysctls)); } #else #define dnotify_sysctl_init() do { } while (0) diff --git a/fs/pipe.c b/fs/pipe.c index 2d88f73f585a..8a808fc25552 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -1508,7 +1508,8 @@ static int __init init_pipe_fs(void) } } #ifdef CONFIG_SYSCTL - register_sysctl_init("fs", fs_pipe_sysctls); + register_sysctl_init("fs", fs_pipe_sysctls, + ARRAY_SIZE(fs_pipe_sysctls)); #endif return err; } diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 66c9d7a07d2e..9670c5b7b5b2 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1443,16 +1443,9 @@ EXPORT_SYMBOL(register_sysctl); * Context: if your base directory does not exist it will be created for you. */ void __init __register_sysctl_init(const char *path, struct ctl_table *table, - const char *table_name) + const char *table_name, size_t table_size) { - int count = 0; - struct ctl_table *entry; - struct ctl_table_header t_hdr, *hdr; - - t_hdr.ctl_table = table; - list_for_each_table_entry(entry, (&t_hdr)) - count++; - hdr = register_sysctl(path, table, count); + struct ctl_table_header *hdr = register_sysctl(path, table, table_size); if (unlikely(!hdr)) { pr_err("failed when register_sysctl %s to %s\n", table_name, path); diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index ffd40dc3e4e9..7c07654e4253 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -2953,7 +2953,8 @@ static int __init dquot_init(void) printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__); - register_sysctl_init("fs/quota", fs_dqstats_table); + register_sysctl_init("fs/quota", fs_dqstats_table, + ARRAY_SIZE(fs_dqstats_table)); dquot_cachep = kmem_cache_create("dquot", sizeof(struct dquot), sizeof(unsigned long) * 4, diff --git a/fs/sysctls.c b/fs/sysctls.c index 76a0aee8c229..944254dd92c0 100644 --- a/fs/sysctls.c +++ b/fs/sysctls.c @@ -31,7 +31,8 @@ static struct ctl_table fs_shared_sysctls[] = { static int __init init_fs_sysctls(void) { - register_sysctl_init("fs", fs_shared_sysctls); + register_sysctl_init("fs", fs_shared_sysctls, + ARRAY_SIZE(fs_shared_sysctls)); return 0; } diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 0fd96d6e39ce..4c3858769226 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -2219,7 +2219,8 @@ static int __init userfaultfd_init(void) SLAB_HWCACHE_ALIGN|SLAB_PANIC, init_once_userfaultfd_ctx); #ifdef CONFIG_SYSCTL - register_sysctl_init("vm", vm_userfaultfd_table); + register_sysctl_init("vm", vm_userfaultfd_table, + ARRAY_SIZE(vm_userfaultfd_table)); #endif return 0; } diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 71d7935e50f0..3074a506592d 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -233,8 +233,9 @@ void unregister_sysctl_table(struct ctl_table_header * table); extern int sysctl_init_bases(void); extern void __register_sysctl_init(const char *path, struct ctl_table *table, - const char *table_name); -#define register_sysctl_init(path, table) __register_sysctl_init(path, table, #table) + const char *table_name, size_t table_size); +#define register_sysctl_init(path, table, size) \ + __register_sysctl_init(path, table, #table, size) extern struct ctl_table_header *register_sysctl_mount_point(const char *path); void do_sysctl_args(void); @@ -254,7 +255,8 @@ extern int no_unaligned_warning; #else /* CONFIG_SYSCTL */ -static inline void register_sysctl_init(const char *path, struct ctl_table *table) +static inline void register_sysctl_init(const char *path, struct ctl_table *table, + size_t table_size) { } diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index 34731241377d..2b10abb8c80e 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -34,7 +34,8 @@ static struct ctl_table kern_do_mounts_initrd_table[] = { static __init int kernel_do_mounts_initrd_sysctls_init(void) { - register_sysctl_init("kernel", kern_do_mounts_initrd_table); + register_sysctl_init("kernel", kern_do_mounts_initrd_table, + ARRAY_SIZE(kern_do_mounts_initrd_table)); return 0; } late_initcall(kernel_do_mounts_initrd_sysctls_init); diff --git a/kernel/acct.c b/kernel/acct.c index 010667ce6080..67125b7c5ca2 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -89,7 +89,8 @@ static struct ctl_table kern_acct_table[] = { static __init int kernel_acct_sysctls_init(void) { - register_sysctl_init("kernel", kern_acct_table); + register_sysctl_init("kernel", kern_acct_table, + ARRAY_SIZE(kern_acct_table)); return 0; } late_initcall(kernel_acct_sysctls_init); diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 14f39c1e573e..a81b5122b16b 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -5406,7 +5406,8 @@ static struct ctl_table bpf_syscall_table[] = { static int __init bpf_syscall_sysctl_init(void) { - register_sysctl_init("kernel", bpf_syscall_table); + register_sysctl_init("kernel", bpf_syscall_table, + ARRAY_SIZE(bpf_syscall_table)); return 0; } late_initcall(bpf_syscall_sysctl_init); diff --git a/kernel/delayacct.c b/kernel/delayacct.c index 6f0c358e73d8..4ef14cb5b5a0 100644 --- a/kernel/delayacct.c +++ b/kernel/delayacct.c @@ -79,7 +79,8 @@ static struct ctl_table kern_delayacct_table[] = { static __init int kernel_delayacct_sysctls_init(void) { - register_sysctl_init("kernel", kern_delayacct_table); + register_sysctl_init("kernel", kern_delayacct_table, + ARRAY_SIZE(kern_delayacct_table)); return 0; } late_initcall(kernel_delayacct_sysctls_init); diff --git a/kernel/exit.c b/kernel/exit.c index 34b90e2e7cf7..633c7a52ef80 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -95,7 +95,8 @@ static struct ctl_table kern_exit_table[] = { static __init int kernel_exit_sysctls_init(void) { - register_sysctl_init("kernel", kern_exit_table); + register_sysctl_init("kernel", kern_exit_table, + ARRAY_SIZE(kern_exit_table)); return 0; } late_initcall(kernel_exit_sysctls_init); diff --git a/kernel/hung_task.c b/kernel/hung_task.c index 9a24574988d2..816f133266c4 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -318,7 +318,8 @@ static struct ctl_table hung_task_sysctls[] = { static void __init hung_task_sysctl_init(void) { - register_sysctl_init("kernel", hung_task_sysctls); + register_sysctl_init("kernel", hung_task_sysctls, + ARRAY_SIZE(hung_task_sysctls)); } #else #define hung_task_sysctl_init() do { } while (0) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 3d578c6fefee..63b04e710890 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -1007,7 +1007,8 @@ static struct ctl_table kexec_core_sysctls[] = { static int __init kexec_core_sysctl_init(void) { - register_sysctl_init("kernel", kexec_core_sysctls); + register_sysctl_init("kernel", kexec_core_sysctls, + ARRAY_SIZE(kexec_core_sysctls)); return 0; } late_initcall(kexec_core_sysctl_init); diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 00e177de91cc..06a3ac7993f0 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -973,7 +973,8 @@ static struct ctl_table kprobe_sysctls[] = { static void __init kprobe_sysctls_init(void) { - register_sysctl_init("debug", kprobe_sysctls); + register_sysctl_init("debug", kprobe_sysctls, + ARRAY_SIZE(kprobe_sysctls)); } #endif /* CONFIG_SYSCTL */ diff --git a/kernel/latencytop.c b/kernel/latencytop.c index 781249098cb6..55050ae0e197 100644 --- a/kernel/latencytop.c +++ b/kernel/latencytop.c @@ -293,7 +293,8 @@ static int __init init_lstats_procfs(void) { proc_create("latency_stats", 0644, NULL, &lstats_proc_ops); #ifdef CONFIG_SYSCTL - register_sysctl_init("kernel", latencytop_sysctl); + register_sysctl_init("kernel", latencytop_sysctl, + ARRAY_SIZE(latencytop_sysctl)); #endif return 0; } diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index dcd1d5bfc1e0..1e29cec7e00c 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -102,7 +102,8 @@ static struct ctl_table kern_lockdep_table[] = { static __init int kernel_lockdep_sysctls_init(void) { - register_sysctl_init("kernel", kern_lockdep_table); + register_sysctl_init("kernel", kern_lockdep_table, + ARRAY_SIZE(kern_lockdep_table)); return 0; } late_initcall(kernel_lockdep_sysctls_init); diff --git a/kernel/panic.c b/kernel/panic.c index 886d2ebd0a0d..0008273d23fd 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -104,7 +104,8 @@ static struct ctl_table kern_panic_table[] = { static __init int kernel_panic_sysctls_init(void) { - register_sysctl_init("kernel", kern_panic_table); + register_sysctl_init("kernel", kern_panic_table, + ARRAY_SIZE(kern_panic_table)); return 0; } late_initcall(kernel_panic_sysctls_init); diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index b43eee07b00c..7fd5e8adc2e8 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c @@ -472,7 +472,8 @@ static __init int pid_namespaces_init(void) pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC | SLAB_ACCOUNT); #ifdef CONFIG_CHECKPOINT_RESTORE - register_sysctl_init("kernel", pid_ns_ctl_table); + register_sysctl_init("kernel", pid_ns_ctl_table, + ARRAY_SIZE(pid_ns_ctl_table)); #endif register_pid_ns_sysctl_table_vm(); diff --git a/kernel/printk/sysctl.c b/kernel/printk/sysctl.c index c228343eeb97..28f37b86414e 100644 --- a/kernel/printk/sysctl.c +++ b/kernel/printk/sysctl.c @@ -81,5 +81,6 @@ static struct ctl_table printk_sysctls[] = { void __init printk_sysctl_init(void) { - register_sysctl_init("kernel", printk_sysctls); + register_sysctl_init("kernel", printk_sysctls, + ARRAY_SIZE(printk_sysctls)); } diff --git a/kernel/reboot.c b/kernel/reboot.c index 3bba88c7ffc6..cf81d8bfb523 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -1277,7 +1277,8 @@ static struct ctl_table kern_reboot_table[] = { static void __init kernel_reboot_sysctls_init(void) { - register_sysctl_init("kernel", kern_reboot_table); + register_sysctl_init("kernel", kern_reboot_table, + ARRAY_SIZE(kern_reboot_table)); } #else #define kernel_reboot_sysctls_init() do { } while (0) diff --git a/kernel/sched/autogroup.c b/kernel/sched/autogroup.c index 991fc9002535..2b9ce82279a5 100644 --- a/kernel/sched/autogroup.c +++ b/kernel/sched/autogroup.c @@ -24,7 +24,8 @@ static struct ctl_table sched_autogroup_sysctls[] = { static void __init sched_autogroup_sysctl_init(void) { - register_sysctl_init("kernel", sched_autogroup_sysctls); + register_sysctl_init("kernel", sched_autogroup_sysctls, + ARRAY_SIZE(sched_autogroup_sysctls)); } #else #define sched_autogroup_sysctl_init() do { } while (0) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a68d1276bab0..b8c7e01dd78a 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4677,7 +4677,8 @@ static struct ctl_table sched_core_sysctls[] = { }; static int __init sched_core_sysctl_init(void) { - register_sysctl_init("kernel", sched_core_sysctls); + register_sysctl_init("kernel", sched_core_sysctls, + ARRAY_SIZE(sched_core_sysctls)); return 0; } late_initcall(sched_core_sysctl_init); diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 5a9a4b81c972..2aacf5ea2ff3 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -46,7 +46,8 @@ static struct ctl_table sched_dl_sysctls[] = { static int __init sched_dl_sysctl_init(void) { - register_sysctl_init("kernel", sched_dl_sysctls); + register_sysctl_init("kernel", sched_dl_sysctls, + ARRAY_SIZE(sched_dl_sysctls)); return 0; } late_initcall(sched_dl_sysctl_init); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 373ff5f55884..db09e56c2dd3 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -217,7 +217,8 @@ static struct ctl_table sched_fair_sysctls[] = { static int __init sched_fair_sysctl_init(void) { - register_sysctl_init("kernel", sched_fair_sysctls); + register_sysctl_init("kernel", sched_fair_sysctls, + ARRAY_SIZE(sched_fair_sysctls)); return 0; } late_initcall(sched_fair_sysctl_init); diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 00e0e5074115..aab9b900ed6f 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -57,7 +57,8 @@ static struct ctl_table sched_rt_sysctls[] = { static int __init sched_rt_sysctl_init(void) { - register_sysctl_init("kernel", sched_rt_sysctls); + register_sysctl_init("kernel", sched_rt_sysctls, + ARRAY_SIZE(sched_rt_sysctls)); return 0; } late_initcall(sched_rt_sysctl_init); diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 6682535e37c8..46d7c3f3e830 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -255,7 +255,8 @@ static struct ctl_table sched_energy_aware_sysctls[] = { static int __init sched_energy_aware_sysctl_init(void) { - register_sysctl_init("kernel", sched_energy_aware_sysctls); + register_sysctl_init("kernel", sched_energy_aware_sysctls, + ARRAY_SIZE(sched_energy_aware_sysctls)); return 0; } diff --git a/kernel/seccomp.c b/kernel/seccomp.c index d3e584065c7f..9683a9a4709d 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -2386,7 +2386,8 @@ static struct ctl_table seccomp_sysctl_table[] = { static int __init seccomp_sysctl_init(void) { - register_sysctl_init("kernel/seccomp", seccomp_sysctl_table); + register_sysctl_init("kernel/seccomp", seccomp_sysctl_table, + ARRAY_SIZE(seccomp_sysctl_table)); return 0; } diff --git a/kernel/signal.c b/kernel/signal.c index 5ba4150c01a7..19791930f12a 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -4788,7 +4788,8 @@ static struct ctl_table signal_debug_table[] = { static int __init init_signal_sysctls(void) { - register_sysctl_init("debug", signal_debug_table); + register_sysctl_init("debug", signal_debug_table, + ARRAY_SIZE(signal_debug_table)); return 0; } early_initcall(init_signal_sysctls); diff --git a/kernel/stackleak.c b/kernel/stackleak.c index 34c9d81eea94..123844341148 100644 --- a/kernel/stackleak.c +++ b/kernel/stackleak.c @@ -59,7 +59,8 @@ static struct ctl_table stackleak_sysctls[] = { static int __init stackleak_sysctls_init(void) { - register_sysctl_init("kernel", stackleak_sysctls); + register_sysctl_init("kernel", stackleak_sysctls, + ARRAY_SIZE(stackleak_sysctls)); return 0; } late_initcall(stackleak_sysctls_init); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 48046932d573..2b9b0c8569ba 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2321,8 +2321,8 @@ static struct ctl_table vm_table[] = { int __init sysctl_init_bases(void) { - register_sysctl_init("kernel", kern_table); - register_sysctl_init("vm", vm_table); + register_sysctl_init("kernel", kern_table, ARRAY_SIZE(kern_table)); + register_sysctl_init("vm", vm_table, ARRAY_SIZE(vm_table)); return 0; } diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 764668467155..84ef42111f78 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -8219,7 +8219,8 @@ static struct ctl_table ftrace_sysctls[] = { static int __init ftrace_sysctl_init(void) { - register_sysctl_init("kernel", ftrace_sysctls); + register_sysctl_init("kernel", ftrace_sysctls, + ARRAY_SIZE(ftrace_sysctls)); return 0; } late_initcall(ftrace_sysctl_init); diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index b1ecd7677642..ac019cb21b18 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -2563,7 +2563,8 @@ static int __init trace_events_user_init(void) if (dyn_event_register(&user_event_dops)) pr_warn("user_events could not register with dyn_events\n"); - register_sysctl_init("kernel", user_event_sysctls); + register_sysctl_init("kernel", user_event_sysctls, + ARRAY_SIZE(user_event_sysctls)); return 0; } diff --git a/kernel/umh.c b/kernel/umh.c index 41088c5c39fd..187a30ff8541 100644 --- a/kernel/umh.c +++ b/kernel/umh.c @@ -565,7 +565,8 @@ static struct ctl_table usermodehelper_table[] = { static int __init init_umh_sysctls(void) { - register_sysctl_init("kernel/usermodehelper", usermodehelper_table); + register_sysctl_init("kernel/usermodehelper", usermodehelper_table, + ARRAY_SIZE(usermodehelper_table)); return 0; } early_initcall(init_umh_sysctls); diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 8e61f21e7e33..dd5a343fadde 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -847,7 +847,8 @@ static struct ctl_table watchdog_sysctls[] = { static void __init watchdog_sysctl_init(void) { - register_sysctl_init("kernel", watchdog_sysctls); + register_sysctl_init("kernel", watchdog_sysctls, + ARRAY_SIZE(watchdog_sysctls)); } #else #define watchdog_sysctl_init() do { } while (0) diff --git a/mm/compaction.c b/mm/compaction.c index c8bcdea15f5f..ca09cdd72bf3 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -3145,7 +3145,7 @@ static int __init kcompactd_init(void) for_each_node_state(nid, N_MEMORY) kcompactd_run(nid); - register_sysctl_init("vm", vm_compaction); + register_sysctl_init("vm", vm_compaction, ARRAY_SIZE(vm_compaction)); return 0; } subsys_initcall(kcompactd_init) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index f154019e6b84..7838b0c0b82b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4681,7 +4681,7 @@ static struct ctl_table hugetlb_table[] = { static void hugetlb_sysctl_init(void) { - register_sysctl_init("vm", hugetlb_table); + register_sysctl_init("vm", hugetlb_table, ARRAY_SIZE(hugetlb_table)); } #endif /* CONFIG_SYSCTL */ diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 27f001e0f0a2..65885a06269b 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -597,7 +597,8 @@ static int __init hugetlb_vmemmap_init(void) for_each_hstate(h) { if (hugetlb_vmemmap_optimizable(h)) { - register_sysctl_init("vm", hugetlb_vmemmap_sysctls); + register_sysctl_init("vm", hugetlb_vmemmap_sysctls, + ARRAY_SIZE(hugetlb_vmemmap_sysctls)); break; } } diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 5b663eca1f29..46aef76d8e91 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -148,7 +148,8 @@ static struct ctl_table memory_failure_table[] = { static int __init memory_failure_sysctl_init(void) { - register_sysctl_init("vm", memory_failure_table); + register_sysctl_init("vm", memory_failure_table, + ARRAY_SIZE(memory_failure_table)); return 0; } late_initcall(memory_failure_sysctl_init); diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 044e1eed720e..500cf2ef9faa 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -734,7 +734,8 @@ static int __init oom_init(void) { oom_reaper_th = kthread_run(oom_reaper, NULL, "oom_reaper"); #ifdef CONFIG_SYSCTL - register_sysctl_init("vm", vm_oom_kill_table); + register_sysctl_init("vm", vm_oom_kill_table, + ARRAY_SIZE(vm_oom_kill_table)); #endif return 0; } diff --git a/mm/page-writeback.c b/mm/page-writeback.c index db7943999007..9f997de8d12f 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2320,7 +2320,8 @@ void __init page_writeback_init(void) cpuhp_setup_state(CPUHP_MM_WRITEBACK_DEAD, "mm/writeback:dead", NULL, page_writeback_cpu_online); #ifdef CONFIG_SYSCTL - register_sysctl_init("vm", vm_page_writeback_sysctls); + register_sysctl_init("vm", vm_page_writeback_sysctls, + ARRAY_SIZE(vm_page_writeback_sysctls)); #endif } diff --git a/security/keys/sysctl.c b/security/keys/sysctl.c index b72b82bb20c6..fa305f74f658 100644 --- a/security/keys/sysctl.c +++ b/security/keys/sysctl.c @@ -71,7 +71,7 @@ struct ctl_table key_sysctls[] = { static int __init init_security_keys_sysctls(void) { - register_sysctl_init("kernel/keys", key_sysctls); + register_sysctl_init("kernel/keys", key_sysctls, ARRAY_SIZE(key_sysctls)); return 0; } early_initcall(init_security_keys_sysctls); From patchwork Wed Jun 21 09:48:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13287026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B866EB64D8 for ; Wed, 21 Jun 2023 09:48:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232102AbjFUJsg (ORCPT ); Wed, 21 Jun 2023 05:48:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232075AbjFUJsd (ORCPT ); Wed, 21 Jun 2023 05:48:33 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85E87E9; Wed, 21 Jun 2023 02:48:27 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230621094825euoutp0181b4f6b040aecf3eeebdeaf12ec2cb95~qo50ZY65B2236622366euoutp01_; Wed, 21 Jun 2023 09:48:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230621094825euoutp0181b4f6b040aecf3eeebdeaf12ec2cb95~qo50ZY65B2236622366euoutp01_ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687340905; bh=hW7nv4xAjVfG7za+1C5oUlGPxr8RrFgRO4qPCmCRgg4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=pvqcIs+1ajOpVCiyEQvsllPVyFIFy9DNCDjcSoLtGIHFsF/eeGNWaxfu+hnFPU5U8 Qgr/Wkz7tKZcVV91E4yYDuQRnhhP8MEH8JVYfcjgIbcusHKAmDEFhlMf6a3Eexw3sc v2ojHF1rzsp7Mu1ArtQ56tO7A6yjgr0QAiZFYi4o= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230621094825eucas1p1548829d9f587def24707307e2152e9d2~qo5z9joL92428124281eucas1p1e; Wed, 21 Jun 2023 09:48:25 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 55.37.11320.867C2946; Wed, 21 Jun 2023 10:48:24 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230621094824eucas1p2b6adfbd3f15ff3665674917f419b25d3~qo5zHPofw2803828038eucas1p2j; Wed, 21 Jun 2023 09:48:24 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230621094824eusmtrp1ad53bbd4b5f9d962f68895e21ba8293f~qo5zCs_hA1249712497eusmtrp1W; Wed, 21 Jun 2023 09:48:24 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-44-6492c768f5f8 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 2B.F5.10549.767C2946; Wed, 21 Jun 2023 10:48:23 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230621094823eusmtip29cf7ab827cf574b4306610d555107eae~qo5yRx4Lo1505515055eusmtip2Y; Wed, 21 Jun 2023 09:48:23 +0000 (GMT) Received: from localhost (106.210.248.248) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jun 2023 10:48:21 +0100 From: Joel Granados To: , Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Gerald Schaefer , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , Herbert Xu , "David S. Miller" , Russ Weight , Greg Kroah-Hartman , Phillip Potter , Clemens Ladisch , Arnd Bergmann , Corey Minyard , Theodore Ts'o , "Jason A. Donenfeld" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Jason Gunthorpe , Leon Romanovsky , Benjamin Herrenschmidt , Song Liu , Robin Holt , Steve Wahl , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sudip Mukherjee , Mark Rutland , "James E.J. Bottomley" , "Martin K. Petersen" , Doug Gilbert , Jiri Slaby , Juergen Gross , Stefano Stabellini , Alexander Viro , Christian Brauner , Benjamin LaHaise , David Howells , Jan Harkes , , Trond Myklebust , Anna Schumaker , Chuck Lever , Jeff Layton , Jan Kara , Anton Altaparmakov , Mark Fasheh , Joel Becker , Joseph Qi , Kees Cook , Iurii Zaikin , Eric Biggers , "Darrick J. Wong" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Balbir Singh , Eric Biederman , "Naveen N. Rao" , Anil S Keshavamurthy , Masami Hiramatsu , Peter Zijlstra , Petr Mladek , Sergey Senozhatsky , Juri Lelli , Vincent Guittot , John Stultz , Steven Rostedt , Andrew Morton , Mike Kravetz , Muchun Song , Naoya Horiguchi , "Matthew Wilcox (Oracle)" , Joerg Reuter , Ralf Baechle , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Roopa Prabhu , Nikolay Aleksandrov , Alexander Aring , Stefan Schmidt , Miquel Raynal , Steffen Klassert , Matthieu Baerts , Mat Martineau , Simon Horman , Julian Anastasov , Remi Denis-Courmont , Santosh Shilimkar , Marc Dionne , Neil Horman , Marcelo Ricardo Leitner , Xin Long , Karsten Graul , Wenjia Zhang , Jan Karcher , Jon Maloy , Ying Xue , Martin Schiller , John Johansen , Paul Moore , James Morris , "Serge E. Hallyn" , Jarkko Sakkinen CC: Joel Granados , Nicholas Piggin , Christophe Leroy , Christian Borntraeger , Sven Schnelle , "H. Peter Anvin" , "Rafael J. Wysocki" , Mike Travis , Oleksandr Tyshchenko , Amir Goldstein , Matthew Bobrowski , John Fastabend , Martin KaFai Lau , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Waiman Long , Boqun Feng , John Ogness , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Andy Lutomirski , Will Drewry , Stephen Boyd , Miaohe Lin , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH 09/11] sysctl: Remove the end element in sysctl table arrays Date: Wed, 21 Jun 2023 11:48:00 +0200 Message-ID: <20230621094817.433842-1-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621091000.424843-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.248] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA01Ta0yTZxT2/b6vFxm4Aipv0GWEqcmcgG4sO2Zg5qLu2+KiYWNzbpk28AWY XFwLohI3akFEUNsyMALjKgVHN2dty2CA2HWlyF1BEAG5jovcW6owLisUF/49z/uc55zznOTl kg59HGduUGg4IwjlB7uybSiNfqbOLbBS5r/z3nUPuF09xAZDSw4Bfw4+oSC2eJGCYqWKBfMy PQcmzseSoFCJCHj21xQCg+IJBx70NrPh2pCIgvShGg6MyxMRtMsGOLDYMUDADUM3AfPFcSQs aqQk5GabSRj8PQ5Ben0MBf0SNQlN0+Ns+LV0jgTN5UIE4+Jv4VERDSm3nSBNcoeAvqs9LMh/ eAtBV7Mz5LRqCKiqM1OgacpE0HE1mYKahBBQt59nw0D5ZQIaNFdY0Feo5sBPs3kkxD/Po0By fxeUllVRls4dBExcHGNBp2KRBQ0V1SyIyyxBIMkWk6C7VUtBe5KcgooyS3NtchmCar2BAnHm FAmzBZUsyGtpJEARf9OyUuUCAa2SfgS5+ds+4NOKDAWiHz5qJOl/Z2WIzlBE0WnRjRQ9/biO oGdnttOqm48JOkE3TNL9jT50mTmLootTOzh0THkbh85SRtAlJSIL042yDrsdtfHyZ4KDTjEC jz3HbQJVbQ2ckyl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v/8Tqeo 2WU9kj5QmuFADVQYHXu5cUHSxfLUY/qF06MOZZdYHWPymf2NHLusyptXs7hFvo2as4eCCr44 0T7tGRymzBz/VqWbeC/vzfpa2rXjwSe9g0a1ovjTxUbNnE+4/0W6IMlJ7jJ45mKncDCj+P32 5cOQWGLQ9vgFPdKuBFdUxnMJSZiA74iLJYL/AN+vVrqgBAAA X-CMS-MailID: 20230621094824eucas1p2b6adfbd3f15ff3665674917f419b25d3 X-Msg-Generator: CA X-RootMTR: 20230621094824eucas1p2b6adfbd3f15ff3665674917f419b25d3 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230621094824eucas1p2b6adfbd3f15ff3665674917f419b25d3 References: <20230621091000.424843-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Remove the empty end element from all the arrays that are passed to the register sysctl calls. In some files this means reducing the explicit array size by one. Also make sure that we are using the size in ctl_table_header instead of evaluating the .procname element. Signed-off-by: Joel Granados --- arch/arm/kernel/isa.c | 4 +- arch/arm64/kernel/armv8_deprecated.c | 8 ++-- arch/arm64/kernel/fpsimd.c | 6 +-- arch/arm64/kernel/process.c | 3 +- arch/ia64/kernel/crash.c | 3 +- arch/powerpc/kernel/idle.c | 3 +- arch/powerpc/platforms/pseries/mobility.c | 3 +- arch/s390/appldata/appldata_base.c | 7 ++-- arch/s390/kernel/debug.c | 3 +- arch/s390/kernel/topology.c | 3 +- arch/s390/mm/cmm.c | 3 +- arch/s390/mm/pgalloc.c | 3 +- arch/x86/entry/vdso/vdso32-setup.c | 3 +- arch/x86/kernel/cpu/intel.c | 3 +- arch/x86/kernel/itmt.c | 3 +- crypto/fips.c | 3 +- drivers/base/firmware_loader/fallback_table.c | 3 +- drivers/cdrom/cdrom.c | 3 +- drivers/char/hpet.c | 13 +++--- drivers/char/ipmi/ipmi_poweroff.c | 3 +- drivers/char/random.c | 3 +- drivers/gpu/drm/i915/i915_perf.c | 33 +++++++-------- drivers/hv/hv_common.c | 3 +- drivers/infiniband/core/iwcm.c | 3 +- drivers/infiniband/core/ucma.c | 3 +- drivers/macintosh/mac_hid.c | 3 +- drivers/md/md.c | 3 +- drivers/misc/sgi-xp/xpc_main.c | 6 +-- drivers/net/vrf.c | 3 +- drivers/parport/procfs.c | 42 ++++++++----------- drivers/perf/arm_pmuv3.c | 3 +- drivers/scsi/scsi_sysctl.c | 3 +- drivers/scsi/sg.c | 3 +- drivers/tty/tty_io.c | 3 +- drivers/xen/balloon.c | 3 +- fs/aio.c | 3 +- fs/cachefiles/error_inject.c | 3 +- fs/coda/sysctl.c | 3 +- fs/coredump.c | 3 +- fs/dcache.c | 3 +- fs/devpts/inode.c | 3 +- fs/eventpoll.c | 3 +- fs/exec.c | 3 +- fs/file_table.c | 3 +- fs/inode.c | 3 +- fs/lockd/svc.c | 3 +- fs/locks.c | 3 +- fs/namei.c | 3 +- fs/namespace.c | 3 +- fs/nfs/nfs4sysctl.c | 3 +- fs/nfs/sysctl.c | 3 +- fs/notify/dnotify/dnotify.c | 3 +- fs/notify/fanotify/fanotify_user.c | 3 +- fs/notify/inotify/inotify_user.c | 3 +- fs/ntfs/sysctl.c | 3 +- fs/ocfs2/stackglue.c | 3 +- fs/pipe.c | 3 +- fs/proc/proc_sysctl.c | 8 ++-- fs/quota/dquot.c | 3 +- fs/sysctls.c | 3 +- fs/userfaultfd.c | 3 +- fs/verity/signature.c | 3 +- fs/xfs/xfs_sysctl.c | 4 +- init/do_mounts_initrd.c | 3 +- ipc/ipc_sysctl.c | 3 +- ipc/mq_sysctl.c | 3 +- kernel/acct.c | 3 +- kernel/bpf/syscall.c | 3 +- kernel/delayacct.c | 3 +- kernel/exit.c | 3 +- kernel/hung_task.c | 3 +- kernel/kexec_core.c | 3 +- kernel/kprobes.c | 3 +- kernel/latencytop.c | 3 +- kernel/locking/lockdep.c | 3 +- kernel/panic.c | 3 +- kernel/pid_namespace.c | 3 +- kernel/pid_sysctl.h | 3 +- kernel/printk/sysctl.c | 3 +- kernel/reboot.c | 3 +- kernel/sched/autogroup.c | 3 +- kernel/sched/core.c | 3 +- kernel/sched/deadline.c | 3 +- kernel/sched/fair.c | 3 +- kernel/sched/rt.c | 3 +- kernel/sched/topology.c | 3 +- kernel/seccomp.c | 3 +- kernel/signal.c | 3 +- kernel/stackleak.c | 3 +- kernel/sysctl.c | 6 +-- kernel/time/timer.c | 3 +- kernel/trace/ftrace.c | 3 +- kernel/trace/trace_events_user.c | 3 +- kernel/ucount.c | 7 ++-- kernel/umh.c | 3 +- kernel/utsname_sysctl.c | 3 +- kernel/watchdog.c | 3 +- lib/test_sysctl.c | 6 +-- mm/compaction.c | 3 +- mm/hugetlb.c | 3 +- mm/hugetlb_vmemmap.c | 3 +- mm/memory-failure.c | 3 +- mm/oom_kill.c | 3 +- mm/page-writeback.c | 3 +- net/appletalk/sysctl_net_atalk.c | 3 +- net/ax25/sysctl_net_ax25.c | 5 +-- net/bridge/br_netfilter_hooks.c | 3 +- net/core/neighbour.c | 14 +++---- net/core/sysctl_net_core.c | 6 +-- net/dccp/sysctl.c | 4 +- net/ieee802154/6lowpan/reassembly.c | 6 +-- net/ipv4/devinet.c | 5 +-- net/ipv4/ip_fragment.c | 6 +-- net/ipv4/route.c | 6 +-- net/ipv4/sysctl_net_ipv4.c | 6 +-- net/ipv4/xfrm4_policy.c | 3 +- net/ipv6/addrconf.c | 5 +-- net/ipv6/icmp.c | 3 +- net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +- net/ipv6/reassembly.c | 6 +-- net/ipv6/route.c | 3 +- net/ipv6/sysctl_net_ipv6.c | 6 +-- net/ipv6/xfrm6_policy.c | 3 +- net/llc/sysctl_net_llc.c | 4 +- net/mpls/af_mpls.c | 10 ++--- net/mptcp/ctrl.c | 3 +- net/netfilter/ipvs/ip_vs_ctl.c | 3 +- net/netfilter/ipvs/ip_vs_lblc.c | 3 +- net/netfilter/ipvs/ip_vs_lblcr.c | 3 +- net/netfilter/nf_conntrack_standalone.c | 10 ++--- net/netfilter/nf_log.c | 5 +-- net/netrom/sysctl_net_netrom.c | 3 +- net/phonet/sysctl.c | 3 +- net/rds/ib_sysctl.c | 3 +- net/rds/sysctl.c | 3 +- net/rds/tcp.c | 3 +- net/rose/sysctl_net_rose.c | 3 +- net/rxrpc/sysctl.c | 3 +- net/sctp/sysctl.c | 10 ++--- net/smc/smc_sysctl.c | 3 +- net/sunrpc/sysctl.c | 3 +- net/sunrpc/xprtrdma/svc_rdma.c | 3 +- net/sunrpc/xprtrdma/transport.c | 3 +- net/sunrpc/xprtsock.c | 3 +- net/tipc/sysctl.c | 3 +- net/unix/sysctl_net_unix.c | 3 +- net/x25/sysctl_net_x25.c | 3 +- net/xfrm/xfrm_sysctl.c | 3 +- security/apparmor/lsm.c | 4 +- security/keys/sysctl.c | 7 ++-- security/loadpin/loadpin.c | 3 +- security/yama/yama_lsm.c | 3 +- 152 files changed, 228 insertions(+), 407 deletions(-) diff --git a/arch/arm/kernel/isa.c b/arch/arm/kernel/isa.c index 561432e3c55a..72b1a0e63d21 100644 --- a/arch/arm/kernel/isa.c +++ b/arch/arm/kernel/isa.c @@ -16,7 +16,7 @@ static unsigned int isa_membase, isa_portbase, isa_portshift; -static struct ctl_table ctl_isa_vars[4] = { +static struct ctl_table ctl_isa_vars[] = { { .procname = "membase", .data = &isa_membase, @@ -35,7 +35,7 @@ static struct ctl_table ctl_isa_vars[4] = { .maxlen = sizeof(isa_portshift), .mode = 0444, .proc_handler = proc_dointvec, - }, {} + } }; static struct ctl_table_header *isa_sysctl_header; diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c index 68ed60a521a6..43945a8bb8e0 100644 --- a/arch/arm64/kernel/armv8_deprecated.c +++ b/arch/arm64/kernel/armv8_deprecated.c @@ -52,10 +52,8 @@ struct insn_emulation { int min; int max; - /* - * sysctl for this emulation + a sentinal entry. - */ - struct ctl_table sysctl[2]; + /* sysctl for this emulation */ + struct ctl_table sysctl; }; #define ARM_OPCODE_CONDTEST_FAIL 0 @@ -558,7 +556,7 @@ static void __init register_insn_emulation(struct insn_emulation *insn) update_insn_emulation_mode(insn, INSN_UNDEF); if (insn->status != INSN_UNAVAILABLE) { - sysctl = &insn->sysctl[0]; + sysctl = &insn->sysctl; sysctl->mode = 0644; sysctl->maxlen = sizeof(int); diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index ecfb2ef6a036..37155b4ae893 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -588,8 +588,7 @@ static struct ctl_table sve_default_vl_table[] = { .mode = 0644, .proc_handler = vec_proc_do_default_vl, .extra1 = &vl_info[ARM64_VEC_SVE], - }, - { } + } }; static int __init sve_sysctl_init(void) @@ -613,8 +612,7 @@ static struct ctl_table sme_default_vl_table[] = { .mode = 0644, .proc_handler = vec_proc_do_default_vl, .extra1 = &vl_info[ARM64_VEC_SME], - }, - { } + } }; static int __init sme_sysctl_init(void) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index cfe232960f2f..ae837130a265 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -723,8 +723,7 @@ static struct ctl_table tagged_addr_sysctl_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; static int __init tagged_addr_init(void) diff --git a/arch/ia64/kernel/crash.c b/arch/ia64/kernel/crash.c index 66917b879b2a..958ab3bbbdbc 100644 --- a/arch/ia64/kernel/crash.c +++ b/arch/ia64/kernel/crash.c @@ -231,8 +231,7 @@ static struct ctl_table kdump_ctl_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; #endif diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c index 3807169fc7e7..f98f7b00d3cf 100644 --- a/arch/powerpc/kernel/idle.c +++ b/arch/powerpc/kernel/idle.c @@ -104,8 +104,7 @@ static struct ctl_table powersave_nap_ctl_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - {} + } }; static int __init diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c index 9fdbee8ee126..48337c9dd3a0 100644 --- a/arch/powerpc/platforms/pseries/mobility.c +++ b/arch/powerpc/platforms/pseries/mobility.c @@ -59,8 +59,7 @@ static struct ctl_table nmi_wd_lpm_factor_ctl_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_douintvec_minmax, - }, - {} + } }; static int __init register_nmi_wd_lpm_factor_sysctl(void) diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c index 54d8ed1c4518..0e1136b3dc01 100644 --- a/arch/s390/appldata/appldata_base.c +++ b/arch/s390/appldata/appldata_base.c @@ -62,8 +62,7 @@ static struct ctl_table appldata_table[] = { .procname = "interval", .mode = S_IRUGO | S_IWUSR, .proc_handler = appldata_interval_handler, - }, - { }, + } }; /* @@ -352,7 +351,7 @@ int appldata_register_ops(struct appldata_ops *ops) return -EINVAL; /* The last entry must be an empty one */ - ops->ctl_table = kcalloc(2, sizeof(struct ctl_table), GFP_KERNEL); + ops->ctl_table = kcalloc(1, sizeof(struct ctl_table), GFP_KERNEL); if (!ops->ctl_table) return -ENOMEM; @@ -365,7 +364,7 @@ int appldata_register_ops(struct appldata_ops *ops) ops->ctl_table[0].proc_handler = appldata_generic_handler; ops->ctl_table[0].data = ops; - ops->sysctl_header = register_sysctl(appldata_proc_name, ops->ctl_table); + ops->sysctl_header = register_sysctl(appldata_proc_name, ops->ctl_table, 1); if (!ops->sysctl_header) goto out; return 0; diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c index 002f843e6523..24f33be6565d 100644 --- a/arch/s390/kernel/debug.c +++ b/arch/s390/kernel/debug.c @@ -977,8 +977,7 @@ static struct ctl_table s390dbf_table[] = { .maxlen = sizeof(int), .mode = S_IRUGO | S_IWUSR, .proc_handler = s390dbf_procactive, - }, - { } + } }; static struct ctl_table_header *s390dbf_sysctl_header; diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c index 372d2c7c9a8e..931da71b8a4a 100644 --- a/arch/s390/kernel/topology.c +++ b/arch/s390/kernel/topology.c @@ -633,8 +633,7 @@ static struct ctl_table topology_ctl_table[] = { .procname = "topology", .mode = 0644, .proc_handler = topology_ctl_handler, - }, - { }, + } }; static int __init topology_init(void) diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c index 918816dcb42a..1b304352a3e9 100644 --- a/arch/s390/mm/cmm.c +++ b/arch/s390/mm/cmm.c @@ -331,8 +331,7 @@ static struct ctl_table cmm_table[] = { .procname = "cmm_timeout", .mode = 0644, .proc_handler = cmm_timeout_handler, - }, - { } + } }; #ifdef CONFIG_CMM_IUCV diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c index a723f1a8236a..59444f580d0d 100644 --- a/arch/s390/mm/pgalloc.c +++ b/arch/s390/mm/pgalloc.c @@ -29,8 +29,7 @@ static struct ctl_table page_table_sysctl[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; static int __init page_table_register_sysctl(void) diff --git a/arch/x86/entry/vdso/vdso32-setup.c b/arch/x86/entry/vdso/vdso32-setup.c index e28cdba83e0e..ab794f70a550 100644 --- a/arch/x86/entry/vdso/vdso32-setup.c +++ b/arch/x86/entry/vdso/vdso32-setup.c @@ -66,8 +66,7 @@ static struct ctl_table abi_table2[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - {} + } }; static __init int ia32_binfmt_init(void) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index c77a3961443d..d446f2a0fbeb 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -1189,8 +1189,7 @@ static struct ctl_table sld_sysctls[] = { .proc_handler = proc_douintvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - {} + } }; static int __init sld_mitigate_sysctl_init(void) diff --git a/arch/x86/kernel/itmt.c b/arch/x86/kernel/itmt.c index 58ec95fce798..427093e4ef87 100644 --- a/arch/x86/kernel/itmt.c +++ b/arch/x86/kernel/itmt.c @@ -73,8 +73,7 @@ static struct ctl_table itmt_kern_table[] = { .proc_handler = sched_itmt_update_handler, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - {} + } }; static struct ctl_table_header *itmt_sysctl_header; diff --git a/crypto/fips.c b/crypto/fips.c index 05a251680700..611a86bd2538 100644 --- a/crypto/fips.c +++ b/crypto/fips.c @@ -62,8 +62,7 @@ static struct ctl_table crypto_sysctl_table[] = { .maxlen = 64, .mode = 0444, .proc_handler = proc_dostring - }, - {} + } }; static struct ctl_table_header *crypto_sysctls; diff --git a/drivers/base/firmware_loader/fallback_table.c b/drivers/base/firmware_loader/fallback_table.c index 7a2d584233bb..d7dedfb2f4d0 100644 --- a/drivers/base/firmware_loader/fallback_table.c +++ b/drivers/base/firmware_loader/fallback_table.c @@ -43,8 +43,7 @@ static struct ctl_table firmware_config_table[] = { .proc_handler = proc_douintvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; static struct ctl_table_header *firmware_config_sysct_table_header; diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 3855da76a16d..e1c352ebab16 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -3668,8 +3668,7 @@ static struct ctl_table cdrom_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = cdrom_sysctl_handler - }, - { } + } }; static struct ctl_table_header *cdrom_sysctl_header; diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index bb1eb801b20c..44eaec98f958 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -722,13 +722,12 @@ static int hpet_is_known(struct hpet_data *hdp) static struct ctl_table hpet_table[] = { { - .procname = "max-user-freq", - .data = &hpet_max_freq, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec, - }, - {} + .procname = "max-user-freq", + .data = &hpet_max_freq, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + } }; static struct ctl_table_header *sysctl_header; diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c index 46b1ea866da9..40c43417a42e 100644 --- a/drivers/char/ipmi/ipmi_poweroff.c +++ b/drivers/char/ipmi/ipmi_poweroff.c @@ -655,8 +655,7 @@ static struct ctl_table ipmi_table[] = { .data = &poweroff_powercycle, .maxlen = sizeof(poweroff_powercycle), .mode = 0644, - .proc_handler = proc_dointvec }, - { } + .proc_handler = proc_dointvec } }; static struct ctl_table_header *ipmi_table_header; diff --git a/drivers/char/random.c b/drivers/char/random.c index 8db2ea9e3d66..e2998580afc6 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1682,8 +1682,7 @@ static struct ctl_table random_table[] = { .procname = "uuid", .mode = 0444, .proc_handler = proc_do_uuid, - }, - { } + } }; /* diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index f43950219ffc..e4d7372afb10 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -4884,24 +4884,23 @@ int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data, static struct ctl_table oa_table[] = { { - .procname = "perf_stream_paranoid", - .data = &i915_perf_stream_paranoid, - .maxlen = sizeof(i915_perf_stream_paranoid), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, + .procname = "perf_stream_paranoid", + .data = &i915_perf_stream_paranoid, + .maxlen = sizeof(i915_perf_stream_paranoid), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, { - .procname = "oa_max_sample_rate", - .data = &i915_oa_max_sample_rate, - .maxlen = sizeof(i915_oa_max_sample_rate), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = &oa_sample_rate_hard_limit, - }, - {} + .procname = "oa_max_sample_rate", + .data = &i915_oa_max_sample_rate, + .maxlen = sizeof(i915_oa_max_sample_rate), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = &oa_sample_rate_hard_limit, + } }; static u32 num_perf_groups_per_gt(struct intel_gt *gt) diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index dd751c391cf7..0216ccd96496 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -146,8 +146,7 @@ static struct ctl_table hv_ctl_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE - }, - {} + } }; static int hv_die_panic_notify_crash(struct notifier_block *self, diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c index 20627a894c89..0147aae8fe9b 100644 --- a/drivers/infiniband/core/iwcm.c +++ b/drivers/infiniband/core/iwcm.c @@ -110,8 +110,7 @@ static struct ctl_table iwcm_ctl_table[] = { .maxlen = sizeof(default_backlog), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; /* diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index f737ab0de883..cbe1ebef2f2e 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -70,8 +70,7 @@ static struct ctl_table ucma_ctl_table[] = { .maxlen = sizeof max_backlog, .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; struct ucma_file { diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c index 5d433ef430fa..822517cf4735 100644 --- a/drivers/macintosh/mac_hid.c +++ b/drivers/macintosh/mac_hid.c @@ -235,8 +235,7 @@ static struct ctl_table mac_hid_files[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; static struct ctl_table_header *mac_hid_sysctl_header; diff --git a/drivers/md/md.c b/drivers/md/md.c index c10cc8ddd94d..3ad23a7bfbc5 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -318,8 +318,7 @@ static struct ctl_table raid_table[] = { .maxlen = sizeof(int), .mode = S_IRUGO|S_IWUSR, .proc_handler = proc_dointvec, - }, - { } + } }; static int start_readonly; diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c index 264b919d0610..3e6a598df22a 100644 --- a/drivers/misc/sgi-xp/xpc_main.c +++ b/drivers/misc/sgi-xp/xpc_main.c @@ -109,8 +109,7 @@ static struct ctl_table xpc_sys_xpc_hb[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = &xpc_hb_check_min_interval, - .extra2 = &xpc_hb_check_max_interval}, - {} + .extra2 = &xpc_hb_check_max_interval} }; static struct ctl_table xpc_sys_xpc[] = { { @@ -120,8 +119,7 @@ static struct ctl_table xpc_sys_xpc[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = &xpc_disengage_min_timelimit, - .extra2 = &xpc_disengage_max_timelimit}, - {} + .extra2 = &xpc_disengage_max_timelimit} }; static struct ctl_table_header *xpc_sysctl; diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index edd8f2ba5595..22dedd3671ec 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -1964,8 +1964,7 @@ static const struct ctl_table vrf_table[] = { .proc_handler = vrf_shared_table_handler, /* set by the vrf_netns_init */ .extra1 = NULL, - }, - { }, + } }; static int vrf_netns_init_sysctl(struct net *net, struct netns_vrf *nn_vrf) diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index 16cee52f035f..f6e0121f8904 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c @@ -259,8 +259,12 @@ PARPORT_MAX_SPINTIME_VALUE; struct parport_sysctl_table { struct ctl_table_header *port_header; struct ctl_table_header *devices_header; - struct ctl_table vars[12]; - struct ctl_table device_dir[2]; +#ifdef CONFIG_PARPORT_1284 + struct ctl_table vars[10]; +#else + struct ctl_table vars[5]; +#endif /* IEEE 1284 support */ + struct ctl_table device_dir[1]; }; static const struct parport_sysctl_table parport_sysctl_template = { @@ -303,9 +307,9 @@ static const struct parport_sysctl_table parport_sysctl_template = { .maxlen = 0, .mode = 0444, .proc_handler = do_hardware_modes - }, + } #ifdef CONFIG_PARPORT_1284 - { + , { .procname = "autoprobe", .data = NULL, .maxlen = 0, @@ -339,9 +343,8 @@ static const struct parport_sysctl_table parport_sysctl_template = { .maxlen = 0, .mode = 0444, .proc_handler = do_autoprobe - }, + } #endif /* IEEE 1284 support */ - {} }, { { @@ -350,20 +353,15 @@ static const struct parport_sysctl_table parport_sysctl_template = { .maxlen = 0, .mode = 0444, .proc_handler = do_active_device - }, - {} + } }, }; struct parport_device_sysctl_table { struct ctl_table_header *sysctl_header; - struct ctl_table vars[2]; - struct ctl_table device_dir[2]; - struct ctl_table devices_root_dir[2]; - struct ctl_table port_dir[2]; - struct ctl_table parport_dir[2]; - struct ctl_table dev_dir[2]; + struct ctl_table vars[1]; + struct ctl_table device_dir[1]; }; static const struct parport_device_sysctl_table @@ -378,8 +376,7 @@ parport_device_sysctl_template = { .proc_handler = proc_doulongvec_ms_jiffies_minmax, .extra1 = (void*) &parport_min_timeslice_value, .extra2 = (void*) &parport_max_timeslice_value - }, - {} + } }, { { @@ -387,18 +384,14 @@ parport_device_sysctl_template = { .data = NULL, .maxlen = 0, .mode = 0555, - }, - {} + } } }; struct parport_default_sysctl_table { struct ctl_table_header *sysctl_header; - struct ctl_table vars[3]; - struct ctl_table default_dir[2]; - struct ctl_table parport_dir[2]; - struct ctl_table dev_dir[2]; + struct ctl_table vars[2]; }; static struct parport_default_sysctl_table @@ -422,8 +415,7 @@ parport_default_sysctl_table = { .proc_handler = proc_dointvec_minmax, .extra1 = (void*) &parport_min_spintime_value, .extra2 = (void*) &parport_max_spintime_value - }, - {} + } } }; @@ -443,7 +435,9 @@ int parport_proc_register(struct parport *port) t->vars[0].data = &port->spintime; for (i = 0; i < 5; i++) { t->vars[i].extra1 = port; +#ifdef CONFIG_PARPORT_1284 t->vars[5 + i].extra2 = &port->probe_info[i]; +#endif /* IEEE 1284 support */ } port_name_len = strnlen(port->name, PARPORT_NAME_MAX_LEN); diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index 763f9c8acfbf..85285c85bd49 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -1179,8 +1179,7 @@ static struct ctl_table armv8_pmu_sysctl_table[] = { .proc_handler = armv8pmu_proc_user_access_handler, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; static void armv8_pmu_register_sysctl_table(void) diff --git a/drivers/scsi/scsi_sysctl.c b/drivers/scsi/scsi_sysctl.c index 0378bd63fea4..22c2d055821e 100644 --- a/drivers/scsi/scsi_sysctl.c +++ b/drivers/scsi/scsi_sysctl.c @@ -17,8 +17,7 @@ static struct ctl_table scsi_table[] = { .data = &scsi_logging_level, .maxlen = sizeof(scsi_logging_level), .mode = 0644, - .proc_handler = proc_dointvec }, - { } + .proc_handler = proc_dointvec } }; static struct ctl_table_header *scsi_table_header; diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index d12cdf875b50..102a3640c6c7 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1638,8 +1638,7 @@ static struct ctl_table sg_sysctls[] = { .maxlen = sizeof(int), .mode = 0444, .proc_handler = proc_dointvec, - }, - {} + } }; static struct ctl_table_header *hdr; diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 63fb3c543b94..bd6b12394d76 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3608,8 +3608,7 @@ static struct ctl_table tty_table[] = { .proc_handler = proc_dointvec, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; /* diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index e4544262a429..bef75c236104 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -93,8 +93,7 @@ static struct ctl_table balloon_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; #else diff --git a/fs/aio.c b/fs/aio.c index b09abe7a14d3..f2ed0a34a5d4 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -238,8 +238,7 @@ static struct ctl_table aio_sysctls[] = { .maxlen = sizeof(aio_max_nr), .mode = 0644, .proc_handler = proc_doulongvec_minmax, - }, - {} + } }; static void __init aio_sysctl_init(void) diff --git a/fs/cachefiles/error_inject.c b/fs/cachefiles/error_inject.c index ea6bcce4f6f1..4fa84880c0d1 100644 --- a/fs/cachefiles/error_inject.c +++ b/fs/cachefiles/error_inject.c @@ -18,8 +18,7 @@ static struct ctl_table cachefiles_sysctls[] = { .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_douintvec, - }, - {} + } }; int __init cachefiles_register_error_injection(void) diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c index 16224a7c6691..e377e400bfed 100644 --- a/fs/coda/sysctl.c +++ b/fs/coda/sysctl.c @@ -35,8 +35,7 @@ static struct ctl_table coda_table[] = { .maxlen = sizeof(int), .mode = 0600, .proc_handler = proc_dointvec - }, - {} + } }; void coda_sysctl_init(void) diff --git a/fs/coredump.c b/fs/coredump.c index 7e55428dce13..99142426a156 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -978,8 +978,7 @@ static struct ctl_table coredump_sysctls[] = { .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; static int __init init_fs_coredump_sysctls(void) diff --git a/fs/dcache.c b/fs/dcache.c index f02bfd383e66..257450fd8f01 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -190,8 +190,7 @@ static struct ctl_table fs_dcache_sysctls[] = { .maxlen = 6*sizeof(long), .mode = 0444, .proc_handler = proc_nr_dentry, - }, - { } + } }; static int __init init_fs_dcache_sysctls(void) diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index c17f971a8c4b..8d56add71e71 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c @@ -68,8 +68,7 @@ static struct ctl_table pty_table[] = { .mode = 0444, .data = &pty_count, .proc_handler = proc_dointvec, - }, - {} + } }; struct pts_mount_opts { diff --git a/fs/eventpoll.c b/fs/eventpoll.c index e1a0e6a6d3de..b0556c52685c 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -321,8 +321,7 @@ static struct ctl_table epoll_table[] = { .proc_handler = proc_doulongvec_minmax, .extra1 = &long_zero, .extra2 = &long_max, - }, - { } + } }; static void __init epoll_sysctls_init(void) diff --git a/fs/exec.c b/fs/exec.c index 5572d148738b..9458ef2b8028 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -2164,8 +2164,7 @@ static struct ctl_table fs_exec_sysctls[] = { .proc_handler = proc_dointvec_minmax_coredump, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, - }, - { } + } }; static int __init init_fs_exec_sysctls(void) diff --git a/fs/file_table.c b/fs/file_table.c index 23a645521960..6fec4c691f0a 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -114,8 +114,7 @@ static struct ctl_table fs_stat_sysctls[] = { .proc_handler = proc_dointvec_minmax, .extra1 = &sysctl_nr_open_min, .extra2 = &sysctl_nr_open_max, - }, - { } + } }; static int __init init_fs_stat_sysctls(void) diff --git a/fs/inode.c b/fs/inode.c index 0a0ad1a2a5d2..79c5916cade7 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -129,8 +129,7 @@ static struct ctl_table inodes_sysctls[] = { .maxlen = 7*sizeof(long), .mode = 0444, .proc_handler = proc_nr_inodes, - }, - { } + } }; static int __init init_fs_inode_sysctls(void) diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 84736267f4e1..082fcf6340d4 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -506,8 +506,7 @@ static struct ctl_table nlm_sysctls[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; #endif /* CONFIG_SYSCTL */ diff --git a/fs/locks.c b/fs/locks.c index ce5733480aa6..9750076cdd8d 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -109,9 +109,8 @@ static struct ctl_table locks_sysctls[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, + } #endif /* CONFIG_MMU */ - {} }; static int __init init_fs_locks_sysctls(void) diff --git a/fs/namei.c b/fs/namei.c index 9b567af081af..b0f8d09c2111 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1067,8 +1067,7 @@ static struct ctl_table namei_sysctls[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, - }, - { } + } }; static int __init init_fs_namei_sysctls(void) diff --git a/fs/namespace.c b/fs/namespace.c index e7f251e40485..780e9292fa52 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4709,8 +4709,7 @@ static struct ctl_table fs_namespace_sysctls[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ONE, - }, - { } + } }; static int __init init_fs_namespace_sysctls(void) diff --git a/fs/nfs/nfs4sysctl.c b/fs/nfs/nfs4sysctl.c index 4a542ee11e68..5515c2e8afe7 100644 --- a/fs/nfs/nfs4sysctl.c +++ b/fs/nfs/nfs4sysctl.c @@ -33,8 +33,7 @@ static struct ctl_table nfs4_cb_sysctls[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; int nfs4_register_sysctl(void) diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c index 9dafd44670e4..8a71d31e5dc3 100644 --- a/fs/nfs/sysctl.c +++ b/fs/nfs/sysctl.c @@ -28,8 +28,7 @@ static struct ctl_table nfs_cb_sysctls[] = { .maxlen = sizeof(nfs_congestion_kb), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; int nfs_register_sysctl(void) diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c index 2c6fe98d6fe1..409ca0a9a048 100644 --- a/fs/notify/dnotify/dnotify.c +++ b/fs/notify/dnotify/dnotify.c @@ -28,8 +28,7 @@ static struct ctl_table dnotify_sysctls[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - {} + } }; static void __init dnotify_sysctl_init(void) { diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 78d3bf479f59..4c43eb38b9cf 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -85,8 +85,7 @@ static struct ctl_table fanotify_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO - }, - { } + } }; static void __init fanotify_sysctls_init(void) diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 0ce25c4ddfec..02b74d8b4e28 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -84,8 +84,7 @@ static struct ctl_table inotify_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO - }, - { } + } }; static void __init inotify_sysctls_init(void) diff --git a/fs/ntfs/sysctl.c b/fs/ntfs/sysctl.c index 2c48f48a0b80..fef88fb6a40f 100644 --- a/fs/ntfs/sysctl.c +++ b/fs/ntfs/sysctl.c @@ -27,8 +27,7 @@ static struct ctl_table ntfs_sysctls[] = { .maxlen = sizeof(debug_msgs), .mode = 0644, /* Mode, proc handler. */ .proc_handler = proc_dointvec - }, - {} + } }; /* Storage for the sysctls header. */ diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index 9a653875d1c5..7be619f93960 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c @@ -657,8 +657,7 @@ static struct ctl_table ocfs2_nm_table[] = { .maxlen = OCFS2_MAX_HB_CTL_PATH, .mode = 0644, .proc_handler = proc_dostring, - }, - { } + } }; static struct ctl_table_header *ocfs2_table_header; diff --git a/fs/pipe.c b/fs/pipe.c index 8a808fc25552..8fab91c2d546 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -1491,8 +1491,7 @@ static struct ctl_table fs_pipe_sysctls[] = { .maxlen = sizeof(pipe_user_pages_soft), .mode = 0644, .proc_handler = proc_doulongvec_minmax, - }, - { } + } }; #endif diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 9670c5b7b5b2..1debd01209fc 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -19,8 +19,9 @@ #include #include "internal.h" -#define list_for_each_table_entry(entry, header) \ - for ((entry) = (header->ctl_table); (entry)->procname; (entry)++) +#define list_for_each_table_entry(entry, header) \ + entry = header->ctl_table; \ + for (size_t i = 0 ; i < header->ctl_table_size ; ++i, entry++) static const struct dentry_operations proc_sys_dentry_operations; static const struct file_operations proc_sys_file_operations; @@ -69,8 +70,7 @@ static struct ctl_table root_table[] = { { .procname = "", .mode = S_IFDIR|S_IRUGO|S_IXUGO, - }, - { } + } }; static struct ctl_table_root sysctl_table_root = { .default_set.dir.header = { diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 7c07654e4253..1eb18c8bd639 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -2941,9 +2941,8 @@ static struct ctl_table fs_dqstats_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, + } #endif - { }, }; static int __init dquot_init(void) diff --git a/fs/sysctls.c b/fs/sysctls.c index 944254dd92c0..d6ed656738ff 100644 --- a/fs/sysctls.c +++ b/fs/sysctls.c @@ -25,8 +25,7 @@ static struct ctl_table fs_shared_sysctls[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_MAXOLDUID, - }, - { } + } }; static int __init init_fs_sysctls(void) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 4c3858769226..165b9c52e626 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -44,8 +44,7 @@ static struct ctl_table vm_userfaultfd_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; #endif diff --git a/fs/verity/signature.c b/fs/verity/signature.c index f617c6a1f16c..05585e93f32b 100644 --- a/fs/verity/signature.c +++ b/fs/verity/signature.c @@ -97,8 +97,7 @@ static struct ctl_table fsverity_sysctl_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; static int __init fsverity_sysctl_init(void) diff --git a/fs/xfs/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c index 61075e9c9e37..5c6337526070 100644 --- a/fs/xfs/xfs_sysctl.c +++ b/fs/xfs/xfs_sysctl.c @@ -204,10 +204,8 @@ static struct ctl_table xfs_table[] = { .proc_handler = xfs_stats_clear_proc_handler, .extra1 = &xfs_params.stats_clear.min, .extra2 = &xfs_params.stats_clear.max - }, + } #endif /* CONFIG_PROC_FS */ - - {} }; int diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index 2b10abb8c80e..a894519efdd3 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -28,8 +28,7 @@ static struct ctl_table kern_do_mounts_initrd_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; static __init int kernel_do_mounts_initrd_sysctls_init(void) diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c index 8c62e443f78b..a46d15f5b476 100644 --- a/ipc/ipc_sysctl.c +++ b/ipc/ipc_sysctl.c @@ -175,9 +175,8 @@ static struct ctl_table ipc_sysctls[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_INT_MAX, - }, + } #endif - {} }; static struct ctl_table_set *set_lookup(struct ctl_table_root *root) diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c index ebb5ed81c151..8191d03b39cb 100644 --- a/ipc/mq_sysctl.c +++ b/ipc/mq_sysctl.c @@ -62,8 +62,7 @@ static struct ctl_table mq_sysctls[] = { .proc_handler = proc_dointvec_minmax, .extra1 = &msg_maxsize_limit_min, .extra2 = &msg_maxsize_limit_max, - }, - {} + } }; static struct ctl_table_set *set_lookup(struct ctl_table_root *root) diff --git a/kernel/acct.c b/kernel/acct.c index 67125b7c5ca2..93417042762b 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -83,8 +83,7 @@ static struct ctl_table kern_acct_table[] = { .maxlen = 3*sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; static __init int kernel_acct_sysctls_init(void) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index a81b5122b16b..980ad104fff8 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -5400,8 +5400,7 @@ static struct ctl_table bpf_syscall_table[] = { .data = &bpf_stats_enabled_key.key, .mode = 0644, .proc_handler = bpf_stats_handler, - }, - { } + } }; static int __init bpf_syscall_sysctl_init(void) diff --git a/kernel/delayacct.c b/kernel/delayacct.c index 4ef14cb5b5a0..539cab051d17 100644 --- a/kernel/delayacct.c +++ b/kernel/delayacct.c @@ -73,8 +73,7 @@ static struct ctl_table kern_delayacct_table[] = { .proc_handler = sysctl_delayacct, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; static __init int kernel_delayacct_sysctls_init(void) diff --git a/kernel/exit.c b/kernel/exit.c index 633c7a52ef80..87cb53a33bbc 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -89,8 +89,7 @@ static struct ctl_table kern_exit_table[] = { .maxlen = sizeof(oops_limit), .mode = 0644, .proc_handler = proc_douintvec, - }, - { } + } }; static __init int kernel_exit_sysctls_init(void) diff --git a/kernel/hung_task.c b/kernel/hung_task.c index 816f133266c4..8d0659453421 100644 --- a/kernel/hung_task.c +++ b/kernel/hung_task.c @@ -312,8 +312,7 @@ static struct ctl_table hung_task_sysctls[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_NEG_ONE, - }, - {} + } }; static void __init hung_task_sysctl_init(void) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 63b04e710890..160779e0a503 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -1001,8 +1001,7 @@ static struct ctl_table kexec_core_sysctls[] = { .data = &load_limit_reboot, .mode = 0644, .proc_handler = kexec_limit_handler, - }, - { } + } }; static int __init kexec_core_sysctl_init(void) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 06a3ac7993f0..ae6b0f78ae6c 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -967,8 +967,7 @@ static struct ctl_table kprobe_sysctls[] = { .proc_handler = proc_kprobes_optimization_handler, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - {} + } }; static void __init kprobe_sysctls_init(void) diff --git a/kernel/latencytop.c b/kernel/latencytop.c index 55050ae0e197..bb4dd0691b3c 100644 --- a/kernel/latencytop.c +++ b/kernel/latencytop.c @@ -84,8 +84,7 @@ static struct ctl_table latencytop_sysctl[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = sysctl_latencytop, - }, - {} + } }; #endif diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 1e29cec7e00c..0db8af590f87 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -95,9 +95,8 @@ static struct ctl_table kern_lockdep_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, + } #endif /* CONFIG_LOCK_STAT */ - { } }; static __init int kernel_lockdep_sysctls_init(void) diff --git a/kernel/panic.c b/kernel/panic.c index 0008273d23fd..79786433efda 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -98,8 +98,7 @@ static struct ctl_table kern_panic_table[] = { .maxlen = sizeof(warn_limit), .mode = 0644, .proc_handler = proc_douintvec, - }, - { } + } }; static __init int kernel_panic_sysctls_init(void) diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index 7fd5e8adc2e8..dc7adbd2f412 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c @@ -311,8 +311,7 @@ static struct ctl_table pid_ns_ctl_table[] = { .proc_handler = pid_ns_ctl_handler, .extra1 = SYSCTL_ZERO, .extra2 = &pid_max, - }, - { } + } }; #endif /* CONFIG_CHECKPOINT_RESTORE */ diff --git a/kernel/pid_sysctl.h b/kernel/pid_sysctl.h index 8b24744752cb..b9528766d2d8 100644 --- a/kernel/pid_sysctl.h +++ b/kernel/pid_sysctl.h @@ -43,8 +43,7 @@ static struct ctl_table pid_ns_ctl_table_vm[] = { .proc_handler = pid_mfd_noexec_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, - }, - { } + } }; static inline void register_pid_ns_sysctl_table_vm(void) { diff --git a/kernel/printk/sysctl.c b/kernel/printk/sysctl.c index 28f37b86414e..d608832b4489 100644 --- a/kernel/printk/sysctl.c +++ b/kernel/printk/sysctl.c @@ -75,8 +75,7 @@ static struct ctl_table printk_sysctls[] = { .proc_handler = proc_dointvec_minmax_sysadmin, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, - }, - {} + } }; void __init printk_sysctl_init(void) diff --git a/kernel/reboot.c b/kernel/reboot.c index cf81d8bfb523..e29d415810c1 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -1271,8 +1271,7 @@ static struct ctl_table kern_reboot_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; static void __init kernel_reboot_sysctls_init(void) diff --git a/kernel/sched/autogroup.c b/kernel/sched/autogroup.c index 2b9ce82279a5..4c558f0de4f7 100644 --- a/kernel/sched/autogroup.c +++ b/kernel/sched/autogroup.c @@ -18,8 +18,7 @@ static struct ctl_table sched_autogroup_sysctls[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - {} + } }; static void __init sched_autogroup_sysctl_init(void) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b8c7e01dd78a..f11ac1d3e315 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4671,9 +4671,8 @@ static struct ctl_table sched_core_sysctls[] = { .proc_handler = sysctl_numa_balancing, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_FOUR, - }, + } #endif /* CONFIG_NUMA_BALANCING */ - {} }; static int __init sched_core_sysctl_init(void) { diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 2aacf5ea2ff3..a6cbdf588590 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -40,8 +40,7 @@ static struct ctl_table sched_dl_sysctls[] = { .mode = 0644, .proc_handler = proc_douintvec_minmax, .extra2 = (void *)&sysctl_sched_dl_period_max, - }, - {} + } }; static int __init sched_dl_sysctl_init(void) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index db09e56c2dd3..876f110e696d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -210,9 +210,8 @@ static struct ctl_table sched_fair_sysctls[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, - }, + } #endif /* CONFIG_NUMA_BALANCING */ - {} }; static int __init sched_fair_sysctl_init(void) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index aab9b900ed6f..2e2d49467dd9 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -51,8 +51,7 @@ static struct ctl_table sched_rt_sysctls[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = sched_rr_handler, - }, - {} + } }; static int __init sched_rt_sysctl_init(void) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 46d7c3f3e830..cd3fffecbce3 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -249,8 +249,7 @@ static struct ctl_table sched_energy_aware_sysctls[] = { .proc_handler = sched_energy_aware_handler, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - {} + } }; static int __init sched_energy_aware_sysctl_init(void) diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 9683a9a4709d..1693f0935904 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -2380,8 +2380,7 @@ static struct ctl_table seccomp_sysctl_table[] = { .procname = "actions_logged", .mode = 0644, .proc_handler = seccomp_actions_logged_handler, - }, - { } + } }; static int __init seccomp_sysctl_init(void) diff --git a/kernel/signal.c b/kernel/signal.c index 19791930f12a..4a87ba91491f 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -4781,9 +4781,8 @@ static struct ctl_table signal_debug_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec - }, + } #endif - { } }; static int __init init_signal_sysctls(void) diff --git a/kernel/stackleak.c b/kernel/stackleak.c index 123844341148..6a9a65ace05a 100644 --- a/kernel/stackleak.c +++ b/kernel/stackleak.c @@ -53,8 +53,7 @@ static struct ctl_table stackleak_sysctls[] = { .proc_handler = stack_erasing_sysctl, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - {} + } }; static int __init stackleak_sysctls_init(void) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 2b9b0c8569ba..f1865c593666 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2041,9 +2041,8 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_INT_MAX, - }, + } #endif - { } }; static struct ctl_table vm_table[] = { @@ -2314,9 +2313,8 @@ static struct ctl_table vm_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = (void *)&mmap_rnd_compat_bits_min, .extra2 = (void *)&mmap_rnd_compat_bits_max, - }, + } #endif - { } }; int __init sysctl_init_bases(void) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index de385b365a7a..b7594ac53c99 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -259,8 +259,7 @@ static struct ctl_table timer_sysctl[] = { .proc_handler = timer_migration_handler, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - {} + } }; static int __init timer_sysctl_init(void) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 84ef42111f78..7a5a607b6cc2 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -8213,8 +8213,7 @@ static struct ctl_table ftrace_sysctls[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = ftrace_enable_sysctl, - }, - {} + } }; static int __init ftrace_sysctl_init(void) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index ac019cb21b18..baf48c16d2c5 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -2530,8 +2530,7 @@ static struct ctl_table user_event_sysctls[] = { .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = set_max_user_events_sysctl, - }, - {} + } }; static int __init trace_events_user_init(void) diff --git a/kernel/ucount.c b/kernel/ucount.c index 59bf6983f1cf..ce7ab90f7953 100644 --- a/kernel/ucount.c +++ b/kernel/ucount.c @@ -85,10 +85,9 @@ static struct ctl_table user_table[] = { #endif #ifdef CONFIG_FANOTIFY UCOUNT_ENTRY("max_fanotify_groups"), - UCOUNT_ENTRY("max_fanotify_marks"), + UCOUNT_ENTRY("max_fanotify_marks") #endif - { } -}; + }; #endif /* CONFIG_SYSCTL */ bool setup_userns_sysctls(struct user_namespace *ns) @@ -96,7 +95,7 @@ bool setup_userns_sysctls(struct user_namespace *ns) #ifdef CONFIG_SYSCTL struct ctl_table *tbl; - BUILD_BUG_ON(ARRAY_SIZE(user_table) != UCOUNT_COUNTS + 1); + BUILD_BUG_ON(ARRAY_SIZE(user_table) != UCOUNT_COUNTS); setup_sysctl_set(&ns->set, &set_root, set_is_seen); tbl = kmemdup(user_table, sizeof(user_table), GFP_KERNEL); if (tbl) { diff --git a/kernel/umh.c b/kernel/umh.c index 187a30ff8541..e1304be4823a 100644 --- a/kernel/umh.c +++ b/kernel/umh.c @@ -559,8 +559,7 @@ static struct ctl_table usermodehelper_table[] = { .maxlen = 2 * sizeof(unsigned long), .mode = 0600, .proc_handler = proc_cap_handler, - }, - { } + } }; static int __init init_umh_sysctls(void) diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c index 24527b155538..8776d45daf3a 100644 --- a/kernel/utsname_sysctl.c +++ b/kernel/utsname_sysctl.c @@ -119,8 +119,7 @@ static struct ctl_table uts_kern_table[] = { .mode = 0644, .proc_handler = proc_do_uts_string, .poll = &domainname_poll, - }, - {} + } }; #ifdef CONFIG_PROC_SYSCTL diff --git a/kernel/watchdog.c b/kernel/watchdog.c index dd5a343fadde..b79e6cfc008c 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -839,10 +839,9 @@ static struct ctl_table watchdog_sysctls[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, + } #endif /* CONFIG_SMP */ #endif - {} }; static void __init watchdog_sysctl_init(void) diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c index 83d37a163836..5a9018787d71 100644 --- a/lib/test_sysctl.c +++ b/lib/test_sysctl.c @@ -129,8 +129,7 @@ static struct ctl_table test_table[] = { .maxlen = SYSCTL_TEST_BITMAP_SIZE, .mode = 0644, .proc_handler = proc_do_large_bitmap, - }, - { } + } }; static void test_sysctl_calc_match_int_ok(void) @@ -184,8 +183,7 @@ static struct ctl_table test_table_unregister[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - }, - {} + } }; static int test_sysctl_run_unregister_nested(void) diff --git a/mm/compaction.c b/mm/compaction.c index ca09cdd72bf3..5013f5b7b44b 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -3126,8 +3126,7 @@ static struct ctl_table vm_compaction[] = { .proc_handler = proc_dointvec_minmax_warn_RT_change, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; static int __init kcompactd_init(void) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 7838b0c0b82b..5236805aee57 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4675,8 +4675,7 @@ static struct ctl_table hugetlb_table[] = { .maxlen = sizeof(unsigned long), .mode = 0644, .proc_handler = hugetlb_overcommit_handler, - }, - { } + } }; static void hugetlb_sysctl_init(void) diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 65885a06269b..b1a2a1089aa3 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -584,8 +584,7 @@ static struct ctl_table hugetlb_vmemmap_sysctls[] = { .maxlen = sizeof(vmemmap_optimize_enabled), .mode = 0644, .proc_handler = proc_dobool, - }, - { } + } }; static int __init hugetlb_vmemmap_init(void) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 46aef76d8e91..9bf5dd7a394e 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -142,8 +142,7 @@ static struct ctl_table memory_failure_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; static int __init memory_failure_sysctl_init(void) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 500cf2ef9faa..a05416f798e7 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -725,8 +725,7 @@ static struct ctl_table vm_oom_kill_table[] = { .maxlen = sizeof(sysctl_oom_dump_tasks), .mode = 0644, .proc_handler = proc_dointvec, - }, - {} + } }; #endif diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 9f997de8d12f..b75aaae6f77b 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2290,8 +2290,7 @@ static struct ctl_table vm_page_writeback_sysctls[] = { .maxlen = sizeof(laptop_mode), .mode = 0644, .proc_handler = proc_dointvec_jiffies, - }, - {} + } }; #endif diff --git a/net/appletalk/sysctl_net_atalk.c b/net/appletalk/sysctl_net_atalk.c index 30dcbbb8aeff..3975c1fad48c 100644 --- a/net/appletalk/sysctl_net_atalk.c +++ b/net/appletalk/sysctl_net_atalk.c @@ -39,8 +39,7 @@ static struct ctl_table atalk_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, - }, - { }, + } }; static struct ctl_table_header *atalk_table_header; diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c index 06afbc14b783..e7e81787e5de 100644 --- a/net/ax25/sysctl_net_ax25.c +++ b/net/ax25/sysctl_net_ax25.c @@ -139,10 +139,9 @@ static const struct ctl_table ax25_param_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = &min_ds_timeout, .extra2 = &max_ds_timeout - }, + } #endif - - { } /* that's all, folks! */ +/* that's all, folks! */ }; int ax25_register_dev_sysctl(ax25_dev *ax25_dev) diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c index ebbaef748a48..dfc37ac00980 100644 --- a/net/bridge/br_netfilter_hooks.c +++ b/net/bridge/br_netfilter_hooks.c @@ -1100,8 +1100,7 @@ static struct ctl_table brnf_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = brnf_sysctl_call_tables, - }, - { } + } }; static inline void br_netfilter_sysctl_default(struct brnf_net *brnf) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index aa5ad1cfc9b1..096d86013300 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -3716,7 +3716,7 @@ static int neigh_proc_base_reachable_time(struct ctl_table *ctl, int write, static struct neigh_sysctl_table { struct ctl_table_header *sysctl_header; - struct ctl_table neigh_vars[NEIGH_VAR_MAX + 1]; + struct ctl_table neigh_vars[NEIGH_VAR_MAX]; } neigh_sysctl_template __read_mostly = { .neigh_vars = { NEIGH_SYSCTL_ZERO_INTMAX_ENTRY(MCAST_PROBES, "mcast_solicit"), @@ -3766,9 +3766,8 @@ static struct neigh_sysctl_table { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_INT_MAX, .proc_handler = proc_dointvec_minmax, - }, - {}, - }, + } + } }; int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, @@ -3779,6 +3778,7 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, const char *dev_name_source; char neigh_path[ sizeof("net//neigh/") + IFNAMSIZ + IFNAMSIZ ]; char *p_name; + size_t neigh_vars_size; t = kmemdup(&neigh_sysctl_template, sizeof(*t), GFP_KERNEL_ACCOUNT); if (!t) @@ -3790,11 +3790,11 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, t->neigh_vars[i].extra2 = p; } + neigh_vars_size = ARRAY_SIZE(t->neigh_vars); if (dev) { dev_name_source = dev->name; /* Terminate the table early */ - memset(&t->neigh_vars[NEIGH_VAR_GC_INTERVAL], 0, - sizeof(t->neigh_vars[NEIGH_VAR_GC_INTERVAL])); + neigh_vars_size = NEIGH_VAR_BASE_REACHABLE_TIME_MS; } else { struct neigh_table *tbl = p->tbl; dev_name_source = "default"; @@ -3843,7 +3843,7 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, p_name, dev_name_source); t->sysctl_header = register_net_sysctl(neigh_parms_net(p), neigh_path, t->neigh_vars, - ARRAY_SIZE(t->neigh_vars)); + neigh_vars_size); if (!t->sysctl_header) goto free; diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index aa615f22507b..9acde2a110cd 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -652,8 +652,7 @@ static struct ctl_table net_core_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, - }, - { } + } }; static struct ctl_table netns_core_table[] = { @@ -681,8 +680,7 @@ static struct ctl_table netns_core_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, .proc_handler = proc_dou8vec_minmax, - }, - { } + } }; static int __init fb_tunnels_only_for_init_net_sysctl_setup(char *str) diff --git a/net/dccp/sysctl.c b/net/dccp/sysctl.c index 1140748858b0..7a5ccae4fc10 100644 --- a/net/dccp/sysctl.c +++ b/net/dccp/sysctl.c @@ -89,9 +89,7 @@ static struct ctl_table dccp_default_table[] = { .maxlen = sizeof(sysctl_dccp_sync_ratelimit), .mode = 0644, .proc_handler = proc_dointvec_ms_jiffies, - }, - - { } + } }; static struct ctl_table_header *dccp_table_header; diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c index 7b717434368c..3d9f2fbb8ec0 100644 --- a/net/ieee802154/6lowpan/reassembly.c +++ b/net/ieee802154/6lowpan/reassembly.c @@ -337,8 +337,7 @@ static struct ctl_table lowpan_frags_ns_ctl_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, - }, - { } + } }; /* secret interval has been deprecated */ @@ -350,8 +349,7 @@ static struct ctl_table lowpan_frags_ctl_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, - }, - { } + } }; static int __net_init lowpan_frags_ns_sysctl_register(struct net *net) diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 6360425dfcb2..eeb229b1ab78 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -2516,7 +2516,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write, static struct devinet_sysctl_table { struct ctl_table_header *sysctl_header; - struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX]; + struct ctl_table devinet_vars[IPV4_DEVCONF_MAX]; } devinet_sysctl = { .devinet_vars = { DEVINET_SYSCTL_COMPLEX_ENTRY(FORWARDING, "forwarding", @@ -2653,8 +2653,7 @@ static struct ctl_table ctl_forward_entry[] = { .proc_handler = devinet_sysctl_forward, .extra1 = &ipv4_devconf, .extra2 = &init_net, - }, - { }, + } }; #endif diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 3d7a82a900b5..2f8a8ac058da 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -579,8 +579,7 @@ static struct ctl_table ip4_frags_ns_ctl_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = &dist_min, - }, - { } + } }; /* secret interval has been deprecated */ @@ -592,8 +591,7 @@ static struct ctl_table ip4_frags_ctl_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, - }, - { } + } }; static int __net_init ip4_frags_ns_ctl_register(struct net *net) diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 883f4f1ee056..de0c0f9078b5 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -3551,8 +3551,7 @@ static struct ctl_table ipv4_route_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; static const char ipv4_route_flush_procname[] = "flush"; @@ -3585,8 +3584,7 @@ static struct ctl_table ipv4_route_netns_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { }, + } }; static __net_init int sysctl_route_net_init(struct net *net) diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 1821f403efc0..31306925a35d 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -577,8 +577,7 @@ static struct ctl_table ipv4_table[] = { .proc_handler = proc_douintvec_minmax, .extra1 = &sysctl_fib_sync_mem_min, .extra2 = &sysctl_fib_sync_mem_max, - }, - { } + } }; static struct ctl_table ipv4_net_table[] = { @@ -1469,8 +1468,7 @@ static struct ctl_table ipv4_net_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = &tcp_plb_max_cong_thresh, - }, - { } + } }; static __net_init int ipv4_sysctl_init_net(struct net *net) diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index ec1d68dbffc3..40610bb3a75a 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c @@ -160,8 +160,7 @@ static struct ctl_table xfrm4_policy_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; static __net_init int xfrm4_net_sysctl_init(struct net *net) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 68a2925c66a5..c72887ad79a3 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -7055,9 +7055,6 @@ static const struct ctl_table addrconf_sysctl[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, - }, - { - /* sentinel */ } }; @@ -7072,7 +7069,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name, if (!table) goto out; - for (i = 0; table[i].data; i++) { + for (i = 0; i < ARRAY_SIZE(addrconf_sysctl); i++) { table[i].data += (char *)p - (char *)&ipv6_devconf; /* If one of these is already set, then it is not safe to * overwrite either of them: this makes proc_dointvec_minmax diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 4159662fa214..b57e2c447969 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -1204,8 +1204,7 @@ static struct ctl_table ipv6_icmp_table_template[] = { .proc_handler = proc_dou8vec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { }, + } }; struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net) diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index dca8e0aabc51..18106042a3ed 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -61,8 +61,7 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = { .maxlen = sizeof(unsigned long), .mode = 0644, .proc_handler = proc_doulongvec_minmax, - }, - { } + } }; static int nf_ct_frag6_sysctl_register(struct net *net) diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 0688261202de..b7d7dd6e1f75 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -435,8 +435,7 @@ static struct ctl_table ip6_frags_ns_ctl_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, - }, - { } + } }; /* secret interval has been deprecated */ @@ -448,8 +447,7 @@ static struct ctl_table ip6_frags_ctl_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, - }, - { } + } }; static int __net_init ip6_frags_ns_sysctl_register(struct net *net) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index a35470576077..0b2a3afe620e 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -6417,8 +6417,7 @@ static struct ctl_table ipv6_route_table_template[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, - }, - { } + } }; struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net) diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c index 29f121f513a6..0d45a8a32752 100644 --- a/net/ipv6/sysctl_net_ipv6.c +++ b/net/ipv6/sysctl_net_ipv6.c @@ -212,8 +212,7 @@ static struct ctl_table ipv6_table_template[] = { .mode = 0644, .proc_handler = proc_doulongvec_minmax, .extra2 = &ioam6_id_wide_max, - }, - { } + } }; static struct ctl_table ipv6_rotable[] = { @@ -246,9 +245,8 @@ static struct ctl_table ipv6_rotable[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, + } #endif /* CONFIG_NETLABEL */ - { } }; static int __net_init ipv6_sysctl_net_init(struct net *net) diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 27efdb18a018..f3559ff33ff4 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c @@ -187,8 +187,7 @@ static struct ctl_table xfrm6_policy_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; static int __net_init xfrm6_net_sysctl_init(struct net *net) diff --git a/net/llc/sysctl_net_llc.c b/net/llc/sysctl_net_llc.c index 195296ba29f0..520fc52059b1 100644 --- a/net/llc/sysctl_net_llc.c +++ b/net/llc/sysctl_net_llc.c @@ -43,12 +43,10 @@ static struct ctl_table llc2_timeout_table[] = { .maxlen = sizeof(sysctl_llc2_rej_timeout), .mode = 0644, .proc_handler = proc_dointvec_jiffies, - }, - { }, + } }; static struct ctl_table llc_station_table[] = { - { }, }; static struct ctl_table_header *llc2_timeout_header; diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index 6f96aae76537..a78daceddf74 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c @@ -1391,8 +1391,7 @@ static const struct ctl_table mpls_dev_table[] = { .mode = 0644, .proc_handler = mpls_conf_proc, .data = MPLS_PERDEV_SYSCTL_OFFSET(input_enabled), - }, - { } + } }; static int mpls_platform_labels(struct ctl_table *table, int write, @@ -1425,8 +1424,7 @@ static const struct ctl_table mpls_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ONE, .extra2 = &ttl_max, - }, - { } + } }; static int mpls_dev_sysctl_register(struct net_device *dev, @@ -1444,7 +1442,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev, /* Table data contains only offsets relative to the base of * the mdev at this point, so make them absolute. */ - for (i = 0; i < ARRAY_SIZE(mpls_dev_table) - 1; i++) { + for (i = 0; i < ARRAY_SIZE(mpls_dev_table); i++) { table[i].data = (char *)mdev + (uintptr_t)table[i].data; table[i].extra1 = mdev; table[i].extra2 = net; @@ -2689,7 +2687,7 @@ static int mpls_net_init(struct net *net) /* Table data contains only offsets relative to the base of * the mdev at this point, so make them absolute. */ - for (i = 0; i < ARRAY_SIZE(mpls_table) - 1; i++) + for (i = 0; i < ARRAY_SIZE(mpls_table); i++) table[i].data = (char *)net + (uintptr_t)table[i].data; net->mpls.ctl = register_net_sysctl(net, "net/mpls", table, diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c index 42dfc834e5c6..27fb556d2273 100644 --- a/net/mptcp/ctrl.c +++ b/net/mptcp/ctrl.c @@ -127,8 +127,7 @@ static struct ctl_table mptcp_sysctl_table[] = { .proc_handler = proc_dou8vec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = &mptcp_pm_type_max - }, - {} + } }; static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index abbd30ee3ce0..fef7104ac33e 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -2258,9 +2258,8 @@ static struct ctl_table vs_vars[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, + } #endif - { } }; #endif diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c index 254eb3b61e15..e6297bb6922b 100644 --- a/net/netfilter/ipvs/ip_vs_lblc.c +++ b/net/netfilter/ipvs/ip_vs_lblc.c @@ -122,8 +122,7 @@ static struct ctl_table vs_vars_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, - }, - { } + } }; #endif diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c index 0e39a4fd421f..f3056767818b 100644 --- a/net/netfilter/ipvs/ip_vs_lblcr.c +++ b/net/netfilter/ipvs/ip_vs_lblcr.c @@ -293,8 +293,7 @@ static struct ctl_table vs_vars_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec_jiffies, - }, - { } + } }; #endif diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index a3b2029ef098..26efc6f28b34 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c @@ -616,11 +616,9 @@ enum nf_ct_sysctl_index { NF_SYSCTL_CT_LWTUNNEL, #endif - __NF_SYSCTL_CT_LAST_SYSCTL, + NF_SYSCTL_CT_LAST_SYSCTL, }; -#define NF_SYSCTL_CT_LAST_SYSCTL (__NF_SYSCTL_CT_LAST_SYSCTL + 1) - static struct ctl_table nf_ct_sysctl_table[] = { [NF_SYSCTL_CT_MAX] = { .procname = "nf_conntrack_max", @@ -955,9 +953,8 @@ static struct ctl_table nf_ct_sysctl_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = nf_hooks_lwtunnel_sysctl_handler, - }, + } #endif - {} }; static struct ctl_table nf_ct_netfilter_table[] = { @@ -967,8 +964,7 @@ static struct ctl_table nf_ct_netfilter_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; static void nf_conntrack_standalone_init_tcp_sysctl(struct net *net, diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c index 755f9cf570ce..686040b5e431 100644 --- a/net/netfilter/nf_log.c +++ b/net/netfilter/nf_log.c @@ -389,7 +389,7 @@ static const struct seq_operations nflog_seq_ops = { #ifdef CONFIG_SYSCTL static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3]; -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1]; +static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO]; static struct ctl_table_header *nf_log_sysctl_fhdr; static struct ctl_table nf_log_sysctl_ftable[] = { @@ -399,8 +399,7 @@ static struct ctl_table nf_log_sysctl_ftable[] = { .maxlen = sizeof(sysctl_nf_log_all_netns), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; static int nf_log_proc_dostring(struct ctl_table *table, int write, diff --git a/net/netrom/sysctl_net_netrom.c b/net/netrom/sysctl_net_netrom.c index c02b93fd9d4f..133dccdc2201 100644 --- a/net/netrom/sysctl_net_netrom.c +++ b/net/netrom/sysctl_net_netrom.c @@ -139,8 +139,7 @@ static struct ctl_table nr_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = &min_reset, .extra2 = &max_reset - }, - { } + } }; int __init nr_register_sysctl(void) diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c index 0fd0fcb00505..5385e980693e 100644 --- a/net/phonet/sysctl.c +++ b/net/phonet/sysctl.c @@ -80,8 +80,7 @@ static struct ctl_table phonet_table[] = { .maxlen = sizeof(local_port_range), .mode = 0644, .proc_handler = proc_local_port_range, - }, - { } + } }; int __init phonet_sysctl_init(void) diff --git a/net/rds/ib_sysctl.c b/net/rds/ib_sysctl.c index 102fd4a18df7..ee9ec39d9b30 100644 --- a/net/rds/ib_sysctl.c +++ b/net/rds/ib_sysctl.c @@ -102,8 +102,7 @@ static struct ctl_table rds_ib_sysctl_table[] = { .maxlen = sizeof(rds_ib_sysctl_flow_control), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; void rds_ib_sysctl_exit(void) diff --git a/net/rds/sysctl.c b/net/rds/sysctl.c index 5abd2730a1bc..17b325585bd9 100644 --- a/net/rds/sysctl.c +++ b/net/rds/sysctl.c @@ -88,8 +88,7 @@ static struct ctl_table rds_sysctl_rds_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { } + } }; void rds_sysctl_exit(void) diff --git a/net/rds/tcp.c b/net/rds/tcp.c index 2e90a2570d3b..e4abe20c4d2d 100644 --- a/net/rds/tcp.c +++ b/net/rds/tcp.c @@ -85,8 +85,7 @@ static struct ctl_table rds_tcp_sysctl_table[] = { .mode = 0644, .proc_handler = rds_tcp_skbuf_handler, .extra1 = &rds_tcp_min_rcvbuf, - }, - { } + } }; u32 rds_tcp_write_seq(struct rds_tcp_connection *tc) diff --git a/net/rose/sysctl_net_rose.c b/net/rose/sysctl_net_rose.c index 4f5a1e8b6c54..1a244a4d0221 100644 --- a/net/rose/sysctl_net_rose.c +++ b/net/rose/sysctl_net_rose.c @@ -111,8 +111,7 @@ static struct ctl_table rose_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = &min_window, .extra2 = &max_window - }, - { } + } }; void __init rose_register_sysctl(void) diff --git a/net/rxrpc/sysctl.c b/net/rxrpc/sysctl.c index 2b5824416036..583306fad3ef 100644 --- a/net/rxrpc/sysctl.c +++ b/net/rxrpc/sysctl.c @@ -124,8 +124,7 @@ static struct ctl_table rxrpc_sysctl_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = (void *)SYSCTL_ONE, .extra2 = (void *)&four, - }, - { } + } }; int __init rxrpc_sysctl_init(void) diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index 233f37f0fa28..93ea4decbb1b 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c @@ -79,9 +79,7 @@ static struct ctl_table sctp_table[] = { .maxlen = sizeof(sysctl_sctp_wmem), .mode = 0644, .proc_handler = proc_dointvec, - }, - - { /* sentinel */ } + } }; /* The following index defines are used in sctp_sysctl_net_register(). @@ -383,9 +381,7 @@ static struct ctl_table sctp_net_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = &pf_expose_max, - }, - - { /* sentinel */ } + } }; static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write, @@ -604,7 +600,7 @@ int sctp_sysctl_net_register(struct net *net) if (!table) return -ENOMEM; - for (i = 0; table[i].data; i++) + for (i = 0; i < ARRAY_SIZE(sctp_net_table); i++) table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; table[SCTP_RTO_MIN_IDX].extra2 = &net->sctp.rto_max; diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c index 9404123883c0..89af1f1dbb58 100644 --- a/net/smc/smc_sysctl.c +++ b/net/smc/smc_sysctl.c @@ -61,8 +61,7 @@ static struct ctl_table smc_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = &min_rcvbuf, - }, - { } + } }; int __net_init smc_sysctl_net_init(struct net *net) diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c index 61222addda7e..f4ac3376c25b 100644 --- a/net/sunrpc/sysctl.c +++ b/net/sunrpc/sysctl.c @@ -159,8 +159,7 @@ static struct ctl_table debug_table[] = { .maxlen = 256, .mode = 0444, .proc_handler = proc_do_xprt, - }, - { } + } }; void diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c index df7fb9c8b785..cbc75193bc70 100644 --- a/net/sunrpc/xprtrdma/svc_rdma.c +++ b/net/sunrpc/xprtrdma/svc_rdma.c @@ -208,8 +208,7 @@ static struct ctl_table svcrdma_parm_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = &zero, .extra2 = &zero, - }, - { }, + } }; static void svc_rdma_proc_cleanup(void) diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c index bf43e05044a3..75c789712cd9 100644 --- a/net/sunrpc/xprtrdma/transport.c +++ b/net/sunrpc/xprtrdma/transport.c @@ -136,8 +136,7 @@ static struct ctl_table xr_tunables_table[] = { .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { }, + } }; #endif diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 7c3d5ed708be..c0c59cd3b31c 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -154,8 +154,7 @@ static struct ctl_table xs_tunables_table[] = { .maxlen = sizeof(xs_tcp_fin_timeout), .mode = 0644, .proc_handler = proc_dointvec_jiffies, - }, - { }, + } }; /* diff --git a/net/tipc/sysctl.c b/net/tipc/sysctl.c index b9cbc3b359aa..e492d8c6c6f3 100644 --- a/net/tipc/sysctl.c +++ b/net/tipc/sysctl.c @@ -90,8 +90,7 @@ static struct ctl_table tipc_table[] = { .maxlen = sizeof(sysctl_tipc_bc_retruni), .mode = 0644, .proc_handler = proc_doulongvec_minmax, - }, - {} + } }; int tipc_register_sysctl(void) diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c index 92f3bc3cd704..716dee11d9e3 100644 --- a/net/unix/sysctl_net_unix.c +++ b/net/unix/sysctl_net_unix.c @@ -18,8 +18,7 @@ static struct ctl_table unix_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec - }, - { } + } }; int __net_init unix_sysctl_register(struct net *net) diff --git a/net/x25/sysctl_net_x25.c b/net/x25/sysctl_net_x25.c index 4d7c2ee41943..1e76f96ba77f 100644 --- a/net/x25/sysctl_net_x25.c +++ b/net/x25/sysctl_net_x25.c @@ -70,8 +70,7 @@ static struct ctl_table x25_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, - }, - { }, + } }; int __init x25_register_sysctl(void) diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c index d04b25a47575..e2b2c3437fbc 100644 --- a/net/xfrm/xfrm_sysctl.c +++ b/net/xfrm/xfrm_sysctl.c @@ -37,8 +37,7 @@ static struct ctl_table xfrm_table[] = { .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec - }, - {} + } }; int __net_init xfrm_sysctl_init(struct net *net) diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index b77344506cf3..67aa6e236e66 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -1778,9 +1778,7 @@ static struct ctl_table apparmor_sysctl_table[] = { .maxlen = sizeof(int), .mode = 0600, .proc_handler = apparmor_dointvec, - }, - - { } + } }; static int __init apparmor_init_sysctl(void) diff --git a/security/keys/sysctl.c b/security/keys/sysctl.c index fa305f74f658..7c944ef5a58c 100644 --- a/security/keys/sysctl.c +++ b/security/keys/sysctl.c @@ -54,9 +54,9 @@ struct ctl_table key_sysctls[] = { .proc_handler = proc_dointvec_minmax, .extra1 = (void *) SYSCTL_ZERO, .extra2 = (void *) SYSCTL_INT_MAX, - }, + } #ifdef CONFIG_PERSISTENT_KEYRINGS - { + , { .procname = "persistent_keyring_expiry", .data = &persistent_keyring_expiry, .maxlen = sizeof(unsigned), @@ -64,9 +64,8 @@ struct ctl_table key_sysctls[] = { .proc_handler = proc_dointvec_minmax, .extra1 = (void *) SYSCTL_ZERO, .extra2 = (void *) SYSCTL_INT_MAX, - }, + } #endif - { } }; static int __init init_security_keys_sysctls(void) diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c index 6f2cc827df41..28b411adbf0b 100644 --- a/security/loadpin/loadpin.c +++ b/security/loadpin/loadpin.c @@ -61,8 +61,7 @@ static struct ctl_table loadpin_sysctl_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_ONE, - }, - { } + } }; static void set_sysctl(bool is_writable) diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c index 7b8164a4b504..2d2700af9f6b 100644 --- a/security/yama/yama_lsm.c +++ b/security/yama/yama_lsm.c @@ -456,8 +456,7 @@ static struct ctl_table yama_sysctl_table[] = { .proc_handler = yama_dointvec_minmax, .extra1 = SYSCTL_ZERO, .extra2 = &max_scope, - }, - { } + } }; static void __init yama_init_sysctl(void) { From patchwork Wed Jun 21 09:48:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13287024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB321EB64D7 for ; Wed, 21 Jun 2023 09:48:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232052AbjFUJsa (ORCPT ); Wed, 21 Jun 2023 05:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbjFUJs2 (ORCPT ); Wed, 21 Jun 2023 05:48:28 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52C54CA for ; Wed, 21 Jun 2023 02:48:27 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230621094825euoutp029e94dc9fd7157e9f525bf02c75101bed~qo50mTTsO1913319133euoutp02r for ; Wed, 21 Jun 2023 09:48:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230621094825euoutp029e94dc9fd7157e9f525bf02c75101bed~qo50mTTsO1913319133euoutp02r DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687340905; bh=oMMsCBVAUEOP5xD/Z+INlpRHDKkS9VhizNcPTCBp948=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Vetou21bFg5GhYx6PfjQwLVmbOJvNqxiglRJajEOyDJl328PDRlTZgMU10ScV/Ve9 R7toOsNaiRniJlf+C6JndiyvQbaNgOhyjrVngFt5Yd8CHnbn6iQcw/0WoQeyFC9AZ8 4cTFXm2TwXChIXpPGJAvnyY8O1PNaf9P509R7LUc= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230621094825eucas1p14a29d1829162515c73fa3108d1609c9c~qo50gGD1M1194511945eucas1p1C; Wed, 21 Jun 2023 09:48:25 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id A2.47.11320.967C2946; Wed, 21 Jun 2023 10:48:25 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230621094825eucas1p2d37372e5bd2377bfe953e6e4f7ff0363~qo50D7ZHB2114621146eucas1p2v; Wed, 21 Jun 2023 09:48:25 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230621094825eusmtrp1e66aac9eac34c360ca66a25014801dd3~qo50DdT361292612926eusmtrp1D; Wed, 21 Jun 2023 09:48:25 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-4b-6492c7690a9d Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D7.06.10549.867C2946; Wed, 21 Jun 2023 10:48:25 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230621094824eusmtip151933cc23390220a581d0f3fc016689d~qo5z2JBAA1131511315eusmtip18; Wed, 21 Jun 2023 09:48:24 +0000 (GMT) Received: from localhost (106.210.248.248) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jun 2023 10:48:24 +0100 From: Joel Granados To: , Kees Cook , Iurii Zaikin CC: Joel Granados , , Subject: [PATCH 10/11] sysctl: Remove nr_entries from new_links Date: Wed, 21 Jun 2023 11:48:01 +0200 Message-ID: <20230621094817.433842-2-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621094817.433842-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.248] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkleLIzCtJLcpLzFFi42LZduznOd3M45NSDBY0KVuc6c612LP3JIvF 5V1z2CxuTHjKaLFsp58Dq8fshossHgs2lXpsWtXJ5vF5k1wASxSXTUpqTmZZapG+XQJXxqcV N1gLTvNX/Pxyl6mB8SVPFyMnh4SAicSHGUeYuxi5OIQEVjBKrNu+kQXC+cIo8eP0YSYI5zOj xMqPKxhhWh78Oc8OYgsJLGeUWLVeCcIGKprYIw/RsJVRYueSXywgCTYBHYnzb+4wg9giAvES s9dsBxvELJArMWv5ErC4sIC9xMPbF1hBbBYBVYm9W/aBLeAVsJE4dO4P1GJ5ibbr08FsTgFb idcr+pkhagQlTs58wgIxU16ieetsZghbQuLgixfMEL3KEtf3LWaDsGslTm25BfaZhMAFDonn jztYIBIuEh/mbWeCsIUlXh3fwg5hy0icntzDAtEwmVFi/78P7BDOakaJZY1foTqsJVquPAFK cADZjhKXHgpDmHwSN94KQhzEJzFp23RmiDCvREeb0ARGlVlIXpiF5IVZSF5YwMi8ilE8tbQ4 Nz212CgvtVyvODG3uDQvXS85P3cTIzCVnP53/MsOxuWvPuodYmTiYDzEKMHBrCTCK7tpUooQ b0piZVVqUX58UWlOavEhRmkOFiVxXm3bk8lCAumJJanZqakFqUUwWSYOTqkGJqUrIe+Zp0iG 8P23do9P9K5tY7b/Oftw3gvuz/Oz+rN37pLMmCe0bPZeG85lurtf3Tt4/Kr29ydnPyZbzFxb vfTqrD/Jc37dcb1696T7hzqX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uUW1unAFp2/H o/yyVdI3f10I69G+vTbiwqnerH8nI4Tifh0Oe/w25r7fEYVw7zJP2RjhjRv5/VnVGe+miNgU Zq843Ll64tvgxQYzC1Z919eb92a/yc4XvhX3wlvybaJ4ky8+VD1pGSkUzbgxZdf8N7xXr/a8 N+T8Ge/m5TlL6o3cUXHbjLK2pV+CuPmaTPZKP5Y6uG7eUufXz4MvBh78NuV5zfwjy3o29JWU 3jh6WImlOCPRUIu5qDgRAJxPrt4+AwAA X-CMS-MailID: 20230621094825eucas1p2d37372e5bd2377bfe953e6e4f7ff0363 X-Msg-Generator: CA X-RootMTR: 20230621094825eucas1p2d37372e5bd2377bfe953e6e4f7ff0363 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230621094825eucas1p2d37372e5bd2377bfe953e6e4f7ff0363 References: <20230621091000.424843-1-j.granados@samsung.com> <20230621094817.433842-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Now that the number of entries is set in the ctl_header struct, there is no need to calculate that number. Replace the variable and logic that does the calculation whith the ctl_header value. Signed-off-by: Joel Granados --- fs/proc/proc_sysctl.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 1debd01209fc..9e7e17dd6162 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1166,18 +1166,16 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ struct ctl_table_header *links; struct ctl_node *node; char *link_name; - int nr_entries, name_bytes; + int name_bytes; name_bytes = 0; - nr_entries = 0; list_for_each_table_entry(entry, head) { - nr_entries++; name_bytes += strlen(entry->procname) + 1; } links = kzalloc(sizeof(struct ctl_table_header) + - sizeof(struct ctl_node)*nr_entries + - sizeof(struct ctl_table)*(nr_entries + 1) + + sizeof(struct ctl_node)*head->ctl_table_size + + sizeof(struct ctl_table)*(head->ctl_table_size + 1) + name_bytes, GFP_KERNEL); @@ -1185,8 +1183,8 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ return NULL; node = (struct ctl_node *)(links + 1); - link_table = (struct ctl_table *)(node + nr_entries); - link_name = (char *)&link_table[nr_entries + 1]; + link_table = (struct ctl_table *)(node + head->ctl_table_size); + link_name = (char *)&link_table[head->ctl_table_size + 1]; link = link_table; list_for_each_table_entry(entry, head) { @@ -1200,7 +1198,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ } init_header(links, dir->header.root, dir->header.set, node, link_table, head->ctl_table_size); - links->nreg = nr_entries; + links->nreg = head->ctl_table_size; return links; } From patchwork Wed Jun 21 09:48:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13287025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 883D3EB64D8 for ; Wed, 21 Jun 2023 09:48:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232080AbjFUJse (ORCPT ); Wed, 21 Jun 2023 05:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbjFUJsc (ORCPT ); Wed, 21 Jun 2023 05:48:32 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B5A3EA for ; Wed, 21 Jun 2023 02:48:30 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230621094828euoutp02560be9b64b0ea63a3672c246ffe8ec64~qo53f0lMS1958919589euoutp02w for ; Wed, 21 Jun 2023 09:48:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230621094828euoutp02560be9b64b0ea63a3672c246ffe8ec64~qo53f0lMS1958919589euoutp02w DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687340908; bh=dbte9P3LahOTAa8vkLg+Y6+keP5p3Zx/hRuNObHLKVE=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=BcGKGimtwHugbx0GY6b12ut2JhRSDV5A7THYwSZ3iL8kfg1IAl93KPpRaEgpNplkS YdBde4XCVHCUZIkxmpYwFJMYF3DG96cLoC8hnIHeuqAoL8Jd9a9HTcXij5/eYL5U6D o/Wciu0IPzA162vaQIEjdwTYjudVFMVN0dXRtSTY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230621094828eucas1p2380095a1edd4d673c43affc5299fbab4~qo53OTIyo1478514785eucas1p2T; Wed, 21 Jun 2023 09:48:28 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id ED.FA.42423.C67C2946; Wed, 21 Jun 2023 10:48:28 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230621094828eucas1p22b0b45adc25f881fe00a20d96d495d95~qo523PHWH0198801988eucas1p2I; Wed, 21 Jun 2023 09:48:28 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230621094828eusmtrp11d40c79030349f6083303a91ed30fe41~qo522rCpK1249712497eusmtrp1f; Wed, 21 Jun 2023 09:48:28 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-e6-6492c76c5a13 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 4B.06.10549.C67C2946; Wed, 21 Jun 2023 10:48:28 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230621094828eusmtip181b98584f1c8352c62496699c33e6758~qo52sbIGp1838018380eusmtip1d; Wed, 21 Jun 2023 09:48:28 +0000 (GMT) Received: from localhost (106.210.248.248) by CAMSVWEXC02.scsc.local (106.1.227.72) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jun 2023 10:48:27 +0100 From: Joel Granados To: , Kees Cook , Iurii Zaikin CC: Joel Granados , , Subject: [PATCH 11/11] sysctl: rm "child" from __register_sysctl_table doc Date: Wed, 21 Jun 2023 11:48:02 +0200 Message-ID: <20230621094817.433842-3-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621094817.433842-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.248] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (106.1.227.71) To CAMSVWEXC02.scsc.local (106.1.227.72) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPIsWRmVeSWpSXmKPExsWy7djP87o5xyelGKz6K2dxpjvXYs/ekywW l3fNYbO4MeEpo8WynX4OrB6zGy6yeCzYVOqxaVUnm8fnTXIBLFFcNimpOZllqUX6dglcGb1L rzAWrBKruPdnOlMD41nBLkZODgkBE4lN926ydTFycQgJrGCUWH/6NiOE84VR4vTRFnaQKiGB z4wSyxd5wXSca1jHDlG0nFFixaJpzBAOUNHmfRMY4WbNPb2BGaSFTUBH4vybO2C2iEC8xOw1 2xlBbGaBXIlZy5eAxYUFvCQu/VjNBmKzCKhKzF15A8jm4OAVsJHYcj0PYrO8RNv16WCtnAK2 Eq9X9IO18goISpyc+YQFYqS8RPPW2cwQtoTEwRcvmCF6lSWu71vMBmEnS7T8+csEYV/hkDj+ uwRklYSAi8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l7Sywg3gFBCVOznzCAjFeXqJ562xm CFtC4uCLF8wQc5Qlru9bzAZhJ0tM2vOLcQKjyCwk7bOQtM9C0r6AkXkVo0hqaXFuem6xoV5x Ym5xaV66XnJ+7iZGYKRtO/Zz8w7Gea8+6h1iZOJgPMQowcGsJMIru2lSihBvSmJlVWpRfnxR aU5q8SFGU6A3JzJLiSbnA2M9ryTe0MzA1NDEzNLA1NLMWEmc17OgI1FIID2xJDU7NbUgtQim j4mDU6qBqcO2j2Ou7TmuRbduLfk8wT+muOpZCBfTWU1NM3vlFZL/1/gIhu+b4/T0ejqPq9qD tQadDSecrK6cVdO28XLbNn3O6iUCeQ3pRiLKlYn3L4SwvfnJfPv73E/qpft/dnJ22xy00gtk ZTzFqXJLbtXSL6kBvv1PQnq8Hh02kpk236I7pM38glDf8hndqxe3TJ8eu5S/VyNK2ecD61Jl xpr4DV4BKYb3Ft3s+cr7Zd8dmcr5+scK3Nbkb9q/4LPvuZmu3lPfv9i9Xq6vy10r9LWer5hB VNiiWW2JtUHHDddEiRS99ZR50XOgv+XYnj5fS4bYNs/S72xfqj48CPZ6YZxXIyj/kXnKibuh nmHmh/8osRRnJBpqMRcVJwIALybYTz0DAAA= X-CMS-MailID: 20230621094828eucas1p22b0b45adc25f881fe00a20d96d495d95 X-Msg-Generator: CA X-RootMTR: 20230621094828eucas1p22b0b45adc25f881fe00a20d96d495d95 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230621094828eucas1p22b0b45adc25f881fe00a20d96d495d95 References: <20230621091000.424843-1-j.granados@samsung.com> <20230621094817.433842-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Remove "child" from code documentation in proc_sysctl.c. Child was replaced with a explicit size value in ctl header and there is no need to have it around in the documentation. Signed-off-by: Joel Granados --- fs/proc/proc_sysctl.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 9e7e17dd6162..8dbc5b2316a5 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1306,27 +1306,22 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path) * __register_sysctl_table - register a leaf sysctl table * @set: Sysctl tree to register on * @path: The path to the directory the sysctl table is in. - * @table: the top-level table structure without any child. This table - * should not be free'd after registration. So it should not be - * used on stack. It can either be a global or dynamically allocated - * by the caller and free'd later after sysctl unregistration. + * + * @table: the top-level table structure. This table should not be free'd + * after registration. So it should not be used on stack. It can either + * be a global or dynamically allocated by the caller and free'd later + * after sysctl unregistration. * * Register a sysctl table hierarchy. @table should be a filled in ctl_table - * array. A completely 0 filled entry terminates the table. + * array. * * The members of the &struct ctl_table structure are used as follows: - * * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not * enter a sysctl file - * - * data - a pointer to data for use by proc_handler - * - * maxlen - the maximum size in bytes of the data - * - * mode - the file permissions for the /proc/sys file - * - * child - must be %NULL. - * + * data - a pointer to data for use by proc_handler + * maxlen - the maximum size in bytes of the data + * mode - the file permissions for the /proc/sys file + * type - Defines the target type (described in struct definition) * proc_handler - the text handler routine (described below) * * extra1, extra2 - extra pointers usable by the proc handler routines @@ -1334,8 +1329,7 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path) * [0] https://lkml.kernel.org/87zgpte9o4.fsf@email.froward.int.ebiederm.org * * Leaf nodes in the sysctl tree will be represented by a single file - * under /proc; non-leaf nodes (where child is not NULL) are not allowed, - * sysctl_check_table() verifies this. + * under /proc; non-leaf nodes are not allowed. * * There must be a proc_handler routine for any terminal nodes. * Several default handlers are available to cover common cases -