Commit Graph

21628 Commits

Author SHA1 Message Date
Emmanuel Vadot
c7fd29f0f2 pkgbase: Create a FreeBSD-telnet package
both telnet and telnetd aren't that useful nowadays but some
might want them.
Create a FreeBSD-telnet package so users have a choice to have
them or not.

Differential Revision:	https://reviews.freebsd.org/D31791
Reviewed by: emaste
2021-09-07 10:18:11 +02:00
Dimitry Andric
efe67f33c3 compiler-rt: add aarch64 init function for LSE atomics
As reported by Ronald, adding the out-of-line LSE atomics helpers for
aarch64 to compiler-rt was not sufficient to link programs using these,
as they also require a __aarch64_have_lse_atomics global. This is
initialized in compiler-rt's lib/builtins/cpu_model.c, roughly similar
to the x86 CPU model and feature detection in that file.

Since upstream does not yet have a FreeBSD specific implementation for
getting the required information, add a simple one that should work for
now, while I try to get it sorted with the LLVM people.

Reported by:	Ronald Klop <ronald-lists@klop.ws>
Fixes:		cc55ee8009
PR:		257392
MFC after:	2 weeks
2021-09-06 21:24:01 +02:00
Mark Murray
292815eac6 Fix powf().
Summary:
From Steve Kargl:

Paul Zimmermann has identified a bug in Openlibm's powf(),
which is identical to FreeBSD's libm.  Both derived from
fdlibm. https://github.com/JuliaMath/openlibm/issues/212.

Consider

% cat h.c
int
main(void)
{
  float x, y, z;
  x =  0x1.ffffecp-1F;
  y = -0x1.000002p+27F;
  z =  0x1.557a86p115F;
  printf("%e %e %e <-- should be %e\n", x, y, powf(x,y), z);
  return 0;
}

% cc -o h -fno-builtin h.c -lm && ./h
9.999994e-01 -1.342177e+08 inf <-- should be 5.540807e+34

Reviewers: manu

Subscribers: imp, andrew, emaste

Differential Revision: https://reviews.freebsd.org/D31865
2021-09-06 18:51:31 +01:00
Alex Richardson
021385aba5 Add WITH_LLVM_BINUTILS to install LLVM binutils instead of Elftoolchain
When WITH_LLVM_BINUTILS is set, we will install the LLVM binutils as
ar/ranlib/nm/objcopy/etc. instead of the elftoolchain ones.
Having the LLVM binutils instead of the elftoolchain ones allows us to use
features such as LTO that depend on binutils that understand LLVM IR.
Another benefit will be an improved user-experience when compiling with
AddressSanitizer, since ASAN does not symbolize backtraces correctly if
addr2line is elftoolchain addr2line instead of llvm-symbolizer.
See https://lists.freebsd.org/archives/freebsd-toolchain/2021-July/000062.html
for more details.

This is currently off by default but will be turned on by default at some
point in the near future.

Reviewed By:	emaste

Differential Revision: https://reviews.freebsd.org/D31060
2021-09-06 09:49:49 +01:00
Brooks Davis
e51b29b5a9 mprotect.2: Remove legacy BSD text
This text dates to the BSD 4.4 import and is misleading.  The mprotect
syscall acts on page granularity and breaks up mappings as required to
do so.

Note that with the addition of non-transparent superpages (aka
largepages) the size of a page at a given address may vary.  This
commit does not attempt to address the lack of documentation of this
feature.

Sponsored by:	DARPA

Reviewed by:	alc, mckusick, imp, kib, markj
Differential Revision:	https://reviews.freebsd.org/D31776
2021-09-03 19:30:23 +01:00
Bryan Drewery
8f8a794775 getdelim(3): Fix losing data on [EAGAIN]
Currently when an [EAGAIN] is encountered we return a partial result
that does not contain the delimeter.  On the next (successful) read we
were returning the next part of the line without the preceding string
from the first failed call.

Fix this by using the same mechanism as ungetc(3) does.  For the buffered
case we could simply set fp->_r and fp->_p back to their values before
sappend() is ran but for simplicity ungetc(3) is done in there as well.

Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D31687
2021-09-02 11:26:26 -07:00
Ka Ho Ng
9bb8304c10 Symbol.map: Remove an extra space before _Fork
Make it consistent with all other entries.

Sponsored by:	The FreeBSD Foundation
2021-09-02 21:10:22 +08:00
Andrew Turner
a947203221 Revert "Disable the accelerated arm64 sha25 in static libraries"
This is now unneeded as arm64 can now resolve ifuncs in static binaries

This reverts commit c81ea895b5.

Sponsored by:	The FreeBSD Foundation
2021-08-30 10:36:43 +01:00
Kristof Provost
46fb68b1de libpfctl: Implement DIOCGETSTATUS wrappers
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D31696
2021-08-29 14:59:38 +02:00
Kristof Provost
b0ccc2e277 libpfctl: fix double free
Reviewed by:	donner
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D31695
2021-08-29 14:59:29 +02:00
Dimitry Andric
4e5d32a445 Fix null pointer subtraction in mergesort()
Clang 13 produces the following warning for this function:

lib/libc/stdlib/merge.c:137:41: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
        if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
                                               ^ ~~~~~~~~~

This is meant to check whether the size and base parameters are aligned
to the size of an int, so use our __is_aligned() macro instead.

Also remove the comment that indicated this "stupid subtraction" was
done to pacify some ancient and unknown Cray compiler, and which has
been there since the BSD 4.4 Lite Lib Sources were imported.

MFC after:	3 days
2021-08-27 19:46:18 +02:00
Gleb Popov
c468923b22 libc/posix1e: Add acl_extended_file_np() function.
Reviewed by: kib, debdrup, gbe
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D28255
2021-08-27 11:52:26 +03:00
Gleb Popov
d81d5b2f2c libc/posix1e: Add acl_equiv_mode_np() function.
Reviewed by: kib, debdrup, gbe
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D28255
2021-08-27 11:52:15 +03:00
Gleb Popov
937f807a36 libc/posix1e: Add acl_cmp_np() function.
Reviewed by: kib, debdrup, gbe
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D28255
2021-08-27 11:52:08 +03:00
Gleb Popov
19f7f91133 libc/posix1e: Add acl_from_mode_np() function.
Reviewed by: kib, debdrup, gbe
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D28255
2021-08-27 11:49:19 +03:00
Dimitry Andric
d396c67f26 googletest: Silence warnings about deprecated implicit copy constructors
Our copy of googletest is rather stale, and causes a number of -Werror
warnings about implicit copy constructor definitions being deprecated,
because several classes have user-declared copy assignment operators.
Silence the warnings until we either upgrade or remove googletest.

MFC after:	3 days
2021-08-26 22:06:53 +02:00
Dimitry Andric
f643997a17 Cleanup compiler warning flags in lib/libefivar/Makefile
There is no need to set -Wno-unused-parameter twice, and instead of
appending to CFLAGS, append to CWARNFLAGS instead. While here, add
-Wno-unused-but-set-variable for the sake of clang 13.0.0.

MFC after:	3 days
2021-08-26 20:53:26 +02:00
Ka Ho Ng
9e202d036d fspacectl(2): Changes on rmsr.r_offset's minimum value returned
rmsr.r_offset now is set to rqsr.r_offset plus the number of bytes
zeroed before hitting the end-of-file. After this change rmsr.r_offset
no longer contains the EOF when the requested operation range is
completely beyond the end-of-file. Instead in such case rmsr.r_offset is
equal to rqsr.r_offset.  Callers can obtain the number of bytes zeroed
by subtracting rqsr.r_offset from rmsr.r_offset.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D31677
2021-08-26 00:03:37 +08:00
Gordon Tetlow
64ae2f785e Fix libfetch out of bounds read.
Approved by:	so
Security:	SA-21:15.libfetch
Security:	CVE-2021-36159
2021-08-24 11:26:45 -07:00
Jessica Clarke
c1f7d8dd23 clang: Build with -fno-strict-aliasing when using GCC
Somewhat ironically, there are strict aliasing violations in Clang,
which can result in the following assertion failure:

  Assertion `*(NamedDecl **)&Data == ND && "PointerUnion mangles the NamedDecl pointer!"' failed.

Upstream's clang/CMakeLists.txt specifically (not LLVM as a whole)
passes -fno-strict-aliasing if the compiler is not Clang, and this fixes
the above issue.

This was seen when cross-building from Linux using a bootstrap
compiler, but likely also affects worlds built with a new enough
external GCC toolchain.

MFC after:	1 week
Reviewed by:	dim
Differential Revision:	https://reviews.freebsd.org/D31533
2021-08-24 15:04:25 +01:00
Ed Maste
37296464de memcpy.3: remove BUGS section allowing overlapping strings
The removed text claimed that memcpy is implemented using bcopy and thus
strings may overlap.  Use of bcopy is an implementation detail that is
no longer true, even if the implementation (on some archs) does allow
overlap.

In any case behaviour is undefined per the C standard if memcpy is
called with overlapping objects, and this man page already claimed that
src and dst may not overlap.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31192
2021-08-24 09:58:10 -04:00
Ka Ho Ng
1eaa36523c fspacectl(2): Clarifies the return values
rmacklem@ spotted two things in the system call:
- Upon returning from a successful operation, vop_stddeallocate can
  update rmsr.r_offset to a value greater than file size. This behavior,
  although being harmless, can be confusing.
- The EINVAL return value for rqsr.r_offset + rqsr.r_len > OFF_MAX is
  undocumented.

This commit has the following changes:
- vop_stddeallocate and shm_deallocate to bound the the affected area
  further by the file size.
- The EINVAL case for rqsr.r_offset + rqsr.r_len > OFF_MAX is
  documented.
- The fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9)'s return
  len is explicitly documented the be the value 0, and the return offset
  is restricted to be the smallest of off + len and current file size
  suggested by kib@. This semantic allows callers to interact better
  with potential file size growth after the call.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D31604
2021-08-24 17:08:28 +08:00
Andrew Turner
bc5304a006 Add arm64 ifunc support in static binaries
Add support for the R_AARCH64_IRELATIVE relocation type in static
binaries on arm64. This is based on the powerpc code, updating it to
use the arm64 resolver ABI, and use the arm64 relocation type.

Tested by:	brd
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31641
2021-08-23 13:39:09 +00:00
Martin Matuska
ddce862ad8 libarchive: import changes from upstream
Libarchive 3.5.2

New features:
  PR #1502: Support for PWB and v7 binary cpio formats
  PR #1509: Support of deflate algorithm in symbolic link decompression
            for ZIP archives

Important bugfixes:
  IS #1044: fix extraction of hardlinks to symlinks
  PR #1480: Fix truncation of size values during 7zip archive
            extraction on 32bit architectures
  PR #1504: fix rar header skiming
  PR #1514: ZIP excessive disk read - fix location of central directory
  PR #1520: fix double-free in CAB reader
  PR #1521: Fixed leak of rar before ending with error
  PR #1530: Handle short writes from archive_write_callback
  PR #1532: 7zip: Use compression settings from file also for file header
  IS #1566: do not follow symlinks when processing the fixup list

MFC after:	2 weeks
Relnotes:	yes
2021-08-23 03:07:36 +02:00
Thomas Munro
3904e7966e Fix aio_readv(2), aio_writev(2) with SIGEV_THREAD.
Add missing wrapper code to librt for these new functions so that
SIGEV_THREAD works.  Without machinery to convert it to SIGEV_THREAD_ID,
you got EINVAL.

Reviewed by:    asomers
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D31618
2021-08-22 23:49:23 +12:00
Thomas Munro
f30a1ae8d5 lio_listio(2): Allow LIO_READV and LIO_WRITEV.
Allow multiple vector IOs to be started with one system call.
aio_readv() and aio_writev() already used these opcodes under the
covers.  This commit makes them available to user space.

Being non-standard extensions, they're only visible if __BSD_VISIBLE is
defined, like the functions.

Reviewed by:    asomers, kib
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D31627
2021-08-22 23:00:42 +12:00
Gordon Bergling
0d55bc8eb2 rpc(3): Correct a few common typos in source code comments
- s/therfore/therefor/
- s/activte/active/

Obtained from:	NetBSD
MFC after:	3 days
2021-08-22 08:16:09 +02:00
Kristof Provost
719b5397c2 libpfctl: Fix endianness issues
Several fields are supplied in big-endian format, so we need to convert
them before we display them.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-08-20 13:53:48 +02:00
Andrew Turner
c81ea895b5 Disable the accelerated arm64 sha25 in static libraries
We don't have ifunc support in static arm64 binaries. Until we do
disable the accelerated sha256 code in a static libmd as it uses an
ifunc.

Reported by:	brd
Sponsored by:	The FreeBSD Foundation
2021-08-19 16:48:30 +00:00
Alexander Motin
c7cf100aaf geli(8): Do not report error on resize to the same size.
Just validate the old metadata and exit.  Originally the check was
added to not thash the only copy of metadata, but we can achieve the
same just by skipping the writing/trashing.  The metadata validation
should protect user from wrongly specifying new size instead of old.

MFC after:	1 month
Sponsored by:	iXsystems, Inc.
2021-08-18 17:11:03 -04:00
Daniel Kolesa
ee3ca711a8 libfetch: use more portable getline() interface
this is for better portability in order to avoid using a function
which is BSD-only or available via libbsd

MFC after:	3 weeks
2021-08-17 16:17:22 +02:00
Konstantin Belousov
300e08933e libc tls: use TLS_DTV_OFFSET defined by rtld.h
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D31541
2021-08-16 13:55:35 +03:00
Fangrui Song
8f63fa78e8 rtld: Remove calculate_tls_end
Variant I architectures use off and Variant II ones use size + off.
Define TLS_VARIANT_I/TLS_VARIANT_II symbols similarly to how libc
handles it.

Reviewed by:	kib
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D31539
Differential revision:	https://reviews.freebsd.org/D31541
2021-08-16 13:55:35 +03:00
Adam Fenn
a3d932dfef libc: vDSO timekeeping: Add pvclock support
Add support for 'VDSO_TH_ALGO_X86_PVCLK'; add vDSO-based timekeeping for
devices that support the KVM/XEN paravirtual clock API.

Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:  https://reviews.freebsd.org/D31418
2021-08-14 15:57:54 +03:00
Gordon Bergling
a1581cd735 Fix a common typo in source code comments
- s/aligment/alignment/

MFC after:	5 days
2021-08-14 14:17:48 +02:00
Jessica Clarke
5ff5d1177b clang: Fix inverted condition in llvm.build.mk
Fixes:		31ba4ce889 ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after:	1 week
2021-08-12 23:53:30 +01:00
Toomas Soome
ee6dc333e1 libsecureboot: define SOPEN_MAX
With commit 97cbd5e722, the SOPEN_MAX
was removed from stand.h.

We would need better mechanism there.
2021-08-10 22:46:40 +03:00
Andrew Turner
69d8dc20be Use arm64 sha256 intrinsics in libmd
Summary:
When running on a CPU that supports the arm64 sha256 intrinsics use them
to improve perfromance of sha256 calculations.

With this changethe following improvement has been seen on an Apple M1
with FreeBS running under Parallels, with similar results on a
Neoverse-N1 r3p1.

x sha256.orig
+ sha256.arm64
+--------------------------------------------------------------------+
|++                                                               x x|
|+++                                                              xxx|
||A                                                               |A||
+--------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   5          3.41           3.5          3.46         3.458   0.042661458
+   5          0.47          0.54           0.5         0.504   0.027018512
Difference at 95.0% confidence
        -2.954 +/- 0.0520768
        -85.4251% +/- 0.826831%
        (Student's t, pooled s = 0.0357071)

Reviewed by:	cem
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31284
2021-08-11 10:20:48 +00:00
Mitchell Horne
d78896e46f pmc(3): remove Pentium-related man pages and references
Support for Pentium events was removed completely in e92a1350b5.

Don't bump .Dd where we are just removing xrefs.

Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31423
2021-08-10 17:19:58 -03:00
Konstantin Belousov
ba3896e169 ipsec_set_policy(3): fix sentence
Sponsored by:	NVIDIA Networking
MFC after:	3 days
2021-08-10 03:46:35 +03:00
Konstantin Belousov
ee62fb2e1e _Exit(3): document implementation
Remove a useless note about unlinking temporary files, they are unlinked
in tmpfile(3) [1].  Add a note about __cxa_atexit().

Explain exactly what are the FreeBSD implementation differences between
exit() and _Exit().

Noted by:	markj [1]
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D31425
2021-08-08 22:39:46 +03:00
Konstantin Belousov
2a51e8823a fork(2): comment about doubtful use of stdio and exit(3) in example
Add fflush(stdout) as the common idiom.  Explain the need to use exit()
but advise against it.

Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D31425
2021-08-08 22:38:59 +03:00
Dimitry Andric
cd38d9cf26 Follow-up to d69d07569e by bumping lld local version
This makes it easier to detect that lld's support for compressed input
sections on BE targets is fixed.

MFC after:	3 days
X-MFC-With:	d69d07569e
2021-08-07 19:14:31 +02:00
Ka Ho Ng
fd0ffba3b4 Fix pathconf.2 documentation error
_PC_MIN_HOLE_SIZE and _PC_DEALLOC_PRESENT were mixed somehow before this
fix.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	delphij
Differential Revision:	https://reviews.freebsd.org/D31436
2021-08-07 07:09:57 +08:00
Ceri Davies
383dbdb2eb fork.2: correct minor typo in manpage. 2021-08-05 19:36:33 +01:00
Ka Ho Ng
0dc332bff2 Add fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9).
fspacectl(2) is a system call to provide space management support to
userspace applications. VOP_DEALLOCATE(9) is a VOP call to perform the
deallocation. vn_deallocate(9) is a public KPI for kmods' use.

The purpose of proposing a new system call, a KPI and a VOP call is to
allow bhyve or other hypervisor monitors to emulate the behavior of SCSI
UNMAP/NVMe DEALLOCATE on a plain file.

fspacectl(2) comprises of cmd and flags parameters to specify the
space management operation to be performed. Currently cmd has to be
SPACECTL_DEALLOC, and flags has to be 0.

fo_fspacectl is added to fileops.
VOP_DEALLOCATE(9) is added as a new VOP call. A trivial implementation
of VOP_DEALLOCATE(9) is provided.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D28347
2021-08-05 23:20:42 +08:00
Phil Shafer
cd2401cdd5 add blank line between variables (testing git commit) 2021-08-04 16:56:55 -04:00
Mitchell Horne
61ed578ee6 Prefer MK_SSP=no to SSP_CFLAGS=
It is more idiomatic. CFLAGS is only augmented with $SSP_CFLAGS when
$MK_SSP != "no".

Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31401
2021-08-04 15:23:22 -03:00
Konstantin Belousov
49ad342cc1 Add _Fork()
Current POSIX standard requires fork() to be async-signal safe.  Neither
our implementation, nor implementations in other operating systems are,
and practically it is impossible to make fork() async-signal safe without
too much efforts.  Also, that would put undue requirement that all atfork
handlers should be async-signal safe as well, which contradicts its main
use.

As result, Austin Group dropped the requirement, and added a new function
_Fork() that should be async-signal safe, but it does not call atfork
handlers.  Basically, _Fork() can be implemented as a raw syscall.

Release of glibc 2.34 added _Fork(), do the same for FreeBSD.
Clarify threading behavior for fork() in the manpage.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D31378
2021-08-03 21:19:32 +03:00
Konstantin Belousov
2d319ebe5c Style
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D31378
2021-08-03 21:19:32 +03:00