kern_linker.c (188440) | kern_linker.c (191816) |
---|---|
1/*- 2 * Copyright (c) 1997-2000 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997-2000 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/kern/kern_linker.c 188440 2009-02-10 15:50:19Z attilio $"); | 28__FBSDID("$FreeBSD: head/sys/kern/kern_linker.c 191816 2009-05-05 10:56:12Z zec $"); |
29 30#include "opt_ddb.h" 31#include "opt_hwpmc_hooks.h" 32#include "opt_mac.h" 33 34#include <sys/param.h> 35#include <sys/kernel.h> 36#include <sys/systm.h> --- 951 unchanged lines hidden (view full) --- 988 989 if ((error = securelevel_gt(td->td_ucred, 0)) != 0) 990 return (error); 991 992 if ((error = priv_check(td, PRIV_KLD_LOAD)) != 0) 993 return (error); 994 995 /* | 29 30#include "opt_ddb.h" 31#include "opt_hwpmc_hooks.h" 32#include "opt_mac.h" 33 34#include <sys/param.h> 35#include <sys/kernel.h> 36#include <sys/systm.h> --- 951 unchanged lines hidden (view full) --- 988 989 if ((error = securelevel_gt(td->td_ucred, 0)) != 0) 990 return (error); 991 992 if ((error = priv_check(td, PRIV_KLD_LOAD)) != 0) 993 return (error); 994 995 /* |
996 * It's possible that kldloaded module will attach a new ifnet, 997 * so vnet context must be set when this ocurs. 998 */ 999 CURVNET_SET(TD_TO_VNET(td)); 1000 1001 /* |
|
996 * If file does not contain a qualified name or any dot in it 997 * (kldname.ko, or kldname.ver.ko) treat it as an interface 998 * name. 999 */ 1000 if (index(file, '/') || index(file, '.')) { 1001 kldname = file; 1002 modname = NULL; 1003 } else { --- 10 unchanged lines hidden (view full) --- 1014 pkm.pm_address = (uintptr_t) lf->address; 1015 PMC_CALL_HOOK(td, PMC_FN_KLD_LOAD, (void *) &pkm); 1016#endif 1017 lf->userrefs++; 1018 if (fileid != NULL) 1019 *fileid = lf->id; 1020unlock: 1021 KLD_UNLOCK(); | 1002 * If file does not contain a qualified name or any dot in it 1003 * (kldname.ko, or kldname.ver.ko) treat it as an interface 1004 * name. 1005 */ 1006 if (index(file, '/') || index(file, '.')) { 1007 kldname = file; 1008 modname = NULL; 1009 } else { --- 10 unchanged lines hidden (view full) --- 1020 pkm.pm_address = (uintptr_t) lf->address; 1021 PMC_CALL_HOOK(td, PMC_FN_KLD_LOAD, (void *) &pkm); 1022#endif 1023 lf->userrefs++; 1024 if (fileid != NULL) 1025 *fileid = lf->id; 1026unlock: 1027 KLD_UNLOCK(); |
1028 CURVNET_RESTORE(); |
|
1022 return (error); 1023} 1024 1025int 1026kldload(struct thread *td, struct kldload_args *uap) 1027{ 1028 char *pathname = NULL; 1029 int error, fileid; --- 21 unchanged lines hidden (view full) --- 1051 int error = 0; 1052 1053 if ((error = securelevel_gt(td->td_ucred, 0)) != 0) 1054 return (error); 1055 1056 if ((error = priv_check(td, PRIV_KLD_UNLOAD)) != 0) 1057 return (error); 1058 | 1029 return (error); 1030} 1031 1032int 1033kldload(struct thread *td, struct kldload_args *uap) 1034{ 1035 char *pathname = NULL; 1036 int error, fileid; --- 21 unchanged lines hidden (view full) --- 1058 int error = 0; 1059 1060 if ((error = securelevel_gt(td->td_ucred, 0)) != 0) 1061 return (error); 1062 1063 if ((error = priv_check(td, PRIV_KLD_UNLOAD)) != 0) 1064 return (error); 1065 |
1066 CURVNET_SET(TD_TO_VNET(td)); |
|
1059 KLD_LOCK(); 1060 lf = linker_find_file_by_id(fileid); 1061 if (lf) { 1062 KLD_DPF(FILE, ("kldunload: lf->userrefs=%d\n", lf->userrefs)); 1063 1064 /* Check if there are DTrace probes enabled on this file. */ 1065 if (lf->nenabled > 0) { 1066 printf("kldunload: attempt to unload file that has" --- 20 unchanged lines hidden (view full) --- 1087 } else 1088 error = ENOENT; 1089 1090#ifdef HWPMC_HOOKS 1091 if (error == 0) 1092 PMC_CALL_HOOK(td, PMC_FN_KLD_UNLOAD, (void *) &pkm); 1093#endif 1094 KLD_UNLOCK(); | 1067 KLD_LOCK(); 1068 lf = linker_find_file_by_id(fileid); 1069 if (lf) { 1070 KLD_DPF(FILE, ("kldunload: lf->userrefs=%d\n", lf->userrefs)); 1071 1072 /* Check if there are DTrace probes enabled on this file. */ 1073 if (lf->nenabled > 0) { 1074 printf("kldunload: attempt to unload file that has" --- 20 unchanged lines hidden (view full) --- 1095 } else 1096 error = ENOENT; 1097 1098#ifdef HWPMC_HOOKS 1099 if (error == 0) 1100 PMC_CALL_HOOK(td, PMC_FN_KLD_UNLOAD, (void *) &pkm); 1101#endif 1102 KLD_UNLOCK(); |
1103 CURVNET_RESTORE(); |
|
1095 return (error); 1096} 1097 1098int 1099kldunload(struct thread *td, struct kldunload_args *uap) 1100{ 1101 1102 return (kern_kldunload(td, uap->fileid, LINKER_UNLOAD_NORMAL)); --- 1059 unchanged lines hidden --- | 1104 return (error); 1105} 1106 1107int 1108kldunload(struct thread *td, struct kldunload_args *uap) 1109{ 1110 1111 return (kern_kldunload(td, uap->fileid, LINKER_UNLOAD_NORMAL)); --- 1059 unchanged lines hidden --- |