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=-6.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS 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 42090C43381 for ; Fri, 29 Mar 2019 16:44:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EDB1218A3 for ; Fri, 29 Mar 2019 16:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553877866; bh=cFuRMaqf6lMmt4L96nHUqyvF1yNua4z08EQCL5Q2fnw=; h=Subject:To:Cc:From:Date:List-ID:From; b=u6QY1OLiJ93uUOVfu1WsiTThC77hxiLcZUdVPRu4zyaSTBVUNYr3ETAKsymvRCpQs SOUrrYx8xZ2SgUwOEebb/8cWz8bGFKh+ydA6OBl9Tk6p+0yETk1DwTqp/wwAlLwNIC 8Rcxey+MfzAIKsV6KHSyin8PdEUeZjPY3sWcE6oA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729746AbfC2QoZ (ORCPT ); Fri, 29 Mar 2019 12:44:25 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:44785 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729150AbfC2QoZ (ORCPT ); Fri, 29 Mar 2019 12:44:25 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 6507E21D3C; Fri, 29 Mar 2019 12:44:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 29 Mar 2019 12:44:24 -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=F2qcP0 N9MtYjLUrMIRkAT4C2Q/tmEc8FEVbB6DEJIkc=; b=58PNEUyV2vKN0GmcNfI/2J WtFcpYe0ujWOeWO7IbwWvN9G1/+hcFew4GXUcHYcAtNXkjKwqwJqb22Ixcgnqrt3 ZDhJZypeGNuDJQrqLVzAK8eDWLW2CZ2F2mkeDN7al1kJsvGNiGBuUb7bI4894u5L GiYjkXoj+6qO8zMwCL+q7lMlRJWdyl2ORtuhuypuGWnJaHzDrGAd6fcdAqvYOGGP IheiSXlTAG/FwcSiSiF0kUcdgWpIZUYDMaQwqDi16TIQvW6owctrbPQjYJJ8wlsB c+ga/tAQbsVUPR4hi4TygSb4I53VvfIHsghiNecenrEO0jBNHv2usW3BKRRGoWoA == 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 C99CE10394; Fri, 29 Mar 2019 12:44:23 -0400 (EDT) Subject: FAILED: patch "[PATCH] NFS: fix mount/umount race in nlmclnt." failed to apply to 4.9-stable tree To: neilb@suse.com, trond.myklebust@hammerspace.com Cc: From: Date: Fri, 29 Mar 2019 17:44:20 +0100 Message-ID: <1553877860195158@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.9-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); }