Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp913900ybv; Thu, 13 Feb 2020 11:56:25 -0800 (PST) X-Google-Smtp-Source: APXvYqwqsToKe9DPQ51UeyGdIHAFrzef09UewLbOZmVJz64Ca+5iL7KwaW0UPMqqw39F6/Z/cnhw X-Received: by 2002:aca:5ad5:: with SMTP id o204mr3931873oib.2.1581623785599; Thu, 13 Feb 2020 11:56:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581623785; cv=none; d=google.com; s=arc-20160816; b=OA7Y8++y1SscnxjL1iEL+/Jn1MqHpbiNWu2tERZGvb6HCDdQ/FR1ujk4p6MzQp/Vne OuxUkV5m63lbFpW75C27weym3mpm0lxk0KQntIrAcikLxgBX8yBA+M9H8MLsnGpl6a4U CiF8jmKES/v63jZ0+KbOW79n/HydOPV8UOWNJFXK3BQhmWFGtht+M9+VT1MAGeDGM+P3 PVxi9zieRW/ZZ3UCUpOiZH9cFsSzJcQ69yct7yvewisTyNx5BPBQzJRaQo97unFG+LOL h4RoYL2D20ap+ZFNKqGvUWZPPbIhBgeYF9UBtRU65c0yTJmLLcUK6MWXyfJJ/t0rUxVS KCbQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=seh5qGjdxQldQv3GyysssxDRYieEulLBJZF91+Ccaoc=; b=fyjdET/tDJHtbsXaqOGMdpwZhbtGAlTyKivJlpvF6pUAJ3tKU6XTEExyXDQV9iJkQ9 R0HPzy+jWDPybzYfttgChUDl9dnvgYXhEJZ5zTLOz+/ByBnFhZXnOZgaYgCR3WwUqfu0 ZPH58+dnv2Qvt6CBXrQCfN6eH8iV2IAhOohU5cpjNcdJWCw1FGDQFEDLs+NXodQywOJ7 CZPnTqFXcTVAluczkTBCpdcCovpHKu03FApYFkBaRkICz2tKAy6kSrUilpjk1Fbp1A98 j/l8aE/4DBrb3IYWhznBQXOcs4ixaTNlda79Pe43EGnhGlR9NIU2Ys4j7obZX0jPyCb5 RNgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JQiuV0p6; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si1550209otn.122.2020.02.13.11.56.05; Thu, 13 Feb 2020 11:56:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-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=@gmail.com header.s=20161025 header.b=JQiuV0p6; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727720AbgBMTxS (ORCPT + 99 others); Thu, 13 Feb 2020 14:53:18 -0500 Received: from mail-yb1-f193.google.com ([209.85.219.193]:41730 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727797AbgBMTxS (ORCPT ); Thu, 13 Feb 2020 14:53:18 -0500 Received: by mail-yb1-f193.google.com with SMTP id j11so3567145ybt.8 for ; Thu, 13 Feb 2020 11:53:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=seh5qGjdxQldQv3GyysssxDRYieEulLBJZF91+Ccaoc=; b=JQiuV0p6Inrdzs/gGVOdHBTypkMAXZcUwO9oadcy3l0KNpkEJiUkNsDzSFAPYYGL/K vF9WMeVtzQzYayTe68LiJig0OBKaLO8BzTz33ENm0WRLcAcsCwZIL6wjMP7+uTD0DseQ GtJFZHT4kzOxddFRNyN23JuH1PyGJq0njg9TxCNiQTVZXuNFJvf5OT4PtLaixvhm17/X uX0lbfELSx/zttpQKF3D9dVIMHpDDViuwWN9XLiMRgZyZUo2g7raqo55HHr6nRe7YGhd fFVfbQMUndj7sBZwZ9wOuqDeJgjLSnzdC5Mp7XSIsP1OLgIlkzK4vmKYeG6xOJc5v3LL w0Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=seh5qGjdxQldQv3GyysssxDRYieEulLBJZF91+Ccaoc=; b=BotfQyjYbyg2RJvsSDTxJ8TpdfgroZEC+sdiswBfnBop7uVMnBVAFZuLHkxpCmRgOb +UEdfAuxwh5YVECCSJGwthxBvOC8wKn2F7F0QvN48zSjo47jjG5BvaM+IhxNiDSsIfWx yS3XasfJq5kHl0zBFIwbZR9cx78dykGBSm/TGTQVPvi4YVJGVMDBjMNIxCH+R+V6WAO4 hSxWw/InEJ9Hob4OEWxSJvGvvd9kcHydrhYXl3gh141h7t5r9+Zmk+T9KQoGsVNkg7Q4 vCcqg1MXZpJbOCO94uOxmEX1Obr7fd6ovGE1dMyc4wupVjvB/vtV4fZNHfcAdHWFTiKj p4sg== X-Gm-Message-State: APjAAAU9//gn2fYoxq0sFygjTxPNARJ5SODPc0Ex3uej97X1hrjgEaNT 35jwoT2gLcAudra4lQpgmA== X-Received: by 2002:a25:99c3:: with SMTP id q3mr9113641ybo.323.1581623597352; Thu, 13 Feb 2020 11:53:17 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id l202sm1560717ywb.89.2020.02.13.11.53.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2020 11:53:16 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/2] NFSv4: Ensure the delegation cred is pinned when we call delegreturn Date: Thu, 13 Feb 2020 14:51:07 -0500 Message-Id: <20200213195107.10095-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200213195107.10095-1-trond.myklebust@hammerspace.com> References: <20200213195107.10095-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 --- fs/nfs/delegation.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index c17ff826e7e9..1865322de142 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -255,13 +255,18 @@ void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, 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; } -- 2.24.1