[santizer] Disable several EVIOxxx ioctls on older kernels.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@184539 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
index 80f2521..887530a 100755
--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
@@ -33,13 +33,15 @@
// 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);
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
index 7ae0c65..86ce8c7 100644
--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -208,7 +208,11 @@
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 @@
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 @@
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;
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index cf55d36..ef0031e 100644
--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -236,6 +236,11 @@
#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;