From patchwork Tue Dec 3 05:32:50 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: 13891721 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 C0FE72B9A2 for ; Tue, 3 Dec 2024 05:33:19 +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=1733204003; cv=fail; b=C22xbhhLzWJpEh/1P1XM7oA/S/cSBIFdDar7E+Ws7dHeeUIL8prv6YZgoDFdb7iBV5jSmevq1O51lTurZRwcM3yY+NrkBh0R6XYPXGcvxcy8rbnBsrYQy5+yQL2fSEeIAnfGta2zwS6BijvzlH2GDO55JtyESX7XBOrHvoVJikU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733204003; c=relaxed/simple; bh=wjownCk7ScElNcF0Kru1GtzcdIDhUfX/jnzbebMImKE=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=KxhiRVDXZ3d+4B3dS5n9tqnjYRbHYThYWl+L7Lu7eeSEnfSmDLsTllwMkkjNLLtMeqqzka2i6q9muBbQdB5rNP6Vu7xpci4lFF3QWoQwx3jYFvpeN4hatdqjOTpZOZpXH8nc57EpfqVrawE09FJ1K2LyzdhhOeIja+9tKKZU1xM= 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=D7pu6RIj; 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="D7pu6RIj" Received: from pps.filterd (m0209324.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B34BrlE029405; Tue, 3 Dec 2024 05:32:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=cc :content-type:date:from:message-id:mime-version:subject:to; s= S1; bh=k97OzVUPFkJH+YspjKJ2urUWxiOIstZ/S9PrCts1mGI=; b=D7pu6RIjr 206CEo8+0ADae6FsuKBtMGnjO8UuMhf7i1i4oUuFMXgFPHpMwNNAYv3R1U0pc1js nFvUnedG38oART2biTcgMyxqqWh7w4ofrGNfRwtY2vCGvKOXIqUh0YnRoV92wgYE 19ZPk8Q1vq0rPnqqSwaQeJM+jjgcDmYEV/YGwausCFBo6NEPBFtWpOiy1zoVNmYC usxrZzkBx0wCFJ/h2Iy4r6FiS3a1XDytOCUBOMcB3/9HS0y+pmvHLuSfhu73ggs8 Jj+ApEBBnEsKsTN0FVsYH+v9bv3bTDMlH8nBsinRx2EPw5iD8UTx8vwoHm5t4XUJ I9PiYdq4oy/VA== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2043.outbound.protection.outlook.com [104.47.26.43]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 437qv3aje0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Dec 2024 05:32:56 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WuYkUOpbHsqHKEPsfN0s0BfYwVRiK68eGWnjNi0ugABkbBCPl/XkyrNGmDA2+CqsYa96Gk0ePdAIGqTE6IWgzXt5y/Ej7qMBJ51EuQj8h/8xzwPoudYe3dI/ZCgqbTUS8+uWix0h1bocZWKL5YM8Kg/hl3ZP0svyhL9637vaeBhyzq5evfVf6EIctx5OvJwnHr/dqvlciAhz3BcTMR9Akp6/viIcMV3AOjMDScYVz89Syksj/xBm4ArRLDnYJxm8NvCUP+YyQEeeLIoYDpJFbfT9sFC70bScn0XgN36j6MqNxtNde7Mqjve9GRHbghdCKKuooMOzutKEusWQ3Th7/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=k97OzVUPFkJH+YspjKJ2urUWxiOIstZ/S9PrCts1mGI=; b=Zv/o4je5HUzsoy1eak6FgR7X51XXS4aXcbTo6jY/CX1CDM6W1ZuM59DIAb+eaxTZFG+DNJXfoTSuUF9BSf0ZmCvMhcULtj565u3BvUw+7uKgWjsiWbuw+Ql+pxSrIGVHqq8gerofD8kqkS/X4HQkRUaLWqJYphRRKIkFuT4if8Jj7ddWEhL9WHr9QjrP09vURzmNYJPpevg8UcMEMb9VPVMAHIa0hqxvywKAv956+8uqnfNofyyCB8Y9By+y50k/z+BxZ6gpBumkt20nfHxmtz3WPQoFvz+mijKNTy/6XMnRueP1gZ8iY9ZH56ifWsYa9cDTu2H6BYlfdtatisn5Ew== 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 JH0PR04MB7479.apcprd04.prod.outlook.com (2603:1096:990:6e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Tue, 3 Dec 2024 05:32:50 +0000 Received: from PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::409e:64d3:cee0:7b06]) by PUZPR04MB6316.apcprd04.prod.outlook.com ([fe80::409e:64d3:cee0:7b06%4]) with mapi id 15.20.8207.014; Tue, 3 Dec 2024 05:32:50 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" Subject: [PATCH v1] exfat: fix exfat_find_empty_entry() not returning error on failure Thread-Topic: [PATCH v1] exfat: fix exfat_find_empty_entry() not returning error on failure Thread-Index: AQHbRUQhePgXuMCkxkOuqdd6gcFPTA== Date: Tue, 3 Dec 2024 05:32:50 +0000 Message-ID: Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|JH0PR04MB7479:EE_ x-ms-office365-filtering-correlation-id: 4fd7cd84-dd2a-429a-bd2f-08dd135bed93 x-proofpoint-id: d8690225-876f-412f-87c6-a7cb45557a4c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|10070799003|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?KyF+a/Befnv4x0J1biqpgmJrao?= =?iso-8859-1?q?sHn824OWqEeP36m1nNoI4Zh5rzz1vsAFiBhcom6N+2LB95RTqTam2AzKmCmf?= =?iso-8859-1?q?A26F6nmMw6FE3UZHgdBrn1JqQfAdAE9Gngfdd2WhBS49YdAC5MYh6y3VJDcY?= =?iso-8859-1?q?oaeOo3ViOFSAniDN7Qsv8+5XijnWRzoSqg4Vbxy2DRVHrBxcLG4cK4YeZ7bP?= =?iso-8859-1?q?WibS/wZgagVCQ1DIdo9WjbqfqTXCVbW8+TUbRkn7fp6I7LGvfoeIEgZ3GUPG?= =?iso-8859-1?q?2vTjald28xfG41LDZWU1GWc8GYYTs8dIhf/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9?= =?iso-8859-1?q?iNaBkAubGthHvmSKKGrUm54gWKHWutoZkpToOCfVBrm9kcpiuIYpzpCdzm72?= =?iso-8859-1?q?nKWyD0E0/KFM48FQMV/cs7lvouplp1IlpPr/4WXkOgKSGd9KR6G2GnehJzyg?= =?iso-8859-1?q?/plfalnfdfnTNswG7BpDZpmSaI/07+bYFbl6TEI3LM4l0DkXojHxCLMVzfQe?= =?iso-8859-1?q?QDV4nMRGmKR4/kOu1GA41SuS7kPIaVlrTVnkl0Fl2a6PyNBR9IPaVlSFijQa?= =?iso-8859-1?q?KoBQbuGJCQ0O4P5EW85QIQ2g=3D=3D?= 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:(13230040)(1800799024)(376014)(366016)(10070799003)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?cvoliSgELbVbMskdANvqoNZ?= =?iso-8859-1?q?t5trDLq8/jyq06dfYhwrAKW48kQOncboED5QBLDKS3C+I7tnB0B/LE/UxSc6?= =?iso-8859-1?q?S9TAwSJJLKM0vZ3YeqtPtVHztPVfXTYKEytcryVMvQFa3sGwR4c0yoqvYZAk?= =?iso-8859-1?q?zJttJSR+2HLxM67gbwvsSeH8NJgQ28POqJhyI4k924v7xsL1axoKlFK19llz?= =?iso-8859-1?q?eE6OSqA6pY2obizqoRYBQJcpnmy/EnGXVgHzWo3qJ9u8BXmQgo0XjCxp+q0Q?= =?iso-8859-1?q?n5G8Bxq3YuyfgH8k0mWIQd9MMtL5/KTAwcauUhuZASIOTDIMOLUfZpBkSk9z?= =?iso-8859-1?q?IQ6M8OM2Ka7mDq39ET2xEdTBIRJKc4E226MwDyPEuqD+M8hoPxGlXnnQh7yb?= =?iso-8859-1?q?rrwl//P0ol1e3YIKeO/nbsU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IamjbYDnuuGmBfIlOgwdQgaF?= =?iso-8859-1?q?nUwRixLVqTCgkJeqxLdixbfqVi/Zla3VX2u8E+1jbUn1iB1zyh5ffP4cLoXR?= =?iso-8859-1?q?52EKyq9tj7x6qVEiaEBGv9jMMwY8kFjtahG5R4oZmWHPDlqBB/kKMbZIe9xL?= =?iso-8859-1?q?lDEkF3yC6xpXfYVkOIlekWQOo9uvwyu6FbMR40QWFMaUK3JTP+B5CJf6EX/9?= =?iso-8859-1?q?xG5/ZRUGu4r3WEW7w97p7w+4ZDp6foaRkgRng612Y/iR7hbiOooLAGK8+f0v?= =?iso-8859-1?q?i2DqFmcMRycgFLbyXxXdPHpVYGT3VEPBTcixS2qExq9Yaxp1fMc4RimVv9tX?= =?iso-8859-1?q?IgOTBUL4kscAfQ3dzMvCMiqtbBzOg4EIKMtoqi5VNpn7ZoyHMUE5BZwkiZyY?= =?iso-8859-1?q?=3D?= Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: wMgVlnQQ4eKUFLGZpH1YtFoUR55m19Fup9c3LFOAHcx2u8OEk1uLj4b6f3VUVA8fGclM3BNDUNq+lrX6G0la9Wa4CJi/5u2kf728Td2TJYAqapU0b4qXDOubGkDkMY29shCjEbkbqa5rPrDY8BK2c7GU9RYpigXW1AsXHQSD57tIpNpLX1iQC+Si05A8PfsdGdqIBQMV2ttc+X2tU6jtwSMTvt9ojwT8UEI6ckIjx1UAgW8mxoFzNT2/k4NRn/IfKBykrSh8yFjCsT4jqZwpIPamYm5LkEZJ9kLl5InhVeJseUPHSMhi+BFOBLWxObTqcPcAvEIewC4K2Kqsg8Bwmqs1WXK3E+tgSQ/Ocpjf7Ncv4qpPPgvtXj2ORSKGDprf9jg4SvFKG7Yu9gjGx+b4Rccs/RYWoJN/r8Kp0itjDcd7zQu5h5ta+idoiH6/ARjTg9nuNi+Xz96hLYTToML+sNPuhyO8leOkAZqrm5dkgh5gw8SpO49AbpXbEJm2BtRMKHr3sQddSd3Nq2k3a/QoW6fx2nJ9BN7TWmVpQgUrZAJgduujNPWVg/WDC04GKRoBZs1r0bTHX5aEBRGAjIrBdjlAyPoesJvPQfklp2odzrmZZzJQrwOufCbHeJfG+jiz 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: 4fd7cd84-dd2a-429a-bd2f-08dd135bed93 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Dec 2024 05:32:50.5037 (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: onVsOTn/XIBFPZ+p/BrW3qKgOtwgk1xgwkUzifcMN3CY0lwjB09HRd7RlUukch4kYO5ghBARN1YpgpvmMg1Kzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: JH0PR04MB7479 X-Proofpoint-ORIG-GUID: tpIZ3ZS7SgWoYK7_dUAf-m9cUpuZKU3A X-Proofpoint-GUID: tpIZ3ZS7SgWoYK7_dUAf-m9cUpuZKU3A X-Sony-Outbound-GUID: tpIZ3ZS7SgWoYK7_dUAf-m9cUpuZKU3A X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-02_14,2024-12-03_02,2024-11-22_01 On failure, "dentry" is the error code. If the error code indicates that there is no space, a new cluster may need to be allocated; for other errors, it should be returned directly. Only on success, "dentry" is the index of the directory entry, and it needs to be converted into the directory entry index within the cluster where it is located. Fixes: 8a3f5711ad74 ("exfat: reduce FAT chain traversal") Reported-by: syzbot+6f6c9397e0078ef60bce@syzkaller.appspotmail.com Tested-by: syzbot+6f6c9397e0078ef60bce@syzkaller.appspotmail.com Signed-off-by: Yuezhang Mo --- fs/exfat/namei.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) From 29a1dc3d2f9b59fd4392ac0ae63c942384f179a7 Mon Sep 17 00:00:00 2001 From: Yuezhang Mo Date: Mon, 2 Dec 2024 09:53:17 +0800 Subject: [PATCH v1] exfat: fix exfat_find_empty_entry() not returning error on failure On failure, "dentry" is the error code. If the error code indicates that there is no space, a new cluster may need to be allocated; for other errors, it should be returned directly. Only on success, "dentry" is the index of the directory entry, and it needs to be converted into the directory entry index within the cluster where it is located. Fixes: 8a3f5711ad74 ("exfat: reduce FAT chain traversal") Reported-by: syzbot+6f6c9397e0078ef60bce@syzkaller.appspotmail.com Tested-by: syzbot+6f6c9397e0078ef60bce@syzkaller.appspotmail.com Signed-off-by: Yuezhang Mo --- fs/exfat/namei.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index f203c53277e2..c24b62681535 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -330,8 +330,8 @@ static int exfat_find_empty_entry(struct inode *inode, while ((dentry = exfat_search_empty_slot(sb, &hint_femp, p_dir, num_entries, es)) < 0) { - if (dentry == -EIO) - break; + if (dentry != -ENOSPC) + return dentry; if (exfat_check_max_dentries(inode)) return -ENOSPC; -- 2.43.0