From owner-svn-src-stable@freebsd.org Fri Aug 2 01:59:59 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A90B9A69D0; Fri, 2 Aug 2019 01:59:59 +0000 (UTC) (envelope-from rmacklem@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 4609Mz3l4Zz4Tbg; Fri, 2 Aug 2019 01:59:59 +0000 (UTC) (envelope-from rmacklem@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 5DAFD235D4; Fri, 2 Aug 2019 01:59:59 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x721xx6W050169; Fri, 2 Aug 2019 01:59:59 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x721xxVu050168; Fri, 2 Aug 2019 01:59:59 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201908020159.x721xxVu050168@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 2 Aug 2019 01:59:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r350528 - stable/12/sys/ufs/ufs X-SVN-Group: stable-12 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/12/sys/ufs/ufs X-SVN-Commit-Revision: 350528 X-SVN-Commit-Repository: base 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.29 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, 02 Aug 2019 01:59:59 -0000 Author: rmacklem Date: Fri Aug 2 01:59:58 2019 New Revision: 350528 URL: https://svnweb.freebsd.org/changeset/base/350528 Log: MFC: r350367 Lock the vnode before calling ufs_bmap_seekdata(). r346932 replaced a call to vn_bmap_seekhole() with a call to ufs_bmap_seekdata(). Although vn_bmap_seekhole() locks the vnode, ufs_bmap_seekdata() assumes it is already locked. This patch adds locking of the vnode before the ufs_bmap_seekdata() call. If the vn_lock() call fails, it returns EBADF since that is the normal error returned when a file system is forced dismounted and is already listed as an error return in the lseek(2) man page. Thanks go to Harry Schmalzbauer (freebsd@omnilan.de) for noting that this MFC was required. Modified: stable/12/sys/ufs/ufs/ufs_vnops.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/12/sys/ufs/ufs/ufs_vnops.c Fri Aug 2 00:13:11 2019 (r350527) +++ stable/12/sys/ufs/ufs/ufs_vnops.c Fri Aug 2 01:59:58 2019 (r350528) @@ -2695,11 +2695,18 @@ static int ufs_ioctl(struct vop_ioctl_args *ap) { struct vnode *vp; + int error; vp = ap->a_vp; switch (ap->a_command) { case FIOSEEKDATA: - return (ufs_bmap_seekdata(vp, (off_t *)ap->a_data)); + error = vn_lock(vp, LK_SHARED); + if (error == 0) { + error = ufs_bmap_seekdata(vp, (off_t *)ap->a_data); + VOP_UNLOCK(vp, 0); + } else + error = EBADF; + return (error); case FIOSEEKHOLE: return (vn_bmap_seekhole(vp, ap->a_command, (off_t *)ap->a_data, ap->a_cred));