Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4319465ybi; Mon, 29 Jul 2019 23:52:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1cfLhCazAx1krVE5MMTaHC5vyZPQ1FCDygiXdXM5oHgnl1YDrjfe+xGdcjjm1Lb6Yrin0 X-Received: by 2002:a63:221f:: with SMTP id i31mr110154201pgi.251.1564469557602; Mon, 29 Jul 2019 23:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564469557; cv=none; d=google.com; s=arc-20160816; b=cAVaVCWASAoUU5Bz1d5mh6QwDW2qRbZjjpgy5sQW5Xj0LZ1DRFijAlC3sCEzzhmeFF u3YIz0XRhE+Y9uQzLMi6uYsdV/cgOw2uopqB3KjfrObeQfIInlrJNss5tLY+A3csVftk ry8/FU3hIhlNAk7rxBdTbwBudkNiAmumZJi08sIQ1832/9IzLjPZMSyqPIfmMakocFze qin2umkmsXB8FSY+hF0veXKAOJ+psR2I7rd8sj2iU8YfSFpcwMXTObpR8+eBfVQIJzYQ xKjek+Aq9DaicwdgLHGgnaXvKwyemQI+EfA4/UUI9kFb3D0+L39tyFbpjTDQae8vVpnm Lobw== 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=PDkcY4zOB8G48dgxwSezGBtXV4zTwKNs+LG5tj5Gsts=; b=a5BrlvLNZU5gbVuyRiZpeZ7patPbkwdkboE2rzcLm9djPEFj/9p21HRoI1BcxuudFc D8+loK8YKab7mDNuxQ/YAPz1J6orLzHg3nthpmiKA/qAF6yGPdro0euyWYFzC/bgIzXo oDEdWqLvbREHyqRhKoHzHx2K3QXJCnhK7G8x1BYFnovh3PEmXJpLW/8/+UtTpY9Ww6ry lnwh7ltsMANbnchEzjuTHKPlx8o9fftwrDUV2W12Ultz1pGjbJWbuc6fB5cyPVDnjHab ZsPgwEypREOMBD6Pzvr4L/LSKZOLQYoHe7wR13QyliKCFc3x37U9MppQCCanUQGRvRqU /BtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CbHzDpCl; 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 a15si17053863pgk.523.2019.07.29.23.52.13; Mon, 29 Jul 2019 23:52:37 -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=CbHzDpCl; 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 S2404067AbfG2Tyc (ORCPT + 99 others); Mon, 29 Jul 2019 15:54:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:47044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391013AbfG2TyX (ORCPT ); Mon, 29 Jul 2019 15:54:23 -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 5B7D1204EC; Mon, 29 Jul 2019 19:54:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564430062; bh=wmV/Hdg2mAJ/eQfdnW1wNtGHgzq8wuVvE5OUD144UNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CbHzDpClGkOb4dtJAVzqusgsUcybhqMtbjpwx9XpwDgdqoJUrsYGWZQOWY29m+pcn 6gnBDp2Pk15+oK6U8wh01BJWFzp9pTTux4CINjtzSgJka8EYzCmwFGeuXIcj+esMxY SYcsYHTJIvLbwlvF6bv2cXs8lOn1LVi9UGdE6XNE= 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 157/215] proc: use down_read_killable mmap_sem for /proc/pid/smaps_rollup Date: Mon, 29 Jul 2019 21:22:33 +0200 Message-Id: <20190729190807.001630404@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 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 01d4eb0e6bd1..4d9a8e72d91f 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -828,7 +828,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) { @@ -845,8 +848,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