Commit graph

462 commits

Author SHA1 Message Date
Kyle Evans be04fec426 Import _FORTIFY_SOURCE implementation from NetBSD
This is a mostly-unmodified copy of the various *_chk implementations
and headers from NetBSD, without yet modifying system headers to start
actually including them.  A future commit will also apply the needed
bits to fix ssp/unistd.h.

Reviewed by:	imp, pauamma_gundo.com (both previous versions), kib
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D32306
2024-05-13 00:23:49 -05:00
John Baldwin 70e5a9ea78 nvmf: Install nvmf.h and nvmf_proto.h in /usr/include/dev/nvmf
Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44707
2024-05-02 16:27:30 -07:00
Stephen J. Kiernan 41956c13f9 include: Ensure security/audit/audit.h gets staged properly.
There is a conflict between bsm/audit.h and security/audit/audit.h due
to the way that staging is being set up using .PATH to point to the
full directory and the leaf files being specified in the list. Due to
this, the bsm/audit.h was getting staged as both bsm/audit.h and
security/audit/audit.h since the sys/bsm directory is listed first in
the .PATH list.

Use sys/security in the .PATH instead of sys/security/audit and specify
the audit header files as audit/<name>.h. This ensures that we get the
correct audit.h stanged for security/audit/audit.h.

Reviewed by:	sjg
Obtained from:	Juniper Networks, Inc.
2024-04-03 20:26:33 -04:00
Stephen J. Kiernan f6e77cb8c1 include: Allow SDESTDIR to be overridden
Obtained from:	Juniper Networks, Inc.
Reviewed by:	sjg
Differential Revision:	https://reviews.freebsd.org/D44540
2024-03-27 19:18:43 -04:00
Warner Losh 5a1d14419a include: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:28 -07:00
Alexander V. Chernikov 2cef62886d pf: convert state retrieval to netlink
Use netlink to export pf's state table.

The primary motivation is to improve how we deal with very large state
stables. With the previous implementation we had to build the entire
list (both in the kernel and in userspace) before we could start
processing. With netlink we start to get data in userspace while the
kernel is still generating more. This reduces peak memory consumption
(which can get to the GB range once we hit millions of states).

Netlink also makes future extension easier, in that we can easily add
fields to the state export without breaking userspace. In that regard
it's similar to an nvlist-based approach, except that it also deals
with transport to userspace and that it performs significantly better
than nvlists. Testing has failed to measure a performance difference
between the previous struct-copy based ioctl and the netlink approach.

Differential Revision:	https://reviews.freebsd.org/D38888
2023-10-10 11:48:21 +02:00
Doug Rabson 78847e1e59 pkgbase: Move headers and libs out of runtime and utilities
Headers from src/include were in the runtime-dev package but
subdirectories of src/include ended up in utilities-dev by default.
Neither package is a good choice - the headers in src/include are not
useful without the libraries contained in clibs-dev.

This moves the standard C headers to clibs-dev (C++ headers are already
in this package). While working on this, I found that various clang
libraries and headers were also bundled into utilities-dev by default
so these are also moved to clang-dev.

I also added a FreeBSD-build-essential meta package to make it simple to
install all the toolchain parts.

PR:		254173
Reviewed byb:	manu
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D41815
2023-09-12 13:22:21 +01:00
Dag-Erling Smørgrav e6615b1034 include: Implement N2867.
This adds macros for checked addition, subtraction, and multiplication with semantics similar to the builtins gcc and clang have had for years.

Reviewed by:	kib, emaste
Differential Revision:	https://reviews.freebsd.org/D41734
2023-09-07 06:40:14 +00:00
Simon J. Gerraty 1554ba03b6 Add mac_grantbylabel
This module allows controlled privilege escallation via mac labels
securely associated with a process via mac_veriexec.

There are over 700 PRIV_* but we can compress many of them into
a single GBL_* thus constraining the size of gbl labels.

The goal is to allow a daemon to run as an unprivileged process while
still being able a set of privileged operations needed.

We add APIs to libveriexec so that userland processes can check labels
and an exec_script API that allows a suitably labeled process to run
something like a python interpreter directly if necessary;
overcomming the 'indirect' flag applied to the interpreter.

Add -l option to sbin/veriexec to report labels.

Reviewed by:	stevek
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D41431
2023-08-24 17:42:11 -07:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Mike Karels d5d97bed4a arm64 lib32: prepare arm64 headers to redirect to arm
In order to compile lib32 libraries and other 32-bit code on arm64,
<machine/foo.h> needs to be redirected to an arm header rather
than arm64 when building with -m32.  Ifdef the arm64 headers that
are installed in /usr/include/machine and used by user-level software
(including references from /usr/include/*.h) so that if __arm__ is
defined when including the arm64 version, <arm/foo.h> is included
rather than using the rest of the file's contents.  Some arm headers
had no arm64 equivalent; headers were added just to do the redirection.
These files use #error if __arm__ is not defined to guard against
confusion.  Also add an include/arm Makefile, and modify Makefiles
as needed to install everything, including the arm files in
/usr/include/arm.  fenv.h comes from lib/msun/arm/fenv.h.

The new arm64 headers are:
    acle-compat.h
    cpuinfo.h
    sysreg.h

Reviewed by:	jrtc27, imp
Differential Revision:	https://reviews.freebsd.org/D40944
2023-07-25 18:59:26 -05:00
John Baldwin 1aaa8f670a nvme: Don't install nvme_private.h in /usr/include.
Reviewed by:	chuck, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D40394
2023-06-26 20:30:45 -07:00
Ed Maste b6271cc0d0 includes: avoid installing if_wg.h twice
if_wg.h was installed via dev/wg in LSUBDIRS and also explicitly.  We
want to install only wg/if_wg.h not the other headers, so add dev/wg to
the skip list in the copies and symlinks targets.

PR:		271266
Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40031
2023-05-09 21:09:39 -04:00
Brooks Davis 1a2249ff0b include: add a check-ldirs target
This target ensures all LDIRS, LSUBDIRS, and LSUBSUBDIRS actually exist.

Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D39006
2023-04-19 16:58:06 +01:00
Michael Butler 21735dfaeb include: Remove no longer existing netgraph/atm
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D39005
2023-03-09 21:39:41 +00:00
Warner Losh 1761b09bf4 byteswap.h: Add a glibc/linux compatible byteswap.h
For endian.h to work instead of sys/endian.h, some software needs
byteswap.h available. It must define {__,}byteswap_{16,32,64}.
Included sys/_endian.h to get an appropriate __byteswap16, etc
and defines the new macros in terms of them. Enhance _endian.h
to allow it to be included from here too.

Sponsored by:		Netflix
Reviewed by:		markj
Differential Revision:	https://reviews.freebsd.org/D32051
2023-01-20 16:37:39 -07:00
Warner Losh 30e0d2a510 linux: For better compatibility, provide compatible endian.h
Add endian.h. This includes sys/endian.h and then adds extra defines
that glibc defines with double underscores for our
_{BIG,BYTE,LITTLE,PDP}_ENDIAN macros. We also define __FLOAT_WORD_ORDER
to be the same as _BYTE_ENDIAN since FreeBSD doesn't currently define
this, and the default with glibc is exactly this for our platforms.
Move common parts of endian.h and sys/endian.h into sys/_endian.h
to limit namespace pollution from endian.h

All this gives us good compatibility with Linux. There may be one or two
upstreams that haven't integrated the patches I tried to send up.

There are some minor differences:
	o The extra glibc macros are not defined. These are all
	  controlled with either __ at the start, or only defined
	  when glibc is being built. We also don't define macros
	  that are used internally in glibc that would pollute
	  the namespace.
	o For complete compatibility, this change must also be
	  paired with providing a glibc-compatible byteswap.h.

Sponsored by:		Netflix
Reviewed by:		mhorne, markj, jhb
Differential Revision:	https://reviews.freebsd.org/D31962
2023-01-20 16:32:45 -07:00
Kyle Evans 8b8babf044 include: put includes into -dev packages
The includes build is kind of funky, as we support either copying or
symlinking files into /usr/include.  For `copies`, we were supplying
the include/ ${TAG_ARGS}, which puts packages into `FreeBSD-runtime`,
without any consideration to the fact that we're installing headers.

Let's copy the approach that the `symlinks` target uses for now, and
add ",dev" to the TAG_ARGS so that headers at least end up in
FreeBSD-runtime-dev, which is more appropriate.  Some of these includes
are actually technically supposed to be in *other* packages and their
INCSGROUP's PACKAGE setting is actually correct, but this is less
trivial to solve.  This is a bandaid to fix the immediate problem of
some headers ending up in two different packages.

PR:		267526
Reviewed by:	dfr, manu
Differential Revision:	https://reviews.freebsd.org/D37256
2022-11-09 22:20:38 -06:00
John Baldwin 744bfb2131 Import the WireGuard driver from zx2c4.com.
This commit brings back the driver from FreeBSD commit
f187d6dfbf plus subsequent fixes from
upstream.

Relative to upstream this commit includes a few other small fixes such
as additional INET and INET6 #ifdef's, #include cleanups, and updates
for recent API changes in main.

Reviewed by:	pauamma, gbe, kevans, emaste
Obtained from:	git@git.zx2c4.com:wireguard-freebsd @ 3cc22b2
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36909
2022-10-28 13:36:12 -07:00
Alexander V. Chernikov 11ca01e9aa netlink: add headers installation 2022-10-01 16:31:58 +00:00
Brooks Davis a09ea2bbc3 amd64: add an i386 include directory
This directory will hold i386-specific headers that are needed for
-m32 support on amd64 and where the amd64 and i386 cases have too
little in common for combining them to make sense.  Files to be
installed will come in later commits.

With the currently required set of files, this could be done with
another INCGROUP in include/Makefile, but at least one file that
might want -m32 support (ieeefp.h) conflicts with a files installed
in /usr/include.

Reviewed by:	jhb, imp
2022-06-13 18:35:38 +01:00
Kirk McKusick c7996ddf80 Create a new GEOM utility, gunion(8).
The gunion(8) utility is used to track changes to a read-only disk on
a writable disk. Logically, a writable disk is placed over a read-only
disk. Write requests are intercepted and stored on the writable
disk. Read requests are first checked to see if they have been
written on the top (writable disk) and if found are returned. If
they have not been written on the top disk, then they are read from
the lower disk.

The gunion(8) utility can be especially useful if you have a large
disk with a corrupted filesystem that you are unsure of how to
repair. You can use gunion(8) to place another disk over the corrupted
disk and then attempt to repair the filesystem. If the repair fails,
you can revert all the changes in the upper disk and be back to the
unchanged state of the lower disk thus allowing you to try another
approach to repairing it. If the repair is successful you can commit
all the writes recorded on the top disk to the lower disk.

Another use of the gunion(8) utility is to try out upgrades to your
system. Place the upper disk over the disk holding your filesystem
that is to be upgraded and then run the upgrade on it. If it works,
commit it; if it fails, revert the upgrade.

Further details can be found in the gunion(8) manual page.

Reviewed by: Chuck Silvers, kib (earlier version)
tested by:   Peter Holm
Differential Revision: https://reviews.freebsd.org/D32697
2022-02-28 16:36:08 -08:00
Cy Schubert 3b9b51fe46 ipfilter: Move kernel bits to netpfil
Through fixes and improvements our ipfilter sources have diverged
enough to warrant move from contrib into sys/netpil. Now that I'm
planning on implementing MSS clamping as in iptables it makes more
sense to move ipfilter to netpfil.

This is the first of three commits the ipfilter move.

Suggested by glebius on two occaions.

Suggested by and discussed with:	glebius
Reviewed by:				glebius, kp (for #network)
MFC after:				1 month
Differential Revision:		https://reviews.freebsd.org/D33510
2021-12-20 06:16:33 -08:00
Konstantin Belousov 160b4b922b Add real sched.h
It is required by IEEE Std 1003.1-2008 AKA POSIX.

Put some Linux compatibility stuff under BSD_VISIBLE namespace, in
particular, sys/cpuset.h definitions.  Also, if user really want
Linux compatibility, she can request cpu_set_t typedef with
_WITH_CPU_SET_T define.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32901
2021-11-10 21:18:53 +02:00
Emmanuel Vadot 663b174b5b an: Remove driver
Last an(4) devices have been End Of Life and End Of Sale in 2007.
Time to remove this driver.

Differential Revision:	https://reviews.freebsd.org/D30679
Reviewed by:		imp (earlier version), emaste (earlier version)
Sponsored by:		Diablotin Systems
2021-06-11 21:18:04 +02:00
Emmanuel Vadot f41efc453a Fix build with WITHOUT_AUDIT=yes in src.conf
Always install the audit related includes are some part of the source
always requires them.

Reported by:	many
Fixes:	8c3eaf244a
2021-04-15 14:11:13 +02:00
John Baldwin 7af04dff02 Only symlink cryptodev.h into /usr/include/crypto/
I missed updating the symlink side in the earlier commit.

Fixes:		283352dd4f
MFC after:	1 week
2021-03-19 16:59:44 -07:00
Kyle Evans f187d6dfbf base: remove if_wg(4) and associated utilities, manpage
After length decisions, we've decided that the if_wg(4) driver and
related work is not yet ready to live in the tree.  This driver has
larger security implications than many, and thus will be held to
more scrutiny than other drivers.

Please also see the related message sent to the freebsd-hackers@
and freebsd-arch@ lists by Kyle Evans <kevans@FreeBSD.org> on
2021/03/16, with the subject line "Removing WireGuard Support From Base"
for additional context.
2021-03-17 09:14:48 -05:00
Emmanuel Vadot 060f0a17bb Revert "include: Remove symlink installation"
This reverts commit 0006530aa1.
2021-03-16 08:40:59 +01:00
Emmanuel Vadot 35b6d9b65e Revert "include: Tag directly the last headers"
This reverts commit 839fc8cdf9.
2021-03-16 08:40:54 +01:00
Emmanuel Vadot 839fc8cdf9 include: Tag directly the last headers
We cannot easily used the TAG here and we don't yet have something to install
even .h from a diretory in bsd.prog.mk

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D29170
MFC after:      2 weeks
2021-03-16 07:13:00 +01:00
Emmanuel Vadot 0006530aa1 include: Remove symlink installation
headers could be installed as symlink to the source tree instead of copies.
Remove the possibility to do that.
This make the makefile easier to read and to maintain and also don't duplicate
code.

While here remove some directories from LSBUDIRS as we already install them using
the INCS stuff.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D29167
MFC after:      2 weeks
2021-03-16 07:12:53 +01:00
Emmanuel Vadot 0594b28795 pkgbase: Install all cam includes with INCS
Now they are correctly taggued and put into the -dev package

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D29166
MFC after:      2 weeks
2021-03-16 07:12:49 +01:00
Emmanuel Vadot 8c3eaf244a pkgbase: Install all BSM includes with INCS
Now they are correctly taggued and put them into the libbsm package

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D29165
MFC after:      2 weeks
2021-03-16 07:12:46 +01:00
John Baldwin 283352dd4f Stop installing kernel-only crypto headers to /usr/include/crypto.
The only user-facing header from OCF is <crypto/cryptodev.h>.

PR:		254167 (exp-run)
MFC after:	1 week
Sponsored by:	Chelsio Communications
2021-03-15 17:00:21 -07:00
Kyle Evans 74ae3f3e33 if_wg: import latest fixup work from the wireguard-freebsd project
This is the culmination of about a week of work from three developers to
fix a number of functional and security issues.  This patch consists of
work done by the following folks:

- Jason A. Donenfeld <Jason@zx2c4.com>
- Matt Dunwoodie <ncon@noconroy.net>
- Kyle Evans <kevans@FreeBSD.org>

Notable changes include:
- Packets are now correctly staged for processing once the handshake has
  completed, resulting in less packet loss in the interim.
- Various race conditions have been resolved, particularly w.r.t. socket
  and packet lifetime (panics)
- Various tests have been added to assure correct functionality and
  tooling conformance
- Many security issues have been addressed
- if_wg now maintains jail-friendly semantics: sockets are created in
  the interface's home vnet so that it can act as the sole network
  connection for a jail
- if_wg no longer fails to remove peer allowed-ips of 0.0.0.0/0
- if_wg now exports via ioctl a format that is future proof and
  complete.  It is additionally supported by the upstream
  wireguard-tools (which we plan to merge in to base soon)
- if_wg now conforms to the WireGuard protocol and is more closely
  aligned with security auditing guidelines

Note that the driver has been rebased away from using iflib.  iflib
poses a number of challenges for a cloned device trying to operate in a
vnet that are non-trivial to solve and adds complexity to the
implementation for little gain.

The crypto implementation that was previously added to the tree was a
super complex integration of what previously appeared in an old out of
tree Linux module, which has been reduced to crypto.c containing simple
boring reference implementations.  This is part of a near-to-mid term
goal to work with FreeBSD kernel crypto folks and take advantage of or
improve accelerated crypto already offered elsewhere.

There's additional test suite effort underway out-of-tree taking
advantage of the aforementioned jail-friendly semantics to test a number
of real-world topologies, based on netns.sh.

Also note that this is still a work in progress; work going further will
be much smaller in nature.

MFC after:	1 month (maybe)
2021-03-14 23:52:04 -05:00
Scott Long afbee98232 Remove xform_poly1305.h from the build, it is not necessary. 2021-03-05 21:28:10 +00:00
Alex Richardson 74eb7f97ec Fix make includes path to nvpair.h
Fixes a typo introduced in 9e5787d228
2021-01-19 21:23:25 +00:00
Alex Richardson 8d30571d45 include: Delete stale symlinks using find(1) instead of a shell loop.
This reduces the number of execve() syscalls during make includes by 88.

Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D27622
2021-01-19 21:23:25 +00:00
Warner Losh a21def4d56 pccard: Remove wi(4) driver
Remove wi(4). pccard is going away, and wi only supports PC Card
devices, though it has a minor amount of glue to also support
PCI cards. However, removing the one without removing the other
is hard, so the whole driver is being removed.

Relnotes: Yes
2021-01-07 20:41:06 -07:00
Vladimir Kondratyev 9477390796 hid: Import hidraw(4) - driver for access to raw HID device data
This driver provides raw access to HID devices through uhid(4)-compatible
interface and is based on pre-8.x uhid(4) code. Unlike uhid(4) it does
not take devices in to monopoly ownership and allows parallel access
from other drivers.

hidraw supports Linux's hidraw-compatible interface as well.

Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D27992
2021-01-08 02:18:43 +03:00
Vladimir Kondratyev 67de2db262 Factor-out hardware-independent part of USB HID support to new module
It will be used by the upcoming HID-over-i2C implementation.  Should be
no-op, except hid.ko module dependency is to be added to affected drivers.

Reviewed by:	hselasky, manu
Differential revision:	https://reviews.freebsd.org/D27867
2021-01-08 02:18:42 +03:00
Alex Richardson 7b0d3a3ccf include: Use printf(1) instead of shell loops for header symlinks
Using a shell for loop means we have to spawn a separate install(1)
process for each header that is symlinked. This patch uses printf(1) to
generate an argument list that has been prefixed with the correct number
of ../ and then uses a single install(1) invocation.

This reduces the number of execve() calls during make includes from 2442
(with D27622) to 1382. Running `make symlinks` in include/ now spawns 214
processes instead of 1276 without this patch.

Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D27723
2021-01-07 09:26:22 +00:00
Emmanuel Vadot f61a3898bb include: Use INCSGROUPS for a few files
Instead of using install directly use INCSGROUPS for them.
All those files are the ones we installed when the directory have more .h
files that we don't want to install so they aren't using the LSUBDIR stuff.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D27612
2021-01-04 16:36:43 +01:00
Emmanuel Vadot b6cc69322a include: Tag the last includes files as part of the -dev package
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D27618
2021-01-04 16:36:39 +01:00
Brandon Bergren b963e10d68 [PowerPC64LE] Ensure nvram is built on powerpc64le.
Fix some cases where conditionals that were trying to exclude powerpcspe
were also excluding powerpc64le.

Sponsored by:	Tag1 Consulting, Inc.
2020-09-13 18:24:15 +00:00
Matt Macy 9e5787d228 Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.

I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.

Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.

Improvements include:
  project quotas, encrypted datasets,
  allocation classes, vectorized raidz,
  vectorized checksums, various command line
  improvements, zstd compression.

Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.

Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
Olivier Cochard d371ed1c4b Install extra TCP stack header files: They are needed to compile a userland
component of TCP Blackbox Recorder as example.

Approved by:	rrs
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D25584
2020-07-08 21:40:27 +00:00
Rick Macklem 31e71d0710 Oops, I didn't notice the "cd" is needed for each install line. 2020-05-31 22:46:32 +00:00
Rick Macklem 6ecaf8f446 Update the Makefile to copy rpcsec_tls.h to /usr/include/rpc. 2020-05-31 22:15:34 +00:00