HardenedBSD/hardenedbsd bc7bf39gnu/usr.bin/binutils/objdump Makefile

HBSD: Revert "Fix GNU objdump build under WITH_PIE"

This reverts commit 139b9f01ca1bfc198fce7c4a3e5fe40388e3fc48.
HardenedBSD doesn't use separate libraries to link with PIE.

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

HardenedBSD/hardenedbsd fbd848bgnu/usr.bin/binutils/as Makefile, gnu/usr.bin/binutils/ld Makefile

HBSD: Revert "Apply WITH_PIE changes to other binutils components"

This reverts commit 4c4acf7e5f1d176bd3bf157a32241b18b0429a44.
HardenedBSD doesn't use separate libraries for linking with PIE.

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

HardenedBSD/hardenedbsd af3cdb5cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/syscall tst.args.c, contrib/netbsd-tests/lib/libpthread t_cond.c

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

* freebsd/12-stable/master:
  MFC 345379:  Bump the IMAGE_SIZE for arm64 SoC images to prevent failures due  to full 
filesystem.  This makes the size of the arm64 SoC images  consistent with armv6 and armv7.
  MFC r344823: Show wiring state of map entries in procstat -v.
  MFC r344935: Have pthread_cond_destroy() return EBUSY if the condvar has waiters.
  MFC r345355: Ensure that we use a 64-bit value for the last mmap() argument.

HardenedBSD/hardenedbsd 4cbe776release/arm64 PINE64-LTS.conf PINE64.conf

MFC 345379:
 Bump the IMAGE_SIZE for arm64 SoC images to prevent failures due
 to full filesystem.  This makes the size of the arm64 SoC images
 consistent with armv6 and armv7.

Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd fb1bcb6sys/kern kern_proc.c, sys/sys user.h

MFC r344823:
Show wiring state of map entries in procstat -v.

HardenedBSD/hardenedbsd be3afe4contrib/netbsd-tests/lib/libpthread t_cond.c, lib/libthr/thread thr_cond.c

MFC r344935:
Have pthread_cond_destroy() return EBUSY if the condvar has waiters.

PR:     234805

HardenedBSD/hardenedbsd 1bdedfecddl/contrib/opensolaris/cmd/dtrace/test/tst/common/syscall tst.args.c

MFC r345355:
Ensure that we use a 64-bit value for the last mmap() argument.

HardenedBSD/hardenedbsd 5a05176contrib/libarchive/libarchive archive_entry.c archive_write_disk_posix.c, contrib/libarchive/libarchive/test test_read_format_zip.c

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

* origin/hardened/current/master:
  Fix another type of buffer overrun for segmented modes.  The buffer index was not taken 
modulo the window size in VGLClear().
  Update vendor/libarchive/dist to git 3c079320b23ddf5ef38c443569c25898ad79ddb9
  Fix the handling of fragmented unordered messages when using DATA chunks and 
FORWARD-TSN.
  run(4): merge some common TSF-related code into run_disable_tsf()
  The Atheros AR7241 has 20 GPIO pins
  Make TMPFS_PAGES_MINRESERVED a kernel option
  Update vendor/libarchive/dist to git 3532bc32819b14bfd8a3a5e3d3554ce14d939940

HardenedBSD/hardenedbsd da57b4fcontrib/libarchive/libarchive archive_entry.c archive_write_disk_posix.c, contrib/libarchive/libarchive/test test_read_format_zip.c

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

* freebsd/current/master:
  Fix another type of buffer overrun for segmented modes.  The buffer index was not taken 
modulo the window size in VGLClear().
  Update vendor/libarchive/dist to git 3c079320b23ddf5ef38c443569c25898ad79ddb9
  Fix the handling of fragmented unordered messages when using DATA chunks and 
FORWARD-TSN.
  run(4): merge some common TSF-related code into run_disable_tsf()
  The Atheros AR7241 has 20 GPIO pins
  Make TMPFS_PAGES_MINRESERVED a kernel option
  Update vendor/libarchive/dist to git 3532bc32819b14bfd8a3a5e3d3554ce14d939940

HardenedBSD/hardenedbsd 436a317contrib/libarchive/libarchive archive_entry.c archive_write_disk_posix.c, contrib/libarchive/libarchive/test test_read_format_zip.c test_read_format_rar5.c

MFV r345495:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1153: fixed 2 bugs in ZIP reader [1]
  PR #1143: ensure archive_read_disk_entry_from_file() uses ARCHIVE_READ_DISK
  Changes to file flags code, support more file flags on FreeBSD:
    UF_OFFLINE, UF_READONLY, UF_SPARSE, UF_REPARSE, UF_SYSTEM
    UF_ARCHIVE is not supported by intention (yet)

PR:            236300
MFC after:      2 weeks

HardenedBSD/hardenedbsd 67852a4lib/libvgl simple.c

Fix another type of buffer overrun for segmented modes.  The buffer index
was not taken modulo the window size in VGLClear().

Segmented modes also need a kernel fix to almost work.  The ioctl to set
the window origin is broken.

These bugs are rarely problems since non-VESA modes only need
segmentation to support multiple pages but libvgl doesn't support
multiple pages and treats these modes as non-segmented, and VESA modes
are usually mapped linearly except on old hardware so they really are
non-segmented.

HardenedBSD/hardenedbsd 360aa1abuild/ci travis_ci.sh, libarchive archive_entry.c archive_write_disk_posix.c

Update vendor/libarchive/dist to git 3c079320b23ddf5ef38c443569c25898ad79ddb9

Relevant vendor changes:
  PR #1153: fixed 2 bugs in ZIP reader
  PR #1143: ensure archive_read_disk_entry_from_file() uses ARCHIVE_READ_DISK
  Changes to file flags code, support more file flags on FreeBSD:
    UF_OFFLINE, UF_READONLY, UF_SPARSE, UF_REPARSE, UF_SYSTEM
    UF_ARCHIVE is not supported by intention (yet)

HardenedBSD/hardenedbsd e89e192sys/netinet sctp_indata.c

Fix the handling of fragmented unordered messages when using DATA chunks
and FORWARD-TSN.

This bug was reported in https://github.com/sctplab/usrsctp/issues/286
for the userland stack.

This is joint work with rrs@.

MFC after:             1 week

HardenedBSD/hardenedbsd 69cab2esys/dev/usb/wlan if_run.c

run(4): merge some common TSF-related code into run_disable_tsf()

No functional change intended.

MFC after:      5 days

HardenedBSD/hardenedbsd 17b9e44sys/mips/atheros ar71xx_gpio.c ar71xx_gpiovar.h

The Atheros AR7241 has 20 GPIO pins

AR724X_GPIO_PINS used for this family is defined as 18
The datasheet for the AR7241 describes 20 pins, allow all to be used.

Submitted by:   Hiroki Mori <yamori813 at yahoo.co.jp>
Reviewed by:    mizhka
Differential Revision:  https://reviews.freebsd.org/D17580

HardenedBSD/hardenedbsd 771a759sys/conf options, sys/fs/tmpfs tmpfs_vfsops.c tmpfs.h

Make TMPFS_PAGES_MINRESERVED a kernel option

TMPFS_PAGES_MINRESERVED controls how much memory is reserved for the system
and not used by tmpfs.

On very small memory systems, the default value may be too high and this
prevents these small memory systems from using reroot, which is required
for them to install firmware updates.

Submitted by:   Hiroki Mori <yamori813 at yahoo.co.jp>
Reviewed by:    mizhka
Differential Revision:  https://reviews.freebsd.org/D13583

HardenedBSD/hardenedbsd 78fa3c7gnu/usr.bin/binutils/as Makefile, gnu/usr.bin/binutils/ld Makefile

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

* origin/hardened/current/master:
  Apply WITH_PIE changes to other binutils components
  Fix GNU objdump build under WITH_PIE

HardenedBSD/hardenedbsd 0e6029cgnu/usr.bin/binutils/as Makefile, gnu/usr.bin/binutils/ld Makefile

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

* freebsd/current/master:
  Apply WITH_PIE changes to other binutils components
  Fix GNU objdump build under WITH_PIE

HardenedBSD/hardenedbsd 529e866sys/amd64/linux linux_systrace_args.c, sys/amd64/linux32 linux32_systrace_args.c linux32_proto.h

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

* origin/hardened/current/master: (35 commits)
  Add description for WITHOUT_RETPOLINE
  Oops, my previous commit to libvgl was missing the change of VGLSetBorder() to match the 
change in its declaration.  Change the declaration back to "byte color" since setting of 
the border color is not supported for more than 256 colors.
  Add event table decoding for SAS Broadcast Primitive events.
  Fix the type of the color args for VGLMouseFreeze(), VGLBitmapPutChar(), 
VGLBitmapString() and VGLSetBorder() so as to not truncate to 8 bits.
  Add support for arbitrary font widths.  Only multiples of 8 were supported.
  Fix a transposition error from the previous commit
  Fix reading of pixels in (4 and 8-plane) planar modes.
  Support device-independent labels for geom_flashmap slices.
  r329522 created problemss with commands that enter the TIMEDOUT state but are 
successfully returned by the card (usually due to an abort being issued as part of timeout 
recovery). Remove what amounts to an insufficient KASSERT, and don't overwrite the state 
value. State should probably be re-designed, and that will be done with a future commit.
  Fix buffer overruns in modes with color depth more than 8.
  Distinguish between "no partition" and "choose best partition" with a constant.
  Revert accidental change that should not have been included in r345475. I had changed 
this value as part of a local experiment, and neglected to change it back before 
committing the other changes.
  Truncate a too-long interrupt handler name when there is only one handler.

    [12 lines not shown]

HardenedBSD/hardenedbsd 4c4acf7gnu/usr.bin/binutils/as Makefile, gnu/usr.bin/binutils/ld Makefile

Apply WITH_PIE changes to other binutils components

Followon to r345489, explicitly specified bare .a libraries need
${PIE_SUFFIX} (although these still built).

MFC with:       r345489

HardenedBSD/hardenedbsd 139b9f0gnu/usr.bin/binutils/objdump Makefile

Fix GNU objdump build under WITH_PIE

Explicitly specified bare .a libraries need ${PIE_SUFFIX}.

Reported by:    David E. Cross, on twitter

HardenedBSD/hardenedbsd 9629806sys/amd64/linux linux_systrace_args.c linux_syscalls.c, sys/amd64/linux32 linux32_systrace_args.c linux32_proto.h

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

* freebsd/current/master:
  Add description for WITHOUT_RETPOLINE
  Oops, my previous commit to libvgl was missing the change of VGLSetBorder() to match the 
change in its declaration.  Change the declaration back to "byte color" since setting of 
the border color is not supported for more than 256 colors.
  Add event table decoding for SAS Broadcast Primitive events.
  Fix the type of the color args for VGLMouseFreeze(), VGLBitmapPutChar(), 
VGLBitmapString() and VGLSetBorder() so as to not truncate to 8 bits.
  Add support for arbitrary font widths.  Only multiples of 8 were supported.
  Fix a transposition error from the previous commit
  Fix reading of pixels in (4 and 8-plane) planar modes.
  Support device-independent labels for geom_flashmap slices.
  r329522 created problemss with commands that enter the TIMEDOUT state but are 
successfully returned by the card (usually due to an abort being issued as part of timeout 
recovery). Remove what amounts to an insufficient KASSERT, and don't overwrite the state 
value. State should probably be re-designed, and that will be done with a future commit.
  Fix buffer overruns in modes with color depth more than 8.
  Distinguish between "no partition" and "choose best partition" with a constant.
  Revert accidental change that should not have been included in r345475. I had changed 
this value as part of a local experiment, and neglected to change it back before 
committing the other changes.
  Truncate a too-long interrupt handler name when there is only one handler.
  Fix libvgl to not always fail to initialize due to its invalid mmap() args (neither 

    [11 lines not shown]

HardenedBSD/hardenedbsd 5e1ca3dtools/build/options WITHOUT_RETPOLINE

Add description for WITHOUT_RETPOLINE

Not used by default at the moment, but added for the benefit of
downstream projects/branches with different options.

HardenedBSD/hardenedbsd fe5436cbin/sh sh.1 jobs.c, bin/sh/tests/execution Makefile pipefail6.42

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

* freebsd/12-stable/master:
  MFC r344502: sh: Add set -o pipefail

HardenedBSD/hardenedbsd 038c461bin/sh sh.1 jobs.c, bin/sh/tests/execution Makefile pipefail6.42

MFC r344502: sh: Add set -o pipefail

The pipefail option allows checking the exit status of all commands in a
pipeline more easily, at a limited cost of complexity in sh itself. It works
similarly to the option in bash, ksh93 and mksh.

Like ksh93 and unlike bash and mksh, the state of the option is saved when a
pipeline is started. Therefore, even in the case of commands like
  A | B &
a later change of the option does not affect the exit status, the same way
  (A | B) &
works.

Since SIGPIPE is not handled specially, more work in the script is required
for a proper exit status for pipelines containing commands such as head that
may terminate successfully without reading all input. This can be something
like

(
        cmd1
        r=$?
        if [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = PIPE ]; then
               exit 0
        else
               exit "$r"

    [5 lines not shown]

HardenedBSD/hardenedbsd facddabusr.bin/proccontrol proccontrol.c

HBSD: Resolve merge conflict

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

HardenedBSD/hardenedbsd b43c595sys/amd64/amd64 vm_machdep.c pmap.c, sys/compat/ndis kern_windrv.c

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

Conflicts:
        usr.bin/proccontrol/proccontrol.c (unresolved)

HardenedBSD/hardenedbsd 603951clib/libvgl vgl.h vgl.3

Oops, my previous commit to libvgl was missing the change of VGLSetBorder()
to match the change in its declaration.  Change the declaration back to
"byte color" since setting of the border color is not supported for more
than 256 colors.

HardenedBSD/hardenedbsd c57accdsys/dev/mpr mpr_table.c, sys/dev/mps mps_table.c

Add event table decoding for SAS Broadcast Primitive events.

HardenedBSD/hardenedbsd c8b259dlib/libvgl vgl.3 vgl.h

Fix the type of the color args for VGLMouseFreeze(), VGLBitmapPutChar(),
VGLBitmapString() and VGLSetBorder() so as to not truncate to 8 bits.

Complete the corresponding fix for VGLGetXY() and VGLPutXY() (parts
of the man page were out of date).

HardenedBSD/hardenedbsd 59d01edlib/libvgl text.c

Add support for arbitrary font widths.  Only multiples of 8 were supported.

Since the font format is undocumented, it is unclear how non-multiples
of 8 should be padded to bytes in the font file.  Use the same
representation as bdf text format (big- endian, with padding in the
lower bits).
DeltaFile
+17-13lib/libvgl/text.c
+17-131 files

HardenedBSD/hardenedbsd 15a481esys/dev/mps mps.c

Fix a transposition error from the previous commit
DeltaFile
+1-1sys/dev/mps/mps.c
+1-11 files

HardenedBSD/hardenedbsd ba34288lib/libvgl simple.c

Fix reading of pixels in (4 and 8-plane) planar modes.

There seems to be no alternative to reading each plane independently using
3 slow i/o's per plane (this delivers 8 nearby pixels, but we don't buffer
the results so run 8 times slower than necessary.

All the code for this was there, but it was ifdefed out and replaced by
simpler code that cannot work in planar modes.  The ifdefed out code
was correct except it was missing a volatile declaration, so compilers
optimized the multiple dummy reads in it to a single read.

HardenedBSD/hardenedbsd 2b09212sys/conf files, sys/geom geom_flashmap.h geom_flashmap.c

Support device-independent labels for geom_flashmap slices.

While geom_flashmap has always supported label names for its slices, it does
so by appending "s.labelname" to the provider device name, meaning you still
have to know the name and unit of the hardware device to use the labels.

These changes add support for device-independent geom_flashmap labels, using
the standard geom_label infrastructure. geom_flashmap now creates a softc
struct attached to its geom, and as it creates slices it stores the label
into an array in the softc. The new geom_label_flashmap uses those labels
when tasting a geom_flashmap provider.

Differential Revision:  https://reviews.freebsd.org/D19535

HardenedBSD/hardenedbsd 136e1d1sys/dev/mpr mpr.c, sys/dev/mps mps.c

r329522 created problemss with commands that enter the TIMEDOUT state but
are successfully returned by the card (usually due to an abort being issued
as part of timeout recovery). Remove what amounts to an insufficient
KASSERT, and don't overwrite the state value. State should probably be
re-designed, and that will be done with a future commit.

Reported by:    phk, bei.io
Reviewed by:    imp, mav
Differential Revision:  D19677

HardenedBSD/hardenedbsd 37338fblib/libvgl main.c bitmap.c

Fix buffer overruns in modes with color depth more than 8.

Support for 16-bit and 32-bit Truecolor modes was supposed to be
complete in r70991 of main.c and in nearby revisions for other files, but
it was broken by the overruns in most cases (all cases were the mouse
is enabled, and most cases where bitmaps are used).  r70991 also
uninintentionally added support for depths 9-15, 17-23 and 25-31.
Depth 24 was more obviously broken and its support is ifdefed out.  In
the other ranges, only depth 15 is common.  It was broken by buffer
overruns in all cases.

bitmap.c:
- the static buffer was used even when it was too small (but it was
  large enough to often work accidentally in depth 16)
- the size of the dynamically allocated buffer was too small
- the sizing info bitmap->PixelBytes was not inititialzed in the bitmap
  constructor.  It often ended up as 0 for MEMBUFs, so using it in more
  places gave more null pointer accesses.  (It is per-bitmap, but since
  conversion between bitmaps of different depths is not supported (except
  from 4 bits by padding to 8), it would work better if it were global.)

main.c:
- depths were rounded down instead of up to a multiple of 8, so PixelBytes
  was 1 too small for depths above 8 except 16, 24 and 32.
- PixelBytes was not initialized for 4-bit planar modes.  It isn't really

    [17 lines not shown]

HardenedBSD/hardenedbsd 59f925cstand/common disk.h disk.c, stand/efi/loader main.c

Distinguish between "no partition" and "choose best partition" with a constant.

The values of the d_slice and d_partition fields of a disk_devdesc have a
few values with special meanings in the disk_open() routine. Through various
evolutions of the loader code over time, a d_partition value of -1 has
meant both "use the first ufs partition found in the bsd label" and "don't
open a bsd partition at all, open the raw slice."

This defines a new special value of -2 to mean open the raw slice, and it
gives symbolic names to all the special values used in d_slice and
d_partition, and adjusts all existing uses of those fields to use the new
constants.

The phab review for this timed out without being accepted, but I'm still
citing it below because there is useful commentary there.

Differential Revision:  https://reviews.freebsd.org/D19262

HardenedBSD/hardenedbsd 8d5378dsys/kern kern_intr.c

Revert accidental change that should not have been included in r345475.
I had changed this value as part of a local experiment, and neglected to
change it back before committing the other changes.

HardenedBSD/hardenedbsd 3ca1299sys/kern kern_intr.c

Truncate a too-long interrupt handler name when there is only one handler.

There are only 19 bytes available for the name of an interrupt plus the
name(s) of handlers/drivers using it. There is a mechanism from the days of
shared interrupts that replaces some of the handler names with '+' when they
don't all fit into 19 bytes.

In modern times there is typically only one device on an interrupt, but long
device names are the norm, especially with embedded systems. Also, in systems
with multiple interrupt controllers, the names of the interrupts themselves
can be long. For example, 'gic0,s54: imx6_anatop0' doesn't fit, and
replacing the device driver name with a '+' provides no useful info at all.

When there is only one handler but its name was too long to fit, this
change truncates enough leading chars of the handler name (replacing them
with a '-' char to indicate that some chars are missing) to use all 19
bytes, preserving the unit number typically on the end of the name. Using
the prior example, this results in: 'gic0,s54:-6_anatop0' which provides
plenty of info to figure out which device is involved.

PR:            211946
Reviewed by:    gonzo@ (prior version without the '-' char)
Differential Revision:  https://reviews.freebsd.org/D19675
DeltaFile
+14-4sys/kern/kern_intr.c
+14-41 files

HardenedBSD/hardenedbsd c73fff2sys/vm vm_map.c

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+0-52sys/vm/vm_map.c
+0-521 files

HardenedBSD/hardenedbsd dd24fcbshare/man/man5 rc.conf.5, sys/dev/cfi cfi_core.c

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

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

HardenedBSD/hardenedbsd 068eaf9lib/libvgl main.c

Fix libvgl to not always fail to initialize due to its invalid mmap()
args (neither MAP_PRIVATE nor MAP_SHARED).  It was broken in r271635
and/or r271724 by stricter checking.  The compatibility code in r271724
doesn't work for my old binaries (actually new binaries with old
libraries).

PR:            needed to test the fix for PR 162373
DeltaFile
+2-2lib/libvgl/main.c
+2-21 files

HardenedBSD/hardenedbsd 7dbe184sys/compat/linux linux_fork.c

Whitespace cleanup (annoying).

MFC after:      1 month

HardenedBSD/hardenedbsd 502aa03sys/amd64/linux linux_systrace_args.c linux_syscalls.c, sys/amd64/linux32 linux32_systrace_args.c linux32_proto.h

Regen from r345471.

MFC after:      1 month

HardenedBSD/hardenedbsd 8232981sys/amd64/linux syscalls.master, sys/amd64/linux32 syscalls.master linux32_dummy.c

Update syscall.master to 5.0.

For 32-bit Linuxulator, ipc() syscall was historically
the entry point for the IPC API. Starting in Linux 4.18, direct
syscalls are provided for the IPC. Enable it.

MFC after:      1 month

HardenedBSD/hardenedbsd ed0d399sys/amd64/linux32 linux32_systrace_args.c linux32_proto.h, sys/i386/linux linux_systrace_args.c linux_proto.h

Regen for r345469 (shmat()).

MFC after:      1 month

HardenedBSD/hardenedbsd 70fa682sys/amd64/linux32 linux32_machdep.c syscalls.master, sys/compat/linux linux_ipc.c linux_ipc.h

Linux between 4.18 and 5.0 split IPC system calls.
In preparation for doing this in the Linuxulator modify our linux_shmat()
to match actual Linux shmat() system call.

MFC after:      1 month

HardenedBSD/hardenedbsd 12f579bsys/amd64/linux linux_machdep.c

Revert r313993.
AMD64_SET_**BASE expects a pointer to a pointer, we just passing in the pointer value 
itself.

Set PCB_FULL_IRET for doreti to restore %fs, %gs and its correspondig base.

PR:            225105
Reported by:    trasz@
MFC after:      1 month

HardenedBSD/hardenedbsd 1ff39c3sys/netinet sctp_output.c sctputil.c

Fix build issue for the userland stack.
Joint work with rrs@.

MFC after:             1 week

HardenedBSD/hardenedbsd aa72882sys/netinet sctp_output.c sctp_structs.h

Fox more signed unsigned issues. This time on the send path.
This is joint work with rrs@ and was found by running syzkaller.

MFC after:             1 week