aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.com>2016-05-23 19:26:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-23 20:04:14 -0400
commit598fdc1d66674264e122ca9d007ad822e98d8b8d (patch)
tree7bfc47b990ddbe11aa324e74fde24676fc202517
parent17b0573d77fbd547cbf1d711b90d269bdcc1efd3 (diff)
uprobes: wait for mmap_sem for write killable
xol_add_vma needs mmap_sem for write. If the waiting task gets killed by the oom killer it would block oom_reaper from asynchronous address space reclaim and reduce the chances of timely OOM resolving. Wait for the lock in the killable mode and return with EINTR if the task got killed while waiting. Do not warn in dup_xol_work if __create_xol_area failed due to fatal signal pending because this is usually considered a kernel issue. Signed-off-by: Michal Hocko <mhocko@suse.com> Acked-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/events/uprobes.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index c01f733ff2e1..b7a525ab2083 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1130,7 +1130,9 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
1130 struct vm_area_struct *vma; 1130 struct vm_area_struct *vma;
1131 int ret; 1131 int ret;
1132 1132
1133 down_write(&mm->mmap_sem); 1133 if (down_write_killable(&mm->mmap_sem))
1134 return -EINTR;
1135
1134 if (mm->uprobes_state.xol_area) { 1136 if (mm->uprobes_state.xol_area) {
1135 ret = -EALREADY; 1137 ret = -EALREADY;
1136 goto fail; 1138 goto fail;
@@ -1469,7 +1471,8 @@ static void dup_xol_work(struct callback_head *work)
1469 if (current->flags & PF_EXITING) 1471 if (current->flags & PF_EXITING)
1470 return; 1472 return;
1471 1473
1472 if (!__create_xol_area(current->utask->dup_xol_addr)) 1474 if (!__create_xol_area(current->utask->dup_xol_addr) &&
1475 !fatal_signal_pending(current))
1473 uprobe_warn(current, "dup xol area"); 1476 uprobe_warn(current, "dup xol area");
1474} 1477}
1475 1478