Commit Graph

8924 Commits

Author SHA1 Message Date
uebayasi
82d46164cd execve_runproc: Isolate emul specific code into a function. 2014-04-20 00:20:01 +00:00
uebayasi
f207cc4217 copyinargs: Shorten a local var name. 2014-04-19 23:00:27 +00:00
uebayasi
ea85945d7a copyinargs: Plug theoretical memory leak when fakearg is too long.
Pointed out & reviewed by Maxime Villard.
2014-04-19 22:59:08 +00:00
maxv
dc8c3423b2 'error' is not set on failure. This is a true bug: everything is freed
and unlocked while zero is returned. Since there's no error, execve_runproc()
will get called and will try to use those freed things.

PS: This bug was here before uebayasi@'s changes
2014-04-18 11:44:31 +00:00
uebayasi
a969a4cf8a calcargs: Correct the size of "argc" in the stack size calculation.
(The old code has worked because it is compensated by wrong size calculation
of "auxinfo" (multiplied by sizeof(void *)).)
2014-04-18 06:59:32 +00:00
maxv
4a1b3781e1 Memory leak (only triggerable from root).
ok christos@
2014-04-18 05:22:13 +00:00
christos
fa910fdab6 CID/1203196: Don't confuse coverity with out of bounds access 2014-04-17 16:14:22 +00:00
maxv
cf89d4e5af Some fs's - like kernfs - set their vfs_min_mount_data to zero. Add a check
to prevent an (un)privileged user from requesting a zero-sized allocation
(and thus a panic).
2014-04-16 19:25:28 +00:00
maxv
23f76b6d00 An (un)privileged user can easily make the kernel dereference a NULL
pointer.

The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).

ok christos@
2014-04-16 18:55:17 +00:00
uebayasi
c3b49b4f57 execve_runproc: Isolate vmcmd execution code into a function. 2014-04-16 02:22:38 +00:00
uebayasi
acaa1e700b execve_runproc: Isolate path / commandname (proc:p_comm) related code into a function. 2014-04-16 01:30:33 +00:00
uebayasi
532bc286ec execve_runproc: Isolate new stack arg filling code into a function. 2014-04-15 17:06:21 +00:00
uebayasi
e4f9e005a5 execve_runproc: Isolate ps_strings filling code into a function. 2014-04-15 16:44:57 +00:00
uebayasi
0244fbfc39 execve_runproc: Simplify &argc address calc. The set of (argc, argv, ...)
is located just "behind" the initial SP.  SHRINK, then ALLOC, and you get
&argc.
2014-04-15 16:13:04 +00:00
uebayasi
9605f3cc61 exec_loadvm: Isolate stack size calc logic into separate functions. 2014-04-15 15:50:16 +00:00
hannken
2f1e07219a Fix a deadlock where one thread exits, enters fstrans_lwp_dtor()
and wants fstrans_lock.  This thread holds the proc_lock.
Another thread holds fstrans_lock and runs pserialize_perform().
As the first thread holds the proc_lock, timeouts are blocked and
the second thread blocks forever in kpause().

Change fstrans_lwp_dtor() to invalidate, but not free its info
structs.  No need to take fstrans_lock.

Change fstrans_get_lwp_info() to reuse invalidated info before
trying to allocate a new one.
2014-04-15 09:50:45 +00:00
maxv
05b3bfa0ba There's no need for this NULL-check. 2014-04-15 06:14:55 +00:00
uebayasi
3d725db397 copyinargs: Redo previous; if given fakearg is longer than arg buf (which is
very unlikely to happen), there's no point to continue with truncated arg.
Just give up and return E2BIG.
2014-04-14 13:14:38 +00:00
uebayasi
dd3e806542 copyinargs: Replace a hand-written string copy loop with strlcpy(3). Carefully
reuse return value of strlcpy(3) to iterate.
2014-04-14 05:39:19 +00:00
uebayasi
4adfcd2c94 Revert braces. 2014-04-13 12:11:01 +00:00
uebayasi
eecddf1604 copyinargs: Refactor. Share code. 2014-04-13 09:19:42 +00:00
uebayasi
35b479ac55 execve_loadvm: Move long code block reading passed arguments() into a function.
This needs further clean up.  (See the XXX comment.)  No functional changes.
2014-04-13 06:03:49 +00:00
uebayasi
04729d8900 execve_runproc: Correct thinko in Rev. 1.386; the new SP always points to
after (higher adderss) argc/argv/env/aux/strings regardless of stack growing
direction .  Machines with grow-up stack will detect the top of
argc/argv/env/aux/strings by the address of *argv[] via ps_strings:ps_argvstr.

This means that old comments about RTLD_GAP are all obsolete.

With help from Nick Hudson.
2014-04-12 15:08:56 +00:00
uebayasi
c1047adce3 Don't #define DEBUG_EXEC. 2014-04-12 07:38:32 +00:00
uebayasi
d01b6ecafe execve_runproc: Refactor debug code. 2014-04-12 07:33:51 +00:00
uebayasi
93fb83ebaa execve_runproc: Move a long code block handling credential into a separate
function.  No functional changes.
2014-04-12 06:31:27 +00:00
uebayasi
763d7b32d6 execve_runproc: Unbreak __MACHINE_STACK_GROWS_UP machines. Clarify the stack
address allocation code.  Summarize an awful big comment about the _rtld()
"gap".

(The log message in Rev. 1.384 was wrong; the new stack address is passed
not via the 3rd register argument, but via the SP.  The 3rd is for ps_strings.)
2014-04-12 05:25:23 +00:00
uebayasi
7dd91721cc Reorder a new lines. Comments. 2014-04-11 18:02:33 +00:00
uebayasi
4282002059 execve_runproc: The stack address passed to the newly execve()'ed process,
via the 3rd register argument, always points to the stack base address (==
minsaddr (min stack address) + ssize (stack size)).  Clarify that.
2014-04-11 17:28:24 +00:00
uebayasi
8ab74c3b1b execve_runproc: Reorder a few local vars. Avoid reuse. No functional changes. 2014-04-11 17:06:02 +00:00
uebayasi
6770193e9c Clarify stack size calculation in copyargs(). Comments. 2014-04-11 11:49:38 +00:00
uebayasi
8f07d0cf93 Clean up assertions. 2014-04-11 11:32:14 +00:00
uebayasi
5dcee2c64e Protect not only proc::p_flag but also lwp::l_ctxlink and proc::p_acflag with
proc:p_lock.
2014-04-11 11:21:29 +00:00
uebayasi
5ddf7749cf Try to decrypt stack size calculation code in execve_loadvm().
No functional changes.  Two potential miscalculations remain.
2014-04-11 11:11:06 +00:00
uebayasi
11c21c773e Cache struct exec_package * for readability. No functional changes. 2014-04-11 02:27:20 +00:00
pooka
885b424da9 regen 2014-04-09 23:57:26 +00:00
pooka
9f45fed20c rump kernel wrappers for aio syscalls 2014-04-09 23:55:37 +00:00
pooka
0bb4e2ffe3 properly handle forward declarations for pointerpointer arguments 2014-04-09 23:50:45 +00:00
rjs
752c60b211 whitespace. 2014-04-07 17:02:15 +00:00
seanb
6bcc34c970 Fix a case where an erroneous EAGAIN was returned out of recvmmsg.
This occured when some, but not all of the mmsg array members
were filled with data from a non-blocking socket.
PR kern/48725
2014-04-07 15:35:23 +00:00
christos
6accf143de Kernel portion of the multiple ptyfs mount support. Protocol changed
between kernel and module, so bump. (Ilya Zykov)
2014-04-04 18:11:58 +00:00
maxv
18ff15fb2d Limit check for 'data_len'. Otherwise a (un)privileged user can easily
panic the system by passing a huge size.

ok christos@
2014-04-04 06:47:02 +00:00
para
608fba6393 make condition for ENOMEM consistent with allocation requirement 2014-04-02 18:09:10 +00:00
matt
790372329e If we are writing PN_XNUM or more phdrs, include one section header and
encode the real # of sections in its sh_info.
2014-04-02 17:19:49 +00:00
para
c28aad1c2f bt_refill is and must be called with VM_NOSLEEP set, assert this
fix error path if pool_get returns NULL
2014-04-02 16:14:50 +00:00
seanb
f9c6e7aeaa len argument to strlcpy() was incorrect when copying
out AF_LOCAL sockets in sysctl helper.  The entire
buffer wasn't available since sun_path member is not
at offset 0 in struct sockaddr_un.
2014-04-02 15:35:45 +00:00
maxv
687880ac6a Style 2014-03-29 09:31:11 +00:00
ozaki-r
6ac95d35b1 Fix unused variable 'mp' 2014-03-28 11:55:09 +00:00
christos
33baebc2e5 explain how a printf might happen (since it has bitten more than one person) 2014-03-27 21:09:33 +00:00
christos
a9253db65e From Ilya Zykov:
- ifdef out some code that is only used for NO_DEV_PTM
- pass the mountpoint instead of the ptm structure to the implementation
  dependent (ptyfs or bsdpty) functions.
- add a function to return the correct ptyfs mountpoint for the current lwp
2014-03-27 17:31:56 +00:00
christos
968c5f53d8 in the bsdpty allocvp flavor, call the bsdpty mkname directly, since it is
the only one possible to be valid (Ilya Zykov)
2014-03-26 21:29:54 +00:00
christos
e9ba8bc5a2 remove {v,}sprintf 2014-03-26 18:03:47 +00:00
macallan
00c16ffd7f snprintf -> vsnprintf in cpu_setmodel()
now this can actually work
hi christos
2014-03-25 12:50:53 +00:00
christos
2788907516 - create cpu_{g,s}etmodel() and hide cpu_model from direct access. 2014-03-24 20:07:40 +00:00
hannken
f3cf481632 - Make VI_XLOCK, VI_CLEAN and VI_LOCKSHARE private to kern/vfs_*.c.
- Make vwait() static.
- Add  vdead_check() to check a vnode for being or becoming dead.

Discussed on tech-kern.

Welcome to 6.99.38
2014-03-24 13:42:40 +00:00
christos
f363da3aa0 fix unused 2014-03-23 02:56:33 +00:00
maxv
2632b9d940 Fix a potential - but very unlikely - NULL pointer dereference.
(it does not introduce a new error code for open(), since
 pathbuf_copyin() is already there and can return ENOMEM)

Found by my code scanner.
2014-03-22 08:15:25 +00:00
maxv
d8a274dfb9 Small changes:
- rename elf_load_file() to elf_load_interp()
 - use the correct type for 'nused'
 - remove useless cases
 - reorder a kmem_alloc

ok christos@
2014-03-22 07:27:21 +00:00
mlelstv
43b8706dc0 Incorrect use of pointer arithmetic.
CID 1193195:  Extra sizeof expression
2014-03-20 06:48:22 +00:00
christos
52813a4e8e fix leak on error from pty_fill_ptmget (Ilya Zykov) 2014-03-19 18:11:17 +00:00
hannken
b349ee43ab Operations vmark(), vunmark() and vismarker() have been replaced by
vfs_vnode_iterator_*(), remove them.

Document vfs_vnode_iterator_*().

Make VI_MARKER private to vfs_vnode.c, vfs_mount.c and unfortunately
to ufs/lfs/lfs_segment.c.

Welcome to 6.99.37
2014-03-18 10:21:47 +00:00
hannken
618ee03549 Change sysctl_kern_vnode() to use vfs_vnode_iterator. 2014-03-17 09:28:37 +00:00
hannken
ed193ed61b Add fstrans_startnowait()/fstrans_done() to vrele_thread(). 2014-03-17 09:27:37 +00:00
maxv
7c09916210 Remove the 'prot' argument from elf_load_psection(). It is not used
outside, and can be declared locally. Clearer.

ok christos@
2014-03-16 07:57:25 +00:00
dholland
a68f9396b6 Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
2014-03-16 05:20:22 +00:00
pooka
c9bffc6f73 regen: time/timer related syscalls for rump kernels 2014-03-14 00:56:37 +00:00
pooka
527bb3b75d Add rump kernel syscall wrapper flag for a bunch of time-related
syscalls (nanosleep, clock_gettime, etc.).  These are mostly intended
for situations where a rump kernel runs on an OS-less host.
2014-03-14 00:52:08 +00:00
pooka
1ac307e403 kill undesirable #ifndef _RUMPKERNEL 2014-03-11 20:32:05 +00:00
pooka
b05633df66 kill undesirable "#ifdef _RUMPKERNEL" 2014-03-11 20:26:08 +00:00
matt
bbe1552068 Tell where the corrruption was encountered in the panic message. 2014-03-07 16:36:32 +00:00
matt
dbd8c999e4 Remove spurious . 2014-03-07 01:55:01 +00:00
christos
54b7adb159 c99 initializers for struct execsw 2014-03-07 01:33:43 +00:00
matt
ab77483fb9 add ep_entryoffset to exec_package so one can calculate the relocabase
of an ET_DYN image.
2014-03-06 09:30:37 +00:00
hannken
72439b7dc8 Current support for iterating over mnt_vnodelist is rudimentary. Every
caller has to care about list and vnode mutexes, reference count being zero,
intermediate vnode states like VI_CLEAN, VI_XLOCK, VI_MARKER and so on.

Add an interface to iterate over a vnode list:

void vfs_vnode_iterator_init(struct mount *mp, struct vnode_iterator **marker)
void vfs_vnode_iterator_destroy(struct vnode_iterator *marker)
bool vfs_vnode_iterator_next(struct vnode_iterator *marker, struct vnode **vpp)

vfs_vnode_iterator_next() returns either "false / *vpp == NULL" when done
or "true / *vpp != NULL" to return the next referenced vnode from the list.

To make vrecycle() work in this environment change it to

bool vrecycle(struct vnode *vp)

where "vp" is a referenced vnode to be destroyed if this is the last reference.

Discussed on tech-kern.

Welcome to 6.99.34
2014-03-05 09:37:29 +00:00
dsl
4af555d7e1 When converting out of range 64bit sysctl values to 'int' (because of
an 'int' sized read) don't assume that sizeof (int) is 4.
2014-03-01 17:27:48 +00:00
riastradh
84bbdd5611 Kick on-demand entropy sources in rndsinks_distribute.
Partial workaround for indefinite hangs when entropy is scarce or
buffered up.  We need to do more to handle entropy that has been
buffered up -- see the comment for details -- but this will help for
now.

Problem noted by pooka.
2014-03-01 14:15:15 +00:00
skrll
dd7bb1e0a8 G/C sys/simplelock.h includes 2014-02-28 10:16:51 +00:00
dsl
7b1adb697e Allow CTLTYPE_INT and CTLTYPE_QUAD to be read and written as either 4 or 8
byte values regardless of the type.
64bit writes to 32bit variables must be valid (signed) values.
32bit reads of large values return -1.
Amongst other things this should fix libm's code that reads machdep.sse
  as a 32bit int, but I'd changed it to 64bit (to common up some code).
2014-02-27 22:50:52 +00:00
hannken
2b6ec89863 The current implementation of vn_lock() is racy. Modification of
the vnode operations vector for active vnodes is unsafe because it
is not known whether deadfs or the original file system will be
called.

- Pass down LK_RETRY to the lock operation (hint for deadfs only).

- Change deadfs lock operation to return ENOENT if LK_RETRY is unset.

- Change all other lock operations to check for dead vnode once
  the vnode is locked and unlock and return ENOENT in this case.

With these changes in place vnode lock operations will never succeed
after vclean() has marked the vnode as VI_XLOCK and before vclean()
has changed the operations vector.

Adresses PR kern/37706 (Forced unmount of file systems is unsafe)

Discussed on tech-kern.

Welcome to 6.99.33
2014-02-27 16:51:37 +00:00
hannken
d940ddcc62 Currently dead vnodes still reside on the vnodelist of the file system
they have been removed from.

Create a "dead mount" that takes dead vnodes until they get freed.

Discussed on tech-kern.
2014-02-27 13:00:06 +00:00
maxv
ff3f3d5c44 We have to ensure the string is NUL-terminated and of the expected
length to avoid copying uninitialized data.

ok christos@
2014-02-27 09:58:05 +00:00
riastradh
98ff99631b Fix bits/bytes mixup in rnd_getmore.
Remove some needless casts and fix format directives while here.

Bit/byte mixup noticed by pooka.
2014-02-25 23:15:43 +00:00
pooka
4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
justin
69dd91d347 Add kern.{ostype,osrelease,osrevision,version} kern.domainname,
kern.rawpartition sysctl support to rump kernel.
Moved the sysctl support that is shared between rump and normal
kernels to init_sysctl_base.c as rump cannot use init_sysctl.c
in order to avoid code duplication. Agreed with pooka@.
2014-02-25 01:02:42 +00:00
mlelstv
5d1221e5bf ttioctl always gets a valid lwp reference. Replace attempt to handle a NULL
reference in only one place with a regular assertion.
2014-02-23 07:54:43 +00:00
maxv
33cfa4fef0 Simplify error path.
ok christos@
2014-02-22 07:53:16 +00:00
maxv
0ff9025533 Revert rev1.38. The header already begins with EXEC_SCRIPT_MAGIC="#!".
So it can't be ELFMAG="\177ELF" at the same time.

ok christos@
2014-02-21 08:11:59 +00:00
maxv
c14dea48b0 Properly check the section size to avoid out-of-bound reads. The
computed size must be the exact same size that is indicated in
sh_size.

ok agc@ christos@
2014-02-21 07:47:02 +00:00
maxv
c22b5e2a12 We need VMCMDs for a binary and its interpreter, so make sure we have
at least one VMCMD. This also prevents the kernel from using an
uninitialized pointer as entry point for the execution.

From me and Christos

ok christos@
2014-02-19 15:23:20 +00:00
para
e3e2479f22 replace vmem(9) custom boundary tag allocation with a pool(9) 2014-02-17 20:40:06 +00:00
maxv
113995d235 Cosmetic; just replace whitespaces by tabs 2014-02-17 19:29:46 +00:00
maxv
03cdabd0dd Small cleanup:
- make elf_load_file() and elf_load_psection() static
 - make loops consistent
 - 'nload' is not used - see rev1.24
 - 'ap' is not used in elf_load_file()

ok agc@ christos@
2014-02-16 17:46:36 +00:00
njoly
9f120b8d09 Remove argument name from prototype. 2014-02-15 22:32:16 +00:00
christos
6f9879ba7d initialize offset to 0 (Maxime Villard) 2014-02-15 17:39:03 +00:00
maxv
c11747d060 Remove the last argument of elf_check_header(). It is easier - and faster - to
check the e_type field in the calling function. Other BSD's already do this.

ok christos@
2014-02-15 16:17:01 +00:00
christos
df9581b1ee explain why the innocent sigaction1 call now works. 2014-02-14 16:35:40 +00:00
christos
b9e9a610e4 Don't check trampolines for SIG_DFL or SIG_IGN since they are not used.
From gimpy.
2014-02-14 16:35:11 +00:00
maxv
1a33eb9d1c Fix memory leak.
ok christos@ agc@
2014-02-14 07:30:07 +00:00
martin
47869c118a Unlock correct mutex in an error path.
PR kern/48592 from Kengo NAKAHARA.
2014-02-12 20:20:15 +00:00
maxv
52673c8d59 Reorder code to avoid using an uninitialized variable: if
sysctl_copyin fails, 'tmp' is not initialized. This bug is
harmless since only the return value will be different;
it does not expose kernel memory unless diagnostic is enabled.

ok agc@ martin@
2014-02-09 14:51:13 +00:00
hannken
97834f7ba0 Change vnode operation lookup to return the resulting vnode *vpp unlocked.
Change cache_lookup() to return an unlocked vnode.

Discussed on tech-kern@

Welcome to 6.99.31
2014-02-07 15:29:20 +00:00
hannken
f106eaceb6 Change vnode operation lookup to return the resulting vnode *vpp unlocked.
Change cache_lookup() to return an unlocked vnode.

Discussed on tech-kern@
2014-02-07 15:26:42 +00:00
msaitoh
62342f9d4d s/mesage/message/ 2014-02-07 11:51:00 +00:00
riastradh
6c0ad81464 __HAVE_ATOMIC_AS_MEMBAR is spelled with two leading underscores.
This underscores the need to replace this error-prone cpp API by
unconditionally defined {pre,post}atomic_membar_*.

This change should only remove unnecessary membar_producers on x86.
2014-02-06 03:47:16 +00:00
martin
65095476e3 Cosmetics: return is an operator, not a function: remove (). 2014-02-02 14:50:46 +00:00
martin
2934fa70dc Limit the amount of kernel memory a posix_spawn syscall can use (for handling
the file action list) by limiting the maximum number of file actions to
twice the current file descriptor limit.
Fix a few bugs in the support functions and document the new limit.
From Maxime Villard.
2014-02-02 14:48:57 +00:00
dogcow
437b1ce30d Delete duplicate symbol definition introduced in 1.371. Now builds again. 2014-02-02 08:25:23 +00:00
manu
70aead41ff Add EMUL_NATIVEROOT so that native binaries can be told to search an
"emulation" directory before the real root. This makes easier to test
an amd64 kernel on the top of an i386 root filesystem prior a full
migration.
2014-02-02 04:28:42 +00:00
yamt
57688c9a9e tty_pty: add CTASSERTs to document assumptions 2014-01-29 02:38:48 +00:00
martin
30a98d4423 Mark a diagnostic only variable 2014-01-28 12:50:54 +00:00
christos
9477bafa18 kill the topdown flag only if we succeed. 2014-01-25 23:58:41 +00:00
christos
f5fe8e85e2 fix unused 2014-01-25 21:11:20 +00:00
christos
840bc63029 __USING_TOPDOWN_VM is no more, __USE_TOPDOWN_VM... 2014-01-25 19:44:11 +00:00
christos
cee146c035 Add compat_10, open NULL == open "." 2014-01-25 17:24:45 +00:00
christos
f4956d9c6a a.out binaries can't handle topdown. 2014-01-25 05:15:05 +00:00
christos
1525b564a7 expose do_open 2014-01-25 02:28:31 +00:00
skrll
c92b6b82d2 Pass PCU_LOADED to pcu_state_load in the "this CPU already has our PCU
state loaded" of pcu_load.

ok, gimpy@ and rmind@
2014-01-23 17:32:03 +00:00
hannken
04c776e5c8 Change vnode operations create, mknod, mkdir and symlink to return
the resulting vnode *vpp unlocked.

Discussed on tech-kern@

Welcome to 6.99.30
2014-01-23 10:13:55 +00:00
hannken
ac59f9acc5 Change vnode operations create, mknod, mkdir and symlink to return
the resulting vnode *vpp unlocked.

Discussed on tech-kern@
2014-01-23 10:11:55 +00:00
hannken
0fa0d339bd Change cache_prune() to test for end-of-list before testing for an
invalid entry.  Prevents a lifelock when the end-of-list marker
gets invalid while scanning the list and all entries are recent.
2014-01-20 07:47:22 +00:00
hannken
1139274440 Change vnode operations create, mknod, mkdir and symlink to keep the
directory node dvp locked on return.

Discussed on tech-kern@

Welcome to 6.99.29
2014-01-17 10:55:01 +00:00
hannken
10a361faf8 Change vnode operations create, mknod, mkdir and symlink to keep the
directory node dvp locked on return.

Discussed on tech-kern@
2014-01-17 10:52:36 +00:00
pooka
73822fbe26 Put cprng sysctls into subr_cprng.c. Also, make sysctl_prng static
in subr_cprng and get rid of SYSCTL_PRIVATE namespace leak macro.

Fixes ping(8) when run against a standalone rump kernel due to appearance
of the kern.urandom sysctl node (in case someone was wondering ...)
2014-01-17 02:12:48 +00:00
christos
2b043c75b6 eliminate use of bsd.sys.mk from Makefiles 2014-01-16 01:15:32 +00:00
hannken
29148b903d Support for vnode operation versioning. Allow a new keyword "VERSION"
in the description so "VERSION 2" will change the name of the argument
from vop_XXX_args to vop_XXX_v2_args.
2014-01-13 12:07:55 +00:00
joerg
c9ec0f85a6 Revert, breaks the build due to missing rumpns_delay in librump.so. 2014-01-12 00:29:15 +00:00
christos
71826933a0 Sleep 10 seconds before rebooting due to panic()
To give an opportunity to screencap a panic(), or pause a VM to attach
a debugger.  (Richard Hansen)
2014-01-11 17:07:45 +00:00
christos
b4a250d75c Reorder code to avoid use-after-free on error. From Maxime Villard 2014-01-11 16:31:20 +00:00
dsl
ff2955473b Re-instate the zero length sections in elf core dumps (they probably help
describe the process memory layout).
Fudge the a.out core code to not dump the entire contents.
I'm not sue that anything can read a.out core files - more progress might
  be made on such dumps by converting the a.out file to elf!
2014-01-07 07:59:03 +00:00
dsl
3dacf18540 Fix previous slightly differently.
No need to have an extra variable and to write to the list head.
2014-01-05 09:13:18 +00:00
mrg
dd411234d3 avoid use-after-free in *coredump().
fixes kernel crashes during coredump on sparc64.
2014-01-05 00:53:53 +00:00
dsl
95739e63cd Remove __HAVE_PROCESS_XFPREGS and add the extra parameter for the size
of the fp save area to all the process_read_fpregs() and
  process_write_fpregs() functions.
None of the functions have been modified to use the new parameters.
The size is set for all the writes, but some of the arch-specific reads
  just pass NULL.
The amd64 (and i386) need variable sized fp register save areas in order
  to support AVX and other enhanced register areas.
These functions are rarely called - so the extra argument won't matter.
2014-01-04 00:10:02 +00:00
dsl
4adfd474c1 Fix bug in previous (panic during process core dump).
Change the interface to ELFNAMEEND(coredump_savenote) so that the caller
  doesn't need to know the type of the elf note header.
Simplifies the calling code somewhat.
2014-01-03 21:34:40 +00:00
dsl
825d1920ba There is no need for uvm_coredump_walkmap() to explicity pass the proc_t
pointer to the calller's function.
If the code needs the process its address can be placed in the caller's
  cookie.
2014-01-03 21:12:18 +00:00
dsl
d773820bd9 Instead of generating all the 'note' sections twice (and hoping that the
'fast path' size on the first path matches the actual size on the second)
  save all the notes (mostly the cpu registers for all the LWPs) in
  malloced memory on the first pass.
Sanity check that the number of memory segments matches written matches
  the count obtained earlier. If gcore() is used they could differ.
  (Not sure that returning ENOMEM is ideal, but it is better than a crash.)
2014-01-03 20:52:47 +00:00
christos
87fb4a985c Simplify error path and fix typos. From Maxime Villard and me. 2014-01-03 15:49:49 +00:00
dsl
7a743f3de6 Minor changes to the process coredump code.
- Add some extra comments.
- Add some XXX comments because the process state might not be stable,
- Add uvm_coredump_count_segs() to simplify the calling code.
- uvm code now only returns non-empty sections/segments.
- Put the 'iocookie' into the 'cookie' block passed to uvm_coredump_walkmap()
  instead of passing it through as an additional parameter.
amd64 can still generate core dumps that gdb can read.
2014-01-03 15:15:02 +00:00
dsl
be74e0a9c9 Change the type of the 'cookie' that holds the state of the core dump file
from 'void *' to the actual type 'struct coredump_iostate *'.
In most of the code the contents of the structure are still unknown.
This just stops the wrong type of pointer being passed to the 'void *'
parameter.
I hope I've found everything, amd64 GENERIC and i386 GENERIC & ALL compile.
2014-01-01 18:57:15 +00:00
christos
54a8b0e862 replace strcpy with copystr and remove useless strcpy (Maxime Villard) 2013-12-24 14:47:04 +00:00
skrll
be521dde4c Remove local getsn and use cngetsn. 2013-12-23 15:34:16 +00:00
skrll
04e9e004ed Check interp after reading it. Checking newly allocated memory doesn't
work.

Hi Christos.
2013-12-21 17:44:33 +00:00
christos
39826d358b Consistency checks for the length of the interpreter (the length includes
the trailing NUL): make sure it is not empty and has the proper length.
From Maxime Villard
2013-12-21 14:41:02 +00:00
mlelstv
757ba59472 cpu_infos is a NULL terminated array, not an array followed by a 0 byte. 2013-12-19 23:36:07 +00:00
pgoyette
2b1203b7ab Make the auto-unload timeout configurable via sysctl, and if the timeout
is set to zero, disable all auto-unloads (even those that were "scheduled"
previously).
2013-12-15 21:09:50 +00:00
pgoyette
4a5c98c1a5 Add SYS_compat_60__lwp_park to the list of syscalls that can be resolved by loading kernel modules.
This seems to address my PR kern/48027
2013-12-14 06:27:57 +00:00
pooka
ef738750b7 reregengen 2013-12-11 09:45:01 +00:00
pooka
e69be3f980 create rump kernel wrapper for utrace() too 2013-12-11 09:40:56 +00:00
pooka
4bb2a888c3 regen 2013-12-09 21:13:21 +00:00
pooka
8dd50f0fc0 one newline is enough 2013-12-09 21:12:45 +00:00
pooka
cb1b7ccb56 need string.h now for !_KERNEL 2013-12-09 21:11:15 +00:00
pooka
a32f91a34e regen 2013-12-09 19:19:39 +00:00
pooka
d5af12a417 Initialize the syscall "frame" to 0 before setting parameters.
Otherwise things which treat syscall parameters as register_t (like
ktrace) will encounter garbage for parameters which are of smaller size
than register_t.  Using memset is probably not the most optimal way,
but oh well.
2013-12-09 19:18:52 +00:00
pooka
3d49ec1a72 As long as we're using #ifdef to decide which stubs get generated, might
as well use __strong_alias instead of __weak_alias.  Some toolchains
such as the cygwin pecoff one get weak aliases a bit wrong, so avoiding
unnecessary weak alises helps there.
2013-12-09 18:06:27 +00:00
pooka
2f027c575e regen 2013-12-09 17:15:11 +00:00
pooka
c21ebec4d0 Create rump kernel wrappers for {f,}ktrace 2013-12-09 17:13:17 +00:00
pooka
9737cfdd2b Group more syscall related routines together (kern_subr -> kern_syscall) 2013-12-09 16:49:43 +00:00
pooka
b4e2514736 Put vfs bits of ktrace into kern_ktrace_vfs.c per convention. 2013-12-09 16:45:23 +00:00
pooka
a639bb644d regen 2013-12-09 16:35:12 +00:00
pooka
1aff7d0261 Echo generated file names so that you can just copypaste & cvs ci
without having to resort to the blazingly fast help of cvs diff.
2013-12-09 16:32:06 +00:00
pooka
f5fe7e313f Rump kernels now use sy_invoke(), which initializes the return
value registers, so no need to do it individually in each wrapper.
2013-12-09 16:27:15 +00:00
wiz
d860f590d4 Fix typo ("then" instead of "than") 2013-12-09 09:35:16 +00:00
hannken
fb83ccaa78 When deciding to defer in vrelel():
- No need to always defer layer vnodes, if we get the vnode lock it
  is safe to inactivate.
- Always use VOP_LOCK(), it makes no sense to use vn_lock() here.
- No need to drop v_interlock for VOP_LOCK(... LK_NOWAIT).
2013-12-07 10:03:28 +00:00
christos
8370a84a29 Put back the vnode changes I backed out yesterday; they were not the problem.
I've tested them with 2 -j 20 builds on an 8 cpu box. It crashed reliably
with the pcu changes present before.
2013-12-01 17:29:40 +00:00
christos
2da727a2d8 Revert recent vnode changes per PR/48411, I still have deadlocks with
build -j 20 on an 8 cpu machine.
2013-12-01 00:59:34 +00:00
hannken
51a028aeda Change vrelel() to mark the vnode as changing after it has aquired
the vnode lock but before it calls VOP_INACTIVE().

Should fix the race between layer_node_find() trying to vget(, LK_NOWAIT)
a locked vnode when vrelel() marked it as changing and wants its lock.

PR kern/48411 (repeatable SMP crashes in amd64-current)
2013-11-29 14:58:55 +00:00
christos
bbbabeddfb one more *_END(head) -> NULL 2013-11-27 17:25:46 +00:00
christos
9d605174d9 Change the queue.3 *_END(&head) macros to NULL. Since we don't have CIRCLEQ
anymore, all the macros expand to NULL anyway, so this improves readability.
Requested by rmind@
2013-11-27 17:24:43 +00:00
rmind
34a5533806 Fix previous, use the correct value for softint_establish (SOFTINT_SERIAL). 2013-11-26 21:13:05 +00:00
rmind
2312c4ca30 Switch XC_HIGHPRI to run at IPL_SOFTSERIAL i.e. the highest software level.
Adjust pcu(9) to this xcall(9) change.  This may fix the problems after
x86 FPU was converted to use PCU, since it avoids heavy contention at the
lower levels (particularly, IPL_SOFTNET).  This is a good illustration why
software interrupts should generally avoid any blocking on locks.
2013-11-26 20:29:40 +00:00
christos
6cce1f9fa7 Use the process credentials instead of the lwp credentials because if the
process just did a setuid() call, the lwp might not have had a chance to
refresh l->l_cred (still has LPR_CRMOD), and we don't want to bother spending
time syncing the creds of a dying lwp. Should fix the problem with hald
people have been observing.
2013-11-25 16:29:25 +00:00
rmind
e6379a24ea do_setresuid: add an assert. 2013-11-25 16:28:20 +00:00
rmind
df64447ca6 Remove cpu_queue (and thus eleminate another use of CIRCLEQ) by replacing
its uses with cpu_infos array.  Extra testing by christos@.
2013-11-24 21:58:38 +00:00
christos
cf928d6150 Explain where this will fail. 2013-11-23 22:15:16 +00:00
hannken
df32ec6a1f Replace VI_INACTNOW and VI_INACTREDO with a new flag VI_CHANGING that gets
set while a vnode changes state from active to inactive or from active
or inactive to clean and protects "vclean(); vrelel()" and "vrelel()"
against "vget()".

Presented on tech-kern.
2013-11-23 13:46:22 +00:00
christos
0b725b63c7 change the mountlist CIRCLEQ into a TAILQ 2013-11-23 13:35:36 +00:00
christos
471b216b8f convert vmem, signals, powerhooks from CIRCLEQ -> TAILQ. 2013-11-22 21:04:11 +00:00
chs
dc00ea6b1e expose various do_*at() functions for compat_linux. 2013-11-18 01:31:42 +00:00
christos
1a9e8a975e remove trigger happy assertion. in m_adj negative lengths are valid. 2013-11-15 17:48:55 +00:00
christos
b764989391 - add KASSERTS on functions that don't accept M_COPYALL
- compute length for m_copyback0, m_makewritable used from ipf, is using
  M_COPYALL.
2013-11-14 18:54:40 +00:00
martin
153351b36e oops, remove accidently commited debug code 2013-11-14 16:53:51 +00:00
martin
41de4c61e8 As discussed on tech-kern: make TOPDOWN-VM runtime selectable per process
(offer MD code or emulations to override it).
2013-11-14 12:07:11 +00:00
skrll
955298ee4a Deal with M_COPYALL becoming -ve properly in m_copym0.
I can now mount via nfs again.
2013-11-14 09:21:30 +00:00
christos
b89fa8e9d5 change M_COPYALL to be -1 instead of depending on it too be "too large",
so that we check explicitly against it in all places. ok gimpy
2013-11-14 00:50:36 +00:00
martin
2fae30a160 Remove dead code 2013-11-11 15:22:11 +00:00
hannken
21542ebe39 Make vclean static (ride 6.99.2).
DOCLOSE is no longer needed -- remove.
2013-11-07 09:48:34 +00:00
martin
c04325564a Define a new NetBSD specific note to encode the code model used for a binary.
Allow MD code to check these notes in the exec path.
2013-11-05 14:26:19 +00:00
hannken
d54b981232 cleanvnode():
- VC_XLOCK/VC_MASK are not used anymore, remove.
- If we get a reference while cleaning, there is no need to retry as
  these reference and this vnode will disappear soon.
- Make sure we run inside a fstrans transaction to prevent deadlocks
  against vget().

vrecycle():
- don't even try to recycle a vnode currently cleaning.
2013-11-03 08:33:00 +00:00
christos
cb9d7c7e3a PR/48098: Brian Marcotte: panic: kernel diagnostic assertion "cred != NULL":
Fix from Michael van Elst, tcpdrop crashes kernel on ebryonic connections.
2013-11-02 20:09:33 +00:00
joerg
1e90a44d68 Preserve NetBSD version from the ABI tag for compat use. 2013-10-30 23:32:30 +00:00
hannken
65b1f85ab6 Vnode API cleanup pass 1.
- Make these defines and functions private to vfs_vnode.c:

  VC_MASK, VC_LOCK, DOCLOSE, VI_IANCTREDO and VI_INACTNOW
  vclean() and vrelel()

- Remove the long time unused lwp argument from vrecycle().

- Remove vtryget(), it is responsible for ugly hacks and doesn't
  look that effective.

Presented on tech-kern.

Welcome to 6.99.25
2013-10-29 09:53:51 +00:00
rmind
59ff95e71b vttodt_tab: index in C99 way, makes it less error-prone. 2013-10-27 16:19:33 +00:00
martin
33ce426346 Mark diagnostic-only variables 2013-10-25 20:37:17 +00:00
martin
419cac9e69 Mark a diagnostic-only variable 2013-10-25 20:28:33 +00:00
martin
e8d61dfcd2 Eliminat an unused variable and simplify the KASSERT which used to use it 2013-10-25 19:55:22 +00:00
martin
7c79fd6cfc Mark a diagnostic-only variable 2013-10-25 16:23:46 +00:00
martin
dad6303a94 Mark a diagnostic-only variable 2013-10-25 16:09:29 +00:00
martin
f6552d7c17 Mark diagnostic-only variables 2013-10-25 16:08:18 +00:00
martin
652ae4d76b Mark a diagnostic-only variable 2013-10-25 15:51:36 +00:00
martin
6a2419fedf Turn a few __unused into __diagused 2013-10-25 11:35:55 +00:00
mlelstv
3d28892c85 use 64bit arithmetic to compute sectors-per-unit 2013-10-19 22:36:57 +00:00