Peter Seiderer [Mon, 8 Jul 2024 09:05:47 +0000 (11:05 +0200)]
Add support for landlock_create_ruleset (444), landlock_add_rule (445) and landlock_restrict_self (446) syscalls
- add support for landlock_create_ruleset (444) syscall
- add support for landlock_add_rule (445) syscall
- add support for landlock_restrict_self (446) syscall
Mark Wielaard [Sat, 23 Nov 2024 21:48:03 +0000 (22:48 +0100)]
drd/tests/swapcontext.c: Rename typedef struct thread_local to threadlocal
Since C23 thread_local is a keyword (thread storage duration).
swapcontext.c:23:16: error: expected '{' before 'thread_local'
23 | typedef struct thread_local {
| ^~~~~~~~~~~~
swapcontext.c:23:16: warning: 'thread_local' is not at beginning of declaration [-Wold-style-declaration]
swapcontext.c:23:16: error: 'thread_local' used with 'typedef'
swapcontext.c:26:3: warning: data definition has no type or storage class
26 | } thread_local_t;
| ^~~~~~~~~~~~~~
Mark Wielaard [Sat, 23 Nov 2024 21:37:14 +0000 (22:37 +0100)]
helgrind/tests/tc17_sembar.c: Remove bool typedef
Since C23 bool is a keyword. Also bool wasn't actually used.
tc17_sembar.c:45:14: error: both 'long' and '_Bool' in declaration specifiers
45 | typedef long bool;
| ^~~~
tc17_sembar.c:45:1: warning: useless type name in empty declaration
45 | typedef long bool;
| ^~~~~~~
Mark Wielaard [Sat, 23 Nov 2024 20:28:13 +0000 (21:28 +0100)]
Add exp and supp patterns for missing main frame for ppc64le
In some cases on ppc64le we are missing the main frame.
Add alternative .exp-ppc64le variants for socket_close_xml,
fdleak_cmsg_xml and fdleak_ipv4_xml. And extra suppressions
without a main frame for fdleak_cmsg_supp.
See also commit 04d30049b "Filter away "main" differences in filter_fdleak"
Paul Floyd [Thu, 21 Nov 2024 07:24:35 +0000 (08:24 +0100)]
Helgrind: fix unused result of write warnings
Thanks to GCC deciding that we can't ignore wur annotated
functions by casting to void we need to do otherwise. It was
either pragmas or adding an annotated unused local. Pragmas
seem to be the least awful.
Bart Van Assche [Mon, 18 Nov 2024 21:15:36 +0000 (13:15 -0800)]
drd: Split handle_client_request()
Make handle_client_request() easier to read by splitting it into two
functions: one for Valgrind core client requests and one for thread-
related client requests.
Mark Wielaard [Thu, 14 Nov 2024 11:25:27 +0000 (12:25 +0100)]
coregrind/m_gdbserver/remote-utils.c (prepare_resume_reply): Use memcpy
GCC8 (but apparently not later versions) complain about the use of
strncpy when not actually copying a string:
remote-utils.c:1140:14: warning: 'char* strncpy(char*, const char*, size_t)' output truncated before terminating nul copying 6 bytes from a string of the same length [-Wstringop-truncation]
strncpy (buf, "watch:", 6);
~~~~~~~~^~~~~~~~~~~~~~~~~~
This is "harmless" because buf is large enough and we will add more
chars (including a zero terminator) later. But using strncpy here is a
bit odd because we don't really want to copy a string, but an array of
6 chars. So use memcpy here to do so, simplyfing the code.
Mark Wielaard [Tue, 12 Nov 2024 12:34:09 +0000 (13:34 +0100)]
vgdb.c (fork_and_exec_valgrind): Fix another off-by-one error write
commit 646978d9adc5 ("vgdb: Handle EINTR and EAGAIN more
consistently") introduced another off-by-one issue trying to write
back the error from child to parent.
Instead of +1 it should have been +written (which initially is zero).
This is when the child needs to do a chdir and that chdir fails. If
that happens the parent would have gotten the wrong error code.
commit 646978d9adc5 ("vgdb: Handle EINTR and EAGAIN more
consistently") introduced an off-by-one issue trying to write back the
error from child to parent.
Instead of +1 it should have been +written (which initially is zero).
This is in an "should never happen" path, so hopefully didn't really
cause issues. But if it did happen the parent would have gotten the
wrong error code.
Andreas Arnez [Fri, 8 Nov 2024 13:52:11 +0000 (14:52 +0100)]
s390x regtest: Add missing register clobber in misc3.c
Depending on compiler options, the translation of test_mvcrl() in
`misc3.c' can misbehave because the inline assembly writes to r0 and
doesn't declare that.
Add a register clobber to fix this. Also, tell the compiler the actual
length of `from' and `to' instead of the decremented value.
Paul Floyd [Sun, 3 Nov 2024 19:42:43 +0000 (20:42 +0100)]
Bug 494327 - Crash when running Helgrind built with #define TRACE_PTH_FNS 1
Use write() rather than 'fprintf()' for the TRACE_PTH_FNS blocks for
pthread_mutex_lock and pthread_mutex_lock. Mixing FILE and fd isn't
great, but this is to stderr which gets flushed on every line, and
it is only for developer builds that modify that TRACE_PTH_FNS macro.
Report track-fd errors for fd used which was not opened or already closed
Add (optional) pathname, description, where_closed and where_opened
fields to struct FdBadUse. Print those fields when set in fd_pp_Error.
Add a new function ML_(find_OpenFd) that provides a recorded OpenFd
given an fd (or NULL when the fd was never recorded).
In ML_(fd_allowed) when using a file descriptor use ML_(find_OpenFd)
to see if the fd was ever created, if not create an "was never
created" FdBadUse error. If it was created, but already closed create
an "was closed already", filling in as much details as we can.
Add none/tests/use_after_close.vgtest to test, already closed, never
created, invalid, double (double) close and invalid close issues.
Adjust error message in none/tests/fdbaduse.stderr.exp.
Florian Krohm [Tue, 29 Oct 2024 15:24:31 +0000 (16:24 +0100)]
Bug 493959 - s390x: Fix regtest failure for op00 with /bin/dash
On different machines /bin/sh may be impersonated by different shells, and
those behave differently as to whether they write "Illegal instruction ..."
to stderr. While newer versions of bash do not, dash does.
For the op00 test case this means that an additional line may be written
to `op00.stderr.out', depending on which shell is being used. Hence
adding "Illegal instruction ..." as an expected line to `op00.stderr.exp'
wouldn't work on all systems.
Instead, fix this issue by adding the case of "illegal instruction" to the
general filtering logic in filter_stderr_basic.in, where various other
messages of this kind are already filtered out.
Carl Love [Wed, 23 Oct 2024 23:25:23 +0000 (18:25 -0500)]
PowerPC, dcbf instruction
ISA 2.7 and ISA 3.0 "accepts" L = 0 to 3, ISA 3.1 "accepts: L = 0 to 7.
Removed the L field check so valgrind will match the real hardware. For
the purposes of Valgrind the dcbf instruction is a NOP anyway so it will
not change the behavior of Valgrind.
Paul Floyd [Sat, 12 Oct 2024 07:10:21 +0000 (09:10 +0200)]
FreeBSD helgrind: temporary (?) fix for Bug 494337
FreeBSD 15 has added a pthread lock to exit() to ensure that atexit handling
is thread safe. Unfortunately that lock gets leaked which messes up just about
all of the Helgrind tests.
Supression won't work as the callstack is the same for both genuine leaks
and this deliberate leak.
This change simply turns off the check for FreeBSD >= 15.
I see two possible proper fixes. One would be to allow one lock on exit.
The problem with that is that we will need to tell apart a clean exit
(1 lock allowed) and any kind of abort that doesn't call exit (no locks
allowed). That's going to be tricky as the Helgrind check is done before
we get back to core and know whether it is an abort or a clean exit.
The other thing would be to hack the lock counting. If we can detect that
it's a pthread_mutex_lock called from exit() then we could ignore that for
counting purposes. That would mean a possibly significant overhead for
each call to pthread_mutex_lock on FreeBSD.
Introduce a new FdBadFd type with associated extra info struct.
Which for now just holds the fd number (no path or description).
fd_pp_Error and fd_update_extra have been updated to handle the
new type and produce xml when requested.
Rename showing_core_errors to showing_core_warning
(returns yes when the tools wants to show core errors,
-q isn't given and we aren't producing xml).
In ML_(fd_allowed) we now call VG_(maybe_record_error) to
generate a real error (that can be suppressed and shows up
in the xml output with full execution backtrace). For now
we also produce the legacy warnings when --track-fds=yes
isn't given.
Add none/tests/fdbaduse.vgtest to test the new FdBadUse
core error.
This is the first part of reporting bad fd usage errors.
We are also tracking already closed file descriptors which
should also produce errors like these. The current bad file
descriptors are just those that are negative or above the
current file limit of the process.
Andreas Arnez [Wed, 9 Oct 2024 15:10:08 +0000 (17:10 +0200)]
s390x: Add missing early-clobber to GET_STARTREGS
The inline assembly for GET_STARTREGS in m_libcassert.c writes to its
output before using the input argument. But since the compiler doesn't
know this, it is allowed to allocate the same register for both, causing
problems. This has been seen when compiling Valgrind with -O0, after
which memcheck/tests/leak-autofreepool-5 fails due to SIGSEGV.
Fix this by declaring the output as early-clobber, so the compiler knows
about the restriction.
Andreas Arnez [Wed, 9 Oct 2024 15:10:08 +0000 (17:10 +0200)]
Bug 493970 - s390x: Drop saving/restoring FPC upon helper call
Saving the FPC before each helper call and restoring it afterwards creates
unnecessary overhead, and it may also not be desirable.
Drop it. Also remove the functions in host_s390_defs.c responsible for
emitting LFPC and STFPC instructions. And since this frees up the FPC
save slot on the stack, adjust the stack layout accordingly.
Andreas Arnez [Wed, 9 Oct 2024 15:10:08 +0000 (17:10 +0200)]
Fix some issues with GSL for `make auxchecks'
When trying to reproduce Bug 423908, I ran into some trouble performing
`make auxchecks', due to problems in GSL:
Newer compilers complain about incompatible pointer types in argument
passing between
unsigned int *
and
size_t *
This affects the fifth argument of function gsl_eigen_jacobi() in
eigen/jacobi.c. Fix this by passing the right pointer type at invocation.
Also, the configure checks for IEEE comparisons and for IEEE denormalized
values don't work as intended, because they call exit() without declaring
it and thus fail independently from those features being supported. Fix
this by using `return' instead.
Paul Floyd [Tue, 8 Oct 2024 19:03:17 +0000 (21:03 +0200)]
macOS regtest: give up trying to build bug492210.c
macOS has to make everything difficult. Global names need
to be decorated with an underscore prefix. And you can't
just read from global variables, you have to do something
like a rip-relative lea.
Paul Floyd [Mon, 7 Oct 2024 05:34:59 +0000 (07:34 +0200)]
FreeBSD regtest: add FAKE macros for scalar
FreeBSD 15 removed the never-implemented sbrk syscall.
Arm64 also has a few missing syscalls (backward compat ones
that predate the arm64 port). Rather than having an ever
increasing number of expecteds the aim is to use these
FAKE macros. It's a bit fiddly to get the matching text.
Mark Wielaard [Sun, 22 Sep 2024 21:24:34 +0000 (23:24 +0200)]
Implement /proc/self/exe readlink[at] fallback in POST handler
Calling the readlink[at] syscall directly from the PRE handler defeats
the FUSE_COMPATIBLE_MAY_BLOCK (SfMayBlock) flag. Add a POST handler
that only explicitly calls the readlink[at] handler for the
/proc/self/exe fallback (this should be fine unless /proc is also
implemented as fuse in this process).
Adjust readlink[at] GENX_ and LINX_ syswrap macros to GENXY and LINXY.