]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Solaris: Add syscall wrapper for sysfs(84)
authorIvo Raisr <ivosh@ivosh.net>
Tue, 19 Apr 2016 15:57:13 +0000 (15:57 +0000)
committerIvo Raisr <ivosh@ivosh.net>
Tue, 19 Apr 2016 15:57:13 +0000 (15:57 +0000)
Fixes BZ#361926

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15862

NEWS
coregrind/m_syswrap/syswrap-solaris.c
include/vki/vki-scnums-solaris.h
include/vki/vki-solaris.h
memcheck/tests/solaris/scalar.c
memcheck/tests/solaris/scalar.stderr.exp

diff --git a/NEWS b/NEWS
index b4d7859c401b94796710875d243608a5f36543ab..19be7b93dcac1860590678ab3b92912b78be0bc8 100644 (file)
--- 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
index b98b17ddb047e70fee655744535a2ce402b48262..45e3a18e783b0f338bf4e448f0587d998710f0f9 100644 (file)
@@ -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)
index 31d072d51002fb7349320ad64c717472f1fbdb13..0ffc4d454541f345896acf6d495b59f6aa2cd1ae 100644 (file)
 #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
index 82371acd98241a5570fd102dcdb95e940935d678..a7b80c6b6d03376c57dd19349d1c27ab640f9415 100644 (file)
@@ -564,6 +564,13 @@ typedef struct vki_kcf_door_arg_s {
 #define vki_namefd namefd
 
 
+#include <sys/fstyp.h>
+#define VKI_FSTYPSZ FSTYPSZ
+#define VKI_GETFSIND GETFSIND
+#define VKI_GETFSTYP GETFSTYP
+#define VKI_GETNFSTYP GETNFSTYP
+
+
 #include <sys/ioccom.h>
 #define _VKI_IOC_DIR(x) ((x) & (IOC_VOID | IOC_OUT | IOC_IN))
 #define _VKI_IOC_SIZE(x) (((x) >> 16) & IOCPARM_MASK)
index c04bb831d2e4c97155de819b65de6e83aa3fd2a3..3947bc0ed109fdda69eae036e8047f9a04a3810c 100644 (file)
@@ -8,6 +8,7 @@
 #include <sys/acl.h>
 #include <sys/door.h>
 #include <sys/fcntl.h>
+#include <sys/fstyp.h>
 #include <sys/lwp.h>
 #include <sys/mman.h>
 #include <sys/mount.h>
@@ -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");
index 0686d4a3fef7a0d4273345c8dc819fa947fae40b..ceddcf29d700bd117dda76547d6e011a94307e27 100644 (file)
@@ -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
 ---------------------------------------------------------