]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoFix copying of MEMBUFs to MEMBUFs. This case was implemented by using
bde [Mon, 8 Apr 2019 04:54:15 +0000 (04:54 +0000)]
Fix copying of MEMBUFs to MEMBUFs.  This case was implemented by using
the same code as the VIDBUF8 case, so it only worked for depths <= 8.
The 2 directions for copying between VIDBUFs and MEMBUFs worked by using
a Read/Write organization which makes the destination a VIDBUF so the
MEMBUF case was not reached, and the VIDBUF cases have already been fixed.

Fix this by removing "optimizations" for the VIDBUF8 case so that the
MEMBUF case can fall through to the general (non-segmented) case.  The
optimizations were to duplicate code for the VIDBUF8 case so as to
avoid 2 multiplications by 1 at runtime.  This optimization is not useful
since the multiplications are not in the inner loop.

Remove the same "optimization" for the VIDBUF8S case.  It was even less
useful there since it duplicated more to do relatively less.

5 years agoFix restoring the geometry when recovering from an error. Just restore the
bde [Mon, 8 Apr 2019 04:07:37 +0000 (04:07 +0000)]
Fix restoring the geometry when recovering from an error.  Just restore the
previous geometry, and don't do extra work to calculate the default geometry
so as to reset to that.

5 years agostrings: disable Casper support while building native-xtools
oshogbo [Mon, 8 Apr 2019 03:35:47 +0000 (03:35 +0000)]
strings: disable Casper support while building native-xtools

Reported by: Charlie Li
Tested by: Charlie Li

5 years agoMake RELDATE be on a single line.
imp [Sun, 7 Apr 2019 21:01:02 +0000 (21:01 +0000)]
Make RELDATE be on a single line.

All variable assignments that start in column 1 have to be on a single
line for amd to build due to as weird dependency there (most likely it
can be fixed to use the new VARS_ONLY feature, but it isn't
today). usr.sbin/amd/include/Makefile calls
usr.sbin/amd/include/newvers.sh which does:
eval `LC_ALL=C egrep '^[A-Z]+=' $1 | grep -v COPYRIGHT`
which is where that requirement comes from. It handles COPYRIGHT since
that's an exception. Rather than add additional exceptions, cope with
the long line in newvers.sh instead. Note: it no longer needs to
filter COPYRIGHT because the assignment doesn't start in column 1
anymore.

I had done a universe when I had an earlier version of r346018 that
had it as one line. When I changed it to multi-line as suggested in
the review, I only built kernels on a couple of architectures to make
sure it didn't break anything.

Add comment to newvers.sh noting this.

Obviously, this unbreaks the amd build.

5 years agoRISC-V: initialize pcpu slightly earlier
mhorne [Sun, 7 Apr 2019 20:12:24 +0000 (20:12 +0000)]
RISC-V: initialize pcpu slightly earlier

In certain scenarios, it is possible for PCPU data to be
accessed before it has been initialized (e.g. during printf
if the kernel was built with the TSLOG option).

Initialize the PCPU pointer for hart 0 at the beginning of
initriscv() rather than near the end.

Reviewed by: markj
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D19726

5 years agoUse default shell assignment rather more complicated if then
imp [Sun, 7 Apr 2019 18:39:55 +0000 (18:39 +0000)]
Use default shell assignment rather more complicated if then
construct.

Discussed with: emaste@, allanjude@ (changes (or not) based on their feedback)
Differential Revision: https://reviews.freebsd.org/D19797

5 years agoRemove now unnecessary kldstat check before attempting to load modules.
crees [Sun, 7 Apr 2019 18:31:45 +0000 (18:31 +0000)]
Remove now unnecessary kldstat check before attempting to load modules.

Since r233109, kldload has the -n option, which silently ignores options
that are already loaded.

https://lists.freebsd.org/pipermail/freebsd-rc/2018-December/003899.html

Note that this script no longer reports if the module is already loaded,
but it could be argued this wasn't particularly useful information.

PR: docs/234248
Reviewed by: bcr (docs), kib, rgrimes (visual)
Approved by: jilles
Differential Revision: https://reviews.freebsd.org/D18670

5 years agoAdd option to build LLVM RISC-V target
mhorne [Sun, 7 Apr 2019 18:24:26 +0000 (18:24 +0000)]
Add option to build LLVM RISC-V target

Reviewed by: emaste, dim
Approved by: markj (mentor)
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D19759

5 years agoAdd g_label_flashmap.c to the module, should have been part of r345480.
ian [Sun, 7 Apr 2019 16:33:22 +0000 (16:33 +0000)]
Add g_label_flashmap.c to the module, should have been part of r345480.

Reported by: Jia-Shiun Li <jiashiun@gmail.com>

5 years agoBump FreeBSD version after r345982.
oshogbo [Sun, 7 Apr 2019 16:07:41 +0000 (16:07 +0000)]
Bump FreeBSD version after r345982.

Reported by: Shawn Webb <shawn.webb@hardenedbsd.org>
Discussed with: imp, cy, rgrimes

5 years agoStop compiling bhyve(8) with -O0.
markj [Sun, 7 Apr 2019 14:30:17 +0000 (14:30 +0000)]
Stop compiling bhyve(8) with -O0.

DEBUG_FLAGS is always added to CFLAGS.  This setting appears to be
accidental and came in with r243327.

Reviewed by: anish, emaste, jhb, rgrimes
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19787

5 years agoFix indentation.
markj [Sun, 7 Apr 2019 14:28:02 +0000 (14:28 +0000)]
Fix indentation.

No functional change intended.

Reviewed by: bcran, jhb, rgrimes
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19786

5 years agoSet the p_oppid field of orphans when exiting.
markj [Sun, 7 Apr 2019 14:26:14 +0000 (14:26 +0000)]
Set the p_oppid field of orphans when exiting.

Such processes will be reparented to the reaper when the current
parent is done with them (i.e., ptrace detached), so p_oppid must be
updated accordingly.

Add a regression test to exercise this code path.  Previously it
would not be possible to reap an orphan with a stale oppid.

Reviewed by: kib, mjg
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19825

5 years agoloader: command_lsefi: ret can be used uninitialized
tsoome [Sun, 7 Apr 2019 14:07:28 +0000 (14:07 +0000)]
loader: command_lsefi: ret can be used uninitialized

MFC after: 1w

5 years agoloader: add file_remove() function to undo file_insert_tail().
tsoome [Sun, 7 Apr 2019 13:36:17 +0000 (13:36 +0000)]
loader: add file_remove() function to undo file_insert_tail().

346002 did miss the fact that we do not only undo the loadaddr, but also
we need to remove the inserted module. Implement file_remove() to do the job.

MFC after: 1w

5 years agoloader: mod_loadkld() error: we previously assumed 'last_file' could be null
tsoome [Sun, 7 Apr 2019 12:20:17 +0000 (12:20 +0000)]
loader: mod_loadkld() error: we previously assumed 'last_file' could be null

The last_file variable is used to reset the loadaddr variable back to original
value; however, it is possible the last_file is NULL, so we can not blindly
trust it. But then again, we can just save the original loadaddr and use
the saved value for recovery.

MFC after: 1w

5 years agoloader: file_addmetadata() should check for memory allocation
tsoome [Sun, 7 Apr 2019 12:10:19 +0000 (12:10 +0000)]
loader: file_addmetadata() should check for memory allocation

malloc() can return NULL.

MFC after: 1w

5 years agoloader: remove pointer checks before free() in module.c
tsoome [Sun, 7 Apr 2019 11:55:11 +0000 (11:55 +0000)]
loader: remove pointer checks before free() in module.c

free() does check for NULL argument, remove duplicate checks.

MFC after: 1w

5 years agoloader: file_addmodule should check for memory allocation
tsoome [Sun, 7 Apr 2019 11:50:41 +0000 (11:50 +0000)]
loader: file_addmodule should check for memory allocation

strdup() can return NULL.

MFC after: 1w

5 years agoloader: malloc+bzero is calloc
tsoome [Sun, 7 Apr 2019 11:48:41 +0000 (11:48 +0000)]
loader: malloc+bzero is calloc

Replace malloc+bzero in module.c with calloc.

MFC after: 1w

5 years agoGive new home to the comment from ppt_pci_reset(), explaining a nuance
kib [Sun, 7 Apr 2019 08:58:09 +0000 (08:58 +0000)]
Give new home to the comment from ppt_pci_reset(), explaining a nuance
of power reset.

Noted by: soralx@cydem.org
Sponsored by: Mellanox Technologies
MFC after: 12 days

5 years agoMFV r345988:
cy [Sat, 6 Apr 2019 23:35:23 +0000 (23:35 +0000)]
MFV r345988:

Update sqlite3-3.26.0 (3260000) --> sqlite3-3.27.1 (3270100)

MFC after: 2 weeks

5 years agoDelete the BUGS entry related to failing when jails are enabled.
rmacklem [Sat, 6 Apr 2019 22:14:03 +0000 (22:14 +0000)]
Delete the BUGS entry related to failing when jails are enabled.

r345994 has finally fixed the bug that caused the nfsuserd(8) daemon to
fail when jails were enabled, so delete the BUGS entry from the man page.

PR: 205193
MFC after: 2 weeks

5 years agoFix nfsuserd so that it handles the mapped localhost address when jails
rmacklem [Sat, 6 Apr 2019 22:05:51 +0000 (22:05 +0000)]
Fix nfsuserd so that it handles the mapped localhost address when jails
are enabled.

The nfsuserd(8) daemon does not function correctly when jails are enabled,
since localhost gets mapped to another IP address and, as such, the upcall
RPC fails.
This patch fixes the problem by doing a getsockname(2) of a socket mapped
to localhost to find out what the correct address is for the comparison
test with the upcall's from IP address.
This patch also adds INET6 support and the required #ifdef's for INET and
INET6. It now uses INET6 by default for the upcalls, if the kernel has
INET6 support and the daemon is also built with INET6 support.

Tested by: freebsd@danielengel.com (earlier version)
PR: 205193
Reviewed by: bz, rgrimes
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19218

5 years agokern/subr_pctrie: Fix mismatched signedness in assertion comparison
cem [Sat, 6 Apr 2019 21:56:24 +0000 (21:56 +0000)]
kern/subr_pctrie: Fix mismatched signedness in assertion comparison

'tos' is an index into an array and never holds a negative value.  Correct
its signedness to match PCTRIE_LIMIT, which it is compared to in assertions.

No functional change (kills a warning).

5 years agoAdd INET6 support for the upcalls to the nfsuserd daemon.
rmacklem [Sat, 6 Apr 2019 21:53:46 +0000 (21:53 +0000)]
Add INET6 support for the upcalls to the nfsuserd daemon.

The kernel code uses UDP to do upcalls to the nfsuserd(8) daemon to get
updates to the username<->uid and groupname<->gid mappings.
A change to AF_LOCAL last year had to be reverted, since it could result
in vnode locking issues on the AF_LOCAL socket.
This patch adds INET6 support and the required #ifdef INET and INET6
to the code.

Requested by: bz
PR: 205193
Reviewed by: bz, rgrimes
MFC after: 2 weeks
Differential Revision: http://reviews.freebsd.org/D19218

5 years agokern/subr_pctrie: Convert old-style boolean_t to plain "bool"
cem [Sat, 6 Apr 2019 20:38:44 +0000 (20:38 +0000)]
kern/subr_pctrie: Convert old-style boolean_t to plain "bool"

No functional change.

5 years agofusefs: fix a panic on mount
asomers [Sat, 6 Apr 2019 18:04:04 +0000 (18:04 +0000)]
fusefs: fix a panic on mount

Don't page fault if the file descriptor provided with "-o fd" is invalid.
This is a merge of r345419 from the projects/fuse2 branch.

Reviewed by: ngie
Tested by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19836

5 years agoAdd firewall_[nat64|nptv6|pmod]_enable variables to /etc/defaults/rc.conf
ae [Sat, 6 Apr 2019 17:21:05 +0000 (17:21 +0000)]
Add firewall_[nat64|nptv6|pmod]_enable variables to /etc/defaults/rc.conf

Reported by: Andrey Fesenko
X-MFC after: r345450

5 years agoUse funlinkat in pidfile to ensure we are removing the right file.
oshogbo [Sat, 6 Apr 2019 11:24:43 +0000 (11:24 +0000)]
Use funlinkat in pidfile to ensure we are removing the right file.

5 years agoRegen after r345982.
oshogbo [Sat, 6 Apr 2019 09:37:10 +0000 (09:37 +0000)]
Regen after r345982.

5 years agoIntroduce funlinkat syscall that always us to check if we are removing
oshogbo [Sat, 6 Apr 2019 09:34:26 +0000 (09:34 +0000)]
Introduce funlinkat syscall that always us to check if we are removing
the file associated with the given file descriptor.

Reviewed by: kib, asomers
Reviewed by: cem, jilles, brooks (they reviewed previous version)
Discussed with: pjd, and many others
Differential Revision: https://reviews.freebsd.org/D14567

5 years agoMFV: r345969
jkim [Sat, 6 Apr 2019 06:02:42 +0000 (06:02 +0000)]
MFV: r345969

Import ACPICA 20190405.

5 years agoWrite string constant differently to improve readability.
delphij [Sat, 6 Apr 2019 03:42:15 +0000 (03:42 +0000)]
Write string constant differently to improve readability.

Reported by: rgrimes
Reviewed by: rgrimes, emaste
MFC after: 13 days
Differential Revision: https://reviews.freebsd.org/D19829

5 years agopowerpc/powernv: Fix major bugs in opal_flash
jhibbits [Sat, 6 Apr 2019 02:39:56 +0000 (02:39 +0000)]
powerpc/powernv: Fix major bugs in opal_flash

* The BIO bio_data may not be page aligned.  Only the base address of each
  page worth of data is extracted to pass to OPAL.  Without page alignment
  it can scribble over random memory when finishing the page read.  Fix this
  by short-reading the first page to properly align for full page reads.
* Fix the definition of OPAL_FLASH_ERASE.
* Properly handle the async message result, as now returned from r345974.

5 years agopowerpc/powernv: Fix issues in opal_async
jhibbits [Sat, 6 Apr 2019 02:31:01 +0000 (02:31 +0000)]
powerpc/powernv: Fix issues in opal_async

* Properly return the full opal_msg from an async completion.
* Don't keep bugging OPAL, wait 100us or so.  With some minor changes to
  DELAY() to drop to very low priority, the thread won't hog the CPU while
  polling for the async completion.

5 years agonetwork.subr: improve configuration of cloned gif(4) interfaces
eugen [Fri, 5 Apr 2019 22:45:08 +0000 (22:45 +0000)]
network.subr: improve configuration of cloned gif(4) interfaces

ifconfig(8) syntax allows to specify only single address_family,
so we need additional invocation of ifconfig to support configuration
of cloned gif interface that may use different address families
for its internal and external addresses.

Also, ifconfig(8) does not allow to omit "inet6" keyword for address family
specifying IPv6 addresses as outer addresses of the interface.

Also, address_family is not "parameter" and it has to go before parameters
including "tunnel" keyword, so "ifconfig gif0 tunnel inet6 $oip1 $oip2" would be
wrong syntax and only "ifconfig gif0 inet6 tunnel $oip1 $oip2" is right.

With this change, the following works:

gifconfig_gif0="inet6 2a00::1 2a01::1"
ifconfig_gif0="inet 10.0.0.1 10.0.0.2 netmask 255.255.255.252"

MFC after: 2 weeks

5 years agoFix gcc warning about shadowed global.
kib [Fri, 5 Apr 2019 20:12:19 +0000 (20:12 +0000)]
Fix gcc warning about shadowed global.

Sponsored by: Mellanox Technologies
MFC after: 2 weeks

5 years agoEmergency fix for NULL deref in xo_xml_leader_len
phil [Fri, 5 Apr 2019 19:42:54 +0000 (19:42 +0000)]
Emergency fix for NULL deref in xo_xml_leader_len

5 years agoImplement devctl(8) command 'reset', using DEV_RESET /dev/devctl2 ioctl.
kib [Fri, 5 Apr 2019 19:32:26 +0000 (19:32 +0000)]
Implement devctl(8) command 'reset', using DEV_RESET /dev/devctl2 ioctl.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoAdd DEV_RESET /dev/devctl2 ioctl.
kib [Fri, 5 Apr 2019 19:31:26 +0000 (19:31 +0000)]
Add DEV_RESET /dev/devctl2 ioctl.

It performs BUS_RESET_CHILD() on the parental bus and the specified
device.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoRemove single-use DEV_RESET() macro.
kib [Fri, 5 Apr 2019 19:27:51 +0000 (19:27 +0000)]
Remove single-use DEV_RESET() macro.

It conflicts with the sys/bus.h DEV_XXX namespace.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoImplement resets for PCI buses and PCIe bridges.
kib [Fri, 5 Apr 2019 19:25:26 +0000 (19:25 +0000)]
Implement resets for PCI buses and PCIe bridges.

For PCI device (i.e. child of a PCI bus), reset tries FLR if
implemented and worked, and falls to power reset otherwise.

For PCIe bus (child of a PCIe bridge or root port), reset
disables PCIe link and then re-trains it, performing what is known as
link-level reset.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoProvide newbus infrastructure for initiating device reset.
kib [Fri, 5 Apr 2019 18:09:22 +0000 (18:09 +0000)]
Provide newbus infrastructure for initiating device reset.

The methods BUS_RESET_PREPARE(), BUS_RESET(), and BUS_RESET_POST()
should be implemented by bus which can provide reset to a device.  The
methods are described in inline doxygen comments.

Code only provides BUS_RESET_PREPARE() and BUS_RESET_POST() helpers
instead of default implementation, because actual bus needs to handle
device state around reset, while helpers provide the other half of
typical prepare/post code.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoAdd __BEGIN_DECLS/__END_DECLS braces to libdevctl header.
kib [Fri, 5 Apr 2019 17:54:31 +0000 (17:54 +0000)]
Add __BEGIN_DECLS/__END_DECLS braces to libdevctl header.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agobhyve: Fix NVMe data structure copy to guest
chuck [Fri, 5 Apr 2019 16:54:20 +0000 (16:54 +0000)]
bhyve: Fix NVMe data structure copy to guest

bhyve's NVMe emulation was transferring Identify data back to the guest
incorrectly causing memory corruptions. These corruptions resulted in
core dumps and other system level errors in the guest.

In their simplest form, NVMe Physical Region Page (PRP) values in
commands indicate which physical pages to use for data transfer. The
first PRP value is not required to be page aligned but does not cross a
page boundary. The second PRP value must be page aligned, does not cross
a page boundary, and need not be contiguous with PRP1.

The code was copying Identify data past the end of PRP1. This happens to
work if PRP1 and PRP2 are physically contiguous but will corrupt guest
memory in unpredictable ways if they are not.

Fix is to copy the Identify data back to the guest piecewise (i.e. for
each PRP entry). Also fix a similarly wrong problem when copying back
Log page data.

Reviewed by: imp (mentor), araujo, jhb, rgrimes, bhyve
Approved by: imp (mentor), bhyve (jhb)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19695

5 years agobhyve: Fix NVMe BAR size calculation
chuck [Fri, 5 Apr 2019 16:54:16 +0000 (16:54 +0000)]
bhyve: Fix NVMe BAR size calculation

The NVMe specification defines bits 13:4 of BAR0 as Reserved (i.e. 0x0).
Most drivers do not enforce this, but the Windows NVMe driver does and
will refuse to start the device (i.e. error 10) if any of these bits are
set.

The current BAR size calculation tries to minimize the amount of memory
the device reserves by scaling the BAR size by the maximum number of
queues supported by the device. But unless the device supports a large
number of queue pairs (over 1536), it will reserve too little memory.

The fix is to allocate a minimum of 16K bytes for BAR0.

Tested on Windows Server 2016 and 2019

Reviewed by: imp (mentor), araujo, jhb, bhyve
Approved by: imp (mentor), bhyve (jhb)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19676

5 years agovn_vmap_seekhole(): align running offset to the block boundary.
kib [Fri, 5 Apr 2019 16:14:16 +0000 (16:14 +0000)]
vn_vmap_seekhole(): align running offset to the block boundary.

Otherwise we might miss the last iteration where EOF appears below
unaligned noff.

Reported and reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D19811

5 years agoFix mis-merge.
kib [Fri, 5 Apr 2019 16:12:35 +0000 (16:12 +0000)]
Fix mis-merge.

Amusingly, it is nop.

Noted by: trasz
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-MFC-rev: r345702

5 years agotwsi: Use config_intrhook_oneshot instead of config_intrhook_establish
manu [Fri, 5 Apr 2019 15:53:27 +0000 (15:53 +0000)]
twsi: Use config_intrhook_oneshot instead of config_intrhook_establish

Suggested by: ian
MFC after: 1 month
X-MFC-With: 345948

5 years agotwsi: Add interrupt mode
manu [Fri, 5 Apr 2019 14:44:23 +0000 (14:44 +0000)]
twsi: Add interrupt mode

Add the ability to use interrupts for i2c message.
We still use polling for early boot i2c transfer (for PMIC
for example) but as soon as interrupts are available use them.
On Allwinner SoC >A20 is seems that polling mode is broken for some
reason, this is now fixed by using interrupt mode.
For Allwinner also fix the frequency calculation, the one in the code
was for when the APB frequency is at 48Mhz while it is at 24Mhz on most
(all?) Allwinner SoCs. We now support both cases.

While here add more debug info when it's compiled in.

Tested On: A20, H3, A64
MFC after: 1 month

5 years agoRemove another instance of All Rights Reserved.
imp [Fri, 5 Apr 2019 14:27:48 +0000 (14:27 +0000)]
Remove another instance of All Rights Reserved.

Remove the phrase from boilerplate copyright we stick on vers.c when
we can't find the template file. In practice, this won't change a
thing, except for the case of compiling the kernel standalone w/o the
rest of a tree on a system that doesn't have
/usr/share/examples/etc/bsd-copyright installed.

5 years agoAdd mpr, mps, mpt to NOTES file
imp [Fri, 5 Apr 2019 02:54:02 +0000 (02:54 +0000)]
Add mpr, mps, mpt to NOTES file

Add these to all the architectures that these are in the GENERIC
kernel.

5 years agoFix build.
delphij [Fri, 5 Apr 2019 02:37:10 +0000 (02:37 +0000)]
Fix build.

MFC after: 2 weeks
X-MFC-With: r345900

5 years agoImplement checking of `.' and `..' entries of subdirectory.
delphij [Fri, 5 Apr 2019 02:21:16 +0000 (02:21 +0000)]
Implement checking of `.' and `..' entries of subdirectory.

Reviewed by: pfg
Obtained from: Android https://android.googlesource.com/platform/external/fsck_msdos/+/b6ee08aadb580341a4d80943741b80de16a88b5d%5E%21/
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19824

5 years agoAdd an entry to UPDATING for r345895, which affects the use of nfsuserd daemons
rmacklem [Thu, 4 Apr 2019 23:40:30 +0000 (23:40 +0000)]
Add an entry to UPDATING for r345895, which affects the use of nfsuserd daemons
built from head sources between July 6, 2017 and Aug. 22, 2018.

5 years agoRestore lfcl when LOSTDIR's chain was corrupted and overwritten
delphij [Thu, 4 Apr 2019 23:34:03 +0000 (23:34 +0000)]
Restore lfcl when LOSTDIR's chain was corrupted and overwritten
with invalid value.

Obtained from: Android https://android.googlesource.com/platform/external/fsck_msdos/+/4d6d6f8a3674ad67f970e2ae908d34f64e4854cf%5E%21/
MFC after: 2 weeks

5 years agosort(1): randomcoll: Skip the memory allocation entirely
cem [Thu, 4 Apr 2019 23:32:27 +0000 (23:32 +0000)]
sort(1): randomcoll: Skip the memory allocation entirely

There's no reason to order based on strcmp of ASCII digests instead of
memcmp of the raw digests.

While here, remove collision fallback.  If you collide two MD5s, they're
probably the same string anyway.  If robustness against MD5 collisions is
desired, maybe we shouldn't use MD5.

None of the behavior of sort -R is specified by POSIX, so we're free to
implement this however we like.  E.g., using a 128-bit counter and block cipher
to generate unique indices for each line of input.

PR: 230792 (2/many)
Relnotes: This will change the sort order for a given dataset with a
given seed.  Other similarly breaking changes are planned.
Sponsored by: Dell EMC Isilon

5 years agoRevert r320698, since the related userland changes were reverted by r338192.
rmacklem [Thu, 4 Apr 2019 23:30:27 +0000 (23:30 +0000)]
Revert r320698, since the related userland changes were reverted by r338192.

r338192 reverted the changes to nfsuserd so that it could use an AF_LOCAL
socket, since it resulted in a vnode locking panic().
Post r338192 nfsuserd daemons use the old AF_INET socket for upcalls and
do not use these kernel changes.
I left them in for a while, so that nfsuserd daemons built from head sources
between r320757 (Jul. 6, 2017) and r338192 (Aug. 22, 2018) would need them
by default.
This only affects head, since the changes were never MFC'd.
I will add an UPDATING entry, since an nfsuserd daemon built from head
sources between r320757 and r338192 will not run unless the "-use-udpsock"
option is specified. (This command line option is only in the affected
revisions of the nfsuserd daemon.)

I suspect few will be affected by this, since most who run systems built
from head sources (not stable or releases) will have rebuilt their nfsuserd
daemon from sources post r338192 (Aug. 22, 2018)

This is being reverted in preparation for an update to include AF_INET6
support to the code.

5 years agoRestore the ability of checking and fixing next free
delphij [Thu, 4 Apr 2019 23:16:36 +0000 (23:16 +0000)]
Restore the ability of checking and fixing next free
cluster in FSINFO that was lost in r203872.

Obtained from: NetBSD
MFC after: 2 weeks

5 years agoAdd requiered programs (cc and c++) for some lib/atf regression tests
olivier [Thu, 4 Apr 2019 20:34:17 +0000 (20:34 +0000)]
Add requiered programs (cc and c++) for some lib/atf regression tests

PR: 236889
Reviewed by: ngie
Approved by: emaste (on IRC)
MFC after: 1 month
Sponsored by: Netflix

5 years agosort(1): randomcoll: Don't sort on ENOMEM
cem [Thu, 4 Apr 2019 20:27:13 +0000 (20:27 +0000)]
sort(1): randomcoll: Don't sort on ENOMEM

PR: 230792 (1/many)
Sponsored by: Dell EMC Isilon

5 years agoif_muge: use NULL not 0 for DRIVER_MODULE pointer args
emaste [Thu, 4 Apr 2019 19:59:31 +0000 (19:59 +0000)]
if_muge: use NULL not 0 for DRIVER_MODULE pointer args

Sponsored by: The FreeBSD Foundation

5 years agoUse IN_foo() macros from sys/netinet/in.h inplace of handcrafted code
rgrimes [Thu, 4 Apr 2019 19:01:13 +0000 (19:01 +0000)]
Use IN_foo() macros from sys/netinet/in.h inplace of handcrafted code

There are a few places that use hand crafted versions of the macros
from sys/netinet/in.h making it difficult to actually alter the
values in use by these macros.  Correct that by replacing handcrafted
code with proper macro usage.

Reviewed by: karels, kristof
Approved by: bde (mentor)
MFC after: 3 weeks
Sponsored by: John Gilmore
Differential Revision: https://reviews.freebsd.org/D19317

5 years agoRewrite intro(4) man page.
ygy [Thu, 4 Apr 2019 18:52:03 +0000 (18:52 +0000)]
Rewrite intro(4) man page.

- Remove issues that no longer apply thanks to devfs
- Add language pointing out devfs's role and referencing its config
- Add a "historical notes" section and move discussion of block vs character devs to it, including pointing out the removal of block devs
- Modernize some examples

MFC after: 1 week
PR: 236970
Submitted by: andrew@tao173.riddles.org.uk
Reviewed by: 0mp
Differential Revision: https://reviews.freebsd.org/D19799

5 years agostrings: capsicumize it
oshogbo [Thu, 4 Apr 2019 16:32:27 +0000 (16:32 +0000)]
strings: capsicumize it

Reviewed by: cem
Discussed with: emaste
Differential Revision: https://reviews.freebsd.org/D18038

5 years agoAdd cap_fileargs.h to -legacy if needed.
oshogbo [Thu, 4 Apr 2019 04:14:20 +0000 (04:14 +0000)]
Add cap_fileargs.h to -legacy if needed.

Reviewed by: arichardson
Differential Revision: https://reviews.freebsd.org/D19685

5 years agoFix malloc stats for the RPCSEC_GSS server code when DEBUG is enabled.
rmacklem [Thu, 4 Apr 2019 01:23:06 +0000 (01:23 +0000)]
Fix malloc stats for the RPCSEC_GSS server code when DEBUG is enabled.

The code enabled when "DEBUG" is defined uses mem_alloc(), which is a
malloc(.., M_RPC, M_WAITOK | M_ZERO), but then calls gss_release_buffer()
which does a free(.., M_GSSAPI) to free the memory.
This patch fixes the problem by replacing mem_alloc() with a
malloc(.., M_GSSAPI, M_WAITOK | M_ZERO).
This bug affects almost no one, since the sources are not normally built
with "DEBUG" defined.

Submitted by: peter@ifm.liu.se
MFC after: 2 weeks

5 years agoReplace read_random(9) with more appropriate arc4rand(9) KPIs
cem [Thu, 4 Apr 2019 01:02:50 +0000 (01:02 +0000)]
Replace read_random(9) with more appropriate arc4rand(9) KPIs

Reviewed by: ae, delphij
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19760

5 years agoImplement tests for online expansion:
pjd [Thu, 4 Apr 2019 00:05:36 +0000 (00:05 +0000)]
Implement tests for online expansion:
- init, init -R
- onetime, onetime -R
- 512 and 4k sectors
- encryption only
- encryption and authentication
- configure -r/-R for detached providers
- configure -r/-R for attached providers
- all keys allocated (10, 20 and 30MB provider sizes)
- keys allocated on demand (10, 20 and 30PB provider sizes)
- reading and writing to provider after expansion (10-30MB only)
- checking if metadata in old location is cleared.

Obtained from: Fudo Security

5 years agoUpdate configure tests after addition of the online expansion.
pjd [Wed, 3 Apr 2019 23:58:58 +0000 (23:58 +0000)]
Update configure tests after addition of the online expansion.

Obtained from: Fudo Security

5 years agoImplement automatic online expansion of GELI providers - if the underlying
pjd [Wed, 3 Apr 2019 23:57:37 +0000 (23:57 +0000)]
Implement automatic online expansion of GELI providers - if the underlying
provider grows, GELI will expand automatically and will move the metadata
to the new location of the last sector.

This functionality is turned on by default. It can be turned off with the
-R flag, but it is not recommended - if the underlying provider grows and
automatic expansion is turned off, it won't be possible to attach this
provider again, as the metadata is no longer located in the last sector.

If the automatic expansion is turned off and the underlying provider grows,
GELI will only log a message with the previous size of the provider, so
recovery can be easier.

Obtained from: Fudo Security

5 years ago- Add missing -T (notrim) option to the label subcommand.
pjd [Wed, 3 Apr 2019 23:50:52 +0000 (23:50 +0000)]
- Add missing -T (notrim) option to the label subcommand.
- Add missing -T option in the onetime subcommand comment.

Obtained from: Fudo Security

5 years agoImport libxo-1.0.2
phil [Wed, 3 Apr 2019 21:55:39 +0000 (21:55 +0000)]
Import libxo-1.0.2

from 1.0.0:
    Add "continuation" flag, to allow multiple "xo" invocations in a single line of output (#58)
    Add --top-wrap to make top-level JSON wrappers
    Add --{open,close}-{list,instace} options
    Add xo_xml_leader(), to detect use of some bogus XML tags. It's still bad form, but it's a little safer now
    Avoid call to xo_write before xo_flush, since the latter calls the former
    Check return code from xo_flush_h properly (<0) (FreeBSD Bug 236935)
    For JSON output, avoid newline before a container's close brace (#62)
    Merge branch 'text_only' of https://github.com/zvr/libxo into zvr-text_only
    Use XO_USE_INT_RETURN_CODES, not USE_INT_RETURN_CODES
    add docs for --continuation
    add docs for --not-first
    call xo_state_set_flags before values and close containers; add XOIF_MADE_OUTPUT flag to track state; make proper empty JSON objects in xo_finish
    color_map code has to be #ifdef'd out, since the struct definition
    correct xo_flush_func_t (doesn't use xo_ssize_t)
    make depth change for --top-wrap only for JSON
    fix to handle --top-wrap in "xo" by being more consistent with handling trailing newlines
    fix to handle text-only version #64 (from zvr)
    fix xo_buf_has_room for round up to the next XO_BUFSIZ, not just add XO_BUFSIZ to the size (FreeBSD Bug 236937)
    update docs for new "xo" options
    update functions to use xo_ssize_t
    update test cases
from 1.0.1:
    Add EINTEGRITY to .pot files under test/gettext/ (fix from FreeBSD)
from 1.0.2:
    handle failure from xo_vnsprintf; don't add -1 to "rc"

PR: 236937, 236935
Submitted by: phil
Reported by: Alfonso S. Siciliano <alfix86@gmail.com>
MFC after: 2 weeks

5 years agoAdd support for cross-building cloudware images.
cperciva [Wed, 3 Apr 2019 21:54:47 +0000 (21:54 +0000)]
Add support for cross-building cloudware images.

If MACHINE_ARCH doesn't match TARGET_ARCH, and we're not in the special
case of building i386 images on an amd64 host, we need to pull in the
qemu-user-static package; this allows us to run some commands inside
the VM disk image chroot, most notably to install packages.

Reviewed by: gjb
MFC after: 2 weeks
Sponsored by: FreeBSD/EC2 patreon (https://www.patreon.com/cperciva)

5 years agoTag libxo 1.0.2
phil [Wed, 3 Apr 2019 21:48:09 +0000 (21:48 +0000)]
Tag libxo 1.0.2

5 years agoImport libxo 1.0.2
phil [Wed, 3 Apr 2019 21:47:19 +0000 (21:47 +0000)]
Import libxo 1.0.2

5 years agocpsw: use `phy-handle` in FDT to find PHY address
emaste [Wed, 3 Apr 2019 21:01:53 +0000 (21:01 +0000)]
cpsw: use `phy-handle` in FDT to find PHY address

In r337703 DTS files were updated to Linux 4.18, including Linux commit
4d8b032d3c03f4e9788a18bbb51b10e6c9e8a56b which removed the `phy_id`
property from am335x-bone-common (as the property was deprecated).

Use `phy-handle` via fdt_get_phyaddr, keeping the existing code as a
fallback for old DTBs.

PR: 236624
Submitted by: manu, Gerald Aryeetey <aryeeteygerald_rogers.com>
Reported by: Gerald Aryeetey
Reviewed by: manu
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19814

5 years agorctl: fix sysctl kern.racct.enable use after r341182
mjg [Wed, 3 Apr 2019 20:37:14 +0000 (20:37 +0000)]
rctl: fix sysctl kern.racct.enable use after r341182

The value was changed from int to bool. Since the new type
is smaller, the rest of the variable in the caller was left
unitialized.

PR: 236714
Reported by: trasz
Diagnosed by: markj
Sponsored by: The FreeBSD Foundation

5 years agoUndo my previous erroneous commit changing the tcp_output kassert.
rrs [Wed, 3 Apr 2019 19:35:07 +0000 (19:35 +0000)]
Undo my previous erroneous commit changing the tcp_output kassert.
Hmm now the question is where did the tcp_log_id change go :o

5 years agoFix typos in r345849.
mav [Wed, 3 Apr 2019 18:35:13 +0000 (18:35 +0000)]
Fix typos in r345849.

MFC after: 1 week

5 years agoList few more ATA commands.
mav [Wed, 3 Apr 2019 18:27:54 +0000 (18:27 +0000)]
List few more ATA commands.

MFC after: 1 week

5 years agolibbe(3): Add a serial to the generated snapshot names
kevans [Wed, 3 Apr 2019 17:04:38 +0000 (17:04 +0000)]
libbe(3): Add a serial to the generated snapshot names

To use bectl in an example, when one creates a new boot environment with
either `bectl create <be>` or `bectl create -e <otherbe> <be>`, libbe will
take a snapshot of the original boot environment to clone. Previously, this
used %F-%T date format as the snapshot name, but this has some limitations-
attempting to create multiple boot environments in quick succession may
collide if done within the same second.

Tack a serial onto it to reduce the chances of a collision... we could still
collide if multiple processes/threads are creating boot environments at the
same time, but this is likely not a big concern as this has only been
reported as occurring in freebsd-ci setup.

MFC after: 3 days

5 years agomsdosfs: zero tail of the last block on truncation for VREG vnodes as well.
kib [Wed, 3 Apr 2019 17:02:18 +0000 (17:02 +0000)]
msdosfs: zero tail of the last block on truncation for VREG vnodes as well.

Despite the call to vtruncbuf() from detrunc(), which results in
zeroing part of the partial page after EOF, there still is a
possibility to retain the stale data which is revived on file
enlargement.  If the filesystem block size is greater than the page
size, partial block might keep other after-EOF pages wired and they
get reused then.  Fix it by zeroing whole part of the partial buffer
after EOF, not relying on vnode_pager_setsize().

PR: 236977
Reported by: asomers
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agobectl.8: Bump date after r345845
0mp [Wed, 3 Apr 2019 13:59:35 +0000 (13:59 +0000)]
bectl.8: Bump date after r345845

Approved by: kevans

5 years agobectl.8: Clean up & clarify the create subcommand
0mp [Wed, 3 Apr 2019 13:46:43 +0000 (13:46 +0000)]
bectl.8: Clean up & clarify the create subcommand

- Improve formatting
- Use consistent variable names
- Improve the description of the create subcommand (1)

PR: 235850 (1)
Submitted by: kevans (1)
Reported by: ler (1)
Reviewed by: kevans
Approved by: src (kevans)
Differential Revision: https://reviews.freebsd.org/D19666

5 years agoFollow the declared behaviour that specifies server string format in
ae [Wed, 3 Apr 2019 12:47:49 +0000 (12:47 +0000)]
Follow the declared behaviour that specifies server string format in
bsnmpclient(3).

snmp_parse_server() function accepts string where some fields can be
omitted: [trans::][community@][server][:port]

"trans" field can be "udp", "udp6", "dgram" and "stream".
"community" can be empty string, if it is omitted, the default value
will be used. For read_community it is "public", for write_comminity
it is "private". "server" field can be hostname, IPv4 address or IPv6
address. IPv6 address should be specified in brackets "[]".
If port is omitted, the default value "snmp" will be used for "udp"
and "udp6" transports. So, now for bsnmpget(1) and bsnmwalk(1) it is
not required to specify all fields in argument of '-s' option. E.g.

  # bsnmpget -s 127.1 sysName.0
  # bsnmpget -s "udp::127.1" sysName.0
  # bsnmpget -s "udp::public@127.1" sysName.0
  # bsnmpget -s "udp::public@127.1:161" sysName.0
  # bsnmpget -s "udp::[::1]" sysName.0
  # bsnmpget -s "udp6::[::1]" sysName.0
  # bsnmpget -s "[fe80::1%lo0]" sysName.0

PR: 236664
Reported by: olivier
MFC after: 1 month

5 years agoAdd a cv_wait to the TPM2.0 harvesting function
mw [Wed, 3 Apr 2019 08:22:58 +0000 (08:22 +0000)]
Add a cv_wait to the TPM2.0 harvesting function

Harvesting has to compete for the TPM chip with userspace.
Before this change the callout could hijack an unread buffer
causing a userspace call to the TPM to fail.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: delphij
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D19712

5 years agoAssert that q can't be NULL. 'empty' is always non-NULL when DIREMPTY
delphij [Wed, 3 Apr 2019 07:09:28 +0000 (07:09 +0000)]
Assert that q can't be NULL.  'empty' is always non-NULL when DIREMPTY
is set earlier.

MFC after: 1 month

5 years agopowerpc: Allow emulating optional FPU instructions on CPUs with an FPU
jhibbits [Wed, 3 Apr 2019 04:01:08 +0000 (04:01 +0000)]
powerpc: Allow emulating optional FPU instructions on CPUs with an FPU

The e5500 has an FPU, but lacks the optional fsqrt instruction.  This
instruction gets emulated in the kernel, but the emulation uses stale data,
from the last switch out, and does not return the result of the operation
immediately.  Fix both of these conditions by saving and restoring the FPRs
around the emulation point.

MFC after: 1 week
MFC with: r345829

5 years agoCreate kernel module to parse Veriexec manifest based on envs
mw [Wed, 3 Apr 2019 03:57:37 +0000 (03:57 +0000)]
Create kernel module to parse Veriexec manifest based on envs

The current approach of injecting manifest into mac_veriexec is to
verify the integrity of it in userspace (veriexec (8)) and pass its
entries into kernel using a char device (/dev/veriexec).
This requires verifying root partition integrity in loader,
for example by using memory disk and checking its hash.
Otherwise if rootfs is compromised an attacker could inject their own data.

This patch introduces an option to parse manifest in kernel based on envs.
The loader sets manifest path and digest.
EVENTHANDLER is used to launch the module right after the rootfs is mounted.
It has to be done this way, since one might want to verify integrity of the init file.
This means that manifest is required to be present on the root partition.
Note that the envs have to be set right before boot to make sure that no one can spoof them.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: sjg
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D19281

5 years agopowerpc: Apply r178139 from sparc64 to powerpc's fpu_sqrt
jhibbits [Wed, 3 Apr 2019 03:54:30 +0000 (03:54 +0000)]
powerpc: Apply r178139 from sparc64 to powerpc's fpu_sqrt

This fix was committed less than 2 months after the code was forked into the
powerpc kernel.  Though powerpc doesn't use quad-precision floating point,
or need it for emulation, the changes do look like correctness fixes
overall.

This was found while trying to get fsqrt emulation working on e5500, which
does have a real FPU, but lacks the fsqrt instruction.  This is not the
complete fix, the rest is to be committed separately.

MFC after: 1 week

5 years agoAdd a comment to the r345818 patch to explain why cl_refs is initialized to 2.
rmacklem [Wed, 3 Apr 2019 03:50:16 +0000 (03:50 +0000)]
Add a comment to the r345818 patch to explain why cl_refs is initialized to 2.

PR: 235582
MFC after: 2 weeks

5 years agoFix a race in the RPCSEC_GSS server code that caused crashes.
rmacklem [Tue, 2 Apr 2019 23:51:08 +0000 (23:51 +0000)]
Fix a race in the RPCSEC_GSS server code that caused crashes.

When a new client structure was allocated, it was added to the list
so that it was visible to other threads before the expiry time was
initialized, with only a single reference count.
The caller would increment the reference count, but it was possible
for another thread to decrement the reference count to zero and free
the structure before the caller incremented the reference count.
This could occur because the expiry time was still set to zero when
the new client structure was inserted in the list and the list was
unlocked.

This patch fixes the race by initializing the reference count to two
and initializing all fields, including the expiry time, before inserting
it in the list.

Tested by: peter@ifm.liu.se
PR: 235582
MFC after: 2 weeks

5 years agoBuild NVMe CAM transport unrelated to NVMe SIM.
mav [Tue, 2 Apr 2019 20:27:56 +0000 (20:27 +0000)]
Build NVMe CAM transport unrelated to NVMe SIM.

Before this I suppose it was impossible load CAM-based NVMe as module.
Plus this appeared to be needed to build r345815 without NVMe driver.

MFC after: 2 weeks

5 years agoCorrect SMC definition in asmc(4) man page.
ygy [Tue, 2 Apr 2019 20:03:03 +0000 (20:03 +0000)]
Correct SMC definition in asmc(4) man page.

MFC after: 3 days
PR: 236954
Submitted by: fbsdbugs4@sentry.org

5 years agoMake cam_error_print() decode NVMe commands.
mav [Tue, 2 Apr 2019 19:37:52 +0000 (19:37 +0000)]
Make cam_error_print() decode NVMe commands.

MFC after: 2 weeks

5 years agoioat(4) should use bus_dma(9) for the operation source and destination
tychon [Tue, 2 Apr 2019 19:08:06 +0000 (19:08 +0000)]
ioat(4) should use bus_dma(9) for the operation source and destination
addresses

Reviewed by: cem
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19725

5 years agoioatcontrol(8) could exercise 8k-aligned copy with page-break, crc and
tychon [Tue, 2 Apr 2019 19:06:25 +0000 (19:06 +0000)]
ioatcontrol(8) could exercise 8k-aligned copy with page-break, crc and
crc-copy modes.

Reviewed by: cem
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19780

5 years agoDMAR driver assumes all physical addresses are backed by a fully
tychon [Tue, 2 Apr 2019 18:50:49 +0000 (18:50 +0000)]
DMAR driver assumes all physical addresses are backed by a fully
initialized struct vm_page.

Reviewed by: kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19753