From patchwork Mon Dec 26 07:23:32 2022 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: 13081685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42F31C4332F for ; Mon, 26 Dec 2022 07:24:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231734AbiLZHYH (ORCPT ); Mon, 26 Dec 2022 02:24:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231717AbiLZHYB (ORCPT ); Mon, 26 Dec 2022 02:24:01 -0500 Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A09292DDA; Sun, 25 Dec 2022 23:24:00 -0800 (PST) Received: from pps.filterd (m0209320.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BQ5jskY031801; Mon, 26 Dec 2022 07:23:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=S1; bh=RvyFy5C6LSmgcCIopRwjCxr4aiN8E5adLg/ezt0fEBA=; b=DEzT3suxZCUbDnVqLfL/tpFysn0jmChr3kEyOaZZW/TNlMPper7iNxdMh3bUQERXtQAH VTKZbN6m49vjOXaLliJJXks3nFkNPALVgOoqCd4/u86O0hLoNghFvzG3KujJVcImOPsG yQwvQD3HFFI7EVqgkJi5VwifngCQx92gDY/IbGi7q1ew6jliMByQXAWLGYNEzLnxfM4e 6Ex4T9Fd+Z1XBQ2tBFK7Bzu0QyUL/3YeZpdo0I4VBqJA30/lODggPG3vdrnM8eS6Y0xV O1H5Rz/HJ0raS1XThe5t4B/0vW7w6PvAhDJZA4T/cX/nzPg/KVNrAELNmqpQk5PMiDYM wQ== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2047.outbound.protection.outlook.com [104.47.110.47]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3mnqamshtg-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Dec 2022 07:23:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CqcuhPbisUuxu6gOARXnZNeeen38WbR2bDXdU3NCy9uJaAXlK/Olxqf4IgNARaTWUa9h/1MDjVpy0sE6XVzBAZDCmQfMa/hU78XClUG3qTd0gfawSRZBQowgnYae1G65MPdW+MbQ+SwYPdgroVk4nm1fiCRae13BckHYiSrLsuS+2bcJ2Io4My6I80k+Qh40jLypEpfmk7It9B0Kd2p6YH2vDSX9+qQtWF9WBHlU2Upi02Uh4qcc8WIAs1HvPRZvVqKYDtsyLiEChQqn3GOSwNkdiEStWNQK4VhqBPR9cIObF/mAIbCKXJRPT+YH8rLByKmFAG7EW8EP7dLzgm7oqA== 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=RvyFy5C6LSmgcCIopRwjCxr4aiN8E5adLg/ezt0fEBA=; b=oOgmiwESMdevL3J3EI8h5rmVeZXYtq+aK2BCZy0P3IXoXVkT5IpnjbviiOxgLoH3dS5ij/MIIr8xyEKYe6f/hFC3Qq8PZ5emXQEfwMb5R8S04shF2YqbQYYcesAiQu0EtacnB7zV6COyBvWEYd9Bc9Mrr/kdovUqHYoDeodGh1T5gAPk7hwhqLXvfytykXSoG9VUKWxDtC5h84M0AgTXO9fN1+l5++TTLrinG5Dxr75+ftin5wRfcFMVkj51elkA4mJHCZsRNWRDZOtnHs+DX8MFUIxFSHzqWt4tVIP6PVfXzHjRhNiF4MHu/20X4IbYNbYyy++pEJu2Zr7zgnREVw== 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 SI2PR04MB4377.apcprd04.prod.outlook.com (2603:1096:4:e9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5966.15; Mon, 26 Dec 2022 07:23:32 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::1cb5:18cc:712d:1f13]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::1cb5:18cc:712d:1f13%7]) with mapi id 15.20.5944.006; Mon, 26 Dec 2022 07:23:32 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Andy.Wu@sony.com" , "Wataru.Aoyama@sony.com" , Wang Yugui Subject: [PATCH v1] exfat: fix unexpected EOF while reading dir Thread-Topic: [PATCH v1] exfat: fix unexpected EOF while reading dir Thread-Index: AdkY9qoUZeiX3wO0RPWa4GhJfGVdag== Date: Mon, 26 Dec 2022 07:23:32 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|SI2PR04MB4377:EE_ x-ms-office365-filtering-correlation-id: 693854c4-1bc0-4546-eff8-08dae71217e6 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qd52EjVcp1Tq+aM3AdZneWwcrz+/b3EC9DBfkUFTG0tIFh7OI1dnDHfJ9Llx2AuNA1X8S/PIhsnoYwUwpXiP5+BB8wFNt8b6LCKyjoHGzYoEYXkeJACdQ8f78R1zZ6Pw8L5TJfVHU793rvJ7B+Kct+9UR5Kvdwrnuezun1kiAL2Y1dqVGUAINlj+COJwSsuNDqHOyU1wdbp9rna2bgQK9s3cC0qPV0v9UqgtzcCnwzjzFYwk9Cu2o14WNN7IjY++UzQxW9Qvy3NShT2fDsTD7YlmoUrV2ttmjnM1H75SDp4yP4HlI3sHSMaBgkIwsPEzHE1NWx90q+1cLcRL0oLVyr0JxlKwqQ80C6y1RlDG4cU81nRQT344xYHI5j0Hx0f1PPTocRSDTnguWy/G6LkL6wjGu8lclntWgGhz6GGgHQT2Bl686v0FGsUyW+NWzfsJFyI3vWoaXJ0z88SSu/qoXmso793QfNnsDwkB1bgxEZTpVpJv9ZfXiffyKF7JmozRfvTYibnYzXYFHdaiIV0BimAFl/7/4chlCDHwlPAARoxFP9kuc9ACFCQ3jaIfkF2+HHV4iSLAAk7sKX4x6R5DIW88BL+WzM9rxS26Wef9A5bSRUnYTsbYu6vPv1MYi6Em7ZKPVV0V/VRvlSH28Q8ywY03XRVoGlKkD/YrtUPr+JiaFI4tAvMbd3azsmuD9YTDp4+BtwyNXlw0D9ebwztl8A== 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:(13230022)(4636009)(39860400002)(346002)(366004)(396003)(376002)(136003)(451199015)(54906003)(110136005)(83380400001)(2906002)(33656002)(7696005)(316002)(38070700005)(478600001)(82960400001)(186003)(122000001)(38100700002)(9686003)(6506007)(26005)(71200400001)(55016003)(86362001)(66946007)(66556008)(66476007)(52536014)(76116006)(41300700001)(4326008)(8676002)(8936002)(66446008)(5660300002)(64756008);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?hssRU3w8rGhNhfqpaQh63zriNVxK?= =?utf-8?q?5EOaqNeyp6hJiE/7RbGj16y+6y91VQChmFzH6Ioa/vmDQ5Vk8v9mXJ14KZzBRMVfT?= =?utf-8?q?NCg5YXKCPZW44XJvn4QyzVmEjoJSgqICN+zDSVaLcnV6UjUIW7UFGWTYD4YntciMq?= =?utf-8?q?27MCwZGlHCQrzyK+SeXQFkd8Latjfjo+tnj2y6Kc11eKf3Folt2BIqYH1Xt0lzcd8?= =?utf-8?q?M4Miwi3uTShY6wANQBWlnp001hCzj1psqEfzHhrFbzU+OIdsiPULqAuiYsjF+THKG?= =?utf-8?q?ldAkGOqppqaqrZ7Fdn30lb3ILQ2ulTuEzOqpk3bkSJXMUAYJe/tYX0tG6ziBNxRGC?= =?utf-8?q?OdIt8qNmuW4IylGYU3lxFyEp4OyT/5/0MARkiwmdR6g/eGV/7Xo1Ssx3hpI8pX/Qn?= =?utf-8?q?gUPj9qrsqa3nJPk3fwt3cd06o3BZcDVTMKBSDbfTLFdJqRhLFYXE3OPykSPL50+mH?= =?utf-8?q?q1Ub0n7E79ihKEgGtV4IvzEBHbrbZEUCRDOQfBlUmIhOECM84voSlZt3ZErLMGGfD?= =?utf-8?q?MchY97POXFrPmIv84y/kYrMa6epYKOUl0O88R+2Ct3bxn69T+dLG6Pysrs9vhYHPo?= =?utf-8?q?3B1vg5uXVYvGS3djsBKC4W+gNKDrUwq8YjcMVB/yLUZERGmdZzuQgp8UrBLTq9Ab5?= =?utf-8?q?AeisAB+cj6rTCJJpt6B+t37EozhInBYg/dGFRMzPWofDiowfTZ1f731LP46H3Yv4B?= =?utf-8?q?QgZi34T98FzbclxdYduPq3ZQedbbdW4lUP9LMj5eCTOaJKwgM2C8q6WYlzuymSxED?= =?utf-8?q?aCftZqNTf72cbZnSvozmP1/P9Po79xF5ePEO3r/62qiNZ6bfUw7oY1yKzSzh1NinK?= =?utf-8?q?Nm7LdZjpjYDQ+Cat+PnqrNtb1p9fqRVRbQfNapYoDKe5ECSCvqVTyWwhVupdwulDW?= =?utf-8?q?YVrlpqSo8PTkni89M/utHxFBjy3Yu/N3kTYtJUijlPyo0vZWCB9foT/PSD4zcyANF?= =?utf-8?q?pElIzpAsfBDwBsfoVuHrxnThjjR/zQq2whalBmv9dNxJeYJw4mlFYTjzOaCaTxApl?= =?utf-8?q?BaoHpCY/fyV/autENmtvV65iyWqQ8veolo360wOmuT0AjXHlB007/hBG8x9p84VsU?= =?utf-8?q?+2ipWLj8PIlfV4IIsf1c1l23XU6vixnisEeWfFA7hG9APpVBgw8sEKyIfqCSMr9eP?= =?utf-8?q?BsXawdnJjs3z0pbIBUD40BKXsQM4LaM4fCmqyEiI2Iw3xHBG2bcQJO0W/Do/DQ7P7?= =?utf-8?q?f/BnDcRR1/NiRR/LgnLqIMkeBD3kz+A+DP+Gq7BhBP6ksqAzXOtKStxYFmCy+A5/0?= =?utf-8?q?TTFpdIqumTdDQF/AyJNqnUlmpntlmsjeIxktKhiLzKj7SBThJgio1qkXSNJvd6G0a?= =?utf-8?q?KI6vHAyJ/Lhr4O2Erfbd/Lk8kBA6rKM+3/4z+3uNE1pgZhCMXpRpIXKYOSJvoqXll?= =?utf-8?q?CxvUBNFj151/6G9xAGhmEMuRuRpzwjEdENyzydz62701itQ4QCaYV8G82o6K54EZ+?= =?utf-8?q?7fRmxuvM5+WOrTa5FfaZlXLiUDclOCFUQjyapIYwkzOMYmV/pH42zajLJ5tBNCdtZ?= =?utf-8?q?KqPLhvQ/+W+K?= MIME-Version: 1.0 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: 693854c4-1bc0-4546-eff8-08dae71217e6 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Dec 2022 07:23:32.2472 (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: r75UAqsawrzWJgL0R/OD7tlrY5sHwUjxtK2BrXosNEqmvKYLJZa6DtsMeSFVsv0f7mJjfphWNFDbXtTizBkLPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR04MB4377 X-Proofpoint-GUID: OvK5HbQz0Lx4Acrqa7hb9ujoEudPMUDE X-Proofpoint-ORIG-GUID: OvK5HbQz0Lx4Acrqa7hb9ujoEudPMUDE X-Sony-Outbound-GUID: OvK5HbQz0Lx4Acrqa7hb9ujoEudPMUDE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-26_04,2022-12-23_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org If the position is not aligned with the dentry size, the return value of readdir() will be NULL and errno is 0, which means the end of the directory stream is reached. If the position is aligned with dentry size, but there is no file or directory at the position, exfat_readdir() will continue to get dentry from the next dentry. So the dentry gotten by readdir() may not be at the position. After this commit, if the position is not aligned with the dentry size, round the position up to the dentry size and continue to get the dentry. Fixes: ca06197382bd ("exfat: add directory operations") Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru Reported-by: Wang Yugui Reviewed-by: Sungjong Seo --- fs/exfat/dir.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 1dfa67f307f1..1122bee3b634 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -234,10 +234,7 @@ static int exfat_iterate(struct file *file, struct dir_context *ctx) fake_offset = 1; } - if (cpos & (DENTRY_SIZE - 1)) { - err = -ENOENT; - goto unlock; - } + cpos = round_up(cpos, DENTRY_SIZE); /* name buffer should be allocated before use */ err = exfat_alloc_namebuf(nb);