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:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42LZduzned3CfZNSDO4tErQ4051rsWfvSRaL y7vmsFncmPCU0WLZTj8HVo/ZDRdZPBZsKvXYtKqTzePzJrkAligum5TUnMyy1CJ9uwSujF/f rjIV7OCpmHLxIHsD43fOLkYODgkBE4nd78K6GLk4hARWMEqsndjIBuF8YZRYsHw7M4TzmVHi 7ubZQBlOsI5djRehqpYzSrz/dIIFrqphWyMrhLOVUWLW/yXMIC1sAjoS59/cAbNFBOIlZq/Z zghiMwvkSsxaDlEjLOAq8fzbDCYQm0VAVeJf7wawdbwCNhLzFjxlh1gtL9F2fTpYL6eArcT5 x+9ZIGoEJU7OfMICMVNeonnrbGYIW0Li4IsXzBC9yhLX9y2GeqFW4tSWW0wgh0oIXOCQaFt3 mREi4SKx9+kzqAZhiVfHt0AtlpH4v3M+VMNkRon9/z6wQzirGSWWNX5lgqiylmi58gSqw1Gi cfEVVkgY80nceCsIcRGfxKRt05khwrwSHW1CExhVZiH5YRaSH2Yh+WEBI/MqRvHU0uLc9NRi w7zUcr3ixNzi0rx0veT83E2MwHRy+t/xTzsY5776qHeIkYmD8RCjBAezkgiv7KZJKUK8KYmV ValF+fFFpTmpxYcYpTlYlMR5tW1PJgsJpCeWpGanphakFsFkmTg4pRqYxBVvHrhdZ3dUmqm+ 8uC9KhtmNRXXi1emWC1xXmu7oa1tlbcI58IT9nyFw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KbyprGLwb11vuOha6ZuHL2pyNNRzucstxfi5RZXWLsE20Wz+KSfyss cl0le0GLZCjPqY+yc2Zt1N+vpeMkJfVH0Vq06cDa94oWum8Xbcl77TzpzaXDdcerhaRY1p+2 +vdOSLvbS5g/8fKKPUv8dzDdPGt3+lTInO1u64Jz1s/KnHBC0NGQWW3jjADX7TF/xa0+zo4o qLjlmnGlrO7LW4+/bwNXnpjU7rXnarHJrYV6K1L2ifksVtjv9nAqD6PN3edbA/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;