Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1092788rwb; Wed, 26 Jul 2023 07:30:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlFTxHYEoyF/0Xv+C7sj3Dw5KUrYF7TJr2pMkwm54/8HU+L+oAi0BwhLUp7vNRaFiUqHSof1 X-Received: by 2002:a05:6358:929:b0:130:df70:b9cd with SMTP id r41-20020a056358092900b00130df70b9cdmr2949056rwi.12.1690381823696; Wed, 26 Jul 2023 07:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690381823; cv=none; d=google.com; s=arc-20160816; b=QH/6XBCVh1KzVe5lqMtgnfPTpAUYyqCQLkBo2IkVuKZARJMtWvR1Es4+QKgiKMP/vM 7FBPmw3UtW8gI2ri+61qUiXUhaZLtNCxiFIzAbnAgWfCogo0sGITP9Nor75mNlPjbB9k KNZYl8z6mEfV7973GW2DrxJ/WN+ilgLp4TPmly4SWoTAcrlMBn4q9eJreHotZ2FPOYoq 2QIlSoZtmkTtkRHi341QmV5uVz9RjkYsIy7PNPLANUXh9c0SjORmhgYjHiUy2EsZSe7o qeAV5KeW2oi/xavRttTOZ4FeeYpf2Si4gP43s/7vZ+7chlCAO53gpA77W7foauRuNcDM C6aw== 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=ZlhOJ8Gab+MSzPX9ZYs0a+yISdusJpdPSBybk1+HDeo=; fh=jc9Oc4z2chBkB++ulkkGj5ASBtrAOk+67EQBS5BnDw0=; b=rPDAxrsasNhbyxhNchYW0gGtzGZx4CXKyQCvLc01UMwZRrQjitCyFWrfwnxm5k+GFX nyGOnHmrKooFGKLQZXL1sNWgArNFJ11aCU48lj3h81WchU4KlZNL0+LbwbkXuXyif8kU fLCaxJwVbFIwJTPGDIH9JQw3TljIvT1yTev9I6wn9KT1rN8uXtsX3kZIzN6u50od+mPl FqGDiHCdFflEEVYwycismG9nO6N/VRMtgC/w5vVukw+xGQzT/VfgvcOquzHXN47jWfG4 /RbLrl0bVVDU/HZpQlWLRLs9Sa7WntCLcTfeSSTn5UVMfM9D1vV3KEKPxhGqQqxFqNqW Oo2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="e/R+nC2g"; 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 k72-20020a636f4b000000b00563a0c1bf06si8191048pgc.428.2023.07.26.07.30.10; Wed, 26 Jul 2023 07:30:23 -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="e/R+nC2g"; 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 S234414AbjGZOH2 (ORCPT + 99 others); Wed, 26 Jul 2023 10:07:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234325AbjGZOHE (ORCPT ); Wed, 26 Jul 2023 10:07:04 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AB1B2733 for ; Wed, 26 Jul 2023 07:06:57 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230726140655euoutp02a570d91e57e27e0deac7cfc6ab8bebc2~1cAhE8a-G1252612526euoutp02h for ; Wed, 26 Jul 2023 14:06:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230726140655euoutp02a570d91e57e27e0deac7cfc6ab8bebc2~1cAhE8a-G1252612526euoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690380416; bh=ZlhOJ8Gab+MSzPX9ZYs0a+yISdusJpdPSBybk1+HDeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e/R+nC2ge/T3UbVrr0Iyiz+GbFLPl4e7nmpSvoG2VVwpskKwo8OvAS2HSbNJne8gO frs4WRdRn6P2bJzSWFbI64oeHluXXSIXjm3a99nbQhjVfMop63Fi8/e7zBuFsfiqTQ 1sMzynSViO4ZFXqX0JoUPzKOu0ywo99tyQ4o6CzA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230726140655eucas1p1716d7debd87fd6db1c31cda39504208a~1cAgzGlbb2260622606eucas1p1t; Wed, 26 Jul 2023 14:06:55 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 10.F6.11320.F7821C46; Wed, 26 Jul 2023 15:06:55 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230726140655eucas1p1c71c8de9edc8441b5262c936731b91a2~1cAghMaJC1812118121eucas1p1A; Wed, 26 Jul 2023 14:06:55 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230726140655eusmtrp146bf937793ee3ac7ee9b51f49865bd32~1cAgggVUt2391823918eusmtrp19; Wed, 26 Jul 2023 14:06:55 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-25-64c1287f3c72 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D3.C7.10549.F7821C46; Wed, 26 Jul 2023 15:06:55 +0100 (BST) Received: from localhost (unknown [106.210.248.223]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230726140655eusmtip12a0effc937e26b573d01a29cbefa6ae5~1cAgTexk92869028690eusmtip1e; Wed, 26 Jul 2023 14:06:55 +0000 (GMT) From: Joel Granados To: mcgrof@kernel.org, Kees Cook , Iurii Zaikin Cc: willy@infradead.org, josh@joshtriplett.org, Joel Granados , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 04/14] sysctl: Add size argument to init_header Date: Wed, 26 Jul 2023 16:06:24 +0200 Message-Id: <20230726140635.2059334-5-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230726140635.2059334-1-j.granados@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFKsWRmVeSWpSXmKPExsWy7djPc7r1GgdTDGY1qlos3f+Q0eL/gnyL M925Fnv2nmSxuLxrDpvFjQlPGS1+/wCylu30c+DwmN1wkcVjwaZSj80rtDxuvbb12LSqk82j b8sqRo/Pm+QC2KO4bFJSczLLUov07RK4Mj52b2EseCFcsW3iRbYGxiMCXYycHBICJhI7Zy5i BbGFBFYwSrxeHNHFyAVkf2GUaFpwnR3C+cwocaD3IxNMR+/pBywQieWMEuuP3maCcF4ySmz/ vJYdpIpNQEfi/Js7zF2MHBwiArESi6ekgISZBaYzSiyZIwNiCwvYS1xZeQ5sNYuAqsSMgysZ QWxeAVuJzitPmSGWyUu0XZ8OFucUsJNYufY7K0SNoMTJmU9YIGbKSzRvnc0McoOEwAkOiS/d bewQz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+xgtgsAqoSMw6uZASxeQVsJTqvPGWG2CAv0XZ9OlicU8BOYuXa72D1QkA1PVOf skPUC0qcnPmEBcRmBqpv3jqbeQKjwCwkqVlIUgsYmVYxiqSWFuem5xYb6hUn5haX5qXrJefn bmIExsm2Yz8372Cc9+qj3iFGJg7GQ4wSHMxKIryGMftShHhTEiurUovy44tKc1KLDzGaAt09 kVlKNDkfGKl5JfGGZgamhiZmlgamlmbGSuK8ngUdiUIC6YklqdmpqQWpRTB9TBycUg1MtUkb 4jfuLX+nGb44uf32h7fZazhnXChmkO6Lry3WiD97Yf50F5PdaQm7bDjC+Nzml/ren7TVLmNP y2+D/Q85/+ZM1JFxuOcZpTA/UtluAUvnZ/vzOnybC+as8z//iy2AY2nvNeuNPybuqSurfSSs aW+6J+NCX33POskVj6/ZqL6Je7V+0iWLpuUfrBOKI94IvNaN0L9zZ+7e0wqrZy3TE54mG+6s 6vb730OJBr3TBW9Yv5YmzVp3/r5WkflWJZsXbr/U+PaLOUnf/eyzbwFv4apjPaL+QZH+R2o/ Vy7kfLrku8W2eQ8ONK80dii4aPeI72bpjqemRx+flftsrPJNtPyMtG/L21jFe6JLf7BfVmIp zkg01GIuKk4EAH43s0ocAwAA X-CMS-MailID: 20230726140655eucas1p1c71c8de9edc8441b5262c936731b91a2 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20230726140655eucas1p1c71c8de9edc8441b5262c936731b91a2 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230726140655eucas1p1c71c8de9edc8441b5262c936731b91a2 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In this commit, the size of the ctl_table array is passed to initialize the ctl_table_size element in the ctl_table_header struct. Although ctl_table_size is not currently used, this step prepares us for when we begin traversing the ctl_table array with it. In __register_sysctl_table we use a calculated size until we add the size argument to that function. Signed-off-by: Joel Granados --- fs/proc/proc_sysctl.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 884460b0385b..fa1438f1a355 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -188,9 +188,10 @@ static void erase_entry(struct ctl_table_header *head, struct ctl_table *entry) static void init_header(struct ctl_table_header *head, struct ctl_table_root *root, struct ctl_table_set *set, - struct ctl_node *node, struct ctl_table *table) + struct ctl_node *node, struct ctl_table *table, size_t table_size) { head->ctl_table = table; + head->ctl_table_size = table_size; head->ctl_table_arg = table; head->used = 0; head->count = 1; @@ -973,7 +974,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set, memcpy(new_name, name, namelen); table[0].procname = new_name; table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO; - init_header(&new->header, set->dir.header.root, set, node, table); + init_header(&new->header, set->dir.header.root, set, node, table, 1); return new; } @@ -1197,7 +1198,8 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ link_name += len; link++; } - init_header(links, dir->header.root, dir->header.set, node, link_table); + init_header(links, dir->header.root, dir->header.set, node, link_table, + head->ctl_table_size); links->nreg = nr_entries; return links; @@ -1372,7 +1374,7 @@ struct ctl_table_header *__register_sysctl_table( return NULL; node = (struct ctl_node *)(header + 1); - init_header(header, root, set, node, table); + init_header(header, root, set, node, table, nr_entries); if (sysctl_check_table(path, header)) goto fail; @@ -1537,7 +1539,7 @@ void setup_sysctl_set(struct ctl_table_set *set, { memset(set, 0, sizeof(*set)); set->is_seen = is_seen; - init_header(&set->dir.header, root, set, NULL, root_table); + init_header(&set->dir.header, root, set, NULL, root_table, 1); } void retire_sysctl_set(struct ctl_table_set *set) -- 2.30.2