]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
PRE(sys_prctl): handle PR_SET_SECCOMP.
authorJulian Seward <jseward@acm.org>
Tue, 10 Mar 2015 11:05:10 +0000 (11:05 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 10 Mar 2015 11:05:10 +0000 (11:05 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14994

coregrind/m_syswrap/syswrap-linux.c
include/vki/vki-linux.h

index e87320a3a71cd4cc6df30bdeef180d765e79803f..f0c979339aff91f1aa6e6155f76e700acef4afb7 100644 (file)
@@ -1018,6 +1018,21 @@ PRE(sys_prctl)
    case VKI_PR_SET_PTRACER:
       PRE_REG_READ2(int, "prctl", int, option, int, ptracer_process_ID);
       break;
+   case VKI_PR_SET_SECCOMP:
+      /* This is a bit feeble in that it uses |option| before checking
+         it, but at least both sides of the conditional check it. */
+      if (ARG2 == VKI_SECCOMP_MODE_FILTER) {
+         PRE_REG_READ3(int, "prctl", int, option, int, mode, char*, filter);
+         if (ARG3) {
+            /* Should check that ARG3 points at a valid struct sock_fprog.
+               Sounds complex; hence be lame. */
+            PRE_MEM_READ( "prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, filter)",
+                          ARG3, 1 );
+         }
+      } else {
+         PRE_REG_READ2(int, "prctl", int, option, int, mode);
+      }
+      break;
    default:
       PRE_REG_READ5(long, "prctl",
                     int, option, unsigned long, arg2, unsigned long, arg3,
index 63a0da516a540f7aed5f974a0dd0ecb9cc76a7df..a66b8bc6cb43bf97775dad0ce12f235fddced243 100644 (file)
@@ -2508,6 +2508,9 @@ struct vki_vt_consize {
 # define VKI_PR_ENDIAN_BIG             0
 # define VKI_PR_ENDIAN_LITTLE  1       /* True little endian mode */
 # define VKI_PR_ENDIAN_PPC_LITTLE      2       /* "PowerPC" pseudo little endian */
+
+#define VKI_PR_SET_SECCOMP 22
+
 #define VKI_PR_SET_PTRACER 0x59616d61
 
 //----------------------------------------------------------------------
@@ -4601,6 +4604,12 @@ enum vki_kcmp_type {
    VKI_KCMP_TYPES
 };
 
+//----------------------------------------------------------------------
+// From linux-3.19-rc5/include/uapi/linux/seccomp.h
+//----------------------------------------------------------------------
+
+#define VKI_SECCOMP_MODE_FILTER 2
+
 #endif // __VKI_LINUX_H
 
 /*--------------------------------------------------------------------*/