From owner-svn-src-all@freebsd.org Wed Apr 3 17:02:19 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8C5C1573A8F; Wed, 3 Apr 2019 17:02:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6AB1A8AE19; Wed, 3 Apr 2019 17:02:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 341F418D09; Wed, 3 Apr 2019 17:02:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x33H2Ix8056775; Wed, 3 Apr 2019 17:02:18 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x33H2IC9056774; Wed, 3 Apr 2019 17:02:18 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201904031702.x33H2IC9056774@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 3 Apr 2019 17:02:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345847 - head/sys/fs/msdosfs X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/fs/msdosfs X-SVN-Commit-Revision: 345847 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6AB1A8AE19 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2019 17:02:20 -0000 Author: kib Date: Wed Apr 3 17:02:18 2019 New Revision: 345847 URL: https://svnweb.freebsd.org/changeset/base/345847 Log: msdosfs: zero tail of the last block on truncation for VREG vnodes as well. Despite the call to vtruncbuf() from detrunc(), which results in zeroing part of the partial page after EOF, there still is a possibility to retain the stale data which is revived on file enlargement. If the filesystem block size is greater than the page size, partial block might keep other after-EOF pages wired and they get reused then. Fix it by zeroing whole part of the partial buffer after EOF, not relying on vnode_pager_setsize(). PR: 236977 Reported by: asomers Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/fs/msdosfs/msdosfs_denode.c Modified: head/sys/fs/msdosfs/msdosfs_denode.c ============================================================================== --- head/sys/fs/msdosfs/msdosfs_denode.c Wed Apr 3 13:59:35 2019 (r345846) +++ head/sys/fs/msdosfs/msdosfs_denode.c Wed Apr 3 17:02:18 2019 (r345847) @@ -405,19 +405,21 @@ detrunc(struct denode *dep, u_long length, int flags, bn = cntobn(pmp, eofentry); error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, &bp); - if (error) { - brelse(bp); + } else { + error = bread(DETOV(dep), de_cluster(pmp, length), + pmp->pm_bpcluster, cred, &bp); + } + if (error) { #ifdef MSDOSFS_DEBUG - printf("detrunc(): bread fails %d\n", error); + printf("detrunc(): bread fails %d\n", error); #endif - return (error); - } - memset(bp->b_data + boff, 0, pmp->pm_bpcluster - boff); - if (flags & IO_SYNC) - bwrite(bp); - else - bdwrite(bp); + return (error); } + memset(bp->b_data + boff, 0, pmp->pm_bpcluster - boff); + if ((flags & IO_SYNC) != 0) + bwrite(bp); + else + bdwrite(bp); } /*