Commit Graph

196518 Commits

Author SHA1 Message Date
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 <nicholas@nicholaswilson.me.uk>
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:	Mark.Martinec@ijs.si
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 <rsitze@gmail.com>
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 <ludovic.rousseau+freebsd@gmail.com>
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 <ludovic.rousseau+freebsd@gmail.com>
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:	yuripv@yuripv.net
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