Message ID | PUZPR04MB631627C059803D3D4609D1C581592@PUZPR04MB6316.apcprd04.prod.outlook.com (mailing list archive) |
---|---|
State | New |
Headers | show
Received: from mx08-001d1705.pphosted.com (mx08-001d1705.pphosted.com [185.183.30.70]) (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 7A9B91F81AF for <linux-fsdevel@vger.kernel.org>; Tue, 12 Nov 2024 04:00:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.183.30.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731384016; cv=fail; b=Rtp11CoR6DW0YFUn6fWskn2pszZpSzMGl1Y3cbA1I/wfGwElC944JdysiV/2NX6yHSxkIL241DF2vbwW2fxBfmfEoTGVcASVd8DFvSP32lYFOl1CLk90PDYLqtl9FeSS73idyaGTZukGw0RozGSAk4wompKLLs9l0fBMzloObNk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731384016; c=relaxed/simple; bh=/OirdAcR8uSFDJQdXWxYv1vrjzaLx3Yd9pKyiJVSX6A=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=gRbcecBgTev888nfnenSknAzfS+KKTZCF8eSXXcHfJEYHfyrpMLpKjhQHRtg3HMCQfxKkX9h5jT3GdsObJRCKKPzAdPf7yMLcxwLdj76x9ZKDwvCxLf0Ag+TTDwNf+oMMEKQX2HFv9TDsP2eAWjMMaT0yzLXduKbxiobtOuyCZE= 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=aREIocvM; arc=fail smtp.client-ip=185.183.30.70 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="aREIocvM" Received: from pps.filterd (m0209321.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ABNNcJq006120; Tue, 12 Nov 2024 03:59:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=S1; bh=/OirdAcR8uSFDJQdXWxYv1vrjzaLx 3Yd9pKyiJVSX6A=; b=aREIocvMH9HlDMjzMOVVeuLdZJMe+TsSXdDwhSwP7a2J7 PoX/SeQ7sNthazxMovj+k3gN8TNS64wmPCdE3Ivyz+GEvsJNKsFulwF1IxgmL7A7 G9bGncDdy9doaViQNfe0veaoc2B4ohzkO2eKx8jYjGK25IADihYFO0sc/OBsEtOs ABaGxevolnz2RH9VU97NS4KqO79u+4+vIRSLDQuJYT6jyvjLQ1juTodpR+DallGu u7xwGjgRGZgeC0Fl+mOm09BSV7wscJhv24xbX1MAi6R1XfPApCvg9DboIBqlCTkk uoeLHrR0XWPqlQqQXVRvfHZJkgR/ZODgMdotRezxw== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2042.outbound.protection.outlook.com [104.47.110.42]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 42t0jft552-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 03:59:58 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iDpnznjlelE1ONQRj8WeTKgC9xjNKsVpYvfs3Wtpg9HfddbpCNWhZ+6pshPMTB0c7SbDAjFES48sk6o67g/pgoc4JQdvGh/1XZX+bpbSCGS5o7JP2YB4D6f02J7rsarmWeCllwuADWsy3GAlCRy58e0n+uB2/lxMkbnXV2mw2ohcDyaAbAO3l2deO+4J4+2nYNZxD2dBkjumoOgiCxifNfWWoao4DG488LU533xII0pr1EZqNhNgYFXQMgjQShN+jNDMNgiGPlcc2vMMo+yLBdYHeetZ8GJVMZtUlOhvn1mTKC1KqQOrLgfFWfMSO7A2oEF5Be+SJU/26bXgwAoXcA== 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=/OirdAcR8uSFDJQdXWxYv1vrjzaLx3Yd9pKyiJVSX6A=; b=RjC7YOXsAA9si4rEWCOlT/6PwFs4KrwHmF6SwXj6KQEkIm1qCJi5LHxeg93kaMkXmxVpQI+3nhXvOaW7TZOOiLhpykeVgqcpnJEOjzlCgnennuL4Uv0WS7EJ2NqIow1OlKLbY2pGuHVKKu0lFk+6harFd4zNXRskEhasLTag5ff8LS9hhTLuBlL+njL7Bdi4NA6X3Yu9uWnutEqresq+S7Kqw3pVdQ5cCBushT8FpU9TxyabwoymucToLY6ojveYsTSIF4vfcmXwBZs0IgDzuGvyIxXM2MYoA3UxQY4RsT5DiM1gdU9t+NrkfejDCSo1mKGvSBINSJgmx0KZCSL5Lg== 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 TYZPR04MB7970.apcprd04.prod.outlook.com (2603:1096:405:ab::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Tue, 12 Nov 2024 03:59:49 +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.8137.027; Tue, 12 Nov 2024 03:59:49 +0000 From: "Yuezhang.Mo@sony.com" <Yuezhang.Mo@sony.com> To: "linkinjeon@kernel.org" <linkinjeon@kernel.org>, "sj1557.seo@samsung.com" <sj1557.seo@samsung.com> CC: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org> Subject: [PATCH v2] exfat: fix file being changed by unaligned direct write Thread-Topic: [PATCH v2] exfat: fix file being changed by unaligned direct write Thread-Index: AdsgM2W/jtVKm234R8yZ0P6GDnagywUg6Y+Q Date: Tue, 12 Nov 2024 03:59:49 +0000 Message-ID: <PUZPR04MB631627C059803D3D4609D1C581592@PUZPR04MB6316.apcprd04.prod.outlook.com> Accept-Language: en-US, zh-CN Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PUZPR04MB6316:EE_|TYZPR04MB7970:EE_ x-ms-office365-filtering-correlation-id: 31b2d81e-b6b2-4ca8-62df-08dd02ce741d 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|376014|1800799024|366016|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?5mSqIx8i1gnjQBESyFWZvbyuU3vFTPe?= =?utf-8?q?mp3/m8wTVLxBlbX2OlnYtqcW5/lDVXPPuIYiJvZjwZ0pDBC5cSDoKSqmlMHqGFG3O?= =?utf-8?q?9OiaHb3oau84r7jneeE+zAM8qLtMfFGP2bdeLIIXikl+0TpKc8tqEz2w0OV/IHVhX?= =?utf-8?q?rzaFCV9Y8E0BR2J3RSFULO+KBwlV2nTiSYmtO9f+rdpWlMMH8Qv7Z7uNj/J7yzXmN?= =?utf-8?q?XuD17WaXxmwaRAA2am8DA/ZO9fg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B/8fIhWu8+8PlKSlY0NCiDbE6DhUFj/NNy5ugEXpxuF?= =?utf-8?q?Fkeli9Csm18Js0R/K9M9GQA9Apk55ffwIFy8wTF5MMJwka1e2azbEqt0fEqVV64Aj?= =?utf-8?q?AqdGYH+bEsUiuWT54pkJMK4vCcgS5kfwDKgh9P5Y9rj6QMMcOKQRy7gR7DEv23Ev5?= =?utf-8?q?41DmvyOtAJdNRA5DbDx4fc/Pb8GF74aTO+BjLBXXrn1uqqDul1ujSfrM=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR04MB6316.apcprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?42INAIvL8ShhYP4KX/G6Q9+NqxVE?= =?utf-8?q?+B26zSwm9eRYPqSyf10ZLIMB3TjY6Jr/0mH5pSSHRUOKykst0PopZb0BFsY2xVqN/?= =?utf-8?q?VcsU6EEVCrL8QfMyAIhoCGe0Qnd6l36M0ASoNVq43ERd74IUol/mRSnyzLsAYz3z4?= =?utf-8?q?zHimWkDemp0nRKOnNuWiezZ2qV4cC4TuCHTkhf4gPLgZABes5oPuY3QIVJZ4F0lv0?= =?utf-8?q?K/s4NIDK4oBRkBVToAuJk7vNXrjCx7X0PbRrKhca5CJ29FmfSRhGE61Oc7Da2NBus?= =?utf-8?q?2O5WJrGrClY2s+nKag7ps737aVimUYAkFdnbNNzF1RMjagXYlzSpdQNT8L5FJk+pR?= =?utf-8?q?gnxZtgMVG8T0aQxVwcHYC+9Ki3DKcRQh2TkZD6+DnPE+RU0c95v7OuK2LpXV/S7hz?= =?utf-8?q?03a7B8zJ0h8khuYgCDoO+lK50lvSt9PAHNS3bAdmorgjZchonXTGcv9InRAMoczhz?= =?utf-8?q?Jp9IRL2D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o8EEJElNL1FL1+nhJC4ghwUuZTho3aed7YlbAsYY9yxWQPeOR?= =?utf-8?q?UBAYaP9Kcu3cPQmF17tmZ1M7mNCFByMlUO+HjttzfqHsQlUQijecsuvJV/qk+QxAF?= =?utf-8?q?CqEJasTlRQQDzO3322SsIkWQWgNY9nlfnmqr8zSxcPTfXQE8XD6xb6REBxj55426r?= =?utf-8?q?4nsyYAlvAfTl?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: <linux-fsdevel.vger.kernel.org> List-Subscribe: <mailto:linux-fsdevel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-fsdevel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: vczMvJvSFpoux3Vrj+cVbiWNA31kqPf+d400+xDlUu8UIRxYXvR7W54oPyOcwwHQE0pFncHxaIyTFwhd9GrVSz6s9yaNabrze8la1lDpizB7rTpu8J/AJvDG9dOXH03TsNodbhSmK8AOdpD7kQIyhTtdoiHxZGwMPIXCNoyzaGvcYT5tGvMG1LjglT/Jy+QiIVVjJ1Vwr3pOY2wAgKElwKWRRoD1hJXiTbdyQI0BQlQGTUnxP6fv2aorjwhhukxqC1cnvfUYIzSRsAwzP8i/7Myw7nAONU8RNzjJS2EktJ+mU6k9aCcUkTyU8hdlyOLAJAgf4ASfemXNyaDR6mzQPN6la1yRjybf7dy5afyLGzEHjAX+0WkfS8hUtpFkG7uiEprpooTOYfixeIVUM58okkcRJ8NkBNAF9Mi4UfTnuy7i3WzaADLKityHg6e12ny2knChFnLKf4h3xTLnFWi5y6o7WxgvWm4S8wniuiYANxbah+bU97h7y/uRwY0MEB0D2dgPn4WFYoq7uvP3J411isRhlnGw0jkdRw+nvjpqV52Xj47TjsbbzJP7NYjNlsOp98huDrYGAskg8JYT1K2Zd1rnK9AsBMe2BTVdGb0UJ7yQD968yjCo/gO1T03QDFiP 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: 31b2d81e-b6b2-4ca8-62df-08dd02ce741d X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Nov 2024 03:59:49.0574 (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: /yHgEzZgoXDGtjHF57RDViTqRyV8Ty6LMglry/A3ndjAUbjGGCz0PKk1+tHUg/Q5+g9tkPO7fIeO5zWzqP5W5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB7970 X-Proofpoint-GUID: zM5rnDw0bEj1mzGaIhvQLdqR72TLym2_ X-Proofpoint-ORIG-GUID: zM5rnDw0bEj1mzGaIhvQLdqR72TLym2_ X-Sony-Outbound-GUID: zM5rnDw0bEj1mzGaIhvQLdqR72TLym2_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-11_08,2024-11-08_01,2024-09-30_01 |
Series |
[v2] exfat: fix file being changed by unaligned direct write
|
expand
|
On Tue, Nov 12, 2024 at 1:00 PM Yuezhang.Mo@sony.com <Yuezhang.Mo@sony.com> wrote: > > Unaligned direct writes are invalid and should return an error > without making any changes, rather than extending ->valid_size > and then returning an error. Therefore, alignment checking is > required before extending ->valid_size. > > Fixes: 11a347fb6cef ("exfat: change to get file size from DataLength") > Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com> > Co-developed-by: Namjae Jeon <linkinjeon@kernel.org> > Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Applied it to #dev. Thanks!
diff --git a/fs/exfat/file.c b/fs/exfat/file.c index a25d7eb789f4..fb38769c3e39 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -584,6 +584,16 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter) if (ret < 0) goto unlock; + if (iocb->ki_flags & IOCB_DIRECT) { + unsigned long align = pos | iov_iter_alignment(iter); + + if (!IS_ALIGNED(align, i_blocksize(inode)) && + !IS_ALIGNED(align, bdev_logical_block_size(inode->i_sb->s_bdev))) { + ret = -EINVAL; + goto unlock; + } + } + if (pos > valid_size) { ret = exfat_extend_valid_size(file, pos); if (ret < 0 && ret != -ENOSPC) {