Compare commits

..
967 Commits
Author SHA1 Message Date
Tai-hwa Liang 28cce1d5b5 arp(8): fixing the deletion failure of IEEE1394 associated addresses
Without this, 'arp -d ${IEEE1394_ADDRESS}' gives the following error:

	arp: delete: cannot locate 10.0.0.71

Reviewed by:	glebius
MFC after:	2 weeks

(cherry picked from commit a0d6d0d0b9)
2021-05-17 10:29:37 +00:00
Tai-hwa Liang 34033bc5b9 if_firewire: fixing panic upon packet reception for VNET build
netisr_dispatch_src() needs valid VNET pointer or firewire_input() will panic
when receiving a packet.

Reviewed by:	glebius
MFC after:	2 weeks

(cherry picked from commit d9b61e7153)
2021-05-17 10:29:12 +00:00
Dimitry Andric 74b123c0a5 Avoid -pedantic warnings about using _Generic in __fp_type_select
When compiling parts of math.h with clang using a C standard before C11,
and using -pedantic, it will result in warnings similar to:

bug254714.c:5:11: warning: '_Generic' is a C11 extension [-Wc11-extensions]
  return !isfinite(1.0);
          ^
/usr/include/math.h:111:21: note: expanded from macro 'isfinite'
                    ^
/usr/include/math.h:82:39: note: expanded from macro '__fp_type_select'
                                      ^

This is because the block that enables use of _Generic is conditional
not only on C11, but also on whether the compiler advertises support for
C generic selections via __has_extension(c_generic_selections).

To work around the warning without having to pessimize the code, use the
__extension__ keyword, which is supported by both clang and gcc. While
here, remove the check for __clang__, as _Generic has been supported for
a long time by gcc too now.

Reported by:	yuri
PR:		254714
2021-04-15 12:26:48 +02:00
Hans Petter Selasky ca32a11644 MFC 4e38478c59:
ipoib: Fix incorrectly computed IPOIB_CM_RX_SG value.

The computed IPOIB_CM_RX_SG is too small. It doesn't account for fallback
to mbuf clusters when jumbo frames are not available and it also doesn't
account for the packet header and trailer mbuf.

This causes a memory overwrite situation when IPOIB_CM is configured.

While at it add a kernel assert to ensure the mapping array is not overwritten.

PR:		254474
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 4e38478c59)
2021-04-01 11:34:24 +02:00
Hans Petter Selasky cdef48b528 MFC 12148d4300:
Fix for locking order reversal in USB audio driver, when using mmap().

Locking the second lock which causes the LOR, can be skipped because
the code updating the shared variables is always executing from the
same USB thread.

lock order reversal:
  1st 0xfffff80005cc3840 pcm7:play:dsp7.p0 (pcm play channel, sleep mutex)
@ usb_transfer.c:2342
  2nd 0xfffff80005cc3860 pcm7:record:dsp7.r0 (pcm record channel, sleep mutex)
@ uaudio.c:2317

lock order pcm record channel -> pcm play channel established at:
witness_checkorder+0x461
__mtx_lock_flags+0x98
dsp_mmap_single+0x151
vm_mmap_cdev+0x65
devfs_mmap_f+0x143
kern_mmap_req+0x594
sys_mmap+0x46
amd64_syscall+0x12e
fast_syscall_common+0xf8

lock order pcm play channel -> pcm record channel attempted at:
witness_checkorder+0xd82
__mtx_lock_flags+0x98
uaudio_chan_play_callback+0xeb
usbd_callback_wrapper+0x7ec
usb_command_wrapper+0x7e
usb_callback_proc+0x8e
usb_process+0xf3
fork_exit+0x80
fork_trampoline+0xe

Found by:	Stefan Ehmann <[email protected]>
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 12148d4300)
2021-03-03 14:33:16 +01:00
Hans Petter Selasky 0a62368c6a MFC 9febbc4541:
Fix for natd(8) sending wrong sequence number after TCP retransmission,
terminating a TCP connection.

If a TCP packet must be retransmitted and the data length has changed in the
retransmitted packet, due to the internal workings of TCP, typically when ACK
packets are lost, then there is a 30% chance that the logic in GetDeltaSeqOut()
will find the correct length, which is the last length received.

This can be explained as follows:

If a "227 Entering Passive Mode" packet must be retransmittet and the length
changes from 51 to 50 bytes, for example, then we have three cases for the
list scan in GetDeltaSeqOut(), depending on how many prior packets were
received modulus N_LINK_TCP_DATA=3:

  case 1:  index 0:   original packet        51
           index 1:   retransmitted packet   50
           index 2:   not relevant

  case 2:  index 0:   not relevant
           index 1:   original packet        51
           index 2:   retransmitted packet   50

  case 3:  index 0:   retransmitted packet   50
           index 1:   not relevant
           index 2:   original packet        51

This patch simply changes the searching order for TCP packets, always starting
at the last received packet instead of any received packet, in
GetDeltaAckIn() and GetDeltaSeqOut().

Else no functional changes.

Discussed with:	rscheff@
Submitted by:	Andreas Longwitz <[email protected]>
PR:		230755
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 9febbc4541)
2021-03-03 10:57:29 +01:00
Martin Matuska 5f80b1e0ae contrib/libarchive: Import libarchive 3.5.1
(cherry picked from commit 69a18c5826)
2021-01-11 02:34:58 +01:00
Xin LI 65ca6e8597 bsdcat,cpio,tar: derive version string from archive.h
(cherry picked from commit 2ff66a9155)
2021-01-11 02:22:02 +01:00
Martin Matuska 3ad46d0783 MFC r368207,368607:
MFC r368207:
Update libarchive to 3.5.0

Relevant vendor changes:
  Issue #1258: add archive_read_support_filter_by_code()
  PR #1347: mtree digest reader support
  Issue #1381: skip hardlinks pointing to itself on extraction
  PR #1387: fix writing of cpio archives with hardlinks without file type
  PR #1388: fix rdev field in cpio format for device nodes
  PR #1389: completed support for UTF-8 encoding conversion
  PR #1405: more formats in archive_read_support_format_by_code()
  PR #1408: fix uninitialized size in rar5_read_data
  PR #1409: system extended attribute support
  PR #1435: support for decompression of symbolic links in zipx archives
  Issue #1456: memory leak after unsuccessful archive_write_open_filename

MFC r368607:
Sync libarchive with vendor.

Vendor changes:
  Issue #1461: Unbreak build without lzma
  Issue #1462: warc reader: Fix build with gcc11
  Issue #1463: Fix code compatibility in test_archive_read_support.c
  Issue #1464: Use built-in strnlen on platforms where not available
  Issue #1465: warc reader: fix undefined behaviour in deconst() function
2020-12-16 22:25:40 +00:00
Hans Petter Selasky e61d354b85 Fix bug in ifconfig regarding VLAN creation.
Detection of VLAN interface type must happen before detection of
interface type by prefix. Else the following sequence of commands will
try to create a LAGG interface instead of a VLAN interface, which
accidentially works, because the data pointed to by the ifr_data
pointer is not parsed by the VLAN create ioctl(2).

How to reproduce:
# ifconfig lagg0 create
# ifconfig lagg0.256 create

This is a direct commit.

Differential Revision:	https://reviews.freebsd.org/D27521
Tested by:		[email protected]
Sponsored by:		Mellanox Technologies // NVIDIA Networking
2020-12-10 09:39:27 +00:00
Cy Schubert 691ac35b6e MFC r367070:
Remove a random equal sign from the example. It should not be there.
It's a syntax error.

PR:		210303
Reported by:	leventelist at gmail.com
2020-10-30 00:34:40 +00:00
Greg Lehey f809076fdb Correct location and date of the Boston Shoemakers' organization,
which significantly predated the USA.

Reference: http://www.famousdaily.com/history/boston-shoemakers-form-first-us-labor-organization.html
2020-10-18 01:57:49 +00:00
Dimitry Andric a4624fea21 MFC r363988:
Fix clang 11 -Wformat warnings in yp_mkdb:

usr.sbin/yp_mkdb/yp_mkdb.c:91:40: error: format specifies type 'char *' but the argument has type 'void *' [-Werror,-Wformat]
                printf("%.*s %.*s\n", (int)key.size, key.data, (int)data.size,
                        ~~~~                         ^~~~~~~~
usr.sbin/yp_mkdb/yp_mkdb.c:92:7: error: format specifies type 'char *' but the argument has type 'void *' [-Werror,-Wformat]
                    data.data);
                    ^~~~~~~~~
2020-08-10 17:35:58 +00:00
Cy Schubert 82d9a84673 MFC r363453:
Document the IPFILTER_PREDEFINED environment variable.

PR:		248088
Reported by:	[email protected]
2020-07-30 02:52:55 +00:00
Dimitry Andric f1577c2659 MFC r362623:
Fix copy/paste mistake in kvm_getswapinfo(3)

It seems this manpage was copied from kvm_getloadavg(3), but the
DIAGNOSTICS section was not updated completely. Update the section with
correct information about a return value of -1.
2020-06-30 15:53:52 +00:00
Ravi Pokala 8cebe0d35c MFC r362078:
Decode the "LACP Fast Timeout" LAGG option flag

r286700 added the "lacp_fast_timeout" option to `ifconfig', but we forgot to
include the new option in the string used to decode the option bits. Add
"LACP_FAST_TIMO" to LAGG_OPT_BITS.

Also, s/LAGG_OPT_LACP_TIMEOUT/LAGG_OPT_LACP_FAST_TIMO/g , to be clearer that
the flag indicates "Fast Timeout" mode.
2020-06-19 07:07:10 +00:00
Hans Petter Selasky 1ae4bac217 MFC r362045:
Make sure packets generated by raw IP code is let through by mlx5en(4).

Allow the TCP header to reside in the mbuf following the IP header.
Else such packets will get dropped.

Backtrace:
mlx5e_sq_xmit()
mlx5e_xmit()
ether_output_frame()
ether_output()
ip_output_send()
ip_output()
rip_output()
sosend_generic()
sosend()
kern_sendit()
sendit()
sys_sendto()
amd64_syscall()
fast_syscall_common()

Sponsored by:	Mellanox Technologies
2020-06-18 10:41:51 +00:00
Hans Petter Selasky e5fce44e51 MFC r362044:
Extend use of unlikely() in the fast path, in mlx5en(4).

Typically the TCP/IP headers fit within the first mbuf and should not
trigger any of the error cases. Use unlikely() for these cases.

No functional change.

Sponsored by:	Mellanox Technologies
2020-06-18 10:31:21 +00:00
Hans Petter Selasky 73356f0257 MFC r362043:
Use const keyword when parsing the TCP/IP header in the fast path in mlx5en(4).

When parsing the TCP/IP header in the fast path, make it clear by using
the const keyword, no fields are to be modified inside the transmitted
packet.

No functional change.

Sponsored by:	Mellanox Technologies
2020-06-18 10:17:36 +00:00
Kyle Evans 3e776406b0 MFC r361977: libusb: improve compatibility
Specifically, add LIBUSB_CLASS_PHYSICAL and the libusb_has_capability API.
Descriptions and functionality for these derived from the
documentation at [0].  The current set of capabilities are all supported by
libusb.

These were detected as missing after updating net/freerdp to 2.1.1, which
attempted to use both.

[0] http://libusb.sourceforge.net/api-1.0/group__libusb__misc.html
2020-06-16 12:21:55 +00:00
Hans Petter Selasky 0be584a949 MFC r362056:
Add missing range checks when receiving USB ethernet packets.

Found by:	Ilja Van Sprundel, IOActive
Sponsored by:	Mellanox Technologies
2020-06-14 05:33:25 +00:00
Martin Matuska 918c81b92d MFC r361294:
Update libarchive to 3.4.3

Relevant vendor changes:
  PR #1352: support negative zstd compression levels
  PR #1359: improve zstd version checking
  PR #1348: support RHT.security.selinux from GNU tar
  PR #1357: support for archives compressed with pzstd
  PR #1367: fix issues in acl tests
  PR #1372: child handling cleanup
  PR #1378: fix memory leak from passphrase callback
2020-06-12 23:02:34 +00:00
Cy Schubert 813b53604c MFC 361721:
Per-rule hit counts (-h) can be used with either -i (input) or -o (output)
filter rule lists.
2020-06-08 14:00:11 +00:00
Hans Petter Selasky 1036bfa7dd MFC r361827:
USB HID descriptors may push/pop the current state to allow
description of items residing in a so-called union. FreeBSD currently
only supports 4 such push levels.

If the push level is not restored within the processing of the same
HID item, an invalid memory location may be used for subsequent HID
item processing.

Verify that the push level is always valid when processing HID items.

Reported by:	Andy Nguyen (Google)
Sponsored by:	Mellanox Technologies
2020-06-08 09:34:16 +00:00
Hans Petter Selasky a879f39e0f MFC r361582:
Fix check for wMaxPacketSize in USB bluetooth driver,
in case device is not FULL speed.

Sponsored by:	Mellanox Technologies
2020-06-08 09:31:14 +00:00
Hans Petter Selasky ed33b8c8a5 MFC r361581:
Implement helper function, usbd_get_max_frame_length(), which allows kernel
device drivers to correctly predict the default USB transfer frame length.

Sponsored by:	Mellanox Technologies
2020-06-08 09:28:26 +00:00
Hans Petter Selasky 8e51c3499e MFC r361577:
Don't allow USB device drivers to parent own interface.
It will prevent proper USB device detach.

Sponsored by:	Mellanox Technologies
2020-06-08 09:25:01 +00:00
Hans Petter Selasky ced76afa5b MFC r361075:
Assign process group of the TTY under the "proctree_lock".

This fixes a race where concurrent calls to doenterpgrp() and
leavepgrp() while TIOCSCTTY is executing may result in tp->t_pgrp
changing value so that tty_rel_pgrp() misses clearing it to NULL. For
more details refer to the use of pgdelete() in the kernel.

No functional change intended.

Panic backtrace:
__mtx_lock_sleep() # page fault due to using destroyed mutex
tty_signal_pgrp()
tty_ioctl()
ptsdev_ioctl()
kern_ioctl()
sys_ioctl()
amd64_syscall()

Sponsored by:	Mellanox Technologies
2020-05-22 09:01:26 +00:00
Hans Petter Selasky 1c51f8afbb MFC r360092:
Bring HCI error messages up-to-date.
See Bluetooth v5.6 core specification Vol.1 Part F: Controller error codes.

Submitted by:	Marc Veldman <[email protected]>
PR:		245737
Sponsored by:	Mellanox Technologies
2020-05-18 08:45:24 +00:00
Hans Petter Selasky d6d5d1aac0 MFC r360070:
Add missing feature descriptions to hci_features2str().

The list of possible features in hccontrol/features2str() is incomplete.
Refer to "Bluetooth Core Specification 5.2 Vol. 2 Part C. 3.3 Feature Mask Definition".

Submitted by:	Marc Veldman <[email protected]>
PR:		245354
Sponsored by:	Mellanox Technologies
2020-05-18 08:43:05 +00:00
Dimitry Andric b6ef66b027 MFC r360322:
Fix race between prebuilding libsbuf and libgeom

The latter needs the former, but with a multi-job build on a fast
machine, the race is sometimes lost. This leads to "ld: error: unable to
find library -lsbuf", when linking libgeom.so.

Submitted by:	kevans
2020-05-01 18:27:14 +00:00
Dimitry Andric 42789815e0 Remove stray "DO NOT DELETE" line, which bmake apparently put in without
my knowledge or consent. I did not intend to commit this.
2020-04-26 15:52:41 +00:00
Dimitry Andric b7132592ad Add casts to work around harmless -Werror warnings from clang 10.0.0,
such as:

usr.sbin/timed/timed/networkdelta.c:160:13: error: implicit conversion from 'long' to 'float' changes value from 9223372036854775807 to 9223372036854775808
      [-Werror,-Wimplicit-int-float-conversion]
        float ap = LONG_MAX;            /* bounds on the median */
              ~~   ^~~~~~~~

Direct commit to stable/{10,11,12}, since timed has been removed from
FreeBSD 13.
2020-04-26 15:50:32 +00:00
Hans Petter Selasky dfce0ef7af MFC r360075:
Set the maximum exit latency to 0 for XHCI USB 3.0 devices, because we
don't implement link power management, LPM.

This fixes error code XHCI_TRB_ERROR_BANDWIDTH for isochronous USB 3.0
transactions.

Submitted by:	Horse Ma <[email protected]>
Sponsored by:	Mellanox Technologies
2020-04-26 08:38:10 +00:00
Hans Petter Selasky d623c63a66 MFC r359968:
Cast all ioctl command arguments through uint32_t internally.

Hide debug print showing use of sign extended ioctl command argument
under INVARIANTS. The print is available to all and can easily fill
up the logs.

No functional change intended.

Sponsored by:	Mellanox Technologies
2020-04-26 08:35:32 +00:00
Dimitry Andric 49b84632c5 MFC r348282 (by lwhsu):
Remove an uneeded indentation introduced in r286196 to silence gcc warnging

Sponsored by:	The FreeBSD Foundation
2020-04-25 22:23:34 +00:00
Dimitry Andric 490e73cc01 MFC r348445 (by lwhsu):
Add the missing braces to fix the code not guarded by the if clause and has
misleading indentation.  This is found by gcc -Wmisleading-indentation

Approved by:	erj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20428
2020-04-25 13:14:06 +00:00
Dimitry Andric 1add3aeb4f Fix misleading indentation in sys/dev/drm2/radeon/evergreen.c
This fixes the following warning from recent versions of clang and gcc:

sys/dev/drm2/radeon/evergreen.c:554:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]

Direct commit to stable/{10,11,12}, since this driver has been removed
from FreeBSD 13.
2020-04-25 13:10:17 +00:00
Dimitry Andric 33d365389d MFC r354834 (by jhibbits):
bsnmp: Fix operator precedence in error check in table_check_response

Summary:
The ?: operator has a lower precedence than == and &&, so the result will always
be recorded as true.  Found by gcc8.

Reviewed by:	ngie, ae
Differential Revision: https://reviews.freebsd.org/D22427
2020-04-25 12:57:20 +00:00
Hans Petter Selasky 5fd1223111 MFC r359446:
Add support for multiple playback and recording devices per physical USB audio
device. This requires some structural refactoring inside the driver, mostly
about converting existing audio channel structures into arrays.

The main audio mixer is provided by the first PCM instance.
The non-first audio instances may only have a software mixer for PCM playback.

Tested by:	Horse Ma <[email protected]>
Sponsored by:	Mellanox Technologies
2020-04-13 16:34:21 +00:00
Hans Petter Selasky 0dce3fac5b MFC r359440:
Implement new mixer API to return the device pointer based on the mixer pointer.

Sponsored by:	Mellanox Technologies
2020-04-13 16:32:18 +00:00
Hans Petter Selasky 34bac8dd3f MFC r359356:
Change default microphone level from 0 to 25.

Discussed with:	Horse Ma <[email protected]>
Sponsored by:	Mellanox Technologies
2020-04-13 16:30:10 +00:00
Hans Petter Selasky 9d29ca0cc0 MFC r359355:
Improve USB audio mixer support for USB audio class 1 and 2.
- make sure volume controls are correctly mapped to "pcm" and "rec" depending
  on how they deliver audio to the USB host.
- make sure there are no duplicate record selections.
- remove internal only mixer class type.
- don't add software volume controls for recording only.
- some minor mixer code cleanup.

Tested by:	Horse Ma <[email protected]>
Sponsored by:	Mellanox Technologies
2020-04-13 16:28:15 +00:00
Hans Petter Selasky d72d2a6419 MFC r359323:
Be more intelligent when classifying USB audio terminal types, so that we
don't end up using SOUND_MIXER_VOLUME for all undefined types.

Sponsored by:	Mellanox Technologies
2020-04-13 16:26:15 +00:00
Hans Petter Selasky 0db97df7b8 MFC r359322:
Make mute controls available for USB audio mixers.

Submitted by:	Horse Ma <[email protected]>
Sponsored by:	Mellanox Technologies
2020-04-13 16:24:21 +00:00
Hans Petter Selasky a308210e1f MFC r359321:
Factor out USB audio mixer value range check.

Sponsored by:	Mellanox Technologies
2020-04-13 16:22:15 +00:00
Hans Petter Selasky 7d70098a7c MFC r359320:
Avoid scaling USB audio mixer values twice.

Sponsored by:	Mellanox Technologies
2020-04-13 16:19:45 +00:00
Hans Petter Selasky 70e5427881 MFC r359653:
Count number of times transmit ring is out of buffers in mlx5en(4).

Differential Revision:	https://reviews.freebsd.org/D24273
Sponsored by:	Mellanox Technologies
2020-04-13 09:02:17 +00:00
Hans Petter Selasky 644d59c8ae MFC r359654:
Ensure a minimum inline size of 16 bytes in mlx5en(4).

This includes 14 bytes of ethernet header and 2 bytes of VLAN header.

This allows for making assumptions about the inline size limit
in the fast transmit path later on.

Use a signed integer variable to catch underflow.

Sponsored by:	Mellanox Technologies
2020-04-13 08:33:49 +00:00
Hans Petter Selasky 9c75837402 MFC r359120:
Correctly implement support for remote wakeup for USB 3.0 device.

Submitted by:	Horse Ma <[email protected]>
Sponsored by:	Mellanox Technologies
2020-03-26 05:38:33 +00:00
Tai-hwa Liang 8faa6d591f MFC r338422: Adding support for CS46xx MIDI output.
With this patch, users can play the MIDI files through /dev/sequencer
device with tools like playmidi. The audio output will go through
the external MIDI device such like wavetable synthesis card.

Reviewed by:	matk (a long time ago), kib
Tested with:	Terratec SiXPack 5.1+ + Yamaha DB50XG
2020-03-20 14:26:08 +00:00
Hans Petter Selasky 4819b05a8b MFC r359014:
Fix for double unlock in ipoib.

The ipoib_unicast_send() function is not supposed to unlock the priv lock.

Sponsored by:	Mellanox Technologies
2020-03-19 09:20:41 +00:00
Hans Petter Selasky efd6d26f78 MFC r358841:
Fix for building libusb under Linux.

Sponsored by:	Mellanox Technologies
2020-03-13 09:18:28 +00:00
Hans Petter Selasky b94a1da4ad MFC r358838:
Add support for the device statistics IOCTL, needed by the coming
linux_libusb upgrade.

Sponsored by:	Mellanox Technologies
2020-03-13 08:57:22 +00:00
Hans Petter Selasky 4bd5683e45 MFC r358695:
Define more subsystem orders.
Intended for use with module_init_order() in the LinuxKPI.

Sponsored by:	Mellanox Technologies
2020-03-13 08:53:59 +00:00
Hans Petter Selasky 4047cce7cc MFC r358694:
Fix some whitespace issues in ipoib.

Sponsored by:	Mellanox Technologies
2020-03-13 08:50:56 +00:00
Martin Matuska 90e4b42003 MFC r358533:
Sync libarchive with vendor.

Relevant vendor changes:
  Issue #1257: Add testcase for ZIPX files with LZMA_STREAM_END marker
  PR #1331: cpio.5: fix hard link description
  Issue #1335: archive_read.c: fix UBSan warning about undefined behavior
  Issue #1338: XAR reader: fix UBSan warning about undefined behavior
  Issue #1339: bsdcpio_test: fix datatype in from_hex()
  Issue #1341: Safe writes: delete temporary file if rename fails.
  Issue #1341: Safe writes: improve error handling
2020-03-13 01:06:08 +00:00
Hans Petter Selasky f155cbeb36 MFC r358629:
Implement a detaching flag for the sound(4) subsystem to take
appropriate actions when we are trying to detach an audio device,
but cannot because someone is using it.

This avoids applications having to wait for the DSP read data
timeout before they receive any error indication.
Tested with virtual_oss(8).

Remove some unused definitions while at it.

PR:		194727
Sponsored by:	Mellanox Technologies
2020-03-11 08:26:11 +00:00
Hans Petter Selasky fcb6db628b MFC r358738:
Remove the power bit from the super speed root hub port status register
because it clobbers the super speed link status when a device is in super
speed mode. Currently the power bit is not needed for anything in the USB
hub driver.

This fixes USB warm reset for super speed devices.

Tested by:	[email protected]
Sponsored by:	Mellanox Technologies
2020-03-11 08:21:48 +00:00
Glen Barber 6ad24bd730 Remove reference to the freebsd-mobile mailing list to fix the build.
This is a direct commit to stable/10 as part of an ongoing investigation
regarding transient and silent build failures.

Sponsored by:	Rubicon Communications, LLC (netgate.com)
2020-02-19 15:30:13 +00:00
Martin Matuska 55f1ebd2ad MFC r356212,r356366,r356416,r357785
Update libarchive to version 3.4.2

Relevant vendor changes (r356212):
  Issue #351: Refactor and implement private state logic for write filters
  PR #1252: RAR5 reader - verify window size for solid files (OSS-Fuzz 15482)
  PR #1255: zip writer - don't append unused NUL for directories
  PR #1260: Fix sparse file offset overflow on 32-bit systems
  PR #1263: UNICODE filename support for reading lha/lzh format
  Issue #1276: Bugfix and optimize archive_wstring_append_from_mbs()
  PR #1288: Add the "xattrhdr" option to pax write options
  PR #1295: 7z reader - fix reading archives with digests in PackInfo
  PR #1296: RAR5 reader - verify window size for multivolume archives
  PR #1297: ZIP reader - support LZMA_STREAM_END marker in 'lzma alone' files
  Issue #1298: Fix a heap-buffer-overflow in archive_string_append_from_wcs()
  OSS-Fuzz 19360, 19362: LHA reader - plug two memory leaks on error
  Fix possible off-by-one when dealing with readlink(2)

Relevant vendor changes (r356366):
  Issue #1302: Plug memory leak on failure of archive_write_client_open()

Relevant vendor changes (r356416):
  Issue #1302: Re-do fix for archive_write_client_open()

Relevant vendor changes (r357785):
  PR #1289: atomic extraction support (bsdtar -x --safe-writes)
  PR #1308: big endian fix for UTF16 support in LHA reader
  PR #1326: reject RAR5 files that declare invalid header flags
  Issue #987: fix support 7z archive entries with Delta filter
  Issue #1317: fix compression output buffer handling in XAR writer
  Issue #1319: fix uname or gname longer than 32 characters in pax writer
  Issue #1325: fix use after free when archiving hardlinks in ISO9660 or XAR
  Use localtime_r() and gmtime_r() instead of localtime() and gmtime()
2020-02-19 01:51:44 +00:00
Rick Macklem c73f11781d MFC: r357149
Fix a crash in the NFSv4 server.

The PR reported a crash that occurred when a file was removed while
client(s) were actively doing lock operations on it.
Since nfsvno_getvp() will return NULL when the file does not exist,
the bug was obvious and easy to fix via this patch. It is a little
surprising that this wasn't found sooner, but I guess the above
case rarely occurs.

PR:		242768
2020-02-17 19:31:34 +00:00
Ed Maste 5b3b2e9520 MFC r357212: libfetch: fix urldecode buffer overrun
Reported by:	Duncan Overbruck
Security:	CVE-2020-7450
2020-02-05 18:26:50 +00:00
Dimitry Andric 8285357af0 MFC r357340:
Merge r357339 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in bsnmpd:

usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c:1661:4: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
                        return (-1);
                        ^
usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c:1658:5: note: previous statement is here
                } else
                  ^

The intent was to group the return statement with the previous syslog()
call.
2020-02-04 19:46:29 +00:00
Dimitry Andric 915e9ddcc8 MFC r357272:
Merge r357271 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in bsnmpd:

usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c:1235:43: error: overlapping comparisons always evaluate to true [-Werror,-Wtautological-overlap-compare]
                            begemotBridgeStpPortEnable_enabled ||
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~

Work around it by casting the enum values to the type of val->v.integer.
2020-02-04 19:35:40 +00:00
Dimitry Andric 2434dfaf87 MFC r357268:
Merge r357260 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in procstat:

usr.bin/procstat/procstat_sigs.c:79:3: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
                xo_close_container(name);
                ^
usr.bin/procstat/procstat_sigs.c:77:4: note: previous statement is here
        } else
          ^

The intent was to group the xo_close_container() call to the previous
snprintf() call.
2020-02-04 19:31:01 +00:00
Dimitry Andric d4c816e3f8 MFC r357269:
Merge r357267 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in tip:

usr.bin/tip/tip/tip.c:428:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                        if (gch == EOF)
                        ^
usr.bin/tip/tip/tip.c:426:5: note: previous statement is here
                } else if (!cumode && gch == character(value(FORCE)))
                  ^

The intent was to have the EOF check grouped with the getchar() call
just above it.  This was accidentally introduced in r354624.
2020-02-04 19:24:10 +00:00
Dimitry Andric 564462232a MFC r357223:
Merge r357222 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in rbootd:

libexec/rbootd/rmpproto.c:335:49: error: multiple unsequenced modifications to 'filename' [-Werror,-Wunsequenced]
        filename = (filename = strrchr(filepath,'/'))? ++filename: filepath;
                 ~                                     ^
2020-02-04 19:19:48 +00:00
Hans Petter Selasky 8bbbe7519d MFC r357298:
Add missing mutex unlock in failure case.

Differential Revision:	https://reviews.freebsd.org/D23430
Submitted by:	cem
Reported by:	Coverity
Coverity CID:	1368773
Sponsored by:	Mellanox Technologies
2020-02-03 11:05:59 +00:00
Hans Petter Selasky c38649c1a5 MFC r356952:
Add new USB ID to uslcom(4).

Submitted by:	Oleg Sharoyko <[email protected]>
PR:		243494
Sponsored by:	Mellanox Technologies
2020-02-03 10:50:52 +00:00
Hans Petter Selasky 4e3ad9932d MFC r356633:
Make sure the VNET is properly set when reaping mbufs in ipoib.
Else the following panic may happen:

panic()
icmp_error()
ipoib_cm_mb_reap()
linux_work_fn()
taskqueue_run_locked()
taskqueue_thread_loop()
fork_exit()
fork_trampoline()

Submitted by:	Andreas Kempe <[email protected]>
Sponsored by:	Mellanox Technologies
2020-02-03 10:47:44 +00:00
Dimitry Andric 5fc03e3ac8 MFC r357226:
Merge r357224 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in binutils:

contrib/binutils/bfd/peicode.h:1356:3: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                if (efi)
                ^
contrib/binutils/bfd/peicode.h:1353:8: note: previous statement is here
              if (pe_arch (bfd_target_efi_arch (*target_ptr)) != arch)
              ^
contrib/binutils/bfd/peicode.h:1370:3: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                if (!efi)
                ^
contrib/binutils/bfd/peicode.h:1367:8: note: previous statement is here
              if (pe_arch (bfd_target_pei_arch (*target_ptr)) != arch)
              ^
2020-01-31 20:04:32 +00:00
Hans Petter Selasky 1d6677d816 MFC r356545:
Fix a XHCI driver issue with Intel's Gemini Lake SOC.

Do not configure any endpoint twice, but instead keep track of which
endpoints are configured on a per device basis, and use an evaluate
endpoint context command instead. When changing the configuration make
sure all endpoints get deconfigured and the configured endpoint mask
is reset.

This fixes an issue where an endpoint might stop working if there is
an error and the endpoint needs to be reconfigured as a part of the
error recovery mechanism in the FreeBSD USB stack.

Tested by:	[email protected]
Sponsored by:	Mellanox Technologies
2020-01-16 08:53:59 +00:00
Eugene Grosbein 5fa34b8a8b MFC r356551: arp(8): avoid segfaulting due to out-of-bounds memory access
Fix obvious mistake that sometimes results in reading memory
past end of an array.

PR:             242784
2020-01-16 08:27:30 +00:00
Hans Petter Selasky ef82243a03 MFC r356409:
Add own counter for cancelled USB transfers.
Do not count these as errors.

Bump the FreeBSD version to force recompilation of external modules.

Sponsored by:	Mellanox Technologies
2020-01-13 11:33:03 +00:00
Hans Petter Selasky 0b844fec0d MFC r356201:
Fix spelling.

PR:		242891
Sponsored by:	Mellanox Technologies
2020-01-06 09:51:54 +00:00
Hans Petter Selasky 342f3e9b35 MFC r356137:
Implement dump_stats command for usbconfig(8).

This command is useful when debugging USB device issues.

Sponsored by:	Mellanox Technologies
2020-01-06 09:40:59 +00:00
Hans Petter Selasky a51c4079e6 MFC r351146:
Implement detach_kernel_driver command in usbconfig(8).

Submitted by:	Kevin Zheng <[email protected]>
PR:		239916
2020-01-06 09:40:18 +00:00
Hans Petter Selasky 13c20419e8 MFC r333089:
Clean up the EXAMPLES section of usbconfig(8).  This removes parts that
become redundant after documenting all the subcommands, and switches
to the new syntax, without the '-d'.

Reviewed by:	hselasky@
Sponsored by:	The FreeBSD Foundation
2020-01-06 09:38:57 +00:00
Hans Petter Selasky 52313900cd MFC r332659:
Make it possible to pass the ugenX.Y to usbconfig(8) without using "-d",
eg "usbconfig ugen1.2 dump_all_desc".

Reviewed by:	hselasky@
Sponsored by:	The FreeBSD Foundation
2020-01-06 09:38:08 +00:00
Hans Petter Selasky 941b2e33b7 MFC r330875:
Add "usbconfig dump_all_desc", a subcommand to dump all device and config
descriptors.

Reviewed by:	hselasky@
Sponsored by:	The FreeBSD Foundation
2020-01-06 09:37:13 +00:00
Hans Petter Selasky 62c9e92224 MFC r327522:
Fix warnings from "mandoc -Tlint -Wwarning".

Reported by:	Yuri Pankov <yuripv at gmx.com>
Sponsored by:	The FreeBSD Foundation
2020-01-06 09:35:57 +00:00
Hans Petter Selasky 39c982b486 MFC r327382:
Improve usbconfig(8) manual page by adding descriptions for subcommands.

Reviewed by:	hselasky
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D13445
2020-01-06 09:35:11 +00:00
Hans Petter Selasky 38306b1aa3 MFC r356136:
Implement new libusb v2.0 API function, libusb20_dev_get_stats().

This function is useful when debugging USB device issues.

Sponsored by:	Mellanox Technologies
2020-01-06 09:22:33 +00:00
Hans Petter Selasky 2cb11e78e7 MFC r356135:
Make USB statistics per device instead of per bus.

Bump the FreeBSD version due to structure change to
force recompilation of external USB modules.

Sponsored by:	Mellanox Technologies
2020-01-06 09:16:41 +00:00
Hans Petter Selasky c9f30175c4 MFC r355447:
Fix compilation issue with mlx5core and sparc64 (gcc48):

sys/dev/mlx5/mlx5_en/mlx5_en_tx.c:335: error: requested alignment is not a constant

Sponsored by:	Mellanox Technologies
2019-12-25 09:34:16 +00:00
Hans Petter Selasky cd8cb58453 MFC r355108 and r355170:
Fix panic when loading kernel modules before root file system is mounted.
Make sure the rootvnode is always NULL checked.

Differential Revision:	https://reviews.freebsd.org/D22545
PR:		241639
Sponsored by:	Mellanox Technologies
2019-12-05 14:53:46 +00:00
Dimitry Andric a082bf8657 r355120 | dim | 2019-11-26 23:01:09 +0100 (Tue, 26 Nov 2019) | 32 lines
The fdlibm hypot() implementations shouldn't potentially left-shift
negative numbers (invoking undefined behavior)

Summary:
Various paths through hypot(x, y) will multiply x and y by a power of
two, perform the calculation in a range where IEEE-754 provides greater
precision, then undo the multiplication to determine the true result.
Undoing that multiplication is implemented as t1*w, where t1=2**k.

2**k is often computed by taking the high word of 1.0, then adding k<<20
(for doubles or long doubles) or k<<23 (for floats) to it, then
overwriting that high word. But when k is negative this left-shifts a
negative value -- and that's undefined behavior in many editions of C
and C++.

This patch should fix all hypot implementations to compute 2**k without
triggering this particular bit of undefined behavior.

Test Plan: I've only very lightly tested out the hypot(double, double)
change, in SpiderMonkey's JavaScript engine, for consistency with prior
behavior.  The other functions' changes have more or less only been
eyeballed.  Careful examination appreciated!  Do note, however, that an
error in any of these changes would most likely produce a value that is
incorrect by a factor of two, so any mistake would most likely be
glaring if invoked.

Submitted by:	Jeff Walden <[email protected]>
Obtained from:	https://github.com/freebsd/freebsd/pull/414
Reviewed by:	dim, lwhsu
Differential Revision: https://reviews.freebsd.org/D22354
2019-12-04 17:45:34 +00:00
Dimitry Andric 2f784e2201 MFC r354255:
Add __isnan()/__isnanf() aliases for compatibility with glibc and CUDA

Even though clang comes with a number of internal CUDA wrapper headers,
compiling sample CUDA programs will result in errors similar to:

In file included from <built-in>:1:
In file included from /usr/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204:
/usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:2910:7: error: no matching function for call to '__isnan'
  if (__isnan(a)) {
      ^~~~~~~
/usr/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16: note: candidate function not viable: call to __device__ function from __host__ function
__DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); }
               ^

CUDA expects __isnan() and __isnanf() declarations to be available,
which are glibc specific extensions, equivalent to the regular isnan()
and isnanf().

To provide these, define __isnan() and __isnanf() as aliases of the
already existing static inline functions __inline_isnan() and
__inline_isnanf() from math.h.

Reported by:	arrowd
PR:		241550
2019-11-10 17:33:10 +00:00
Warner Losh 056a75cc04 Replace current with stable/10
Direct commit because not relevant to other branches

Reported by:	Jamie Landeg-Jones
2019-11-06 14:34:14 +00:00
Marius Strobl b71493ef59 MFC: r353778 (partial)
In em_handle_link(), only re-arm the link state change interrupt for
82574 and also only if such a device uses MSI-X, i. e. takes advantage
of autoclearing. In case of INTx and MSI re-arming isn't appropriate
here and setting EM_MSIX_LINK isn't either.
2019-10-30 21:49:34 +00:00
Navdeep Parhar b67908ead5 MFC r319872, r321063, r321582, r322034, r322425, r322962, r322985,
r325596, r326026, r328420, r331472, r333276, r333650, r333652, r334406,
r334409-r334410, r334489, r336042, r340651, r342603, and r345083.

This updates the cxgbe firmwares in stable/10 and also pulls in support
for some newer boards and flash parts.

r319872:
cxgbe(4):  Do not request an FEC setting that the port does not support.

r321063:
cxgbe(4): Various link/media related improvements.

r321582:
cxgbe(4): Some updates to the common code.

r322034:
cxgbe(4): Always use the first and not the last virtual interface
associated with a port in begin_synchronized_op.

r322425:
cxgbe(4): Save the last reported link parameters and compare them with
the current state to determine whether to generate a link-state change
notification.  This fixes a bug introduced in r321063 that caused the
driver to sometimes skip these notifications.

r322962:
cxgbe(4): Remove write only variable from t4_port_init.

r322985:
cxgbe(4): Maintain one ifmedia per physical port instead of one per
Virtual Interface (VI).  All autonomous VIs that share a port share the
same media.

r325596:
cxgbe(4): Do not request settings not supported by the port.

r326026:
cxgbe(4): Add a custom board to the device id list.

r328420:
cxgbe(4): Do not display harmless warning in non-debug builds.

r331472:
cxgbe(4): Always initialize requested_speed to a valid value.

This fixes an avoidable EINVAL when the user tries to disable AN after
the port is initialized but l1cfg doesn't have a valid speed to use.

r333276:
cxgbe(4): Update all firmwares to 1.19.1.0.

r333650:
cxgbe(4): Claim some more T5 and T6 boards.

r333652:
cxgbe(4): Add support for two more flash parts.

r334406:
cxgbe(4): Consider all supported speeds when building the ifmedia list
for a port.  Fix other related issues while here:
- Require port lock for access to link_config.
- Allow 100Mbps operation by tracking the speed in Mbps.  Yes, really.
- New port flag to indicate that the media list is immutable.  It will
  be used in future refinements.

This also fixes a bug where the driver reports incorrect media with
recent firmwares.

r334409:
cxgbe(4): Implement ifm_change callback.

r334410:
cxgbe(4): Use ifm for ifmedia just like the rest of the kernel.

No functional change.

r334489:
cxgbe(4): Include full duplex mediaopt in media that can be reported as
active.  Always report full duplex in active media.

r336042:
cxgbe(4): Assume that any unknown flash on the card is 4MB and has 64KB
sectors, instead of refusing to attach to the card.

r340651:
cxgbe(4): Update T4/5/6 firmwares to 1.22.0.3.

r342603:
cxgbe(4): Attach to two T540 variants.

r345083:
cxgbe(4): Update T4/5/6 firmwares to 1.23.0.0.
2019-10-10 23:27:02 +00:00
Navdeep Parhar 34959866ee MFC r318147 (by erj@):
Add several new media types to if_media.h

These include several 25G types (for active direct attach cables and LR modules),
and a missing type for 10G active direct attach.
2019-10-10 20:28:34 +00:00
Martin Matuska 3c2683a217 MFC r316456,352732:
Sync libarchive with vendor.

MFC r316456:
Vendor changes (FreeBSD-related):
  Report which extended attributes could not be restored
  Update archive_read_disk.3 and archive_write_disk.3 manual pages
  Plug memory leaks in xattr tests.

MFC r352732:
Relevant vendor changes:
  Issue #1237: Fix integer overflow in archive_read_support_filter_lz4.c
  PR #1249: Correct some typographical and grammatical errors.
  PR #1250: Minor corrections to the formatting of manual pages
2019-10-09 22:19:48 +00:00
Hans Petter Selasky 3c4311e020 MFC r352556:
Add quirk for XHCI(4) controllers to support USB control transfers
above 1Kbyte.  It might look like some XHCI(4) controllers do not
support when the USB control transfer is split using a link TRB. The
next NORMAL TRB after the link TRB is simply failing with XHCI error
code 4. The quirk ensures we allocate a 64Kbyte buffer so that the
data stage TRB is not broken with a link TRB.

Found at:	EuroBSDcon 2019
Sponsored by:	Mellanox Technologies
2019-10-07 08:25:25 +00:00
Hans Petter Selasky e7dd3ad419 MFC r352555:
Increase the maximum user-space buffer size from 256kBytes to 32MBytes for
libusb. This is useful for speeding up large data transfers while reducing
the interrupt rate.

Found at:	EuroBSDcon 2019
Sponsored by:	Mellanox Technologies
2019-10-07 08:13:49 +00:00
Hans Petter Selasky 57ffd7528d MFC r352554:
The maximum TD size is 31 and not 15.

Found at:	EuroBSDcon 2019
Sponsored by:	Mellanox Technologies
2019-10-07 08:11:12 +00:00
Cy Schubert d3bc527101 MFC r353116:
Add missing definition in DEBUG code.
2019-10-07 04:44:01 +00:00
Cy Schubert e70465f083 MFC r352783:
Fix a typo.
2019-09-30 02:32:51 +00:00
Cy Schubert 820c8f076e MFC r352737:
ipf mistakenly regards UDP packets with a checksum of 0xffff as bad.

Obtained from:	NetBSD fil.c r1.30, NetBSD PR/54443
2019-09-29 03:41:15 +00:00
Dimitry Andric aafb6278fe MFC r352710:
Do not left-shift a negative number (inducing undefined behavior in
C/C++) in exp(3), expf(3), expm1(3) and expm1f(3) during intermediate
computations that compute the IEEE-754 bit pattern for |2**k| for
integer |k|.

The implementations of exp(3), expf(3), expm1(3) and expm1f(3) need to
compute IEEE-754 bit patterns for 2**k in certain places.  (k is an
integer and 2**k is exactly representable in IEEE-754.)

Currently they do things like 0x3FF0'0000+(k<<20), which is to say they
take the bit pattern representing 1 and then add directly to the
exponent field to get the desired power of two.  This is fine when k is
non-negative.

But when k<0 (and certain classes of input trigger this), this
left-shifts a negative number -- an operation with undefined behavior in
C and C++.

The desired semantics can be achieved by instead adding the
possibly-negative k to the IEEE-754 exponent bias to get the desired
exponent field, _then_ shifting that into its proper overall position.

(Note that in case of s_expm1.c and s_expm1f.c, there are SET_HIGH_WORD
and SET_FLOAT_WORD uses further down in each of these files that perform
shift operations involving k, but by these points k's range has been
restricted to 2 < k <= 56, and the shift operations under those
circumstances can't do anything that would be UB.)

Submitted by:	Jeff Walden, https://github.com/jswalden
Obtained from:	https://github.com/freebsd/freebsd/pull/411
Obtained from:	https://github.com/freebsd/freebsd/pull/412
2019-09-28 08:57:29 +00:00
Cy Schubert 3847415966 MFC r351380:
Specifying array sizes for fully initialized tables at compile time is
redundant.
2019-08-25 01:09:31 +00:00
Hans Petter Selasky 4335d2452c MFC r350396:
Add support for tethering with Nokia 7 plus and the alike.

PR:		239495
Sponsored by:	Mellanox Technologies
2019-08-14 09:42:26 +00:00
Xin LI 69d3582519 MFC r350855: Upgrade to Bzip2 version 1.0.8. 2019-08-14 06:41:22 +00:00
Cy Schubert 58a7f68e4a MFC r349927, r349929:
r349927:
  Resolve IPv6 checksum errors with stateful inspection. According to
  PR/203585 this appears to have been broken by r235959, which predates
  the ipfilter 5.1.2 import into FreeBSD.

  The IPv6 checksum calculation is incorrect. To resolve this we call
  in6_cksum() to do the the heavy lifting for us, through a new function
  ipf_pcksum6(). Should we need to revisit this area again, a DTrace probe
  is added to aid with future debugging.

  Plus whitespace adjustments (r348989).

  PR:		203275, 203585
  Differential Revision:	https://reviews.freebsd.org/D20583

r349929:
  Move the new ipf_pcksum6() function from ip_fil_freebsd.c to fil.c.
  The reason for this is that ipftest(8), which still works on FreeBSD-11,
  fails to link to it, breaking stable/11 builds.

  ipftest(8) was broken (segfault) sometime during the FreeBSD-12 cycle.
  glebius@ suggested we disable building it until I can get around to
  fixing it. Hence this was not caught in -current.

  The intention is to fix ipftest(8) as it is used by the netbsd-tests
  (imported by ngie@ many moons ago) for regression testing.
2019-07-12 02:14:05 +00:00
Cy Schubert 3eddf40960 MFC r348987, r348989:
Resolve IPv6 checksum errors with stateful inspection. According to
PR/203585 this appears to have been broken by r235959, which predates
the ipfilter 5.1.2 import into FreeBSD.

The IPv6 checksum calculation is incorrect. To resolve this we call
in6_cksum() to do the the heavy lifting for us, through a new function
ipf_pcksum6(). Should we need to revisit this area again, a DTrace probe
is added to aid with future debugging.

Plus whitespace adjustments (r348989).

PR:		203275, 203585
Differential Revision:	https://reviews.freebsd.org/D20583
2019-07-12 00:50:33 +00:00
Cy Schubert e11f098796 MFC 349843:
Update frtuc struct comments. It not only defines TCP things we are
interested in but also UDP.

While at it document the source and destination port variables.
2019-07-11 00:44:09 +00:00
Cy Schubert 505dd01bd3 MFC r349842:
Correct the description for the low port in the port compare struct.

Adjust the high port description to match that of the low port
description.
2019-07-11 00:38:10 +00:00
Martin Matuska fa709acf62 MFC r349527,349538:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1217: RAR5 reader - fix ARM filter going beyond window buffer boundary
            (OSS-Fuzz 15431)
  PR #1218: Fixes to sparse file handling
2019-07-11 00:22:10 +00:00
Cy Schubert 16c89808ad MFC r349503-349504:
Document the -B, binary logfile, and the -C config file options.
Reference the ipmon.5 man page and ipmon.conf.

PR:		238816
2019-07-05 04:24:09 +00:00
Xin LI c09ed60d59 MFC r349505: Upgrade to Bzip2 version 1.0.7. 2019-07-04 07:36:09 +00:00
Hans Petter Selasky ccecdbb860 MFC r349409 and r349410:
Fix support for LIBUSB_HOTPLUG_ENUMERATE in libusb. Currently all
devices are enumerated regardless of of the LIBUSB_HOTPLUG_ENUMERATE
flag. Make sure when the flag is not specified no arrival events are
generated for currently enumerated devices.

Sponsored by:	Mellanox Technologies
2019-07-03 18:26:07 +00:00
Hans Petter Selasky af463d4604 MFC r349370:
Fix parsing of corrupt data in usbdump(8). Check that the transfer
type array lookup is within bounds to avoid segfault.

PR:		238801
Sponsored by:	Mellanox Technologies
2019-07-03 18:19:29 +00:00
Cy Schubert a40f4ba780 MFC r349448:
Fix a typo.

PR/238816 initially addressed updates to usage() however it has now
become a shopping list of fixes to ipmon man pages and usage().

PR:		238816
2019-07-03 18:11:22 +00:00
Martin Matuska dcb89611eb MFC r348993,349135:
Sync libarchive with vendor including security fixes

r348993:
  - version bumped to 3.4.0
  - check_symlinks_fsobj() without chdir() and fchdir()
  - bsdtar.1 manpage fixes
  - patches from OpenBSD to libarchive_fe/passphrase.c

r349135:
  PR #1212: RAR5 reader - window_mask was not updated correctly
            (OSS-Fuzz 15278)
  OSS-Fuzz 15120: RAR reader - extend use after free bugfix
2019-06-28 22:36:27 +00:00
Greg Lehey a8a6dc7af6 Correct Konrad Zuse's year of birth. 2019-06-22 23:36:28 +00:00
Hans Petter Selasky 092b6c4b7b MFC r348797:
Fix for reading the configuration descriptor in libusb. Catch invalid
configuration descriptor reads early on to avoid issues with devices
that don't check for a valid USB configuration read request.

Submitted by:	[email protected]
PR:		238412
2019-06-11 08:53:26 +00:00
Hans Petter Selasky 6f8b402c4f MFC r348631:
In usb(4) fix a lost completion event issue towards libusb(3). It may happen
if a USB transfer is cancelled that we need to fake a completion event.
Implement missing support in ugen_fs_copy_out() to handle this.

This fixes issues with webcamd(8) and firefox.

Sponsored by:	Mellanox Technologies
2019-06-10 13:37:38 +00:00
Hans Petter Selasky c0717d46d7 MFC r348604:
In xhci(4) there is no stream ID in the completion TRB.
Instead iterate all the stream IDs in stream mode to find
the matching USB transfer.

Sponsored by:	Mellanox Technologies
2019-06-10 13:17:39 +00:00
Hans Petter Selasky acb37d6a4b MFC r348603:
Make sure the DMA tags get freed in mlx5en(4).

Sponsored by:	Mellanox Technologies
2019-06-09 08:22:38 +00:00
Martin Matuska 0498a411d0 MFC r347990:
Sync libarchive with vendor.

Relevant vendor changes:
  Issue #795: XAR - do not try to add xattrs without an allocated name
  PR #812: non-recursive option for extract and list
  PR #958: support reading metadata from compressed files
  PR #999: add --exclude-vcs option to bsdtar
  Issue #1062: treat empty archives with a GNU volume header as valid
  PR #1074: Handle ZIP files with trailing 0s in the extra fields
            (Android APK archives)
  PR #1109: Ignore padding in Zip extra field data (Android APK archives)
  PR #1167: fix problems related to unreadable directories
  Issue #1168: fix handling of strtol() and strtoul()
  PR #1172: RAR5 - fix invalid window buffer read in E8E9 filter
  PR #1174: ZIP reader - fix of MSZIP signature parsing
  PR #1175: gzip filter - fix reading files larger than 4GB from memory
  PR #1177: gzip filter - fix memory leak with repeated header reads
  PR #1180: ZIP reader - add support for Info-ZIP Unicode Path Extra Field
  PR #1181: RAR5 - fix merge_block() recursion
            (OSS-Fuzz 12999, 13029, 13144, 13478, 13490)
  PR #1183: fix memory leak when decompressing ZIP files with LZMA
  PR #1184: fix RAR5 OSS-Fuzz issues 12466, 14490, 14491, 12817
    OSS-Fuzz 12466: RAR5 - fix buffer overflow when parsing huffman tables
    OSS-Fuzz 14490, 14491: RAR5 - fix bad shift-left operations
    OSS-Fuzz 12817: RAR5 - handle a case with truncated huffman tables
  PR #1186: RAR5 - fix invalid type used for dictionary size mask
            (OSS-Fuzz 14537)
  PR #1187: RAR5 - fix integer overflow (OSS-Fuzz 14555)
  PR #1190: RAR5 - RAR5 don't try to unpack entries marked as directories
            (OSS-Fuzz 14574)
  PR #1196: RAR5 - fix a potential SIGSEGV on 32-bit builds
  OSS-Fuzz 2582: RAR - fix use after free if there is an invalid entry
  OSS-Fuzz 14331: RAR5 - fix maximum owner name length
  OSS-Fuzz 13965: RAR5 - use unsigned int for volume number + range check

  Additional RAR5 reader changes:
    - support symlinks, hardlinks, file owner, file group, versioned files
    - change ARCHIVE_FORMAT_RAR_V5 to 0x100000
    - set correct mode for readonly directories
    - support readonly, hidden and system Windows file attributes

MFC r347999:
Install missing data file for
lib.libarchive.functional_test.test_read_format_zip_utf8_paths
2019-06-04 10:36:26 +00:00
David E. O'Brien b332f01285 MF11 r347561.
MFC r344085: Note that readpassphrase() came into FreeBSD's libc at 4.6.
2019-05-14 04:34:58 +00:00
Cy Schubert 071bcb5eb1 MFC r347234:
Improve the legibility of the login.access.5 man page by separating
each argument into its own paragraph.
2019-05-10 01:02:07 +00:00
Rick Macklem a9e05705d2 MFC: r346856
Add #ifdef INET6 around declaration of nbuf.

It was reported that without #ifdef INET6 around the declaration of "nbuf",
a build would report an unused variable. For some reason, I didn't see that
warning when I did a build, but it seems reasonable to add these #ifdef INET6's.
2019-05-06 03:20:02 +00:00
Rick Macklem e83bd0f7db MFC: r346365
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.
2019-05-03 02:30:01 +00:00
Rick Macklem 4e51f5cf05 MFC: r346709
Add support to nfsdumpstate for printing of INET6 addresses for locks.

r346190 added support for printing of INET6 addresses for the "-o" option
(all opens) but missed adding support for INET6 addresses for the "-l" option.
This patch adds that support.
2019-05-02 01:17:55 +00:00
Cy Schubert 26efe89f15 MFC r346804:
Left justify a function header brace as it should be.
No functional change.
2019-05-01 01:49:33 +00:00
Rick Macklem 00b96936cc MFC: r346191
Add support for INET6 addresses to the kernel code that dumps open/lock state.

PR#223036 reported that INET6 callback addresses were not printed by
nfsdumpstate(8). This kernel patch adds INET6 addresses to the dump structure,
so that nfsdumpstate(8) can print them out, post-r346190.
2019-04-27 02:43:27 +00:00
Rick Macklem 2dbf196972 MFC: r346190
Fix nfsdumpstate(8) so that it can print out INET6 callback addresses.

The patch adds support for printing of INET6 callback addresses.
It also adds the #ifdef INET, INET6 as requested by bz@.
2019-04-27 02:34:10 +00:00
Hans Petter Selasky 1548c9782a MFC r346229 and r346248:
Fix spelling and remove superfluous USB keyword.

Submitted by:		Dmitry Luhtionov <[email protected]>
Sponsored by:		Mellanox Technologies
2019-04-25 12:02:17 +00:00
Rick Macklem bb226a3f18 Fix Makefile after r346467 merged incorrect include file. 2019-04-21 14:45:18 +00:00
Rick Macklem 7d8f4816b4 MFC: r345995
Delete the BUGS entry related to failing when jails are enabled.

r345994 has finally fixed the bug that caused the nfsuserd(8) daemon to
fail when jails were enabled, so delete the BUGS entry from the man page.
2019-04-21 01:33:13 +00:00
Rick Macklem 3baad40425 MFC: r345994
Fix nfsuserd so that it handles the mapped localhost address when jails
are enabled.

The nfsuserd(8) daemon does not function correctly when jails are enabled,
since localhost gets mapped to another IP address and, as such, the upcall
RPC fails.
This patch fixes the problem by doing a getsockname(2) of a socket mapped
to localhost to find out what the correct address is for the comparison
test with the upcall's from IP address.
This patch also adds INET6 support and the required #ifdef's for INET and
INET6. It now uses INET6 by default for the upcalls, if the kernel has
INET6 support and the daemon is also built with INET6 support.
2019-04-21 01:25:27 +00:00
Rick Macklem c9da36eabe MFC: r345992, r346087
Add INET6 support for the upcalls to the nfsuserd daemon.

The kernel code uses UDP to do upcalls to the nfsuserd(8) daemon to get
updates to the username<->uid and groupname<->gid mappings.
A change to AF_LOCAL last year had to be reverted, since it could result
in vnode locking issues on the AF_LOCAL socket.
This patch adds INET6 support and the required #ifdef INET and INET6
to the code.
2019-04-21 01:15:54 +00:00
Rick Macklem d01e313d98 MFC: r345866
Fix malloc stats for the RPCSEC_GSS server code when DEBUG is enabled.

The code enabled when "DEBUG" is defined uses mem_alloc(), which is a
malloc(.., M_RPC, M_WAITOK | M_ZERO), but then calls gss_release_buffer()
which does a free(.., M_GSSAPI) to free the memory.
This patch fixes the problem by replacing mem_alloc() with a
malloc(.., M_GSSAPI, M_WAITOK | M_ZERO).
This bug affects almost no one, since the sources are not normally built
with "DEBUG" defined.
2019-04-18 02:54:07 +00:00
Rick Macklem 4c7926670d MFC: r345818, r345828
Fix a race in the RPCSEC_GSS server code that caused crashes.

When a new client structure was allocated, it was added to the list
so that it was visible to other threads before the expiry time was
initialized, with only a single reference count.
The caller would increment the reference count, but it was possible
for another thread to decrement the reference count to zero and free
the structure before the caller incremented the reference count.
This could occur because the expiry time was still set to zero when
the new client structure was inserted in the list and the list was
unlocked.

This patch fixes the race by initializing the reference count to two
and initializing all fields, including the expiry time, before inserting
it in the list.
2019-04-16 02:48:04 +00:00
Martin Matuska 23980249b8 MFC r345497:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1153: fixed 2 bugs in ZIP reader [1]
  PR #1143: ensure archive_read_disk_entry_from_file() uses ARCHIVE_READ_DISK
  Changes to file flags code, support more file flags on FreeBSD:
    UF_OFFLINE, UF_READONLY, UF_SPARSE, UF_REPARSE, UF_SYSTEM
    UF_ARCHIVE is not supported by intention (yet)

PR:		236300 [1]
2019-04-10 21:46:28 +00:00
Hans Petter Selasky b67bed9285 MFC r345499:
Change all kernel C-type macros into static inline functions.

The current kernel C-type macros might obscurely hide the fact that
the input argument might be used multiple times.

This breaks code like:
isalpha(*ptr++)

Use static inline functions instead of macros to fix this.

Reviewed by:		kib @
Differential Revision:	https://reviews.freebsd.org/D19694
Sponsored by:		Mellanox Technologies
2019-04-05 11:35:58 +00:00
Mark Johnston cede92bda3 MFC r345359, r345384:
Don't attempt to measure TSC skew when running as a VM guest.

PR:	218452
2019-04-04 02:08:36 +00:00
Ravi Pokala 0b329e2416 MFC r345611:
Teach jedec_dimm(4) to be more forgiving of non-fatal errors.

It looks like some DIMMs claim to have a TSOD, but actually don't. Some
claim they weren't able to change the SPD page, but they did. Neither of
those should be fatal errors.
2019-04-03 06:37:25 +00:00
Andriy Voskoboinyk 035f13e4e2 MFC r345252:
net80211: correct check for SMPS node flags updates

Update node flags when driver supports SMPS, not when it is disabled or
in dynamic mode ((iv_htcaps & HTCAP_SMPS) != 0).

Was checked with RTL8188EE (1T1R), STA mode - 'smps' word should disappear
from 'ifconfig wlan0' output.
2019-04-01 07:54:27 +00:00
Philip Paeps 9fd54ea189 MFC r345524: Import tzdata 2019a 2019-03-29 01:41:51 +00:00
Andriy Voskoboinyk d6194ef4b6 MFC r345318:
lockf(1): return EX_UNAVAILABLE if -n is used and the lock file does not
exist

Apply EX_UNAVAILABLE patch part from PR 170775 to match the documentation.

Was checked with a command from PR 210770:
lockf -n /tmp/doesnotexist echo; echo $?

PR:		210770
2019-03-27 08:55:59 +00:00
Hans Petter Selasky 0d8cb69392 MFC r342961:
snd_uaudio: Add quirks for Edirol UA-25EX in advanced driver mode.

Extend the vendor class USB audio quirk to cover devices without
the USB audio control descriptor.

PR:			234794
Sponsored by:		Mellanox Technologies
2019-03-26 13:53:33 +00:00
Hans Petter Selasky 02211cbd1f MFC r344795:
Fix typos in libusb.

Found by:		Denis Ahrens <[email protected]>
Sponsored by:		Mellanox Technologies
2019-03-26 13:46:47 +00:00
David Bright fbc0ca537e MFC r345009:
Fix a scribbler in the PMS driver.

The ESGL bit was left uninitialized when executing the REPORT LUNS
ioctl. This could allow a zeroed data buffer to be treated as a
scatter/gather list. The firmware would eventually walk past the end
of the data buffer, potentially find what looked like a valid
address/length pair, and write the result to semi-random memory.

Obtained from:  Dell EMC Isilon
Sponsored by:   Dell EMC Isilon
2019-03-25 17:04:33 +00:00
Andriy Voskoboinyk b11e41b9b5 MFC r344748:
Allow to build ifconfig(8) without wireless support

The change removes SIOC[GS]IEEE80211 handling from ifconfig(8)
if WITHOUT_WIRELESS_SUPPORT=yes is set in src.conf(5).

Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D19289
2019-03-15 08:21:11 +00:00
David Bright b2f28855c3 MFC r344470:
Fix several Coverity-detected issues in newsyslog.

- CID 1394815, CID 1305673: Dereference before null check - memory was
  allocated and the allocation checked for NULL with a call to errx()
  if it failed. Code below that was guaranteed that the pointer was
  non-NULL, but there was another check for NULL at the exit of the
  function (after the memory had already been referenced). Eliminate
  the useless NULL check.

- CID 1007452: Resource leak - Storage intended to be allocated and
  returned to the caller was never freed. This was the result of a
  regression in the function signature introduced in r208648 (2010)
  (thanks for that find, @cem!). Fixed by altering the function
  signature and passing the allocated memory to the caller as
  intended. This also fixes PR158794.

- CID 1008620: Logically dead code in newsyslog.c - This was a direct
  result of CID 1007452. Since the memory allocated as described there
  was not returned to the caller, a subsequent check for the memory
  having been allocated was dead code. Returning the memory
  re-animates the code that is the subject of this CID.

- CID 1006131: Unused value - in parsing a configuration file, a
  pointer to the end of the last field was saved, but not used after
  that. Rewrite to use the pointer value. This could have been fixed
  by avoiding the assignment altogether, but this solutions more
  closely follows the pattern used in the preceding code.

PR:             158794
Reported by:    Coverity, Ken-ichi EZURA <[email protected]> (PR158794)

Sponsored by:	Dell EMC Isilon
2019-03-07 13:11:00 +00:00
Andriy Voskoboinyk fa6c92268a MFC r344245:
snmp_hostres(3): fix a typo in sanity checks in handle_chunk()

PR:		204253
Submitted by:	David Binderman <[email protected]>
2019-03-04 03:38:43 +00:00
Andriy Voskoboinyk 65574f271f MFC r344244:
Fix memory / resource leaks in usr.sbin/rpc.ypupdated/update.c

Re-apply r343909 to this file to get the issue fixed.

PR:		204956
Reported by:	David Binderman <[email protected]>
2019-03-04 03:30:39 +00:00
Hans Petter Selasky be3a17ce18 MFC r344477:
Add new USB quirk.

PR:			235897
Sponsored by:		Mellanox Technologies
2019-03-01 08:06:23 +00:00
Martin Matuska 42efdf8868 MFC r344063,r344088:
MFC r344063:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1085: Fix a null pointer dereference bug in zip writer
  PR #1110: ZIP reader added support for XZ, LZMA, PPMD8 and BZIP2
            decopmpression
  PR #1116: Add support for 64-bit ar format
  PR #1120: Fix a 7zip crash [1] and a ISO9660 infinite loop [2]
  PR #1125: RAR5 reader - fix an invalid read and a memory leak
  PR #1131: POSIX reader - do not fail when tree_current_lstat() fails
            due to ENOENT [3]
  PR #1134: Delete unnecessary null pointer checks before calls of free()
  OSS-Fuzz 10843: Force intermediate to uint64_t to make UBSAN happy.
  OSS-Fuzz 11011: Avoid buffer overflow in rar5 reader

MFC r344088:
  archive_read_disk_posix.c: initialize delayed_errno

PR:		233006 [3]
Security:	CVE-2019-1000019 [1], CVE-2019-1000020 [2]
2019-02-28 22:57:09 +00:00
David Bright b82d523565 MFC r344473:
CID 1332000: Logically dead code in sys/dev/pms/RefTisa/tisa/sassata/sas/ini/itdio.c

A pointer is first tested for NULL. If non-NULL, another pointer is
set equal to the first. The second pointer is then checked for NULL
and an error path taken if so. This second test and the associated
path is dead code as the pointer value, having just been checked for
NULL, cannot be NULL at this point. Remove the dead code.

Sponsored by:	Dell EMC Isilon
2019-02-27 22:29:37 +00:00
Andriy Voskoboinyk 9ae23c37e6 MFC r344198:
GC ATA_REQUEST_TIMEOUT option remnants

It was removed from code in r249083 and from sys/conf/options in r249213.

PR:		193935, 222170
2019-02-21 09:54:57 +00:00
David Bright 726c292d34 MFC r344024:
CID 1009492: Logically dead code in sys/cam/scsi/scsi_xpt.c

In `probedone()`, for the `PROBE_REPORT_LUNS` case, all paths that
fall to the bottom of the case set `lp` to `NULL`, so the test for a
non-NULL value of `lp` and call to `free()` if true is dead code as
the test can never be true. Fix by eliminating the whole if
statement. To guard against a possible future change that accidentally
violates this assumption, use a `KASSERT()` to catch if `lp` is
non-NULL.

Sponsored by:	Dell EMC Isilon
2019-02-20 22:49:09 +00:00
Andriy Voskoboinyk 53f5c5a262 MFC r343501:
Add NO_6_BYTE / NO_SYNC_CACHE quirks for (C|D|E).* Olympus digital cameras

PR:		97472
Submitted by:	Fabio Luis Girardi <[email protected]>
Reviewed by:	imp
2019-02-17 02:58:44 +00:00
Andriy Voskoboinyk a658d1b889 MFC r343980:
ifconfig(8): display 802.11n rates correctly for 'roam:rate' parameter
2019-02-16 01:05:22 +00:00
Andriy Voskoboinyk 737bef022c MFC r343909:
newkey(8): fix 'tmpname' memory leak (always) and input file descriptor leak
when output file cannot be opened

PR:		201732
Reported by:	David Binderman <[email protected]>
2019-02-16 00:37:08 +00:00
Hans Petter Selasky f83e5ba607 MFC r343905:
Improve Bluetooth device discovery support for Android and Microsoft devices.

Tested using the virtual_bt_speaker(8) tool from the virtual_oss(8)
project at github.com.

PR:			210089
Sponsored by:		Mellanox Technologies
2019-02-15 09:22:23 +00:00
Cy Schubert 2f0b37465d MFC r343591:
Do not obtain an already held read lock. This causes a witness panic when
ipfs is invoked. This is the second of two panics resolving PR 235110.

PR:		235110
Reported by:	[email protected]
2019-02-14 00:52:03 +00:00
Andriy Voskoboinyk 19b7e9b2eb MFC r343871:
recoverdisk(1): fclose() file supplied via '-r readlist' parameter when
it's no longer needed

PR:		204952
Reported by:	David Binderman <[email protected]>
2019-02-13 09:28:48 +00:00
Andriy Voskoboinyk 75496dd965 MFC r343870:
ipcs(1): drop obsolete error checking

This code is unreachable since r77551.

PR:		201728
2019-02-12 07:03:37 +00:00
Andriy Voskoboinyk 251ef7900d MFC r343698, r343700:
ifconfig(8): display management / multicast wlan(4) rates properly

For 11n / 11ac we are still using non-11n rates for management and
multicast traffic by default; check 'MCS rate' bit to determine how
to print them correctly.

PR:		161035
2019-02-10 20:42:06 +00:00
Andriy Voskoboinyk 5009172724 MFC r343837:
net80211(4): validate supplied roam:rate values from ifconfig(8)
2019-02-10 20:26:12 +00:00
Andriy Voskoboinyk 75988fabe0 MFC r343604:
bwn(4): reuse ieee80211_tx_complete function
2019-02-08 14:32:27 +00:00
Andriy Voskoboinyk a11b7e786b MFC r343603:
ipw(4): reuse ieee80211_tx_complete function

This should partially fix 'netstat -b -I wlan0' output
2019-02-08 13:57:28 +00:00
Hans Petter Selasky c041e9605c MFC r343572:
Add support for Audio Sink and Audio Source profiles to sdpd(8).

This allows user-space programs like virtual_oss(8) to act
as a Bluetooth speaker device.

Sponsored by:		Mellanox Technologies
2019-02-08 10:28:13 +00:00
Andriy Voskoboinyk d848e0f9f0 MFC r343683:
Do not acquire IEEE80211_LOCK twice in cac_timeout(); reuse
locked function instead.

It is externally visible since r257065.
2019-02-08 04:48:12 +00:00
Bryan Drewery ee6d36d2b6 MFC r337272:
Fix some filemon path logging issues.
2019-02-07 23:57:28 +00:00
Bryan Drewery 79973f6364 MFC r343633:
Shar files may be seen as binary by grep.
2019-02-07 21:37:06 +00:00
Andriy Voskoboinyk ffb22e4bfe MFC r343682:
sys/dev/wtap: Check return value from malloc(..., M_NOWAIT) and
drop unneeded cast.
2019-02-06 02:35:56 +00:00
Andriy Voskoboinyk 67741ae5d2 MFC r343681:
run(4): fix allocated memory type for ieee80211_node(4)

PR:		177366
2019-02-06 02:18:11 +00:00
Andriy Voskoboinyk 035ec4b4cd MFC r343574:
Fix compilation with 'option NDISAPI + device ndis' and
without 'device pccard' in the kernel config file.

PR:		171532
Reported by:	Robert Bonomi <[email protected]>
2019-02-06 02:07:37 +00:00
Andriy Voskoboinyk b4274b1660 MFC r343697:
net80211(4): fix rate check when 'roaming' ifconfig(8) option is set to 'auto'

Do not try to clear 'basic rate' bit from roamRate; it cannot be here and,
actually, this operation clears 'MCS rate' bit instead, breaking comparison
for 11n / 11ac modes.
2019-02-06 01:53:01 +00:00
Andriy Voskoboinyk 1016d958e0 MFC r343542:
upgt(4): unbreak build with UPGT_DEBUG
2019-02-06 01:42:26 +00:00
Andriy Voskoboinyk 08bba2c35a MFC r343541:
Drop some unneeded includes from wireless USB drivers.
2019-02-05 03:01:10 +00:00
Andriy Voskoboinyk 719a6c1e73 MFC r343576:
ndiscvt(8): abort if no IDs were found during conversion.

PR:		69268
Submitted by:	<[email protected]>
2019-02-04 03:44:07 +00:00
Cy Schubert adf0e8f860 MFC r343600:
Document the instance context pointer.
2019-02-03 00:36:12 +00:00
Andriy Voskoboinyk ab9314d4a8 MFC r343502:
Remove RADIUS-related files when WITHOUT_RADIUS_SUPPORT=true is set
in src.conf(5)

PR:		234041
2019-02-02 16:57:49 +00:00
Hans Petter Selasky 8da73091b3 MFC r343453:
Add new USB quirk.

PR:			235202
Differential Revision:	https://reviews.freebsd.org/D18917
Sponsored by:		Mellanox Technologies
2019-02-01 10:09:54 +00:00
Andriy Voskoboinyk b5a8d779b9 MFC r343496:
pcf(4): fix parentheses in if condition

PR:		210709
Submitted by:	David Binderman <[email protected]>
2019-02-01 03:26:10 +00:00
Andriy Voskoboinyk 3ea7774c65 MFC r343495:
wlan.4: improve wording

PR:		218075
Submitted by:	Aaron Taylor <[email protected]>
2019-02-01 02:43:13 +00:00
Andriy Voskoboinyk 1ef2c160ee MFC r343473:
geom_uzip(4): move NULL pointer KASSERT check before it is dereferenced

PR:		203499
Submitted by:	<[email protected]>

MFC r343475:
geom_uzip(4): set 'gp != NULL' assertion on top of the function

There was yet another access to this variable in g_trace() few
lines upper.

PR:		203499
Reported by:	cem
2019-01-31 11:36:28 +00:00
Cy Schubert d1ece82051 MFC r343486:
Fix a typo.
2019-01-30 02:39:08 +00:00
Andriy Voskoboinyk 3b390ad105 MFC r343341:
ifconfig: drop unused macros from ifieee80211.c
2019-01-28 00:51:26 +00:00
Marius Strobl 6373632dd0 MFC: r342634 (partial)
o Don't allocate resources for SDMA in sdhci(4) if the controller or the
  front-end doesn't support SDMA or the latter implements a platform-
  specific transfer method instead. While at it, factor out allocation
  and freeing of SDMA resources to sdhci_dma_{alloc,free}() in order to
  keep the code more readable when adding support for ADMA variants.

o Base the size of the SDMA bounce buffer on MAXPHYS up to the maximum
  of 512 KiB instead of using a fixed 4-KiB-buffer. With the default
  MAXPHYS of 128 KiB and depending on the controller and medium, this
  reduces the number of SDHCI interrupts by a factor of ~16 to ~32 on
  sequential reads while an increase of throughput of up to ~84 % was
  seen.

  Front-ends for broken controllers that only support an SDMA buffer
  boundary of a specific size may set SDHCI_QUIRK_BROKEN_SDMA_BOUNDARY
  and supply a size via struct sdhci_slot. According to Linux, only -
  unsupported in stable/10 anyway - Qualcomm MSM-type SDHCI controllers
  are affected by this, though.

  Requested by: Shreyank Amartya (unconditional bump to 512 KiB)

o Introduce a SDHCI_DEPEND macro for specifying the dependency of the
  front-end modules on the sdhci(4) one and bump the module version
  of sdhci(4) to 2 via an also newly introduced SDHCI_VERSION in order
  to ensure that all components are in sync WRT struct sdhci_slot.

o In sdhci(4):
  - Make pointers const were applicable, and
  - replace a few device_printf(9) calls with slot_printf() for
    consistency.
2019-01-27 19:05:18 +00:00
Andriy Voskoboinyk 620c830265 MFC r343190:
net80211: drop m_pullup call from ieee80211_crypto_decap.

For most wireless drivers Rx mbuf is allocated as one
contiguous chunk; only few are using chains for allocations -
but even then at least MCLBYTES (minus Rx descriptor size) is
available in the first mbuf.

In addition to the above, m_pullup was never called here - otherwise,
reallocation will break post-crypto_decap logic (ieee80211_decap,
ieee80211_deliver_data...), so just remove it; length check is left
in case if some truncated frame appears here.

PR:		234241
2019-01-26 12:41:16 +00:00
Cy Schubert b69546edea MFC r343103:
Remove redundant ipfilter version of pcap-bpf.h. As of r214535 it was
no longer needed.
2019-01-23 02:43:49 +00:00
Cy Schubert 5ac1c8e14e MFC r343073:
Remove an IRIX-only source file.
2019-01-23 02:40:29 +00:00
Rodney W. Grimes 78b4ca619f MFC: 325765 (imp) Add notes about overlapping copies.
Add notes to each of these that specifically state that results are
undefined if the strings overlap. In the case of memcpy, we document
the overlapping behavior on FreeBSD (pre-existing). For str*, it is
left unspecified, however, since the default (and x86) implementations
do not handle overlapping strings properly.

PR: 223653
Approved by:	phk (mentor)
2019-01-22 21:52:07 +00:00
Pedro F. Giffuni cbabf0751d MFC r343023:
msun: reduce diff between src/e_j0.c and src/e_j0f.c

PR:	229501
2019-01-21 14:55:10 +00:00
Joerg Wunsch 9caf9f83b8 MFC r342791: fix a typo in chio(4) (which propagates into chio(1)) 2019-01-20 21:49:13 +00:00
Hans Petter Selasky 4170992769 MFC r342884:
Fix loopback traffic when using non-lo0 link local IPv6 addresses.

The loopback interface can only receive packets with a single scope ID,
namely the scope ID of the loopback interface itself. To mitigate this
packets which use the scope ID are appearing as received by the real
network interface, see "origifp" in the patch. The current code would
drop packets which are designated for loopback which use a link-local
scope ID in the destination address or source address, because they
won't match the lo0's scope ID. To fix this restore the network
interface pointer from the scope ID in the destination address for
the problematic cases. See comments added in patch for a more detailed
description.

This issue was introduced with route caching by karels@ .

Reviewed by:		bz (network)
Differential Revision:	https://reviews.freebsd.org/D18769
Sponsored by:		Mellanox Technologies
2019-01-18 08:59:00 +00:00
Hans Petter Selasky 9d1ff4df70 MFC r342778:
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 <[email protected]>
Sponsored by:	Mellanox Technologies
2019-01-18 08:49:10 +00:00
Hans Petter Selasky e264efd0ee MFC r342730:
Improve USB generic debug messages. Print process ID and name when opening
and closing usb/ugenX.Y character device nodes.

Sponsored by:	Mellanox Technologies
2019-01-18 08:45:56 +00:00
Ed Maste e49e325d07 MFC r343043: scp: disallow empty or current directory
Obtained from:	OpenBSD scp.c 1.198
Security:	CVE-2018-20685
Sponsored by:	The FreeBSD Foundation
2019-01-16 15:19:09 +00:00
Andriy Voskoboinyk 7b4a785027 MFC r342966:
net80211: fix possible panic for some drivers after r342465

Check if rate control structures were allocated before trying to
access them in various places; this was possible before on
allocation failure (unlikely), but was revealed after r342211
where allocation was deferred.

The patch was adjusted a bit since file contents are different enough
since r306591.

Also, 'rate_stats' sysctl is not available here, so the panic is
unlikely to happen here even without this patch.
2019-01-15 02:26:03 +00:00
Andriy Voskoboinyk f07b3a7049 MFC r342810:
powerd(8): allow to force a method of battery state query

This change allows to determine power source via sysctl or /dev/apm
when devd(8) is running (used by default).

Based on patch from PR; other changes on top of it:
- '-f' (force) -> '-s' (source) parameter renaming;
- allow 'apm' -> 'devd' transition when '-s devd' is set
(if APM is enabled);
- man page update.

PR:		125707
Submitted by:	Konstantin Stepanov <[email protected]>
Reviewed by:	bcr, imp
Differential Revision:	https://reviews.freebsd.org/D18742
2019-01-13 02:27:10 +00:00
Cy Schubert ca266105b5 MFC r342605:
TCP_PAWS_IDLE is does not exist in NetBSD and illumos. In FreeBSD
TCP_PAWS_IDLE is defined in netinet/tcp_seq.h, however this header
isn't included explicitly or implicitly at this point therefore
as far ipfilter is concerned TCP_PAWS_IDLE is not defined. Remove
the #ifdef and include netinet/tcp.h unconditionally.
2019-01-06 00:32:14 +00:00
Marius Strobl ad1a70e2df MFC: r336610 (partial), r339207, r339267
- Or in the DMA coalescing Rx threshold so the other bits set in E1000_DMACR
  remain intact as intended in igb_init_dmac(). [1]

- Fix igb corrupting checksums with BPF and VLAN
  In stable/11, this merely syncs the code with head as the problem was
  introduced with r311849 in the latter and then fixed by r339207 with
  a different approach than the code used pre-r311849 and in stable/11.

- Use mbuf defines to construct csum offload masks rather than literals

MF11: r340148

Don't use 9k jumbo clusters

Reported by:	Coverity
CID:		1304929 [1]
2019-01-05 19:35:10 +00:00
Hans Petter Selasky 3604972f42 MFC r342549:
Add USB quirk for SPL Crimson Rev 1.

PR:			234380
Sponsored by:		Mellanox Technologies
2019-01-03 09:28:18 +00:00
Hans Petter Selasky ec1fc7a966 MFC r342456:
Fix reading of USB sample rate descriptor for SPL Crimson Rev 1.

Read first one entry, then try to read the full rate descriptor table.

PR:			234380
Sponsored by:		Mellanox Technologies
2019-01-03 09:25:39 +00:00
John Baldwin 50537c971c MFC 341800: Don't report stale signal information in ptrace_lwpinfo.
Once a signal's siginfo was copied to 'td_si' as part of the signal
exchange in issignal(), it was never cleared.  This caused future
thread events that are reported as SIGTRAP events without signal
information to report the stale siginfo in 'td_si'.  For example, if a
debugger created a new process and used SIGSTOP to stop it after
PT_ATTACH, future system call entry / exit events would set PL_FLAG_SI
with the SIGSTOP siginfo in pl_siginfo.  This broke 'catch syscall' in
current versions of gdb as it assumed PL_FLAG_SI with SIGTRAP
indicates a breakpoint or single step trap.
2019-01-02 19:11:49 +00:00
Cy Schubert ebc61fca9b MFC r342596:
Remove duplicate include of sys/mbuf.h.

Reported by:	Trond Endrest <[email protected]>
2019-01-02 15:13:08 +00:00
Philip Paeps 8054b963b8 MFC r342613: Import tzdata 2018h
MFC r342644: Import tzdata 2018i
2019-01-01 10:05:36 +00:00
Cy Schubert c2d6f837a0 MFC r342385:
Remove an empty #if block.

The interesting thing is that looking through Darren's commit logs,
the line containing an extern ppsratecheck() definition was removed
from the v5-1-RELEASE branch but not from HEAD (I have taken his
CVS tree and converted it to GIT). There is a commit adding an
additional #if defined to the empty block. I can only assume that
this was intentional for something later. Looking through HEAD the
extern ppsratecheck() is there. However if we put it back it would
conflict with a static ppsratecheck() definition in fil.c when
building ipftest.

Therefore we remove this empty block.

ppsratecheck() is a function in the FreeBSD kernel. However ipftest
cannot call the ppsratecheck() in the kernel. Therefore one exists in
fil.c for use when building the userland ipftest utility which
approximates the packet filter in userland for testing of ipfilter
rules against packets captured with tcpdump.
2018-12-31 03:53:33 +00:00
Cy Schubert 1ba55d7a2a MFC r342547:
Remove another empty #ifdef block. This empty block also exists in
the upstream HEAD.
2018-12-30 04:42:01 +00:00
Cy Schubert 983d3db147 MFC r342377:
Remove NETBSD_PF. NETBSD_PF is a flag that defines whether the pfil(9)
framework is available. pfil(9) has been in FreeBSD since FreeBSD 5
and according to svn log was first committed to HEAD in 2000, therefore
it is safe to say the check is no longer needed in FreeBSD.

pfil(9) first appeared in NetBSD 1.3 (hence the name NETBSD_PF).
Therefore it is safe to say that it is supported by every NetBSD system
today. The framework also exists in illumos.

As ipfilter code is shared and exchanged between FreeBSD and NetBSD, and
at some point in the future illumos too, and as all three platforms have
pfil(9), the redundant NETBSD_PF #defines and #ifdefs are removed.
2018-12-30 04:37:49 +00:00
Cy Schubert 6f60a5092b MFC r341279:
Clean up a redundant non-redefinition of IFNAMSIZ. IFNAMSIZ
is defined in net/if.h, therefore the condition is never met and
confusing to those who follow.
2018-12-30 04:31:51 +00:00
Cy Schubert 7e9e09ad94 MFC r342374:
Remove the last vestiges of HP/UX from a FreeBSD-only ipfilter
source file.
2018-12-29 03:18:16 +00:00
John Baldwin 6aa2ece36b MFC 340441: Revert r332735 and fix MSI-X to properly fail allocations when full.
The off-by-one errors in 332735 weren't actual errors and were
preventing the last MSI interrupt source from being used.  Instead,
the issue is that when all MSI interrupt sources were allocated, the
loop in msix_alloc() would terminate with 'msi' still set to non-null.
The only check for 'i' overflowing was in the 'msi' == NULL case, so
msix_alloc() would try to reuse the last MSI interrupt source instead
of failing.

Fix by moving the check for all sources being in use to just after the
loop.
2018-12-29 01:19:14 +00:00
Eugene Grosbein 97dfb0e552 MFC r342367: ifconfig.8, lagg.4: fix documentation bug: -use_flowid
needs to be used to force local hash computation and disable usage
of RSS hash provided by driver.

PR:		234242
2018-12-29 00:44:11 +00:00
John Baldwin 7fa305f233 MFC 340304: Use tcp_state_change() in the cxgbe(4) TOE module.
r254889 added tcp_state_change() as a centralized place to log state
changes in TCP connections for DTrace.  r294869 and r296881 took
advantage of this central location to manage per-state counters.
However, TOE sockets were still performing some (but not all) state
change updates via direct assignments to t_state.  This resulted in
state counters underflowing when TOE was in use.  Fix by using
tcp_state_change() when changing a TOE connection's state.
2018-12-29 00:30:17 +00:00
Andrew Rybchenko 81a143a858 MFC r341785
sfxge(4): use n Tx queues instead of n + 2 on EF10 HW

On EF10 HW we can avoid sending packets without checksum offload
or with IP-only checksum offload to dedicated queues. Instead, we
can use option descriptors to change offload policy on any queue
during runtime. Thus, we don't need to create two dedicated queues.

Submitted by:   Ivan Malov <Ivan.Malov at oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18390
2018-12-26 10:39:34 +00:00
Andrew Rybchenko 838575e172 MFC r341784
sfxge(4): prepare the number of Tx queues on event queue 0 to become
variable

The number of Tx queues on event queue 0 can depend on the NIC family
type, and this property will be leveraged by future patches.
This patch prepares the code for this change.

Submitted by:   Ivan Malov <Ivan.Malov at oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18389
2018-12-26 10:38:51 +00:00
Andrew Rybchenko fef0c307de MFC r341783
sfxge(4): report support for Tx checksum op descriptors

FreeBSD driver needs a patch to provide a means for packets
which do not need checksum offload but have flow ID set
to avoid hitting only the first Tx queue (which has been used
for packets not needing checksum offload).

This should be possible on Huntington, Medford or Medford2 chips
since these support toggling checksum offload on any given queue
dynamically by means of pushing option descriptors.

The patch for FreeBSD driver will then need a means to figure out
whether the feature can be used, and testing adapter family might
not be a good solution.

This patch adds a feature bit specifically to indicate support
for checksum option descriptors. The new feature bits may have
more users in future, apart from the mentioned FreeBSD patch.

Submitted by:   Ivan Malov <Ivan.Malov at oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18388
2018-12-26 10:37:06 +00:00
Andrew Rybchenko 0c4b121c97 MFC r341782
sfxge(4): populate per-event queue stats in sysctl

In order to find out why the first event queue and corresponding
interrupt is triggered more frequent, it is useful to know which
events go to each event queue.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18418
2018-12-26 10:35:41 +00:00
Andrew Rybchenko ad4ba7b644 MFC r341327
sfxge(4): rollback last seen VLAN TCI if Tx packet is dropped

Early processing of a packet on transmit may change last seen
VLAN TCI in the queue context. If such a packet is eventually
dropped, last seen VLAN TCI must be set to its previous value.

Submitted by:   Ivan Malov <Ivan.Malov at oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18288
2018-12-26 10:28:43 +00:00
Andrew Rybchenko 962e212aaf MFC r341326
sfxge(4): ensure EvQ poll stops when abort is requested

If an event handler requested an abort, only the inner loop was
guarenteed to be broken out of - the outer loop could continue
if total == batch.

Fix this by poisoning batch to ensure it is different to total.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18287
2018-12-26 10:28:03 +00:00
Andrew Rybchenko 4aeab6620e MFC r341311
sfxge(4): make last byte of module information available

Adjust bounds so the interface supports reading
the last available byte of data.

Submitted by:   Richard Houldsworth <rhouldsworth at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18273
2018-12-26 10:27:24 +00:00
Andrew Rybchenko 13641354ff MFC r341309
sfxge(4): fix MAC Tx stats for less or equal to 64 bytes

This statistic should include 64byte and smaller frames.
Fix EF10 calculation to match Siena code.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18271
2018-12-26 10:26:58 +00:00
Andrew Rybchenko 48c06b3a62 MFC r341302
sfxge(4): fix a typo in unicast filter insertion comment

Submitted by:   Ivan Malov <ivan.malov at oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18264
2018-12-26 10:26:24 +00:00
Andrew Rybchenko d5f0e08d7d MFC r341301
sfxge(4): prevent access to the NIC config before probe

NIC config is initialized during NIC probe.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18263
2018-12-26 10:25:55 +00:00
Andrew Rybchenko 8972fcfb5f MFC r341297
sfxge(4): fix out of bounds read when dereferencing sdup

Introduce and use macro to make sure that MCDI buffers allocated
on stack are rounded up properly.

Submitted by:   Gautam Dawar <gdawar at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18259
2018-12-26 10:25:01 +00:00
Andrew Rybchenko 7c3a5f894d MFC r341295
sfxge(4): avoid usage of too big arrays on stack

Found by PreFAST static analysis.

Submitted by:   Martin Harvey <mharvey at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18257
2018-12-26 10:23:16 +00:00
Andrew Rybchenko 7e6a2ca817 MFC r341290
sfxge(4): check size of memory to read sensors data to

Size of provided memory should be consistent with specified size.

Submitted by:   Martin Harvey <mharvey at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18252
2018-12-26 10:22:49 +00:00
Andrew Rybchenko 963ac8cfe8 MFC r341215
sfxge(4): fix build because of no declaration

Functions declared in mcdi_mon.h are implemented in mcdi_mon.c.
The build fails if compiler options require declaration before
definition.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18246
2018-12-26 10:22:18 +00:00
Andrew Rybchenko 4983a94af2 MFC r341214
sfxge(4): fix SAL annotation for input buffers

Submitted by:   Martin Harvey <mharvey at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18245
2018-12-26 10:21:40 +00:00
Andrew Rybchenko 96fb587c80 MFC r341213
sfxge(4): fix PreFAST warnings because of unused return

Submitted by:   Martin Harvey <mharvey at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18244
2018-12-26 10:20:54 +00:00
Andrew Rybchenko 0642ba031f MFC r341197
sfxge(4): fix comparison always true warning

Loopback type used as bit index has efx_loopback_type_t type
which is enum. clang complains that it is always true when it
is compared with qword (64 bit) bits number boundary.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18228
2018-12-26 10:20:02 +00:00
Andrew Rybchenko 07c38003ff MFC r341038
sfxge(4): add method to make checksum option descriptors

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18160
2018-12-26 10:19:12 +00:00
Andrew Rybchenko bd9534bcaa MFC r340896
sfxge(4): remove Falcon-specific concurrency check

Falcon support has been withdrawn from libefx, however, there is still
an obsolete Falcon-specific assertion that efx_mac_stats_upload()
and efx_port_poll() aren't concurrent. To be consistent with an overall
Falcon support revocation it's desirable to remove it.

Fix debug build invalid assertion failure.

Submitted by:   Ivan Malov <ivan.malov at oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D1813
2018-12-26 10:17:44 +00:00
Andrew Rybchenko b474479251 MFC r340895
sfxge(4): move BIU test code into Siena-specific file

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18129
2018-12-26 10:16:48 +00:00
Andrew Rybchenko cec4c5a491 MFC r340894
sfxge(4): fix PreFAST static analysis warning (C6001)

Fix warning
"C6001: Using uninitialized memory '*sensor_maskp'"
which could occur when the npages argument to efx_mcdi_sensor_info()
is less than or equal to zero.

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18128
2018-12-26 10:16:11 +00:00
Andrew Rybchenko 2558ff2059 MFC r340892
sfxge(4): remove obsolete check for pre-Siena hardware

The fail4 label was used twice, so it doesn't need removing.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18126
2018-12-26 10:15:31 +00:00
Andrew Rybchenko ebad0805d5 MFC r340891
sfxge(4): fix warnings from VS2015 C compiler (C4214)

Fix multiple level 4 warnings
"C4214: nonstandard extension used: bit field types other than int";
no functional changes.

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18125
2018-12-26 10:14:29 +00:00
Andrew Rybchenko 3aab99b512 MFC r340890
sfxge(4): fix warnings from VS2015 C compiler (C4057)

Fix two level 4 warnings
"C4057: 'function': 'const uint8_t *' differs in indirection to
slightly different base types from 'caddr_t'"; no functional changes.

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18124
2018-12-26 10:13:42 +00:00
Andrew Rybchenko 1a7280394b MFC r340889
sfxge(4): fix warnings from VS2015 C compiler (C4189)

Fix multiple level 4 warnings
"C4189: 'xxx': local variable is initialized but not referenced";
no functional changes.

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18123
2018-12-26 10:12:15 +00:00
Andrew Rybchenko 7d08d53c04 MFC r340888
sfxge(4): fix warnings from VS2015 C compiler (C4100)

Fix multiple level 4 warnings
"C4100: 'xxx': unreferenced formal parameter"
no functional changes.

The _NOTE(ARGUNUSED(xxx)) annotations are being exposed to the Visual
Studio 2015 C compiler with the following:

  #define _NOTE_ARGUNUSED(...) UNREFERENCED_PARAMETER((__VA_ARGS__));
  #define _NOTE(_annotation)   _NOTE_ ## _annotation

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18122
2018-12-26 10:09:53 +00:00
Andrew Rybchenko 097d15cf3f MFC r340887
sfxge(4): fix warnings from VS2015 C compiler (C4245)

Fix level 4 warning
"C4245: 'initializing': conversion from 'int' to 'uint32_t',
signed/unsigned mismatch" warning; no functional changes.

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18121
2018-12-26 10:08:28 +00:00
Andrew Rybchenko bf94bf5fe7 MFC r340886
sfxge(4): fix warnings from VS2015 C compiler (C4244)

Fix level 4 warning
"C4244: '+=': conversion from 'unsigned int' to 'uint16_t', possible
loss
of data"; no functional changes.

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18120
2018-12-26 10:07:30 +00:00
Andrew Rybchenko b3a54368d3 MFC r340885
sfxge(4): fix warnings from VS2015 C compiler (C4310)

Fix level 4 warning
"C4310: cast truncates constant value";
no functional changes.

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18119
2018-12-26 10:06:14 +00:00
Andrew Rybchenko 69f0cfcc85 MFC r340884
sfxge(4): fix probes in licensing support

EFSYS_PROBE1 takes one typed value (in addition to the probe name),
whereas EFSYS_PROBE has just the probe name.

Which to use is determined by the probe name - "fail1" probes are
expected to include the function result.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18118
2018-12-26 10:05:36 +00:00
Andrew Rybchenko 58de3f9c0a MFC r340883
sfxge(4): fix diagnostics support build without Siena

The compilation failed because __efx_sram_pattern_fns was used in
efx_nic.c, but defined in efx_sram.c which is only needed when
supporting Siena.

To fix it move all the code using __efx_sram_pattern_fns into
Siena-specific files (except for the definition in efx_sram.c itself,
as that file only needs to be included in Siena-supporting builds
anyway).

The functions to test registers and tables are unlikely to apply to any
new hardware and so can be moved into Siena files. Since Huntington
such tests have been implemented in firmware.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18117
2018-12-26 10:05:03 +00:00
Andrew Rybchenko 7a81bb2f4e MFC r340875
sfxge(4): fix build issue with PHY LED control enabled

Fixed build issue with the EFSYS_OPT_PHY_LED_CONTROL for Huntigton and
Medford.

Submitted by:   Vijay Srivastava <vijays at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18110
2018-12-26 10:03:59 +00:00
Andrew Rybchenko 64fcde015a MFC r340833
sfxge(4): support inner checksum offload on transmit

Inner checksum offloads may be used only if firmware supports
these tunnels.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18102
2018-12-26 10:03:11 +00:00
Andrew Rybchenko 0da289e271 MFC r340831
sfxge(4): make MAC naming consistent with other modules

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18101
2018-12-26 10:02:05 +00:00
Andrew Rybchenko 5790d22011 MFC r340826
sfxge(4): fix ignoring function return value

fix PreFAST issue, add missing annotation that function return value
should not be ignored. Fix alignment.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18096
2018-12-26 10:01:25 +00:00
Andrew Rybchenko 9ba4757e69 MFC r340822
sfxge(4): fix check in NVRAM validate

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18092
2018-12-26 10:00:25 +00:00
Andrew Rybchenko 0ad065b5b6 MFC r340814
sfxge(4): fix result code in MCDI NVRAM update finish

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18084
2018-12-26 09:59:24 +00:00
Andrew Rybchenko edecacbb94 MFC r340806
sfxge(4): fix default RSS context check on Siena

Default RSS context check is carried out during filter
insertion on Siena and it needs to be fixed

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18076
2018-12-26 09:44:08 +00:00
Andrew Rybchenko 6f7399cf02 MFC r340805
sfxge(4): define a handle to denote default RSS context

Make the existing filter-specific define more general.
This is the same as MC_CMD_RSS_CONTEXT_ALLOC_OUT_RSS_CONTEXT_ID_INVALID.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18075
2018-12-26 09:43:38 +00:00
Andrew Rybchenko 4c7f2e8c36 MFC r340804
sfxge(4): insert filters for encapsulated packets

On Medford, with full-featured firmware running, encapsulated
packets may not be delivered unless filters are inserted for
them, as ordinary filters are not applied to encapsulated
packets. So filters for encapsulated packets need to be
inserted for each class of encapsulated packet. For simplicity,
catch-all filters are always inserted. These may match more
packets than the OS has asked for, but trying to insert more
precise filters increases complexity for little gain.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18074
2018-12-26 09:42:40 +00:00
Andrew Rybchenko 638e23108e MFC r340803
sfxge(4): support filters for encapsulated packets

This supports filters which match all unicast or multicast
inner frames in VXLAN, GENEVE, or NVGRE packets.
(Additional fields to match on can be added easily.)

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18073
2018-12-26 09:41:04 +00:00
Andrew Rybchenko ddb451f436 MFC r340802
sfxge(4): use proper MCDI command for encap filters

MC_CMD_FILTER_OP_IN_EXT is needed to set filters for encapsulated
packets.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18072
2018-12-26 09:40:13 +00:00
Andrew Rybchenko 6e353a3094 MFC r340801
sfxge(4): provide information about supported tunnels

VXLAN/NVGRE (and Geneve) support is available on SFN8xxx with
full-feature firmware variant running.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18071
2018-12-26 09:38:50 +00:00
Andrew Rybchenko a477aaa2ea MFC r340800
sfxge(4): let caller know that queue is already flushed

Tx/Rx queue may be already flushed due to Tx/Rx error on the queue or
MC reboot. Caller needs to know that the queue is already flushed to
avoid waiting for flush done event.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18070
2018-12-26 09:37:30 +00:00
Andrew Rybchenko 7e03e9bab8 MFC r340799
sfxge(4): fix error code usage

MCDI results returned in req.emr_rc have already been translated
from MC_CMD_ERR_* to errno names, so using an MC_CMD_ERR_* value
is incorrect.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18069
2018-12-26 09:36:42 +00:00
Andrew Rybchenko 2d35145a6a MFC r340798
sfxge(4): fix out of bounds read in VIs allocation

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18068
2018-12-26 09:34:26 +00:00
Andrew Rybchenko 5c594e3d4b MFC r340767
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>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D8948
2018-12-26 09:33:26 +00:00
Andrew Rybchenko 72e45f14ce MFC r312885
sfxge(4): compact the first hot part of RxQ control

buf_base_id is used on RxQ control operations only and not used on
datapath.

Sponsored by:   Solarflare Communications, Inc.
2018-12-26 09:32:30 +00:00
Andrew Rybchenko 267438dc71 MFC r312884
sfxge(4): fix RxQ structure layout vs usage on datapath

Recent changes in the pseudo header accessor prototypes start to
use common code RxQ handle on datapath. The handle was located
at the end of the structure with members not used on datapath.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D9359
2018-12-26 09:31:36 +00:00
Andrew Rybchenko e43467b116 MFC r312883
sfxge(4): fix invalid VLAN tagging after stop/start

TxQ is destroyed on stop and last used tag should be reset to default 0
on the next start.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D9358
2018-12-26 09:30:53 +00:00
Andrew Rybchenko d4a3959fde MFC r312868
sfxge(4): cleanup: remove unused soft context struct member rxq_cache

Sponsored by:   Solarflare Communications, Inc.
2018-12-26 09:30:06 +00:00
Andrew Rybchenko 11a7d788cd MFC r312867
sfxge(4): cleanup: remvoe trailing tab

Sponsored by:   Solarflare Communications, Inc.
2018-12-26 09:29:26 +00:00
Andrew Rybchenko 380b45e923 MFC r312866
sfxge(4): cleanup: remove unused txq_index TxQ control structure member

Sponsored by:   Solarflare Communications, Inc.
2018-12-26 09:28:40 +00:00
Andriy Voskoboinyk cce13dd81d MFC r342211:
net80211: fix out-of-bounds read in ieee80211_amrr(9)
2018-12-25 14:06:52 +00:00
Martin Matuska 90e1fc4d10 MFC r339746,339751,339794,340866,340939,342042:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1013: Add missing h_base offset when performing absolute seeks in
            xar decompression
  PR #1023: Support extracting extattrs as non-root on non-user-writeable
            files
  PR #1061: Add support for extraction of RAR v5 archives
  PR #1066: Fix out of bounds read on empty string filename for gnutar, pax
            and v7tar
  PR #1067: Fix temporary file path buffer overflow in tests
  IS #1068: Correctly process and verify integer arguments passed to
            bsdcpio and bsdtar
  PR #1070: Don't default XAR entry atime/mtime to the current time
  PR #1080: Spelling fixes
  PR #1084: RAR5 reader bugfixes
  PR #1091: fix use-after-free in delayed newc link processing
  PR #1092: Fix a few obvious resource leaks and strcpy() misuses
  IS #1096: Support extracting ACLs with in-entry comments (GNU tar)
  PR #1102: RAR5 reader - fix big-endian problems
  PR #1105: Fix various crash, memory corruption and infinite loop conditions

  RAR5 reader: FreeBSD build platform fixes for powerpc(64), mips(64),
               sparc64 and riscv64
  RAR5 reader: more maybe-uninitialized size_t fixes for riscv64
               FreeBSD build
2018-12-21 23:33:28 +00:00
Eugene Grosbein 0b8dca6c4c MFC r342071: ng_bpf.4: fix EXAMPLES: do not activate promiscuous mode
PR:	102719
2018-12-17 07:03:36 +00:00
Hans Petter Selasky bc6049b1b7 MFC r334648:
Add support for SIMCom SIM7600E.

PR:		226066
Sponsored by:	MSI/FUNTORO
2018-12-13 10:34:26 +00:00
Cy Schubert a4ad88bfb5 MFC r341650:
Remove an ugly Ultrix hack. Ultrix has been AWOL since the last ice
age, more to come.
2018-12-13 03:12:15 +00:00
Hans Petter Selasky d76c98baef MFC r341585:
mlx5en: Improve configuration of HW LRO.

In order to enable HW LRO, both the "hw_lro" sysctl in the mlx5en(4) config
space must be set, and the ifconfig(8) LRO capability must be set. Any other
settings will disable HW LRO.

Sponsored by:   Mellanox Technologies
2018-12-12 13:14:41 +00:00
Cy Schubert 642c97df2a As part of the general cleanup of the ipfilter code, special cases
are committed separately to document fixing them separately from
the general cleanup. In this case we don't want to hide the utter
brokenness of what is being fixed.

Clean up a discombobulated block of #if's, with one block unreachable.
ip_fil.c is used in ipftest which is used to dry-run test ipfilter
rules in userspace without loading them in the kernel. The call to
(*ifp->if_output) matches that in the FreeBSD kernel.

Further testing and work will be required to make ipftest fully
functional.
2018-12-11 01:49:06 +00:00
Cy Schubert 2d5eded5cf MFC r341377, r341388 (fixup):
Restore handling of PMTU discovery, removed through an unifdef(1)
following the MFV of r254219 into r255332. In addition the 'FreeBSD'
macro was never defined in ipfilter 5.1.2 thus it never would have
been enabled in the first place.

This work is prompted by a general cleanup of the IP Filter code
prompted by working to resolve a PR. More to follow.
2018-12-08 17:50:00 +00:00
Cy Schubert eb5a9c91ba MFC r341384:
Remove IFF_DRVRLOCK as it is used in IRIX only (and we all know IRIX
is dead). This includes collaterally removing code shared by HP/UX,
SGI, and Linux, where IP Filter will in all likelihood for various
reasons never run again.
2018-12-08 17:28:52 +00:00
Cy Schubert 3eee430b0f MFC r341280:
Clean up a rather useless conditional structure member definition.
2018-12-07 21:42:41 +00:00
Andriy Gapon 1b11836f52 MFC r336641: fix incorrect operator in the AUDITPIPE_SET_QLIMIT bounds check
PR:		229983
2018-12-06 13:32:51 +00:00
Cy Schubert c2d78c98c3 MFC r341265:
Remove an old comment/code and replace with a comment that
directly references a NetBSD commit.
2018-12-06 04:28:39 +00:00
Ed Maste 960ea6fb46 MFC r341484: Always treat firmware request and response sizes as unsigned.
This fixes an incomplete bounds check on the guest-supplied request
size where a very large request size could be interpreted as a negative
value and not be caught by the bounds check.

Submitted by:	jhb
Reported by:	Reno Robert
Security:	CVE-2018-17160
2018-12-05 21:51:39 +00:00
Ed Maste c4a517beda MFC r298454 (araujo): Use MIN()/MAX() macros from sys/param.h. 2018-12-05 21:49:39 +00:00
Ed Maste f3a85c82dc MFC r323010: hv_vss.4: Fix spelling of 'responsibility'
PR:		221300
Submitted by:	Fabian Keil
Obtained from:	ElectroBSD
2018-12-04 14:07:45 +00:00
Ed Maste 8e0d96988e MFC r340095: Remove apparently unused 0-byte files that cause grief on Windows
r235274 added a sort regression test (it operates by comparing output
against GNU sort).  The commit included a number of 0-byte files, one
of which ends in a trailing . which reportedly breaks svn/git checkouts
on Windows.

It appears these were added accidentally, so just remove them.

PR:		232479
2018-12-03 02:38:15 +00:00
Cy Schubert 0cd3cb2936 MFC r340868:
An OSF/1 ifdef makes absolutley no sense in a FreeBSD specific source
file.
2018-12-01 18:17:51 +00:00
Cy Schubert 35b92eedc7 MFC r340909:
Combine two lines into one following unifdef for r255332.
2018-12-01 18:09:17 +00:00
Andrew Rybchenko a9119a2df0 MFC r340765
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.
Differential Revision:  https://reviews.freebsd.org/D18024
2018-11-30 10:00:09 +00:00
Cy Schubert e4276ae970 This is a direct commit to the stable/10 branch. This would have been
MFC r340754 except that etc/rc.d has been moved in HEAD which would
have resulted in a tree conflict if merged.

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.
2018-11-30 06:47:01 +00:00
Ed Maste ce76f9b658 MFC r340260: Avoid buffer underwrite in icmp_error
icmp_error allocates either an mbuf (with pkthdr) or a cluster depending
on the size of data to be quoted in the ICMP reply, but the calculation
failed to account for the additional padding that m_align may apply.

Include the ip header in the size passed to m_align.  On 64-bit archs
this will have the net effect of moving everything 4 bytes later in the
mbuf or cluster.  This will result in slightly pessimal alignment for
the ICMP data copy.

Also add an assertion that we do not move m_data before the beginning of
the mbuf or cluster.

Reported by:	A reddit user
Security:	CVE-2018-17156
Sponsored by:	The FreeBSD Foundation
2018-11-29 20:14:09 +00:00
Eugene Grosbein 6dc2319ebe MFC r339818: rcorder(8):
Add support for /etc/rc.resume, so it calls
  "rcorder -k resume" and runs scripts containing "KEYWORD: resume"
  with single "resume" argument.

  Working example is the port sysutils/cpupdate that defines
  extra_commands="resume" to reload CPU microcode cleared
  by suspend/resume sequence.

  This change does nothing for a system having no scripts with
  KEYWORD: resume.

PR:			227866
Differential Revision:	https://reviews.freebsd.org/D15247
2018-11-26 13:36:30 +00:00
Eugene Grosbein 205f3d28db makewhatis: do not try to operate on read-only mounted
directories just to fail later. This is direct commit to stable/10
instead of MFC r339817 due to makewhatis.local being moved
in recent branches.
2018-11-26 13:08:34 +00:00
Eugene Grosbein 40789e9c2b Prevent ip_input() from panicing due to unprotected access
to INADDR_HASH. This is direct commit to stable/10 instead of MFC r339808
due to significant differences in code base.

PR:			220078
Differential Revision:	https://reviews.freebsd.org/D12457
Tested-by:		Cassiano Peixoto and others
2018-11-26 12:47:12 +00:00
Eugene Grosbein 3140654d68 Prevent stf(4) from panicing due to unprotected access
to INADDR_HASH. This is direct commit to stable/10
instead of MFC r339806 due to significant differences
in code base.

PR:			220078
Differential Revision:	https://reviews.freebsd.org/D12457
Tested-by:		Cassiano Peixoto and others
2018-11-26 12:19:30 +00:00
Eugene Grosbein 6b44451479 Prevent multicast code from panicing due to unprotected access
to INADDR_HASH. This is direct commit to stable/10 instead of MFC r339807
due to significant difference in code base.

PR:                   		220078
Tested-by:			Cassiano Peixoto and others
2018-11-26 11:51:44 +00:00
Eugene Grosbein a84cc28ddd MFC r339816: mount_msdosfs
mount_msdosfs: do not fail mounts requiring locale name conversion table
  that is already present in a kernel statically.

  For example, the command "mount_msdosfs -L ru_RU.KOI8-R" fails with error
  "mount_msdosfs: msdosfs_iconv: File exists" for a kernel having
  options LIBICONV and MSDOSFS_ICONV. After this change, it mounts
  successfully.

MFC after:		1 month
Differential Revision:	https://reviews.freebsd.org/D16951
2018-11-26 11:23:01 +00:00
Marius Strobl 650755a803 MFC: r339007, r340543, r340654
- Add ACPI identifier for AMD eMMC 5.0 controller [1]
- Add a quirk handling for AMDI0040 controllers allowing them to do HS400. [2]

Submitted by:	Rajesh Kumar [1], Shreyank Amartya (original version) [2]
2018-11-22 13:18:58 +00:00
Marius Strobl 34451c1412 MFC: r340495
- Restore setting the clock for devices which support the default/legacy
  transfer mode only (lost with r321385). [1]
- Similarly, don't try to set the power class on MMC devices that comply
  to version 4.0 of the system specification but are operated in default/
  legacy transfer or 1-bit bus mode as no power class is specified for
  these cases. Trying to set a power class nevertheless resulted in an -
  albeit harmless - error message.

PR:	231713 [1]
2018-11-21 18:54:38 +00:00
Eugene Grosbein 1f8960de4d Unbreak build after r340671. This is direct commit to stable/10. 2018-11-20 11:19:02 +00:00
Eugene Grosbein 0378a5ee13 MFC r339558: New sysctl: net.inet.icmp.error_keeptags
Currently, icmp_error() function copies FIB number from original packet
  into generated ICMP response but not mbuf_tags(9) chain.
  This prevents us from easily matching ICMP responses corresponding
  to tagged original packets by means of packet filter such as ipfw(8).
  For example, ICMP "time-exceeded in-transit" packets usually generated
  in response to traceroute probes lose tags attached to original packets.

  This change adds new sysctl net.inet.icmp.error_keeptags
  that defaults to 0 to avoid extra overhead when this feature not needed.

  Set net.inet.icmp.error_keeptags=1 to make icmp_error() copy mbuf_tags
  from original packet to generated ICMP response.

PR:		215874
2018-11-20 10:45:46 +00:00
Hans Petter Selasky a8d10cfe8c MFC r340254:
Put a size limit on the opensm.log and use bzip2(1).

Discussed with:		markj@
Sponsored by:		Mellanox Technologies
2018-11-19 09:50:06 +00:00
Eugene Grosbein f6a7609e51 MFC r339472: rc.initdiskless: fix commentary grammar after r339465 2018-11-19 06:52:20 +00:00
Eugene Grosbein 58838efb7f MFC r339465: rc.initdiskless: add support for auxiliary NVRAM.
Currently, rc.inidiskless assumes that local system configuration
  changes are kept in some mountable file system. For example,
  nanobsd uses dedicated partition mounted as /cfg for this.

  However, small embedded devices like MIPS routers may have no enough flash
  space to keep full-blown file system but have only one or couple
  small flash blocks to keep persistent local configuration overrides.

  This change extends rc.initdiskless and introduces ability to run auxiliary
  command /conf/T/M/extract that is supposed to extract configuration overrides
  from such local storage.

  For example, the command /conf/default/etc/extract may contain something like:

  cd "$1" && bsdcpio --quiet -idu < /dev/map/cfg

  bsdcpio command extracts compressed archive from the storage to /etc
  assuming the storage is exposed by the kernel as /dev/map/cfg to userland.

PR:		204215
2018-11-19 06:39:00 +00:00
Rick Macklem 6fb9ebbcde MFC: r339999
Fix NFS client vnode locking to avoid a crash during forced dismount.

A crash was reported where the crash occurred in nfs_advlock() when the
NFS_ISV4(vp) macro was being executed. This was caused by the vnode
being VI_DOOMED due to a forced dismount in progress.
This patch fixes the problem by locking the vnode before executing the
NFS_ISV4() macro.

PR:		232673
2018-11-18 23:48:15 +00:00
Hans Petter Selasky 5dbda28845 MFC r340248:
Don't read the USB audio sync endpoint when we don't use it to save
isochronous bandwidth.

Sponsored by:		Mellanox Technologies
2018-11-11 12:34:19 +00:00
Hans Petter Selasky 6588a8a640 MFC r340212:
Sometimes the complete split packet may be queued too early and the
transaction translator will return a NAK. Ignore this message and
retry the complete split instead.

Sponsored by:		Mellanox Technologies
2018-11-10 10:32:55 +00:00
Hans Petter Selasky 07d8582cf7 MFC r340089:
Use correct type for IOCTL request argument.
This fixes signed IOCTL value warnings in uhsoctl().

Submitted by:		Marcin Cieslak <[email protected]>
Sponsored by:		Mellanox Technologies
2018-11-09 08:47:54 +00:00
Andriy Gapon 26fa3ad3ab MFC r339595: nfsrvd_readdirplus: for some errors, do not fail the entire request
Sponsored by:	Panzura
2018-11-06 14:22:44 +00:00
Wei Hu 1cc32baccb MFC: 339585
r339585:
	Do not drop UDP traffic when TXCSUM_IPV6 flag is on

	PR:		231797
	Submitted by:	whu
	Reviewed by:	dexuan
	Obtained from:	Kevin Morse
	Sponsored by:	Microsoft
2018-10-31 06:24:07 +00:00
Philip Paeps f32e2a16b1 MFC r339848: Import tzdata 2018g 2018-10-31 02:02:41 +00:00
John Baldwin ad984d890f MFC 338408: Don't directly dereference a user pointer in the VPD ioctl.
The PCIOCLISTVPD ioctl on /dev/pci is used to fetch a list of VPD
key-value pairs for a specific PCI function.  It is used by
'pciconf -l -V'.  The list is stored in a userland-supplied buffer as
an array of variable-length structures where the key and data length
are stored in a fixed-size header followed by the variable-length
value as a byte array.  To facilitate walking this array in userland,
<sys/pciio.h> provides a PVE_NEXT() helper macro to return a pointer
to the next array element by reading the the length out of the current
header and using it to compute the address of the next header.

To simplify the implementation, the ioctl handler was also using
PVE_NEXT() when on the user address of the user buffer to compute the
user address of the next array element.  However, the PVE_NEXT() macro
when used with a user address was reading the value's length by
indirecting the user pointer.  The value was ready after the current
record had been copied out to the user buffer, so it appeared to work
on architectures where user addresses are directly dereferencable from
the kernel (all but powerpc and i386 after the 4:4 split).  The recent
enablement of SMAP on amd64 caught this violation however.  To fix,
add a variant of PVE_NEXT() for use in the ioctl handler that takes an
explicit value length.
2018-10-30 21:31:32 +00:00
David C Somayajulu 8948e52b94 MFC r339366
Add support for Error Recovery

Submitted by:[email protected]
2018-10-29 21:31:23 +00:00
David C Somayajulu a14a59e758 MFC r338734
Fixed isses:
  State check before enqueuing transmit task in bxe_link_attn() routine.
  State check before invoking bxe_nic_unload in bxe_shutdown().

Submitted by:[email protected]
2018-10-29 21:14:48 +00:00
Andriy Gapon 5021f0e3c2 MFC r337528: add an option for ddb ps command to print process arguments
Sponsored by:	Panzura
2018-10-29 12:48:30 +00:00
Andriy Gapon 6b024c8d7d MFC r303648: Fix ddb "show proc" to show full arguments
PR:		200052
2018-10-29 12:45:08 +00:00
Hans Petter Selasky 2145b74fa2 MFC r339587:
Added support for formula-based arbitrary baud rates, in contrast to
the current fixed values, which enables use of rates above 1 Mbps.
Improved the detection of HXD chips, and the status flag handling as
well.

Submitted by:		Gabor Simon <[email protected]>
PR:			225932
Differential revision:	https://reviews.freebsd.org/D16639
Sponsored by:		Mellanox Technologies
2018-10-29 12:11:27 +00:00
Hans Petter Selasky a1099aeb91 MFC r339582:
Drop sequencer mutex around uiomove() and make sure we don't move more bytes
than is available, else a panic might happen.

Found by:		Peter Holm <[email protected]>
Sponsored by:		Mellanox Technologies
2018-10-25 14:56:19 +00:00
Hans Petter Selasky f9b6d90406 MFC r339581:
Fix off-by-one which can lead to panics.

Found by:		Peter Holm <[email protected]>
Sponsored by:		Mellanox Technologies
2018-10-25 14:35:52 +00:00
Slava Shwartsman 34f800b271 MFC r339584:
mlx5: Notify user that the ConnectX-6 shutdown its port due to power limitation

If power exceed the slot limit, or slot limit is unknown the ConnectX-6
firmware will shutdown its port.
Inform the user via debug message.

Approved by:    hselasky (mentor), kib (mentor)
Sponsored by:   Mellanox Technologies
2018-10-25 14:12:48 +00:00
Devin Teske 5971f16009 MFC r339509: Fix loader.conf(5) "password" feature
Restore the ability to prevent the user from interrupting the boot process
without first entering the password stored in loader.conf(5).

PR:		kern/207069
Reported by:	[email protected]
Sponsored by:	Smule, Inc.
2018-10-24 23:21:12 +00:00
Eugene Grosbein f904e5688b MFC r339462: make upgrade from previous FreeBSD versions less painful
and make previously working configuration like this work again:

gif_interfaces="gif0"
gifconfig_gif0="1.1.1.1 2.2.2.2"
ifconfig_gif0="inet 192.168.1.1 192.168.1.2 netmask 255.255.255.252"

PR:		204700
2018-10-24 05:15:46 +00:00
Philip Paeps 6a649fdd09 MFC r339503: Import tzdata 2018f 2018-10-23 01:42:43 +00:00
Hans Petter Selasky 76855bdaaf MFC r339388:
Fix for reception of large full speed isochronous frames via the transaction
translator, when using the DWC OTG USB controller driver. Make sure to re-try
getting the complete split packets until a DATA0 packet is received. Larger
isochronous frames may be split into multiple MDATA packets terminated
by a single DATA0 packet.

PR:			230434
Sponsored by:		Mellanox Technologies
2018-10-19 08:40:25 +00:00
Jamie Gritton 7ea86bafa2 MFC r339211:
Fix the test prohibiting jails from sharing IP addresses.

  It's not supposed to be legal for two jails to contain the same IP address,
  unless both jails contain only that one address.  This is the behavior
  documented in jail(8), and is there to prevent confusion when multiple
  jails are listening on IADDR_ANY.

  VIMAGE jails (now the default for GENERIC kernels) test this correctly,
  but non-VIMAGE jails have been performing an incomplete test when nested
  jails are used.
2018-10-17 16:17:56 +00:00
Tai-hwa Liang 83058c00f5 MFC r338200: Adding device ID for Terratec SiXPack 5.1+. 2018-10-10 22:51:45 +00:00
Hans Petter Selasky 2e0467d401 MFC r338993:
When multiple threads are involved receiving completion events in LibUSB
make sure there is always a master polling thread, by setting the "ctx_handler"
field in the context. Else the reception of completion events can stop.
This happens if event threads are created and destroyed during runtime.

Found by:		Ludovic Rousseau <[email protected]>
PR:			231742
Sponsored by:		Mellanox Technologies
2018-10-05 07:50:44 +00:00
Hans Petter Selasky 82101a443a Selectivly backport fix for firmware command hang when switching from
polling-based firmware commands to event based firmware commands.

This is a direct commit.

Linux commit:
a7e1f04905e5b2b90251974dddde781301b6be37

Sponsored by:	Mellanox Technologies
2018-10-02 16:01:33 +00:00
Glen Barber c854065bfa Document EN-18:09 through EN-18:12.
Sponsored by:	The FreeBSD Foundation
2018-10-01 18:15:25 +00:00
Alan Somers c074fc92d2 MFC r337222:
Fix LOCAL_PEERCRED with socketpair(2)

Enable the LOCAL_PEERCRED socket option for unix domain stream sockets
created with socketpair(2). Previously, it only worked with unix domain
stream sockets created with socket(2)/listen(2)/connect(2)/accept(2).

PR:		176419
Reported by:	Nicholas Wilson <[email protected]>
Differential Revision:	https://reviews.freebsd.org/D16350
2018-10-01 18:00:52 +00:00
Alan Somers f01a3952cc MFC r336871, r336874
r336871:
getrusage(2): fix return value under 32-bit emulation

According to the man page, getrusage(2) should return EFAULT if the rusage
argument lies outside of the process's address space. But due to an
oversight in r100384, that's never been the case during 32-bit emulation.
Fix it.

PR:		230153
Reported by:	tests(7)
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D16500

r336874:
freebsd32_getrusage(2): skip freebsd32_rusage_out on error

PR:		230153
Reported by:	kib
X-MFC-With:	336871
Differential Revision:	https://reviews.freebsd.org/D16500
2018-10-01 16:23:00 +00:00
Alan Somers 8ceeb67835 MFC r337973:
Add Modbus Application Protocol to /etc/services

IANA reassigned ports 502 and 802 on 2014-06-10

PR:		213276
Submitted by:	[email protected]
2018-10-01 16:14:38 +00:00
Alan Somers 28b454a277 MFC r338216:
tftpd: Fix data corruption bug with netascii

Transferring files in netascii format requires, among other things,
translating all CR characters to a CR,NUL pair. tftpd does this correctly
except when the CR occurs as the last octet of a packet. In that case, it
erroneously drops the NUL which should be part of the following packet. The
bug was caused by using 0 as a sentinel value in a variable that could
legitimately hold 0. Fix it by switching the sentinel value to -1.

PR:		178055
Reported by:	Richard <[email protected]>
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D16853
2018-10-01 16:11:09 +00:00
Alan Somers 84e8f2d12d MFC r337779:
tftp: Close a resource leak when putting files

Reported by:	Coverity
CID:		1394842
2018-10-01 16:10:27 +00:00
Alan Somers 0f843eba70 MFC r336609:
Fix several Coverity warnings in tftp

Some of the changes are in the libexec/tftpd directory, but to functions that
are only used by tftp(1) (they share some code).

* strcpy => strlcpy (1006793, 1006794, 1006796, 1006741)
* Unchecked return value and TOCTTOU (1009314)
* NULL pointer dereference (1018035, 1018036)

Reported by:	Coverity
CID:		1006793, 1006794, 1006796, 1006741, 1009314, 1018035
CID:		1018036
2018-10-01 16:09:20 +00:00
Alan Somers dc6061b1fc MFC r336605:
Fix multiple Coverity warnings in tftpd(8)

* Initialize uninitialized variable (CID 1006502)
* strcpy => strlcpy (CID 1006792, 1006791, 1006790)
* Check function return values (CID 1009442, 1009441, 1009440)
* Delete dead code in receive_packet (not reported by Coverity)
* Remove redundant alarm(3) in receive_packet (not reported by Coverity)

Reported by:	Coverity
CID: 1006502, 1006792, 1006791, 1006790, 1009442, 1009441, 1009440
Differential Revision:	https://reviews.freebsd.org/D11287
2018-10-01 16:08:27 +00:00
Alan Somers 41ac23b42a MFC r336587:
tftpd(8): when completing an WRQ, flush the file before acknowleding receipt

tftpd(8) should flush a newly written file to disk before ACKing the final DATA
packet.  Otherwise there is a narrow race window when a subsequent read may not
see the file.  This is somewhat related to r330710, but the race window is much
smaller.  Hopefully this will fix the intermittent tests in Jenkins.

Reported by:	Jenkins
2018-10-01 16:07:32 +00:00
Martin Matuska 953200c497 MFC r338827:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1019: Add allocation check for the zip_entry struct
  Oss-Fuzz #10192: Handle whitespace-only ACL fields correctly
2018-09-28 22:02:01 +00:00
John Baldwin b0764fbd2a MFC 337673: Add an overview section to bus_dma.9.
Describe the role of tags and mapping objects as abstractions.
Describe static vs dynamic transaction types and give a brief overview
of the set of functions and object life cycles used for static vs
dynamic.

While here, fix a few other typos and expand a bit on parent tags.
2018-09-28 17:40:06 +00:00
Gordon Tetlow b4d7e0c3ec There are various cases where we modify the inp_vflag and inp_inc.inc_flags
fields during a syscall, but don't restore those fields if the operation
fails.  This can leave the inp structure in an inconsistent state and cause
various problems.

Restore the inp_vflag and inp_inc.inc_flags fields when the underlying
operation fails and the inp could be in an inconsistent state.

This is a direct commit to the branch as the code is different enough in
the other branches to make it difficult to resolve a merge.

Submitted by:	jtl@
Reported by:	Jakub Jirasek, Secunia Research at Flexera
Reviewed by:	jhb@
Approved by:	so
Security:	FreeBSD-EN-18:11.listen
Security:	CVE-2018-6925
2018-09-27 18:48:50 +00:00
Gordon Tetlow cd71228881 MFC r338982.
Clear stack allocated data structure to prevent kernel memory leak.

Reported by:	Thomas Barabosch, Fraunhofer FKIE
Reviewed by:	wes@
Approved by:	so
Security:	FreeBSD-EN-18:12.mem
Security:	CVE-2018-17155
2018-09-27 18:44:40 +00:00
Mark Johnston 060ae3d506 MFC r338724:
Fix an nvpair leak in vdev_geom_read_config().

PR:	230704
2018-09-24 14:50:44 +00:00
Glen Barber 372e64753c MFC r338754:
Update the pkg-stage.sh script used to populate packages on the
 dvd1.iso installation medium from including KDE4 to KDE5, as the
 KDE4-based ports have been marked as deprecated in the Ports
 Collection.

Sponsored by:	The FreeBSD Foundation
2018-09-21 15:58:08 +00:00
Alexander Motin f7e88fa00d MFC r317659, r317752:
Make some UART consoles to not spin wait for data to be sent.

At least with Tx FIFO enabled it shows me ~10% reduction of verbose boot
time with serial console at 115200 baud.
2018-09-19 19:54:13 +00:00
Alexander Motin 9c42b0254f MFC r308750:
Add support for UART found in the Ingenic XBurst system on chips.

These CPUs has non-standard UART enable bit hidden in the UART FIFO
Control Register.
2018-09-19 19:52:53 +00:00
Martin Matuska d5d4b1a5ba MFC r338600:
Update libarchive to 3.3.3

As all important changes have already been merged from libarchive git
this is just a version number bump, documentation update and some
polishing for cpio tests. Other source code changes are not relevant to
FreeBSD.

Relnotes:	yes
2018-09-19 09:41:44 +00:00
Hans Petter Selasky e46a165203 MFC r338679:
Improve LibUSB debugging by simultaneously allowing both function
and transfer prints. Make sure the debug level comes from the
correct USB context.

Found by:		Ludovic Rousseau <[email protected]>
PR:			231264
Sponsored by:		Mellanox Technologies
2018-09-19 08:12:41 +00:00
Hans Petter Selasky fa813063bd MFC r338616:
Fix issues about cancelling USB transfers in LibUSB when the USB device has
been detached. When a USB device has been detached the kernel file handle
stops responding to commands. USB applications which continue to run after
the USB device has been detached, depend on LibUSB generated events to tear
down its pending USB transfers. Add code to handle the needed cleanup when
processing the USB transfer(s) fails and prevent new USB transfer(s) from
being submitted.

Found by:		Ludovic Rousseau <[email protected]>
PR:			231076
Sponsored by:		Mellanox Technologies
2018-09-19 07:57:30 +00:00
Dimitry Andric 16e924a895 MFC r309748 (by glebius):
Treat R_X86_64_PLT32 relocs as R_X86_64_PC32.

If we load a binary that is designed to be a library, it produces
relocatable code via assembler directives in the assembly itself
(rather than compiler options).  This emits R_X86_64_PLT32 relocations,
which are not handled by the kernel linker.

Submitted by:	gallatin
Reviewed by:	kib
PR:		231451
2018-09-18 20:46:55 +00:00
Glen Barber 33619bc9a7 Add xml:id for diff reduction.
Sponsored by:	The FreeBSD Foundation
2018-09-13 15:58:03 +00:00
Glen Barber 00bc3fb79c Document SA-18:12 and EN-18:08.
Sponsored by:	The FreeBSD Foundation
2018-09-13 15:55:22 +00:00
Marius Strobl dbf2356ff6 MFC: r333614, r333647, r338275, r338280, r338513
- Let mmcsd_ioctl() ensure appropriate privileges via priv_check(9).
- If present, take advantage of the R/W cache of eMMC revision 1.5 and
  later devices. These caches work akin to the ones found in HDDs/SSDs
  that ada(4)/da(4) also enable if existent, but likewise increase the
  likelihood of data loss in case of a sudden power outage etc. On the
  other hand, write performance is up to twice as high for e. g. 1 GiB
  files depending on the actual chip and transfer mode employed.
  For maximum data integrity, the usage of eMMC caches can be disabled
  via the hw.mmcsd.cache tunable.
- Get rid of the NOP mmcsd_open().
- Obtain the bus mode (MMC or SD) from the directly superordinated
  bus rather than reaching up to the bridge and use the cached mode
  in mmcsd_delete(), too.
- Use le32dec(9) for decoding EXT_CSD values where it makes sense. [1]
- Locally cache some instance variable values in mmc_discover_cards()
  in order to improve the code readability a bit.

Obtained from:	NetBSD [1]
2018-09-13 10:18:50 +00:00
Marius Strobl ab6d4e884c MFC: r333613
The broken DDR52 support of Intel Bay Trail eMMC controllers rumored
in the commit log of r321385 has been confirmed via the public VLI54
erratum. Thus, stop advertising DDR52 for these controllers.
Note that this change should hardly make a difference in practice as
eMMC chips from the same era as these SoCs most likely support HS200
at least, probably even up to HS400ES.
2018-09-13 09:26:16 +00:00
Marius Strobl f0cc09e106 MFC: r338261, r338512
- According to section 2.2.5 of the SDHCI specification version 4.20,
  SDHCI_TRNS_ACMD12 is to be set only for multiple-block read/write
  commands without data length information, so don't unconditionally
  set this bit. The result matches what e. g. Linux does.
- Section 2.2.19 of the SDHCI specification version 4.20 states that
  SDHCI_ACMD12_ERR should be only valid if SDHCI_INT_ACMD12ERR is set
  and hardware may clear SDHCI_ACMD12_ERR when SDHCI_INT_ACMD12ERR is
  cleared (differing silicon behavior is specifically allowed, though).
  Thus, read SDHCI_ACMD12_ERR before clearing SDHCI_INT_ACMD12ERR.
  While at it, use the 16-bit accessor rather than the 32-bit one for
  reading the 16-bit SDHCI_ACMD12_ERR.
- SDHCI_INT_TUNEERR isn't one of the ROC bits in SDHCI_INT_STATUS so
  clear it explicitly.
- Add missing prototypes and sort them.
- Explicitly compare a pointer to NULL. The __builtin_expect() of clang
  3.4.1 otherwise isn't able to cope with the expression.
2018-09-13 09:20:07 +00:00
Hans Petter Selasky 8138909b15 Fix incorrect display of the sys.class.infiniband.xxx.ports.1.rate sysctl
entry in ibcore by adding support for new rate types.

This is a direct commit.

Sponsored by:	Mellanox Technologies
2018-09-12 10:53:22 +00:00
Gordon Tetlow 87cbcdce06 MFC 338603:
Correct ELF header parsing code to prevent invalid ELF sections from
disclosing memory.

Submitted by:	markj
Reported by:	Thomas Barabosch, Fraunhofer FKIE
Approved by:	so
Security:	FreeBSD-SA-18:12.elf
Security:	CVE-2018-6924
Sponsored by:	The FreeBSD Foundation
2018-09-12 05:03:30 +00:00
Hans Petter Selasky 4ab7c1b3ba MFC r338492:
Add support for receive side scaling stride, RSSS, in mlx5en(4).

The receive side scaling stride parameter is a value which define the interval
between active receive side queues. The traffic for the inactive queues is
redirected to the nearest active queue by use of modulus. The default value
of this parameter is one, which means all receive side queues are used.

The point of this feature is to redirect more traffic to fewer receive side
queues in order to take more advantage of sorted large receive offload,
sorted LRO. The sorted LRO works better when more packets are accumulated
per service interval.

Sponsored by:		Mellanox Technologies
2018-09-10 08:10:52 +00:00
Hans Petter Selasky 978e8e8d67 MFC r338490:
Don't stall transmit queue on drops in mlx5en(4).

When a transmitted packet is dropped don't stall the transmit queue.

Sponsored by:		Mellanox Technologies
2018-09-10 08:06:34 +00:00
Hans Petter Selasky 8fa361e73b MFC r338489:
Maximum number of mbuf frags is off-by-one for worst case scenario in mlx5en(4).

Inspecting the PRM no more than 0x3F data segments, DS, of size 16 bytes is
allowed.

Worst case scenario summary of DS usage:
Header is fixed:	2 DS
Maximum inlining:	98 => (98 - 2) / 16 = 6 DS
Remainder:		0x3F - 2 - 6 = 55 DS (mbuf frags)

Previously a value of 56 DS was used and this would work in the
normal case because not all inline data area was used up.

Sponsored by:		Mellanox Technologies
2018-09-10 08:03:52 +00:00
Eugene Grosbein ff4c6536a0 MFC r316623: fix build after incomplete MFC r338544 by me. 2018-09-09 18:40:30 +00:00
Eugene Grosbein ed53051c8e MFC r316615 by sevan: Remove the last vestiges of FDC_DEBUG & FD_DEBUG
PR:             105608
Submitted by:   Differential Revision:  https://reviews.freebsd.org/D10303
2018-09-09 18:10:35 +00:00
Xin LI e6159bba80 MFC r338126: MFV r338092: ntp 4.2.8p12.
Relnotes:	yes
2018-09-08 04:10:26 +00:00
Marius Strobl 455c3de6d1 MFC: r338304
The read accessors generated by __BUS_ACCESSOR() have the problem that
they don't check the result of BUS_READ_IVAR(9) and silently return stack
garbage on failure in case a bus doesn't implement a particular instance
variable for example. With MMC bridges not providing MMCBR_IVAR_RETUNE_REQ,
yet, this in turn can cause mmc(4) to get into a state in which re-tuning
seems to be necessary but is inappropriate, causing mmc_wait_for_request()
to fail. Thus, don't use __BUS_ACCESSOR() for mmcbr_get_retune_req() and
instead provide a version of the latter which returns retune_req_none if
reading MMCBR_IVAR_RETUNE_REQ fails.
2018-09-05 20:47:51 +00:00
Cy Schubert 574f2635e2 Avoid printing extraneous function names when searching man page
database (apropos, man -k). This commit Replaces .SS with .SH,
similar to the man page provided by original heimdal (as in port).

PR:		230573
Submitted by:	[email protected]
2018-09-05 01:33:30 +00:00
Xin LI 9a22853558 MFC r337522:
In read_zones(), check if the file name actually fit in the buffer
and make sure it would terminate with nul with strlcpy().

Reviewed by:	imp (earlier revision)
Differential Revision:	https://reviews.freebsd.org/D16595
2018-09-03 06:57:25 +00:00
Tai-hwa Liang a18cec31d6 MFC r338038: Extending the delay cycles to give the codec more time to pump ADC data across the AC-link.
Without this patch, some CS4614 cards will need users to reload the driver manually or
the hardware won't be initialised properly. Something like:

	# kldload snd_csa
	# kldunload snd_csa
	# kldload snd_csa

Tested with:	Terratec SiXPack 5.1+
2018-08-26 13:03:58 +00:00
Colin Percival 43428744ac MFC r336420,336433,336593,336621,336622,336624,337394,337401,338141
Teach the EC2 AMI upload code to:
* Mark EBS snapshots as public,
* Announce new AMIs to an SNS topic, and
* Place the SVN branch and revision into the AMI "description".
2018-08-26 05:28:17 +00:00
Eugene Grosbein 8fdef07d56 MFC 338013: bsnmpd(8): fix and optimize interface description processing
* correctly prepare a buffer to obtain interface description from a kernel
  and truncate long description instead of dropping it altogether and
  spamming logs;
* skip calling strlen() for each description and each SNMP request
  for MIB-II/ifXTable's ifAlias.
* teach bsnmpd to allocate memory dynamically for interface descriptions
  to decrease memory usage for common case and not to break
  if long description occurs;

PR:			217763
Reviewed by:		harti and others
Differential Revision:	https://reviews.freebsd.org/D16459
2018-08-25 10:42:44 +00:00
Rick Macklem 588e42f591 MFC: r337438
Allow newnfs_request() to retry all callback RPCs with an NFSERR_DELAY reply.

The code in newnfs_request() retries RPCs that get a reply of NFSERR_DELAY,
but exempts certain NFSv4 operations. However, for callback RPCs, there
should not be any exemptions at this time. The code would have erroneously
exempted the CBRECALL callback, since it has the same operation number as
the CLOSE operation.
This patch fixes this by checking for a callback RPC (indicated by clp != NULL)
and not checking for exempt operations for callbacks.
This would have only affected the NFSv4 server when delegations are enabled
(they are not enabled by default) and the client replies to CBRECALL with
NFSERR_DELAY. This may never actually happen.
Spotted during code inspection.
2018-08-24 22:48:19 +00:00
Kyle Evans f93a0104ee MFC r338120: config(8): Allow escape-quoted empty strings
For use with things like BOOT_TAG=\"\" -- there are valid reasons to allow
empty strings, especially as these are usually being passed through as
options. The same argument could perhaps be made for the unquoted
variant in things like MODULES_OVERRIDE="", but it's not immediately clear
that this is an issue so I've left it untouched.
2018-08-23 02:20:09 +00:00
Pedro F. Giffuni 60b1eff86c MFC r337456:
msdosfs: fixes for Undefined Behavior.

These were found by the Undefined Behaviour GsoC project at NetBSD:

Do not change signedness bit with left shift.
While there avoid signed integer overflow.
Address both issues with using unsigned type.

msdosfs_fat.c:512:42, left shift of 1 by 31 places cannot be represented
in type 'int'
msdosfs_fat.c:521:44, left shift of 1 by 31 places cannot be represented
in type 'int'
msdosfs_fat.c:744:14, left shift of 1 by 31 places cannot be represented
in type 'int'
msdosfs_fat.c:744:24, signed integer overflow: -2147483648 - 1 cannot be
represented in type 'int [20]'
msdosfs_fat.c:840:13, left shift of 1 by 31 places cannot be represented
in type 'int'
msdosfs_fat.c:840:36, signed integer overflow: -2147483648 - 1 cannot be
represented in type 'int [20]'

Detected with micro-UBSan in the user mode.

Hinted from:	NetBSD (CVS 1.33)
2018-08-22 04:21:25 +00:00
Cy Schubert e831dfec4e MFC r338047:
The bucket index is subtracted by one at lines 2304 and 2314.  When 0 it
becomes -1, except these are unsigned integers, so they become very large
numbers. Thus are always larger than the maximum bucket; the hash table
insertion fails causing NAT to fail.

This commit ensures that if the index is already zero it is not reduced
prior to insertion into the hash table.

PR:		208566
2018-08-22 01:43:11 +00:00
Cy Schubert fb4264f920 MFC r338046:
Add handy DTrace probes useful in diagnosing NAT issues. DTrace probes
are situated next to error counters and/or in one instance prior to the
-1 return from various functions. This was useful in diagnosis of
PR/208566 and will be handy in the future diagnosing NAT failures.

PR:		208566
2018-08-22 01:23:11 +00:00
Cy Schubert 7d8841d5f3 MFC r338045:
Expose np (nat_t - an entry in the nat table structure) in the DTrace
probe when nat fails (label badnat). This is useful in diagnosing
failed NAT issues and was used in PR/208566.

PR:		208566
2018-08-22 01:04:52 +00:00
Rick Macklem 33fd806aa3 MFC: r336839
Modify the NFSv4.1 server so that it allows ReclaimComplete as done by ESXi 6.7.

I believe that a ReclaimComplete with rca_one_fs == TRUE is only
to be used after a file system has been transferred to a different
file server.  However, RFC5661 is somewhat vague w.r.t. this and
the ESXi 6.7 client does both a ReclaimComplete with rca_one_fs == TRUE
and one with ReclaimComplete with rca_one_fs == FALSE.
Therefore, just ignore the rca_one_fs == TRUE operation and return
NFS_OK without doing anything instead of replying NFS4ERR_NOTSUPP.
This allows the ESXi 6.7 NFSv4.1 client to do a mount.
After discussion on the NFSv4 IETF working group mailing list, doing this
along with setting a flag to note that a ReclaimComplete with rca_one_fs TRUE
was an appropriate way to handle this.
The flag that indicates that a ReclaimComplete with rca_one_fs == TRUE was
done may be used to disable replies of NFS4ERR_GRACE for non-reclaim
state operations in a future commit.

This patch along with r332790, r334492 and r336357 allow ESXi 6.7 NFSv4.1 mounts
work ok. ESX 6.5 NFSv4.1 mounts do not work well, due to what I believe are
violations of RFC-5661 and should not be used.
2018-08-21 11:17:25 +00:00
Cy Schubert 64a996bf49 MFC r337410:
Remove redundant and incorrect default definition of AF_INET6. AF_INET6
is defined in sys/socket.h where it's defined as 28.

A bit of trivia: On NetBSD AF_INET6 is defined as 24. On Solaris it is
defined as 26. This is probably why Darren defaulted to 26, because
ipfilter was originally written for SunOS 4 and Solaris many moons ago.
2018-08-21 00:37:48 +00:00
Kristof Provost 8e38082d37 MFC r337969:
pf: Limit the maximum number of fragments per packet

Similar to the network stack issue fixed in r337782 pf did not limit the number
of fragments per packet, which could be exploited to generate high CPU loads
with a crafted series of packets.

Limit each packet to no more than 64 fragments. This should be sufficient on
typical networks to allow maximum-sized IP frames.

This addresses the issue for both IPv4 and IPv6.

Security:	CVE-2018-5391
Sponsored by:	Klara Systems
2018-08-20 15:43:08 +00:00
Jamie Gritton ac75e04c89 MFC r337867:
Don't let clobber jailparam values when checking for modification of
  init-only parameters.

PR:		230487
Submitted by:	Jason Mader
2018-08-20 05:32:42 +00:00
Martin Matuska 3c36cfaa42 MFH r337745:
Sync libarchive with vendor..

Vendor changes:
  PR #1042: validate iso9660 directory record length

MFC after:	3 days
Security:	CVE-2017-14501
2018-08-18 23:24:53 +00:00
Dimitry Andric dd2e215ca9 MFC r337322:
Fix build of hyperv with base gcc on i386

Summary:
Base gcc fails to compile `sys/dev/hyperv/pcib/vmbus_pcib.c` for i386,
with the following -Werror warnings:

cc1: warnings being treated as errors
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'new_pcichild_device':
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:567: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'vmbus_pcib_on_channel_callback':
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:940: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'hv_pci_protocol_negotiation':
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1012: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'hv_pci_enter_d0':
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1073: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'hv_send_resources_allocated':
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1125: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c: In function 'vmbus_pcib_map_msi':
/usr/src/sys/dev/hyperv/pcib/vmbus_pcib.c:1730: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

This is because on i386, several casts from `uint64_t` to a pointer
reduce the value from 64 bit to 32 bit.

For gcc, this can be fixed by an intermediate cast to uintptr_t. Note
that I am assuming the incoming values will always fit into 32 bit!

Differential Revision: https://reviews.freebsd.org/D15753
2018-08-17 06:31:30 +00:00
Cy Schubert 0c8a0839c6 MFC r337558, r337560
r337558:
Identify the return value (rval) that led to the IPv4 NAT failure
in ipf_nat_checkout() and report it in the frb_natv4out and frb_natv4in
dtrace probes.

This is currently being used to diagnose NAT failures in PR/208566. It's
rather handy so this commit makes it available for future diagnosis and
debugging efforts.

PR:		208566

r337560:
Correct a comment. Should have been detected by ipf_nat_in() not
ipf_nat_out().
2018-08-17 02:46:36 +00:00
Brooks Davis 8119a2aadb MFC r337727 (rewritten due to unmerged API change in 11+):
Copy out from kernel to data, not the other way around.

Sponsored by:	DARPA, AFRL
2018-08-16 15:54:12 +00:00
Glen Barber 67e9ce9e67 Document SA-18:09 through SA-18:11.
Sponsored by:	The FreeBSD Foundation
2018-08-16 15:32:17 +00:00
Glen Barber b71152f3a5 MFC r337717, r337718:
r337717:
  Add lang/python2, lang/python3, and lang/python to GCE images
  to help avoid hard-coding 'python<MAJOR>.<MINOR>' in several
  scripts in the client-side scripts. [1]

 r337718:
  Add a space between a variable and escaped new line.

PR:		230248 [1]
Sponsored by:	The FreeBSD Foundation
2018-08-16 15:17:22 +00:00
Jamie Gritton 049a188eb5 Load filesystem modules associated with allow.mount permissions.
PR:		192092
2018-08-15 22:32:55 +00:00
Jamie Gritton 577070645f MFC r331332:
If a jail parameter isn't found, try loading a related kernel module.

PR:		192092
2018-08-15 21:38:44 +00:00
Xin LI 4e118cfb10 Fix unauthenticated EAPOL-Key decryption vulnerability. [SA-18:11.hostapd]
Approved by:	so
2018-08-15 05:05:02 +00:00
Brooks Davis b76f85cf57 MFC r337508:
Terminate filter_create_ext() args with NULL, not 0.

filter_create_ext() is documented to take a NULL terminated set of
arguments.  0 is promoted to an int so this would fail on 64-bit
systems if the value was not passed in a register.  On all currently
supported 64-bit architectures it is.

Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
2018-08-14 16:25:09 +00:00
Mark Johnston 4cf3aa1f8a MFC r337426:
ifconfig: Fix use of _Noreturn.
2018-08-14 14:19:57 +00:00
Hans Petter Selasky fbd0a063fa Bump the mlx5core, mlx5en(4) and mlx5ib driver version.
This is a direct commit.

Sponsored by:	Mellanox Technologies
2018-08-14 11:52:05 +00:00
Hans Petter Selasky 111c9625bf MFC r330657:
Use vport rather than physical-port MTU in mlx5en(4).

Set and report vport MTU rather than physical MTU,
The driver will set both vport and physical port mtu
and will rely on the query of vport mtu.

SRIOV VFs have to report their MTU to their vport manager (PF),
and this will allow them to work with any MTU they need
without failing the request.

Also for some cases where the PF is not a port owner, PF can
work with MTU less than the physical port mtu if set physical
port mtu didn't take effect.

Based on Linux upstream commit:
cd255efff9baadd654d6160e52d17ae7c568c9d3

Submitted by:	Meny Yossefi <[email protected]>
Sponsored by:	Mellanox Technologies
2018-08-14 11:44:11 +00:00
Hans Petter Selasky 1f5e866b6e MFC r325661:
Expose the current hardware MTU in mlx5en(4) as a separate entry
in the sysctl tree.

Sponsored by:	Mellanox Technologies
2018-08-14 11:43:02 +00:00
Hans Petter Selasky 8109745120 Enter error state when handling bad device in mlx5core and add checks
for error state to mlx5en(4) to make live migration work.

This is a direct commit.

Sponsored by:	Mellanox Technologies
2018-08-14 11:24:14 +00:00
Hans Petter Selasky bcbdf5d092 MFC r336450:
Do not inline transmit headers and use HW VLAN tagging if supported by mlx5en(4).

Query the minimal inline mode supported by the card.
When creating a send queue, cache the queried mode and optimize the transmit
if no inlining is required.  In this case, we can avoid touching the headers
cache line and avoid dirtying several more lines by copying headers into
the send WQEs.  Also, if no inline headers are used, hardware assists in
the VLAN tag framing.

Submitted by:	kib@, slavash@
Sponsored by:	Mellanox Technologies
2018-08-14 11:19:04 +00:00
Hans Petter Selasky 5b953b71be MFC r336407:
Handle jumbo frames without requiring big clusters in mlx5en(4).

The scatter list is formed by the chunks of MCLBYTES each, and larger
than default packets are returned to the stack as the mbuf chain.

Submitted by:	kib@
Sponsored by:	Mellanox Technologies
2018-08-14 11:15:05 +00:00
Kyle Evans 18d9146d7e MFC r322325: cat: fix build with -DNO_UDOM_SUPPORT
PR:		230489
2018-08-14 01:57:11 +00:00
Glen Barber 18ce870b09 MFC r337555, r337556:
r337555:
  Update and replace old rc daemons for GCE images.

 r337556:
  Invoke the growfs rc script for each boot on GCE.

PR:		229000, 230275
Sponsored by:	The FreeBSD Foundation
2018-08-13 14:24:00 +00:00
Xin LI 127f5d540e Remove mention of FreeBSD 9.x which is EoL'ed now. 2018-08-12 21:43:59 +00:00
Devin Teske 0e744365e9 MFC SVN r336350: Send sysrc(8) error message to stderr (not stdout)
PR:		bin/229806
Reported by:	Andreas Sommer <[email protected]>
Sponsored by:	Smule, Inc.
2018-08-10 20:07:59 +00:00
David C Somayajulu 0a7a797728 MFC r336695
Remove support for QLNX_RCV_IN_TASKQ - i.e., Rx only in TaskQ.
Added support for LLDP passthru
Upgrade ECORE to version 8.33.5.0
Upgrade STORMFW to version 8.33.7.0
2018-08-09 01:39:47 +00:00
David C Somayajulu 125e576f89 MFC r336680
Update man page with support for 41000 Series adapters
2018-08-09 01:05:25 +00:00
David C Somayajulu d160ad4523 MFC r336438
Fixes for  the following issues:
1. Fix taskqueues drain/free to fix panic seen when interface is being
   bought down and in parallel asynchronous link events happening.

2. Fix bxe_ifmedia_status()

Submitted by:[email protected] and [email protected]
2018-08-09 00:48:55 +00:00
Bryan Drewery 0b79893678 MFC r321333:
Properly set userid for truncate_test.
2018-08-08 18:59:25 +00:00
Bryan Drewery 2c4f23868e MFC r323620:
Fix the raise tests.
2018-08-08 18:54:05 +00:00
Bryan Drewery 33229990f8 MFC r335183:
proc0_post: Fix some locking issues
2018-08-08 17:49:35 +00:00
Glen Barber 1ae35f69f9 Document SA-18:08.
Sponsored by:	The FreeBSD Foundation
2018-08-07 15:03:11 +00:00
Jonathan T. Looney c578b069c6 MFC r337390: Bump date after r337384. 2018-08-06 18:47:03 +00:00
Jonathan T. Looney 065ebc9378 MFC r337384:
Address concerns about CPU usage while doing TCP reassembly.

Currently, the per-queue limit is a function of the receive buffer
size and the MSS.  In certain cases (such as connections with large
receive buffers), the per-queue segment limit can be quite large.
Because we process segments as a linked list, large queues may not
perform acceptably.

The better long-term solution is to make the queue more efficient.
But, in the short-term, we can provide a way for a system
administrator to set the maximum queue size.

We set the default queue limit to 100.  This is an effort to balance
performance with a sane resource limit.  Depending on their
environment, goals, etc., an administrator may choose to modify this
limit in either direction.

Approved by:	so
Security:	FreeBSD-SA-18:08.tcp
Sponsored by:	CVE-2018-6922
2018-08-06 17:46:28 +00:00
Pedro F. Giffuni e7b9fd7c60 MFC r336926:
sed: unsign some indexes to fix sign-compare warnings.

Hinted by:	OpenBSD (CVS 1.32)
2018-08-06 02:10:52 +00:00
Martin Matuska 8330784108 MFH r336801,r336854:
MFH r336801 (cem):
Cherry-pick upstream 2c8c83b9

Relevant vendor changes:
  Fix issue #948: out-of-bounds read in lha_read_data_none()

MFH r336854:
Sync libarchive with vendor.

Important vendor changes:
  PR #993: Chdir to -C directory for metalog processing
  OSS-Fuzz #4969: Check size of the extended time field in zip archives
  PR #973: Record informational compression level in gzip header

amdbugs:	877
Security:	CVE-2017-14503
2018-08-05 14:36:12 +00:00
Alan Somers 97db1ae4c6 MFC r336319:
auditon(2): fix A_SETPOLICY with 64-bit values

A_SETPOLICY is supposed to work with either 64 or 32-bit values, but due to a
typo the 64-bit version has never worked correctly.

Submitted by:	aniketp
Reviewed by:	asomers, cem
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D16222
2018-08-03 14:47:47 +00:00
Alan Somers 4efe4ec21c MFC r336205:
Don't acquire evclass_lock with a spinlock held

When the "pc" audit class is enabled and auditd is running, witness will
panic during thread exit because au_event_class tries to lock an rwlock
while holding a spinlock acquired upstack by thread_exit.

To fix this, move AUDIT_SYSCALL_EXIT futher upstack, before the spinlock is
acquired. Of thread_exit's 16 callers, it's only necessary to call
AUDIT_SYSCALL_EXIT from two, exit1 (for exiting processes) and kern_thr_exit
(for exiting threads). The other callers are all kernel threads, which
needen't call AUDIT_SYSCALL_EXIT because since they can't make syscalls
there will be nothing to audit.  And exit1 already does call
AUDIT_SYSCALL_EXIT, making the second call in thread_exit redundant for that
case.

PR:		228444
Reported by:	aniketp
Reviewed by:	aniketp, kib
Differential Revision:	https://reviews.freebsd.org/D16210
2018-08-03 14:45:53 +00:00
Alan Somers 7267123f2c MFC r335899:
auditd(8): register signal handlers interrutibly

auditd_wait_for_events() relies on read(2) being interrupted by signals,
but it registers signal handlers with signal(3), which sets SA_RESTART.
That breaks asynchronous signal handling. It means that signals don't
actually get handled until after an audit(8) trigger is received.
Symptoms include:

* Sending SIGTERM to auditd doesn't kill it right away; you must send
  SIGTERM and then send a trigger with auditon(2).
* Same with SIGHUP
* Zombie child processes don't get reaped until auditd receives a trigger
  sent by auditon. This includes children created by expiring audit trails
  at auditd startup.

Fix by using sigaction(2) instead of signal(3).

Cherry pick https://github.com/openbsm/openbsm/commit/d060887

PR:		229381
Reviewed by:	cem
Obtained from:	OpenBSM
Differential Revision:	https://github.com/openbsm/openbsm/pull/36
2018-08-03 14:37:23 +00:00
Alan Somers 206e1e3420 MFC r335287, r335290
r335287:
praudit(1): return 0 on success

Cherry pick https://github.com/openbsm/openbsm/commit/ed83bb3

Submitted by:	aniketp
Reviewed by:	rwatson, 0mp
Obtained from:	OpenBSM
Sponsored by:	Google, Inc. (GSoC 2018)
Pull Request:	https://github.com/openbsm/openbsm/pull/32

r335290:
praudit(1): add tests

Submitted by:	aniketp
X-MFC-With:	335287
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15751
2018-08-03 14:36:29 +00:00
Alan Somers 643935ba00 MFC r334547:
pty.3: Add a HISTORY section

These functions were first added in 4.3 BSD-Reno, according to
http://unix.superglobalmegacorp.com/ and the CSRG svn repository.

Reviewed by:	bcr, bjk
Differential Revision:	https://reviews.freebsd.org/D15652
2018-08-03 14:25:15 +00:00
Alan Somers 6aede33778 MFC r334394:
auditpipe(4): fix some ioctl arguments in the man page

Fix the argument types for the AUDITPIPE_[GS]ET_PRESELECT_(NA)?FLAGS ioctls.
Also, fix some grammar.

[skip ci]

PR:		226713
Submitted by:	aniketp
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15620
2018-08-03 14:23:51 +00:00
Alan Somers 22ef1b1c2e MFC r334390:
au_read_rec(3): correct return value in man page

Submitted by:	aniketp
Reviewed by:	csjp (earlier version)
Sponsored by:	Google, Inc. (GSoC 2018)
Differential Revision:	https://reviews.freebsd.org/D15618
2018-08-03 14:23:01 +00:00
Alan Somers ea02a8fc97 MFC r334296:
Fix "Bad tailq" panic when auditing auditon(A_SETCLASS, ...)

Due to an oversight in r195280, auditon(A_SETCLASS, ...) would cause a tailq
element to get added to the tailq twice, resulting in a circular tailq. This
panics when INVARIANTS are on.

Differential Revision:	https://reviews.freebsd.org/D15381
2018-08-03 14:22:16 +00:00
Alan Somers 6f8126ebc4 MFC r330720:
tftpd: reject unknown opcodes

If tftpd receives a command with an unknown opcode, it simply exits 1.  It
doesn't send an ERROR packet, and the client will hang waiting for one.  Fix
it.

PR:		226005
2018-08-03 14:19:56 +00:00
Alan Somers a358c70def MFC r330719:
tftpd: Abort on an WRQ access violation

On a WRQ (write request) tftpd checks whether the client has access
permission for the file in question.  If not, then the write is prevented.
However, tftpd doesn't reply with an ERROR packet, nor does it abort.
Instead, it tries to receive the packet anyway.

The symptom is slightly different depending on the nature of the error.  If
the target file is nonexistent and tftpd lacks permission to create it, then
tftpd will willingly receive the file, but not write it anywhere.  If the
file exists but is not writable, then tftpd will fail to ACK to WRQ.

PR:		225996
2018-08-03 14:19:09 +00:00
Alan Somers 21d1db71f4 MFC r330718:
tftpd: Verify world-writability for WRQ when using relative paths

tftpd(8) says that files may only be written if they already exist and are
publicly writable.  tftpd.c verifies that a file is publicly writable if it
uses an absolute pathname.  However, if the pathname is relative, that check
is skipped.  Fix it.

Note that this is not a security vulnerability, because the transfer
ultimately doesn't work unless the file already exists and is owned by user
nobody.  Also, this bug does not affect the default configuration, because
the default uses the "-s" option which makes all pathnames absolute.

PR:		226004
2018-08-03 14:18:02 +00:00
Alan Somers b77d00d401 MFC r330710:
tftpd: Flush files as soon as they are fully received

On an RRQ, tftpd doesn't exit as soon as it's finished receiving a file.
Instead, it waits five seconds just in case the client didn't receive the
server's last ACK and decides to resend the final DATA packet.
Unfortunately, this created a 5 second delay from when the client thinks
it's done sending the file, and when the file is available for other
processes.

Fix this bug by closing the file as soon as receipt is finished.

PR:			157700
Reported by:		Barry Mishler <[email protected]>
2018-08-03 14:17:11 +00:00
Alan Somers cbb8e5aaa7 MFC r330696, r330709, r330742, r331358
r330696:
Add some functional tests for tftpd(8)

tftpd(8) is difficult to test in isolation due to its relationship with
inetd.  Create a test program that mimics the behavior of tftp(1) and
inetd(8) and verifies tftpd's response in several different scenarios.

These test cases cover all of the basic TFTP protocol, but not the optional
parts.

PR:		157700
PR:		225996
PR:		226004
PR:		226005
Differential Revision:	https://reviews.freebsd.org/D14310

r330709:
Commit missing file from r330696

X-MFC-With:	330696

r330742:
tftpd: fix the build of tests on i386 after 330696

It's those darn printf format specifiers again

Reported by:	cy, kibab
X-MFC-With:	330696

r331358:
tftpd: misc Coverity cleanup in the tests

A bunch of unchecked return values from open(2) and read(2)

Reported by:	Coverity
CID:		1386900, 1386911, 1386926, 1386928, 1386932, 1386942
CID:		1386961, 1386979
X-MFC-With:	330696
2018-08-03 14:13:15 +00:00
Konstantin Belousov 9e4f09660d MFC r336683:
Extend ranges of the critical sections to ensure that context switch
code never sees FPU pcb flags not consistent with the hardware state.
2018-08-03 14:12:37 +00:00
Alan Somers 5445e498d4 MFC r328266:
mlock(2): correct documentation for error conditions.

The man page is years out of date regarding errors. Our implementation _does_
allow unaligned addresses, and it _does_not_ check for negative lengths,
because the length is unsigned. It checks for overflow instead.

Update the tests accordingly.

Reviewed by:	bcr
Differential Revision:	https://reviews.freebsd.org/D13826
2018-08-03 14:08:39 +00:00
Rick Macklem a76ba01a3f MFC: r336357
Modify the reasons for not issuing a delegation in the NFSv4.1 server.

The ESXi NFSv4.1 client will generate warning messages when the reason for
not issuing a delegation is two. Two refers to a resource limit and I do
not see why it would be considered invalid. However it probably was not the
best choice of reason for not issuing a delegation.
This patch changes the reasons used to ones that the ESXi client doesn't
complain about. This change does not affect the FreeBSD client and does
not appear to affect behaviour of the Linux NFSv4.1 client.
RFC5661 defines these "reasons" but does not give any guidance w.r.t. which
ones are more appropriate to return to a client.
2018-08-01 19:25:12 +00:00
Hans Petter Selasky 348bb71138 MFC r322596:
Add SI_SUB_TASKQ after SI_SUB_INTR and move taskqueue initialization there for EARLY_AP_STARTUP

This fixes a regression accidentally introduced in r322588, due to an
interaction with EARLY_AP_STARTUP.

Reviewed by:	bdrewery@, jhb@
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12053
2018-08-01 13:13:43 +00:00
Hans Petter Selasky 2dda37976d MFC r311169, r312975, r313080, r315718 and r316031:
Add support for atomic_(f)cmpset to x86.
2018-08-01 12:49:51 +00:00
Hans Petter Selasky ba74b2df94 MFC r321686 and r330361:
Add inline functions to convert between sbintime_t and decimal time units.
Use them in some existing code that is vulnerable to roundoff errors.
2018-08-01 11:08:52 +00:00
Hans Petter Selasky abb412bee9 MFC r330344:
Correct the return code from pause() during cold startup from zero to
EWOULDBLOCK. This also matches the description in pause(9).

Discussed with:	kib@
Sponsored by:	Mellanox Technologies
2018-08-01 10:35:49 +00:00
Hans Petter Selasky 14f07a1651 MFC r330349 and r330362:
Allow pause_sbt() to catch signals during sleep by passing C_CATCH flag.
Define pause_sig() function macro helper similarly to other kernel functions
which catch signals. Update outdated function description.

Document pause_sig(9) and update prototypes for existing pause(9) and
pause_sbt(9) functions.

Discussed with:	kib@
Suggested by:	cem@
Sponsored by:	Mellanox Technologies
2018-08-01 10:34:53 +00:00
Rick Macklem 8a88630a2f MFC: r336215
Ignore the cookie verifier for NFSv4.1 when the cookie is 0.

RFC5661 states that the cookie verifier should be 0 when the cookie is 0.
However, the wording is somewhat unclear and a recent discussion on the
[email protected] mailing list indicated that the NFSv4 server should ignore
the cookie verifier's value when the dirctory offset cookie is 0.
This patch deletes the check for this that would return NFSERR_BAD_COOKIE
when the verifier was not 0.
This was found during testing of the ESXi client against the NFSv4.1 server.
2018-07-31 21:02:45 +00:00
Mark Johnston 62291305d9 Revert r335693, r335694, r335695 by eadler.
They cause mail(1) to crash in certain scenarios.

PR:		230196
Reported by:	Pete French <[email protected]>
2018-07-31 00:37:25 +00:00
Rick Macklem b481731ba3 MFC: r335866
Fix the server side krpc so that the kernel nfsd threads terminate.

Occationally the kernel nfsd threads would not terminate when a SIGKILL
was posted for the kernel process (called nfsd (slave)). When this occurred,
the thread associated with the process (called "ismaster") had returned from
svc_run_internal() and was sleeping waiting for the other threads to terminate.
The other threads (created by kthread_start()) were still in svc_run_internal()
handling NFS RPCs.
The only way this could occur is for the "ismaster" thread to return from
svc_run_internal() without having called svc_exit().
There was only one place in the code where this could happen and this patch
stops that from happening.
Since the problem is intermittent, I cannot be sure if this has fixed the
problem, but I have not seen an occurrence of the problem with this patch
applied.
2018-07-30 19:29:31 +00:00
Rick Macklem 7696e62330 MFC: r334966
Add a couple of safety belt checks to the NFSv4.1 client related to sessions.

There were a couple of cases in newnfs_request() that it assumed that it
was an NFSv4.1 mount with a session. This should always be the case when
a Sequence operation is in the reply or the server replies NFSERR_BADSESSION.
However, if a server was broken and sent an erroneous reply, these safety
belt checks should avoid trouble.
The one check required a small tweak to nfsmnt_mdssession() so that it
returns NULL when there is no session instead of the offset of the field
in the structure (0x8 for i386).
This patch should have no effect on normal operation of the client.
Found by inspection during pNFS server development.
2018-07-30 12:17:10 +00:00
Hans Petter Selasky b802dc1100 MFC r336632:
Update modify counter when setting a mixer control.

PR:		229969
2018-07-30 09:28:00 +00:00
Hans Petter Selasky 48f7c0c87a MFC r335700:
Improve the kernel's USB descriptor reading function.
Some USB devices does not allow a partial descriptor readout.

Found by:	bz@
Sponsored by:	Mellanox Technologies
2018-07-30 09:21:19 +00:00
Hans Petter Selasky 0ab2248a85 MFC r335669:
Improve the userspace USB string reading function in LibUSB.
Some USB devices does not allow a partial descriptor readout.

Found by:		bz @
Sponsored by:		Mellanox Technologies
2018-07-30 09:16:47 +00:00
Rick Macklem 7fef05b6b0 MFC: r334492
Add the BindConnectiontoSession operation to the NFSv4.1 server.

Under some fairly unusual circumstances, the Linux NFSv4.1 client is
doing a BindConnectiontoSession operation for TCP connections.
It is also used by the ESXi6.5 NFSv4.1 client.
This patch adds this operation to the NFSv4.1 server.

PR:		226493
2018-07-28 20:38:08 +00:00
David Bright 252b4fb88e MFC r336457:
Make the definition of struct kevent in event.h match what the man page for kevent(2) says.

This is a trivial comment-only fix. The man page for kevent(2) gives
the definition of struct kevent, including a comment on each
field. The actual definition in sys/event.h omitted the comments on
some fields. Add the comments in. Not only does this make the man page
and include file agree, but the comments are useful in and of
themselves.

Sponsored by:	Dell EMC
2018-07-23 18:47:04 +00:00
Dexuan Cui 1d4a343a91 MFC: 336426
r336426
        hyperv/hn: Fix panic in hypervisor code upon device detach event

        Submitted by:       hselasky
        Reviewed by:        dexuan
        Differential Revision:      https://reviews.freebsd.org/D16139
2018-07-23 17:38:35 +00:00
Rick Macklem aa006917ab MFC: r333766
Add a missing nfsrv_freesession() call for an unlikely failure case.

Since NFSv4.1 clients normally create a single session which supports
both fore and back channels, it is unlikely that a callback will fail
due to a lack of a back channel.
However, if this failure occurred, the session wasn't being dereferenced
and would never be free'd.
Found by inspection during pNFS server development.
2018-07-19 21:07:39 +00:00
Peter Jeremy bb211063a4 Retrospectively document SVN branch point for stable-10 and its releases.
This is a direct commit to stable/10 because the releases are taken
from the stable/10 branch.

Approved by:	jhb (mentor)
Differential Revision:	D16263
2018-07-18 09:32:43 +00:00
Dimitry Andric 320b9998aa Pull in r211155 from upstream llvm trunk (by Tim Northover):
DAG: move sret demotion into most basic LowerCallTo implementation.

  It looks like there are two versions of LowerCallTo here: the
  SelectionDAGBuilder one is designed to operate on LLVM IR, and the
  TargetLowering one in the case where everything is at DAG level.

  Previously, only the SelectionDAGBuilder variant could handle
  demoting an impossible return to sret semantics (before delegating to
  the TargetLowering version), but this functionality is also useful
  for certain libcalls (e.g. 128-bit operations on 32-bit x86).  So
  this commit moves the sret handling down a level.

  rdar://problem/17242889

This should fix "Call result #3 has unhandled type i32" errors when
building devel/libslang2 for i386.  Direct commit to stable/10, since
clang 3.5 and later already have this change.

Reported by:	mi
PR:		229754
2018-07-17 21:10:31 +00:00
Rick Macklem ed810a82b9 MFC: r333645
End grace for the NFSv4 server if all mounts do ReclaimComplete.

The NFSv4 protocol requires that the server only allow reclaim of state
and not issue any new open/lock state for a grace period after booting.
The NFSv4.0 protocol required this grace period to be greater than the
lease duration (over 2minutes). For NFSv4.1, the client tells the server
that it has done reclaiming state by doing a ReclaimComplete operation.
If all NFSv4 clients are NFSv4.1, the grace period can end once all the
clients have done ReclaimComplete, shortening the time period considerably.
This patch does this. If there are any NFSv4.0 mounts, the grace period
will still be over 2minutes.
This change is only an optimization and does not affect correct operation.
2018-07-17 19:26:17 +00:00
Pedro F. Giffuni ad39f6294d MFC r336115;
libiconv: correct undefined behavior.

Detected on NetBSD:
# nm /usr/lib/libc.so|grep sanit
    /public/src.git/lib/libc/citrus/modules/citrus_mapper_std.c:173:8:
runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Obtained from:	NetBSD (CVS Rev. 1.11)
2018-07-16 00:28:33 +00:00
Rick Macklem 390a21dac2 MFC: r333579
The NFSv4.1 server should return NFSERR_BACKCHANBUSY instead of NFS_OK.

When an NFSv4.1 session is busy due to a callback being in progress,
nfsrv_freesession() should return NFSERR_BACKCHANBUSY instead of NFS_OK.
The only effect this has is that the DestroySession operation will report
the failure for this case and this probably has little or no effect on a
client. Spotted by inspection and no failures related to this have been
reported.
2018-07-12 22:59:02 +00:00
David Bright d6c658db1f MFC r335765, r335776, r336186:
Remove potential identifier conflict in the EV_SET macro.

PR43905 pointed out a problem with the EV_SET macro if the passed
struct kevent pointer were specified with an expression with side
effects (e.g., "kevp++"). This was fixed in rS110241, but by using a
local block that defined an internal variable (named "kevp") to get
the pointer value once. This worked, but could cause issues if an
existing variable named "kevp" is in scope. To avoid that issue,
jilles@ pointed out that "C99 compound literals and designated
initializers allow doing this cleanly using a macro". This change
incorporates that suggestion, essentially verbatim from jilles@
comment on PR43905, except retaining the old definition for pre-C99 or
non-STDC (e.g., C++) compilers.

PR:	43905
Submitted by:	Jilles Tjoelker (jilles@)
Reported by:	Lamont Granquist <[email protected]>
Sponsored by:	Dell EMC
2018-07-11 14:56:38 +00:00
Rick Macklem bd4acd5ad1 MFC: r333508
Add support for the TestStateID operation to the NFSv4.1 server.

The Linux client now uses the TestStateID operation, so this patch adds
support for it to the NFSv4.1 server. The FreeBSD client never uses this
operation, so it should not be affected.
2018-07-10 19:37:52 +00:00
Jamie Gritton 0f975aaa9b MFC r335921:
Allow jail names (not just IDs) to be specified for: cpuset(1), ipfw(8),
   sockstat(1), ugidfw(8)
  These are the last of the jail-aware userland utilities that didn't work
   with names.

PR:		229266
Differential Revision:	D16047
2018-07-06 19:10:07 +00:00
Ed Maste 3eddb5884e MFC r306098 (br): Use kqueue(2) instead of select(2).
This helps to ensure we will not lose SIGINT sent by parent to child.

PR:		212562, 228492
2018-07-04 18:03:19 +00:00
Ian Lepore 9450517b0b MFC r335575, r335786
r335575:
Use 'mv -f' in rc.d/ntpd to avoid spuriously halting the boot.

The final 'mv' to install a fetched leap-list file can fail (due to a
readonly fs, or schg flags, for example), and that leads to mv(1)
prompting the user, stopping the boot process.  Instead, use mv -f
to supress the prompting, and if verbose mode is on, emit a warning
that the existing file cannot be replaced.

PR:		219255

r335786:
Rename variable ntp_tmp_leapfile to have a leading underbar, to distinguish
it from variables with similar names which are set in rc.conf.  This will
make more sense as the script grows more similar-name local variables in
some upcoming changes.
2018-07-04 14:12:09 +00:00
Ian Lepore f13edcc66a MFC r335595-r335596
r335595:
Modernize usage of "restrict" keyword in ntp.conf

It is no longer necessary to specify a -4/-6 flag on any ntp.conf
keyword.  The address type is inferred from the address itself as
necessary.  "restrict default" statements always apply to both address
families regardless of any -4/-6 flag that may be present.

So this change just tidies up our default config by removing the redundant
restrict -6 statement and comment, and by removing the -6 flag from the
restrict keyword that allows access from localhost.

This change was inspired by the patches provided in PRs 201803 and 210245,
and included some contrib/ntp code inspection to verify that the -4/-6
keywords are basically no-ops in all contexts now.

PR:		201803 210245
Differential Revision:	https://reviews.freebsd.org/D15974

r335596:
Fix a comment; the ntp leaplist file is updated periodically, but not weekly
(it's only updated when a check shows it's within 30 days of expiring).

PR:		207138
2018-07-04 14:10:36 +00:00
Devin Teske 4480b4b52f MFC SVN r335750: Fix typo in top-level Makefile
Submitted by:	Ben Widawsky <[email protected]>
Sponsored by:	Smule, Inc.
Differential Revision:	https://reviews.freebsd.org/P186
2018-07-04 03:24:11 +00:00
Devin Teske 11a60dc657 MFC SVN r290340: Fix typo in error message
Submitted by:	git_johnko.ca (John Ko)
Sponsored by:	Smule, Inc.
Differential Revision:	https://reviews.freebsd.org/D3997
2018-07-03 22:11:16 +00:00
Bartek Rutkowski 589bc2cacd MFC r327317:
humanize_number(3): fix math edge case in rounding large numbers

Fix for remainder overflow, when in rare cases adding remainder to divider
exceeded 1 and turned the total to 1000 in final formatting, taking up
the space for the unit character.

The fix continues the division of the original number if the above case
happens -- added the appropriate check to the for loop performing
the division. This lowers the value shown, to make it fit into the buffer
space provided (1.0M for 4+1 character buffer, as used by ls).

Add test case for the reported bug and extend test program to support
providing buffer length (ls -lh uses 5, tests hard-coded 4).

PR:		224498
2018-07-03 14:57:11 +00:00
Brooks Davis 861b0cf105 MFC r335641:
Fix a stack overflow in mount_smbfs when hostname is too long.

The local hostname was blindly copied into the to the nn_name array.
When the hostname exceeded 16 bytes, it would overflow.  Truncate the
hostname to 15 bytes plus a 0 terminator which is the "workstation name"
suffix.

Use defensive strlcpy() when filling nn_name in all cases.

PR:		228354
Reported by:	[email protected]
Reviewed by:	jpaetzel,  ian (prior version)
Discussed with:	Security Officer (gtetlow)
Security:	Stack overflow with the hostname.
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15936
2018-06-28 21:23:05 +00:00
Devin Teske eca3bc5b7c MFC r335607: check-password.4th(8): Fix manual [in]accuracy
SVN r280384 updated the maximum password length from 16 bytes to 255. The
manual was not updated to reflect this.

Sponsored by:	Smule, Inc.
2018-06-27 21:22:00 +00:00
Cy Schubert db23c15772 MFC r335355:
Fix amq -i timestamp segmentation violation.
2018-06-27 19:42:55 +00:00
Eitan Adler 29cd095f56 MFC r302776, r302799:
mail(1): Bring some fixes from other BSDs.

- Use varargs properly
- Use pid_t
- Better handling of error conditions on forked jobs.
- Some prototype and warning cleanups.

Fix missing forked job changes from r302776 in wait_child().
2018-06-27 04:56:01 +00:00
Glen Barber 30e60fee3b MFC r325107, r335665:
r325107 (eadler, partial):
  Update the updating URL in UPDATING.

 r335665:
  Use the 'Updating from Source' Handbook section in UPDATING.

PR:		229345
Submitted by:	Niels Bakker
Approved by:	re (marius, insta-MFC)
Sponsored by:	The FreeBSD Foundation
2018-06-26 16:16:08 +00:00
Andriy Gapon f89b3f9fcf MFC r334002: uchcom: extend hardware support to version 0x30 2018-06-25 08:57:03 +00:00
Andriy Gapon c0e4472652 MFC r334001: uchcom: remove UCHCOM_REG_BREAK2 alias of UCHCOM_REG_LCR1 2018-06-25 08:55:19 +00:00
Andriy Gapon 2ff9b7cd34 MFC r334000: uchcom: reject parity and double stop bits as unsupported 2018-06-25 08:53:30 +00:00
Andriy Gapon 31db47dadc MFC r333999: uchcom: add a hardware configuration tweak seen in Linux code 2018-06-25 08:50:46 +00:00
Andriy Gapon f9ac551121 MFC r333998: uchcom: add DPRINTF-s to aid debugging of the driver 2018-06-25 08:49:13 +00:00
Andriy Gapon d8edebc6ac MFC r333997: uchcom: report detected product based on USB product ID 2018-06-25 08:47:54 +00:00
Andriy Gapon 0dcbb0d041 MFC r333667: followup to r332730/r332752: set kdb_why to "trap" for fatal traps
This change updates arm, arm64 and mips achitectures.  Additionally, it
removes redundant checks for kdb_active where it already results in
kdb_reenter() and adds kdb_reenter() calls where they were missing.

Some architectures check the return value of kdb_trap(), but some don't.
I haven't changed any of that.

Some trap handling routines have a return code.  I am not sure if I
provided correct ones for returns after kdb_reenter().  kdb_reenter
should never return unless kdb_jmpbufp is NULL for some reason.
2018-06-22 11:16:17 +00:00
Andriy Gapon b4e42f96f4 Revert r335546 as temporary pool name feature has not been merged 2018-06-22 10:13:15 +00:00
Andriy Gapon 80f6f8450e MFC r333630: Fix 'zpool create -t <tempname>'
Creating a pool with a temporary name fails when we also specify custom
dataset properties: this is because we mistakenly call
zfs_set_prop_nvlist() on the "real" pool name which, as expected,
cannot be found because the SPA is present in the namespace with the
temporary name.
2018-06-22 09:41:13 +00:00
Andriy Gapon 55c154e714 MFC r333269: amdsbwd: fix reboot status reporting 2018-06-22 09:26:05 +00:00
Andriy Gapon ad52904715 MFC r333243: opensolaris system_taskq does not need to run at maximum priority 2018-06-22 09:23:06 +00:00
Andriy Gapon 49cd7c25e7 MFC r333212: amdsbwd: add suspend and resume methods 2018-06-22 09:20:50 +00:00
Andriy Gapon 859d56f66c MFC r333209: hpet: use macros instead of magic values for the timer mode 2018-06-22 09:09:59 +00:00
Devin Teske 14b6fd4d2b MFC r335308: bsdconfig: Fix a bug when editing users
The usermgmt API was stomping on a global ($user_gid to be specific)
so things would appear to work fine until you tried to make a second
pass into the API with the now-tainted variable contents.

Fixed by localizing menu-specific contents as to not leak outside API.

PR:		bin/208774
Reported by:	Martin Waschbuesch <[email protected]>
Sponsored by:	Smule, Inc.
2018-06-21 15:02:17 +00:00
Andrey V. Elsukov bfb1e1af8b MFC r335133:
In m_megapullup() use m_getjcl() to allocate 9k or 16k mbuf when requested.

  It is better to try allocate a big mbuf, than just silently drop a big
  packet. A better solution could be reworking of libalias modules to be
  able use m_copydata()/m_copyback() instead of requiring the single
  contiguous buffer.

  PR:		229006
2018-06-21 11:24:20 +00:00
Konstantin Belousov 0b76893fe4 MFC r335072, r335089, r335131, r335132:
Enable eager FPU context switch on i386 and amd64.

CVE:  CVE-2018-3665
Tested by:	emaste (smoke boot)
2018-06-20 18:51:38 +00:00
Devin Teske 07833d6a1c dpv(3): MFC r330943, r335264
r330943:
Fix bad error messages from dpv(3)

Before = dpv: <__func__>: posix_spawnp(3): No such file or directory
 After = dpv: <path/cmd>: No such file or directory

Most notably, show the 2nd argument being passed to posix_spawnp(3)
so we know what path/cmd failed.

Also, we don't need to have "posix_spawnp(3)" in the error message
nor the function because that can [a] change and [b] traversed using
a debugger if necessary.

r335264:
Fix comparison between pointer and char literal

PR:		misc/204252
Reported by:	David Binderman <[email protected]>
Sponsored by:	Smule, Inc.
2018-06-20 05:50:54 +00:00
Dimitry Andric a0fa4cf6a2 Follow-up to r335289, which merged r334948 from head, to really fix the
bxe build on i386.  In the stable/10 branch, the rman functions still
use u_long instead of uintmax_t (this was changed in r294883 and
r297000), so these have to be printed using the l modifier instead.

Pointy hat to:	me
Noticed by:	gjb
2018-06-18 20:42:53 +00:00
Dimitry Andric 58bccbeb68 MFC r334948:
Fix build of bxe with base gcc on i386

Casting from rman_res_t to a pointer results in "cast to pointer from
integer of different size" warnings with base gcc on i386, so print
these without casting.  The kva field of struct bxe_bar is of type
vm_offset_t, which can be 32 or 64 bit, so cast it to uintmax_t before
printing.

Reviewed by:	markj
Differential Revision: https://reviews.freebsd.org/D15733
2018-06-17 17:28:27 +00:00
Kristof Provost dd60e78046 MFC r334876:
pf: Fix deadlock with route-to

If a locally generated packet is routed (with route-to/reply-to/dup-to) out of
a different interface it's passed through the firewall again. This meant we
lost the inp pointer and if we required the pointer (e.g. for user ID matching)
we'd deadlock trying to acquire an inp lock we've already got.

Pass the inp pointer along with pf_route()/pf_route6().

PR:		228782
2018-06-16 11:42:27 +00:00
Glen Barber bbc326a0e2 MFC r333374:
Use vYYYYMMDD in the timestamp suffix for Google Compute Engine
 snapshot images for consistency with other OSes.

Sponsored by:	The FreeBSD Foundation
2018-06-11 17:22:27 +00:00
Hans Petter Selasky f7bdbbaf4a MFC r334158:
Add function to wait for USB ethernet attach to complete.

Sponsored by:	Mellanox Technologies
2018-06-07 07:33:46 +00:00
Rick Macklem cb4f65f3d5 MFC: r333580
Fix a slow leak of session structures in the NFSv4.1 server.

For a fairly rare case of a client doing an ExchangeID after a hard reboot,
the old confirmed clientid still exists, but some clients use a new
co_verifier. For this case, the server was not freeing up the sessions on
the old confirmed clientid.
This patch fixes this case. It also adds two LIST_INIT() macros, which are
actually no-ops, since the structure is malloc()d with M_ZERO so the pointer
is already set to NULL.
It should have minimal impact, since the only way I could exercise this
code path was by doing a hard power cycle (pulling the plus) on a machine
running Linux with a NFSv4.1 mount on the server.
Originally spotted during testing of the ESXi 6.5 client.

PR:		228497
2018-06-06 22:18:24 +00:00
Rick Macklem 4307641a00 MFC: r334396
Strengthen locking for the NFSv4.1 server DestroySession operation.

If a client did a DestroySession on a session while it was still in use,
the server might try to use the session structure after it is free'd.
I think the client has violated RFC5661 if it does this, but this patch
makes DestroySession block all other nfsd threads so no thread could
be using the session when it is free'd. After the DestroySession, nfsd
threads will not be able to find the session. The patch also adds a check
for nd_sessionid being set, although if that was not the case it would have
been all 0s and unlikely to have a false match.
This might fix the crashes described in PR#228497 for the FreeNAS server.

PR:		228497
2018-06-06 01:30:48 +00:00
Rick Macklem c303df046f MFC: r334252
Fix the sleep event for layout recall.

The sleep for I/O completion during an NFSv4.1 pNFS layout recall used
the wrong event value and could result in the "[nfscl]" thread hung
for the mount.
This patch fixes the event to be the correct.
This bug will only affect NFSv4.1 pnfs mounts and only when the server
does a layout recall callback, so it won't affect many. Without the patch,
a mount without the "pnfs" option will avoid the problem.
Found during testing of the pNFS server.
2018-06-04 20:55:25 +00:00
Rick Macklem 7630cd4459 MFC: r333592
Fix the eir_server_scope reply argument for NFSv4.1 ExchangeID.

In the reply to an ExchangeID operation, the NFSv4.1 server returns a
"scope" value (eir_server_scope). If this value is the same, it indicates
that two servers share state, which is never the case for FreeBSD servers.
As such, the value needs to be unique and it was without this patch.
However, I just found out that it is not supposed to change when the
server reboots and without this patch, it did change.
This patch fixes eir_server_scope so that it does not change when the
server is rebooted.
The only affect not having this patch has is that Linux clients don't
reclaim opens and locks after a server reboot, which meant they lost
any byte range locks held before the server rebooted.
It only affects NFSv4.1 mounts and the FreeBSD NFSv4.1 client was not
affected by this bug.
2018-06-04 20:40:22 +00:00
Xin LI 1bbfdedf4a MFC r333098:
Don't bail out from the check if readboot() returns !FSFATAL.

This can happen when the fsinfo signature is invalid, and the
user have choose to fix it, in which case the code would return
FSBOOTMOD (not FSOK but not FSFATAL either).

All other (fatal) cases would return FSFATAL.

Obtained from:	Android Open Source Project
Obtained from:	https://android.googlesource.com/platform/external/fsck_msdos/+/d8775a29ea7eac2e5f1504dd21da3725b93b3036
2018-06-04 05:47:15 +00:00
Brooks Davis 2ee8c153e2 MFC r292268, r334176
r292268:
Remove sys/types.h due to STANDARDS and unistd.h also includes
sys/types.h.

r334176:
Indicate the brk/sbrk are deprecated and not portable.

More firmly suggest mmap(2) instead.

Include the history of arm64 and riscv shipping without brk/sbrk.

Mention that sbrk(0) produces unreliable results.

Reviewed by:	emaste, Marcin Cieślak
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15535
2018-05-31 16:10:44 +00:00
Sean Bruno 076e25f378 Activate Wake On Lan features for Ice Lake and Cannon Lake devices.
This is a direct commit to stable/10 as its not needed in -current.

PR:		228302
Submitted by:	Kaho Toshikazu <[email protected]>
2018-05-26 21:58:43 +00:00
Cy Schubert 7c021a9e7d MFC r333392-r333393, r333427
r333392:
Fix memory leak. (CID 1199373).

r333393:
Document intentional fallthrough. (CID 976535)

r333427:
Fix style error introduced in r333393.

Reported by:	jhb, imp, phk
2018-05-25 06:26:07 +00:00
Ed Maste 221b5f42fa MFC r326074: filter all passwords (not only changed) from periodic passwd backup
The periodic 200.backup-passwd script outputs any differences it finds
in master.passwd, relative to the previous backup.  It intends to elide
the encrypted password field, but previously did so only for changed
lines (i.e., those beginning with - or + in the diff).

Apply the sed expression also to unchanged lines to also elide their
passwords.

PR:		223461
Reported by:	Andre Albsmeier
Sponsored by:	The FreeBSD Foundation
2018-05-23 14:05:56 +00:00
Ed Maste 3070b13325 sys/modules: don't build bxe,qlxgbe if the user objects to sourceless ucode
MFC of r322682 and r322684

PR:		204747
Submitted by:	Fabian Keil
Obtained from:	ElectroBSD
2018-05-23 13:59:37 +00:00
Sean Bruno d72f35db09 MFC r303848
Repair trivial panic in ng_uncallout.  Fixes bugzilla #211031

PR:		211031
2018-05-15 13:19:00 +00:00
Pedro F. Giffuni f41fc2eeb1 MFC r333239:
msdosfs: long names of files are created incorrectly.

This fixes a regression that happened in r120492 (2003) where libkiconv
was introduced and we went from checking unlen to checking for '\0'.

PR:		111843
Patch by:	Damjan Jovanovic
2018-05-14 19:21:57 +00:00
Glen Barber 5e7055187a MFC r333473:
Add a special GCE_LICENSE variable to Makefile.gce, which when set,
 will include license metadata in the resultant GCE image.

 GCE_LICENSE is unset by default, as it primarily pertains to images
 produced by the FreeBSD Project, but for downstream FreeBSD consumers,
 it can be set in the make(1) environment in the format of:

   --licenses="projects/PROJECT_ID/global/licenses/LICENSE_NAME"

 The "license" is not a license, per se, but required metadata that
 is required by the GCE marketplace.  For the FreeBSD Project, the
 license name is simply 'freebsd', with the description of 'FreeBSD'.

Sponsored by:	The FreeBSD Foundation
2018-05-14 17:44:02 +00:00
David C Somayajulu 5ca9eef531 MFC r333004
Fix Issue with adding MUltiCast Addresses. When multicast addresses are
added/deleted, the delete the multicast addresses previously programmed
in HW and reprogram the new set of multicast addresses.

Submitted by:[email protected]
2018-05-09 20:18:23 +00:00
David C Somayajulu f38be6fd3b MFC r333003
Upgraded FW Related Files to version 5.4.67
2018-05-09 18:35:49 +00:00
Glen Barber 61d7884e02 Belatedly bump copyright year.
Approved by:	re (implicit)
Sponsored by:	The FreeBSD Foundation
2018-05-08 18:03:08 +00:00
Glen Barber 4d26e9b556 Document EN-18:05, EN-18:06, SA-18:06.
Approved by:	re (implicit)
Sponsored by:	The FreeBSD Foundation
2018-05-08 17:59:25 +00:00
Ed Maste 5a1995e997 MFC r333368: Prepare DB# handler for deferred trigger of watchpoints.
Prepare DB# handler for deferred trigger of watchpoints.

Since pop %ss/mov %ss instructions defer all interrupts and exceptions
for the next instruction, it is possible that the userspace watchpoint
trap executes on the first instruction of the kernel entry for
syscall/bpt.

In this case, DB# should be treated similarly to NMI: on amd64 we must
always load GSBASE even if the trap comes from kernel mode, and load
the kernel page table root into %cr3.  Moreover, the trap must
use the dedicated stack, because we are still on the user stack when
trapped on syscall entry.

For i386, we must reload %cr3.  The syscall instruction is not configured,
so there is no issue with executing on user stack when trapping.

Due to some CPU erratas it is not always possible to detect that the
userspace watchpoint triggered by inspecting %dr6.  In trap(), compare the
trap %rip with the known unsafe entry points and if matched pretend that
the watchpoint did not fire at all.

Thank you to the MSRC Incident Response Team, and in particular Greg
Lenti and Nate Warfield, for coordinating the response to this issue
across multiple vendors.

Thanks to Computer Recycling at The Working Center of Kitchener for
making hardware available to allow us to test the patch on additional
CPU families.

Reviewed by:	jhb
Discussed with:	Matthew Dillon
Tested by:	emaste
Security:	CVE-2018-8897
Security:	FreeBSD-SA-18:06.debugreg
Sponsored by:	The FreeBSD Foundation
2018-05-08 17:05:39 +00:00
Xin LI f31cc7dfc3 MFC r332877: Correct size for allocation and bzero of fdsr.
Approved by:	re (gjb)
2018-05-08 05:11:06 +00:00
Glen Barber b5069a7bea MFC r333262, r333264:
r333262:
  Ensure the ports and src trees are available on GCE images,
  satisfying a requirement to allow FreeBSD to be considered
  a top-tier supported OS in Google Compute Engine.

 r333264:
  Fix a typo.

Sponsored by:	The FreeBSD Foundation
2018-05-07 16:22:17 +00:00
Philip Paeps a7f39ea857 MFC r333247: Import tzdata 2018e
North Korea switches back to +09 on 2018-05-05.

This version more correctly models time stamps in time zones with
negative DST such as Europe/Dublin (from 1971 on), Europe/Prague
(1946/7), and Africa/Windhoek (1994/2017).  This does not affect the
UT offsets, only time zone abbreviations and the tm_isdst flag.
2018-05-07 07:02:26 +00:00
Ed Maste 4ecf8ef6f5 MFC r333234: zfs_ioctl: avoid out-of-bound read
admbugs:	796
Submitted by:	Domagoj Stolfa <[email protected]>
Reported by:	Ilja Van Sprundel <[email protected]>
2018-05-04 13:40:59 +00:00
Marius Strobl 22943b0b34 MFC: r330803
Use FALLTHROUGH.
2018-05-03 15:47:49 +00:00
Marius Strobl d44ad75936 MFC: r327312, r327842, r327865
- Add initial support for Intel Ice Lake and Cannon Lake Ethernet MACs.
- Add workaround for Intel Sky Lake and Kabby Lake Ethernet MAC erratum
  1.5.4.5.
- Fix uses of 1 << 31.
2018-05-03 15:41:04 +00:00
Andriy Gapon 74d05d4006 MFC r332752: set kdb_why to "trap" when calling kdb_trap from trap_fatal
This will allow to hook a ddb script to "kdb.enter.trap" event.
Previously there was no specific name for this event, so it could only
be handled by either "kdb.enter.unknown" or "kdb.enter.default" hooks.
Both are very unspecific.

Having a specific event is useful because the fatal trap condition is
very similar to panic but it has an additional property that the current
stack frame is the frame where the trap occurred.  So, both a register
dump and a stack bottom dump have additional information that can help
analyze the problem.

I have added the event only on architectures that have trap_fatal()
function defined.  I haven't looked at other architectures.  Their
maintainers can add support for the event later.

Sample script:
kdb.enter.trap=bt; show reg; x/aS $rsp,20; x/agx $rsp,20

Note: changes to powerpc/aim/trap.c and powerpc/booke/trap.c are direct
changes.

Sponsored by:	Panzura
2018-05-03 07:57:08 +00:00
Hans Petter Selasky 8f8dc87b90 MFC r333100:
Improve fix in r304629 by allowing configuration of the behaviour
through a SYSCTL instead of a compile time define.

Add quirk by default for all LynxPoint XHCI controllers.

PR:		227602
Sponsored by:	Mellanox Technologies
2018-05-03 07:38:45 +00:00
Andriy Gapon 45ef9bb244 follow-up to r333201 for powerpc, no kdb_active check in trap_fatal
This is a direct commit as there are two copies of trap_fatal for
powerpc in this branch.

Sponsored by:	Panzura
2018-05-03 07:37:49 +00:00
Andriy Gapon 59935f635f MFC r332730: don't check for kdb reentry in trap_fatal(), it's impossible
Sponsored by:	Panzura
2018-05-03 07:34:10 +00:00
Andriy Gapon 524f6e1a6d MFC r332559: mountd: fix a crash when getgrouplist reports too many groups
Sponsored by:	Panzura
2018-05-03 07:28:49 +00:00
Andriy Gapon f5526cf316 MFC r332426: allow ZFS pool to have temporary name for duration of current import
The change adds -t <name> option to zpool create and -t option to zpool
import in its form with an old name and a new name.  This allows to
import (or create) a pool under a name that's different from its real,
permanent name without affecting that name.  This is useful when working
with VM images or images of other physical systems if they happen to
have a ZFS pool with the same name as the host system.

Sponsored by:	Panzura (porting)
2018-05-03 07:22:24 +00:00
Kristof Provost a897e81456 MFC r333084:
pfctl: Don't break connections on skipped interfaces on reload

On reload we used to first flush everything, including the list of skipped
interfaces.  This can lead to termination of these connections if they send
packets before the new configuration is applied.

Note that this doesn't currently happen on 12 or 11, because of special EACCES
handling introduced in r315514. This special behaviour in tcp_output() may
change, hence the fix in pfctl.

PR:		214613
Submitted by:	Andreas Longwitz <longwitz at incore.de>
2018-05-02 22:36:10 +00:00
John Baldwin d9e6ca820f MFC 332735:
Fix two off-by-one errors when allocating MSI and MSI-X interrupts.

x86 enforces an (arbitray) limit on the number of available MSI and
MSI-X interrupts to simplify code (in particular, interrupt_source[]
is statically sized).  This means that an attempt to allocate an MSI
vector needs to fail if it would go beyond the limit, but the checks
for exceeding the limit had an off-by-one error.  In the case of MSI-X
which allocates interrupts one at a time this meant that IRQ 768 kept
getting handed out multiple times for msix_alloc() instead of failing
because all MSI IRQs were in use.
2018-04-30 20:29:28 +00:00
Roger Pau Monné ce7d41d87b MFC 270041:
net: move interface removal notification up in if_detach_internal

Requested by: dexuan
2018-04-30 08:39:23 +00:00
John Baldwin 9bb7e52e18 MFC 332733:
Workaround fixed I/O port resources encoded as I/O port ranges in _CRS.

ACPI I/O port descriptors use _MIN and _MAX fields to specify the set
of allowable base (start) addresses for an I/O port resource along with
a _LEN field specifying the length.  A fixed resource is supposed to be
encoded with _MIN == _MAX, but some buggy firmwares instead set _MAX to
the end of the fixed range.  Relocating I/O ranges only make sense in
_PRS (possible resource settings), not in _CRS (current resource settings),
so if an I/O port range with _MAX set set to the end of the range is
present in _CRS, treat it as a fixed I/O port resource starting at
_MIN.

PR:		224096
2018-04-28 00:16:54 +00:00
Kenneth D. Merry 5a273df84f MFC r332458:
------------------------------------------------------------------------
  r332458 | ken | 2018-04-12 15:21:18 -0600 (Thu, 12 Apr 2018) | 34 lines

  Handle Programmable Early Warning for control commands in sa(4).

  When the tape position is inside the Early Warning area, the tape
  drive will return a sense key of NO SENSE, and an ASC/ASCQ of
  0x00,0x02, which means: End-of-partition/medium detected".  If
  this was in response to a control command like WRITE FILEMARKS,
  we correctly translate this as informational status and return
  0 from saerror().

  Programmable Early Warning should be handled the same way, but
  we weren't handling it that way.  As a result, if a PEW status
  (sense key of NO SENSE, ASC/ASCQ of 0x00,0x07, "Programmable early
  warning detected") came back in response to a WRITE FILEMARKS,
  we returned an error.

  The impact of this was that if an application was writing to a
  sa(4) device, and a PEW area was set (in the Device Configuration
  Extension subpage -- mode page 0x10, subpage 1), and a filemark
  needed to be written on close, we could wind up returning an error
  to the user on close because of a "failure" to write the filemarks.

  It actually isn't a failure, but rather just a status report from
  the drive, and shouldn't be treated as a failure.

  sys/cam/scsi/scsi_sa.c:
  	For control commands in saerror(), treat asc/ascq 0x00,0x07
  	the same as 0x00,{0-5} -- not an error.  Return 0, since
  	the command actually did succeed.

  Reported by:	Dr. Andreas Haakh <[email protected]>
  Tested by:	Dr. Andreas Haakh <[email protected]>
  Sponsored by:	Spectra Logic
  ------------------------------------------------------------------------
2018-04-24 13:52:39 +00:00
Hans Petter Selasky 9e604113e5 MFC r329372 and r329464:
Implement enable_irq() and disable_irq() in the LinuxKPI and add checks for
valid IRQ tag before setting up or tearing down an interrupt handler in the
LinuxKPI. This is needed when the interrupt handler is disabled
before freeing the interrupt.

Submitted by:	Johannes Lundberg <[email protected]>
Sponsored by:	Mellanox Technologies
2018-04-24 10:32:25 +00:00
Hans Petter Selasky 5bd319785a MFC r331355:
Clear old MSIX IRQ numbers in the LinuxKPI.

When disabling the MSIX IRQ vectors for a PCI device through the
LinuxKPI, make sure any old MSIX IRQ numbers are no longer visible to
the linux_pci_find_irq_dev() function else IRQs can be requested from
the wrong PCI device.

Sponsored by:	Mellanox Technologies
2018-04-24 10:05:23 +00:00
Thomas Zander 14dfc5ddf0 MFC r332861:
Remove unused definition bl_dfp; fix build with bktr compiled into kernel

Approved by:	cognet
2018-04-24 10:02:17 +00:00
Dexuan Cui bf07cde5f2 MFC: 332385
r332385:
    hyperv/storvsc: storvsc_io_done(): do not use CAM_SEL_TIMEOUT

    CAM_SEL_TIMEOUT was introduced in
    https://reviews.freebsd.org/D7521 (r304251), which claimed:

    "VM shall response to CAM layer with CAM_SEL_TIMEOUT to filter those
    invalid LUNs. Never use CAM_DEV_NOT_THERE which will block LUN scan
    for LUN number higher than 7."

    But it turns out this is not correct:

    I think what really filters the invalid LUNs in r304251 is that:
    before r304251, we could set the CAM_REQ_CMP without checking
    vm_srb->srb_status at all:
    ccb->ccb_h.status |= CAM_REQ_CMP.

    r304251 checks vm_srb->srb_status and sets ccb->ccb_h.status properly,
    so the invalid LUNs are filtered.

    I changed my code version to r304251 but replaced the CAM_SEL_TIMEOUT
    with CAM_DEV_NOT_THERE, and I confirmed the invalid LUNs can also be
    filtered, and I successfully hot-added and hot-removed 8 disks to/from
    the VM without any issue.

    CAM_SEL_TIMEOUT has an unwanted side effect -- see cam_periph_error():
    For a selection timeout, we consider all of the LUNs on
    the target to be gone. If the status is CAM_DEV_NOT_THERE,
    then we only get rid of the device(s) specified by the
    path in the original CCB.

    This means: for a VM with a valid LUN on 3:0:0:0, when the VM inquires
    3:0:0:1 and the host reports 3:0:0:1 doesn't exist and storvsc returns
    CAM_SEL_TIMEOUT to the CAM layer, CAM will detech 3:0:0:0 as well: this
    is the bug I reported recently:
    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=226583

    PR:     226583
    Reviewed by:    mav
    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D14690
2018-04-24 03:07:49 +00:00
Glen Barber f207cb0eb4 MFC r332674:
Increase the msdosfs partition size on arm SoC images where the
 current size may not be sufficiently large for development and/or
 testing.

PR:		227548
Sponsored by:	The FreeBSD Foundation
2018-04-23 13:47:29 +00:00
Andriy Gapon 2f7a7476c8 MFC r331875: x86 cpu_reset: if failed to switch to BSP proceed to cpu_reset_real 2018-04-19 06:20:53 +00:00
Andriy Gapon 16c02ef01b MFC r331874: x86 cpu_reset_proxy: no need to stop_cpus() the original processor 2018-04-19 06:13:41 +00:00
Andriy Gapon 3ea3666fcb MFC r331616: vfs_donmount: in certain cases try r/o mount if r/w mount fails
If the operation is not an update, if neither r/w nor r/o mode is
explicitly requested, if the error code hints at the possibility of the
media being read-only, and if the fallback is allowed, then we can try
to automatically downgrade to the readonly mode.

This is especially useful for auto-mounting of removable media that
sometimes can happen to be write-protected.

The fallback to r/o is not enabled by default.  It can be requested on a
per-mount basis with a new mount option, 'autoro'.  Or it can be
globally allowed by setting vfs.default_autoro.

stable/10 note: this branch does not have SYSCTL_BOOL, so SYSCTL_INT is
used instead.

Relnotes:	yes
2018-04-19 05:52:47 +00:00
Pedro F. Giffuni d0c7b58516 MFC r328957:
{ext2|ufs}_readdir: Avoid setting negative ncookies.

ncookies cannot be negative or the allocator will fail. This should only
happen if a caller is very broken but we can still try to survive the
event.

We should probably also verify for uio_resid > MAXPHYS but in that case
it is not clear that just clipping the ncookies value is an adequate
response.
2018-04-19 02:50:15 +00:00
Ed Maste 05464b6be5 MFC r332452: Update vt(4) "Terminus BSD Console" font to v4.46
"Terminus BSD Console" is a derivative of Terminus that is provided
by Mr. Dimitar Zhekov under the 2-clause BSD license for use by the
FreeBSD vt(4) console and other BSDs.

PR:		227409
Sponsored by:	The FreeBSD Foundation
2018-04-19 00:50:51 +00:00
John Baldwin 39fa81c1d9 MFC 331466:
Add a workaround to the hypervisor detection for older versions of KVM.

Originally KVM set %eax to 0 in the cpuid leaf 0x4000000 rather than
to the highest supported leaf in the hypervisor "branch".  Detect this
case and fixup the %eax value so that the hypervisor is still
detected.
2018-04-19 00:11:02 +00:00
Glen Barber d893ef440d MFC r326278 (manu):
growfs: Commit the changes after expanding the partition

 This fix the problem in arm snapshot present since at least 6 months
 where growfs was failing at firstboot and dropped you in a single
 user shell.

Note: In addition to this merge, kern.geom.part.mbr.enforce_chs has
been enabled on the build machine to mitigate against the issue in
the PR referenced.

PR:		226536
Sponsored by:	The FreeBSD Foundation
2018-04-18 16:22:23 +00:00
Ed Maste 4d88e7e65e MFC r332421: vt: add three more cp437 mappings for vga textmode
In UTF-8 locales mandoc uses a number of characters outside of the Basic
Latin group, e.g. from general punctuation or miscellaneous mathematical
symbols, and these rendered as ? in text mode.

This change adds (char, replacement, code point, description):

    – - U+2013 En Dash
    ⟨ < U+27E8 Mathematical Left Angle Bracket
    ⟩ > U+27E9 Mathematical Right Angle Bracket

This change addresses some common cases; there are others that still
need to be added after a more thorough review.

PR:		227409
Sponsored by:	The FreeBSD Foundation
2018-04-17 12:52:30 +00:00
John Baldwin 5194e9ef37 MFC 331324: Ensure thread library is initialized in pthread_testcancel().
Call _thr_check_init() before reading curthread in pthread_testcancel().

If a constructor in a library creates a semaphore via sem_init() and
then waits for it via sem_wait(), the program can core dump in
_pthread_testcancel() called from sem_wait().  This is because the
semaphore implementation lives in libc, so the library's constructors
can be run before libthr's constructors.

Sponsored by:	DARPA / AFRL
2018-04-16 20:45:21 +00:00
Alan Somers 9affb5506f MFC r329606:
tail: fix "tail -r" for piped input that begins with '\n'

A subtle logic bug, probably introduced in r311895, caused tail to print the
first two lines of piped input in forward order, if the very first character
was a newline.

PR:		222671
Reported by:	Jim Long <[email protected]>, [email protected]
Sponsored by:	Spectra Logic Corp
2018-04-16 16:42:16 +00:00
Kristof Provost a723e73a6f MFC r331546:
pf: reload and resync do the same thing

The reload and resync commands for the startup script do exactly the same
thing, so implement one as a call to the other.
2018-04-16 16:02:54 +00:00
Kristof Provost 54685b7c71 MFC r332142:
pf: Improve ioctl validation

Ensure that multiplications for memory allocations cannot overflow, and
that we'll not try to allocate M_WAITOK for potentially overly large
allocations.
2018-04-14 00:20:47 +00:00
Kristof Provost c6075572ac MFC r332107:
pf: Improve ioctl validation for DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS and DIOCRSETTFLAGS

These ioctls can process a number of items at a time, which puts us at
risk of overflow in mallocarray() and of impossibly large allocations
even if we don't overflow.

Limit the allocation to required size (or the user allocation, if that's
smaller). That does mean we need to do the allocation with the rules
lock held (so the number doesn't change while we're doing this), so it
can't M_WAITOK.
2018-04-13 22:33:18 +00:00
Kristof Provost 56d0b89ecf MFC r332136:
pf: Improve ioctl validation for DIOCIGETIFACES and DIOCXCOMMIT

These ioctls can process a number of items at a time, which puts us at
risk of overflow in mallocarray() and of impossibly large allocations
even if we don't overflow.

There's no obvious limit to the request size for these, so we limit the
requests to something which won't overflow. Change the memory allocation
to M_NOWAIT so excessive requests will fail rather than stall forever.
2018-04-13 21:19:06 +00:00
Kristof Provost 02be584fa3 MFC r332101:
pf: Improve ioctl validation for DIOCRADDTABLES and DIOCRDELTABLES

The DIOCRADDTABLES and DIOCRDELTABLES ioctls can process a number of
tables at a time, and as such try to allocate <number of tables> *
sizeof(struct pfr_table). This multiplication can overflow. Thanks to
mallocarray() this is not exploitable, but an overflow does panic the
system.

Arbitrarily limit this to 65535 tables. pfctl only ever processes one
table at a time, so it presents no issues there.
2018-04-13 19:23:06 +00:00
Rodney W. Grimes 44e54b2a0c MFC: r332075
Exit with usage when extra arguments are on command line
preventing mistakes such as "halt 0p" for "halt -p".
Approved by:	bde (mentor, implicit), phk (mentor,implicit)
MFC after:	1 week
2018-04-13 03:47:41 +00:00
Glen Barber a92a229284 Document EN-18:03, EN-18:04, SA-18:04, SA-18:05.
Sponsored by:	The FreeBSD Foundation
2018-04-10 14:07:29 +00:00
Xin LI bf40c36a8a MFC r331180: Plug a possible memory leak. 2018-04-10 03:15:07 +00:00
Brooks Davis 25cf91628f MFC r332151:
ifconf(): correct handling of sockaddrs smaller than struct sockaddr.

Portable programs that use SIOCGIFCONF (e.g. traceroute) assume
that each pseudo ifreq is of length MAX(sizeof(struct ifreq),
sizeof(ifr_name) + ifr_addr.sa_len).  For short sockaddrs we copied
too much from the source sockaddr resulting in a heap leak.

I believe only one such sockaddr exists (struct sockaddr_sco which
is 8 bytes) and it is unclear if such sockaddrs end up on interfaces
in practice.  If it did, the result would be an 8 byte heap leak on
current architectures.

admbugs:	869
Reviewed by:	kib
Obtained from:	CheriBSD
Security:	kernel heap leak
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14981
2018-04-09 16:32:49 +00:00
Kristof Provost 7e72a2292c MFC r331225:
pf: Fix memory leak in DIOCRADDTABLES

If a user attempts to add two tables with the same name the duplicate table
will not be added, but we forgot to free the duplicate table, leaking memory.
Ensure we free the duplicate table in the error path.

Reported by:	Coverity
CID:		1382111
2018-04-09 15:29:14 +00:00
Ed Maste 3ceda8a315 MFC r331053: ANSIfy i386/vm86.c 2018-04-09 13:01:43 +00:00
Ed Maste 5b5a1b6f04 MFC r282920: vtfontcvt: Allow 6 digits in verbose output
Some fonts (e.g. GNU Unifont) have more than 100,000 (half-)glyphs.

Sponsored by:	The FreeBSD Foundation
2018-04-09 13:00:03 +00:00
Ed Maste 1ed304f570 MFC r296920: vtfontcvt: support .hex fonts with chars beyond Unicode BMP
This is already supported by the vt(4) vfnt format mapping from code
points to glyphs. Update the .hex font parser to accept up to six hex
digits.

Sponsored by:	The FreeBSD Foundation
2018-04-09 12:58:53 +00:00
Ed Maste e5e46708f5 MFC r331935: vtfontcvt: allow .bdf characters less than full height
Sponsored by:	The FreeBSD Foundation
2018-04-09 12:57:08 +00:00
Ed Maste 82c3f7f153 MFC r327529: ath: fix possible memory disclosure in ioctl handler
Submitted by:	Domagoj Stolfa <[email protected]>
2018-04-09 12:55:09 +00:00
Ed Maste 04af5acddf MFC ath(4) potential memory disclosure fixes
[1] r327499: ath: fix memory disclosure from ath_btcoex_ioctl

The ath_btcoex_ioctl handler allocated a buffer without M_ZERO and
returned it to userland without writing to it.

The device has permissions only for root so this is not urgent, and the
fix can be MFCd and considered for a future EN.

[2] r327500: ath: fix possible memory disclosures in ioctl handlers

Apply the fix from r327499 to additional ioctl handlers.

Note: related fix in r327529 does not apply directly to stable/10 and
will be addressed in a followup commit.

Submitted by:	Domagoj Stolfa <[email protected]> [1]
Reported by:	Ilja van Sprundel <[email protected]> [1,2]
Reviewed by:	adrian [1]
Sponsored by:	The FreeBSD Foundation
2018-04-09 12:53:15 +00:00
Brooks Davis 73c97f6fdf MFC r332087:
ifconf(): Always zero the whole struct ifreq.

The previous split of zeroing ifr_name and ifr_addr seperately is safe
on current architectures, but would be unsafe if pointers were larger
than 8 bytes. Combining the zeroing adds no real cost (a few
instructions) and makes the security property easier to verify.

Reviewed by:	kib, emaste
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14912
2018-04-08 17:23:33 +00:00
Brooks Davis 5a37d82bb2 MFC r331737:
GC never enabled support for SIOCGADDRROM and SIOCGCHIPID.

When de(4) was imported in 1997 the world was not ready for these ioctls.
In over 20 years that hasn't changed so it seems safe to assume their
time will never come.

Reviewed by:	imp, jhb
Approved by:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14889
2018-04-08 17:03:39 +00:00
Michael Tuexen e1d0fbf505 Fix an assignment to force the level to be in the required interval.
CID:		1008428
2018-04-08 16:29:24 +00:00
Michael Tuexen 61cdc217fe MFC r327205:
Fix an assignment. While there, do some whitespace cleanups.

CID:	1008936
2018-04-08 16:26:16 +00:00
Michael Tuexen caa78ee7f9 MFC r327203:
Allow the first (and second) argument of sn_calloc() be a sum.
This fixes a bug reported in
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224103

PR:		224103
2018-04-08 16:24:37 +00:00
Brooks Davis 433ef06769 MFC r331654, r331869
r331654:
Don't access userspace directly from the kernel in nxge(4).

Update to what the previous code seemed to be doing via the correct
interfaces.  Further issues exist in xge_ioctl_registers(), but this is
debugging code in a driver that has few users and they don't appear to
be crashes or leaks.

Reviewed by:	jhb (prior version)
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14848

r331869:
Fix the build on arches with default unsigned char.  Capture the fubyte()
return value in an int as well as the char, and test the full int value
for fubyte() failure.
2018-04-08 15:35:57 +00:00
Brooks Davis ca5f49ce75 MFC r331648:
Improve copy-and-pasted versions of SIOCGIFADDR.

The original implementation used a reference to ifr_data and a cast to
do the equivalent of accessing ifr_addr. This was copied multiple
times since 1996.

Approved by:	kib
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14873
2018-04-07 00:04:28 +00:00
Andriy Gapon 5edfd60f1d MFC r331761: align i386 cpu_reset() with amd64 version 2018-04-06 12:39:47 +00:00
Andriy Gapon 48f64bc427 MFC r330977: g_access: deal with races created by geoms that drop the topology lock
PR:		225960
2018-04-06 12:23:59 +00:00
Andriy Gapon 9c4776242d MFC r330295: ZFS: fix adding vdevs to very large pools
PR:		226096
2018-04-06 11:48:12 +00:00
Konstantin Belousov 8921ee42b3 MFC r331374:
Fixes for ptrace(PT_GETXSTATE_INFO) related to the padding in struct
ptrace_xstate_info).
2018-04-05 13:39:53 +00:00
Ed Maste 4fb0ed98f4 MFC r331757: Correct comment typo in Hyper-V
PR:		226665
Submitted by:	Ryo ONODERA
2018-04-05 12:59:49 +00:00
Ed Maste a811871ec0 MFC r332042: Fix kernel memory disclosure in linux_ioctl_socket
strlcpy is used to copy a string into a buffer to be copied to userland,
previously leaving uninitialized data after the terminating NUL.  Zero
the buffer first to avoid a kernel memory disclosure.

admbugs:	765, 811
Reported by:	Ilja Van Sprundel <[email protected]>
Reported by:	Vlad Tsyrklevich
Sponsored by:	The FreeBSD Foundation
2018-04-05 12:54:10 +00:00
Ed Maste 8b3b1b1e25 MFC r332034: linux_ioctl_hdio: fix kernel memory disclosure
Stack-allocated struct linux_hd_big_geometry has undeclared padding
copied to userland.

admbugs:	765
Reported by:	Vlad Tsyrklevich
Security:	Kernel memory disclosure
Sponsored by:	The FreeBSD Foundation
2018-04-05 12:50:47 +00:00
David C Somayajulu 8819836f05 MFC r331739
1. Add additional debug prints.
2. Break transmit when IFF_DRV_RUNNING is OFF.
3. set desc_count=0 for default case in switch in ql_rcv_isr()
2018-04-04 23:58:35 +00:00
Ed Maste a501da48ae Fix build: correct variable names on stable/10
r332032 merged r330356 from HEAD but did not account for a renamed
variable (of a different type) between stable/10 and HEAD.  Further
fix to r332036.
2018-04-04 17:45:05 +00:00
Ed Maste ed7ddd7c42 Fix build: use correct variable name on stable/10
r332032 merged r330356 from HEAD but did not account for a renamed
variable (of a different type) between stable/10 and HEAD.

Reported by:	lwhsu
2018-04-04 16:28:30 +00:00
Ed Maste 11f05a66ea MFC r330356 (eadler): sys/linux: Fix a few potential infoleaks in Linux IPC
admbugs:	765, 812, 813, 814
Submitted by:	Domagoj Stolfa <[email protected]>
Reported by:	Ilja Van Sprundel <[email protected]>
Reported by:	Vlad Tsyrklevich
2018-04-04 14:12:07 +00:00
Ed Maste b95c7d180b MFC r330354 (eadler): sys/fuse: fix off by one error
Reported by:	Ilja Van Sprundel <[email protected]>
Submitted by:	Domagoj Stolfa <[email protected]>
2018-04-04 13:16:00 +00:00
Hans Petter Selasky f0b861cb56 MFC r331642:
Add support for right and middle click with integrated button to WSP
USB trackpad driver.

Submitted by:	James Wright <[email protected]>
PR:		226961
Sponsored by:	Mellanox Technologies
2018-04-04 08:45:41 +00:00
Gordon Tetlow b215cd6eeb MFC r331981:
Limit glyph count in vtfont_load to avoid integer overflow.

Invalid font data passed to PIO_VFONT can result in an integer overflow
in glyphsize.  Characters may then be drawn on the console using glyph
map entries that point beyond the end of allocated glyph memory,
resulting in a kernel memory disclosure.

Submitted by:   emaste
Reported by:    Dr. Silvio Cesare of InfoSect
Security:       CVE-2018-6917
Security:       FreeBSD-SA-18:04.vt
Sponsored by:   The FreeBSD Foundation
2018-04-04 05:26:33 +00:00
Eugene Grosbein e7c4d54206 MFC r331630: Fix instructions in the zfsboot manual page.
zfsloader(8) fails to probe a slice containing ZFS pool if its second sector
contains traces of BSD label (DISKMAGIC == 0x82564557).
Fix manual page to show working example erasing such traces.
2018-04-03 14:09:34 +00:00
Andriy Gapon 3cc02c5153 MFC r327056: Use resume_cpus() instead of restart_cpus() to resume from ACPI suspension.
The merge needed fixing because common x86 code changed by the original
commit is still split between i386 and amd64 in this branch.
2018-04-03 07:52:06 +00:00
Glen Barber 0dfc0c25e1 MFC r331806:
Add logic for "families" for GCE images.

 This allows for GCE consumers to easily detect the latest major
 version of FreeBSD when using the gcloud command line utility.

 To ensure snapshot builds do not conflict with release-style
 builds (ALPHA, BETA, RC, RELEASE), the '-snap' suffix is appended
 to the GCE image family name.

Sponsored by:	The FreeBSD Foundation
2018-04-02 13:25:38 +00:00
Glen Barber a52b07c434 MFC r331696, r331697:
r331696:
  Update the Release Engineering article URL to the modern version.

 r331697:
  Add an example for building SD card images for the RPI-B and RPI3.

Note, this commit manually fixes a merge conflict caused by r325096,
which does a seemingly recursive http -> https update, which this
commit was never marked for MFC.

Sponsored by:	The FreeBSD Foundation
2018-03-31 01:37:14 +00:00
Ed Maste 06e5649477 MF11 r331330: Fix kernel memory disclosure in svr4_sys_getdents64
svr4_sys_getdents64() copies a dirent structure to userland.  When
calculating the record length for any given dirent entry alignment is
performed.  However, the aligned bytes are not cleared, this will
trigger an info leak.

Reported by:	Ilja Van Sprundel <[email protected]>
Security:	Kernel memory disclosure (801)
Sponsored by:	The FreeBSD Foundation
2018-03-29 22:31:14 +00:00
Glen Barber 6c1c9b93f0 MFC r331562 (manu):
release: arm: Copy boot.scr from ports

 Latest u-boot update need u-boot script to load and start ubldr.
 (See D14230 for more details)
 Copy this file for our arm release on the fat partition.
2018-03-29 19:29:12 +00:00
Ravi Pokala 22e135fe1f MFC 331345:
jedec_dimm: Use correct string length when populating sc->slotid_str

Don't limit the copy to the size of the target string *pointer* (always
4 on 32-bit / 8 on 64-bit). Instead, just use strdup().
2018-03-29 15:01:01 +00:00
Navdeep Parhar 4d5f734036 MFC r323006 and r324386.
This brings the cxgbe(4) firmware up to 1.16.63.0.

Sponsored by:	Chelsio Communications
2018-03-29 01:20:58 +00:00
Glen Barber 06c99c13aa MFC r331559:
Escape trailing newlines in a long variable list for consistency.

Sponsored by:	The FreeBSD Foundation
2018-03-29 00:42:44 +00:00
Ed Maste 628d6851bc MFC r331329: Fix kernel memory disclosure in ibcs2_getdents
ibcs2_getdents() copies a dirent structure to userland.  The ibcs2
dirent structure contains a 2 byte pad element.  This element is never
initialized, but copied to userland none-the-less.

Note that ibcs2 has not built on HEAD since r302095.

Submitted by:	Domagoj Stolfa <[email protected]>
Reported by:	Ilja Van Sprundel <[email protected]>
Security:	Kernel memory disclosure (803)
Sponsored by:	The FreeBSD Foundation
2018-03-28 13:44:02 +00:00
Philip Paeps 1aca79159f MFC r331481: Import tzdata 2018d 2018-03-28 07:45:57 +00:00
John Baldwin a7fb74bb3a MFC 318387: Add support for child devices that aren't ports.
Invoke any identify routines of child drivers during attach before attaching
children, and delete any remaining devices after deleting ports.

Sponsored by:	Chelsio Communications
2018-03-27 20:49:47 +00:00
Brooks Davis 6df14957a8 MFC r330949:
Fix FSACTL_GET_NEXT_ADAPTER_FIB under 32-bit compat.

This includes FSACTL_LNX_GET_NEXT_ADAPTER_FIB.

Reviewed by:	cem
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14672
2018-03-27 17:52:52 +00:00
Brooks Davis a89be2aa86 MFC r330876, r330945
r330876:
Fix ISP_FC_LIP and ISP_RESCAN on big-endian 64-bit systems.

For _IO() ioctls, addr is a pointer to uap->data which is a caddr_t.
When the caddr_t stores an int, dereferencing addr as an (int *) results
in truncation on little-endian 64-bit systems and corruption (owing to
extracting top bits) on big-endian 64-bit systems. In practice the
value of chan was probably always zero on systems of the latter type as
all such FreeBSD platforms use a register-based calling convention.

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

r330945:
Add opt_compat.h to isp(4) as required by r330876.
2018-03-27 17:48:39 +00:00
Brooks Davis cc8dd83672 MFC r330820:
Reject ioctls to SCSI enclosures from 32-bit compat processes.

The ioctl objects contain pointers and require translation and some
refactoring of the infrastructure to work. For now prevent opertion
on garbage values. This is very slightly overbroad in that ENCIOC_INIT
is safe.

Reviewed by:	imp, kib
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14671
2018-03-27 17:43:03 +00:00
Brooks Davis 20d2818692 MFC r330819, r330885, r330934
r330819:
Reject CAMIOGET and CAMIOQUEUE ioctl's on pass(4) in 32-bit compat mode.

These take a union ccb argument which is full of kernel pointers.
Substantial translation efforts would be required to make this work.
By rejecting the request we avoid processing or returning entierly
wrong data.

Reviewed by:	imp, ken, markj, cem
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14654

r330885:
We need opt_compat.h after r330819 and 330820.

Add opt_compat.h to fix the stand-alone build case.

Sponsored by: Netflix.

r330934:
This should have been += so clean builds work.

Noticed by: hps@
2018-03-27 17:42:04 +00:00
Andriy Gapon 381e7cc38e MFC r330974: MFV r330973: 9164 assert: newds == os->os_dsl_dataset
PR:		225877
2018-03-27 11:34:34 +00:00
Glen Barber b4061ddd30 MFC r331364:
Remove google_accounts_manager from VM_RC_LIST in the GCE configuration
 file, no longer needed.

PR:		221714
Sponsored by:	The FreeBSD Foundation
2018-03-26 14:13:42 +00:00
Sevan Janiyan c501b0c093 MFC r322665
Add caveat to kinfo_getvmmap(3) explaining high CPU utilisation.
Based on kib's reply on https://lists.freebsd.org/pipermail/freebsd-hackers/2016-July/049710.html
2018-03-25 01:33:51 +00:00
Sevan Janiyan 5d4943f8dc MFC r316464
Whilst mount_pcfs originated as a patch in 386BSD, NetBSD 0.8 actually
was the first release of an OS to ship with it.
Heads up by Ingo Schwarze.
2018-03-25 01:31:16 +00:00
Sevan Janiyan feb7ff9aec MFC 321881
For the udp-client example, instruct user to add an entry for a udp based
service.
For tcp-client & udp-client, use the same port in configuration snippet as used
in the comment prior to remove any ambiguity on the port number which needs to
be specified.
2018-03-25 01:24:02 +00:00
Sevan Janiyan 5a072c9a88 MFC r316721 r331274
Most wireless drivers don't support altq(4).

Extend the description of ALTQ to call it a system which is a framework in
altq(4) to match altq(9). This makes preserving the history section as the
author of ALTQ easier in the history section, rather than calling it a framework
in the description & a system in the history.
Add a history section to altq(4) and extend the history section in altq(9)
2018-03-25 01:17:40 +00:00
John Baldwin ed527c8787 MFC 330872:
Add a "jail" keyword to list the name of a jail rather than its ID.
2018-03-24 00:26:42 +00:00
Ed Maste 1b6662f36d MFC r331333: Fix kernel memory disclosure in drm_infobufs
drm_infobufs() has a structure on the stack, fills it out and copies it
to userland.  There are 2 elements in the struct that are not filled out
and left uninitialized.  This will leak uninitialized kernel stack data
to userland.

Submitted by:	Domagoj Stolfa <[email protected]>
Reported by:	Ilja Van Sprundel <[email protected]>
Security:	Kernel memory disclosure (798)
2018-03-23 02:38:31 +00:00
Ed Maste 96b517ab52 MFC r331339: Correct signedness bug in drm_modeset_ctl
drm_modeset_ctl() takes a signed in from userland, does a boundscheck,
and then uses it to index into a structure and write to it.  The
boundscheck only checks upper bound, and never checks for nagative
values.  If the int coming from userland is negative [after conversion]
it will bypass the boundscheck, perform a negative index into an array
and write to it, causing memory corruption.

Note that this is in the "old" drm driver; this issue does not exist
in drm2.

Reported by:	Ilja Van Sprundel <[email protected]>
Reviewed by:	cem
Sponsored by:	The FreeBSD Foundation
2018-03-23 02:34:45 +00:00
Glen Barber 9b9ef2ecc7 MFC r322794:
Use py-google-compute-engine instead for releasing Google Compute
 Engine (GCE) images with an updated version of Google's tools.

PR:		221714
Sponsored by:	The FreeBSD Foundation
2018-03-22 17:46:38 +00:00
Ed Maste 76a9d2da93 MFC r330668: bktr: correct Japan IF frequency
PR:		36451
Submitted by:	Hijiri Umemoto <hijiri at umemoto.org>
2018-03-22 00:55:36 +00:00
Navdeep Parhar 5742aac648 MFC r328315:
cxgb(4): Validate offset/len in the GET_EEPROM ioctl.

Sponsored by:	Chelsio Communications.
2018-03-21 20:13:24 +00:00
Andriy Gapon 2b176099ef MFC r330793: fix r297857, do not modify CPU extension bits under virtual machines
PR:		213155
2018-03-21 15:13:47 +00:00
Andriy Gapon bf33ee0982 MFC r330374: db_script_exec: use a saved script name when reporting commands executed 2018-03-21 15:05:45 +00:00
Kristof Provost 706d8bfe11 MFC 330105:
pf: Do not flush on reload

pfctl only takes the last '-F' argument into account, so this never did what
was intended.

Moreover, there is no reason to flush rules before reloading, because pf keeps
track of the rule which created a given state. That means that existing
connections will keep being processed according to the rule which originally
created them. Simply reloading the (new) rules suffices. The new rules will
apply to new connections.

PR:		127814
Submitted by:	Andreas Longwitz <longwitz at incore.de>
2018-03-21 09:57:29 +00:00
Kristof Provost 9fada12683 MFC r330108:
pf: Apply $pf_flags when verifying the pf.conf file

When checking the validity of the pf.conf file also include the user supplied
pf_flags. These flags might overrule macros or specify anchors, which we will
apply when actually applying the pf.conf file, so we must also take them into
account when verifying the validity.

Submitted by:	Andreas Longwitz <longwitz at incore.de>
2018-03-21 09:55:49 +00:00
Ian Lepore c595080630 MFC r330745:
Make root mount timeout logic work for filesystems other than ufs.

The vfs.mountroot.timeout tunable and .timeout directive in a mount.conf(5)
file allow specifying a wait timeout for the device(s) hosting the root
filesystem to become usable.  The current mechanism for waiting for devices
and detecting their availability can't be used for zfs-hosted filesystems.
See the comment #20 in the PR for some expanded detail on these points.

This change adds retry logic to the actual root filesystem mount.  That is,
insted of relying on device availability using device name lookups, it uses
the kernel_mount() call itself to detect whether the filesystem can be
mounted, and loops until it succeeds or the configured timeout is exceeded.

These changes are based on the patch attached to the PR, but it's rewritten
enough that all mistakes belong to me.

PR:		208882
2018-03-20 22:57:14 +00:00
David Bright 7967f8d10e MFC r331015:
Modify rc.d/fsck to handle new status from fsck/fsck_ffs

r328013 introduced a new error code from fsck_ffs that indicates that
it could not completely fix the file system; this happens when it
prints the message PLEASE RERUN FSCK. However, this status can happen
when fsck is run in "preen" mode and the rc.d/fsck script does not
handle that error code. Modify rc.d/fsck so that if "fsck -p"
("preen") returns the new status code (16) it will run "fsck -y", as
it currently does for a status code of 8 (the "standard error exit").

Reported by:    markj
Sponsored by:   Dell EMC
2018-03-19 17:38:35 +00:00
Marius Strobl 8b6ce1cb07 MFC: r328834
o Let rtld(1) set up psABI user trap handlers prior to executing the
  objects' init functions instead of doing the setup via a constructor
  in libc as the init functions may already depend on these handlers
  to be in place. This gets us rid of:
  - the undefined order in which libc constructors as __guard_setup()
    and jemalloc_constructor() are executed WRT __sparc_utrap_setup(),
  - the requirement to link libc last so __sparc_utrap_setup() gets
    called prior to constructors in other libraries (see r122883).
  For static binaries, crt1.o still sets up the user trap handlers.
o Move misplaced prototypes for MD functions in to the MD prototype
  section of rtld.h.
o Sprinkle nitems().
2018-03-19 14:28:58 +00:00
Andrey V. Elsukov f9492aa77d MFC r330792:
Do not try to reassemble IPv6 fragments in "reass" rule.

  ip_reass() expects IPv4 packet and will just corrupt any IPv6 packets
  that it gets. Until proper IPv6 fragments handling function will be
  implemented, pass IPv6 packets to next rule.

  PR:		170604
2018-03-19 09:54:16 +00:00
Kristof Provost 67bccbc52f MFC r329950:
pf: Cope with overly large net.pf.states_hashsize

If the user configures a states_hashsize or source_nodes_hashsize value we may
not have enough memory to allocate this. This used to lock up pf, because these
allocations used M_WAITOK.

Cope with this by attempting the allocation with M_NOWAIT and falling back to
the default sizes (with M_WAITOK) if these fail.

PR:		209475
Submitted by:	Fehmi Noyan Isi <fnoyanisi AT yahoo.com>
2018-03-18 11:26:07 +00:00
Eugene Grosbein 3a10f779f6 MFC r329279: add support for user-supplied Host-Uniq tag to ng_pppoe(4).
Submitted by:		ale
Approved by:		mav (mentor)
Relnotes:		yes
Differential Revision:	https://reviews.freebsd.org/D9270
2018-03-16 15:10:13 +00:00
Marius Strobl 452b20c336 MFC: r327929
Use the correct revision specifier (EXT_CSD revision rather than
system specification version) for deciding whether the EXT_CSD
register includes the EXT_CSD_GEN_CMD6_TIME field.

Submitted by:	Masanobu SAITOH
2018-03-15 23:02:52 +00:00
Marius Strobl 5df0c346de MFC: r327355, r327926
- Don't allow userland to switch partitions; it's next to impossible
  to recover from that, especially when something goes wrong.
- When userland changes EXT_CSD, update the kernel copy before using
  relevant EXT_CSD bits in mmcsd_switch_part().
2018-03-15 23:01:04 +00:00
Marius Strobl 3bc99eb5ce MFC: r327339, r327924
- There is no need to keep the tuning error and re-tuning interrupts
  enabled (though, no interrupt generation enabled for them) all the
  time as soon as (re-)tuning is supported; only enable them and let
  them generate interrupts when actually using (re-)tuning.
- Also disable all interrupts except SDHCI_INT_DATA_AVAIL ones while
  executing tuning and not just their signaling.
- Set the tuning error and re-tuning interrupt enable bits based on
  the SDHCI_TUNING_ENABLED rather than the SDHCI_TUNING_SUPPORTED flag,
  i. e. only when (re-)tuning is actually used. Currently, this change
  makes no net difference, though.
2018-03-15 22:58:34 +00:00
Marius Strobl b14e2d703d MFC: r327315
Add quirks for Intel Denverton eMMC 5.0 controllers.
2018-03-15 22:51:13 +00:00
Marius Strobl ffee24b918 MFC: r287805
Unconditionally build CTF tools in the bootstrap-tools phase of the build.

Stale CTF tools are a frequent source of DTrace issues, and they compile
quickly enough that the increase in build time is negligible.

Apart from what's described in the original commit message above, this
change also fixes building GENERIC kernels, i. e. kernel configurations
having "makeoptions WITH_CTF=1", when the host world has been built with
WITHOUT_CDDL.
2018-03-15 22:42:28 +00:00
Andriy Gapon 420d7ed050 MFC r330057: add ZFS_ENTER protection to .zfs/snapshot vnode operations that need it 2018-03-15 11:04:30 +00:00
Andriy Gapon eb3e898c97 MFC r322245,r329717: MFV r322242: 8373 TXG_WAIT in ZIL commit path
MFC r322245: MFV r322242: 8373 TXG_WAIT in ZIL commit path
MFC r329717: MFV r329715: 8997 ztest assertion failure in zil_lwb_write_issue
2018-03-15 11:00:55 +00:00
Ed Maste 8ce48994fd MFC r330667: asmc: update temperature sensor name/description
PR:		225911
Submitted by:	Trev
2018-03-15 00:44:34 +00:00
Marius Strobl dd97a72c7b MFC: 327314
With the advent of interrupt remapping, Intel has repurposed bit 11
(now: Interrupt_Index[15]) and assigned the previously reserved bits
55:48 (Interrupt_Index[14:0] goes into 63:49 while Destination Field
used 63:56 and bit 48 now is Interrupt_Format) in the IO redirection
tables (see the VT-d specification, "5.1.5.1 I/OxAPIC Programming").
Thus, when not using interrupt remapping, ensure that all previously
reserved bits in the high part of the RTEs are zero instead of doing
a read-modify-write for their Destination Field bits only.
Otherwise, on machines based on Apollo Lake and its derivatives such
as Denverton, typically some of the previously preserved bits remain
set after boot when not employing interrupt remapping. The result is
that INTx interrupts are not getting delivered.
Note: With an AMD IOMMU, interrupt remapping apparently bypasses the
IO APIC altogether.

Submitted by:	loos (modulo comment)
Reviewed by:	jhb (modulo comment)
2018-03-14 23:59:52 +00:00
John Baldwin b8fe4c6eb8 Convert pci_delete_child() to a bus_child_deleted() method.
Instead of providing a wrapper around device_delete_child() that the PCI
bus and child bus drivers must call explicitly, move the bulk of the logic
from pci_delete_child() into a bus_child_deleted() method
(pci_child_deleted()).  This allows PCI devices to be safely deleted via
device_delete_child().
- Add a bus_child_deleted method to the ACPI PCI bus which clears the
  device_t associated with the corresponding ACPI handle in addition to
  the normal PCI bus cleanup.
- Change cardbus_detach_card to call device_delete_children() and move
  CardBus-specific delete logic into a new cardbus_child_deleted() method.
- Use device_delete_child() instead of pci_delete_child() in the SRIOV code.
- Add a bus_child_deleted method to the OpenFirmware PCI bus drivers which
  frees the OpenFirmware device info for each PCI device.

To preserve KBI, a pci_delete_child() function is left in place that
just calls device_delete_child().

PR:		226562
Requested by:	dexuan
2018-03-14 19:04:40 +00:00
Eugene Grosbein cac711d89e MFC r329105: ppp(8): fix code producing debugging logs
ppp(8): fix code producing debugging logs

  Fix several cases when long buffer is copied to shorter one
  using snprintf that results in contents truncation and
  clobbering unsaved errno value and creation of misleading logs.

PR:		218517
Approved by:	mav (mentor)
2018-03-12 17:37:38 +00:00
Brooks Davis a6b664ed92 MFC r330409:
Refer to SysV IPC permissions as numeric constants.

POSIX defines no macros for these permissions.

Also remove unneeded headers from synopsis.

PR:		225905
Reviewed by:	wblock
Differential Revision:	https://reviews.freebsd.org/D14461
2018-03-12 16:04:10 +00:00
Alan Somers 69be211061 MFC r323314, r323338, r328849
r323314:
Audit userspace geom code for leaking memory to disk

Any geom class using g_metadata_store, as well as geom_virstor which
duplicated g_metadata_store internally, would dump sectorsize - mdsize bytes
of userspace memory following the metadata block stored. This is most or all
geom classes (gcache, gconcat, geli, gjournal, glabel, gmirror, gmultipath,
graid3, gshsec, gstripe, and geom_virstor).

PR:		222077 (comment #3)
Reported by:	Maxim Khitrov <max AT mxcrypt.com>
Reviewed by:	des
Security:	yes
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12269

r323338:
Fix information leak in geli(8) integrity mode

In integrity mode, a larger logical sector (e.g., 4096 bytes) spans several
physical sectors (e.g., 512 bytes) on the backing device.  Due to hash
overhead, a 4096 byte logical sector takes 8.5625 512-byte physical sectors.
This means that only 288 bytes (256 data + 32 hash) of the last 512 byte
sector are used.

The memory allocation used to store the encrypted data to be written to the
physical sectors comes from malloc(9) and does not use M_ZERO.

Previously, nothing initialized the final physical sector backing each
logical sector, aside from the hash + encrypted data portion.  So 224 bytes
of kernel heap memory was leaked to every block :-(.

This patch addresses the issue by initializing the trailing portion of the
physical sector in every logical sector to zeros before use.  A much simpler
but higher overhead fix would be to tag the entire allocation M_ZERO.

PR:		222077
Reported by:	Maxim Khitrov <max AT mxcrypt.com>
Reviewed by:	emaste
Security:	yes
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12272

r328849:
geom: don't write stack garbage in disk labels

Most consumers of g_metadata_store were passing in partially unallocated
memory, resulting in stack garbage being written to disk labels. Fix them by
zeroing the memory first.

gvirstor repeated the same mistake, but in the kernel.

Also, glabel's label contained a fixed-size string that wasn't
initialized to zero.

PR:		222077
Reported by:	Maxim Khitrov <[email protected]>
Reviewed by:	cem
X-MFC-With:	323314
X-MFC-With:	323338
Differential Revision:	https://reviews.freebsd.org/D14164
2018-03-10 04:17:01 +00:00
Alan Somers 82265f38cc MFC r329265, r329384
r329265:
Implement .vop_pathconf and .vop_getacl for the .zfs ctldir

zfsctl_common_pathconf will report all the same variables that regular ZFS
volumes report. zfsctl_common_getacl will report an ACL equivalent to 555,
except that you can't read xattrs or edit attributes.

Fixes a bug where "ls .zfs" will occasionally print something like:
ls: .zfs/.: Operation not supported

PR:		225793
Reviewed by:	avg
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D14365

r329384:
Handle generic pathconf attributes in the .zfs ctldir

MFC instructions: change the value of _PC_LINK_MAX to INT_MAX

Reported by:	jhb
X-MFC-With:	329265
Sponsored by:	Spectra Logic Corp
2018-03-10 04:10:57 +00:00
Alan Somers 8a969370c0 MFC r329067:
Fix "zpool add" crash when a replacing vdev has a spare child

Fix an assertion in zpool that causes a crash when running any "zpool add"
command on a spare that contains a replacing vdev with a spare child.

This likely affects Illumos, too.

PR:		225546
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D14138
2018-03-10 04:02:51 +00:00
Tycho Nightingale 7071d6577f MFC r328011,329162
r328011:

Provide some mitigation against CVE-2017-5715 by clearing registers
upon returning from the guest which aren't immediately clobbered by
the host.  This eradicates any remaining guest contents limiting their
usefulness in an exploit gadget.

r329162:

Provide further mitigation against CVE-2017-5715 by flushing the
return stack buffer (RSB) upon returning from the guest.
2018-03-10 00:44:33 +00:00
Ed Maste 8751aec202 MFC r285885 by brueffer:
In tmpfs_chtimes(), remove checks on the nanosecond level when
determining whether a node changed.

Other filesystems, e.g., UFS, only check on seconds, when determining
whether something changed.

This also corrects the birthtime case, where we checked tv_nsec
twice, instead of tv_sec and tv_nsec (PR).

PR:		201284
2018-03-09 17:59:22 +00:00
David Bright f17c8115ca MFC r330245:
Allow the "@" and "!" characters in passwd file GECOS fields.

Two PRs (152084 & 210187) request allowing the "@" and/or "!"
characters in the passwd file GECOS field. The man page for pw does
not mention that those characters are disallowed, Linux supports those
characters in this field, and the "@" character in particular would be
useful for storing email addresses in that field.

PR:             152084, 210187
Submitted by:   [email protected], Dave Cottlehuber <[email protected]>
Reported by:    [email protected], Dave Cottlehuber <[email protected]>
Sponsored by:   Dell EMC
2018-03-09 14:45:47 +00:00
David Bright 3f63e58efb MFC r330085:
dhclient violates RFC2131 when sending early DHCPREQUEST message to re-obtain old IP

When dhclient first starts, if an old IP address exists in the
dhclient.leases file, dhclient(8) sends early DHCPREQUEST message(s)
in an attempt to re-obtain the old IP address again. These messages
contain the old IP as a requested-IP-address option in the message
body (correct) but also use the old IP address as the packet's source
IP (incorrect).

RFC2131 sec 4.1 states:

  DHCP messages broadcast by a client prior to that client obtaining
  its IP address must have the source address field in the IP header
  set to 0.

The use of the old IP as the packet's source address is incorrect if
(a) the computer is now on a different network or (b) it is on the
same network, but the old IP has been reallocated to another host.

Fix dhclient to use 0.0.0.0 as the source IP in this circumstance
without removing any existing functionality. Any previously-used old
IP is still requested in the body of an early DHCPREQUEST message.

PR:             199378
Submitted by:   J.R. Oldroyd <[email protected]>
Reported by:    J.R. Oldroyd <[email protected]>
Sponsored by:   Dell EMC
2018-03-09 14:39:28 +00:00
Ravi Pokala c3a609fe16 MFC r330304: imcsmb(4): Intel integrated Memory Controller (iMC) SMBus
controller driver

imcsmb(4) provides smbus(4) support for the SMBus controller functionality
in the integrated Memory Controllers (iMCs) embedded in Intel Sandybridge-
Xeon, Ivybridge-Xeon, Haswell-Xeon, and Broadwell-Xeon CPUs. Each CPU
implements one or more iMCs, depending on the number of cores; each iMC
implements two SMBus controllers (iMC-SMBs).

*** IMPORTANT NOTE ***
Because motherboard firmware or the BMC might try to use the iMC-SMBs for
monitoring DIMM temperatures and/or managing an NVDIMM, the driver might
need to temporarily disable those functions, or take a hardware interlock,
before using the iMC-SMBs. Details on how to do this may vary from board to
board, and the procedure may be proprietary. It is strongly suggested that
anyone wishing to use this driver contact their motherboard vendor, and
modify the driver as described in the manual page and in the driver itself.
(For what it's worth, the driver as-is has been tested on various SuperMicro
motherboards.)
2018-03-09 02:55:27 +00:00
Brooks Davis c89dc0f0aa MFC r330527:
Use umtx_copyin_umtx_time32() in __umtx_op_lock_umutex_compat32().

Non-NULL timeouts where copied in improperly and could produce failures
due to incompatible data structures.

Reviewed by:	kib
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14587
2018-03-09 01:21:22 +00:00
David Bright f7592a911b MFC r330034
Fix a memory leak in syslogd

A memory leak in syslogd for processing of forward actions was
reported. This modification adapts the patch submitted with that bug
to fix the leak.

PR:		198385
Submitted by:	Sreeram <[email protected]>
Reported by:	Sreeram <[email protected]>
Sponsored by:	Dell EMC
2018-03-08 17:14:16 +00:00
Gordon Tetlow 2a9efdcd88 Fixup the AH patch to properly compile. 2018-03-07 16:55:15 +00:00
Glen Barber daa3b84da6 Document EN-18:01, EN-18:02, SA-18:01, SA-18:02.
Sponsored by:	The FreeBSD Foundation
2018-03-07 15:02:13 +00:00
Andriy Gapon 6c1567718b MFC r329714: MFV r329713: 8731 ASSERT3U(nui64s, <=, UINT16_MAX) fails for large blocks 2018-03-07 13:40:15 +00:00
Xin LI 2c8b1e4df3 MFC r316339,317396,317829,326010,329554: less v530.
Relnotes:	yes
2018-03-07 06:39:00 +00:00
Gordon Tetlow 7121827ae6 Port r329561 to stable/10. There were structural changes preventing MFC.
Check packet length to not make an out of bounds access. Also, save ah_nxt
value to use later, since the ah pointer can become invalid.

Reviewed by:	ae@
Approved by:	so
Security:	CVE-2018-6916
Security:	FreeBSD-SA-18:01.ipsec
2018-03-07 05:47:48 +00:00
David C Somayajulu b93d482bef MFC r329855
1. Added support to offline a port if is error recovery on successful.
  2. Sysctls to enable/disable driver_state_dump and error_recovery.
  3. Sysctl to control the delay between hw/fw reinitialization and
     restarting the fastpath.
  4. Stop periodic stats retrieval if interface has IFF_DRV_RUNNING flag off.
  5. Print contents of PEG_HALT_STATUS1 and PEG_HALT_STATUS2 on heartbeat
     failure.
  6. Speed up slowpath shutdown during error recovery.
  7. link_state update using atomic_store.
  8. Added timestamp information on driver state and minidump captures.
  9. Added support for Slowpath event logging
  10.Added additional failure injection types to simulate failures.
2018-03-06 23:17:56 +00:00
Alan Somers d9118dd9d5 MFC r324940:
Fix the error message when creating a zpool on a too-small device

Don't check for SPA_MINDEVSIZE in vdev_geom_attach when opening by path.
It's redundant with the check in vdev_open, and failing to attach here
results in the wrong error message being printed.  However, still check for
it in some other situations:

* When opening by guids, so we don't get bogged down reading from slow
  devices like floppy drives.
* In vdev_geom_read_pool_label for the same reason, because we iterate over
  all providers.
* If the caller requests that we verify the guid, because then we'll have to
  read from the device before vdev_open verifies the size.

PR:		222227
Reported by:	Marie Helene Kvello-Aune <[email protected]>
Reviewed by:	avg, mav
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D12531
2018-03-05 20:43:43 +00:00
Alan Somers e3ae308bf6 MFC r326401:
Fix assertion when ZFS fails to open certain devices

"panic: vdev_geom_close_locked: cp->private is NULL"
This panic will result if ZFS fails to open a device due to either of the
following reasons:

1) The device's sector size is greater than 8KB.
2) ZFS wants to open the device RW, but it can't be opened for writing.

The solution is to change the initialization order to ensure that the
assertion will be satisfied.

PR:		221066
Reported by:	David NewHamlet <[email protected]>
Reviewed by:	avg
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D13278
2018-03-05 20:28:49 +00:00
Alan Somers 1998724852 MFC r320726, r320727
r320726:
Expect :snprintf_float to segfault

This issue started occurring within the past month or so.

PR:   220502
Reported by:  Jenkins (amd64-head job)

r320727:
:snprintf_float: don't blindly set RLIMIT_DATA and RLIMIT_AS to 1 MB -- raise
the limit to 32MB instead.

Require user=root and memory=64MB+ first so one can be reasonably sure that
the test will function appropriately.

MFC with:     r320726
PR:   220502
2018-03-05 19:02:32 +00:00
David Bright 9dc4844cc8 MFC r330027
iconv uses strlen directly on user supplied memory

`iconv_sysctl_add` from `sys/libkern/iconv.c` incorrectly limits the
size of user strings, such that several out of bounds reads could have
been possible.

static int
iconv_sysctl_add(SYSCTL_HANDLER_ARGS)
{
	struct iconv_converter_class *dcp;
	struct iconv_cspair *csp;
	struct iconv_add_in din;
	struct iconv_add_out dout;
	int error;

	error = SYSCTL_IN(req, &din, sizeof(din));
	if (error)
		return error;
	if (din.ia_version != ICONV_ADD_VER)
		return EINVAL;
	if (din.ia_datalen > ICONV_CSMAXDATALEN)
		return EINVAL;
	if (strlen(din.ia_from) >= ICONV_CSNMAXLEN)
		return EINVAL;
	if (strlen(din.ia_to) >= ICONV_CSNMAXLEN)
		return EINVAL;
	if (strlen(din.ia_converter) >= ICONV_CNVNMAXLEN)
		return EINVAL;
...

Since the `din` struct is directly copied from userland, there is no
guarantee that the strings supplied will be NULL terminated. The
`strlen` calls could continue reading past the designated buffer
sizes.

Declaration of `struct iconv_add_in` is found in `sys/sys/iconv.h`:

struct iconv_add_in {
	int	ia_version;
	char	ia_converter[ICONV_CNVNMAXLEN];
	char	ia_to[ICONV_CSNMAXLEN];
	char	ia_from[ICONV_CSNMAXLEN];
	int	ia_datalen;
	const void *ia_data;
};

Our strings are followed by the `ia_datalen` member, which is checked
before the `strlen` calls:

if (din.ia_datalen > ICONV_CSMAXDATALEN)

Since `ICONV_CSMAXDATALEN` has value `0x41000` (and is `unsigned`),
this ensures that `din.ia_datalen` contains at least 1 byte of 0, so
it is not possible to trigger a read out of bounds of the `struct`
however, this code is fragile and could introduce subtle bugs in the
future if the `struct` is ever modified.

PR:		207302
Submitted by:	CTurt <[email protected]>
Reported by:	CTurt <[email protected]>
Sponsored by:	Dell EMC
2018-03-05 16:00:05 +00:00
Eugene Grosbein 06df31c975 MFC r329994: mac_portacl(4): stop panicing INVARIANTS-enabled kernel by loading .ko
when kernel already has options MAC_PORTACL.

PR:		183817
Approved by:	avg (mentor)
2018-03-05 12:21:36 +00:00
Eugene Grosbein b5e2ba045d MFC r329930: route(8): make it possible to manually delete pinned route
Reported by:	Andreas Longwitz <[email protected]>
Approved by:	avg (mentor)
2018-03-05 12:06:41 +00:00
Bryan Drewery e0aa5ae9f3 MFC r325776:
Rework r325568 so all 'make LINT' targets work.
2018-03-04 23:36:58 +00:00
Bryan Drewery 539b0ac223 MFC r330127:
Allow overriding .MAKE.MAKEFILE_PREFERENCE.
2018-03-04 23:34:04 +00:00
Bryan Drewery 174ae18539 MFC r329271:
nanosleep(2): Fix bogus incrementing of rmtp by tc_tick_sbt on [EINTR].
2018-03-04 23:31:25 +00:00
Xin LI 9e402adfae Document SA-17:12 and correct EN-17:09 link [1]
Reported by:	eadler [1]
2018-03-03 08:52:02 +00:00
John Baldwin 50d2595378 MFC 328608: Export tcp_always_keepalive for use by the Chelsio TOM module.
This used to work by accident with ld.bfd even though always_keepalive
was marked as static. LLD honors static more correctly, so export this
variable properly (including moving it into the tcp_* namespace).

Relative to HEAD the MFC includes two additional changes:
- The t3_tom module used for cxgb(4) is also patched.
- A strong reference from the new name (tcp_always_keepalive) to the old
  name (always_keepalive) has been added to preserve the KBI for existing
  modules.

Suggested by:	kib (strong reference)
Sponsored by:	Chelsio Communications
2018-03-03 00:54:12 +00:00
Kirk McKusick 18828d7b86 MFC of 329880.
Add error number to "fsync: giving up on dirty" message.
2018-03-02 04:43:07 +00:00
Glen Barber 5bbc1d7dc4 MFC r330033:
Bump the size of virtual machine disk images from 20G to 30G,
 providing more space for a local buildworld to succeed without
 attaching separate disks for /usr/src and /usr/obj.

Sponsored by:	The FreeBSD Foundation
2018-03-01 16:41:37 +00:00
Andriy Gapon 638d18bf7d MFC r329314: MFV r329313: 8857 zio_remove_child() panic due to already destroyed parent zio
PR:		223803
2018-03-01 10:57:50 +00:00
Andriy Gapon 748e8ee3d9 MFC r329711: MFV r329710: 8966 use after end of the lifetime of a local variable
PR:		225162
2018-03-01 08:30:08 +00:00
Xin LI 9678087ac9 MFC r330104: MFV r330102: ntp 4.2.8p11 2018-03-01 04:06:49 +00:00
John Baldwin b01c7a91b3 MFC 328630:
Clarify that the additional arguments to makecontext() are of type int.
2018-02-28 22:39:47 +00:00
John Baldwin c060f308fe MFC 328610: Ensure 'name' is not NULL before passing to strcmp().
This avoids a nested page fault when obtaining a stack trace in DDB if
the address from the first frame does not resolve to a known symbol.
2018-02-28 22:33:07 +00:00
Ravi Pokala 674390c26f MFC r329843:
jedec_dimm(4): report asset info and temperatures for DDR3 and DDR4 DIMMs

A super-set of the functionality of jedec_ts(4). jedec_dimm(4) reports asset
information (Part Number, Serial Number) encoded in the "Serial Presence
Detect" (SPD) data on JEDEC DDR3 and DDR4 DIMMs. It also calculates and
reports the memory capacity of the DIMM, in megabytes. If the DIMM includes
a "Thermal Sensor On DIMM" (TSOD), the temperature is also reported.
2018-02-28 10:00:02 +00:00
Pedro F. Giffuni 333e9ced4a MFC r329848:
__printf_render_int(): small type change to match use.

Variable l is consistently used as an int rather than a char.
Sort names while here.

Obtained from:	Apple's Libc-1244.30.3
2018-02-28 02:49:48 +00:00
Pedro F. Giffuni 8e0318ae4f MFC r329846:
getpeereid(3): Fix behavior on failure to match documentation.

According to the getpeereid(3) documentation, on failure the value -1 is
returned and the global variable errno is set to indicate the error. We
were returning the error instead.

Obtained from:	Apple's Libc-1244.30.3
2018-02-28 02:39:38 +00:00
Ravi Pokala 658fa6b9dd MFC r329682:
mountd: Return proper errno values in a few error paths

When attempting to mount a non-directory which exists, return ENOTDIR
instead of ENOENT. If stat() or statfs() failed, don't pass part of the
invalid (struct statfs) to ex_search(). In that same case, preserve the
value of "bad" rather than overwriting with EACCES.
2018-02-28 00:30:03 +00:00
Dimitry Andric a2e3a4e9cf Avoid using the C++11 auto keyword, which was introduced in r328555, as
part of an upstream change.  This is not supported by gcc 4.2.1, which
is still the default system compiler for some architectures.

Direct commit to stable/9 and stable/10, since this does not apply to
stable/11 and head.

Reported by:	[email protected]
PR:		202665,226068
2018-02-27 19:02:49 +00:00
Andriy Gapon b98ac2065c MFC r329556,r329820 remove an assert in zfsctl_snapdir_lookup to match r323578 2018-02-27 14:51:21 +00:00
Andriy Gapon a342276410 MFC r329364: move vintr_intercept_enabled under INVARIANTS 2018-02-27 14:47:56 +00:00
Andriy Gapon 73e250e9da MFC r328996: exec_map_first_page: fix an inverse condition introduced in r254138 2018-02-27 14:45:55 +00:00
Andriy Gapon 9020da2c8c MFC r329016: remove a duplicate assignment 2018-02-27 14:43:19 +00:00
Andriy Gapon 6a9147a0c2 MFC r328881: zfs: move a utility function, ioflags, closer to its consumers 2018-02-27 14:41:35 +00:00
Andriy Gapon f09d1cf342 MFC r328217: zfs: no need to check that size of zfs_cmd_t is not greater than IOCPARM_MAX 2018-02-27 14:23:43 +00:00
John Baldwin df2325ebf2 MFC 328134: Update various statements in vmstat(8) to match reality.
- The process stats are actually thread counts rather than process
  counts.
- Simplify various descriptions to remove mention of stats that are
  updated every 5 seconds (all VM related stats are now "instant",
  only the load average is updated every 5 seconds).
- Don't make any mention of special treatment for processes that have
  been active in the last 20 seconds.  We don't track that stat.
- Rework the description of active virtual memory.  Call it mapped
  virtual memory and explicitly point out it is not the same as the
  active page queue (which corresponds to "Active" in top(1)), and
  also hint at the possible bogusness of the value (e.g. if a process
  maps a single page out of a multiple GB file, the entire file's size
  is considered mapped).
- Simplify a few descriptions that implied their output was a value
  per interval.  All of the "rate" values are per-second rates scaled
  across the interval.
- Update a few comments for 'struct vmtotal' along similar lines.
2018-02-27 01:28:19 +00:00
Hans Petter Selasky 6d9971573e MFC r329195:
Add new USB quirk.

PR:		225844
Sponsored by:	Mellanox Technologies
2018-02-26 07:57:56 +00:00
Hans Petter Selasky 951e31ab35 Fix for LINT-{NOINET,NOINET6,NOIP} kernel builds.
This is a direct commit.

Reported by:	rpokala@
Sponsored by:	Mellanox Technologies
2018-02-25 11:29:55 +00:00
Eugene Grosbein 3830237fc6 Fix after incomplete MFC r326012: correctly delete loopback route
while removing interface address.

Reported by:	Andreas Longwitz <[email protected]>
Approved by:	avg (mentor)
2018-02-24 16:50:57 +00:00
Kirk McKusick 2f5d320887 MFC of 329749.
Fix a read past the end of a buffer in fsck.
2018-02-23 23:07:41 +00:00
Ravi Pokala 0cd5d56fce MFC r323508:
When doing a non-interactive installation, don't display an interactive
warning about a filesystem which doesn't have a mountpoint. Presumably, the
person who wrote the install script knew what they were doing.
2018-02-23 16:46:49 +00:00
Hans Petter Selasky e1ecdc2384 Fix for LINT kernel build.
This is a direct commit.

Discussed with:	np@
Reported by:	rpokala@
Sponsored by:	Mellanox Technologies
2018-02-22 20:48:02 +00:00
Hans Petter Selasky 15396afc3d Fix for LINT-NOINET kernel build.
This is a direct commit.

Reported by:	rpokala@
Sponsored by:	Mellanox Technologies
2018-02-22 20:09:21 +00:00
Ravi Pokala 0ae5770513 MFC r329295:
Panasas discovered that ioctl(SIOCGLAGGPORT) returns ENOTTY for mxge(4) when
the NIC is not a member of a lagg. This came as a surprise, because the
SIOCGLAGGPORT handler in if_lagg.c only returns ENOENT (if run against the
laggX interface, rather than a physical port) or EINVAL (if run against a
non-member physical port). This behavior was not seen with other drivers,
such as bge(4), igb(4), and cxl(4). When I compared their respective ioctl
handlers, I found that they all called ether_ioctl() for the default (i.e.
unhandled) case; by contrast, mxge(4) only calls ether_ioctl() for two
specific cases, and returns ENOTTY for the default case.

Remove the two cases which explicitly call ether_ioctl(), and let the
default case call it instead. This matches what the vast majority of the NIC
drivers do.
2018-02-22 19:40:03 +00:00
Brooks Davis 484ba2f95f MFC r329525:
Correct/improve the descriptions if kern.ipc.(shmsegs,sema,msqids).

The description of kern.ipc.shmsegs was wrong since 2005.  I updated the
others (which were more correct) to match.

PR:		225933
Reviewed by:	cem
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14391
2018-02-21 18:32:57 +00:00
Konstantin Belousov def9959efc MFC r329254:
Ensure memory consistency on COW.
2018-02-21 11:31:29 +00:00
Vladimir Kondratyev f85ac5beaf MFC r328864 (Synaptics part only):
psm(4): Fix panic occuring soon after PS/2 packet has been rejected by
synaptics sanity checker.

After packet has been rejected contents of packet buffer is not cleared
with setting of inputbytes counter to 0. So when this packet buffer is
filled again being an element of circular queue, new data appends to old
data rather than overwrites it. This leads to packet buffer overflow
after 10 rounds.

Fix it with setting of packet's inputbytes counter to 0 after rejection.

While here add extra logging of rejected packets.

PR:		222667 (for reference)
Reported by:	Neel Chauhan <[email protected]>
Tested by:	Neel Chauhan <[email protected]>
2018-02-18 22:12:20 +00:00
Andriy Gapon b954e44c2b MFC r328622: vmm/svm: post LAPIC interrupts using event injection
PR:		215972
2018-02-15 17:10:42 +00:00
Andriy Gapon ca2c4d9cde MFC r327996: geom_disk / scsi_da: deny opening write-protected disks for writing
Ths change consists of two parts.

geom_disk: deny opening a disk for writing if it's marked as
write-protected.  A new disk(9) flag is added to mark write protected
disks.  A possible alternative could be to add another parameter to d_open,
so that the open mode could be passed to it and the disk drivers could
make the decision internally, but the flag required less churn.

scsi_da: add a new phase of disk probing to query the all pages mode
sense page.  We can determine if the disk is write protected using bit 7
of the device specific field in the mode parameter header returned by
MODE SENSE.

PR:		224037
2018-02-15 16:31:35 +00:00
Hans Petter Selasky 0cec88ba71 MFC r328163:
Add new USB ID to U3G driver.

PR:		134299
Sponsored by:	Mellanox Technologies
2018-02-15 08:57:14 +00:00
Hans Petter Selasky 69897ee27a MFC r328830:
Add new USB ID.

PR:		225641
Submitted by:	Ryan <[email protected]>
Sponsored by:	Mellanox Technologies
2018-02-15 08:52:58 +00:00
Hans Petter Selasky f98b5c89dd MFC r328591:
Move the mlx5 core device pointer first in the mlx5en priv. This help simplify
checks to recognize own network devices when using mlx5ib. This patch fixes
an issues where mlx5ib fails to recognize mceX network devices for use with
RoCE.

Sponsored by:	Mellanox Technologies
2018-02-15 08:48:04 +00:00
Andrey V. Elsukov d0b0e528a2 MFC r328876:
Modify ip6_get_prevhdr() to be able use it safely.

  Instead of returning pointer to the previous header, return its offset.
  In frag6_input() use m_copyback() and determined offset to store next
  header instead of accessing to it by pointer and assuming that the memory
  is contiguous.

  In rip6_input() use offset returned by ip6_get_prevhdr() instead of
  calculating it from pointers arithmetic, because IP header can belong
  to another mbuf in the chain.

  Reported by:	Maxime Villard <max at m00nbsd dot net>
2018-02-12 13:52:58 +00:00
Ed Maste a2ac09dc6d MFC r328895: Correct Russia spelling in regdomain.xml
PR:		225658
2018-02-10 22:36:42 +00:00
Ravi Pokala 68a60671f9 jedec_ts(4) uses a sysctl format specifier of "IK4", to indicate that it
reports milliKelvin. However, sysctl(8) on stable/10 only knows about "IK",
without a numeric suffix, which represents deciKelvin.

Adjust the format specifier, and round the temperature value reported.

Reviewed by:	avg
Sponsored by:	Panasas
Differential Revision:	https://reviews.freebsd.org/D14055
2018-02-08 09:24:23 +00:00
Ed Maste b27a6daf13 MFC r328412: vt: add Ctrl+/ key mapping
This matches Xorg's handling of Ctrl+/ and may be useful as a tmux
escape.

PR:		212197
Submitted by:	martin at sugioarto.com
2018-02-08 00:42:02 +00:00
Kirk McKusick 63eca837e6 Adjust MFC in r328946 to stable/10.
This is a direct commit to the branch.
2018-02-07 22:50:10 +00:00
Kirk McKusick 532a36b6ab MFC of 328647.
avoid segment fault in g_journal
2018-02-06 19:17:40 +00:00
Kirk McKusick 64b3f0b195 MFC of 328643.
fix vn_printf listing of its union
2018-02-06 19:14:53 +00:00
Kirk McKusick ca81adc68a MFC of 328304 and 328382.
Do not dedup egid (group entry 0)
2018-02-06 19:09:49 +00:00
Xin LI 6bc6f962c6 MFC r328273 (kevlo): Document how to load nmdm(4) from a kernel module. 2018-02-06 07:50:30 +00:00
Andrey V. Elsukov 5d55250aec MFC r328770:
Merge r1.120 from NetBSD:
    Fix a pretty simple, yet pretty tragic typo: we should return IPPROTO_DONE,
    not IPPROTO_NONE. With IPPROTO_NONE we will keep parsing the header chain
    on an mbuf that was already freed.

  Reported by:	Maxime Villard <max at m00nbsd dot net>
2018-02-05 09:25:53 +00:00
Eitan Adler e6546abc96 MFC r323683:
MFV r323678: file 5.32
2018-02-05 08:50:34 +00:00
Andriy Gapon d252ce4b8e MFC r327775: amdsbwd: fix handling of timeout values beyond the supported range 2018-02-04 13:58:29 +00:00
Andriy Gapon c42826f37a MFC r327726: vmm/svm: contigmalloc of the whole svm_softc is excessive 2018-02-04 13:54:43 +00:00
Martin Matuska 062b76cfdb MFH r328332:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #893: delete dead ppmd7 alloc callbacks
  PR #904: Fix archive freeing bug in bsdcat
  PR #961: Fix ZIP format names
  PR #962: Don't modify attributes for existing directories
           when ARCHIVE_EXTRACT_NO_OVERWRITE is set
  PR #964: Fix -Werror=implicit-fallthrough= for GCC 7
  PR #970: zip: Allow backslash as path separator
2018-02-03 02:17:25 +00:00
Kirk McKusick 4fbaa5c448 MFC of 328444.
Eliminate "fsync: giving up on dirty" messages.
2018-02-02 01:28:14 +00:00
Hans Petter Selasky 3d0b5b9e36 MFC r328623:
Properly implement the cond_resched() function macro in the LinuxKPI.

Sponsored by:	Mellanox Technologies
2018-02-01 13:16:11 +00:00
Pedro F. Giffuni c31768c1d2 MFC r328497:
pfctl(8): Fix two wrong conditions.

Caught by gcc80's -Wtautological-compare option.

MFC after:	5 days
Reviewed by:	kp
Obtained from:	DragonFlyBSD (git e3cdbf6c)
2018-02-01 02:00:36 +00:00
Andrey V. Elsukov 0aa4fdbd3a MFC r328350:
Merge revision 1.35 from NetBSD:
    fix pointer/offset mistakes in handling of IPv4 options

  Reported by:  Maxime Villard <maxv at NetBSD.org>

MFC r328352:
  Adopt revision 1.76 and 1.77 from NetBSD:
    Fix a vulnerability in IPsec-IPv6-AH, that allows an attacker to remotely
    crash the kernel with a single packet.

    In this loop we need to increment 'ad' by two, because the length field
    of the option header does not count the size of the option header itself.

    If the length is zero, then 'count' is incremented by zero, and there's
    an infinite loop. Beyond that, this code was written with the assumption
    that since the IPv6 packet already went through the generic IPv6 option
    parser, several fields are guaranteed to be valid; but this assumption
    does not hold because of the missing '+2', and there's as a result a
    triggerable buffer overflow (write zeros after the end of the mbuf,
    potentially to the next mbuf in memory since it's a pool).

    Add the missing '+2', this place will be reinforced in separate commits.

  Reported by:  Maxime Villard <maxv at NetBSD.org>
2018-01-31 09:26:28 +00:00
John Baldwin 090b412f77 MFC 327561:
Report offset relative to the backing object for kinfo_vmentry structures.

For the pathname reported in kinfo_vmentry structures (kve_path), the
sysctl handlers walk the object chain to find the bottom-most VM object.
This permits a COW mapping of a file with dirty pages to report the
pathname of the originally mapped file.  Do the same for the object
offset (kve_offset) computing a cumulative offset during the same object
walk so that the reported offset is relative to the reported pathname.

Note that ptrace(PT_VM_ENTRY) already returns a cumulative offset
rather than the raw offset of the VM map entry.

Note also that this does not affect procstat -v output (even structured
output) since that output does not include the kve_offset field.

Sponsored by:	DARPA / AFRL
2018-01-29 23:43:04 +00:00
Jung-uk Kim d0b45f30c0 Revert a local change and sync. with head. No functional change.
Note this is a direct commit because head has OpenSSL 1.0.2.
2018-01-29 18:21:50 +00:00
Dimitry Andric fa8dbc7aa1 Pull in r217197 from upstream clang trunk (by Richard Smith):
PR20844: If we fail to list-initialize a reference, map to the
  referenced type before retrying the initialization to produce
  diagnostics. Otherwise, we may fail to produce any diagnostics, and
  silently produce invalid AST in a -Asserts build. Also add a note to
  this codepath to make it more clear why we were trying to create a
  temporary.

This should fix assertions when parsing some forms of incomplete list
intializers.

Direct commit to stable/9 and stable/10, since stable/11 and head
already have this upstream fix.

Reported by:	[email protected]
PR:		202665
2018-01-29 18:11:27 +00:00
Jean-Sébastien Pédron 6373c92077 psm: Log syncmask[1], not syncmask[0] twice
MFC of:		r328208
2018-01-27 17:24:59 +00:00
Philip Paeps c274fcd141 MFC r328055: Import tzdata 2018a
MFC r328318: Import tzdata 2018c
2018-01-27 13:34:14 +00:00
Glen Barber 2af4fcdcca MFC r328283, r328284:
r328283:
  When CHROOTBUILD_SKIP is set, evaluate the existence of /bin/sh
  within the CHROOTDIR.  If it does not exist, unset CHROOTBUILD_SKIP
  to prevent build failures.

 r328284:
  Bump Copyright year.

Sponsored by:	The FreeBSD Foundation
2018-01-26 04:32:31 +00:00
Brooks Davis d2ca71b7ae MFC r328297:
Don't escape '?'s in protocol output.

This isn't required by mandoc and is nonfunctional in groff.

PR:		224632
Reported by:	[email protected]
Differential Revision:	https://reviews.freebsd.org/D13779
2018-01-26 00:35:33 +00:00
John Baldwin 34cec59992 MFC 287600,287602: Fixes for fork following tests.
287600:
Properly size the children[] arrays in the follow fork tests.

287602:
Use _exit() instead of exit() in child processes created during tests.
2018-01-25 00:08:13 +00:00
John Baldwin 812e1fe7f3 MFC 325028,328344: Discard the correct thread event reported for a ptrace stop.
325028:
Discard the correct thread event reported for a ptrace stop.

When multiple threads wish to report a tracing event to a debugger,
both threads call ptracestop() and one thread will win the race to be
the reporting thread (p->p_xthread).  The debugger uses PT_LWPINFO
with the process ID to determine which thread / LWP is reporting an
event and the details of that event.  This event is cleared as a side
effect of the subsequent ptrace event that resumed the process
(PT_CONTINUE, PT_STEP, etc.).  However, ptrace() was clearing the
event identified by the LWP ID passed to the resume request even if
that wasn't the 'p_xthread'.  This could result in clearing an event
that had not yet been observed by the debugger and leaving the
existing event for 'p_thread' pending so that it was reported a second
time.

Specifically, if the debugger stopped due to a software breakpoint in
one thread, but then switched to another thread that was used to
resume (e.g. if the user switched to a different thread and issued a
step), the resume request (PT_STEP) cleared a pending event (if any)
for the thread being stepped.  However, the process immediately
stopped and the first thread reported it's breakpoint event a second
time.  The debugger decremented the PC for "both" breakpoint events
which resulted in the PC now pointing into the middle of an
instruction (on x86) and a SIGILL fault when the process was resumed a
second time.

To fix, always clear the pending event for 'p_xthread' when resuming a
process.  ptrace() still honors the requested LWP ID when enabling
single-stepping (PT_STEP) or setting a different PC (PT_CONTINUE).

328344:
Mark the unused argument to continue_thread() as such.

clang in HEAD and 11 does not warn about this, but clang in 10 does.
2018-01-24 21:48:39 +00:00
John Baldwin e8c58205fe MFC 326953:
Catch up to r325719 which makes the kern.proc.pid sysctl "work" for zombies.

Some of the ptrace tests need to wait for a child process to become a
zombie before preceding.  The parent process polls the child process
via the kern.proc.pid sysctl to wait for it to become a zombie.
Previously the code polled until the sysctl failed with ESRCH.  Now it
will poll until either the sysctl fails with ESRCH (for compatiblity
with older kernels) or returns a kinfo_proc structure with the ki_stat
field set to SZOMB.
2018-01-24 00:32:02 +00:00
John Baldwin 1963363577 MFC 325835: Use #if instead of #ifdef for __BSD_VISIBLE tests.
__BSD_VISIBLE is always defined and it's value instead needs to be
tested via #if to determine if FreeBSD-specific APIs should be
exposed.

PR:		196226
2018-01-23 18:22:41 +00:00
Kristof Provost 56a799b7a1 MFC r327675
pf: Avoid integer overflow issues by using mallocarray() iso. malloc()

pfioctl() handles several ioctl that takes variable length input, these
include:
- DIOCRADDTABLES
- DIOCRDELTABLES
- DIOCRGETTABLES
- DIOCRGETTSTATS
- DIOCRCLRTSTATS
- DIOCRSETTFLAGS

All of them take a pfioc_table struct as input from userland. One of
its elements (pfrio_size) is used in a buffer length calculation.
The calculation contains an integer overflow which if triggered can lead
to out of bound reads and writes later on.

Reported by:	Ilja Van Sprundel <[email protected]>
2018-01-23 05:03:26 +00:00
Kristof Provost 2506e2e267 MFC r327674, r327796
Introduce mallocarray() in the kernel

Similar to calloc() the mallocarray() function checks for integer
overflows before allocating memory.
It does not zero memory, unless the M_ZERO flag is set.

Additionally, move the overflow check logic out to WOULD_OVERFLOW() for
consumers to have a common means of testing for overflowing allocations.
WOULD_OVERFLOW() should be a secondary check -- on 64-bit platforms, just
because an allocation won't overflow size_t does not mean it is a sane size
to request.  Callers should be imposing reasonable allocation limits far,
far, below overflow.

Obtained from:	OpenBSD
2018-01-23 04:37:31 +00:00
Cy Schubert 877996fe6d MFC r327718:
When growing the state, also grow the seed array. Otherwise memory
that was not allocated will be accessed.

This necessitated refactoring state seed allocation from
ipf_state_soft_init() into a new common ipf_state_seed_alloc() function
as it is now also used by ipf_state_rehash() when changing the size of
the state hash table in addition to by ipf_state_soft_init() during
initialization.

According to Christos Zoulas <[email protected]>:

The bug was encountered by a NetBSD vendor who's customer machines had
large ipfilter states. The bug was reliably triggered by resizing the
state variables using "ipf -T".

Submitted by:	Christos Zoulas <[email protected]>
Reviewed by:	delphij, rgrimes
Obtained from:	NetBSD ip_state.c CVS revs r1.9 and r1.10
Differential Revision:	https://reviews.freebsd.org/D13755
2018-01-23 04:01:48 +00:00
Ed Maste bb7a958c31 MFC r327497, r327498: fix memory disclosure in hpt* ioctls
r327497: hpt27xx: plug info leak in hpt_ioctl

The hpt27xx ioctl handler allocates a buffer without M_ZERO and calls
hpt_do_ioctl(), which might not overwrite the entire buffer.

Also zero bytesReturned in case it is not written by hpt_do_ioctl().

The hpt27xx device has permissions only for root so this is not urgent,
and the fix can be MFCd and considered for a future EN.

Reported by:  Ilja van Sprundel <[email protected]>
Submitted by: Domagoj Stolfa <[email protected]> (M_ZERO)

r327498: hpt{nr,rr}: plug info leak in hpt_ioctl

The hpt{nr,rr} ioctl handler allocates a buffer without M_ZERO and calls
hpt_do_ioctl(), which might not overwrite the entire buffer.

Also zero bytesReturned in case it is not written by hpt_do_ioctl().

The hpt27{nr,rr} device has permissions only for root so this is not urgent,
and the fix can be MFCd and considered for a future EN.

The same issue was reported in the hpt27xx driver by Ilja Van Sprundel.

Security:	memory disclosure in root-only ioctls
Sponsored by:	The FreeBSD Foundation
2018-01-23 02:29:39 +00:00
Ed Maste 1feaff7587 MFC r317806 by glebius:
The nandsim(4) simulator driver doesn't have any protection against
races at least in its ioctl handler, and at the same time it creates
device entry with 0666 permissions.

To plug possible issues in it:
- Mark it as needing Giant.
- Switch device mode to 0600.

Submitted by:	C Turt
Reviewed by:	imp
Security:	Possible double free in ioctl handler
2018-01-23 02:16:06 +00:00
Cy Schubert 92fac34355 MFC r327913:
Remove redundant variable.
2018-01-20 18:04:08 +00:00
Cy Schubert f8a6feb874 MFC r327912:
Though this block of code is not used by FreeBSD, correct a call to
sprintf() with a macro call to SNPRINTF similar to other calls to
SNPRINTF within this same block.
2018-01-20 18:00:42 +00:00
Andriy Gapon 10c2c81509 MFC r327724: usbdevs: add ASMedia vendor ID 2018-01-16 11:25:08 +00:00
Andriy Gapon 8276df42de MFC r327725: zfs_mount: restore a bit of ifdef-out illumos code 2018-01-16 11:22:07 +00:00
Andriy Gapon 4f96ad4cb6 MFC r327593: Fix a couple of comments in AMD Virtual Machine Control Block structure 2018-01-15 12:17:26 +00:00
Andriy Gapon 0df721359a MFC r326567: ddb: fix validation of cpu id in 'set db_cpu=x' 2018-01-15 12:15:04 +00:00
Andriy Gapon 1f51b367d1 MFC r326140: vmrun.sh: add -A option for AHCI emulation of disk devices 2018-01-15 12:00:34 +00:00
Cy Schubert b259d48b25 MFC 327737:
USNO and possibly others have misinterpreted the maining of the
leapseconds last-update field and incorrectly increment it when changing
the file even though the leapsecond data has not changed. For instance,
if a leapsecond file is obtained from USNO, when it expires it will not
be replaced by a newer file from other sources because it has an
incorrect later last-update (version).

This corrects r304780.

PR:		225029
Submitted by:	ian
2018-01-12 02:49:18 +00:00
Bryan Drewery abe641ed37 MFC r284406:
Use cpp -I$includedir
2018-01-11 21:31:10 +00:00
Pedro F. Giffuni 85de07bdcf MFC r327289:
rpc.sprayd: Bring some changes from NetBSD.

Most notable, other than some style issues:
CVS 1.11:
  do not use LOG_CONS.
CVS 1.13:
  consistently use exit instead of return in main().
  use LOG_WARNING instead of LOG_ERR for non critical errors.

Obtained from:	NetBSD
2018-01-10 21:24:03 +00:00
Cy Schubert 678464faf0 MFC r327540:
Correct function name in description block.
2018-01-09 06:10:57 +00:00
Cy Schubert 6d439230dc MFC r327336:
Correct the comment describing badrs which is bad router solicitiation,
not bad router advertisement.
2018-01-09 06:07:51 +00:00
Eitan Adler 374d8735c9 MFC r327183:
.git*: add gitattributes and gitignore

For users of the git mirrors, lets provide useful git configuration
files.
2018-01-06 05:00:30 +00:00
Pedro F. Giffuni 33968a002a MFC r327329:
dev/txp: Update if_txpreg.h to match OpenBSD's version.

Resolve a minor mismatch: TXP_CMD_READ_VERSION instead of
TXP_CMD_VERSIONS_READ.
Curiously the later is defined but not used in OpenBSD.

Obtained from:	OpenBSD (CVS 1.31-1.34)
2018-01-05 17:23:17 +00:00
Pedro F. Giffuni f76bc9ec8a MFC r327295:
Start syncing changes from OpenBSD's ip6_id.c instead of ip_id.c.

correct non-repetitive ID code, based on comments from niels provos.
- seed2 is necessary, but use it as "seed2 + x" not "seed2 ^ x".
- skipping number is not needed, so disable it for 16bit generator (makes
  the repetition period to 30000)

Obtained from:	OpenBSD (CVS rev. 1.2)
2018-01-04 15:57:49 +00:00
Steven Hartland 8fb5108ae3 MFC r322812:
Avoid TCP log messages which are false positives.

Sponsored by:	Multiplay
2018-01-03 16:16:20 +00:00
Dimitry Andric 2eb7d5c168 MFC r327164:
Fix clang 6.0.0 compiler warnings in binutils

Latest clang git has a warning -Wnull-pointer-arithmetic which will
trigger a -Werror failure. Addition and subtraction from a null pointer
is undefined behaviour and could be optimized into anything.

Furthermore, using the difference between two pointers and casting the
result back to a pointer is not portable since the size of ptrdiff_t
does not necessary have to be the same as size of void* (this happens
e.g. on CHERI). Using intptr_t instead fixes this portability issue and
the compiler warning.

Submitted by;	Alexander Richardson
Obtained from:	CheriBSD
Differential Revision: https://reviews.freebsd.org/D12928
2018-01-01 20:39:12 +00:00
Dimitry Andric b33e03dac6 MFC r327167:
Remove obsolete register keyword from opensolaris's sysmacros.h.  When
compiling zfsd with recent clang, it leads to a warning about the
register storage class being incompatible with C++17.
2018-01-01 20:24:16 +00:00
Hajimu UMEMOTO e7792fa7a5 MFC r327029:
Don't ignore trailing spaces after numerical IP addresses.

PR:		224403
2017-12-27 14:50:07 +00:00
Xin LI 24aeae9648 MFC r326791: Close the correct file descriptor. 2017-12-26 08:33:02 +00:00
Xin LI ac71d9d987 MFC r326185: Set errno to EFTYPE instead of EINVAL to be more consistent
with the rest of code.
2017-12-25 04:34:10 +00:00
Andrey V. Elsukov 177fe77540 MFC r326898:
Fix possible memory leak.

  vxlan_ftable entries are sorted in descending order, due to wrong arguments
  order it is possible to stop search before existing element will be found.
  Then new element will be allocated in vxlan_ftable_update_locked() and can
  be inserted in the list second time or trigger MPASS() assertion with
  enabled INVARIANTS.

  PR:		224371
2017-12-24 02:06:16 +00:00
Eugene Grosbein ed7ba28641 MFC r326872: fix expiration arithmetic after r326738 and MFC.
Approved by:    mav (mentor)
2017-12-22 18:15:34 +00:00
Konstantin Belousov 037de6896e MFC r326851:
In devfs_lookupx() dotdot lookup case, avoid dereferencing
dvp->v_mount after dvp is unlocked.
2017-12-21 13:32:49 +00:00
Xin LI c130afe92a MFC r326562: Use strlcpy(). 2017-12-20 07:18:07 +00:00
Rick Macklem d5b02b98f8 MFC: r326544
Avoid the overhead of acquiring a lock in nfsrv_checkgetattr() when
there are no write delegations issued.

manu@ reported on the freebsd-current@ mailing list that there was
a significant performance hit in nfsrv_checkgetattr() caused by
the acquisition/release of a state lock, even when there were no
write delegations issued.
This patch add a count of outstanding issued write delegations to the
NFSv4 server. This count allows nfsrv_checkgetattr() to return without
acquiring any lock when the count is 0, avoiding the performance hit
for the case where no write delegations are issued.
2017-12-19 23:00:08 +00:00
Dimitry Andric 5fee68aab0 MFC r326880:
Pull in r320755 from upstream clang trunk (by me):

  Don't trigger -Wuser-defined-literals for system headers

  Summary:
  In D41064, I proposed adding `#pragma clang diagnostic ignored
  "-Wuser-defined-literals"` to some of libc++'s headers, since these
  warnings are now triggered by clang's new `-std=gnu++14` default:

  $ cat test.cpp
  #include <string>

  $ clang -std=c++14 -Wsystem-headers -Wall -Wextra -c test.cpp
  In file included from test.cpp:1:
  In file included from /usr/include/c++/v1/string:470:
  /usr/include/c++/v1/string_view:763:29: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<char> operator "" sv(const char *__str, size_t __len)
                              ^
  /usr/include/c++/v1/string_view:769:32: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len)
                                 ^
  /usr/include/c++/v1/string_view:775:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len)
                                  ^
  /usr/include/c++/v1/string_view:781:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len)
                                  ^
  In file included from test.cpp:1:
  /usr/include/c++/v1/string:4012:24: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<char> operator "" s( const char *__str, size_t __len )
                         ^
  /usr/include/c++/v1/string:4018:27: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
                            ^
  /usr/include/c++/v1/string:4024:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
                             ^
  /usr/include/c++/v1/string:4030:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
      basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
                             ^
  8 warnings generated.

  Both @aaron.ballman and @mclow.lists felt that adding this workaround
  to the libc++ headers was the wrong way, and it should be fixed in
  clang instead.

  Here is a proposal to do just that.  I verified that this suppresses
  the warning, even when -Wsystem-headers is used, and that the warning
  is still emitted for a declaration outside of system headers.

  Reviewers: aaron.ballman, mclow.lists, rsmith

  Reviewed By: aaron.ballman

  Subscribers: mclow.lists, aaron.ballman, andrew, emaste, cfe-commits

  Differential Revision: https://reviews.llvm.org/D41080

This will allow to compile some of the libc++ headers in C++14 mode
(which is the default for gcc 6 and higher, and will be the default for
clang 6.0.0 and higher), with -Wsystem-headers and -Werror enabled.

Reported by:	andrew
2017-12-19 11:44:24 +00:00
Greg Lehey 42f8c7370e Revert revision 326923
Demanded unconditionally by:	imp@
2017-12-19 01:02:58 +00:00
Greg Lehey 8c5674546e Correct character set. 2017-12-17 22:12:57 +00:00
Cy Schubert 8fb69ebb6a MFC r326558, r326566:
fdformat is a sysadmin command and thus its man page should be in
volume 8 instead of volume 1.

Reviewed by:	imp
2017-12-17 06:00:49 +00:00
Eugene Grosbein 029dda1c36 MFC r326738: pw(8): correct expiration period handling
and command line overrides to preconfigured values for -e, -p and -w flags.

  Use non-negative symbols instead of magic values
  in passwd_val/pw_password functions.

PR:		223431
Submitted by:	Yuri Pankov (in part, patch for the manual)
Approved by:	mav (mentor)
Relnotes:	yes
2017-12-14 13:10:22 +00:00
Konstantin Belousov f4c225ae42 MFC r326657:
Fix livelock in ufsdirhash_create().
2017-12-14 11:45:02 +00:00
Xin LI 56580f3f6d MFC r326391: Prevent OOB access on corrupted msdos directories.
Submitted by:	Veo Zhang <veo live com>
2017-12-14 07:55:11 +00:00
Cy Schubert 953b27c01d MFC r324248:
hen building multiple kernels using KERNCONF, non-existent KERNCONF
files will produce an error and buildkernel will fail. Previously missing
KERNCONF files silently failed giving no indication as to why, only to
subsequently discover during installkernel that the desired kernel was
never built in the first place.

This is a rework of r302865.

This is the correct patch.

Reviewed by:	ngie (previous version, r302865)
Differential Revision:	https://reviews.freebsd.org/D7167
2017-12-13 20:15:23 +00:00
Dimitry Andric c1bc22f3a4 MFC r326748:
Document the existence and precision of the remaining long double
functions for which an imprecise stub implementation was added in
r255294, namely powl(3) and tgammal(3).

Submitted by:	Steve Kargl

MFC r326753:

Correct r326748, indicating that tgammal(3) is mapped to tgamma(3), not
to itself.

Noticed by:	jilles
2017-12-13 18:38:02 +00:00
Xin LI ab532b41ce MFC r326361: Remove unused include. 2017-12-13 06:20:18 +00:00
Pedro F. Giffuni 4173b7bb35 MFC r326282: (by fsu)
Remap ENOATTR to ENODATA in the linuxulator.
In the linux ENOADATA is frequently #defined as ENOATTR. The change is
required for an xattrs support implementation.
2017-12-12 22:10:12 +00:00
Xin LI 55dc07245b Revert r326763. The change depends on r264387 which was not merged.
Pointy hat to:	delphij
2017-12-12 04:08:30 +00:00
Xin LI 299c23513b MFC r325723:
find(1): Don't treat statfs() error as fatal in f_fstype, which can happen
when a directory is removed in the middle of find.

Instead of a full err(), allow find to continue, plus print a warning with
exitstatus set when appropriate.

Reported by:	100.chksetuid via gordon
Reviewed by:	jilles
2017-12-11 05:21:48 +00:00
Xin LI d1b7b4c8de MFC r326244:
Don't assign rs as we will assign it later.
2017-12-11 05:10:11 +00:00
Dimitry Andric 357a1b4201 MFC r326670:
Remove an unused incude from lib/msun/bsdsrc/b_log.c.

Submitted by:	Steve Kargl
2017-12-10 14:49:06 +00:00
Dimitry Andric 0254e44c7b MFC r326669:
Remove the sentence in math(3) about some long double math functions not
being available.

Submitted by:	Steve Kargl
2017-12-10 13:58:37 +00:00
Eugene Grosbein fd440d3089 MFC r326655,326668: correct error handling for graid
SINGLE/CONCAT/RAID5 volumes.

Approved by:    mav (mentor)
2017-12-10 13:45:41 +00:00
Gordon Tetlow cace5b5f05 Fix error state handling.
Security:	CVE-2017-3737
Security:	FreeBSD-SA-17:12.openssl
2017-12-09 03:41:31 +00:00
Hans Petter Selasky 0a84ca9a11 Add support for IPv6 based addresses as part of the TCP unify portspace feature
in ibcore. This resolves an interopability issue when using both iWarp(T6) and
RDMA(CX-4 and CX-5) devices at the same time.

The problem is IPv4 based sockets cannot be bound to an IPv6 based address
causing sobind() to fail preventing all use of IPv6 based addresses with RDMA
when an iWarp device is present.

This is a direct commit.

Tested by:	KrishnamRaju ErapaRaju <[email protected]>
Sponsored by:	Mellanox Technologies
2017-12-08 19:21:46 +00:00
Hans Petter Selasky a6eb36ccdf MFC r326362:
Disallow TUN and TAP character device IOCTLs to modify the network device
type to any value. This can cause page faults and panics due to accessing
uninitialized fields in the "struct ifnet" which are specific to the network
device type.

Found by:	[email protected]
PR:		223767
Sponsored by:	Mellanox Technologies
2017-12-08 15:26:57 +00:00
Baptiste Daroussin cf0f2f1df2 MFC r326633:
Update to 2017-12-06
2017-12-08 10:50:13 +00:00
Baptiste Daroussin 937269ff3d MFC r326527:
Only skip looking for manpages if both man directory and cat directory
are not existing.

This allows man(1) to read catpages when no man directories are available at all

PR:		223559
Reported by:	wosch
2017-12-08 10:47:29 +00:00
Baptiste Daroussin 8b7a1b50f5 MFC r326526:
In case man(1) found a catpage to display skip looking ".so" which is manpage
only.

In case we are trying to read a catpage, the manpage variable is not defined.
It results in the "cattool" having no arguments.

In case the catpage is compressed, the cattool used is "zcat" which dies if the
standard input is a terminal, meaning the function calling it is exiting as if
there were no ".so"
In case the catpage is uncompressed, the cattool used is "zcat -f" which waits
reading standard input, making the man(1) command hang.

PR:		223560
Reported by:	wosch
2017-12-08 10:44:44 +00:00
Jung-uk Kim 473dfdfd1c MFC: r267961, r309361, r322710, r323286, r326378, r326383, r326407
Sync. hwpstate with head.

r267961 (hselasky, partial):

Remove a redundant TUNABLE statement.

r309361 (danfe):

- Mention mismatching numbers in MSR vs. ACPI _PSS count warning.
- Rephrase unsupported AMD CPUs message and wrap as an overly long line.
- Improve readability when reporting resulted P-state transition (debug).

r322710, r323286 (cem):

- Add support for family 17h pstate info from MSRs.
- Yield CPU awaiting frequency change.

r326378, r326383, r326407:

- Fix some style(9) nits.
- Add a tunable "debug.hwpstate_verify" to check P-state after changing it
and turn it off by default.
2017-12-06 21:40:24 +00:00
Cy Schubert 0147ee9485 MFC r326343:
Fix fetching ntp leapfile after 325256

Submitted by:	Ronald Klop <[email protected]>
Original commit by:    asomers
MFC PR:		224126
2017-12-06 00:00:37 +00:00
Julian Elischer daf566cfe2 Steps to Reproduce:
#ngctl mkpeer ipfw: patch 7 in
#ngctl name ipfw:7 tcp_rst
#ngctl connect ipfw: tcp_rst: 8 out
#ngctl msg tcp_rst: setconfig { count=1 csum_flags=0 ops=[ { mode=8 value=4 length=1 offset=33 } ] }
ngctl: send msg: Argument list too long

It's broken after base r309389 and could be fixed in base r309408, but the first one went to 10.4 and the second one didn't.

PR:		224019
Submitted by:	[email protected]
2017-12-05 14:46:12 +00:00
Glen Barber ec91c95016 MFC r326315, r326330, r326331, r326412:
r326315:
  Set DISTDIR and WRKDIRPREFIX when building ports within the
  chroot(8) to avoid mtime changes within the ports checkout,
  which can cause checksum differences.

 r326330:
  Add a comment to release/release.conf.sample documenting
  EMBEDDEDPORTS. [1]

  Remove and update stale documentation from release(7) while here.

 r326331:
  Correct a comment.

 r326412:
  Fix port build flags passed to make(1) after r326315, where
  it was missed for embedded image builds.

PR:		206344 [1]
Sponsored by:	The FreeBSD Foundation
2017-12-04 15:28:07 +00:00
Konstantin Belousov 520e61335a MFC r326424:
Add comment for vm_map_find_min().
2017-12-04 10:05:59 +00:00
Hans Petter Selasky cd2695ab86 MFC r325897:
Improve the library dependencies helper script in src/tools.

Implement double pass of the relevant Makefiles. First make a list of
library names and directories and then scan for all the dependencies.
Spaces in directories in the source tree are not supported.

This avoids using hardcoded mappings between the library name
and the directory containing the library Makefile.

Add support for scanning contrib/ofed .

Bail out on any errors.

Sponsored by:	Mellanox Technologies
2017-12-04 09:54:03 +00:00
Hans Petter Selasky b9f34576ff MFC r326161:
Implement atomic_fetchadd_64() for i386. This function is needed by the
atomic64 header file in the LinuxKPI for i386.

Reviewed by:	kib
Sponsored by:	Mellanox Technologies
2017-12-04 09:46:08 +00:00
Hans Petter Selasky cd766a6dd0 MFC r326392:
Properly define the VLAN_XXX() function macros to avoid miscompilation when
used inside "if" statements comparing with another value.

Detailed explanation:
"if (a ? b : c != 0)" is not the same like "if ((a ? b : c) != 0)"
which is the expected behaviour of a function macro.

Affects:
toecore, linuxkpi and ibcore.

Reviewed by:	kib
Sponsored by:	Mellanox Technologies
2017-12-04 09:27:36 +00:00
Andriy Gapon c4d9ca5509 MFC r326070: zfs_write: fix problem with writes appearing to succeed when over quota
The problem happens when the writes have offsets and sizes aligned with
a filesystem's recordsize (maximum block size).  In this scenario
dmu_tx_assign() would fail because of being over the quota, but the uio
would already be modified in the code path where we copy data from the
uio into a borrowed ARC buffer.  That makes an appearance of a partial
write, so zfs_write() would return success and the uio would be modified
consistently with writing a single block.

That bug can result in a data loss because the writes over the quota
would appear to succeed while the actual data is being discarded.

This commit fixes the bug by ensuring that the uio is not changed until
after all error checks are done.  To achieve that the code now uses
uiocopy() + uioskip() as in the original illumos design.  We can do that
now that uiocopy() has been updated in r326067 to use
vn_io_fault_uiomove().
2017-12-01 11:14:13 +00:00
Andriy Gapon bd0d3ce3ee MFC r326067: make illumos uiocopy use vn_io_fault_uiomove 2017-12-01 11:11:25 +00:00
Kristof Provost ceba78f981 MFC r325850: pfctl: teach route-to to deal with interfaces with multiple addresses
The route_host parsing code set the interface name, but only for the first
node_host in the list. If that one happened to be the inet6 address and the
rule wanted an inet address it'd get removed by remove_invalid_hosts() later
on, and we'd have no interface name.

We must set the interface name for all node_host entries in the list, not just
the first one.

PR:		223208
2017-11-30 21:32:28 +00:00
Konstantin Belousov 6dfeed992a MFC r326122:
Kill all descendants of the reaper, even if they are descendants of a
subordinate reaper.  Also, mark reapers when listing pids.

PR:	223745
2017-11-30 14:38:07 +00:00
Ed Maste 259d410454 MFC r326135: bfd: fix segfault in the ihex parser on malformed ihex file
From binutils commit 0102ea8cec5fc509bba6c91df61b7ce23a799d32, made
available under GPLv2 by Nick Clifton.

PR:		198824
Security:	CVE-2014-8503
2017-11-30 00:27:49 +00:00
Ed Maste 4a259b9b45 MFC r326136: bfd: avoid crash on corrupt binaries
From binutils commits 5a4b0ccc20ba30caef53b01bee2c0aaa5b855339 and
7e1e19887abd24aeb15066b141cdff5541e0ec8e, made available under GPLv2
by Nick Clifton.

PR:		198824
Security:	CVE-2014-8501
Security:	CVE-2014-8502
2017-11-30 00:25:25 +00:00
Ed Maste 88932e0a20 MFC r326082: freebsd-update: do not duplicate patchlist entries
PR:		221079
Submitted by:	Masachika ISHIZUKA
Submitted by:	[email protected]
Reviewed by:	cperciva
2017-11-29 20:44:40 +00:00
Glen Barber 4a375482f2 Document SA-17:06 through SA-17:11 and EN-17:07 through EN:17-10.
Sponsored by:	The FreeBSD Foundation
2017-11-29 14:45:28 +00:00
Xin LI 2fe7059f04 Avoid out-of-bounds read.
Security:	CVE-2017-3735
Security:	FreeBSD-SA-17:11.openssl
Obtained from:	OpenSSL https://github.com/openssl/openssl/pull/4276
2017-11-29 05:35:28 +00:00
Alan Somers 28872d8f86 MFC r325363:
Fix mpr(4) panics caused by bad drive mapping tables

sys/dev/mpr/mpr_mapping.c
	If _mapping_process_dpm_pg0 detects inconsistencies in the drive
	mapping table (stored in the HBA's NVRAM), abort reading it and
	continue to boot as if the mapping table were blank.  I observed
	such inconsistencies in several HBAs after upgrading firmware from
	14.0.0.0 to 15.0.0.0.

Reviewed by:	slm
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D12901
2017-11-28 19:57:16 +00:00
Alan Somers f78a5b5016 MFC r324805:
Fix the mps(4) HISTORY section.

Looks like a copy/paste error from r302673.

Sponsored by:	Spectra Logic Corp
2017-11-28 19:46:48 +00:00
Alan Somers 5e9820457c MFC r324221:
MFV r316861: 6866 zdb -l should return non-zero if it fails to find any label

illumos/illumos-gate@64723e3611
https://github.com/illumos/illumos-gate/commit/64723e361134b2a2c45341334174f9d34002f8d0

https://www.illumos.org/issues/6866
  Need this for #6865.
  To be generally more scripting-friendly, overload this issue with adding '-q'
  option which should skip printing any label information.

Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: John Kennedy <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
Author: Yuri Pankov <[email protected]>
2017-11-28 18:44:58 +00:00
Alan Somers c8a1fc1752 MFC r324220:
MFC r316858 7280 Allow changing global libzpool variables in zdb

7280 Allow changing global libzpool variables in zdb and ztest through command line

illumos/illumos-gate@0e60744c98
https://github.com/illumos/illumos-gate/commit/0e60744c982adecd0a1f146f5637475d07ab1069

https://www.illumos.org/issues/7280
  zdb is very handy for diagnosing problems with a pool in a safe and
  quick way. When a pool is in a bad shape, we often want to disable some
  fail-safes, or adjust some tunables in order to open them. In the
  kernel, this is done by changing public variables in mdb. The goal of
  this feature is to add the same capability to zdb and ztest, so that
  they can change libzpool tuneables from the command line.

Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: Dan Kimmel <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
Author: Pavel Zakharov <[email protected]>
2017-11-28 18:35:58 +00:00
Alan Somers 1a66cb8c50 MFC r323813:
MFV r323789:  8473 scrub does not detect errors on active spares

illumos/illumos-gate@554675eee7
https://github.com/illumos/illumos-gate/commit/554675eee75dd2d7398d960aa5c81083ceb8505a

https://www.illumos.org/issues/8473
Scrubbing is supposed to detect and repair all errors in the pool. However,
it wrongly ignores active spare devices. The problem can easily be
reproduced in OpenZFS at git rev 0ef125d with these commands:

truncate -s 64m /tmp/a /tmp/b /tmp/c
sudo zpool create testpool mirror /tmp/a /tmp/b spare /tmp/c
sudo zpool replace testpool /tmp/a /tmp/c
/bin/dd if=/dev/zero bs=1024k count=63 oseek=1 conv=notrunc of=/tmp/c
sync
sudo zpool scrub testpool
zpool status testpool # Will show 0 errors, which is wrong
sudo zpool offline testpool /tmp/a
sudo zpool scrub testpool
zpool status testpool # Will show errors on /tmp/c,
		      # which should've already been fixed

FreeBSD head is partially affected: the first scrub will detect some errors, but the second scrub will detect more.

Reviewed by: Andy Stormont <[email protected]>
Reviewed by: Matt Ahrens <[email protected]>
Reviewed by: George Wilson <[email protected]>
Approved by: Richard Lowe <[email protected]>

Sponsored by:	Spectra Logic Corp
2017-11-28 18:27:25 +00:00
Alan Somers 80b7443245 MFC r323275, r324112
r323275:
Add basic tests for chflags, mkdir, rcp, and rmdir

Add basic command line parsing test coverage for these utilities.  The tests
were automatically generated based on their man pages.  These tests can be
expanded by hand for more thorough coverage.  The aim is to generate very
basic amount of test coverage for all the utilities in the base system.

Submitted by:	shivansh
Reviewed by:	asomers, brooks
Sponsored by:	Google, Inc (GSoC 2017)
Differential Revision:	https://reviews.freebsd.org/D12036

r324112:
Fix Makefile entries from r323275

Reported by:		Vladimir Zakharov <[email protected]>
Reviewed by:		ngie
X-MFC-With:		323275
2017-11-28 18:18:39 +00:00
Alan Somers e8c221ddec MFC r323194:
Fix remounting ZFS filesystem with "zfs mount"

"zfs mount -o" passes a list of mount options directly to nmount(2) after
sanity checking them. In particular, zfs(8) will refuse to mount an already
existing file system unless "remount" is specified in the option list.
However, the "remount" option only exists in Illumos. FreeBSD's equivalent is
"update".

PR:		221985
Reviewed by:	avg
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D12233
2017-11-28 17:33:10 +00:00
Alan Somers cff6a62c35 MFC r323193:
Honor all options of "zfs mount -o"

The existing code in zmount incorrectly parses the comma-delimited option
string. The result is that nmount only honors the last option. AFAICT the
parsing has been broken ever since ZFS's initial import in change 168404.

PR:		222078
Reviewed by:	avg
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D12232
2017-11-28 17:30:25 +00:00
Alan Somers e5d402ee36 MFC r322868:
Fix 100.chksetuid and 110.neggrpperm for mountpoints with spaces

Also, fix them for mountpoints with tabs.

PR:		48325
Reported by:	[email protected], [email protected]
2017-11-28 17:27:00 +00:00
Alan Somers 103b5ba329 MFC r322546:
Fix some ZFS debugging messages

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
	Be more careful about the use of provider names vs vdev names in
	ZFS_LOG statements.

Sponsored by:	Spectra Logic Corp
2017-11-28 17:25:24 +00:00
Brooks Davis b6d7343ec4 MFC r301679 (partial), r309626, r326307
r301679:
Update to a June 8th snapshot of (un)vis form NetBSD.

This adds stravis() and some new encoding flags VIS_SHELL, VIS_META,
and VIS_NOLOCALE.

Assorted cleanups and fixes includeing a manpage typo[0].

NOTE: The symbol for stravis() is not exported in this merge.

r309626:
strvis(3): Avoid internal state of multibyte functions being tainted.

The mbtoc(3) and wctomb(3) functions use internal state which may be
tainted before the call to strvis(3).  In this context we can just use
the thread-safe versions mbrtoc(3) and wcrtomb(3) which allow passing
our own state from our stack.

r326307:
Update vis(3) the latest from NetBSD.

This adds VIS_DQ for compatiblity with OpenBSD.

Correct by an off-by-one error and a read buffer overflow detected using
asan.

PR:		210013 [0]
Submitted by:	pi [0]
2017-11-28 17:20:53 +00:00
Glen Barber 65ef4cef4a MFC r326068:
Remove /etc/resolv.conf from virtual machine images, which is
 copied from the build host.  It is renamed to /etc/resolv.conf.bak
 on boot, so never used anyway.

Sponsored by:	The FreeBSD Foundation
2017-11-27 15:12:14 +00:00
Xin LI c4d7a82da3 MFC r325755: Be more careful when doing calculation with request from
userland.
2017-11-27 03:49:51 +00:00
Pedro F. Giffuni 0af42dee01 MFC r326028:
iconv: Fix a pointer mismatch.

Catch NULL pointer earlier, check for empty string later.
Apparently this fixes a GCC8 warning.

Obtained from:	NetBSD (CVS Rev. 1.21, 1.22) through DragonFlyBSD
2017-11-27 02:44:36 +00:00
Konstantin Belousov fa4940d4ec MFC r326098:
Return different error code for the guard page layout violation.

PR:	223732
2017-11-25 14:51:40 +00:00
Alexander Motin abc02d1e04 MFC r325552: s/NgSendMsgReply/NgSendReplyMsg/ in man to match the code.
Submitted by:	Dmitry Luhtionov <[email protected]>
2017-11-22 21:24:47 +00:00
Xin LI fa5a7b686e MFC r325532: Update arcmsr(4) to 1.40.00.01:
- Fix clear doorbell queue buffer for ADAPTER_TYPE_B
 - Fix release memory resource when detach device
 - Add support for ARC-1216, 1226 SAS 12Gb controllers
 - Declare some functions as static
 - Change checking dword read/write for IOP rqbuffer.

Many thanks to Areca for continuing to support FreeBSD.

Submitted by: 黃清隆 <ching2048 areca com tw>
2017-11-22 06:36:55 +00:00
Hans Petter Selasky a4da60e0e4 MFC r299674 and r299931:
Handle case of class being set, but not parent when calling
device_register() in the LinuxKPI.

Requested by:	Chelsio
Sponsored by:	Mellanox Technologies
2017-11-21 10:19:33 +00:00
Glen Barber e9e052e809 MFC r325373, r325861:
r325373 (manu):
  release/arm: Do not install ubldr

 r325861 (manu):
  release: Update u-boot and firmware file for RPI-B target.

Sponsored by:	The FreeBSD Foundation
2017-11-20 19:05:53 +00:00
Glen Barber 348be50e14 MFC r325950, r325953:
r325950:
  Sort variables for consistency.

 r325953:
  Add general configuration files used by release/release.sh for
  big-iron installation images.

Sponsored by:	The FreeBSD Foundation
2017-11-20 15:57:56 +00:00
Glen Barber 36149ef35f MFC r325863:
Only copy /etc/resolv.conf to ${CHROOTDIR} if /etc/resolv.conf does
 not already exist within ${CHROOTDIR}.  This allows re-using a build
 chroot with CHROOTBUILD_SKIP set to a non-empty value and CHROOTDIR
 set to '/' in release.conf.

Sponsored by:	The FreeBSD Foundation
2017-11-20 15:46:23 +00:00
Eugene Grosbein ff942643fd MFC r325436: RTF_PINNED for an interface
Allow a process to assign an IP address to local ppp interface
  even if kernel routing table already has a route to the address in question
  installed by some routing daemon (PR 223129).

  Also, allow loopback route deletion when stopping a VIMAGE jail (PR 222647).

PR:			222647, 223129
Reviewed by:		gnn
Approved by:		mav (mentor)
Differential Revision:	https://reviews.freebsd.org/D12747
2017-11-20 09:24:01 +00:00
Xin LI 997502dcc7 MFC r325383:
Avoid calling get_controller_count() until attaching, this would avoid
costly PCI config space operations that slows down systems without the
hardware.

Many thanks to HighPoint for continued support of FreeBSD!

Submitted by:	Steve Chang
Reported by:	cperciva
2017-11-20 06:49:05 +00:00
Hans Petter Selasky 79f649ed9a MFC r325616:
Make sure sin_zero is zero in ibcore. Else socket address maching using
bcmp() might fail.

Sponsored by:	Mellanox Technologies
2017-11-17 15:49:01 +00:00
Hans Petter Selasky a2e98b7670 MFC r325615:
Make sure the IPv6 scope ID gets zeroed when exchanging CMA messages in ibcore.
Else the IPv6 address matching might fail. This change adds support for both
embedded and non-embedded IPv6 scope IDs when passing a IPv6 link-local socket
address to RDMA. Prior to this change only global IPv6 addresses would work
with RDMA.

Sponsored by:	Mellanox Technologies
2017-11-17 15:46:45 +00:00
Hans Petter Selasky afc2f77bf0 MFC r325614:
Multiple fixes for using IPv6 link-local addresses with RDMA.

1) Fail to resolve RDMA address if rtalloc1() returns the loopback
device, lo0, as the gateway interface.

2) Use ip_dev_find() and ip6_dev_find() to lookup network interfaces
with matching IPv4 and IPv6 addresses, respectivly.

3) In addr_resolve() make sure the "ifa" pointer is always set, also when
the "ifp" is NULL. Else a NULL pointer access might happen trying to
read from the "ifa" pointer later on.

Sponsored by:	Mellanox Technologies
2017-11-17 15:43:29 +00:00
Hans Petter Selasky 947ae25870 MFC r325533:
Make the dma_alloc_coherent() function in the LinuxKPI NULL safe with regard
to the "dev" argument.

Submitted by:	Krishnamraju Eraparaju @ Chelsio
Sponsored by:	Chelsio Communications
2017-11-17 15:30:36 +00:00
Andriy Gapon cc98e8acdc MFC r325610: MFV r325609: 7531 Assign correct flags to prefetched buffers 2017-11-17 10:13:24 +00:00
Andriy Gapon cd8afce397 MFC r325035: MFV r325013,r325034: 640 number_to_scaled_string is duplicated in several commands
FreeBSD note: of all libcmdutils functionality ZFS (and other illumos
contrib code) currently uses only nicenum() function (which is similar
to humanize_number but has some formatting differences).  For this
reason I decided to not port the whole library.  As a result, nicenum.c
from libcmdutils is compiled into libzfs and libzpool.  This is a bit
ugly, but works.  If one day we are forced to create libillumos, then
the file should be moved to that library.
2017-11-16 23:36:19 +00:00
Andriy Gapon 05d79860aa MFC r325228: vdev_geom_close: close errored consumer even if vdev_reopening is set 2017-11-16 23:02:04 +00:00
Andriy Gapon d34ccdd9fa MFC r325606: MFV r325605: 8713 Buffer overflow in dsl_dataset_name() 2017-11-16 22:47:41 +00:00
Andriy Gapon 42bcaf4597 MFC r325227,r325272: geom_slice: do not destroy softc until providers are gone
Note: there was a merge conflict, likely because of a missing MFC of an
earlier change.
2017-11-16 22:37:03 +00:00
John Baldwin 0c9545b04c MFC 325039: Rework pass through changes in r305485 to be safer.
Specifically, devices that do not support PCI-e FLR and were not
gracefully shutdown by the guest OS could continue to issue DMA
requests after the VM was terminated.  The changes in r305485 meant
that those DMA requests were completed against the host's memory which
could result in random memory corruption.  Instead, leave ppt devices
that are not attached to a VM disabled in the IOMMU and only restore
the devices to the host domain if the ppt(4) driver is detached from a
device.

As an added safety belt, disable busmastering for a pass-through device
when before adding it to the host domain during ppt(4) detach.

PR:		222937
2017-11-16 18:22:03 +00:00
Glen Barber f561a44183 MFC r320252, r320686, r325769:
r320252:
  In release/release.sh:
  - Rename chroot_arm_armv6_build_release() to chroot_arm_build_release()
    and make it hardware agnostic (such as armv6 -vs- armv7 -vs- arm64).
  - Evaluate EMBEDDED_TARGET differently so release/tools/arm.subr can
    be used for arm/armv6 and arm64/aarch64.
  - Update comments and copyright.

  In release/tools/arm.subr:
  - In arm_create_disk(), change the default alignment from 63 to 512k,
    fixing a boot issue on arm64 and EFI. [1]
  - Update comments and copyright.

 r320686:
  Fix the ftp-stage target by loosening the constraints on the TARGET
  and TARGET_ARCH variables.

 r325769:
  Update the GUMSTIX image build to use arm/arm TARGET/TARGET_ARCH.
  Update the TARGET/TARGET_ARCH matching in release/release.sh and
  release/Makefile.mirrors for simplification.

Note: The RPI3.conf addition from r320252 is not included, as it is
not supported on 10-STABLE.  Additionally, arm64/aarch64 changes are
also excluded from this commit.

Sponsored by:	The FreeBSD Foundation
2017-11-16 16:00:01 +00:00
Gordon Tetlow 92d61a5a38 MFC r325865
Properly bzero kldstat structure to prevent kernel information leak.

Security:	FreeBSD-SA-17:10.kldstat
Security:	CVE-2017-1088
2017-11-15 22:35:16 +00:00
Baptiste Daroussin 5787fd2f35 MFC r325737:
Update to 2017.10.21
2017-11-15 12:23:01 +00:00
Baptiste Daroussin 2ce7898d74 MFC r325717:
Remove __unused attributed on arguments that are actually used
2017-11-15 12:21:06 +00:00
Baptiste Daroussin 6dae661b8e MFC r325716:
Fix some nroff style issue
2017-11-15 12:19:11 +00:00
Eugene Grosbein fdaa28afdc Fix breakage in r325799 that removed a bit of code by my mistake.
Approved by:		avg (mentor)
2017-11-14 11:02:46 +00:00
Dag-Erling Smørgrav 32c93197e0 MFH (r325010): don't bother verifying a password that we know is too long.
Reported by:	jkim@
Security:	CVE-2016-6210
2017-11-14 10:49:07 +00:00
Eugene Grosbein 7eaf90d364 MFC r325559: ifconfig_<interface>_descr
Add suitable knob ifconfig_<interface>_descr for static interface description.
Document availability of interface descriptions within rc.conf(5).

Approved by:	avg (mentor)
2017-11-14 09:31:56 +00:00
Jamie Gritton a6bbfc588c MFC r297935:
Separate POSIX sem/shm objects in jails, by prepending the jail's path
  name to the object's "path".  While the objects don't have real path
  names, it's a filesystem-like namespace, which allows jails to be
  kept to their own space, but still allows the system / jail parent to
  access a jail's IPC.

MFC r297936:

  Separate POSIX mqueue objects in jails; actually, separate them by the
  jail's root, so jails that don't have their own filesystem directory
  also won't have their own mqueue namespace.

MFC r297976:

  Clean up some style(9) violations.

MFC r298567:

   Use the new PR_METHOD_REMOVE to clean up jail handling in POSIX
   message queues.

PR:		208082
Submitted by:	delphij
2017-11-13 23:21:17 +00:00
Konstantin Belousov d201dff4c4 MFC r325671:
Check that the pmc index is less than the number of hardware PMCs,
instead of asserting the condition.
2017-11-13 09:10:17 +00:00
Pedro F. Giffuni 84bdce81bc MFC r324962 (by fsu@):
Set doreallocblks sysctl value to zero by default because of
possibility of filesystem corruption.

Fedor has found some weird behavior in his tests.
2017-11-13 02:31:25 +00:00
Don Lewis 34b625c6fe MFC r325008
Fix Dummynet AQM packet marking function ecn_mark() and fq_codel /
fq_pie schedulers packet classification functions in layer2 (bridge mode).

Dummynet AQM packet marking function ecn_mark() and fq_codel/fq_pie
schedulers packet classification functions (fq_codel_classify_flow()
and fq_pie_classify_flow()) assume mbuf is pointing at L3 (IP)
packet. However, this assumption is incorrect if ipfw/dummynet is
used to manage layer2 traffic (bridge mode) since mbuf will point
at L2 frame.  This patch solves this problem by identifying the
source of the frame/packet (L2 or L3) and adding ETHER_HDR_LEN
offset when converting an mbuf pointer to ip pointer if the traffic
is from layer2.  More specifically, in dummynet packet tagging
function, tag_mbuf(), iphdr_off is set to ETHER_HDR_LEN if the
traffic is from layer2 and set to zero otherwise. Whenever an access
to IP header is required, mtodo(m, dn_tag_get(m)->iphdr_off) is
used instead of mtod(m, struct ip *) to correctly convert mbuf
pointer to ip pointer in both L2 and L3 traffic.

Submitted by:	lstewart
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D12506
2017-11-12 01:28:20 +00:00
Konstantin Belousov 8e007ba11d MFC r325567:
Zero whole struct ptrace_lwpinfo to not leak kernel stack data.

Security:	CVE-2017-1086
2017-11-10 12:31:58 +00:00
Hans Petter Selasky 73a85c9213 Remove the now obsolete "unify_tcp_port_space" ibcore module parameter.
Missed as part of the MFC of r324792 in r325611.

This is a direct commit.

Sponsored by:	Mellanox Technologies
2017-11-09 19:46:40 +00:00
Hans Petter Selasky b4b666dcbb MFC r325278:
Unconditionally include "opt_inet6.h" in the LinuxKPI.
This makes sure the INET6 macro gets properly defined,
also for kernel module builds.

Sponsored by:	Mellanox Technologies
2017-11-09 19:15:28 +00:00
Hans Petter Selasky a81e346f8e MFC r324792:
The remote DMA TCP portspace selector, RDMA_PS_TCP, is used for both
iWarp and RoCE in ibcore. The selection of RDMA_PS_TCP can not be used
to indicate iWarp protocol use. Backport the proper IB device
capabilities from Linux upstream to distinguish between iWarp and
RoCE. Only allocate the additional socket required for iWarp for RDMA
IDs when at least one iWarp device present. This resolves
interopability issues between iWarp and RoCE in ibcore

Reviewed by:		np @
Differential Revision:	https://reviews.freebsd.org/D12563
Sponsored by:		Mellanox Technologies
2017-11-09 19:00:11 +00:00
Hans Petter Selasky 0e131a698e MFC r324490:
Add support for parsing and using IPv6 addresses in krping.

Sponsored by:		Mellanox Technologies
2017-11-09 17:51:55 +00:00
Hans Petter Selasky bae97c674d Use MAC-based GID format for the GID table entries in mlx5ib(4) to be
compatible with the ibcore module in FreeBSD 10-stable.

This fixes RDMA over VLAN, because the MAC-based GID format embeds
the VLAN ID into the GID itself and this is what ibcore expects when
requesting GID indexes from the GID cache.

RoCE V1.5 and V2 is not supported in 10-stable by mlx5ib(4).
This is a direct commit.

Sponsored by:	Mellanox Technologies
2017-11-09 17:02:20 +00:00
Konstantin Belousov 13ccab15ee MFC r325270:
Consistently ensure that we do not load MXCSR with reserved bits set.
2017-11-08 11:39:42 +00:00
Andriy Gapon 815782e143 MFC r324757: remove spa_sync_on assert from spa_async_thread_vd 2017-11-08 09:35:06 +00:00
Pedro F. Giffuni 87307154bb MFC r325397:
ANSI-fy exec_shell_imgact().

Fix a stray space while here.

PR:	223317
2017-11-07 14:28:10 +00:00
Kenneth D. Merry 13b5259d08 MFC r325371
------------------------------------------------------------------------
  r325371 | ken | 2017-11-03 15:04:22 -0600 (Fri, 03 Nov 2017) | 19 lines

  Add the LTO-8 Type M density code (0x5d, LTO-8M) to libmt and the
  mt(1) man page.

  LTO-8 Type M (also known as M8) is a pristine LTO-7 cartridge
  formatted in a LTO-8 drive in a new, higher density format.  It
  has a separate density code, and is only readable in an LTO-8
  drive.

  lib/libmt/mtlib.c:
  	Add the LTO-8 Type M density code to the density table
  	in libmt.

  usr.bin/mt/mt.1:
  	Add the LTO-8 Type M density code to the density
  	table in the mt(1) man page.

  Sponsored by:	Spectra Logic

  ------------------------------------------------------------------------
2017-11-06 20:08:02 +00:00
Glen Barber 489a7b284e MFC r325156:
Set a default hostname for virtual machine images.

Sponsored by:	The FreeBSD Foundation
2017-11-06 18:07:23 +00:00
Eugene Grosbein 5f6849353d MFC r324212:
rsh: introduce new option -N disabling shutdown of socket sending path.

PR:		205144
Approved by:	mav (mentor)
2017-11-06 12:45:51 +00:00
Eugene Grosbein 0b3b1b320a MFC r324364: ftpd(8): fix user context handling
Apply authenticated user context after update of wtmp(5) at start of session,
so that ftpd process is not killed by kernel with SIGXFSZ when user has
"filesize" limit lower than size of system wtmp file. Same applies
to session finalization: revert to super-user context before update of wtmp.

If ftpd hits limit while writing a file at user request,
do not get killed with SIGXFSZ instantly but apparently ignore the signal,
process error and report it to the user, and continue with the session.

PR:		143570
Approved by:	mav (mentor)
2017-11-06 11:11:44 +00:00
Enji Cooper 60399e335f MFC r324928:
Remove dead stores

The return value of various snprintf calls was stored in `len` and not used
in many functions.
2017-11-05 22:36:32 +00:00
Enji Cooper 729a5c919e MFC r324862:
Clean up trailing whitespace in kdb_thr_ctx(..)
2017-11-05 22:34:27 +00:00
Rick Macklem d16c8a6970 MFC: r324639
Fix the client IP address reported by nfsdumpstate for 64bit arch and NFSv4.1.

The client IP address was not being reported for some NFSv4 mounts by
nfsdumpstate. Upon investigation, two problems were found for mounts
using IPv4. One was that the code (originally written and tested on i386)
assumed that a "u_long" was a "uint32_t" and would exactly store an
IPv4 host address. Not correct for 64bit arches.
Also, for NFSv4.1 mounts, the field was not being filled in. This was
basically correct, because NFSv4.1 does not use a callback address.
However, it meant that nfsdumpstate could not report the client IP addr.
This patch should fix both of these issues.
For IPv6, the address will still not be reported. The original NFSv4 RFC
only specified IPv4 callback addresses. I think this has changed and, if so,
a future commit to fix reporting of IPv6 addresses will be needed.
2017-11-05 20:28:28 +00:00
Rick Macklem 5940eed86b MFC: r324506
Fix forced dismount when a pNFS mount is hung on a DS.

When a "pnfs" NFSv4.1 mount is hung because of an unresponsive DS,
a forced dismount wouldn't work, because the RPC socket for the DS
was not being closed. This patch fixes this.
This will only affect "pnfs" mounts where the pNFS server's DS
is unresponsive (crashed or network partitioned or...).
Found during testing of the pNFS server.
2017-11-04 21:30:27 +00:00
Pedro F. Giffuni f650c78740 MFC r325067:
bsnmpd: Only refresh devtree if devd event is a new or removed device.

It makes sense to refresh the tree only when a device is inserted or
removed, otherwise bsnmpd needlessly wastes lots of CPU.

PR:		209368
2017-11-04 14:56:58 +00:00
Pedro F. Giffuni 9bcd95dfb2 MFC r325066:
Fix out-of-bounds read in libc/regex.

The bug is an out-of-bounds read detected with address sanitizer that
happens when 'sp' in p_b_coll_elems() includes NUL byte[s], e.g. if it's
equal to "GS\x00". In that case len will be equal to 4, and the
strncmp(cp->name, sp, len) call will succeed when cp->name is "GS" but the
cp->name[len] == '\0' comparison will cause the read to go out-of-bounds.

Checking the length using strlen() instead eliminates the issue.

The bug was found in LLVM with oss-fuzz:
	https://reviews.llvm.org/D39380

Obtained from:	Vlad Tsyrklevich through posting on openbsd-tech
2017-11-04 14:45:36 +00:00
Cy Schubert 804785977e MFC r325030:
Remove redundant sys/cdefs.h include.
2017-11-04 05:17:03 +00:00
Andrey V. Elsukov 314759e561 MFC r324947:
Add IPv6 support for O_TCPDATALEN opcode.

  PR:		222746
2017-10-31 11:09:39 +00:00
Andriy Gapon d918d935ce MFC r324957: iscsi_shutdown_post: do nothing if panic-ing 2017-10-31 09:58:51 +00:00
Andriy Gapon cf15321fa2 MFC r324694: never retry oustanding requests when terminating iscsi session 2017-10-31 09:57:10 +00:00
Andriy Gapon 589e936a56 MFC r324689: iscsi: do not hold the global lock while tearing down a session 2017-10-31 09:55:22 +00:00
Pedro F. Giffuni d01b8389df MFC r324620 (by fsu@):
Add extended attributes support to fuse kernel module.

Author:         ken
Reviewed by:    cem, pfg (mentor)
Approved by:    pfg (mentor)

Differential Revision: https://reviews.freebsd.org/D12485
2017-10-30 20:31:48 +00:00
Philip Paeps 247a1e70f5 MFC r325059: import tzdata 2017c 2017-10-30 15:57:48 +00:00
Andriy Gapon b676945ddf MFC r324348: MFV r316934: 7340 receive manual origin should override automatic origin 2017-10-30 10:35:45 +00:00
Andriy Gapon 76b8da2bd5 MFC r324347: MFV r316933: 5142 libzfs support raidz root pool (loader project)
FreeBSD note: we have long supported this feature, this commit only
removes a small difference in libzfs.
2017-10-30 10:33:05 +00:00
Andriy Gapon cbfe5e39c4 MFC r324346: MFV r316931: 6268 zfs diff confused by moving a file to another directory 2017-10-30 10:29:31 +00:00
Andriy Gapon 4192744ea4 MFC r324345: MFV r316877: 7571 non-present readonly numeric ZFS props do not have default valu 2017-10-30 09:01:52 +00:00
Konstantin Belousov 13e9b3bf6f MFC r324853:
Remove the support for mknod(S_IFMT), which created dummy vnodes with
VBAD type.
2017-10-29 09:48:28 +00:00
Cy Schubert d1cd92d233 Sync (make same) the offsetof macro definition in include/ with the
definition of the same in sys/sys/. The problem was discovered while
working on implementing a new C11 gets_s() for libc. (The new gets_s()
requires rsize_t found in include/stddef.h.) The solution to sync the two
definitions was suggested by ed@ while discussing D12667.

Suggested by:	ed
2017-10-29 04:33:50 +00:00
Stefan Eßer 3b02af23a3 MFC 324721: Add references to sysrc(8) to SEE ALSO.
MFC 324823: Mention sysrc(8) as scripting interface for config files.
2017-10-28 07:06:57 +00:00
Mark Johnston 802c3824a7 MFC r324809:
Free the right address range if kmem_back() fails in memguard_alloc().
2017-10-27 14:23:53 +00:00
Mark Johnston 860461b5e6 MFC r324704:
Fix a racy VI_DOOMED check in MNT_VNODE_FOREACH_ALL().
2017-10-25 01:07:12 +00:00
Enji Cooper e2ac84a25d Install missing test input file missed in r324418
While here, remove an unnecessary PACKAGE variable definition (only applies to
^/stable/11+).

This is a direct commit to ^/stable/10
2017-10-22 21:11:59 +00:00
Andriy Voskoboinyk daf0b12e1f MFC r324672:
ifnet(9): split ifc_alloc_unit() (should simplify code flow)

Allocate smallest unit number from pool via ifc_alloc_unit_next()
and exact unit number (if available) via ifc_alloc_unit_specific().

While here, address possible deadlock (mentioned in PR).

PR:		217401
Differential Revision:	https://reviews.freebsd.org/D12551
2017-10-21 10:48:06 +00:00
Hans Petter Selasky 04dcc8492d MFC r324445:
When showing the sleepqueues from the in-kernel debugger,
properly dump all the sleepqueues and not just the first one

History:
It appears that in the commit which introduced the code,
r165272, the array indexes of "sq_blocked[0]" and "td_name[i]"
were interchanged. In r180927 "td_name[i]" was corrected to
"td_name[0]", but "sq_blocked[0]" was left unchanged.

PR:		222624
Discussed with:	kmacy @
Sponsored by:	Mellanox Technologies
2017-10-20 10:06:02 +00:00
Hans Petter Selasky ab8b2ff7e9 MFC r323916:
Extend sysctl description for hw.usb.disable_enumeration .

PR:		222505
Submitted by:	Julian H. Stacey <[email protected]>
Sponsored by:	Mellanox Technologies
2017-10-20 10:01:21 +00:00
Ed Maste addb8348dd MFC r324595: ANSIfy vm_kern.c
PR:		222673
Submitted by:	[email protected]
2017-10-20 00:38:01 +00:00
Ed Maste 9399a86e16 MFC r324594: truss: mention 'H' in usage
r298427 (MFC of r295930) introduced the 'H' option to display thread
IDs, but did not add the option to usage().

PR:		222837
Submitted by:	Oliver Kiddle <[email protected]>
2017-10-20 00:33:49 +00:00
David C Somayajulu 135e556e63 MFC r324538
Added support driver state capture/retrieval
2017-10-19 17:37:33 +00:00
David C Somayajulu 49a8fe4038 MFC r324535
Add sanity checks in ql_hw_send() qla_send() to ensure that empty slots
in Tx Ring map to empty slot in Tx_buf array before Transmits. If the
checks fail further Transmission on that Tx Ring is prevented.
2017-10-19 17:35:37 +00:00
Andriy Gapon f43faa2092 MFC r324311: sysctl-s in a module should be accessible only when the module is initialized
Sponsored by:	Panzura
2017-10-19 08:00:34 +00:00
Andriy Gapon 07c9a00115 MFC r324312: fix the misleading log facility used in devd/zfs.conf 2017-10-19 07:23:47 +00:00
Andriy Gapon 3dcfbe3501 MFC r324309: remove heuristic error detection from ddi_strto*() 2017-10-19 07:21:45 +00:00
Gordon Tetlow 746aa8b814 Update wpa_supplicant/hostapd for 2017-01 vulnerability release.
Note this is a different patchset than what was applied to head and
stable/11 due to the much older version of wpa_supplicant/hostapd in
stable/10.

hostapd: Avoid key reinstallation in FT handshake
Prevent reinstallation of an already in-use group key
Extend protection of GTK/IGTK reinstallation of WNM-Sleep Mode cases
Fix TK configuration to the driver in EAPOL-Key 3/4 retry case
Prevent installation of an all-zero TK
Fix PTK rekeying to generate a new ANonce
TDLS: Reject TPK-TK reconfiguration
WNM: Ignore Key Data in WNM Sleep Mode Response frame if no PMF in use
WNM: Ignore WNM-Sleep Mode Response if WNM-Sleep Mode has not been used
WNM: Ignore WNM-Sleep Mode Response without pending request
FT: Do not allow multiple Reassociation Response frames
TDLS: Ignore incoming TDLS Setup Response retries

Submitted by: jhb
Obtained from:        https://w1.fi/security/2017-01/ (against later version)
Security:     FreeBSD-SA-17:07
Security:     CERT VU#228519
Security:     CVE-2017-13077
Security:     CVE-2017-13078
Security:     CVE-2017-13079
Security:     CVE-2017-13080
Security:     CVE-2017-13081
Security:     CVE-2017-13082
Security:     CVE-2017-13086
Security:     CVE-2017-13087
Security:     CVE-2017-13088
Differential Revision:	https://reviews.freebsd.org/D12724
2017-10-19 03:18:22 +00:00
Enji Cooper 43c145d323 MFC r324497:
Mute gcc warning about p not being possibly initialized

I'm running into this warning on a tinderbox run with gcc 4.2.1 with mips and
powerpc.
2017-10-17 15:53:19 +00:00
Enji Cooper 81a349bad3 MFC r324478:
Check the exit code from fsck_ffs instead of relying on MODIFIED being in the output

^/head@r323923 changed when MODIFIED is printed at exit. It's better to follow the
documented way of determining whether or not a filesystem is clean per fsck_ffs, i.e.,
ensure that the exit code is either 0 or 7.

The pass/fail determination is brittle prior to this commit, and ^/head@r323923 made
the issue apparent -- thus this needs to be fixed independent of ^/head@r323923.

PR:		222780
MFC with:	r323923
2017-10-17 15:49:36 +00:00
Hans Petter Selasky a3ee361f9b MFC r289568, r300676, r300677, r300719, r300720 and r300721:
Implement LinuxKPI module parameters as SYSCTLs.

The bool module parameter is no longer supported, because there is no
equivalent in FreeBSD 10-stable. These are converted into "int" type.

There are two macros available which control the behaviour of the
LinuxKPI module parameters:

- LINUXKPI_PARAM_PARENT allows the consumer to set the SYSCTL parent
where the modules parameters will be created.

- LINUXKPI_PARAM_PREFIX defines a parameter name prefix, which is
  added to all created module parameters.

The LinuxKPI module parameters also have a permissions value.
If any write bits are set we are allowed to modify the module
parameter runtime. Reflect this when creating the static SYSCTL
nodes.

The module_param_call() function is no longer supported.

Sponsored by:	Mellanox Technologies
2017-10-17 11:20:32 +00:00
Kirk McKusick 15baaff7b1 MFC of 324456.
Do not report filesystem as modified if only timestamp updated in superblock.
2017-10-16 21:55:31 +00:00
Brooks Davis f6d20b64f3 MFC r321256:
Include ARCH_FLAGS in CFLAGS when building modules.

Without this change, modules will match the default compiler
configuration which may not be the same as the kernel values.

Reviewed by:	imp
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D11633
2017-10-15 22:45:25 +00:00
Brooks Davis c8f2b71eae MFC r320999:
Add 32-bit compat for kinfo_proc's ki_tdaddr.

This appears to have been an oversight in r213536.

Reviewed by:	markj
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D11521
2017-10-15 22:39:31 +00:00
Brooks Davis 7e2d718b00 MFC r324243:
Remove an unneeded and incorrect memset().

On Variant I TLS architectures (aarch64, arm, mips, powerpc, and riscv)
the __libc_allocate_tls function allocates thread local storage memory
with calloc(). It then copies initialization data over the portions with
non-zero initial values. Before this change it would then pointlessly
zero the already zeroed remainder of the storage. Unfortunately the
calculation was wrong and it would zero TLS_TCB_SIZE (2*sizeof(void *))
additional bytes.

In practice, this overflow only matters if the TLS segment is sized such
that calloc() allocates less than TLS_TCB_SIZE extra memory. Even
then, the likely result will be zeroing part of the next bucket. This
coupled with the impact being confined to Tier II platforms means there
will be no security advisory for this issue.

Reviewed by:	kib, dfr
Discussed with:	security-officer (delphij)
Found by:	CHERI
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D12547
2017-10-14 16:49:39 +00:00
John Baldwin e6f07bccc4 MFC 324039: Don't defer wakeup()s for completed journal workitems.
Normally wakeups() are performed for completed softupdates work items
in workitem_free() before the underlying memory is free()'d.
complete_jseg() was clearing the "wakeup needed" flag in work items to
defer the wakeup until the end of each loop iteration.  However, this
resulted in the item being free'd before it's address was used with
wakeup().  As a result, another part of the kernel could allocate this
memory from malloc() and use it as a wait channel for a different
"event" with a different lock.  This triggered an assertion failure
when the lock passed to sleepq_add() did not match the existing lock
associated with the sleep queue.  Fix this by removing the code to
defer the wakeup in complete_jseg() allowing the wakeup to occur
slightly earlier in workitem_free() before free() is called.
2017-10-13 22:40:57 +00:00
John Baldwin 9e6d27c32f MFC 324073: Use UMA_ALIGNOF() for name cache UMA zones.
This fixes kernel crashes due to misaligned accesses to the 64-bit
time_t embedded in struct namecache_ts in MIPS n32 kernels.
2017-10-13 21:58:44 +00:00
John Baldwin dd9e892a39 MFC 324072: Add UMA_ALIGNOF().
This is a wrapper around _Alignof() that sets the alignment for a zone
to the alignment required by a given type.  This allows the compiler to
determine the proper alignment rather than having the programmer try to
guess.
2017-10-13 17:11:08 +00:00
Andriy Gapon 28bd48606e MFC r323612: gmirror: treat ENXIO as disk disconnect, not media error 2017-10-13 09:14:05 +00:00
Andriy Gapon e8471c46d5 MFC r323528: MFV r323527: 5815 libzpool's panic function doesn't set global panicstr 2017-10-13 09:11:24 +00:00
Andriy Gapon 595f7c8e12 MFC r323525: MFV r323523: 8331 zfs_unshare returns wrong error code for smb unshare failure 2017-10-13 09:07:58 +00:00
Andriy Gapon d81ca701a1 MFC r323524: MFV r316932: 6280 libzfs: unshare_one() could fail with EZFS_SHARENFSFAILED 2017-10-13 09:05:20 +00:00
Sepherosa Ziehau d64e6089db MFC 324517
hyperv/hn: Enable transparent VF by default.

    Sponsored by:   Microsoft
2017-10-13 02:29:43 +00:00
Sepherosa Ziehau 165809463f MFC 324489,324516
324489
    hyperv/hn: Workaround erroneous hash type observed on WS2016.

    Background:
    - UDP 4-tuple hash type is unconditionally enabled in Hyper-V on WS2016,
      which is _not_ affected by NDIS_OBJTYPE_RSS_PARAMS.
    - Non-fragment UDP/IPv4 datagrams' hash type is delivered to VM as
      TCP_IPV4.

    Currently this erroneous behavior only applies to WS2016/Windows10.

    Force l3/l4 protocol check, if the RXed packet's hash type is TCP_IPV4,
    and the Hyper-V is running on WS2016/Windows10.  If the RXed packet is
    UDP datagram, adjust mbuf hash type to UDP_IPV4.

    Sponsored by:   Microsoft

324516
    hyperv/hn: Workaround erroneous hash type observed on WS2016 for VF.

    The background was described in r324489.

    Sponsored by:   Microsoft
2017-10-13 02:26:39 +00:00
Sepherosa Ziehau ec114c75d7 MFC 324488
hyperv/vmbus: Expose Hyper-V major version.

    Sponsored by:   Microsoft
2017-10-13 02:16:35 +00:00
Sepherosa Ziehau 9cba853cdb MFC 324487
hyperv/vmbus: Add tunable to pin/unpin event tasks.

    Event tasks are pinned to their respective CPU by default, in the same
    fashion as they were.

    Unpin the event tasks by setting hw.vmbus.pin_evttask to 0, if certain
    CPUs serve special purpose.

    Sponsored by:   Microsoft
2017-10-13 02:01:03 +00:00
Rick Macklem af3bb4d023 MFC: r324074
Fix a memory leak that occurred in the pNFS client.

When a "pnfs" NFSv4.1 mount was unmounted, it didn't free up the layouts
and deviceinfo structures. This leak only affects "pnfs" mounts and only
when the mount is umounted.
Found while testing the pNFS Flexible File layout client code.
2017-10-11 23:42:29 +00:00
Rick Macklem 148605ebdd MFC: r323978
Change a panic to an error return.

There was a panic() in the NFS server's write operation that didn't
need to be a panic() and could just be an error return.
This patch makes that change.
Found by code inspection during development of the pNFS service.
2017-10-11 23:33:50 +00:00
Rick Macklem 7363c689ec MFC: r323689
Fix bogus FREAD with NFSV4OPEN_ACCESSREAD. No functional change.

The code in nfscl_doflayoutio() bogusly used FREAD instead of
NFSV4OPEN_ACCESSREAD. Since both happen to be defined as "1", this
worked and the patch doesn't result in a functional change.
Found by inspection during development of Flex File Layout support.
2017-10-11 23:21:24 +00:00
Hans Petter Selasky 9f9a676cfa MFC r315404:
Add basic support for VIMAGE to the LinuxKPI and ibcore.

Support is implemented by mapping Linux's "struct net" into FreeBSD's
"struct vnet". Currently only vnet0 is supported by ibcore.

Sponsored by:		Mellanox Technologies
2017-10-11 10:56:59 +00:00
Hans Petter Selasky f94ae6eff9 MFC r315405, r323351 and r323364:
Add helper function similar to ip_dev_find() to the LinuxKPI to lookup
a network device by its IPv6 address in the given VNET.

Sponsored by:		Mellanox Technologies
2017-10-11 10:20:53 +00:00
Hans Petter Selasky 96607a6d9d MFC r324202:
Make sure the doorbell lock is valid for the i386 version
of the mlx5en(4) driver.

Tested by:		gallatin @
Sponsored by:		Mellanox Technologies
2017-10-11 10:04:17 +00:00
Sepherosa Ziehau 55896b8181 MFC 324050
tcp: Don't "negotiate" MSS.

    _NO_ OSes actually "negotiate" MSS.

    RFC 879:
    "... This Maximum Segment Size (MSS) announcement (often mistakenly
    called a negotiation) ..."

    This negotiation behaviour was introduced 11 years ago by r159955
    without any explaination about why FreeBSD had to "negotiate" MSS:

        In syncache_respond() do not reply with a MSS that is larger than what
        the peer announced to us but make it at least tcp_minmss in size.

        Sponsored by:   TCP/IP Optimization Fundraise 2005

    The tcp_minmss behaviour is still kept.

    Syncookie fix was prodded by tuexen, who also helped to test this
    patch w/ packetdrill.

    Reviewed by:    tuexen, karels, bz (previous version)
    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D12430
2017-10-11 06:28:46 +00:00
Cy Schubert 915881bdc2 MFC r324249, 324260, and 324277
Clarify the wording describing the stayopen flag and style fixes.
2017-10-11 05:07:37 +00:00
Cy Schubert 4762949123 MFC r323945 and 323962
Fix misspellings, typos and /* border misalignments.
2017-10-11 05:02:36 +00:00
Pedro F. Giffuni 340f3802c2 MFC r322368, r322371:
fnmatch(3): improve POSIX conformance.

In a recent interpretation[1], "\\" shall return a non-zero value
(indicating either no match or an error).

The fix involves a change over r254091 and now the behavior matches the
Sun/IBM/HP closed source implementations and also likely musl libc.

Submitted by:	Joerg Schilling <joerg at schily.net>

[1] http://austingroupbugs.net/view.php?id=806
2017-10-10 21:04:40 +00:00
Sepherosa Ziehau 647bc632aa MFC 324049,324077
324049
    hyperv/hn: Fix UDP checksum offload issue in Azure.

    UDP checksum offload does not work in Azure if following conditions are
    met:
    - sizeof(IP hdr + UDP hdr + payload) > 1420.
    - IP_DF is not set in IP hdr

    Use software checksum for UDP datagrams falling into this category.

    Add two tunables to disable UDP/IPv4 and UDP/IPv6 checksum offload, in
    case something unexpected happened.

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D12429

324077
    hyperv/hn: Unbreak i386 building.

    Reported by:    cy
    Sponsored by:   Microsoft
2017-10-10 03:40:38 +00:00
Sepherosa Ziehau e976c007d3 MFC 324048
hyperv/hn: Set tcp header offset for CSUM/LSO offloading.

    No observable effect; better safe than sorry.

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D12417
2017-10-10 03:35:24 +00:00
Sepherosa Ziehau 6f0a6499cb MFC 323728,323729
323728
    hyperv/hn: Fix MTU setting

    - Add size of an ethernet header to the value configured to NVS.  This
      does not seem to have any effects if MTU is 1500, but fix hypervisor
      side's setting if MTU > 1500.
    - Override the MTU setting according to the view from the hypervisor
      side.

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D12352

323729
    hyperv/hn: Incease max supported MTU

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D12365
2017-10-10 03:29:36 +00:00
Sepherosa Ziehau c40d235839 MFC 323727,324316
323727
    hyperv/hn: Apply VF's RSS setting

    Since in Azure SYN and SYN|ACK go through the synthetic parts while the
    rest of the same TCP flow goes through the VF, apply VF's RSS settings
    to synthetic parts to have a consistent hash value/type for the same TCP
    flow.

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D12333

324316
    hyperv/hn: Fix options RSS building

    Reported by:    np
    Sponsored by:   Microsoft
2017-10-10 03:21:17 +00:00
Sepherosa Ziehau 12f12d3340 MFC 323176
hyperv/hn: Log RSS capabilities mask.

    This helps to detect when UDP hash types can be supported.

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D12177
2017-10-10 03:02:54 +00:00
Sepherosa Ziehau 9a52ced0ca MFC 323175
hyperv/hn: Implement SIOCGIFRSS{KEY,HASH}.

    The conditional compiling in the review request is removed, since
    these IOCTLs will be available in stable/10 and stable/11.

    Reviewed by:    gallatin
    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D12175
2017-10-10 02:57:30 +00:00
Sepherosa Ziehau 3f2b4e23a1 MFC 323170
if: Add ioctls to get RSS key and hash type/function.

    It will be needed by hn(4) to configure its RSS key and hash
    type/function in the transparent VF mode in order to match VF's
    RSS settings. The description of the transparent VF mode and
    the RSS hash value issue are here:
    https://svnweb.freebsd.org/base?view=revision&revision=322299
    https://svnweb.freebsd.org/base?view=revision&revision=322485

    These are generic enough to promise two independent IOCs instead
    of abusing SIOCGDRVSPEC.

    Setting RSS key and hash type/function is a different story,
    which probably requires more discussion.

    Comment about UDP_{IPV4,IPV6,IPV6_EX} were only in the patch
    in the review request; these hash types are standardized now.

    Reviewed by:    gallatin
    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D12174
2017-10-10 02:35:04 +00:00
Sepherosa Ziehau f44ae60927 MFC 322488
hyperv: Update copyright for the files changed in 2017

    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D11982
2017-10-10 02:22:34 +00:00
Martin Matuska 4ed6d57568 MFH r324148:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #905: Support for Zstandard read and write filters
  PR #922: Avoid overflow when reading corrupt cpio archive
  Issue #935: heap-based buffer overflow in xml_data (CVE-2017-14166)
  OSS-Fuzz 2936: Place a limit on the mtree line length
  OSS-Fuzz 2394: Ensure that the ZIP AES extension header is large enough
  OSS-Fuzz 573: Read off-by-one error in RAR archives (CVE-2017-14502)

Security:	CVE-2017-14166, CVE-2017-14502
2017-10-08 20:55:45 +00:00
Enji Cooper 19a803dbea MFC note: MK_LIBSOFT doesn't apply to ^/stable/10 .
MFC r322633,r324143:

r322633:

Honor NO_RTLD for rtld-elf, similar to what's done in libexec/Makefile, with
libexec/rtld-elf/... for MK_{LIB32,LIBSOFT}.

r324143:

Adjust r322633 to only apply to libexec/rtld-elf, and not usr.bin/ldd,
when running build32/install32

This unbreaks installing usr.bin/ldd as ldd32 when NO_RTLD is defined.

MFC with:       r322633
2017-10-07 18:49:39 +00:00
Devin Teske 985195fe16 MFC SVN r295342-295344
Differential Revision:	https://reviews.freebsd.org/D12568
Submitted by:	Vinicius Zava (egypcio at googlemail.com)
Reviewed by:	allanjude
2017-10-06 18:22:36 +00:00
David C Somayajulu 75330d56ae MFC r324065
Tx Ring Shadow Consumer Index Register needs to be cleared prior
to passing it's physical address to the FW during Tx Create Context.
2017-10-05 18:58:24 +00:00
David C Somayajulu d20c09f125 MFC r324026
Fix delete all multicast addresses

Submitted by:[email protected]
2017-10-05 18:51:32 +00:00
Andriy Gapon 51d684ddf9 MFC r323578,r323769: dounmount: do not release the mount point's reference
on the covered vnode

As long as mnt_ref is not zero there can be a consumer that might try
to access mnt_vnodecovered.  For this reason the covered vnode must not
be freed until mnt_ref goes to zero.
So, move the release of the covered vnode to vfs_mount_destroy.
2017-10-05 07:16:31 +00:00
Enji Cooper 360ea66422 MFC r322951:
Respect MK_TCSH with build-tools and native-xtools

This helps reduce the WORLDTMP footprint slightly.

Based on a patch I submitted 5 years ago to GNATS.

PR:		174051
Relnotes:	yes (anyone who cross-builds with MK_TCSH=yes will run into
		     build failures if the host doesn't have tcsh(1))
Reminded by:	Fabian Keil <[email protected]>
2017-10-04 16:35:58 +00:00
Enji Cooper 2a47d02e14 Revert r324132
I accidentally used the wrong commit message

Reported by:	rgrimes
2017-10-04 16:33:22 +00:00
Andriy Gapon 18d847dd0b MFC r323791: MFV r323790: 8567 Inconsistent return value in zpool_read_label 2017-10-04 07:43:23 +00:00
Andriy Gapon ff7708d97a MFC r323483: zfsctl_snapdir_lookup should be able to handle an uncovered vnode 2017-10-04 07:37:57 +00:00
Andriy Gapon e2f49a2f4d MFC r323481: zfsvfs_hold: assert that the busied filesystem can not be unmounted 2017-10-04 07:35:49 +00:00
Glen Barber 47c8054205 Fix a path in a Subversion example.
While here, recommend https.

PR:		222761
Submitted by:	1983-01-06 <at> gmx.net
Sponsored by:	The FreeBSD Foundation
2017-10-03 19:08:16 +00:00
Marius Strobl 84470bb4e5 Now that 10.4-RELEASE is out, move stable/10 back to STABLE.
Approved by:	re (implicit)
2017-10-03 13:20:17 +00:00
John Baldwin f2c383df2c MFC 323994: Log signal number passed to PT_STEP requests in KTR_PTRACE traces. 2017-10-02 18:03:55 +00:00
Andriy Gapon 713d8c06c8 MFC r323918: MFV r323917: 8648 Fix range locking in ZIL commit codepath
This fixes a problem introduced in r320496, MFC of r308782.
2017-10-02 12:47:35 +00:00
Eugene Grosbein 245441c11a MFC r323873, r324081: Unprotected modification of ng_iface(4)
private data leads to kernel panic. Fix a race with per-node
read-mostly lock and refcounting for a hook.

PR:			220076
Tested by:		peixoto.cassiano
Approved by:		mav (mentor)
Relnotes:		yes
Differential Revision:	https://reviews.freebsd.org/D12435
2017-10-01 19:40:29 +00:00
Andriy Gapon cb704dcd6e MFC r323522: slightly simplify zfs_vptocnp 2017-10-01 14:50:58 +00:00
Enji Cooper e302bab34e MFC r322635:
Fix WARNS

- Remove ad hoc inet_ntoa prototype declaration; it's already handled
  by the included headers.
- De-K&Rify the function prototypes for eachres_whoami(..),
  eachres_getfile(..), and main(..).

PR:		71667
Tested with:	clang (5.0), gcc (4.2.1, 5)
2017-09-30 20:50:31 +00:00
Enji Cooper 50ef68ecac Regenerate src.conf(5) per r324140 2017-09-30 20:48:02 +00:00
Enji Cooper e6291c1be1 MFC r321952:
Allowing MK_NLS_CATALOGS to be enabled if MK_NLS == no doesn't make a whole lot
of sense. Anchor MK_NLS_CATALOGS being enabled off of MK_NLS.
2017-09-30 20:46:34 +00:00
Enji Cooper c0eb492e98 MFC r322951:
Respect MK_TCSH with build-tools and native-xtools

This helps reduce the WORLDTMP footprint slightly.

Based on a patch I submitted 5 years ago to GNATS.

PR:		174051
Relnotes:	yes (anyone who cross-builds with MK_TCSH=yes will run into
		     build failures if the host doesn't have tcsh(1))
Reminded by:	Fabian Keil <[email protected]>
2017-09-30 20:44:25 +00:00
Enji Cooper 08d5b51800 MFC r314601:
r314601 (by des):

Re-apply part of r311585 which was inadvertantly reverted in the upgrade
to 7.3p1.  The other part (which adds -DLIBWRAP to sshd's CFLAGS) is
still in place.
2017-09-30 20:31:27 +00:00
Enji Cooper 8d8eaaed4f MFC r322441:
Delete trailing whitespace
2017-09-30 20:07:57 +00:00
Enji Cooper d7ff911992 MFC r321845:
Standardize on SRCTOP instead of .CURDIR-relative paths
2017-09-30 20:06:36 +00:00
John Baldwin da1150d269 MFC 323631: Add an -a flag to getconf.
When -a is specified, the name and value of all system or path
configuration values is reported to standard output.

Sponsored by:	Chelsio Communications
2017-09-30 17:30:22 +00:00
Kristof Provost 3beccaf9a5 MFC r323864
bridge: Set module version

This ensures that the loader will not load the module if it's also built in to
the kernel.

PR:             220860
Submitted by:   Eugene Grosbein <[email protected]>
2017-09-30 10:16:15 +00:00
David C Somayajulu 03e11d1e98 MFC r323824
1. ql_hw.c:
    	In ql_hw_send() return EINVAL when TSO framelength exceeds max
    	supported length by HW.(davidcs)
    2. ql_os.c:
    	In qla_send() call bus_dmamap_unload before freeing mbuf or
    	recreating dmmamap.(davidcs)
    	In qla_fp_taskqueue() Add additional checks for IFF_DRV_RUNNING
    	Fix qla_clear_tx_buf() call bus_dmamap_sync() before freeing
    	mbuf.

Submitted by:	[email protected]
2017-09-26 21:18:43 +00:00
David C Somayajulu 1e168504e5 MFC r323782
Add sysctl "enable_minidump" to turn on/off automatic minidump retrieval
2017-09-26 21:16:10 +00:00
David C Somayajulu 2a7fd3ecc1 MFC r323781
Update minidump template for version 5.4.66
2017-09-26 21:13:58 +00:00
Andriy Gapon 0bab1e3657 MFC r323480: zfs_get_vfs: reference a requested filesystem instead of vfs_busy-ing it
Sponsored by:	Panzura
2017-09-26 09:32:29 +00:00
Andriy Gapon 0779110c15 MFC r323479,r323491: zfs: tighten debug versions of ZTOV and VTOZ
Sponsored by:	Panzura
2017-09-26 08:45:11 +00:00
Jung-uk Kim d80f9ccbd6 MFC: r323840
Remove an ancient comment about the existence of READ(16)/WRITE(16) for MMC.
2017-09-25 18:26:31 +00:00
Glen Barber e983a222b0 MFC r323924:
Revert r323812 from release/tools/arm.subr, which has broken the
 build on arm/armv6 images.

Pointyhat:	gjb (myself)
MFC note:	releng/10.4 has broken because of this
Sponsored by:	The FreeBSD Foundation
2017-09-22 14:40:04 +00:00
Marius Strobl 6fe9f52e55 - Akin r302691 in head, synchronize the build stripping for the disc1
image with that of the bootonly image (but similarly modulo games
  and groff(1)) as the amd64 disc1 image is overflowing. This also
  removes the defunct WITHOUT_ATF.
- Remove the misspelled WITHOUT_INSTALLIB (also in place with correct
  spelling, i. e. WITHOUT_INSTALLLIB) from the bootonly image build
  stripping.

This is a direct commit to stable/10 as the corresponding knobs have
different names in head and counterparts to e. g. MK_DEBUG_FILES and
MK_TESTS default to off in stable/10 in the first place.
2017-09-22 04:57:42 +00:00
John Baldwin cd0f1220df MFC 323025: Read max_stack_flags from correct object.
'obj' is not initialized here.

Sponsored by:	DARPA / AFRL
2017-09-21 20:59:36 +00:00
Marius Strobl d966327a88 MFC: r285215
remove _NORMAL flag which isn't suppose to be used w/ _alloc_ctx...

MFC: r285289

address an issue where consumers, like IPsec, can reuse the same
session in multiple threads w/o locking..  There was a single fpu
context shared per session, if multiple threads were using the session,
and both migrated away, they could corrupt each other's fpu context...

MFC: r285297

upon further examination, it turns out that _unregister_all already
provides the guarantee that no threads will be in the _newsession code..

MFC: r298332

aesni(4): Initialize error before use [1]

Reported by:	Coverity [1]
CID:		1331554 [1]
2017-09-21 19:30:32 +00:00
Marius Strobl 48e2d5d746 MFC: r275751
Add _NEW flag to mtx(9), sx(9), rmlock(9) and rwlock(9).
A _NEW flag passed to _init_flags() to avoid check for double-init.
2017-09-21 19:24:11 +00:00
Cy Schubert 5cb8b673fd MFC r323715:
Don't use an apostrophe in a possesive pronoun.
2017-09-21 03:18:11 +00:00
Marius Strobl 561b312cda MFC: r320916
Reset unsupported SFP tuneable back to original entry name.
2017-09-20 21:51:10 +00:00
Marius Strobl 353c7d68cd Unbreak netmap(4) support in ixgbe(4) after r315333:
- Both ixgbe_netmap.c and ixv_netmap.c assumed a netmap(4) driver
  newer than what's actually in stable/10.
- Additionally, at the bottom line ixv_netmap.c did exactly the same
  as ixgbe_netmap.c, i. e. used IXGBE_TDH() as appropriate for PFs
  only instead of IXGBE_VFTDH() and tried to configure CRC stripping
  although the corresponding registers aren't available to VFs in the
  first place.

With these changes, the netmap(4) support in ixgbe(4) is in line
again with the code in sys/dev/netmap/ixgbe_netmap.h as of r295008.
Breakage reported by: Slawa Olhovchenkov

Just like r315333 that never existed in head, this is a direct commit
to stable/10. However, ixgbe(4) in head has a related bug in that it
assumes a netmap(4) driver API older than what's in head and also
does the wrong things for VFs as it uses the PF-only ixgbe_netmap.c
for both PFs and VFs in the first place.
2017-09-20 21:22:20 +00:00
John Baldwin 402108e463 MFC 322270: Fix a NULL pointer dereference in mly_user_command().
If mly_user_command fails to allocate a command slot it jumps to an 'out'
label used for error handling.  The error handling code checks for a data
buffer in 'mc->mc_data' to free before checking if 'mc' is NULL.  Fix by
just returning directly if we fail to allocate a command and only using
the 'out' label for subsequent errors when there is actual cleanup to
perform.

PR:		217747
Reported by:	PVS-Studio
2017-09-20 20:48:21 +00:00
Glen Barber 27f984e9b1 MFC r323812:
Bootstrap etcupdate(8) and mergemaster(8) databases when creating
 virtual machine images and embedded images, similar to what is
 done when extracting base.txz to the target root filesystem in
 a new installation.

Approved by:	re (marius, insta-MFC)
Sponsored by:	The FreeBSD Foundation
2017-09-20 17:09:04 +00:00
Hans Petter Selasky 7314c098cc MFC r322530 and r323220:
Add new USB quirk(s).

PR:			221775
PR:			221328
Sponsored by:		Mellanox Technologies
2017-09-20 14:43:55 +00:00
Andriy Gapon f6cc61cefb MFC r323540: jedec_ts: add many more devices from various vendors
The new IDs are taken from the hardware to which I have access
and from open datasheets.

Also, the hardware probing is moved to the device probe method.
2017-09-20 06:29:11 +00:00
Andriy Gapon 0cfffb2fcf MFC r323482: zfs_ctldir: remove obsolete / bogus ARGSUSED lint directives
None of the tagged functions had unused parameters.
2017-09-19 12:43:47 +00:00
Andriy Gapon 01ef7e4e34 MFC r322241: MFV r322240: 8491 uberblock on-disk padding to reserve space for smoothly merging zpool checkpoint & MMP in ZFS
illumos/illumos-gate@79c2b812ee
https://github.com/illumos/illumos-gate/commit/79c2b812ee2010ebf20fdd92dc5f06b59000a94c

https://www.illumos.org/issues/8491
  The zpool checkpoint feature in DxOS added a new field in the uberblock.
  The Multi-Modifier Protection Pull Request from ZoL adds two new fields in the
  uberblock (Reference: https://github.com/zfsonlinux/zfs/pull/6279).
  As these two changes come from two different sources and once upstreamed and
  deployed will introduce an incompatibility with each other we want
  to upstream a change that will reserve the padding for both of them so
  integration goes smoothly and everyone gets both features.

Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: Brian Behlendorf <[email protected]>
Reviewed by: Olaf Faaland <[email protected]>
Approved by: Gordon Ross <[email protected]>
Author: Serapheim Dimitropoulos <[email protected]>
2017-09-19 09:26:13 +00:00
Andriy Gapon 71c457c638 MFC r322228: MFV r322227: 8377 Panic in bookmark deletion
illumos/illumos-gate@42418f9e73
https://github.com/illumos/illumos-gate/commit/42418f9e73f0d007aa87675ecc206c26fc8e073e

https://www.illumos.org/issues/8377
  The problem is that when dsl_bookmark_destroy_check() is executed from open
  context (the pre-check), it fills in dbda_success based on the existence of the
  bookmark.
  But the bookmark (or containing filesystem as in this case) can be destroyed
  before we get to syncing context. When we re-run dsl_bookmark_destroy_check()
  in syncing
  context, it will not add the deleted bookmark to dbda_success, intending for
  dsl_bookmark_destroy_sync() to not process it. But because the bookmark is
  still in dbda_success
  from the open-context call, we do try to destroy it.
  The fix is that dsl_bookmark_destroy_check() should not modify dbda_success
  when called from open context.

Reviewed by: Paul Dagnelie <[email protected]>
Reviewed by: Pavel Zakharov <[email protected]>
Reviewed by: George Wilson <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
Author: Matthew Ahrens <[email protected]>
2017-09-19 09:15:07 +00:00
Andriy Gapon b7c1ea5ed8 MFC r321471: spa_import_rootpool should be able to handle an imported root pool
That is required to support reboot -r with a new root filesystem being
on an already imported pool.

PR:		210721
2017-09-19 08:43:45 +00:00
Andriy Gapon 3462719c98 MFC r320352: zfs: port vdev_file part of illumos change 3306
3306 zdb should be able to issue reads in parallel
illumos/illumos-gate/31d7e8fa33fae995f558673adb22641b5aa8b6e1
https://www.illumos.org/issues/3306

The upstream change was made before we started to import upstream commits
individually.  It was imported into the illumos vendor area as r242733.
That commit was MFV-ed in r260138, but as the commit message says
vdev_file.c was left intact.

This commit actually implements the parallel I/O for vdev_file using a
taskqueue with multiple thread.  This implementation does not depend on
the illumos or FreeBSD bio interface at all, but uses zio_t to pass
around all the relevent data.  So, the code looks a bit different from
the upstream.

This commit also incorporates ZoL commit
zfsonlinux/zfs/bc25c9325b0e5ced897b9820dad239539d561ec9 that fixed
https://github.com/zfsonlinux/zfs/issues/2270
We need to use a dedicated taskqueue for exactly the same reason as ZoL
as we do not implement TASKQ_DYNAMIC.
2017-09-19 08:39:54 +00:00
Andriy Gapon 8b033dd98f MFC r320151: remove bogus declaration of malloc from tcp_wrappers
The declaration was already inactive when INET6 was enabled
and it causes a build error in the other case because of
a conflict with the correct definition in stdlib.h.
2017-09-19 08:34:13 +00:00
Andriy Gapon 4a7d58e1d4 MFC r320266: jedec_ts: add support for devices manufactured by IDT
Full manufacturer name is Integrated Device Technology, Inc.
Supported devices include TSE2002B3C and TS3000B3A.
2017-09-19 08:29:53 +00:00
Andriy Gapon 2657317f37 MFV r320195: bhyveload: correctly query size of disks
On FreeBSD fstat(2) works fine for querying sizes of plain files,
but not so much for character devices.
So, use DIOCGMEDIASIZE to try to get the correct size for disks
and disk-like devices (e.g. zvols).

PR:		220186
2017-09-19 08:19:20 +00:00
Andriy Gapon 74312db898 MFV r318962: Allow PROBE_SPINUP to fail in CAM ATA transport
The motivation for this is two-fold.

1. Some old WD SATA disks may appear as if they need to be spun up
when they are already spinning.  Those disks would respond with
an error to the spin-up request.

2. Even if we really fail to spin up the disk, we still can try to
proceed to the subsequent phases.  If we fail later on, then no
difference.  Otherwise we get a chance to communicate with the
disk which is better than completely ignoring it, because a user
can try to recover the disk.
2017-09-19 07:39:39 +00:00
Andriy Gapon 5684d73ce7 MFC r319746,r319747,r319769: 8269 dtrace stddev aggregation is normalized incorrectly
illumos/illumos-gate@79809f9cf4
https://github.com/illumos/illumos-gate/commit/79809f9cf402f130667349b2d4007ecd65d63c6f

https://www.illumos.org/issues/8269
  It seems that currently normalization of stddev aggregation is done
  incorrectly.
  We divide both the sum of values and the sum of their squares by the
  normalization factor. But we should divide the sum of squares by the
  normalization factor squared to scale the original values properly.

FreeBSD note: the actual change was committed in r316853, this commit
adds the test files and record merge information.

Reviewed by: Bryan Cantrill <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
Author: Andriy Gapon <[email protected]>

Sponsored by:	Panzura
2017-09-19 07:31:53 +00:00
Andriy Gapon 95883ab780 MFC r319212: fix indentation 2017-09-19 07:19:27 +00:00
Glen Barber b9eb76d00a - Prune stale entries from 10.3-RELEASE.
- Prune entries from errata.xml and security.xml.
- Update versions to reflect 10.4-RELEASE.

Sponsored by:	The FreeBSD Foundation
2017-09-18 15:17:07 +00:00
Cy Schubert 5a2840a603 MFC r323478:
Improve the wording of a comment describing why EAGAIN is the error code.
2017-09-18 00:17:53 +00:00
Cy Schubert 14cd2bf09a MFC r322112:
krb5_err.h is generated from a .et file in kerberos5/lib/libkrb5.
As kerberos5/lib/krb5 include files are already referenced it makes
no sense to generate it again here.
2017-09-18 00:13:48 +00:00
Baptiste Daroussin 61d73a2c26 MFC r323160:
Update pci_vendors to 2017-09-01
2017-09-17 06:35:33 +00:00
Marius Strobl 3822029869 MFC: r322669
In fetch_resolve() if the port number or service name is included
in the host argument (e. g. "www.freebsd.org:443"), correctly set
the service pointer accordingly.  Previously, the service pointer
was set to the separator instead, causing getaddrinfo(3) to fail.
2017-09-17 01:32:45 +00:00
Marius Strobl 43616ffe4d - Reset stable/10 back to -PRERELEASE status now that releng/10.4
has been branched.
- Update __FreeBSD_version to reflect the new -STABLE branch.
- Switch the pkg(8) configuration for the default installation and the
  DVD image creation back to the latest set, i. e. revert r322737.

Approved by:	re (implicit)
2017-09-15 00:32:22 +00:00
1819 changed files with 333024 additions and 262056 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
*.c diff=cpp
*.h diff=cpp
*.cpp diff=cpp
*.hpp diff=cpp
*.py diff=python
+18
View File
@@ -0,0 +1,18 @@
_.tinderbox.*
_.amd64.*
_.arm.*
_.arm64.*
_.i386.*
_.ia64.*
_.mips.*
_.pc98.*
_.powerpc.*
_.riscv.*
_.sparc64.*
_.sun4v.*
GPATH
GRTAGS
GTAGS
ID
cscope.out
?cscope.out
+1 -1
View File
@@ -144,7 +144,7 @@ _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
# We often need to use the tree's version of make to build it.
# Choices add to complexity though.
# We cannot blindly use a make which may not be the one we want
# so be exlicit - until all choice is removed.
# so be explicit - until all choice is removed.
.if !defined(WITHOUT_BMAKE)
WANT_MAKE= bmake
.else
+18 -8
View File
@@ -640,8 +640,10 @@ build32: .PHONY
${_+_}cd ${.CURDIR}; \
${LIB32WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
.for _t in obj depend all
.if !defined(NO_RTLD)
${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
-DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
.endif
${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
DIRPRFX=usr.bin/ldd ${_t}
.endfor
@@ -658,8 +660,10 @@ distribute32 install32: .MAKE .PHONY
.if ${MK_KERBEROS} != "no"
${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
.endif
.if !defined(NO_RTLD)
${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
.endif
${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} \
${.TARGET:S/32$//}
.endif
@@ -1026,6 +1030,10 @@ BUILDKERNELS+= ${_kernel}
.if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
INSTALLKERNEL= ${_kernel}
.endif
.else
.if make(buildkernel)
.error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
.endif
.endif
.endfor
@@ -1363,11 +1371,9 @@ ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/c
${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/libllvmsupport
.endif
# dtrace tools are required for older bootstrap env and cross-build
.if ${MK_CDDL} != "no" && \
((${BOOTSTRAPPING} < 1000034 && \
!(${BOOTSTRAPPING} >= 901505 && ${BOOTSTRAPPING} < 999999)) \
|| (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
# Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
# resulting from missing bug fixes or ELF Toolchain updates.
.if ${MK_CDDL} != "no"
_dtrace_tools= cddl/lib/libctf lib/libelf \
lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
@@ -1460,9 +1466,13 @@ _gcc_tools= gnu/usr.bin/cc/cc_tools
_rescue= rescue/rescue
.endif
.if ${MK_TCSH} != "no"
_tcsh=bin/csh
.endif
build-tools: .MAKE
.for _tool in \
bin/csh \
${_tcsh} \
bin/sh \
${_rescue} \
${LOCAL_TOOL_DIRS} \
@@ -1580,7 +1590,7 @@ native-xtools: .PHONY
bin/cat \
bin/chmod \
bin/cp \
bin/csh \
${_tcsh} \
bin/echo \
bin/expr \
bin/hostname \
@@ -1728,7 +1738,7 @@ gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
_prebuild_libs+= lib/libc++
.endif
lib/libgeom__L: lib/libexpat__L
lib/libgeom__L: lib/libexpat__L lib/libsbuf__L
.if defined(WITH_ATF) || ${MK_TESTS} != "no"
.if !defined(WITH_ATF)
+2
View File
@@ -38,6 +38,8 @@
# xargs -n1 | sort | uniq -d;
# done
# 20171204: Move fdformat man page from volume 1 to volume 8.
OLD_FILES+=usr/share/man/man1/fdformat.1.gz
# 20170620: remove stale manpage
OLD_FILES+=usr/share/man/man2/cap_rights_get.2.gz
# 20170610: chown-f_test replaced by chown_test
+32 -92
View File
@@ -1,4 +1,4 @@
Updating Information for FreeBSD current users
Updating Information for FreeBSD stable/10 users
This file is maintained and copyrighted by M. Warner Losh <[email protected]>.
See end of file for further details. For commonly done items, please see the
@@ -6,7 +6,7 @@ COMMON ITEMS: section later in the file. These instructions assume that you
basically know what you are doing. If not, then please consult the FreeBSD
handbook:
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/updating-src.html
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
Items affecting the ports and packages system can be found in
/usr/ports/UPDATING. Please read that file before running portupgrade.
@@ -16,98 +16,22 @@ from older versions of FreeBSD, try WITHOUT_CLANG to bootstrap to the tip of
stable/10, and then rebuild without this option. The bootstrap process from
older version of current is a bit fragile.
20180927 p13 FreeBSD-EN-18:11.listen
FreeBSD-EN-18:12.mem
Fix DoS in listen syscall over IPv6 socket. [EN-18:11.listen]
Fix small kernel memory disclosures. [EN-18:12.mem]
20180912 p12 FreeBSD-SA-18:12.elf
Fix improper elf header parsing.
20180814 p11 FreeBSD-SA-18:08.tcp [revised]
FreeBSD-SA-18:11.hostapd
Revise manual pages. [SA-18:08.tcp]
Fixeunauthenticated EAPOL-Key decryption vulnerability.
[SA-18:11.hostapd]
20180806 p10 FreeBSD-SA-18:08.tcp
Fix resource exhaustion in TCP reassembly.
20180508 p9 FreeBSD-SA-18:06.debugreg
FreeBSD-EN-18:05.mem
FreeBSD-EN-18:06.tzdata
Fix mishandling of x86 debug exceptions. [SA-18:06.debugreg]
Fix multiple small kernel memory disclosures. [EN-18:05.mem]
Update timezone database information. [EN-18:06.tzdata]
20180404 p8 FreeBSD-SA-18:04.vt
FreeBSD-SA-18:05.ipsec
FreeBSD-EN-18:03.tzdata
FreeBSD-EN-18:04.mem
Fix vt console memory disclosure. [SA-18:04.vt]
Fix ipsec crash or denial of service. [SA-18:05.ipsec]
Update timezone database information. [EN-18:03.tzdata]
Fix multiple small kernel memory disclosures. [EN-18:04.mem]
20180307 p7 FreeBSD-SA-18:01.ipsec [revised]
Fix ipsec validation and use-after-free.
20180307 p6 FreeBSD-SA-18:01.ipsec
FreeBSD-SA-18:02.ntp
FreeBSD-EN-18:01.tzdata
FreeBSD-EN-18:02.file
Fix ipsec validation and use-after-free. [SA-18:01.ipsec]
Fix multiple vulnerabilities in ntp. [SA-18:02.ntp]
Update timezone database information. [EN-18:01.tzdata]
Update file(1) to new version with security update. [EN-18:02.file]
20171209 p5 FreeBSD-SA-17:12.openssl
Fix OpenSSL error state vulnerability.
20171129 p4 FreeBSD-SA-17:11.openssl
Fix OpenSSL out-of-bounds read vulnerability.
20171115 p3 FreeBSD-SA-17:08.ptrace
FreeBSD-SA-17:09.shm
FreeBSD-SA-17:10.kldstat
Fix ptrace(2) vulnerability. [SA-17:08.ptrace]
Fix POSIX shm namespace vulnerability. [SA-17:09.shm]
Fix kldstat(2) vulnerability. [SA-17:10.kldstat]
20171102: p2 FreeBSD-EN-17:09.tzdata
Update timezone database information. [EN-17:09]
20171017: p1 FreeBSD-SA-17:07.wpa
Fix WPA2 protocol vulnerability. [SA-17:07]
20180504:
The tz database (tzdb) has been updated to 2018e. This version more
correctly models time stamps in time zones with negative DST such as
Europe/Dublin (from 1971 on), Europe/Prague (1946/7), and
Africa/Windhoek (1994/2017). This does not affect the UT offsets, only
time zone abbreviations and the tm_isdst flag.
20171003:
10.4-RELEASE.
When building multiple kernels using KERNCONF, non-existent KERNCONF
files will produce an error and buildkernel will fail. Previously
missing KERNCONF files silently failed giving no indication as to
why, only to subsequently discover during installkernel that the
desired kernel was never built in the first place.
20170915:
The releng/10.4 branch has been created from stable/10@r323601
20170824:
Since the switch to GPT disk labels, fsck for UFS/FFS has been
@@ -144,6 +68,9 @@ older version of current is a bit fragile.
by mkdir under .zfs/snapshot/. That should be the only user visible
change.
20160304:
The releng/10.3 branch has been created from stable/10@r296371
20160124:
The NONE and HPN patches has been removed from OpenSSH. They are
still available in the security/openssh-portable port.
@@ -203,6 +130,9 @@ older version of current is a bit fragile.
Please consider using 'options KSTACK_PAGES=X' where X is greater
than or equal to ZFS_MIN_KSTACK_PAGES i.e. 4 in such configurations.
20150723:
The releng/10.2 branch has been created from stable/10@r285827
20150703:
The default Unbound configuration now enables remote control
using a local socket. Users who have already enabled the
@@ -270,6 +200,9 @@ older version of current is a bit fragile.
20141118:
10.1-RELEASE.
20141207:
The releng/10.1 branch has been created from stable/10@r272459.
20140904:
The ofwfb driver, used to provide a graphics console on PowerPC when
using vt(4), no longer allows mmap() of all of physical memory. This
@@ -384,6 +317,9 @@ older version of current is a bit fragile.
big-endian integer in accordance with RFC 4402.
__FreeBSD_version is bumped to 1000701.
20131207:
The releng/10.0 branch has been created from stable/10@r259064.
20131108:
The WITHOUT_ATF build knob has been removed and its functionality
has been subsumed into the more generic WITHOUT_TESTS. If you were
@@ -406,6 +342,10 @@ older version of current is a bit fragile.
or
# pkg install pkg; ldd /usr/local/sbin/pkg | grep bsdyml
20131010:
The stable/10 branch has been created in subversion from head
revision r256279.
20131010:
The rc.d/jail script has been updated to support jail(8)
configuration file. The "jail_<jname>_*" rc.conf(5) variables
-2
View File
@@ -58,8 +58,6 @@ SUBDIR+= tests
.include <bsd.arch.inc.mk>
SUBDIR:= ${SUBDIR:O}
SUBDIR_PARALLEL=
.include <bsd.subdir.mk>
+1 -1
View File
@@ -51,11 +51,11 @@ __FBSDID("$FreeBSD$");
#ifndef NO_UDOM_SUPPORT
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#endif
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <locale.h>
#include <stddef.h>
+6
View File
@@ -1,6 +1,12 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
# $FreeBSD$
.include <bsd.own.mk>
PACKAGE=runtime
PROG= chflags
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
.include <bsd.prog.mk>
+5
View File
@@ -0,0 +1,5 @@
# $FreeBSD$
ATF_TESTS_SH+= chflags_test
.include <bsd.test.mk>
+63
View File
@@ -0,0 +1,63 @@
#
# Copyright 2017 Shivansh Rai
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
usage_output='usage: chflags'
atf_test_case invalid_usage
invalid_usage_head()
{
atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message"
}
invalid_usage_body()
{
atf_check -s not-exit:0 -e match:"$usage_output" chflags -f
atf_check -s not-exit:0 -e match:"$usage_output" chflags -H
atf_check -s not-exit:0 -e match:"$usage_output" chflags -h
atf_check -s not-exit:0 -e match:"$usage_output" chflags -L
atf_check -s not-exit:0 -e match:"$usage_output" chflags -P
atf_check -s not-exit:0 -e match:"$usage_output" chflags -R
atf_check -s not-exit:0 -e match:"$usage_output" chflags -v
}
atf_test_case no_arguments
no_arguments_head()
{
atf_set "descr" "Verify that chflags(1) fails and generates a valid usage message when no arguments are supplied"
}
no_arguments_body()
{
atf_check -s not-exit:0 -e match:"$usage_output" chflags
}
atf_init_test_cases()
{
atf_add_test_case invalid_usage
atf_add_test_case no_arguments
}
+6
View File
@@ -1,6 +1,12 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
.include <bsd.own.mk>
PACKAGE=runtime
PROG= mkdir
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
.include <bsd.prog.mk>
+5
View File
@@ -0,0 +1,5 @@
# $FreeBSD$
ATF_TESTS_SH+= mkdir_test
.include <bsd.test.mk>
+61
View File
@@ -0,0 +1,61 @@
#
# Copyright 2017 Shivansh Rai
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
usage_output='usage: mkdir'
atf_test_case invalid_usage
invalid_usage_head()
{
atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message"
}
invalid_usage_body()
{
atf_check -s not-exit:0 -e inline:"mkdir: option requires an argument -- m
usage: mkdir [-pv] [-m mode] directory_name ...
" mkdir -m
atf_check -s not-exit:0 -e match:"$usage_output" mkdir -p
atf_check -s not-exit:0 -e match:"$usage_output" mkdir -v
}
atf_test_case no_arguments
no_arguments_head()
{
atf_set "descr" "Verify that mkdir(1) fails and generates a valid usage message when no arguments are supplied"
}
no_arguments_body()
{
atf_check -s not-exit:0 -e match:"$usage_output" mkdir
}
atf_init_test_cases()
{
atf_add_test_case invalid_usage
atf_add_test_case no_arguments
}
+1
View File
@@ -53,6 +53,7 @@ char *emulname(KINFO *, VARENT *);
VARENT *find_varentry(VAR *);
const char *fmt_argv(char **, char *, char *, size_t);
double getpcpu(const KINFO *);
char *jailname(KINFO *, VARENT *);
char *kvar(KINFO *, VARENT *);
char *label(KINFO *, VARENT *);
char *loginclass(KINFO *, VARENT *);
+1
View File
@@ -96,6 +96,7 @@ static VAR var[] = {
{"ignored", "", "sigignore", 0, NULL, 0, CHAR, NULL, 0},
{"inblk", "INBLK", NULL, USER, rvar, ROFF(ru_inblock), LONG, "ld", 0},
{"inblock", "", "inblk", 0, NULL, 0, CHAR, NULL, 0},
{"jail", "JAIL", NULL, LJUST, jailname, 0, CHAR, NULL, 0},
{"jid", "JID", NULL, 0, kvar, KOFF(ki_jid), INT, "d", 0},
{"jobc", "JOBC", NULL, 0, kvar, KOFF(ki_jobc), SHORT, "d", 0},
{"ktrace", "KTRACE", NULL, 0, kvar, KOFF(ki_traceflag), INT, "x", 0},
+14
View File
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <grp.h>
#include <jail.h>
#include <langinfo.h>
#include <locale.h>
#include <math.h>
@@ -840,3 +841,16 @@ loginclass(KINFO *k, VARENT *ve __unused)
}
return (strdup(k->ki_p->ki_loginclass));
}
char *
jailname(KINFO *k, VARENT *ve __unused)
{
char *name;
if (k->ki_p->ki_jid == 0)
return (strdup("-"));
name = jail_getname(k->ki_p->ki_jid);
if (name == NULL)
return (strdup("-"));
return (name);
}
+3 -1
View File
@@ -29,7 +29,7 @@
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
.Dd August 12, 2016
.Dd March 13, 2018
.Dt PS 1
.Os
.Sh NAME
@@ -554,6 +554,8 @@ group name (from egid) (alias
.It Cm inblk
total blocks read (alias
.Cm inblock )
.It Cm jail
jail name
.It Cm jid
jail ID
.It Cm jobc
+6
View File
@@ -1,6 +1,9 @@
# @(#)Makefile 8.1 (Berkeley) 7/19/93
# $FreeBSD$
.include <bsd.own.mk>
PACKAGE=rcmds
PROG= rcp
SRCS= rcp.c util.c
CFLAGS+=-DBINDIR=${BINDIR}
@@ -9,4 +12,7 @@ BINOWN= root
BINMODE=4555
PRECIOUSPROG=
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
.include <bsd.prog.mk>
+5
View File
@@ -0,0 +1,5 @@
# $FreeBSD$
ATF_TESTS_SH+= rcp_test
.include <bsd.test.mk>
+60
View File
@@ -0,0 +1,60 @@
#
# Copyright 2017 Shivansh Rai
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
usage_output='usage: rcp'
atf_test_case invalid_usage
invalid_usage_head()
{
atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message"
}
invalid_usage_body()
{
atf_check -s not-exit:0 -e match:"$usage_output" rcp -4
atf_check -s not-exit:0 -e match:"$usage_output" rcp -6
atf_check -s not-exit:0 -e match:"$usage_output" rcp -p
atf_check -s not-exit:0 -e match:"$usage_output" rcp -r
}
atf_test_case no_arguments
no_arguments_head()
{
atf_set "descr" "Verify that rcp(1) fails and generates a valid usage message when no arguments are supplied"
}
no_arguments_body()
{
atf_check -s not-exit:0 -e match:"$usage_output" rcp
}
atf_init_test_cases()
{
atf_add_test_case invalid_usage
atf_add_test_case no_arguments
}
+5
View File
@@ -1,6 +1,11 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
.include <bsd.own.mk>
PACKAGE=runtime
PROG= rmdir
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
.include <bsd.prog.mk>
+5
View File
@@ -0,0 +1,5 @@
# $FreeBSD$
ATF_TESTS_SH+= rmdir_test
.include <bsd.test.mk>
+58
View File
@@ -0,0 +1,58 @@
#
# Copyright 2017 Shivansh Rai
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
usage_output='usage: rmdir'
atf_test_case invalid_usage
invalid_usage_head()
{
atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message"
}
invalid_usage_body()
{
atf_check -s not-exit:0 -e match:"$usage_output" rmdir -p
atf_check -s not-exit:0 -e match:"$usage_output" rmdir -v
}
atf_test_case no_arguments
no_arguments_head()
{
atf_set "descr" "Verify that rmdir(1) fails and generates a valid usage message when no arguments are supplied"
}
no_arguments_body()
{
atf_check -s not-exit:0 -e match:"$usage_output" rmdir
}
atf_init_test_cases()
{
atf_add_test_case invalid_usage
atf_add_test_case no_arguments
}
+5 -7
View File
@@ -74,7 +74,7 @@ zmount(const char *spec, const char *dir, int mflag, char *fstype,
char *dataptr, int datalen, char *optptr, int optlen)
{
struct iovec *iov;
char *optstr, *os, *p;
char *optstr, *os, *p, *tofree;
int iovlen, rv;
assert(spec != NULL);
@@ -87,7 +87,7 @@ zmount(const char *spec, const char *dir, int mflag, char *fstype,
assert(optptr != NULL);
assert(optlen > 0);
optstr = strdup(optptr);
tofree = optstr = strdup(optptr);
assert(optstr != NULL);
iov = NULL;
@@ -98,11 +98,9 @@ zmount(const char *spec, const char *dir, int mflag, char *fstype,
build_iovec(&iov, &iovlen, "fspath", __DECONST(char *, dir),
(size_t)-1);
build_iovec(&iov, &iovlen, "from", __DECONST(char *, spec), (size_t)-1);
for (p = optstr; p != NULL; strsep(&p, ",/ ")) {
if (*p != '\0')
build_iovec(&iov, &iovlen, p, NULL, (size_t)-1);
}
while ((p = strsep(&optstr, ",/")) != NULL)
build_iovec(&iov, &iovlen, p, NULL, (size_t)-1);
rv = nmount(iov, iovlen, 0);
free(optstr);
free(tofree);
return (rv);
}
@@ -0,0 +1,46 @@
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
* Copyright 2017 Panzura. All rights reserved.
*/
/*
* ASSERTION:
* Positive test for normalization() of stddev()
*
* SECTION: Aggregations/Normalization
*
*/
#pragma D option quiet
#pragma D option aggrate=1ms
#pragma D option switchrate=50ms
BEGIN
{
i = 0;
}
tick-100ms
/i < 11/
{
@ = stddev(i * 100);
i++;
}
tick-100ms
/i == 11/
{
printf("normalized data:\n");
normalize(@, 10);
exit(0);
}
@@ -0,0 +1,3 @@
normalized data:
31
@@ -35,13 +35,13 @@ main(int argc, char **argv)
sigset_t ss;
(void) sigemptyset(&ss);
(void) sigaddset(&ss, SIGINT);
(void) sigaddset(&ss, SIGUSR1);
(void) sigprocmask(SIG_BLOCK, &ss, NULL);
do {
(void) getpid();
(void) sigpending(&ss);
} while (!sigismember(&ss, SIGINT));
} while (!sigismember(&ss, SIGUSR1));
return (0);
}
@@ -47,7 +47,7 @@ syscall::getpid:entry
/pid == $1/
{
trace("raised");
raise(SIGINT);
raise(SIGUSR1);
/*
* Wait no more than half a second for the process to die.
*/
@@ -55,6 +55,7 @@ syscall::getpid:entry
}
syscall::exit:entry
/pid == $1/
{
exit(0);
}
@@ -45,7 +45,7 @@ main(int argc, char **argv)
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
(void) sigaction(SIGINT, &sa, NULL);
(void) sigaction(SIGUSR1, &sa, NULL);
for (;;) {
(void) getpid();
@@ -47,7 +47,7 @@ syscall::getpid:return
/pid == $1/
{
trace("raised");
raise(SIGINT);
raise(SIGUSR1);
/*
* Wait no more than half a second for the process to die.
*/
@@ -55,6 +55,7 @@ syscall::getpid:return
}
syscall::exit:entry
/pid == $1/
{
exit(0);
}
@@ -45,7 +45,7 @@ main(int argc, char **argv)
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
(void) sigaction(SIGINT, &sa, NULL);
(void) sigaction(SIGUSR1, &sa, NULL);
for (;;) {
(void) getpid();
@@ -47,7 +47,7 @@ syscall::getpid:entry
/pid == $1/
{
trace("raised");
raise(SIGINT);
raise(SIGUSR1);
/*
* Wait no more than half a second for the process to die.
*/
@@ -55,6 +55,7 @@ syscall::getpid:entry
}
syscall::exit:entry
/pid == $1/
{
exit(0);
}
+15 -4
View File
@@ -15,11 +15,12 @@
.\" Copyright 2012, Richard Lowe.
.\" Copyright (c) 2012, Marcelo Araujo <[email protected]>.
.\" Copyright (c) 2012, 2014 by Delphix. All rights reserved.
.\" Copyright 2016 Nexenta Systems, Inc.
.\" All Rights Reserved.
.\"
.\" $FreeBSD$
.\"
.Dd July 26, 2014
.Dd October 1, 2017
.Dt ZDB 8
.Os
.Sh NAME
@@ -27,12 +28,13 @@
.Nd Display zpool debugging and consistency information
.Sh SYNOPSIS
.Nm
.Op Fl CumdibcsDvhLMXFPA
.Op Fl CmdibcsDvhLMXFPA
.Op Fl e Op Fl p Ar path...
.Op Fl t Ar txg
.Op Fl U Ar cache
.Op Fl I Ar inflight I/Os
.Op Fl x Ar dumpdir
.Op Fl o Ar var=value
.Ar poolname
.Op Ar object ...
.Nm
@@ -63,7 +65,7 @@
.Ar poolname
.Nm
.Fl l
.Op Fl uA
.Op Fl Aqu
.Ar device
.Nm
.Fl C
@@ -155,10 +157,15 @@ dataset.
If specified multiple times, display counts of each intent log transaction
type.
.It Fl l Ar device
Display the vdev labels from the specified device.
Read the vdev labels from the specified device.
Return 0 if a valid label was found, 1 if an error occurred, and 2 if no valid
labels were found.
If the
.Fl u
option is also specified, also display the uberblocks on this device.
If the
.Fl q
option is also specified, also display the uberblocks on this device.
.It Fl L
Disable leak tracing and the loading of space maps.
By default,
@@ -252,6 +259,10 @@ Limit the number of outstanding checksum I/Os to the specified value.
The default value is 200. This option affects the performance of the
.Fl c
option.
.It Fl o Ar var=value
Set the given global libzpool variable to the provided value. The value must be
an unsigned 32-bit integer. Currently only little-endian systems are supported
to avoid accidentally setting the high 32 bits of 64-bit variables.
.It Fl P
Print numbers in an unscaled form more amenable to parsing, eg. 1000000 rather
than 1M.
+157 -76
View File
@@ -23,6 +23,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016 by Delphix. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
* Copyright 2016 Nexenta Systems, Inc.
*/
#include <stdio.h>
@@ -60,6 +61,7 @@
#include <sys/ddt.h>
#include <sys/zfeature.h>
#include <zfs_comutil.h>
#include <libcmdutils.h>
#undef verify
#include <libzfs.h>
@@ -117,8 +119,9 @@ static void
usage(void)
{
(void) fprintf(stderr,
"Usage: %s [-CumMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] "
"[-U config] [-I inflight I/Os] [-x dumpdir] poolname [object...]\n"
"Usage: %s [-CmMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] "
"[-U config] [-I inflight I/Os] [-x dumpdir] [-o var=value] "
"poolname [object...]\n"
" %s [-divPA] [-e -p path...] [-U config] dataset "
"[object...]\n"
" %s -mM [-LXFPA] [-t txg] [-e [-p path...]] [-U config] "
@@ -126,7 +129,7 @@ usage(void)
" %s -R [-A] [-e [-p path...]] poolname "
"vdev:offset:size[:flags]\n"
" %s -S [-PA] [-e [-p path...]] [-U config] poolname\n"
" %s -l [-uA] device\n"
" %s -l [-Aqu] device\n"
" %s -C [-A] [-U config]\n\n",
cmdname, cmdname, cmdname, cmdname, cmdname, cmdname, cmdname);
@@ -137,7 +140,6 @@ usage(void)
(void) fprintf(stderr, " If object numbers are specified, only "
"those objects are dumped\n\n");
(void) fprintf(stderr, " Options to control amount of output:\n");
(void) fprintf(stderr, " -u uberblock\n");
(void) fprintf(stderr, " -d dataset(s)\n");
(void) fprintf(stderr, " -i intent logs\n");
(void) fprintf(stderr, " -C config (or cachefile if alone)\n");
@@ -151,7 +153,7 @@ usage(void)
(void) fprintf(stderr, " -D dedup statistics\n");
(void) fprintf(stderr, " -S simulate dedup to measure effect\n");
(void) fprintf(stderr, " -v verbose (applies to all others)\n");
(void) fprintf(stderr, " -l dump label contents\n");
(void) fprintf(stderr, " -l read label contents\n");
(void) fprintf(stderr, " -L disable leak tracking (do not "
"load spacemaps)\n");
(void) fprintf(stderr, " -R read and display block from a "
@@ -180,6 +182,10 @@ usage(void)
"checksumming I/Os [default is 200]\n");
(void) fprintf(stderr, " -G dump zfs_dbgmsg buffer before "
"exiting\n");
(void) fprintf(stderr, " -o <variable>=<value> set global "
"variable to an unsigned 32-bit integer value\n");
(void) fprintf(stderr, " -q don't print label contents\n");
(void) fprintf(stderr, " -u uberblock\n");
(void) fprintf(stderr, "Specify an option more than once (e.g. -bb) "
"to make only that option verbose\n");
(void) fprintf(stderr, "Default is to dump everything non-verbosely\n");
@@ -257,12 +263,12 @@ dump_history_offsets(objset_t *os, uint64_t object, void *data, size_t size)
}
static void
zdb_nicenum(uint64_t num, char *buf)
zdb_nicenum(uint64_t num, char *buf, size_t buflen)
{
if (dump_opt['P'])
(void) sprintf(buf, "%llu", (longlong_t)num);
(void) snprintf(buf, buflen, "%llu", (longlong_t)num);
else
nicenum(num, buf);
nicenum(num, buf, sizeof (buf));
}
const char histo_stars[] = "****************************************";
@@ -439,12 +445,17 @@ dump_bpobj(objset_t *os, uint64_t object, void *data, size_t size)
bpobj_phys_t *bpop = data;
char bytes[32], comp[32], uncomp[32];
/* make sure the output won't get truncated */
CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (comp) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (uncomp) >= NN_NUMBUF_SZ);
if (bpop == NULL)
return;
zdb_nicenum(bpop->bpo_bytes, bytes);
zdb_nicenum(bpop->bpo_comp, comp);
zdb_nicenum(bpop->bpo_uncomp, uncomp);
zdb_nicenum(bpop->bpo_bytes, bytes, sizeof (bytes));
zdb_nicenum(bpop->bpo_comp, comp, sizeof (comp));
zdb_nicenum(bpop->bpo_uncomp, uncomp, sizeof (uncomp));
(void) printf("\t\tnum_blkptrs = %llu\n",
(u_longlong_t)bpop->bpo_num_blkptrs);
@@ -737,7 +748,10 @@ dump_metaslab_stats(metaslab_t *msp)
avl_tree_t *t = &msp->ms_size_tree;
int free_pct = range_tree_space(rt) * 100 / msp->ms_size;
zdb_nicenum(metaslab_block_maxsize(msp), maxbuf);
/* max sure nicenum has enough space */
CTASSERT(sizeof (maxbuf) >= NN_NUMBUF_SZ);
zdb_nicenum(metaslab_block_maxsize(msp), maxbuf, sizeof (maxbuf));
(void) printf("\t %25s %10lu %7s %6s %4s %4d%%\n",
"segments", avl_numnodes(t), "maxsize", maxbuf,
@@ -754,7 +768,8 @@ dump_metaslab(metaslab_t *msp)
space_map_t *sm = msp->ms_sm;
char freebuf[32];
zdb_nicenum(msp->ms_size - space_map_allocated(sm), freebuf);
zdb_nicenum(msp->ms_size - space_map_allocated(sm), freebuf,
sizeof (freebuf));
(void) printf(
"\tmetaslab %6llu offset %12llx spacemap %6llu free %5s\n",
@@ -1337,6 +1352,9 @@ dump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size)
time_t crtime;
char nice[32];
/* make sure nicenum has enough space */
CTASSERT(sizeof (nice) >= NN_NUMBUF_SZ);
if (dd == NULL)
return;
@@ -1352,15 +1370,15 @@ dump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size)
(u_longlong_t)dd->dd_origin_obj);
(void) printf("\t\tchild_dir_zapobj = %llu\n",
(u_longlong_t)dd->dd_child_dir_zapobj);
zdb_nicenum(dd->dd_used_bytes, nice);
zdb_nicenum(dd->dd_used_bytes, nice, sizeof (nice));
(void) printf("\t\tused_bytes = %s\n", nice);
zdb_nicenum(dd->dd_compressed_bytes, nice);
zdb_nicenum(dd->dd_compressed_bytes, nice, sizeof (nice));
(void) printf("\t\tcompressed_bytes = %s\n", nice);
zdb_nicenum(dd->dd_uncompressed_bytes, nice);
zdb_nicenum(dd->dd_uncompressed_bytes, nice, sizeof (nice));
(void) printf("\t\tuncompressed_bytes = %s\n", nice);
zdb_nicenum(dd->dd_quota, nice);
zdb_nicenum(dd->dd_quota, nice, sizeof (nice));
(void) printf("\t\tquota = %s\n", nice);
zdb_nicenum(dd->dd_reserved, nice);
zdb_nicenum(dd->dd_reserved, nice, sizeof (nice));
(void) printf("\t\treserved = %s\n", nice);
(void) printf("\t\tprops_zapobj = %llu\n",
(u_longlong_t)dd->dd_props_zapobj);
@@ -1370,7 +1388,8 @@ dump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size)
(u_longlong_t)dd->dd_flags);
#define DO(which) \
zdb_nicenum(dd->dd_used_breakdown[DD_USED_ ## which], nice); \
zdb_nicenum(dd->dd_used_breakdown[DD_USED_ ## which], nice, \
sizeof (nice)); \
(void) printf("\t\tused_breakdown[" #which "] = %s\n", nice)
DO(HEAD);
DO(SNAP);
@@ -1389,15 +1408,22 @@ dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size)
char used[32], compressed[32], uncompressed[32], unique[32];
char blkbuf[BP_SPRINTF_LEN];
/* make sure nicenum has enough space */
CTASSERT(sizeof (used) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (compressed) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (uncompressed) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (unique) >= NN_NUMBUF_SZ);
if (ds == NULL)
return;
ASSERT(size == sizeof (*ds));
crtime = ds->ds_creation_time;
zdb_nicenum(ds->ds_referenced_bytes, used);
zdb_nicenum(ds->ds_compressed_bytes, compressed);
zdb_nicenum(ds->ds_uncompressed_bytes, uncompressed);
zdb_nicenum(ds->ds_unique_bytes, unique);
zdb_nicenum(ds->ds_referenced_bytes, used, sizeof (used));
zdb_nicenum(ds->ds_compressed_bytes, compressed, sizeof (compressed));
zdb_nicenum(ds->ds_uncompressed_bytes, uncompressed,
sizeof (uncompressed));
zdb_nicenum(ds->ds_unique_bytes, unique, sizeof (unique));
snprintf_blkptr(blkbuf, sizeof (blkbuf), &ds->ds_bp);
(void) printf("\t\tdir_obj = %llu\n",
@@ -1456,12 +1482,15 @@ dump_bptree(objset_t *os, uint64_t obj, char *name)
bptree_phys_t *bt;
dmu_buf_t *db;
/* make sure nicenum has enough space */
CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ);
if (dump_opt['d'] < 3)
return;
VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
bt = db->db_data;
zdb_nicenum(bt->bt_bytes, bytes);
zdb_nicenum(bt->bt_bytes, bytes, sizeof (bytes));
(void) printf("\n %s: %llu datasets, %s\n",
name, (unsigned long long)(bt->bt_end - bt->bt_begin), bytes);
dmu_buf_rele(db, FTAG);
@@ -1493,13 +1522,18 @@ dump_full_bpobj(bpobj_t *bpo, char *name, int indent)
char comp[32];
char uncomp[32];
/* make sure nicenum has enough space */
CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (comp) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (uncomp) >= NN_NUMBUF_SZ);
if (dump_opt['d'] < 3)
return;
zdb_nicenum(bpo->bpo_phys->bpo_bytes, bytes);
zdb_nicenum(bpo->bpo_phys->bpo_bytes, bytes, sizeof (bytes));
if (bpo->bpo_havesubobj && bpo->bpo_phys->bpo_subobjs != 0) {
zdb_nicenum(bpo->bpo_phys->bpo_comp, comp);
zdb_nicenum(bpo->bpo_phys->bpo_uncomp, uncomp);
zdb_nicenum(bpo->bpo_phys->bpo_comp, comp, sizeof (comp));
zdb_nicenum(bpo->bpo_phys->bpo_uncomp, uncomp, sizeof (uncomp));
(void) printf(" %*s: object %llu, %llu local blkptrs, "
"%llu subobjs in object %llu, %s (%s/%s comp)\n",
indent * 8, name,
@@ -1553,6 +1587,11 @@ dump_deadlist(dsl_deadlist_t *dl)
char comp[32];
char uncomp[32];
/* make sure nicenum has enough space */
CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (comp) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (uncomp) >= NN_NUMBUF_SZ);
if (dump_opt['d'] < 3)
return;
@@ -1561,9 +1600,9 @@ dump_deadlist(dsl_deadlist_t *dl)
return;
}
zdb_nicenum(dl->dl_phys->dl_used, bytes);
zdb_nicenum(dl->dl_phys->dl_comp, comp);
zdb_nicenum(dl->dl_phys->dl_uncomp, uncomp);
zdb_nicenum(dl->dl_phys->dl_used, bytes, sizeof (bytes));
zdb_nicenum(dl->dl_phys->dl_comp, comp, sizeof (comp));
zdb_nicenum(dl->dl_phys->dl_uncomp, uncomp, sizeof (uncomp));
(void) printf("\n Deadlist: %s (%s/%s comp)\n",
bytes, comp, uncomp);
@@ -1835,6 +1874,13 @@ dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header)
char aux[50];
int error;
/* make sure nicenum has enough space */
CTASSERT(sizeof (iblk) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (dblk) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (lsize) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (asize) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (bonus_size) >= NN_NUMBUF_SZ);
if (*print_header) {
(void) printf("\n%10s %3s %5s %5s %5s %5s %6s %s\n",
"Object", "lvl", "iblk", "dblk", "dsize", "lsize",
@@ -1855,11 +1901,11 @@ dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header)
}
dmu_object_info_from_dnode(dn, &doi);
zdb_nicenum(doi.doi_metadata_block_size, iblk);
zdb_nicenum(doi.doi_data_block_size, dblk);
zdb_nicenum(doi.doi_max_offset, lsize);
zdb_nicenum(doi.doi_physical_blocks_512 << 9, asize);
zdb_nicenum(doi.doi_bonus_size, bonus_size);
zdb_nicenum(doi.doi_metadata_block_size, iblk, sizeof (iblk));
zdb_nicenum(doi.doi_data_block_size, dblk, sizeof (dblk));
zdb_nicenum(doi.doi_max_offset, lsize, sizeof (lsize));
zdb_nicenum(doi.doi_physical_blocks_512 << 9, asize, sizeof (asize));
zdb_nicenum(doi.doi_bonus_size, bonus_size, sizeof (bonus_size));
(void) sprintf(fill, "%6.2f", 100.0 * doi.doi_fill_count *
doi.doi_data_block_size / (object == 0 ? DNODES_PER_BLOCK : 1) /
doi.doi_max_offset);
@@ -1922,6 +1968,8 @@ dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header)
for (;;) {
char segsize[32];
/* make sure nicenum has enough space */
CTASSERT(sizeof (segsize) >= NN_NUMBUF_SZ);
error = dnode_next_offset(dn,
0, &start, minlvl, blkfill, 0);
if (error)
@@ -1929,7 +1977,7 @@ dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header)
end = start;
error = dnode_next_offset(dn,
DNODE_FIND_HOLE, &end, minlvl, blkfill, 0);
zdb_nicenum(end - start, segsize);
zdb_nicenum(end - start, segsize, sizeof (segsize));
(void) printf("\t\tsegment [%016llx, %016llx)"
" size %5s\n", (u_longlong_t)start,
(u_longlong_t)end, segsize);
@@ -1960,6 +2008,9 @@ dump_dir(objset_t *os)
int print_header = 1;
int i, error;
/* make sure nicenum has enough space */
CTASSERT(sizeof (numbuf) >= NN_NUMBUF_SZ);
dsl_pool_config_enter(dmu_objset_pool(os), FTAG);
dmu_objset_fast_stat(os, &dds);
dsl_pool_config_exit(dmu_objset_pool(os), FTAG);
@@ -1978,7 +2029,7 @@ dump_dir(objset_t *os)
ASSERT3U(usedobjs, ==, BP_GET_FILL(os->os_rootbp));
zdb_nicenum(refdbytes, numbuf);
zdb_nicenum(refdbytes, numbuf, sizeof (numbuf));
if (verbosity >= 4) {
(void) snprintf(blkbuf, sizeof (blkbuf), ", rootbp ");
@@ -2154,45 +2205,48 @@ dump_label_uberblocks(vdev_label_t *lbl, uint64_t ashift)
}
}
static void
static int
dump_label(const char *dev)
{
int fd;
vdev_label_t label;
char *path, *buf = label.vl_vdev_phys.vp_nvlist;
char path[MAXPATHLEN];
char *buf = label.vl_vdev_phys.vp_nvlist;
size_t buflen = sizeof (label.vl_vdev_phys.vp_nvlist);
struct stat64 statbuf;
uint64_t psize, ashift;
int len = strlen(dev) + 1;
boolean_t label_found = B_FALSE;
if (strncmp(dev, ZFS_DISK_ROOTD, strlen(ZFS_DISK_ROOTD)) == 0) {
len++;
path = malloc(len);
(void) snprintf(path, len, "%s%s", ZFS_RDISK_ROOTD,
dev + strlen(ZFS_DISK_ROOTD));
} else {
path = strdup(dev);
(void) strlcpy(path, dev, sizeof (path));
if (dev[0] == '/') {
if (strncmp(dev, ZFS_DISK_ROOTD,
strlen(ZFS_DISK_ROOTD)) == 0) {
(void) snprintf(path, sizeof (path), "%s%s",
ZFS_RDISK_ROOTD, dev + strlen(ZFS_DISK_ROOTD));
}
} else if (stat64(path, &statbuf) != 0) {
char *s;
(void) snprintf(path, sizeof (path), "%s%s", ZFS_RDISK_ROOTD,
dev);
if ((s = strrchr(dev, 's')) == NULL || !isdigit(*(s + 1)))
(void) strlcat(path, "s0", sizeof (path));
}
if ((fd = open64(path, O_RDONLY)) < 0) {
(void) printf("cannot open '%s': %s\n", path, strerror(errno));
free(path);
exit(1);
}
if (fstat64(fd, &statbuf) != 0) {
if (stat64(path, &statbuf) != 0) {
(void) printf("failed to stat '%s': %s\n", path,
strerror(errno));
free(path);
(void) close(fd);
exit(1);
}
if (S_ISBLK(statbuf.st_mode)) {
(void) printf("cannot use '%s': character device required\n",
path);
free(path);
(void) close(fd);
exit(1);
}
if ((fd = open64(path, O_RDONLY)) < 0) {
(void) printf("cannot open '%s': %s\n", path, strerror(errno));
exit(1);
}
@@ -2202,36 +2256,43 @@ dump_label(const char *dev)
for (int l = 0; l < VDEV_LABELS; l++) {
nvlist_t *config = NULL;
(void) printf("--------------------------------------------\n");
(void) printf("LABEL %d\n", l);
(void) printf("--------------------------------------------\n");
if (!dump_opt['q']) {
(void) printf("------------------------------------\n");
(void) printf("LABEL %d\n", l);
(void) printf("------------------------------------\n");
}
if (pread64(fd, &label, sizeof (label),
vdev_label_offset(psize, l, 0)) != sizeof (label)) {
(void) printf("failed to read label %d\n", l);
if (!dump_opt['q'])
(void) printf("failed to read label %d\n", l);
continue;
}
if (nvlist_unpack(buf, buflen, &config, 0) != 0) {
(void) printf("failed to unpack label %d\n", l);
if (!dump_opt['q'])
(void) printf("failed to unpack label %d\n", l);
ashift = SPA_MINBLOCKSHIFT;
} else {
nvlist_t *vdev_tree = NULL;
dump_nvlist(config, 4);
if (!dump_opt['q'])
dump_nvlist(config, 4);
if ((nvlist_lookup_nvlist(config,
ZPOOL_CONFIG_VDEV_TREE, &vdev_tree) != 0) ||
(nvlist_lookup_uint64(vdev_tree,
ZPOOL_CONFIG_ASHIFT, &ashift) != 0))
ashift = SPA_MINBLOCKSHIFT;
nvlist_free(config);
label_found = B_TRUE;
}
if (dump_opt['u'])
dump_label_uberblocks(&label, ashift);
}
free(path);
(void) close(fd);
return (label_found ? 0 : 2);
}
static uint64_t dataset_feature_count[SPA_FEATURES];
@@ -2511,6 +2572,9 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
int sec_remaining =
(zcb->zcb_totalasize - bytes) / 1024 / kb_per_sec;
/* make sure nicenum has enough space */
CTASSERT(sizeof (buf) >= NN_NUMBUF_SZ);
zfs_nicenum(bytes, buf, sizeof (buf));
(void) fprintf(stderr,
"\r%5s completed (%4dMB/s) "
@@ -2843,6 +2907,14 @@ dump_block_stats(spa_t *spa)
char avg[32], gang[32];
char *typename;
/* make sure nicenum has enough space */
CTASSERT(sizeof (csize) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (lsize) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (psize) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (asize) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (avg) >= NN_NUMBUF_SZ);
CTASSERT(sizeof (gang) >= NN_NUMBUF_SZ);
if (t < DMU_OT_NUMTYPES)
typename = dmu_ot[t].ot_name;
else
@@ -2876,12 +2948,17 @@ dump_block_stats(spa_t *spa)
zcb.zcb_type[ZB_TOTAL][t].zb_asize)
continue;
zdb_nicenum(zb->zb_count, csize);
zdb_nicenum(zb->zb_lsize, lsize);
zdb_nicenum(zb->zb_psize, psize);
zdb_nicenum(zb->zb_asize, asize);
zdb_nicenum(zb->zb_asize / zb->zb_count, avg);
zdb_nicenum(zb->zb_gangs, gang);
zdb_nicenum(zb->zb_count, csize,
sizeof (csize));
zdb_nicenum(zb->zb_lsize, lsize,
sizeof (lsize));
zdb_nicenum(zb->zb_psize, psize,
sizeof (psize));
zdb_nicenum(zb->zb_asize, asize,
sizeof (asize));
zdb_nicenum(zb->zb_asize / zb->zb_count, avg,
sizeof (avg));
zdb_nicenum(zb->zb_gangs, gang, sizeof (gang));
(void) printf("%6s\t%5s\t%5s\t%5s\t%5s"
"\t%5.2f\t%6.2f\t",
@@ -3587,7 +3664,7 @@ main(int argc, char **argv)
spa_config_path = spa_config_path_env;
while ((c = getopt(argc, argv,
"bcdhilmMI:suCDRSAFLXx:evp:t:U:PG")) != -1) {
"bcdhilmMI:suCDRSAFLXx:evp:t:U:PGo:q")) != -1) {
switch (c) {
case 'b':
case 'c':
@@ -3613,6 +3690,7 @@ main(int argc, char **argv)
case 'X':
case 'e':
case 'P':
case 'q':
dump_opt[c]++;
break;
case 'I':
@@ -3656,6 +3734,11 @@ main(int argc, char **argv)
case 'x':
vn_dumpdir = optarg;
break;
case 'o':
error = set_global_var(optarg);
if (error != 0)
usage();
break;
default:
usage();
break;
@@ -3711,10 +3794,8 @@ main(int argc, char **argv)
usage();
}
if (dump_opt['l']) {
dump_label(argv[0]);
return (0);
}
if (dump_opt['l'])
return (dump_label(argv[0]));
if (dump_opt['X'] || dump_opt['F'])
rewind = ZPOOL_DO_REWIND |
@@ -57,6 +57,7 @@
.Ar ...
.Op Fl m Ar mountpoint
.Op Fl R Ar root
.Op Fl t Ar tempname
.Ar pool vdev ...
.Nm
.Cm destroy
@@ -108,6 +109,7 @@
.Op Fl m
.Op Fl N
.Op Fl R Ar root
.Op Fl t
.Op Fl F Op Fl n
.Ar pool | id
.Op Ar newpool
@@ -868,6 +870,7 @@ do not actually discard any transactions.
.Ar ...
.Op Fl m Ar mountpoint
.Op Fl R Ar root
.Op Fl t Ar tempname
.Ar pool vdev ...
.Xc
.Pp
@@ -969,6 +972,18 @@ or
.Qq Cm none .
For more information on dataset mount points, see
.Xr zfs 8 .
.It Fl t Ar tempname
Sets the in-core pool name to
.Pa tempname
while the on-disk name will be the name specified as the pool name
.Pa pool .
This will set the default
.Sy cachefile
property to
.Sy none .
This is intended to handle name space collisions when creating pools
for other systems, such as virtual machines or physical machines
whose pools live on network block devices.
.El
.It Xo
.Nm
@@ -1223,6 +1238,7 @@ Searches for and imports all pools found.
.Op Fl m
.Op Fl N
.Op Fl R Ar root
.Op Fl t
.Op Fl F Op Fl n
.Ar pool | id
.Op Ar newpool
@@ -1282,6 +1298,20 @@ Import the pool without mounting any file systems.
.It Fl R Ar root
Equivalent to
.Qq Fl o Cm cachefile=none,altroot= Ns Pa root
.It Fl t
Used with
.Ar newpool .
Specifies that
.Ar newpool
is temporary.
Temporary pool names last until export.
Ensures that the original pool name will be used in all label updates and
therefore is retained upon export.
Will also set
.Sy cachefile
property to
.Sy none
when not explicitly specified.
.It Fl F
Recovery mode for a non-importable pool. Attempt to return the pool to an
importable state by discarding the last few transactions. Not all damaged pools
+66 -25
View File
@@ -212,8 +212,9 @@ get_usage(zpool_help_t idx)
return (gettext("\tclear [-nF] <pool> [device]\n"));
case HELP_CREATE:
return (gettext("\tcreate [-fnd] [-o property=value] ... \n"
"\t [-O file-system-property=value] ... \n"
"\t [-m mountpoint] [-R root] <pool> <vdev> ...\n"));
"\t [-O file-system-property=value] ...\n"
"\t [-m mountpoint] [-R root] [-t tempname] "
"<pool> <vdev> ...\n"));
case HELP_DESTROY:
return (gettext("\tdestroy [-f] <pool>\n"));
case HELP_DETACH:
@@ -230,7 +231,7 @@ get_usage(zpool_help_t idx)
"[-R root] [-F [-n]] -a\n"
"\timport [-o mntopts] [-o property=value] ... \n"
"\t [-d dir | -c cachefile] [-D] [-f] [-m] [-N] "
"[-R root] [-F [-n]]\n"
"[-R root] [-F [-n]] [-t]\n"
"\t <pool | id> [newpool]\n"));
case HELP_IOSTAT:
return (gettext("\tiostat [-v] [-T d|u] [pool] ... [interval "
@@ -479,6 +480,21 @@ add_prop_list(const char *propname, char *propval, nvlist_t **props,
return (0);
}
/*
* Set a default property pair (name, string-value) in a property nvlist
*/
static int
add_prop_list_default(const char *propname, char *propval, nvlist_t **props,
boolean_t poolprop)
{
char *pval;
if (nvlist_lookup_string(*props, propname, &pval) == 0)
return (0);
return (add_prop_list(propname, propval, props, poolprop));
}
/*
* zpool add [-fn] <pool> <vdev> ...
*
@@ -704,7 +720,7 @@ zpool_do_labelclear(int argc, char **argv)
return (1);
}
if (zpool_read_label(fd, &config) != 0 || config == NULL) {
if (zpool_read_label(fd, &config) != 0) {
(void) fprintf(stderr,
gettext("failed to read label from %s\n"), vdev);
return (1);
@@ -775,14 +791,15 @@ errout:
/*
* zpool create [-fnd] [-o property=value] ...
* [-O file-system-property=value] ...
* [-R root] [-m mountpoint] <pool> <dev> ...
* [-R root] [-m mountpoint] [-t tempname] <pool> <dev> ...
*
* -f Force creation, even if devices appear in use
* -n Do not create the pool, but display the resulting layout if it
* were to be created.
* -R Create a pool under an alternate root
* -m Set default mountpoint for the root dataset. By default it's
* -R Create a pool under an alternate root
* -m Set default mountpoint for the root dataset. By default it's
* '/<pool>'
* -t Use the temporary name until the pool is exported.
* -o Set property=value.
* -d Don't automatically enable all supported pool features
* (individual features can be enabled with -o).
@@ -802,6 +819,7 @@ zpool_do_create(int argc, char **argv)
int c;
nvlist_t *nvroot = NULL;
char *poolname;
char *tname = NULL;
int ret = 1;
char *altroot = NULL;
char *mountpoint = NULL;
@@ -810,7 +828,7 @@ zpool_do_create(int argc, char **argv)
char *propval;
/* check options */
while ((c = getopt(argc, argv, ":fndR:m:o:O:")) != -1) {
while ((c = getopt(argc, argv, ":fndR:m:o:O:t:")) != -1) {
switch (c) {
case 'f':
force = B_TRUE;
@@ -826,11 +844,7 @@ zpool_do_create(int argc, char **argv)
if (add_prop_list(zpool_prop_to_name(
ZPOOL_PROP_ALTROOT), optarg, &props, B_TRUE))
goto errout;
if (nvlist_lookup_string(props,
zpool_prop_to_name(ZPOOL_PROP_CACHEFILE),
&propval) == 0)
break;
if (add_prop_list(zpool_prop_to_name(
if (add_prop_list_default(zpool_prop_to_name(
ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE))
goto errout;
break;
@@ -889,6 +903,27 @@ zpool_do_create(int argc, char **argv)
goto errout;
}
break;
case 't':
/*
* Sanity check temporary pool name.
*/
if (strchr(optarg, '/') != NULL) {
(void) fprintf(stderr, gettext("cannot create "
"'%s': invalid character '/' in temporary "
"name\n"), optarg);
(void) fprintf(stderr, gettext("use 'zfs "
"create' to create a dataset\n"));
goto errout;
}
if (add_prop_list(zpool_prop_to_name(
ZPOOL_PROP_TNAME), optarg, &props, B_TRUE))
goto errout;
if (add_prop_list_default(zpool_prop_to_name(
ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE))
goto errout;
tname = optarg;
break;
case ':':
(void) fprintf(stderr, gettext("missing argument for "
"'%c' option\n"), optopt);
@@ -1061,8 +1096,8 @@ zpool_do_create(int argc, char **argv)
ret = 1;
if (zpool_create(g_zfs, poolname,
nvroot, props, fsprops) == 0) {
zfs_handle_t *pool = zfs_open(g_zfs, poolname,
ZFS_TYPE_FILESYSTEM);
zfs_handle_t *pool = zfs_open(g_zfs,
tname ? tname : poolname, ZFS_TYPE_FILESYSTEM);
if (pool != NULL) {
if (zfs_mount(pool, NULL, 0) == 0)
ret = zfs_shareall(pool);
@@ -1931,7 +1966,8 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
* import [-o mntopts] [-o prop=value] ... [-R root] [-D]
* [-d dir | -c cachefile] [-f] -a
* import [-o mntopts] [-o prop=value] ... [-R root] [-D]
* [-d dir | -c cachefile] [-f] [-n] [-F] <pool | id> [newpool]
* [-d dir | -c cachefile] [-f] [-n] [-F] [-t]
* <pool | id> [newpool]
*
* -c Read pool information from a cachefile instead of searching
* devices.
@@ -1960,6 +1996,9 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
*
* -N Import the pool but don't mount datasets.
*
* -t Use newpool as a temporary pool name instead of renaming
* the pool.
*
* -T Specify a starting txg to use for import. This option is
* intentionally undocumented option for testing purposes.
*
@@ -2001,7 +2040,7 @@ zpool_do_import(int argc, char **argv)
char *endptr;
/* check options */
while ((c = getopt(argc, argv, ":aCc:d:DEfFmnNo:R:T:VX")) != -1) {
while ((c = getopt(argc, argv, ":aCc:d:DEfFmnNo:R:tT:VX")) != -1) {
switch (c) {
case 'a':
do_all = B_TRUE;
@@ -2055,11 +2094,13 @@ zpool_do_import(int argc, char **argv)
if (add_prop_list(zpool_prop_to_name(
ZPOOL_PROP_ALTROOT), optarg, &props, B_TRUE))
goto error;
if (nvlist_lookup_string(props,
zpool_prop_to_name(ZPOOL_PROP_CACHEFILE),
&propval) == 0)
break;
if (add_prop_list(zpool_prop_to_name(
if (add_prop_list_default(zpool_prop_to_name(
ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE))
goto error;
break;
case 't':
flags |= ZFS_IMPORT_TEMP_NAME;
if (add_prop_list_default(zpool_prop_to_name(
ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE))
goto error;
break;
@@ -2193,9 +2234,9 @@ zpool_do_import(int argc, char **argv)
(void) fprintf(stderr, gettext("cannot import '%s': "
"a pool with that name already exists\n"),
argv[0]);
(void) fprintf(stderr, gettext("use the form '%s "
"<pool | id> <newpool>' to give it a new name\n"),
"zpool import");
(void) fprintf(stderr, gettext("use the form 'zpool import "
"[-t] <pool | id> <newpool>' to give it a new temporary "
"or permanent name\n"));
err = 1;
} else if (pools == NULL && idata.exists) {
(void) fprintf(stderr, gettext("cannot import '%s': "
@@ -684,6 +684,21 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
verify(nvlist_lookup_string(cnv,
ZPOOL_CONFIG_TYPE,
&childtype) == 0);
if (strcmp(childtype,
VDEV_TYPE_SPARE) == 0) {
/* We have a replacing vdev with
* a spare child. Get the first
* real child of the spare
*/
verify(
nvlist_lookup_nvlist_array(
cnv,
ZPOOL_CONFIG_CHILDREN,
&rchild,
&rchildren) == 0);
assert(rchildren >= 2);
cnv = rchild[0];
}
}
verify(nvlist_lookup_string(cnv,
+19 -10
View File
@@ -25,6 +25,7 @@
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
* Copyright 2017 Joyent, Inc.
*/
/*
@@ -124,6 +125,7 @@
#include <errno.h>
#include <sys/fs/zfs.h>
#include <libnvpair.h>
#include <libcmdutils.h>
static int ztest_fd_data = -1;
static int ztest_fd_rand = -1;
@@ -554,12 +556,13 @@ usage(boolean_t requested)
{
const ztest_shared_opts_t *zo = &ztest_opts_defaults;
char nice_vdev_size[10];
char nice_gang_bang[10];
char nice_vdev_size[NN_NUMBUF_SZ];
char nice_gang_bang[NN_NUMBUF_SZ];
FILE *fp = requested ? stdout : stderr;
nicenum(zo->zo_vdev_size, nice_vdev_size);
nicenum(zo->zo_metaslab_gang_bang, nice_gang_bang);
nicenum(zo->zo_vdev_size, nice_vdev_size, sizeof (nice_vdev_size));
nicenum(zo->zo_metaslab_gang_bang, nice_gang_bang,
sizeof (nice_gang_bang));
(void) fprintf(fp, "Usage: %s\n"
"\t[-v vdevs (default: %llu)]\n"
@@ -581,6 +584,8 @@ usage(boolean_t requested)
"\t[-F freezeloops (default: %llu)] max loops in spa_freeze()\n"
"\t[-P passtime (default: %llu sec)] time per pass\n"
"\t[-B alt_ztest (default: <none>)] alternate ztest path\n"
"\t[-o variable=value] ... set global variable to an unsigned\n"
"\t 32-bit integer value\n"
"\t[-h] (print help)\n"
"",
zo->zo_pool,
@@ -616,7 +621,7 @@ process_options(int argc, char **argv)
bcopy(&ztest_opts_defaults, zo, sizeof (*zo));
while ((opt = getopt(argc, argv,
"v:s:a:m:r:R:d:t:g:i:k:p:f:VET:P:hF:B:")) != EOF) {
"v:s:a:m:r:R:d:t:g:i:k:p:f:VET:P:hF:B:o:")) != EOF) {
value = 0;
switch (opt) {
case 'v':
@@ -703,6 +708,10 @@ process_options(int argc, char **argv)
case 'B':
(void) strlcpy(altdir, optarg, sizeof (altdir));
break;
case 'o':
if (set_global_var(optarg) != 0)
usage(B_FALSE);
break;
case 'h':
usage(B_TRUE);
break;
@@ -3150,10 +3159,10 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
old_class_space, new_class_space);
if (ztest_opts.zo_verbose >= 5) {
char oldnumbuf[6], newnumbuf[6];
char oldnumbuf[NN_NUMBUF_SZ], newnumbuf[NN_NUMBUF_SZ];
nicenum(old_class_space, oldnumbuf);
nicenum(new_class_space, newnumbuf);
nicenum(old_class_space, oldnumbuf, sizeof (oldnumbuf));
nicenum(new_class_space, newnumbuf, sizeof (newnumbuf));
(void) printf("%s grew from %s to %s\n",
spa->spa_name, oldnumbuf, newnumbuf);
}
@@ -6190,7 +6199,7 @@ main(int argc, char **argv)
ztest_info_t *zi;
ztest_shared_callstate_t *zc;
char timebuf[100];
char numbuf[6];
char numbuf[NN_NUMBUF_SZ];
spa_t *spa;
char *cmd;
boolean_t hasalt;
@@ -6327,7 +6336,7 @@ main(int argc, char **argv)
now = MIN(now, zs->zs_proc_stop);
print_time(zs->zs_proc_stop - now, timebuf);
nicenum(zs->zs_space, numbuf);
nicenum(zs->zs_space, numbuf, sizeof (numbuf));
(void) printf("Pass %3d, %8s, %3llu ENOSPC, "
"%4.1f%% of %5s used, %3.0f%% done, %8s to go\n",
@@ -0,0 +1,130 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2017 Jason king
*/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/debug.h>
#include "libcmdutils.h"
/* The largest suffix that can fit, aka an exabyte (2^60 / 10^18) */
#define INDEX_MAX (6)
/* Verify INDEX_MAX fits */
CTASSERT(INDEX_MAX * 10 < sizeof (uint64_t) * 8);
void
nicenum_scale(uint64_t n, size_t units, char *buf, size_t buflen,
uint32_t flags)
{
uint64_t divamt = 1024;
uint64_t divisor = 1;
int index = 0;
int rc = 0;
char u;
if (units == 0)
units = 1;
if (n > 0) {
n *= units;
if (n < units)
goto overflow;
}
if (flags & NN_DIVISOR_1000)
divamt = 1000;
/*
* This tries to find the suffix S(n) such that
* S(n) <= n < S(n+1), where S(n) = 2^(n*10) | 10^(3*n)
* (i.e. 1024/1000, 1,048,576/1,000,000, etc). Stop once S(n)
* is the largest prefix supported (i.e. don't bother computing
* and checking S(n+1). Since INDEX_MAX should be the largest
* suffix that fits (currently an exabyte), S(INDEX_MAX + 1) is
* never checked as it would overflow.
*/
while (index < INDEX_MAX) {
uint64_t newdiv = divisor * divamt;
/* CTASSERT() guarantee these never trip */
VERIFY3U(newdiv, >=, divamt);
VERIFY3U(newdiv, >=, divisor);
if (n < newdiv)
break;
divisor = newdiv;
index++;
}
u = " KMGTPE"[index];
if (index == 0) {
rc = snprintf(buf, buflen, "%llu", n);
} else if (n % divisor == 0) {
/*
* If this is an even multiple of the base, always display
* without any decimal precision.
*/
rc = snprintf(buf, buflen, "%llu%c", n / divisor, u);
} else {
/*
* We want to choose a precision that reflects the best choice
* for fitting in 5 characters. This can get rather tricky
* when we have numbers that are very close to an order of
* magnitude. For example, when displaying 10239 (which is
* really 9.999K), we want only a single place of precision
* for 10.0K. We could develop some complex heuristics for
* this, but it's much easier just to try each combination
* in turn.
*/
int i;
for (i = 2; i >= 0; i--) {
if ((rc = snprintf(buf, buflen, "%.*f%c", i,
(double)n / divisor, u)) <= 5)
break;
}
}
if (rc + 1 > buflen || rc < 0)
goto overflow;
return;
overflow:
/* prefer a more verbose message if possible */
if (buflen > 10)
(void) strlcpy(buf, "<overflow>", buflen);
else
(void) strlcpy(buf, "??", buflen);
}
void
nicenum(uint64_t num, char *buf, size_t buflen)
{
nicenum_scale(num, 1, buf, buflen, 0);
}
@@ -0,0 +1,235 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013 RackTop Systems.
*/
/*
* Copyright 2017 Joyent, Inc.
*/
/*
* Declarations for the functions in libcmdutils.
*/
#ifndef _LIBCMDUTILS_H
#define _LIBCMDUTILS_H
#ifdef illumos
#if !defined(_LP64) && \
!((_FILE_OFFSET_BITS == 64) || defined(_LARGEFILE64_SOURCE))
#error "libcmdutils.h can only be used in a largefile compilation environment"
#endif
#endif
/*
* This is a private header file. Applications should not directly include
* this file.
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <libintl.h>
#include <string.h>
#include <dirent.h>
#ifdef illumos
#include <attr.h>
#endif
#include <sys/avl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <libnvpair.h>
#ifdef __cplusplus
extern "C" {
#endif
/* extended system attribute support */
#define _NOT_SATTR 0
#define _RO_SATTR 1
#define _RW_SATTR 2
#define MAXMAPSIZE (1024*1024*8) /* map at most 8MB */
#define SMALLFILESIZE (32*1024) /* don't use mmap on little file */
/* Type used for a node containing a device id and inode number */
#if defined(_LP64) || (_FILE_OFFSET_BITS == 64)
typedef struct tree_node {
dev_t node_dev;
ino_t node_ino;
avl_node_t avl_link;
} tree_node_t;
#else
typedef struct tree_node {
dev_t node_dev;
ino64_t node_ino;
avl_node_t avl_link;
} tree_node_t;
#endif
/* extended system attribute support */
/* Determine if a file is the name of an extended system attribute file */
extern int sysattr_type(char *);
/* Determine if the underlying file system supports system attributes */
extern int sysattr_support(char *, int);
/* Copies the content of the source file to the target file */
#if defined(_LP64) || (_FILE_OFFSET_BITS == 64)
extern int writefile(int, int, char *, char *, char *, char *,
struct stat *, struct stat *);
#else
extern int writefile(int, int, char *, char *, char *, char *,
struct stat64 *, struct stat64 *);
#endif
/* Gets file descriptors of the source and target attribute files */
extern int get_attrdirs(int, int, char *, int *, int *);
/* Move extended attribute and extended system attribute */
extern int mv_xattrs(char *, char *, char *, int, int);
/* Returns non default extended system attribute list */
extern nvlist_t *sysattr_list(char *, int, char *);
/* avltree */
/*
* Used to compare two nodes. We are attempting to match the 1st
* argument (node) against the 2nd argument (a node which
* is already in the search tree).
*/
extern int tnode_compare(const void *, const void *);
/*
* Used to add a single node (containing the input device id and
* inode number) to the specified search tree. The calling
* application must set the tree pointer to NULL before calling
* add_tnode() for the first time.
*/
#if defined(_LP64) || (_FILE_OFFSET_BITS == 64)
extern int add_tnode(avl_tree_t **, dev_t, ino_t);
#else
extern int add_tnode(avl_tree_t **, dev_t, ino64_t);
#endif
/*
* Used to destroy a whole tree (all nodes) without rebalancing.
* The calling application is responsible for setting the tree
* pointer to NULL upon return.
*/
extern void destroy_tree(avl_tree_t *);
/* user/group id helpers */
/*
* Used to get the next available user id in given range.
*/
extern int findnextuid(uid_t, uid_t, uid_t *);
/*
* Used to get the next available group id in given range.
*/
extern int findnextgid(gid_t, gid_t, gid_t *);
/* dynamic string utilities */
typedef struct custr custr_t;
/*
* Allocate and free a "custr_t" dynamic string object. Returns 0 on success
* and -1 otherwise.
*/
extern int custr_alloc(custr_t **);
extern void custr_free(custr_t *);
/*
* Allocate a "custr_t" dynamic string object that operates on a fixed external
* buffer.
*/
extern int custr_alloc_buf(custr_t **, void *, size_t);
/*
* Append a single character, or a NUL-terminated string of characters, to a
* dynamic string. Returns 0 on success and -1 otherwise. The dynamic string
* will be unmodified if the function returns -1.
*/
extern int custr_appendc(custr_t *, char);
extern int custr_append(custr_t *, const char *);
/*
* Append a format string and arguments as though the contents were being parsed
* through snprintf. Returns 0 on success and -1 otherwise. The dynamic string
* will be unmodified if the function returns -1.
*/
extern int custr_append_printf(custr_t *, const char *, ...);
extern int custr_append_vprintf(custr_t *, const char *, va_list);
/*
* Determine the length in bytes, not including the NUL terminator, of the
* dynamic string.
*/
extern size_t custr_len(custr_t *);
/*
* Clear the contents of a dynamic string. Does not free the underlying
* memory.
*/
extern void custr_reset(custr_t *);
/*
* Retrieve a const pointer to a NUL-terminated string version of the contents
* of the dynamic string. Storage for this string should not be freed, and
* the pointer will be invalidated by any mutations to the dynamic string.
*/
extern const char *custr_cstr(custr_t *str);
#define NN_DIVISOR_1000 (1U << 0)
/* Minimum size for the output of nicenum, including NULL */
#define NN_NUMBUF_SZ (6)
void nicenum(uint64_t, char *, size_t);
void nicenum_scale(uint64_t, size_t, char *, size_t, uint32_t);
#ifdef __cplusplus
}
#endif
#endif /* _LIBCMDUTILS_H */
@@ -22,7 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2011, 2016 by Delphix. All rights reserved.
* Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
* Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved.
* Copyright (c) 2013 Martin Matuska. All rights reserved.
@@ -2068,6 +2068,7 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
if (zfs_prop_readonly(prop) &&
*source != NULL && (*source)[0] == '\0') {
*source = NULL;
return (-1);
}
break;
@@ -55,15 +55,6 @@
#define ZDIFF_REMOVED '-'
#define ZDIFF_RENAMED 'R'
static boolean_t
do_name_cmp(const char *fpath, const char *tpath)
{
char *fname, *tname;
fname = strrchr(fpath, '/') + 1;
tname = strrchr(tpath, '/') + 1;
return (strcmp(fname, tname) == 0);
}
typedef struct differ_info {
zfs_handle_t *zhp;
char *fromsnap;
@@ -262,7 +253,6 @@ static int
write_inuse_diffs_one(FILE *fp, differ_info_t *di, uint64_t dobj)
{
struct zfs_stat fsb, tsb;
boolean_t same_name;
mode_t fmode, tmode;
char fobjname[MAXPATHLEN], tobjname[MAXPATHLEN];
int fobjerr, tobjerr;
@@ -323,7 +313,6 @@ write_inuse_diffs_one(FILE *fp, differ_info_t *di, uint64_t dobj)
if (fmode != tmode && fsb.zs_gen == tsb.zs_gen)
tsb.zs_gen++; /* Force a generational difference */
same_name = do_name_cmp(fobjname, tobjname);
/* Simple modification or no change */
if (fsb.zs_gen == tsb.zs_gen) {
@@ -334,7 +323,7 @@ write_inuse_diffs_one(FILE *fp, differ_info_t *di, uint64_t dobj)
if (change) {
print_link_change(fp, di, change,
change > 0 ? fobjname : tobjname, &tsb);
} else if (same_name) {
} else if (strcmp(fobjname, tobjname) == 0) {
print_file(fp, di, ZDIFF_MODIFIED, fobjname, &tsb);
} else {
print_rename(fp, di, fobjname, tobjname, &tsb);
@@ -864,6 +864,7 @@ label_offset(uint64_t size, int l)
/*
* Given a file descriptor, read the label information and return an nvlist
* describing the configuration, if there is one.
* Return 0 on success, or -1 on failure
*/
int
zpool_read_label(int fd, nvlist_t **config)
@@ -876,7 +877,7 @@ zpool_read_label(int fd, nvlist_t **config)
*config = NULL;
if (fstat64(fd, &statbuf) == -1)
return (0);
return (-1);
size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t);
if ((label = malloc(sizeof (vdev_label_t))) == NULL)
@@ -910,7 +911,8 @@ zpool_read_label(int fd, nvlist_t **config)
free(label);
*config = NULL;
return (0);
errno = ENOENT;
return (-1);
}
typedef struct rdsk_node {
@@ -1088,7 +1090,7 @@ zpool_open_func(void *arg)
}
#endif /* illumos */
if ((zpool_read_label(fd, &config)) != 0) {
if ((zpool_read_label(fd, &config)) != 0 && errno == ENOMEM) {
(void) close(fd);
(void) no_memory(rn->rn_hdl);
return;
@@ -1589,7 +1591,7 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr,
*inuse = B_FALSE;
if (zpool_read_label(fd, &config) != 0) {
if (zpool_read_label(fd, &config) != 0 && errno == ENOMEM) {
(void) no_memory(hdl);
return (-1);
}
@@ -20,9 +20,11 @@
*/
/*
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
* Copyright 2017 RackTop Systems.
*/
/*
@@ -87,7 +89,7 @@ zfs_share_type_t zfs_is_shared_proto(zfs_handle_t *, char **,
zfs_share_proto_t);
/*
* The share protocols table must be in the same order as the zfs_share_prot_t
* The share protocols table must be in the same order as the zfs_share_proto_t
* enum in libzfs_impl.h
*/
typedef struct {
@@ -872,7 +874,7 @@ unshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint,
/* make sure libshare initialized */
if ((err = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) {
free(mntpt); /* don't need the copy anymore */
return (zfs_error_fmt(hdl, EZFS_SHARENFSFAILED,
return (zfs_error_fmt(hdl, proto_table[proto].p_unshare_err,
dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"),
name, _sa_errorstr(err)));
}
@@ -883,12 +885,13 @@ unshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint,
if (share != NULL) {
err = zfs_sa_disable_share(share, proto_table[proto].p_name);
if (err != SA_OK) {
return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,
return (zfs_error_fmt(hdl,
proto_table[proto].p_unshare_err,
dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"),
name, _sa_errorstr(err)));
}
} else {
return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,
return (zfs_error_fmt(hdl, proto_table[proto].p_unshare_err,
dgettext(TEXT_DOMAIN, "cannot unshare '%s': not found"),
name));
}
@@ -630,6 +630,7 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
goto error;
}
break;
case ZPOOL_PROP_READONLY:
if (!flags.import) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
@@ -640,6 +641,16 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
}
break;
case ZPOOL_PROP_TNAME:
if (!flags.create) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property '%s' can only be set at "
"creation time"), propname);
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
goto error;
}
break;
default:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property '%s'(%d) not defined"), propname, prop);
@@ -2272,6 +2283,7 @@ vdev_get_physpaths(nvlist_t *nv, char *physpath, size_t phypath_size,
return (ret);
}
} else if (strcmp(type, VDEV_TYPE_MIRROR) == 0 ||
strcmp(type, VDEV_TYPE_RAIDZ) == 0 ||
strcmp(type, VDEV_TYPE_REPLACING) == 0 ||
(is_spare = (strcmp(type, VDEV_TYPE_SPARE) == 0))) {
nvlist_t **child;
@@ -3195,7 +3195,12 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
/*
* Determine the name of the origin snapshot, store in zc_string.
*/
if (drrb->drr_flags & DRR_FLAG_CLONE) {
if (originsnap) {
(void) strncpy(zc.zc_string, originsnap, sizeof (zc.zc_string));
if (flags->verbose)
(void) printf("using provided clone origin %s\n",
zc.zc_string);
} else if (drrb->drr_flags & DRR_FLAG_CLONE) {
if (guid_to_name(hdl, zc.zc_value,
drrb->drr_fromguid, B_FALSE, zc.zc_string) != 0) {
zcmd_free_nvlists(&zc);
@@ -3206,11 +3211,6 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
}
if (flags->verbose)
(void) printf("found clone origin %s\n", zc.zc_string);
} else if (originsnap) {
(void) strncpy(zc.zc_string, originsnap, sizeof (zc.zc_string));
if (flags->verbose)
(void) printf("using provided clone origin %s\n",
zc.zc_string);
}
boolean_t resuming = DMU_GET_FEATUREFLAGS(drrb->drr_versioninfo) &
@@ -48,6 +48,7 @@
#include <sys/mnttab.h>
#include <sys/mntent.h>
#include <sys/types.h>
#include <libcmdutils.h>
#include <libzfs.h>
#include <libzfs_core.h>
@@ -575,42 +576,7 @@ zfs_strdup(libzfs_handle_t *hdl, const char *str)
void
zfs_nicenum(uint64_t num, char *buf, size_t buflen)
{
uint64_t n = num;
int index = 0;
char u;
while (n >= 1024) {
n /= 1024;
index++;
}
u = " KMGTPE"[index];
if (index == 0) {
(void) snprintf(buf, buflen, "%llu", n);
} else if ((num & ((1ULL << 10 * index) - 1)) == 0) {
/*
* If this is an even multiple of the base, always display
* without any decimal precision.
*/
(void) snprintf(buf, buflen, "%llu%c", n, u);
} else {
/*
* We want to choose a precision that reflects the best choice
* for fitting in 5 characters. This can get rather tricky when
* we have numbers that are very close to an order of magnitude.
* For example, when displaying 10239 (which is really 9.999K),
* we want only a single place of precision for 10.0K. We could
* develop some complex heuristics for this, but it's much
* easier just to try each combination in turn.
*/
int i;
for (i = 2; i >= 0; i--) {
if (snprintf(buf, buflen, "%.*f%c", i,
(double)num / (1ULL << 10 * index), u) <= 5)
break;
}
}
nicenum(num, buf, buflen);
}
void
@@ -727,11 +727,9 @@ static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" };
void
vpanic(const char *fmt, va_list adx)
{
(void) fprintf(stderr, "error: ");
(void) vfprintf(stderr, fmt, adx);
(void) fprintf(stderr, "\n");
abort(); /* think of it as a "user-level crash dump" */
char buf[512];
(void) vsnprintf(buf, 512, fmt, adx);
assfail(buf, NULL, 0);
}
void
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
/*
@@ -579,8 +579,9 @@ extern void kernel_init(int);
extern void kernel_fini(void);
struct spa;
extern void nicenum(uint64_t num, char *buf);
extern void nicenum(uint64_t num, char *buf, size_t);
extern void show_pool_stats(struct spa *);
extern int set_global_var(char *arg);
typedef struct callb_cpr {
kmutex_t *cc_lockp;
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016 by Delphix. All rights reserved.
*/
#include <assert.h>
@@ -31,38 +32,12 @@
#include <sys/spa.h>
#include <sys/fs/zfs.h>
#include <sys/refcount.h>
#include <dlfcn.h>
/*
* Routines needed by more than one client of libzpool.
*/
void
nicenum(uint64_t num, char *buf)
{
uint64_t n = num;
int index = 0;
char u;
while (n >= 1024) {
n = (n + (1024 / 2)) / 1024; /* Round up or down */
index++;
}
u = " KMGTPE"[index];
if (index == 0) {
(void) sprintf(buf, "%llu", (u_longlong_t)n);
} else if (n < 10 && (num & (num - 1)) != 0) {
(void) sprintf(buf, "%.2f%c",
(double)num / (1ULL << 10 * index), u);
} else if (n < 100 && (num & (num - 1)) != 0) {
(void) sprintf(buf, "%.1f%c",
(double)num / (1ULL << 10 * index), u);
} else {
(void) sprintf(buf, "%llu%c", (u_longlong_t)n, u);
}
}
static void
show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent)
{
@@ -95,15 +70,17 @@ show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent)
sec = MAX(1, vs->vs_timestamp / NANOSEC);
nicenum(vs->vs_alloc, used);
nicenum(vs->vs_space - vs->vs_alloc, avail);
nicenum(vs->vs_ops[ZIO_TYPE_READ] / sec, rops);
nicenum(vs->vs_ops[ZIO_TYPE_WRITE] / sec, wops);
nicenum(vs->vs_bytes[ZIO_TYPE_READ] / sec, rbytes);
nicenum(vs->vs_bytes[ZIO_TYPE_WRITE] / sec, wbytes);
nicenum(vs->vs_read_errors, rerr);
nicenum(vs->vs_write_errors, werr);
nicenum(vs->vs_checksum_errors, cerr);
nicenum(vs->vs_alloc, used, sizeof (used));
nicenum(vs->vs_space - vs->vs_alloc, avail, sizeof (avail));
nicenum(vs->vs_ops[ZIO_TYPE_READ] / sec, rops, sizeof (rops));
nicenum(vs->vs_ops[ZIO_TYPE_WRITE] / sec, wops, sizeof (wops));
nicenum(vs->vs_bytes[ZIO_TYPE_READ] / sec, rbytes,
sizeof (rbytes));
nicenum(vs->vs_bytes[ZIO_TYPE_WRITE] / sec, wbytes,
sizeof (wbytes));
nicenum(vs->vs_read_errors, rerr, sizeof (rerr));
nicenum(vs->vs_write_errors, werr, sizeof (werr));
nicenum(vs->vs_checksum_errors, cerr, sizeof (cerr));
(void) printf("%*s%s%*s%*s%*s %5s %5s %5s %5s %5s %5s %5s\n",
indent, "",
@@ -153,3 +130,58 @@ show_pool_stats(spa_t *spa)
nvlist_free(config);
}
/*
* Sets given global variable in libzpool to given unsigned 32-bit value.
* arg: "<variable>=<value>"
*/
int
set_global_var(char *arg)
{
void *zpoolhdl;
char *varname = arg, *varval;
u_longlong_t val;
#ifndef _LITTLE_ENDIAN
/*
* On big endian systems changing a 64-bit variable would set the high
* 32 bits instead of the low 32 bits, which could cause unexpected
* results.
*/
fprintf(stderr, "Setting global variables is only supported on "
"little-endian systems\n", varname);
return (ENOTSUP);
#endif
if ((varval = strchr(arg, '=')) != NULL) {
*varval = '\0';
varval++;
val = strtoull(varval, NULL, 0);
if (val > UINT32_MAX) {
fprintf(stderr, "Value for global variable '%s' must "
"be a 32-bit unsigned integer\n", varname);
return (EOVERFLOW);
}
} else {
return (EINVAL);
}
zpoolhdl = dlopen("libzpool.so", RTLD_LAZY);
if (zpoolhdl != NULL) {
uint32_t *var;
var = dlsym(zpoolhdl, varname);
if (var == NULL) {
fprintf(stderr, "Global variable '%s' does not exist "
"in libzpool.so\n", varname);
return (EINVAL);
}
*var = (uint32_t)val;
dlclose(zpoolhdl);
} else {
fprintf(stderr, "Failed to open libzpool.so to set global "
"variable\n");
return (EIO);
}
return (0);
}
+4
View File
@@ -4,6 +4,7 @@
.PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs
.PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
.PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common
.PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils/common
LIB= zfs
DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBUMEM} ${LIBUTIL} ${LIBM} ${LIBNVPAIR} \
@@ -21,6 +22,8 @@ SRCS= deviceid.c \
zmount.c \
zone.c
SRCS+= nicenum.c
SRCS+= libzfs_changelist.c \
libzfs_compat.c \
libzfs_config.c \
@@ -59,5 +62,6 @@ CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libuutil/common
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs_core/common
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils
.include <bsd.lib.mk>
+5 -1
View File
@@ -23,6 +23,8 @@ ATOMIC_SRCS= opensolaris_atomic.c
.endif
# UNICODE_SRCS
.PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/common/unicode
# LIBCMDUTILS_SRCS
.PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils/common
LIB= zpool
@@ -31,10 +33,11 @@ ZFS_SHARED_SRCS= ${ZFS_SHARED_OBJS:C/.o$/.c/}
KERNEL_SRCS= kernel.c taskq.c util.c
LIST_SRCS= list.c
UNICODE_SRCS= u8_textprep.c
LIBCMDUTILS_SRCS=nicenum.c
SRCS= ${ZFS_COMMON_SRCS} ${ZFS_SHARED_SRCS} \
${KERNEL_SRCS} ${LIST_SRCS} ${ATOMIC_SRCS} \
${UNICODE_SRCS}
${UNICODE_SRCS} ${LIBCMDUTILS_SRCS}
WARNS?= 0
CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris
@@ -47,6 +50,7 @@ CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs
CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/head
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils
# XXX: pthread doesn't have mutex_owned() equivalent, so we need to look
# into libthr private structures. That's sooo evil, but it's only for
# ZFS debugging tools needs.
+1
View File
@@ -11,6 +11,7 @@ CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include
CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzpool/common
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils
CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs
CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys
@@ -167,6 +167,8 @@ TESTFILES= \
tst.sizedkeys.d.out \
tst.stddev.d \
tst.stddev.d.out \
tst.stddev.normalize.d \
tst.stddev.normalize.d.out \
tst.subr.d \
tst.sum.d \
tst.sum.d.out \
+1
View File
@@ -12,6 +12,7 @@ CSTD= c99
CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris
CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include
CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libuutil/common
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common
+1 -1
View File
@@ -79,7 +79,7 @@ enum show_opt {
static void
time_print(time_type tt)
{
time_t t = (time_t)*tt;
time_t t = (time_t)(intptr_t)tt;
struct tm *tp = localtime(&t);
printf("%02d/%02d/%04d %02d:%02d:%02d",
tp->tm_mon + 1, tp->tm_mday,
+2 -2
View File
@@ -4815,7 +4815,7 @@ _bfd_elf_archive_symbol_lookup (bfd *abfd,
len = strlen (name);
copy = bfd_alloc (abfd, len);
if (copy == NULL)
return (struct elf_link_hash_entry *) 0 - 1;
return (struct elf_link_hash_entry *)(intptr_t)-1;
first = p - name + 1;
memcpy (copy, name, first);
@@ -4927,7 +4927,7 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
}
h = archive_symbol_lookup (abfd, info, symdef->name);
if (h == (struct elf_link_hash_entry *) 0 - 1)
if (h == (struct elf_link_hash_entry *)(intptr_t)-1)
goto error_return;
if (h == NULL)
+1 -1
View File
@@ -320,7 +320,7 @@ ihex_scan (bfd *abfd)
{
if (! ISHEX (buf[i]))
{
ihex_bad_byte (abfd, lineno, hdr[i], error);
ihex_bad_byte (abfd, lineno, buf[i], error);
goto error_return;
}
}
+20
View File
@@ -448,6 +448,17 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd,
{
int idx;
/* PR 17512: Corrupt PE binaries can cause seg-faults. */
if (a->NumberOfRvaAndSizes > 16)
{
(*_bfd_error_handler)
(_("%B: aout header specifies an invalid number of data-directory entries: %d"),
abfd, a->NumberOfRvaAndSizes);
/* Paranoia: If the number is corrupt, then assume that the
actual entries themselves might be corrupt as well. */
a->NumberOfRvaAndSizes = 0;
}
for (idx = 0; idx < 16; idx++)
{
/* If data directory is empty, rva also should be 0. */
@@ -1428,6 +1439,15 @@ pe_print_edata (bfd * abfd, void * vfile)
}
}
/* PR 17512: Handle corrupt PE binaries. */
if (datasize < 36)
{
fprintf (file,
_("\nThere is an export table in %s, but it is too small (%d)\n"),
section->name, (int) datasize);
return TRUE;
}
fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"),
section->name, (unsigned long) addr);
+14 -14
View File
@@ -1353,13 +1353,13 @@ pe_bfd_object_p (bfd * abfd)
if (pe_arch (bfd_target_efi_arch (*target_ptr)) != arch)
continue;
if (efi)
{
/* TARGET_PTR is an EFI backend. Don't match
TARGET with a EFI file. */
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
if (efi)
{
/* TARGET_PTR is an EFI backend. Don't match
TARGET with a EFI file. */
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
}
else if (bfd_target_pei_p (*target_ptr))
{
@@ -1367,13 +1367,13 @@ pe_bfd_object_p (bfd * abfd)
if (pe_arch (bfd_target_pei_arch (*target_ptr)) != arch)
continue;
if (!efi)
{
/* TARGET_PTR is a PE backend. Don't match
TARGET with a PE file. */
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
if (!efi)
{
/* TARGET_PTR is a PE backend. Don't match
TARGET with a PE file. */
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
}
}
}
+3 -3
View File
@@ -119,11 +119,11 @@ extern "C" {
may ignore the byte-within-word field of the pointer. */
#ifndef __PTR_TO_INT
# define __PTR_TO_INT(P) ((P) - (char *) 0)
# define __PTR_TO_INT(P) ((intptr_t)(P))
#endif
#ifndef __INT_TO_PTR
# define __INT_TO_PTR(P) ((P) + (char *) 0)
# define __INT_TO_PTR(P) ((void*)(intptr_t)(P))
#endif
/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is
@@ -427,7 +427,7 @@ __extension__ \
__o1->maybe_empty_object = 1; \
__o1->next_free \
= __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
& ~ (__o1->alignment_mask)); \
& ~(intptr_t)(__o1->alignment_mask)); \
if (__o1->next_free - (char *)__o1->chunk \
> __o1->chunk_limit - (char *)__o1->chunk) \
__o1->next_free = __o1->chunk_limit; \
+1 -1
View File
@@ -474,7 +474,7 @@ table_check_response(struct tabwork *work, const struct snmp_pdu *resp)
if (snmp_client.version == SNMP_V1 &&
resp->error_status == SNMP_ERR_NOSUCHNAME &&
resp->error_index ==
(work->descr->last_change.len == 0) ? 1 : 2)
((work->descr->last_change.len == 0) ? 1 : 2))
/* EOT */
return (0);
/* Error */
+63 -4
View File
@@ -439,11 +439,15 @@ mibif_restart_mibII_poll_timer(void)
int
mib_fetch_ifmib(struct mibif *ifp)
{
static int kmib[2] = { -1, 0 }; /* for sysctl net.ifdescr_maxlen */
int name[6];
size_t kmiblen = nitems(kmib);
size_t len;
void *newmib;
struct ifmibdata oldmib = ifp->mib;
struct ifreq irr;
unsigned int alias_maxlen = MIBIF_ALIAS_SIZE_MAX;
if (fetch_generic_mib(ifp, &oldmib) == -1)
return (-1);
@@ -515,18 +519,69 @@ mib_fetch_ifmib(struct mibif *ifp)
}
out:
/*
* Find sysctl mib for net.ifdescr_maxlen (one time).
* kmib[0] == -1 at first call to mib_fetch_ifmib().
* Then kmib[0] > 0 if we found sysctl mib for net.ifdescr_maxlen.
* Else, kmib[0] == 0 (unexpected error from a kernel).
*/
if (kmib[0] < 0 &&
sysctlnametomib("net.ifdescr_maxlen", kmib, &kmiblen) < 0) {
kmib[0] = 0;
syslog(LOG_WARNING, "sysctlnametomib net.ifdescr_maxlen: %m");
}
/*
* Fetch net.ifdescr_maxlen value every time to catch up with changes.
*/
len = sizeof(alias_maxlen);
if (kmib[0] > 0 && sysctl(kmib, 2, &alias_maxlen, &len, NULL, 0) < 0) {
/* unexpected error from the kernel, use default value */
alias_maxlen = MIBIF_ALIAS_SIZE_MAX;
syslog(LOG_WARNING, "sysctl net.ifdescr_maxlen: %m");
}
/*
* Kernel limit might be decreased after interfaces got
* their descriptions assigned. Try to obtain them anyway.
*/
if (alias_maxlen == 0)
alias_maxlen = MIBIF_ALIAS_SIZE_MAX;
/*
* Allocate maximum memory for a buffer and later reallocate
* to free extra memory.
*/
if ((ifp->alias = malloc(alias_maxlen)) == NULL) {
syslog(LOG_WARNING, "malloc(%d) failed: %m", (int)alias_maxlen);
goto fin;
}
strlcpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name));
irr.ifr_buffer.buffer = MIBIF_PRIV(ifp)->alias;
irr.ifr_buffer.length = sizeof(MIBIF_PRIV(ifp)->alias);
irr.ifr_buffer.buffer = ifp->alias;
irr.ifr_buffer.length = alias_maxlen;
if (ioctl(mib_netsock, SIOCGIFDESCR, &irr) == -1) {
MIBIF_PRIV(ifp)->alias[0] = 0;
free(ifp->alias);
ifp->alias = NULL;
if (errno != ENOMSG)
syslog(LOG_WARNING, "SIOCGIFDESCR (%s): %m", ifp->name);
} else if (irr.ifr_buffer.buffer == NULL) {
MIBIF_PRIV(ifp)->alias[0] = 0;
free(ifp->alias);
ifp->alias = NULL;
syslog(LOG_WARNING, "SIOCGIFDESCR (%s): too long (%zu)",
ifp->name, irr.ifr_buffer.length);
} else {
ifp->alias_size = strnlen(ifp->alias, alias_maxlen) + 1;
if (ifp->alias_size > MIBIF_ALIAS_SIZE)
ifp->alias_size = MIBIF_ALIAS_SIZE;
if (ifp->alias_size < alias_maxlen)
ifp->alias = realloc(ifp->alias, ifp->alias_size);
}
fin:
ifp->mibtick = get_ticks();
return (0);
}
@@ -706,6 +761,10 @@ mibif_free(struct mibif *ifp)
mibif_reset_hc_timer();
}
if (ifp->alias != NULL) {
free(ifp->alias);
ifp->alias = NULL;
}
free(ifp->private);
ifp->private = NULL;
free(ifp->physaddr);
+2 -3
View File
@@ -57,8 +57,9 @@
#include "snmp_mibII.h"
#include "mibII_tree.h"
/* maximum size of the interface alias */
/* maximum size of the interface alias unless overridden with net.ifdescr_maxlen */
#define MIBIF_ALIAS_SIZE (64 + 1)
#define MIBIF_ALIAS_SIZE_MAX 1024
/*
* Interface list and flags.
@@ -81,8 +82,6 @@ struct mibif_private {
uint64_t hc_imcasts;
uint64_t hc_ipackets;
/* this should be made public */
char alias[MIBIF_ALIAS_SIZE];
};
#define MIBIF_PRIV(IFP) ((struct mibif_private *)((IFP)->private))
+1 -1
View File
@@ -528,7 +528,7 @@ op_ifxtable(struct snmp_context *ctx, struct snmp_value *value,
break;
case LEAF_ifAlias:
ret = string_get(value, MIBIF_PRIV(ifp)->alias, -1);
ret = string_get(value, ifp->alias, ifp->alias_size - 1);
break;
case LEAF_ifCounterDiscontinuityTime:
+3
View File
@@ -80,6 +80,9 @@ struct mibif {
/* to be set by ifType specific modules. This is ifSpecific. */
struct asn_oid spec_oid;
char *alias;
size_t alias_size;
/* private data - don't touch */
void *private;
};
+31 -2
View File
@@ -2,8 +2,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
@@ -325,3 +325,32 @@ Security fix only. Fixes CERT-FI 20469 as it applies to bzip2.
Izdebski.
* Make the documentation build on Ubuntu 10.04
1.0.7 (27 Jun 19)
~~~~~~~~~~~~~~~~~
* Fix undefined behavior in the macros SET_BH, CLEAR_BH, & ISSET_BH
* bzip2: Fix return value when combining --test,-t and -q.
* bzip2recover: Fix buffer overflow for large argv[0]
* bzip2recover: Fix use after free issue with outFile (CVE-2016-3189)
* Make sure nSelectors is not out of range (CVE-2019-12900)
1.0.8 (13 Jul 19)
~~~~~~~~~~~~~~~~~
* Accept as many selectors as the file format allows.
This relaxes the fix for CVE-2019-12900 from 1.0.7
so that bzip2 allows decompression of bz2 files that
use (too) many selectors again.
* Fix handling of large (> 4GB) files on Windows.
* Cleanup of bzdiff and bzgrep scripts so they don't use
any bash extensions and handle multiple archives correctly.
* There is now a bz2-files testsuite at
https://sourceware.org/git/bzip2-tests.git
+3 -3
View File
@@ -2,7 +2,7 @@
--------------------------------------------------------------------------
This program, "bzip2", the associated library "libbzip2", and all
documentation, are copyright (C) 1996-2010 Julian R Seward. All
documentation, are copyright (C) 1996-2019 Julian R Seward. All
rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, jseward@bzip.org
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Julian Seward, jseward@acm.org
bzip2/libbzip2 version 1.0.8 of 13 July 2019
--------------------------------------------------------------------------
+10 -29
View File
@@ -6,8 +6,8 @@ This version is fully compatible with the previous public releases.
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in this file.
@@ -73,7 +73,7 @@ HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc.
It's difficult for me to support compilation on all these platforms.
My approach is to collect binaries for these platforms, and put them
on the master web site (http://www.bzip.org). Look there. However
on the master web site (https://sourceware.org/bzip2/). Look there. However
(FWIW), bzip2-1.0.X is very standard ANSI C and should compile
unmodified with MS Visual C. If you have difficulties building, you
might want to read README.COMPILATION.PROBLEMS.
@@ -161,43 +161,22 @@ WHAT'S NEW IN 0.9.5 ?
* Many small improvements in file and flag handling.
* A Y2K statement.
WHAT'S NEW IN 1.0.0 ?
WHAT'S NEW IN 1.0.x ?
See the CHANGES file.
WHAT'S NEW IN 1.0.2 ?
See the CHANGES file.
WHAT'S NEW IN 1.0.3 ?
See the CHANGES file.
WHAT'S NEW IN 1.0.4 ?
See the CHANGES file.
WHAT'S NEW IN 1.0.5 ?
See the CHANGES file.
WHAT'S NEW IN 1.0.6 ?
See the CHANGES file.
I hope you find bzip2 useful. Feel free to contact me at
[email protected]
I hope you find bzip2 useful. Feel free to contact the developers at
[email protected]
if you have any suggestions or queries. Many people mailed me with
comments, suggestions and patches after the releases of bzip-0.15,
bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1,
1.0.2 and 1.0.3, and the changes in bzip2 are largely a result of this
feedback. I thank you for your comments.
bzip2's "home" is http://www.bzip.org/
bzip2's "home" is https://sourceware.org/bzip2/
Julian Seward
jseward@bzip.org
jseward@acm.org
Cambridge, UK.
18 July 1996 (version 0.15)
@@ -213,3 +192,5 @@ Cambridge, UK.
20 December 2006 (bzip2, version 1.0.4)
10 December 2007 (bzip2, version 1.0.5)
6 Sept 2010 (bzip2, version 1.0.6)
27 June 2019 (bzip2, version 1.0.7)
13 July 2019 (bzip2, version 1.0.8)
+3 -3
View File
@@ -2,8 +2,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
@@ -12,7 +12,7 @@ This program is released under the terms of the license contained
in the file LICENSE.
------------------------------------------------------------------
bzip2-1.0.6 should compile without problems on the vast majority of
bzip2 should compile without problems on the vast majority of
platforms. Using the supplied Makefile, I've built and tested it
myself for x86-linux and amd64-linux. With makefile.msc, Visual C++
6.0 and nmake, you can build a native Win32 version too. Large file
+5 -5
View File
@@ -8,8 +8,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
@@ -202,9 +202,9 @@ void fallbackQSort3 ( UInt32* fmap,
bhtab [ 0 .. 2+(nblock/32) ] destroyed
*/
#define SET_BH(zz) bhtab[(zz) >> 5] |= (1 << ((zz) & 31))
#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~(1 << ((zz) & 31))
#define ISSET_BH(zz) (bhtab[(zz) >> 5] & (1 << ((zz) & 31)))
#define SET_BH(zz) bhtab[(zz) >> 5] |= ((UInt32)1 << ((zz) & 31))
#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~((UInt32)1 << ((zz) & 31))
#define ISSET_BH(zz) (bhtab[(zz) >> 5] & ((UInt32)1 << ((zz) & 31)))
#define WORD_BH(zz) bhtab[(zz) >> 5]
#define UNALIGNED_BH(zz) ((zz) & 0x01f)
+4 -4
View File
@@ -1,7 +1,7 @@
.PU
.TH bzip2 1
.SH NAME
bzip2, bunzip2 \- a block-sorting file compressor, v1.0.6
bzip2, bunzip2 \- a block-sorting file compressor, v1.0.8
.br
bzcat \- decompresses files to stdout
.br
@@ -405,7 +405,7 @@ I/O error messages are not as helpful as they could be.
tries hard to detect I/O errors and exit cleanly, but the details of
what the problem is sometimes seem rather misleading.
This manual page pertains to version 1.0.6 of
This manual page pertains to version 1.0.8 of
.I bzip2.
Compressed data created by this version is entirely forwards and
backwards compatible with the previous public releases, versions
@@ -427,9 +427,9 @@ with MaybeUInt64 set to be an unsigned 64-bit integer.
.SH AUTHOR
Julian Seward, jsewardbzip.org.
Julian Seward, jseward@acm.org.
http://www.bzip.org
https://sourceware.org/bzip2/
The ideas embodied in
.I bzip2
+21 -19
View File
@@ -7,8 +7,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
@@ -128,12 +128,12 @@
#if BZ_LCCWIN32
# include <io.h>
# include <fcntl.h>
# include <sys\stat.h>
# include <sys/stat.h>
# define NORETURN /**/
# define PATH_SEP '\\'
# define MY_LSTAT _stat
# define MY_STAT _stat
# define MY_LSTAT _stati64
# define MY_STAT _stati64
# define MY_S_ISREG(x) ((x) & _S_IFREG)
# define MY_S_ISDIR(x) ((x) & _S_IFDIR)
@@ -554,7 +554,7 @@ static
Bool testStream ( FILE *zStream )
{
BZFILE* bzf = NULL;
Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i;
Int32 bzerr, bzerr_dummy, ret, streamNo, i;
UChar obuf[5000];
UChar unused[BZ_MAX_UNUSED];
Int32 nUnused;
@@ -577,7 +577,7 @@ Bool testStream ( FILE *zStream )
streamNo++;
while (bzerr == BZ_OK) {
nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 );
BZ2_bzRead ( &bzerr, bzf, obuf, 5000 );
if (bzerr == BZ_DATA_ERROR_MAGIC) goto errhandler;
}
if (bzerr != BZ_STREAM_END) goto errhandler;
@@ -748,8 +748,8 @@ void panic ( const Char* s )
fprintf ( stderr,
"\n%s: PANIC -- internal consistency error:\n"
"\t%s\n"
"\tThis is a BUG. Please report it to me at:\n"
"\tjseward@bzip.org\n",
"\tThis is a BUG. Please report it to:\n"
"\tbzip2-devel@sourceware.org\n",
progName, s );
showFileNames();
cleanUpAndFail( 3 );
@@ -829,7 +829,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n )
" The user's manual, Section 4.3, has more info on (1) and (2).\n"
" \n"
" If you suspect this is a bug in bzip2, or are unsure about (1)\n"
" or (2), feel free to report it to me at: jseward@bzip.org.\n"
" or (2), feel free to report it to: bzip2-devel@sourceware.org.\n"
" Section 4.3 of the user's manual describes the info a useful\n"
" bug report should have. If the manual is available on your\n"
" system, please try and read it before mailing me. If you don't\n"
@@ -852,7 +852,7 @@ void mySIGSEGVorSIGBUScatcher ( IntNative n )
" The user's manual, Section 4.3, has more info on (2) and (3).\n"
" \n"
" If you suspect this is a bug in bzip2, or are unsure about (2)\n"
" or (3), feel free to report it to me at: jseward@bzip.org.\n"
" or (3), feel free to report it to: bzip2-devel@sourceware.org.\n"
" Section 4.3 of the user's manual describes the info a useful\n"
" bug report should have. If the manual is available on your\n"
" system, please try and read it before mailing me. If you don't\n"
@@ -1605,11 +1605,11 @@ void license ( void )
"bzip2, a block-sorting file compressor. "
"Version %s.\n"
" \n"
" Copyright (C) 1996-2010 by Julian Seward.\n"
" Copyright (C) 1996-2019 by Julian Seward.\n"
" \n"
" This program is free software; you can redistribute it and/or modify\n"
" it under the terms set out in the LICENSE file, which is included\n"
" in the bzip2-1.0.6 source distribution.\n"
" in the bzip2 source distribution.\n"
" \n"
" This program is distributed in the hope that it will be useful,\n"
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
@@ -2005,12 +2005,14 @@ IntNative main ( IntNative argc, Char *argv[] )
testf ( aa->name );
}
}
if (testFailsExist && noisy) {
fprintf ( stderr,
"\n"
"You can use the `bzip2recover' program to attempt to recover\n"
"data from undamaged sections of corrupted files.\n\n"
);
if (testFailsExist) {
if (noisy) {
fprintf ( stderr,
"\n"
"You can use the `bzip2recover' program to attempt to recover\n"
"data from undamaged sections of corrupted files.\n\n"
);
}
setExit(2);
exit(exitValue);
}
+6 -4
View File
@@ -7,8 +7,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
@@ -309,11 +309,12 @@ Int32 main ( Int32 argc, Char** argv )
UInt32 buffHi, buffLo, blockCRC;
Char* p;
strcpy ( progName, argv[0] );
strncpy ( progName, argv[0], BZ_MAX_FILENAME-1);
progName[BZ_MAX_FILENAME-1]='\0';
inFileName[0] = outFileName[0] = 0;
fprintf ( stderr,
"bzip2recover 1.0.6: extracts blocks from damaged .bz2 files.\n" );
"bzip2recover 1.0.8: extracts blocks from damaged .bz2 files.\n" );
if (argc != 2) {
fprintf ( stderr, "%s: usage is `%s damaged_file_name'.\n",
@@ -457,6 +458,7 @@ Int32 main ( Int32 argc, Char** argv )
bsPutUChar ( bsWr, 0x50 ); bsPutUChar ( bsWr, 0x90 );
bsPutUInt32 ( bsWr, blockCRC );
bsClose ( bsWr );
outFile = NULL;
}
if (wrBlock >= rbCtr) break;
wrBlock++;
+4 -4
View File
@@ -8,8 +8,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
@@ -47,12 +47,12 @@ void BZ2_bz__AssertH__fail ( int errcode )
fprintf(stderr,
"\n\nbzip2/libbzip2: internal error number %d.\n"
"This is a bug in bzip2/libbzip2, %s.\n"
"Please report it to me at: jseward@bzip.org. If this happened\n"
"Please report it to: bzip2-devel@sourceware.org. If this happened\n"
"when you were using some program which uses libbzip2 as a\n"
"component, you should also report this bug to the author(s)\n"
"of that program. Please make an effort to report this bug;\n"
"timely and accurate bug reports eventually lead to higher\n"
"quality software. Thanks. Julian Seward, 10 December 2007.\n\n",
"quality software. Thanks.\n\n",
errcode,
BZ2_bzlibVersion()
);
+2 -2
View File
@@ -8,8 +8,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
+3 -3
View File
@@ -8,8 +8,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
@@ -36,7 +36,7 @@
/*-- General stuff. --*/
#define BZ_VERSION "1.0.6, 6-Sept-2010"
#define BZ_VERSION "1.0.8, 13-Jul-2019"
typedef char Char;
typedef unsigned char Bool;
+3 -3
View File
@@ -8,8 +8,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
@@ -454,7 +454,7 @@ void sendMTFValues ( EState* s )
AssertH( nGroups < 8, 3002 );
AssertH( nSelectors < 32768 &&
nSelectors <= (2 + (900000 / BZ_G_SIZE)),
nSelectors <= BZ_MAX_SELECTORS,
3003 );
+2 -2
View File
@@ -8,8 +8,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
+10 -4
View File
@@ -8,8 +8,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
@@ -285,7 +285,7 @@ Int32 BZ2_decompress ( DState* s )
/*--- Now the selectors ---*/
GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
if (nGroups < 2 || nGroups > BZ_N_GROUPS) RETURN(BZ_DATA_ERROR);
GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
for (i = 0; i < nSelectors; i++) {
@@ -296,8 +296,14 @@ Int32 BZ2_decompress ( DState* s )
j++;
if (j >= nGroups) RETURN(BZ_DATA_ERROR);
}
s->selectorMtf[i] = j;
/* Having more than BZ_MAX_SELECTORS doesn't make much sense
since they will never be used, but some implementations might
"round up" the number of selectors, so just ignore those. */
if (i < BZ_MAX_SELECTORS)
s->selectorMtf[i] = j;
}
if (nSelectors > BZ_MAX_SELECTORS)
nSelectors = BZ_MAX_SELECTORS;
/*--- Undo the MTF values for the selectors. ---*/
{
+2 -2
View File
@@ -8,8 +8,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
+2 -2
View File
@@ -8,8 +8,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
+2 -2
View File
@@ -13,8 +13,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
+2 -2
View File
@@ -17,8 +17,8 @@
This file is part of bzip2/libbzip2, a program and library for
lossless, block-sorting data compression.
bzip2/libbzip2 version 1.0.6 of 6 September 2010
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
bzip2/libbzip2 version 1.0.8 of 13 July 2019
Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
Please read the WARNING, DISCLAIMER and PATENTS sections in the
README file.
+1 -1
View File
@@ -1,5 +1,5 @@
Checking test results. If any of the four "cmp"s which follow
report any differences, something is wrong. If you can't easily
figure out what, please let me know (jseward@bzip.org).
figure out what, please let me know (jseward@acm.org).
Regular → Executable
View File
File mode changed.
Binary file not shown.
+1 -1
View File
@@ -364,7 +364,7 @@ void check_options ()
output_chain = filter_create_int(NULL, filter_tee_header, headerfilename);
if ( !(m4 = getenv("M4")))
m4 = M4;
filter_create_ext(output_chain, m4, "-gP", 0);
filter_create_ext(output_chain, m4, "-gP", NULL);
filter_create_int(output_chain, filter_fix_linedirs, NULL);
/* For debugging, only run the requested number of filters. */
-7
View File
@@ -479,14 +479,7 @@ ipf_fastroute(m, mpp, fin, fdp)
m->mb_ifp = ifp;
printpacket(fin->fin_out, m);
#if defined(__sgi) && (IRIX < 60500)
(*ifp->if_output)(ifp, (void *)ip, NULL);
# if TRU64 >= 1885
(*ifp->if_output)(ifp, (void *)m, NULL, 0, 0);
# else
(*ifp->if_output)(ifp, (void *)m, NULL, 0);
# endif
#endif
done:
fin->fin_ifp = sifp;
fin->fin_out = sout;
-2
View File
@@ -49,9 +49,7 @@ struct file;
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#ifndef TCP_PAWS_IDLE /* IRIX */
# include <netinet/tcp.h>
#endif
#include <netinet/udp.h>
#include <arpa/inet.h>
+9 -9
View File
@@ -70,9 +70,9 @@ int send_ether(nfd, buf, len, gwip)
bcopy((char *)buf, s + sizeof(*eh), len);
if (gwip.s_addr == last_gw.s_addr)
{
bcopy(last_arp, (char *)A_A eh->ether_dhost, 6);
bcopy(last_arp, (char *) &eh->ether_dhost, 6);
}
else if (arp((char *)&gwip, (char *)A_A eh->ether_dhost) == -1)
else if (arp((char *)&gwip, (char *) &eh->ether_dhost) == -1)
{
perror("arp");
return -2;
@@ -112,17 +112,17 @@ int send_ip(nfd, mtu, ip, gwip, frag)
eh = (ether_header_t *)ipbuf;
bzero((char *)A_A eh->ether_shost, sizeof(eh->ether_shost));
bzero((char *) &eh->ether_shost, sizeof(eh->ether_shost));
if (last_gw.s_addr && (gwip.s_addr == last_gw.s_addr))
{
bcopy(last_arp, (char *)A_A eh->ether_dhost, 6);
bcopy(last_arp, (char *) &eh->ether_dhost, 6);
}
else if (arp((char *)&gwip, (char *)A_A eh->ether_dhost) == -1)
else if (arp((char *)&gwip, (char *) &eh->ether_dhost) == -1)
{
perror("arp");
return -2;
}
bcopy((char *)A_A eh->ether_dhost, last_arp, sizeof(last_arp));
bcopy((char *) &eh->ether_dhost, last_arp, sizeof(last_arp));
eh->ether_type = htons(ETHERTYPE_IP);
bcopy((char *)ip, (char *)&ipsv, sizeof(*ip));
@@ -139,11 +139,11 @@ int send_ip(nfd, mtu, ip, gwip, frag)
}
if (ip->ip_src.s_addr != local_ip.s_addr) {
(void) arp((char *)&ip->ip_src, (char *)A_A local_arp);
bcopy(local_arp, (char *)A_A eh->ether_shost,sizeof(last_arp));
(void) arp((char *)&ip->ip_src, (char *) &local_arp);
bcopy(local_arp, (char *) &eh->ether_shost,sizeof(last_arp));
local_ip = ip->ip_src;
} else
bcopy(local_arp, (char *)A_A eh->ether_shost, 6);
bcopy(local_arp, (char *) &eh->ether_shost, 6);
if (!frag || (sizeof(*eh) + iplen < mtu))
{
+3 -3
View File
@@ -100,7 +100,7 @@ int ip_resend(dev, mtu, r, gwip, datain)
return -2;
}
bzero((char *)A_A eh->ether_shost, sizeof(eh->ether_shost));
bzero((char *) &eh->ether_shost, sizeof(eh->ether_shost));
if (gwip.s_addr && (arp((char *)&gwip, dhost) == -1))
{
perror("arp");
@@ -116,12 +116,12 @@ int ip_resend(dev, mtu, r, gwip, datain)
eh->ether_type = htons((u_short)ETHERTYPE_IP);
if (!gwip.s_addr) {
if (arp((char *)&gwip,
(char *)A_A eh->ether_dhost) == -1) {
(char *) &eh->ether_dhost) == -1) {
perror("arp");
continue;
}
} else
bcopy(dhost, (char *)A_A eh->ether_dhost,
bcopy(dhost, (char *) &eh->ether_dhost,
sizeof(dhost));
if (!ip->ip_sum)
ip->ip_sum = chksum((u_short *)ip,
+1 -1
View File
@@ -355,7 +355,7 @@ block in proto tcp from any port >= 1024 to any port < 1024
pass in proto tcp from 10.1.0.0/24 to any port = 22
block out proto udp from any to 10.1.1.1 port = 135
pass in proto udp from 1.1.1.1 port = 123 to 10.1.1.1 port = 123
pass in proto tcp from 127.0.0.0/8 to any port = 6000:6009
pass in proto tcp from 127.0.0.0/8 to any port 6000:6009
.fi
.PP
If there is no desire to mention any specific source or destintion
+9
View File
@@ -158,6 +158,15 @@ display the statistics prior to them being zeroed.
Zero global statistics held in the kernel for filtering only (this doesn't
affect fragment or state statistics).
.DT
.SH ENVIRONMENT
.NM utilizes the following environment variable.
.TP
.B IPF_PREDEFINED
ipfilter variables, see VARIABLES in ipf(5), can be specified in this
environment variable providing shell access to ipfilter and ipnat variables.
For example,
.br
IPF_PREDEFINED='my_server="10.1.1.1"; my_client="10.1.1.2";'
.SH FILES
/dev/ipauth
.br
+1 -2
View File
@@ -69,8 +69,7 @@ the kernel) if any is present.
Show groups currently configured (both active and inactive).
.TP
.B \-h
Show per-rule the number of times each one scores a "hit". For use in
combination with \fB\-i\fP.
Show per-rule the number of times each one scores a "hit".
.TP
.B \-i
Display the filter list used for the input side of the kernel IP processing.
+12 -2
View File
@@ -7,6 +7,10 @@ ipmon \- monitors /dev/ipl for logged packets
[
.B \-abBDFhnpstvxX
] [
.B "\-B <binarylogfile>"
] [
.B "\-C <configfile>"
] [
.B "\-N <device>"
] [
.B "\-L <facility>"
@@ -27,7 +31,7 @@ ipmon \- monitors /dev/ipl for logged packets
.LP
\fBipmon\fP opens \fB/dev/ipl\fP for reading and awaits data to be saved from
the packet filter. The binary data read from the device is reprinted in
human readable for, however, IP#'s are not mapped back to hostnames, nor are
human readable form, however, IP#'s are not mapped back to hostnames, nor are
ports mapped back to service names. The output goes to standard output by
default or a filename, if given on the command line. Should the \fB\-s\fP
option be used, output is instead sent to \fBsyslogd(8)\fP. Messages sent
@@ -92,6 +96,10 @@ Enable logging of the raw, unformatted binary data to the specified
\fI<binarylogfilename>\fP file. This can be read, later, using \fBipmon\fP
with the \fB-f\fP option.
.TP
.B \-C <configfilename>
This option specifies a file to be used to specify optional extra actions
when it sees specific log entries from the kernel.
.TP
.B \-D
Cause ipmon to turn itself into a daemon. Using subshells or backgrounding
of ipmon is not required to turn it into an orphan so it can run indefinitely.
@@ -178,9 +186,11 @@ recorded data.
.br
/dev/ipstate
.br
/etc/ipmon.conf
.br
/etc/services
.SH SEE ALSO
ipl(4), ipf(8), ipfstat(8), ipnat(8)
ipl(4), ipmon(5), ipf(8), ipfstat(8), ipnat(8)
.SH BUGS
.PP
If you find any, please send email to me at [email protected]
+1 -1
View File
@@ -104,7 +104,7 @@ map le0 10.0.0.0/8 -> 192.168.55.0/24 portmap tcp/udp auto
In this instance, the word "auto" tells IPFilter to calculate a private
range of port numbers for each address on the LHS to use without fear
of them being trampled by others. This can lead to problems if there are
connections being generated mire quickly than IPFilter can expire them.
connections being generated more quickly than IPFilter can expire them.
In this instance, and if we want to get away from a private range of
port numbers, we can say:
.nf
+1 -1
View File
@@ -108,7 +108,7 @@ Sets the hashing seed to the number specified. Only for use with
type pools.
.TP
.B -t <type>
Sets the type of pool being defined. Myst be one of
Sets the type of pool being defined. Must be one of
.B tree,
.B hash,
.B group-map.
-683
View File
@@ -1,683 +0,0 @@
/* $FreeBSD$ */
/*
* Copyright (C) 2012 by Darren Reed.
* (C)opyright 1997 by Marc Boucher.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
*/
/* TODO: (MARCXXX)
- ipl_init failure -> open ENODEV or whatever
- prevent multiple LKM loads
- surround access to ifnet structures by IFNET_LOCK()/IFNET_UNLOCK() ?
- m != m1 problem
*/
#include <sys/types.h>
#include <sys/conf.h>
#ifdef IPFILTER_LKM
#include <sys/mload.h>
#endif
#include <sys/systm.h>
#include <sys/errno.h>
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
#ifdef IFF_DRVRLOCK /* IRIX6 */
#include <sys/hashing.h>
#include <netinet/in_var.h>
#endif
#include <sys/mbuf.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <netinet/tcpip.h>
#include <netinet/ip_icmp.h>
#include <netinet/ipfilter.h>
#include "ipl.h"
#include "ip_compat.h"
#include "ip_fil.h"
#include "ip_nat.h"
#ifndef MBUF_IS_CLUSTER
# define MBUF_IS_CLUSTER(m) ((m)->m_flags & MCL_CLUSTER)
#endif
#undef IPFDEBUG /* #define IPFDEBUG 9 */
#ifdef IPFILTER_LKM
u_int ipldevflag = D_MP;
char *iplmversion = M_VERSION;
#else
u_int ipfilterdevflag = D_MP;
char *ipfiltermversion = M_VERSION;
#endif
ipfmutex_t ipl_mutex, ipfi_mutex, ipf_rw, ipf_stinsert, ipf_auth_mx;
ipfmutex_t ipf_nat_new, ipf_natio, ipf_timeoutlock;
ipfrwlock_t ipf_frag, ipf_state, ipf_nat, ipf_natfrag, ipf_auth;
ipfrwlock_t ipf_global, ipf_mutex, ipf_ipidfrag, ipf_frcache, ipf_tokens;
int (*ipf_checkp) __P((struct ip *, int, void *, int, mb_t **));
#ifdef IPFILTER_LKM
static int *ipff_addr;
static int ipff_value;
static __psunsigned_t *ipfk_addr;
static __psunsigned_t ipfk_code[4];
#endif
static void nifattach();
static void nifdetach();
typedef struct nif {
struct nif *nf_next;
struct ifnet *nf_ifp;
#if (IRIX < 60500)
int (*nf_output)(struct ifnet *, struct mbuf *, struct sockaddr *);
#else
int (*nf_output)(struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *);
#endif
char nf_name[LIFNAMSIZ];
int nf_unit;
} nif_t;
static nif_t *nif_head;
static int nif_interfaces = 0;
extern int in_interfaces;
#if IRIX >= 60500
toid_t ipf_timer_id;
#endif
extern ipnat_t *nat_list;
#ifdef IPFDEBUG
static void ipf_dumppacket(m)
struct mbuf *m;
{
u_char *s;
char *t, line[80];
int len, off, i;
off = 0;
while (m != NULL) {
len = M_LEN(m);
s = mtod(m, u_char *);
printf("mbuf 0x%lx len %d flags %x type %d\n",
m, len, m->m_flags, m->m_type);
printf("dat 0x%lx off 0x%lx/%d s 0x%lx next 0x%lx\n",
m->m_dat, m->m_off, m->m_off, s, m->m_next);
while (len > 0) {
t = line;
for (i = 0; (i < 16) && (len > 0); len--, i++)
sprintf(t, " %02x", *s++), t += strlen(t);
*s = '\0';
printf("mbuf:%x:%s\n", off, line);
off += 16;
}
m = m->m_next;
}
}
#endif
static int
#if IRIX < 60500
ipl_if_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst)
#else
ipl_if_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
struct rtentry *rt)
#endif
{
#if (IPFDEBUG >= 0)
static unsigned int cnt = 0;
#endif
nif_t *nif;
MUTEX_ENTER(&ipfi_mutex); /* sets interrupt priority level to splhi */
for (nif = nif_head; nif; nif = nif->nf_next)
if (nif->nf_ifp == ifp)
break;
MUTEX_EXIT(&ipfi_mutex);
if (nif == NULL) {
printf("IP Filter: ipl_if_output intf %x NOT FOUND\n", ifp);
return ENETDOWN;
}
#if (IPFDEBUG >= 7)
if ((++cnt % 200) == 0)
printf("IP Filter: ipl_if_output(ifp=0x%lx, m=0x%lx, dst=0x%lx), m_type=%d m_flags=0x%lx m_off=0x%lx\n", ifp, m, dst, m->m_type, (u_long)m->m_flags, m->m_off);
#endif
if (ipf_checkp) {
struct mbuf *m1 = m;
struct ip *ip;
int hlen;
switch(m->m_type)
{
case MT_HEADER:
if (m->m_len == 0) {
if (m->m_next == NULL)
break;
m = m->m_next;
}
/* FALLTHROUGH */
case MT_DATA:
if (!MBUF_IS_CLUSTER(m) &&
((m->m_off < MMINOFF) || (m->m_off > MMAXOFF))) {
#if (IPFDEBUG >= 4)
printf("IP Filter: ipl_if_output: bad m_off m_type=%d m_flags=0x%lx m_off=0x%lx\n", m->m_type, (u_long)m->m_flags, m->m_off);
#endif
break;
}
if (m->m_len < sizeof(char)) {
#if (IPFDEBUG >= 3)
printf("IP Filter: ipl_if_output: mbuf block too small (m_len=%d) for IP vers+hlen, m_type=%d m_flags=0x%lx\n", m->m_len, m->m_type, (u_long)m->m_flags);
#endif
break;
}
ip = mtod(m, struct ip *);
if (ip->ip_v != IPVERSION) {
#if (IPFDEBUG >= 2)
ipf_dumppacket(m);
printf("IP Filter: ipl_if_output: bad ip_v m_type=%d m_flags=0x%lx m_off=0x%lx\n", m->m_type, (u_long)m->m_flags, m->m_off);
#endif
break;
}
hlen = ip->ip_hl << 2;
if ((*ipf_checkp)(ip, hlen, ifp, 1, &m1) || (m1 == NULL))
return EHOSTUNREACH;
m = m1;
break;
default:
#if (IPFDEBUG >= 2)
printf("IP Filter: ipl_if_output: bad m_type=%d m_flags=0x%lxm_off=0x%lx\n", m->m_type, (u_long)m->m_flags, m->m_off);
#endif
break;
}
}
#if (IRIX < 60500)
return (*nif->nf_output)(ifp, m, dst);
#else
return (*nif->nf_output)(ifp, m, dst, rt);
#endif
}
int
#if !defined(IPFILTER_LKM) && (IRIX >= 60500)
ipfilter_kernel(struct ifnet *rcvif, struct mbuf *m)
#else
ipl_kernel(struct ifnet *rcvif, struct mbuf *m)
#endif
{
#if (IPFDEBUG >= 7)
static unsigned int cnt = 0;
if ((++cnt % 200) == 0)
printf("IP Filter: ipl_kernel(rcvif=0x%lx, m=0x%lx\n",
rcvif, m);
#endif
if (ipf_running <= 0)
return IPF_ACCEPTIT;
/*
* Check if we want to allow this packet to be processed.
* Consider it to be bad if not.
*/
if (ipf_checkp) {
struct mbuf *m1 = m;
struct ip *ip;
int hlen;
if ((m->m_type != MT_DATA) && (m->m_type != MT_HEADER)) {
#if (IPFDEBUG >= 4)
printf("IP Filter: ipl_kernel: bad m_type=%d m_flags=0x%lx m_off=0x%lx\n", m->m_type, (u_long)m->m_flags, m->m_off);
#endif
return IPF_ACCEPTIT;
}
if (!MBUF_IS_CLUSTER(m) &&
((m->m_off < MMINOFF) || (m->m_off > MMAXOFF))) {
#if (IPFDEBUG >= 4)
printf("IP Filter: ipl_kernel: bad m_off m_type=%d m_flags=0x%lx m_off=0x%lx\n", m->m_type, (u_long)m->m_flags, m->m_off);
#endif
return IPF_ACCEPTIT;
}
if (m->m_len < sizeof(char)) {
#if (IPFDEBUG >= 1)
printf("IP Filter: ipl_kernel: mbuf block too small (m_len=%d) for IP vers+hlen, m_type=%d m_flags=0x%lx\n", m->m_len, m->m_type, (u_long)m->m_flags);
#endif
return IPF_ACCEPTIT;
}
ip = mtod(m, struct ip *);
if (ip->ip_v != IPVERSION) {
#if (IPFDEBUG >= 4)
printf("IP Filter: ipl_kernel: bad ip_v\n");
#endif
m_freem(m);
return IPF_DROPIT;
}
ip->ip_len = htons(ip->ip_len);
ip->ip_off = htons(ip->ip_off);
hlen = ip->ip_hl << 2;
if ((*ipf_checkp)(ip, hlen, rcvif, 0, &m1) || !m1)
return IPF_DROPIT;
ip = mtod(m1, struct ip *);
ip->ip_len = ntohs(ip->ip_len);
ip->ip_off = ntohs(ip->ip_off);
#if (IPFDEBUG >= 2)
if (m != m1)
printf("IP Filter: ipl_kernel: m != m1\n");
#endif
}
return IPF_ACCEPTIT;
}
int
ipl_ipfilter_attach(void)
{
#if defined(IPFILTER_LKM)
__psunsigned_t *addr_ff, *addr_fk;
st_findaddr("ipfilterflag", &addr_ff);
# if (IPFDEBUG >= 1)
printf("IP Filter: st_findaddr ipfilterflag=0x%lx\n", addr_ff);
# endif
if (!addr_ff)
return ESRCH;
st_findaddr("ipfilter_kernel", &addr_fk);
# if (IPFDEBUG >= 1)
printf("IP Filter: st_findaddr ipfilter_kernel=0x%lx\n", addr_fk);
# endif
if (!addr_fk)
return ESRCH;
MUTEX_ENTER(&ipfi_mutex); /* sets interrupt priority level to splhi */
ipff_addr = (int *)addr_ff;
ipff_value = *ipff_addr;
*ipff_addr = 0;
ipfk_addr = addr_fk;
bcopy(ipfk_addr, ipfk_code, sizeof(ipfk_code));
/* write a "li t4, ipl_kernel" instruction */
ipfk_addr[0] = 0x3c0c0000 |
(((__psunsigned_t)ipl_kernel >> 16) & 0xffff);
ipfk_addr[1] = 0x358c0000 |
((__psunsigned_t)ipl_kernel & 0xffff);
/* write a "jr t4" instruction" */
ipfk_addr[2] = 0x01800008;
/* write a "nop" instruction */
ipfk_addr[3] = 0;
icache_inval(ipfk_addr, sizeof(ipfk_code));
*ipff_addr = 1; /* enable ipfilter_kernel */
MUTEX_EXIT(&ipfi_mutex);
#else
extern int ipfilterflag;
ipfilterflag = 1;
#endif
nif_interfaces = 0;
nifattach();
return 0;
}
/*
* attach the packet filter to each non-loopback interface that is running
*/
static void
nifattach()
{
nif_t *nif, *qf2;
struct ifnet *ifp;
struct frentry *f;
ipnat_t *np;
MUTEX_ENTER(&ipfi_mutex); /* sets interrupt priority level to splhi */
for (ifp = ifnet; ifp; ifp = ifp->if_next) {
if ((!(ifp->if_flags & IFF_RUNNING)) ||
(ifp->if_flags & IFF_LOOPBACK))
continue;
/*
* Look for entry already setup for this device
*/
for (nif = nif_head; nif; nif = nif->nf_next)
if (nif->nf_ifp == ifp)
break;
if (nif)
continue;
if (ifp->if_output == ipl_if_output) {
printf("IP Filter: ERROR INTF 0x%lx STILL ATTACHED\n",
ifp);
continue;
}
#if (IPFDEBUG >= 2)
printf("IP Filter: nifattach nif %x opt %x\n",
ifp, ifp->if_output);
#endif
KMALLOC(nif, nif_t *);
if (!nif) {
printf("IP Filter: malloc(%d) for nif_t failed\n",
sizeof(nif_t));
continue;
}
nif->nf_ifp = ifp;
(void) strncpy(nif->nf_name, ifp->if_name,
sizeof(nif->nf_name));
nif->nf_name[sizeof(nif->nf_name) - 1] = '\0';
nif->nf_unit = ifp->if_unit;
nif->nf_next = nif_head;
nif_head = nif;
/*
* Activate any rules directly associated with this interface
*/
WRITE_ENTER(&ipf_mutex);
for (f = ipf_rules[0][0]; f; f = f->fr_next) {
if ((f->fr_ifa == (struct ifnet *)-1)) {
if (f->fr_ifname[0] &&
(GETIFP(f->fr_ifname, 4) == ifp))
f->fr_ifa = ifp;
}
}
for (f = ipf_rules[1][0]; f; f = f->fr_next) {
if ((f->fr_ifa == (struct ifnet *)-1)) {
if (f->fr_ifname[0] &&
(GETIFP(f->fr_ifname, 4) == ifp))
f->fr_ifa = ifp;
}
}
RWLOCK_EXIT(&ipf_mutex);
WRITE_ENTER(&ipf_nat);
for (np = nat_list; np; np = np->in_next) {
if ((np->in_ifps[0] == (void *)-1)) {
if (np->in_ifnames[0][0] &&
(GETIFP(np->in_ifnames[0], 4) == ifp))
np->in_ifps[0] = (void *)ifp;
}
if ((np->in_ifps[1] == (void *)-1)) {
if (np->in_ifnames[1][0] &&
(GETIFP(np->in_ifnames[1], 4) == ifp))
np->in_ifps[1] = (void *)ifp;
}
}
RWLOCK_EXIT(&ipf_nat);
nif->nf_output = ifp->if_output;
ifp->if_output = ipl_if_output;
#if (IPFDEBUG >= 2)
printf("IP Filter: nifattach: ifp(%lx)->if_output FROM %lx TO %lx\n",
ifp, nif->nf_output, ifp->if_output);
#endif
printf("IP Filter: attach to [%s,%d]\n",
nif->nf_name, ifp->if_unit);
}
if (!nif_head)
printf("IP Filter: not attached to any interfaces\n");
nif_interfaces = in_interfaces;
MUTEX_EXIT(&ipfi_mutex);
return;
}
/*
* unhook the IP filter from all defined interfaces with IP addresses
*/
static void
nifdetach()
{
nif_t *nif, *qf2, **qp;
struct ifnet *ifp;
MUTEX_ENTER(&ipfi_mutex); /* sets interrupt priority level to splhi */
/*
* Make two passes, first get rid of all the unknown devices, next
* unlink known devices.
*/
for (qp = &nif_head; (nif = *qp); ) {
for (ifp = ifnet; ifp; ifp = ifp->if_next)
if (nif->nf_ifp == ifp)
break;
if (ifp) {
qp = &nif->nf_next;
continue;
}
printf("IP Filter: removing [%s]\n", nif->nf_name);
*qp = nif->nf_next;
KFREE(nif);
}
while ((nif = nif_head)) {
nif_head = nif->nf_next;
for (ifp = ifnet; ifp; ifp = ifp->if_next)
if (nif->nf_ifp == ifp)
break;
if (ifp) {
printf("IP Filter: detaching [%s,%d]\n",
nif->nf_name, ifp->if_unit);
#if (IPFDEBUG >= 4)
printf("IP Filter: nifdetach: ifp(%lx)->if_output FROM %lx TO %lx\n",
ifp, ifp->if_output, nif->nf_output);
#endif
ifp->if_output = nif->nf_output;
}
KFREE(nif);
}
MUTEX_EXIT(&ipfi_mutex);
return;
}
void
ipl_ipfilter_detach(void)
{
#ifdef IPFILTER_LKM
nifdetach();
MUTEX_ENTER(&ipfi_mutex); /* sets interrupt priority level to splhi */
if (ipff_addr) {
*ipff_addr = 0;
if (ipfk_addr) {
bcopy(ipfk_code, ipfk_addr, sizeof(ipfk_code));
icache_inval(ipfk_addr - 16, sizeof(ipfk_code)+32);
}
*ipff_addr = ipff_value;
}
MUTEX_EXIT(&ipfi_mutex);
#else
extern int ipfilterflag;
nifdetach();
ipfilterflag = 0;
#endif
}
/* this function is called from ipf_slowtimer at 500ms intervals to
keep our interface list in sync */
void
ipl_ipfilter_intfsync(void)
{
MUTEX_ENTER(&ipfi_mutex);
if (nif_interfaces != in_interfaces) {
/* if the number of interfaces has changed, resync */
MUTEX_EXIT(&ipfi_mutex);
ipf_sync(&ipfmain, NULL);
} else
MUTEX_EXIT(&ipfi_mutex);
}
#ifdef IPFILTER_LKM
/* this routine should be treated as an interrupt routine and should
not call any routines that would cause it to sleep, such as: biowait(),
sleep(), psema() or delay().
*/
int
iplunload(void)
{
int error = 0;
if (ipf_refcnt)
return EBUSY;
WRITE_ENTER(&ipf_global);
error = ipl_detach();
if (error != 0) {
RWLOCK_EXIT(&ipf_global);
return error;
}
ipf_running = -2;
#if (IRIX < 60500)
LOCK_DEALLOC(ipl_mutex.l);
LOCK_DEALLOC(ipf_rw.l);
LOCK_DEALLOC(ipf_auth.l);
LOCK_DEALLOC(ipf_natfrag.l);
LOCK_DEALLOC(ipf_ipidfrag.l);
LOCK_DEALLOC(ipf_tokens.l);
LOCK_DEALLOC(ipf_stinsert.l);
LOCK_DEALLOC(ipf_nat_new.l);
LOCK_DEALLOC(ipf_natio.l);
LOCK_DEALLOC(ipf_nat.l);
LOCK_DEALLOC(ipf_state.l);
LOCK_DEALLOC(ipf_frag.l);
LOCK_DEALLOC(ipf_auth_mx.l);
LOCK_DEALLOC(ipf_mutex.l);
LOCK_DEALLOC(ipf_frcache.l);
LOCK_DEALLOC(ipfi_mutex.l);
RWLOCK_EXIT(&ipf_global);
LOCK_DEALLOC(ipf_global.l);
#else
MUTEX_DESTROY(&ipf_rw);
MUTEX_DESTROY(&ipfi_mutex);
MUTEX_DESTROY(&ipf_timeoutlock);
RW_DESTROY(&ipf_mutex);
RW_DESTROY(&ipf_frcache);
RW_DESTROY(&ipf_tokens);
RWLOCK_EXIT(&ipf_global);
delay(hz);
RW_DESTROY(&ipf_global);
#endif
printf("%s unloaded\n", ipfilter_version);
delay(hz);
return 0;
}
#endif
void
ipfilterinit(void)
{
#ifdef IPFILTER_LKM
int error;
#endif
#if (IRIX < 60500)
ipfi_mutex.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_mutex.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_frcache.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_timeoutlock.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_global.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_frag.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_state.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_nat.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_stinsert.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_natfrag.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_ipidfrag.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_tokens.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_auth.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipf_rw.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
ipl_mutex.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP);
if (!ipfi_mutex.l || !ipf_mutex.l || !ipf_timeoutlock.l ||
!ipf_frag.l || !ipf_state.l || !ipf_nat.l || !ipf_natfrag.l ||
!ipf_auth.l || !ipf_rw.l || !ipf_ipidfrag.l || !ipl_mutex.l ||
!ipf_stinsert.l || !ipf_auth_mx.l || !ipf_frcache.l ||
!ipf_tokens.l)
panic("IP Filter: LOCK_ALLOC failed");
#else
MUTEX_INIT(&ipf_rw, "ipf rw mutex");
MUTEX_INIT(&ipf_timeoutlock, "ipf timeout mutex");
RWLOCK_INIT(&ipf_global, "ipf filter load/unload mutex");
RWLOCK_INIT(&ipf_mutex, "ipf filter rwlock");
RWLOCK_INIT(&ipf_frcache, "ipf cache rwlock");
#endif
#ifdef IPFILTER_LKM
error = ipl_attach();
if (error) {
iplunload();
} else {
char *defpass;
if (FR_ISPASS(ipf_pass))
defpass = "pass";
else if (FR_ISBLOCK(ipf_pass))
defpass = "block";
else
defpass = "no-match -> block";
printf("%s initialized. Default = %s all, Logging = %s%s\n",
ipfilter_version, defpass,
# ifdef IPFILTER_LOG
"enabled",
# else
"disabled",
# endif
# ifdef IPFILTER_COMPILED
" (COMPILED)"
# else
""
# endif
);
}
#endif
return;
}
Loaded 100 of 1819 files, more files were not shown because too many files have changed in this diff. Show more