summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2023-04-10 20:50:18 +0200
committerSam Atkins <atkinssj@gmail.com>2023-04-14 16:12:04 +0100
commited74f792e22167b23bca8f7bd9f27372bfd93831 (patch)
tree2c905a637d27617572c56cae22569238d3c20a7c /Kernel
parentdcd462a05017ea9c66f24ac7adc9f1cb339345f7 (diff)
downloadserenity-ed74f792e22167b23bca8f7bd9f27372bfd93831.zip
Kernel: Pick the maximum out of the requested stack sizes
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Syscalls/execve.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp
index d5d6db4c99..1f93613016 100644
--- a/Kernel/Syscalls/execve.cpp
+++ b/Kernel/Syscalls/execve.cpp
@@ -284,7 +284,7 @@ static ErrorOr<LoadResult> load_elf_object(Memory::AddressSpace& new_space, Open
size_t master_tls_size = 0;
size_t master_tls_alignment = 0;
FlatPtr load_base_address = 0;
- size_t stack_size = 0;
+ size_t stack_size = Thread::default_userspace_stack_size;
auto elf_name = TRY(object_description.pseudo_path());
VERIFY(!Processor::in_critical());
@@ -381,7 +381,10 @@ static ErrorOr<LoadResult> load_elf_object(Memory::AddressSpace& new_space, Open
return load_section(program_header);
if (program_header.type() == PT_GNU_STACK) {
- stack_size = program_header.size_in_memory();
+ auto new_stack_size = program_header.size_in_memory();
+
+ if (new_stack_size > stack_size)
+ stack_size = new_stack_size;
}
// NOTE: We ignore other program header types.
@@ -397,10 +400,6 @@ static ErrorOr<LoadResult> load_elf_object(Memory::AddressSpace& new_space, Open
return result;
}());
- if (stack_size == 0) {
- stack_size = Thread::default_userspace_stack_size;
- }
-
if (!elf_image.entry().offset(load_offset).get()) {
dbgln("do_exec: Failure loading program, entry pointer is invalid! {})", elf_image.entry().offset(load_offset));
return ENOEXEC;