Commit Graph

253256 Commits

Author SHA1 Message Date
Mark Johnston
e12492164a Move PLTs to the beginning of amd64 kernel modules.
As with .text, the aim is to ensure that executable sections are
segregated from the rest, to avoid creation of writeable and executable
mappings.  Recent versions of LLVM emit a PLT in firmware modules.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26444
2020-09-16 13:51:47 +00:00
Li-Wen Hsu
6132212808 Temporarily skip sys.fs.tmpfs.times_test.{empty,non_empty} in CI
PR:		249362
Sponsored by:	The FreeBSD Foundation
2020-09-16 09:58:15 +00:00
Baptiste Daroussin
dfe3db06bb Update to 2020.08.19
MFC after:	3 days
2020-09-16 07:30:18 +00:00
Warner Losh
9ea860660f Use standard bool type, instead of non-standard boolean_t 2020-09-16 06:02:30 +00:00
Rick Macklem
a5c55410b3 Fix a LOR between the NFS server and server side krpc.
Recent testing of the NFS-over-TLS code found a LOR between the mutex lock
used for sessions and the sleep lock used for server side krpc socket
structures.
The code in nfsrv_checksequence() would call SVC_RELEASE() with the mutex
held.  Normally this is ok, since all that happens is SVC_RELEASE()
decrements a reference count.  However, if the socket has just been shut
down, SVC_RELEASE() drops the reference count to 0 and acquires a sleep
lock during destruction of the server side krpc structure.

This patch fixes the problem by moving the SVC_RELEASE() call in
nfsrv_checksequence() down a few lines to below where the mutex is released.

MFC after:	1 week
2020-09-16 02:25:18 +00:00
Mark Johnston
b4e07e3da5 Fix locking in uipc_accept().
Reported by:	cy
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-09-15 23:03:56 +00:00
Konstantin Belousov
081e36e760 Add tmpfs page cache read support.
Or it could be explained as lockless (for vnode lock) reads.  Reads
are performed from the node tn_obj object.  Tmpfs regular vnode object
lifecycle is significantly different from the normal OBJT_VNODE: it is
alive as far as ref_count > 0.

Ensure liveness of the tmpfs VREG node and consequently v_object
inside VOP_READ_PGCACHE by referencing tmpfs node in tmpfs_open().
Provide custom tmpfs fo_close() method on file, to ensure that close
is paired with open.

Add tmpfs VOP_READ_PGCACHE that takes advantage of all tmpfs quirks.
It is quite cheap in code size sense to support page-ins for read for
tmpfs even if we do not own tmpfs vnode lock.  Also, we can handle
holes in tmpfs node without additional efforts, and do not have
limitation of the transfer size.

Reviewed by:	markj
Discussed with and benchmarked by:	mjg (previous version)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D26346
2020-09-15 22:19:16 +00:00
Konstantin Belousov
4601f5f5ee Microoptimize tmpfs node ref/unref by using atomics.
Avoid tmpfs mount and node locks when ref count is greater than zero,
which is the case until node is being destroyed by unlink or unmount.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D26346
2020-09-15 22:13:21 +00:00
Konstantin Belousov
3c484f325e Convert page cache read to VOP.
There are several negative side-effects of not calling into VOP layer
at all for page cache reads.  The biggest is the missed activation of
EVFILT_READ knotes.

Also, it allows filesystem to make more fine grained decision to
refuse read from page cache.

Keep VIRF_PGREAD flag around, it is still useful for nullfs, and for
asserts.

Reviewed by:	markj
Tested by:	pho
Discussed with:	mjg
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D26346
2020-09-15 22:06:36 +00:00
Konstantin Belousov
888636655d vfs_subr.c: export io_hold_cnt and vn_read_from_obj().
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D26346
2020-09-15 22:00:58 +00:00
Konstantin Belousov
96474d2a3f Do not copy vp into f_data for DTYPE_VNODE files.
The pointer to vnode is already stored into f_vnode, so f_data can be
reused.  Fix all found users of f_data for DTYPE_VNODE.

Provide finit_vnode() helper to initialize file of DTYPE_VNODE type.

Reviewed by:	markj (previous version)
Discussed with:	freqlabs (openzfs chunk)
Tested by:	pho (previous version)
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D26346
2020-09-15 21:55:21 +00:00
Eric Joyner
a3b9a7366e e1000: Properly retain promisc flag
From Franco:
The iflib rewrite forced the promisc flag but it was not reported
to the system.  Noticed on a stock VM that went into unsolicited
promisc mode when dhclient was started during bootup.

PR:		248869
Submitted by:	Franco Fichtner <franco@opnsense.org>
Reviewed by:	erj@
MFC after:	3 days
2020-09-15 21:07:30 +00:00
Ed Maste
09860d44e4 bhyve: do not permit write access to VMCB / VMCS
Reported by:	Patrick Mooney
Submitted by:	jhb
Security:	CVE-2020-24718
2020-09-15 21:04:27 +00:00
Eric Joyner
467515a494 igb(4): Fix define and includes with RSS option enabled
This re-adds the opt_rss.h header to the driver and includes some
RSS-specific headers when RSS is defined.

PR:		249191
Submitted by:	Milosz Kaniewski <milosz.kaniewski@gmail.com>
MFC after:	3 days
2020-09-15 21:00:25 +00:00
Mark Johnston
2ac431003b ftpd: Exit during authentication if an error occurs after chroot().
admbug:		969
Security:	CVE-2020-7468
2020-09-15 20:54:18 +00:00
Brandon Bergren
9673f30503 [PowerPC64LE] Use correct in_masks table on LE to fix checksumming
Due to a check that should have been an endian check being an #if 0,
the wrong checksum mask table was being used on LE, which was causing
extreme strangeness in DNS resolution -- *some* hosts would be resolvable,
but most would not.

This fixes DNS resolution.

(I am committing some parts of the LE patchset ahead of time to reduce the
amount of work I have to do while committing the main patchset.)

Sponsored by:	Tag1 Consulting, Inc.
2020-09-15 20:47:33 +00:00
Brandon Bergren
1e936efbce [PowerPC64LE] Set up the powernv partition table correctly.
The partition table is always big endian.

Sponsored by:	Tag1 Consulting, Inc.
2020-09-15 20:25:38 +00:00
Konstantin Belousov
101d5b527a bhyve: intercept AMD SVM instructions.
Intercept and report #UD to VM on SVM/AMD in case VM tried to execute an
SVM instruction.  Otherwise, SVM allows execution of them, and instructions
operate on host physical addresses despite being executed in guest mode.

Reported by:	Maxime Villard <max@m00nbsd.net>
admbug:	972
CVE:	CVE-2020-7467
Reviewed by:	grehan, markj
Differential revision:	https://reviews.freebsd.org/D26313
2020-09-15 20:22:50 +00:00
Mark Johnston
448000279e Fix locking in uipc_accept().
This function wasn't converted to use the new locking protocol in
r333744.  Make it use the PCB lock for synchronizing connection state.

Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26300
2020-09-15 19:23:42 +00:00
Mark Johnston
ccdadf1a9b Simplify unix socket connection peer locking.
unp_pcb_owned_lock2() has some sharp edges and forces callers to deal
with a bunch of cases.  Simplify it:

- Rename to unp_pcb_lock_peer().
- Return the connected peer instead of forcing callers to load it
  beforehand.
- Handle self-connected sockets.
- In unp_connectat(), just lock the accept socket directly.  It should
  not be possible for the nascent socket to participate in any other
  lock orders.
- Get rid of connect_internal().  It does not provide any useful
  checking anymore.
- Block in unp_connectat() when a different thread is concurrently
  attempting to lock both sides of a connection.  This provides simpler
  semantics for callers of unp_pcb_lock_peer().
- Make unp_connectat() return EISCONN if the socket is already
  connected.  This fixes a race[1] when multiple threads attempt to
  connect() to different addresses using the same datagram socket.
  Upper layers will disconnect a connected datagram socket before
  calling the protocol connect's method, but there is no synchronization
  between this and protocol-layer code.

Reported by:	syzkaller [1]
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26299
2020-09-15 19:23:22 +00:00
Mark Johnston
ed92e1c78c Avoid an unnecessary malloc() when connecting dgram sockets.
The allocated memory is only required for SOCK_STREAM and SOCK_SEQPACKET
sockets.

Reviewed by:	kevans
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26298
2020-09-15 19:23:01 +00:00
Mark Johnston
f0317f868b Simplify unp_disconnect() callers.
In all cases, PCBs are unlocked after unp_disconnect() returns.  Since
unp_disconnect() may release the last PCB reference, callers may have to
bump the refcount before the call just so that they can release them
again.

Change unp_disconnect() to release PCB locks as well as connection
references; this lets us remove several refcount manipulations.  Tighten
assertions.

Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26297
2020-09-15 19:22:37 +00:00
Mark Johnston
4820bf6ac2 Rename unp_pcb_lock2().
unp_pcb_lock_pair() seems like a better name.  Also make it handle the
case where the two sockets are the same instead of making callers do it.
No functional change intended.

Reviewed by:	glebius, kevans, kib
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26296
2020-09-15 19:22:16 +00:00
Mark Johnston
5362170da7 Improve unix socket PCB refcounting.
- Use refcount_init().
- Define an INVARIANTS-only zone destructor to assert that various
  bits of PCB state aren't left dangling.
- Annotate unp_pcb_rele() with __result_use_check.
- Simplify control flow.

Reviewed by:	glebius, kevans, kib
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26295
2020-09-15 19:21:58 +00:00
Mark Johnston
d5cbccecd8 Update unix domain socket locking comments.
- Define a locking key for unpcb members.
- Rewrite some of the locking protocol description to make it less
  verbose and avoid referencing some subroutines which will be renamed.
- Reorder includes.

Reviewed by:	glebius, kevans, kib
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26294
2020-09-15 19:21:33 +00:00
Dimitry Andric
e588341d48 Vendor import of llvm-project branch release/11.x
llvmorg-11.0.0-rc2-91-g6e042866c30.
2020-09-15 18:55:37 +00:00
Kyle Evans
9e9d3e134b certctl: fix unprivileged mode
The first issue was lack of quoting around INSTALLFLAGS, which set it
incorrectly and produced an error on -M.

The second issue was that we weren't actually doing the install in
unprivileged mode, making it effectively useless. This was designed to pass
through the proper metalog/unpriv flags to install(1), so just let it
happen.

MFC after:	3 days
2020-09-15 17:13:29 +00:00
Edward Tomasz Napierala
c26391f4dd Move SV_ABI_ERRNO translation into linux-specific code, to simplify
the syscall path and declutter it a bit.  No functional changes intended.

Reviewed by:	kib (earlier version)
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26378
2020-09-15 16:41:21 +00:00
Stefan Eßer
160ea95362 src.conf.5: regen after r365753 2020-09-15 16:38:44 +00:00
Stefan Eßer
624b0c0457 Add descriptions of the WITH_(OUT)_GH_BC options that exist in -CURRENT
(default: WITH_GH_BC) and 12-STABLE (default: WITHOUT_GH_BC).

Since the new implementation of bc and dc is optionally available in
12-STABLE, I intend to MFC these descriptions for inclusion in 12.2.

MFC after:	3 days
2020-09-15 16:22:05 +00:00
Warner Losh
2215adc5ff Include sys/types.h here
It's included by header pollution in most of the compile
environments. However, in the standalone envirnment, it's not
included. Go ahead and include it always since the overhead is low and
it is simpler that way.

MFC After: 3 days
2020-09-15 15:21:29 +00:00
Andrew Turner
d6aa5fe5eb Use ATTR_DEFAULT in the arm64 locore.S
We can use ATTR_DEFAULT directly in locore.S as it fits within an orr
instruction operand.

Sponsored by:	Innovate UK
2020-09-15 14:15:04 +00:00
Mark Johnston
c6dce83da8 Fix some posixshmcontrol nits.
- Exit with an error if no path is specified.
- Man page typo.
- Error message typo.

Reviewed by:	kib
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D26376
2020-09-15 13:36:19 +00:00
Brandon Bergren
1d2a0dce33 [PowerPC] Remove obsolete MK_LOADER_FORCE_LE
In D12421, the ability to compile stand/ in little-endian was added, with the
intention to extend loader.kboot to run in Petitboot.

However, no further work was done, as the kernel then gained self-execution
capabilities as Petitboot was taught to load FreeBSD kernels directly.

The FreeBSD installer on powerpc64 (on POWER8 and POWER9) uses
/boot/etc/kboot.conf instead of loader.

As this option does nothing but cause stand/ to be miscompiled and actively
causes confusion, remove it.

(I have a functioning petitboot loader in my local tree, however, it turned
out to be quite inconvient to use due to the current petitboot plugin design
so I put it on hold.)

Reviewed by:	emaste, imp, jhibbits
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D26430
2020-09-15 04:22:28 +00:00
Warner Losh
0c97af56a7 We don't need the sc_ekeys_lock in standalone environment.
When we bring in geli into the boot loader, we are single threaded so
we don't have to worry about locking. We have no mutexes, and don't need
to use them, so comment it out.

MFC After: 3 days
2020-09-14 23:51:14 +00:00
Warner Losh
44a8153672 Don't do the busy dance in icee_open/close
We don't need to do the busy dance for this driver. It's handled by
destroy_dev() entirely. Since all we did was busy/unbusy in
open/close, just delete them. We therefore don't need to track closes
either.

Reviewed by: ian@
Differential Revision: https://reviews.freebsd.org/D26431
2020-09-14 23:30:04 +00:00
Warner Losh
45472826b9 Tweak what's visible in the standalone environment. We define offsetof
in stand.h typically, but when this is included we can define it
multiple times. However, we don't define bool in stand.h at the
moment, so allow it to be defined inside types.h when we're building
for the standalone environment.

MFC After: 3 days
2020-09-14 23:27:51 +00:00
Navdeep Parhar
bb60ba7e22 cxgbe(4): Get the count of FCS errors from the MAC and not MPS for T6 ports.
The MPS register on the T6 counts something other than FCS errors despite its
name.

MFC after:	3 days
Sponsored by:	Chelsio Communications
2020-09-14 22:15:54 +00:00
Ian Lepore
3c41bcdf29 Add product ID strings for a couple Microchip usb hubs. Also, update the
vendor ID string to say just "Microchip Technology" -- the buyout of
Standard Microsystems happened in 2012 and the SMC/SMSC names are pretty
much retired at this point.

PR:		241406
2020-09-14 17:33:28 +00:00
Andrew Turner
e7b841ae27 Cleanups for gprof:
* Remove identical or almost identical headers
 * Only build aout.c on amd64 and i386. None of the the other current
   architectures ever supported running a.out binaries
 * Enable on all architectures

Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D26369
2020-09-14 16:18:53 +00:00
Andrew Turner
2a6803de1c Use MACHINE_CPUARCH when checking for arm64
Use MACHINE_CPUARCH with arm64 (aarch64) when we build code that could run
on any 64-bit Arm instruction set. This will simplify checks in downstream
consumers targeting prototype instruction sets.

The only place we check for MACHINE_ARCH == aarch64 is when building the
device tree blobs. As these are targeting current generation ISAs.

Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D26370
2020-09-14 16:12:28 +00:00
Glen Barber
5fb8eca870 Fix setting RELENGDIR when release.sh is called from an external
script.

Sponsored by:	Rubicon Communications, LLC (netgate.com)
2020-09-14 15:58:10 +00:00
Brandon Bergren
9e4c35f867 stand/ficl 64-bit compatibility
Currently, the only thing that prevents a functioning 64-bit FICL build is
a few integer types that were intended to be fixed-width.

Changing them to C99 integer types allows building a functioning 64-bit
FICL.

While this isn't applicable to the default settings of any in-tree loaders,
it is necessary for a future Petitboot loader, due to the requirement that
it be compiled as a 64-bit program.

Reviewed by:	tsoome, imp (earlier revision)
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D26364
2020-09-14 15:48:30 +00:00
Brandon Bergren
115c987b3f [PowerPC] Make cpu frequency detection endian-independent
On ibm,extended-clock-frequency, ensure we be64toh() the value.

On clock-frequency, remove the right-shifting hack (which was needed due to
reading a 32 bit value into a 64 bit variable) and switch to OF_getencprop()
for reading (which will handle endian conversion internally.)

Reviewed by:	jhibbits (in irc)
Sponsored by:	Tag1 Consulting, Inc.
2020-09-14 15:20:37 +00:00
Gordon Tetlow
bfdd0a34ad Partially revert r346018 and use the if/then construct instead of shell.
There are a couple of places in the tree that directly parse the newvers.sh
script looking for the BRANCH variable. I found two locations, one in
release/Makefile and the other in bin/freebsd-version/Makefile.

While there is a good argument that BRANCH_OVERRIDE should properly
propagate in those circumstances and the new behavior is thus better, the
reality is this change broke freebsd-update's ability to find timestamps in
binaries and resulted in a large number of gratuitous changes.

Reported by:	freebsd-update
Discussed with:	cperciva
MFC after:	1 day
2020-09-14 14:45:30 +00:00
Hans Petter Selasky
39b0f9c389 Poll statistics more frequently in mlx5en(4).
This makes traffic steering algorithms more accurate.

MFC after:	1 week
Submitted by:	gallatin @
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-09-14 14:24:54 +00:00
Edward Tomasz Napierala
2ccf8a827c Skip armv7 bectl tests on CI; they deadlock (""KSTACK_PAGES is 2").
PR:		249229
Sponsored by:	DARPA
2020-09-14 10:35:39 +00:00
Edward Tomasz Napierala
fecb19e431 Move td_softdep_cleanup() from userret() to ast(); it's infrequent
at best.  The schedule_cleanup() function already sets TDF_ASTPENDING.

Reviewed by:	kib, mckusick
Tested by:	pho
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26375
2020-09-14 10:17:07 +00:00
Edward Tomasz Napierala
60f083efe2 Move TDP_GEOM check from userret() to ast(); this code path is quite
infrequent.

Reviewed by:	kib
No objections:	mav
Tested by:	pho
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26374
2020-09-14 10:14:03 +00:00
Edward Tomasz Napierala
30d158eecc Move racct/rctl throttling from userret() to ast(). There's no reason
for it to sit in the syscall fast path.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26368
2020-09-14 09:44:24 +00:00