From owner-svn-src-head@freebsd.org Wed Sep 4 14:20:40 2019 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 AED93F3011; Wed, 4 Sep 2019 14:20:40 +0000 (UTC) (envelope-from kevans@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 46NmFN48FJz4MH7; Wed, 4 Sep 2019 14:20:40 +0000 (UTC) (envelope-from kevans@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 71A511CC88; Wed, 4 Sep 2019 14:20:40 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x84EKeTv035696; Wed, 4 Sep 2019 14:20:40 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x84EKeiQ035695; Wed, 4 Sep 2019 14:20:40 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201909041420.x84EKeiQ035695@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 4 Sep 2019 14:20:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r351815 - head/sys/fs/pseudofs X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/fs/pseudofs X-SVN-Commit-Revision: 351815 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: Wed, 04 Sep 2019 14:20:40 -0000 Author: kevans Date: Wed Sep 4 14:20:39 2019 New Revision: 351815 URL: https://svnweb.freebsd.org/changeset/base/351815 Log: pseudofs: make readdir work without a pid again Specifically, the following was broken: $ mount -t procfs procfs /proc $ ls -l /proc r351741 reworked readdir slightly to avoid pfs_node/pidhash LOR, but inadvertently regressed pid == NO_PID; new pfs_lookup_proc() fails for the obvious reasons, and later pfs_visible_proc doesn't capture the pid == NO_PID -> return 1 aspect of pfs_visible. We can infact skip this whole block if we're operating on a directory w/ NO_PID, as it's always visible. Reported by: trasz Reviewed by: mjg Differential Revision: https://reviews.freebsd.org/D21518 Modified: head/sys/fs/pseudofs/pseudofs_vnops.c Modified: head/sys/fs/pseudofs/pseudofs_vnops.c ============================================================================== --- head/sys/fs/pseudofs/pseudofs_vnops.c Wed Sep 4 14:05:04 2019 (r351814) +++ head/sys/fs/pseudofs/pseudofs_vnops.c Wed Sep 4 14:20:39 2019 (r351815) @@ -809,23 +809,28 @@ pfs_readdir(struct vop_readdir_args *va) if (resid == 0) PFS_RETURN (0); - if (!pfs_lookup_proc(pid, &proc)) + proc = NULL; + if (pid != NO_PID && !pfs_lookup_proc(pid, &proc)) PFS_RETURN (ENOENT); sx_slock(&allproc_lock); pfs_lock(pd); - PROC_LOCK(proc); - /* check if the directory is visible to the caller */ - if (!pfs_visible_proc(curthread, pd, proc)) { - _PRELE(proc); - PROC_UNLOCK(proc); - sx_sunlock(&allproc_lock); - pfs_unlock(pd); - PFS_RETURN (ENOENT); - } KASSERT(pid == NO_PID || proc != NULL, ("%s(): no process for pid %lu", __func__, (unsigned long)pid)); + + if (pid != NO_PID) { + PROC_LOCK(proc); + + /* check if the directory is visible to the caller */ + if (!pfs_visible_proc(curthread, pd, proc)) { + _PRELE(proc); + PROC_UNLOCK(proc); + sx_sunlock(&allproc_lock); + pfs_unlock(pd); + PFS_RETURN (ENOENT); + } + } /* skip unwanted entries */ for (pn = NULL, p = NULL; offset > 0; offset -= PFS_DELEN) {