From owner-svn-src-all@freebsd.org Thu Feb 1 19:57:22 2018 Return-Path: Delivered-To: svn-src-all@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 156E6EC25BD; Thu, 1 Feb 2018 19:57:22 +0000 (UTC) (envelope-from hselasky@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 B50968286C; Thu, 1 Feb 2018 19:57:21 +0000 (UTC) (envelope-from hselasky@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 AF0B41193D; Thu, 1 Feb 2018 19:57:21 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w11JvLv9036857; Thu, 1 Feb 2018 19:57:21 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w11JvL3K036856; Thu, 1 Feb 2018 19:57:21 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201802011957.w11JvL3K036856@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 1 Feb 2018 19:57:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328731 - head/sys/compat/linuxkpi/common/src X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/compat/linuxkpi/common/src X-SVN-Commit-Revision: 328731 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: Thu, 01 Feb 2018 19:57:22 -0000 Author: hselasky Date: Thu Feb 1 19:57:21 2018 New Revision: 328731 URL: https://svnweb.freebsd.org/changeset/base/328731 Log: Fix some recent regressions after r328436 in the LinuxKPI: 1) The OPW() function macro should have the same return type like the function it executes. 2) The DEVFS I/O-limit should be enforced for all character device reads and writes. 3) The character device file handle should be passable, same as for DEVFS based file handles. Reported by: jbeich @ MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_compat.c Thu Feb 1 19:48:05 2018 (r328730) +++ head/sys/compat/linuxkpi/common/src/linux_compat.c Thu Feb 1 19:57:21 2018 (r328731) @@ -669,7 +669,7 @@ static struct cdev_pager_ops linux_cdev_pager_ops[2] = #define OPW(fp,td,code) ({ \ struct file *__fpop; \ - int __retval; \ + __typeof(code) __retval; \ \ __fpop = (td)->td_fpop; \ (td)->td_fpop = (fp); \ @@ -1277,6 +1277,8 @@ linux_file_read(struct file *file, struct uio *uio, st /* XXX no support for I/O vectors currently */ if (uio->uio_iovcnt != 1) return (EOPNOTSUPP); + if (uio->uio_resid > DEVFS_IOSIZE_MAX) + return (EINVAL); linux_set_current(td); if (filp->f_op->read) { bytes = OPW(file, td, filp->f_op->read(filp, uio->uio_iov->iov_base, @@ -1314,6 +1316,8 @@ linux_file_write(struct file *file, struct uio *uio, s /* XXX no support for I/O vectors currently */ if (uio->uio_iovcnt != 1) return (EOPNOTSUPP); + if (uio->uio_resid > DEVFS_IOSIZE_MAX) + return (EINVAL); linux_set_current(td); if (filp->f_op->write) { bytes = OPW(file, td, filp->f_op->write(filp, uio->uio_iov->iov_base, @@ -1556,6 +1560,7 @@ struct fileops linuxfileops = { .fo_chmod = invfo_chmod, .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, + .fo_flags = DFLAG_PASSABLE, }; /*