Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp343146yba; Wed, 15 May 2019 02:17:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/RpDEwNT50gz7SjHJADwpKArPAVh3HdW7rGVGeXO3WOr2uGC4aJiCMAWnnesIaLaU8Hrf X-Received: by 2002:aa7:810e:: with SMTP id b14mr46904882pfi.112.1557911878269; Wed, 15 May 2019 02:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557911878; cv=none; d=google.com; s=arc-20160816; b=uvYLnY+RzIcLGg/daoXCWaYwu8TXNOpoVXVVTdZZBkm/BdpOx0w/qJe8dg54I5iT51 TNxaBA7rNwyJ5vgoJnERQZkm6fd989ngSVT9KlHU9lYG4Yin99xet1/T1/HrimKW1kkb LVmuIb4/5lzM8Qfh5757ZX9G2Xw38j8l6awlCwpUWgh4xEjg0NDnTX+uMplAd4d7tFLw 0pN47SE0tu89sB1fiZI+DWuUT2E3DpUNKre1KiupFbqCndAN3ykjKWSeTNg8Kb0YvFeQ Omkasa5Y0UAIyMe2o3cm6ajFtdO1emcZvLSA3YaRKuMxMSB9bcDN66UDKbn3zeofST5S cCxw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=xFK3WFDRYBzxrq8yWCIlp7llC9R8MAhIqHXVBtxwgUY=; b=Eu3gpgBbLiKvjgkaFaAPxpoMxDt8IqI75OEzKD5hVhYEdG0wIV7uqrQI56u1W0fFMu 6qw/+f0APiB5WdBAFssorCqv1S1yyjCpax6Mf7ZIpBcHCblhKU+ev2KwAsb5LqRd3gbP 8yVEAcWoS/YILx6TRcNzxB2C6HIHf0zZ+Z/MsQjEzLtAEUYiQAZdVFp4EeeUNkqXYosr Qz0JhqlGpc9WhhCjKCYHRNfOztNCGhu2VhgmwPSxp9ZMCiV/L56URAYyU00NPL235vly 0gfxVtyRUOfeGx7W1DaCBJuf56AB7d1MSMEuTOcnPkfF7d2NJJlx+jlqHxXeKSv+EBuh smzw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u12si1360119pgj.145.2019.05.15.02.17.43; Wed, 15 May 2019 02:17:58 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726302AbfEOJQT (ORCPT + 99 others); Wed, 15 May 2019 05:16:19 -0400 Received: from relay.sw.ru ([185.231.240.75]:49850 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbfEOJQT (ORCPT ); Wed, 15 May 2019 05:16:19 -0400 Received: from [172.16.25.169] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hQq1H-00071z-GC; Wed, 15 May 2019 12:16:15 +0300 Subject: Re: [PATCH 1/5] proc: use down_read_killable for /proc/pid/maps To: Konstantin Khlebnikov , linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Cc: Cyrill Gorcunov , Al Viro References: <155790967258.1319.11531787078240675602.stgit@buzz> From: Kirill Tkhai Message-ID: <77650cec-70cc-149a-74e9-2256c6138032@virtuozzo.com> Date: Wed, 15 May 2019 12:16:14 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <155790967258.1319.11531787078240675602.stgit@buzz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15.05.2019 11:41, Konstantin Khlebnikov wrote: > Do not stuck forever if something wrong. > This function also used for /proc/pid/smaps. > > Signed-off-by: Konstantin Khlebnikov For the series: Reviewed-by: Kirill Tkhai > --- > fs/proc/task_mmu.c | 6 +++++- > fs/proc/task_nommu.c | 6 +++++- > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > index 01d4eb0e6bd1..2bf210229daf 100644 > --- a/fs/proc/task_mmu.c > +++ b/fs/proc/task_mmu.c > @@ -166,7 +166,11 @@ static void *m_start(struct seq_file *m, loff_t *ppos) > if (!mm || !mmget_not_zero(mm)) > return NULL; > > - down_read(&mm->mmap_sem); > + if (down_read_killable(&mm->mmap_sem)) { > + mmput(mm); > + return ERR_PTR(-EINTR); > + } > + > hold_task_mempolicy(priv); > priv->tail_vma = get_gate_vma(mm); > > diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c > index 36bf0f2e102e..7907e6419e57 100644 > --- a/fs/proc/task_nommu.c > +++ b/fs/proc/task_nommu.c > @@ -211,7 +211,11 @@ static void *m_start(struct seq_file *m, loff_t *pos) > if (!mm || !mmget_not_zero(mm)) > return NULL; > > - down_read(&mm->mmap_sem); > + if (down_read_killable(&mm->mmap_sem)) { > + mmput(mm); > + return ERR_PTR(-EINTR); > + } > + > /* start from the Nth VMA */ > for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) > if (n-- == 0)