From patchwork Tue Sep 21 09:21:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12507395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A43AC433EF for ; Tue, 21 Sep 2021 09:21:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 221E96112F for ; Tue, 21 Sep 2021 09:21:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231424AbhIUJXM (ORCPT ); Tue, 21 Sep 2021 05:23:12 -0400 Received: from mail-dm6nam10on2044.outbound.protection.outlook.com ([40.107.93.44]:63482 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231310AbhIUJXL (ORCPT ); Tue, 21 Sep 2021 05:23:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fbEyEDntcbv5I7aQq8sFKEXfvd5aj2hMYctxLl/whSrFULfRmRcARXfGh4XbzyC0sa7TJpq3yDaTgFu8aBwXXWDPv530S0Cev/DEIIqkOZdye5R2OJZJ2H0AgoEMok1FjJnZaKoSfJ6A2O1TFma5IjEdwDJcDAzkwZ2oIT1xE6DJgLPW2/qXsPbMPCyfERN78HG4umQyFTxGswQwvtN5ihxjWv9CMHvq9KBupb0dftBY0197S1LLcI9GqXird86GLJUebhIxNctpeW1qtVy8+QVuyMJpxk8QFIbYYxNWvWhE7iXyZU+YsJNmc4yOQ00WXEkIa3mMTjUZbzKYVAtzEQ== 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; bh=XtFKyiJ1M3Zy42t1+rO6sn6EKlM6OUwxQ4sjIwnFnQ0=; b=bveyybrdmDLKcgLfgtvcVcs//QSBFHAGn8hG9Tc5AV3QqUW+JDkXuzv9n4DjImz9TcEaqw0KJLC7D5XjgUGdzo4oNy6Pr/MpmxJFhGZo/HcPnHPpIR60veJ/Y0+IswT+MC9is2Y50eIjaoT/H+L4JImlRUvZdSM1t878iWFl273az3A9wtUopxsILKygMvmE0nKMZrLVG8+COUoaddwb+11dMqmxACotTL+sqs9g+uRBci/gjCyYtf+eYem3ZKGh79U57pjsNwC9PCkRJFTBUUhvyg369+sQq3mcSRaVpQO7ogpmisTi2kjirY3+PlOHfuBu/ddoRXdIDTDNM9cYZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.35) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=XtFKyiJ1M3Zy42t1+rO6sn6EKlM6OUwxQ4sjIwnFnQ0=; b=UxDm98CUK7xPXHf1XRCJd0SpfEXYA3oNZnxGR+6c477QhHn7z8+ZLyYfXcpa1ZlK1Kzui2WneCG6M6wsXviJ3DMGnnAfVuLT5CAoQXOm1iRsoDN/tQNo/RILOyma6xcXRmE3rSoLYx8dB/TBgCZmuwZ1wPzV7GTC26vAfDwXtPnYd3/j1/OZQsmh7jaBGzCj0v1cnQKr801IBEcOQKCBltXT7wDQ5npNjKGSHvssEki0gh68qS0u0XwaUoESfHI98sWY3TrL8PNuR4F0e7BrvmZfFrzH74z/+GzW8MKs4fytLkawjDE1cO83OpquMvGqsKz15GYkwWfnd3Qbjt1c0w== Received: from CO2PR04CA0110.namprd04.prod.outlook.com (2603:10b6:104:7::12) by MWHPR12MB1469.namprd12.prod.outlook.com (2603:10b6:301:10::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 09:21:41 +0000 Received: from CO1NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:104:7:cafe::3d) by CO2PR04CA0110.outlook.office365.com (2603:10b6:104:7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:21:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.35) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.35 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.35; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.35) by CO1NAM11FT061.mail.protection.outlook.com (10.13.175.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:21:41 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:21:41 +0000 Received: from dev.nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:21:40 +0000 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni Subject: [PATCH 1/8] loop: use sysfs_emit() in the sysfs offset show Date: Tue, 21 Sep 2021 02:21:16 -0700 Message-ID: <20210921092123.13632-2-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210921092123.13632-1-chaitanyak@nvidia.com> References: <20210921092123.13632-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ced3b469-ed93-4c6f-f390-08d97ce138ff X-MS-TrafficTypeDiagnostic: MWHPR12MB1469: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IT6AdVzwE601CzTf8Hl9O5tcM0Q2kZIN1ggkB2wcjuPbZoH+cR0symJf/PIHfbjmM8JNOxFu7Vp6h7D/3V7TkSYUFCwy+Wl7/Z3E1GnoFFQk7URKXk92uGvpRitQT3FL2TpDjGRTLGlTNoCY3kQXKuI4JRq0aKR5zkwZxGIpJqyOhEOQ4owPyUehDNuNDj6PMw/VEFDC1FYLE6RmLixsfPNN2TM6AVchfLPO+PLzPa6EeOd704QsPcJv/d3luaDGSo4LQzCrwE1N08lS7na2Az4eLRklpyhJ1b72S/lH7dNVi41gL4CS0AaF0BdpEl4924cPhZ/86M14Pfk48shwSEae0abo1mIS6Fr8BHgv4Ff82VY4QrcuPmUlZLKJzUzaXoYYPs37TFEWaJrQRbsYfywzNQ3mrcdDGynKk6jqliGATYTpXRe7JXG80QJExGN1KlkzwYkQqj55ebNX7phwkb+8XMjryfdlsYeeWeXsmI/C8d6gU2Svfy+ITN33US/tDEUe8H4Stiusku5ctN2mET176PJ/oFB99gSFM0l/995R4ngyP3Uc3OB14AOo/P28qotep/+eODW6AjUbhhc9gmxxgIUMvalOHJu7euHJYAwhDajU7UHqtmjKMpgHPHrIj/xGo3fNA2sNVZC+qvjC60wlIApFaWgYNbyrdY3jEwIUQlsq62uRRLftBuYtHRRJxT884cLEdXZjfSwzye8lIQ== X-Forefront-Antispam-Report: CIP:216.228.112.35;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid04.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(356005)(47076005)(107886003)(4326008)(7696005)(16526019)(26005)(2616005)(336012)(6916009)(8676002)(70206006)(86362001)(1076003)(36756003)(6666004)(316002)(508600001)(36906005)(2906002)(426003)(36860700001)(54906003)(5660300002)(186003)(8936002)(7636003)(70586007)(83380400001)(82310400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 09:21:41.4340 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ced3b469-ed93-4c6f-f390-08d97ce138ff X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.35];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1469 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni Output defects can exist in sysfs content using sprintf and snprintf. 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 that 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 7bf4686af774..e37444977ae6 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -856,7 +856,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 Tue Sep 21 09:21:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12507397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07A29C433F5 for ; Tue, 21 Sep 2021 09:21:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFF8161050 for ; Tue, 21 Sep 2021 09:21:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231386AbhIUJXW (ORCPT ); Tue, 21 Sep 2021 05:23:22 -0400 Received: from mail-mw2nam10on2046.outbound.protection.outlook.com ([40.107.94.46]:64161 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231310AbhIUJXV (ORCPT ); Tue, 21 Sep 2021 05:23:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lK9Gsr894KolGQXzZpWSex4q7cLOKjapDyxwig6EBoiDdxod4kj/noXGIOeBtFLS2efBdX4a2R0sp9m40Co40giazp2qXrT8IlW3LKrXuVWKQKMywDpmAjDrBsV8VidY/SoMjkLJqmwlSl8jKCRE2BtWTKWkmr2tKJY1HZ2HYTEpx5lN14Bt9cDYJpUXJSaXv2KHIO5FGCC1J6xW6QTqbp5nwOBEDRdfUB2HkdD8pxR7TOlNoL+KXBWAS3CZktNnuxjCelLv48BQBV3uZkG/PpIoTHuH3LzQL1MazgKNNFeChNAtLTCMEO752oX7YLmBHxZHDXY9WEnybzts89j7vw== 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; bh=JC4DAhPEq7lr4N5Q1PUa1GDAblU90slo0cTRZRF6OUc=; b=nesubadXLH2vA6Zwy4KDOq2WXG4zCCREWZKMXs094evVfYert/3ZtaXg3xlgWkhRl+wY2F7t4xnEKB7OwsmzrVUUCjIOrV0zkRN2RozilH3MAkWWGyffRpdDYd8fSxa11ozZ09auqAO7J4fQ/5lzacALhPGoosi9v7mvC9oU/kcoNITsukjWHHBlM55WrP+UFrZ7ebvICK/Q/f57NMLwP5Q6bezVheWIbqGl3o4fUMyKYnnnB4SGdEEK89YqpF3vdCSu6yZ6n5cb0hjsFt/rrdMej33uISbRxCqTl46iPlzgks7hSiL3MTFbBQNFETSjarT5y0NUxlNofQFiNyOHkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=JC4DAhPEq7lr4N5Q1PUa1GDAblU90slo0cTRZRF6OUc=; b=XIc3Rx59Qmt8jlwZF0UszYg8WVM5p8NoZ8cjbY7+PoLJ2WzNfZ2bv3RHUtZOnWvMuFs6A9bEtpu5B1gm4OWm5abvg7UqLcRxkzljbkWEd2ML+5lYz66ElBomxs6CDYKcC4csrAHxFyqd9CIhFnWY+H/Z6HmmHFa5SJKDXbyWZC4ZGBQqY+3PPx3P7A7ObDTR7J4ro9CgUjhDqPdNYaJkujDdx7JpO+jBNaQoO0vyp+nKf6G+cdcHxR+Qbwe7XBWGCbDwFhBSJcxJPXHYBJ9NkCyCuvYAyE5TZmZByfMWQekR3rwHvdDrqfvdzA0MtB6e1qByCtLeapBZZ4EEJend9g== Received: from BN6PR17CA0004.namprd17.prod.outlook.com (2603:10b6:404:65::14) by DM4PR12MB5101.namprd12.prod.outlook.com (2603:10b6:5:390::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 09:21:52 +0000 Received: from BN8NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:404:65:cafe::dd) by BN6PR17CA0004.outlook.office365.com (2603:10b6:404:65::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:21:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by BN8NAM11FT040.mail.protection.outlook.com (10.13.177.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:21:52 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 02:21:51 -0700 Received: from dev.nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:21:51 +0000 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni Subject: [PATCH 2/8] loop: use sysfs_emit() in the sysfs sizelimit show Date: Tue, 21 Sep 2021 02:21:17 -0700 Message-ID: <20210921092123.13632-3-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210921092123.13632-1-chaitanyak@nvidia.com> References: <20210921092123.13632-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5fd3014d-4178-495b-4683-08d97ce13f83 X-MS-TrafficTypeDiagnostic: DM4PR12MB5101: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6z8uHbMACKF7MVEjfXYwLCjpK34JXqGeAI3/xQIKzRhZNq8Ghwav25HlSU1thqRz6Ta2xJjp/VTupZGIZY3FuAvgWVeNWLVSez45Q+buwX1imts+qoLm1d+iLzFoi1QabIS1iVNI2YKOBc5t36F2Bis3fLzxLDq2+JmedV5oikUBtTeuJW6jvveWPYU0JxkZIFpuMj22Kc5vM4PSqNq8zNB0qLnVdo1bIooZeGYcSOzOiNl9sEVEIiMoPZtP02w6Xuia7mjdLj34UURoKqikwO/9RGlIoptCNHXtI0e3fFPqQX8zv5SPoPIr7NftjZkLX4NATtmw5GLN6Y4D8dfL+OxqJ0i9didrtC37hPQzQJzYBM2C0x3HNbGPcvEYc+tKrkCMJXP/jWy5/WfXAuriSTZBmP46kAKS63xnuJN3Duz10o1VPzNbX7ka4aKausHB6GJUJOHi+gSTRW1HuYOeturOBV55ZMynJtIEnLZo7BAnibuILNIwgcgaAuWLq3oV/+jW3Ejyac1P3OxIvT/eKIPcXnv9+u+XyQ+Ovnj4w4oF/hnY7PrX81v5yNZbFWgI8uD33KJrGAG2uIiSrn2ATbLSar18iq4YHiBl18xyY7iBGuAwZc5wC4jtiet+mOlp0jy8jKZtN2zbuPHM/sNRip6TvgmhdntZm/Omm6UzZ0JA2zzVqomrN/vbGi5Exc5xkCd11OQpS5rOup+AKQF9hA== X-Forefront-Antispam-Report: CIP:216.228.112.32;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid01.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(6916009)(47076005)(4326008)(2616005)(86362001)(16526019)(186003)(7696005)(508600001)(426003)(6666004)(36860700001)(316002)(356005)(1076003)(8936002)(54906003)(5660300002)(7636003)(36756003)(107886003)(70206006)(70586007)(8676002)(336012)(82310400003)(2906002)(26005)(83380400001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 09:21:52.2890 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5fd3014d-4178-495b-4683-08d97ce13f83 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.32];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5101 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni Output defects can exist in sysfs content using sprintf and snprintf. 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 that the size of the temporary buffer and ensures that no overrun is done for sizelimit 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 e37444977ae6..ec1329afc154 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -861,7 +861,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 Tue Sep 21 09:21:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12507399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D8CEC433F5 for ; Tue, 21 Sep 2021 09:22:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14D6E61131 for ; Tue, 21 Sep 2021 09:22:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231429AbhIUJXe (ORCPT ); Tue, 21 Sep 2021 05:23:34 -0400 Received: from mail-bn8nam11on2066.outbound.protection.outlook.com ([40.107.236.66]:14944 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231310AbhIUJXd (ORCPT ); Tue, 21 Sep 2021 05:23:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DcF301AevUJKL7S2howE6pSRavYnHaCUE5oybCwIAYAmMaFyD7EMA81rBWQC4aRvEuj9r2C9JERJSuV4uFilz4Bqe+xOZdo3E9FNzUX2FdJ87od9XbQjpHeqJhcWYFH+/ZfiQnzWQDqxVilEwT38ZWFHqEjS7AKVVHOX+CSiczC0HZuma1QL437ba2AGIYr/qU/M8vl3eqYK0KIJgTUVYv1JL1JHcrj2FAy/UCUgKnrII8UP5PJ16MOgMgeMCKPvzByXetF7hjcdSuU6I0fZqIawTT+rOX7qYG/z/LaH6OIYV+VL+mvgv7TNVWnoY8WOpVl2UqqS8NBViTCRKhTrVQ== 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; bh=g21bEP7qQSxlu7u9SAaH6Bavwe7ziNMzUH/+g/I+s/4=; b=LuCFt03Rryky5/DWC0ICdoDjkHxw5TXQCFN27Z6+z0PmvL2g0TisRwSXkP7u9oIhGrML3LxPGrdkxNa1ebX6dxLYKeCUb1VYYCOaUGPjv5MP+BOgXrc8ZJHBQHapR4bUSFP5E24FSqmX2akYS6ht6P5MEbZkyqbRsXxh9jITFiqn4jcnxsYrJAp3iq1vwD0sFuZiGB/wBHrU+7dUEHKeLUzL6w6sqxoCs+vA2OpUv3IOUjTrk70SXPihLjQ3O6NucSmFgaFUtGH78h8RYybjg3Fz8VyUI1BpuPOOSe4rhWW/LOlL7r9U61Ypt+3z+K1iVOE9AymxKVqxM5qKdnsAmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=g21bEP7qQSxlu7u9SAaH6Bavwe7ziNMzUH/+g/I+s/4=; b=susj02/t1oMsxi0nh/ZAZlP7P4naQXAYkHbi7nNP3a43v9wnzfikxTUPMHr7EEEcWc6CJouhAXTeyzPmDHxPloQyNGfGnW7oUi1oXI5Mcprq4ob1mDyiENQ+2uwf4q/QjjfncXt5X3/crfvtF9fvdAV7F3iXNnuqvmiLvgAflEBhnYamClpUT70uCbSUCXdFznjBobS9Nf1CB5aKhP1oQLSFQXBKH7XVy3aB9oD+DNf8mmf1jGPtk+eRJV3tI9G0JgGiOtWp2e3jd99eUqQTWo4c3hIWMHZobZvbyNfbGUuFkEHrfdB2uD0dbV/6xR8gZEz0PH+DxLiIoW6FBnAdCA== Received: from MW4PR03CA0192.namprd03.prod.outlook.com (2603:10b6:303:b8::17) by BYAPR12MB3303.namprd12.prod.outlook.com (2603:10b6:a03:131::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 09:22:03 +0000 Received: from CO1NAM11FT006.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::7c) by MW4PR03CA0192.outlook.office365.com (2603:10b6:303:b8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:22:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT006.mail.protection.outlook.com (10.13.174.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:22:02 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:22:02 +0000 Received: from dev.nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:22:01 +0000 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni Subject: [PATCH 3/8] loop: use sysfs_emit() in the sysfs autoclear show Date: Tue, 21 Sep 2021 02:21:18 -0700 Message-ID: <20210921092123.13632-4-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210921092123.13632-1-chaitanyak@nvidia.com> References: <20210921092123.13632-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c70d2ed-71e2-4c2e-30a0-08d97ce145c9 X-MS-TrafficTypeDiagnostic: BYAPR12MB3303: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xd9liSbItH21s4yEE6SpBaoR87dHAroE1E6vZhMI3u0WMqPenYv/FZH7HcPkvtlwvQOvwiCc2WvLY8Vu1B80DYlCcvkbbtq6cQVNUSaXreUQXCkuzgNlbIWodrSn07mwiGWUJhIFbTAuLZ/BB0gTJXKs4mNkA+LTGANps1sR3aq43OjPrc/q/VutclwDdrv2/YYd/i4M8Af22O7+5DjKEIKrh1jDCwhlFS/EPW+wCsWJfhEVS3UKvGuaWdM+sq2gSw3x+QrVyy+p5KfMjlF+185sdsiWMv/4MYjV3Jms8GQadVRUR0ZDYAG7Au3R7HlMZZ/T0jH3SaVtRszT//NA004hN7W3WluS0IWSnVH5jSiPGIJko2rVNvpHNdL7wmra6J1Jq1Zsm+KOemU9HVdTtKUdXKB6PZX9Dfww/C4ihN0x3x5S1eVpMt8D5Dw8Ino2upYH1L1uql7ITFjrtCSC5R2SPlxwmYDFzRstH37Q9EyMEjnDoA6sFesuYv9gpfUSJoZEh3OKiLumMkf3QhrXKdguo1SExqRI5W58OQvC+zek3r19ozGIdotZQvDedo9ZaofGIMis/xts5M9dwvWgZWW0LaG+5h6VAVDamj4nUrf0W7sRpaktJ0ocesmtNwnfyHrj2y+7ztRoJV4G3ty6vrcA+XEYfE9CeOk/K0gZ9HYR5fBE64oKweVd9mlCKv57bs0FNL2ZydTxwXJn3q53Dg== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(336012)(4326008)(1076003)(7696005)(36860700001)(7636003)(2616005)(2906002)(6916009)(8676002)(47076005)(83380400001)(508600001)(186003)(26005)(54906003)(70206006)(316002)(82310400003)(70586007)(16526019)(356005)(36756003)(36906005)(107886003)(5660300002)(86362001)(6666004)(8936002)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 09:22:02.8966 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c70d2ed-71e2-4c2e-30a0-08d97ce145c9 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT006.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3303 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni Output defects can exist in sysfs content using sprintf and snprintf. 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 that the size of the temporary buffer and ensures that no overrun is done for autoclear 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 ec1329afc154..fd935b788c53 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -868,7 +868,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 Tue Sep 21 09:21:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12507401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50071C433F5 for ; Tue, 21 Sep 2021 09:22:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36E1661131 for ; Tue, 21 Sep 2021 09:22:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231310AbhIUJXo (ORCPT ); Tue, 21 Sep 2021 05:23:44 -0400 Received: from mail-bn8nam08on2041.outbound.protection.outlook.com ([40.107.100.41]:12892 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231301AbhIUJXn (ORCPT ); Tue, 21 Sep 2021 05:23:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kBnUl0MFpUggQrl4weEc2cGqQeTet6wIzGccW56jnvZFpO7NG5/lf17Ug6XkFlRPcWFF2OYVxXgtobYLi7uTFX+ENpBKLaaI2GAOMzjvkNvprctgQ8GEirYMpAJpPH3OIfMi6atYZ9ERPwquXBu92R7d1YXI6wbjCmbjGgDsA3jPsuNKHIw10phUDQhZNxEkmMv8LIuwCB4zwiWHbOgcVg127dP8SsDcp1MAeoA1M7DWS7Gu5a6lrRKEXWxG/eGCiaK7VDfE5zcj7d+zBHX5Y0IycBbzqbCFjTo3nthxLrTGQQ6mAbXIL48lLId29lweLzWWjEBphumCpi+bvXXFog== 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; bh=lSQm8OH6e8TKVdWYPj5V/Cy/TzpZpmNerTwTpse3eUQ=; b=kbb5Ub4ba5emOnfYJsg5J/l/YQ7bhjPmnGHbVIRRtfL/uCb88cDRBXjKLXruasttSyMV85z6YfYAtSkpmLpuig6XNplCi4s0lCqIiEmNIe368V9D0LjQ8FE7MT+2fQ3X9WRwPAaChRNQOT0s5/U7IvuqrwSi0Q7cLKyHo65d9EuFD+Ff5I7FsJ3kh3BA141AQHGWcCoJ7t0Sv4U9S35iMdfawHfStRVibaTADuTCxvuNxbtLf10rmul8FBOZfBySflFWO1GlMctJhF5Hp0nBf0eRGp1tsyB7zrErG5mireD30Rf6pei3tkAongEwTMrB09BEcc0zBxXXPRJuvtVQqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=lSQm8OH6e8TKVdWYPj5V/Cy/TzpZpmNerTwTpse3eUQ=; b=VgcOFqLp/2/XAuC6HdgB89bttLsFSb1eiALT+DWNgDI5CAXz8+3pRrL/LVJRW+UaJXc8qfzGBz8uU8CMU98e3D5SkI8WCjjbJq2+sQZc6mO247qh6B3cQ4cc/jjEwEhRkONuQX+YqXcORwOPG5AmpHl4HTCZEKuph0XEdKBiVO0FuWaLHeqwbat9pA2jINQZ4OezsxLOsRkaORUBBCP+31if2H0zUelSsnI70SSvyx6dJkpMp7zVNxoGyMxstS9FGcR7145IWGvaA5gM4pnIB+emtkj+g5P5Yv2wEl8YtTfLr/lCHi4goYxOa1dLeTfjjn20nncNUvm8GhFSHBTKNQ== Received: from MWHPR11CA0003.namprd11.prod.outlook.com (2603:10b6:301:1::13) by BN7PR12MB2641.namprd12.prod.outlook.com (2603:10b6:408:30::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Tue, 21 Sep 2021 09:22:14 +0000 Received: from CO1NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:301:1:cafe::48) by MWHPR11CA0003.outlook.office365.com (2603:10b6:301:1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:22:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by CO1NAM11FT052.mail.protection.outlook.com (10.13.174.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:22:13 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:22:13 +0000 Received: from dev.nvidia.com (172.20.187.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:22:12 +0000 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni Subject: [PATCH 4/8] loop: use sysfs_emit() in the sysfs partscan show Date: Tue, 21 Sep 2021 02:21:19 -0700 Message-ID: <20210921092123.13632-5-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210921092123.13632-1-chaitanyak@nvidia.com> References: <20210921092123.13632-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f856f272-9aa5-478e-756a-08d97ce14c2e X-MS-TrafficTypeDiagnostic: BN7PR12MB2641: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q8GieMS/2dlAD2uolSzsXiEhQL0ppNpmUyFcnk0SVsIA5i9jHi8QJrSQ3IpQcn8uP12+xQLlPkcY49lsbMirwbecKsrMp/xCPvOgiE83OnmL9P6bbfeKSejX4e3Il1t+TlAkWAV7im7PqRrpBpbjka54XtirOYseQysjiXTr9UEo3Q9LGL0p9WHNWiC6kiYKhNLHB43UBnOWstpQcI+THmC3RetGq82pm+mBcauDd4r04hyijYWoeC4BuXBVxDERrBp45YFVqwZBk/d6HFJ7o5q3IwNDaLOmdOt7LYUlQjP6/CyidPoswLJm/pMnHP6WAYYaN6Wxs0dptCq5E7cXKMAKJilkxJrR6aVbKdnTa8JJd0iA2YpBzJBRRIAjzbGhcXGTk0HD7KrgiA7P3qafaC36SVdWHjszh9HNsKZd4GoSNkRSZLUDZy7/Sm5romuKSE41Zng6hYYBceMWF8fWh0JVFOk8aJDaE2f75aRmmYAW4/hJ1GTR7139a8oqFtM1uUVc48XCzmKyWbKeZ+Cry/BrxGIq4Qd6OS1abpmn3ou1TG2lTYxtsJXZ9yIiUe/5JCWOliA5x0AF6VKn1DPMNIY0K6bbcCCcTj6b42012Sck6A2hC/8AGz+e8Lm7LS/U1mqAOrjuE/pJeYC7ppJU19Lbj4Vwcwx5ua4FjsQRnJjMNdW8KPNyqbd4ewlnX25OPMHZUuWLjWjzEjOXFjg4lw== X-Forefront-Antispam-Report: CIP:216.228.112.36;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid05.nvidia.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(107886003)(86362001)(186003)(316002)(36906005)(7636003)(70586007)(70206006)(508600001)(7696005)(47076005)(356005)(6916009)(5660300002)(8936002)(36756003)(54906003)(4326008)(36860700001)(1076003)(2616005)(426003)(336012)(26005)(2906002)(82310400003)(83380400001)(16526019)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 09:22:13.6145 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f856f272-9aa5-478e-756a-08d97ce14c2e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.36];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2641 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni Output defects can exist in sysfs content using sprintf and snprintf. 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 that the size of the temporary buffer and ensures that no overrun is done for partscan 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 fd935b788c53..63f64341c19c 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -875,7 +875,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 Tue Sep 21 09:21:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12507403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B144CC433EF for ; Tue, 21 Sep 2021 09:22:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9009B61159 for ; Tue, 21 Sep 2021 09:22:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231380AbhIUJXy (ORCPT ); Tue, 21 Sep 2021 05:23:54 -0400 Received: from mail-dm6nam08on2085.outbound.protection.outlook.com ([40.107.102.85]:5088 "EHLO NAM04-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231301AbhIUJXx (ORCPT ); Tue, 21 Sep 2021 05:23:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZgbMP7syMKT8BcFZurG7zc9wfbgOCphEnQ2lnV8D+oeo3mvNbRu61/HfnDQBgvFIxcD41g52u91HfKQOH/qRQQCRneQmQkTIEMp4HJ2gWK1o8N8fkHbHXsrvPaf83aysb+Hw7E0IRlnQZMGa6TAWvs7l5zOQbujtTq3MVIbbVkxhbccrvnJa78+vQ4qJzUDfl0RzCyYaeLz57PqHq+5w4yOwaX/NpxWBd5pWg8gNS7GXDSWXxYwGYhd14KlB5wUFslM5a6wFUbhc7rFmqo3ThcgcleCYXfQIcVHJvXc6uRfU4F3ye8eN+bk+Bcbf1oUDM53MqHQS6i6gqHcACcDYSA== 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; bh=+hofEBzIjHIGAx/kafNyoatEN83I/reMA8RMvOyxDMY=; b=R2jG7beJtQv8RbbA+wFZ3egmIFBOY/O0nsuHKlHPJfiA7BNzG2+QV43mGDVjgFUJxLcy4Ec7Xop2F3XhgBcfA9bccDCWKmuNnfMn5INIO++dXNWj3mIxBh9d4yoQzFkTKhAj4OiQQnW8Itm4foQxJHavWQmHYf9aBihZ3EvudKe0drVaXf8SPyyVqQQMIaPcNW2O78kveOZTHQdQDjaMtq6gpC4w1Prmzxpc+atBIizrIhvvhrTGLos55CT0H38SbEALpM1Rn+ovmQgA0DSWE1ZQqnJvlJNmbFCu/oHFgwYAjHXhsYGA9Y4sbZCRBwQBqZSfr4p/09c6BaIYQ6v3dQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.35) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=+hofEBzIjHIGAx/kafNyoatEN83I/reMA8RMvOyxDMY=; b=eWbeE2IWfYb9ydpl7WU82pr8RCThUH/WP559d9liUWMxv8u09gPeKzNqIJnQqc5M9w+2Sku+XAgwl7JOREhUjuugbfe5lcM1sFuvYQSPJEvINCVQ/t3YLI94JC9vQQIsFpk29kBRdvvoeCMIELEoP7egvUoYCIKkYYzQyHyXKiEektJKe+q9c0GnCTYGPZKlufrj1Yh0gXybEImB178W8pRvha7HZ2iejtk7VtkscQWgYSxvJBfj5E7w3pIdDLwSjM+m5mhMnHP461elgW/jFXC/N1HulDhajYq/GViJoH9NamldE/xOhBhE0b46WjV87nkxSGNqa7OguKOb+Im7Hg== Received: from MW4P223CA0018.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::23) by BL1PR12MB5318.namprd12.prod.outlook.com (2603:10b6:208:31d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 09:22:24 +0000 Received: from CO1NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:303:80:cafe::3) by MW4P223CA0018.outlook.office365.com (2603:10b6:303:80::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:22:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.35) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.35 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.35; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.35) by CO1NAM11FT044.mail.protection.outlook.com (10.13.175.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:22:24 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:22:23 +0000 Received: from dev.nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:22:23 +0000 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni Subject: [PATCH 5/8] loop: use sysfs_emit() in the sysfs dio show Date: Tue, 21 Sep 2021 02:21:20 -0700 Message-ID: <20210921092123.13632-6-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210921092123.13632-1-chaitanyak@nvidia.com> References: <20210921092123.13632-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c1337aaf-bc16-4903-492a-08d97ce15276 X-MS-TrafficTypeDiagnostic: BL1PR12MB5318: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oDdFXMa71bWEOo2zNu0Gi5SrZjOm1N72AqqCVpqmeu7zQCRojZ/PJNFEf0sd4riGhyNz6NTroFWhO9Joub+Z+Ex7V4YlvHYpyGMX6SZlv11rAtaFjuy5li4lNQcRHskXI5vzk4SSEwBm9mJci7Tu1/Yho30qtFHxJuSDItg4xNTSfcEgi6nMl2GXg7z0h9s1SDnlrDkwJ2YY8k8qKTddsmMKmwQwAXXWoQLzl+nvWfIAciOEJV6G2LqxIEnJJEbnIbUnjze788k+WK17knjxQx948K3Y6YpMMTPFUujYNeFKdnv+4I42OaUMhJeB232A2RtLtoSjg4nz5CrMquiMZyMkqSg0EXq3sMIe3aKeakgtLW2ADWrLwhmgln6IH/lW9RRYXtCsMqpgPsKpCxPPoBzT0X+Kc2/6JAu0NR2VvjTmdj3UqvVp7GDSbykzpHxova0sr8e1TTAcs5ukT88WuBB+Unvz3ZdzKxjN0ON78quPENiQdVh2EVrnweiVR4bZCst9YpyF67INh396desuAGZMHdgXNI9Yc0Qy7LH8iIpDMsof9DnrzWEWYgZqc4EVPn6pZq7d6kchVrr8smy0kUPQQY+UQbG4tXEAMjkixwezdktthaCYHUHmz1o/8KhVGa/WIoXddAImOapsK3LL+XcmLCQ07ACl7VHvomUqiIGWy4+eszTWlPWO5wtC+/clHfmzJUR65N2CjyOihsdi2A== X-Forefront-Antispam-Report: CIP:216.228.112.35;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid02.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(2616005)(6916009)(107886003)(4326008)(16526019)(36756003)(8676002)(8936002)(426003)(2906002)(336012)(83380400001)(36860700001)(356005)(316002)(36906005)(508600001)(7636003)(186003)(86362001)(82310400003)(47076005)(70586007)(70206006)(1076003)(7696005)(54906003)(26005)(4744005)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 09:22:24.0996 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c1337aaf-bc16-4903-492a-08d97ce15276 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.35];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5318 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni Output defects can exist in sysfs content using sprintf and snprintf. 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 that the size of the temporary buffer and ensures that no overrun is done for dio 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 63f64341c19c..fedb8d63b4c6 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -882,7 +882,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 Tue Sep 21 09:21:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12507405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A075C433F5 for ; Tue, 21 Sep 2021 09:22:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3344F61050 for ; Tue, 21 Sep 2021 09:22:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231334AbhIUJYF (ORCPT ); Tue, 21 Sep 2021 05:24:05 -0400 Received: from mail-mw2nam12on2049.outbound.protection.outlook.com ([40.107.244.49]:38948 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231301AbhIUJYE (ORCPT ); Tue, 21 Sep 2021 05:24:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FKe/r9tghrZg165hF+6n7LnvCVIkyV1mAKhBEOgkI2UNx6lDeMlQDteUjgrcz7LBaTWgd+OiG6OJ1dwg+MuTb9G1ir2qH6FxaOIuK9XS87wplmu4Ff9S/7Fa6p/2Otl2WhvAVpqNnm8HfE+JdkiuGwC4UOypP5LHrmp2QKhVDNhCYfaLaiX4qeV9EqOzEFA+WWzc1ZyFMwXEVE/4PUc1ERI1NSVteqfXV36vj14817fltaqf4HgGH+O43xbk+x1UV7mWQWukSi87d5sbd90y4El/IYWcc/HwIIbZOtlPJ+7fdiOhckzMtzKVyYzlJ4MuVvdHG1DAQkKgy2Bb1K8HfQ== 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; bh=BQY+HIBs/59R7t04DIoa7bAAaNzADbzDGFqDs1wkm64=; b=TE/7aeDkri8HZM21djZqVoujHgvIclxuNZtQaqhlLTHwlZnY06jWsY5AA3s6ykxpKx97F95R8Z6u50GBPX79fOqzjCwS5JFi0zwlht3GkBrf6bwqpr6k8k2+VRPTGgFVrwcu/qfa7NctB+b3ljlPieAQVnkNBWKi/zJbZqmBmnIcVhhE+o7KktU8ONB+tK6h23dddQBGLhRpCTNaZaxYAusSF7qcJSIbT+bEhPC52Y4lyR88WpoGb+b3WL8yN3z1Yz3rmxohuIiEFekHwzdqnBhHzB7VXQHD2lifU8Db/pk76Sbgd3k45xCncGiCQeZ06Wx4inPgiXhPf/GPdAeBKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=BQY+HIBs/59R7t04DIoa7bAAaNzADbzDGFqDs1wkm64=; b=XrjSPni7Gti66klpXlXaENymf6oo0iJOTbkPBkOHDQ3Vud9h7R0dv42zPo1xSQ7v8FQqFEowW+CRmaethr8Xn58WGo8hJq1OGmQK7uwLumQQD7jebwCDOsNJmrEfS7GpsvxgtOXCu0iCvNBCctUU/CmHFXobiYW1coX0QG/sjC5Y43nKh0UCNKaFeCYcg6iuY5Ayo1HHOhqqvhHXNCFfj/A4NUSASpiG16dm4aQ9IW5uT0x5on3cIBQDMyJbbmTpzPftGuRiwbJTmhzZHqXSMtjLj1hxOEuEF9w9f5ZM/56i5iUV+r5RoAo7PsHoj2UAL8A6NJbINQlNH+qCXhn/Mg== Received: from BN6PR14CA0048.namprd14.prod.outlook.com (2603:10b6:404:13f::34) by DM5PR1201MB2520.namprd12.prod.outlook.com (2603:10b6:3:e9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 09:22:35 +0000 Received: from BN8NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:404:13f:cafe::fa) by BN6PR14CA0048.outlook.office365.com (2603:10b6:404:13f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:22:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by BN8NAM11FT038.mail.protection.outlook.com (10.13.176.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:22:35 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 02:22:34 -0700 Received: from dev.nvidia.com (172.20.187.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:22:34 +0000 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni Subject: [PATCH 6/8] loop: remove extra variable in lo_fallocate() Date: Tue, 21 Sep 2021 02:21:21 -0700 Message-ID: <20210921092123.13632-7-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210921092123.13632-1-chaitanyak@nvidia.com> References: <20210921092123.13632-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8aa8c4ce-1bb8-4bb7-3ea5-08d97ce1591c X-MS-TrafficTypeDiagnostic: DM5PR1201MB2520: 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: qbqLObnyte5Hs1NVRBHhuftTGUEVf7aqS6Ngyn2v9PAO1PE9+5nq7MivuhQQ5s1O9QUHov2wur7mrYXnhFAA5oh10Ar9+MBLvAJvS+M/bU9fpr4aPZP8AZgLg5wNKVmkBfo+BSR+++a5ubcI4DhiM5nk0CwE1OqhqRCkADE2o8CINVJ54tNSR+r0Swr77/4zM5Nc4ZL33ZZCroKe0aoj6RSkHOZqsGp+2Xbv45v9Rn5nTRLnM7k0rNpLfnhmONnv/zk9Sqf2tYCa5DRr8a+5MHQLxmB4iffV4aDBqgj5Bh+QMikdO8050JQLAeeqkwRzSqNUfuS72yRs8RiK9DFQoQDdpJcSD4VuRm525yhXFeTzJOu2pONDN7eVNg6ObdJtdiNtFWgwq9RAWCB84mYspF0vCaXrbfconTpkUELfHq8v4GJHi6yHhpx08hK58XZekBTy4lsLL5RsRQ68PLOS2GdVyHbakwbC5v41GAXu8M5JkLZ9jjTkr1y6EPNva3WVNnIoTAihHZJDmgPS1+gB4OqPMn528xBrX8r+K7jrPr135DB4NMZxWRl8wFUK4kg1YHRFiaYhxIYnzx/scWXfPhqqBCZ/83g0OBBA47WazSibJectCq0R9IEGL2UcciQjYC0MoAQx5yz1lCHLoe2M2i1pVI9btOnPtrpi+OXpnN89K9reoqr19r2C5VszitjHMvIO6q6Dp3I8Vbk6W9lQLg== X-Forefront-Antispam-Report: CIP:216.228.112.32;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid01.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(26005)(36860700001)(2906002)(4744005)(86362001)(508600001)(16526019)(7636003)(356005)(47076005)(36756003)(6916009)(5660300002)(186003)(82310400003)(70206006)(2616005)(8936002)(7696005)(4326008)(107886003)(6666004)(1076003)(83380400001)(316002)(70586007)(336012)(426003)(54906003)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 09:22:35.2428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8aa8c4ce-1bb8-4bb7-3ea5-08d97ce1591c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.32];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB2520 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni 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 fedb8d63b4c6..51c42788731a 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -480,12 +480,11 @@ static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos, * information. */ 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 Tue Sep 21 09:21:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12507407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58410C433EF for ; Tue, 21 Sep 2021 09:22:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F42D61131 for ; Tue, 21 Sep 2021 09:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231387AbhIUJYQ (ORCPT ); Tue, 21 Sep 2021 05:24:16 -0400 Received: from mail-co1nam11on2053.outbound.protection.outlook.com ([40.107.220.53]:3937 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231301AbhIUJYP (ORCPT ); Tue, 21 Sep 2021 05:24:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OgE7EC8j4LPhP6dSKag6SX77dJtEnP+d3VvFixevLQYH1aH8Y7kjjSQ8icyBqHUuRNmTv4KjsW5lwVb2uklAN2riDIW2yzgTRq/sfCDf7f5eAWfLpsS86Cyh/kbre34oDWGZhzZbHCq8zajRVwFUkmxKnqaIrf8p/a9h/mYpxbR5LiJowv3BVFIy0S4o4T36RBsqtZnKYanKwzjGkIJujFCaXeDTJdy0fOw0aP97vG7O0iumPp6CmJGudVABYrpNzq3ye3UPtNLwvJIelOIz5yERYNTdPn23i6JkUIUqs+i0wTQx2CqEGwEJLwxPejOFN1jQOXBoO4UFagJJMJs0TQ== 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; bh=o6jIC3QNLi8cmLPriTYoHfRE5LpuuqrBuDSAy+oYsQY=; b=IN4kbfW7P+lofPLYnexkhScmsAIfjP4m42iKSqW52ha5jWbfoAXd9dGhYZTBJCwWEvMwicKkwaHaUu4qpLVFla5h7YpnhXu/j/qJwACZkl/6Zpo+cY+JPoyy0N4oYNRFTG37OwcsWlYST/17/iFPmQ+444CZBZXsVyBoTXjO3yRgVBLhifLjKmERGLn1t5DfPPk90xuzkVq+BbApQuLIEAdzghwp5P05CLrsmULUWEtrz1rqjWk9frLLJixm59yNfj/ez6LlLSUYm+4eu1RQeK+okUOa+rNUT/dOLggk+VIiLrErajPIPw55mwLDA2BknHu1cVbEhlV9Seargn3wnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=o6jIC3QNLi8cmLPriTYoHfRE5LpuuqrBuDSAy+oYsQY=; b=AgnAvMf2Yx2ARszhzJBG54iSHkmpFxe4LVwF1q+TX6IyIIxwE18NrIsJ3OepdhR+xMVXpYqbCPSJiH7saCv57O2U5Mq9zCIbthUY8CX/Wn+WJb25DIBFoQ4370Ef5GQOU/GgZ7bn9exXRr0Cqhoep4CSZWdf/Q0/U1vFfz1lA0Pj/YkmjuCfI2lqrMpqGzlR+2GGMVB+2f3P4AfcCOaREfTWwBBmTd4eSS/yCa5IG8Ay8PYypcktEJ6J3Qmw6zyRmR3dfrTBtgpHgDhARVuc8a9Jf5w6WaiKwxqyVjKVVamnLeOJFjpbVtHhES5AzNKIpXCdBuGDdHkvE7SDbHWgWg== Received: from CO1PR15CA0096.namprd15.prod.outlook.com (2603:10b6:101:21::16) by PH0PR12MB5403.namprd12.prod.outlook.com (2603:10b6:510:eb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 21 Sep 2021 09:22:46 +0000 Received: from CO1NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:101:21:cafe::40) by CO1PR15CA0096.outlook.office365.com (2603:10b6:101:21::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:22:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT019.mail.protection.outlook.com (10.13.175.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:22:45 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:22:45 +0000 Received: from dev.nvidia.com (172.20.187.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:22:44 +0000 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni Subject: [PATCH 7/8] loop: remove extra variable in lo_req_flush Date: Tue, 21 Sep 2021 02:21:22 -0700 Message-ID: <20210921092123.13632-8-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210921092123.13632-1-chaitanyak@nvidia.com> References: <20210921092123.13632-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ada2e52-2163-44a8-5ded-08d97ce15f64 X-MS-TrafficTypeDiagnostic: PH0PR12MB5403: 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: jsq2nF4HNs2wypID9UgPAIfobbjOO8ezpa1LK2giFP51XhWG2R569StUmAYG0AwZu3+gXYd9Gdi76iTASHz1Vo6mc7/xk1ReORJbs9hpYbx/AVgiNAwbPWPm+qmW3QVf8lm8iK8TSThOC+oiZ/FwltpnDEYebDwO6dbuynBWft76mE7Z+5BmI5WoGlM7sXcgxC5rOHYS3zfPAaRbMe5OmuZ4l3MMBZKQdgrxo05sYXNxDUdeOyQ6IM5aHf1XOaMldjCVvvkT3wjhOHCGRrm6l6XO6qS99nOzCH71g/UKAdfRO0Dg2fGRhJUd01YC4w0JDOXj/9v1fbAxnbuETLO2GRatZWuhBVa3cvTaPctcHVLpclA2PujNTXBn6c9/MF1pX669C8uRHlMHfYzeywX3IlUahgVBCgGdU8JEMV/PcOXM60raTKIwqcNT2z3NdzHFeD9Zm3Ms4L5r+9snA2lWcHdX1L++8A/iEC3ObMn/O05s1FayQAzsqtCOCmGfvyRz4/QL2gkwM/fsdNadan/t/BtZf/wQDK0KJ2UUSN7m8dMSrDf4HI/ecbPVMD46Y5cftPSeohgDGODqISC1u7vMO/AGDzKyx0hLzwkASaq7j80VIDWgzjn8/h9bjKGHP+AvlFNR2ikCNCR9Npr5+Vk80bIMclCXM7P8dtYurryGLbKkpAvWkpQk1Rc5VGUqgnkIECdo+RkxpACk6NCJNslXog== X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(36860700001)(2906002)(508600001)(47076005)(426003)(8936002)(70206006)(8676002)(36906005)(1076003)(83380400001)(316002)(82310400003)(6916009)(7636003)(107886003)(86362001)(4744005)(6666004)(186003)(16526019)(2616005)(4326008)(5660300002)(7696005)(70586007)(54906003)(36756003)(26005)(356005)(336012);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 09:22:45.8515 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ada2e52-2163-44a8-5ded-08d97ce15f64 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5403 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni 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 51c42788731a..6478d3b0dd2a 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -498,8 +498,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 Tue Sep 21 09:21:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12507409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77A04C433F5 for ; Tue, 21 Sep 2021 09:22:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5812661131 for ; Tue, 21 Sep 2021 09:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231390AbhIUJY0 (ORCPT ); Tue, 21 Sep 2021 05:24:26 -0400 Received: from mail-bn8nam11on2080.outbound.protection.outlook.com ([40.107.236.80]:28001 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231301AbhIUJY0 (ORCPT ); Tue, 21 Sep 2021 05:24:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QH9kVfIOZftkseUP9MU4BjjxlivRqX0TgNTlpVDx8szi84/6MP81XNq5a7SRPAvO1b7X4+ZLnLyl+51tRRgyD6cOQ59n9Cbmg/dlu/ELzWutz54tPs++YHnM9uay13xwsyA/a+hp7qznhTKGKG1nj0pA1SKE5AHKUhY5jpOM7I5KzqyrWjzQN+miIyfABe3pA0bZb4OXDdfSCg97ZVUF5C+hlRJai0nFUjPFMzN8l4UKfbrtguLibwtqBN7Cbrdbvu67IPwvQyi7tNDCQDcoyOVdwtbLIRu4QnAgbMnpL2Y/lIrwQOwQGRHajZbM8HSMqlgdhRcObY7DFgmUcw9Yqw== 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; bh=bLKmu5Np871dzCybS6J8teZsJ6qkWLSPl9AoueyjVwA=; b=WARmPEX6roHeZSg66Njoc+2j7vLVQNzUXJ1ihOXclU8taq3q95FhIw6Ubqv4Q5IrTwG064Fj2V10bEydiQDY8ZKtM8eLi818XjR7ISurE3nxQddcvhbZ4Y8eVXeL1GsX2r64FxC3viw+w1BpEf0CrbcFNRBghChzYopthbBZ5liE91U9k9+jEmH5HeMj2j/B8xzAxHxg5JXk03ZHyhpD1plFRxCqg7jLVCzBVjcr3tKrZrEOrMIThVFsRjGKmetC7c+oIiSYKvlr0I98SeKuKLNK7plz4J2v36webOskgktb2gH6OX6djaSnqb4VgvBu/BjLZtJuOCfBG5dlBC1xUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=bLKmu5Np871dzCybS6J8teZsJ6qkWLSPl9AoueyjVwA=; b=H+EsEIdFK2SK/xHqCxBZ8eoydOA/tiqQ1r5vZqs+87o69HmOMOCfla0lrzl73aMnp87XBkFs11+b3RQyly+B4Z60+pai7HSnk9QjT4q0AEYpkF8SDX5QKzqNE3AUdaxlYHtTr+pB7n9rFTA+pn69jED6rb33E+oOItR2mJsFCE38zq7LfSU+RmojPMgsDlsbft9hMH56TwWiET+/FPZI5dKs7mowxfqEblbSw+YBXKSkWJL1LZAFz0HHB2YfWrPhQFD7M+mtUYmNnQZqj7ma3711Iz9VlCg4nQCFE1KxBbesWBRiA6iAJ/kqaVPStKxO8ygZblYdRhu529MBteFfAw== Received: from MWHPR13CA0014.namprd13.prod.outlook.com (2603:10b6:300:16::24) by BN8PR12MB3188.namprd12.prod.outlook.com (2603:10b6:408:6b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Tue, 21 Sep 2021 09:22:57 +0000 Received: from CO1NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:300:16:cafe::8b) by MWHPR13CA0014.outlook.office365.com (2603:10b6:300:16::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.5 via Frontend Transport; Tue, 21 Sep 2021 09:22:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by CO1NAM11FT045.mail.protection.outlook.com (10.13.175.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 21 Sep 2021 09:22:56 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:22:56 +0000 Received: from dev.nvidia.com (172.20.187.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 09:22:55 +0000 From: Chaitanya Kulkarni To: CC: , Chaitanya Kulkarni Subject: [PATCH 8/8] loop: allow user to set the queue depth Date: Tue, 21 Sep 2021 02:21:23 -0700 Message-ID: <20210921092123.13632-9-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210921092123.13632-1-chaitanyak@nvidia.com> References: <20210921092123.13632-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55c15b81-c2c1-48ca-61cb-08d97ce165df X-MS-TrafficTypeDiagnostic: BN8PR12MB3188: 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: 1hCQ9RDkQcLudJxijI46uUxkKoKLHl9/oT0Jpgg+yMRmJAQlVDNEmaoX1npxjr5Y5bl4zpO6yjq628fjEMicweKkBvUM/CVaQFfCSCNOEsUEpK9LlBhRlXyQWaZcr/sHV+eyc52d3BUAzVLkt3R1ugZwz8ZK62AbMcE+GPg1J/KiiM8Vxn/w+M0J0HuiiRfXS0GF8v5/Zg4qpAsquS4B2yJxb7EjghmbdInyaILuDjZv6w9HILeXtquhp5foQJWoWPdFsxv0YTdPy0gxDCGIdljeJKcare8KgCSfwv6bqsED3G4TdAVHzh34e6WCpD+KtI57n7v9R1gciq/q+tfsbLKD3GS4B8VXR6R32kSI3SR/viCiRPBpYowH8Jk74YA8NIS9tw0V0gCkZIS3fAtUkGiQfCO0Z+0EPrm3kxvXyuEOADbpYJMubZ6HasBZO412E5fGaZDnRNK8HvwWrHzc1+9EXQMqPr2asEkHGxyZLDNURfmbOYSEy6DWiQMeeUAl7alGxUBWPYgybyKyWEHi7doXmL0D/XiM/ai/MDMpzt5AHlPOxrkFP4eaovfXrPKBkHGCMN9udPGPjHQLJEfXSBkD81NSxbPqgOpeg3BjSuFzqOwmQwQVs+Z5JCT8k8JLQ8e8agQVTW/DekcA4QZsVTFGgpWc53DZlsjCR0+JgKKyCK1xdsjXlJi1c9hQweL0Q+CFE1SL094zbRJJWBk6NA== X-Forefront-Antispam-Report: CIP:216.228.112.36;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid05.nvidia.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(1076003)(186003)(7696005)(508600001)(356005)(26005)(7636003)(16526019)(107886003)(6666004)(6916009)(4326008)(47076005)(54906003)(2616005)(5660300002)(83380400001)(8936002)(316002)(36860700001)(36906005)(336012)(426003)(70586007)(36756003)(70206006)(8676002)(2906002)(86362001)(82310400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2021 09:22:56.7090 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55c15b81-c2c1-48ca-61cb-08d97ce165df X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.36];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3188 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni 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 6478d3b0dd2a..aeba72b5dd2d 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2096,6 +2096,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); @@ -2328,7 +2331,7 @@ static int loop_add(int i) err = -ENOMEM; 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 |