Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9115120rwd; Wed, 21 Jun 2023 03:17:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7TRp+SxtgvQTs4aH1p+kT8jGWpYyqznU+UvtaawHVyl22wX7YGMjgJhtt4iUNldmxmxHRR X-Received: by 2002:a05:6a20:3d1b:b0:122:687d:e61c with SMTP id y27-20020a056a203d1b00b00122687de61cmr6694684pzi.30.1687342630622; Wed, 21 Jun 2023 03:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687342630; cv=none; d=google.com; s=arc-20160816; b=Shl5zoOpm/Q55tpfX6MzaBHiJ8el5QV4Ooo8Hs9jCwvEzGsa+tIUq4+YDZXlAGPl8I ih1i65nSs1U1JHcPJpJjM2DY6S6h4Rkvyimvbe+X8PJzamkcvkFNrh2rQgzn27n7YYnT gTMHtcrUO7zYA+WaJpyXH8kkkWiVAETeagdngkjUSdl/ogNOlT6qzJYDnAR2HCEdpzgF MXcPBBYkI979V/GqCtMVKlOuRYSkg3x0g9NPLlHfx0TrwROF3LU5RayWQceQlW2vlJQR jw1ANUSD5ouDKoS4WzmlMJw8qO4smcvw+TvRMDd8OpmaTyAU6XuT1gJdKHU2X2D8Ili9 niOA== 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=oMMsCBVAUEOP5xD/Z+INlpRHDKkS9VhizNcPTCBp948=; b=iIOjDlXVZqg1PYR4A6TtcvddOWqhV+pC8/tktJWu3PoZv56zQSsvx/4VHvHV30XIVT VbDoNleS1OyYri17fJnpip1yv08tk0+zsMXGYG4WLvhg8yjKlB8TfNSu0aJAApCVJ+ba 9OGyn9bAVkR2kxlzAbPnsJNx5P2zbgEqed01PhzOr7BW+cGwGLEhe+N+pxsaizH4c495 /pa1GqBObNAcA/43sYmRaPXDc91RyUg4lwcWPcYbt6s4Jpl+Ef/a4w3I7qHHhYGIomOl N2sUQbYrd5prGkV0Vms5DEve0e5dpK33J3VyeaKNC4MIdZH3TL13GMG18Q60rnP2GghC 0vEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Vetou21b; 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 w135-20020a627b8d000000b00665ff626133si3676628pfc.348.2023.06.21.03.16.58; Wed, 21 Jun 2023 03:17:10 -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=Vetou21b; 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 S232069AbjFUJsa (ORCPT + 99 others); Wed, 21 Jun 2023 05:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231646AbjFUJs2 (ORCPT ); Wed, 21 Jun 2023 05:48:28 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A8D09B for ; Wed, 21 Jun 2023 02:48:27 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230621094825euoutp01f50104b93f33e2478df2d8dad893fc58~qo50mSsRE2243922439euoutp01_ for ; Wed, 21 Jun 2023 09:48:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230621094825euoutp01f50104b93f33e2478df2d8dad893fc58~qo50mSsRE2243922439euoutp01_ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1687340905; bh=oMMsCBVAUEOP5xD/Z+INlpRHDKkS9VhizNcPTCBp948=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Vetou21bFg5GhYx6PfjQwLVmbOJvNqxiglRJajEOyDJl328PDRlTZgMU10ScV/Ve9 R7toOsNaiRniJlf+C6JndiyvQbaNgOhyjrVngFt5Yd8CHnbn6iQcw/0WoQeyFC9AZ8 4cTFXm2TwXChIXpPGJAvnyY8O1PNaf9P509R7LUc= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230621094825eucas1p14a29d1829162515c73fa3108d1609c9c~qo50gGD1M1194511945eucas1p1C; Wed, 21 Jun 2023 09:48:25 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id A2.47.11320.967C2946; Wed, 21 Jun 2023 10:48:25 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230621094825eucas1p2d37372e5bd2377bfe953e6e4f7ff0363~qo50D7ZHB2114621146eucas1p2v; Wed, 21 Jun 2023 09:48:25 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230621094825eusmtrp1e66aac9eac34c360ca66a25014801dd3~qo50DdT361292612926eusmtrp1D; Wed, 21 Jun 2023 09:48:25 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-4b-6492c7690a9d Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D7.06.10549.867C2946; Wed, 21 Jun 2023 10:48:25 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230621094824eusmtip151933cc23390220a581d0f3fc016689d~qo5z2JBAA1131511315eusmtip18; Wed, 21 Jun 2023 09:48:24 +0000 (GMT) Received: from localhost (106.210.248.248) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jun 2023 10:48:24 +0100 From: Joel Granados To: , Kees Cook , Iurii Zaikin CC: Joel Granados , , Subject: [PATCH 10/11] sysctl: Remove nr_entries from new_links Date: Wed, 21 Jun 2023 11:48:01 +0200 Message-ID: <20230621094817.433842-2-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230621094817.433842-1-j.granados@samsung.com> MIME-Version: 1.0 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+NgFmpkleLIzCtJLcpLzFFi42LZduznOd3M45NSDBY0KVuc6c612LP3JIvF 5V1z2CxuTHjKaLFsp58Dq8fshossHgs2lXpsWtXJ5vF5k1wASxSXTUpqTmZZapG+XQJXxqcV N1gLTvNX/Pxyl6mB8SVPFyMnh4SAicSHGUeYuxi5OIQEVjBKrNu+kQXC+cIo8eP0YSYI5zOj xMqPKxhhWh78Oc8OYgsJLGeUWLVeCcIGKprYIw/RsJVRYueSXywgCTYBHYnzb+4wg9giAvES s9dsBxvELJArMWv5ErC4sIC9xMPbF1hBbBYBVYm9W/aBLeAVsJE4dO4P1G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LMwvkSsxavgQsLixgL/Hw9gWwqSwCqhJ7t+xjB7F5 BWwkDp37wwixTV6i7fp0MJtTwFbi9Yp+sF4hgXyJLWtnsULUC0qcnPmEBWK+vETz1tnMELaE xMEXL6A+UJa4vm8xG4RdK/H57zPGCYwis5C0z0LSPgtJ+wJG5lWMIqmlxbnpucWGesWJucWl eel6yfm5mxiBsbbt2M/NOxjnvfqod4iRiYPxEKMEB7OSCK/spkkpQrwpiZVVqUX58UWlOanF hxhNgf6cyCwlmpwPjPa8knhDMwNTQxMzSwNTSzNjJXFez4KORCGB9MSS1OzU1ILUIpg+Jg5O qQamJU689+/qrp4Qzv/1buzPI1+/RrBpSKb7PEtOzwhP2t+z6gm71dm5+4MvzEie2LqqqCj9 jORBi6jNj8TtZv7O9vp85wq36o1/b072NXbETLIQnrzoLt/z3C8zGR/c/v2OuUW1unAFp2/H o/yyVdI3f10I69G+vTbiwqnerH8nI4Tifh0Oe/w25r7fEYVw7zJP2RjhjRv5/VnVGe+miNgU Zq843Ll64tvgxQYzC1Z919eb92a/yc4XvhX3wlvybaJ4ky8+VD1pGSkUzbgxZdf8N7xXr/a8 N+T8Ge/m5TlL6o3cUXHbjLK2pV+CuPmaTPZKP5Y6uG7eUufXz4MvBh78NuV5zfwjy3o29JWU 3jh6WImlOCPRUIu5qDgRAJxPrt4+AwAA X-CMS-MailID: 20230621094825eucas1p2d37372e5bd2377bfe953e6e4f7ff0363 X-Msg-Generator: CA X-RootMTR: 20230621094825eucas1p2d37372e5bd2377bfe953e6e4f7ff0363 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230621094825eucas1p2d37372e5bd2377bfe953e6e4f7ff0363 References: <20230621091000.424843-1-j.granados@samsung.com> <20230621094817.433842-1-j.granados@samsung.com> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the number of entries is set in the ctl_header struct, there is no need to calculate that number. Replace the variable and logic that does the calculation whith the ctl_header value. Signed-off-by: Joel Granados --- fs/proc/proc_sysctl.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 1debd01209fc..9e7e17dd6162 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1166,18 +1166,16 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ struct ctl_table_header *links; struct ctl_node *node; char *link_name; - int nr_entries, name_bytes; + int name_bytes; name_bytes = 0; - nr_entries = 0; list_for_each_table_entry(entry, head) { - nr_entries++; name_bytes += strlen(entry->procname) + 1; } links = kzalloc(sizeof(struct ctl_table_header) + - sizeof(struct ctl_node)*nr_entries + - sizeof(struct ctl_table)*(nr_entries + 1) + + sizeof(struct ctl_node)*head->ctl_table_size + + sizeof(struct ctl_table)*(head->ctl_table_size + 1) + name_bytes, GFP_KERNEL); @@ -1185,8 +1183,8 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ return NULL; node = (struct ctl_node *)(links + 1); - link_table = (struct ctl_table *)(node + nr_entries); - link_name = (char *)&link_table[nr_entries + 1]; + link_table = (struct ctl_table *)(node + head->ctl_table_size); + link_name = (char *)&link_table[head->ctl_table_size + 1]; link = link_table; list_for_each_table_entry(entry, head) { @@ -1200,7 +1198,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ } init_header(links, dir->header.root, dir->header.set, node, link_table, head->ctl_table_size); - links->nreg = nr_entries; + links->nreg = head->ctl_table_size; return links; } -- 2.30.2