From owner-p4-projects@FreeBSD.ORG Tue Jan 22 16:29:18 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5165416A419; Tue, 22 Jan 2008 16:29:18 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1583216A469 for ; Tue, 22 Jan 2008 16:29:18 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 1F7B213C45B for ; Tue, 22 Jan 2008 16:29:18 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m0MGTHn8055645 for ; Tue, 22 Jan 2008 16:29:17 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m0MGTHn7055642 for perforce@freebsd.org; Tue, 22 Jan 2008 16:29:17 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 22 Jan 2008 16:29:17 GMT Message-Id: <200801221629.m0MGTHn7055642@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 Cc: Subject: PERFORCE change 133870 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jan 2008 16:29:18 -0000 http://perforce.freebsd.org/chv.cgi?CH=133870 Change 133870 by rwatson@rwatson_freebsd_capabilities on 2008/01/22 16:28:22 Don't allow sysctl read or write access in capability mode unless nodes have been specifically marked as available. Affected files ... .. //depot/projects/trustedbsd/capabilities/src/sys/kern/kern_sysctl.c#2 edit .. //depot/projects/trustedbsd/capabilities/src/sys/sys/sysctl.h#2 edit Differences ... ==== //depot/projects/trustedbsd/capabilities/src/sys/kern/kern_sysctl.c#2 (text+ko) ==== @@ -38,10 +38,12 @@ #include __FBSDID("$FreeBSD: src/sys/kern/kern_sysctl.c,v 1.179 2007/11/30 21:29:08 peter Exp $"); +#include "opt_capabilities.h" #include "opt_compat.h" #include "opt_mac.h" #include +#include #include #include #include @@ -1288,6 +1290,19 @@ KASSERT(req->td != NULL, ("sysctl_root(): req->td == NULL")); +#ifdef CAPABILITIES + /* + * If the process is in capability mode, then don't permit reading or + * writing unless specifically granted for the node. + */ + if (req->td->td_ucred->cr_flags & CRED_FLAG_CAPMODE) { + if (req->oldptr && !(oid->oid_kind & CTLFLAG_CAPRD)) + return (EPERM); + if (req->newptr && !(oid->oid_kind & CTLFLAG_CAPWR)) + return (EPERM); + } +#endif + /* Is this sysctl sensitive to securelevels? */ if (req->newptr && (oid->oid_kind & CTLFLAG_SECURE)) { lvl = (oid->oid_kind & CTLMASK_SECURE) >> CTLSHIFT_SECURE; ==== //depot/projects/trustedbsd/capabilities/src/sys/sys/sysctl.h#2 (text+ko) ==== @@ -85,6 +85,8 @@ #define CTLMASK_SECURE 0x00F00000 /* Secure level */ #define CTLFLAG_TUN 0x00080000 /* Tunable variable */ #define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) +#define CTLFLAG_CAPRD 0x00040000 /* Can be read in capability mode */ +#define CTLFLAG_CAPWR 0x00020000 /* Can be written in capability mode */ /* * Secure level. Note that CTLFLAG_SECURE == CTLFLAG_SECURE1.