FreeBSD/src 328324vendor/libarchive/dist/cat/test test_stdin.c, vendor/libarchive/dist/libarchive/test test_compat_zip_8.zip.uu

vendor/libarchive/dist: Add new files missing in r328323

FreeBSD/src 328323vendor/libarchive/dist CMakeLists.txt, vendor/libarchive/dist/libarchive archive_read_support_format_rar.c archive_read_support_format_7zip.c

Update libarchive to git 2d9156bb3ad92c43c1e81546f4a2c21549ba248f

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

FreeBSD/src 328322stable 11, stable/11/sys/amd64/amd64 sys_machdep.c

MFC r328082:
Amd64 user_ldt_deref() is not used outside sys_machdep.c.  Mark it as
static.

FreeBSD/src 328321head/sys/net ieee8023ad_lacp.c

Added missing CTLFLAG_VNET to lacp default_strict_mode

Added CTLFLAG_VNET to net.link.lagg.lacp.default_strict_mode which was missed
in r290450.

Reported by:    julian@
MFC after:      1 week
Sponsored by:   Multiplay

FreeBSD/src 328320head/sys/kern sched_ule.c

ULE: provide defaults to ts_cpu

Fix a bug when the system has no CPU 0. When created, threads were implicitly assigned to 
CPU 0.
This had no practical effect since a real CPU was chosen immediately by the scheduler. 
However,
on systems without a CPU 0, sched_ule attempted to access the scheduler queue of the "old" 
CPU
when assigned the initial choice of the old one. This caused an attempt to use illegal 
memory
and a crash (or, more usually, a deadlock). Fix this by assigned new threads to the BSP
explicitly and add some asserts to see that this problem does not recur.

Authored by:           Nathan Whitehorn <nwhitehorn at freebsd.org>
Submitted by:          Wojciech Macek <wma at semihalf.com>
Obtained from:         Semihalf
Differential revision: https://reviews.freebsd.org/D13932

FreeBSD/src 328319head/usr.bin/m4 extern.h

m4: add annotations to various functions

Explain to the compiler that several functions are either noreturn or
take printf like arguments

Discussed with: swildner at DragonFlyBSD.org

FreeBSD/src 328318head/contrib/tzdata NEWS europe

Import tzdata 2018c

Changes: https://github.com/eggert/tz/blob/2018c/NEWS

MFC after:      3 days

FreeBSD/src 328317vendor/tzdata tzdata2018c

Tag import of tzdata 2018c

FreeBSD/src 328316vendor/tzdata/dist NEWS europe

Import tzdata 2018c

FreeBSD/src 328315head/sys/dev/cxgb cxgb_main.c

cxgb(4): Validate offset/len in the GET_EEPROM ioctl.

Reported by:    Ilja Van Sprundel <ivansprundel at ioactive.com>

FreeBSD/src 328314head/sys/netinet ip_reass.c, head/sys/netinet6 frag6.c

Do not generate illegal mbuf chains during IP fragment reassembly.  Only
the first mbuf of the reassembled datagram should have a pkthdr.

This was discovered with cxgbe(4) + IPSEC + ping with payload more than
interface MTU.  cxgbe can generate !M_WRITEABLE mbufs and this results
in m_unshare being called on the reassembled datagram, and it complains:

panic: m_unshare: m0 0xfffff80020f82600, m 0xfffff8005d054100 has M_PKTHDR

PR:            224922
Reviewed by:    ae@
MFC after:      1 week
Sponsored by:   Chelsio Communications
Differential Revision:  https://reviews.freebsd.org/D14009

FreeBSD/src 328313head/sys/netpfil/pf pf.c

pf: States have at least two references

pf_unlink_state() releases a reference to the state without checking if
this is the last reference. It can't be, because pf_state_insert()
initialises it to two. KASSERT() that this is always the case.

CID:    1347140

FreeBSD/src 328312head/sys/dev/iicbus nxprtc.c

Follow changes in r328307 by using new IIC_RECURSIVE flag.

The driver now ensures only one thread at a time is running in the API
functions (clock_gettime() and clock_settime()) by specifically requesting
ownership of the i2c bus without using IIC_RECURSIVE, then it does all IO
using IIC_RECURSIVE so that each individual IO operation doesn't try to
re-acquire the bus.

The other IO done by the driver happens at attach or intr_config_hooks time,
when there can't be multiple threads running with the same device instance.
So, the IIC_RECURSIVE flag can be safely ORed into the wait flags for all IO
done by the driver, because it's all either done in a single-threaded
environment, or protected within a block bounded by explict
iicbus_acquire_bus() and iicbus_release_bus() calls.

FreeBSD/src 328311head/sys/dev/iicbus isl12xx.c

Follow changes in r328307 by using new IIC_RECURSIVE flag.

The driver now ensures only one thread at a time is running in the API
functions (clock_gettime() and clock_settime()) by specifically requesting
ownership of the i2c bus without using IIC_RECURSIVE, then it does all IO
using IIC_RECURSIVE so that each individual IO operation doesn't try to
re-acquire the bus.

The other IO done by the driver happens at attach or intr_config_hooks time,
when there can't be multiple threads running with the same device instance.
So, the IIC_RECURSIVE flag can be safely ORed into the wait flags for all IO
done by the driver, because it's all either done in a single-threaded
environment, or protected within a block bounded by explict
iicbus_acquire_bus() and iicbus_release_bus() calls.

FreeBSD/src 328310stable 11, stable/11/usr.bin/clang/lld ld.lld.1 Makefile

MFC r327770: lld: introduce basic man page

Upstream lld has no man page. Introduce a basic one for FreeBSD based on
ld.lld --help, with a brief introduction and additional detail for some
options.

We'll continue refining this in FreeBSD, and then submit it upstream once
the first round of edits are complete.

Submitted by:   krion, Arshan Khanifar, emaste, bjk
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 328309stable 10 11, stable/10/tests/sys/kern ptrace_test.c

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.

FreeBSD/src 328308stable 11, stable/11/sys/sys cdefs.h

MFC r328221:

Define a new __alloc_size2 attribute to complement the existing support.

At least on GCC7, calling __alloc_size(x) twice is not equivalent to
calling using the attribute once with two arguments. The later is the
documented use in GCC documentation so add a new alloc_size(n, x)
alternative to cover for the few places where it is used: basically:
calloc(3), reallocarray(3) and  mallocarray(9).

Submitted by:   Mark Millard

FreeBSD/src 328307head/sys/dev/iicbus iiconf.c iiconf.h

Fix a bug introduced with recursive bus ownership support in r321584.

The recursive ownership support added in r321584 was unconditionally in
effect all the time -- whenever a given i2c slave device instance tried to
lock the i2c bus for exclusive use when it already owned the bus, the call
returned immediately without waiting.  However, many i2c slave drivers use
bus ownership to enforce that only a single thread at a time can be using
the slave device.  The recursive locking changes broke this use case.

Now there is a new flag, IIC_RECURSIVE, which can be mixed in with the
other flags passed to iicbus_acquire_bus() to allow drivers to indicate
when recursive locking is desired.  Using the flag implies that the driver
is managing concurrent access to the device by different threads in some way.

This immediately fixes all existing i2c slave drivers except for the two
i2c RTC drivers which use the recursive locking feature; those will be
fixed in a followup commit.

FreeBSD/src 328306head/bin/ps ps.1 keyword.c

Remove some KSE references from ps(1).

- Simplify the description of -H to assume 1:1 threading.
- Drop 'process' from description of 'lwp' field and the corresponding
  XO field name.
- Do add an expansion of LWP in the description of 'lwp' and 'nlwps'.
- Add 'tid' as an alias for the 'lwp' field.

Reviewed by:    imp, kib (older version)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D14021

FreeBSD/src 328305head/lib/libcxxrt Version.map

libcxxrt: Move mangled symbols out of extern "C++" in Version.map

r260553 added a number of mangled C++ symbols to Version.map inside of
an existing `extern "C++"` block.

ld.bfd 2.17.50 treats `extern "C++"` permissively and will match both
mangled and demangled symbols against the strings in the version map
block.  ld.lld interprets `extern "C++"` strictly, and matches only
demangled symbols.

I believe lld's behaviour is correct.  Contemporary versions of ld.bfd
also behave as lld does, so move the mangled symbols out of the
`extern "C++"` block.

PR:            225128, 185663
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 328304head/lib/libc/gen getgrent.c, head/lib/libc/sys setgroups.2

In the C library, the setting up of the group array by various
utilities is done by calling gr_addgid() for each group to be
added (usually found by traversing /etc/group) then calling the
setgroups() system call after the group set has been created.
The gr_addgid() function (helpfully?) deduplicates the addition
of group members. So, if you call it to add a group member that
already exists, it is just dropped. Because group[0] is the
effective group-ID and is over-written when a setgid program
is run, The value in group[0] is usually duplicated so that
group value is not lost when a setgid program is run.

Historically this happened because the group value indicated
in the password file also appears in /etc/group (e.g., if you
are group staff in the password file, you will also appear in
the staff line in /etc/group). But, with the addition of the
deduplication, the attempt to add group staff was lost because
it already appeared in group[0]. So, the fix is to deduplicate
starting from group[1] which allows a duplicate of the entry in
group[0], but not in later entries.

There is some confusion about the setgroups system call because in
BSD it has (always) set the entire group including the egid group
(in group[0]). However, in Linux, it skips over group[0] and starts
setting from group[1]. See this comment from linux_setgroups:


    [21 lines not shown]

FreeBSD/src 328303head/sys/dev/iicbus nxprtc.c

Switch to using the bcd_clocktime conversion functions that validate the BCD
data without panicking, and have common code for handling AM/PM mode.

FreeBSD/src 328302head/sys/dev/iicbus ds1307.c

Switch to using the bcd_clocktime conversion functions that validate the BCD
data without panicking, and have common code for handling AM/PM mode.

FreeBSD/src 328301head/sys/dev/iicbus ds13rtc.c

Switch to using the bcd_clocktime conversion functinos that validate the BCD
data without panicking, and have common code for handling AM/PM mode.

FreeBSD/src 328300head/sys/sys copyright.h

copyright.h: Update license text to 'THE AUTHOR'

This matches the license text at
https://www.freebsd.org/copyright/freebsd-license.html

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 328299head/sys/amd64/linux linux_support.s, head/sys/amd64/linux32 linux32_support.s

Use BSD-2-Clause-FreeBSD license on linux_support.s

These files previously had a 3-clause license and 'THE REGENTS' text.
Switch to standard 2-clause text with kib's approval, and add the SPDX
tag.

Approved by:    kib

FreeBSD/src 328298stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs zfs_vnops.c, stable/11/sys/fs/devfs devfs_vnops.c

MFC 320900,323882,324224,324226,324228,326986,326988,326989,326990,326993,
326994,326995,327004: Various fixes for pathconf(2).

The original change to use vop_stdpathconf() more widely was motivated
by a panic due to recent AIO-related changes.  However, bde@ reported
that vop_stdpathconf() contained too many settings that were not
filesystem-independent.  The end result of this set of patches is to
fix the AIO-related panic via use of a trimmed-down vop_stdpathconf()
while also adding support for missing pathconf variables in various
filesystems (and removing a few settings incorrectly reported as
supported).

320900:
Consistently use vop_stdpathconf() for default pathconf values.

Update filesystems not currently using vop_stdpathconf() in pathconf
VOPs to use vop_stdpathconf() for any configuration variables that do
not have filesystem-specific values.  vop_stdpathconf() is used for
variables that have system-wide settings as well as providing default
values for some values based on system limits.  Filesystems can still
explicitly override individual settings.

323882:
Only handle _PC_MAX_CANON, _PC_MAX_INPUT, and _PC_VDISABLE for TTY devices.


    [87 lines not shown]

FreeBSD/src 328297head/usr.bin/procstat procstat.1

Don't escape '?'s in protocol output.

This isn't required by mandoc and is nonfunctional in groff.

PR:            224632
Reported by:    w.schwarzenfeld at utanet.at
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D13779

FreeBSD/src 328296head/sys/netinet6 scope6.c in6.c

sys/netinet6: fix typos in comments.  No functional change.

MFC after:      3 weeks
Sponsored by:   Spectra Logic Corp

FreeBSD/src 328295stable 11, stable/11/sys/fs/tmpfs tmpfs_vnops.c tmpfs_fifoops.c

MFC 323993: Use tmpfs_print for tmpfs FIFOs.

FreeBSD/src 328294stable 10 11, stable/10/sys/sys aio.h shm.h

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

FreeBSD/src 328293head/stand/fdt fdt_loader_cmd.c

stand/fdt: Fallback to `name` + ".dtbo" if we fail to load `name`

This behavior also matches a Linux-ism by allowing fdt_overlays to specify
names of overlays without an extension, e.g. fdt-overlays="sunxi-h3-h5-emac"

If we fail to load the file given by a name in fdt_overlays, try again with
".dtbo" appended to it. This still allows overlays to lack .dtbo extension
if user prefers it and just adds a fallback cushion.

Future work could move this from a hard-coded ".dtbo" to a loader.conf(5)
configuration option.

Reviewed by:    gonzo
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D13968

FreeBSD/src 328292head/stand/common misc.c

There's no tainted data here, tag it as such to avoid the slew of
false positives. The files the boot loader reads are assumed to be
good.

CID: 1006663,1006665,1265013, 1265014 (possibly more)
Sponsored by: Netflix

FreeBSD/src 328291head/stand/libsa environment.c

getenv does not return tainted data in the boot loader. Attempt to
clue Coverity into that fact.

Sponsored by: Netflix

FreeBSD/src 328290head/stand/common interp.c

On malloc failure, be sure to close the include file that triggered
it.

CID: 1007775
Sponsored by: Netflix

FreeBSD/src 328289head/stand/common commands.c

Don't leak memory when displaying help.

Right now, we'll leak memory when we display a help topic because we
don't free t, s, d that we've just used when breaking out of the loop.
NB: coverity just reported t, but s and d also leak.

CID: 1007776

FreeBSD/src 328288head/stand/common boot.c

Fix some resource leaks.

Always free dev and fstyp before strduping new values to assign to
them. Free them at the end of the loop. This keeps them from leaking
for mal-formed /etc/fstab lines.

CID: 1007777, 1007778, 1007779
Sponsored by: Netflix

FreeBSD/src 328287head/etc Makefile, head/etc/mtree BSD.root.dist

Add /boot/overlays to runtime pkg, fix distrib-dirs METALOG generation

/boot/overlays was recently added without belonging to a package. It's only
used by bootloaders at the moment, so add it to the 'runtime' package to get
added with ubldr and friends.

Fix distrib-dirs METALOG generation while we're here. History elsewhere
seems to indicate that bapt@ fixed this to pull in all attributes from
mtrees while generating the METALOG. This fix got clobbered somewhere later,
so restore it.

Reviewed by:    bapt, gjb
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D13996

FreeBSD/src 328286head/contrib/llvm/tools/lld/ELF SymbolTable.cpp

lld: Don't mark a shared library as needed because of a lazy symbol.

Obtained from:  LLVM r323221 by Rafael EspĂ­ndola

FreeBSD/src 328285user/gjb/thermite thermite.sh

Sync with the RE version:
- Minor change to sanitize the path to _srcdir in stdout.
- Bump copyright year.

Sponsored by:   The FreeBSD Foundation

FreeBSD/src 328284head/release release.sh

Bump Copyright year following r328283.

MFC after:      3 days
MFC with:       r328283
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 328283head/release release.sh

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.

Requested by:   swills
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation

FreeBSD/src 328282head/bin/date date.c

Fill in ut_id. While it's not relevant to the {OLD,NEW}_TIME entries,
we shouldn't leak stack garbage into the field.

Sponsored by: Netflix

FreeBSD/src 328281head/usr.bin/sockstat sockstat.c

sockstat: add break that was forgot in 328279

Reported by:    garga@
MFC after:      1 week
X-MFC With:     328279
Sponsored by:   Gandi.net

FreeBSD/src 328280head/sys/fs/ext2fs ext2_extents.c ext2_lookup.c

extfs: Remove unused variables.

Found by:       scan-build
Reviewed by:    fsu
Differential Revision:  https://reviews.freebsd.org/D14017

FreeBSD/src 328279head/usr.bin/sockstat sockstat.c sockstat.1

sockstat: Add -q option to suppress the header line

MFC after:      1 week
Sponsored by:   Gandi.net

FreeBSD/src 328278head/sys/powerpc/powernv opal_pci.c

PowerNV: send MSI_EOI always after MSI unmask

MSI/MSI-x interrupts are edge-triggered. If an interrupt
arrives when IRQ line is masked, it will be lost and will
never recover. Perform MSI_EOI always after unmask to give
a chance for PHB/XICS to send an interrupt again if MSI/MSI-x
pending bit is set in MSI/MSI-x BAR space.

Submitted by:          Wojciech Macek <wma at semihalf.org>
Obtained from:         Semihalf
Sponsored by:          IBM, QCM Technologies

FreeBSD/src 328277stable 10, stable/10/sys/netpfil/pf pf_ioctl.c

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 <ivansprundel at ioactive.com>

FreeBSD/src 328276stable 10, stable/10/share/man/man9 malloc.9

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

FreeBSD/src 328275stable 11, stable/11/sys/netpfil/pf pf_ioctl.c

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 <ivansprundel at ioactive.com>