From patchwork Wed Jan 24 05:00:37 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: 13528536 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 AE67EC131 for ; Wed, 24 Jan 2024 05:01:02 +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=1706072469; cv=fail; b=IuB6JGXkii1okDlHx5UlBzgqxld/T1W1lhJlphojX0kehOUpSHCUEt6qFnoq+mqiWj7p8vgeOWFE8vx1t2DWbKioi0hZug3DIYfdIIFLrrv/nsiSWKr3iQ/iWJ2D62fAe73R+yOIi7Zo4ifAvro2om/hcORcMoIe0CoyN3trfeQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706072469; c=relaxed/simple; bh=f37UhxOmVG2lDTUmYkxAzz7jKT9kBeZazb2JJK7MsGw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=VeSgtM6GsL1RxsoD7qqRwOZP5Y1QK36HxeH/8TZ3WWPK3ldRWreXU/DzPTIswbygxLSIlxIBfPHRIbmoSeIFD/FtFPeUnO3jqGezF3MUIGxRw1GmAFuxFI/bl6NgFuQdNJV738SG/EBhIE1kOcFzSyooAqtUTrfRC62lKyHA6qI= 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=V65D5pMz; 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="V65D5pMz" Received: from pps.filterd (m0209325.ppops.net [127.0.0.1]) by mx08-001d1705.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40O4kJD5021607; Wed, 24 Jan 2024 05:00:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=S1; bh=sueIqtg6Edif6AzoNh8PLyWElLyuCzHkhAxkATRD83g=; b=V65D5pMzRw7H45HKLPnvRbE8ulsTNzerqbYFidwIURtBnemW2R8a8S3FdFQGdX0KHPwa VVJvpne+2gS1ySjBCxCs6eAOfJJ9FC2kCDA3Wb7wgRjUWoZcK6U+RE78L/TGXELtldLi SNpwI84mSG2vAuXesybXIjVeiMIT3fkU19buxAVq2MyHKxV6ulpmYIi3nPz9MUvQrxv0 QbLlKZCAE1qm8Zh+gP9CSwcqUQZF9GlFTjRbjqe2ZYXzU53D4Jj8yc5yuTdEofYWwn7Q E3YeytouUKbpBS7Vn2EaFr0poLJJ2Ft+B0OHHstGFft/wVFgEhIfklOAKqryQAU6AsQy sg== Received: from apc01-tyz-obe.outbound.protection.outlook.com (mail-tyzapc01lp2041.outbound.protection.outlook.com [104.47.110.41]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 3vr7fb4057-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2024 05:00:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QaphUYBFxYpzyQAtRBp8WExNhzDHjywXHynjEadakl1MA177BvOlcUl/h9IZDwCMaMh2Bf24eeOiiR9EXR436ds/NCnv2mKBNNLkvFQw9P/GsKYsHtb8u0AliP11YCgvMzSVSnnTr+8WcLBqGmnfYIZ0V3kciL2Hyi+nGFXBGfKx6DAQqxP3Ezo7rQSsZ+1AoS9lMnEZOCjVnqm0gc96WP7W6rIg6+NhszrYxpuH//UsnafKeRDb4cIO/RmmLWM/mcoRgv9Edi9vwGDMrBObrLAejYYinQXBM0iJUqDXs9YqqXZKujjik3R+uXrMziRhzf1R/vMnWZ76flchDawRNw== 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=sueIqtg6Edif6AzoNh8PLyWElLyuCzHkhAxkATRD83g=; b=aixXZoY7OkYRNSGr6UySSpzNRI4bdMczT+6PIRclSjodutihacI34FWI4qN2Ovns8u3xQ3Ri5lcHSS/b6n7HlRY7RTKEKxAHRxkwubEgOCka6TkiGNd0ZmcTFExuir95ZaV2lYrQuwLD7qWxXhGc3HlUDwiDKctxf1dRtHWg/V53DQa/yuzNQFLqWVfv81FZjqOkbj5Y4ibX80gfdKdS60O1sa91sm46UT+ocFUvqkb5YPtsdO9kouNXnzi8QcjGDozVRipg0zci2LZAk4Qvciz+rqjdEz4H05ayb2H1EsB7wdKA0qilUE3b1JTzG6ZpMIvxcyuqBPC2LdTWhH+U2Q== 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 OS8PR04MB8424.apcprd04.prod.outlook.com (2603:1096:604:2b1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.22; Wed, 24 Jan 2024 05:00:37 +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.7202.035; Wed, 24 Jan 2024 05:00:37 +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] exfat: fix file not locking when writing zeros in exfat_file_mmap() Thread-Topic: [PATCH] exfat: fix file not locking when writing zeros in exfat_file_mmap() Thread-Index: AdpN3FSy7vLvoUe1T5GfQPH9ulVGdwApZEFg Date: Wed, 24 Jan 2024 05:00:37 +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_|OS8PR04MB8424:EE_ x-ms-office365-filtering-correlation-id: 5e42e131-8868-4f2f-7814-08dc1c99676d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 52pR1cL09A2IWn5pB0sJCoQd5g3E6thrxUwCK2HW5R0cMAw9El+LEqFo7WuXTJzMa77t0Ov3tbgEEcfvL+5F9SNttcZFC10o3HhXVadrIu3WPmX5wbXkgBZPnARExqCHwxMgC+aGTRxTNdejunkn7Me0f7ctEEUZovwyb/ZoNyOvFvWdN+dmHZ9nvwUueGVgKdYQ6Tm33QlCpaVOXgi94Dp9oSghjQiTEojVPpjGcFdSFCG3LsjebF3A2YVXAGiiKirH/OyCo1fq+HdCERd5k4u/d7GBz/eSeBJJknbcoFGE6XIk1vfRSvg6jtz79+FbSpuotnDGVbcjRR4zFH/qgQe+cPFFyxpuYYvzUfUqmj/kYRzCTiw8dkkzWRV1w2Dck8Iwy30cgVhAOYDxH1aOKw3DysQwvu2k8MquiGXz7PkOU6v5qS4CfiY5fKPClMM8DoA9vf6gRNhZp8efyhfeAySKqEnM7UuZ3F6p6DETeFNwb8WLGBxjiixJuEPxehaOw+gvygxi8Myx28cZybhAnot6offVYpUPUMIPlBcg0EYveRoiyFmLxb/gZTalUBAvWhHqrgpHOIgLUODTKMcX2h57qkxldPTgx7f9S3AhVtgCdXQPKYYK3OLyc/OVBE9n 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)(136003)(39860400002)(376002)(346002)(396003)(366004)(230922051799003)(64100799003)(451199024)(186009)(1800799012)(33656002)(99936003)(4744005)(86362001)(2906002)(38070700009)(66476007)(64756008)(83380400001)(41300700001)(82960400001)(316002)(66556008)(76116006)(54906003)(110136005)(66446008)(66946007)(71200400001)(107886003)(7696005)(6506007)(26005)(55016003)(38100700002)(9686003)(122000001)(478600001)(52536014)(5660300002)(8936002)(8676002)(4326008);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?voZKAdCUjVfXVi2RBwk09qjt9vDk?= =?utf-8?q?ILj7Lla77VCXq7SSosN+Da+ro0Ef6HIzAFtaTqNbpyV/WJ/u2deTicyxZRS1o7guN?= =?utf-8?q?8gDpKuUyChaZ9ev5+8whoH/ZOQejXo51/SEovc4Td8FWvj8PxUbAMmqaoDT42tKpf?= =?utf-8?q?tT4iPca4roiOdIB9xC9wLxDjWRi+7vT2LPj2zDUbr47RMi5IOdZRCVmjagagUhWy4?= =?utf-8?q?QC3SZA4X7anAbfbj5R47VzsCt5jEyhVCnZvWYMY+cs1HJOyPuzVatl4Mki/624UBN?= =?utf-8?q?kkoG2balEqCz24nLltKX4BthVlWvGqHptDVghnvr+IRyRjpNVjecI3tgmV6UN6HPr?= =?utf-8?q?pUpWRbvr2Jz18vr/k31XwMBBHbudgZI2mzDqpRXro7Bcc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wP+o9yBA10t86FvdBwJ?= =?utf-8?q?QTme7LFrUDYzfcwuUWEtBuT6hKqcFSQqdntqZhdsCcTHrqjzkqqhmUzseE46npfsV?= =?utf-8?q?dyhRy9LHKB75BHZN9b+Jy9D7gRGeWTuJwdbhBUGWIqwPfnXgWR7DbMv7VmYqXyOyC?= =?utf-8?q?YF8yu7SW+2uSix8fw9f274cO5SqdKX91nLUpfiTyaD/idUJsoNlKTRnuLYn+ioqng?= =?utf-8?q?K4nqB0FPdGuHlo/TVV/Wa13JeBdc3JR59Z7QU/TmcvwHVvd301PZF+/DtdN2+JQjV?= =?utf-8?q?ubpz7st2I1W6?= 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: msch/QTkZXb6xmdtJheAyoTkwHteXu8fPQJ5PZKWy8DdwDZ68StF/Ng1h/oFbo6wmCz3KH3MUTgdOekFY7BfE5ac1T6nAVdNEly7/z8f5lEHWp8TbIhTkl96mSgCjEdj4kl76UshRHH16PcUq2N+h6GmCKGhtCOVRU5Bf9Ldf85/j6pktCWerGv6PxRaxDWVmwbwQdCIENzqYL+iQrYrgouCReUN4Mb/E75L7NDrJiuU2rEfiaOEYroNue/9sHrFxqYlckD50WJQLxukw4N0T2/UKOWxIX+6BCkS8185iY0H9vARUUHsSTo7AZl4WM0y7vBeP1MV9qolAWosPKuGk+fonarHLdL6+dtFySDNryKgAT/045jYIjyZgPaYrBYpvHZaQrz5TUo3YqZ8YaQeqrc8hpaHaVA5wYrE+IfwcbNemq2nxLDapc448jM9gQK0pGVrWJScoiVJ9ifmcS2rP2T/YxfObg1LARwukPzW2vRCAQHs6phZs0ScWWGhIwtzuLDRI+F60fbAD6kKCWZ7tEpgDi4xk9vKRXZSoJ25bjjW4RO2OluWMJCT9eISIGDsNT8LVsb00k2usFzc5w892NNpv+Yr9Z8disbU56mjZfyI8ogJxvg/8WYgy6j1kZ3+ 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: 5e42e131-8868-4f2f-7814-08dc1c99676d X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2024 05:00:37.0474 (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: YuXheOv6iaii8yZTPoXri3McnZoLQRPL/ExxPum33fUpzn4ussiZAtWlap9FNeWXkdQ7e/3wEJ93gm81etzo8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS8PR04MB8424 X-Proofpoint-GUID: 1vz9Y3MM11a-6uiDvXGrZK7oeoAM-A9U X-Proofpoint-ORIG-GUID: 1vz9Y3MM11a-6uiDvXGrZK7oeoAM-A9U X-Sony-Outbound-GUID: 1vz9Y3MM11a-6uiDvXGrZK7oeoAM-A9U X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-24_02,2024-01-23_02,2023-05-22_02 inode->i_rwsem should be locked when writing file. But the lock is missing when writing zeros to the file in exfat_file_mmap(). Fixes: 11a347fb6cef ("exfat: change to get file size from DataLength") Signed-off-by: Yuezhang Mo --- fs/exfat/file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/exfat/file.c b/fs/exfat/file.c index d25a96a148af..473c1641d50d 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -613,7 +613,11 @@ static int exfat_file_mmap(struct file *file, struct vm_area_struct *vma) start + vma->vm_end - vma->vm_start); if ((vma->vm_flags & VM_WRITE) && ei->valid_size < end) { + if (!inode_trylock(inode)) + return -EAGAIN; + ret = exfat_file_zeroed_range(file, ei->valid_size, end); + inode_unlock(inode); if (ret < 0) { exfat_err(inode->i_sb, "mmap: fail to zero from %llu to %llu(%d)",