Paul Floyd [Mon, 23 May 2022 19:27:58 +0000 (21:27 +0200)]
Add small sleep to none/tests/pth_2sig to help prevent hanging
On FreeBSD 13.0 x86 this testcase was hanging on some systems.
It seems like the SIGTERM signals were not being recieved
before the child exited, which left the parent hanging in the
pause() waiting to be killed.
Reported, patch provided and tested by Nick Briggs.
Paul Floyd [Sun, 22 May 2022 11:05:10 +0000 (13:05 +0200)]
Change coredump note names for FreeBSD
Was not able to load vgcore files with lldb on FreeBSD.
I think that there is a way to go for lldb / FreeBSD to be able to fully read vgcore files.
See
https://www.moritz.systems/blog/lldb-core-dump-support-improvements/
Aaron Merey [Mon, 9 May 2022 20:56:23 +0000 (16:56 -0400)]
Add --enabled-debuginfod command line option
Currently debuginfod is enabled in Valgrind when the $DEBUGINFOD_URLS
environment variable is set and disabled when it isn't set.
This patch adds an --enable-debuginfod=<yes|no> command line option
to provide another level of control over whether Valgrind attempts
to download debuginfo. "yes" is the default value.
$DEBUGINFOD_URLS must still contain debuginfod server URLs in order
for this feature to work when --enable-debuginfod=yes.
Paul Floyd [Wed, 18 May 2022 21:41:43 +0000 (23:41 +0200)]
Make testcase myrandom() noinline.
With clang 13 none/tests/amd64/amd64locked fails because of what
looks like a clang optimization error. do_bt_G_E_tests is the
point of failure, and one factor is that clang 13 is inlining
myrandom().
Paul Floyd [Sat, 14 May 2022 14:46:03 +0000 (16:46 +0200)]
More changes for FreeBSD 13.1
These concern auxv, swapoff and fcntl F_KINFO
I wanted to use the new fcntl K_INFO to replace the existing
horrible implementation of resolve_filename, but it seems to
have change the behaviour for redirected files. Several
fdleak regtests fail because stdout resolves to an empty
string.
Mike Crowe [Mon, 9 Sep 2019 13:16:16 +0000 (14:16 +0100)]
Intercept strncmp for glibc ld.so v2.28+
In glibc 5aad5f617892e75d91d4c8fb7594ff35b610c042 (first released in
v2.28) a call to strncmp was added to dl-load.c:is_dst. This causes
valgrind to complain about glibc's highly-optimised strncmp performing
sixteen-byte reads on short strings in ld.so. Let's intercept strncmp in
ld.so too so we use valgrind's simple version to avoid this problem.
Paul Floyd [Mon, 9 May 2022 20:53:04 +0000 (22:53 +0200)]
Bug 446754 Improve error codes from alloc functions under memcheck
I've made these changes only for FreeBSD and Solaris for the moment.
I don't know what should be done on Linux for aligned_alloc/memalign.
The current Valgrind code refects the glibc implementation, but not
what the documentation says.
Paul Floyd [Mon, 9 May 2022 06:15:06 +0000 (08:15 +0200)]
Update clang version of insn-pmovmskb expected.
I'm not sure when this output changed.
This expected differs from the main GCC expected due to clang emitting
a cmovne for the ternary expression in 'use':
fprintf(stderr, "%d: Invalid value is %s\n", index, invalid ? "true" : "false");
Di Chen [Thu, 14 Apr 2022 16:08:17 +0000 (00:08 +0800)]
Support new memfd_secret linux syscall (447)
memfd_secret is a new syscall in linux 5.14. memfd_secret() is
disabled by default and a command-line option needs to be added to
enable it at boot time.
Paul Floyd [Tue, 12 Apr 2022 21:34:41 +0000 (23:34 +0200)]
Bug 452274 memcheck crashes with Assertion 'sci->status.what == SsIdle' failed
FreeBSD (and Darwin) use the carry flag for syscall syscall status.
That means that in the assembler for do_syscall_for_client_WRK
they have a call to LibVEX_GuestAMD64_put_rflag_c (amd64) or
LibVEX_GuestX86_put_eflag_c (x86). These also call WRK functions.
The problem is that do_syscall_for_client_WRK has carefully crafted
labels correspinding to IP addresses. If a signal interrupts
processdings, IP can be compared to these addresses so that
VG_(fixup_guest_state_after_syscall_interrupted) can work
out how to resume the syscall. But if IP is in the save
carry flag functions, the address is not recognized and
VG_(fixup_guest_state_after_syscall_interrupted) fails.
The crash in the title happens because the interrupted
syscall does not reset its status, and on the next syscall
it is expected that the status be idle.
To fix this I added global variables that get set to 1
just before calling the save carry flag functions, and cleared
just after. VG_(fixup_guest_state_after_syscall_interrupted)
can then check this and work out which section we are in
and resume the syscall correctly.
Also:
Start a new NEWS section for 3.20
Add a regtest for this and also a similar one for Bug 445032
(x86-freebsd only, new subdir).
I saw that this problem also probably exists with macOS, so I made
the same changes there (not yet tested)
Mark Wielaard [Mon, 11 Apr 2022 12:45:49 +0000 (14:45 +0200)]
Extend helgrind suppression for _IO_*xsputn* FILE* state manipulation
commit 7b5867b1f "helgrind reports false races for printfs using
mempcpy on FILE* state" extended the helgrind-glibc-io-xsputn
suppression by also covering mempcpy (instead of __GI_mempcpy).
The test added in that commit exposed a couple of other variants
of this suppression where _IO_*xsputn* called memcpy (instead of
mempcpy) and/or had an extra indirection/function in between.
Replace the two two suppressions with one that covers all cases
where _IO_*xsputn* *mem*cpy variants with possibly another ...
function in between.
Mark Wielaard [Fri, 8 Apr 2022 12:58:38 +0000 (14:58 +0200)]
helgrind reports false races for printfs using mempcpy on FILE* state
We already have a suppression for helgrind which is for when glibc
uses __GI_mempcpy to manipulate internal FILE state (this was bug
352130). But since glibc-2.26 mempcpy is used instead __GI_mempcpy,
making the suppresion from the original bug obsolete.
This patch adds a new suppression using mempcpy but doesn't replace
the original suppression for older systems.
Patch adding suppression + testcase by Jesus Checa <jcheca@redhat.com>
Randy MacLeod [Wed, 17 Oct 2018 01:01:04 +0000 (21:01 -0400)]
Fix out of tree builds.
The paths to these files need to be fully specified in
the out of tree build case. glibc-2.X.supp is a generated file so the
full path is deliberately not specified in that case.
Also adjust the mpi include dir location as valgrind.h is
generated as well and needs to be taken out of build dir.
Also adjust the location of generated xml file. And the search paths
for the xmllint, xsltproc and xmlto programs.
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Aaron Merey [Wed, 26 Jan 2022 01:24:18 +0000 (20:24 -0500)]
Bug 445011: SIGCHLD is sent when valgrind uses debuginfod-find
Valgrind fork+execs debuginfod-find in order to perform debuginfod
queries. Any SIGCHLD debuginfod-find sends upon termination can
mistakenly be delivered to the client running under valgrind.
To prevent this, record in a hash table the PID of each process
valgrind forks for internal use. Do not send SIGCHLD to the client
if it is from a PID in this hash table.
Mark Wielaard [Thu, 7 Apr 2022 20:02:12 +0000 (22:02 +0200)]
Update mc_main Copyright message to include 2022
We haven't ran auxprogs/change-copyright-year since we switched to git.
This means most Copyright year ranges still say 2017. The script also
doesn't work for years >= 2020. Instead of trying to figure out how to
correctly update the per file Copyright year ranges just update the
main copyright notice that the program outputs on startup.
Since memfd_secret introduced in kernel 5.14, valgrind should rename
the "memfd" test to "memfd_create" test to avoid the ambiguity, so that
user will not get confused with the "memfd_secret" test.
After this change, syscall memfd_create will be tested by:
Mark Wielaard [Wed, 16 Feb 2022 21:56:31 +0000 (22:56 +0100)]
Warn for execve syscall with argv or argv[0] being NULL.
For execve valgrind would silently fail when argv was NULL or
unadressable. Make sure that this produces a warning under memcheck.
The linux kernel accepts argv[0] being NULL, but most other kernels
don't since posix says it should be non-NULL and it causes argc to
be zero which is unexpected and might cause security issues.
This adjusts some testcases so they don't rely on execve succeeding
when argv is NULL and expect warnings about argv or argv[0] being
NULL or unaddressable.
Carl Love [Tue, 5 Apr 2022 01:31:33 +0000 (21:31 -0400)]
Powerpc 32bit, fix the vbpermq support
Passing the two 128-bit vA and vB arguments doesn't work in 32-bit mode.
The clean helper was changed to compute the result for 8 indexes. The
helper is then called twice to get the result for the upper 64-bits of the
vB register and the lower 64-bits of the vB register.
The patch is an additional fix for bugzilla 451827.
Paul Floyd [Sun, 3 Apr 2022 20:00:09 +0000 (22:00 +0200)]
Fixes for memcheck/tests/freebsd/realpathat
The syscall to realpathat was missing the buffer size argument.
By luck, no problem on amd64 but this failed on x86.
This adds the argument and a filter for the errors (size_t can be 4 or 8 bytes)
Mark Wielaard [Fri, 1 Apr 2022 15:28:24 +0000 (17:28 +0200)]
configure.ac: AC_HEADER_TIME is deprecated just check for sys/time.h
AC_HEADER_TIME is deprecated and checks for various things, like
whether you can include both time.h and sys/time.h together. Which
is fine on all systems these days. Just check whether sys/time.h
is available. HAVE_SYS_TIME_H is used once in the code base in the
timerfd-syscall.c testcase. So even this limited check might be
overkill.
Carl Love [Wed, 23 Mar 2022 18:41:16 +0000 (13:41 -0500)]
Powerpc, re-implement the vbpermq instruction support
The instruction support generates too many Iops when multiple vbpermq
instructions occur together in the binary. This patch changes the
implementation to use a clean helper and thus avoid overflowing the
internal Valgrind buffer.
Mark Wielaard [Sat, 19 Mar 2022 00:06:40 +0000 (01:06 +0100)]
bpf attr->raw_tracepoint.name may be NULL for BPF_RAW_TRACEPOINT_OPEN.
For BPF_RAW_TRACEPOINT_OPEN attr->raw_tracepoint.name may be NULL.
Otherwise it should point to a valid (max 128 char) string. Only
raw_tracepoint.prog_fd needs to be set.
Carl Love [Fri, 11 Feb 2022 20:07:20 +0000 (14:07 -0600)]
Powerpc: Fix checking for scv support, add check to scv instruction parsing.
The check for the scv instruction in coregrind/m_machine.c issues an scv
instruction and uses sigill to determine if the instruction is supported.
Issuing scv on systems that don't support scv, i.e. scv support is not in
HWCAPS2, generates a message in dmesg "Facility 'SCV' unavailable (12),
exception".
This patch removes the sigill based scv instruction test from
coregrind/m_machine.c. The scv support is now determined by reading the
HWCAPS2 in setup_client_stack(). VG_(machine_ppc64_set_scv_support) is
called to set the flag ppc_scv_supported in struct VexArchInfo.
The allow_scv flag is added in disInstr_PPC_WRK. The allow_scv flag is
used to ensure the host has support for scv before generating the iops for
the scv instruction.
On s390x Linux platforms the sys_ipc semtimedop call has four instead of
five parameters, where the timeout is passed in the third instead of the
fifth.
Reflect this difference in the handling of VKI_SEMTIMEDOP.
Mark Wielaard [Fri, 11 Feb 2022 16:50:47 +0000 (17:50 +0100)]
arm64: Mismatch detected between RDMA and atomics features
check_hwcaps contains code that tries to enforce Arm architecture's
rules for the support of features (FEAT_) on v8.1. Specifically for
v8.1 FEAT_RDM and FEAT_LSE (named FEAT_ATOMICS in Valgrind) are
mandatory.
But an v8.x implementation can implement any of the v8.{x+1}
features, or not, as it chooses. Also under QEMU, which tends
to implement features on an "as-demanded" basis, you sometimes
end up with an odd combination of features, which does not
strictly comply with the architecture.
So ignore the "v8.x" architecture levels, and look only only at
"is feature X present or not". Unless the features are really not
independent.
Carl Love [Tue, 8 Feb 2022 23:52:33 +0000 (17:52 -0600)]
Powerpc: Update ACC support to reflect being mapped over vsr registers
The ISA 3.1 implemention provides the effect of ACC and VSRs
logically containing the same data. Future versions of the
hardware may define new state or redefine the backing state
of the registers.
This reworks the code to support the ACC as implemented as a logical
mapping over the VSR registers, and lays groundwork for a future
implementation utilizing a separate register file. There
is a single boolean variable, ACC_mapped_on_VSR, that can be set in
disInstr_PPC_WRK(), based on the ISA being used, to select which
implementation model to use.
Mark Wielaard [Wed, 9 Feb 2022 22:37:53 +0000 (23:37 +0100)]
Do not try to record fd name for io_uring_setup
In POST(sys_io_uring_setup) we tried to use record_fd_open_with_given_name
with ARG1 as name. But ARG1 isn't a char pointer. So this might crash with
--track-fds=yes. Since no (file) name is associated with the fd returned by
io_uring_setup use record_fd_open_nameless instead.
Andreas Arnez [Mon, 3 Jan 2022 17:15:05 +0000 (18:15 +0100)]
s390: Fix VFLRX and WFLRX instructions
Due to a typo in s390_irgen_VFLR, the VFLR instruction behaves incorrectly
when its m3 field contains 4, meaning extended format. In that case VFLR
is also written as VFLRX (or WFLRX) and supposed to round down from the
extended 128-bit format to the long 64-bit format. However, the typo
checks for m3 == 2 instead, so the value of 4 is unhandled, causing
Valgrind to throw a specification exception.
Mark Wielaard [Tue, 8 Feb 2022 15:36:08 +0000 (16:36 +0100)]
ppc64 --track-origins=yes failure because of bad cmov addHRegUse
For Pin_CMov getRegUsage_PPCInstr called addHRegUse for the dst
register with HRmWrite, but since this is a conditional move the
register could be both read and written (read + write = modify).
This matches the dst of Pin_FpCMov and Pin_AvCMov.
In a very rare case, and only with --track-origins=yes, this
could cause bad code generation.
This is slightly amazing, this code is from 2005 and as far as
I know we never seen an issue with --track-origins=yes on power
before. And I have been unable to come up simple reproducer.
Carl Love [Tue, 1 Feb 2022 21:29:30 +0000 (21:29 +0000)]
Fix setting condition code for Vector Compare quad word instructions.
The vcmpgtsq., vcmpgtuq,, vcmpequq. instructions set the condition code field
6 to 0b1000 for true, 0b0010 for false. The condition code was being set
according to the typical condition code values for equal and greater than
which is incorrect for these instructions. The patch fixes the setting of the
condition code as specified in the instructions.
Carl Love [Fri, 14 Jan 2022 23:04:44 +0000 (23:04 +0000)]
Assorted changes to protect from side affects from the feature checking code.
Patch contributed by Will Schmidt <will_schmidt@vnet.ibm.com>
This problem was initially reported by Tulio, he assisted me in
identifying the underlying issue here.
This was discovered on a Power10, and occurs since the ISA 3.1 support
check uses the brh instruction via a hardcoded ".long 0x7f1401b6" asm stanza.
That encoding writes to r20, and since the stanza does not contain a clobber
the compiler did not know to save or restore that register upon entry or exit.
The junk value remaining in r20 subsequently caused a segfault.
This patch adds clobber masks to the instruction stanzas, as well as
updates the associated comments to clarify which registers are being
used.
As part of this change I've also
- updated the .long for the cnttzw instruction to write to r20, and
zeroed the reserved bits from that instruction so it is properly
decoded by the disassembler.
- updated the .long for the dadd instruction to write to f0.
I've inspected the current codegen with these changes in place, and
confirm that r20 is now saved and restored on entry and exit from the
machine_get_hwcaps() function.
bugzilla 447995 Valgrind segfault on power10 due to hwcap checking code
Paul Floyd [Sat, 11 Dec 2021 11:32:08 +0000 (12:32 +0100)]
Bug 446823 FreeBSD - missing syscalls when using libzm4
Adds syscall wrappers for __specialfd and __realpathat.
Also remove kernel dependency on COMPAT_FREEBSD10.
This change also reorganizes somewhat the scalar test
and adds configure time checks for the FreeBSD version,
allowing regression tests to be compiled depending on the
FreeBSD release.
From now on, scalar.c will contain syscalls for FreeBSD 11 and 12
and subsequent releases will get their own scalar, starting with
scalar_13_plus.c.
Paul Floyd [Thu, 9 Dec 2021 21:54:23 +0000 (22:54 +0100)]
FreeBSD sigreturn arg names again
Also make drd/tests/shared_timed_mutex more robust
Already not great using time delays, but the test seems
to fail intermittently due to spurious wakeups. So instead
of railing straight away, make it "three strikes and you're out".