Commit graph

21689 commits

Author SHA1 Message Date
Andriy Gapon
e32acf95ea cam_get_device: resolve path links before parsing device name
The CAM subsystem uses bus:taget:lun tuple to address peripherals.  But
for convenience many userland programs such as camcontrol accept devices
names such as da0.  There is a libcam function, cam_open_device, to
support that.  It first calls cam_get_device() to parse the device name
as a driver name and a unit (and handle some special device name
prefixes) and then uses cam_lookup_pass() to find a matching pass
device.

This change extends cam_get_device() to apply realpath(3) to the device
name before parsing it.  This will allow to use tools such as camcontrol
and smartctl with symbolic links that could be friendlier (more
distinguished) names for devices.

Relnotes:	maybe

(cherry picked from commit 1abf1e8c6b)
2022-02-16 09:52:53 +02:00
Konstantin Belousov
d0199f27c0 libc binuptime(): use the right function to get the most significant bit index
PR:	261781

(cherry picked from commit a1f9326607)
2022-02-15 02:36:51 +02:00
Mateusz Piotrowski
8152b699d7 strftime.3: Fix a typo and use St for standards
MFC after:	1 week

(cherry picked from commit 4073917408)
2022-02-14 18:05:07 +01:00
Dimitry Andric
284434f7a6 Disable clang 14 warning about bitwise operators in zstd
Parts of zstd, used in openzfs and other places, trigger a new clang 14
-Werror warning:

```
sys/contrib/zstd/lib/decompress/huf_decompress.c:889:25: error: use of bitwise '&' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
                        (BIT_reloadDStreamFast(&bitD1) == BIT_DStream_unfinished)
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

While the warning is benign, it should ideally be fixed upstream and
then vendor-imported, but for now silence it selectively.

MFC after:	3 days

(cherry picked from commit 5f2aca8394)
2022-02-11 17:42:30 +01:00
Kyle Evans
7393eedb03 execve: disallow argc == 0
The manpage has contained the following verbiage on the matter for just
under 31 years:

"At least one argument must be present in the array"

Previous to this version, it had been prefaced with the weakening phrase
"By convention."

Carry through and document it the rest of the way.  Allowing argc == 0
has been a source of security issues in the past, and it's hard to
imagine a valid use-case for allowing it.  Toss back EINVAL if we ended
up not copying in any args for *execve().

The manpage change can be considered "Obtained from: OpenBSD"

(cherry picked from commit 773fa8cd13)
(cherry picked from commit c9afc7680f)
2022-02-10 14:21:59 -06:00
Ed Maste
c437ff145c Add libfido2 to the build
From https://github.com/Yubico/libfido2:

    libfido2 provides library functionality and command-line tools to
    communicate with a FIDO device over USB, and to verify attestation
    and assertion signatures.

    libfido2 supports the FIDO U2F (CTAP 1) and FIDO 2.0 (CTAP 2)
    protocols.

libfido2 will be used by ssh to support FIDO/U2F keys. It is currently
intended only for use by ssh, and so is installed as a PRIVATELIB and is
placed in the ssh pkgbase package.

This is currently disabled for the 32-bit library build as libfido2 is
not compatible with the COMPAT_32BIT hack in usb_ioctl.h.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32448

(cherry picked from commit 7b1e19ad78)
(cherry picked from commit 93942379cc)
2022-02-09 16:24:54 -05:00
Ed Maste
e610bb4a85 Add libcbor to the build
From https://github.com/PJK/libcbor:

    libcbor is a C library for parsing and generating CBOR, the general-
    purpose schema-less binary data format.

libcbor will be used by ssh to support FIDO/U2F keys.  It is currently
intended only for use by ssh, and so is installed as a PRIVATELIB and is
placed in the ssh pkgbase package.

cbor_export.h and configuration.h were generated by the upstream CMake
build.  We could create them with bmake rules instead (as NetBSD has
done) but this is a fine start.

This is currently disabled for the 32-bit library build as libfido2 is
not compatible with the COMPAT_32BIT hack in usb_ioctl.h, and there is
no need for libcbor without libfido2.

Reviewed by:	kevans
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32347

(cherry picked from commit 2e85df652c)
2022-02-09 16:24:32 -05:00
Ed Maste
317a38ab65 openssh: update to OpenSSH v8.7p1
Some notable changes, from upstream's release notes:

- sshd(8): Remove support for obsolete "host/port" syntax.
- ssh(1): When prompting whether to record a new host key, accept the key
  fingerprint as a synonym for "yes".
- ssh-keygen(1): when acting as a CA and signing certificates with an RSA
  key, default to using the rsa-sha2-512 signature algorithm.
- ssh(1), sshd(8), ssh-keygen(1): this release removes the "ssh-rsa"
  (RSA/SHA1) algorithm from those accepted for certificate signatures.
- ssh-sk-helper(8): this is a new binary. It is used by the FIDO/U2F
  support to provide address-space isolation for token middleware
  libraries (including the internal one).
- ssh(1): this release enables UpdateHostkeys by default subject to some
  conservative preconditions.
- scp(1): this release changes the behaviour of remote to remote copies
  (e.g. "scp host-a:/path host-b:") to transfer through the local host
  by default.
- scp(1): experimental support for transfers using the SFTP protocol as
  a replacement for the venerable SCP/RCP protocol that it has
  traditionally used.

Additional integration work is needed to support FIDO/U2F in the base
system.

Deprecation Notice
------------------

OpenSSH will disable the ssh-rsa signature scheme by default in the
next release.

Reviewed by:	imp
MFC after:	1 month
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29985

(cherry picked from commit 19261079b7)
(cherry picked from commit f448c3ed4a)
(cherry picked from commit 1f290c707a)
(cherry picked from commit 0f9bafdfc3)
(cherry picked from commit adb56e58e8)
(cherry picked from commit 576b58108c)
(cherry picked from commit 1c99af1ebe)
(cherry picked from commit 87152f3405)
(cherry picked from commit 172fa4aa75)
2022-02-09 14:53:11 -05:00
Ed Maste
23742427f3 geom: Add HiFive boot partitions
As documented in the HiFive Unmatched Software Reference Manual.

Reviewed by:	imp, mhorne
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34010

(cherry picked from commit 9c296a2105)
2022-02-09 12:39:50 -05:00
Ed Maste
b481ed4832 gpart.8: minor tidying
Reported by:	igor(1)

(cherry picked from commit 3524dead81)
2022-02-09 12:39:50 -05:00
Konstantin Belousov
4a978de48b lnumeric.c: replace some space*8 by tabs
(cherry picked from commit 529575be27)
2022-02-09 02:42:46 +02:00
Konstantin Belousov
a6ba681b44 __ctype_load(): check for calloc() failure
(cherry picked from commit ef061a2e29)
2022-02-09 02:42:46 +02:00
Konstantin Belousov
0f674081c4 __numeric_load(): check for calloc() failure
(cherry picked from commit 87151b60e0)
2022-02-09 02:42:46 +02:00
Konstantin Belousov
0c60f03d83 libc/locale/lnumeric.c: minor style
(cherry picked from commit 1aa669c5f9)
2022-02-09 02:42:46 +02:00
Konstantin Belousov
23da067dd4 __monetary_load(): check for calloc() failure
(cherry picked from commit 4d3b84f67c)
2022-02-09 02:42:45 +02:00
Konstantin Belousov
c3f2e156ba libc/locale/lmonetary.c: minor style
(cherry picked from commit 0fed1e6f18)
2022-02-09 02:42:45 +02:00
Konstantin Belousov
7570b84079 __messages_load(): check for calloc() failure
(cherry picked from commit bc9ce839f9)
2022-02-09 02:42:45 +02:00
Konstantin Belousov
f6d0811884 libc/locale/lmessages.c: minor style
(cherry picked from commit 5b7e92d48f)
2022-02-09 02:42:45 +02:00
Konstantin Belousov
a0f1e4c5ca __collate_load(): check for calloc failure
(cherry picked from commit b8ad908ad9)
2022-02-09 02:42:45 +02:00
Konstantin Belousov
e6d728c97c libc/locale/collate.c: minor style
(cherry picked from commit a8be061167)
2022-02-09 02:42:45 +02:00
Konstantin Belousov
e1c53fc8e1 xlocale.c: only call init_key() when locale was successfully allocated
(cherry picked from commit 7bf532c9d4)
2022-02-09 02:42:45 +02:00
Konstantin Belousov
3e4e8d5cbf xlocale.c: check for allocation failure
PR:	261679

(cherry picked from commit b68522308d)
2022-02-09 02:42:45 +02:00
Konstantin Belousov
236a826c14 xlocale.c:init_key(): do not ignore errors from pthread_key_create()
(cherry picked from commit fcdf9d7de5)
2022-02-09 02:42:45 +02:00
Konstantin Belousov
8a8709c408 libc/locale/xlocale.c: minor style
(cherry picked from commit aaa6fa65a6)
2022-02-09 02:42:45 +02:00
Ed Maste
ef9fc5c52c csu: define STRIP_FBSDID
__FBSDID() places the provided string in the output object's .comment
section.  However, with the transition to Git $FreeBSD$ is no longer
expanded and so we emitted a literal $FreeBSD$.

$FreeBSD$ will be addressed in a holistic manner in the future, but at
least avoid embedding it into everything linked on FreeBSD (via csu).

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33594

(cherry picked from commit cb2d135015)
2022-02-08 15:53:31 -05:00
Ed Maste
53f18b7c20 libc: use standard LF line endings, not CRLF
(cherry picked from commit 29e54af43e)
2022-02-08 15:52:23 -05:00
Piotr Kubaj
8c56b338da riscv64: enable ASAN and UBSAN
Differential review:	https://reviews.freebsd.org/D33875
Approved by:	dim, imp

(cherry picked from commit 9fc1314266)
2022-02-08 13:26:03 +01:00
Piotr Kubaj
cb1bee9bd3 powerpc: Enable LLDB on all powerpc architectures
While LLDB on powerpc and powerpcspe builds as-is, on powerpc64 and
powerpc64le it requires adding a couple of additional source files
to build.

Differential review:	https://reviews.freebsd.org/D34043
Approved by:	dim, imp, emaste

(cherry picked from commit 0b2d2290fe)
2022-02-08 13:26:02 +01:00
Konstantin Belousov
ec2db06d0d stdio: add test for 86a16ada1e: fflush() handling of errors
PR:	76398

(cherry picked from commit 72d5dedfa6)
2022-02-01 05:29:16 +02:00
Konstantin Belousov
afa9a1f5ec __sflush(): on write error, if nothing was written, reset FILE state back
PR:	76398

(cherry picked from commit 86a16ada1e)
2022-02-01 05:29:15 +02:00
Konstantin Belousov
5775b8b392 ptrace(2): document policies affecting access to the facility
(cherry picked from commit a393644ecb)
2022-01-29 03:10:45 +02:00
Dimitry Andric
cb31d2ea4c Sort SRCS in libcxxrt's Makefile, and use += to list sources
No functional change intended.

MFC after:	3 days

(cherry picked from commit 3c3df36600)
2022-01-27 19:58:33 +01:00
Jose Luis Duran
925c54a30f file: Fix cross-compilation on Darwin/macOS
Darwin/macOS does not have pipe2(2).

Apply a similar guard as in f3d7ace4b2
after 43a5ec4eb4.

Pull Request: https://github.com/freebsd/freebsd-src/pull/574

(cherry picked from commit f5ccb3a33e)
2022-01-25 00:05:17 +00:00
Jessica Clarke
5d10ed57e6 libc: Fix "harmless" iconv one-byte overread
Checking there are still bytes left must be done before dereferencing
the pointer, not the other way round. This is harmless on traditional
architectures since the result will immediately be thrown away, and all
callers are in separate translation units so there is no potential for
optimising based on this out-of-bounds read. However, on CHERI, pointers
are bounded, and so this will trap if fed a string that does not have a
NUL within the first len bytes.

Found by:	CHERI
Reviewed by:	brooks

(cherry picked from commit 6d5297569e)
2022-01-24 23:59:47 +00:00
Jessica Clarke
ca45128899 libcrypt: Drop inclusion of libutil.h
This was rendered obsolete in 2012 by a0ee974f0b, since auth_getval
was the only reason the header was included.

MFC after:	1 week

(cherry picked from commit 7d232d647e)
2022-01-24 23:59:19 +00:00
Jessica Clarke
6318e220e3 Bootstrap libz when cross-building from non-FreeBSD
This is needed now libdwarf depends on libz.

Fixes:		dbf05458e3 ("libdwarf: Support consumption of compressed ELF sections")
MFC after:	1 week

(cherry picked from commit 8d5d329553)
2022-01-24 23:59:14 +00:00
Mark Johnston
7a38cb1e4e Revert "libthr: Use kern.stacktop for thread stack calculation."
The current ASLR stack gap feature will be removed, and with that the
need for this change, and the kern.stactop sysctl, is gone.  Moreover,
the approach taken in this revision does not provide compatibility for
old copies of libthr.so, and the revision should have also updated
__libc_map_stacks_exec().

This reverts commit 78df56ccfc.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f75b1ff6e5)
2022-01-24 09:20:03 -05:00
Konstantin Belousov
7a6364ac77 kqueue(2): Add note about format of the data for NOTE_EXIT
PR:	261346

(cherry picked from commit 7406ec4ea9)
2022-01-22 02:50:23 +02:00
Ed Maste
423fb85f33 libc: correct SPDX tag on strstr.c
It was obtained from musl, and is MIT licensed.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2e9bc9d144)
2022-01-18 19:32:29 -05:00
Ed Maste
e475c5f6ca libc: fix misleading comment in strstr
Obtained from:	musl c53e9b239418

(cherry picked from commit c6750f07b4)
2022-01-18 19:32:29 -05:00
Xin LI
46aa53e2b8 file: upgrade to 5.41.
(cherry picked from commit 43a5ec4eb4)
2022-01-17 16:43:58 -08:00
Eugene Grosbein
e4dd9ce81b gpart(8): MFC: add minimal reference to glabel(8) to manual page
(cherry picked from commit ba94a95402)
2022-01-17 13:44:00 +07:00
Konstantin Belousov
07d32ede46 libc clnt_com_create: relock rpcsoc_lock earlier when port is obtained from portmapper
PR:	261051

(cherry picked from commit 6d06bc688e)
2022-01-15 02:51:13 +02:00
Konstantin Belousov
8c709f30a1 sched_get/setaffinity(): try to be more compatible with Linux
(cherry picked from commit d9cacbf4b0)
2022-01-14 18:17:31 +02:00
Stefan Eßer
dc4114875e Make CPU_SET macros compliant with other implementations
(cherry picked from commit e2650af157)
2022-01-14 18:17:30 +02:00
Stefan Eßer
379bfb2aa9 sys/bitset.h: reduce visibility of BIT_* macros
(cherry picked from commit 5e04571cf3)
2022-01-14 18:17:30 +02:00
Math Ieu
3f8542d396 sched_get/setaffinity(3): pid 0 should designate current process
PR:	260487

(cherry picked from commit caacda7a3e)
2022-01-14 18:17:30 +02:00
Konstantin Belousov
58865d5f8d sched.h: Hide all Linux compat sched_* functions under _WITH_CPU_SET_T
(cherry picked from commit 90fa9705d5)
2022-01-14 18:17:29 +02:00
Konstantin Belousov
d3e9527a10 x86: provide userspace implementation of sched_getcpu() where possible
(cherry picked from commit f239545591)
2022-01-14 18:17:29 +02:00
Konstantin Belousov
a48d9f1900 Add sched_getcpu()
(cherry picked from commit 77b2c2f814)
2022-01-14 18:17:29 +02:00