From owner-svn-src-all@freebsd.org Fri Dec 22 17:19:09 2017 Return-Path: Delivered-To: svn-src-all@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 5C7BAEA56D5; Fri, 22 Dec 2017 17:19:09 +0000 (UTC) (envelope-from fsu@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 3671D7F4C6; Fri, 22 Dec 2017 17:19:09 +0000 (UTC) (envelope-from fsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBMHJ8EM047071; Fri, 22 Dec 2017 17:19:08 GMT (envelope-from fsu@FreeBSD.org) Received: (from fsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBMHJ8d8047070; Fri, 22 Dec 2017 17:19:08 GMT (envelope-from fsu@FreeBSD.org) Message-Id: <201712221719.vBMHJ8d8047070@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fsu set sender to fsu@FreeBSD.org using -f From: Fedor Uporov Date: Fri, 22 Dec 2017 17:19:08 +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: r327087 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: fsu X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 327087 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 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: Fri, 22 Dec 2017 17:19:09 -0000 Author: fsu Date: Fri Dec 22 17:19:08 2017 New Revision: 327087 URL: https://svnweb.freebsd.org/changeset/base/327087 Log: MFC r326808, r326824: Move buffer size checks outside of the vnode locks. Reviewed by: kib, cem, pfg (mentor) Approved by: pfg (mentor) Differential Revision: https://reviews.freebsd.org/D13405 Modified: stable/11/sys/kern/vfs_extattr.c Modified: stable/11/sys/kern/vfs_extattr.c ============================================================================== --- stable/11/sys/kern/vfs_extattr.c Fri Dec 22 17:15:02 2017 (r327086) +++ stable/11/sys/kern/vfs_extattr.c Fri Dec 22 17:19:08 2017 (r327087) @@ -165,6 +165,9 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, co ssize_t cnt; int error; + if (nbytes > IOSIZE_MAX) + return (EINVAL); + error = vn_start_write(vp, &mp, V_WAIT | PCATCH); if (error) return (error); @@ -175,10 +178,6 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, co auio.uio_iov = &aiov; auio.uio_iovcnt = 1; auio.uio_offset = 0; - if (nbytes > IOSIZE_MAX) { - error = EINVAL; - goto done; - } auio.uio_resid = nbytes; auio.uio_rw = UIO_WRITE; auio.uio_segflg = UIO_USERSPACE; @@ -197,7 +196,9 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, co cnt -= auio.uio_resid; td->td_retval[0] = cnt; +#ifdef MAC done: +#endif VOP_UNLOCK(vp, 0); vn_finished_write(mp); return (error); @@ -328,6 +329,9 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, co size_t size, *sizep; int error; + if (nbytes > IOSIZE_MAX) + return (EINVAL); + vn_lock(vp, LK_SHARED | LK_RETRY); /* @@ -344,10 +348,6 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, co auio.uio_iov = &aiov; auio.uio_iovcnt = 1; auio.uio_offset = 0; - if (nbytes > IOSIZE_MAX) { - error = EINVAL; - goto done; - } auio.uio_resid = nbytes; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; @@ -372,8 +372,9 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, co td->td_retval[0] = cnt; } else td->td_retval[0] = size; - +#ifdef MAC done: +#endif VOP_UNLOCK(vp, 0); return (error); } @@ -636,6 +637,9 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, v ssize_t cnt; int error; + if (nbytes > IOSIZE_MAX) + return (EINVAL); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); auiop = NULL; @@ -647,10 +651,6 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, v auio.uio_iov = &aiov; auio.uio_iovcnt = 1; auio.uio_offset = 0; - if (nbytes > IOSIZE_MAX) { - error = EINVAL; - goto done; - } auio.uio_resid = nbytes; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_USERSPACE; @@ -674,8 +674,9 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, v td->td_retval[0] = cnt; } else td->td_retval[0] = size; - +#ifdef MAC done: +#endif VOP_UNLOCK(vp, 0); return (error); }