Commit graph

290615 commits

Author SHA1 Message Date
Kristof Provost 60d8dbbef0 netinet: add a probe point for IP, IP6, ICMP, ICMP6, UDP and TCP stats counters
When debugging network issues one common clue is an unexpectedly
incrementing error counter. This is helpful, in that it gives us an
idea of what might be going wrong, but often these counters may be
incremented in different functions.

Add a static probe point for them so that we can use dtrace to get
futher information (e.g. a stack trace).

For example:
	dtrace -n 'mib:ip:count: { printf("%d", arg0); stack(); }'

This can be disabled by setting the following kernel option:
	options 	KDTRACE_NO_MIB_SDT

Reviewed by:	gallatin, tuexen (previous version), gnn (previous version)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43504
2024-04-08 17:29:59 +02:00
Jake Freeland 34791f4ac7 capsicum.h: Include ktrace.h only in kernel
Fix cross build failure by including ktrace.h only when _KERNEL is
defined.

Fixes:		9bec841312
Approved by:	markj (mentor)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2024-04-08 09:32:58 -05:00
Rob Norris b6c7ff583f libvmmapi: add missing capability strings
Signed-off-by: Rob Norris <robn@despairlabs.com>

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44642
2024-04-08 09:08:59 -04:00
Rob Norris b9fa1500cb bhyvectl: generate usage from options table
The usage text had fallen out of sync with the actually available
options. Rather than keep them in sync by hand, just generate usage from
the available options.

Signed-off-by: Rob Norris <robn@despairlabs.com>

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44641
2024-04-08 09:08:54 -04:00
Mark Johnston 4696650782 swap_pager: Unbusy readahead pages after an I/O error
The swap pager itself allocates readahead pages, so should take care to
unbusy them after a read error, just as it does in the non-error case.

PR:		277538
Reviewed by:	olce, dougm, alc, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44646
2024-04-08 09:02:48 -04:00
Vladimir Kondratyev 4e7aa03b70 LinuxKPI: Stub sysfs_remove_link in linux/sysfs.h
sysfs_create_link is stubbed already. Stub sysfs_remove_link too to be
feature-complete.

Sponsored by:	Serenity Cyber Security, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:43 +03:00
Vladimir Kondratyev 56041ee817 LinuxKPI: Add want_init_on_free to linux/mm.h
want_init_on_free returns if heap memory zeroing on free is enabled.
FreeBSD does not zeroes heap memory on free().

Sponsored by:	Serenity Cyber Security
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:43 +03:00
Vladimir Kondratyev f7ea333e2b LinuxKPI: Add ACPI_ID_LEN const to linux/mod_devicetable.h
Sponsored by:	Serenity Cyber Security, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:43 +03:00
Vladimir Kondratyev f1206503e5 LinuxKPI: Add pci_dev_id to linux/pci.h
It returns bus/device/function number for given PCI device.
Also add intermediate PCI_DEVID macro used in some drivers.

Sponsored by:	Serenity Cyber Security, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:43 +03:00
Vladimir Kondratyev e8f59f4d31 LinuxKPI: Add the accelerator PCIe class
Sponsored by:	Serenity Cyber Security, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:43 +03:00
Vladimir Kondratyev e0eeeca8b8 LinuxKPI: Add PTR_IF macro
Sponsored by:	Serenity Cyber Security, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:42 +03:00
Vladimir Kondratyev 06902a4479 LinuxKPI: Add vm_flags_(clear|set) functions
Sponsored by:	Serenity Cyber Security, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:42 +03:00
Vladimir Kondratyev 61fb195e8d LinuxKPI: Improve timer_shutdown_sync
timer_shutdown_sync not only shutdowns a timer but prevents it rearming.

Sponsored by:	Serenity CyberSecurity, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:42 +03:00
Vladimir Kondratyev 9289c1f6f1 LinuxKPI: Add get_random_u32_below function
get_random_u32_below returns a random integer in the interval [0, ceil),
with uniform distribution.

Sponsored by:	Serenity CyberSecurity, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:42 +03:00
Vladimir Kondratyev 38c276a43f LinuxKPI: Add VM_ACCESS_FLAGS define to linux/mm.h
VM_ACCESS_FLAGS is a basic access permission flags.

Sponsored by:	Serenity CyberSecurity, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:42 +03:00
Vladimir Kondratyev 3208d4ad2b LinuxKPI: Import vanilla linux/overflow.h
It is dual-licensed (GPLv2 & MIT) and self-contained header file.
No need to reimplement it.

Sponsored by:	Serenity CyberSecurity, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:42 +03:00
Vladimir Kondratyev 8cfd1dd821 LinuxKPI: Move [SU](8|16|32|64)_(MAX|MIN) defines to linux/limits.h
Some source files get them from linux/limits.h directly rather than from
linux/kernel.h.
While here replace Linux constant values with sys/stdint.h provided ones.

Sponsored by:	Serenity Cyber Security, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:42 +03:00
Vladimir Kondratyev 1970388766 LinuxKPI: Add strnchr function
strnchr() finds a character in a length limited string.

Sponsored by:	Serenity CyberSecurity, LLC
Reviewed by:	emaste
MFC after:	1 month
2024-04-08 09:47:42 +03:00
Vladimir Kondratyev aafe4126f7 LinuxKPI: Add ms_to_ktime
Sponsored by:	Serenity CyberSecurity, LLC
Reviewed by:	emaste
MFC after:	1 week
2024-04-08 09:47:42 +03:00
Vladimir Kondratyev 8ace984e47 LinuxKPI: Set suspend type on syspend/resume cycle enter
Recent amdgpu depends on pm_suspend_target_state value to separate
S3 and S0ix support.

Sponsored by:	Serenity Cyber Security, LLC
Reviewed by:	manu (in bugzilla)
MFC after:	1 week
2024-04-08 09:47:41 +03:00
Jake Freeland 1ff4bc0f49 RELNOTES: Add entry for updates to ktrace(2)
Approved by:	markj (mentor)
2024-04-07 18:52:51 -05:00
Jake Freeland 2f39a98664 tests: Add ktrace capability violation test cases
Introduce regression tests for ktrace(2) that target capability
violations.

These test cases ensure that ktrace(2) records these violations:
- CAPFAIL_NOTCAPABLE
- CAPFAIL_INCREASE
- CAPFAIL_SYSCALL
- CAPFAIL_SIGNAL
- CAPFAIL_PROTO
- CAPFAIL_SOCKADDR
- CAPFAIL_NAMEI
- CAPFAIL_CPUSET

A portion of these test cases create processes that do NOT enter
capability mode, but raise violations. This is intended behavior.
Users may run `ktrace -t p` on non-Capsicumized programs to detect
violations that would occur if the process were in capability mode.

Reviewed by:	markj
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D40682
2024-04-07 18:52:51 -05:00
Jake Freeland aa32d7cbc9 ktrace: Record socket violations with KTR_CAPFAIL
Report restricted access to socket addresses and protocols while
Capsicum violation tracing with CAPFAIL_ADDR and CAPFAIL_PROTO.

Reviewed by:	markj
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D40681
2024-04-07 18:52:51 -05:00
Jake Freeland 0cd9cde767 ktrace: Record namei violations with KTR_CAPFAIL
Report namei path lookups while Capsicum violation tracing with
CAPFAIL_NAMEI. vfs caching is also ignored when tracing to mimic
capability mode behavior.

Reviewed by:	markj
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D40680
2024-04-07 18:52:51 -05:00
Jake Freeland 6a4616a529 ktrace: Record signal violations with KTR_CAPFAIL
Report the delivery of signals to processes other than self while
Capsicum violation tracing with CAPFAIL_SIGNAL.

Reviewed by:	markj
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D40679
2024-04-07 18:52:51 -05:00
Jake Freeland 05296a0ff6 ktrace: Record syscall violations with KTR_CAPFAIL
Report syscalls that are not allowed in capability mode with
CAPFAIL_SYSCALL.

Reviewed by:	markj
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D40678
2024-04-07 18:52:51 -05:00
Jake Freeland 96c8b3e509 ktrace: Record cpuset violations with KTR_CAPFAIL
Report Capsicum violations in the cpuset namespace with CAPFAIL_CPUSET.

Reviewed by:	markj
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D40677
2024-04-07 18:52:51 -05:00
Jake Freeland 9bec841312 ktrace: Record detailed ECAPMODE violations
When a Capsicum violation occurs in the kernel, ktrace will now record
detailed information pertaining to the violation.

For example:
- When a namei lookup violation occurs, ktrace will record the path.
- When a signal violation occurs, ktrace will record the signal number.
- When a sendto(2) violation occurs, ktrace will record the recipient
  sockaddr.

For all violations, the syscall and ABI is recorded.

kdump is also modified to display this new information to the user.

Reviewed by:	oshogbo, markj
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D40676
2024-04-07 18:52:51 -05:00
Rick Macklem 401c0f8aa1 exports.5: Add RFC number for NFS over TLS
This is a content change.

MFC after:	1 week
2024-04-07 16:35:55 -07:00
Ed Maste e8b7c78c1b Cirrus-CI: switch to llvm18 by default
As of commit 439352ac82 Clang/LLVM 18 is the default in-tree compiler.
Follow suit in with the external toolchain package used by Cirrus-CI.

Sponsored by:	The FreeBSD Foundation
2024-04-07 17:23:25 -04:00
Michael Tuexen e8c149ab85 tcp: add some debug output
Also log, when dropping text or FIN after having received a FIN.
This is the intended behavior described in RFC 9293.
A follow-up patch will enforce this behavior for the base stack
and the RACK stack.
Reviewed by:		rscheff
MFC after:		3 days
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D44669
2024-04-07 22:41:24 +02:00
Dimitry Andric 4c983a2886 libcompiler_rt Makefile.inc: include bsd.compiler.mk to fix build
Apparently libgcc_s has always included libcompiler_rt's Makefile.inc
without first including bsd.compiler.mk, even though Makefile.inc used
COMPILER_TYPE already. It looks like we were just lucky that the
expression was not malformed.

PR:		276104
Reported by:	Herbert J. Skuhra <herbert@gojira.at>
MFC after:	1 month
2024-04-07 21:45:51 +02:00
Dimitry Andric 2e226748a9 libcompiler_rt Makefile.inc: don't build bfloat16 support for gcc < 13
Older versions of gcc produce "error: unknown type name '__bf16'".

PR:		276104
MFC after:	1 month
2024-04-07 20:21:01 +02:00
Dimitry Andric d00b9344bb libcompiler_rt Makefile.inc: remove debugging messages
PR:		276104
MFC after:	1 month
2024-04-07 20:16:52 +02:00
Dimitry Andric b811dac211 Fix GENERIC-KASAN kernel build for amd64
Work around https://github.com/llvm/llvm-project/issues/87923, which
leads to an assertion failure compiling several kernel source files with
asan enabled.

PR:		276104
MFC after:	1 month
2024-04-07 19:58:52 +02:00
Doug Moore 1526667bc6 vm_reserv: Add vm_reserv_is_populated
Add a function to check whether an aligned block of vm pages are
allocated, for use with impending changes to arm64 superpage
managment.

Reviewed by:	alc
Differential Revision:	http://reviews.freebsd.org/D44575
2024-04-07 12:28:52 -05:00
Dimitry Andric 61e482f2fc Fix arm64 build after llvm 18.1.3 upgrade (take 2)
Instead of compiling the whole sys/arm64/arm64/vfp.c file without
-mgeneral-regs-only, which might have unwanted side effects, add
".arch_extension fp" / ".arch_extension nofp" pairs to the inline
assembly.

PR:		276104
Suggested by:	andrew
MFC after:	1 month
2024-04-07 11:23:06 +02:00
Dimitry Andric f4d93b6761 Fix arm64 build after llvm 18.1.3 upgrade
Apparently clang 18 has become more strict about using floating point
registers in inline assembly when -mgeneral-regs-only is used. This
causes sys/arm64/arm64/vfp.c to fail to compile, with "error:
instruction requires: fp-armv8", and "error: expected readable system
register".

To fix it, similar to other files compiled for arm64, disable
-mgeneral-regs-only for this particular file.

PR:		276104
MFC after:	1 month
2024-04-07 02:07:38 +02:00
Dimitry Andric 0192eda105 Bump __FreeBSD_version for llvm 18.1.3 merge
PR:		276104
MFC after:	1 month
2024-04-06 22:15:21 +02:00
Dimitry Andric 439352ac82 Merge llvm-project release/18.x llvmorg-18.1.3-0-gc13b7485b879
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.3-0-gc13b7485b879.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:34 +02:00
Dimitry Andric 49a6e426df Merge commit f5f3d5d6534f from llvm-project (by Qizhi Hu):
[Clang][Sema] Fix a crash in lambda instantiation (#85565)

  Fix https://github.com/llvm/llvm-project/issues/85343
  When build lambda expression in lambda instantiation, `ThisType` is
  required in `Sema::CheckCXXThisCapture` to build `this` capture. Set
  `this` type by import `Sema::CXXThisScopeRAII` and it will be used later
  in lambda expression transformation.

  Co-authored-by: huqizhi <836744285@qq.com>

This fixes 'Assertion failed: (!isNull() && "Cannot retrieve a NULL type
pointer"), function getCommonPtr" when building the x11-wm/wayfire port.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:31 +02:00
Dimitry Andric ce4f1f49e0 Revert commit 6255157d24e2 from llvm-project (by Dimitry Andric):
[libc++] Re-enable std::pair trivial copy constructor for FreeBSD >= 14

  After many years of using the really old std::pair ABI which did not yet
  have a trivial copy constructor, FreeBSD 14 and later will finally get
  rid of it. Only use the old ABI for FreeBSD 13 and earlier.

  Note: on the FreeBSD side, we will bump our libc++.so version for this,
  and keep an old compatibility library in a separate package.

  Differential Revision: https://reviews.llvm.org/D126462

This ABI change can cause crashes when binaries compiled against older
libc++ versions are run against binaries compiled against this libc++
version.

For example, lang/ldc uses a precompiled bootstrap ldc2 binary that was
compiled against the old libc++, but also links against libLLVM-15.so.
If libLLVM-15.so is compiled against the new libc++ version, the ABI
mismatch results in segfaults or even stack overflows.

Note: we can only re-enable the std::pair trivial copy constructors
again when the official libc++ ABI version is bumped to 2.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:31 +02:00
Dimitry Andric 4c2d3b022a Merge llvm-project release/18.x llvmorg-18.1.1-0-gdba2a75e9c7e
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.1-0-gdba2a75e9c7e.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:25 +02:00
Dimitry Andric 56727255ad Merge llvm-project release/18.x llvmorg-18.1.0-rc3-0-g6c90f8dd5463
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.0-rc3-0-g6c90f8dd5463.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:19 +02:00
Dimitry Andric 74626c16ff Merge llvm-project release/18.x llvmorg-18.1.0-rc2-53-gc7b0a6ecd442
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.0-rc2-53-gc7b0a6ecd442.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:13 +02:00
Dimitry Andric b3edf44679 Merge llvm-project release/18.x llvmorg-18.1.0-rc2-0-gc6c86965d967
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.0-rc2-0-gc6c86965d967.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:07 +02:00
Dimitry Andric 868ee3f285 [libc++] Rename __bit_reference template parameter to avoid conflict
As of 4d20cfcf4eb08217ed37c4d4c38dc395d7a66d26, `__bit_reference`
contains a template `__fill_n` with a bool `_FillValue` parameter.

Unfortunately there is a relatively widely used piece of scientific
software called NetCDF, which exposes a (C) macro `_FillValue` in its
public headers.

When building the NetCDF C++ bindings, this quickly leads to compilation
errors when the macro interferes with the template in `__bit_reference`.

Rename the parameter to `_FillVal` to avoid the conflict.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:03 +02:00
Dimitry Andric dc36515b62 Merge commit 5f4ee5a2dfa9 from llvm-project (by Shanzhi):
[Clang][AST] Fix a crash on attaching doc comments (#78716)

  This crash is basically caused by calling
  `ASTContext::getRawCommentForDeclNoCacheImp` with its input arguments
  `RepresentativeLocForDecl` and `CommentsInTheFile` refering to different
  files. A reduced reproducer is provided in this patch.

  After the source locations for instantiations of funtion template are
  corrected in the commit 256a0b298c68b89688b80350b034daf2f7785b67, the
  variable `CommitsInThisFile` in the function
  `ASTContext::attachCommentsToJustParsedDecls` would refer to the source
  file rather than the header file for implicit function template
  instantiation. Therefore, in the first loop in
  `ASTContext::attachCommentsToJustParsedDecls`, `D` should also be
  adjusted for relevant scenarios like the second loop.

  Fixes #67979
  Fixes #68524
  Fixes #70550

This should fix a segfault when compiling graphics/gdal.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:02 +02:00
Dimitry Andric ddbac700c2 Merge commit 6e4930c67508 from llvm-project (by Alexander Kornienko):
Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)"

  This reverts commit 924701311aa79180e86ad8ce43d253f27d25ec7d. Causes compilation
  errors on valid code, see
  https://github.com/llvm/llvm-project/pull/77768#issuecomment-1908062472.

In particular, this fixes bogus "call to constructor of 'SomeType' is
ambiguous" errors.

PR:		276104
MFC after:	1 month
2024-04-06 22:14:01 +02:00
Dimitry Andric 878ed4957e Merge llvm-project release/18.x llvmorg-18-init-18361-g22683463740e
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18-init-18361-g22683463740e.

PR:		276104
MFC after:	1 month
2024-04-06 22:13:56 +02:00