Kernel: Align argv and envp to pointer boundary

This bug was found with ubsan
This commit is contained in:
Bananymous 2025-07-01 14:20:09 +03:00
parent fb7e9719a1
commit 41e1819072
1 changed files with 3 additions and 2 deletions

View File

@ -285,6 +285,9 @@ namespace Kernel
// auxv
needed_size += auxv.size() * sizeof(LibELF::AuxiliaryVector);
if (auto rem = needed_size % alignof(char*))
needed_size += alignof(char*) - rem;
if (needed_size > m_userspace_stack->size())
return BAN::Error::from_errno(ENOBUFS);
@ -358,8 +361,6 @@ namespace Kernel
stack_push_str(envp[i]);
}
ASSERT(vaddr == userspace_stack_top());
setup_exec(entry, userspace_stack_top() - needed_size);
return {};