From: Ivo Raisr Date: Tue, 19 Apr 2016 15:57:13 +0000 (+0000) Subject: Solaris: Add syscall wrapper for sysfs(84) X-Git-Tag: svn/VALGRIND_3_12_0~161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91f761476766d9c8f8327a60cace1cb00785e6bc;p=thirdparty%2Fvalgrind.git Solaris: Add syscall wrapper for sysfs(84) Fixes BZ#361926 git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15862 --- diff --git a/NEWS b/NEWS index b4d7859c40..19be7b93dc 100644 --- a/NEWS +++ b/NEWS @@ -92,6 +92,7 @@ where XXXXXX is the bug number as listed below. 360752 raise the number of reserved fds in m_main.c from 10 to 12 361354 ppc64[le]: wire up separate socketcalls system calls 361226 s390x: risbgn (EC59) not implemented +361926 Unhandled Solaris syscall: sysfs(84) n-i-bz Fix incorrect (or infinite loop) unwind on RHEL7 x86 and amd64 n-i-bz massif --pages-as-heap=yes does not report peak caused by mmap+munmap diff --git a/coregrind/m_syswrap/syswrap-solaris.c b/coregrind/m_syswrap/syswrap-solaris.c index b98b17ddb0..45e3a18e78 100644 --- a/coregrind/m_syswrap/syswrap-solaris.c +++ b/coregrind/m_syswrap/syswrap-solaris.c @@ -951,6 +951,7 @@ DECL_TEMPLATE(solaris, sys_lwp_name); #endif /* SOLARIS_LWP_NAME_SYSCALL */ DECL_TEMPLATE(solaris, sys_privsys); DECL_TEMPLATE(solaris, sys_ucredsys); +DECL_TEMPLATE(solaris, sys_sysfs); DECL_TEMPLATE(solaris, sys_getmsg); DECL_TEMPLATE(solaris, sys_putmsg); DECL_TEMPLATE(solaris, sys_lstat); @@ -4556,6 +4557,51 @@ POST(sys_ucredsys) } } +PRE(sys_sysfs) +{ + /* Kernel: int sysfs(int opcode, long a1, long a2); */ + PRINT("sys_sysfs ( %ld, %ld, %ld )", SARG1, SARG2, ARG3); + + switch (ARG1 /*opcode*/) { + case VKI_GETFSIND: + /* Libc: int sysfs(int opcode, const char *fsname); */ + PRE_REG_READ2(long, SC2("sysfs", "getfsind"), int, opcode, + const char *, fsname); + PRE_MEM_RASCIIZ("sysfs(fsname)", ARG2); + break; + case VKI_GETFSTYP: + /* Libc: int sysfs(int opcode, int fs_index, char *buf); */ + PRE_REG_READ3(long, SC2("sysfs", "getfstyp"), int, opcode, + int, fs_index, char *, buf); + PRE_MEM_WRITE("sysfs(buf)", ARG3, VKI_FSTYPSZ + 1); + break; + case VKI_GETNFSTYP: + /* Libc: int sysfs(int opcode); */ + PRE_REG_READ1(long, SC2("sysfs", "getnfstyp"), int, opcode); + break; + default: + VG_(unimplemented)("Syswrap of the sysfs call with opcode %ld.", SARG1); + /*NOTREACHED*/ + break; + } +} + +POST(sys_sysfs) +{ + switch (ARG1 /*opcode*/) { + case VKI_GETFSIND: + case VKI_GETNFSTYP: + break; + case VKI_GETFSTYP: + POST_MEM_WRITE(ARG3, VG_(strlen)((HChar *) ARG3) + 1); + break; + default: + vg_assert(0); + break; + } +} + + PRE(sys_getmsg) { /* int getmsg(int fildes, struct strbuf *ctlptr, struct strbuf *dataptr, @@ -10392,6 +10438,7 @@ static SyscallTableEntry syscall_table[] = { GENXY(__NR_getdents, sys_getdents), /* 81 */ SOLXY(__NR_privsys, sys_privsys), /* 82 */ SOLXY(__NR_ucredsys, sys_ucredsys), /* 83 */ + SOLXY(__NR_sysfs, sys_sysfs), /* 84 */ SOLXY(__NR_getmsg, sys_getmsg), /* 85 */ SOLX_(__NR_putmsg, sys_putmsg), /* 86 */ #if defined(SOLARIS_OLD_SYSCALLS) diff --git a/include/vki/vki-scnums-solaris.h b/include/vki/vki-scnums-solaris.h index 31d072d510..0ffc4d4545 100644 --- a/include/vki/vki-scnums-solaris.h +++ b/include/vki/vki-scnums-solaris.h @@ -138,7 +138,7 @@ #define __NR_getdents SYS_getdents #define __NR_privsys SYS_privsys #define __NR_ucredsys SYS_ucredsys -//#define __NR_sysfs SYS_sysfs +#define __NR_sysfs SYS_sysfs #define __NR_getmsg SYS_getmsg #define __NR_putmsg SYS_putmsg #define __NR_setgroups SYS_setgroups diff --git a/include/vki/vki-solaris.h b/include/vki/vki-solaris.h index 82371acd98..a7b80c6b6d 100644 --- a/include/vki/vki-solaris.h +++ b/include/vki/vki-solaris.h @@ -564,6 +564,13 @@ typedef struct vki_kcf_door_arg_s { #define vki_namefd namefd +#include +#define VKI_FSTYPSZ FSTYPSZ +#define VKI_GETFSIND GETFSIND +#define VKI_GETFSTYP GETFSTYP +#define VKI_GETNFSTYP GETNFSTYP + + #include #define _VKI_IOC_DIR(x) ((x) & (IOC_VOID | IOC_OUT | IOC_IN)) #define _VKI_IOC_SIZE(x) (((x) >> 16) & IOCPARM_MASK) diff --git a/memcheck/tests/solaris/scalar.c b/memcheck/tests/solaris/scalar.c index c04bb831d2..3947bc0ed1 100644 --- a/memcheck/tests/solaris/scalar.c +++ b/memcheck/tests/solaris/scalar.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -461,14 +462,35 @@ __attribute__((noinline)) static void sys_ucredsys(void) { GO(SYS_ucredsys, "(UCREDSYS_UCREDGET) 3s 1m"); - SY(SYS_ucredsys, x0 + 0, x0, x0 + 1 ); FAIL; + SY(SYS_ucredsys, x0 + 0, x0, x0 + 1); FAIL; } __attribute__((noinline)) static void sys_ucredsys2(void) { GO(SYS_ucredsys, "(UCREDSYS_GETPEERUCRED) 3s 1m"); - SY(SYS_ucredsys, x0 + 1, x0 - 1, x0 + 1 ); FAILx(EBADF); + SY(SYS_ucredsys, x0 + 1, x0 - 1, x0 + 1); FAILx(EBADF); +} + +__attribute__((noinline)) +static void sys_sysfs(void) +{ + GO(SYS_sysfs, "(GETFSIND) 2s 1m"); + SY(SYS_sysfs, x0 + GETFSIND, x0 + 1); FAIL; +} + +__attribute__((noinline)) +static void sys_sysfs2(void) +{ + GO(SYS_sysfs, "(GETFSTYP) 3s 1m"); + SY(SYS_sysfs, x0 + GETFSTYP, x0, x0 + 1); FAIL; +} + +__attribute__((noinline)) +static void sys_sysfs3(void) +{ + GO(SYS_sysfs, "(GETNFSTYP) 1s 0m"); + SY(SYS_sysfs, x0 + GETNFSTYP); SUCC; } __attribute__((noinline)) @@ -1787,7 +1809,9 @@ int main(void) sys_ucredsys2(); /* SYS_sysfs 84 */ - /* XXX Missing wrapper. */ + sys_sysfs(); + sys_sysfs2(); + sys_sysfs3(); /* SYS_getmsg 85 */ GO(SYS_getmsg, "4s 1m"); diff --git a/memcheck/tests/solaris/scalar.stderr.exp b/memcheck/tests/solaris/scalar.stderr.exp index 0686d4a3fe..ceddcf29d7 100644 --- a/memcheck/tests/solaris/scalar.stderr.exp +++ b/memcheck/tests/solaris/scalar.stderr.exp @@ -1495,6 +1495,41 @@ Syscall param ucredsys(buf) points to unaddressable byte(s) ... Address 0x........ is not stack'd, malloc'd or (recently) free'd +--------------------------------------------------------- + 84: SYS_sysfs (GETFSIND) 2s 1m +--------------------------------------------------------- +Syscall param sysfs_getfsind(opcode) contains uninitialised byte(s) + ... + +Syscall param sysfs_getfsind(fsname) contains uninitialised byte(s) + ... + +Syscall param sysfs(fsname) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +--------------------------------------------------------- + 84: SYS_sysfs (GETFSTYP) 3s 1m +--------------------------------------------------------- +Syscall param sysfs_getfstyp(opcode) contains uninitialised byte(s) + ... + +Syscall param sysfs_getfstyp(fs_index) contains uninitialised byte(s) + ... + +Syscall param sysfs_getfstyp(buf) contains uninitialised byte(s) + ... + +Syscall param sysfs(buf) points to unaddressable byte(s) + ... + Address 0x........ is not stack'd, malloc'd or (recently) free'd + +--------------------------------------------------------- + 84: SYS_sysfs (GETNFSTYP) 1s 0m +--------------------------------------------------------- +Syscall param sysfs_getnfstyp(opcode) contains uninitialised byte(s) + ... + --------------------------------------------------------- 85: SYS_getmsg 4s 1m ---------------------------------------------------------