From owner-p4-projects@FreeBSD.ORG Sat Mar 5 15:36:18 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5184E1065674; Sat, 5 Mar 2011 15:36: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 E4801106566C for ; Sat, 5 Mar 2011 15:36:17 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id D088F8FC1E for ; Sat, 5 Mar 2011 15:36:17 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p25FaHET085189 for ; Sat, 5 Mar 2011 15:36:17 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p25FaHp5085186 for perforce@freebsd.org; Sat, 5 Mar 2011 15:36:17 GMT (envelope-from trasz@freebsd.org) Date: Sat, 5 Mar 2011 15:36:17 GMT Message-Id: <201103051536.p25FaHp5085186@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 189561 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Mar 2011 15:36:18 -0000 http://p4web.freebsd.org/@@189561?ac=10 Change 189561 by trasz@trasz_victim on 2011/03/05 15:35:13 Fix stuff broken by IFC. Affected files ... .. //depot/projects/soc2009/trasz_limits/sys/kern/kern_loginclass.c#34 edit .. //depot/projects/soc2009/trasz_limits/sys/sys/loginclass.h#15 edit Differences ... ==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_loginclass.c#34 (text+ko) ==== @@ -1,7 +1,10 @@ /*- - * Copyright (c) 2009 Edward Tomasz Napierała + * Copyright (c) 2011 The FreeBSD Foundation * All rights reserved. * + * This software was developed by Edward Tomasz Napierala under sponsorship + * from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -22,6 +25,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD: src/sys/kern/kern_loginclass.c,v 1.1 2011/03/05 12:40:35 trasz Exp $ */ /* @@ -38,7 +43,7 @@ */ #include -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: src/sys/kern/kern_loginclass.c,v 1.1 2011/03/05 12:40:35 trasz Exp $"); #include #include @@ -56,11 +61,6 @@ #include #include -/* - * XXX: Review locking. - */ - -/* XXX: Use UMA instead? */ static MALLOC_DEFINE(M_LOGINCLASS, "loginclass", "loginclass structures"); LIST_HEAD(, loginclass) loginclasses; @@ -74,14 +74,14 @@ SYSINIT(loginclass, SI_SUB_CPU, SI_ORDER_FIRST, lc_init, NULL); void -loginclass_acquire(struct loginclass *lc) +loginclass_hold(struct loginclass *lc) { refcount_acquire(&lc->lc_refcount); } void -loginclass_release(struct loginclass *lc) +loginclass_free(struct loginclass *lc) { int old; @@ -105,7 +105,7 @@ * Return loginclass structure with a corresponding name. Not * performance critical, as it's used mainly by setloginclass(2), * which happens once per login session. Caller has to use - * loginclass_release() on the returned value when it's no longer + * loginclass_free() on the returned value when it's no longer * needed. */ struct loginclass * @@ -113,7 +113,7 @@ { struct loginclass *lc, *newlc; - if (name[0] == '\0' || strlen(name) > MAXLOGNAME - 1) + if (name[0] == '\0' || strlen(name) >= MAXLOGNAME) return (NULL); newlc = malloc(sizeof(*newlc), M_LOGINCLASS, M_ZERO | M_WAITOK); @@ -125,7 +125,7 @@ continue; /* Found loginclass with a matching name? */ - loginclass_acquire(lc); + loginclass_hold(lc); mtx_unlock(&loginclasses_lock); container_destroy(&newlc->lc_container); free(newlc, M_LOGINCLASS); @@ -159,21 +159,10 @@ struct proc *p; struct loginclass *lc; - if (uap->pid == 0) { - p = td->td_proc; - PROC_LOCK(p); - } else { - p = pfind(uap->pid); - if (p == NULL) - return (ESRCH); - error = p_cansee(td, p); - if (error != 0) { - PROC_UNLOCK(p); - return (error); - } - } + p = td->td_proc; + PROC_LOCK(p); lc = p->p_ucred->cr_loginclass; - loginclass_acquire(lc); + loginclass_hold(lc); PROC_UNLOCK(p); lcnamelen = strlen(lc->lc_name) + 1; @@ -181,7 +170,7 @@ error = ERANGE; if (error == 0) error = copyout(lc->lc_name, uap->namebuf, lcnamelen); - loginclass_release(lc); + loginclass_free(lc); return (error); } @@ -223,8 +212,7 @@ #ifdef CONTAINERS container_proc_ucred_changed(p, oldcred, newcred); #endif - - loginclass_release(oldcred->cr_loginclass); + loginclass_free(oldcred->cr_loginclass); crfree(oldcred); return (0); ==== //depot/projects/soc2009/trasz_limits/sys/sys/loginclass.h#15 (text+ko) ==== @@ -1,7 +1,10 @@ /*- - * Copyright (c) 2009 Edward Tomasz Napierała + * Copyright (c) 2011 The FreeBSD Foundation * All rights reserved. * + * This software was developed by Edward Tomasz Napierala under sponsorship + * from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -22,6 +25,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD: src/sys/sys/loginclass.h,v 1.1 2011/03/05 12:40:35 trasz Exp $ */ #ifndef _SYS_LOGINCLASS_H_ @@ -39,8 +44,8 @@ struct container *lc_container; }; -void loginclass_acquire(struct loginclass *lc); -void loginclass_release(struct loginclass *lc); +void loginclass_hold(struct loginclass *lc); +void loginclass_free(struct loginclass *lc); struct loginclass *loginclass_find(const char *name); void loginclass_container_foreach(void (*callback)(struct container *container, void *arg2, void *arg3), void *arg2, void *arg3);