]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoMFV r362143:
Cy Schubert [Sat, 13 Jun 2020 04:47:59 +0000 (04:47 +0000)]
MFV r362143:

Update sqlite3 to 3.32.2 (3320200).

CVE-2020-11655: SQLite through 3.31.1 allows attackers to cause a denial of
service (segmentation fault) via a malformed window-function query because
the AggInfo object's initialization is mishandled.

CVE-2020-13434: SQLite through 3.32.0 has an integer overflow in
sqlite3_str_vappendf in printf.c.

CVE-2020-13435: SQLite through 3.32.0 has a segmentation fault in
sqlite3ExprCodeTarget in expr.c.

CVE-2020-13630: ext/fts3/fts3.c in SQLite before 3.32.0 has a
use-after-free in fts3EvalNextRow, related to the snippet feature

CVE-2020-13631: SQLite before 3.32.0 allows a virtual table to be renamed
to the name of one of its shadow tables, related to alter.c and build.c.

CVE-2020-13632: ext/fts3/fts3_snippet.c in SQLite before 3.32.0 ha s a
NULL pointer dereference via a crafted matchinfo() query.

PR: 247149
Reported by: spam123@bitbert.com
MFC after: 3 days
Security: vuxml: c4ac9c79-ab37-11ea-8b5e-b42e99a1b9c3
https://nvd.nist.gov/vuln/detail/CVE-2020-11655
https://nvd.nist.gov/vuln/detail/CVE-2020-13434
https://nvd.nist.gov/vuln/detail/CVE-2020-13435
https://nvd.nist.gov/vuln/detail/CVE-2020-13630
https://nvd.nist.gov/vuln/detail/CVE-2020-13631
https://nvd.nist.gov/vuln/detail/CVE-2020-13632

3 years agoImport sqlite3-3.32.2 (3320200)
Cy Schubert [Sat, 13 Jun 2020 03:50:35 +0000 (03:50 +0000)]
Import sqlite3-3.32.2 (3320200)

3 years agoFix !DEBUGNET build after r362138
Conrad Meyer [Sat, 13 Jun 2020 03:16:09 +0000 (03:16 +0000)]
Fix !DEBUGNET build after r362138

X-MFC-With: r362138

3 years agoFlip kern.tty_info_kstacks on by default
Conrad Meyer [Sat, 13 Jun 2020 03:04:40 +0000 (03:04 +0000)]
Flip kern.tty_info_kstacks on by default

It's a useful debug aid for anyone using Ctrl-T today, and doesn't seem to be
widely known.  So, enable it out of the box to help people find it.

It's a tunable and sysctl, so if you don't like it, it's easy to disable
locally.

If people really hate it, we can always flip it back.

Reported by: Daniel O'Connor

3 years agoLinuxkpi uses the rb-tree structures without using their interfaces,
Doug Moore [Sat, 13 Jun 2020 01:54:09 +0000 (01:54 +0000)]
Linuxkpi uses the rb-tree structures without using their interfaces,
making them break when the representation changes. Revert changes that
eliminated the color field from rb-trees, leaving everything as it was
before.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D25250

3 years agonet80211: Add framework for debugnet(4) support
Conrad Meyer [Sat, 13 Jun 2020 00:59:36 +0000 (00:59 +0000)]
net80211: Add framework for debugnet(4) support

Allow net80211 drivers to register a small vtable of debugnet-related
methods.

This is not a functional change.  Driver support is needed, similar to
debugnet(4) for wired NICs.

Reviewed by: adrian, markj (earlier version both)
Differential Revision: https://reviews.freebsd.org/D17308

3 years agoAllow <sys/elf_common.h> to be used in assembly.
John Baldwin [Fri, 12 Jun 2020 23:43:44 +0000 (23:43 +0000)]
Allow <sys/elf_common.h> to be used in assembly.

Hide C-only declarations under #ifndef LOCORE.  This will be used by
future changes to define ELF notes in assembly.

Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25211

3 years agoAllow <sys/param.h> to be included from userland assembly files.
John Baldwin [Fri, 12 Jun 2020 23:42:36 +0000 (23:42 +0000)]
Allow <sys/param.h> to be included from userland assembly files.

This will be used by future changes to define ELF notes in assembly.

Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25211

3 years agoVarious optimizations to software AES-CCM and AES-GCM.
John Baldwin [Fri, 12 Jun 2020 23:10:30 +0000 (23:10 +0000)]
Various optimizations to software AES-CCM and AES-GCM.

- Make use of cursors to avoid data copies for AES-CCM and AES-GCM.

  Pass pointers into the request's input and/or output buffers
  directly to the Update, encrypt, and decrypt hooks rather than
  always copying all data into a temporary block buffer on the stack.

- Move handling for partial final blocks out of the main loop.

  This removes branches from the main loop and permits using
  encrypt/decrypt_last which avoids a memset to clear the rest of the
  block on the stack.

- Shrink the on-stack buffers to assume AES block sizes and CCM/GCM
  tag lengths.

- For AAD data, pass larger chunks to axf->Update.  CCM can take each
  AAD segment in a single call.  GMAC can take multiple blocks at a
  time.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25058

3 years agoFix a regression in r361804 for TLS 1.3.
John Baldwin [Fri, 12 Jun 2020 22:27:26 +0000 (22:27 +0000)]
Fix a regression in r361804 for TLS 1.3.

I was not including the record type stored in the first byte of the
trailer as part of the payload to be encrypted and hashed.

Sponsored by: Netflix

3 years agoControl for Special Register Buffer Data Sampling mitigation.
Konstantin Belousov [Fri, 12 Jun 2020 22:14:45 +0000 (22:14 +0000)]
Control for Special Register Buffer Data Sampling mitigation.

New microcode update for Intel enables mitigation for SRBDS, which
slows down RDSEED and related instructions.  The update also provides
a control to limit the mitigation to SGX enclaves, which should
restore the speed of random generator by the cost of potential
cross-core bufer sampling.

See https://software.intel.com/security-software-guidance/insights/deep-dive-special-register-buffer-data-sampling

GIve the user control over it.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25221

3 years agox86: add bits definitions for SRBDS mitigation control.
Konstantin Belousov [Fri, 12 Jun 2020 22:12:57 +0000 (22:12 +0000)]
x86: add bits definitions for SRBDS mitigation control.

See https://software.intel.com/security-software-guidance/insights/deep-dive-special-register-buffer-data-sampling

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25221

3 years agortld: set osrel when in the direct exec mode.
Konstantin Belousov [Fri, 12 Jun 2020 22:10:03 +0000 (22:10 +0000)]
rtld: set osrel when in the direct exec mode.

Rtld itself is a shared object which does not have vendor note, so
after the direct exec of ld-elf.so.1 process has p_osrel set to zero.
This affects the ABI of syscalls.

Set osrel to the __FreeBSD_version value at compile time right after
rtld identified direct exec mode.  Then, switch to the osrel read from
the binary note or zero if no note, right before starting calling
ifunc resolvers, which is the first byte of the user code.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agoverify_pcr_export: bump kenv_mvallen if needed
Simon J. Gerraty [Fri, 12 Jun 2020 21:55:30 +0000 (21:55 +0000)]
verify_pcr_export: bump kenv_mvallen if needed

The loader.ve.hashed list can easily exceed KENV_MVALLEN.
If so, bump kenv_mvallen to a multiple of KENV_MVALLEN to
accommodate the value.

Reviewed by: stevek
MFC after: 1 week

3 years agoHonor db_pager_quit in some vm_object ddb commands
Eric van Gyzen [Fri, 12 Jun 2020 21:53:08 +0000 (21:53 +0000)]
Honor db_pager_quit in some vm_object ddb commands

These can be rather verbose.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon

3 years agomac_veriexec_fingerprint_check_vnode: v_writecount > 0 means active writers
Simon J. Gerraty [Fri, 12 Jun 2020 21:51:20 +0000 (21:51 +0000)]
mac_veriexec_fingerprint_check_vnode: v_writecount > 0 means active writers

v_writecount can actually be < 0 for text,
so check for v_writecount > 0

Reviewed by: stevek
MFC after: 1 week

3 years agoMinor cleanup of initialized variables
Simon J. Gerraty [Fri, 12 Jun 2020 21:48:46 +0000 (21:48 +0000)]
Minor cleanup of initialized variables

Sort the list and cleanup trailing white-space

Reviewed by: stevek
MFC after: 1 week

3 years agoFix AES-CCM requests with an AAD size smaller than a single block.
John Baldwin [Fri, 12 Jun 2020 21:33:02 +0000 (21:33 +0000)]
Fix AES-CCM requests with an AAD size smaller than a single block.

The amount to copy for the first block is the minimum of the size of
the AAD region or the remaining space in the first block.

Reported by: cryptocheck -z
MFC after: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25140

3 years agoVarious fixes to TLS for MIPS.
John Baldwin [Fri, 12 Jun 2020 21:21:18 +0000 (21:21 +0000)]
Various fixes to TLS for MIPS.

- Clear the current thread's TLS pointer on exec. Previously the TLS
  pointer (and register) remain unchanged.

- Explicitly clear the TLS pointer when new threads are created.

- Make md_tls_tcb_offset per-process instead of per-thread.

  The layout of the TLS and TCB are identical for all threads in a
  process, it is only the TLS pointer values themselves that vary by
  thread.  This also makes setting md_tls_tcb_offset in
  cpu_set_user_tls() redundant with the setting in exec_setregs(), so
  only set it in exec_setregs().

Submitted by: Alfredo Mazzinghi (1)
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24957

3 years agoFPU init: allocate initial state from UMA to ensure alignment
Eric van Gyzen [Fri, 12 Jun 2020 21:17:56 +0000 (21:17 +0000)]
FPU init: allocate initial state from UMA to ensure alignment

The Intel Instruction Set Reference says this about the XSAVE instruction:

    Use of a destination operand not aligned to 64-byte boundary
    (in either 64-bit or 32-bit modes) results in a general-protection
    (#GP) exception.

This alignment happens naturally when all malloc buckets are powers
of two.  However, this change is necessary on some systems when
certain non-power-of-two (and non-multiple of 64) malloc buckets
are defined.

Reviewed by: cem; kib; earlier version by jhb
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D25098

3 years agoFPU: make xsave_area_desc static
Eric van Gyzen [Fri, 12 Jun 2020 21:12:26 +0000 (21:12 +0000)]
FPU: make xsave_area_desc static

...because it can be.

Reviewed by: cem kib
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D25098

3 years agoFPU init: Do potentially blocking operations before disabling interrupts
Eric van Gyzen [Fri, 12 Jun 2020 21:10:45 +0000 (21:10 +0000)]
FPU init: Do potentially blocking operations before disabling interrupts

In particular, uma_zcreate creates sysctl oids, which locks an sx lock,
which uses IPIs under contention.  IPIs tend not to work very well
when interrupts are disabled.  Who knew, right?

Reviewed by: cem kib
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D25098

3 years agoSo it turns out with the right window scaling you can get the code in all stacks to
Randall Stewart [Fri, 12 Jun 2020 19:56:19 +0000 (19:56 +0000)]
So it turns out with the right window scaling you can get the code in all stacks to
always want to do a window update, even when no data can be sent. Now in
cases where you are not pacing thats probably ok, you just send an extra
window update or two. However with bbr (and rack if its paced) every time
the pacer goes off its going to send a "window update".

Also in testing bbr I have found that if we are not responding to
data right away we end up staying in startup but incorrectly holding
a pacing gain of 192 (a loss). This is because the idle window code
does not restict itself to only work with PROBE_BW. In all other
states you dont want it doing a PROBE_BW state change.

Sponsored by: Netflix Inc.
Differential Revision:  https://reviews.freebsd.org/D25247

3 years agox86: Bump default msi/msix vector limit to 2048
Andrew Gallatin [Fri, 12 Jun 2020 18:41:12 +0000 (18:41 +0000)]
x86: Bump default msi/msix vector limit to 2048

Given that 64c/128t CPUs are currently available, and that many
devices (nvme, many NICs) desire to map 1 MSI-X vector per core,
or even 1 per-thread, it is becoming far easier to see MSI-X interrupt
setup fail due to msi vector exhaustion, and devices fail to attach at
boot on large system.

This bump costs 12KB on amd64 (and 6KB on i386), which seems
worth the trade off for a better out of the box experience on
high end hardware.

Reviewed by: jhb
MFC after: 21 days
Sponsored by: Netflix

3 years agoposix_spawn: fix for some custom allocator setups
Kyle Evans [Fri, 12 Jun 2020 18:13:32 +0000 (18:13 +0000)]
posix_spawn: fix for some custom allocator setups

libc cannot assume that aligned_alloc and free come from jemalloc, or that
any application providing its own malloc and free is actually providing
aligned_alloc.

Switch back to malloc and just make sure we're passing a properly aligned
stack into rfork_thread, as an application perhaps can't reasonably replace
just malloc or just free without headaches.

This unbreaks ksh93 after r361996, which provides malloc/free but no
aligned_alloc.

Reported by: freqlabs
Diagnosed by: Andrew Gierth <andrew_tao173.riddles.org.uk>
X-MFC-With: r361996

3 years agoRevert r362108, as it breaks compilation.
Doug Moore [Fri, 12 Jun 2020 17:48:12 +0000 (17:48 +0000)]
Revert r362108, as it breaks compilation.

3 years agoCoresight replicator:
Ruslan Bukin [Fri, 12 Jun 2020 17:31:38 +0000 (17:31 +0000)]
Coresight replicator:
o Add a header file;
o Split-out FDT attachment to a separate file;
o Add ACPI attachment.

Sponsored by: DARPA, AFRL

3 years agoThe linuxkpi code accesses left/right rb tree pointers without using
Doug Moore [Fri, 12 Jun 2020 16:51:55 +0000 (16:51 +0000)]
The linuxkpi code accesses left/right rb tree pointers without using
RB_LEFT or RB_RIGHT, so they aren't stripping off the color bit
encoded there. Strip off that bit for linuxkpi.

Reported by: dch
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D25245

3 years agoWhitespace change due to upstream cleanup.
Michael Tuexen [Fri, 12 Jun 2020 16:40:10 +0000 (16:40 +0000)]
Whitespace change due to upstream cleanup.

MFC after: 1 week

3 years agoMore cleanups due to ifdef cleanup done upstream
Michael Tuexen [Fri, 12 Jun 2020 16:31:13 +0000 (16:31 +0000)]
More cleanups due to ifdef cleanup done upstream

MFC after: 1 week

3 years agoAdd compat.linux.debug sysctl, to make it possible to silence down
Edward Tomasz Napierala [Fri, 12 Jun 2020 14:37:50 +0000 (14:37 +0000)]
Add compat.linux.debug sysctl, to make it possible to silence down
the debug messages. While here, clean up some variable naming.

Reviewed by: bcr (manpages), emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25230

3 years agoFix naming clash.
Edward Tomasz Napierala [Fri, 12 Jun 2020 14:31:19 +0000 (14:31 +0000)]
Fix naming clash.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoMake linux(4) warn about unsupported fcntls.
Edward Tomasz Napierala [Fri, 12 Jun 2020 14:25:32 +0000 (14:25 +0000)]
Make linux(4) warn about unsupported fcntls.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25231

3 years agoMinor code cleanup; no functional changes.
Edward Tomasz Napierala [Fri, 12 Jun 2020 14:23:10 +0000 (14:23 +0000)]
Minor code cleanup; no functional changes.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25232

3 years agoFix config_intrhook leak on initial reset failure.
Alexander Motin [Fri, 12 Jun 2020 14:14:01 +0000 (14:14 +0000)]
Fix config_intrhook leak on initial reset failure.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

3 years agoARM Coresight Trace Memory Controller (TMC):
Ruslan Bukin [Fri, 12 Jun 2020 13:59:58 +0000 (13:59 +0000)]
ARM Coresight Trace Memory Controller (TMC):
o Split-out FDT attachment to a separate file;
o Add ACPI attachment.

Sponsored by: DARPA, AFRL

3 years agoMFV r362082:
Cy Schubert [Fri, 12 Jun 2020 13:02:44 +0000 (13:02 +0000)]
MFV r362082:

Update sqlite3 3.31.1 --> 3.32.0.

PR: 247149
Reported by: spam123@bitbert.com
Reminded by: emaste
MFC after: 3 days
Security: CVE-2020-11655, CVE-2020-13434, CVE-2020-13435,
CVE-2020-13630, CVE-2020-13631, CVE-2020-13632

3 years agoTeach the arm64 vfp.h about struct thread.
Andrew Turner [Fri, 12 Jun 2020 10:43:21 +0000 (10:43 +0000)]
Teach the arm64 vfp.h about struct thread.

Ensure struct thread is defined in vfp.h. In some cases it is not and stops
the kernel from building.

Sponsored by: Innovate UK

3 years agoSmall cleanup due to upstream ifdef cleanups.
Michael Tuexen [Fri, 12 Jun 2020 10:13:23 +0000 (10:13 +0000)]
Small cleanup due to upstream ifdef cleanups.

MFC after: 1 week

3 years agoAdd myself (gbe) to committers-doc.dot and calendar.freebsd
Gordon Bergling [Fri, 12 Jun 2020 09:34:10 +0000 (09:34 +0000)]
Add myself (gbe) to committers-doc.dot and calendar.freebsd

Reviewed by: bcr (mentor)
Approved by: bcr (mentor)
Differential Revision: https://reviews.freebsd.org/D25241

3 years ago[wlanstats] Add the per-node amsdu hardware decap'ed receive stats.
Adrian Chadd [Fri, 12 Jun 2020 06:10:27 +0000 (06:10 +0000)]
[wlanstats] Add the per-node amsdu hardware decap'ed receive stats.

This is useful for tracking hardware provided AMSDU frames to see
when we're (a) seeing them, and (b) seeing the split between
intermediary and final frames.

Tested:

* QCA9880 (athp) - AP mode

3 years ago[net80211] First part of A-MSDU offload handling - don't bump A-MPDU reordering seqno
Adrian Chadd [Fri, 12 Jun 2020 04:19:03 +0000 (04:19 +0000)]
[net80211] First part of A-MSDU offload handling - don't bump A-MPDU reordering seqno

When doing A-MSDU offload handling the driver is required to mark
A-MSDUs from the same MPDU with the same sequence number.
It then tags them as AMSDU (if it's a decap'ed A-MSDU) and AMSDU_MORE
(saying there's more AMSDUs decapped in the same MSDU.)
This allows encryption and sequence number offload to work right.

In the A-MSDU path the sequence number check looks at the A-MSDU flags
in the frame to see whether it's part of the same seqno and will pass them
(ie, not increment rx_seq until the last A-MSDU is seen from the driver,
or a new seqno shows up.0

However, I did this work in the A-MSDU path but not the A-MSDU in A-MPDU path.
For the non A-MDSU offload case the A-MPDU receive reordering will do its
thing and then pass up the MPDU up for decap - which then will see it's
an A-MSDU and decap each sub-frame.  But this isn't done for offloaded
A-MSDU frames.

This requires two parts:

* Don't bump the RX sequence number, same as above; and
* If frames go into the reordering buffer, they need to be added into the slot
  as a set of frames rather than a single frame, so once a new seqno shows up
  this slot can be marked as "full" and we can move on.

This patch does the first.  The latter requires that I find and commit
work to change rxa_m from an mbuf to an mbufq and the nhandle A-MSDU
there.  But, the first is enough to allow the normal case (ie, no or not
a lot of A-MPDU RX reordering) to work.

This allows the athp driver (QCA9880) throughput to go from VERY low
(like 5mbit TCP, 1/3-1/4 expected UDP throughput) to ~ 250mbit TCP
and > 300mbit UDP on a VHT/40 channel.  TCP sucks because, well, it
shows up as MASSIVE packet loss when all but one frame in a decap'ed
A-MSDU stream is dropped. Le whoops.

Now, where'd I put that laptop with the patch for rxa_m mbufq that
I wrote like in 2017...

Tested:

* AR9380, STA/AP mode (a big no-op, no A-MSDU hardware decap);
* if_run (RT3593), STA DWDS mode (A-MPDU / A-MSDU receive, but again
  no A-MSDU hardware decap);
* QCA9880, STA/AP mode (which is doing hardware A-MPDU/A-MSDU decap,
  but no A-MPDU reordering in the firmware.)

3 years agoImport sqlite3-3.32.0 (3320000)
Cy Schubert [Fri, 12 Jun 2020 01:56:08 +0000 (01:56 +0000)]
Import sqlite3-3.32.0 (3320000)

3 years agoDecode the "LACP Fast Timeout" LAGG option flag
Ravi Pokala [Thu, 11 Jun 2020 22:46:08 +0000 (22:46 +0000)]
Decode the "LACP Fast Timeout" LAGG option flag

r286700 added the "lacp_fast_timeout" option to `ifconfig', but we forgot to
include the new option in the string used to decode the option bits. Add
"LACP_FAST_TIMO" to LAGG_OPT_BITS.

Also, s/LAGG_OPT_LACP_TIMEOUT/LAGG_OPT_LACP_FAST_TIMO/g , to be clearer that
the flag indicates "Fast Timeout" mode.

Reported by: Greg Foster <gfoster at panasas dot com>
Reviewed by: jpaetzel
MFC after: 1 week
Sponsored by: Panasas
Differential Revision: https://reviews.freebsd.org/D25239

3 years agoShorten the filename of the coresight replicator driver.
Ruslan Bukin [Thu, 11 Jun 2020 21:52:06 +0000 (21:52 +0000)]
Shorten the filename of the coresight replicator driver.

Sponsored by: DARPA, AFRL

3 years agonetmap: introduce netmap_kring_on()
Vincenzo Maffione [Thu, 11 Jun 2020 20:35:28 +0000 (20:35 +0000)]
netmap: introduce netmap_kring_on()

This function returns NULL if the ring identified by
queue id and direction is in netmap mode. Otherwise
return the corresponding kring.
Use this function to replace vtnet_netmap_queue_on().

MFC after: 1 week

3 years agoCorrect comment (this should have been committed with r362065).
Konstantin Belousov [Thu, 11 Jun 2020 20:26:39 +0000 (20:26 +0000)]
Correct comment (this should have been committed with r362065).

Sponsored by: The FreeBSD Foundation
MFC after: 13 days

3 years agoSkip sys.net.if_lagg_test.lacp_linkstate_destroy_stress in CI because of panic
Li-Wen Hsu [Thu, 11 Jun 2020 18:59:57 +0000 (18:59 +0000)]
Skip sys.net.if_lagg_test.lacp_linkstate_destroy_stress in CI because of panic

PR: 244168
Sponsored by: The FreeBSD Foundation

3 years agoRemove some more duplicate test cases I accidentally committed
Mateusz Piotrowski [Thu, 11 Jun 2020 18:14:34 +0000 (18:14 +0000)]
Remove some more duplicate test cases I accidentally committed

Reported by: markj, yuripv
MFC after: 2 weeks
X-MFC-With: 362017

3 years agoRestore TLB invalidations done before smp started.
Konstantin Belousov [Thu, 11 Jun 2020 17:25:20 +0000 (17:25 +0000)]
Restore TLB invalidations done before smp started.

In particular, invalidation of the preloaded modules text to allow
execution from it was broken after D25188/r362031.

Reviewed by: markj
Reported by: delphij, dhw
Sponsored by: The FreeBSD Foundation
MFC after: 13 days

3 years agoem(4): Always reinit interface when adding/removing VLAN
Eric Joyner [Thu, 11 Jun 2020 15:59:49 +0000 (15:59 +0000)]
em(4): Always reinit interface when adding/removing VLAN

This partially reverts r361053 since there have been reports
by users that this breaks some functionality for em(4)
devices; it seems at first glance that some sort of interface
restart is required for those cards.

This isn't a proper fix; this unbreaks those users until a proper
fix is found for their issues.

PR: 240818
Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

3 years agoxargs(1): Add EXAMPLES to man page
Fernando ApesteguĂ­a [Thu, 11 Jun 2020 15:14:39 +0000 (15:14 +0000)]
xargs(1): Add EXAMPLES to man page

Add EXAMPLES covering options I, J, L, n, P.

While here, fix warning (STYLE: no blank before trailing delimiter: Fl P,)
Bumping .Dd

Approved by: bcr@
Differential Revision: https://reviews.freebsd.org/D25214

3 years agoDon't use newlines with linux_msg(). No functional changes.
Edward Tomasz Napierala [Thu, 11 Jun 2020 14:57:30 +0000 (14:57 +0000)]
Don't use newlines with linux_msg().  No functional changes.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoAdd missing range checks when receiving USB ethernet packets.
Hans Petter Selasky [Thu, 11 Jun 2020 14:31:51 +0000 (14:31 +0000)]
Add missing range checks when receiving USB ethernet packets.

Found by: Ilja Van Sprundel, IOActive
MFC after: 3 days
Sponsored by: Mellanox Technologies

3 years agoReplace LINUX_FASYNC with LINUX_O_ASYNC; no functional changes.
Edward Tomasz Napierala [Thu, 11 Jun 2020 14:09:43 +0000 (14:09 +0000)]
Replace LINUX_FASYNC with LINUX_O_ASYNC; no functional changes.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25218

3 years agoNon-functional changes due to upstream cleanup.
Michael Tuexen [Thu, 11 Jun 2020 13:34:09 +0000 (13:34 +0000)]
Non-functional changes due to upstream cleanup.

MFC after: 1 week

3 years agoFix grabbing of tegra uart.
Michal Meloun [Thu, 11 Jun 2020 12:53:22 +0000 (12:53 +0000)]
Fix grabbing of tegra uart.
An attempt to write to FCR register may corrupt transmit FIFO,
so we should wait for the FIFO to be empty before we can modify it.

MFC after: 1 week

3 years agoImprove the warnings.
Edward Tomasz Napierala [Thu, 11 Jun 2020 12:35:00 +0000 (12:35 +0000)]
Improve the warnings.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoMake linux(4) handle SO_REUSEPORT.
Edward Tomasz Napierala [Thu, 11 Jun 2020 12:25:49 +0000 (12:25 +0000)]
Make linux(4) handle SO_REUSEPORT.

Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25216

3 years agofix up r362047: a call to zvol_*_minors() was not hidden from userland
Andriy Gapon [Thu, 11 Jun 2020 11:35:30 +0000 (11:35 +0000)]
fix up r362047: a call to zvol_*_minors() was not hidden from userland

Reported by: CI/FreeBSD-head-powerpc64-build
MFC after: 5 weeks
X-MFC with: r362047

3 years agorework how ZVOLs are updated in response to DSL operations
Andriy Gapon [Thu, 11 Jun 2020 10:41:31 +0000 (10:41 +0000)]
rework how ZVOLs are updated in response to DSL operations

With this change all ZVOL updates are initiated from the SPA sync
context instead of a mix of the sync and open contexts.  The updates are
queued to be applied by a dedicated thread in the original order.  This
should ensure that ZVOLs always accurately reflect the corresponding
datasets.  ZFS ioctl operations wait on the mentioned thread to complete
its work.  Thus, the illusion of the synchronous ZVOL update is
preserved.  At the same time, the SPA sync thread never blocks on ZVOL
related operations avoiding problems like reported in bug 203864.

This change is based on earlier work in the same direction: D7179 and
D14669 by Anthoine Bourgeois.  D7179 tried to perform ZVOL operations
in the open context and that opened races between them.  D14669 uses a
design very similar to this change but with different implementation
details.

This change also heavily borrows from similar code in ZoL, but there are
many differences too.  See:
- https://github.com/zfsonlinux/zfs/commit/a0bd735adb1b1eb81fef10b4db102ee051c4d4ff
- https://github.com/zfsonlinux/zfs/issues/3681
- https://github.com/zfsonlinux/zfs/issues/2217

PR: 203864
MFC after: 5 weeks
Sponsored by: CyberSecure
Differential Revision: https://reviews.freebsd.org/D23478

3 years agoMake sure packets generated by raw IP code is let through by mlx5en(4).
Hans Petter Selasky [Thu, 11 Jun 2020 09:41:54 +0000 (09:41 +0000)]
Make sure packets generated by raw IP code is let through by mlx5en(4).

Allow the TCP header to reside in the mbuf following the IP header.
Else such packets will get dropped.

Backtrace:
mlx5e_sq_xmit()
mlx5e_xmit()
ether_output_frame()
ether_output()
ip_output_send()
ip_output()
rip_output()
sosend_generic()
sosend()
kern_sendit()
sendit()
sys_sendto()
amd64_syscall()
fast_syscall_common()

MFC after: 1 week
Sponsored by: Mellanox Technologies

3 years agoExtend use of unlikely() in the fast path, in mlx5en(4).
Hans Petter Selasky [Thu, 11 Jun 2020 09:38:51 +0000 (09:38 +0000)]
Extend use of unlikely() in the fast path, in mlx5en(4).

Typically the TCP/IP headers fit within the first mbuf and should not
trigger any of the error cases. Use unlikely() for these cases.

No functional change.

MFC after: 1 week
Sponsored by: Mellanox Technologies

3 years agoUse const keyword when parsing the TCP/IP header in the fast path in mlx5en(4).
Hans Petter Selasky [Thu, 11 Jun 2020 09:36:37 +0000 (09:36 +0000)]
Use const keyword when parsing the TCP/IP header in the fast path in mlx5en(4).

When parsing the TCP/IP header in the fast path, make it clear by using
the const keyword, no fields are to be modified inside the transmitted
packet.

No functional change.

MFC after: 1 week
Sponsored by: Mellanox Technologies

3 years agoiicbb: rebuild the bit-banging algorithms using different primitives
Andriy Gapon [Thu, 11 Jun 2020 05:34:31 +0000 (05:34 +0000)]
iicbb: rebuild the bit-banging algorithms using different primitives

I2C_SET was quite inflexible, it used too long delays as well as some
unnecessary delays.  The new building blocks are iicbb_clockin and
iicbb_clockout.  The former sets SDA and starts the high period of SCL,
the latter executes the low period of SCL.  What happens during the high
phase depends on the operation.  For writes we just hold both lines, for
reads we poll SDA.  S, Sr and P change SDA in the middle of the high
period.

Also, the calculation of udelay has been updated, so that the resulting
period more closely corresponds the requested bus frequency.  There is a
new knob, io_delay, that allows to further adjust udelay based on the
estimated latency of pin toggling operations.

Finally, I slightly changed debug tracing and added error indicators to
it.  The debug prints are compiled in but disabled by default.  This can
be of use if there is any fallout from this change.

Some ideas for further improvements:
- add a function for sub-microsecond delays (e.g., in units of 1/10th of
  a microsecond) and use it for more precise timing of short delays;
- account for the actual time spent in the pin I/O.

Some sample debug output with the new code follows.

Reading temperature and humidity from HTU21 in the bus hold mode:
  <<w80+ we3+ <w81+ .....r6d+ rac+ r94- >>
  <<w80+ we5+ <w81+ .............r47+ re2+ r84- >>
where '<<' is S, '<' is Sr, '>>' is P, '.' is one millisecond of clock
stretching by the slave.

Reading temperature and humidity in the no-hold mode:
  <<w80+ wf3+ >>
  <<w81- >>
  <<w81+ r6d+ r54+ raf- >>
  <<w80+ wf5+ >>
  <<w81- >>
  <<w81+ r48+ r4e+ r9c- >>
where '+' is Ack and '-' is NoAck.
We see that first read attempts are not acknowledged.

MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D22206

3 years agoRemove duplicate lines from sed tests
Mateusz Piotrowski [Thu, 11 Jun 2020 03:03:52 +0000 (03:03 +0000)]
Remove duplicate lines from sed tests

Reported by: yuripv
Approved by: pfg (src)
MFC after: 2 weeks
X-MFC-With: 362017

3 years agoHard-code the ice_ddp firmware version.
Mark Johnston [Thu, 11 Jun 2020 00:36:35 +0000 (00:36 +0000)]
Hard-code the ice_ddp firmware version.

Like every other firmware image in the tree, the makefile will need to
be updated to point to the newest import.

Reviewed by: erj, imp (previous version)
Differential Revision: https://reviews.freebsd.org/D25222

3 years agoFix a couple of nits in Linux sysinfo(2) emulation.
Mark Johnston [Wed, 10 Jun 2020 23:52:50 +0000 (23:52 +0000)]
Fix a couple of nits in Linux sysinfo(2) emulation.

- Use the same definition of free memory as Linux.
- Rename the totalbig and freebig fields to match the corresponding
  names on Linux.

Discussed with: alc
MFC after: 1 week

3 years agoAdd a comment reflecting the commit log for r361945.
Mark Johnston [Wed, 10 Jun 2020 23:52:39 +0000 (23:52 +0000)]
Add a comment reflecting the commit log for r361945.

Suggested by: alc
Reviewed by: alc
MFC with: r361945

3 years agoRemove the FIRMWARE_MAX limit.
Mark Johnston [Wed, 10 Jun 2020 23:52:29 +0000 (23:52 +0000)]
Remove the FIRMWARE_MAX limit.

The firmware module arbitrarily limits us to at most 50 images.  It is
possible to hit this limit on platforms that preload many firmware
images, or link all of the firmware images for a set of devices into the
kernel.

Convert the table into a linked list, removing the limit.

Reported by: Steve Wheeler
Reviewed by: rpokala
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC (Netgate)
Differential Revision: https://reviews.freebsd.org/D25161

3 years agopowerpc/pmap: Fix pte_find_next() iterators for booke64 pmap
Justin Hibbits [Wed, 10 Jun 2020 23:03:35 +0000 (23:03 +0000)]
powerpc/pmap: Fix pte_find_next() iterators for booke64 pmap

After r361988 fixed the reference count leak on booke64, it became possible
for an iteration somewhere in the middle of a page to become stale, with the
page vanishing (correctly) due to all PTEs on that page going away.
pte_find_next() would start at that iterator, and move along 'higher' order
directory pages until it finds a valid one, without zeroing out the lower
order pages.  For instance:

/* Find next pte at or above 0x10002000. */
pte = pte_find_next(pmap, &(0x10002000));
pte_remove(pmap, pte);
/* This pte was the last reference in the page table page, page is
 * gone.
 */
pte = pte_find_next(pmap, 0x10002000);
/* pte_find_next will see 0x10002000's page is gone, and jump to the
 * next one, but starting iteration at the '0x2000' slot, skipping
 * 0x0000 and 0x1000.
 */

This caused some processes, like git, to trip the KASSERT() in
pmap_release().

Fix this by zeroing all lower order iterators at each level.

3 years agoRemove double-calls to tc_get_timecount() to warm timecounters.
Konstantin Belousov [Wed, 10 Jun 2020 22:30:32 +0000 (22:30 +0000)]
Remove double-calls to tc_get_timecount() to warm timecounters.

It seems that second call does not add any useful state change for all
implemented timecounters.

Discussed with: bde
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks

3 years agoAdd pthread_getname_np() and pthread_setname_np() aliases for
Konstantin Belousov [Wed, 10 Jun 2020 22:13:24 +0000 (22:13 +0000)]
Add pthread_getname_np() and pthread_setname_np() aliases for
pthread_get_name_np() and pthread_set_name_np().

This re-applies r361770 after compatibility fixes.

Reviewed by: antoine, jkim, markj
Tested by: antoine (exp-run)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25117

3 years agoamd64 pmap: reorder IPI send and local TLB flush in TLB invalidations.
Konstantin Belousov [Wed, 10 Jun 2020 22:07:57 +0000 (22:07 +0000)]
amd64 pmap: reorder IPI send and local TLB flush in TLB invalidations.

Right now code first flushes all local TLB entries that needs to be
flushed, then signals IPI to remote cores, and then waits for
acknowledgements while spinning idle.  In the VMWare article 'Don’t
shoot down TLB shootdowns!' it was noted that the time spent spinning
is lost, and can be more usefully used doing local TLB invalidation.

We could use the same invalidation handler for local TLB as for
remote, but typically for pmap == curpmap we can use INVLPG for locals
instead of INVPCID on remotes, since we cannot control context
switches on them.  Due to that, keep the local code and provide the
callbacks to be called from smp_targeted_tlb_shootdown() after IPIs
are fired but before spin wait starts.

Reviewed by: alc, cem, markj, Anton Rang <rang at acm.org>
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D25188

3 years agoAdd mode selection to iMX6 IPU driver
Oleksandr Tymoshenko [Wed, 10 Jun 2020 22:00:31 +0000 (22:00 +0000)]
Add mode selection to iMX6 IPU driver

- Configure ipu1_di0 tob e sourced from the VIDEO_PLL(PLL5) and hardcode
  frequency to (455000000/3)Mhz. This value, further divided, can yield
  frequencies close enough to support 1080p, 720p, 1024x768, and 640x480
  modes. This is not ideal but it's an improvement comparing to the only
  hardcoded 1024x768 mode.

- Fix memory leaks if attach method failed
- Print EDID when -v passed to the kernel

3 years agoFix reading EDID on TVs/monitors without E-DCC support
Oleksandr Tymoshenko [Wed, 10 Jun 2020 21:38:35 +0000 (21:38 +0000)]
Fix reading EDID on TVs/monitors without E-DCC support

Writing segment id to I2C device 0x30 only required if the segment is
non-zero. On the devices without E-DCC support writing to that address
fails and whole transaction then fails too. To avoid this do
not attempt write to the segment selection device unless required.

MFC after: 2 weeks

3 years agoAdjust crypto_apply function callbacks for OCF.
John Baldwin [Wed, 10 Jun 2020 21:18:19 +0000 (21:18 +0000)]
Adjust crypto_apply function callbacks for OCF.

- crypto_apply() is only used for reading a buffer to compute a
  digest, so change the data pointer to a const pointer.

- To better match m_apply(), change the data pointer type to void *
  and the length from uint16_t to u_int.  The length field in
  particular matters as none of the apply logic was splitting requests
  larger than UINT16_MAX.

- Adjust the auth_xform Update callback to match the function
  prototype passed to crypto_apply() and crypto_apply_buf().  This
  removes the needs for casts when using the Update callback.

- Change the Reinit and Setkey callbacks to also use a u_int length
  instead of uint16_t.

- Update auth transforms for the changes.  While here, use C99
  initializers for auth_hash structures and avoid casts on callbacks.

Reviewed by: cem
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D25171

3 years agopci: loosen PCIe hot-plug requirements
Chuck Tuffli [Wed, 10 Jun 2020 20:12:45 +0000 (20:12 +0000)]
pci: loosen PCIe hot-plug requirements

The original PCIe hot-plug code required a couple of things which cause
PCI probing errors on the QEMU Q35 system and possibly physical systems
(Dell R6515).

Allocate the hot-plug interrupt as shared to support INTx interrupts.
The hot-plug interrupt mechanism should normally be MSI as PCIe mandates
MSI support, but QEMU's Q35 bridge only provides INTx interrupts.

Second, the code required the Electromechanical Interlock (Slot Status
EIS) to be engaged if present (Slot Capability EIP). Some platforms
including QEMU Q35 set EIP but not EIS. Fix by deleting the check.

Reviewed by: imp, mav, jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D24877

3 years agoRead commands from stdin when -f - is passed to sed(1)
Mateusz Piotrowski [Wed, 10 Jun 2020 19:23:58 +0000 (19:23 +0000)]
Read commands from stdin when -f - is passed to sed(1)

This patch teaches sed to interpret a "-" in a special way when given
as an argument to the -f flag.

This behavior is also present in GNU sed.

PR: 244872
Tested by: antoine (exp-run)
Reviewed by: pfg, tobik (older version)
Approved by: pfg (src)
Relnotes: yes
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D24079

3 years ago[net80211] ok ok if_xname won't ever be NULL.
Adrian Chadd [Wed, 10 Jun 2020 18:59:46 +0000 (18:59 +0000)]
[net80211] ok ok if_xname won't ever be NULL.

Somewhere in net80211 if_xname is checked against NULL but it doesn't trigger
a compiler warning, but this does.  So DTRT for FreeBSD and the other if_xname
derefences can be converted to this function at a later time.

3 years agoMake linux(4) set the openfiles soft resource limit to 1024 for Linux
Edward Tomasz Napierala [Wed, 10 Jun 2020 18:50:46 +0000 (18:50 +0000)]
Make linux(4) set the openfiles soft resource limit to 1024 for Linux
applications, which often depend on this being the case.  There's a new
sysctl, compat.linux.default_openfiles, to control this behaviour.

Reviewed by: kevans, emaste, bcr (manpages)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25177

3 years agoSupport SO_SNDBUFFORCE/SO_RCVBUFFORCE by aliasing them to the
Edward Tomasz Napierala [Wed, 10 Jun 2020 18:43:43 +0000 (18:43 +0000)]
Support SO_SNDBUFFORCE/SO_RCVBUFFORCE by aliasing them to the
standard SO_SNDBUF/SO_RCVBUF.  Mostly cosmetics, to get rid
of the warning during 'apt upgrade'.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25173

3 years agoFix arm64 kernel build with DEBUG on
Ed Maste [Wed, 10 Jun 2020 16:00:43 +0000 (16:00 +0000)]
Fix arm64 kernel build with DEBUG on

Submitted by: Greg V <greg@unrelenting.technology>, andrew
Differential Revision: https://reviews.freebsd.org/D24986

3 years agoAll the ARM Coresight interconnect devices set ResourceProducer on memory
Ruslan Bukin [Wed, 10 Jun 2020 14:39:54 +0000 (14:39 +0000)]
All the ARM Coresight interconnect devices set ResourceProducer on memory
resources, ignore it.

The devices found in the ARM Neoverse N1 System Development Platform
(N1SDP).

Sponsored by: DARPA, AFRL

3 years agoARM Coresight Funnel device:
Ruslan Bukin [Wed, 10 Jun 2020 14:28:36 +0000 (14:28 +0000)]
ARM Coresight Funnel device:
o Split-out FDT attachment to a separate file;
o Add ACPI attachment;
o Add support for the Static Funnel device.

Sponsored by: DARPA, AFRL

3 years agorelease: Fix arm GPT image
Emmanuel Vadot [Wed, 10 Jun 2020 14:10:48 +0000 (14:10 +0000)]
release: Fix arm GPT image

msdosfs labels are capitalized, use EFI instead of efi.

MFC after: 3 days

3 years agoFix the efi serial console in the Arm models.
Andrew Turner [Wed, 10 Jun 2020 09:31:37 +0000 (09:31 +0000)]
Fix the efi serial console in the Arm models.

On some UEFI implementations the ConsOut EFI variable is not a device
path end type so we never move to the next node. Fix this by always
incrementing the device path node pointer, with a sanity check that
the node length is large enough so no two nodes overlap.

While here return failure on malloc failure rather than a NULL pointer
dereference.

Reviewed by: tsoome, imp (previous version)
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D25202

3 years agoSwitch rtsock code to using newly-create rib_action() KPI call.
Alexander V. Chernikov [Wed, 10 Jun 2020 07:46:22 +0000 (07:46 +0000)]
Switch rtsock code to using newly-create rib_action() KPI call.

This simplifies the code and allows to further split rtentry and nexthop,
 removing one of the blockers for multipath code introduction, described in
 D24141.

Reviewed by: ae
Differential Revision: https://reviews.freebsd.org/D25192

3 years agoPrevent TCP Cubic to abruptly increase cwnd after app-limited
Richard Scheffenegger [Wed, 10 Jun 2020 07:32:02 +0000 (07:32 +0000)]
Prevent TCP Cubic to abruptly increase cwnd after app-limited

Cubic calculates the new cwnd based on absolute time
elapsed since the start of an epoch. A cubic epoch is
started on congestion events, or once the congestion
avoidance phase is started, after slow-start has
completed.

When a sender is application limited for an extended
amount of time and subsequently a larger volume of data
becomes ready for sending, Cubic recalculates cwnd
with a lingering cubic epoch. This recalculation
of the cwnd can induce a massive increase in cwnd,
causing a burst of data to be sent at line rate by
the sender.

This adds a flag to reset the cubic epoch once a
session transitions from app-limited to cwnd-limited
to prevent the above effect.

Reviewed by: chengc_netapp.com, tuexen (mentor)
Approved by: tuexen (mentor), rgrimes (mentor)
MFC after: 3 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D25065

3 years agoAdd le_read_channel_map and le_read_remote_features command
Takanori Watanabe [Wed, 10 Jun 2020 05:01:00 +0000 (05:01 +0000)]
Add le_read_channel_map and le_read_remote_features command

PR: 247051
Submitted by:   Marc Veldman marc at bumblingdork.com

3 years agoAdd LE events:
Takanori Watanabe [Wed, 10 Jun 2020 04:54:02 +0000 (04:54 +0000)]
Add LE events:
READ_REMOTE_FEATURES_COMPL
LONG_TERM_KEY_REQUEST
REMOTE_CONN_PARAM_REQUEST
DATA_LENGTH_CHANGE
READ_LOCAL_P256_PK_COMPL
GEN_DHKEY_COMPL
ENH_CONN_COMPL

PR: 247050
Submitted by: Marc Veldman marc at bumblingdork.com

3 years agopowerpc/powernv: Don't use the vmem quantum cache for OPAL PCI MSI allocations
Justin Hibbits [Wed, 10 Jun 2020 04:08:16 +0000 (04:08 +0000)]
powerpc/powernv: Don't use the vmem quantum cache for OPAL PCI MSI allocations

vmem quantum cache is only needed when doing a lot of concurrent allocations,
which doesn't happen when allocating MSIs.  This wastes memory for the cache
zones.  Avoid this waste and don't use the quantum cache.

Reported by: markj

3 years agopowerpc/mpc85xx: Don't use the quantum cache in vmem for MPIC MSIs
Justin Hibbits [Wed, 10 Jun 2020 04:04:59 +0000 (04:04 +0000)]
powerpc/mpc85xx: Don't use the quantum cache in vmem for MPIC MSIs

The qcache is unnecessary for this purpose, it's only needed when there are
lots of concurrent allocations.

Reported by: markj

3 years agoFixup r361997 by balancing parens. Duh.
Doug Moore [Wed, 10 Jun 2020 03:36:17 +0000 (03:36 +0000)]
Fixup r361997 by balancing parens.  Duh.

3 years agoAdd missing shell script from r361995
Kyle Evans [Wed, 10 Jun 2020 03:04:36 +0000 (03:04 +0000)]
Add missing shell script from r361995

Pointy hat: kevans
Reported by: rpokala
X-MFC-With: r361995

3 years agoAdd two functions that create M_EXTPG mbufs with anonymous pages.
Rick Macklem [Wed, 10 Jun 2020 02:51:39 +0000 (02:51 +0000)]
Add two functions that create M_EXTPG mbufs with anonymous pages.

These two functions are needed by nfs-over-tls, but could also be
useful for other purposes.
mb_alloc_ext_plus_pages() - Allocates a M_EXTPG mbuf and enough anonymous
      pages to store "len" data bytes.
mb_mapped_to_unmapped() - Copies the data from a list of mapped (non-M_EXTPG)
      mbufs into a list of M_EXTPG mbufs allocated with anonymous pages.
      This is roughly the inverse of mb_unmapped_to_ext().

Reviewed by: gallatin
Differential Revision: https://reviews.freebsd.org/D25182

3 years agoRestore an RB_COLOR macro, for the benefit of a bit of DIAGNOSTIC code
Doug Moore [Wed, 10 Jun 2020 02:50:25 +0000 (02:50 +0000)]
Restore an RB_COLOR macro, for the benefit of a bit of DIAGNOSTIC code
that depends on it.

Reported by: rpokala, mjguzik
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D25204

3 years agoexecvPe: obviate the need for potentially large stack allocations
Kyle Evans [Wed, 10 Jun 2020 01:32:13 +0000 (01:32 +0000)]
execvPe: obviate the need for potentially large stack allocations

Some environments in which execvPe may be called have a limited amount of
stack available. Currently, it avoidably allocates a segment on the stack
large enough to hold PATH so that it may be mutated and use strsep() for
easy parsing. This logic is now rewritten to just operate on the immutable
string passed in and do the necessary math to extract individual paths,
since it will be copying out those segments to another buffer anyways and
piecing them together with the name for a full path.

Additional size is also needed for the stack in posix_spawnp(), because it
may need to push all of argv to the stack and rebuild the command with sh in
front of it. We'll make sure it's properly aligned for the new thread, but
future work should likely make rfork_thread a little easier to use by
ensuring proper alignment.

Some trivial cleanup has been done with a couple of error writes, moving
strings into char arrays for use with the less fragile sizeof().

Reported by: Andrew Gierth <andrew_tao173.riddles.org.uk>
Reviewed by: jilles, kib, Andrew Gierth
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25038

3 years agoexecvp: fix up the ENOEXEC fallback
Kyle Evans [Wed, 10 Jun 2020 01:30:37 +0000 (01:30 +0000)]
execvp: fix up the ENOEXEC fallback

If execve fails with ENOEXEC, execvp is expected to rebuild the command
with /bin/sh instead and try again.

The previous version did this, but overlooked two details:

argv[0] can conceivably be NULL, in which case memp would never get
terminated.  We must allocate no less than three * sizeof(char *) so we can
properly terminate at all times. For the non-NULL argv standard case, we
count all the non-NULL elements and actually skip the first argument, so we
end up capturing the NULL terminator in our bcopy().

The second detail is that the spec is actually worded such that we should
have been preserving argv[0] as passed to execvp:

"[...] executed command shall be as if the process invoked the sh utility
using execl() as follows:

execl(<shell path>, arg0, file, arg1, ..., (char *)0);

where <shell path> is an unspecified pathname for the sh utility, file is
the process image file, and for execvp(), where arg0, arg1, and so on
correspond to the values passed to execvp() in argv[0], argv[1], and so on."

So we make this change at this time as well, while we're already touching
it. We decidedly can't preserve a NULL argv[0] as this would be incredibly,
incredibly fragile, so we retain our legacy behavior of using "sh" for
argv[] in this specific instance.

Some light tests are added to try and detect some components of handling the
ENOEXEC fallback; posix_spawnp_enoexec_fallback_null_argv0 is likely not
100% reliable, but it at least won't raise false-alarms and it did result in
useful failures with pre-change libc on my machine.

This is a secondary change in D25038.

Reported by: Andrew Gierth <andrew_tao173.riddles.org.uk>
Reviewed by: jilles, kib, Andrew Gierth
MFC after: 1 week

3 years agoAdd some default cases for unreachable code to silence compiler warnings.
John Baldwin [Wed, 10 Jun 2020 00:09:31 +0000 (00:09 +0000)]
Add some default cases for unreachable code to silence compiler warnings.

This was caused by r361481 when the buffer type was changed from an
int to an enum.

Reported by: mjg, rpokala
Sponsored by: Chelsio Communications