Commit Graph

23052 Commits

Author SHA1 Message Date
Jose Luis Duran
c1fa6f4c5d libefivar: Fix incorrect check for DisplayOnly text format in AcpiEx
Text format for AcpiEx device path in UEFI Spec:
AcpiEx(HID,CID,UID,HIDSTR,CIDSTR,UIDSTR)
AcpiEx(HID|HIDSTR,(CID|CIDSTR,UID|UIDSTR))(Display Only)

When convert device path to text for AcpiEx device path,
current code check AllowShortcuts parameter to convert
the device path to DisplayOnly text format(shorter text
representation) by mistake.
It should check DisplayOnly parameter.

This commit is to fix this issue.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1312
Obtained from:	e9ab1635a2
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:35 -07:00
Jose Luis Duran
492d9953fa libefivar: Handle AcpiExp device path when optional para is not specified
AcpiExp text device path: AcpiExp(HID,CID,UIDSTR)
And according to UEFI spec, the CID parameter is optional
and has a default value of 0. But current implementation
miss to check following cases for the AcpiExp.
FromText: when text device is AcpiExp(HID,,UIDSTR)/AcpiExp(HID,0,UIDSTR)
ToText: when the CID is 0 in the node structure

This commit is to do the enhancement.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1243
Obtained from:	a8b5750901
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:31 -07:00
Jose Luis Duran
965f85271c libefivar: Handle USBxxx device path when optional para is not specified
According to UEFI spec,
for the Messaging Device Path with USB Class SubType, some paras
are optional in the text device path.
Take UsbClass(VID,PID,Class,SubClass,Protocol) for example,
The VID is an integer between 0 and 65535 and is optional. The
default value is 0xFFFF.
The PID is an integer between 0 and 65535 and is optional. The
default value is 0xFFFF.
The Class is an integer between 0 and 255 and is optional. The
default value is 0xFF.
The SubClass is an integer between 0 and 255 and is optional. The
default value is 0xFF.
The Protocol is an integer between 0 and 255 and is optional. The
default value is 0xFF.
So if any the optional para is not specified in the text device,
we should set related para in the node structure to default value.

This commit is to do the enhancement for USB Class device path
when optional para is not specified.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1243
Obtained from:	3874108034
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:24 -07:00
Jose Luis Duran
4e83ac7d2e libefivar: Handle Sata device path when optional para is not specified
Sata device path format:Sata(HPN, PMPN, LUN)
According to UEFI Spec, the PMPN is an integer between
0 and 65535 and is optional. If not provided, the default is 0xFFFF.

This commit is to do the enhancement for Sata device path
when optional para is not specified.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1243
Obtained from:	6d9b9bbb61
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:20 -07:00
Jose Luis Duran
9a62aa9329 libefivar: Use VENDOR_DEVICE_PATH structure for Debug Port device path
When converting DebugPort device path from text,
current code use VENDOR_DEFINED_MESSAGING_DEVICE_PATH structure
for Debug port device node.
typedef struct {
  EFI_DEVICE_PATH_PROTOCOL  Header;
  EFI_GUID                  Guid;
  UINT8                     VendorDefinedData[1];
} VENDOR_DEFINED_MESSAGING_DEVICE_PATH;

And Debugport Device Path is a vendor-defined messaging
device path with no data, only a GUID. So it's better to
use VENDOR_DEVICE_PATH to create the Debug port device node.
typedef struct {
  EFI_DEVICE_PATH_PROTOCOL        Header;
  EFI_GUID                        Guid;
} VENDOR_DEVICE_PATH;

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1229
Obtained from:	9343d0a1cd
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:12 -07:00
Jose Luis Duran
a51ae7212d libefivar: Add PciRoot/PcieRoot text for ACPI Expanded Device Path
According to UEFI spec,for ACPI Expanded Device Path
when HID=PNP0A03 or CID=PNP0A03 and HID != PNP0A08,
the device path node can be displayed as: PciRoot(UID|UIDSTR)
When HID=PNP0A08 or CID=PNP0A08, the device path node can be
displayed as: PcieRoot(UID|UIDSTR). But current code miss the
code logic.

This commit is to do the enhancement.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1228
Obtained from:	78af0984b4
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:08 -07:00
Jose Luis Duran
ac2b16d3b1 libefivar: Correct condition check for AcpiExp text format
According to UEFI Spec, for ACPI Expanded Device Path,
when HIDSTR=empty, CIDSTR=empty, UID STR!=empty,
the ACPI Expanded Device Path node can be displayed as
AcpiExp(HID,CID,UIDSTR) format.
And if UID is 0 and UIDSTR is empty, then use AcpiEx format.

This patch is to correct the condition check to follow UEFI
Spec when convert the device path node to the AcpiExp text
format.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1226
Obtained from:	fb4bea551e
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:04 -07:00
Jose Luis Duran
8278071ae1 libefivar: Correct the string order of ACPI Expanded Device Path
According to UEFI Spec, ACPI Expanded Device Path can be display
AcpiEx(HID|HIDSTR,(CID|CIDSTR,UID|UIDSTR)), but current code display
UID|UIDSTR before CID|CIDSTR.
This patch is to fix this issue.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1227
Obtained from:	05fe752589
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:13:00 -07:00
Jose Luis Duran
49951297d2 libefivar: Clean up source files
1. Do not use tab characters
2. No trailing white space in one line
3. All files must end with CRLF

Adapted according to FreeBSD-update instructions, with the sole purpose
of reducing the differences with upstream sources.

Obtained from:	9095d37b8f
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:12:55 -07:00
Jose Luis Duran
50668299b3 libefivar: Fix iSCSI.Lun byte order issue
Obtained from:	19f21ed916
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:12:52 -07:00
Jose Luis Duran
acfee0131a libefivar: Fix byte orders of iSCSI.Lun
Per UEFI spec, iSCSI.Lun is a 8-byte array with byte #0 in the left.
It means "0102030405060708" should be converted to:
    UINT8[8] = {01, 02, 03, 04, 05, 06, 07, 08}
or  UINT64 = {0807060504030201}

Today's implementation wrongly uses the reversed order.

Obtained from:	d0196be1e3
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:12:47 -07:00
Jose Luis Duran
76ed5f1b26 libefivar: Fix bug when converting iSCSI node
If protocol string is not specified, default TCP(0) should be used.
Today's implementation wrongly sets to 1 for this case.

Obtained from:	e6c80aea71
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:12:41 -07:00
Jose Luis Duran
d9d1a1e7ab libefivar: Add DevPathFromTextDns and DevPathToTextDns libraries
V3:
* Fix the bug in DevPathFromTextDns()

V2:
* Add no IP instance case check.

Obtained from:	9b9d0655c1
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:12:29 -07:00
Jose Luis Duran
e8fc7f1189 libefivar: Add BluetoothLe device path node support
Obtained from:	ff5623e990
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:12:25 -07:00
Jose Luis Duran
0081638344 libefivar: Reverse the byte order of BD_ADDR for Bluetooth
For the following two functions:
DevPathFromTextBluetooth()
DevPathToTextBluetooth()

The Bluetooth device address "UINT8  Address[6]" is displayed with the
order from Address[5] to Address[0]. This commit reverses the order.

Obtained from:	4fc8277133
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:12:21 -07:00
Jose Luis Duran
7ca6daff6a libefivar: Refine the DevPathFromTextiSCSI protocol parsing
For current iSCSI protocol parsing, UINT16 truncation may be happened. Since
the Spec already have declaimed that 0 is TCP Protocol and 1+ is reserved, the
parsing can be refined as below:

  if (StrCmp (ProtocolStr, L"TCP") == 0) {
    ISCSIDevPath->NetworkProtocol = 0;
  } else {
    //
    // Undefined and reserved.
    //
    ISCSIDevPath->NetworkProtocol = 1;
  }

Obtained from:	7571a1c191
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:12:18 -07:00
Jose Luis Duran
b782b7884c libefivar: Fix FromText bug for multi-instance devicepath
UefiDevicePathLibConvertTextToDevicePath correctly detects when it
has hit a ',' splicing together multiple paths. However, the code
that tries to cope with it:
{code}
if (IsInstanceEnd) {
  DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (
                                   END_DEVICE_PATH_LENGTH);
  ASSERT (DeviceNode != NULL);
  SetDevicePathEndNode (DeviceNode);

  NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
  FreePool (DevicePath);
  FreePool (DeviceNode);
  DevicePath = NewDevicePath;
}
{code}
causes a problem. The END node that's appended it the node for the
entire list. So when the node is appended in AppendDevicePathNode,
it winds up disappearing. This leads to the path
'PciRoot(0x0),PciRoot(0x0)' parsing as if 'PciRoot(0x0)/PciRoot(0x0)'
were specified. These are two very different things.

NOTE:
This fix was already committed.  It has been included with the sole
intention of reducing diffs with upstream.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=419
Obtained from:	647636e175
Pull Request:	https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:11:59 -07:00
Jose Luis Duran
81a659e364 libefivar: Fix the wrong MAC address length
Network interface type should be checked before the conversion between
text device path node and MAC device path. Otherwise, the MAC text string
can't be converted to the representation of a device node, which leads to
the series failure of network HII configuration(e.g. IP, VLAN, HTTP Boot
configuration in Network Device List).

Obtained from:	2d67f2bae3
Pull Request: https://github.com/freebsd/freebsd-src/pull/581
2022-02-27 09:11:55 -07:00
Richard Scheffenegger
bd6bb49397 iscsi: per-session timeouts and rapid teardown of session on reconnect
Add per-Session configurable ping (SCSI NOP) and login timeouts.

Remove the torn down, old iSCSI session quickly, when performing a reconnect.

Reviewed By: trasz
Sponsored by:        NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D34198
2022-02-25 10:35:47 +01:00
Eric van Gyzen
a8fea07c30 sendfile_test: fix copy-paste bug
Require the newly opened file descriptor to be good, instead of
re-requiring the one that was required three lines earlier.
Thankfully, opening /dev/null is really unlikely to fail.

Reported by:	Coverity
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2022-02-24 17:05:12 -06:00
Jose Luis Duran
91a35e5803 libefivar: Correct the string expression of UTF8 vendor device path
According to UEFI spec, the string expression of UTF8 vendor
device node should be displayed as: VenUtf8(). Current code
display it as: VenUft8() by mistake when convert device
path node to text.

This commit is to fix this bug.

Upstream Bug:	https://bugzilla.tianocore.org/show_bug.cgi?id=1225
Obtained from:	959be180e1
Pull Request:	https://github.com/freebsd/freebsd-src/pull/580
2022-02-23 09:20:26 -07:00
Piotr Kubaj
884ba43116 powerpc: enable initial-exec TLS
Summary:
Use initial-exec, like other architectures.

While here, switch MACHINE_ARCH in lib/libc/Makefile to LIBC_ARCH and consistently use powerpc.

Subscribers: imp, #contributor_reviews_base

Differential Revision: https://reviews.freebsd.org/D34315
Reviewed by:	luporl
MFC after:	2 weeks
2022-02-22 19:34:28 +01:00
Jessica Clarke
9f22e0959b libpmc: Allow specifying explicit EVENT_xxH events on armv7 and arm64
This is useful for processors where we don't have an event table; in
those cases we default to a Cortex A8 (armv7) or Cortex A53 (arm64) in
order to attempt to provide something useful, but you're then limited to
the counters in those tables, some of which may also not be implemented
(e.g. LD/ST_RETIRED are no longer implemented in more recent cores,
replaced by LD/ST_SPEC).

Adding the raw EVENT_xxH event lists to each table ensures that you can
always request the exact events you want, regardless of what has been
detected or is known.

Reviewed by:	mhorne
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D33805
2022-02-15 16:10:34 +00:00
John Baldwin
bbf4df1722 libthr: Disable stack unwinding on ARM.
When a thread exits, _Unwind_ForcedUnwind() is used to walk up stack
frames executing pending cleanups pushed by pthread_cleanup_push().
The cleanups are popped by thread_unwind_stop() which is passed as a
callback function to _Unwind_ForcedUnwind().

LLVM's libunwind uses a different function type for the callback on
32-bit ARM relative to all other platforms.  The previous unwind.h
header (as well as the unwind.h from libcxxrt) use the non-ARM type on
all platforms, so this has likely been broken on 32-bit arm since it
switched to using LLVM's libunwind.

For now, just disable stack unwinding on 32-bit arm to unbreak the
build until a proper fix is tested.
2022-02-10 12:47:08 -08:00
John Baldwin
c00d345665 Install unwind.h into /usr/include
Install headers from LLVM's libunwind in place of the headers from
libcxxrt and allow C applications to use the library.

As part of this, remove include/unwind.h and switch libthr over to
using the installed unwind.h.

Reviewed by:	dim, emaste
MFC after:	10 days
Differential Revision: https://reviews.freebsd.org/D34065
2022-02-10 19:00:32 +01:00
Martin Matuska
833a452e9f libarchive: import changes from upstream
Libarchive 3.6.0

New features:
PR #1614: tar: new option "--no-read-sparse"
PR #1503: RAR reader: filter support
PR #1585: RAR5 reader: self-extracting archive support

New features (not used in FreeBSD base):
PR #1567: tar: threads support for zstd (#1567)
PR #1518: ZIP reader: zstd decompression support

Security Fixes:
PR #1491, #1492, #1493, CVE-2021-36976:
   fix invalid memory access and out of bounds read in RAR5 reader
PR #1566, #1618, CVE-2021-31566:
   extended fix for following symlinks when processing the fixup list

Other notable bugfixes and improvements:
PR #1620: tar: respect "--ignore-zeros" in c, r and u modes
PR #1625: reduced size of application binaries

MFC after:	2 weeks
Relnotes:	yes
2022-02-10 00:35:42 +01:00
Stefan Eßer
af7d105379 sysctlbyname(): restore access to user variables
The optimization of sysctlbyname() in commit d05b53e0ba had the
side-effect of not going through the fix-up for the user.* variables
in the previously called sysctl() function.

This lead to 0 or an empty strings being returned by sysctlbyname()
for all user.* variables.

An alternate implementation would store the user variables in the
kernel during system start-up. That would allow to remove the fix-up
code in the C library that is currently required to provide the actual
values.

This update restores the previous code path for the user.* variables
and keeps the performance optimization intact for all other variables.

Approved by:	mjg
Reviewed by:	kaktus
Differential Revision:	https://reviews.freebsd.org/D34171
2022-02-09 23:10:31 +01:00
Dimitry Andric
5f2aca8394 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
2022-02-08 21:46:08 +01:00
Konstantin Belousov
a1f9326607 libc binuptime(): use the right function to get the most significant bit index
Reported and tested by:	Jaroslaw Pelczar <jarek@jpelczar.com>
PR:	261781
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-02-08 21:44:23 +02:00
John Baldwin
6426978617 Extend the VMM stats interface to support a dynamic count of statistics.
- Add a starting index to 'struct vmstats' and change the
  VM_STATS ioctl to fetch the 64 stats starting at that index.
  A compat shim for <= 13 continues to fetch only the first 64
  stats.

- Extend vm_get_stats() in libvmmapi to use a loop and a static
  thread local buffer which grows to hold the stats needed.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D27463
2022-02-07 14:11:10 -08:00
Mateusz Piotrowski
4073917408 strftime.3: Fix a typo and use St for standards
MFC after:	1 week
2022-02-07 15:14:47 +01:00
Stefan Eßer
9535d9f104 libc: add helper furnction to set sysctl() user.* variables
Testing had revealed that trying to retrieve the user.localbase
variable into to small a buffer would return the correct error code,
but would not fill the available buffer space with a partial result.

A partial result is of no use, but this is still a violation of the
documented behavior, which has been fixed in the previous commit to
this function.

I just checked the code for "user.cs_path" and found that it had the
same issue.

Instead of fixing the logic for each user.* sysctl string variable
individually, this commit adds a helper function set_user_str() that
implements the semantics specified in the sysctl() man page.

It is currently only used for "user.cs_path" and "user.localbase",
but it will offer a significant simplification when further such
variables will be added (as I intend to do).

MFC after:	3 days
2022-02-05 13:33:53 +01:00
Stefan Eßer
e11ad014d1 libc: return partial sysctl() result if buffer is too small
Testing of a new feature revealed that calling sysctl() to retrieve
the value of the user.localbase variable passing too low a buffer size
could leave the result buffer unchanged.

The behavior in the normal case of a sufficiently large buffer was
correct.

All known callers pass a sufficiently large buffer and have thus not
been affected by this issue. If a non-default value had been assigned
to this variable, the result was as documented, too.

Fix the function to fill the buffer with a partial result, if the
passed in buffer size is too low to hold the full result.

MFC after:	3 days
2022-02-04 13:44:20 +01:00
Konstantin Belousov
529575be27 lnumeric.c: replace some space*8 by tabs
Reported by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-02-03 20:56:03 +02:00
Konstantin Belousov
ef061a2e29 __ctype_load(): check for calloc() failure
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:04:00 +02:00
Konstantin Belousov
87151b60e0 __numeric_load(): check for calloc() failure
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:52 +02:00
Konstantin Belousov
1aa669c5f9 libc/locale/lnumeric.c: minor style
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:44 +02:00
Konstantin Belousov
4d3b84f67c __monetary_load(): check for calloc() failure
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:35 +02:00
Konstantin Belousov
0fed1e6f18 libc/locale/lmonetary.c: minor style
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:29 +02:00
Konstantin Belousov
bc9ce839f9 __messages_load(): check for calloc() failure
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:24 +02:00
Konstantin Belousov
5b7e92d48f libc/locale/lmessages.c: minor style
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:17 +02:00
Konstantin Belousov
b8ad908ad9 __collate_load(): check for calloc failure
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:07 +02:00
Konstantin Belousov
a8be061167 libc/locale/collate.c: minor style
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:02:59 +02:00
Konstantin Belousov
7bf532c9d4 xlocale.c: only call init_key() when locale was successfully allocated
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:02:59 +02:00
Konstantin Belousov
b68522308d xlocale.c: check for allocation failure
PR:	261679
Reported by:	phil.stone@gmx.com
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:02:58 +02:00
Konstantin Belousov
fcdf9d7de5 xlocale.c:init_key(): do not ignore errors from pthread_key_create()
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:02:58 +02:00
Konstantin Belousov
aaa6fa65a6 libc/locale/xlocale.c: minor style
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:02:58 +02:00
Warner Losh
356deeb2e7 kyua/qemu: When running in qemu, don't teset sendfile
qemu's bsd-user doesn't implement sendfile, so just skip those tests
that use it.

Sponsored by:		Netflix
2022-02-02 14:27:51 -07:00
Kristof Provost
6f47a72d8e libpfctl: fix pfctl_kill_states()
735748f30a changed the output of the states so that the creator id
endianness would be consistent. This means that we need to convert the
host endianness creatorid back to big-endian before we give it to the
kernel.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-01-31 19:13:26 +01:00
Mitchell Horne
99830f702d libpmc: remove mips support
Bye bye!

Reviewed by:	imp, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34083
2022-01-28 16:35:32 -04:00
Konstantin Belousov
72d5dedfa6 stdio: add test for 86a16ada1e: fflush() handling of errors
PR:	76398
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34044
2022-01-28 01:09:47 +02:00
John Baldwin
3a502289d3 Use uintptr_t for return type of _Unwind_GetCFA.
This matches the type in other unwind headers.

Reviewed by:	dim, emaste
Differential Revision:	https://reviews.freebsd.org/D34050
2022-01-27 10:53:21 -08:00
John Baldwin
b84693501a Use an unsigned 64-bit integer for exception class.
This matches the type in other unwind headers (LLVM libunwind,
libcxxrt, glibc).

NB: include/unwind.h is not installed but is only used by libthr

Reviewed by:	imp, dim, emaste
Differential Revision:	https://reviews.freebsd.org/D34049
2022-01-27 10:34:35 -08:00
Kyle Evans
c9afc7680f tests: fix posix_spawnp_enoexec_fallback_null_argv0
This test was written because execvp was found to improperly handle the
argc == 0 case when it falls back from an ENOEXEC.  We could probably
mostly revert it now, but let's just fix the test for the time being and
circle back later to decide if we want to simplify execvp.  The test
will likely remain either way just to make sure execvp isn't working
around the newly enforced restriction with the fallback.

Fixes:	301cb491ea ("execvp: fix up the ENOEXEC fallback")
Reported by:	jenkins via lwhsu@
2022-01-27 11:22:49 -06:00
Andrew Turner
548a2ec49b Add PT_GETREGSET
This adds the PT_GETREGSET and PT_SETREGSET ptrace types. These can be
used to access all the registers from a specified core dump note type.
The NT_PRSTATUS and NT_FPREGSET notes are initially supported. Other
machine-dependant types are expected to be added in the future.

The ptrace addr points to a struct iovec pointing at memory to hold the
registers along with its length. On success the length in the iovec is
updated to tell userspace the actual length the kernel wrote or, if the
base address is NULL, the length the kernel would have written.

Because the data field is an int the arguments are backwards when
compared to the Linux PTRACE_GETREGSET call.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19831
2022-01-27 11:40:34 +00:00
Kristof Provost
735748f30a libpfctl: fix creatorid endianness
We provide the hostid (which is the state creatorid) to the kernel as a
big endian number (see pfctl/pfctl.c pfctl_set_hostid()), so convert it
back to system endianness when we get it from the kernel.

This avoids a confusing mismatch between the value the user configures
and the value displayed in the state.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33989
2022-01-27 09:07:27 +01:00
Kyle Evans
773fa8cd13 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"

Reviewed by:	emaste, kib, markj (all previous version)
Differential Revision:	https://reviews.freebsd.org/D34045
2022-01-26 13:40:27 -06:00
Ed Maste
9c296a2105 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
2022-01-26 10:54:45 -05:00
Ed Maste
3524dead81 gpart.8: minor tidying
Reported by:	igor(1)
2022-01-26 10:54:45 -05:00
Piotr Kubaj
0b2d2290fe 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
2022-01-26 15:03:27 +01:00
Andriy Gapon
1abf1e8c6b 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.

MFC after:	3 weeks
Relnotes:	maybe
2022-01-26 11:25:31 +02:00
John Baldwin
8de1a8131e libthr: Use TLS_TCB_* in _tcb_[cd]tor.
This matches libc and rtld in using the alignment (TLS_TCB_ALIGN) from
machine/tls.h instead of hardcoding 16.

Reviewed by:	kib
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D34023
2022-01-25 11:38:34 -08:00
Konstantin Belousov
86a16ada1e __sflush(): on write error, if nothing was written, reset FILE state back
otherwise the data is just dropped.  Check for current position equal to
the buffer base at the entry of the function; if not equal, setvbuf()
was done from the write method and it is not our business to override
the decision.

PR:	76398
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34007
2022-01-25 17:26:05 +02:00
John Baldwin
b943d31594 Include the correct header for pdfork()'s prototype.
Reviewed by:	kib, markj
Obtained from:	CheriBSD
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33988
2022-01-24 09:52:12 -08:00
Martin Matuska
e92ffd9b62 zfs: merge openzfs/zfs@17b2ae0b2 (master) into main
Notable upstream pull request merges:
  #12766 Fix error propagation from lzc_send_redacted
  #12805 Updated the lz4 decompressor
  #12851 FreeBSD: Provide correct file generation number
  #12857 Verify dRAID empty sectors
  #12874 FreeBSD: Update argument types for VOP_READDIR
  #12896 Reduce number of arc_prune threads
  #12934 FreeBSD: Fix zvol_*_open() locking
  #12947 lz4: Cherrypick fix for CVE-2021-3520
  #12961 FreeBSD: Fix leaked strings in libspl mnttab
  #12964 Fix handling of errors from dmu_write_uio_dbuf() on FreeBSD
  #12981 Introduce a flag to skip comparing the local mac when raw sending
  #12985 Avoid memory allocations in the ARC eviction thread

Obtained from:	OpenZFS
OpenZFS commit:	17b2ae0b24
2022-01-22 23:05:15 +01:00
Dimitry Andric
3c3df36600 Sort SRCS in libcxxrt's Makefile, and use += to list sources
No functional change intended.

MFC after:	3 days
2022-01-22 21:08:55 +01:00
Ed Maste
6f6fbfa3a8 Remove quotes around Makefile .error/.warn/.info strings
The text after .error et al is emitted verbatim.

Reviewed by:	sjg
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33904
2022-01-22 14:03:07 -05:00
Konstantin Belousov
a393644ecb ptrace(2): document policies affecting access to the facility
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33986
2022-01-22 19:36:56 +02:00
наб
bc40713a8f
libspl: ASSERT*: !! for sizeof
sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD
build configurations: work around this by !!ing ‒
this makes the sizeof target the ! result type (_Bool), instead

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used")
Closes #12984
Closes #12986
2022-01-21 10:20:11 -08:00
Konstantin Belousov
7406ec4ea9 kqueue(2): Add note about format of the data for NOTE_EXIT
Noted by:	Dave Baukus <daveb@spectralogic.com>
PR:	261346
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2022-01-20 00:37:25 +02:00
наб
e1c720de7d
libefi: remove efi_type()
All it is right now is some #if 0ed Solaris code that returns ENOSYS,
and is only applicable for the Solaris blockdev layer.
In the Illumos gate, there's a single user: rmformat(1);
I recommend a read of the manual as a blast from the past, but, well

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Issue #12844
Closes #12969
2022-01-18 14:40:43 -08:00
Xin LI
cc68614da8 MFV f83ac37f1e: libbsdxml (expat) 2.4.3. 2022-01-17 16:34:41 -08:00
Mark Johnston
f75b1ff6e5 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
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33704
2022-01-17 11:41:49 -05:00
Xin LI
f83ac37f1e Vendor import of expat 2.4.3. 2022-01-16 18:55:26 -08:00
Ed Maste
2e9bc9d144 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
2022-01-16 11:56:28 -05:00
Ed Maste
c6750f07b4 libc: fix misleading comment in strstr
Obtained from:	musl c53e9b239418
2022-01-16 11:52:29 -05:00
Stefan Eßer
10af8e45a8 fread.c: fix undefined behavior
A case of undefined behavior in __fread() has been detected by UBSAN
and reported by Mark Millard:

/usr/main-src/lib/libc/stdio/fread.c:133:10: runtime error: applying
zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior in
/usr/main-src/lib/libc/stdio/fread.c:133:10

While being benign (the NULL pointer is later passed to memcpy() with
a length argument of 0), this issue causes in the order of 600 Kyua
test cases to fail on systems running a world built with WITH_UBSAN
and WITH_ASAN.

The undefined behavior can be prevented by skipping operations that
have no effect for r == 0. Mark Millard has suggested to only skip
this code segment if fp->_p == NULL, but I have verified that for the
case of r == 0 no further argument checking is performed on the
addresses passed to memcpy() and thus no bugs are hidden from the
sanitizers due to the simpler condition chosen.

Reported by:	Mark Millard (marklmi@yahoo.com)
Tested by:	Mark Millard (marklmi@yahoo.com)
Differential Revision:	https://reviews.freebsd.org/D33903
MFC after:	2 weeks
2022-01-16 00:43:56 +01:00
наб
18168da727
module/*.ko: prune .data, global .rodata
Evaluated every variable that lives in .data (and globals in .rodata)
in the kernel modules, and constified/eliminated/localised them
appropriately. This means that all read-only data is now actually
read-only data, and, if possible, at file scope. A lot of previously-
global-symbols became inlinable (and inlined!) constants. Probably
not in a big Wowee Performance Moment, but hey.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12899
2022-01-14 15:37:55 -08:00
Ryan Moeller
69c5e694a1
FreeBSD: Fix leaked strings in libspl mnttab
The FreeBSD implementations of various libspl functions for getting
mounted device information were found to leak several strings which
were being allocated in statfs2mnttab but never freed.

The Solaris getmntany(3C) and related interfaces are expected to return
strings residing in static buffers that need to be copied rather than
freed by the caller.

Use static thread-local storage to stash the mnttab structure strings
from FreeBSD's statfs info rather than strings allocated on the heap by
strdup(3).

While here, remove some stray commented out lines.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #12961
2022-01-14 12:38:32 -08:00
Piotr Kubaj
9fc1314266 riscv64: enable ASAN and UBSAN
Differential review:	https://reviews.freebsd.org/D33875
Approved by:	dim, imp
2022-01-14 01:29:58 +01:00
наб
4737a9eb70
linux: libzfs: mount: fix uninitialised flags
They're later |=d with constants, but never reset

Caught by valgrind while investigating
https://github.com/openzfs/zfs/pull/12928#issuecomment-1007496550

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12954
2022-01-13 11:07:54 -08:00
Stefan Eßer
d106f982a5 qsort.c: prevent undefined behavior
Mark Milliard has detected a case of undefined behavior with the LLVM
UBSAN. The mandoc program called qsort with a==NULL and n==0, which is
allowed by the POSIX standard. The qsort() in FreeBSD did not attempt
to perform any accesses using the passed pointer for n==0, but it did
add an offset to the pointer value, which is undefined behavior in
case of a NULL pointer. This operation has no adverse effects on any
achitecture supported by FreeBSD, but could be caught in more strict
environments.

After some discussion in the freebsd-current mail list, it was
concluded that the case of a==NULL and n!=0 should still be caught by
UBSAN (or cause a program abort due to an illegal access) in order to
not hide errors in programs incorrectly invoking qsort().

Only the the case of a==NULL and n==0 should be fixed to not perform
the undefined operation on a NULL pointer.

This commit makes qsort() exit before reaching the point of
potentially undefined behvior for the case n==0, but does not test
the value of a, since the result will not depend on whether this
pointer is NULL or an actual pointer to an array if n==0.

The issue found by Mark Milliard in the whatis command has been
reported to the upstream (OpenBSD) and has already been patched
there.

MFC after:	1 week
2022-01-13 11:09:38 +01:00
Warner Losh
479ef15dfd libc: Teak comment about mips
Remove mips from the list of machines using TLS variant I and reformat
paragraph. No functional change intended.

Sponsored by:		Netflix
2022-01-10 10:15:15 -07:00
Eugene Grosbein
ba94a95402 gpart(8): add minimal reference to glabel(8) to manual page
MFC after:	1 week
2022-01-10 22:07:23 +07:00
Konstantin Belousov
6d06bc688e libc clnt_com_create: relock rpcsoc_lock earlier when port is obtained from portmapper
Otherwise on mapper failure we goto error handler which expect
rpscoc_lock owned, but we do not.

PR:	261051
Reported by:	RyanCai <ryancaicse@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-01-09 07:36:06 +02:00
Ed Maste
adc88b9c01 Build libclang also if LLDB is enabled
LLDB depends on libclang as it uses Clang as the expression parser.
Previously setting WITHOUT_CLANG but leaving LLDB enabled (as default)
resulted in a build failure.

Users who set WITHOUT_CLANG in order to reduce build time or size
might want to set WITHOUT_LLDB in addition to WITHOUT_CLANG, or use
WITHOUT_TOOLCHAIN instead.

PR:		260993
Reported by:	eugen
Reviewed by:	dim
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2022-01-07 15:23:55 -05:00
Rich Ercolani
d6c1bbdd65
Updated the lz4 decompressor
As an experiment, I stole the lz4 decompressor from
upstream lz4 (1.9.3), and landed it.

Feedback suggested that keeping the vendor lz4 code isolated and
unlinted was probably reasonable, so I lobbed it into its own file.

It also seemed reasonable to put the mostly-untouched* code into
lz4.c proper, and relegate the integrated and ZFS-specific code to
lz4_zfs.c.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12805
2022-01-07 10:36:49 -08:00
Jose Luis Duran
f5ccb3a33e 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
2022-01-07 07:52:34 -07:00
Tino Reichardt
a798b485ae Remove sha1 hashing from OpenZFS, it's not used anywhere.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Attila Fülöp <attila@fueloep.org>
Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12895
Closes #12902
2022-01-06 16:16:28 -08:00
наб
5c8389a8cb module: icp: rip out the Solaris loadable module architecture
After progressively folding away null cases, it turns out there's
/literally/ nothing there, even if some things are part of the
Solaris SPARC DDI/DKI or the seventeen module types (some doubled for
32-bit userland), or the entire modctl syscall definition.
Nothing.

Initialisation is handled in illumos-crypto.c,
which calls all the initialisers directly

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Attila Fülöp <attila@fueloep.org>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12895
Closes #12902
2022-01-06 16:14:04 -08:00
Paul Dagnelie
399b98198a
Revert "zfs list: Allow more fields in ZFS_ITER_SIMPLE mode"
This reverts commit f6a0dac84a.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #12938
2022-01-06 11:12:53 -08:00
Warner Losh
f3d7ace4b2 file: Turns out we need xlocal.h protection
It turns out that we still need xlocal.h protection for when we're
cross building on Linux. Linux doesn't have this file, but os/x
does. Before, we'd assume we didn't have it, like old FreeBSD, when
cross compiling. After the latest update, all that code was removed so
cross compiling needs to be handled separaetly. Do so by defining
HAVE_XLOCALE_H only when we're not building on linux. This allows us
to build the mkmagic build tool needed to build file(1).

Sponsored by:		Netflix
Reviewed by:		jrtc27
Differential Revision:	https://reviews.freebsd.org/D33741
2022-01-04 14:12:59 -07:00
Mark Johnston
e2576591b9 libsysdecode: Decode sendmsg/recvmsg flags containing an underscore
Otherwise MSG_CMSG_CLOEXEC is not decoded.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-01-04 09:46:23 -05:00
Hans Petter Selasky
fff236e89d mixer(3): Revert: "Fix for header file pollution."
Differential Revision:	https://reviews.freebsd.org/D33732
Submitted by:	christos@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-04 12:35:23 +01:00
Hans Petter Selasky
55224280e2 mixer(3): Fix for header file pollution.
Differential Revision:	https://reviews.freebsd.org/D33732
Submitted by:	christos@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-04 11:43:59 +01:00
Xin LI
43a5ec4eb4 file: upgrade to 5.41.
MFC after:	2 weeks
2022-01-03 22:03:39 -08:00
Konstantin Belousov
d9cacbf4b0 sched_get/setaffinity(): try to be more compatible with Linux
in handling the cpuset sizes different from sizeof(cpuset_t).

For both cases, cpuset size shorter than sizeof(cpuset_t) results
in EINVAL on Linux.

For sched_getaffinity(), be more permissive and accept cpuset size
larger than our cpuset_t, by clipping the syscall argument and zeroing
the rest of the output buffer.  For sched_setaffinity(), we should allow
shorter cpusets than current ABI size, again zeroing the rest of the bits.

With this change, python os.sched_get/setaffinity functions work.

Reported by:	se
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-01-03 04:31:40 +02:00
Xin LI
9026652101 libmagic: Remove support for older FreeBSD where xlocale was not available.
The MINIMUM_SUPPORTED_OSREL is 1002501 (FreeBSD 10.3), and xlocale is
supported there.

While I'm there, explicitly use config.h generated with --disable-bzlib
--disable-xzlib instead of deleting them manually.

MFC after:	2 weeks
2022-01-02 18:05:08 -08:00
наб
1f182103aa libzfs: fix unused, remove argsused
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12844
2021-12-23 09:42:47 -08:00
наб
0cad373e5c libnvpair: fix unused, remove argsused
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12844
2021-12-23 09:42:47 -08:00