Commit Graph

358 Commits

Author SHA1 Message Date
christos
53627aeceb If you are going to dick around with p_stat, remember to put it
back so that spawn processes with attributes don't end up starting
up stopped!
XXX: pullup to 6.
2012-11-08 17:40:46 +00:00
christos
eac5a1b990 remove KERN_USRSTACK 2012-10-14 20:56:55 +00:00
christos
c6f0835de6 add KERN_USRSTACK (this is not dynamically defined for FreeBSD compatibility) 2012-10-13 15:35:55 +00:00
dholland
523ec9d4d8 Add missing newline to printf (in the disabled code for $ORIGIN). 2012-08-29 18:56:39 +00:00
christos
72e4156b86 revert racy vfork() parent-blocking-before-child-execs-or-exits code.
ok rmind
2012-07-27 20:52:49 +00:00
rmind
6d7c79596a fork1: fix use-after-free problems. Addresses PR/46128 from Andrew Doran.
Note: PL_PPWAIT should be fully replaced and modificaiton of l_pflag by
other LWP is undesirable, but this is enough for netbsd-6.
2012-07-22 22:40:18 +00:00
rmind
b10bf4690c Revert posix_spawn() clean up for now, there are some bugs. 2012-05-02 23:33:11 +00:00
rmind
0c217aec3a posix_spawn:
- Remove copy-pasting in error paths, use execve_free_{vmspace,data}().
- Move some code (both in the init and exit paths) out of the locks.
- Slightly simplify do_posix_spawn() callers.
- Add few asserts and comments.
2012-04-30 21:19:58 +00:00
martin
0ed1ffcc64 Fix leak in a posix_spawn error path, from Greg Oster. 2012-04-15 15:35:00 +00:00
martin
4e00857f25 Fix asynchronous posix_spawn child exit status (and test for it). 2012-04-09 19:42:06 +00:00
martin
94b761b6aa Rework posix_spawn locking and memory management:
- always provide a vmspace for the new proc, initially borrowing from proc0
   (this part fixes PR 46286)
 - increase parallelism between parent and child if arguments allow this,
   avoiding a potential deadlock on exec_lock
 - add a new flag for userland to request old (lockstepped) behaviour for
   better error reporting
 - adapt test cases to the previous two and add a new variant to test the
   diagnostics flag
 - fix a few memory (and lock) leaks
 - provide netbsd32 compat
2012-04-08 11:27:44 +00:00
elad
0c9d8d15c9 Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

    http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
    http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
    http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
2012-03-13 18:40:26 +00:00
martin
aec05724e5 Remove a KPREEMPT_ENABLE() in an error path I overlooked in the previous
change - pointed out by Manuel Bouyer.
While there, add a KASSERT() to make sure we have preemption enabled in
the success case.
2012-03-10 14:35:05 +00:00
martin
f9619b6218 Make sure the child of a posix_spawn operation is not preempted during
the times when it does not have any vm_space.
Should fix PR kern/46153.
2012-03-10 08:46:45 +00:00
christos
4ab990718f keep track of the original array length so we can pass it to kmem_free, from
enami
2012-02-21 04:13:22 +00:00
christos
222b58ad16 fix fae free'ing, from enami. 2012-02-21 03:44:54 +00:00
christos
ca439b8516 Posix spawn fixes:
- split the file actions allocation and freeing into separate functions
- use pnbuf
- don't play games with pointers (partially freeing stuff etc), only check
  fa and sa and free as needed using the same code.
- use copyinstr properly
- KM_SLEEP allocation can't fail
- if path allocation failed midway, we would be possibily freeing
  userland strings.
- use sizeof(*var) instead sizeof(type)
2012-02-20 18:18:30 +00:00
martin
6bde504952 More posix_spawn fallout:
Fix a kmem_alloc() call with zero size (PR kern/46038), allow file actions
to be passed, even if empty.
Rearange p_reflock locking for the child, avoid a double free in an
error case, avoid a memory leak in another error case - all pointed out
by yamt.
During blocking operations early in the child borrow the kernel vmspace
(as suggested by yamt).
2012-02-20 12:19:55 +00:00
rmind
ad12c77015 Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
2012-02-19 21:05:51 +00:00
martin
f4db024f0d Fix SDT_PROBE macro argument overlooked in argument renaming, noted by <chs> 2012-02-12 20:11:03 +00:00
martin
c6a7db15e9 Minor tweaks to posix_spawn error handling.
The standard allows "open" file actions for descriptors that are alreay
open, add support for that.
2012-02-12 13:14:37 +00:00
martin
f8c7c04bbe Add a posix_spawn syscall, as discussed on tech-kern.
Based on the summer of code project by Charles Zhang, heavily reworked
later by me - all bugs are likely mine.
Ok: core, releng.
2012-02-11 23:16:15 +00:00
matt
2210079e9b Add a hook for freeing an ep_emul_arg. Add a wrapper routine
(exec_free_emul_arg) to call the hook and then clear the ep_emul_arg
and ep_emul_arg_free members in the exec_package.
Change users/accessors to use these routines.
Approved by releng.
2012-02-03 20:11:53 +00:00
christos
3628cdc41a Add a macro to align the length of the stack, not the pointer itself, since
we always want the alignment to grow the length.
2012-01-25 18:26:26 +00:00
christos
dd23e71080 Use and define ALIGN() ALIGN_POINTER() and STACK_ALIGN() consistently,
and avoid definining them in 10 different places if not needed.
2012-01-24 20:03:36 +00:00
dholland
02a36e4e59 Revert Christos's accidental changes. 2011-12-04 15:12:07 +00:00
christos
bd022c3303 fix incomplete statement. 2011-11-24 19:55:22 +00:00
christos
4a6a144a44 make the diagnostic messages more informative. 2011-11-24 17:09:14 +00:00
tls
3afd44cf08 First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>.  This change includes
the following:

	An initial cleanup and minor reorganization of the entropy pool
	code in sys/dev/rnd.c and sys/dev/rndpool.c.  Several bugs are
	fixed.  Some effort is made to accumulate entropy more quickly at
	boot time.

	A generic interface, "rndsink", is added, for stream generators to
	request that they be re-keyed with good quality entropy from the pool
	as soon as it is available.

	The arc4random()/arc4randbytes() implementation in libkern is
	adjusted to use the rndsink interface for rekeying, which helps
	address the problem of low-quality keys at boot time.

	An implementation of the FIPS 140-2 statistical tests for random
	number generator quality is provided (libkern/rngtest.c).  This
	is based on Greg Rose's implementation from Qualcomm.

	A new random stream generator, nist_ctr_drbg, is provided.  It is
	based on an implementation of the NIST SP800-90 CTR_DRBG by
	Henric Jungheim.  This generator users AES in a modified counter
	mode to generate a backtracking-resistant random stream.

	An abstraction layer, "cprng", is provided for in-kernel consumers
	of randomness.  The arc4random/arc4randbytes API is deprecated for
	in-kernel use.  It is replaced by "cprng_strong".  The current
	cprng_fast implementation wraps the existing arc4random
	implementation.  The current cprng_strong implementation wraps the
	new CTR_DRBG implementation.  Both interfaces are rekeyed from
	the entropy pool automatically at intervals justifiable from best
	current cryptographic practice.

	In some quick tests, cprng_fast() is about the same speed as
	the old arc4randbytes(), and cprng_strong() is about 20% faster
	than rnd_extract_data().  Performance is expected to improve.

	The AES code in src/crypto/rijndael is no longer an optional
	kernel component, as it is required by cprng_strong, which is
	not an optional kernel component.

	The entropy pool output is subjected to the rngtest tests at
	startup time; if it fails, the system will reboot.  There is
	approximately a 3/10000 chance of a false positive from these
	tests.  Entropy pool _input_ from hardware random numbers is
	subjected to the rngtest tests at attach time, as well as the
	FIPS continuous-output test, to detect bad or stuck hardware
	RNGs; if any are detected, they are detached, but the system
	continues to run.

	A problem with rndctl(8) is fixed -- datastructures with
	pointers in arrays are no longer passed to userspace (this
	was not a security problem, but rather a major issue for
	compat32).  A new kernel will require a new rndctl.

	The sysctl kern.arandom() and kern.urandom() nodes are hooked
	up to the new generators, but the /dev/*random pseudodevices
	are not, yet.

	Manual pages for the new kernel interfaces are forthcoming.
2011-11-19 22:51:18 +00:00
reinoud
12590f04bf Improve diagnostics message on entry point too low/high checking 2011-09-16 21:02:28 +00:00
reinoud
7c13e88609 Also fix DPRINTF()'s for DEBUG_EXEC 2011-08-27 18:11:48 +00:00
reinoud
14ad4e1152 Fix DPRINTF()'s missing the extra parenteses 2011-08-27 18:07:10 +00:00
reinoud
4db0d938ff Enhance EXEC_DEBUG by also printing the UVM commands 2011-08-27 17:51:38 +00:00
jmcneill
1501db31c9 defflag DEBUG_EXEC 2011-08-26 19:07:13 +00:00
jmcneill
6051688a5b Fix a typo in r1.243: test for STACKALIGN not STACKLALIGN:
"If STACKALIGN is defined, use it instead of ALIGN.  Some arches need a
 stack more aligned that ALIGN will give."
2011-08-26 12:52:01 +00:00
reinoud
a6fda0ea96 Provide a better fix for the checks 2011-08-26 09:29:16 +00:00
reinoud
a6debd8fb7 Change aprint_verbose() to a normal printf() surrounded by #ifdef DIAGNOSTIC 2011-08-26 09:13:08 +00:00
reinoud
e5fe2f455a Fix check for VM_MIN_ADDRESS since it doesn't need to be a constant 2011-08-26 09:07:48 +00:00
christos
012b2b9c3c fix compilation for VM_MIN_ADDRESS == 0 2011-08-26 06:56:11 +00:00
reinoud
336984324e Move debug -> verbose 2011-08-25 19:54:30 +00:00
reinoud
f6a2add8fe On a verbose kernel boot show why executables are denied due to their start
adresses. This will hardly ever occure in real-life.
2011-08-25 19:14:07 +00:00
manu
9db30be448 First stage of support for Extended API set 2. Most of the think is
unimplemented, except enough of linkat(2) to hardlink to a symlink.

Everything new in headers is guarded #ifdef _INCOMPLETE_XOPEN_C063 since
some software (e.g.: xcvs in our own tree) will assume they can use openat(2)
when AT_FDCWD is defined. _INCOMPLETE_XOPEN_C063 will go away once support
will be completed.
2011-08-08 12:08:52 +00:00
matt
f3c47d398e Add some more MI hook points for PCU. Discard the PCU state at lwp_exit and
at exec time.  Before forking, save the PCU state so that cpu_lwp_fork
doesn't have.  Remove MD code which did that before.
2011-06-06 22:04:34 +00:00
alnsn
a739efc5b5 kern/42030 - tracking of file descriptors by ktrace/kdump 2011-06-01 21:24:59 +00:00
joerg
e958063324 Remove IRIX emulation 2011-04-26 16:36:40 +00:00
jakllsch
ec9ba6e38d Make debugging code compile. 2011-03-14 20:12:40 +00:00
christos
63a1920d77 fix debugging printfs. 2011-03-13 23:44:14 +00:00
joerg
48717cfc00 Refactor ps_strings access. Based on PK_32, write either the normal
version or the 32bit compat layout in execve1. Introduce a new function
copyin_psstrings for reading it back from userland and converting it to
the native layout. Refactor procfs to share most of the code with the
kern.proc_args sysctl handler.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
2011-03-04 22:25:24 +00:00
christos
1428cd07df better debugging messages. 2011-03-04 04:17:12 +00:00
joerg
20a3edc3f6 Ensure that the LWP private area has a consistent value after exec. 2011-03-01 18:53:10 +00:00