From patchwork Mon Feb 14 10:01:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12745361 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 51BD5C433FE for ; Mon, 14 Feb 2022 10:35:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348419AbiBNKfT (ORCPT ); Mon, 14 Feb 2022 05:35:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348356AbiBNKes (ORCPT ); Mon, 14 Feb 2022 05:34:48 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2048.outbound.protection.outlook.com [40.107.220.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A77E9116E for ; Mon, 14 Feb 2022 02:01:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dwW+s7E/zDASnv/soDeWRzvFvzTu4JSAHfSF+WrFU1IeWXxTbRQZ4NzGUqWXJc10KeAhW+izouofMmhSs2ZUfZk1f14uBrm2K+V0hF91X9Gb1hBS4a0vRjHb+EXW8M1ael/ZY+GiQv9C2QT1/+sQxwZNawFEG7QFVPyJl9yHDByXdk1u5OCaJuOVF9XH9q14sgHH41/eqyvnWIrsJ/BKfIwID7oEbGsYks1jA7GvXugwZ936Y2bYvLpZGMHh2lF96aeBDWeXIczru/XELG5wZMXO2eTDPy0KA+XGMTu6ES1MxyxC1HaUQao4hJb4gHwXW/s8zs2W5T7I+Zj7EN0pNA== 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=DSDYIEgyQJfK79hZlpKeG4Ezx3j3xkc9Upq9C+n+SQE=; b=WsI7YsqG5tEJW6iI1L3MtRFvxUXBc9kCuIwPcX72TB5ZSzI/s9I8df9hNg/rsGZPDjKJEE8v02cHUC4CZczhCXy7ZqetFzjW73bL0tZpApLlILsFKVjQd6WWy01T00/1s0nM8BV48iSn/GQApyuKEkrnbkwdJVsHfBQ62bmEsOyokvxoIPO0w213oOdVMOX3nXhXIH4o2MvUn5evKwiMr4wJLXjpx9IwuYYrxrQ71jfmNkyo0b4BZH2O/PH51LBogaDLn2Uhtqbb1OutflEC+mdL2aEk2KHZxTon1EH3m389rd68uyA2ngTX5vY3QgOC2Arf+U5LKP66Ng2HmiyfqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=oracle.com 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=DSDYIEgyQJfK79hZlpKeG4Ezx3j3xkc9Upq9C+n+SQE=; b=QJgf8NmBSR5MZBismXo44gFIAJnbE/8edROXB/+M1h/h9YBi0HO5MkHrv+Ipr7jIzmTZVvTiCbBn0C91fhcODKFrwNlWD3Sweu5qnuWujynKqwMYYFt1fukgI76+KzZe9dHN3sFLTYt5flbOHTe2Bqe1gFI8eJdB+hNS261IGkbi4A7N0gM4+fgTllWXXaBJFfW/Odiy7fXD7FeJTwxi+uurWkEDwo+XWhMpoglff/wEiqadbmpeQHp/vx1NqqTqyZ5aZujsmvVn020Z725nQHN1KQuuUerVchYZKFew0KvgNq4sufzFh8WVWw0nQKWmh+tYUXJjyriLoYa06d0uLQ== Received: from DM6PR01CA0012.prod.exchangelabs.com (2603:10b6:5:296::17) by PH7PR12MB5950.namprd12.prod.outlook.com (2603:10b6:510:1d9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Mon, 14 Feb 2022 10:01:46 +0000 Received: from DM6NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:5:296:cafe::d1) by DM6PR01CA0012.outlook.office365.com (2603:10b6:5:296::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:01:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) 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 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by DM6NAM11FT027.mail.protection.outlook.com (10.13.172.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:01:45 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Feb 2022 10:01:43 +0000 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.9; Mon, 14 Feb 2022 02:01:42 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH 1/8] loop: use sysfs_emit() in the sysfs offset show Date: Mon, 14 Feb 2022 02:01:12 -0800 Message-ID: <20220214100119.6795-2-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220214100119.6795-1-kch@nvidia.com> References: <20220214100119.6795-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f21de33f-ab39-4002-bc0d-08d9efa10254 X-MS-TrafficTypeDiagnostic: PH7PR12MB5950:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EMBgAALKpNA0A4gpUZUkU73Q40nRrDgw462jcB4z3Q21Fp9Nq4mMWoJ+cXA3Rp9MKHvMz3kZUxSWMueCCjLNkDFWXjaw4zdwCmFtwP9kz48ZoE/L3e0T7NNLablufPXDaWpMROov363vRBrsSDqQnOGSGt5BqKobyp/heSMfQiZrs3Zy+8tVndZzVSnnhgR8Cwd/NdDhkHWZcUzgGioJ+76BpvtoV//YtjiFCmyQaC4OaBnn5cLPuYlaOm/cbHFHXodivTyDyoIba7e+Nq+cINn3Qb6o+3oEQlFHGuHjOsf8vt3AEGh+Pz2SS6fVoAHC50pyXauDF5HDS3GzOEakcK/5Cj2BDWJFtDDVXPHJj9+n7tKX2z/LAjQgKFw9RcadMqO8GZe2zgRb41ArmDzEfjeZpNALaCTJht03mdrfhgHfigeVxrm5WzmtsUjHrcLgom2nRBMYRGuJxBXOQwInxNkbKLjGwVKyzI8OIkhR3E+EjeCwhm9+Zn1TE4UA2cccGcerhKzm8eBvh6kqitTJg8bFTxvh/Q5Z0CLtMiL45MMdpdGdjaB4xcuDlBNXhOxBFWb1vFuVFZ1J45DbiV1oNh6utzbla7s4mqb0tWB9T6BfEO3qqSJLElaRHOw4s8SJ5mQ+tyoZyXNnuCksIf9r/ak4K30x4VAsfNRUUC19mdWO+wZ6sbfTWJaOXuKXxlccufPEI8phUDFpZChuefAYEw== X-Forefront-Antispam-Report: CIP:12.22.5.235;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(54906003)(2906002)(186003)(47076005)(316002)(8676002)(6666004)(26005)(426003)(81166007)(336012)(83380400001)(6916009)(508600001)(5660300002)(70206006)(36756003)(70586007)(2616005)(82310400004)(40460700003)(36860700001)(16526019)(1076003)(7696005)(4326008)(8936002)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 10:01:45.6266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f21de33f-ab39-4002-bc0d-08d9efa10254 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.235];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5950 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org sprintf does not know the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content and it's possible to overrun the PAGE_SIZE buffer length. Use a generic sysfs_emit function that knows the size of the temporary buffer and ensures that no overrun is done for offset attribute. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Himanshu Madhani --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index bdea448d2419..f6ed265d34e7 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -680,7 +680,7 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf) static ssize_t loop_attr_offset_show(struct loop_device *lo, char *buf) { - return sprintf(buf, "%llu\n", (unsigned long long)lo->lo_offset); + return sysfs_emit(buf, "%llu\n", (unsigned long long)lo->lo_offset); } static ssize_t loop_attr_sizelimit_show(struct loop_device *lo, char *buf) From patchwork Mon Feb 14 10:01:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12745363 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 8A381C433F5 for ; Mon, 14 Feb 2022 10:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231831AbiBNKfe (ORCPT ); Mon, 14 Feb 2022 05:35:34 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242108AbiBNKet (ORCPT ); Mon, 14 Feb 2022 05:34:49 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2085.outbound.protection.outlook.com [40.107.237.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 972566460 for ; Mon, 14 Feb 2022 02:01:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dVpI+fzB1CSyoO7YRy6IRzHx+Mtjh1JU6GsR4Ne5fDRfKoNI70w1cnU8ArgKDvLOJGThdIKhN+2meYr/AAxw4F3UvvJtnMUYXCC2MNT219+Gls+ASjvQt1hagc99LbkZlOu+KoqlJBs5zbex3tNqckZS0/LnzOTq/7Y2lyVfvGjEeEhV67QbZ/mWSUB7jpYI//ZrKt4jkCBf16JsiLpcq31EBcSMmW9/8A0TzskGTNQneiQSJ4k6aua9yX832Caa1XENnKZEa8Fe6SWD1tR1VYshwpLlFw+GHa2961/HJkg+5J39aGV3CauPcW8EwqrULnfOIeHaV+Qh06BTK6DozA== 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=NFvFoH1Nz/pvHArQHYwz3e1Yj5iD5MOCGgiONhtkfYk=; b=ZhJHzaLIF5Rk3fFFb9UnAfTJf4i+jSjgNEnKErfDzeS7zflY+r//vDMb1KkuZqs7QV9xtqHyN9TIlWp1Hql//qnEOXgJGFbrYWP7g/jKxHs6MdnSoVZv+nC37QnyHHwfbmBuWoNf1gixca2APtQ+x0iDCYoNBOgFpo51ZoMHZh5748R3vF4bbOG84+u0D4PbmS2AzrhY+h4nEnPhNSS7cBg/3ae1XfrtmsHas5OSe3cEzBM6YPc4tD865SHYw7VJszFLPWdHeyandsM38yRpRbQSjfZksp7218hKLdOX9ZzcEsRceAQ4EicwUdsyzSwVdLJw5i8fEiKy9kgc7Re/jg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=oracle.com 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=NFvFoH1Nz/pvHArQHYwz3e1Yj5iD5MOCGgiONhtkfYk=; b=MWFGzaRAttLgOrZb6DmuTXWkRFnEGnKSlGTKII2s7kOhvOyttTjUOXSyEuPwAlBjP8F6nfSvUrAIU3gLTeHgx5s2RBZXIS6p3EhejOTSllV0a8avDh0c5izbE3OpEXb8UlwJ0zq/7ugcI9ILYk7+99daWoUFf5BKeDEqq9cDBcHCfg4xmqLCzTKM9thlljDeCiQ5qqx6BxSXz00T5kEJ2I3Ow0to8pY/uKA9peLVVdsQE7JcYTgbsSEqRdy0Co81MWXF/qIGcax9/Q5B6+IPxNiQsNOGcwMVDg+5y47Qr+JWhFI2C4DcXseXn5+XsSEuoObahTVHnubM64Bwtj6Jww== Received: from BN0PR08CA0005.namprd08.prod.outlook.com (2603:10b6:408:142::20) by CY4PR12MB1400.namprd12.prod.outlook.com (2603:10b6:903:3a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Mon, 14 Feb 2022 10:01:56 +0000 Received: from BN8NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:408:142:cafe::a8) by BN0PR08CA0005.outlook.office365.com (2603:10b6:408:142::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:01:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by BN8NAM11FT045.mail.protection.outlook.com (10.13.177.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:01:55 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Feb 2022 10:01:54 +0000 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.9; Mon, 14 Feb 2022 02:01:53 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH 2/8] loop: use sysfs_emit() in the sysfs sizelimit show Date: Mon, 14 Feb 2022 02:01:13 -0800 Message-ID: <20220214100119.6795-3-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220214100119.6795-1-kch@nvidia.com> References: <20220214100119.6795-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: db042976-69a3-498b-7c33-08d9efa10869 X-MS-TrafficTypeDiagnostic: CY4PR12MB1400:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V1WsjyHQLRgjoYht3pFxH5OsbZRlAcfEH2QcLX1q+WQIJem7JZxOruoZYFAt6fFIaZn2uYpkHx6hgWG3B+03U2RQ60PzEgiNXzvXNSYci4PsgQ6MsqpEyOXvRtO9DZkqJC4fEgRLCq0ccl0elXyDxjii08DQQKd5pttkviv5mDdgEmvsL7m5Lt1Lg6c+1wt2s7hedgVHvjTV7tA6uAt+0z14kM9qnktbDobFf7WLS77TEgeIZCApgJYdsGhiQYwF2CDETESbQISdnNK6P1jTbU2xVx0SC+G7kNxceDb6nbZ5nLCPfm9Ps3CUYZLdqoWT5wnQbz7PBayg3L5GJXPCie8d4BwqY1zK+Ov9nBbZOGNa/nMakuHHEssSVAO+ARQxGf90hsTSUHBbYR+wcFpqtSKQsuq/JCQS2HhqdyHNnyWVeB3Xg9dQkOHMGz9CfB7ycwOrZZrXqgHjrXgXJ60X2300V96MATsX/DaQGqiiVtpNrjosf4R068Znhu7OvcGyhdNAo69Zh+rcc4zqRYMIz1JHqAhc0EemGAxbOtxKd09Df3fa1vCDfYkQUw5AUPZQAw1g0xnIeLjgSAxESlramXvqDWkeqTRy4/lEjuTfHZ4GPhrUK2nh7yEG/UBKQ0vCN97Y+iIehuv1abIcagKy0T8HmUvP7kQsPaZ9kYHYV0blG2Mhu4d69y9W9ByfEQckW2v5swhupnSX3QVtBFzumA== X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(70586007)(508600001)(4326008)(426003)(16526019)(186003)(5660300002)(336012)(36756003)(70206006)(8676002)(6916009)(54906003)(316002)(2906002)(26005)(1076003)(2616005)(83380400001)(40460700003)(36860700001)(81166007)(356005)(47076005)(6666004)(8936002)(7696005)(82310400004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 10:01:55.7665 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db042976-69a3-498b-7c33-08d9efa10869 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1400 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org sprintf does not know the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content and it's possible to overrun the PAGE_SIZE buffer length. Use a generic sysfs_emit function that knows the size of the temporary buffer and ensures that no overrun is done for offset attribute. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Himanshu Madhani --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index f6ed265d34e7..c7fc790a6390 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -685,7 +685,7 @@ static ssize_t loop_attr_offset_show(struct loop_device *lo, char *buf) static ssize_t loop_attr_sizelimit_show(struct loop_device *lo, char *buf) { - return sprintf(buf, "%llu\n", (unsigned long long)lo->lo_sizelimit); + return sysfs_emit(buf, "%llu\n", (unsigned long long)lo->lo_sizelimit); } static ssize_t loop_attr_autoclear_show(struct loop_device *lo, char *buf) From patchwork Mon Feb 14 10:01:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12745364 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 B767EC433EF for ; Mon, 14 Feb 2022 10:37:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239554AbiBNKhH (ORCPT ); Mon, 14 Feb 2022 05:37:07 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348690AbiBNKfy (ORCPT ); Mon, 14 Feb 2022 05:35:54 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2071.outbound.protection.outlook.com [40.107.223.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 335F819C35 for ; Mon, 14 Feb 2022 02:02:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JG0+UAbitJ5WeFQciOAYJ8tmNpKk3EJdFCrMCfgotnvgxGWj7c25CXad7veONTz/OTi4hByhLuieDgfJcUXkVA5Mun1s5TVtKsRHTNYsXdS6QJN2Nf6f9GO48s13FQrUl1THxRAziCDwuYqDLF4/iRMtFMRdL30Lim0M9I0S148Gm+c7d5UYcwKO3kojOz+IHBDdKSSEh+jaX/gwGkgBQ/gRxBvMga5zShQZbSXQmHG+GILTrZf0VhGNySldlfvEr4b3LB9WHETY3XPWW0q7Cb2bP52PkVRgAmhXZoyKvc0sz5jLh46dp8qbI2/bSIM3FeCcA4zAzkT1WnlGfMNXUg== 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=vgWn+VitCNfGe5veJuB56Si8cZ8UtH9O2y3j2aFb9BU=; b=g9YAS/c0KgFKP9Y0dOgpy5Zzjzviqp8fKUj9unNcfS3Pd5FwkzGzTY7R1SDl6Ik0SvQVzA8sg/H0OJLnrthABxpw808jY0Y9kAfrFeP7sUlswAichKQOaulJzHRKE78ARtunWhnHPiej6schf2wHHjiVcsDIjFX+Y0od3NPb2F+GQ3E1Ccbu8oWzXbfwsgfzXiywrAmchLnrCDSPFS9mch81Nl+fDtXl6Jtna3/6RZdVJajPzVg+KJ/gongarzlUqbi48OZS2+tAlx5tLq3i2KZQzlFMvQyiax2DavLn+GeQUZLLKUWmpCR2hqO1M39FJW5rA0iN0eSHawx0J3N0SQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=oracle.com 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=vgWn+VitCNfGe5veJuB56Si8cZ8UtH9O2y3j2aFb9BU=; b=MTpLGBLfVJKKXI0zwITeuXtzOJrBS5KW6XaBCeDtIcxBKXGEcQK5q0CY4Mtmz4ELpG4CHG4nrTR9be5lgJUw5I0N+A71mtYxQRlWndhdr1qrHvyrUlfi2miz9Xznk1lYib6KjLGftrnbAQ2xyzxH8UdAdmRsjms3j9omqjU4euPQ80LFiOsxqtYpBJ8KXWhdL+pS+hXOZS5C4AVcWqpY7UdfGP6oQSJkK8QJgEhc2RcSXbM2DODzsXNnUHLsqPCZ5dzK1cTP1KT3z/G92karT0msLe1FgAaDc95FirBpLGJ85WYd+uGmtVtpJvRIKseDmXlqrJYlQYuHgpPgXUe6nw== Received: from MW4PR04CA0081.namprd04.prod.outlook.com (2603:10b6:303:6b::26) by DM8PR12MB5496.namprd12.prod.outlook.com (2603:10b6:8:38::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Mon, 14 Feb 2022 10:02:12 +0000 Received: from CO1NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6b:cafe::2b) by MW4PR04CA0081.outlook.office365.com (2603:10b6:303:6b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15 via Frontend Transport; Mon, 14 Feb 2022 10:02:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) 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 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by CO1NAM11FT026.mail.protection.outlook.com (10.13.175.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:02:11 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Feb 2022 10:02:05 +0000 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.9; Mon, 14 Feb 2022 02:02:04 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH 3/8] loop: use sysfs_emit() in the sysfs autoclear show Date: Mon, 14 Feb 2022 02:01:14 -0800 Message-ID: <20220214100119.6795-4-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220214100119.6795-1-kch@nvidia.com> References: <20220214100119.6795-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b8690f46-2ecb-489c-7c67-08d9efa111e6 X-MS-TrafficTypeDiagnostic: DM8PR12MB5496:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:561; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jCrsmNxQB20TLts6heAOKKFeVrA3t9cooRnt1lLMVKj+cvtT1tI5z/YtMCSAC+pI1t99a8+kEz+RXOPewsWlY4DP1Dg6857jrZRbHZhMd0jYbxjPVnQeVrMXWGjSbrAFa/VSZ+qV2d/TBfwOcdEl6SzZY8QXvaql4y8Cs+DiOtILp58XCIDecWhHHlZU5YKVkhcJlFB8Jfrb5W7NFrIfB8zVi0kCHz1NGJnVnREr4zlpBfR4/cVoqL71SqmKXLn9p4kChJPrrI8tXQFMYtdDgQlPzzn5Boj3pOq1wqCo5hhj39wrmGQVwV65lZp+eXwi0TuRCNDxGMRSq03dPjPna69fpZwIaCGSQ68G16F4nL1izyVlcvKOBJaPqIGPqwQ/9vw1XxvdnUOboRVTE9G2yPYHBNCA24K2HgIvAuik4PLFnVksN9o2AZtOmaol4YStzrrxe3hKBt9zmjsbioNH3E2tZ8augcgTcB4vckq2hJF6e7YsPu+Uk72pcNhl3WcB0A4VXMcephQYsIuqqi1h/ivn/2FyZIgS/W7P+/uc/H9NW8LYzoxCH4gGBROiMdzekNXH1982XWm5T2Q1XeS6UJplO0KrsvYgnGdoH4Q1OpIWXPRdDh5ky8y119UERVbXOnQ26s8rE8GofTNeCU8521ndqrj3qX6394OPeTK51HrKaxnN/m8AEix7/22urCSPHAm79vuYq+M89xmCBZjDXQ== X-Forefront-Antispam-Report: CIP:12.22.5.235;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(47076005)(36860700001)(2906002)(82310400004)(40460700003)(81166007)(356005)(4744005)(5660300002)(508600001)(6916009)(70206006)(4326008)(8676002)(70586007)(8936002)(6666004)(426003)(336012)(316002)(83380400001)(36756003)(7696005)(54906003)(1076003)(2616005)(26005)(16526019)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 10:02:11.2320 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8690f46-2ecb-489c-7c67-08d9efa111e6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.235];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5496 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org sprintf does not know the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content and it's possible to overrun the PAGE_SIZE buffer length. Use a generic sysfs_emit function that knows the size of the temporary buffer and ensures that no overrun is done for offset attribute. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Himanshu Madhani --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index c7fc790a6390..c049c1967ec3 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -692,7 +692,7 @@ static ssize_t loop_attr_autoclear_show(struct loop_device *lo, char *buf) { int autoclear = (lo->lo_flags & LO_FLAGS_AUTOCLEAR); - return sprintf(buf, "%s\n", autoclear ? "1" : "0"); + return sysfs_emit(buf, "%s\n", autoclear ? "1" : "0"); } static ssize_t loop_attr_partscan_show(struct loop_device *lo, char *buf) From patchwork Mon Feb 14 10:01:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12745366 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 AD57EC433F5 for ; Mon, 14 Feb 2022 10:37:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348265AbiBNKhI (ORCPT ); Mon, 14 Feb 2022 05:37:08 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348801AbiBNKf7 (ORCPT ); Mon, 14 Feb 2022 05:35:59 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2067.outbound.protection.outlook.com [40.107.100.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C86211FA57 for ; Mon, 14 Feb 2022 02:02:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KAufxb6vrz5KHbbMAxoczN5vhEtWHJ2RYYiWezw2DsjalvCfVeOvCwccByP5CoWQRc2px7W4Tc2GgsNSJrInPnvtuxXdtJVnjGpIWfMprksJ1bkJxsso0omzbIaMIGhctIHE1kKBxH3TMQ7dvGq49sHlr4VVBZsrakTA0Oc8vByhFqNU45XQ/MOaRNDaONEfxmjk85FU01WsKFmWMPPmvH8ixHQTByGCg5oy2YeUj5AxjtMYhOtCIjt0KDOVOOZL3x56KVrsYl/cJWnkUSXRC1xbqI+nxM0ehtHT6LF/9GrdyqQc5lttp8Z8paYIGTPXtWNRbxQ2YebUVhcaSchdHQ== 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=cnTIuNZ7uKToQ3ls8U/Yvg2/KNzwQTZJifEkJhWnr/Y=; b=i1DCiX/S+g7P7NR/wof97DM32waY5J9kxBCjZiwFchoevWmdwKBbyXWcH5USlSO+8H80xSauhYUu7OUvrExLJET6CNcC1U2cgFPZ/j1WZ0f29Df4CxMJ4jLWBUrKC/7LdT1M9LZlSXmsspLSHUybAioha3hZHeV9TCSvSPFiIGXGT9mXU0IHtSyegRoZRz1gFslwt9h1NZfrLFwtwwMvx6S3cO5e+LpEjyM9ucE9vFnOBY4m9hX/rdnBYG0NqA1rvgcDrRUMTV0g9bu0l35z3OrMmjQce16UTZYUm/KbbbnxojB+i15GOlPnFRuay+dvBmXIiAEPJ2x7a1RkV/V3JQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=oracle.com 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=cnTIuNZ7uKToQ3ls8U/Yvg2/KNzwQTZJifEkJhWnr/Y=; b=CwIyA0cdmuZyZAlGIuTRtxHRkXFxG2K/k6BDrgUmY7tSpZmkkfXwQ5wjm4JLGLsSHWj6w06S9x9pn65YoqBTGovvblF7n6c65XU7UdJF3x9B07/ubAhRrB7fM59wHJuZVg+V/SN4pJEfh8Y1KsZLFP0glv5fbBdqf58TFFI28KXyjMDrK33tWvZ7csS6Jb6m41fqQnvkM7pYjueZ0f0jSO+6DfVXldXq9+2+BxKUy6kEUQPIlWaJtBoUa9o7eAwsOjcfggX2mm/odybrq0ziYDQSE6LPaY3XUg+R8e+5aPJjxCdxdIfRZCQNtJICqCyjMwqLlj6jr2skCSiXNHE8/w== Received: from DM5PR07CA0058.namprd07.prod.outlook.com (2603:10b6:4:ad::23) by CH2PR12MB4038.namprd12.prod.outlook.com (2603:10b6:610:7b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Mon, 14 Feb 2022 10:02:18 +0000 Received: from DM6NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ad:cafe::88) by DM5PR07CA0058.outlook.office365.com (2603:10b6:4:ad::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:02:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT032.mail.protection.outlook.com (10.13.173.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:02:17 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Feb 2022 10:02:16 +0000 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.9; Mon, 14 Feb 2022 02:02:16 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH 4/8] loop: use sysfs_emit() in the sysfs partscan show Date: Mon, 14 Feb 2022 02:01:15 -0800 Message-ID: <20220214100119.6795-5-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220214100119.6795-1-kch@nvidia.com> References: <20220214100119.6795-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fdf0155e-c18e-4aa5-db0d-08d9efa11592 X-MS-TrafficTypeDiagnostic: CH2PR12MB4038:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:561; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oiYCkVWOXsEAAJdrkIs9ilUpJ0KvauKCXYrHrx32hNl9VjDDAQlNt46wa0U/4NrPlhu7VtpVRL23K+oJiIgv+sptrV1iiOBA1N/fEpGjkYPK1fZpovTa+5IZ+F8zxURgSlXkJ5pINcmFWfjsH0xPN2BsnkE1DKcXsIj8IXWv1pw905CJewlo01Q5SLRO9ZGxKZiNeds1KfBYHgf0aYAXxeBAFPZ+nB5nHH2fHOItn3eVXcHh0peCE83dYF/U3Yt7Uh3+ZlETLKtS1F3di6N5PE2jB10CnSobZp7CgW58j6wk+Kvo66Pgu4fj4ZurKVFbGrwfqKy8K3iDqW0D9ZY4Stwhj0fvwKKtPKbClqEInnqWihZORyI6eHJNGmsFm8HQHgDI6t6AN2SLH+7a5AJKnkSuJqZPfRu+32U2vrUGnjtbSy83gXa5ysvHSEQK3vW0XYxvWr5Ke9EGr7kBvuZRDHSZrh+o3jDCRVUgQjzD0P50XNgZOBqNcJ/Bj3OIP9UaxQZCfy6W9KDIZiz2nTSjO4TXlCxJWI/27Fiizm32Qem8nddlxT280esoGvCiPqFRvwQAHuPXxMkLU/b+Qfa5OPel/o6saYgdGayskFnQewpHr1iVNrV0nGkP1hnqi2z1VASlxzQeepeHfPU0vQm/5SimW+f1nIUMm5M8IqoBbQbn0m1W22OqNB3haUNkaA53PKZdvwrHhGFsLJ0h0I70Mw== X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(81166007)(4744005)(5660300002)(7696005)(356005)(54906003)(6916009)(316002)(36860700001)(36756003)(47076005)(1076003)(70206006)(16526019)(336012)(2616005)(8936002)(508600001)(40460700003)(4326008)(70586007)(82310400004)(8676002)(186003)(426003)(26005)(83380400001)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 10:02:17.9104 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fdf0155e-c18e-4aa5-db0d-08d9efa11592 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4038 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org sprintf does not know the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content and it's possible to overrun the PAGE_SIZE buffer length. Use a generic sysfs_emit function that knows the size of the temporary buffer and ensures that no overrun is done for offset attribute. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Himanshu Madhani --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index c049c1967ec3..7fa6f68d7e41 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -699,7 +699,7 @@ static ssize_t loop_attr_partscan_show(struct loop_device *lo, char *buf) { int partscan = (lo->lo_flags & LO_FLAGS_PARTSCAN); - return sprintf(buf, "%s\n", partscan ? "1" : "0"); + return sysfs_emit(buf, "%s\n", partscan ? "1" : "0"); } static ssize_t loop_attr_dio_show(struct loop_device *lo, char *buf) From patchwork Mon Feb 14 10:01:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12745365 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 C1F11C4332F for ; Mon, 14 Feb 2022 10:37:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348337AbiBNKhK (ORCPT ); Mon, 14 Feb 2022 05:37:10 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348998AbiBNKgF (ORCPT ); Mon, 14 Feb 2022 05:36:05 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2062.outbound.protection.outlook.com [40.107.95.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 825FAA2F25 for ; Mon, 14 Feb 2022 02:02:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I3c/byQgwwklYk8QvfXIhjv9ffTaS8Rkp9Wevlf77zfaqnoPkUqrGRqhJXeqXn/gP6mGQ3fLbXgpAXxaacKFZutY3Aj4I9oTlm/oaeEMqyFza7sIgl7G7YzUJwnmgOHCly07Dyt8Qjpt4SNFsHzs13PHfi0vOZeFvVGvt72k8gu4iwYxWLw+6T3qXo7+R/BWzERI5LaoRCYOte2JfYXuGWAIShIBmqDP4zqJgdoALtdyFqokPv/JNTnsLbcY/KpiZmk1uMgsw4oQbIxjESBM7FZqmWOiTyuTAwZYrok9oqBsMZfq63AZGNbrMrrfpCZHaGuLDtaQfNnr+9ohx4g51w== 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=Rqf5KKvcQRTBo2JD5S+jsaS4BNf2pDZpa4zth07JTEw=; b=e4lCCg7CjHVn6D6ELzCsayIjZU1SYuivZuwZHa5arX/cgeWPL1qgy0IyjAMDDqEk4DYkuS8o5EMFv+yIu3oGKXoJiIvn4V+ddlIDpZgQW55Hrx+3MC+13IpwqPQRycm7/5LHH472O/3ADAUXKmJ0DJXCIhXR8WF+Ww0mARzfmReC2vE68UuD9J7BycIJ2aXtX0iybbs/Muj33TVfo6j0UVRJE4rGFeQ7vBijM7iN+APpWiMQ9XoFGMchXecaGFFYqTgTcQoxKPzLScgfj/9YMz8545jXL2ufpOEwlJg+/3McWYh9yUEzx127AapAFEBlYwSddJA8yY2ZP/dS56qK0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=oracle.com 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=Rqf5KKvcQRTBo2JD5S+jsaS4BNf2pDZpa4zth07JTEw=; b=AOQMjEbzCZLL9LqbNn5ARUIIYczdGnLjexJ45ZzZfAueqqI2T391R6g8CEqsY0F8K9Fd95ps/8BiN/BOAumKDnoRXKaHTsvAI2vOnEpFGK6aqhKKNVOQN2vuhR0HaqBSUgDnLAqefpBktGJFOSJOUZvfc5JKtkh7yc/2JyPWLPzNwP/gQdAKWi0DPBYIIGQe1S+THppQRA4Pm652cQXxu3hP0Vzrqwcn6TjA4/rvpy2kQ/yr8+vT3LeMj177lEwXGUdfyjBCrc88EoSY42iX7hWTHmGvj9AN0EFsMItdy34qtxUTmEjnyihxn1ZKf5Lv0wQk7IwljBt89y4yEWLuSg== Received: from DS7PR07CA0012.namprd07.prod.outlook.com (2603:10b6:5:3af::20) by DM5PR12MB1562.namprd12.prod.outlook.com (2603:10b6:4:d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15; Mon, 14 Feb 2022 10:02:29 +0000 Received: from DM6NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::fe) by DS7PR07CA0012.outlook.office365.com (2603:10b6:5:3af::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:02:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) 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 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT026.mail.protection.outlook.com (10.13.172.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:02:28 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Feb 2022 10:02:28 +0000 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.9; Mon, 14 Feb 2022 02:02:27 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH 5/8] loop: use sysfs_emit() in the sysfs dio show Date: Mon, 14 Feb 2022 02:01:16 -0800 Message-ID: <20220214100119.6795-6-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220214100119.6795-1-kch@nvidia.com> References: <20220214100119.6795-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: caefd28a-05cb-47b5-12c5-08d9efa11c06 X-MS-TrafficTypeDiagnostic: DM5PR12MB1562:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:561; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FT8nmzhCaBoDmUoVugmmDbUfQYVI7Lpp4lRKZTlSsVYZra2jYUo6+0tSd6UlhSyZEpuEXm9vFk2sJn9A7eTcWVH2k3Lzjj+RiC6B+/NMSkP1q77sOlsLlT8HQxvT7aJ9ARjB8kHGdDhJr2GMJExnTNaiW7KeAXQPuwXHMIg6Yyvgo0JVdvjxTryqod1OLQ0W7eH76LjWvUujE3n0imnm/zXwHSLe4icAT3txVL5J3+e4rih0jbIyi/y1uhLMpIHdVM6l4kv9FFy2/m7eYvv1W5C8CuOZazOEGI1tTELLHn6Jr17xO368fwNB27X/flk9ViMmzSnBvmBRSSMOE10JtdPn1w+ya2J8h3oPCaUjNaEZwIHuPEqwAjtpDx5xvxY7A4Z6qklC3P8d9jh1Ll27ODjrSeu9vD+xtMVlUWPHNA3GLgbO1/BkNdL3YT0OMDd5z/fN/xlZpPNpqkAXBIZozKmDdk2erfBmA/8w0u5IHaYI4JgpYzr7pZI4OUb8BPPmjWIRgraYkRmWIqh+AR+jan6U7fhZcBJggOykD0ZnJk8yevzTBGZtmD/1qiTa9ojoPuwl1aaLPY1udjMAdd0cRovdleUQAEClUttGvYAGuZ7EMncJWop/qHF5QhN+RH8Cy6ErCgXcKqF8fexHpekgcXy6h96pNE7aZslZX7Xfjics2tutcPP/990dqQcXiP1k7OUOZh5XHYrr12KQMNpajw== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(4326008)(2906002)(40460700003)(47076005)(82310400004)(356005)(6916009)(54906003)(316002)(70206006)(8676002)(81166007)(70586007)(36860700001)(4744005)(8936002)(5660300002)(2616005)(336012)(426003)(186003)(36756003)(6666004)(26005)(16526019)(7696005)(83380400001)(508600001)(1076003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 10:02:28.7319 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: caefd28a-05cb-47b5-12c5-08d9efa11c06 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1562 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org sprintf does not know the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content and it's possible to overrun the PAGE_SIZE buffer length. Use a generic sysfs_emit function that knows the size of the temporary buffer and ensures that no overrun is done for offset attribute. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Himanshu Madhani --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 7fa6f68d7e41..a55e5eda1d17 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -706,7 +706,7 @@ static ssize_t loop_attr_dio_show(struct loop_device *lo, char *buf) { int dio = (lo->lo_flags & LO_FLAGS_DIRECT_IO); - return sprintf(buf, "%s\n", dio ? "1" : "0"); + return sysfs_emit(buf, "%s\n", dio ? "1" : "0"); } LOOP_ATTR_RO(backing_file); From patchwork Mon Feb 14 10:01:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12745368 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 2984EC433EF for ; Mon, 14 Feb 2022 10:37:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348391AbiBNKhN (ORCPT ); Mon, 14 Feb 2022 05:37:13 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349788AbiBNKgn (ORCPT ); Mon, 14 Feb 2022 05:36:43 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2073.outbound.protection.outlook.com [40.107.244.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5BEAAE67 for ; Mon, 14 Feb 2022 02:03:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EtiAx92ZmqmnYx8wzWv1adnoXuUSWuFK1qqDqCZ2j8kfL+EAwoLbFxmTa99vNnvvQ82+WhskpmRJqBE+q61aXSpLxv/UcPA2dmXd3b6LXgE/UcQBY2nj2zhcpquFCQswTk8rEZs3uUDoR9ySmYCv/Ppp+WZliOoBqBtY4KDBb4cDdoqPgy3xZUYSLpStZ8tylGHiXug5Asy14me+TC1lLgdWa3Gbz3FzcMQExuG4SqqguiO+ALVgoCS/jnJl6mj8JprviyQTEIVD3Y5dats27Ik1ZpO2U9+alFaR5Ox26LrwAgwv96A0lQ1QawQyIqAlzZZcOtdQk/KPOb+l8d2+UQ== 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=tPRL8HISYCbWUWa86yzKyPNqFQr5skJ1vmQY5DJJ4s4=; b=YwtbC+ZVqBXLE0guDZ2zowfuPzY1UVuwuI46vXLEl+3BHEmnt85MH7LmSoXcrwaWVM1Xxygsxh5rBNJ76PlfNYiyqtoZNflv4+opB2J2T6Jik4bPBmmtUcRzzvNkZkATKkV49edGRR7kc8jGNChd7V9pYNRU3lA67vO7qpM84skv9atDiwIdYHfk2AO9Rh9Re8wt/DIKpdbmg8+AwAJcQrXXEt6wxC9xFSLHzlrrbstnMdXb6Mv5D9u6GAzpEg0lvScYwgP5f05fSZGJx+68rWMeEklTshqzxozpNqEf3J99PddhuPa7KaULHqVRbzR5mRygMYTIGdxttLMbfO4VQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=oracle.com 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=tPRL8HISYCbWUWa86yzKyPNqFQr5skJ1vmQY5DJJ4s4=; b=o1Yr98j1ZkZjHMSDso/YMaC4l8q1pcA52Hab7tIV5DuRRLOexD1aTNCFHwlaMWxOkrCx6WN3fX7j78YMuBfOolCV7ayKKLRAKTDOCKb96OXlCX8uDQKr13B0HCFzsN9JLo7AVHe/tOjPp4Q9V4pfMxrREg0oVw9MSXOH5SN9U6/LCTuMqiWAOSmkhx9ONepP6k8FqrhR6xLH17wWcv+mDauW4jcbcGJhXeQc/+/eVXuFbAQAIblSJVrJZaJUrwzJmAxo/5nKGxwxI6AxseRJZqvIt1iwypwH/PIk9MqmRAh1hvMFWfYQW7qKmVleVHOTBfa0xBBR94dzxeq2Uw+IJw== Received: from DM5PR19CA0024.namprd19.prod.outlook.com (2603:10b6:3:151::34) by PH7PR12MB5807.namprd12.prod.outlook.com (2603:10b6:510:1d3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Mon, 14 Feb 2022 10:02:41 +0000 Received: from DM6NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:3:151:cafe::4b) by DM5PR19CA0024.outlook.office365.com (2603:10b6:3:151::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15 via Frontend Transport; Mon, 14 Feb 2022 10:02:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT049.mail.protection.outlook.com (10.13.172.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:02:40 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Feb 2022 10:02:39 +0000 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.9; Mon, 14 Feb 2022 02:02:39 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH 6/8] loop: remove extra variable in lo_fallocate() Date: Mon, 14 Feb 2022 02:01:17 -0800 Message-ID: <20220214100119.6795-7-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220214100119.6795-1-kch@nvidia.com> References: <20220214100119.6795-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 12043c90-258d-40dd-92b7-08d9efa12319 X-MS-TrafficTypeDiagnostic: PH7PR12MB5807:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 92RMICFzsW/Xj133BYqycR3id7VvhEOFj+y8SFTfx+Z8bgVTl6ov8EzFffOF7QeXcsWejhPkk9sxz2OxZR5aOg2sGBhYssu3zcH8fYKhY8XM2HLCWiNtBn/Yq7a+vtNQ89f8hf93hl5EQ7HzSXh44qVl+VYT/zWWZZkqaT6BPyxLSHcd9VEKW9vJbdpAQ2QsMbO0sLVwF9c8HSHPEDzDGmnTvJ8LVK03ucRmPZta0a4r/QmsUbzYVQQON33a7eKdkxlNce8GvyxKgLZH/XmvdHLRTmztPuKPH0IgTGq4IFoXg80L2yMR2pb2hjyUOXyC5Ax55k2saFF+5+3iygW+Ie/bt89zT6ypzNhOj77Fxm0hERwXUxNC5RJOunyh3rN7Ng9kQiBotK7a4tAX6pDUhcxQkpqzj7j7ufcdRcjO9zxwoSIBlLOw49A9yNIXpDfRCBogJmm19KUch10p8TvzcJnKBnBQvpDSqKtETyEIcdkB3uc2jOQhbLj1jhWk/sx1U3NR3ASwwDFqlKGwwjd2xdFOr+hpUEptkITFupNco9Ru8CDeA4KgtTAw6BmgfnSlUX6aZ6gmtdxyn4vwm8FPqkhfeKvJ/RXh5PshdyD7ml/OPALNwFlqDgCkHVn4Escqy1uTf/P//VswwlI4SoLLR8g5DT+NCdqeJFXigmqqvCxZp0Uz+ru1q6Upkyv1GD6kSNkiE+kzLcOgYX1h6Tvn0w== X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(2616005)(1076003)(81166007)(47076005)(26005)(356005)(2906002)(36756003)(40460700003)(54906003)(508600001)(426003)(8936002)(83380400001)(8676002)(36860700001)(6916009)(4744005)(5660300002)(82310400004)(7696005)(70586007)(6666004)(316002)(336012)(4326008)(70206006)(186003)(16526019)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 10:02:40.6037 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12043c90-258d-40dd-92b7-08d9efa12319 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5807 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The local variable q is used to pass it to the blk_queue_discard(). We can get away with using lo->lo_queue instead of storing in a local variable which is not used anywhere else. No functional change in this patch. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Himanshu Madhani --- drivers/block/loop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index a55e5eda1d17..77c61eaaa6e4 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -308,12 +308,11 @@ static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos, * a.k.a. discard/zerorange. */ struct file *file = lo->lo_backing_file; - struct request_queue *q = lo->lo_queue; int ret; mode |= FALLOC_FL_KEEP_SIZE; - if (!blk_queue_discard(q)) { + if (!blk_queue_discard(lo->lo_queue)) { ret = -EOPNOTSUPP; goto out; } From patchwork Mon Feb 14 10:01:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12745367 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 3C9B5C433FE for ; Mon, 14 Feb 2022 10:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348101AbiBNKhL (ORCPT ); Mon, 14 Feb 2022 05:37:11 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350015AbiBNKgt (ORCPT ); Mon, 14 Feb 2022 05:36:49 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20615.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::615]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D97BD3700A for ; Mon, 14 Feb 2022 02:03:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sc9Iqq4MHkrdt8s5+S6XgxtxuH2n8jaKmfw7jv0Qhbdac9LtwxCFJ4p68h7VdGnV8ja2/dCzH04FNa9/J5vcetP3QeP6jfjtbjbLZVdvP06Ly56fLmIuz0wXU9URQSwroV9TUNWaECPXlLpX578yXDM/rLCS0m2pfk+J8ICIraSD+ZjhSc9usoYZt12MMrcx32r6fsrcgjnzYphjxBU8AKtOdk68IWHRND+unoBAAuw55AOYGV1e5fdCZwR761p0ZD2c9BbA3v/tgHcnX94pGhsFXl0sS8D4XBixijwAgX8LG5ceKBuRHj3SUyC/GeCubmhm/IKfwd7tClY28B27JQ== 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=oBaNSjKaFgvWSO7NQJV5wU9zY8iE7LQJaYZZRHkKAwQ=; b=JkJph3GINc3IB7/xyq+7iR4A5RjqkcnwxyDHuQNY208P33h+Za5xoynHCQcChHloRe54FB027lW5Pf48OjbLI8dHh2t5Kf8HSlx1kAMpyOwhEv7BXck3Kzv4sQZucniGGWK+RSkBhnGRZHC01+kUs7M8u4AT32NvjGtT9zf+C9o7evkohEJpUCk/MUNbwxPtQXA4zNpABF6JW8d4kzQNs5Fz6wxqsYM+0rmTBt2wHL35xyVFLIInO1v7V7Hje86CWMHcEl1MsQf6nYoxKurpaMrUOzJBY8VLWIu/TfNhelPbWONtAm53GycSm7mx6LELQX8EahuO3j/rN040w9u/kA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=oracle.com 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=oBaNSjKaFgvWSO7NQJV5wU9zY8iE7LQJaYZZRHkKAwQ=; b=Qo9oMgTHT5TbEHtfko/1WoIOC2Jvfv2+tk1n0KChUcuSRNPXUiFuW6NCsZHjVRfwEN4gm1L3lcIsiWs9zBeFMhum/MLlo69vZiAfEC6n/432Dc1WZNCdRaK3p03OyUYZEZcs3rcLODQD5oT0Dy9BHaVdoDWaI0j6SV83C/hWxQdUiAw2W1iVjubteWKynzPIvCiip3pr9IZ8ehYm9psmgKln7ToiqvVPl32bnYb9gnx/yuTWwHGMn5S6Yez7QnnpQsOzoH7sXs4jMXHbcT7j9YZLylV6kGPZIk3fD18AQLne05pTfqxwkrLAJCW01JxaSP1IOGSTB3XhU5fjaewHew== Received: from MWHPR14CA0030.namprd14.prod.outlook.com (2603:10b6:300:12b::16) by BYAPR12MB3272.namprd12.prod.outlook.com (2603:10b6:a03:131::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Mon, 14 Feb 2022 10:02:52 +0000 Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:300:12b:cafe::c5) by MWHPR14CA0030.outlook.office365.com (2603:10b6:300:12b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.15 via Frontend Transport; Mon, 14 Feb 2022 10:02:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:02:51 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Feb 2022 10:02:50 +0000 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.9; Mon, 14 Feb 2022 02:02:50 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH 7/8] loop: remove extra variable in lo_req_flush Date: Mon, 14 Feb 2022 02:01:18 -0800 Message-ID: <20220214100119.6795-8-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220214100119.6795-1-kch@nvidia.com> References: <20220214100119.6795-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e1ec8714-7979-4bbd-5de5-08d9efa129c2 X-MS-TrafficTypeDiagnostic: BYAPR12MB3272:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1QiKzfdYSoj0aCm6BkHl0VbfE+1AUAR6L46s6MpGnI/jQ1fwfHrkTD14Li8Ov7D1wY/qy+ChD/KCArKZBIWxLwu0g7RreLlmiQ56zhLx+0GuIV8HMhCXVXyytnlPj1Y9hwlogUkbWyLlUsJ4WU4b9myadR01I5hS77k8wWUh19GRrYeR3bbwGOvgzhj2uPOV2slrT5iob1vlbTMOlcYgpDI7CiV2GltyHmrTV9auR0/uYukb3b5QW1kLhy/p4nYcPzjx0RP2HupZnD9VSmfzcaYDccYJrR5ShvCcfU5uOZDU3y6NIfgavvJ/aJhTm3JfuVn/c+ntyqAGqcv2Y+3GhdcytmdMH2l4zS+dGzf26MNQaTw0OM04SHcfkmCl9HSuT309O0GkQ6c8Px1Ym+jjTzBjL5Vsz9nRCjgLbQTR5OMypse3EtG9RaC64yrecOSwUknLfssgg+EZG6wq8e4hkF9/S5o+aOF/q1IumZ52HKPcwmkQ/AmqwhaNoHIZZKMRX9OO/CWxgKDSZtE9mjQm00wOoC+GKJdRHMcf/TfuYwbJHpUElliCLDgOnwcGv5BphIJORXuqYOtAMVPxHaq8HnYyOGG1pKP8PhWYHhgoTfrNNGgbQKwVyXDJzZNveCrPUpztQFXECGQ2kVIByXl4wcOMsrqK6/AoAMSWYHSvBTia4/lLiou4N9FbmYeqNmhaHosB2Em78m9ezJKZzJ4nAw== X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(2906002)(4744005)(36860700001)(83380400001)(26005)(186003)(16526019)(336012)(426003)(47076005)(82310400004)(1076003)(2616005)(8676002)(4326008)(70206006)(316002)(81166007)(70586007)(54906003)(6916009)(40460700003)(508600001)(8936002)(36756003)(6666004)(5660300002)(7696005)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 10:02:51.7919 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1ec8714-7979-4bbd-5de5-08d9efa129c2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3272 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The local variable file is used to pass it to the vfs_fsync(). We can get away with using lo->lo_backing_file instead of storing in a local variable which is not used anywhere else. No functional change in this patch. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Himanshu Madhani --- drivers/block/loop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 77c61eaaa6e4..18b30a56bfc4 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -326,8 +326,7 @@ static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos, static int lo_req_flush(struct loop_device *lo, struct request *rq) { - struct file *file = lo->lo_backing_file; - int ret = vfs_fsync(file, 0); + int ret = vfs_fsync(lo->lo_backing_file, 0); if (unlikely(ret && ret != -EINVAL)) ret = -EIO; From patchwork Mon Feb 14 10:01:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12745369 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 8D9C7C433EF for ; Mon, 14 Feb 2022 10:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348410AbiBNKhO (ORCPT ); Mon, 14 Feb 2022 05:37:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350223AbiBNKhA (ORCPT ); Mon, 14 Feb 2022 05:37:00 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2067.outbound.protection.outlook.com [40.107.237.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06A9CA66EC for ; Mon, 14 Feb 2022 02:03:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LjqlT7MWXq23/W2BR/kZM4EI8k7sxARFe+s6lNvssZ2C4yJKMEe2YbhpcKVdWYyaySVqlPdt+8H6H1WV7rzEXtkmBeUgb0k6/7aXtw/kwkIg+e4OAesNqyCcHMOt7NsGnpIbaKxXWaLHvAznAg5bdgokGOxK0qbLZhPluRjdkdAeyZTylmD7C33XVYZBbdNSzjvC4I4V0E+5kyVdypuTqbatq3RikzcUMAfxJ+pBmmM7M4ybQA5/E06R6hFwZ8nlmxLXP4jlbNgmdtHZMvIpHZF+XetpcBAhH+pfhiKFxrEVaLlfoAxx8CmWcdrSJtaJrEr5RExX4TTA7dLU1r/CRQ== 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=ZirCYQgO91Xa3Ta75VHvK+haR/Ieo9cvEFnC1t/Ya0k=; b=XUSpVo0GRLlgjxm/k1FyWl1mgAZM8Tz1JdElIn2jE8giYOFhRtOZUcNf1QdljlEGIooMiMMNc8lpk+wmEAE9vjK6NhXLc1QrAujCONbBzKFlbRodgWoJ/BsRG+QX7drenY8GFf+cyLzMSeFTEGHt4YX6pTZoE05R3uoK8jRISlr1C4H6qejruvBWEircYnLL392++/YR1OkzAiwX5Um94Ej4hPkX/ILYdxcBCAPZ6/9bihA61cNxf9VxT5pEosLiyL7Jc1QxydzI3sLGJfoNRO5uYNbc6dHZP+Z4vL2sOlxDpcwRB4V3yiD5m0SH7d641nruidQb0H4zZvw1t23Blg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=oracle.com 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=ZirCYQgO91Xa3Ta75VHvK+haR/Ieo9cvEFnC1t/Ya0k=; b=DpeiTkdC0AS6gc3HGTJa1gm3B+OKxOwqgEjalUUEndBfM6mq5roCYHgrQ34TCbm69x6z1BBw7TvLrO2vGoJajjPjs6JZdD+mdQZNM6wJ/4FhL+q3LC2dvy4PyGqaFfrUKzHp6iTUnbmK/iqJ4G5y35Itx2KuVaXgPWfprIEsQqRVdTg5yYQlqbFo/HJ9DWDsCtOUqgUN/y/o19dcvhRwJd9XPlYZqTa11bAxa0NaZnQtWgTHxQcTgRtOn9P5UVSaMEnFyaa0rz1nqOl46AUBB7KXjVMCqzY4WRBRI8lfX609bi0YJxCW9pmo5P6iYJquWsHQleQ6JxrjW1Gxdt/AEA== Received: from DM6PR07CA0122.namprd07.prod.outlook.com (2603:10b6:5:330::18) by DS7PR12MB5934.namprd12.prod.outlook.com (2603:10b6:8:7d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.14; Mon, 14 Feb 2022 10:03:02 +0000 Received: from DM6NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:5:330:cafe::74) by DM6PR07CA0122.outlook.office365.com (2603:10b6:5:330::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:03:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT033.mail.protection.outlook.com (10.13.172.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 10:03:02 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Feb 2022 10:03:02 +0000 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.9; Mon, 14 Feb 2022 02:03:01 -0800 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH 8/8] loop: allow user to set the queue depth Date: Mon, 14 Feb 2022 02:01:19 -0800 Message-ID: <20220214100119.6795-9-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220214100119.6795-1-kch@nvidia.com> References: <20220214100119.6795-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c38349d-2a97-4192-3619-08d9efa13043 X-MS-TrafficTypeDiagnostic: DS7PR12MB5934:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OcE3GV19IDTX/eY7hUZnwKHtJZMml8pTx55UBergFGaN+C0FzevYJbIgonrCKYq+nQ7Az5hVH1kbehKXdYeucFCpiGFtdlyGmzdh1eecUKFwvjBq8hBnZPpEeDVfowdvJ9vsQB7lVM8gKrYQmv1q1fNf7zYf8jbGMy6DeTm2UuLtZJG1Um6gKkUQq9dxHogH2aZLXJJbiCuUjl1rVTNwGdYf5EPJCF2uju/2DlNf4Ltl8wzLfrBoD47Ph0ulvYgxjgobj2W7pUNHeFoG4w5HA1mASA9gA8zXFLTvXGwXNdiBznYfsorptzMjaiUz0RohSo1ulhlnBp7MMGCcf7UbAbtH4h1PUKysRUzOGLXfILpET3lSlxJUj8RPp0tC/M+TkWNqV5xT9VBPtiVjVvy61UKg/4Ssmg/2OFRTjNSQTA10nNTSF7Vgo05RSPOyvpuTlJVQJnPwHWAOZP4eao8GB1ZWEq93UkfkSsxebzkC96U95dCwQpR1IbsCbMVuoEQ7deO1p8OpvARJ7fDQ5dJwlGzJ60sULzSEHzy0vZTryTBolgDJsoVErCk7u7CgWn5jE5DQWVGc4qP8yDG+4pzwW7ZE/r2fwAMYImYkfzi6vlSqvBOs2w3EY7KB1LUCap2fWqx+S18AawWLkf9/ZMJvxX9/ZvjdCHdigIBHLt4/SaHpe2L2/LtwE+l66gyp7kgmlc6IiOv92dBKTt7gg0/bfQ== X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(5660300002)(40460700003)(508600001)(356005)(36860700001)(36756003)(2906002)(81166007)(426003)(54906003)(83380400001)(7696005)(6666004)(1076003)(16526019)(2616005)(47076005)(70206006)(26005)(70586007)(186003)(82310400004)(4326008)(336012)(8676002)(8936002)(6916009)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 10:03:02.6245 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c38349d-2a97-4192-3619-08d9efa13043 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5934 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Instead of hardcoding queue depth allow user to set the hw queue depth using module parameter. Set default value to 128 to retain the existing behavior. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Himanshu Madhani --- drivers/block/loop.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 18b30a56bfc4..fd2184d63c11 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1785,6 +1785,9 @@ module_param(max_loop, int, 0444); MODULE_PARM_DESC(max_loop, "Maximum number of loop devices"); module_param(max_part, int, 0444); MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device"); +static int hw_queue_depth = 128; +module_param_named(hw_queue_depth, hw_queue_depth, int, 0444); +MODULE_PARM_DESC(hw_queue_depth, "Queue depth for each hardware queue. Default: 128"); MODULE_LICENSE("GPL"); MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR); @@ -1979,7 +1982,7 @@ static int loop_add(int i) lo->tag_set.ops = &loop_mq_ops; lo->tag_set.nr_hw_queues = 1; - lo->tag_set.queue_depth = 128; + lo->tag_set.queue_depth = hw_queue_depth; lo->tag_set.numa_node = NUMA_NO_NODE; lo->tag_set.cmd_size = sizeof(struct loop_cmd); lo->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_STACKING |