[compiler-rt] 99ade15 - Revert "[compiler-rt] prctl interception update, SECCOMP_MODE_FILTER support. (#107722)"

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 08:27:14 PDT 2024


Author: Nico Weber
Date: 2024-09-24T11:27:06-04:00
New Revision: 99ade15d192db4afa897a7052a9c73dd42c2b88c

URL: https://github.com/llvm/llvm-project/commit/99ade15d192db4afa897a7052a9c73dd42c2b88c
DIFF: https://github.com/llvm/llvm-project/commit/99ade15d192db4afa897a7052a9c73dd42c2b88c.diff

LOG: Revert "[compiler-rt] prctl interception update, SECCOMP_MODE_FILTER support. (#107722)"

This reverts commit b75174d05aa033a382d4c088e96e068a774f46da.
Does not build on Android, see comments on
https://github.com/llvm/llvm-project/pull/107722

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
    compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
    compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index e29cc0c8b390ab..bf5bb43018efc4 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -1289,9 +1289,6 @@ INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3,
   static const int PR_SCHED_CORE = 62;
   static const int PR_SCHED_CORE_GET = 0;
   static const int PR_GET_PDEATHSIG = 2;
-  static const int PR_SET_SECCOMP = 22;
-
-  static const int SECCOMP_MODE_FILTER = 2;
   if (option == PR_SET_VMA && arg2 == 0UL) {
     char *name = (char *)arg5;
     COMMON_INTERCEPTOR_READ_RANGE(ctx, name, internal_strlen(name) + 1);
@@ -1310,9 +1307,6 @@ INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3,
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, (u64 *)(arg5), sizeof(u64));
   } else if (res != -1 && option == PR_GET_PDEATHSIG) {
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, (u64 *)(arg2), sizeof(int));
-  } else if (res != -1 && option == PR_SET_SECCOMP &&
-             arg2 == SECCOMP_MODE_FILTER) {
-    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, (u64 *)(arg3), struct_sock_fprog_sz);
   }
   return res;
 }

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
index 5eeb2a89efa8c5..6d61d276d77e35 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
@@ -117,16 +117,15 @@ typedef struct user_fpregs elf_fpregset_t;
 #if SANITIZER_LINUX
 #if SANITIZER_GLIBC
 #include <fstab.h>
-#      include <linux/filter.h>
-#      include <net/if_ppp.h>
-#      include <netax25/ax25.h>
-#      include <netipx/ipx.h>
-#      include <netrom/netrom.h>
-#      include <obstack.h>
-#      if HAVE_RPC_XDR_H
-#        include <rpc/xdr.h>
-#      endif
-#      include <scsi/scsi.h>
+#include <net/if_ppp.h>
+#include <netax25/ax25.h>
+#include <netipx/ipx.h>
+#include <netrom/netrom.h>
+#include <obstack.h>
+#if HAVE_RPC_XDR_H
+# include <rpc/xdr.h>
+#endif
+#include <scsi/scsi.h>
 #else
 #include <linux/if_ppp.h>
 #include <linux/kd.h>
@@ -532,10 +531,9 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
 
   unsigned struct_audio_buf_info_sz = sizeof(struct audio_buf_info);
   unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats);
-  unsigned struct_sock_fprog_sz = sizeof(struct sock_fprog);
-#  endif  // SANITIZER_GLIBC
+#endif  // SANITIZER_GLIBC
 
-#  if !SANITIZER_ANDROID && !SANITIZER_APPLE
+#if !SANITIZER_ANDROID && !SANITIZER_APPLE
   unsigned struct_sioc_sg_req_sz = sizeof(struct sioc_sg_req);
   unsigned struct_sioc_vif_req_sz = sizeof(struct sioc_vif_req);
 #endif

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index ca03841ccc1988..34bfef1f7ef456 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -1050,8 +1050,7 @@ extern unsigned struct_serial_struct_sz;
 extern unsigned struct_sockaddr_ax25_sz;
 extern unsigned struct_unimapdesc_sz;
 extern unsigned struct_unimapinit_sz;
-extern unsigned struct_sock_fprog_sz;
-#  endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
+#endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
 
 extern const unsigned long __sanitizer_bufsiz;
 

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp
index dab1d1b48f8689..cbff02d66efa78 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/prctl.cpp
@@ -4,8 +4,6 @@
 
 #include <assert.h>
 #include <errno.h>
-#include <linux/filter.h>
-#include <linux/seccomp.h>
 #include <stdint.h>
 #include <string.h>
 #include <sys/mman.h>
@@ -80,13 +78,5 @@ int main() {
     }
   }
 
-  sock_filter f[] = {{.code = (BPF_LD | BPF_W | BPF_ABS),
-                      .k = (uint32_t)(SKF_AD_OFF | SKF_AD_CPU)},
-                     {.code = (BPF_RET | BPF_A), .k = 0}};
-  sock_fprog pr = {.len = 2, .filter = f};
-
-  res = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &pr);
-  assert(res == -1);
-
   return 0;
 }


        


More information about the llvm-commits mailing list