]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoRelax compat.linux.osrelease checks. This way one can do eg
Edward Tomasz Napierala [Mon, 2 Sep 2019 16:57:42 +0000 (16:57 +0000)]
Relax compat.linux.osrelease checks.  This way one can do eg
'compat.linux.osrelease=3.10.0-957.12.1.el7.x86_64', which
corresponds to CentOS 7.

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

5 years agovfs: restore mp null check in vop_stdgetwritemount
Mateusz Guzik [Mon, 2 Sep 2019 15:24:25 +0000 (15:24 +0000)]
vfs: restore mp null check in vop_stdgetwritemount

The initially read mount point can already be NULL.

Reported by: markj
Fixes: r351656 ("vfs: stop refing freed mount points in vop_stdgetwritemount")
Sponsored by: The FreeBSD Foundation

5 years agoLinuxKPI: Add sysfs create/remove functions that handles multiple files in one call.
Johannes Lundberg [Mon, 2 Sep 2019 14:51:59 +0000 (14:51 +0000)]
LinuxKPI: Add sysfs create/remove functions that handles multiple files in one call.

Reviewed by: hps
Approved by: imp (mentor), hps
MFC after: 1 week
Differential Revision: D21475

5 years agolibc: Use musl's optimized memchr
Ed Maste [Mon, 2 Sep 2019 13:56:44 +0000 (13:56 +0000)]
libc: Use musl's optimized memchr

Parentheses added to HASZERO macro to avoid a GCC warning.

Reviewed by: kib, mjg
Obtained from: musl (snapshot at commit 4d0a82170a)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17631

5 years agolibutil: remove SIGSYS handling from setusercontext
Mateusz Guzik [Mon, 2 Sep 2019 13:55:31 +0000 (13:55 +0000)]
libutil: remove SIGSYS handling from setusercontext

It was a workaround for cases where the kernel lacks setloginclass(2),
added in the 9.x era.

Submitted by: Pawel Biernacki

5 years agoBelatedly bump __FreeBSD_version for r351659, gets(3) removal
Ed Maste [Mon, 2 Sep 2019 12:48:18 +0000 (12:48 +0000)]
Belatedly bump __FreeBSD_version for r351659, gets(3) removal

Reported by: linimon

5 years agoproc: clear pid bitmap entry after dropping proctree lock
Mateusz Guzik [Mon, 2 Sep 2019 12:46:43 +0000 (12:46 +0000)]
proc: clear pid bitmap entry after dropping proctree lock

There is no correctness change here, but the procid lock is contended in
the fork path and taking it while holding proctree avoidably extends its
hold time.

Note that there are other ids which can end up getting cleared with the
lock.

Sponsored by: The FreeBSD Foundation

5 years agoloader.efi: use and prefer coninex interface
Toomas Soome [Mon, 2 Sep 2019 11:04:17 +0000 (11:04 +0000)]
loader.efi: use and prefer coninex interface

Add support for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.

5 years agoloader.efi: some systems do not translate scan code 0x8 to backspace
Toomas Soome [Mon, 2 Sep 2019 10:45:10 +0000 (10:45 +0000)]
loader.efi: some systems do not translate scan code 0x8 to backspace

Add scancode translation for backspace.

5 years agoUse DEVICE memory instead of UNCACHEABLE on aarch64 in ioremap() in the LinuxKPI.
Hans Petter Selasky [Mon, 2 Sep 2019 08:34:45 +0000 (08:34 +0000)]
Use DEVICE memory instead of UNCACHEABLE on aarch64 in ioremap() in the LinuxKPI.
This fixes system hangs on reading device registers on aarch64.

Tested with: Marvell MACCHIATObin (Armada8k) + mlx4en, amdgpu
Submitted by: Greg V <greg@unrelenting.technology>
Differential Revision: https://reviews.freebsd.org/D20789
MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agoFix regression issue after r351616. Make sure the mbuf queue gets initialized.
Hans Petter Selasky [Mon, 2 Sep 2019 08:31:18 +0000 (08:31 +0000)]
Fix regression issue after r351616. Make sure the mbuf queue gets initialized.

Found by: gonzo@
MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agoRemove remnants of optimization for > pagesize allocations.
Brooks Davis [Mon, 2 Sep 2019 08:03:29 +0000 (08:03 +0000)]
Remove remnants of optimization for > pagesize allocations.

In the past, this allocator seems to have allocated things larger than
a page seperately. Much of this code was removed at some point (perhaps
along with sbrk() used) so remove the rest. Instead, keep allocating in
power-of-two bins up to FIRST_BUCKET_SIZE << (NBUCKETS - 1). If we want
something more efficent, we should use a fancier allocator.

While here, remove some vestages of sbrk() use. Most importantly, don't
try to page align the pagepool since it's always page aligned by mmap().

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

5 years agomips: fix some mcount nits
Kyle Evans [Mon, 2 Sep 2019 01:55:55 +0000 (01:55 +0000)]
mips: fix some mcount nits

The symbol version for _mcount was removed 12 years ago in r169525 from
gmon/Symbol.map, to be added to the per-arch Symbol.map. mips was overlooked
in this, so _mcount has no symver. Add it back to where it should have been,
rather than where it would go if it were added today, since we're correcting
a historical mistake.

Additionally, _mcount is getting thrown into .mdebug.abi32 in the llvm80/90
world as it's not getting explicitly thrown into .text, so do this now. This
fixes the libc build that was previously failing due to relocations in
.mdebug.abi32. This is specifically due to the way clang's integrated AS
works and that they emit the .mdebug.abiNN section early in the process. An
LLVM bug has been submitted[0] and an agreement has been made that the
mips backend should switch to .text following .mdebug.abiNN for
compatibility.

[0] https://bugs.llvm.org/show_bug.cgi?id=43119

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

5 years agoExtend uma_reclaim() to permit different reclamation targets.
Mark Johnston [Sun, 1 Sep 2019 22:22:43 +0000 (22:22 +0000)]
Extend uma_reclaim() to permit different reclamation targets.

The page daemon periodically invokes uma_reclaim() to reclaim cached
items from each zone when the system is under memory pressure.  This
is important since the size of these caches is unbounded by default.
However it also results in bursts of high latency when allocating from
heavily used zones as threads miss in the per-CPU caches and must
access the keg in order to allocate new items.

With r340405 we maintain an estimate of each zone's usage of its
(per-NUMA domain) cache of full buckets.  Start making use of this
estimate to avoid reclaiming the entire cache when under memory
pressure.  In particular, introduce TRIM, DRAIN and DRAIN_CPU
verbs for uma_reclaim() and uma_zone_reclaim().  When trimming, only
items in excess of the estimate are reclaimed.  Draining a zone
reclaims all of the cached full buckets (the previous behaviour of
uma_reclaim()), and may further drain the per-CPU caches in extreme
cases.

Now, when under memory pressure, the page daemon will trim zones
rather than draining them.  As a result, heavily used zones do not incur
bursts of bucket cache misses following reclamation, but large, unused
caches will be reclaimed as before.

Reviewed by: jeff
Tested by: pho (an earlier version)
MFC after: 2 months
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D16667

5 years agoRestrict the input domain set in cpuset_setdomain(2) to all_domains.
Mark Johnston [Sun, 1 Sep 2019 21:38:08 +0000 (21:38 +0000)]
Restrict the input domain set in cpuset_setdomain(2) to all_domains.

To permit larger values of MAXMEMDOM, which is currently 8 on amd64,
cpuset_setdomain(2) accepts a mask of size 256.  In the kernel, domain
set masks are 64 bits wide, but can only represent a set of MAXMEMDOM
domains due to the use of the ds_order table.

Domain sets passed to cpuset_setdomain(2) are restricted to a subset
of their parent set, which is typically the root set, but before this
happens we modify the input set to exclude empty domains.
domainset_empty_vm() and other code which manipulates domain sets
expect the mask to be a subset of all_domains, so enforce that when
performing validation of cpuset_setdomain(2) parameters.

Reported and tested by: pho
Reviewed by: kib
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21477

5 years agoFix an off-by-one bug in the CPU and domain ID parser.
Mark Johnston [Sun, 1 Sep 2019 21:20:31 +0000 (21:20 +0000)]
Fix an off-by-one bug in the CPU and domain ID parser.

The "size" parameter is the size of the corresponding bit set, so the
maximum CPU or domain index is size - 1.

MFC after: 1 week

5 years agoMove CAS check in powerpc64 ofw loader until after the PVR check.
Brandon Bergren [Sun, 1 Sep 2019 18:26:21 +0000 (18:26 +0000)]
Move CAS check in powerpc64 ofw loader until after the PVR check.

This unbreaks using the powerpc64 loader on a 32-bit processor.

Approved by: jhibbits (mentor)
Differential Revision: https://reviews.freebsd.org/D21297

5 years agomakefs: share msdosfsmount.h between kernel msdosfs and makefs
Ed Maste [Sun, 1 Sep 2019 16:55:33 +0000 (16:55 +0000)]
makefs: share msdosfsmount.h between kernel msdosfs and makefs

Sponsored by: The FreeBSD Foundation

5 years agovnic: correct and simplify SIOCSIFFLAGS
Ed Maste [Sun, 1 Sep 2019 16:53:17 +0000 (16:53 +0000)]
vnic: correct and simplify SIOCSIFFLAGS

PR: 223573, 223575
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13028

5 years agoar: use more correct size_t type for loop index
Ed Maste [Sun, 1 Sep 2019 16:51:25 +0000 (16:51 +0000)]
ar: use more correct size_t type for loop index

Submitted by: cem
MFC after: 1 week

5 years agolldb: shorten thread names to make logs easier to follow
Ed Maste [Sun, 1 Sep 2019 16:50:34 +0000 (16:50 +0000)]
lldb: shorten thread names to make logs easier to follow

lldb prepends the thread name to log entries, and the existing thread
name for the FreeBSD ProcessMonitor thread was longer than the kernel's
supported thread name length, and so was truncated.  This made logs hard
to read, as the truncated thread name ran into the log message.  Shorten
"lldb.process.freebsd.operation" to just "freebsd.op" so that logs are
more readable.

(Upstreaming to lldb still to be done).

5 years agoRemove CLANG_NO_IAS definition
Ed Maste [Sun, 1 Sep 2019 16:47:48 +0000 (16:47 +0000)]
Remove CLANG_NO_IAS definition

CLANG_NO_IAS is not used anywhere in the tree.

Sponsored by: The FreeBSD Foundation

5 years agolibstdc++: remove gets
Ed Maste [Sun, 1 Sep 2019 16:41:24 +0000 (16:41 +0000)]
libstdc++: remove gets

Removed from libc in r351659

5 years agolibc: remove gets
Ed Maste [Sun, 1 Sep 2019 16:12:05 +0000 (16:12 +0000)]
libc: remove gets

gets is unsafe and shouldn't be used (for many years now).  Leave it in
the existing symbol version so anything that previously linked aginst it
still runs, but do not allow new software to link against it.

(The compatability/legacy implementation must not be static so that
the symbol and in particular the compat sym gets@FBSD_1.0 make it
into libc.)

PR: 222796 (exp-run)
Reported by: Paul Vixie
Reviewed by: allanjude, cy, eadler, gnn, jhb, kib, ngie (some earlier)
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D12298

5 years agoAdd myself (fox) and update the mentor information.
Santhosh Raju [Sun, 1 Sep 2019 15:39:28 +0000 (15:39 +0000)]
Add myself (fox) and update the mentor information.

Approved by: philip (mentor)

5 years agonetmap: import changes from upstream (SHA 137f537eae513)
Vincenzo Maffione [Sun, 1 Sep 2019 14:47:41 +0000 (14:47 +0000)]
netmap: import changes from upstream (SHA 137f537eae513)

 - Rework option processing.
 - Use larger integers for memory size values in the
   memory management code.

MFC after: 2 weeks

5 years agovfs: stop refing freed mount points in vop_stdgetwritemount
Mateusz Guzik [Sun, 1 Sep 2019 14:01:09 +0000 (14:01 +0000)]
vfs: stop refing freed mount points in vop_stdgetwritemount

The code used blindly ref based on an unsafely red address and then would
backpedal if necessary. This was safe in terms of memory access since
mounts are type-stable, but made for a potential a bug where the mount
was reused and had the count reset to 0 before this code decreased it.

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

5 years agoFix initialization of top_fsn.
Michael Tuexen [Sun, 1 Sep 2019 10:39:16 +0000 (10:39 +0000)]
Fix initialization of top_fsn.

MFC after: 3 days

5 years agoImprove the handling of state cookie parameters in INIT-ACK chunks.
Michael Tuexen [Sun, 1 Sep 2019 10:09:53 +0000 (10:09 +0000)]
Improve the handling of state cookie parameters in INIT-ACK chunks.
This fixes problem with parameters indicating a zero length or partial
parameters after an unknown parameter indicating to stop processing. It
also fixes a problem with state cookie parameters after unknown
parametes indicating to stop porcessing.
Thanks to Mark Wodrich from Google for finding two of these issues
by fuzz testing the userland stack and reporting them in
https://github.com/sctplab/usrsctp/issues/355
and
https://github.com/sctplab/usrsctp/issues/352

MFC after: 3 days

5 years agoAdd support for TP-Link Archer T2U Nano.
Jung-uk Kim [Sun, 1 Sep 2019 06:40:58 +0000 (06:40 +0000)]
Add support for TP-Link Archer T2U Nano.

MFC after: 2 weeks

5 years agonullfs: reduce areas protected by vnode interlock in null_lock
Mateusz Guzik [Sun, 1 Sep 2019 02:52:00 +0000 (02:52 +0000)]
nullfs: reduce areas protected by vnode interlock in null_lock

Similarly to the other routine stop taking the interlock for the lower
vnode. The interlock for nullfs vnode is still taken to ensure
stability of ->v_data.

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

5 years agoposixshm: switch to OBJT_SWAP in advance of other changes
Kyle Evans [Sun, 1 Sep 2019 00:33:16 +0000 (00:33 +0000)]
posixshm: switch to OBJT_SWAP in advance of other changes

Future changes to posixshm will start tracking writeable mappings in order
to support file sealing. Tracking writeable mappings for an OBJT_DEFAULT
object is complicated as it may be swapped out and converted to an
OBJT_SWAP. One may generically add this tracking for vm_object, but this is
difficult to do without increasing memory footprint of vm_object and blowing
up memory usage by a significant amount.

On the other hand, the swap pager can be expanded to track writeable
mappings without increasing vm_object size. This change is currently in
D21456. Switch over to OBJT_SWAP in advance of the other changes to the
swap pager and posixshm.

5 years agoARM kernel can get RAM regions three ways:
Aleksandr Rybalko [Sat, 31 Aug 2019 21:28:06 +0000 (21:28 +0000)]
ARM kernel can get RAM regions three ways:
o from FDT;
o from EFI;
o from Linux Boot API (ATAG).
U-Boot may pass RAM info all that 3 ways simultaneously.
We do select between FDT and EFI, but not for ATAG.
So this is not problem fix, but correctness check.

MFC after: 2 weeks

5 years agoUnskip test cases from netbsd-tests by defining __HAVE_FENV
Li-Wen Hsu [Sat, 31 Aug 2019 20:45:45 +0000 (20:45 +0000)]
Unskip test cases from netbsd-tests by defining __HAVE_FENV

This unskips:
  - lib.libc.stdlib.strtod_test.strtod_round
  - lib.msun.fe_round_test.t_nofe_round

In lib/msun/tests/Makefile only define on fe_round_test.c because
lib.msun.ilogb_test.ilogb will get wrong results and needs more examination.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

5 years agoFix dtrace test case after r351423 due to ping6(8) options changed
Li-Wen Hsu [Sat, 31 Aug 2019 15:10:27 +0000 (15:10 +0000)]
Fix dtrace test case after r351423 due to ping6(8) options changed

Failure test case:
    cddl.usr.sbin.dtrace.common.ip.t_dtrace_contrib.tst_ipv6localicmp_ksh

Sponsored by: The FreeBSD Foundation

5 years agoFix tests use /etc/motd after r350184 by using an always existing file
Li-Wen Hsu [Sat, 31 Aug 2019 14:41:58 +0000 (14:41 +0000)]
Fix tests use /etc/motd after r350184 by using an always existing file

Sponsored by: The FreeBSD Foundation

5 years agozfs: fix snapshot dir destruction after introducion of VOP_NEED_INACTIVE
Mateusz Guzik [Sat, 31 Aug 2019 13:24:22 +0000 (13:24 +0000)]
zfs: fix snapshot dir destruction after introducion of VOP_NEED_INACTIVE

Reported by: lwhsu
PR: 240221
Sponsored by: The FreeBSD Foundation

5 years agoImprove function definition.
Michael Tuexen [Sat, 31 Aug 2019 13:13:40 +0000 (13:13 +0000)]
Improve function definition.

MFC after: 3 days

5 years agoImprove the handling of illegal sequence number combinations in received
Michael Tuexen [Sat, 31 Aug 2019 08:18:49 +0000 (08:18 +0000)]
Improve the handling of illegal sequence number combinations in received
data chunks. Abort the association if there are data chunks with larger
fragement sequence numbers than the fragement sequence of the last
fragment.
Thanks to Mark Wodrich from Google who found this issue by fuzz testing
the userland stack and reporting this issue in
https://github.com/sctplab/usrsctp/issues/355

MFC after: 3 days

5 years agoloader.efi: use shift 16 in efipart as it is max ashift supported by zfs
Toomas Soome [Sat, 31 Aug 2019 06:24:09 +0000 (06:24 +0000)]
loader.efi: use shift 16 in efipart as it is max ashift supported by zfs

5 years agovfs: add a missing VNODE_REFCOUNT_FENCE_REL to v_incr_usecount_locked
Mateusz Guzik [Fri, 30 Aug 2019 21:54:45 +0000 (21:54 +0000)]
vfs: add a missing VNODE_REFCOUNT_FENCE_REL to v_incr_usecount_locked

Sponsored by: The FreeBSD Foundation

5 years agoEarliest reference to /dev/null I can find is in v4 sh(1) and nulldev in
Sevan Janiyan [Fri, 30 Aug 2019 21:49:00 +0000 (21:49 +0000)]
Earliest reference to /dev/null I can find is in v4 sh(1) and nulldev in
nsys/ken/subr.c
via TUHS archive
https://minnie.tuhs.org/cgi-bin/utree.pl?file=V4

MFC after: 5 days

5 years agoqemu-system-aarch64 does list block device with very large block size
Toomas Soome [Fri, 30 Aug 2019 20:54:30 +0000 (20:54 +0000)]
qemu-system-aarch64 does list block device with very large block size

Also insert Vendor device as "parent" disk (found in
qemu-system-aarch64 -cpu cortex-a57).

This does fix lsdev in loader.efi on this platform.

5 years agoWrap a vlan's parent's if_output in a separate function.
Matt Joras [Fri, 30 Aug 2019 20:19:43 +0000 (20:19 +0000)]
Wrap a vlan's parent's if_output in a separate function.

When a vlan interface is created, its if_output is set directly to the
parent interface's if_output. This is fine in the normal case but has an
unfortunate consequence if you end up with a certain combination of vlan
and lagg interfaces.

Consider you have a lagg interface with a single laggport member. When
an interface is added to a lagg its if_output is set to
lagg_port_output, which blackholes traffic from the normal networking
stack but not certain frames from BPF (pseudo_AF_HDRCMPLT). If you now
create a vlan with the laggport member (not the lagg interface) as its
parent, its if_output is set to lagg_port_output as well. While this is
confusing conceptually and likely represents a misconfigured system, it
is not itself a problem. The problem arises when you then remove the
lagg interface. Doing this resets the if_output of the laggport member
back to its original state, but the vlan's if_output is left pointing to
lagg_port_output. This gives rise to the possibility that the system
will panic when e.g. bpf is used to send any frames on the vlan
interface.

Fix this by creating a new function, vlan_output, which simply wraps the
parent's current if_output. That way when the parent's if_output is
restored there is no stale usage of lagg_port_output.

Reviewed by: rstone
Differential Revision: D21209

5 years agoUpdate and clean up the UMA man page.
Mark Johnston [Fri, 30 Aug 2019 19:35:44 +0000 (19:35 +0000)]
Update and clean up the UMA man page.

- Fix warnings from igor and mandoc.
- Provide a brief description of the separation between zones and their
  backend slab allocators.
- Document cache zones and secondary zones.
- Document the kernel config options added in r350659.
- Document the uma_zalloc_pcpu() and uma_zfree_pcpu() wrappers.
- Document uma_zone_reserve(), uma_zone_reserve_kva() and
  uma_zone_prealloc().
- Document uma_zone_alloc() and uma_zone_freef().
- Add some missing MLINKs and Xrefs.

MFC after: 2 weeks

5 years agoavoid holding PCB mutex during copyin/copyout()
Maksim Yevmenkin [Fri, 30 Aug 2019 16:35:31 +0000 (16:35 +0000)]
avoid holding PCB mutex during copyin/copyout()

Reported by: imp, mms dot vanbreukelingen at gmail dot com
Reviewed by: imp

5 years agoAdd entries for unmapped mbufs and KTLS.
John Baldwin [Fri, 30 Aug 2019 16:30:09 +0000 (16:30 +0000)]
Add entries for unmapped mbufs and KTLS.

5 years agoProperly check for an interrupted cv_wait_sig().
Mark Johnston [Fri, 30 Aug 2019 15:40:31 +0000 (15:40 +0000)]
Properly check for an interrupted cv_wait_sig().

The returned error number may be EINTR or ERESTART depending on
whether or not the signal is supposed to interrupt the system call.

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

5 years agoRemove unneeded blank line. No functional change.
Xin LI [Fri, 30 Aug 2019 06:06:12 +0000 (06:06 +0000)]
Remove unneeded blank line.  No functional change.

MFC after: 2 weeks

5 years agovfs: tidy up assertions in vfs_subr
Mateusz Guzik [Fri, 30 Aug 2019 00:45:53 +0000 (00:45 +0000)]
vfs: tidy up assertions in vfs_subr

- assert unlocked vnode interlock in vref
- assert right counts in vputx
- print debug info for panic in vdrop

Sponsored by: The FreeBSD Foundation

5 years agoxdma: avoid NULL deref in error case
Ed Maste [Fri, 30 Aug 2019 00:40:08 +0000 (00:40 +0000)]
xdma: avoid NULL deref in error case

Reported by: Dr Silvio Cesare of InfoSect
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agoqlxgbe: avoid NULL deref in error case
Ed Maste [Fri, 30 Aug 2019 00:38:16 +0000 (00:38 +0000)]
qlxgbe: avoid NULL deref in error case

Reported by: Dr Silvio Cesare of InfoSect
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agoexynos5: avoid NULL deref in error case
Ed Maste [Fri, 30 Aug 2019 00:36:17 +0000 (00:36 +0000)]
exynos5: avoid NULL deref in error case

Reported by: Dr Silvio Cesare of InfoSect
MFC after: 3 days
MFC with: r351618
Sponsored by: The FreeBSD Foundation

5 years agoexynos5: avoid NULL deref in error case
Ed Maste [Fri, 30 Aug 2019 00:34:27 +0000 (00:34 +0000)]
exynos5: avoid NULL deref in error case

Reported by: Dr Silvio Cesare of InfoSect
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agonullfs: use VOP_NEED_INACTIVE
Mateusz Guzik [Fri, 30 Aug 2019 00:30:03 +0000 (00:30 +0000)]
nullfs: use VOP_NEED_INACTIVE

Reviewed by: kib
Tested by: pho (previous version)
Sponsored by: The FreeBSD Foundation

5 years agoUse mbuf queue instead of ifqueue in USB network drivers.
Gleb Smirnoff [Fri, 30 Aug 2019 00:05:04 +0000 (00:05 +0000)]
Use mbuf queue instead of ifqueue in USB network drivers.

Reviewed by: stevek

5 years agoAllow mbuf queues to be unlimited.
Gleb Smirnoff [Fri, 30 Aug 2019 00:03:41 +0000 (00:03 +0000)]
Allow mbuf queues to be unlimited.

There is number of legacy code that uses ifqueue without setting
a limit on it first. Easier to allow for that rather than improve
legacy drivers.

5 years ago- address missing whitespace for indent
Jason Helfman [Thu, 29 Aug 2019 23:23:12 +0000 (23:23 +0000)]
- address missing whitespace for indent

PR: 239727
Submitted by: gbergling@gmail.com
Reviewed by: 0mp@
MFC after: 1 week

5 years agoRemove unused VM page locking macros.
Mark Johnston [Thu, 29 Aug 2019 22:13:15 +0000 (22:13 +0000)]
Remove unused VM page locking macros.

They were orphaned by r292373.

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

5 years agoSimplify bhyve vlapic ESR logic.
John Baldwin [Thu, 29 Aug 2019 18:23:38 +0000 (18:23 +0000)]
Simplify bhyve vlapic ESR logic.

The bhyve virtual local APIC uses an instance-global flag to indicate
when an error LVT is being delivered to prevent infinite recursion.
Use a function argument instead to reduce the amount of instance-global
state.

This was inspired by reviewing the bhyve save/restore work, which
saves a copy of the instance-global state for each vlapic.

Smart OS bug: https://smartos.org/bugview/OS-7777
Submitted by: Patrick Mooney
Reviewed by: markj, rgrimes
Obtained from: SmartOS / Joyent
Differential Revision: https://reviews.freebsd.org/D20365

5 years agoUse relative paths in ObsoleteFiles.inc
Niclas Zeising [Thu, 29 Aug 2019 17:25:50 +0000 (17:25 +0000)]
Use relative paths in ObsoleteFiles.inc

Approved by: imp
Differential Revision: https://reviews.freebsd.org/D21467

5 years agopwm.9 symlink shouldn't be removed
Niclas Zeising [Thu, 29 Aug 2019 17:17:39 +0000 (17:17 +0000)]
pwm.9 symlink shouldn't be removed

When the pwm.9 manual was removed, a symlink between pwmbus.9 and pwm.9 was
created, but there's an entry in ObsoleteFiles.inc to remove pwn.9, meaning
that on every installation pwm.9 is created, and make delete-old deletes it.

Remove the entry from ObsoleteFiles.inc, the symlink is clearly intentional
and shouldn't be removed.

Reviewed by: imp, ian
Approved by: imp (implicit, review OK)
Differential Revision: https://reviews.freebsd.org/D21198

5 years agoTake proper lock in ses_setphyspath_callback().
Alexander Motin [Thu, 29 Aug 2019 17:02:02 +0000 (17:02 +0000)]
Take proper lock in ses_setphyspath_callback().

XPT_DEV_ADVINFO call should be protected by the lock of the specific
device it is addressed to, not the lock of SES device.  In some weird
case, probably with hardware violating standards, it sometimes caused
NULL dereference due to race.

To protect from it further, add lock assertion to *_dev_advinfo().

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

5 years agoMan page for AMD Non-Transparent Bridge (ntb_hw_amd) driver.
Alexander Motin [Thu, 29 Aug 2019 13:46:54 +0000 (13:46 +0000)]
Man page for AMD Non-Transparent Bridge (ntb_hw_amd) driver.

Submitted by: Rajesh Kumar <rajesh1.kumar@amd.com>
Reviewed by: bcr
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D21462

5 years agoichsmb: defer smbus attach until interrupts are available
Yuri Pankov [Thu, 29 Aug 2019 12:49:21 +0000 (12:49 +0000)]
ichsmb: defer smbus attach until interrupts are available

This fixes a "timed sleep before timers are working" panic seen
while attaching jedec_dimm(4) instances too early in the boot.

Submitted by: ian
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D21452

5 years agovnic: avoid NULL deref in error case
Ed Maste [Thu, 29 Aug 2019 12:05:06 +0000 (12:05 +0000)]
vnic: avoid NULL deref in error case

Reported by: Dr Silvio Cesare of InfoSect
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agoscsi_cd: whitespace cleanup
Andriy Gapon [Thu, 29 Aug 2019 08:26:40 +0000 (08:26 +0000)]
scsi_cd: whitespace cleanup

Remove trailing whitespace and fix mixed indentation.

MFC after: 3 weeks

5 years agoscsi_cd: ifdef out cdsize()
Andriy Gapon [Thu, 29 Aug 2019 08:19:11 +0000 (08:19 +0000)]
scsi_cd: ifdef out cdsize()

It was used only by the old cdcheckmedia().

MFC after: 3 weeks

5 years agoscsi_cd: make the media check asynchronous
Andriy Gapon [Thu, 29 Aug 2019 07:51:11 +0000 (07:51 +0000)]
scsi_cd: make the media check asynchronous

This makes the media check process asynchronous, so we no longer block
in cdstrategy() to check for media.

PR: 219857
Obtained from: ken
MFC after: 3 weeks

5 years agoRework v_object lifecycle for vnodes.
Konstantin Belousov [Thu, 29 Aug 2019 07:50:25 +0000 (07:50 +0000)]
Rework v_object lifecycle for vnodes.

Current implementation of vnode_create_vobject() and
vnode_destroy_vobject() is written so that it prepared to handle the
vm object destruction for live vnode.  Practically, no filesystems use
this, except for some remnants that were present in UFS till today.
One of the consequences of that model is that each filesystem must
call vnode_destroy_vobject() in VOP_RECLAIM() or earlier, as result
all of them get rid of the v_object in reclaim.

Move the call to vnode_destroy_vobject() to vgonel() before
VOP_RECLAIM().  This makes v_object stable: either the object is NULL,
or it is valid vm object till the vnode reclamation.  Remove code from
vnode_create_vobject() to handle races with the parallel destruction.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21412

5 years agoUFS: stop reusing the vnode for reallocated inode.
Konstantin Belousov [Thu, 29 Aug 2019 07:45:23 +0000 (07:45 +0000)]
UFS: stop reusing the vnode for reallocated inode.

In ffs_valloc(), force reclaim existing vnode on inode reuse, instead
of trying to re-initialize the same vnode for new purposes.  This is
done in preparation of changes to the vp->v_object lifecycle handling.

A new FFSV_REPLACE flag to ffs_vgetf() directs the function to
vgone(9) the vnode if found in vfs hash, instead of returning it.

Reviewed by: markj, mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21412

5 years agoFix qmath(3) build problems with GCC 8.
Edward Tomasz Napierala [Thu, 29 Aug 2019 07:39:31 +0000 (07:39 +0000)]
Fix qmath(3) build problems with GCC 8.

Discussed with: asomers
Sponsored by: Klara Systems
Differential Revision: https://reviews.freebsd.org/D21442

5 years agoRemove useless redefinition of NSFBUFS in i386/vm_machdep.c.
Konstantin Belousov [Thu, 29 Aug 2019 07:34:14 +0000 (07:34 +0000)]
Remove useless redefinition of NSFBUFS in i386/vm_machdep.c.

Sponsored by: The FreeBSD Foundation

5 years agoCentralize __pcpu definitions.
Konstantin Belousov [Thu, 29 Aug 2019 07:25:27 +0000 (07:25 +0000)]
Centralize __pcpu definitions.

Many extern struct pcpu <something>__pcpu declarations were
copied/pasted in sources.  The issue is that the definition is MD, but
it cannot be provided by machine/pcpu.h due to actual struct pcpu
defined in sys/pcpu.h later than the inclusion of machine/pcpu.h.
This forced the copying when other code needed direct access to
__pcpu.  There is no way around it, due to machine/pcpu.h supplying
part of struct pcpu fields.

To work around the problem, add a new machine/pcpu_aux.h header, which
should fill any needed MD definitions after struct pcpu definition is
completed. This allows to remove copies of __pcpu spread around the
source.  Also on x86 it makes it possible to remove work arounds like
OFFSETOF_CURTHREAD or clang specific warnings supressions.

Reported and tested by: lwhsu, bcran
Reviewed by: imp, markj (previous version)
Discussed with: jhb
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21418

5 years agozfs_ioc_snapshot: check user-prop permissions on snapshotted datasets
Andriy Gapon [Thu, 29 Aug 2019 07:19:06 +0000 (07:19 +0000)]
zfs_ioc_snapshot: check user-prop permissions on snapshotted datasets

Previously, the permissions were checked on the pool which was obviously
incorrect.

After this change, zfs_check_userprops() only validates the properties
without any permission checks.  The permissions are checked individually
for each snapshotted dataset.

This was also committed to ZoL: zfsonlinux/zfs@e6203d2

Reported by: CyberSecure
MFC after: 1 week
Sponsored by: CyberSecure

5 years agoFix address annotation in xml output from w
Mike Karels [Thu, 29 Aug 2019 02:44:18 +0000 (02:44 +0000)]
Fix address annotation in xml output from w

The libxo xml feature of adding an annotation with the "original"
address from the utmpx file if it is different than the final "from"
field was broken by r351379. This was pointed out by the gcc error
that save_p might be used uninitialized. Save the original address
as needed in each entry, don't just use the last one from the previous
loop.

Reviewed by: marcel@
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21390

5 years agoUse get_pcpu() to fetch the current CPU's pcpu pointer.
John Baldwin [Wed, 28 Aug 2019 23:40:57 +0000 (23:40 +0000)]
Use get_pcpu() to fetch the current CPU's pcpu pointer.

This avoids encoding knowledge about how pcpu objects are allocated and is
also a few instructions shorter.

MFC after: 2 weeks

5 years agocxgbe/t4_tom: Use the correct value of sndbuf in AIO Tx.
Navdeep Parhar [Wed, 28 Aug 2019 23:31:58 +0000 (23:31 +0000)]
cxgbe/t4_tom: Use the correct value of sndbuf in AIO Tx.

This should have been part of r351540.

Sponsored by: Chelsio Communications

5 years agoFix AHCI Enclosure Management, broken by r351356.
Alexander Motin [Wed, 28 Aug 2019 22:04:04 +0000 (22:04 +0000)]
Fix AHCI Enclosure Management, broken by r351356.

ivars value of -1 was used to distinguish EM device, and r351356 left some
wrong checks for it.  Give EM device separate flag there instead.

5 years agoInstall all bzip2.1 MLINKs from the same place.
Mark Johnston [Wed, 28 Aug 2019 21:01:51 +0000 (21:01 +0000)]
Install all bzip2.1 MLINKs from the same place.

Reported by: antoine
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agotmpfs: use VOP_NEED_INACTIVE
Mateusz Guzik [Wed, 28 Aug 2019 20:35:23 +0000 (20:35 +0000)]
tmpfs: use VOP_NEED_INACTIVE

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

5 years agovfs: add VOP_NEED_INACTIVE
Mateusz Guzik [Wed, 28 Aug 2019 20:34:24 +0000 (20:34 +0000)]
vfs: add VOP_NEED_INACTIVE

vnode usecount drops to 0 all the time (e.g. for directories during path lookup).
When that happens the kernel would always lock the exclusive lock for the vnode
in order to call vinactive(). This blocks other threads who want to use the vnode
for looukp.

vinactive is very rarely needed and can be tested for without the vnode lock held.

This patch gives filesytems an opportunity to do it, sample total wait time for
tmpfs over 500 minutes of poudriere -j 104:

before: 557563641706 (lockmgr:tmpfs)
after:   46309603301 (lockmgr:tmpfs)

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21371

5 years agoamd64: clean up cpu_switch.S
Mateusz Guzik [Wed, 28 Aug 2019 19:40:57 +0000 (19:40 +0000)]
amd64: clean up cpu_switch.S

- LK macro (conditional on SMP for the lock prefix) is unused
- SETLK unnecessarily performs xchg. obtained value is never used and the
  implicit lock prefix adds avoidable cost. Barrier provided by it does
  not appear to be of any use.
- the lock waited for is almost never blocked, yet the loop starts with
  a pause. Move it out of the common case.

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

5 years agovm: only lock tmpfs vnode shared in vm_object_deallocate
Mateusz Guzik [Wed, 28 Aug 2019 19:28:27 +0000 (19:28 +0000)]
vm: only lock tmpfs vnode shared in vm_object_deallocate

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

5 years agoAvoid direct accesses of the vm_page wire_count field.
Mark Johnston [Wed, 28 Aug 2019 18:01:54 +0000 (18:01 +0000)]
Avoid direct accesses of the vm_page wire_count field.

No functional change intended.

Sponsored by: Netflix

5 years agoMFV/ZoL: Fix wrong assertion in libzfs diff error handling
Alexander Motin [Wed, 28 Aug 2019 17:39:46 +0000 (17:39 +0000)]
MFV/ZoL: Fix wrong assertion in libzfs diff error handling

In compare(), all error cases set the error code to EPIPE, so when an
error is set, the correct assertion to make is that the error is EPIPE,
not EINVAL.

Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@freqlabs.com>
Closes #8743
zfsonlinux/zfs@9dc41a769df164875d974c2431b2453e70e16c41

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

5 years agoDocument fetchReqHTTP().
Mark Johnston [Wed, 28 Aug 2019 17:01:28 +0000 (17:01 +0000)]
Document fetchReqHTTP().

Submitted by: Farhan Khan <khanzf@gmail.com>
Reviewed by: 0mp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D18788

5 years agoproc: eliminate the zombproc list
Mateusz Guzik [Wed, 28 Aug 2019 16:18:23 +0000 (16:18 +0000)]
proc: eliminate the zombproc list

It is not needed by anything in the kernel and it slightly drives up contention
on both proctree and allproc locks.

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

5 years agoWire pages in vm_page_grab() when appropriate.
Mark Johnston [Wed, 28 Aug 2019 16:08:06 +0000 (16:08 +0000)]
Wire pages in vm_page_grab() when appropriate.

uiomove_object_page() and exec_map_first_page() would previously wire a
page after having grabbed it.  Ask vm_page_grab() to perform the wiring
instead: this removes some redundant code, and is cheaper in the case
where the requested page is not resident since the page allocator can be
asked to initialize the page as wired, whereas a separate vm_page_wire()
call requires the page lock.

In vm_imgact_hold_page(), use vm_page_unwire_noq() instead of
vm_page_unwire(PQ_NONE).  The latter ensures that the page is dequeued
before returning, but this is unnecessary since vm_page_free() will
trigger a batched dequeue of the page.

Reviewed by: alc, kib
Tested by: pho (part of a larger patch)
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21440

5 years agoDocument ipf_nat_hashtab_add() return codes.
Cy Schubert [Wed, 28 Aug 2019 04:55:17 +0000 (04:55 +0000)]
Document ipf_nat_hashtab_add() return codes.

MFC after: 3 days

5 years agoDestroy the mutex in case of error.
Cy Schubert [Wed, 28 Aug 2019 04:55:03 +0000 (04:55 +0000)]
Destroy the mutex in case of error.

Obtained from: NetBSD ip_nat.c r1.7
MFC after: 3 days

5 years agoFixup typo in comment.
Cy Schubert [Wed, 28 Aug 2019 04:54:26 +0000 (04:54 +0000)]
Fixup typo in comment.

Obtained from: NetBSD ip_nat.c r1.7
MFC after: 3 days

5 years agofusefs: Fix some bugs regarding the size of the LISTXATTR list
Alan Somers [Wed, 28 Aug 2019 04:19:37 +0000 (04:19 +0000)]
fusefs: Fix some bugs regarding the size of the LISTXATTR list

* A small error in r338152 let to the returned size always being exactly
  eight bytes too large.

* The FUSE_LISTXATTR operation works like Linux's listxattr(2): if the
  caller does not provide enough space, then the server should return ERANGE
  rather than return a truncated list.  That's true even though in FUSE's
  case the kernel doesn't provide space to the client at all; it simply
  requests a maximum size for the list.  We previously weren't handling the
  case where the server returns ERANGE even though the kernel requested as
  much size as the server had told us it needs; that can happen due to a
  race.

* We also need to ensure that a pathological server that always returns
  ERANGE no matter what size we request in FUSE_LISTXATTR won't cause an
  infinite loop in the kernel.  As of this commit, it will instead cause an
  infinite loop that exits and enters the kernel on each iteration, allowing
  signals to be processed.

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

5 years agoproc: remove zpfind
Mateusz Guzik [Wed, 28 Aug 2019 01:22:21 +0000 (01:22 +0000)]
proc: remove zpfind

It is not used by anything. If someone wants it back it should be reimplemented
to use the proc hash.

Sponsored by: The FreeBSD Foundation

5 years agoOnly define the 'tls' member of sfio in KERN_TLS is defined.
John Baldwin [Tue, 27 Aug 2019 22:21:18 +0000 (22:21 +0000)]
Only define the 'tls' member of sfio in KERN_TLS is defined.

This field was not initialized in the !KERN_TLS case triggering an
assertion failure when using sendfile(2).

Reported by: pho, asomers
Sponsored by: Netflix

5 years agoAdjust the deprecated warnings for /dev/crypto to be less noisy.
John Baldwin [Tue, 27 Aug 2019 21:29:37 +0000 (21:29 +0000)]
Adjust the deprecated warnings for /dev/crypto to be less noisy.

Warn when actual operations are performed instead of when sessions are
created.  The /dev/crypto engine in OpenSSL 1.0.x tries to create
sessions for all possible algorithms each time it is initialized
resulting in spurious warnings.

Reported by: Mike Tancsa
MFC after: 3 days
Sponsored by: Chelsio Communications

5 years agounionfs: stop passing LK_INTERLOCK to VOP_UNLOCK
Mateusz Guzik [Tue, 27 Aug 2019 20:51:17 +0000 (20:51 +0000)]
unionfs: stop passing LK_INTERLOCK to VOP_UNLOCK

This is part of the preparation to remove flags argument from VOP_UNLOCK.
Also has a side effect of fixing stacking on top of nullfs broken by r351472.

Reported by: cy
Sponsored by: The FreeBSD Foundation

5 years agovfs: stop passing LK_INTERLOCK to VOP_UNLOCK
Mateusz Guzik [Tue, 27 Aug 2019 20:30:56 +0000 (20:30 +0000)]
vfs: stop passing LK_INTERLOCK to VOP_UNLOCK

The plan is to drop the flags argument. There is also a temporary bug
now that nullfs ignores the flag.

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

5 years agoMFV r351553:
Hiroki Sato [Tue, 27 Aug 2019 20:11:45 +0000 (20:11 +0000)]
MFV r351553:

Fix a problem which prevented -OServerSSLOptions or -OClientSSLOptions
specified in the command-line option from working.

This patch has been accepted by the upstream.

Reviewed by and discussed with: gshapiro

5 years agoFix a problem which prevented -OServerSSLOptions or -OClientSSLOptions
Hiroki Sato [Tue, 27 Aug 2019 19:37:19 +0000 (19:37 +0000)]
Fix a problem which prevented -OServerSSLOptions or -OClientSSLOptions
specified in the command-line option from working.

This patch has been accepted by the upstream.

Reviewed by and discussed with: gshapiro