From patchwork Fri Oct 7 06:30:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13000877 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 7A55FC433F5 for ; Fri, 7 Oct 2022 06:31:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229573AbiJGGbZ (ORCPT ); Fri, 7 Oct 2022 02:31:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbiJGGbY (ORCPT ); Fri, 7 Oct 2022 02:31:24 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2087.outbound.protection.outlook.com [40.107.243.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B7D5E319D for ; Thu, 6 Oct 2022 23:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LMwy/RC8n4J+e4sWWk7McmOwKiVju0oeXO9KFrig4WI/J9mbge+KkukCdcNmuLPW6xw5OuW3ggVmjgkZqi10tDZwIMeS20pCjtSkE1qjFMNUBmb62yf36X53TNRSQoAba40DL2xRopAlyQi4lxUD50xCzxJ4zuKqESvNK6q0XAGuKaWGqjIi94yzpFDIHLd8+NlMOJIfXAVNpjzZmf9nglh+q83I5wPp0psd2Hm89o5yAr3CqcEPF0MdVwuG2PC+maq4RCe9ewKLf+YcnVaytaV5PbB84NSGL9aYnvlzjvdlPNTY8+dKjYRur+BPRFZxZ5RYhYhpKln/ZyCA5rFVRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DSVaPpVQWWC2wfvjU3mMWpESVILb/hT2nHhrbRVE2p0=; b=FVQW9bo57aL77vNENj+dvvifNNf+F7/R6sDZec+KGE9qwAa3A7sjs0senpI8k6Mv3YhFGA3J0OLi6z292F1AJzIGAE/2VYY3BdAM10d+ylai30aA1ON/sGn/dqirDUGOVDqWbGxyuWmQI9MSU9OHG6kYD1MXTA24J0Fp7j+XK5zRb8OclAWbpESUepfD+5lu29UIjjJ/JP7zFBMUJZC0O3iXlUzZllF4CgmEIgT+lb7p8Fo4fSCAabsYtoPL+I4rQ0hijZKi0LaWuwLC9SyHxrcxnZccArChe0Acw3CLXfykC+xhRlRskDjuIoRlmyn8n1+rlTrrZyBS6c8uTYbL/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DSVaPpVQWWC2wfvjU3mMWpESVILb/hT2nHhrbRVE2p0=; b=fZaS/mrKCzC3CqEj/WhefYBJcC2JVkqYH1QBxjeFFWsGc7CQRjUZHFWA8f0LRTejr+Yz+5dHQoF/in+RkdKWiwAgidps3JXIwFl1LIcsxwIvp9dh14uS3GXiITcrKDh6YxDW9JPcP2qEYepJcUWUwNerg6QX9/zoYMD//xIQBwH17sxFb2HfMaUXqA4h/ZBZ40MXYoyxJHasZGfrw/PKGir726nvf5nIQzUoAMVZtZeiCZvK2mKablE4KRXuVivF+0GT1tGKnZWJS6w9/Yo0nO2r/Q0uHcqUAOhpql1GEgppok+NfhUwxVLa/xYjGszVva1AEaOrjJI0F7l0UU+8Kw== Received: from BN0PR04CA0189.namprd04.prod.outlook.com (2603:10b6:408:e9::14) by CY8PR12MB7588.namprd12.prod.outlook.com (2603:10b6:930:9b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.19; Fri, 7 Oct 2022 06:31:20 +0000 Received: from BN8NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e9:cafe::84) by BN0PR04CA0189.outlook.office365.com (2603:10b6:408:e9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23 via Frontend Transport; Fri, 7 Oct 2022 06:31:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT067.mail.protection.outlook.com (10.13.177.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Fri, 7 Oct 2022 06:31:20 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 6 Oct 2022 23:31:04 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 6 Oct 2022 23:31:03 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH 1/6] null_blk: check for valid submit_queue value Date: Thu, 6 Oct 2022 23:30:31 -0700 Message-ID: <20221007063036.13428-2-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221007063036.13428-1-kch@nvidia.com> References: <20221007063036.13428-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT067:EE_|CY8PR12MB7588:EE_ X-MS-Office365-Filtering-Correlation-Id: 321f04f1-0e65-4bb5-88f0-08daa82d8c21 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ez5uDB5mTq2kmOGJpcsJ0BGtVTggzdiOxxJDnkmAVjOBHhlvXovB4XzYBPQ5G7n7Ef67UEjrsu1E7U3Hc3FeaJTM5paOHG/9N2LC9P1f3d9gb8gSj+wszQKg8Ol9u61zU1HeHyPAUuoKsJ3Vz5JxUpEh1DvjdtLpdRoE6EEO5avU53a/4yP1AwPdebSe+S+YE6VnxuABNFYDOflBiJ9AVJn8sC0Hsb4vJyCM81m6iUzEmVy3wxnJp7x+7X3hg48WM63hv7P35UcHSE53Lm99GHC4fzhFe+SoEj9nAjKQQfvNZYHJJqHKkhL7vmfU8K21f8CwgQ5wKg8GgFRre/wXkMp8HQFF99IyP4V+MoeHK1s4/kbofUSiDjQeft15qe5/SElh3Av1sxJOBKgH5Kydse4iyZLiRbWuRt0Tp1a8czTZX6HJm6QHpTWlQ9fAA9ZSM5sOpc/zWX32qJn2IWkZAB6K97XXv7oF6VHOssQdMQk7ubCT+MdDXXVoeG9xDG08VcKUpL4zJqUxFNDRr1Cp+mlVSob5ApwuWKj+TPypOL31+6O9FDhOkhs4tb9RKfhS8+UOm1xPKLrtk9SGMTDQogp4OCMXNIO6kdS2ADzuZPlRE7/SXI3tSdvVBdZCEAq1tZxigTO7IxxAYQ5AKqW52S6O+XEqGllkFfqJFMwJBSbFb/XEvEoKyhLHkpBFOutHTFuJazTutkuwqwH4HkNE9KWzy5BRyiiwwzW7Wo2Qgy/mbA2D8j5ofMf63gw3LobqVxQpngLuqdH8GB6dQ37w+g== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(136003)(376002)(39860400002)(396003)(451199015)(40470700004)(46966006)(36840700001)(8676002)(26005)(6666004)(82740400003)(70206006)(356005)(40460700003)(478600001)(7696005)(70586007)(7636003)(4326008)(36756003)(2616005)(36860700001)(54906003)(1076003)(426003)(82310400005)(186003)(336012)(83380400001)(6916009)(16526019)(316002)(47076005)(41300700001)(8936002)(2906002)(5660300002)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2022 06:31:20.2318 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 321f04f1-0e65-4bb5-88f0-08daa82d8c21 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7588 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for submit_queue, that allows user to set negative values. Move null_param_store_val() at the top so we can reuse that code in module param ops. Add a callback null_set_submit_queues() to error out when submit_queue value is < 1 before module is loaded. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 42 +++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 1f154f92f4c2..c8dbff120c65 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -77,6 +77,21 @@ enum { NULL_IRQ_TIMER = 2, }; +static int null_param_store_val(const char *str, int *val, int min, int max) +{ + int ret, new_val; + + ret = kstrtoint(str, 10, &new_val); + if (ret) + return -EINVAL; + + if (new_val < min || new_val > max) + return -EINVAL; + + *val = new_val; + return 0; +} + static bool g_virt_boundary = false; module_param_named(virt_boundary, g_virt_boundary, bool, 0444); MODULE_PARM_DESC(virt_boundary, "Require a virtual boundary for the device. Default: False"); @@ -86,7 +101,16 @@ module_param_named(no_sched, g_no_sched, int, 0444); MODULE_PARM_DESC(no_sched, "No io scheduler"); static int g_submit_queues = 1; -module_param_named(submit_queues, g_submit_queues, int, 0444); +static int null_set_submit_queues(const char *s, const struct kernel_param *p) +{ + return null_param_store_val(s, &g_submit_queues, 1, INT_MAX); +} + +static const struct kernel_param_ops null_submit_queues_param_ops = { + .set = null_set_submit_queues, + .get = param_get_int, +}; +device_param_cb(submit_queues, &null_submit_queues_param_ops, &g_submit_queues, 0444); MODULE_PARM_DESC(submit_queues, "Number of submission queues"); static int g_poll_queues = 1; @@ -116,22 +140,6 @@ MODULE_PARM_DESC(init_hctx, "Fault injection to fail hctx init. init_hctx= max) - return -EINVAL; - - *val = new_val; - return 0; -} - static int null_set_queue_mode(const char *str, const struct kernel_param *kp) { return null_param_store_val(str, &g_queue_mode, NULL_Q_BIO, NULL_Q_MQ); From patchwork Fri Oct 7 06:30:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13000878 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 4B50CC433FE for ; Fri, 7 Oct 2022 06:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229582AbiJGGbf (ORCPT ); Fri, 7 Oct 2022 02:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbiJGGbd (ORCPT ); Fri, 7 Oct 2022 02:31:33 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2060.outbound.protection.outlook.com [40.107.95.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8129FC4596 for ; Thu, 6 Oct 2022 23:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dOwerxenXwjMRhYL0PT9ETwHcLio96mQx9E3ig2Tb6PU+nNEqJO9MTStzh2ZsTyGpJGm2PHZBWd3woTlbf61uOPJ3PUB3aWGVsAoTHkogDhJBmeMyQqydkL8rJhuRWwEXZG5UtBACCgK+rUBIuU3Ef+UqikCnWosgHmETLeahz1nzsGwgSSQ61YBi/VFwD5EMnIrA9j7SorST1b6bcOVxXqPwKBXw/t9nlKdyPuyav4gj2hSJ5T3gDOKkY02YLiUSdc3RvBGCHjQUQsh3pTXGQeqtUlLJJzES6BcqUSYmY7hAFWr29Ae7DNTCtrqUb0pRzZR9ydZCPEBYmYMOXU+RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gkJgnMAhvE/GYEbPeGlpe+60NAIzCeDKkPPGcDEWCgQ=; b=BYaXQudU1wxCGUIHnjAKppJYWRCJEWB058+CrOxW8bQ7suCxQZKQ3p0sNiJfbA6SEoi5TsAcnMGIdfLCrNspB2A5WhfCxABfff+66IqKRpOknjwWroUFYjncyYSPW6Psc4VH+W9It2VC9ysUCMW2fagpQfJZE1LnC8kDpfgJs53IRv36ZeYCck6nuDIhZWnh0y3FFt+EXqlqdoD569vFtQ3MHNqS2k3onQLVT70UrlBGYNehQhTT8YDSAPiZ+doL/wT383Ro2dGmFVzKCpit6yIrosIdlNC9yI+yFxSbvgT60uJ1o2vM6mTAaQ1Z7FLPyCz26pTBWaEbIWHlw+90vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gkJgnMAhvE/GYEbPeGlpe+60NAIzCeDKkPPGcDEWCgQ=; b=R9lIhJV8AyuzNJ+TSoWjpZ9KSIU8OhNLMiU61mdo7yl/eazFRgbmqtNWypbEka+L/5yyQp1aCnzm6nfxP7K+GUEfMnGtyF9NhJM5a4b/kin0zNSo+olKuUAMXR9b+NvkaSDrdGkE2acUdNYCLZjtKjEUS2zAGACM9I6gkME7iNUHyQU41gtIHt66n4s9Rxv2UG/raik0bSzcM3TpM8nLEkz1yCglx8FTMxfRnQJHKvUoKc2p9UW6yXbvYiBZGGPmegkj9Vr9xuocmFtE1Ofe9lO1XQVcjmvvGpcMiz9UcHUmj07+VhVmoY85dOn61G3sLMEHwMzFcJUd9y5KQbF1UA== Received: from BN9PR03CA0141.namprd03.prod.outlook.com (2603:10b6:408:fe::26) by CH2PR12MB4261.namprd12.prod.outlook.com (2603:10b6:610:a9::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Fri, 7 Oct 2022 06:31:31 +0000 Received: from BN8NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::b7) by BN9PR03CA0141.outlook.office365.com (2603:10b6:408:fe::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.26 via Frontend Transport; Fri, 7 Oct 2022 06:31:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT044.mail.protection.outlook.com (10.13.177.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Fri, 7 Oct 2022 06:31:30 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 6 Oct 2022 23:31:15 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 6 Oct 2022 23:31:14 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH 2/6] null_blk: check for valid poll_queue value Date: Thu, 6 Oct 2022 23:30:32 -0700 Message-ID: <20221007063036.13428-3-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221007063036.13428-1-kch@nvidia.com> References: <20221007063036.13428-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT044:EE_|CH2PR12MB4261:EE_ X-MS-Office365-Filtering-Correlation-Id: 60cff45b-a112-442d-201e-08daa82d9255 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OxA0dM9Nq6+GwDI+xxfKXMLRyIzZNGogn/SKvFTOHSiHZL7w4pnSl6Q/5XfSDz87ArWQq8kmN2ZollR5AT8rdXEgH491nsLT6+SnWXSkAQh0dnz7I3EZZekJedtRkuVKkapn2J2zYEQT6IiXjdw9KQP3k9AWr/KdRpOIFE5UwU+8N77gGozV4GRPbJMtGw4VUXlNnn38oCuUKYB6QzJLop7sRTLmKWqaBqFd2qZZm2Uo3fR8uH5i2VqL8Ttjzpuocq2C6Pk8PqIaxAEJQGo8L76RTyl5cqbQwg2VfPndQkgry/W6lwDC6D1DE+wlTHAJJG6fRZHzfjH2NN9scOCXMMwG9TE7G9MRATmaOQgyOKaVw5ZDzYV/POtHk/sIxmNyrow4dwh3yOhKBF5TxpN3gLNxSbKvCsDPMEr3XmFqYTFQgl0H8UxjZn6Pmh7ifU3eS0QraPPU8aUyitx7aqRwvWky269eV0y9Bwwcwp/ELAe0Su3pVVAMKN2H0PuvR3dVuy4NNQp6K7GW69oy271pQ+3PSX5hHXf/28cO7lfBEy6/U9G+EO4nBHxnIBCR0nqhb18UO6s+qHQl7em7RGC8kvHAOJPv+dK2ASjOeLeRWdolcKn+9YyI4CKEOLmkGEycuwJxNGpXezKZjNthjIN/3mBK7924gTwfyj/QBkTxtxs7YUt+sOGoMlDFrRzJgrMWTeg/tbhpBawWxS2A0qskF9UEWMv88ewUUypoIqfdc4gn0dWVVpDMQYUZGCnZfL7wyNkD7q7JWK4ySC+zfTE7Uw== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(136003)(376002)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(2616005)(70206006)(70586007)(316002)(4326008)(1076003)(8676002)(7636003)(478600001)(336012)(40460700003)(82740400003)(2906002)(83380400001)(16526019)(36756003)(41300700001)(186003)(6666004)(7696005)(356005)(26005)(54906003)(6916009)(40480700001)(36860700001)(47076005)(8936002)(426003)(82310400005)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2022 06:31:30.6362 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60cff45b-a112-442d-201e-08daa82d9255 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4261 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for poll_queue, that allows user to set negative values. Add a callback to error out when poll_queue value is set < 1 before module is loaded. This fixes OOPs with invalid poll_queue value of -2 :- Entering kdb (current=0xffff88817eaed100, pid 5624) on processor 12 Oops: (null) due to oops @ 0xffffffff8165093f CPU: 12 PID: 5624 Comm: modprobe Tainted: G OE 6.0.0-rc7blk+ #53 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:blk_mq_alloc_tag_set+0x14f/0x380 Code: 83 c5 01 3b 6b 40 0f 83 9a 01 00 00 48 8b 43 68 4c 63 e5 4e 8d 34 e0 f6 43 58 08 75 d7 8b 53 44 89 ee 48 89 df e8 d1 ed ff ff <49> 89 06 48 8b 43 68 4a 83 3c e0 00 75 c3 83 ed 01 78 0f 89 ee 48 RSP: 0018:ffffc90002eefd70 EFLAGS: 00010282 RAX: ffff888112b155c0 RBX: ffff88811069dc38 RCX: 0000000000000003 RDX: ffff88811069d000 RSI: ffff88810ed60000 RDI: 00000000000001f8 RBP: 0000000000000000 R08: 0000000000000003 R09: ffff888112b15650 R10: 000000000010ed60 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000040 R14: 0000000000000000 R15: 0000000000000000 FS: 00007f71e4147b80(0000) GS:ffff888fff500000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 000000014d81c000 CR4: 0000000000350ee0 Call Trace: null_add_dev+0x7a7/0x870 [null_blk] null_init+0x1de/0x1000 [null_blk] ? 0xffffffffc03a9000 do_one_initcall+0x44/0x210 ? kmem_cache_alloc_trace+0x15b/0x2b0 do_init_module+0x4c/0x1f0 __do_sys_finit_module+0xb4/0x130 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f71e426e15d Code: c5 0c 00 0f 05 eb a9 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d e3 7c 0c 00 f7 d8 64 89 01 48 RSP: 002b:00007fffb29f27a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 0000564b29d78b90 RCX: 00007f71e426e15d RDX: 0000000000000000 RSI: 0000564b29d78f00 RDI: 0000000000000003 RBP: 0000000000040000 R08: 0000000000000000 R09: 0000000000000020 R10: 0000000000000003 R11: 0000000000000246 R12: 0000564b29d78f00 R13: 0000564b29d78cc0 R14: 0000564b29d78b90 R15: 0000564b29d78f20 [12]kdb> Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index c8dbff120c65..29e43444cf66 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -114,7 +114,18 @@ device_param_cb(submit_queues, &null_submit_queues_param_ops, &g_submit_queues, MODULE_PARM_DESC(submit_queues, "Number of submission queues"); static int g_poll_queues = 1; -module_param_named(poll_queues, g_poll_queues, int, 0444); + +static int null_set_poll_queues(const char *s, const struct kernel_param *p) +{ + return null_param_store_val(s, &g_poll_queues, 1, INT_MAX); +} + +static const struct kernel_param_ops null_poll_queues_param_ops = { + .set = null_set_poll_queues, + .get = param_get_int, +}; + +device_param_cb(poll_queues, &null_poll_queues_param_ops, &g_poll_queues, 0444); MODULE_PARM_DESC(poll_queues, "Number of IOPOLL submission queues"); static int g_home_node = NUMA_NO_NODE; From patchwork Fri Oct 7 06:30:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13000879 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 DD7DCC433FE for ; Fri, 7 Oct 2022 06:31:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbiJGGbw (ORCPT ); Fri, 7 Oct 2022 02:31:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiJGGbp (ORCPT ); Fri, 7 Oct 2022 02:31:45 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2083.outbound.protection.outlook.com [40.107.92.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3245DE319D for ; Thu, 6 Oct 2022 23:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QXLWpG/kFTEPLzR9dpj/+dYU9LG0vnITP204mM7w9Tn94oh5mBSXYmhpiJ2VtB2/mb27QTNuw8G6sT+UhsEqM5GpqJ74jmls7Pt0OfO7mQ0G9wTDWgv/EQMOGgaki39Gj3HYo03ODEImGp5+pewbAa9yJFxnVA2Nn06utDuo+ElLPToryOpgpRPRR1dJ/1p97m1XCAPu4rVWjRJ0zIGGQbNijTCBZMP9/cDas2ffeRbugtC8APMr/UhdZNdxb6lsjIJM+bf8hKpxpOKmA54mc3JoixSar3dX27kzbYOXJ/iFvmG5FF4DVvhkAUVdPciGzsMMda1nlc0nTgLZ5WcxDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HxfqhzuC1gwwygt8nD2oQm5xT7OM/dOrSmCsRHlGBeA=; b=XM6oHFP3y+3f6tFTH68tZOJZY47Joqv1xoQDT24uyBht4xB+y+pRqqxZ/LreBwZXp6YFrkxn0wwY0UgdxfUYaYGqr56+UhA9VmNXNk2vPo1u78u2X9ywxYDfu2oFn4/IqvkWVpXY3jm97qc0ZT2YKiiDDe/fnqqgC+Zu/6smkJWo+QhfSj4Vc8rUbpN3VYK8RHK/catyKOR/dPMRBCZEMdNl2eQM5KNVoZAyfo5x3D++VPrGx+BU+wH3PsJEnxy2vHi2621Ei9dfroH1oUSIZlMNfN7EvFC18Bxi7PfW9z4czhreNsnxaxe7QLDfF+VTpFixLJTTOigF1jBaW40Nsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HxfqhzuC1gwwygt8nD2oQm5xT7OM/dOrSmCsRHlGBeA=; b=jHD+YrSe/VU8WuNbiThZxNbDAOJ6kESM24O8CIObr7aprr8u14t97wYcMTFgP4kAMyDHghHhYdjHKlJKceiLsbjLECIdpHbAU8/B01t7oIN0o4DPktmjBqJ7EX6lVUKvmYD9h3LbOfj/SF44lFK7qPv8q7jOeJT+6qsdZ4kFrevrYQpDgAXVpgmTg1h5zdLvXqVWve0qqRU6gIhHpXNSu4saOq6pRcRQNOa8lhxTIrU9iYzC3g9fE5Qx/WoFqDzkjwdkvQFvtiamXxFgeIRraZc7b714UIcXsjramP3RPD/YW9Ao15puwbLoYh7nLZyzH7ZofWI9RYdMMo7WT8cVMQ== Received: from DM6PR12CA0034.namprd12.prod.outlook.com (2603:10b6:5:1c0::47) by PH7PR12MB7138.namprd12.prod.outlook.com (2603:10b6:510:1ee::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.20; Fri, 7 Oct 2022 06:31:40 +0000 Received: from DM6NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1c0:cafe::81) by DM6PR12CA0034.outlook.office365.com (2603:10b6:5:1c0::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23 via Frontend Transport; Fri, 7 Oct 2022 06:31:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT012.mail.protection.outlook.com (10.13.173.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Fri, 7 Oct 2022 06:31:40 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 6 Oct 2022 23:31:27 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 6 Oct 2022 23:31:26 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH 3/6] null_blk: check for valid gb value Date: Thu, 6 Oct 2022 23:30:33 -0700 Message-ID: <20221007063036.13428-4-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221007063036.13428-1-kch@nvidia.com> References: <20221007063036.13428-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT012:EE_|PH7PR12MB7138:EE_ X-MS-Office365-Filtering-Correlation-Id: 794987e9-c7db-40a8-3627-08daa82d980f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ImZAQoj4HxuLL97BWPhMeEnuqzCo0f5R2IejH+89oQy84WfV97Z/077WEwXpHXiGpRfdB1Zry2YdK9VpF6Zonl0FT8JcfS/a8ZIRba1b5mwCfQ0oyDRdvy6nsSa6hXpgEDcq23w0WVDs5+l7qM8iJmFa+wdXKLsbav747itCNwScNnDn+IAxjiNr23LaCYWXarZzrPoJVna7xLYK3t3ckZMcr1KmFb49IXTofPjG3kIDg9tCbrb00tgWw1UBW5D8lihXxg7Hm8CVxhRreKyKn1DLSFKIVaWKNRs8FpFdBsoN3zygczkMSbsFq0VIStPMjMEm77blUUxR41L/hOkD0ZZgf8V9SF2wk/NqzLpV6C+oP6vNpAE/NyGSISr3kvspMOhYcpmCVu5IpXWGUy/VY8+h+g7ugxokQ3hMudh078d3g5ib6X/4XHtUbu0+pM7rYFY65waQ83XjKIWQoES0Wd83CXbMErjpAQNbBTx0fLbK4LCMT593R7uhpfLdg/sf25mnfTMiRGCqr6vM4quSZasGeknRDiwoamhABV6RS3qzqSgAmN3usyIy3XoqtiCAVLM29nQYbSY6Ka6gxx+HHdRst2asjfDxRA0BltifFs2nEMETwGr8zKlBQ8/d6ayln6UFkno/Y8hTqHNeC0K6bVRsahPdxn8huqgIMzSqqVSNAR9Qsgdal7cDgJo31FkMDOnjn2BN39qUa5zIhcnjfdXd2Z0qDzaY91xsU0OlFf2K1hlaALZAgSBdD0ZcYPByvpEd+9PZMdxDDFpFV+u2Rw== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(376002)(39860400002)(346002)(451199015)(46966006)(36840700001)(40470700004)(8676002)(82740400003)(6666004)(26005)(70206006)(356005)(7696005)(40460700003)(478600001)(4326008)(70586007)(7636003)(36756003)(83380400001)(36860700001)(1076003)(54906003)(2616005)(426003)(82310400005)(186003)(47076005)(336012)(316002)(6916009)(16526019)(41300700001)(8936002)(2906002)(40480700001)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2022 06:31:40.2600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 794987e9-c7db-40a8-3627-08daa82d980f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7138 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for gb, that allows user to set negative values. Add a callback to error out when gb value is set < 1 before module is loaded. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 29e43444cf66..83bf9065831a 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -165,7 +165,18 @@ device_param_cb(queue_mode, &null_queue_mode_param_ops, &g_queue_mode, 0444); MODULE_PARM_DESC(queue_mode, "Block interface to use (0=bio,1=rq,2=multiqueue)"); static int g_gb = 250; -module_param_named(gb, g_gb, int, 0444); + +static int null_set_gb(const char *s, const struct kernel_param *p) +{ + return null_param_store_val(s, &g_gb, 1, INT_MAX); +} + +static const struct kernel_param_ops null_gb_param_ops = { + .set = null_set_gb, + .get = param_get_int, +}; + +device_param_cb(gb, &null_gb_param_ops, &g_gb, 0444); MODULE_PARM_DESC(gb, "Size in GB"); static int g_bs = 512; From patchwork Fri Oct 7 06:30:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13000880 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 0C763C433FE for ; Fri, 7 Oct 2022 06:32:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbiJGGb7 (ORCPT ); Fri, 7 Oct 2022 02:31:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229663AbiJGGbz (ORCPT ); Fri, 7 Oct 2022 02:31:55 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2080.outbound.protection.outlook.com [40.107.93.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F060115C11 for ; Thu, 6 Oct 2022 23:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eQIi3dQxBaWadzUfSJrNzgGJMmLL/HRfhYn25oPBCuOPftChkcErcFwS46C+7iyUYpYxMyEhPA7wDiWF2anJd/1yORfLee98Za+wmqOUin4opdGk5s0Tl6oqsJOg3Xf41j3yAfBKUnTnQLuCmFFU0tX8SuBEhdjK57zKR71EMSml/EK0fKIABndlwPJuxPEag+rO7U92OidgC/NoeSLZOvD1QFPzHyrnkT8NRb6UccKpUIC7njmPQpn5TgV0yEudZ71X3yhdMjUZBRIgqKMgC4pwVk8rda4OF7DCVRqg94uLYb1uGpiRMria2Dhk9fe/QmiZw1g1CxIQ0iiBh8+iaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6cJTmDi1q1+r8ju23ipeqrbOanoIov9Sf/VrRL3TonQ=; b=RIFxMX2/2PZU56W4kglB945Ndq/Y+spHKPY0Khnik7xs0xb9gnXI/e8db05dF58kwU5hUpntPhR9TMbZ9VPIajVxiAoNDPvQHRiSJZ03vOlrZGXwtQdB4TXYPChaJRuNr0fKgjywNZo+ZCMEbNGjU9K7b1Le12BVSIjTabqfFFpvHGKmrCFn/kiDoShjftKutRUkB26Qy6mbD+rmormBdK8H0noGCaR/PtaDnCgSQtU38zP60xlEmXykfxjnDJ14EyhcCvLgb7IcuTd/0fUcnfsHydWzy61HXlerHxW8B3njJVl/+qUBGFsqHwyfRWGMKGSG8Zem044e5m1nKkZTdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6cJTmDi1q1+r8ju23ipeqrbOanoIov9Sf/VrRL3TonQ=; b=NLBOb/44MyjKWV3z/kqLxcV4dXgJJ2ormq/a4cr1Xk9ZZTXPGUb3TUeBsaAj9cn3jUIn8v5+xsV3D5WL4cRQhcCNuUHiZSjmY3tu12c/yBwKA2KddKk6iz69qGAGLmxmtX+zoBHR/PMDIA/NbvaCigm9sZHjqde8L6neYGyz+42KNPTvzK/1QjKeNlscYHBgOFc5M6P6njiY7BgGyyN+qK3GPR1y5Vch8vXgsTLoPUhDgST14DkItnXB2DOggi9aZuEizLV5keCgkga0XKVex4gazUwaJcq2MyaPTIr8ZAiYlYFQrURSH6+HZLPxbrExKp4ODNlI8SKkzWVI9ixsdw== Received: from DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) by MW4PR12MB7384.namprd12.prod.outlook.com (2603:10b6:303:22b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.19; Fri, 7 Oct 2022 06:31:52 +0000 Received: from DM6NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b4:cafe::f1) by DS7PR03CA0137.outlook.office365.com (2603:10b6:5:3b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23 via Frontend Transport; Fri, 7 Oct 2022 06:31:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT098.mail.protection.outlook.com (10.13.173.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Fri, 7 Oct 2022 06:31:52 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 6 Oct 2022 23:31:38 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 6 Oct 2022 23:31:37 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH 4/6] null_blk: check for valid block size value Date: Thu, 6 Oct 2022 23:30:34 -0700 Message-ID: <20221007063036.13428-5-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221007063036.13428-1-kch@nvidia.com> References: <20221007063036.13428-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT098:EE_|MW4PR12MB7384:EE_ X-MS-Office365-Filtering-Correlation-Id: 81ce81d7-dd95-43a4-df92-08daa82d9f44 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: itIkB9mfZ39PvlhQsfshYRVms0LoOs9OT5W723LvKeMU0ti5W6fJpl7iKMeOHbZGD1fI+ByOtvQiSA/6TE9OrcWPe0PgIqzJq9SxcWler+3RgdyvM+LznXxyxp6Xv3mQ0DrwxpesB1Uo2Cc57oAJT7z2NCPxQl+efb9y7kCMzAFdRFdsNwKbjlq22tYHl0NADgYbAIi1BfvnCkgQqGOOvgv8sg6Fn3X+jpM/wIpQdWDFS7XiqqIgywyULpvXrf2q3JRfgupxBc4sQ3P9BENw261ERCx1C23lqt5sSGiQLhy0C3pxq3pCR9JsR42BKEuqUvvi694w50de0187mx5vqFQ7/nzxLFu3FpJr2RA6nUjRDVfBnnu7l8BpicwZ33jc7gZucfouFx60DInSCSjUbAgvj7MMV4k4mTuz3Zg2u3cq+p0mJGRSDIZnDtYR8y/95D7srAN0+kPQRBrDXKfC0Q38mlde8xaIllFexKKOPzI4c1qKn1Xtg/LzEMp/cwuUuCal97i6fkfUedbDbEd7WMcoCi2cVj6avmXEMZ2ZNVU4OVacgUxAsKUJd6WFxy1V0dZAkAUla44RkSjaqg1aC+iDN2ophV0Ilgxwz6n9ay9thDPlMRPgzvvU6AKj2N2VDt7Nbr9TVUkZiK72IhdYzyRK05dVTIt6l593cIpfjc3DyER/CDsJs7ceqt1C9iWUK7Fj+4JUiuklXhWj0zFvWGeuIH4F/B8k7Hr6N7oY8elMTCdjp+kpqjqJtqgyGVTkriSixE0Nl3hnGMIC2EDRQg== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(136003)(396003)(39860400002)(376002)(451199015)(36840700001)(46966006)(40470700004)(8936002)(336012)(426003)(82740400003)(70206006)(186003)(70586007)(47076005)(83380400001)(36756003)(40480700001)(8676002)(4326008)(6666004)(478600001)(16526019)(6916009)(54906003)(40460700003)(356005)(1076003)(7636003)(316002)(7696005)(2616005)(41300700001)(26005)(36860700001)(2906002)(5660300002)(82310400005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2022 06:31:52.3557 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 81ce81d7-dd95-43a4-df92-08daa82d9f44 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7384 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for block size, that allows user to set negative values. Add a callback to error out when block size value is set < 1 before module is loaded. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 83bf9065831a..7cfc1eaa5e3c 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -180,7 +180,18 @@ device_param_cb(gb, &null_gb_param_ops, &g_gb, 0444); MODULE_PARM_DESC(gb, "Size in GB"); static int g_bs = 512; -module_param_named(bs, g_bs, int, 0444); + +static int null_set_bs(const char *s, const struct kernel_param *p) +{ + return null_param_store_val(s, &g_bs, 512, INT_MAX); +} + +static const struct kernel_param_ops null_bs_param_ops = { + .set = null_set_bs, + .get = param_get_int, +}; + +device_param_cb(bs, &null_bs_param_ops, &g_bs, 0444); MODULE_PARM_DESC(bs, "Block size (in bytes)"); static int g_max_sectors; From patchwork Fri Oct 7 06:30:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13000881 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 6DA03C433FE for ; Fri, 7 Oct 2022 06:32:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbiJGGcL (ORCPT ); Fri, 7 Oct 2022 02:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbiJGGcK (ORCPT ); Fri, 7 Oct 2022 02:32:10 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A2DBF2528 for ; Thu, 6 Oct 2022 23:32:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VNLJhBw2FK57UoDjTwXSlNHRqgIe45sHWV5IiQAPYqXVRt45+LPNnfn9KE4Cu1tJ7rMW9PQGID16cGwVUhExjgQXbfriDP50cu2FWYXL/RGrcVf9GIeDefM0xnSUooleYUiHb6YFiGNoatO65br7PCJEZXfKtRZYqfReuS5kOv8mJLtYt3FqDEc7/Oc9FR5UcT0MUBrTFB2zv1qFVBNCU2nTZ7psC4OcL0VMnnnWA1R05dLMqGlPfcztSicM5ZNAq2iP5WNv6iPfLEQoX2yFHKnKR7raRbKmw9CzSH5nHVcCdAa3ZpO+rfVf5v1LeiR+hIwMKUWFLa5T/4e+/IuAzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lWEb/hALhtdYFGUjTq0CWn9EDOs0shJvZ0y8GbOm7To=; b=lmGnuc5M71C0HfkGpUQxu7LqqmgXuZGkNVHlLMOmGKBR7UMypoY+j0YFVG+MlQFjhufftzNtThr/lS9Mxm5UlVTbZgiAMGTUFS711ReE44JvdZsV/QN2jEWQG/VBqZtmhpIbmNSbQ9QxWV8UvYKZXSUqHrBbU7wbxRKoI/6AklDvKkfJ9QYcGbVtdkF3TJcMefiNIk/L/e4714kqS9S5H98EtODlA4jzLUjFXRBmIt8sevPGvrWGvfJUOIqCA9jZ7d9XY4eoHP4pMOMhK7fQ2pfVO5tyMJcoodNUkILdYKusDoUOiL/bMMLmlrFgcyaooIb11Nk/3WPjLHxUzmOF3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lWEb/hALhtdYFGUjTq0CWn9EDOs0shJvZ0y8GbOm7To=; b=St6h6Y8LLB0/2b7ncNJ6MLkz6kEI/AukRQg+yY6FGdF94C61PoDMGlLRCCTExRItNM9onyR/sZMHX7VlZO89hTFwPNSRkUv92W4somG/Qr7Wi6axxrL+mAiioXVcF+1QbaYnJG6xPvJUaXoWVSAnWPn//pXc4CpghO/E2ljfbKutLZpP7mtRSPMH2wc/mOojjK5XgKYJZrny8pvq5cDn6RWvQr8uEIMk3AS3UzPH3MAXUojJa7tTldjcjqm05zGsTMqgmS4ASvnINsDKIkUgzTAnl4SQNtPcn3nM7SKh18zSBhE5Z5lfqeEnYUBVUwRRVcjd9fjw4dDzRKu3I7I+mg== Received: from BN0PR03CA0028.namprd03.prod.outlook.com (2603:10b6:408:e6::33) by CH0PR12MB5027.namprd12.prod.outlook.com (2603:10b6:610:e2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Fri, 7 Oct 2022 06:32:07 +0000 Received: from BN8NAM11FT092.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e6:cafe::11) by BN0PR03CA0028.outlook.office365.com (2603:10b6:408:e6::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.26 via Frontend Transport; Fri, 7 Oct 2022 06:32:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT092.mail.protection.outlook.com (10.13.176.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Fri, 7 Oct 2022 06:32:07 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 6 Oct 2022 23:31:50 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 6 Oct 2022 23:31:49 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH 5/6] null_blk: check for valid max_sectors value Date: Thu, 6 Oct 2022 23:30:35 -0700 Message-ID: <20221007063036.13428-6-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221007063036.13428-1-kch@nvidia.com> References: <20221007063036.13428-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT092:EE_|CH0PR12MB5027:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e3acd9a-b2c2-4f1e-5f02-08daa82da840 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: raZAoFf31kA2T9g5nFEg3RUqMFGrHXh54cc4mfWhjdPLqH10xGkiXWFmqno6Izs/DvwJfRvBtAobkCY1uaAezDGSbPaV340POD0yuyb1mb2u9gbdrdD+6ApSnh0TDhVx7pE84k0QR1V/3GEmtVy7RSH3Gg1TUfM/rCw19cmVxIvjRlOrrZXoxn+Nf0zUuzA+mVhYQcE4dBtJuK5JeKBXFNTjCBfP4zKv7344d37Xl4OoRvAjMBopYtpJ0pClPvSIzS4RxL9/CV8VWVR8499lttet8h/TOq6ur29D+KIE/IXaxOv/06QkktJugfr5ptaFF3l5pMLebW2Cx2JNrLbqJwH88UJMMBr0NJvfJOCc9mmR1KRRlVIy18QpZXJSquA+kA8GnypbeemRYA7aZ5ORjjPB+QLr/x3qujyjBDmWKFytWSautI7kVfrISI6Y+fladdFsiv54aCgqyZwjfeX2gyVuPzHRDXKHklKnSul7RDFNuFi5p+ILRl1/ZWbAfXEfXOgcQ3uXWCLXxpgdhRP0UKRoFURWAZOxDEt9FYsGwsDBQNVTnB3rAcaxLJOGU577FBdAldDrWw8lBvfCgKBfHyDYxq38HjbmAN8bTqNlbB9mACF2HsIk3JRd7VMIfqmrLou3yNi7esvErEfXEJSZjEHMgikoIXfgGLcZmAiwzDPLDlfwZstzo3IdzKBPaDQT651N1gr2wcS9zzV2VFNSmB9uHUCANBdaaBHB3WPPeZP2cJfZJwiqHkiXi41eZl/mZ5r1Y+8/8ZuiAamW93U99g== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(376002)(346002)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(8936002)(5660300002)(41300700001)(2906002)(7636003)(40480700001)(26005)(70586007)(356005)(40460700003)(426003)(4326008)(70206006)(8676002)(6666004)(82740400003)(2616005)(82310400005)(16526019)(47076005)(336012)(6916009)(36860700001)(186003)(7696005)(316002)(83380400001)(36756003)(478600001)(1076003)(54906003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2022 06:32:07.3944 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e3acd9a-b2c2-4f1e-5f02-08daa82da840 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT092.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5027 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for max_sectors, that allows user to set negative values. Add a callback to error out when max_sectors value is set < 1 before module is loaded. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 7cfc1eaa5e3c..1b9fa5af02d5 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -195,7 +195,18 @@ device_param_cb(bs, &null_bs_param_ops, &g_bs, 0444); MODULE_PARM_DESC(bs, "Block size (in bytes)"); static int g_max_sectors; -module_param_named(max_sectors, g_max_sectors, int, 0444); + +static int null_set_max_sects(const char *s, const struct kernel_param *p) +{ + return null_param_store_val(s, &g_max_sectors, 1, INT_MAX); +} + +static const struct kernel_param_ops null_max_sects_param_ops = { + .set = null_set_max_sects, + .get = param_get_int, +}; + +device_param_cb(max_sectors, &null_max_sects_param_ops, &g_max_sectors, 0444); MODULE_PARM_DESC(max_sectors, "Maximum size of a command (in 512B sectors)"); static unsigned int nr_devices = 1; From patchwork Fri Oct 7 06:30:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13000882 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 18D09C433F5 for ; Fri, 7 Oct 2022 06:32:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbiJGGcW (ORCPT ); Fri, 7 Oct 2022 02:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbiJGGcU (ORCPT ); Fri, 7 Oct 2022 02:32:20 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2046.outbound.protection.outlook.com [40.107.220.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3734CC4594 for ; Thu, 6 Oct 2022 23:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kDWC/t/4dmslbJ81Q0/ze1xll6Nc16uIayWeyE7igVCfLLwliYAwhy5Hd/di9Irn7PYXWLuJrHZVJsEWK6N+RDNc3RLrYq00lMYGFFcDZozvuKbEyGAixPM7urlwSMznqTZXobwUgqCmE59LryQpKZsTMsGwwvZLqgclTf3kHMcDf7Ir4nPgArJW4+CSUzLux+ATrWSUVVH1p2ZaJ/BtMDTEBY7Kxd9m++7/8SXhpexiqcTRQnamuozAl3A8XuibXV4smo/2QthmgB5ALDnjKKtNRXEGGq8CqTVqLy+870D7CtVKK78cuy27kFPM6dM3m1rkrbLIpGA2oMsF2N9H3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ffz/m9EapRYdEuNUhQr4hjGXmUzzPF8SQq+c3j8nnq0=; b=NgkyRCLqWiscoPxIjQkGpLimWf9/nLts+G9p6YsIExuYsk3Xips5u60lN74PY3RJ46dYkI05PVTn3Lb3tkf4m889W0ptIfqF6aG0NTh93TuaGEHbCMR3G11XRD7LIKdTMRExwPfTp1SY8WKVej3LwNGE24EP9GdZDmsBgNgPOmAqLvwK/na7AJG1Rs9oRjy49oNO2vEUiiG7E66lIO077O7Je0LK7oV8sYaqhwcoa5UAn+Kn3Wgw35Dwy088fxlbrcw7rn5y4rAxRTC1hN/CvnYqjjzsUsbQfzbdRWDRODg5dUegs1e+DqyX9dEfhT5cYw/zWLpqi1ZDwiMSkQLxwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ffz/m9EapRYdEuNUhQr4hjGXmUzzPF8SQq+c3j8nnq0=; b=VDdSiZqWSNF/betBQq5+IoXl5tIE8dkRUxaR4weAJKGZ3Tokwis8r1LWDhnZ8rPSHt8QsiW1ZFBkx7trnXcb1nvjYFW52Fb57QstCeyMiZnm02Sqem/Ebl/rx1+hK0gM5rzeJjzjhKR61+x7vgDqB+kzILhtsYnXIYppaMXpc99CZTqxi8A3v/yIaRvTt1a64msAymhsTUC+dohd9qWX11bT5Msfq78YtbIqVrniadodNyTRjSqgYNnXJ/dYZKAZ8dulfV77h103IKqOh06LUV7Z8XGFyhKt6M4r86bisS1MXs+edb2HxhxbL1cEwaieJDcn2kIaOPyCcdZoc01Zaw== Received: from BN9PR03CA0523.namprd03.prod.outlook.com (2603:10b6:408:131::18) by CH2PR12MB4890.namprd12.prod.outlook.com (2603:10b6:610:63::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Fri, 7 Oct 2022 06:32:18 +0000 Received: from BN8NAM11FT092.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::be) by BN9PR03CA0523.outlook.office365.com (2603:10b6:408:131::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24 via Frontend Transport; Fri, 7 Oct 2022 06:32:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT092.mail.protection.outlook.com (10.13.176.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Fri, 7 Oct 2022 06:32:18 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 6 Oct 2022 23:32:01 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 6 Oct 2022 23:32:00 -0700 From: Chaitanya Kulkarni To: CC: , , , , , , , Subject: [PATCH 6/6] null_blk: check for valid queue depth value Date: Thu, 6 Oct 2022 23:30:36 -0700 Message-ID: <20221007063036.13428-7-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221007063036.13428-1-kch@nvidia.com> References: <20221007063036.13428-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT092:EE_|CH2PR12MB4890:EE_ X-MS-Office365-Filtering-Correlation-Id: 7dd0d718-b952-4840-1c8b-08daa82daef0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DpCKQua//mJCOfWYPR8t13++Eyw6bK4OgvTs9UfGZ6fKHS3RoZxRtZCOc+B7oXrSqjUD+fdR6b5Mu9tQ5lW2O6NBFSzjVXv+tAF/7ZPjx9TgAn07Vts/9/R7KBz8NyxhoZ7HXdnUMA2OokxYY1GylQjJZLq9zMbyYNjU3Vb8u30I+Cd0JY1QmPCTA4tsldy6N5GzQh5IOwQ8T3YpN+rEQRvIMsKYqYQm3bOToLCAfeLdRgfX++jjqSPx818DhrwFFsWwH6Eeug0yn0jS9ojevm653zskfteMaIb1vW31t6zySW5nbtJU87s9a/7V1XmvxNjmRBBrerBqx6mUum1ix34/yRqCPQNWgHhkzO9fBu+FlGRMlCbrtMyo6Ras0WXBWisacNw9Ng7/np6fz1eAtqu/+sr1vpY/cPcSx73lt7HyhvGWERj8eu774ddrBhXC8yQILQUXxrEHRAqASKghZOQyK+daAIDBcoQ4vIAQRN+LsfQNYPrHs175MFPP8TuGgJX9WtiDSIWxjtSe785cd7Oof81qx4D9rEWPNMOBMe9R7yGDtWvlJa4peQbaBh+ytBBV1M39+lUJMr6a8xhm9qSRqTVRuMCCOn312gpFmL+lZHGkPJLPl0tfuoWviEEds8Vc+1XldlRRAdmzsVUj4hKkHykSaWzz9BI/D0562CChMvMI4mgyOvcFOkcLZp24PhqE4b5yt7Bvb8zoGK2McihRmlvLCQm93VGdK0e3cuW2ftGauFsCmVllXDxQRAHdcgL2LqZP+UySMEWCCTBxyw== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(376002)(346002)(396003)(136003)(451199015)(46966006)(36840700001)(40470700004)(336012)(47076005)(7636003)(478600001)(2906002)(54906003)(356005)(82310400005)(6916009)(70586007)(2616005)(36756003)(16526019)(1076003)(186003)(26005)(82740400003)(70206006)(4326008)(5660300002)(8936002)(426003)(8676002)(316002)(41300700001)(83380400001)(6666004)(40480700001)(7696005)(40460700003)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Oct 2022 06:32:18.6281 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7dd0d718-b952-4840-1c8b-08daa82daef0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT092.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4890 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now we don't check for valid module parameter value for queue depth, that allows user to set negative values. Add a callback to error out when queue depth value is set < 1 before module is loaded. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 1b9fa5af02d5..ae339376f112 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -246,7 +246,18 @@ module_param_named(completion_nsec, g_completion_nsec, ulong, 0444); MODULE_PARM_DESC(completion_nsec, "Time in ns to complete a request in hardware. Default: 10,000ns"); static int g_hw_queue_depth = 64; -module_param_named(hw_queue_depth, g_hw_queue_depth, int, 0444); + +static int null_set_hw_queue_depth(const char *s, const struct kernel_param *p) +{ + return null_param_store_val(s, &g_hw_queue_depth, 1, INT_MAX); +} + +static const struct kernel_param_ops null_hw_qdepth_param_ops = { + .set = null_set_hw_queue_depth, + .get = param_get_int, +}; + +device_param_cb(hw_queue_depth, &null_hw_qdepth_param_ops, &g_hw_queue_depth, 0444); MODULE_PARM_DESC(hw_queue_depth, "Queue depth for each hardware queue. Default: 64"); static bool g_use_per_node_hctx;