summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_linker.c
Commit message (Collapse)AuthorAgeFilesLines
* 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@
* Don't assign strcmp to a variable called err and then compare itdwmalone2002-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
* Fix a breakage introduced in rev.1.75 (supposedly style cleanup), which resultssobomax2002-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".
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredjhb2002-02-271-6/+5
| | | | reference.
* - Whitespace fixes leftover from previous commit.arr2002-02-221-21/+21
| | | | Submitted by: bde
* - Massive style fixup.arr2002-02-221-1268/+1292
| | | | | Reviewed by: mike Approved by: dfr
* Add a comment indicating that the vnode locking in this section of therwatson2002-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.
* - Ensure that linker file id's are unique, rather than blindlyarr2001-11-181-1/+15
| | | | | | incrementing the value. Reviewed by: dfr, peter
* Fix a number of misspellings of "dependency" and "dependencies" iniedowse2001-11-161-9/+9
| | | | | | | comments and function names. PR: kern/8589 Submitted by: Rajesh Vaidheeswarran <rv@fore.com>
* o Move suser() calls in kern/ to using suser_xxx() with an explicitrwatson2001-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
* Add the sysctl "kern.function_list", which currently exports allgreen2001-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
* KSE Milestone 2julian2001-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
* Fix the kern.module_path issue that required the trailing '/' characterpeter2001-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.
* Implement the long-awaited module->file cache database. A userlandpeter2001-09-111-87/+299
| | | | | | | tool (kldxref(8)) keeps a cache of what modules and versions are inside what .ko files. I have tested this on both Alpha and i386. Submitted by: bp
* Giant Pushdown. Saved the worst P4 tree breakage for last.dillon2001-09-011-19/+61
| | | | | | | | | | | | reboot() getpriority() setpriority() rtprio() osetrlimit() ogetrlimit() setrlimit() getrlimit() getrusage() getpid() getppid() getpgrp() getpgid() getsid() getgid() getegid() getgroups() setsid() setpgid() setuid() seteuid() setgid() setegid() setgroups() setreuid() setregid() setresuid() setresgid() getresuid() getresgid () __setugid() getlogin() setlogin() modnext() modfnext() modstat() modfind() kldload() kldunload() kldfind() kldnext() kldstat() kldfirstmod() kldsym() getdtablesize() dup2() dup() fcntl() close() ofstat() fstat() nfsstat() fpathconf() flock()
* Sync the default module search path with the one indd2001-08-201-1/+1
| | | | | | | sys/boot/common/module.c. PR: 21405 Submitted by: Makoto MATSUSHITA <matusita@jp.FreeBSD.org>
* Don't try to print a field that doesn't exist; in usually commentedjake2001-07-311-2/+2
| | | | out debugging code.
* Constify (silence warnings introduced by last commit to sys/module.h)des2001-06-201-7/+7
|
* Add linker_reference_module().brian2001-06-181-0/+25
| | | | | This function loads a module if required, otherwise bumps the reference count -- the opposite of linker_file_unload().
* With this commit, I hereby pronounce gensetdefs past its use-by date.peter2001-06-131-94/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace the a.out emulation of 'struct linker_set' with something a little more flexible. <sys/linker_set.h> now provides macros for accessing elements and completely hides the implementation. The linker_set.h macros have been on the back burner in various forms since 1998 and has ideas and code from Mike Smith (SET_FOREACH()), John Polstra (ELF clue) and myself (cleaned up API and the conversion of the rest of the kernel to use it). The macros declare a strongly typed set. They return elements with the type that you declare the set with, rather than a generic void *. For ELF, we use the magic ld symbols (__start_<setname> and __stop_<setname>). Thanks to Richard Henderson <rth@redhat.com> for the trick about how to force ld to provide them for kld's. For a.out, we use the old linker_set struct. NOTE: the item lists are no longer null terminated. This is why the code impact is high in certain areas. The runtime linker has a new method to find the linker set boundaries depending on which backend format is in use. linker sets are still module/kld unfriendly and should never be used for anything that may be modular one day. Reviewed by: eivind
* Make the TUNABLE_*() macros look and behave more consistantly like thepeter2001-06-061-4/+2
| | | | | SYSCTL_*() macros. TUNABLE_INT_DECL() was an odd name because it didn't actually declare the int, which is what the name suggests it would do.
* o Actually extract version of interface and store it along with the name.bp2001-03-221-52/+99
| | | | | | | o Add new parameter to the modlist_lookup() function to perform lookups with strict version matching. o Collapse duplicate code to function(s).
* Slightly reorganize code in the linker_load_dependancies() function to makebp2001-03-221-54/+52
| | | | codepath more straightforward.
* Remove support for old way of handling module dependencies.bp2001-03-221-35/+18
| | | | Approved by: peter
* Another round of the <sys/queue.h> FOREACH transmogriffer.phk2001-02-041-2/+1
| | | | | Created with: sed(1) Reviewed by: md5(1)
* Mechanical change to use <sys/queue.h> macro API instead ofphk2001-02-041-12/+12
| | | | | | | fondling implementation details. Created with: sed(1) Reviewed by: md5(1)
* Pull out the module path from the loader. ie: if you boot frompeter2000-12-281-4/+8
| | | | | | | | /boot/kernel.foobar/* then that had better be in the path ahead of the others. Submitted by: Daniel J. O'Connor <darius@dons.net.au> PR: 23662
* Convert more malloc+bzero to malloc+M_ZERO.dwmalone2000-12-081-10/+6
| | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net>
* Add a workaround for statically linked kernels.dfr2000-10-041-0/+6
|
* The kernel is now known as `kernel.ko' and it and its matching modulesobrien2000-09-061-1/+1
| | | | | | live in ``/boot/kernel/''. Submitted by: Hisashi Hiramoto <hiramoto@phys.chs.nihon-u.ac.jp>
* Fix self referential dependencies. eg: uhub was packaged along withpeter2000-08-021-3/+13
| | | | | | | usb, all in usb.ko. uhub depends on usb. The bug was that the preload processing only adds a module to the list once it's internal dependencies are resolved... Since it was not "seeing" the internal usb module it believed that uhub had a missing dependency.
* Correct SYSINIT execution order in the case when KLD contains morebp2000-07-091-2/+2
| | | | | | than one SYSINIT with the same 'subsystem' id and different 'order' id. Reviewed by: peter
* Move the truncation code out of vn_open and into the open system callmckusick2000-07-041-2/+3
| | | | | | | | | | after the acquisition of any advisory locks. This fix corrects a case in which a process tries to open a file with a non-blocking exclusive lock. Even if it fails to get the lock it would still truncate the file even though its open failed. With this change, the truncation is done only after the lock is successfully acquired. Obtained from: BSD/OS
* Move the securelevel check before loading KLD's into linker_load_file(),archie2000-06-291-2/+10
| | | | | | | | instead of requiring every caller of linker_load_file() to perform the check itself. This avoids netgraph loading KLD's when securelevel > 0, not to mention any future code that may call linker_load_file(). Reviewed by: dfr
OpenPOWER on IntegriCloud