Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4081935ybi; Mon, 29 Jul 2019 18:52:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhDw/1O5cJqPOSg1o2qSKbA8Q712OPN8H2dTL0X5rsUo4Z0YQesikCP/qunL6dhTpbaKiv X-Received: by 2002:a17:902:86:: with SMTP id a6mr26218370pla.244.1564451524449; Mon, 29 Jul 2019 18:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564451524; cv=none; d=google.com; s=arc-20160816; b=TofhMHkCBDQv1NRVJ/m+bkR21apMS1oQV013mpsAR5lz2TYQxTmHnkXSUXdfSxcnuN LWLPv6t3uU/7UVhne5VygdJSjX5rQXHLP5pTjT3cG5kZuC/qIECNSZeLYkMZ2kXJWX2m mNi2h+nxMDNgbWLhvmTB57ZwKs3GBlgBjci26jzjMsYAgrJMpriE93lrGYHP6oYJ6fS0 IEkOpuVva6e0aFbvPx3POxr+9wliGOjbt7KkTzjJCiJaWTpbTXJbVC1s+4msHRH5aFKY m2CjUOS7PQzCWfubUNo7EDsUFcuhdEa1mC1We+B4H+zaD6JXE6K0t/7kJ5ys09fmW/v6 +RyA== 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=xyfG5fNmgu4Bfbe1QzTwtnSidnCE5zs1u3epu0mxIrU=; b=rEyi0FbfT85Xu3LTvRbohtL6y0X7XSgujnbPpxmkXODITa8PIoDGACe4kCzzbwdZb2 qgo0C2riaFm4sQVZOTXH0TyXk8597cOSilE+o1BUFW2UtRvWbqlIInnM1soglRAsvBJG W9lSUi5h84W2a6I232Qx3vK+6M8/zj9jEf75PLQ5ambhQjeFOt50hJxmb+YpiYmRPjdj wri+WtZG8Yxmiq1SGN0NmaIYR2fOBPt+t0p+bs4s9RnXlv004YJEWsXlDdbQah/gUaPi ksyqhA8eh4EWIfH21gyDOLK84o46r63I2XFuiJyCz4+h61R6C0y+xmT+yo5DI1Siqbib LIVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ytt4dx0b; 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 a21si27412449pgv.185.2019.07.29.18.51.49; Mon, 29 Jul 2019 18:52: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=Ytt4dx0b; 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 S2389590AbfG2Tng (ORCPT + 99 others); Mon, 29 Jul 2019 15:43:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:59918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389665AbfG2Tnc (ORCPT ); Mon, 29 Jul 2019 15:43:32 -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 7BAF821773; Mon, 29 Jul 2019 19:43:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429412; bh=333I/5dGGjAojenhI1WcZlnlZf5vSbq8kbFNtZytKEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ytt4dx0b2xWk1iSfbqmrs0l3Ey9CH1kPKNTzDGEpojnmyvbBF38sfe8vca33u+C2c lb21e4EaiKWu9fdkK/WFrkA+g0aYhObJaZY57iyBlwFYKdrK4RJS95A0kQQEUqHPUw x9I4g1F+dSzQAEn8FIIEAc7GFVwyvgDGdPubS4ok= 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 090/113] proc: use down_read_killable mmap_sem for /proc/pid/pagemap Date: Mon, 29 Jul 2019 21:22:57 +0200 Message-Id: <20190729190716.968891980@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 ad80b932c57d85fd6377f97f359b025baf179a87 ] 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/156007493638.3335.4872164955523928492.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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index b2010055180e..74965e17ffd5 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1535,7 +1535,9 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, /* overflow ? */ if (end < start_vaddr || end > end_vaddr) end = end_vaddr; - down_read(&mm->mmap_sem); + ret = down_read_killable(&mm->mmap_sem); + if (ret) + goto out_free; ret = walk_page_range(start_vaddr, end, &pagemap_walk); up_read(&mm->mmap_sem); start_vaddr = end; -- 2.20.1