Kernel: Align argv and envp to pointer boundary
This bug was found with ubsan
This commit is contained in:
parent
fb7e9719a1
commit
41e1819072
|
@ -285,6 +285,9 @@ namespace Kernel
|
||||||
// auxv
|
// auxv
|
||||||
needed_size += auxv.size() * sizeof(LibELF::AuxiliaryVector);
|
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())
|
if (needed_size > m_userspace_stack->size())
|
||||||
return BAN::Error::from_errno(ENOBUFS);
|
return BAN::Error::from_errno(ENOBUFS);
|
||||||
|
|
||||||
|
@ -358,8 +361,6 @@ namespace Kernel
|
||||||
stack_push_str(envp[i]);
|
stack_push_str(envp[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(vaddr == userspace_stack_top());
|
|
||||||
|
|
||||||
setup_exec(entry, userspace_stack_top() - needed_size);
|
setup_exec(entry, userspace_stack_top() - needed_size);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Reference in New Issue