[RHEL8,COMMIT] mm/gup: Let __get_user_pages_locked() return -EINTR for fatal signal

Submitted by Konstantin Khorenko on April 20, 2020, 7:34 a.m.

Details

Message ID 202004200734.03K7YRoE016265@finist_co8.work.ct
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko April 20, 2020, 7:34 a.m.
The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.3.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.3.6
------>
commit d4f652a6c5ee5ebcbe2fdf30abcfcb315a7e0dac
Author: Hillf Danton <hdanton@sina.com>
Date:   Mon Apr 20 10:34:26 2020 +0300

    mm/gup: Let __get_user_pages_locked() return -EINTR for fatal signal
    
    __get_user_pages_locked() will return 0 instead of -EINTR after commit
    4426e945df588 ("mm/gup: allow VM_FAULT_RETRY for multiple times") which
    added extra code to allow gup detect fatal signal faster.
    
    Restore the original -EINTR behavior.
    
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Fixes: 4426e945df58 ("mm/gup: allow VM_FAULT_RETRY for multiple times")
    Reported-by: syzbot+3be1a33f04dc782e9fd5@syzkaller.appspotmail.com
    Signed-off-by: Hillf Danton <hdanton@sina.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Signed-off-by: Peter Xu <peterx@redhat.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    
    https://jira.sw.ru/browse/PSBM-102938
    (cherry picked from commit ae46d2aa6a7fbe8ca0946f24b061b6ccdc6c3f25)
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/gup.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/mm/gup.c b/mm/gup.c
index 3d08b68c210f..049e05960e1e 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -941,8 +941,11 @@  static __always_inline long __get_user_pages_locked(struct task_struct *tsk,
 		 * start trying again otherwise it can loop forever.
 		 */
 
-		if (fatal_signal_pending(current))
+		if (fatal_signal_pending(current)) {
+			if (!pages_done)
+				pages_done = -EINTR;
 			break;
+		}
 
 		*locked = 1;
 		ret = down_read_killable(&mm->mmap_sem);