mmu.c (d0034a7a4ac7fae708146ac0059b9c47a1543f0d) mmu.c (6032aca0deb9c138df122192f8ef02de1fdccf25)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de)
4 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
5 */
6
7#include <linux/mm.h>
8#include <linux/sched/signal.h>

--- 7 unchanged lines hidden (view full) ---

16
17int init_new_context(struct task_struct *task, struct mm_struct *mm)
18{
19 struct mm_context *from_mm = NULL;
20 struct mm_context *to_mm = &mm->context;
21 unsigned long stack = 0;
22 int ret = -ENOMEM;
23
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de)
4 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
5 */
6
7#include <linux/mm.h>
8#include <linux/sched/signal.h>

--- 7 unchanged lines hidden (view full) ---

16
17int init_new_context(struct task_struct *task, struct mm_struct *mm)
18{
19 struct mm_context *from_mm = NULL;
20 struct mm_context *to_mm = &mm->context;
21 unsigned long stack = 0;
22 int ret = -ENOMEM;
23
24 stack = get_zeroed_page(GFP_KERNEL);
24 stack = __get_free_pages(GFP_KERNEL | __GFP_ZERO, ilog2(STUB_DATA_PAGES));
25 if (stack == 0)
26 goto out;
27
28 to_mm->id.stack = stack;
29 if (current->mm != NULL && current->mm != &init_mm)
30 from_mm = &current->mm->context;
31
32 block_signals_trace();

--- 14 unchanged lines hidden (view full) ---

47 " failed, errno = %d\n", ret);
48 goto out_free;
49 }
50
51 return 0;
52
53 out_free:
54 if (to_mm->id.stack != 0)
25 if (stack == 0)
26 goto out;
27
28 to_mm->id.stack = stack;
29 if (current->mm != NULL && current->mm != &init_mm)
30 from_mm = &current->mm->context;
31
32 block_signals_trace();

--- 14 unchanged lines hidden (view full) ---

47 " failed, errno = %d\n", ret);
48 goto out_free;
49 }
50
51 return 0;
52
53 out_free:
54 if (to_mm->id.stack != 0)
55 free_page(to_mm->id.stack);
55 free_pages(to_mm->id.stack, ilog2(STUB_DATA_PAGES));
56 out:
57 return ret;
58}
59
60void destroy_context(struct mm_struct *mm)
61{
62 struct mm_context *mmu = &mm->context;
63

--- 5 unchanged lines hidden (view full) ---

69 */
70 if (mmu->id.u.pid < 2) {
71 printk(KERN_ERR "corrupt mm_context - pid = %d\n",
72 mmu->id.u.pid);
73 return;
74 }
75 os_kill_ptraced_process(mmu->id.u.pid, 1);
76
56 out:
57 return ret;
58}
59
60void destroy_context(struct mm_struct *mm)
61{
62 struct mm_context *mmu = &mm->context;
63

--- 5 unchanged lines hidden (view full) ---

69 */
70 if (mmu->id.u.pid < 2) {
71 printk(KERN_ERR "corrupt mm_context - pid = %d\n",
72 mmu->id.u.pid);
73 return;
74 }
75 os_kill_ptraced_process(mmu->id.u.pid, 1);
76
77 free_page(mmu->id.stack);
77 free_pages(mmu->id.stack, ilog2(STUB_DATA_PAGES));
78 free_ldt(mmu);
79}
78 free_ldt(mmu);
79}