Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9050456rwd; Wed, 21 Jun 2023 02:15:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Swc9zCZM+30GexCwCS6Us8uJSIpHAWSRYkp+19PeIYtPJK3HA8JVJkKdljKhfkAIfy6MX X-Received: by 2002:a05:620a:e01:b0:763:baab:9017 with SMTP id y1-20020a05620a0e0100b00763baab9017mr3155404qkm.51.1687338918150; Wed, 21 Jun 2023 02:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687338918; cv=none; d=google.com; s=arc-20160816; b=T7d7FfwfSjNpngRLlf55ITjTCgqA9T90w3maCz6lr7mKvZ1i0+ujwlrODQfjKihKMp V1cko2KsI82Q2qFnCcjl8EIUCuO+gCFcojds39TpPwcsls6ppy43mvoU2FXOmYFlpm03 UAc6SOdQQeMcb8B2yV9TCQ5GGDXEMnVWwUjUjm+KaLAj79WTBkPQVWF4Exvqoi10wnTa ViU7uesaBtN2oZPy5e1NUuLLMhEadZ0S9Ze/rBNzMYvHk2WpPc7xPV3FgkIfxPKinWKr wqkQLEWTU+8gPwRyhILNk2gkbSssTB0xkmnIeLLzkTwxBGJv20T0Uif3IQR9UmQ0RbNh S2Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=2vCkgLvpZCXFi6D3nJ5E3ic3+Plkyq+z4m9VdlmF+tc=; b=Z1HFzPRnTokRla5qTdTLuQ3Pe5FBx56o3UnZlYTZFm1TcaQ4nZrk+rrftxN+9Nw/jF abTpQKZH4+vG+pxLDFHZBf9ut+89O4KnyamgOLI21OoOBwdeMKfrZxmKXWNkahyGfz3e nynikeGvg/fx3d3Murra1nLLw4sbC52Jjv5VUBoNseapFe6rGU31yRVjkFvg4IxDP2pC 30rAIxFW2oCNmSmDJdQleUztMQiOoq2GoPRqp18HK7nwMUWIDxaXWTiobGMKKTS3ygQj dciP/5W71M4KFLSBCbUAgX4A98Nj9nQukWAonTdDQ+HdXiJuZYxDQvdUK2Hs8mRIg0Ze zkMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=p45yve07; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k84-20020a628457000000b0066868af25ffsi3762650pfd.21.2023.06.21.02.15.01; Wed, 21 Jun 2023 02:15:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=p45yve07; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231254AbjFUJKq (ORCPT + 99 others); Wed, 21 Jun 2023 05:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbjFUJKN (ORCPT ); Wed, 21 Jun 2023 05:10:13 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A911E1704 for ; Wed, 21 Jun 2023 02:10:10 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230621091009euoutp026dd82298ed34dfe78291358f2a7105fa~qoYaD5Dve0778307783euoutp02k for ; Wed, 21 Jun 2023 09:10:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230621091009euoutp026dd82298ed34dfe78291358f2a7105fa~qoYaD5Dve0778307783euoutp02k 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 zghiMwvkSsxaDlEjLOAq8fzbDCYQm0VAVeJf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oCNx/s0dZhBbRCBeYvaa7YwgNrNArsSs5UvA4sICrhLPv81gArFZBFQl/vVuANvG K2AjMW/BU3aIbfISbdeng/VyCthKnH/8ngXEFgKqmf/hMiNEvaDEyZlPWCDmy0s0b53NDGFL SBx88YIZYo6yxPV9i6G+qZX4/PcZ4wRGkVlI2mchaZ+FpH0BI/MqRpHU0uLc9NxiI73ixNzi 0rx0veT83E2MwFjbduznlh2MK1991DvEyMTBeIhRgoNZSYRXdtOkFCHelMTKqtSi/Pii0pzU 4kOMpkB/TmSWEk3OB0Z7Xkm8oZmBqaGJmaWBqaWZsZI4r2dBR6KQQHpiSWp2ampBahFMHxMH p1QDk5PFL31en64ZJ/XUoy2vrtjByV5j2PzakdH+zEeGvx5Lf2zgms75sv5S+IGdEqvmcqpf akreosbdoLS2XIwn/VKbyprGLwb11vuOha6ZuHL2pyNNRzucstxfi5RZXWLsE20Wz+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> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.30.2