17095 Commits

Author SHA1 Message Date
Paul Floyd
a17b8d0198 Add FreeBSD-specific expected for memcheck/tests/gone_abrt_xml
The difference is in the si_code. Linux has a value of 0, FreeBSD has
65537. This is correct.

From vki-freebsd.h

/*
 * si_code values
 */

and indeed this signal gets sent by kill()
2022-05-09 09:47:12 +02:00
Paul Floyd
1ec5d23e73 Make memcheck/tests/clientperm clang-friendly
The use of the ternary operator was causing diffs compared to
GCC output. Switching to use two 'ifs' should remove this
difference.
2022-05-09 09:16:48 +02:00
Paul Floyd
54ee45d208 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");
2022-05-09 08:15:06 +02:00
Paul Floyd
407c00c2e9 FreeBSD: only set osrel for executables. 2022-05-09 07:49:56 +02:00
Paul Floyd
e23f5b6a14 FreeBSD x86 small logging changes and add comments explaining why none/tests/manythreads fails 2022-05-07 17:30:23 +02:00
Paul Floyd
295ce0e643 Update FreeBSD struct vki_kinfo_vmentry 2022-05-07 17:28:08 +02:00
Paul Floyd
184e3ba052 Bug 453055 shared_timed_mutex drd test fails with "Lock shared failed" message
Patch submited by Jesus Checa jcheca@redhat.com
2022-04-27 21:13:45 +02:00
Paul Floyd
6af21da952 Bug 452779 Valgrind fails to build on FreeBSD 13.0 with llvm-devel (15.0.0)
Only link with libgcc-sup if the compiler is clang.
Still need -lgcc
2022-04-27 21:10:35 +02:00
Paul Floyd
8b2cf214af Fix warning building memcheck/tests/memalign2
Was getting warnings with clang like

memalign2.c:62:17: warning: requested alignment is not a power of 2 [-Wnon-power-of-two-alignment]
   p = memalign(0, 100);      assert(0 == (long)p % 8);
2022-04-19 22:36:36 +02:00
Paul Floyd
acdef43dce memcheck/tests/amd64/shr_edx builds fine with clang
Make it build unconditionally
2022-04-19 22:27:59 +02:00
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