File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
amd/device-libs/asanrtl/src Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 77
88#include "shadow_mapping.h"
99
10+ static const __constant u8 kAsanHeapLeftRedzoneMagic = (u8 )0xfa ;
11+
1012NO_SANITIZE_ADDR
1113static uptr
1214range_check (uptr beg , uptr end ) {
@@ -45,3 +47,25 @@ __asan_region_is_poisoned(uptr beg, uptr size)
4547 }
4648 return 0 ;
4749}
50+
51+ USED NO_INLINE NO_SANITIZE_ADDR
52+ void
53+ __asan_poison_region (ulong beg , ulong size )
54+ {
55+ // Handle intial bytes if not aligned.
56+ if (!is_aligned_by_granularity (beg )) {
57+ ulong beg_round_downto = round_downto (beg , SHADOW_GRANULARITY );
58+ __global s8 * shadow_ptr = (__global s8 * )MEM_TO_SHADOW (beg_round_downto );
59+ s8 shadow_value = (s8 ) (beg - beg_round_downto );
60+ * shadow_ptr = shadow_value ;
61+ }
62+
63+ // Handle aligned bytes.
64+ ulong end = round_downto (beg + size , SHADOW_GRANULARITY );
65+ ulong beg_round_upto = round_upto (beg , SHADOW_GRANULARITY );
66+ if (end > beg_round_upto ) {
67+ u64 shadow_size = (end - beg_round_upto ) / SHADOW_GRANULARITY ;
68+ __global s8 * shadow_ptr = (__global s8 * )MEM_TO_SHADOW (beg_round_upto );
69+ __builtin_memset (shadow_ptr , kAsanHeapLeftRedzoneMagic , shadow_size );
70+ }
71+ }
You can’t perform that action at this time.
0 commit comments