]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agonewkey(8): fix 'tmpname' memory leak (always) and input file descriptor leak
avos [Fri, 8 Feb 2019 14:31:44 +0000 (14:31 +0000)]
newkey(8): fix 'tmpname' memory leak (always) and input file descriptor leak
when output file cannot be opened

PR: 201732
Reported by: David Binderman <dcb314@hotmail.com>
MFC after: 1 week

5 years agoFix several Coverity-detected issues in newsyslog.
dab [Fri, 8 Feb 2019 13:54:16 +0000 (13:54 +0000)]
Fix several Coverity-detected issues in newsyslog.

- CID 1394815, CID 1305673: Dereference before null check - memory was
  allocated and the allocation checked for NULL with a call to errx()
  if it failed. Code below that was guaranteed that the pointer was
  non-NULL, but there was another check for NULL at the exit of the
  function (after the memory had already been referenced). Eliminate
  the useless NULL check.

- CID 1007454, CID 1007453: Resource leak - The result of a strdup()
  was stored in a global variable and not freed before program exit.

- CID 1007452: Resource leak - Storage intended to be allocated and
  returned to the caller was never freed. This was the result of a
  regression in the function signature introduced in r208648 (2010)
  (thanks for that find, @cem!). Fixed by altering the function
  signature and passing the allocated memory to the caller as
  intended. This also fixes PR158794.

- CID 1008620: Logically dead code in newsyslog.c - This was a direct
  result of CID 1007452. Since the memory allocated as described there
  was not returned to the caller, a subsequent check for the memory
  having been allocated was dead code. Returning the memory
  re-animates the code that is the subject of this CID.

- CID 1006131: Unused value - in parsing a configuration file, a
  pointer to the end of the last field was saved, but not used after
  that. Rewrite to use the pointer value. This could have been fixed
  by avoiding the assignment altogether, but this solutions more
  closely follows the pattern used in the preceding code.

PR: 158794
Reported by: Coverity, Ken-ichi EZURA <k.ezura@gmail.com> (PR158794)
Reviewed by: cem, markj
MFC after: 1 week
Sponsored by: Dell EMC Isilon

5 years agoImprove Bluetooth device discovery support for Android and Microsoft devices.
hselasky [Fri, 8 Feb 2019 13:10:45 +0000 (13:10 +0000)]
Improve Bluetooth device discovery support for Android and Microsoft devices.

Tested using the virtual_bt_speaker(8) tool from the virtual_oss(8)
project at github.com.

PR: 210089
MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agoAdd macOS 10.14.
pluknet [Fri, 8 Feb 2019 11:49:59 +0000 (11:49 +0000)]
Add macOS 10.14.

5 years agoUn null_vptocnp(), cache vp->v_mount and use it for null_nodeget() call.
kib [Fri, 8 Feb 2019 08:20:18 +0000 (08:20 +0000)]
Un null_vptocnp(), cache vp->v_mount and use it for null_nodeget() call.

The vp vnode is unlocked during the execution of the VOP method and
can be reclaimed, zeroing vp->v_data.  Caching allows to use the
correct mount point.

Reported and tested by: pho
PR: 235549
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoBefore using VTONULL(), check that the covered vnode belongs to nullfs.
kib [Fri, 8 Feb 2019 08:17:31 +0000 (08:17 +0000)]
Before using VTONULL(), check that the covered vnode belongs to nullfs.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoSome style for nullfs_mount(). Also use bool type for isvnunlocked.
kib [Fri, 8 Feb 2019 08:15:29 +0000 (08:15 +0000)]
Some style for nullfs_mount().  Also use bool type for isvnunlocked.

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoCorrectly return exit status from the exited process.
kib [Fri, 8 Feb 2019 07:36:08 +0000 (07:36 +0000)]
Correctly return exit status from the exited process.

This is also OpenBSD rev. 1.117, as pointed out by
Ryan Moeller <ryan@ixsystems.com>.

Submitted by: Nash Kaminski <nashkaminski@gmail.com>
MFC after: 1 week

5 years agoAllow some nesting of ng_iface(4) interfaces and add a configuration knob.
glebius [Fri, 8 Feb 2019 06:19:28 +0000 (06:19 +0000)]
Allow some nesting of ng_iface(4) interfaces and add a configuration knob.

PR: 235500
MFC after: 1 week

5 years agoFix renameat(2) for CAPABILITIES kernels.
kib [Fri, 8 Feb 2019 04:18:17 +0000 (04:18 +0000)]
Fix renameat(2) for CAPABILITIES kernels.

When renameat(2) is used with:
- absolute path for to;
- tofd not set to AT_FDCWD;
- the target exists
kern_renameat() requires CAP_UNLINK capability on tofd, but
corresponding namei ni_filecap is not initialized at all because the
lookup is absolute.  As result, the check was done against empty filecap
and syscall fails erronously.

Fix it by creating a return flags namei member and reporting if the
lookup was absolute, then do not touch to.ni_filecaps at all.

PR: 222258
Reviewed by: jilles, ngie
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-MFC-note: KBI breakage
Differential revision: https://reviews.freebsd.org/D19096

5 years agodo_execve(): lock vnode when needed.
kib [Fri, 8 Feb 2019 04:06:48 +0000 (04:06 +0000)]
do_execve(): lock vnode when needed.

Code after exec_fail_dealloc label expects that the image vnode is
locked if present.  When copyout() of the strings or auxv vectors fails,
goto to the error handling did not relocked the vnode as required.

The copyout() can be made failing e.g. by creating an ELF image with
PT_GNU_STACK segment disabling the write.

Reported by: Jonathan Stuart <n0t.jcs@gmail.com> (found by fuzzing)
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

5 years agocxgbev(4): Initialize debug_flags from the environment like in the PF driver.
np [Fri, 8 Feb 2019 03:31:38 +0000 (03:31 +0000)]
cxgbev(4): Initialize debug_flags from the environment like in the PF driver.

5 years agoGC a historical artifact.
brooks [Thu, 7 Feb 2019 23:17:44 +0000 (23:17 +0000)]
GC a historical artifact.

Back in 1993, the fgetln (then fgetline) interface was changed to not
return a C string.  The change was accomplished by ifdefing out the code
that did the termination.  Changing the interface would violate our API
stability rules so remove the old implementation.

Sponsored by: DARPA, AFRL

5 years agor343881 had an uninitialized error. This fixes that.
sef [Thu, 7 Feb 2019 22:10:20 +0000 (22:10 +0000)]
r343881 had an uninitialized error.  This fixes that.

PR:             233849
Reported by:    Andre Albsmeier
MFC after:      1 month
Sponsored by:   iXsystems Inc
Differential Revision:  https://reviews.freebsd.org/D18785

5 years agor339008 broke repquota for UFS. This rectifies that.
sef [Thu, 7 Feb 2019 21:51:39 +0000 (21:51 +0000)]
r339008 broke repquota for UFS.  This rectifies that.

Refactor the function calls and tests so that, on UFS, the proper fields
are filled out.

PR: 233849
Reported by: Andre Albsmeier
Reviewed by: mav, delphij
MFC after: 1 month
Sponsored by: iXsystems Inc
Differential Revision: https://reviews.freebsd.org/D18785

5 years agoFix build of r343877
bdrewery [Thu, 7 Feb 2019 21:41:27 +0000 (21:41 +0000)]
Fix build of r343877

MFC after: 2 weeks
X-MFC-with: r343877
Pointyhat to: bdrewery

5 years agoipfw table list: Fix showing header outside of 'all'.
bdrewery [Thu, 7 Feb 2019 21:05:44 +0000 (21:05 +0000)]
ipfw table list: Fix showing header outside of 'all'.

Properly pass down is_all to table_show_list().  This restores the behavior
before r272840 so that only 'ipfw table all list' shows the headers.

MFC after: 2 weeks
Relnotes: yes

5 years agoAdd missing data barriers after storeing a new valid pagetable entry.
andrew [Thu, 7 Feb 2019 20:58:45 +0000 (20:58 +0000)]
Add missing data barriers after storeing a new valid pagetable entry.

When moving from an invalid to a valid entry we don't need to invalidate
the tlb, however we do need to ensure the store is ordered before later
memory accesses. This is because this later access may be to a virtual
address within the newly mapped region.

Add the needed barriers to places where we don't later invalidate the
tlb. When we do invalidate the tlb there will be a barrier to correctly
order this.

This fixes a panic on boot on ThunderX2 when INVARIANTS is turned off:
panic: vm_fault_hold: fault on nofault entry, addr: 0xffff000040c11000

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

5 years agoAdd a missing data barrier to the start of arm64_tlb_flushID.
andrew [Thu, 7 Feb 2019 20:50:39 +0000 (20:50 +0000)]
Add a missing data barrier to the start of arm64_tlb_flushID.

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

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

5 years agomtree: Add dtb subdir to the mtree file
manu [Thu, 7 Feb 2019 18:54:25 +0000 (18:54 +0000)]
mtree: Add dtb subdir to the mtree file

makefs will fails otherwise

Reported by: emaste
MFC after: 1 week

5 years agoarm64: dtb: allwinner: Add the new pine64-lts dtb file to the build
manu [Thu, 7 Feb 2019 18:07:17 +0000 (18:07 +0000)]
arm64: dtb: allwinner: Add the new pine64-lts dtb file to the build

MFC after: 1 month
X-MFC-With: r342936

5 years ago[ppc64] fix /dev/kmem
luporl [Thu, 7 Feb 2019 17:30:44 +0000 (17:30 +0000)]
[ppc64] fix /dev/kmem

For direct mapped kernel addresses, ppc64 function was not
performing the dmap to physical conversion, before jumping
to the code that fetched the value from physical memory.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D19086

5 years agorecoverdisk(1): fclose() file supplied via '-r readlist' parameter when
avos [Thu, 7 Feb 2019 14:40:28 +0000 (14:40 +0000)]
recoverdisk(1): fclose() file supplied via '-r readlist' parameter when
it's no longer needed

PR: 204952
Reported by: David Binderman <dcb314@hotmail.com>
MFC after: 5 days

5 years agoipcs(1): drop obsolete error checking
avos [Thu, 7 Feb 2019 14:29:45 +0000 (14:29 +0000)]
ipcs(1): drop obsolete error checking

This code is not reached since r77551.

PR: 201728
MFC after: 5 days

5 years agoMention clang-format in WITH_CLANG_EXTRAS
emaste [Thu, 7 Feb 2019 14:05:21 +0000 (14:05 +0000)]
Mention clang-format in WITH_CLANG_EXTRAS

It's a useful tool and gives a further hint at the types of additional
binaries enabled by the option.

5 years agoCorrect ypldap(8) install path in OptionalObsoleteFiles.inc
avos [Thu, 7 Feb 2019 13:12:43 +0000 (13:12 +0000)]
Correct ypldap(8) install path in OptionalObsoleteFiles.inc

It's installed to /usr/sbin, not to /usr/bin (and was always here).

While here, add missing manpages and /var/yp directory to the list.

MFC after: 1 week

5 years agonetmap: revert netmap_attach_ext() to pre-r343772
vmaffione [Thu, 7 Feb 2019 11:28:53 +0000 (11:28 +0000)]
netmap: revert netmap_attach_ext() to pre-r343772

Reported by: marius
MFC after: 1 week

5 years agocxgbe(4): Auto-dump the CIM block's logic analyzer on a TIMER0 interrupt.
np [Thu, 7 Feb 2019 05:40:51 +0000 (05:40 +0000)]
cxgbe(4): Auto-dump the CIM block's logic analyzer on a TIMER0 interrupt.

Sponsored by: Chelsio Communications

5 years agocxgbe(4): Auto-dump the device log on a mailbox timeout or when the
np [Thu, 7 Feb 2019 05:06:29 +0000 (05:06 +0000)]
cxgbe(4): Auto-dump the device log on a mailbox timeout or when the
firmware reports an error in pcie_fw.

Sponsored by: Chelsio Communications

5 years agopci_host_generic_acpi: use IORT data for MSI/MSI-X
jchandra [Thu, 7 Feb 2019 04:50:16 +0000 (04:50 +0000)]
pci_host_generic_acpi: use IORT data for MSI/MSI-X

Use the information from IORT parsing to translate the PCI RID to
GIC ITS device ID. And similarly, use the information to find the
PIC XREF identifier to be used for PCI devices.

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

5 years agoAdd comment noting that the strange spelling of GenuineIntel is for reason.
kib [Thu, 7 Feb 2019 03:58:29 +0000 (03:58 +0000)]
Add comment noting that the strange spelling of GenuineIntel is for reason.

Requested by: rpokala
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoNow that there is only one way to allocate a slab, remove uz_slab method.
glebius [Thu, 7 Feb 2019 03:55:05 +0000 (03:55 +0000)]
Now that there is only one way to allocate a slab, remove uz_slab method.

Discussed with: jeff

5 years agoReport cache zones in UMA stats sysctl, that 'vmstat -z' uses. This
glebius [Thu, 7 Feb 2019 03:32:45 +0000 (03:32 +0000)]
Report cache zones in UMA stats sysctl, that 'vmstat -z' uses. This
should had been part of r251826.

5 years agoarm64 gicv3: add IORT and NUMA support
jchandra [Thu, 7 Feb 2019 03:01:54 +0000 (03:01 +0000)]
arm64 gicv3: add IORT and NUMA support

acpi_iort.c has added support to query GIC proximity and MSI XREF
ID for GIC ITS blocks. Use this when GIC ITS blocks are initialized
from ACPI.

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

5 years agoUse ifunc to select the barrier instruction for RDTSC.
kib [Thu, 7 Feb 2019 02:56:10 +0000 (02:56 +0000)]
Use ifunc to select the barrier instruction for RDTSC.

This optimizes out runtime switch and removes yet another cpuid from
libc.

Note that this is the first use of ifunc in i386 libc, so
ifunc-capable toolchain is required for building runnable userspace on
i386, same as on amd64.

Discussed with: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoarm64 acpi: Add support for IORT table
jchandra [Thu, 7 Feb 2019 02:30:33 +0000 (02:30 +0000)]
arm64 acpi: Add support for IORT table

Add new file arm64/acpica/acpi_iort.c to support the "IO Remapping
Table" (IORT). The table is specified in ARM document "ARM DEN 0049D"
titled "IO Remapping Table Platform Design Document".  The IORT table
has information on the associations between PCI root complexes, SMMU
blocks and GIC ITS blocks in the system.

The changes are to parse and save the information in the IORT table.
The API to use this information is added to sys/dev/acpica/acpivar.h.

The acpi_iort.c also has code to check the GIC ITS nodes seen in the
IORT table with corresponding entries in MADT table (for validity)
and with entries in SRAT table (for proximity information).

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

5 years agoPort sysctl kern.elf32.read_exec from amd64 to i386.
kib [Thu, 7 Feb 2019 02:17:34 +0000 (02:17 +0000)]
Port sysctl kern.elf32.read_exec from amd64 to i386.

Make it more comprehensive on i386, by not setting nx bit for any
mapping, not just adding PF_X to all kernel-loaded ELF segments.  This
is needed for the compatibility with older i386 programs that assume
that read access implies exec, e.g. old X servers with hand-rolled
module loader.

Reported and tested by: bde
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoFix resume on i386 PAE.
kib [Thu, 7 Feb 2019 02:09:34 +0000 (02:09 +0000)]
Fix resume on i386 PAE.

It was broken before PAE/no-PAE merge, but since now PAE is the
default, resume is apparently becomes for all machines.

The corrected issues:
- the trampoline page is not mapped executable, so machine faults when
  paging is on;
- MSR.EFER and %cr4 both should be loaded before paging is enabled,
  otherwise paging structures are invalid (cr4.PAE and EFER.NX).
- MSR.EFER and %cr4 should be only loaded if present.  I attempt to handle
  this by not touching the registers if the value is zero.

There are some more bits still not quite correct, e.g. unconditional
access to %cr4 in resumectx.

Reported and debugging help by: bde
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agocontigmalloc: handle M_EXEC.
kib [Thu, 7 Feb 2019 02:00:23 +0000 (02:00 +0000)]
contigmalloc: handle M_EXEC.

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

5 years agoClean up all directories created by `make hier`
ngie [Wed, 6 Feb 2019 21:24:44 +0000 (21:24 +0000)]
Clean up all directories created by `make hier`

The logic I introduced in r322511 unfortunately left chflags schg'ed
directories behind created by `make hier` (in the stock /etc/mtree
files, this is limited to /var/empty).

The proposed change calls `chflags -R 0` and `rm -Rf ...` to clean all
of the directories that could not be removed by `${MAKE} clean`.
`${MAKE} clean` in bsd.obj.mk calls `cleandir`/`cleanobj`, which handles
the first directory tree walk/removal.

Approved by: emaste (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D18641

5 years agoSupport the Lenovo OneLink in ure(4).
gavin [Wed, 6 Feb 2019 20:18:22 +0000 (20:18 +0000)]
Support the Lenovo OneLink in ure(4).

MFC after: 1 week

5 years agoriscv: default to non-executable stack
emaste [Wed, 6 Feb 2019 19:22:15 +0000 (19:22 +0000)]
riscv: default to non-executable stack

There's no need to worry about potential backwards compatibility issues
in a brand-new architecture, so avoid stack PROT_EXEC as with arm64.

Discussed with: br

5 years agovtfontcvt: whitespace cleanup
emaste [Wed, 6 Feb 2019 18:50:48 +0000 (18:50 +0000)]
vtfontcvt: whitespace cleanup

PR: 205707
Submitted by: Dmitry Wagin

5 years agoRetire SPX_HACK option unused after r342244
emaste [Wed, 6 Feb 2019 17:21:25 +0000 (17:21 +0000)]
Retire SPX_HACK option unused after r342244

5 years agoRetire CTM option after r342126
emaste [Wed, 6 Feb 2019 16:30:08 +0000 (16:30 +0000)]
Retire CTM option after r342126

5 years agonet80211(4): validate supplied roam:rate values from ifconfig(8)
avos [Wed, 6 Feb 2019 13:01:21 +0000 (13:01 +0000)]
net80211(4): validate supplied roam:rate values from ifconfig(8)

MFC after: 4 days

5 years agoAdapt FreeBSD specific DT stub for Jetson TK1 board to be consistent with
mmel [Wed, 6 Feb 2019 06:03:44 +0000 (06:03 +0000)]
Adapt FreeBSD specific DT stub for Jetson TK1 board to be consistent with
update of devicetree to 4.19 in r340337.
Our build system doesn't provide dependencies for included DTS files, so
nobody noticed this issue for long time.

PR: 235362
MFC after: 1 week

5 years agor341692 changed cap_syslog(3) to preserve the stdio descriptors inherited
jah [Wed, 6 Feb 2019 04:36:28 +0000 (04:36 +0000)]
r341692 changed cap_syslog(3) to preserve the stdio descriptors inherited
from its parent so that LOG_PERROR would work.  However, this caused
dhclient(8)'s stdio streams to remain open across daemonization, breaking
the ability to capture its foreground output as done in netconfig_ipv4.

Fix this by reverting r341692 and instead passing the parent's stderr
descriptor as an argument to cap_openlog() only when LOG_PERROR is specified
in logopt.

PR: 234514
Suggested by: markj
Reported by: Shawn Webb
Reviewed by: markj, oshogbo
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D18989

5 years agopwm.8: fix markup in synopsis, add -f description
yuripv [Wed, 6 Feb 2019 04:00:37 +0000 (04:00 +0000)]
pwm.8: fix markup in synopsis, add -f description

Reviewed by: bcr, manu
Differential revision: https://reviews.freebsd.org/D18829

5 years agopwm.9: fix markup in interfaces description
yuripv [Wed, 6 Feb 2019 03:57:51 +0000 (03:57 +0000)]
pwm.9: fix markup in interfaces description

Reviewed by: manu
Differential revision: https://reviews.freebsd.org/D18830

5 years agopowerpc: Bind IRQs to only one interrupt on QorIQ SoCs
jhibbits [Wed, 6 Feb 2019 03:52:14 +0000 (03:52 +0000)]
powerpc: Bind IRQs to only one interrupt on QorIQ SoCs

The QorIQ SoCs don't actually support multicast interrupts, and the
references state explicitly that multicast is undefined behavior.  Avoid the
undefined behavior by binding to only a single CPU, using a quirk to
determine if this is necessary.

MFC after: 3 weeks

5 years agoiwn(4): plug initialization path vs interrupt handler races
avos [Wed, 6 Feb 2019 01:34:14 +0000 (01:34 +0000)]
iwn(4): plug initialization path vs interrupt handler races

There are few places in interrupt handler where the driver
lock is dropped; ensure that device is still running before
processing remaining ring entries.

PR: 192641
MFC after: 5 days

5 years agoAdd quirk for Sansisk X400 drives
imp [Tue, 5 Feb 2019 22:53:36 +0000 (22:53 +0000)]
Add quirk for Sansisk X400 drives

Certain versions of Sandisk x400 firmware can hang under extremely
heavly load of large I/Os for prolonged periods of time. Newer /
current versions work fine, and should be used where possible. Where
not possible, this quirk ensures that I/O requests are limited to 128k
to avoids the bug, even under extreme load. Since MAXPHYS is 128k,
only users with custom kernels are at risk on the older firmware.
Once all known users of the older firmware have upgraded, this quirk
will be removed.

Sponsored by: Netflix, Inc.

5 years agoRemove obsolete controller
imp [Tue, 5 Feb 2019 21:37:45 +0000 (21:37 +0000)]
Remove obsolete controller

We removed support for the super-old samsung s3xxxx parts, but this is
a straggler. Remove it too.

5 years agoRemove All Rights Reserved
imp [Tue, 5 Feb 2019 21:37:34 +0000 (21:37 +0000)]
Remove All Rights Reserved

Remove the all rights reserved clause from my copyright, and make
other minor tweaks needed where that might have created ambiguity.

5 years agoRemove a few stray "All Rights Reserved." declarations on stuff I've
imp [Tue, 5 Feb 2019 21:28:29 +0000 (21:28 +0000)]
Remove a few stray "All Rights Reserved." declarations on stuff I've
written.

5 years agoMake it possible to override PAE mode on boot.
kib [Tue, 5 Feb 2019 20:09:31 +0000 (20:09 +0000)]
Make it possible to override PAE mode on boot.

Initialize the static kenv in pmap_cold() and fetch user opinion on
vm.pmap.pae_mode tunable if hardware is capable.  Note that the static
environment is reinitilized in init386() later when paging is enabled.

Reviewed by: bde
Discussed with: kevans
Sponsored by: The FreeBSD Foundation
MFC after: 2 months

5 years agoRemove pointless initial value for i386 vm.pmap.pat_works sysctl definition.
kib [Tue, 5 Feb 2019 20:02:16 +0000 (20:02 +0000)]
Remove pointless initial value for i386 vm.pmap.pat_works sysctl definition.

The OID is served by external data.

Submitted by: bde
MFC after: 3 days

5 years ago[ppc64] llan: fix fatal kernel trap when system is low on memory
luporl [Tue, 5 Feb 2019 18:16:14 +0000 (18:16 +0000)]
[ppc64] llan: fix fatal kernel trap when system is low on memory

When running several builders in parallel, on QEMU, with 8GB of
memory, a fatal kernel trap (0x300 (data storage interrupt))
caused by llan driver is sometimes observed, when the system
starts to run out of swap space.

This happens because, at llan_intr(), a phyp call to add a
logical LAN buffer is always made when llan_add_rxbuf() fails,
even if it fails to allocate a new buffer.

PR: 235489
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D19084

5 years agoAvoid leaking fp references when truncating SCM_RIGHTS control messages.
markj [Tue, 5 Feb 2019 17:55:08 +0000 (17:55 +0000)]
Avoid leaking fp references when truncating SCM_RIGHTS control messages.

Reported by: pho
Approved by: so
MFC after: 0 minutes
Security: CVE-2019-5596
Sponsored by: The FreeBSD Foundation

5 years agoamd64: clear callee-preserved registers on syscall exit.
kib [Tue, 5 Feb 2019 17:49:27 +0000 (17:49 +0000)]
amd64: clear callee-preserved registers on syscall exit.

%r8, %r10, and on non-KPTI configuration %r9 were not restored on fast
return from a syscall.

Reviewed by: markj
Approved by: so
Security: CVE-2019-5595
Sponsored by: The FreeBSD Foundation
MFC after: 0 minutes

5 years agoFix missing translation of old ioctls for KDSETMODE, KDSBORDER and
bde [Tue, 5 Feb 2019 17:17:12 +0000 (17:17 +0000)]
Fix missing translation of old ioctls for KDSETMODE, KDSBORDER and
CONS_SETWINORG.  After translation, the last 2 are not supported, but
the first one has incomplete support that is enough to run old versions
of X.

5 years agoMy recent fix for programmable function keys in syscons only worked
bde [Tue, 5 Feb 2019 16:59:29 +0000 (16:59 +0000)]
My recent fix for programmable function keys in syscons only worked
when TEKEN_CONS25 is configured.  Fix this by adding a function to
set the flag that enables the fix and always calling this function
for syscons.

Expand the man page for teken_set_cons25().  This function is not
very useful since it can only set but not clear 1 flag.  In practice,
it is only used when TEKEN_CONS25 is configured and all that does is
choose the the default emulation for syscons at compile time.

5 years agoFix zapping of static hints and env in init_static_kenv(). Environments
bde [Tue, 5 Feb 2019 15:34:55 +0000 (15:34 +0000)]
Fix zapping of static hints and env in init_static_kenv().  Environments
are terminated by 2 NULs, but only 1 NUL was zapped.  Zapping only 1
NUL just splits the first string into an empty string and a corrupted
string.  All other strings in static hints and env remained live early
in the boot when they were supposed to be disabled.

Support calling init_static_kenv() very early in the boot, so as to
use the env very early in the boot.  Then the pointer to the loader
env may change after the first call due to enabling paging or otherwise
remapping the pointer.  Another call is needed to register the change.
Don't use the previous pointer in this (or any) later call.

Reviewed by: kib

5 years agonetmap: refactor logging macros and pipes
vmaffione [Tue, 5 Feb 2019 12:10:48 +0000 (12:10 +0000)]
netmap: refactor logging macros and pipes

Changelist:
    - Replace ND, D and RD macros with nm_prdis, nm_prinf, nm_prerr
      and nm_prlim, to avoid possible naming conflicts.
    - Add netmap_krings_mode_commit() helper function and use that
      to reduce code duplication.
    - Refactor pipes control code to export some functions that
      can be reused by the veth driver (on Linux) and epair(4).
    - Add check to reject API requests with version less than 11.
    - Small code refactoring for the null adapter.

MFC after: 1 week

5 years agoOnly reduce the PMTU after the send call. The only way to increase it, is
tuexen [Tue, 5 Feb 2019 10:29:31 +0000 (10:29 +0000)]
Only reduce the PMTU after the send call. The only way to increase it, is
via PMTUD.

This fixes an MTU issue reported by Timo Voelker.

MFC after: 3 days

5 years agoFix an off-by-one error in the input validation of the SCTP_RESET_STREAMS
tuexen [Tue, 5 Feb 2019 10:13:51 +0000 (10:13 +0000)]
Fix an off-by-one error in the input validation of the SCTP_RESET_STREAMS
socketoption.

This was found by running syzkaller.

MFC after: 3 days

5 years agoarm, acpi: increase size of memory region arrays
jchandra [Tue, 5 Feb 2019 06:25:35 +0000 (06:25 +0000)]
arm, acpi: increase size of memory region arrays

Bump up MAX_HWCNT and MAX_EXCNT to 32 when ACPI is enabled. These are
the sizes of the hwregions and exregions arrays respectively. ACPI
firmware typically has more memory regions and the current value of
16 is not sufficient for some platforms.

This commit fixes a failure seen with AMI firmware on Cavium's Sabre
ThunderX2 reference platform. This platform needs 21 physical memory
regions and 18 excluded regions to boot correctly with the current
firmware release.

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

5 years agopowerpc: Don't idle with the wait instruction on booke
jhibbits [Tue, 5 Feb 2019 04:47:41 +0000 (04:47 +0000)]
powerpc: Don't idle with the wait instruction on booke

It appears idling via 'wait' on e5500 causes strange behaviors, such as
top(1) simply hanging sporadically, until input.  Until this can possibly be
sorted out (interrupt issue?), just don't idle on this hardware.  The SoCs
are low power already, and the wait state doesn't save much anyway.

5 years agoextattr_list_vp: Narrow locked section somewhat
cem [Tue, 5 Feb 2019 04:47:21 +0000 (04:47 +0000)]
extattr_list_vp: Narrow locked section somewhat

Suggested by: mjg
Reviewed by: kib, mjg
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19083

5 years agoextattr_list_vp: Only take shared vnode lock
cem [Tue, 5 Feb 2019 03:32:58 +0000 (03:32 +0000)]
extattr_list_vp: Only take shared vnode lock

List is a 'read'-type operation that does not modify shared state; it's safe
for multiple thread to proceed concurrently.  This is reflected in the vnode
operation LISTEXTATTR locking protocol specification, which only requires a
shared lock.

(Similar to previous r248933.)

Reported by: Case van Rij <case.vanrij AT isilon.com>
Reviewed by: kib, mjg
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19082

5 years agoFix deterministic builds by sorting input to fts in jevents
mmacy [Tue, 5 Feb 2019 00:31:25 +0000 (00:31 +0000)]
Fix deterministic builds by sorting input to fts in jevents

Reported by: emaste@

5 years agoUpdate CPUID bits definitions and CPU identification based on changes
kib [Mon, 4 Feb 2019 23:57:59 +0000 (23:57 +0000)]
Update CPUID bits definitions and CPU identification based on changes
in SDM rev. 069.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

5 years agoRegularize the Netflix copyright
imp [Mon, 4 Feb 2019 21:28:25 +0000 (21:28 +0000)]
Regularize the Netflix copyright

Use recent best practices for Copyright form at the top of
the license:
1. Remove all the All Rights Reserved clauses on our stuff. Where we
   piggybacked others, use a separate line to make things clear.
2. Use "Netflix, Inc." everywhere.
3. Use a single line for the copyright for grep friendliness.
4. Use date ranges in all places for our stuff.

Approved by: Netflix Legal (who gave me the form), adrian@ (pmc files)

5 years agoFixes for very early use of the pthread_mutex_* and libthr malloc.
kib [Mon, 4 Feb 2019 21:16:15 +0000 (21:16 +0000)]
Fixes for very early use of the pthread_mutex_* and libthr malloc.

When libthr is statically linked into the binary, order of the
constructors execution is not deterministic.  It is possible for the
application constructor to use pthread_mutex_* functions before the
libthr initialization was done.

Handle it by:
- making thr_malloc.c locking functions operational when curthread is not
  yet set;
- making __thr_malloc_init() idempotent, allowing more than one call to it;
- unconditionally calling __thr_malloc_init() before initializing
  a process-private mutex.

Reported and tested by: mmel
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoo As illustrated by e. g. figure 7-14 of the Intel 82599 10 GbE
marius [Mon, 4 Feb 2019 20:46:57 +0000 (20:46 +0000)]
o As illustrated by e. g. figure 7-14 of the Intel 82599 10 GbE
  controller datasheet revision 3.3, in the context of Ethernet
  MACs the control data describing the packet buffers typically
  are named "descriptors". Each of these descriptors references
  one buffer, multiple of which a packet can be composed of.
  By contrast, in comments, messages and the names of structure
  members, iflib(4) refers to DMA resources employed for RX and
  TX buffers (rather than control data) as "desc(riptors)".
  This odd naming convention of iflib(4) made reviewing r343085
  and identifying wrong and missing bus_dmamap_sync(9) calls in
  particular way harder than it already is. This convention may
  also explain why the netmap(4) part of iflib(4) pairs the DMA
  tags for control data with DMA maps of buffers and vice versa
  in calls to bus_dma(9) functions.
  Therefore, change iflib(4) to refer to buf(fers) when buffers
  and not the usual understanding of descriptors is meant. This
  change does not include corrections to the DMA resources used
  in the netmap(4) parts. However, it revises error messages to
  state which kind of allocation/creation failed. Specifically,
  the "Unable to allocate tx_buffer (map) memory" copy & pasted
  inappropriately on several occasions was replaced with proper
  messages.
o Enhance some other error messages to indicate which half - RX
  or TX - they apply to instead of using identical text in both
  cases and generally canonicalize them.
o Correct the descriptions of iflib_{r,t}xsd_alloc() to reflect
  reality; current code doesn't use {r,t}x_buffer structures.
o In iflib_queues_alloc():
  - Remove redundant BUS_DMA_NOWAIT of iflib_dma_alloc() calls,
  - change the M_WAITOK from malloc(9) calls into M_NOWAIT. The
    return values are already checked, deferred DMA allocations
    not being an option at this point, BUS_DMA_NOWAIT has to be
    used anyway and prior malloc(9) calls in this function also
    specify M_NOWAIT.

Reviewed by: shurd
Differential Revision: https://reviews.freebsd.org/D19067

5 years agos/Maximal/Maximum/ in sysctl description.
mav [Mon, 4 Feb 2019 20:09:22 +0000 (20:09 +0000)]
s/Maximal/Maximum/ in sysctl description.

Submitted by: smh
MFC after: 1 week

5 years agoAvoid the DNS lookup for "localhost"
ngie [Mon, 4 Feb 2019 19:12:45 +0000 (19:12 +0000)]
Avoid the DNS lookup for "localhost"

ci.FreeBSD.org does not have access to a DNS resolver/network (unlike my test
VM), so in order for the test to pass on the host, it needs to avoid the DNS
lookup by using the numeric host address representation.

PR: 235200
Reviewed by: asomers, lwhsu
Approved by: emaste (mentor)
MFC after: 2 weeks
MFC with: r343362, r343365, r343367-r343368, r343461
Differential Revision: https://reviews.freebsd.org/D19026

5 years agorelease: arm64: pine64-lts: Use the newly created u-boot-pine64-lts port
manu [Mon, 4 Feb 2019 18:30:47 +0000 (18:30 +0000)]
release: arm64: pine64-lts: Use the newly created u-boot-pine64-lts port

In U-Boot 2019.01 there is now a config for this board, use it for the
release image.

MFC after: 1 week

5 years agorelease: arm64: rpi3: Install the RPI3B+ DTB file
manu [Mon, 4 Feb 2019 18:29:23 +0000 (18:29 +0000)]
release: arm64: rpi3: Install the RPI3B+ DTB file

We should use the correct DTB file otherwise the firmware uses
the RPI3B one.

MFC after: 1 week

5 years agoUse NLDT to get number of LDTs on i386
dim [Mon, 4 Feb 2019 18:07:03 +0000 (18:07 +0000)]
Use NLDT to get number of LDTs on i386

Compiling a GENERIC kernel for i386 with clang 8.0 results in the
following warning:

/usr/src/sys/i386/i386/sys_machdep.c:542:40: error: 'sizeof ((ldt))' will return the size of the pointer, not the array itself [-Werror,-Wsizeof-pointer-div]
        nldt = pldt != NULL ? pldt->ldt_len : nitems(ldt);
                                              ^~~~~~~~~~~
/usr/src/sys/sys/param.h:299:32: note: expanded from macro 'nitems'
#define nitems(x)       (sizeof((x)) / sizeof((x)[0]))
                         ~~~~~~~~~~~ ^

Indeed, 'ldt' is declared as 'union descriptor *', so nitems() is not
the right way to determine the number of LDTs.  Instead, the NLDT define
from sys/x86/include/segments.h should be used.

Reviewed by: kib
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D19074

5 years agoOnly enable trace-cmp on Clang and modern GCC.
andrew [Mon, 4 Feb 2019 16:55:24 +0000 (16:55 +0000)]
Only enable trace-cmp on Clang and modern GCC.

It's was only added to GCC 8.1 so don't try to enable it for earlier
releases.

Reported by: lwhsu
Sponsored by: DARPA, AFRL

5 years agoAdd missed tunables/sysctls for some new vdev variables.
mav [Mon, 4 Feb 2019 16:13:41 +0000 (16:13 +0000)]
Add missed tunables/sysctls for some new vdev variables.

While there, make few existing sysctls writeable, since there is no reason
not to.

MFC after: 1 week

5 years agopowerpc64: Add a trap stack area
luporl [Mon, 4 Feb 2019 16:02:03 +0000 (16:02 +0000)]
powerpc64: Add a trap stack area

Currently, the trap code switches to the the temporary stack in the dbtrap
section. It works in most cases, but in the beginning of the execution, the
temp stack is being used, as starting in the powerpc_init() code.

In this current scenario, the stack is being overwritten, which causes the
return of breakpoint() to take abnormal execution.

This current patchset create a small stack to use by the dbtrap: codepath
avoiding the corruption of the temporary stack.

PR: 224872
Submitted by: breno.leitao_gmail.com
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D14484

5 years agoAdd missing SCTP_EOR entry.
tuexen [Mon, 4 Feb 2019 13:30:47 +0000 (13:30 +0000)]
Add missing SCTP_EOR entry.

MFC after: 3 days

5 years agoRemove two more #ifdefs missed in r343701.
cy [Mon, 4 Feb 2019 05:37:16 +0000 (05:37 +0000)]
Remove two more #ifdefs missed in r343701.

MFC after: 1 month
X-MFC with: r343701

5 years agoAdd support for the authinfo map
gshapiro [Mon, 4 Feb 2019 02:18:27 +0000 (02:18 +0000)]
Add support for the authinfo map

Submitted by: keramida

5 years agoCheck element type before setting LEDs.
mav [Mon, 4 Feb 2019 01:24:10 +0000 (01:24 +0000)]
Check element type before setting LEDs.

With r319610, sesutil started twiddling the bits of every SES device.
Not everything is a disk slot, there are also fan controllers, temperature
sensors, even power supplies, among other things controlled by SES.

Add a type check to make sure we are only operating on device slot and array
device slot elements.  Other type elements will be skipped, but it would be
simple to add additional cases for controlling the ident LEDs of other
element types (which are not necessarily the same bits).

Rather than doing raw bit manipulation of an unstructured byte array using
unnamed numeric constants, leverage existing code abstractions.

Submitted by: Ryan Moeller <ryan@freqlabs.com>
MFC after: 1 week
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D19052

5 years agoUse switch instead of chained if/else to improve readability.
mav [Mon, 4 Feb 2019 01:20:56 +0000 (01:20 +0000)]
Use switch instead of chained if/else to improve readability.

Submitted by: Ryan Moeller <ryan@freqlabs.com>
MFC after: 1 week
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D19051

5 years agoDo not call PHOLD() while owning the allproc_lock sx.
kib [Sun, 3 Feb 2019 21:31:40 +0000 (21:31 +0000)]
Do not call PHOLD() while owning the allproc_lock sx.

Otherwise the lock might recurse in faultin() if the process is
swapped out.

Reported by: zeising
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoi386: Do not ever store to other-CPU counter64 slot.
kib [Sun, 3 Feb 2019 21:28:58 +0000 (21:28 +0000)]
i386: Do not ever store to other-CPU counter64 slot.

On CPUs supporting cmpxchg8b, fetch is performed by cmpxchg8b on
corresponding CPU slot, which unconditionally write to the slot.  If
for that slot, the owner CPU increments it, then both CPUs might run
the cmpxchg8b instruction concurrently and this might race and
override the incremental write.  So the counter update would be lost.

Fix it by implementing fetch as IPI and accumulation of result.  It is
acceptable for rare counter64 fetch operation to be more expensive.

Diagnosed and tested by: Andreas Longwitz <longwitz@incore.de>
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

5 years agoAllow vm_page_free_prep() to dequeue pages without the page lock.
markj [Sun, 3 Feb 2019 18:43:20 +0000 (18:43 +0000)]
Allow vm_page_free_prep() to dequeue pages without the page lock.

This is a step towards being able to free pages without the page
lock held.  The approach is simply to add an implementation of
vm_page_dequeue_deferred() which does not assert that the page
lock is held.  Formally, the page lock is required to set
PGA_DEQUEUE, but in the case of vm_page_free_prep() we get the
same mutual exclusion for free by virtue of the fact that no
other references to the page may exist.

No functional change intended.

Reviewed by: kib (previous version)
MFC after: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D19065

5 years agoFix a race in vm_page_dequeue_deferred().
markj [Sun, 3 Feb 2019 18:38:58 +0000 (18:38 +0000)]
Fix a race in vm_page_dequeue_deferred().

To detect the case where the page is already marked for a deferred
dequeue, we must read the "queue" and "aflags" fields in a
precise order.  Otherwise, a race with a concurrent
vm_page_dequeue_complete() could leave the page with PGA_DEQUEUE
set despite it already having been dequeued.  Fix the problem by
using vm_page_queue() to check the queue state, which correctly
handles the race.

Reviewed by: kib
Tested by: pho
MFC after: 3 days
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D19039

5 years agoEnable COVERAGE and KCOV by default on arm64 and amd64.
andrew [Sun, 3 Feb 2019 12:46:27 +0000 (12:46 +0000)]
Enable COVERAGE and KCOV by default on arm64 and amd64.

This allows userspace to trace the kernel using the coverage sanitizer
found in clang. It will also allow other coverage tools to be built as
modules and attach into the same framework.

Sponsored by: DARPA, AFRL

5 years agoTeach pfil_ioctl() about VIMAGE.
glebius [Sun, 3 Feb 2019 08:28:02 +0000 (08:28 +0000)]
Teach pfil_ioctl() about VIMAGE.

Submitted by: gallatin

5 years agoReduce log spam from rpc.statd
dfr [Sun, 3 Feb 2019 08:15:26 +0000 (08:15 +0000)]
Reduce log spam from rpc.statd

This only reports failed attempts to contact hosts on the first attempt.

5 years agonew_kmem_alloc(9) is a Solaris/illumos malloc(9). FreeBSD and NetBSD
cy [Sun, 3 Feb 2019 05:26:10 +0000 (05:26 +0000)]
new_kmem_alloc(9) is a Solaris/illumos malloc(9). FreeBSD and NetBSD
never get here, however a test for SOLARIS, as redundant as this test is,
serves to document that this is the illumos definition. This should help
those who come after me to follow the code more easily.

MFC after: 1 month

5 years agoKernel module shim sources have no business being in the userland
cy [Sun, 3 Feb 2019 05:26:07 +0000 (05:26 +0000)]
Kernel module shim sources have no business being in the userland
build directory, especially those for other operating systems.
The kernel module shims for other operating systems are hereby removed.
The kernel module shim for FreeBSD, mlfk_ipl.c, is already in
sys/contrib/ipfilter/netinet. The one here is never used and should
not be in the userland build directory either.

mlfk_rule.c isn't used either however we will keep it in case someone
wishes to use this shim to load rules via a kernel module, handy for
embedded. In that case it should be copied to
sys/contrib/ipfilter/netinet and a Makefile created to employ it.
(Probably a useful documentation project when time permits.)

MFC after: 1 month

5 years agoRemove a reference to HP-UX in a comment.
cy [Sun, 3 Feb 2019 05:26:04 +0000 (05:26 +0000)]
Remove a reference to HP-UX in a comment.

MFC after: 1 month

5 years agoRemove a redundant ip_compat.h, originally merged from upstream.
cy [Sun, 3 Feb 2019 05:26:01 +0000 (05:26 +0000)]
Remove a redundant ip_compat.h, originally merged from upstream.

MFC after: 1 month