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
This commit is contained in:
Konstantin Belousov 2019-04-03 17:02:18 +00:00
parent 2b9dde098f
commit c973ee9e06
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=345847

View File

@ -405,19 +405,21 @@ detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred)
bn = cntobn(pmp, eofentry);
error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
NOCRED, &bp);
if (error) {
brelse(bp);
#ifdef MSDOSFS_DEBUG
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);
} 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);
#endif
return (error);
}
memset(bp->b_data + boff, 0, pmp->pm_bpcluster - boff);
if ((flags & IO_SYNC) != 0)
bwrite(bp);
else
bdwrite(bp);
}
/*