summaryrefslogtreecommitdiff
path: root/sys/kern/exec_script.c
AgeCommit message (Collapse)Author
2021-05-03Remove duplicate #ifdef block.fcambus
2020-03-23Fix typo in comment.pgoyette
2020-03-23LK_SHARED is OK for VOP_ACCESS().ad
2019-09-15adjust for new check_exec signature.christos
2019-01-27Merge the [pgoyette-compat] branchpgoyette
2018-09-03Rename min/max -> uimin/uimax for better honesty.riastradh
These functions are defined on unsigned int. The generic name min/max should not silently truncate to 32 bits on 64-bit systems. This is purely a name change -- no functional change intended. HOWEVER! Some subsystems have #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) even though our standard name for that is MIN/MAX. Although these may invite multiple evaluation bugs, these do _not_ cause integer truncation. To avoid `fixing' these cases, I first changed the name in libkern, and then compile-tested every file where min/max occurred in order to confirm that it failed -- and thus confirm that nothing shadowed min/max -- before changing it. I have left a handful of bootloaders that are too annoying to compile-test, and some dead code: cobalt ews4800mips hp300 hppa ia64 luna68k vax acorn32/if_ie.c (not included in any kernels) macppc/if_gm.c (superseded by gem(4)) It should be easy to fix the fallout once identified -- this way of doing things fails safe, and the goal here, after all, is to _avoid_ silent integer truncations, not introduce them. Maybe one day we can reintroduce min/max as type-generic things that never silently truncate. But we should avoid doing that for a while, so that existing code has a chance to be detected by the compiler for conversion to uimin/uimax without changing the semantics until we can properly audit it all. (Who knows, maybe in some cases integer truncation is actually intended!)
2018-06-30Fix module build.kre
Options SUIDSCRIPTS and FDSCRIPTS will be off for the module. If one (or both) should be enabled, add it to CPPFLAGSin the module Makefile.
2018-06-30defflag {SETUID,FD}SCRIPTSchristos
2018-04-27Canonicalize the interpreter path in #! scripts since check_exec() expectschristos
an absolute path, and we KASSERT if that's not the case later.
2014-09-05Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to getmatt
a correctly typed pointer.
2014-06-30Reorder two variables and fix some comments.maxv
2014-06-30If the interpreter is "", do not keep loading the script (which will latermaxv
fail), but return ENOEXEC directly. ok christos@
2014-06-23Use KASSERT() instead of #ifdef(DIAGNOSTIC). Clearer.maxv
2014-03-07c99 initializers for struct execswchristos
2014-02-21Revert rev1.38. The header already begins with EXEC_SCRIPT_MAGIC="#!".maxv
So it can't be ELFMAG="\177ELF" at the same time. ok christos@
2014-02-17Cosmetic; just replace whitespaces by tabsmaxv
2013-09-19exec modules need to be of the exec kindchristos
2010-11-19Introduce struct pathbuf. This is an abstraction to hold a pathnamedholland
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.
2010-06-24Clean up vnode lock operations pass 2:hannken
VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument. Welcome to 5.99.32. Discussed on tech-kern.
2010-05-02Remove the nameidata from struct exec_package. It was used only for twodholland
things: passing an argument to check_exec, which is better done explicitly, and handing back the resolved pathname generated by namei, which we can make an explicit slot for in struct exec_package instead. While here, perform some related tidyup, and store the kernel-side copy of the path to the executable as well as the pointer into userspace. (But the latter should probably be removed in the future.)
2008-11-19Make the emulations, exec formats, coredump, NFS, and the NFS serverad
into modules. By and large this commit: - shuffles header files and ifdefs - splits code out where necessary to be modular - adds module glue for each of the components - adds/replaces hooks for things that can be installed at runtime
2008-03-21Catch up with descriptor handling changes. See kern_descrip.c revisionad
1.173 for details.
2008-01-02use kmem_alloc instead of malloc.yamt
2007-12-31Remove systrace. Ok core@.ad
2007-12-14nuke the leprechaun from VOP_ACCESSpooka
Paul Lavoie, kern/37542
2007-11-26Remove the "struct lwp *" argument from all VFS and VOP interfaces.pooka
The general trend is to remove it from all kernel interfaces and this is a start. In case the calling lwp is desired, curlwp should be used. quick consensus on tech-kern
2007-04-22Change the way that emulations locate files within the emulation root todsl
avoid having to allocate space in the 'stackgap' - which is very LWP unfriendly. The additional code for non-emulation namei() is trivial, the reduction for the emulations is massive. The vnode for a processes emulation root is saved in the cwdi structure during process exec. If the emulation root the TRYEMULROOT flag are set, namei() will do an initial search for absolute pathnames in the emulation root, if that fails it will retry from the normal root. ".." at the emulation root will always go to the real root, even in the middle of paths and when expanding symlinks. Absolute symlinks found using absolute paths in the emulation root will be relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links inside the emulation root don't need changing). If the root of the emulation would be returned (for an emulation lookup), then the real root is returned instead (matching the behaviour of emul_lookup, but being a cheap comparison here) so that programs that scan "../.." looking for the root dircetory don't loop forever. The target for symbolic links is no longer mangled (it used to get the CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended). CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding TRYEMULROOT to the flags to NDINIT(). A lot of the emulation system call stubs could now be deleted.
2007-03-04Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.christos
2007-02-17Change the process/lwp flags seen by userland via sysctl back to thepavel
P_*/L_* naming convention, and rename the in-kernel flags to avoid conflict. (P_ -> PK_, L_ -> LW_ ). Add back the (now unused) LSDEAD constant. Restores source compatibility with pre-newlock2 tools like ps or top. Reviewed by Andrew Doran.
2007-02-09Merge newlock2 to head.ad
2006-12-20Remove the third argument from check_exec() and just check for ep_flagselad
in the exec_package to know if we need to use VERIEXEC_DIRECT or VERIEXEC_INDIRECT. Suggested by and okay yamt@
2006-07-26at the request of elad, as veriexec.h has returned, revert the changesdogcow
from 2006-07-25.
2006-07-25mechanically go through anddogcow
s,include "veriexec.h",include <sys/verified_exec.h>, as the former has apparently gone away.
2006-07-24some fixes:elad
- adapt to NVERIEXEC in init_sysctl.c. - we now need "veriexec.h" for NVERIEXEC. - "opt_verified_exec.h" -> "opt_veriexec.h", and include it only where it is needed.
2006-07-23Use the LWP cached credentials where sane.ad
2006-07-22deprecate the VERIFIED_EXEC option; now we only need the pseudo-device toelad
enable it. while here, some config file tweaks. tons of input from cube@ (thanks!) and okay blymn@.
2006-05-14integrate kauth.elad
2006-03-17don't use MALLOC with a non-constant size; use malloc instead.christos
2005-12-11merge ktrace-lwp.christos
2005-07-29#ifdef VERIFIED_EXECelad
2005-07-17catch up with verified exec defopt changes.christos
2005-07-16defopt verified_exec.christos
2005-06-27From marius@openbsd:elad
Fix an issue when scripts are executed under systrace where the argv[0] would be normalized, and hence break scripts that depend on how they were called.
2005-06-26From marius@openbsd:elad
Add an exec message so that whenever a set-uid/gid process executes a new image which we may control, the exec does not go by unnoticed.
2005-05-19Some changes in veriexec.elad
New features: - Add a veriexec_report() routine to make most reporting consistent and remove some common code. - Add 'strict' mode that controls how veriexec behaves. - Add sysctl knobs: o kern.veriexec.verbose controls verbosity levels. Value: 0, 1. o kern.veriexec.strict controls strict level. Values: 0, 1, 2. See documentation in sysctl(3) for details. o kern.veriexec.algorithms returns a string with a space separated list of supported hashing algorithms in veriexec. - Updated documentation in man pages for sysctl(3) and sysctl(8). Bug fixes: - veriexec_removechk(): Code cleanup + handle FINGERPRINT_NOTEVAL correctly. - exec_script(): Don't pass 0 as flag when executing a script; use the defined VERIEXEC_INDIRECT - which is 1. Makes indirect execution enforcement work. - Fix some printing formats and types..
2004-11-04Check to see if the script has an ELF header, and if so, return ENOEXEC.matt
2004-04-21kill sprintf, use snprintfitojun
2003-06-29Back out the lwp/ktrace changes. They contained a lot of colateral damage,fvdl
and need to be examined and discussed more.
2003-06-28Pass lwp pointers throughtout the kernel, as required, so that the lwpid candarrenr
be inserted into ktrace records. The general change has been to replace "struct proc *" with "struct lwp *" in various function prototypes, pass the lwp through and use l_proc to get the process pointer when needed. Bump the kernel rev up to 1.6V
2003-05-16use strlcpy. [fixed off-by-one in subr_prop.c]itojun