From owner-svn-src-stable@freebsd.org Thu Apr 19 02:50:16 2018 Return-Path: Delivered-To: svn-src-stable@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 9E7E4F9E7EF; Thu, 19 Apr 2018 02:50:16 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 523366802F; Thu, 19 Apr 2018 02:50:16 +0000 (UTC) (envelope-from pfg@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 4D16D23B27; Thu, 19 Apr 2018 02:50:16 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3J2oGRi077155; Thu, 19 Apr 2018 02:50:16 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3J2oGVu077152; Thu, 19 Apr 2018 02:50:16 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201804190250.w3J2oGVu077152@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Thu, 19 Apr 2018 02:50:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r332750 - in stable/10/sys: fs/ext2fs ufs/ufs X-SVN-Group: stable-10 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: in stable/10/sys: fs/ext2fs ufs/ufs X-SVN-Commit-Revision: 332750 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.25 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: Thu, 19 Apr 2018 02:50:16 -0000 Author: pfg Date: Thu Apr 19 02:50:15 2018 New Revision: 332750 URL: https://svnweb.freebsd.org/changeset/base/332750 Log: MFC r328957: {ext2|ufs}_readdir: Avoid setting negative ncookies. ncookies cannot be negative or the allocator will fail. This should only happen if a caller is very broken but we can still try to survive the event. We should probably also verify for uio_resid > MAXPHYS but in that case it is not clear that just clipping the ncookies value is an adequate response. Modified: stable/10/sys/fs/ext2fs/ext2_lookup.c stable/10/sys/ufs/ufs/ufs_vnops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/fs/ext2fs/ext2_lookup.c ============================================================================== --- stable/10/sys/fs/ext2fs/ext2_lookup.c Thu Apr 19 02:47:21 2018 (r332749) +++ stable/10/sys/fs/ext2fs/ext2_lookup.c Thu Apr 19 02:50:15 2018 (r332750) @@ -150,7 +150,10 @@ ext2_readdir(struct vop_readdir_args *ap) return (EINVAL); ip = VTOI(vp); if (ap->a_ncookies != NULL) { - ncookies = uio->uio_resid; + if (uio->uio_resid < 0) + ncookies = 0; + else + ncookies = uio->uio_resid; if (uio->uio_offset >= ip->i_size) ncookies = 0; else if (ip->i_size - uio->uio_offset < ncookies) Modified: stable/10/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/10/sys/ufs/ufs/ufs_vnops.c Thu Apr 19 02:47:21 2018 (r332749) +++ stable/10/sys/ufs/ufs/ufs_vnops.c Thu Apr 19 02:50:15 2018 (r332750) @@ -2179,7 +2179,10 @@ ufs_readdir(ap) if (ip->i_effnlink == 0) return (0); if (ap->a_ncookies != NULL) { - ncookies = uio->uio_resid; + if (uio->uio_resid < 0) + ncookies = 0; + else + ncookies = uio->uio_resid; if (uio->uio_offset >= ip->i_size) ncookies = 0; else if (ip->i_size - uio->uio_offset < ncookies)