From patchwork Fri Jun 16 08:59:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13282324 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 7DF44EB64D8 for ; Fri, 16 Jun 2023 08:59:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245314AbjFPI7e (ORCPT ); Fri, 16 Jun 2023 04:59:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244839AbjFPI7c (ORCPT ); Fri, 16 Jun 2023 04:59:32 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 264531FEC for ; Fri, 16 Jun 2023 01:59:30 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230616085928euoutp014831e10a3257e5e67d7dd3b6ae5db970~pGAplDNbL0219502195euoutp01X for ; Fri, 16 Jun 2023 08:59:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230616085928euoutp014831e10a3257e5e67d7dd3b6ae5db970~pGAplDNbL0219502195euoutp01X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1686905968; bh=dg1KPdqa1g30CQqgCK1VP5CwiQO47gFwHbWyH2hvLF4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=VwbANNbpWrZru++AVnexz+2JjOlPP/TkCVDCFtPigSwiRq2kkRx0S8rDHzXNqhzeB y/OohgInSBnExpD7FDI5L6QXGoDAM+SbK64bDy82WpcSRdRVupbSngmhqLDegM25Ah UwcC8qAfCBW7bkjiYkJCbuhkUCUJa8xUxvekiDV0= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230616085928eucas1p1959b798afec98ae3b8f1a1d3426307d3~pGApXwMii0928509285eucas1p1l; Fri, 16 Jun 2023 08:59:28 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 77.45.42423.0742C846; Fri, 16 Jun 2023 09:59:28 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230616085927eucas1p265c6e3512e3102a7df507da9d3f1f094~pGApH_LI40622606226eucas1p2y; Fri, 16 Jun 2023 08:59:27 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230616085927eusmtrp1dfc1ac545dffb05a28527161c9716660~pGApHafTJ0876708767eusmtrp16; Fri, 16 Jun 2023 08:59:27 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-35-648c2470551e Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 74.2B.10549.F642C846; Fri, 16 Jun 2023 09:59:27 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230616085927eusmtip1b502a18d8eb5188582174eccc78b4e8e~pGAo-QwfQ0863908639eusmtip1t; Fri, 16 Jun 2023 08:59:27 +0000 (GMT) Received: from localhost (106.210.248.231) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Jun 2023 09:59:27 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH v2 1/8] parport: plug a sysctl register leak Date: Fri, 16 Jun 2023 10:59:15 +0200 Message-ID: <20230616085922.3066990-2-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230616085922.3066990-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.231] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRmVeSWpSXmKPExsWy7djP87oFKj0pBsdvsFjs2XuSxeLyrjls FtPvvGezuDHhKaMDi8emVZ1sHp83yQUwRXHZpKTmZJalFunbJXBl/N2/l7VghWjFlF1fmBsY Lwt2MXJySAiYSFx6tIi5i5GLQ0hgBaPEoi33mSCcL4wSH3dvZ4RwPjNK3Dm1gx2m5eqrJewQ ieWMEoe7rzKDJMCqHh9OhUhsZZSYf2sXE0iCTUBH4vybO2BFIgLiEidOb2YEsZkFJjBKzDrE AWILC9hIbF53mQ3EZhFQlVg2cQFYL6+ArcTLvQvYIDbLS7Rdnw7WyylgJ/F4UgM7RI2gxMmZ T1ggZspLNG+dzQxhS0gcfPECyOYA6lWW+PQ8AWJMrcSpLbfA3pQQOMIh0TvvL9RnLhL7/jxl hrCFJV4d3wIVl5E4PbmHBaJhMqPE/n8f2CGc1YwSyxq/MkFUWUu0XHkC1eEoceHXeXaIzXwS N94KQhzEJzFp23Sog3glOtqEJjCqzELywiwkL8xC8sICRuZVjOKppcW56anFhnmp5XrFibnF pXnpesn5uZsYgUnj9L/jn3Ywzn31Ue8QIxMH4yFGCQ5mJRHeZSe6UoR4UxIrq1KL8uOLSnNS iw8xSnOwKInzatueTBYSSE8sSc1OTS1ILYLJMnFwSjUwNS1cZxKe7hM+LYJl++IjBp9/WYW0 RkmtO3EmYVFgjcolZV9Xfg6TYpaKPQt/tHlOP/sqJkj7pWjF54xml1WZchVf+vP35H7yY3Y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1wcP/vu8xWNFl99CcdHj/rqb9BdVbzKQ4Gd1ln0elP9aftE5jVt5CbXne5QvCthLh5lds++W 7uru/WD3cqe2+a3JvIeC2ae/2uFns3INZ/uz53+CC9l3TlKanLh/oz57afua5WkrwjdbOiQz TQmcWvh7WmDPardAjvobAvEppx8/DetnyRP5voj3rlb3ovXc0z29NTintJZUv1BiKc5INNRi LipOBADLOq60MQMAAA== X-CMS-MailID: 20230616085927eucas1p265c6e3512e3102a7df507da9d3f1f094 X-Msg-Generator: CA X-RootMTR: 20230616085927eucas1p265c6e3512e3102a7df507da9d3f1f094 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230616085927eucas1p265c6e3512e3102a7df507da9d3f1f094 References: <20230616085922.3066990-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@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 16 08:59:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13282325 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 C7DECEB64D7 for ; Fri, 16 Jun 2023 08:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245581AbjFPI7f (ORCPT ); Fri, 16 Jun 2023 04:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245175AbjFPI7d (ORCPT ); Fri, 16 Jun 2023 04:59:33 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FE6E10F6 for ; Fri, 16 Jun 2023 01:59:32 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230616085931euoutp012a3ae644864e58cca986d606b3e2a7f1~pGAsQKKYq0219702197euoutp01f for ; Fri, 16 Jun 2023 08:59:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230616085931euoutp012a3ae644864e58cca986d606b3e2a7f1~pGAsQKKYq0219702197euoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1686905971; bh=gwuzFK21w1IOUF2ZGdDkpZFWv7+ktlTmNmcMNJTZlNE=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=ELoF/9yUQ7IjrBkRGfgL1x+5x7nyLwVG0D4iC3JV05CoWun1x1Zw3lyPCyPO0xAGl TKvRMMMOK2TRtYy/I6h8hmBb+E/kYZQf/TFK5qw14NNsxbLOW5jQYUtv7CV6FMNnfM UpjaqRYGf/EMbGCCM55ZsKXbm2xoyLhQmeRo4ZbY= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230616085931eucas1p2bc2687a34c3ff9d55124f6115568dc59~pGAsI7-gc1069610696eucas1p2m; Fri, 16 Jun 2023 08:59:31 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id F6.C4.11320.2742C846; Fri, 16 Jun 2023 09:59:31 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230616085930eucas1p2d1b7ee012df532b3dcf15f96cd2f8c18~pGAr4XYjz0641806418eucas1p2w; Fri, 16 Jun 2023 08:59:30 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230616085930eusmtrp12126bbccdb46c5978b271a0fd6a1786f~pGAr3tq6Z0890108901eusmtrp1P; Fri, 16 Jun 2023 08:59:30 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-38-648c24725a0b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 39.9E.14344.2742C846; Fri, 16 Jun 2023 09:59:30 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230616085930eusmtip1fd95dc136c7c8f4e24f37577e65ff7fb~pGArtLQ4O1526615266eusmtip1O; Fri, 16 Jun 2023 08:59:30 +0000 (GMT) Received: from localhost (106.210.248.231) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Jun 2023 09:59:29 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH v2 2/8] test_sysctl: Fix test metadata getters Date: Fri, 16 Jun 2023 10:59:16 +0200 Message-ID: <20230616085922.3066990-3-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230616085922.3066990-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.231] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCIsWRmVeSWpSXmKPExsWy7djPc7rFKj0pBve2MVns2XuSxeLyrjls FtPvvGezuDHhKaMDi8emVZ1sHp83yQUwRXHZpKTmZJalFunbJXBlPL3+jblgq1DF3b4tTA2M 3fxdjJwcEgImEgt/nmbsYuTiEBJYwShx8mMflPOFUaLj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jblgq1DF3b4tTA2M3fxdjJwcEgImEjPPP2HvYuTi EBJYyiix/Mh+FoiEjMTGL1dZIWxhiT/Xutggij4ySnyduIgFwtnKKHFk10SwDjYBHYnzb+4w g9giAuISJ05vZgSxmQUmMErMOsQBYgsL2EnceLqADcRmEVCV+LbsLTuIzStgK/Fh93NGiG3y Em3Xp4PZnED1jyc1gNUIAdU03u6HqheUODnzCQvEfHmJ5q2zmSFsCYmDL14A2RxAc5QlPj1P gBhZK/H57zPGCYwis5B0z0LSPQtJ9wJG5lWMIqmlxbnpucVGesWJucWleel6yfm5mxiBEbXt 2M8tOxhXvvqod4iRiYPxEKMEB7OSCO+yE10pQrwpiZVVqUX58UWlOanFhxhNgd6cyCwlmpwP jOm8knhDMwNTQxMzSwNTSzNjJXFez4KORCGB9MSS1OzU1ILUIpg+Jg5OqQamhB2ewembrmfy zoldI/XW9Uz7461qBsZHNzhev7DOZuGK/7mvO3U2Hd3y7+Pzh5r/H0Ser9240tPqEd9vYe4H xfeOp9yQ/MG10Wgfk4PB3dTGaq+y2Sz6loccVbj5rky5+KTf3X7rp6s9B1TY7wsYToj/tPFP QN5uDu3J7EdaE07M6VttOCNd7+cEYTZvLfUaQ6OLRZbHt0vt3uSr+3jdXo1pqz0eGhWJ7Fi/ 2GVu5t/PVwOVjdYcTD/lol1kebrBSUFLJeZFPlNMybtGRjXx3qYnRe4b9zhUv+KakZQupf/t WS5318L/Xd8UTf1X7JjOv85rhrpv+e5tdw74/ZLYfeLY3j28nlqRt57pbBLnVmIpzkg01GIu Kk4EAEl0ieUxAwAA X-CMS-MailID: 20230616085930eucas1p2d1b7ee012df532b3dcf15f96cd2f8c18 X-Msg-Generator: CA X-RootMTR: 20230616085930eucas1p2d1b7ee012df532b3dcf15f96cd2f8c18 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230616085930eucas1p2d1b7ee012df532b3dcf15f96cd2f8c18 References: <20230616085922.3066990-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@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 16 08:59:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13282326 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 4704AEB64D8 for ; Fri, 16 Jun 2023 09:00:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245155AbjFPI7i (ORCPT ); Fri, 16 Jun 2023 04:59:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240797AbjFPI7g (ORCPT ); Fri, 16 Jun 2023 04:59:36 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 485E010F6 for ; Fri, 16 Jun 2023 01:59:34 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230616085933euoutp01bcb9573da1ae5d1df0e3830c389da5b2~pGAuDXbCE0259902599euoutp01P for ; Fri, 16 Jun 2023 08:59:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230616085933euoutp01bcb9573da1ae5d1df0e3830c389da5b2~pGAuDXbCE0259902599euoutp01P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1686905973; bh=hYhRLkPi8FoDCUTYM89A2RNac7EIMazIQAo5IMuTC+s=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=mVFHafhhQ0RweYn15twShwBBZ46FbtZJ8usTR3F3h9T1RthAFxseggOLeBDl+hZLJ DSkNl+km/xsruFdQxRXgATygvSlvzFK6KjLlaQkkHOt5QSM+ByR2yadJQv9WQ98EKu asSMbsFktl1drzMGf3gAT35rLOnMs8VR3JPf3qYo= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230616085932eucas1p1a8b8595d201c77f521ca9c47f9918fc5~pGAt53mE90928509285eucas1p1p; Fri, 16 Jun 2023 08:59:32 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 99.C4.11320.4742C846; Fri, 16 Jun 2023 09:59:32 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230616085932eucas1p1d3d120da7944fc06d714035043697e4d~pGAtmNejj0512805128eucas1p11; Fri, 16 Jun 2023 08:59:32 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230616085932eusmtrp1f6928a4e49ee4e0f0b21f31506551e8f~pGAtlmZSr0890108901eusmtrp1W; Fri, 16 Jun 2023 08:59:32 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-42-648c24746962 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 3B.9E.14344.4742C846; Fri, 16 Jun 2023 09:59:32 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230616085932eusmtip22ea7cb030edfb2cec4c90444bcdd258d~pGAtcnsCH1537815378eusmtip2a; Fri, 16 Jun 2023 08:59:32 +0000 (GMT) Received: from localhost (106.210.248.231) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Jun 2023 09:59:31 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH v2 3/8] test_sysctl: Group node sysctl test under one func Date: Fri, 16 Jun 2023 10:59:17 +0200 Message-ID: <20230616085922.3066990-4-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230616085922.3066990-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.231] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRmVeSWpSXmKPExsWy7djPc7olKj0pBrO7LCz27D3JYnF51xw2 i+l33rNZ3JjwlNGBxWPTqk42j8+b5AKYorhsUlJzMstSi/TtErgyrk3rZy14xF1x78Y7xgbG a5xdjJwcEgImEr3rupm7GLk4hARWMEq0zn7GDJIQEvjCKDFnthhE4jOjxIQzN9hhOjY9PcEO kVjOKDG/4REjXNXf6b+hMlsZJV6tusUG0sImoCNx/s0dsLkiAuISJ05vZgSxmQUmMErMOsQB YgsLeElM3nOGCcRmEVCVuHH9G1g9r4CtxIxdt1khVstLtF2fDtbLKWAn8XhSAztEjaDEyZlP WCBmyks0b53NDGFLSBx88QLI5gDqVZb49DwBYkytxKktt5hA7pQQOMAh0bv+LtR8F4n3/cvZ IGxhiVfHt0C9LCNxenIPC0TDZEaJ/f8+sEM4qxklljV+ZYKospZoufIEqsNRYuLWC+wQm/kk brwVhDiIT2LStulQB/FKdLQJTWBUmYXkhVlIXpiF5IUFjMyrGMVTS4tz01OLjfJSy/WKE3OL S/PS9ZLzczcxApPG6X/Hv+xgXP7qo94hRiYOxkOMEhzMSiK8y050pQjxpiRWVqUW5ccXleak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mkycrEHV20 fNYsaVbR5SmHXnquS83wr+TV+bKsKjqOfdWM9WvFa5NEHPWOpwlofLuUzGgu/ajvTu7BVGed S+eiO5S1Tu/5utVobiuPM39dYeX8Ke43XToOC6z8nulz8s89y79C6hOUJujPzZwsxs7jOZNj wnX9o35uYYYf2D6USDUGTum6ynX83SfrXbLLrAtfJb7JiRbOvfNOTTBr3dGreloK3SYJT19v v2agtrtj21XfjWZXjZc+U2B/yLwmzmnS4md713rLLtV5nH7AOvDm5vTAhI8Pee/trDysIiIx 9fQjzY/917Nfi33SNmzeFHww/I/71IJDd95Jbw4S+Ms5/93KqP1SEr+P66xSYinOSDTUYi4q TgQAkG7KRzEDAAA= X-CMS-MailID: 20230616085932eucas1p1d3d120da7944fc06d714035043697e4d X-Msg-Generator: CA X-RootMTR: 20230616085932eucas1p1d3d120da7944fc06d714035043697e4d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230616085932eucas1p1d3d120da7944fc06d714035043697e4d References: <20230616085922.3066990-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@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 16 08:59:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13282340 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 3C3A9EB64DD for ; Fri, 16 Jun 2023 09:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343889AbjFPJAm (ORCPT ); Fri, 16 Jun 2023 05:00:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343614AbjFPI7i (ORCPT ); Fri, 16 Jun 2023 04:59:38 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E08D1BC3 for ; Fri, 16 Jun 2023 01:59:37 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230616085935euoutp021ed06f15341cf5101272647166a51f63~pGAwpQJY42873228732euoutp02W for ; Fri, 16 Jun 2023 08:59:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230616085935euoutp021ed06f15341cf5101272647166a51f63~pGAwpQJY42873228732euoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1686905975; bh=f1HjrLD6njVVPjduaddJfi5+Ds9joRkOIy3esLq1bnY=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=KoXZXarVSr/tD/cq7Yr116Qpv0UTVbKgzPKO47hFfs5Ou7v5oY2VR2r1o77XmxHl+ l996+etLl/hWWokJ0qKPX5rdIbEX+hVlBb1QRWaSSoX44e6vyYrFrj1ck2pNDbNbFZ Beje4hzUUapjgY0PMNBPSVe7UTXhO14VGhqp6p/c= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230616085935eucas1p1171b73897e1cd825a5d5ab373ed4c9c9~pGAwaB_uZ1146911469eucas1p1m; Fri, 16 Jun 2023 08:59:35 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 6C.45.42423.7742C846; Fri, 16 Jun 2023 09:59:35 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230616085935eucas1p2439375978f0ee33afd6310a9f8c5d07a~pGAwHTLq61755217552eucas1p2_; Fri, 16 Jun 2023 08:59:35 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230616085935eusmtrp1c68c5c817c528c9d8849b36ad7e6f2d5~pGAwGsbAm0890108901eusmtrp1a; Fri, 16 Jun 2023 08:59:35 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-4d-648c24771e35 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id DC.9E.14344.7742C846; Fri, 16 Jun 2023 09:59:35 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230616085935eusmtip252b10b84713a96d7276b9661b401440f~pGAv_AsVC1986719867eusmtip25; Fri, 16 Jun 2023 08:59:35 +0000 (GMT) Received: from localhost (106.210.248.231) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Jun 2023 09:59:34 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH v2 4/8] test_sysctl: Add an unregister sysctl test Date: Fri, 16 Jun 2023 10:59:18 +0200 Message-ID: <20230616085922.3066990-5-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230616085922.3066990-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.231] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKIsWRmVeSWpSXmKPExsWy7djPc7rlKj0pBpuuqFjs2XuSxeLyrjls FtPvvGezuDHhKaMDi8emVZ1sHp83yQUwRXHZpKTmZJalFunbJXBlHGpZwlhwWqRiVf9dlgbG NwJdjJwcEgImEj2v7zKC2EICKxglph/N7mLkArK/MEosa7zEAuF8ZpTYvGMqO0zHz+6z7BAd yxklFvdawRXd+nSCCcLZyijRvOEAE0gVm4COxPk3d5hBbBEBcYkTpzeD7WMWmMAoMesQB4gt LOAkcejsMhYQm0VAVWL+ri9g9bwCthKP73ZDbZaXaLs+HayXU8BO4vGkBnaIGkGJkzOfsEDM lJdo3jqbGcKWkDj44gWQzQHUqyzx6XkCxJhaiVNbboHdKSFwgEPiR9dNNoiEi8SPKXtYIWxh iVfHt0DtlZE4PbmHBaJhMqPE/n8f2CGc1aBA+soEUWUt0XLlCVSHo8TNd6dZIDbzSdx4Kwhx EJ/EpG3ToQ7ilehoE5rAqDILyQuzkLwwC8kLCxiZVzGKp5YW56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tSi/Pii0pzU4kOMpkBvTmSWEk3O B8Z0Xkm8oZmBqaGJmaWBqaWZsZI4r2dBR6KQQHpiSWp2ampBahFMHxMHp1QDk+Nt5qjca9Z8 Z+dZpWZ9ucwto9dkp+6jwGTmXdBh4M4ZOXWuxhy9mLPsCwPSDziuj5sh8SmXP/Vj8oRtDyT+ v7V7p29y51SZ17ZNB5dVTMi/pqzxVN4wt3bVu4mbztktNZ5/f/uOYhf5vjNlSbbLJSINq1Td j8TOOvC08muqcJvewrNsrlaa6gfXH3y39uT6bG6DpTt6s6XCLVd2/qj4E18tqXdlzsa9TT/3 Hrw78fhBBxN7yUvbeW7GVct2HFXe4L7qWqb0osfbKu9NfDiPP87t8R/BXy2ZHZkyKu4/VZed sHZSkvR7Jf1s1nbR9CWurVs1I/Vu7vlblhEbeiOBia2zYtfrLNtal00rJJ8mKLEUZyQaajEX FScCAI0Gvi0xAwAA X-CMS-MailID: 20230616085935eucas1p2439375978f0ee33afd6310a9f8c5d07a X-Msg-Generator: CA X-RootMTR: 20230616085935eucas1p2439375978f0ee33afd6310a9f8c5d07a X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230616085935eucas1p2439375978f0ee33afd6310a9f8c5d07a References: <20230616085922.3066990-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@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 16 08:59:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13282339 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 C399CEB64D8 for ; Fri, 16 Jun 2023 09:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245726AbjFPJAk (ORCPT ); Fri, 16 Jun 2023 05:00:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343871AbjFPI7t (ORCPT ); Fri, 16 Jun 2023 04:59:49 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB9C230CA for ; Fri, 16 Jun 2023 01:59:38 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230616085937euoutp0117048b407f7ab66e31344c4d308bfbdc~pGAyMqMrQ0219502195euoutp01i for ; Fri, 16 Jun 2023 08:59:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230616085937euoutp0117048b407f7ab66e31344c4d308bfbdc~pGAyMqMrQ0219502195euoutp01i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1686905977; bh=bxclUZv9jPrQ5jKcyYEbND/Krq83dxgsRJ8rzENWdE8=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=axotJ3q9jypT/P70UZod6ZYCnJKI3b7eew1unLG9EFfIT2BpiziHXtpd1MKziIcTh 0ZOEvtXkjJqaQ0SLaNxV4JfO/gAjFkkLGc2UZOtVVpCozDTBfduMV+K69FuFP9NwEh HPlqMHci/IPTlw3sCMkhqL1Vqv4tVQk0hJd/JKeM= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230616085937eucas1p2049999b954d45f4ea4c8bb141d303b2b~pGAyHQPra1525715257eucas1p2Y; Fri, 16 Jun 2023 08:59:37 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 1D.C4.11320.9742C846; Fri, 16 Jun 2023 09:59:37 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230616085937eucas1p2128b2ddb3c01c887a606f376de850767~pGAxw7LIy1755217552eucas1p2B; Fri, 16 Jun 2023 08:59:37 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230616085937eusmtrp18f4a6e5e8bc6988652294b0a7480e8bc~pGAxwYBGj0876708767eusmtrp1R; Fri, 16 Jun 2023 08:59:37 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-51-648c2479a117 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B9.2B.10549.9742C846; Fri, 16 Jun 2023 09:59:37 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230616085936eusmtip26d75365940dfa4d7f6bbbc981595f2bb~pGAxmWPUB1986419864eusmtip2-; Fri, 16 Jun 2023 08:59:36 +0000 (GMT) Received: from localhost (106.210.248.231) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Jun 2023 09:59:36 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH v2 5/8] test_sysctl: Add an option to prevent test skip Date: Fri, 16 Jun 2023 10:59:19 +0200 Message-ID: <20230616085922.3066990-6-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230616085922.3066990-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.231] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRmVeSWpSXmKPExsWy7djP87qVKj0pBu+apCz27D3JYnF51xw2 i+l33rNZ3JjwlNGBxWPTqk42j8+b5AKYorhsUlJzMstSi/TtErgyVtztZin4J1ux7tJTtgbG +xJdjJwcEgImEltbWtm6GLk4hARWMEp8WPmYHcL5wijxb9kLZgjnM6NE45edjDAt8+ZdY4FI LGeUWLlrPhtc1f7++VD9WxklDk1sYwFpYRPQkTj/5g4ziC0iIC5x4vRmsFHMAhMYJWYd4gCx hQXcJY7N3gJWzyKgKvHn5EYmEJtXwFbiwOHtzBCr5SXark8H6+UUsJN4PKmBHaJGUOLkzCcs EDPlJZq3zmaGsCUkDr4A+YEDqFdZ4tPzBIgxtRKnttxiArlTQuAIh8TphnZ2iISLxPn7a1kh bGGJV8e3QMVlJE5P7mGBaJgM9OW/D+wQzmpGiWWNX5kgqqwlWq48YYfY5iixaGclhMknceOt IMQ9fBKTtk2HuodXoqNNaAKjyiwkH8xC8sEsJB8sYGRexSieWlqcm55abJSXWq5XnJhbXJqX rpecn7uJEZg0Tv87/mUH4/JXH/UOMTJxMB5ilOBgVhLhXXaiK0WINyWxsiq1KD++qDQntfgQ ozQHi5I4r7btyWQhgfTEktTs1NSC1CKYLBMHp1QDkw+Xakpq8qyKJe4TL+1b73f219KVHX8y f+dW1TI92WgixuPWssXl7pULsl+nOMldVuBovbjyp+NkCzedpTKTKqKv3/giL3qqquSldfzD L6t+zVzXaq/pOeeSnYjF1L/ch2bt+yjxcXHG3+Ktweqppwpt5gRfMn3Badwu1sB5dWmF74LA SDfWQ/IxWzncmFRue5w30BC6G8AqlJa3ZfdHuaaiD/feNC+4csxgzg53pzq20l7+eQXuMuyP rzP+fT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LDu+Y vtIgJPzgihsCMrrXNrOxu8ls3vbo7snGa1P4V+96seD1mjXzV8scCD9yfmV3/iK3TCWW4oxE Qy3mouJEAPuksBIxAwAA X-CMS-MailID: 20230616085937eucas1p2128b2ddb3c01c887a606f376de850767 X-Msg-Generator: CA X-RootMTR: 20230616085937eucas1p2128b2ddb3c01c887a606f376de850767 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230616085937eucas1p2128b2ddb3c01c887a606f376de850767 References: <20230616085922.3066990-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@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 16 08:59:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13282338 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 1B8F3EB64D7 for ; Fri, 16 Jun 2023 09:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343865AbjFPJAl (ORCPT ); Fri, 16 Jun 2023 05:00:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343957AbjFPI7u (ORCPT ); Fri, 16 Jun 2023 04:59:50 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91C4B30EC for ; Fri, 16 Jun 2023 01:59:41 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230616085940euoutp021002c337db8080db01f65514684652a5~pGA0yUyyj3175731757euoutp02c for ; Fri, 16 Jun 2023 08:59:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230616085940euoutp021002c337db8080db01f65514684652a5~pGA0yUyyj3175731757euoutp02c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1686905980; bh=kfxf1qr5GWf+HXq/jSKKNVDlnExuNV1LXklo/nv5rro=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=bnmgi3t+PyMzL05stx63GEQYXohAVP2y6oHJzhWYU3avPBAUmI5vUBKYf/hNIH0mI SvAXcVV6kxHl9V/V4eA9R96643hmzoQdyhr8gXT4q0AtU3R6ydPZDnQNj+O/UkRa6P kjRw/j9uXl4mhDxzpilkLiKliFIa85npf5LUGHyE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230616085940eucas1p222cde6bbd26954fa7c85168511eb5645~pGA0leklA1074010740eucas1p2Z; Fri, 16 Jun 2023 08:59:40 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 10.D4.11320.C742C846; Fri, 16 Jun 2023 09:59:40 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230616085939eucas1p24e5c916a261653ce64bb65c7d12d2830~pGA0T_ivb1074010740eucas1p2Y; Fri, 16 Jun 2023 08:59:39 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230616085939eusmtrp21011ce618e2f36069088ccd3403a1948~pGA0TV7gC1371213712eusmtrp2t; Fri, 16 Jun 2023 08:59:39 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-56-648c247cb3e4 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FF.9E.14344.B742C846; Fri, 16 Jun 2023 09:59:39 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230616085939eusmtip283390eb1560c05c5a6b780f28d30849c~pGA0GnKWL2148921489eusmtip2G; Fri, 16 Jun 2023 08:59:39 +0000 (GMT) Received: from localhost (106.210.248.231) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Jun 2023 09:59:39 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH v2 6/8] test_sysclt: Test for registering a mount point Date: Fri, 16 Jun 2023 10:59:20 +0200 Message-ID: <20230616085922.3066990-7-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230616085922.3066990-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.231] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKIsWRmVeSWpSXmKPExsWy7djP87o1Kj0pBlf+sVns2XuSxeLyrjls FtPvvGezuDHhKaMDi8emVZ1sHp83yQUwRXHZpKTmZJalFunbJXBlPLv0ialgt3JF97eVrA2M x2W7GDk5JARMJF7s6GTqYuTiEBJYwShxd80+ZgjnC6PE2lUr2SCcz4wS29bNAHI4wFoe39OA iC9nlLi+7BE7XFHj3z+sEM5WRoldn/azgyxhE9CROP/mDjOILSIgLnHi9GZGEJtZYAKjxKxD HCC2sIC7xKIXT8DiLAKqEouPtzOB2LwCthLTjr5ngThWXqLt+nSwGk4BO4nHkxrYIWoEJU7O fMICMVNeonnrbGYIW0Li4IsXzBBXK0t8ep4AMaZW4tSWW2A/Swgc4ZCYcOYMO0TCRWL1jlYm CFtY4tXxLVBxGYn/O+dDNUxmlNj/7wM7hLOaUWJZ41eoDmuJlitP2CG2OUo0HGW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n525iBMbT tmM/t+xgXPnqo94hRiYOxkOMEhzMSiK8y050pQjxpiRWVqUW5ccXleakFh9iNAV6cyKzlGhy PjCi80riDc0MTA1NzCwNTC3NjJXEeT0LOhKFBNITS1KzU1MLUotg+pg4OKUamOysNv2YlsP8 eUWX4mFpYW29Ar5rPRqt0rtWTnfc7vC99VK/9CUe+RAV48iAPbNd2GQnqzLvLDC0u2IW47io 6dTlTzFsLclGL4/q/Yt/vPjFJcYD3zgfnOZX2R2UGmyzYanVrm890ZfXHI+L1T7i+JB5dZOM acZ0ozVMzY8UmH76Pt9YuGxK9vsC7h17+nPkPjvXXNphMlfX/4eN3xbzLLX9C2ey8Tjuufbs TfFMvaJFJ38djLFwmVJ+eGPiphOVkc1V/d9vF4nc2v7k6LIrCyp3/hbpM9+2qXmF5fa3Ss8M TrFXXo/pWHpJ82r9UpEP7id3rkv80yn0ZJ+PnNgi9Ycfd5QeP/3pwQnNxybLW+yVWIozEg21 mIuKEwGa2hg4MAMAAA== X-CMS-MailID: 20230616085939eucas1p24e5c916a261653ce64bb65c7d12d2830 X-Msg-Generator: CA X-RootMTR: 20230616085939eucas1p24e5c916a261653ce64bb65c7d12d2830 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230616085939eucas1p24e5c916a261653ce64bb65c7d12d2830 References: <20230616085922.3066990-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@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 16 08:59:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13282341 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 D6C28C001DE for ; Fri, 16 Jun 2023 09:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343926AbjFPJAo (ORCPT ); Fri, 16 Jun 2023 05:00:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343983AbjFPI7v (ORCPT ); Fri, 16 Jun 2023 04:59:51 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4784330FC for ; Fri, 16 Jun 2023 01:59:43 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230616085942euoutp0196c03f90486852a7653cfe45473a1778~pGA2Xk5eZ0287502875euoutp016 for ; Fri, 16 Jun 2023 08:59:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230616085942euoutp0196c03f90486852a7653cfe45473a1778~pGA2Xk5eZ0287502875euoutp016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1686905982; bh=k6w26tA5MuuVW167a8RaVYBvH9le+QbGGVR79rArU/4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=FctFWHJPsD3dDo/3kFxh3zjFrLgqE8tEobwKRK/rDJNSz3MUbE0MGaJ5DTVgL0xA+ Q7B3ynnHVixyIUSMEdvNTk9kkZu49WWQE8DiZoftcFjCsWkdw5zKLPSEjzhSyEPRu6 lrIdn+HJoLIAw4NnESjVEzLcUCmzDFMOt9zI/i2c= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230616085941eucas1p21635b3c7e00f84049d5b66ea5fcd22a3~pGA2OB0bz0552005520eucas1p2y; Fri, 16 Jun 2023 08:59:41 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 51.D4.11320.D742C846; Fri, 16 Jun 2023 09:59:41 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230616085941eucas1p152b54db1511bfdd1afab32621aec847e~pGA1_NAv72668626686eucas1p1U; Fri, 16 Jun 2023 08:59:41 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230616085941eusmtrp2ea835b8ccfdbc7908ca8719bd6ab21c5~pGA19aaMh1371213712eusmtrp2y; Fri, 16 Jun 2023 08:59:41 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-5e-648c247d4969 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F0.AE.14344.D742C846; Fri, 16 Jun 2023 09:59:41 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230616085941eusmtip20ee9de30262fab02e77e310597033a2d~pGA1xagG11986719867eusmtip28; Fri, 16 Jun 2023 08:59:41 +0000 (GMT) Received: from localhost (106.210.248.231) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Jun 2023 09:59:40 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH v2 7/8] sysctl: Remove debugging dump_stack Date: Fri, 16 Jun 2023 10:59:21 +0200 Message-ID: <20230616085922.3066990-8-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230616085922.3066990-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.231] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sI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X-Msg-Generator: CA X-RootMTR: 20230616085941eucas1p152b54db1511bfdd1afab32621aec847e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230616085941eucas1p152b54db1511bfdd1afab32621aec847e References: <20230616085922.3066990-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@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 16 08:59:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13282342 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 A77A6C3DA40 for ; Fri, 16 Jun 2023 09:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343947AbjFPJAq (ORCPT ); Fri, 16 Jun 2023 05:00:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344039AbjFPI7y (ORCPT ); Fri, 16 Jun 2023 04:59:54 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 498103593 for ; Fri, 16 Jun 2023 01:59:46 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230616085945euoutp01ddff4ba5a54719d060fb23117d2435c7~pGA5NT4BP0287502875euoutp017 for ; Fri, 16 Jun 2023 08:59:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230616085945euoutp01ddff4ba5a54719d060fb23117d2435c7~pGA5NT4BP0287502875euoutp017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1686905985; bh=s42QTWpzjdbXRf/v8kr6TgDyip3CoXMlXkBbdLK2j7U=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=OKiyQCHQmIjhpQj+TNvuzmyxHfcw+okhHXvb9yf23irKWYJOFqaJYt/7Ja4RId3C+ QnryZviQgeHT2ucAWljCzUFFyhu0lNpbdJjspQIsms3OevmzdkWcKShZmL/eyTQm6i innqoZuyoYtR0Ns/HjmNAJmvKhD7X6dnTY6nDcgk= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230616085944eucas1p2d5f9f8aa9dcbd4675c8a09472dfa4f47~pGA5BOFX_1074010740eucas1p2f; Fri, 16 Jun 2023 08:59:44 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id E2.D4.11320.0842C846; Fri, 16 Jun 2023 09:59:44 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230616085944eucas1p14e8491c53f5390064035de1ffb354c7a~pGA4mPsH91147911479eucas1p1v; Fri, 16 Jun 2023 08:59:44 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230616085944eusmtrp19ab93ce2c07d0c9d2fa0a23465908f22~pGA4luWLe0890108901eusmtrp1q; Fri, 16 Jun 2023 08:59:44 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-6b-648c24803df9 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 4E.2B.10549.0842C846; Fri, 16 Jun 2023 09:59:44 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230616085944eusmtip1a55b416dd4f231c839f2978cd016c00f~pGA4cIQMT1526915269eusmtip1T; Fri, 16 Jun 2023 08:59:44 +0000 (GMT) Received: from localhost (106.210.248.231) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Jun 2023 09:59:43 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH v2 8/8] sysctl: replace child with an enumeration Date: Fri, 16 Jun 2023 10:59:22 +0200 Message-ID: <20230616085922.3066990-9-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230616085922.3066990-1-j.granados@samsung.com> MIME-Version: 1.0 X-Originating-IP: [106.210.248.231] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCIsWRmVeSWpSXmKPExsWy7djPc7oNKj0pBr9mmFrs2XuSxeLyrjls FtPvvGezuDHhKaMDi8emVZ1sHp83yQUwRXHZpKTmZJalFunbJXBlvNl2gaVgk3XFwXWrWBoY dxp0MXJySAiYSNw4+pO5i5GLQ0hgBaPEg6vTWSGcL4wSvTuesYFUCQl8ZpS4/FkFpmPX9h1s EEXLGSWe7tnMBOEAFc1b08II4WxllJjVOoMJpIVNQEfi/Js7zCC2iIC4xInTmxlBbGaBCUBF hzhAbGEBR4nO63vA4iwCqhInntxj72Lk4OAVsJXo++wEsVleou36dLAS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L0cHLwCthJ9n50glslL tF2fDlbCKWAn8XhSA9h4IaCSxtv9YDavgKDEyZlPWCDGy0s0b53NDGFLSBx88YIZZKSEgLLE p+cJECNrJT7/fcY4gVFkFpLuWUi6ZyHpXsDIvIpRJLW0ODc9t9hQrzgxt7g0L10vOT93EyMw nrYd+7l5B+O8Vx/1DjEycTAeYpTgYFYS4V12oitFiDclsbIqtSg/vqg0J7X4EKMp0JcTmaVE k/OBEZ1XEm9oZmBqaGJmaWBqaWasJM7rWdCRKCSQnliSmp2aWpBaBNPHxMEp1cAUfXSpP3vl lIkHjTd9CjzcPH/JCbF53glZss0JQosT/2hP83LtqnDl9Hr5NGTWzW8MCc941nY4+NiLWSn8 3LrmN1uu5PTt5Z1XUjqf/PVODPJd1ZtTf0Z6XblHWv+BopCaPzMVXx9cZ+3xaM22e0I7ppat vXWkY15O8dprp/4+OOj4vmrDO/PMJ5M3PVv4lNk4r7Tkjpt+nMgu4Sd3mj932Ik8P+bxlD2D N993g9G6X0cYHZlnzY9YPPnBiokR8z2a/Lg7Uy6py1xOUDT5r66+5n7XIYN+mT2ZXvs5JE/X awqbbpogx5CT6/SXy679po5O5IHtZ4WnK+Qos4rUR3+rk1/K8inr6LIWqYrI7SeVWIozEg21 mIuKEwHJp7fEMAMAAA== X-CMS-MailID: 20230616085944eucas1p14e8491c53f5390064035de1ffb354c7a X-Msg-Generator: CA X-RootMTR: 20230616085944eucas1p14e8491c53f5390064035de1ffb354c7a X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230616085944eucas1p14e8491c53f5390064035de1ffb354c7a References: <20230616085922.3066990-1-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@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 an enumeration that will have two values: the default (0) and the permanently empty (1). The latter is left at zero so when struct ctl_table is created with kzalloc or in a local context, it will have the zero value by default. We document the new enum with kdoc. * 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 | 14 ++++++- 3 files changed, 30 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..c4ea804d862b 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[] = { - { } + {.type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY } }; /** @@ -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].type == SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) +#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].type = SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) +#define sysctl_clear_perm_empty_ctl_header(hptr) \ + (hptr->ctl_table[0].type = SYSCTL_TABLE_TYPE_DEFAULT) 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..59d451f455bf 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -137,7 +137,17 @@ struct ctl_table { void *data; int maxlen; umode_t mode; - struct ctl_table *child; /* Deprecated */ + /** + * enum type - Enumeration to differentiate between ctl target types + * @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations + * @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently + * empty directory target to serve + * as mount point. + */ + enum { + SYSCTL_TABLE_TYPE_DEFAULT, + SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY + } type; proc_handler *proc_handler; /* Callback for text formatting */ struct ctl_table_poll *poll; void *extra1; @@ -229,7 +239,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 */