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 864dee4share/man/man4 nvdimm.4, sys/amd64/amd64 machdep.c pmap.c

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

* freebsd/current/master:
  ping: fix unaligned access to ancillary data
  last(1): correction after r351413
  Add nvdimm(4) man page.
  amd64: rework PCPU allocation
  Do not constrain allocations for doublefault, boot, and mce stacks.
  Style.
  Remove unecessary VM_ALLOC_ZERO from allocation of the domain-local page for pcpu.
  Make stack grow use the same gap as stack create.
  dtso: allwinner: Add an overlay for H3 thermal node

HardenedBSD/hardenedbsd d2a8e62sbin/ping ping.c

ping: fix unaligned access to ancillary data

Use CMSG_FIRSTHDR rather than assume that an array is correctly aligned.
Fixes warnings on sparc64 and powerpcspe.

Submitted by:   Ján Sučan <sucanjan at gmail.com>
MFH:           2 weeks
Sponsored by:   Google LLC (Google Summer of Code 2019)
Differential Revision:  https://reviews.freebsd.org/D21406
DeltaFile
+2-3sbin/ping/ping.c
+2-31 files

HardenedBSD/hardenedbsd eb4bf8alib/libthr/thread thr_cancel.c thr_init.c

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

* freebsd/12-stable/master:
  MFC r351349: Fix _pthread_cancel_enter() and _pthread_cancel_leave() jmptable entries.

HardenedBSD/hardenedbsd c6a158dusr.bin/last last.c

last(1): correction after r351413

Make that change no-op for C/POSIX locale just like for UTF-8
that it superset of US-ASCII.

MFC after:      2 weeks
X-MFC-With:     r351413

HardenedBSD/hardenedbsd abf4163share/man/man4 nvdimm.4 Makefile

Add nvdimm(4) man page.

Reviewed by:    emaste
Discussed with: scottl, scottph
Sponsored by:   The FreeBSD Foundation
MFC after:      3 days
Differential revision:  https://reviews.freebsd.org/D21386

HardenedBSD/hardenedbsd b13a167sys/amd64/amd64 machdep.c pmap.c, sys/amd64/include counter.h md_var.h

amd64: rework PCPU allocation

Move pcpu KVA out of .bss into dynamically allocated VA at
pmap_bootstrap().  This avoids demoting superpage mapping .data/.bss.
Also it makes possible to use pmap_qenter() for installation of
domain-local pcpu page on NUMA configs.

Refactor pcpu and IST initialization by moving it to helper functions.

Reviewed by:    markj
Tested by:      pho
Discussed with: jeff
Sponsored by:   The FreeBSD Foundation
Differential revision:  https://reviews.freebsd.org/D21320

HardenedBSD/hardenedbsd 4e8090esys/amd64/amd64 mp_machdep.c

Do not constrain allocations for doublefault, boot, and mce stacks.

All these stacks are used only once (doublefault, boot) or very rare
(mce).

Reviewed by:    markj
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
Differential revision:  https://reviews.freebsd.org/D21320

HardenedBSD/hardenedbsd 4b87d8bsys/amd64/amd64 mp_machdep.c

Style.

HardenedBSD/hardenedbsd 86ab2a8sys/amd64/amd64 mp_machdep.c

Remove unecessary VM_ALLOC_ZERO from allocation of the domain-local
page for pcpu.

Reviewed by:    markj
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
Differential revision:  https://reviews.freebsd.org/D21320

HardenedBSD/hardenedbsd 4650cfcsys/vm vm_map.c

Make stack grow use the same gap as stack create.

Store stack_guard_page * PAGE_SIZE into the gap->next_read field at
the time of the stack creation.  This makes the used guard size
consistent between stack creation and stack grow time.

Suggested by:   alc
Reviewed by:    alc, markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D21384
DeltaFile
+14-2sys/vm/vm_map.c
+14-21 files

HardenedBSD/hardenedbsd 2357c21sys/dts/arm/overlays sun8i-h3-ths.dtso sun8i-h3-sid.dtso, sys/modules/dtb/allwinner Makefile

dtso: allwinner: Add an overlay for H3 thermal node

Reviewed by:    manu

HardenedBSD/hardenedbsd 2a056a7lib/libthr/thread thr_cancel.c thr_init.c

MFC r351349:
Fix _pthread_cancel_enter() and _pthread_cancel_leave() jmptable entries.

PR:     240022

HardenedBSD/hardenedbsd 75f9a47sys/kern subr_pcpu.c, sys/vm uma.h

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

* freebsd/current/master:
  Fix failure test cases after r351423 due to ping6(8) options changed
  Remove the obsolete pcpu_zone_ptr zone.

HardenedBSD/hardenedbsd ef37aa1sys/amd64/amd64 pmap.c, sys/amd64/include pmap.h

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

* origin/hardened/11-stable/master:
  MFC 350551: Don't reset memory attributes when mapping physical addresses for ACPI.
  MFC 339432: Do not flush cache for PCIe config window.

HardenedBSD/hardenedbsd a14c8a3sys/amd64/amd64 pmap.c, sys/amd64/include pmap.h

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

* freebsd/11-stable/master:
  MFC 350551: Don't reset memory attributes when mapping physical addresses for ACPI.
  MFC 339432: Do not flush cache for PCIe config window.

HardenedBSD/hardenedbsd f9ac3b8sys/amd64/amd64 pmap.c, sys/i386/i386 pmap.c

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

* freebsd/12-stable/master:
  MFC 350551: Don't reset memory attributes when mapping physical addresses for ACPI.

HardenedBSD/hardenedbsd 7ed91a6tests/sys/netpfil/common pass_block.sh, tests/sys/netpfil/pf pass_block.sh

Fix failure test cases after r351423 due to ping6(8) options changed

Failure test cases:
    sys.netpfil.common.pass_block.pf_v6
    sys.netpfil.pf.pass_block.noalias
    sys.netpfil.pf.pass_block.v6

Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd 070322bsbin/ping ping.c, sys/conf makeLINT.mk

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

* freebsd/current/master:
  It turns out the duplication is only mostly harmless.
  cxgbe/t4_tom: Any invalid scaling factor in the hardware's wsf field implies that window 
scaling is not in use.
  whitespace nit.
  cxgbe(4): Use the same buffer size for TOE rx queues as the NIC rx queues.
  ping: Fix alignment errors
  vfs: assert the lock held in MNT_REF/MNT_REL
  Stop clearing page flags in vm_page_pqbatch_submit().
  Make vm_pqbatch_submit_page() externally visible.
  De-commision the MNTK_NOINSMNTQ kernel mount flag.
  Fix universe to include arm LINT kernel configs.

HardenedBSD/hardenedbsd 587eb54sys/amd64/amd64 pmap.c, sys/i386/i386 pmap.c

MFC 350551:
Don't reset memory attributes when mapping physical addresses for ACPI.

Previously, AcpiOsMemory was using pmap_mapbios which would always map
the requested address Write-Back (WB).  For several AMD Ryzen laptops,
the BIOS uses AcpiOsMemory to directly access the PCI MCFG region in
order to access PCI config registers.  This has the side effect of
remapping the MCFG region in the direct map as WB instead of UC
hanging the laptops during boot.

On the one laptop I examined in detail, the _PIC global method used to
switch from 8259A PICs to I/O APICs uses a pair of PCI config space
registers at offset 0x84 in the device at 0:0:0 to as a pair of
address/data registers to access an indirect register in the chipset
and clear a single bit to switch modes.

To fix, alter the semantics of pmap_mapbios() such that it does not
modify the attributes of any existing mappings and instead uses the
existing attributes.  If a new mapping is created, this new mapping
uses WB (the default memory attribute).

Special thanks to the gentleman whose name I don't have who brought
two affected laptops to the hacker lounge at BSDCan.  Direct access to
the affected systems permitted finding the root cause within an hour
or so.

    [2 lines not shown]

HardenedBSD/hardenedbsd 765bddbsys/amd64/amd64 pmap.c, sys/i386/i386 pmap.c

MFC 350551:
Don't reset memory attributes when mapping physical addresses for ACPI.

Previously, AcpiOsMemory was using pmap_mapbios which would always map
the requested address Write-Back (WB).  For several AMD Ryzen laptops,
the BIOS uses AcpiOsMemory to directly access the PCI MCFG region in
order to access PCI config registers.  This has the side effect of
remapping the MCFG region in the direct map as WB instead of UC
hanging the laptops during boot.

On the one laptop I examined in detail, the _PIC global method used to
switch from 8259A PICs to I/O APICs uses a pair of PCI config space
registers at offset 0x84 in the device at 0:0:0 to as a pair of
address/data registers to access an indirect register in the chipset
and clear a single bit to switch modes.

To fix, alter the semantics of pmap_mapbios() such that it does not
modify the attributes of any existing mappings and instead uses the
existing attributes.  If a new mapping is created, this new mapping
uses WB (the default memory attribute).

Special thanks to the gentleman whose name I don't have who brought
two affected laptops to the hacker lounge at BSDCan.  Direct access to
the affected systems permitted finding the root cause within an hour
or so.

    [2 lines not shown]

HardenedBSD/hardenedbsd 088e7aasys/kern subr_pcpu.c, sys/vm uma.h

Remove the obsolete pcpu_zone_ptr zone.

It was only used by flowtable (removed in r321618).

Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd 0668b4econtrib/telnet/arpa telnet.h, contrib/telnet/libtelnet auth-proto.h auth.c

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

* origin/hardened/11-stable/master:
  MFC r331074 (cem): telnetd(8): Fix dereference of uninitialized value 'IF'
  MFC r351070: telnet: remove 3rd clause from Berkeley copyrights
  vtfontcvt: improve BDF and hex font parsing
  MFC r305815: vtfontcvt: remove superfluous newlines in errx messages

HardenedBSD/hardenedbsd 30fcf23sys/dev/nvme nvme.c nvme_ahci.c

It turns out the duplication is only mostly harmless.

While it worked with the kenrel, it wasn't working with the loader.
It failed to handle dependencies correctly. The reason for that is
that we never created a nvme module with the DRIVER_MODULE, but
instead a nvme_pci and nvme_ahci module. Create a real nvme module
that nvd can be dependent on so it can import the nvme symbols it
needs from there.

Arguably, nvd should just be a simple child of nvme, but transitioning
to that (and winning that argument given why it was done this way) is
beyond the scope of this change.

Reviewed by: jhb@
Differential Revision: https://reviews.freebsd.org/D21382

HardenedBSD/hardenedbsd a3a8670sys/dev/cxgbe/tom t4_listen.c

cxgbe/t4_tom: Any invalid scaling factor in the hardware's wsf field
implies that window scaling is not in use.

MFC after:      3 days
Sponsored by:   Chelsio Communications

HardenedBSD/hardenedbsd 230bb8econtrib/telnet/libtelnet enc_des.c encrypt.c, contrib/telnet/telnetd telnetd.c

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

* freebsd/11-stable/master:
  MFC r331074 (cem): telnetd(8): Fix dereference of uninitialized value 'IF'
  MFC r351070: telnet: remove 3rd clause from Berkeley copyrights
  vtfontcvt: improve BDF and hex font parsing
  MFC r305815: vtfontcvt: remove superfluous newlines in errx messages

HardenedBSD/hardenedbsd bcf48adsys/dev/cxgbe/tom t4_listen.c

whitespace nit.

HardenedBSD/hardenedbsd 0567f95sys/dev/cxgbe t4_sge.c

cxgbe(4): Use the same buffer size for TOE rx queues as the NIC rx queues.

This is a minor simplification.

MFC after:      1 week
Sponsored by:   Chelsio Communications

HardenedBSD/hardenedbsd 4f0e6b3contrib/telnet/telnet commands.c defines.h, usr.bin/vtfontcvt vtfontcvt.c

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

* freebsd/12-stable/master:
  MFC r351070: telnet: remove 3rd clause from Berkeley copyrights
  vtfontcvt: improve BDF and hex font parsing

HardenedBSD/hardenedbsd 6a537dfsbin/ping ping.c

ping: Fix alignment errors

This fixes -Wcast-align errors when compiled with WARNS=6.

Submitted by:   Ján Sučan <sucanjan at gmail.com>
MFC after:      2 weeks
Sponsored by:   Google LLC (Google Summer of Code 2019)
Differential Revision:  https://reviews.freebsd.org/D21327
DeltaFile
+104-98sbin/ping/ping.c
+104-981 files

HardenedBSD/hardenedbsd 89d97a7sys/amd64/amd64 pmap.c, sys/amd64/include pmap.h

MFC 339432: Do not flush cache for PCIe config window.

Apparently AMD machines cannot tolerate this. This was uncovered by
r339386, where cache flush started really flushing the requested range.

Introduce pmap_mapdev_pciecfg(), which simply does not flush cache
comparing with pmap_mapdev().  It assumes that the MCFG region was
never accessed through the cacheable mapping, which is most likely
true for machine to boot at all.

Note that i386 does not need the change, since the architecture
handles access per-page due to the KVA shortage, and page remapping
already does not flush the cache.

MFC note: 339386 has not been MFC'd to 11, but merging this change
should still be fine for 11 and reduces conflicts in MFCs of other
changes.

HardenedBSD/hardenedbsd 2d3cff4sys/sys mount.h

vfs: assert the lock held in MNT_REF/MNT_REL

Sponsored by:   The FreeBSD Foundation
DeltaFile
+5-1sys/sys/mount.h
+5-11 files

HardenedBSD/hardenedbsd 31e583asys/vm vm_page.c

Stop clearing page flags in vm_page_pqbatch_submit().

All existing callers guarantee that the page does not have a
pre-existing dequeue pending.  Thus, if the page is dequeued before
pqbatch_submit() acquires the page queue lock, we do not need to do
anything since vm_page_dequeue_complete() takes care of clearing all
page queue state flags for us.

With this change, vm_page_pqbatch_submit() has the nice property that it
does not directly modify any fields in the page structure.

Reviewed by:    alc, kib
Tested by:      pho (part of a larger change)
MFC after:      1 week
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D21372
DeltaFile
+0-1sys/vm/vm_page.c
+0-11 files

HardenedBSD/hardenedbsd d74417dsys/vm vm_page.c vm_page.h

Make vm_pqbatch_submit_page() externally visible.

It will become useful for the page daemon to be able to directly create
a batch queue entry for a page, and without modifying the page
structure.  Rename vm_pqbatch_submit_page() to vm_page_pqbatch_submit()
to keep the namespace consistent.  No functional change intended.

Reviewed by:    alc, kib
MFC after:      1 week
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D21369

HardenedBSD/hardenedbsd 8b8c10esys/kern vfs_mount.c vfs_subr.c, sys/sys mount.h

De-commision the MNTK_NOINSMNTQ kernel mount flag.

After all the changes, its dynamic scope is same as for MNTK_UNMOUNT,
but to allow the syncer vnode to be re-installed on unmount failure.
But the case of syncer was already handled by using the VV_FORCEINSMQ
flag for quite some time.

Tested by:      pho
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week

HardenedBSD/hardenedbsd 287be90sbin/ping6 ping6.8 ping6.c, sbin/ping6/tests ping6_test.sh

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

* freebsd/current/master:
  Turn off -Werror for gcc 4.2.1 for userland
  Turn off -Werror for gcc 4.2.1
  vtfontcvt: simplify rshift_row
  ping: fix include guard symbol name to reflect the header file name
  ping6: Rename options for better consistency with ping
  Report Clock Power Management support and status.
  netpfil tests: Add forward test for the three firewalls

HardenedBSD/hardenedbsd 7a8887bsys/conf makeLINT.mk

Fix universe to include arm LINT kernel configs.

Strip comments from the NOTES.armv[57] files as is done for other
NOTES files when building the corresponding LINT configs.  Without
this, the LINT configs contained the NO_UNIVERSE comment from the
NOTES.armv[57] files.

Reviewed by:    imp
MFC after:      1 week
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D21264

HardenedBSD/hardenedbsd 0d7fac1contrib/telnet/telnetd telnetd.c

MFC r331074 (cem): telnetd(8): Fix dereference of uninitialized value 'IF'

Reported by:    Coverity

HardenedBSD/hardenedbsd b85806acontrib/telnet/arpa telnet.h, contrib/telnet/libtelnet auth-proto.h auth.c

MFC r351070: telnet: remove 3rd clause from Berkeley copyrights

Per the July 22, 1999 letter (in /COPYRIGHT) from
William Hoskins
Director, Office of Technology Licensing
University of California, Berkeley

HardenedBSD/hardenedbsd 3ae1f86contrib/telnet/libtelnet enc-proto.h enc_des.c

MFC r351070: telnet: remove 3rd clause from Berkeley copyrights

Per the July 22, 1999 letter (in /COPYRIGHT) from
William Hoskins
Director, Office of Technology Licensing
University of California, Berkeley

HardenedBSD/hardenedbsd 7857f07sys/netinet tcp_input.c

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

* origin/hardened/11-stable/master:
  MFC r350974:   Save ip_ttl value and restore it after checksum calculation.

HardenedBSD/hardenedbsd fe11da4share/mk bsd.sys.mk

Turn off -Werror for gcc 4.2.1 for userland

As discussed on arch@, gcc 4.2.1 is on its way out. Turn off Werror on gcc
versions < 5.0 permantly. This will allow older platforms to continue to compile
w/o new errors once we take them out of universe by default. This will also free
developers from chasing down obsolete warnings that produce no beneficial
changes to the source.

Discussed on: arch@
Reviewed by: jhb@, emaste@, pfg@
Differential Revision: https://reviews.freebsd.org/D21378

HardenedBSD/hardenedbsd 48efb04sys/conf kern.pre.mk kmod.mk

Turn off -Werror for gcc 4.2.1

As part of marching gcc 4.2.1 out of the tree, turn off -Werror on gcc 4.2.1
compiles by default. It generates too many false positives and breaks CI
for no benefit.

Discussed on: arch@
Reviewed by: jhb@, emaste@, pfg@
Differential Revision: https://reviews.freebsd.org/D21378

HardenedBSD/hardenedbsd d9b3ef7sys/netinet tcp_input.c

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

* freebsd/11-stable/master:
  MFC r350974:   Save ip_ttl value and restore it after checksum calculation.

HardenedBSD/hardenedbsd c6540b7usr.bin/vtfontcvt vtfontcvt.c

vtfontcvt: improve BDF and hex font parsing

MFC r348661: vtfontcvt: rework height/width setting

Introduce VFNT_MAXDIMENSION to replace bare 128, add set_height, and
consistently use set_height and set_width.

Submitted by:   Dmitry Wagin

MFC r348662: vtfontcvt: include width and height in verbose info

Submitted by:   Dmitry Wagin

MFC r348668: vtfontcvt: zero memory allocated by xmalloc

Submitted by:   Dmitry Wagin

MFC r348692: vtfontcvt: exit on error if the input font has too many glyphs

The kernel has a limit of 131072 glyphs in a font; add the same check to
vtfontcvt so that we won't create a font file that the kernel will not
load.

MFC r348796: vtfontcvt: allow out-of-order glyphs


    [46 lines not shown]
DeltaFile
+258-101usr.bin/vtfontcvt/vtfontcvt.c
+258-1011 files

HardenedBSD/hardenedbsd b5764e1usr.bin/vtfontcvt vtfontcvt.c

MFC r305815: vtfontcvt: remove superfluous newlines in errx messages

HardenedBSD/hardenedbsd 5a70577usr.bin/vtfontcvt vtfontcvt.c

vtfontcvt: improve BDF and hex font parsing

MFC r348661: vtfontcvt: rework height/width setting

Introduce VFNT_MAXDIMENSION to replace bare 128, add set_height, and
consistently use set_height and set_width.

Submitted by:   Dmitry Wagin

MFC r348662: vtfontcvt: include width and height in verbose info

Submitted by:   Dmitry Wagin

MFC r348668: vtfontcvt: zero memory allocated by xmalloc

Submitted by:   Dmitry Wagin

MFC r348692: vtfontcvt: exit on error if the input font has too many glyphs

The kernel has a limit of 131072 glyphs in a font; add the same check to
vtfontcvt so that we won't create a font file that the kernel will not
load.

MFC r348796: vtfontcvt: allow out-of-order glyphs


    [46 lines not shown]
DeltaFile
+258-101usr.bin/vtfontcvt/vtfontcvt.c
+258-1011 files

HardenedBSD/hardenedbsd a9ffd83sys/netinet tcp_input.c

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

* freebsd/12-stable/master:
  MFC r350974:   Since ipvoly is used for checksum calculation, part of original IP   
header is zeroed. This part includes ip_ttl field, that can be used   later in IP_MINTTL 
socket option handling.

HardenedBSD/hardenedbsd 23a4436usr.bin/vtfontcvt vtfontcvt.c

vtfontcvt: simplify rshift_row

We don't need to specify the buffer size in both bytes and bits.

MFC after:      1 week
Sponsored by:   The FreeBSD Foundation