paulfloyd / freebsd_valgrind

Git repo used to Upstream the FreeBSD Port of Valgrind
GNU General Public License v2.0
15 stars 4 forks source link

scalar read/write - no errors with bad fd [amd64] #91

Closed paulfloyd closed 4 years ago

paulfloyd commented 4 years ago

Starting to create a 'scalar' regtest and

   GO(SYS_read, "3s 0m");
   SY(SYS_read, x0-1, x0, x0 + 1); FAILx(EFAULT);

generates

---------------------------------------------------------
  3:                SYS_read 3s 1m
---------------------------------------------------------
==5342== Syscall param read(buf) contains uninitialised byte(s)
==5342==    at 0x4A18EBA: syscall (in /lib/libc.so.7)
==5342==    by 0x201377: main (scalar.c:20)
==5342== 
==5342== Syscall param read(count) contains uninitialised byte(s)
==5342==    at 0x4A18EBA: syscall (in /lib/libc.so.7)
==5342==    by 0x201377: main (scalar.c:20)

Where is the 'Syscall param read(fd) contains uninitialised byte(s)' error message?

This seems to work OK with x86 executables.

Strangely if I change the call to

   SY(SYS_read+x0, x0, x0, x0 + 1); FAILx(EFAULT);

so that an error is expected on the syscall number as well, then I do get an error on the fd argument (but not the syscall number). It's as if there is a mixup between the 1st two syscall arguments on amd64 wrt memcheck validation.

Looking at the code in syswrap-main.c/getSyscallArgsFromGuestState the FreeBSD code does look a mess.

paulfloyd commented 4 years ago

Fixed with push To https://github.com/paulfloyd/freebsd_valgrind.git d4c752b68..2dbd678bc freebsd -> freebsd