summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_linker.c
Commit message (Collapse)AuthorAgeFilesLines
* The kernel linker includes a number of utility functions to look up symbolrwatson2007-12-011-13/+87
| | | | | | | | | | | | | | | | | information in support of DDB(4); these functions bypass normal linker locking as they may run in contexts where locking is unsafe (such as the kernel debugger). Add a new interface linker_ddb_search_symbol_name(), which looks up a symbol name and offset given an address, and also linker_search_symbol_name() which does the same but *does* follow the locking conventions of the linker. Unlike existing functions, these functions place the name in a caller-provided buffer, which is stable even after linker locks have been released. These functions will be used in upcoming revisions to stack(9) to support kernel stack trace generation in contexts as part of a live, rather than suspended, kernel.
* Add a function to list symbols in a file and their values at thejb2007-11-181-0/+10
| | | | | same time rather than having to list the symbols and then go back and look each one up by name.
* Merge first in a series of TrustedBSD MAC Framework KPI changesrwatson2007-10-241-6/+6
| | | | | | | | | | | | | | | | | | | | | | | from Mac OS X Leopard--rationalize naming for entry points to the following general forms: mac_<object>_<method/action> mac_<object>_check_<method/action> The previous naming scheme was inconsistent and mostly reversed from the new scheme. Also, make object types more consistent and remove spaces from object types that contain multiple parts ("posix_sem" -> "posixsem") to make mechanical parsing easier. Introduce a new "netinet" object type for certain IPv4/IPv6-related methods. Also simplify, slightly, some entry point names. All MAC policy modules will need to be recompiled, and modules not updates as part of this commit will need to be modified to conform to the new KPI. Sponsored by: SPARTA (original patches against Mac OS X) Obtained from: TrustedBSD Project, Apple Computer
* Add the full module path name to the kld_file_stat structurejb2007-10-221-7/+38
| | | | | | | | | | | | | | for kldstat(2). This allows libdtrace to determine the exact file from which a kernel module was loaded without having to guess. The kldstat(2) API is versioned with the size of the kld_file_stat structure, so this change creates version 2. Add the pathname to the verbose output of kldstat(8) too. MFC: 3 days
* Revert UF_OPENING workaround for CURRENT.kib2007-05-311-2/+2
| | | | | | | | | Change the VOP_OPEN(), vn_open() vnode operation and d_fdopen() cdev operation argument from being file descriptor index into the pointer to struct file. Proposed and reviewed by: jhb Reviewed by: daichi (unionfs) Approved by: re (kensmith)
* Remove MAC Framework access control check entry points made redundant withrwatson2007-04-221-5/+0
| | | | | | | | | | | | | | | | | | the introduction of priv(9) and MAC Framework entry points for privilege checking/granting. These entry points exactly aligned with privileges and provided no additional security context: - mac_check_sysarch_ioperm() - mac_check_kld_unload() - mac_check_settime() - mac_check_system_nfsd() Add mpo_priv_check() implementations to Biba and LOMAC policies, which, for each privilege, determine if they can be granted to processes considered unprivileged by those two policies. These mostly, but not entirely, align with the set of privileges granted in jails. Obtained from: TrustedBSD Project
* Remove 'MPSAFE' annotations from the comments above most system calls: allrwatson2007-03-041-27/+0
| | | | | | | | system calls now enter without Giant held, and then in some cases, acquire Giant explicitly. Remove a number of other MPSAFE annotations in the credential code and tweak one or two other adjacent comments.
* Fix a comment.jhb2007-02-261-2/+2
|
* Drop the global kernel linker lock while executing the sysinit's for ajhb2007-02-231-15/+21
| | | | | | | | freshly-loaded kernel module. To avoid various unload races, hide linker files whose sysinit's are being run from userland so that they can't be kldunloaded until after all the sysinit's have finished. Tested by: gallatin
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningrwatson2006-11-061-2/+3
| | | | | | | | | | | | | specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net>
* Complete break-out of sys/sys/mac.h into sys/security/mac/mac_framework.hrwatson2006-10-221-1/+2
| | | | | | | | | | | | | begun with a repo-copy of mac.h to mac_framework.h. sys/mac.h now contains the userspace and user<->kernel API and definitions, with all in-kernel interfaces moved to mac_framework.h, which is now included across most of the kernel instead. This change is the first step in a larger cleanup and sweep of MAC Framework interfaces in the kernel, and will not be MFC'd. Obtained from: TrustedBSD Project Sponsored by: SPARTA
* Explicitly use STAILQ_REMOVE_HEAD() when we know we are removing the headjhb2006-07-101-3/+2
| | | | | | | | element to avoid confusing Coverity. It's now also easier for humans to parse as well. Found by: Coverity Prevent(tm) CID: 1201
* Fix two more instances of using a linker_file_t object in TAILQ() macrosjhb2006-07-101-4/+5
| | | | | | | after free'ing it. Found by: Coverity Prevent(tm) CID: 1435
* Don't try to reuse the linker_file structure after we've freed it whenjhb2006-07-101-2/+2
| | | | | | | throwing out the kld's loaded by the loader that didn't successfully link. Found by: Coverity Prevent(tm) CID: 1435
* - Explicitly acquire Giant around SYSINIT's and SYSUNINIT's since they arejhb2006-07-061-3/+10
| | | | | | | | not all known to be MPSAFE yet. - Actually remove Giant from the kernel linker by taking it out of the KLD_LOCK() and KLD_UNLOCK() macros. Pointy hat to: jhb (2)
* Replace the kld_mtx mutex with a kld_sx sx lock and expand it's scope tojhb2006-06-211-50/+77
| | | | | | | | | | | | protect all linker-related data structures including the contents of linker file objects and the any linker class data as well. Considering how rarely the linker is used I just went with the simple solution of single-threading the whole thing rather than expending a lot of effor on something more fine-grained and complex. Giant is still explicitly acquired while registering and deregistering sysctl's as well as in the elf linker class while calling kmupetext(). The rest of the linker runs without Giant unless it has to acquire Giant while loading files from a non-MPSAFE filesystem.
* - Push down Giant in kldfind() and kldsym().jhb2006-06-211-16/+10
| | | | - Remove several goto's by either using direct return's or else clauses.
* Fix two comments and a style fix.jhb2006-06-211-4/+6
|
* Various whitespace fixes.jhb2006-06-211-12/+11
|
* Conditionally acquire Giant around VFS operations.jhb2006-06-201-3/+10
|
* - Push Giant down into linker_reference_module().jhb2006-06-201-1/+31
| | | | | | | | - Add a new function linker_release_module() as a more intuitive complement to linker_reference_module() that wraps linker_file_unload(). linker_release_module() can either take the module name and version info passed to linker_reference_module() or it can accept the linker file object returned by linker_reference_module().
* Make linker_find_file_by_name() and linker_find_file_by_id() static tojhb2006-06-201-2/+12
| | | | | simplify linker locking. The only external consumers now use linker_file_foreach().
* - Add a new linker_file_foreach() function that walks the list of linkerjhb2006-06-201-28/+52
| | | | | | | | | | | | | | file objects calling a user-specified predicate function on each object. The iteration terminates either when the entire list has been iterated over or the predicate function returns a non-zero value. linker_file_foreach() returns the value returned by the last invocation of the predicate function. It also accepts a void * context pointer that is passed to the predicate function as well. Using an iterator function avoids exposing linker internals to the rest of the kernel making locking simpler. - Use linker_file_foreach() instead of walking the list of linker files manually to lookup ndis files in ndis(4). - Use linker_file_foreach() to implement linker_hwpmc_list_objects().
* Make linker_file_add_dependency() and linker_load_module() static sincejhb2006-06-201-4/+8
| | | | only the linker uses them.
* Don't check if malloc(M_WAITOK) returns NULL.jhb2006-06-201-4/+0
|
* Use 'else' to remove another goto.jhb2006-06-201-5/+2
|
* - Remove some useless variable initializations.jhb2006-06-201-6/+3
| | | | | - Make some conditional free()'s where the condition was always true unconditional.
* Unbreak 64-bit architectures. The 3rd argument to kern_kldload() ismarcel2006-06-141-4/+6
| | | | | a pointer to an integer and td->td_retval[0] is of type register_t. On 64-bit architectures register_t is wider than an integer.
* - Add a kern_kldload() that is most of the previous kldload() and pushjhb2006-06-131-39/+47
| | | | | | Giant down in it. - Push Giant down in kern_kldunload() and reorganize it slightly to avoid using gotos. Also, expose this function to the rest of the kernel.
* - Push down Giant some in kldstat().jhb2006-06-131-29/+21
| | | | | | - Use a 'struct kld_file_stat' on the stack to read data under the lock and then do one copyout() w/o holding the lock at the end to push the data out to userland.
* Unexpand TAILQ_FOREACH() and TAILQ_FOREACH_SAFE().jhb2006-06-131-4/+2
|
* Remove some more pointless goto's and don't check to see ifjhb2006-06-131-16/+9
| | | | malloc(M_WAITOK) returns NULL.
* Handle the simple case of just dropping a reference near the start ofjhb2006-06-131-28/+27
| | | | | | | linker_file_unload() instead of in the middle of a bunch of code for the case of dropping the last reference to improve readability and sanity. While I'm here, remove pointless goto's that were just jumping to a return statement.
* extlen and cpp is not used here in linker_search_kld(), so nuke them.delphij2006-05-271-10/+2
| | | | | Reported by: Mingyan Guo <guomingyan at gmail dot com> MFC After: 2 weeks
* MFP4: Support for profiling dynamically loaded objects.jkoshy2006-03-261-0/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Kernel changes: Inform hwpmc of executable objects brought into the system by kldload() and mmap(), and of their removal by kldunload() and munmap(). A helper function linker_hwpmc_list_objects() has been added to "sys/kern/kern_linker.c" and is used by hwpmc to retrieve the list of currently loaded kernel modules. The unused `MAPPINGCHANGE' event has been deprecated in favour of separate `MAP_IN' and `MAP_OUT' events; this change reduces space wastage in the log. Bump the hwpmc's ABI version to "2.0.00". Teach hwpmc(4) to handle the map change callbacks. Change the default per-cpu sample buffer size to hold 32 samples (up from 16). Increment __FreeBSD_version. libpmc(3) changes: Update libpmc(3) to deal with the new events in the log file; bring the pmclog(3) manual page in sync with the code. pmcstat(8) changes: Introduce new options to pmcstat(8): "-r" (root fs path), "-M" (mapfile name), "-q"/"-v" (verbosity control). Option "-k" now takes a kernel directory as its argument but will also work with the older invocation syntax. Rework string handling in pmcstat(8) to use an opaque type for interned strings. Clean up ELF parsing code and add support for tracking dynamic object mappings reported by a v2.0.00 hwpmc(4). Report statistics at the end of a log conversion run depending on the requested verbosity level. Reviewed by: jhb, dds (kernel parts of an earlier patch) Tested by: gallatin (earlier patch)
* Fix a bug in the kernel module runtime linker that made it impossiblejdp2005-10-191-0/+3
| | | | | | | | | | | | | to unload the usb.ko module after boot if it was originally preloaded from "/boot/loader.conf". When processing preloaded modules, the linker erroneously added self-dependencies the each module's reference count. That prevented usb.ko's reference count from ever going to 0, so it could not be unloaded. Sponsored by Isilon Systems. Reviewed by: pjd, peter MFC after: 1 week
* Fix panic when module is compiled in and it is loaded from loader.conf.pjd2005-05-281-3/+5
| | | | | | Only panic is fixed, module will be still listed in kldstat(8) output. Not sure what is correct fix, because adding unloading code in case of failure to linker_init_kernel_modules() doesn't work.
* Prevent loading modules with are compiled into the kernel.pjd2005-05-281-2/+8
| | | | | | | PR: kern/48759 Submitted by: Pawe³ Ma³achowski <pawmal@unia.3lo.lublin.pl> Patch from: demon MFC after: 2 weeks
* - Denote a few places where kobj class references are manipulated withoutjhb2005-03-311-3/+4
| | | | | | holding the appropriate lock. - Add a comment explaining why we bump a driver's kobj class reference when loading a module.
* When trying each linker class in turn with a preloaded module, exitiedowse2004-08-271-3/+2
| | | | | | the loop if the preload was successful. Previously a successful preload was ignored if the linker class was not the last in the list.
* Give kldunload a -f(orce) argument.phk2004-07-131-11/+38
| | | | | | | | | | | | | | | | | Add a MOD_QUIESCE event for modules. This should return error (EBUSY) of the module is in use. MOD_UNLOAD should now only fail if it is impossible (as opposed to inconvenient) to unload the module. Valid reasons are memory references into the module which cannot be tracked down and eliminated. When kldunloading, we abandon if MOD_UNLOAD fails, and if -force is not given, MOD_QUIESCE failing will also prevent the unload. For backwards compatibility, we treat EOPNOTSUPP from MOD_QUIESCE as success. Document that modules should return EOPNOTSUPP for unknown events.
* Trim a few things from the dmesg output and stick them under bootverbose tojhb2004-07-011-2/+3
| | | | | | | cut down on the clutter including PCI interrupt routing, MTRR, pcibios, etc. Discussed with: USENIX Cabal
* Since we go to the trouble of compiling the kobj ops table for each class,peter2004-05-171-0/+1
| | | | | | | | | | | | and cannot handle it going away, add an explicit reference to the kobj class inside each linker class. Without this, a class with no modules loaded will sit with an idle refcount of 0. Loading and unloading a module with it causes a 0->1->0 transition which frees the ops table and causes subsequent loads using that class to explode. Normally, the "kernel" module will remain forever loaded and prevent this happening, but if you have more than one linker class active, only one owns the "kernel". This finishes making modules work for kldload(8) on amd64.
* Plug minor memory leak of module_t structures when unloading a filepeadar2004-04-091-1/+3
| | | | | | from the kernel. Reviewed By: Doug Rabson (dfr@)
* Split the mlock() kernel code into two parts, mlock(), which unpackstruckman2004-02-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the syscall arguments and does the suser() permission check, and kern_mlock(), which does the resource limit checking and calls vm_map_wire(). Split munlock() in a similar way. Enable the RLIMIT_MEMLOCK checking code in kern_mlock(). Replace calls to vslock() and vsunlock() in the sysctl code with calls to kern_mlock() and kern_munlock() so that the sysctl code will obey the wired memory limits. Nuke the vslock() and vsunlock() implementations, which are no longer used. Add a member to struct sysctl_req to track the amount of memory that is wired to handle the request. Modify sysctl_wire_old_buffer() to return an error if its call to kern_mlock() fails. Only wire the minimum of the length specified in the sysctl request and the length specified in its argument list. It is recommended that sysctl handlers that use sysctl_wire_old_buffer() should specify reasonable estimates for the amount of data they want to return so that only the minimum amount of memory is wired no matter what length has been specified by the request. Modify the callers of sysctl_wire_old_buffer() to look for the error return. Modify sysctl_old_user to obey the wired buffer length and clean up its implementation. Reviewed by: bms
* Avoid NULL pointer dereferencing in modlist_lookup2().fjoe2003-09-231-1/+1
| | | | | PR: 56570 Submitted by: Thomas Wintergerst <Thomas.Wintergerst@nord-com.net>
* Add fdidx argument to vn_open() and vn_open_cred() and pass -1 throughout.phk2003-07-271-2/+2
|
* Use __FBSDID().obrien2003-06-111-2/+3
|
* FreeBSD 5.0 has stopped shipping /modules 2.5 years ago. Catchru2003-03-031-1/+1
| | | | | up with this further by excluding /modules from the (default) kern.module_path.
* Back out M_* changes, per decision of the TRB.imp2003-02-191-11/+11
| | | | Approved by: trb
OpenPOWER on IntegriCloud