From owner-svn-src-stable@freebsd.org Fri Nov 11 19:40:35 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71C8AC3C2DB; Fri, 11 Nov 2016 19:40:35 +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 mx1.freebsd.org (Postfix) with ESMTPS id 286C91ACC; Fri, 11 Nov 2016 19:40:35 +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 uABJeY0Y000532; Fri, 11 Nov 2016 19:40:34 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uABJeYra000529; Fri, 11 Nov 2016 19:40:34 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201611111940.uABJeYra000529@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 11 Nov 2016 19:40:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r308545 - stable/11/sys/fs/msdosfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2016 19:40:35 -0000 Author: kib Date: Fri Nov 11 19:40:34 2016 New Revision: 308545 URL: https://svnweb.freebsd.org/changeset/base/308545 Log: MFC r308025: Enable vn_io_fault() deadlock avoidance for msdosfs. Modified: stable/11/sys/fs/msdosfs/msdosfs_vfsops.c stable/11/sys/fs/msdosfs/msdosfs_vnops.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/msdosfs/msdosfs_vfsops.c ============================================================================== --- stable/11/sys/fs/msdosfs/msdosfs_vfsops.c Fri Nov 11 19:37:51 2016 (r308544) +++ stable/11/sys/fs/msdosfs/msdosfs_vfsops.c Fri Nov 11 19:40:34 2016 (r308545) @@ -742,7 +742,7 @@ mountmsdosfs(struct vnode *devvp, struct mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; - mp->mnt_kern_flag |= MNTK_USES_BCACHE; + mp->mnt_kern_flag |= MNTK_USES_BCACHE | MNTK_NO_IOPF; MNT_IUNLOCK(mp); if (pmp->pm_flags & MSDOSFS_LARGEFS) Modified: stable/11/sys/fs/msdosfs/msdosfs_vnops.c ============================================================================== --- stable/11/sys/fs/msdosfs/msdosfs_vnops.c Fri Nov 11 19:37:51 2016 (r308544) +++ stable/11/sys/fs/msdosfs/msdosfs_vnops.c Fri Nov 11 19:40:34 2016 (r308545) @@ -593,7 +593,7 @@ msdosfs_read(struct vop_read_args *ap) diff = blsize - bp->b_resid; if (diff < n) n = diff; - error = uiomove(bp->b_data + on, (int) n, uio); + error = vn_io_fault_uiomove(bp->b_data + on, (int) n, uio); brelse(bp); } while (error == 0 && uio->uio_resid > 0 && n != 0); if (!isadir && (error == 0 || uio->uio_resid != orig_resid) && @@ -723,6 +723,12 @@ msdosfs_write(struct vop_write_args *ap) * then no need to read data from disk. */ bp = getblk(thisvp, bn, pmp->pm_bpcluster, 0, 0, 0); + /* + * This call to vfs_bio_clrbuf() ensures that + * even if vn_io_fault_uiomove() below faults, + * garbage from the newly instantiated buffer + * is not exposed to the userspace via mmap(). + */ vfs_bio_clrbuf(bp); /* * Do the bmap now, since pcbmap needs buffers @@ -760,7 +766,7 @@ msdosfs_write(struct vop_write_args *ap) /* * Copy the data from user space into the buf header. */ - error = uiomove(bp->b_data + croffset, n, uio); + error = vn_io_fault_uiomove(bp->b_data + croffset, n, uio); if (error) { brelse(bp); break;