Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Mar 2002 04:03:46 +0100 (CET)
From:      "Simon 'corecode' Schubert" <corecode@corecode.ath.cx>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/36522: stat outside procs in procfs succeeds from within a jail
Message-ID:  <200203300303.g2U33ki38379@elevation.zuhause.stoert.net>

next in thread | raw e-mail | index | archive | help

>Number:         36522
>Category:       kern
>Synopsis:       stat outside procs in procfs succeeds from within a jail
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 29 19:20:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Simon 'corecode' Schubert
>Release:        FreeBSD 4.5-STABLE i386
>Organization:
>Environment:
System: FreeBSD elevation.zuhause.stoert.net 4.5-STABLE FreeBSD 4.5-STABLE #0: Fri Mar 22 19:08:08 CET 2002 corecode@elevation.zuhause.stoert.net:/usr/obj/i386/k7/usr/src/sys/ELEVATION i386


	
>Description:
	from within a jail:
	doing a stat(2) on a process' dir/file in procfs that doesn't
	belong to the jail returns a valid result and not ENOENT, though
	readdir doesn't list these directories/files
	
>How-To-Repeat:
	# jail / elev 1 `which perl` \
		-e 'stat "/proc/$ARGV[0]" and print "valid!\n" or print "invalid!\n"' 1

	should print `invalid!', but doesn't do so.
	
>Fix:
	i'm no kernel hacker, but i assume there is a PRISON_CHECK() missing;
	i didn't check that code, just assume that. no guarantee this will even
	compile neither work!


--- /usr/src/sys/miscfs/procfs/procfs_vnops.c	Wed Jan 23 02:00:54 2002
+++ procfs_vnops.c	Sat Mar 30 04:00:51 2002
@@ -444,7 +444,7 @@
 	default:
 		procp = PFIND(pfs->pfs_pid);
 		if (procp == NULL || procp->p_cred == NULL ||
-		    procp->p_ucred == NULL)
+		    procp->p_ucred == NULL || !PRISON_CHECK(curproc, procp))
 			return (ENOENT);
 	}
 
	


>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203300303.g2U33ki38379>