From 5752f0a173b84a76b772ee0abc8b4a1ad99d301d Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Sun, 18 Oct 2020 11:42:15 +0200 Subject: pk: Fix pushing of argc to match linux kernel behaviour The linux kernel pushes argc as an int, not an uintptr_t. (The offset to the next element is still sizeof(uintptr_t).) --- pk/pk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pk/pk.c b/pk/pk.c index bce11a5..87dfc78 100644 --- a/pk/pk.c +++ b/pk/pk.c @@ -129,15 +129,15 @@ static void run_loaded_program(size_t argc, char** argv, uintptr_t kstack_top) // place argc, argv, envp, auxp on stack #define PUSH_ARG(type, value) do { \ *((type*)sp) = (type)value; \ - sp += sizeof(type); \ + sp ++; \ } while (0) #define STACK_INIT(type) do { \ unsigned naux = sizeof(aux)/sizeof(aux[0]); \ stack_top -= (1 + argc + 1 + envc + 1 + 2*naux) * sizeof(type); \ stack_top &= -16; \ - long sp = stack_top; \ - PUSH_ARG(type, argc); \ + type *sp = (void*)stack_top; \ + PUSH_ARG(int, argc); \ for (unsigned i = 0; i < argc; i++) \ PUSH_ARG(type, argv[i]); \ PUSH_ARG(type, 0); /* argv[argc] = NULL */ \ -- cgit v1.1