HardenedBSD/hardenedbsd d32f51dcontrib/llvm/tools/clang/lib/Driver SanitizerArgs.cpp

HBSD: Do not require non-existent cfi_blacklist.txt

clang 7.0.0 adopted a linux-ism of forcing everyone to adopt something.
HardenedBSD does not currently need or use cfi_blacklist.txt, so undo
the linux-ism.

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
Sponsored-by:   SoldierX
(cherry picked from commit a86776ebe535e12dd9b41ff1e71a6776f4b0d393)
Signed-off-by: Shawn Webb <shawn.webb at hardenedbsd.org>

HardenedBSD/hardenedbsd 1000257contrib/llvm/lib/Demangle ItaniumDemangle.cpp, contrib/llvm/lib/Target/X86 X86ISelLowering.cpp X86InstrAVX512.td

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

* origin/hardened/current/master: (98 commits)
  HBSD: clang/llvm 7.0.1 fixups
  Continuing efforts to provide hardening of FFS. This change adds a check hash to the 
filesystem inodes. Access attempts to files associated with an inode with an invalid check 
hash will fail with EINVAL (Invalid argument). Access is reestablished after an fsck is 
run to find and validate the inodes with invalid check-hashes. This check avoids a class 
of filesystem panics related to corrupted inodes. The hash is done using crc32c.
  pf tests: Use the ATF cleanup infrastructure in the ioctl tests
  pf tests: ioctl tests require root rights
  pf: Prevent integer overflow in PF when calculating the adaptive timeout.
  Remove a dead file.  CVS was removed in r251794.
  Allow CTL device specification in bhyve virtio-scsi.
  HBSD: Resolve merge conflict
  Remove unused argument to priv_check_cred.
  Fix !tx_abdicate error from r336560
  Set tentative merge date, and add UPDATING note.
  audi: replace open-coded TDP_AUDITREC checks with the macro
  Fix the PAE kernel gcc build.
  asmc: Add Support for MacBookAir 7,1 and 7,2
  For arm and armv6, only enable LLVM target support for arm by default, to shrink 
libllvm.a.
  Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch r348686 

    [7 lines not shown]

HardenedBSD/hardenedbsd 1fccb93sbin/fsck_ffs inode.c, sys/ufs/ffs ffs_subr.c ffs_softdep.c

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

HardenedBSD/hardenedbsd 0ccc116lib/libclang_rt/cfi Makefile, sys/conf kern.mk kmod.mk

HBSD: clang/llvm 7.0.1 fixups

The sanitizer runtime now causes the compiler toolchain to link with
libz. Update the libraries clang, llvm, etc. depend on to add libz.

retpolineplt/retpolineplt is no longer an available linker option for
kernel builds (kmod and kern).

One of the sanitizer files libcfi depends on was renamed.

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
Sponsored-by:   SoldierX

HardenedBSD/hardenedbsd 89c5ffesys/conf newvers.sh, sys/powerpc/conf GENERIC GENERIC64

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

* freebsd/12-stable/master:
  MFC 340694: Enable evdev on ppc32
  MFC 340632
  Call stable/12 -STABLE now that 12.0-RELEASE is out.

HardenedBSD/hardenedbsd fb00f8bsys/cddl/contrib/opensolaris/uts/common/fs/zfs zfs_znode.c

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

* origin/hardened/11-stable/master:
  MFC: r339289: Resolve a hang in ZFS during vnode reclaimation

HardenedBSD/hardenedbsd 1cecb22sys/cddl/contrib/opensolaris/uts/common/fs/zfs zfs_znode.c

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

* freebsd/11-stable/master:
  MFC: r339289: Resolve a hang in ZFS during vnode reclaimation

HardenedBSD/hardenedbsd 830a63alib/libufs inode.c, sbin/fsck_ffs inode.c

Continuing efforts to provide hardening of FFS. This change adds a
check hash to the filesystem inodes. Access attempts to files
associated with an inode with an invalid check hash will fail with
EINVAL (Invalid argument). Access is reestablished after an fsck
is run to find and validate the inodes with invalid check-hashes.
This check avoids a class of filesystem panics related to corrupted
inodes. The hash is done using crc32c.

Note this check-hash is for the inode itself and not any of its
indirect blocks. Check-hash validation may be extended to also
cover indirect block pointers, but that will be a separate (and
more costly) feature.

Check hashes are added only to UFS2 and not to UFS1 as UFS1 is
primarily used in embedded systems with small memories and low-powered
processors which need as light-weight a filesystem as possible.

Reviewed by:  kib
Tested by:    Peter Holm
Sponsored by: Netflix

HardenedBSD/hardenedbsd 8908e9btests/sys/netpfil/pf/ioctl validation.c

pf tests: Use the ATF cleanup infrastructure in the ioctl tests

Use ATF_TC_CLEANUP(), because that means the cleanup code will get
called even if a test fails. Before it would only be executed if every
test within the body succeeded.

Reported by:    Marie Helene Kvello-Aune <marieheleneka at gmail.com>
MFC after:      2 weeks

HardenedBSD/hardenedbsd 3a9dd6dtests/sys/netpfil/pf/ioctl validation.c

pf tests: ioctl tests require root rights

Explicitly mark these tests as requiring root rights. We need to be able
to open /dev/pf.

Reported by:    Marie Helene Kvello-Aune <marieheleneka at gmail.com>
MFC after:      2 weeks

HardenedBSD/hardenedbsd e7bab00sys/netpfil/pf pf.c

pf: Prevent integer overflow in PF when calculating the adaptive timeout.

Mainly states of established TCP connections would be affected resulting
in immediate state removal once the number of states is bigger than
adaptive.start.  Disabling adaptive timeouts is a workaround to avoid this bug.
Issue found and initial diff by Mathieu Blanc (mathieu.blanc at cea dot fr)

Reported by: Andreas Longwitz <longwitz AT incore.de>
Obtained from:  OpenBSD
MFC after:      2 weeks

HardenedBSD/hardenedbsd 40f5fbctools/build/options WITHOUT_CVS

Remove a dead file.  CVS was removed in r251794.

HardenedBSD/hardenedbsd 5cd8d1asys/powerpc/conf GENERIC

MFC 340694: Enable evdev on ppc32

Enable evdev on ppc32 as well, similar to what was done i386 and amd64 in
r340387 and ppc64 in r340632.

Evdev can be used by X and is used by wayland to handle input devices.

Approved by:    jhibbits

HardenedBSD/hardenedbsd d5368d2sys/powerpc/conf GENERIC64

MFC 340632

Enable evdev on ppc64

Enable evdev on ppc64 as well, similar to what was done for amd64 and i386
in r340387.

Evdev can be used by X and is used by wayland to handle input devices.

Approved by:    mmacy

HardenedBSD/hardenedbsd 14cfae9usr.sbin/bhyve pci_virtio_scsi.c bhyve.8

Allow CTL device specification in bhyve virtio-scsi.

There was a large refactoring done in CTL to allow multiple ioctl frontend
ports (and respective devices) to be created, particularly for bhyve.
Unfortunately, respective part of bhyve functionality got lost somehow from
the original virtio-scsi commit.  This change allows wanted device path to
be specified in either of two ways:
 -s 6,virtio-scsi,/dev/cam/ctl1.1
 -s 6,virtio-scsi,dev=/dev/cam/ctl2.3
If neither is specified, the default /dev/cam/ctl device is used.

While there, remove per-queue CTL device opening, which makes no sense at
this point.

Reported by:    wg
Reviewed by:    araujo
MFC after:      3 days
Sponsored by:   iXsystems, Inc.
Differential Revision:  https://reviews.freebsd.org/D18504

HardenedBSD/hardenedbsd c834fdecontrib/compiler-rt/lib/cfi cfi.cc

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
Sponsored-by:   SoldierX

HardenedBSD/hardenedbsd 07d5e0bcontrib/llvm/lib/Demangle ItaniumDemangle.cpp, contrib/llvm/lib/Target/X86 X86ISelLowering.cpp X86InstrAVX512.td

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

Conflicts:
        contrib/compiler-rt/lib/cfi/cfi.cc (unresolved)

HardenedBSD/hardenedbsd bf6caa0sys/cddl/contrib/opensolaris/uts/common/fs/zfs zfs_znode.c

MFC: r339289: Resolve a hang in ZFS during vnode reclaimation

  This is caused by a deadlock between zil_commit() and zfs_zget()
  Add a way for zfs_zget() to break out of the retry loop in the common case

PR:            229614, 231117
Reported by:    grembo, jhb, Andreas Sommer, others
Relnotes:       yes
Sponsored by:   Klara Systems

HardenedBSD/hardenedbsd 7e31d1dsys/cddl/compat/opensolaris/kern opensolaris_policy.c, sys/fs/ext2fs ext2_vnops.c

Remove unused argument to priv_check_cred.

Patch mostly generated with cocinnelle:

@@
expression E1,E2;
@@

- priv_check_cred(E1,E2,0)
+ priv_check_cred(E1,E2)

Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd c22b0b1sys/conf newvers.sh

Call stable/12 -STABLE now that 12.0-RELEASE is out.

Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd d41b4eccontrib/llvm/lib/Demangle ItaniumDemangle.cpp, contrib/llvm/lib/Target/X86 X86ISelLowering.cpp X86InstrAVX512.td

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
the upstream release_70 branch r348686 (effectively, 7.0.1 rc3).  The
release will follow very soon, but no more functional changes are
expected.

Release notes for llvm, clang and lld 7.0.0 are available here:
<http://releases.llvm.org/7.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/7.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/7.0.0/tools/lld/docs/ReleaseNotes.html>

PR:            230240, 230355
Relnotes:       yes
MFC after:      2 months

HardenedBSD/hardenedbsd 38be9dasys/kern kern_descrip.c kern_resource.c, sys/sys resourcevar.h

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

* origin/hardened/current/master:
  fd: dedup code in sys_getdtablesize
  Make lim_cur inline if possible.
  fd: tidy up closing a fd
  fd: stop looking for exact freefile after allocation

HardenedBSD/hardenedbsd f316ae9sys/kern kern_descrip.c kern_resource.c, sys/sys resourcevar.h

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

* freebsd/current/master:
  fd: dedup code in sys_getdtablesize
  Make lim_cur inline if possible.
  fd: tidy up closing a fd
  fd: stop looking for exact freefile after allocation

HardenedBSD/hardenedbsd 8be3d25usr.sbin/jail jail.8

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
Sponsored-by:   SoldierX

HardenedBSD/hardenedbsd 13a12eesys/dev/netmap netmap_kloop.c netmap.c, sys/net netmap_virt.h

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

Conflicts:
        usr.sbin/jail/jail.8 (unresolved)

HardenedBSD/hardenedbsd e870850sys/net iflib.c

Fix !tx_abdicate error from r336560

r336560 was supposed to restore pre-r323954 behaviour when tx_abdicate is
not set (the default case). However, it appears that rather than the drainage
check being made conditional on tx_abdicate being set, it was duplicated
so it occured twice if tx_abdicate was set and once if it was not.

Now when !tx_abdicate, drainage is only checked if the doorbell isn't
pending.

Reported by:    lev
MFC after:      1 week
Sponsored by:   Limelight Networks
DeltaFile
+0-1sys/net/iflib.c
+0-11 files

HardenedBSD/hardenedbsd 7120659. UPDATING ObsoleteFiles.inc

Set tentative merge date, and add UPDATING note.

HardenedBSD/hardenedbsd 9be8abasys/security/audit audit.h

audi: replace open-coded TDP_AUDITREC checks with the macro

Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd b598872sys/x86/x86 ucode.c

Fix the PAE kernel gcc build.

The error was caused by map_ucode() casting a vm_paddr_t to a void *.
Use a uintptr_t instead to match the caller.  Fix some style bugs while
here.

Reported by:    bde
Reviewed by:    bde
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
DeltaFile
+10-8sys/x86/x86/ucode.c
+10-81 files

HardenedBSD/hardenedbsd 1b02aefsys/dev/asmc asmcvar.h asmc.c

asmc: Add Support for MacBookAir 7,1 and 7,2

PR:            226172
Submitted by:   James Wright <james.wright at jigsawdezign.com>
Reported by:    James Wright <james.wright at jigsawdezign.com>
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18396

HardenedBSD/hardenedbsd ad4efecsys/arm64/acpica acpi_machdep.c, sys/dev/ahci ahci_pci.c

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

* origin/hardened/current/master:
  Only read the ACPI proximity tabled on arm64 when we are booting from ACPI.
  Remove questionable initialization for ICH8M, rely on BIOS to properly initialize the 
controller.

HardenedBSD/hardenedbsd ba8523csys/kern kern_descrip.c

fd: dedup code in sys_getdtablesize

Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd 5936383sys/kern kern_resource.c, sys/sys resourcevar.h

Make lim_cur inline if possible.

It is a function call only to accomodate *some* ABIs which install a hook.
They only care for 3 types of limits: DATA, STACK, VMEM

Instead of always calling the func, see at compilation time if the requested
limit is something else and just do the read if so.

Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd 45f96absys/kern kern_descrip.c

fd: tidy up closing a fd

- avoid a call to knote_close in the common case
- annotate mqueue as unlikely

Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd 9e88840sys/arm64/acpica acpi_machdep.c, sys/dev/ahci ahci_pci.c

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

* freebsd/current/master:
  Only read the ACPI proximity tabled on arm64 when we are booting from ACPI.
  Remove questionable initialization for ICH8M, rely on BIOS to properly initialize the 
controller.

HardenedBSD/hardenedbsd 78cf9b9sys/kern kern_descrip.c

fd: stop looking for exact freefile after allocation

If a lower fd is closed later, the lookup goes to waste. Allocation
always performs the lookup anyway.

Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd e0f0441sys/dev/netmap netmap_kloop.c netmap.c, sys/net netmap_virt.h

MFC r341516, r341589

netmap: align codebase to the current upstream (760279cfb2730a585)

Changelist:
  - Replace netmap passthrough host support with a more general
    mechanism to call TXSYNC/RXSYNC from an in-kernel event-loop.
    No kernel threads are used to use this feature: the application
    is required to spawn a thread (or a process) and issue a
    SYNC_KLOOP_START (NIOCCTRL) command in the thread body. The
    kernel loop is executed by the ioctl implementation, which returns
    to userspace only when a different thread calls SYNC_KLOOP_STOP
    or the netmap file descriptor is closed.
  - Update the if_ptnet driver to cope with the new data structures,
    and prune all the obsolete ptnetmap code.
  - Add support for "null" netmap ports, useful to allocate netmap_if,
    netmap_ring and netmap buffers to be used by specialized applications
    (e.g. hypervisors). TXSYNC/RXSYNC on these ports have no effect.
  - Various fixes and code refactoring.

Sponsored by:   Sunny Valley Networks
Differential Revision:  https://reviews.freebsd.org/D18015

HardenedBSD/hardenedbsd 3e3733asys/arm64/acpica acpi_machdep.c

Only read the ACPI proximity tabled on arm64 when we are booting from
ACPI.

Sponsored by:   DARPA, AFRL

HardenedBSD/hardenedbsd 30c4d65share/vt/keymaps uk.macbook.kbd, stand/powerpc/uboot ppc64_elf_freebsd.c

Merge ^/head r341764 through r341812.

HardenedBSD/hardenedbsd 3140f98share/mk src.opts.mk

For arm and armv6, only enable LLVM target support for arm by default,
to shrink libllvm.a.

This is a workaround for "relocation truncated to fit" errors with BFD
ld 2.17.50 on arm and armv6, when linking executables against it.

The required range extensions are not yet supported by this very old
version of BFD ld.  When arm and armv6 userland can be successfully
linked by lld, this workaround can be removed.

HardenedBSD/hardenedbsd 5c66c60lib/libc/sys getfh.2, libexec/rc rc.subr

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

* origin/hardened/current/master:
  Free bootstacks after AP startup.
  Remove special case handling for getfhat(fd, NULL, handle).
  Remove an unused malloc(9) type.
  Use inline tests for individual PTE bits in the RISC-V pmap.
  Add uk.macbook.kbd keymap (vt)
  powerpc/booke: Don't get and use the load offset for TOC on APs
  rc.subr: Implement list_vars without using 'read'

HardenedBSD/hardenedbsd 1a0fc84lib/libc/sys getfh.2, libexec/rc rc.subr

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

* freebsd/current/master:
  Free bootstacks after AP startup.
  Remove special case handling for getfhat(fd, NULL, handle).
  Remove an unused malloc(9) type.
  Use inline tests for individual PTE bits in the RISC-V pmap.
  Add uk.macbook.kbd keymap (vt)
  powerpc/booke: Don't get and use the load offset for TOC on APs
  rc.subr: Implement list_vars without using 'read'

HardenedBSD/hardenedbsd 93df27econtrib/ipfilter ip_fil.c

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

* origin/hardened/11-stable/master:
  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.

HardenedBSD/hardenedbsd baeb9d6contrib/ipfilter ip_fil.c

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

* freebsd/11-stable/master:
  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.

HardenedBSD/hardenedbsd 1fcf9e5sys/dev/ahci ahci_pci.c

Remove questionable initialization for ICH8M, rely on BIOS to properly
initialize the controller.

According to the datasheet, the old code checks if port 2 (P2E, 0x4) was
the only enabled port (except port 0, which was ignored by mask 0xfe),
and issue a write to the PCS register to disable all but port 0, right
before ahci_ctlr_reset.

Some other operating systems would issue a port enable to all ports, but
since the current code only does the special initialization for ICH8M,
it entirely and rely on BIOS to do the right thing (the alternative
would be https://reviews.freebsd.org/D18300?id=50922 , should we see
reports that we really need to do it).

Reviewed by:    mav
MFC after:      3 months
Differential Revision:  https://reviews.freebsd.org/D18300

HardenedBSD/hardenedbsd f70186fcontrib/ipfilter ip_fil.c

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

* freebsd/10-stable/master:
  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.

HardenedBSD/hardenedbsd 28de053sys/kern kern_thread.c, sys/x86/x86 mp_x86.c

Free bootstacks after AP startup.

Bootstacks are unused after APs executed sched_throw() in
init_secondary_tail() and started executing on proper idle thread
stack.  Add sysinit that detects that the idle thread for each CPU was
scheduled at least once, and free corresponding bootstack.

Slight addition of the code (~200 bytes) is compensated by the saving,
because even on typical small modern desktop CPU we leak 128K of
memory otherwise (4 pages x 8 threads).

Reviewed by:    jhb
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D18486

HardenedBSD/hardenedbsd 4045451lib/libc/sys getfh.2, sys/kern vfs_syscalls.c

Remove special case handling for getfhat(fd, NULL, handle).

There is no reason for it to behave differently from openat(fd, NULL).
Also the handling did not worked because the substituted path was from
the system address space, causing EFAULT.

Submitted by:   Jack Halford <jack at gandi.net>
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D18501

HardenedBSD/hardenedbsd 2918dccsys/riscv/riscv pmap.c

Remove an unused malloc(9) type.

MFC after:      1 week
Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd 32498fdsys/riscv/riscv pmap.c

Use inline tests for individual PTE bits in the RISC-V pmap.

Inline tests for PTE_* bits are easy to read and don't really require a
predicate function, and predicates which operate on a pt_entry_t are
inconvenient when working with L1 and L2 page table entries.

Reviewed by:    jhb
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D18461
DeltaFile
+20-51sys/riscv/riscv/pmap.c
+20-511 files