-.\" $OpenBSD: kubsan.4,v 1.4 2024/09/06 13:30:59 mbuhl Exp $
+.\" $OpenBSD: kubsan.4,v 1.5 2024/09/06 13:31:59 mbuhl Exp $
.\"
.\" Copyright (c) 2019 Anton Lindqvist <anton@openbsd.org>
.\"
.Dv NULL
as the value for a function argument annotated with
.Dv __nonnull__ .
+.It Invalid builtin
+Passing zero to a compiler builtin where not allowed.
.It Invalid load
Loading a value that cannot be represented by the destination type.
.It Type mismatch
-/* $OpenBSD: subr_kubsan.c,v 1.12 2019/11/06 19:16:48 anton Exp $ */
+/* $OpenBSD: subr_kubsan.c,v 1.13 2024/09/06 13:31:59 mbuhl Exp $ */
/*
* Copyright (c) 2019 Anton Lindqvist <anton@openbsd.org>
struct kubsan_report {
enum {
KUBSAN_FLOAT_CAST_OVERFLOW,
+ KUBSAN_INVALID_BUILTIN,
KUBSAN_INVALID_VALUE,
KUBSAN_NEGATE_OVERFLOW,
KUBSAN_NONNULL_ARG,
unsigned long v_val;
} v_float_cast_overflow;
+ struct {
+ const struct invalid_builtin_data *v_data;
+ } v_invalid_builtin;
+
struct {
const struct invalid_value_data *v_data;
unsigned long v_val;
} kr_u;
};
#define kr_float_cast_overflow kr_u.v_float_cast_overflow
+#define kr_invalid_builtin kr_u.v_invalid_builtin
#define kr_invalid_value kr_u.v_invalid_value
#define kr_negate_overflow kr_u.v_negate_overflow
#define kr_nonnull_arg kr_u.v_nonnull_arg
struct type_descriptor *d_ttype; /* to type */
};
+struct invalid_builtin_data {
+ struct source_location d_src;
+ uint8_t d_kind;
+};
+
struct invalid_value_data {
struct source_location d_src;
struct type_descriptor *d_type;
kubsan_defer_report(&kr);
}
+void
+__ubsan_handle_invalid_builtin(struct invalid_builtin_data *data)
+{
+ struct kubsan_report kr = {
+ .kr_type = KUBSAN_INVALID_VALUE,
+ .kr_src = &data->d_src,
+ .kr_invalid_builtin = { data },
+ };
+
+ kubsan_defer_report(&kr);
+}
+
void
__ubsan_handle_load_invalid_value(struct invalid_value_data *data,
unsigned long val)
break;
}
+ case KUBSAN_INVALID_BUILTIN: {
+ const struct invalid_builtin_data *data =
+ kr->kr_invalid_builtin.v_data;
+
+ printf("kubsan: %s: invalid builtin: passing zero to "
+ "%s, which is not a valid argument\n",
+ bloc, kubsan_kind(data->d_kind));
+ break;
+ }
+
case KUBSAN_INVALID_VALUE: {
const struct invalid_value_data *data =
kr->kr_invalid_value.v_data;