Commit Graph

196840 Commits

Author SHA1 Message Date
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 <shoesoft@gmx.net>
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 <longwitz@incore.de>
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:		raul.munoz@custos.es
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:	joeb1@a1poweruser.com
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 <marc@bumblingdork.com>
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 <marc@bumblingdork.com>
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 <Shichun.Ma@dell.com>
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 <Shichun.Ma@dell.com>
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 <Shichun.Ma@dell.com>
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 <Shichun.Ma@dell.com>
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 <Shichun.Ma@dell.com>
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 <Shichun.Ma@dell.com>
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