From patchwork Wed May 15 08:41:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 10944411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B98376 for ; Wed, 15 May 2019 08:41:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BC1928A22 for ; Wed, 15 May 2019 08:41:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F386228A27; Wed, 15 May 2019 08:41:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B96928A22 for ; Wed, 15 May 2019 08:41:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6FF36B000D; Wed, 15 May 2019 04:41:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B1FEE6B000E; Wed, 15 May 2019 04:41:15 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C0F26B0010; Wed, 15 May 2019 04:41:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by kanga.kvack.org (Postfix) with ESMTP id 357226B000D for ; Wed, 15 May 2019 04:41:15 -0400 (EDT) Received: by mail-lf1-f69.google.com with SMTP id v136so432806lfa.3 for ; Wed, 15 May 2019 01:41:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:user-agent:mime-version:content-transfer-encoding; bh=on37xMtDHf4i5spIW0sgEiVZh+kGUSg0VAm5Sv46Das=; b=iXPPlJN539idl5ggRQfdQlUrvls7zPq2mZ4U/UsPBKgcDy2dmdiYob0gwf6K6Ae4Du YZb578D/P2hcq1YlsgxgxHe0Nu3Lqo4UuJxJE9wDSdUsuIgiuZQi0sGru4hpIfXn89UA nQbh0WfMEAdMgRqTqqpwjU2lK8rjAmNGSaERrj1F1YD5P6ADKgcuH3rdmUgmDy6UO92n X9pJGrei7cOHYQ5w6DNFVaEnZ5/Zfuy5xR7g1eGapFIajLV0fHspV0GW5f+lfyUbxup9 CzLCWSNPpKvquo9o40eSIrhPmVkA+l1CuRYykYW7un4vsJvzYYvfMAEmDpcB9lMFNyC8 zT3Q== X-Gm-Message-State: APjAAAWTyjgh3jjoPZxrUgxCcaMY/Kmcs4jSeKN92ehp2+HUygV6zbYS gnmW892tTc2963J9KgcWif6TilOXyqGv8wjnxYyE3xVU849aIkVtoAv+Nu8WM34cENl83QQb/4v aABHjOwLyzY6aAZHLJ+bZe/cILfJSyPi21NkDmGUlNtFxZWm0/qJqkIf9iIrq8M7Stw== X-Received: by 2002:a2e:8796:: with SMTP id n22mr7297016lji.75.1557909674679; Wed, 15 May 2019 01:41:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkbDJRr8vZfaKipfaeMo4VIFC+JhTOjLGZX4usy4KShRCZVVyUtluxGQ+qWIKcOqbKjr1C X-Received: by 2002:a2e:8796:: with SMTP id n22mr7296980lji.75.1557909673843; Wed, 15 May 2019 01:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557909673; cv=none; d=google.com; s=arc-20160816; b=fAkbbfw2WyTNevyqflXhEJyFRIH3xKh9pLpEqDyr74sByC6D5/rWACi8VYApagMugP repvkqTI2rAyee7H2uXCqr2soKZKWADILz4kGKZEBQBGVLqBYQgVqU+SQOOixJ5p0dKL C4H4XMR86eRz9uW/w1qLCb2QFXCilpcUjS0F204zqx8FULSTh1VdpXCh1UyE/iDkxMzX OMjBn0CcrTdPWYYLygnEuf6aWGZP5Y6Lr1DWUj8PwCag2u7DZ0uBoftcdt57qkY3mnsg AvJNzpxHhGBvCHZRrbf/0eHR9BVQ394IliZ5BVjQUXlH0mfS+vy4VM/8YScw842OcavT X0NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:message-id:date :cc:to:from:subject:dkim-signature; bh=on37xMtDHf4i5spIW0sgEiVZh+kGUSg0VAm5Sv46Das=; b=ehIDNmZ/jRUqgN7Mtiv2Gpf5Nzpd9ST8+/oJrIlcz8w2h6OdzRWSmejksDs/E24VNG jR8PsV3IBCt9rOOnS9FNIzrL3ltclzMvRnbpn0WnQVqez7+pVUrGMZ8uzGdVyvURRAN/ eVdIvWY30nK/iHe7mbkW83mL5EaREq8Czf6qLJkcDH+PL7jwCAgsAfG9qB1OqAlHc7gI jANWbQBr5cSLJhHJuqTBk4rndJwwu7XlzriGoCMNH2MEjUDGKLaxqs9VEd4tFxdl9LWo cz6uWGdJXoOwtZ/XxJMad/lE/HpH4M9rZSa1SwOVEgEappJm8UaKqGAqD+Jzo3+Rb+3A /HvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=bJzcjZX6; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 5.45.199.163 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from forwardcorp1j.mail.yandex.net (forwardcorp1j.mail.yandex.net. [5.45.199.163]) by mx.google.com with ESMTP id v7si1003096lje.199.2019.05.15.01.41.13 for ; Wed, 15 May 2019 01:41:13 -0700 (PDT) Received-SPF: pass (google.com: domain of khlebnikov@yandex-team.ru designates 5.45.199.163 as permitted sender) client-ip=5.45.199.163; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=bJzcjZX6; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 5.45.199.163 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id 917962E14C0; Wed, 15 May 2019 11:41:13 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 7l8bZ6vz9S-fD0GwFgT; Wed, 15 May 2019 11:41:13 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1557909673; bh=on37xMtDHf4i5spIW0sgEiVZh+kGUSg0VAm5Sv46Das=; h=Message-ID:Date:To:From:Subject:Cc; b=bJzcjZX6IIAUCNZqdyJas7Z7fGK9P92gcfgKNFGVYrbxnXDJ17C82J8LRWdyyAtHl EqAUj/W8BAy4Hpaw7JwRetWb/oFU2VFVtGgph3dPKN16Nxj069xSvJi4qjWeh07zl9 r+h/pSCIwWSvsMqVdHCAPlw4g0drkv+mbzc+HnWY= Authentication-Results: mxbackcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:ed19:3833:7ce1:2324]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id dM2CepgjQa-fC8SnGfC; Wed, 15 May 2019 11:41:12 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: [PATCH 1/5] proc: use down_read_killable for /proc/pid/maps From: Konstantin Khlebnikov To: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Cc: Cyrill Gorcunov , Kirill Tkhai , Al Viro Date: Wed, 15 May 2019 11:41:12 +0300 Message-ID: <155790967258.1319.11531787078240675602.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Do not stuck forever if something wrong. This function also used for /proc/pid/smaps. Signed-off-by: Konstantin Khlebnikov Reviewed-by: Cyrill Gorcunov Reviewed-by: Kirill Tkhai Acked-by: Michal Hocko --- 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) From patchwork Wed May 15 08:41:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 10944413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79F4176 for ; Wed, 15 May 2019 08:41:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68BE528A26 for ; Wed, 15 May 2019 08:41:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D2B028A28; Wed, 15 May 2019 08:41:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE62228A26 for ; Wed, 15 May 2019 08:41:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF12E6B000E; Wed, 15 May 2019 04:41:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E7B266B0010; Wed, 15 May 2019 04:41:23 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6A1D6B0266; Wed, 15 May 2019 04:41:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by kanga.kvack.org (Postfix) with ESMTP id 73BCC6B000E for ; Wed, 15 May 2019 04:41:23 -0400 (EDT) Received: by mail-lj1-f200.google.com with SMTP id e9so295609ljk.0 for ; Wed, 15 May 2019 01:41:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=wvnT3PULz7mp/5rmrkYmIaE3b+NEu8QwgpbJMZv7HlI=; b=oRP7GiUvNcFxPAOXBydE8BZ16vtyJLd8N9DEjk44DZwWWIUEhYeL3EzETV78ScafWT EJfA8LP1wUgXUbLgpifnF8xcNMEMIeNSY515Sw6Uq8mH+S8jMkwvFjVHOdznKF2IIzlF 9Ze+Z2Ud4Bj/tLDGeOAHf/pYZ1sSEWjNDIu+qY/fJzlxbHSnry88PufrHLi0UxGy/F3W 8onfd8/a2av7zYCKKlUGWsz5rgFX5NdkUdkGf5w0GCS7Lk3zTC3vX4LDN2C2hBZ+RzL0 hpKxLrza45/BVSDkHcqwDDhTrMH8IAJIuzmPplBCb0SCdJsJ26tij9VawKTDeHs3esef memw== X-Gm-Message-State: APjAAAXLpEnyMJoBjhFLRG21w9Tp7B1Gew4xKO6OQrljbQkez3oEFBwb LRBgc6PhGIxdt4VXeB0mCVOqqU9HRXCa1KV98WemSW5WXUD8EIqDR/yxkFY+tx0zfcGlWPSyMnr 3m8BvmSk9k4QJbGmy9IDD2Fm8Xe31uoU4gjfjYOwojOm/XzxnqE+fgmFlWpDoT3OoNg== X-Received: by 2002:a19:3f4f:: with SMTP id m76mr19264633lfa.17.1557909682876; Wed, 15 May 2019 01:41:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoC0G2lIh1YBMGsVGpHtZ9llMyVmM7XSEypG9o4OGenbnh3PQ29vERITiMKwpQHn1Ix1MM X-Received: by 2002:a19:3f4f:: with SMTP id m76mr19264484lfa.17.1557909679557; Wed, 15 May 2019 01:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557909679; cv=none; d=google.com; s=arc-20160816; b=kxzt6/jImy+Tdw1QIlBuGwk6vf5oU+qB9AylYAIRMkVBy7HzQFu9GyXgzVn0Jwk/aF 69ll9K8D31ewXENFKd+TkLRDtnQMBaLbLtmrqtP3q9RR5a9FHv9UOPB+ZrFBc7a2Xt8E YKSkcm3hXOHzBAy5BXC4bnwkR9y5GQ4ceKrvyEJ4YVDijVVzJ7kKMkKN9I/m1AqQ/yMm ZCb3EzBlpvwHS4dhkcTOaYI7ec2OK5pFOKqU8X4lWIh4i+tJ4c96QjQ2YroS96wF/Eb/ 6TQDMvxrRDo5Gx2SI8RJdumMnsEW4/rEXv92wOsgTxZjcZ2Wt7QCYqhbp9PrQIS3C9wf /4VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=wvnT3PULz7mp/5rmrkYmIaE3b+NEu8QwgpbJMZv7HlI=; b=Vz/4cxOie6Gc9T2U30ui0eGzQt+QiDca9Bsy9QpwOwl3WbWPzUsVIznydFGBna2YmK wduHqxI/JoeH1nf/2DTZUKTVCh56+c987mCUo5zauePUOmkJu0c9nm0TS5KpVPhS+I5c Hn6KIP2XXySjGnaDfzgAv2tbkmqPjrdCG5y2xvzYCB2fSvY9r0jelT5YkXF8/F3gF9rQ 1MPjov6A512yonoPlgCElXXG7Fo8nZQxXGquZLV/p2rUgqvEIvgNp/S53g18aN15dXiC ndyGGq0vUG7/le2SWbMLBkLee4Q5i7M2OCR7xGZuiiqBdYghGevxv9ktE88wI/1nmVT6 W0GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=YMkmG2co; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1a2d::193 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from forwardcorp1o.mail.yandex.net (forwardcorp1o.mail.yandex.net. [2a02:6b8:0:1a2d::193]) by mx.google.com with ESMTP id s18si1088955lji.90.2019.05.15.01.41.18 for ; Wed, 15 May 2019 01:41:19 -0700 (PDT) Received-SPF: pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1a2d::193 as permitted sender) client-ip=2a02:6b8:0:1a2d::193; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=YMkmG2co; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1a2d::193 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from mxbackcorp1j.mail.yandex.net (mxbackcorp1j.mail.yandex.net [IPv6:2a02:6b8:0:1619::162]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id 8563F2E1468; Wed, 15 May 2019 11:41:18 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id fGJe6SgsV0-fFwWAmiP; Wed, 15 May 2019 11:41:18 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1557909678; bh=wvnT3PULz7mp/5rmrkYmIaE3b+NEu8QwgpbJMZv7HlI=; h=In-Reply-To:Message-ID:References:Date:To:From:Subject:Cc; b=YMkmG2cooQOcVa0FiLi1MVU1FVZP2M+lDPTbbBlfsbr/FOwm+nsx7EqzTFFcRvWSV ynbQAZnHcsQr4l4bHuiiUQdiV8Qpzg/7Z4sn6TGToJpcCwe8vR6+QmRClEcwZYE5Cy MR1+Ep1QcQMZHH8y12Gc3P/spGChKkSK/vgqVCm8= Authentication-Results: mxbackcorp1j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:ed19:3833:7ce1:2324]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id GTPPl6MHyV-fF8GxvWP; Wed, 15 May 2019 11:41:15 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: [PATCH 2/5] proc: use down_read_killable for /proc/pid/smaps_rollup From: Konstantin Khlebnikov To: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Cc: Cyrill Gorcunov , Kirill Tkhai , Al Viro Date: Wed, 15 May 2019 11:41:14 +0300 Message-ID: <155790967469.1319.14744588086607025680.stgit@buzz> In-Reply-To: <155790967258.1319.11531787078240675602.stgit@buzz> References: <155790967258.1319.11531787078240675602.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Ditto. Signed-off-by: Konstantin Khlebnikov --- 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 2bf210229daf..781879a91e3b 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -832,7 +832,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) { @@ -849,8 +852,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; From patchwork Wed May 15 08:41:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 10944415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF0CC912 for ; Wed, 15 May 2019 08:41:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF49828A22 for ; Wed, 15 May 2019 08:41:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0F8728A27; Wed, 15 May 2019 08:41:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C64328A22 for ; Wed, 15 May 2019 08:41:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63FE06B0010; Wed, 15 May 2019 04:41:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5CC156B0269; Wed, 15 May 2019 04:41:25 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F5346B026A; Wed, 15 May 2019 04:41:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by kanga.kvack.org (Postfix) with ESMTP id CF9446B0010 for ; Wed, 15 May 2019 04:41:24 -0400 (EDT) Received: by mail-lf1-f71.google.com with SMTP id e11so429247lfn.19 for ; Wed, 15 May 2019 01:41:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=8cD7osAd7wj30fMNGC0J8IUxkft7sVoc3Ldv03Ms9+A=; b=scsdRM/Y9FiKE2JQeYBZ+GuEmFYAlY+HQ6TZmNvvNhmjodnR+7oy2SHLxo4DgbeFOB K8VVzVCy3k/7To1YpiNY6C5UfdB+uqMiXkwsp6kr4aTn8arhrBkxzCvqo2jXQjcX+Ak9 mDmN13Ytali0W4XJIhC+VTVNQ05/OQ9E2RBTdjydfq6yxJVoeW4YK6KtFpw/f2bIgOKB 1JBOsjrvUMllasoiVjoZEh+Nn7uHDtkfqVDq4J6/uj9T6EGky35PwOBXZpHxTf6e1Nco me1+mnPrKkK8H9oRVSI0MV2WH5msgHotmp3ceD2NXQTvBX3xK626HFUrz6PV+G9piYSM 8kCA== X-Gm-Message-State: APjAAAWKRL4Oi/UzGkEr8eVEVREd/jyTFQB+TY5ituOgrCWYPepzhiYP iqAePSJ+HkRmRjX82aAwpX4QmE2e9CYdMkWUz1s5SiA8srS7wRuUtydhicbzNnB1KSZ9+M8hsUM fa4hQkyplLxdI4gW9tdx1PQsEJD9CLuXrhVJPNTq788jP1nEisOnuMacYC/rMHuTazw== X-Received: by 2002:a2e:81d0:: with SMTP id s16mr19412506ljg.145.1557909684311; Wed, 15 May 2019 01:41:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwV8eB280JuE68VZOHDUxRSe2SGCINz9ipF6pZNECnyno88M77vu2OAae/qsa6Wg7zoOSk7 X-Received: by 2002:a2e:81d0:: with SMTP id s16mr19412470ljg.145.1557909683427; Wed, 15 May 2019 01:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557909683; cv=none; d=google.com; s=arc-20160816; b=M034JK6RSJCMUSQwg+Bb0b2oFsRSJj1vZyhoPF+wLncO12UGUSqEzHnbTd6PHluevK e0rnxeXWZryTMJelDLZr33Ou4TD9qnCI6STLzj1ZJFg58yOiY5OLpSW8x5cIFN7gJm13 OQqIOF0DbgjmaaxuI5wxfut1q+40xeNPLb+2paSh3tLEEBLku6FbY1CCTFuNwqJOXJX6 /CDLFVV5QnZEbZZtWbjlBoy+ThvFsSiIyjas1aavn3YUVt/TJnLjRKhhoo774ogq3F01 dh6DQ32A6tmGR4tJwdQ7hb/n2covW2lLIZUG34n2jZVkaOxrhjf+IbAuz8x4vmUpOiz+ +NCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=8cD7osAd7wj30fMNGC0J8IUxkft7sVoc3Ldv03Ms9+A=; b=ZEmbz9zCQpy82pHEEQ28FVq8UvyDaB1ojNUZ9xkNsPMAz4sYWCoOv5V3xw0CY94fYg uz+JCITFzVLtVXRGqEfQurxpVCfUA8ZxrFfm2AWqGLzYV8IIAOwFzjFurhM+TXjX/7E4 +d81SLwCLDYxjVcQzCwvQjK+SCqppMq9Su0VO/kLKaprIh/98p8eupFVeiT8PVa5gl1I QCtrD04j4H95w+rXvQqVa44mMXDFG1lZVbkKNBF6cqv4Mkexev0p1vOS1HAf09y+r8gr vhW4g6YeJAbOl/RuqQD6QLdD4E0G1f3mGuhLNywE5/ilY7xBLLWWD/m6CoPpRdTuW0do 0krg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=C1Gdt9q6; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 77.88.29.217 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from forwardcorp1p.mail.yandex.net (forwardcorp1p.mail.yandex.net. [77.88.29.217]) by mx.google.com with ESMTP id u26si1153536lfd.24.2019.05.15.01.41.20 for ; Wed, 15 May 2019 01:41:23 -0700 (PDT) Received-SPF: pass (google.com: domain of khlebnikov@yandex-team.ru designates 77.88.29.217 as permitted sender) client-ip=77.88.29.217; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=C1Gdt9q6; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 77.88.29.217 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from mxbackcorp1g.mail.yandex.net (mxbackcorp1g.mail.yandex.net [IPv6:2a02:6b8:0:1402::301]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 6C13C2E1471; Wed, 15 May 2019 11:41:20 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp1g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id BfmpUuiCqw-fJsqIJcU; Wed, 15 May 2019 11:41:20 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1557909680; bh=8cD7osAd7wj30fMNGC0J8IUxkft7sVoc3Ldv03Ms9+A=; h=In-Reply-To:Message-ID:References:Date:To:From:Subject:Cc; b=C1Gdt9q6DvCWb8OHGL64+FSDhO+5tEwZKryiXKS18mzixvKGghDJYSKH81UNviwME /A8Dn06dQrccwq2bJFh3nZ73zV9z8LI08I/MXXklUY/i+rbKyZhgGvpGXVLvHuXr+7 LIqC9GlgTCkLXk02BEAVj9Z0aXmjiJCTOfL0nNVM= Authentication-Results: mxbackcorp1g.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:ed19:3833:7ce1:2324]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ImDQZhn1h5-fJ84Bnif; Wed, 15 May 2019 11:41:19 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: [PATCH 3/5] proc: use down_read_killable for /proc/pid/pagemap From: Konstantin Khlebnikov To: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Cc: Cyrill Gorcunov , Kirill Tkhai , Al Viro Date: Wed, 15 May 2019 11:41:19 +0300 Message-ID: <155790967960.1319.6040190052682812218.stgit@buzz> In-Reply-To: <155790967258.1319.11531787078240675602.stgit@buzz> References: <155790967258.1319.11531787078240675602.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Ditto. Signed-off-by: Konstantin Khlebnikov --- 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 781879a91e3b..78bed6adc62d 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1547,7 +1547,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; From patchwork Wed May 15 08:41:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 10944417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2375D912 for ; Wed, 15 May 2019 08:41:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 140D628A22 for ; Wed, 15 May 2019 08:41:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08A5428A27; Wed, 15 May 2019 08:41:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA32228A22 for ; Wed, 15 May 2019 08:41:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE5146B0266; Wed, 15 May 2019 04:41:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B95516B0269; Wed, 15 May 2019 04:41:25 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C2F66B026A; Wed, 15 May 2019 04:41:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by kanga.kvack.org (Postfix) with ESMTP id 1987D6B0266 for ; Wed, 15 May 2019 04:41:25 -0400 (EDT) Received: by mail-lf1-f70.google.com with SMTP id 17so432417lfr.14 for ; Wed, 15 May 2019 01:41:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=DXKTyv1Zt0cbjxS03oPn1lBJLs878fkqtHSHT6TGUvY=; b=eL7MZ7LBZYyjNt3lHWhwFWFao99PbTCnPHVdCqrnyWf/6I9HflP2kO9Nr2BIZmbgRN x0+fZW4VHvmHWSR+MPPgwfZGro67NLF0OcKcztE3uqEyZwyrpexdAUH36jEJUEjr7QST t9Au2kln4Gbh2ZYMEygXrwAPEpCgy3yGGJ7bdyfzqvnqhkBoDcDEumo1k59AOaLwlv53 iMCzuAJdIW/JCPcF6Tnw62S3m2GM3tX83FjZm4v11ED86lsVRL2jmhyJ8Vcjg0Kj5UAe qvM04FWraKwOZJnva7iLRbgpHw0xljQxXBGz0/O1JgSL/0nkhjGmpqWaZd2Vil5/j9tR 2lsQ== X-Gm-Message-State: APjAAAUt7QnZMWj+AS+7yTgYEw+gx60ynJeOfX+NNaKck5p9SBnOOy++ Oc2VEtyxSRW2C6DDvj5XU5269PAB0qoo5PSBTrwlvZ186mH7bb28KTQSa24yttcRzNUScfDuSD3 GaoI3yYkeE3BsqUPy2KB8F/vPiHDjwLxnECgc4ixGWBOv6oEkHCQaj/evdLvMeCacpw== X-Received: by 2002:a2e:7f13:: with SMTP id a19mr19572942ljd.35.1557909684560; Wed, 15 May 2019 01:41:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5RQt8XzHJldgerEhqKGBPr7MVyaexmrIQPq87mcm5M6O4EEl2wihM84+Kn9wkDqrDkm+j X-Received: by 2002:a2e:7f13:: with SMTP id a19mr19572866ljd.35.1557909682676; Wed, 15 May 2019 01:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557909682; cv=none; d=google.com; s=arc-20160816; b=ojakKdS5ORJpReWxTiBmVtiq7YLdvIuvaSAPseHlV5MFkobHg4XWAdmht3AO/MHFCF 6/O9HPAec+E/hrmfPVzNxikPTc3R9kxExz0IAJnljj/jC8QZwgy5SutaL8sZJvYs2Mgg 7FYxyMJbTbI0H1i0GEPQhje/MKdZuSAAg/a390lGBFwZno/5l8B1sowi6avyv4UkuVUt 7K2KGdw5Vl9PvuURZC2PND6thKTZfKHgSy7cgGQM5BlWohfKWiZ77RfcavE5ora8WhyF 4OmC2lpqQezrWzimnTnpTEKiNKglAPZ7K27aCPzJ5+zkmUnZhN6Ay6bsjtvtyN8ufoNJ RjCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=DXKTyv1Zt0cbjxS03oPn1lBJLs878fkqtHSHT6TGUvY=; b=r2L+cgnsx21jefXbc0Q/MszzoWV3TqI8Nh9A0KMIHEtppM16Ke9+0R6dsTdRRj2k5m e1wcxWIdj6jqMLUVMdu21jnxyaMwiJrlLYlqSnj7LSghaSPRCD93wgqaGwXWxkvFKrlB x+nU9+2aO6qjYD7sozObEFTJN4E1ILx6OZxoOJHaI0TZdyHL9vytE0N9u/J3isouf7Li NNl1GxKaCK6TUSIm2P+riS7uFbkJfo0sUjl7d1u8EtWjTvT8AZ5BPwj0Cg64HEph8aKn tByni6UIyvBOqcyUKBsBxCvNk4S26G02mMvu0SGipeeio31BZknvVMsRbJfhVZIoEK7S I6xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=aNjr5SR1; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1472:2741:0:8b6:217 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from forwardcorp1p.mail.yandex.net (forwardcorp1p.mail.yandex.net. [2a02:6b8:0:1472:2741:0:8b6:217]) by mx.google.com with ESMTP id h25si940565ljk.170.2019.05.15.01.41.22 for ; Wed, 15 May 2019 01:41:22 -0700 (PDT) Received-SPF: pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1472:2741:0:8b6:217 as permitted sender) client-ip=2a02:6b8:0:1472:2741:0:8b6:217; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=aNjr5SR1; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1472:2741:0:8b6:217 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 658F52E146D; Wed, 15 May 2019 11:41:22 +0300 (MSK) Received: from smtpcorp1o.mail.yandex.net (smtpcorp1o.mail.yandex.net [2a02:6b8:0:1a2d::30]) by mxbackcorp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 9zoT92Owie-fL0uKV6u; Wed, 15 May 2019 11:41:22 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1557909682; bh=DXKTyv1Zt0cbjxS03oPn1lBJLs878fkqtHSHT6TGUvY=; h=In-Reply-To:Message-ID:References:Date:To:From:Subject:Cc; b=aNjr5SR1VzkHw+xEMkDZjfNamwaILWaRolaTmyWU5+xXDFs9RbvV8LmC1+fXO4YCP dm2PkDwHYBgEKcdaXOl1syN8qZ/el2BXO6s9Bno/cJUjP8agzdxS8NqjpxZqkvdF5P GFMlg9fUgmB31B3VVcLdRfMkfsf1X2zY9luH43kk= Authentication-Results: mxbackcorp2j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:ed19:3833:7ce1:2324]) by smtpcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id wNdlQeZj5Y-fLl0uD8T; Wed, 15 May 2019 11:41:21 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: [PATCH 4/5] proc: use down_read_killable for /proc/pid/clear_refs From: Konstantin Khlebnikov To: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Cc: Cyrill Gorcunov , Kirill Tkhai , Al Viro Date: Wed, 15 May 2019 11:41:21 +0300 Message-ID: <155790968147.1319.10247444846354273332.stgit@buzz> In-Reply-To: <155790967258.1319.11531787078240675602.stgit@buzz> References: <155790967258.1319.11531787078240675602.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Replace the only unkillable mmap_sem lock in clear_refs_write. Signed-off-by: Konstantin Khlebnikov --- fs/proc/task_mmu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 78bed6adc62d..7f84d1477b5b 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1140,7 +1140,10 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, goto out_mm; } - down_read(&mm->mmap_sem); + if (down_read_killable(&mm->mmap_sem)) { + count = -EINTR; + goto out_mm; + } tlb_gather_mmu(&tlb, mm, 0, -1); if (type == CLEAR_REFS_SOFT_DIRTY) { for (vma = mm->mmap; vma; vma = vma->vm_next) { From patchwork Wed May 15 08:41:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 10944419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BB5F76 for ; Wed, 15 May 2019 08:41:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A5A228A22 for ; Wed, 15 May 2019 08:41:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EFFC28A27; Wed, 15 May 2019 08:41:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00B7A28A22 for ; Wed, 15 May 2019 08:41:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 977666B0269; Wed, 15 May 2019 04:41:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8D8666B026A; Wed, 15 May 2019 04:41:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 707036B026B; Wed, 15 May 2019 04:41:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by kanga.kvack.org (Postfix) with ESMTP id 02DA36B0269 for ; Wed, 15 May 2019 04:41:26 -0400 (EDT) Received: by mail-lj1-f198.google.com with SMTP id n14so286359ljj.19 for ; Wed, 15 May 2019 01:41:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=EuTSakk/W384FbrZL7W4VmC2fzsD5CQ2PPKONFosPBE=; b=ke2sqOugiqAR2RveYuhVJS+sovOuxOpvzWvQLajLTaZtFKMZNaKkvijjhlYMrWpf5I W9reF+OZ3aS9DKW9D5qf58uIXMXIuuoUPeUtDqRtSiCZ7AeTW/8E1K6XX7UTZ1YYZXxy Rre4Yt7+K2opnY1wiy3JCbm9uhccDJEert5u3mnLbHcCAywoz3AszzxlNHy2l96owgMJ NuO59QKzuqdao4pRQ39S67mEGbB8/4iLafiv+WuVAi9PZSVCrLdte5YR3FVr1jifg3H3 6rsMTRdwS9c58EAJqgX7+bOIDDXPe5rbZO6rz4QweVPi9W8elZTRoghBCWohEaCgv10C 2a0Q== X-Gm-Message-State: APjAAAU2mdA4ckujtjc491D0x+IPBQNsBapl5hH0E4BwxVJZwIw5CKXQ P2SQ28WvmAG+WM9AW+eWZgENcu3XvIu4BB6G6qukQA6WWpUYxPCh4sm5lQAfowfnpjluxeSsohU hCZlrGWhT3YQWJFLvgmk4p0vXj/kimBVKirvGKzaGsibYreYguiqrADQ/KYFfcdi8nA== X-Received: by 2002:a2e:5501:: with SMTP id j1mr19181833ljb.58.1557909685439; Wed, 15 May 2019 01:41:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdABT+ga57UnGnytI798wJkRDk2+1BcLRldkCWEcFb/I3goGkB9lk9H6jGJ1avulbK/v/T X-Received: by 2002:a2e:5501:: with SMTP id j1mr19181787ljb.58.1557909684301; Wed, 15 May 2019 01:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557909684; cv=none; d=google.com; s=arc-20160816; b=GFBwnv0dVOBEoxNmw9WccUkPQe/R1QHw50fpAULyuDkxgdo2WcVygBlCps+Wnocd/O O/jKxRucKCajMTOEP7L9yo0beE1rMH6nQkuPGMdRN2l7h3z2WYHx+qdTFx7LoNnzX9pO HtpKDVHB/coGzNKwJK4h4TF3by+me8md0THtvpHhB/9znR4bA4yZFt/SuFWw1rxxw8PS WPnB3Y8ycjzhgK+dgLL09RMO4cER7ndHJZh1kqpJszt0jVNUk45JlgVTnMFejLQY/cTH QnRLG07miFBXlmM4sXGAKpV+ORwW+aQEKpENyDaXk08eAbfMv+AJYRTz3bJ+vLAiXmLs rcIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=EuTSakk/W384FbrZL7W4VmC2fzsD5CQ2PPKONFosPBE=; b=qwNQwUmM36azDYVU0hWf+u3zSn23VAE7RWu34jXXFDtUTUrio1SwlYFe3JEwgUuCJD eSd6XkUQTOLiyeu9+xGa2lLgQRBHrsBY6C0agsuqBmT6yaLZSPBP0qxa9Pl11C37MKYD d06y/ZbJ1cWjgTj9IIOWQu6l9zP/OCOqmxeoKyIS1QFWsGBvCfOww9vB22hA5Cqoh8Ah lTOLuUPrr7OstGBISBXu8oNjbIOiu0A0hQRBrQ0G5FiXLG3eRrwlLhN2DzBb5EuI/aTS VVfQQNgOBHm3HnftB7PYpHc0nzlvchFt0pEpNMODE+u/lcD97ASa8am8XKgLMmvJIdef 7PQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=oDzJ6O4C; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1472:2741:0:8b6:217 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from forwardcorp1p.mail.yandex.net (forwardcorp1p.mail.yandex.net. [2a02:6b8:0:1472:2741:0:8b6:217]) by mx.google.com with ESMTP id g2si1052134lja.128.2019.05.15.01.41.24 for ; Wed, 15 May 2019 01:41:24 -0700 (PDT) Received-SPF: pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1472:2741:0:8b6:217 as permitted sender) client-ip=2a02:6b8:0:1472:2741:0:8b6:217; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=oDzJ6O4C; spf=pass (google.com: domain of khlebnikov@yandex-team.ru designates 2a02:6b8:0:1472:2741:0:8b6:217 as permitted sender) smtp.mailfrom=khlebnikov@yandex-team.ru; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: from mxbackcorp1j.mail.yandex.net (mxbackcorp1j.mail.yandex.net [IPv6:2a02:6b8:0:1619::162]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 0AE4C2E1474; Wed, 15 May 2019 11:41:24 +0300 (MSK) Received: from smtpcorp1o.mail.yandex.net (smtpcorp1o.mail.yandex.net [2a02:6b8:0:1a2d::30]) by mxbackcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id EhUVTWkR5e-fNwi2wOO; Wed, 15 May 2019 11:41:24 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1557909684; bh=EuTSakk/W384FbrZL7W4VmC2fzsD5CQ2PPKONFosPBE=; h=In-Reply-To:Message-ID:References:Date:To:From:Subject:Cc; b=oDzJ6O4CIEQs5Ah2zbLrIQXVVTPf+lFiG0PinmnSVMh6ZGcHdOxvsjtOSKXzQl05R WRiJfug3aYbM0VoEz3ChYfL2j4NwD+PRPmdHi4I2w5h0T489aSzr+2jzVFeIZpvTPB WGdE7tWY9YJtH3HEBz2ssD0/jwALsw4gByyBquLM= Authentication-Results: mxbackcorp1j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:ed19:3833:7ce1:2324]) by smtpcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id qWdnaWaYI8-fNlaNIYK; Wed, 15 May 2019 11:41:23 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: [PATCH 5/5] proc: use down_read_killable for /proc/pid/map_files From: Konstantin Khlebnikov To: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Cc: Cyrill Gorcunov , Kirill Tkhai , Al Viro Date: Wed, 15 May 2019 11:41:23 +0300 Message-ID: <155790968346.1319.5754627575519802426.stgit@buzz> In-Reply-To: <155790967258.1319.11531787078240675602.stgit@buzz> References: <155790967258.1319.11531787078240675602.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP It seems ->d_revalidate() could return any error (except ECHILD) to abort validation and pass error as result of lookup sequence. Signed-off-by: Konstantin Khlebnikov Reviewed-by: Roman Gushchin --- fs/proc/base.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 9c8ca6cd3ce4..515ab29c2adf 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1962,9 +1962,12 @@ static int map_files_d_revalidate(struct dentry *dentry, unsigned int flags) goto out; if (!dname_to_vma_addr(dentry, &vm_start, &vm_end)) { - down_read(&mm->mmap_sem); - exact_vma_exists = !!find_exact_vma(mm, vm_start, vm_end); - up_read(&mm->mmap_sem); + status = down_read_killable(&mm->mmap_sem); + if (!status) { + exact_vma_exists = !!find_exact_vma(mm, vm_start, + vm_end); + up_read(&mm->mmap_sem); + } } mmput(mm); @@ -2010,8 +2013,11 @@ static int map_files_get_link(struct dentry *dentry, struct path *path) if (rc) goto out_mmput; + rc = down_read_killable(&mm->mmap_sem); + if (rc) + goto out_mmput; + rc = -ENOENT; - down_read(&mm->mmap_sem); vma = find_exact_vma(mm, vm_start, vm_end); if (vma && vma->vm_file) { *path = vma->vm_file->f_path; @@ -2107,7 +2113,10 @@ static struct dentry *proc_map_files_lookup(struct inode *dir, if (!mm) goto out_put_task; - down_read(&mm->mmap_sem); + result = ERR_PTR(-EINTR); + if (down_read_killable(&mm->mmap_sem)) + goto out_put_mm; + vma = find_exact_vma(mm, vm_start, vm_end); if (!vma) goto out_no_vma; @@ -2118,6 +2127,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir, out_no_vma: up_read(&mm->mmap_sem); +out_put_mm: mmput(mm); out_put_task: put_task_struct(task); @@ -2160,7 +2170,12 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) mm = get_task_mm(task); if (!mm) goto out_put_task; - down_read(&mm->mmap_sem); + + ret = down_read_killable(&mm->mmap_sem); + if (ret) { + mmput(mm); + goto out_put_task; + } nr_files = 0;