Commit Graph

8684 Commits

Author SHA1 Message Date
Dimitry Andric
43c7dd6b59 Merge ^/head r358075 through r358130. 2020-02-19 21:03:06 +00:00
Baptiste Daroussin
e18651243e Update to 6.2-20200215
While I didn't plan another upgrade, This version incorporate fixes from
kevans@ so let's upgrade to it
2020-02-19 17:09:08 +00:00
Dimitry Andric
abaad9d77d Merge ^/head r358049 through r358074. 2020-02-18 17:59:37 +00:00
Cy Schubert
9658b6b3f4 As with ipf(8), give ippool(8) the ability to load IP pools from multiple
files. This allows for loading, during the same invocation of ippool, of
multiple sources of input using multiple tools to concurrently maintain the
files such as fail2ban, macro preprocessors, and manually.

MFC after:	1 week
2020-02-18 11:26:49 +00:00
Baptiste Daroussin
aae38d10b4 Update ncurses to 20200118
Among the changes from before:
- Add support for extended colors on widechar version
- Enable ncurses extended functions
- Enable version 2 of the extended mouse support
- Enable SCREEN extensions

Modification that differs from upstream:
- _nc_delink_entries used to be exposed and was turn static,
  turn it back as dynamic to not break abi
- Adapt our old termcap.c to modern ncurses

MFC after:	3 weeks
2020-02-18 08:11:52 +00:00
Dimitry Andric
3c4ad300a1 Merge ^/head r358000 through r358048. 2020-02-17 20:27:05 +00:00
Li-Wen Hsu
80986ae0c1 Really skip the tests in capsicum tests
Sponsored by:	The FreeBSD Foundation
2020-02-17 20:25:33 +00:00
Li-Wen Hsu
30fd7f5487 Temporarily skip flakey test in sys.capsicum.capsicum-test.main:
PipePdfork.WildcardWait

PR:		244165
Sponsored by:	The FreeBSD Foundation
2020-02-16 14:33:55 +00:00
Dimitry Andric
46bc58a0ff Merge commit 62654cab7 from llvm git (by me):
Restore functionality of --sysroot on FreeBSD after b18cb9c47

  After b18cb9c47, clang would sometimes prefer the host C++ includes
  (e.g. in /usr/include/c++/v1) before those specified via --sysroot.
  While this behavior may be desirable on Linux, it is not so on
  FreeBSD, where we make extensive use of --sysroot during the build of
  the base system.  In that case, clang must *not* search outside the
  sysroot, except for its own internal headers.

  Add an override addLibCxxIncludePaths() to restore the old behavior,
  which is to simply append /usr/include/c++/v1 to the specified
  sysroot.  While here, apply clang-format to the FreeBSD specific
  toolchain files.

  Fixes PR44923.
2020-02-16 13:22:36 +00:00
Dimitry Andric
473b61d31e Merge commit 221c5af4e from llvm git (by Nico Weber):
Fix a -Wbitwise-conditional-parentheses warning in
  _LIBUNWIND_ARM_EHABI libunwind builds

  ```
  src/UnwindCursor.hpp:1344:51: error: operator '?:' has lower precedence than '|'; '|' will be evaluated first [-Werror,-Wbitwise-conditional-parentheses]
    _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0;  // Use enum?
					~~~~~~~~~~~ ^
  src/UnwindCursor.hpp:1344:51: note: place parentheses around the '|' expression to silence this warning
    _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0;  // Use enum?
						    ^
					(          )
  src/UnwindCursor.hpp:1344:51: note: place parentheses around the '?:' expression to evaluate it first
    _info.flags = isSingleWordEHT ? 1 : 0 | scope32 ? 0x2 : 0;  // Use enum?
						    ^
					    (                )
  ```

  But `0 |` is a no-op for either of those two interpretations, so I
  think what was meant here was

  ```
    _info.flags = (isSingleWordEHT ? 1 : 0) | (scope32 ? 0x2 : 0);  // Use enum?
  ```

  Previously, if `isSingleWordEHT` was set, bit 2 would never be set.
  Now it is. From what I can tell, the only thing that checks these
  bitmask is ProcessDescriptors in Unwind-EHABI.cpp, and that only
  cares about bit 1, so in practice this shouldn't have much of an
  effect.

  Differential Revision: https://reviews.llvm.org/D73890

This fixes the above errors when building libunwind for arm variants.
2020-02-15 15:03:26 +00:00
Dimitry Andric
13138422bc Merge ^/vendor/llvm-project/release-10.x up to its last change (upstream
commit llvmorg-10.0.0-rc2-0-g90c78073f73), bump versions, and update
build glue.
2020-02-15 14:58:40 +00:00
Dimitry Andric
74dc6beb30 Merge ^/head r357855 through r357920. 2020-02-14 19:32:58 +00:00
Kyle Evans
d8b7b73571 ncurses: correct check for gcc >= 5.0
The hack in question is intended to workaround seemingly bogus #line markers
in cpp output. As far as I can tell, llvm cpp doesn't do this by default, so
there's no reason to add -P.

In our /bin/sh, the main incantation should be placed in a sub-shell in
order to properly pipe the output to fgrep.

The main motivation for this change is admittedly to stop emitting the noise
about clang not being gcc in make -s buildworld

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D22952
2020-02-14 04:16:22 +00:00
Ed Maste
fe91dd0138 addr2line: use stdbool.h header for bool
Presumably a bool definition is obtained via header contamination on
FreeBSD-CURRENT.  Found while trying to upstream FreeBSD addr2line
changes - the FreeBSD 11.2 CI build failed there.

Reported by:	Cirrus-CI, upstream ELF Tool Chain
MFC with:	r357844
Sponsored by:	The FreeBSD Foundation
2020-02-13 16:17:05 +00:00
Dimitry Andric
44e86fbdcf Merge ^/head r357662 through r357854. 2020-02-13 12:52:24 +00:00
Ed Maste
6c4a4f1bc2 addr2line: Handle DW_AT_ranges in compile units
Based on original submission by Marat Radchenko in ELF Tool Chain
ticket #545, rebased and updated by Tiger Gao.

PR:		217736
Submitted by:	Marat Radchenko <marat@slonopotamus.org>
Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23501
2020-02-12 21:52:10 +00:00
Ed Maste
57d7e4cc2c elfcopy: set ELF OS/ABI field when converting from binary
PR:		228934
Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
Reviewed by:	markj, jkoshy
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23504
2020-02-12 15:59:59 +00:00
Martin Matuska
f976241773 MFV r357783:
Update libarchive to 3.4.2

Relevant vendor changes:
  PR #1289: atomic extraction support (bsdtar -x --safe-writes)
  PR #1308: big endian fix for UTF16 support in LHA reader
  PR #1326: reject RAR5 files that declare invalid header flags
  Issue #987: fix support 7z archive entries with Delta filter
  Issue #1317: fix compression output buffer handling in XAR writer
  Issue #1319: fix uname or gname longer than 32 characters in pax writer
  Issue #1325: fix use after free when archiving hardlinks in ISO9660 or XAR
  Use localtime_r() and gmtime_r() instead of localtime() and gmtime()

X-MFC-With:	r356212,r356365,r356416
MFC after:	1 week
2020-02-12 00:16:56 +00:00
Martin Matuska
8185c4ae24 Update vendor/libarchive/dist to git 3288ebb0353beb51dfb09d444dedbe9235ead53d
Libarchive 3.4.2

Relevant vendor changes:
  PR #1289: atomic extraction support (bsdtar -x --safe-writes)
  PR #1308: big endian fix for UTF16 support in LHA reader
  PR #1326: reject RAR5 files that declare invalid header flags
  Issue #987: fix support 7z archive entries with Delta filter
  Issue #1317: fix compression output buffer handling in XAR writer
  Issue #1319: fix uname or gname longer than 32 characters in pax writer
  Issue #1325: fix use after free when archiving hardlinks in ISO9660 or XAR
  Use localtime_r() and gmtime_r() instead of localtime() and gmtime()
2020-02-11 23:48:03 +00:00
Xin LI
d38c30c092 MFV r357712: file 5.38.
MFC after:	2 weeks
2020-02-11 07:02:48 +00:00
Kyle Evans
850e0825a2 MFV r357687: Import NFS fix for O_SEARCH tests
The version that ended upstream was ultimately slightly different than the
version committed here; notably, statvfs() is used but it's redefined
appropriately to statfs() on FreeBSD since we don't provide the fstypename
for the former interface.
2020-02-09 04:05:30 +00:00
Kyle Evans
14d3b06919 O_SEARCH test: mark revokex an expected fail on NFS
The revokex test does not work when the scratch directory is created on NFS.
Given the nature of NFS, it likely can never work without looking like a
security hole since O_SEARCH would rely on the server knowing that the
directory did have +x at the time of open and that it's OK for it to have
been revoked based on POSIX specification for O_SEARCH.

This does mean that O_SEARCH is only partially functional on NFS in general,
but I suspect the execute bit getting revoked in the process is likely not
common.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D23573
2020-02-07 22:36:37 +00:00
Dimitry Andric
bc02c18c48 Merge ^/head r357408 through r357661. 2020-02-07 19:08:37 +00:00
Kyle Evans
7295d1dda1 MFV r357635: imnport v1.9 of the O_SEARCH tests
The RCSID data was wrong, so this is effectively a record-only merge
with correction of said data. No further changes should be needed in this
area, as we've now upstreamed our local changes to this specific test.
2020-02-06 18:51:36 +00:00
Xin LI
f99e4a2d11 MFV r357608: Limit memory usage in xz(1) instead of in tuklib.
Apply upstream 353970510895f6a80adfe60cf71b70a95adfa8bc to limit memory
usage on 32-bit binary to 4020 MiB.

Submitted by:	Lasse Collin <lasse.collin at tukaani.org>
Reviewed by:	kib, bcr
Differential Revision:	https://reviews.freebsd.org/D23474
2020-02-06 07:47:28 +00:00
Kyle Evans
28e68bc000 O_SEARCH test: drop O_SEARCH|O_RDWR local diff
In FreeBSD's O_SEARCH implementation, O_SEARCH in conjunction with O_RDWR or
O_WRONLY is explicitly rejected. In this case, O_RDWR was not necessary
anyways as the file will get created with or without it.

This was submitted upstream as misc/54940 and committed in rev 1.8 of the
file.
2020-02-05 17:21:36 +00:00
Kyle Evans
56cc8b7595 O_SEARCH tests: plug trivial fd leak
Coverity correctly reports this as a resource leak. It's an admittedly minor
one, but plug it anyways.

This has been submitted upstream as misc/54939.

CID:		978288
2020-02-05 02:30:46 +00:00
Mark Johnston
85642eee46 readelf: Don't leak memory when dwarf_get_fde_info_for_all_regs() fails.
CID:		1292493
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:18:56 +00:00
Mark Johnston
37fa1df2d1 readelf: Fix the check for an error from realloc().
Use err() instead of errx() while here, since realloc() sets errno.

CID:		1401326
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:18:37 +00:00
Mark Johnston
dfa169049b readelf: Fix a double close of the input file.
The caller of dump_object() is responsible for opening the file, let it
be responsible for closing too.

CID:		1411588
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:18:16 +00:00
Mark Johnston
b7fc41b3ca size: Avoid returning a stack pointer from xlatetom().
The callers only check whether the returned pointer is non-NULL, so this
was harmless in practice, but change the return value to guard against
the issue.

CID:		1411597
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:17:59 +00:00
Mark Johnston
640ff6ed84 elfcopy: Avoid leaking dst's fd when we fail to copy a file.
We should really create the output file in the same directory as the
destination file so that rename() works.  This will be done in a future
change as part of some work to run in capability mode.

CID:		1262523
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:16:56 +00:00
Mark Johnston
f2530c80db elfcopy: Handle multiple data descriptors properly.
The code clearly meant to resize the buffer in the case where a section
was backed by multiple data descriptors.

In practice this shouldn't have been a problem since libelf would return
a single data descriptor for each section in a newly opened file.

CID:		1262522
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:16:41 +00:00
Mark Johnston
334f09a65b libelftc: Add a missing check for an error from vector_str_init().
While here consistently use the same spelling for such checks.

CID:		1376769
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:16:16 +00:00
Mark Johnston
a3c35da61b libelftc: Fix memory leaks in the C++ demanglers.
CID:		1262518, 1262519, 1262520, 1262529
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:15:52 +00:00
Mark Johnston
ab3b51df28 libdwarf: Fix a memory leak in _dwarf_frame_section_init().
If frame length validation failed we would leak memory.

CID:		1193366
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:15:29 +00:00
Mark Johnston
513e76aaf8 libdwarf: Make an out-pointer of _dwarf_abbrev_add() mandatory.
All callers pass a non-NULL pointer, and otherwise it was possible to
leak memory if the abbrev was not added to a CU.

CID:		1193365
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:15:11 +00:00
Mark Johnston
e5551befe8 libdwarf: Fix a possible memory leak in dwarf_add_AT_location_expr().
CID:		1193364
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:14:53 +00:00
Mark Johnston
75bd29add2 libdwarf: Remove unnecessary NULL checks.
All callers of _dwarf_add_expr() and _dwarf_expr_into_block() pass a
non-NULL expr pointer, and these functions assume that expr is non-NULL
anyway.

CID:		1193305, 1193306
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:14:34 +00:00
Cy Schubert
c998f2d39d Revert r357201: downgrade sqlite3 from sqlite3-3.31.0 (3310000) to
sqlite3-3.30.1 (3300100), as it causes svnlite segfaults on PowerPC,
resulting in corruption.

Reported by:	Mark Millard <marklmi at yahoo.com>
		Francis Little <oggy at farscape.co.uk>
2020-02-04 19:45:51 +00:00
Mark Johnston
35beedae40 addr2line: Avoid a name collision.
The RB_ macros define functions with a parameter named head, and gcc
warns about this.

MFC with:	r357450
2020-02-03 19:08:35 +00:00
Mark Johnston
af84329100 addr2line: Cache CU DIEs upon a successful address lookup.
Previously, addr2line would sequentially search all CUs for each input
address.  For some uses, notably syzkaller's code coverage map generator,
this was extremely slow.  Add a CU cache into which entries are added
following a successful lookup, and search the cache before falling back
to a scan.  When translating a large number of addresses this yields
slightly better performance than GNU addr2line.

Garbage-collect an unused hash table which appears to have been intended
for the same purpose.  A hash table doesn't seem particularly suitable
since each CU spans a range of addresses.

Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23418
2020-02-03 16:41:40 +00:00
Kyle Evans
6a5abb1ee5 Provide O_SEARCH
O_SEARCH is defined by POSIX [0] to open a directory for searching, skipping
permissions checks on the directory itself after the initial open(). This is
close to the semantics we've historically applied for O_EXEC on a directory,
which is UB according to POSIX. Conveniently, O_SEARCH on a file is also
explicitly undefined behavior according to POSIX, so O_EXEC would be a fine
choice. The spec goes on to state that O_SEARCH and O_EXEC need not be
distinct values, but they're not defined to be the same value.

This was pointed out as an incompatibility with other systems that had made
its way into libarchive, which had assumed that O_EXEC was an alias for
O_SEARCH.

This defines compatibility O_SEARCH/FSEARCH (equivalent to O_EXEC and FEXEC
respectively) and expands our UB for O_EXEC on a directory. O_EXEC on a
directory is checked in vn_open_vnode already, so for completeness we add a
NOEXECCHECK when O_SEARCH has been specified on the top-level fd and do not
re-check that when descending in namei.

[0] https://pubs.opengroup.org/onlinepubs/9699919799/

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D23247
2020-02-02 16:34:57 +00:00
Dimitry Andric
59abbffacd Merge ^/head r357270 through r357349. 2020-01-31 19:40:40 +00:00
Ed Maste
43e8403953 retire BSD_CRTBEGIN option
BSD crt is currently used on all architectures (other than sparc64).
Remove the option and use BSD crt everywhere as part of the GCC 4.2.1
retirement plan.

https://lists.freebsd.org/pipermail/freebsd-arch/2020-January/019823.html

PR:		239851
Reviewed by:	andrew, brooks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23122
2020-01-31 18:04:04 +00:00
Conrad Meyer
53345534c8 contrib/apr: Rip out bogus [CS]PRNG implementation
This construction used some relatively slow design involving SHA2; even if
it were fed real entropy (unclear; external to the design), it did not
handle fork in a safe way, and it was difficult to audit for correctness.
So just rip it out and use the very simple and known-correct arc4random(3)
interface in its place.
2020-01-30 18:12:41 +00:00
Conrad Meyer
e3907d2395 contrib/apr: Remove scope leak UB
In apr_vformatter, the variable buf was declared inside a limited scope
region, but a pointer to it is leaked outside of that region and used
later.  This is undefined behavior.  Fix by moving the buf variable to
function scope.

Reported by:	Coverity
CID:		1192541
2020-01-30 17:50:51 +00:00
Dimitry Andric
bb1d0df511 Merge ^/head r357179 through r357269. 2020-01-29 21:09:36 +00:00
Dimitry Andric
b9f5806c25 Revert upstream lld r371957 (git commit 06bb7dfbd) by Fangrui Song:
[ELF] Map the ELF header at imageBase

  If there is no readonly section, we map:

  * The ELF header at imageBase+maxPageSize
  * Program headers at imageBase+maxPageSize+sizeof(Ehdr)
  * The first section .text at imageBase+maxPageSize+sizeof(Ehdr)+sizeof(program headers)

  Due to the interaction between Writer<ELFT>::fixSectionAlignments and
  LinkerScript::allocateHeaders,
  `alignDown(p_vaddr(R PT_LOAD)) = alignDown(p_vaddr(RX PT_LOAD))`.
  The RX PT_LOAD will override the R PT_LOAD at runtime, which is not ideal:

  ```
  // PHDR at 0x401034, should be 0x400034
    PHDR           0x000034 0x00401034 0x00401034 0x000a0 0x000a0 R   0x4
  // R PT_LOAD contains just Ehdr and program headers.
  // At 0x401000, should be 0x400000
    LOAD           0x000000 0x00401000 0x00401000 0x000d4 0x000d4 R   0x1000
    LOAD           0x0000d4 0x004010d4 0x004010d4 0x00001 0x00001 R E 0x1000
  ```

  * createPhdrs allocates the headers to the R PT_LOAD.
  * fixSectionAlignments assigns `imageBase+maxPageSize+sizeof(Ehdr)+sizeof(program headers)` (formula: `alignTo(dot, maxPageSize) + dot % config->maxPageSize`) to addrExpr of .text
  * allocateHeaders computes the minimum address among SHF_ALLOC sections, i.e. addr(.text)
  * allocateHeaders sets address of ELF header to `addr(.text)-sizeof(Ehdr)-sizeof(program headers) = imageBase+maxPageSize`

  The main observation is that when the SECTIONS command is not used, we
  don't have to call allocateHeaders. This requires an assumption that
  the presence of PT_PHDR and addresses of headers can be decided
  regardless of address information.

  This may seem natural because dot is not manipulated by a linker script.
  The other thing is that we have to drop the special rule for -T<section>
  in `getInitialDot`. If -Ttext is smaller than the image base, the headers
  will not be allocated with the old behavior (allocateHeaders is called)
  but always allocated with the new behavior.

  The behavior change is not a problem. Whether and where headers are
  allocated can vary among linkers, or ld.bfd across different versions
  (--enable-separate-code or not). It is thus advised to use a linker
  script with the PHDRS command to have a consistent behavior across
  linkers. If PT_PHDR is needed, an explicit --image-base can be a simpler
  alternative.

  Differential Revision: https://reviews.llvm.org/D67325

  llvm-svn: 371957

This causes "ld: error: output file too large: 18446744073707016908
bytes" when linking our loader_4th and loader_lua.  Clearly, something
is wrong when using -Ttext 0x0: I will file an upstream bug report for
this.
2020-01-29 16:57:55 +00:00
Dimitry Andric
8841e3fb92 Merge r357224 from the clang1000-import branch:
Fix the following -Werror warning from clang 10.0.0 in binutils:

contrib/binutils/bfd/peicode.h:1356:3: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                if (efi)
                ^
contrib/binutils/bfd/peicode.h:1353:8: note: previous statement is here
              if (pe_arch (bfd_target_efi_arch (*target_ptr)) != arch)
              ^
contrib/binutils/bfd/peicode.h:1370:3: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                if (!efi)
                ^
contrib/binutils/bfd/peicode.h:1367:8: note: previous statement is here
              if (pe_arch (bfd_target_pei_arch (*target_ptr)) != arch)
              ^

MFC after:	3 days
2020-01-28 20:11:27 +00:00