]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoFix multiple denial of service in ntpd.
Gordon Tetlow [Thu, 19 Mar 2020 16:52:41 +0000 (16:52 +0000)]
Fix multiple denial of service in ntpd.

Approved by: so
Security: FreeBSD-SA-20:09.ntp

4 years agoFix kernel memory disclosure with nested jails.
Gordon Tetlow [Thu, 19 Mar 2020 16:51:33 +0000 (16:51 +0000)]
Fix kernel memory disclosure with nested jails.

Approved by: so
Security: FreeBSD-SA-20:08.jail
Security: CVE-2020-7453

4 years agoFix incorrect user-controlled pointer use in epair.
Gordon Tetlow [Thu, 19 Mar 2020 16:50:36 +0000 (16:50 +0000)]
Fix incorrect user-controlled pointer use in epair.

Approved by: so
Security: FreeBSD-SA-20:07.epair
Security: CVE-2020-7452

4 years agoFix insufficient ixl(4) ioctl(2) privilege checking.
Gordon Tetlow [Thu, 19 Mar 2020 16:49:32 +0000 (16:49 +0000)]
Fix insufficient ixl(4) ioctl(2) privilege checking.

Approved by: so
Security: FreeBSD-SA-20:06.if_ixl_ioctl
Security: CVE-2019-15877

4 years agoFix insufficient oce(4) ioctl(2) privilege checking.
Gordon Tetlow [Thu, 19 Mar 2020 16:48:29 +0000 (16:48 +0000)]
Fix insufficient oce(4) ioctl(2) privilege checking.

Approved by: so
Security: FreeBSD-SA-20:05.if_oce_ioctl
Security: CVE-2019-15876

4 years agoFix TCP IPv6 SYN cache kernel information disclosure.
Gordon Tetlow [Thu, 19 Mar 2020 16:46:01 +0000 (16:46 +0000)]
Fix TCP IPv6 SYN cache kernel information disclosure.

Approved by: so
Security: FreeBSD-SA-20:04.tcp
Security: CVE-2020-7451

4 years agoFix incorrect checksum calculations with IPv6 extension headers.
Gordon Tetlow [Thu, 19 Mar 2020 16:43:37 +0000 (16:43 +0000)]
Fix incorrect checksum calculations with IPv6 extension headers.

Approved by: so
Security: FreeBSD-EN-20:06.ipv6

4 years agoFix packet forwarding performance in mlx5en(4) driver.
Gordon Tetlow [Thu, 19 Mar 2020 16:41:29 +0000 (16:41 +0000)]
Fix packet forwarding performance in mlx5en(4) driver.

Approved by: so
Security: FreeBSD-EN-20:05.mlx5en

4 years agoFix misleading log messages upon successful sshd login.
Gordon Tetlow [Thu, 19 Mar 2020 16:34:11 +0000 (16:34 +0000)]
Fix misleading log messages upon successful sshd login.

Approved by: so
Security: FreeBSD-EN-20:03.sshd

4 years agoAdd UPDATING entries and bump version.
Gordon Tetlow [Tue, 28 Jan 2020 18:58:37 +0000 (18:58 +0000)]
Add UPDATING entries and bump version.

Approved by: so

4 years agoFix kernel stack data disclosure
Gordon Tetlow [Tue, 28 Jan 2020 18:57:45 +0000 (18:57 +0000)]
Fix kernel stack data disclosure

Reported by: Ilja Van Sprundel
Approved by: so
Security: FreeBSD-SA-20:03.thrmisc
Security: CVE-2019-15875

4 years agoFix libfetch buffer overflow
Gordon Tetlow [Tue, 28 Jan 2020 18:55:25 +0000 (18:55 +0000)]
Fix libfetch buffer overflow

Reported by: Duncan Overbruck
Approved by: so
Security: FreeBSD-SA-20:01.libfetch
Security: CVE-2020-7450

4 years agoFix imprecise ordering of SSP canary initialization
Gordon Tetlow [Tue, 28 Jan 2020 18:53:14 +0000 (18:53 +0000)]
Fix imprecise ordering of SSP canary initialization

Submitted by: Kyle Evans
Approved by: so
Security: FreeBSD-EN-20:01.ssp

4 years agoAdd UPDATING entries and bump version numbers.
Gordon Tetlow [Tue, 12 Nov 2019 18:13:51 +0000 (18:13 +0000)]
Add UPDATING entries and bump version numbers.

Approved by: so

4 years agoFix Machine Check Exception on Page Size Change.
Gordon Tetlow [Tue, 12 Nov 2019 18:13:04 +0000 (18:13 +0000)]
Fix Machine Check Exception on Page Size Change.

Approved by: so
Security: FreeBSD-SA-19:25.mcepsc
Security: CVE-2018-12207

4 years agoFix UEFI Loader Memory Fragmentation.
Gordon Tetlow [Tue, 12 Nov 2019 18:10:26 +0000 (18:10 +0000)]
Fix UEFI Loader Memory Fragmentation.

Approved by: so
Security: FreeBSD-EN-19:19.loader

4 years ago- Switch releng/12.1 from RC2 to RELEASE.
Glen Barber [Fri, 1 Nov 2019 00:00:17 +0000 (00:00 +0000)]
- Switch releng/12.1 from RC2 to RELEASE.
- Add the anticipated 12.1-RELEASE date to UPDATING.
- Set a static __FreeBSD_version.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoMFS r354090:
Michael Tuexen [Fri, 25 Oct 2019 18:46:53 +0000 (18:46 +0000)]
MFS r354090:

Ensure that the flags indicating IPv4/IPv6 are not changed by failing
bind() calls. This would lead to inconsistent state resulting in a panic.
A fix for stable/11 was committed in
https://svnweb.freebsd.org/base?view=revision&revision=338986

Reported by: syzbot+2609a378d89264ff5a42@syzkaller.appspotmail.com
Obtained from: jtl@
Sponsored by: Netflix, Inc.
Approved by: re (gjb@)

4 years agoMFC r353776 (dim):
Glen Barber [Mon, 21 Oct 2019 17:17:21 +0000 (17:17 +0000)]
MFC r353776 (dim):
 Follow up on r351916 by also bumping the version suffix to 12.1 in
 Makefile.libcompat.

Approved by: re (kib)
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years ago- Update releng/12.1 from RC1 to RC2 as part of the 12.1-RELEASE
Glen Barber [Fri, 18 Oct 2019 00:00:11 +0000 (00:00 +0000)]
- Update releng/12.1 from RC1 to RC2 as part of the 12.1-RELEASE
  cycle.
- Update the dvd1.iso pkg(8) configuration to use the release_1
  package set to populate the dvd.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoMFC r353675 from stable-12 (r353651-r353652 from head)...
Ian Lepore [Thu, 17 Oct 2019 16:20:24 +0000 (16:20 +0000)]
MFC r353675 from stable-12 (r353651-r353652 from head)...

r353651:
Relax the sdhci(4) check that filters out the 1.8v voltage option unless
the slot is flagged as 'embedded'.

The features related to embedded and shared slots were added in v3.0 of
the sdhci spec.  Hardware prior to v3 sometimes supported 1.8v on non-
removable devices in embedded systems, but had no way to indicate that
via the standard sdhci registers (instead they use out of band metadata
such as FDT data).

This change adds the controller specification version to the check for
whether to filter out the 1.8v selection.  On older hardware, the 1.8v
option is allowed to remain.  On 3.0 or later it still requires the
embedded-slot flag to remain.

This is part of the fix for PR 241301 (eMMC not detected on Beaglebone).
Changes to the sdhci_ti driver are also needed for a full fix.

PR:           241301

r353652:
Revert r351218 (by manu).  While the changes in r351218 appear to be (and
should be) correct, they lead to the eMMC on a Beaglebone failing to work
in some situations.

The TI sdhci hardware is kind of strange.  The first device inherently
supports 1.8v and 3.3v and the abililty to switch between them, and the
other two devices must be set to 1.8v in the sdhci power control register to
operate correctly, but doing so actually makes them run at 3.3v (unless an
external level-shifter is present in the signal path).  Even the 1.8v on the
first device may actually be 3.3v (or any other value), depending on what
voltage is fed to the VDDS1-VDDS7 power supply pins on the am335x chip.

Another strange quirk is that the convention for am335x sdhci drivers in
linux and uboot and the am335x boot ROM seems to be to set the voltage in
the sdhci capabilities register to 3.0v even though the actual voltage is
3.3v.  Why this is done is a complete mystery to me, but it seems to be
required for correct operation.

If we had complete modern support for the am335x chip we could get the
actual voltages from the FDT data and the regulator framework.  But our
am335x code currently doesn't have any regulator framework support.
Reverting to the prior code will get the popular Beaglebone boards working
again.

This is part of the fix for PR 241301, but also requires r353651 for a
complete fix.

PR:           241301
Discussed with: manu

Approved by: re(kib)

4 years agoMFC r353660: ixgbe: Disable EEE for backplane X550EM_X
Eric Joyner [Wed, 16 Oct 2019 21:46:49 +0000 (21:46 +0000)]
MFC r353660: ixgbe: Disable EEE for backplane X550EM_X

This prevents a kernel panic when configuring EEE on X552 devices.

PR: 240320
Approved by: re@ (gjb@)
Sponsored by: Intel Corporation

4 years agoMFS r353475, r353553:
Mark Johnston [Tue, 15 Oct 2019 16:27:04 +0000 (16:27 +0000)]
MFS r353475, r353553:
Fix a couple of bugs around handling of PGA_WRITEABLE.

Approved by: re (kib)

4 years agoMFS r353563:
Michael Tuexen [Tue, 15 Oct 2019 16:05:55 +0000 (16:05 +0000)]
MFS r353563:

Ensure that local variables are reset to their initial value when
dealing with error cases in a loop over all remote addresses.
This issue was found and reported by OSS_Fuzz in:

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18080
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18086
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18121
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18163

MFS r353567:

Fix mergeinfo for r353563.

Approved by: re(gjb)

4 years agoMFS r353554:
Mark Johnston [Tue, 15 Oct 2019 14:45:33 +0000 (14:45 +0000)]
MFS r353554:
Fix handling of empty SCM_RIGHTS messages.

Approved by: re (kib)

4 years agoloader.efi: efipart needs to use ioalign
Toomas Soome [Tue, 15 Oct 2019 06:19:33 +0000 (06:19 +0000)]
loader.efi: efipart needs to use ioalign

UEFI specification 2.7A, EFI_BLOCK_IO_PROTOCOL, page 566.

The ioalign property does define the alignment of data buffer.

If the alignment is required and our buffer is not aligned, or if
the data buffer is not multiple of Blocksize, we need to use bounce buffer
to perform the block IO. This is much like with BIOS version, except
there the INT13 needs buffer to be located in low memory.

MFS: r353501
MFC: r347195,350654-350656,351274,351630,351637,352421,352439,352443-352446,352451

Approved by: re (gjb)

4 years agoMFS r353450:
Glen Barber [Sat, 12 Oct 2019 17:15:32 +0000 (17:15 +0000)]
MFS r353450:
 MFC r353348:
  Connect the libucl(3) manual page to the build.

Approved by: re (kib)
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoUpdate releng/12.1 to RC1 as part of the 12.1-RELEASE cycle.
Glen Barber [Fri, 11 Oct 2019 00:02:00 +0000 (00:02 +0000)]
Update releng/12.1 to RC1 as part of the 12.1-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoMFS r353402:
Michael Tuexen [Thu, 10 Oct 2019 18:39:11 +0000 (18:39 +0000)]
MFS r353402:

In r343587 a simple port filter as sysctl tunable was added to siftr.
The new sysctl was not added to the siftr.4 man page at the time.
This updates the man page, and removes one left over trailing whitespace.

Submitted by: Richard Scheffenegger
Differential Revision: https://reviews.freebsd.org/D21619
Reviewed by: bcr@
Approved by: re (gjb@)

4 years agoMFS r353409:
Glen Barber [Thu, 10 Oct 2019 18:27:05 +0000 (18:27 +0000)]
MFS r353409:
 MFC r353320:
  Rework the logic for installing the pkg(8) configuration.

  'quarterly' package sets do not exist for head, so explicitly
  install the 'latest' configuration file there.  Otherwise,
  fall back to the original conditional evaluation to determine
  if the 'latest' or 'quarterly' configuration file should be
  installed.

Approved by: re (kib)
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoMFS r353395:
Michael Tuexen [Thu, 10 Oct 2019 18:19:22 +0000 (18:19 +0000)]
MFS r353395:

Add missing input validation. This could result in reading from
uninitialized memory.
The issue was found by OSS-Fuzz for usrsctp  and reported in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17780

MFS r353396:

Cleanup sctp_asconf_error_response() and ensure that the parameter
is padded as required. This fixes the followig bug reported by
OSS-Fuzz for the usersctp stack:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17790

MFS r353397:

When skipping the address parameter, take the padding into account.

MFS r353398:

Fix the adding of padding to COOKIE-ECHO chunks.

Thanks to Mark Wodrich who found this issue while fuzz testing the
usrsctp stack and reported the issue in
https://github.com/sctplab/usrsctp/issues/382

MFS r353399:

Plumb an mbuf leak found by Mark Wodrich from Google by fuzz testing the
userland stack and reporting it in:
https://github.com/sctplab/usrsctp/issues/396

MFS r353400:

Fix a use after free bug when removing remote addresses.
This bug was found by OSS-Fuzz and reported in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18004

MFS r353401:

Plumb an mbuf leak in a code path that should not be taken. Also avoid
that this path is taken by setting the tail pointer correctly.
There is still bug related to handling unordered unfragmented messages
which were delayed in deferred handling.
This issue was found by OSS-Fuzz testing the usrsctp stack and reported
in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17794

MFS r353403:

Validate length before use it, not vice versa.
r353060 should have contained this...
This fixes
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18070

Approved by: re (gjb@)

4 years agoMFS r353405:
Hans Petter Selasky [Thu, 10 Oct 2019 16:04:43 +0000 (16:04 +0000)]
MFS r353405:
Fix regression issue after r352989:

As noted by the commit message, callouts are now persistant
and should not be in the auto-zero section of the RQ's and SQ's.
This fixes an assert when using the TX completion event
factor feature with mlx5en(4).

Found by: gallatin@
Sponsored by: Mellanox Technologies
Approved by: re (gjb)

4 years agoMFC r353065, MFS12 353385:
Konstantin Belousov [Thu, 10 Oct 2019 15:19:49 +0000 (15:19 +0000)]
MFC r353065, MFS12 353385:
tmpfs_readdir(): unlock the locked node.

Approved by: re (gjb)

4 years agoMFS r353177:
Hans Petter Selasky [Mon, 7 Oct 2019 15:29:37 +0000 (15:29 +0000)]
MFS r353177:
Add quirk for XHCI(4) controllers to support USB control transfers
above 1Kbyte.  It might look like some XHCI(4) controllers do not
support when the USB control transfer is split using a link TRB. The
next NORMAL TRB after the link TRB is simply failing with XHCI error
code 4. The quirk ensures we allocate a 64Kbyte buffer so that the
data stage TRB is not broken with a link TRB.

Found at: EuroBSDcon 2019
Sponsored by: Mellanox Technologies
Approved by: re (gjb)

4 years agoMFS r353276:
Mark Johnston [Mon, 7 Oct 2019 15:26:40 +0000 (15:26 +0000)]
MFS r353276:
Disallow fcntl(F_READAHEAD) when the vnode is not a regular file.

Approved by: re (gjb)

4 years agoMFS r353173:
Hans Petter Selasky [Mon, 7 Oct 2019 15:25:00 +0000 (15:25 +0000)]
MFS r353173:
Increase the maximum user-space buffer size from 256kBytes to 32MBytes for
libusb. This is useful for speeding up large data transfers while reducing
the interrupt rate.

Found at: EuroBSDcon 2019
Sponsored by: Mellanox Technologies
Approved by: re (gjb)

4 years agoMFS r353169:
Hans Petter Selasky [Mon, 7 Oct 2019 15:03:24 +0000 (15:03 +0000)]
MFS r353169:
The maximum TD size is 31 and not 15.

Found at: EuroBSDcon 2019
Sponsored by: Mellanox Technologies
Approved by: re (gjb)

4 years agoMFS r353184, r353186, r353188, r353190, r353192, r353194, r353196, r353198,
Hans Petter Selasky [Mon, 7 Oct 2019 13:13:06 +0000 (13:13 +0000)]
MFS r353184, r353186, r353188, r353190, r353192, r353194, r353196, r353198,
r353200, r353203, r353205, r353207, r353209, r353211, r353213, r353215,
r353217, r353219, r353221, r353223, r353225, r353227, r353229, r353231,
r353233, r353235, r353237, r353239, r353241, r353243, r353245, r353247,
r353249, r353251, r353253, r353255, r353257, r353259, r353261, r353263,
r353265 and r353267:

Update mlx5core, mlx5en(4) and mlx5ib(4).

Sponsored by: Mellanox Technologies
Approved by: re (gjb)

MFC r352956:
Fix reported max SGE calculation in mlx5ib.

Add the 512 bytes limit of RDMA READ and the size of remote address to the max
SGE calculation.

Linux commit: 288c01b746aa

MFC r352957:
Update warning and error print formats in mlx5ib.

MFC r352958:
Make sure the number of IRQ vectors doesn't exceed 256 in mlx5core.
The "intr" field in "struct mlx5_ifc_eqc_bits" is only 8 bits wide.

MFC r352959:
Check return value of mlx5_vector2eqn() function in mlx5en.

MFC r352960:
Fix for missing cleanup code in error case in mlx5en.

MFC r352961:
Implement macro for asserting priv lock in mlx5en.

MFC r352962:
Add support for Multi-Physical Function Switch, MPFS, in mlx5en.

MPFS is a logical switch in the Mellanox device which forward packets
based on a hardware driven L2 address table, to one or more physical-
or virtual- functions. The physical- or virtual- function is required
to tell the MPFS by using the MPFS firmware commands, which unicast
MAC addresses it is requesting from the physical port's traffic.
Broadcast and multicast traffic however, is copied to all listening
physical- and virtual- functions and does not need a rule in the MPFS
switching table.

Linux commit: eeb66cdb682678bfd1f02a4547e3649b38ffea7e

MFC r352963:
Cleanup naming of IRQ vectors in mlx5en.
Remove unused IRQ naming functions and arrays.

MFC r352964:
Export channel IRQ number as part of the "hw_ctx_debug" sysctl(8) in mlx5en(4).

MFC r352965:
Correct and update some counter names in mlx5en(4).

MFC r352966:
Add port module event software counters in mlx5core.
While at it, fixup PME based on latest PRM defines.

MFC r352967:
Make the mlx5_vsc_wait_on_flag(9) function global.

MFC r352968:
Move mlx5_ifc_vsc_space_bits and mlx5_ifc_vsc_addr_bits to mlx5_ifc.h.

MFC r352969:
Use the MLX5_VSC_DOMAIN_SEMAPHORES constant instead of hand-rolled symbol
in mlx5core.

MFC r352970:
Define MLX5_VSC_DOMAIN_SCAN_CRSPACE.

MFC r352971:
Read rege map from crdump scan space in mlx5core.

MFC r352972:
Remove no longer needed fwdump register tables from mlx5core.

MFC r352973:
Add missing blank line at the end of the print in mlx5core.

MFC r352974:
Add proper print in case of 0x0 health syndrome in mlx5core.

In case of health counter fails to increment it indicates a bad device health.
In case when the syndrome indicated by firmware is 0x0, this indicates that
firmware is unable to respond to initialization segment reads.
Add proper print in this case.

MFC r352975:
Unify prints in mlx5core.

All prints in mlx5core should use on of the macros:
mlx5_core_err/dbg/warn

MFC r352976:
Unify prints in mlx5en(4).

All prints in mlx5en(4) should use on of the macros:
mlx5_en_err/dbg/warn

MFC r352977:
Sort the ports registers definitions numerically in mlx5core.

MFC r352978:
Add definition for the Port Buffer Status Register in mlx5core.

MFC r352979:
Update definitons for PPTB and PBMC registers layouts in mlx5core.

MFC r352980:
Add mlx5e_dbg() compatibility macro.

MFC r352981:
Import Linux code to query/set buffer state in mlx5en(4).

MFC r352982:
Add support for buffer parameter manipulations in mlx5en(4).

The following sysctls are added:
dev.mce.N.conf.qos.cable_length
dev.mce.N.conf.qos.buffers_size
dev.mce.N.conf.qos.buffers_prio

MFC r352983 and r353001:
Move EEPROM information query from a sysctl in mlx5en(4) to an ioctl
in mlx5core. The EEPROM information is not only a property of the
mlx5en(4) driver.

MFC r352984:
Add the ability to query the EEPROM information in mlx5tool(8).

MFC r352985:
Add sysctl(8) to get and set forward error correction, FEC, configuration
in mlx5en(4).

MFC r352986:
Return an error from ioctl(MLX5_FW_RESET) if reset was rejected in mlx5core.

MFC r352987:
Remove mkey_be from channel structure in mlx5en(4).
Use value from priv structure instead.
This saves some space in the channel structure.

MFC r352988:
Remove unused cpu field from channel structure in mlx5en(4).

MFC r352989:
Seal transmit path with regards to using destroyed mutex in mlx5en(4).

It may happen during link down that the running state may be observed
non-zero in the transmit routine, right before the running state is
cleared. This may end up using a destroyed mutex.

Make all channel mutexes and callouts persistant.

Preserve receive and send queue statistics during link toggle.

MFC r352991 and 353000:
Wait for FW readiness before initializing command interface in mlx5core.

Before attempting to initialize the command interface we must wait till
the fw_initializing bit is clear.

If we fail to meet this condition the hardware will drop our
configuration, specifically the descriptors page address.  This scenario
can happen when the firmware is still executing an FLR flow and did not
finish yet so the driver needs to wait for that to finish.

Linux commits:
6c780a0267b8
b8a92577f4be.

MFC r352992:
Use size_t for byte_to_write variable when comparing to eeprom_info_out_len
which is also size_t in mlx5tool(8).

MFC r352993:
Randomize the delay when waiting for VSC flag in mlx5core.

The PRM suggests random 0 - 10ms to prevent multiple waiters on the same
interval in order to avoid starvation.

MFC r352994:
Improve mlx5_fwdump_prep logging in mlx5core.

MFC r352995:
Only update lossy buffers config when manual PFC configuration was done
in mlx5en(4).

MFC r352996:
Add print to show user a reason for rejecting buffer size change in mlx5en(4).

MFC r352997:
Print numeric error_type and module_status in mlx5core
in case the strings are not available.

MFC r352998:
Bump driver version for mlx5core, mlx5en(4) and mlx5ib(4).

4 years agoMFS r353182:
Hans Petter Selasky [Mon, 7 Oct 2019 12:54:28 +0000 (12:54 +0000)]
MFS r353182:
Make sure the transmit loop doesn't get starved in ipoib.

When the software send queue gets filled up, callbacks to
if_transmit will stop. Make sure the transmit callback
routine checks the send queue and outputs any remaining
mbufs. Else the remaining mbufs may simply sit in the
output queue blocking the transmit path.

Sponsored by: Mellanox Technologies
Approved by: re (gjb)

4 years agoMFS r353180:
Hans Petter Selasky [Mon, 7 Oct 2019 12:51:36 +0000 (12:51 +0000)]
MFS r353180:
Notify all sleeping threads of device removal in krping.
Implement d_purge for krping_cdevsw.

Submitted by: slavash@
Sponsored by: Mellanox Technologies
Approved by: re (gjb)

4 years agoMFS r353157: tuntap(4): loosen up tunclose restrictions
Kyle Evans [Mon, 7 Oct 2019 02:57:00 +0000 (02:57 +0000)]
MFS r353157: tuntap(4): loosen up tunclose restrictions

Realistically, this cannot work. We don't allow the tun to be opened twice,
so it must be done via fd passing, fork, dup, some mechanism like these.
Applications demonstrably do not enforce strict ordering when they're
handing off tun devices, so the parent closing before the child will easily
leave the tun/tap device in a bad state where it can't be destroyed and a
confused user because they did nothing wrong.

Concede that we can't leave the tun/tap device in this kind of state because
of software not playing the TUNSIFPID game, but it is still good to find and
fix this kind of thing to keep ifconfig(8) up-to-date and help ensure good
discipline in tun handling.

Approved by: re (gjb)

4 years agoMFS r353106:
Mark Johnston [Fri, 4 Oct 2019 16:36:09 +0000 (16:36 +0000)]
MFS r353106:
Implement pmap_page_is_mapped() correctly on arm64 and riscv.

Approved by: re (kib)

4 years agoMFS r353032:
Andrew Turner [Fri, 4 Oct 2019 14:10:56 +0000 (14:10 +0000)]
MFS r353032:

Check the vfs option length is valid before accessing through

When a VFS option passed to nmount is present but NULL the kernel will
place an empty option in its internal list. This will have a NULL
pointer and a length of 0. When we come to read one of these the kernel
will try to load from the last address of virtual memory. This is
normally invalid so will fault resulting in a kernel panic.

Fix this by checking if the length is valid before dereferencing.

Approved by: re (kib)
Sponsored by: DARPA, AFRL

4 years agoUpdate releng/12.1 to BETA3 as part of the 12.1-RELEASE cycle.
Glen Barber [Fri, 4 Oct 2019 00:04:21 +0000 (00:04 +0000)]
Update releng/12.1 to BETA3 as part of the 12.1-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoMerge r353031 from stable/12:
Dimitry Andric [Thu, 3 Oct 2019 16:22:56 +0000 (16:22 +0000)]
Merge r353031 from stable/12:

Pull in r357528 from upstream llvm trunk (by Craig Topper):

  [X86] Check MI.isConvertibleTo3Addr() before calling
  convertToThreeAddress in X86FixupLEAs.

  X86FixupLEAs just assumes convertToThreeAddress will return nullptr
  for any instruction that isn't convertible.

  But the code in convertToThreeAddress for X86 assumes that any
  instruction coming in has at least 2 operands and that the second one
  is a register. But those properties aren't guaranteed of all
  instructions. We should check the instruction property first.

Pull in r365720 from upstream llvm trunk (by Craig Topper):

  [X86] Don't convert 8 or 16 bit ADDs to LEAs on Atom in FixupLEAPass.

  We use the functions that convert to three address to do the
  conversion, but changing an 8 or 16 bit will cause it to create a
  virtual register. This can't be done after register allocation where
  this pass runs.

  I've switched the pass completely to a white list of instructions
  that can be converted to LEA instead of a blacklist that was
  incorrect. This will avoid surprises if we enhance the three address
  conversion function to include additional instructions in the future.

  Fixes PR42565.

This should fix assertions/segfaults when compiling certain ports with
CPUTYPE=atom.

Approved by: re (kib)
PR: 240928

4 years agoMFS r353051:
Mark Johnston [Thu, 3 Oct 2019 15:23:38 +0000 (15:23 +0000)]
MFS r353051:
Add IFLIB_SINGLE_IRQ_RX_ONLY.

PR: 239118
Approved by: re (gjb)

4 years agoMFS12 r353047:
Glen Barber [Thu, 3 Oct 2019 14:41:20 +0000 (14:41 +0000)]
MFS12 r353047:
 MFC r353004, r353012:
 r353004:
  Explicitly add opensolaris_load="YES" to loader.conf through the
  installer when installing the system on a ZFS root filesystem.

  For arm64, zfs_load="YES" does not add opensolaris.ko as a kld
  dependency, so add it explicitly to prevent boot-time failures
  out-of-box.

 r353012:
  Add a comment explaining why the opensolaris_load line in loader.conf
  is explicitly added.

PR: 240478
Approved by: re (kib)
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoMFS r353041: fdt_slicer: bump to SI_ORDER_THIRD following r347183
Kyle Evans [Thu, 3 Oct 2019 14:27:04 +0000 (14:27 +0000)]
MFS r353041: fdt_slicer: bump to SI_ORDER_THIRD following r347183

r347183 bumped GEOM classes to SI_ORDER_SECOND to resolve a race between
them and the initialization of devsoftc.mtx in devinit, but missed this
dependency on g_flashmap that may now lose the race against GEOM
classes/g_init.

There's a great comment that describes the situation that has also been
updated with the new ordering of GEOM classes.

Approved by: re (kib)

4 years agoMFS r352509:
Michael Tuexen [Thu, 3 Oct 2019 13:30:48 +0000 (13:30 +0000)]
MFS r352509:

Only allow a SCTP-AUTH shared key to be updated by the application
if it is not deactivated and not used.
This avoids a use-after-free problem.

MFS r352674:

Fix the handling of invalid parameters in ASCONF chunks.
Thanks to Mark Wodrich from Google for reproting the issue in
https://github.com/sctplab/usrsctp/issues/376
for the userland stack.

MFS r352675:

Cleanup the RTO calculation and perform some consistency checks
before computing the RTO.
This should fix an overflow issue reported by Felix Weinrank in
https://github.com/sctplab/usrsctp/issues/375
for the userland stack and found by running a fuzz tester.

MFS r352676:

Don't hold the info lock when calling sctp_select_a_tag().
This avoids a double lock bug in the NAT colliding state processing
of SCTP. Thanks to Felix Weinrank for finding and reporting this issue in
https://github.com/sctplab/usrsctp/issues/374
He found this bug using fuzz testing.

MFS r353034:

Plumb a memory leak.
Thanks to Felix Weinrank for finding this issue using fuzz testing
and reporting it for the userland stack:
https://github.com/sctplab/usrsctp/issues/378

MFS r353036:

Don't use stack memory which is not initialized.
Thanks to Mark Wodrich for reporting this issue for the userland stack in
https://github.com/sctplab/usrsctp/issues/380
This issue was also found for usrsctp by OSS-fuzz in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17778

Approved by: re (kib@)

4 years agoMFS r352673:
Michael Tuexen [Thu, 3 Oct 2019 12:26:55 +0000 (12:26 +0000)]
MFS r352673:

When the RACK stack computes the space for user data in a TCP segment,
it wasn't taking the IP level options into account. This patch fixes this.
In addition, it also corrects a KASSERT and adds protection code to assure
that the IP header chain and the TCP head fit in the first fragment as
required by RFC 7112.

MFS: r353035:

RFC 7112 requires a host to put the complete IP header chain
including the TCP header in the first IP packet.
Enforce this in tcp_output(). In addition make sure that at least
one byte payload fits in the TCP segement to allow making progress.
Without this check, a kernel with INVARIANTS will panic.
This issue was found by running an instance of syzkaller.

Approved by: re (kib@)
Reviewed by: rrs@ (r352673), jtl@ (r353035)
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D21665
Differential Revision: https://reviews.freebsd.org/D21666

4 years agoMFS r352672:
Michael Tuexen [Thu, 3 Oct 2019 11:20:56 +0000 (11:20 +0000)]
MFS r352672:

When processing an incoming IPv6 packet over the loopback interface which
contains Hop-by-Hop options, the mbuf chain is potentially changed in
ip6_hopopts_input(), called by ip6_input_hbh().
This can happen, because of the the use of IP6_EXTHDR_CHECK, which might
call m_pullup().
So provide the updated pointer back to the called of ip6_input_hbh() to
avoid using a freed mbuf chain inip6_input().

Approved by: re (kib@)
Reviewed by: markj@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D21664

4 years agoMFC r352867: Add support for ps -H on corefiles in libkvm
Mike Karels [Thu, 3 Oct 2019 02:51:48 +0000 (02:51 +0000)]
MFC r352867: Add support for ps -H on corefiles in libkvm

Add support for kernel threads in kvm_getprocs() and the underlying
kvm_proclist() in libkvm when fetching from a kernel core file. This
has been missing/needed for several releases, when kernel threads became
normal threads.  The loop over the processes now contains a sub-loop for
threads, which iterates beyond the first thread only when threads are
requested.  Also set some fields such as tid that were previously
uninitialized.

Approved by: re (gjb)
Sponsored by:   Forcepoint LLC

4 years agoMFS12 r352896: vt: fix problems with trying to switch to a closed VT
Andriy Gapon [Wed, 2 Oct 2019 13:36:54 +0000 (13:36 +0000)]
MFS12 r352896: vt: fix problems with trying to switch to a closed VT

Approved by: re (gjb)

4 years agoMFS12 r352721: print summary line for space estimate of zfs send from bookmark
Andriy Gapon [Wed, 2 Oct 2019 13:25:28 +0000 (13:25 +0000)]
MFS12 r352721: print summary line for space estimate of zfs send from bookmark

This should have been merged as a part of r352901 but I missed it.

Approved by: re (gjb)

4 years agoFix a regression introduced in r344601, and work properly with the
Sean Eric Fagan [Tue, 1 Oct 2019 18:05:51 +0000 (18:05 +0000)]
Fix a regression introduced in r344601, and work properly with the
-v and -n options.

PR: 240640
Reported by: Andriy Gapon <avg@FreeBSD.org>
Reviewed by: avg
Differential Revision: https://reviews.freebsd.org/D21709
Approved by: re

4 years agoMFC r352910 and r352911
Eric Joyner [Mon, 30 Sep 2019 18:22:33 +0000 (18:22 +0000)]
MFC r352910 and r352911

MFC r352910: iflib: Remove redundant VLAN events deregistration
MFC r352911: ix/ixv: Read MSI-X bar from device config

These fix an issue with a kernel panic on unload with an iflib-using
driver and allow certain HP-branded Intel 10G cards to use MSI-X,
respectively.

Approved by: re@ (gjb@)
Sponsored by: Intel Corporation

4 years agoMerge from stable/12 r352723: fix dsl_scan_ds_clone_swapped logic
Andriy Gapon [Mon, 30 Sep 2019 15:08:45 +0000 (15:08 +0000)]
Merge from stable/12 r352723: fix dsl_scan_ds_clone_swapped logic

PR: 239566
Approved by: re (gjb)

4 years agoMFS r352872: MFC r351802:
Xin LI [Mon, 30 Sep 2019 14:32:41 +0000 (14:32 +0000)]
MFS r352872: MFC r351802:

Correct overflow logic in fullpath().

Obtained from: OpenBSD
Approved by: re (gjb)

4 years agoMerge from stable/12 r352595: Add -vnP support to 'zfs send' for bookmarks
Andriy Gapon [Mon, 30 Sep 2019 14:19:18 +0000 (14:19 +0000)]
Merge from stable/12 r352595: Add -vnP support to 'zfs send' for bookmarks

Approved by: re (gjb)

4 years agoMFC r352620, MFS12 r352892:
Konstantin Belousov [Mon, 30 Sep 2019 14:16:44 +0000 (14:16 +0000)]
MFC r352620, MFS12 r352892:
Fix destruction of the robust mutexes.

Approved by: re (gjb)

4 years agoMF stable/12 r352685:
Justin Hibbits [Mon, 30 Sep 2019 14:11:49 +0000 (14:11 +0000)]
MF stable/12 r352685:

libm: Include float.h to get LDBL_MANT_DIG

The long double aliases of double functions are only exposed as aliases
if LDBL_MANT_DIG is 53 (same as DBL_MANT_DIG).  Without float.h
included these files were not exposing weak aliases as expected,
leading to link failures if programs use the *l functions.  This should
fix editors/calligra on targets with 64-bit long double, which uses
erfl and erfcl.  Found on powerpc64.

Approved by: re(delphij)

4 years agoMFS r352508:
Michael Tuexen [Mon, 30 Sep 2019 04:54:02 +0000 (04:54 +0000)]
MFS r352508:
Don't write to memory outside of the allocated array for SACK blocks.

PR: 240837
Approved by: re (delphij@)
Obtained from: rrs@
Sponsored by: Netflix, Inc.

4 years agoMFC r349225:
Li-Wen Hsu [Mon, 30 Sep 2019 03:35:48 +0000 (03:35 +0000)]
MFC r349225:

Finsh readding Big5 in r317204, which was reverting r315568.  This commit
reverts r315569.

Reported by: Ting-Wei Lan <lantw44 gmail com>
Discussed with: kevlo
Sponsored by: The FreeBSD Foundation

Approved by: re (delphij)

4 years agoMFC r352363:
Ian Lepore [Sun, 29 Sep 2019 18:33:29 +0000 (18:33 +0000)]
MFC r352363:

Apply a runtime patch to the FDT data for imx6 to fix iomuxc problems.

The latest imported FDT data defines a node for an iomuxc-gpr device,
which we don't support (or need, right now) in addition to the usual
iomuxc device.  Unfortunately, the dts improperly assigns overlapping
ranges of mmio space to both devices.  The -gpr device is also a syscon
and simple_mfd device.

At runtime the simple_mfd driver attaches for the iomuxc-gpr node, then
when the real iomuxc driver comes along later, it fails to attach because
it tries to allocate its register space, and it's already partially in
use by the bogus instance of simple_mfd.

This change works around the problem by simply disabling the node for
the iomuxc-gpr device, since we don't need it for anything.

Approved by: re@ (gjb)

4 years agoUpdate releng/12.1 to BETA2 as part of the 12.1-RELEASE cycle.
Glen Barber [Fri, 27 Sep 2019 00:00:21 +0000 (00:00 +0000)]
Update releng/12.1 to BETA2 as part of the 12.1-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoMFS r352772: MFC r349342 (by imp):
Alexander Motin [Thu, 26 Sep 2019 23:27:24 +0000 (23:27 +0000)]
MFS r352772: MFC r349342 (by imp):
Use the cam_ed copy of ata_params rather than malloc and freeing
memory for it. This reaches into internal bits of xpt a little, and
I'll clean that up later.

Reviewed by: imp
Approved by: re (gjb)

4 years agoRegen src.conf.5 after r352768, r352769
Ed Maste [Thu, 26 Sep 2019 21:06:55 +0000 (21:06 +0000)]
Regen src.conf.5 after r352768, r352769

Approved by: re (gjb)

4 years agoMF stable/12 r352759,r352771
Michael Gmelin [Thu, 26 Sep 2019 20:56:07 +0000 (20:56 +0000)]
MF stable/12 r352759,r352771

Approved by: re (gjb)

r352759:
freebsd-update.8: Style fixes, document new features.
freebsd-update:   Make usage output consistent.
freebsd-update:   Add `updatesready' and `showconfig' commands
freebsd-update:   Change exit code of `freebsd-update install' to 2
                  in case there are no pending updates and there wasn't
                  a fetch phase in the same invocation.

r352771:
Add mergeinfo missing in r352759

PR: 240757, 240177, 229346
Reviewed by: manpages (bcr), secteam (emaste), yuripv
Differential Revision: https://reviews.freebsd.org/D21473

4 years agoMFS r352752: Add a WITH_BIND_NOW build knob
Ed Maste [Thu, 26 Sep 2019 18:56:41 +0000 (18:56 +0000)]
MFS r352752: Add a WITH_BIND_NOW build knob

MFC r340186: Add a WITH_BIND_NOW build knob

The linker's -z now flag sets the DF_BIND_NOW flag, which signals to the
runtime loader that all relocation processing should be performed at
process startup rather than on demand.  In combination with lld's
default of enabling relro this causes the GOT to be made read-only when
the process starts, preventing straightforward GOT overwrite attacks.

MFC r341429: disable BIND_NOW in libc, libthr, and rtld

An issue remains with BIND_NOW and processes using threads.  For now,
restore libc's BIND_NOW disable, and also disable BIND_NOW in rtld and
libthr.

MFC r345625: revert r341429 "disable BIND_NOW in libc, libthr, and rtld"

r345620 by kib@ fixed the rtld issue that caused a crash at startup
during resolution of libc's ifuncs with BIND_NOW.

MFC r345638: Revert change accidentally committed along with r345625

MFC r345640: Revert other accidentally committed part of r345625

Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation

4 years agoMFS r352754: Add WITH_PIE knob to build Position Independent Executables
Ed Maste [Thu, 26 Sep 2019 18:37:58 +0000 (18:37 +0000)]
MFS r352754: Add WITH_PIE knob to build Position Independent Executables

MFC r344179: Add WITH_PIE knob to build Position Independent Executables

Building binaries as PIE allows the executable itself to be loaded at a
random address when ASLR is enabled (not just its shared libraries).

With this change PIE objects have a .pieo extension and INTERNALLIB
libraries libXXX_pie.a.

MK_PIE is disabled for some kerberos5 tools, Clang, and Subversion, as
they explicitly reference .a libraries in their Makefiles.  These can
be addressed on an individual basis later.  MK_PIE is also disabled for
rtld-elf because it is already position-independent using bespoke
Makefile rules.

Currently only dynamically linked binaries will be built as PIE.

MFC r344181: Fix Makefile conditional after r344179

MFC r344182: Use make's :tl instead of checking "no" and "NO"

MFC r344189: Fixup bsd.prog.mk after r344182

MFC r344211: wlandebug: disable PIE to fix build failure

libifconfig is built as a static-only PRIVATELIB (and there is no _pie.a
version) so disable PIE in libifconfig's consumer.

r345489: Fix GNU objdump build under WITH_PIE

Explicitly specified bare .a libraries need ${PIE_SUFFIX}.

r345490: Apply WITH_PIE changes to other binutils components

Followon to r345489, explicitly specified bare .a libraries need
${PIE_SUFFIX} (although these still built).

r345778: Fix gdb/kgdb build under WITH_PIE

Explicitly specified bare .a libraries need ${PIE_SUFFIX}.

Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation

4 years agoMFS r352720:
Mark Johnston [Thu, 26 Sep 2019 18:36:52 +0000 (18:36 +0000)]
MFS r352720:
Use separate descriptors in bhyve's stdio uart backend.

Approved by: re (gjb)

4 years agoMFS r352749:
Mark Johnston [Thu, 26 Sep 2019 18:36:15 +0000 (18:36 +0000)]
MFS r352749:
Revert r316820.

PR: 233952
Approved by: re (gjb)

4 years agoMFS r352750:
Mark Johnston [Thu, 26 Sep 2019 18:35:26 +0000 (18:35 +0000)]
MFS r352750:
ping6: Use caph_rights_limit(3) for STDIN_FILENO

Approved by: re (gjb)

4 years agoMerge from stable/12 r352735 and r352741
Warner Losh [Thu, 26 Sep 2019 16:51:51 +0000 (16:51 +0000)]
Merge from stable/12 r352735 and r352741

Merge all the stability fixes for the mpr and mps drivers. This fixes a
number of different panics. Unfortunately, mps now requires atomic_swap_64
to work properly, so it has been disabled on 32-bit powerpc and mips. The
impact should be negligible, however, since this device is difficult to
attach to those platforms.

Approved by: re@ (glen)
Relnotes: YES (for ppc32 removal)

4 years agoMFC r352493: Fix typo, setting hidden flag instead of reparse.
Alexander Motin [Wed, 25 Sep 2019 18:47:05 +0000 (18:47 +0000)]
MFC r352493: Fix typo, setting hidden flag instead of reparse.

Approved by: re (gjb)

4 years agoMFS r352678: msdosfs: do not deget unlinked denodes
Kyle Evans [Wed, 25 Sep 2019 17:16:21 +0000 (17:16 +0000)]
MFS r352678: msdosfs: do not deget unlinked denodes

When a file is unlinked, the denode is not reclaimed until the last
reference is dropped, but the directory entry is immediately up for reuse.
This is a problem later when createde goes to grab a denode for the newly
created entry -- we search the hash and find a dead denode, then return that
without even bumping the reference count and the data later gets truncated
when the the last reference to the unlinked file is dropped.

This manifested itself as a broken in-place strip(1) on msdosfs.

The comment indicating that we want to skip these denodes has been updated
to reflect where this is actually done.

Approved by: re (gjb)

4 years agoMF stable/12 r352608
Michael Gmelin [Mon, 23 Sep 2019 15:58:54 +0000 (15:58 +0000)]
MF stable/12 r352608

Approved by: re (gjb)

r352608:
freebsd-update: Fix src component detection

In case BASEDIR was set to a directory that differed from the default
filesystem root, freebsd-update wrongly checked for the existence
of /usr/src/COPYRIGHT to determine if the src component was
installed. Existing code to address this wasn't effective due to the
order in which configuration options were evaluated.

PR: 224048, 238558, 239997
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D21579

4 years agoMF stable/12 r352489
Alan Somers [Sun, 22 Sep 2019 00:12:43 +0000 (00:12 +0000)]
MF stable/12 r352489

Approved by: re (kib)

r351192:
periodic: fix anticongestion for scripts run after security

Revision 316342, which introduced the anticongestion feature, failed to
consider that the periodic scripts are executed by a recursive invocation of
periodic.  The recursive invocation wrongly cleaned up a temporary file that
should've been cleaned up only by the original invocation.  The result is
that if the first script that requests an anticongestion sleep runs after
the security scripts, the sleep won't happen.

Fix this bug by delaying cleanup until the end of the original invocation.

PR:             236564
Submitted by:   Yasuhiro KIMURA <yasu@utahime.org>
Reviewed by:    imp

r351203:
periodic: replace "tty" with "test -t 0"

Apparently using tty for this purpose has been deprecated since 4.4 Lite.

Reviewed by:    cy
Differential Revision:  https://reviews.freebsd.org/D21318

4 years agoMF stable/12 r352534:
Alan Somers [Sat, 21 Sep 2019 13:00:38 +0000 (13:00 +0000)]
MF stable/12 r352534:

Fix an off-by-one error from r351961

That revision addressed a Coverity CID that could lead to a buffer overflow,
but it had an off-by-one error in the buffer size check.

Approved by: re (kib)
Reported by: Coverity
Coverity CID: 1405530
MFC-With: 351961
Sponsored by: The FreeBSD Foundation

4 years agoMFS r352565: SIOCSIFNAME: Do nothing if we're not actually changing
Kyle Evans [Sat, 21 Sep 2019 01:39:49 +0000 (01:39 +0000)]
MFS r352565: SIOCSIFNAME: Do nothing if we're not actually changing

Instead of throwing EEXIST, just succeed if the name isn't actually
changing. We don't need to trigger departure or any of that because there's
no change from consumers' perspective.

PR: 240539
Approved by: re (gjb)

4 years ago- Copy stable/12@r352480 to releng/12.1 as part of the 12.1 release
Glen Barber [Fri, 20 Sep 2019 00:05:14 +0000 (00:05 +0000)]
- Copy stable/12@r352480 to releng/12.1 as part of the 12.1 release
  cycle.
- Update from PRERELEASE to BETA1.
- Set the default pkg(7) repository to 'quarterly'.
- Bump __FreeBSD_version.
- Prune svn:mergeinfo from the new branch.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoMFC r352137:
Hans Petter Selasky [Wed, 18 Sep 2019 07:31:31 +0000 (07:31 +0000)]
MFC r352137:
Callout drain does not have to be followed by a callout stop call.
Fix bogus code.

Sponsored by: Mellanox Technologies

4 years agoMFC r352207:
Hans Petter Selasky [Wed, 18 Sep 2019 07:28:54 +0000 (07:28 +0000)]
MFC r352207:
Use true and false when dealing with bool type in the LinuxKPI.
No functional change.

Sponsored by: Mellanox Technologies

4 years agoMFC r352206:
Hans Petter Selasky [Wed, 18 Sep 2019 07:26:43 +0000 (07:26 +0000)]
MFC r352206:
Fix synchronous work drain issue in the LinuxKPI.

A work callback may restart itself. Loop in the drain function to see if the
work has been rescheduled and stop the subsequent reschedules, if any.

Sponsored by: Mellanox Technologies

4 years agoMFC r350463
Alan Cox [Wed, 18 Sep 2019 07:25:04 +0000 (07:25 +0000)]
MFC r350463
  In pmap_advise(), when we encounter a superpage mapping, we first demote
  the mapping and then destroy one of the 4 KB page mappings so that there
  is a potential trigger for repromotion.  Currently, we destroy the first
  4 KB page mapping that falls within the (current) superpage mapping or the
  virtual address range [sva, eva).  However, I have found empirically that
  destroying the last 4 KB mapping produces slightly better results,
  specifically, more promotions and fewer failed promotion attempts.
  Accordingly, this revision changes pmap_advise() to destroy the last 4 KB
  page mapping.  It also replaces some nearby uses of boolean_t with bool.

4 years agoMFC r340602:
Jayachandran C. [Wed, 18 Sep 2019 07:22:37 +0000 (07:22 +0000)]
MFC r340602:

gitv3_its: fixes for multiple GIC ITS blocks

First pass of support for multiple GIC ITS blocks with ACPI.
Changes are to:
 * register the correct subset of interrupts with pic_register
   in case of ACPI.
 * initialize just the cpu interface for the first ITS, when
   domain information is not avialable. This has to be done
   until we split the per-CPU init to do LPI setup just once.
 * remove duplicate check for the GIC ITS domain, the sc_cpus
   are setup from domain, so the check again in per-CPU init
   seems unnecessary.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17841

4 years agoMFC r352205:
Hans Petter Selasky [Wed, 18 Sep 2019 07:21:08 +0000 (07:21 +0000)]
MFC r352205:
Fix broken DECLARE_TASKLET() macro after r347852.

Sponsored by: Mellanox Technologies

4 years agoMFC r340599-r340601
Jayachandran C. [Wed, 18 Sep 2019 07:16:00 +0000 (07:16 +0000)]
MFC r340599-r340601

r340599:
acpica, pci_host_generic_acpi: redo pci_host_generic_acpi.c

This is a major update for pci_host_generic_acpi.c, the current
implementation has some gaps that are better fixed up in one go.
The changes are to:
 * Follow x86 method of not adding PCI resources to PCI host bridge in
   ACPI code. This has been moved to pci_host_generic_acpi.c, where we
   walk thru its resources of the host bridge and add them.
 * Fixup code in pci_host_generic_acpi.c to read all decoded ranges
   and update the 'ranges' property. This allows us to share most of
   the code with generic implementation (and the FDT one).
 * Parse and setup IO ranges and bus ranges when walking the resources
   above. Drop most of the changes related to this from acpica code.
 * Add the ECAM memory area as mem resource 0. Implement the logic to
   get the ECAM area from MCFG (using bus range which we now decode),
   or from _CBA (using _BBN/bus range). Drop aarch64 ifdefs from acpica
   code which did part of this.
 * Switch resource activation to similar code as FDT implementation,
   this can be moved into generic implementation in a later pass.
 * Drop the mechanism of using the 7th bit of bus number as the domain,
   this is not correct and will work only in very specific cases. Use
   _SEG as PCI domain and use the bus ranges of the host bridge to
   provide start bus number.

This commit should not make any functional change to dev/acpica/acpi.c
for other architectures, almost all the changes there are to revert
earlier additions in this file done for aarch64.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17791

r340600:
pci_host_generic, acpi_resource: drop unneeded code

Now that we are handling PCI resources in pci_host_generic_acpi.c, we
don't need these change (made by r336129)

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17792

r340601:
pci_host_generic : move activate/release to generic code

Now that the ACPI and FDT implementations for activating and
deactivating resources are the same, we can move it to
pci_host_generic.c.  No functional changes.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17793

4 years agoMFC r340598:
Jayachandran C. [Wed, 18 Sep 2019 07:09:16 +0000 (07:09 +0000)]
MFC r340598:

acpica: rework INTRNG interrupts

On arm64 (where INTRNG is enabled), the interrupts have to be mapped
with ACPI_BUS_MAP_INTR() before adding them as resources to devices.

The earlier code did the mapping before calling acpi_set_resource(),
which bypassed code that checked for PCI link interrupts.

To fix this, move the call to map interrupts into acpi_set_resource()
and that requires additional work to lookup interrupt properties.
The changes here are to:
 * extend acpi_lookup_irq_handler() to lookup an irq in the ACPI
   resources
 * create a helper function acpi_map_intr() which uses the updated
   acpi_lookup_irq_handler() to look up an irq, and then map it
   with ACPI_BUS_MAP_INTR()
 * use acpi_map_intr() in acpi_pcib_route_interrupt() to map
   pci link interrupts.

With these changes, we can drop the ifdefs in acpi_resource.c, and
we can also drop the call for mapping interrupts in generic_timer.c

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17790

4 years agoMFC r350347
Alan Cox [Wed, 18 Sep 2019 07:01:01 +0000 (07:01 +0000)]
MFC r350347
  Implement pmap_advise().  (Without a working pmap_advise() implementation
  madvise(MADV_DONTNEED) and madvise(MADV_FREE) are NOPs.)

4 years agoMFC r340595-r340597
Jayachandran C. [Wed, 18 Sep 2019 06:50:29 +0000 (06:50 +0000)]
MFC r340595-r340597

r340595:
pci_host_generic: remove unneeded ThunderX2 quirk

The current quirk implementation writes a fixed address to the PCI BAR
to fix a firmware bug. The PCI BARs are allocated by firmware and will
change depending on PCI devices present. So using a fixed address here
is not correct.

This quirk worked around a firmware bug that programmed the MSI-X bar
of the SATA controller incorrectly. The newer firmware does not have
this issue, so it is better to drop this quirk altogether.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17655

r340596:
pci_host_generic: allocate resources against devices

Fix up pci_host_generic.c and pci_host_generic_fdt.c to allocate
resources against devices that requested them. Currently the
allocation happens against the pcib, which is incorrect.

This is needed for the upcoming changes for fixing up
pci_host_generic_acpi.c

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17656

r340597:
pci_host_generic*: basic implementation of bus range

Both ACPI and FDT support bus ranges for pci host bridges. Update
pci_host_generic*.[ch] with a default implementation to support this.
This will be used in the next set of changes for ACPI based host
bridge. No functional changes in this commit.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17657

4 years agoMFC r349117, r349122, r349183, r349897, r349943, r350004, r350029, r350038,
Alan Cox [Tue, 17 Sep 2019 17:28:44 +0000 (17:28 +0000)]
MFC r349117, r349122, r349183, r349897, r349943, r350004, r350029, r350038,
  r350191, r350202, r350422, r350427, r350525

r349117:
  Three enhancements to arm64's pmap_protect():

  Implement protection changes on superpage mappings.  Previously, a superpage
  mapping was unconditionally demoted by pmap_protect(), even if the
  protection change applied to the entire superpage mapping.

  Precompute the bit mask describing the protection changes rather than
  recomputing it for every page table entry that is changed.

  Skip page table entries that already have the requested protection changes
  in place.

r349122:
  Three changes to arm64's pmap_unwire():

  Implement wiring changes on superpage mappings.  Previously, a superpage
  mapping was unconditionally demoted by pmap_unwire(), even if the wiring
  change applied to the entire superpage mapping.

  Rewrite a comment to use the arm64 names for bits in a page table entry.
  Previously, the bits were referred to by their x86 names.

  Use atomic_"op"_64() instead of atomic_"op"_long() to update a page table
  entry in order to match the prevailing style in this file.

r349183:
  Correct an error in r349122.  pmap_unwire() should update the pmap's wired
  count, not its resident count.

r349897: (by markj)
  Rename pmap_page_dirty() to pmap_pte_dirty().

  This is a precursor to implementing dirty bit management.

r349943: (by markj)
  Apply some light cleanup to uses of pmap_pte_dirty().
  - Check for ATTR_SW_MANAGED before anything else.
  - Use pmap_pte_dirty() in pmap_remove_pages().

r350004: (by markj)
  Implement software access and dirty bit management for arm64.

  Previously the arm64 pmap did no reference or modification tracking;
  all mappings were treated as referenced and all read-write mappings
  were treated as dirty.  This change implements software management
  of these attributes.

  Dirty bit management is implemented to emulate ARMv8.1's optional
  hardware dirty bit modifier management, following a suggestion from alc.
  In particular, a mapping with ATTR_SW_DBM set is logically writeable and
  is dirty if the ATTR_AP_RW_BIT bit is clear.  Mappings with
  ATTR_AP_RW_BIT set are write-protected, and a write access will trigger
  a permission fault.  pmap_fault() handles permission faults for such
  mappings and marks the page dirty by clearing ATTR_AP_RW_BIT, thus
  mapping the page read-write.

r350029: (by markj)
  Propagate attribute changes during demotion.

  After r349117 and r349122, some mapping attribute changes do not trigger
  superpage demotion. However, pmap_demote_l2() was not updated to ensure
  that the replacement L3 entries carry any attribute changes that
  occurred since promotion.

r350038: (by markj)
  Always use the software DBM bit for now.

  r350004 added most of the machinery needed to support hardware DBM
  management, but it did not intend to actually enable use of the hardware
  DBM bit.

r350191:
  Introduce pmap_store(), and use it to replace pmap_load_store() in places
  where the page table entry was previously invalid.  (Note that I did not
  replace pmap_load_store() when it was followed by a TLB invalidation, even
  if we are not using the return value from pmap_load_store().)

  Correct an error in pmap_enter().  A test for determining when to set
  PGA_WRITEABLE was always true, even if the mapping was read only.

  In pmap_enter_l2(), when replacing an empty kernel page table page by a
  superpage mapping, clear the old l2 entry and issue a TLB invalidation.  My
  reading of the ARM architecture manual leads me to believe that the TLB
  could hold an intermediate entry referencing the empty kernel page table
  page even though it contains no valid mappings.

  Replace a couple direct uses of atomic_clear_64() by the new
  pmap_clear_bits().

  In a couple comments, replace the term "paging-structure caches", which is
  an Intel-specific term for the caches that hold intermediate entries in the
  page table, with wording that is more consistent with the ARM architecture
  manual.

r350202:
  With the introduction of software dirty bit emulation for managed mappings,
  we should test ATTR_SW_DBM, not ATTR_AP_RW, to determine whether to set
  PGA_WRITEABLE.  In effect, we are currently setting PGA_WRITEABLE based on
  whether the dirty bit is preset, not whether the mapping is writeable.
  Correct this mistake.

r350422: (by markj)
  Remove an unneeded trunc_page() in pmap_fault().

r350427: (by markj)
  Have arm64's pmap_fault() handle WnR faults on dirty PTEs.

  If we take a WnR permission fault on a managed, writeable and dirty
  PTE, simply return success without calling the main fault handler.  This
  situation can occur if multiple threads simultaneously access a clean
  writeable mapping and trigger WnR faults; losers of the race to mark the
  PTE dirty would end up calling the main fault handler, which had no work
  to do.

r350525: (by markj)
  Use ATTR_DBM even when hardware dirty bit management is not enabled.

  The ARMv8 reference manual only states that the bit is reserved in
  this case; following Linux's example, use it instead of a
  software-defined bit for the purpose of indicating that a managed
  mapping is writable.

4 years agoMFC r351649 Check for region dups.
Aleksandr Rybalko [Tue, 17 Sep 2019 11:20:53 +0000 (11:20 +0000)]
MFC r351649 Check for region dups.

4 years agoMFC r343042, r343875
Andrew Turner [Tue, 17 Sep 2019 10:09:59 +0000 (10:09 +0000)]
MFC r343042, r343875

r343042:
Ensure the I-Cache is correctly handled in arm64_icache_sync_range

The cache_handle_range macro to handle the arm64 instruction and data
cache operations would return when it was complete. This causes problems
for arm64_icache_sync_range and arm64_icache_sync_range_checked as they
assume they can execute the i-cache handling instruction after it has been
called.

Fix this by making this assumption correct.

While here add missing instruction barriers and adjust the style to
match the rest of the assembly.

Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D18838

r343875:
Add a missing data barrier to the start of arm64_tlb_flushID.

We need to ensure the page table store has happened before the tlbi.

Reported by: jchandra
Tested by: jchandra
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19097

4 years agoMFC r342552:
Andrew Turner [Tue, 17 Sep 2019 10:00:53 +0000 (10:00 +0000)]
MFC r342552:
Pass VM_PROT_EXECUTE to vm_fault for instruction faults.

We need to tell vm_fault the reason for the fault was because we tried to
execute from the memory location. Without this it may return with success
as we only request read-only memory, then we return to the same location
and try to execute from the same memory address. This leads to an infinite
loop raising the same fault and returning to the same invalid location.

Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D18511

4 years agoMFC r352048:
Mitchell Horne [Mon, 16 Sep 2019 22:00:29 +0000 (22:00 +0000)]
MFC r352048:

Fix cpuwhich_t column width

4 years agoMFC r351613:
Mark Johnston [Mon, 16 Sep 2019 18:40:27 +0000 (18:40 +0000)]
MFC r351613:
Remove unused VM page locking macros.

This completes the merge of the revision.  r352043 updated only the merge
info for some reason.

Reported by: alc

4 years agoLinuxKPI: Limit exposure of new field in dev_pm_ops to LinuxKPI >= 50000.
Johannes Lundberg [Mon, 16 Sep 2019 18:23:01 +0000 (18:23 +0000)]
LinuxKPI: Limit exposure of new field in dev_pm_ops to LinuxKPI >= 50000.

This will fix a suspend/resume issue that occurs on drm-kmod packages
build on 12.0 and run on 12.1.

Approved by: imp (mentor)

4 years agoMFC r352138, r352214, r352216:
Yuri Pankov [Mon, 16 Sep 2019 16:17:29 +0000 (16:17 +0000)]
MFC r352138, r352214, r352216:

locale: handle day, abday, mon, abmon, am_pm keywords

All of these are defined as mandatory by POSIX.

While here, mark all non-standard ones as FreeBSD-only as
other systems (at least, GNU/Linux and illumos) do not handle
them, so we should not encourage their use.

- make abday, day, abmon, mon, am_pm output quoting match linux
- workaround localeconv() issue for mon_grouping and grouping (PR172215)
- for other values not available in default locale, output -1 instead of
  127 (CHAR_MAX) as returned by localeconv()

PR: 237752

4 years agoMFC r351604:
Yuri Pankov [Mon, 16 Sep 2019 16:10:44 +0000 (16:10 +0000)]
MFC r351604:

ichsmb: defer smbus attach until interrupts are available

This fixes a "timed sleep before timers are working" panic seen
while attaching jedec_dimm(4) instances too early in the boot.

Submitted by: ian
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D21452