]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoRename skein_block_asm.s to .S and assemble using Clang IAS
Ed Maste [Sat, 6 Jun 2020 00:35:41 +0000 (00:35 +0000)]
Rename skein_block_asm.s to .S and assemble using Clang IAS

Comparing the object files produced by GNU as 2.17.50 and Clang IAS
shows many immaterial changes in strtab etc., and one material change
in .text:

   1bac:  4c 8b 4f 18             mov    0x18(%rdi),%r9
   1bb0:  eb 0e                   jmp    1bc0 <Skein1024_block_loop>
-  1bb2:  66 66 2e 0f 1f 84 00    data16 nopw %cs:0x0(%rax,%rax,1)
-  1bb9:  00 00 00 00
-  1bbd:  0f 1f 00                nopl   (%rax)
+  1bb2:  66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
+  1bb9:  00 00 00
+  1bbc:  0f 1f 40 00             nopl   0x0(%rax)

 0000000000001bc0 <Skein1024_block_loop>:
 Skein1024_block_loop():
   1bc0:  4c 8b 47 10             mov    0x10(%rdi),%r8
   1bc4:  4c 03 85 c0 00 00 00    add    0xc0(%rbp),%r8

That is, GNU as and Clang's integrated assembler use different multi-
byte NOPs for alignment (GNU as emits an 11 byte NOP + a 3 byte NOP,
while Clang IAS emits a 10 byte NOP + a 4 byte NOP).

Dependency cleanup hacks are not required, because we do not create
.depend files from GNU as.

Reviewed by: allanjude, arichardson, cem, tsoome
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D8434

4 years agoFix hang due to missing unbusy in sendfile when an async data I/O fails.
Chuck Silvers [Sat, 6 Jun 2020 00:02:50 +0000 (00:02 +0000)]
Fix hang due to missing unbusy in sendfile when an async data I/O fails.

r359473 removed the page unbusy logic from sendfile_iodone() because when
vm_pager_get_pages_async() would return an error after failing to start
the async I/O (eg. because VOP_BMAP failed), sendfile_swapin() would also
unbusy the pages, and it was wrong to unbusy twice.  However this breaks
the case where vm_pager_get_pages_async() succeeds in starting an async I/O
and the async I/O is what fails.  In this case, sendfile_iodone() must
unbusy the pages, and because sendfile_iodone() doesn't know which case
it is in, sendfile_iodone() must always unbusy pages and relookup pages
which have been substituted with bogus_page, which in turn means that
sendfile_swapin() must never do unbusy or relookup for pages which have
been given to vm_pager_get_pages_async(), even if there is an error.

Reviewed by: kib, markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25136

4 years agoMakefile.inc1: remove stale dependency cleanup from 2018
Ed Maste [Fri, 5 Jun 2020 20:18:55 +0000 (20:18 +0000)]
Makefile.inc1: remove stale dependency cleanup from 2018

4 years agodts: patch the am33xx dts for upcoming clock support
Emmanuel Vadot [Fri, 5 Jun 2020 20:14:54 +0000 (20:14 +0000)]
dts: patch the am33xx dts for upcoming clock support

Some ranges are too small compared to what they really are.
Add functional clocks for the timers.

Submitted by:  Oskar Holmlund (oskar.holmlund@ohdata.se)
X-Differential Revision: https://reviews.freebsd.org/D25118

4 years agodts: Update our copy to be in sync with Linux 5.7
Emmanuel Vadot [Fri, 5 Jun 2020 20:09:13 +0000 (20:09 +0000)]
dts: Update our copy to be in sync with Linux 5.7

MFC after: 2 months

4 years agoImport DTS files from Linux 5.7
Emmanuel Vadot [Fri, 5 Jun 2020 19:28:32 +0000 (19:28 +0000)]
Import DTS files from Linux 5.7

4 years agoAlso pass SKEIN_USE_ASM to the assembler, via AFLAGS
Ed Maste [Fri, 5 Jun 2020 18:56:43 +0000 (18:56 +0000)]
Also pass SKEIN_USE_ASM to the assembler, via AFLAGS

4 years agolibrtld_db: Handle anonymous mappings below the first file mapping.
Mark Johnston [Fri, 5 Jun 2020 18:44:14 +0000 (18:44 +0000)]
librtld_db: Handle anonymous mappings below the first file mapping.

r360979 erroneously assumed that the lowest mapping in an address space
would be a file mapping, but of course this is not true in general.

Reported and tested by: Frederic Chardon <chardon.frederic@gmail.com>
MFC after: 3 days

4 years agoskein_block_asm.S: use #ifdef not .ifdef, for Clang IAS
Ed Maste [Fri, 5 Jun 2020 18:37:04 +0000 (18:37 +0000)]
skein_block_asm.S: use #ifdef not .ifdef, for Clang IAS

Clang IAS does not support the --defsym argument, and

.ifndef SKEIN_USE_ASM

gets turned into

.ifndef 1792

by the preprocessor, which results in

error: expected identifier after '.ifdef'
.ifndef 1792
        ^

Use #ifdef instead, which still works with GNU as.

Reviewed by: cem
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25154

4 years agozfsbootcfg: use vfs.root.mountfrom and update nextboot on every vdev
Toomas Soome [Fri, 5 Jun 2020 18:18:27 +0000 (18:18 +0000)]
zfsbootcfg: use vfs.root.mountfrom and update nextboot on every vdev

vfs.zfs.boot.primary_pool is only set on BIOS boot, use vfs.root.mountfrom
instead and update all vdevs on pool.

Reviewed by: allanjude
Sponsored by: Netflix, Klara Inc.
Differential Revision: https://reviews.freebsd.org/D25103

4 years agoApply C SKEIN_LOOP setting only to skein_block.c
Ed Maste [Fri, 5 Jun 2020 17:00:38 +0000 (17:00 +0000)]
Apply C SKEIN_LOOP setting only to skein_block.c

Otherwise if assembling skein_block_asm.s with Clang's integrated assembler
we can pass conflicting SKEIN_LOOP settings (via CFLAGS and ACFLAGS).

4 years agoBelatedly bump .Dd for r361783
Benjamin Kaduk [Fri, 5 Jun 2020 16:59:14 +0000 (16:59 +0000)]
Belatedly bump .Dd for r361783

Reported by: lwhsu
Pointy hat to: bjk

4 years agogeom_label: Use provider aliasing to alias upstream geoms
Conrad Meyer [Fri, 5 Jun 2020 16:12:21 +0000 (16:12 +0000)]
geom_label: Use provider aliasing to alias upstream geoms

For synthetic aliases (just pseudonyms inferred from metadata like GPT or
UFS labels, GPT UUIDs, etc), use the GEOM provider aliasing system to create
a symlink to the real device instead of creating an independent device.
This makes it more clear which labels and devices correspond, and we can
safely have multiple labels to a single device accessed at once.

The confusingly named geom_label on-disk construct continues to behave
identically to how it did before.

This requires teaching GEOM's provider aliasing about the possibility
that aliases might be added later in time, and GEOM's devfs interaction
layer not to worry about existing aliases during retaste.

Discussed with: imp
Relnotes: sure, if we don't end up reverting it
Differential Revision: https://reviews.freebsd.org/D24968

4 years agogeom: Don't re-add duplicate aliases
Conrad Meyer [Fri, 5 Jun 2020 16:05:09 +0000 (16:05 +0000)]
geom: Don't re-add duplicate aliases

Reviewed by: imp (informal +1; extracted from phab 24968)

4 years agoAdd bunch of HDA controller and codec IDs.
Alexander Motin [Fri, 5 Jun 2020 15:06:58 +0000 (15:06 +0000)]
Add bunch of HDA controller and codec IDs.

MFC after: 2 weeks

4 years ago[net80211] Don't call ic_updateslot if it's not set.
Adrian Chadd [Fri, 5 Jun 2020 14:17:19 +0000 (14:17 +0000)]
[net80211] Don't call ic_updateslot if it's not set.

Turns out this isn't a required call. I didn't pick it up because my
uncommitted changes involve new updateslot methods for cards I'm working
on.

Dunce hat to: adrian

4 years agoAllow assembling skein_block_asm.s with clang
Alex Richardson [Fri, 5 Jun 2020 13:54:13 +0000 (13:54 +0000)]
Allow assembling skein_block_asm.s with clang

GNU as seems to allow macro arguments without the '\' but clang is more
strict in that regard.
This change makes the source code compatible with LLVM's but does not yet
change the build system or rename it to .S.

The new code assembles identically with GNU as 2.17.50.

Reviewed By: emaste
Differential Revision: https://reviews.freebsd.org/D25143

4 years agocsu: Avoid additional nops in the MIPS INIT_CALL_SEQ macro
Alex Richardson [Fri, 5 Jun 2020 08:46:55 +0000 (08:46 +0000)]
csu: Avoid additional nops in the MIPS INIT_CALL_SEQ macro

Since we had a .set reorder, the nop after the "jal" was being placed after
the delay slot, resulting in two nops.
While changing this code also guard the .set noreorder with .set push/pop
and use $zero as the cpsetup save register since we don't need to save $gp.

Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D25025

4 years agoAvoid using non-portable dd status=none flag
Alex Richardson [Fri, 5 Jun 2020 08:46:50 +0000 (08:46 +0000)]
Avoid using non-portable dd status=none flag

Copying the approach chosen in r309412. This fixes building the libc tests
on a macOS host since the macOS /bin/dd binary does not support status=none.

As there only seem to be two uses, this commit changes the two Makefiles.
If this becomes more common, we could also add a wrapper bootstrap script
that ignores status= and forwards the remaining args to the real dd.
Another alternative would be to remove the status flag and pipe stderr to
/dev/null, but them we lose error messages.

Reviewed By: brooks
Differential Revision: https://reviews.freebsd.org/D24785

4 years agoEnsure pci_channel_offline() actually queries the PCI register space,
Hans Petter Selasky [Fri, 5 Jun 2020 08:12:08 +0000 (08:12 +0000)]
Ensure pci_channel_offline() actually queries the PCI register space,
and not only the software cache of that register.  Else
pci_channel_offline() won't detect that the PCI device is gone when
using the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoUSB HID descriptors may push/pop the current state to allow
Hans Petter Selasky [Fri, 5 Jun 2020 07:57:16 +0000 (07:57 +0000)]
USB HID descriptors may push/pop the current state to allow
description of items residing in a so-called union. FreeBSD currently
only supports 4 such pop levels.

If the push level is not restored within the processing of the same
HID item, an invalid memory location may be used for subsequent HID
item processing.

Verify that the push level is always valid when processing HID items.

Reported by: Andy Nguyen (Google)
MFC after: 3 days
Sponsored by: Mellanox Technologies

4 years ago[net80211] print out node A-MSDU state.
Adrian Chadd [Fri, 5 Jun 2020 07:38:46 +0000 (07:38 +0000)]
[net80211] print out node A-MSDU state.

Now that the node AMSDU TX/RX flags are correctly set in ieee80211_ht.c,
we can print out the AMSDU state here.

4 years ago[net80211] Add initial A-MSDU in A-MPDU negotation support.
Adrian Chadd [Fri, 5 Jun 2020 07:38:10 +0000 (07:38 +0000)]
[net80211] Add initial A-MSDU in A-MPDU negotation support.

This is hopefully a big no-op unless you're running some extra
patches to flip on A-MSDU options in a driver.

802.11n supports sending A-MSDU in A-MPDU. That lets you do things
like pack small frames into an A-MSDU and stuff /those/ into an A-MPDU.
It allows for much more efficient airtime because you're not
wasting time sending small frames - which is still a problem when
doing A-MPDU as there's still per-frame overhead and minimum A-MPDU
density requirements.

It, however, is optional for 802.11n.  A lot of stuff doesn't advertise
it (but does it, just wait!); and I know that ath10k does it and my
ath(4) driver work supports it.

Now, 802.11ac makes A-MSDU in A-MPDU something that can happen more
frequently, because even though you can send very large A-MPDUs
(like 1 megabyte and larger) you still have the small frame problem.
So, 802.11ac NICs like ath10k and iwm will support A-MSDU in A-MPDU
out of the box if it's enabled - and you can negotiate it.

So, let's lay down the ground work to enable A-MSDU in A-MPDU.
This will allow hardware like iwn(4) and ath(4) which supports
software A-MSDU but hardware A-MPDU to be more efficient.

Drivers that support A-MSDU in A-MPDU will set TX/RX htcap flags.
Note this is separate from the software A-MSDU encap path; /that/
dictates whether net80211 is doing A-MSDU encapsulation or not.
These HTC flags control negotiation, NOT encapsulation.

Once this negotiation and driver bits are done, hardware like
rtwn(4), run(4), and others will be able to use A-MSDU even without
A-MPDU working;  right now FF and A-MSDU aren't even attempted
if you're an 11n node.  It's a small hold-over from the initial
A-MPDU work and I know how to fix it, but to flip it on properly
I need to be able to negotiate or ignore A-MSDU in A-MPDU.

Oh and the fun part - some 11ac APs I've tested will quite happily
decap A-MSDU in A-MPDU even though they don't negotiate it when
doing 802.11n.  So hey, I know it works - I just want to properly
handle things. :-)

Tested:

* AR9380, STA/AP mode

4 years ago[net80211] Migrate short slot time configuration into per-vap and deferred taskqueue...
Adrian Chadd [Fri, 5 Jun 2020 06:21:23 +0000 (06:21 +0000)]
[net80211] Migrate short slot time configuration into per-vap and deferred taskqueue updates.

The 11b/11g ERP and slot time update handling are two things which weren't
migrated into the per-VAP state when Sam did the initial VAP work.
That makes sense for a lot of setups where net80211 is driving radio state
and the radio only cares about the shared state.

However, as noted by a now deleted comment, the ERP and slot time updates
aren't EXACTLY correct/accurate - they only take into account the most
RECENTLY created VAP, and the state updates when one creates/destroys
VAPs isn't exactly great.

So:

* track the short slot logic per VAP;
* whenever the slot time configuration changes, just push it into a deferred
  task queue update so drivers don't have to serialise it themselves;
* if a driver registers a per-VAP slot time handler then it'll just get the
  per VAP one;
* .. if a driver registers a global one then the legacy behaviour is maintained -
  a single slot time is calculated and pushed out.

Note that the calculated slot time is better than the existing logic - if ANY
of the VAPs require long slot then it's disabled for all VAPs rather than
whatever the last configured VAP did.

Now, this isn't entirely complete - the rest of ERP tracking around short/long
slot capable station tracking needs to be converted into per-VAP, as well
as the preamble/barker flags.  Luckily those also can be done in a similar
fashion - keep per-VAP counters/flags and unify them before doing the driver
update.  I'll defer that work until later.

All the existing drivers can keep doing what they're doing with the global
slot time flags as that is maintained. One driver (iwi) used the per-VAP
flags instead of the ic flags, so now that driver will work properly.

This unblocks some ath10k porting work as the firmware takes the slot time
configuration per-VAP rather than globally, and some firmware handles
STA+AP and STA+STA (on same/different channels) configurations where
the firmware will switch slot time as appropriate.

Tested:

* AR9380, STA/AP mode
* AR9880 (ath10k), STA mode

4 years ago[net80211] Add some TODOs around A-MSDU in A-MPDU negotiation.
Adrian Chadd [Fri, 5 Jun 2020 06:07:23 +0000 (06:07 +0000)]
[net80211] Add some TODOs around A-MSDU in A-MPDU negotiation.

net80211 currently doesn't negotiate A-MSDU in A-MPDU during ADDBA.
I've added the field in net80211 and this commit:

* Prints out the ADDBA field value during ADDBA;
* Adds some comments around where I need to follow up with some
  negotiation logic.

Right now we don't have a driver flag anywhere which controls
whether A-MSDU in A-MPDU is allowed.  I know it works (I have it
manually turned on at home on a couple test APs, heh!) but
I can't flip it on until we can negotiate it.

Tested:

* AR9380, STA/AP mode, printing out ADDBA requests

4 years ago[iwn] Set default ampdu parameters.
Adrian Chadd [Fri, 5 Jun 2020 04:24:34 +0000 (04:24 +0000)]
[iwn] Set default ampdu parameters.

These are from the linux iwlwifi driver ;the default use smaller
maximum AMPDUs (8k) and a much smaller density (none.)  The latter
could cause stability issues.

Tested:

* Tested on Intel 6300, STA mode.

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

4 years ago[net80211] Add field definition for A-MSDU inside A-MPDU.
Adrian Chadd [Fri, 5 Jun 2020 04:04:47 +0000 (04:04 +0000)]
[net80211] Add field definition for A-MSDU inside A-MPDU.

Now that I have A-MSDU and A-MPDU coexisting together, we need to actually
announce if (a) it's permitted and (b) figure out if we should use it
when transmitting.

This just adds the field; it doesn't yet include it in ADDBA exchanges.

4 years agoLimit AHCI to only one MSI if more is not needed.
Alexander Motin [Fri, 5 Jun 2020 02:21:46 +0000 (02:21 +0000)]
Limit AHCI to only one MSI if more is not needed.

My AMD Ryzen system has 4 AHCI controllers, each supporting 16 MSI vectors.
Since two of the controllers have only one SATA port, limit to single MSI
saves system 30 interrupt vectors for free.

It may be possible to also limit number of MSI vectors to 4 and 8 for the
other two controllers, but according to the AHCI specification after that
controllers may revert to only one vector, that would be a bigger loss to
risk.

MFC after: 2 weeks

4 years agoFurther evaluation of the POSIX spec for fdatasync() shows that it
Kirk McKusick [Fri, 5 Jun 2020 01:00:55 +0000 (01:00 +0000)]
Further evaluation of the POSIX spec for fdatasync() shows that it
requires that new data on growing files be accessible. Thus, the
the fsyncdata() system call must update the on-disk inode when the
size of the file has changed.

This commit adds another inode update flag, IN_SIZEMOD, that gets
set any time that the file size changes. If either the IN_IBLKDATA
or the IN_SIZEMOD flag is set when fdatasync() is called, the
associated inode is synchronously written to disk. We could have
overloaded the IN_IBLKDATA flag to also track size changes since
the only (current) use case for these flags are for fsyncdata(),
but it does seem useful for possible future uses to separately
track the file size changes and the inode block pointer changes.

Reviewed by: kib
MFC with: -r361785
Differential revision:  https://reviews.freebsd.org/D25072

4 years ago[net80211] Add some more debugging during scanning
Adrian Chadd [Fri, 5 Jun 2020 00:16:54 +0000 (00:16 +0000)]
[net80211] Add some more debugging during scanning

I'm trying to chase down more weird "I am not doing an incremental scan
when being asked" issues so these debugging statements help.
Notably, I've added more debugging around reasons why the scan is skipped -
eg because the cache is considered hot.

This should be a no-op unless you care about the debugging output!

4 years ago[net80211] Print out a bad PN in both hex and decimal.
Adrian Chadd [Fri, 5 Jun 2020 00:14:02 +0000 (00:14 +0000)]
[net80211] Print out a bad PN in both hex and decimal.

I've been using this to visually identify when I'm getting corrupted PNs
from the hardware. :(

4 years ago[net80211] Send a probe request after IBSS node discovery
Adrian Chadd [Fri, 5 Jun 2020 00:11:44 +0000 (00:11 +0000)]
[net80211] Send a probe request after IBSS node discovery

This sends a probe request after IBSS node discovery through
beacon frames. This allows things like HT and VHT capabilities
to be "negotiated" in adhoc mode.

It is .. kinda fire and pray - this isn't retried after discovery
so it's quite possible that nodes occasionally don't come up with
HT/VHT rate upgrades. At some point it may be a fun side project
to add support for retrying these probe requests/negotiations
after IBSS node discovery.

Tested:

* tested with multiple ath(4) NICs in 11n mode.

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

4 years agoRefer to AES-CBC as "aes-cbc" rather than "rijndael-cbc" for IPsec.
John Baldwin [Thu, 4 Jun 2020 22:58:37 +0000 (22:58 +0000)]
Refer to AES-CBC as "aes-cbc" rather than "rijndael-cbc" for IPsec.

At this point, AES is the more common name for Rijndael128.  setkey(8)
will still accept the old name, and old constants remain for
compatiblity.

Reviewed by: cem, bcr (manpages)
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D24964

4 years agoUpdate crypto(7) to list current ciphers.
John Baldwin [Thu, 4 Jun 2020 22:16:19 +0000 (22:16 +0000)]
Update crypto(7) to list current ciphers.

Add descriptions of AES-CCM, Camellia-CBC, and Chacha20.

Reviewed by: cem (previous version)
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D24963

4 years agoDocument upgrade procedure in FREEBSD-upgrade
Mitchell Horne [Thu, 4 Jun 2020 20:48:57 +0000 (20:48 +0000)]
Document upgrade procedure in FREEBSD-upgrade

It was pointed out to me that this is the convention for documenting upgrade
instructions, rather than just leaving the instructions in the commit message.
It's possible these commands won't be used again before we transition to git,
but then at least they'll give a path forward for whoever touches this next.

Suggested by: lwhsu

4 years agoAdd O_DIRECT flag to DD for cache bypass
Richard Scheffenegger [Thu, 4 Jun 2020 20:47:11 +0000 (20:47 +0000)]
Add O_DIRECT flag to DD for cache bypass

FreeBSD DD utility has not had support for the O_DIRECT flag, which
is useful to bypass local caching, e.g. for unconditionally issuing
NFS IO requests during testing.

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

4 years agoem(4): Add support for Comet Lake Mobile Platform, update shared code
Eric Joyner [Thu, 4 Jun 2020 20:39:28 +0000 (20:39 +0000)]
em(4): Add support for Comet Lake Mobile Platform, update shared code

This change introduces Comet Lake Mobile Platform support in the e1000
driver along with shared code patches described below.

- Cast return value of e1000_ltr2ns() to higher type to avoid overflow
- Remove useless statement of assigning act_offset
- Add initialization of identification LED
- Fix flow control setup after connected standby:
  After connected standby the driver blocks resets during
  "AdapterStart" and skips flow control setup. This change adds
  condition in e1000_setup_link_ich8lan() to always setup flow control
  and to setup physical interface only when there is no need to block
  resets.

Signed-off-by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>
Submitted by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>
Reviewed by: erj@
Tested by: Jeffrey Pieper <jeffrey.e.pieper@intel.com>
MFC after: 1 week
Relnotes: yes
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D25035

4 years agoUse separate output buffers for OCF requests in KTLS.
John Baldwin [Thu, 4 Jun 2020 20:12:34 +0000 (20:12 +0000)]
Use separate output buffers for OCF requests in KTLS.

KTLS encryption requests for file-backed data such as from sendfile(2)
require the encrypted data to be stored in a separate buffer from the
unencrypted file input data.  Previously the OCF backend for KTLS
manually copied the data from the input buffer to the output buffer
before queueing the crypto request.  Now the OCF backend will use a
separate output buffer for such requests and avoid the copy.  This
mostly helps when an async co-processor is used by saving CPU cycles
used on the copy.

Reviewed by: gallatin (earlier version)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D24545

4 years agoFix obvious typo: IN_BLKDATA should be IN_IBLKDATA
Stefan Eßer [Thu, 4 Jun 2020 19:54:25 +0000 (19:54 +0000)]
Fix obvious typo: IN_BLKDATA should be IN_IBLKDATA

4 years agoUpdate edk2 headers to stable202005
Mitchell Horne [Thu, 4 Jun 2020 19:21:41 +0000 (19:21 +0000)]
Update edk2 headers to stable202005

We use these to compile libefivar. The particular motivation for this update is
the inclusion of the RISC-V machine definitions that allow us to build the
library on the platform. This support could easily have been submitted as a
small local diff, but the timing of the release coincided with this work, and
it has been over 3 years since these sources were initially imported.

Note that this comes with a license change from regular BSD 2-clause to the
BSD+Patent license. This has been approved by core@ for this particular
project [1].

As with the original import, we retain only the subset of headers that we
actually need to build libefivar. I adapted imp@'s process slightly for this
update:

    # Generate list of the headers needed to build
    cp -r ../vendor/edk2/dist/MdePkg/Include sys/contrib/edk2
    cd lib/libefivar
    make
    pushd `make -V .OBJDIR`
    cat .depend*.o | grep sys/contrib | cut -d' ' -f 3 |
        sort -u | sed -e 's=/full/path/sys/contrib/edk2/==' > /tmp/xxx
    popd

    # Merge the needed files
    cd ../../sys/contrib/edk2
    svn revert -R .
    for i in `cat /tmp/xxx`; do
        svn merge -c VendorRevision svn+ssh://repo.freebsd.org/base/vendor/edk2/dist/MdePkg/$i $i
    done
    svn merge -c VendorRevision svn+ssh://repo.freebsd.org/base/vendor/edk2/dist/MdePkg/MdePkg.dec MdePkg.dec

[1] https://www.freebsd.org/internal/software-license.html

4 years agoTwo additional places that need to identify IN_IBLKDATA.
Kirk McKusick [Thu, 4 Jun 2020 18:35:21 +0000 (18:35 +0000)]
Two additional places that need to identify IN_IBLKDATA.

Reviewed by: kib
MFC with: -r361785
Differential Revision:  https://reviews.freebsd.org/D25072

4 years agoRELNOTES and UPDATING: Document the new policy on read(2) of dirfd
Kyle Evans [Thu, 4 Jun 2020 18:19:16 +0000 (18:19 +0000)]
RELNOTES and UPDATING: Document the new policy on read(2) of dirfd

These changes have been completely flushed as of r361799; note it.

4 years agovfs: add restrictions to read(2) of a directory [2/2]
Kyle Evans [Thu, 4 Jun 2020 18:17:25 +0000 (18:17 +0000)]
vfs: add restrictions to read(2) of a directory [2/2]

This commit adds the priv(9) that waters down the sysctl to make it only
allow read(2) of a dirfd by the system root. Jailed root is not allowed, but
jail policy and superuser policy will abstain from allowing/denying it so
that a MAC module can fully control the policy.

Such a MAC module has been written, and can be found at:
https://people.freebsd.org/~kevans/mac_read_dir-0.1.0.tar.gz

It is expected that the MAC module won't be needed by many, as most only
need to do such diagnostics that require this behavior as system root
anyways. Interested parties are welcome to grab the MAC module above and
create a port or locally integrate it, and with enough support it could see
introduction to base. As noted in mac_read_dir.c, it is released under the
BSD 2 clause license and allows the restrictions to be lifted for only
jailed root or for all unprivileged users.

PR: 246412
Reviewed by: mckusick, kib, emaste, jilles, cy, phk, imp (all previous)
Reviewed by: rgrimes (latest version)
Differential Revision: https://reviews.freebsd.org/D24596

4 years agovfs: add restrictions to read(2) of a directory [1/2]
Kyle Evans [Thu, 4 Jun 2020 18:09:55 +0000 (18:09 +0000)]
vfs: add restrictions to read(2) of a directory [1/2]

Historically, we've allowed read() of a directory and some filesystems will
accommodate (e.g. ufs/ffs, msdosfs). From the history department staffed by
Warner: <<EOF

pdp-7 unix seemed to allow reading directories, but they were weird, special
things there so I'm unsure (my pdp-7 assembler sucks).

1st Edition's sources are lost, mostly. The kernel allows it. The
reconstructed sources from 2nd or 3rd edition read it though.

V6 to V7 changed the filesystem format, and should have been a warning, but
reading directories weren't materially changed.

4.1b BSD introduced readdir because of UFS. UFS broke all directory reading
programs in 1983. ls, du, find, etc all had to be rewritten. readdir() and
friends were introduced here.

SysVr3 picked up readdir() in 1987 for the AT&T fork of Unix. SysVr4 updated
all the directory reading programs in 1988 because different filesystem
types were introduced.

In the 90s, these interfaces became completely ubiquitous as PDP-11s running
V7 faded from view and all the folks that initially started on V7 upgraded
to SysV. Linux never supported this (though I've not done the software
archeology to check) because it has always had a pathological diversity of
filesystems.
EOF

Disallowing read(2) on a directory has the side-effect of masking
application bugs from relying on other implementation's behavior
(e.g. Linux) of rejecting these with EISDIR across the board, but allowing
it has been a vector for at least one stack disclosure bug in the past[0].

By POSIX, this is implementation-defined whether read() handles directories
or not. Popular implementations have chosen to reject them, and this seems
sensible: the data you're reading from a directory is not structured in some
unified way across filesystem implementations like with readdir(2), so it is
impossible for applications to portably rely on this.

With this patch, we will reject most read(2) of a dirfd with EISDIR. Users
that know what they're doing can conscientiously set
bsd.security.allow_read_dir=1 to allow read(2) of directories, as it has
proven useful for debugging or recovery. A future commit will further limit
the sysctl to allow only the system root to read(2) directories, to make it
at least relatively safe to leave on for longer periods of time.

While we're adding logic pertaining to directory vnodes to vn_io_fault, an
additional assertion has also been added to ensure that we're not reaching
vn_io_fault with any write request on a directory vnode. Such request would
be a logical error in the kernel, and must be debugged rather than allowing
it to potentially silently error out.

Commented out shell aliases have been placed in root's chsrc/shrc to promote
awareness that grep may become noisy after this change, depending on your
usage.

A tentative MFC plan has been put together to try and make it as trivial as
possible to identify issues and collect reports; note that this will be
strongly re-evaluated. Tentatively, I will MFC this knob with the default as
it is in HEAD to improve our odds of actually getting reports. The future
priv(9) to further restrict the sysctl WILL NOT BE MERGED BACK, so the knob
will be a faithful reversion on stable/12. We will go into the merge
acknowledging that the sysctl default may be flipped back to restore
historical behavior at *any* point if it's warranted.

[0] https://www.freebsd.org/security/advisories/FreeBSD-SA-19:10.ufs.asc

PR: 246412
Reviewed by: mckusick, kib, emaste, jilles, cy, phk, imp (all previous)
Reviewed by: rgrimes (latest version)
MFC after: 1 month (note the MFC plan mentioned above)
Relnotes: absolutely, but will amend previous RELNOTES entry
Differential Revision: https://reviews.freebsd.org/D24596

4 years agoRemove licenses
Oleksandr Tymoshenko [Thu, 4 Jun 2020 17:20:58 +0000 (17:20 +0000)]
Remove licenses

I haven't requested explicit permission from authors and shouldn't have
added BSDL headers without it.

Requestes by: imp

4 years agodhclient: Fix a logic bug remove_protocol().
Mark Johnston [Thu, 4 Jun 2020 16:24:13 +0000 (16:24 +0000)]
dhclient: Fix a logic bug remove_protocol().

A logic bug in remove_protocol() meant that it would remove (leak) all
structures in the list preceding the one intended for removal.

PR: 245971
Submitted by: joost@jodocus.org (original version)
MFC after: 1 week

4 years agoUpdate vt(4) config option names to chase r303043.
Mark Johnston [Thu, 4 Jun 2020 16:05:24 +0000 (16:05 +0000)]
Update vt(4) config option names to chase r303043.

PR: 246080
Submitted by: David Marec <david@lapinbilly.eu>
MFC after: 1 week

4 years agoRestrict default /root permissions
Conrad Meyer [Thu, 4 Jun 2020 16:04:19 +0000 (16:04 +0000)]
Restrict default /root permissions

Remove world-readability from the root directory.  Sensitive information may be
stored in /root and we diverge here from normative administrative practice, as
well as installation defaults of other Unix-alikes.  The wheel group is still
permitted to read the directory.

750 is no more restrictive than defaults for the rest of the open source
Unix-alike world.  In particular, Ben Woods surveyed DragonFly, NetBSD,
OpenBSD, ArchLinux, CentOS, Debian, Fedora, Slackware, and Ubuntu.  None have a
world-readable /root by default.

Submitted by: Gordon Bergling <gbergling AT gmail.com>
Reviewed by: ian, myself
Discussed with: emaste (informal approval)
Relnotes: sure?
Differential Revision: https://reviews.freebsd.org/D23392

4 years agoifconfig(8): make it possible to filter output by interface group.
Eugene Grosbein [Thu, 4 Jun 2020 14:44:44 +0000 (14:44 +0000)]
ifconfig(8): make it possible to filter output by interface group.

Now options -g/-G allow to select/unselect interfaces by groups
in the "ifconfig -a" output just like already existing -d/-u.

Examples:

to exclude loopback from the list: ifconfig -a -G lo
to show vlan interfaces only: ifconfig -a -g vlan
to show tap interfaces that are up: ifconfig -aug tap

Arguments to -g/-G may be shell patterns and both may be specified.
Later options -g/-G override previous ones.

MFC after: 2 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D25029

4 years agoipfw: unbreak matching with big table type flow.
Eugene Grosbein [Thu, 4 Jun 2020 14:15:39 +0000 (14:15 +0000)]
ipfw: unbreak matching with big table type flow.

Test case:

# n=32769
# ipfw -q table 1 create type flow:proto,dst-ip,dst-port
# jot -w 'table 1 add tcp,127.0.0.1,' $n 1 | ipfw -q /dev/stdin
# ipfw -q add 5 unreach filter-prohib flow 'table(1)'

The rule 5 matches nothing without the fix if n>=32769.

With the fix, it works:
# telnet localhost 10001
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Permission denied
telnet: Unable to connect to remote host

MFC after: 2 weeks
Discussed with: ae, melifaro

4 years agosuperio: do not assume that current LDN cannot change after config exit
Andriy Gapon [Thu, 4 Jun 2020 13:18:21 +0000 (13:18 +0000)]
superio: do not assume that current LDN cannot change after config exit

That assumption should be true when superio(4) uses the hardware
exlusively.  But it turns out to not hold on some real systems.
So, err on the side of correctness rather than performance.
Clear current_ldn in sio_conf_exit.

Reported by: bz
Tested by: bz
MFC after: 1 week

4 years agoifconfig.8: fix cpability and flag descriptions for list scan / sta
Andriy Gapon [Thu, 4 Jun 2020 13:06:49 +0000 (13:06 +0000)]
ifconfig.8: fix cpability and flag descriptions for list scan / sta

Some capability descriptions under list scan actually described flags.
Some capability descriptions were missing.
Some flag descriptions under list sta actually described capabilites.

Reviewed by: adrian
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25014

4 years agoUFS: write inode block for fdatasync(2) if pointers in inode where allocated
Konstantin Belousov [Thu, 4 Jun 2020 12:23:15 +0000 (12:23 +0000)]
UFS: write inode block for fdatasync(2) if pointers in inode where allocated

The fdatasync() description in POSIX specifies that
    all I/O operations shall be completed as defined for synchronized I/O
    data integrity completion.
and then the explanation of Synchronized I/O Data Integrity Completion says
    The write is complete only when the data specified in the write
    request is successfully transferred and all file system
    information required to retrieve the data is successfully
    transferred.

For UFS this means that all pointers must be on disk. Indirect
pointers already contribute to the list of dirty data blocks, so only
direct blocks and root pointers to indirect blocks, both of which
reside in the inode block, should be taken care of. In ffs_balloc(),
mark the inode with the new flag IN_IBLKDATA that specifies that
ffs_syncvnode(DATA_ONLY) needs a call to ffs_update() to flush the
inode block.

Reviewed by: mckusick
Discussed with: tmunro
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25072

4 years agoRevert r361770 "Add pthread_getname_np() and pthread_setname_np() aliases" for now.
Konstantin Belousov [Thu, 4 Jun 2020 09:06:03 +0000 (09:06 +0000)]
Revert r361770 "Add pthread_getname_np() and pthread_setname_np() aliases" for now.

It is not compatible enough with Linux.

Requested by: antoine, jkim
Sponsored by: The FreeBSD Foundation

4 years agoAdd EXAMPLES to killall(1)
Benjamin Kaduk [Thu, 4 Jun 2020 04:29:43 +0000 (04:29 +0000)]
Add EXAMPLES to killall(1)

Submitted by: fernape
Differential Revision: https://reviews.freebsd.org/D25002

4 years agoAdd copyright headers to spigen overlays for rpi3 and rpi4
Oleksandr Tymoshenko [Thu, 4 Jun 2020 02:36:41 +0000 (02:36 +0000)]
Add copyright headers to spigen overlays for rpi3 and rpi4

Reported by: Rodney W. Grimes <freebsd@gndrsh.dnsmgr.net> (for rpi4)

4 years agoCorrect terminology in vm.imply_prot_max sysctl description
Ed Maste [Thu, 4 Jun 2020 01:49:29 +0000 (01:49 +0000)]
Correct terminology in vm.imply_prot_max sysctl description

As with r361769 (man page), PROT_* are properly called protections, not
permissions.

MFC after: 1 week
MFC with: r361769
Sponsored by: The FreeBSD Foundation

4 years agoFix mountd to handle getgrouplist() not returning groups[0] == groups[1].
Rick Macklem [Thu, 4 Jun 2020 00:28:20 +0000 (00:28 +0000)]
Fix mountd to handle getgrouplist() not returning groups[0] == groups[1].

Prior to r174547, getgrouplist(3) always returned a groups list with
element 0 and 1 set to the basegid argument, so long as ngroups was > 1.
Post-r174547 this is not the case. r328304 disabled the deduplication that
removed the duplicate, but the duplicate still does not occur unless the
group for a user in the password database is also entered in the group
database.
This patch fixes mountd so that it handles the case where a user specified
with the -maproot or -mapall exports option has a getgrouplist(3) groups
list where groups[0] != groups[1].
Found while testing another mountd patch.

MFC after: 2 weeks

4 years agoAdd opt_compat.h needed by r359374.
John Baldwin [Wed, 3 Jun 2020 23:21:44 +0000 (23:21 +0000)]
Add opt_compat.h needed by r359374.

Reported by: kevans

4 years ago[run] Fix up tx/rx frame size.
Adrian Chadd [Wed, 3 Jun 2020 22:30:44 +0000 (22:30 +0000)]
[run] Fix up tx/rx frame size.

This specifically fixes that TX frames are large enough now to hold a 3900 odd
byte AMSDU (the little ones); me flipping it on earlier messed up transmit!

Tested:

* if_run, STA mode, TX/RX TCP/UDP iperf.  TCP is now back to normal and
  correctly does ~ 3200 byte AMSDU/fast frames (2x1600ish byte MSDUs).

4 years agoExplicitly zero IVs on the stack.
John Baldwin [Wed, 3 Jun 2020 22:19:52 +0000 (22:19 +0000)]
Explicitly zero IVs on the stack.

Reviewed by: delphij
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25057

4 years agoExplicitly zero AES key schedules on the stack.
John Baldwin [Wed, 3 Jun 2020 22:18:21 +0000 (22:18 +0000)]
Explicitly zero AES key schedules on the stack.

Reviewed by: delphij
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25057

4 years agoAdd spigen overlay for Raspberry Pi 4
Oleksandr Tymoshenko [Wed, 3 Jun 2020 22:18:15 +0000 (22:18 +0000)]
Add spigen overlay for Raspberry Pi 4

Submitted by: gergely.czuczy@harmless.hu

4 years agoExplicitly zero on-stack IVs, tags, and HMAC keys.
John Baldwin [Wed, 3 Jun 2020 22:15:11 +0000 (22:15 +0000)]
Explicitly zero on-stack IVs, tags, and HMAC keys.

Reviewed by: delphij
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25057

4 years agoAdd explicit bzero's of sensitive data in software crypto consumers.
John Baldwin [Wed, 3 Jun 2020 22:11:05 +0000 (22:11 +0000)]
Add explicit bzero's of sensitive data in software crypto consumers.

Explicitly zero IVs, block buffers, and hashes/digests.

Reviewed by: delphij
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25057

4 years agoAdd dtb for Firefly RK3399 to the list of Rockchip dtbs
Oleksandr Tymoshenko [Wed, 3 Jun 2020 21:19:57 +0000 (21:19 +0000)]
Add dtb for Firefly RK3399 to the list of Rockchip dtbs

4 years agoAdd pthread_getname_np() and pthread_setname_np() aliases
Konstantin Belousov [Wed, 3 Jun 2020 20:54:36 +0000 (20:54 +0000)]
Add pthread_getname_np() and pthread_setname_np() aliases

for pthread_get_name_np() and pthread_set_name_np(), to be
compatible with Linux.

PR: 238404
Proposed and reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25117

4 years agommap.2: correct prot argument terminology
Ed Maste [Wed, 3 Jun 2020 20:42:52 +0000 (20:42 +0000)]
mmap.2: correct prot argument terminology

One of the error descriptions referred to permissions; in context the
meaning was probably clear, but the prot values are properly called
protections.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years ago[otus] enable 802.11n for 2GHz and 5GHz.
Adrian Chadd [Wed, 3 Jun 2020 20:25:02 +0000 (20:25 +0000)]
[otus] enable 802.11n for 2GHz and 5GHz.

This flips on basic 11n for 2GHz/5GHz station operation.

* It flips on HT20 and MCS rates;
* It enables A-MPDU decap - the payload format is a bit different;
* It does do some basic checks for HT40 but I haven't yet flipped on
  HT40 support;
* It enables software A-MSDU transmit; I honestly don't want to make
  A-MPDU TX work and there are apparently issues with QoS and A-MPDU TX.
  So I totally am ignoring A-MPDU TX;
* MCS rate transmit is fine.

I haven't:

* A-MPDU TX, as I said above;
* made radiotap work fully;
* HT40;
* short-GI support;
* lots of other stuff that honestly no-one is likely to use.

But! Hey, this is another ye olde 11n USB NIC that now works pretty OK
in 11n rates. A-MPDU receive seems fine enough given it's a draft-n
device from before 2010.

Tested:

* Ye olde UB82 Test NIC (AR9170 + AR9104) - 2GHz/5GHz

4 years agoDocument SO_NO_OFFLOADS and SO_NO_DDP.
John Baldwin [Wed, 3 Jun 2020 18:59:31 +0000 (18:59 +0000)]
Document SO_NO_OFFLOADS and SO_NO_DDP.

Reviewed by: bcr, np
MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D25043

4 years agoImport edk2-stable202005
Mitchell Horne [Wed, 3 Jun 2020 18:44:51 +0000 (18:44 +0000)]
Import edk2-stable202005

As with the previous import, only the MdePkg subdirectory has been
brought in. The line-endings were also converted using:

% find . -type f | xargs -n 1 sed -I.BAK -e `printf "s/\r//g"`
% find . -name \*.BAK | xargs rm

4 years agoRevise r361712 to disable tcpmd5.ko for 'options TCP_SIGNATURE'
John Baldwin [Wed, 3 Jun 2020 18:42:28 +0000 (18:42 +0000)]
Revise r361712 to disable tcpmd5.ko for 'options TCP_SIGNATURE'

4 years agolualoader: drop the filename and word "LUA" from errors
Kyle Evans [Wed, 3 Jun 2020 18:29:32 +0000 (18:29 +0000)]
lualoader: drop the filename and word "LUA" from errors

The filename is nearly always wrong since it's /boot/lua/loader.lua, which
is not useful for diagnostics. The actual errmsg will include a lua filename
if this is relevant.

Dropping "LUA" while we're here because that's almost universally
irrelevant to whatever error follows, unless the error states that it's
actually a lua problem.

Both of these are minor nits that just detract from identifying the
pertinent information.

MFC after: 3 days

4 years agonetmap: vtnet: clean up rxsync disabled logs
Vincenzo Maffione [Wed, 3 Jun 2020 17:47:32 +0000 (17:47 +0000)]
netmap: vtnet: clean up rxsync disabled logs

MFC after: 1 week

4 years agonetmap: vtnet: fix race condition in rxsync
Vincenzo Maffione [Wed, 3 Jun 2020 17:46:21 +0000 (17:46 +0000)]
netmap: vtnet: fix race condition in rxsync

This change prevents a race that happens when rxsync dequeues
N-1 rx packets (with N being the size of the netmap rx ring).
In this situation, the loop exits without re-enabling the
rx interrupts, thus causing the VQ to stall.

MFC after: 1 week

4 years agonetmap: vtnet: add vtnrx_nm_refill index to receive queues
Vincenzo Maffione [Wed, 3 Jun 2020 17:42:17 +0000 (17:42 +0000)]
netmap: vtnet: add vtnrx_nm_refill index to receive queues

The new index tracks the next netmap slot that is going
to be enqueued into the virtqueue. The index is necessary
to prevent the receive VQ and the netmap rx ring from going
out of sync, considering that we never enqueue N slots, but
at most N-1. This change fixes a bug that causes the VQ
and the netmap ring to go out of sync after N-1 packets
have been received.

MFC after: 1 week

4 years agoFix typo in previous commit
Ryan Moeller [Wed, 3 Jun 2020 17:26:00 +0000 (17:26 +0000)]
Fix typo in previous commit

Applied the wrong patch

Reported by: Michael Butler <imb@protected-networks.net>
Approved by: mav (mentor)
Sponsored by: iXsystems.com

4 years agoscope6: Check for NULL afdata before dereferencing
Ryan Moeller [Wed, 3 Jun 2020 16:57:30 +0000 (16:57 +0000)]
scope6: Check for NULL afdata before dereferencing

Narrows the race window with if_detach.

Approved by: mav (mentor)
MFC after: 3 days
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25017

4 years agogptboot.efi: align secbuf to 4K
Mitchell Horne [Wed, 3 Jun 2020 16:38:16 +0000 (16:38 +0000)]
gptboot.efi: align secbuf to 4K

The u-boot EFI implementation of the ReadBlocks and WriteBlocks methods
requires that the provided buffer meet the IO alignment requirements of
the underlying disk. Unlike loader.efi, gptboot.efi doesn't check this
requirement, and therefore fails to perform a successful read. Adjust
secbuf's alignment to 4K in hopes that we will always meet this
requirement.

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25111

4 years agoWe should never allow either the broadcast or IN_ADDR_ANY to be
Randall Stewart [Wed, 3 Jun 2020 14:16:40 +0000 (14:16 +0000)]
We should never allow either the broadcast or IN_ADDR_ANY to be
connected to or sent to. This was fond when working with Michael
Tuexen and Skyzaller. Skyzaller seems to want to use either of
these two addresses to connect to at times. And it really is
an error to do so, so lets not allow that behavior.

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

4 years agoThis fixes a couple of skyzaller crashes. Most
Randall Stewart [Wed, 3 Jun 2020 14:07:31 +0000 (14:07 +0000)]
This fixes a couple of skyzaller crashes. Most
of them have to do with TFO. Even the default stack
had one of the issues:

1) We need to make sure for rack that we don't advance
   snd_nxt beyond iss when we are not doing fast open. We
   otherwise can get a bunch of SYN's sent out incorrectly
   with the seq number advancing.
2) When we complete the 3-way handshake we should not ever
   append to reassembly if the tlen is 0, if TFO is enabled
   prior to this fix we could still call the reasemmbly. Note
   this effects all three stacks.
3) Rack like its cousin BBR should track if a SYN is on a
   send map entry.
4) Both bbr and rack need to only consider len incremented on a SYN
   if the starting seq is iss, otherwise we don't increment len which
   may mean we return without adding a sendmap entry.

This work was done in collaberation with Michael Tuexen, thanks for
all the testing!
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D25000

4 years agoRestrict enabling TCP-FASTOPEN to end-points in CLOSED or LISTEN state
Michael Tuexen [Wed, 3 Jun 2020 13:51:53 +0000 (13:51 +0000)]
Restrict enabling TCP-FASTOPEN to end-points in CLOSED or LISTEN state

Enabling TCP-FASTOPEN on an end-point which is in a state other than
CLOSED or LISTEN, is a bug in the application. So it should not work.
Also the TCP code does not (and needs not to) handle this.
While there, also simplify the setting of the TF_FASTOPEN flag.

This issue was found by running syzkaller.

Reviewed by: rrs
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D25115

4 years agoAdd if_reassing method to all tunneling interfaces.
Andrey V. Elsukov [Wed, 3 Jun 2020 13:02:31 +0000 (13:02 +0000)]
Add if_reassing method to all tunneling interfaces.

After r339550 tunneling interfaces have started handle appearing and
disappearing of ingress IP address on the host system.
When such interfaces are moving into VNET jail, they lose ability to
properly handle ifaddr_event_ext event. And this leads to need to
reconfigure tunnel to make it working again.

Since moving an interface into VNET jail leads to removing of all IP
addresses, it looks consistent, that tunnel configuration should also
be cleared. This is what will do if_reassing method.

Reported by: John W. O'Brien <john saltant com>
MFC after: 1 week

4 years agotmpfs: Preserve alignment of struct fid fields
Ryan Moeller [Wed, 3 Jun 2020 09:38:51 +0000 (09:38 +0000)]
tmpfs: Preserve alignment of struct fid fields

On 64-bit platforms, the two short fields in `struct tmpfs_fid` are padded to
the 64-bit alignment of the long field.  This pushes the offsets of the
subsequent fields by 4 bytes and makes `struct tmpfs_fid` bigger than
`struct fid`.  `tmpfs_vptofh()` casts a `struct fid *` to `struct tmpfs_fid *`,
causing 4 bytes of adjacent memory to be overwritten when the struct fields are
set.  Through several layers of indirection and embedded structs, the adjacent
memory for one particular call to `tmpfs_vptofh()` happens to be the stack
canary for `nfsrvd_compound()`.  Half of the canary ends up being clobbered,
going unnoticed until eventually the stack check fails when `nfsrvd_compound()`
returns and a panic is triggered.

Instead of duplicating fields of `struct fid` in `struct tmpfs_fid`, narrow the
struct to cover only the unique fields for tmpfs and assert at compile time
that the struct fits in the allotted space.  This way we don't have to
replicate the offsets of `struct fid` fields, we just use them directly.

Reviewed by: kib, mav, rmacklem
Approved by: mav (mentor)
MFC after: 1 week
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25077

4 years agonetmap: vale: fix disabled logs
Vincenzo Maffione [Wed, 3 Jun 2020 05:49:19 +0000 (05:49 +0000)]
netmap: vale: fix disabled logs

MFC after: 1 week

4 years agonetmap: vtnet: remove leftover memory barriers
Vincenzo Maffione [Wed, 3 Jun 2020 05:48:42 +0000 (05:48 +0000)]
netmap: vtnet: remove leftover memory barriers

MFC after: 1 week

4 years agonetmap: vtnet: call netmap_rx_irq() under VQ lock
Vincenzo Maffione [Wed, 3 Jun 2020 05:27:29 +0000 (05:27 +0000)]
netmap: vtnet: call netmap_rx_irq() under VQ lock

The netmap_rx_irq() function normally wakes up user-space threads
waiting for more packets. In this case, it is not necessary to
call it under the driver queue lock. However, if the interface is
attached to a VALE switch, netmap_rx_irq() ends up calling rxsync
on the interface (see netmap_bwrap_intr_notify()). Although
concurrent rxsyncs are serialized through the kring lock
(see nm_kr_tryget()), the lock acquire operation is not blocking.
As a result, it may happen that netmap_rx_irq() is called on
an RX ring while another instance is running, causing the
second call to fail, and received packets stall in the receive VQ.
We fix this issue by calling netmap_irx_irq() under the VQ lock.

MFC after: 1 week

4 years agonetmap: vtnet: honor NM_IRQ_RESCHED
Vincenzo Maffione [Wed, 3 Jun 2020 05:09:33 +0000 (05:09 +0000)]
netmap: vtnet: honor NM_IRQ_RESCHED

The netmap_rx_irq() function may return NM_IRQ_RESCHED to inform the
driver that more work is pending, and that netmap expects netmap_rx_irq()
to be called again as soon as possible.
This change implements this behaviour in the vtnet driver.

MFC after: 1 week

4 years agoRemove unnecessary WITNESS check in x86 bus_dma
Jason A. Harmening [Wed, 3 Jun 2020 00:16:36 +0000 (00:16 +0000)]
Remove unnecessary WITNESS check in x86 bus_dma

When I did some bus_dma cleanup in r320528, I brought forward some sketchy
WITNESS checks from the prior x86 busdma wrappers, instead of recognizing
them as technical debt and just dropping them.  Two of these were removed in
r346351 and r346851, but one remains in bounce_bus_dmamem_alloc(). This check
could be constrained to only apply in the BUS_DMA_NOWAIT case, but it's cleaner
to simply remove it and rely on the checks already present in the sleepable
allocation paths used by this function.

While here, remove another unnecessary witness check in bus_dma_tag_create
(the tag is always allocated with M_NOWAIT), and fix a couple of typos.

Reported by: cem
Reviewed by: kib, cem
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25107

4 years agolld: Set DF_1_PIE for -pie
Ed Maste [Tue, 2 Jun 2020 22:57:13 +0000 (22:57 +0000)]
lld: Set DF_1_PIE for -pie

DF_1_PIE originated from Solaris[1].

GNU ld[2] sets the flag on non-Solaris platforms.

It can help distinguish PIE from ET_DYN.
eu-classify from elfutils uses this to recognize PIE[3].

glibc uses this flag to reject dlopen'ing a PIE[4]

[1] https://docs.oracle.com/cd/E36784_01/html/E36857/chapter6-42444.html
[2] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=5fe2850dd96483f176858fd75c098313d5b20bc2
[3] https://sourceware.org/git/?p=elfutils.git;a=commit;h=3f489b5c7c78df6d52f8982f79c36e9a220e8951
[4] https://sourceware.org/bugzilla/show_bug.cgi?id=24323

Discussed with: dim
Obtained from: LLVM ee9a251caf1d
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agollvm: Add DF_1_PIE
Ed Maste [Tue, 2 Jun 2020 22:55:51 +0000 (22:55 +0000)]
llvm: Add DF_1_PIE

Discussed with: dim
Obtained from: LLVM d9943e7f0ce8
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years ago[run] note that PHY_HT is for mixed mode.
Adrian Chadd [Tue, 2 Jun 2020 22:37:53 +0000 (22:37 +0000)]
[run] note that PHY_HT is for mixed mode.

Submitted by: Ashish Gupta <ashishgu@andrew.cmu.edu>
Differential Revision: https://reviews.freebsd.org/D25108

4 years ago[run] Set the number of HT chains.
Adrian Chadd [Tue, 2 Jun 2020 22:36:17 +0000 (22:36 +0000)]
[run] Set the number of HT chains.

* Set the tx/rx chains based on the existing MIMO eeprom reads
* Add 3-chain rates

Tested:

* MAC/BBP RT5390 (rev 0x0502), RF RT5370 (MIMO 1T1R), 2g/5g STA
* MAC/BBP RT3593 (rev 0x0402), RF RT3053 (MIMO 3T3R), 2g/5g STA

4 years agoUppercase 'dso' to indicate that it is abbreviation.
Konstantin Belousov [Tue, 2 Jun 2020 17:33:10 +0000 (17:33 +0000)]
Uppercase 'dso' to indicate that it is abbreviation.

Suggested by: arichardson
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoRemove from RB_REMOVE_COLOR some null checks where the pointer checked
Doug Moore [Tue, 2 Jun 2020 17:18:16 +0000 (17:18 +0000)]
Remove from RB_REMOVE_COLOR some null checks where the pointer checked
is provably never null.  Restructure the surrounding code just enough
to make the non-nullness obvious.

Reviewed by: markj
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D25089

4 years ago[run] Add 11NA flags for 5G NICs that support HT.
Adrian Chadd [Tue, 2 Jun 2020 16:40:58 +0000 (16:40 +0000)]
[run] Add 11NA flags for 5G NICs that support HT.

Now that I'm a proud owner of an ASUS USB-N66, I can test 2G/5G and
3-stream configurations.

For now, just flip on 5G HT rates.  I've tested this in both
5G HT20 and 5G 11a modes.  It's still one stream for now until
we verify that the number of streams reported (ie the MIMO below)
is actually the number of 11n streams, NOT the number of antennas.
(They don't have to match! You can have more antennas than MIMO
streams!)

Tested:

* run0: MAC/BBP RT3593 (rev 0x0402), RF RT3053 (MIMO 3T3R)

4 years agoDo not allow to load ET_DYN object with DF_1_PIE flag set.
Konstantin Belousov [Tue, 2 Jun 2020 16:20:58 +0000 (16:20 +0000)]
Do not allow to load ET_DYN object with DF_1_PIE flag set.

Linkers are supposed to mark PIE binaries with DF_1_PIE, such binary
cannot be correctly and usefully loaded neither by dlopen(3) nor as a
dependency of other object.  For instance, we cannot do anything
useful with COPY relocations, among other things.

Glibc already added similar restriction.

Requested and reviewed by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25086

4 years agoImplement __is_constexpr() function macro in the LinuxKPI.
Hans Petter Selasky [Tue, 2 Jun 2020 12:23:04 +0000 (12:23 +0000)]
Implement __is_constexpr() function macro in the LinuxKPI.
Bump the FreeBSD version.

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoImplement struct_size() function macro in the LinuxKPI.
Hans Petter Selasky [Tue, 2 Jun 2020 10:19:45 +0000 (10:19 +0000)]
Implement struct_size() function macro in the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoImplement BUILD_BUG_ON_ZERO() in the LinuxKPI.
Hans Petter Selasky [Tue, 2 Jun 2020 09:45:43 +0000 (09:45 +0000)]
Implement BUILD_BUG_ON_ZERO() in the LinuxKPI.
Tested using gcc and clang.

MFC after: 1 week
Sponsored by: Mellanox Technologies