Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4081932ybi; Mon, 29 Jul 2019 18:52:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqw32S6GuXTln20WYPL0j8HuZaQAnFRqZOBKPKN95rJ+8Xotjo4q3NoT4cAQUT2ieTwt2ECB X-Received: by 2002:a65:56c1:: with SMTP id w1mr105065602pgs.395.1564451523880; Mon, 29 Jul 2019 18:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564451523; cv=none; d=google.com; s=arc-20160816; b=sMOWWXKWzjYonCfNYzOOuxZGO4+Xwz7uPV1GXCr0vOa9m+Nl7ms5cr3xJ6zscQEqLc bGc1FUe1KN4ZmpT5ps4Em845UEj3F/9jLPiHihc4W50v9+lylnP0iDH/70I2KoSkj4Yo vfQVM49hz5jSsGrgA6VoPSc87cDWlGdskvrX5ip2ibF8Cgtlel1PDIvo7LmHxhloJQ+c okx8VIuWfwZiyassPyUnzAaZHLy2zIKYwL99cPqnKyjCHetADQhDG2IBEli7RXipdKRy NpCHYLIAQNCsfKYBjk5atlUVMNFWwchsEH0Ghk2PiU9ZK5ER/ePPqMyXYJBoDICkiDjx Q45g== 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=0zetfJaMijeKGJuMbIrDfaXCNsxMhvem+1dPu9EqEmk=; b=wALMNJ11x36ihNVb76wmlZBMzBA6QyAXg09gMEsTRGuPjzVsywOYRtqtwQqgodgM3z 8BZjJ/+FXgxafeZCwrQ3Kd2TWi7zKWELvJYqKn+ZxLjqSsdosrN9BVhaHOxu8AvbfASv Eu6EG86hbzQKzx2yzYzT0cYeiMDSxteFR7lhCexMQaZ3IgYoJlu8aHJBpvHemGreuhsU i7k1MmuRe7/+nIdIGPToirl28dpCZa7HSM9eNV+y7zOLq88idma/Ss9NA0ksRXP4svYy a7qqKqHb2FjmYq7ATGPUQ+iQvla8LThE+ktwoXary6LzqfU7zjDdCsInrvT8DSwOHH9/ NIKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PwNRXeki; 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 m9si27374851pll.333.2019.07.29.18.51.49; Mon, 29 Jul 2019 18:52:03 -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=PwNRXeki; 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 S2389667AbfG2Tnc (ORCPT + 99 others); Mon, 29 Jul 2019 15:43:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:59832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389657AbfG2Tna (ORCPT ); Mon, 29 Jul 2019 15:43:30 -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 D32C2205F4; Mon, 29 Jul 2019 19:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429409; bh=3lizOSZSapAncVFPDk5SecML46iwtuSEJnnXCAzjas0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PwNRXekieHW8Ac57KKNAG5jNWExGzTKvt5OpKgaldt19nnLPDT2xLmyphhd4km4G7 vBhNGYmr1qDKrKP1knA7IqTxA/lg9IlMOqsVbDShEYa0U9tqjJv8YsK6MBKJSbYVDu rSC9Y4Jak6E+d+I8GqHc8upsheEIpZzpHNSm6ARg= 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 089/113] proc: use down_read_killable mmap_sem for /proc/pid/smaps_rollup Date: Mon, 29 Jul 2019 21:22:56 +0200 Message-Id: <20190729190716.728939574@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 a26a97815548574213fd37f29b4b78ccc6d9ed20 ] 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/156007493429.3335.14666825072272692455.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 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index c5819baee35c..b2010055180e 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -826,7 +826,10 @@ static int show_smaps_rollup(struct seq_file *m, void *v) memset(&mss, 0, sizeof(mss)); - down_read(&mm->mmap_sem); + ret = down_read_killable(&mm->mmap_sem); + if (ret) + goto out_put_mm; + hold_task_mempolicy(priv); for (vma = priv->mm->mmap; vma; vma = vma->vm_next) { @@ -843,8 +846,9 @@ static int show_smaps_rollup(struct seq_file *m, void *v) release_task_mempolicy(priv); up_read(&mm->mmap_sem); - mmput(mm); +out_put_mm: + mmput(mm); out_put_task: put_task_struct(priv->task); priv->task = NULL; -- 2.20.1