2.6.30-noarch: Add generic mm_switch protection
Subsystems (5)
PATCH 1/3 2.6.30-noarch: Add generic mm_switch protection
Add helpers around mm_switch and updates of current->[active_]mm so that archs can implement the proper protections.
Signed-off-by Jan Kiszka <[email protected]>
---
fs/aio.c | 5 ++++- fs/exec.c | 3 +++ kernel/fork.c | 3 +++ 3 files changed, 10 insertions(+), 1 deletions(-)
fs/aio.c +4 -1
@@ -618,13 +618,16 @@ static void use_mm(struct mm_struct *mm) {struct mm_struct *active_mm;struct task_struct *tsk = current; +unsigned long flags;task_lock (tsk); active_mm = tsk->active_mm;atomic_inc (&mm->mm_count); tsk->mm = mm; +ipipe_mm_switch_protect (flags); tsk->active_mm = mm; -switch_mm (active_mm, mm, tsk); +__switch_mm (active_mm, mm, tsk); +ipipe_mm_switch_unprotect (flags);task_unlock (tsk);mmdrop (active_mm);
fs/exec.c +3 -0
@@ -698,6 +698,7 @@ static int exec_mmap(struct mm_struct *mm) {struct task_struct *tsk;struct mm_struct * old_mm, *active_mm; +unsigned long flags;/* Notify parent that we're no longer interested in the old VM */ tsk = current;
@@ -720,8 +721,10 @@ static int exec_mmap(struct mm_struct *mm)task_lock (tsk); active_mm = tsk->active_mm; tsk->mm = mm; +ipipe_mm_switch_protect (flags); tsk->active_mm = mm;activate_mm (active_mm, mm); +ipipe_mm_switch_unprotect (flags);task_unlock (tsk);arch_pick_mmap_layout (mm);if (old_mm) {
kernel/fork.c +3 -0
@@ -1670,11 +1670,14 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags) }if (new_mm) { +unsigned long flags; mm = current->mm; active_mm = current->active_mm; current->mm = new_mm; +ipipe_mm_switch_protect (flags); current->active_mm = new_mm;activate_mm (active_mm, new_mm); +ipipe_mm_switch_unprotect (flags); new_mm = mm; }