From patchwork Thu Jan 18 09:43:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuezhang.Mo@sony.com" X-Patchwork-Id: 13522657 Received: from mx07-001d1705.pphosted.com (mx07-001d1705.pphosted.com [185.132.183.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9448A1F939 for ; Thu, 18 Jan 2024 09:53:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.132.183.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705571624; cv=fail; b=NJGthe8PivDYrLIho0gR13UOz8xBSCAkCHKLKl7f/J1rwV7qswtNeqXPV3KRnb+j5D/C/m+3McCtrbpGyo/gLq6uHKg70mUgECd/uUQRLeLPfR6g7pr+R09cw2qHpiTkab3o+Pa5bjt9ZnSM6S0fCABl9KPXXknC57uke8QrKuI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705571624; c=relaxed/simple; bh=LGLLy6bcuNVFLLvfBcRHowJQU4pwuM7Mz/hpW/uoLM4=; h=Received:DKIM-Signature:Received:ARC-Message-Signature: ARC-Authentication-Results:Received:Received:From:To:CC:Subject: Thread-Topic:Thread-Index:Date:Message-ID:Accept-Language: Content-Language:X-MS-Has-Attach:X-MS-TNEF-Correlator: x-ms-publictraffictype:x-ms-traffictypediagnostic: x-ms-office365-filtering-correlation-id: x-ms-exchange-senderadcheck:x-ms-exchange-antispam-relay: x-microsoft-antispam:x-microsoft-antispam-message-info: x-forefront-antispam-report: x-ms-exchange-antispam-messagedata-chunkcount: x-ms-exchange-antispam-messagedata-0: X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype: X-MS-Exchange-CrossTenant-userprincipalname: X-MS-Exchange-Transport-CrossTenantHeadersStamped: X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID:Content-Type: X-Proofpoint-UnRewURL:MIME-Version:X-Sony-Outbound-GUID: X-Proofpoint-Virus-Version; b=SrfM1NqxgR4xRO5TKhD+pwdNXN1SPrwmea20ZFRzhQrSCUXhrWiprgeXuMiXBbetsUryQFfNJPB8eIZTZI7AaKO4lXpGjuNLJPNnQiCpsr7r56LwSWDb3MPNy6L8TcBiE+eNNPlnXJNJ/Yrr+5Km6a15Nqa2scWPMRZuRfDdK0Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=VEp2qWS1; arc=fail smtp.client-ip=185.132.183.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="VEp2qWS1" Received: from pps.filterd (m0209328.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40I3sAjE025089; Thu, 18 Jan 2024 09:43:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=S1; bh=uLbdr9omxUp+QM+F7frPgl/MEITen9oYQseC2g/kyGw=; b=VEp2qWS1YvgD1ZLMhAhoFUZ7E4VA+zHakNRsUojBwHFtAB1R8OAAGTGrCCWDpGVw64yH TTuC4Yr3m43iZIWGMQXrArMqDufCFFMmjgk2KdAYhvtqekCEnLwSdKcesnARCSgLPkMt JvwDr0ZkuRZvOioza+n4sq24js3w2GdKnPhY0a/UAP3UnUBz+IAdDF9AaIlDMRAMf9db a0CS7ZpbEt20SMhLLBRbnY6D6o8x6uV/rCDS1zAUYzfsLj1UAM3wN8LuQK2vwmi2kxD0 F5X/hIm8yUEorw+ImHQOErbhak06p2EMDh0xxpfObjxf6q3g6X5RkwGYNSRmi12ddntW qA== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2041.outbound.protection.outlook.com [104.47.26.41]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3vkkpn55we-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Jan 2024 09:43:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gBmWlVuA2Nlpsitr7yq6C6EHczd8uPsHxsFlbwd/eiZhhfasKaBVOgoEbBorAQ6ospmvIsR0fcRAgcXdfWaN21Yk95IZvhuIhEg/oDj/BwIdZ4exT4N5dJEvxgU4W6RIiv9PGT9gWrDAWK3v+eOGtVWi8DDv9Z2QPT940+WALLyAR6b0dqgtQkqVjaa8WIs5iS8o1bJpdRQL5WRPy01FsZUqNHstOzEs0kRhzYSYF8t6YqxDnrF51DqcF1lzjM4m2QBfldQU9t8OcMoCNTviem5xRw62PDvjzpH54t3xTitTUzJg4m6I1BMYZIClAz8leFZLd8ybSIK2PsEK8b3DeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uLbdr9omxUp+QM+F7frPgl/MEITen9oYQseC2g/kyGw=; b=JAeeXhbSBiVhn/+si62v3fTMFEWa9SD+Z+PgtjFYq5+zCiv0XH9C6LoZOxfJOQh9z0EzkuUm/qaEJeYXxM8kZ1eShOKZVFpvi+T7lzm9B5F+ypeu5EyifGddm2/psbCYCi2EWqz0U4EftZpDOTvZxC9NXWq93sFQtGfZE5LCuAl322GgtiL+jgKajD98m5xomtb3vTT0qE+kK6oqE5zES4V/1s8a23lJeBQgmTW9cfvUoBCF+mWPa+MBZktGtqKXUVtIeZ3+Kk7WI9hoOSzwEX3oHbRTmi/pmsbUYK55bUKmcT6FwNfpOMp6Irx434aeqBcgwUWm6T7ef7NJCkFaNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sony.com; dmarc=pass action=none header.from=sony.com; dkim=pass header.d=sony.com; arc=none Received: from PUZPR04MB6316.apcprd04.prod.outlook.com (2603:1096:301:fc::7) by SEYPR04MB6773.apcprd04.prod.outlook.com (2603:1096:101:da::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Thu, 18 Jan 2024 09:43:23 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::f0fc:7116:6105:88b2]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::f0fc:7116:6105:88b2%6]) with mapi id 15.20.7181.026; Thu, 18 Jan 2024 09:43:23 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" Subject: [PATCH v1] exfat: fix zero the unwritten part for dio read Thread-Topic: [PATCH v1] exfat: fix zero the unwritten part for dio read Thread-Index: AdpJsQv8T4Ivuy8bSKO3lgONYXaYZAAP/Anw Date: Thu, 18 Jan 2024 09:43:22 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|SEYPR04MB6773:EE_ x-ms-office365-filtering-correlation-id: 26d98409-2c85-4cc2-b466-08dc1809e96d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: M8bx0hox2vtew7+OcsUB0uRO0fkEN8EGpRGZxOEqqDVZPBLSqi+froEm6k0kvXLPXdq4GJnJdYH4EqTDNFMQ6uE9cQPPbFOYJ5f2lUkwNYLw+imL6DYqBesGLjE43UkSxp32VmvSnHhhOagHpvkv+CtZEvEaZVQoeEvCCWhdZTkuWxt2xyzzhXoBhVNEWWyZ08d/mjkcSxFFCVzpYHPIVaPIQJNFs8EqfJ2/zZqkdAOjdw3HBVUpFcAzhIqK3FouK3L+lITGanDcLaEO8DyCiDzppJZXXrVWe+23XQHQHXD1j88F4d1KLeg8mWCBluJPLUCOZErhjRLYtesG9lqraCBzDgUq2ArYeEKsZbSwO4k+pkLFWAzQDNCgoEIPh7fw7R6WQ1mE7aEc2gVHd0uKyP169Yu+uiKsSxvBLurC2OvcHdsY2NFbxkoIwEAu89AIt2frengvAhthLBRhaeiebn9+jHoeF2tCg4k2hj65Pg7BIxpdG88mFI5hzO9xtVpvqeJb5+4db9jNJSiUgTioT/pTcJKqIfj1IPH00W4HzgcTFIQKOXvoww+dnttnDkJ6kd6tQJq+KVqXSU4J8zHs8ViMzTUh1LDBiz8KiIfPl3kmYwx/CcmZyKV19Vm9Gs7A9G6KARFeFlZo0UFRErdmXw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(396003)(366004)(376002)(346002)(136003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(82960400001)(26005)(86362001)(478600001)(99936003)(9686003)(55016003)(316002)(41300700001)(71200400001)(2906002)(107886003)(6506007)(33656002)(7696005)(966005)(38070700009)(66446008)(66946007)(66476007)(5660300002)(76116006)(54906003)(66556008)(64756008)(83380400001)(110136005)(38100700002)(4326008)(8676002)(8936002)(52536014)(122000001)(99710200001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?MNqyeGh8+yKrlqOD/cpQNvTXglek?= =?utf-8?q?9jpTcvQaAZXChb+ub65KXMLhL/w4dSyfiPlqbh+ckuZS4CgzbA8o5J4pEw5W1H7cq?= =?utf-8?q?/chZhT6P5QJVC3QSKMdJ1iliU6oqy/7ZheQ2ArpZAs0lD0p2GcUC2mvnuyLDHOPjh?= =?utf-8?q?kP9sSIN3FfQ3EtrQpBPYF2Z61gUX0E0wSl1DhXFrt0UPl9t8M/3+qwpOGd/Sdh0Pl?= =?utf-8?q?9Y+3LHdg0cNBgrBKYDegNzCpZ8w/g2Gv9N5vDJiBk/MXLS+rBk+2QeWiHrtAVLIVw?= =?utf-8?q?OIREuCkbc0xtdkdP32WkIjFvN0RaczzQoexCdj7pYGWFK8whnVagtHlnMQ+ad/kVZ?= =?utf-8?q?xPV/zAW1QhVxIPonj42Qio1JnSaVE8BnWxIvyPCTf6eoOSBPD67eC742auHTyYeqt?= =?utf-8?q?eIRyu+i/fgBnNbJKsSHJxvqVC0SMTwK+NYh3cDgSfVg5/iGlWj4vkXdUTCf8bwxFo?= =?utf-8?q?SxkUGtkZ5JXZgf2ttdXlWx8JpMPmPUvfSWfzOmspGCofrzVzN6yl66vbRwGT0uSKs?= =?utf-8?q?799a4dWTOkXSqHZ1NU2XixOrPM8t4DAclHaiRYzXCT89Z4V9OzozjPdCeDsFdMp82?= =?utf-8?q?chCS1ImkD/sgqlETPOakw3jgDbGjhZZojfuZJJzlcY49wWkGUEKOxf3ojXM9GouKr?= =?utf-8?q?KJCdbZK0KBp+AWoaLaA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ntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ZfBvkt4vRhYtU8DBxCE28wwQmB5/L1Cycg8eu0DkLmpyoVRv+5gfJnFTSkw5WbF/xVg9E3uIQqiAGv84MbaiH8yHk9SM0wQ/aFZvWvxJUTOOQ3B0mBMI9rWpnuG18B5m5k5zufOxnKMJpqISlw8Bhme1ZHH94GkLxjcLsF8JzvGX4xvt46Dy8mNdPIU14UBnAfxe/3yT0qD/RtFaRncqEPru/DARLGjpf1/CdftUsdrRM+bZMF3E59eyWzNY61wYRqeNKmgJzZTqP5eg6q+GOId+rAnHufEQYhIWwLbrpwz2Fb12DE7qYPEidf/w2J1tl9dF6qnLyE2m6gnc61oiHVAqKlEgRN2KcNYh7BQZLldm7W3ePFGD9mRCgoROr0TA5l2UR9K/dRK9+UlQ9eU/Mp5wQQWL/DrTWhDoWbTV3PC9iaGW3EYOml8lVfJdvJwk44szvjNzKO8oyGvvpk3OFhu2a0ZWFTmx1t2nTN77ypyzB49+qt3tCG0l4uttW/XIWkdbCwdzJ9WdHYTD4ta2e03+p7cjVonW4T58xkV9/+B0ahtIOCWKBYEkyJ2UaaL3ABLHWyH/9ZzrQJMn1FefxJAIRKbmsXc7SSkZpnUfDoOZ9sZzhOpLLLhNtsPo93uy X-OriginatorOrg: sony.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PUZPR04MB6316.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26d98409-2c85-4cc2-b466-08dc1809e96d X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2024 09:43:22.9577 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 66c65d8a-9158-4521-a2d8-664963db48e4 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fwhN79IUzQat0eR/GZUjWhGcfVye7HqLpEuFadZkBe3zmFShM3xganUOyuxFllDiJjVMNuEV3wzlqcXg0uEzoA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR04MB6773 X-Proofpoint-ORIG-GUID: 7Zcp8Ybo7wh7r1wJhHmhwyeygGsWaOJA X-Proofpoint-GUID: 7Zcp8Ybo7wh7r1wJhHmhwyeygGsWaOJA X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Sony-Outbound-GUID: 7Zcp8Ybo7wh7r1wJhHmhwyeygGsWaOJA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-18_04,2024-01-17_01,2023-05-22_02 For dio read, bio will be leave in flight when a successful partial aio read have been setup, blockdev_direct_IO() will return -EIOCBQUEUED. In the case, iter->iov_offset will be not advanced, the oops reported by syzbot will occur if revert iter->iov_offset with iov_iter_revert(). The unwritten part had been zeroed by aio read, so there is no need to zero it in dio read. Reported-by: syzbot+fd404f6b03a58e8bc403@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=fd404f6b03a58e8bc403 Fixes: 11a347fb6cef ("exfat: change to get file size from DataLength") Signed-off-by: Yuezhang Mo --- fs/exfat/inode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index 522edcbb2ce4..0687f952956c 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -501,7 +501,7 @@ static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter) struct inode *inode = mapping->host; struct exfat_inode_info *ei = EXFAT_I(inode); loff_t pos = iocb->ki_pos; - loff_t size = iocb->ki_pos + iov_iter_count(iter); + loff_t size = pos + iov_iter_count(iter); int rw = iov_iter_rw(iter); ssize_t ret; @@ -525,11 +525,10 @@ static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter) */ ret = blockdev_direct_IO(iocb, inode, iter, exfat_get_block); if (ret < 0) { - if (rw == WRITE) + if (rw == WRITE && ret != -EIOCBQUEUED) exfat_write_failed(mapping, size); - if (ret != -EIOCBQUEUED) - return ret; + return ret; } else size = pos + ret;