]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoUse the more proper term of SATL instead of ATA_BEHIND_SCSI.
imp [Mon, 15 Jul 2019 20:25:41 +0000 (20:25 +0000)]
Use the more proper term of SATL instead of ATA_BEHIND_SCSI.

Most people know SAS attached SATA devices by the name SAT or SATL
(with the latter being a little more common). Change the device type
ATA_BEHIND_SCSI to SATL since it's more specific and meaningful.

Suggested by: scottl@

4 years agoIn do_sem2_wait(), balance umtx_key_get() with umtx_key_release() on retry.
kib [Mon, 15 Jul 2019 19:18:25 +0000 (19:18 +0000)]
In do_sem2_wait(), balance umtx_key_get() with umtx_key_release() on retry.

Reported by: ler
Bisected and reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 12 days

4 years agoImplement software access and dirty bit management for arm64.
markj [Mon, 15 Jul 2019 17:13:32 +0000 (17:13 +0000)]
Implement software access and dirty bit management for arm64.

Previously the arm64 pmap did no reference or modification tracking;
all mappings were treated as referenced and all read-write mappings
were treated as dirty.  This change implements software management
of these attributes.

Dirty bit management is implemented to emulate ARMv8.1's optional
hardware dirty bit modifier management, following a suggestion from alc.
In particular, a mapping with ATTR_SW_DBM set is logically writeable and
is dirty if the ATTR_AP_RW_BIT bit is clear.  Mappings with
ATTR_AP_RW_BIT set are write-protected, and a write access will trigger
a permission fault.  pmap_fault() handles permission faults for such
mappings and marks the page dirty by clearing ATTR_AP_RW_BIT, thus
mapping the page read-write.

Reviewed by: alc
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20907

4 years agopmap_clear_modify() needs to clear PTE_W.
markj [Mon, 15 Jul 2019 15:45:33 +0000 (15:45 +0000)]
pmap_clear_modify() needs to clear PTE_W.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoFix reference counting in pmap_ts_referenced() on RISC-V.
markj [Mon, 15 Jul 2019 15:43:15 +0000 (15:43 +0000)]
Fix reference counting in pmap_ts_referenced() on RISC-V.

pmap_ts_referenced() does not necessarily clear the access bit from
all accessed mappings of a given page.  Thus, if a scan of the mappings
needs to be restarted, we should be careful to avoid double-counting
accessed mappings whose access bits were not cleared in a previous
attempt.

Reported by: alc
Reviewed by: alc
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20926

4 years agoRemove duplicated device firmware entry in generic arm kernel config added in r333191
manu [Mon, 15 Jul 2019 15:07:55 +0000 (15:07 +0000)]
Remove duplicated device firmware entry in generic arm kernel config added in r333191

Submitted by: Daniel Engberg (daniel.engberg.lists@pyret.net)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D20680

4 years agoRemove RELEASE_CRUNCH here. It's obsolete.
imp [Mon, 15 Jul 2019 15:02:40 +0000 (15:02 +0000)]
Remove RELEASE_CRUNCH here. It's obsolete.

Remove RELEASE_CRUNCH here. It's obsolete and hasn't worked in a while.  The
build options need to be revisited, since many older ones are listed, while
newer useful ones are not. But that rototilling I'll leave to others.

4 years agoAdd support for MSG_EOR and MSG_EOF in sendmsg() for SCTP.
tuexen [Mon, 15 Jul 2019 14:54:04 +0000 (14:54 +0000)]
Add support for MSG_EOR and MSG_EOF in sendmsg() for SCTP.

This is an FreeBSD extension, not covered by Posix.

This issue was found by running syzkaller.

MFC after: 1 week

4 years agoFix socket state handling when freeing an SCTP endpoint.
tuexen [Mon, 15 Jul 2019 14:52:52 +0000 (14:52 +0000)]
Fix socket state handling when freeing an SCTP endpoint.

This issue was found by runing syzkaller.

MFC after: 1 week

4 years agoReplace complicated expression to disable libedit when no libthr is being built
imp [Mon, 15 Jul 2019 14:23:51 +0000 (14:23 +0000)]
Replace complicated expression to disable libedit when no libthr is being built
with a simpler one.

4 years agoRemove all the RELEASE_CRUNCH instances that partially disable IPSEC
imp [Mon, 15 Jul 2019 14:19:39 +0000 (14:19 +0000)]
Remove all the RELEASE_CRUNCH instances that partially disable IPSEC

We remove IPSEC only in parts of the tree, and not others. RELEASE_CRUNCH to
disable it has not kept up with all its uses. Remove it. Should there be a real
need to disable IPSEC, one that hasn't shown up in the base system to date,
it can be re-added behind a WITHOUT_IPSEC build option.

4 years agoIn do_lock_pi(), do not return prematurely.
kib [Mon, 15 Jul 2019 08:39:52 +0000 (08:39 +0000)]
In do_lock_pi(), do not return prematurely.

If umtxq_check_susp() indicates an exit, we should clean the resources
before returning.  Do it by breaking out of the loop and relying on
post-loop cleanup.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 12 days
Differential revision: https://reviews.freebsd.org/D20949

4 years agoCorrectly check for casueword(9) success in do_set_ceiling().
kib [Mon, 15 Jul 2019 08:38:01 +0000 (08:38 +0000)]
Correctly check for casueword(9) success in do_set_ceiling().

After r349951, the return code must be checked instead of old == new
comparision.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 12 days
Differential revision: https://reviews.freebsd.org/D20949

4 years agoMK_OPENSSL makes RELEASE_CRUNCH redundant here
imp [Mon, 15 Jul 2019 07:39:28 +0000 (07:39 +0000)]
MK_OPENSSL makes RELEASE_CRUNCH redundant here

Since these things are more completely controlled by the MK_OPENSSL knob, remove
RELEASE_CRUNCH here. It's no longer needed for the release and other users can
use the more proper knob if they so desire.

4 years agoNow that we have MK_LS_COLORS, we don't need RELEASE_CRUNCH check here.
imp [Mon, 15 Jul 2019 07:35:46 +0000 (07:35 +0000)]
Now that we have MK_LS_COLORS, we don't need RELEASE_CRUNCH check here.

The RELEASE_CRUNCH check is redundant here. We don't need it for releases
anymore, and picobsd can control this more directly without making it a special
case.

4 years agoImprove the input validation for l_linger.
tuexen [Sun, 14 Jul 2019 21:44:18 +0000 (21:44 +0000)]
Improve the input validation for l_linger.
When using the SOL_SOCKET level socket option SO_LINGER, the structure
struct linger is used as the option value. The component l_linger is of
type int, but internally copied to the field so_linger of the structure
struct socket. The type of so_linger is short, but it is assumed to be
non-negative and the value is used to compute ticks to be stored in a
variable of type int.

Therefore, perform input validation on l_linger similar to the one
performed by NetBSD and OpenBSD.

Thanks to syzkaller for making me aware of this issue.

Thanks to markj@ for pointing out that a similar check should be added
to so_linger_set().

Reviewed by: markj@
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20948

4 years agoPR: 239143
kib [Sun, 14 Jul 2019 21:08:54 +0000 (21:08 +0000)]
PR: 239143
Reported and tested by: Wes Maag <jwmaag@gmail.com>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoThis is the second in a number of patches needed to
rrs [Sun, 14 Jul 2019 16:05:47 +0000 (16:05 +0000)]
This is the second in a number of patches needed to
get BBRv1 into the tree. This fixes the DSACK bug but
is also needed by BBR. We have yet to go two more
one will be for the pacing code (tcp_ratelimit.c) and
the second will be for the new updated LRO code that
allows a transport to know the arrival times of packets
and (tcp_lro.c). After that we should finally be able
to get BBRv1 into head.

Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D20908

4 years agoWhen calling sctp_initialize_auth_params(), the inp must have at
tuexen [Sun, 14 Jul 2019 12:04:39 +0000 (12:04 +0000)]
When calling sctp_initialize_auth_params(), the inp must have at
least a read lock. To avoid more complex locking dances, just
call it in sctp_aloc_assoc() when the write lock is still held.

Reported by: syzbot+08a486f7e6966f1c3cfb@syzkaller.appspotmail.com
MFC after: 1 week

4 years agoFix a typo in r349969
chuck [Sun, 14 Jul 2019 03:49:48 +0000 (03:49 +0000)]
Fix a typo in r349969

OUI_FRREBSD_NVME_HIGH should have been OUI_FREEBSD_NVME_HIGH

Caught by: Gary Jennejohn

4 years agoCalculate the offset of the interface name using FR_NAME rather than
cy [Sun, 14 Jul 2019 02:46:34 +0000 (02:46 +0000)]
Calculate the offset of the interface name using FR_NAME rather than
calclulating it "by hand". This improves consistency with the rest of
the code and is in line with planned fixes and other work.

MFC after: 1 week

4 years agoRecycle the unused FR_CMPSIZ macro which became orphaned in ipfilter 5
cy [Sun, 14 Jul 2019 02:46:30 +0000 (02:46 +0000)]
Recycle the unused FR_CMPSIZ macro which became orphaned in ipfilter 5
prior to its import into FreeBSD. This macro calculates the size to be
compared within the frentry structure. The ipfilter 4 version of the
macro calculated the compare size based upon the static size of the
frentry struct. Today it uses the ipfilter 5 method of calculating the
size based upon the new to ipfilter 5 fr_size value found in the
frentry struct itself.

No effective change in code is intended.

MFC after: 1 week

4 years agostyle(9)
cy [Sun, 14 Jul 2019 02:46:26 +0000 (02:46 +0000)]
style(9)

MFC after: 3 days

4 years agoAdd an entry mentioning the permission/mode change to daily accounting files.
ian [Sat, 13 Jul 2019 16:48:27 +0000 (16:48 +0000)]
Add an entry mentioning the permission/mode change to daily accounting files.

4 years agoRevert r349442, which was a workaround for bus errors caused by an errant
alc [Sat, 13 Jul 2019 16:32:19 +0000 (16:32 +0000)]
Revert r349442, which was a workaround for bus errors caused by an errant
TLB entry.  Specifically, at the start of pmap_enter_quick_locked(), we
would sometimes have a TLB entry for an invalid PTE, and we would need to
issue a TLB invalidation before exiting pmap_enter_quick_locked().  However,
we should never have a TLB entry for an invalid PTE.  r349905 has addressed
the root cause of the problem, and so we no longer need this workaround.

X-MFC after: r349905

4 years agoLimit access to system accounting files.
ian [Sat, 13 Jul 2019 16:07:38 +0000 (16:07 +0000)]
Limit access to system accounting files.

In 2013 the security chapter of the Handbook was updated in r42501 to
suggest limiting access to the system accounting file [*1] by creating the
initial file with a mode of 0600. This was in part based on a discussion in
the forums [*2]. Unfortunately, this advice is overridden by the fact that a
new file is created as part of periodic daily processing, and the file mode
is set by the rc.d/accounting script.

These changes update the accounting script to create the directory with mode
0750 if it doesn't already exist, and to create the daily file with mode
0640. This limits write access to root only, read access to root and members
of wheel, and eliminates world access completely. For admins who want to
prevent even members of wheel from accessing the files, the mode of the
/var/account directory can be manually changed to 0700, because the script
never creates or changes that directory if it already exists.

The accounting_rotate_log() function now also handles the error cases of no
existing log file to rotate, and attempting to rotate the file multiple
times (.0 file already exists).

Another small change here eliminates the complexity of the mktemp/chmod/mv
sequence for creating a new acct file by using install(1) with the flags
needed to directly create the file with the desired ownership and
modes. That allows coalescing two separate if checkyesno accounting_enable
blocks into one.

These changes were inspired by my investigation of PR 202203.

[1] https://www.freebsd.org/doc/handbook/security-accounting.html
[2] http://forums.freebsd.org/showthread.php?t=41059

PR: 202203
Differential Revision: https://reviews.freebsd.org/D20876

4 years agoRemove a stale comment.
alc [Sat, 13 Jul 2019 15:53:28 +0000 (15:53 +0000)]
Remove a stale comment.

Reported by: markj
MFC after: 1 week

4 years agoAdd arm_sync_icache() and arm_drain_writebuf() sysarch syscall wrappers.
ian [Sat, 13 Jul 2019 15:34:29 +0000 (15:34 +0000)]
Add arm_sync_icache() and arm_drain_writebuf() sysarch syscall wrappers.

NetBSD and OpenBSD have libc wrapper functions for the ARM_SYNC_ICACHE and
ARM_DRAIN_WRITEBUF sysarch operations. This change adds compatible functions
to our library. This should make it easier for various upstream sources to
support *BSD operating systems with a single variation of cache maintence
code in tools like interpreters and JIT compilers.

I consider the argument types passed to arm_sync_icache() to be especially
unfortunate, but this is intended to match the other BSDs.

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

4 years agoPull in r365760 from upstream lld trunk (by Fangrui Song):
dim [Sat, 13 Jul 2019 15:04:30 +0000 (15:04 +0000)]
Pull in r365760 from upstream lld trunk (by Fangrui Song):

  [ELF] Handle non-glob patterns before glob patterns in version
  scripts & fix a corner case of --dynamic-list

  This fixes PR38549, which is silently accepted by ld.bfd.
  This seems correct because it makes sense to let non-glob patterns
  take precedence over glob patterns.

  lld issues an error because
  `assignWildcardVersion(ver, VER_NDX_LOCAL);` is processed before
  `assignExactVersion(ver, v.id, v.name);`.

  Move all assignWildcardVersion() calls after assignExactVersion()
  calls to fix this.

  Also, move handleDynamicList() to the bottom. computeBinding() called
  by includeInDynsym() has this cryptic rule:

      if (versionId == VER_NDX_LOCAL && isDefined() && !isPreemptible)
return STB_LOCAL;

  Before the change:

  * foo's version is set to VER_NDX_LOCAL due to `local: *`
  * handleDynamicList() is called
    - foo.computeBinding() is STB_LOCAL
    - foo.includeInDynsym() is false
    - foo.isPreemptible is not set (wrong)
  * foo's version is set to V1

  After the change:

  * foo's version is set to VER_NDX_LOCAL due to `local: *`
  * foo's version is set to V1
  * handleDynamicList() is called
    - foo.computeBinding() is STB_GLOBAL
    - foo.includeInDynsym() is true
    - foo.isPreemptible is set (correct)

  Reviewed By: ruiu

  Differential Revision: https://reviews.llvm.org/D64550

This makes it longer necessary to patch the version scripts for the
samba ports, to avoid "duplicate symbol 'pdb_search_init' in version
script" errors.

PR: 230602
MFC after: 3 days

4 years agobhyve: Create EUI64 for NVMe namespaces
chuck [Sat, 13 Jul 2019 12:48:28 +0000 (12:48 +0000)]
bhyve: Create EUI64 for NVMe namespaces

Accept an IEEE Extended Unique Identifier (EUI-64) from the command
line for each NVMe namespace. If one isn't provided, it will create one
based on the CRC16 of:
 - the FreeBSD IEEE OUI
 - PCI bus, device/slot, function values
 - Namespace ID

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

4 years agor348494 fixes a race in udp_output(). The same race exists in
tuexen [Sat, 13 Jul 2019 12:45:08 +0000 (12:45 +0000)]
r348494 fixes a race in udp_output(). The same race exists in
udp_output6(), therefore apply a similar patch to IPv6.

Reported by: syzbot+c5ffbc8f14294c7b0e54@syzkaller.appspotmail.com
Reviewed by: bz@, markj@
MFC after: 2 weeks
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D20936

4 years agonetmap: fix bug introduced by r349752
vmaffione [Sat, 13 Jul 2019 08:08:25 +0000 (08:08 +0000)]
netmap: fix bug introduced by r349752

r349752 introduced a NULL pointer reference bug
in the emulated netmap code.

Reported by: lwhsu
MFC after: 3 days

4 years agopowerpc64/pmap: No need for moea64_pvo_remove_from_page_locked() wrapper
jhibbits [Sat, 13 Jul 2019 03:39:46 +0000 (03:39 +0000)]
powerpc64/pmap: No need for moea64_pvo_remove_from_page_locked() wrapper

The only consumer of moea64_pvo_remove_from_page_locked() already has the
page in hand, so there is no need to search for the page while holding the
lock.  Drop the wrapper, and rename _moea64_pvo_remove_from_page_locked().

Reported by: alc

4 years agoAdd device type NVME and device type MMCSD to get_device_type
imp [Sat, 13 Jul 2019 03:22:28 +0000 (03:22 +0000)]
Add device type NVME and device type MMCSD to get_device_type

For completeness, add nvme and mmc/sd devices to the list of device
types we know.

4 years agopowerpc64/pmap: Reduce scope of PV_LOCK in remove path
jhibbits [Sat, 13 Jul 2019 03:02:11 +0000 (03:02 +0000)]
powerpc64/pmap: Reduce scope of PV_LOCK in remove path

Summary:
Since the 'page pv' lock is one of the most highly contended locks, we
need to try to do as much work outside of the lock as we can.  The
moea64_pvo_remove_from_page() path is a low hanging fruit, where we can
do some heavy work (PHYS_TO_VM_PAGE()) outside of the lock if needed.
In one path, moea64_remove_all(), the PV lock is already held and can't
be swizzled, so we provide two ways to perform the locked operation, one
that can call PHYS_TO_VM_PAGE outside the lock, and one that calls with
the lock already held.

Reviewed By: luporl
Differential Revision: https://reviews.freebsd.org/D20694

4 years agoSet pcpu curpmap for powerpc64
jhibbits [Sat, 13 Jul 2019 00:19:57 +0000 (00:19 +0000)]
Set pcpu curpmap for powerpc64

Summary:
If an illegal instruction is encountered on a process running on a
powerpc64 kernel it would attempt to sync the cache before retrying the
instruction "just in case".  However, since curpmap is not set, when
moea64_sync_icache() attempts to lock the pmap, it's locking on a NULL pointer,
triggering a panic.  Fix this by adding a (assumed unnecessary) fallback to
curthread's pmap in moea64_sync_icache().

Reported by: alfredo.junior_eldorado.org.br
Reviewed by: luporl, alfredo.junior_eldorado.org.br
Differential Revision: https://reviews.freebsd.org/D20911

4 years agoFix layout. -C needs to be styled as a flag here, not as a new list item.
tijl [Fri, 12 Jul 2019 21:19:47 +0000 (21:19 +0000)]
Fix layout.  -C needs to be styled as a flag here, not as a new list item.

MFC after: 2 weeks

4 years agocxgbe(4): Completely ignore all top level interrupts that are not enabled.
np [Fri, 12 Jul 2019 20:59:10 +0000 (20:59 +0000)]
cxgbe(4): Completely ignore all top level interrupts that are not enabled.

The driver used to log any non-zero cause and when running with a single
line interrupt it would spam the console/logs with reports of interrupts
that are of no interest to anyone.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoFix syntax.
kib [Fri, 12 Jul 2019 19:14:52 +0000 (19:14 +0000)]
Fix syntax.

Nod from: jhb
Sponsored by: The FreeBSD Foundation

4 years agousr.sbin/bhyve: close backend file descriptor during tap init error
seanc [Fri, 12 Jul 2019 18:50:46 +0000 (18:50 +0000)]
usr.sbin/bhyve: close backend file descriptor during tap init error

Coverity CID: 1402953
Reviewed by: scottl, markj, aleksandr.fedorov -at- itglobal.com
Approved by: vmaffione, jhb
Differential Revision: https://reviews.freebsd.org/D20913

4 years agoProvide protection against starvation of the ll/sc loops when accessing userpace.
kib [Fri, 12 Jul 2019 18:43:24 +0000 (18:43 +0000)]
Provide protection against starvation of the ll/sc loops when accessing userpace.

Casueword(9) on ll/sc architectures must be prepared for userspace
constantly modifying the same cache line as containing the CAS word,
and not loop infinitely.  Otherwise, rogue userspace livelocks the
kernel.

To fix the issue, change casueword(9) interface to return new value 1
indicating that either comparision or store failed, instead of relying
on the oldval == *oldvalp comparison.  The primitive no longer retries
the operation if it failed spuriously.  Modify callers of
casueword(9), all in kern_umtx.c, to handle retries, and react to
stops and requests to terminate between retries.

On x86, despite cmpxchg should not return spurious failures, we can
take advantage of the new interface and just return PSL.ZF.

Reviewed by: andrew (arm64, previous version), markj
Tested by: pho
Reported by: https://xenbits.xen.org/xsa/advisory-295.txt
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D20772

4 years agoStyle: avoid long lines by using .Fo instead of .Fn.
kib [Fri, 12 Jul 2019 18:39:41 +0000 (18:39 +0000)]
Style: avoid long lines by using .Fo instead of .Fn.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years agousr.sbin/bhyveload: don't leak an fd if a device can't be opened
seanc [Fri, 12 Jul 2019 18:38:18 +0000 (18:38 +0000)]
usr.sbin/bhyveload: don't leak an fd if a device can't be opened

Coverity CID: 1194167
Approved by: markj, jhb
Differential Revision: https://reviews.freebsd.org/D20935

4 years agoTie the name limit of a VM to SPECNAMELEN from devfs instead of a
scottl [Fri, 12 Jul 2019 18:37:56 +0000 (18:37 +0000)]
Tie the name limit of a VM to SPECNAMELEN from devfs instead of a
hard-coded value. Don't allocate space for it from the kernel stack.
Account for prefix, suffix, and separator space in the name. This
takes the effective length up to 229 bytes on 13-current, and 37 bytes
on 12-stable. 37 bytes is enough to hold a full GUID string.

PR: 234134
MFC after: 1 week
Differential Revision: http://reviews.freebsd.org/D20924

4 years agousr.sbin/bhyve: only unassign a pt device after obtaining bus/slot/func
seanc [Fri, 12 Jul 2019 18:33:58 +0000 (18:33 +0000)]
usr.sbin/bhyve: only unassign a pt device after obtaining bus/slot/func

Coverity CID: 119430211943031194304
Approved by: jhb, markj
Differential Revision: https://reviews.freebsd.org/D20933

4 years agousr.sbin/bhyve: free resources when erroring out of pci_vtcon_sock_add()
seanc [Fri, 12 Jul 2019 18:20:56 +0000 (18:20 +0000)]
usr.sbin/bhyve: free resources when erroring out of pci_vtcon_sock_add()

Coverity CID: 1362880
Approved by: markj, jhb
Differential Revision: https://reviews.freebsd.org/D20916

4 years agousr.sbin/bhyve: prevent use-after-free in virtio scsi request handling
seanc [Fri, 12 Jul 2019 18:17:35 +0000 (18:17 +0000)]
usr.sbin/bhyve: prevent use-after-free in virtio scsi request handling

Coverity CID: 1393377
Approved by: araujo, jhb
Differential Revision: https://reviews.freebsd.org/D20915

4 years agousr.sbin/bhyve: don't leak a FD if the device is not a tty
seanc [Fri, 12 Jul 2019 18:13:58 +0000 (18:13 +0000)]
usr.sbin/bhyve: don't leak a FD if the device is not a tty

Coverity CID: 1194193
Approved by: markj, jhb
Differential Revision: https://reviews.freebsd.org/D20934

4 years agoApply some light cleanup to uses of pmap_pte_dirty().
markj [Fri, 12 Jul 2019 15:24:25 +0000 (15:24 +0000)]
Apply some light cleanup to uses of pmap_pte_dirty().

- Check for ATTR_SW_MANAGED before anything else.
- Use pmap_pte_dirty() in pmap_remove_pages().

No functional change intended.

Reviewed by: alc
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoadd back the comment around the pending DSACK fixes.
rrs [Fri, 12 Jul 2019 11:45:42 +0000 (11:45 +0000)]
add back the comment around the pending DSACK fixes.

4 years agoDo not modify cmd pointer if it is already last opcode in the rule.
ae [Fri, 12 Jul 2019 09:59:21 +0000 (09:59 +0000)]
Do not modify cmd pointer if it is already last opcode in the rule.

MFC after: 1 week

4 years agoCorrectly truncate the rule in case when it has several action opcodes.
ae [Fri, 12 Jul 2019 09:48:42 +0000 (09:48 +0000)]
Correctly truncate the rule in case when it has several action opcodes.

It is possible, that opcode at the ACTION_PTR() location is not real
action, but action modificator like "log", "tag" etc. In this case we
need to check for each opcode in the loop to find O_EXTERNAL_ACTION.

Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC

4 years agoSupport multiple serial ports per device.
phk [Fri, 12 Jul 2019 09:02:12 +0000 (09:02 +0000)]
Support multiple serial ports per device.

Enable this for the NovAtel OEMv2 GPS receiver.

Not fixed:  The receiver shows up as "<Interface 0>" in the device
tree, because that is literally what the descriptor-string is.

Reviewed by: hselasky@

4 years agoRetire the -DRELEASE_CRUNCH define.
imp [Fri, 12 Jul 2019 06:19:25 +0000 (06:19 +0000)]
Retire the -DRELEASE_CRUNCH define.

The RELEASE_CRUNCH ifdefs save about 100 bytes of text space. The
complexity is not worth it as they eliminate error messages.

Left the RELEASE_CRUNCH ifdef to eliminate a lot of stuff in place.
That saves an interesting amount of space and change some behaviors,
so absent a more detailed analysis, maintain the status quo.

4 years agousr.sbin/bhyve: unconditionally initialize the NVMe completion status
seanc [Fri, 12 Jul 2019 05:53:13 +0000 (05:53 +0000)]
usr.sbin/bhyve: unconditionally initialize the NVMe completion status

Follow-up work to improve the handling of unsupported/invalid opcodes
is being developed by chuck@.

Coverity CID: 1398928
Reviewed by: chuck
Approved by: araujo, imp
Differential Revision: https://reviews.freebsd.org/D20914

4 years agoRetire support for -DMINIMALISTIC
imp [Fri, 12 Jul 2019 05:35:45 +0000 (05:35 +0000)]
Retire support for -DMINIMALISTIC

We've not used this in years since we retired sysinstall, and it
hasn't compiled in at least a year. A full camcontrol is only 180k, so
making it smaller is not as important as it once was.

OK'd by: ken@, scottl@

4 years agousr.sbin/bhyve: free resources when erroring out of pci_vtnet_init()
seanc [Fri, 12 Jul 2019 05:19:37 +0000 (05:19 +0000)]
usr.sbin/bhyve: free resources when erroring out of pci_vtnet_init()

Coverity CID: 1402978
Approved by: vmaffione
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D20912

4 years agoThere is no SMALLER define anymore here
imp [Fri, 12 Jul 2019 05:19:06 +0000 (05:19 +0000)]
There is no SMALLER define anymore here

Stop defining SMALLER. Since we replaced cpio with libarchive version,
there's no options to make it smaller. Also, the comment about the
FreeBSD installer is obsolete. Remove them both.

4 years agoRemove unused defines since r147075
imp [Fri, 12 Jul 2019 04:44:50 +0000 (04:44 +0000)]
Remove unused defines since r147075

When the OpenBSD dhclient was brought in 14 years ago, we stopped
supporting building a reduced sized dhclient, yet retained the options
here.  Also, the OpenBSD dhclient doesn't need lint defined, so it can
go too.

4 years agoMove the new ipf_pcksum6() function from ip_fil_freebsd.c to fil.c.
cy [Fri, 12 Jul 2019 01:59:08 +0000 (01:59 +0000)]
Move the new ipf_pcksum6() function from ip_fil_freebsd.c to fil.c.
The reason for this is that ipftest(8), which still works on FreeBSD-11,
fails to link to it, breaking stable/11 builds.

ipftest(8) was broken (segfault) sometime during the FreeBSD-12 cycle.
glebius@ suggested we disable building it until I can get around to
fixing it. Hence this was not caught in -current.

The intention is to fix ipftest(8) as it is used by the netbsd-tests
(imported by ngie@ many moons ago) for regression testing.

MFC after: immediately

4 years agoAllow efi loader to get network params from uboot
jhibbits [Fri, 12 Jul 2019 00:54:20 +0000 (00:54 +0000)]
Allow efi loader to get network params from uboot

Summary:
efi loader does not work with static network parameters. It always uses
BOOTP/DHCP and also uses RARP as a fallback.  Problems with DHCP servers can
cause the loader to fail to populate network parameters.

Submitted by: Siddharth Tuli <siddharthtuli_gmail.com>
Reviewed by: imp
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D20811

4 years agousr.sbin/bhyve: send an initialized value to wake up blocking kqueue
seanc [Thu, 11 Jul 2019 23:54:50 +0000 (23:54 +0000)]
usr.sbin/bhyve: send an initialized value to wake up blocking kqueue

This is a no-op initialization because nothing reads this value.  "This
wasn't wrong previously, but this is more correct now." -imp

Coverity CID: 1194307
Approved by: markj, imp, scottl
Differential Revision: https://reviews.freebsd.org/D20921

4 years agolibsecureboot: avoid recusion in ve_trust_init
sjg [Thu, 11 Jul 2019 22:06:59 +0000 (22:06 +0000)]
libsecureboot: avoid recusion in ve_trust_init

set our guard value immediately.
also replace call to ve_trust_init in opgp_sig.c:initialize with
call to openpgp_trust_init.

Reported by: mindal@semihalf.com
Reviewed by: jhibbits obrien
MFC after: 1 week

4 years agoAddress problems in blist_alloc introduced in r349777. The swap block allocator...
dougm [Thu, 11 Jul 2019 20:52:39 +0000 (20:52 +0000)]
Address problems in blist_alloc introduced in r349777.  The swap block allocator could become corrupted
if a retry to allocate swap space, after a larger allocation attempt failed, allocated a smaller set of free blocks
that ended on a 32- or 64-block boundary.

Add tests to detect this kind of failure-to-extend-at-boundary and prevent the associated accounting screwup.

Reported by: pho
Tested by: pho
Reviewed by: alc
Approved by: markj (mentor)
Discussed with: kib
Differential Revision: https://reviews.freebsd.org/D20893

4 years agousr.sbin/bhyve: commit miss from r349918
seanc [Thu, 11 Jul 2019 19:51:33 +0000 (19:51 +0000)]
usr.sbin/bhyve: commit miss from r349918

Submitted by: markj
Approved by: markj
Differential Revision: https://reviews.freebsd.org/D20918

4 years agousr.sbin/bhyve: free leaked memory during option parsing
seanc [Thu, 11 Jul 2019 19:41:14 +0000 (19:41 +0000)]
usr.sbin/bhyve: free leaked memory during option parsing

Also update to use strsep(3) instead of strtok(3).

Most of this commit inadvertently ended up in r349914.

Coverity CID: 1357337
Approved by: markj
PR: 233038
Differential Revision: https://reviews.freebsd.org/D20918

4 years agoRemove a tautological test for adding a rule in the block that
cy [Thu, 11 Jul 2019 19:36:18 +0000 (19:36 +0000)]
Remove a tautological test for adding a rule in the block that
adds rules.

MFC after: 1 week

4 years agoCorrect r349898. The default is add a rule.
cy [Thu, 11 Jul 2019 19:36:14 +0000 (19:36 +0000)]
Correct r349898. The default is add a rule.

MFC after: 1 week
X-MFC with: r349898

4 years agousr.sbin/bhyve: initialize return value in xhci device interrupt handler
seanc [Thu, 11 Jul 2019 19:26:35 +0000 (19:26 +0000)]
usr.sbin/bhyve: initialize return value in xhci device interrupt handler

Coverity CID: 1357340
Approved by: scottl, markj
Differential Revision: https://reviews.freebsd.org/D20917

4 years agousr.sbin/bhyve: free resources if there is an initialization error in rfb
seanc [Thu, 11 Jul 2019 19:07:45 +0000 (19:07 +0000)]
usr.sbin/bhyve: free resources if there is an initialization error in rfb

Coverity CID: 1357335
Approved by: markj, jhb
Differential Revision: https://reviews.freebsd.org/D20919

4 years agoEnsure that mds_handler always points to a valid method.
kib [Thu, 11 Jul 2019 16:22:49 +0000 (16:22 +0000)]
Ensure that mds_handler always points to a valid method.

Depending on system configuration, version, and architecture,
mds_handler might be dereferenced from doreti before
hw_mds_recalculate_boot() initialized it.  Statically assign void
method to cover all cases.

Reported by: "Schuendehuette, Matthias (LDA IT PLM)" <matthias.schuendehuette@siemens.com>
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years agoRestore ability to pass NULL name argument to pthread_set_name_np(3)
kib [Thu, 11 Jul 2019 16:19:33 +0000 (16:19 +0000)]
Restore ability to pass NULL name argument to pthread_set_name_np(3)
to clear the thread name.

PR: 239142
Submitted by: Lewis Donzis <lew@perftech.com>
MFC after: 3 days

4 years agoFix some ISS bit definitions for data aborts.
markj [Thu, 11 Jul 2019 15:36:59 +0000 (15:36 +0000)]
Fix some ISS bit definitions for data aborts.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoMore fully implement the state machine.
imp [Thu, 11 Jul 2019 06:22:15 +0000 (06:22 +0000)]
More fully implement the state machine.

When a command is finished running, we must transition it from INQUEUE
to busy state. We were failing to do that, so we hit a panic when the
commands were freed. This only affects mpr, mps already did simmilar
things. Now both the polling and interrupt paths properly set BUSY as
appropriate.

4 years agoUpdate to jhb's other suggestion, use #error when
rrs [Thu, 11 Jul 2019 04:40:58 +0000 (04:40 +0000)]
Update to jhb's other suggestion, use #error when
we are missing  HPTS.

4 years agoUpdate copyright per JBH's suggestions.. thanks.
rrs [Thu, 11 Jul 2019 04:38:33 +0000 (04:38 +0000)]
Update copyright per JBH's suggestions.. thanks.

4 years agopowerpc: Only worry about the lower 32 bits of SP in a 32-bit process
jhibbits [Thu, 11 Jul 2019 03:29:25 +0000 (03:29 +0000)]
powerpc: Only worry about the lower 32 bits of SP in a 32-bit process

Summary:
Running a 32-bit process on a 64-bit POWER CPU may still use all 64-bits
in calculations, while ignoring the upper 32 bits for addressing
storage.  It so happens that some processes end up with r1 (SP) having
bit 31 set in some cases (33-bit address).  Writing out to this 33-bit
address obviosly fails.  Since the CPU ignores the upper bits, we should
as well.

sendsig() and cpu_fetch_syscall_args() appear to be the only functions
that actually rely on userspace register values for copy in/out, and
cpu_fetch_syscall_args() doesn't seem to be bitten in practice yet.

Reviewed By: luporl
Differential Revision: https://reviews.freebsd.org/D20896

4 years agoAccording to Section D5.10.3 "Maintenance requirements on changing System
alc [Thu, 11 Jul 2019 02:43:23 +0000 (02:43 +0000)]
According to Section D5.10.3 "Maintenance requirements on changing System
register values" of the architecture manual, an isb instruction should be
executed after updating ttbr0_el1 and before invalidating the TLB.  The
lack of this instruction in pmap_activate() appears to be the reason why
andrew@ and I have observed an unexpected TLB entry for an invalid PTE on
entry to pmap_enter_quick_locked().  Thus, we should now be able to revert
the workaround committed in r349442.

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20904

4 years agoAdd vm_page_hold.9 to ObsoleteFiles.inc.
markj [Thu, 11 Jul 2019 02:15:50 +0000 (02:15 +0000)]
Add vm_page_hold.9 to ObsoleteFiles.inc.

Add a missing .gz suffix to pwm.9 while here.

4 years agoipfilter commands, in this case ipf(8), passes its operations and rules
cy [Thu, 11 Jul 2019 00:08:46 +0000 (00:08 +0000)]
ipfilter commands, in this case ipf(8), passes its operations and rules
via an ioctl interface. Rules can be added or removed and stats and
counters can be zeroed out. As the ipfilter interprets these
instructions or operations they are stored in an integer called
addrem (add/remove). 1 is add, 2 is remove, and 3 is clear stats and
counters. Much of this is not documented. This commit documents these
operations by replacing simple integers with a self documenting
enum along with a few basic comments.

MFC after: 1 week

4 years agoRename pmap_page_dirty() to pmap_pte_dirty().
markj [Wed, 10 Jul 2019 22:52:26 +0000 (22:52 +0000)]
Rename pmap_page_dirty() to pmap_pte_dirty().

This is a precursor to implementing dirty bit management.

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

4 years agotelnet: fix minor style violation
philip [Wed, 10 Jul 2019 22:36:14 +0000 (22:36 +0000)]
telnet: fix minor style violation

While here also fix a very unlikely NULL pointer dereference.

Submitted by: Shawn Webb <shawn.webb@hardenedbsd.org>

4 years agoEnforce a 4GB DMA boundary on isci(4)
imp [Wed, 10 Jul 2019 22:23:59 +0000 (22:23 +0000)]
Enforce a 4GB DMA boundary on isci(4)

This device cannot cross a 4GB boundary with DMA.  Removing the
boundary in r346386 resulted in low frequency memory corruption on
machines with isci(4) controllers.

Submitted by: gallatin@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20910

4 years agoThis commit updates rack to what is basically being used at NF as
rrs [Wed, 10 Jul 2019 20:40:39 +0000 (20:40 +0000)]
This commit updates rack to what is basically being used at NF as
well as sets in some of the groundwork for committing BBR. The
hpts system is updated as well as some other needed utilities
for the entrance of BBR. This is actually part 1 of 3 more
needed commits which will finally complete with BBRv1 being
added as a new tcp stack.

Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D20834

4 years agoInherit P2_PROTMAX_{ENABLE,DISABLE} across fork().
markj [Wed, 10 Jul 2019 19:57:48 +0000 (19:57 +0000)]
Inherit P2_PROTMAX_{ENABLE,DISABLE} across fork().

Thus, when using proccontrol(1) to disable implicit application of
PROT_MAX within a process, child processes will inherit this setting.

Discussed with: kib
MFC with: r349609
Sponsored by: The FreeBSD Foundation

4 years agoReorganize the SRCS lists as one file per line, and then alphabetize them.
ian [Wed, 10 Jul 2019 19:32:50 +0000 (19:32 +0000)]
Reorganize the SRCS lists as one file per line, and then alphabetize them.
No functional changes.

4 years agotelnet: fix a couple of snprintf() buffer overflows
philip [Wed, 10 Jul 2019 17:42:04 +0000 (17:42 +0000)]
telnet: fix a couple of snprintf() buffer overflows

Obtained from: Juniper Networks
MFC after: 1 week

4 years agoFix compile errors with the CI20
imp [Wed, 10 Jul 2019 17:21:59 +0000 (17:21 +0000)]
Fix compile errors with the CI20

Fix mutex includes and fix a typo. The CI20 kernel is not built as
part of universe.

PR: 239115
Submitted by: Kai Nacke

4 years agoDe-pollute arm's sysarch.h.
ian [Wed, 10 Jul 2019 14:34:52 +0000 (14:34 +0000)]
De-pollute arm's sysarch.h.

Instead of including stdint.h for uintptr_t, include sys/_types.h and use
__types for everything that isn't a native C keyword type.

Remove the #include of cdefs.h.  It appears after the include of armreg.h
which has a precondition of cdefs.h being included before it, so everyone
including sysarch.h is already including cdefs.h.  (When armv5 support
goes away, there will be no need include armreg.h here either.)

Unfortunately, the unprefixed struct member names "addr" and "len" cannot
be changed, because 3rd-party software is relying on them (libcompiler_rt
is one known consumer).

4 years agolinuxcommon: add module version
avg [Wed, 10 Jul 2019 13:47:10 +0000 (13:47 +0000)]
linuxcommon: add module version

MFC after: 2 weeks

4 years ago[PPC64] pseries: fix realmaxaddr calculation
luporl [Wed, 10 Jul 2019 13:36:17 +0000 (13:36 +0000)]
[PPC64] pseries: fix realmaxaddr calculation

On POWER9/pseries, QEMU passes several regions of memory,
instead of a single region containing all memory, as the
code was expecting.

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

4 years agoowc_gpiobus: small formatting cleanup
avg [Wed, 10 Jul 2019 12:40:07 +0000 (12:40 +0000)]
owc_gpiobus: small formatting cleanup

MFC after: 1 week

4 years agoLet linuxulator mprotect mask unsupported bits before calling kern_mprotect.
tijl [Wed, 10 Jul 2019 08:19:33 +0000 (08:19 +0000)]
Let linuxulator mprotect mask unsupported bits before calling kern_mprotect.

After r349240 kern_mprotect returns EINVAL for unsupported bits in the prot
argument.  Linux rtld uses PROT_GROWSDOWN and PROT_GROWS_UP when marking the
stack executable.  Mask these bits like kern_mprotect used to do.  For other
unsupported bits EINVAL is returned like Linux does.

Reviewed by: trasz, brooks
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20864

4 years agoApply a workaround to be able to build clang 8.0.0 headers with clang
dim [Wed, 10 Jul 2019 05:57:37 +0000 (05:57 +0000)]
Apply a workaround to be able to build clang 8.0.0 headers with clang
3.4.1, which is still in the stable/10 branch.

It looks like clang 3.4.1 implements static_asserts by instantiating a
temporary static object, and if those are in an anonymous union, it
results in "error: anonymous union can only contain non-static data
members".

To work around this implementation limitation, move the static_asserts
in question out of the anonymous unions.

This should make building the latest stable/11 from stable/10 possible
again.

Reported by: Mike Tancsa <mike@sentex.net>
MFC after: 3 days

4 years agoAdd support for RTL8156, 2.5GbE USB network controller, to if_cdce(4).
hrs [Wed, 10 Jul 2019 05:45:50 +0000 (05:45 +0000)]
Add support for RTL8156, 2.5GbE USB network controller, to if_cdce(4).
This chip can be found in Planex USB-LAN2500R.

4 years agopowerpc: Clamp 32-bit binaries to 32-bit MAXUSER
jhibbits [Wed, 10 Jul 2019 04:09:15 +0000 (04:09 +0000)]
powerpc: Clamp 32-bit binaries to 32-bit MAXUSER

sv_maxuser specifies the maximum addressable space for user space.  Presently
this is all 64-bits worth, which is impossible for a 32-bit process.

This bug has existed since the initial import of powerpc64 in 2010.

MFC after: 2 weeks

4 years agoAdd pwm.9, it was also deleted during the big round of pwm changes.
ian [Wed, 10 Jul 2019 03:45:23 +0000 (03:45 +0000)]
Add pwm.9, it was also deleted during the big round of pwm changes.

4 years agoCorrect definitions in sys.opencrypto.runtests.main for 32bit platform
lwhsu [Wed, 10 Jul 2019 01:08:08 +0000 (01:08 +0000)]
Correct definitions in sys.opencrypto.runtests.main for 32bit platform

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

4 years agoUse 'retval' label for first error in syscallenter().
jhb [Tue, 9 Jul 2019 23:58:12 +0000 (23:58 +0000)]
Use 'retval' label for first error in syscallenter().

This is more consistent with the rest of the function and lets us
unindent most of the function.

Reviewed by: kib
MFC after: 1 month
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D20897

4 years agocxgbe(4): Clear the freelist statistics in the clearstats ioctl.
np [Tue, 9 Jul 2019 22:24:22 +0000 (22:24 +0000)]
cxgbe(4): Clear the freelist statistics in the clearstats ioctl.

Move all clearstats code into its own function while here.

MFC after: 1 week
Sponsored by: Chelsio Communications