316 Commits

Author SHA1 Message Date
Ivo Raisr
c356e1c01f Syscall wrapper for prctl(PR_SET_NAME) must not check more than 16 bytes.
Fixes BZ#379039.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16314
2017-04-26 19:27:14 +00:00
Ivo Raisr
e8a32aa888 Valgrind reports INTERNAL ERROR in rt_sigsuspend syscall wrapper.
Fixes BZ#379094.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16311
2017-04-25 06:44:28 +00:00
Ivo Raisr
8d35572e60 Fix an INTERNAL ERROR problem in execve syscall wrapper.
Fixes BZ#378535.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16301
2017-04-10 20:36:00 +00:00
Ivo Raisr
76e451c60d fcntl syscall wrapper was missing flock structure check on Linux.
Fixes BZ#377930.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16287
2017-03-27 05:06:32 +00:00
Ivo Raisr
d9f02db4c8 Fix for 377698 - Missing memory check for futex() uaddr arg for FUTEX_WAKE,
and FUTEX_WAKE_BITSET, check only 4 args for FUTEX_WAKE_BITSET,
and 2 args for FUTEX_TRYLOCK_PI.
Fixes BZ#377698.
Patch by: diane.meirowitz@oracle.com


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16285
2017-03-23 23:22:21 +00:00
Philippe Waroquiers
c54854475c And some more follow up for 376956 syswrap of SNDDRV and DRM_IOCTL_VERSION
causing some addresses to be wrongly marked as addressable

Just in case, do the assert after ARG2 has been truncated to 32 bits,
to avoid comparing sign extended requests on 64 bits.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16278
2017-03-17 18:45:23 +00:00
Philippe Waroquiers
eb0d79c25a Follow up to fix 376956 syswrap of SNDDRV and DRM_IOCTL_VERSION causing some
addresses to be wrongly marked as addressable

As noted by Ivo, if the syscall fails, then we have a leak.

So, enable the flag SfPostOnFail if we allocate memory.
In the POST ioctl, check that FAILURE only happens for this drm ioctl,
and free the memory for both SUCCESS and FAILURE.
Do the POST_MEM_WRITE only if SUCCESS
        


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16277
2017-03-17 18:38:42 +00:00
Philippe Waroquiers
a6a72c71be Fix 376956 syswrap of SNDDRV and DRM_IOCTL_VERSION causing some addresses
to be wrongly marked as addressable

Patch from Daniel Glöckner, slightly modified.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16274
2017-03-15 19:35:29 +00:00
Petar Jovanovic
30717ab5a2 Add support for syscall ptrace(traceme)
It fixes Bug 377376.

Patch by Aleksandra Karadzic.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16273
2017-03-15 15:23:27 +00:00
Philippe Waroquiers
5bc11df85c Add missing break for the DRM ioctl operations that do not have any args
Due to this missing break, the code was falling through to
the case VKI_SNDRV_CTL_IOCTL_PVERSION:
and was then setting some bytes as defined at (whatever address is in) ARG3.

Patch and analysis by Daniel Glöckner 



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16266
2017-03-11 21:07:21 +00:00
Mark Wielaard
add127dbf9 Fix two safe_to_deref/sizeof mismatches in sys_sigaction/sys_rt_sigaction.
Before dereferencing the sigaction pointer and reading the fields we
need to make sure the whole struct is safe_to_deref. We were using the
size of the pointer, but needed the size of the struct.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16258
2017-03-02 11:14:36 +00:00
Ivo Raisr
db21c24191 Fix a bug when --log-file output isn't split when a program forks.
Patch loosely based on idea by Timur Iskhodzhanov <timurrrr@google.com>.
Fixes BZ#162848


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16200
2017-01-12 11:28:20 +00:00
Petar Jovanovic
98d36af988 mips: remove some old cruft from clone functions
Follow up to r16186 when this cruft was noticed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16188
2016-12-16 18:31:57 +00:00
Philippe Waroquiers
489cfd5156 Fix 342040 Valgrind mishandles clone with CLONE_VFORK | CLONE_VM that clones to a different stack
Fix 373192 Calling posix_spawn in glibc 2.24 completely broken

Functionally, this patch just does the following 2 changes to the
fork clone handling:
* It does not mask anymore CLONE_VFORK :
  The only effect of this flag is to suspend the parent, waiting for
  the child to either exit or execve.
  If some applications depends on this synchronisation, better keep it,
  as it will not harm to suspend the parent valgrind waiting for the
  child valgrind to exit or execve.
* In case the guest calls the clone syscall providing a non zero client stack,
  set the child guest SP after the syscall, before executing guest instructions.
  Not setting the guest stack ptr was the source of the problem reported
  in the bugs.

This also adds a test case  none/tests/linux/clonev.
Before this patch, test gives a SEGV, which is fixed by the patch.

The patch is however a lot bigger : this fix was touching some (mostly
identical/duplicated) code in all the linux platforms.
So, the clone/fork code has been factorised as much as possible.
This removes about 1700 lines of code.

This has been tested on:
* amd64
* x86
* ppc64 be and le
* ppc32
* arm64

This has been compiled on but *not really tested* on:
* mips64 (not too clear how to properly build and run valgrind on gcc22)

It has *not* been compiled and *not* tested on:
* arm
* mips32
* tilegx
* darwin   (normally, no impact)
* solaris  (normally, no impact)

The changes are relatively mechanical, so it is not impossible that
it will compile and work out of the box on these platforms.
Otherwise, questions welcome.

A few points of interest:
* Some platforms did have a typedef void vki_modify_ldt_t,
  and some platforms had no definition for this type at all.
  To make it easier to factorise, for such platforms, the following has
  been used:
     typedef char vki_modify_ldt_t;
    When the sizeof vki_modify_ldt_t is > 1, then the arg syscall is checked.
  This is somewhat a hack, but was simplifying the factorisation.

* for mips32/mips64 and tilegx, there is a strange unconditional assignment
  of 0 to a register (guest_r2 on mips, guest_r0 on tilegx).
  Unclear what this is, in particular because this is assigned whatever
  the result of the syscall (success or not).
  



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16186
2016-12-11 21:39:23 +00:00
Petar Jovanovic
9a6096841e mips32: fix fadvise64 system call
For fadvise64 system call, 7th 32-bit argument slot (third on the stack)
will also be used due to MIPS O32 calling convention in passing 64-bit
values.

sys_fadvise64(int fd, loff_t offset, loff_t len, int advice);

NR_fadvise64 -> v0               (sysno)
fd           -> a0               (ARG1)
offset       -> a2, a3           (ARG3, ARG4)
len          -> SP + 16, SP + 20 (ARG5, ARG6)
advise       -> SP + 24          (ARG7)

Change the code according to it.

Patch by Aleksandar Rikalo.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16162
2016-11-29 14:27:25 +00:00
Philippe Waroquiers
260f165999 Fix 373046 - Stacks registered by core are never deregistered
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16159
2016-11-28 19:34:06 +00:00
Julian Seward
cad347059e Bug 348616 - Wine/valgrind: Warning: noted but unhandled ioctl 0x5390
with no size/direction hints. (DVD_READ_STRUCT)

Patch from Austin English (austinenglish@gmail.com).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16153
2016-11-23 13:26:23 +00:00
Julian Seward
15f0421b15 Bug 352767 - Wine/valgrind: Warning: noted but unhandled ioctl 0x5307
with no size/direction hints. (CDROMSTOP).

Patch from Austin English (austinenglish@gmail.com).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16152
2016-11-23 13:15:22 +00:00
Philippe Waroquiers
d208bc934b Fix 372504 Hanging on exit_group
Note that it is unclear if the PRE syscall for rt_sigsuspend
is properly setting up a temporary mask in the thread state
tmp_sig_mask:  if an handler is called while a thread is
calling sigsuspend, the mask during the handler run must be
the temporary mask set by sigsuspend.
It is not clear if/where the valgrind sigframe builder/handler
sets the tmp_sig_mask to the value as expected by the user
(i.e. the value of the temporary mask which was given to
the sigsuspend syscall)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16141
2016-11-19 14:54:44 +00:00
Philippe Waroquiers
54a1e7856d 371412 Rename wrap_sys_shmat to sys_shmat like other wrappers
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16109
2016-11-01 15:00:45 +00:00
Julian Seward
71b25c5da3 Add support for Linux perf-events ioctls. Fixes #368419.
Patch from Keno Fischer (keno@juliacomputing.com).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16077
2016-10-19 16:08:25 +00:00
Julian Seward
01492a3544 Fix run_a_thread_NORETURN assembly code typo for VGP_arm64_linux target.
Fixes #368823.  Patch from chh@google.com.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16074
2016-10-18 17:31:53 +00:00
Mark Wielaard
d70383e803 Don't crash, but warn and return EINVAL on unknown fcntl command.
Bug #369446
LTP: testcases/kernel/syscalls/fcntl/fcntl13

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15998
2016-10-01 11:54:52 +00:00
Mark Wielaard
2cb131bf04 Don't check bad iovec array in process_vm_readv/writev. Bug #369441.
Found by LTP testcases/kernel/syscalls/cma/process_vm01.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15997
2016-10-01 11:54:51 +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
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
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
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
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
a848da57ad Add arm64 scalar test. Enable tested syscalls.
The new memcheck/tests/arm64-linux/scalar test is based on the
memcheck/tests/x86-linux/scalar test and contains all syscalls
that are also available on arm64. To make comparison of exp results
easier the order of the tested syscalls is the same as on x86.
This enables a couple extra arm64 syscalls. Part of the fix for
bug #359503 - Add missing syscalls for aarch64 (arm64).

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15825
2016-03-09 16:18:36 +00:00
Ivo Raisr
912bede3dd Sanitize signal mask in ppoll and pselect syscalls
Reported and Linux patch contributed by Steven Smith <sos22@archy.org.uk>
Fixes BZ#359871



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15823
2016-03-08 09:04:48 +00:00
Mark Wielaard
54794decc8 Bug 359201 followup. futex skips argument 5 if op is FUTEX_WAIT_BITSET.
The original fix in svn r15793 read argument 6 separately by using PRA6
unconditionally. This is wrong. We need to first check whether a
track_pre_reg_read callback is registered (only memcheck does).
The PRE_REG_READX macro already had this check. Just add the same
before calling PRA6. Thanks to Tom Hughes for noticing. Without this
helgrind/tests/cond_timedwait_test and drd/tests/pth_inconsistent_cond_wait
regtests would fail.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15795
2016-02-18 11:14:47 +00:00
Mark Wielaard
ccd541e916 Bug 359201 futex syscall skips argument 5 if op is FUTEX_WAIT_BITSET
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15793
2016-02-17 20:53:34 +00:00
Julian Seward
5e5d78dda0 Fix inconsistent use of vki_ prefixes for struct vki_ifreq.
No functional change.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15713
2015-10-19 11:21:33 +00:00
Florian Krohm
c332279b5c Fix up a few comments.
Patch by Jean Delvare <jdelvare@suse.de>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15657
2015-09-20 13:42:06 +00:00
Florian Krohm
0d5f723bec Followup to r14908 (BZ #342603).
Comparing the command byte with VKI_I2C_SMBUS_QUICK is like comparing
apples to carrots, it makes no sense. The command byte is unused for
quick transactions anyway so checking its value is pointless.
Patch by Jean Delvare <jdelvare@suse.de>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15656
2015-09-20 13:41:25 +00:00
Florian Krohm
4a999cf4a2 Followup to r14908 (BZ #342603).
The first byte of the data array holds the length, so the actual data
length is the value of that byte plus one.
Patch by Jean Delvare <jdelvare@suse.de>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15655
2015-09-20 13:40:47 +00:00
Julian Seward
adc2dafee9 Update copyright dates, to include 2015. No functional change.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15577
2015-08-21 11:32:26 +00:00
Julian Seward
e421887527 345338 - TIOCGSERIAL and TIOCSSERIAL ioctl support on Linux
Patch from Martin Ling (martin-kdebugs@earth.li)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15542
2015-08-14 08:17:37 +00:00
Julian Seward
396f02357d Bug 349034 - Add Lustre ioctls LL_IOC_GROUP_LOCK and LL_IOC_GROUP_UNLOCK
Patch from Frank Zago (fzago@cray.com)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15541
2015-08-14 08:05:35 +00:00
Julian Seward
a2df7642ef Bug 339563 - The DVB demux DMX_STOP ioctl doesn't have a wrapper.
Patch from mchehab@infradead.org (Mauro Carvalho Chehab).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15537
2015-08-13 14:53:17 +00:00
Florian Krohm
9a3883bf3d Fix printf format inconsistencies as pointed out by gcc -Wformat-signedness.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15510
2015-08-08 21:45:33 +00:00
Christian Borntraeger
c2baee9b7b add KVM_S390_MEMOP ioctl handling
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15334
2015-06-12 10:54:12 +00:00
Julian Seward
a4d69434b8 Bug 348728 - Fix broken check for VIDIOC_G_ENC_INDEX
Patch from Hans Verkuil (hverkuil@xs4all.nl)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15314
2015-06-05 11:25:32 +00:00
Julian Seward
eed8fbcd80 Bug 348102 - Patch updating v4l2 API support (edit)
Patch from Hans Verkuil (hverkuil@xs4all.nl) 


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15313
2015-06-05 11:23:35 +00:00
Julian Seward
9dc5a73468 Fix bug 345126: Incorrect handling of VIDIOC_G_AUDIO and G_AUDOUT
Patch from Hans Verkuil (hverkuil@xs4all.nl)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15276
2015-05-22 10:40:42 +00:00
Tom Hughes
2799d8f88a Add support for the syncfs system call.
Based on patch from j@eckel.me on BZ#347389.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15191
2015-05-07 18:54:31 +00:00
Bart Van Assche
44609129ea Add support for LL_IOC_PATH2FID and LL_IOC_GETPARENT Lustre ioctls
From: Frank Zago <fzago@cray.com>


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15123
2015-04-21 17:46:52 +00:00