summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_linker.c
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-11/+11
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Resolve relative relocations in klds before trying to parse the module'sjake2003-01-211-73/+29
| | | | | | | | | | | | metadata. This fixes module dependency resolution by the kernel linker on sparc64, where the relocations for the metadata are different than on other architectures; the relative offset is in the addend of an Elf_Rela record instead of the original value of the location being patched. Also fix printf formats in debug code. Submitted by: Hartmut Brandt <brandt@fokus.gmd.de> PR: 46732 Tested on: alpha (obrien), i386, sparc64
* unwrap lines made short enough by SCARGS removalalfred2002-12-141-6/+3
|
* SCARGS removal take II.alfred2002-12-141-14/+14
|
* Backout removal SCARGS, the code freeze is only "selectively" over.alfred2002-12-131-14/+14
|
* Remove SCARGS.alfred2002-12-131-14/+14
| | | | Reviewed by: md5
* Merge kld access control checks from the MAC tree: these access controlrwatson2002-11-191-0/+42
| | | | | | | | | | | checks permit policy modules to augment the system policy for permitting kld operations. This permits policies to limit access to kld operations based on credential (and other) properties, as well as to perform checks on the kld being loaded (integrity, etc). Approved by: re Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* fix kldload error return when a module is rejected because it's staticallysam2002-10-171-4/+12
| | | | | | linked in the kernel. When this condition is detected deep in the linker internals the EEXIST error code that's returned is stomped on and instead an ENOEXEC code is returned. This makes apps like sysinstall bitch.
* Plug a memory-leak.phk2002-10-151-0/+1
| | | | "I think you're right" by: jake
* In order to better support flexible and extensible access control,rwatson2002-08-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | make a series of modifications to the credential arguments relating to file read and write operations to cliarfy which credential is used for what: - Change fo_read() and fo_write() to accept "active_cred" instead of "cred", and change the semantics of consumers of fo_read() and fo_write() to pass the active credential of the thread requesting an operation rather than the cached file cred. The cached file cred is still available in fo_read() and fo_write() consumers via fp->f_cred. These changes largely in sys_generic.c. For each implementation of fo_read() and fo_write(), update cred usage to reflect this change and maintain current semantics: - badfo_readwrite() unchanged - kqueue_read/write() unchanged pipe_read/write() now authorize MAC using active_cred rather than td->td_ucred - soo_read/write() unchanged - vn_read/write() now authorize MAC using active_cred but VOP_READ/WRITE() with fp->f_cred Modify vn_rdwr() to accept two credential arguments instead of a single credential: active_cred and file_cred. Use active_cred for MAC authorization, and select a credential for use in VOP_READ/WRITE() based on whether file_cred is NULL or not. If file_cred is provided, authorize the VOP using that cred, otherwise the active credential, matching current semantics. Modify current vn_rdwr() consumers to pass a file_cred if used in the context of a struct file, and to always pass active_cred. When vn_rdwr() is used without a file_cred, pass NOCRED. These changes should maintain current semantics for read/write, but avoid a redundant passing of fp->f_cred, as well as making it more clear what the origin of each credential is in file descriptor read/write operations. Follow-up commits will make similar changes to other file descriptor operations, and modify the MAC framework to pass both credentials to MAC policy modules so they can implement either semantic for revocation. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Make the consumers of the linker_load_file() function usemux2002-08-021-5/+2
| | | | | | | | | | | | | linker_load_module() instead. This fixes a bug where the kernel was unable to properly locate and load a kernel module in vfs_mount() (and probably in the netgraph code as well since it was using the same function). This is because the linker_load_file() does not properly search the module path. Problem found by: peter Reviewed by: peter Thanks to: peter
* Pre-wire the output buffer so that sysctl_kern_function_list() doesn'ttruckman2002-07-221-0/+1
| | | | block in SYSCTL_OUT() while holding a lock.
* - Delay unlocking a vnode in linker_hints_lookup until we're actually donejeff2002-07-071-5/+4
| | | | | with it. - Remove a now stale comment about improper vnode locking.
* - Remove the lock(9) protecting the kernel linker system.arr2002-06-191-14/+46
| | | | | | | | | | | - Added a mutex, kld_mtx, to protect the kernel_linker system. Note that while ``classes'' is global (to that file), it is only read only after SI_SUB_KLD, SI_ORDER_ANY. - Add a SYSINIT to flip a flag that disallows class registration after SI_SUB_KLD, SI_ORDER_ANY. Idea for ``classes'' read only by: jake Reviewed by: jake
* Test if rootvnode is NULL rather than if rootdev is NODEV when determiningbrian2002-04-261-1/+1
| | | | | | | | if there's a filesystem present. rootdev can be NODEV in the NFS-mounted root scenario. Discussed with: Harti Brandt <brandt@fokus.gmd.de>, iedowse
* In linker_load_module(), check that rootdev != NODEV before callingbrian2002-04-101-3/+5
| | | | | | | | | | | linker_search_module(). Without this, modules loaded from loader.conf that then try to load in additional modules (such as digi.ko loading a card's BIOS) die badly in the vn_open() called from linker_search_module(). It may be worth checking (KASSERTing?) that rootdev != NODEV in vn_open() too.
* Change linker_reference_module() so that it's passed a structbrian2002-04-101-3/+14
| | | | | | | | | | mod_depend * (which may be NULL). The only consumer of this function at the moment is digi_loadmoduledata(), and that passes a NULL mod_depend *. In linker_reference_module(), check to see if we've already got the required module loaded. If we have, bump the reference count and return that, otherwise continue the module search as normal.
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-04-011-2/+2
| | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
* - Recommit the securelevel_gt() calls removed by commits rev. 1.84 ofarr2002-03-251-6/+6
| | | | | | | | kern_linker.c and rev. 1.237 of vfs_syscalls.c since these are not the source of the recent panics occuring around kldloading file system support modules. Requested by: rwatson
* - Back out the commit to make the linker_load_file() securelevel checkarr2002-03-221-6/+6
| | | | | | made aware in jail environments. Supposedly something is broken, so this should be backed out until further investigation proves otherwise, or a proper fix can be provided.
* - Fix a logic error in checking the securelevel that was introduced in thearr2002-03-211-6/+2
| | | | | | previous commit. Pointy hats to: arr, rwatson
* - Change a check of securelevel to securelevel_gt() call in order to helparr2002-03-201-6/+10
| | | | | | | | | against users within a jail attempting to load kernel modules. - Add a check of securelevel_gt() to vfs_mount() in order to chop some low hanging fruit for the repair of securelevel checking of linking and unlinking files from within jails. There is more to be done here. Reviewed by: rwatson
* - Change a malloc / bzero pair to make use of the M_ZERO malloc(9) flag.arr2002-03-191-2/+1
|
* - Lock down the ``module'' structure by adding an SX lock that is used byarr2002-03-181-7/+8
| | | | | | | | | all the global bits of ``module'' data. This commit adds a few generic macros, MOD_SLOCK, MOD_XLOCK, etc., that are meant to be used as ways of accessing the SX lock. It is also the first step in helping to lock down the kernel linker and module systems. Reviewed by: jhb, jake, smp@
OpenPOWER on IntegriCloud