From patchwork Fri Jun 2 11: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: 13265120 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 5E3DAC77B7A for ; Fri, 2 Jun 2023 11:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235637AbjFBLHD (ORCPT ); Fri, 2 Jun 2023 07:07:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235054AbjFBLHA (ORCPT ); Fri, 2 Jun 2023 07:07:00 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB7C9E5A for ; Fri, 2 Jun 2023 04:06:43 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230602110642euoutp02b19e8efd9398fe19450c26d69c63aa0a~k0tvts8gt3126531265euoutp02C for ; Fri, 2 Jun 2023 11:06:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230602110642euoutp02b19e8efd9398fe19450c26d69c63aa0a~k0tvts8gt3126531265euoutp02C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685704002; bh=dg1KPdqa1g30CQqgCK1VP5CwiQO47gFwHbWyH2hvLF4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=A5l5Dp0AsTr1RIc34FVHNsJfLaUAnmSusVxKX4qlpPDDurxAOdbh1gL/bxyZT60FW dRdjS4AmmB+5TM8/8NyzSsuCdKGehSeXb1pujSUbG5qikEDDFk6ZUNW3/MiShXO6cX CjZ9Ui6kS5VV9nwpGeUxyr6IFWJaId1SrKp8yUJw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602110642eucas1p25278f4b80e5bc361bc1250e3a0a178a9~k0tvex7YG0783007830eucas1p2J; Fri, 2 Jun 2023 11:06:42 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 49.67.11320.24DC9746; Fri, 2 Jun 2023 12:06:42 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602110641eucas1p1e2e92293c385e8083ed104dbb96aa68b~k0tvCWeV_0085500855eucas1p1d; Fri, 2 Jun 2023 11:06:41 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230602110641eusmtrp19ef6e4a22f40bb673b99d0be0320a9a5~k0tvB3wJ52194821948eusmtrp1R; Fri, 2 Jun 2023 11:06:41 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-69-6479cd42acc8 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C3.A9.10549.14DC9746; Fri, 2 Jun 2023 12:06:41 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230602110641eusmtip19329dc84f1680badc901c2cba72579b5~k0tu5IEoL3230032300eusmtip19; Fri, 2 Jun 2023 11:06:41 +0000 (GMT) Received: from localhost (106.210.248.205) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jun 2023 12:06:41 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 1/8] parport: plug a sysctl register leak Date: Fri, 2 Jun 2023 13:06:31 +0200 Message-ID: <20230602110638.789426-2-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602110638.789426-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.205] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOIsWRmVeSWpSXmKPExsWy7djPc7pOZytTDL4f5LPYs/cki8XlXXPY LKbfec9mcWPCU0YHFo9NqzrZPD5vkgtgiuKySUnNySxLLdK3S+DK+Lt/L2vBCtGKKbu+MDcw XhbsYuTkkBAwkeg9OYm1i5GLQ0hgBaPEge4LTBDOF0aJNW9Ps0M4nxklNjYcYIZpmfEDpmU5 o8TK53fY4KpefV/LDOFsYZRoWf+IFaSFTUBH4vybO2DtIgLiEidOb2YEKWIWmMAo0bfuF0sX IweHsIClRO9bSxCTRUBF4uo/H5ByXgEbiSfr37JBbJaXaLs+nRHE5hSwlTh0+gwbRI2gxMmZ T1hAbGagmuats5khbAmJgy9eQF2tLDFh3W9WCLtW4tSWW2B/Sggc4ZCY83ceE0TCRaL51AZ2 CFtY4tXxLVC2jMTpyT0sEA2TGSX2//vADuGsZpRY1vgVqttaouXKE6gOR4kn/9ezg3wjIcAn ceOtIMRFfBKTtk1nhgjzSnS0CU1gVJmF5IdZSH6YheSHBYzMqxjFU0uLc9NTi43yUsv1ihNz i0vz0vWS83M3MQLTxul/x7/sYFz+6qPeIUYmDsZDjBIczEoivEJh5SlCvCmJlVWpRfnxRaU5 qcWHGKU5WJTEebVtTyYLCaQnlqRmp6YWpBbBZJk4OKUamKyaXGtTZaV2vc42NbX4mdexpFko zX3WX237EpNMTz3XhuuPRVavvxBgt4z34KdI/qsdbxTumCoYvFo/dcI9rbm9FmEO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xHx7oT9jzoTT9 fUZg3h7bqxEa6+Q/HvjxVOeJ+XOv5SuaGjLOLNlvynVmlxPvUuVW+wCd2eYzdUS2LpOYJVBw JW2KzI5zj289XvmvewvPsVaT/4d8K/v4yhQ+x9hNi2PsvSq87LBBgIcv+/LYg9Y+pseCxbia J700mpd7zNqOnd/zFg+rxpm5v/bvvNI9PTZm+rQAuSxtxxOmznckPP+kKc5QYVFiKc5INNRi LipOBADcb+IRMQMAAA== X-CMS-MailID: 20230602110641eucas1p1e2e92293c385e8083ed104dbb96aa68b X-Msg-Generator: CA X-RootMTR: 20230602110641eucas1p1e2e92293c385e8083ed104dbb96aa68b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602110641eucas1p1e2e92293c385e8083ed104dbb96aa68b References: <20230602110638.789426-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org parport registers two sysctl directories in the parport_proc_register function but only one of them was getting unregistered in parport_proc_unregister. Keep track of both sysctl table headers and handle them together when (un)registering. Signed-off-by: Joel Granados --- drivers/parport/procfs.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index cbb1fb5127ce..0f2d2e1ee28e 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c @@ -257,14 +257,16 @@ PARPORT_MAX_SPINTIME_VALUE; struct parport_sysctl_table { - struct ctl_table_header *sysctl_header; + struct ctl_table_header *port_header; + struct ctl_table_header *devices_header; struct ctl_table vars[12]; struct ctl_table device_dir[2]; }; static const struct parport_sysctl_table parport_sysctl_template = { - .sysctl_header = NULL, - { + .port_header = NULL, + .devices_header = NULL, + { { .procname = "spintime", .data = NULL, @@ -429,7 +431,6 @@ parport_default_sysctl_table = { int parport_proc_register(struct parport *port) { struct parport_sysctl_table *t; - struct ctl_table_header *devices_h; char *tmp_dir_path; size_t tmp_path_len, port_name_len; int bytes_written, i, err = 0; @@ -464,8 +465,8 @@ int parport_proc_register(struct parport *port) err = -ENOENT; goto exit_free_tmp_dir_path; } - devices_h = register_sysctl(tmp_dir_path, t->device_dir); - if (devices_h == NULL) { + t->devices_header = register_sysctl(tmp_dir_path, t->device_dir); + if (t->devices_header == NULL) { err = -ENOENT; goto exit_free_tmp_dir_path; } @@ -478,8 +479,8 @@ int parport_proc_register(struct parport *port) goto unregister_devices_h; } - t->sysctl_header = register_sysctl(tmp_dir_path, t->vars); - if (t->sysctl_header == NULL) { + t->port_header = register_sysctl(tmp_dir_path, t->vars); + if (t->port_header == NULL) { err = -ENOENT; goto unregister_devices_h; } @@ -490,7 +491,7 @@ int parport_proc_register(struct parport *port) return 0; unregister_devices_h: - unregister_sysctl_table(devices_h); + unregister_sysctl_table(t->devices_header); exit_free_tmp_dir_path: kfree(tmp_dir_path); @@ -505,7 +506,8 @@ int parport_proc_unregister(struct parport *port) if (port->sysctl_table) { struct parport_sysctl_table *t = port->sysctl_table; port->sysctl_table = NULL; - unregister_sysctl_table(t->sysctl_header); + unregister_sysctl_table(t->devices_header); + unregister_sysctl_table(t->port_header); kfree(t); } return 0; From patchwork Fri Jun 2 11: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: 13265121 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 D243EC77B7A for ; Fri, 2 Jun 2023 11:07:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235799AbjFBLHO (ORCPT ); Fri, 2 Jun 2023 07:07:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235323AbjFBLHE (ORCPT ); Fri, 2 Jun 2023 07:07:04 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8311E63 for ; Fri, 2 Jun 2023 04:06:46 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230602110645euoutp018644b9c80c38267ba0bf378f49ae9b4f~k0tytLmhx0110301103euoutp015 for ; Fri, 2 Jun 2023 11:06:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230602110645euoutp018644b9c80c38267ba0bf378f49ae9b4f~k0tytLmhx0110301103euoutp015 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685704005; bh=gwuzFK21w1IOUF2ZGdDkpZFWv7+ktlTmNmcMNJTZlNE=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=lcErz3Znew6Cqgq6ClEyB0FClsY3UnYnjd0HLH70Qz3y2F9yhnV3JaRUXWBniT47r u++2iOnhmF0rlaTnXDYEx223Mo1dGpcbe+Xapd8uuLQnJ4NyJeM1bINIY+0PJCanCd 6NFT30IHbGkWNHfw2pOnXwiWNVjfSKBccKG3m+ec= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602110645eucas1p2443fb17acbed500c524607354f4e339f~k0tyoJ_Bo0783007830eucas1p2P; Fri, 2 Jun 2023 11:06:45 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 54.6A.42423.54DC9746; Fri, 2 Jun 2023 12:06:45 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602110645eucas1p1ee5f3fe8c849258d7773288e1607e183~k0tyREed30212702127eucas1p1U; Fri, 2 Jun 2023 11:06:45 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230602110645eusmtrp14019d1d594f4a33202fbe00e12e43d12~k0tyQn6No2194821948eusmtrp1Z; Fri, 2 Jun 2023 11:06:45 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-33-6479cd45188b Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 26.A9.10549.54DC9746; Fri, 2 Jun 2023 12:06:45 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230602110645eusmtip23cc9b3b71b8ced0fc78dfa05a342c3a8~k0tyGqxd_1061810618eusmtip2E; Fri, 2 Jun 2023 11:06:45 +0000 (GMT) Received: from localhost (106.210.248.205) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jun 2023 12:06:44 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 2/8] test_sysctl: Fix test metadata getters Date: Fri, 2 Jun 2023 13:06:32 +0200 Message-ID: <20230602110638.789426-3-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602110638.789426-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.205] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOIsWRmVeSWpSXmKPExsWy7djP87quZytTDK4eU7bYs/cki8XlXXPY LKbfec9mcWPCU0YHFo9NqzrZPD5vkgtgiuKySUnNySxLLdK3S+DKeHr9G3PBVqGKu31bmBoY u/m7GDk4JARMJO6csexi5OIQEljBKPH1SDcjhPOFU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GKu31bmBoYu/m7GDk5JARMJNbObmTsYuTi EBJYyiix8v0pRoiEjMTGL1dZIWxhiT/Xutggij4ySjQ+nssO4WxhlJjUtZ0FpIpNQEfi/Js7 zCC2iIC4xInTm8HGMgtMYJToW/cLrEhYwFpizspedhCbRUBFoufLciYQm1fARmLn3M1sEOvk JdquTwc7g1PAVuLQ6TNgcSGgmvVnLrBD1AtKnJz5BGwmM1B989bZzBC2hMTBFy+YIeYoS0xY 9xvqhVqJz3+fMU5gFJmFpH0WkvZZSNoXMDKvYhRJLS3OTc8tNtQrTswtLs1L10vOz93ECIyq bcd+bt7BOO/VR71DjEwcjIcYJTiYlUR4hcLKU4R4UxIrq1KL8uOLSnNSiw8xmgL9OZFZSjQ5 HxjXeSXxhmYGpoYmZpYGppZmxkrivJ4FHYlCAumJJanZqakFqUUwfUwcnFINTHvbb+lOuZwx 8UCp21Ffh3XC/zjC9E+0n+VWOxNoZPGZX4THp8u61nurXGRrc0yuZSO3n9L1CC5GnuyKx8vr ymM79+ln7LcM4jvPwiS2OfZMwK9Z2ht7BUskf2m/1FI3eMnqkyCS1+pTuavvCtPMHZaLNJsK hPMNeJbN9Zm1XG2BzPf84NKgqX1NH9q5G+S8tZdsCFzcnMYm1s7+WvzxeqFrV1rPeWeL3tBf PKPq44ETkgmXDy9teMX8RkpP7zVTQUVojF1I/OvJvw7pLO+5klkdPrE6ddNiXcaNIfvb1m96 qf9yUtDtY1VCRW/XVjlP+njqnfelM3NrVY0cD/z7r3p3Ik/qo1MzVz3MEDRWYinOSDTUYi4q TgQApbbyXDMDAAA= X-CMS-MailID: 20230602110645eucas1p1ee5f3fe8c849258d7773288e1607e183 X-Msg-Generator: CA X-RootMTR: 20230602110645eucas1p1ee5f3fe8c849258d7773288e1607e183 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602110645eucas1p1ee5f3fe8c849258d7773288e1607e183 References: <20230602110638.789426-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The functions get_test_{count,enabled,target} use awk to get the N'th field in the ALL_TESTS variable. A variable with leading zeros (e.g. 0009) is misinterpreted as an entire line instead of the N'th field. Remove the leading zeros so this does not happen. We can now use the helper in tests 6, 7 and 8. Signed-off-by: Joel Granados --- tools/testing/selftests/sysctl/sysctl.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh index bfc54b422f25..cb8f83dfe16b 100755 --- a/tools/testing/selftests/sysctl/sysctl.sh +++ b/tools/testing/selftests/sysctl/sysctl.sh @@ -730,7 +730,7 @@ sysctl_test_0005() sysctl_test_0006() { - TARGET="${SYSCTL}/bitmap_0001" + TARGET="${SYSCTL}/$(get_test_target 0006)" reset_vals ORIG="" run_bitmaptest @@ -738,7 +738,7 @@ sysctl_test_0006() sysctl_test_0007() { - TARGET="${SYSCTL}/boot_int" + TARGET="${SYSCTL}/$(get_test_target 0007)" if [ ! -f $TARGET ]; then echo "Skipping test for $TARGET as it is not present ..." return $ksft_skip @@ -778,7 +778,7 @@ sysctl_test_0007() sysctl_test_0008() { - TARGET="${SYSCTL}/match_int" + TARGET="${SYSCTL}/$(get_test_target 0008)" if [ ! -f $TARGET ]; then echo "Skipping test for $TARGET as it is not present ..." return $ksft_skip @@ -857,25 +857,32 @@ function test_num() usage fi } +function remove_leading_zeros() +{ + echo $1 | sed 's/^0*//' +} function get_test_count() { test_num $1 - TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$1'}') + awk_field=$(remove_leading_zeros $1) + TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$awk_field'}') echo ${TEST_DATA} | awk -F":" '{print $2}' } function get_test_enabled() { test_num $1 - TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$1'}') + awk_field=$(remove_leading_zeros $1) + TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$awk_field'}') echo ${TEST_DATA} | awk -F":" '{print $3}' } function get_test_target() { test_num $1 - TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$1'}') + awk_field=$(remove_leading_zeros $1) + TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$awk_field'}') echo ${TEST_DATA} | awk -F":" '{print $4}' } From patchwork Fri Jun 2 11: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: 13265123 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 06860C7EE24 for ; Fri, 2 Jun 2023 11:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235901AbjFBLHg (ORCPT ); Fri, 2 Jun 2023 07:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235847AbjFBLH0 (ORCPT ); Fri, 2 Jun 2023 07:07:26 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C70D1BD for ; Fri, 2 Jun 2023 04:07:01 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230602110647euoutp024c8d01f22cd46006ea1e7be678114c90~k0t0DqSN-2929129291euoutp02v for ; Fri, 2 Jun 2023 11:06:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230602110647euoutp024c8d01f22cd46006ea1e7be678114c90~k0t0DqSN-2929129291euoutp02v DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685704007; bh=hYhRLkPi8FoDCUTYM89A2RNac7EIMazIQAo5IMuTC+s=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=F+57COksDqKZDi9A2lx6QJL9Yj7wZ4Sw+rw2cAUwYlNDrjcRTMPcjF8Ty4XEwVn12 Xpz7SKanbB/wxdTwzMhkcWPl+sdDFGmSIC1tnns1mV8uYocjdp1M4V1vxvp4HBuw42 i3eNRYuKjLZOBTj9ATfCwB6gEvmRaZ2vrYE5G5Js= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602110647eucas1p227c666ec3d609dbb8f6e79cc0a905259~k0tz1tsdT2051020510eucas1p2a; Fri, 2 Jun 2023 11:06:46 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 7E.7F.37758.64DC9746; Fri, 2 Jun 2023 12:06:46 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602110646eucas1p115dd1191419eb10bca47c9a6eefa6450~k0tzlCui_0212702127eucas1p1V; Fri, 2 Jun 2023 11:06:46 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230602110646eusmtrp2700e84b8f332ee8e4b33ed0517dc2f76~k0tzkj-cx2226722267eusmtrp2J; Fri, 2 Jun 2023 11:06:46 +0000 (GMT) X-AuditID: cbfec7f5-815ff7000002937e-8a-6479cd464dc5 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 3F.DB.14344.64DC9746; Fri, 2 Jun 2023 12:06:46 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230602110646eusmtip2e919595238ac8b6993427301d6341e89~k0tzaxyaX1061810618eusmtip2F; Fri, 2 Jun 2023 11:06:46 +0000 (GMT) Received: from localhost (106.210.248.205) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jun 2023 12:06:45 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 3/8] test_sysctl: Group node sysctl test under one func Date: Fri, 2 Jun 2023 13:06:33 +0200 Message-ID: <20230602110638.789426-4-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602110638.789426-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.205] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOIsWRmVeSWpSXmKPExsWy7djP87puZytTDJZutrLYs/cki8XlXXPY LKbfec9mcWPCU0YHFo9NqzrZPD5vkgtgiuKySUnNySxLLdK3S+DKuDatn7XgEXfFvRvvGBsY r3F2MXJwSAiYSEy9ztPFyMUhJLCCUeLLrkNsEM4XRokP6zuYIZzPjBJrLrxm72LkBOtY+2oV C0RiOaPE9SPL2eCq7sw6ApXZwihx5PYqVpAWNgEdifNv7jCD2CIC4hInTm9mBCliFpjAKNG3 7hcLSEJYwF2ibfk/NhCbRUBFovHfbSYQm1fARmL2ni5miN3yEm3XpzOC2JwCthKHTp9hg6gR lDg58wnYHGagmuats5khbAmJgy9eQPUqS0xY95sVwq6VOLXlFhOEfYBDYv0VfQjbReLTxDVQ cWGJV8e3QP0sI/F/53wmkKMlBCYzSuz/94EdwlnNKLGs8StUh7VEy5UnUB2OEtcuLGKHhDGf xI23ghAH8UlM2jadGSLMK9HRJjSBUWUWkhdmIXlhFpIXFjAyr2IUTy0tzk1PLTbOSy3XK07M LS7NS9dLzs/dxAhMG6f/Hf+6g3HFq496hxiZOBgPMUpwMCuJ8AqFlacI8aYkVl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1cBUeTf/ZVjhzWMH tzmpGcYdPp6qdVg1PZHpiTLLjx86XAa3HHeyhXp0pCie9dvpmRaTfDInfqK1l3iZeti7WEG/ e7yLiq/9Xrf+6qtFj59yfH/Vn17Hs0a3bjp7zZHDhdvt/Te1aF+2z4uMzXR1YAio2PxfL5zv 6urClTcFO3q7+79rvP9TLCIzz3Prgp1ul6Yw+/zZxL33+5NvlzTvuyhICV1acmTjNpuCnfyp 0jFn7ZSuN5sLFT+r+3FWZt7x1jcrth42KXHae8GtNDvmTHRtgeDRoKuZP81zytmFeIRMbicF vHFb/+PLh9cqWzdM1JeytVvL2G61/5OI77nNf6Ys5dv87y3jk8i+4rVcd+2VWIozEg21mIuK EwE0f9g5MwMAAA== X-CMS-MailID: 20230602110646eucas1p115dd1191419eb10bca47c9a6eefa6450 X-Msg-Generator: CA X-RootMTR: 20230602110646eucas1p115dd1191419eb10bca47c9a6eefa6450 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602110646eucas1p115dd1191419eb10bca47c9a6eefa6450 References: <20230602110638.789426-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Preparation commit to add a new type of test to test_sysctl.c. We want to differentiate between node and (sub)directory tests. Signed-off-by: Joel Granados --- lib/test_sysctl.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c index e2a816d85ea2..0cf7c547d61a 100644 --- a/lib/test_sysctl.c +++ b/lib/test_sysctl.c @@ -126,9 +126,7 @@ static struct ctl_table test_table[] = { { } }; -static struct ctl_table_header *test_sysctl_header; - -static int __init test_sysctl_init(void) +static void test_sysctl_calc_match_int_ok(void) { int i; @@ -153,7 +151,13 @@ static int __init test_sysctl_init(void) for (i = 0; i < ARRAY_SIZE(match_int); i++) if (match_int[i].defined != match_int[i].wanted) match_int_ok = 0; +} +static struct ctl_table_header *test_sysctl_header; + +static int test_sysctl_setup_node_tests(void) +{ + test_sysctl_calc_match_int_ok(); test_data.bitmap_0001 = kzalloc(SYSCTL_TEST_BITMAP_SIZE/8, GFP_KERNEL); if (!test_data.bitmap_0001) return -ENOMEM; @@ -162,8 +166,18 @@ static int __init test_sysctl_init(void) kfree(test_data.bitmap_0001); return -ENOMEM; } + return 0; } + +static int __init test_sysctl_init(void) +{ + int err; + + err = test_sysctl_setup_node_tests(); + + return err; +} module_init(test_sysctl_init); static void __exit test_sysctl_exit(void) From patchwork Fri Jun 2 11:06:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13265122 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 49F32C77B7A for ; Fri, 2 Jun 2023 11:07:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235842AbjFBLH0 (ORCPT ); Fri, 2 Jun 2023 07:07:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235107AbjFBLHN (ORCPT ); Fri, 2 Jun 2023 07:07:13 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02DBF198 for ; Fri, 2 Jun 2023 04:06:51 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230602110649euoutp01f142d0f3d3d96b6e0e5939c327297d16~k0t2foYJ10043200432euoutp01e for ; Fri, 2 Jun 2023 11:06:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230602110649euoutp01f142d0f3d3d96b6e0e5939c327297d16~k0t2foYJ10043200432euoutp01e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685704009; bh=f1HjrLD6njVVPjduaddJfi5+Ds9joRkOIy3esLq1bnY=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=k0PEgADhvo9GS/8EziJJ8+YBDRBajjsrbEBycS2y3yquOZqIH/7/yezUD5rIA2oBj SkfPi0x0Slsy9VUBzRSI7D0JAaM3EKB6GRXf/qJa81xdmukBg1zs2WNTytDVoaMDsz WAyje9wOMKFrKEG2tyyx/rDdC6jghlVqjfzaaEms= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602110649eucas1p28840581b7ed263d9183eb206ae73eb8b~k0t2PEHvj3164631646eucas1p2s; Fri, 2 Jun 2023 11:06:49 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id F0.77.11320.94DC9746; Fri, 2 Jun 2023 12:06:49 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602110649eucas1p1fc4db9a31735ed13e14c3142e1edb23b~k0t2AAFU52550025500eucas1p1s; Fri, 2 Jun 2023 11:06:49 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230602110649eusmtrp117f0da1caa43f6460c75da86d68d59c4~k0t1-iGSw2194821948eusmtrp1l; Fri, 2 Jun 2023 11:06:49 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-85-6479cd49faef Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id BA.A9.10549.94DC9746; Fri, 2 Jun 2023 12:06:49 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230602110649eusmtip129b8cc86ce1cff9465c3b2643e67ef54~k0t1yIPZj0530205302eusmtip1U; Fri, 2 Jun 2023 11:06:49 +0000 (GMT) Received: from localhost (106.210.248.205) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jun 2023 12:06:48 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 4/8] test_sysctl: Add an unregister sysctl test Date: Fri, 2 Jun 2023 13:06:34 +0200 Message-ID: <20230602110638.789426-5-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602110638.789426-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.205] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJIsWRmVeSWpSXmKPExsWy7djP87qeZytTDO5uU7DYs/cki8XlXXPY LKbfec9mcWPCU0YHFo9NqzrZPD5vkgtgiuKySUnNySxLLdK3S+DKONSyhLHgtEjFqv67LA2M bwS6GDk5JARMJPq2v2bqYuTiEBJYwSjxr2cNI4TzhVHi56OtUM5nRom3H1qYYFrWdJ1kgUgs Z5R4f+koC1zVx/+rWSGcLYwStyavYQdpYRPQkTj/5g4ziC0iIC5x4vRmsLnMAhMYJfrW/WIB SQgL2EvMO3YNbAeLgIrEqRuzWEFsXgEbidnH1rBC7JaXaLs+nRHE5hSwlTh0+gwbRI2gxMmZ T8DmMAPVNG+dzQxhS0gcfPGCGaJXWWLCut9Qc2olTm25Bfa2hMARDombT3dAFblIND7+yghh C0u8Or6FHcKWkTg9uYcFomEyo8T+fx/YIZzVjBLLGr9Cg8ZaouXKE6gOR4l/57uAbA4gm0/i xltBiIv4JCZtm84MEeaV6GgTmsCoM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zFKcDArifAKhZWnCPGmJFZWpRblxxeV5qQWH2I0BfpzIrOUaHI+ MKrzSuINzQxMDU3MLA1MLc2MlcR5PQs6EoUE0hNLUrNTUwtSi2D6mDg4pRqYVI/r7353sMEn d5PRV/ZF0x0WfNm58vqKvtVyrMus9qbErH7V15Zzj/uVEOfaR8cWZ54wMHor0Rn0SurBs3PZ pRt6FTg+McUcvT7T8f/6lTGyrzYxiqixT1sfaPsuenXG8oSFC900ptzdp/m22cP47e8/a648 1pogs1Fq7uUNs8xWn67YmbpKszS3cuLynGcM1ycuX78r70jAw8jLmZfDOh47pof3r9A9yOw5 cwmzBv+xKzvrEx6xu8xS8+eTnbm0Xujig5O60bYB388s/lB/vmvDPOabu+VmxytYsufzTX5m cvXpbJn+qK9la4r1T3ZrXDvW3yr4KOfeUj7zf66uco+l7874p84h9uCtzdwdopuUWIozEg21 mIuKEwEfEtWDMgMAAA== X-CMS-MailID: 20230602110649eucas1p1fc4db9a31735ed13e14c3142e1edb23b X-Msg-Generator: CA X-RootMTR: 20230602110649eucas1p1fc4db9a31735ed13e14c3142e1edb23b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602110649eucas1p1fc4db9a31735ed13e14c3142e1edb23b References: <20230602110638.789426-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add a test that checks that the unregistered directory is removed from /proc/sys/debug Signed-off-by: Joel Granados --- lib/test_sysctl.c | 30 ++++++++++++++++++++++++ tools/testing/selftests/sysctl/sysctl.sh | 16 +++++++++++++ 2 files changed, 46 insertions(+) diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c index 0cf7c547d61a..555244687443 100644 --- a/lib/test_sysctl.c +++ b/lib/test_sysctl.c @@ -170,12 +170,42 @@ static int test_sysctl_setup_node_tests(void) return 0; } +/* Used to test that unregister actually removes the directory */ +static struct ctl_table test_table_unregister[] = { + { + .procname = "unregister_error", + .data = &test_data.int_0001, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + }, + {} +}; + +static int test_sysctl_run_unregister_nested(void) +{ + struct ctl_table_header *unregister; + + unregister = register_sysctl("debug/test_sysctl/unregister_error", + test_table_unregister); + if (!unregister) + return -ENOMEM; + + unregister_sysctl_table(unregister); + return 0; +} + static int __init test_sysctl_init(void) { int err; err = test_sysctl_setup_node_tests(); + if (err) + goto out; + err = test_sysctl_run_unregister_nested(); + +out: return err; } module_init(test_sysctl_init); diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh index cb8f83dfe16b..a6d79d7a36e4 100755 --- a/tools/testing/selftests/sysctl/sysctl.sh +++ b/tools/testing/selftests/sysctl/sysctl.sh @@ -31,6 +31,7 @@ ALL_TESTS="$ALL_TESTS 0005:3:1:int_0003" ALL_TESTS="$ALL_TESTS 0006:50:1:bitmap_0001" ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int" ALL_TESTS="$ALL_TESTS 0008:1:1:match_int" +ALL_TESTS="$ALL_TESTS 0009:1:1:unregister_error" function allow_user_defaults() { @@ -797,6 +798,20 @@ sysctl_test_0008() return 0 } +sysctl_test_0009() +{ + TARGET="${SYSCTL}/$(get_test_target 0009)" + echo -n "Testing if $TARGET unregistered correctly ..." + if [ -d $TARGET ]; then + echo "TEST FAILED" + rc=1 + test_rc + fi + + echo "ok" + return 0 +} + list_tests() { echo "Test ID list:" @@ -813,6 +828,7 @@ list_tests() echo "0006 x $(get_test_count 0006) - tests proc_do_large_bitmap()" echo "0007 x $(get_test_count 0007) - tests setting sysctl from kernel boot param" echo "0008 x $(get_test_count 0008) - tests sysctl macro values match" + echo "0009 x $(get_test_count 0009) - tests sysct unregister" } usage() From patchwork Fri Jun 2 11:06:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13265125 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 4D755C7EE2E for ; Fri, 2 Jun 2023 11:07:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235862AbjFBLHk (ORCPT ); Fri, 2 Jun 2023 07:07:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235832AbjFBLH1 (ORCPT ); Fri, 2 Jun 2023 07:07:27 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA453E48 for ; Fri, 2 Jun 2023 04:07:02 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230602110651euoutp016afe011a2dd3895f4b86e897ef6071d2~k0t3xucm73253732537euoutp01Z for ; Fri, 2 Jun 2023 11:06:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230602110651euoutp016afe011a2dd3895f4b86e897ef6071d2~k0t3xucm73253732537euoutp01Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685704011; bh=bxclUZv9jPrQ5jKcyYEbND/Krq83dxgsRJ8rzENWdE8=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=nwgMTkPtOstQSgGbGvbFM77EiUqy78EItNzVChb35/ko9FezeXJDwfuzh3zsT9UG5 GMaQ6JYATiSCwlPEcdUn3xfNCf28D2lWPFNpALNWAPJH6/q0LFXlDD+hxQkpsTECHe CM+eAYQSWOfOX/3X4UJIWkE1LlYfuf186vPUzeAI= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230602110651eucas1p14e20bc6236c10d4fc8d6e271e60ffb79~k0t3rdCIa0212702127eucas1p1a; Fri, 2 Jun 2023 11:06:51 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 78.6A.42423.B4DC9746; Fri, 2 Jun 2023 12:06:51 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602110650eucas1p1e04fdac1151ed028d1d081cf30433174~k0t3Ycr2b2548925489eucas1p1m; Fri, 2 Jun 2023 11:06:50 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230602110650eusmtrp124d79e1d2067604f7bd0bfd887a8c663~k0t3X77E72194821948eusmtrp1o; Fri, 2 Jun 2023 11:06:50 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-44-6479cd4bf821 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id EB.A9.10549.A4DC9746; Fri, 2 Jun 2023 12:06:50 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230602110650eusmtip2aef1f882657ce0c13324aa492ba559cd~k0t3NbY5X0430104301eusmtip23; Fri, 2 Jun 2023 11:06:50 +0000 (GMT) Received: from localhost (106.210.248.205) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jun 2023 12:06:50 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 5/8] test_sysctl: Add an option to prevent test skip Date: Fri, 2 Jun 2023 13:06:35 +0200 Message-ID: <20230602110638.789426-6-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602110638.789426-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.205] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBIsWRmVeSWpSXmKPExsWy7djPc7reZytTDI7+ZLHYs/cki8XlXXPY LKbfec9mcWPCU0YHFo9NqzrZPD5vkgtgiuKySUnNySxLLdK3S+DKWHG3m6Xgn2zFuktP2RoY 70t0MXJySAiYSHRd3cfcxcjFISSwglHiUusGdgjnC6PE1i/fWCCcz4wSU5dOYYdpaTjykQ0i sZxRovfWNna4qlmNO1khnC2MEo8+rAJrYRPQkTj/5g4ziC0iIC5x4vRmRpAiZoEJjBJ9636x gCSEBVwkelp/MXUxcnCwCKhIHPljAhLmFbCR+L1xFTPEanmJtuvTGUFsTgFbiUOnz7BB1AhK nJz5BGwMM1BN89bZzBC2hMTBFy+gepUlJqz7zQph10qc2nKLCeQGCYEDHBLH5nQxQSRcJJr2 zmGEsIUlXh3fAvWzjMTpyT0sEA2TGSX2//vADuGsZpRY1vgVqttaouXKE6gOR4kPU1rZQL6R EOCTuPFWEOIiPolJ26YzQ4R5JTrahCYwqsxC8sMsJD/MQvLDAkbmVYziqaXFuempxYZ5qeV6 xYm5xaV56XrJ+bmbGIGJ4/S/4592MM599VHvECMTB+MhRgkOZiURXqGw8hQh3pTEyqrUovz4 otKc1OJDjNIcLErivNq2J5OFBNITS1KzU1MLUotgskwcnFINTLM+HwoWFrIwOnY8/Jaawkwv 3W+lfx8yLxbwsPy7vzP3TeP5s9ksLIWG7kcrj8Re31cu0fyIb+L5GQFrdtjeDhYWnqGwx2mb RczPuecWXC2rySyPtv36SOL77sLPLdfTlnxYmeWzPO2xxs9VVxJnPPibyuh6ZCbjbdWd2l8M 70Q9U109q8JXckX+g675JbszK7qniLY6fnu7O8TfZKbDpPmv0r4dbrOwcsv7+PS8/iSXzG3M VQ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l227nsG8jmWmbehxdyapbzvuc6/6 o+cyfVfYFuY5/UaT38yW50p1scq4HVjN7atyuIPRi/Va4u0jhQu0567YFqVSpMRSnJFoqMVc VJwIAMNhuCYxAwAA X-CMS-MailID: 20230602110650eucas1p1e04fdac1151ed028d1d081cf30433174 X-Msg-Generator: CA X-RootMTR: 20230602110650eucas1p1e04fdac1151ed028d1d081cf30433174 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602110650eucas1p1e04fdac1151ed028d1d081cf30433174 References: <20230602110638.789426-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Tests were being skipped because the target was not present. Add a flag that controls whether to skip a test based on the presence of the target. Actually skip tests in the test_case function with a "return" instead of a "continue". Signed-off-by: Joel Granados --- tools/testing/selftests/sysctl/sysctl.sh | 66 ++++++++++++++++-------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh index a6d79d7a36e4..9c0e9711138b 100755 --- a/tools/testing/selftests/sysctl/sysctl.sh +++ b/tools/testing/selftests/sysctl/sysctl.sh @@ -14,24 +14,26 @@ TEST_FILE=$(mktemp) # This represents # -# TEST_ID:TEST_COUNT:ENABLED:TARGET +# TEST_ID:TEST_COUNT:ENABLED:TARGET:SKIP_NO_TARGET # # TEST_ID: is the test id number # TEST_COUNT: number of times we should run the test # ENABLED: 1 if enabled, 0 otherwise # TARGET: test target file required on the test_sysctl module +# SKIP_NO_TARGET: 1 skip if TARGET not there +# 0 run eventhough TARGET not there # # Once these are enabled please leave them as-is. Write your own test, # we have tons of space. -ALL_TESTS="0001:1:1:int_0001" -ALL_TESTS="$ALL_TESTS 0002:1:1:string_0001" -ALL_TESTS="$ALL_TESTS 0003:1:1:int_0002" -ALL_TESTS="$ALL_TESTS 0004:1:1:uint_0001" -ALL_TESTS="$ALL_TESTS 0005:3:1:int_0003" -ALL_TESTS="$ALL_TESTS 0006:50:1:bitmap_0001" -ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int" -ALL_TESTS="$ALL_TESTS 0008:1:1:match_int" -ALL_TESTS="$ALL_TESTS 0009:1:1:unregister_error" +ALL_TESTS="0001:1:1:int_0001:1" +ALL_TESTS="$ALL_TESTS 0002:1:1:string_0001:1" +ALL_TESTS="$ALL_TESTS 0003:1:1:int_0002:1" +ALL_TESTS="$ALL_TESTS 0004:1:1:uint_0001:1" +ALL_TESTS="$ALL_TESTS 0005:3:1:int_0003:1" +ALL_TESTS="$ALL_TESTS 0006:50:1:bitmap_0001:1" +ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int:1" +ALL_TESTS="$ALL_TESTS 0008:1:1:match_int:1" +ALL_TESTS="$ALL_TESTS 0009:1:1:unregister_error:0" function allow_user_defaults() { @@ -614,7 +616,6 @@ target_exists() TEST_ID="$2" if [ ! -f ${TARGET} ] ; then - echo "Target for test $TEST_ID: $TARGET not exist, skipping test ..." return 0 fi return 1 @@ -902,16 +903,36 @@ function get_test_target() echo ${TEST_DATA} | awk -F":" '{print $4}' } +function get_test_skip_no_target() +{ + test_num $1 + awk_field=$(remove_leading_zeros $1) + TEST_DATA=$(echo $ALL_TESTS | awk '{print $'$awk_field'}') + echo ${TEST_DATA} | awk -F":" '{print $5}' +} + +function skip_test() +{ + TEST_ID=$1 + TEST_TARGET=$2 + if target_exists $TEST_TARGET $TEST_ID; then + TEST_SKIP=$(get_test_skip_no_target $TEST_ID) + if [[ $TEST_SKIP -eq "1" ]]; then + echo "Target for test $TEST_ID: $TEST_TARGET not exist, skipping test ..." + return 0 + fi + fi + return 1 +} + function run_all_tests() { for i in $ALL_TESTS ; do - TEST_ID=${i%:*:*:*} + TEST_ID=${i%:*:*:*:*} ENABLED=$(get_test_enabled $TEST_ID) TEST_COUNT=$(get_test_count $TEST_ID) TEST_TARGET=$(get_test_target $TEST_ID) - if target_exists $TEST_TARGET $TEST_ID; then - continue - fi + if [[ $ENABLED -eq "1" ]]; then test_case $TEST_ID $TEST_COUNT $TEST_TARGET fi @@ -946,18 +967,19 @@ function watch_case() function test_case() { + TEST_ID=$1 NUM_TESTS=$2 + TARGET=$3 - i=0 - - if target_exists $3 $1; then - continue + if skip_test $TEST_ID $TARGET; then + return fi + i=0 while [ $i -lt $NUM_TESTS ]; do - test_num $1 - watch_log $i ${TEST_NAME}_test_$1 noclear - RUN_TEST=${TEST_NAME}_test_$1 + test_num $TEST_ID + watch_log $i ${TEST_NAME}_test_${TEST_ID} noclear + RUN_TEST=${TEST_NAME}_test_${TEST_ID} $RUN_TEST let i=$i+1 done From patchwork Fri Jun 2 11:06:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13265127 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 A52F3C7EE24 for ; Fri, 2 Jun 2023 11:07:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235955AbjFBLHp (ORCPT ); Fri, 2 Jun 2023 07:07:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235542AbjFBLH1 (ORCPT ); Fri, 2 Jun 2023 07:07:27 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1D11E4C for ; Fri, 2 Jun 2023 04:07:05 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230602110654euoutp012c39f22392a9b8e16e166ba05d0df2e6~k0t6k6N2G0043200432euoutp01f for ; Fri, 2 Jun 2023 11:06:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230602110654euoutp012c39f22392a9b8e16e166ba05d0df2e6~k0t6k6N2G0043200432euoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685704014; bh=kfxf1qr5GWf+HXq/jSKKNVDlnExuNV1LXklo/nv5rro=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=qDbUlCYK5vteGCIvveFEhAOIKnOIZwIOxB1BgxJ64hzXNPxc6sBrHA4igyaR0HQaH x0VO1japVLfX6o76J/ShIIWGxJrThIiEibuTk0YGO+FCgOKemr2eSv9k4SopDGz4lp /LkxL3viu4qQV3aSWE+kGeVr+8E75esT+wgDNmcE= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230602110654eucas1p168408bec9728da4d94d35a3afe9e936e~k0t6cuSv-2550025500eucas1p1x; Fri, 2 Jun 2023 11:06:54 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 1A.6A.42423.D4DC9746; Fri, 2 Jun 2023 12:06:54 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602110653eucas1p19b1f6aac96a61c61e49af5738a0a11ff~k0t6I_-cd0823408234eucas1p1M; Fri, 2 Jun 2023 11:06:53 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230602110653eusmtrp23493124332f3a9b991bafc65ca7bf558~k0t6IexGM2226722267eusmtrp2Y; Fri, 2 Jun 2023 11:06:53 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-4e-6479cd4deb3a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E6.EB.14344.D4DC9746; Fri, 2 Jun 2023 12:06:53 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230602110653eusmtip117fecc7740d2420720213f1b1b20bde5~k0t6AF1NP0530205302eusmtip1X; Fri, 2 Jun 2023 11:06:53 +0000 (GMT) Received: from localhost (106.210.248.205) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jun 2023 12:06:52 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 6/8] test_sysclt: Test for registering a mount point Date: Fri, 2 Jun 2023 13:06:36 +0200 Message-ID: <20230602110638.789426-7-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602110638.789426-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.205] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOIsWRmVeSWpSXmKPExsWy7djPc7p+ZytTDI50Mlns2XuSxeLyrjls FtPvvGezuDHhKaMDi8emVZ1sHp83yQUwRXHZpKTmZJalFunbJXBlPLv0ialgt3JF97eVrA2M x2W7GDk5JARMJBpefmMCsYUEVjBKXHwr2cXIBWR/YZRoP/EfKvGZUaL7oSBMw4pJs9ghipYz SvS/WckC4QAVbZ71B8rZwijxZuc8VpAWNgEdifNv7jCD2CIC4hInTm9mBCliFpjAKNG37hcL SEJYwEXi++S7YPtYBFQknu76ww5i8wrYSLya9pENYre8RNv16YwgNqeArcSh02fYIGoEJU7O fAI2hxmopnnrbGYIW0Li4IsXzBC9yhIT1v1mhbBrJU5tucUEcoSEwAEOickbT0MlXCTO7zgN tUxY4tXxLewQtozE/53zoRomM0rs//eBHcJZzSixrPEr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C0n7AkbmVYwiqaXFuem5xUZ6xYm5xaV56XrJ+bmbGIFR te3Yzy07GFe++qh3iJGJg/EQowQHs5IIr1BYeYoQb0piZVVqUX58UWlOavEhRlOgPycyS4km 5wPjOq8k3tDMwNTQxMzSwNTSzFhJnNezoCNRSCA9sSQ1OzW1ILUIpo+Jg1OqgSm+xeyq3Ky7 FZsbZv962cm2UUfj+4YfRxiX8WRFHCq+FPT4Xxh/QeDEjanHOsS9Xs0L2+TGxt08cfb6kKh7 96v1j7XFLmVdM8t+K1+TnZfvc+ePj0W8p9ue8kjZbzn7dGHTWy6+lGfsbVvzJNYufT+f84XW a8cp64V3vRKYxjQlcseU/zPOlrrL+K5eJ5Qu8/7alpYFgfbaSZq5FxbXLGn94y2/w7tAjoux 3UpxwZU1/DwdrXczok22LWRMMf+UeujOw+LmPIupkp1bj//LcPRJ+h+6Lv94RnN/9KIJrone Ntz5d/Y+25ijE9BSHS/sVlmsOOdI3ouOs0d/6fktC/GMaLENqFH6Hhf78L/ydSWW4oxEQy3m ouJEAGm23/AzAwAA X-CMS-MailID: 20230602110653eucas1p19b1f6aac96a61c61e49af5738a0a11ff X-Msg-Generator: CA X-RootMTR: 20230602110653eucas1p19b1f6aac96a61c61e49af5738a0a11ff X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602110653eucas1p19b1f6aac96a61c61e49af5738a0a11ff References: <20230602110638.789426-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Test that target gets created by register_sysctl_mount_point and that no additional target can be created "on top" of a permanently empty sysctl table. Create a mount point target (mnt) in the sysctl test driver; try to create another on top of that (mnt_error). Output an error if "mnt_error" is present when we run the sysctl selftests. Signed-off-by: Joel Granados --- lib/test_sysctl.c | 45 ++++++++++++++++++++---- tools/testing/selftests/sysctl/sysctl.sh | 16 +++++++++ 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c index 555244687443..8036aa91a1cb 100644 --- a/lib/test_sysctl.c +++ b/lib/test_sysctl.c @@ -30,6 +30,13 @@ static int i_zero; static int i_one_hundred = 100; static int match_int_ok = 1; + +static struct { + struct ctl_table_header *test_h_setup_node; + struct ctl_table_header *test_h_mnt; + struct ctl_table_header *test_h_mnterror; +} sysctl_test_headers; + struct test_sysctl_data { int int_0001; int int_0002; @@ -153,16 +160,14 @@ static void test_sysctl_calc_match_int_ok(void) match_int_ok = 0; } -static struct ctl_table_header *test_sysctl_header; - static int test_sysctl_setup_node_tests(void) { test_sysctl_calc_match_int_ok(); test_data.bitmap_0001 = kzalloc(SYSCTL_TEST_BITMAP_SIZE/8, GFP_KERNEL); if (!test_data.bitmap_0001) return -ENOMEM; - test_sysctl_header = register_sysctl("debug/test_sysctl", test_table); - if (!test_sysctl_header) { + sysctl_test_headers.test_h_setup_node = register_sysctl("debug/test_sysctl", test_table); + if (!sysctl_test_headers.test_h_setup_node) { kfree(test_data.bitmap_0001); return -ENOMEM; } @@ -195,6 +200,26 @@ static int test_sysctl_run_unregister_nested(void) return 0; } +static int test_sysctl_run_register_mount_point(void) +{ + sysctl_test_headers.test_h_mnt + = register_sysctl_mount_point("debug/test_sysctl/mnt"); + if (!sysctl_test_headers.test_h_mnt) + return -ENOMEM; + + sysctl_test_headers.test_h_mnterror + = register_sysctl("debug/test_sysctl/mnt/mnt_error", + test_table_unregister); + /* + * Don't check the result.: + * If it fails (expected behavior), return 0. + * If successful (missbehavior of register mount point), we want to see + * mnt_error when we run the sysctl test script + */ + + return 0; +} + static int __init test_sysctl_init(void) { int err; @@ -204,6 +229,10 @@ static int __init test_sysctl_init(void) goto out; err = test_sysctl_run_unregister_nested(); + if (err) + goto out; + + err = test_sysctl_run_register_mount_point(); out: return err; @@ -213,8 +242,12 @@ module_init(test_sysctl_init); static void __exit test_sysctl_exit(void) { kfree(test_data.bitmap_0001); - if (test_sysctl_header) - unregister_sysctl_table(test_sysctl_header); + if (sysctl_test_headers.test_h_setup_node) + unregister_sysctl_table(sysctl_test_headers.test_h_setup_node); + if (sysctl_test_headers.test_h_mnt) + unregister_sysctl_table(sysctl_test_headers.test_h_mnt); + if (sysctl_test_headers.test_h_mnterror) + unregister_sysctl_table(sysctl_test_headers.test_h_mnterror); } module_exit(test_sysctl_exit); diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh index 9c0e9711138b..444b2befda82 100755 --- a/tools/testing/selftests/sysctl/sysctl.sh +++ b/tools/testing/selftests/sysctl/sysctl.sh @@ -34,6 +34,7 @@ ALL_TESTS="$ALL_TESTS 0006:50:1:bitmap_0001:1" ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int:1" ALL_TESTS="$ALL_TESTS 0008:1:1:match_int:1" ALL_TESTS="$ALL_TESTS 0009:1:1:unregister_error:0" +ALL_TESTS="$ALL_TESTS 0010:1:1:mnt/mnt_error:0" function allow_user_defaults() { @@ -813,6 +814,20 @@ sysctl_test_0009() return 0 } +sysctl_test_0010() +{ + TARGET="${SYSCTL}/$(get_test_target 0010)" + echo -n "Testing that $TARGET was not created ..." + if [ -d $TARGET ]; then + echo "TEST FAILED" + rc=1 + test_rc + fi + + echo "ok" + return 0 +} + list_tests() { echo "Test ID list:" @@ -830,6 +845,7 @@ list_tests() echo "0007 x $(get_test_count 0007) - tests setting sysctl from kernel boot param" echo "0008 x $(get_test_count 0008) - tests sysctl macro values match" echo "0009 x $(get_test_count 0009) - tests sysct unregister" + echo "0010 x $(get_test_count 0010) - tests sysct mount point" } usage() From patchwork Fri Jun 2 11:06:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13265126 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 83876C7EE24 for ; Fri, 2 Jun 2023 11:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235849AbjFBLHm (ORCPT ); Fri, 2 Jun 2023 07:07:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235858AbjFBLH1 (ORCPT ); Fri, 2 Jun 2023 07:07:27 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0E36E4A for ; Fri, 2 Jun 2023 04:07:05 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230602110655euoutp0167029999c156d8b14d9b13b71c094865~k0t8AlBUu0189401894euoutp01t for ; Fri, 2 Jun 2023 11:06:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230602110655euoutp0167029999c156d8b14d9b13b71c094865~k0t8AlBUu0189401894euoutp01t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685704015; bh=k6w26tA5MuuVW167a8RaVYBvH9le+QbGGVR79rArU/4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=h8UHQj2/jVHqdxNAasLw3FBNzysehIA1ap5mRDIBZjzJzDX3Rvu7Sjl6PHcxRufE2 PMp89oVLf83knfN2tPL1NgTqB+YK+3M+mYUkozBYAPMrFRyjt2PAGAaDJBF6Y0KKOP OON3vcNMoqwwabRN1k1vI3lvxJjyaT+0RbJt3iu8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602110655eucas1p227675246ff808500707c7c36c19ed8a4~k0t73-8Gr2054620546eucas1p2e; Fri, 2 Jun 2023 11:06:55 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 96.8F.37758.F4DC9746; Fri, 2 Jun 2023 12:06:55 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602110655eucas1p158a37f974de602978a3307dc9e4a1356~k0t7qfo190085500855eucas1p1m; Fri, 2 Jun 2023 11:06:55 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230602110655eusmtrp2078bab60da58c0b9d3e545dc16bc4eb8~k0t7p-lp02226722267eusmtrp2f; Fri, 2 Jun 2023 11:06:55 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-a9-6479cd4f2f25 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 2A.EB.14344.F4DC9746; Fri, 2 Jun 2023 12:06:55 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230602110655eusmtip14bd9c332aca74c82127b8f77fbca7809~k0t7hYWXJ3230032300eusmtip1D; Fri, 2 Jun 2023 11:06:55 +0000 (GMT) Received: from localhost (106.210.248.205) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jun 2023 12:06:54 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 7/8] sysctl: Remove debugging dump_stack Date: Fri, 2 Jun 2023 13:06:37 +0200 Message-ID: <20230602110638.789426-8-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602110638.789426-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.205] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002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as1p158a37f974de602978a3307dc9e4a1356 X-Msg-Generator: CA X-RootMTR: 20230602110655eucas1p158a37f974de602978a3307dc9e4a1356 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602110655eucas1p158a37f974de602978a3307dc9e4a1356 References: <20230602110638.789426-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Remove unneeded dump_stack in __register_sysctl_table Signed-off-by: Joel Granados --- fs/proc/proc_sysctl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 8873812d22f3..07804097f997 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1406,7 +1406,6 @@ struct ctl_table_header *__register_sysctl_table( spin_unlock(&sysctl_lock); fail: kfree(header); - dump_stack(); return NULL; } From patchwork Fri Jun 2 11:06:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13265124 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 18105C7EE2C for ; Fri, 2 Jun 2023 11:07:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235859AbjFBLHj (ORCPT ); Fri, 2 Jun 2023 07:07:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235329AbjFBLH1 (ORCPT ); Fri, 2 Jun 2023 07:07:27 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21200E44 for ; Fri, 2 Jun 2023 04:07:02 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230602110658euoutp02b726e5c9572055b16390d652e475b7cd~k0t_rZL8g2929029290euoutp02y for ; Fri, 2 Jun 2023 11:06:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230602110658euoutp02b726e5c9572055b16390d652e475b7cd~k0t_rZL8g2929029290euoutp02y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685704018; bh=BhjlbE3l65EDbxXPKpYH+/IItCuSaglkyGpoc2fZJys=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=X0LTpbuqcSvbiXMG8CGVd2hMCiFANmN0MeNr9nHqf5XoJm0XPowTlO9Q39fGZsCww VYNpi/yndgc1369Xeb/TxQjIua+Zz5/gD72Hwb0UpzYmcH3UCVX7WF/P+iAQwScyo5 4hY8AAhHhkMuo17hdYwUhg74s6lqbCIm7csNdLy0= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602110658eucas1p27ccf28cedfee77b724984314dfce3c77~k0t_jdLpI2052120521eucas1p2d; Fri, 2 Jun 2023 11:06:58 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 97.77.11320.25DC9746; Fri, 2 Jun 2023 12:06:58 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230602110658eucas1p27d31eeac2417f9e19f8d4b6de012209b~k0t_KGxtF2052220522eucas1p2z; Fri, 2 Jun 2023 11:06:58 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230602110658eusmtrp19add2e18ca5bb2a26ee0cbd401c5a237~k0t_JjZpq2194821948eusmtrp12; Fri, 2 Jun 2023 11:06:58 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-9a-6479cd527b71 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 51.B9.10549.15DC9746; Fri, 2 Jun 2023 12:06:57 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230602110657eusmtip2922d74715e738263fbe99c2d1cb968c1~k0t9_p76L0244502445eusmtip27; Fri, 2 Jun 2023 11:06:57 +0000 (GMT) Received: from localhost (106.210.248.205) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jun 2023 12:06:57 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 8/8] sysctl: replace child with a flags var Date: Fri, 2 Jun 2023 13:06:38 +0200 Message-ID: <20230602110638.789426-9-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602110638.789426-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.205] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBIsWRmVeSWpSXmKPExsWy7djPc7pBZytTDCbdELfYs/cki8XlXXPY LKbfec9mcWPCU0YHFo9NqzrZPD5vkgtgiuKySUnNySxLLdK3S+DKeP5oEnPBUrOKJzevMzcw PtXpYuTkkBAwkbi2+AdzFyMXh5DACkaJ/QvWMEE4XxglDk7pZ4dwPjNKdE6ZwgzTcrxpHQtE YjmjxInFG5ngqn6v64FytjBKvGrbyQLSwiagI3H+zR2wdhEBcYkTpzczghQxC0xglOhb9wus SFjAWqL77xJGEJtFQEXi8rz5bCA2r4CNxI2Dx6F2y0u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fnzWcDsXkFbCRuHDzODLFO XqLt+nSwGk4BW4lDp8+A1QgB1aw/c4Edol5Q4uTMJ2AzmYHqm7fOZoawJSQOvngBNUdZYsK6 31Av1Ep8/vuMcQKjyCwk7bOQtM9C0r6AkXkVo0hqaXFuem6xoV5xYm5xaV66XnJ+7iZGYFRt O/Zz8w7Gea8+6h1iZOJgPMQowcGsJMIrFFaeIsSbklhZlVqUH19UmpNafIjRFOjPicxSosn5 wLjOK4k3NDMwNTQxszQwtTQzVhLn9SzoSBQSSE8sSc1OTS1ILYLpY+LglGpginw5ye355S9L uGIrg1zeNGxcsvXd9HMnnssv3H/lvMb0+25NC+qWTnlm/ibnk4tR4YokyTc8HH0Z0dryZX97 eUxWPtWdx8T8nOOL3qevLZ+8zmdutvZf+fBszJLWn01PHkY/ePQ86quTZ9Zzbd4TZ1mlTmxb IvB88ksTN+WfH9e2VDGszSjfFZ7ZwL8p6u7e7N7dM2vefrvdVm3fE/9+Web7+cddz4nFB/6x n728oJ/Drzdqe98sHb5vOxLcLHmfbLr8tcaH/YzSRo+rNondu5p0ZbYLunrd57/pOq9+6qNk fl2VTon8Dc84WWapB86qKZB8uNGwvFzebY7TLY/g4/MqE4qmHPup91QltD4gQomlOCPRUIu5 qDgRABcI0OAzAwAA X-CMS-MailID: 20230602110658eucas1p27d31eeac2417f9e19f8d4b6de012209b X-Msg-Generator: CA X-RootMTR: 20230602110658eucas1p27d31eeac2417f9e19f8d4b6de012209b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602110658eucas1p27d31eeac2417f9e19f8d4b6de012209b References: <20230602110638.789426-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is part of the effort to remove the empty element at the end of ctl_table structs. "child" was a deprecated elem in this struct and was being used to differentiate between two types of ctl_tables: "normal" and "permanently emtpy". What changed?: * Replace "child" with a u8 "flag" variable and use it to differentiate between types by refactoring the permanently empty helper functions. * Remove the "empty child" check from sysctl_check_table * Remove count_subheaders function as there is no longer a need to calculate how many headers there are for every child * Remove the recursive call to unregister_sysctl_table as there is no need to traverse down the child tree any longer * Add a new SYSCTL_PERM_EMPTY_DIR binary flag * Remove the last remanence of child from partport/procfs.c Signed-off-by: Joel Granados --- drivers/parport/procfs.c | 1 - fs/proc/proc_sysctl.c | 81 +++++++++------------------------------- include/linux/sysctl.h | 4 +- 3 files changed, 20 insertions(+), 66 deletions(-) diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c index 0f2d2e1ee28e..4e5b972c3e26 100644 --- a/drivers/parport/procfs.c +++ b/drivers/parport/procfs.c @@ -387,7 +387,6 @@ parport_device_sysctl_template = { .data = NULL, .maxlen = 0, .mode = 0555, - .child = NULL }, {} } diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 07804097f997..a180bc952397 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -29,9 +29,8 @@ static const struct file_operations proc_sys_dir_file_operations; static const struct inode_operations proc_sys_dir_operations; /* Support for permanently empty directories */ - struct ctl_table sysctl_mount_point[] = { - { } + {.flags = SYSCTL_PERM_EMPTY_DIR } }; /** @@ -48,21 +47,14 @@ struct ctl_table_header *register_sysctl_mount_point(const char *path) } EXPORT_SYMBOL(register_sysctl_mount_point); -static bool is_empty_dir(struct ctl_table_header *head) -{ - return head->ctl_table[0].child == sysctl_mount_point; -} - -static void set_empty_dir(struct ctl_dir *dir) -{ - dir->header.ctl_table[0].child = sysctl_mount_point; -} - -static void clear_empty_dir(struct ctl_dir *dir) - -{ - dir->header.ctl_table[0].child = NULL; -} +#define sysctl_is_perm_empty_ctl_table(tptr) \ + (tptr[0].flags & SYSCTL_PERM_EMPTY_DIR) +#define sysctl_is_perm_empty_ctl_header(hptr) \ + (sysctl_is_perm_empty_ctl_table(hptr->ctl_table)) +#define sysctl_set_perm_empty_ctl_header(hptr) \ + (hptr->ctl_table[0].flags |= SYSCTL_PERM_EMPTY_DIR) +#define sysctl_clear_perm_empty_ctl_header(hptr) \ + (hptr->ctl_table[0].flags &= ~SYSCTL_PERM_EMPTY_DIR) void proc_sys_poll_notify(struct ctl_table_poll *poll) { @@ -230,20 +222,22 @@ static void erase_header(struct ctl_table_header *head) static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) { struct ctl_table *entry; + struct ctl_table_header *dir_h = &dir->header; int err; + /* Is this a permanently empty directory? */ - if (is_empty_dir(&dir->header)) + if (sysctl_is_perm_empty_ctl_header(dir_h)) return -EROFS; /* Am I creating a permanently empty directory? */ - if (header->ctl_table == sysctl_mount_point) { + if (sysctl_is_perm_empty_ctl_table(header->ctl_table)) { if (!RB_EMPTY_ROOT(&dir->root)) return -EINVAL; - set_empty_dir(dir); + sysctl_set_perm_empty_ctl_header(dir_h); } - dir->header.nreg++; + dir_h->nreg++; header->parent = dir; err = insert_links(header); if (err) @@ -259,9 +253,9 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header) put_links(header); fail_links: if (header->ctl_table == sysctl_mount_point) - clear_empty_dir(dir); + sysctl_clear_perm_empty_ctl_header(dir_h); header->parent = NULL; - drop_sysctl_table(&dir->header); + drop_sysctl_table(dir_h); return err; } @@ -479,7 +473,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, inode->i_mode |= S_IFDIR; inode->i_op = &proc_sys_dir_operations; inode->i_fop = &proc_sys_dir_file_operations; - if (is_empty_dir(head)) + if (sysctl_is_perm_empty_ctl_header(head)) make_empty_dir_inode(inode); } @@ -1136,9 +1130,6 @@ static int sysctl_check_table(const char *path, struct ctl_table *table) struct ctl_table *entry; int err = 0; list_for_each_table_entry(entry, table) { - if (entry->child) - err |= sysctl_err(path, entry, "Not a file"); - if ((entry->proc_handler == proc_dostring) || (entry->proc_handler == proc_dobool) || (entry->proc_handler == proc_dointvec) || @@ -1465,25 +1456,6 @@ void __init __register_sysctl_init(const char *path, struct ctl_table *table, kmemleak_not_leak(hdr); } -static int count_subheaders(struct ctl_table *table) -{ - int has_files = 0; - int nr_subheaders = 0; - struct ctl_table *entry; - - /* special case: no directory and empty directory */ - if (!table || !table->procname) - return 1; - - list_for_each_table_entry(entry, table) { - if (entry->child) - nr_subheaders += count_subheaders(entry->child); - else - has_files = 1; - } - return nr_subheaders + has_files; -} - static void put_links(struct ctl_table_header *header) { struct ctl_table_set *root_set = &sysctl_table_root.default_set; @@ -1546,28 +1518,11 @@ static void drop_sysctl_table(struct ctl_table_header *header) */ void unregister_sysctl_table(struct ctl_table_header * header) { - int nr_subheaders; might_sleep(); if (header == NULL) return; - nr_subheaders = count_subheaders(header->ctl_table_arg); - if (unlikely(nr_subheaders > 1)) { - struct ctl_table_header **subheaders; - int i; - - subheaders = (struct ctl_table_header **)(header + 1); - for (i = nr_subheaders -1; i >= 0; i--) { - struct ctl_table_header *subh = subheaders[i]; - struct ctl_table *table = subh->ctl_table_arg; - unregister_sysctl_table(subh); - kfree(table); - } - kfree(header); - return; - } - spin_lock(&sysctl_lock); drop_sysctl_table(header); spin_unlock(&sysctl_lock); diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 653b66c762b1..0cd79a7f1d3e 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -137,7 +137,7 @@ struct ctl_table { void *data; int maxlen; umode_t mode; - struct ctl_table *child; /* Deprecated */ + u8 flags; proc_handler *proc_handler; /* Callback for text formatting */ struct ctl_table_poll *poll; void *extra1; @@ -229,7 +229,7 @@ extern int unaligned_enabled; extern int unaligned_dump_stack; extern int no_unaligned_warning; -extern struct ctl_table sysctl_mount_point[]; +#define SYSCTL_PERM_EMPTY_DIR (1 << 0) #else /* CONFIG_SYSCTL */