Home | History | Annotate | Download | only in kern
History log of /src/sys/kern/kern_module_vfs.c
RevisionDateAuthorComments
 1.19  20-Mar-2025  pgoyette One more `module' name formatting. Again, NFCI
 1.18  29-Jun-2021  dholland branches: 1.18.16;
Add containment for the cloning devices hack in vn_open.

Cloning devices (and also things like /dev/stderr) work by allocating
a struct file, stuffing it in the file table (which is a layer
violation), stuffing the file descriptor number for it in a magic
field of struct lwp (which is gross), and then "failing" with one of
two magic errnos, EDUPFD or EMOVEFD.

Before this commit, all callers of vn_open in the kernel (there are
quite a few) were expected to check for these errors and handle the
situation. Needless to say, none of them except for open() itself did,
resulting in internal negative errnos being returned to userspace.

This hack is fairly deeply rooted and cannot be eliminated all at
once. This commit adds logic to handle the magic errnos inside
vn_open; now on success vn_open returns either a vnode or an integer
file descriptor, along with a flag that says whether the underlying
code requested EDUPFD or EMOVEFD. Callers not prepared to cope with
file descriptors can pass NULL for the extra return values, in which
case if a file descriptor would be produced vn_open fails with
EOPNOTSUPP.

Since I'm rearranging vn_open's signature anyway, stop exposing struct
nameidata. Instead, take three arguments: an optional vnode to use as
the starting point (like openat()), the path, and additional namei
flags to use, restricted to NOCHROOT and TRYEMULROOT. (Other namei
behavior, e.g. NOFOLLOW, can be requested via the open flags.)

This change requires a kernel bump. Ride the one an hour ago.
(That was supposed to be coordinated; did not intend to let an hour
slip by. My fault.)
 1.17  27-Jan-2019  pgoyette branches: 1.17.16;
Merge the [pgoyette-compat] branch
 1.16  01-Jun-2017  chs branches: 1.16.8; 1.16.10;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.15  15-Jan-2017  maya use a bound string copy
 1.14  15-Mar-2016  pgoyette branches: 1.14.2;
Add debug messages to report all attempts to load modules (and their
plists) from the filesystem. Note that messages are displayed prior
to the actual load activity. Previous messages are still displayed
for success/failure reporting.

This is an interim solution to the issue in kern/15837 and should be
replaced (or enhanced) once there is an off-system logging capability.
 1.13  02-Dec-2014  pooka print kernel module path only in kernels which support paths
 1.12  14-Sep-2011  christos branches: 1.12.12; 1.12.30;
- don't if then else the same thing. print a more meaningful message
- don't leak a dictionary on failure
- minor KNF
 1.11  06-Aug-2011  mbalmer Do not not look for modules in the current working directory first. This is
to prevent from accidentally loading ./module.kmod when we actually wanted to
load module from the system module area.

To load a module from a filesystem path, the module name must contain at
least on path separator character (/), to load a module from the system
module areas, the name must not contain a path separator character:

modload ./mymod.kmod # loads mymod.kmod from the curren directory
modload mymod # loads mymod.kmod from the system module area
 1.10  28-Nov-2010  jnemeth Rename the autoloaded property list from <module>.prop to <module>.plist
as discussed on tech-kern.
 1.9  19-Nov-2010  dholland Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
 1.8  18-Nov-2010  jnemeth if autoloading check for a noautoload=true property and if found,
deny the autoload
 1.7  24-Jun-2010  hannken Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
 1.6  24-May-2010  pgoyette Move definition of module_load_vfs_vec from kern_module_vfs.c to
kern_module.c - keeps rump happy.

Thanks, pooka!
 1.5  24-May-2010  pgoyette Clean up kern_module.c rev 1.66, thanks to pooka@ for review & suggestions
 1.4  04-Apr-2010  jnemeth don't leak a vnode and don't call namei (implicitly) twice
 1.3  16-Feb-2010  dholland branches: 1.3.2; 1.3.4;
Don't inspect vn_stat() results until after checking that it succeeded.
If anyone's been seeing random "File too large" results from module loading,
this should fix it.
 1.2  19-Jan-2010  pooka branches: 1.2.2;
Rename a few routines from _file() to _vfs() for consistency.
Ride 5.99.24 bump.
 1.1  18-Nov-2009  pooka * make it possible to include kern_module in a kernel without vfs
support, i.e. move vfs functionality to a separate module
(kern_module_vfs.c)
* make module proplist size an MI constant (now 8k) instead of PAGE_SIZE
* change some error values to something else than the karmic EINVAL
 1.2.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.2.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.3.4.3  05-Mar-2011  rmind sync with head
 1.3.4.2  03-Jul-2010  rmind sync with head
 1.3.4.1  30-May-2010  rmind sync with head
 1.3.2.3  11-Aug-2010  yamt sync with head.
 1.3.2.2  11-Mar-2010  yamt sync with head
 1.3.2.1  16-Feb-2010  yamt file kern_module_vfs.c was added on branch yamt-nfs-mp on 2010-03-11 15:04:17 +0000
 1.12.30.4  28-Aug-2017  skrll Sync with HEAD
 1.12.30.3  05-Feb-2017  skrll Sync with HEAD
 1.12.30.2  19-Mar-2016  skrll Sync with HEAD
 1.12.30.1  06-Apr-2015  skrll Sync with HEAD
 1.12.12.1  03-Dec-2017  jdolecek update from HEAD
 1.14.2.1  20-Mar-2017  pgoyette Sync with HEAD
 1.16.10.1  10-Jun-2019  christos Sync with HEAD
 1.16.8.1  08-Jul-2018  pgoyette Use SET, CLR, ISSET macros from types.h

NFCI
 1.17.16.1  01-Aug-2021  thorpej Sync with HEAD.
 1.18.16.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed