From: Konstantin Khlebnikov Date: Fri, 12 Jul 2019 03:59:56 +0000 (-0700) Subject: proc: use down_read_killable mmap_sem for /proc/pid/pagemap X-Git-Tag: v4.19.63~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=42beb7b3d446f035d93c818dbc81c467d25a45c8;p=platform%2Fkernel%2Flinux-rpi.git proc: use down_read_killable mmap_sem for /proc/pid/pagemap [ Upstream commit ad80b932c57d85fd6377f97f359b025baf179a87 ] Do not remain stuck forever if something goes wrong. Using a killable lock permits cleanup of stuck tasks and simplifies investigation. Link: http://lkml.kernel.org/r/156007493638.3335.4872164955523928492.stgit@buzz Signed-off-by: Konstantin Khlebnikov Reviewed-by: Roman Gushchin Reviewed-by: Cyrill Gorcunov Reviewed-by: Kirill Tkhai Acked-by: Michal Hocko Cc: Alexey Dobriyan Cc: Al Viro Cc: Matthew Wilcox Cc: Michal Koutný Cc: Oleg Nesterov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index b201005..74965e1 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1535,7 +1535,9 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, /* overflow ? */ if (end < start_vaddr || end > end_vaddr) end = end_vaddr; - down_read(&mm->mmap_sem); + ret = down_read_killable(&mm->mmap_sem); + if (ret) + goto out_free; ret = walk_page_range(start_vaddr, end, &pagemap_walk); up_read(&mm->mmap_sem); start_vaddr = end;