From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 353E3C4360F for ; Fri, 29 Mar 2019 16:44:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03565218A3 for ; Fri, 29 Mar 2019 16:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553877868; bh=PIZrth+R4ECqiuR0na0Q3JpmxoLtRgCJImBQmkWDYak=; h=Subject:To:Cc:From:Date:List-ID:From; b=o3fRoYk+ojeW/k6gclIZ5P0O1pn40tbdQpACO22ed7aV/ZKCTpwR0niqmhpc2hQ3V CqwJcQRNMScrqJsCTtYrIHsjtvT7hx8RQ5WunkdW8mZwxqF9n6s8CkEb/Z13eox1R1 ruc+D4s+wWer9ucal/plAXa5rKvI6Q8YkomceX+Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729748AbfC2Qo1 (ORCPT ); Fri, 29 Mar 2019 12:44:27 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:48809 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729150AbfC2Qo1 (ORCPT ); Fri, 29 Mar 2019 12:44:27 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 44AB122086; Fri, 29 Mar 2019 12:44:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 29 Mar 2019 12:44:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=5ijX22 2x/uO9J0Oe4hfExFzt9hpuVVn7EPT194JuNYc=; b=OumWEImZQJYQAEFBE46ti8 97FDxR75X0xeA40x8ysZLuq0Lr6sXlII1SH14isNBwKhszk+z0CofDZNwLbR5MnS jHXKKTVfMK6D24V2Ph854F5k+SkPiXo7Y7JOkd5dJgXjV1puuhUa5JgwMaW6K7AN S11h7e35R1yfVw6jvfFBRbLD7A8NFw2xqRfONWw4Rb7tKTyk/fyEtjFZjcM1TDhq bk9dRtLdm1TrgxsgbpII2f7jjIUPUyA9qEY5KB9ltAtAISPAfWubXTmeOE+0mhF0 iRjD7lrVYlp/efLq5Lh7DEbp+oXKT4FW5hm7eAdvVNu8+9SQIYQanLxUZDx4OATQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrkeejgdeihecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvhfffkfggtgfgsehtkeertddttd flnecuhfhrohhmpeeoghhrvghgkhhhsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhg qeenucfkphepkeefrdekiedrkeelrddutdejnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hgrhgvgheskhhrohgrhhdrtghomhenucevlhhushhtvghrufhiiigvpeef X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id B764BE49DD; Fri, 29 Mar 2019 12:44:25 -0400 (EDT) Subject: FAILED: patch "[PATCH] NFS: fix mount/umount race in nlmclnt." failed to apply to 4.4-stable tree To: neilb@suse.com, trond.myklebust@hammerspace.com Cc: From: Date: Fri, 29 Mar 2019 17:44:21 +0100 Message-ID: <155387786123871@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.4-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 4a9be28c45bf02fa0436808bb6c0baeba30e120e Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 19 Mar 2019 11:33:24 +1100 Subject: [PATCH] NFS: fix mount/umount race in nlmclnt. If the last NFSv3 unmount from a given host races with a mount from the same host, we can destroy an nlm_host that is still in use. Specifically nlmclnt_lookup_host() can increment h_count on an nlm_host that nlmclnt_release_host() has just successfully called refcount_dec_and_test() on. Once nlmclnt_lookup_host() drops the mutex, nlm_destroy_host_lock() will be called to destroy the nlmclnt which is now in use again. The cause of the problem is that the dec_and_test happens outside the locked region. This is easily fixed by using refcount_dec_and_mutex_lock(). Fixes: 8ea6ecc8b075 ("lockd: Create client-side nlm_host cache") Cc: stable@vger.kernel.org (v2.6.38+) Signed-off-by: NeilBrown Signed-off-by: Trond Myklebust diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 93fb7cf0b92b..f0b5c987d6ae 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -290,12 +290,11 @@ void nlmclnt_release_host(struct nlm_host *host) WARN_ON_ONCE(host->h_server); - if (refcount_dec_and_test(&host->h_count)) { + if (refcount_dec_and_mutex_lock(&host->h_count, &nlm_host_mutex)) { WARN_ON_ONCE(!list_empty(&host->h_lockowners)); WARN_ON_ONCE(!list_empty(&host->h_granted)); WARN_ON_ONCE(!list_empty(&host->h_reclaim)); - mutex_lock(&nlm_host_mutex); nlm_destroy_host_locked(host); mutex_unlock(&nlm_host_mutex); }