kern_linker.c (60938) | kern_linker.c (62261) |
---|---|
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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * | 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 --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * $FreeBSD: head/sys/kern/kern_linker.c 60938 2000-05-26 02:09:24Z jake $ | 26 * $FreeBSD: head/sys/kern/kern_linker.c 62261 2000-06-29 17:57:04Z archie $ |
27 */ 28 29#include "opt_ddb.h" 30 31#include <sys/param.h> 32#include <sys/kernel.h> 33#include <sys/systm.h> 34#include <sys/malloc.h> --- 261 unchanged lines hidden (view full) --- 296 297int 298linker_load_file(const char* filename, linker_file_t* result) 299{ 300 linker_class_t lc; 301 linker_file_t lf; 302 int foundfile, error = 0; 303 | 27 */ 28 29#include "opt_ddb.h" 30 31#include <sys/param.h> 32#include <sys/kernel.h> 33#include <sys/systm.h> 34#include <sys/malloc.h> --- 261 unchanged lines hidden (view full) --- 296 297int 298linker_load_file(const char* filename, linker_file_t* result) 299{ 300 linker_class_t lc; 301 linker_file_t lf; 302 int foundfile, error = 0; 303 |
304 /* Refuse to load modules if securelevel raised */ 305 if (securelevel > 0) 306 return EPERM; 307 |
|
304 lf = linker_find_file_by_name(filename); 305 if (lf) { 306 KLD_DPF(FILE, ("linker_load_file: file %s is already loaded, incrementing refs\n", filename)); 307 *result = lf; 308 lf->refs++; 309 goto out; 310 } 311 --- 108 unchanged lines hidden (view full) --- 420linker_file_unload(linker_file_t file) 421{ 422 module_t mod, next; 423 modlist_t ml, nextml; 424 struct common_symbol* cp; 425 int error = 0; 426 int i; 427 | 308 lf = linker_find_file_by_name(filename); 309 if (lf) { 310 KLD_DPF(FILE, ("linker_load_file: file %s is already loaded, incrementing refs\n", filename)); 311 *result = lf; 312 lf->refs++; 313 goto out; 314 } 315 --- 108 unchanged lines hidden (view full) --- 424linker_file_unload(linker_file_t file) 425{ 426 module_t mod, next; 427 modlist_t ml, nextml; 428 struct common_symbol* cp; 429 int error = 0; 430 int i; 431 |
432 /* Refuse to unload modules if securelevel raised */ 433 if (securelevel > 0) 434 return EPERM; 435 |
|
428 KLD_DPF(FILE, ("linker_file_unload: lf->refs=%d\n", file->refs)); 429 lockmgr(&lock, LK_EXCLUSIVE, 0, curproc); 430 if (file->refs == 1) { 431 KLD_DPF(FILE, ("linker_file_unload: file is unloading, informing modules\n")); 432 /* 433 * Inform any modules associated with this file. 434 */ 435 for (mod = TAILQ_FIRST(&file->modules); mod; mod = next) { --- 237 unchanged lines hidden (view full) --- 673{ 674 char* pathname, *realpath; 675 const char *filename; 676 linker_file_t lf; 677 int error = 0; 678 679 p->p_retval[0] = -1; 680 | 436 KLD_DPF(FILE, ("linker_file_unload: lf->refs=%d\n", file->refs)); 437 lockmgr(&lock, LK_EXCLUSIVE, 0, curproc); 438 if (file->refs == 1) { 439 KLD_DPF(FILE, ("linker_file_unload: file is unloading, informing modules\n")); 440 /* 441 * Inform any modules associated with this file. 442 */ 443 for (mod = TAILQ_FIRST(&file->modules); mod; mod = next) { --- 237 unchanged lines hidden (view full) --- 681{ 682 char* pathname, *realpath; 683 const char *filename; 684 linker_file_t lf; 685 int error = 0; 686 687 p->p_retval[0] = -1; 688 |
681 if (securelevel > 0) | 689 if (securelevel > 0) /* redundant, but that's OK */ |
682 return EPERM; 683 684 if ((error = suser(p)) != 0) 685 return error; 686 687 realpath = NULL; 688 pathname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); 689 if ((error = copyinstr(SCARG(uap, file), pathname, MAXPATHLEN, NULL)) != 0) --- 26 unchanged lines hidden (view full) --- 716} 717 718int 719kldunload(struct proc* p, struct kldunload_args* uap) 720{ 721 linker_file_t lf; 722 int error = 0; 723 | 690 return EPERM; 691 692 if ((error = suser(p)) != 0) 693 return error; 694 695 realpath = NULL; 696 pathname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); 697 if ((error = copyinstr(SCARG(uap, file), pathname, MAXPATHLEN, NULL)) != 0) --- 26 unchanged lines hidden (view full) --- 724} 725 726int 727kldunload(struct proc* p, struct kldunload_args* uap) 728{ 729 linker_file_t lf; 730 int error = 0; 731 |
724 if (securelevel > 0) | 732 if (securelevel > 0) /* redundant, but that's OK */ |
725 return EPERM; 726 727 if ((error = suser(p)) != 0) 728 return error; 729 730 lf = linker_find_file_by_id(SCARG(uap, fileid)); 731 if (lf) { 732 KLD_DPF(FILE, ("kldunload: lf->userrefs=%d\n", lf->userrefs)); --- 639 unchanged lines hidden --- | 733 return EPERM; 734 735 if ((error = suser(p)) != 0) 736 return error; 737 738 lf = linker_find_file_by_id(SCARG(uap, fileid)); 739 if (lf) { 740 KLD_DPF(FILE, ("kldunload: lf->userrefs=%d\n", lf->userrefs)); --- 639 unchanged lines hidden --- |