From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F27BC61DA4 for ; Thu, 2 Feb 2023 23:09:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73E7C6B0071; Thu, 2 Feb 2023 18:09:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EEA66B0073; Thu, 2 Feb 2023 18:09:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B6A46B0074; Thu, 2 Feb 2023 18:09:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 487066B0071 for ; Thu, 2 Feb 2023 18:09:05 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1322A41042 for ; Thu, 2 Feb 2023 23:09:05 +0000 (UTC) X-FDA: 80423894250.25.73F03B1 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf12.hostedemail.com (Postfix) with ESMTP id 2DCD040025 for ; Thu, 2 Feb 2023 23:09:02 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=dilger-ca.20210112.gappssmtp.com header.s=20210112 header.b="tiXwB/YF"; spf=pass (imf12.hostedemail.com: domain of adilger@dilger.ca designates 209.85.214.177 as permitted sender) smtp.mailfrom=adilger@dilger.ca; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675379343; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VqUjNnlLe9QrrnNqYH4vz9I08V1g+NAtbBxDawrBf84=; b=WeD+1yicHAcz5ASiDsjNUbnojt5fVc7REfXBp9PALG7f8yK/KvvYfdWIDg0s/adztYVXY5 qOmaeqSG8HeXxqbOCUFeT0G9RbSvuJS2lUBl0BhiAWCyhQ/Ouo2t8wFMMAjvVK0+q2ort2 iw3C5dZwGDLu4BEkMdSDcNqI7kkcMJw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=dilger-ca.20210112.gappssmtp.com header.s=20210112 header.b="tiXwB/YF"; spf=pass (imf12.hostedemail.com: domain of adilger@dilger.ca designates 209.85.214.177 as permitted sender) smtp.mailfrom=adilger@dilger.ca; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675379343; a=rsa-sha256; cv=none; b=SPQFSxyB5UqHZn0+PrGJyW74c/NFWDpFex0PG/TiarVQUonJE9SAiKNaOqxe0sdk35pFNe IgCvmYSD+ROUFfgfEo02KllDh2PRY4CWVguJuFzsokUWDV8jbsnFzlcMKpv3b81GL3D876 6nAAzrDTUikYTu4o8sSW73C9BqWJENU= Received: by mail-pl1-f177.google.com with SMTP id r8so3511605pls.2 for ; Thu, 02 Feb 2023 15:09:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dilger-ca.20210112.gappssmtp.com; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=VqUjNnlLe9QrrnNqYH4vz9I08V1g+NAtbBxDawrBf84=; b=tiXwB/YFL3/UVZmPjd1ZEHaio2kX0wKkQg/TK4XDyG5MggLDGQDJfWKEahDjvcVnDG 6olYuokRsSvkdJTx6NLxKE1iynQEBqIsubNzoIAZ81PLPSyV8X6yyr5yf3t+HAgsR9TU AkeudAKrJPQJfqwzuJGdQqCsR3q6FfySNI5pTmzmZFWjadchc/wgnWagVWIb7KKRU9yP amAQDGUyxDWKtYtYMMneMgVNvubuRf7HPQiN6fejbHo63bkHRKG9WFiiWUaHTiqv9lMF In7o7qTQiJGykaRwM0RWpUxVPpcJTQ8wFN83IMVfu7hdpzyHzadr6ilm+dGarBCmTPsQ Mh/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VqUjNnlLe9QrrnNqYH4vz9I08V1g+NAtbBxDawrBf84=; b=bD78rzJlLQc9k7UyRZlMPhhQGU4nqe93IZbGX1boA+nGQCr/vWcFRul48Kto2upQzD d6c8tgBdxmwmHO6xLlcwxlxFb9haDVm1KVBFd88M9VceBDOiEuzXZx6ATTpR00Bn9J1v rLvGPS6AAHjzNKCkHvUP8f+ZPEw5mlaxn+nsmgywVPWeWGPprBEYHIe/f3+6XstOKJ80 R2xXBUbHUna03WhUPEGgrB9hldT+mUeEbym7OlUTmObh3+2Nx84l5rCVd9VHnCMrfGio PmXYvF7P+R8ZSWT6DMBs85MZYRaWPIG6oN8miq/ujiNtFwsc1ba4G341A0N5+XzHLMQu YYsg== X-Gm-Message-State: AO0yUKUjNAfDB3R5ar7kE8fM9UkBq6SqXmDlSbfCAvrVhC0BNlAL14oT udMbLHTpFvVa90oC3iID7gC7bQ== X-Google-Smtp-Source: AK7set945rckBnElMZ3rf+zcsuttJnQ5VSAsDV2YHSLk1UFGwfYjX3yosnFoI7MQkt1MREnq7QE/VA== X-Received: by 2002:a05:6a21:1586:b0:bd:b061:9527 with SMTP id nr6-20020a056a21158600b000bdb0619527mr7590449pzb.4.1675379341884; Thu, 02 Feb 2023 15:09:01 -0800 (PST) Received: from cabot.adilger.int (S01061cabc081bf83.cg.shawcable.net. [70.77.221.9]) by smtp.gmail.com with ESMTPSA id o6-20020a637306000000b004d346876d37sm300348pgc.45.2023.02.02.15.09.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Feb 2023 15:09:01 -0800 (PST) From: Andreas Dilger Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_8DFD1D9F-16F3-4D17-914C-8298AD90A8D5"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH 0/5] Fix a minor POSIX conformance problem Date: Thu, 2 Feb 2023 16:08:49 -0700 In-Reply-To: <20230202204428.3267832-1-willy@infradead.org> Cc: linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, Hugh Dickins , linux-kernel@vger.kernel.org, fstests@vger.kernel.org To: "Matthew Wilcox (Oracle)" References: <20230202204428.3267832-1-willy@infradead.org> X-Mailer: Apple Mail (2.3273) X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: q1gkzm5h19rhrzm3sf6ipp97bfm3eu9y X-Rspamd-Queue-Id: 2DCD040025 X-HE-Tag: 1675379342-777464 X-HE-Meta: U2FsdGVkX1+Btq0QDZVEU4YerY38yPcU3vXuj6K4hAQGkEzxw5jsXT9YuoPcBU/rAx9c6Kt+imiWIIT0EjdFCkloW36+qICZxJtU+OvLUlEQWyVC98zIH5kbxoVOPTsuvU5NmbgKtqCX791LXdGp8cIHJ08sGIaSYXWtnVL/9IVDRcflvDCRpJhHGER5seiDnMxycOluFg3W/gbBDNxsAeujoa3tw+VMMg4CnLMTJqqUGeigbK2dqx6xgvalmQPKjmfgePzvQLlobXHV+M6WCt+aGuYmQjvqciaN5wHCajGh9YaXnwn5wjPrCPeJ4rpB86DOeziFNGb5km8XY6amyJpkf8kpKSKn0ZJYt7yp6gCmHob5hZfpg5wIGIViZP0g/fS/cdRyu9HXIb/2M4O1sJ9iwPEGYbwxDnrJBBZAeEm7kZI8anW7oIChWdGPYP2hyZQeO4et+6K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7nhjXAVHu7lDejXR2BXb1GyLQINoMXZ4eIaGtYCH199jXMBf74Z2AOENEs8A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --Apple-Mail=_8DFD1D9F-16F3-4D17-914C-8298AD90A8D5 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Feb 2, 2023, at 1:44 PM, Matthew Wilcox (Oracle) = wrote: >=20 > POSIX requires that on ftruncate() expansion, the new bytes must read > as zeroes. If someone's mmap()ed the file and stored past EOF, for > most filesystems the bytes in that page will be not-zero. It's a > pretty minor violation; someone could race you and write to the file > between the ftruncate() call and you reading from it, but it's a bit > of a QOI violation. Is it possible to have mmap return SIGBUS for the writes beyond EOF? On the one hand, that might indicate incorrect behavior of the = application, and on the other hand, it seems possible that the application doesn't know it is writing beyond EOF and expects that data to be read back OK? What happens if it is writing beyond EOF, but the block hasn't even been allocated because PAGE_SIZE > blocksize? IMHO, this seems better to stop the root of the problem (mmap() allowing bad writes), rather than trying to fix it after the fact. Cheers, Andreas > I've tested xfs (passes before & after), ext4 and tmpfs (both fail > before, pass after). Testing from other FS developers appreciated. > fstest to follow; not sure how to persuade git-send-email to work on > multiple repositories >=20 > Matthew Wilcox (Oracle) (5): > truncate: Zero bytes after 'oldsize' if we're expanding the file > ext4: Zero bytes after 'oldsize' if we're expanding the file > tmpfs: Zero bytes after 'oldsize' if we're expanding the file > afs: Zero bytes after 'oldsize' if we're expanding the file > btrfs: Zero bytes after 'oldsize' if we're expanding the file >=20 > fs/afs/inode.c | 2 ++ > fs/btrfs/inode.c | 1 + > fs/ext4/inode.c | 1 + > mm/shmem.c | 2 ++ > mm/truncate.c | 7 +++++-- > 5 files changed, 11 insertions(+), 2 deletions(-) >=20 > -- > 2.35.1 >=20 Cheers, Andreas --Apple-Mail=_8DFD1D9F-16F3-4D17-914C-8298AD90A8D5 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQIzBAEBCAAdFiEEDb73u6ZejP5ZMprvcqXauRfMH+AFAmPcQoIACgkQcqXauRfM H+CNdBAAhriBgXO1g+TzG5HbJSljgcpvSaRMy+yNpMbCc6Fp/C3J3xQPJReOJDee 5YOaqYEwU2ap/xwIjl+OtXpEy/zq8qwO9LCofufBtMH4akhS26i8lfWoXzeo8MzH +ibRkNMk7vamH8PT46gwMLNldqk5pt7Dxwu/XarWsDg98JxZVQvvmPJIcXtgsETA GLFrhm+SudzQVCeBGJS0I4ZU4eDNpJxiExlCpkR04wgHE3GvvQT2ehVjcQXasqwg z2u9r0VwflncAmvkgIpylxOXmSX44jwpnahJwk3dAP/DmdYRf3kQVooglndm5sAF aAj6kT/mVNKdg+GJSIHjnTJjCM7BFkyFxi06xKVWjSpfYvgA5PoY8egV20kHpA3i wRbxnoS3u5fxEx1KHj3HVnn7vhBnRsSC3AnZjLlTvtuqp7xKNMt5S5JnADLGZ6Ud wNrl27/8LceOvSG7E/9yOmzLUvbrzZoWSRRYIymwF/6H5g0Ki4voGImZ0l+Yn4OW sbgwcyJ1pq5Py4PgKY+iBPK61Gtk+sTOsfC3I2KWUy+7mAfQ23pfGMjY3EUNB5eC EXuEnYw1ePIXt2MSN9yPJLz5r882eLrdbkp0nD1jx85OJFFgJvlcZ0rmPyGpBrT7 ZPq3/kKDUTwYJXO4cW+EuNV1rcTu2YttzPLBWzECgMhmXpdz0vI= =TgpS -----END PGP SIGNATURE----- --Apple-Mail=_8DFD1D9F-16F3-4D17-914C-8298AD90A8D5--