]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMFC r357826: elfcopy: set ELF OS/ABI field when converting from binary
Ed Maste [Tue, 19 May 2020 22:09:59 +0000 (22:09 +0000)]
MFC r357826: elfcopy: set ELF OS/ABI field when converting from binary

PR: 228934
Submitted by: Tiger Gao
Sponsored by: The FreeBSD Foundation

4 years agoMFC r360564: Cleanup LUN addition/removal.
Alexander Motin [Tue, 19 May 2020 14:31:47 +0000 (14:31 +0000)]
MFC r360564: Cleanup LUN addition/removal.

 - Make ctl_add_lun() synchronous.  Asynchronous addition was used by
Copan's proprietary code long ago and never for upstream FreeBSD.
 - Move LUN enable/disable calls from backends to CTL core.
 - Serialize LUN modification and partially removal to avoid double frees.
 - Slightly unify backends code.

4 years agoMFC r359686: Fix panic on kern.cam.ctl.ha_role change after r333446.
Alexander Motin [Tue, 19 May 2020 13:52:34 +0000 (13:52 +0000)]
MFC r359686: Fix panic on kern.cam.ctl.ha_role change after r333446.

4 years agoMFC r360983:
Konstantin Belousov [Tue, 19 May 2020 07:47:59 +0000 (07:47 +0000)]
MFC r360983:
Clear namespace pollution in include/malloc_np.h

4 years agoMFC r360966:
Mark Johnston [Tue, 19 May 2020 03:24:45 +0000 (03:24 +0000)]
MFC r360966:
rtwn: Add a USB ID for the TP-Link TL-WN727N.

PR: 246417

4 years agoMFC r360960:
Ryan Moeller [Tue, 19 May 2020 01:43:00 +0000 (01:43 +0000)]
MFC r360960:

nfs: Remove APPLESTATIC macro

It is no longer useful.

Reviewed by:    rmacklem
Approved by:    mav (mentor)
Sponsored by:   iXsystems, Inc.
Differential Revision:  https://reviews.freebsd.org/D24811

4 years agoMFC r361114:
Colin Percival [Tue, 19 May 2020 01:40:45 +0000 (01:40 +0000)]
MFC r361114:

  Move the devmatch rc.d script before netif in the boot process.

  Prior to this change, using lagg to aggregate wired and wireless networks
  was broken in the (relatively common) case where wifi drivers + firmware
  are loaded by devmatch, since the interface didn't exist at the time when
  the lagg interface was being created.

PR: 246506

4 years agoMFC r361097:
Colin Percival [Tue, 19 May 2020 01:39:37 +0000 (01:39 +0000)]
MFC r361097:
  Send Lid status notification via devd from acpi_lid_status_update.

  Some laptops don't send ACPI "lid status changed" notifications upon
  opening the lid if the system was currently suspended.  In r358219
  this was partially fixed, updating the "lid_status" variable upon
  resume even if there is no "status changed" notification from ACPI.

  Unfortunately the fix in r358219 did not include notifying userland
  via devd; this causes problems on systems using upowerd (e.g. KDE),
  since upowerd remembers the most recent devd notification about the
  lid status rather than querying the sysctl to get the current status.

  This showed up as two symptoms when KDE's "When laptop lid closed: Sleep"
  option is set:
  1. 50% of the time, closing the lid would not trigger S3 sleep.
  2. 50% of the time, plugging/unplugging AC power would trigger S3 sleep.

PR: 246477

4 years agoMFC r361077, r361078, r361079:
Konstantin Belousov [Mon, 18 May 2020 14:37:10 +0000 (14:37 +0000)]
MFC r361077, r361078, r361079:
Improve comment for compat32 handling of sysctl hw.pagesizes.

4 years agoMFC r360925:
Hans Petter Selasky [Mon, 18 May 2020 09:45:59 +0000 (09:45 +0000)]
MFC r360925:
Refresh the USB device strings when a USB device is re-enumerated.

Submitted by: Horse Ma <Shichun.Ma@dell.com>
Sponsored by: Mellanox Technologies

4 years agoMFC r360623:
Hans Petter Selasky [Mon, 18 May 2020 09:44:26 +0000 (09:44 +0000)]
MFC r360623:
Optimise use of sg_page_count() in __sg_page_iter_next() in the LinuxKPI.
No need to compute value twice.

No functional change intended.

Sponsored by: Mellanox Technologies

4 years agoMFC r360622:
Hans Petter Selasky [Mon, 18 May 2020 09:37:02 +0000 (09:37 +0000)]
MFC r360622:
Implement more scatter and gather functions in the LinuxKPI.

Differential Revision: https://reviews.freebsd.org/D24611
Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

4 years agoMFC r360621:
Hans Petter Selasky [Mon, 18 May 2020 09:35:42 +0000 (09:35 +0000)]
MFC r360621:
Fix warning about sleeping with non-sleepable lock when allocating
"current" from linux_cdev_pager_populate() in the LinuxKPI:

Backtrace:
witness_debugger()
witness_warn()
uma_zalloc_arg()
malloc()
linux_alloc_current()
linux_cdev_pager_populate()
vm_fault()
vm_fault_trap()
trap_pfault()
trap()
calltrap()

Suggested by: avg@
Sponsored by: Mellanox Technologies

4 years agoMFC r360532:
Hans Petter Selasky [Mon, 18 May 2020 09:26:42 +0000 (09:26 +0000)]
MFC r360532:
Implement more PCI-express bandwidth functions in the LinuxKPI.

Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

4 years agoMFC r360531:
Hans Petter Selasky [Mon, 18 May 2020 09:25:23 +0000 (09:25 +0000)]
MFC r360531:
Implement mutex_lock_killable() in the LinuxKPI.

Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

4 years agoMFC r360530:
Hans Petter Selasky [Mon, 18 May 2020 09:24:05 +0000 (09:24 +0000)]
MFC r360530:
Implement DIV64_U64_ROUND_UP() in the LinuxKPI.

Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

4 years agoMFC r360529:
Hans Petter Selasky [Mon, 18 May 2020 09:22:47 +0000 (09:22 +0000)]
MFC r360529:
Implement more lockdep macros in the LinuxKPI.

Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

4 years agoMFC r351003:
Hans Petter Selasky [Mon, 18 May 2020 09:21:45 +0000 (09:21 +0000)]
MFC r351003:
Fix build with DRM and INVARIANTS enabled.

The DRM drivers use the lockdep assertion macros with spinlock_t locks
which are backed by mutexes, not sx locks.  This causes compile
failures since you can't use sx_assert with a mutex.  Instead, change
the lockdep macros to use lock_class methods.  This works by assuming
that each LinuxKPI locking primitive embeds a FreeBSD lock as its
first structure and uses a cast to get to the underlying 'struct
lock_object'.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D20992

4 years agoMFC r360329:
Hans Petter Selasky [Mon, 18 May 2020 09:17:05 +0000 (09:17 +0000)]
MFC r360329:
Properly update AD field length in hccontrol(8).

While at it use strtol() instead of atoi() to support hexadecimal
numbers aswell as 10-base numbers.

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245899
Sponsored by: Mellanox Technologies

4 years agoMFC r360288:
Hans Petter Selasky [Mon, 18 May 2020 09:15:45 +0000 (09:15 +0000)]
MFC r360288:
Put advertising data in correct place.

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245848
Sponsored by: Mellanox Technologies

4 years agoMFC r360263:
Hans Petter Selasky [Mon, 18 May 2020 09:14:24 +0000 (09:14 +0000)]
MFC r360263:
Rename two commands to match the Bluetooth specification in hccontrol(8).
Fix some bad spelling while at it.

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245868
Sponsored by: Mellanox Technologies

4 years agoMFC r360243:
Hans Petter Selasky [Mon, 18 May 2020 09:13:03 +0000 (09:13 +0000)]
MFC r360243:
Add support for LE advertising to hccontrol(8).

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245848
Sponsored by: Mellanox Technologies

4 years agoMFC r360127:
Hans Petter Selasky [Mon, 18 May 2020 09:11:41 +0000 (09:11 +0000)]
MFC r360127:
Implement the atomic fetch add unless functions for the LinuxKPI.

Sponsored by: Mellanox Technologies

4 years agoMFC r360119:
Hans Petter Selasky [Mon, 18 May 2020 09:10:21 +0000 (09:10 +0000)]
MFC r360119:
Implement aligned LinuxKPI types for u16, u32 and u64.
Makes a difference for 32-bit platforms mostly.

Sponsored by: Mellanox Technologies

4 years agoMFC r360118:
Hans Petter Selasky [Mon, 18 May 2020 09:09:03 +0000 (09:09 +0000)]
MFC r360118:
Allow test_bit() in the LinuxKPI to accept a const pointer.

Sponsored by: Mellanox Technologies

4 years agoMFC r360790:
Hans Petter Selasky [Mon, 18 May 2020 09:07:14 +0000 (09:07 +0000)]
MFC r360790:
Set PCM_CAP_VIRTUAL for virtual DSP devices.

Submitted by: Kevin Zheng <kevinz5000@gmail.com>
PR: 246206
Sponsored by: Mellanox Technologies

4 years agoMFC r360528:
Hans Petter Selasky [Mon, 18 May 2020 09:05:29 +0000 (09:05 +0000)]
MFC r360528:
Implement kstrtou64() in the LinuxKPI.

Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

4 years agoMFC r360377:
Hans Petter Selasky [Mon, 18 May 2020 09:03:12 +0000 (09:03 +0000)]
MFC r360377:
Add support for reading temperature in mlx5en(4).

Sponsored by: Mellanox Technologies

4 years agoMFC r360197:
Hans Petter Selasky [Mon, 18 May 2020 09:00:45 +0000 (09:00 +0000)]
MFC r360197:
Add support for Read_Local_Supported_Commands command to hccontrol(8).

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245811
Sponsored by: Mellanox Technologies

4 years agoMFC r360172:
Hans Petter Selasky [Mon, 18 May 2020 08:58:41 +0000 (08:58 +0000)]
MFC r360172:
Update string tables in hccontrol(8).

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245796
Sponsored by: Mellanox Technologies

4 years agoMFC r360116:
Hans Petter Selasky [Mon, 18 May 2020 08:57:21 +0000 (08:57 +0000)]
MFC r360116:
Substitute le_read_supported_status with le_read_supported_states.
Refer to bluetooth core v5.2 specifications Vol4. Part E. 7.8.27.

PR: 245763
Submitted by: Marc Veldman <marc@bumblingdork.com>
Sponsored by: Mellanox Technologies

4 years agoMFC r360115:
Hans Petter Selasky [Mon, 18 May 2020 08:55:49 +0000 (08:55 +0000)]
MFC r360115:
Allow the ERR_CAST() function in the LinuxKPI to take a const void pointer.
No functional change.

Sponsored by: Mellanox Technologies

4 years agoMFC r360095:
Hans Petter Selasky [Mon, 18 May 2020 08:52:06 +0000 (08:52 +0000)]
MFC r360095:
Fix cut and paste off-by-one error in hccontrol(8).
Make sure strncpy() doesn't write beyond its given buffer.

PR: 245739
Sponsored by: Mellanox Technologies

4 years agoMFC r360094:
Hans Petter Selasky [Mon, 18 May 2020 08:46:17 +0000 (08:46 +0000)]
MFC r360094:
Improve printing of le features in hccontrol(8).

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245739
Sponsored by: Mellanox Technologies

4 years agoMFC r360092:
Hans Petter Selasky [Mon, 18 May 2020 08:44:16 +0000 (08:44 +0000)]
MFC r360092:
Bring HCI error messages up-to-date.
See Bluetooth v5.6 core specification Vol.1 Part F: Controller error codes.

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245737
Sponsored by: Mellanox Technologies

4 years agoMFC r360070:
Hans Petter Selasky [Mon, 18 May 2020 08:40:39 +0000 (08:40 +0000)]
MFC r360070:
Add missing feature descriptions to hci_features2str().

The list of possible features in hccontrol/features2str() is incomplete.
Refer to "Bluetooth Core Specification 5.2 Vol. 2 Part C. 3.3 Feature Mask Definition".

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245354
Sponsored by: Mellanox Technologies

4 years agoMFC r360900:
Ryan Moeller [Mon, 18 May 2020 00:32:42 +0000 (00:32 +0000)]
MFC r360900:

vfs_exports: Tighten bounds and assert consistency of numsecflavors

We know the value must be greater than 0 and less than MAXSECFLAVORS.

Reject values outside this range in the initial check in vfs_export and add
KASSERTs in the later consumers.

Also check that we are called with one of either MNT_DELEXPORT or MNT_EXPORTED
set.

Reviewed by:    rmacklem
Approved by:    mav (mentor)
Sponsored by:   iXsystems, Inc.
Differential Revision:  https://reviews.freebsd.org/D24753

4 years agoMFC r361064
Peter Grehan [Sun, 17 May 2020 11:09:38 +0000 (11:09 +0000)]
MFC r361064
    Hide host CPUID 0x15 TSC/Crystal ratio/freq info from guest

    In recent Linux (5.3+) and OpenBSD (6.6+) kernels, and with hosts that
    support CPUID 0x15, the local APIC frequency is determined directly
    from the reported crystal clock to avoid calibration against the 8254
    timer.

    However, the local APIC frequency implemented by bhyve is 128MHz, where
    most h/w systems report frequencies around 25MHz. This shows up on
    OpenBSD guests as repeated keystrokes on the emulated PS2 keyboard
    when using VNC, since the kernel's timers are now much shorter.

    Fix by reporting all-zeroes for CPUID 0x15. This allows guests to fall
    back to using the 8254 to calibrate the local APIC frequency.

    Future work could be to compute values returned for 0x15 that would
    match the host TSC and bhyve local APIC frequency, though all dependencies
    on this would need to be examined (for example, Linux will start using
    0x16 for some hosts).

    PR: 246321
    Reported by: Jason Tubnor (and tested)

Approved by: bz (mentor)

4 years agoAdd new stats(7) man page and hook it up to the build.
Benedict Reuschling [Sun, 17 May 2020 09:34:29 +0000 (09:34 +0000)]
Add new stats(7) man page and hook it up to the build.

This man page contains stat utilities that are available in
the base system. This is a better approach than looking them
up via "apropos stat" or similar commands.

Thanks to Daniel Ebdrup Jensen for writing the original page
and incorporating the feedback given.

Submitted by: Daniel Ebdrup Jensen
Reviewed by: 0mp, allanjude, brueffer, bcr
Approved by: bcr
Relnotes: yes (new stats(7) man page)
Differential Revision: https://reviews.freebsd.org/D24417

4 years agoMFC r360613:
Alan Somers [Sun, 17 May 2020 02:36:42 +0000 (02:36 +0000)]
MFC r360613:

Fix intermittent cleanup failures in the ggated test

4 years agoMFC r360339, r360567
Alan Somers [Sun, 17 May 2020 02:35:50 +0000 (02:35 +0000)]
MFC r360339, r360567

r360339:
mac_bsdextended: ATFify the tests

The new tests have more complete setup and cleanup, are more granular, and
correctly annotate expected failures and skipped tests. A follow-up commit
will resolve a conflict with the fusefs tests (bug 244229).

Differential Revision: https://reviews.freebsd.org/D24257

r360567:
Resolve conflict between the fusefs(5) and mac_bsdextended(4) tests

mac_bsdextended(4), when enabled, causes ordinary operations to send many
more VOP_GETATTRs to file system. The fusefs tests expectations aren't
written with those in mind. Optionally expecting them would greatly
obfuscate the fusefs tests. Worse, certain fusefs functionality (like
attribute caching) would be impossible to test if the tests couldn't expect
an exact number of GETATTR operations.

This commit resolves that conflict by making two changes:

1. The fusefs tests will now check for mac_bsdextended, and skip if it's
   enabled.
2. The mac_bsdextended tests will now check whether the module is enabled, not
   merely loaded. If it's loaded but disabled, the tests will automatically
   enable it for the duration of the tests.

With these changes, a CI system can achieve best coverage by loading both
fusefs and mac_bsdextended at boot, and setting
security.mac.bsdextended.enabled=0

PR: 244229
Reported by: lwhsu
Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D24577

4 years agoMFC r359435:
Alan Somers [Sun, 17 May 2020 02:21:53 +0000 (02:21 +0000)]
MFC r359435:

fusefs: add a dtrace probe that fires after mounting is complete

This probe is useful for showing the protocol options negotiated with a FUSE
server.

4 years agoMFC r360087:
Alan Somers [Sun, 17 May 2020 01:55:07 +0000 (01:55 +0000)]
MFC r360087:

libbsm: fix some MLINKS

Add missing MLINKS entries for a few functions. Remove some old typo
entries.

Reported by: phk
Reviewed by: cem

4 years agoMFC r360080:
Alan Somers [Sun, 17 May 2020 01:51:25 +0000 (01:51 +0000)]
MFC r360080:

zfs-program.8: fix orphan .Xr

Reported by: phk
Reviewed by: avg
Differential Revision: https://reviews.freebsd.org/D24488

4 years agoMFC r360079:
Alan Somers [Sun, 17 May 2020 01:50:04 +0000 (01:50 +0000)]
MFC r360079:

cap_dns.3: fix some orphan .Xr links

Reported by: phk

4 years agoMFC r360078, r360086
Alan Somers [Sun, 17 May 2020 01:48:12 +0000 (01:48 +0000)]
MFC r360078, r360086

r360078:
bectl.8, beinstall.sh.8: fix man page section of beinstall.sh

Reported by: phk

r360086:
bectl.8: correctly sort SEE ALSO section after 360078

Reported by: yuripv
MFC with: 360078

4 years agoMFC r360077:
Alan Somers [Sun, 17 May 2020 01:46:00 +0000 (01:46 +0000)]
MFC r360077:

zfsd.8: fix orphan .Xr

Though ZFS is a kernel module, it has no man page in section 4.

Reported by: phk

4 years agoMFC r360845:
Konstantin Belousov [Sat, 16 May 2020 09:03:18 +0000 (09:03 +0000)]
MFC r360845:
Avoid spurious ENOMEMs from sysctl hw.pagesizes.

PR: 246215

4 years agoMFC r360848:
Mark Johnston [Sat, 16 May 2020 00:28:49 +0000 (00:28 +0000)]
MFC r360848:
rtwn: Add a new USB ID.

PR: 246315

4 years agoMFC r360551-r360554
Mitchell Horne [Fri, 15 May 2020 20:01:30 +0000 (20:01 +0000)]
MFC r360551-r360554

This set of changes allows booting with OpenSBI v0.7.

r360551:
Make mpentry independent of _start

r360552:
Add support for HSM SBI extension

r360553:
Use the HSM SBI extension to start APs

r360554:
Use the HSM SBI extension to halt CPUs

4 years agoMFC r360813:
Ryan Moeller [Fri, 15 May 2020 01:01:02 +0000 (01:01 +0000)]
MFC r360813:

Remove APPLEKEXT ifndefs

They are no longer useful.

Reviewed by:    rmacklem
Approved by:    mav (mentor)
Sponsored by:   iXsystems, Inc.
Differential Revision:  https://reviews.freebsd.org/D24752

4 years agoMFC r360952: Generate zlib.pc from source.
Xin LI [Fri, 15 May 2020 00:50:52 +0000 (00:50 +0000)]
MFC r360952: Generate zlib.pc from source.

4 years agoMFC r360594: ipfw: whitespace fix in SCTP_ABORT_ASSOCIATION case statement comment
Ed Maste [Thu, 14 May 2020 20:43:59 +0000 (20:43 +0000)]
MFC r360594: ipfw: whitespace fix in SCTP_ABORT_ASSOCIATION case statement comment

PR: Neel Chauhan <neel AT neelc DOT org>

4 years agoMFC r360398 and r360902
Eric Joyner [Thu, 14 May 2020 19:56:54 +0000 (19:56 +0000)]
MFC r360398 and r360902

These commits introduce a new iflib device-dependent method and
implements that method in the Intel ethernet network drivers;
this method tells iflib if the network interface needs to be
restarted when certain events happen.

This fixes several issues that occur when VLANs are registered
or unregistered with the network interface.

PR: 240818, 241785
Sponsored by: Intel Corporation

4 years agoBump Dd for r361044.
John Baldwin [Thu, 14 May 2020 19:15:21 +0000 (19:15 +0000)]
Bump Dd for r361044.

This is a direct commit to stable/{11,12} as I missed the bump in the
commit to head, but the file has already been removed from head.

4 years agoMFC r360915:
Dimitry Andric [Thu, 14 May 2020 19:09:13 +0000 (19:09 +0000)]
MFC r360915:

Use -fno-asynchronous-unwind-tables to compile lib/csu

Summary:
In r209294 kib added -fno-asynchronous-unwind-tables to the compile
flags for the GNU C startup components. This was done to work around a
BFD ld assertion, "no .eh_frame_hdr table will be created", which is
produced because of the layout of the startup objects.

Add the same flag to lib/csu too, for the same reason. And similarly to
r209294, also add -fno-omit-frame-pointer.

This is primarily meant to quickly MFC to stable/11, so it can end up in
the 11.4 release, as a fix for https://bugs.freebsd.org/246322.

PR: 246322
Differential Revision: https://reviews.freebsd.org/D24797

4 years agoMFC 360710: Deprecate ubsec(4) for FreeBSD 13.0.
John Baldwin [Thu, 14 May 2020 18:59:34 +0000 (18:59 +0000)]
MFC 360710: Deprecate ubsec(4) for FreeBSD 13.0.

With the removal of in-tree consumers of DES, Triple DES, and
MD5-HMAC, the only algorithm this driver still supports is SHA1-HMAC.
This is not very useful as a standalone algorithm (IPsec AH-only with
SHA1 would be the only user).

This driver has also not been kept up to date with the original driver
in OpenBSD which supports a few more cards and AES-CBC on newer cards.
The newest card currently supported by this driver was released in
2005.

Relnotes: yes

4 years agoMFC 360634: Add RFC reference for AES-CTR with IPsec.
John Baldwin [Thu, 14 May 2020 18:55:45 +0000 (18:55 +0000)]
MFC 360634: Add RFC reference for AES-CTR with IPsec.

4 years agoMFC 360399:
John Baldwin [Thu, 14 May 2020 18:49:43 +0000 (18:49 +0000)]
MFC 360399:
Update the cached MSI state when any MSI capability register is written.

bhyve uses cached copies of the MSI capability registers to generate
MSI interrupts for device models.  Previously, these cached fields
were only set when the MSI capability control register was updated.
The Linux kernel recently adopted a change to deal with races in MSI
interrupt delivery that writes to the MSI capability address and data
registers to alter the destination of MSI interrupts without writing
to the MSI capability control register.  bhyve was not updating its
cached registers for these writes and continued to send interrupts
with the old data value to the old address.  Fix this by recomputing
the cached values for every write to any MSI capability register.

4 years agoMFC 360818: Fix a memory leak for ENCIOC_GETSTRING I introduced in r360171.
John Baldwin [Thu, 14 May 2020 18:19:28 +0000 (18:19 +0000)]
MFC 360818: Fix a memory leak for ENCIOC_GETSTRING I introduced in r360171.

4 years agoMFC 360171,360179,360285,360388: Don't dereference various user pointers.
John Baldwin [Thu, 14 May 2020 17:56:43 +0000 (17:56 +0000)]
MFC 360171,360179,360285,360388: Don't dereference various user pointers.

360171:
Don't access a user buffer directly from the kernel.

The handle_string callback for the ENCIOC_SETSTRING ioctl was passing
a user pointer to memcpy().  Fix by using copyin() instead.

For ENCIOC_GETSTRING ioctls, the handler was storing the user pointer
in a CCB's data_ptr field where it was indirected by other code.  Fix
this by allocating a temporary buffer (which ENCIOC_SETSTRING already
did) and copying the result out to the user buffer after the CCB has
been processed.

360179:
Don't pass a user buffer pointer as the data pointer in a CCB.

Allocate a temporary buffer in the kernel to serve as the CCB data
pointer for a pass-through transaction and use copyin/copyout to
shuffle the data to/from the user buffer.

360285:
Don't indirect user pointers directly in two 802.11s ioctls.

IEEE80211_MESH_RTCMD_ADD was invoking memcmp() to validate the
supplied address directly on the user pointer rather than first doing
a copyin() and validating the copied value.

IEEE80211_MESH_RTCMD_DELETE was passing the user pointer directly to
ieee80211_mesh_rt_del() rather than copying the user buffer into a
temporary kernel buffer.

360388:
Don't run strcmp() against strings stored in user memory.

Instead, copy the strings into a temporary buffer on the stack and
run strcmp on the copies.

4 years agoMFC r360568:
David Bright [Thu, 14 May 2020 12:52:08 +0000 (12:52 +0000)]
MFC r360568:

Fix various Coverity-detected errors in nvme driver

This fixes several Coverity-detected errors in the nvme driver.

CIDs addressed: 100834410093771009380119374013054701403975,
1403980

Sponsored by: Dell EMC Isilon

4 years agoMFC r360491: Introduce a lower bound of 2 MSS to TCP Cubic.
Richard Scheffenegger [Thu, 14 May 2020 09:55:41 +0000 (09:55 +0000)]
MFC r360491:   Introduce a lower bound of 2 MSS to TCP Cubic.

Running TCP Cubic together with ECN could end up reducing cwnd down to 1 byte, if the
receiver continously sets the ECE flag, resulting in very poor transmission speeds.

In line with RFC6582 App. B, a lower bound of 2 MSS is introduced, as well as a typecast
to prevent any potential integer overflows during intermediate calculation steps of the
adjusted cwnd.

Reported by: Cheng Cui
Reviewed by: tuexen (mentor)
Approved by: tuexen (mentor)
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D23353

4 years agoMFC r360786:
Piotr Pawel Stefaniak [Thu, 14 May 2020 06:07:23 +0000 (06:07 +0000)]
MFC r360786:
ps: extend the non-standard option -d (tree view) to work with -p

4 years agoMFC 359047,359054: Deprecate procfs-based process debugging.
John Baldwin [Wed, 13 May 2020 21:16:02 +0000 (21:16 +0000)]
MFC 359047,359054: Deprecate procfs-based process debugging.

359047:
Mark procfs-based process debugging as deprecated for FreeBSD 13.

Attempting to use ioctls on /proc/<pid>/mem to control a process will
trigger warnings on the console.  The <sys/pioctl.h> include file will
also now emit a compile-time warning when used from userland.

359054:
Fix the workaround to ignore the #warning for GCC.

clang and gcc use different warning flags for #warning preprocessor
directives.

For both 12 and 11, adjust the GCC warning flags to only be added in
4.7 and later since 4.2.1 does not support -Wno-cpp.  For 11, add the
needed warning suppression to procctl's build.  procctl was removed in
12.0.

4 years agoMFC r360691:
Mark Johnston [Wed, 13 May 2020 12:33:51 +0000 (12:33 +0000)]
MFC r360691:
arm: Don't enable interrupts in init_secondary().

4 years agoMFC r359166: objcopy: add new sections also when there is no .shstrtab
Ed Maste [Tue, 12 May 2020 23:51:04 +0000 (23:51 +0000)]
MFC r359166: objcopy: add new sections also when there is no .shstrtab

Previously objcopy (elfcopy) --add-sections inserted new sections before
.shstrtab, but omitted them if there was no .shstrtab.

Now, after processing existing sections add new sections if they were
not yet added.

PR: 241437
Reported by: arrowd
Submitted by: Tiger Gao <tig@FreeBSDFoundation.org>
Sponsored by: The FreeBSD Foundation

4 years agoMFC r343969 by nwhitehorn:
Justin Hibbits [Tue, 12 May 2020 21:51:56 +0000 (21:51 +0000)]
MFC r343969 by nwhitehorn:

Performance improvements for octe(4):
- Distribute RX load across multiple cores, if present. This reverts
r217212, which is no longer relevant (I think because of the newer
SDK).
- Use newer APIs for pinning taskqueue entries to specific cores.
- Deepen RX buffers.

This more than doubles NAT forwarding throughput on an EdgeRouter Lite from,
with typical packet mixture, 90 Mbps to over 200 Mbps. The result matches
forwarding throughput in Linux without the UBNT hardware offload on the same
hardware, and thus likely reflects hardware limits.

4 years agoMFC r360777: Optimize ENA Rx refill for low memory conditions
Marcin Wojtas [Tue, 12 May 2020 18:44:41 +0000 (18:44 +0000)]
MFC r360777: Optimize ENA Rx refill for low memory conditions

Sometimes, especially when there is not much memory in the system left,
allocating mbuf jumbo clusters (like 9KB or 16KB) can take a lot of time
and it is not guaranteed that it'll succeed. In that situation, the
fallback will work, but if the refill needs to take a place for a lot of
descriptors at once, the time spent in m_getjcl looking for memory can
cause system unresponsiveness due to high priority of the Rx task. This
can also lead to driver reset, because Tx cleanup routine is being
blocked and timer service could detect that Tx packets aren't cleaned
up. The reset routine can further create another unresponsiveness - Rx
rings are being refilled there, so m_getjcl will again burn the CPU.
This was causing NVMe driver timeouts and resets, because network driver
is having higher priority.

Instead of 16KB jumbo clusters for the Rx buffers, 9KB clusters are
enough - ENA MTU is being set to 9K anyway, so it's very unlikely that
more space than 9KB will be needed.

However, 9KB jumbo clusters can still cause issues, so by default the
page size mbuf cluster will be used for the Rx descriptors. This can have a
small (~2%) impact on the throughput of the device, so to restore
original behavior, one must change sysctl "hw.ena.enable_9k_mbufs" to
"1" in "/boot/loader.conf" file.

As a part of this patch (important fix), the version of the driver
was updated to v2.1.2.

Submitted by:   cperciva
PR:             225791, 234838, 235856, 236989, 243531

4 years agoMFC r360968: libalias: fix potential memory disclosure from ftp module
Ed Maste [Tue, 12 May 2020 16:52:08 +0000 (16:52 +0000)]
MFC r360968: libalias: fix potential memory disclosure from ftp module

admbugs: 956
Submitted by: markj
Reported by: Vishnu Dev TJ working with Trend Micro Zero Day Initiative
Approved by: so
Security: FreeBSD-SA-20:13.libalias
Security: CVE-2020-7455
Security: ZDI-CAN-10849

4 years agoMFC r360967: libalias: validate packet lengths before accessing headers
Ed Maste [Tue, 12 May 2020 16:49:04 +0000 (16:49 +0000)]
MFC r360967: libalias: validate packet lengths before accessing headers

admbugs: 956
Submitted by: ae
Reported by: Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative
Reported by: Vishnu working with Trend Micro Zero Day Initiative
Approved by: so
Security: FreeBSD-SA-20:12.libalias
Security: CVE-2020-7454
Security: ZDI-CAN-10624, ZDI-CAN-10850

4 years agoMFC 358394: Use stream_read() to read all 12 bytes of the RFB client version.
John Baldwin [Tue, 12 May 2020 16:05:21 +0000 (16:05 +0000)]
MFC 358394: Use stream_read() to read all 12 bytes of the RFB client version.

read() can return a short read, whereas stream_read() waits until the
full version string is read.

4 years agoMFC r360438:
Mark Johnston [Tue, 12 May 2020 14:01:14 +0000 (14:01 +0000)]
MFC r360438:
Make sendfile(SF_SYNC)'s CV wait interruptible.

4 years agoMFC r360844:
Konstantin Belousov [Tue, 12 May 2020 12:29:39 +0000 (12:29 +0000)]
MFC r360844:
Document BUS_OOMERR.

4 years agoMFC r360676: elfctl: update earliest FreeBSD revision to 12.2
Ed Maste [Tue, 12 May 2020 01:01:48 +0000 (01:01 +0000)]
MFC r360676: elfctl: update earliest FreeBSD revision to 12.2

elfctl has been merged to stable/12, and so will appear in FreeBSD 12.2

Reported by: Dewayne Geraghty
Sponsored by: The FreeBSD Foundation

4 years agoMFC 357643: Tidy the _set_tp function for RISC-V.
John Baldwin [Mon, 11 May 2020 21:24:22 +0000 (21:24 +0000)]
MFC 357643: Tidy the _set_tp function for RISC-V.

- Use a constant for the offset instead of a magic number.
- Use an addi instruction that writes to tp directly instead of a mv
  that writes the result of a compiler-generated addi.

4 years agoMFC 357632: Use the context created in makectx() for stack traces.
John Baldwin [Mon, 11 May 2020 20:58:27 +0000 (20:58 +0000)]
MFC 357632: Use the context created in makectx() for stack traces.

Always use the kdb_thr_ctx() for db_trace_thread() as on other
architectures.  Initialize pcb_ra to be the sepc from the saved
trapframe rather than the saved ra to avoid skipping a frame.

4 years agoMFC 357630: Fix DDB to unwind across exception frames.
John Baldwin [Mon, 11 May 2020 20:41:27 +0000 (20:41 +0000)]
MFC 357630: Fix DDB to unwind across exception frames.

While here, add an extra line of information for exceptions and
interrupts and compress the per-frame line down to one line to match
other architectures.

4 years agoMFC r350571:
Justin Hibbits [Mon, 11 May 2020 20:10:01 +0000 (20:10 +0000)]
MFC r350571:

Fix the build after r350570.

Signed char cannot compare to values above 0x7f.  Use unsigned instead.

4 years agoMFC 357594: Use csr_read() to read sstatus instead of inline assembly.
John Baldwin [Mon, 11 May 2020 19:57:45 +0000 (19:57 +0000)]
MFC 357594: Use csr_read() to read sstatus instead of inline assembly.

While here, remove a local variable to avoid the CSR read in non-debug
kernels.

4 years agoMFC 357595: Fix EXCP_MASK to include all relevant bits from scause.
John Baldwin [Mon, 11 May 2020 18:47:51 +0000 (18:47 +0000)]
MFC 357595: Fix EXCP_MASK to include all relevant bits from scause.

While cause codes higher than 16 are reserved, the exception code
field of the register is defined to be all bits but the upper-most
bit.

4 years agoMFC 356840,357344: Add stricter checks on user changes to SSTATUS.
John Baldwin [Mon, 11 May 2020 16:14:20 +0000 (16:14 +0000)]
MFC 356840,357344: Add stricter checks on user changes to SSTATUS.

356840:
Check for invalid sstatus values in set_mcontext().

Previously, this check was only in sys_sigreturn() which meant that
user applications could write invalid values to the register via
setcontext() or swapcontext().

357344:
Add stricter checks on user changes to SSTATUS.

Rather than trying to blacklist which bits userland can't write to via
sigreturn() or setcontext(), only permit changes to whitelisted bits.

- Permit arbitrary writes to bits in the user-writable USTATUS
  register that shadows SSTATUS.

- Ignore changes in write-only bits maintained by the CPU.

- Ignore the user-supplied value of the FS field used to track
  floating point state and instead set it to a value matching the
  actions taken by set_fpcontext().

4 years agoMFC r360381:
Mark Johnston [Mon, 11 May 2020 15:21:03 +0000 (15:21 +0000)]
MFC r360381:
Add some regression tests for read and write kevents on pipes.

4 years agoMFC r360380:
Mark Johnston [Mon, 11 May 2020 15:20:40 +0000 (15:20 +0000)]
MFC r360380:
Fix handling of EV_EOF for named pipes.

PR: 203366, 224615, 246350

4 years agoMFC r360379:
Mark Johnston [Mon, 11 May 2020 15:20:05 +0000 (15:20 +0000)]
MFC r360379:
Call pipeselwakeup() after toggling PIPE_EOF.

4 years agoMFC r360378:
Mark Johnston [Mon, 11 May 2020 15:17:57 +0000 (15:17 +0000)]
MFC r360378:
Avoid returning POLLIN if the pipe descriptor is not open for reading.

4 years agoMFC r360619:
Xin LI [Mon, 11 May 2020 07:20:37 +0000 (07:20 +0000)]
MFC r360619:
 - Fix logic error in swapoff case: follow same handling of p and
   linelen in the swapon case.
 - Use strlcpy instead of strncpy.

4 years agoMFC r360836:
Toomas Soome [Mon, 11 May 2020 06:59:01 +0000 (06:59 +0000)]
MFC r360836:

loader: vdev_read() can corrupt memory

When reading less than sector size but from sector boundary,
the vdev_read() will read full sector into the provided buffer
and therefore corrupting memory past buffer end.

4 years agoMFC r360801: Merge commit 21e5e1724b75 from llvm git:
Ed Maste [Sun, 10 May 2020 14:56:25 +0000 (14:56 +0000)]
MFC r360801: Merge commit 21e5e1724b75 from llvm git:

  getMainExecutable: Fix hand-rolled AT_EXECPATH for older FreeBSD

  Once we hit AT_NULL, we need to bail out of the loop; not just the
  enclosing switch.  This fixes basic usage (e.g. `cc --version`) when
  AT_EXECPATH isn't present on older branches (e.g. under
  emu-user-static, at the moment), where we would previously run off
  the end of ::environ.

  Patch By: kevans

  Reviewed By: arichardson

4 years agoMFC 356839: Save and restore floating point registers in get/set_mcontext().
John Baldwin [Sun, 10 May 2020 14:53:08 +0000 (14:53 +0000)]
MFC 356839: Save and restore floating point registers in get/set_mcontext().

arm64 and riscv were only saving and restoring floating point
registers for sendsig() and sys_sigreturn(), but not for getcontext(),
setcontext(), and swapcontext().

While here, remove an always-false check for uap being NULL from
sys_sigreturn().

4 years agoMerge r360138:
Gleb Smirnoff [Sun, 10 May 2020 14:46:46 +0000 (14:46 +0000)]
Merge r360138:

  Fix immediate crash when snmpd is bound to a specific IP address.

  The code that sets up msghdr must first fully fill in the msghdr
  itself, and only then use CMSG_xxx() macros.

PR: 246323

4 years agoMFC r360609:
Kristof Provost [Sun, 10 May 2020 09:50:44 +0000 (09:50 +0000)]
MFC r360609:

pf: Improve DIOCADDRULE validation

We expect the addrwrap.p.dyn value to be set to NULL (and assert such),
but do not verify it on input.

Reported-by: syzbot+936a89182e7d8f927de1@syzkaller.appspotmail.com

4 years agoMFC r360610: Add session locking in cfiscsi_ioctl_handoff().
Alexander Motin [Sun, 10 May 2020 02:13:38 +0000 (02:13 +0000)]
MFC r360610: Add session locking in cfiscsi_ioctl_handoff().

While there, remove ifdef around cs_target check in cfiscsi_ioctl_list().
I am not sure why this ifdef was added, but without this check code will
crash below on NULL dereference.

4 years agoMFC 357255,357337: Fix definition of SSTATUS_SD and MSTATUS_SD.
John Baldwin [Sun, 10 May 2020 00:34:09 +0000 (00:34 +0000)]
MFC 357255,357337: Fix definition of SSTATUS_SD and MSTATUS_SD.

357255:
Fix definition of SSTATUS_SD

The SD bit is defined as the MSB of the sstatus register, meaning its
position will vary depending on the CSR's length. Previously, there were
two (unused) defines for this, for the 32 and 64-bit cases, but their
definitions were swapped.

Consolidate these into one define: SSTATUS_SD, and make the definition
dependent on the value of __riscv_xlen.

357337:
Fix 64-bit value of SSTATUS_SD to use an unsigned long.

While here, fix MSTATUS_SD to match SSTATUS_SD.

4 years agoMFC 357313: Trim duplicate CSR swaps from user exceptions.
John Baldwin [Sat, 9 May 2020 21:34:50 +0000 (21:34 +0000)]
MFC 357313: Trim duplicate CSR swaps from user exceptions.

The stack pointer is swapped with the sscratch CSR just before the
jump to cpu_exception_handler_user where the first instruction swaps
it again.  The two swaps together are a no-op, but the csr swap
instructions can be expensive (e.g. on Bluespec RISC-V cores csr swap
instructions force a full pipeline stall).

4 years agoMFC 357305: Remove unused fields from struct pcb.
John Baldwin [Sat, 9 May 2020 21:32:44 +0000 (21:32 +0000)]
MFC 357305: Remove unused fields from struct pcb.

cpu_switch/throw() and savectx() do not save or restore any values in
these fields which mostly held non-callee-save registers.

makectx() copied these fields from kdb_frame, but they weren't used
except for PC_REGS using pcb_sepc.  Change PC_REGS to use
kdb_frame->tf_sepc directly instead.

4 years agoMFC 357591:
John Baldwin [Sat, 9 May 2020 20:14:05 +0000 (20:14 +0000)]
MFC 357591:
Read the breakpoint instruction to determine its length in BKPT_SKIP.

This fixes continuing from debug.kdb.enter=1 after enabling the use of
compressed instructions since the compiler can emit the two byte
c.ebreak instead of the 4 byte ebreak.

4 years agoMFC 357593: Remove stale workaround for the htif console.
John Baldwin [Sat, 9 May 2020 20:10:01 +0000 (20:10 +0000)]
MFC 357593: Remove stale workaround for the htif console.

In practice this discarded all characters entered at the DDB prompt.

4 years agoMFC 354289,354441,355095: Use lld on armv6.
John Baldwin [Sat, 9 May 2020 20:02:48 +0000 (20:02 +0000)]
MFC 354289,354441,355095: Use lld on armv6.

354289:
armv6: Switch to LLD by default

This could just be ${__TT} == "arm", except armv5 isn't slated for death until
EOY.

arm tinderbox builds.  Let's see what else shakes out.

354441:
arch.7: armv6 uses lld by default as of r354289

355095:
remove armv6 LLVM workaround introduced in r341812

r341812 enabled only arm target support in LLVM on arm and armv6,
because ld.bfd 2.17.50 lacked support for range extensions required for
linking such large binaries/libraries.  r341812 indicated that the
workaround should be removed once the userland can be linked by lld.

r354289 switched armv6 to use lld by default, so remove the workaround
on armv6.  The workaround remains in place for arm (v5), and will
presumably be removed when arm is retired.

4 years agoMFC 356499: Use clang and lld as the default toolchain for RISCV.
John Baldwin [Sat, 9 May 2020 17:14:59 +0000 (17:14 +0000)]
MFC 356499: Use clang and lld as the default toolchain for RISCV.

- Enable clang and lld as system toolchains.
- Don't use external GCC for universe by default.
- Re-enable riscv64sf since it builds fine with clang + lld.

Sponsored by: DARPA