phtread: limit stack size to Genode's max stack size

issue #2791
This commit is contained in:
Sebastian Sumpf 2017-09-27 09:48:13 +02:00 committed by Christian Helmuth
parent dfc2e2bd68
commit 2ff11dc063

View File

@ -237,10 +237,15 @@ extern "C" {
if (!attr || !*attr)
return EINVAL;
if (stacksize > (Thread::stack_virtual_size() - 4 * 4096) ||
stacksize < 4096)
if (stacksize < 4096)
return EINVAL;
size_t max_stack = Thread::stack_virtual_size() - 4 * 4096;
if (stacksize > max_stack) {
warning(__func__, ": requested stack size is ", stacksize, " limiting to ", max_stack);
stacksize = max_stack;
}
(*attr)->stack_size = Genode::align_addr(stacksize, 12);
return 0;