]> git.ipfire.org Git - thirdparty/valgrind.git/log
thirdparty/valgrind.git
6 years ago--> 3.14.0 final VALGRIND_3_14_BRANCH VALGRIND_3_14_0
Julian Seward [Tue, 9 Oct 2018 11:52:05 +0000 (13:52 +0200)] 
--> 3.14.0 final

6 years agoFix macOS 10.13 building from tarball
Rhys Kidd [Mon, 8 Oct 2018 01:26:35 +0000 (21:26 -0400)] 
Fix macOS 10.13 building from tarball

Fixes: 1ce04c3 ("Preliminary support for Darwin 17.x (macOS 10.13)")
6 years ago--> 3.14.0.RC2
Julian Seward [Wed, 3 Oct 2018 13:37:06 +0000 (15:37 +0200)] 
--> 3.14.0.RC2

6 years agosigframe construction for x86-linux: ensure that ESP is correctly aligned before...
Julian Seward [Wed, 3 Oct 2018 13:29:42 +0000 (15:29 +0200)] 
sigframe construction for x86-linux: ensure that ESP is correctly aligned before entering the handler.  n-i-bz.

Without this, a signal handler compiled by Clang 6, which uses movdqa to load/store
relative to ESP, segfaults because the resulting address isn't 16-aligned.

6 years agox86 front end: handle UD2 as an officially recognised, unimplemented instruction...
Julian Seward [Wed, 3 Oct 2018 13:26:48 +0000 (15:26 +0200)] 
x86 front end: handle UD2 as an officially recognised, unimplemented instruction, like the amd64 front end does.  n-i-bz.

This doesn't change anything downstream -- a SIGILL is still raised -- but
there's a bit less debug printing now.

6 years ago--> 3.14.0.RC1
Julian Seward [Sun, 30 Sep 2018 08:21:27 +0000 (10:21 +0200)] 
--> 3.14.0.RC1

6 years agoMemcheck on amd64; fix false positive associated with spec cases {Z,NZ} after {LOGICB...
Julian Seward [Sun, 30 Sep 2018 07:29:43 +0000 (09:29 +0200)] 
Memcheck on amd64; fix false positive associated with spec cases {Z,NZ} after {LOGICB,LOGICW}.  n-i-bz.

For the spec cases {Z,NZ} after {LOGICB,LOGICW}, which are simply comparisons
of the result against zero, use Cmp{EQ,NE}32 rather than their 64-bit
counterparts.  This is because Memcheck on amd64 instruments the 32 bit
versions exactly, at the default --expensive-definedness-checks=auto setting.
The alternative would have been to make Memcheck also do exact instrumentation
of the 64 bit versions, but that would also burden all other 64 bit eq/ne
comparisons with that cost for no purpose.  So this is a cheaper solution.

6 years agoFix s390x_dirtyhelper_vec_op signature for non-s390x case.
Mark Wielaard [Thu, 27 Sep 2018 03:09:42 +0000 (05:09 +0200)] 
Fix s390x_dirtyhelper_vec_op signature for non-s390x case.

The definition of s390x_dirtyhelper_vec_op in guest_s390_helpers.c
didn't match the one from guest_s390_defs.h for the non-s390x case.
Causing a compiler warning/error.

6 years agos390x: Vector integer and string insn support -- tests
Andreas Arnez [Mon, 24 Sep 2018 17:08:01 +0000 (19:08 +0200)] 
s390x: Vector integer and string insn support -- tests

This adds test cases and some internal stuff to the z/Architecture vector
integer and string instruction support.

Contributed by Vadim Barkov <vbrkov@gmail.com>.

6 years agos390x: Vector integer and string instruction support
Andreas Arnez [Mon, 24 Sep 2018 16:56:07 +0000 (18:56 +0200)] 
s390x: Vector integer and string instruction support

This adds z/Architecture vector integer and string instruction support.

The main author of this patch is Vadim Barkov <vbrkov@gmail.com>.  Some
fixes were provided by Andreas Arnez <arnez@linux.ibm.com>.

6 years agoFix 398028 Assertion `cfsi_fits` failing in simple C program
Philippe Waroquiers [Wed, 26 Sep 2018 16:04:43 +0000 (18:04 +0200)] 
Fix 398028  Assertion `cfsi_fits` failing in simple C program

At least with libopenblas, we can have several rx mappings
with some holes between mappings.
Change the invariant (2) checking so that such holes are ok,
as long as no cfsi refers to such an hole.

6 years agoUpdate bug status for s390x conditional trap insn support
Andreas Arnez [Mon, 24 Sep 2018 16:03:47 +0000 (18:03 +0200)] 
Update bug status for s390x conditional trap insn support

This updates the bug status for git commit 20976f432, "s390x: Implement
conditional trap instructions".

6 years agos390x: Implement conditional trap instructions
Andreas Arnez [Wed, 25 Jul 2018 12:23:02 +0000 (14:23 +0200)] 
s390x: Implement conditional trap instructions

This implements various z/Architecture instructions that conditionally
yield a data exception ("trap").  The condition is either based on a
comparison being true ("compare and trap") or on a loaded value being
zero ("load and trap").  These instructions haven't been widely used in
the past, but may now be emitted by newer compilers.  Note that the
resulting signal for a data exception is SIGFPE, not SIGTRAP.  Thus this
patch also adds a new jump kind Ijk_SigFPE.

6 years agoHook up statx syscall for s390x-linux
Mark Wielaard [Sat, 22 Sep 2018 09:08:12 +0000 (11:08 +0200)] 
Hook up statx syscall for s390x-linux

Fixes memcheck/tests/linux/sys-statx.vgtest on s390x-linux.

6 years agoHook up linux membarrier syscall for s390x-linux
Mark Wielaard [Sat, 22 Sep 2018 09:02:08 +0000 (11:02 +0200)] 
Hook up linux membarrier syscall for s390x-linux

Fixes none/tests/linux/membarrier on s390x-linux.

6 years agoFix arm64-linux/scalar clone test argument check order.
Mark Wielaard [Wed, 19 Sep 2018 19:23:06 +0000 (21:23 +0200)] 
Fix arm64-linux/scalar clone test argument check order.

When the clone syscall was refactored to work across all linux arches
the arguments were checked in a different order. Fix the arm64-linux
scalar.stderr.exp to match the same order for the (invalid) clone
arguments.

This makes memcheck/tests/arm64-linux/scalar.vgtest pass again.

6 years agoRun power_ISA2_0[57] tests with -q
Mark Wielaard [Tue, 18 Sep 2018 20:55:45 +0000 (22:55 +0200)] 
Run power_ISA2_0[57] tests with -q

memcheck/tests/ppc64/power_ISA2_0[57] could spuriously fail when
some internal glibc function would allocate and free some memory.
To get the expected output run the tests with -q and clear stderr.exp.

6 years agoHook up linux membarrier syscall for x86-linux
Mark Wielaard [Tue, 18 Sep 2018 19:55:45 +0000 (21:55 +0200)] 
Hook up linux membarrier syscall for x86-linux

Fixes none/tests/linux/membarrier on x86-linux.

6 years agoHook up linux membarrier syscall for ppc64[le]
Mark Wielaard [Tue, 18 Sep 2018 16:21:21 +0000 (18:21 +0200)] 
Hook up linux membarrier syscall for ppc64[le]

Fixes none/tests/linux/membarrier on ppc64[le] platforms.

6 years agoUpdate.
Julian Seward [Tue, 18 Sep 2018 07:58:11 +0000 (09:58 +0200)] 
Update.

6 years agoBug 395991 - wine's unit tests enter a signal delivery loop under valgrind on armv7l...
Julian Seward [Tue, 18 Sep 2018 07:53:38 +0000 (09:53 +0200)] 
Bug 395991 - wine's unit tests enter a signal delivery loop under valgrind on armv7l when SIGSEGV is used.

On signal handler return, restore r0 .. r15 inclusive from the sigcontext that we
gave to the handler, so that any changes the handler has made to those values
will take effect on return.

6 years agoA bit of whitespace and guard changes relating to VGABI_N32. No functional change...
Julian Seward [Tue, 18 Sep 2018 07:24:01 +0000 (09:24 +0200)] 
A bit of whitespace and guard changes relating to VGABI_N32.  No functional change.  n-i-bz.

* coregrind/m_redir.c: whitespace changes only

* memcheck/mc_main.c:
  - change 6 guards of the form "defined (VGABI_N32)" to
    "defined(VGA_mips64) && defined(VGABI_N32)"
  - Fix up poor indentation

6 years agoDo not mention VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE to bypass shared memory...
Philippe Waroquiers [Sat, 15 Sep 2018 16:00:57 +0000 (18:00 +0200)] 
Do not mention VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE to bypass shared memory definedness false positive

as when the error is reported (e.g. conditional jump), it is not
known anymore that this originates from which memory range.

6 years agoUpdate filter_gdb to make nlvgdbsigqueue work with gdb 8.2
Philippe Waroquiers [Sat, 15 Sep 2018 09:26:52 +0000 (11:26 +0200)] 
Update filter_gdb to make nlvgdbsigqueue work with gdb 8.2

gdb 8.2 now produces a message 'remote target killed',
so have filter_gdb delete it.

Tested on debian/amd64 with gdb 7.12/8.0/8.1/8.2

6 years agoUpdate filter_gdb to make nlcontrolc work with gdb 8.2
Philippe Waroquiers [Sat, 15 Sep 2018 09:06:07 +0000 (11:06 +0200)] 
Update filter_gdb to make nlcontrolc work with gdb 8.2

gdb 8.2 has changed the layout of the thread list headers.

Tested on debian/amd64 with gdb 7.12/8.0/8.1/8.2

6 years agoUpdate test to make it work with gdb 8.2
Philippe Waroquiers [Sat, 15 Sep 2018 08:58:07 +0000 (10:58 +0200)] 
Update test to make it work with gdb 8.2

Tested on debian/amd64 with gdb 7.12/8.0/8.1/8.2

6 years agoAdd noinst_HEADERS = vector.h to none/tests/s390x/Makefile.am.
Mark Wielaard [Fri, 14 Sep 2018 22:00:13 +0000 (00:00 +0200)] 
Add noinst_HEADERS = vector.h to none/tests/s390x/Makefile.am.

The vector.h file should end up in the dist tar.

6 years agoUpdate vg-entities.xml and valgrind.h for next version number.
Mark Wielaard [Fri, 14 Sep 2018 21:12:45 +0000 (23:12 +0200)] 
Update vg-entities.xml and valgrind.h for next version number.

6 years agoInclude suppsrc_lineno.supp and suppsrc_sanlineno.supp in EXTRA_DIST.
Mark Wielaard [Fri, 14 Sep 2018 20:55:17 +0000 (22:55 +0200)] 
Include suppsrc_lineno.supp and suppsrc_sanlineno.supp in EXTRA_DIST.

These are test file that are needed in the dist tar.

6 years agoUpdate somewhat more for 3.14 final.
Julian Seward [Fri, 14 Sep 2018 11:48:54 +0000 (13:48 +0200)] 
Update somewhat more for 3.14 final.

6 years agoBug 397089 - (TESTCASES FOR) Incorrect decoding of three-register vmovss/vmovsd opcod...
Julian Seward [Fri, 14 Sep 2018 11:23:19 +0000 (13:23 +0200)] 
Bug 397089 - (TESTCASES FOR) Incorrect decoding of three-register vmovss/vmovsd opcode 11h.

Adds test cases, that check both the 10h and 11h decodings.  For some reason
the expected output diff is huge.  I don't know why.  It is the same as what
the hardware produces, though.

6 years agoBug 397089 - Incorrect decoding of three-register vmovss/vmovsd opcode 11h.
Julian Seward [Fri, 14 Sep 2018 11:19:34 +0000 (13:19 +0200)] 
Bug 397089 - Incorrect decoding of three-register vmovss/vmovsd opcode 11h.

This fixes the incorrect 11h decoding of three-register vmovss/vmovsd.
Patch from Tomas Trnka (tomastrnka@gmx.com).

6 years agoImprove doc to describe limitations discussed in 398445 (false positive on shared...
Philippe Waroquiers [Thu, 13 Sep 2018 19:13:51 +0000 (21:13 +0200)] 
Improve doc to describe limitations discussed in 398445 (false positive on shared memory)

6 years agoMention --keep-debuginfo=yes in the FAQ for unloaded shared objects.
Philippe Waroquiers [Thu, 13 Sep 2018 19:12:56 +0000 (21:12 +0200)] 
Mention --keep-debuginfo=yes in the FAQ for unloaded shared objects.

6 years agoUpdate NEWS with bug fix for KDE #373069
Petar Jovanovic [Mon, 10 Sep 2018 10:12:57 +0000 (10:12 +0000)] 
Update NEWS with bug fix for KDE #373069

KDE #373069 memcheck/tests/leak_cpp_interior fails with GCC 5.1+
was (partially) fixed in r16217.

6 years agoUpdate NEWS with bug fix for KDE #396906
Petar Jovanovic [Tue, 4 Sep 2018 21:23:03 +0000 (21:23 +0000)] 
Update NEWS with bug fix for KDE #396906

Fixed in the previous commit.

6 years agomips32: fix broken inline asm in helgrind/tests/tc08_hbl2.c
Petar Jovanovic [Tue, 4 Sep 2018 21:20:39 +0000 (21:20 +0000)] 
mips32: fix broken inline asm in helgrind/tests/tc08_hbl2.c

Remove the duplicated L1xyzzy1main, and use local symbol to replace.

This fixes KDE #396906.

Patch by Hongxu Jia <hongxu.jia@windriver.com>

6 years agoComplete first-pass triage of all reported bugs.
Julian Seward [Tue, 4 Sep 2018 08:07:58 +0000 (10:07 +0200)] 
Complete first-pass triage of all reported bugs.

6 years agoAlmost catch up with first-pass triaging of bugs.
Julian Seward [Mon, 3 Sep 2018 10:02:19 +0000 (12:02 +0200)] 
Almost catch up with first-pass triaging of bugs.

6 years agoBug 398066 s390x: cgijl dep1, 0 reports false uninitialised values warning.
Mark Wielaard [Mon, 3 Sep 2018 10:56:53 +0000 (12:56 +0200)] 
Bug 398066 s390x: cgijl dep1, 0 reports false uninitialised values warning.

This is similar to bug #387712 (about cgijnl), but a newer gcc uses cgijl
now. So use a similar fix when cc_dep2 is zero, only check whether the
most significant bit of cc_dep1 is set to 1.

6 years agoBug 397354 utimensat should ignore tv_sec if tv_nsec is UTIME_NOW/OMIT.
Mark Wielaard [Mon, 3 Sep 2018 09:54:38 +0000 (11:54 +0200)] 
Bug 397354 utimensat should ignore tv_sec if tv_nsec is UTIME_NOW/OMIT.

When code uses utimensat with UTIME_NOW or UTIME_OMIT valgrind memcheck
would generate a warning. But as the utimensat manpage says:

  If the tv_nsec field of one of the timespec structures has the  special
  value  UTIME_NOW,  then  the corresponding file timestamp is set to the
  current time.  If the tv_nsec field of one of the  timespec  structures
  has the special value UTIME_OMIT, then the corresponding file timestamp
  is left unchanged.  In both of these cases, the  value  of  the  corre‐
  sponding tv_sec field is ignored.

So ignore the timespec tv_sec when tv_nsec is set to UTIME_NOW or
UTIME_OMIT.

6 years agoFix Bug 397424 - glibc 2.27 and gdb_server tests
Philippe Waroquiers [Sun, 2 Sep 2018 12:19:57 +0000 (14:19 +0200)] 
Fix Bug 397424 - glibc 2.27 and gdb_server tests

commit a214595daed7830a091dcd0f52c5b8073bfd04dd already handled some
of the new differences created by glib 2.27.

This commit should filter the new way gdb shows a select syscall
with glibc 2.27

6 years agoFix 393146 failing assert "is_DebugInfo_active(di)"
Philippe Waroquiers [Sat, 1 Sep 2018 21:36:42 +0000 (23:36 +0200)] 
Fix 393146 failing assert "is_DebugInfo_active(di)"

Some applications are mapping an object ro, and then unmaps it directly.
In such a case, we have a di that contains obsolete fsm.maps (not matching
OS mappings). The di for this unmapped object is not active,
and has no dinfo (have_dinfo == False).
(more generally, fsm.maps can contain a whole bunch of obsolete mappings).

Later on, some other libs can be mapped with a mapping overlapping
this obsolete mapping.

A di that never had its debug info loaded can really be discarded,
even if CG_(clo_keep_debuginfo).
In such a case, it is normal to have to discard a not active di.

(it might be better to keep fsm.maps in sync with the real OS
mapping, but that is a much bigger change/fix).

The FSM debug tracing was static, it is now dynamic according
to debug loglevel >= 3.

The below is an extract of the trace showing what happens.

SYSCALL[4384,1](257) sys_openat ( 4294967196, 0x4244398(/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so), 524288 ) --> [async] ...
SYSCALL[4384,1](257) ... [async] --> Success(0x3)
SYSCALL[4384,1](72) sys_fcntl[ARG3=='arg'] ( 3, 2, 1 )[sync] --> Success(0x0)
SYSCALL[4384,1](5) sys_newfstat ( 3, 0x1ffefff8b0 )[sync] --> Success(0x0)
SYSCALL[4384,1](5) sys_newfstat ( 3, 0x1ffefff9c0 )[sync] --> Success(0x0)
SYSCALL[4384,1](9) sys_mmap ( 0x0, 10520, 1, 1, 3, 0 )--4384-- di_notify_mmap-0:
--4384-- di_notify_mmap-1: 0x4027000-0x4029fff r--
--4384-- di_notify_mmap-2: /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so
--4384-- di_notify_mmap-3: is_rx_map 0, is_rw_map 0, is_ro_map 1
--4384-- di_notify_mmap-4: noting details in DebugInfo* at 0x10024CEA10
--4384-- di_notify_mmap-6: no dinfo loaded /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so (no rx or no rw mapping)
 --> [pre-success] Success(0x4027000)
SYSCALL[4384,1](3) sys_close ( 3 )[sync] --> Success(0x0)
SYSCALL[4384,1](11) sys_munmap ( 0x4027000, 10520 )[sync] --> Success(0x0)
  ^^^^ the above munmap has not cleaned up or removed anything in DebugInfo* at 0x10024CEA10

Later on, /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so is mapped
overlapping the memory where libqeglfs.so was mapped ro.

Now, this cleans up the (useless) di that never had have_dinfo true, e.g.

------ start ELF OBJECT -------------------------------------------------------
------ name = /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
...
--4384-- Discarding syms at 0x0-0x0 in /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so (have_dinfo 0)
(the 0x0-0x0 in the trace is because there was never any text mapping for libqeglfs.so).

6 years agoChange filter_memcheck_monitor as glibc 2.27 seems to keep some more memory
Philippe Waroquiers [Sat, 1 Sep 2018 16:51:21 +0000 (18:51 +0200)] 
Change filter_memcheck_monitor as glibc 2.27 seems to keep some more memory

There is no real need to verify how much memory is still in use at
exit, so filter this in filter_memcheck_monitor.

Analysis by Dimitrije Nikolic

6 years agomips: Fix asm in m_debuglog.c
Petar Jovanovic [Fri, 24 Aug 2018 13:59:14 +0000 (15:59 +0200)] 
mips: Fix asm in m_debuglog.c

Add missing clobbers in local_sys_write_stderr() and local_sys_getpid()
functions.

Patch by Aleksandar Rikalo.

6 years agomips: fix unhandled mips64-linux syscall: 5326
Petar Jovanovic [Thu, 23 Aug 2018 15:20:06 +0000 (17:20 +0200)] 
mips: fix unhandled mips64-linux syscall: 5326

This fixes memcheck/tests/linux/sys-statx on MIPS64.

6 years agomips: skip MSA tests for the secondary target
Petar Jovanovic [Thu, 23 Aug 2018 13:14:18 +0000 (13:14 +0000)] 
mips: skip MSA tests for the secondary target

No need for MSA tests for the secondary target. This change removes
build warnings present with the secondary target.

6 years agomacos: Fix missing syscall ulock_wait (OS X 10.12). bz#379754
Rhys Kidd [Mon, 12 Feb 2018 01:42:17 +0000 (20:42 -0500)] 
macos: Fix missing syscall ulock_wait (OS X 10.12). bz#379754

Based upon patch available at:
https://bugs.kde.org/attachment.cgi?id=105482

6 years agomacos: Fix valgrind OS-X build: config.h not found (out-of-tree macOS builds). bz...
Rhys Kidd [Sun, 19 Aug 2018 18:22:13 +0000 (14:22 -0400)] 
macos: Fix valgrind OS-X build: config.h not found (out-of-tree macOS builds). bz#396475

Patch from Rob Boehne.

6 years agoarm64 front end: add early-writeback handling for w (32 bit int) and q (128 bit)...
Julian Seward [Sun, 19 Aug 2018 07:18:20 +0000 (09:18 +0200)] 
arm64 front end: add early-writeback handling for w (32 bit int) and q (128 bit) stores.

Clang 6.0.1 creates instructions of the form str wX, [sp,#-N] and str qX,
[sp,#-N], and the lack of early writeback causes many false positive errors
from Memcheck, plus it potentially breaks the segfault-based main-thread stack
extension mechanism.  This commit adds support for them, using the same scheme
with which existing cases are handled.

6 years agosupp_pattEQinp: initialise a variable that gcc 7.3.1 + LTO thinks might be used unini...
Julian Seward [Sun, 19 Aug 2018 07:13:30 +0000 (09:13 +0200)] 
supp_pattEQinp: initialise a variable that gcc 7.3.1 + LTO thinks might be used uninitialised.

6 years agoFix 388174 - valgrind with Wine quits with "Assertion 'cfsi_fits' failed"
Julian Seward [Fri, 17 Aug 2018 07:31:37 +0000 (09:31 +0200)] 
Fix 388174 - valgrind with Wine quits with "Assertion 'cfsi_fits' failed"

In check_CFSI_related_invariants, this commit improves the check for invariant
(2), which, as noted in an existing comment, "might need to be improved".
Instead of assuming that the CFSI range fits entirely into one "rx" mapping,
check that it is covered by the union of all the "rx" mappings we have.  This
is the correct check.  The previous check was observed to have failed as below
for at least some Clang generated objects (possibly in conjunction with lld as
the linker.)

valgrind: m_debuginfo/debuginfo.c:717 (check_CFSI_related_invariants): Assertion 'cfsi_fits' failed.

6 years agoAdd changes to ensure that a DebugInfo that has been archived cannot be archived...
Julian Seward [Fri, 17 Aug 2018 07:09:21 +0000 (09:09 +0200)] 
Add changes to ensure that a DebugInfo that has been archived cannot be archived again.

* discard_or_archive_marked_DebugInfos: clear the mark bit for a Debuginfo
  that will be archived

* discard_DebugInfos_which_overlap_with: when selecting DebugInfos to be
  discarded or archived, fix a mistake in which some mark bits wouldn't be
  changed at all, meaning their "old" value was used to influence the current
  operation.

These may (or may not) fix #393146; at the very least, they are somehow
related.

6 years agoOn x86: enable by default, expensive-when-needed instrumentation of Add32.
Julian Seward [Fri, 17 Aug 2018 06:40:40 +0000 (08:40 +0200)] 
On x86: enable by default, expensive-when-needed instrumentation of Add32.

This reduces Memcheck's false-positive level a lot on clang -O2 generated
code.

6 years agox86 front end: add spec rules for S/NS after SUBL(x, 0)
Julian Seward [Fri, 17 Aug 2018 06:37:06 +0000 (08:37 +0200)] 
x86 front end: add spec rules for S/NS after SUBL(x, 0)

This reduces Memcheck's false-positive level on clang -O2 generated code.

6 years agoImprove bpf wrapper to check arguments more carefully
Tom Hughes [Tue, 14 Aug 2018 19:46:22 +0000 (20:46 +0100)] 
Improve bpf wrapper to check arguments more carefully

6 years agoAdd file descriptor tracking in wrappers for bpf system call
Quentin Monnet [Sat, 14 Apr 2018 22:56:37 +0000 (23:56 +0100)] 
Add file descriptor tracking in wrappers for bpf system call

Support for the bpf system call was added in a previous commit, but
did not include tracking for file descriptors handled by the call.

Add checks and tracking for file descriptors. Check in PRE() wrapper
that all file descriptors (pointing to object such as eBPF programs or
maps, cgroups, or raw tracepoints) used by the system call are valid,
then add tracking in POST() wrapper for newly produced file descriptors.

As the file descriptors are not always processed in the same way by the
bpf call, add to the header file some additional definitions from bpf.h
that are necessary to sort out under what conditions descriptors should
be checked in the PRE() helper.

6 years agoAdd support for bpf system call
Quentin Monnet [Wed, 4 Apr 2018 23:40:49 +0000 (00:40 +0100)] 
Add support for bpf system call

Fixes: 388786 - Support bpf syscall in amd64 Linux
Add support for bpf() Linux-specific system call on amd64 platform. The
bpf() syscall is used to handle eBPF objects (programs and maps), and
can be used for a number of operations. It takes three arguments:

- "cmd" is an integer encoding a subcommand to run. Available subcommand
  include loading a new program, creating a map or updating its entries,
  retrieving information about an eBPF object, and may others.
- "attr" is a pointer to an object of type union bpf_attr. This object
  converts to a struct related to selected subcommand, and embeds the
  various parameters used with this subcommand. Some of those parameters
  are read by the kernel (example for an eBPF map lookup: the key of the
  entry to lookup), others are written into (the value retrieved from
  the map lookup).
- "attr_size" is the size of the object pointed by "attr".

Since the action performed by the kernel, and the way "attr" attributes
are processed depends on the subcommand in use, the PRE() and POST()
wrappers need to make the distinction as well. For each subcommand, mark
the attributes that are read or written.

For some map operations, the only way to infer the size of the memory
areas used for read or write operations seems to involve reading
from /proc/<pid>/fdinfo/<fd> in order to retrieve the size of keys
and values for this map.

The definitions of union bpf_attr and of other eBPF-related elements
required for adequately performing the checks were added to the Linux
header file.

Processing related to file descriptors is added in a follow-up patch.

6 years agoMove pre_check for ASCII string out of PRE(sys_prctl)
Quentin Monnet [Sat, 14 Apr 2018 22:23:11 +0000 (23:23 +0100)] 
Move pre_check for ASCII string out of PRE(sys_prctl)

The sys_prctl wrapper with PR_SET_NAME option reads an ASCII string passed
as its second argument. This string is supposed to be shorter than a given
limit. As the actual length of the string is unknown, the PRE() wrapper
performs a number of checks on it, including, in worst case, trying to
dereference it byte by byte.

To avoid re-implementing all this logic for other wrappers that could
need it, get the string processing out of the wrapper and move it to a
static function. Note that passing tid as an argument to the function is
required for macros PRE_MEM_RASCIIZ and PRE_MEM_READ to work properly.

6 years agoVG_(di_notify_mmap): once we've read debuginfo for an object, ignore all further...
Julian Seward [Tue, 14 Aug 2018 08:13:46 +0000 (10:13 +0200)] 
VG_(di_notify_mmap): once we've read debuginfo for an object, ignore all further mappings.  n-i-bz.

Once we've read debuginfo for an object, ignore all further mappings.  If we
don't do that, applications that mmap in their own objects to inspect them for
whatever reason, will cause "irrelevant" mappings to be recorded in the
object's fsm.maps table.  This can lead to serious problems later on.

This has become necessary because 64aa729bfae71561505a40c12755bd6b55bb3061 of
Thu Jul 12 2018 (the fix for bug 395682) started recording readonly segments
in the fsm.maps table, where before they were ignored.

6 years agoMake sys-statx.c test compile with glibc >= 2.28
Philippe Waroquiers [Sun, 12 Aug 2018 11:27:38 +0000 (13:27 +0200)] 
Make sys-statx.c test compile with glibc >= 2.28

Newer glibc >= 2.28 provides a wrapper (and struct definitions) for statx.
So, only include linux/stat.h on older glibc.

This fixes a build failure on (at least) fedora 29 with glibc 2.28

6 years agoAnnounce in NEWS the fix for unhandled amd64-linux syscall: 332 (statx)
Philippe Waroquiers [Sat, 11 Aug 2018 14:00:43 +0000 (16:00 +0200)] 
Announce in NEWS the fix for unhandled amd64-linux syscall: 332 (statx)

Fix was pushed as 8bc2b6fd26070f9f4d3f067910eb3e3b5e662fd7

6 years agoFix 392118 - unhandled amd64-linux syscall: 332 (statx)
Philippe Waroquiers [Sat, 11 Aug 2018 13:56:56 +0000 (15:56 +0200)] 
Fix 392118 - unhandled amd64-linux syscall: 332 (statx)

Code patch provided by Mattias Andrée

Added a regression test to (somewhat) test stat and statx.

Tested on amd64 only.

6 years agoFix warning that VG_(free(basename)) might discard const qualifier
Philippe Waroquiers [Fri, 10 Aug 2018 04:35:02 +0000 (06:35 +0200)] 
Fix warning that VG_(free(basename)) might discard const qualifier

So, unconditionally allocate some memory in a non const variable.

6 years agomips64: change memcheck/tests/mips64/filter_stderr
Petar Jovanovic [Thu, 9 Aug 2018 10:40:46 +0000 (12:40 +0200)] 
mips64: change memcheck/tests/mips64/filter_stderr

This change removes backtrace line (posix_fadvise64.c) that is not always in
output of the failing test (fadvise64).
It fixes memcheck/tests/mips64/fadvise64 on MIPS64 platforms with glibc 2.27
or newer.

Patch by Dimitrije Nikolic.

7 years agomips: add membarrier system call support
Petar Jovanovic [Tue, 7 Aug 2018 12:09:43 +0000 (14:09 +0200)] 
mips: add membarrier system call support

Fixes none/tests/linux/membarrier on MIPS platforms.

7 years agoBug 397012 - glibc ld.so uses arch_prctl on i386.
Mark Wielaard [Tue, 31 Jul 2018 13:32:43 +0000 (15:32 +0200)] 
Bug 397012 - glibc ld.so uses arch_prctl on i386.

arch_prctl used to be amd64 only. But since linux 4.12 it is also
implemented for i386. And since glibc 2.28 ld.so will use it to see
if the cpu/kernel provides CET support.

To prevent seeing:

WARNING: unhandled x86-linux syscall: 384
You may be able to write your own handler.
Read the file README_MISSING_SYSCALL_OR_IOCTL.
Nevertheless we consider this a bug.  Please report
it at http://valgrind.org/support/bug_reports.html.

on every program run under valgrind just make it explicitly
not implemented (ENOSYS). This is fine for the glibc usage.
It just indicates there is no CET support.

7 years agoUpdate.
Julian Seward [Mon, 6 Aug 2018 09:05:31 +0000 (11:05 +0200)] 
Update.

7 years agoFix a few leaks in VG_(make_core_dump)
Philippe Waroquiers [Wed, 1 Aug 2018 19:49:07 +0000 (21:49 +0200)] 
Fix a few leaks in VG_(make_core_dump)

Probably not very critical, as very surely the process will die
shortly after, but better still clean the memory, as the code
was already doing some effort to free memory (e.g. VG_(free)(seg_starts);).

Note that when testing on debian 9/amd64, the resulting core dump
was not very usable (e.g. was not really showing what the guest threads
are doing). So, there must be a bug in the core dumping logic.

7 years agoFix segmentation violation caused by stack misalignment when vgdb use ptrace to force...
Philippe Waroquiers [Wed, 1 Aug 2018 17:37:13 +0000 (19:37 +0200)] 
Fix segmentation violation caused by stack misalignment when vgdb use ptrace to force activate gdbserver

On amd64, on a big application, a vgdb call that wakes up the application
using ptrace fails unfrequently (we speak about one failure every few thousands vgdb calls).
The failure started to appear when valgrind was compiled with gcc 7.3 instead of gcc 6.4

After investigation:
* gcc 7.3 is using (more) sse instructions
* Such instructions imply to have a stack pointer aligned on 16 bytes.
* vgdb-invoker-ptrace.c 'ptrace' modification of the stack pointer was
  not respecting the amd64 ABI convention to align on 16 bytes.
  It was also not protecting the red zone (unclear if this could cause
  the problem, but in any case, this ptrace logic is similar to a
  signal handler, and cannot modify the redzone.

The fix consists in respecting the ABI.

Without the patch, segmentation violation due to an sse instruction
being executed with an address on the stack not aligned on 16 bytes,
happening something like every 5000 vgdb execution.
With the patch, 250_000 executions without problems.

7 years agoRemove the useless (Addr) cast when calculating the highest stack byte addr
Philippe Waroquiers [Mon, 30 Jul 2018 22:08:38 +0000 (00:08 +0200)] 
Remove the useless (Addr) cast when calculating the highest stack byte addr

Cast not needed, as stack_low_addr is an Addr.

7 years agoFix wrong stack range output by commit 7daa08611 (more info in scheduler state)
Philippe Waroquiers [Mon, 30 Jul 2018 20:28:48 +0000 (22:28 +0200)] 
Fix wrong stack range output by commit 7daa08611 (more info in scheduler state)

The stack base starts at the beginning of the protection page/zone,
so we need to add VG_STACK_GUARD_SZB to get the real lowest usable
byte.
As the VgStack is an opaque type, add a function in aspacemgr to
return the Addr of the first lowest usable byte.

7 years agoBug 396887 - arch_prctl should return EINVAL on unknown option.
Mark Wielaard [Mon, 30 Jul 2018 10:20:16 +0000 (12:20 +0200)] 
Bug 396887 - arch_prctl should return EINVAL on unknown option.

Currently arch_prctl calls VG_(core_panic) when it sees an unknown
arch_prctl option which kills the process. glibc uses arch_prctl with
an (as yet) unknown option to see if the kernel supports CET. This
breaks any application running under valgrind on x86_64 with:

valgrind: the 'impossible' happened:
   Unsupported arch_prctl option

Thread 1: status = VgTs_Runnable (lwpid 19934)
==19934==    at 0x121A15: get_cet_status (cpu-features.c:28)
==19934==    by 0x121A15: init_cpu_features (cpu-features.c:474)
==19934==    by 0x121A15: dl_platform_init (dl-machine.h:228)
==19934==    by 0x121A15: _dl_sysdep_start (dl-sysdep.c:231)
==19934==    by 0x10A1D7: _dl_start_final (rtld.c:413)
==19934==    by 0x10A1D7: _dl_start (rtld.c:520)

We already handle all known options. It would be better to do as the
kernel does and just return failure with EINVAL instead.

7 years agoFix uninitialised epoch when recording execontext.
Philippe Waroquiers [Sun, 29 Jul 2018 19:21:07 +0000 (21:21 +0200)] 
Fix uninitialised epoch when recording execontext.

A fresh execontext must have a DiEpoch_INVALID()
but the epoch was left uninitialised.

This was detected by self-hosting valgrind.

7 years agoEven more triaging.
Julian Seward [Sat, 28 Jul 2018 22:06:02 +0000 (00:06 +0200)] 
Even more triaging.

7 years agoGive some more information in the scheduler information thread status
Philippe Waroquiers [Fri, 27 Jul 2018 22:36:35 +0000 (00:36 +0200)] 
Give some more information in the scheduler information thread status

* In case a thread is executing a syscall, give the syscall no being
  executed.
* Show the address range of the valgrind stack, similarly to the client
  stack

7 years agoUpdate bug status.
Julian Seward [Fri, 27 Jul 2018 15:22:43 +0000 (17:22 +0200)] 
Update bug status.

7 years agoSomewhat update bug status.
Julian Seward [Fri, 27 Jul 2018 14:51:10 +0000 (16:51 +0200)] 
Somewhat update bug status.

7 years agoShow the stack trace info in case of Valgrind crash
Philippe Waroquiers [Thu, 26 Jul 2018 21:16:53 +0000 (23:16 +0200)] 
Show the stack trace info in case of Valgrind crash

The stack information can be useful together with the stacktraces.

7 years agoAdd 3_13_BUGSTATUS.txt to EXTRA_DIST.
Julian Seward [Wed, 25 Jul 2018 04:54:59 +0000 (06:54 +0200)] 
Add 3_13_BUGSTATUS.txt to EXTRA_DIST.

7 years agoReorder bug sections in alphabetical order, for easier navigation.
Julian Seward [Wed, 25 Jul 2018 04:54:09 +0000 (06:54 +0200)] 
Reorder bug sections in alphabetical order, for easier navigation.

7 years agoCreate 3_13_BUGSTATUS.txt and pull all new bug reports into it.
Julian Seward [Wed, 25 Jul 2018 04:19:45 +0000 (06:19 +0200)] 
Create 3_13_BUGSTATUS.txt and pull all new bug reports into it.

7 years agoBug 385412 - s390x: new non-vector z13 instructions not implemented
Julian Seward [Tue, 24 Jul 2018 08:10:40 +0000 (10:10 +0200)] 
Bug 385412 - s390x: new non-vector z13 instructions not implemented

Apart from instructions with vector operands, Valgrind does not implement the
additional z/Architecture instructions introduced with z13.

These are:
- load and zero rightmost byte (LZRF, LZRG);
- load logical and zero rightmost byte (LLZRGF);
- load halfword high immediate on condition (LOCHHI);
- load halfword immediate on condition (LOCHI, LOCGHI);
- load high on condition (LOCFHR, LOCFH);
- store high on condition (STOCFH);
- perform pseudorandom number operation (PPNO), with the functions
  PPNO-Query and PPNO-SHA-512-DRNG;
- load count to block boundary (LCBB).

Patches from Vadim Barkov (vbrkov@gmail.com), with coordination, testing
and format cleanups from Andreas Arnez (arnez@linux.ibm.com).

7 years agoFix the test VPCMPESTRM_0x45_128 so that it doesn't depend on random junk in RAX...
Julian Seward [Mon, 23 Jul 2018 12:52:19 +0000 (14:52 +0200)] 
Fix the test VPCMPESTRM_0x45_128 so that it doesn't depend on random junk in RAX and RDX.

This test fails sporadically (eg, on Fedora 27 with gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5))
because the tested instruction uses RAX and RDX as input, but the test framework doesn't
set them :-/, so the outcome basically depends on whatever junk the compiler left in those
registers beforehand.  As a result of this, all previous uses of RAX in the test have
been changed to use RSI instead.  n-i-bz.

7 years agoAccept read-only PT_LOAD segments and .rodata.
Mark Wielaard [Thu, 12 Jul 2018 11:56:00 +0000 (13:56 +0200)] 
Accept read-only PT_LOAD segments and .rodata.

The new binutils ld -z separate-code option creates multiple read-only
PT_LOAD segments and might place .rodata in a non-executable segment.

Allow and keep track of separate read-only segments and allow a readonly
page with .rodata section.

Based on patches from Tom Hughes <tom@compton.nu> and
H.J. Lu <hjl.tools@gmail.com>.

https://bugs.kde.org/show_bug.cgi?id=395682

7 years agoarm64 front end: do early writeback for "str dX, [sp, #-imm]!". n-i-bz.
Julian Seward [Sat, 14 Jul 2018 13:50:43 +0000 (15:50 +0200)] 
arm64 front end: do early writeback for "str dX, [sp, #-imm]!".  n-i-bz.

This is needed to make Memcheck usable on arm64 code generated by clang 6.

7 years agoarm64 front end: add spec rules for {EQ,NE} after {LOGIC32,LOGIC64}.
Julian Seward [Sat, 14 Jul 2018 13:47:32 +0000 (15:47 +0200)] 
arm64 front end: add spec rules for {EQ,NE} after {LOGIC32,LOGIC64}.

7 years agoAdd some initialisations that seemed to be required as a result of an LTO build with...
Julian Seward [Sat, 14 Jul 2018 13:39:59 +0000 (15:39 +0200)] 
Add some initialisations that seemed to be required as a result of an LTO build with a gcc 8 prerelease.

7 years agoMinor reformatting
Philippe Waroquiers [Fri, 29 Jun 2018 20:46:24 +0000 (22:46 +0200)] 
Minor reformatting

Fix a few inconsistencies in formatting.
In particular, when an expression is split on several lines,
put the operators (e.g. && , ||, +, -, ...) at the beginning
of the new line : this seems to be more common
in the code, and is the coding convention used e.g. in gcc/gdb
(and incidently also at my work :)).

7 years agoFollow up to changeset 410d736a9928f535e2591c9d5f32e8e0941f96d8.
Ivo Raisr [Tue, 26 Jun 2018 17:17:23 +0000 (19:17 +0200)] 
Follow up to changeset 410d736a9928f535e2591c9d5f32e8e0941f96d8.

Fixes BZ#390471.
Patch by: Matthias Schwarzott <zzam@gentoo.org>

7 years agoPPC32, update expected results for jm_vec_isa_2_07.c.
Carl Love [Tue, 26 Jun 2018 14:51:11 +0000 (09:51 -0500)] 
PPC32, update expected results for jm_vec_isa_2_07.c.

Add missing mtvsrwa, mtfprd, mtvrwa, mtvrd results.

Signed-off-by: Carl Love <carll@us.ibm.com>
7 years agoFix ppc32 results for test_isa_2_06_part3.c.
Carl Love [Mon, 25 Jun 2018 21:24:14 +0000 (16:24 -0500)] 
Fix ppc32 results for test_isa_2_06_part3.c.

The ppc32 results were not updated when the xvnegsp instruction support
was added.  Add the xvnegsp 32-bit results to
ppc/test_isa_2_06_part3.stdout.exp.

Signed-off-by: Carl Love <carll@us.ibm.com>
7 years agoAbility to add suppressions based on source file name and line number.
Ivo Raisr [Mon, 25 Jun 2018 19:52:08 +0000 (21:52 +0200)] 
Ability to add suppressions based on source file name and line number.

Fixes BZ#390471.
Patch based on work by: Jeff Frontz <jeff.frontz@gmail.com> and Joseph M Link.

7 years agoPPC64, add support for the xvnegsp instruction. Add test case for the instruction.
Carl Love [Thu, 21 Jun 2018 22:27:40 +0000 (17:27 -0500)] 
PPC64, add support for the xvnegsp instruction. Add test case for the instruction.

https://bugs.kde.org/show_bug.cgi?id=395709

Signed-off-by: Carl Love <carll@us.ibm.com>
7 years agoAdd processing of sized delete operators into filter_libc
Petar Jovanovic [Thu, 21 Jun 2018 09:59:20 +0000 (11:59 +0200)] 
Add processing of sized delete operators into filter_libc

C++14 introduces sized delete operators and Valgrind support is added
by 6ef6f73. In addition, stderr filter which is used by Regtest should
be able to recognize this particular form in error report (just like
the other kinds of delete operators) in order to provide uniform output.

Fixes memcheck/tests/mismatches failure on non C++14 builds.

Patch by Aleksandar Rikalo.

7 years agoImplement ptrace syscall wrapper for arm64-linux.
Mark Wielaard [Tue, 19 Jun 2018 16:26:43 +0000 (18:26 +0200)] 
Implement ptrace syscall wrapper for arm64-linux.

With this valgrind is able to run gdb on arm64.
Also fixes the memcheck/tests/linux/getregset testcase.

https://bugs.kde.org/show_bug.cgi?id=368913

7 years agoMask AT_HWCAPS on arm64 to those instructions VEX implements.
Mark Wielaard [Tue, 19 Jun 2018 16:00:45 +0000 (18:00 +0200)] 
Mask AT_HWCAPS on arm64 to those instructions VEX implements.

This patch makes sure that the process running under valgrind only sees
the AES, PMULL, SHA1, SHA2, CRC32, FP, and ASIMD features in auxv AT_HWCAPS.

https://bugs.kde.org/show_bug.cgi?id=381556

7 years agoUpdate .gitignore
Petar Jovanovic [Wed, 20 Jun 2018 13:20:24 +0000 (13:20 +0000)] 
Update .gitignore

Add none/tests/linux/membarrier to .gitignore.
It was introduced with e9a82f3d759189868f7bdb33729dfe4c0bbc119c.

7 years agoAdd workaround for arm64 AT_HWCAP on newer kernels. Bug KDE#381556.
Mark Wielaard [Mon, 18 Jun 2018 13:07:27 +0000 (15:07 +0200)] 
Add workaround for arm64 AT_HWCAP on newer kernels. Bug KDE#381556.

Starting with linux 4.11 the kernel started to populate the AT_HWCAPS
auxv entry. And glibc 2.26 now uses this to see whether it can use the
mrs instruction and certain feature registers on arm64. Since these
are not supported under valgrind this causes an unhandled instruction
error. Workaround this for now my just clearing the AT_HWCAPS on arm64.

This should be fixed properly by someone with knowledge of what each
of the arm64 HWCAPS bits mean and which bits correspond to instructions
and registers supported by VEX or not.
https://bugs.kde.org/show_bug.cgi?id=381556

7 years agonone/tests/linux/membarrier.vgtest: Only execute if membarrier exists.
Mark Wielaard [Sat, 16 Jun 2018 21:25:48 +0000 (23:25 +0200)] 
none/tests/linux/membarrier.vgtest: Only execute if membarrier exists.