Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6210290ybv; Tue, 18 Feb 2020 12:05:40 -0800 (PST) X-Google-Smtp-Source: APXvYqzMQpEmEc1Y9itg+/3BamwwpnlNtu8taCZ3RY6+yn1a/2CH3LlAWqk2JLGDdCAkgaRX31v3 X-Received: by 2002:a05:6830:1251:: with SMTP id s17mr14711061otp.108.1582056340073; Tue, 18 Feb 2020 12:05:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582056340; cv=none; d=google.com; s=arc-20160816; b=DV6TieDjpntxwkDH9+YdYXm74Mt3oiKZqx+KQjpGS5/whhgSyLKxsfjkggDI5jlRZL 2fVfZ866MorSMIEbg7YBti/Z2J2Ywiirv/Q3NBAE0aMfmbPQGxacErkkU2myyg62hp0l jSo4yuNEgeVZAFD9HDbjkA51iV2ozyDCt+x2BuYOzVJy/YRqGSKDhpI4gtwFAQbRiCA7 zrWK/wVDuDcC3uiAmOuzmV7CzxHUwATikKapVCqZp3/a0AwH9x80JRPkZngXBiGuRq83 SbS9sXch0PUF/qhh1rfjsyeXHpglwLyS/eHxyCuN9RLdEzrOL0QiFvAoSuuHQz6q5EqS 8cYw== 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=nV7OOouazPPJFMKBzs0YAVr13YpSQ98RJCeCzRQfaPU=; b=uryG3lldKU3vuSLy5ca9XVCfX2KKuKZ5fBgaGB9OzZFewocoyIrrem6ans9hDHgGLL tD4u1Ql9YQlQGKYlePaM09m3WDW0TV6PzsU/DfDYEsqA3r+s+O1VNmbbZxMDcf9A5xQE rhmsvR6WTQkRksmz78qYW5RItiYMSvGyGLzdX6atp1y/YOuymN6wRa0TjwG8XG1TCEdr CfRqK0lkPkEzT7udaB+TnvdalkzzYbSDjI8a3kJ/ETppksfU5iZd7lCK+gDC+8rRAeiM +II7Gh91TdTjqcdXOlUeK/nKy08pIto8maWzadBY86xdjtSXYjbi/C5oBd0wTlJWaOtz UwCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I44bABFx; 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 d14si179586ote.195.2020.02.18.12.05.28; Tue, 18 Feb 2020 12:05:40 -0800 (PST) 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=I44bABFx; 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 S1728995AbgBRUEV (ORCPT + 99 others); Tue, 18 Feb 2020 15:04:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:45014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729128AbgBRUDj (ORCPT ); Tue, 18 Feb 2020 15:03:39 -0500 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 CA9F124125; Tue, 18 Feb 2020 20:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582056219; bh=oM3IV5POdbjJh4hmqvmev7NnW2IKj0WapaGYhE37NXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I44bABFxPW1nHxB42MkNi28bcrHulEeB1KcL2645bci7H/e+l8u67OOYyNWBdoB9r A/y5TrkSz6QowNq89ElHQ2Cu5kw8Yf91n+ci9Jn5YmCSgKyk0A/8fgORbmCCQ4QTBH p9g+NPWB8z5CLO7U+O6S3Q3DIddy/d/NoKiS7gSE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Anna Schumaker Subject: [PATCH 5.5 73/80] NFSv4: Ensure the delegation cred is pinned when we call delegreturn Date: Tue, 18 Feb 2020 20:55:34 +0100 Message-Id: <20200218190438.811033255@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200218190432.043414522@linuxfoundation.org> References: <20200218190432.043414522@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 From: Trond Myklebust commit 5d63944f8206a80636ae8cb4b9107d3b49f43d37 upstream. Ensure we don't release the delegation cred during the call to nfs4_proc_delegreturn(). Fixes: ee05f456772d ("NFSv4: Fix races between open and delegreturn") Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker Signed-off-by: Greg Kroah-Hartman --- fs/nfs/delegation.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -222,13 +222,18 @@ void nfs_inode_reclaim_delegation(struct static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync) { + const struct cred *cred; int res = 0; - if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) - res = nfs4_proc_delegreturn(inode, - delegation->cred, + if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { + spin_lock(&delegation->lock); + cred = get_cred(delegation->cred); + spin_unlock(&delegation->lock); + res = nfs4_proc_delegreturn(inode, cred, &delegation->stateid, issync); + put_cred(cred); + } return res; }