Commit Graph

238872 Commits

Author SHA1 Message Date
Mark Johnston
cb56711d68 Add a bounds check to the tws(4) passthrough ioctl handler.
tws_passthru() was doing a copyin of a user-specified request
without validating its length, so a malicious request could overrun
the buffer.  By default, the tws(4) device file is only accessible
as root.

admbug:		825
Reported by:	Anonymous of the Shellphish Grill Team
Reviewed by:	delphij
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18536
2019-01-05 15:28:20 +00:00
Toomas Soome
a9f7119bb8 With buggy int13 ah=15, we can mis-identify the floppy devices.
We have no option than trust INT13 ah=08 return code during the init phase.

PR:		234460
Reported by:	Oleh Hushchenkov
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D18723
2019-01-05 07:20:00 +00:00
Kristof Provost
e65e209520 pf: Remove references to pflow from the pf.conf man page
pflow no longer exists. It was removed as part of a pf update back in 2012
(r240233).

PR:		223957
MFC after:	1 week
2019-01-05 05:50:16 +00:00
Kristof Provost
de2d0d297a Remove unneeded NULL check for td_ucred
td_ucred is always set, so we don't need the ternary expression to check for
it.
2019-01-04 21:12:17 +00:00
Hans Petter Selasky
4604b6a18d Reduce timeout for reading the USB HUB port status to 1000ms and try to filter
out dead USB HUB devices by implementing an error counter, so that the USB
enumeration thread does not spend all its time reading from non-responding
devices, blocking user-space access in the end.

Tested by:	Matthias Apitz <guru@unixarea.de>
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-01-04 21:09:38 +00:00
Mark Johnston
0fadd6731f Disable savecore(8)'s libcasper support when WITHOUT_DYNAMICROOT=yes.
This follows the example of other Capsicumized programs in /sbin.

Reported by:	Manfred Antar <manfredantar@gmail.com>
MFC with:	r342699
Sponsored by:	The FreeBSD Foundation
2019-01-04 19:20:19 +00:00
Konstantin Belousov
f2c79297eb Fix i386 LINT build after r342769.
It seems that libkern/mcount.c is the only consumer of vm/pmap.h that
does not include machine/atomic.h.  Make it work by bringing
machine/atomic.h when pmap.h is used for kernel non-asm .c file.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2019-01-04 19:10:46 +00:00
Andrew Gallatin
35bc37b6b9 Limit git history searches in newvers.sh
newvers.sh takes upwards of 4-5 seconds to complete on trees checked
out from github, due to searching the entire history for non-existent
git-svn metadata. Similarly, if one does not check out notes, we
again search the entire history for notes. That makes newvers.sh very
slow for many github users.

To fix this in a fair way, limit the history search to the last 10K
commits: if you're more than 10K commits out of sync, then you've
forked the project, and our SVN rev is no longer very important to you.

Due to how git implements --grep in conjunction with -n, --grep has been
removed for performance reasons (git does not seem to limit its search
to the -n limit in this case, and takes just as long as it did with no
limit).

Reviewed by:	emaste, imp
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D18745
2019-01-04 18:38:27 +00:00
Ed Maste
6871d48825 Add explicit csu test dependency
lib/csu/tests/dynamiclib requires libh_csu.so be built first.  I'm not
sure this is the most correct/best way to address this but it solves
the issue in my testing.

PR:		233734
Sponsored by:	The FreeBSD Foundation
2019-01-04 18:35:25 +00:00
Conrad Meyer
33c80c7cc2 Bump __FreeBSD_version for r342771 2019-01-04 18:34:44 +00:00
Conrad Meyer
6b83069e05 Expose threads-per-core and physical core count information
With new sysctls (to the best of our ability do detect them).  Restructured
smp.4 slightly for clarity (keep relevant stuff closer to the top) while
documenting.

Reviewed by:	markj, jhibbits (ppc parts)
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D18322
2019-01-04 18:31:17 +00:00
David Bright
98ae4866ba asmc: Patch to add MacBook Pro 9,2 support
PR:		211513
Submitted by:	William Theesfeld Jr <wtheesfeld@mailbox.org>
Reported by:	William Theesfeld Jr <wtheesfeld@mailbox.org>
MFC after:	1 week
2019-01-04 18:21:49 +00:00
Konstantin Belousov
0598e55ea3 i386: Use atomic 64bit load to read PDE value from PAE pagetables in
pmap_kextract().

pmap_kextract() can race with promotion/demotion on the kernel page
table, in which case current non-atomic 64bit read would see torn
value, breaking pmap_kextract().  pmap_kextract() would correctly
handle either promoted or demoted PDE, but not a mix where one word
is from a different state.

It requires PAE and > 4G memory to reproduce.  We observed this in
real loads, both for intensive use of malloc(9)/free(9) where
vtoslab() returned invalid pointer to the slab, and with the use of
busdma_bounce, where incorrect page was bounced.

In collaboration with:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D18714
2019-01-04 17:33:07 +00:00
Mark Johnston
2f2ddd68a5 Support MSG_DONTWAIT in send*(2).
As it does for recv*(2), MSG_DONTWAIT indicates that the call should
not block, returning EAGAIN instead.  Linux and OpenBSD both implement
this, so the change makes porting easier, especially since we do not
return EINVAL or so when unrecognized flags are specified.

Submitted by:	Greg V <greg@unrelenting.technology>
Reviewed by:	tuexen
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D18728
2019-01-04 17:31:50 +00:00
Konstantin Belousov
f0d85a5dc5 x86: Report per-cpu IPI TLB shootdown generation in ddb 'show pcpu' output.
It is useful for inspecting tlb shootdown hangs.  The smp_tlb_generation value
is available using regular ddb data inspection commands.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2019-01-04 17:25:47 +00:00
Mark Johnston
23732c0fe3 Don't enable interrupts in init_secondary().
The MI kernel assumes that interrupts will not be enabled on APs until
after the first context switch.  In particular, the problem was causing
occasional deadlocks during boot.

Remove an unneeded intr_disable() added in r335005.

Reviewed by:	jhb (previous version)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18738
2019-01-04 17:14:50 +00:00
Mark Johnston
c1959ba49b Fix dirty bit handling in pmap_remove_write().
Reviewed by:	jhb, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18732
2019-01-04 17:10:16 +00:00
Mark Johnston
b679dc7fee Clear PGA_WRITEABLE in pmap_remove_pages().
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18731
2019-01-04 17:08:45 +00:00
Ed Maste
feea78990c newvers: retire p4 version support
Perforce no longer offers a FreeBSD client and it not a viable VCS for
FreeBSD development.  Remove p4 version logic to simplify newvers.sh in
advance of other changes.

Sponsored by:	The FreeBSD Foundation
2019-01-04 16:47:35 +00:00
Chuck Tuffli
fbac7e0ba2 Fix bhyve's NVMe Completion Queue entry values
The function which processes Admin commands was not returning the
Command Specific value in Completion Queue Entry, Dword 0 (CDW0). This
effects commands such as Set Features, Number of Queues which returns
the number of queues supported by the device in CDW0. In this case, the
host will only create 1 queue pair (Number of Queues is zero based).
This also masked a bug in the queue counting logic.

Reviewed by: imp, araujo
Approved by: imp (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D18703
2019-01-04 15:03:35 +00:00
Chuck Tuffli
76e47b9420 Fix bhyve's NVMe queue bookkeeping
Many size / length parameters in NVMe are "0's based", meaning, a value
of 0x0 represents 1, 0x1 represents 2, etc.. While this leads to an
efficient encoding, it can lead to subtle bugs. With respect to queues,
these parameters include:
 - Maximum number of queue entries
 - Maximum number of queues
 - Number of Completion Queues
 - Number of Submission Queues

To be consistent, convert all 0's based values from the host to 1's
based value internally. Likewise, covert internal 1's based values to
0's based values when returned to the host. This fixes an off-by-one bug
when creating IO queues and simplifies some of the code. Note that this
bug is masked by another bug.

While in the neighborhood,
 - fix an erroneous queue ID check (checking CQ count when deleting SQ)
 - check for queue ID of 0x0 in a few places where this is illegal
 - clean up the Set Features, Number of Queues command and check for
   illegal values

Reviewed by: imp, araujo
Approved by: imp (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D18702
2019-01-04 15:03:30 +00:00
Ed Maste
2cb541bf69 newvers: avoid clearing svn revision information with nested VCS dirs
Consider the case where FreeBSD is checked out via Subversion with a
(perhaps unrelated) .git or .hg directory at a higher level - for
example,

    .../.git
    .../src/freebsd

Previously newvers obtained the SVN revision information via svnversion,
and then tried to obtain the SVN revision corresponding to the git or hg
commit, overwriting the existing information.

As a short term fix use a different variable for hg-svn or git-svn
information, setting $svn from hg or git info only if not empty.

Reported by:	Matthias Apitz
Sponsored by:	The FreeBSD Foundation
2019-01-04 14:42:36 +00:00
Andriy Voskoboinyk
48f21a05da rtwn_pci(4): sync r88ee_power_on() with OpenBSD
Tested with RTL8188EE, STA mode

Submitted by:	Farhan Khan <khanzf@gmail.com>
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D18727
2019-01-04 04:26:39 +00:00
Navdeep Parhar
1a35ae9353 cxgbe(4): Clear FW_OK if the firmware reports an error.
Sponsored by:	Chelsio Communications
2019-01-04 04:15:17 +00:00
Kyle Evans
253b638eab getopt_long(3): fix case of malformed long opt
When presented with an arg string like '-l-', getopt_long will successfully
parse out the 'l' short option, then proceed to match '--' against the first
longopts entry as it later does a strncmp with len=0. This latter bit is
arguably another bug in itself, but presumably not a practical issue as all
callers of parse_long_options are already doing the right thing (except this
one pointed out).

An opt string like '-l-' should be considered malformed and throw a bad
argument rather than behaving as if '--' were passed. It cannot possibly do
what the invoker expects, and it's probably the result of a typo (ls -l- a)
rather than any intent.

Reported by:	Tony Overfield <toverfield@yahoo.com>
Reviewed by:	imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D18616
2019-01-04 03:13:24 +00:00
Allan Jude
07372194c3 The lam(1) man page is unclear about the uppercase versions of the flags
PR:		229571
Submitted by:	Tim Chase <freebsd@tim.thechases.com>
2019-01-04 02:48:43 +00:00
Matt Macy
5881181d8c mp_ring: avoid items offset difference between iflib and mp_ring
on architectures without 64-bit atomics

Reported by:	Augustin Cavalier <waddlesplash@gmail.com>
2019-01-03 23:06:05 +00:00
Matt Macy
27e05a1902 zfsboot: support newer ZFS versions
declare v3 objset size/layout to fix userboot and possibly other loader issues

- fix for userboot assertion failure in zfs_dev_close in free due to out of bounds write
- fix for zfs_alloc / zfs_free mismatch assertion failure when booting GPT on BIOS
2019-01-03 22:49:11 +00:00
Romain Tartière
2f1a2bdf81 Add man page for dlvsym(3)
Add a short description of the function to the appropriate man page and add
reference to it where it makes sense.

Reviewed by:	bcr, markj, 0mp
Approved by:	markj
Differential Revision:	https://reviews.freebsd.org/D18725
2019-01-03 21:31:17 +00:00
Toomas Soome
6564182252 loader.efi: efi variable rework and lsefi command added
This update does add diag and debug capabilities to interpret the efi
variables, configuration and protocols (lsefi).

The side effect is that we add/update bunch of related headers.
2019-01-03 20:27:50 +00:00
Jilles Tjoelker
993b1e419c sh: Add test for exported but unset variables
PR:		233545
2019-01-03 20:23:12 +00:00
Jilles Tjoelker
56f33d07ce sh: Do not place exported but unset variables into the environment
PR:		233545
Submitted by:	Jan Beich
Obtained from:	NetBSD
2019-01-03 20:22:35 +00:00
Konstantin Belousov
d3f4030708 Fix typo in r342710.
Noted by:	lidl
MFC after:	3 days
2019-01-03 19:35:07 +00:00
Vincenzo Maffione
08f34ad9ed netmap: unit tests: fix issues found by coverity scan
Reported by:	asomers
MFC after:	1 week
Sponsored by:	Sunny Valley Networks
2019-01-03 16:47:05 +00:00
Mark Johnston
7c59ec14e6 Fix a use-after-free in the riscv pmap_release() implementation.
Don't bother zeroing the top-level page before freeing it.  Previously,
the page was freed before being zeroed.

Reviewed by:	jhb, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18720
2019-01-03 16:26:52 +00:00
Mark Johnston
bad66a29d4 Synchronize access to the allpmaps list.
The list will be removed with some future work.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18721
2019-01-03 16:24:03 +00:00
Mark Johnston
60af34002e Fix some issues with the riscv pmap_protect() implementation.
- Handle VM_PROT_EXECUTE.
- Clear PTE_D and mark the page dirty when removing write access
  from a mapping.
- Atomically clear PTE_W to avoid clobbering a hardware PTE update.

Reviewed by:	jhb, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18719
2019-01-03 16:21:44 +00:00
Mark Johnston
8ccaccd522 Set PTE_U on PTEs created by pmap_enter_quick().
Otherwise prefaulted entries are not accessible from user mode and
end up triggering a fault upon access, so prefaulting has no effect.

Reviewed by:	jhb, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18718
2019-01-03 16:19:32 +00:00
Mark Johnston
619999ff9f Use regular stores to update PTEs in the riscv pmap layer.
There's no need to use atomics when the previous value isn't needed.
No functional change intended.

Reviewed by:	kib
Discussed with:	jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18717
2019-01-03 16:15:28 +00:00
Mark Johnston
7b1e32a5be Configure hz=100 in the QEMU target.
We currently don't have a good way to dynamically detect whether the
kernel is running as a guest.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18715
2019-01-03 16:11:21 +00:00
Hans Petter Selasky
fdb955f51f Improve USB generic debug messages. Print process ID and name when opening
and closing usb/ugenX.Y character device nodes.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-01-03 14:27:51 +00:00
Toomas Soome
34ada20958 loader.efi: update memmap command to recognize new attributes
Also move memory type to string translation to libefi for later use.

MFC after:	2 weeks
2019-01-03 09:03:58 +00:00
Andriy Voskoboinyk
d42e525cbc rtwnfw(4): refresh this manpage too (add rtwn-rtl8188eefw module).
MFC after:	3 days
2019-01-03 03:27:37 +00:00
Konstantin Belousov
85f3b801e9 Fix typo, use boolean operator instead of bit-wise.
Reviewed by:	marius, shurd
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2019-01-03 01:01:03 +00:00
Toomas Soome
295586e818 i386_parsedev() needs to support fd devices
MFC after:	2 weeks
2019-01-02 20:31:15 +00:00
Andriy Voskoboinyk
920dfe026c rtwn_usb(4): add USB id for TP-LINK TL-WN821N v5.
It is already mentioned in manpage, but was missing from the driver.

MFC after:	4 days
2019-01-02 18:35:40 +00:00
Andriy Voskoboinyk
b2facf8191 rtwn(4): refresh manpages.
- Add 'device rtwn' to rtwn_pci(4) and rtwn_usb(4) config sample;
kernel will not compile otherwise.
- Refresh devices list in rtwn_usb(4); add 'chipset' column.
- Bump Dd after this commit and r342682.

MFC after:	4 days
2019-01-02 18:30:22 +00:00
Mark Johnston
2e4c75c15e Fix an error check after r342699.
Reported by:	gcc
MFC with:	r342699
Sponsored by:	The FreeBSD Foundation
2019-01-02 17:34:25 +00:00
Andriy Voskoboinyk
0fe1808c72 rtwn_pci(4): fix panic with INVARIANTS (due to inverted assertion logic)
MFC after:	4 days
2019-01-02 17:13:55 +00:00
Mark Johnston
d7fffd0689 Capsicumize savecore(8).
- Use cap_fileargs(3) to open dump devices after entering capability
  mode, and use cap_syslog(3) to log messages.
- Use a relative directory fd to open output files.
- Use zdopen(3) to compress kernel dumps in capability mode.

Reviewed by:	cem, oshogbo
MFC after:	2 months
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18458
2019-01-02 17:09:35 +00:00