clang's -fsanitize=function relies on the presence of
__ubsan_handle_function_type_mismatch() to print the detection of indirect
calls of a function through a function pointer of the wrong type.
Implement the helper, inspired on the llvm ubsan lib implementation.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
ubsan_epilogue(&flags);
}
+
+void __ubsan_handle_function_type_mismatch(
+ struct function_type_mismatch_data *data, unsigned long val)
+{
+ unsigned long flags;
+
+ if (suppress_report(&data->location))
+ return;
+
+ ubsan_prologue(&data->location, &flags);
+
+ pr_err("call to function %ps through pointer to incorrect function type %s\n",
+ (void *)val, data->type->type_name);
+
+ ubsan_epilogue(&flags);
+}
kind_clz,
};
+struct function_type_mismatch_data {
+ struct source_location location;
+ struct type_descriptor *type;
+};
+
#if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__)
typedef __int128 s_max;
typedef unsigned __int128 u_max;