From patchwork Wed Jul 26 14:06:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13328105 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 794C8A927 for ; Wed, 26 Jul 2023 14:07:01 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 678A92D4B for ; Wed, 26 Jul 2023 07:06:59 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230726140658euoutp016267ca1b24497b90a7728685ac19270f~1cAjDqrbj2885428854euoutp01j for ; Wed, 26 Jul 2023 14:06:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230726140658euoutp016267ca1b24497b90a7728685ac19270f~1cAjDqrbj2885428854euoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690380418; bh=uk1lVMRV3vGO5Qj9WjqlASY9SYqLs0/HcEQUQxX19Rw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EKAmgduM7qzb2gIDDmckuuVzf25+OAdO4ayEbPOT+yir3pA0BER3a2MX63wSH3eWW sTNl5PPj29iH8ZzwTXL49RvffUsKQElqVXaniGzXlxgnx2bmdqJoyALh2F8SDKbDF3 jtpD0M5ya253gi1NtX8OVUVfiSY8PkAwyBN2gLRI= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230726140657eucas1p15c9fb223083bdcc0cb2e453039297ba1~1cAicl1Jr2260622606eucas1p1v; Wed, 26 Jul 2023 14:06:57 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 23.F6.11320.18821C46; Wed, 26 Jul 2023 15:06:57 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230726140656eucas1p26cd9da21663d25b51dda75258aaa3b55~1cAh7604I0631806318eucas1p2d; Wed, 26 Jul 2023 14:06:56 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230726140656eusmtrp27aa5978c675164d2f45044b932f3fabb~1cAh7N5a32014720147eusmtrp2X; Wed, 26 Jul 2023 14:06:56 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-2c-64c12881da24 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 41.57.14344.08821C46; Wed, 26 Jul 2023 15:06:56 +0100 (BST) Received: from localhost (unknown [106.210.248.223]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230726140656eusmtip1bd0558d02c1d90789e02183fa3849da1~1cAhrKSyu0800208002eusmtip1X; Wed, 26 Jul 2023 14:06:56 +0000 (GMT) From: Joel Granados To: mcgrof@kernel.org, Kees Cook , Iurii Zaikin , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: willy@infradead.org, josh@joshtriplett.org, Joel Granados , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 05/14] sysctl: Add a size arg to __register_sysctl_table Date: Wed, 26 Jul 2023 16:06:25 +0200 Message-Id: <20230726140635.2059334-6-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230726140635.2059334-1-j.granados@samsung.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id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Mh7n9D5tdBiW1ble9X6x2czT/0sv27l uijshOeCjLL7W4oEoieJq6qELuac058fpCagzW9mGf/vhu8q9g37KzpSZpqa17/Q5HoR0ssc eWCOQ8Zla505xdsWlc1lyuh/JlL6xdlxcv2JacG3TyqxFGckGmoxFxUnAgDdHjk0PwMAAA== X-CMS-MailID: 20230726140656eucas1p26cd9da21663d25b51dda75258aaa3b55 X-Msg-Generator: CA X-RootMTR: 20230726140656eucas1p26cd9da21663d25b51dda75258aaa3b55 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230726140656eucas1p26cd9da21663d25b51dda75258aaa3b55 References: <20230726140635.2059334-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This is part of the effort to remove the sentinel element in the ctl_table arrays. We add a table_size argument to __register_sysctl_table and adjust callers, all of which pass ctl_table pointers and need an explicit call to ARRAY_SIZE. The new table_size argument does not yet have any effect in the init_header call which is still dependent on the sentinel's presence. table_size *does* however drive the `kzalloc` allocation in __register_sysctl_table with no adverse effects as the allocated memory is either one element greater than the calculated ctl_table array (for the calls in ipc_sysctl.c, mq_sysctl.c and ucount.c) or the exact size of the calculated ctl_table array (for the call from sysctl_net.c and register_sysctl). This approach will allows us to "just" remove the sentinel without further changes to __register_sysctl_table as table_size will represent the exact size for all the callers at that point. 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 fa1438f1a355..8d04f01a89c1 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 Jul 26 14:06:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13328106 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD41E21D39 for ; Wed, 26 Jul 2023 14:07:06 +0000 (UTC) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DECA52D4B for ; Wed, 26 Jul 2023 07:07:01 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230726140700euoutp02500c6354b9fbe6d2894b0289b5edd828~1cAlcp9v-1608016080euoutp02E for ; Wed, 26 Jul 2023 14:07:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230726140700euoutp02500c6354b9fbe6d2894b0289b5edd828~1cAlcp9v-1608016080euoutp02E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690380420; bh=l0L9NM3baww7PVLEXdKvMFx2kXphPK9z7x02k5Zm7P0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GaZxoBUp0wCR4r6ry2u8S1nlpqI/0qhL2+zbvIjyGJR+l3toEsBx2lbuszRlVdZuN a7u5sBbS7gNqEgWKaE7fYAt2x2czxScQ+8Qw80/uY3XSteIXks2Mt84KNlWh0SSdmw dolELmm/P+GgX1xIbOffGwpWjeDTt3xHs9OVnbUA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230726140659eucas1p1999364497c41da742f5a590178eed9e0~1cAkx_DyJ2259322593eucas1p1k; Wed, 26 Jul 2023 14:06:59 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 27.F6.11320.38821C46; Wed, 26 Jul 2023 15:06:59 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230726140659eucas1p2c3cd9f57dd13c71ddeb78d2480587e72~1cAkRDtvl0079900799eucas1p2w; Wed, 26 Jul 2023 14:06:59 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230726140659eusmtrp23f74b881de77cedcdbb407cdb337d489~1cAkQSJFE2014720147eusmtrp2e; Wed, 26 Jul 2023 14:06:59 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-36-64c12883b123 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 73.57.14344.38821C46; Wed, 26 Jul 2023 15:06:59 +0100 (BST) Received: from localhost (unknown [106.210.248.223]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230726140659eusmtip26b7013f9921e15f7a7bc21417164a14d~1cAj_0AFI2113521135eusmtip2C; Wed, 26 Jul 2023 14:06:59 +0000 (GMT) From: Joel Granados To: mcgrof@kernel.org, Catalin Marinas , Will Deacon , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Kees Cook , Iurii Zaikin , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: willy@infradead.org, josh@joshtriplett.org, Joel Granados , Christian Borntraeger , Sven Schnelle , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 06/14] sysctl: Add size to register_sysctl Date: Wed, 26 Jul 2023 16:06:26 +0200 Message-Id: <20230726140635.2059334-7-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230726140635.2059334-1-j.granados@samsung.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOKsWRmVeSWpSXmKPExsWy7djPc7rNGgdTDA6v1bfYePolm8Xjv4fY LN4v62G0mHO+hcXi6bFH7BYXZn1jtXg9bxWjxdL9Dxkt/i/ItzjTnWtxYVsfq8Wmx9dYLfbs PclicXnXHDaLCQubmS1uTHjKaHFsgZjFt9NvGC2WrV/LbtFyx9Ti9w+ggmU7/RzEPNbMW8Po MbvhIovHlpU3mTwWbCr12LxCy+PWa1uPTas62TwmLDrA6LF5Sb3H+31X2Tz6tqxi9Pi8SS6A J4rLJiU1J7MstUjfLoErY/qtDWwFHWYVz9efZmlgfK7TxcjJISFgIrH10EHWLkYuDiGBFYwS c/YtY4NwvjBKHNy+kQnC+cwosfvdPXaYlhenW6ESyxklnqzpYQZJCAm8ZJS4c9sGxGYT0JE4 /+YOM0iRiMAmZom73xaCOcwCZ5kkjq+fDDZKWMBKYtvfCUwgNouAqsTrvpdgk3gFbCWOrH3G ArFOXqLt+nRGEJtTwE5i5drvrBA1ghInZz4Bq2EGqmneOpsZov4ap8SE6WpdjBxAtovEtPPF EGFhiVfHt0B9ICPxf+d8sA8kBCYzSuz/94EdwlnNKLGs8SsTRJW1RMuVJ+wgg5gFNCXW79K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LnWxQZR85xRYmrvdBaQBJuAjsT5N3eYQRIiAvuYJaZ+OsUKkmAWuM4kMfltEIgtLGAlse3v BCYQm0VAVeJ130tmEJtXwFbiyNpnLBAb5CXark9nBLE5BewkVq79DjZHCKimZ+pTdoh6QYmT M5+wQMyXl2jeOpt5AqPALCSpWUhSCxiZVjGKpJYW56bnFhvpFSfmFpfmpesl5+duYgTG97Zj P7fsYFz56qPeIUYmDsZDjBIczEoivIYx+1KEeFMSK6tSi/Lji0pzUosPMZoC3T2RWUo0OR+Y YPJK4g3NDEwNTcwsDUwtzYyVxHk9CzoShQTSE0tSs1NTC1KLYPqYODilGpiinPWzzRwXTTw/ 73dG9sPzC6ct69rAHnGEZdtlV56fL45f6pKYN5lx5+ot1/zTbYu2vLc2a714qPL//5/T/63k 328/LenmJ58lepr/3oquurK1S2rzuVvhznpzrF40eXZ6NWzTs5NUznmd91vN+/QOhaIN94XX HLl47v6qp5nnYh6kBx5X+C80b6qlwXLps0lJyaFzD/p8atlwTjAq+T1HT0P6ph3t3qlflD+d v/mAIcolOP1B8JTJ784/uZR/4sBlG0a/tZMZVmjp6jPXzm2s+l2UtfHxtQoLz/UuK1hmNswN aF1/YcYEplgW24aVQnc1N6suX//1qqZmneq015HHbZbIzmN77PCGm/X2/cTgqUosxRmJhlrM RcWJAB+R3qZ4AwAA X-CMS-MailID: 20230726140659eucas1p2c3cd9f57dd13c71ddeb78d2480587e72 X-Msg-Generator: CA X-RootMTR: 20230726140659eucas1p2c3cd9f57dd13c71ddeb78d2480587e72 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230726140659eucas1p2c3cd9f57dd13c71ddeb78d2480587e72 References: <20230726140635.2059334-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org In order to remove the end element from the ctl_table struct arrays, we replace the register_syctl function with a macro that will add the ARRAY_SIZE to the new register_sysctl_sz function. In this way the callers that are already using an array of ctl_table structs do not have to change. We *do* change the callers that pass the ctl_table array as a pointer. Signed-off-by: Joel Granados --- arch/arm64/kernel/armv8_deprecated.c | 2 +- arch/s390/appldata/appldata_base.c | 2 +- fs/proc/proc_sysctl.c | 30 +++++++++++++++------------- include/linux/sysctl.h | 10 ++++++++-- kernel/ucount.c | 2 +- net/sysctl_net.c | 2 +- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c index 1febd412b4d2..e459cfd33711 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_sz("abi", sysctl, 1); } } diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c index bbefe5e86bdf..3b0994625652 100644 --- a/arch/s390/appldata/appldata_base.c +++ b/arch/s390/appldata/appldata_base.c @@ -365,7 +365,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_sz(appldata_proc_name, ops->ctl_table, 1); if (!ops->sysctl_header) goto out; return 0; diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 8d04f01a89c1..c04293911e7e 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -43,7 +43,7 @@ static 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_sz(path, sysctl_mount_point, 0); } EXPORT_SYMBOL(register_sysctl_mount_point); @@ -1398,7 +1398,7 @@ struct ctl_table_header *__register_sysctl_table( } /** - * register_sysctl - register a sysctl table + * register_sysctl_sz - register a sysctl table * @path: The path to the directory the sysctl table is in. If the path * doesn't exist we will create it for you. * @table: the table structure. The calller must ensure the life of the @table @@ -1408,25 +1408,20 @@ struct ctl_table_header *__register_sysctl_table( * to call unregister_sysctl_table() and can instead use something like * register_sysctl_init() which does not care for the result of the syctl * registration. + * @table_size: The number of elements in table. * * Register a sysctl table. @table should be a filled in ctl_table * array. A completely 0 filled entry terminates the 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_sz(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); +EXPORT_SYMBOL(register_sysctl_sz); /** * __register_sysctl_init() - register sysctl table to path @@ -1451,10 +1446,17 @@ 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_sz(path, table, count); if (unlikely(!hdr)) { - pr_err("failed when register_sysctl %s to %s\n", table_name, path); + pr_err("failed when register_sysctl_sz %s to %s\n", table_name, path); return; } kmemleak_not_leak(hdr); diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 0495c858989f..b1168ae281c9 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -215,6 +215,9 @@ struct ctl_path { const char *procname; }; +#define register_sysctl(path, table) \ + register_sysctl_sz(path, table, ARRAY_SIZE(table)) + #ifdef CONFIG_SYSCTL void proc_sys_poll_notify(struct ctl_table_poll *poll); @@ -227,7 +230,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_sz(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 +266,9 @@ 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_sz(const char *path, + struct ctl_table *table, + size_t table_size) { return NULL; } diff --git a/kernel/ucount.c b/kernel/ucount.c index 2b80264bb79f..4aa6166cb856 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_sz("user", empty, 0); kmemleak_ignore(user_header); BUG_ON(!user_header); BUG_ON(!setup_userns_sysctls(&init_user_ns)); diff --git a/net/sysctl_net.c b/net/sysctl_net.c index 8ee4b74bc009..d9cbbb51b143 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_sz("net", empty, 0); if (!net_header) goto out; ret = register_pernet_subsys(&sysctl_pernet_ops); From patchwork Wed Jul 26 14:06:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13328107 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EC8421D39 for ; Wed, 26 Jul 2023 14:07:09 +0000 (UTC) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6EFE270F for ; Wed, 26 Jul 2023 07:07:04 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230726140703euoutp025a8762fc6873bd0c2de017a5a8406752~1cAoZK64Y1608116081euoutp02H for ; Wed, 26 Jul 2023 14:07:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230726140703euoutp025a8762fc6873bd0c2de017a5a8406752~1cAoZK64Y1608116081euoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690380423; bh=cMTBe7sf9ly5UubZ6NjClaUkcmfE+QKlrsv2BzOiDwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vvd+n4h7geZSsoeldQAkwhPqgw3HCYur0tmqfRaEQJ9xFOCRtTd7tHFUqTzmwdoFe SL+ejs5ZIgioncLKDt5lYO7DpE8uFT6Yl3U6HBeSUEfJ81Skd/vqEjPm/kxRxGmcxx jTvBskRbLnKHuRmqJjxeP6cCb5QTSG74CGXq9e2s= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230726140702eucas1p14c105669e63c6e3cfd4d0cb7320154a4~1cAni14LW2259722597eucas1p1v; Wed, 26 Jul 2023 14:07:02 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 8A.F6.11320.68821C46; Wed, 26 Jul 2023 15:07:02 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230726140702eucas1p20c75fc21d675ea267dd2ad4ebd6e60b4~1cAnKGUn40231902319eucas1p2Q; Wed, 26 Jul 2023 14:07:02 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230726140702eusmtrp215065597cf1bd38d1f098d84ab275544~1cAnJbZxl2063520635eusmtrp2E; Wed, 26 Jul 2023 14:07:02 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-41-64c12886d5f1 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A6.57.14344.68821C46; Wed, 26 Jul 2023 15:07:02 +0100 (BST) Received: from localhost (unknown [106.210.248.223]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230726140702eusmtip2423b6f9945d4ce69ab1ed5e9d0188f6a~1cAm7AxCU2279822798eusmtip2E; Wed, 26 Jul 2023 14:07:02 +0000 (GMT) From: Joel Granados To: mcgrof@kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: willy@infradead.org, keescook@chromium.org, josh@joshtriplett.org, Joel Granados , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/14] sysctl: Add size to register_net_sysctl function Date: Wed, 26 Jul 2023 16:06:28 +0200 Message-Id: <20230726140635.2059334-9-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230726140635.2059334-1-j.granados@samsung.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Sub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a9cC7n2zv0SGmfvuseU2 aV/o43v+3tm9x05NZQ2t2GX7p6t8q7TI/Q+ZGpOCV+a6BETc+mRcnSbsIHD9/p3DTScLpTeG /czd915jsWjBrVqtnZm1WjozFrHL3PhpUn33sBJLcUaioRZzUXEiAAubwa41AwAA X-CMS-MailID: 20230726140702eucas1p20c75fc21d675ea267dd2ad4ebd6e60b4 X-Msg-Generator: CA X-RootMTR: 20230726140702eucas1p20c75fc21d675ea267dd2ad4ebd6e60b4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230726140702eucas1p20c75fc21d675ea267dd2ad4ebd6e60b4 References: <20230726140635.2059334-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This is part of the effort to remove the sentinel (last empty) element from the ctl_table arrays. We create a new function register_net_sysctl_sz with an extra size argument. A macro replaces the existing register_net_sysctl. For now, the size passed by the macro is SIZE_MAX (will eventually be ARRAY_SIZE) to avoid compilation warnings from pointers to ctl_table arrays instead of the arrays themselves. Care is also taken to add table_size to the stopping criteria in such a way that when we remove the empty sentinel element, it will continue stopping in the last element of the ctl_table array Signed-off-by: Joel Granados --- include/net/net_namespace.h | 10 ++++++---- net/sysctl_net.c | 22 +++++++++++++--------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 78beaa765c73..e4e5fe75a281 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -469,15 +469,17 @@ void unregister_pernet_device(struct pernet_operations *); struct ctl_table; +#define register_net_sysctl(net, path, table) \ + register_net_sysctl_sz(net, path, table, SIZE_MAX) #ifdef CONFIG_SYSCTL int net_sysctl_init(void); -struct ctl_table_header *register_net_sysctl(struct net *net, const char *path, - struct ctl_table *table); +struct ctl_table_header *register_net_sysctl_sz(struct net *net, const char *path, + struct ctl_table *table, size_t table_size); void unregister_net_sysctl_table(struct ctl_table_header *header); #else static inline int net_sysctl_init(void) { return 0; } -static inline struct ctl_table_header *register_net_sysctl(struct net *net, - const char *path, struct ctl_table *table) +static inline struct ctl_table_header *register_net_sysctl_sz(struct net *net, + const char *path, struct ctl_table *table, size_t table_size) { return NULL; } diff --git a/net/sysctl_net.c b/net/sysctl_net.c index d9cbbb51b143..051ed5f6fc93 100644 --- a/net/sysctl_net.c +++ b/net/sysctl_net.c @@ -122,12 +122,13 @@ __init int net_sysctl_init(void) * allocated. */ static void ensure_safe_net_sysctl(struct net *net, const char *path, - struct ctl_table *table) + struct ctl_table *table, size_t table_size) { struct ctl_table *ent; pr_debug("Registering net sysctl (net %p): %s\n", net, path); - for (ent = table; ent->procname; ent++) { + ent = table; + for (size_t i = 0; i < table_size && ent->procname; ent++, i++) { unsigned long addr; const char *where; @@ -160,21 +161,24 @@ 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) +struct ctl_table_header *register_net_sysctl_sz(struct net *net, + const char *path, + struct ctl_table *table, + size_t table_size) { - int count = 0; + int count; struct ctl_table *entry; if (!net_eq(net, &init_net)) - ensure_safe_net_sysctl(net, path, table); + ensure_safe_net_sysctl(net, path, table, table_size); - for (entry = table; entry->procname; entry++) - count++; + entry = table; + for (count = 0 ; count < table_size && entry->procname; entry++, count++) + ; return __register_sysctl_table(&net->sysctls, path, table, count); } -EXPORT_SYMBOL_GPL(register_net_sysctl); +EXPORT_SYMBOL_GPL(register_net_sysctl_sz); void unregister_net_sysctl_table(struct ctl_table_header *header) { From patchwork Wed Jul 26 14:06:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13328108 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B7D021D39 for ; Wed, 26 Jul 2023 14:07:10 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ABC52D60 for ; Wed, 26 Jul 2023 07:07:05 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230726140704euoutp016a3838b3abacf87deac9eb5cbbd5ab67~1cApBgTei3202732027euoutp01b for ; Wed, 26 Jul 2023 14:07:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230726140704euoutp016a3838b3abacf87deac9eb5cbbd5ab67~1cApBgTei3202732027euoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690380424; bh=Nj7Ghn+kSOTETzoJsaSu9wi1agkqgAyigWTwaRVhj0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HbnW/01MMcRCUhrsw3LYP6YjvDlXVP1MYApY5uoZdJmbfsrwN26OoN2OHYPgCiOBd 0YucJmFEG67aChRlzsG8aquq5auZfYYNphVIxMK/01giXLTjURJ+6zxGk4TpO7tvCt 6xZXQkBs3Kfs5pzrNM3yGS9pXvThzX9I2zh5pxks= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230726140704eucas1p100b74ffbb75f5a4cb26bcfdedf619471~1cAornRKb2261122611eucas1p1p; Wed, 26 Jul 2023 14:07:04 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 8B.F6.11320.78821C46; Wed, 26 Jul 2023 15:07:04 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230726140703eucas1p2786577bcc67d5ae434671dac11870c60~1cAn-_eJa0080000800eucas1p2s; Wed, 26 Jul 2023 14:07:03 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230726140703eusmtrp262155482faef2d00243300fa4bb51762~1cAn-O03L2063520635eusmtrp2F; Wed, 26 Jul 2023 14:07:03 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-43-64c128872c53 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 87.57.14344.78821C46; Wed, 26 Jul 2023 15:07:03 +0100 (BST) Received: from localhost (unknown [106.210.248.223]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230726140703eusmtip2325884d0d96c3ee20ec7922d060314b9~1cAn01PTT2007220072eusmtip2H; Wed, 26 Jul 2023 14:07:03 +0000 (GMT) From: Joel Granados To: mcgrof@kernel.org, Joerg Reuter , Ralf Baechle , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: willy@infradead.org, keescook@chromium.org, josh@joshtriplett.org, Joel Granados , linux-hams@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/14] ax.25: Update to register_net_sysctl_sz Date: Wed, 26 Jul 2023 16:06:29 +0200 Message-Id: <20230726140635.2059334-10-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230726140635.2059334-1-j.granados@samsung.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLKsWRmVeSWpSXmKPExsWy7djP87odGgdTDM58ZbSYc76FxeLpsUfs Fkv3P2S0+L8g3+JnH7fFme5ciwvb+lgtrm2/y2RxedccNosbE54yWhxbIGbx7fQbRotLe1Qs fv+Yw+bA5zG74SKLx5aVN5k8Fmwq9di8Qsvj1mtbj02rOtk8jq5cy+Txft9VNo++LasYPT5v kvN4M+01UwB3FJdNSmpOZllqkb5dAlfG4buT2ArWsVf8+fmYvYFxJlsXIyeHhICJxPGJd9i7 GLk4hARWMEr83PiEGcL5wigx6W8PI0iVkMBnRomN621gOs49OQtVtJxRYu3X14wQzktGiYm3 Z4DNZRPQkTj/5g5YlYjAB0aJ9qcHwKqYBQ4zSnz92cUOUiUsYCfxaPlLsA4WAVWJpXfnsIDY vEDxnqutUBfKS7Rdnw52BydQfOXa76wQNYISJ2c+AatnBqpp3jobbJuEQDenxJ+fF1khml0k tsz9xw5hC0u8Or4FypaR+L9zPhNEw2RGif3/PrBDOKsZJZY1fmWCqLKWaLnyBCjBAbRCU2L9 Ln2IsKPEmZ4drCBhCQE+iRtvBSGO4JOYtG06M0SYV6KjTQiiWkWib+kUFghbSuL65Z1Qf3lI PL55jXkCo+IsJO/MQvLOLIS9CxiZVzGKp5YW56anFhvlpZbrFSfmFpfmpesl5+duYgSmuNP/ jn/Zwbj81Ue9Q4xMHIyHGCU4mJVEeA1j9qUI8aYkVlalFuXHF5XmpBYfYpTmYFES59W2PZks JJCeWJKanZpakFoEk2Xi4JRqYBL5U/1x+uHj86pZQ1YLRyxPyOfcuOfUvLVrBTTPbLpfeG2X ztITO26oL/L0qL114OoG9zJO1Umt/5782/66MVW1oEEs6dE+zdNf/0UYKRieY5uYqyLu8HFF kOLBep9Uq6V9vN4isZqn3D4/6d8RYvyhY+/v1oqWy1qTdxTe2XrnY5LJksq7b/02u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GlnPGEz4m 970lzC9+n/Da0qlhFsjisue25PfVvs2m95YsZqiP/lUycduFM9knVspOfKQSJbiFtafzh7+3 eC6XM/PEbz5TJ3oZ+bbNDl1/STXOdK5qq93e3tJyvpRN+ktXm809/VjL9ZWGi56/baiQ6sby BZf/q+rtu7wrcyWfhnawUeediN70p4d3ftSJ9Zx0s5H9nnbrvq6ELbzWRUaTZJVYijMSDbWY i4oTASZ3r8BMAwAA X-CMS-MailID: 20230726140703eucas1p2786577bcc67d5ae434671dac11870c60 X-Msg-Generator: CA X-RootMTR: 20230726140703eucas1p2786577bcc67d5ae434671dac11870c60 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230726140703eucas1p2786577bcc67d5ae434671dac11870c60 References: <20230726140635.2059334-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This is part of the effort to remove the sentinel (last empty) element from the ctl_table arrays. We update to the new function and pass it the array size. Signed-off-by: Joel Granados --- net/ax25/sysctl_net_ax25.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c index 2154d004d3dc..db66e11e7fe8 100644 --- a/net/ax25/sysctl_net_ax25.c +++ b/net/ax25/sysctl_net_ax25.c @@ -159,7 +159,8 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev) table[k].data = &ax25_dev->values[k]; snprintf(path, sizeof(path), "net/ax25/%s", ax25_dev->dev->name); - ax25_dev->sysheader = register_net_sysctl(&init_net, path, table); + ax25_dev->sysheader = register_net_sysctl_sz(&init_net, path, table, + ARRAY_SIZE(ax25_param_table)); if (!ax25_dev->sysheader) { kfree(table); return -ENOMEM; From patchwork Wed Jul 26 14:06:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13328109 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04D6821D39 for ; Wed, 26 Jul 2023 14:07:14 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A9FB2D71 for ; Wed, 26 Jul 2023 07:07:08 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230726140707euoutp01870ce7171d43c91b702e506d34ee0aab~1cArbiFYi2885328853euoutp01i for ; Wed, 26 Jul 2023 14:07:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230726140707euoutp01870ce7171d43c91b702e506d34ee0aab~1cArbiFYi2885328853euoutp01i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690380427; bh=N/tDn9xxgtPj3eeWaK+OzmB4bUzNii0EGpI6o50nYlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pNaW5b8TJXaGTl1SEuaXc3ZPzT0d2nuEoslVgvOznQrgb+q/d3VchRseOWur1yssr +H7P9gKV9QvqmRVOmPMZc8ggqAvdsuCPJ+7OtRJog09Io0I752iv2UyIRr3Ut0VhSW UUxo/Kz5iL/QA6svZHhypp0DmctgIICynw76tBn0= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230726140706eucas1p24789a1a06dfe1ac64f6f1096b26f3d07~1cAq-VuOC0231902319eucas1p2b; Wed, 26 Jul 2023 14:07:06 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id E8.66.37758.A8821C46; Wed, 26 Jul 2023 15:07:06 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230726140706eucas1p1b11e5f0bd17f0de19af9608cbd8d17f3~1cAqhUQ8V1609216092eucas1p1z; Wed, 26 Jul 2023 14:07:06 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230726140706eusmtrp2578967f01f9a76cc3d031fa9ca6dff29~1cAqgYz0r2063520635eusmtrp2I; Wed, 26 Jul 2023 14:07:06 +0000 (GMT) X-AuditID: cbfec7f5-815ff7000002937e-1f-64c1288a133f Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F8.57.14344.98821C46; Wed, 26 Jul 2023 15:07:05 +0100 (BST) Received: from localhost (unknown [106.210.248.223]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230726140705eusmtip1a687fd37e974447dc1969db1ddf960e4~1cAqM8dOl0182201822eusmtip1c; Wed, 26 Jul 2023 14:07:05 +0000 (GMT) From: Joel Granados To: mcgrof@kernel.org, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Roopa Prabhu , Nikolay Aleksandrov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern , Simon Horman , Julian Anastasov Cc: willy@infradead.org, keescook@chromium.org, josh@joshtriplett.org, Joel Granados , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, bridge@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvs-devel@vger.kernel.org Subject: [PATCH 10/14] netfilter: Update to register_net_sysctl_sz Date: Wed, 26 Jul 2023 16:06:30 +0200 Message-Id: <20230726140635.2059334-11-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230726140635.2059334-1-j.granados@samsung.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02Sf1CTdRzH+z7Ps2c/avg4vPZt/jpX3RnR1MPO753JpVk+kt3sutXh5dmO PQLJGG0galaMCSEKTMWbjBm7ip8D1k0GjCOwdQ0RNqphTPKoEPwFSgEDlHRtPHj53/vz+bze 3/fnc/fl4aJSUsJLTc9ktOnKNCkpIJo99/teKVz7g2r9OddqdKn+dy566PoSR5a+YwRqbMvD 0KhnmIuai2wAGZxBgCo7/wJopGSYg0JWDSorNGCo94Qa/dxczEH+NguJDBWTOAoYRwHyWJ9F xsbLBJrpGQfINH4FR5enQxiasqxF83MW8nUxfc/XDejynF8Iuqn2KkZbHVn0hZoYenBsC+2o O07SZwLVgL47fwmjiwz3SHqi4wpJFzfVAfpUXjug3bNWDm25P0PQU45Vu6k9gtdUTFrqQUa7 Lv4jQYp/cIiT0bLp0OScHeSAQlkh4PMgtREWzOvJiBZRNQB6b+4uBIKwngaw0lwK2GIKwJ7v 6sFjh29Wj7ODagB/7GxZpG4D2Dll4kQokoqFfePXFqhllB+HFy39RKTAqa8xeMvzEzdCRVPb oP+P4YV3CepF+Nu/Z/GIFlLx0KM3cdm81TB/wLTA8MP92oZZDssshd1lI0RE42HG4CxfSIPU Az5sH20gWPN2+OArB8bqaHinq2nx0RUw5KrAWMOZ8N6P/uayhQ3AKn1w0bEZHusfCQ944YiX oL1tHdveCktODYJIG1JRMHB3KbtEFDzdbMLZthAW5ItY+gVYXF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YQaqEBZwkLt9/xAhiswioSlz7M5UZxOYVsJM41jidHWKF vETb9elgNZxA8ZVrv7OC2EICthI9U5+yQ9QLSpyc+QRsMzNQffPW2cwTGAVmIUnNQpJawMi0 ilEktbQ4Nz232EivODG3uDQvXS85P3cTIzAtbDv2c8sOxpWvPuodYmTiYDzEKMHBrCTCaxiz L0WINyWxsiq1KD++qDQntfgQoynQ3ROZpUST84GJKa8k3tDMwNTQxMzSwNTSzFhJnNezoCNR SCA9sSQ1OzW1ILUIpo+Jg1Oqgcl24xGljT4l5bY2mct0O2oEBNdn7La6k/cwsJMtn7OuhF2p vtpDN5spkzFxwqfrN+b9+Dgj4D7v4n9ZwiXRoROF3u2/x5LIbRKWJpp9dofS89Qcke/HA9m2 M9w47iCq4mWm4bMhovx6aFzWiQPcheIm5dybr7ifqzWapOIccHxD3OX1UVwP3dPmvpY/pHne JfznZc2S7VOKrY7H1Uc9NHkVP3vLy/o11xiD7q39+5WhNatIOjunatNU7gU/Wu7o/H/E+1Cv odjZ4MPvEy7JAa++xXck6az7yzr148+IaetvM60983DqMWaGl7tXpapkq9iq6oocU2yILV+1 LF82rYEv4fcFxvfBomfzrxX8VGIpzkg01GIuKk4EAGwH1juUAwAA X-CMS-MailID: 20230726140706eucas1p1b11e5f0bd17f0de19af9608cbd8d17f3 X-Msg-Generator: CA X-RootMTR: 20230726140706eucas1p1b11e5f0bd17f0de19af9608cbd8d17f3 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230726140706eucas1p1b11e5f0bd17f0de19af9608cbd8d17f3 References: <20230726140635.2059334-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This is part of the effort to remove the sentinel (last empty) element from the ctl_table arrays. We update to the new function and pass it the array size. Care is taken to mirror the NULL assignments with a size of zero (for the unprivileged users) Signed-off-by: Joel Granados --- net/bridge/br_netfilter_hooks.c | 3 ++- net/ipv6/netfilter/nf_conntrack_reasm.c | 3 ++- net/netfilter/ipvs/ip_vs_ctl.c | 8 ++++++-- net/netfilter/ipvs/ip_vs_lblc.c | 10 +++++++--- net/netfilter/ipvs/ip_vs_lblcr.c | 10 +++++++--- net/netfilter/nf_conntrack_standalone.c | 4 +++- net/netfilter/nf_log.c | 7 ++++--- 7 files changed, 31 insertions(+), 14 deletions(-) diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c index 1a801fab9543..15186247b59a 100644 --- a/net/bridge/br_netfilter_hooks.c +++ b/net/bridge/br_netfilter_hooks.c @@ -1135,7 +1135,8 @@ static int br_netfilter_sysctl_init_net(struct net *net) br_netfilter_sysctl_default(brnet); - brnet->ctl_hdr = register_net_sysctl(net, "net/bridge", table); + brnet->ctl_hdr = register_net_sysctl_sz(net, "net/bridge", table, + ARRAY_SIZE(brnf_table)); if (!brnet->ctl_hdr) { if (!net_eq(net, &init_net)) kfree(table); diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index d13240f13607..b2dd48911c8d 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -87,7 +87,8 @@ static int nf_ct_frag6_sysctl_register(struct net *net) table[2].data = &nf_frag->fqdir->high_thresh; table[2].extra1 = &nf_frag->fqdir->low_thresh; - hdr = register_net_sysctl(net, "net/netfilter", table); + hdr = register_net_sysctl_sz(net, "net/netfilter", table, + ARRAY_SIZE(nf_ct_frag6_sysctl_table)); if (hdr == NULL) goto err_reg; diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index 62606fb44d02..8d69e4c2d822 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -4266,6 +4266,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs) struct net *net = ipvs->net; struct ctl_table *tbl; int idx, ret; + size_t ctl_table_size = ARRAY_SIZE(vs_vars); atomic_set(&ipvs->dropentry, 0); spin_lock_init(&ipvs->dropentry_lock); @@ -4282,8 +4283,10 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs) return -ENOMEM; /* Don't export sysctls to unprivileged users */ - if (net->user_ns != &init_user_ns) + if (net->user_ns != &init_user_ns) { tbl[0].procname = NULL; + ctl_table_size = 0; + } } else tbl = vs_vars; /* Initialize sysctl defaults */ @@ -4353,7 +4356,8 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs) #endif ret = -ENOMEM; - ipvs->sysctl_hdr = register_net_sysctl(net, "net/ipv4/vs", tbl); + ipvs->sysctl_hdr = register_net_sysctl_sz(net, "net/ipv4/vs", tbl, + ctl_table_size); if (!ipvs->sysctl_hdr) goto err; ipvs->sysctl_tbl = tbl; diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c index 1b87214d385e..cf78ba4ce5ff 100644 --- a/net/netfilter/ipvs/ip_vs_lblc.c +++ b/net/netfilter/ipvs/ip_vs_lblc.c @@ -550,6 +550,7 @@ static struct ip_vs_scheduler ip_vs_lblc_scheduler = { static int __net_init __ip_vs_lblc_init(struct net *net) { struct netns_ipvs *ipvs = net_ipvs(net); + size_t vars_table_size = ARRAY_SIZE(vs_vars_table); if (!ipvs) return -ENOENT; @@ -562,16 +563,19 @@ static int __net_init __ip_vs_lblc_init(struct net *net) return -ENOMEM; /* Don't export sysctls to unprivileged users */ - if (net->user_ns != &init_user_ns) + if (net->user_ns != &init_user_ns) { ipvs->lblc_ctl_table[0].procname = NULL; + vars_table_size = 0; + } } else ipvs->lblc_ctl_table = vs_vars_table; ipvs->sysctl_lblc_expiration = DEFAULT_EXPIRATION; ipvs->lblc_ctl_table[0].data = &ipvs->sysctl_lblc_expiration; - ipvs->lblc_ctl_header = - register_net_sysctl(net, "net/ipv4/vs", ipvs->lblc_ctl_table); + ipvs->lblc_ctl_header = register_net_sysctl_sz(net, "net/ipv4/vs", + ipvs->lblc_ctl_table, + vars_table_size); if (!ipvs->lblc_ctl_header) { if (!net_eq(net, &init_net)) kfree(ipvs->lblc_ctl_table); diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c index ad8f5fea6d3a..9eddf118b40e 100644 --- a/net/netfilter/ipvs/ip_vs_lblcr.c +++ b/net/netfilter/ipvs/ip_vs_lblcr.c @@ -736,6 +736,7 @@ static struct ip_vs_scheduler ip_vs_lblcr_scheduler = static int __net_init __ip_vs_lblcr_init(struct net *net) { struct netns_ipvs *ipvs = net_ipvs(net); + size_t vars_table_size = ARRAY_SIZE(vs_vars_table); if (!ipvs) return -ENOENT; @@ -748,15 +749,18 @@ static int __net_init __ip_vs_lblcr_init(struct net *net) return -ENOMEM; /* Don't export sysctls to unprivileged users */ - if (net->user_ns != &init_user_ns) + if (net->user_ns != &init_user_ns) { ipvs->lblcr_ctl_table[0].procname = NULL; + vars_table_size = 0; + } } else ipvs->lblcr_ctl_table = vs_vars_table; ipvs->sysctl_lblcr_expiration = DEFAULT_EXPIRATION; ipvs->lblcr_ctl_table[0].data = &ipvs->sysctl_lblcr_expiration; - ipvs->lblcr_ctl_header = - register_net_sysctl(net, "net/ipv4/vs", ipvs->lblcr_ctl_table); + ipvs->lblcr_ctl_header = register_net_sysctl_sz(net, "net/ipv4/vs", + ipvs->lblcr_ctl_table, + vars_table_size); if (!ipvs->lblcr_ctl_header) { if (!net_eq(net, &init_net)) kfree(ipvs->lblcr_ctl_table); diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index 169e16fc2bce..0ee98ce5b816 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c @@ -1106,7 +1106,9 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net) table[NF_SYSCTL_CT_BUCKETS].mode = 0444; } - cnet->sysctl_header = register_net_sysctl(net, "net/netfilter", table); + cnet->sysctl_header = register_net_sysctl_sz(net, "net/netfilter", + table, + ARRAY_SIZE(nf_ct_sysctl_table)); if (!cnet->sysctl_header) goto out_unregister_netfilter; diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c index 8a29290149bd..8cc52d2bd31b 100644 --- a/net/netfilter/nf_log.c +++ b/net/netfilter/nf_log.c @@ -487,9 +487,10 @@ static int netfilter_log_sysctl_init(struct net *net) for (i = NFPROTO_UNSPEC; i < NFPROTO_NUMPROTO; i++) table[i].extra2 = net; - net->nf.nf_log_dir_header = register_net_sysctl(net, - "net/netfilter/nf_log", - table); + net->nf.nf_log_dir_header = register_net_sysctl_sz(net, + "net/netfilter/nf_log", + table, + ARRAY_SIZE(nf_log_sysctl_table)); if (!net->nf.nf_log_dir_header) goto err_reg; From patchwork Wed Jul 26 14:06:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13328111 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48FCF253D5 for ; Wed, 26 Jul 2023 14:07:16 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DA372D79; Wed, 26 Jul 2023 07:07:11 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230726140710euoutp01c2f546dc7d3f1d81abe0dae631a5e49c~1cAuVUlpK3202132021euoutp01d; Wed, 26 Jul 2023 14:07:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230726140710euoutp01c2f546dc7d3f1d81abe0dae631a5e49c~1cAuVUlpK3202132021euoutp01d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690380430; bh=eEG+9wdw3V8Mgi0svvwops3ImN3rHxuCM63fKfPTemk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uWx8l9YdqTEEanl4fst1oxCka5BL0LmY4ps6UXSWAHtP5+SRaG1qjszyujdxRJ7Or lT7zvmjLA/eSHfMQHDnFmo5uCnRJsEZCgGyG39pn8P6mH47tJcLEfvPgwzupbzd5tq hgwffHObaZK+iAJLPsuy89JF2Eg5y+Pd3VVLQGzM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230726140709eucas1p23a046bfe707387d5086c45b0e7bb332c~1cAuDXBhz0677606776eucas1p2r; Wed, 26 Jul 2023 14:07:09 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 86.76.42423.D8821C46; Wed, 26 Jul 2023 15:07:09 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230726140709eucas1p2033d64aec69a1962fd7e64c57ad60adc~1cAtfR7ue0711407114eucas1p2p; Wed, 26 Jul 2023 14:07:09 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230726140709eusmtrp19711e67c27de29be1bdc849ddf5f81f5~1cAtdj1EQ2391823918eusmtrp1X; Wed, 26 Jul 2023 14:07:09 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-9a-64c1288d4904 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 7C.C7.10549.D8821C46; Wed, 26 Jul 2023 15:07:09 +0100 (BST) Received: from localhost (unknown [106.210.248.223]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230726140708eusmtip206258e4e07c8a2754ecc16260081f003~1cAtKZYNv3056730567eusmtip2e; Wed, 26 Jul 2023 14:07:08 +0000 (GMT) From: Joel Granados To: mcgrof@kernel.org, "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexander Aring , Stefan Schmidt , Miquel Raynal , Steffen Klassert , Herbert Xu , Matthieu Baerts , Mat Martineau , Santosh Shilimkar , Marcelo Ricardo Leitner , Xin Long , Karsten Graul , Wenjia Zhang , Jan Karcher Cc: willy@infradead.org, keescook@chromium.org, josh@joshtriplett.org, Joel Granados , "D. Wythe" , Tony Lu , Wen Gu , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.linux.dev, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com, linux-sctp@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 11/14] networking: Update to register_net_sysctl_sz Date: Wed, 26 Jul 2023 16:06:31 +0200 Message-Id: <20230726140635.2059334-12-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230726140635.2059334-1-j.granados@samsung.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01Sa0xTZxjOd87paWlSdiwEvxQTtzoMFocjI+EzAzdwZicxu5gw2GRmdvYM k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HV6uOqksKeY0bpEfuvojGx+WqIg9YpD3KZiSns2kZ 0uR0aUaq5KnY3cV6uYjKl2v54zxfzKv/n0PImHgdko9X9bGqucx9B84qnwmIRo+Mb7HkyJJe /fq9vX4FDd7wD+4kNrU6/fsarm+uCDFpi7eC9TOO0dLHSnM6q7S/rp+9nrrS8bSm3l11Ijvu slFxjDEk5az/zXo34QaB7q9D0x7mD7yYJZ6rD7GGc2U/LVzyzv+168ipQEd5+7Ne08Ir/IfC 7/RbvVNvllGV6ubX7160eZOme0Y+3WVl70zoJU2zfUsFtYco0/K647rbXY/rhfWV6MSFqT0n 18l2fLFzjBwLjohdAz37k+Mattipl+euqTMf9F/JaX/+94OnQp4Ez6wxt9rtPN/YdGm8oPyt PXv/rB8P1onLDw8ljQipjzaKJZhGIWcTUbVG/i/j4pEQyAMAAA== X-CMS-MailID: 20230726140709eucas1p2033d64aec69a1962fd7e64c57ad60adc X-Msg-Generator: CA X-RootMTR: 20230726140709eucas1p2033d64aec69a1962fd7e64c57ad60adc X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230726140709eucas1p2033d64aec69a1962fd7e64c57ad60adc References: <20230726140635.2059334-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This is part of the effort to remove the sentinel (last empty) element from the ctl_table arrays. We update to the new function and pass it the array size. Care is taken to mirror the NULL assignments with a size of zero (for the unprivileged users). An additional size function was added to the following files in order to calculate the size of an array that is defined in another file: include/net/ipv6.h net/ipv6/icmp.c net/ipv6/route.c net/ipv6/sysctl_net_ipv6.c Signed-off-by: Joel Granados --- include/net/ipv6.h | 2 + net/core/neighbour.c | 8 +++- net/core/sysctl_net_core.c | 3 +- net/ieee802154/6lowpan/reassembly.c | 8 +++- net/ipv4/devinet.c | 3 +- net/ipv4/ip_fragment.c | 3 +- net/ipv4/route.c | 8 +++- net/ipv4/sysctl_net_ipv4.c | 3 +- net/ipv4/xfrm4_policy.c | 3 +- net/ipv6/addrconf.c | 3 +- net/ipv6/icmp.c | 5 ++ net/ipv6/reassembly.c | 3 +- net/ipv6/route.c | 13 ++++-- net/ipv6/sysctl_net_ipv6.c | 16 +++++-- net/ipv6/xfrm6_policy.c | 3 +- net/mpls/af_mpls.c | 72 +++++++++++++++-------------- net/mptcp/ctrl.c | 3 +- net/rds/tcp.c | 3 +- net/sctp/sysctl.c | 4 +- net/smc/smc_sysctl.c | 3 +- net/unix/sysctl_net_unix.c | 3 +- net/xfrm/xfrm_sysctl.c | 8 +++- 22 files changed, 116 insertions(+), 64 deletions(-) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 7332296eca44..63ba68536a20 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -1274,7 +1274,9 @@ static inline int snmp6_unregister_dev(struct inet6_dev *idev) { return 0; } #ifdef CONFIG_SYSCTL struct ctl_table *ipv6_icmp_sysctl_init(struct net *net); +size_t ipv6_icmp_sysctl_table_size(void); struct ctl_table *ipv6_route_sysctl_init(struct net *net); +size_t ipv6_route_sysctl_table_size(struct net *net); int ipv6_sysctl_register(void); void ipv6_sysctl_unregister(void); #endif diff --git a/net/core/neighbour.c b/net/core/neighbour.c index ddd0f32de20e..adc7fc4ff9bf 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -3779,6 +3779,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 +3791,13 @@ 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"; @@ -3841,8 +3844,9 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, snprintf(neigh_path, sizeof(neigh_path), "net/%s/neigh/%s", p_name, dev_name_source); - t->sysctl_header = - register_net_sysctl(neigh_parms_net(p), neigh_path, t->neigh_vars); + t->sysctl_header = register_net_sysctl_sz(neigh_parms_net(p), + neigh_path, 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 782273bb93c2..03f1edb948d7 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -712,7 +712,8 @@ static __net_init int sysctl_core_net_init(struct net *net) tmp->data += (char *)net - (char *)&init_net; } - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl); + net->core.sysctl_hdr = register_net_sysctl_sz(net, "net/core", tbl, + ARRAY_SIZE(netns_core_table)); if (net->core.sysctl_hdr == NULL) goto err_reg; diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c index a91283d1e5bf..6dd960ec558c 100644 --- a/net/ieee802154/6lowpan/reassembly.c +++ b/net/ieee802154/6lowpan/reassembly.c @@ -360,6 +360,7 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net) struct ctl_table_header *hdr; struct netns_ieee802154_lowpan *ieee802154_lowpan = net_ieee802154_lowpan(net); + size_t table_size = ARRAY_SIZE(lowpan_frags_ns_ctl_table); table = lowpan_frags_ns_ctl_table; if (!net_eq(net, &init_net)) { @@ -369,8 +370,10 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net) goto err_alloc; /* Don't export sysctls to unprivileged users */ - if (net->user_ns != &init_user_ns) + if (net->user_ns != &init_user_ns) { table[0].procname = NULL; + table_size = 0; + } } table[0].data = &ieee802154_lowpan->fqdir->high_thresh; @@ -379,7 +382,8 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net) table[1].extra2 = &ieee802154_lowpan->fqdir->high_thresh; table[2].data = &ieee802154_lowpan->fqdir->timeout; - hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table); + hdr = register_net_sysctl_sz(net, "net/ieee802154/6lowpan", table, + table_size); if (hdr == NULL) goto err_reg; diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 5deac0517ef7..89087844ea6e 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -2720,7 +2720,8 @@ static __net_init int devinet_init_net(struct net *net) goto err_reg_dflt; err = -ENOMEM; - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl); + forw_hdr = register_net_sysctl_sz(net, "net/ipv4", tbl, + ARRAY_SIZE(ctl_forward_entry)); if (!forw_hdr) goto err_reg_ctl; net->ipv4.forw_hdr = forw_hdr; diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 69c00ffdcf3e..a4941f53b523 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -615,7 +615,8 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net) table[2].data = &net->ipv4.fqdir->timeout; table[3].data = &net->ipv4.fqdir->max_dist; - hdr = register_net_sysctl(net, "net/ipv4", table); + hdr = register_net_sysctl_sz(net, "net/ipv4", table, + ARRAY_SIZE(ip4_frags_ns_ctl_table)); if (!hdr) goto err_reg; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 98d7e6ba7493..e7e9fba0357a 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -3592,6 +3592,7 @@ static struct ctl_table ipv4_route_netns_table[] = { static __net_init int sysctl_route_net_init(struct net *net) { struct ctl_table *tbl; + size_t table_size = ARRAY_SIZE(ipv4_route_netns_table); tbl = ipv4_route_netns_table; if (!net_eq(net, &init_net)) { @@ -3603,8 +3604,10 @@ static __net_init int sysctl_route_net_init(struct net *net) /* Don't export non-whitelisted sysctls to unprivileged users */ if (net->user_ns != &init_user_ns) { - if (tbl[0].procname != ipv4_route_flush_procname) + if (tbl[0].procname != ipv4_route_flush_procname) { tbl[0].procname = NULL; + table_size = 0; + } } /* Update the variables to point into the current struct net @@ -3615,7 +3618,8 @@ static __net_init int sysctl_route_net_init(struct net *net) } tbl[0].extra1 = net; - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl); + net->ipv4.route_hdr = register_net_sysctl_sz(net, "net/ipv4/route", + tbl, table_size); if (!net->ipv4.route_hdr) goto err_reg; return 0; diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 2afb0870648b..6ac890b4073f 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -1519,7 +1519,8 @@ static __net_init int ipv4_sysctl_init_net(struct net *net) } } - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table); + net->ipv4.ipv4_hdr = register_net_sysctl_sz(net, "net/ipv4", table, + ARRAY_SIZE(ipv4_net_table)); if (!net->ipv4.ipv4_hdr) goto err_reg; diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 9403bbaf1b61..57ea394ffa8c 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c @@ -178,7 +178,8 @@ static __net_init int xfrm4_net_sysctl_init(struct net *net) table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh; } - hdr = register_net_sysctl(net, "net/ipv4", table); + hdr = register_net_sysctl_sz(net, "net/ipv4", table, + ARRAY_SIZE(xfrm4_policy_table)); if (!hdr) goto err_reg; diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index e5213e598a04..d615a84965c2 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -7085,7 +7085,8 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name, snprintf(path, sizeof(path), "net/ipv6/conf/%s", dev_name); - p->sysctl_header = register_net_sysctl(net, path, table); + p->sysctl_header = register_net_sysctl_sz(net, path, table, + ARRAY_SIZE(addrconf_sysctl)); if (!p->sysctl_header) goto free; diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 65fa5014bc85..a76b01b41b57 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -1229,4 +1229,9 @@ struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net) } return table; } + +size_t ipv6_icmp_sysctl_table_size(void) +{ + return ARRAY_SIZE(ipv6_icmp_table_template); +} #endif diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 5bc8a28e67f9..5ebc47da1000 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -470,7 +470,8 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net) table[1].extra2 = &net->ipv6.fqdir->high_thresh; table[2].data = &net->ipv6.fqdir->timeout; - hdr = register_net_sysctl(net, "net/ipv6", table); + hdr = register_net_sysctl_sz(net, "net/ipv6", table, + ARRAY_SIZE(ip6_frags_ns_ctl_table)); if (!hdr) goto err_reg; diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 64e873f5895f..51c6cdae8723 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -6447,14 +6447,19 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net) table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss; table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval; table[10].data = &net->ipv6.sysctl.skip_notify_on_dev_down; - - /* Don't export sysctls to unprivileged users */ - if (net->user_ns != &init_user_ns) - table[1].procname = NULL; } return table; } + +size_t ipv6_route_sysctl_table_size(struct net *net) +{ + /* Don't export sysctls to unprivileged users */ + if (net->user_ns != &init_user_ns) + return 0; + + return ARRAY_SIZE(ipv6_route_table_template); +} #endif static int __net_init ip6_route_net_init(struct net *net) diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c index 94a0a294c6a1..888676163e90 100644 --- a/net/ipv6/sysctl_net_ipv6.c +++ b/net/ipv6/sysctl_net_ipv6.c @@ -275,17 +275,23 @@ static int __net_init ipv6_sysctl_net_init(struct net *net) if (!ipv6_icmp_table) goto out_ipv6_route_table; - net->ipv6.sysctl.hdr = register_net_sysctl(net, "net/ipv6", ipv6_table); + net->ipv6.sysctl.hdr = register_net_sysctl_sz(net, "net/ipv6", + ipv6_table, + ARRAY_SIZE(ipv6_table_template)); if (!net->ipv6.sysctl.hdr) goto out_ipv6_icmp_table; - net->ipv6.sysctl.route_hdr = - register_net_sysctl(net, "net/ipv6/route", ipv6_route_table); + net->ipv6.sysctl.route_hdr = register_net_sysctl_sz(net, + "net/ipv6/route", + ipv6_route_table, + ipv6_route_sysctl_table_size(net)); if (!net->ipv6.sysctl.route_hdr) goto out_unregister_ipv6_table; - net->ipv6.sysctl.icmp_hdr = - register_net_sysctl(net, "net/ipv6/icmp", ipv6_icmp_table); + net->ipv6.sysctl.icmp_hdr = register_net_sysctl_sz(net, + "net/ipv6/icmp", + ipv6_icmp_table, + ipv6_icmp_sysctl_table_size()); if (!net->ipv6.sysctl.icmp_hdr) goto out_unregister_route_table; diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index eecc5e59da17..8f931e46b460 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c @@ -205,7 +205,8 @@ static int __net_init xfrm6_net_sysctl_init(struct net *net) table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh; } - hdr = register_net_sysctl(net, "net/ipv6", table); + hdr = register_net_sysctl_sz(net, "net/ipv6", table, + ARRAY_SIZE(xfrm6_policy_table)); if (!hdr) goto err_reg; diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index bf6e81d56263..5bad14b3c71e 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c @@ -1396,6 +1396,40 @@ static const struct ctl_table mpls_dev_table[] = { { } }; +static int mpls_platform_labels(struct ctl_table *table, int write, + void *buffer, size_t *lenp, loff_t *ppos); +#define MPLS_NS_SYSCTL_OFFSET(field) \ + (&((struct net *)0)->field) + +static const struct ctl_table mpls_table[] = { + { + .procname = "platform_labels", + .data = NULL, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = mpls_platform_labels, + }, + { + .procname = "ip_ttl_propagate", + .data = MPLS_NS_SYSCTL_OFFSET(mpls.ip_ttl_propagate), + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, + { + .procname = "default_ttl", + .data = MPLS_NS_SYSCTL_OFFSET(mpls.default_ttl), + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ONE, + .extra2 = &ttl_max, + }, + { } +}; + static int mpls_dev_sysctl_register(struct net_device *dev, struct mpls_dev *mdev) { @@ -1419,7 +1453,8 @@ static int mpls_dev_sysctl_register(struct net_device *dev, snprintf(path, sizeof(path), "net/mpls/conf/%s", dev->name); - mdev->sysctl = register_net_sysctl(net, path, table); + mdev->sysctl = register_net_sysctl_sz(net, path, table, + ARRAY_SIZE(mpls_dev_table)); if (!mdev->sysctl) goto free; @@ -2637,38 +2672,6 @@ static int mpls_platform_labels(struct ctl_table *table, int write, return ret; } -#define MPLS_NS_SYSCTL_OFFSET(field) \ - (&((struct net *)0)->field) - -static const struct ctl_table mpls_table[] = { - { - .procname = "platform_labels", - .data = NULL, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = mpls_platform_labels, - }, - { - .procname = "ip_ttl_propagate", - .data = MPLS_NS_SYSCTL_OFFSET(mpls.ip_ttl_propagate), - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, - { - .procname = "default_ttl", - .data = MPLS_NS_SYSCTL_OFFSET(mpls.default_ttl), - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ONE, - .extra2 = &ttl_max, - }, - { } -}; - static int mpls_net_init(struct net *net) { struct ctl_table *table; @@ -2689,7 +2692,8 @@ static int mpls_net_init(struct net *net) for (i = 0; i < ARRAY_SIZE(mpls_table) - 1; i++) table[i].data = (char *)net + (uintptr_t)table[i].data; - net->mpls.ctl = register_net_sysctl(net, "net/mpls", table); + net->mpls.ctl = register_net_sysctl_sz(net, "net/mpls", table, + ARRAY_SIZE(mpls_table)); if (net->mpls.ctl == NULL) { kfree(table); return -ENOMEM; diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c index ae20b7d92e28..43e540328a52 100644 --- a/net/mptcp/ctrl.c +++ b/net/mptcp/ctrl.c @@ -150,7 +150,8 @@ static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) table[4].data = &pernet->stale_loss_cnt; table[5].data = &pernet->pm_type; - hdr = register_net_sysctl(net, MPTCP_SYSCTL_PATH, table); + hdr = register_net_sysctl_sz(net, MPTCP_SYSCTL_PATH, table, + ARRAY_SIZE(mptcp_sysctl_table)); if (!hdr) goto err_reg; diff --git a/net/rds/tcp.c b/net/rds/tcp.c index c5b86066ff66..2dba7505b414 100644 --- a/net/rds/tcp.c +++ b/net/rds/tcp.c @@ -565,7 +565,8 @@ static __net_init int rds_tcp_init_net(struct net *net) } tbl[RDS_TCP_SNDBUF].data = &rtn->sndbuf_size; tbl[RDS_TCP_RCVBUF].data = &rtn->rcvbuf_size; - rtn->rds_tcp_sysctl = register_net_sysctl(net, "net/rds/tcp", tbl); + rtn->rds_tcp_sysctl = register_net_sysctl_sz(net, "net/rds/tcp", tbl, + ARRAY_SIZE(rds_tcp_sysctl_table)); if (!rtn->rds_tcp_sysctl) { pr_warn("could not register sysctl\n"); err = -ENOMEM; diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index a7a9136198fd..f65d6f92afcb 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c @@ -612,7 +612,9 @@ int sctp_sysctl_net_register(struct net *net) table[SCTP_PF_RETRANS_IDX].extra2 = &net->sctp.ps_retrans; table[SCTP_PS_RETRANS_IDX].extra1 = &net->sctp.pf_retrans; - net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table); + net->sctp.sysctl_header = register_net_sysctl_sz(net, "net/sctp", + table, + ARRAY_SIZE(sctp_net_table)); if (net->sctp.sysctl_header == NULL) { kfree(table); return -ENOMEM; diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c index b6f79fabb9d3..3ab2d8eefc55 100644 --- a/net/smc/smc_sysctl.c +++ b/net/smc/smc_sysctl.c @@ -81,7 +81,8 @@ int __net_init smc_sysctl_net_init(struct net *net) table[i].data += (void *)net - (void *)&init_net; } - net->smc.smc_hdr = register_net_sysctl(net, "net/smc", table); + net->smc.smc_hdr = register_net_sysctl_sz(net, "net/smc", table, + ARRAY_SIZE(smc_table)); if (!net->smc.smc_hdr) goto err_reg; diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c index 500129aa710c..3e84b31c355a 100644 --- a/net/unix/sysctl_net_unix.c +++ b/net/unix/sysctl_net_unix.c @@ -36,7 +36,8 @@ int __net_init unix_sysctl_register(struct net *net) table[0].data = &net->unx.sysctl_max_dgram_qlen; } - net->unx.ctl = register_net_sysctl(net, "net/unix", table); + net->unx.ctl = register_net_sysctl_sz(net, "net/unix", table, + ARRAY_SIZE(unix_table)); if (net->unx.ctl == NULL) goto err_reg; diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c index 0c6c5ef65f9d..7fdeafc838a7 100644 --- a/net/xfrm/xfrm_sysctl.c +++ b/net/xfrm/xfrm_sysctl.c @@ -44,6 +44,7 @@ static struct ctl_table xfrm_table[] = { int __net_init xfrm_sysctl_init(struct net *net) { struct ctl_table *table; + size_t table_size = ARRAY_SIZE(xfrm_table); __xfrm_sysctl_init(net); @@ -56,10 +57,13 @@ int __net_init xfrm_sysctl_init(struct net *net) table[3].data = &net->xfrm.sysctl_acq_expires; /* Don't export sysctls to unprivileged users */ - if (net->user_ns != &init_user_ns) + if (net->user_ns != &init_user_ns) { table[0].procname = NULL; + table_size = 0; + } - net->xfrm.sysctl_hdr = register_net_sysctl(net, "net/core", table); + net->xfrm.sysctl_hdr = register_net_sysctl_sz(net, "net/core", table, + table_size); if (!net->xfrm.sysctl_hdr) goto out_register; return 0; From patchwork Wed Jul 26 14:06:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13328110 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B0B521D39 for ; Wed, 26 Jul 2023 14:07:16 +0000 (UTC) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE98030D7 for ; Wed, 26 Jul 2023 07:07:13 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230726140712euoutp015566ea7370ceccf3bc812234098e5516~1cAwVGtQ13221632216euoutp01Z for ; Wed, 26 Jul 2023 14:07:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230726140712euoutp015566ea7370ceccf3bc812234098e5516~1cAwVGtQ13221632216euoutp01Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690380432; bh=zV6NK1bOT7jAIeViULG7reTqUFYKfHTzkiJZni8yHtw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bruaHRbr42VkRh/qfcRULFN/xrZjWD9E8bHu8H1ChgNhnYXwrYUMb+3S032pQQehV gvYKYKZ381/s//zMEKeAlYVpV0HAaGEpHq+XlvTE0lhs69pyCLGHbPqc61ZYd+7xgG JvRUN+GGfPwhybBhlhRKRmsXH5lhyS41ojKTXOYs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230726140711eucas1p214dadbb42dd76ca07c8791c7d08d861b~1cAv40m5x1969419694eucas1p2N; Wed, 26 Jul 2023 14:07:11 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 7E.66.37758.F8821C46; Wed, 26 Jul 2023 15:07:11 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230726140711eucas1p25a947afeef5593e21578f778355db192~1cAviQmRq0080900809eucas1p2g; Wed, 26 Jul 2023 14:07:11 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230726140711eusmtrp129a255c6e058423b93a5158f0fac4994~1cAvhqgAO2411224112eusmtrp1Q; Wed, 26 Jul 2023 14:07:11 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-34-64c1288fc24c Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 2F.57.14344.F8821C46; Wed, 26 Jul 2023 15:07:11 +0100 (BST) Received: from localhost (unknown [106.210.248.223]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230726140711eusmtip244e8e96d9a2910724634c8526608f09e~1cAvTjpRq1659816598eusmtip2j; Wed, 26 Jul 2023 14:07:11 +0000 (GMT) From: Joel Granados To: mcgrof@kernel.org, David Ahern , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: willy@infradead.org, keescook@chromium.org, josh@joshtriplett.org, Joel Granados , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/14] vrf: Update to register_net_sysctl_sz Date: Wed, 26 Jul 2023 16:06:32 +0200 Message-Id: <20230726140635.2059334-13-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230726140635.2059334-1-j.granados@samsung.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBKsWRmVeSWpSXmKPExsWy7djPc7r9GgdTDJp/6lrMOd/CYrFuVyuT xdNjj9gtlu5/yGjxf0G+xZnuXIsL2/pYLS7vmsNmcWPCU0aLYwvELL6dfsNo8fvHHDYHHo/Z DRdZPLasvMnksWBTqcfmFVoet17bemxa1cnm8X7fVTaPvi2rGD0+b5IL4IzisklJzcksSy3S t0vgypjd4Vfwna1i+dsVrA2Mt1i7GDk5JARMJObf7WTuYuTiEBJYwSjx5t42JgjnC6PEv7+d UM5nRol3X3cBtXCAtUyaxgYRX84ocXHRRnaQUUICLxklniyWBLHZBHQkzr+5AzZWROA0o8Tp v7vYQRxmkI5Xi6+ygFQJC9hI3Lj4BKybRUBVoq93PRvIBl4BO4kfr9Ih7pOXaLs+nRHE5gQK r1z7HexuXgFBiZMzn4CNYQaqad46G2yZhMAXDonHb1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Yk/17qgap4zSryde4cF JMEmoCNx/s0dZpCEiMBFRom+x5fYQRxmgbWMEvOmTwOrEhawkbhx8Qk7iM0ioCrR17ueDWQD r4CdxI9X6RAb5CXark9nBLE5gcIr135nBbGFBGwleqY+BWvlFRCUODnzCdhIZqD65q2zmScw CsxCkpqFJLWAkWkVo0hqaXFuem6xkV5xYm5xaV66XnJ+7iZGYHxtO/Zzyw7Gla8+6h1iZOJg PMQowcGsJMJrGLMvRYg3JbGyKrUoP76oNCe1+BCjKdDZE5mlRJPzgRGeVxJvaGZgamhiZmlg amlmrCTO61nQkSgkkJ5YkpqdmlqQWgTTx8TBKdXAtI5R/pP+kgomJ3tWpewcd01Xka+XTss9 5409IaNxJlHqj9OkFxtVI+vbsn5L5Zp0Mn7jNXg/q+33oUrOIy7hYhHyp9fsuvzpQxuTwLyL QVffLWeZvbXfrF1ZvGV24wbnLKbP/ft+NaTI15x1Fp15eP6nhnM6FdVF9tpnLzkK/05SVmEy qoq+fDm1cZ1hpsgfn8KcO0tXFzcLHfQ54bvmg3Jdu3ApY6UI59fP0kk2Nz0F9JR3F9wtmavA v5OJr9X2VcWzSeeXbr3hxbqiScmZf9PsZd8YvGwzeNJbLDOjpy5d9uXonxMmMgwyi2+c8+px bBa4d8Z4avSNd9/nutkpLpX/qxslly9eu/vpNhklluKMREMt5qLiRAD1/g2bOAMAAA== X-CMS-MailID: 20230726140711eucas1p25a947afeef5593e21578f778355db192 X-Msg-Generator: CA X-RootMTR: 20230726140711eucas1p25a947afeef5593e21578f778355db192 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230726140711eucas1p25a947afeef5593e21578f778355db192 References: <20230726140635.2059334-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This is part of the effort to remove the sentinel (last empty) element from the ctl_table arrays. We update to the new function and pass it the array size. Signed-off-by: Joel Granados --- drivers/net/vrf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index bdb3a76a352e..f4c3df15a0e5 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -1979,7 +1979,8 @@ static int vrf_netns_init_sysctl(struct net *net, struct netns_vrf *nn_vrf) /* init the extra1 parameter with the reference to current netns */ table[0].extra1 = net; - nn_vrf->ctl_hdr = register_net_sysctl(net, "net/vrf", table); + nn_vrf->ctl_hdr = register_net_sysctl_sz(net, "net/vrf", table, + ARRAY_SIZE(vrf_table)); if (!nn_vrf->ctl_hdr) { kfree(table); return -ENOMEM; From patchwork Wed Jul 26 14:06:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13328112 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 750BD26B2C for ; Wed, 26 Jul 2023 14:07:17 +0000 (UTC) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C0F2D71 for ; Wed, 26 Jul 2023 07:07:14 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230726140713euoutp02bc19bc28b8abc3814e3a67c8261f8fd1~1cAxBAxZH1609016090euoutp02L for ; Wed, 26 Jul 2023 14:07:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230726140713euoutp02bc19bc28b8abc3814e3a67c8261f8fd1~1cAxBAxZH1609016090euoutp02L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690380433; bh=JW7CP4Fi6G/IV8T1nAiu1rAhykb9tptNcnfn6WjOSE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPdTn6KzY3FNTAgMP+RF/FRdbqkmUvfDA0eja1hkvhHVExd1a4wiodJQlGXmeBLfB Yg9HRdmaH9jpZEsLK4EqKQDK1u1MF8Ga6ZPK+46lGOX8j//eRASoTreX4NjQ69dQAj VPZEn78HI2EZtG3U0NsHB2OrdHFuPNxT/lrA02mQ= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230726140712eucas1p2a55c1427b18503a11470c8e14d66e08c~1cAwusIzF0694406944eucas1p2o; Wed, 26 Jul 2023 14:07:12 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 71.76.37758.09821C46; Wed, 26 Jul 2023 15:07:12 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230726140712eucas1p1bc7b2d150482936d974ceba9c51d7bc4~1cAwan4r92257522575eucas1p1F; Wed, 26 Jul 2023 14:07:12 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230726140712eusmtrp2fca45d42ef0d1e8a0b96492448999419~1cAwaFtP52063520635eusmtrp2O; Wed, 26 Jul 2023 14:07:12 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-3a-64c1289048fb Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 61.67.14344.09821C46; Wed, 26 Jul 2023 15:07:12 +0100 (BST) Received: from localhost (unknown [106.210.248.223]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230726140712eusmtip2f0fe322b3296998b4ab61e5f2597cf0a~1cAwPqTnT3059730597eusmtip2s; Wed, 26 Jul 2023 14:07:12 +0000 (GMT) From: Joel Granados To: mcgrof@kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: willy@infradead.org, keescook@chromium.org, josh@joshtriplett.org, Joel Granados , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/14] sysctl: SIZE_MAX->ARRAY_SIZE in register_net_sysctl Date: Wed, 26 Jul 2023 16:06:33 +0200 Message-Id: <20230726140635.2059334-14-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230726140635.2059334-1-j.granados@samsung.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGKsWRmVeSWpSXmKPExsWy7djPc7oTNA6mGBy/r2Ux53wLi8XTY4/Y LZbuf8ho8X9BvsWZ7lyLC9v6WC0u75rDZnFjwlNGi2MLxCy+nX7DaPH7xxw2B26P2Q0XWTy2 rLzJ5LFgU6nH5hVaHrde23psWtXJ5vF+31U2j74tqxg9Pm+SC+CM4rJJSc3JLEst0rdL4MrY tnwzS8EXzoq1m1+yNTBu4uhi5OSQEDCRWHhhIXsXIxeHkMAKRomNO6+wQThfGCVedC+Hynxm lNg2/zQzTMu2jj+sEInljBJ3rk5mhHBeMkqsmt8OVsUmoCNx/s0dZpCEiMBKRomu1gVgVcwg La8WX2UBqRIW8JLYevEDG4jNIqAqsf7XbKYuRg4OXgE7iXMLDCHWyUu0XZ/OCGJzAoV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2Nbxh7WLkYtDSGApo8T67rOMXYwcQAkpie/LOCFqhCX+XOtig6h5zihxveEMC0iC TUBH4vybO8wgCRGBtYwSN9+eYgdxmEGcedOngVUJC3hJbL34gQ3EZhFQlVj/azYTyAZeATuJ cwsMITbIS7Rdn84IYnMChVeu/c4KYgsJ2Er0TH3KDmLzCghKnJz5BGwkM1B989bZzBMYBWYh Sc1CklrAyLSKUSS1tDg3PbfYSK84Mbe4NC9dLzk/dxMjMLK2Hfu5ZQfjylcf9Q4xMnEwHmKU 4GBWEuE1jNmXIsSbklhZlVqUH19UmpNafIjRFOjsicxSosn5wNjOK4k3NDMwNTQxszQwtTQz VhLn9SzoSBQSSE8sSc1OTS1ILYLpY+LglGpgmrp+3pNjXXoHLy5NWnHWQ+7aI8XTXQHXC/Ye i/xdW/rX/1i4jPK6vYKfd2fp1caafCudKHh7Q1vz38KTV9NvhT0tZNBY9TovXKNk+cWI3V/d xL5/6X+2R/iKpv2Vzu/nG6c93n3Bc8mrhX9++V5lWMnwUGkTS9Xlj/c6vjq0sdR3xOVYpF+e kyEv+WWC4VJn0/9n+bq9wnYufPmmILH/7R7DNU2fDsp4TBeUSvgT+WuD+5sT1YEPz7ftu1xX HWnXEr+E7W3MlULfD5N5Z1jadPzat97wbJ8Ov4OqlBtrVMOzpsAcsWuWDru1njywZk5IDTVI zqlxCgrki0zQ9fh84LuO2JW1C7esqnO8oDjlshJLcUaioRZzUXEiAIPY8mk1AwAA X-CMS-MailID: 20230726140712eucas1p1bc7b2d150482936d974ceba9c51d7bc4 X-Msg-Generator: CA X-RootMTR: 20230726140712eucas1p1bc7b2d150482936d974ceba9c51d7bc4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230726140712eucas1p1bc7b2d150482936d974ceba9c51d7bc4 References: <20230726140635.2059334-1-j.granados@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This is part of the effort to remove the end element (sentinel) from the ctl_table arrays. Now that all the callers to register_net_sysctl are actual arrays, we replace SIZE_MAX with ARRAY_SIZE of the table. Stopping condition continues to be based on both size and procname null test. This sets things up for when the sentinel element is actually removed: Before removing sentinel the stopping criteria will be the last null element. When the sentinel is removed then the (correct) size will take over. Signed-off-by: Joel Granados --- include/net/net_namespace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index e4e5fe75a281..75dba309e043 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -470,7 +470,7 @@ void unregister_pernet_device(struct pernet_operations *); struct ctl_table; #define register_net_sysctl(net, path, table) \ - register_net_sysctl_sz(net, path, table, SIZE_MAX) + register_net_sysctl_sz(net, path, table, ARRAY_SIZE(table)) #ifdef CONFIG_SYSCTL int net_sysctl_init(void); struct ctl_table_header *register_net_sysctl_sz(struct net *net, const char *path,