From nobody Tue May 17 20:42:12 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 482651AE3DDD; Tue, 17 May 2022 20:42:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L2p2Y1Sh4z4ZyM; Tue, 17 May 2022 20:42:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652820133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zmq87VpaSSWM4hOanm0bP5RHqX2oOJ40pdkwTbMswxE=; b=TpniGl12UjpVa9iS0L/T5nlq2E4TViC6jVuBzzN9udIChXvzromvf+F4SsBu8Qnis38nNA mwLnoJNVJ3RK6SJdtadYo6URsvT3fbzy0e8BISFZu8QzeMy2aRD1gEwzWSWrHkxVphHiGL A8xl4xZpVqZQRW4vFSQCd9KIaBUqpnJiWMy3IjmVoi8g0cORokQCZs/2uGRxlHTOgOdDJ7 OZbWogHkc/B2zbgbuGDrdo9dBscHTt6cazf1pFdQcvfCfRLhmbbzx/co9rzrFD7sXCQa3o +zWBSVFRdfv1YRfipZaxcLR75bq5893UdeUlkDh5tC/KuhT/mOskQG4cYE553A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 135391BDCE; Tue, 17 May 2022 20:42:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24HKgCEs078337; Tue, 17 May 2022 20:42:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24HKgCOq078336; Tue, 17 May 2022 20:42:12 GMT (envelope-from git) Date: Tue, 17 May 2022 20:42:12 GMT Message-Id: <202205172042.24HKgCOq078336@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 3c6bc3e9664a - stable/13 - nfscl: Acquire a refcount on "cred" for mirrored pNFS RPCs List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3c6bc3e9664a9ece9e92115aed5087dc1c25fc34 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652820133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zmq87VpaSSWM4hOanm0bP5RHqX2oOJ40pdkwTbMswxE=; b=mQbbQj8+vN6db6nk9JzV8wCKpL5SfntKfaOkQcNCb20y8FSocxym9UIv8qYT8L5EpPBWvS YW7/DhYlvHKFhJma+3QaUltmqmnr78w+Kh/PpKKuTzzqub5/rVs9LHoc15oE+lfr5nHhm1 OVl8qBvd6w+rMgunstugAR3pHmkF1yBnd0mGhWcO40Bf/kd0BKu4AcYq/WHjpr5V6KxJW3 8HwcHy/aBnnrvl+g4mlg0retJ0W7Zt4bsjbgetTB42JmVVuOJ3chmmZAb3T3ZX/uo/JDSu CtWh02eSUKYe7gRCE7MtwKyFXPTkfvss5/oL5GowzzfUQE9R/DTPceGj2k7BaQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652820133; a=rsa-sha256; cv=none; b=VjnuHEx47aryt4SbQAOextpI8GHEFq3kXsw+FpZQDXSPJP+xrRu0GuSlsGHm/f1x6Uv8T3 g6+jJKm75VYEVQ6ZwhyCpWBdpegif8EqcSxxYK3CjdlrAkLnenywDGI2GdQ5JblwQUZkSn 5LgBRtlhLPBUsbOjwPG/q28LJYxkFpLclfqe39gE/QFFrhV+oLjOgKpJOjWjajoy/mzSH1 6tSzURSsLd3CcsENH2qmZEtAC3oNGCW/vpP48dMpT0/wMsodnFmmx9oyf+BZPzJ0pZK6eo lLqAXetu9BDxFVHYG7uzi3nAxBo47GrFY3NxgKFSV3yoik5/Wg219UEoy4bFDQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=3c6bc3e9664a9ece9e92115aed5087dc1c25fc34 commit 3c6bc3e9664a9ece9e92115aed5087dc1c25fc34 Author: Rick Macklem AuthorDate: 2022-05-03 14:22:15 +0000 Commit: Rick Macklem CommitDate: 2022-05-17 20:39:49 +0000 nfscl: Acquire a refcount on "cred" for mirrored pNFS RPCs When the NFSv4.1/4.2 client is doing a pnfs mount to mirrored DS(s), asynchronous threads are used to do the RPCs against the DS(s) concurrently. If a DS is slow to reply, it is possible for the "cred" to be free'd before the asynchronous thread is done with it, causing a panic/crash. This patch fixes the problem by acquiring a refcount on the "cred" while it is being used by the asynchronous thread for a DS RPC. This bug was found during a recent IETF NFSv4 testing event. This bug only affects "pnfs" mounts to mirrored pNFS servers. (cherry picked from commit 70910e4b55ca976ca0ad4aa3e34252ba148a6126) --- sys/fs/nfsclient/nfs_clrpcops.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 9922cf00d464..149b57e49fb7 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -6723,6 +6723,7 @@ start_writedsmir(void *arg, int pending) drpc->fhp, drpc->m, drpc->vers, drpc->minorvers, drpc->cred, drpc->p); drpc->done = 1; + crfree(drpc->cred); NFSCL_DEBUG(4, "start_writedsmir: err=%d\n", drpc->err); } @@ -6750,7 +6751,7 @@ nfsio_writedsmir(vnode_t vp, int *iomode, int *must_commit, drpc->m = m; drpc->vers = vers; drpc->minorvers = minorvers; - drpc->cred = cred; + drpc->cred = crhold(cred); drpc->p = p; drpc->inprog = 0; ret = EIO; @@ -6758,9 +6759,11 @@ nfsio_writedsmir(vnode_t vp, int *iomode, int *must_commit, ret = nfs_pnfsio(start_writedsmir, drpc); NFSCL_DEBUG(4, "nfsio_writedsmir: nfs_pnfsio=%d\n", ret); } - if (ret != 0) + if (ret != 0) { error = nfsrpc_writedsmir(vp, iomode, &drpc->must_commit, stateidp, dsp, off, len, fhp, m, vers, minorvers, cred, p); + crfree(drpc->cred); + } NFSCL_DEBUG(4, "nfsio_writedsmir: error=%d\n", error); return (error); } @@ -6908,6 +6911,7 @@ start_commitds(void *arg, int pending) drpc->dsp, drpc->fhp, drpc->vers, drpc->minorvers, drpc->cred, drpc->p); drpc->done = 1; + crfree(drpc->cred); NFSCL_DEBUG(4, "start_commitds: err=%d\n", drpc->err); } @@ -6930,7 +6934,7 @@ nfsio_commitds(vnode_t vp, uint64_t offset, int cnt, struct nfsclds *dsp, drpc->fhp = fhp; drpc->vers = vers; drpc->minorvers = minorvers; - drpc->cred = cred; + drpc->cred = crhold(cred); drpc->p = p; drpc->inprog = 0; ret = EIO; @@ -6938,9 +6942,11 @@ nfsio_commitds(vnode_t vp, uint64_t offset, int cnt, struct nfsclds *dsp, ret = nfs_pnfsio(start_commitds, drpc); NFSCL_DEBUG(4, "nfsio_commitds: nfs_pnfsio=%d\n", ret); } - if (ret != 0) + if (ret != 0) { error = nfsrpc_commitds(vp, offset, cnt, dsp, fhp, vers, minorvers, cred, p); + crfree(drpc->cred); + } NFSCL_DEBUG(4, "nfsio_commitds: error=%d\n", error); return (error); } @@ -7047,11 +7053,12 @@ start_adviseds(void *arg, int pending) drpc->advise, drpc->dsp, drpc->fhp, drpc->vers, drpc->minorvers, drpc->cred, drpc->p); drpc->done = 1; + crfree(drpc->cred); NFSCL_DEBUG(4, "start_adviseds: err=%d\n", drpc->err); } /* - * Set up the commit DS mirror call for the pNFS I/O thread. + * Set up the advise DS mirror call for the pNFS I/O thread. */ static int nfsio_adviseds(vnode_t vp, uint64_t offset, int cnt, int advise, @@ -7070,7 +7077,7 @@ nfsio_adviseds(vnode_t vp, uint64_t offset, int cnt, int advise, drpc->fhp = fhp; drpc->vers = vers; drpc->minorvers = minorvers; - drpc->cred = cred; + drpc->cred = crhold(cred); drpc->p = p; drpc->inprog = 0; ret = EIO; @@ -7078,9 +7085,11 @@ nfsio_adviseds(vnode_t vp, uint64_t offset, int cnt, int advise, ret = nfs_pnfsio(start_adviseds, drpc); NFSCL_DEBUG(4, "nfsio_adviseds: nfs_pnfsio=%d\n", ret); } - if (ret != 0) + if (ret != 0) { error = nfsrpc_adviseds(vp, offset, cnt, advise, dsp, fhp, vers, minorvers, cred, p); + crfree(drpc->cred); + } NFSCL_DEBUG(4, "nfsio_adviseds: error=%d\n", error); return (error); }