Home | History | Annotate | Download | only in sunos
History log of /src/sys/compat/sunos/sunos_misc.c
RevisionDateAuthorComments
 1.177  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.176  26-Oct-2019  christos use strlcpy() for the uts conversion, makes the code simpler and more readable.
 1.175  04-Oct-2019  mrg replace memcpy() with src bounds overflow with single char write.
 1.174  23-Sep-2019  christos make this compile again.
 1.173  03-Jul-2019  dholland branches: 1.173.2;
Stack buffers mustn't escape their scope. PR 54326 from David Binderman
 1.172  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.171  28-Jul-2017  riastradh branches: 1.171.2; 1.171.4;
Fail, don't panic, on bad dirents from file system.

Controllable via puffs from userland.

From Ilja Van Sprundel.
 1.170  23-Oct-2015  maxv branches: 1.170.10;
Change do_sys_mount() so that it only takes as argument the type of the
drive instead of its associated vfsops. Makes it more friendly, and allows
compat binaries to autoload VFS modules if needed.

sent on tech-kern@, ok christos@
 1.169  05-Sep-2014  matt branches: 1.169.2;
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.168  24-Jun-2010  hannken branches: 1.168.14; 1.168.18; 1.168.20; 1.168.28; 1.168.34; 1.168.36; 1.168.40;
Clean up vnode lock operations pass 2:

VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
 1.167  03-Mar-2010  pooka branches: 1.167.2;
One more overcomplex ENOSYS bites the dust.
 1.166  03-Mar-2010  he When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.

This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.

Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.165  29-Jun-2009  dholland branches: 1.165.2;
Convert 67 namei call sites to use namei_simple, in these functions:

check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
 1.164  11-Jan-2009  tsutsui branches: 1.164.2;
Update for compat_50 stuff. (compile test only)
 1.163  19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.162  12-Nov-2008  ad Remove LKMs and switch to the module framework, pass 1.

Proposed on tech-kern@.
 1.161  07-Aug-2008  plunky branches: 1.161.2; 1.161.4; 1.161.8;
convert some [left behind] compat code to use new sockopt API
 1.160  24-Jun-2008  ad branches: 1.160.2;
Replace references to getsock/getvnode.
 1.159  21-Mar-2008  ad branches: 1.159.4; 1.159.6; 1.159.8;
Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
 1.158  27-Dec-2007  martin branches: 1.158.6;
Remove now superflous (and wrong) extern declaration for maxfiles.
 1.157  20-Dec-2007  dsl 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.156  08-Dec-2007  pooka branches: 1.156.4;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.155  08-Dec-2007  dsl ANSIfy most of the function definitions in sys/compat (but not ndis).
All by the magic of sed ...
 1.154  04-Dec-2007  dsl Remove all the __P
 1.153  27-Nov-2007  dogcow branches: 1.153.2;
more VFS_STATVFS(x,y,z) fallout; change them to VFS_STATVFS(x,y). (hi, pooka!)
 1.152  08-Oct-2007  ad branches: 1.152.4;
Merge file descriptor locking, cwdi locking and cross-call changes
from the vmlocking branch.
 1.151  17-Jul-2007  christos branches: 1.151.6; 1.151.8; 1.151.10;
include <compat/sys/mount.h> for MFSNAMELEN
 1.150  12-Jul-2007  dsl Change compat mount code to pass do_sys_mount() kernel resident buffers.
Possibly the standard nfs code needs teaching how to set the length and
address family in order to support non-netbsd sockaddr.
There are now no active stackgap() calls in the compat tree.
 1.149  12-May-2007  dsl Change interface to settimeofday1() so that it can also be used from
compat code in order to avoid the stackgap.
 1.148  28-Apr-2007  dogcow and unbork some more changes.
 1.147  22-Apr-2007  dsl Change the way that emulations locate files within the emulation root to
avoid having to allocate space in the 'stackgap'
- which is very LWP unfriendly.
The additional code for non-emulation namei() is trivial, the reduction for
the emulations is massive.
The vnode for a processes emulation root is saved in the cwdi structure
during process exec.
If the emulation root the TRYEMULROOT flag are set, namei() will do an initial
search for absolute pathnames in the emulation root, if that fails it will
retry from the normal root.
".." at the emulation root will always go to the real root, even in the middle
of paths and when expanding symlinks.
Absolute symlinks found using absolute paths in the emulation root will be
relative to the emulation root (so /usr/lib/xxx.so -> /lib/xxx.so links
inside the emulation root don't need changing).
If the root of the emulation would be returned (for an emulation lookup), then
the real root is returned instead (matching the behaviour of emul_lookup,
but being a cheap comparison here) so that programs that scan "../.."
looking for the root dircetory don't loop forever.
The target for symbolic links is no longer mangled (it used to get the
CHECK_ALT_xxx() treatment, so could get /emul/xxx prepended).
CHECK_ALT_xxx() are no more. Most of the change is deleting them, and adding
TRYEMULROOT to the flags to NDINIT().
A lot of the emulation system call stubs could now be deleted.
 1.146  04-Mar-2007  tsutsui branches: 1.146.2; 1.146.4;
- don't forget to add * to all params
- use (char *) where pointer arith is required
 1.145  04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.144  09-Feb-2007  ad branches: 1.144.2;
Merge newlock2 to head.
 1.143  14-Nov-2006  elad branches: 1.143.2;
Clean some KAUTH_GENERIC_ISSUSER usage in compat code.
 1.142  01-Sep-2006  matt branches: 1.142.2; 1.142.4;
When calling PTRACE from an LKM, use sysent[SYS_ptrace].sy_call in case
the sys_ptrace symbol isn't present.
 1.141  30-Aug-2006  he Update for options PTRACE.
 1.140  23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.139  26-Jun-2006  mrg version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.
 1.138  15-May-2006  yamt branches: 1.138.4;
- include kauth.h for kauth_authorize_generic.
- wrap a long line.
 1.137  14-May-2006  elad integrate kauth.
 1.136  01-Mar-2006  yamt branches: 1.136.2; 1.136.4; 1.136.6;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.135  24-Dec-2005  perry branches: 1.135.2; 1.135.4; 1.135.6;
__inline__ -> inline
 1.134  11-Dec-2005  christos merge ktrace-lwp.
 1.133  14-Sep-2005  he This now needs <compat/sys/signal.h> to build.
 1.132  19-Apr-2005  christos branches: 1.132.2;
PR/29696: Joel Carnat: NetBSD freezes when accessing smbfs mounted FS with
firefox/linux due to compat getdents() call assumption that all filesystems
support cookies.
 1.131  26-Feb-2005  perry branches: 1.131.2;
nuke trailing whitespace
 1.130  17-Sep-2004  skrll branches: 1.130.4; 1.130.6;
There's no need to pass a proc value when using UIO_SYSSPACE with
vn_rdwr(9) and uiomove(9).

OK'd by Jason Thorpe
 1.129  25-Apr-2004  matt Constify sreq2breq
 1.128  25-Apr-2004  matt Constify a few read-only arrays/variables.
 1.127  22-Apr-2004  hannken Make it compile again after statvfs import.
 1.126  21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.125  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.124  29-Jun-2003  fvdl branches: 1.124.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.123  29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.122  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.121  16-May-2003  itojun use strlcpy
[compat/svr4_32 should have bound check for SVR4_32_AUX_ARGSIZ]
 1.120  23-Feb-2003  pk Make updating a file's reference and use count MP-safe.
 1.119  29-Jan-2003  atatat Cull unused variables. Sigh.

PS - Cross compilers are cool.
 1.118  28-Jan-2003  atatat No need to pick a "default address" for mmap in compat code, since we
merely call sys_mmap() at the end anyway, and that will pick the
address for us, if it's needed.

Likewise for checking if /dev/zero is being mapped.
 1.117  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.116  06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.115  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.114  16-Mar-2002  christos branches: 1.114.4;
make the stackgap_{init,alloc} functions MP friendly (i.e. pass struct proc *
in, instead of using curproc). While there add an optional size argument to
stackgap_init.
 1.113  03-Jan-2002  mrg move the COMPAT_SUNOS SO_BROADCAST hack out of uipc_socket.c into the
compat/sunos code. besides being cleaner this allows the sunos LKM
to properly work without any special kernel hacks.
 1.112  02-Dec-2001  tsutsui Don't define COMPAT_SUNOS here. It is defined in opt_compat_sunos.h
and <sys/ioctl.h> and <sys/tty.h> include it properly.

XXX Is this needed for LKM?
 1.111  13-Nov-2001  lukem add RCSIDs (including regeneration of files as appropriate)
 1.110  14-Jun-2001  thorpej branches: 1.110.2; 1.110.4;
Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads. What we do is stick descriptors in the table, but
mark them as "larval". This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again. When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
 1.109  30-May-2001  mrg use _KERNEL_OPT.
 1.108  12-Feb-2001  fvdl branches: 1.108.2;
Cast 32bit sunos_nfs_arg member to (char *)(long) to avoid warning
after sunos.h change (cast is safe; a SunOS binary will pas a 32 bit
pointer).
 1.107  01-Dec-2000  jdolecek make LKM safe
 1.106  01-Dec-2000  jdolecek add e_path (emulation path) to struct emul, which replaces emulation-specific
*_emul_path variables

change macros CHECK_ALT_{CREAT|EXIST} to use that, 'root' doesn't need
to be passed explicitly any more and *_CHECK_ALT_{CREAT|EXIST} are removed
change explicit emul_find() calls in probe functions to get the emulation
path from the checked exec switch entry's emulation

remove no longer needed header files

add e_flags and e_syscall to struct emul; these are unsed and empty for now
 1.105  28-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.104  30-Mar-2000  augustss Kill register declarations.
 1.103  28-Mar-2000  simonb Centralise the declarations of cpu_model, machine, machine_arch,
osrelease, and ostype and remove "extern char foo[];" (for hostname
and domainname too).

Also delete redunctant decl of boottime in kern_info_43.c.
 1.102  26-Mar-2000  kleink Merge parts of chs-ubc2 into the trunk:
* Remove the casts to vaddr_t from the round_page() and trunc_page() macros to
make them type-generic, which is necessary i.e. to operate on file offsets
without truncating them.
* In due course, cast pointer arguments to these macros to an appropriate
integral type (paddr_t, vaddr_t).

Originally done by Chuck Silvers, updated by myself.
 1.101  05-May-1999  thorpej branches: 1.101.2;
Add "use counting" to file entries. When closing a file, and it's reference
count is 0, wait for use count to drain before finishing the close.

This is necessary in order for multiple processes to safely share file
descriptor tables.
 1.100  22-Mar-1999  sommerfe branches: 1.100.4;
Use regular system fchroot, now that we have it.
 1.99  09-Feb-1999  christos Const poisoning and CHECK_ALT_CREAT fixes
 1.98  21-Dec-1998  drochner g/c SA_USERTRAMP (ok'd by pk)
 1.97  19-Dec-1998  drochner get "opt_compat_xxx.h" includes out of <sys/signal.h>
 1.96  14-Sep-1998  pk Fix copyout() argument switch.
 1.95  13-Sep-1998  pk Signal compat: sunos sigset_t conversions;
new sunos_sigvec() & sunos_sigpending()
 1.94  08-Sep-1998  rvb ufs_readdir no longer checks if vp->v_type != VDIR so
the individual emulated readdirs must check.
Since netbsd and freebsd return EINVAL for the error
and I don't know what the other platforms do, return
EINVAL for them too.
 1.93  29-Aug-1998  mrg move <vm/vm_swap.h> to <sys/swap.h>. <vm/vm_swap.h> still works for now (goes away later)
 1.92  09-Aug-1998  perry bzero->memset, bcopy->memcpy, bcmp->memcmp
 1.91  26-Jun-1998  hannken Include NFSSERVER option header opt_nfsserver.h.
 1.90  04-Mar-1998  fvdl Make this compile again.
 1.89  03-Mar-1998  fvdl Only free cookiebuf when sure that the vop actually allocated it.
 1.88  01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.87  19-Feb-1998  thorpej Include the NFS option header.
 1.86  21-Oct-1997  fvdl branches: 1.86.2;
Update for new msync (== __msync13), use flags
 1.85  19-Oct-1997  christos Simplify use of round_page() like in other emulations.
 1.84  19-Oct-1997  carrel cast to void * not caddr_t
 1.83  10-Oct-1997  fvdl Fix braino in my interpretation of the eof flag to VOP_READDIR.
 1.82  10-Oct-1997  fvdl Signal error when getting a 64 bit offset cookie that can't be stored
in 32 bits. Provide an error message to the user, and return EINVAL.
Also, pay attention to the EOF flag from VOP_READDIR. Correct a
misspell in a panic message.
 1.81  04-Aug-1997  bouyer branches: 1.81.2;
Fix "missing entries" bug when reading large directories: When reading a
directory and running out of space in the dest buffer, off should point to the
current entry (which was not saved) and not to the next.
I discovered this bug using linux and SunOS emulation over NFS, but seems to
affect other emulations as well.
 1.80  13-Jun-1997  thorpej branches: 1.80.4;
Garbage-collect sunos_sys_swapon(); it is not needed.
 1.79  12-Jun-1997  mrg bring mrg-vm-swap2 onto mainline.
 1.78  08-May-1997  mycroft branches: 1.78.2;
Pass the vnode type to vaccess(), and use it when checking VEXEC. Make sure
that the mode bits passed to vaccess() and returned by foo_getattr() contain
only permission bits.
 1.77  08-May-1997  mycroft VEXEC -> VLOOKUP, as appropriate.
 1.76  31-Jan-1997  thorpej NFSCLIENT -> NFS
 1.75  28-Dec-1996  cjs branches: 1.75.2;
This recently stopped compiling due to a warning about const being
dropped. This fix suggested by cgd.
 1.74  13-Oct-1996  christos Remove STACKGAPBASE dependencies.
 1.73  13-Oct-1996  christos catch up with Jason's changes.
 1.72  07-Sep-1996  mycroft Implement poll(2).
 1.71  03-Sep-1996  mycroft Define execv() and execve() consistently across emulations.
Do path name translation.
 1.70  30-Aug-1996  christos add obsolete stime(2)
 1.69  26-Aug-1996  thorpej Implement sunos_sys_execve(). The previous code simply called
sys_execve() without doing an alternate patch check, which was
incorrect. Bug pointed out by Krister Walfridsson <cato@df.lth.se>
on port-sparc@NetBSD.ORG.
 1.68  11-Aug-1996  mrg update sunos_sys_reboot() to actually work again.
 1.67  09-Aug-1996  mrg Change reboot(2) to take two arguments: bootopt like normal and also
a boot string for firmware that can do this, such as the SPARC and
the sun3 models. It is currently silently ignored on all other
hardware now, however. The MD function "boot()" has been changed to
also take a char *.
 1.66  14-Jun-1996  cgd avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.
 1.65  22-Apr-1996  christos branches: 1.65.4;
remove include of <sys/cpu.h>
 1.64  14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.63  28-Feb-1996  gwr dir => dirent
 1.62  25-Feb-1996  pk If NFS `rsize' is specified, set `readdirsize' too.
 1.61  18-Feb-1996  pk Adapt compat NFS mount code to NFSv3.
 1.60  05-Jan-1996  pk Implement vhangup(); more or less as suggested in PR#1560 (matthew green).
I'm vrele'ing s_ttyvp here too, so sys_exit() won't have to go over it
again.
 1.59  14-Dec-1995  ghudson Reverse pk's changes from 1.57; the faked cookies are not valid,
and are no longer necessary now that NFS provides cookies.
 1.58  07-Nov-1995  gwr ufs ==> ffs
 1.57  11-Oct-1995  pk Gets NFS-mounted /emul/sunos going again by faking readdir cookies if
not supported by VOP_READDIR().
 1.56  09-Oct-1995  mycroft branches: 1.56.2;
Use cookies for directory offset, mostly from Greg Hudson.
 1.55  07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.54  19-Sep-1995  thorpej Make system calls conform to a standard prototype and bring those
prototypes into scope.
 1.53  15-Aug-1995  gwr Catch up with renamed SA_DISABLE flag and update
sunos_sigvec to allow the new SA_RESETHAND flag.
 1.52  05-Jul-1995  pk Start using sunos_sigvec().
 1.51  25-Jun-1995  briggs * Don't include sys/exec.h explicitly--it's not protected against multiple
inclusions and compat_util.h now includes it.
* Declare struct emul *e=p->p_emul in a couple of places so we can use
STACKGAPBASE macro (should this macro be modified to take a struct
emul * or struct proc * parameter?).
* Declare extern struct emul emul_sunos for sunos_sigvec's comparison.
 1.50  24-Jun-1995  christos Use compat_util.[ch]
 1.49  18-Jun-1995  cgd don't assume the f_fsnamelen is nul-truncated or longer than MFSNAMELEN
 1.48  11-Jun-1995  pk Go with the flow; use `/emul/sunos' pseudo-root (from Matthew Green).
Note: sunos_stat() and sunos_lstat() were added too.
 1.47  27-Apr-1995  christos Try to make the reboot system call compile under sun3 with RB_STRING
support [not tested]
Add files.sunos
Rename system call switch table file from sunos_init_sysent.c to sunos_sysent.c
like other emulations.
 1.46  26-Apr-1995  gwr Make sunos_reboot(RB_STRING,"...") work for sun3.
Could be made to work for sparc too.
 1.45  23-Apr-1995  briggs Fix compiler error in sunos_reboot().
 1.44  22-Apr-1995  christos Added sunos_reboot().
 1.43  21-Mar-1995  mycroft Update to use timer{add,sub}().
 1.42  09-Mar-1995  mycroft copy*str() should use size_t.
 1.41  17-Dec-1994  mycroft timevaladd -> __timeradd (AGAIN)
 1.40  16-Dec-1994  deraadt correct ansi glitch
 1.39  15-Dec-1994  pk mode/flags confusion in sunos_open().
 1.38  11-Dec-1994  mycroft Use __timeradd(), not timervaladd().
 1.37  30-Nov-1994  pk Convert SunOS IP multicast socket options.
 1.36  23-Nov-1994  deraadt m68k does not have PT_{SET,GET}FPREGS
 1.35  20-Nov-1994  deraadt ptrace from chs+@CS.cmu.edu, poll from christos
 1.34  14-Nov-1994  deraadt fix sunos_mmap
 1.33  25-Oct-1994  deraadt rename, new syscall interface, etc.
 1.32  20-Oct-1994  cgd pay a small amount of lip service to the new syscall args mechanism.
In reality, none of these will compile.
 1.31  28-Sep-1994  deraadt use STACKGAPBASE
 1.30  29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.29  22-Jun-1994  pk sun_mount: fill in one more field.
 1.28  15-Jun-1994  deraadt async_daemon only if NFSCLIENT
 1.27  10-Jun-1994  pk Adapt to 4.4-lite.
 1.26  08-Jun-1994  mycroft Minor change.
 1.25  06-Jun-1994  deraadt tricky
 1.24  24-May-1994  deraadt maxfdescs -> maxfiles
 1.23  21-May-1994  deraadt iszerodev
 1.22  19-May-1994  deraadt fix uname after sysctl
 1.21  05-May-1994  deraadt p->p_sig -> p->p_siglist
 1.20  05-May-1994  cgd fix my forgetfulness; from gwr
 1.19  04-May-1994  cgd expand the rlimit struct, kill last vestiges of off_t bogosity.
 1.18  29-Apr-1994  cgd kill syscall name aliases. no user-visible changes
 1.17  26-Apr-1994  pk SunOS's RLIMIT_NOFILE is different: add sun_[gs]rlimit().
 1.16  24-Apr-1994  deraadt make sunos mount(2) work again
 1.15  02-Apr-1994  cgd sickness to get SunOS mmap right
 1.14  27-Mar-1994  cgd expand uid_t/gid_t/off_t
 1.13  03-Mar-1994  deraadt DoH!
 1.12  03-Mar-1994  deraadt first cut at a SUNOS_COMPAT sysconf() system call.
 1.11  20-Feb-1994  chopps place conditional around sun_nfssvc.
 1.10  12-Dec-1993  deraadt m68k/sparc sunos binary compatibility code, pulled down from magnum branch
for consumption by the m68k masses
 1.9  22-Nov-1993  deraadt branches: 1.9.2;
moved from arch/sparc/sunos to compat/sunos
 1.8  20-Nov-1993  deraadt new compat functions: sun_open, sun_auditsys, sun_setpgid, sun_uname
some from Markus.
 1.7  12-Nov-1993  deraadt specdev.h moves
 1.6  10-Nov-1993  deraadt silly typo
 1.5  10-Nov-1993  deraadt support both sun3 & sparc concepts of minor/major #'s for /dev/zero
 1.4  15-Oct-1993  deraadt fix sun_getdents()
fix sun_mmap()
Note: delete the "struct dirent" in here when sys/dirent.h is created.
 1.3  13-Oct-1993  deraadt Add a stub auditsys() system call that does nothing.
SunOS /sbin/fsck calls it..
 1.2  11-Oct-1993  deraadt various changes, suffice to say that 4.4 syscalls do not look like ours
 1.1  02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.9.2.10  23-Jan-1994  deraadt make sun_misc compile without NFSSERVER. thanks to
Niklas Hallqvist <niklas@appli.se>
 1.9.2.9  01-Dec-1993  pk Introduced sun_mknod() which also deals with FIFOs (ie. `mknod xxx p' on SunOS).
 1.9.2.8  30-Nov-1993  deraadt impliment fstatfs() and statfs() better
 1.9.2.7  27-Nov-1993  deraadt very rudimentary exportfs(2) support, ie. "return 0"
 1.9.2.6  27-Nov-1993  deraadt statfs(2) and fstatfs(2) support. `df' now works.
 1.9.2.5  27-Nov-1993  deraadt add vhangup(2)
generalize m68k support for /dev/zero..
 1.9.2.4  26-Nov-1993  deraadt add real wimpy quotactl(2) emulation
 1.9.2.3  26-Nov-1993  deraadt add basically bogus ustat(2) support.
 1.9.2.2  26-Nov-1993  deraadt nfssvc(2) system call emulation. might work, might not -- have to
wait for exportfs(2) support for mountd..
 1.9.2.1  26-Nov-1993  deraadt added mount(2) nfs support
 1.56.2.2  07-Nov-1995  gwr From Head: ufs ==> ffs
 1.56.2.1  13-Oct-1995  pk Update from trunk: fake cookies
 1.65.4.1  10-Dec-1996  mycroft From trunk:
Do execv() and execve() path name translation consistently across
emulations.
 1.75.2.1  14-Jan-1997  thorpej Snapshot of work-in-progress, committed to private branch.

These changes implement machine-independent root device and file system
selection. Notable features:

- All ports behave in a consistent manner regarding root
device selection.
- No more "options GENERIC"; all kernels have the ability
to boot with RB_ASKNAME to select root device and file system
type.
- Root file system type can be wildcarded; a machine-independent
function will try all possible file systems for the selected
root device until one succeeds.
- If the root file system fails to mount, the operator will
be given the chance to select a new root device and file
system type, rather than having the machine simply panic.
- nfs_mountroot() no longer panics if any part of the NFS
mount process fails; it now returns an error, giving the
operator a chance to recover.
- New, more consistent, config(8) grammar. The constructs:

config netbsd swap generic
config netbsd root on nfs

have been replaced with:

config netbsd root on ? type ?
config netbsd root on ? type nfs

Additionally, the operator may select or wildcard root file
system type in the kernel configuration file:

config netbsd root on cd0a type cd9660

config(8) now requires that a "root" specification be
made. "root" may be wired down or wildcarded. "swap" and
"dump" specifications are optional, and follow previous
semantics.

- config(8) has a new "file-system" keyword, used to configure
file systems into the kernel. Eventually, this will be used
to generate the default vfssw[].

- "options NFSCLIENT" is obsolete, and is replaced by
"file-system NFS". "options NFSSERVER" still exists, since
NFS server support is independent of the NFS file system
client.

- sys/arch/<foo>/<foo>/swapgeneric.c is no longer used, and
will be removed; all information is now generated by config(8).

As of this commit, all ports except arm32 have been updated to use
the new setroot(). Only SPARC, i386, and Alpha ports have been
tested at this time. Port masters should test these changes on their
ports, and report any problems back to me.

More changes are on their way, including RB_ASKNAME support in
nfs_mountroot() (to prompt for server address and path) and, potentially,
the ability to select rarp/bootparam or bootp in nfs_mountroot().
 1.78.2.2  01-Jun-1997  mrg implement sunos_sys_swapon().
 1.78.2.1  08-May-1997  mrg file sunos_misc.c was added on branch mrg-vm-swap2 on 1997-06-01 14:14:12 +0000
 1.80.4.2  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.80.4.1  23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.81.2.1  08-Sep-1997  thorpej Significantly restructure the way signal state for a process is stored.
Rather than using bitmasks to redundantly store the information kept
in the process's sigacts (because the sigacts was kept in the u-area),
hang sigacts directly off the process, and access it directly.

Simplify signal setup code tremendously by storing information in
the sigacts as an array of struct sigactions, rather than in a different
format, since userspace uses sigactions.

Make sigacts sharable by adding reference counting.
 1.86.2.2  21-Oct-1997  fvdl Update for new msync (== __msync13), use flags
 1.86.2.1  21-Oct-1997  fvdl file sunos_misc.c was added on branch netbsd-1-3 on 1997-10-21 00:58:42 +0000
 1.100.4.1  21-Jun-1999  thorpej Sync w/ -current.
 1.101.2.3  12-Mar-2001  bouyer Sync with HEAD.
 1.101.2.2  08-Dec-2000  bouyer Sync with HEAD.
 1.101.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.108.2.12  17-Sep-2002  nathanw Catch up to -current.
 1.108.2.11  01-Aug-2002  nathanw Catch up to -current.
 1.108.2.10  12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.108.2.9  21-Jun-2002  gmcgarry LWPify socket syscalls.
 1.108.2.8  29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.108.2.7  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.108.2.6  28-Feb-2002  nathanw Catch up to -current.
 1.108.2.5  11-Jan-2002  nathanw More catchup.
 1.108.2.4  08-Jan-2002  nathanw Catch up to -current.
 1.108.2.3  15-Nov-2001  pk LWP system call signature conversion.
 1.108.2.2  14-Nov-2001  nathanw Catch up to -current.
 1.108.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.110.4.1  26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.110.2.4  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.110.2.3  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.110.2.2  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.110.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.114.4.2  15-Jul-2002  gehenna catch up with -current.
 1.114.4.1  16-May-2002  gehenna Get rid of iszerodev. Use the 'zerodev' (dev_t for /dev/zero).
 1.124.2.7  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.124.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.124.2.5  21-Nov-2004  skrll Adapt to branch.
 1.124.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.124.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.124.2.2  03-Aug-2004  skrll Sync with HEAD
 1.124.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.130.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.130.4.1  29-Apr-2005  kent sync with -current
 1.131.2.1  01-Oct-2005  tron Pull up following revision(s) (requested by christos in ticket #838):
sys/compat/svr4/svr4_misc.c: revision 1.112
sys/compat/ibcs2/ibcs2_misc.c: revision 1.74
sys/compat/linux/common/linux_misc.c: revision 1.136
sys/compat/irix/irix_dirent.c: revision 1.14
sys/compat/sunos/sunos_misc.c: revision 1.132
sys/compat/svr4_32/svr4_32_misc.c: revision 1.31
sys/compat/sunos32/sunos32_misc.c: revision 1.30
sys/compat/linux/common/linux_file64.c: revision 1.26
PR/29696: Joel Carnat: NetBSD freezes when accessing smbfs mounted FS with
firefox/linux due to compat getdents() call assumption that all filesystems
support cookies.
 1.132.2.8  24-Mar-2008  yamt sync with head.
 1.132.2.7  21-Jan-2008  yamt sync with head
 1.132.2.6  07-Dec-2007  yamt sync with head
 1.132.2.5  27-Oct-2007  yamt sync with head.
 1.132.2.4  03-Sep-2007  yamt sync with head.
 1.132.2.3  26-Feb-2007  yamt sync with head.
 1.132.2.2  30-Dec-2006  yamt sync with head.
 1.132.2.1  21-Jun-2006  yamt sync with head.
 1.135.6.2  01-Jun-2006  kardel Sync with head.
 1.135.6.1  22-Apr-2006  simonb Sync with head.
 1.135.4.1  09-Sep-2006  rpaulo sync with head
 1.135.2.1  18-Feb-2006  yamt adapt the rest of MI code.
 1.136.6.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.136.4.2  10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.136.4.1  08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.136.2.3  03-Sep-2006  yamt sync with head.
 1.136.2.2  11-Aug-2006  yamt sync with head
 1.136.2.1  24-May-2006  yamt sync with head.
 1.138.4.1  13-Jul-2006  gdamore Merge from HEAD.
 1.142.4.1  10-Dec-2006  yamt sync with head.
 1.142.2.3  30-Jan-2007  ad Remove support for SA. Ok core@.
 1.142.2.2  12-Jan-2007  ad sparc MD changes.
 1.142.2.1  18-Nov-2006  ad Sync with head.
 1.143.2.1  12-Jun-2010  riz Pull up following revision(s) (requested by he in ticket #1387):
sys/compat/svr4/svr4_misc.c: revision 1.149
sys/compat/linux/common/linux_misc.c: revision 1.214
sys/compat/common/vfs_syscalls_30.c: revision 1.31
sys/compat/sunos/sunos_misc.c: revision 1.166
sys/compat/linux/common/linux_file64.c: revision 1.50
sys/compat/svr4_32/svr4_32_misc.c: revision 1.68
sys/compat/ibcs2/ibcs2_misc.c: revision 1.110
sys/compat/linux32/common/linux32_dirent.c: revision 1.10
sys/compat/sunos32/sunos32_misc.c: revision 1.69
sys/compat/irix/irix_dirent.c: revision 1.24
sys/compat/osf1/osf1_file.c: revision 1.38
When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.
This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.
Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.144.2.3  17-May-2007  yamt sync with head.
 1.144.2.2  07-May-2007  yamt sync with head.
 1.144.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.146.4.1  11-Jul-2007  mjf Sync with head.
 1.146.2.4  09-Oct-2007  ad Sync with head.
 1.146.2.3  20-Aug-2007  ad Sync with HEAD.
 1.146.2.2  15-Jul-2007  ad Sync with head.
 1.146.2.1  27-May-2007  ad Sync with head.
 1.151.10.1  14-Oct-2007  yamt sync with head.
 1.151.8.2  09-Jan-2008  matt sync with HEAD
 1.151.8.1  06-Nov-2007  matt sync with HEAD
 1.151.6.3  09-Dec-2007  jmcneill Sync with HEAD.
 1.151.6.2  27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.151.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.152.4.3  18-Feb-2008  mjf Sync with HEAD.
 1.152.4.2  27-Dec-2007  mjf Sync with HEAD.
 1.152.4.1  08-Dec-2007  mjf Sync with HEAD.
 1.153.2.2  26-Dec-2007  ad Sync with head.
 1.153.2.1  08-Dec-2007  ad Sync with head.
 1.156.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.158.6.4  17-Jan-2009  mjf Sync with HEAD.
 1.158.6.3  28-Sep-2008  mjf Sync with HEAD.
 1.158.6.2  29-Jun-2008  mjf Sync with HEAD.
 1.158.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.159.8.1  27-Jun-2008  simonb Sync with head.
 1.159.6.3  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.159.6.2  14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.159.6.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.159.4.4  11-Aug-2010  yamt sync with head.
 1.159.4.3  11-Mar-2010  yamt sync with head
 1.159.4.2  18-Jul-2009  yamt sync with head.
 1.159.4.1  04-May-2009  yamt sync with head.
 1.160.2.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.160.2.1  19-Oct-2008  haad Sync with HEAD.
 1.161.8.1  21-Apr-2010  matt sync to netbsd-5
 1.161.4.1  17-Mar-2010  snj Pull up following revision(s) (requested by he in ticket #1323):
sys/compat/common/vfs_syscalls_30.c: revision 1.31
sys/compat/ibcs2/ibcs2_misc.c: revision 1.110
sys/compat/irix/irix_dirent.c: revision 1.24
sys/compat/linux/common/linux_file64.c: revision 1.50
sys/compat/linux/common/linux_misc.c: revision 1.214
sys/compat/linux32/common/linux32_dirent.c: revision 1.10
sys/compat/sunos/sunos_misc.c: revision 1.166
sys/compat/sunos32/sunos32_misc.c: revision 1.69
sys/compat/svr4/svr4_misc.c: revision 1.149
sys/compat/svr4_32/svr4_32_misc.c: revision 1.68
When implementing "read directory", when there are too many empty entries
in a row, and we need to try to read the next block, and have passed a
non-NULL cookie pointer to VOP_READDIR, ensure that we free the cookie
buffer before re-doing VOP_READDIR, so that we don't leak memory.
This fix is similar to nfs_serv.c revisions 1.115 + 1.124.
This should fix the long-standing problem observed by e.g. using Linux-
emulated programs to take backup of servers, which is one of the problems
which were reported in PR#42661.
Thanks to pooka@ for the hints for traversing the VOP* layer.
 1.161.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.164.2.1  23-Jul-2009  jym Sync with HEAD.
 1.165.2.2  17-Aug-2010  uebayasi Sync with HEAD.
 1.165.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.167.2.1  03-Jul-2010  rmind sync with head
 1.168.40.1  12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.168.36.1  12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.168.34.1  12-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1479):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.168.28.1  19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.168.20.1  19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.168.18.1  03-Dec-2017  jdolecek update from HEAD
 1.168.14.1  19-Aug-2017  snj Pull up following revision(s) (requested by mrg in ticket #1483):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.169.2.2  28-Aug-2017  skrll Sync with HEAD
 1.169.2.1  27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.170.10.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.170.10.1  09-Aug-2017  snj Pull up following revision(s) (requested by spz in ticket #193):
sys/compat/common/vfs_syscalls_12.c: revision 1.34
sys/rump/kern/lib/libsys_sunos/rump_sunos_compat.c: revision 1.2
sys/compat/svr4_32/svr4_32_misc.c: revision 1.78
sys/compat/sunos32/sunos32_misc.c: revision 1.78
sys/compat/linux/common/linux_misc.c: revision 1.239
sys/compat/osf1/osf1_file.c: revision 1.44
sys/compat/common/vfs_syscalls_43.c: revision 1.60
sys/compat/svr4/svr4_misc.c: revision 1.158
sys/compat/ibcs2/ibcs2_misc.c: revision 1.114
sys/compat/linux/common/linux_file64.c: revision 1.59
sys/compat/linux32/common/linux32_dirent.c: revision 1.18
sys/compat/sunos/sunos_misc.c: revision 1.171
Fail, don't panic, on bad dirents from file system.
Controllable via puffs from userland.
From Ilja Van Sprundel.
 1.171.4.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.171.4.1  10-Jun-2019  christos Sync with HEAD
 1.171.2.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.173.2.1  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.

RSS XML Feed