Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3802765ybi; Mon, 29 Jul 2019 12:56:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkHSfyM9TpYpcKEg3MiJ0sA+zkfCNliaCDx6fxEA8vTMnWITgpKPrd7UUl7k/I0brQTJmf X-Received: by 2002:a65:534c:: with SMTP id w12mr105984392pgr.51.1564430198432; Mon, 29 Jul 2019 12:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430198; cv=none; d=google.com; s=arc-20160816; b=Y1K7OovtTgT0POm0PXhRx0awKYRwFIY7wNOsGiqVXq1nLXuGG88cCn4dGxwxiB8c/N s4m/jzYTUeMvwYHLqTVGNi/Xlz8sXA7Xp1Z3r7Z2UE5MJYVFSA3brGt9921CNpdQ+IqV C2a4Zf16OsWjTuZNggbpZ8LP3EgK4lq62PnH68KWaZ/l3f5ETax2F3mUtmzFD9hfgqCj IcORJC3GraU1CR7L/IBfepfoFR0hhj1B6eB7xVUKqJqhELugxS7iNatganoin3m/thSi mvDcoLOnJIoCT+G6tCfGEsuBE2l6EpIidZaAQV1H0PaIBTYFrVcehkM8aGGl/7FB16bu tgmw== 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=Gn+Jp/V5tv8pcbEA+G6OONq739GVsnqOc3FLc6seCr0=; b=HZlSslpwvcy3ctMjVdpNo+MZMmpOwo4BdXWuRFKnLtZcIaOXhfqyXfzW2lzmUdvspr KRHomjeEmBjX3OPEeFQpN9Qh4MBli1ioxvJjU/pJiDqZAyVrzb3AS0oaXObEb2f7HJEC HUaz+l7OJW9DWjWKi22Chj4kpjT6vc49GxYYy1BVE8azQHToJFyhcOqiE6QYHWStITsN 169Qwh0f4aW4b5zF5eJsQZF4f6MflKRGkIHf4WRpHHn4WemcvHT9jLAmS6uaCgkdR7Tf +39Ae2nyEBVaEcJXtVnkG6aJgMET2u8FQ1GO+BQaFfqpDrb5qiVbzTKyDIzaNMxc3VMW qjSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pnTPb4Aj; 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 x10si29349400pfj.93.2019.07.29.12.56.23; Mon, 29 Jul 2019 12:56:38 -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=pnTPb4Aj; 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 S2391035AbfG2TzL (ORCPT + 99 others); Mon, 29 Jul 2019 15:55:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:47882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403890AbfG2TzI (ORCPT ); Mon, 29 Jul 2019 15:55:08 -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 46E952054F; Mon, 29 Jul 2019 19:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564430107; bh=vYx/zHP8wWU9g1UIxBmoe+KnVEnCZqWTIOJc41rRGsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pnTPb4AjXNFB1atxPkhyren0de8uUY5M7C5OzZK6Eife3lxasvT3F4XHKO7wNmhTH kqXJSAHRJziPmm+FWxmDk8CvhQClgWxnEOvuiWlkZPgTqVubPevyza6k1YOnFBdz4K 57kJQp9pTU0n9JNu4lJo+t+xfCzJfR2G4MY3PTIE= 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 5.2 159/215] proc: use down_read_killable mmap_sem for /proc/pid/clear_refs Date: Mon, 29 Jul 2019 21:22:35 +0200 Message-Id: <20190729190807.416089191@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@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 1d9c63cd8a3c..abcd9513efff 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1136,7 +1136,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