1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00
Commit Graph

19191 Commits

Author SHA1 Message Date
Navdeep Parhar
73936ae305 bsdinstall: Fix typo (Instalation -> Installation).
(cherry picked from commit 5104dfbeff)
2022-03-04 13:10:59 -08:00
Eric van Gyzen
6887791e18 efivar: handle error when reading --fromfile
The result of read() was stored in an unsigned variable, so the
test for a negative value would never work.

While I'm here, print a better error message for an empty file,
omitting the misleading errno message.

Reported by:	Coverity
MFC after:	1 week
Sponsored by:	Dell EMC Isilon

(cherry picked from commit d0f4e583bf)
2022-03-02 15:56:31 -06:00
Warner Losh
d8d0ac7b5d efivar: use bool for booleans
Rather than int flags we ++, use booleans for all command line args.
No functional change intended.

Reviewed by:		markj@
Sponsored by:		Netflix, Inc
Differential Revision:	https://reviews.freebsd.org/D29621

(cherry picked from commit 066b096d13)
2022-03-02 15:56:31 -06:00
Warner Losh
c2d161d300 efivar: Attempt to fix setting/printing/deleting EFI vars with '-' in their name
Due to how we're parsing UUIDs, we were disallowing setting, printing or
deleting any UEFI variable with a '-' in it when you attempted to do that
operation with the exact name (wildcard reporting was unaffected). Fix the
parser to loop over all the dashes in the name and only give up when all
possible matches are exhausted.

Reviewed by:		markj@
Sponsored by:		Netflix, Inc
Differential Revision:	https://reviews.freebsd.org/D29620

(cherry picked from commit 0292a5c95f)
2022-03-02 15:56:31 -06:00
Warner Losh
36a9057e04 efivar: Add --quiet to not report errors
Add -q/--quiet flag to the command line. With it, errors are not reported at
all. Instead nothing is printed and the exit code is non-zero.

Reviewed by:		markj
Sponsored by:		Netflix, Inc
Differential Revision:	https://reviews.freebsd.org/D29619

(cherry picked from commit 3c0dcbfc85)
2022-03-02 15:56:31 -06:00
Eric van Gyzen
bf75cc097a rtsold: fix memory leak in script execution
Since commit 04e9edb544, rtsold has leaked the memory for the
argument vector of every script it runs.

Reported by:	Coverity
Reviewed by:	markj
Fixes:		04e9edb544
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D34355

(cherry picked from commit 331b84b5db)
2022-03-02 15:56:31 -06:00
Eric van Gyzen
b43916e230 rtsold: Use correct error in llflags_get()
Set errno to EINVAL if the name overflows the buffer, as was done
before commit ecce515d54.

Reviewed by:	dab, markj
Fixes:		ecce515d54
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D34354

(cherry picked from commit a2a8efb4f6)
2022-03-02 15:56:31 -06:00
Eric van Gyzen
f3629ca2f5 uefisign: handle empty sections
loader.efi has an empty set_Xfic section.  Handle it correctly.

```
Sections:
Idx Name          Size      VMA               LMA               File off  Algn
[...]
3 set_Xcom      00000168  00000000000d4000  00000000000d4000  000d0e00  2**2
	      CONTENTS, ALLOC, LOAD, DATA
4 set_Xfic      00000000  00000000000d4168  00000000000d4168  00000000  2**2
	      ALLOC, LOAD, DATA
5 .sdata        00000448  00000000000d5000  00000000000d5000  000d1000  2**2
	      CONTENTS, ALLOC, LOAD, DATA
[...]
```

Reviewed by:	trasz, dab
Reported by:	andy.y.liu@dell.com
Tested by:	andy.y.liu@dell.com
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D29606

(cherry picked from commit 12db51d208)
2022-03-02 15:56:30 -06:00
Eric van Gyzen
858c11b39c uefisign: fix handling of errors from child proc
Close the unused pipe file descriptors so the parent will notice if
the child exits prematurely.  Previously, the parent would block
forever on a read from the pipe.

    $ uefisign -c foo.cert -k foo.key -o loader.efi loader.efi.unsigned
    uefisign: section points inside the headers
    load: 0.06  cmd: uefisign 4502 [piperd] 7.25r 0.00u 0.00s 0% 5968k
    ... _sleep+0x1be pipe_read+0x3d6 kern_readv+0x8c sys_read+0x83 ...

Reviewed by:	trasz
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D29605

(cherry picked from commit 9e6158d274)
2022-03-02 15:56:29 -06:00
Chuck Tuffli
0f26e9f2e2 bhyve nvme: Advertise Namespace changed AEN
Advertise Namespace Attribute Notices events in the Optional
Asynchronous Events Supported (OAES) field of the Identify Controller
data structure. Additionally, rename the enums and macros to clarify
these are AEN's related to Notices and not generic information.

Reported by: andy@omniosce.org

(cherry picked from commit e0ac9dc2b0)
2022-02-27 17:59:31 -08:00
Chuck Tuffli
7de3a3e919 nvme: fix spelling of Namespace
Fix spelling of a macro definition.

PR:		262141

(cherry picked from commit c2318cf80a)
2022-02-27 17:59:31 -08:00
Ryan Stone
e88dbe4f46 MFC 315bca194a:
Fix an early return in ctld UCL parser

If the UCL ctld parser encountered a port that used the CTL
ioctl device, it fell into a special case that had an erroneous
early return.  This caused all configuration in the target
following the port attribute to be skipped.  Fix this by replacing
the return with a continue so that the rest of the config is
parsed correctly.

Sponsored by: Dell EMC Isilon
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D31703
Reviewed by: bapt

(cherry picked from commit 315bca194a)
2022-02-25 14:06:46 -05:00
Robert Wing
487c84bb61 bhyve/block_if: allow DIOCGMEDIASIZE ioctl
This is needed to get mediasize of the device after a resize event.

I missed this earlier as I was building WITH_BHYVE_SNAPSHOT, which
disables capsicum.

Reviewed by:	khng, markj
Fixes: ae9ea22e14 ("bhyve: get mediasize for character devices when ...")
Differential Revision:	https://reviews.freebsd.org/D34013

(cherry picked from commit 08cb63a12f)
2022-02-23 08:45:32 -09:00
Robert Wing
847cdccdb0 bhyve: get mediasize for character devices when resizing virtio-blk
Reviewed by:	imp, allanjude, jhb
Differential Revision:	https://reviews.freebsd.org/D33403

(cherry picked from commit ae9ea22e14)
2022-02-23 08:43:14 -09:00
Andrew Turner
6d518e308c Add the Arm SPE interrupt to acpidump
To support the Arm Statistical Profiling Extension (SPE) ACPI 6.3 added
a place to hold the SPE interrupt. Add to acpidump to show when printing
the Arm Generic Interrupt data.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c363da4ae8)
2022-02-22 16:23:07 +00:00
Chuck Tuffli
eae02d9593 bhyve nvme: Fix Identify Namespace, NSID=ffffffff
If the NVMe Controller doesn't support Namespace Management, it should
return "Invalid Namespace or Format" when the Host request Identify
Namespace with the global NSID value.

Fixes UNH IOL 16.0 Test 9.1, Case 6

(cherry picked from commit ac678b4aaf)
2022-02-21 19:28:39 -08:00
Chuck Tuffli
d9685b5787 bhyve nvme: Fix Set Features, AEN
NVMe Controllers which do not support Endurance Groups must return an
error when the Endurance Group Event Aggregate Log Change Notices bit is
set in Set Features, Asynchronous Event Configuration.

Fixes UNH IOL Test 3.12, Case 8

(cherry picked from commit fa263c532b)
2022-02-21 19:28:25 -08:00
Chuck Tuffli
3286533a1c bhyve nvme: Fix reported VWC value
v1.4 and later NVMe Controllers report "Flush all Namespaces" support
differently.

Fixes UNH IOL 16.0 Test 2.6, Case 3

(cherry picked from commit ff5ed0fac4)
2022-02-21 19:28:07 -08:00
Chuck Tuffli
541ff74584 bhyve nvme: Fix LBA out-of-range calculation
The function which checks for a valid LBA range mistakenly named an
input value as NLB ("Number of Logical Blocks") instead of "number of
blocks". The NVMe specification defines NLB as a zero-based value (i.e.
NLB=0x0 represents 1 block, 0x1 is 2 blocks, etc.), but the passed
parameter is a 1's-based value.

Fix is to rename the variable to avoid future confusion.

While in the neighborhood, also check that the starting LBA is less than
the size of the backing storage to avoid an integer overflow.

(cherry picked from commit 9d8cd04694)
2022-02-21 19:27:47 -08:00
Chuck Tuffli
3444d620b2 bhyve nvme: Add Select support to Get Features
Implement basic support for the SEL field of Get Features. This returns
information about Namespace Specific features.

Fixes UNH IOL 16.0 Test 1.2, Case 13

(cherry picked from commit 073f2076fe)
2022-02-21 19:27:14 -08:00
Chuck Tuffli
06ec065bed bhyve nvme: Update v1.4 Identify Controller data
Compliant v1.4 Controllers must report a Controller Type (CNTRLTYPE).
Also, do not advertise secure erase functionality in the Format NVM
Attributes field of the Identify Controller data structure as the
Controller does not implement secure erase.

Fixes UNH ILO Test 1.1, Case 2

(cherry picked from commit 29241c96f7)
2022-02-21 19:27:03 -08:00
Chuck Tuffli
0bb86659cb bhyve nvme: Add Temperature Threshold support
This adds the ability for a guest OS to send Set / Get Feature,
Temperature Threshold commands. The implementation assumes a constant
temperature and will generate an Asynchronous Event Notification if the
specified threshold is above/below this value. Although the
specification allows 9 temperature values, this implementation only
implements the Composite Temperature.

While in the neighborhood, move the clear of the CSTS register in the
reset function after all other cleanup. This avoids a race with the
guest thinking the reset is complete (i.e. CSTS.RDY = 0) before the NVMe
emulation is actually complete with the reset.

Fixes UNH IOL 16.0 Test 1.7, cases 1, 2, and 4.

(cherry picked from commit ea9ee35583)
2022-02-21 19:26:45 -08:00
Chuck Tuffli
6e5e38c241 bhyve nvme: Fix Set Features
Be more conservative and only support the Features mandatory for an I/O
Controller.

Avoids a "hang" in UNH test 1.2.10 associated with Predictable Latency
Mode Configuration and Host Behavior Support features.

(cherry picked from commit 1381a11829)
2022-02-21 19:26:32 -08:00
Chuck Tuffli
d494130626 bhyve nvme: Remove redundant AER Limit checks
The NVMe emulation checked if the Asynchronous Event Request Limit
(a.k.a AERL) would be exceeded in pci_nvme_aer_add(), but this function
is only called from nvme_opc_async_event_req() which also checks for
exceeding the AERL.

(cherry picked from commit 45ab4076f3)
2022-02-21 19:26:18 -08:00
Chuck Tuffli
ae60b4cfe1 bhyve nvme: Add missing Admin opcodes
Don't treat unsupported Admin commands as Invalid Opcode. Instead return
the proper Invalid Field in Command.

Fixes UNH IOL test 1.17.2

(cherry picked from commit 785b5da318)
2022-02-21 19:26:06 -08:00
Chuck Tuffli
8f65e94045 bhyve nvme: Implement Log Page Offset
Modify the Get Log Page command to parse the Log Page Offset fields to
support more recent versions of the NVMe specification.

Fixes various tests for UNH Test 1.3.*

(cherry picked from commit b1b2a4d9e8)
2022-02-21 19:25:51 -08:00
Chuck Tuffli
29f50a83cc bhyve nvme: Fix Namespace Specific Set Features
Return an error if the feature specified in Set Features is Namespace
specific but the Namespace ID uses the Global Namespace tag.

Fixes UNH Test 1.2.7

(cherry picked from commit 62d47feceb)
2022-02-21 19:25:34 -08:00
Chuck Tuffli
3d681a9a80 bhyve nvme: Fix NVM Format completion status
The NVM Format command is unique among the Admin commands in that it
needs to finish asynchronously. For this reason, the emulation code
invented a synthetic completion status (NVME_NO_STATUS) to indicate that
the command was still in progress and the command processing loop should
not generate a completion message. The implementation used the value
0xffff for the synthetic value as this set both the Status Code and
Status Code Type fields to reserved values.

Format initialized the completion status to this value and expected
error cases to override it with a status code/type appropriate to the
situation. The macros used to set the NVMe status are careful not to
modify bit 0 (i.e. the phase bit), which with the synthetic completion
status, causes the phase bit to get out of sync. When running tests in a
guest with illegal NVM Format commands, Admin commands would eventually
hang because it appeared there were no completions due to the incorrect
phase bit value.

Fix is to only set NVME_NO_STATUS if the blockif delete command
succeeds. While in the neighborhood, add a missing break statement when
NVM Format is not supported.

(cherry picked from commit cf76cdd4bf)
2022-02-21 19:25:18 -08:00
Chuck Tuffli
bed94664db bhyve nvme: Advertise v1.4 support
Bump advertised NVMe support from v1.3 to v1.4

(cherry picked from commit 595a12f18b)
2022-02-21 19:24:50 -08:00
Chuck Tuffli
67fa95bf0c bhyve nvme: Inform guests of namespace resize
Register a "block resize" callback to be notified of changes to the
backing storage for the Namespace. Use this to generate an Asynchronous
Event Notification, Namespace Attributes Changed when the guest OS
provides an Asynchronous Event Request.

(cherry picked from commit cf3ed8e0cd)
2022-02-21 19:24:35 -08:00
Chuck Tuffli
c7c490ddef bhyve nvme: Add AEN support to NVMe emulation
Add Asynchronous Event Notification infrastructure to the NVMe
emulation.

(cherry picked from commit 9f1fa1a461)
2022-02-21 19:24:15 -08:00
Chuck Tuffli
1685d8368c bhyve blockif: fix blockif_candelete with Capsicum
NVMe conformance tests for the Format command failed if the
backing-storage for the bhyve device was a file instead of a Zvol. The
tests (and the specification) expect a Format to destroy all previously
written data. The bhyve NVMe emulation implements this by trimming /
deallocating all data from the backing-storage.

The blockif_candelete() function indicated the file did not support
deallocation (i.e. fpathconf(..., _PC_DEALLOC_PRESENT) returned FALSE)
even though the kernel supported file hole punching. This occurs on
builds with Capsicum enabled because blockif did not allow the
fpathconf(2) right.

Fix is to add CAP_FPATHCONF to the cap_rights_init(3) call.

PR:		260081

(cherry picked from commit d8c1d7b652)
2022-02-21 19:23:16 -08:00
Chuck Tuffli
b7a2cf0d91 bhyve: fix NVMe MDTS comment
Removes an obsolete comment and adds parenthesis around the macro while
in the area. No functional change.

(cherry picked from commit a11ca79cd9)
2022-02-21 19:22:35 -08:00
Edward Tomasz Napierala
fd2ae8152d chroot: fix typo in usage
While here also fix typo in a variable name.

Reported By:	oshogbo

(cherry picked from commit 0634390572)
2022-02-14 18:42:56 +00:00
Edward Tomasz Napierala
5b8c677664 sesutil: Fix status checking
Previously we would display "OK, Swapped" for swapped disks,
instead of the usual disk size.

Reviewed By:	allanjude
Differential Revision:	https://reviews.freebsd.org/D31219

(cherry picked from commit a157196713)
2022-02-14 18:42:44 +00:00
Edward Tomasz Napierala
460b4b550d Implement unprivileged chroot
This builds on recently introduced NO_NEW_PRIVS flag to implement
unprivileged chroot, enabled by `security.bsd.unprivileged_chroot`.
It allows non-root processes to chroot(2), provided they have the
NO_NEW_PRIVS flag set.

The chroot(8) utility gets a new flag, -n, which sets NO_NEW_PRIVS
before chrooting.

Reviewed By:	kib
Sponsored By:	EPSRC
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D30130

(cherry picked from commit a40cf4175c)
2022-02-14 18:42:21 +00:00
Robert Wing
d3cc82c9b7 bhyve: set EV_CLEAR for EVFILT_VNODE mevents
When an EVFILT_VNODE filter event is triggered, reset it.

This fixes the issue where a virtio-blk resize event would cause the
mevent thread to consume 100% of the cpu.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D33326

(cherry picked from commit 0b29683b32)
2022-02-17 12:35:19 -09:00
Alfredo Dal'Ava Junior
0d27ad33a4 kldxref: add R_PPC_ADDR32 handler
Implements R_PPC_ADDR32 handler for kldxref, addressing
"kldxref: unhandled relocation type 1" when running
"kldxref /boot/kernel" on powerpc 32 bits.

Reviewed by:	luporl
MFC after:	2 days
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D33745

(cherry picked from commit 79f5d19890)
2022-02-17 18:48:52 -03:00
Edward Tomasz Napierala
b993d60f60 Cross-reference camcontrol(8) and zonectl(8) man pages.
(cherry picked from commit 28b475b018)
2022-02-14 00:04:44 +00:00
Alan Somers
46fdfa9e11 sesutil: fix a comment
Sponsored by:	Axcient

(cherry picked from commit 18acbeb392)
2022-02-16 21:34:29 -07:00
Fangrui Song
31ec0c5834 crunchgen: remove -dc from linker invocation
In GNU ld and ld.lld, -dc is used with -r to allocate space to COMMON
symbols.  It is presumably to work around legacy code which cannot
handle COMMON symbols in relocatable output.  ld.lld may remove -dc or
make it a no-op for the 15.0.0 release.

As of 7420b323a0 crunch/crunchide does not require -dc, as the symbol
hiding technique no longer relied on making symbols local.

In addition -fno-common is now the default in Clang and GCC, so -dc
serves no purpose as the compiler does not generate COMMON symbols
anyway.

See https://maskray.me/blog/2022-02-06-all-about-common-symbols for more
detail on common symbols.

Reviewed by:	emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D34215

(cherry picked from commit ec81497cc7)
2022-02-16 20:03:53 -05:00
Alexander Motin
389a668f7f pciconf: Fix PCIS_CRYPTO_ENTERTAIN copy/paste.
Submitted by:   Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	1 week

(cherry picked from commit c04506fd4c)
2022-02-15 19:46:28 -05:00
Kyle Evans
47c0781405 freebsd-update: improve BE creation feature
This addresses one nit and one bug in the BE creation feature of
freebsd-update:

The nit addressed is that it currently only names the BEs after the
userland version, but the kernel version may be higher.  After this
change, we request both and pass them through sort(1) to choose the
highest.  This is especially helpful if a freebsd-update patch touched
one but not the other.

The bug fixed is that roots updated that are not located at '/', e.g.,
by using -b or -j, will no longer create boot environments
automatically.  There's a very low chance these will actually change the
BE in any meaningful way, anyways.  It could make sense in the future
to allow an argument-override to create the BE anyways if someone comes
up with a non-standard setup, e.g., where a jail is an important part of
their boot environment on an appliance or some such setup.

Half of this patch is submitted by delphij@, the other half kevans@.

PR:		261446

(cherry picked from commit e01e8f911b)
2022-02-15 00:09:50 -06:00
Robert Wing
cd6bdac081 bhyve/virtio: use correct device id for virtio-scsi
Section 4.1.2.1 of the virtio spec states that the transitional PCI
device id for a scsi device is 0x1004.

Fix suggested by reporter.

PR:             259961
Reported by:    me@nanaya.pro
Reviewed by:	imp, jhb
Fixes:  f9c005a17f ("Add bhyve virtio-scsi storage backend support.")
Differential Revision:	https://reviews.freebsd.org/D34103

(cherry picked from commit b4cc5d63b6)
2022-02-10 10:45:56 -09:00
Dimitry Andric
212c271999 Fix too small sscanf output buffers in kbdmap
This fixes the following warnings from clang 14:

usr.sbin/kbdmap/kbdmap.c:241:16: error: 'sscanf' may overflow; destination buffer in argument 5 has size 20, but the corresponding specifier may require size 21 [-Werror,-Wfortify-source]
                            &a, &b, buf);
                                    ^
usr.sbin/kbdmap/kbdmap.c:615:8: error: 'sscanf' may overflow; destination buffer in argument 3 has size 64, but the corresponding specifier may require size 65 [-Werror,-Wfortify-source]
                            keym, lng, desc);
                            ^
usr.sbin/kbdmap/kbdmap.c:615:14: error: 'sscanf' may overflow; destination buffer in argument 4 has size 64, but the corresponding specifier may require size 65 [-Werror,-Wfortify-source]
                            keym, lng, desc);
                                  ^
usr.sbin/kbdmap/kbdmap.c:615:19: error: 'sscanf' may overflow; destination buffer in argument 5 has size 256, but the corresponding specifier may require size 257 [-Werror,-Wfortify-source]
                            keym, lng, desc);
                                       ^

In each case, the buffer being sscanf'd into is one byte too small.

MFC after:	 3 days

(cherry picked from commit e17fede8ff)
2022-02-09 18:26:24 +01:00
Dimitry Andric
50cf1cf368 Fix too small hostname buffer in bootparamd
This fixes the following warning from clang 14:

usr.sbin/bootparamd/bootparamd/bootparamd.c:204:32: error: 'fscanf' may
overflow; destination buffer in argument 3 has size 255, but the
corresponding specifier may require size 256 [-Werror,-Wfortify-source]

The MAX_MACHINE_NAME macro indicates the maximum number of bytes in a
machine name, but it does not include the NUL terminator required for
scanf.

MFC after:	 3 days

(cherry picked from commit d310bf3867)
2022-02-09 18:26:18 +01:00
Gordon Bergling
c278a7f1ba moused(8): Fix a common typo in source code comments
- s/comatible/compatible/

Obtained from:	NetBSD

(cherry picked from commit 64b3bcc6bd)
2022-02-09 07:19:13 +01:00
Gordon Bergling
3222f9a524 makefs(8): Fix a few typos in source code comments
- s/concearned/concerned/
- s/quadradically/quadratically/

Obtained from:	NetBSD

(cherry picked from commit 164fa411b9)
2022-02-09 07:18:33 +01:00
Ed Maste
c429893a65 fstyp: fix build WITHOUT_ICONV
Reported by:	Michael Dexter, Build Option Survey
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 3513df4bcc)
2022-02-08 15:50:32 -05:00
Ed Maste
bd588d70f3 bsnmpd: Remove "All Rights Reserved" from FreeBSD Foundation copyrights
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 5fff2859ec)
2022-02-08 15:50:32 -05:00