Author: iraisr
Date: Tue Apr 19 16:57:13 2016
New Revision: 15862
Log:
Solaris: Add syscall wrapper for sysfs(84)
Fixes BZ#361926
Modified:
trunk/NEWS
trunk/coregrind/m_syswrap/syswrap-solaris.c
trunk/include/vki/vki-scnums-solaris.h
trunk/include/vki/vki-solaris.h
trunk/memcheck/tests/solaris/scalar.c
trunk/memcheck/tests/solaris/scalar.stderr.exp
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Tue Apr 19 16:57:13 2016
@@ -92,6 +92,7 @@
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
Modified: trunk/coregrind/m_syswrap/syswrap-solaris.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-solaris.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-solaris.c Tue Apr 19 16:57:13 2016
@@ -951,6 +951,7 @@
#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 @@
}
}
+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 @@
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)
Modified: trunk/include/vki/vki-scnums-solaris.h
==============================================================================
--- trunk/include/vki/vki-scnums-solaris.h (original)
+++ trunk/include/vki/vki-scnums-solaris.h Tue Apr 19 16:57:13 2016
@@ -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
Modified: trunk/include/vki/vki-solaris.h
==============================================================================
--- trunk/include/vki/vki-solaris.h (original)
+++ trunk/include/vki/vki-solaris.h Tue Apr 19 16:57:13 2016
@@ -564,6 +564,13 @@
#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)
Modified: trunk/memcheck/tests/solaris/scalar.c
==============================================================================
--- trunk/memcheck/tests/solaris/scalar.c (original)
+++ trunk/memcheck/tests/solaris/scalar.c Tue Apr 19 16:57:13 2016
@@ -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 @@
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 @@
sys_ucredsys2();
/* SYS_sysfs 84 */
- /* XXX Missing wrapper. */
+ sys_sysfs();
+ sys_sysfs2();
+ sys_sysfs3();
/* SYS_getmsg 85 */
GO(SYS_getmsg, "4s 1m");
Modified: trunk/memcheck/tests/solaris/scalar.stderr.exp
==============================================================================
--- trunk/memcheck/tests/solaris/scalar.stderr.exp (original)
+++ trunk/memcheck/tests/solaris/scalar.stderr.exp Tue Apr 19 16:57:13 2016
@@ -1496,6 +1496,41 @@
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
---------------------------------------------------------
Syscall param getmsg(fildes) contains uninitialised byte(s)
|