]>
git.saurik.com Git - apple/xnu.git/blob - san/ubsan.h
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
;
88 UBSAN_OVERFLOW_add
= 1,
91 UBSAN_OVERFLOW_divrem
,
92 UBSAN_OVERFLOW_negate
,
96 UBSAN_POINTER_OVERFLOW
,
101 struct ubsan_violation
{
106 struct ubsan_overflow_desc
*overflow
;
107 struct ubsan_unreachable_desc
*unreachable
;
108 struct ubsan_shift_desc
*shift
;
109 struct ubsan_align_desc
*align
;
110 struct ubsan_ptroverflow_desc
*ptroverflow
;
111 struct ubsan_oob_desc
*oob
;
113 struct san_src_loc
*loc
;
116 void ubsan_log_append(struct ubsan_violation
*);
117 size_t ubsan_format(struct ubsan_violation
*, char *buf
, size_t sz
);
123 void __ubsan_handle_add_overflow(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
124 void __ubsan_handle_sub_overflow(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
125 void __ubsan_handle_mul_overflow(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
126 void __ubsan_handle_divrem_overflow(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
127 void __ubsan_handle_negate_overflow(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
128 void __ubsan_handle_add_overflow_abort(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
129 void __ubsan_handle_sub_overflow_abort(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
130 void __ubsan_handle_mul_overflow_abort(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
131 void __ubsan_handle_divrem_overflow_abort(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
132 void __ubsan_handle_negate_overflow_abort(struct ubsan_overflow_desc
*, uint64_t lhs
, uint64_t rhs
);
133 void __ubsan_handle_builtin_unreachable(struct ubsan_unreachable_desc
*);
134 void __ubsan_handle_shift_out_of_bounds(struct ubsan_shift_desc
*, uint64_t lhs
, uint64_t rhs
);
135 void __ubsan_handle_shift_out_of_bounds_abort(struct ubsan_shift_desc
*, uint64_t lhs
, uint64_t rhs
);
136 void __ubsan_handle_type_mismatch_v1(struct ubsan_align_desc
*, uint64_t val
);
137 void __ubsan_handle_type_mismatch_v1_abort(struct ubsan_align_desc
*, uint64_t val
);
138 void __ubsan_handle_pointer_overflow(struct ubsan_ptroverflow_desc
*, uint64_t lhs
, uint64_t rhs
);
139 void __ubsan_handle_pointer_overflow_abort(struct ubsan_ptroverflow_desc
*, uint64_t lhs
, uint64_t rhs
);
140 void __ubsan_handle_out_of_bounds(struct ubsan_oob_desc
*, uint64_t idx
);
141 void __ubsan_handle_out_of_bounds_abort(struct ubsan_oob_desc
*, uint64_t idx
);
143 #endif /* _UBSAN_H_ */