]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoar: use array notation to access s_so
emaste [Mon, 22 Apr 2019 17:29:26 +0000 (17:29 +0000)]
ar: use array notation to access s_so

This is somewhat more readable than pointer arithmetic.  Also remove an
unnecessary cast while here.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

5 years agoar: test for writing 64-bit format only if symbol count is nonzero
emaste [Mon, 22 Apr 2019 17:25:00 +0000 (17:25 +0000)]
ar: test for writing 64-bit format only if symbol count is nonzero

This is a minor simplification; if we do not have any symbols the empty
symbol table can be in 32-bit format.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

5 years agocxgbe(4): Make sure bundled_fw is always initialized before use.
np [Mon, 22 Apr 2019 17:00:30 +0000 (17:00 +0000)]
cxgbe(4): Make sure bundled_fw is always initialized before use.

This fixes a bug that prevented the driver from auto-flashing the
firmware when it didn't see one on the card.  This feature was
introduced in r321390 and this bug was introduced in r343269.

Reported by: gallatin@
MFC after: 1 week
Sponsored by: Chelsio Communications

5 years agorandom.3: Remove obsolete BUGS section
cem [Mon, 22 Apr 2019 16:29:34 +0000 (16:29 +0000)]
random.3: Remove obsolete BUGS section

Relative performance to rand(3) is sort of irrelevant; they do different things
and a user with sensitivity to RNG performance won't use libc random(3) anyway.

The historical note about bad seeding is long obsolete, referring to a 1996 or
earlier version of FreeBSD.

Sponsored by: Dell EMC Isilon

5 years agorand.3: Match better recommendation language from random.3
cem [Mon, 22 Apr 2019 16:26:39 +0000 (16:26 +0000)]
rand.3: Match better recommendation language from random.3

Sponsored by: Dell EMC Isilon

5 years agor297225 move the assignment of sin from add to the top of the function.
bz [Mon, 22 Apr 2019 14:53:53 +0000 (14:53 +0000)]
r297225 move the assignment of sin from add to the top of the function.
sin is not changed after the initial assignment, so no need to set it again.

MFC after: 10 days

5 years agoRemove some excessive brackets.
bz [Mon, 22 Apr 2019 14:20:49 +0000 (14:20 +0000)]
Remove some excessive brackets.

No functional change.

MFC after: 10 days

5 years agoUse separate descriptors in bhyve's stdio uart backend.
markj [Mon, 22 Apr 2019 13:57:52 +0000 (13:57 +0000)]
Use separate descriptors in bhyve's stdio uart backend.

bhyve was previously using stdin for both reading and writing to the
console, which made it difficult to redirect console output.  Use
stdin for reading and stdout for writing.  This makes it easier to use
bhyve as a backend for syzkaller.

As a side effect, the change fixes a minor bug which would cause bhyve
to fail with ENOTCAPABLE if configured to use nmdm for com1 and stdio
for com2.

bhyveload already uses separate descriptors, as does the bvmcons driver.

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

5 years agolibbe(3): Add a test for be creation
kevans [Mon, 22 Apr 2019 13:45:08 +0000 (13:45 +0000)]
libbe(3): Add a test for be creation

Submitted by: Rob Fairbanks <rob.fx907 gmail com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D18564

5 years agolibbe(3): allow creation of arbitrary depth boot environments
kevans [Mon, 22 Apr 2019 13:43:38 +0000 (13:43 +0000)]
libbe(3): allow creation of arbitrary depth boot environments

libbe currently only provides an API to create a recursive boot environment,
without any formal support for intentionally limiting the depth. This
changeset adds an API, be_create_depth, that may be used to arbitrarily
restrict the depth of the new BE.

Submitted by: Rob Fairbanks <rob.fx907 gmail com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D18564

5 years agoClarify the relationship between INVARIANTS and DIAGNOSTIC a bit.
markj [Mon, 22 Apr 2019 11:31:13 +0000 (11:31 +0000)]
Clarify the relationship between INVARIANTS and DIAGNOSTIC a bit.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

5 years agoDisable vm map consistency checking by default on INVARIANTS kernels.
markj [Mon, 22 Apr 2019 11:23:35 +0000 (11:23 +0000)]
Disable vm map consistency checking by default on INVARIANTS kernels.

The checks are too expensive for a general-purpose kernel.  Enable the
checks when DIAGNOSTIC is defined and provide a sysctl to enable the
checks in a non-DIAGNOSTIC INVARIANTS kernel.

Reviewed by: kib
Discussed with: Doug Moore <dougm@rice.edu>
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19999

5 years agoFix sys.kern.coredump_phnum_test.coredump_phnum on i386
ngie [Mon, 22 Apr 2019 11:21:20 +0000 (11:21 +0000)]
Fix sys.kern.coredump_phnum_test.coredump_phnum on i386

The zero-padding when printing out the Size field is on 32-bit architectures is
5, not 15. Adjust the regular expression to work with both the 32-bit and
64-bit case.

MFC after: 1 week
Reviewed by: lwhsu, markj
Approved by: emaste (mentor, implicit)
Differential Revision: https://reviews.freebsd.org/D20005

5 years agoFix `get_int_via_sysctlbyname(..)` on Jenkins
ngie [Mon, 22 Apr 2019 11:09:24 +0000 (11:09 +0000)]
Fix `get_int_via_sysctlbyname(..)` on Jenkins

Initialize `oldlen` to the size of the value, instead of leaving the value
unitialized. Leaving it unitialized seems to work by accident on amd64 when
running 64-bit programs, but not on i386.

This matches patterns in use in other programs.

PR: 237458
Approved by: emaste (mentor; implicit)
MFC after: 1 week
Tested on: ^/head (amd64), ^/stable/11 (i386)

5 years agoFix build for mips and powerpc after r346530.
hselasky [Mon, 22 Apr 2019 08:32:00 +0000 (08:32 +0000)]
Fix build for mips and powerpc after r346530.

Need to include sys/kernel.h to define SYSINIT() which is used
by sys/eventhandler.h .

MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agoFix panic in network stack due to memory use after free in relation to
hselasky [Mon, 22 Apr 2019 07:27:24 +0000 (07:27 +0000)]
Fix panic in network stack due to memory use after free in relation to
fragmented packets.

When sending IPv4 and IPv6 fragmented packets and a fragment is lost,
the mbuf making up the fragment will remain in the temporary hashed
fragment list for a while. If the network interface departs before the
so-called slow timeout clears the packet, the fragment causes a panic
when the timeout kicks in due to accessing a freed network interface
structure.

Make sure that when a network device is departing, all hashed IPv4 and
IPv6 fragments belonging to it, get freed.

Backtrace:
panic()
icmp6_reflect()

hlim = ND_IFINFO(m->m_pkthdr.rcvif)->chlim;
^^^^ rcvif->if_afdata[AF_INET6] is NULL.

icmp6_error()
frag6_freef()
frag6_slowtimo()
pfslowtimo()
softclock_call_cc()
softclock()
ithread_loop()

Differential Revision: https://reviews.freebsd.org/D19622
Reviewed by: bz (network), adrian
MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agognop(8): Nopify configuration as a kernel dump device
cem [Mon, 22 Apr 2019 03:25:49 +0000 (03:25 +0000)]
gnop(8): Nopify configuration as a kernel dump device

As a dummy / no-op dump device, to facilitate dumpon(8) testing.

Reviewed by: markj (earlier version)
Differential Revision: https://reviews.freebsd.org/D19991

5 years agoReport DIF protection type the disk is formatted with.
mav [Mon, 22 Apr 2019 01:08:14 +0000 (01:08 +0000)]
Report DIF protection type the disk is formatted with.

Some disks formatted with protection report errors if written without
protection used.  This should help to diagnose the problem.

MFC after: 2 weeks

5 years agoAdd #ifdef INET as requested by bz@.
rmacklem [Sun, 21 Apr 2019 22:53:51 +0000 (22:53 +0000)]
Add #ifdef INET as requested by bz@.

5 years agoPolish SCSI sense data validity checks.
mav [Sun, 21 Apr 2019 19:07:03 +0000 (19:07 +0000)]
Polish SCSI sense data validity checks.

According to specs and common sense, all sense data reported in descriptor
format should be valid.  But practice shows different, some devices return
descriptors with invalid data, resulting in error messages looking worse.

Decouple block/stream commands sense data and information field printing.
Looking on present specs, there are much more cases when those fields are
not related, and incomplete old code was not printing valid sense data and
leaving empty lines for invalid.

MFC after: 2 weeks

5 years agoTypo fix in ipfw.8: amd -> and
bcr [Sun, 21 Apr 2019 18:27:13 +0000 (18:27 +0000)]
Typo fix in ipfw.8: amd -> and

There is an (obvious) typo in the following sentence:

"Please note, that keep-state amd limit imply implicit check-state for ..."

Replace the "amd" with "and", bump .Dd.

PR: 237438
Submitted by: michael@galassi.us
MFC after: 3 days

5 years agoMove the reporting of spurious interrupts under bootverbose control, because
ian [Sun, 21 Apr 2019 17:39:01 +0000 (17:39 +0000)]
Move the reporting of spurious interrupts under bootverbose control, because
occasional spurious interrupts are a normal thing on this hardware.  Also,
change the name of the cpu-local interrupt controller driver from local_intc
to lintc, because the name gets built into interrupt names, which have to
fit into a 19-byte field for stats reporting (so this allows 5 more bytes
of the actual interrupt name to be displayed).

5 years agoUse a shadow buffer and never read from the frame buffer. Remove large slow
bde [Sun, 21 Apr 2019 16:17:35 +0000 (16:17 +0000)]
Use a shadow buffer and never read from the frame buffer.  Remove large slow
code for reading from the frame buffer.

Reading from the frame buffer is usually much slower than writing to
the frame buffer.  Typically 10 to 100 times slower.  It old modes,
it takes many more PIOs, and in newer modes with no PIOs writes are
often write-combined while reads remain uncached.

Reading from the frame buffer is not very common, so this change doesn't
give speedups of 10 to 100 times.  My main test case is a floodfill()
function that reads about as many pixels as it writes.  The speedups
are typically a factor of 2 to 4.

Duplicating writes to the shadow buffer is slower when no reads from the
frame buffer are done, but reads are often done for the pixels under the
mouse cursor, and doing these reads from the shadow buffer more than
compensates for the overhead of writing the shadow buffer in at least the
slower modes.  Management of the mouse cursor also becomes simpler.

The shadow buffer doesn't take any extra memory, except twice as much
in old 4-plane modes.  A buffer for holding a copy of the frame buffer
was allocated up front for use in the screen switching signal handler.
This wasn't changed when the handler was made async-signal safe.  Use
the same buffer the shadow (but make it twice as large in the 4-plane
modes), and remove large special code for writing it as well as large
special code for reading ut.  It used to have a rawer format in the
4-plane modes.  Now it has a bitmap format which takes twice as much
memory but can be written almost as fast without special code.

VIDBUFs that are not the whole frame buffer were never supported, and the
change depends on this.  Check for invalid VIDBUFs in some places and do
nothing.  The removed code did something not so good.

5 years agoFix missing restoring of the mouse cursor position, the border color and the
bde [Sun, 21 Apr 2019 10:33:09 +0000 (10:33 +0000)]
Fix missing restoring of the mouse cursor position, the border color and the
blank state after a screen switch.

5 years ago[ath] [ath_hal] [ath_hal_9300] Extend the start PCU receive to handle resetting ANI.
adrian [Sun, 21 Apr 2019 02:36:01 +0000 (02:36 +0000)]
[ath] [ath_hal] [ath_hal_9300] Extend the start PCU receive to handle resetting ANI.

One of the fun issues with scanning has been how the existing
ANI values were programmed into the hardware when channels were
changed.  If you're on a really crappy channel and ANI has made
you deaf then when you scan you continue to be deaf on all channels.

This code passes in a flag to startpcureceive which in AR5416 and later
is also used to enable ANI.  This allows it to know if it's a normal
operation or a scan operation.

This fixes my situation at home where a temporary spot of a device
going deaf due to interference starts scanning and .. can't hear
anything until I restart.

Now, this isn't the full fix - ideally:

(a) all the ANI config and per-channel information would be migrated
     to the shared HAL stuff and enabled for all of the NICs;
(b) when a station reassociates and some other error conditions
    (like missed beacons, NF calibration failures, etc) a knob
    to reset ANI parameters would likely help recovery.

But hey, I'm committing bits of code again! woo!

Tested:

* AR9344 (2G), STA operation

5 years agodtc(1): Pull in fix for segfault-upon-error condition
kevans [Sun, 21 Apr 2019 01:58:42 +0000 (01:58 +0000)]
dtc(1): Pull in fix for segfault-upon-error condition

Specifically, parse errors within a node would lead to a segfault due to
an unconditional dereference after emitting the error.

Obtained from: https://github.com/davidchisnall/dtc/commit/e5ecf9319fd3f
MFC after: 3 days

5 years agoMFV r346450:
cy [Sat, 20 Apr 2019 23:18:19 +0000 (23:18 +0000)]
MFV r346450:

Update sqlite3-3.27.1 (3270100) --> sqlite3-3.27.2 (3270200)

MFC after: 11 days

5 years agopsm(4): give names to synaptics commands
wulf [Sat, 20 Apr 2019 21:06:12 +0000 (21:06 +0000)]
psm(4): give names to synaptics commands

Submitted by: Ben LeMasurier <ben@crypt.ly>
MFC after: 2 weeks

5 years agopsm(4): respect tap_disabled configuration with enabled Extended support
wulf [Sat, 20 Apr 2019 21:04:56 +0000 (21:04 +0000)]
psm(4): respect tap_disabled configuration with enabled Extended support

This fixes a bug where, even when hw.psm.tap_enabled=0, touchpad taps
were processed.
tap_enabled has three states: unconfigured, disabled, and enabled (-1, 0, 1).
To respect PR kern/139272, taps are ignored only when explicity disabled.

Submitted by: Ben LeMasurier <ben@crypt.ly> (initial version)
MFC after: 2 weeks

5 years agopsm(4): do not process gestures when palm is present
wulf [Sat, 20 Apr 2019 21:02:41 +0000 (21:02 +0000)]
psm(4): do not process gestures when palm is present

Ignoring of gesture processing when the palm is detected helps to reduce
some of the erratic pointer behavior.

This fixes regression introduced in r317814

Reported by: Ben LeMasurier <ben@crypt.ly>
MFC after: 2 weeks

5 years agopsm(4): Add support for 4 and 5 finger touches in synaptics driver
wulf [Sat, 20 Apr 2019 21:00:44 +0000 (21:00 +0000)]
psm(4): Add support for 4 and 5 finger touches in synaptics driver

While 4-th and 5-th finger positions are not exported through PS/2
interface, total number of touches is reported by MT trackpads.

MFC after: 2 weeks

5 years agoMake libvgl mostly work without superuser privilege in direct modes by
bde [Sat, 20 Apr 2019 20:29:03 +0000 (20:29 +0000)]
Make libvgl mostly work without superuser privilege in direct modes by
not doing any unnecessary PIO instructions or refusing to start when the
i/o privilege needed for these instructions cannot be acquired.

This turns off useless palette management in direct modes.  Palette
management had no useful effect since the hardware palette is not used
in these modes.

This transiently acquires i/o privilege if possible as needed to give
VGLSetBorder() and VGLBlankDisplay() a chance of working.  Neither has
much chance of working.  I was going to drop support for them in direct
modes, but found that VGLBlankDisplay() still works with an old graphics
card on a not so old LCD monitor.

This has some good side effects: reduce glitches for managing the palette
for screen switches, and speed up and reduce async-signal-unsafeness in
mouse cursor drawing.

5 years agoRevert r346443
ngie [Sat, 20 Apr 2019 16:37:28 +0000 (16:37 +0000)]
Revert r346443

My wide sweeping stylistic change (while well intended) is impeding others from
working on `tests/sys/opencrypto`.

The plan is to revert the change in ^/head, then reintroduce the changes after
the other changes get merged into ^/head .

Approved by: emaste (mentor; implicit)
Requested by: jhb
MFC after: 2 months

5 years agonetdump: Fix 11 compatibility DIOCSKERNELDUMP ioctl
cem [Sat, 20 Apr 2019 16:07:29 +0000 (16:07 +0000)]
netdump: Fix 11 compatibility DIOCSKERNELDUMP ioctl

The logic was present for the 11 version of the DIOCSKERNELDUMP ioctl, but
had not been updated for the 12 ABI.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D19980

5 years agoEnable ioremap for aarch64 in the LinuxKPI
emaste [Sat, 20 Apr 2019 15:57:05 +0000 (15:57 +0000)]
Enable ioremap for aarch64 in the LinuxKPI

Required for Mellanox drivers (e.g. on Ampere eMAG at Packet.com).

PR: 237055
Submitted by: Greg V <greg@unrelenting.technology>
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D19987

5 years agotests/sys/opencrypto: fix whitespace per PEP8
ngie [Sat, 20 Apr 2019 15:43:28 +0000 (15:43 +0000)]
tests/sys/opencrypto: fix whitespace per PEP8

Replace hard tabs with four-character indentations, per PEP8.

This is being done to separate stylistic changes from the tests from functional
ones, as I accidentally introduced a bug to the tests when I used four-space
indentation locally.

No functional change.

MFC after: 2 months
Approved by: emaste (mentor: implicit blanket approval for trivial fixes)

5 years agoUse symlinks for kernel modules rather than hardlinks
asomers [Sat, 20 Apr 2019 12:51:05 +0000 (12:51 +0000)]
Use symlinks for kernel modules rather than hardlinks

When aliasing a kernel module to a different name (ie if_igb for if_em),
it's better to use symlinks than hard links. kldxref will omit entries for
the links, ensuring that the loaded module has the correct name.

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

5 years agoExport cpu_core from opensolaris.ko.
markj [Sat, 20 Apr 2019 11:34:53 +0000 (11:34 +0000)]
Export cpu_core from opensolaris.ko.

It is referenced by dtrace*.ko.

PR: 191462
Submitted by: me.freebsd@cgf.cx
MFC after: 1 week

5 years agoSpecify using Python2, these .py files have not been converted to use Python3
lwhsu [Sat, 20 Apr 2019 07:32:29 +0000 (07:32 +0000)]
Specify using Python2, these .py files have not been converted to use Python3
yet, but the default Python version in ports has been switched to 3.

Sponsored by: The FreeBSD Foundation

5 years agoStart to reduce the number of #ifdef EFI_ZFS_BOOT
imp [Sat, 20 Apr 2019 05:31:56 +0000 (05:31 +0000)]
Start to reduce the number of #ifdef EFI_ZFS_BOOT

There's a number of EFI_ZFS_BOOT #ifdefs that aren't needed, or can be
eliminated with some trivial #defines. Remove the EFI_ZFS_BOOT ifdefs
that aren't needed. Replace libzfs.h include which is not safe to
include without EFI_ZFS_BOOT with efizfs.h which is and now
conditionally included libzfs.h. Define efizfs_set_preferred away
and define efi_zfs_probe to NULL when ZFS is compiled out.

5 years agoAdd SY8106A Buck Regulator and Allwinner CIR devices to GENERIC arm64 kernel.
ganbold [Sat, 20 Apr 2019 03:21:47 +0000 (03:21 +0000)]
Add SY8106A Buck Regulator and Allwinner CIR devices to GENERIC arm64 kernel.

5 years agocron(8): schedule interval jobs that get loaded during execution
kevans [Sat, 20 Apr 2019 02:54:20 +0000 (02:54 +0000)]
cron(8): schedule interval jobs that get loaded during execution

Jobs using the @<second> syntax currently only get executed if they exist
when cron is started. The simplest reproducer of this is:

echo '@20 root echo "Hello!"' >> /etc/cron.d/myjob

myjob will get loaded at the next second==0, but this echo job will not
run until cron restarts. These jobs are normally handled in
run_reboot_jobs(), which sets e->lastexit of INTERVAL jobs to the startup
time so they run 'n' seconds later.

Fix this by special-casing TargetTime > 0 in the database load. Preexisting
jobs will be handled at startup during run_reboot_jobs as normal, but if
we've reloaded a database during runtime we'll hit this case and set
e->lastexit to the current time when we process it. They will then run every
'n' seconds from that point, and a full restart of cron is no longer
required to make these jobs work.

Reported by: Juraj Lutter (otis_sk.freebsd.org)
Reviewed by: allanjude, bapt, bjk (earlier version), Juraj Lutter
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D19924

5 years agopowerpc64/powernv: Relax flash block write requirements
jhibbits [Sat, 20 Apr 2019 02:44:38 +0000 (02:44 +0000)]
powerpc64/powernv: Relax flash block write requirements

Since writes don't necessarily need to be on erase-block boundaries, we can
relax the block size and alignments down to sector size.  If it needs to be
erased, opalflash_erase() will check proper alignment and size.

5 years agoAdd support for the ModeSetMasked attribute to the NFSv4.1 server.
rmacklem [Fri, 19 Apr 2019 23:35:08 +0000 (23:35 +0000)]
Add support for the ModeSetMasked attribute to the NFSv4.1 server.

I do not know of an extant NFSv4.1 client that currently does a Setattr
operation for the ModeSetMasked, but it has been discussed on the linux-nfs
mailing list.
This patch adds support for doing a Setattr of ModeSetMasked, so that it
will work for any future NFSv4.1 client that chooses to do so.
Tested via a hacked FreeBSD NFSv4.1 client.

MFC after: 2 weeks

5 years agoReplace "vp" with NULL to make the code more readable.
rmacklem [Fri, 19 Apr 2019 23:27:23 +0000 (23:27 +0000)]
Replace "vp" with NULL to make the code more readable.

At the time of this nfsv4_sattr() call, "vp == NULL", so this patch doesn't
change the semantics, but I think it makes the code more readable.
It also makes it consistent with the nfsv4_sattr() call a few lines above
this one. Found during code inspection.

MFC after: 2 weeks

5 years agoTest SHA2-224-HMAC now that OCF supports it.
jhb [Fri, 19 Apr 2019 22:20:42 +0000 (22:20 +0000)]
Test SHA2-224-HMAC now that OCF supports it.

Reviewed by: cem
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D19882

5 years agoRevert r346410 and r346411
cem [Fri, 19 Apr 2019 22:08:17 +0000 (22:08 +0000)]
Revert r346410 and r346411

libkern in .PATH has too many filename conflicts with libc and my -DNO_CLEAN
tinderbox didn't catch that ahead of time.  Mea culpa.

5 years agoSync cryptographic algorithm constants with current cryptodev.h.
jhb [Fri, 19 Apr 2019 21:58:51 +0000 (21:58 +0000)]
Sync cryptographic algorithm constants with current cryptodev.h.

Reviewed by: cem
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D19881

5 years agoFix copying of overlapping bitmaps. The cases of copying within the
bde [Fri, 19 Apr 2019 20:29:49 +0000 (20:29 +0000)]
Fix copying of overlapping bitmaps.  The cases of copying within the
screen bitmap and within a single MEMBUF were broken when first source
line is before the first destination line and the sub-bitmaps overlap.

The fix just copies horizontal lines in reverse order when the first
source line is before the first destination line.  This switches
directions unnecessarily in some cases, but the switch is about as
fast as doing a precise detection of overlaps.  When the first lines
are the same, there can be undetected overlap in the horizontal
direction.  The old code already handles this mostly accidentally by
using bcopy() for MEMBUFs and by copying through a temporary buffer
for the screen bitmap although the latter is sub-optimal in direct
modes.

5 years agokernel build: Disable unhelpful GCC warning (tripped after r346352)
cem [Fri, 19 Apr 2019 20:08:45 +0000 (20:08 +0000)]
kernel build: Disable unhelpful GCC warning (tripped after r346352)

-Wformat-zero-length does not highlight any particularly wrong code and it
is especially meaningless for device_printf().  Turn it off entirely to
remove a source of false positives.

Sponsored by: Dell EMC Isilon

5 years agoBump __FreeBSD_version after r346410
cem [Fri, 19 Apr 2019 20:06:22 +0000 (20:06 +0000)]
Bump __FreeBSD_version after r346410

5 years agolibkern: Bring in arc4random_uniform(9) from libc
cem [Fri, 19 Apr 2019 20:05:47 +0000 (20:05 +0000)]
libkern: Bring in arc4random_uniform(9) from libc

It is a useful arc4random wrapper in the kernel for much the same reasons as
in userspace.  Move the source to libkern (because kernel build is
restricted to sys/, but userspace can include any file it likes) and build
kernel and libc versions from the same source file.

Copy the documentation from arc4random_uniform(3) to the section 9 page.

While here, add missing arc4random_buf(9) symlink.

Sponsored by: Dell EMC Isilon

5 years agoAdd wrapper functions to convert strings to EFI_DEVICE_PATH
imp [Fri, 19 Apr 2019 19:45:19 +0000 (19:45 +0000)]
Add wrapper functions to convert strings to EFI_DEVICE_PATH

In anticipation of new functionality, create routines to convert char *
and a CHAR16 * to a EFI_DEVICE_PATH
EFI_DEVICE_PATH *efi_name_to_devpath(const char *path);
EFI_DEVICE_PATH *efi_name_to_devpath16(CHAR16 *path);
void efi_devpath_free(EFI_DEVICE_PATH *dp);
The first two return an EFI_DEVICE_PATH for the passed in paths. The
third frees up the storage the first two return when the caller is
done with it.

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

5 years agoAdd UEFI definitions related to converting string to DEVICE_PATH
imp [Fri, 19 Apr 2019 19:45:15 +0000 (19:45 +0000)]
Add UEFI definitions related to converting string to DEVICE_PATH

Add definitions from UEFI 2.7 Errata B standards doc for converting a
text string to a device path. Added clearly missing 'e' at the end of
Device to resolve mismatch in that document in
EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL element names.

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

5 years agoAdd define for CONST.
imp [Fri, 19 Apr 2019 19:44:59 +0000 (19:44 +0000)]
Add define for CONST.

Newer interfaces take CONST parameters, so define CONST to minimize
differences between our headers and the standards docs.

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

5 years agoWhen an IPv6 packet is received for a raw socket which has the
tuexen [Fri, 19 Apr 2019 18:09:37 +0000 (18:09 +0000)]
When an IPv6 packet is received for a raw socket which has the
IPPROTO_IPV6 level socket option IPV6_CHECKSUM enabled and the
checksum check fails, drop the message. Without this fix, an
ICMP6 message was sent indicating a parameter problem.

Thanks to bz@ for suggesting a way to simplify this fix.

Reviewed by: bz@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19969

5 years ago[ath] Fix return value check to not complain.
adrian [Fri, 19 Apr 2019 18:00:33 +0000 (18:00 +0000)]
[ath] Fix return value check to not complain.

Compilers complain more about things, so let's keep them happy.

5 years agoWhen a checksum has to be computed for a received IPv6 packet because it
tuexen [Fri, 19 Apr 2019 17:28:28 +0000 (17:28 +0000)]
When a checksum has to be computed for a received IPv6 packet because it
is requested by the application using the IPPROTO_IPV6 level socket option
IPV6_CHECKSUM on a raw socket, ensure that the packet contains enough
bytes to contain the checksum at the specified offset.

Reported by: syzbot+6295fcc5a8aced81d599@syzkaller.appspotmail.com
Reviewed by: bz@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19968

5 years agoAvoid a buffer overwrite in rip6_output() when computing the checksum
tuexen [Fri, 19 Apr 2019 17:21:35 +0000 (17:21 +0000)]
Avoid a buffer overwrite in rip6_output() when computing the checksum
as requested by the user via the IPPROTO_IPV6 level socket option
IPV6_CHECKSUM. The check if there are enough bytes in the packet to
store the checksum at the requested offset was wrong by 1.

Reviewed by: bz@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19967

5 years agoImprove input validation for the socket option IPV6_CHECKSUM.
tuexen [Fri, 19 Apr 2019 17:17:41 +0000 (17:17 +0000)]
Improve input validation for the socket option IPV6_CHECKSUM.

When using the IPPROTO_IPV6 level socket option IPV6_CHECKSUM on a raw
IPv6 socket, ensure that the value is either -1 or a non-negative even
number.

Reviewed by: bz@, thj@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19966

5 years agorandom.4: Include description of knobs added in r346358
cem [Fri, 19 Apr 2019 17:15:58 +0000 (17:15 +0000)]
random.4: Include description of knobs added in r346358

Reported by: ngie
Sponsored by: Dell EMC Isilon

5 years agoAdd stat counter for ipv6 atomic fragments
thj [Fri, 19 Apr 2019 17:06:43 +0000 (17:06 +0000)]
Add stat counter for ipv6 atomic fragments

Add a stat counter to track ipv6 atomic fragments. Atomic fragments can be
generated in response to invalid path MTU values, but are also a potential
attack vector and considered harmful (see RFC6946 and RFC8021).

While here add tracking of the atomic fragment counter to netstat and systat.

Reviewed by:    tuexen, jtl, bz
Approved by:    jtl (mentor), bz (mentor)
Event:  Aberdeen hackathon 2019
Differential Revision:  https://reviews.freebsd.org/D17511

5 years agoChange the way FreeBSD GID inheritance is hacked.
mav [Fri, 19 Apr 2019 15:44:45 +0000 (15:44 +0000)]
Change the way FreeBSD GID inheritance is hacked.

I believe previous ifdef caused NULL dereference in later zfs_log_create()
on attempt to create file inside directory belonging to ephemeral group
created on illumos, trying to write to log information about GID domain
of the newly created file, inheriting the ephemeral GID.

This patch reuses original illumos SGID code with exception that due to
lack of ID mapping code on FreeBSD ephemeral GID will turn into GID_NOBODY
by another ifdef inside zfs_fuid_map_id().

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

5 years agoremove the 4GB boundary requirement on PCI DMA segments
tychon [Fri, 19 Apr 2019 13:43:33 +0000 (13:43 +0000)]
remove the 4GB boundary requirement on PCI DMA segments

Reviewed by: kib
Discussed with: jhb
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19867

5 years agopfctl: Fix ifgroup check
kp [Fri, 19 Apr 2019 10:52:54 +0000 (10:52 +0000)]
pfctl: Fix ifgroup check

We cannot just assume that any name which ends with a letter is a group
That's not been true since we allowed renaming of network interfaces. It's also
not true for things like epair0a.

Try to retrieve the group members for the name to check, since we'll get ENOENT
if the group doesn't exist.

MFC after: 1 week
Event: Aberdeen hackathon 2019

5 years agoClose filedescriptors when done with them.
phk [Fri, 19 Apr 2019 06:49:46 +0000 (06:49 +0000)]
Close filedescriptors when done with them.

5 years agoFix the NFSv4.0 server so that it does not support NFSv4.1 attributes.
rmacklem [Fri, 19 Apr 2019 03:36:22 +0000 (03:36 +0000)]
Fix the NFSv4.0 server so that it does not support NFSv4.1 attributes.

During inspection of a packet trace, I noticed that an NFSv4.0 mount
reported that it supported attributes that are only defined for NFSv4.1.
In practice, this bug appears to be benign, since NFSv4.0 clients will
not use attributes that were added for NFSv4.1.
However, this was not correct and this patch fixes the NFSv4.0 server
so that it only supports attributes defined for NFSv4.0.
It also adds a definition for NFSv4.1 attributes that can only be set,
although it is only defined as 0 for now.
This is anticipation of the addition of support for the NFSv4.1 mode+mask
attribute soon.

MFC after: 2 weeks

5 years agoUpdate to Zstandard 1.4.0
cem [Fri, 19 Apr 2019 02:54:13 +0000 (02:54 +0000)]
Update to Zstandard 1.4.0

The full release notes can be found on Github:

  https://github.com/facebook/zstd/releases/tag/v1.4.0

Relnotes: yes

5 years agopowerpc/powernv: Make erasing before writes optional
jhibbits [Fri, 19 Apr 2019 02:28:04 +0000 (02:28 +0000)]
powerpc/powernv: Make erasing before writes optional

If the OPAL flash driver supports writing without erase, it adds a
'no-erase' property to the flash device node.  Honor that property and don't
bother erasing if it exists.

5 years agoimport zstd 1.4.0
cem [Fri, 19 Apr 2019 00:31:04 +0000 (00:31 +0000)]
import zstd 1.4.0

5 years agoPush down INP_WLOCK slightly in tcp_ctloutput.
jhb [Thu, 18 Apr 2019 23:21:26 +0000 (23:21 +0000)]
Push down INP_WLOCK slightly in tcp_ctloutput.

The inp lock is not needed for testing the V6 flag as that flag is set
once when the inp is created and never changes.  For non-TCP socket
options the lock is immediately dropped after checking that flag.
This just pushes the lock down to only be acquired for TCP socket
options.

This isn't a hot-path, more a cosmetic cleanup I noticed while reading
the code.

Reviewed by: bz
MFC after: 1 month
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D19740

5 years agoWhen parsing command line stuff, treat tabs and spaces the same.
imp [Thu, 18 Apr 2019 22:52:12 +0000 (22:52 +0000)]
When parsing command line stuff, treat tabs and spaces the same.

When creating complex config files, people like to use tabs to offset
sections. Treat them the same as spaces for delimiters.

5 years agorandom(4): Restore availability tradeoff prior to r346250
cem [Thu, 18 Apr 2019 20:48:54 +0000 (20:48 +0000)]
random(4): Restore availability tradeoff prior to r346250

As discussed in that commit message, it is a dangerous default.  But the
safe default causes enough pain on a variety of platforms that for now,
restore the prior default.

Some of this is self-induced pain we should/could do better about; for
example, programmatic CI systems and VM managers should introduce entropy
from the host for individual VM instances.  This is considered a future work
item.

On modern x86 and Power9 systems, this may be wholly unnecessary after
D19928 lands (even in the non-ideal case where early /boot/entropy is
unavailable), because they have fast hardware random sources available early
in boot.  But D19928 is not yet landed and we have a host of architectures
which do not provide fast random sources.

This change adds several tunables and diagnostic sysctls, documented
thoroughly in UPDATING and sys/dev/random/random_infra.c.

PR: 230875 (reopens)
Reported by: adrian, jhb, imp, and probably others
Reviewed by: delphij, imp (earlier version), markm (earlier version)
Discussed with: adrian
Approved by: secteam(delphij)
Relnotes: yeah
Security: related
Differential Revision: https://reviews.freebsd.org/D19944

5 years agoImplement flag for telling cuse(3) clients if the peer is running in 32-bit
hselasky [Thu, 18 Apr 2019 19:04:07 +0000 (19:04 +0000)]
Implement flag for telling cuse(3) clients if the peer is running in 32-bit
compat mode or not. This is useful when implementing compatibility ioctl(2)
handlers in userspace.

MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agoUse correct type name.
kib [Thu, 18 Apr 2019 15:31:03 +0000 (15:31 +0000)]
Use correct type name.

Sponsored by: Mellanox Technologies
MFC after: 1 week

5 years agoAdd note that I'm the defacto maintainer of libegacy, our
imp [Thu, 18 Apr 2019 15:19:28 +0000 (15:19 +0000)]
Add note that I'm the defacto maintainer of libegacy, our
compat shims for building bootstrap tools that use new features
on systems too old to have those new features. The world view
for this part of the build is unique to the whole build process
and continuty of design for new compat shims help this library
remain viable.

5 years agoMinor tweak to the debug
imp [Thu, 18 Apr 2019 15:19:19 +0000 (15:19 +0000)]
Minor tweak to the debug

Make it clear we're loading from UFS.

5 years agoCorrect handling of RMRR during early enumeration stages.
kib [Thu, 18 Apr 2019 14:18:06 +0000 (14:18 +0000)]
Correct handling of RMRR during early enumeration stages.

On some machines, DMAR contexts must be created before all devices
under the scope of the corresponding DMAR unit are enumerated.
Current code has two problems with that:
- scope lookup returns NULL device_t, which causes to skip creating a
  context with RMRR, which is fatal for the affected device.
- calculation of the final pci dbsf address fails if any bridge in the
  scope is not yet enumerated, because code relies on pcib_get_bus().

Make creation of contexts work either with device_t, or with DMAR PCI
scope paths.  Scope provides enough information to infer context
address, and it is directly matched against DMAR tables scopes.

When calculating bus addresses for the scope or device, use direct
pci_cfgregread(PCIR_SECBUS_1) to get the secondary bus number, instead
of pcib_get_bus().

The issue was observed on HP Gen servers, where iLO PCI devices are
located behind south bridge switch.  Turning on translation without
satisfying RMRR requests caused iLO to mostly hang, up to the level of
being unusable to control the server.

While there, remove hw.dmar.dmar_match_verbose tunable, and make the
normal logging under bootverbose useful and sufficient to diagnose
DRHD and RMRR parsing and matching.

Sponsored by: Mellanox Technologies
MFC after: 1 week

5 years agoRemove witness warning. dmar_bus_dmamap_create() does not sleep.
kib [Thu, 18 Apr 2019 14:03:59 +0000 (14:03 +0000)]
Remove witness warning. dmar_bus_dmamap_create() does not sleep.

Sponsored by: Mellanox Technologies
MFC after: 1 week

5 years agoReduce verbosity, do not announce details of irte programming by default.
kib [Thu, 18 Apr 2019 14:02:33 +0000 (14:02 +0000)]
Reduce verbosity, do not announce details of irte programming by default.

Sponsored by: Mellanox Technologies
MFC after: 1 week

5 years agopf: No need to M_NOWAIT in DIOCRSETTFLAGS
kp [Thu, 18 Apr 2019 11:37:44 +0000 (11:37 +0000)]
pf: No need to M_NOWAIT in DIOCRSETTFLAGS

Now that we don't hold a lock during DIOCRSETTFLAGS memory allocation we can
use M_WAITOK.

MFC after: 1 week
Event: Aberdeen hackathon 2019
Pointed out by: glebius@

5 years agoAdd a bugs section to pflog man page
thj [Thu, 18 Apr 2019 11:06:45 +0000 (11:06 +0000)]
Add a bugs section to pflog man page

FreeBSD does not set the pid field in the pfloghdr struct. This field is
populated on other platforms, document this to save people from trying
to use this field.

Event: Aberdeen hackathon 2019
Reviewed by: kp, bcr, bz
Approved by: bz (mentor)
Differential Revision: https://reviews.freebsd.org/D19952

5 years agopf tests: Fail the test if we can't set the rules
kp [Thu, 18 Apr 2019 10:54:08 +0000 (10:54 +0000)]
pf tests: Fail the test if we can't set the rules

The test should fail if pf rules can't be set. This is helpful both
while writing tests and to verify that pfctl works as expected.

MFC after: 1 week
Event: Aberdeen hackathon 2019

5 years agoAdd efi_delenv
imp [Thu, 18 Apr 2019 05:40:50 +0000 (05:40 +0000)]
Add efi_delenv

Add an interface to remove / delete UEFI variables.

5 years agoAdd a more generic efi_setenv function.
imp [Thu, 18 Apr 2019 05:37:18 +0000 (05:37 +0000)]
Add a more generic efi_setenv function.

efi_setenv allows any UEFI variable to be set.

5 years agoAs an interim measure until a more permanent solution is implemented
cy [Thu, 18 Apr 2019 01:02:00 +0000 (01:02 +0000)]
As an interim measure until a more permanent solution is implemented
workaround the following error:

/usr/src/contrib/elftoolchain/strings/strings.c:198:55: error: use of
undeclared identifier
'FA_OPEN' fa = fileargs_init(argc, argv, O_RDONLY, 0, &rights, FA_OPEN);

Reported by: O. Hartmann <ohartmann@walstatt.org>
Reported by: Michael Butler <imb@protected-networks.net>
Reported by: gjb@ & cy@ (implicit)
Reviewed by: emaste@
Noted by: rgrimes@

5 years agoarm: allwinner: Fix audio for Allwinner H3/H5
manu [Wed, 17 Apr 2019 21:45:19 +0000 (21:45 +0000)]
arm: allwinner: Fix audio for Allwinner H3/H5

Due to three conditions the codec driver for Allwinner A10/A20 and H3/H5 did not work properly here:

    Wrong bit position for the analog audio reset
    Hardware Reset of codec was not de-asserted correctly
    Linux DTS file did not contain the address of the analog register the way as the driver was expecting it.

This patch proposes fixes for those three parts.

Submitted by: freebsdnewbie@freenet.de (Manuel Stühn)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D19910

5 years agoofw_graph: Add functions for graph bindings
manu [Wed, 17 Apr 2019 20:09:01 +0000 (20:09 +0000)]
ofw_graph: Add functions for graph bindings

Those functions are helpers to work on graph bindings.
graphs are mostly use with video related devices.
See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/graph.txt?id=4436a3711e3249840e0679e92d3c951bcaf25515

MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D19877

5 years agoPut QEMU CI smoke test boot log in /tmp if TMPDIR not set
emaste [Wed, 17 Apr 2019 19:24:41 +0000 (19:24 +0000)]
Put QEMU CI smoke test boot log in /tmp if TMPDIR not set

Sponsored by: The FreeBSD Foundation

5 years agoInstall some entropy for QEMU CI smoke test
emaste [Wed, 17 Apr 2019 19:16:26 +0000 (19:16 +0000)]
Install some entropy for QEMU CI smoke test

See r346250 and followup commits and mailing list discussion.
We currently fail to boot properly in the absense of boot-time entropy.

Sponsored by: The FreeBSD Foundation

5 years agoCompile sha1.c when ether support is included
kevans [Wed, 17 Apr 2019 18:08:28 +0000 (18:08 +0000)]
Compile sha1.c when ether support is included

sha1 is used by ether_gen_addr after r346324. Perhaps in an ideal world we
could detect that the kernel's been compiled without sha1_* bits included
and silently fallback to arc4random instead because these platforms/kernel
configs are far and few between. It's fairly lightweight, though, so just
include it for now.

5 years agoreadelf: use size_t for object counts
emaste [Wed, 17 Apr 2019 17:50:44 +0000 (17:50 +0000)]
readelf: use size_t for object counts

PR: 212539
Reported by: cem
Sponsored by: The FreeBSD Foundation

5 years agoiflib: Use new ether_gen_addr, restricting addresses to that subset
kevans [Wed, 17 Apr 2019 17:19:54 +0000 (17:19 +0000)]
iflib: Use new ether_gen_addr, restricting addresses to that subset

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

5 years agonet: adjust randomized address bits
kevans [Wed, 17 Apr 2019 17:18:43 +0000 (17:18 +0000)]
net: adjust randomized address bits

Give devices that need a MAC a 16-bit allocation out of the FreeBSD
Foundation OUI range. Change the name ether_fakeaddr to ether_gen_addr now
that we're dealing real MAC addresses with a real OUI rather than random
locally-administered addresses.

Reviewed by: bz, rgrimes
Differential Revision: https://reviews.freebsd.org/D19587

5 years agoreadelf: speed up readelf -wo
emaste [Wed, 17 Apr 2019 17:00:16 +0000 (17:00 +0000)]
readelf: speed up readelf -wo

Use an array instead of STAILQ, and sort at the end instead of while
adding new elements.

PR: 212539
Submitted by: Bora Özarslan <borako.ozarslan@gmail.com>
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

5 years ago[casper] fix compilation when casper is disabled.
adrian [Wed, 17 Apr 2019 16:58:38 +0000 (16:58 +0000)]
[casper] fix compilation when casper is disabled.

This triggers an error in gcc-mips 6.4.0 complaining about unused arguments.

Tested:

* compiled/run on mips32; nothing complained.

5 years agocap_fileargs: fix test after r346318
emaste [Wed, 17 Apr 2019 16:45:42 +0000 (16:45 +0000)]
cap_fileargs: fix test after r346318

Reported by: danfe, mjg
MFC after: 3 weeks
MFC with: r346315
Sponsored by: The FreeBSD Foundation

5 years agopf tests: Try to provoke the panic with invalid DIOCRSETTFLAGS
kp [Wed, 17 Apr 2019 16:45:35 +0000 (16:45 +0000)]
pf tests: Try to provoke the panic with invalid DIOCRSETTFLAGS

There was an issue with copyin() on DIOCRSETTFLAGS, which would panic if
pfrio_buffer was NULL.
Test for the issue fixed in r346319.

MFC after: 1 week
Event: Aberdeen hackathon 2019

5 years agopf: Fix panic on invalid DIOCRSETTFLAGS
kp [Wed, 17 Apr 2019 16:42:54 +0000 (16:42 +0000)]
pf: Fix panic on invalid DIOCRSETTFLAGS

If during DIOCRSETTFLAGS pfrio_buffer is NULL copyin() will fault, which we're
not allowed to do with a lock held.
We must count the number of entries in the table and release the lock during
copyin(). Only then can we re-acquire the lock. Note that this is safe, because
pfr_set_tflags() will check if the table and entries exist.

This was discovered by a local syzcaller instance.

MFC after: 1 week
Event: Aberdeen hackathon 2019

5 years agocap_fileargs: fix GCC build, don't shadow 'stat'
emaste [Wed, 17 Apr 2019 16:31:30 +0000 (16:31 +0000)]
cap_fileargs: fix GCC build, don't shadow 'stat'

Reported by: ci.freebsd.org
MFC after: 3 weeks
MFC with: r346315
Sponsored by: The FreeBSD Foundation