OpenBSD CVS

CVS log for src/sys/kern/kern_sig.c


[BACK] Up to [local] / src / sys / kern

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.330 / (download) - annotate - [select for diffs], Mon Jun 3 12:48:25 2024 UTC (7 days, 15 hours ago) by claudio
Branch: MAIN
CVS Tags: HEAD
Changes since 1.329: +17 -22 lines
Diff to previous 1.329 (colored)

Remove the now unsued s argument to SCHED_LOCK and SCHED_UNLOCK.

The SPL level is not tacked by the mutex and we no longer need to track
this in the callers.
OK miod@ mlarkin@ tb@ jca@

Revision 1.329 / (download) - annotate - [select for diffs], Wed May 22 09:22:55 2024 UTC (2 weeks, 5 days ago) by claudio
Branch: MAIN
Changes since 1.328: +4 -3 lines
Diff to previous 1.328 (colored)

In the big p_stat switch in ptsignal do not call return but instead
use one of the gotos. In this case goto out with mask and prop set to 0.

OK jca@

Revision 1.328 / (download) - annotate - [select for diffs], Mon May 20 10:32:20 2024 UTC (3 weeks ago) by claudio
Branch: MAIN
Changes since 1.327: +44 -42 lines
Diff to previous 1.327 (colored)

Rework interaction between sleep API and exit1() and start unlocking ps_threads

This diff adjusts how single_thread_set() accounts the threads by using
ps_threadcnt as initial value and counting all threads out that are already
parked. In single_thread_check call exit1() before decreasing ps_singlecount
this is now done in exit1().

exit1() and thread_fork() ensure that ps_threadcnt is updated with the
pr->ps_mtx held and in exit1() also account for exiting threads since
exit1() can sleep.

OK mpi@

Revision 1.327 / (download) - annotate - [select for diffs], Wed May 8 13:05:33 2024 UTC (4 weeks, 5 days ago) by claudio
Branch: MAIN
Changes since 1.326: +42 -20 lines
Diff to previous 1.326 (colored)

Rework how action SIG_HOLD is handled in ptsignal.

Since we want to unlock sigsuspend, ptsignal needs to double check in the
SSLEEP case that the signal being delivered is still masked or unmasked.
Remove the early return for action SIG_HOLD so that the SSLEEP case can
properly recheck the sigmask.

On top of this update siglist only in one place at the end of ptsignal
this now includes the clearing of signals for the SA_CONT and SA_STOP
cases.

OK mpi@

Revision 1.326 / (download) - annotate - [select for diffs], Tue May 7 10:46:35 2024 UTC (4 weeks, 6 days ago) by claudio
Branch: MAIN
Changes since 1.325: +2 -2 lines
Diff to previous 1.325 (colored)

In Rev 1.296 the update of the siglist was moved to the end of ptsignal().
One atomic_clearbits_int() hiding in SSTOP was missed when converting all
the exceptions that cleared the siglist again. Instead of clearing the bits
the mask needs to be set to 0 so that it is properly ignored.
OK mpi@

Revision 1.325 / (download) - annotate - [select for diffs], Thu Apr 18 09:06:42 2024 UTC (7 weeks, 4 days ago) by claudio
Branch: MAIN
Changes since 1.324: +4 -1 lines
Diff to previous 1.324 (colored)

If a proc has P_WEXIT set do not stop it, let it exit since it is already
mostly dead.

This is more like belts and suspenders since a proc in exit1() will not
receive signals anymore and so proc_stop() should not be reachable. This
is even the case when sigexit() is called and a coredump() is happening.
OK mpi@

Revision 1.324 / (download) - annotate - [select for diffs], Wed Apr 10 10:05:26 2024 UTC (2 months ago) by claudio
Branch: MAIN
Changes since 1.323: +35 -13 lines
Diff to previous 1.323 (colored)

Unlock dosigsuspend() and with that some aspects of ppoll and pselect

Change p_sigmask from atomic back to non-atomic updates. All changes to
p_sigmask are only allowed by curproc (the owner). There is no need for
atomic instructions here.

p_sigmask is mostly accessed by curproc with the exception of ptsignal().
In ptsignal() p_sigmask is now only read once unless a SSLEEP proc gets
the signal. In that case recheck the p_sigmask before wakeup to ensure
that no unnecessary wakeup happens.

Add some KASSERT(p == curproc) to ensure this precondition.
sigabort() is special since it is also called by ddb but apart from that
only works for curproc.

With and OK mvs@ OK mpi@

Revision 1.323 / (download) - annotate - [select for diffs], Sat Mar 30 13:33:20 2024 UTC (2 months, 1 week ago) by mpi
Branch: MAIN
Changes since 1.322: +5 -1 lines
Diff to previous 1.322 (colored)

Prevent a recursion inside wakeup(9) when scheduler tracepoints are enabled.

Tracepoints like "sched:enqueue" and "sched:unsleep" were called from inside
the loop iterating over sleeping threads as part of wakeup_proc().  When such
tracepoints were enabled they could result in another wakeup(9) possibly
corrupting the sleepqueue.

Rewrite wakeup(9) in two stages, first dequeue threads from the sleepqueue then
call setrunnable() and possible tracepoints for each of them.

This requires moving unsleep() outside of setrunnable() because it messes with
the sleepqueue.

ok claudio@

Revision 1.322 / (download) - annotate - [select for diffs], Sun Feb 25 00:07:13 2024 UTC (3 months, 2 weeks ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5
Changes since 1.321: +6 -1 lines
Diff to previous 1.321 (colored)

New accounting flag ABTCFI to indicate signal SIGILL + code ILL_BTCFI
has occurred in the process.
ok various people

Revision 1.321 / (download) - annotate - [select for diffs], Wed Jan 17 22:22:25 2024 UTC (4 months, 3 weeks ago) by kurt
Branch: MAIN
Changes since 1.320: +4 -3 lines
Diff to previous 1.320 (colored)

Fix core file writing when a file map into memory has later been truncated
to be smaller than the mapping. Record which memory segments are backed by
vnodes while walking the uvm map and later suppress EFAULT errors caused
by the underlying file being truncated. okay miod@

Revision 1.320 / (download) - annotate - [select for diffs], Fri Oct 6 08:58:13 2023 UTC (8 months ago) by claudio
Branch: MAIN
Changes since 1.319: +2 -4 lines
Diff to previous 1.319 (colored)

In sys___thrsigdivert() switch tsleep_nsec() to use the nowake ident
channel instead of inventing an own one.
OK kettenis@ mvs@

Revision 1.319 / (download) - annotate - [select for diffs], Fri Sep 29 12:47:34 2023 UTC (8 months, 1 week ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.318: +8 -8 lines
Diff to previous 1.318 (colored)

Extend single_thread_set() mode with additional flag attributes.

The mode can now be or-ed with SINGLE_DEEP or SINGLE_NOWAIT to alter
the behaviour of single_thread_set(). This allows explicit control
of the SINGLE_DEEP behaviour.

If SINGLE_DEEP is set the deep flag is passed to the initial check call
and by that the check will error out instead of suspending (SINGLE_UNWIND)
or exiting (SINGLE_EXIT). The SINGLE_DEEP flag is required in calls to
single_thread_set() outside of userret. E.g. at the start of sys_execve
because the proc is not allowed to call exit1() in that location.

SINGLE_NOWAIT skips the wait at the end of single_thread_set() and therefor
returns BEFORE all threads have been parked. Currently this is only used by
the ptrace code and should not be used anywhere else. Not waiting for all
threads to settle is asking for trouble.

This solves an issue by using SINGLE_UNWIND in the coredump case where
the code should actually exit in case another thread crashed moments earlier.
Also the SINGLE_UNWIND in pledge_fail() is now marked SINGLE_DEEP since
the call to pledge_fail() is for sure not at the kernel boundary.

OK mpi@

Revision 1.318 / (download) - annotate - [select for diffs], Tue Sep 19 10:43:33 2023 UTC (8 months, 3 weeks ago) by claudio
Branch: MAIN
Changes since 1.317: +5 -5 lines
Diff to previous 1.317 (colored)

Before coredump or in pledge_fail use SINGLE_UNWIND to stop all threads.

SINGLE_UNWIND unwinds to the kernel boundary. On the other hand
SINGLE_SUSPEND will sleep inside tsleep(9) and other sleep functions.
Since the code will exit1() very soon after it is better to already unwind.
Now one could argue that for coredumps all threads should stop asap to
get a clean dump. Using SINGLE_UNWIND the sleep will fail with ERESTART
and no copyout should happen in that case.

This is a bit of a workaround since SINGLE_SUSPEND has a small race
where single_thread_wait() returns before all threads are really stopped.
When SINGLE_EXIT is called quickly after this can blow up inside
sleep_finish.

Reported-by: syzbot+3ef066fcfaf991f2ac2c@syzkaller.appspotmail.com

OK mpi@ kettenis@

Revision 1.317 / (download) - annotate - [select for diffs], Wed Sep 13 14:25:49 2023 UTC (8 months, 4 weeks ago) by claudio
Branch: MAIN
Changes since 1.316: +35 -47 lines
Diff to previous 1.316 (colored)

Revert commitid: yfAefyNWibUyjkU2, ESyyH5EKxtrXGkS6 and itscfpFvJLOj8mHB;

The change to the single thread API results in crashes inside exit1()
as found by Syzkaller. There seems to be a race in the exit codepath.
What exactly fails is not really clear therefor revert for now.

This should fix the following Syzkaller reports:
Reported-by: syzbot+38efb425eada701ca8bb@syzkaller.appspotmail.com
Reported-by: syzbot+ecc0e8628b3db39b5b17@syzkaller.appspotmail.com
and maybe more.

Reverted commits:

Revision 1.316 / (download) - annotate - [select for diffs], Sat Sep 9 14:50:09 2023 UTC (9 months ago) by claudio
Branch: MAIN
Changes since 1.315: +4 -2 lines
Diff to previous 1.315 (colored)

Fix SCHED_LOCK() leak in single_thread_set()

In the (q->p_flag & P_WEXIT) branch is a continue that did not release
the SCHED_LOCK. Refactor the code a bit to simplify the places SCHED_LOCK
is grabbed and released.

Reported-by: syzbot+ea26d351acfad3bb3f15@syzkaller.appspotmail.com
OK kettenis@

Revision 1.315 / (download) - annotate - [select for diffs], Fri Sep 8 09:06:31 2023 UTC (9 months ago) by claudio
Branch: MAIN
Changes since 1.314: +7 -8 lines
Diff to previous 1.314 (colored)

Change how ps_threads and p_thr_link are locked away from using SCHED_LOCK.

The per process thread list can be traversed (read) by holding either
the KERNEL_LOCK or the per process ps_mtx (instead of SCHED_LOCK).
Abusing the SCHED_LOCK for this makes it impossible to split up the
scheduler lock into something more fine grained.

Tested by phessler@, ok mpi@

Revision 1.314 / (download) - annotate - [select for diffs], Mon Sep 4 13:18:41 2023 UTC (9 months ago) by claudio
Branch: MAIN
Changes since 1.313: +44 -33 lines
Diff to previous 1.313 (colored)

Protect ps_single, ps_singlecnt and ps_threadcnt by the process mutex.

The single thread API needs to lock the process to enter single thread
mode and does not need to stop the scheduler.

This code changes ps_singlecount from a count down to zero to ps_singlecnt
which counts up until equal to ps_threadcnt (in which case all threads
are properly asleep).

Tested by phessler@, OK mpi@ cheloha@

Revision 1.313 / (download) - annotate - [select for diffs], Wed Aug 16 07:55:52 2023 UTC (9 months, 3 weeks ago) by claudio
Branch: MAIN
Changes since 1.312: +5 -10 lines
Diff to previous 1.312 (colored)

Move SCHED_LOCK after sleep_signal_check.

sleep_signal_check() is there to look for pending signals / single thread
requests which were posted before sleep_setup() finished. Once p_stat
is set to SSLEEP the wakeup and delivery of signals is taken care of
by ptsignal and single_thread_set().

Moving the SCHED_LOCK further down allows to cleanup cursig() and to
remove a SCHED_LOCK recursion in single_thread_check().

OK mpi@

Revision 1.312 / (download) - annotate - [select for diffs], Sun Aug 13 15:53:31 2023 UTC (9 months, 4 weeks ago) by claudio
Branch: MAIN
Changes since 1.311: +7 -4 lines
Diff to previous 1.311 (colored)

Fix P_WSLEEP handling when continuing SSTOP-ed processes

When continuing a process on the sleep queue just let it switch to
p_stat = SSLEEP even when P_WSLEEP is set. Once a proc is SSTOP-ed
in sleep_finish() a valid sleep point has been reached and there is
no need to make the process runnable again (which results in some
hairy race conditions). Instead simply clear P_WSLEEP since a stopped
proc reached the sleep state and there is no race with wakeup() anymore.

OK mpi@

Revision 1.311 / (download) - annotate - [select for diffs], Fri Aug 11 07:54:18 2023 UTC (10 months ago) by claudio
Branch: MAIN
Changes since 1.310: +4 -4 lines
Diff to previous 1.310 (colored)

Move the single_thread_check() to the start of userret().

This way threads stopped by SINGLE_SUSPEND will check for pending
signals right after being released instead of returning to userland
first. The same order of check is already used in sleep_signal_check().

OK mpi@

Revision 1.310 / (download) - annotate - [select for diffs], Fri Jul 14 07:07:08 2023 UTC (10 months, 4 weeks ago) by claudio
Branch: MAIN
Changes since 1.309: +3 -4 lines
Diff to previous 1.309 (colored)

struct sleep_state is no longer used, remove it.
Also remove the priority argument to sleep_finish() the code can use
the p_flag P_SINTR flag to know if the signal check is needed or not.
OK cheloha@ kettenis@ mpi@

Revision 1.309 / (download) - annotate - [select for diffs], Tue Jul 11 07:02:43 2023 UTC (11 months ago) by claudio
Branch: MAIN
Changes since 1.308: +3 -3 lines
Diff to previous 1.308 (colored)

Rework sleep_setup()/sleep_finish() to no longer hold the scheduler lock
between calls.

Instead of forcing an atomic operation across multiple calls use a three
step transaction.
1. setup sleep state by calling sleep_setup()
2. recheck sleep condition to ensure that the event did not fire before
   sleep_setup() registered the proc onto the sleep queue
3. call sleep_finish() to either sleep or keep on running based on the
   step 2 outcome and any possible signal delivery

To make this work wakeup from signals, single thread api and wakeup(9) need
to be aware if a process is between step 1 and step 3 so that the process
is not enqueued back onto the runqueue while going to sleep. Introduce
the p_flag P_WSLEEP to detect this situation.

On top of this remove the spl dance in msleep() which is no longer required.
It is ok to process interrupts between step 1 and 3.

OK mpi@ cheloha@

Revision 1.308 / (download) - annotate - [select for diffs], Mon Jul 10 22:54:40 2023 UTC (11 months ago) by deraadt
Branch: MAIN
Changes since 1.307: +2 -2 lines
Diff to previous 1.307 (colored)

Allow unveiled programs to dump core (in the default, classic, into . way)
by passing BYPASSUNVEIL just for this vnode.  The coredump() code is quite
careful, so this will be fine.
ok kn kettenis semarie

Revision 1.307 / (download) - annotate - [select for diffs], Wed Jun 28 08:23:25 2023 UTC (11 months, 2 weeks ago) by claudio
Branch: MAIN
Changes since 1.306: +3 -3 lines
Diff to previous 1.306 (colored)

First step at removing struct sleep_state.

Pass the timeout and sleep priority not only to sleep_setup() but also
to sleep_finish(). With that sls_timeout and sls_catch can be removed
from struct sleep_state.

The timeout is now setup first thing in sleep_finish() and no longer as
last thing in sleep_setup(). This should not cause a noticeable difference
since the code run between sleep_setup() and sleep_finish() is minimal.

OK kettenis@

Revision 1.306 / (download) - annotate - [select for diffs], Mon Apr 3 11:57:50 2023 UTC (14 months, 1 week ago) by claudio
Branch: MAIN
Changes since 1.305: +24 -23 lines
Diff to previous 1.305 (colored)

Reduce indent in single_thread_check_locked() by inverting initial
if () check which just returns.
OK mpi@

Revision 1.305 / (download) - annotate - [select for diffs], Fri Feb 10 14:34:17 2023 UTC (15 months, 4 weeks ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.304: +2 -2 lines
Diff to previous 1.304 (colored)

Adjust knote(9) API

Make knote(9) lock the knote list internally, and add knote_locked(9)
for the typical situation where the list is already locked.

Remove the KNOTE(9) macro to simplify the API.

Manual page OK jmc@
OK mpi@ mvs@

Revision 1.304 / (download) - annotate - [select for diffs], Tue Jan 31 15:18:56 2023 UTC (16 months, 1 week ago) by deraadt
Branch: MAIN
Changes since 1.303: +6 -1 lines
Diff to previous 1.303 (colored)

On systems without xonly mmu hardware-enforcement, we can still mitigate
against classic BROP with a range-checking wrapper in front of copyin() and
copyinstr() which ensures the userland source doesn't overlap the main program
text, ld.so text, signal tramp text (it's mapping is hard to distinguish
so it comes along for the ride), or libc.so text.  ld.so tells the kernel
libc.so text range with msyscall(2).  The range checking for 2-4 elements is
done without locking (because all 4 ranges are immutable!) and is inexpensive.

write(sock, &open, 400) now fails with EFAULT.  No programs have been
discovered which require reading their own text segments with a system call.

On a machine without mmu enforcement, a test program reports the following:
                  userland   kernel
ld.so             readable   unreadable
mmap xz           unreadable unreadable
mmap x            readable   readable
mmap nrx          readable   readable
mmap nwx          readable   readable
mmap xnwx         readable   readable
main              readable   unreadable
libc unmapped?    readable   unreadable
libc mapped       readable   unreadable

ok kettenis, additional help from miod

Revision 1.303 / (download) - annotate - [select for diffs], Mon Jan 2 23:09:48 2023 UTC (17 months, 1 week ago) by guenther
Branch: MAIN
Changes since 1.302: +5 -12 lines
Diff to previous 1.302 (colored)

Add tfind_user(), for getting a proc* given a user-space TID and
the process* that it should be part of.  Use that in clock_get{time,res}(),
thrkill(), and ptrace().

ok jca@ miod@ mpi@ mvs@

Revision 1.302 / (download) - annotate - [select for diffs], Thu Dec 29 01:36:36 2022 UTC (17 months, 1 week ago) by guenther
Branch: MAIN
Changes since 1.301: +7 -2 lines
Diff to previous 1.301 (colored)

Add ktrace struct tracepoints for siginfo_t to the kernel side of
waitid(2) and __thrsigdivert(2) and teach kdump(1) to handle them.
Also report more from the siginfo_t inside PSIG tracepoints.

ok mpi@

Revision 1.301 / (download) - annotate - [select for diffs], Sun Oct 16 16:27:02 2022 UTC (19 months, 3 weeks ago) by deraadt
Branch: MAIN
Changes since 1.300: +1 -1 lines
Diff to previous 1.300 (colored)

Rather than marking MAP_STACK on entries for sigaltstack() [2 days ago],
go back to the old approach: using a new anon mapping because it removes
any potential gadgetry pre-placed in the region (by making it zero).  But
also bring in a few more validation checks beyond contigious mapping -- it
must not be a syscall region, and the protection must be precisely RW.
This does allow sigaltstack() to shoot zero'd MAP_STACK non-immutable regions
into the main stack area (which will soon be immutable).  I am not sure we
can keep reinforce immutable on the region after we do stack (like maybe
determine this while doing the validation entry walk?)
Sadly, continued support for sigaltstack() does require selecting the guessed
best compromise.
ok kettenis

Revision 1.300 / (download) - annotate - [select for diffs], Sat Oct 15 03:23:50 2022 UTC (19 months, 3 weeks ago) by deraadt
Branch: MAIN
Changes since 1.299: +2 -2 lines
Diff to previous 1.299 (colored)

During the MAP_STACK introduction in 2018, sigaltstack() became a
problem because haphazard use could shoot holes in the address space
(changing permissions, providing opportunities for pivoting, etc). I
tried to write a diff to convert the address space correctly but did
not understand enough about map entries, so instead we mapped new
memory over top of the existing object.  Placing a new mapping becomes
unfeasible with the upcoming mimmutable model, so here is code that
adds MAP_STACK to the region.  It will only do so for a contigiously
mapped region that is non-syscall with permission RW, otherwise it
returns an error.
Food for thought: If we know the object isn't service by an object,
we should consider zero'ing the region, to block pre-pivot placement?
ok kettenis

Revision 1.299 / (download) - annotate - [select for diffs], Sun Aug 14 01:58:27 2022 UTC (21 months, 4 weeks ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.298: +1 -5 lines
Diff to previous 1.298 (colored)

remove unneeded includes in sys/kern
ok mpi@ miod@

Revision 1.298 / (download) - annotate - [select for diffs], Wed Jun 29 10:48:22 2022 UTC (23 months, 1 week ago) by claudio
Branch: MAIN
Changes since 1.297: +9 -9 lines
Diff to previous 1.297 (colored)

Move the deep check back into the loop. There are ways that even though
we're deep the code will SSTOP and sleep and then on wakeup we need to
recheck the deep conditions.
Issue analyzed and OK by mpi@

Reported-by: syzbot+f7634539e73108238c2a@syzkaller.appspotmail.com

Revision 1.297 / (download) - annotate - [select for diffs], Tue Jun 28 12:08:17 2022 UTC (23 months, 2 weeks ago) by claudio
Branch: MAIN
Changes since 1.296: +9 -12 lines
Diff to previous 1.296 (colored)

Cleanup the sleep loop in single_thread_check_locked(). The deep checks
only matter on entry and the pr->ps_single check is done in the while body.
With and OK mpi@

Revision 1.296 / (download) - annotate - [select for diffs], Fri May 13 15:32:00 2022 UTC (2 years ago) by claudio
Branch: MAIN
Changes since 1.295: +88 -64 lines
Diff to previous 1.295 (colored)

Use the process ps_mtx to protect the process sigacts structure.
With this cursig(), postsig() and trapsignal() become safe to be called
without KERNEL_LOCK. As a side-effect sleep with PCATCH no longer needs
the KERNEL_LOCK either. Since sending a signal can happen from interrupt
context raise the ps_mtx IPL to high.
Feedback from mpi@ and kettenis@
OK kettenis@

Revision 1.295 / (download) - annotate - [select for diffs], Fri Mar 11 10:05:38 2022 UTC (2 years, 3 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.294: +38 -5 lines
Diff to previous 1.294 (colored)

Revert part of rev 1.293. Using cursig() to deliver masked signals
to the debugger can cause a loop between the debugger and cursig()
if the signal is masked. cursig() has no way to know which signal
was already delivered to the debugger and so it delivers the same
signal over and over again.

Instead handle traps to masked signals directly in trapsignal. This
is what rev 1.293 was mostly about. If SIGTRAP was masked by the
process breakpoints no longer worked since the signal deliver to
the debugger did not happen. Doing this case in trapsignal solves
both the problem with the loop and the delivery of masked traps.

Problem reported and fix tested by matthieu@
OK kettenis@ mpi@

Revision 1.294 / (download) - annotate - [select for diffs], Mon Feb 14 11:26:05 2022 UTC (2 years, 3 months ago) by claudio
Branch: MAIN
Changes since 1.293: +48 -38 lines
Diff to previous 1.293 (colored)

Introduce a signal context that is used to pass signal related information
from cursig() to postsig() or the caller itself. This will simplify locking.
Also alter sigactsfree() a bit and move it into process_zap() so ps_sigacts
is always a valid pointer.
OK semarie@

Revision 1.293 / (download) - annotate - [select for diffs], Sun Feb 6 09:57:59 2022 UTC (2 years, 4 months ago) by claudio
Branch: MAIN
Changes since 1.292: +6 -11 lines
Diff to previous 1.292 (colored)

Simplify cursig() a bit and make sure that signals are always sent to
the parent of ptraced processes. Especially ignore the signal mask set
by sigprocmask(2) in that case. In userret() alter the testcase for
when to call cursig() which is only there to avoid taking the
KERNEL_LOCK when returning from a MP safe syscall. This can be revisited
once cursig() is MP safe.
Problem with debugging signal handlers found by kurt@
Tested and OK kurt@, OK mpi@

Revision 1.292 / (download) - annotate - [select for diffs], Sun Jan 2 21:01:20 2022 UTC (2 years, 5 months ago) by tb
Branch: MAIN
Changes since 1.291: +2 -2 lines
Diff to previous 1.291 (colored)

immediatly -> immediately

Revision 1.291 / (download) - annotate - [select for diffs], Tue Dec 7 22:17:02 2021 UTC (2 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.290: +3 -5 lines
Diff to previous 1.290 (colored)

Delete the last emulation callbacks: we're Just ELF, so declare
exec_elf_fixup() and coredump_elf() in <sys/exec_elf.h> and call
them and the MD setregs() directly in kern_exec.c and kern_sig.c

Also delete e_name[] (only used by sysctl), e_errno (unused), and
e_syscallnames[] (only used by SYSCALL_DEBUG) and constipate
syscallnames to 'const char *const[]'

ok kettenis@

Revision 1.290 / (download) - annotate - [select for diffs], Wed Nov 24 10:40:15 2021 UTC (2 years, 6 months ago) by claudio
Branch: MAIN
Changes since 1.289: +16 -9 lines
Diff to previous 1.289 (colored)

Refactor postsig_done(). Pass the catchmask and signal reset flag to the
function. This will make unlocking cursig() & postsig() a bit easier.
OK mpi@

Revision 1.289 / (download) - annotate - [select for diffs], Wed Nov 24 10:28:55 2021 UTC (2 years, 6 months ago) by claudio
Branch: MAIN
Changes since 1.288: +16 -13 lines
Diff to previous 1.288 (colored)

Minor code cleanup. Move a comment to the right place, move a function
to get a better order of functions. Also reduce the size of sigprop
to NSIG from NSIG+1. NSIG is defined as 33 and so includes the extra
element for this array.
OK mpi@

Revision 1.288 / (download) - annotate - [select for diffs], Fri Nov 12 17:57:13 2021 UTC (2 years, 6 months ago) by cheloha
Branch: MAIN
Changes since 1.287: +4 -6 lines
Diff to previous 1.287 (colored)

sigsuspend(2): sleep on &nowake channel

sigsuspend(2) only returns upon delivery of a signal: we do not expect
a wakeup(9).  Indicate this by sleeping on &nowake instead of
&p->p_p->ps_sigacts.  We still need to loop here to handle spurious
wakeups, though.

Spurious wakeup case pointed out by kettenis@.

ok claudio@

Revision 1.287 / (download) - annotate - [select for diffs], Sun Oct 24 00:02:25 2021 UTC (2 years, 7 months ago) by jsg
Branch: MAIN
Changes since 1.286: +6 -6 lines
Diff to previous 1.286 (colored)

use NULL not 0 for pointer values in kern
ok semarie@

Revision 1.286 / (download) - annotate - [select for diffs], Sat Oct 23 14:56:55 2021 UTC (2 years, 7 months ago) by claudio
Branch: MAIN
Changes since 1.285: +4 -4 lines
Diff to previous 1.285 (colored)

Be consistend and add missing spaces around some of the NOTREACHED comments.

Revision 1.285 / (download) - annotate - [select for diffs], Wed Oct 6 15:46:03 2021 UTC (2 years, 8 months ago) by claudio
Branch: MAIN
Changes since 1.284: +10 -4 lines
Diff to previous 1.284 (colored)

Change sendsig() interface so that the MD code does not need to access
data from struct process anymore. This changes how siginfo and onstack
are accessed and make sendsig() more MP friendly.
With and OK semarie@ OK kettenis@

Revision 1.284 / (download) - annotate - [select for diffs], Mon Oct 4 08:48:12 2021 UTC (2 years, 8 months ago) by claudio
Branch: MAIN
Changes since 1.283: +2 -12 lines
Diff to previous 1.283 (colored)

Simplify sys___thrsigdivert a bit. cursig() always moves the pending signal
to p_siglist and so there is no need to check ps_siglist for the signal.
OK mpi@

Revision 1.283 / (download) - annotate - [select for diffs], Tue Sep 28 10:00:18 2021 UTC (2 years, 8 months ago) by claudio
Branch: MAIN
Changes since 1.282: +3 -3 lines
Diff to previous 1.282 (colored)

Fix timeout behaviour bug introduced in 1.241.
If the timespec is zero-valued sys___thrsigdivert() should just do the
check for pending signals and return immediatly.
OK kettenis@

Revision 1.282 / (download) - annotate - [select for diffs], Wed Jul 14 22:09:24 2021 UTC (2 years, 10 months ago) by bluhm
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.281: +8 -2 lines
Diff to previous 1.281 (colored)

After VFS shutdown, init(8) cannot map a missing page that contains
the signal handler code.  Traditionally a process would spin in
such a case, but we changed the logic in revision 1.167 trapsignal()
to receive a fatal signal.  If that happens to init(8), the kernel
panics.  In case of reboot, jump between init signal handler and
page fault trap until the kernel resets the machine.
reported and tested weerd@; OK deraadt@

Revision 1.281 / (download) - annotate - [select for diffs], Mon May 10 18:01:24 2021 UTC (3 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.280: +34 -46 lines
Diff to previous 1.280 (colored)

Revert previous, it introduced a regression with breakpoints in gdb.

Revision 1.280 / (download) - annotate - [select for diffs], Thu May 6 09:33:22 2021 UTC (3 years, 1 month ago) by mpi
Branch: MAIN
Changes since 1.279: +46 -34 lines
Diff to previous 1.279 (colored)

Refactor routines to stop/unstop processes and save the corresponding signal.

- Move the "hack" involving P_SINTR to avoid grabbing the SCHED_LOCK()
recursively closer to where it is necessary, in proc_stop()

- Introduce proc_unstop(), the symmetric routine to proc_stop(), which
manipulates `ps_xsig' and use it whenever a SSTOPed thread needs to be
awaken.

- Manipulate `ps_xsig' only in proc_stop/unstop()

ok kettenis@

Revision 1.279 / (download) - annotate - [select for diffs], Sun Mar 21 10:24:36 2021 UTC (3 years, 2 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.278: +6 -6 lines
Diff to previous 1.278 (colored)

Use uppercases for defines.

No functional change.

ok semarie@

Revision 1.278 / (download) - annotate - [select for diffs], Fri Mar 12 10:13:28 2021 UTC (3 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.277: +7 -11 lines
Diff to previous 1.277 (colored)

Kill SINGLE_PTRACE and use SINGLE_SUSPEND which has almost the same semantic

single_thread_set() is modified to explicitly indicated when waiting until
sibling threads are parked is required.  This is obviously not required if
a traced thread is switching away from a CPU after handling a STOP signal.

ok claudio@

Revision 1.277 / (download) - annotate - [select for diffs], Mon Mar 8 18:09:15 2021 UTC (3 years, 3 months ago) by claudio
Branch: MAIN
Changes since 1.276: +10 -6 lines
Diff to previous 1.276 (colored)

Revert commitid: AZrsCSWEYDm7XWuv;

Kill SINGLE_PTRACE and use SINGLE_SUSPEND which has almost the same semantic.

This diff did not properly kill SINGLE_PTRACE and broke RAMDISK kernels.

Revision 1.276 / (download) - annotate - [select for diffs], Mon Mar 8 10:54:53 2021 UTC (3 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.275: +3 -6 lines
Diff to previous 1.275 (colored)

Move a KERNEL_ASSERT_LOCKED() from single_thread_clear() to cursig().

Ze big lock is currently necessary to ensure that two sibling threads
are not racing against each other when processing signals.  However it
is not strickly necessary to unpark sibling threads.

ok claudio@

Revision 1.275 / (download) - annotate - [select for diffs], Mon Mar 8 10:12:05 2021 UTC (3 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.274: +6 -10 lines
Diff to previous 1.274 (colored)

Kill SINGLE_PTRACE and use SINGLE_SUSPEND which has almost the same semantic.

single_thread_set() is modified to explicitly indicated when waiting until
sibling threads are parked is required.  This is obviously not required if
a traced thread is switching away from a CPU after handling a STOP signal.

ok claudio@

Revision 1.274 / (download) - annotate - [select for diffs], Thu Mar 4 09:02:37 2021 UTC (3 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.273: +20 -12 lines
Diff to previous 1.273 (colored)

Merge issignal() and CURSIG() in preparation for turning it mp-safe.

This makes appear some redundant & racy checks.

ok semarie@

Revision 1.273 / (download) - annotate - [select for diffs], Mon Feb 15 09:35:59 2021 UTC (3 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.272: +1 -6 lines
Diff to previous 1.272 (colored)

Move single_thread_set() out of KERNEL_LOCK().

Use the SCHED_LOCK() to ensure `ps_thread' isn't being modified by a sibling
when entering tsleep(9) w/o KERNEL_LOCK().

ok visa@

Revision 1.272 / (download) - annotate - [select for diffs], Mon Feb 8 10:51:01 2021 UTC (3 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.271: +5 -5 lines
Diff to previous 1.271 (colored)

Revert the convertion of per-process thread into a SMR_TAILQ.

We did not reach a consensus about using SMR to unlock single_thread_set()
so there's no point in keeping this change.

Revision 1.271 / (download) - annotate - [select for diffs], Mon Feb 8 08:18:45 2021 UTC (3 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.270: +2 -2 lines
Diff to previous 1.270 (colored)

Simplify sleep_setup API to two operations in preparation for splitting
the SCHED_LOCK().

Putting a thread on a sleep queue is reduce to the following:

sleep_setup();
/* check condition or release lock */
sleep_finish();

Previous version ok cheloha@, jmatthew@, ok claudio@

Revision 1.270 / (download) - annotate - [select for diffs], Fri Dec 25 12:59:52 2020 UTC (3 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.269: +3 -3 lines
Diff to previous 1.269 (colored)

Refactor klist insertion and removal

Rename klist_{insert,remove}() to klist_{insert,remove}_locked().
These functions assume that the caller has locked the klist. The current
state of locking remains intact because the kernel lock is still used
with all klists.

Add new functions klist_insert() and klist_remove() that lock the klist
internally. This allows some code simplification.

OK mpi@

Revision 1.269 / (download) - annotate - [select for diffs], Wed Dec 23 20:48:06 2020 UTC (3 years, 5 months ago) by cheloha
Branch: MAIN
Changes since 1.268: +2 -2 lines
Diff to previous 1.268 (colored)

sigsuspend(2): change wmesg from "pause" to "sigsusp"

Make it obvious where the thread is blocked.  "pause" is ambiguous.

Tweaked by kettenis@.

Probably ok kettenis@.

Revision 1.268 / (download) - annotate - [select for diffs], Mon Dec 7 16:55:28 2020 UTC (3 years, 6 months ago) by mpi
Branch: MAIN
Changes since 1.267: +5 -5 lines
Diff to previous 1.267 (colored)

Convert the per-process thread list into a SMR_TAILQ.

Currently all iterations are done under KERNEL_LOCK() and therefor use
the *_LOCKED() variant.

From and ok claudio@

Revision 1.267 / (download) - annotate - [select for diffs], Fri Dec 4 15:16:45 2020 UTC (3 years, 6 months ago) by mpi
Branch: MAIN
Changes since 1.266: +23 -11 lines
Diff to previous 1.266 (colored)

Prevent a TOCTOU race in single_thread_set() by extending the scope of the lock.

Make sure `ps_single' is set only once by checking then updating it without
releasing the lock.

Analyzed by and ok claudio@

Revision 1.266 / (download) - annotate - [select for diffs], Wed Dec 2 22:35:32 2020 UTC (3 years, 6 months ago) by mpi
Branch: MAIN
Changes since 1.265: +9 -23 lines
Diff to previous 1.265 (colored)

Revert previous extension of the SCHED_LOCK(), the state isn't passed down.

Panic reported by dhill@

Revision 1.265 / (download) - annotate - [select for diffs], Wed Dec 2 16:52:30 2020 UTC (3 years, 6 months ago) by mpi
Branch: MAIN
Changes since 1.264: +23 -9 lines
Diff to previous 1.264 (colored)

Prevent a TOCTOU race in single_thread_set() by extending the scope of the lock.

Make sure `ps_single' is set only once by checking then updating it without
releasing the lock.

Analyzed by and ok claudio@

Revision 1.264 / (download) - annotate - [select for diffs], Sun Nov 8 20:37:24 2020 UTC (3 years, 7 months ago) by mpi
Branch: MAIN
Changes since 1.263: +11 -3 lines
Diff to previous 1.263 (colored)

In case of failure, call sigexit() from trapsignal instead of sensig().

Simplify MD code and reduce the amount of recursion into the signal code
which helps when dealing with locks.

ok cheloha@, deraadt@

Revision 1.263 / (download) - annotate - [select for diffs], Wed Sep 16 13:50:42 2020 UTC (3 years, 8 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.262: +18 -1 lines
Diff to previous 1.262 (colored)

Move duplicated code to send an uncatchable SIGABRT into a function.

ok claudio@

Revision 1.262 / (download) - annotate - [select for diffs], Sun Sep 13 13:33:37 2020 UTC (3 years, 8 months ago) by claudio
Branch: MAIN
Changes since 1.261: +2 -3 lines
Diff to previous 1.261 (colored)

Unbreak tree. Instead of passing struct process to siginit() just pass the
struct sigacts since that is the only thing that is modified by siginit.

Revision 1.261 / (download) - annotate - [select for diffs], Wed Sep 9 16:29:14 2020 UTC (3 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.260: +17 -1 lines
Diff to previous 1.260 (colored)

Introduce a helper to check if a signal is ignored or masked by a thread.

ok claudio@, pirofti@

Revision 1.260 / (download) - annotate - [select for diffs], Wed Aug 26 03:16:53 2020 UTC (3 years, 9 months ago) by visa
Branch: MAIN
Changes since 1.259: +15 -14 lines
Diff to previous 1.259 (colored)

Fix a race in single-thread mode switching

Extend the scope of SCHED_LOCK() to better synchronize
single_thread_set(), single_thread_clear() and single_thread_check().
This prevents threads from suspending before single_thread_set() has
finished. If a thread suspended early, ps_singlecount might get
decremented too much, which in turn could make single_thread_wait()
get stuck.

The race could be triggered for example by trying to stop
a multithreaded process with a debugger. When triggered, the race
prevents the debugger from finishing a wait4(2) call on the debuggee.
This kind of gdb hang was reported by Julian Smith on misc@.

Unfortunately, single-thread mode switching still has issues and hangs
are still possible.

OK mpi@

Revision 1.259 / (download) - annotate - [select for diffs], Wed Aug 19 10:10:57 2020 UTC (3 years, 9 months ago) by mpi
Branch: MAIN
Changes since 1.258: +3 -1 lines
Diff to previous 1.258 (colored)

Push KERNEL_LOCK/UNLOCK() dance inside trapsignal().

ok kettenis@, visa@

Revision 1.258 / (download) - annotate - [select for diffs], Mon Jun 15 13:18:33 2020 UTC (3 years, 11 months ago) by visa
Branch: MAIN
Changes since 1.257: +7 -1 lines
Diff to previous 1.257 (colored)

Raise SPL when modifying ps_klist to prevent a race with interrupts.
The list can be accessed from interrupt context if a signal is sent
from an interrupt handler.

OK anton@ cheloha@ mpi@

Revision 1.257 / (download) - annotate - [select for diffs], Sun Jun 14 07:22:55 2020 UTC (3 years, 11 months ago) by visa
Branch: MAIN
Changes since 1.256: +1 -2 lines
Diff to previous 1.256 (colored)

Remove misleading XXX about locking of ps_klist. All of the kqueue
subsystem and ps_klist handling still run under the kernel lock.

Revision 1.256 / (download) - annotate - [select for diffs], Tue Apr 7 13:27:51 2020 UTC (4 years, 2 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.255: +3 -3 lines
Diff to previous 1.255 (colored)

Abstract the head of knote lists. This allows extending the lists,
for example, with locking assertions.

OK mpi@, anton@

Revision 1.255 / (download) - annotate - [select for diffs], Fri Mar 20 08:14:07 2020 UTC (4 years, 2 months ago) by claudio
Branch: MAIN
Changes since 1.254: +29 -18 lines
Diff to previous 1.254 (colored)

Use atomic operations to update ps_singlecount. This makes
single_thread_check() safe to be called without KERNEL_LOCK().
single_thread_wait() needs to use sleep_setup() and sleep_finish()
instead of tsleep() to make sure no wakeup() is lost.
Input kettenis@, with and OK visa@

Revision 1.254 / (download) - annotate - [select for diffs], Wed Mar 18 15:48:21 2020 UTC (4 years, 2 months ago) by visa
Branch: MAIN
Changes since 1.253: +13 -5 lines
Diff to previous 1.253 (colored)

Restart child process scan in dowait4() if single_thread_wait() sleeps.
This ensures that the conditions checked are still in force. The sleep
breaks atomicity, allowing another thread to alter the state.

single_thread_set() should return immediately after sleep when called
from dowait4() because there is no guarantee that the process pr still
exists. When called from single_thread_set(), the process is that of
the calling thread, which prevents process pr from disappearing.

OK anton@, mpi@, claudio@

Revision 1.253 / (download) - annotate - [select for diffs], Fri Mar 13 09:25:21 2020 UTC (4 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.252: +10 -10 lines
Diff to previous 1.252 (colored)

Rename "sigacts" flag field to avoid conflict with the "process" one.

This shows that atomic_* operations should not be necessery to write
to this field unlike with the process one.

The advantage of using a somewhat-unique prefix for struct member is
moot when multiple definitions use the same prefix :o)

From Amit Kulkarni, ok claudio@

Revision 1.252 / (download) - annotate - [select for diffs], Wed Mar 11 15:45:03 2020 UTC (4 years, 3 months ago) by claudio
Branch: MAIN
Changes since 1.251: +41 -2 lines
Diff to previous 1.251 (colored)

Move the sigprop definition and the other bits under SIGPROP into
kern_sig.c where they are currently added by the include. While doing
that mark the sigprop array as const.
OK mpi@ anton@ millert@

Revision 1.251 / (download) - annotate - [select for diffs], Fri Feb 21 11:10:23 2020 UTC (4 years, 3 months ago) by claudio
Branch: MAIN
Changes since 1.250: +1 -35 lines
Diff to previous 1.250 (colored)

Remove sigacts structure sharing. The only process that used sharing was
proc0 which is used for kthreads and idle threads. proc0 and all those
other kernel threads don't handle signals so there is no benefit in sharing.
Simplifies the code a fair bit since the refcnt is gone.
OK kettenis@

Revision 1.250 / (download) - annotate - [select for diffs], Fri Feb 21 06:08:42 2020 UTC (4 years, 3 months ago) by claudio
Branch: MAIN
Changes since 1.249: +2 -2 lines
Diff to previous 1.249 (colored)

Adjust a comment, no functional change

Revision 1.249 / (download) - annotate - [select for diffs], Thu Feb 20 16:56:52 2020 UTC (4 years, 3 months ago) by visa
Branch: MAIN
Changes since 1.248: +2 -2 lines
Diff to previous 1.248 (colored)

Replace field f_isfd with field f_flags in struct filterops to allow
adding more filter properties without cluttering the struct.

OK mpi@, anton@

Revision 1.248 / (download) - annotate - [select for diffs], Wed Feb 19 11:33:48 2020 UTC (4 years, 3 months ago) by claudio
Branch: MAIN
Changes since 1.247: +13 -13 lines
Diff to previous 1.247 (colored)

Remove the indirection via timeout for proc_stop_sweep(). Using a soft
interrupt is enough to defer the signal handling. This is a leftover
from the times where not all archs had generic soft interrupts.
It is possible that the defer signal handling to a soft interrupt will
be removed at a later stage.
Input anton@, mpi@ OK kettenis@

Revision 1.247 / (download) - annotate - [select for diffs], Sat Feb 15 09:35:48 2020 UTC (4 years, 3 months ago) by anton
Branch: MAIN
Changes since 1.246: +3 -3 lines
Diff to previous 1.246 (colored)

Consistently perform atomic writes to the ps_flags field of struct
process.

ok bluhm@ claudio@ visa@

Revision 1.246 / (download) - annotate - [select for diffs], Fri Feb 14 14:32:44 2020 UTC (4 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.245: +3 -1 lines
Diff to previous 1.245 (colored)

Push the KERNEL_LOCK() insidge pgsigio() and selwakeup().

The 3 subsystems: signal, poll/select and kqueue can now be addressed
separatly.

Note that bpf(4) and audio(4) currently delay the wakeups to a separate
context in order to respect the KERNEL_LOCK() requirement.  Sockets (UDP,
TCP) and pipes spin to grab the lock for the sames reasons.

ok anton@, visa@

Revision 1.245 / (download) - annotate - [select for diffs], Sat Feb 1 15:52:34 2020 UTC (4 years, 4 months ago) by anton
Branch: MAIN
Changes since 1.244: +1 -3 lines
Diff to previous 1.244 (colored)

Back out previous. Nothing wrong with the diff per se but I should have
asked for more oks; my bad!

Revision 1.244 / (download) - annotate - [select for diffs], Sat Feb 1 15:06:21 2020 UTC (4 years, 4 months ago) by anton
Branch: MAIN
Changes since 1.243: +3 -1 lines
Diff to previous 1.243 (colored)

Grab the kernel lock in pgsigio() as it's strictly needed while
operating on the process structure and issuing signals. This is similar
to what sigio_setown() already does.

With this in place, the pipe subsystem is no longer required to grab the
kernel lock before calling pgsigio().

ok visa@

Revision 1.243 / (download) - annotate - [select for diffs], Thu Jan 30 08:51:27 2020 UTC (4 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.242: +4 -4 lines
Diff to previous 1.242 (colored)

Split `p_priority' into `p_runpri' and `p_slppri'.

Using different fields to remember in which runqueue or sleepqueue
threads currently are will make it easier to split the SCHED_LOCK().

With this change, the (potentially boosted) sleeping priority is no
longer overwriting the thread priority.  This let us get rids of the
logic required to synchronize `p_priority' with `p_usrpri'.

Tested by many, ok visa@

Revision 1.242 / (download) - annotate - [select for diffs], Thu Jan 16 16:35:03 2020 UTC (4 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.241: +2 -2 lines
Diff to previous 1.241 (colored)

Introduce wakeup_proc() a function to un-SSTOP/SSLEEP a thread.

This moves most of the SCHED_LOCK() related to protecting the sleepqueue
and its states to kern/kern_sync.c

Name suggestion from jsg@, ok kettenis@, visa@

Revision 1.241 / (download) - annotate - [select for diffs], Tue Jan 14 08:52:18 2020 UTC (4 years, 4 months ago) by mpi
Branch: MAIN
Changes since 1.240: +7 -13 lines
Diff to previous 1.240 (colored)

Introduce TIMESPEC_TO_NSEC() and use it to convert userland facing
tsleep(9) to tsleep_nsec(9).

ok bluhm@

Revision 1.240 / (download) - annotate - [select for diffs], Wed Jan 8 16:27:41 2020 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.239: +16 -5 lines
Diff to previous 1.239 (colored)

Unify handling of ioctls FIOSETOWN/SIOCSPGRP/TIOCSPGRP and
FIOGETOWN/SIOCGPGRP/TIOCGPGRP. Do this by determining the meaning of
the ID parameter inside the sigio code. Also add cases for FIOSETOWN
and FIOGETOWN where there have been TIOCSPGRP and TIOCGPGRP before.
These changes allow removing the ID translation from sys_fcntl() and
sys_ioctl().

Idea from NetBSD

OK mpi@, claudio@

Revision 1.239 / (download) - annotate - [select for diffs], Fri Jan 3 09:46:41 2020 UTC (4 years, 5 months ago) by claudio
Branch: MAIN
Changes since 1.238: +1 -28 lines
Diff to previous 1.238 (colored)

Retire csignal() the last users were converted to use pgsigio(9) instead.
OK visa@ anton@

Revision 1.238 / (download) - annotate - [select for diffs], Tue Dec 31 13:48:32 2019 UTC (4 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.237: +7 -3 lines
Diff to previous 1.237 (colored)

Use C99 designated initializers with struct filterops. In addition,
make the structs const so that the data are put in .rodata.

OK mpi@, deraadt@, anton@, bluhm@

Revision 1.237 / (download) - annotate - [select for diffs], Thu Dec 19 17:40:11 2019 UTC (4 years, 5 months ago) by mpi
Branch: MAIN
Changes since 1.236: +3 -3 lines
Diff to previous 1.236 (colored)

Convert infinite sleeps to {m,t}sleep_nsec(9).

ok visa@

Revision 1.236 / (download) - annotate - [select for diffs], Wed Dec 11 07:30:09 2019 UTC (4 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.235: +12 -13 lines
Diff to previous 1.235 (colored)

Replace p_xstat with ps_xexit and ps_xsig
Convert those to a consolidated status when needed in wait4(), kevent(),
	and sysctl()
Pass exit code and signal separately to exit1()
(This also serves as prep for adding waitid(2))

ok mpi@

Revision 1.235 / (download) - annotate - [select for diffs], Sun Oct 6 16:24:14 2019 UTC (4 years, 8 months ago) by beck
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.234: +3 -2 lines
Diff to previous 1.234 (colored)

Fix vn_open to require an op of 0, and 0 or KERNELPATH only as flags.

sweep tree to correct NDIINT op and flags ahead of time. document
the requirement. This allows KERNELPATH to be used to bypass
unveil for crash dumps with nosuidcoredump=2 or 3

ok visa@ deraadt@ florian@

Revision 1.234 / (download) - annotate - [select for diffs], Thu Oct 3 13:58:59 2019 UTC (4 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.233: +24 -23 lines
Diff to previous 1.233 (colored)

sysctl global nosuidcoredump was being inspected twice inside coredump(),
with a sleep between.  Reorganize the code for a single check.
ok anton beck florian mpi

Revision 1.233 / (download) - annotate - [select for diffs], Wed Aug 7 14:14:01 2019 UTC (4 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.232: +11 -6 lines
Diff to previous 1.232 (colored)

avoid large MAXPATHLEN object on the stack in coredump(), by allocating
it from the pool.
ok bluhm visa

Revision 1.232 / (download) - annotate - [select for diffs], Wed Jul 10 15:52:17 2019 UTC (4 years, 11 months ago) by mpi
Branch: MAIN
Changes since 1.231: +2 -2 lines
Diff to previous 1.231 (colored)

Stop sleeping at PUSER.

This allows to enforce that sleeping priorities will now always be <
PUSER.

ok visa@, ratchov@

Revision 1.231 / (download) - annotate - [select for diffs], Fri Jun 21 09:39:48 2019 UTC (4 years, 11 months ago) by visa
Branch: MAIN
Changes since 1.230: +2 -3 lines
Diff to previous 1.230 (colored)

Make resource limit access MP-safe. So far, the copy-on-write sharing
of resource limit structs has been done between processes. By applying
copy-on-write also between threads, threads can read rlimits in
a nearly lock-free manner.

Inspired by code in DragonFly BSD and FreeBSD.

OK mpi@, agreement from jmatthew@ and anton@

Revision 1.230 / (download) - annotate - [select for diffs], Mon May 13 19:21:31 2019 UTC (5 years ago) by bluhm
Branch: MAIN
Changes since 1.229: +32 -22 lines
Diff to previous 1.229 (colored)

When killing a process, the signal is handled by any thread that
does not block the signal.  If all threads block the signal, we
delivered it to the main thread.  This does not conform to POSIX.
If any thread unblocks the signal, it should be delivered immediately
to this thread.
Mark such signals pending at the process instead of a single thread.
Then any thread can handle it later.
OK kettenis@ guenther@

Revision 1.229 / (download) - annotate - [select for diffs], Wed May 1 06:26:42 2019 UTC (5 years, 1 month ago) by dlg
Branch: MAIN
Changes since 1.228: +3 -1 lines
Diff to previous 1.228 (colored)

add a KERNEL_ASSERT_LOCKED() to ptsignal

it obviously needs to be called with the kernel lock held, so it
makes sense to check that so we can unlock more code without
introducing bugs that shoot us in the face in the indeterminate
future.

csignal is basically a wrapper around ptsignal, so calls to that
without the kernel lock should be caught by this too.

discussed with mpi@ on bugs@

Revision 1.228 / (download) - annotate - [select for diffs], Tue Feb 19 22:42:41 2019 UTC (5 years, 3 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.227: +3 -2 lines
Diff to previous 1.227 (colored)

open the coredump file non-blocking. cheloha found it blocks with a fifo.
ok cheloha deraadt

Revision 1.227 / (download) - annotate - [select for diffs], Wed Jan 23 21:53:42 2019 UTC (5 years, 4 months ago) by cheloha
Branch: MAIN
Changes since 1.226: +2 -2 lines
Diff to previous 1.226 (colored)

Sprinkle a pinch of timerisvalid/timespecisvalid over the rest of sys/kern

Revision 1.226 / (download) - annotate - [select for diffs], Mon Dec 17 14:51:57 2018 UTC (5 years, 5 months ago) by visa
Branch: MAIN
Changes since 1.225: +1 -13 lines
Diff to previous 1.225 (colored)

Remove unused function gsignal().

OK deraadt@ anton@

Revision 1.225 / (download) - annotate - [select for diffs], Mon Nov 12 15:09:17 2018 UTC (5 years, 6 months ago) by visa
Branch: MAIN
Changes since 1.224: +271 -1 lines
Diff to previous 1.224 (colored)

Add a mechanism for managing asynchronous IO signal registrations.
It centralizes IO signal privilege checking and makes possible to revoke
a registration when the target process or process group is deleted.

Adapted from FreeBSD.

OK kettenis@ mpi@ guenther@

Revision 1.224 / (download) - annotate - [select for diffs], Fri Aug 3 14:47:56 2018 UTC (5 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.223: +6 -3 lines
Diff to previous 1.223 (colored)

wrap long lines

Revision 1.223 / (download) - annotate - [select for diffs], Wed Jul 18 16:55:17 2018 UTC (5 years, 10 months ago) by bluhm
Branch: MAIN
Changes since 1.222: +4 -7 lines
Diff to previous 1.222 (colored)

Revert the change that delivers process signals to any threads.  As
side effect pending signals specifically sent to the main thread
were handled by other threads.  This made gcj in textproc/pdftk
port build stall.
Noticed and tested by espie@.

Revision 1.222 / (download) - annotate - [select for diffs], Wed Jul 11 19:28:16 2018 UTC (5 years, 11 months ago) by bluhm
Branch: MAIN
Changes since 1.221: +7 -4 lines
Diff to previous 1.221 (colored)

If no thread can immediately handle a signal, which has been sent
to the process, it is made pending at the main thread.  There it
could hang forever.  So also check the main thread for signal
delivery.  This workaround fixes hung tests in posixtestsuite.  The
proper solution would be to split pending signals for process and
threads.
input visa@; OK guenther@

Revision 1.221 / (download) - annotate - [select for diffs], Tue Jul 10 04:19:59 2018 UTC (5 years, 11 months ago) by guenther
Branch: MAIN
Changes since 1.220: +7 -11 lines
Diff to previous 1.220 (colored)

Move from sendsig() to its callers the initsiginfo() calls and
instead of passing sendsig() the code+type+val, pass a siginfo_t*
to copy from.  Eliminate the indirection through struct emul for
sendsig(); we no longer have a SunOS4-compat version of sendsig()

ok deraadt@

Revision 1.220 / (download) - annotate - [select for diffs], Sat Apr 28 03:13:04 2018 UTC (6 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.219: +4 -4 lines
Diff to previous 1.219 (colored)

Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@

Revision 1.219 / (download) - annotate - [select for diffs], Thu Apr 12 17:13:44 2018 UTC (6 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.218: +6 -1 lines
Diff to previous 1.218 (colored)

Implement MAP_STACK option for mmap().  Synchronous faults (pagefault and
syscall) confirm the stack register points at MAP_STACK memory, otherwise
SIGSEGV is delivered. sigaltstack() and pthread_attr_setstack() are modified
to create a MAP_STACK sub-region which satisfies alignment requirements.
Observe that MAP_STACK can only be set/cleared by mmap(), which zeroes the
contents of the region -- there is no mprotect() equivalent operation, so
there is no MAP_STACK-adding gadget.
This opportunistic software-emulation of a stack protection bit makes
stack-pivot operations during ROPchain fragile (kind of like removing a
tool from the toolbox).
original discussion with tedu, uvm work by stefan, testing by mortimer
ok kettenis

Revision 1.218 / (download) - annotate - [select for diffs], Tue Mar 27 08:22:41 2018 UTC (6 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.217: +8 -6 lines
Diff to previous 1.217 (colored)

Exclude SIGKILL from ptrace(2) interception.

This can lead to a deadlock where the parent waits infinitely for the
traced process.

Original problem reported by tb@ and worked around by visa@ for release
by not calling CURSIG() twice in userret().

ok tb@, visa@

Revision 1.217 / (download) - annotate - [select for diffs], Sat Mar 24 04:13:59 2018 UTC (6 years, 2 months ago) by visa
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.216: +2 -2 lines
Diff to previous 1.216 (colored)

Avoid calling issignal() twice on signal delivery in order not
to generate more than one ptrace(2) event. Do that by checking
pending signals first without altering any state. If there is
an unmasked signal ready for delivery, acquire the kernel lock
and redo the checks in issignal().

This prevents gdb from blocking on exit when it attempts to kill
an attached process, issue reported by tb@.

OK mpi@, deraadt@

Revision 1.216 / (download) - annotate - [select for diffs], Mon Feb 26 13:33:25 2018 UTC (6 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.215: +41 -34 lines
Diff to previous 1.215 (colored)

Fix a TOCTOU race that causes signals to be delivered more than once.

The race is only triggerable if one of the threads of a multi-threaded
program is in the middle of a NOLOCK syscall when a signal is received.

The problem is that `ps_sigact' is shared between threads so its access
should be serialized.  In the case of SA_RESETHAND, the handler is reset
when a signal is delivered, so delivering the signal twice would put the
process in an "impossible" state where some threads were stopped and some
were waiting for the others to die.

Serialize signal checking & processing with the KERNEL_LOCK() for now,
and introduce postsig_done() gypped from FreeBSD, to make sure the lock
is held when resetting the handler.

Bug report from espie@, ok visa@

Revision 1.215 / (download) - annotate - [select for diffs], Mon Feb 19 08:59:52 2018 UTC (6 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.214: +2 -2 lines
Diff to previous 1.214 (colored)

Remove almost unused `flags' argument of suser().

The account flag `ASU' will no longer be set but that makes suser()
mpsafe since it no longer mess with a per-process field.

No objection from millert@, ok tedu@, bluhm@

Revision 1.214 / (download) - annotate - [select for diffs], Sat Dec 30 23:08:29 2017 UTC (6 years, 5 months ago) by guenther
Branch: MAIN
Changes since 1.213: +2 -2 lines
Diff to previous 1.213 (colored)

Don't pull in <sys/file.h> just to get fcntl.h

ok deraadt@ krw@

Revision 1.213 / (download) - annotate - [select for diffs], Mon Nov 27 01:20:12 2017 UTC (6 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.212: +2 -2 lines
Diff to previous 1.212 (colored)

Fix comment typo

Revision 1.212 / (download) - annotate - [select for diffs], Thu Jun 8 17:14:02 2017 UTC (7 years ago) by bluhm
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.211: +9 -1 lines
Diff to previous 1.211 (colored)

ASLR, W^X, and guard pages trigger processor traps that result in
SIGILL, SIGBUS, SIGSEGV signals.  Make such memory violations visible
in lastcomm(1).  This also works if a programm tries to hide them
with a signal handler.  Manual kill -SEGV does not generate false
positives.
OK deraadt@

Revision 1.211 / (download) - annotate - [select for diffs], Thu Apr 20 12:59:36 2017 UTC (7 years, 1 month ago) by visa
Branch: MAIN
Changes since 1.210: +4 -1 lines
Diff to previous 1.210 (colored)

Add a port of witness(4) lock validation tool from FreeBSD.

Go-ahead from kettenis@, guenther@, deraadt@

Revision 1.210 / (download) - annotate - [select for diffs], Fri Apr 14 15:11:31 2017 UTC (7 years, 1 month ago) by bluhm
Branch: MAIN
Changes since 1.209: +3 -3 lines
Diff to previous 1.209 (colored)

Avoid some false positives with cppcheck.  No binary change.
OK jsg@

Revision 1.209 / (download) - annotate - [select for diffs], Thu Apr 13 03:52:25 2017 UTC (7 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.208: +2 -5 lines
Diff to previous 1.208 (colored)

Provide mips64 with kernel-facing TCB_{GET,SET} macros that store it
in struct mdproc.  With that, all archs have those and the __HAVE_MD_TCB
macro can be unifdef'ed as always defined.

ok kettenis@ visa@ jsing@

Revision 1.208 / (download) - annotate - [select for diffs], Tue Jan 24 00:58:55 2017 UTC (7 years, 4 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.207: +2 -2 lines
Diff to previous 1.207 (colored)

Rename pfind(9) into tfind(9) to reflect that it deals with threads.

While here document prfind(9.

with and ok guenther@

Revision 1.207 / (download) - annotate - [select for diffs], Sat Jan 21 05:42:03 2017 UTC (7 years, 4 months ago) by guenther
Branch: MAIN
Changes since 1.206: +7 -6 lines
Diff to previous 1.206 (colored)

p_comm is the process's command and isn't per thread, so move it from
struct proc to struct process.

ok deraadt@ kettenis@

Revision 1.206 / (download) - annotate - [select for diffs], Wed Oct 5 02:31:52 2016 UTC (7 years, 8 months ago) by guenther
Branch: MAIN
Changes since 1.205: +8 -8 lines
Diff to previous 1.205 (colored)

Display/test/use the process PID, not the thread's TID, in a few places.

ok mpi@ mikeb@

Revision 1.205 / (download) - annotate - [select for diffs], Thu Sep 15 02:00:16 2016 UTC (7 years, 8 months ago) by dlg
Branch: MAIN
Changes since 1.204: +3 -4 lines
Diff to previous 1.204 (colored)

all pools have their ipl set via pool_setipl, so fold it into pool_init.

the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);

Revision 1.204 / (download) - annotate - [select for diffs], Sun Sep 4 17:22:40 2016 UTC (7 years, 9 months ago) by jsing
Branch: MAIN
Changes since 1.203: +1 -58 lines
Diff to previous 1.203 (colored)

Remove sys_o58_kill since OpenBSD 6.0 has been tagged/released.

ok deraadt@

Revision 1.203 / (download) - annotate - [select for diffs], Thu Aug 25 00:00:02 2016 UTC (7 years, 9 months ago) by dlg
Branch: MAIN
Changes since 1.202: +2 -1 lines
Diff to previous 1.202 (colored)

pool_setipl

ok kettenis@

Revision 1.202 / (download) - annotate - [select for diffs], Thu Jul 14 05:55:08 2016 UTC (7 years, 10 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.201: +4 -1 lines
Diff to previous 1.201 (colored)

Prevent silly states via knotes on pids > 2^32 and on nonexistent signals.

ok tedu@

Revision 1.183.4.1 / (download) - annotate - [select for diffs], Thu Jul 14 02:46:11 2016 UTC (7 years, 10 months ago) by tedu
Branch: OPENBSD_5_8
Changes since 1.183: +3 -3 lines
Diff to previous 1.183 (colored) next main 1.184 (colored)

backport timeout overflow fixes:
fix several places where calculating ticks could overflow.
it's not enough to assign to an unsigned type because if the arithmetic
overflows the compiler may decide to do anything. so change all the
long long casts to uint64_t so that we start with the right type.
reported by Tim Newsham of NCC.
ok deraadt

Revision 1.192.2.1 / (download) - annotate - [select for diffs], Thu Jul 14 02:45:23 2016 UTC (7 years, 10 months ago) by tedu
Branch: OPENBSD_5_9
Changes since 1.192: +3 -3 lines
Diff to previous 1.192 (colored) next main 1.193 (colored)

backport timeout overflow fixes:
fix several places where calculating ticks could overflow.
it's not enough to assign to an unsigned type because if the arithmetic
overflows the compiler may decide to do anything. so change all the
long long casts to uint64_t so that we start with the right type.
reported by Tim Newsham of NCC.
ok deraadt

Revision 1.201 / (download) - annotate - [select for diffs], Wed Jul 6 15:53:01 2016 UTC (7 years, 11 months ago) by tedu
Branch: MAIN
Changes since 1.200: +3 -3 lines
Diff to previous 1.200 (colored)

fix several places where calculating ticks could overflow.
it's not enough to assign to an unsigned type because if the arithmetic
overflows the compiler may decide to do anything. so change all the
long long casts to uint64_t so that we start with the right type.
reported by Tim Newsham of NCC.
ok deraadt

Revision 1.200 / (download) - annotate - [select for diffs], Mon Jun 27 19:55:02 2016 UTC (7 years, 11 months ago) by jca
Branch: MAIN
Changes since 1.199: +9 -4 lines
Diff to previous 1.199 (colored)

Repair kill(2) on zombie processes.

kill(2) is supposed to find zombie processes, this probably got broken
when the process reaper was introduced.  As a temporary(tm) workaround,
walk the list of zombie processes if we can't find the target pid in the
main process list.

Problem with zsh initially reported by Geoff Wozniak on misc@, analysis
done by naddy@.  ok kettenis@ tedu@

Revision 1.199 / (download) - annotate - [select for diffs], Mon Jun 27 16:49:45 2016 UTC (7 years, 11 months ago) by jsing
Branch: MAIN
Changes since 1.198: +58 -1 lines
Diff to previous 1.198 (colored)

Restore the sys_o58_kill system call.

By keeping both the new (sys_kill/sys_thrkill) and old (sys_o58_kill)
system calls for the OpenBSD 6.0 release, code that uses either of these
mechanisms will work on both of the supported OpenBSD releases. This
provides a clean transition for runtimes that make direct system calls
(namely the Go programming language).

This requires a minimal amount of non-intrusive code and does not block
development progress within OpenBSD.

ok deraadt@ guenther@

Revision 1.198 / (download) - annotate - [select for diffs], Sat Jun 11 21:41:50 2016 UTC (8 years ago) by tedu
Branch: MAIN
Changes since 1.197: +6 -1 lines
Diff to previous 1.197 (colored)

if the timeout rounds to zero, make it one tick, otherwise we sleep
forever. noticed by Davin McCall.
while here, if the timeout actually is zero, return appropriate error.
ok guenther.

Revision 1.197 / (download) - annotate - [select for diffs], Tue May 31 22:14:43 2016 UTC (8 years ago) by deraadt
Branch: MAIN
Changes since 1.196: +1 -58 lines
Diff to previous 1.196 (colored)

sys_o58_kill is no longer needed for compat.
ok guenther sthen

Revision 1.196 / (download) - annotate - [select for diffs], Tue Mar 29 08:46:08 2016 UTC (8 years, 2 months ago) by mpi
Branch: MAIN
Changes since 1.195: +2 -3 lines
Diff to previous 1.195 (colored)

Use a macro to check if a thread has a sibling.

Note that without locking a thread cannot claim that it is part
of a multi-threaded process using this macro.

Suggested by miod@, ok guenther@

Revision 1.195 / (download) - annotate - [select for diffs], Sat Mar 26 21:38:54 2016 UTC (8 years, 2 months ago) by beck
Branch: MAIN
Changes since 1.194: +3 -3 lines
Diff to previous 1.194 (colored)

add newline on the end of the failure message
ok deraadt@

Revision 1.194 / (download) - annotate - [select for diffs], Sat Mar 19 12:04:15 2016 UTC (8 years, 2 months ago) by natano
Branch: MAIN
Changes since 1.193: +4 -4 lines
Diff to previous 1.193 (colored)

Remove the unused flags argument from VOP_UNLOCK().

torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt

Revision 1.193 / (download) - annotate - [select for diffs], Wed Mar 9 13:38:50 2016 UTC (8 years, 3 months ago) by mpi
Branch: MAIN
Changes since 1.192: +3 -3 lines
Diff to previous 1.192 (colored)

Correct some comments and definitions, from Michal Mazurek.

Revision 1.192 / (download) - annotate - [select for diffs], Sat Jan 9 06:13:43 2016 UTC (8 years, 5 months ago) by semarie
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE
Branch point for: OPENBSD_5_9
Changes since 1.191: +1 -2 lines
Diff to previous 1.191 (colored)

drop "abort" promise, and make it the default behaviour.
The current code has already setted it by default since 1.74

any pledge failure tries to make a coredump (default rules for coredump still
applies: so setuid binaries don't create them locally).

ok deraadt@

Revision 1.191 / (download) - annotate - [select for diffs], Sat Dec 5 10:11:53 2015 UTC (8 years, 6 months ago) by tedu
Branch: MAIN
Changes since 1.190: +1 -5 lines
Diff to previous 1.190 (colored)

remove stale lint annotations

Revision 1.190 / (download) - annotate - [select for diffs], Tue Nov 10 04:30:59 2015 UTC (8 years, 7 months ago) by guenther
Branch: MAIN
Changes since 1.189: +82 -5 lines
Diff to previous 1.189 (colored)

Split the intra-thread functionality from kill(2) into its own syscall
thrkill(2), rolling the kill(2) syscall number with the ABI change to
avoid breaking binaries during during the transition.  thrkill(2) includes
a 'tcb' argument that eliminates the need for locking in pthread_kill()
and simplifies pthread_cancel().  Switch __stack_smash_handler() to use
thrkill(2) and explicitly unblock SIGABRT.

Minor bump to both libc and libpthread: make sure you install a new kernel!

ok semarie@

Revision 1.189 / (download) - annotate - [select for diffs], Mon Nov 2 16:31:55 2015 UTC (8 years, 7 months ago) by semarie
Branch: MAIN
Changes since 1.188: +2 -2 lines
Diff to previous 1.188 (colored)

move the pledgenote annotation from `struct proc' to `struct nameidata'

pledgenote is used for annotate the policy for a namei context. So make it
tracking the nameidata.

It is expected for the caller to explicitly define the policy. It is a kernel
bug to not do so.

ok deraadt@

Revision 1.188 / (download) - annotate - [select for diffs], Sun Nov 1 19:03:33 2015 UTC (8 years, 7 months ago) by semarie
Branch: MAIN
Changes since 1.187: +4 -10 lines
Diff to previous 1.187 (colored)

refactor pledge_*_check and pledge_fail functions

- rename _check function without suffix: a "pledge" function called from
  anywhere is a "check" function.

- makes pledge_fail call the responsability to the _check function. remove it
  from caller.

- make proper use of (potential) returned error of _check() functions.

- adds pledge_kill() and pledge_protexec()

with and OK deraadt@

Revision 1.187 / (download) - annotate - [select for diffs], Sun Oct 25 20:39:54 2015 UTC (8 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.186: +3 -3 lines
Diff to previous 1.186 (colored)

Fold "malloc" into "stdio" and -- recognizing that no program so far has
used less than "stdio" -- include all the "self" operations.  Instead of
different defines, use regular PLEDGE_* in the "p_pledgenote" variable
(which indicates the operation subtype a system call is performing).  Many
checks before easier to understand.  p_pledgenote can often be passed
directly to ktrace, so that kdump says:
 15565 test     CALL  pledge(0xa9a3f804c51,0)
 15565 test     STRU  pledge request="stdio"
 15565 test     RET   pledge 0
 15565 test     CALL  open(0xa9a3f804c57,0x2<O_RDWR>)
 15565 test     NAMI  "/tmp/testfile"
 15565 test     PLDG  open, "wpath", errno 1 Operation not permitted
with help from semarie, ok guenther

Revision 1.186 / (download) - annotate - [select for diffs], Sat Oct 10 19:12:39 2015 UTC (8 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.185: +3 -2 lines
Diff to previous 1.185 (colored)

pid 0 also implies self, so allow that for the pledge case.  Found in
a refactoring being done for the bc/dc relationship with otto.

Revision 1.185 / (download) - annotate - [select for diffs], Fri Oct 9 23:55:03 2015 UTC (8 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.184: +10 -1 lines
Diff to previous 1.184 (colored)

Allow kill(self, sig) in pledge SELF also.  the stack protector, abort(),
and readpassphrase() in particular use this.
ok millert tedu semarie

Revision 1.184 / (download) - annotate - [select for diffs], Fri Oct 9 01:10:27 2015 UTC (8 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.183: +2 -2 lines
Diff to previous 1.183 (colored)

Rename tame() to pledge().  This fairly interface has evolved to be more
strict than anticipated.  It allows a programmer to pledge/promise/covenant
that their program will operate within an easily defined subset of the
Unix environment, or it pays the price.

Revision 1.183 / (download) - annotate - [select for diffs], Mon Jul 27 18:22:37 2015 UTC (8 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE
Branch point for: OPENBSD_5_8
Changes since 1.182: +2 -2 lines
Diff to previous 1.182 (colored)

Rather than disabling tame to coredump, leave it enabled but flag that
a coredump is happening.  This improves behaviour while threaded.
ok semarie

Revision 1.182 / (download) - annotate - [select for diffs], Mon Jul 20 00:19:14 2015 UTC (8 years, 10 months ago) by beck
Branch: MAIN
Changes since 1.181: +8 -6 lines
Diff to previous 1.181 (colored)

Fix annoying console spew when we can't write the core file. use log instead.
ok krw@ sthen@ comments from deraadt@, miod@

Revision 1.181 / (download) - annotate - [select for diffs], Sun Jul 19 02:35:35 2015 UTC (8 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.180: +2 -1 lines
Diff to previous 1.180 (colored)

tame(2) is a subsystem which restricts programs into a "reduced feature
operating model".  This is the kernel component; various changes should
proceed in-tree for a while before userland programs start using it.
ok miod, discussions and help from many

Revision 1.180 / (download) - annotate - [select for diffs], Tue May 5 02:13:46 2015 UTC (9 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.179: +4 -40 lines
Diff to previous 1.179 (colored)

emul_native is only used for kernel threads which can't dump core, so
delete coredump_trad(), uvm_coredump(), cpu_coredump(), struct md_coredump,
and various #includes that are superfluous.

This leaves compat_linux processes without a coredump callback.  If that
ability is desired, someone should update it to use coredump_elf32() and
verify the results...

ok kettenis@

Revision 1.179 / (download) - annotate - [select for diffs], Sat Mar 14 03:38:50 2015 UTC (9 years, 3 months ago) by jsg
Branch: MAIN
Changes since 1.178: +1 -2 lines
Diff to previous 1.178 (colored)

Remove some includes include-what-you-use claims don't
have any direct symbols used.  Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@

Revision 1.178 / (download) - annotate - [select for diffs], Mon Feb 9 13:41:24 2015 UTC (9 years, 4 months ago) by pelikan
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.177: +7 -10 lines
Diff to previous 1.177 (colored)

make sigprocmask(2) not take the kernel lock

Tests on a 4-core CPU show setjmp(3) run four times as fast under load.

discussed on tech@ some time ago, now by kettenis and guenther, ok deraadt

Revision 1.177 / (download) - annotate - [select for diffs], Fri Dec 19 05:59:21 2014 UTC (9 years, 5 months ago) by tedu
Branch: MAIN
Changes since 1.176: +3 -3 lines
Diff to previous 1.176 (colored)

start retiring the nointr allocator. specify PR_WAITOK as a flag as a
marker for which pools are not interrupt safe. ok dlg

Revision 1.176 / (download) - annotate - [select for diffs], Tue Dec 16 18:30:04 2014 UTC (9 years, 5 months ago) by tedu
Branch: MAIN
Changes since 1.175: +3 -1 lines
Diff to previous 1.175 (colored)

primary change: move uvm_vnode out of vnode, keeping only a pointer.
objective: vnode.h doesn't include uvm_extern.h anymore.
followup changes: include uvm_extern.h or lock.h where necessary.
ok and help from deraadt

Revision 1.175 / (download) - annotate - [select for diffs], Sun Nov 16 05:42:21 2014 UTC (9 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.174: +73 -65 lines
Diff to previous 1.174 (colored)

Rework the __thrsigdivert (aka sigwait()) handling: instead of interfering
in ptsignal(), which broke ptrace() in various circumstances, act more like
sigsuspend() by updating the signal mask and picking off waited for signals
when one occurs.  Don't always restart when an unwaited-for-but-handled
signal occurs, as that screws with both timeout calculation and cancellation.

main problem noted by jmatthew@
ok tedu@

Revision 1.174 / (download) - annotate - [select for diffs], Sun Aug 10 23:44:20 2014 UTC (9 years, 10 months ago) by bluhm
Branch: MAIN
Changes since 1.173: +3 -3 lines
Diff to previous 1.173 (colored)

Write the core file of a non-suid process into the current directory
even if sysctl kern.nosuidcoredump has been set to 2 or 3.  This
allows a regular user to debug his programs again.
OK guenther@ deraadt@

Revision 1.173 / (download) - annotate - [select for diffs], Sun Jul 13 16:41:21 2014 UTC (9 years, 11 months ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.172: +3 -2 lines
Diff to previous 1.172 (colored)

Introduce PS_NOBROADCASTKILL a process flag that excludes processes from
receiving broadcast signals (kill -1). The flag can be set via a new
sysctl KERN_PROC_NOBROADCASTKILL. This will be used by iscsid to survive
the mass killing by init(8) when terminating multi-user operations.
With and OK guenther@

Revision 1.172 / (download) - annotate - [select for diffs], Sun Jul 13 15:46:21 2014 UTC (9 years, 11 months ago) by uebayasi
Branch: MAIN
Changes since 1.171: +3 -7 lines
Diff to previous 1.171 (colored)

KERNEL_ASSERT_LOCKED(9): Assertion for kernel lock (Rev. 3)

This adds a new assertion macro, KERNEL_ASSERT_LOCKED(), to assert that
kernel_lock is held.  In the long process of removing kernel_lock, there will
be a lot (hundreds or thousands) of use of this; virtually almost all functions
in !MP-safe subsystems should have this assertion.  Thus this assertion should
have a short, good name.

Not only that "KERNEL_ASSERT_LOCKED" is consistent with other KERNEL_* and
SCHED_ASSERT_LOCKED() macros.

Input from dlg@ guenther@ kettenis@.

OK dlg@ guenther@

Revision 1.171 / (download) - annotate - [select for diffs], Sat Jul 12 21:21:19 2014 UTC (9 years, 11 months ago) by matthew
Branch: MAIN
Changes since 1.170: +16 -11 lines
Diff to previous 1.170 (colored)

Refactor out dosigsuspend() function

Discussed with guenther and kettenis

Revision 1.170 / (download) - annotate - [select for diffs], Fri Jul 11 08:18:31 2014 UTC (9 years, 11 months ago) by guenther
Branch: MAIN
Changes since 1.169: +2 -2 lines
Diff to previous 1.169 (colored)

It's init as a process that's special, not init's original thread.
Remember initprocess instead of initproc.

ok matthew@ blambert@

Revision 1.169 / (download) - annotate - [select for diffs], Tue Jul 8 17:19:25 2014 UTC (9 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.168: +1 -4 lines
Diff to previous 1.168 (colored)

decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis

Revision 1.168 / (download) - annotate - [select for diffs], Fri Jul 4 05:58:30 2014 UTC (9 years, 11 months ago) by guenther
Branch: MAIN
Changes since 1.167: +2 -3 lines
Diff to previous 1.167 (colored)

Track whether a process is a zombie or not yet fully built via flags
PS_{ZOMBIE,EMBRYO} on the process instead of peeking into the process's
thread data.  This eliminates the need for the thread-level SDEAD state.

Change kvm_getprocs() (both the sysctl() and kvm backends) to report the
"most active" scheduler state for the process's threads.

tweaks kettenis@
feedback and ok matthew@

Revision 1.167 / (download) - annotate - [select for diffs], Sat Jun 21 20:58:30 2014 UTC (9 years, 11 months ago) by guenther
Branch: MAIN
Changes since 1.166: +12 -1 lines
Diff to previous 1.166 (colored)

If the kernel generates a deadly trap signal (SEGV, BUS, etc) for
an untraced process but finds it blocking or ignoring it, just kill
the process instead of looping.  It's undefined behavor in POSIX but
quite annoying when encountered in practice.

improvements from kettenis@
ok matthew@

Revision 1.166 / (download) - annotate - [select for diffs], Sun May 4 05:03:26 2014 UTC (10 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.165: +6 -9 lines
Diff to previous 1.165 (colored)

Add PS_SYSTEM, the process-level mirror of the thread-level P_SYSTEM,
and FORK_SYSTEM as a flag to set them.  This eliminates needing to
peek into other processes threads in various places.  Inspired by NetBSD

ok miod@ matthew@

Revision 1.165 / (download) - annotate - [select for diffs], Sun May 4 03:53:37 2014 UTC (10 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.164: +40 -14 lines
Diff to previous 1.164 (colored)

When kern.nosuidcoredump=3, act like =2 but try to dump cores into
the /var/crash/programname/ directory, as root. For instance,
    # mkdir /var/crash/bgpd/
    # chmod 700 /var/crash/bgpd/    # If you skip this step, you are a moron
    # sysctl kern.nosuidcoredump=3
    # bgpd
    # pkill -ABRT bgpd
    # ls /var/crash/bgpd/
    14764.core   23207.core   6423.core
Of course, in real life the idea is that you don't kill the daemon but it
crashes and you collect parallel cores.  Careful you don't fill your /var.
Further tuneables are being considered.

Sorry to be picking on bgpd for this example.  I've watched the "too
difficult to debug privsep code" angst for far too long.
ok guenther

Revision 1.164 / (download) - annotate - [select for diffs], Fri Apr 18 11:51:17 2014 UTC (10 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.163: +8 -7 lines
Diff to previous 1.163 (colored)

Have each thread keeps its own (counted!) reference to the process's ucreds
to avoid possible use-after-free references when swapping ids in threaded
processes.  "Do I have the right creds?" checks are always made with the
threads creds.

Inspired by FreeBSD and NetBSD
"right time" deraadt@

Revision 1.163 / (download) - annotate - [select for diffs], Sun Mar 30 21:54:48 2014 UTC (10 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.162: +24 -18 lines
Diff to previous 1.162 (colored)

Eliminates struct pcred by moving the real and saved ugids into
struct ucred; struct process then directly links to the ucred

Based on a discussion at c2k10 or so before noting that FreeBSD and
NetBSD did this too.

ok matthew@

Revision 1.162 / (download) - annotate - [select for diffs], Wed Mar 26 05:27:18 2014 UTC (10 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.161: +20 -20 lines
Diff to previous 1.161 (colored)

Simply cansignal(), passing it processes instead of procs and
dropping the pcred argument.  Fix handling of kill(-1, sig) from a
thread other than the original thread.

ok deraadt@

Revision 1.161 / (download) - annotate - [select for diffs], Wed Mar 26 05:23:42 2014 UTC (10 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.160: +11 -9 lines
Diff to previous 1.160 (colored)

Move p_emul and p_sigcode from proc to process.
Tweak the handling of ktrace EMUL when changing ktracing: only
generate one per process (not one per thread) and pass the correct
proc pointer down to the VFS layer.  Permit generating of NAMI and
CSW records inside ktrace(2) itself.

ok deraadt@ millert@

Revision 1.160 / (download) - annotate - [select for diffs], Mon Mar 24 03:48:00 2014 UTC (10 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.159: +1 -2 lines
Diff to previous 1.159 (colored)

The kernel isn't involved in times(3); <sys/times.h> should never be
included there

Revision 1.159 / (download) - annotate - [select for diffs], Sat Mar 22 06:05:45 2014 UTC (10 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.158: +36 -32 lines
Diff to previous 1.158 (colored)

Move p_sigacts from struct proc to struct process.

testing help mpi@

Revision 1.158 / (download) - annotate - [select for diffs], Sun Feb 9 11:17:19 2014 UTC (10 years, 4 months ago) by kettenis
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.157: +35 -9 lines
Diff to previous 1.157 (colored)

Fix the lock order reversal problem in the code that stops traced
multi-threaded  processes when they receive a signal:

1. Make the parent of the process (the tracer) wait for all threads to be
   stopped (in wait4(2)) instead of the thread that received the signal.
   This prevents us from calling tsleep(9) recursively.

2. Assume that we already hold the kernel lock if the P_SINTR flag is set
   (just like we already assumed we were holding the scheduler lock) and
   don't try to grab it again.

This should fix the panic that many people reported when debugging
multi-threaded programs with gdb(1).

ok & lots of help from guenther@

Revision 1.157 / (download) - annotate - [select for diffs], Tue Jan 21 01:48:44 2014 UTC (10 years, 4 months ago) by tedu
Branch: MAIN
Changes since 1.156: +3 -3 lines
Diff to previous 1.156 (colored)

bzero -> memset

Revision 1.156 / (download) - annotate - [select for diffs], Mon Jan 20 21:19:28 2014 UTC (10 years, 4 months ago) by guenther
Branch: MAIN
Changes since 1.155: +15 -12 lines
Diff to previous 1.155 (colored)

Threads can't be zombies, only processes, so change zombproc to zombprocess,
make it a list of processes, and change P_NOZOMBIE and P_STOPPED from thread
flags to process flags.  Add allprocess list for the code that just wants
to see processes.

ok tedu@

Revision 1.155 / (download) - annotate - [select for diffs], Tue Oct 8 03:50:07 2013 UTC (10 years, 8 months ago) by guenther
Branch: MAIN
Changes since 1.154: +15 -1 lines
Diff to previous 1.154 (colored)

Fix delivery of SIGPROF and SIGVTALRM to threaded processes by having
hardclock() set a flag on the running thread and force AST processing,
and then have the thread signal itself from userret().

idea and flag names from FreeBSD
ok jsing@

Revision 1.154 / (download) - annotate - [select for diffs], Tue Oct 8 03:36:48 2013 UTC (10 years, 8 months ago) by guenther
Branch: MAIN
Changes since 1.153: +32 -20 lines
Diff to previous 1.153 (colored)

If a thread sends a signal to its own process, then have that thread
take the signal by preference if it's eligible (unblocked or sigwaiting).

ok jsing@

Revision 1.153 / (download) - annotate - [select for diffs], Sun Oct 6 19:44:42 2013 UTC (10 years, 8 months ago) by guenther
Branch: MAIN
Changes since 1.152: +2 -2 lines
Diff to previous 1.152 (colored)

Tweak comment

Revision 1.152 / (download) - annotate - [select for diffs], Sat Jun 1 04:05:26 2013 UTC (11 years ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.151: +10 -15 lines
Diff to previous 1.151 (colored)

some small style changes that are distracting me from seeing a real bug

Revision 1.151 / (download) - annotate - [select for diffs], Mon Apr 29 17:06:20 2013 UTC (11 years, 1 month ago) by matthew
Branch: MAIN
Changes since 1.150: +15 -1 lines
Diff to previous 1.150 (colored)

Extend P_SIGSUSPEND handling in userret() to properly restore the
sigmask even if there are no pending signals under the temporary
sigmask.

Refactor existing select() and poll() system calls to introduce the
pselect() and ppoll() system calls.

Add rthread wrappers for pselect() and ppoll().  While there, update
cancellation point comments to reflect recent fdatasync() addition.

Minor bumps for libc and librthread due to new symbols.

ok guenther, millert, deraadt, jmc

Revision 1.150 / (download) - annotate - [select for diffs], Sat Apr 6 06:08:20 2013 UTC (11 years, 2 months ago) by tedu
Branch: MAIN
Changes since 1.149: +1 -4 lines
Diff to previous 1.149 (colored)

i missed a file, crap.  found by deraadt

Revision 1.149 / (download) - annotate - [select for diffs], Thu Mar 28 16:55:25 2013 UTC (11 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.148: +1 -2 lines
Diff to previous 1.148 (colored)

do not include machine/cpu.h from a .c file; it is the responsibility of
.h files to pull it in, if needed
ok tedu

Revision 1.148 / (download) - annotate - [select for diffs], Fri Feb 8 04:30:37 2013 UTC (11 years, 4 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.147: +12 -13 lines
Diff to previous 1.147 (colored)

Insufficient levels of hops in the local brew led to Theo and I mucking
up the VFS calls in the error paths in coredump()

Pointed out by armani@, ok beck@

Revision 1.147 / (download) - annotate - [select for diffs], Tue Jan 15 02:03:38 2013 UTC (11 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.146: +14 -1 lines
Diff to previous 1.146 (colored)

Allow SIGKILL to terminate coredumping processes.  Semantics decided
with kettenis guenther and beck.
ok guenther

Revision 1.146 / (download) - annotate - [select for diffs], Tue Jan 15 01:34:27 2013 UTC (11 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.145: +45 -18 lines
Diff to previous 1.145 (colored)

Slice & dice coredump write requests into MAXPHYS blocks, and
yield between operations.  Re-grab the vnode every operation,
so that multiple coredumps can be saved at the same time.
ok guenther beck etc

Revision 1.145 / (download) - annotate - [select for diffs], Sun Dec 2 07:03:32 2012 UTC (11 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.144: +20 -4 lines
Diff to previous 1.144 (colored)

Determine whether we're currently on the alternative signal stack
dynamically, by comparing the stack pointer against the altstack
base and size, so that you get the correct answer if you longjmp
out of the signal handler, as tested by regress/sys/kern/stackjmp/.
Also, fix alt stack handling on vax, where it was completely broken.

Testing and corrections by miod@, krw@, tobiasu@, pirofti@

Revision 1.144 / (download) - annotate - [select for diffs], Wed Oct 17 04:48:52 2012 UTC (11 years, 7 months ago) by guenther
Branch: MAIN
Changes since 1.143: +13 -2 lines
Diff to previous 1.143 (colored)

If a thread calls __threxit() or _exit() immediately after another
thread coredumps, the former thread needs to be released by the
later single_thread_set(SINGLE_EXIT) call, even though its P_WEXIT
flag is set.

ok kettenis@

Revision 1.143 / (download) - annotate - [select for diffs], Wed Jul 11 08:45:21 2012 UTC (11 years, 11 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2
Changes since 1.142: +2 -2 lines
Diff to previous 1.142 (colored)

exit1(EXIT_THREAD) needs to call single_thread_check() so that it
can be suspended and/or decrement pr->ps_singlecount if necessary.
With that added, the call the other direction needs to use its own
flag (EXIT_THREAD_NOCHECK) to avoid looping.

problem diagnosed from a hang naddy@ hit; ok kettenis@

Revision 1.142 / (download) - annotate - [select for diffs], Wed Jun 6 04:47:43 2012 UTC (12 years ago) by guenther
Branch: MAIN
Changes since 1.141: +6 -6 lines
Diff to previous 1.141 (colored)

EVFILT_SIGNAL and EVFILT_PROC events need to track the process they're
attached to and not just the thread, which can go away.

Problem observed by jsg@; ok jsg@ matthew@

Revision 1.141 / (download) - annotate - [select for diffs], Fri Apr 13 16:37:51 2012 UTC (12 years, 2 months ago) by kettenis
Branch: MAIN
Changes since 1.140: +12 -4 lines
Diff to previous 1.140 (colored)

First stab at making ptrace(2) usable for debugging multi-threaded programs.
It implements a full-stop model where all threads are stopped before handing
over control to the debugger.  Events are reported as before through wait(2);
you will have to call ptrace(PT_GET_PROCESS_STATE, ...) to find out which
thread hit the event.  Since this changes the size of struct ptrace_state,
you will have to recompile gdb.

ok guenther@

Revision 1.140 / (download) - annotate - [select for diffs], Thu Apr 12 10:11:41 2012 UTC (12 years, 2 months ago) by mikeb
Branch: MAIN
Changes since 1.139: +3 -3 lines
Diff to previous 1.139 (colored)

move accounting flags to struct process; idea and ok guenther

Revision 1.139 / (download) - annotate - [select for diffs], Wed Apr 11 15:28:50 2012 UTC (12 years, 2 months ago) by kettenis
Branch: MAIN
Changes since 1.138: +2 -2 lines
Diff to previous 1.138 (colored)

Move the P_WAITED flag from struct proc to struct process.

ok guenther@

Revision 1.138 / (download) - annotate - [select for diffs], Fri Mar 23 15:51:26 2012 UTC (12 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.137: +3 -3 lines
Diff to previous 1.137 (colored)

Make rusage totals, itimers, and profile settings per-process instead
of per-rthread.  Handling of per-thread tick and runtime counters
inspired by how FreeBSD does it.

ok kettenis@

Revision 1.137 / (download) - annotate - [select for diffs], Mon Mar 19 09:05:39 2012 UTC (12 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.136: +20 -1 lines
Diff to previous 1.136 (colored)

Add tracing and dumping of "pointer to struct" syscall arguments for
structs timespec, timeval, sigaction, and rlimit.

ok otto@ jsing@

Revision 1.136 / (download) - annotate - [select for diffs], Sat Mar 10 06:27:21 2012 UTC (12 years, 3 months ago) by guenther
Branch: MAIN
Changes since 1.135: +7 -5 lines
Diff to previous 1.135 (colored)

Give sigwait priority over ptrace to avoid panic

Revision 1.135 / (download) - annotate - [select for diffs], Sat Mar 10 05:54:28 2012 UTC (12 years, 3 months ago) by guenther
Branch: MAIN
Changes since 1.134: +3 -4 lines
Diff to previous 1.134 (colored)

Add PS_EXITING to better differentiate between the process exiting and
the main thread exiting.  c.f. regress/sys/kern/main-thread-exited/

Revision 1.134 / (download) - annotate - [select for diffs], Mon Feb 20 22:23:39 2012 UTC (12 years, 3 months ago) by guenther
Branch: MAIN
Changes since 1.133: +18 -14 lines
Diff to previous 1.133 (colored)

First steps for making ptrace work with rthreads:
 - move the P_TRACED and P_INEXEC flags, and p_oppid, p_ptmask, and
   p_ptstat member from struct proc to struct process
 - sort the PT_* requests into those that take a PID vs those that
   can also take a TID
 - stub in PT_GET_THREAD_FIRST and PT_GET_THREAD_NEXT

ok kettenis@

Revision 1.133 / (download) - annotate - [select for diffs], Wed Jan 25 06:12:13 2012 UTC (12 years, 4 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.132: +30 -15 lines
Diff to previous 1.132 (colored)

A signal handled by __thrsigdivert() shouldn't be marked pending
for the thread handling it.  Otherwise (i.e., no sig divert), prefer
to deliver a process-aimed signal to some thread which doesn't have
the signal blocked.

ok tedu@

Revision 1.132 / (download) - annotate - [select for diffs], Tue Jan 17 02:34:18 2012 UTC (12 years, 4 months ago) by guenther
Branch: MAIN
Changes since 1.131: +3 -3 lines
Diff to previous 1.131 (colored)

Reimplement mutexes, condvars, and rwlocks to eliminate bugs,
particularly the "consume the signal you just sent" hang, and putting
the wait queues in userspace.

Do cancellation handling in pthread_cond_*wait(), pthread_join(),
and sem_wait().

Add __ prefix to thr{sleep,wakeup,exit,sigdivert}() syscalls; add
'abort" argument to thrsleep to close cancellation race; make
thr{sleep,wakeup} return errno values via *retval to avoid touching
userspace errno.

Revision 1.131 / (download) - annotate - [select for diffs], Sun Dec 11 19:42:28 2011 UTC (12 years, 6 months ago) by guenther
Branch: MAIN
Changes since 1.130: +164 -2 lines
Diff to previous 1.130 (colored)

Suspend other rthreads before dumping core or execing; make them exit
when exec succeeds.

ok jsing@

Revision 1.130 / (download) - annotate - [select for diffs], Tue Nov 22 23:20:19 2011 UTC (12 years, 6 months ago) by joshe
Branch: MAIN
Changes since 1.129: +13 -4 lines
Diff to previous 1.129 (colored)

Move struct proc's sigaltstack struct from the zeroed area into the
copied area, and initialize it properly in the FORK_THREAD case.

This restores the behavior of a forked process inheriting its parent's
signal stack.

ok guenther@

Revision 1.129 / (download) - annotate - [select for diffs], Wed Nov 16 20:50:19 2011 UTC (12 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.128: +12 -1 lines
Diff to previous 1.128 (colored)

Make userret() MI.  On architectures which jammed stuff into it in the
past, pull that code out seperately.
ok guenther miod

Revision 1.128 / (download) - annotate - [select for diffs], Wed Nov 9 20:57:38 2011 UTC (12 years, 7 months ago) by guenther
Branch: MAIN
Changes since 1.127: +6 -7 lines
Diff to previous 1.127 (colored)

Change fork1() and kthread_create() to match the rest of the tree
and use curp vs p instead of p1 vs p2.  Add curpr and pr variables
for the respective struct processes.  Make sigactsshare() return
the shared sigacts intead of taking the struct proc to update.

ok deraadt@

Revision 1.127 / (download) - annotate - [select for diffs], Tue Sep 20 10:07:37 2011 UTC (12 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.126: +23 -24 lines
Diff to previous 1.126 (colored)

MD trap() passes a MD "traptype" and siginfo-style "code" up to the MI
layers.  Then things get terribly confusing because the various MI layers
swap variable names for parameters, local variables, and structure fields
numerous times.  Unconfuse all this mess.

Note that exec_elf.c coredump cpi_sigcode used to contain the MD traptype
but will now contain the MI siginfo-style "code" value.
ok miod kettenis pirofti

Revision 1.126 / (download) - annotate - [select for diffs], Mon Jul 11 15:40:47 2011 UTC (12 years, 11 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.125: +2 -5 lines
Diff to previous 1.125 (colored)

Revert art@'s moving around of the KERNEL_LOCK()/KERNEL_UNLOCK() calls,
as it causes hangs in some ports, including libsigsegv's configure script

confirmed by krw@, landry@

Revision 1.125 / (download) - annotate - [select for diffs], Sat Jul 9 05:31:26 2011 UTC (12 years, 11 months ago) by matthew
Branch: MAIN
Changes since 1.124: +1 -45 lines
Diff to previous 1.124 (colored)

More syscalls.master cleanup:

sys_osigaltstack() is 7 years old and no longer needed; all glory to
the sys_sigaltstack()!

sys_ogetdirentries() is about 9 months old, but still acceptable
within our release cycle; move from STD to COMPAT_48 to make this
clearer for tedu@ next year.

sys_sbrk() and sys_sstk() are completely obsolete: all they do is
return ENOSYS.

ok guenther@

Revision 1.124 / (download) - annotate - [select for diffs], Thu Jul 7 18:11:24 2011 UTC (12 years, 11 months ago) by art
Branch: MAIN
Changes since 1.123: +5 -2 lines
Diff to previous 1.123 (colored)

There is a bunch of places in the kernel entry points where we don't
hold the kernel lock, but still need call one function that needs it.

Instead of grabbing the lock all over the place, move the locks into
the affected functions: trapsignal, scdebug*, ktrsyscall, ktrsysret,
systrace_redirect and ADDUPROF. In the cases we already hold the biglock
we'll just recurse.

kettenis@, beck@ ok

Revision 1.123 / (download) - annotate - [select for diffs], Wed Jul 6 21:41:37 2011 UTC (12 years, 11 months ago) by art
Branch: MAIN
Changes since 1.122: +3 -3 lines
Diff to previous 1.122 (colored)

Clean up after P_BIGLOCK removal.
KERNEL_PROC_LOCK -> KERNEL_LOCK
KERNEL_PROC_UNLOCK -> KERNEL_UNLOCK

oga@ ok

Revision 1.122 / (download) - annotate - [select for diffs], Tue Jul 5 04:48:02 2011 UTC (12 years, 11 months ago) by guenther
Branch: MAIN
Changes since 1.121: +81 -86 lines
Diff to previous 1.121 (colored)

Recommit the reverted sigacts change now that the NFS use-after-free
problem has been tracked down.  This fixes the sharing of the signal
handling state: shared bits go in sigacts, per-rthread bits goes in
struct proc.

ok deraadt@

Revision 1.121 / (download) - annotate - [select for diffs], Mon Apr 18 21:44:56 2011 UTC (13 years, 1 month ago) by guenther
Branch: MAIN
Changes since 1.120: +85 -80 lines
Diff to previous 1.120 (colored)

Revert the sigacts diff: NFS can apparently retain pointers to processes
until they're zombies and then send them signals (for intr mounts).  Until
that is untangled, the sigacts change is unsafe.  sthen@ was the victim
for this one

Revision 1.120 / (download) - annotate - [select for diffs], Fri Apr 15 04:52:40 2011 UTC (13 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.119: +81 -86 lines
Diff to previous 1.119 (colored)

Correct the sharing of the signal handling state: stuff that should
be shared (p_sigignore, p_sigcatch, P_NOCLDSTOP, P_NOCLDWAIT) moves
to struct sigacts, wihle stuff that should be per rthread (ps_oldmask,
SAS_OLDMASK, ps_sigstk) moves to struct proc.  Treat the coredumping
state bits (ps_sig, ps_code, ps_type, ps_sigval) as per-rthread
until our locking around coredumping is better.

Oh, and remove the old SunOS-compat ps_usertramp member.

"I like the sound of this" tedu@

Revision 1.119 / (download) - annotate - [select for diffs], Sun Apr 3 14:56:28 2011 UTC (13 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.118: +5 -4 lines
Diff to previous 1.118 (colored)

Move PPWAIT flag from struct proc to process, so that rthreads in
a vforked child behave correctly.  Have the parent in a vfork()
wait on a (different) flag in *its* process instead of the child
to prevent a possible use-after-free.  When ktracing the child
return from a fork, call it rfork if an rthread was created.

ok blambert@

Revision 1.118 / (download) - annotate - [select for diffs], Sat Apr 2 17:04:35 2011 UTC (13 years, 2 months ago) by guenther
Branch: MAIN
Changes since 1.117: +4 -4 lines
Diff to previous 1.117 (colored)

Move P_SUGID and P_SUGIDEXEC from struct proc to struct process, so
that you can't evade the checks by doing the dirty work in an rthread

ok blambert@, deraadt@

Revision 1.117 / (download) - annotate - [select for diffs], Mon Mar 7 07:07:13 2011 UTC (13 years, 3 months ago) by guenther
Branch: MAIN
Changes since 1.116: +3 -3 lines
Diff to previous 1.116 (colored)

The scheduling 'nice' value is per-process, not per-thread, so move it
into struct process.

ok tedu@ deraadt@

Revision 1.116 / (download) - annotate - [select for diffs], Mon Jul 26 01:56:27 2010 UTC (13 years, 10 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.115: +30 -29 lines
Diff to previous 1.115 (colored)

Correct the links between threads, processes, pgrps, and sessions,
so that the process-level stuff is to/from struct process and not
struct proc.  This fixes a bunch of problem cases in rthreads.
Based on earlier work by blambert and myself, but mostly written
at c2k10.

Tested by many: deraadt, sthen, krw, ray, and in snapshots

Revision 1.115 / (download) - annotate - [select for diffs], Fri Jul 2 19:57:15 2010 UTC (13 years, 11 months ago) by tedu
Branch: MAIN
Changes since 1.114: +1 -12 lines
Diff to previous 1.114 (colored)

remove support for compat_sunos (and m68k4k).  ok deraadt guenther

Revision 1.114 / (download) - annotate - [select for diffs], Thu Jul 1 02:41:12 2010 UTC (13 years, 11 months ago) by guenther
Branch: MAIN
Changes since 1.113: +12 -11 lines
Diff to previous 1.113 (colored)

Always identify threads with THREAD_PID_OFFSET, so that there's no
way a kill() intended for a thread can result in a separate process
getting the signal.
ok tedu@ art@

Revision 1.113 / (download) - annotate - [select for diffs], Wed Jun 30 01:47:35 2010 UTC (13 years, 11 months ago) by tedu
Branch: MAIN
Changes since 1.112: +34 -20 lines
Diff to previous 1.112 (colored)

lots of SCARG simplification.  ok matthew

Revision 1.112 / (download) - annotate - [select for diffs], Tue Jun 29 20:48:50 2010 UTC (13 years, 11 months ago) by guenther
Branch: MAIN
Changes since 1.111: +1 -4 lines
Diff to previous 1.111 (colored)

Strip out ancient bits in struct user that were still used only by
the now-removed HPUX compat code.
ok and build testing deraadt@

Revision 1.111 / (download) - annotate - [select for diffs], Tue Jun 29 02:46:43 2010 UTC (13 years, 11 months ago) by tedu
Branch: MAIN
Changes since 1.110: +15 -14 lines
Diff to previous 1.110 (colored)

less SCARG, more pretty.  ok guenther

Revision 1.110 / (download) - annotate - [select for diffs], Tue Jun 29 00:28:14 2010 UTC (13 years, 11 months ago) by tedu
Branch: MAIN
Changes since 1.109: +6 -21 lines
Diff to previous 1.109 (colored)

Eliminate RTHREADS kernel option in favor of a sysctl.  The actual status
(not done) hasn't changed, but now it's less work to test things.
ok art deraadt

Revision 1.109 / (download) - annotate - [select for diffs], Mon Jun 28 23:00:30 2010 UTC (13 years, 11 months ago) by guenther
Branch: MAIN
Changes since 1.108: +1 -2 lines
Diff to previous 1.108 (colored)

<sys/time.b> is for ftime(), which is just in libcompat and not the kernel,
so stop including it in kernel .c files.
"sure" deraadt@

Revision 1.108 / (download) - annotate - [select for diffs], Tue May 18 22:26:10 2010 UTC (14 years ago) by tedu
Branch: MAIN
Changes since 1.107: +4 -4 lines
Diff to previous 1.107 (colored)

move knote list to struct process.  ok guenther

Revision 1.107 / (download) - annotate - [select for diffs], Fri Nov 27 19:43:55 2009 UTC (14 years, 6 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7
Changes since 1.106: +29 -3 lines
Diff to previous 1.106 (colored)

Convert thrsigdivert to (almost) be sigtimedwait by adding siginfo_t
and struct timespec * argument.  sigtimedwait is just a one line
wrapper after this.

"get it in" deraadt@, tedu@, cheers by others

Revision 1.106 / (download) - annotate - [select for diffs], Wed Nov 4 19:14:10 2009 UTC (14 years, 7 months ago) by kettenis
Branch: MAIN
Changes since 1.105: +2 -7 lines
Diff to previous 1.105 (colored)

Get rid of __HAVE_GENERIC_SOFT_INTERRUPTS now that all our platforms support it.

ok jsing@, miod@

Revision 1.105 / (download) - annotate - [select for diffs], Sat Jun 6 21:25:19 2009 UTC (15 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.104: +11 -1 lines
Diff to previous 1.104 (colored)

We need miod's no-coredumps-on-ramdisks diff, because we have grown the
media just a wee bit too much.

Revision 1.104 / (download) - annotate - [select for diffs], Fri Jun 5 03:57:32 2009 UTC (15 years ago) by ray
Branch: MAIN
Changes since 1.103: +2 -2 lines
Diff to previous 1.103 (colored)

%zu is not meant for size_t in the kernel. Change to %lu.

OK miod

Revision 1.103 / (download) - annotate - [select for diffs], Thu Mar 5 19:52:24 2009 UTC (15 years, 3 months ago) by kettenis
Branch: MAIN
Changes since 1.102: +57 -10 lines
Diff to previous 1.102 (colored)

Make ELF platforms generate ELF core dumps.  Somewhat based on code from
NetBSD.

ok kurt@, drahn@, miod@

Revision 1.102 / (download) - annotate - [select for diffs], Thu Jan 29 22:18:06 2009 UTC (15 years, 4 months ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.101: +3 -4 lines
Diff to previous 1.101 (colored)

Remove KASSERT() that could trigger when an rthread in sigwait()
got multiple signals before tsleep() could wakeup.  Also, POSIX
says that sigwait() should never return EINTR, so map that to
ERESTART.

ok kurt@, tedu@
fixes the panic encountered by ariane@ with kaffe

Revision 1.101 / (download) - annotate - [select for diffs], Tue Dec 16 07:57:28 2008 UTC (15 years, 5 months ago) by guenther
Branch: MAIN
Changes since 1.100: +64 -28 lines
Diff to previous 1.100 (colored)

Move the functionality of psignal() to a new function ptsignal()
that takes an additional argument "type" that indicates whether the
signal is for the process, just a particular thread, or propagated
to a thread because it's not caught or blocked.  psignal() becomes
a wrapper that does the first of those.

So that sys_kill() can tell apart signals for the process and signals
for the process's original thread, the tid of the original thread
is defined as its pid + THREAD_PID_OFFSET.

ok tedu@ art@ andreas@ kurt@   "better early than late" deraadt@

Revision 1.100 / (download) - annotate - [select for diffs], Fri Oct 3 04:22:37 2008 UTC (15 years, 8 months ago) by guenther
Branch: MAIN
Changes since 1.99: +47 -6 lines
Diff to previous 1.99 (colored)

Make sigwait() work correctly.  In particular, it'll work when the
signal is already pending in the calling thread or the main thread
and there's no longer a race condition where the signal could be
diverted but sigwait() would still block.  There were some off-by-one
errors too.

(The checking of the main thread's pending list is just until a
pending list for the process can be added to struct process.  For
now, such signals end up as pending on the main thread.)

oks tedu@ and art@

Revision 1.99 / (download) - annotate - [select for diffs], Tue Jun 10 20:41:52 2008 UTC (16 years ago) by hshoexer
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.98: +3 -11 lines
Diff to previous 1.98 (colored)

posix compliant permission checks for sending signals.  Based on diffs
provided by christian ehrhardt (Christian_Ehrhardt@genua.de) and micky,
thanks!

ok deraadt millert

Revision 1.98 / (download) - annotate - [select for diffs], Thu May 22 17:04:59 2008 UTC (16 years ago) by thib
Branch: MAIN
Changes since 1.97: +2 -2 lines
Diff to previous 1.97 (colored)

Use LIST_FOREACH() instead of handrolling.

From: Pierre Riteau pierre.riteau_att_gmail.com
OK miod@

Revision 1.97 / (download) - annotate - [select for diffs], Tue Nov 27 16:22:13 2007 UTC (16 years, 6 months ago) by martynas
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.96: +2 -2 lines
Diff to previous 1.96 (colored)

typos;  ok jmc@
sys/dev/pci/pciide.c from naddy@

Revision 1.96 / (download) - annotate - [select for diffs], Mon Nov 19 17:47:47 2007 UTC (16 years, 6 months ago) by millert
Branch: MAIN
Changes since 1.95: +3 -3 lines
Diff to previous 1.95 (colored)

Don't overwrite a core file owned by a different user.  Makes the code
match the comment.  OK deraadt@

Revision 1.95 / (download) - annotate - [select for diffs], Sat Sep 1 15:14:44 2007 UTC (16 years, 9 months ago) by martin
Branch: MAIN
Changes since 1.94: +5 -5 lines
Diff to previous 1.94 (colored)

replace the machine dependant bytes-to-clicks macro by the MI ptoa()
version for i386

more architectures and ctob() replacement is being worked on

prodded by and ok miod

Revision 1.94 / (download) - annotate - [select for diffs], Wed May 30 07:42:52 2007 UTC (17 years ago) by moritz
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.93: +7 -4 lines
Diff to previous 1.93 (colored)

Adjust filename buffer for the new /var/crash prefix to prevent
truncation and add an additional truncation check.

ok deraadt@ tedu@

Revision 1.93 / (download) - annotate - [select for diffs], Tue May 29 00:26:29 2007 UTC (17 years ago) by jcs
Branch: MAIN
Changes since 1.92: +3 -2 lines
Diff to previous 1.92 (colored)

update comment re nosuidcoredump sysctl
ok tedu

Revision 1.92 / (download) - annotate - [select for diffs], Tue May 29 00:03:18 2007 UTC (17 years ago) by tedu
Branch: MAIN
Changes since 1.91: +10 -7 lines
Diff to previous 1.91 (colored)

put suid coredumps into /var/crash if kern.nosuidcoredump is set to 2.
makes debugging easier, docs in a bit
ok beck deraadt

Revision 1.91 / (download) - annotate - [select for diffs], Tue May 8 14:16:36 2007 UTC (17 years, 1 month ago) by miod
Branch: MAIN
Changes since 1.90: +4 -1 lines
Diff to previous 1.90 (colored)

Needs an extern decl for generic soft interrupts platforms.

Revision 1.90 / (download) - annotate - [select for diffs], Tue May 8 11:16:31 2007 UTC (17 years, 1 month ago) by art
Branch: MAIN
Changes since 1.89: +60 -20 lines
Diff to previous 1.89 (colored)

First step in making the SCHED_LOCK not recursive.
 - Defer the sending of SIGCHLD and waking the parent when a process goes
   to sleep. We set a flag in the process "P_STOPPED" and schedule a
   timeout that checks all processes for this flag and sends SIGCHLD
   and wakes the parent on those processes that have this flag set.
 - Delay the waking of the parent in psignal on SIGCONT until we've
   released the SCHED_LOCK at the end.
 - In issignal, check for P_SINTR as a way to see we were called from
   the tsleep path with SCHED_LOCK locked and don't skip locking
   in that case. (This is slightly ugly, but it works until we have
   some better way).

miod@ ok (after finding and fixing an MD bug on sgi)

Revision 1.89 / (download) - annotate - [select for diffs], Tue Apr 3 08:05:43 2007 UTC (17 years, 2 months ago) by art
Branch: MAIN
Changes since 1.88: +16 -8 lines
Diff to previous 1.88 (colored)

Start moving state that is shared among threads in a process into
a new struct. Instead of doing a huge rename and deal with the fallout
for weeks, like other projects that need no mention, we will slowly and
carefully move things out of struct proc into a new struct process.

 - Create struct process and the infrastructure to create and remove them.
 - Move threads in a process into struct process.

deraadt@, tedu@ ok

Revision 1.88 / (download) - annotate - [select for diffs], Thu Mar 15 10:22:30 2007 UTC (17 years, 3 months ago) by art
Branch: MAIN
Changes since 1.87: +10 -10 lines
Diff to previous 1.87 (colored)

Since p_flag is often manipulated in interrupts and without biglock
it's a good idea to use atomic.h operations on it. This mechanic
change updates all bit operations on p_flag to atomic_{set,clear}bits_int.

Only exception is that P_OWEUPC is set by MI code before calling
need_proftick and it's automatically cleared by ADDUPC. There's
no reason for MD handling of that flag since everyone handles it the
same way.

kettenis@ ok

Revision 1.87 / (download) - annotate - [select for diffs], Tue Feb 6 18:42:37 2007 UTC (17 years, 4 months ago) by art
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.86: +16 -14 lines
Diff to previous 1.86 (colored)

Use atomic.h operation for manipulating p_siglist in struct proc. Solves
the problem with lost signals in MP kernels.

miod@, kettenis@ ok

Revision 1.86 / (download) - annotate - [select for diffs], Wed Jan 17 23:08:18 2007 UTC (17 years, 4 months ago) by art
Branch: MAIN
Changes since 1.85: +4 -3 lines
Diff to previous 1.85 (colored)

When sending signals, instead of checking if the process sending the
signal to is the curproc, check if it's SONPROC. That way we'll also
signotify processes on other CPUs. This gives MD code the opportunity
to actually deliver signals to other CPUs faster than the clock
interrupt (in the worst case).

This is a NOP until MD code is fixed.

miod@ ok

Revision 1.85 / (download) - annotate - [select for diffs], Tue Jan 16 17:52:18 2007 UTC (17 years, 4 months ago) by thib
Branch: MAIN
Changes since 1.84: +1 -2 lines
Diff to previous 1.84 (colored)

Retire VOP_LEASE(); It was a bit for NQNFS and has
effectively been a no-op for quite some time now,
without promise for future usage.

ok pedro@
Testing by krw@ (earlier diff)
and Johan Mson Lindman (tybollt@solace.miun.se)

Revision 1.84 / (download) - annotate - [select for diffs], Thu Jun 15 20:08:01 2006 UTC (18 years ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.83: +4 -16 lines
Diff to previous 1.83 (colored)

Nothing sets P_FSTRACE anymore, so remove all what's left of it.

Revision 1.83 / (download) - annotate - [select for diffs], Wed Jun 7 18:58:39 2006 UTC (18 years ago) by miod
Branch: MAIN
Changes since 1.82: +1 -15 lines
Diff to previous 1.82 (colored)

killproc() is orphaned, so kill it; ok deraadt@

Revision 1.82 / (download) - annotate - [select for diffs], Sat Mar 4 10:22:20 2006 UTC (18 years, 3 months ago) by miod
Branch: MAIN
Changes since 1.81: +11 -37 lines
Diff to previous 1.81 (colored)

Remove traditional coredump support since all our platforms have proper
cpu_coredump() behaviour.

Revision 1.81 / (download) - annotate - [select for diffs], Mon Feb 20 19:39:11 2006 UTC (18 years, 3 months ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9
Changes since 1.80: +11 -2 lines
Diff to previous 1.80 (colored)

Compile out more rthreads stuff unless option RTHREADS;
discussed with a few, ok tedu@

Revision 1.80 / (download) - annotate - [select for diffs], Wed Jan 18 23:42:12 2006 UTC (18 years, 4 months ago) by miod
Branch: MAIN
Changes since 1.79: +7 -5 lines
Diff to previous 1.79 (colored)

Fix logic botch when checking for COMPAT_SUNOS binary specifics; repairs
some TIOCGPGRP result fallout.
ok deraadt@

Revision 1.79 / (download) - annotate - [select for diffs], Thu Dec 22 06:58:20 2005 UTC (18 years, 5 months ago) by tedu
Branch: MAIN
Changes since 1.78: +9 -3 lines
Diff to previous 1.78 (colored)

1.  when signalling a process group, don't deliver a copy to every thread
2.  when delivering a STOP or CONT signal to a process, now replicate
	to every thread.
makes ^Z and fg work nicer, first noticed by peter hessler.
signals and threads are not right, but this is at least a little less wrong.

Revision 1.78 / (download) - annotate - [select for diffs], Sat Dec 3 18:09:08 2005 UTC (18 years, 6 months ago) by tedu
Branch: MAIN
Changes since 1.77: +28 -2 lines
Diff to previous 1.77 (colored)

kernel support for threaded processes (rthreads).
uses rfork(RFTHREAD) to create threads, which are presently processes
that are a little more tightly bound together.  several new syscalls
added to facilitate a userland thread library.
all conditional on RTHREADS, currently disabled.
ok deraadt

Revision 1.77 / (download) - annotate - [select for diffs], Mon Nov 28 00:14:29 2005 UTC (18 years, 6 months ago) by jsg
Branch: MAIN
Changes since 1.76: +53 -116 lines
Diff to previous 1.76 (colored)

ansi/deregister.
'go for it' deraadt@

Revision 1.76 / (download) - annotate - [select for diffs], Fri Jun 17 22:33:34 2005 UTC (18 years, 11 months ago) by niklas
Branch: MAIN
CVS Tags: OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.75: +8 -26 lines
Diff to previous 1.75 (colored)

A second approach at fixing the telnet localhost & problem
(but I tend to call it ssh localhost & now when telnetd is
history).  This is more localized patch, but leaves us with
a recursive lock for protecting scheduling and signal state.
Better care is taken to actually be symmetric over mi_switch.
Also, the dolock cruft in psignal can go with this solution.
Better test runs by more people for longer time has been
carried out compared to the c2k5 patch.

Long term the current mess with interruptible sleep, the
default action on stop signals and wakeup interactions need
to be revisited.  ok deraadt@, art@

Revision 1.75 / (download) - annotate - [select for diffs], Sun May 29 03:20:41 2005 UTC (19 years ago) by deraadt
Branch: MAIN
Changes since 1.74: +41 -20 lines
Diff to previous 1.74 (colored)

sched work by niklas and art backed out; causes panics

Revision 1.74 / (download) - annotate - [select for diffs], Wed May 25 23:17:47 2005 UTC (19 years ago) by niklas
Branch: MAIN
Changes since 1.73: +21 -42 lines
Diff to previous 1.73 (colored)

This patch is mortly art's work and was done *a year* ago.  Art wants to thank
everyone for the prompt review and ok of this work ;-)  Yeah, that includes me
too, or maybe especially me.  I am sorry.

Change the sched_lock to a mutex. This fixes, among other things, the infamous
"telnet localhost &" problem.  The real bug in that case was that the sched_lock
which is by design a non-recursive lock, was recursively acquired, and not
enough releases made us hold the lock in the idle loop, blocking scheduling
on the other processors.  Some of the other processors would hold the biglock though,
which made it impossible for cpu 0 to enter the kernel...  A nice deadlock.
Let me just say debugging this for days just to realize that it was all fixed
in an old diff noone ever ok'd was somewhat of an anti-climax.

This diff also changes splsched to be correct for all our architectures.

Revision 1.73 / (download) - annotate - [select for diffs], Sun Dec 26 21:22:13 2004 UTC (19 years, 5 months ago) by miod
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.72: +4 -5 lines
Diff to previous 1.72 (colored)

Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.

Revision 1.72 / (download) - annotate - [select for diffs], Sun Jul 4 13:35:01 2004 UTC (19 years, 11 months ago) by niklas
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.71: +2 -2 lines
Diff to previous 1.71 (colored)

proc_stop needs sched_lock locked.  From art, verified with NetBSD.

Revision 1.71 / (download) - annotate - [select for diffs], Sun Jun 13 21:49:26 2004 UTC (20 years ago) by niklas
Branch: MAIN
Changes since 1.70: +42 -8 lines
Diff to previous 1.70 (colored)

debranch SMP, have fun

Revision 1.35.2.16 / (download) - annotate - [select for diffs], Sun Jun 6 22:27:47 2004 UTC (20 years ago) by niklas
Branch: SMP
Changes since 1.35.2.15: +5 -1 lines
Diff to previous 1.35.2.15 (colored) to branchpoint 1.35 (colored) next main 1.36 (colored)

splsched not in !MP

Revision 1.35.2.15 / (download) - annotate - [select for diffs], Sun Jun 6 21:46:12 2004 UTC (20 years ago) by tedu
Branch: SMP
Changes since 1.35.2.14: +3 -1 lines
Diff to previous 1.35.2.14 (colored) to branchpoint 1.35 (colored)

don't rely on curcpu() and other fixes for non-mp

Revision 1.35.2.14 / (download) - annotate - [select for diffs], Sat Jun 5 23:18:25 2004 UTC (20 years ago) by tedu
Branch: SMP
Changes since 1.35.2.13: +2 -1 lines
Diff to previous 1.35.2.13 (colored) to branchpoint 1.35 (colored)

few fixes to make non-smp compile

Revision 1.35.2.13 / (download) - annotate - [select for diffs], Sat Jun 5 23:13:01 2004 UTC (20 years ago) by niklas
Branch: SMP
Changes since 1.35.2.12: +27 -16 lines
Diff to previous 1.35.2.12 (colored) to branchpoint 1.35 (colored)

Merge with the trunk

Revision 1.70 / (download) - annotate - [select for diffs], Tue Apr 6 17:24:11 2004 UTC (20 years, 2 months ago) by mickey
Branch: MAIN
CVS Tags: SMP_SYNC_B, SMP_SYNC_A
Changes since 1.69: +28 -17 lines
Diff to previous 1.69 (colored)

fix siginfo generation for posted signals and avoid double ktrpsig() call for the same signal; deraadt@ ok

Revision 1.35.2.12 / (download) - annotate - [select for diffs], Thu Feb 19 10:56:37 2004 UTC (20 years, 3 months ago) by niklas
Branch: SMP
Changes since 1.35.2.11: +63 -16 lines
Diff to previous 1.35.2.11 (colored) to branchpoint 1.35 (colored)

Merge of current from two weeks agointo the SMP branch

Revision 1.69 / (download) - annotate - [select for diffs], Wed Jan 14 05:23:25 2004 UTC (20 years, 5 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.68: +48 -3 lines
Diff to previous 1.68 (colored)

change sigaltstack.ss_size type to size_t.  handle syscall fallout.
add stack_t and ucontext_t typedefs.
ok deraadt@

Revision 1.68 / (download) - annotate - [select for diffs], Mon Sep 1 18:06:03 2003 UTC (20 years, 9 months ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE, OPENBSD_3_4
Changes since 1.67: +3 -3 lines
Diff to previous 1.67 (colored)

match syscallargs comments with reality
from Patrick Latifi <patrick.l@hermes.usherb.ca>
ok jason@ tedu@

Revision 1.67 / (download) - annotate - [select for diffs], Fri Aug 15 20:32:18 2003 UTC (20 years, 10 months ago) by tedu
Branch: MAIN
Changes since 1.66: +2 -2 lines
Diff to previous 1.66 (colored)

change arguments to suser.  suser now takes the process, and a flags
argument.  old cred only calls user suser_ucred.  this will allow future
work to more flexibly implement the idea of a root process.  looks like
something i saw in freebsd, but a little different.
use of suser_ucred vs suser in file system code should be looked at again,
for the moment semantics remain unchanged.
review and input from art@  testing and further review miod@

Revision 1.66 / (download) - annotate - [select for diffs], Mon Aug 4 16:27:01 2003 UTC (20 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.65: +2 -2 lines
Diff to previous 1.65 (colored)

Use strlcpy(), not strncpy() when copying p->p_comm to core.c_name
to guarantee NUL termination; from Patrick Latifi.

Revision 1.65 / (download) - annotate - [select for diffs], Sun Aug 3 19:25:49 2003 UTC (20 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.64: +6 -2 lines
Diff to previous 1.64 (colored)

Implement the WCONTINUED flag to the wait(2) family of syscalls and the
associated WIFCONTINUED macro as per 1003.1-2001.  Adapted from FreeBSD.
A minor amount of trickiness is involved here.  The value for WCONTINUED
is chosen in such a way that _WSTATUS(_WCONTINUED) == _WSTOPPED and the
WIFSTOPPED macro has been modified such that WIFSTOPPED(_WCONTINUED) !=
_WSTOPPED.  This means we don't need to add an extra check to the
WIFSIGNALED and WIFSTOPPED macros.  deraadt@ OK.

Revision 1.64 / (download) - annotate - [select for diffs], Mon Jul 21 22:44:50 2003 UTC (20 years, 10 months ago) by tedu
Branch: MAIN
Changes since 1.63: +9 -11 lines
Diff to previous 1.63 (colored)

remove caddr_t casts.  it's just silly to cast something when the function
takes a void *.  convert uiomove to take a void * as well.  ok deraadt@

Revision 1.35.2.11 / (download) - annotate - [select for diffs], Sat Jun 7 11:03:40 2003 UTC (21 years ago) by ho
Branch: SMP
Changes since 1.35.2.10: +2 -6 lines
Diff to previous 1.35.2.10 (colored) to branchpoint 1.35 (colored)

Sync SMP branch to -current

Revision 1.63 / (download) - annotate - [select for diffs], Mon Jun 2 23:28:05 2003 UTC (21 years ago) by millert
Branch: MAIN
Changes since 1.62: +2 -6 lines
Diff to previous 1.62 (colored)

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999.  Proofed by myself and Theo.

Revision 1.50.2.4 / (download) - annotate - [select for diffs], Mon May 19 22:31:10 2003 UTC (21 years ago) by tedu
Branch: UBC
Changes since 1.50.2.3: +2 -2 lines
Diff to previous 1.50.2.3 (colored) to branchpoint 1.50 (colored) next main 1.51 (colored)

sync

Revision 1.35.2.10 / (download) - annotate - [select for diffs], Thu May 15 04:08:02 2003 UTC (21 years, 1 month ago) by niklas
Branch: SMP
Changes since 1.35.2.9: +36 -9 lines
Diff to previous 1.35.2.9 (colored) to branchpoint 1.35 (colored)

Biglock!  Most of the logic
comes from NetBSD.
Also a lot of fixes, enough to get a dual cpu machine actually run MP for a
very short while (we are just talking about seconds) before starving out one
of the cpus.  More coming very soon.

Revision 1.35.2.9 / (download) - annotate - [select for diffs], Tue May 13 19:21:28 2003 UTC (21 years, 1 month ago) by ho
Branch: SMP
Changes since 1.35.2.8: +2 -2 lines
Diff to previous 1.35.2.8 (colored) to branchpoint 1.35 (colored)

Sync the SMP branch to -current. This includes moving to ELF.

Revision 1.62 / (download) - annotate - [select for diffs], Sat May 3 21:14:59 2003 UTC (21 years, 1 month ago) by deraadt
Branch: MAIN
CVS Tags: UBC_SYNC_A
Changes since 1.61: +2 -2 lines
Diff to previous 1.61 (colored)

string fixes; tedu ok

Revision 1.35.2.8 / (download) - annotate - [select for diffs], Fri Mar 28 00:41:26 2003 UTC (21 years, 2 months ago) by niklas
Branch: SMP
Changes since 1.35.2.7: +21 -9 lines
Diff to previous 1.35.2.7 (colored) to branchpoint 1.35 (colored)

Sync the SMP branch with 3.3

Revision 1.50.2.3 / (download) - annotate - [select for diffs], Tue Oct 29 00:36:44 2002 UTC (21 years, 7 months ago) by art
Branch: UBC
Changes since 1.50.2.2: +11 -6 lines
Diff to previous 1.50.2.2 (colored) to branchpoint 1.50 (colored)

sync to -current

Revision 1.61 / (download) - annotate - [select for diffs], Tue Oct 1 17:33:39 2002 UTC (21 years, 8 months ago) by art
Branch: MAIN
CVS Tags: UBC_SYNC_B, OPENBSD_3_3_BASE, OPENBSD_3_3, OPENBSD_3_2_BASE, OPENBSD_3_2
Changes since 1.60: +3 -3 lines
Diff to previous 1.60 (colored)

Oppsie. Missing part from this commit:
Prevent two localhost crashes with proc filters.
- don't send NOTE_SIGNAL to exiting processes.
- null dereference on error condition.
from Peter Werner <peterw at ifost.org.au>
deraadt@ ok

Revision 1.60 / (download) - annotate - [select for diffs], Sun Jul 14 02:44:30 2002 UTC (21 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.59: +2 -1 lines
Diff to previous 1.59 (colored)

be more permissive, and let close relatives do SIGALRM

Revision 1.59 / (download) - annotate - [select for diffs], Tue Jun 11 08:19:17 2002 UTC (22 years ago) by art
Branch: MAIN
Changes since 1.58: +8 -4 lines
Diff to previous 1.58 (colored)

Protect mi_switch with splstatclock.

Revision 1.50.2.2 / (download) - annotate - [select for diffs], Tue Jun 11 03:29:40 2002 UTC (22 years ago) by art
Branch: UBC
Changes since 1.50.2.1: +31 -15 lines
Diff to previous 1.50.2.1 (colored) to branchpoint 1.50 (colored)

Sync UBC branch to -current

Revision 1.58 / (download) - annotate - [select for diffs], Wed May 8 19:24:42 2002 UTC (22 years, 1 month ago) by millert
Branch: MAIN
Changes since 1.57: +4 -1 lines
Diff to previous 1.57 (colored)

A process can always signal itself--no need to restrict signals even if
it is setugid.  deraadt@ ok

Revision 1.57 / (download) - annotate - [select for diffs], Thu Apr 18 08:25:04 2002 UTC (22 years, 1 month ago) by miod
Branch: MAIN
Changes since 1.56: +9 -5 lines
Diff to previous 1.56 (colored)

Provide the correct signal number to the ktrace PSIG information instead
of an uninitialized variable.
millert@ ok

Revision 1.35.2.7 / (download) - annotate - [select for diffs], Thu Mar 28 11:43:04 2002 UTC (22 years, 2 months ago) by niklas
Branch: SMP
Changes since 1.35.2.6: +3 -3 lines
Diff to previous 1.35.2.6 (colored) to branchpoint 1.35 (colored)

Merge in -current from about a week ago

Revision 1.56 / (download) - annotate - [select for diffs], Thu Mar 14 01:27:04 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.55: +4 -4 lines
Diff to previous 1.55 (colored)

First round of __P removal in sys

Revision 1.35.2.6 / (download) - annotate - [select for diffs], Wed Mar 6 02:13:23 2002 UTC (22 years, 3 months ago) by niklas
Branch: SMP
Changes since 1.35.2.5: +37 -20 lines
Diff to previous 1.35.2.5 (colored) to branchpoint 1.35 (colored)

Merge in trunk

Revision 1.55 / (download) - annotate - [select for diffs], Fri Feb 22 19:19:28 2002 UTC (22 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.54: +17 -8 lines
Diff to previous 1.54 (colored)

include a siginfo_t with ktrace PSIG information, so that kdump can print
fault addresses and other information. (a small bug exists: in some signal
delivery cases, two PSIG records may be inserted, because postsig() is
unaware a PSIG record has already been placed.  but this small bug can
stay since the siginfo_t information helps us find and fix other bugs)

Revision 1.49.2.1 / (download) - annotate - [select for diffs], Thu Feb 21 04:14:57 2002 UTC (22 years, 3 months ago) by jason
Branch: OPENBSD_3_0
Changes since 1.49: +8 -1 lines
Diff to previous 1.49 (colored) next main 1.50 (colored)

Pull in patch from current:
Ignore signals if/when we are exiting.
Prevents a hang in the NFS code when
dumping core and pressing ^C, etc.
ok art@

Revision 1.42.2.1 / (download) - annotate - [select for diffs], Thu Feb 21 00:10:38 2002 UTC (22 years, 3 months ago) by miod
Branch: OPENBSD_2_9
Changes since 1.42: +8 -1 lines
Diff to previous 1.42 (colored) next main 1.43 (colored)

MFC, requested by weingart@

Ignore signals if/when we are exiting.
Prevents a hang in the NFS code when
dumping core and pressing ^C, etc.
ok art@

Revision 1.50.2.1 / (download) - annotate - [select for diffs], Thu Jan 31 22:55:40 2002 UTC (22 years, 4 months ago) by niklas
Branch: UBC
Changes since 1.50: +22 -14 lines
Diff to previous 1.50 (colored)

Merge in -current, builds on i386, otherwise untested

Revision 1.54 / (download) - annotate - [select for diffs], Thu Jan 31 02:12:18 2002 UTC (22 years, 4 months ago) by weingart
Branch: MAIN
Changes since 1.53: +8 -1 lines
Diff to previous 1.53 (colored)

Ignore signals if/when we are exiting.
Prevents a hang in the NFS code when
dumping core and pressing ^C, etc.
ok art@

Revision 1.53 / (download) - annotate - [select for diffs], Wed Jan 23 00:39:47 2002 UTC (22 years, 4 months ago) by art
Branch: MAIN
Changes since 1.52: +2 -2 lines
Diff to previous 1.52 (colored)

Pool deals fairly well with physical memory shortage, but it doesn't deal
well (not at all) with shortages of the vm_map where the pages are mapped
(usually kmem_map).

Try to deal with it:
 - group all information the backend allocator for a pool in a separate
   struct. The pool will only have a pointer to that struct.
 - change the pool_init API to reflect that.
 - link all pools allocating from the same allocator on a linked list.
 - Since an allocator is responsible to wait for physical memory it will
   only fail (waitok) when it runs out of its backing vm_map, carefully
   drain pools using the same allocator so that va space is freed.
   (see comments in code for caveats and details).
 - change pool_reclaim to return if it actually succeeded to free some
   memory, use that information to make draining easier and more efficient.
 - get rid of PR_URGENT, noone uses it.

Revision 1.52 / (download) - annotate - [select for diffs], Sat Jan 19 19:00:14 2002 UTC (22 years, 4 months ago) by millert
Branch: MAIN
Changes since 1.51: +3 -1 lines
Diff to previous 1.51 (colored)

If handler for SIGCHLD is SIG_IGN, reset to SIG_DLF.  This is consistent
with our handling of SA_NOCLDWAIT as well as other operating systems.
From FreeBSD.

Revision 1.51 / (download) - annotate - [select for diffs], Mon Jan 7 16:16:32 2002 UTC (22 years, 5 months ago) by millert
Branch: MAIN
Changes since 1.50: +12 -13 lines
Diff to previous 1.50 (colored)

If the handler for SIGCHLD is set to SIG_IGN, act as if the
SA_NOCLDWAIT (don't create zombies) flag has been specified.  This
is consistent with most other operating systems and is what XPG4.2
specifies.

Revision 1.35.2.5 / (download) - annotate - [select for diffs], Tue Nov 13 23:04:23 2001 UTC (22 years, 7 months ago) by niklas
Branch: SMP
Changes since 1.35.2.4: +2 -4 lines
Diff to previous 1.35.2.4 (colored) to branchpoint 1.35 (colored)

merge in -current

Revision 1.50 / (download) - annotate - [select for diffs], Tue Nov 6 19:53:20 2001 UTC (22 years, 7 months ago) by miod
Branch: MAIN
CVS Tags: UBC_BASE
Branch point for: UBC
Changes since 1.49: +2 -4 lines
Diff to previous 1.49 (colored)

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)

Revision 1.35.2.4 / (download) - annotate - [select for diffs], Wed Oct 31 03:26:29 2001 UTC (22 years, 7 months ago) by nate
Branch: SMP
Changes since 1.35.2.3: +7 -4 lines
Diff to previous 1.35.2.3 (colored) to branchpoint 1.35 (colored)

Sync the SMP branch to something just after 3.0

Revision 1.49 / (download) - annotate - [select for diffs], Fri Sep 21 21:36:48 2001 UTC (22 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE
Branch point for: OPENBSD_3_0
Changes since 1.48: +3 -2 lines
Diff to previous 1.48 (colored)

execsigs() could modify the wrong sigacts; based on David.Arana@eng.sun.com saying he could not understand how this worked

Revision 1.48 / (download) - annotate - [select for diffs], Thu Sep 20 23:30:29 2001 UTC (22 years, 8 months ago) by art
Branch: MAIN
Changes since 1.47: +2 -2 lines
Diff to previous 1.47 (colored)

cosmetic.

Revision 1.47 / (download) - annotate - [select for diffs], Thu Aug 9 14:44:42 2001 UTC (22 years, 10 months ago) by niklas
Branch: MAIN
Changes since 1.46: +4 -2 lines
Diff to previous 1.46 (colored)

Unshare signal actions on exec, from NetBSD.  While I am here a little KNF nit too

Revision 1.35.2.3 / (download) - annotate - [select for diffs], Wed Jul 4 10:48:25 2001 UTC (22 years, 11 months ago) by niklas
Branch: SMP
Changes since 1.35.2.2: +19 -29 lines
Diff to previous 1.35.2.2 (colored) to branchpoint 1.35 (colored)

Merge in -current from two days ago in the SMP branch.
As usual with merges, they do not indicate progress, so do not hold
your breath for working SMP, and do not mail me and ask about the
state of it.  It has not changed.  There is work ongoing, but very, very
slowly.  The commit is done in parts as to not lock up the tree in too
big chunks at a time.

Revision 1.46 / (download) - annotate - [select for diffs], Wed Jun 27 04:49:44 2001 UTC (22 years, 11 months ago) by art
Branch: MAIN
Changes since 1.45: +1 -5 lines
Diff to previous 1.45 (colored)

remove old vm

Revision 1.45 / (download) - annotate - [select for diffs], Fri Jun 22 14:14:09 2001 UTC (22 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.44: +12 -12 lines
Diff to previous 1.44 (colored)

KNF

Revision 1.44 / (download) - annotate - [select for diffs], Mon Jun 18 09:00:24 2001 UTC (22 years, 11 months ago) by art
Branch: MAIN
Changes since 1.43: +8 -10 lines
Diff to previous 1.43 (colored)

trace_req is a nop.
rename stop -> proc_stop (stop is not a good function name).

Revision 1.43 / (download) - annotate - [select for diffs], Wed May 16 05:07:52 2001 UTC (23 years, 1 month ago) by millert
Branch: MAIN
Changes since 1.42: +1 -5 lines
Diff to previous 1.42 (colored)

kill COMPAT_{09,10,11} kernel options.  We still need kern_info_09.c and kern_ipc_10.c for other compat modules.

Revision 1.35.2.2 / (download) - annotate - [select for diffs], Mon May 14 22:32:41 2001 UTC (23 years, 1 month ago) by niklas
Branch: SMP
Changes since 1.35.2.1: +149 -19 lines
Diff to previous 1.35.2.1 (colored) to branchpoint 1.35 (colored)

merge in approximately 2.9 into SMP branch

Revision 1.42 / (download) - annotate - [select for diffs], Mon Apr 2 21:43:12 2001 UTC (23 years, 2 months ago) by niklas
Branch: MAIN
CVS Tags: OPENBSD_2_9_BASE
Branch point for: OPENBSD_2_9
Changes since 1.41: +78 -3 lines
Diff to previous 1.41 (colored)

On popular demand, the Linux-compatibility clone(2) implementation based
on NetBSD's code, as well as some faked Posix RT extensions by me.  This makes
at least simple linuxthreads tests work.

Revision 1.41 / (download) - annotate - [select for diffs], Mon Feb 19 10:21:48 2001 UTC (23 years, 3 months ago) by art
Branch: MAIN
Changes since 1.40: +15 -12 lines
Diff to previous 1.40 (colored)

Clean up spl handling.

Revision 1.40 / (download) - annotate - [select for diffs], Thu Nov 16 20:02:17 2000 UTC (23 years, 6 months ago) by provos
Branch: MAIN
Changes since 1.39: +54 -1 lines
Diff to previous 1.39 (colored)

support kernel event queues, from FreeBSD by Jonathan Lemon,
okay art@, millert@

Revision 1.39 / (download) - annotate - [select for diffs], Fri Nov 10 18:15:47 2000 UTC (23 years, 7 months ago) by art
Branch: MAIN
Changes since 1.38: +3 -4 lines
Diff to previous 1.38 (colored)

Change the ktrace interface functions from taking the trace vnode to taking the
traced proc. The vnode is in the proc and all functions need the proc.

Revision 1.38 / (download) - annotate - [select for diffs], Mon Jun 5 11:02:50 2000 UTC (24 years ago) by art
Branch: MAIN
CVS Tags: OPENBSD_2_8_BASE, OPENBSD_2_8
Changes since 1.37: +2 -2 lines
Diff to previous 1.37 (colored)

Changes to exit handling.

cpu_exit no longer frees the vmspace and u-area. This is now handled by a
separate kernel thread "reaper". This is to avoid sleeping locks in the
critical path of cpu_exit where we're not allowed to sleep.

From NetBSD

Revision 1.37 / (download) - annotate - [select for diffs], Fri Apr 21 15:47:27 2000 UTC (24 years, 1 month ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_7_BASE, OPENBSD_2_7
Changes since 1.36: +2 -2 lines
Diff to previous 1.36 (colored)

Change kernel-only open flag FNOSYMLINK to userland-visible O_NOFOLLOW;
adapated from FreeBSD.  Also change O_FSYNC to the more standard O_SYNC
and document it.  open(2) needs some real examples for proper usage,
to come later.

Revision 1.35.2.1 / (download) - annotate - [select for diffs], Fri Mar 24 09:09:24 2000 UTC (24 years, 2 months ago) by niklas
Branch: SMP
Changes since 1.35: +2 -2 lines
Diff to previous 1.35 (colored)

Sync with -current

Revision 1.36 / (download) - annotate - [select for diffs], Fri Mar 3 11:31:43 2000 UTC (24 years, 3 months ago) by art
Branch: MAIN
Changes since 1.35: +2 -2 lines
Diff to previous 1.35 (colored)

Use LIST_ macros instead of internal field names to walk the allproc list.

Revision 1.35 / (download) - annotate - [select for diffs], Fri Nov 5 01:18:01 1999 UTC (24 years, 7 months ago) by mickey
Branch: MAIN
CVS Tags: kame_19991208, SMP_BASE
Branch point for: SMP
Changes since 1.34: +5 -1 lines
Diff to previous 1.34 (colored)

more stack direction fixes; art@ ok

Revision 1.34 / (download) - annotate - [select for diffs], Sun Jul 18 17:05:13 1999 UTC (24 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_6_BASE, OPENBSD_2_6
Changes since 1.33: +2 -1 lines
Diff to previous 1.33 (colored)

on exec, clear P_NOCLDWAIT; ambrisko@whistle.com

Revision 1.33 / (download) - annotate - [select for diffs], Fri Feb 26 05:10:40 1999 UTC (25 years, 3 months ago) by art
Branch: MAIN
CVS Tags: OPENBSD_2_5_BASE, OPENBSD_2_5
Changes since 1.32: +9 -1 lines
Diff to previous 1.32 (colored)

uvm allocation and name changes

Revision 1.32 / (download) - annotate - [select for diffs], Thu Feb 18 00:01:38 1999 UTC (25 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.31: +1 -2 lines
Diff to previous 1.31 (colored)

oops

Revision 1.31 / (download) - annotate - [select for diffs], Wed Feb 17 23:27:38 1999 UTC (25 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.30: +2 -1 lines
Diff to previous 1.30 (colored)

missing spl; christos

Revision 1.30 / (download) - annotate - [select for diffs], Sun Jun 7 20:17:25 1998 UTC (26 years ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_4_BASE, OPENBSD_2_4
Changes since 1.29: +3 -1 lines
Diff to previous 1.29 (colored)

permit SIGUSR1/USR2 through as well in cansignal()

Revision 1.29 / (download) - annotate - [select for diffs], Sat May 30 20:54:42 1998 UTC (26 years ago) by deraadt
Branch: MAIN
Changes since 1.28: +2 -1 lines
Diff to previous 1.28 (colored)

permit sig 0 (existance checking) to setuid parents; ibo@ragnarok.val-axs.net

Revision 1.28 / (download) - annotate - [select for diffs], Mon May 18 21:41:45 1998 UTC (26 years ago) by deraadt
Branch: MAIN
Changes since 1.27: +5 -1 lines
Diff to previous 1.27 (colored)

add more signals to setuid part of cansignal()

Revision 1.27 / (download) - annotate - [select for diffs], Sun May 17 19:38:43 1998 UTC (26 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.26: +51 -13 lines
Diff to previous 1.26 (colored)

convert CANSIGNAL() macro into a function, and then add significant constraints
regarding setuid/setgid targets (this is permitted by POSIX, and solves a
number of security issues).  This is due to a conversation months ago with
dholland@hcs.harvard.edu.

Revision 1.26 / (download) - annotate - [select for diffs], Fri Feb 20 14:46:18 1998 UTC (26 years, 3 months ago) by niklas
Branch: MAIN
CVS Tags: OPENBSD_2_3_BASE, OPENBSD_2_3
Changes since 1.25: +4 -2 lines
Diff to previous 1.25 (colored)

GCC 2.8 caught this type error, thanks

Revision 1.25 / (download) - annotate - [select for diffs], Fri Jan 9 16:41:09 1998 UTC (26 years, 5 months ago) by csapuntz
Branch: MAIN
Changes since 1.24: +2 -2 lines
Diff to previous 1.24 (colored)

core dumps disabled for SUID programs is default again.

Revision 1.24 / (download) - annotate - [select for diffs], Fri Jan 9 16:33:48 1998 UTC (26 years, 5 months ago) by csapuntz
Branch: MAIN
Changes since 1.23: +6 -3 lines
Diff to previous 1.23 (colored)

Get rid of dumping across symlinks. Races can cause this to be problematic
from a security standpoint (i.e. arbitrary files on the FS can be wiped out).

Revision 1.23 / (download) - annotate - [select for diffs], Mon Dec 8 21:25:36 1997 UTC (26 years, 6 months ago) by deraadt
Branch: MAIN
Changes since 1.22: +5 -1 lines
Diff to previous 1.22 (colored)

add kern.nosuidcoredump to lock things out even more

Revision 1.22 / (download) - annotate - [select for diffs], Thu Nov 6 05:58:18 1997 UTC (26 years, 7 months ago) by csapuntz
Branch: MAIN
Changes since 1.21: +2 -2 lines
Diff to previous 1.21 (colored)

Updates for VFS Lite 2 + soft update.

Revision 1.21 / (download) - annotate - [select for diffs], Mon Oct 6 20:19:56 1997 UTC (26 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_2_BASE, OPENBSD_2_2
Changes since 1.20: +1 -1 lines
Diff to previous 1.20 (colored)

back out vfs lite2 till after 2.2

Revision 1.20 / (download) - annotate - [select for diffs], Mon Oct 6 15:12:21 1997 UTC (26 years, 8 months ago) by csapuntz
Branch: MAIN
Changes since 1.19: +2 -2 lines
Diff to previous 1.19 (colored)

VFS Lite2 Changes

Revision 1.19 / (download) - annotate - [select for diffs], Mon Sep 15 05:46:13 1997 UTC (26 years, 9 months ago) by millert
Branch: MAIN
Changes since 1.18: +16 -1 lines
Diff to previous 1.18 (colored)

From FreeBSD (joerg@freebsd.org):
    Implement SA_NOCLDWAIT by reparenting kids of processes that have
    the appropriate bit set to PID 1, and let PID 1 handle the zombie.
    This assumes that PID 1 will wait for its kids (which is true of init).
    This also includes some FreeBSD sigaction.2.

Revision 1.18 / (download) - annotate - [select for diffs], Fri Sep 12 02:47:34 1997 UTC (26 years, 9 months ago) by deraadt
Branch: MAIN
Changes since 1.17: +2 -1 lines
Diff to previous 1.17 (colored)

add copyright for the work i did in csignal()

Revision 1.17 / (download) - annotate - [select for diffs], Sun Aug 31 20:42:18 1997 UTC (26 years, 9 months ago) by deraadt
Branch: MAIN
Changes since 1.16: +41 -1 lines
Diff to previous 1.16 (colored)

for non-tty TIOCSPGRP/F_SETOWN/FIOSETOWN pgid setting calls, store uid
and euid as well, then deliver them using new csignal() interface
which ensures that pgid setting process is permitted to signal the
pgid process(es). Thanks to newsham@aloha.net for extensive help and
discussion.

Revision 1.16 / (download) - annotate - [select for diffs], Sat Feb 1 21:49:41 1997 UTC (27 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_1_BASE, OPENBSD_2_1
Changes since 1.15: +28 -7 lines
Diff to previous 1.15 (colored)

add type & union sigval args to sendsig/trapsignal

Revision 1.15 / (download) - annotate - [select for diffs], Mon Jan 27 22:48:36 1997 UTC (27 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.14: +5 -4 lines
Diff to previous 1.14 (colored)

add another parameter to trapsignal() and sendsig() -- fault addr to be
delivered with in the siginfo information

Revision 1.14 / (download) - annotate - [select for diffs], Mon Jan 27 01:15:32 1997 UTC (27 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.13: +16 -0 lines
Diff to previous 1.13 (colored)

initial cut at SA_SIGINFO support

Revision 1.13 / (download) - annotate - [select for diffs], Sun Oct 27 08:01:26 1996 UTC (27 years, 7 months ago) by tholo
Branch: MAIN
Changes since 1.12: +4 -3 lines
Diff to previous 1.12 (colored)

Signal handling now fully POSIX.1-1990 compliant

Revision 1.12 / (download) - annotate - [select for diffs], Sun Oct 27 04:56:51 1996 UTC (27 years, 7 months ago) by tholo
Branch: MAIN
Changes since 1.11: +1 -2 lines
Diff to previous 1.11 (colored)

Allow kill(, 0) on process groups that hold only zombies; per POSIX

Revision 1.11 / (download) - annotate - [select for diffs], Sun Oct 27 03:48:29 1996 UTC (27 years, 7 months ago) by tholo
Branch: MAIN
Changes since 1.10: +2 -27 lines
Diff to previous 1.10 (colored)

Don't verify that euid has write permission

Revision 1.10 / (download) - annotate - [select for diffs], Sun Oct 27 02:26:55 1996 UTC (27 years, 7 months ago) by tholo
Branch: MAIN
Changes since 1.9: +2 -2 lines
Diff to previous 1.9 (colored)

Correct last fix

Revision 1.9 / (download) - annotate - [select for diffs], Sat Oct 26 07:28:13 1996 UTC (27 years, 7 months ago) by tholo
Branch: MAIN
Changes since 1.8: +2 -1 lines
Diff to previous 1.8 (colored)

A process can send a signal to another process if the uid of the signalling
process is the same as the saved uid of the signalled process

Revision 1.8 / (download) - annotate - [select for diffs], Sun Oct 20 07:37:22 1996 UTC (27 years, 7 months ago) by tholo
Branch: MAIN
Changes since 1.7: +34 -6 lines
Diff to previous 1.7 (colored)

Further limit the cases where we write core files

Revision 1.7 / (download) - annotate - [select for diffs], Fri Oct 18 06:08:40 1996 UTC (27 years, 7 months ago) by tholo
Branch: MAIN
Changes since 1.6: +34 -19 lines
Diff to previous 1.6 (colored)

From Keith Bostic, with some minor changes:
 The problem reported on BUGTRACK was that ftpd could be convinced to
 drop core after it had discarded its special permissions, but while
 it still had a copy of the encrypted passwords in its buffers.  Change
 coredump() to:

     + Don't drop core for any process that was ever setuid/setgid if
       it's not running as root.
     + Change errno returns from EFAULT to appropriate values -- this
       will be useful for when coredump() becomes a system call and
       gcore goes away.
     + Create core dump files mode 600, and don't dump to files that
       are owned by anyone else or readable or writable by anyone other
       than the owner.

Revision 1.6 / (download) - annotate - [select for diffs], Tue Sep 3 11:01:43 1996 UTC (27 years, 9 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_0_BASE, OPENBSD_2_0
Changes since 1.5: +3 -3 lines
Diff to previous 1.5 (colored)

another typo....

Revision 1.5 / (download) - annotate - [select for diffs], Tue Sep 3 05:01:45 1996 UTC (27 years, 9 months ago) by deraadt
Branch: MAIN
Changes since 1.4: +7 -3 lines
Diff to previous 1.4 (colored)

do not coredump for setuid/setgid, unless run by root

Revision 1.4 / (download) - annotate - [select for diffs], Thu May 2 13:12:13 1996 UTC (28 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.3: +2 -3 lines
Diff to previous 1.3 (colored)

sync syscalls, no sys/cpu.h

Revision 1.3 / (download) - annotate - [select for diffs], Sun Mar 3 17:19:54 1996 UTC (28 years, 3 months ago) by niklas
Branch: MAIN
Changes since 1.2: +23 -9 lines
Diff to previous 1.2 (colored)

From NetBSD: 960217 merge

Revision 1.2 / (download) - annotate - [select for diffs], Fri Jan 5 16:18:33 1996 UTC (28 years, 5 months ago) by deraadt
Branch: MAIN
Changes since 1.1: +2 -2 lines
Diff to previous 1.1 (colored)

ss_sp is correct, ss_base is not. noticed by agc@sde.uts.amdahl.com; netbsd pr#1784

Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Wed Oct 18 08:52:44 1995 UTC (28 years, 8 months ago) by deraadt
CVS Tags: netbsd_1_1
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 (colored)

initial import of NetBSD tree

Revision 1.1 / (download) - annotate - [select for diffs], Wed Oct 18 08:52:44 1995 UTC (28 years, 8 months ago) by deraadt
Branch: MAIN

Initial revision

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.