]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoRevert parts of r337849 and r337857
brd [Wed, 15 Aug 2018 23:18:34 +0000 (23:18 +0000)]
Revert parts of r337849 and r337857

This fixes the build and I will redo these changes as part of a future review
that organizes them differently.  The way I tried to do it here could be done
better.  Sorry for the noise.

Approved by: will (mentor)
Differential Revision: https://reviews.freebsd.org/D16737

5 years agolibi386: use BD_RD and BR_WR constants
tsoome [Wed, 15 Aug 2018 22:40:09 +0000 (22:40 +0000)]
libi386: use BD_RD and BR_WR constants

Use BD_RD and BD_WR instead of 0 and 1.

Reported by: ian

5 years agolibi386: remove bd_read() and bd_write() wrappers
tsoome [Wed, 15 Aug 2018 22:25:05 +0000 (22:25 +0000)]
libi386: remove bd_read() and bd_write() wrappers

Those wroappers are nice, but do not really add much value.

5 years agoam335x: Add pocketbeagle DTS to the build
manu [Wed, 15 Aug 2018 21:47:03 +0000 (21:47 +0000)]
am335x: Add pocketbeagle DTS to the build

U-Boot works for this board since 2018.07 and the DTS is now present
in the tree.

5 years agolibsa: zfs_probe() needs to set spa to NULL
tsoome [Wed, 15 Aug 2018 21:38:06 +0000 (21:38 +0000)]
libsa: zfs_probe() needs to set spa to NULL

Silence the warning about possibly uninitialized use of spa.

5 years agocxgbe(4): Use VLAN_TRUNKDEV instead of private cookie to figure out the
np [Wed, 15 Aug 2018 21:24:05 +0000 (21:24 +0000)]
cxgbe(4): Use VLAN_TRUNKDEV instead of private cookie to figure out the
parent of a VLAN ifnet.

MFC after: 1 week
Sponsored by: Chelsio Communications

5 years agolibi386: remove BD_SUPPORT_FRAGS
tsoome [Wed, 15 Aug 2018 21:21:16 +0000 (21:21 +0000)]
libi386: remove BD_SUPPORT_FRAGS

BD_SUPPORT_FRAGS is preprocessor knob to allow partial reads in bioscd/biosdisk
level. However, we already have support for partial reads in bcache, and there
is no need to have duplication via preprocessor controls.

Note that bioscd/biosdisk interface is assumed to perform IO in 512B blocks,
so the only translation we have to do is 512 <-> native block size.

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

5 years agopkgfs_init: Initialize pkg
kevans [Wed, 15 Aug 2018 21:13:10 +0000 (21:13 +0000)]
pkgfs_init: Initialize pkg

new_package may not set *pp if it errors out, leaving pkg uninitialized.

Reported by: GCC

5 years agoFix mismerge in r337196.
mav [Wed, 15 Aug 2018 21:01:57 +0000 (21:01 +0000)]
Fix mismerge in r337196.

ZoL did the same mistake, and fixed it with separate commit 863522b1f9:

dsl_scan_scrub_cb: don't double-account non-embedded blocks

We were doing count_block() twice inside this function, once
unconditionally at the beginning (intended to catch the embedded block
case) and once near the end after processing the block.

The double-accounting caused the "zpool scrub" progress statistics in
"zpool status" to climb from 0% to 200% instead of 0% to 100%, and
showed double the I/O rate it was actually seeing.

This was apparently a regression introduced in commit 00c405b4b5e8,
which was an incorrect port of this OpenZFS commit:

    https://github.com/openzfs/openzfs/commit/d8a447a7

Reviewed by: Thomas Caputi <tcaputi@datto.com>
Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
Closes #7720
Closes #7738

Reported by: sef

5 years agodd(1): Kill off duplicate progress definition following r337865
kevans [Wed, 15 Aug 2018 20:50:38 +0000 (20:50 +0000)]
dd(1): Kill off duplicate progress definition following r337865

Reported by: mmacy

5 years agostand: Use -Oz/-Os for all loader/stand builds.
imp [Wed, 15 Aug 2018 20:31:11 +0000 (20:31 +0000)]
stand: Use -Oz/-Os for all loader/stand builds.

While we're not super size constrained, the x86 BIOS /boot/loader has
to be less than about 520k-530k to be reliable. The LUA loader is at
this size today. -Oz saves 15-20% on the size, keeping us safely small
enough (comparable to where we were with the 4th loader). This will
also help with sjg's work on bringing in bearssl, though we may again
be looking for space in the LUA loader.

Size table for clang 6.0.0:
default -O1 -Os -Oz
4th 442368 417792 389120 376832
lua 524288 479232 446464 430080

Tested by: kevans91@ (ubldr on armv7), dhw@ (loader on amdy64)
Differential Revision: https://reviews.freebsd.org/D16724

5 years agoDon't let clobber jailparam values when checking for modification of
jamie [Wed, 15 Aug 2018 20:23:17 +0000 (20:23 +0000)]
Don't let clobber jailparam values when checking for modification of
init-only parameters.

Compare string parameter values with strncmp, not memcmp.

PR: 230487
Reported by: Jason Mader
MFC after: 3 days

5 years agoFix in6_multi double free
mmacy [Wed, 15 Aug 2018 20:23:08 +0000 (20:23 +0000)]
Fix in6_multi double free

This is actually several different bugs:
- The code is not designed to handle inpcb deletion after interface deletion
  - add reference for inpcb membership
- The multicast address has to be removed from interface lists when the refcount
  goes to zero OR when the interface goes away
  - decouple list disconnect from refcount (v6 only for now)
- ifmultiaddr can exist past being on interface lists
  - add flag for tracking whether or not it's enqueued
- deferring freeing moptions makes the incpb cleanup code simpler but opens the
  door wider still to races
  - call inp_gcmoptions synchronously after dropping the the inpcb lock

Fundamentally multicast needs a rewrite - but keep applying band-aids for now.

Tested by: kp
Reported by: novel, kp, lwhsu

5 years agodd: Incorporate some changes from imp for status=progress
kevans [Wed, 15 Aug 2018 19:46:13 +0000 (19:46 +0000)]
dd: Incorporate some changes from imp for status=progress

Notable changes from what landed in r337505:
- sigalarm handler isn't setup unless we're actually using it
- Humanized versions of the amount of data transferred in the progress
  update

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

5 years agoAdd post-mortem note to UPDATING about r337506
kevans [Wed, 15 Aug 2018 19:28:48 +0000 (19:28 +0000)]
Add post-mortem note to UPDATING about r337506

MFC after: 3 days

5 years ago- Add exec hook "exec.created". This is called when the jail is
netchild [Wed, 15 Aug 2018 18:35:42 +0000 (18:35 +0000)]
- Add exec hook "exec.created". This is called when the jail is
  created and before exec.start is called. [1]
- Bump __FreeBSD_version.

This allows to attach ZFS datasets and various other things to be
done before any command/service/rc-script is started in the new
jail.

PR: 228066 [1]
Reviewed by: jamie [1]
Submitted by: Stefan Grönke <stefan@gronke.net> [1]
Differential Revision: https://reviews.freebsd.org/D15330 [1]

5 years agoindent(1): bug fix after r336333
pstef [Wed, 15 Aug 2018 18:19:45 +0000 (18:19 +0000)]
indent(1): bug fix after r336333

The bug was that isalnum() is not exactly equivalent to previous code which
also allowed characters "$" and "_", so check for those explicitly.

Reported by: tuexen@

5 years agoFUSE: Document global sysctl knobs
cem [Wed, 15 Aug 2018 17:41:19 +0000 (17:41 +0000)]
FUSE: Document global sysctl knobs

So that I don't have to keep grepping around the codebase to remember what each
one does.  And maybe it saves someone else some time.

Fix a trivial whitespace issue while here.

No functional change.

Sponsored by: Dell EMC Isilon

5 years agoFix a typo in comment.
loos [Wed, 15 Aug 2018 16:36:29 +0000 (16:36 +0000)]
Fix a typo in comment.

MFC after: 3 days
X-MFC with: r321316
Sponsored by: Rubicon Communications, LLC (Netgate)

5 years agoFix build after r337849
brd [Wed, 15 Aug 2018 16:22:12 +0000 (16:22 +0000)]
Fix build after r337849

This moves the symlink creation to after where the files are installed.

This also inverts the shell change so that it only happens if MK_TCSH is on.

Approved by: will (mentor)
Differential Revision: https://reviews.freebsd.org/D16725

5 years agoLate style follow up on r312770.
loos [Wed, 15 Aug 2018 15:44:30 +0000 (15:44 +0000)]
Late style follow up on r312770.

Submitted by: glebius
X-MFC with: r312770
MFC after: 3 days

5 years agoRemove pmap_kenter_section from the arm pmap. It's unused.
andrew [Wed, 15 Aug 2018 14:57:34 +0000 (14:57 +0000)]
Remove pmap_kenter_section from the arm pmap. It's unused.

Sponsored by: DARPA, AFRL

5 years agoMove ssh config file handling into the ssh Makefiles.
brd [Wed, 15 Aug 2018 14:53:42 +0000 (14:53 +0000)]
Move ssh config file handling into the ssh Makefiles.

This helps with pkgbase by using CONFS and tagging these as config files.

Approved by: allanjude (mentor), des
Differential Revision: https://reviews.freebsd.org/D16678

5 years agoRemove ARM_HAVE_SUPERSECTIONS. It was only supported on some XScale CPUs.
andrew [Wed, 15 Aug 2018 14:52:56 +0000 (14:52 +0000)]
Remove ARM_HAVE_SUPERSECTIONS. It was only supported on some XScale CPUs.

Sponsored by: DARPA, AFRL

5 years agoMake code and data only used within the arm pmap code as static.
andrew [Wed, 15 Aug 2018 14:45:01 +0000 (14:45 +0000)]
Make code and data only used within the arm pmap code as static.

Sponsored by: DARPA, AFRL

5 years agoMove all sh and csh files into bin/sh/ or bin/csh/
brd [Wed, 15 Aug 2018 14:41:24 +0000 (14:41 +0000)]
Move all sh and csh files into bin/sh/ or bin/csh/

This simplifies pkgbase by migrating these to CONFS so they are properly
tagged as config files.

Approved by: will (mentor)
Differential Revision: https://reviews.freebsd.org/D16708

5 years agoRemove arm pmap variables that are only ever set and never read.
andrew [Wed, 15 Aug 2018 14:29:04 +0000 (14:29 +0000)]
Remove arm pmap variables that are only ever set and never read.

Sponsored by: DARPA, AFRL

5 years agoRemove ARM_MMU_GENERIC, it's the only ARMV4/v5 MMU we support.
andrew [Wed, 15 Aug 2018 14:19:07 +0000 (14:19 +0000)]
Remove ARM_MMU_GENERIC, it's the only ARMV4/v5 MMU we support.

Sponsored by: DARPA, AFRL

5 years agoRemove the ARMv5 pmap function pointers. These were to support XScale so
andrew [Wed, 15 Aug 2018 13:52:31 +0000 (13:52 +0000)]
Remove the ARMv5 pmap function pointers. These were to support XScale so
are now unused.

Sponsored by: DARPA, AFRL

5 years agoRemove checks for now unsupported CPU_* values in arm headers.
andrew [Wed, 15 Aug 2018 13:48:59 +0000 (13:48 +0000)]
Remove checks for now unsupported CPU_* values in arm headers.

Sponsored by: DARPA, AFRL

5 years agoThe interface name must be sanitized before the search to match the existing
loos [Wed, 15 Aug 2018 13:42:22 +0000 (13:42 +0000)]
The interface name must be sanitized before the search to match the existing
netgraph node.

Fixes the search (and use) of VLANs with dot notation.

Obtained from: pfSense
Sponsored by: Rubicon Communications, LLC (Netgate)

5 years agoStart to remove XScale support from the ARMv4/v5 pmap. Support for XScale
andrew [Wed, 15 Aug 2018 13:40:16 +0000 (13:40 +0000)]
Start to remove XScale support from the ARMv4/v5 pmap. Support for XScale
has been removed from the kernel so we can remove it from here to help
simplify the code.

Sponsored by: DARPA, AFRL

5 years agoSet the Execute Never flags in EFI device memory as required by the ARMv8
andrew [Wed, 15 Aug 2018 13:19:15 +0000 (13:19 +0000)]
Set the Execute Never flags in EFI device memory as required by the ARMv8
spec.

Sponsored by: DARPA, AFRL

5 years agoRemove PHYSADDR from kernel configurations that don't need it. The only
andrew [Wed, 15 Aug 2018 13:13:19 +0000 (13:13 +0000)]
Remove PHYSADDR from kernel configurations that don't need it. The only
place we need to set it is when we also have FLASHADDR set.

Sponsored by: DARPA, AFRL

5 years agozfs: add ztest to the kyua test suite.
will [Wed, 15 Aug 2018 13:05:04 +0000 (13:05 +0000)]
zfs: add ztest to the kyua test suite.

This program is currently failing, and has been for >6 months on HEAD.
Ideally, this should be run 24x7 in CI, to discover hard-to-find bugs that
only manifest with concurrent i/o.

Requested by: lwhsu, mmacy

5 years agoRemove the VIRT armv7 kernel config. It is supported by GENERIC.
andrew [Wed, 15 Aug 2018 13:03:01 +0000 (13:03 +0000)]
Remove the VIRT armv7 kernel config. It is supported by GENERIC.

Sponsored by: DARPA, AFRL

5 years agoFix early EFIRT on PCID machines after r337773.
kib [Wed, 15 Aug 2018 12:48:49 +0000 (12:48 +0000)]
Fix early EFIRT on PCID machines after r337773.

Ensure that the valid PCID state is created for proc0 pmap, since it
might be used by efirt enter() before first context switch on the BSP.

Sponsored by: The FreeBSD Foundation
MFC after: 6 days

5 years agoIn the help message at the mountroot prompt, suggest something that
trasz [Wed, 15 Aug 2018 12:12:21 +0000 (12:12 +0000)]
In the help message at the mountroot prompt, suggest something that
actually works and matches the bsdinstall(8) default.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years agoImprove formatting.
trasz [Wed, 15 Aug 2018 11:39:13 +0000 (11:39 +0000)]
Improve formatting.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years agomake.conf(5): Note that src.conf should not be used for ports and documentation.
0mp [Wed, 15 Aug 2018 10:45:24 +0000 (10:45 +0000)]
make.conf(5): Note that src.conf should not be used for ports and documentation.

Reviewed by: bcr, kevans, krion, matthew
Approved by: krion (mentor)
Differential Revision: https://reviews.freebsd.org/D15177

5 years agoAdd SECURITY section to loader(8).
trasz [Wed, 15 Aug 2018 08:45:05 +0000 (08:45 +0000)]
Add SECURITY section to loader(8).

Reviewed by: bcr, jilles, imp (earlier version)
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D16700

5 years agocd9660 pointer sign issues and missing __packed attribute
tsoome [Wed, 15 Aug 2018 06:42:31 +0000 (06:42 +0000)]
cd9660 pointer sign issues and missing __packed attribute

The isonum_* functions are defined to take unsigend char* as an argument,
but the structure fields are defined as char. Change to u_char where needed.

Probably the full structure should be changed, but I'm not sure about the
side affects.

While there, add __packed attribute.

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

5 years agocxgbe(4): Use two hashes instead of a table to keep track of
np [Wed, 15 Aug 2018 03:03:01 +0000 (03:03 +0000)]
cxgbe(4): Use two hashes instead of a table to keep track of
hashfilters.  Two because the driver needs to look up a hashfilter by
its 4-tuple or tid.

A couple of fixes while here:
- Reject attempts to add duplicate hashfilters.
- Do not assume that any part of the 4-tuple that isn't specified is 0.
  This makes it consistent with all other mandatory parameters that
  already require explicit user input.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

5 years agoFlesh out a comment about what we're doing with read bias and trims.
imp [Wed, 15 Aug 2018 00:15:40 +0000 (00:15 +0000)]
Flesh out a comment about what we're doing with read bias and trims.

Sponsored by: Netflix

5 years agoarm/ralink cleanup
imp [Tue, 14 Aug 2018 20:45:43 +0000 (20:45 +0000)]
arm/ralink cleanup

Remove the non-INTRNG code.
Remove left over cut and paste code from the lpc code that was the start for the port.
Set KERNPHYSADDR and KERNVIRTADDR

Tested on Buffalo_WZR2-G300N

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

5 years agoFix a broken "SEE ALSO" section of hlfsd(8).
0mp [Tue, 14 Aug 2018 20:33:48 +0000 (20:33 +0000)]
Fix a broken "SEE ALSO" section of hlfsd(8).

While here pet mandoc and igor.

Reviewed by: bcr, eadler, krion, mat
Approved by: krion (mentor), mat (mentor)
Differential Revision: https://reviews.freebsd.org/D16376

5 years agoFix a couple whitespace errors in r337814.
dab [Tue, 14 Aug 2018 20:26:54 +0000 (20:26 +0000)]
Fix a couple whitespace errors in r337814.

Reported by: Renato Botelho <garga.bsd@gmail.com>
MFC after: 3 days
X-MFC-with: r337814
Sponsored by: Dell EMC

5 years agoMFV r337818:
cy [Tue, 14 Aug 2018 20:24:10 +0000 (20:24 +0000)]
MFV r337818:

WPA: Ignore unauthenticated encrypted EAPOL-Key data

Ignore unauthenticated encrypted EAPOL-Key data in supplicant
processing. When using WPA2, these are frames that have the Encrypted
flag set, but not the MIC flag.

When using WPA2, EAPOL-Key frames that had the Encrypted flag set but
not the MIC flag, had their data field decrypted without first verifying
the MIC. In case the data field was encrypted using RC4 (i.e., when
negotiating TKIP as the pairwise cipher), this meant that
unauthenticated but decrypted data would then be processed. An adversary
could abuse this as a decryption oracle to recover sensitive information
in the data field of EAPOL-Key messages (e.g., the group key).
(CVE-2018-14526)

Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
Obtained from:  git://w1.fi/hostap.git
MFC after:      1 day
Security:       CVE-2018-14526
Security:       VuXML: 6bedc863-9fbe-11e8-945f-206a8a720317

5 years agoFix several (more) memory leaks.
dab [Tue, 14 Aug 2018 19:31:06 +0000 (19:31 +0000)]
Fix several (more) memory leaks.

A follow-up to r337812 to catch a couple more memory leaks that should
have been included in that change.

Reported by: Coverity
CID: 12960641296067 (for real this time)
MFC after: 3 days
X-MFC-with: r337812
Sponsored by: Dell EMC

5 years agoHelp ensure that the copy loop doesn't get converted to a memcpy() call.
markj [Tue, 14 Aug 2018 19:21:31 +0000 (19:21 +0000)]
Help ensure that the copy loop doesn't get converted to a memcpy() call.

Reported and reviewed by: kib
X-MFC with: r337715
Sponsored by: The FreeBSD Foundation

5 years agoFix several memory leaks.
dab [Tue, 14 Aug 2018 19:12:45 +0000 (19:12 +0000)]
Fix several memory leaks.

The libkqueue tests have several places that leak memory by using an
idiom like:

puts(kevent_to_str(kevp));

Rework to save the pointer returned from kevent_to_str() and then
free() it after it has been used.

Reported by: asomers (pointer to Coverity), Coverity
CID: 1296063129606412960651296066129606713502871394960
Sponsored by: Dell EMC

5 years agoDisable the auto negotiation if the port is set to fixed-link.
loos [Tue, 14 Aug 2018 18:58:16 +0000 (18:58 +0000)]
Disable the auto negotiation if the port is set to fixed-link.

Tested on SG-3100 (ARMADA38X) and Espresso.bin (A37x0).  Fixes the network
on espresso.bin.

Sponsored by: Rubicon Communications, LLC (Netgate)

5 years agoMFV r337586: lua: Update to 5.3.5
kevans [Tue, 14 Aug 2018 18:58:01 +0000 (18:58 +0000)]
MFV r337586: lua: Update to 5.3.5

Bugfix release, nothing too major.

Tested with: lualoader via userboot, lualoader live
Differential Revision: https://reviews.freebsd.org/D16665

5 years agoFor our INT64 implementation, we can compare integers and numbers
imp [Tue, 14 Aug 2018 18:45:25 +0000 (18:45 +0000)]
For our INT64 implementation, we can compare integers and numbers
directly because they are the same thing.

Reviewed by: kevans@

5 years agoWhen the LUA floating point model is INT64, we don't need to do the
imp [Tue, 14 Aug 2018 18:45:20 +0000 (18:45 +0000)]
When the LUA floating point model is INT64, we don't need to do the
overflow dance. This avoids compile errors on latter-day gcc compilers
as well as simplifies the generated code.

Reviewed by: kevans@

5 years agoPrevent a wanring about checkdp being unused. It's not needed when we
imp [Tue, 14 Aug 2018 18:45:16 +0000 (18:45 +0000)]
Prevent a wanring about checkdp being unused. It's not needed when we
have INT64 floats and somehow snuck through unused until now.

Reviewed by: kevans@

5 years agoCreate a loader for each interpreter for x86 BIOS and all EFI
imp [Tue, 14 Aug 2018 18:44:41 +0000 (18:44 +0000)]
Create a loader for each interpreter for x86 BIOS and all EFI

Create loader_{4th,lua,simp}{,.efi}. All of these are installed by
default. Create LOADER_DEFAULT_INTERP to specify the default
interpreter when no other is specified. LOADER_INTERP is the current
interpreter language building. Turn building of lua on by default to
match 4th. simploader is a simplified loader build w/o any interpreter
language (but with a simple loader).  This is the historic behavir you
got with WITHOUT_FORTH. Make a hard link to the default loader. This
has to be a hard link rather than the more desirable soft link because
older zfsboot blocks don't support symlinks.

RelNotes: Yes
Differential Revision: https://reviews.freebsd.org/D16705

5 years agobectl(8): Check jailparam_* return values
kevans [Tue, 14 Aug 2018 18:35:33 +0000 (18:35 +0000)]
bectl(8): Check jailparam_* return values

Previous iteration of this assumed that these won't fail because we've
already setup the jail param to this point, but the allocations could still
fail in pretty bad conditions.

Admit that it's possible and return (ENOENT, EINVAL, ENOMEM, or 0) when
deleting arguments. EINVAL shouldn't happen since we're passing optarg;
which may satisfy *optarg == '\0' but never optarg == NULL.

CID: 13948851394901

5 years agolibbe(3): Fix leaky faucets
kevans [Tue, 14 Aug 2018 18:11:06 +0000 (18:11 +0000)]
libbe(3): Fix leaky faucets

Amongst them:
- Resource leaks
- Logically dead code
- Unused values
- Null termination issues

Reported by: asomers (pointer to Coverity), Coverity
CID: 139477713947911394830139484413948721394894,
CID: 1394900139490713949501394965

5 years agoMerge OpenSSL 1.0.2p.
jkim [Tue, 14 Aug 2018 17:48:02 +0000 (17:48 +0000)]
Merge OpenSSL 1.0.2p.

5 years agoUpdate the inet(4) and inet6(4) man pages to reflect the changes made
jtl [Tue, 14 Aug 2018 17:36:21 +0000 (17:36 +0000)]
Update the inet(4) and inet6(4) man pages to reflect the changes made
to the reassembly code in r337778, r337780, r337781, r337782, and
r337783.

Security: FreeBSD-SA-18:10.ip
Security: CVE-2018-6923

5 years agoLower the default limits on the IPv6 reassembly queue.
jtl [Tue, 14 Aug 2018 17:32:07 +0000 (17:32 +0000)]
Lower the default limits on the IPv6 reassembly queue.

Currently, the limits are quite high. On machines with millions of
mbuf clusters, the reassembly queue limits can also run into
the millions. Lower these values.

Also, try to ensure that no bucket will have a reassembly
queue larger than approximately 100 items. This limits the cost to
find the correct reassembly queue when processing an incoming
fragment.

Due to the low limits on each bucket's length, increase the size of
the hash table from 64 to 1024.

Reviewed by: jhb
Security: FreeBSD-SA-18:10.ip
Security: CVE-2018-6923

5 years agoLower the default limits on the IPv4 reassembly queue.
jtl [Tue, 14 Aug 2018 17:30:46 +0000 (17:30 +0000)]
Lower the default limits on the IPv4 reassembly queue.

In particular, try to ensure that no bucket will have a reassembly
queue larger than approximately 100 items. This limits the cost to
find the correct reassembly queue when processing an incoming
fragment.

Due to the low limits on each bucket's length, increase the size of
the hash table from 64 to 1024.

Reviewed by: jhb
Security: FreeBSD-SA-18:10.ip
Security: CVE-2018-6923

5 years agoProvide part of the mitigation for L1TF-VMM.
kib [Tue, 14 Aug 2018 17:29:41 +0000 (17:29 +0000)]
Provide part of the mitigation for L1TF-VMM.

On the guest entry in bhyve, flush L1 data cache, using either L1D
flush command MSR if available, or by reading enough uninteresting
data to fill whole cache.

Flush is automatically enabled on CPUs which do not report RDCL_NO,
and can be disabled with the hw.vmm.l1d_flush tunable/kenv.

Security: CVE-2018-3646
Reviewed by: emaste. jhb, Tony Luck <tony.luck@intel.com>
Sponsored by: The FreeBSD Foundation

5 years agoDrop 0-byte IPv6 fragments.
jtl [Tue, 14 Aug 2018 17:29:22 +0000 (17:29 +0000)]
Drop 0-byte IPv6 fragments.

Currently, we process IPv6 fragments with 0 bytes of payload, add them
to the reassembly queue, and do not recognize them as duplicating or
overlapping with adjacent 0-byte fragments. An attacker can exploit this
to create long fragment queues.

There is no legitimate reason for a fragment with no payload. However,
because IPv6 packets with an empty payload are acceptable, allow an
"atomic" fragment with no payload.

Reviewed by: jhb
Security: FreeBSD-SA-18:10.ip
Security: CVE-2018-6923

5 years agoImplement a limit on on the number of IPv6 reassembly queues per bucket.
jtl [Tue, 14 Aug 2018 17:27:41 +0000 (17:27 +0000)]
Implement a limit on on the number of IPv6 reassembly queues per bucket.

There is a hashing algorithm which should distribute IPv6 reassembly
queues across the available buckets in a relatively even way. However,
if there is a flaw in the hashing algorithm which allows a large number
of IPv6 fragment reassembly queues to end up in a single bucket, a per-
bucket limit could help mitigate the performance impact of this flaw.

Implement such a limit, with a default of twice the maximum number of
reassembly queues divided by the number of buckets. Recalculate the
limit any time the maximum number of reassembly queues changes.
However, allow the user to override the value using a sysctl
(net.inet6.ip6.maxfragbucketsize).

Reviewed by: jhb
Security: FreeBSD-SA-18:10.ip
Security: CVE-2018-6923

5 years agoAdd a limit of the number of fragments per IPv6 packet.
jtl [Tue, 14 Aug 2018 17:26:07 +0000 (17:26 +0000)]
Add a limit of the number of fragments per IPv6 packet.

The IPv4 fragment reassembly code supports a limit on the number of
fragments per packet. The default limit is currently 17 fragments.
Among other things, this limit serves to limit the number of fragments
the code must parse when trying to reassembly a packet.

Add a limit to the IPv6 reassembly code. By default, limit a packet
to 65 fragments (64 on the queue, plus one final fragment to complete
the packet). This allows an average fragment size of 1,008 bytes, which
should be sufficient to hold a fragment. (Recall that the IPv6 minimum
MTU is 1280 bytes. Therefore, this configuration allows a full-size
IPv6 packet to be fragmented on a link with the minimum MTU and still
carry approximately 272 bytes of headers before the fragmented portion
of the packet.)

Users can adjust this limit using the net.inet6.ip6.maxfragsperpacket
sysctl.

Reviewed by: jhb
Security: FreeBSD-SA-18:10.ip
Security: CVE-2018-6923

5 years agoMake the IPv6 fragment limits be global, rather than per-VNET, limits.
jtl [Tue, 14 Aug 2018 17:24:26 +0000 (17:24 +0000)]
Make the IPv6 fragment limits be global, rather than per-VNET, limits.

The IPv6 reassembly fragment limit is based on the number of mbuf clusters,
which are a global resource. However, the limit is currently applied
on a per-VNET basis. Given enough VNETs (or given sufficient customization
on enough VNETs), it is possible that the sum of all the VNET fragment
limits will exceed the number of mbuf clusters available in the system.

Given the fact that the fragment limits are intended (at least in part) to
regulate access to a global resource, the IPv6 fragment limit should
be applied on a global basis.

Note that it is still possible to disable fragmentation for a particular
VNET by setting the net.inet6.ip6.maxfragpackets sysctl to 0 for that
VNET. In addition, it is now possible to disable fragmentation globally
by setting the net.inet6.ip6.maxfrags sysctl to 0.

Reviewed by: jhb
Security: FreeBSD-SA-18:10.ip
Security: CVE-2018-6923

5 years agoImplement a limit on on the number of IPv4 reassembly queues per bucket.
jtl [Tue, 14 Aug 2018 17:23:05 +0000 (17:23 +0000)]
Implement a limit on on the number of IPv4 reassembly queues per bucket.

There is a hashing algorithm which should distribute IPv4 reassembly
queues across the available buckets in a relatively even way. However,
if there is a flaw in the hashing algorithm which allows a large number
of IPv4 fragment reassembly queues to end up in a single bucket, a per-
bucket limit could help mitigate the performance impact of this flaw.

Implement such a limit, with a default of twice the maximum number of
reassembly queues divided by the number of buckets. Recalculate the
limit any time the maximum number of reassembly queues changes.
However, allow the user to override the value using a sysctl
(net.inet.ip.maxfragbucketsize).

Reviewed by: jhb
Security: FreeBSD-SA-18:10.ip
Security: CVE-2018-6923

5 years agotftp: Close a resource leak when putting files
asomers [Tue, 14 Aug 2018 17:20:31 +0000 (17:20 +0000)]
tftp: Close a resource leak when putting files

Reported by: Coverity
CID: 1394842
MFC after: 2 weeks

5 years agoAdd a global limit on the number of IPv4 fragments.
jtl [Tue, 14 Aug 2018 17:19:49 +0000 (17:19 +0000)]
Add a global limit on the number of IPv4 fragments.

The IP reassembly fragment limit is based on the number of mbuf clusters,
which are a global resource. However, the limit is currently applied
on a per-VNET basis. Given enough VNETs (or given sufficient customization
of enough VNETs), it is possible that the sum of all the VNET limits
will exceed the number of mbuf clusters available in the system.

Given the fact that the fragment limit is intended (at least in part) to
regulate access to a global resource, the fragment limit should
be applied on a global basis.

VNET-specific limits can be adjusted by modifying the
net.inet.ip.maxfragpackets and net.inet.ip.maxfragsperpacket
sysctls.

To disable fragment reassembly globally, set net.inet.ip.maxfrags to 0.
To disable fragment reassembly for a particular VNET, set
net.inet.ip.maxfragpackets to 0.

Reviewed by: jhb
Security: FreeBSD-SA-18:10.ip
Security: CVE-2018-6923

5 years agoAdd definitions related to the L1D flush operation capability and MSR.
kib [Tue, 14 Aug 2018 17:19:11 +0000 (17:19 +0000)]
Add definitions related to the L1D flush operation capability and MSR.

Sponsored by: The FreeBSD Foundation

5 years agoImprove IPv6 reassembly performance by hashing fragments into buckets.
jtl [Tue, 14 Aug 2018 17:17:37 +0000 (17:17 +0000)]
Improve IPv6 reassembly performance by hashing fragments into buckets.

Currently, all IPv6 fragment reassembly queues are kept in a flat
linked list. This has a number of implications. Two significant
implications are: all reassembly operations share a common lock,
and it is possible for the linked list to grow quite large.

Improve IPv6 reassembly performance by hashing fragments into buckets,
each of which has its own lock. Calculate the hash key using a Jenkins
hash with a random seed.

Reviewed by: jhb
Security: FreeBSD-SA-18:10.ip
Security: CVE-2018-6923

5 years agoImprove hashing of IPv4 fragments.
jtl [Tue, 14 Aug 2018 17:15:47 +0000 (17:15 +0000)]
Improve hashing of IPv4 fragments.

Currently, IPv4 fragments are hashed into buckets based on a 32-bit
key which is calculated by (src_ip ^ ip_id) and combined with a random
seed. However, because an attacker can control the values of src_ip
and ip_id, it is possible to construct an attack which causes very
deep chains to form in a given bucket.

To ensure more uniform distribution (and lower predictability for
an attacker), calculate the hash based on a key which includes all
the fields we use to identify a reassembly queue (dst_ip, src_ip,
ip_id, and the ip protocol) as well as a random seed.

Reviewed by: jhb
Security: FreeBSD-SA-18:10.ip
Security: CVE-2018-6923

5 years agoReserve page at the physical address zero on amd64.
kib [Tue, 14 Aug 2018 17:14:33 +0000 (17:14 +0000)]
Reserve page at the physical address zero on amd64.

We always zero the invalidated PTE/PDE for superpage, which means that
L1TF CPU vulnerability (CVE-2018-3620) can be only used for reading
from the page at zero.

Note that both i386 and amd64 exclude the page from phys_avail[]
array, so this change is redundant, but I think that phys_avail[] on
UEFI-boot does not need to do that.  Eventually the blacklisting
should be made conditional on CPUs which report that they are not
vulnerable to L1TF.

Reviewed by: emaste. jhb
Sponsored by: The FreeBSD Foundation

5 years agoamd64: ensure that curproc->p_vmspace pmap always matches PCPU
kib [Tue, 14 Aug 2018 16:37:14 +0000 (16:37 +0000)]
amd64: ensure that curproc->p_vmspace pmap always matches PCPU
curpmap.

When performing context switch on a machine without PCID, if current
%cr3 equals to the new pmap %cr3, which is typical for kernel_pmap
vs. kernel process, I overlooked to update PCPU curpmap value.  Remove
check for %cr3 not equal to pm_cr3 for doing the update.  It is
believed that this case cannot happen at all, due to other changes in
this revision.

Also, do not set the very first curpmap to kernel_pmap, it should be
vmspace0 pmap instead to match curproc.

Move the common code to activate the initial pmap both on BSP and APs
into pmap_activate_boot() helper.

Reported by: eadler, ambrisko
Discussed with: kevans
Reviewed by: alc, markj (previous version)
Tested by: ambrisko (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D16618

5 years agoAdd support to the Marvell Xenon SDHCI controller.
loos [Tue, 14 Aug 2018 16:33:30 +0000 (16:33 +0000)]
Add support to the Marvell Xenon SDHCI controller.

Tested on Espresso.bin (37x0) and Macchiato.bin (8k) with SD cards and
eMMCs.

Obtained from: pfSense
Sponsored by: Rubicon Communications, LLC (Netgate)

5 years agoQuery MVPConf0.PVPE for number of CPUs.
br [Tue, 14 Aug 2018 16:29:10 +0000 (16:29 +0000)]
Query MVPConf0.PVPE for number of CPUs.

Rather than hard-coding the number of CPUs to 2, look up the PVPE field
in MVPConf0, as the valid VPE numbers are from 0 to PVPE inclusive.

Submitted by: "James Clarke" <jrtc4@cam.ac.uk>
Reviewed by: br
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D16644

5 years agoFix typo.
kib [Tue, 14 Aug 2018 16:27:17 +0000 (16:27 +0000)]
Fix typo.

Noted by: alc
MFC after: 3 days

5 years agoAvoid repeated address calculation for malta_ap_boot.
br [Tue, 14 Aug 2018 16:26:44 +0000 (16:26 +0000)]
Avoid repeated address calculation for malta_ap_boot.

Submitted by: "James Clarke" <jrtc4@cam.ac.uk>
Reviewed by: br, arichardson
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D16655

5 years agoRemove unused code.
br [Tue, 14 Aug 2018 16:22:14 +0000 (16:22 +0000)]
Remove unused code.

Sponsored by: DARPA, AFRL

5 years agoImport OpenSSL 1.0.2p.
jkim [Tue, 14 Aug 2018 16:18:14 +0000 (16:18 +0000)]
Import OpenSSL 1.0.2p.

5 years agoRewrite RISC-V disassembler:
br [Tue, 14 Aug 2018 16:03:03 +0000 (16:03 +0000)]
Rewrite RISC-V disassembler:
- Use macroses from encoding.h generated by riscv-opcodes.
- Add support for C-compressed ISA extension.

Sponsored by: DARPA, AFRL

5 years agoRemove cpu_pfr from arm. It's unused.
andrew [Tue, 14 Aug 2018 16:01:25 +0000 (16:01 +0000)]
Remove cpu_pfr from arm. It's unused.

5 years agoRemove an old comment now the code it references has been removed.
andrew [Tue, 14 Aug 2018 15:48:13 +0000 (15:48 +0000)]
Remove an old comment now the code it references has been removed.

5 years agoFix the spelling of armv4_idcache_inv_all in an END macro.
andrew [Tue, 14 Aug 2018 15:42:27 +0000 (15:42 +0000)]
Fix the spelling of armv4_idcache_inv_all in an END macro.

5 years agoUse the correct PTE when changing the attribute of multiple pages.
loos [Tue, 14 Aug 2018 15:27:50 +0000 (15:27 +0000)]
Use the correct PTE when changing the attribute of multiple pages.

Submitted by: andrew (long time ago)
Sponsored by: Rubicon Communications, LLC (Netgate)

5 years agoExplain why we aren't using memcpy().
markj [Tue, 14 Aug 2018 14:50:06 +0000 (14:50 +0000)]
Explain why we aren't using memcpy().

Reported by: jmg
X-MFC with: r337715
Sponsored by: The FreeBSD Foundation

5 years agoDon't use memcpy() in the early microcode loading code.
markj [Tue, 14 Aug 2018 14:02:53 +0000 (14:02 +0000)]
Don't use memcpy() in the early microcode loading code.

At some point memcpy() may be an ifunc, ifunc resolution cannot be done
until CPU identification has been performed, and CPU identification must
be done after loading any microcode updates.

X-MFC with: r337715
Sponsored by: The FreeBSD Foundation

5 years agoFix a typo on the PSCI smc call wrapper.
loos [Tue, 14 Aug 2018 13:56:49 +0000 (13:56 +0000)]
Fix a typo on the PSCI smc call wrapper.

Looks good from: andrew
Sponsored by: Rubicon Communications, LLC (Netgate)

5 years agoFix the !SMP x86 build.
markj [Tue, 14 Aug 2018 13:56:42 +0000 (13:56 +0000)]
Fix the !SMP x86 build.

Reported by: Michael Butler <imb@protected-networks.net>
X-MFC with: r337715
Sponsored by: The FreeBSD Foundation

5 years agoAdd good description of init and lock devices from sio to uart.
imp [Tue, 14 Aug 2018 13:52:10 +0000 (13:52 +0000)]
Add good description of init and lock devices from sio to uart.

5 years agoAdd the "autoro" flag to /media. This makes it attempt to mount
trasz [Tue, 14 Aug 2018 13:52:08 +0000 (13:52 +0000)]
Add the "autoro" flag to /media.  This makes it attempt to mount
it read-only instead of just failing if the media is write-protected.

The /net doesn't seem to require the flag.

MFC after: 2 weeks
Relnotes: yes
Sponsored by: DARPA, AFRL

5 years agoMFV r337744:
mm [Tue, 14 Aug 2018 11:42:32 +0000 (11:42 +0000)]
MFV r337744:
Sync libarchive with vendor..

Vendor changes:
  PR #1042: validate iso9660 directory record length

MFC after: 3 days
Security: CVE-2017-14501

5 years agoAdd init_exec kenv(1) variable, to make init(8) execute a file
trasz [Tue, 14 Aug 2018 11:01:52 +0000 (11:01 +0000)]
Add init_exec kenv(1) variable, to make init(8) execute a file
after opening the console, replacing init as PID 1.

From the user point of view, it makes it possible to run eg the
shell as PID 1, using 'set init_exec=/bin/sh' at the loader(8)
prompt.

Reviewed by: kib
MFC after: 2 weeks
Relnotes: yes
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D16625

5 years agoSupport reading from the arm64 ID registers from userspace.
andrew [Tue, 14 Aug 2018 11:00:54 +0000 (11:00 +0000)]
Support reading from the arm64 ID registers from userspace.

Trap reads to the arm64 ID registers and write a safe value into them. This
will allow us to put more useful values in these later and have userland
check them to find what features the hardware supports.

These are currently safe defaults, but will later be populated with better
values from the hardware.

Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D16533

5 years agoUse a macro to set the assoc state. I missed this in r337706.
tuexen [Tue, 14 Aug 2018 08:33:47 +0000 (08:33 +0000)]
Use a macro to set the assoc state. I missed this in r337706.

5 years agoRemove a set but not used warning showing up in usrsctp.
tuexen [Tue, 14 Aug 2018 08:32:33 +0000 (08:32 +0000)]
Remove a set but not used warning showing up in usrsctp.

5 years agoRestore ability to send ICMP and ICMPv6 redirects.
ae [Tue, 14 Aug 2018 07:54:14 +0000 (07:54 +0000)]
Restore ability to send ICMP and ICMPv6 redirects.

It was lost when tryforward appeared. Now ip[6]_tryforward will be enabled
only when sending redirects for corresponding IP version is disabled via
sysctl. Otherwise will be used default forwarding function.

PR: 221137
Submitted by: mckay@
MFC after: 2 weeks

5 years agoAdd library and kernel support for AMD Family 17h counters
mmacy [Tue, 14 Aug 2018 05:18:43 +0000 (05:18 +0000)]
Add library and kernel support for AMD Family 17h counters

NB: lacks default sample rate for most counters