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

Method assert_write_access

src/kernel/generic/kasan.cpp:114–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114inline void kernel::Kasan::assert_write_access(uintptr_t addr, size_t size)
115{
116 if (!_enabled)
117 return;
118
119 _enabled = false;
120
121 uintptr_t shadow_start = addr / 8;
122 uintptr_t shadow_end = (addr + size - 1) / 8;
123
124 for (uintptr_t shadow_addr = shadow_start; shadow_addr <= shadow_end; shadow_addr++)
125 {
126 uint8_t shadow_value = _shadow_memory[shadow_addr];
127
128 // Calculate the first invalid byte within this shadow byte
129 uintptr_t first_invalid_byte = shadow_addr * 8;
130 if (first_invalid_byte < addr + size && (shadow_value == 0 || shadow_value == 0x1))
131 {
132 fmt::err$("kasan: invalid write access at address {}, size {}\n", addr | fmt::FMT_HEX, size);
133
134 unreachable$();
135 }
136 }
137
138 _enabled = true;
139
140 this->_lock.release();
141}
142
143extern "C" void __asan_before_dynamic_init()
144{

Callers 6

__asan_storeN_noabortFunction · 0.80
__asan_store1_noabortFunction · 0.80
__asan_store2_noabortFunction · 0.80
__asan_store4_noabortFunction · 0.80
__asan_store8_noabortFunction · 0.80
__asan_store16_noabortFunction · 0.80

Calls 1

releaseMethod · 0.45

Tested by

no test coverage detected