Commit Graph

249 Commits

Author SHA1 Message Date
pooka 87319696e5 Add a comment clarifying that in the succesful case the function
returns from the middle of the loop.
2007-10-02 12:01:17 +00:00
christos 861eaa84d8 - add debugging info to the remaining failure cases in execve1.
- use size_t where appropriate.
2007-09-20 20:51:38 +00:00
ad 63c4506184 Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
2007-08-15 12:07:23 +00:00
pooka 05ce20f4a0 Retire uvn_attach() - it abuses VXLOCK and its functionality,
setting vnode sizes, is handled elsewhere: file system vnode creation
or spec_open() for regular files or block special files, respectively.

Add a call to VOP_MMAP() to the pagedvn exec path, since the vnode
is being memory mapped.

reviewed by tech-kern & wrstuden
2007-07-22 19:16:04 +00:00
yamt f03010953f merge yamt-idlelwp branch. asked by core@. some ports still needs work.
from doc/BRANCHES:

	idle lwp, and some changes depending on it.

	1. separate context switching and thread scheduling.
	   (cf. gmcgarry_ctxsw)
	2. implement idle lwp.
	3. clean up related MD/MI interfaces.
	4. make scheduler(s) modular.
2007-05-17 14:51:11 +00:00
dsl b8fbaf8c4b Change the way that emulations locate files within the emulation root to
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-04-22 08:29:55 +00:00
matt 770557b66a If STACKALIGN is defined, use it instead of ALIGN. Some arches need a
stack more aligned that ALIGN will give.
2007-03-09 22:25:56 +00:00
ad c147748d84 - Make the proclist_lock a mutex. The write:read ratio is unfavourable,
and mutexes are cheaper use than RW locks.
- LOCK_ASSERT -> KASSERT in some places.
- Hold proclist_lock/kernel_lock longer in a couple of places.
2007-03-09 14:11:22 +00:00
dogcow 66b89c08f2 die, caddr_t, die. 2007-03-05 04:59:19 +00:00
thorpej 4f3d5a9cc0 TRUE -> true, FALSE -> false 2007-02-22 06:34:42 +00:00
cube 632ece3eaf Introduce a new member to struct emul, e_startlwp, to be used by
sys__lwp_create.  It allows using the said syscall under COMPAT_NETBSD32.

The libpthread regression tests now pass on amd64 and sparc64.
2007-02-19 15:10:02 +00:00
pavel 934634a18c Change the process/lwp flags seen by userland via sysctl back to the
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-17 22:31:36 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
elad 24d02b5648 style nit 2007-02-08 00:26:50 +00:00
rillig ff925d7fe2 typo. 2007-02-05 14:34:29 +00:00
elad 606687adb0 Use ndp->ni_cnd.cn_pnbuf, not epp->ep_ndp->ni_dirp, for the pathname
for Veriexec/PaX purposes.

(this is safe here because the nameiop is LOOKUP.)

Fixes part of PR/35278.
2006-12-23 17:23:51 +00:00
elad 368ec17e69 Remove the third argument from check_exec() and just check for ep_flags
in the exec_package to know if we need to use VERIEXEC_DIRECT or
VERIEXEC_INDIRECT.

Suggested by and okay yamt@
2006-12-20 11:35:29 +00:00
elad a84fee7faf Initial implementation of PaX Segvguard (this is still work-in-progress,
it's just to get it out of my local tree).
2006-11-22 02:02:51 +00:00
yamt 1a7bc55dcc remove some __unused from function parameters. 2006-11-01 10:17:58 +00:00
dogcow 372e6ef309 now that we have -Wno-unused-parameter, back out all the tremendously ugly
code to gratuitously access said parameters.
2006-10-17 18:21:29 +00:00
dogcow 2023789a40 More -Wunused fallout. sprinkle __unused when possible; otherwise, use the
do { if (&x) {} } while (/* CONSTCOND */ 0);
construct as suggested by uwe in <20061012224845.GA9449@snark.ptc.spbu.ru>.
2006-10-13 16:53:35 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
ad a0c8510a86 Single-thread updates to the process credential. 2006-07-30 21:58:11 +00:00
dogcow c959b3c4bd at the request of elad, as veriexec.h has returned, revert the changes
from 2006-07-25.
2006-07-26 09:33:57 +00:00
dogcow cc44d2fe07 mechanically go through and
s,include "veriexec.h",include <sys/verified_exec.h>,
as the former has apparently gone away.
2006-07-25 00:23:06 +00:00
elad 5d611badde some fixes:
- 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-24 16:37:28 +00:00
ad f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
elad a92c1615a4 deprecate the VERIFIED_EXEC option; now we only need the pseudo-device to
enable it. while here, some config file tweaks.

tons of input from cube@ (thanks!) and okay blymn@.
2006-07-22 10:34:26 +00:00
ad 2b79369c7e - Hold a reference to the process credentials in each struct lwp.
- Update the reference on syscall and user trap if p_cred has changed.
- Collect accounting flags in the LWP, and collate on LWP exit.
2006-07-19 21:11:37 +00:00
ad e7447d9340 - Always make p->p_cred a private copy before modifying.
- Share credentials among processes when forking.
2006-07-17 15:29:06 +00:00
elad b5d09ef065 okay, since there was no way to divide this to two commits, here it goes..
introduce fileassoc(9), a kernel interface for associating meta-data with
files using in-kernel memory. this is very similar to what we had in
veriexec till now, only abstracted so it can be used more easily by more
consumers.

this also prompted the redesign of the interface, making it work on vnodes
and mounts and not directly on devices and inodes. internally, we still
use file-id but that's gonna change soon... the interface will remain
consistent.

as a result, veriexec went under some heavy changes to conform to the new
interface. since we no longer use device numbers to identify file-systems,
the veriexec sysctl stuff changed too: kern.veriexec.count.dev_N is now
kern.veriexec.tableN.* where 'N' is NOT the device number but rather a
way to distinguish several mounts.

also worth noting is the plugging of unmount/delete operations
wrt/fileassoc and veriexec.

tons of input from yamt@, wrstuden@, martin@, and christos@.
2006-07-14 18:41:40 +00:00
elad 215bd95ba4 integrate kauth. 2006-05-14 21:15:11 +00:00
elad 31162c28c3 Coverity CID 1739: Plug leak. 2006-04-14 23:54:21 +00:00
cube 699fe710fb Rework the _lwp* and sa_* families of syscalls so some details can be
handled differently depending on the emulation.  This paves the way for
COMPAT_NETBSD32 support of our pthread system.
2006-03-29 23:02:31 +00:00
matt ce8489309f There is no need to use MALLOC/FREE when rebuilding the execsw array
due to LKM loading/unloading.  This is not performance critical.
2006-03-22 01:14:46 +00:00
christos a4495f4cec implement PT_SYSCALL 2006-03-05 07:21:37 +00:00
manu ee0c5b44de Add initial (but unfinished) COMPAT_LINUX32 for amd64. This is good enough so
that the i386 license manager part of amd64 version of Fluent works.

While I'm here, add SysV IPC to COMPAT_LINUX/amd64
2006-02-09 19:18:56 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
christos fae23817af back out the lwp portion of the previous commit which is not ready yet to
be committed.
2005-10-31 04:39:41 +00:00
christos cd2a437026 Don't clear unconditionally P_SUGID when we exec. Clear it only when the
real and effective user and group ids match. From Tavis Ormandy.
2005-10-31 04:31:58 +00:00
christos d2d5cc4265 Better debugging info on failure 2005-08-19 02:04:02 +00:00
junyoung fb1a9a3413 Use NULL where appropriate. 2005-08-05 11:14:32 +00:00
elad f73e4c7b31 Simplify previous commit. 2005-07-29 22:57:34 +00:00
elad 3c0a7f641b Use real executed program in logs instead of the script that was executed.
For example, this used to give false logs of matching fingerprint for
foo.sh while foo.sh don't have an entry, and the program executed (and
matching the fingerprint) is the interpreter - /bin/sh.
2005-07-29 22:37:11 +00:00
christos 1510fe1543 defopt verified_exec. 2005-07-16 22:47:18 +00:00
cube 355bcba766 Split sys_execve() and add execve1() that does most of the work, and takes
as an argument a function that will retrieve an element of the pointer
arrays in user space.  This allows COMPAT_NETBSD32 to share the code for
the emulated version of execve(2), and fixes various issues that came from
the slow drift between the two implementations.

Note:  when splitting up a syscall function, I'll use two different ways
       of naming the resulting helper function.  If it stills does
       copyin/out operations, it will be named <syscall>1().  If it does
       not (as it was the case for get/setitimer), it will be named
       do<syscall>.
2005-07-11 20:15:26 +00:00
christos ec1dc88c1d define syscall here. 2005-07-10 04:20:34 +00:00
christos df1b79805d don't declare syscall and syscall_intern. 2005-07-10 00:54:54 +00:00
elad 1b7133edad From marius@openbsd:
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-27 17:11:20 +00:00
elad 8ebc2e9bee From marius@openbsd:
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-06-26 19:58:29 +00:00