Commit Graph

5221 Commits

Author SHA1 Message Date
Mark Wielaard
547abdee69 Fix crash in sys_modify_ldt wrapper on bad ptr. Bug #369383.
Make sure ptr is safe_to_deref if not NULL.
Also fixup some corner case error return codes.
We have to do that ourselves since we never actually call into the kernel.

Found by LTP testcases/kernel/syscalls/modify_ldt/modify_ldt01.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15995
2016-10-01 11:54:50 +00:00
Mark Wielaard
e1e9a77564 Fix crash in linux [rt_]sigaction wrapper with bad old/new sigaction handler.
Since we try to modify the old/new sigaction handler before passing it
to the kernel we must make sure that (if they aren't NULL) it is safe
to use. If not we should bail out early with EFAULT.

Bug #369362
Found by LTP testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15994
2016-10-01 11:54:49 +00:00
Mark Wielaard
1063360181 Fix crash in vmsplice linux kernel wrapper when iovec is bad. Bug #369361.
Found by LTP testcases/kernel/syscalls/vmsplice/vmsplice02.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15993
2016-10-01 11:54:48 +00:00
Mark Wielaard
52b55f29f3 Fix crash when old/new sigprocmask isn't safe to dereference. Bug #369360.
Since we want to use the set and oldset for bookkeeping we also want
to make sure they are addressable otherwise, like the kernel, we EFAULT.
Also use EINVAL instead of EMFILE as failure when sigset size is wrong.

Found by LTP testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15992
2016-10-01 11:54:47 +00:00
Mark Wielaard
1e3852e27c Fix crash in msghdr_foreachfield when iov_len isn't safe to dereference.
Also stop checking when max length of bytes have been reached.

Bug #369359
Found by LTP testcases/kernel/syscalls/recvmsg/recvmsg01.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15991
2016-10-01 11:54:41 +00:00
Mark Wielaard
31e1b8c9ba Fix pre_mem_read_sockaddr crash on invalid syscall arguments. Bug #369356.
Don't do any more checks if it isn't safe to inspect the address family.
Likewise, don't check sun_path if the string address isn't safe.

Found by LTP testcases/kernel/syscalls/bind/bind01.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15990
2016-10-01 11:54:40 +00:00
Mark Wielaard
be052139d6 Don't require the current working directory to exist. Bug #369209.
At startup valgrind fetches the current working directory and stashes
it away to be used later (in debug messages, read config files or create
log files). But if the current working directory didn't exist (or there
was some other error getting its path) then valgrind would go in an
endless loop. This was caused by assuming that any error meant a larger
buffer needed to be created to store the cwd path (ERANGE). However
there could be other reasons calling getcwd failed.

Fix this by only looping and resizing the buffer when the error is
ERANGE. Any other error just means we cannot fetch and store the current
working directory. Fix all callers to check get_startup_wd() returns
NULL. Only abort startup if a relative path needs to be used for
user supplied relative log files. Debug messages will just show
"<NO CWD>". And skip reading any config files from the startup_wd
if it doesn't exist.

Also add a new testcase that tests executing valgrind in a deep,
inaccessible and/or non-existing directory (none/tests/nocwd.vgtest).

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15989
2016-10-01 11:54:38 +00:00
Philippe Waroquiers
cd2843e06d Fix warning introduced by revision 15982
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15983
2016-09-24 12:58:29 +00:00
Philippe Waroquiers
eaefbe1f25 Fix 361615 - Inconsistent termination for multithreaded process terminated by signal
Test program by earl_chew



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15982
2016-09-24 12:06:34 +00:00
Ivo Raisr
98273bc5f4 Solaris: Add ioctl wrapper for MNTIOC_GETEXTMNTENT.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15981
2016-09-23 23:00:21 +00:00
Rhys Kidd
ab2edd2901 Preliminary support for macOS Sierra (10.12). Does not fully resolve bz#365327.
No regressions on OS X 10.11.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15976
2016-09-22 02:55:24 +00:00
Mark Wielaard
219f3152bc Bug #359503 continued. adjtimex syscall missing on arm64.
Enable adjtimex syscall on arm64 and fix bug if argument is a bad pointer.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15953
2016-09-14 11:47:26 +00:00
Mark Wielaard
9d0a8787d5 Update libiberty demangler.
Update the libiberty demangler using the auxprogs/update-demangler
script. There were various extensions and bug fixes since our last
import. Add new D language demangler file d-demangle.c and update
the vg_libciface.h header with some new constructs used (strtol,
xmalloc_failed, xmemdup, XDELETEVEC, XDUPVEC).

Resolves bug #359181 - Buffer Overflow during Demangling.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15951
2016-09-13 19:06:23 +00:00
Philippe Waroquiers
5de4bad5a7 Fix 199468 - Suppressions: stack size limited to 25 while --num-callers allows more frames
Nr of callers in a suppression entry had a smaller limit than the max
for --num-callers.
This means it was not possible to precisely suppress an error with a big
stack trace.
Also, --gen-suppressions was not providing the full stack trace of
the error in the generated suppressions.

Now, a suppression entry can have the same nr of callers as a backtrace.
Generated suppressions are generated with up to --num-callers callers.

This change has neglectible impact :
* memory: stack array of 500*2 words is declared, instead of 24*2 words
  This array is declared on the interim stack (startup stack), which is
  largely big enough.
* cpu : neglectible more cpu needed to read suppression entries
        (to initialise the bigger stack array when reading a supp entry),
Apart of the above, no impact on performance (unless of course bigger
supp entries are really used).

Note that this does not impact the behaviour for existing suppression files.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15945
2016-09-07 20:12:30 +00:00
Ivo Raisr
b0b7bbf30b Follow up to SVN commit r15936.
Fix the sloppy check I introduced.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15939
2016-08-17 18:05:13 +00:00
Ivo Raisr
b6224ced96 Follow up to r15936.
Kernel allocates another page after fork and we have to
keep aspacemgr's point of view consistent.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15937
2016-08-15 02:31:27 +00:00
Ivo Raisr
6260274e4e Follow recent Solaris development with respect to
SUNWDTRACE program header. Newer Solaris no longer utilizes
this program header as a scratchspace for DTrace fasttrap
provider, before libc is loaded.
For the time being, it serves as a space for initial thread
pointer.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15936
2016-08-12 22:28:50 +00:00
Petar Jovanovic
030cea68c8 mips32: add support for FPXX mode
With this patch, MIPS32 Valgrind compiled with -mfpxx can handle all types
(regarding FP_ABI flag) of MIPS32 ELFs.

- Functions arch_elf_pt_proc() and arch_check_elf() are added to elf reader
  according to linux/fs/binfmt_elf.c from Linux 4.1;
- Processing .MIPS.abiflags section and initializing appropriate FPU mode
  for MIPS32 are added;
- Emulation of prctl(GET/SET_FP_MODE) sys-calls are implemented for MIPS32.

Patch by Aleksandar Rikalo <Aleksandar.Rikalo@imgtec.com>

Related VEX change: r3243.

This implements BZ#366079.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15934
2016-08-10 14:38:10 +00:00
Julian Seward
1a2f71d6ff Reimplement pszB_to_listNo using a binary search rather than a linear search.
Unlikely as it seems, this saves a considerable number of instructions (2% of total)
on very heap-intensive code (perf/heap.c).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15926
2016-08-05 14:54:27 +00:00
Julian Seward
7c3b4bf540 Make "ashmem" and "binder" ioctls be handled properly on 64-bit ARM Android,
rather than falling through to the generic handler and being mishandled.
Fixes #360574.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15923
2016-08-04 21:11:28 +00:00
Julian Seward
f8eca86bbf Add infrastructure for detection of 32-bit ARMv8 capable CPUs (Valgrind side).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15921
2016-08-03 11:40:36 +00:00
Julian Seward
7a8129795c Fix incorrect assertion re sizeof TTEntryC on arm-linux. Fixes #362935.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15912
2016-07-21 12:47:51 +00:00
Ivo Raisr
86203023fa Set executable protection on schedctl pages only when necessary.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15903
2016-07-11 21:05:03 +00:00
Philippe Waroquiers
80dec3e514 Fix 365273 - Invalid write to stack location reported after signal handler runs
Analysis and patch by Earl Chew

Tested on x86/amd64/ppc64



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15902
2016-07-10 21:17:58 +00:00
Philippe Waroquiers
b07050d998 Fix leak in m_redir.c
See below discussion for more details.

On Sat, 2016-07-02 at 14:20 +0200, Philippe Waroquiers wrote:
> I am testing a patch (provided by Julian) that solves a false positive
> memcheck found at my work.
> 
> Testing this, I decided to run valgrind under valgrind (not done since
> a long time).
> 
> This shows a leak in many tests, the stack trace being such as:
> ==26246== 336 bytes in 21 blocks are definitely lost in loss record 72 of 141
> ==26246==    at 0x2801C01D: vgPlain_arena_malloc (m_mallocfree.c:1855)
> ==26246==    by 0x2801D616: vgPlain_arena_strdup (m_mallocfree.c:2528)
> ==26246==    by 0x2801D616: vgPlain_strdup (m_mallocfree.c:2600)
> ==26246==    by 0x2801F5AD: vgPlain_redir_notify_new_DebugInfo (m_redir.c:619)
> ==26246==    by 0x2803B650: di_notify_ACHIEVE_ACCEPT_STATE (debuginfo.c:771)
> ==26246==    by 0x2803B650: vgPlain_di_notify_mmap (debuginfo.c:1067)
> ==26246==    by 0x2806589C: vgModuleLocal_generic_PRE_sys_mmap (syswrap-generic.c:2368)
> ==26246==    by 0x2809932A: vgSysWrap_amd64_linux_sys_mmap_before (syswrap-amd64-linux.c:637)
> ==26246==    by 0x28061E11: vgPlain_client_syscall (syswrap-main.c:1906)
> ==26246==    by 0x2805E9D2: handle_syscall (scheduler.c:1118)
> ==26246==    by 0x280604A6: vgPlain_scheduler (scheduler.c:1435)
> ==26246==    by 0x2806FF87: thread_wrapper (syswrap-linux.c:103)
> ==26246==    by 0x2806FF87: run_a_thread_NORETURN (syswrap-linux.c:156)
> 
> 
> The strdup call in m_redir.c:619 was introduced by r15726.
> 
> However, I am not sure this is a bug that is introduced by this change,
> or if it just reveals a leak that was already there.
> The "very original" replacement logic did not do memory allocation for
> the replacement: see m_redir.c in valgrind 3.10.1 : it was just copying
> some chars from VG_(clo_soname_synonyms) to demangled_sopatt

Yes, it should do exactly the same as the other code paths. If
replaced_sopatt != NULL then it is an allocated string that has been
assigned to demangled_sopatt. I had assumed that would take care of the
life-time issues of the allocated string. But now that I read the code
it is indeed not so clear.

> Then in 3.11, the fixed size demangled_sopatt was changed to be
> a dynamically allocated buffer.
> The revision log 14664 that introduced this explains that the ownership of
> returned buffer is not easy. It tells at the end:
> "So the rule of thunb here is: if in doubt strdup the string."
> 
> but now we have to see when to free what, it seems ???
> 
> Any thoughts ?

So if replaced_sopatt != NULL, then demangled_sopatt contains the
allocated string, and it is then immediately copied and assigned to
spec->from_sopatt. After that it is used under check_ppcTOCs. But there
it will first be reassigned a new value through maybe_Z_demangle
(overwriting any existing string being pointed to). So for this
particular leak it seem fine to free it right after the spec[List] has
been initialized (line 642).

Cheers,

Mark



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15898
2016-07-02 18:46:23 +00:00
Mark Wielaard
08086f0855 Bug 364413 pselect sycallwrapper mishandles NULL sigmask.
Don't check or try to copy sigmask if it is NULL. The sigmask might be
given in a struct, where the length is non-zero, but the signal set
pointer is NULL.

Testcase provided by Paul Eggert <eggert@cs.ucla.edu>.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15893
2016-06-21 19:58:21 +00:00
Rhys Kidd
2ea4e5efa4 Fix tst->os_state.pthread - magic_delta assertion failure on OSX 10.11
bz#354883

Whilst I’ve seen different magic_delta values on one of my older development machines (Intel Nehalem-based), enough other users have reported success with this change.

If this causes regressions, please report your hardware details in our Bugzilla.

Regression test output on OS X 10.11

Before:

== 601 tests, 223 stderr failures, 12 stdout failures, 0 stderrB failures, 0 stdoutB failures, 31 post failures ==

After:

== 601 tests, 223 stderr failures, 12 stdout failures, 0 stderrB failures, 0 stdoutB failures, 31 post failures ==

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15891
2016-06-04 15:34:56 +00:00
Mark Wielaard
6b8c5dfb75 Bug 363680 add renameat2() support
Patch written by Jann Horn <jannhorn@googlemail.com>.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15889
2016-05-31 12:16:15 +00:00
Mark Wielaard
59d79476bc Bug 363714 ppc64 missing syscalls sync, waitid and name_to/open_by_handle_at
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15888
2016-05-30 20:16:04 +00:00
Mark Wielaard
958ea4cb5b Bug #363705 arm64 missing syscall name_to_handle_at and open_by_handle_at
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15887
2016-05-30 14:17:25 +00:00
Ivo Raisr
fbaa6ad350 Solaris: Further refinement of r15882 for Solaris versions
which do not have <sys/sysnvl.h> header file.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15885
2016-05-29 12:10:58 +00:00
Ivo Raisr
d894770ee3 Solaris: Add ioctl wrappers for DINFOUSRLD and DINFOIDENT.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15884
2016-05-29 09:29:28 +00:00
Ivo Raisr
aad88ea2d0 Solaris: Add syscall modctl with several commands implemented.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15882
2016-05-28 22:05:43 +00:00
Philippe Waroquiers
268ff84f7b Document brk segment limitation, reference manual in limit reached msg.
The msg telling brk cannot be extended confuses some users
so improve the documentation and have the msg referencing the doc.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15880
2016-05-22 20:48:09 +00:00
Ivo Raisr
ffcb955c34 Solaris: Add wrapper for setparam subcode of the door syscall.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15879
2016-05-16 12:51:27 +00:00
Ivo Raisr
8ace9b4f06 Solaris ioctl: Add wrapper for I_FLUSH.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15878
2016-05-16 11:38:29 +00:00
Ivo Raisr
662eab632a Solaris ioctl: Add wrapper for I_FIND.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15877
2016-05-16 06:12:27 +00:00
Petar Jovanovic
c7d3589646 mips32: raise the limit for sizeof(TTEntryC)
Raise limit for sizeof(TTEntryC) due to 8-byte alignement requirement for
ULong on mips32 platforms. It is a follow up to the same change on ppc32
(see r15875), and it un-breaks mips32-linux (broken with r15784).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15876
2016-05-06 17:34:55 +00:00
Julian Seward
325dfcc0d9 Un-break ppc32-linux following r15784. It appears that ppc32-ELF
layout constraints are different from x86-ELF and so the assertion on
the sizeof(TTEntryC) fails on ppc32-linux.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15875
2016-04-28 15:52:01 +00:00
Julian Seward
c10a83a800 Split the structure TTEntry into hot (small) and cold (large) parts,
TTEntryH and TTEntryC.  TTEntryH is a VexGuestExtents plus one more
field.  For scenarios involving a lot of code discarding, when the
fast-path discard mechanism does not apply, this change reduces
significantly the number of LLC misses, because such discarding
involves sequentially searching the arrays of TTEntryH's.  For recent
Firefoxes the miss rate in a 6MB L3 cache is reduced by about 1/3, as
measured by /usr/bin/perf.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15874
2016-04-27 16:46:04 +00:00
Julian Seward
f0077be94b Fix indentation that gcc-6 -Wmisleading-indentation rightfully complaints about.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15873
2016-04-27 08:19:52 +00:00
Julian Seward
abf0d0a78d Fix compilation breakage on platforms that do already have a definition
for Elf{32,64}_Chdr.  This is fallout from r15868.  That commit provided
a configure test, but the resulting config.h was not included here, causing
the test results to be ignored.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15869
2016-04-24 17:11:44 +00:00
Ivo Raisr
da7df0f276 Valgrind is able to read compressed debuginfo sections in two formats:
- zlib ELF gABI format with SHF_COMPRESSED flag (gcc option -gz=zlib)
  - zlib GNU format with .zdebug sections (gcc option -gz=zlib-gnu)

Patch by: Aleksandar Rikalo <aleksandar.rikalo@imgtec.com>
Fixes BZ#303877



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15868
2016-04-23 20:28:27 +00:00
Ivo Raisr
5d4c5ae3d6 Fix Valgrind coredump when VG_(unimplemented)() is called
early during main initialization, before the threads are
created and scheduler is initialized.
Fixes BZ#362009


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15867
2016-04-23 19:35:11 +00:00
Carl Love
862031ddab PPC64, Valgrind with GDB does not display 64-bit and 128-bit registers
correctly

Forgot to add the new files to the previous commit 15864.

coregrind/m_gdbserver/power64-core2-valgrind-s1.xml
coregrind/m_gdbserver/power64-core2-valgrind-s2.xml
coregrind/m_gdbserver/power-vsx-valgrind-s1.xml
coregrind/m_gdbserver/power-vsx-valgrind-s2.xml
coregrind/m_gdbserver/power-vsx.xml

Bugzilla 360008 was opened for this issue.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15866
2016-04-22 15:03:46 +00:00
Carl Love
a30916183c PPC64, Valgrind with GDB does not display 64-bit and 128-bit registers
correctly

1)  Fix Endianess issue that was missed in the BE to LE port.  GDB was
    not displaying the contents of the 64-bit and 128-bit registers
    correctly due to an Endianess issue.

2)  Fix displaying the shadow registers for the 64-bit and 128-bit
    registers.

Bugzilla 360008 was opened for this issue.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15864
2016-04-21 18:21:26 +00:00
Ivo Raisr
eb743789cd Print arguments of DWARF extension DW_CFA_ORCL_arg_loc.
n-i-bz


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15863
2016-04-20 00:21:50 +00:00
Ivo Raisr
91f7614767 Solaris: Add syscall wrapper for sysfs(84)
Fixes BZ#361926


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15862
2016-04-19 15:57:13 +00:00
Ivo Raisr
7cd8f83b96 Follow up to bug 345307.
Passing parameter on x86 architecture was wrong in final_tidyup().


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15854
2016-04-08 21:29:15 +00:00
Ivo Raisr
60a0aa1d53 Kludge for multiple .rodata sections on Solaris introduced by BZ#353802
is no longer needed. The situation with multiple ".rodata" sections existed
only between dozens of builds of Solaris 12.
Fixes BZ#360749


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15853
2016-04-08 20:38:30 +00:00