]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoI add the ability to accept the default pin widget configuration to help
sbruno [Wed, 17 Jul 2019 04:13:46 +0000 (04:13 +0000)]
I add the ability to accept the default pin widget configuration to help
with various laptops using hdaa(4) sound devices.  We don't seem to know
the "correct" configurations for these devices and the defaults are far
superiour, e.g. they work if you don't nuke the default configs.

PR: 200526
Differential Revision: https://reviews.freebsd.org/D17772

4 years agobhyve: update the NVMe CQ based on the status
chuck [Wed, 17 Jul 2019 03:19:30 +0000 (03:19 +0000)]
bhyve: update the NVMe CQ based on the status

Instead of skipping the NVMe Completion Queue update based on the
opcode, define a synthetic status value which indicates the completion
queue entry is invalid. This will also allow deferred completion queue
updates for other commands.

Also returns the correct status for unrecognized opcodes ("invalid
opcode").

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

4 years agoMore follow-up to r350075, I forgot to update ObsoleteFiles.
kevlo [Wed, 17 Jul 2019 02:24:16 +0000 (02:24 +0000)]
More follow-up to r350075,  I forgot to update ObsoleteFiles.

Spotted by: lwhsu

4 years agoAdd an MLINK for igb.
kevlo [Wed, 17 Jul 2019 02:08:57 +0000 (02:08 +0000)]
Add an MLINK for igb.

Discussed with: lwhsu

4 years agoMention iflib(4).
kevlo [Wed, 17 Jul 2019 01:56:40 +0000 (01:56 +0000)]
Mention iflib(4).

4 years agoStyle.
mckusick [Tue, 16 Jul 2019 23:39:39 +0000 (23:39 +0000)]
Style.
No change intended.

4 years agoWhen a process attempts to allocate space on a full filesystem, a
mckusick [Tue, 16 Jul 2019 23:12:27 +0000 (23:12 +0000)]
When a process attempts to allocate space on a full filesystem, a
filesystem full message is sent to the offending process or the
kernel log if the offending process cannot be identified.

To prevent an explotion of messages, the kernel ppsratecheck()
function is used to limit the messages to one per second. This
revision changes the variable that tracks the rate of these messages
from a systemwide limit to a per-filesystem limit by moving it from
a global variable to a variable in the ufsmount structure.

Suggested by: kib
Reviewed by:  kib
Sponsored by: Netflix

4 years agoUse PT_GET_SC_ARGS and PT_GET_SC_RET in truss.
jhb [Tue, 16 Jul 2019 22:59:15 +0000 (22:59 +0000)]
Use PT_GET_SC_ARGS and PT_GET_SC_RET in truss.

This removes all of the architecture-specific functions from truss.

A per-ABI structure is still needed to map syscall numbers to names
and FreeBSD errno values to ABI error values as well as hold syscall
counters.  However, the linker set of ABI structures is now replaced
with a simple table mapping ABI names to structures.  This approach
permits sharing the same ABI structure among separate names such as
i386 a.out and ELF binaries as well as ELF v1 vs ELF v2 for powerpc64.

A few differences are visible due to using PT_GET_SC_RET to fetch the
error value of a system call.  Note that ktrace/kdump have had the
"new" behaviors for a long time already:
- System calls that return with EJUSTRETURN or ERESTART will now be
  noticed and logged as such.  Previously sigreturn (which uses
  EJUSTRETURN) would report whatever random value was in the register
  holding errno from the previous system call for example.  Now it
  reports EJUSTRETURN.
- System calls that return errno as their error value such as
  posix_fallocate() and posix_fadvise() now report non-zero return
  values as errors instead of success with a non-zero return value.

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

4 years agoAssume that the timeout value from the capacity is 1-based
imp [Tue, 16 Jul 2019 22:55:30 +0000 (22:55 +0000)]
Assume that the timeout value from the capacity is 1-based

Neither the 1.3 or 1.4 standards say this number is 1's based, but adding 1
costs little and copes with those NVMe drives that report '0' in this field
cheaply. This is consistent with what the Linux driver does as well.

4 years agoAdd missing mode in open(2) calls with O_CREAT.
brooks [Tue, 16 Jul 2019 22:27:49 +0000 (22:27 +0000)]
Add missing mode in open(2) calls with O_CREAT.

When O_CREAT is specified, the third, variadic argument is
required as the permission. If on is not passed, then depending
on the ABI, either the contents of the third argument register
or some arbitrary stuff on the stack will be used as the permission.

This has been merged to NetBSD.

Reviewed by: asomers, ngie
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D20972

4 years agoAs of upstream fil.c CVS r1.53 (March 1, 2009), prior to the import of
cy [Tue, 16 Jul 2019 19:00:42 +0000 (19:00 +0000)]
As of upstream fil.c CVS r1.53 (March 1, 2009), prior to the import of
ipfilter 5.1.2 into FreeBSD-10, the fix for, 2580062 from/to targets
should be able to use any interface name, moved frentry.fr_cksum to
prior to frentry.fr_func thereby making this code redundant. After
investigating whether this fix to move fr_cksum was correct and if it
broke anything, it has been determined that the fix is correct and this
code is redundant. We remove it here.

MFC after: 2 weeks

4 years agoRefactor, removing one compare.
cy [Tue, 16 Jul 2019 19:00:38 +0000 (19:00 +0000)]
Refactor, removing one compare.

This changes the return code however the caller only tests for 0 and != 0.
One might ask then, why multiple return codes when the caller only tests
for 0 and != 0? From what I can tell, Darren probably passed various
return codes for sake of debugging. The debugging code is long gone
however we can still use the different return codes using DTrace FBT
traces. We can still determine why the compare failed by examining the
differences between the fr1 and fr2 frentry structs, which is a simple
test in DTrace. This allows reducing the number of tests, improving the
code while not affecting our ability to capture information for
diagnostic purposes.

MFC after: 1 week

4 years agoFix compilation on platforms using gcc.
tuexen [Tue, 16 Jul 2019 17:54:20 +0000 (17:54 +0000)]
Fix compilation on platforms using gcc.
When compiling RACK on platforms using gcc, a warning that tcp_outflags
is defined but not used is issued and terminates compilation on PPC64,
for example. So don't indicate that tcp_outflags is used.

Reviewed by: rrs@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D20971

4 years agoImplement {io,admin}-passthru commands.
imp [Tue, 16 Jul 2019 17:24:25 +0000 (17:24 +0000)]
Implement {io,admin}-passthru commands.

These are mostly compatible with Linux, with three exceptions.
1. We don't do metadata segment stuff. Our passthrough interface
   doesn't cope. The code is there, but generates an error.
2. Linux lets you specify a namespace ID for the command. We current
   do not: we get ours from the namespace device, or pass in a generic
   one. Generally, this will lead to the same command, but FreeBSD's
   is safer since you can't specify the wrong id.
3. --show-command outputs to stderr instead of stdout so you can both
   see your command, and capture its output with a simple redirect.

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

4 years agoCreate generic command / arg parsing routines
imp [Tue, 16 Jul 2019 17:24:03 +0000 (17:24 +0000)]
Create generic command / arg parsing routines

Create a set of routines and structures to hold the data for the args
for a command. Use them to generate help and to parse args. Convert
all the current commands over to the new format. "comnd" is a hat-tip
to the TOPS-20 %COMND JSYS that (very) loosely inspired much of the
subsequent command line notions in the industry, but this is far
simpler (the %COMND man page is longer than this code) and not in the
kernel... Also, it implements today's de-facto
command [verb]+ [opts]* [args]*
format rather than the old, archaic TOPS-20 command format :)

This is a snapshot of a work in progress to get the nvme passthru
stuff committed. In time it will become a private library and used
by some other programs in the tree that conform to the above pattern.

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

4 years agoAdd a regression test which transfers varying number of rights.
markj [Tue, 16 Jul 2019 16:33:44 +0000 (16:33 +0000)]
Add a regression test which transfers varying number of rights.

This exercises the PKG_MAX_SIZE limit mentioned in r350054.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoUse a platform-independent constant for PKG_MAX_SIZE.
markj [Tue, 16 Jul 2019 16:28:50 +0000 (16:28 +0000)]
Use a platform-independent constant for PKG_MAX_SIZE.

This constant determines the number of rights libnv will attempt to
transmit in a given control message.  In practice, the upper limit
defined by the kernel is machine-dependent and is smaller on 64-bit
kernels than on 32-bit kernels.  To ensure that a 32-bit libnv works
as expected when run on a 64-bit kernel, use a limit that will work
on both 32-bit and 64-bit kernels.

PR: 238511
Discussed with: oshogbo
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20942

4 years agoConvert the nvlist send/recv tests to ATF.
markj [Tue, 16 Jul 2019 16:25:27 +0000 (16:25 +0000)]
Convert the nvlist send/recv tests to ATF.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoFix two mismatches between function declaration and definition.
brooks [Tue, 16 Jul 2019 16:03:08 +0000 (16:03 +0000)]
Fix two mismatches between function declaration and definition.

In both cases, function pointer arguments were inconsistently declared
and the result worked because of C's odd rules around function pointer
(de)references.  With a stricter compiler these fail to compile.

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

4 years agoChase r350037.
markj [Tue, 16 Jul 2019 16:02:20 +0000 (16:02 +0000)]
Chase r350037.

Reported by: jenkins
MFC with: r350037
Sponsored by: The FreeBSD Foundation

4 years agoAdds signal number format to kern.corefile
vangyzen [Tue, 16 Jul 2019 15:51:09 +0000 (15:51 +0000)]
Adds signal number format to kern.corefile

Add format capability to core file names to include signal
that generated the core. This can help various validation workflows
where all cores should not be considered equally (SIGQUIT is often
intentional and not an error unlike SIGSEGV or SIGBUS)

Submitted by: David Leimbach (leimy2k@gmail.com)
Reviewed by: markj
MFC after: 1 week
Relnotes: sysctl kern.corefile can now include the signal number
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20970

4 years agoAlways use the software DBM bit for now.
markj [Tue, 16 Jul 2019 15:41:09 +0000 (15:41 +0000)]
Always use the software DBM bit for now.

r350004 added most of the machinery needed to support hardware DBM
management, but it did not intend to actually enable use of the hardware
DBM bit.

Reviewed by: andrew
MFC with: r350004
Sponsored by: The FreeBSD Foundation

4 years agoFix the arm64 page table entry attribute mask.
markj [Tue, 16 Jul 2019 15:38:01 +0000 (15:38 +0000)]
Fix the arm64 page table entry attribute mask.

It did not include the DBM or contiguous bits.

Reported by: andrew
Reviewed by: andrew
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

4 years agoPropagate attribute changes during demotion.
markj [Tue, 16 Jul 2019 14:40:49 +0000 (14:40 +0000)]
Propagate attribute changes during demotion.

After r349117 and r349122, some mapping attribute changes do not trigger
superpage demotion. However, pmap_demote_l2() was not updated to ensure
that the replacement L3 entries carry any attribute changes that
occurred since promotion.

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

4 years agoAdd support for ICMPv6 messages indicating a parameter problem related
tuexen [Tue, 16 Jul 2019 12:57:59 +0000 (12:57 +0000)]
Add support for ICMPv6 messages indicating a parameter problem related
to an unrecognized next header.

MFC after: 2 weeks

4 years agoLet packet_op() explicitly return the type and code instead of doing
tuexen [Tue, 16 Jul 2019 12:38:17 +0000 (12:38 +0000)]
Let packet_op() explicitly return the type and code instead of doing
this implicitly by encoding it in a number space.

No functional change intended.

This is done as a preparation to add support for ICMPv6 mesages
indicating a parameter problem related to the next header.

MFC after: 2 weeks

4 years agoWhitespace change. No functional change.
tuexen [Tue, 16 Jul 2019 10:06:41 +0000 (10:06 +0000)]
Whitespace change. No functional change.

MFC after: 2 weeks

4 years agobge: check that the bus is a pci bus before using it as such
avg [Tue, 16 Jul 2019 08:36:49 +0000 (08:36 +0000)]
bge: check that the bus is a pci bus before using it as such

This fixes the following panic on powerpc:
  pci_get_vendor failed for pcib1 on bus ofwbus0, error = 2

PR: 238730
Reported by: Dennis Clarke <dclarke@blastwave.org>
Tested by: Dennis Clarke <dclarke@blastwave.org>
MFC after: 2 weeks

4 years agostrings: extends rights
oshogbo [Tue, 16 Jul 2019 04:17:25 +0000 (04:17 +0000)]
strings: extends rights

The libelf is using mmap if it can, if not it was fall backing to read.

Reported by: markj

4 years agopowerpc: Fix casueword(9) post-r349951
jhibbits [Tue, 16 Jul 2019 03:55:27 +0000 (03:55 +0000)]
powerpc: Fix casueword(9) post-r349951

'=' asm constraint marks a variable as write-only.  Because of this, gcc
throws away the initialization of 'res', causing garbage to be returned if
the CAS was successful.  Use '+' to mark res as read/write, so that the
initialization stays in the generated asm.  Also, fix the reservation
clearing stwcx store index register in casueword32, and only do the dummy
store when needed, skip it if the real store has already succeeded.

4 years agostrings: fix entering to the capability mode
oshogbo [Tue, 16 Jul 2019 03:32:21 +0000 (03:32 +0000)]
strings: fix entering to the capability mode

Reported by: markj

4 years agoRevert r349973. Upon further reflection, I realized that the comment
alc [Tue, 16 Jul 2019 03:09:03 +0000 (03:09 +0000)]
Revert r349973.  Upon further reflection, I realized that the comment
deleted by r349973 is still valid on i386.  Restore it.

Discussed with:    markj

4 years agoUse a different approach to range check.
imp [Mon, 15 Jul 2019 23:43:38 +0000 (23:43 +0000)]
Use a different approach to range check.

gcc hates dt < CC_DT_NONE since it can never be true when dt is an unsigned
type. Since that's a compiler choice and may be affected by weird stuff, instead
use (unsigned)dt > CC_DT_UNKNOWN to test for bounds error since that will work
regardless of the signedness of dt.

4 years agoFix filename to avoid skipping lib/libc/net/servent test.
olivier [Mon, 15 Jul 2019 23:41:00 +0000 (23:41 +0000)]
Fix filename to avoid skipping lib/libc/net/servent test.

PR: 239177
Approved by: ngie
MFC after: 1 month
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20943

4 years agoImplement a devtype command.
imp [Mon, 15 Jul 2019 22:33:37 +0000 (22:33 +0000)]
Implement a devtype command.

List the device's protocol. The returned value is one of the following:
ata direct attach ATA or SATA device
satl a SATA device attached via SAS
scsi A parallel SCSI or SAS
nvme A direct attached NVMe device
mmcsd A MMC or SD attached device

Reviewed by: scottl@, rpokala@
Differential Revision: https://reviews.freebsd.org/D20950

4 years agoAdd ptrace op PT_GET_SC_RET.
jhb [Mon, 15 Jul 2019 21:48:02 +0000 (21:48 +0000)]
Add ptrace op PT_GET_SC_RET.

This ptrace operation returns a structure containing the error and
return values from the current system call.  It is only valid when a
thread is stopped during a system call exit (PL_FLAG_SCX is set).

The sr_error member holds the error value from the system call.  Note
that this error value is the native FreeBSD error value that has _not_
been translated to an ABI-specific error value similar to the values
logged to ktrace.

If sr_error is zero, then the return values of the system call will be
set in sr_retval[0] and sr_retval[1].

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

4 years agoIn nxprtc(4), use the countdown timer for better timekeeping resolution
ian [Mon, 15 Jul 2019 21:47:40 +0000 (21:47 +0000)]
In nxprtc(4), use the countdown timer for better timekeeping resolution
on PCx2129 chips too.

The datasheet for the PCx2129 chips says that there is only a watchdog
timer, no countdown timer.  It turns out the countdown timer hardware is
there and works just the same as it does on a PCx2127 chip, except that you
can't use it to trigger an interrupt or toggle an output pin.  We don't need
interrupts or output pins, we only need to read the timer register to get
sub-second resolution.  So start treating the 2129 chips the same as 2127.

4 years agoFix nxprtc(4) on systems that support i2c repeat-start correctly.
ian [Mon, 15 Jul 2019 21:40:58 +0000 (21:40 +0000)]
Fix nxprtc(4) on systems that support i2c repeat-start correctly.

An obscure footnote in the datasheets for the PCx2127, PCx2129, and
PCF8523 rtc chips states that the chips do not support i2c repeat-start
operations.  When the driver was originally written and tested, the i2c
bus on that system also didn't support repeat-start and just quietly
turned repeat-start operations into a stop-then-start, making it appear
that the nxprtc driver was working properly.

The repeat-start situation only comes up on reads, so instead of using
the standard iicdev_readfrom(), use a local nxprtc_readfrom(), which is
just a cut-and-pasted copy of iicdev_readfrom(), modified to send two
separate start-data-stop sequences instead of using repeat-start.

4 years agoAdd a test for PT_GET_SC_ARGS.
jhb [Mon, 15 Jul 2019 21:26:55 +0000 (21:26 +0000)]
Add a test for PT_GET_SC_ARGS.

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

4 years agoDon't pass error from syscallenter() to syscallret().
jhb [Mon, 15 Jul 2019 21:25:16 +0000 (21:25 +0000)]
Don't pass error from syscallenter() to syscallret().

syscallret() doesn't use error anymore.  Fix a few other places to permit
removing the return value from syscallenter() entirely.
- Remove a duplicated assertion from arm's syscall().
- Use td_errno for amd64_syscall_ret_flush_l1d.

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

4 years agoAlways set td_errno to the error value of a system call.
jhb [Mon, 15 Jul 2019 21:16:01 +0000 (21:16 +0000)]
Always set td_errno to the error value of a system call.

Early errors prior to a system call did not set td_errno.  This commit
sets td_errno for all errors during syscallenter().  As a result,
syscallret() can now always use td_errno without checking TDP_NERRNO.

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

4 years agoDon't free read control entries, which are still on the stream queue when
tuexen [Mon, 15 Jul 2019 20:45:01 +0000 (20:45 +0000)]
Don't free read control entries, which are still on the stream queue when
adding them the the read queue fails

MFC after: 1 week

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.