+ mm-use-down_read_killable-for-locking-mmap_sem-in-access_remote_vm.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm: use down_read_killable for locking mmap_sem in access_remote_vm
has been added to the -mm tree.  Its filename is
     mm-use-down_read_killable-for-locking-mmap_sem-in-access_remote_vm.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/mm-use-down_read_killable-for-locking-mmap_sem-in-access_remote_vm.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/mm-use-down_read_killable-for-locking-mmap_sem-in-access_remote_vm.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxxxxxx>
Subject: mm: use down_read_killable for locking mmap_sem in access_remote_vm

This function is used by ptrace and proc files like /proc/pid/cmdline and
/proc/pid/environ.

Access_remote_vm never returns error codes, all errors are ignored and
only size of successfully read data is returned.  So, if current task was
killed we'll simply return 0 (bytes read).

Mmap_sem could be locked for a long time or forever if something goes
wrong.  Using a killable lock permits cleanup of stuck tasks and
simplifies investigation.

Link: http://lkml.kernel.org/r/156007494202.3335.16782303099589302087.stgit@buzz
Signed-off-by: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxxxxxx>
Reviewed-by: Michal Koutný <mkoutny@xxxxxxxx>
Acked-by: Oleg Nesterov <oleg@xxxxxxxxxx>
Acked-by: Michal Hocko <mhocko@xxxxxxxx>
Cc: Alexey Dobriyan <adobriyan@xxxxxxxxx>
Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
Cc: Cyrill Gorcunov <gorcunov@xxxxxxxxx>
Cc: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx>
Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Roman Gushchin <guro@xxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/memory.c |    4 +++-
 mm/nommu.c  |    3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

--- a/mm/memory.c~mm-use-down_read_killable-for-locking-mmap_sem-in-access_remote_vm
+++ a/mm/memory.c
@@ -4344,7 +4344,9 @@ int __access_remote_vm(struct task_struc
 	void *old_buf = buf;
 	int write = gup_flags & FOLL_WRITE;
 
-	down_read(&mm->mmap_sem);
+	if (down_read_killable(&mm->mmap_sem))
+		return 0;
+
 	/* ignore errors, just check how much was successfully transferred */
 	while (len) {
 		int bytes, ret, offset;
--- a/mm/nommu.c~mm-use-down_read_killable-for-locking-mmap_sem-in-access_remote_vm
+++ a/mm/nommu.c
@@ -1792,7 +1792,8 @@ int __access_remote_vm(struct task_struc
 	struct vm_area_struct *vma;
 	int write = gup_flags & FOLL_WRITE;
 
-	down_read(&mm->mmap_sem);
+	if (down_read_killable(&mm->mmap_sem))
+		return 0;
 
 	/* the access must start within one of the target process's mappings */
 	vma = find_vma(mm, addr);
_

Patches currently in -mm which might be from khlebnikov@xxxxxxxxxxxxxx are

proc-use-down_read_killable-mmap_sem-for-proc-pid-maps.patch
proc-use-down_read_killable-mmap_sem-for-proc-pid-smaps_rollup.patch
proc-use-down_read_killable-mmap_sem-for-proc-pid-pagemap.patch
proc-use-down_read_killable-mmap_sem-for-proc-pid-clear_refs.patch
proc-use-down_read_killable-mmap_sem-for-proc-pid-map_files.patch
mm-use-down_read_killable-for-locking-mmap_sem-in-access_remote_vm.patch





[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux