Commit 8cd12043 authored by Kinsbursky Stanislav's avatar Kinsbursky Stanislav Committed by Cyrill Gorcunov

parasite: replace stack heap with mapped one

Stack heap size is probably small for dumping unix sockest skb's (it's hard to
discover, how big it could be; thus let's assume that 10MB is enough,
otherwise give up and throw error).
So let' replace this stack heap wil 10 MB anonimous private mapping.
Signed-off-by: 's avatarStanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 5990b6bf
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#define PARASITE_STACK_SIZE 2048 #define PARASITE_STACK_SIZE 2048
#define PARASITE_ARG_SIZE 8196 #define PARASITE_ARG_SIZE 8196
#define PARASITE_BRK_SIZE 32768
#define PARASITE_MAX_SIZE (64 << 10) #define PARASITE_MAX_SIZE (64 << 10)
......
...@@ -28,10 +28,27 @@ static struct vma_entry vma; ...@@ -28,10 +28,27 @@ static struct vma_entry vma;
static int logfd = -1; static int logfd = -1;
static int tsock = -1; static int tsock = -1;
static void brk_init(void *brk) static int brk_init(void)
{ {
brk_start = brk_tail = brk; unsigned long heap_size = 10 * 1024 * 1024;
brk_end = brk_start + PARASITE_BRK_SIZE; unsigned long ret;
/*
* Map 10 MB. Hope this will be enough for unix skb's...
*/
ret = sys_mmap(0, heap_size,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (ret < 0)
return -ENOMEM;
brk_start = brk_tail = (void *)ret;
brk_end = brk_start + heap_size;
return 0;
}
static void brk_fini(void)
{
sys_munmap(brk_start, brk_end - brk_start);
} }
static void *brk_alloc(unsigned long bytes) static void *brk_alloc(unsigned long bytes)
...@@ -390,6 +407,9 @@ static int init(struct parasite_init_args *args) ...@@ -390,6 +407,9 @@ static int init(struct parasite_init_args *args)
int ret; int ret;
k_rtsigset_t to_block; k_rtsigset_t to_block;
if (brk_init() < 0)
return -1;
tsock = sys_socket(PF_UNIX, SOCK_DGRAM, 0); tsock = sys_socket(PF_UNIX, SOCK_DGRAM, 0);
if (tsock < 0) { if (tsock < 0) {
return -1; return -1;
...@@ -423,13 +443,12 @@ static int fini(void) ...@@ -423,13 +443,12 @@ static int fini(void)
sys_sigprocmask(SIG_SETMASK, &old_blocked, NULL); sys_sigprocmask(SIG_SETMASK, &old_blocked, NULL);
sys_close(logfd); sys_close(logfd);
sys_close(tsock); sys_close(tsock);
brk_fini();
return 0; return 0;
} }
static int __used parasite_service(unsigned long cmd, void *args, void *brk) static int __used parasite_service(unsigned long cmd, void *args)
{ {
brk_init(brk);
BUILD_BUG_ON(sizeof(struct parasite_dump_pages_args) > PARASITE_ARG_SIZE); BUILD_BUG_ON(sizeof(struct parasite_dump_pages_args) > PARASITE_ARG_SIZE);
BUILD_BUG_ON(sizeof(struct parasite_init_args) > PARASITE_ARG_SIZE); BUILD_BUG_ON(sizeof(struct parasite_init_args) > PARASITE_ARG_SIZE);
BUILD_BUG_ON(sizeof(struct parasite_dump_misc) > PARASITE_ARG_SIZE); BUILD_BUG_ON(sizeof(struct parasite_dump_misc) > PARASITE_ARG_SIZE);
...@@ -478,7 +497,6 @@ static void __parasite_head __used parasite_head(void) ...@@ -478,7 +497,6 @@ static void __parasite_head __used parasite_head(void)
"movq %rsp, %rbp \n" "movq %rsp, %rbp \n"
"movl parasite_cmd(%rip), %edi \n" "movl parasite_cmd(%rip), %edi \n"
"leaq parasite_args(%rip), %rsi \n" "leaq parasite_args(%rip), %rsi \n"
"leaq parasite_brk(%rip), %rdx \n"
"call parasite_service \n" "call parasite_service \n"
"parasite_service_complete: \n" "parasite_service_complete: \n"
"int $0x03 \n" "int $0x03 \n"
...@@ -490,9 +508,6 @@ static void __parasite_head __used parasite_head(void) ...@@ -490,9 +508,6 @@ static void __parasite_head __used parasite_head(void)
".space "__stringify(PARASITE_ARG_SIZE)",0 \n" ".space "__stringify(PARASITE_ARG_SIZE)",0 \n"
".space "__stringify(PARASITE_STACK_SIZE)", 0 \n" ".space "__stringify(PARASITE_STACK_SIZE)", 0 \n"
"parasite_stack: \n" "parasite_stack: \n"
".long 0 \n"
"parasite_brk: \n"
".space "__stringify(PARASITE_BRK_SIZE)", 0 \n"
".long 0 \n"); ".long 0 \n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment