#
2a44cccd |
| 11-Jan-2025 |
Alexander Leidinger <Alexander@Leidinger.net> |
Add option to clear caller-used registers on function return.
The WITH_ZEROREGS option for src.conf will zero caller-used register contents just before returning from a function, ensuring that tempo
Add option to clear caller-used registers on function return.
The WITH_ZEROREGS option for src.conf will zero caller-used register contents just before returning from a function, ensuring that temporary values are not leaked beyond the function boundary. This means that register contents are less likely to be available for side channel attacks and information exposures.
It reduces all except 1 of the simple "write-what-where" ROP gadgets in /lib: grep "Gadget found" /tmp/before_lib* | wc -l 197 grep "Gadget found" /tmp/after_lib* | wc -l 1 grep "Gadget found" /tmp/after_lib* /tmp/after_libbsdxml.so.4.txt: [+] Gadget found: 0x1b3f1 mov qword ptr [rdi], rcx ; pop rbp ; ret
To reproduce: for lib in *.so.*; do echo $lib: ROPgadget --ropchain --binary /tmp/be_mount.Sx87/lib/$lib | sed -n '/Step 1/,/Step 2/p' >! /tmp/before_$lib.txt ROPgadget --ropchain --binary $lib | sed -n '/Step 1/,/Step 2/p' >! /tmp/after_$lib.txt done
Additionally, in some cases this reduces the number of all ROP gadgets (quick check with /libs only): libalias.so.7: reduction 10.000% libavl.so.2: reduction 13.900% libbsdxml.so.4: reduction 37.500% libc.so.7: reduction 10.000% libc++.so.1: reduction 14.800% libcam.so.7: reduction 50.700% libcap_netdb.so.1: reduction 5.800% libcasper.so.1: reduction 14.600% libcrypto.so.30: reduction 7.500% libdtrace.so.2: reduction 3.900% libelf.so.2: reduction 15.800% libgcc_s.so.1: reduction 32.700% libibverbs.so.1: reduction 5.300% libicp.so.3: reduction 2.100% libipt.so.0: reduction 28.200% libirdma.so.1: reduction 1.600% libkiconv.so.4: reduction 0% libm.so.5: reduction 21.900% libmd.so.6: reduction 0% libmd.so.7: reduction 3.100% libncursesw.so.9: reduction 11.200% libnvpair.so.2: reduction 40.200% libpcap.so.8: reduction 11.400% libpjdlog.so.0: reduction 27.400% libsbuf.so.6: reduction 2.900% libspl.so.2: reduction 42.300% libsys.so.7: reduction 2.700% libthr.so.3: reduction 21.000% libuutil.so.2: reduction 13.100% libz.so.6: reduction 5.600% libzpool.so.2: reduction 15.100%
In some cases it adds some ROP gadgets despite removing the simple ROP gadgets: lib80211.so.1: reduction -32.700% libbe.so.1: reduction -22.300% libbegemot.so.4: reduction -20.500% libcap_dns.so.2: reduction -58.000% libcap_fileargs.so.1: reduction -28.200% libcap_grp.so.1: reduction -54.000% libcap_net.so.1: reduction -28.800% libcap_pwd.so.1: reduction -38.800% libcap_sysctl.so.2: reduction -71.100% libcap_syslog.so.1: reduction -15.000% libcrypt.so.5: reduction -14.600% libctf.so.2: reduction -.300% libcxxrt.so.1: reduction -14.000% libdevstat.so.7: reduction -1.600% libedit.so.8: reduction -4.200% libgeom.so.5: reduction -16.500% libicp_rescue.so.3: reduction -2.300% libipsec.so.4: reduction -31.800% libjail.so.1: reduction -21.700% libkvm.so.7: reduction -5.300% libmlx5.so.1: reduction -6.300% libmt.so.5: reduction -23.000% libnv.so.1: reduction -.400% librss.so.1: reduction -3.800% librt.so.1: reduction -24.000% libssp.so.0: reduction -21.100% libstats.so.0: reduction -9.000% libtinfow.so.9: reduction -3.500% libtpool.so.2: reduction -36.500% libufs.so.8: reduction -11.900% libulog.so.0: reduction -67.400% libumem.so.2: reduction -2.000% libutil.so.9: reduction -7.200% libxo.so.0: reduction -9.000% libzdb.so.2: reduction -11.700% libzfs_core.so.2: reduction -17.700% libzfs.so.4: reduction -.300% libzfsbootenv.so.1: reduction -26.900% libzutil.so.2: reduction -5.600%
To reproduce: for lib in *.so.*; do echo -n $lib: before="$(ROPgadget --nosys --nojop --binary /tmp/be_mount.Sx87/lib/$lib | tail -n1 | cut -d : -f 2)" after="$(ROPgadget --nosys --nojop --binary $lib | tail -n1 | cut -d : -f 2)" echo " reduction" $(bc -S 3 -e "(1-${after}/${before})*100")% done >/tmp/reduction.txt
Most of the time the size difference is very small (<1% for >50% of the files and >10% for only 2 files): lib80211.so.1: size change .100% libalias.so.7: size change 0% libavl.so.2: size change 0% libbe.so.1: size change .100% libbegemot.so.4: size change .100% libbsdxml.so.4: size change 0% libc.so.7: size change 1.200% libc++.so.1: size change 1.600% libcam.so.7: size change 1.900% libcap_dns.so.2: size change .100% libcap_fileargs.so.1: size change .100% libcap_grp.so.1: size change .100% libcap_net.so.1: size change .100% libcap_netdb.so.1: size change .100% libcap_pwd.so.1: size change .100% libcap_sysctl.so.2: size change .100% libcap_syslog.so.1: size change .100% libcasper.so.1: size change 0% libcrypt.so.5: size change 3.900% libcrypto.so.30: size change 1.400% libctf.so.2: size change .100% libcxxrt.so.1: size change .100% libdevstat.so.7: size change 15.400% exceptional libdtrace.so.2: size change .600% libedit.so.8: size change 1.800% libelf.so.2: size change .100% libgcc_s.so.1: size change 3.000% libgeom.so.5: size change 0% libibverbs.so.1: size change .100% libicp_rescue.so.3: size change .100% libicp.so.3: size change 1.500% libipsec.so.4: size change .100% libipt.so.0: size change 3.100% libirdma.so.1: size change .100% libjail.so.1: size change .100% libkiconv.so.4: size change .100% libkvm.so.7: size change .100% libm.so.5: size change 1.700% libmd.so.6: size change 0% libmd.so.7: size change .100% libmlx5.so.1: size change 0% libmt.so.5: size change .100% libncursesw.so.9: size change 1.900% libnv.so.1: size change 4.300% libnvpair.so.2: size change 4.300% libpcap.so.8: size change 1.200% libpjdlog.so.0: size change .100% librss.so.1: size change .200% librt.so.1: size change .100% libsbuf.so.6: size change .100% libspl.so.2: size change 0% libssp.so.0: size change .100% libstats.so.0: size change .100% libsys.so.7: size change .100% libthr.so.3: size change 2.400% libtinfow.so.9: size change 1.600% libtpool.so.2: size change .100% libufs.so.8: size change .100% libulog.so.0: size change .100% libumem.so.2: size change 54.300% exceptional libutil.so.9: size change .100% libuutil.so.2: size change .100% libxo.so.0: size change .100% libz.so.6: size change .100% libzdb.so.2: size change .300% libzfs_core.so.2: size change .100% libzfs.so.4: size change 2.000% libzfsbootenv.so.1: size change .100% libzpool.so.2: size change 1.200% libzutil.so.2: size change 0%
show more ...
|
Revision tags: release/14.2.0, release/13.4.0 |
|
#
973bbdab |
| 22-Aug-2024 |
Jose Luis Duran <jlduran@gmail.com> |
mk: Add a BTI-report linker feature
Add support for specifying how to report the missing Branch Target Identification (BTI) linker feature on AArch64.
For:
Kernel: bti-report on when the linker
mk: Add a BTI-report linker feature
Add support for specifying how to report the missing Branch Target Identification (BTI) linker feature on AArch64.
For:
Kernel: bti-report on when the linker supports it Userspace: bti-report on when the linker supports it and BTI_REPORT_ERROR is defined
Fixes: 43e8849bc294 ("conf: Enable BTI checking in the arm64 kernel") Pull Request: https://github.com/freebsd/freebsd-src/pull/1393
show more ...
|
Revision tags: release/14.1.0 |
|
#
82854693 |
| 22-May-2024 |
Andrew Turner <andrew@FreeBSD.org> |
arm64: Allow userspace to be built with PAC and BTI
Add the WITH/WITHOUT_BRANCH_PROTECTION build flags. This can be used to enable the use of pointer authentication (FEAT_PAuth) and branch target id
arm64: Allow userspace to be built with PAC and BTI
Add the WITH/WITHOUT_BRANCH_PROTECTION build flags. This can be used to enable the use of pointer authentication (FEAT_PAuth) and branch target identification (FEAT_BTI) in userspace.
The kernel already handles both of these is userspace, we just need to enable it.
Leave disabled for a short period for this to settle before enabling.
Reviewed by: emaste Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D42596
show more ...
|
Revision tags: release/13.3.0, release/14.0.0 |
|
#
2befa269 |
| 01-Sep-2023 |
Brooks Davis <brooks@FreeBSD.org> |
Add INIT_ALL build option
This option replaces WITH_INIT_ALL_PATTERN and WITH_INIT_ALL_ZERO with INIT_ALL=pattern and INIT_ALL=zero respectively. As these are relatively rarely used options no back
Add INIT_ALL build option
This option replaces WITH_INIT_ALL_PATTERN and WITH_INIT_ALL_ZERO with INIT_ALL=pattern and INIT_ALL=zero respectively. As these are relatively rarely used options no backwards compatibility is implemented.
Reviewed by: emaste Relnotes: yes Differential Revision: https://reviews.freebsd.org/D41675
show more ...
|
#
d0b2dbfa |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
|
#
92053e4f |
| 21-Jul-2023 |
John Baldwin <jhb@FreeBSD.org> |
share/mk: Pass -znoexecstack to ld.bfd when linking libraries and programs.
lld assumes -znoexecstack by default whereas ld.bfd still defaults to -zexecstack in the absence of .note.GNU-stack annota
share/mk: Pass -znoexecstack to ld.bfd when linking libraries and programs.
lld assumes -znoexecstack by default whereas ld.bfd still defaults to -zexecstack in the absence of .note.GNU-stack annotations. Adding the flags centrally avoids having to patch various libraries in the tree as one-offs (e.g. OpenSSL 3 is the current thing generating new warnings with ld.bfd).
Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D41120
show more ...
|
#
3006f6df |
| 23-May-2023 |
Dimitry Andric <dim@FreeBSD.org> |
Update -ftrivial-auto-var-init flags for clang >= 16
As of clang 16, the -ftrivial-auto-var-init=zero option no longer needs -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
Update -ftrivial-auto-var-init flags for clang >= 16
As of clang 16, the -ftrivial-auto-var-init=zero option no longer needs -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang to enable the option. Only add it for older clang versions.
PR: 271047 Reviewed by: emaste MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D40208
show more ...
|
Revision tags: release/13.2.0, release/12.4.0 |
|
#
4ca6ecf1 |
| 30-Jun-2022 |
Jessica Clarke <jrtc27@FreeBSD.org> |
Really fix cross-builds from macOS
LINKER_TYPE is set to mac not macos on macOS.
Fixes: 7927452ac4e9 ("Add RELRO build knob, default to enabled")
|
#
7927452a |
| 26-Jun-2022 |
Ed Maste <emaste@FreeBSD.org> |
Fix cross-builds from macOS
The macOS linker does not support -zrelro/-znorelro. Since it is only used to for build tools that run on the host, and WITH_RELRO or WITHOUT_RELRO does not matter there
Fix cross-builds from macOS
The macOS linker does not support -zrelro/-znorelro. Since it is only used to for build tools that run on the host, and WITH_RELRO or WITHOUT_RELRO does not matter there, just skip the option.
Reviewed by: markj Fixes: 2f3a961487c9 ("Add RELRO build knob, default to enabled") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35589
show more ...
|
#
2f3a9614 |
| 22-Jun-2022 |
Ed Maste <emaste@FreeBSD.org> |
Add RELRO build knob, default to enabled
Note that lld enables relro by default, so that we already had either partial or full RELRO, depending on the state of the BIND_NOW knob.
Add a RELRO knob s
Add RELRO build knob, default to enabled
Note that lld enables relro by default, so that we already had either partial or full RELRO, depending on the state of the BIND_NOW knob.
Add a RELRO knob so that the option can be disabled if desired, and so that builds using the GNU toolchain are equivalent to those using the standard Clang/LLVM toolchain.
Reviewed by: markj MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35545
show more ...
|
Revision tags: release/13.1.0 |
|
#
98e58025 |
| 02-Jan-2022 |
Warner Losh <imp@FreeBSD.org> |
bsd.lib/prog.mk: Remove special case for mips
We no longer need to set the TLS model for mips64*.
Sponsored by: Netflix
|
Revision tags: release/12.3.0, release/13.0.0 |
|
#
c910570e |
| 01-Mar-2021 |
Ed Maste <emaste@FreeBSD.org> |
Use compressed debug in standalone userland debug files by default
The compiler supports CFLAGS=-gz=zlib to compress .debug sections in object files, libraries, and binaries. Enable it to reduce di
Use compressed debug in standalone userland debug files by default
The compiler supports CFLAGS=-gz=zlib to compress .debug sections in object files, libraries, and binaries. Enable it to reduce disk usage for standalone debug files (and /usr/obj).
Reviewed by: dim, kevans Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29002
show more ...
|
#
428a32ed |
| 03-Aug-2021 |
Alex Richardson <arichardson@FreeBSD.org> |
Use .sinclude for bsd.sanitizer.mk
We don't install this file since MK_ASAN/MK_UBSAN is only supported for src builds. However, some ports also use bsd.lib.mk/bsd.prog.mk so we should not fail the b
Use .sinclude for bsd.sanitizer.mk
We don't install this file since MK_ASAN/MK_UBSAN is only supported for src builds. However, some ports also use bsd.lib.mk/bsd.prog.mk so we should not fail the build if it can't be included.
Reported by: jkim Fixes: 7bc797e3f380 ("Add build system support for ASAN+UBSAN instrumentation")
show more ...
|
#
7bc797e3 |
| 02-Aug-2021 |
Alex Richardson <arichardson@FreeBSD.org> |
Add build system support for ASAN+UBSAN instrumentation
This adds two new options WITH_ASAN/WITH_UBSAN that can be set to enable instrumentation of all binaries with AddressSanitizer and/or Undefine
Add build system support for ASAN+UBSAN instrumentation
This adds two new options WITH_ASAN/WITH_UBSAN that can be set to enable instrumentation of all binaries with AddressSanitizer and/or UndefinedBehaviourSanitizer. This current patch is almost sufficient to get a complete buildworld with sanitizer instrumentation but in order to actually build and boot a system it depends on a few more follow-up commits.
Reviewed By: brooks, kib, markj Differential Revision: https://reviews.freebsd.org/D31043
show more ...
|
#
7c8d3811 |
| 21-May-2021 |
Marcin Wojtas <mw@FreeBSD.org> |
Add afterbuild target to bsd.prog.mk.
Afterbuild target allows to perform operations on fully built binary. This is needed to allow for ELF feature flags modification during world build.
Submitted
Add afterbuild target to bsd.prog.mk.
Afterbuild target allows to perform operations on fully built binary. This is needed to allow for ELF feature flags modification during world build.
Submitted by: Dawid Gorecki <dgr@semihalf.com> Reviewed by: imp Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D29551
show more ...
|
#
5cf6f1c4 |
| 30-Jan-2021 |
Alex Richardson <arichardson@FreeBSD.org> |
Remove the MK_LIBCPLUSPLUS option
This option has been equivalent to any form of C++ support since libstdc++ was removed. Therefore, replace all MK_LIBCPLUSPLUS uses with MK_CXX.
Reviewed By: emast
Remove the MK_LIBCPLUSPLUS option
This option has been equivalent to any form of C++ support since libstdc++ was removed. Therefore, replace all MK_LIBCPLUSPLUS uses with MK_CXX.
Reviewed By: emaste Differential Revision: https://reviews.freebsd.org/D27974
show more ...
|
#
7fa2f2a6 |
| 06-Jan-2021 |
Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> |
Rename NO_WERROR -> MK_WERROR=no
As suggested in D27598. This also supports MK_WERROR.clang=no and MK_WERROR.gcc=no to support the existing NO_WERROR.<compiler> uses.
Reviewed By: brooks Differenti
Rename NO_WERROR -> MK_WERROR=no
As suggested in D27598. This also supports MK_WERROR.clang=no and MK_WERROR.gcc=no to support the existing NO_WERROR.<compiler> uses.
Reviewed By: brooks Differential Revision: https://reviews.freebsd.org/D27601
show more ...
|
#
e268fd0a |
| 10-Nov-2020 |
Brooks Davis <brooks@FreeBSD.org> |
Support initializing stack variables on function entry
There are two options: - WITH_INIT_ALL_ZERO: Zero all variables on the stack. - WITH_INIT_ALL_PATTERN: Initialize variables with well-defined
Support initializing stack variables on function entry
There are two options: - WITH_INIT_ALL_ZERO: Zero all variables on the stack. - WITH_INIT_ALL_PATTERN: Initialize variables with well-defined patterns.
The exact pattern are a compiler implementation detail and vary by type. They are somewhat documented in the LLVM commit message: https://reviews.llvm.org/rL349442 I've used WITH_INIT_ALL_* to match Microsoft's InitAll feature rather than naming them after the LLVM specific compiler flags.
In a range of consumer products, options like these are used in both debug and production builds with debugs builds using patterns (intended to provoke crashes on use of uninitialized values) and production using zeros (deemed more likely to lead to harmless misbehavior or NULL-pointer dereferences).
Reviewed by: emaste Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D27131
show more ...
|
Revision tags: release/12.2.0, release/11.4.0 |
|
#
8e1e3e1c |
| 02-Jun-2020 |
Ed Maste <emaste@FreeBSD.org> |
bsd.prog.mk: split MK_PIE test for clarity
And a comment explaining why PIE flags are disabled for static binaries.
|
#
697b271d |
| 20-May-2020 |
Ed Maste <emaste@FreeBSD.org> |
pkgbase: use -dev,-dbg instead of -development,-debug
-development is long and awkward, and is also inconsistent with prior art from the Linux world, which uses -dev (Debian) or -devel (Red Hat). F
pkgbase: use -dev,-dbg instead of -development,-debug
-development is long and awkward, and is also inconsistent with prior art from the Linux world, which uses -dev (Debian) or -devel (Red Hat). Follow the Debian convention, and similarly for debug info packages.
Also remove redundant pkgbase development tag from includes. We already tag include files with package=runtime,dev; there is no need to separately tag them as dev.
Discussed with: bapt Reviewed by: manu Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24139
show more ...
|
#
79f59915 |
| 08-Jan-2020 |
John Baldwin <jhb@FreeBSD.org> |
Add -mno-relax to CFLAGS in bsd.prog/lib.mk instead of bsd.cpu.mk.
bsd.cpu.mk is included by bsd.init.mk before bsd.linker.mk, so it was always setting the flag since LINKER_FEATURES wasn't defined.
Add -mno-relax to CFLAGS in bsd.prog/lib.mk instead of bsd.cpu.mk.
bsd.cpu.mk is included by bsd.init.mk before bsd.linker.mk, so it was always setting the flag since LINKER_FEATURES wasn't defined.
Reported by: mhorne Reviewed by: imp, mhorne Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23076
show more ...
|
Revision tags: release/12.1.0 |
|
#
c09aa214 |
| 31-Oct-2019 |
Brooks Davis <brooks@FreeBSD.org> |
Allow bsd.compat.mk to be reliably included outside Makefile.inc1.
Replace explicit TARGET_* variables with COMPAT_* versions defined based on where the file is being included.
Also, require that b
Allow bsd.compat.mk to be reliably included outside Makefile.inc1.
Replace explicit TARGET_* variables with COMPAT_* versions defined based on where the file is being included.
Also, require that bsd.compat.mk be included directly. It's not going to be widely used so always loading it in bsd.prog.mk doesn't make sense. Instead users can include it directly.
Reviewed by: imp, bdrewery (prior revision) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22059
show more ...
|
#
f9cb60c6 |
| 16-Oct-2019 |
Warner Losh <imp@FreeBSD.org> |
bsd.compat.mk isn't setup to be included outside of Makefile.inc so comment it out here until that's sorted out. Otherwise the build is broken. when TARGET_ARCH isn't defined.
|
#
6b53d510 |
| 15-Oct-2019 |
Brooks Davis <brooks@FreeBSD.org> |
Add the ability to link programs against a compat ABI.
Linkage is controlled by two make knobs: WANT_COMPAT - Prefer to link against the compat ABI. NEED_COMPAT - Link against the compat ABI or fa
Add the ability to link programs against a compat ABI.
Linkage is controlled by two make knobs: WANT_COMPAT - Prefer to link against the compat ABI. NEED_COMPAT - Link against the compat ABI or fail to build.
Supported values are "32", "soft", and "any". The latter meaning pick the first[0] supported compat ABI.
This can be used to provide test binaries for compat ABIs or to link ABI-specific programs.
[0] We currently support only one compat ABI at a time, but this may change in the future and some code in this commit is structured to ease that change.
Reviewed by: bdrewery, jhb Obtained from: CheriBSD (in concept) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22023
show more ...
|
#
8b3bc70a |
| 08-Oct-2019 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r352764 through r353315.
|