17085 Commits

Author SHA1 Message Date
Paul Floyd
8187a60ac3 Add a configure test for -ansi and use it for none/tests/ansi 2022-04-19 22:21:37 +02:00
Paul Floyd
1dbc46750f Bug 452779 Valgrind fails to build on FreeBSD 13.0 with llvm-devel (15.0.0)
This fixes building.

I may make the -lgcc and libgcc-sup conditonal on not using clang later.
2022-04-19 22:03:01 +02:00
Di Chen
fca4a3d8e5 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.

$ cat /proc/cmdline
[...] secretmem.enable=y

https://bugs.kde.org/451878
https://lwn.net/Articles/865256/
2022-04-19 11:59:36 +02:00
Dario Binacchi
9c9fd9ae24 coregrind: fix compilation for uclibc
It fixes a known iusse whose details are described at [1] and more
generally it guarantees that Valgrind is properly compiled for ulibc.

[1] https://www.mail-archive.com/valgrind-users@lists.sourceforge.net/msg05295.html

Suggested-by Michael Trimarchi <michael@amarulasolutions.com>
Co-developed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
2022-04-19 10:44:07 +02:00
Paul Floyd
d6bcd3ba29 Some more auxv extensions for FreeBSD 14
New entries added to testcase and documented in initimg.
May need more work
2022-04-14 00:01:49 +02:00
Paul Floyd
60dd674e71 Missing defines for FreeBSD 14 swapoff
+1 typo
2022-04-13 23:32:55 +02:00
Paul Floyd
cdd98111c7 Updates to FreeBSD syscalls for FreeBSD 14
3 new syscalls, and swapoff has a COMPAT13 version.
2022-04-13 23:00:44 +02:00
Paul Floyd
6c51e110a2 Update FreeBSD scalar for x86
Missed one execve diff.
2022-04-13 22:59:09 +02:00
Mark Wielaard
9fd4181b0e Set version to 3.20.0.GIT 2022-04-13 00:34:39 +02:00
Paul Floyd
d5b782056d Fix typo in EXTRA_DIST 2022-04-12 23:55:46 +02:00
Paul Floyd
3e7774ea5a 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)
2022-04-12 23:50:48 +02:00
Paul Floyd
68ac5ca0ea Fix building on macOS
Adds a feature check for clockid_t

Also fix a typo in a macro affecting pthread_mutex_clocklock on Linux.
2022-04-11 22:32:45 +02:00
Mark Wielaard
8d3c8034b8 -> 3.19.0 final. 2022-04-11 15:29:18 +02:00
Mark Wielaard
4c27f0f764 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.

https://bugs.kde.org/show_bug.cgi?id=450962
2022-04-11 14:45:49 +02:00
Paul Floyd
2b33a318d8 Update Solaris execve with checks for NULL argv
Also requires 2 expected to be updated
2022-04-10 23:02:13 +02:00
Paul Floyd
5f83395616 Fix a crash handling fexecve.
Found this by testing the Solaris execx (the bits that are
Linux-cmpatible) test. That was giving

--28286-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11 (SIGSEGV) - exiting
--28286-- si_code=2;  Faulting address: 0x4A0095A;  sp: 0x1002ca9c88

valgrind: the 'impossible' happened:
   Killed by fatal signal

host stacktrace:
==28286==    at 0x5803DE54: vgPlain_strcpy (m_libcbase.c:309)
==28286==    by 0x5810A9B3: vgSysWrap_linux_sys_execveat_before (syswrap-linux.c:13310)
==28286==    by 0x580953C9: vgPlain_client_syscall (syswrap-main.c:2234)

It's a mistake to copy the path obtained with VG_(resolve_filename) to
the client ARG2, it's unlikely to have space for the path.

Instead just copy the pointer.
2022-04-10 20:55:28 +02:00
Mark Wielaard
116b93b490 -> 3.19.0.RC2 2022-04-09 02:13:46 +02:00
Mark Wielaard
7b5867b1fd 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>

https://bugs.kde.org/show_bug.cgi?id=450962
2022-04-08 14:58:38 +02:00
Mark Wielaard
a1bb40171a Move ht_sigchld_ignore and ht_ignore_node to pub_tool_signals.h
ht_sigchld_ignore and ht_ignore_node were defined in pub_core_signals.h
which cannot include any other tool header.

...checking header files and include directives
*** File coregrind/pub_core_signals.h must not include pub_tool_hashtable.h

So move the definition and type to pub_tool_signals.h
2022-04-08 09:42:18 +02:00
Randy MacLeod
2c0fb66569 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>
2022-04-07 23:44:02 +02:00
Aaron Merey
2ad9335044 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.

https://bugs.kde.org/show_bug.cgi?id=445011
2022-04-07 22:09:57 +02:00
Mark Wielaard
7959d0661b 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.
2022-04-07 22:02:12 +02:00
Paul Floyd
19584a93d1 Update FreeBSD [f]execve expecteds
As requested by Mark, for https://bugs.kde.org/show_bug.cgi?id=450437
2022-04-07 07:56:27 +02:00
Di Chen
6a35b364c5 memfd test should be memfd_create test
Currently, syscall memfd_create was tested by this:

$ perl tests/vg_regtest memcheck/tests/linux/memfd.vgtest

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:

$ perl tests/vg_regtest memcheck/tests/linux/memfd_create.vgtest
2022-04-07 00:36:41 +02:00
Mark Wielaard
8eb547054a 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.

https://bugs.kde.org/show_bug.cgi?id=450437
2022-04-06 22:48:45 +02:00
Paul Floyd
f540c79937 Missed macro when adding FreeBSD 13.1
Also add the names of some new FreeBSD 14 syscalls (not yet
inplemented in Valgrind).
2022-04-06 20:54:19 +02:00
Carl Love
bc4dc04d5f 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.
2022-04-05 01:45:50 +00:00
Paul Floyd
615731617b Add missing bugzilla items and some more FreeBSD/DRD/Helgrind news 2022-04-04 07:52:45 +02:00
Paul Floyd
4dd849e4ec Second go at memcheck/tests/freebsd/relapathat
Missed adding the argument to the C file
Needs more filtering
2022-04-03 22:28:26 +02:00
Paul Floyd
e816f4c44f 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)
2022-04-03 22:00:09 +02:00
Paul Floyd
d6cdc6e523 Add filter to memcheck/tests/freebsd/fexecve for the size
Different size on x86 was causing a failure
2022-04-03 21:28:24 +02:00
Paul Floyd
6c91d2d4ee Extend FreeBSD procctl
4 new types added in FreeBSD 13.1
2022-04-03 18:27:17 +02:00
Paul Floyd
bbc3bcab0a Bug 451843 - valgrind fails to start on a FreeBSD system which enforces W^X
Also add FreeBSD 13.1 to configure.ac
2022-04-03 15:50:38 +02:00
Paul Floyd
aba645e5a5 Add some FreeBSD tests to .gitignore 2022-04-03 15:34:14 +02:00
Mark Wielaard
ece5611887 202? -> 2022 2022-04-02 20:22:02 +02:00
Mark Wielaard
25c406975b 3.19.0-RC1 Add some NEWS entries 2022-04-02 19:13:12 +02:00
Mark Wielaard
ff84a3542e 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.
2022-04-01 17:28:24 +02:00
Carl Love
00017cda52 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.

bugzilla 451827
2022-03-25 15:11:51 +00:00
Mark Wielaard
957339db27 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.

https://bugs.kde.org/show_bug.cgi?id=451626
2022-03-19 01:06:40 +01:00
Carl Love
7f11271403 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.
2022-02-18 19:12:21 +00:00
Andreas Arnez
03a8b24ae3 Bug 444552 - s390x: Fix sys_ipc semtimedop syscall
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.
2022-02-18 19:46:47 +01:00
Mark Wielaard
536e869f16 NEWS: Add bug 445916 Demangle Rust v0 symbols with .llvm suffix 2022-02-18 00:07:44 +01:00
Mark Wielaard
e0b62fe055 Update libiberty demangler
Update the libiberty demangler using the auxprogs/update-demangler
script to gcc git commit d3b2ead595467166c849950ecd3710501a5094d9.

This update includes:

- libiberty rust-demangle, ignore .suffix
- libiberty: Fix infinite recursion in rust demangler
- Update copyright years
- libiberty: support digits in cpp mangled clone names
- d-demangle: properly skip anonymous symbols
- d-demangle: remove parenthesis where it is not needed
2022-02-17 18:38:44 +01:00
Mark Wielaard
df214356db none/tests/amd64/avx_estimate_insn.vgtest fails on AMD processors
commit ef9ac3aa0fd3ed41d74707ffe49abe9ad2797ddd
"fix avx-1 amd64 test" split off the estimate instructions
into their own testcase avx_estimate_insn.

The commit message suggested that two .exp files would be
added, one for the intel and one for the amd cases.

It seems the .exp-amd variant was forgotten. This commit
adds it.

https://bugs.kde.org/show_bug.cgi?id=413330
2022-02-16 23:26:16 +01:00
Mark Wielaard
29954981d8 Add power_ISA2_05.stdout.exp_Without_FPPO_2 to EXTRA_DIST 2022-02-16 23:03:00 +01:00
Carl Love
ac8f8e9039 Powerpc: Additional expected output for memcheck/tests/ppc64/power_ISA2_05 test.
Latest compiler is generating slightly different effective address.
2022-02-14 17:30:15 +00:00
Mark Wielaard
13427e2ae7 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.

https://bugs.kde.org/show_bug.cgi?id=449494
2022-02-11 17:59:13 +01:00
Carl Love
193ced6bb3 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.
2022-02-11 16:30:20 +00:00
Carl Love
762dcd854a Powerpc: Fix typo in assembly code specification.
The extra 0 results in an assebler error:
    Error: junk at end of line, first unrecognized character is `x'
2022-02-10 17:32:53 +00:00
Julian Seward
4908f97231 Add missing \n in debug printing. No end-user functional change. 2022-02-10 05:33:38 +01:00