From patchwork Thu Sep 23 01:49:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12511797 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 983DFC433EF for ; Thu, 23 Sep 2021 01:50:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E4B161211 for ; Thu, 23 Sep 2021 01:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238850AbhIWBvh (ORCPT ); Wed, 22 Sep 2021 21:51:37 -0400 Received: from mail-bn8nam12on2046.outbound.protection.outlook.com ([40.107.237.46]:22624 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238177AbhIWBvg (ORCPT ); Wed, 22 Sep 2021 21:51:36 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VaE8P49E6yrCI7dZau9/90rxAI0m+h4qgkubTg+LZOjUo085eP2KUfA5T9bY/GpxN/qV8059oo6lJntmy6d5UJl7W+b2S5ZNpSKvqZ1iFKUF482At85N2Cj4P91N9zKjQ/g5NAG39o6P6s0ITw7uQfG2Vo8sR9qmUBY/4hq3HspvPWcLK1fNrDTqDggHwB2W31/9eWepUuPT5DxClWgjgXGb+edKHTs9iiHn50SVA9zAupB6Sevtnh3NTNgi+m6lkOBsRQ62ayVOSyAfJj0LZQhavzCNvtBq8EkNx4ML10+PKoXGW7F2mSWbq0L75N4Nk+SH/tqTsCPEUyAc5of74g== 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=EZvsYZj76XD/k58GqJhoqfQ8fv33Enqoo3Sfou57ofo=; b=ZLnkONmNqvWL9xTnNG5LwjueMiPpxI33+XYjrB4tB9ZfrSmzYp9gXviUd8mcDiIo8etxIYYGMDmMnAWaO2FHiu+x1qCBLPS4neukCVvMfM/iU7VOlmVS9Ic++qGKClq+sy9pHdP1EUSFfJhI7zfgkjK2vampJ5LbrgNRet/jKWwUH0KS9w2n76pXqGJusEIWT/FrUqpdysQa6kuZ4Q3BU7VcojyCjhsy/mu3uZpgypuQpNh3zO+H1YPam0SpXYilBc5s0flSv3r70VD2/UUjS8JeTiVRq5b9bmKGhTbWN5RQkg6EmAiRN4NohuFTc6f8VRpBwD77fy95ZFH0v7+bow== 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=EZvsYZj76XD/k58GqJhoqfQ8fv33Enqoo3Sfou57ofo=; b=HBcE8olFpXcmZFdjEFcMkDp7x9GHnEBPbkVSNwtOrzuxGy4bStxHAtNEptmlJ/VCbciTOAKYdx0fM4a7QOUAo5VFkJrnzoklkG+ClNyybT9IxJJdyWuY8Ubg/vgxi4yarfAdqowHkcSQ/KnK5KcK92fxffJST7l+2WBhSC2uOyB+Gn3xUxkmy4ZnoEgnZ1fkQrfN7J4Vdlo6b+SQ6kV5m6K5RxGUX6IDX213J/OSMwVIFt6rdTEDLkVRsqlGDWKos933xSbyh/LgjhjZ8fr2i+5N8cU4CvHlFscT9zKYPeq/PqR3cJT5KqJVY+piDYozvCUANzFdkbXvKO+GE+Zq/Q== Received: from DM6PR08CA0044.namprd08.prod.outlook.com (2603:10b6:5:1e0::18) by BN6PR12MB1889.namprd12.prod.outlook.com (2603:10b6:404:105::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.17; Thu, 23 Sep 2021 01:50:03 +0000 Received: from DM6NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1e0:cafe::3) by DM6PR08CA0044.outlook.office365.com (2603:10b6:5:1e0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15 via Frontend Transport; Thu, 23 Sep 2021 01:50:03 +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 DM6NAM11FT054.mail.protection.outlook.com (10.13.173.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 01:50:03 +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; Thu, 23 Sep 2021 01:50:02 +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; Thu, 23 Sep 2021 01:50:02 +0000 From: Chaitanya Kulkarni To: CC: Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V2 1/8] loop: use sysfs_emit() in the sysfs offset show Date: Wed, 22 Sep 2021 18:49:38 -0700 Message-ID: <20210923014945.6229-2-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210923014945.6229-1-chaitanyak@nvidia.com> References: <20210923014945.6229-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c986673d-0d53-45bc-a441-08d97e34761e X-MS-TrafficTypeDiagnostic: BN6PR12MB1889: 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: KO5/8Lh2Vr7Jbt0wDKfxXi8tw7PUFLUq5rJOmNZ7IkKqucU0pln2swbuQtiQgmGqwChv2Rr/OEkLQXFwI43poto8IeGo+IiG247YyVi21rKi1d3bdJzrQV8hK2Ve96de9jes/sb70xVRIkbMSsxqWvmxYN/TmUlPD+AmFntaodZ7qVlDRg90bkJRHY54ASIrw274KeJSa/OU2Vcs2vOTpn/cgsuyYOXuvg4f8Uj1oP/1aaWUK7BFEAmXCA5pHY8ADC4kaZI62ZZKOVAWyDIbfL1jQ8M4UWr69oJNayIDzZ33P7/8aIdY5ShnsAM5hHI/1v5NZcuDxXDKdmJWNtpq8XV7EiDcgTHiL83mVtcls3kPRoB3ua76FVbL1UR08woemVHKSxDIDgt5KaWaSb1cl+GfIY3hrmvtv0Gmkyh3EIFhtFwwWGUoul8Lj4oMrXdIAyYkjA36LxsaIwrf3lGBbov3OwP9sqf1+OpDHSKHaAaDdfJW5ciIPi2uCsKdf5jnLf/wZTeQ1z8hlZVt96V+ySE5pNaxA/JCrs31cSWYmn6rrsZfiAbjgYm6FjFTUf3OovowUpwWTH7x9MclQ1zekJS7/SIJmjWXvOy/WmNZoZKXTZd1NQx87qqJmDfRV3FZRsyWrW2vLVt0v7ZQu4UMwiuX8wQtexQpw3s/prXx4QDPJGgy4lF2AUHUhp6kXWsA2UpHZYJYa9WlJLJqGHNm4A== 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)(16526019)(86362001)(508600001)(36860700001)(54906003)(83380400001)(7636003)(186003)(2906002)(356005)(8676002)(426003)(6666004)(70586007)(7696005)(47076005)(2616005)(1076003)(70206006)(82310400003)(4326008)(8936002)(336012)(5660300002)(36906005)(26005)(36756003)(6916009)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 01:50:03.3605 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c986673d-0d53-45bc-a441-08d97e34761e 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: DM6NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1889 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni 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 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 Thu Sep 23 01:49:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12511799 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 5D7C9C433F5 for ; Thu, 23 Sep 2021 01:50:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B4D06115A for ; Thu, 23 Sep 2021 01:50:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238177AbhIWBvq (ORCPT ); Wed, 22 Sep 2021 21:51:46 -0400 Received: from mail-bn8nam12on2078.outbound.protection.outlook.com ([40.107.237.78]:30497 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238851AbhIWBvq (ORCPT ); Wed, 22 Sep 2021 21:51:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YfMHo00Js8ZgKuA6O7VCZB64FOzXPSPtuUDMHFGU/hEtDJpDFXk/eg/VLF+YhCEwXAXJ4u8IaOSpt67uyc4HhxEb7CBA94wyA+OZPzOKlL/X2pA6twDN6pgV7QtI+JxSdj9g3C8HBVMtPtaQh+/aqAzlcMRaNTLwRLSHTg5xuSCG7RHq4hFWLReXD3a/rlP+nJGQp5L0ghDoXbFolavebn9JjomSSNk45rMmKkkuBGB7v+TkugiL2ILNTM/6s8dXMrTQJskkRUoXZmSPYYaoKN29axC2uMhDuRq+JEAkqlDNnKMg+E7s5Ko7XrHk5oQHLTcHLlR+dYv9/pKYJ3349w== 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=hXlsd5hXtNwb7rcbGKFJkeUZfNXck1TIOQ41amocCGU=; b=OXiP3uW+HE9OyVlHDzTdj2j9urpZiCliQCxGgIK+upGloHkOXw1YM8UmV4+9Qy8URue9sxRNWXhGjCwWkQs9ez8KTxqMgFMtTCFLP1M293pNyMN/Dx5ng/HI44eczbcZP0YMHefk4gJ4kvCzovwCjUeuxYJ8a6T+iIkbJd/fRCp9+Qwm4r8teSbRoQ82iDJbcfEm/NfQSUb0pIlHZYM3eNM7ejPnKlzFmYerm+pn221y2qPCM/15Hhx+Zyy+exM4VFvZkuMHdJuCUxOIKuaHiSssd73p+ce4gWT4DbhMF+S7qcRoAyBpfnI35HxIMF3UgJXRP68YIwpkrBUUEAk+fQ== 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=hXlsd5hXtNwb7rcbGKFJkeUZfNXck1TIOQ41amocCGU=; b=mE8iWzHpdrvFgPvEGL8kccgYVYuCkpBUojNmUpmNuqXO9RakC/u4RjjSP5wyZW5bnsiH+2s5BSXS5oQW3n6MV6l0vLBe8BOGBl3GDQPXjMbtElU85ia+h3ONmdS3kA2K008fhPp3OIqGbEFpMy/9QurZzpMYWGv4ucdNUZ5nJSiigi/JObtu83ZADqWH7ujDqYgu0VrbAGudch+4IWHcY/DfFLAd27njFRCTXX82Y6WRFYbEctAhbgRoYDJvVxCD7s3do2JSjbDha6bnv7EqOlMEZEE2dLs7oF2LKZMwY75bbAjXDVpkUUM5DlYmEA7q/oK++mGUoXlIT1na63Hvfw== Received: from DM5PR1401CA0007.namprd14.prod.outlook.com (2603:10b6:4:4a::17) by DM6PR12MB4353.namprd12.prod.outlook.com (2603:10b6:5:2a6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Thu, 23 Sep 2021 01:50:14 +0000 Received: from DM6NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:4:4a:cafe::66) by DM5PR1401CA0007.outlook.office365.com (2603:10b6:4:4a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14 via Frontend Transport; Thu, 23 Sep 2021 01:50:14 +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 DM6NAM11FT020.mail.protection.outlook.com (10.13.172.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 01:50:14 +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; Thu, 23 Sep 2021 01:50: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; Thu, 23 Sep 2021 01:50:13 +0000 From: Chaitanya Kulkarni To: CC: Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V2 2/8] loop: use sysfs_emit() in the sysfs sizelimit show Date: Wed, 22 Sep 2021 18:49:39 -0700 Message-ID: <20210923014945.6229-3-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210923014945.6229-1-chaitanyak@nvidia.com> References: <20210923014945.6229-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8938f14d-4ce7-41f3-72d6-08d97e347ccf X-MS-TrafficTypeDiagnostic: DM6PR12MB4353: 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: iHvl/JM02/ho0N7n/HfcLOtoI/Ixx16wAHeOK0OJsTq25coPNS4ppTchltRUbRvoq4DdpFbz8N3j8TjphXUtwCFgs+gxPs9AGhLLMyEgA7s+yZ/zl6rbBi78PzYNzvwcrCJTxmkIBpBTEmlGmHwuOcAFfEcHiiGEFijBOmdYhhDCubG/cySihDraS1+6jbdzMJPIY3PA/yyRjDsG+wZX4Ll5eO7Z9mi6ZqiHO/TNc2M5xmN8eQ4VJroSRXMbphK3XMiUsn43yqFtU0jHStCBdhUtUhp9dVCFOTTX6ZlTGTIvzbpyO/TQN14T/5aechvsesf5OZXWryrFR6KbR1aMTTgHjZfXY4PM0usyna+Z0j1QTRYYP7lM9BxdYYkwg37aQ9ywQPFPBFc5XNcm8xrAZ7s7dN7GgWy+hXpae7+Xgpy577LxDVmOilKGrY5O/Lqq6Xauw78R+TqhqH8YS9uzlXmnc/s5m3/93m7KwJxNDSZkBjWRrN9ip5IoXK9nQaFrlzuGATcihRNARzs17fbj9+tkrKXmfm83JWO/pcV8gdRCSevxy2ZuxkIs7dp/70nDCB36ClfT0KDNk6/OXtiHhBX9J1st4RTt+p5cK01r0kcAQLrikajheez5uNjQBwIyKMkZHtlbzRpjpcJprfS6cWwZwtRkN1Ei0jVIpGhWhuvOYKbwwFI8ZOomAzSHjLeegtxe0iuo1VVhrw1RWXIGrg== 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)(82310400003)(7636003)(336012)(47076005)(6666004)(86362001)(70206006)(36860700001)(54906003)(83380400001)(426003)(16526019)(1076003)(316002)(26005)(2616005)(356005)(2906002)(36906005)(186003)(4326008)(7696005)(5660300002)(36756003)(8676002)(508600001)(6916009)(8936002)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 01:50:14.5985 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8938f14d-4ce7-41f3-72d6-08d97e347ccf 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: DM6NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4353 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni 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 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 Thu Sep 23 01:49:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12511801 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 3D827C433F5 for ; Thu, 23 Sep 2021 01:50:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D8486113E for ; Thu, 23 Sep 2021 01:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238852AbhIWBv6 (ORCPT ); Wed, 22 Sep 2021 21:51:58 -0400 Received: from mail-bn7nam10on2089.outbound.protection.outlook.com ([40.107.92.89]:19557 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238851AbhIWBv5 (ORCPT ); Wed, 22 Sep 2021 21:51:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dViBPYj0TYvDk+C/n0Euo6VCVbaT0S+nGEvb1QnF25uvBCp4dOOaTj3WGdbd/B3gdxjFI4umkt6KNFB5RF6uMRXzOI1aPH9HGpawb0a+1/RThh9fdqIew77dYc4aR3tlSmYMxylIpxGq7ZqcMo2AslKpYsKiM5oJXKkkkGOfQjUdwxXUdaPZLS13tIXc6HYzZu1fHIniwQmqjosZ+tIf7xQ4+mrD3L2YyTDToGcfLo25NmS1uafS4a5L29O4x2QWem+MpGMINynfAILnUSr0gRMQHTl7MnGf4EaspUBqxusuZ2XsCca8dO/TSsQA/9fJLaOkVMslQbM8JBK6Z4cyOA== 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=VD+49fMWPMMGUfMIO3JompnVgf6yYeZ7iMuf2BRVqmg=; b=dlIQ0bspoxUpGP3DDfJBIsckNp8I7YvIsQgfMJAJmuxyQiN/wvNsLwytIS0RnqjVRl6JHwKrG16UusFJjygaAN23F3CnWLKcm1TO35W9Fq69UeZpTSs0j2V+lDImTm1bDQNK0ucxBAR42Ah8PxfyeIBFqUEyGMi32KmXwCl/rRVDQ8mDq7YIRGkuV4tHA6F/tuQ6EZevt5sJiqkUDHaonSaHA1pe7lm1AkbAEfhg9406ZikG7cR1UVZeKlgkLi6kmVcgVV8Unm2d2KQ0glY0bLsfeMSNV2yFuCH1g1sBo7diNWBnExl6rt9ibRCWFP0dBZ9InvY4ICXnRki3b3tQmQ== 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=VD+49fMWPMMGUfMIO3JompnVgf6yYeZ7iMuf2BRVqmg=; b=ioUOvmYF0RVtakauxP9BV/aeAbwKb5jMfoITpHxe7Z3ory0NLFhH/A6UHPUjMnp6+VBVnBRMCEJdlgtGRqh2IBN6zkihOfJifEqg1bLpfFezV5zuyEEZCObT+NVxOuSoyd05GSAuSmSfbMllzzzPYGvjUGpBNOsgwWZXdxwOK0Uy4sDXzfuZsypdgQCuknDNE3e9urVHJy3xYXYFW4RB1T6Z1WmqwXnLy7ZpM0ADBQE2yXkgccc6ojR0Wqj3b5Ghi/8QtwY3vDQMjNm37P+aPMdAwnBhwl6G7gCX2EDRdERH0r/4ETaP7F42wwC5VsCLxzSLmjYttJT4zEVGOg+hqQ== Received: from DM5PR16CA0002.namprd16.prod.outlook.com (2603:10b6:3:c0::12) by BL0PR12MB5539.namprd12.prod.outlook.com (2603:10b6:208:1c3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 23 Sep 2021 01:50:25 +0000 Received: from DM6NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:3:c0:cafe::2a) by DM5PR16CA0002.outlook.office365.com (2603:10b6:3:c0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14 via Frontend Transport; Thu, 23 Sep 2021 01:50:25 +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 DM6NAM11FT012.mail.protection.outlook.com (10.13.173.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 01:50:24 +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; Wed, 22 Sep 2021 18:50:24 -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; Thu, 23 Sep 2021 01:50:23 +0000 From: Chaitanya Kulkarni To: CC: Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V2 3/8] loop: use sysfs_emit() in the sysfs autoclear show Date: Wed, 22 Sep 2021 18:49:40 -0700 Message-ID: <20210923014945.6229-4-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210923014945.6229-1-chaitanyak@nvidia.com> References: <20210923014945.6229-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc079e16-afda-4c39-7f24-08d97e348302 X-MS-TrafficTypeDiagnostic: BL0PR12MB5539: 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: 05pym39lUfASdpd0j5BVrpbP1G5asWR06szFS0w1NRpBzToZSktrzQTMbLU0QdMeESvosoa2tpx1EqbxJQPukaGZkPQQNZSYP6iYPDWxyNEbLzO/cvynZBOTUaN0jbArRvuUGLobmOlBSyElsf+tM3IRG8rL2MqH/n9UKVDXhKZAdWcWZQ3dHPZ2QFi8/V+k+AJ2WOoCmF94VgCf476z5nkMSrrjFFmpAblW/vdK0an8YLSZof1ytiQEVRGHhZ6v4x1gCleukDEQ4K55jfHVT7nNgXhSzxlzgx//64SrywSY3gk22F9Ev841RfelNZtaCVlFufKL/rElHKZy5LlM8zs5axne9o06Jbkx2RuUN2UumGlZisz1eoOmPTLaN4eYrreJgc/gT4ZDVtoY60q9l5VZwpSIFL6FRojdHQiuntiihScEDqBoqnbo9bwHjdIUGz2+zo5WyAGIYAGCeg6LsOPti+rpCPvhJ5NZ+Z/xFky38fUp296AMaEBRfoqmTXuSS+qjpwj/uJQ5mfdjAHTjXikqiAUQgBFtS65A9An8IZdA5dZNxjLRtIVKfpYcju3i/oZQk4ZNl3+j0Rcw4oOvFUk32DdDFlt660y3PPbc/Q+RgcqZ/fTBHi9pqdXimuOaxpLWtnCUMzqXyINNOQ+cMIJdF24vHEmXPnDB1xOYTItAdOessdhFe6HYCKfDN8vqgFwqltslHBg6XCA5f4ToQ== 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)(356005)(316002)(8676002)(7696005)(82310400003)(2616005)(54906003)(508600001)(186003)(16526019)(86362001)(8936002)(426003)(336012)(5660300002)(36860700001)(36756003)(70206006)(7636003)(83380400001)(4326008)(6916009)(6666004)(47076005)(2906002)(1076003)(26005)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 01:50:24.9904 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc079e16-afda-4c39-7f24-08d97e348302 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: DM6NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5539 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni 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 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 Thu Sep 23 01:49:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12511803 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 9622FC433F5 for ; Thu, 23 Sep 2021 01:50:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D6316113E for ; Thu, 23 Sep 2021 01:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238853AbhIWBwI (ORCPT ); Wed, 22 Sep 2021 21:52:08 -0400 Received: from mail-dm3nam07on2067.outbound.protection.outlook.com ([40.107.95.67]:58273 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238851AbhIWBwH (ORCPT ); Wed, 22 Sep 2021 21:52:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V/P1bX+DclDaN1TPwnOH109a+p6tDvQd9ocscV9cbWKNzVAu+5Bzm4Kr2reKQYdHLOYj07nek0geJvPL8MpwNEauIXxKx0Wuk+jUOyuc/racImsdNc3zxxNAzX2B7bqTfpPfvZ8tGqiYkK90HlzAJ233bGETWOlCuHB/Vadi5CGXkIiRnveJ2D/0SxlV2KHNnxSJIC9PI8mNHyYhjTqa+DCG8ReWP22SgSIB5xYvoS+qaxK0tdN64HQG+PNJJmCVkgORM0F0B68rDtlVtBYq2Iequ1R7jqlizX6t3ubwmxIgZM/c6JC9C+UqPpWDazRNllFo3KvGgILWYtNFU+CoYg== 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=4hPGlrU19cyAN3zQ6YIGQDDqItqVmU4ak+pQCItJfjk=; b=Jbwbcjnm+nz5CR+IUsqGZoPnTIKEBoCcAHE1mCPdDiuL9K5WdlVDq/dPgY8nh2PzRaF64Fvr81bRwETANHs4pO3BNmDkd/gAw9ZvDyoWiFAKd2U3ccRQTBbYGgJuTivTEdI8HOnxdDU0BnhiOJ9treOZaeim21GEkdx+6NqWUwvuPP5iyHxrDX5DRoGxNG/og4vnY4h+q2sLPNygBEnMriDwsg6tfah3WyAvcJvioshE7avLT7bWFXVMXCSDw1L7ghTi3tuYn3GCrud2ZBEtLKsEg9n3qQlnEZsajaNr6OvNoDASr0J2SrVjlJNq2rCH193GhvpULIInyc/ZmOyNfw== 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=4hPGlrU19cyAN3zQ6YIGQDDqItqVmU4ak+pQCItJfjk=; b=YPJGwP4D+PT+9KsJMBYIKa701pLOmwRXA0EsHE6PiLNyyfGqAtK2xMXIYM2q05Ml6pQY410kxx0Ugkwxwr6sTrusxIdtPN0pGwXU5B5V5qq7i/iEk9wnqStZ+2u29cX3ymea9mfPs0m83Y5y8OE0cTVjKcHFMiV/S55vWYVglz93GCOlOOinAqhYW//LhC4FMX+4dARneaDQTBONsyjArVPESC+VaeRbyaVe+E4J0BGfO6ur9WlIF0Ck0PGuoQi4XsXCFDgcDV/SgTq7R51423TLrkUJuyxbldMGOuVSFDORHUuSMXj9qZrlSlv+v0Cggau7Rk43KBXOnkJMP/KO5w== Received: from DM6PR18CA0036.namprd18.prod.outlook.com (2603:10b6:5:15b::49) by DM6PR12MB3785.namprd12.prod.outlook.com (2603:10b6:5:1cd::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Thu, 23 Sep 2021 01:50:36 +0000 Received: from DM6NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::85) by DM6PR18CA0036.outlook.office365.com (2603:10b6:5:15b::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 01:50:36 +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 DM6NAM11FT060.mail.protection.outlook.com (10.13.173.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 01:50:35 +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; Thu, 23 Sep 2021 01:50:35 +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; Thu, 23 Sep 2021 01:50:34 +0000 From: Chaitanya Kulkarni To: CC: Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V2 4/8] loop: use sysfs_emit() in the sysfs partscan show Date: Wed, 22 Sep 2021 18:49:41 -0700 Message-ID: <20210923014945.6229-5-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210923014945.6229-1-chaitanyak@nvidia.com> References: <20210923014945.6229-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a50f86c5-ef2c-4bd0-4508-08d97e348985 X-MS-TrafficTypeDiagnostic: DM6PR12MB3785: 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: IHzaC0RDij7JVhn6m5gBC0CkVUqeVMbPuiIwCz60awSUFIx5CNzr9HyP2EW8DB8+YS7uYz9J+2eGI6EP6l8maFRv/bkfiIAEfMx0KfA37NNOEHfxqgKEqW80t3ionfFHCYPeFr34dNl1kOdWLql1GieoXcaEqhhQYkRcpPueAWCAQQ8LIbZ6Xz8yzbMDBvRbNt5+xNpa9zWQ1cqcgTfklsUwi66qpUOXgQD1ER0YQt5UvI7D6H6zGNqTUoqP7mElVZ6y+MtVsKaCVO+uDTvNbEHyE7zt8AvOfvAT1Gvq0oM6mOcRzty0Oj/HvR3xtujX+/WDvFc9n8iwvl1YIptv3GXP2TxcArmNpdOKAZyEAhiBTf+kTqe4d8s9efwqEew3IZVIRsb8FyuXdm78KaY+eeUwzJpM0j5wKi6+lMt7hDYKYUcODFaVmKUEpQsJWCPUq0VglFpZEvxLO4bIvnjGWiTJWpMjLVnX4RXCLZrqu15ywqV4ue5FA7008wpHngznQ/HOGejWaT4Oo7pwfHV/cn5nQhNIP3YhHn/y+1ivt/41igiMxRckfF04dhvQbEfzBc16wIhs5mBQOB3uzbhRo3ugHKcbI40MFJHkYoz6cW6yN51k93SyakA+kMakZvGC5fYUjW4RoZwHZRpvUitHlhfGS/SRLaNK4t6Jwv1Gf8tmY4jMr89Zs+4atJrOEG1QCY/pkqfFt5fK/oTGJqeltQ== 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)(5660300002)(6916009)(426003)(2616005)(54906003)(7636003)(316002)(4326008)(6666004)(508600001)(356005)(26005)(70206006)(70586007)(47076005)(83380400001)(36860700001)(1076003)(36906005)(86362001)(8676002)(8936002)(2906002)(36756003)(16526019)(336012)(186003)(7696005)(82310400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 01:50:35.8778 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a50f86c5-ef2c-4bd0-4508-08d97e348985 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: DM6NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3785 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni 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 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 Thu Sep 23 01:49:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12511805 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 8B605C433EF for ; Thu, 23 Sep 2021 01:50:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EFB560FC1 for ; Thu, 23 Sep 2021 01:50:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238854AbhIWBwT (ORCPT ); Wed, 22 Sep 2021 21:52:19 -0400 Received: from mail-bn7nam10on2054.outbound.protection.outlook.com ([40.107.92.54]:27195 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238851AbhIWBwS (ORCPT ); Wed, 22 Sep 2021 21:52:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TCl8YMLOQm5saCGdARuMEGnEJ0wh0s6SZ/3nuGJqHTUHcMtuan3bh4xI8+4EL/ky5IgHjq9818mYt9lbY1D1Yu8wNVJ7ynaI/HTSwkD6LfUAkYK0/DOpejiEqXBtmUNrZpoemdHuM2W05g8+jEpQvqz2CiFrHh4n0fVTQL0B3hKdaJN8FmRmzhZLnATesIak1t5U8ZgXsxvE6SZepvQpQGu/spo85EtPAw86klvAWlvE0xVbbG6jnkWFDyaVUMoEuTEviPj3E/Jq45Y9LsC9mnwK5OJYJjS2Mm2mt1Xp+fpDKZ9+f1f2HgE1GJaQa6eIVm8/HdqE9UXw1NQjNLlyaA== 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=nX0yX4mUHKisQ5aNL2ia0giEMlIMY3Jgr0TKfmnzng8=; b=dqx4YHH4P1LL+jlt5krb3KcmhQQJDBRQuVH7Qez5X3sT056F1mxpCVJC0yKye1gD4JA4iO5+qid5whEP+vl8+pGtQUNOyXtEa3/F+afFhneVvfri1YaCjhCWiAkTM4ikIcRADGfRk/LToo0BT1dLzqV/jkLGci45rxdriKeAQnAiBEDMY9fiaSr08gfvgDY4z02QWkYkFcv/pORJVsgwYp5L46UYIMb9JN+fZE2yNJf0/tYNyL0TPRtkV0DHFMBjsY0n8ut9jAfuPm/TSbzfTQ1DD7KScA7i68BgsCqE2gXPB1bJbWYPXR6zz3Ni4danq9muOpHmUNZSXbbU78yabg== 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=nX0yX4mUHKisQ5aNL2ia0giEMlIMY3Jgr0TKfmnzng8=; b=eN681u/zqqzvm876L5Xz0ZgLfiIGSigaxc96UxJfdHSj7jM63Npu5KUCBlB2PoE4gdcdoWVKkg9Hw7HOj9jKQ6yFiFWrtaXPTvc/MUA7KzIo4rN+pfTF0x36hS4hwlyPPqgZlsvRWrAm0X4cKcBirmShy/kIYqdexJd9QfrBak5ghQrTarbdB2i0bV0cwvJxoBH3F2eXMHFhKI2pfVCjCxX6hSm8hI0ITXCKD7SMhYwlYQDKqBG7u2jAlmefGoQD8VfTq4a1lhzLAPgab3cOCeumlYQqEKW73VgussaAUZ8esHoLDfRmeZBN5dYZRhya9sPcj/TXoYhhGUgSfOgi8g== Received: from DM5PR21CA0007.namprd21.prod.outlook.com (2603:10b6:3:ac::17) by MW2PR12MB2555.namprd12.prod.outlook.com (2603:10b6:907:b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Thu, 23 Sep 2021 01:50:46 +0000 Received: from DM6NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ac:cafe::94) by DM5PR21CA0007.outlook.office365.com (2603:10b6:3:ac::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.6 via Frontend Transport; Thu, 23 Sep 2021 01:50:46 +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 DM6NAM11FT003.mail.protection.outlook.com (10.13.173.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 01:50:46 +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; Thu, 23 Sep 2021 01:50:45 +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; Thu, 23 Sep 2021 01:50:45 +0000 From: Chaitanya Kulkarni To: CC: Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V2 5/8] loop: use sysfs_emit() in the sysfs dio show Date: Wed, 22 Sep 2021 18:49:42 -0700 Message-ID: <20210923014945.6229-6-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210923014945.6229-1-chaitanyak@nvidia.com> References: <20210923014945.6229-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a59bf51f-80c4-4a12-136b-08d97e348fd6 X-MS-TrafficTypeDiagnostic: MW2PR12MB2555: 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: 3tmdr8a5h4rOwD2enYgKHohbzv37KTI6JwjiH/ad/qJ8akCZYZi0ks6cSnQc/S9OuWkWR6Xa1q4n9PrxQaNblehYi1F2ZrecQ9OIBy3UalVP47T1wjPOwmJt8tY0C7y7cXJ/Nktuq5E88X0nzUsoOXgM+opAjDlMLDN6USEZrnVmsHYwooY8k6FUuJmZqHxJV+XeZhNmu45m9JTophWwBn3SgoEjdHaUO/ihPRnwJ6LW2DYKv+Oetxbzx1YxBBJrQxJVTAAjzSY9AQdaJ+KMvMijfGredMnPmF4YQKWZSfkwCQ+6QiAHYnYv50fX6jVf/T4doVghV0/wAmh8tTCfY0dRYu7NrpVjFfigNmdbkan77NCyrAlc8CKqs00wFNMGGExpEpNTPP8TqPbEOduBcdmtZKo3AgIqMkTUu0VDXM6Bb86c8sjqQyQfjx1P5bNT1NU8J8OHuhlNk3cclPgs2QBIQfkjPUfKDa1kIOxZJ74YFYOq03fJxtl1odsTYxoQiqrGKTZ8tjQWa2D+6Rw5+dnHbzA9DOuRNTF2QY2e7008u93m83H9DmvHcVZQhrI/aL01uWIOiMd3jMKQl2Mgl4tBYvxf9jwcuXC1XuVGSSc8PBRLMKMU0TyknHcNB1SvsDt3qrgp4vVHOTB72ofqZY+xeyU8ZWtTLn/yFiir76eKlAaWuw8kfiPFgDOgi0mGeC9DvtJyzJ2T6B3YtJOx9g== 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)(316002)(82310400003)(8676002)(70206006)(86362001)(36756003)(6666004)(36906005)(5660300002)(8936002)(7696005)(4744005)(336012)(2906002)(36860700001)(47076005)(426003)(4326008)(16526019)(186003)(7636003)(26005)(356005)(508600001)(2616005)(1076003)(54906003)(70586007)(83380400001)(6916009);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 01:50:46.5037 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a59bf51f-80c4-4a12-136b-08d97e348fd6 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: DM6NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2555 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Chaitanya Kulkarni 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 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 Thu Sep 23 01:49:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12511807 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 04265C433F5 for ; Thu, 23 Sep 2021 01:51:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB1CE60FC1 for ; Thu, 23 Sep 2021 01:51:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238832AbhIWBwa (ORCPT ); Wed, 22 Sep 2021 21:52:30 -0400 Received: from mail-bn1nam07on2067.outbound.protection.outlook.com ([40.107.212.67]:7755 "EHLO NAM02-BN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238817AbhIWBw3 (ORCPT ); Wed, 22 Sep 2021 21:52:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IVWnJ30vQUaNxihC2hRw0A04dPvLAQ5OhAqJyHU6T/KEt2FWeBW1Y6y2wxVnwkh39su7zTC57K/L0piAHk2EEYr+I93txS72NlIfSZA2RF0uP0b+YZ7XJzkoNnn3PAd7rgvtzTCS6NvAydGPh2GSn8KzNORlMHhyi1zHLRDixPFKMHDtyEX4FhkNByHbFsph2x4RS0tkEBax6wJdPzHPYyZjV34SvZ863UPNyx0m+EU7/dP+INvK48ax9raVcVm64vsQ5LQXhfgIe3WUmtplyCgBXSQBiZbU/8kdNPUh9p4upRnWG3AFFUg4mSnqp6wJYopQ2FOJ9jpzMbXZ+uSdZw== 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=Gl2WszHW5c7knAkG206RrWW9l/E9N/SnUN07GajKMXY=; b=VrLpR6Fixy/mzSOMa8U/XjtPwdOyZIWQhJU4wrleIze6gFhKM11RQ0qpjNJaLrCOXAEXgIFhFd/i397823dET9v8QbcqjnV4181DpP+PO5PgAWAzAuuHu/DPfVFsSzHsM5a3WSsIqAnZIRZu+GahAbBAL/4V8tqoaaUeU8XdWl10MwT76f72ugoWF1VUaMy65XhTpKvV3NgtpyZheGw0qaUoP6N/lC/j8bWYw0IzmiXdOCkz9R3WEVXq9sNOjwizOii3Oc6SETS0w7fvV/r0JV8onHQk9XHQzppscEsqmjwQQfOsqsf1nNIul46D8BzTJf1CyERV5jqKkWmCKXQeHw== 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=Gl2WszHW5c7knAkG206RrWW9l/E9N/SnUN07GajKMXY=; b=ItoMrZSIerTC74bolIMHWBGLEv62nszGU0/nv+H39haHmbwVZM2mueFoiDSxB7caxT8PxVr7X+d23qqr8RqM00ffyNURuPLrGkRuaX9Ujox6oBPzM3xG7OkHMjbXJ5JpTcTLa2eKvID8G/vl57B7ioVRHYvJbm+XRigQJrSrX7UQUPmjZ83Jp44BGSL/0pRfcI6y6n10sbimdPOAuTCKf3NyK3Y4ZOdzeAjmxtIt3D2HtDR/gdmpj+eTPmEkSvitG8sHqtVeNRKk1IYIYli+r9cAjQBzY8f9YIpxRABDrXSKF1dYngST1rzeZlNv54k6BnIgNEcMeQZqXC/zK/4udQ== Received: from DM5PR06CA0077.namprd06.prod.outlook.com (2603:10b6:3:4::15) by DM6PR12MB4941.namprd12.prod.outlook.com (2603:10b6:5:1b8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15; Thu, 23 Sep 2021 01:50:57 +0000 Received: from DM6NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:3:4:cafe::70) by DM5PR06CA0077.outlook.office365.com (2603:10b6:3:4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 01:50:57 +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 DM6NAM11FT068.mail.protection.outlook.com (10.13.173.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 01:50:57 +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; Thu, 23 Sep 2021 01:50: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; Thu, 23 Sep 2021 01:50:56 +0000 From: Chaitanya Kulkarni To: CC: Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V2 6/8] loop: remove extra variable in lo_fallocate() Date: Wed, 22 Sep 2021 18:49:43 -0700 Message-ID: <20210923014945.6229-7-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210923014945.6229-1-chaitanyak@nvidia.com> References: <20210923014945.6229-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e77c32cc-e06d-4e51-a2ac-08d97e349638 X-MS-TrafficTypeDiagnostic: DM6PR12MB4941: 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: kCM7Jc0oevMNpXpxJMwTpDKvZoLuL/q2JRYI72085lbcTQExEcONhTnruyTt3ItD2aCEunOUacOsSh6prDbPT3PZP9LPuDJDQto6RX6J1GQ/PuOtIOWPW817ZuNws+WId1d+5GcqUVzrpJ5j2iQSFPQJ1vYEyi+GhEmhUKMsWyvra/neFZ9F1jmmByj4NMYt3aUN0PbsOvp9eYVx0qbfMHBcNfFM50Co22cQ7EXrytzTd80tKKXAVHXE1+ZVmpu5J8ouX5Dvlgk1YjMYXrLfUXPTmRUoYiMOp0AVEoJ4uOteXCHpXd3vUP4VCjpy3t/X+Pbl6dXV4BQp8uHxziLA/aVIUTmTecrh6IVYxY0AcBCtxP9xiUFJo308HqtHy+QjAFEkJTmAN0HLmqH/tEauhAspvtNcwuA2q5CRrqKPzZc43YCTZSagdhVuSfHj3r1mYGBZlPwYCTQq7+yeFpHPwrYDL1CXmlOdF20hm8NqA4GOrGD/T/NFI/iD0pBPkhUvyigoTzFqlTpgdeW+w7dkTc+2XEULhT2JyJMKKTBYtcPQyXAxHln/qySR7qcpjxx97PKSWjhoZm7N0p0nnDjfEkUKV/B9vHQ32hrRsLOuZlpyPLfpuWZP6+hDcl6pNT1cH9gIWd8pNyhpxJh4WxEoYQLCHKR615H+oeEJ3WqzySUPK9ZoIM/p5WJEc0pb0V+OkhW/zI2Dq3GShxPfezFMmw== 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)(26005)(16526019)(186003)(7696005)(508600001)(1076003)(36756003)(47076005)(36860700001)(86362001)(82310400003)(83380400001)(336012)(2616005)(426003)(6916009)(4326008)(8676002)(54906003)(70206006)(8936002)(36906005)(70586007)(5660300002)(6666004)(2906002)(316002)(7636003)(356005)(4744005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 01:50:57.2159 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e77c32cc-e06d-4e51-a2ac-08d97e349638 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: DM6NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4941 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 Thu Sep 23 01:49:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12511809 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 CF528C433F5 for ; Thu, 23 Sep 2021 01:51:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B244B6115A for ; Thu, 23 Sep 2021 01:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238840AbhIWBwk (ORCPT ); Wed, 22 Sep 2021 21:52:40 -0400 Received: from mail-bn7nam10on2071.outbound.protection.outlook.com ([40.107.92.71]:14915 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238817AbhIWBwk (ORCPT ); Wed, 22 Sep 2021 21:52:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cz6twmDyXU4O6r3nY3X2aq82o1mE1GpBZnpIshXQsqmmL1w4Fnl6jNOfmtaQOMy4P2+hY469li0drGvSHOyUtCW7VGRnm71msLSMhJenV7grjLItBS4M1Dtc0VqJlqW9wlXSZ+wVJV6iAv6UPhawITMQnEsdRFQMHIY4Ju4of+7IyCWIDoQBJ1W9sjvjTDe8InY8MjsoZmBs62u0X8VNL6Tqfm8HDxt1pLxYSaku2nGflOZm3Ag+rECfMO2Xq/OBf4plWMODKKKAJPRgNCkUsmm7m79Rplmn3WbhWWDChIu/SYOvBLOapcBl46J7W3Ckw68XkTm+AImorRHBSFxZ5g== 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=3KvSj+h078RU2g6dCUQIzA4y1ESajFKmU8Vl9gMI4d8=; b=OLtnv2nlfTG10t7AEqVTInT5EBkHfobK3ZFSkv9f41PRpte87PJ4my9mw3Rcd3b7KNKGpvrldnFxX1UqQRLHlLgr60QNVWUH3UsY0NNmMDVkQpMvPVQSu1GaHmqAb7a58tvkQfLaG9T8vvZCzMpr0U+feuX514styX6q89ubyaB1Zj25iG0w+Y5WR/hv4hnoHRt3uWJ2N1odZx5ktVvb+jwtizYUcCOOpU9nwgGVdcsqtl9V6axavSZd41fu0d5RVvQa3V1Q1BWaqw9ZmEN9DKS02nmAngqeVYgbDk8Mk7hcjOn3xYmMiXV2jdBvwAVTxO4wgELZX+QDjjhMWrZ3rQ== 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=3KvSj+h078RU2g6dCUQIzA4y1ESajFKmU8Vl9gMI4d8=; b=FRnrTEcXq9Dd+K+3dUPiVCiHwvDLnpeFVt5+0s/BYa09e1GLGM55FTkWN+IS5LX0cid1fcxHe1Qy1s+xx0DAmpF83fiZd3F+xVLSxzIrEYgMVzzkuW0DiGAUhhmhFQMoZkL2Fkthg2g56zA7Kd/Q2wo3tPOk8HSvpNQa0YhRPc6lMbKP/KZsGOihLatA7R642etsfV2NGrXxSFgpRph0GXd1wQExJl3CC+TiX2See37GB5rSFETQf/I57hKlId2V1/JT13WIfLacXKf57iUMLbsZYC3fhf5uje06lxgt2hlojbPCQ4KvQnK74OcqLQWWGA9FtRFSFIjA9qo7U2vlow== Received: from DM6PR18CA0029.namprd18.prod.outlook.com (2603:10b6:5:15b::42) by CH2PR12MB4024.namprd12.prod.outlook.com (2603:10b6:610:2a::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Thu, 23 Sep 2021 01:51:08 +0000 Received: from DM6NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::fa) by DM6PR18CA0029.outlook.office365.com (2603:10b6:5:15b::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14 via Frontend Transport; Thu, 23 Sep 2021 01:51:08 +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 DM6NAM11FT060.mail.protection.outlook.com (10.13.173.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 01:51:08 +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; Wed, 22 Sep 2021 18:51:07 -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; Thu, 23 Sep 2021 01:51:06 +0000 From: Chaitanya Kulkarni To: CC: Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V2 7/8] loop: remove extra variable in lo_req_flush Date: Wed, 22 Sep 2021 18:49:44 -0700 Message-ID: <20210923014945.6229-8-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210923014945.6229-1-chaitanyak@nvidia.com> References: <20210923014945.6229-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fe73300c-50fe-46eb-f3ae-08d97e349cb6 X-MS-TrafficTypeDiagnostic: CH2PR12MB4024: 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: JZCXc/7fPoIhLZORiY6ayw3XHttsRzjIUfcc+u13z4qPKcDBwxIf7yO89E9mwniLtESsR0nKYK5pq/PQcb9XoZttS+hi31N81TaGUvL4rqROUgmeU/T5aeEghLCaMEf0+cYd0h+eE3GxwAf027GpE6Hbi/XKwOlxeYcpMepAICYZ/aDTEqHNeuHj8pOfbfKOMnVzjfsdIFuZFPUBSp+yIyHf35Zg+ALeojlekArhskkc5BxsWjtF7Ojn2wN/My012TPzbud8V4gOEnmEFedtdF9T+IlCcq4COmOehQ4/E73m+tLrhLTyl3UmatHY/v6I8FPTGevrF9SaB51rZA6fo6sl8uKc4zpE7dxCESsKvRw3QEK6Y1JYqSNr/irlVdvij91fBOOvc5HqIraNUdnCFkBzolIpHdoxgonw6kNt/6olppS4123gQZ3e4lz1b0F8S2zLJ9FIazWEIs34C/bQ83fYxtWaCIVDFEPdP6v44QmmOkLQjLCWbcT7Q37y51isaJbmVoWbRmMDylRIpvDdgcZzz2JSGuXzO+AloPL/9zw/XwFyhn1XZ3MVX3YGaMEO6VYqk/9rABuFdPUEDajMhK2zKB5p6GmxEpQQZ3Cqrpfu9Pg+xRcjME/ebhynjVIDMn4lUUghnOCZ56QpJP1dHxtxVTiJw/vtMxEPgJZDbPvjvdQRRKEKUXq4PM/qMphYVmT96rgcga40scZmLM3zPQ== 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)(46966006)(36840700001)(83380400001)(2616005)(86362001)(82310400003)(36860700001)(2906002)(16526019)(4744005)(5660300002)(508600001)(4326008)(1076003)(70586007)(426003)(8936002)(6666004)(8676002)(316002)(186003)(6916009)(7696005)(7636003)(47076005)(54906003)(356005)(36756003)(70206006)(336012)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 01:51:08.1171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe73300c-50fe-46eb-f3ae-08d97e349cb6 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: DM6NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4024 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 Thu Sep 23 01:49:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12511811 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 3C124C433EF for ; Thu, 23 Sep 2021 01:51:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E92F6115A for ; Thu, 23 Sep 2021 01:51:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238851AbhIWBwv (ORCPT ); Wed, 22 Sep 2021 21:52:51 -0400 Received: from mail-mw2nam12on2080.outbound.protection.outlook.com ([40.107.244.80]:55520 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238817AbhIWBwv (ORCPT ); Wed, 22 Sep 2021 21:52:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RpvJU0ZM9R6PEGGlK2pV1QLd9SqTPhvT0ZyCtL3rL2Ir689lMyzoBDXXGcwcXOxnGc2pkyPrJIu1otMIrCX1Vt6/wocWAExHqRKOi5fEQI057plxvOH3rhZwfdh9NaVqDE3dmGVIhd3Drlon1ggh4WL3YDWwMBXsFzEPqu7Rz8Lzk2p9l6oBMKZSR/XI52AgsPVGlG8e4kyHqqmnlMoiFRZBqOyVG8NAAkI9EvcTk5Gn9TVBSwvT6tcDrFF0nPQlEOA2crWaQK7PM90mpI+yP4PZM+YfNEAq3GXVLvPZHmAZ4eeUBKOIWzGBu6BGSJQCSASvyuDnIFCELeItw1NYjQ== 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=WhegZps1GvwBN9JBNm4GtwfYiV3aHgaDGOveINy+oYg=; b=Iuno+0V9VVM+cjqs1PUYgTCJigEI6E5xtxttB6RVdmHwPTp/Vyl7Y2llCL22zLdlqtNVeFuq/voDVXGaxSa/7iWRKgd8+ZoJaOkVusbvHzr7j3G8Swwhpyt49FsTRGZXHyeqCIqMVkzZoMfDH9EWPQfbJqDojBW070Dus7JXqqgyG4XR1Niy0Ho0f/Lsew3J+8K/KllltNZFiL8wSoXBVGBcpZH7U6IqK/26Dpc/ssKTMpPrRfUWLVuH0YH99XCTYK7iCkUifZwP25IcfKDfVpjZ/XmZfabpXWdrVQ6zM59qW1Ey+L4AZVXpHXoYtcPzVIAJ3uDFizNPlxIcOVIrYw== 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=WhegZps1GvwBN9JBNm4GtwfYiV3aHgaDGOveINy+oYg=; b=q5aoG8a+0/aAPMGhTtRM/vI8mBx/59SHJfIroFRZR2lUxAYXZ/G0o8Q4Md3VSuSVC3KQnR1Q9Gbu6+cF1bnG3jtr1IAbCGmWqJ2XqtTedKDEaLPd1w2XZfIALY/LUDqvCpGgXPGcB6a9C00fkHPRh30q7BKmXcQMegffPcVb5L83bjQowQ4+W4otSTb27Cr3+NIiQ4dgC0EdZ7BAskauPhbxy6FpskeW8QYvZ7UezbeKTVOhyfQ2eQSiZebteMbY2JcLCjdhiXao4BltLvHTAZwqbLJFE36oBurL3Zb8LAabsw0FhGP6HH6EVZc4XnOnop2MJJXUlbIHvh0uLYtCVw== Received: from DM6PR03CA0011.namprd03.prod.outlook.com (2603:10b6:5:40::24) by SA0PR12MB4382.namprd12.prod.outlook.com (2603:10b6:806:9a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 23 Sep 2021 01:51:18 +0000 Received: from DM6NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:5:40:cafe::e6) by DM6PR03CA0011.outlook.office365.com (2603:10b6:5:40::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 01:51:18 +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 DM6NAM11FT018.mail.protection.outlook.com (10.13.172.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 01:51:18 +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; Thu, 23 Sep 2021 01:51:18 +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; Thu, 23 Sep 2021 01:51:17 +0000 From: Chaitanya Kulkarni To: CC: Chaitanya Kulkarni , Himanshu Madhani Subject: [PATCH V2 8/8] loop: allow user to set the queue depth Date: Wed, 22 Sep 2021 18:49:45 -0700 Message-ID: <20210923014945.6229-9-chaitanyak@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210923014945.6229-1-chaitanyak@nvidia.com> References: <20210923014945.6229-1-chaitanyak@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18dde720-d8cf-4258-6c13-08d97e34a303 X-MS-TrafficTypeDiagnostic: SA0PR12MB4382: 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: kCDNt6sb17dInhcX8anWwi1Yg2BmelvX/hm7FkP13zqWQBhO1RpJ7ZnNOyWQ8/8n544ysX9BBet4Zv8sfjsiBmgiTVenlgzfyQsdQnDeLCehZ2+VV4MMiXPHiCKkyx99wVXkrXSw9sdRjiMn/YAmW73rqyFxzNQc4gstubzRqoNFNMEDH10HMBPz/XJUEodNu326KjWpFE37c8ajdEW68XexDY5kNYHXC2YdtgZlTjEW/JpIyN7lgc4nEgO4+aB9nqK5BLvve+c/RU5NgTdVu+6N8X7i60hizI3wdQ30euTjlPo27ZAnLHiafGtTkHodaT/qp38ktVjexhHVG3ipOsSk4kFDWTFDKiM7e10fqAeeGF9zl+9UEaMqSXQQqB38OTZt1+d1/SElgeoaK/Vs/Lq1t6NLmL9NjHwmJsF5g/9ZMNHKkhNY2CbaL/0oKsc5b8A3JVFJc4r1w79H5JNmlZqndWUUxvwXYuqPTuUIx2Ou1ii85Jc/9N/l91K+Q2pAauh5D0apAjuAQK38aC3ZtJLZjO8F3+NellV95ktA2p5Rp9eXdoOekrCMVtYFW8+NvF91L2FiFyx+vw0yPi68zADX6CHgNPLOwAW0LG86ffL1u/5yP1dC5a4c9tWxAXerdIBiJu/wFyc8KphvF/t8QDqPa3QcopljDLOnt99fj8PKPiNh4F8CFuRCK2Lu79+NOmm/eKomxmwdOCRbfbTdAw== 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)(82310400003)(426003)(2616005)(356005)(7636003)(36756003)(336012)(86362001)(83380400001)(5660300002)(7696005)(1076003)(8676002)(6916009)(36906005)(8936002)(70206006)(316002)(54906003)(6666004)(70586007)(16526019)(186003)(26005)(36860700001)(47076005)(508600001)(4326008)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 01:51:18.6836 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18dde720-d8cf-4258-6c13-08d97e34a303 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: DM6NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4382 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 |