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 489fe9bsys/x86/include bus.h

MFC r347216:
amd64: fix BUS_SPACE_MAXSIZE to 64bit max value.

HardenedBSD/hardenedbsd 3d6dee2share/man/man5 devfs.5, sys/amd64/linux linux_ptrace.c

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

* origin/hardened/current/master:
  Xr make_dev(9) from devfs(5).
  Make linux_ptrace() use linux_msg() instead of printf().

HardenedBSD/hardenedbsd 8bb6645share/man/man5 devfs.5, sys/amd64/linux linux_ptrace.c

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

* freebsd/current/master:
  Xr make_dev(9) from devfs(5).
  Make linux_ptrace() use linux_msg() instead of printf().

HardenedBSD/hardenedbsd ebfe91eshare/man/man5 devfs.5

Xr make_dev(9) from devfs(5).

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd 91c5b29sys/amd64/linux linux_ptrace.c

Make linux_ptrace() use linux_msg() instead of printf().

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd 3e8a932stand/common load_elf.c, stand/powerpc Makefile

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

* origin/hardened/current/master:
  Add my name to the copyright
  Follow up to r348042: cast `aad` to a byte array
  Fix encoding issues with python 3
  stand: TARGET_ARCH is spelled MACHINE_ARCH in Makefiles
  Remove spurious newline
  Fix `KAT(CCM)?Parser` file descriptor leaks
  Squash deprecation warning related to array.array(..).tostring()
  stand/powerpc: Only build loader.kboot for powerpc64
  Include eventhandler.h in more compilation units
  Unbreak the build when `ELF_VERBOSE` is defined after r348005

HardenedBSD/hardenedbsd 130828bstand/common load_elf.c, stand/powerpc Makefile

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

* freebsd/current/master:
  Add my name to the copyright
  Follow up to r348042: cast `aad` to a byte array
  Fix encoding issues with python 3
  stand: TARGET_ARCH is spelled MACHINE_ARCH in Makefiles
  Remove spurious newline
  Fix `KAT(CCM)?Parser` file descriptor leaks
  Squash deprecation warning related to array.array(..).tostring()
  stand/powerpc: Only build loader.kboot for powerpc64
  Include eventhandler.h in more compilation units
  Unbreak the build when `ELF_VERBOSE` is defined after r348005

HardenedBSD/hardenedbsd ccee57ctests/sys/opencrypto cryptodev.py cryptotest.py

Add my name to the copyright

I have contributed a number of changes to these tests over the past few
hundred revisions, and believe I deserve credit for the changes I have
made (plus, the copyright hadn't been updated since 2014).

MFC after:      1 week

HardenedBSD/hardenedbsd b674413tests/sys/opencrypto cryptodev.py

Follow up to r348042: cast `aad` to a byte array

This is not completely necessary today, but this change is being made in a
conservative manner to avoid accidental breakage in the future, if this ever
was a unicode string.

PR:            237403
MFC after:      1 week

HardenedBSD/hardenedbsd 1dc65catests/sys/opencrypto cryptodev.py

Fix encoding issues with python 3

In python 3, the default encoding was switched from ascii character sets to
unicode character sets in order to support internationalization by default.
Some interfaces, like ioctls and packets, however, specify data in terms of
non-unicode encodings formats, either in host endian (`fcntl.ioctl`) or
network endian (`dpkt`) byte order/format.

This change alters assumptions made by previous code where it was all
data objects were assumed to be basestrings, when they should have been
treated as byte arrays. In order to achieve this the following are done:
* str objects with encodings needing to be encoded as ascii byte arrays are
  done so via `.encode("ascii")`. In order for this to work on python 3 in a
  type agnostic way (as it anecdotally varied depending on the caller), call
  `.encode("ascii")` only on str objects with python 3 to cast them to ascii
  byte arrays in a helper function name `str_to_ascii(..)`.
* `dpkt.Packet` objects needing to be passed in to `fcntl.ioctl(..)` are done
  so by casting them to byte arrays via `bytes()`, which calls
  `dpkt.Packet__str__` under the covers and does the necessary str to byte array
  conversion needed for the `dpkt` APIs and `struct` module.

In order to accomodate this change, apply the necessary typecasting for the
byte array literal in order to search `fop.name` for nul bytes.

This resolves all remaining python 2.x and python 3.x compatibility issues on

    [6 lines not shown]

HardenedBSD/hardenedbsd 1d2d2b6stand/powerpc Makefile

stand: TARGET_ARCH is spelled MACHINE_ARCH in Makefiles

Reported by:    imp

HardenedBSD/hardenedbsd c0a79d2tests/sys/opencrypto cryptodev.py

Remove spurious newline

Even though some python styles suggest there should be multiple newlines between
methods/classes, for consistency with the surrounding code, it's best to be
consistent by having merely one newline between each functional block.

MFC after:      1 week

HardenedBSD/hardenedbsd e41352fsys/sys param.h

Bump FreeBSD version after change to struct in linuxkpi from r348035.
DeltaFile
+1-1sys/sys/param.h
+1-11 files

HardenedBSD/hardenedbsd 7e56198sys/compat/linuxkpi/common/include/linux device.h

MFC r347601:
LinuxKPI: Add prepare to pm_ops and bump FreeBSD version.

This patch is part of D19565

Reviewed by:    hps
Approved by:    imp (mentor), hps

HardenedBSD/hardenedbsd 39b4ac4sys/compat/linuxkpi/common/include/linux mm_types.h

MFC r347600:
LinuxKPI: Add vm_fault_t type.

This patch is part of D19565

Reviewed by:    hps
Approved by:    imp (mentor), hps

HardenedBSD/hardenedbsd b426689sys/compat/linuxkpi/common/include/linux timer.h, sys/compat/linuxkpi/common/src linux_compat.c

MFC r347592:
LinuxKPI: Let del_timer return a value to match Linux.

This patch is part of https://reviews.freebsd.org/D19565.

Reviewed by:    hps
Approved by:    imp (mentor), hps

HardenedBSD/hardenedbsd 44c7139tests/sys/opencrypto cryptotest.py cryptodev.py

Fix `KAT(CCM)?Parser` file descriptor leaks

Make `KAT(CCM)?Parser` into a context suite-capable object by implementing
`__enter__` and `__exit__` methods which manage opening up the file descriptors
and closing them on context exit. This implementation was decided over adding
destructor logic to a `__del__` method, as there are a number of issues around
object lifetimes when dealing with threading cleanup, atexit handlers, and a
number of other less obvious edgecases. Plus, the architected solution is more
pythonic and clean.

Complete the iterator implementation by implementing a `__next__` method for
both classes which handles iterating over the data using a generator pattern,
and by changing `__iter__` to return the object instead of the data which it
would iterate over. Alias the `__next__` method to `next` when working with
python 2.x in order to maintain functional compatibility between the two major
versions.

As part of this work and to ensure readability, push the initialization of the
parser objects up one layer and pass it down to a helper function. This could
have been done via a decorator, but I was trying to keep it simple for other
developers to make it easier to modify in the future.

This fixes ResourceWarnings with python 3.

PR:            237403

    [2 lines not shown]

HardenedBSD/hardenedbsd bb62553tests/sys/opencrypto cryptodev.py

Squash deprecation warning related to array.array(..).tostring()

In version 3.2+, `array.array(..).tostring()` was renamed to
`array.array(..).tobytes()`. Conditionally call `array.array(..).tobytes()` if
the python version is 3.2+.

PR:            237403
MFC after:      1 week

HardenedBSD/hardenedbsd 858043dstand/powerpc Makefile

stand/powerpc: Only build loader.kboot for powerpc64

kboot is only made for powerpc64 systems, not 32-bit systems.

This unbreaks the build for powerpcspe.

Reported by:    ngie

HardenedBSD/hardenedbsd 354cc40contrib/libarchive/libarchive archive_read_support_format_rar5.c archive_read_support_format_zip.c, contrib/libarchive/libarchive/test test_read_format_rar5.c test_read_disk_directory_traversals.c

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

* origin/hardened/current/master: (25 commits)
  Followup to r347996
  Add two missing eventhandler.h headers
  HBSD: Resolve merge conflict
  Reverse the bit logic of sc_led_modes_mask.  Instead of initializing it to all-ones then 
carving out blocks of zeroes where specified values go, init it to all-zeroes, put in ones 
where values need to be masked, then use it as value &= ~sc_led_modes_mask.  In addition 
to being more idiomatic, this means everything related to FDT data is initialized to zero 
along with the rest of the softc, and that allows removing some #ifdef FDT sections and 
wrapping the whole muge_set_leds() function in a single ifdef block.
  Allow the end-user to pass along arguments to cryptotest.py via `$CRYPTOTEST_ARGS`
  A MAC adddress from FDT data should override anything stored in eeprom or OTP registers 
(because the user is in control of the fdt data).  Remove the early returns from the code 
that tries to find a good mac address, so that the execution always flows through the 
routine to get an address from FDT data last, when on FDT-enabled systems.
  Don't detour through sc->sc_ue when we have a direct pointer to ue in hand already.  
Also, shorten a variable name for nicer line-wrapping.
  Use the new usb fdt support functions to locate the proper fdt node for the device 
instance, and to get the MAC address for the device instance. The ad-hoc code this 
replaces could find the wrong instance if multiple devices were present.
  Hook DEFINE_IFUNC.9 up to the build.
  mips: remove 16-byte alignment from .init and .fini epilogues

    [12 lines not shown]

HardenedBSD/hardenedbsd 3d54d87sys/conf kern.pre.mk

MFC r347570:
Specify -z notext when building with -z ifunc-noplt.

HardenedBSD/hardenedbsd 1dc5f4cshare/man/man9 DEFINE_IFUNC.9, stand/powerpc/kboot main.c

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

* freebsd/current/master:
  Followup to r347996
  Add two missing eventhandler.h headers
  Reverse the bit logic of sc_led_modes_mask.  Instead of initializing it to all-ones then 
carving out blocks of zeroes where specified values go, init it to all-zeroes, put in ones 
where values need to be masked, then use it as value &= ~sc_led_modes_mask.  In addition 
to being more idiomatic, this means everything related to FDT data is initialized to zero 
along with the rest of the softc, and that allows removing some #ifdef FDT sections and 
wrapping the whole muge_set_leds() function in a single ifdef block.
  Allow the end-user to pass along arguments to cryptotest.py via `$CRYPTOTEST_ARGS`
  A MAC adddress from FDT data should override anything stored in eeprom or OTP registers 
(because the user is in control of the fdt data).  Remove the early returns from the code 
that tries to find a good mac address, so that the execution always flows through the 
routine to get an address from FDT data last, when on FDT-enabled systems.
  Don't detour through sc->sc_ue when we have a direct pointer to ue in hand already.  
Also, shorten a variable name for nicer line-wrapping.
  Use the new usb fdt support functions to locate the proper fdt node for the device 
instance, and to get the MAC address for the device instance. The ad-hoc code this 
replaces could find the wrong instance if multiple devices were present.
  Hook DEFINE_IFUNC.9 up to the build.
  mips: remove 16-byte alignment from .init and .fini epilogues
  muge: update FDT LED configuration
  [PowerPC64] stand: fix build using clang 8 as compiler

    [7 lines not shown]

HardenedBSD/hardenedbsd 0e503casys/arm/ti/am335x am335x_lcd.c tda19988.c, sys/compat/linuxkpi/common/src linux_compat.c

Include eventhandler.h in more compilation units

This was enumerated with exhaustive search for sys/eventhandler.h includes,
cross-referenced against EVENTHANDLER_* usage with the comm(1) utility.  Manual
checking was performed to avoid redundant includes in some drivers where a
common os_bsd.h (for example) included sys/eventhandler.h indirectly, but it is
possible some of these are redundant with driver-specific headers in ways I
didn't notice.

(These CUs did not show up as missing eventhandler.h in tinderbox.)

X-MFC-With:     r347984

HardenedBSD/hardenedbsd 4ac8e90stand/common load_elf.c

Unbreak the build when `ELF_VERBOSE` is defined after r348005

This change properly terminates the formatting string quote modification done
in r348005, which is triggered when `ELF_VERBOSE` is defined.

MFC with:       r348005
Reported by:    ci (amd64, gcc)

HardenedBSD/hardenedbsd dfc6cdftests/sys/opencrypto cryptotest.py

Followup to r347996

Replace uses of `foo.encode("hex")` with `binascii.hexlify(foo)` for forwards
compatibility between python 2.x and python 3.

PR:            237403
MFC after:      1 week

HardenedBSD/hardenedbsd 2e158b5sys/dev/netmap netmap_freebsd.c, sys/netinet/netdump netdump_client.c

Add two missing eventhandler.h headers

These are obviously missing from the .c files, but don't show up in any
tinderbox configuration (due to latent header pollution of some kind).  It
seems some configurations don't have this pollution, and the includes are
obviously missing, so go ahead and add them.

Reported by:    Peter Jeremy <peter AT rulingia.com>
X-MFC-With:     r347984

HardenedBSD/hardenedbsd 925eb14sys/kern kern_exec.c

HBSD: Resolve merge conflict

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

HardenedBSD/hardenedbsd eafeb68sys/sys shm.h msg.h, usr.bin/ipcrm ipcrm.c

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

* origin/hardened/11-stable/master:
  MFC r329348 (by brooks): Get rid of the requirement to include SysV IPC headers with 
_KERNEL defined in ipcrm by introducing _WANT_SYSVxxx_INTERNALS defines.

HardenedBSD/hardenedbsd e8ff0bdsys/sys shm.h msg.h, usr.bin/ipcrm ipcrm.c

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

* freebsd/11-stable/master:
  MFC r329348 (by brooks): Get rid of the requirement to include SysV IPC headers with 
_KERNEL defined in ipcrm by introducing _WANT_SYSVxxx_INTERNALS defines.

HardenedBSD/hardenedbsd f8c4665contrib/libarchive/libarchive archive_read_support_format_rar5.c archive_read_support_format_zip.c, contrib/libarchive/libarchive/test test_read_format_rar5.c test_read_disk_directory_traversals.c

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

Conflicts:
        sys/kern/kern_exec.c (unresolved)

HardenedBSD/hardenedbsd c2122bdsys/dev/usb/net if_muge.c

Reverse the bit logic of sc_led_modes_mask.  Instead of initializing it to
all-ones then carving out blocks of zeroes where specified values go, init
it to all-zeroes, put in ones where values need to be masked, then use it
as value &= ~sc_led_modes_mask.  In addition to being more idiomatic, this
means everything related to FDT data is initialized to zero along with the
rest of the softc, and that allows removing some #ifdef FDT sections and
wrapping the whole muge_set_leds() function in a single ifdef block.

This also deletes the early-out from muge_set_leds() when an eeprom exists.
Even if there is an eeprom with led config in it, the fdt data (if present)
should override that, because the user is in control of the fdt data.

HardenedBSD/hardenedbsd e2fe1e7tests/sys/opencrypto runtests.sh

Allow the end-user to pass along arguments to cryptotest.py via `$CRYPTOTEST_ARGS`

This allows someone to use `-v` to dump out standard output.

HardenedBSD/hardenedbsd 879af44sys/dev/usb/net if_muge.c

A MAC adddress from FDT data should override anything stored in eeprom or
OTP registers (because the user is in control of the fdt data).  Remove the
early returns from the code that tries to find a good mac address, so that
the execution always flows through the routine to get an address from FDT
data last, when on FDT-enabled systems.

HardenedBSD/hardenedbsd 3da531dsys/dev/usb/net if_muge.c

Don't detour through sc->sc_ue when we have a direct pointer to ue in hand
already.  Also, shorten a variable name for nicer line-wrapping.

No functional changes.

HardenedBSD/hardenedbsd 7c799c1sys/dev/usb/net if_muge.c

Use the new usb fdt support functions to locate the proper fdt node for
the device instance, and to get the MAC address for the device instance.
The ad-hoc code this replaces could find the wrong instance if multiple
devices were present.

HardenedBSD/hardenedbsd fdf35bclibexec/rc rc.conf, sbin/ifconfig ifconfig.8

MFC r347963:

Change ed(4), ep(4), and fxp(4) examples to em(4).

ed(4) and ep(4) will be removed in FreeBSD 13. fxp(4) remains
popular in older systems, but isn't as future proof as em(4).

Reviewed by:    bz, jhb
Differential Revision:  https://reviews.freebsd.org/D20311

HardenedBSD/hardenedbsd cd58dbbshare/man/man9 Makefile

Hook DEFINE_IFUNC.9 up to the build.

Reported by:    pluknet
MFC with:       r348003

HardenedBSD/hardenedbsd a888be5lib/csu/mips crtn.S

mips: remove 16-byte alignment from .init and .fini epilogues

The .init and .fini epilogues from crtn should be placed immediately
after any instructions in .init and .fini sections from the linked
objects.  Using 16-byte alignment for the epilogues on MIPS was a bug,
but it did not cause any issue with GNU ld as GNU ld (2.17.50) fills the
padding with NOPs.

Current versions of LLD fill any padding between different object files
with trap instructions.  Inserting trap padding prior to the .init/.fini
epilogue is undesriable as the resulting binary will crash at runtime.

The .init and .fini sections in object files linked between crti and
crtn must already be a multiple of the instruction size and so no
alignment directive is required in crtn.  Indeed, other architectures
(except sparc64) do not specify alignment in their crtn implementations.

Reported by:    arichardson
Reviewed by:    andrew
Event:         Waterloo Hackathon 2019
Differential Revision:  https://reviews.freebsd.org/D18291

HardenedBSD/hardenedbsd 5c11907sys/dev/usb/net if_muge.c if_mugereg.h

muge: update FDT LED configuration

Also use LED mode settings from the FDT to set the PHY.
From v3 of the patch submitted in the PR.

I moved the sc_led_modes and sc_led_modes_mask default setting outside
of the #ifdef FDT case.

PR:            237325
Submitted by:   Ralf <iz-rpi03 at hs-karlsruhe.de>
Reviewed by:    ian
MFC after:      2 weeks
MFC with:       r348001
Event:         Waterloo Hackathon 2019
Differential Revision:  https://reviews.freebsd.org/D20325

HardenedBSD/hardenedbsd cc2e8efcddl/contrib/opensolaris/lib/libzfs/common libzfs_diff.c, stand/common load_elf.c

[PowerPC64] stand: fix build using clang 8 as compiler

This change fixes "stand" build issues when using clang 8
as compiler.

Submitted by:   alfredo.junior_eldorado.org.br
Reviewed by:    jhibbits
Differential Revision: https://reviews.freebsd.org/D20026

HardenedBSD/hardenedbsd ecca595sys/kern kern_kcov.c

kcov depends on eventhandler.h.

MFC after:      3 days

HardenedBSD/hardenedbsd 56e7fdbshare/man/man9 DEFINE_IFUNC.9

Add a man page for DEFINE_IFUNC.

Reviewed by:    kib
Discussed with: emaste
MFC after:      2 weeks
Event:         Waterloo Hackathon 2019
Differential Revision:  https://reviews.freebsd.org/D20310

HardenedBSD/hardenedbsd 535e3bfshare/man/man9 DRIVER_MODULE.9

Typo.

MFC after:      3 days

HardenedBSD/hardenedbsd c5c726fsys/dev/usb/net if_muge.c

muge: configure LEDs per dtb (for Raspberry Pi 3B+)

Also apply some style(9) and remove the message about EEPROM configuration
(if there's an EEPROM the hardware handles LED configuration itself).

PR:            237325
Reviewed by:    ian
MFC after:      2 weeks
Submitted by:   Ralf <iz-rpi03 at hs-karlsruhe.de>

HardenedBSD/hardenedbsd 9fbc1dftests/sys/sys splay_test.c rb_test.c

Improve tree(3) tests by using ATF_REQUIRE where applicable.

MFC after:      2 weeks
Sponsored by:   Klara Inc.

HardenedBSD/hardenedbsd 08c31a3lib/libarchive/tests Makefile

Install missing data file for
lib.libarchive.functional_test.test_read_format_zip_utf8_paths

MFC after:      2 weeks (with r347989)
Sponsored by:   The FreeBSD Foundation

HardenedBSD/hardenedbsd c94c62bsys/mips/mediatek mtk_spi_v1.c

[mediatek] Add support for non-flash devices on the SPI bus of the Mediatek SoCs.

The existing SPI support only worked for directly attached flash chips.
it didn't implement clock programming or chipselect.  It also supports
transfers with unbalanced tx/rx command sizes.

Submitted by:   <yamori813 at yahoo.co.jp>
Differential Revision:  https://reviews.freebsd.org/D20101

HardenedBSD/hardenedbsd b833ad9tests/sys/opencrypto cryptotest.py cryptodev.py

Replace uses of `foo.(de|en)code('hex')` with `binascii.(un)?hexlify(foo)`

Python 3 no longer doesn't support encoding/decoding hexadecimal numbers using
the `str.format` method. The backwards compatible new method (using the
binascii module/methods) is a comparable means of converting to/from
hexadecimal format.

In short, the functional change is the following:
* `foo.decode('hex')` -> `binascii.unhexlify(foo)`
* `foo.encode('hex')` -> `binascii.hexlify(foo)`

While here, move the dpkt import in `cryptodev.py` down per PEP8, so it comes
after the standard library provided imports.

PR:            237403
MFC after:      1 week