From owner-svn-src-stable@FreeBSD.ORG Tue Dec 17 13:13:03 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 218B2FD0; Tue, 17 Dec 2013 13:13:03 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0CDAF10F0; Tue, 17 Dec 2013 13:13:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBHDD2B5073310; Tue, 17 Dec 2013 13:13:02 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBHDD2VT073309; Tue, 17 Dec 2013 13:13:02 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201312171313.rBHDD2VT073309@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 17 Dec 2013 13:13:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r259507 - stable/9/sys/fs/pseudofs X-SVN-Group: stable-9 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.17 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: Tue, 17 Dec 2013 13:13:03 -0000 Author: kib Date: Tue Dec 17 13:13:02 2013 New Revision: 259507 URL: http://svnweb.freebsd.org/changeset/base/259507 Log: MFC r258088: Add check for buflen overflow by comparing the buflen with both offset and resid. MFC r258397: Redo r258088 to avoid relying on signed arithmetic overflow. Modified: stable/9/sys/fs/pseudofs/pseudofs_vnops.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/pseudofs/pseudofs_vnops.c ============================================================================== --- stable/9/sys/fs/pseudofs/pseudofs_vnops.c Tue Dec 17 13:10:28 2013 (r259506) +++ stable/9/sys/fs/pseudofs/pseudofs_vnops.c Tue Dec 17 13:13:02 2013 (r259507) @@ -616,8 +616,7 @@ pfs_read(struct vop_read_args *va) struct proc *proc; struct sbuf *sb = NULL; int error, locked; - off_t offset; - ssize_t buflen, resid; + off_t buflen; PFS_TRACE(("%s", pn->pn_name)); pfs_assert_not_owned(pn); @@ -654,14 +653,12 @@ pfs_read(struct vop_read_args *va) goto ret; } - /* beaucoup sanity checks so we don't ask for bogus allocation */ - if (uio->uio_offset < 0 || uio->uio_resid < 0 || - (offset = uio->uio_offset) != uio->uio_offset || - (resid = uio->uio_resid) != uio->uio_resid || - (buflen = offset + resid) < offset || buflen >= INT_MAX) { + if (uio->uio_resid < 0 || uio->uio_offset < 0 || + uio->uio_resid > OFF_MAX - uio->uio_offset) { error = EINVAL; goto ret; } + buflen = uio->uio_offset + uio->uio_resid; if (buflen > MAXPHYS) buflen = MAXPHYS;