MCPcopy Create free account
hub / github.com/Supercip971/WingOS / assert_read_access

Method assert_read_access

src/kernel/generic/kasan.cpp:74–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74inline void kernel::Kasan::assert_read_access(uintptr_t addr, size_t size)
75{
76
77 if (!_enabled)
78 return;
79
80 this->_lock.lock();
81 _enabled = false;
82
83 uintptr_t shadow_start = addr / 8;
84 uintptr_t shadow_end = (addr + size - 1) / 8;
85
86 uintptr_t addr_tag = (addr >> 56) & 0xFF;
87
88 if (addr_tag == 0)
89 {
90 // Skip the check for addresses with tag 0
91 _enabled = true;
92 this->_lock.release();
93 return;
94 }
95 for (uintptr_t shadow_addr = shadow_start; shadow_addr <= shadow_end; shadow_addr++)
96 {
97 uint8_t shadow_value = _shadow_memory[shadow_addr];
98
99 // Calculate the first invalid byte within this shadow byte
100 uintptr_t first_invalid_byte = shadow_addr * 8;
101 if (first_invalid_byte < addr + size && (shadow_value == 0 || shadow_value == 0x1))
102 {
103 fmt::err$("kasan: invalid read access at address {}, size {}\n", addr | fmt::FMT_HEX, size);
104
105 unreachable$();
106 }
107 }
108
109 _enabled = true;
110
111 this->_lock.release();
112}
113
114inline void kernel::Kasan::assert_write_access(uintptr_t addr, size_t size)
115{

Callers 6

__asan_loadN_noabortFunction · 0.80
__asan_load1_noabortFunction · 0.80
__asan_load2_noabortFunction · 0.80
__asan_load4_noabortFunction · 0.80
__asan_load8_noabortFunction · 0.80
__asan_load16_noabortFunction · 0.80

Calls 2

lockMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected