Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3804501ybi; Mon, 29 Jul 2019 12:58:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwA4bz+mS9lZMPqp+0x+eomHSIsPOznr2r7a5cUlF/TdRyogQqcHefzHEslLiP1p/ezzow8 X-Received: by 2002:a17:90a:24ac:: with SMTP id i41mr112333389pje.124.1564430333141; Mon, 29 Jul 2019 12:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430333; cv=none; d=google.com; s=arc-20160816; b=zCypi4Y1pkCbrZDTwnzw6AS04dCopP2VJxO9hGhEnR7HRgnOzEFuc6bKtpQHEwU1wN FaL0XEYyOMPZZ73yJ9SPSvoLRmE0kKdf/GhgoD6igfDDOA3+g/VIO8hwUqYVI9zvLW/b 6PB0cNWkTaN7OS3OoEgX/1qSiLuALhZRJD3/bREoPmqDtnY0v5Tgs9INn+tf2UeaHsHc eV7bGcd0KtaEfCqK3hXZZwud48CgUxiORED+JYagOOhaZdAbZST2DHYUCur+AsiR+V/K FUa3HkKyx8NNowydYft1LXnBpZUUB3Gdpq74niFi9/WHjixsBxfqUisnqhhPYCCtjprJ IK5A== 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=1aSJdTfLmLV/1+FcnJQlB2Id1rAjsbcD2mPDHhJoyuQ=; b=CFq1goKDDj/9N2RnTX59rWoseNGzkRBCXDWG3ZRpK8+6qQwWngNKbFn7HJ6kYw4V6A M3ze3aEKRlBh5p8GG4ljuIj+ojiSurJ6sFlrws2Yu4HKPVczQw2ZbDJhFJir6ZSdt8qb 3Zs07x3U5BcIYPt1ouxICKOxNcFa/BEvLSCK8+Rz0Qj53wMn9KQGDNviBzXdqP1Dg3Ya XwclwkHWzq6TbAFxV+9f81yGPO0ngw3Gu8A8BwOQxHE4HGKdh+wWES33gN0IO25iJgpa U7U2KZ6gzVfqWMo61Hw8eS5vtdeAnfMpFxS8bZTIOXvjOhtU7koHtKUbNukluHD5ORlx b0YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=orRxnYmI; 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 32si28417594pgm.409.2019.07.29.12.58.37; Mon, 29 Jul 2019 12:58:53 -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=orRxnYmI; 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 S2404146AbfG2Ty7 (ORCPT + 99 others); Mon, 29 Jul 2019 15:54:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:47624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404134AbfG2Ty4 (ORCPT ); Mon, 29 Jul 2019 15:54:56 -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 AB0C7217F4; Mon, 29 Jul 2019 19:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564430095; bh=4OAOV4eLg5aS+22JvGjmkV/W14HiKNop4uNcdJS+FYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=orRxnYmIxq6eoXZoaWjOFanPmq1XlJbL/Y/kLNTpxCEAPsKVfKP+VF4k8c7/vukuO VaYDaUp4VKpZriFvRyrf93sB4akzKc8C/bpunOlfb2IErdDDVXPomxgq5IOxzuGU/f QubaHS6Lf9l/Gcc6tMdQf0LS5gxG+7mHE9vRoUNc= 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 158/215] proc: use down_read_killable mmap_sem for /proc/pid/pagemap Date: Mon, 29 Jul 2019 21:22:34 +0200 Message-Id: <20190729190807.218887608@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 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 4d9a8e72d91f..1d9c63cd8a3c 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1543,7 +1543,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