From owner-p4-projects@FreeBSD.ORG Sun Jul 27 07:32:06 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 24D0E37B405; Sun, 27 Jul 2003 07:32:06 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D220737B404 for ; Sun, 27 Jul 2003 07:32:05 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 52B9943F85 for ; Sun, 27 Jul 2003 07:32:05 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h6REW40U095834 for ; Sun, 27 Jul 2003 07:32:04 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h6REW3aD095831 for perforce@freebsd.org; Sun, 27 Jul 2003 07:32:03 -0700 (PDT) Date: Sun, 27 Jul 2003 07:32:03 -0700 (PDT) Message-Id: <200307271432.h6REW3aD095831@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 35088 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jul 2003 14:32:07 -0000 http://perforce.freebsd.org/chv.cgi?CH=35088 Change 35088 by rwatson@rwatson_tislabs on 2003/07/27 07:31:34 For the kern.file sysctl, don't reveal file descriptor information for processes the requesting thread isn't permitted to see. This relates to PR 54211 submitted by Pawel Jakub Dawidek, but is a subset solution in a slightly different form. Per the comment, some information about the total number of file descriptors is revealed, but this is a product of the way in which the size is calculated. Once we merge struct file label/access control support, there will also need to be a canseefile() check here. Affected files ... .. //depot/projects/trustedbsd/mac/sys/kern/kern_descrip.c#45 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/kern/kern_descrip.c#45 (text+ko) ==== @@ -2305,6 +2305,14 @@ struct proc *p; int error, n; + /* + * XXXMAC + * Note: because the number of file descriptors is calculated + * in different ways for sizing vs returning the data, + * there is information leakage from the first loop. However, + * it is of a similar order of magnitude to the leakage from + * global system statistics such as kern.openfiles. + */ sysctl_wire_old_buffer(req, 0); if (req->oldptr == NULL) { n = 16; /* A slight overestimate. */ @@ -2327,6 +2335,10 @@ sx_slock(&allproc_lock); LIST_FOREACH(p, &allproc, p_list) { PROC_LOCK(p); + if (p_cansee(req->td, p) != 0) { + PROC_UNLOCK(p); + continue; + } xf.xf_pid = p->p_pid; xf.xf_uid = p->p_ucred->cr_uid; PROC_UNLOCK(p);