From owner-svn-src-head@freebsd.org Mon Feb 3 22:27:04 2020 Return-Path: Delivered-To: svn-src-head@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 26A19230B3E; Mon, 3 Feb 2020 22:27:04 +0000 (UTC) (envelope-from mjg@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 48BMrS0HP2z4DBm; Mon, 3 Feb 2020 22:27:04 +0000 (UTC) (envelope-from mjg@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 0521B7C20; Mon, 3 Feb 2020 22:27:04 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 013MR3Sx081556; Mon, 3 Feb 2020 22:27:03 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 013MR3KI081555; Mon, 3 Feb 2020 22:27:03 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202002032227.013MR3KI081555@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Mon, 3 Feb 2020 22:27:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357469 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 357469 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Feb 2020 22:27:04 -0000 Author: mjg Date: Mon Feb 3 22:27:03 2020 New Revision: 357469 URL: https://svnweb.freebsd.org/changeset/base/357469 Log: fd: remove the seq argument from fget routines It is almost always NULL. Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Mon Feb 3 22:26:29 2020 (r357468) +++ head/sys/kern/kern_descrip.c Mon Feb 3 22:27:03 2020 (r357469) @@ -2780,7 +2780,7 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights */ static __inline int _fget(struct thread *td, int fd, struct file **fpp, int flags, - cap_rights_t *needrightsp, seqc_t *seqp) + cap_rights_t *needrightsp) { struct filedesc *fdp; struct file *fp; @@ -2788,7 +2788,7 @@ _fget(struct thread *td, int fd, struct file **fpp, in *fpp = NULL; fdp = td->td_proc->p_fd; - error = fget_unlocked(fdp, fd, needrightsp, &fp, seqp); + error = fget_unlocked(fdp, fd, needrightsp, &fp, NULL); if (__predict_false(error != 0)) return (error); if (__predict_false(fp->f_ops == &badfileops)) { @@ -2830,7 +2830,7 @@ int fget(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp) { - return (_fget(td, fd, fpp, 0, rightsp, NULL)); + return (_fget(td, fd, fpp, 0, rightsp)); } int @@ -2839,19 +2839,24 @@ fget_mmap(struct thread *td, int fd, cap_rights_t *rig { int error; #ifndef CAPABILITIES - error = _fget(td, fd, fpp, 0, rightsp, NULL); + error = _fget(td, fd, fpp, 0, rightsp); if (maxprotp != NULL) *maxprotp = VM_PROT_ALL; #else cap_rights_t fdrights; - struct filedesc *fdp = td->td_proc->p_fd; + struct filedesc *fdp; seqc_t seq; + fdp = td->td_proc->p_fd; MPASS(cap_rights_is_set(rightsp, CAP_MMAP)); for (;;) { - error = _fget(td, fd, fpp, 0, rightsp, &seq); - if (error != 0) + error = fget_unlocked(fdp, fd, rightsp, fpp, &seq); + if (__predict_false(error != 0)) return (error); + if (__predict_false((*fpp)->f_ops == &badfileops)) { + fdrop(*fpp, td); + return (EBADF); + } if (maxprotp != NULL) fdrights = *cap_rights(fdp, fd); if (!fd_modified(fdp, fd, seq)) @@ -2872,14 +2877,14 @@ int fget_read(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp) { - return (_fget(td, fd, fpp, FREAD, rightsp, NULL)); + return (_fget(td, fd, fpp, FREAD, rightsp)); } int fget_write(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp) { - return (_fget(td, fd, fpp, FWRITE, rightsp, NULL)); + return (_fget(td, fd, fpp, FWRITE, rightsp)); } int @@ -2926,7 +2931,7 @@ _fgetvp(struct thread *td, int fd, int flags, cap_righ int error; *vpp = NULL; - error = _fget(td, fd, &fp, flags, needrightsp, NULL); + error = _fget(td, fd, &fp, flags, needrightsp); if (error != 0) return (error); if (fp->f_vnode == NULL) {