Commit Graph

243786 Commits

Author SHA1 Message Date
Alan Somers
99f13ae12c ping: add -H option for enabling reverse DNS lookup
This is the reverse of the -n flag.

Submitted by:	Ján Sučan <sucanjan@gmail.com>
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21356
2019-08-21 21:05:15 +00:00
Alexander Motin
71a2818142 Improve NVMe hot unplug handling.
If device is unplugged from the system (CSTS register reads return
0xffffffff), it makes no sense to send any more recovery requests or
expect any responses back.  If there is a detach call in such state,
just stop all activity and free resources.  If there is no detach
call (hot-plug is not supported), rely on normal timeout handling,
but when it trigger controller reset, do not wait for impossible and
quickly report failure.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2019-08-21 20:17:30 +00:00
Mark Johnston
9fb7c918ef Remove manual wire_count adjustments from the unmapped mbuf code.
The original code came from a desire to minimize the number of updates
to v_wire_count, which prior to r329187 was updated using atomics.
However, there is no significant benefit to batching today, so simply
allocate pages using VM_ALLOC_WIRED and rely on system accounting.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D21323
2019-08-21 20:01:52 +00:00
Konstantin Belousov
65174f684c Fix _pthread_cancel_enter() and _pthread_cancel_leave() jmptable entries.
PR:	240022
Reported by:	Andrew Gierth <andrew@tao11.riddles.org.uk>
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2019-08-21 19:53:50 +00:00
Mark Johnston
6bc13e042f Modify pipe_poll() to properly check for pending direct writes.
With r349546, it is a responsibility of the writer to clear PIPE_DIRECTW
after pinned data has been read.  In particular, once a reader has
drained this data, there is a small window where the pipe is empty but
PIPE_DIRECTW is set.  pipe_poll() was using the presence of PIPE_DIRECTW
to determine whether to return POLLIN, so in this window it would
claim that data was available to read when this was not the case.

Fix this by modifying several checks for PIPE_DIRECTW to instead look
at the number of residual bytes in data pinned by a direct writer.  In
some cases we really do want to check for PIPE_DIRECTW, since the
presence of this flag indicates that any attempt to write to the pipe
will block on the existing direct writer.

Bisected and test case provided by:	mav
Tested by:	pho
Reviewed by:	kib
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21333
2019-08-21 19:35:04 +00:00
Ed Maste
59e9b3695a makefs: Verify that the BPB media descriptor and FAT ID match
From r322982 in sys/fs/msdosfs.
2019-08-21 19:09:40 +00:00
Ed Maste
476b0ab758 makefs: share denode.h between kernel msdosfs and makefs
There is no need to duplicate this file when it can be trivially
shared (just exposing sections previously under #ifdef _KERNEL).

MFC with:	r351273
Differential Revision:	The FreeBSD Foundation
2019-08-21 19:07:13 +00:00
Mark Johnston
8b90607f20 Simplify vm_page_dequeue() and fix an assertion.
- Add a vm_pagequeue_remove() function to physically remove a page
  from its queue and update the queue length.
- Remove vm_page_pagequeue_lockptr() and let vm_page_pagequeue()
  return NULL for dequeued pages.
- Avoid unnecessarily reloading the queue index if vm_page_dequeue()
  loses a race with a concurrent queue operation.
- Correct an always-true assertion: vm_page_dequeue() may be called
  from the page allocator with the page unlocked.  The assertion
  m->order == VM_NFREEORDER simply tests whether the page has been
  removed from the vm_phys free lists; instead, check whether the
  page belongs to an object.

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21341
2019-08-21 16:11:12 +00:00
Mark Johnston
acad79e66f Unconditionally enable debug.vm_lowmem.
It is useful for testing purposes to be able to drain UMA caches, so
do not limit the sysctl to DIAGNOSTIC kernels.

MFC after:	1 week
Sponsored by:	Netflix
2019-08-21 16:01:17 +00:00
Mark Johnston
930b195263 Don't requeue active pages in vm_swapout_object_deactivate_pages().
As of r332974 the page daemon does not requeue pages during a scan
of the active queue, so there is not much value in doing so here
either.

Reviewed by:	alc, dougm, kib
MFC after:	1 week
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21343
2019-08-21 15:52:10 +00:00
Alan Somers
229e8bf2bb ping: do reverse DNS lookup of the target address
When printing replies, ping will now attempt a reverse DNS lookup of the
target.  That can be suppressed by using the "-n" option.  Curiously, ping
has always done reverse lookups in certain error paths, but never in the
success path.

Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21351
2019-08-21 14:52:12 +00:00
Bjoern A. Zeeb
6d7adebad5 gprof: disable building of a.out components
On arm64, riscv, and s390x disable building of aout components.
This allows gprof to build on these architectures which never supported
the legacy a.out binary format.

Obtained from:		s390x branch
MFC after:		3 months
2019-08-21 10:54:52 +00:00
Randall Stewart
e13ad86c67 Fix an issue when TSO and Rack play together. Basically
an retransmission of the initial SYN (with data) would
cause us to strip the SYN and decrement/increase offset/len
which then caused us a -1 offset and a panic.

Reported by:	Larry Rosenman
(Michael Tuexen helped me debug this at the IETF)
2019-08-21 10:45:28 +00:00
Bjoern A. Zeeb
e303ee524e athhal: disable unused function (big endian only)
Disable ar9300_swap_tx_desc() for the moment.  It is an unused
function only tried to compile on big endian systems.

Found by:	s390x buildkernel
MFC after:	3 months
2019-08-21 10:42:31 +00:00
Xin LI
443127c517 Use MTX_NEW instead of bzero().
Submitted by:	cem
2019-08-21 08:15:30 +00:00
Xin LI
5473ef874e Fix sound on headset jack for ThinkPad T51. 2019-08-21 08:01:43 +00:00
Xin LI
ee318606ce Fix a panic in ubt_do_hci_request.
The 'mtx' is on stack and can contain garbages that would cause mtx_init
(and in turn lock_init) to think that the mutex was already initialized.
2019-08-21 07:45:39 +00:00
Mateusz Guzik
d7cf1814bd seqc: predict false for _in_modify and type fixes for _consistent_*
seqc_consistent_* return bool, not seqc. [0]

While here annotate the rarely true condition - it is expected to run
into it on vare occasion (compared to the other case).

Reported by:	oshogbo [0]
Sponsored by:	The FreeBSD Foundation
2019-08-21 04:54:48 +00:00
Justin Hibbits
aef13f050c dpaa: Fix warnings in dtsec(4) found by clang
These are all trivial warnings that have no real functional change.
2019-08-21 02:26:22 +00:00
Ed Maste
51e79affa3 makefs: share fat.h between kernel msdosfs and makefs
There is no reason to duplicate this file when it can be trivially
shared (just exposing one section previously under #ifdef _KERNEL).

Reviewed by:	imp, cem
MFC with:	r351273
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21346
2019-08-21 02:21:40 +00:00
Alexander Motin
51b92c1af6 Formalize NVMe controller consumer life cycle.
This fixes possible double call of fail_fn, for example on hot removal.
It also allows ctrlr_fn to safely return NULL cookie in case of failure
and not get useless ns_fn or fail_fn call with NULL cookie later.

MFC after:	2 weeks
2019-08-21 02:17:39 +00:00
Ed Maste
ef63362055 makefs: use char * not void * for buf b_data, drop casts in msdos
(The kernel uses caddr_t.)

Suggested by:	cem
Reviewed by:	cem
MFC with:	r351273
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21348
2019-08-21 01:45:29 +00:00
Alan Somers
c43633c6a1 ping: Add tests of the Internet checksum function
Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google LLC (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21340
2019-08-20 21:59:48 +00:00
Ed Maste
35284c22e9 makefs.8: update history
- ported to FreeBSD and first appeared in 8.0
- Christos Zoulas added the FAT support that I imported
2019-08-20 21:14:44 +00:00
Ed Maste
b350417ae6 makefs: avoid "dereferencing 'void *' pointer" warnings
On GCC 4.2.1 archs

MFC with:	r351273
Sponsored by:	The FreeBSD Foundation
2019-08-20 20:04:16 +00:00
Toomas Soome
a15a23234d loader.efi: efipart should be more careful about constructing block device lists
The cd handles should be collected as list of partitions. Some systems also
provide base name for block device (like PciRoot(0x0)/Pci(0x5,0x0)), we need
to be careful about those.

To make out life a bit easier, we prepare not just an array of handles, but we
allocate pdinfo struct for each handle and devicepath, then we can simplify
our work to sort the devices.

Differential Revision:	https://reviews.freebsd.org/D21187
2019-08-20 19:31:11 +00:00
Ed Maste
98dc8da58c makefs: add msdosfs (FAT) support
Add FAT support to makefs by copying some files from sys/fs/msdosfs/ and
updating others with changes from NetBSD.

The six files copied from sys/fs/msdosfs at r348251 and modified are:
denode.h direntry.h fat.h msdosfs_fat.c msdosfs_lookup.c msdosfsmount.h

I would prefer to avoid the duplication, but reluctance to doing so was
expressed in a previous review (D11197); for now copy the files and
revisit in the future.

Submitted by:	Siva Mahadevan
Discussed with:	cem, imp
MFC after:	1 month
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D16438
2019-08-20 18:20:45 +00:00
Mark Johnston
35fd0fc409 Use a sleepable lock for midistat functions.
Otherwise the mutex needs to be dropped when copying out the midistat
sbuf, leading to a race which allows one to read kernel memory beyond
the end of the sbuf buffer.

Reported and tested by:	pho
Security:	CVE-2019-5612
2019-08-20 17:52:12 +00:00
Ed Maste
f37192064a mqueuefs: fix compat32 struct file leak
In a compat32 error case we previously leaked a struct file.

Submitted by:	Karsten König, Secfault Security
Security:	CVE-2019-5603
2019-08-20 17:44:03 +00:00
Dimitry Andric
51ff47d7a5 Pull in r368867 from upstream libc++ trunk (by Marshall Clow):
Rework recursive_timed_mutex so that it uses __thread_id instead of
  using the lower-level __libcpp_thread_id. This is prep for fixing
  PR42918. Reviewed as https://reviews.llvm.org/D65895

Pull in r368916 from upstream libc++ trunk (by Marshall Clow):

  Fix thread comparison by making sure we never pass our special 'not a
  thread' value to the underlying implementation. Fixes PR#42918.

This should fix std:🧵🆔:operator==() attempting to call
pthread_equal(3) with zero values.

Reported by:	andrew@tao11.riddles.org.uk
PR:		239038, 239550
MFC after:	3 days
2019-08-20 17:39:32 +00:00
Brooks Davis
98ab79066d Remove some compatability with Seventh Edition UNIX realloc().
In Seventh Edition UNIX, the last pointer passed to free() was
guaranteed to not actually have been freed allowing memory to be
"compacted" via the following pattern:

free(foo);
foo = realloc(foo, newsize);

Further, Andrew Koenig reports in "C Traps and Pitfalls" that the
original realloc() implementation required this pattern.

The C standard is clear that this is Undefined Behavior. Modern
allocators don't support it and no portable code could rely on it so
remove this support.

Note: the removed implementation contains an off-by-one error and if
an item isn't found on the freelist, then twice as much memory as the
largest possible allocation will be copied.

Reviewed by:	kib, imp
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D21296
2019-08-20 16:07:17 +00:00
Justin Hibbits
31c484ad31 Unbreak USB ethernet module builds
Sponsored by:	Juniper Networks, Inc.
2019-08-20 15:14:32 +00:00
Kristof Provost
3e1ebe7fb8 netpfil tests: Add too many fragments test for pf, ipfw and ipf
Add test for checking that the packets are dropped if it is fragmented into
more than the defined value.

Submitted by:	Ahsan Barkati
Reviewed by:	kp
Sponsored by:	Google, Inc. (GSoC 2019)
Differential Revision:	https://reviews.freebsd.org/D21307
2019-08-20 14:46:12 +00:00
Kristof Provost
df3d236d96 netpfil tests: Add the set ToS test for ipfw and pf
This test tests the following:

 - The firewall is able to set the tos bits
 - The firewall is able to set the DSCP bits when EN bits is already set and
   the EN bits remains unchanged.
 - The firewall is able to drop the packets based on ToS value

Submitted by:	Ahsan Barkati
Reviewed by:	kp
Sponsored by:	Google, Inc. (GSoC 2019)
Differential Revision:	https://reviews.freebsd.org/D21305
2019-08-20 14:31:22 +00:00
Justin Hibbits
6793e5b23d powerpc: Link Book-E kernels at the same address as AIM kernels
Summary:
Reduce the diff between AIM and Book-E even more.  This also cleans up
vmparam.h significantly.

Reviewed by:	luporl
Differential Revision:	https://reviews.freebsd.org/D21301
2019-08-20 01:26:02 +00:00
Stephen J. Kiernan
df845c0f86 usb_ethernet.h includes a number of mii headers, but only does so in
order to have struct mii_data available. However, it only really needs
a forward declaration of struct mii_data for use in pointer form for
the return type of a function prototype.

Custom kernel configuration that have usb and fdt enabled, but no miibus,
end up with compilation failures because miibus_if.h will not get
generated.

Due to the above, the following changes have been made to usb_ethernet.h:
 * remove the inclusion of mii headers
 * forward-declare struct mii_data
 * include net/ifq.h to satify the need for complete struct ifqueue

Reviewed by:	ian
Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D21293
2019-08-20 01:06:43 +00:00
Jeff Roberson
cf27e0d125 Use an atomic reference count for paging in progress so that callers do not
require the object lock.

Reviewed by:	markj
Tested by:	pho (as part of a larger branch)
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21311
2019-08-19 23:09:38 +00:00
Conrad Meyer
54a210d407 Fix stylistic nit in r351239
Meant to fix this before committing, but forgot.
2019-08-19 23:01:59 +00:00
Conrad Meyer
3bbe6e643c gdb(4): Support "qC" query
Sometimes GDB gets confused about what the current thread is.  When it does,
it asks the remote: "Who am I?"

Answer it.
2019-08-19 22:58:30 +00:00
Conrad Meyer
130ef1ad11 gdb(4): Pack 'info threads' responses into fewer packets
We suffer at least one round trip ACK latency every command / packet that
GDB has to send and receive, and the response format for 'info threads'
supports packing many threads IDs into a single packet, so do so.

Adds and uses a new API, gdb_txbuf_has_capacity(), which checks for a
certain number of bytes available in the outgoing txbuf.

On an example amd64 VM, the number of RTTs to transmit this list is reduced
by a factor of 110x.  This is especially beneficial with recent GDB, which
seems to request the list at least twice during attach.
2019-08-19 22:57:03 +00:00
Conrad Meyer
2b0ebb77e4 libkern: Implement strchrnul(3) 2019-08-19 22:53:05 +00:00
Jeff Roberson
4153054a7c Permit vm_pager_has_page() to run with a shared lock. Introduce
VM_OBJECT_DROP/VM_OBJECT_PICKUP to handle functions that are called with
uncertain lock state.

Reviewed by:	kib, markj
Tested by:	pho
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21310
2019-08-19 22:25:28 +00:00
Jung-uk Kim
8a3238521b Partially revert the previous commit.
It was an experiment and not meant to be committed. :-(
2019-08-19 21:45:25 +00:00
Ed Maste
5059f7c3ed makefs.8: expand description of image size
Submitted by:	ryan_freqlabs.com, Siva Mahadevan
Differential Revision:	https://reviews.freebsd.org/D21316
2019-08-19 21:38:10 +00:00
Jung-uk Kim
ff0107de44 Fix sound on headset jack for Lenovo Thinkpad X1 Carbon Gen 6 (model 20KH).
Note this commit was inspired by r350433.

MFC after:	2 weeks
2019-08-19 21:30:12 +00:00
Ed Maste
4d393b6c64 makefs.8: style updates from igor
Sponsored by:	The FreeBSD Foundation
2019-08-19 21:21:32 +00:00
Kyle Evans
5c4eed8601 tuntap: belatedly add MODULE_VERSION for if_tun and if_tap
When tun/tap were merged, appropriate MODULE_VERSION should have been added
for things like modfind(2) to continue to do the right thing with the old
names.

Reported by:	jhb
2019-08-19 19:01:59 +00:00
Kyle Evans
7d7fb3dc01 mips: avoid empty mdproc struct
Compiling with a more modern toolchain than GCC 4.2 in base warns about the
empty struct. Take a hint and comment from r350902+r350953 by luporl@.
2019-08-19 18:15:17 +00:00
Alan Somers
a3ce769851 Fix uninitialized variable warnings when MK_CASPER=no
Submitted by:	Ján Sučan <sucanjan@gmail.com>
MFC after:	2 weeks
Sponsored by:	Google, inc. (Google Summer of Code 2019)
Differential Revision:	https://reviews.freebsd.org/D21322
2019-08-19 17:54:40 +00:00
D Scott Phillips
1974d7a40e Don't set the string "unknown" as a device's location_str
Return an empty string when the location is unknown instead of the
string "unknown". This ensures that all location entries are of
the form key=val.

Suggested by:	imp
Approved by:	jhb (mentor)
MFC after:	1 week
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D21326
2019-08-19 17:51:06 +00:00