From owner-p4-projects@FreeBSD.ORG Sun Mar 26 19:17:43 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CD4D416A422; Sun, 26 Mar 2006 19:17:43 +0000 (UTC) X-Original-To: perforce@freebsd.org 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 8F01816A420 for ; Sun, 26 Mar 2006 19:17:43 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 55C3E43D45 for ; Sun, 26 Mar 2006 19:17:43 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k2QJHhXu028689 for ; Sun, 26 Mar 2006 19:17:43 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k2QJHhLc028686 for perforce@freebsd.org; Sun, 26 Mar 2006 19:17:43 GMT (envelope-from jhb@freebsd.org) Date: Sun, 26 Mar 2006 19:17:43 GMT Message-Id: <200603261917.k2QJHhLc028686@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 94079 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: Sun, 26 Mar 2006 19:17:44 -0000 http://perforce.freebsd.org/chv.cgi?CH=94079 Change 94079 by jhb@jhb_zion on 2006/03/26 19:17:37 Simple Giant pushdown. Affected files ... .. //depot/projects/smpng/sys/kern/kern_linker.c#42 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_linker.c#42 (text+ko) ==== @@ -758,13 +758,11 @@ td->td_retval[0] = -1; - mtx_lock(&Giant); - if ((error = securelevel_gt(td->td_ucred, 0)) != 0) - goto out; + return (error); if ((error = suser(td)) != 0) - goto out; + return (error); pathname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); if ((error = copyinstr(uap->file, pathname, MAXPATHLEN, NULL)) != 0) @@ -782,16 +780,16 @@ kldname = NULL; modname = pathname; } + + mtx_lock(&Giant); error = linker_load_module(kldname, modname, NULL, NULL, &lf); - if (error) - goto out; - - lf->userrefs++; - td->td_retval[0] = lf->id; + if (error == 0) { + lf->userrefs++; + td->td_retval[0] = lf->id; + } + mtx_unlock(&Giant); out: - if (pathname) - free(pathname, M_TEMP); - mtx_unlock(&Giant); + free(pathname, M_TEMP); return (error); } @@ -804,14 +802,13 @@ linker_file_t lf; int error = 0; - mtx_lock(&Giant); - if ((error = securelevel_gt(td->td_ucred, 0)) != 0) - goto out; + return (error); if ((error = suser(td)) != 0) - goto out; + return (error); + mtx_lock(&Giant); lf = linker_find_file_by_id(fileid); if (lf) { KLD_DPF(FILE, ("kldunload: lf->userrefs=%d\n", lf->userrefs)); @@ -822,15 +819,14 @@ printf("kldunload: attempt to unload file that was" " loaded by the kernel\n"); error = EBUSY; - goto out; + } else { + lf->userrefs--; + error = linker_file_unload(lf, flags); + if (error) + lf->userrefs++; } - lf->userrefs--; - error = linker_file_unload(lf, flags); - if (error) - lf->userrefs++; } else error = ENOENT; -out: mtx_unlock(&Giant); return (error); } @@ -875,7 +871,6 @@ return (error); #endif - mtx_lock(&Giant); td->td_retval[0] = -1; pathname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); @@ -883,15 +878,15 @@ goto out; filename = linker_basename(pathname); + mtx_lock(&Giant); lf = linker_find_file_by_name(filename); + mtx_unlock(&Giant); if (lf) td->td_retval[0] = lf->id; else error = ENOENT; out: - if (pathname) - free(pathname, M_TEMP); - mtx_unlock(&Giant); + free(pathname, M_TEMP); return (error); } @@ -1041,22 +1036,20 @@ return (error); #endif - mtx_lock(&Giant); - if ((error = copyin(uap->data, &lookup, sizeof(lookup))) != 0) - goto out; + return (error); if (lookup.version != sizeof(lookup) || - uap->cmd != KLDSYM_LOOKUP) { - error = EINVAL; - goto out; - } + uap->cmd != KLDSYM_LOOKUP) + return (EINVAL); symstr = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); if ((error = copyinstr(lookup.symname, symstr, MAXPATHLEN, NULL)) != 0) goto out; + mtx_lock(&Giant); if (uap->fileid != 0) { lf = linker_find_file_by_id(uap->fileid); if (lf == NULL) { error = ENOENT; + mtx_unlock(&Giant); goto out; } if (LINKER_LOOKUP_SYMBOL(lf, symstr, &sym) == 0 && @@ -1082,10 +1075,9 @@ if (lf == NULL) error = ENOENT; } + mtx_unlock(&Giant); out: - if (symstr) - free(symstr, M_TEMP); - mtx_unlock(&Giant); + free(symstr, M_TEMP); return (error); }