summaryrefslogtreecommitdiff
path: root/sys/kern/kern_linker.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix panic when module is compiled in and it is loaded from loader.conf.Pawel Jakub Dawidek2005-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. Notes: svn path=/head/; revision=146733
* Prevent loading modules with are compiled into the kernel.Pawel Jakub Dawidek2005-05-281-2/+8
| | | | | | | | | | PR: kern/48759 Submitted by: Pawe³ Ma³achowski <pawmal@unia.3lo.lublin.pl> Patch from: demon MFC after: 2 weeks Notes: svn path=/head/; revision=146730
* - Denote a few places where kobj class references are manipulated withoutJohn Baldwin2005-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. Notes: svn path=/head/; revision=144443
* When trying each linker class in turn with a preloaded module, exitIan Dowse2004-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. Notes: svn path=/head/; revision=134364
* Give kldunload a -f(orce) argument.Poul-Henning Kamp2004-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. Notes: svn path=/head/; revision=132117
* Trim a few things from the dmesg output and stick them under bootverbose toJohn Baldwin2004-07-011-2/+3
| | | | | | | | | | cut down on the clutter including PCI interrupt routing, MTRR, pcibios, etc. Discussed with: USENIX Cabal Notes: svn path=/head/; revision=131398
* Since we go to the trouble of compiling the kobj ops table for each class,Peter Wemm2004-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. Notes: svn path=/head/; revision=129364
* Plug minor memory leak of module_t structures when unloading a filePeter Edwards2004-04-091-1/+3
| | | | | | | | | from the kernel. Reviewed By: Doug Rabson (dfr@) Notes: svn path=/head/; revision=128057
* Split the mlock() kernel code into two parts, mlock(), which unpacksDon Lewis2004-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 Notes: svn path=/head/; revision=126253
* Avoid NULL pointer dereferencing in modlist_lookup2().Max Khon2003-09-231-1/+1
| | | | | | | | PR: 56570 Submitted by: Thomas Wintergerst <Thomas.Wintergerst@nord-com.net> Notes: svn path=/head/; revision=120382
* Add fdidx argument to vn_open() and vn_open_cred() and pass -1 throughout.Poul-Henning Kamp2003-07-271-2/+2
| | | | Notes: svn path=/head/; revision=118094
* Use __FBSDID().David E. O'Brien2003-06-111-2/+3
| | | | Notes: svn path=/head/; revision=116182
* FreeBSD 5.0 has stopped shipping /modules 2.5 years ago. CatchRuslan Ermilov2003-03-031-1/+1
| | | | | | | | up with this further by excluding /modules from the (default) kern.module_path. Notes: svn path=/head/; revision=111852
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-11/+11
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-11/+11
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Resolve relative relocations in klds before trying to parse the module'sJake Burkholder2003-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 Notes: svn path=/head/; revision=109605
* unwrap lines made short enough by SCARGS removalAlfred Perlstein2002-12-141-6/+3
| | | | Notes: svn path=/head/; revision=107855
* SCARGS removal take II.Alfred Perlstein2002-12-141-14/+14
| | | | Notes: svn path=/head/; revision=107849
* Backout removal SCARGS, the code freeze is only "selectively" over.Alfred Perlstein2002-12-131-14/+14
| | | | Notes: svn path=/head/; revision=107839
* Remove SCARGS.Alfred Perlstein2002-12-131-14/+14
| | | | | | | Reviewed by: md5 Notes: svn path=/head/; revision=107838
* Merge kld access control checks from the MAC tree: these access controlRobert Watson2002-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 Notes: svn path=/head/; revision=107089
* fix kldload error return when a module is rejected because it's staticallySam Leffler2002-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. Notes: svn path=/head/; revision=105337
* Plug a memory-leak.Poul-Henning Kamp2002-10-151-0/+1
| | | | | | | "I think you're right" by: jake Notes: svn path=/head/; revision=105167
* In order to better support flexible and extensible access control,Robert Watson2002-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 Notes: svn path=/head/; revision=101941
* Make the consumers of the linker_load_file() function useMaxime Henrion2002-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 Notes: svn path=/head/; revision=101241
* Pre-wire the output buffer so that sysctl_kern_function_list() doesn'tDon Lewis2002-07-221-0/+1
| | | | | | | block in SYSCTL_OUT() while holding a lock. Notes: svn path=/head/; revision=100488
* - Delay unlocking a vnode in linker_hints_lookup until we're actually doneJeff Roberson2002-07-071-5/+4
| | | | | | | | with it. - Remove a now stale comment about improper vnode locking. Notes: svn path=/head/; revision=99553
* - Remove the lock(9) protecting the kernel linker system.Andrew R. Reiter2002-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 Notes: svn path=/head/; revision=98452
* Test if rootvnode is NULL rather than if rootdev is NODEV when determiningBrian Somers2002-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 Notes: svn path=/head/; revision=95488
* In linker_load_module(), check that rootdev != NODEV before callingBrian Somers2002-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. Notes: svn path=/head/; revision=94322
* Change linker_reference_module() so that it's passed a structBrian Somers2002-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. Notes: svn path=/head/; revision=94321
* Change the suser() API to take advantage of td_ucred as well as do aJohn Baldwin2002-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@ Notes: svn path=/head/; revision=93593
* - Recommit the securelevel_gt() calls removed by commits rev. 1.84 ofAndrew R. Reiter2002-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 Notes: svn path=/head/; revision=93159
* - Back out the commit to make the linker_load_file() securelevel checkAndrew R. Reiter2002-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. Notes: svn path=/head/; revision=92927
* - Fix a logic error in checking the securelevel that was introduced in theAndrew R. Reiter2002-03-211-6/+2
| | | | | | | | | previous commit. Pointy hats to: arr, rwatson Notes: svn path=/head/; revision=92884
* - Change a check of securelevel to securelevel_gt() call in order to helpAndrew R. Reiter2002-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 Notes: svn path=/head/; revision=92803
* - Change a malloc / bzero pair to make use of the M_ZERO malloc(9) flag.Andrew R. Reiter2002-03-191-2/+1
| | | | Notes: svn path=/head/; revision=92705
* - Lock down the ``module'' structure by adding an SX lock that is used byAndrew R. Reiter2002-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@ Notes: svn path=/head/; revision=92547
* Don't assign strcmp to a variable called err and then compare itDavid Malone2002-03-101-20/+12
| | | | | | | | | | | with zero, just compare strcmp with zero. This fixes the same bug which Maxim just fixed and fixes some odd style too. PR: 35712 Reviewed by: arr Notes: svn path=/head/; revision=92032
* Fix a breakage introduced in rev.1.75 (supposedly style cleanup), which resultsMaxim Sobolev2002-03-101-6/+6
| | | | | | | | | in "missing dependencies" error when loading some kld modules. It is sad to see how often these days style cleanus break doesn't broken things. Perhaps people should recall good old principle: "don't fix it if it isn't broken". Notes: svn path=/head/; revision=92016
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredJohn Baldwin2002-02-271-6/+5
| | | | | | | reference. Notes: svn path=/head/; revision=91406
* - Whitespace fixes leftover from previous commit.Andrew R. Reiter2002-02-221-21/+21
| | | | | | | Submitted by: bde Notes: svn path=/head/; revision=91068
* - Massive style fixup.Andrew R. Reiter2002-02-221-1268/+1292
| | | | | | | | Reviewed by: mike Approved by: dfr Notes: svn path=/head/; revision=91040
* Add a comment indicating that the vnode locking in this section of theRobert Watson2002-02-101-0/+3
| | | | | | | | kernel linker code may be wrong: it fails to hold a lock across the call to VOP_GETATTR(), and vn_rdwr() with IO_NODELOCKED. Notes: svn path=/head/; revision=90483
* - Ensure that linker file id's are unique, rather than blindlyAndrew R. Reiter2001-11-181-1/+15
| | | | | | | | | incrementing the value. Reviewed by: dfr, peter Notes: svn path=/head/; revision=86553
* Fix a number of misspellings of "dependency" and "dependencies" inIan Dowse2001-11-161-9/+9
| | | | | | | | | | comments and function names. PR: kern/8589 Submitted by: Rajesh Vaidheeswarran <rv@fore.com> Notes: svn path=/head/; revision=86469
* o Move suser() calls in kern/ to using suser_xxx() with an explicitRobert Watson2001-11-011-2/+2
| | | | | | | | | | | | credential selection, rather than reference via a thread or process pointer. This is part of a gradual migration to suser() accepting a struct ucred instead of a struct proc, simplifying the reference and locking semantics of suser(). Obtained from: TrustedBSD Project Notes: svn path=/head/; revision=85844
* Add the sysctl "kern.function_list", which currently exports allBrian Feldman2001-10-301-0/+31
| | | | | | | | | | | | | | | | | | | | function symbols in the kernel in a list of C strings, with an extra nul-termination at the end. This sysctl requires addition of a new linker operation. Now, linker_file_t's need to respond to "each_function_name" to export their function symbols. Note that the sysctl doesn't currently allow distinguishing multiple symbols with the same name from different modules, but could quite easily without a change to the linker operation. This will be a nicety to have when it can be used. Obtained from: NAI Labs CBOSS project Funded by: DARPA Notes: svn path=/head/; revision=85736
* KSE Milestone 2Julian Elischer2001-09-121-44/+43
| | | | | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha Notes: svn path=/head/; revision=83366
* Fix the kern.module_path issue that required the trailing '/' characterPeter Wemm2001-09-121-12/+15
| | | | | | | | on each module path component. Fix a one-byte buffer overflow at the same time that got highlighted in the process. Notes: svn path=/head/; revision=83358