[compiler-rt] r184539 - [santizer] Disable several EVIOxxx ioctls on older kernels.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Fri Jun 21 03:54:57 PDT 2013


Author: eugenis
Date: Fri Jun 21 05:54:57 2013
New Revision: 184539

URL: http://llvm.org/viewvc/llvm-project?rev=184539&view=rev
Log:
[santizer] Disable several EVIOxxx ioctls on older kernels.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc?rev=184539&r1=184538&r2=184539&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc Fri Jun 21 05:54:57 2013
@@ -33,13 +33,15 @@ static unsigned ioctl_table_size = 0;
 // require a global initializer. And this table must be available before global
 // initializers are run.
 static void ioctl_table_fill() {
-#define _(rq, tp, sz)                                  \
-  CHECK(ioctl_table_size < ioctl_table_max);           \
-  ioctl_table[ioctl_table_size].req = IOCTL_##rq;      \
-  ioctl_table[ioctl_table_size].type = ioctl_desc::tp; \
-  ioctl_table[ioctl_table_size].size = sz;             \
-  ioctl_table[ioctl_table_size].name = #rq;            \
-  ++ioctl_table_size;
+#define _(rq, tp, sz)                                    \
+  if (IOCTL_##rq != IOCTL_NOT_PRESENT) {                 \
+    CHECK(ioctl_table_size < ioctl_table_max);           \
+    ioctl_table[ioctl_table_size].req = IOCTL_##rq;      \
+    ioctl_table[ioctl_table_size].type = ioctl_desc::tp; \
+    ioctl_table[ioctl_table_size].size = sz;             \
+    ioctl_table[ioctl_table_size].name = #rq;            \
+    ++ioctl_table_size;                                  \
+  }
 
   _(FIOASYNC, READ, sizeof(int));
   _(FIOCLEX, NONE, 0);

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc?rev=184539&r1=184538&r2=184539&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.cc Fri Jun 21 05:54:57 2013
@@ -208,7 +208,11 @@ namespace __sanitizer {
   unsigned struct_audio_buf_info_sz = sizeof(struct audio_buf_info);
   unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
   unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
+#if EV_VERSION > (0x010000)
   unsigned struct_input_keymap_entry_sz = sizeof(struct input_keymap_entry);
+#else
+  unsigned struct_input_keymap_entry_sz = 0;
+#endif
   unsigned struct_ipx_config_data_sz = sizeof(struct ipx_config_data);
   unsigned struct_kbdiacrs_sz = sizeof(struct kbdiacrs);
   unsigned struct_kbentry_sz = sizeof(struct kbentry);
@@ -232,6 +236,8 @@ namespace __sanitizer {
   unsigned struct_sioc_vif_req_sz = sizeof(struct sioc_vif_req);
 #endif
 
+  unsigned IOCTL_NOT_PRESENT = 0;
+
   unsigned IOCTL_FIOASYNC = FIOASYNC;
   unsigned IOCTL_FIOCLEX = FIOCLEX;
   unsigned IOCTL_FIOGETOWN = FIOGETOWN;
@@ -556,9 +562,15 @@ namespace __sanitizer {
   unsigned IOCTL_EQL_GETSLAVECFG = EQL_GETSLAVECFG;
   unsigned IOCTL_EQL_SETMASTRCFG = EQL_SETMASTRCFG;
   unsigned IOCTL_EQL_SETSLAVECFG = EQL_SETSLAVECFG;
+#if EV_VERSION > (0x010000)
   unsigned IOCTL_EVIOCGKEYCODE_V2 = EVIOCGKEYCODE_V2;
   unsigned IOCTL_EVIOCGPROP = EVIOCGPROP(0);
   unsigned IOCTL_EVIOCSKEYCODE_V2 = EVIOCSKEYCODE_V2;
+#else
+  unsigned IOCTL_EVIOCGKEYCODE_V2 = IOCTL_NOT_PRESENT;
+  unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT;
+  unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT;
+#endif
   unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
   unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
   unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h?rev=184539&r1=184538&r2=184539&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h Fri Jun 21 05:54:57 2013
@@ -236,6 +236,11 @@ namespace __sanitizer {
 #endif
 
   // ioctl request identifiers
+
+  // A special value to mark ioctls that are not present on the target platform,
+  // when it can not be determined without including any system headers.
+  extern unsigned IOCTL_NOT_PRESENT;
+
   extern unsigned IOCTL_FIOASYNC;
   extern unsigned IOCTL_FIOCLEX;
   extern unsigned IOCTL_FIOGETOWN;





More information about the llvm-commits mailing list