From patchwork Fri Jun 2 10:07:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13265000 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 3C79CC7EE29 for ; Fri, 2 Jun 2023 10:08:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235210AbjFBKIY (ORCPT ); Fri, 2 Jun 2023 06:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235031AbjFBKIW (ORCPT ); Fri, 2 Jun 2023 06:08:22 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61712132 for ; Fri, 2 Jun 2023 03:08:16 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230602100815euoutp02d025b768b875d2966f9dcf8a095e5e0c~kz6tRw7bK3193731937euoutp02g for ; Fri, 2 Jun 2023 10:08:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230602100815euoutp02d025b768b875d2966f9dcf8a095e5e0c~kz6tRw7bK3193731937euoutp02g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685700495; bh=dg1KPdqa1g30CQqgCK1VP5CwiQO47gFwHbWyH2hvLF4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=oD7Iiq6TlKgPG5zILVOnrh701Qbaxr/VdenbG24kf6qAUKZx8YNgOc2szMKc5qwNk y9Dcks/iLrvnNTkjEHFpqIs4pkaKUv7G93ZanITCD/mMXDOzjpRdKrdXdM5gtPWKfW VhAg98YLXbdXjiF+xb16+FyzXpBTL3cw++VgsCVw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602100811eucas1p2615b62a4c0f1f1eb5c92db91a20f5a7b~kz6peCK-51569615696eucas1p2v; Fri, 2 Jun 2023 10:08:11 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id A2.9D.11320.B8FB9746; Fri, 2 Jun 2023 11:08:11 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602100810eucas1p12ceafb0c85c74ad2e2e9d96db56786a5~kz6pMSS0V0575805758eucas1p1Q; Fri, 2 Jun 2023 10:08:10 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230602100810eusmtrp17411fb21898111e0f6efc12dbe8a51a7~kz6pLrVC51803818038eusmtrp1K; Fri, 2 Jun 2023 10:08:10 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-f8-6479bf8b0910 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id C9.34.14344.A8FB9746; Fri, 2 Jun 2023 11:08:10 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230602100810eusmtip1857d2adad3a20543cd7f090f516540a4~kz6pDIsdH0244502445eusmtip1I; Fri, 2 Jun 2023 10:08:10 +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 11:08:10 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 1/8] parport: plug a sysctl register leak Date: Fri, 2 Jun 2023 12:07:58 +0200 Message-ID: <20230602100805.777917-2-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602100805.777917-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: H4sIAAAAAAAAA02Se0iTURjGO9/3bX5bTT7n7cXCaiqSplYU2WViFyINuiATjEqnfurIG7uk RkFlaa6s1aTVVLLwxrxQ85KFw7Sa2SJN09aUAtEaZqWpf6goNU+B//3e93mfc97ncGhSOEN5 0bJ0JStPl6aKuHyq2Tz7LuhaW07iprdfuKGtpi4qtO9ZCTdUN/SLG2rVjKJw6qDRUMA9OGX0 Pkoc5+9OZFNlZ1h5SFgcP2WhzcTJrHbPLno2TV5AfS5qxKOB2Qpm+ycnNeLTQqYawZXCfA4u phGMF9yhcDGFwL5QT/y3XCoaX2IhU4XAPBOF+e9Q51MJNjQiaDB9IR0Cl9kI3eNDS+zGeMJr SwNyMMloEOg7aDWiaVdmBxT+2OFoU4wv/KwZ5DhYwOyGadMTCt+7FvI+6pasPEYMlXdHCTzj Al33Rih85FrIbSomMQO02+0k9vqApn6eg/k8vGm0EY49gXlJw0PdVYSF/dA0OszF7ApjnY1O mNeARXudwgYtgrbFCSdc1CCovDjz71l2weUPI/8ce+B7kZVwJAPGGaw/XPBGznC7WUfitgCu 5gk1yFe/LIN+WQb9sgxliDQgT1alSEtmFVvS2axghTRNoUpPDk7ISDOivz/Dstg53YKqxiaD OxBBow4ENClyEwijsxKFgkRpzllWnhErV6Wyig60mqZEnoJAcVeCkEmWKtnTLJvJyv+rBM3z ukAcUM6tz8qUeLdGHbsdq+FIfme+KCwreM/ITio8h7TaEu3nkcVXgqQVEwlfOT0tSq17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dDn3tk4f6EZzzg0zgk1zYl+5aSY/Pap c615tVn23eb/O5l3Rk98tafIQGZDQr3GFYWnJrdsjDlen3a4OSdxkkPV0o2vNb5odfuq62kl HNjMc5/3udkFxup3BwqZkr/cSGndPy3SrfruLj3HgP1alo2uZlNOnvvAvUJp3p8pxxfJC5hI 6XQ/cJe0Msww8LeZ1KA0cU/8rKXLpBuirtjsDC28HVC/cPZk5tttb6fq8z1+6aLEUpyRaKjF XFScCABEFaACMQMAAA== X-CMS-MailID: 20230602100810eucas1p12ceafb0c85c74ad2e2e9d96db56786a5 X-Msg-Generator: CA X-RootMTR: 20230602100810eucas1p12ceafb0c85c74ad2e2e9d96db56786a5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602100810eucas1p12ceafb0c85c74ad2e2e9d96db56786a5 References: <20230602100805.777917-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 2 10:07:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13265001 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 8AE59C7EE2C for ; Fri, 2 Jun 2023 10:08:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235177AbjFBKIZ (ORCPT ); Fri, 2 Jun 2023 06:08:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235143AbjFBKIW (ORCPT ); Fri, 2 Jun 2023 06:08:22 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D893194 for ; Fri, 2 Jun 2023 03:08:16 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230602100815euoutp01b0fb62b3e3c14bd3971381e5282d03c5~kz6tXZ4dh0566005660euoutp01E for ; Fri, 2 Jun 2023 10:08:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230602100815euoutp01b0fb62b3e3c14bd3971381e5282d03c5~kz6tXZ4dh0566005660euoutp01E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685700495; bh=gwuzFK21w1IOUF2ZGdDkpZFWv7+ktlTmNmcMNJTZlNE=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Uhqp8u1RDGdYhE7p0dUp2DVn2Kl7t38eCw3GIUnA23//WAv00Qo6yz0z/NL7W77Iw NxGeaLro3zsgnBnJrnHtBymiAFNCzuC915usMWxigdc3Ob5AkDzzEnJsO8he/ARi3N gHKsmcoisp/4lelD+SMCGfiie39BZkoJcEFKMcIQ= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602100812eucas1p2ee60d116422b859b8b2368dab22a3455~kz6rBxq_m0507505075eucas1p2c; Fri, 2 Jun 2023 10:08:12 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id D7.20.42423.C8FB9746; Fri, 2 Jun 2023 11:08:12 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602100812eucas1p14c8b09a24157e24c40b2c1869e2d1c56~kz6qxImmN2168821688eucas1p1A; Fri, 2 Jun 2023 10:08:12 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230602100812eusmtrp14d669053a0b08bb228c50ede5f255c56~kz6qwdEFe1804218042eusmtrp1E; Fri, 2 Jun 2023 10:08:12 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-b0-6479bf8c0d34 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 2A.34.14344.C8FB9746; Fri, 2 Jun 2023 11:08:12 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230602100812eusmtip16688d6ac326554b917db77ef42572fa8~kz6qlNGQ53205432054eusmtip17; Fri, 2 Jun 2023 10:08:12 +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 11:08:11 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 2/8] test_sysctl: Fix test metadata getters Date: Fri, 2 Jun 2023 12:07:59 +0200 Message-ID: <20230602100805.777917-3-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602100805.777917-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+NgFvrGIsWRmVeSWpSXmKPExsWy7djP87o9+ytTDFpmGVjs2XuSxeLyrjls FtPvvGezuDHhKaMDi8emVZ1sHp83yQUwRXHZpKTmZJalFunbJXBlPL3+jblgq1DF3b4tTA2M 3fxdjJwc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ezSUnNySxLLdK3S9DLeHr9G3PBVqGKu31bmBoYu/m7GDk5JARMJN5/PsnUxcjF ISSwlFGi+eAONoiEjMTGL1dZIWxhiT/Xutggij4ySvQ3XWKBcLYwSmx7+JYFpIpNQEfi/Js7 zCC2iIC4xInTmxlBbGaBCYwSsw5xgNjCAtYSc1b2soPYLAIqEof3HgazeQVsJB61fITaLC/R dn06WC+ngK3EshlPmUBsIaCa848mMUPUC0qcnPmEBWK+vETz1tnMELaExMEXL5gh5ihLTFj3 G+qDWonPf58xTmAUmYWkfRaS9llI2hcwMq9iFEktLc5Nzy020itOzC0uzUvXS87P3cQIjKlt x35u2cG48tVHvUOMTByMhxglOJiVRHiFwspThHhTEiurUovy44tKc1KLDzGaAv05kVlKNDkf GNV5JfGGZgamhiZmlgamlmbGSuK8ngUdiUIC6YklqdmpqQWpRTB9TBycUg1MM5k5VhW77Z5n re09S3mPIOvifwFs86cc/vpk705PwzXz5WcvSvfexcTG+HKWM/OuksX3Di+9MSnfd88zV9WK 6pOp08rr5gZ4FXZUHon4/ON2e+WDB665x/ZdfvzFa7Pn+4d/jm67Nf3CrOtiX00O+8Ts/PnZ TvvO0pj9J1PtvrXMfyy42vk8h5rSJsUJ/yOEq2pu9N3bkLSUN+8mqxvvtsMW5p+6z3vLV9qe mHhYQnje/TLZwlvt7+++vXjdbOH8F1Z2Vg+P5EdPvnLxWPN+d4vEZQ89slKO6GTEBZnWTQ6J /i1c/eFtRdScuDmHVm40dghrTZQ2/Vy6flbeozNNETqzXRwOiBwSX3jxkFJJzQ8lluKMREMt 5qLiRAAr5LtRMgMAAA== X-CMS-MailID: 20230602100812eucas1p14c8b09a24157e24c40b2c1869e2d1c56 X-Msg-Generator: CA X-RootMTR: 20230602100812eucas1p14c8b09a24157e24c40b2c1869e2d1c56 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602100812eucas1p14c8b09a24157e24c40b2c1869e2d1c56 References: <20230602100805.777917-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 2 10:08:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13265002 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 DCB8EC7EE29 for ; Fri, 2 Jun 2023 10:08:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234840AbjFBKI0 (ORCPT ); Fri, 2 Jun 2023 06:08:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235153AbjFBKIW (ORCPT ); Fri, 2 Jun 2023 06:08:22 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8DC7198 for ; Fri, 2 Jun 2023 03:08:16 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230602100815euoutp02eeadf758a68100ddbce1a8c66e755283~kz6tc9Rco3193731937euoutp02i for ; Fri, 2 Jun 2023 10:08:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230602100815euoutp02eeadf758a68100ddbce1a8c66e755283~kz6tc9Rco3193731937euoutp02i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685700495; bh=hYhRLkPi8FoDCUTYM89A2RNac7EIMazIQAo5IMuTC+s=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=YdMQjQYDQFZKHmHEbzFHq4pdKaktxp/1Zbn5GUR7X+fBmht1BzED0www7/zs29Taw GUsBH3/xDoyXow6dHvxYKPzES4Xj1zqoYD4OZkbi66F4pH4u5oR5y5zmDlsAT2Glyb r9h3L5ISHPLuO8dkWgdVDdNN5Cs1drurIv5S7qEE= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602100814eucas1p2af69e4ad0f660befbf5aa2b2213cc394~kz6siDBzK1995219952eucas1p2t; Fri, 2 Jun 2023 10:08:14 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 81.35.37758.E8FB9746; Fri, 2 Jun 2023 11:08:14 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230602100814eucas1p15571a8954a027cecc68bf8cf670c3cc2~kz6sQWdV92168721687eucas1p1w; Fri, 2 Jun 2023 10:08:14 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230602100814eusmtrp1be4717455196156d25dc8bcf60e53fce~kz6sP5CU71803818038eusmtrp1P; Fri, 2 Jun 2023 10:08:14 +0000 (GMT) X-AuditID: cbfec7f5-7ffff7000002937e-3a-6479bf8eb6a8 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 48.E1.10549.D8FB9746; Fri, 2 Jun 2023 11:08:14 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230602100813eusmtip1df27e3376303b6489f747f728197d58e~kz6sCO9SQ0240902409eusmtip1G; Fri, 2 Jun 2023 10:08:13 +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 11:08:13 +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 12:08:00 +0200 Message-ID: <20230602100805.777917-4-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602100805.777917-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+NgFvrOIsWRmVeSWpSXmKPExsWy7djP87p9+ytTDOa+EbHYs/cki8XlXXPY LKbfec9mcWPCU0YHFo9NqzrZPD5vkgtgiuKySUnNySxLLdK3S+DKuDatn7XgEXfFvRvvGBsY r3F2MXJySAiYSBy/+4Wli5GLQ0hgBaPEtfvtrCAJIYEvjBLXZ0VDJD4zSux4v4MdpuPaoj52 iMRyRon3p+azwlWtXLQOatYWRokD/Y2MIC1sAjoS59/cYQaxRQTEJU6c3gwWZxaYwCgx6xAH iC0s4C7RtvwfG4jNIqAisXDjGrA7eAVsJE4+ucgIsVpeou36dDCbU8BWYtmMp0wQNYISJ2c+ YYGYKS/RvHU2M4QtIXHwxQtmiF5liQnrfrNC2LUSp7bcYgI5VELgAIfE97a9TBAJF4nNu85A 2cISr45vgfpZRuL05B4WiIbJjBL7/31gh3BWM0osa/wK1WEt0XLlCVSHo0T/gmlAqzmAbD6J G28FIS7ik5i0bTpUmFeio01oAqPKLCQ/zELywywkPyxgZF7FKJ5aWpybnlpsnJdarlecmFtc mpeul5yfu4kRmDZO/zv+dQfjilcf9Q4xMnEwHmKU4GBWEuEVCit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pRTB9TBycUg1M/MdX5h8xEr66 QrvQfc406U8rvR5ryc7d1Gx6IqzoPP9FUZ9XbcytH+sSU5/f2liv+fd76HPbs/m/gt7cOcqi LD8jdGWDSMS6Qjf99SbGZr4i8TN61y5cnc6SyLG06kR2wavV/f53KzlKJ9Zqa5y60GjEu1Mi 0bjB7rp79ewyw8m31j7XzTu2VWt/bVFQTI7nrKd7+pwXaO3rtsqTMSwNKc7NvM3/3Pz5h/1h Xz0972c2thad36FzXLxl3muPabfPRRkkzY5wYJq7qY3xS/7CHa99udpn7Y3IyvHIYz72bQ7v yeQvh41ZW7/Fl25RnnanN+azhLDDiXklbxUcdTUs3pZ7zTQOX5oaP0vc3VmJpTgj0VCLuag4 EQBdLM/BMQMAAA== X-CMS-MailID: 20230602100814eucas1p15571a8954a027cecc68bf8cf670c3cc2 X-Msg-Generator: CA X-RootMTR: 20230602100814eucas1p15571a8954a027cecc68bf8cf670c3cc2 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602100814eucas1p15571a8954a027cecc68bf8cf670c3cc2 References: <20230602100805.777917-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 2 10:08:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados X-Patchwork-Id: 13265003 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 22B3DC7EE24 for ; Fri, 2 Jun 2023 10:08:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235204AbjFBKIb (ORCPT ); Fri, 2 Jun 2023 06:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235202AbjFBKIX (ORCPT ); Fri, 2 Jun 2023 06:08:23 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0C1C1AD for ; Fri, 2 Jun 2023 03:08:19 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230602100817euoutp01a92605cb8aaa4830493aa5e79e744950~kz6vKrk4_0248402484euoutp01W for ; Fri, 2 Jun 2023 10:08:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230602100817euoutp01a92605cb8aaa4830493aa5e79e744950~kz6vKrk4_0248402484euoutp01W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685700497; bh=f1HjrLD6njVVPjduaddJfi5+Ds9joRkOIy3esLq1bnY=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=ZpZ8dW85nTYstRrklw7jGepnTiGBveS5HeGJPFdQ2cdTyjfCrydvKtCVD8AaS40hm +cMvD7ssylGvBGm7rzHBkH5ANmlLZtNYJRH021nPz1PPu+LzDuAEbV5w6zTQHGGq+8 MzWlo+UULNbe3B+64ZUKHH5gMa3GJ+Swv1lK0Sd4= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230602100817eucas1p2a857bad455aa25270c84dfb1ff6ee0a5~kz6vDIJOP1995219952eucas1p2x; Fri, 2 Jun 2023 10:08:17 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id F1.30.42423.19FB9746; Fri, 2 Jun 2023 11:08:17 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230602100816eucas1p2c945884b8fd81603dbb39f65f1189f42~kz6uvPKLb1573615736eucas1p29; Fri, 2 Jun 2023 10:08:16 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230602100816eusmtrp13ae771f8a5597a66fa213d5326d501b4~kz6usXowp1803818038eusmtrp1U; Fri, 2 Jun 2023 10:08:16 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-bc-6479bf914b3b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 5C.34.14344.09FB9746; Fri, 2 Jun 2023 11:08:16 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230602100816eusmtip19e65f13776df3900286781284b8272be~kz6uf3oq-0246202462eusmtip1I; Fri, 2 Jun 2023 10:08:16 +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 11:08:15 +0100 From: Joel Granados To: CC: , , , Joel Granados Subject: [PATCH 4/8] test_sysctl: Add an unregister sysctl test Date: Fri, 2 Jun 2023 12:08:01 +0200 Message-ID: <20230602100805.777917-5-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230602100805.777917-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+NgFvrBIsWRmVeSWpSXmKPExsWy7djPc7oT91emGLxpYLHYs/cki8XlXXPY LKbfec9mcWPCU0YHFo9NqzrZPD5vkgtgiuKySUnNySxLLdK3S+DKONSyhLHgtEjFqv67LA2M bwS6GDk5JARMJE5daWTpYuTiEBJYwSgx781FZgjnC6PEiT1v2SGcz4wS/2dPZ4RpaV4zGapq OaPEs8enGeGqju18D5XZwijx4eFHVpAWNgEdifNv7jCD2CIC4hInTm8GG8UsMIFRYtYhDhBb WMBeYt6xa0wgNouAisSKX+/ZQGxeARuJtzf3s0Oslpdouw5xBqeArcSyGU+ZIGoEJU7OfMIC MVNeonnrbGYIW0Li4IsXzBC9yhIT1v1mhbBrJU5tucUEcqiEwB4OiSW7VkMVuUjsnfUDqkhY 4tXxLVCLZSROT+5hgWiYzCix/98HdghnNaPEssavTBBV1hItV55AdThK/J71FuhUDiCbT+LG W0GIi/gkJm2bzgwR5pXoaBOawK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MHIyHGCU4mJVEeIXCylOEeFMSK6tSi/Lji0pzUosPMZoC/TmRWUo0OR8Y 1Xkl8YZmBqaGJmaWBqaWZsZK4ryeBR2JQgLpiSWp2ampBalFMH1MHJxSDUyl8nIHRKRnxDqs nRudve7986SADffllJ6Hz9/+fTvLLMlDIRfSPBv4zppMa9m1bOmtx59WezcGJdue0WLoKZtr kMq4yymKw0CM3XnvK/X5/44nFeUelrvP8FQsfj7nARefMq/1LC86wn1tFoSEGs3bclTlNm/9 z0LlqSwJRbu4Si76+bLo5DBXsSkslf236E+TxWrt9zv7LIJbDzql9s74ePnOovup3ftf3p83 v07rAZ9jhB/nDve2Uo0nu4Uzk298MX3VcOAUq8CsstCGb0biXf7hS32lnDIvWiq1HQ3RSBVZ 9JyZy1clvXJij/Gj0IutpbNal206Erd/C9/HDfG8vkWLmOfzXnpc4MpqpMRSnJFoqMVcVJwI AKZM7RIyAwAA X-CMS-MailID: 20230602100816eucas1p2c945884b8fd81603dbb39f65f1189f42 X-Msg-Generator: CA X-RootMTR: 20230602100816eucas1p2c945884b8fd81603dbb39f65f1189f42 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230602100816eucas1p2c945884b8fd81603dbb39f65f1189f42 References: <20230602100805.777917-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()