Commit Graph

20022 Commits

Author SHA1 Message Date
ad b81fe3a293 Adjust previous. In the condvar case the wakeup might already have been
eaten.
2020-06-06 22:23:59 +00:00
thorpej a792b8435e Improvements to the problib(3) API:
==> Provide a much more complete set of setters and getters for different
    value types in the prop_array_util(3) and prop_dictionary_util(3)
    functions.

==> Overhaul the prop_data(3), prop_number(3), and prop_string(3) APIs
    to be easier to use and less awkwardly named,  Deprecate the old
    awkward names, and produce link-time warnings when they are referenced.

==> Deprecate mutable prop_data(3) and prop_string(3) objects.  The old
    APIs that support them still exist, but will now produce link-time
    warnings when used.

==> When the new prop_string(3) API is used, strings are internally
    de-duplicated as a memory footprint optimization.

==> Provide a rich set of bounds-checked gettter functions in and a
    corresponding set of convenience setters in the prop_number(3) API.

==> Add a new prop_bool_value(3) function that is equivalent to
    prop_bool_true(3), but aligned with the new "value" routines in
    prop_data(3), prop_string(3), and prop_number(3).
2020-06-06 21:25:59 +00:00
roy c3293770af terminfo(5): Numbre -> Number
Thanks to yukonbob
2020-06-05 22:08:10 +00:00
nia d06dd93f7d Remove more bogus tests for 64-bit i386 and SuperH.
These are always false.
2020-06-05 11:16:15 +00:00
nia 35c066bcd5 getaddrinfo.3: order of the struct members is wrong, correct it 2020-06-04 11:28:00 +00:00
riastradh 0b4833402a Nix trailing whitespace. NFCI. 2020-06-04 04:40:01 +00:00
joerg 558a0c7357 If _malloc_thread_cleanup is implement, call it from libpthread.
Provide the hook from modern jemalloc to avoid using TSD for the thread
destruction cleanup as it can result in reentrancy crashes if fork is
called from a thread that never called malloc as it will result in a
late malloc from the pre-fork synchronisation handler.
2020-06-04 00:45:32 +00:00
ad 051faad4aa Deal with a couple of problems with threads being awoken early due to
timeouts or cancellation where:

- The restarting thread calls _lwp_exit() before another thread gets around
  to waking it with _lwp_unpark(), leading to ESRCH (observed by joerg@).
  (I may have removed a similar check mistakenly over the weekend.)

- The restarting thread considers itself gone off the sleep queue but
  at the same time another thread is part way through waking it, and hasn't
  fully completed that operation yet by setting thread->pt_mutexwait = 0.
  I think that could have potentially lead to the list of waiters getting
  messed up given the right circumstances.
2020-06-03 22:10:24 +00:00
kamil 5d0165c29d timespec_get(3) was developed by myself
Remove FreeBSD from the authorship as it was just a pullup of small
documentation changes.
2020-06-02 19:30:29 +00:00
nia d5d305cc98 Don't suggest removing arc4random with a libc bump.
It's established enough in non-legacy code that this is a terrible idea.
Even if we add getentropy it's not a comparable API (not a userspace RNG
capable of streaming large numbers of bytes, doesn't have _uniform, etc).

"Feel free to remove that line!" - riastradh
2020-06-02 13:56:30 +00:00
joerg b90f380e16 Don't overalign _RuneStatePriv, it must share the alignment of mbstate_t
it aliased with. Assert that the alignment actually used reflects the
alignment required by existing implementation and for newly build
modules assert that it is at most the guaranteed alignment.
2020-06-02 01:30:31 +00:00
joerg 34a4ae727b Pass down errno when calling pthread__errorfunc after a system call.
Allow format arguments for that reason and use (v)snprintf_ss in
pthread_errorfunc to avoid race conditions and the like.
2020-06-02 00:29:53 +00:00
ad 06d492d198 In the interests of reliability simplify waiter handling more and redo
condvars to manage the list of waiters with atomic ops.
2020-06-01 11:44:59 +00:00
christos 58b288d88d use strlcpy() instead of strncpy() for gcc happiness 2020-05-31 23:24:23 +00:00
rin 3a564f248f Add m68k assembler version of __muldi3().
This is intended for 68060:
  - GCC does not emit __muldi3() for 68020-40, that have 32 * 32 --> 64 mulul
  - mulsl (and moveml), used in this code, are not implemented for 68010

In comparison with that from compiler_rt, this version saves:
  - 12% of processing time
  - 12 bytes of stack
  - 50 bytes of code size
Also, slightly faster, memory saving, and smaller than libgcc version.

By examining with evcnt(9), __muldi3() is invoked more than 1000 times per
sec by kernel, which should justify to introduce assembler version of this
function.
2020-05-31 11:43:37 +00:00
roy 877982596a terminfo: test strlcpy result against space free, not string length
riastradh@ yep, looks good.
2020-05-30 16:03:58 +00:00
rmind b899bfd96f Major NPF improvements (merge from upstream):
- Switch to the C11-style atomic primitives using atomic_loadstore(9).

- npfkern: introduce the 'state.key.interface' and 'state.key.direction'
  settings.  Users can now choose whether the connection state should be
  strictly per-interface or global at the configuration level.  Keep NAT
  logic to be always per-interface, though.

- npfkern: rewrite the G/C worker logic and make it self-tuning.

- npfkern and libnpf: multiple bug fixes; add param exporting; introduce
  more parameters.  Remove npf_nvlist_{copyin,copyout}() functions and
  refactor npfctl_load_nvlist() with others; add npfctl_run_op() to have
  a single entry point for operations.  Introduce npf_flow_t and clean up
  some code.

- npfctl: lots of fixes for the 'npfctl show' logic; make 'npfctl list'
  more informative; misc usability improvements and more user-friendly
  error messages.

- Amend and improve the manual pages.
2020-05-30 14:16:56 +00:00
christos c1167da0aa Add pathconf and lpathconf (fixes lib/librumphijack/nfs test which uses ls
which now uses lpathconf)
2020-05-27 18:55:36 +00:00
christos 14c787bcf7 Bring in 2020a 2020-05-25 14:52:48 +00:00
christos 56e4243b76 Add libuv 2020-05-24 19:29:19 +00:00
rin 6ce10d32d6 Fix fallout from NO_STATIC_MODULES -> OPENPAM_STATIC_MODULES changes;
libpam.a fails to load any modules and does not work at all.

At the moment, openpam_load.c at least must be compiled with and without
OPENPAM_STATIC_MODULES for static and shared libraries, respectively.

Therefore, use CSHLIBFLAGS again, in order to build objects for static and
shared libraries separately.

This may be ugly, but seems better for me than adding further hacks in
libpam/libpam/Makefile, which is already complicated enough...
2020-05-23 00:43:33 +00:00
riastradh 59ccc04e14 Teach libc's compat ldexp stub to raise fp exceptions.
This ldexp stub will shadow the ldexp weak alias for scalbn in libm,
which is unfortunate but hard to fix properly without chasing the
mythical libc bump beast.  With the change here, we should raise all
the same exceptions that libm's scalbn does -- overflow, underflow,
inexact-result, and (for signalling NaN only) invalid-operation.
This in turn should correct the missing overflow/underflow exceptions
of our portable C fma, and perhaps other routines.

XXX pullup
2020-05-21 05:56:31 +00:00
ad bc77394ce5 - Try to eliminate a hang in "parked" I've been seeing while stress testing.
Centralise wakeup of deferred waiters in pthread__clear_waiters() and use
  throughout libpthread.  Make fewer assumptions.  Be more conservative in
  pthread_mutex when dealing with pending waiters.

- Remove the "hint" argument everywhere since the kernel doesn't use it any
  more.
2020-05-16 22:53:37 +00:00
christos d18bf24229 bump for ACLS 2020-05-16 18:59:23 +00:00
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