]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMerge llvm trunk r366426, resolve conflicts, and update FREEBSD-Xlist.
dim [Wed, 21 Aug 2019 18:13:02 +0000 (18:13 +0000)]
Merge llvm trunk r366426, resolve conflicts, and update FREEBSD-Xlist.

4 years agomakefs.8: update history
emaste [Tue, 20 Aug 2019 21:14:44 +0000 (21:14 +0000)]
makefs.8: update history

- ported to FreeBSD and first appeared in 8.0
- Christos Zoulas added the FAT support that I imported

4 years agoVendor import of stripped llvm trunk r366426 (just before the release_90
dim [Tue, 20 Aug 2019 20:50:12 +0000 (20:50 +0000)]
Vendor import of stripped llvm trunk r366426 (just before the release_90
branch point):

https://llvm.org/svn/llvm-project/llvm/trunk@366426

4 years agomakefs: avoid "dereferencing 'void *' pointer" warnings
emaste [Tue, 20 Aug 2019 20:04:16 +0000 (20:04 +0000)]
makefs: avoid "dereferencing 'void *' pointer" warnings

On GCC 4.2.1 archs

MFC with: r351273
Sponsored by: The FreeBSD Foundation

4 years agoloader.efi: efipart should be more careful about constructing block device lists
tsoome [Tue, 20 Aug 2019 19:31:11 +0000 (19:31 +0000)]
loader.efi: efipart should be more careful about constructing block device lists

The cd handles should be collected as list of partitions. Some systems also
provide base name for block device (like PciRoot(0x0)/Pci(0x5,0x0)), we need
to be careful about those.

To make out life a bit easier, we prepare not just an array of handles, but we
allocate pdinfo struct for each handle and devicepath, then we can simplify
our work to sort the devices.

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

4 years agomakefs: add msdosfs (FAT) support
emaste [Tue, 20 Aug 2019 18:20:45 +0000 (18:20 +0000)]
makefs: add msdosfs (FAT) support

Add FAT support to makefs by copying some files from sys/fs/msdosfs/ and
updating others with changes from NetBSD.

The six files copied from sys/fs/msdosfs at r348251 and modified are:
denode.h direntry.h fat.h msdosfs_fat.c msdosfs_lookup.c msdosfsmount.h

I would prefer to avoid the duplication, but reluctance to doing so was
expressed in a previous review (D11197); for now copy the files and
revisit in the future.

Submitted by: Siva Mahadevan
Discussed with: cem, imp
MFC after: 1 month
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D16438

4 years agoRemove upstream files and directories from vendor/llvm/dist that we do
dim [Tue, 20 Aug 2019 17:58:59 +0000 (17:58 +0000)]
Remove upstream files and directories from vendor/llvm/dist that we do
not use.  This saves on repository space, and reduces the number of tree
conflicts when merging.

4 years agoUse a sleepable lock for midistat functions.
markj [Tue, 20 Aug 2019 17:52:12 +0000 (17:52 +0000)]
Use a sleepable lock for midistat functions.

Otherwise the mutex needs to be dropped when copying out the midistat
sbuf, leading to a race which allows one to read kernel memory beyond
the end of the sbuf buffer.

Reported and tested by: pho
Security: CVE-2019-5612

4 years agomqueuefs: fix compat32 struct file leak
emaste [Tue, 20 Aug 2019 17:44:03 +0000 (17:44 +0000)]
mqueuefs: fix compat32 struct file leak

In a compat32 error case we previously leaked a struct file.

Submitted by: Karsten König, Secfault Security
Security: CVE-2019-5603

4 years agoPull in r368867 from upstream libc++ trunk (by Marshall Clow):
dim [Tue, 20 Aug 2019 17:39:32 +0000 (17:39 +0000)]
Pull in r368867 from upstream libc++ trunk (by Marshall Clow):

  Rework recursive_timed_mutex so that it uses __thread_id instead of
  using the lower-level __libcpp_thread_id. This is prep for fixing
  PR42918. Reviewed as https://reviews.llvm.org/D65895

Pull in r368916 from upstream libc++ trunk (by Marshall Clow):

  Fix thread comparison by making sure we never pass our special 'not a
  thread' value to the underlying implementation. Fixes PR#42918.

This should fix std::thread::id::operator==() attempting to call
pthread_equal(3) with zero values.

Reported by: andrew@tao11.riddles.org.uk
PR: 239038, 239550
MFC after: 3 days

4 years agoRemove some compatability with Seventh Edition UNIX realloc().
brooks [Tue, 20 Aug 2019 16:07:17 +0000 (16:07 +0000)]
Remove some compatability with Seventh Edition UNIX realloc().

In Seventh Edition UNIX, the last pointer passed to free() was
guaranteed to not actually have been freed allowing memory to be
"compacted" via the following pattern:

free(foo);
foo = realloc(foo, newsize);

Further, Andrew Koenig reports in "C Traps and Pitfalls" that the
original realloc() implementation required this pattern.

The C standard is clear that this is Undefined Behavior. Modern
allocators don't support it and no portable code could rely on it so
remove this support.

Note: the removed implementation contains an off-by-one error and if
an item isn't found on the freelist, then twice as much memory as the
largest possible allocation will be copied.

Reviewed by: kib, imp
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21296

4 years agoUnbreak USB ethernet module builds
jhibbits [Tue, 20 Aug 2019 15:14:32 +0000 (15:14 +0000)]
Unbreak USB ethernet module builds

Sponsored by: Juniper Networks, Inc.

4 years agonetpfil tests: Add too many fragments test for pf, ipfw and ipf
kp [Tue, 20 Aug 2019 14:46:12 +0000 (14:46 +0000)]
netpfil tests: Add too many fragments test for pf, ipfw and ipf

Add test for checking that the packets are dropped if it is fragmented into
more than the defined value.

Submitted by: Ahsan Barkati
Reviewed by: kp
Sponsored by: Google, Inc. (GSoC 2019)
Differential Revision: https://reviews.freebsd.org/D21307

4 years agonetpfil tests: Add the set ToS test for ipfw and pf
kp [Tue, 20 Aug 2019 14:31:22 +0000 (14:31 +0000)]
netpfil tests: Add the set ToS test for ipfw and pf

This test tests the following:

 - The firewall is able to set the tos bits
 - The firewall is able to set the DSCP bits when EN bits is already set and
   the EN bits remains unchanged.
 - The firewall is able to drop the packets based on ToS value

Submitted by: Ahsan Barkati
Reviewed by: kp
Sponsored by: Google, Inc. (GSoC 2019)
Differential Revision: https://reviews.freebsd.org/D21305

4 years agopowerpc: Link Book-E kernels at the same address as AIM kernels
jhibbits [Tue, 20 Aug 2019 01:26:02 +0000 (01:26 +0000)]
powerpc: Link Book-E kernels at the same address as AIM kernels

Summary:
Reduce the diff between AIM and Book-E even more.  This also cleans up
vmparam.h significantly.

Reviewed by: luporl
Differential Revision: https://reviews.freebsd.org/D21301

4 years agousb_ethernet.h includes a number of mii headers, but only does so in
stevek [Tue, 20 Aug 2019 01:06:43 +0000 (01:06 +0000)]
usb_ethernet.h includes a number of mii headers, but only does so in
order to have struct mii_data available. However, it only really needs
a forward declaration of struct mii_data for use in pointer form for
the return type of a function prototype.

Custom kernel configuration that have usb and fdt enabled, but no miibus,
end up with compilation failures because miibus_if.h will not get
generated.

Due to the above, the following changes have been made to usb_ethernet.h:
 * remove the inclusion of mii headers
 * forward-declare struct mii_data
 * include net/ifq.h to satify the need for complete struct ifqueue

Reviewed by: ian
Obtained from: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D21293

4 years agoUse an atomic reference count for paging in progress so that callers do not
jeff [Mon, 19 Aug 2019 23:09:38 +0000 (23:09 +0000)]
Use an atomic reference count for paging in progress so that callers do not
require the object lock.

Reviewed by: markj
Tested by: pho (as part of a larger branch)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21311

4 years agoFix stylistic nit in r351239
cem [Mon, 19 Aug 2019 23:01:59 +0000 (23:01 +0000)]
Fix stylistic nit in r351239

Meant to fix this before committing, but forgot.

4 years agogdb(4): Support "qC" query
cem [Mon, 19 Aug 2019 22:58:30 +0000 (22:58 +0000)]
gdb(4): Support "qC" query

Sometimes GDB gets confused about what the current thread is.  When it does,
it asks the remote: "Who am I?"

Answer it.

4 years agogdb(4): Pack 'info threads' responses into fewer packets
cem [Mon, 19 Aug 2019 22:57:03 +0000 (22:57 +0000)]
gdb(4): Pack 'info threads' responses into fewer packets

We suffer at least one round trip ACK latency every command / packet that
GDB has to send and receive, and the response format for 'info threads'
supports packing many threads IDs into a single packet, so do so.

Adds and uses a new API, gdb_txbuf_has_capacity(), which checks for a
certain number of bytes available in the outgoing txbuf.

On an example amd64 VM, the number of RTTs to transmit this list is reduced
by a factor of 110x.  This is especially beneficial with recent GDB, which
seems to request the list at least twice during attach.

4 years agolibkern: Implement strchrnul(3)
cem [Mon, 19 Aug 2019 22:53:05 +0000 (22:53 +0000)]
libkern: Implement strchrnul(3)

4 years agoPermit vm_pager_has_page() to run with a shared lock. Introduce
jeff [Mon, 19 Aug 2019 22:25:28 +0000 (22:25 +0000)]
Permit vm_pager_has_page() to run with a shared lock.  Introduce
VM_OBJECT_DROP/VM_OBJECT_PICKUP to handle functions that are called with
uncertain lock state.

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

4 years agoPartially revert the previous commit.
jkim [Mon, 19 Aug 2019 21:45:25 +0000 (21:45 +0000)]
Partially revert the previous commit.

It was an experiment and not meant to be committed. :-(

4 years agomakefs.8: expand description of image size
emaste [Mon, 19 Aug 2019 21:38:10 +0000 (21:38 +0000)]
makefs.8: expand description of image size

Submitted by: ryan_freqlabs.com, Siva Mahadevan
Differential Revision: https://reviews.freebsd.org/D21316

4 years agoFix sound on headset jack for Lenovo Thinkpad X1 Carbon Gen 6 (model 20KH).
jkim [Mon, 19 Aug 2019 21:30:12 +0000 (21:30 +0000)]
Fix sound on headset jack for Lenovo Thinkpad X1 Carbon Gen 6 (model 20KH).

Note this commit was inspired by r350433.

MFC after: 2 weeks

4 years agomakefs.8: style updates from igor
emaste [Mon, 19 Aug 2019 21:21:32 +0000 (21:21 +0000)]
makefs.8: style updates from igor

Sponsored by: The FreeBSD Foundation

4 years agotuntap: belatedly add MODULE_VERSION for if_tun and if_tap
kevans [Mon, 19 Aug 2019 19:01:59 +0000 (19:01 +0000)]
tuntap: belatedly add MODULE_VERSION for if_tun and if_tap

When tun/tap were merged, appropriate MODULE_VERSION should have been added
for things like modfind(2) to continue to do the right thing with the old
names.

Reported by: jhb

4 years agomips: avoid empty mdproc struct
kevans [Mon, 19 Aug 2019 18:15:17 +0000 (18:15 +0000)]
mips: avoid empty mdproc struct

Compiling with a more modern toolchain than GCC 4.2 in base warns about the
empty struct. Take a hint and comment from r350902+r350953 by luporl@.

4 years agoFix uninitialized variable warnings when MK_CASPER=no
asomers [Mon, 19 Aug 2019 17:54:40 +0000 (17:54 +0000)]
Fix uninitialized variable warnings when MK_CASPER=no

Submitted by: Ján Sučan <sucanjan@gmail.com>
MFC after: 2 weeks
Sponsored by: Google, inc. (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21322

4 years agoDon't set the string "unknown" as a device's location_str
scottph [Mon, 19 Aug 2019 17:51:06 +0000 (17:51 +0000)]
Don't set the string "unknown" as a device's location_str

Return an empty string when the location is unknown instead of the
string "unknown". This ensures that all location entries are of
the form key=val.

Suggested by: imp
Approved by: jhb (mentor)
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D21326

4 years agoTrim a spurious blank line I added in r348969.
jhb [Mon, 19 Aug 2019 17:28:12 +0000 (17:28 +0000)]
Trim a spurious blank line I added in r348969.

I did not bump .Dd since there is no content change.

MFC after: 3 days

4 years agoping: fix -Wformat-truncating warning with GCC
asomers [Mon, 19 Aug 2019 17:28:12 +0000 (17:28 +0000)]
ping: fix -Wformat-truncating warning with GCC

Increase buffer size for the string representation of n_time

ICMP timestamp is a 32-bit number. In pr_ntime(), number of minutes
and seconds is always 2 characters wide. Max. number of hours is 4
characters wide. The buffer size should be at least:

4 + 2 + 2 + 1 (':') + 1 (':') + 1 ('\0') = 11

Submitted by: Ján Sučan <sucanjan@gmail.com>
MFC after: 2 weeks
Sponsored by: Google, inc. (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21325

4 years agolink ptnet(4) man page to the build system
vmaffione [Mon, 19 Aug 2019 17:26:04 +0000 (17:26 +0000)]
link ptnet(4) man page to the build system

Reported by: kevans
Reviewed by: kevans, bcr
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21312

4 years agoif_tuntap: minor improvements
vmaffione [Mon, 19 Aug 2019 17:23:22 +0000 (17:23 +0000)]
if_tuntap: minor improvements

Rewrite a loop to avoid duplicating the exit condition.
Simplify mask processing in tunpoll().
Fix minor typos.

Reviewed by: kevans, markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D21302

4 years agoFix netdump buffering after r348473.
markj [Mon, 19 Aug 2019 16:29:51 +0000 (16:29 +0000)]
Fix netdump buffering after r348473.

nd_buf is used to buffer headers (for both the kernel dump itself and
for EKCD) before the final call to netdump_dumper(), which flushes
residual data in nd_buf.  As a result, a small portion of the residual
data would be corrupted.  This manifests when kernel dump compression
is enabled since both zstd and zlib detect the corruption during
decompression.

Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D21294

4 years agoti: sdhci: Correct voltage caps
manu [Mon, 19 Aug 2019 14:33:22 +0000 (14:33 +0000)]
ti: sdhci: Correct voltage caps

ti,dual-volt property say that the eMMC support 1.8V and 3.3V not 3.0V
Use the correct caps for the mmc stack.
Note that the MMCHS_SD_CAPA register can only be written once after bootup
so if one is using a u-boot compiled with eMMC support (this is the default)
this code is a no-op but just in case someone have u-boot compiled without
eMMC support this make eMMC works when the kernel is booted.

MFC after: 1 week

4 years agoarm64: a37x0_gpio: Use syscon instead of MMIO region
manu [Mon, 19 Aug 2019 14:28:54 +0000 (14:28 +0000)]
arm64: a37x0_gpio: Use syscon instead of MMIO region

The fdt node for this driver is a simple-mfd and syscon compatible one
meaning that simplemfd will be the driver attached for it. The gpio driver
is attached to the 'gpio' subnode so use syscon_get_handle_default to
obtain the handle of the syscon from the parent device and use this
to read/write to the memory region.

MFC after: 1 week

4 years agoping6: revert r350857
asomers [Mon, 19 Aug 2019 14:20:26 +0000 (14:20 +0000)]
ping6: revert r350857

Some socket options require root privileges to set.  The old code did indeed
drop privileges at the earliest opportunity.

Submitted by: Ján Sučan <sucanjan@gmail.com>
MFC after: Never
Sponsored by: Google, Inc. (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21319

4 years agovfs: fix up r351193 ("stop always overwriting ->mnt_stat in VFS_STATFS")
mjg [Mon, 19 Aug 2019 14:11:54 +0000 (14:11 +0000)]
vfs: fix up r351193 ("stop always overwriting ->mnt_stat in VFS_STATFS")

fs-specific part of vfs_statfs routines only fill in small portion of the
structure. Previous code was always copying everything at a higher layer to
acoomodate it and this patch does the same.

'df' (no arguments) worked fine because the caller uses mnt_stat itself as the
target buffer, making all the copying a no-op for its own case.
'df /' and similar use a different consumer which passes its own buffer and
this is where you can run into trouble.

Reported by: cy
Fixes: r351193
Sponsored by: The FreeBSD Foundation

4 years agoUse TAILQ_FOREACH_SAFE() macro to avoid use after free in soclose().
ae [Mon, 19 Aug 2019 12:42:03 +0000 (12:42 +0000)]
Use TAILQ_FOREACH_SAFE() macro to avoid use after free in soclose().

PR: 239893
MFC after: 1 week

4 years agoassert that td_lk_slocks is not leaked upon return from kernel
avg [Mon, 19 Aug 2019 11:18:36 +0000 (11:18 +0000)]
assert that td_lk_slocks is not leaked upon return from kernel

This is similar to checks for td_sx_slocks and td_rw_rlocks.
Although td_lk_slocks is an implementation detail, it still makes sense
to validate it.

MFC after: 1 week
Sponsored by: Panzura

4 years agonetpfil tests: Move pft_ping.py and sniffer.py to the common test directory
kp [Mon, 19 Aug 2019 10:48:27 +0000 (10:48 +0000)]
netpfil tests: Move pft_ping.py and sniffer.py to the common test directory

The pft_ping.py and sniffer.py tool is moved from tests/sys/netpfil/pf to
tests/sys/netpfil/common directory because these tools are to be used in
common for all the firewalls.

Submitted by: Ahsan Barkati
Reviewed by: kp, thj
Sponsored by: Google, Inc. (GSoC 2019)
Differential Revision: https://reviews.freebsd.org/D21276

4 years agosys.kern.pdeathsig.signal_delivered_ptrace: fix startup.
kib [Mon, 19 Aug 2019 09:33:09 +0000 (09:33 +0000)]
sys.kern.pdeathsig.signal_delivered_ptrace: fix startup.

Inform D that C executed procctl(PROC_PDEATHSIG_CTL).  Otherwise D
might allow B to exit before C is set up to receive a signal on the
parent exit.  In this case, C waits forever for the signal and test
hangs.

PR: 237657
Reported and tested by: lwhsu
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agosys.kern.pdeathsig.signal_delivered_ptrace: fix debugger detach
kib [Mon, 19 Aug 2019 09:29:27 +0000 (09:29 +0000)]
sys.kern.pdeathsig.signal_delivered_ptrace: fix debugger detach

ptrace(PT_DETACH) requires stopped debuggee, otherwise it fails.  When
the call fails, the C process is left as debuggee of the process D,
and might be killed too early if process D exits occurs fast enough.

Since pipes are not closed in the forked children, this resulted in
the test hanging, since no write occured from C to wake A.

PR: 237657
Reported and tested by: lwhsu
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoUse calloc().
delphij [Mon, 19 Aug 2019 05:24:42 +0000 (05:24 +0000)]
Use calloc().

MFC after: 2 weeks

4 years agoRemove redundant check and wrong fix: fat.c checks already take care
delphij [Mon, 19 Aug 2019 04:28:12 +0000 (04:28 +0000)]
Remove redundant check and wrong fix: fat.c checks already take care
about cluster chains.

Obtained from: OpenBSD
MFC after: 2 weeks

4 years agoperiodic: replace "tty" with "test -t 0"
asomers [Mon, 19 Aug 2019 01:14:11 +0000 (01:14 +0000)]
periodic: replace "tty" with "test -t 0"

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

Reviewed by: cy
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D21318

4 years agoAdd an entry to RELNOTES for r351201.
rmacklem [Mon, 19 Aug 2019 00:46:31 +0000 (00:46 +0000)]
Add an entry to RELNOTES for r351201.

4 years agoAdd a vop_stdioctl() that performs a trivial FIOSEEKDATA/FIOSEEKHOLE.
rmacklem [Mon, 19 Aug 2019 00:29:05 +0000 (00:29 +0000)]
Add a vop_stdioctl() that performs a trivial FIOSEEKDATA/FIOSEEKHOLE.

Without this patch, when an application performed lseek(SEEK_DATA/SEEK_HOLE)
on a file in a file system that does not have its own VOP_IOCTL(), the
lseek(2) fails with errno ENOTTY. This didn't seem appropriate, since
ENOTTY is not listed as an error return by either the lseek(2) man page
nor the POSIX draft for lseek(2).
A discussion on freebsd-current@ seemed to indicate that implementing
a trivial algorithm that returns the offset argument for FIOSEEKDATA and
returns the file's size for FIOSEEKHOLE was the preferred fix.
http://docs.FreeBSD.org/cgi/mid.cgi?CAOtMX2iiQdv1+15e1N_r7V6aCx_VqAJCTP1AW+qs3Yg7sPg9wA
The Linux kernel appears to implement this trivial algorithm as well.

This patch adds a vop_stdioctl() that implements this trivial algorithm.
It returns errors consistent with vn_bmap_seekhole() and, as such, will
still return ENOTTY for non-regular files.

I have proposed a separate patch that maps errors not described by the
lseek(2) man page nor POSIX draft to EINVAL. This patch is under separate
review.

Reviewed by: kib
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D21299

4 years agoAllocate all per-cpu datastructures in domain correct memory.
jeff [Sun, 18 Aug 2019 23:44:23 +0000 (23:44 +0000)]
Allocate all per-cpu datastructures in domain correct memory.

Reviewed by: kib, gallatin (some objections)
Tested by: pho
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21242

4 years agoiwmbtfw(8): Fix compilation on platforms using gcc.
wulf [Sun, 18 Aug 2019 23:10:07 +0000 (23:10 +0000)]
iwmbtfw(8): Fix compilation on platforms using gcc.

X-MFC with: r351197

4 years agoAllocate amd64's page array using pages and page directory pages from the
jeff [Sun, 18 Aug 2019 23:07:56 +0000 (23:07 +0000)]
Allocate amd64's page array using pages and page directory pages from the
NUMA domain that the pages describe.  Patch original from gallatin.

Reviewed by: kib
Tested by: pho
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21252

4 years agoiwmbtfw: Firmware loader for Intel Wireless 8260 based Bluetooth USB devices
wulf [Sun, 18 Aug 2019 22:20:28 +0000 (22:20 +0000)]
iwmbtfw: Firmware loader for Intel Wireless 8260 based Bluetooth USB devices

Currently supported models are: 8260, 8265, 9560, 9260 and 22161.
Firmware files can be installed with comms/iwmbt-firmware port.

PR: 237083
Reviewed by: hps, emax
X-MFC with: r351196
Differential Revision: https://reviews.freebsd.org/D21071

4 years agong_ubt(4): do not attach Intel Wireless 8260/8265 in bootloader mode.
wulf [Sun, 18 Aug 2019 22:11:42 +0000 (22:11 +0000)]
ng_ubt(4): do not attach Intel Wireless 8260/8265 in bootloader mode.

Add helper function for synchronous execution of HCI commands at probe
stage and use this function to check firmware state of Intel Wireless
8260/8265 bluetooth devices found in many post 2016 year laptops.

Attempt to initialize FreeBSD bluetooth stack while such a device is in
bootloader mode locks the adapter hardly so it requires power on/off
cycle to restore.

This change blocks ng_ubt attachment unless operational firmware is
loaded thus preventing the lock up.

PR: 237083
Reviewed by: hps, emax
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D21071

4 years agoFix an issue with executing tmpfs binary.
kib [Sun, 18 Aug 2019 20:36:11 +0000 (20:36 +0000)]
Fix an issue with executing tmpfs binary.

Suppose that a binary was executed from tmpfs mount, and the text
vnode was reclaimed while the binary was still running.  It is
possible during even the normal operations since tmpfs vnode'
vm_object has swap type, and no references on the vnode is held.  Also
assume that the text vnode was revived for some reason.  Then, on the
process exit or exec, unmapping of the text mapping tries to remove
the text reference from the vnode, but since it went from
recycle/instantiation cycle, there is no reference kept, and assertion
in VOP_UNSET_TEXT_CHECKED() triggers.

Fix this by keeping a use reference on the tmpfs vnode for each exec
reference.  This prevents the vnode reclamation while executable map
entry is active.

Do it by adding per-mount flag MNTK_TEXT_REFS that directs
vop_stdset_text() to add use ref on first vnode text use, and
per-vnode VI_TEXT_REF flag, to record the need on unref in
vop_stdunset_text() on last vnode text use going away.  Set
MNTK_TEXT_REFS for tmpfs mounts.

Reported by: bdrewery
Tested by: sbruno, pho (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoChange locking requirements for VOP_UNSET_TEXT().
kib [Sun, 18 Aug 2019 20:24:52 +0000 (20:24 +0000)]
Change locking requirements for VOP_UNSET_TEXT().

Require the vnode to be locked for the VOP_UNSET_TEXT() call.  This
will be used by the following bug fix for a tmpfs issue.

Tested by: sbruno, pho (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agovfs: stop always overwriting ->mnt_stat in VFS_STATFS
mjg [Sun, 18 Aug 2019 18:40:12 +0000 (18:40 +0000)]
vfs: stop always overwriting ->mnt_stat in VFS_STATFS

The struct is already populated on each mount (and remount). Fields are either
constant or not used by filesystem in the first place.

Some infrequently used functions use it to avoid having to allocate a new buffer
and are left alone.

The current code results in an avoidable copying single-threaded and significant
cache line bouncing multithreaded

While here deduplicate initial filling of the struct.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21317

4 years agoperiodic: fix anticongestion for scripts run after security
asomers [Sun, 18 Aug 2019 17:12:06 +0000 (17:12 +0000)]
periodic: fix anticongestion for scripts run after security

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

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

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

4 years agorandom(4): Reorder configuration of random source modules
cem [Sun, 18 Aug 2019 16:04:01 +0000 (16:04 +0000)]
random(4): Reorder configuration of random source modules

Move fast entropy source registration to the earlier
SI_SUB_RANDOM:SI_ORDER_FOURTH and move random_harvestq_prime after that.
Relocate the registration routines out of the much later randomdev module
and into random_harvestq.

This is necessary for the fast random sources to actually register before we
perform random_harvestq_prime() early in the kernel boot.

No functional change.

Reviewed by: delphij, markjm
Approved by: secteam(delphij)
Differential Revision: https://reviews.freebsd.org/D21308

4 years agoi386: Implement atomic_load_64(9) and atomic_store_64(9).
kib [Sun, 18 Aug 2019 15:58:44 +0000 (15:58 +0000)]
i386: Implement atomic_load_64(9) and atomic_store_64(9).

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoFix bug introduced by r351184.
mmel [Sun, 18 Aug 2019 15:37:19 +0000 (15:37 +0000)]
Fix bug introduced by r351184.
We should check the returned handle, not the pointer to it.

Noticed by: ian
X-MFC with: r351184
MFC after: 1 week

4 years agoAdd a blocking wait bit to refcount. This allows refs to be used as a simple
jeff [Sun, 18 Aug 2019 11:43:58 +0000 (11:43 +0000)]
Add a blocking wait bit to refcount.  This allows refs to be used as a simple
barrier.

Reviewed by: markj, kib
Discussed with: jhb
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21254

4 years agoImprove rk_pinctrl driver:
mmel [Sun, 18 Aug 2019 09:19:33 +0000 (09:19 +0000)]
Improve rk_pinctrl driver:
- add support for 'output-low', 'output-high', 'output-low' and
  'output-enable' properties. These are use in RK3288 DT files
- add support for RK3288
- to reduce overall file size, use local macros for initialization
  of pinctrl description structures.

MFC after: 2 weeks

4 years agoImprove rk_i2c driver:
mmel [Sun, 18 Aug 2019 09:11:43 +0000 (09:11 +0000)]
Improve rk_i2c driver:
- Properly handle IIC_M_NOSTOP and IIC_M_NOSTART flags.
- add polling mode, so driver can be used even if interrupts are not
  enabled (this is necessary for proper support of PMICs).
- add support for RK3288

MFC after: 2 weeks

4 years agoEnhance support of extres in dwmmc driver.
mmel [Sun, 18 Aug 2019 08:54:10 +0000 (08:54 +0000)]
Enhance support of extres in dwmmc driver.
Handle all clocks, regulators and resets defined by dwmmc bindings.

MFC after: 2 weeks

4 years agoAdd method for getting of syscon handle from parent device.
mmel [Sun, 18 Aug 2019 08:08:56 +0000 (08:08 +0000)]
Add method for getting of syscon handle from parent device.

If simple multifuction device also provides syscon interface, its
childern should be able to consume it. Due to this:
- declare coresponding method in syscon interface
- implement it in simple multifunction device driver

MFC after: 1 week

4 years agoRemove unnecessary debugging from r351181 that caused powerpc build to fail.
jeff [Sun, 18 Aug 2019 08:07:31 +0000 (08:07 +0000)]
Remove unnecessary debugging from r351181 that caused powerpc build to fail.

Tested by: make universe TARGETS=powerpc

4 years agovm_phys_avail_find is only used on NUMA kernels. Fix a build error.
jeff [Sun, 18 Aug 2019 07:43:15 +0000 (07:43 +0000)]
vm_phys_avail_find is only used on NUMA kernels.  Fix a build error.

4 years agoEncapsulate phys_avail manipulation in a set of simple routines. Add a
jeff [Sun, 18 Aug 2019 07:06:31 +0000 (07:06 +0000)]
Encapsulate phys_avail manipulation in a set of simple routines.  Add a
NUMA aware boot time memory allocator that will be used to allocate early
domain correct structures.  Code partially submitted by gallatin.

Reviewed by: gallatin, kib
Tested by: pho
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21251

4 years agoOFED: Fix accidental double-copy of rdma_sdp.h in r351176
cem [Sun, 18 Aug 2019 04:19:41 +0000 (04:19 +0000)]
OFED: Fix accidental double-copy of rdma_sdp.h in r351176

The mistake came about like this: the first attempt to commit was blocked by
a pre-commit hook due to missing SVN tags.  svn revert doesn't delete new
files, I guess.  While reapplying the fixed diff, the non-empty target file
was just concatenated with the new contents?  Ugh. :-(

4 years agosimple_httpd was not buildable for some time due to multiple missing
eugen [Sun, 18 Aug 2019 01:00:21 +0000 (01:00 +0000)]
simple_httpd was not buildable for some time due to multiple missing
"static" keywords and -Werror,-Wmissing-variable-declarations

This change adds needed "static" so it builds again with WARNS?=6
No functional changes.

MFC after: 1 week

4 years agoRevert r351130
manu [Sat, 17 Aug 2019 19:06:05 +0000 (19:06 +0000)]
Revert r351130

This driver should use the syscon handle exposed by the parent simple-mfd one.

4 years agoRevert r351129
manu [Sat, 17 Aug 2019 19:05:11 +0000 (19:05 +0000)]
Revert r351129

the point of syscon node is to avoid multiple device driver reading/writing
to the same area.

Reported by: ian

4 years agoOFED: Unbreak SDP support in ibcore
cem [Sat, 17 Aug 2019 18:54:07 +0000 (18:54 +0000)]
OFED: Unbreak SDP support in ibcore

This regression was introduced in the r326169 Linux v4.9 Infiniband upgrade.
Restore the functionality.

Reviewed by: hselasky
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D21298

4 years agofork: rework locking around do_fork
mjg [Sat, 17 Aug 2019 18:19:49 +0000 (18:19 +0000)]
fork: rework locking around do_fork

- move allproc lock into the func, it is of no use prior to it
- the code would lock p1 and p2 while holding allproc to partially
construct it after it gets added to the list. instead we can do the
work prior to adding anything.
- protect lastpid with procid_lock

As a side effect we do less work with allproc held.

Sponsored by: The FreeBSD Foundation

4 years agofork: bump process count before checking for permission to cross the limit
mjg [Sat, 17 Aug 2019 17:56:43 +0000 (17:56 +0000)]
fork: bump process count before checking for permission to cross the limit

The limit is almost never reached. Do the check only on failure to see if
we can override it.

No change in user-visible behavior.

Sponsored by: The FreeBSD Foundation

4 years agofork: stop skipping < 100 ids on wrap around
mjg [Sat, 17 Aug 2019 17:42:01 +0000 (17:42 +0000)]
fork: stop skipping < 100 ids on wrap around

Code doing this is commented with a claim that these IDs are occupied by
daemons, but that's demonstrably false. To an extent the range is used by init
and kernel processes (and on sufficiently big machines it indeed is fully
populated).

On a sample box 40-way box the highest id in the range is 63. On a different one
it is 23. Just use the range.

Sponsored by: The FreeBSD Foundation

4 years agoping6: Raise WARNS level to 6
asomers [Sat, 17 Aug 2019 17:22:08 +0000 (17:22 +0000)]
ping6: Raise WARNS level to 6

Submitted by: Ján Sučan <sucanjan@gmail.com>
MFC after: 2 weeks
Sponsored by: Google, inc. (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21260

4 years agoping: Move in_cksum() to a separate source file
asomers [Sat, 17 Aug 2019 15:25:01 +0000 (15:25 +0000)]
ping: Move in_cksum() to a separate source file

This is a preparation step for adding ATF tests of in_cksum(), which has been
modified to operate on unaligned data. ping.o cannot be linked to the test
executable because both of them contain 'main' symbol.

Submitted by: Ján Sučan <sucanjan@gmail.com>
MFC after: 2 weeks
Sponsored by: Google, inc. (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21288

4 years agoping6: Fix dnsdecode() bug introduced by r350859
asomers [Sat, 17 Aug 2019 14:28:32 +0000 (14:28 +0000)]
ping6: Fix dnsdecode() bug introduced by r350859

Revision 350859 removed level of indirection that was needed for setting the
caller's `cp' pointer. dnsdecode() uses return value to indicate error or
success. It returns pointer to a buffer holding a decompressed DNS name or
NULL. The caller uses that value only to find out the result, not for accessing
the buffer.

We use the return value to propagate the new value of `cp' pointer to
the caller instead of using an output argument.

Submitted by: Ján Sučan <sucanjan@gmail.com>
MFC after: 2 weeks
MFC-With: 350859
Sponsored by: Google, Inc (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21266

4 years agoSDP: Fix brain-o from r351162
cem [Sat, 17 Aug 2019 10:11:34 +0000 (10:11 +0000)]
SDP: Fix brain-o from r351162

Lost in translation between different SDP stacks.

Reported by: hselasky

4 years agozfs_vget: fix vnode reference count leak in error path
avg [Sat, 17 Aug 2019 09:23:03 +0000 (09:23 +0000)]
zfs_vget: fix vnode reference count leak in error path

If vn_lock() failed, then the function returned the error but the vnode
obtained via zfs_zget() was never released.

MFC after: 10 days
Sponsored by: Panzura

4 years agoInclude item position in report descriptor dump in usbhidctl(1).
hselasky [Sat, 17 Aug 2019 08:29:22 +0000 (08:29 +0000)]
Include item position in report descriptor dump in usbhidctl(1).

Submitted by: Kevin Zheng <kevinz5000@gmail.com>
PR: 239918
MFC after: 1 week

4 years agoReduce size of EFI_STAGING_SIZE to 32 on arm
thj [Sat, 17 Aug 2019 06:47:43 +0000 (06:47 +0000)]
Reduce size of EFI_STAGING_SIZE to 32 on arm

Reduce the size of the EFI_STAGING area we allocate on arm to 32. On arm SBC
such as the NanoPi-NEOLTS the staging area allocation will fail on the 256MB
model with a staging size of 64.

Reviewed by:    bcran, manu
Approved by:    bz (mentor)
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D21016

4 years agoAdd basic NAT test for pf, ipf and ipfw
thj [Sat, 17 Aug 2019 06:44:11 +0000 (06:44 +0000)]
Add basic NAT test for pf, ipf and ipfw

Add common firewall NAT tests for pf, ipf and ipfw (using both in-kernel and
userspace NAT).

Submitted by:   Ahsan Barkati
Sponsored by:   Google, Inc. (GSoC 2019)
Reviewed by:    kp
Approved by:    bz (mentor)
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D21199

4 years agoOFED: Fix ib_mad.h ib_user_mad.h include to match new uapi path
cem [Sat, 17 Aug 2019 03:09:03 +0000 (03:09 +0000)]
OFED: Fix ib_mad.h ib_user_mad.h include to match new uapi path

Sponsored by: Dell EMC Isilon

4 years agoSDP: Add a dbg() on QP events
cem [Sat, 17 Aug 2019 03:07:41 +0000 (03:07 +0000)]
SDP: Add a dbg() on QP events

Sponsored by: Dell EMC Isilon

4 years agoSDP: Also log a nice status string in RX WC error dbg()
cem [Sat, 17 Aug 2019 03:06:46 +0000 (03:06 +0000)]
SDP: Also log a nice status string in RX WC error dbg()

Sponsored by: Dell EMC Isilon

4 years agoSDP: Include nice string names for raw event numbers in a dbg()
cem [Sat, 17 Aug 2019 03:05:09 +0000 (03:05 +0000)]
SDP: Include nice string names for raw event numbers in a dbg()

Sponsored by: Dell EMC Isilon

4 years agoSDP: SYSCTL_DECL SDP-wide sysctl node in header
cem [Sat, 17 Aug 2019 03:03:26 +0000 (03:03 +0000)]
SDP: SYSCTL_DECL SDP-wide sysctl node in header

This allows use of the shared _net_inet_sdp in more than one compilation
unit.  (Nothing in-tree uses this today, but some of Isilon's out-of-tree
SDP enhancements add sysctls below the node.)

Sponsored by: Dell EMC Isilon

4 years agoLinuxkpi: Prevent easy generated ctor name conflicts with prefix
cem [Sat, 17 Aug 2019 03:00:58 +0000 (03:00 +0000)]
Linuxkpi: Prevent easy generated ctor name conflicts with prefix

Sponsored by: Dell EMC Isilon

4 years agoFix small bug in wrapping introduced in r325955.
imp [Sat, 17 Aug 2019 02:36:42 +0000 (02:36 +0000)]
Fix small bug in wrapping introduced in r325955.

When local support was fixed, it introduced a minor bug in formatting. We don't
increment the lpos by enouogh, so lines are a little too long. Adjust to be
correct now with variable length srcprefix.

4 years agoAdd nowerror and local to the list of tokens.
imp [Sat, 17 Aug 2019 02:36:37 +0000 (02:36 +0000)]
Add nowerror and local to the list of tokens.

4 years agoMove initializations of config earlier.
imp [Sat, 17 Aug 2019 02:35:53 +0000 (02:35 +0000)]
Move initializations of config earlier.

Inizialize global variables earlier in the process. It doesn't matter today, but
may in the future if we want to access these lists earlier in config's run.

4 years agonet: Update SFF-8024 definitions and strings with values from rev 4.6
erj [Sat, 17 Aug 2019 00:10:56 +0000 (00:10 +0000)]
net: Update SFF-8024 definitions and strings with values from rev 4.6

This will let ifconfig -v's SFF eeprom read functionality recognize more
module types.

Signed-off-by: Eric Joyner <erj@freebsd.org>
Reviewed by: gallatin@
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D21041

4 years agoiflib: add iflib_deregister to help cleanup on exit
erj [Fri, 16 Aug 2019 23:33:44 +0000 (23:33 +0000)]
iflib: add iflib_deregister to help cleanup on exit

Commit message by Jake:
The iflib_register function exists to allocate and setup some common
structures used by both iflib_device_register and iflib_pseudo_register.

There is no associated cleanup function used to undo the steps taken in
this function.

Both iflib_device_deregister and iflib_pseudo_deregister have some of
the necessary steps scattered in their flow. However, most of the
necessary cleanup is not done during the error path of
iflib_device_register and iflib_pseudo_register.

Some examples of missed cleanup include:

the ifp pointer is not free'd during error cleanup
the STATE and CTX locks are not destroyed during error cleanup
the vlan event handlers are not removed during error cleanup
media added to the ifmedia structure is not removed
the kobject reference is never deleted
Additionally, when initializing the kobject class reference counter is
increased even though kobj_init already increases it. This results in
the class never being free'd again because the reference count would
never hit zero even after all driver instances are unloaded.

To aid in proper cleanup, implement an iflib_deregister function that
goes through the reverse steps taken by iflib_register.

Call this function during the error cleanup for iflib_device_register
and iflib_pseudo_register. Additionally call the function in the
iflib_device_deregister and iflib_pseudo_deregister functions near the
end of their flow. This helps reduce code duplication and ensures that
proper steps are taken to cleanup allocations and references in both the
regular and error cleanup flows.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Submitted by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed by: shurd@, erj@
MFC after: 3 days
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D21005

4 years agoRework r339635 to fix .depend.tables.h handling.
bdrewery [Fri, 16 Aug 2019 22:34:10 +0000 (22:34 +0000)]
Rework r339635 to fix .depend.tables.h handling.

Avoid touching the tables.h file unless it has changed to avoid unneeded
rebuilds.

Also revert r350301's explicit dependencies.

Reviewed by: emaste
MFC after: 2 weeks
X-MFC-With: r339635 (kevans request)
PR: 238828
Sponsored by: DellEMC
Differential Revision: https://reviews.freebsd.org/D21295

4 years agoImplement detach_kernel_driver command in usbconfig(8).
hselasky [Fri, 16 Aug 2019 21:17:56 +0000 (21:17 +0000)]
Implement detach_kernel_driver command in usbconfig(8).

Submitted by: Kevin Zheng <kevinz5000@gmail.com>
PR: 239916
MFC after: 1 week

4 years agoarm64: Add EspressoBin DTB to the build
manu [Fri, 16 Aug 2019 21:11:43 +0000 (21:11 +0000)]
arm64: Add EspressoBin DTB to the build

This will compile the espressobin dts to a dtb file and this will be
install in /boot/dtb/marvell/ during installkernel.

MFC after: 1 week

4 years agoDelete sys/dir.h which was deprecated since 1997.
delphij [Fri, 16 Aug 2019 20:53:36 +0000 (20:53 +0000)]
Delete sys/dir.h which was deprecated since 1997.

PR: 21519
Submitted by: Yoshihiro Ota <ota j email ne jp>
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D20479