From patchwork Thu Feb 2 20:44:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 1736641 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=gandalf.ozlabs.org; envelope-from=srs0=pwo0=56=vger.kernel.org=linux-ext4-owner@ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=Bh63M/0n; dkim-atps=neutral Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P79l82XSdz23hn for ; Fri, 3 Feb 2023 07:44:52 +1100 (AEDT) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4P79l826CFz4y07 for ; Fri, 3 Feb 2023 07:44:52 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4P79l8237Tz4y0L; Fri, 3 Feb 2023 07:44:52 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=Bh63M/0n; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4P79l81v7mz4y07 for ; Fri, 3 Feb 2023 07:44:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233054AbjBBUov (ORCPT ); Thu, 2 Feb 2023 15:44:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbjBBUof (ORCPT ); Thu, 2 Feb 2023 15:44:35 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6DAC76AB; Thu, 2 Feb 2023 12:44:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=74nszHLks+AFGqdfRGx6vNnWqXDqZ9xHI0qBKa9QcdI=; b=Bh63M/0nqGUZZvEkwrwA6JtjLg 6o8uQmpPAbwbDBcLTYskUV04rtjVxAbkRI8ywM/Cpg4QgkiduK6adIw3ab64Pf5IMVgLHdPjVDTBl aFg3fWxnpxmnDgfKBu03xsCHOnK4kcN7ZNcdNL6rFyRosOEDWxJ2OH3HyqGJPOB9okC+kK4RFv5JW x710OIFndtSvYOt8aghfbiSUMaoLwhFO3gM1DyXoahA8R0FHcoR780FR7VUl6VjqZywykxzxsTZsT z7NGee99rYn2z4rassj8Q+UR5edf87SIIhF/tDMjeQicVliVbhgeiEiraaTJYPSgPnMq8cG0Ud4/t ULWEZsfQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNgRb-00Di7d-Ga; Thu, 02 Feb 2023 20:44:31 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , 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 Subject: [PATCH 4/5] afs: Zero bytes after 'oldsize' if we're expanding the file Date: Thu, 2 Feb 2023 20:44:26 +0000 Message-Id: <20230202204428.3267832-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230202204428.3267832-1-willy@infradead.org> References: <20230202204428.3267832-1-willy@infradead.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org POSIX requires that "If the file size is increased, the extended area shall appear as if it were zero-filled". It is possible to use mmap to write past EOF and that data will become visible instead of zeroes. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Howells --- fs/afs/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 6d3a3dbe4928..92e2ba7625de 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -854,6 +854,8 @@ static void afs_setattr_edit_file(struct afs_operation *op) if (size < i_size) truncate_pagecache(inode, size); + else + truncate_pagecache(inode, i_size); if (size != i_size) fscache_resize_cookie(afs_vnode_cache(vp->vnode), vp->scb.status.size);