Commit Graph

9553 Commits

Author SHA1 Message Date
nat
f1631e52a4 Add functions to access device flags. This restores simultaneous audio
open/close.

OK hannken@ christos@
2016-12-09 19:13:47 +00:00
roy
89a9eb7b34 When loading a kernel, test if it's already loaded before authorizing.
This allows us to return EEXIST instead of EPERM for higher secure levels.

My use case was to stop npfctl complaining that it could not load bpfjit
on ERLITE when it was compiled into the kernel.
It then went on to complain that NPF performance would be de-graded,
but this is clearly not the case.
2016-12-09 13:06:41 +00:00
christos
cdadd9e0af void duplicate definition on statically linking libc+ssp and rumpkern+ssp. 2016-12-06 02:55:42 +00:00
christos
cf786e11e4 set the signal flag when the signal was sent to every lwp, not to just an
individual one.
2016-12-05 22:07:16 +00:00
christos
1d6d63b6d6 PR/51685: Kamil Rytarowski: Fill sigcontext info in kpsignal2 so that the
debugger/core-dump signal info gets filled in in all code paths (including
the lwp_kill one).
2016-12-04 16:40:43 +00:00
christos
840d624913 Add missing ktrkuser 2016-12-03 22:28:16 +00:00
hannken
f3e32599e8 - Change vcache_reclaim() to always call VOP_INACTIVE() before VOP_RECLAIM().
When called from vrecycle() or vgone() there is a window where the refcount
  is greater than zero and another thread could get and release a reference
  that would miss VOP_INACTIVE() as the refcount doesn't drop to zero.

  Adjust test fs/puffs/t_basic:  test VOP_INACTIVE count being greater zero.

- Make vrecycle() more robust by checking v_usecount first and preventing
  further references across vn_lock().  Fixes a deadlock where one thread
  starts unmount, second thread locks a directory and allocates a vnode
  and first thread tries to vrecycle() the directory.
  First thread holds vfs_busy and wants vnode, second thread holds vnode
  and wants vfs_busy.

- With these fixes in place change cleanvnode() to use vget()/vrecycle()
  to reclaim the vnode.
2016-12-01 14:49:03 +00:00
ozaki-r
6f15561386 Fix a race condition of low priority xcall
xc_lowpri and xc_thread are racy and xc_wait may return during/before
executing all xcall callbacks, resulting in a kernel panic at worst.

xc_lowpri serializes multiple jobs by a mutex and a cv. If all xcall
callbacks are done, xc_wait returns and also xc_lowpri accepts a next job.

The problem is that a counter that counts the number of finished xcall
callbacks is incremented *before* actually executing a xcall callback
(see xc_tailp++ in xc_thread). So xc_lowpri accepts a next job before
all xcall callbacks complete and a next job begins to run its xcall callbacks.

Even worse the counter is global and shared between jobs, so if a xcall
callback of the next job completes, the shared counter is incremented,
which confuses wc_wait of the previous job as all xcall callbacks of the
previous job are done and wc_wait of the previous job returns during/before
executing its xcall callbacks.

How to fix: there are actually two counters that count the number of finished
xcall callbacks for low priority xcall for historical reasons (I guess):
xc_tailp and xc_low_pri.xc_donep. xc_low_pri.xc_donep is incremented correctly
while xc_tailp is incremented wrongly, i.e., before executing a xcall callback.
We can fix the issue by dropping xc_tailp and using only xc_low_pri.xc_donep.

PR kern/51632
2016-11-21 00:54:21 +00:00
christos
ecb08d7cca Add FALLTHROUGH commit 2016-11-19 19:06:12 +00:00
pgoyette
f48fa2dcc1 By popular request, don't bother initializing a static pointer to NULL. 2016-11-18 02:37:33 +00:00
pgoyette
fdd49fc76c Use compile-time initialization for the list head, and make sure that
the sysctllog is also initialized before being used.
2016-11-17 08:06:49 +00:00
pgoyette
a1889144f5 Initialize the bufq code right before we're ready to load the strategy
modules.
2016-11-16 12:31:33 +00:00
pgoyette
219154eeef Define a new module class for the bufq_strategy modules. These need to
be loaded and intialized before autoconfigure runs, since some devices
(like disks and floppy drives) want to call bufq_alloc().
2016-11-16 10:42:14 +00:00
pgoyette
556c690963 Modularize the various bufq strategies 2016-11-16 00:46:46 +00:00
kre
75973081c3 Return the "true" parent's pid as the parent pid (ppid) via the
various sysctl/procfs interfaces that allow it to be interrogated.
(This is rather than the temporary parent's pid when a process is
being traced and has been reparented.)

XXX The ppid in elf32 core files has not been similarly adjusted,
XXX Should it be ?
2016-11-14 08:55:51 +00:00
christos
931a19e8b1 Make p_ppid contain the original parent's pid even for traced processes.
Only change it when we are being permanently reparented to init. Since
p_ppid is only used as a cached value to retrieve the parent's process id
from userland, this change makes it correct at all times. Idea from kre@
Revert specialized logic from getpid/getppid now that it is not needed.
2016-11-13 15:25:01 +00:00
christos
f19994519e back to using SIGSTOP.. 2016-11-12 20:03:17 +00:00
christos
cf7cb04d80 PR/51624: Return the original parent for a traced process. 2016-11-12 19:42:47 +00:00
christos
711ad24258 kern/51621: When attaching to a child send it a SIGTRAP not a SIGSTOP like
Linux and FreeBSD do.
2016-11-11 17:10:04 +00:00
njoly
a9422942bd Adjust clock_nanosleep(2) to not copyout remaining time struct if
TIMER_ABSTIME flag is set.

Ok Christos.
2016-11-11 15:29:36 +00:00
jdolecek
86e8a3aae2 during truncate with wapbl, register deallocation for upper indirect block
before recursing into lower blocks, to make sure that it will be removed after
all its referenced blocks are removed

fixes 'ffs_blkfree_common: freeing free block' panic triggered by
ufs_truncate_retry() when just the upper indirect block registration failed,
code tried to free the lower blocks again after wapbl flush

problem found by hannken@, thank you
2016-11-10 20:56:32 +00:00
christos
b2924f399d GC WOPTSCHECKED, define macros for the select opts and all the valid opts.
The linux compat flags are not part of X/Open.
2016-11-10 17:07:14 +00:00
ozaki-r
8db944330d Add a new sanity check to psref
It checks if a target being acquired is already acquired with
the same psref. It is usable but not lightweight, so enabled
only if DEBUG.
2016-11-09 09:00:46 +00:00
kre
b6732360dd PR kern/51600 ; PR standards/51606
Revert 1.264 - that was intended to fix 51600, but didn't, it just
hid the problem, and caused 51606.  This fixes 51606.

Handle waiting on a process that has been detatched from its parent
because of being ptrace'd by some other process.  This fixes 51600.
("handle" here means that the wait() hangs, or with WNOHANG, returns 0,
we cannot actually wait on a process that is not currently an attached
child.)

Note: the detatched process waiting is not yet perfect (it fails to
take account of options like WALLSIG and WALTSIG) - suport for those
(that is, ignoring a detatched child that one of those options will
later cause to be ignored when the process is re-attached.)

For now, for ither than when waiting for a specific process ID, when
a process does a wait() sys call (any of them), has no applicable
children attached that can be returned, and has at least one detatched
child, then we do a linear search of all processes to look for a
suitable detatched child.  This is likely to be slow - but very rare.
Eventually it might be better to keep a list of detatched children
per process.
2016-11-09 00:30:17 +00:00
christos
678541356f Return 0 if WNOHANG and no kids. 2016-11-05 02:59:22 +00:00
christos
9b5ab01589 deduplicate the complex lock reparent dance. 2016-11-04 18:14:04 +00:00
christos
e8fde31e58 Cleanup old parent from zombies too. Fixes repeatable panic when we try
to signal the already freed zombie parent after the child exits.
2016-11-04 18:12:06 +00:00
kamil
f26cf4cb48 Prefer modern simple past tense and past participle of catch
The "catched" form is obsolete and nonstandard, prefer "caught".
2016-11-03 22:08:30 +00:00
christos
7bfe2974a7 Fix wrong WIFCONTINUED() status. 2016-11-03 20:58:25 +00:00
hannken
30572e03fd Add a function to print the fields of a vnode including its implementation
and use it from vprint() and vfs_vnode_print().

Move vstate_name() to vfs_subr.c.
2016-11-03 11:04:21 +00:00
hannken
175d720a94 Split sys/vnode.h into sys/vnode.h and sys/vnode_impl.h
- Move _VFS_VNODE_PRIVATE protected operations into vnode_impl.h.
- Move struct vnode_impl definition and operations into vnode_impl.h.
- Include vnode_impl.h where we include vnode.h with _VFS_VNODE_PRIVATE defined.
- Get rid of _VFS_VNODE_PRIVATE.
2016-11-03 11:03:31 +00:00
hannken
4f55676a14 Prepare the split of sys/vnode.h into sys/vnode.h and sys/vnode_impl.h
- Rename struct vcache_node to vnode_impl, start its fields with vi_.
- Rename enum vcache_state to vnode_state, start its elements with VS_.
- Rename macros VN_TO_VP and VP_TO_VN to VIMPL_TO_VNODE and VNODE_TO_VIMPL.
- Add typedef struct vnode_impl vnode_impl_t.
2016-11-03 11:02:09 +00:00
pgoyette
18cd37a864 Remove ptrace_do{,fp}regs - they are a duplicate of process_* routines
which are still in sys_ptrace_common.c.
2016-11-03 03:57:05 +00:00
pgoyette
032607b8f0 Regenerate files for modularization of ptrace(2) 2016-11-02 00:14:11 +00:00
pgoyette
a60b99094c * Split sys/kern/sys_process.c into three parts:
1 - ptrace(2) syscall for native emulation
        2 - common ptrace(2) syscall code (shared with compat_netbsd32)
        3 - support routines that are shared with PROCFS and/or KTRACE

* Add module glue for #1 and #2.  Both modules will be built-in to the
  kernel if "options PTRACE" is included in the config file (this is
  the default, defined in sys/conf/std).

* Mark the ptrace(2) syscall as modular in syscalls.master (generated
  files will be committed shortly).

* Conditionalize all remaining portions of PTRACE code on a new kernel
  option PTRACE_HOOKS.

XXX Instead of PROCFS depending on 'options PTRACE', we should probably
    just add a procfs attribute to the sys/kern/sys_process.c file's
    entry in files.kern, and add PROCFS to the "#if defineds" for
    process_domem().  It's really confusing to have two different ways
    of requiring this file.
2016-11-02 00:11:59 +00:00
maxv
e18421c86e The mbuf is freed by the protocol even on error, so always NULL the pointer
instead of double-freeing it. Indirectly pointed out by Mootja.
2016-10-31 15:27:24 +00:00
maxv
a8d918182b Memory leak, found by Mootja. By the way, we probably shouldn't be
returning -1 here.
2016-10-31 15:08:45 +00:00
maxv
bee122aa97 Memory leak, found by Mootja. It is easily triggerable from userland. 2016-10-31 15:05:05 +00:00
christos
6f53bbe9e7 Fix arg64 computation for compat_netbsd32 2016-10-28 23:44:32 +00:00
jdolecek
b695bc874e reorganize ffs_truncate()/ffs_indirtrunc() to be able to partially
succeed; change wapbl_register_deallocation() to return EAGAIN
rather than panic when code hits the limit

callers changed to either loop calling ffs_truncate() using new
utility ufs_truncate_retry() if their semantics requires it, or
just ignore the failure; remove ufs_wapbl_truncate()

this fixes possible user-triggerable panic during truncate, and
resolves WAPBL performance issue with truncates of large files

PR kern/47146 and kern/49175
2016-10-28 20:38:12 +00:00
jdolecek
71a8e131fb fixup comment 2016-10-28 20:17:27 +00:00
ozaki-r
8941dc1184 Fix an assertion in _psref_held
The assertion, psref->psref_lwp == curlwp, is valid only if the target
is held by the caller.

Reviewed by riastradh@
2016-10-28 07:27:52 +00:00
skrll
f2ef31cb48 PR kern/51514: ptrace(2) fails for 32-bit process on 64-bit kernel
Updated from the original patch in the PR by me.
2016-10-19 09:44:00 +00:00
skrll
a857ba2662 KNF 2016-10-15 09:09:55 +00:00
skrll
855e4d5be4 Trailing whitespace 2016-10-14 08:38:31 +00:00
skrll
07111ed295 KNF 2016-10-14 08:37:05 +00:00
uwe
c9ab2a37ec Revert to revision 1.249 to undo changes from PR 49636.
Marking up some zeroes with a type suffix, while not marking others in
the very same function does nothing but places cognitive burden on the
reader.

Spelling "clear bits" as "&~" is actually not uncommon (and some say
is more readable).
2016-10-13 19:10:23 +00:00
dholland
d81762cbc9 foo & ~bar, not foo &~ bar. From Henning Petersen in PR 49636. 2016-10-10 01:22:51 +00:00
dholland
a6c9b0f9c4 PR 49636 Henning Petersen: use "0L" to return 0 from a function returning
long, and test its returned value against "0L" instead of "0".

This is not especially necessary, but it's also harmless.
2016-10-10 01:22:08 +00:00
christos
192a00203a Hide MFREE now that it is not being used anymore and provide some debugging
for the location of the last free for debugging kernels.
2016-10-04 14:13:21 +00:00