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
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
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
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
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
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
timer_shutdown_sync not only shutdowns a timer but prevents it rearming.
Sponsored by: Serenity CyberSecurity, LLC
Reviewed by: emaste
MFC after: 1 week
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
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
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
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
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
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
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
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
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
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
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
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
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
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
[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
[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
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
[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#67979Fixes#68524Fixes#70550
This should fix a segfault when compiling graphics/gdal.
PR: 276104
MFC after: 1 month
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