Home | History | Annotate | Download | only in netbsd32
History log of /src/sys/compat/netbsd32/netbsd32_signal.c
RevisionDateAuthorComments
 1.55  22-Nov-2024  mlelstv Crude patch to allow building and loading of compat_16 and compat_netbsd32_16 code
on aarch64.
 1.54  29-Apr-2024  mlelstv branches: 1.54.2;
In netbsd32___sigaction_sigtramp continue to use the compat module when
already locked for this process.

Needs pullup to netbsd-10.
 1.53  06-Nov-2021  thorpej branches: 1.53.4;
COMPAT_NETBSD32 is all about running the 32-bit flavor of native
binaries on a 64-bit platform[*], as such:
- Make the logic about which "sendsig" flavor to call MI (as it is in the
native 64-bit environment) and follow the same rules as the native 32-bit
environment.
- Make COMPAT_NETBSD32 x COMPAT_16 work the same as it would in the
native 32-bit environment by providing a netbsd32_sendsig_sigcontext_16_hook,
rather than overriding the entire sendsig logic with a netbsd32_sendsig_hook.
- In netbsd32___sigaction_sigtramp(), make sure the compat_netbsd32_16
module is loaded if the trampoline version specifies a sigcontext style
handler, otherwise return EINVAL so that libc can try again with siginfo
style.

[*] ...except for arm32, which uses it to mean "run 32-bit OABI binaries
from the 32-bit EABI environment". Doing it this way was arguably a mistake,
but we are stuck with it for now, so support it by providing a machine-
dependent override for netbsd32_sendsig() that also disables the corresponding
logic in netbsd32___sigaction_sigtramp().

Fixes PR kern/56487.
 1.52  07-Sep-2021  riastradh sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.51  19-Jan-2021  simonb KNF consistency: No parentheses are needed around the return value.
 1.50  18-Nov-2019  rin branches: 1.50.8;
TRAP_EXEC does not have extra fields to be filled in at the moment.
Explicitly ignore fields for now.

Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9
 1.49  18-Nov-2019  rin When converting siginfo, examine si_code at the beginning,
as explained in siginfo(2).

- If it is SI_NOINFO, there's no additional information.
- If it is non-positive, i.e., codes described in siginfo(2),
we need to fill in _rt.

XXX
Description for SA_ASYNCIO in siginfo(2) seems outdated;
neither si_fd nor si_band are filled in with that code.

XXX
pullup to netbsd-9
 1.48  18-Nov-2019  rin Provide _ptrace_state for SIGTRAP with TRAP_EXEC, TRAP_CHLD, or TRAP_LWP.

Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9
 1.47  18-Nov-2019  rin Sort by signal numbers as far as possible, adjust locations of functions.
No functional changes intended.

XXX
pullup to netbsd-9
 1.46  18-Nov-2019  rin Belatedly catch up with kern_sig.c rev 1.358:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_sig.c#rev1.358

Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.

With some minor changes:

- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.

XXX
pullup to netbsd-9
 1.45  17-Dec-2017  christos branches: 1.45.4; 1.45.8;
handle siginfo requests for ptrace32
 1.44  06-Dec-2017  christos disable 32 bit signal ktrace records; 32 bit traced process produce 64 bit
trace records, the only record that we can't parse is that one :-)
XXX: pullup-8
 1.43  18-Sep-2016  christos branches: 1.43.8;
remove multiple default.
 1.42  18-Sep-2016  christos more ifdef KTRACE
fix wraps
 1.41  17-Sep-2016  christos deal with not having KTRACE
 1.40  13-Sep-2016  martin Allow emulations to override the creation of ktrace records for posting
signals. In compat_netbsd32 use this to write the 32bit version of
the records, so a 32bit userland kdump is happy.
 1.39  20-Jun-2015  martin branches: 1.39.2;
Implement modctl, sigqueinfo and mq_*
 1.38  24-Jan-2014  christos branches: 1.38.6;
sigaction until 1.4 had an int sigmask, don't trash the stack.
 1.37  19-Feb-2012  rmind branches: 1.37.2; 1.37.4;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.36  18-Nov-2011  christos branches: 1.36.4;
add a copyin function for sigset so that we can use sigtimedwait1 from
emulations.
 1.35  03-Feb-2011  joerg branches: 1.35.4;
Explicitly initialize ucontext before calling getmcontext.
 1.34  23-Apr-2010  rmind branches: 1.34.2; 1.34.4;
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
 1.33  19-Jan-2010  pooka branches: 1.33.2; 1.33.4;
A few more instances of __sigtimedwait1 -> sigtimedwait1
 1.32  11-Jan-2009  christos merge christos-time_t
 1.31  15-Oct-2008  wrstuden branches: 1.31.2; 1.31.4; 1.31.8;
Merge wrstuden-revivesa into HEAD.
 1.30  29-May-2008  mrg branches: 1.30.4;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.29  24-Apr-2008  ad branches: 1.29.2; 1.29.4;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.28  20-Dec-2007  dsl branches: 1.28.6; 1.28.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.27  08-Dec-2007  dsl branches: 1.27.4;
ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.26  08-Oct-2007  ad branches: 1.26.6;
LOCK_ASSERT -> KASSERT
 1.25  16-Jun-2007  dsl branches: 1.25.6; 1.25.8; 1.25.10;
Modify the (recently added) compat_sigaltstack() #define to take the
values of the SS_ONSTACK and SS_DISABLE constants.
Use it to shorten the source files when this action is replicated.
Actually, given the monstrous complexity of sigaltstack1() there is
probably a much better way to do this...
 1.24  21-May-2007  christos rename si_sigval -> si_value to match POSIX RTS.
 1.23  18-Mar-2007  dsl Change all the NETBSD32PTR64(SCARG(uap, xxx))) to SCARG_P32(uap, xxx).
 1.22  16-Mar-2007  dsl remove all the double (and triple) casts used to convert 32bit userspace
pointers to and from 64bit kernel pointers. Instead use the defines
NETBSD32PTR64(p32) to read a 32bit pointer and (the new) NETBSD32PTR32(p32,p64)
to write a 32bit pointer throughout.
The 32bit pointer is now a struct to enforce the above.
amd64 (with linux emul) and sparc64 will both compile (when the arch stuff
goes in soon), and amd64 still runs some i386 binaries.
 1.21  04-Mar-2007  christos branches: 1.21.2; 1.21.4; 1.21.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20  19-Feb-2007  cube Make netbsd32_{get,set}ucontext and associated functions
{get,set}ucontext32 look like their native counterparts again after
newlock2 merge. This avoids entering sigprocmask1 without the proc mutex
held...
 1.19  09-Feb-2007  ad branches: 1.19.2;
Merge newlock2 to head.
 1.18  08-Nov-2006  drochner -SUS says that a successful call to setcontext(2) does not return. This
implies that _UC_CPU must be set in the context passed. Check for this
and return EINVAL if not; this gives a cheap test for corrupted
ucontexts eg on a signal handler stack which would go unnoticed otherwise.
-Don't ckeck for NULL ucontext pointers explicitely. This is an error,
except in the swapcontext() case where it can be easily caught in
userland.
 1.17  15-Mar-2006  cube branches: 1.17.10; 1.17.12;
SA introduce a new case of siginfo structure. Be ready for it when the
time comes to support SA in COMPAT_NETBSD32 (which is soon).
 1.16  11-Dec-2005  christos branches: 1.16.4; 1.16.6; 1.16.8; 1.16.10;
merge ktrace-lwp.
 1.15  27-Sep-2005  chs make this compile again.
 1.14  24-Sep-2005  christos make the siginfo converters static and comment out the one that is not used.
 1.13  24-Sep-2005  christos include new compat siginfo header.
 1.12  13-Sep-2005  christos make this compile again.
 1.11  19-Aug-2005  christos Fix lossage I created with the 64 bit ino_t change.
 1.10  23-Jul-2005  cube Implement __sigtimedwait(2).
 1.9  02-Jun-2005  drochner branches: 1.9.2;
in siginfo conversion functions, declare the source operand as "const"
 1.8  26-Feb-2005  perry nuke trailing whitespace
 1.7  13-Oct-2003  fvdl branches: 1.7.8; 1.7.10;
Implement 32bit get/setcontext entry points.
 1.6  18-Jan-2003  thorpej branches: 1.6.2;
Merge the nathanw_sa branch.
 1.5  27-Nov-2002  atatat Complete the rename: s/sa_/<compat>_sa_/g

Also tweak the darwin siginfo stuff to avoid the same type of collision.
 1.4  23-Oct-2002  scw In preparation for COMPAT_NETBSD32 on SH-5:

- The MD netbsd32_machdep.h header now defines the 32-bit pointer type
instead of using u_int32_t everywhere,
- The MD netbsd32_machdep.h header now defines a macro (at least on
current implementations) which converts a 32-bit pointer to its 64-bit
equivalent,
- Change the MI code to utilise the above two items in all the right places,
- Implement netbsd32___sigaction_sigtramp().

Tested on Sparc64 by Matt Green.
 1.3  04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.2  13-Nov-2001  lukem branches: 1.2.8;
add RCSIDs (including regeneration of files as appropriate)
 1.1  08-Feb-2001  mrg branches: 1.1.2; 1.1.4; 1.1.6;
split up netbsd32_netbsd.c into 9 new files, leaving only those syscalls that
have no special interpretations besides simple syscall args conversion.
 1.1.6.2  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.6  11-Dec-2002  thorpej Sync with HEAD.
 1.1.4.5  20-Nov-2002  petrov lwpify netbsd32___sigaction_sigtramp.
 1.1.4.4  11-Nov-2002  nathanw Catch up to -current
 1.1.4.3  23-Aug-2002  petrov lwpification.
 1.1.4.2  01-Aug-2002  nathanw Catch up to -current.
 1.1.4.1  14-Nov-2001  nathanw Catch up to -current.
 1.1.2.2  11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1  08-Feb-2001  bouyer file netbsd32_signal.c was added on branch thorpej_scsipi on 2001-02-11 19:14:16 +0000
 1.2.8.1  15-Jul-2002  gehenna catch up with -current.
 1.6.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.4  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1  03-Aug-2004  skrll Sync with HEAD
 1.7.10.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.8.1  29-Apr-2005  kent sync with -current
 1.9.2.6  21-Jan-2008  yamt sync with head
 1.9.2.5  27-Oct-2007  yamt sync with head.
 1.9.2.4  03-Sep-2007  yamt sync with head.
 1.9.2.3  26-Feb-2007  yamt sync with head.
 1.9.2.2  30-Dec-2006  yamt sync with head.
 1.9.2.1  21-Jun-2006  yamt sync with head.
 1.16.10.1  19-Apr-2006  elad sync with head.
 1.16.8.1  01-Apr-2006  yamt sync with head.
 1.16.6.1  22-Apr-2006  simonb Sync with head.
 1.16.4.1  09-Sep-2006  rpaulo sync with head
 1.17.12.1  10-Dec-2006  yamt sync with head.
 1.17.10.4  30-Jan-2007  ad Remove support for SA. Ok core@.
 1.17.10.3  18-Nov-2006  ad Sync with head.
 1.17.10.2  17-Nov-2006  ad Checkpoint work in progress.
 1.17.10.1  21-Oct-2006  ad Checkpoint work in progress on locking and per-LWP signals. Very much a
a work in progress and there is still a lot to do.
 1.19.2.3  24-Mar-2007  yamt sync with head.
 1.19.2.2  12-Mar-2007  rmind Sync with HEAD.
 1.19.2.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.21.6.2  29-Mar-2007  reinoud Pullup to -current
 1.21.6.1  18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.21.4.1  11-Jul-2007  mjf Sync with head.
 1.21.2.4  22-Aug-2007  ad Make it compile.
 1.21.2.3  15-Jul-2007  ad Sync with head.
 1.21.2.2  27-May-2007  ad Sync with head.
 1.21.2.1  10-Apr-2007  ad Sync with head.
 1.25.10.1  14-Oct-2007  yamt sync with head.
 1.25.8.2  09-Jan-2008  matt sync with HEAD
 1.25.8.1  06-Nov-2007  matt sync with HEAD
 1.25.6.2  09-Dec-2007  jmcneill Sync with HEAD.
 1.25.6.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.26.6.1  26-Dec-2007  ad Sync with head.
 1.27.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.28.8.2  04-Jun-2008  yamt sync with head
 1.28.8.1  18-May-2008  yamt sync with head.
 1.28.6.2  17-Jan-2009  mjf Sync with HEAD.
 1.28.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.29.4.6  28-Sep-2008  skrll Adapt the SA COMPAT_NETBSD32 stuff to this branch.
 1.29.4.5  25-Sep-2008  skrll Typo in comment and define 'p' in getucontext32_sa.
 1.29.4.4  27-Jun-2008  wrstuden Add getucontext32_sa() and getucontext_sa(), and use them. They
are sa-specific versions of getucontext{,32}(). The main difference
is that they do NOT require the p_lock be held. We report an empty
signal mask, both to avoid needing p_lock and because the process
signal mask is almost always 0 for SA.
 1.29.4.3  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.29.4.2  14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

The l_sigstk changes are most likely totally un-needed as SA will
never use a signal stack - we send an upcall (or will as other
diffs are brought in).

The l_sigmask changes were too controvertial. In all honesty, I
think it's probably best to revert them. The main reason they were
there is the fact that in an SA process, we don't mask signals per
kernel thread, we mask them per user thread. In the kernel, we want
them all to get turned into upcalls. Thus the normal state of
l_sigmask in an SA process is for it to always be empty.

While we are in the process of delivering a signal, we want to
temporarily mask a signal (so we don't recursively exhaust our
upcall stacks). However signal delivery is rare (important, but
rare), and delivering back-to-back signals is even rarer. So rather
than cause every user of a signal mask to be prepared for this very
rare case, we will just add a second check later in the signal
delivery code. Said change is not in this diff.

This also un-compensates all of our compatability code for dealing
with SA. SA is a NetBSD-specific thing, so there's no need for
Irix, Linux, Solaris, SVR4 and so on to cope with it.

As previously, everything other than kern_sa.c compiles in i386
GENERIC as of this checkin. I will switch to ALL soon for compile
testing.
 1.29.4.1  10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.29.2.3  11-Aug-2010  yamt sync with head.
 1.29.2.2  11-Mar-2010  yamt sync with head
 1.29.2.1  04-May-2009  yamt sync with head.
 1.30.4.1  19-Oct-2008  haad Sync with HEAD.
 1.31.8.2  04-Jan-2009  christos add new syscalls.
 1.31.8.1  15-Oct-2008  christos file netbsd32_signal.c was added on branch christos-time_t on 2009-01-04 01:56:02 +0000
 1.31.4.1  16-Feb-2011  bouyer Pull up following revision(s) (requested by joerg in ticket #1556):
sys/compat/irix/irix_signal.c: revision 1.56
sys/compat/svr4/svr4_signal.c: revision 1.65
sys/compat/netbsd32/netbsd32_signal.c: revision 1.35
sys/kern/sys_sig.c: revision 1.31
Explicitly initialize ucontext before calling getmcontext.
 1.31.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.33.4.2  05-Mar-2011  rmind sync with head
 1.33.4.1  30-May-2010  rmind sync with head
 1.33.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.34.4.1  08-Feb-2011  bouyer Sync with HEAD
 1.34.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.35.4.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.35.4.1  17-Apr-2012  yamt sync with head
 1.36.4.1  24-Feb-2012  mrg sync to -current.
 1.37.4.1  18-May-2014  rmind sync with head
 1.37.2.2  03-Dec-2017  jdolecek update from HEAD
 1.37.2.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.6.2  05-Oct-2016  skrll Sync with HEAD
 1.38.6.1  22-Sep-2015  skrll Sync with HEAD
 1.39.2.1  04-Nov-2016  pgoyette Sync with HEAD
 1.43.8.2  21-Jun-2023  martin Pull up following revision(s) (requested by riastradh in ticket #1836):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.43.8.1  12-Apr-2018  martin Pull up following revision(s) (requested by kamil in ticket #713):

sys/modules/procfs/Makefile: revision 1.4
sys/miscfs/procfs/procfs_vfsops.c: revision 1.98
bin/ps/ps.1: revision 1.108
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.32
sys/miscfs/procfs/procfs_vnops.c: revision 1.198
sys/kern/sys_ptrace_common.c: revision 1.23
sys/kern/sys_ptrace_common.c: revision 1.24
sbin/mount_procfs/mount_procfs.8: revision 1.36
sys/kern/sys_ptrace_common.c: revision 1.25
sys/kern/sys_ptrace.c: revision 1.5
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.30
sys/sys/proc.h: revision 1.342
sys/kern/sys_ptrace_common.c: revision 1.26
sys/miscfs/procfs/procfs_ctl.c: file removal
sys/kern/sys_ptrace_common.c: revision 1.27
sys/miscfs/procfs/procfs_subr.c: revision 1.109
sys/kern/sys_ptrace_common.c: revision 1.28
sys/secmodel/extensions/secmodel_extensions.c: revision 1.8
sys/kern/sys_ptrace_common.c: revision 1.29
sys/sys/ptrace.h: revision 1.62
sys/compat/netbsd32/netbsd32_signal.c: revision 1.45
share/man/man9/kauth.9: revision 1.109
sys/miscfs/procfs/files.procfs: revision 1.12
sys/compat/netbsd32/netbsd32.h: revision 1.115
sys/miscfs/procfs/procfs.h: revision 1.72
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.5
sys/kern/kern_sig.c: revision 1.337
sys/sys/kauth.h: revision 1.75
sys/sys/sysctl.h: revision 1.224
sys/kern/sys_ptrace_common.c: revision 1.30
sys/kern/sys_ptrace_common.c: revision 1.31
sys/kern/sys_ptrace_common.c: revision 1.32
sys/kern/sys_ptrace_common.c: revision 1.33
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.20
sys/kern/sys_ptrace_common.c: revision 1.34
sys/kern/sys_ptrace_common.c: revision 1.36
sys/kern/kern_proc.c: revision 1.207
sys/kern/kern_exit.c: revision 1.269
doc/TODO.ptrace: revision 1.29

Make {s,g}et{db,fp,}regs work again for PK_32 processes
XXX: pullup-8

add disgusting magic to handle compat_netbsd32 as a module.

use process_*reg32 instead of struct *reg32.

Remove the filesystem tracing feature

This is a legacy interface from 4.4BSD, and it was
introduced to overcome shortcomings of ptrace(2) at that time, which are
no longer relevant (performance). Today /proc/#/ctl offers a narrow
subset of ptrace(2) commands and is not applicable for modern
applications use beyond simplistic tracing scenarios.

This removal will simplify kernel internals. Users will still be able to
use all the other /proc files.

This change won't affect other procfs files neither Linux compat
features within mount_procfs(8). /proc/#/ctl isn't available on Linux.

Remove:
- /proc/#/ctl from mount_procfs(8)
- P_FSTRACE note from the documentation of ps(1)
- /proc/#/ctl and filesystem tracing documentation from mount_procfs(8)
- KAUTH_REQ_PROCESS_PROCFS_CTL documentation from kauth(9)
- source code file miscfs/procfs/procfs_ctl.c
- PFSctl and procfs_doctl() from sys/miscfs/procfs/procfs.h
- KAUTH_REQ_PROCESS_PROCFS_CTL from sys/sys/kauth.h
- PSL_FSTRACE (0x00010000) from sys/sys/proc.h
- P_FSTRACE (0x00010000) from sys/sys/sysctl.h

Reduce code complexity after removal of this functionality.

Update TODO.ptrace accordingly: remove two entries about /proc tracing.

Do not keep legacy notes as comments in the headers about removed

PSL_FSTRACE / P_FSTRACE, as this interface had little number of users
(close or equal to zero).
Proposed on tech-kern@.

All filesystem tracing utility users are encouraged to switch to ptrace(2).

Sponsored by <The NetBSD Foundation>

untangle the mess:
- factor out common code
- break each ptrace subcall to its own sub-function
.. more to come ...
- reduce ifdef ugliness by moving it up top.
- factor out PT_IO and make PT_{READ,WRITE}_{I,D} use it
- factor out PT_DUMPCORE
- factor out sendsig code
.. more to come ...

handle siginfo requests for ptrace32

ptrace: Partially undo PT_{READ,WRITE}_{I,D} and unbreak these commands

The refactored code did not work and was generating EFAULT.

Sponsored by <The NetBSD Foundation>

Merge the code back; the problem was that since we are reading/writing
to a kernel address for PT_{READ,WRITE}_{I,D} we need the kernel vmspace.
provide separate read and write functions to accomodate register functions
that need a size argument.

don't ignore error from copyout_piod

Use the proper process (the tracee) to get information about lwps and
registers and the tracer for vmspace.

Add new sysctl(3) entry: security.models.extensions.user_set_dbregs

Model this new sysctl(3) entry after "user_set_cpu_affinity" in the same
level of sysctl(3) switches.

Allow to read unconditionally Debug Registers (no change here). This is
convenient as even if a user of a debugger does not use hardware assisted
watchpoints/breakpoints, a debugger can still prompt these values to store
in an internal cache with context of registers. Reading them should have
no security concerns.

Add a paranoid MI switch that prohibits by default setting these registers
by a regular user (non-superuser). Make this switch disabled by default.
There are enough reserved bits out there to allow using them
unconditionally on hardened hosts.

Features shipped with Debug Registers are optional features in debuggers.
There is no reduction in elementary functionality.

Reviewed by <christos>

Sponsored by <The NetBSD Foundation>
 1.45.8.2  03-Aug-2022  martin Pull up following revision(s), all via patch
(requested by riastradh in ticket #1487):

sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168
sys/compat/sunos/sunos_misc.c: revision 1.177
sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52
sys/compat/common/kern_resource_43.c: revision 1.23
sys/compat/netbsd32/netbsd32_conv.h: revision 1.46
sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35
sys/compat/common/vfs_syscalls_12.c: revision 1.38
sys/compat/ultrix/ultrix_misc.c: revision 1.126
sys/compat/common/kern_sig_43.c: revision 1.37
sys/compat/linux/common/linux_mtio.c: revision 1.8
sys/compat/freebsd/freebsd_misc.c: revision 1.34
sys/compat/freebsd/freebsd_machdep.c: revision 1.5
sys/compat/linux/common/linux_olduname.c: revision 1.67
sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44
sys/compat/freebsd/freebsd_sched.c: revision 1.23
sys/compat/ossaudio/ossaudio.c: revision 1.84
sys/compat/sys/time_types.h: revision 1.6
sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51
sys/compat/common/ieee80211_20.c: revision 1.7
sys/compat/linux/common/linux_file.c: revision 1.119
sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34
sys/compat/netbsd32/netbsd32_wait.c: revision 1.25
sys/compat/linux32/common/linux32_time.c: revision 1.38
sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33
sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52
sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46
sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36
sys/compat/ultrix/ultrix_ioctl.c: revision 1.39
sys/compat/linux/common/linux_misc.c: revision 1.252
sys/compat/linux/common/linux_hdio.c: revision 1.19
sys/compat/sunos/sunos_ioctl.c: revision 1.71
sys/compat/linux/common/linux_sched.c: revision 1.79
sys/compat/common/kern_info_43.c: revision 1.40
sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20
sys/compat/linux/common/linux_socket.c: revision 1.153
sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60
sys/compat/common/vfs_syscalls_43.c: revision 1.68
sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25
sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9
sys/compat/common/kern_time_50.c: revision 1.37
sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42
sys/compat/linux/common/linux_cdrom.c: revision 1.28
sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43
sys/compat/common/kern_info_09.c: revision 1.22
sys/compat/linux32/common/linux32_resource.c: revision 1.12
sys/compat/linux/common/linux_oldolduname.c: revision 1.67
sys/compat/common/if_media_80.c: revision 1.4
sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5
sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8
sys/compat/linux32/common/linux32_signal.c: revision 1.21
sys/compat/common/kern_sig_13.c: revision 1.22
sys/compat/sunos32/sunos32_ioctl.c: revision 1.36
sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62
sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23
sys/compat/netbsd32/netbsd32_time.c: revision 1.56
sys/compat/linux/common/linux_signal.c: revision 1.84
sys/compat/netbsd32/netbsd32_signal.c: revision 1.52
sys/compat/sunos32/sunos32_misc.c: revision 1.85
sys/compat/linux/common/linux_time.c: revision 1.40
sys/compat/linux/common/linux_fdio.c: revision 1.14
sys/compat/common/vfs_syscalls_30.c: revision 1.43

sys/compat: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure. If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.
 1.45.8.1  19-Nov-2019  martin Pull up following revision(s) (requested by rin in ticket #456):

sys/compat/netbsd32/netbsd32_signal.c: revision 1.46
sys/compat/netbsd32/netbsd32_signal.c: revision 1.47
sys/compat/netbsd32/netbsd32_signal.c: revision 1.48
sys/compat/netbsd32/netbsd32_signal.c: revision 1.49
sys/compat/netbsd32/netbsd32_signal.c: revision 1.50

Belatedly catch up with kern_sig.c rev 1.358:
Provide syscall information with SIGTRAP TRAP_SCE/TRAP_SCX so that
picotrace/truss, for example, works fine on COMPAT_NETBSD32.
With some minor changes:
- Centralize netbsd32_si{,32}_si{32,}() into netbsd32_ksi{,32}_ksi{32,}().
- Provide si_status with SIGCHLD.
- Remove the remaining of SA.

Sort by signal numbers as far as possible, adjust locations of functions.
No functional changes intended.

XXX
pullup to netbsd-9

Provide _ptrace_state for SIGTRAP with TRAP_EXEC, TRAP_CHLD, or TRAP_LWP.
Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9

When converting siginfo, examine si_code at the beginning,
as explained in siginfo(2).
- If it is SI_NOINFO, there's no additional information.
- If it is non-positive, i.e., codes described in siginfo(2),
we need to fill in _rt.

XXX
Description for SA_ASYNCIO in siginfo(2) seems outdated;
neither si_fd nor si_band are filled in with that code.

XXX
pullup to netbsd-9

TRAP_EXEC does not have extra fields to be filled in at the moment.
Explicitly ignore fields for now.
Pointed out by kamil. Thanks!

XXX
pullup to netbsd-9
 1.45.4.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.50.8.1  03-Apr-2021  thorpej Sync with HEAD.
 1.53.4.1  26-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #989):

sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.5
sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.6
sys/compat/netbsd32/netbsd32_signal.c: revision 1.54

In netbsd32___sigaction_sigtramp continue to use the compat module when
already locked for this process.

Enable compat sigreturn system call.

netbsd32_compat_16.c: Fix whitespace.
No functional change intended.
 1.54.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed