Commit Graph

19998 Commits

Author SHA1 Message Date
christos
9aa2a9c323 Add ACL support for FFS. From FreeBSD. 2020-05-16 18:31:45 +00:00
thorpej
74b029050e Avoid pulling in "namespace.h" here, as it can have unintended
effects on consumers of this header.
2020-05-16 16:16:59 +00:00
joerg
7cbd7912a7 Bump libc minor version for malloc lock change 2020-05-15 14:57:33 +00:00
joerg
8409cf4a20 Hook up proper fork lock handling for malloc:
- lock all relevant mutexes just before fork
- unlock all mutexes just after fork in the parent
- full reinit non-spinlocks in the child
This is not using the normal pthread_atfork interface to ensure order of
operation, malloc is used as implementation detail too often.
2020-05-15 14:37:21 +00:00
joerg
858ee362bb Lock/unlock/reinit pthread__deadqueue_lock over fork. 2020-05-15 14:30:23 +00:00
wiz
3528b8e86e Use more markup. 2020-05-14 13:40:49 +00:00
kamil
48b46ced17 Introduce new ptrace(2) operations: PT_SET_SIGPASS and PT_GET_SIGPASS
They deliver the logic of bypassing selected signals directly to the
debuggee, without informing the debugger.

This can be used to implement the QPassSignals GDB/LLDB protocol.

This call can be useful to avoid signal races in ATF ptrace tests.
2020-05-14 13:32:15 +00:00
simonb
a5e6defa61 KNF nit. 2020-05-14 11:50:04 +00:00
msaitoh
8012ca3f0e Remove extra semicolon. 2020-05-14 08:34:17 +00:00
kamil
ba111eb8df Remove mentions of CLONE_PID and CLONE_STOPPED
CLONE_PID was removed in Linux 2.5.15 and recycled for
CLONE_PIDFD since Linux 5.2.

CLONE_STOPPED was removed in Linux 2.6.38 and recycled
for CLONE_NEWCGROUP since Linux 4.6.
2020-05-12 11:39:08 +00:00
kre
872f7801f3 Do as the manual says, and use _PATH_DEFPATH if PATH is not present in
the environment rather than simply turning into posix_spawn() in that case.

Also, we cannot use strtok() to parse PATH, the semantics don't fit the API.
Borrow the guts of execvp for the PATH search.

We still simply check for a file with 'x' permission, and assume that one
will do, whatever it is, which isn't really correct, but ...
2020-05-11 14:54:34 +00:00
maya
b47e7497df Don't add getentropy.c to the build (remove symbol from libc)
Still being discussed in tech-userlevel. If we wait any longer someone
is going to try the excuse that the discussion is entirely pointless, since
removing symbols is too hard.
2020-05-10 19:36:49 +00:00
skrll
62da6573ee Rename curbrk to __curbrk, and make it and __minbrk hidden 2020-05-10 14:34:31 +00:00
skrll
ef7a9d8de1 Don't futz with tpidr_el0 in {set,long}jmp as it breaks TLS as seen in
qemu
2020-05-10 14:05:59 +00:00
skrll
fe2a0db7f4 No need to .import __cerror as SYS.h does it 2020-05-09 08:25:33 +00:00
wiz
94cffb35ae Fix macro usage. Fix typo. New sentence, new line. 2020-05-07 12:55:06 +00:00
nia
5e1fba1a1e Add getentropy() to libc - a simple wrapper to access the kernel CSPRNG.
Posted to tech-userlevel@ a week ago and reviewed by riastradh@.

GETENTROPY(3)		   Library Functions Manual		 GETENTROPY(3)

NAME
     getentropy - fill a buffer with high quality random data

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <unistd.h>

     int
     getentropy(void *buf, size_t buflen);

DESCRIPTION
     The getentropy() function fills a buffer with high quality random data,
     suitable for seeding cryptographically secure psuedorandom number
     generators.

     getentropy() is only intended for seeding random number generators and is
     not intended for use by regular code which simply needs secure random
     data.  For this purpose, please use arc4random(3).

     The maximum value for buflen is 256 bytes.

IMPLEMENTATION NOTES
     getentropy() reads from the sysctl(7) variable kern.arandom.

RETURN VALUES
     The getentropy() function returns 0 on success, and -1 if an error
     occurred.

ERRORS
     getentropy() will succeed unless:

     [EFAULT]		The buf argument points to an invalid memory address.

     [EIO]		Too many bytes were requested.

SEE ALSO
     arc4random(3), rnd(4)

STANDARDS
     The getentropy() function is non-standard.

HISTORY
     The getentropy() function first appeared in OpenBSD 5.6, then in
     FreeBSD 12.0, and NetBSD 10.
2020-05-06 16:17:36 +00:00
christos
81f24eb1c1 Allocate one more byte so that we are always NUL-terminated, and remove
the extra commented out NUL-terminations. As suggested in:

    http://mail-index.netbsd.org/source-changes-d/2020/04/01/msg012470.html
2020-05-06 12:44:36 +00:00
kamil
0cb847d641 Avoid buffer overflow
Disable the offending code.

OK by kre@
2020-05-06 07:25:26 +00:00
skrll
fd7fe8589e Mark __cerror as hidden to avoid using the PLT. This is required for new
binutils where the PLT stubs now use %t1 (%r22) which is used to pass
the errno to __cerror.
2020-05-05 20:43:47 +00:00
skrll
af937be388 Add a space before any non-nullified instruction. NFCI. 2020-05-05 20:39:18 +00:00
skrll
2af01421ec Add a space before any non-nullified instruction. NFCI. 2020-05-05 06:20:55 +00:00
skrll
cfd190c74d Use the delay slot 2020-05-05 06:11:06 +00:00
skrll
bd82c7dc44 Remove unnecesary #define/#undef _LOCORE 2020-05-05 06:06:16 +00:00
skrll
22b0819af2 Remove unnecesary #define/#undef _LOCORE 2020-05-04 06:42:11 +00:00
skrll
7f91a39bb5 Even more trailing whitespace 2020-05-03 15:29:22 +00:00
skrll
94eade6946 More trailing whitespace 2020-05-03 15:27:06 +00:00
skrll
4210e62106 Trailing whitespace 2020-05-03 08:36:09 +00:00
mrg
e6631f7240 turn off TLS for mips on old jemalloc. it doesn't work. 2020-05-03 07:32:54 +00:00
christos
db3eb68fb5 Cast off_t to size_t to appease lint:
warning: conversion from 'long long' to 'int' may lose accuracy
2020-05-02 14:31:13 +00:00
christos
4b08ec2333 Fix the vax build and explain why... 2020-05-01 21:58:16 +00:00
riastradh
0f6461fb7e Reverse sense of NO_STATIC_MODULES -> OPENPAM_STATIC_MODULES.
This avoids leaking NO_STATIC_MODULES into the public header, which
has led to considerable confusion and workarounds in pkgrsc.

PR security/39313
PR security/55216

ok christos
2020-04-29 02:16:56 +00:00
christos
d37b621bc8 Don't treat failure to map the file as fatal. 2020-04-28 14:27:41 +00:00
christos
6b123e2600 make kvm_pread use the mapped buffer if it is available. 2020-04-28 00:19:23 +00:00
christos
39cda3989e Implement kvm_write() for dump files. We map the file privately so that
changes don't get propagated back, and then write to the private buffer.
This is not useful yes, but it is simple enough to make pread use the buffer
if it is available.
2020-04-28 00:12:01 +00:00
pgoyette
8d1dd42752 Document ENOSYS return from MODCTL_EXIST.
Remove EMLINK since it is no longer returned.
2020-04-26 18:56:49 +00:00
thorpej
276ef22378 Add a NetBSD native futex implementation, mostly written by riastradh@.
Map the COMPAT_LINUX futex calls to the native ones.
2020-04-26 18:53:31 +00:00
maxv
26cfc3f122 Switch to the new PTE naming. The old naming is now unused, remove it. 2020-04-25 05:17:16 +00:00
joerg
18796b949c Explicitly use -fcommon for globals shared between libc and CSU. 2020-04-22 23:32:25 +00:00
thorpej
c6ca5287d3 Remove man page for the never-exposed _lwp_gettid(2) call. 2020-04-22 21:27:06 +00:00
rin
27f1060c62 Restrict usage of m68k assembler versions of {,u}divsi3 and {,u}divsi3 to
kernel and bootloader for 68010.

They requires a special calling convention to udivsi3, and cannot to be
mixed up in normal routines provided by libgcc or compiler_rt. Although,
there's no problem for using them in a controlled situation, i.e., kernel
and standalone programs.

Note that this does not affect at all m68k ports other than sun2, since
codes generated by gcc do not call these routines.

Assembler files are moved from common/lib/libc/arch/m68k/gen to
sys/lib/libkern/arch/m68k in order not to be compiled in libc.

Revert hack introduced to lib/libc/compiler_rt/Makefile.inc rev 1.37:
http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/compiler_rt/Makefile.inc#rev1.37

Proposed on port-sun2@ with no response...
(Again, this does not affect m68k ports other than sun2.)
http://mail-index.netbsd.org/port-sun2/2020/03/10/msg000102.html
2020-04-22 11:28:56 +00:00
rin
1d3b363c69 Use __mc68010__ to distinguish m68000 (sun2) from other m68k ports;
__mc68000__ is defined both for m68000 and m68k.
2020-04-22 08:48:12 +00:00
rin
45df14becf Fix previous for libhack, where _REENTRANT is not defined;
arenas_map_key is used only when NO_TLS && _REENTRANT.
2020-04-22 08:45:06 +00:00
joerg
880ddc3f7b Switch to using TLS in old jemalloc for everywhere but VAX and sun2. 2020-04-21 22:22:55 +00:00
nia
ab8a3679da ossaudio: removed outdated comment 2020-04-20 12:01:44 +00:00
joerg
1116ee1756 Improve TSD behavior
Optimistically check whether the key has been used by this thread
already and avoid locking in that case. This avoids the atomic operation
in the hot path. When the value is set to non-NULL for the first time,
put the entry on the to-be-freed list and keep it their until
destruction or thread exit. Setting the key to NULL and back is common
enough and updating the list is more expensive than the extra check on
the final round.
2020-04-19 20:47:03 +00:00
joerg
57360565c8 Reinit TSD mutex in the child to avoid issues with former waiters 2020-04-19 20:46:04 +00:00
nia
8e9e149d7d ossaudio: Implement SNDCTL_DSP_(SET|GET)TRIGGER. 2020-04-19 13:44:50 +00:00
nia
d4490f2a9c ossaudio: Make SNDCTL_DSP_[GET|SET][PLAY|RECORD]VOL closer to OSSv4
Problems in the previous code include returning values in the 0-255
range NetBSD uses instead of the 0-100 range OSSv4 expects, using
AUDIO_GETBUFINFO (which doesn't even return the mixer bits), and
not encoding channels as specified: "level=(left)|(right << 8)".

In reality, setting the gain in this way (through /dev/audio rather
than /dev/mixer) doesn't seem to work properly, and the mixer-set
value seems to be retained.

However, these changes at least ensure that the return values are
correct and the balance is set correctly.

I've only found one application using this API (audio/audacious), and
OSSv4 support in it is currently disabled precisely because it breaks
when it attempts to set the track volume using it.
2020-04-19 11:27:40 +00:00
joerg
25a494ecc4 Rename __atomic_fork to __locked_fork and give it &errno as argument.
rtld and libc use different storage, so the initial version would
incorrectly report the failure reason for fork().

There is still a small race condition inside ld.elf_so as it doesn't use
thread-safe errno internally, but that's a more contained internal
issue.
2020-04-19 01:06:15 +00:00