Commit Graph

271792 Commits

Author SHA1 Message Date
Ed Maste
2075d00fab hwpmc: drop 0x before %p printf format string
%p already includes the 0x.

Sponsored by:	The FreeBSD Foundation
2022-01-22 13:39:05 -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
Konstantin Belousov
fe6db72708 Add security.bsd.allow_ptrace sysctl
that disables any access to ptrace(2) for all processes.

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
Konstantin Belousov
55a0aa2162 p_candebug(), p_cansee(): always allow for curproc
Privilege checks in both functions should allow the current process to
infer information about itself, as well as use the interfaces that are
proclaimed 'debugging', for instance, procctl(2).

Note that in p_cansee() case, explicit comparision of curproc and p
avoids a race where the process might change credentials and cause
thread to compare its cached stale credentials against updated process
creds, effectively disallowing the process to observe itself.

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
Konstantin Belousov
3de96d664a vm_pageout_scans: correct detection of active object
For non-anonymous swap objects, there is always a reference from the
owner to the object to keep it from recycling.  Account for it when
deciding should we query pmap for hardware active references for the
page.

As result, we avoid unneeded calls to pmap_ts_referenced(), which for
non-mapped page means avoiding unneccessary lock and unlock of the pv list.

Reviewed by:	markj
Discussed with:	alc
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33924
2022-01-22 19:34:32 +02:00
Wojciech Macek
0daa28057c ip_mroute: add unlock in early-exit
Add missing unlock if V_ip_mrotue is not set

Obtained from:		Semihalf
2022-01-22 14:48:47 +01:00
Stefan Eßer
f89afaa148 port_conflicts_check.lua: revert commit 82bfeeff10
An enhanced version of this script has been committed to the ports
repository as /usr/ports/Tools/scripts/port_conflicts_check.lua.
2022-01-22 13:08:15 +01:00
Wojciech Macek
889c60500d ip_mroute: release epoch lock if mrouter is not configured
Add mising "else" branch to release a lock if mrouter is not
configured.

Obtained from:		Semihalf
Sponsored by:		Stormshield
2022-01-22 11:48:30 +01:00
Ka Ho Ng
fa66950534 iscsi: Fix missing is_lock unlock after cam_simq_alloc() failed
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-01-21 16:34:18 -05:00
Ryan Moeller
b252fb2430 bhyve: ahci: Fix regression with no ports
An AHCI controller may be specified with no connected ports.  Avoid
dumping core in this case for compatibility with existing VM configs.

Reviewed by:	khng, jhb
Fixes:		621b509048 Refactor configuration management in bhyve.
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D33969
2022-01-21 12:59:25 +00:00
Takanori Watanabe
eb815a7419 atrtc: Install address space handler for \_SB and its descendant.
SystemCMOS address space is accessible for system wide.
 So install address handler in \_SB space.

Reviewed by: jhb

Differential Revision: https://reviews.freebsd.org/D33892
2022-01-21 15:32:30 +09:00
Takanori Watanabe
5c69be7084 acpi: Ignore _STA and never disable AT RTC devices
atrtc(4) should always install a SystemCMOS address space handler unless
the RTC Not Present bit is not set in IAPC_BOOT_ARCH in the FADT.
The atrtc(4) driver already checks this bit, but _STA can return not-present
even when this bit is clear.

Reviewed by : jhb
Differential Revision: https://reviews.freebsd.org/D33891
2022-01-21 15:30:46 +09:00
Wojciech Macek
9ce46cbc95 ip_mroute: move ip_mrouter_done outside lock
X_ip_mrouter_done might sleep, which triggers INVARIANTS to
print additional errors on the screen.
Move it outside the lock, but provide some basic synchronization
to avoid race condition during module uninit/unload.

Obtained from:		Semihalf
Sponsored by:		Stormshield
2022-01-21 06:17:19 +01:00
Wojciech Macek
58630bdd13 Revert "ip_mroute: do not call epoch_waitwhen lock is taken"
This reverts commit 2e72208b6c.
2022-01-21 06:17:19 +01:00
Piotr Kubaj
a0f3abb098 powerpc: enable ice in GENERIC64LE
Approved by:	erj
Differential Revision: https://reviews.freebsd.org/D33974
2022-01-21 02:17:46 +01:00
Ed Maste
0746301c49 ssh: pass 0 to procctl(2) to operate on self
As of f833ab9dd1 procctl(2) allows idtype P_PID with id = 0 as a
shortcut for the calling process ID.  The shortcut also bypasses the
p_cansee / p_candebug test (since the process is able to act on itself.)

At present if the security.bsd.unprivileged_proc_debug sysctl is 0 then
procctl(P_PID, getpid(), ... for a process to act on itself will fail,
but procctl(P_PID, 0, ... will succeed.  This should likely be addressed
with a kernel change.

In any case the id = 0 shortcut is a tiny optimization for a process to
act on itself and allows the self-procctl to succeed, so use it in ssh.

Reported by:	Shawn Webb
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33970
2022-01-20 19:54:49 -05:00
Michael Reifenberger
19eaa01bea Append Keyboard Layout specified option for using VNC.
Part two: Append bhyve -K option for specified keyboard layout
with layout setting files every languages.
Since the cmd option '-k' was used in the meantime
it was changed to '-K'

PR:		246121
Submitted by:	koinec@yahoo.co.jp
Reviewed by:	grehan@
Differential Revision:	https://reviews.freebsd.org/D29473

MFC after:	4 weeks
2022-01-20 23:49:27 +01:00
John Baldwin
89e0ee0db4 chacha20_poly1305: Use the correct license disclaimer.
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33976
2022-01-20 14:36:48 -08:00
John Baldwin
77da558ceb check/delete-old: Auto-generate lib32 entries for libraries.
- Add usr/lib32/libfoo.so.N for lib/libfoo.so.N.

- Add usr/lib32/foo for usr/lib/foo.

- Treat casper libraries special since they are installed to
  /usr/lib32 instead of /usr/lib32/casper and thus map
  usr/lib/casper/foo to usr/lib32/foo.

Note that OLD_DIRS and MOVED_LIBS entries are not duplicated, only
OLD_FILES and OLD_LIBS.

Reviewed by:	imp, emaste
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33324
2022-01-20 14:09:57 -08:00
John Baldwin
f033840b25 Use MOVED_LIBS for the libalias modules being moved to /lib.
This is a bit more unusual in that the modules dropped their major
version suffix at the same time, so the old files being removed by
MOVED_LIBS in this case are the symlinks to the old libraries.

Reviewed by:	emaste
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33849
2022-01-20 12:48:24 -08:00
John Baldwin
57ba3f00f5 Use MOVED_LIBS for libraries moved between /usr/lib and /lib.
Add a MOVED_LIBS variable similar to OLD_LIBS except that MOVED_LIBS
is used for the cases that a library's name doesn't change, but it
just moves between /usr/lib and /lib.  This will be used by a future
change to auto-generate lib32 old files entries for which these cases
need to be ignored (a moved library remains in /usr/lib32).

Suggested by:	emaste
Reviewed by:	emaste
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33848
2022-01-20 12:47:43 -08:00
John Baldwin
c96dfb2156 Rework documentation of OLD_*.
- Be more explicit in the difference between OLD_DIRS and OLD_FILES
  (the former is only in delete-old-libs whereas the latter is in
  delete-old).

- Document that debug symbols in /usr/lib/debug/ for files in
  OLD_FILES and OLD_LIBS are removed as well.

Reviewed by:	emaste
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33847
2022-01-20 12:46:29 -08:00
Mark Johnston
6be8944d96 ktls: Zero out TLS_GET_RECORD control messages
Otherwise we end up copying one uninitialized byte into the socket
buffer.

Reported by:	KMSAN
Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33953
2022-01-20 15:42:46 -05:00
Mark Johnston
d91d2b513e geom: Handle partial I/O in g_{read,write,delete}_data()
These routines are used internally by GEOM to dispatch I/O requests to a
provider, typically for tasting or for updating GEOM class metadata
blocks.

These routines assumed that partial I/O did not occur without setting
BIO_ERROR, but this is possible in at least two cases:
- Some or all of the I/O range is beyond the provider's mediasize.
  In this scenario g_io_check() truncates the bounds of the request
  before it is handed to the target provider.
- A read from vnode-backed md(4) device returns EOF (the backing vnode
  is allowed to be smaller than the device itself) or partial vnode I/O
  occurs.
In these scenarios g_read_data() could return a partially uninitialized
buffer.  Many consumers are not affected by the first case, since the
offsets used for provider metadata or tasting are relative to the
provider's mediasize, but in some cases metadata is read at fixed
offsets, such as when searching for a UFS superblock using the offsets
defined by SBLOCKSEARCH.

Thus, modify the routines to explicitly check for a non-zero residual
and return EIO in that case.  Remove a related check from the
DIOCGDELETE ioctl handler, it is handled within g_delete_data() now.

Reviewed by:	mav, imp, kib
Reported by:	KMSAN
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31293
2022-01-20 08:29:39 -05:00
Mark Johnston
526ddf174e vtnet: Mark MRG_RXBUF headers as initialized before loading fields
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-01-20 08:25:14 -05:00
Mark Johnston
3d8562348c fusefs: Address -Wunused-but-set-variable warnings
Reviewed by:	asomers
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D33957
2022-01-20 08:25:00 -05:00
Mark Johnston
c3196306f0 clockcalib: Fix an overflow bug
tc_counter_mask is an unsigned int and in the TSC timecounter is equal
to UINT_MAX, so the addition tc->tc_counter_mask + 1 can overflow to 0,
resulting in a hang during boot.

Fixes:		c2705ceaeb ("x86: Speed up clock calibration")
Reviewed by:	cperciva
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33956
2022-01-20 08:23:38 -05:00
Wolfram Schneider
e0282802a6 remove debug code for cpu usage
I guess nobody used this in the last decade, and you can get
similar results with the time(1) command.
2022-01-20 06:43:54 +00:00
Wolfram Schneider
cfa3856452 Use 64-bit integers for database statistics
This fix (harmless) integer overflows for larger partitions (>2TB)

PR: 223023
2022-01-20 06:27:08 +00: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
Mitchell Horne
eb81812fb7 riscv: fix unused var in page_fault_handler()
clang warns that p is set-but-not-used, so let's use it.
2022-01-19 17:21:25 -04:00
Alan Somers
eea7c61590 Add tests for ses(4)
The tests require SES hardware.  Without it, the test cases will be
skipped.

Reviewed by:	ken
Differential Revision: https://reviews.freebsd.org/D31809
Sponsored by:	Axcient
MFC after:	2 weeks
2022-01-19 12:43:51 -07:00
Alan Somers
18acbeb392 sesutil: fix a comment
MFC after:	2 weeks
Sponsored by:	Axcient
2022-01-19 12:43:51 -07:00
Wolfram Schneider
a97ce14abc correct type of mmap len parameter
Using locate -m on a database > 2GB should work now.

PR: 261277
2022-01-19 19:32:16 +00:00
Alan Somers
170a0a8ebb ses: minor cleanup
* Prefer variables of small scope rather than large scope
* Remove a magic number
* style(9) for return statements
* Remove the get_enc_status method, which never did anything
* Fix a variable type in the handle_string method
* Proofread some comments

MFC after:	2 weeks
Sponsored by:	Spectra Logic, Axcient
Reviewed by:	ken, mav
Differential Revision: https://reviews.freebsd.org/D31686
2022-01-19 12:08:03 -07:00
Ed Maste
7cafe89f9c sanitizers: Improve FreeBSD ASLR detection
The kern.elf64.aslr.pie_enable and kern.elf32.aslr.pie_enable sysctls
control the default setting for PIE binary address randomization, but
it is possible to enable or disable ASLR on a per-process basis.  Use
procctl(2) to query whether ASLR is enabled.

(Note that with ASLR enabled but sysctl kern.elf64.aslr.pie_enable=0
a PIE binary will in effect have randomization disabled, and be
functional with msan.  This is not intended as as a user-facing control
though.  The user can use proccontrol(1) to disable aslr for the
process.)

Approved by:	dim
Obtained from:	LLVM 64de0064f315f57044294879d9ff4eacb454d45b
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33933
2022-01-19 13:07:40 -05:00
Robert Wing
51fbd894dd bhyve/snapshot: fix pthread_create() error check
pthread_create() returns 0 on success or an error number on failure.

Reviewed by:	khng, markj
Differential Revision:	https://reviews.freebsd.org/D33930
2022-01-19 08:40:06 -09:00
Mark Johnston
6c7e4d72b1 vt: Use a taskqueue to clear splash_cpu logos
vt_fini_logos() calls vtbuf_grow(), which reallocates the console
window's buffer using malloc(M_WAITOK).  Because vt_fini_logos() is
called via a callout, we end up panicking if INVARIANTS is enabled.

Fix the problem simply by clearing the logos using a timed taskqueue.
taskqueue_thread is formally allowed to sleep; of course, if we actually
end up sleeping to satisfy the allocation, then we have bigger problems.

PR:		260896
Reviewed by:	emaste
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33932
2022-01-19 10:53:15 -05:00
Andrew Turner
2ad1999722 Add the Armv8.3-SPE registers 2022-01-19 12:07:35 +00:00
Andrew Turner
b5876847ac Teach DTrace about BTI on arm64
The Branch Target Identification (BTI) Armv8-A extension adds new
instructions that can be placed where we may indirrectly branch to,
e.g. at the start of a function called via a function pointer. We can't
emulate these in DTrace as the kernel will have raised a different
exception before the DTrace handler has run.

Skip over the BTI instruction if it's used as the first instruction in
a function.

Sponsored by:	The FreeBSD Foundation
2022-01-19 12:07:35 +00:00
Baptiste Daroussin
6521372e95 pci_vendors: update to 2022-01-15 2022-01-19 09:58:13 +01:00
Alfonso Siciliano
8ea2d22e6d bsddialog: Fix for terminals without colours
When running the installer, in particular disextract (which is so far
the only part converted to bsddialog), on serial console or vt100 or
actually any terminal without color support, it failed to start.

This change makes bsddialog fallback on the black and white theme.

This is incorporated in newer version of bsddialog which will be
imported soon.

PR:		261272
Reported by:	thj
Differential Revision:	https://reviews.freebsd.org/D33920
2022-01-19 09:28:42 +01:00
Doug Moore
0ce7909cd0 vm_phys: add essential segment bounds check
A lower-bound segment check is necessary in vm_phys_alloc_seg_contig.
Add one.

Reported by:	jenkins
Reviewed by:	alc
Fixes:	da92ecbc0d vm_phys: fix seg->end test in alloc_seg_contig
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D33945
2022-01-19 00:42:39 -06:00
Alan Somers
89d57b94d7 fusefs: implement VOP_DEALLOCATE
MFC after:	Never
Reviewed by:	khng
Differential Revision: https://reviews.freebsd.org/D33800
2022-01-18 21:13:02 -07:00
Alexander Motin
b7ff445ffa Reduce bufdaemon/bufspacedaemon shutdown time.
Before this change bufdaemon and bufspacedaemon threads used
kthread_shutdown() to stop activity on system shutdown.  The problem is
that kthread_shutdown() has no idea about the wait channel and lock used
by specific thread to wake them up reliably.  As result, up to 9 threads
could consume up to 9 seconds to shutdown for no good reason.

This change introduces specific shutdown functions, knowing how to
properly wake up specific threads, reducing wait for those threads on
shutdown/reboot from average 4 seconds to effectively zero.

MFC after:	2 weeks
Reviewed by:	kib, markj
Differential Revision:  https://reviews.freebsd.org/D33936
2022-01-18 19:26:16 -05:00
Robert Wing
6596f19daa etc/defaults/rc.conf: set default of zfskeys_enable to NO
This addresses the following boot message:
    /etc/rc: WARNING: $zfskeys_enable is not set properly - see rc.conf(5).

Reported by:    Mark Millard
Sponsored by:   Modirum MDPay
Sponsored by:   Klara Inc.
Fixes: bfb7a31b6a ("rc: Hook zfskeys to the build")
Fixes: 33ff39796f ("Add zfskeys rc.d script for auto-loading encryption keys")
2022-01-18 14:26:30 -09:00
John Baldwin
dd2f7a4b45 Bump __FreeBSD_version for the addition of <crypto/chacha20_poly1305.h>.
Sponsored by:	The FreeBSD Foundation
2022-01-18 14:49:24 -08:00
John Baldwin
42876a039e crypto: Stop compiling in chacha20poly1305 AEAD ciphers from libsodium.
These ciphers are now supported via OCF or 'struct enc_xform'.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33889
2022-01-18 14:48:40 -08:00
John Baldwin
e71680049b crypto: Add a simple API for [X]ChaCha20-Poly1035 on flat buffers.
This is a synchronous software API which wraps the existing software
implementation shared with OCF.  Note that this will not currently
use optimized backends (such as ossl(4)) but may be appropriate for
operations on small buffers.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33524
2022-01-18 14:47:13 -08:00
Robert Wing
ae9ea22e14 bhyve: get mediasize for character devices when resizing virtio-blk
Reviewed by:	imp, allanjude, jhb
Differential Revision:	https://reviews.freebsd.org/D33403
2022-01-18 11:26:49 -09:00