]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agofork: remove avoidable proc lock/unlock pair
mjg [Thu, 22 Nov 2018 21:29:36 +0000 (21:29 +0000)]
fork: remove avoidable proc lock/unlock pair

We don't have to access the process after making it runnable, so there
is no need to hold it either.

Sponsored by: The FreeBSD Foundation

5 years agofork: fix use-after-free with vfork
mjg [Thu, 22 Nov 2018 21:08:37 +0000 (21:08 +0000)]
fork: fix use-after-free with vfork

The pointer to the child is stored without any reference held. Then it is
blindly used to wait until P_PPWAIT is cleared. However, if the child is
autoreaped it could have exited and get freed before the parent started
waiting.

Use the existing hold mechanism to mitigate the problem. Most common case
of doing exec remains unchanged. The corner case of doing exit performs
wake up before waiting for holds to clear.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18295

5 years agoPlug some networking sysctl leaks.
markj [Thu, 22 Nov 2018 20:49:41 +0000 (20:49 +0000)]
Plug some networking sysctl leaks.

Various network protocol sysctl handlers were not zero-filling their
output buffers and thus would export uninitialized stack memory to
userland.  Fix a number of such handlers.

Reported by: Thomas Barabosch, Fraunhofer FKIE
Reviewed by: tuexen
MFC after: 3 days
Security: kernel memory disclosure
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18301

5 years agoA TCP stack is required to check SEG.ACK first, when processing a
tuexen [Thu, 22 Nov 2018 20:05:57 +0000 (20:05 +0000)]
A TCP stack is required to check SEG.ACK first, when processing a
segment in the SYN-SENT state as stated in Section 3.9 of RFC 793,
page 66. Ensure this is also done by the TCP RACK stack.

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

5 years agoEnsure that the TCP RACK stack honours the setting of the
tuexen [Thu, 22 Nov 2018 20:02:39 +0000 (20:02 +0000)]
Ensure that the TCP RACK stack honours the setting of the
net.inet.tcp.drop_synfin sysctl-variable.

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

5 years agoEnsure that the default RTT stack can make an RTT measurement if
tuexen [Thu, 22 Nov 2018 19:56:52 +0000 (19:56 +0000)]
Ensure that the default RTT stack can make an RTT measurement if
the TCP connection was initiated using the RACK stack, but the
peer does not support the TCP RACK extension.

This ensures that the TCP behaviour on the wire is the same if
the TCP connection is initated using the RACK stack or the default
stack.

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

5 years agoEnsure that TCP RST-segments announce consistently a receiver window of
tuexen [Thu, 22 Nov 2018 19:49:52 +0000 (19:49 +0000)]
Ensure that TCP RST-segments announce consistently a receiver window of
zero. This was already done when sending them via tcp_respond().

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

5 years agoClear unused bytes in ia32_osendsig().
markj [Thu, 22 Nov 2018 17:51:19 +0000 (17:51 +0000)]
Clear unused bytes in ia32_osendsig().

Mirror the fix for the native i386 implementation from r218327.  This
code is compiled only when the non-default COMPAT_43 option is
configured.

Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Reviewed by: kib
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18298

5 years agoproto: change device permissions to 0600
emaste [Thu, 22 Nov 2018 16:55:09 +0000 (16:55 +0000)]
proto: change device permissions to 0600

C Turt reports that the driver is not thread safe and may have
exploitable races.

Note that the proto device is intended for prototyping and development,
and is not for use on production systems.  From the man page:

SECURITY CONSIDERATIONS
     Because programs have direct access to the hardware, the proto
     driver is inherently insecure.  It is not advisable to use this
     driver on a production machine.

The proto device is not included in any of FreeBSD's kernel config files
(although the module is built).

The issues in the proto device still need to be fixed, and the device is
inherently (and intentionally) insecure, but it might as well be limited
to root only.

admbugs: 782
Reported by: C Turt <ecturt@gmail.com>
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agosfxge(4): limit max TXQ size on Medford to 2048
arybchik [Thu, 22 Nov 2018 16:15:24 +0000 (16:15 +0000)]
sfxge(4): limit max TXQ size on Medford to 2048

Queues with 4096 descriptors are not supported as the top bit is used for vfifo
stuffing.

Submitted by:   Mark Spender <mspender at solarflare.com>
Reviewed by:    gnn
Sponsored by:   Solarflare Communications, Inc.
MFC after:      2 days
Differential Revision:  https://reviews.freebsd.org/D8948

5 years agosfxge(4): support packed stream Rx mode in libefx
arybchik [Thu, 22 Nov 2018 14:31:35 +0000 (14:31 +0000)]
sfxge(4): support packed stream Rx mode in libefx

Submitted by:   Artem V. Andreev <Artem.Andreev@oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18022

5 years agosfxge(4): cleanup: move into right place
arybchik [Thu, 22 Nov 2018 14:10:46 +0000 (14:10 +0000)]
sfxge(4): cleanup: move into right place

Due to incorrect merge the piece of code was put in incorrect
place and diverge from libefx in other locations.

Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18024

5 years agoAllow forced start of ipmon in special cases where testing is desired
cy [Thu, 22 Nov 2018 04:48:27 +0000 (04:48 +0000)]
Allow forced start of ipmon in special cases where testing is desired
(or other special cases) and when ipfilter is disabled in rc.conf but
started by other means.

MFC after: 1 week

5 years agostrings: unbreak the build after r340746
mjg [Wed, 21 Nov 2018 22:37:49 +0000 (22:37 +0000)]
strings: unbreak the build after r340746

Discussed with: oshogbo
Sponsored by: The FreeBSD Foundation

5 years agouipc_usrreq: fix inode number assignment
mjg [Wed, 21 Nov 2018 22:25:05 +0000 (22:25 +0000)]
uipc_usrreq: fix inode number assignment

The code was incrementing a global variable in an unsafe manner.
Two different threads stating two different sockets could have resulted
in the same inode numbers assigned to both.

Creation is protected with a global lock, move the assigment there.
Since inode numbers are 64-bit now drop the check for overflows.

Sponsored by: The FreeBSD Foundation

5 years agoproc: update list manipulation comment on process exit
mjg [Wed, 21 Nov 2018 22:16:10 +0000 (22:16 +0000)]
proc: update list manipulation comment on process exit

Processes stay in the hash until they get reaped.

This code does not unlink the child from the parent, so remove
the claim that it does.

Sponsored by: The FreeBSD Foundation

5 years agouipc_shm: use unr64 for inode numbers
mjg [Wed, 21 Nov 2018 22:01:06 +0000 (22:01 +0000)]
uipc_shm: use unr64 for inode numbers

Sponsored by: The FreeBSD Foundation

5 years agostrings: fix style nits
oshogbo [Wed, 21 Nov 2018 21:48:02 +0000 (21:48 +0000)]
strings: fix style nits

Reviewed by: cem, emaste, Joseph Koshy <jkoshy@users.sourceforge.net>
Differential Revision: https://reviews.freebsd.org/D18036

5 years agoFix CU: output of the --debug-dump=decodedline, the problem there
sobomax [Wed, 21 Nov 2018 21:46:06 +0000 (21:46 +0000)]
Fix CU: output of the --debug-dump=decodedline, the problem there
is that both file name and current directory is recorded, however
file name sometimes already contains absolute path. In which case
prefixing it with directory name results in an invalid pathname.

Only append directory name if the file name does not start with '/'.
This seems to DTRT.

Approved by: emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D18290

5 years agoproc: convert pfind & friends to use pidhash locks and other cleanup
mjg [Wed, 21 Nov 2018 20:15:56 +0000 (20:15 +0000)]
proc: convert pfind & friends to use pidhash locks and other cleanup

pfind_locked is retired as it relied on allproc which unnecessarily
restricts locking of the hash.

Sponsored by: The FreeBSD Foundation

5 years agoproc: implement pid hash locks and an iterator
mjg [Wed, 21 Nov 2018 18:56:15 +0000 (18:56 +0000)]
proc: implement pid hash locks and an iterator

forks, exits and waits are frequently stalled during poudriere -j 128 runs
due to killpg and process list exports performed for each package.

Both uses take the allproc lock. The latter case can be modified to iterate
over the hash with finer grained locking instead.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17817

5 years agoImprove two KASSERTs in the TCP RACK stack.
tuexen [Wed, 21 Nov 2018 18:19:15 +0000 (18:19 +0000)]
Improve two KASSERTs in the TCP RACK stack.

There are two locations where an always true comparison was made in
a KASSERT. Replace this by an appropriate check and use a consistent
panic message. Also use this code when checking a similar condition.

PR: 229664
Reviewed by: rrs@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D18021

5 years agoRevert r340096: 9952 Block size change during zfs receive drops spill block
mav [Wed, 21 Nov 2018 18:18:57 +0000 (18:18 +0000)]
Revert r340096: 9952 Block size change during zfs receive drops spill block

It was reported, and I easily reproduced it, that this change triggers panic
when receiving replication stream with enabled embedded blocks, when short
file compressing into one embedded block changes its block size.  I am not
sure that the problem is in this particuler patch, not just triggered by it,
but since investigation and fix will take some time, I've decided to revert
this for now.

PR: 198457, 233277

5 years agoAvoid unsynchronized updates to kn_status.
markj [Wed, 21 Nov 2018 17:32:09 +0000 (17:32 +0000)]
Avoid unsynchronized updates to kn_status.

kn_status is protected by the kqueue's lock, but we were updating it
without the kqueue lock held.  For EVFILT_TIMER knotes, there is no
knlist lock, so the knote activation could occur during the kn_status
update and result in KN_QUEUED being lost, in which case we'd enqueue
an already-enqueued knote, corrupting the queue.

Fix the problem by setting or clearing KN_DISABLED before dropping the
kqueue lock to call into the filter.  KN_DISABLED is used only by the
core kevent code, so there is no side effect from setting it earlier.

Reported and tested by: Sylvain GALLIANO <sg@efficientip.com>
Reviewed by: kib
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18060

5 years agoRemove KN_HASKQLOCK.
markj [Wed, 21 Nov 2018 17:28:10 +0000 (17:28 +0000)]
Remove KN_HASKQLOCK.

It is a write-only flag whose last use was removed in r302235.

No functional change intended.

Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18059

5 years agoUse taskqueue_quiesce(9) to implement taskq_wait().
markj [Wed, 21 Nov 2018 17:19:08 +0000 (17:19 +0000)]
Use taskqueue_quiesce(9) to implement taskq_wait().

PR: 227784
Reviewed by: cem
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17975

5 years agoAdd a taskqueue_quiesce(9) KPI.
markj [Wed, 21 Nov 2018 17:18:27 +0000 (17:18 +0000)]
Add a taskqueue_quiesce(9) KPI.

This is similar to taskqueue_drain_all(9) but will wait for the queue
to become idle before returning instead of only waiting for
already-enqueued tasks to finish.  This will be used in the opensolaris
compat layer.

PR: 227784
Reviewed by: cem
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17975

5 years agoDTrace/powerpc: Fix FBT return probes
jhibbits [Wed, 21 Nov 2018 16:47:11 +0000 (16:47 +0000)]
DTrace/powerpc: Fix FBT return probes

The FBT fuction boundary prober was setting one return probe marker value,
but the dtrace handler was expecting another.  This causes a hang when
tracing return probes.

5 years agoAdd some non-default src.conf(5) knob descriptions
emaste [Wed, 21 Nov 2018 14:50:45 +0000 (14:50 +0000)]
Add some non-default src.conf(5) knob descriptions

Some WITH_/WITHOUT_ defaults will likey change in the future (e.g. as we
migrate to copyfree base system components).

Add non-default descriptions for the benefit of WIP branches.

5 years agoUnbreak kernel build with VLAN_ARRAY defined.
oleg [Wed, 21 Nov 2018 13:34:21 +0000 (13:34 +0000)]
Unbreak kernel build with VLAN_ARRAY defined.

MFC after: 1 week

5 years agoCross-reference libbe(3) and bectl(8).
0mp [Wed, 21 Nov 2018 12:46:28 +0000 (12:46 +0000)]
Cross-reference libbe(3) and bectl(8).

Those two manual pages are already referencing each other in the HISTORY
sections, which people might skip. Mention those manual pages explicitly in
the SEE ALSO sections.  Also, remove a reference to be(1) from libbe(3).

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

5 years agolibbe(3): Put each error value in separate line.
0mp [Wed, 21 Nov 2018 11:22:44 +0000 (11:22 +0000)]
libbe(3): Put each error value in separate line.

As requested by a TODO in the source code.

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

5 years agolinuxkpi: Use pageproc instead of vmproc
bwidawsk [Wed, 21 Nov 2018 04:34:18 +0000 (04:34 +0000)]
linuxkpi: Use pageproc instead of vmproc

According to markj@:
pageproc contains the page daemon and laundry threads, which are
responsible for managing the LRU page queues and writing back dirty
pages.  vmproc's main task is to swap out kernel stacks when the system
is under memory pressure, and swap them back in when necessary.  It's a
somewhat legacy component of the system and isn't required.  You can
build a kernel without it by specifying "options NO_SWAPPING" (which is
a somewhat misleading name), in which vm_swapout_dummy.c is compiled
instead of vm_swapout.c.

Based on this, we want pageproc to emulate kswapd, not vmproc.

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

5 years agoFix incorrect DSCP value range from 0..64 to 0..63.
ygy [Wed, 21 Nov 2018 00:22:31 +0000 (00:22 +0000)]
Fix incorrect DSCP value range from 0..64 to 0..63.

PR: 232786
Submitted by: Sergey Akhmatov <sergey@akhmatov.ru>
Reviewed by: AllanJude
MFC after: 1 week

5 years agoAdd definitions for Intel Speed Shift
bwidawsk [Wed, 21 Nov 2018 00:21:58 +0000 (00:21 +0000)]
Add definitions for Intel Speed Shift

These definitions will be used by a driver to implement Hardware
P-States (autonomous control of HWP, via Intel Speed Shift technology).

Reviewed by: kib
Approved by: emaste (mentor)
Differential Revision: https://reviews.freebsd.org/D18050

5 years agoRevert r340706. Some files became symlinks and vice versa.
jkim [Wed, 21 Nov 2018 00:00:00 +0000 (00:00 +0000)]
Revert r340706.  Some files became symlinks and vice versa.

Pointy hat to: jkim

5 years agogit-svn-init: Add docs to the choice of repos
bwidawsk [Tue, 20 Nov 2018 23:27:15 +0000 (23:27 +0000)]
git-svn-init: Add docs to the choice of repos

5 years agolinuxkpi: Remove duplicated text
bwidawsk [Tue, 20 Nov 2018 23:05:09 +0000 (23:05 +0000)]
linuxkpi: Remove duplicated text

Somehow this got botched while moving from git -> svn

5 years agolinuxkpi: Add some basic swap functions
bwidawsk [Tue, 20 Nov 2018 22:49:19 +0000 (22:49 +0000)]
linuxkpi: Add some basic swap functions

These are used by kms-drm to determine various heuristics relate
memory conditions.

The number of free swap pages is just a variable, and it can be
much cheaper by either adding a new getter, or simply extern'ing
swap_total. However, this patch opts to use the more expensive,
existing interface - since this isn't an operation in a high per
path.

This allows us to remove some more gpl linuxkpi and do the follo
kms-drm:
git rm linuxkpi/gplv2/include/linux/swap.h

Reviewed by:    mmacy, Johannes Lundberg <johalun0@gmail.com>
Approved by:    emaste (mentor)
Differential Revision:  https://reviews.freebsd.org/D18052

5 years agoDefine AHCI_PORT_IDENT and increase by 1 the VTBLK_BLK_ID_BYTES
araujo [Tue, 20 Nov 2018 22:21:19 +0000 (22:21 +0000)]
Define AHCI_PORT_IDENT and increase by 1 the VTBLK_BLK_ID_BYTES
to avoid buffer accessed out of bounds, also switch to snprintf(3).

PR: 200859
Submitted by: Caglar <caglar@10ur.org>
Obtained from: https://github.com/mist64/xhyve/pull/24
MFC after: 4 weeks
Sponsored by: iXsystems Inc.

5 years agoRemove stale manual pages after OpenSSL 1.1.1a merge.
jkim [Tue, 20 Nov 2018 22:12:10 +0000 (22:12 +0000)]
Remove stale manual pages after OpenSSL 1.1.1a merge.

5 years agoMerge OpenSSL 1.1.1a.
jkim [Tue, 20 Nov 2018 21:10:04 +0000 (21:10 +0000)]
Merge OpenSSL 1.1.1a.

5 years agocsu: use BSD-1-clause license on csu files
emaste [Tue, 20 Nov 2018 21:04:20 +0000 (21:04 +0000)]
csu: use BSD-1-clause license on csu files

Copyright on these files is held by kib@ and/or the Foundation, and both
agree to this change.

Approved by: kib

5 years agoAdd NT_FREEBSD_FEATURE_CTL ELF note to csu
emaste [Tue, 20 Nov 2018 20:59:49 +0000 (20:59 +0000)]
Add NT_FREEBSD_FEATURE_CTL ELF note to csu

This note will be used to allow binaries to opt out of, or in to,
upcoming vulnerability mitigation and other features.  It is not yet
connected but being added now to facilitate testing and ensure
compatibility with existing kernels and tools.

Reviewed by: brooks, jhb, kib, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17438

5 years agoClear pad bytes in the struct exported by kern.ntp_pll.gettime.
markj [Tue, 20 Nov 2018 20:32:10 +0000 (20:32 +0000)]
Clear pad bytes in the struct exported by kern.ntp_pll.gettime.

Reported by: Thomas Barabosch, Fraunhofer FKIE
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agoEnable evdev on ppc32
zeising [Tue, 20 Nov 2018 19:31:02 +0000 (19:31 +0000)]
Enable evdev on ppc32

Enable evdev on ppc32 as well, similar to what was done i386 and amd64 in
r340387 and ppc64 in r340632.

Evdev can be used by X and is used by wayland to handle input devices.

Approved by: jhibbits
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D18049

5 years agoImport OpenSSL 1.1.1a.
jkim [Tue, 20 Nov 2018 18:59:41 +0000 (18:59 +0000)]
Import OpenSSL 1.1.1a.

5 years agoMake multiline APPLY_MASK() macro to be function-like.
ae [Tue, 20 Nov 2018 18:38:28 +0000 (18:38 +0000)]
Make multiline APPLY_MASK() macro to be function-like.

Reported by: cem
MFC after: 1 week

5 years agoPlug a trivial memory leak.
markj [Tue, 20 Nov 2018 18:13:18 +0000 (18:13 +0000)]
Plug a trivial memory leak.

CID: 1396911
MFC with: r340485

5 years agoAvoid clobbering a user-specified -g value after r340547.
markj [Tue, 20 Nov 2018 18:10:56 +0000 (18:10 +0000)]
Avoid clobbering a user-specified -g value after r340547.

CID: 1396919
MFC with: r340547

5 years agostand: remove CLANG_NO_IAS from btx and gptboot
emaste [Tue, 20 Nov 2018 16:54:42 +0000 (16:54 +0000)]
stand: remove CLANG_NO_IAS from btx and gptboot

Many components under stand/ had CLANG_NO_IAS added when Clang's
Integrated Assembler (IAS) did not handle .codeNN directives.  Clang
gained support quite some time ago, and we can now build stand/ with
IAS.

Note that in some cases there are small differences in the generated
output, so CLANG_NO_IAS should be removed only after testing (or after
finding no differences in the output).

PR: 205250, 233094
Sponsored by: The FreeBSD Foundation

5 years agotmpfs: use unr64 for inode numbers
mjg [Tue, 20 Nov 2018 15:14:30 +0000 (15:14 +0000)]
tmpfs: use unr64 for inode numbers

Sponsored by: The FreeBSD Foundation

5 years agoHandle kernel superpage mappings in pmap_remove_l2().
markj [Tue, 20 Nov 2018 15:12:37 +0000 (15:12 +0000)]
Handle kernel superpage mappings in pmap_remove_l2().

PR: 233088
Reviewed by: alc, andrew, kib
Tested by: sbruno
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17981

5 years agopipe: use unr64
mjg [Tue, 20 Nov 2018 14:59:27 +0000 (14:59 +0000)]
pipe: use unr64

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18054

5 years agoImplement unr64
mjg [Tue, 20 Nov 2018 14:58:41 +0000 (14:58 +0000)]
Implement unr64

Important users of unr like tmpfs or pipes can get away with just
ever-increasing counters, making the overhead of managing the state
for 32 bit counters a pessimization.

Change it to an atomic variable. This can be further sped up by making
the counts variable "allocate" ranges and store them per-cpu.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18054

5 years agortld: when immediate bind mode is requested, process irelocs in PLT
kib [Tue, 20 Nov 2018 14:52:43 +0000 (14:52 +0000)]
rtld: when immediate bind mode is requested, process irelocs in PLT
immediately after other PLT relocs.

Otherwise, if the object has relro page, we write to readonly page,
and we would need to use mprotect(2) two more times to fix it.  Note
that resolve_object_ifunc() does nothing when called second time, so
there is no need to avoid existing call.

Reported and tested by: emaste
PR: 233333
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoFix another user address dereference in linux_sendmsg syscall.
tijl [Tue, 20 Nov 2018 14:18:57 +0000 (14:18 +0000)]
Fix another user address dereference in linux_sendmsg syscall.

This was hidden behind the LINUX_CMSG_NXTHDR macro which dereferences its
second argument.  Stop using the macro as well as LINUX_CMSG_FIRSTHDR.  Use
the size field of the kernel copy of the control message header to obtain
the next control message.

PR: 217901
MFC after: 2 days
X-MFC-With: r340631

5 years agoports(7): Do not mention deprecated WITH_OPENSSL_PORT.
0mp [Tue, 20 Nov 2018 10:01:56 +0000 (10:01 +0000)]
ports(7): Do not mention deprecated WITH_OPENSSL_PORT.

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

5 years agoEnsure that all values of ns, us and ms work for {n,u,m}stosbt
imp [Tue, 20 Nov 2018 07:11:23 +0000 (07:11 +0000)]
Ensure that all values of ns, us and ms work for {n,u,m}stosbt

Integer overflows and wrong constants limited the accuracy of these
functions and created situatiosn where sbttoXs(Xstosbt(Y)) != Y. This
was especailly true in the ns case where we had millions of values
that were wrong.

Instead, used fixed constants because there's no way to say ceil(X)
for integer math. Document what these crazy constants are.

Also, use a shift one fewer left to avoid integer overflow causing
incorrect results, and adjust the equasion accordingly. Document this.

Allow times >= 1s to be well defined for these conversion functions
(at least the Xstosbt). There's too many users in the tree that they
work for >= 1s.

This fixes a failure on boot to program firmware on the mlx4
NIC. There was a msleep(1000) in the code. Prior to my recent rounding
changes, msleep(1000) worked, but msleep(1001) did not because the old
code rounded to just below 2^64 and the new code rounds to just above
it (overflowing, causing the msleep(1000) to really sleep 1ms).

A test program to test all cases will be committed shortly. The test
exaustively tries every value (thanks to bde for the test).

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

5 years agoImprove sanity checking for the dircount hint argument to
rmacklem [Tue, 20 Nov 2018 01:59:57 +0000 (01:59 +0000)]
Improve sanity checking for the dircount hint argument to
NFSv3's ReaddirPlus and NFSv4's Readdir operations. The code
checked for a zero argument, but did not check for a very large value.
This patch clips dircount at the server's maximum data size.

MFC after: 1 week

5 years agonfsm_advance() would panic() when the offs argument was negative.
rmacklem [Tue, 20 Nov 2018 01:56:34 +0000 (01:56 +0000)]
nfsm_advance() would panic() when the offs argument was negative.
The code assumed that this would indicate a corrupted mbuf chain, but
it could simply be caused by bogus RPC message data.
This patch replaces the panic() with a printf() plus error return.

MFC after: 1 week

5 years agor304026 added code that started statistics gathering for an operation
rmacklem [Tue, 20 Nov 2018 01:52:45 +0000 (01:52 +0000)]
r304026 added code that started statistics gathering for an operation
before the operation number (the variable called "op") was sanity checked.
This patch moves the code down to below the range sanity check for "op".

5 years agoGiven that the idea of D15374 was to "make memmove a first class citizen",
marius [Tue, 20 Nov 2018 00:08:33 +0000 (00:08 +0000)]
Given that the idea of D15374 was to "make memmove a first class citizen",
provide a _MEMMOVE extension of _MEMCPY that deals with overlap based on
the previous bcopy(9) implementation and use the former for bcopy(9) and
memmove(9). This addresses my D15374 review comment, avoiding extra MOVs
in case of memmove(9) and trashing the stack pointer.

5 years agopom: Fix fencepost bugs.
tmunro [Tue, 20 Nov 2018 00:06:53 +0000 (00:06 +0000)]
pom: Fix fencepost bugs.

Under some conditions pom would report "waning" and then "full", show
higher percentages than it should, and get confused by DST.  Fix.

Before:

  2018.01.30: The Moon is Waxing Gibbous (97% of Full)
  2018.01.31: The Moon is Waning Gibbous (100% of Full)
  2018.02.01: The Moon is Full
  2018.02.02: The Moon is Waning Gibbous (98% of Full)

After:

  2018.01.30: The Moon is Waxing Gibbous (96% of Full)
  2018.01.31: The Moon is Waxing Gibbous (99% of Full)
  2018.02.01: The Moon is Full
  2018.02.02: The Moon is Waning Gibbous (97% of Full)

PR:                    231705
Submitted by:          Andrew Gierth
Approved by:           allanjude (mentor)
MFC after:             2 weeks
Differential Revision: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=231705

5 years agoFor consistency within the front-end, prefer SDHCI_{READ,WRITE}_{2,4}()
marius [Mon, 19 Nov 2018 23:56:33 +0000 (23:56 +0000)]
For consistency within the front-end, prefer SDHCI_{READ,WRITE}_{2,4}()
to sdhci_acpi_{read,write}_{2,4}() in the sdhci_acpi_set_uhs_timing()
added in r340543.

5 years agopowerpc: Sync icache on SIGILL, in case of cache issues
jhibbits [Mon, 19 Nov 2018 23:54:49 +0000 (23:54 +0000)]
powerpc: Sync icache on SIGILL, in case of cache issues

The update of jemalloc to 5.1.0 exposed a cache syncing issue on a Freescale
e500 base system.  There was already code in the FPU emulator to address
this, but it was limited to a single static variable, and did not attempt to
sync the cache.  This pulls that out to the higher level program exception
handler, and syncs the cache.

If a SIGILL is hit a second time at the same address, it will be treated as
a real illegal instruction, and handled accordingly.

5 years agorescue: set NO_SHARED in Makefile
emaste [Mon, 19 Nov 2018 22:18:18 +0000 (22:18 +0000)]
rescue: set NO_SHARED in Makefile

The rescue binary is built statically via the Makefile generated by
crunchgen, but that does not trigger other shared/static logic in
bsd.prog.mk - in particular disabling retpolineplt with static linking.

PR: 233336
Reported by: Charlie Li
Sponsored by: The FreeBSD Foundation

5 years agocxgbe(4): Update T4/5/6 firmwares to 1.22.0.3.
np [Mon, 19 Nov 2018 21:59:07 +0000 (21:59 +0000)]
cxgbe(4): Update T4/5/6 firmwares to 1.22.0.3.

Obtained from: Chelsio Communications
MFC after: 2 months
Sponsored by: Chelsio Communications

5 years agoAvoid retpolineplt with static linking
emaste [Mon, 19 Nov 2018 20:48:47 +0000 (20:48 +0000)]
Avoid retpolineplt with static linking

Statically linked binaries linked with -zretpolineplt crash at startup
as lld produces a broken PLT.

PR: 233336
Sponsored by: The FreeBSD Foundation

5 years agoAdd a fortune describing how to upload a machine's dmesg information to the
bcr [Mon, 19 Nov 2018 20:45:49 +0000 (20:45 +0000)]
Add a fortune describing how to upload a machine's dmesg information to the
NYCBUG database.

We want to encourage our users to upload their dmesgs so that the project can
get a better insight into what kind of hardware is run on. This helps in making
data-driven decisions about i.e., platform and driver support.

Note that dmesgs may contain sensitive information like hardware serial numbers,
hence uploading them without review is discouraged.

Reviewed by: brooks, imp, allanjude
Approved by: allanjude
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D17705

5 years agoAdd capsicum_helpers.h to -legacy if needed
arichardson [Mon, 19 Nov 2018 18:58:34 +0000 (18:58 +0000)]
Add capsicum_helpers.h to -legacy if needed

This fixes bootstrap of capsicumized strings on FreeBSD 11.

Reviewed By: oshogbo, bdrewery
Differential Revision: https://reviews.freebsd.org/D17971

5 years agoacpi: fix acpi_ec_probe to only check EC devices
bwidawsk [Mon, 19 Nov 2018 18:29:03 +0000 (18:29 +0000)]
acpi: fix acpi_ec_probe to only check EC devices

This patch utilizes the fixed_devclass attribute in order to make sure
other acpi devices with params don't get confused for an EC device.

The existing code assumes that acpi_ec_probe is only ever called with a
dereferencable acpi param. Aside from being incorrect because other
devices of ACPI_TYPE_DEVICE may be probed here which aren't ec devices,
(and they may have set acpi private data), it is even more nefarious if
another ACPI driver uses private data which is not dereferancable. This
will result in a pointer deref during boot and therefore boot failure.

On X86, as it stands today, no other devices actually do this (acpi_cpu
checks for PROCESSOR type devices) and so there is no issue. I ran into
this because I am adding such a device which gets probed before
acpi_ec_probe and sets private data. If ARM ever has an EC, I think
they'd run into this issue as well.

There have been several iterations of this patch. Earlier
iterations had ECDT enumerated ECs not call into the probe/attach
functions of this driver. This change was Suggested by: jhb@.

Reviewed by:    jhb
Approved by: emaste (mentor)
Differential Revision:  https://reviews.freebsd.org/D16635

5 years agoMake libthr(3) use sysconf(_SC_NPROCESSORS_CONF); this shaves off
trasz [Mon, 19 Nov 2018 18:24:08 +0000 (18:24 +0000)]
Make libthr(3) use sysconf(_SC_NPROCESSORS_CONF); this shaves off
two calls to sysctl(2) from the binary startup.

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

5 years agoMake sysconf(_SC_PAGESIZE) return the value from getpagesize(3).
trasz [Mon, 19 Nov 2018 18:23:17 +0000 (18:23 +0000)]
Make sysconf(_SC_PAGESIZE) return the value from getpagesize(3).
That avoids a syscall - getpagesize(3) gets the value from the ELF
aux strings.

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

5 years agolibc: forcibly disable BIND_NOW
emaste [Mon, 19 Nov 2018 18:12:39 +0000 (18:12 +0000)]
libc: forcibly disable BIND_NOW

Building libc WITH_BIND_NOW results in segfault at process start.  For
now force BIND_NOW off until the root cause can be identified and fixed.

PR: 233333
Sponsored by: The FreeBSD Foundation

5 years agoRemove comments made obsolete by the ino64 work.
markj [Mon, 19 Nov 2018 17:33:44 +0000 (17:33 +0000)]
Remove comments made obsolete by the ino64 work.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agolibcasper: provide compatibility with the old version of service
oshogbo [Mon, 19 Nov 2018 17:22:52 +0000 (17:22 +0000)]
libcasper: provide compatibility with the old version of service

Some external tools like tcpdump(1) have upstream the changes with old limits
name. Because of that provide compatibility with the old names.

Reported by: emaste

5 years agoUse swp_pager_isondev() throughout. Submitted by: ota@j.email.ne.jp
alc [Mon, 19 Nov 2018 17:17:23 +0000 (17:17 +0000)]
Use swp_pager_isondev() throughout.  Submitted by: ota@j.email.ne.jp

Change swp_pager_isondev()'s return type to bool.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D16712

5 years agobectl(8) tests: attempt to load the ZFS module
kevans [Mon, 19 Nov 2018 17:09:57 +0000 (17:09 +0000)]
bectl(8) tests: attempt to load the ZFS module

Observed in a CI test image, bectl_create test will run and be marked as
skipped because the module is not loaded. The first zpool invocation will
automagically load the module, but bectl_create is still skipped. Subsequent
tests all pass as expected because the module is now loaded and everything
is OK.

MFC after: 3 days

5 years agolibbe(3): Handle non-ZFS rootfs better
kevans [Mon, 19 Nov 2018 16:47:21 +0000 (16:47 +0000)]
libbe(3): Handle non-ZFS rootfs better

If rootfs isn't ZFS, current version will emit an error claiming so and fail
to initialize libbe. As a consumer, bectl -r (undocumented) can be specified
to operate on a BE independently of whether on a UFS or ZFS root.

Unbreak this for the UFS case by only erroring out the init if we can't
determine a ZFS dataset for rootfs and no BE root was specified. Consumers
of libbe should take care to ensure that rootfs is non-empty if they're
trying to use it, because this could certainly be the case.

Some check is needed before zfs_path_to_zhandle because it will
unconditionally emit to stderr if the path isn't a ZFS filesystem, which is
unhelpful for our purposes.

This should also unbreak the bectl(8) tests on a UFS root, as is the case in
Jenkins' -test runs.

MFC after: 3 days

5 years agoEnable evdev on ppc64
zeising [Mon, 19 Nov 2018 15:36:58 +0000 (15:36 +0000)]
Enable evdev on ppc64

Enable evdev on ppc64 as well, similar to what was done for amd64 and i386
in r340387.

Evdev can be used by X and is used by wayland to handle input devices.

Approved by: mmacy
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D18026

5 years agoDo proper copyin of control message data in the Linux sendmsg syscall.
tijl [Mon, 19 Nov 2018 15:31:54 +0000 (15:31 +0000)]
Do proper copyin of control message data in the Linux sendmsg syscall.

Instead of calling m_append with a user address, allocate an mbuf cluster
and copy data into it using copyin.  For the SCM_CREDS case, instead of
zeroing a stack variable and appending that to the mbuf, zero part of the
mbuf cluster directly.  One mbuf cluster is also the size limit used by
the FreeBSD sendmsg syscall (uipc_syscalls.c:sockargs()).

PR: 217901
Reviewed by: kib
MFC after: 3 days

5 years agoMinor code factoring. No functional change.
hselasky [Mon, 19 Nov 2018 09:36:09 +0000 (09:36 +0000)]
Minor code factoring. No functional change.

MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agoBe more verbose when a sysctl fails to unregister.
hselasky [Mon, 19 Nov 2018 09:35:16 +0000 (09:35 +0000)]
Be more verbose when a sysctl fails to unregister.
Print name of sysctl in question.

MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agoUnbreak ng_source(4) for 64-bit platforms including amd64.
eugen [Mon, 19 Nov 2018 07:27:50 +0000 (07:27 +0000)]
Unbreak ng_source(4) for 64-bit platforms including amd64.

5 years agoFix access to cpu_model[] in mtk_soc_set_cpu_model()
sgalabov [Mon, 19 Nov 2018 06:48:48 +0000 (06:48 +0000)]
Fix access to cpu_model[] in mtk_soc_set_cpu_model()

There may be cases where cpu_model[] may not be 32bit aligned, so it is
better to not try to access it as such in order to avoid unaligned access.

Sponsored by: Smartcom - Bulgaria AD

5 years agogitv3_its: fixes for multiple GIC ITS blocks
jchandra [Mon, 19 Nov 2018 03:52:56 +0000 (03:52 +0000)]
gitv3_its: fixes for multiple GIC ITS blocks

First pass of support for multiple GIC ITS blocks with ACPI.
Changes are to:
 * register the correct subset of interrupts with pic_register
   in case of ACPI.
 * initialize just the cpu interface for the first ITS, when
   domain information is not avialable. This has to be done
   until we split the per-CPU init to do LPI setup just once.
 * remove duplicate check for the GIC ITS domain, the sc_cpus
   are setup from domain, so the check again in per-CPU init
   seems unnecessary.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17841

5 years agopci_host_generic : move activate/release to generic code
jchandra [Mon, 19 Nov 2018 03:43:10 +0000 (03:43 +0000)]
pci_host_generic : move activate/release to generic code

Now that the ACPI and FDT implementations for activating and
deactivating resources are the same, we can move it to
pci_host_generic.c.  No functional changes.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17793

5 years agopci_host_generic, acpi_resource: drop unneeded code
jchandra [Mon, 19 Nov 2018 03:34:15 +0000 (03:34 +0000)]
pci_host_generic, acpi_resource: drop unneeded code

Now that we are handling PCI resources in pci_host_generic_acpi.c, we
don't need these change (made by r336129)

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17792

5 years agoacpica, pci_host_generic_acpi: redo pci_host_generic_acpi.c
jchandra [Mon, 19 Nov 2018 03:16:16 +0000 (03:16 +0000)]
acpica, pci_host_generic_acpi: redo pci_host_generic_acpi.c

This is a major update for pci_host_generic_acpi.c, the current
implementation has some gaps that are better fixed up in one go.
The changes are to:
 * Follow x86 method of not adding PCI resources to PCI host bridge in
   ACPI code. This has been moved to pci_host_generic_acpi.c, where we
   walk thru its resources of the host bridge and add them.
 * Fixup code in pci_host_generic_acpi.c to read all decoded ranges
   and update the 'ranges' property. This allows us to share most of
   the code with generic implementation (and the FDT one).
 * Parse and setup IO ranges and bus ranges when walking the resources
   above. Drop most of the changes related to this from acpica code.
 * Add the ECAM memory area as mem resource 0. Implement the logic to
   get the ECAM area from MCFG (using bus range which we now decode),
   or from _CBA (using _BBN/bus range). Drop aarch64 ifdefs from acpica
   code which did part of this.
 * Switch resource activation to similar code as FDT implementation,
   this can be moved into generic implementation in a later pass.
 * Drop the mechanism of using the 7th bit of bus number as the domain,
   this is not correct and will work only in very specific cases. Use
   _SEG as PCI domain and use the bus ranges of the host bridge to
   provide start bus number.

This commit should not make any functional change to dev/acpica/acpi.c
for other architectures, almost all the changes there are to revert
earlier additions in this file done for aarch64.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17791

5 years agoacpica: rework INTRNG interrupts
jchandra [Mon, 19 Nov 2018 03:02:47 +0000 (03:02 +0000)]
acpica: rework INTRNG interrupts

On arm64 (where INTRNG is enabled), the interrupts have to be mapped
with ACPI_BUS_MAP_INTR() before adding them as resources to devices.

The earlier code did the mapping before calling acpi_set_resource(),
which bypassed code that checked for PCI link interrupts.

To fix this, move the call to map interrupts into acpi_set_resource()
and that requires additional work to lookup interrupt properties.
The changes here are to:
 * extend acpi_lookup_irq_handler() to lookup an irq in the ACPI
   resources
 * create a helper function acpi_map_intr() which uses the updated
   acpi_lookup_irq_handler() to look up an irq, and then map it
   with ACPI_BUS_MAP_INTR()
 * use acpi_map_intr() in acpi_pcib_route_interrupt() to map
   pci link interrupts.

With these changes, we can drop the ifdefs in acpi_resource.c, and
we can also drop the call for mapping interrupts in generic_timer.c

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17790

5 years agopci_host_generic*: basic implementation of bus range
jchandra [Mon, 19 Nov 2018 02:55:18 +0000 (02:55 +0000)]
pci_host_generic*: basic implementation of bus range

Both ACPI and FDT support bus ranges for pci host bridges. Update
pci_host_generic*.[ch] with a default implementation to support this.
This will be used in the next set of changes for ACPI based host
bridge. No functional changes in this commit.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17657

5 years agopci_host_generic: allocate resources against devices
jchandra [Mon, 19 Nov 2018 02:43:34 +0000 (02:43 +0000)]
pci_host_generic: allocate resources against devices

Fix up pci_host_generic.c and pci_host_generic_fdt.c to allocate
resources against devices that requested them. Currently the
allocation happens against the pcib, which is incorrect.

This is needed for the upcoming changes for fixing up
pci_host_generic_acpi.c

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17656

5 years agopci_host_generic: remove unneeded ThunderX2 quirk
jchandra [Mon, 19 Nov 2018 02:38:02 +0000 (02:38 +0000)]
pci_host_generic: remove unneeded ThunderX2 quirk

The current quirk implementation writes a fixed address to the PCI BAR
to fix a firmware bug. The PCI BARs are allocated by firmware and will
change depending on PCI devices present. So using a fixed address here
is not correct.

This quirk worked around a firmware bug that programmed the MSI-X bar
of the SATA controller incorrectly. The newer firmware does not have
this issue, so it is better to drop this quirk altogether.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D17655

5 years agobectl(8): Add some regression tests
kevans [Mon, 19 Nov 2018 02:30:12 +0000 (02:30 +0000)]
bectl(8): Add some regression tests

These tests operate on a file-backed zpool that gets created in the kyua
temp dir. root and ZFS support are both required for these tests. Current
tests cover create, destroy, export/import, jail, list (kind of), mount,
rename, and jail.

List tests should later be extended to cover formatting and the different
list flags, but for now only covers basic "are create/destroy actually
reflected properly"

MFC after: 3 days

5 years agolibbe(3): Properly account for altroot when creating new BEs
kevans [Mon, 19 Nov 2018 02:16:20 +0000 (02:16 +0000)]
libbe(3): Properly account for altroot when creating new BEs

Previously we would blindly copy the 'mountpoint' property, which includes
the altroot. The altroot needs to be snipped off prior to setting it on the
new BE, though, or you'll end up with a new BE and a mountpoint of /mnt with
altroot=/mnt

MFC after: 3 days

5 years agobectl(3)/libbe(3): Allow BE root to be specified
kevans [Mon, 19 Nov 2018 02:12:08 +0000 (02:12 +0000)]
bectl(3)/libbe(3): Allow BE root to be specified

Add an undocumented -r option preceding the bectl subcommand to specify a BE
root to operate out of. This will remain undocumented for now, as some
caveats apply:

- BEs cannot be activated in the pool that doesn't contain the rootfs
- bectl create cannot work out of the box without the -e option right now,
  since it defaults to the rootfs and cross-pool cloning doesn't work like
  that (IIRC)

Plumb the BE root through to libbe(3) so that some things -can- be done to
it, e.g.

bectl -r tank/ROOT create -e default upgrade
bectl -r tank/ROOT mount upgrade /mnt

this aides in some upgrade setups where rootfs is not necessarily ZFS, and
also makes it easier/possible to regression-test bectl when combined with a
file-backed zpool.

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D18029

5 years agoRetire sbsndptr() KPI
kbowling [Mon, 19 Nov 2018 00:54:31 +0000 (00:54 +0000)]
Retire sbsndptr() KPI

As of r340465 all consumers use sbsndptr_adv and sbsndptr_noadv

Reviewed by: gallatin
Approved by: krion (mentor)
Differential Revision: https://reviews.freebsd.org/D17998

5 years agoFix -DNO_CLEAN amd64 build after r340463
arichardson [Sun, 18 Nov 2018 19:55:03 +0000 (19:55 +0000)]
Fix -DNO_CLEAN amd64 build after r340463

Without this change I got the following error:
clang-7: error: no such file or directory: '..../lib/libc/amd64/string/bzero.S'

Reviewed By: mjg
Differential Revision: https://reviews.freebsd.org/D18031

5 years agobrandelf: capsicumize it
oshogbo [Sun, 18 Nov 2018 12:23:03 +0000 (12:23 +0000)]
brandelf: capsicumize it