Ver Fonte

sysinit: pointee type should be u8 when using ptr::write_bytes

Using *const (), no bytes are written to the position, which might
result in uninitialized memory access.

Fixes: ebd3d1224c01 ("change(x86): optimize bootstrap code, remove kinit.cpp")
Fixes: 191877a3acd0 ("feat(hal): impl basic single hart bootstrap for riscv64")
Signed-off-by: greatbridf <greatbridf@icloud.com>
greatbridf há 1 semana atrás
pai
commit
20b12dfa22
2 ficheiros alterados com 2 adições e 2 exclusões
  1. 1 1
      crates/eonix_hal/src/arch/riscv64/bootstrap.rs
  2. 1 1
      src/kernel_init.rs

+ 1 - 1
crates/eonix_hal/src/arch/riscv64/bootstrap.rs

@@ -186,7 +186,7 @@ fn setup_kernel_page_table(alloc: BasicPageAllocRef) {
 
     unsafe {
         core::ptr::write_bytes(
-            KERNEL_BSS_START.addr() as *mut (),
+            KERNEL_BSS_START.addr() as *mut u8,
             0,
             bss_length,
         );

+ 1 - 1
src/kernel_init.rs

@@ -41,7 +41,7 @@ fn setup_kernel_page_array(alloc: BasicPageAllocRef, count_pages: usize) {
     unsafe {
         // SAFETY: We've just mapped the area with sufficient length.
         core::ptr::write_bytes(
-            V_KERNEL_PAGE_ARRAY_START.addr() as *mut (),
+            V_KERNEL_PAGE_ARRAY_START.addr() as *mut u8,
             0,
             count_pages * PAGE_SIZE,
         );