Commit Graph

986 Commits

Author SHA1 Message Date
maxv dedb2f3a2d Fix bug, the computation of cpuset_nentries was incorrect, we must do +1
to be able to address the last 32 bits.

On a machine with 80 CPUs, this caused "cpuctl identify >64" to return
garbage.
2019-05-11 11:53:55 +00:00
skrll 6e867a675a toolify
PR/54182: Cross-building on Linux fails in rb.c
2019-05-09 10:56:24 +00:00
thorpej 88c316691b Use posix_madvise() rather than the legacy madvise() call, and
wrapp the calls in #ifdef for the advice we're giving.  Should
address reports of host tool build issues.
2019-05-08 04:34:33 +00:00
thorpej 8319f966d5 Fix building libprop as a host tool library on platforms that don't have
the Matt Thomas rbtree:

- Include rb.c in libnbcompat, and provide a nbcompat sys/rbtree.h
  header.
- Make sure libprop's source file include prop_object_impl.h before
  anything else, and pull in nbtool_config.h from there.

Tested by simulating such a host system by renaming the host's
<sys/rbtree.h> out of the way (which reproduced the build failure)
and verifying that the host-tool installboot contained the rb_*
functions in its own .text segment.
2019-05-08 02:25:50 +00:00
kre 63e182f423 snprintb(3) says that, in the new(?) Torek format, all fields specs end with \0
The F spec is one of those, it should be terminated with \0 just like all
the others (irrelevant that it has no extra data to delimit).

Fix <sys/mman.h> to define the snprintb() format string correctly (include
the missing \0's).   Fix the copy of that definition included into
snprintb(3) to match the updated mman.h version (ride the date bump
from the day before yesterday .. this is the same change, just corrected).

Undo the previous snprintb.c change ("off by one" fix) which was an
attempt to make the broken mman.h usage work (and did, but not the way
it should be done).   Also, after using the new * format (instead of only
when something has already matched) skip the associated data so we don't
attempt to interpret it as more field specifiers.  This func needs lots of TLC!

Fix the ATF tests for snprintb() to not assume that F format is really
exactly like f format, and has data after the field specifier.  It doesn't.
Add several more tests (including testing the '*' field operator
recently added).
2019-04-29 07:55:38 +00:00
christos c650b5f27f Fix an off-by-one in the F modifier that ended up skipping the first : or =
entry, and add a * specifier for a "default case".
2019-04-27 17:45:28 +00:00
mrg cee1dacaf3 add missing atomic_and_16_nv_cas.c atomic_and_8_nv_cas.c. 2019-04-17 07:40:34 +00:00
mrg 5a9be18c46 add missing aliases for _atomic_cas_32_ni and atomic_cas_uint_ni. 2019-04-17 07:35:38 +00:00
jmcneill 0d57af0fd1 Fix typo: __aebi_memset -> __aeabi_memset 2019-03-30 10:18:03 +00:00
roy 18d2bd2e00 rbtree: Add a define to mark function arguments as unused for non debug
This allows rbtree to be used outside of NetBSD without any compile
warnings and removes the need for the lint comment.
2019-03-08 09:14:54 +00:00
isaki ae06bb460e Fix return value. or_and_fetch should return new value. 2019-03-01 09:57:32 +00:00
isaki 3bbf8c07ee Add missing alias for __atomic_fetch_nand_N.
XXX I'm not sure why does llvm/sparc call __atomic instead of
    __sync though.
XXX atomic_*_cas.c should be more symmetric...
2019-03-01 06:14:52 +00:00
isaki acd53d24e1 Add missing atomic_and_{8,16}_nv_cas.c for __sync_and_and_fetch_{1,2}.
XXX why is not only atomic_and_* symmetric unlike the others?
    (in common/lib/libc/atomic/)
2019-02-28 02:35:37 +00:00
rin 8cef165a13 Export atomic_cas_32_ni in a similar manner to its 64-bit counterpart.
Compile test only, but seems trivial enough for me.

Fix build error due to test/lib/libc/atomic/t_atomic_cas.

Note that mips32 does not use atomic_cas.S.
2019-02-20 05:25:12 +00:00
martin 6899bcaca3 Add atomic_cas_64_ni alias 2019-02-19 18:17:45 +00:00
rin e73f820d2b Sort STRONG_ALIAS's in the same manner as ATOMIC_OP_ALIAS's.
No functional changes.
2019-02-19 12:51:44 +00:00
rin 9121ca69a2 Export _atomic_cas_64 as atomic_cas_64_ni.
Note that _atomic_cas_64 is already exported as atomic_cas_{ulong,prt}_ni.

Fix build error of test/lib/atomic/t_atomic_cas, which is successfully
passed on RPI3B+ now.
2019-02-19 12:47:36 +00:00
martin b79193cac1 Add some atomic_cas_64_ni aliases 2019-02-18 11:22:56 +00:00
isaki ec9c813c13 Add missing export of atomic_or_64 (since rev1.1). 2019-02-17 07:34:44 +00:00
kamil 075cfd7e0e Fix kUBSan build with GCC7
Add missing __unreachable() and FALLTHROUGH keywords.

Reported by <Akul Pillai>
2019-02-13 17:17:02 +00:00
ryo 3f09074d57 - atomic_*_{8,16}_nv() must return a new value, not an old value.
- use "dmb sy" for atomic_*{8,16}_nv() in the same way as atomic_*{32,64}_nv().
2019-02-08 06:56:56 +00:00
ryo 706088913a fix atomic_sub_*(). it was (delta - *ptr), should be (*ptr - delta).
changing shared macro doesn't effect other atomic_ops because
(*ptr [+|^] delta) and (delta [+|^] *ptr) have same result.

atomic_sub_*() haven't used because non standard API?
2019-02-06 05:33:14 +00:00
mrg da4bf28d55 - use __unreachable() and move 'break's around to increase consistency
and correctness

ok kamil@
2019-02-04 22:07:41 +00:00
mrg f5f53dd6ab add support to detect the 3 vmware GPT partition types:
- VMKcore (dump partition)
- VMFS
- VMware reserved

this enables vmkcore partitions for netbsd swap or dump, as well
as naming all of them.
2018-11-06 04:04:33 +00:00
christos 1689d3d9a9 use postincrement, like the patch
XXX: pullup-8
2018-10-15 19:32:48 +00:00
christos 124c823126 Avoid out-of-bounds reads
https://www.openwall.com/lists/musl/2017/06/29/6
XXX: pullup-8
2018-10-15 18:37:19 +00:00
jdolecek bcc384fdef remove M_CANFAIL flag for malloc(9) - it was completely ignored, so had
actually no effect
2018-10-14 17:37:40 +00:00
christos 4496cdcb87 toolify. 2018-08-16 12:03:10 +00:00
christos 143603fad0 Add nbotool stuff. 2018-08-11 16:25:32 +00:00
kamil a36fdb1010 Try to fix the evbppc-powerpc64 build
Avoid "comparison between signed and unsigned integer expressions" on
Big-Endian hosts.
2018-08-03 16:31:04 +00:00
kamil 7adf6ec6dd Register a new directory in common/lib/libc/misc
Registe misc/ with ubsan.c.
2018-08-03 03:35:17 +00:00
kamil aee9a63f2a Tidy up the comment in ubsan.c
As noted, style has no impact on the comparison of a similar code.
This version is a reimplementation from scratch with no code and no
algirithm (whenever possible) reuse.

Public symbols and struct layout must be kept in sync with the code
generation part. It casues violation of the style like with long filenames.

My previous comment was 'too perfect' and could trigger some unnecessary
attention.
2018-08-03 03:12:32 +00:00
kamil 9aff107674 Import micro-UBSan (ubsan.c)
This is a reimplementation of the Undefined Behavior Sanitizer with the
following properties:
 - pure and clean-room C implementation,
 - no -fsanitize=vpts support, as it requires RTTI support and C++
   low-level routies to validate whether C++ objects are compatible
 - designed to be used inside libc and known as uUBSan or user-UBSan
 - designed to be shared with kernel and known as kUBSan or kernel-UBSan
 - designed to be usable with ATF tests as a standalone runtime,
   reachable without any MK* switches
 - designed to be safer for hardening as it does not have side effects on
   executables like writing to a selected location on demand
 - controllable with environment variable LIBC_UBSAN with options:
   * a - abort on report
   * A - do not abort on a report (unless a failure is unrecoverable)
   * e - output report to stderr
   * E - do not output report on stderr
   * l - output report on syslog (LOG_DEBUG | LOG_USER)
   * L - do not output report on syslog
   * o - output report on stdout
   * O - do not output report on stdout
   The default options are: "AeLO".
 - compatible with Clang (3.8, 7.x) and GCC (6.x) code generation
 - all handlers (except =vptr) from Clang/LLVM up to 7svn are supported

Tested with Clang amd64+i386 and GCC amd64+i386.
2018-08-03 02:05:43 +00:00
ryo 82b677e373 strnlen(s, (size_t)-1) returned -1. it must return the length of s. 2018-08-01 17:09:26 +00:00
kamil 38a0dc974f Avoid undefined behavior in snprintb.c
Do not change the signedness bit with a left shift operation.
Switch to unsigned integer to prevent this.

snprintb.c:178:17, left shift of 1 by 31 places cannot be represented in type 'int'

Detected with micro-UBSan in the user mode.
2018-07-26 00:33:26 +00:00
kamil 4fb9e183e5 Avoid undefined behavior in an inet_addr.c
Do not change the signedness bit with a left shift operation.
Cast to unsigned integer to prevent this.

inet_addr.c:218:20, left shift of 131 by 24 places cannot be represented in type 'int'

Detected with micro-UBSan in the user mode.
2018-07-26 00:20:41 +00:00
kamil 4581cca75c Avoid undefined behavior in an cpuset.c
Do not change the signedness bit with a left shift operation.
Switch to unsigned integer to prevent this.

cpuset.c:112:18, left shift of 1 by 31 places cannot be represented in type 'int'

Detected with micro-UBSan in the user mode.
2018-07-26 00:13:19 +00:00
bouyer efd0e73e34 On Xen, always alias _atomic_cas_64 to _atomic_cas_cx8. AFAIK Xen doesn't
support CPUs that don't support cx8.
i386 XENPAE_DOMU boots again.
2018-07-18 13:39:36 +00:00
ryo 6c83813761 avoid reading from out of range that may cause access fault. 2018-07-09 06:07:06 +00:00
christos 3aee54a15e switch to FreeBSD's memmem (faster) 2018-07-08 17:53:12 +00:00
martin 23e81d3280 Complete previous by complteley removing the _DIAGASSERT from memmove -
the accidental left over from previous fired on all legitimate calls
and caused PR bin/52986 and PR lib/52987.
2018-02-12 11:14:15 +00:00
mrg 240c43e6ba - remove two more _DIAGASSERT() checks against not NULL for functions
with arguments with nonnull attributes.  in two cases, leave
  code behind that should set defaults to "(null)".
2018-02-06 09:28:48 +00:00
skrll b07568df9e Working / new versions from Ryo Shimizu 2018-02-04 21:52:16 +00:00
mrg 51502cf62d updates for GCC 6.4:
- remove many _DIAGASSERT() checks against not NULL for functions
  with arguments with nonnull attributes.  (probably more to come,
  the set between x86 and sparc us disjoint.)

- port libsanitizer's GetPcSpBp() to sparc, sparc64 and amd64.
2018-02-04 20:22:17 +00:00
mrg 8fdd01b3ee fixes for GCC 6:
- -Wstrict-prototypes is not available for C++, so don't try to
  ignore it for C++.
- remove many _DIAGASSERT() checks against not NULL for functions
  with arguments with nonnull attributes.  in two cases, leave
  code behind that should set defaults to "(null)".
- use -Wno-error=frame-address for i386 mcount, as it seems valid
  to assume the caller will have a frame.fair
2018-02-04 01:13:45 +00:00
kamil c5b83981a9 Add bunch of missing includes of namespace.h in libc
The NetBSD Standard C Library uses internally some of its functions with
a mangled symbol name, usually "_symbol". The internal functions shall not
use the global (public) symbols.

This change eliminates usage of the global changes of the following symbols:
 - strlcat -> _strlcat
 - sysconf -> __sysconf
 - closedir -> _closedir
 - fparseln -> _fparseln
 - kill -> _kill
 - mkstemp -> _mkstemp
 - reallocarr -> _reallocarr
 - strcasecmp -> _strcasecmp
 - strncasecmp -> _strncasecmp
 - strptime -> _strptime
 - strtok_r -> _strtok_r
 - sysctl -> _sysctl
 - dlopen -> __dlopen
 - dlclose -> __dlclose
 - dlsym -> __dlsym

Sponsored by <The NetBSD Foundation>
2018-01-04 20:57:28 +00:00
riastradh 969998948d Import SHA-3 code into libc and libkern.
No new public symbols in libc, but publishing the symbols is a simple
matter if/when we decide to do so.

Proposed on tech-kern and tech-userlevel with no objections:

https://mail-index.NetBSD.org/tech-kern/2017/11/11/msg022581.html
https://mail-index.NetBSD.org/tech-userlevel/2017/11/11/msg010968.html
2017-11-30 05:47:24 +00:00
tsutsui 6dd94d2a84 Restore a local change (in rev1.4) that was lost on zlib 1.12.10 merge.
The rev 1.4 changelog:
> Disable a sanity check output buffer != NULL in _STANDALONE case.
> Some kernels are loaded at address 0x0 by bootloaders and
> output buffer address could be zero in such case.
>
> Fixes "read text" errors on loading install floppy of NetBSD/news68k 4.0,
> reported by KIYOHARA Takashi on port-news68k.

This problem may also affect other m68k ports which use a gzipped install
kernel and kernel text address located at PA 0x0.

Should be pulled up to netbsd-8.
2017-11-12 07:55:05 +00:00
wiz aa4b308c77 Simplify, and comment out xrefs to non-existing pages. 2017-10-23 00:59:44 +00:00
abhinav bc341be216 Remove comma after last Nm entry in the NAME section 2017-10-22 15:34:13 +00:00