From patchwork Tue Dec 31 05:40:18 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: 13923646 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 E75421632D7 for ; Tue, 31 Dec 2024 06:17:52 +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=1735625875; cv=fail; b=UURne3EHVWccYhuZeFMB9LymDYT6jP4ksIW209552WXMQs+07fsL3Iqm06q/Q/dFdiEevf87uycxqIK8W2H8iYAiO/LNq5NZ2w66F8P2bFqkdihYqd/Dfyadehf46hTpbqhF/d/wbJ2vySFy99ONitRlQYU1QxuLnAEBsRVPaYw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735625875; c=relaxed/simple; bh=s9B2EtblJ7apzbyEWyebB2yqxp5dZbMpJuM6m4YrV4k=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=cL4gQxd5E6RdPioXa0kcpOUMwfWh4pmblo8ShjWk6Dvpg0ieK+5mcnSwQKYW3OpLJFAx9UQXhEwGmKtYKBLc1ZflfLXj17DcIz/Tvrw3BW4+lJET2klnE1jG6sxRMVbTBHipu3gq0tV4tI9NMLzTXH9jqfZFNetYObNvmf5tlbs= 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=FdIWaGn1; 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="FdIWaGn1" 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 4BV5dSBi021515; Tue, 31 Dec 2024 05:40:24 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=Jacon7mZondtT+013piln1agkm+q41UjG+EdwcN0tms=; b=FdIWaGn1t NGAdqvwPAvOIqUxcE5kklCr4vZGycHqjKQsiXc3pUzHGZGtW7XBFtJxfqWc35mqi Hz8tIXNlYE/+fNnkAc3ilTovH9ZIQ0GpVmmM3OA8kbKlMhL+nF6EDQaT7qF4bl/7 jSK7UfnS4VgT4sFI3HghCKoKMB+zENmTtjI1pr89ixPH7GHZlOAeL/t1z+cWQ3Yc yonwmhnaN0rtJcPzlre8v9EmllTfvipBSjBMVes4stg+iCoKd/1D4PXtnG5OJmYG NV4pTL07eu7EYBJA9nlYdrmYaYKOXTIP0kBOdql5BKQ2QM9QrXjIS8eV9IG5+t+X 7soKH+VH/P/PQ== Received: from apc01-psa-obe.outbound.protection.outlook.com (mail-psaapc01lp2048.outbound.protection.outlook.com [104.47.26.48]) by mx08-001d1705.pphosted.com (PPS) with ESMTPS id 43t6g320w5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Dec 2024 05:40:23 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lzh+9ZNT0tY7zJmNM/81SHoLWa4GH0ChkcPvbZz2+/k1H1xPx1h0Cr6VGBvqcVjNuzA45yt5BnhEwad9VTySNsZoNJRpRYPWWsV0R9TcUhb1EZGokLm9eFfK/joTiTZt32xDH36QF82iBrln+TNR19EDcX152f/Ivt4rXvcPsvscvZcUkDDWAGVBEUdHy3ILQtNsYkWpm3YBS/IGiFDwxdvetaDoUpVN2TBgZaTfpnpg/tSzm3Ubn+9E+y8xgF2sByzrsCVKuIxv2C7OieMeQztj6/VWcrXnP1140IWwQGMrmHjbhPuyJV/c5uvX8sWhGhCXp4wuuGyM8rbDi2ZvJw== 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=Jacon7mZondtT+013piln1agkm+q41UjG+EdwcN0tms=; b=hnsBi7MMcGH2026ea5ohSqnEyh96mkim0kb6u/X6X/c8r3L1IFJgTduQ5TPnHwgMpetbVsq6dQFVa1X7V6RwH41kpDxXyCmILj1ALkzR10k94LyrhztlKzYij5rV6ybCNTlGu+BC7QcoYGwFQVSg0YxHEtClwCV/igT9EvtvwzGEuazvmrxeDVJo+qTzjwmQ7AzgzrVvlU6FYyPED9WNFbb4RQQ1Gd3GAKZ62xz16ZZ09MbU7UGJpPQR9U+d2X7zvOI158XVdUGNUwLTq+2FZxq+P4W6kjfxCNSF1+IX1GsOoVXpEjNYYJARAcQFNFJwfaZgrSSK3JHnEltIh0luyw== 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 TYSPR04MB8128.apcprd04.prod.outlook.com (2603:1096:405:9a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.19; Tue, 31 Dec 2024 05:40:18 +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.8293.000; Tue, 31 Dec 2024 05:40:18 +0000 From: "Yuezhang.Mo@sony.com" To: "linkinjeon@kernel.org" , "sj1557.seo@samsung.com" CC: "linux-fsdevel@vger.kernel.org" Subject: [PATCH v2] exfat: fix the new buffer was not zeroed before writing Thread-Topic: [PATCH v2] exfat: fix the new buffer was not zeroed before writing Thread-Index: AQHbW0BN+ZoUCapwaE6xAGnGRVTnuw== Date: Tue, 31 Dec 2024 05:40:18 +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_|TYSPR04MB8128:EE_ x-ms-office365-filtering-correlation-id: cf2fe9c7-e54e-4eb2-7bab-08dd295d9be0 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|10070799003|366016|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?MNS6JT7HyvrWhltVPrE93+T2ZA?= =?iso-8859-1?q?dTza8mipji0aKWYNNftmtVfcQmoGpbILypgbl3t4x34uBVIdo/hMND126fbT?= =?iso-8859-1?q?FH30exyGAqJgMI25XnX48iTD7ytl5gqi+qv+lhY0WDPBXLMJzT3wMLqVhK+d?= =?iso-8859-1?q?cjc+79nXK7OKyukhgaj/7QYjwqFxteRrKe5pSB0SOJd843UGpvTDRJwd1mu8?= =?iso-8859-1?q?gmscOPi/y81ifQqGc85qkzTiACUP0GVQuOWJjIfxJI83UAHE9/SwRdDlB5ox?= =?iso-8859-1?q?UqOQ0nnV8ggZkq8B+Cfy46HU0xxsgiFVL9DzWUI59WbFpaOvUTonXqVkVjrx?= =?iso-8859-1?q?EWWr77jTI4cdIzarTtu9sJptmOjHmYLGBDdHJF6sMkQSSii3ETLkn7eElJJR?= =?iso-8859-1?q?qdx67phwhscR1bIPxgWFp7JYlegES/doOBqa+gou7+w+i51Sf2BRRqdAxTaO?= =?iso-8859-1?q?X7UQqMzmf5TOgZAXGYeZadJd5Vl0I0sO6RxAhHywJ8IvE/XIZuoORF3cHgVw?= =?iso-8859-1?q?dn0QwVMtYgh0sBAkIWSDtxtgrlkImB/lKK5J7e07hdprR6ulSS380wvy+HZ3?= =?iso-8859-1?q?hrH5lTgJHJGg4BZ/NrMtMM8taXmOlZ10f1n6wbQLRw5GSfGfjWUgr+JEmKyy?= =?iso-8859-1?q?1s42pCUiy+DSN3GOLBTcKwy2dsR56TqwZ1sG6yD6ALLx7b+J+AvqWQsxchwI?= =?iso-8859-1?q?4r/5eWCKFkautAwKOVvyXroRX8+D05wIywayj/BxZDjSNFsvvbxfNM9vwJgz?= =?iso-8859-1?q?4NrJC0E7FWECNJmVUMwWQxMrA8pifJtZAm2xKgY7zJ9t+Y65drPnGRyc2bHW?= =?iso-8859-1?q?3rg73WE2scwPWyKijk9BeDhAsHJqdHGgli3WYv/+uchBCQmCkyFinhpq/YW1?= =?iso-8859-1?q?NjrBuNDRgY/CpWWFREYWImiZ5ToahvxuigEsbFE6N2SeQH/1geiis2pV1ZJe?= =?iso-8859-1?q?IMMGKfO/+I365mqsJOlqeXMPE8Dj81wp0drBCrhnLDDhmRZeR1qQvHDWx40d?= =?iso-8859-1?q?468TL/B5kxjLdh9uTIZzxv3S8OoSI7+fbtnbIZuv7XysXgkp3YnjQ5UlHTio?= =?iso-8859-1?q?MAinRPuelDcgUeKcI0JxDCP14FWLpMjb9g1A9kG51fGmrb41okTWWRA82YRT?= =?iso-8859-1?q?oXAm/J4mT2XkKEKano46perrgk4yHkDTnJFMnggAl/xLJ2NQXaPpazumop/6?= =?iso-8859-1?q?5lwLSZEKX7JejLSTcRadX4yMsvrSmGCwn9vG4fMnQkXdikQW4BwS7wvOqq+c?= =?iso-8859-1?q?Qk26yLZeLZimv3BHxckeD7rQeEhE/I3VlNj+Amdf3TPPOXjUJk9FuhCxVZ2R?= =?iso-8859-1?q?0rWJE+uQLuvLz7jhX8Y4RmbtgiR7T/1Zhaj7i/1klAVzYTmTRJFpyl4QZFU3?= =?iso-8859-1?q?Ve+Ji02S4x8rZoanUiup5lcOQYjOiGwCctTB/a7SV5jfH25vUBpsFe5+cRJO?= =?iso-8859-1?q?q2qiRQZbT2xpmSBPCJ7QQ2zQ=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)(10070799003)(366016)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?K0NSF9Qe3R9H5+WMwvLFvsU?= =?iso-8859-1?q?QYtmRGvYtlVlSterJ8AgZwlFIIN2qurSJVOgvw4jO4LoWPq8DZJsnWvKpWUU?= =?iso-8859-1?q?B+rv8s4hU/I6PwDUScGWh0IHMqd212hHigCGJfwPedTVigndwujJik0sOtAc?= =?iso-8859-1?q?evkLvpxHQSNWd8RQfH76a6wVkmNhi4OpIR4oX5RNQe7Dn2QlAlJKUhC1kzEv?= =?iso-8859-1?q?C2BkpNpjdhtcDTsFusA1o0iSTJ+R+LxCVuiBKlVCDtEXFrIFhWtTvAPOe17m?= =?iso-8859-1?q?+NGSP/DEFvneXhl0ZLVKqRx8C43KF2Zutpb0r3kNsY8RqIDlUIJgAXjBln/W?= =?iso-8859-1?q?G7GiBLNWYVyskKA9t+Z4dHYQvw7Kpae1fygiW20Rpn5fVR5KuQ6z4w+3EXFR?= =?iso-8859-1?q?Kq3zwCS77Tgj2i2QlGiMqBrYhv+L9PfOU2hUcHlmuyeqUzqMDDchjVIKPSmT?= =?iso-8859-1?q?8bS5WOpr9tgj96q/HknAU1P+MtABNZ+2TW/b9k2dRpPX3BOXG0RrEV0NbQ5b?= =?iso-8859-1?q?cj6ATJ/hRfREp5YoyvFMnC9uJZPHYF2297Ci+0ehcFx4vUEgDEzmUs2QeBXL?= =?iso-8859-1?q?Sf1uK4itoME07d5f0EXGU3vct1hZ9Y0KOoLFcnefw5Anv7vrW23nHbctQ/R0?= =?iso-8859-1?q?oWBWm9xAOFg/MbN20fDTccp3A/UcW3eA4lCw0SGp8iM3lBI7n3IWv8/IwDwJ?= =?iso-8859-1?q?JsAjay8p4YnvPwTwsxT+ioHybeINiamfTIf6rznx1SMMW2DfLWDM1nRvoiX1?= =?iso-8859-1?q?w89VgY8/Xw3o8G68gy7idTRAHzCBm86k4U8OdHB5UNojH3vl/+Db392FE05K?= =?iso-8859-1?q?nmHnZJ1x9zxfZNq3CRFUH/Xk3IwR1R4q1mmRw8ypY6olr5iSkARDtjx6XT3V?= =?iso-8859-1?q?T9Set7jRP0r9cRV0ONCMOAeOkRTSa+rc/igU3bwjXzV5hldG0YG0bimH2a9T?= =?iso-8859-1?q?/0MCaY3dQwZbDephVFaEdrYxzbdl5JlIvch+K3R0XYJLe8+mQICp/dT6aKz+?= =?iso-8859-1?q?BGdr4xG6V0Kxv5wYx7XPOjROanf6h//DS7kggma8I4r7TiRqQJPUEjHG8T/K?= =?iso-8859-1?q?MkZxIPUFkbKkV1v2Ykac680Jp+j9EGclJvBI7cum3Obg+otpfajh0YvV+gOc?= =?iso-8859-1?q?HKaWaIMO1MB7lm+m6/7OSC//BxNrIQ7SMBsdg2ERDmvRQchMRJOotaTlVh23?= =?iso-8859-1?q?zBbGOsfOPGMU7tXTlZSn1we9TSM4C/rzucYfbykf8wKDUwIVakV+zP4qIUD4?= =?iso-8859-1?q?e1awGbROer6Jd0uY2SD2r166Emtf0QCW8QFfXySx3pB7hS1AOcwDKR8iEyFH?= =?iso-8859-1?q?5LV7y1dpnV9oD1KclKiGH+Y/ahppRlesk1VC4bkNVb8I3xNNSQUyqVdayTCF?= =?iso-8859-1?q?Uy3wEb91fGZfdMRqxBp7KDFyKsg93YlHllJk+aa0RILxqdxtMrQnRXo3tcOa?= =?iso-8859-1?q?nmmwES2CjRV2D3jG/VMZ124HitjJ3IgmYCmwtfE/VPF7QpA8PhE62d83whYs?= =?iso-8859-1?q?iHM+TxR4mIiCJmIvcXOUCQmbGRX6ZibQzJwY9DnkSNdF+swEVlK5d6pkph7Q?= =?iso-8859-1?q?RDTSLPXW1c0g3vYNLBCALCfen5Qe4BAd40gBFVC3DTxHFLEpb3nlKdoMfRN9?= =?iso-8859-1?q?AQ8401aQ0Le3Y9x0LAbiSknMu6UFS/0ULVWK//NGuwWDdAG7UvLDfzDRPpFA?= =?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: k1PpgquONr3Yj6bQRRXk59sfkqukKQCvy2CojZMylBoa8ef+YI9NPt9TEPJ24nhM/08CRTkJ2aHy5gZArGx+v0hFcwVuF9N42dhXju0TApeRks6dZJRMK3ZSHylJd6hzQMutyAUz5Gbngk6YmwjxKRmb9aD5bwcNKqtNq2S7DRKnc2aBukUGRGTtgDu3EsStd80JGljTIe4+efmuQHgA2awYapGr9HZYB9ZSCik3vAe7FeRsxDZJoO4affRb0rqaho5cOSqlGkhZryrf0imsVzVqW4QLICbZWYDTPU9fFVW+uuFwduEkQaQtUMLcq4noCqI6jeN34WTFHwysZMqJaBZV04tAMPEDpXO1XHUI2iKx6cZohWeaDY3JLcuq7byCJRiziLr67zr0shCj7oVKsuQxsNe5neE22b/ph40r3IWqtPQ33YpMT80dJJGRCpx2lZXIlUpAIMZg5gFF/3R4651Xk+q8KqgYnPggHpuXBvqRi9ayWR+UjpwqLHXCMGpIik2tjQZwyZXUWySzAo1vgMLVn/aj65wyRTtkOw/uQHh74J5q2LWZFeTQ8h9zm3i/RjiuuQX4TAEk6c2XVHwhOh3EWhxrHp79/29Kz8MAA5oZBAiIvTCfKQQ/KxoHIOjd 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: cf2fe9c7-e54e-4eb2-7bab-08dd295d9be0 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Dec 2024 05:40:18.0117 (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: sgZT7n/U+iXsXI27vLOuJmNT0mhNPOQb0ncrLnLDjVLRqwyYur9bu9CTPylr7Ni329kSKruQ9eSXtqiJwnlmVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYSPR04MB8128 X-Proofpoint-GUID: rY6GYFVgTUNhHIOTPkgGMV-prREJ8oEg X-Proofpoint-ORIG-GUID: rY6GYFVgTUNhHIOTPkgGMV-prREJ8oEg X-Sony-Outbound-GUID: rY6GYFVgTUNhHIOTPkgGMV-prREJ8oEg 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-31_02,2024-12-24_01,2024-11-22_01 Before writing, if a buffer_head marked as new, its data must be zeroed, otherwise uninitialized data in the page cache will be written. So this commit uses folio_zero_new_buffers() to zero the new buffers before ->write_end(). Fixes: 6630ea49103c ("exfat: move extend valid_size into ->page_mkwrite()") Reported-by: syzbot+91ae49e1c1a2634d20c0@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=91ae49e1c1a2634d20c0 Tested-by: syzbot+91ae49e1c1a2634d20c0@syzkaller.appspotmail.com Signed-off-by: Yuezhang Mo --- fs/exfat/file.c | 6 ++++++ 1 file changed, 6 insertions(+) From c3806c35811ce47e143f3d251ced18c481a0d808 Mon Sep 17 00:00:00 2001 From: Yuezhang Mo Date: Thu, 12 Dec 2024 16:29:23 +0800 Subject: [PATCH v2] exfat: fix the new buffer was not zeroed before writing Before writing, if a buffer_head marked as new, its data must be zeroed, otherwise uninitialized data in the page cache will be written. So this commit uses folio_zero_new_buffers() to zero the new buffers before ->write_end(). Fixes: 6630ea49103c ("exfat: move extend valid_size into ->page_mkwrite()") Reported-by: syzbot+91ae49e1c1a2634d20c0@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=91ae49e1c1a2634d20c0 Tested-by: syzbot+91ae49e1c1a2634d20c0@syzkaller.appspotmail.com Signed-off-by: Yuezhang Mo --- fs/exfat/file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/exfat/file.c b/fs/exfat/file.c index fb38769c3e39..05b51e721783 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -545,6 +545,7 @@ static int exfat_extend_valid_size(struct file *file, loff_t new_valid_size) while (pos < new_valid_size) { u32 len; struct folio *folio; + unsigned long off; len = PAGE_SIZE - (pos & (PAGE_SIZE - 1)); if (pos + len > new_valid_size) @@ -554,6 +555,9 @@ static int exfat_extend_valid_size(struct file *file, loff_t new_valid_size) if (err) goto out; + off = offset_in_folio(folio, pos); + folio_zero_new_buffers(folio, off, off + len); + err = ops->write_end(file, mapping, pos, len, len, folio, NULL); if (err < 0) goto out; @@ -563,6 +567,8 @@ static int exfat_extend_valid_size(struct file *file, loff_t new_valid_size) cond_resched(); } + return 0; + out: return err; } -- 2.43.0