fix 123837 semctl system call: 4rth argument is optional, depending on cmd
authorphilippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Tue, 23 Oct 2012 21:38:52 +0000 (21:38 +0000)
committerphilippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Tue, 23 Oct 2012 21:38:52 +0000 (21:38 +0000)
commit8e2b4a23f2e9a099219fc3aa02b586700cfb75e0
tree55c071254e193a7e55b162289d064d36c114c087
parent174f6f2f2e92126d24bf4f19f98878dabc339573
fix 123837 semctl system call: 4rth argument is optional, depending on cmd

Depending on the semctl command (arg3), arg4 might or might not be needed.
The PRE(sys_ipc) multiplexed syscall for semctl was always checking
all 4 args.

The fix consists in dereferencing the 4th arg (which in sys_ipc is ARG5)
only if the semctl syscall cmd implies 4 arguments.
This avoids the false positive on linux x86.

Note that PRE(sys_ipc) is still too simplistic as it assumes
that 6 args are always read, which is not the case.
This seems to cause false positive on mips:
  memcheck on none/tests/sem gives:
     Syscall param ipc(fifth) contains uninitialised byte(s)

It would be nice to implement the multiplexed PRE(sys_ipc) by
calling the PRE(sys_xxxx) similar PRE, depending on ARG1 of sys_ipc.
This would then avoid the simplistic PRE(sys_ipc) logic without duplicating
the logic in PRE(sys_semctl) (and all other sys_ipc multiplexed syscalls).
However, I found no easy way to do that.

With the current fix, some logic about semctl is partially duplicated between
the PRE(sys_ipc) (for platforms such as x86 having a multiplexed sys call)
and PRE(sys_semctl) (for platforms such as amd64, having a direct sys call)
to fix the false positive encountered on x86.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13082 a5019735-40e9-0310-863c-91ae7b9d1cf9
NEWS
coregrind/m_syswrap/syswrap-linux.c