HardenedBSD/hardenedbsd a906febsys/vm vm_unix.c

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+0-5sys/vm/vm_unix.c
+0-51 files

HardenedBSD/hardenedbsd 887d9e4lib/libcasper/services/cap_sysctl cap_sysctl.c cap_sysctl.3, lib/libcasper/services/cap_sysctl/tests sysctl_test.c

Merge remote-tracking branch 'origin/freebsd/current/master' into hardened/current/master

Conflicts:
        sys/vm/vm_unix.c (unresolved)

HardenedBSD/hardenedbsd 6357299sys/amd64/linux32 Makefile, sys/compat/freebsd32 capabilities.conf

Merge remote-tracking branch 'origin/freebsd/12-stable/master' into 
hardened/12-stable/master

Conflicts:
        sys/i386/ibcs2/ibcs2_proto.h (deleted)
        sys/i386/ibcs2/ibcs2_syscall.h (deleted)
        sys/i386/ibcs2/ibcs2_sysent.c (deleted)

HardenedBSD/hardenedbsd 8c0df04share/man/man5 src.conf.5, share/mk src.opts.mk

Merge branch 'freebsd/current/master' into hardened/current/master

* freebsd/current/master:
  src.conf(5): regenerate after r352465, r352466
  Add description for WITH_GOOGLETEST
  googletest: default-disable on all of MIPS for now
  mips: ubldr: use truncated load address for mips32

HardenedBSD/hardenedbsd 062772fshare/man/man5 src.conf.5

src.conf(5): regenerate after r352465, r352466

These changed the defaults for the GOOGLETEST knob and added a description
for WITH_GOOGLETEST.

HardenedBSD/hardenedbsd a1c40b8tools/build/options WITH_GOOGLETEST

Add description for WITH_GOOGLETEST

This is the logical negation of WITHOUT_GOOGLETEST, and helpful to have as
we now have different per-arch defaults for this option.

HardenedBSD/hardenedbsd bf614a9share/mk src.opts.mk

googletest: default-disable on all of MIPS for now

Parts of the fusefs tests trigger a bug in current versions of llvm: IR
representation of some routine for the MIPS targets is a function with a
large number of arguments. This then leads the compiler on an hour+ long
goose chase, which is OK if you build the current tree but less-so if you're
trying external toolchain or doing a universe build involving mips when it
eventually gets switched over to LLVM.

Better, accurate details can be found in LLVM PR43263.

HardenedBSD/hardenedbsd a7c4d00stand/mips/uboot Makefile

mips: ubldr: use truncated load address for mips32

BFD appears to silently truncate 0xffffffff80800000 when it processes the
ldscript for 32-bit mips, but LLD chokes on it as the linker script tries to
place elements above 32-bit range. It's unclear to me if silent truncation
is kosher or not and whether this patch is really what we want to do, but it
is one approach at least.

Reviewed by:    imp, mizhka
Differential Revision:  https://reviews.freebsd.org/D21487

HardenedBSD/hardenedbsd 7da6be8contrib/jemalloc/src jemalloc.c, lib/libc/sys open.2

Merge branch 'freebsd/current/master' into hardened/current/master

* freebsd/current/master:
  Temporarily skip sys.netpfil.common.tos.pf_tos on i386 CI as it always fails
  Temporarily skip sys.netpfil.common.forward.pf_v4 on i386 CI as it always fails
  Use correct filename in newsyslog.conf
  log daemon.info to /var/log/daemon.log by default
  ifconfig: add report of the string from SIOCGIFDOWNREASON.
  Add SIOCGIFDOWNREASON.
  Further refine r352393, only call vnode_pager_setsize() outside the node lock when 
shrinking.
  realloc(x, 0) should not return NULL.
  Return EISDIR when directory is opened with O_CREAT without O_DIRECTORY.

HardenedBSD/hardenedbsd 8bc0e48tests/sys/netpfil/common tos.sh

Temporarily skip sys.netpfil.common.tos.pf_tos on i386 CI as it always fails

PR:            240086
Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd f94e2betests/sys/netpfil/common forward.sh

Temporarily skip sys.netpfil.common.forward.pf_v4 on i386 CI as it always fails

PR:            240085
Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd a6f0387usr.sbin/newsyslog newsyslog.conf

Use correct filename in newsyslog.conf

Approved by:           bapt (implicit)
Differential Revision:  https://reviews.freebsd.org/D21561

HardenedBSD/hardenedbsd f3228a1usr.sbin/newsyslog newsyslog.conf, usr.sbin/syslogd syslog.conf

log daemon.info to /var/log/daemon.log by default

log daemon facility now that daemon(8) has syslog support which defaults to
daemon facility, info priority

Reviewed by:           bapt
Approved by:           bapt
Differential Revision:  https://reviews.freebsd.org/D21561

HardenedBSD/hardenedbsd 7816badcddl/contrib/opensolaris/cmd/zfs zfs.8, cddl/contrib/opensolaris/lib/libzfs/common libzfs_sendrecv.c

Merge branch 'freebsd/current/master' into hardened/current/master

* freebsd/current/master:
  loader: provide u> and xemit words if needed
  The VFS-level clustering code collects together sequential blocks by issuing 
delayed-writes (bdwrite()) until a non-sequential block is written or the maximum cluster 
size is reached. At that point it collects the delayed buffers together (using bread()) to 
write them in a single operation. The assumption was that since we just looked at them 
they will still be in memory so there is no need to check for a read error from bread(). 
Very occationally (apparently every 10-hours or so when being pounded by Peter Holm's 
tests) this assumption is wrong.
  loader: revert r352421
  vfs: apply r352437 to the fast path as well
  fixup up fallout from r352447 in libbe
  Temporarily skip flakey test case lib.libc.sys.stat_test.stat_socket
  MFZoL: Add -vnP support to 'zfs send' for bookmarks
  loader.efi: efipart needs to use ioalign
  loader: add memalign() to libsa
  loader: stand.h should define reallocf as Reallocf

HardenedBSD/hardenedbsd f02a2adsbin/ifconfig ifmedia.c

ifconfig: add report of the string from SIOCGIFDOWNREASON.

Sample output:
# ifconfig mce0
mce0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=3ed07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWFILTER,VLAN_HWTSO,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6,TXRTLMT,HWRXTSTMP>
        ether e4:1d:2d:e7:10:0a
        media: Ethernet autoselect <full-duplex,rxpause,txpause>
        status: no carrier (Negotiation failure)
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

Reviewed by:    hselasky, rrs
Sponsored by:   Mellanox Technologies
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D21527

HardenedBSD/hardenedbsd 465bfaesys/net if.h if.c, sys/sys sockio.h

Add SIOCGIFDOWNREASON.

The ioctl(2) is intended to provide more details about the cause of
the down for the link.

Eventually we might define a comprehensive list of codes for the
situations.  But interface also allows the driver to provide free-form
null-terminated ASCII string to provide arbitrary non-formalized
information.  Sample implementation exists for mlx5(4), where the
string is fetched from firmware controlling the port.

Reviewed by:    hselasky, rrs
Sponsored by:   Mellanox Technologies
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D21527

HardenedBSD/hardenedbsd 82f8cfdsys/fs/nfsclient nfs_clport.c

Further refine r352393, only call vnode_pager_setsize() outside the
node lock when shrinking.

This is similar to r252528, applied to the above commit.

Apparently there is a race which makes necessary at least to keep the
n_size and pager size consistent when extending.  Current suspect is
that iod threads perform vnode_pager_setsize() without taking the
vnode lock, which corrupts the file content.

Reported and tested by: Masachika ISHIZUKA <ish at amail.plala.or.jp>
Discussed with: rmacklem (related issues)
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week

HardenedBSD/hardenedbsd 53e898fcontrib/jemalloc/src jemalloc.c

realloc(x, 0) should not return NULL.

See http://www.open-std.org/jtc1/sc22/wg14/www/docs/summary.htm#dr_400.
Upstream jemalloc issue is opened by emaste at
https://github.com/jemalloc/jemalloc/issues/1629.

Reviewed by:    emaste
PR:     240456
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DIfferential revision:  https://reviews.freebsd.org/D21632

HardenedBSD/hardenedbsd c4ddd57lib/libc/sys open.2, sys/kern vfs_vnops.c

Return EISDIR when directory is opened with O_CREAT without O_DIRECTORY.

Reviewed by:    bcr (man page), emaste (previous version)
PR:     240452
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DIfferential revision:  https://reviews.freebsd.org/D21634

HardenedBSD/hardenedbsd 3929af9stand/forth loader.4th

loader: provide u> and xemit words if needed

We have external interpreter (userboot.so) which may be lagging behind
with updates and may be missing u> xemit words.

HardenedBSD/hardenedbsd 70e679bsys/kern vfs_cluster.c

The VFS-level clustering code collects together sequential blocks
by issuing delayed-writes (bdwrite()) until a non-sequential block
is written or the maximum cluster size is reached. At that point
it collects the delayed buffers together (using bread()) to write
them in a single operation. The assumption was that since we just
looked at them they will still be in memory so there is no need to
check for a read error from bread(). Very occationally (apparently
every 10-hours or so when being pounded by Peter Holm's tests)
this assumption is wrong.

The fix is to check for errors from bread() and fail the cluster
write thus falling back to the default individual flushing of any
still dirty buffers.

Reported by: Peter Holm and Chuck Silvers
Reviewed by: kib
MFC after:   3 days

HardenedBSD/hardenedbsd 7f0cacesys/arm64/arm64 pmap.c trap.c, sys/arm64/include pte.h

MFC r349117, r349122, r349183, r349897, r349943, r350004, r350029, r350038,
  r350191, r350202, r350422, r350427, r350525

r349117:
  Three enhancements to arm64's pmap_protect():

  Implement protection changes on superpage mappings.  Previously, a superpage
  mapping was unconditionally demoted by pmap_protect(), even if the
  protection change applied to the entire superpage mapping.

  Precompute the bit mask describing the protection changes rather than
  recomputing it for every page table entry that is changed.

  Skip page table entries that already have the requested protection changes
  in place.

r349122:
  Three changes to arm64's pmap_unwire():

  Implement wiring changes on superpage mappings.  Previously, a superpage
  mapping was unconditionally demoted by pmap_unwire(), even if the wiring
  change applied to the entire superpage mapping.

  Rewrite a comment to use the arm64 names for bits in a page table entry.
  Previously, the bits were referred to by their x86 names.

    [100 lines not shown]

HardenedBSD/hardenedbsd 96afe81stand/libsa zalloc_malloc.c

loader: revert r352421

As insisted by kib, malloc(0) is quite legal.

HardenedBSD/hardenedbsd b6dddc8sys/kern vfs_default.c

vfs: apply r352437 to the fast path as well

This one is very hard to run into. If the filesystem is being unmounted or
the mount point is freed the vfs_op_thread_enter will fail. For it to
succeed the mount point itself would have to be reallocated in the time
window between the initial read and the attempt to enter.

Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd 548ac73lib/libbe be.c

fixup up fallout from r352447 in libbe

I totally forgot that we now have another in-tree consumer of libzfs.

MFC after:      3 days
X-MFC with:     r352447
DeltaFile
+2-1lib/libbe/be.c
+2-11 files

HardenedBSD/hardenedbsd 4181d59contrib/netbsd-tests/lib/libc/sys t_stat.c

Temporarily skip flakey test case lib.libc.sys.stat_test.stat_socket

PR:            240621
Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd 28e4f4ccddl/contrib/opensolaris/cmd/zfs zfs.8 zfs_main.c, cddl/contrib/opensolaris/lib/libzfs/common libzfs_sendrecv.c libzfs.h

MFZoL: Add -vnP support to 'zfs send' for bookmarks

zfsonlinux/zfs at 835db58592d7d947e5818eb7281882e2a46073e0

We have long supported estimating a size of an incremental stream from a
snapshot.  We should do the same for bookmarks as well.

Obtained from:  ZoL
Author:        loli10K <ezomori.nozomu at gmail.com>
MFC after:      3 days

HardenedBSD/hardenedbsd 16ef880stand/efi/libefi efipart.c

loader.efi: efipart needs to use ioalign

UEFI specification 2.7A, EFI_BLOCK_IO_PROTOCOL, page 566.

The ioalign property does define the alignment of data buffer.

If the alignment is required and our buffer is not aligned, or if
the data buffer is not multiple of Blocksize, we need to use bounce buffer
to perform the block IO. This is much like with BIOS version, except
there the INT13 needs buffer to be located in low memory.

Additionally, we need to handle disk writes properly.
DeltaFile
+113-24stand/efi/libefi/efipart.c
+113-241 files

HardenedBSD/hardenedbsd 05e4fd4stand/libsa zalloc.c zalloc_malloc.c

loader: add memalign() to libsa

Implement memalign(size_t alignment, size_t size) to allocate aligned memory.

HardenedBSD/hardenedbsd d8d8567stand/libsa zalloc.c zalloc_malloc.c, sys/kern vfs_default.c

Merge branch 'freebsd/current/master' into hardened/current/master

* freebsd/current/master:
  loader: cstyle cleanup libsa zalloc sources
  loader: factor out guard location setup from Realloc
  Only allow a SCTP-AUTH shared key to be updated by the application if it is not 
deactivated and not used. This avoids a use-after-free problem.
  vfs: fix braino resulting in NULL pointer deref in r352424

HardenedBSD/hardenedbsd 4cfe636stand/libsa stand.h

loader: stand.h should define reallocf as Reallocf

Use the same approach as other zalloc functions.

HardenedBSD/hardenedbsd 17bb033stand/libsa zalloc.c zalloc_malloc.c

loader: cstyle cleanup libsa zalloc sources

Clean up libstand zalloc* sources. Note that it is not 100% whitespace cleanup.
I also reduced block in znalloc and zfree as those were obvious simplifications
and did help to save one level of indent.

HardenedBSD/hardenedbsd 06e2640sys/arm/arm physmem.c

MFC r351649 Check for region dups.

HardenedBSD/hardenedbsd bc3f9bdsys/arm64/arm64 cpufunc_asm.S

MFC r343042, r343875

r343042:
Ensure the I-Cache is correctly handled in arm64_icache_sync_range

The cache_handle_range macro to handle the arm64 instruction and data
cache operations would return when it was complete. This causes problems
for arm64_icache_sync_range and arm64_icache_sync_range_checked as they
assume they can execute the i-cache handling instruction after it has been
called.

Fix this by making this assumption correct.

While here add missing instruction barriers and adjust the style to
match the rest of the assembly.

Sponsored by:   DARPA, AFRL
Differential Revision:  https://reviews.freebsd.org/D18838

r343875:
Add a missing data barrier to the start of arm64_tlb_flushID.

We need to ensure the page table store has happened before the tlbi.

Reported by:    jchandra

    [3 lines not shown]

HardenedBSD/hardenedbsd 985d23fsys/arm64/arm64 trap.c

MFC r342552:
Pass VM_PROT_EXECUTE to vm_fault for instruction faults.

We need to tell vm_fault the reason for the fault was because we tried to
execute from the memory location. Without this it may return with success
as we only request read-only memory, then we return to the same location
and try to execute from the same memory address. This leads to an infinite
loop raising the same fault and returning to the same invalid location.

Sponsored by:   DARPA, AFRL
Differential Revision:  https://reviews.freebsd.org/D18511

HardenedBSD/hardenedbsd 36a81edstand/libsa zalloc_malloc.c

loader: factor out guard location setup from Realloc

To simplify and make it easier to read, use ga_Bytes field from guard
structure.

HardenedBSD/hardenedbsd 9ba53a7sys/netinet sctp_auth.c

Only allow a SCTP-AUTH shared key to be updated by the application
if it is not deactivated and not used.
This avoids a use-after-free problem.

Reported by:           da_cheng_shao at yeah.net
MFC after:             3 days

HardenedBSD/hardenedbsd 9757ecasys/kern vfs_default.c

vfs: fix braino resulting in NULL pointer deref in r352424

The breakage was added after all the testing and the testing which followed
was not sufficient to find it.

Reported by:    pho
Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd b4c145fshare/misc committers-ports.dot, sys/mips/include pcpu.h

Merge branch 'freebsd/current/master' into hardened/current/master

* freebsd/current/master:
  mips: move support for temporary mappings above KSEG0 to per-CPU data
  Remove dead code from vm_map_unlink_entry made dead by r351476, and also a 
no-longer-used enumerant.
  Amend r352422, add missing 'n'

HardenedBSD/hardenedbsd 5d72cd0lib/libc/sys cpuset.2

Merge remote-tracking branch 'origin/hardened/11-stable/master' into 
hardened/11-stable/unstable

* origin/hardened/11-stable/master:
  MFC r352048:

HardenedBSD/hardenedbsd a0c3215lib/libc/sys cpuset.2

Merge branch 'freebsd/11-stable/master' into hardened/11-stable/master

* freebsd/11-stable/master:
  MFC r352048:

HardenedBSD/hardenedbsd c187267sys/mips/include pcpu.h, sys/mips/mips pmap.c

mips: move support for temporary mappings above KSEG0 to per-CPU data

This is derived from similar work done in r310481 for i386 and r312610 for
armv6/armv7. Additionally, use a critical section to keep the thread
pinned for per-CPU operations instead of completely disabling local interrupts.

No objections from:     adrian, jmallett, imp
Differential Revision:  https://reviews.freebsd.org/D18593

HardenedBSD/hardenedbsd b901d58sys/vm vm_map.c

Remove dead code from vm_map_unlink_entry made dead by r351476, and also
a no-longer-used enumerant.

Reviewed by: alc
Approved by: markj (mentor, implicit)
Tested by: pho (as part of a larger change)
Differential Revision: https://reviews.freebsd.org/D21668
DeltaFile
+1-11sys/vm/vm_map.c
+1-111 files

HardenedBSD/hardenedbsd f6df80bsys/kern vfs_mount.c vfs_vnops.c, sys/riscv/riscv clock.c

Merge branch 'freebsd/current/master' into hardened/current/master

* freebsd/current/master:
  fix the article to be correct...
  RISC-V: Support EARLY_AP_STARTUP
  vfs: convert struct mount counters to per-cpu
  vfs: manage mnt_writeopcount with atomics
  vfs: manage mnt_lockref with atomics
  vfs: manage mnt_ref with atomics
  Add myself (dmgk) to calendar.freebsd
  Add myself (dmgk) as a ports committer
  loader: Malloc(0) should return NULL.
  loader_4th: scan_buffer can leave empty string on stack

HardenedBSD/hardenedbsd 3c177dashare/misc committers-ports.dot

Amend r352422, add missing 'n'

Reported by:    yuripv
Approved by:    araujo (mentor)
Differential Revision:  https://reviews.freebsd.org/D21679

HardenedBSD/hardenedbsd fcc1fe6libexec/rc/rc.d growfs

fix the article to be correct...

HardenedBSD/hardenedbsd e9360c3sys/riscv/conf GENERIC, sys/riscv/riscv clock.c mp_machdep.c

RISC-V: Support EARLY_AP_STARTUP

The EARLY_AP_STARTUP option initializes non-boot processors
much sooner during startup. This adds support for this option
on RISC-V and enables it by default for GENERIC.

Reviewed by:    jhb, markj
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D21661

HardenedBSD/hardenedbsd 34f4234lib/libc/sys cpuset.2

MFC r352048:

Fix cpuwhich_t column width

HardenedBSD/hardenedbsd 94fee6elib/libc/sys cpuset.2

MFC r352048:

Fix cpuwhich_t column width

HardenedBSD/hardenedbsd 6090f91sys/kern vfs_mount.c vfs_subr.c, sys/sys mount.h pcpu.h

vfs: convert struct mount counters to per-cpu

There are 3 counters modified all the time in this structure - one for
keeping the structure alive, one for preventing unmount and one for
tracking active writers. Exact values of these counters are very rarely
needed, which makes them a prime candidate for conversion to a per-cpu
scheme, resulting in much better performance.

Sample benchmark performing fstatfs (modifying 2 out of 3 counters) on
a 104-way 2 socket Skylake system:
before:   852393 ops/s
after:  76682077 ops/s

Reviewed by:    kib, jeff
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D21637