Date: Sat, 5 Mar 2011 15:36:17 GMT From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 189561 for review Message-ID: <201103051536.p25FaHp5085186@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <trasz@FreeBSD.org> + * 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 <sys/cdefs.h> -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: src/sys/kern/kern_loginclass.c,v 1.1 2011/03/05 12:40:35 trasz Exp $"); #include <sys/param.h> #include <sys/container.h> @@ -56,11 +61,6 @@ #include <sys/sysproto.h> #include <sys/systm.h> -/* - * 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 <trasz@FreeBSD.org> + * 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103051536.p25FaHp5085186>