Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3793822ybi; Mon, 29 Jul 2019 12:45:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxo4knsMvyr54QJu5OaQ1MgBD7b/tLMVdUCS1tq0/tsoTPMQyotJVfhSNbEI+5MdL2CQwUq X-Received: by 2002:a65:464d:: with SMTP id k13mr95101376pgr.99.1564429504568; Mon, 29 Jul 2019 12:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429504; cv=none; d=google.com; s=arc-20160816; b=eSrV3SIuMC9RjssaZecWw5tW/bz0nwDfS+NBlobxJOaoBrohO0ZWcmjDJd/V4yYxK9 OCuCWICp27JBYBEI7q2+avBLiGzdHPI43d7AX7QEdbArgR/fKYvKOLRlImyqIBNwvXYP 4gPZguLCHNuwzCzMb8VjbKXXcA3zHmZUjx+izFN48ihC1W4wdjJ+yFAaoYLE8oaHIXiT fhdNT5UZ40P9RjCfGeMVu67dToTZNhin0PURPiiro94IpdgkK89X8cRDSwd6+PG0LR9n +VRmE91WIqo+Nr8lxZiviyg1gc7BqEFaR819vDFplWJtPcUxePieiNKUhlcOFzMOfitu 03bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lc/8oPm4rhQLTWOBTLeAmBCpXimdg6q8Q6893ovp2kY=; b=x9hhojVgY36ctY+2W7KHnU4SvQmAJ0sE3JQXQ2u38hh+Qug/tqtcq3J+adSmnQ41Mt mfbVht1htpGHRFXmutfyraVMMXEc+GTLFZZhXcj+91RZsJrnsb5sZ0hXtg4+53Kj0POX K39GhGMCPI4PkStk4I2Jx8o8DKoOHQvfwQFLab2dAYt8oIjhAAdG0vPWbssXelQo2wP1 54DhTzJQCyqnQW1tGO1AU+3IA9oBr0lKAGclUO3JKEWlzmMhQ6CwAlWbo6UMKes8PeyC 9aTvEAzVv+67FuiwjbLBfQ5o9ecV39Ne3XOrqjamJeZwU0cTKpRoDdvBc3y9BKn2ebbR MUjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D7sarOmR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o33si25396026plb.408.2019.07.29.12.44.49; Mon, 29 Jul 2019 12:45:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D7sarOmR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389683AbfG2Tnk (ORCPT + 99 others); Mon, 29 Jul 2019 15:43:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:60008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389146AbfG2Tng (ORCPT ); Mon, 29 Jul 2019 15:43:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E3CC20C01; Mon, 29 Jul 2019 19:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429415; bh=7IlkZw/2t+39Kdv3zI+iZeNRgsWP2mSgdijooRbHjyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D7sarOmRUsCiMgfOgY6szA/aRvokh5q4x/mOZMI4j8bBHYu1RJNa/A1+oJD9y4l5q r4hVASvijt3JoXLDXUZTUkAvT4BVHa52fYI/kJ9VcDhL6LOLo2MaquPOIJSoiPT0SO C0eWNnbs6OV8zDf+OrS16SRGwSn0qLr493e6BSJI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konstantin Khlebnikov , Roman Gushchin , Cyrill Gorcunov , Kirill Tkhai , Michal Hocko , Alexey Dobriyan , Al Viro , Matthew Wilcox , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Oleg Nesterov , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 091/113] proc: use down_read_killable mmap_sem for /proc/pid/clear_refs Date: Mon, 29 Jul 2019 21:22:58 +0200 Message-Id: <20190729190717.223896566@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit c46038017fbdcac627b670c9d4176f1d0c2f5fa3 ] Do not remain stuck forever if something goes wrong. Using a killable lock permits cleanup of stuck tasks and simplifies investigation. Replace the only unkillable mmap_sem lock in clear_refs_write(). Link: http://lkml.kernel.org/r/156007493826.3335.5424884725467456239.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 --- fs/proc/task_mmu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 74965e17ffd5..195fbbaf77d4 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1131,7 +1131,10 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, goto out_mm; } - down_read(&mm->mmap_sem); + if (down_read_killable(&mm->mmap_sem)) { + count = -EINTR; + goto out_mm; + } tlb_gather_mmu(&tlb, mm, 0, -1); if (type == CLEAR_REFS_SOFT_DIRTY) { for (vma = mm->mmap; vma; vma = vma->vm_next) { -- 2.20.1