]>
git.saurik.com Git - apple/xnu.git/blob - san/ubsan.h
e24045ab24177342f5f78d2a02aef4556e04d031
2 * Copyright (c) 2018 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
35 struct san_type_desc
{
36 uint16_t type
; // 0: integer, 1: float
39 uint16_t issigned
: 1;
41 }; /* int descriptor */
44 }; /* float descriptor */
55 struct ubsan_overflow_desc
{
56 struct san_src_loc loc
;
57 struct san_type_desc
*ty
;
60 struct ubsan_unreachable_desc
{
61 struct san_src_loc loc
;
64 struct ubsan_shift_desc
{
65 struct san_src_loc loc
;
66 struct san_type_desc
*lhs_t
;
67 struct san_type_desc
*rhs_t
;
70 struct ubsan_align_desc
{
71 struct san_src_loc loc
;
72 struct san_type_desc
*ty
;
77 struct ubsan_ptroverflow_desc
{
78 struct san_src_loc loc
;
81 struct ubsan_oob_desc
{
82 struct san_src_loc loc
;
83 struct san_type_desc
*array_ty
;
84 struct san_type_desc
*index_ty
;
87 struct ubsan_load_invalid_desc
{
88 struct san_src_loc loc
;
89 struct san_type_desc
*type
;
93 UBSAN_OVERFLOW_add
= 1,
96 UBSAN_OVERFLOW_divrem
,
97 UBSAN_OVERFLOW_negate
,
101 UBSAN_POINTER_OVERFLOW
,
105 UBSAN_LOAD_INVALID_VALUE
,
109 struct ubsan_violation
{
114 struct ubsan_overflow_desc
*overflow
;
115 struct ubsan_unreachable_desc
*unreachable
;
116 struct ubsan_shift_desc
*shift
;
117 struct ubsan_align_desc
*align
;
118 struct ubsan_ptroverflow_desc
*ptroverflow
;
119 struct ubsan_oob_desc
*oob
;
120 struct ubsan_load_invalid_desc
*invalid
;
123 struct san_src_loc
*loc
;
126 void ubsan_log_append(struct ubsan_violation
*);
127 size_t ubsan_format(struct ubsan_violation
*, char *buf
, size_t sz
);
133 void __ubsan_handle_add_overflow(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
134 void __ubsan_handle_add_overflow_abort(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
135 void __ubsan_handle_builtin_unreachable(struct ubsan_unreachable_desc
*);
136 void __ubsan_handle_divrem_overflow(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
137 void __ubsan_handle_divrem_overflow_abort(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
138 void __ubsan_handle_mul_overflow(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
139 void __ubsan_handle_mul_overflow_abort(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
140 void __ubsan_handle_negate_overflow(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
141 void __ubsan_handle_negate_overflow_abort(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
142 void __ubsan_handle_out_of_bounds(struct ubsan_oob_desc
*, uint64_t idx
);
143 void __ubsan_handle_out_of_bounds_abort(struct ubsan_oob_desc
*, uint64_t idx
);
144 void __ubsan_handle_pointer_overflow(struct ubsan_ptroverflow_desc
*, uint64_t lhs
, uint64_t rhs
);
145 void __ubsan_handle_pointer_overflow_abort(struct ubsan_ptroverflow_desc
*, uint64_t lhs
, uint64_t rhs
);
146 void __ubsan_handle_shift_out_of_bounds(struct ubsan_shift_desc
*, uint64_t lhs
, uint64_t rhs
);
147 void __ubsan_handle_shift_out_of_bounds_abort(struct ubsan_shift_desc
*, uint64_t lhs
, uint64_t rhs
);
148 void __ubsan_handle_sub_overflow(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
149 void __ubsan_handle_sub_overflow_abort(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
150 void __ubsan_handle_type_mismatch_v1(struct ubsan_align_desc
*, uint64_t val
);
151 void __ubsan_handle_type_mismatch_v1_abort(struct ubsan_align_desc
*, uint64_t val
);
152 void __ubsan_handle_load_invalid_value(struct ubsan_load_invalid_desc
*, uint64_t);
153 void __ubsan_handle_load_invalid_value_abort(struct ubsan_load_invalid_desc
*, uint64_t);
155 /* currently unimplemented */
156 void __ubsan_handle_float_cast_overflow(struct san_src_loc
*);
157 void __ubsan_handle_float_cast_overflow_abort(struct san_src_loc
*);
158 void __ubsan_handle_function_type_mismatch(struct san_src_loc
*);
159 void __ubsan_handle_function_type_mismatch_abort(struct san_src_loc
*);
160 void __ubsan_handle_implicit_conversion(struct san_src_loc
*);
161 void __ubsan_handle_implicit_conversion_abort(struct san_src_loc
*);
162 void __ubsan_handle_invalid_builtin(struct san_src_loc
*);
163 void __ubsan_handle_invalid_builtin_abort(struct san_src_loc
*);
164 void __ubsan_handle_missing_return(struct san_src_loc
*);
165 void __ubsan_handle_missing_return_abort(struct san_src_loc
*);
166 void __ubsan_handle_nonnull_arg(struct san_src_loc
*);
167 void __ubsan_handle_nonnull_arg_abort(struct san_src_loc
*);
168 void __ubsan_handle_nonnull_return(struct san_src_loc
*);
169 void __ubsan_handle_nonnull_return_abort(struct san_src_loc
*);
170 void __ubsan_handle_nullability_arg(struct san_src_loc
*);
171 void __ubsan_handle_nullability_arg_abort(struct san_src_loc
*);
172 void __ubsan_handle_nullability_return(struct san_src_loc
*);
173 void __ubsan_handle_nullability_return_abort(struct san_src_loc
*);
174 void __ubsan_handle_vla_bound_not_positive(struct san_src_loc
*);
175 void __ubsan_handle_vla_bound_not_positive_abort(struct san_src_loc
*);
177 #endif /* _UBSAN_H_ */