From nobody Tue Jan 02 01:56:40 2024 X-Original-To: dev-commits-src-all@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 4T3wvD6GpKz55t7w; Tue, 2 Jan 2024 01:56:40 +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 4T3wvD5ZpWz4JgN; Tue, 2 Jan 2024 01:56:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704160600; 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=wmYbzJI1e8AmAZHBnh3EGyPwy+gAmNFpTIWxtUKctLQ=; b=UtesNd5ia8lGVZuOJshI5lvcCbwWpIi5chDIN1mFGzmskAdobqx/1nceBF5dcyg0yT1lg/ DCdsJiIe64GNaM7nzgItssM1cRoNX/rSCNAXdwwsztOPJOFmFZ7u20zus+a5Vr3iJXjaRZ sXUP2fbDH5MkTJu63eX3Tmj0cpzhCFmKDF0YJPgFvI7GfKYOburGkRHWgJqDl7lDkFgteS iuKcY5+C21XpWJAo8qe6+cfiIoODw12eLy/PXOY6jiHUuB6fUfkoI5Sa3ZLRhMTHRx/KlD vgvTCvGNbIvH39/MKHHltr2pr+ffGECvVdxVuztyCtIOTlNW8NZpCR4r7AMqEw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704160600; a=rsa-sha256; cv=none; b=YPA8ebUssxvLQgHS6Aoi2HlJ5U0Bn5w3C0NmICvOCrW08vMh91/gND9O+CYG3g/ry8JaE+ u3YpyDvt0+vNzxBXL2bzPeO0hvFCxFdgzCztoEbcqCUzoEQfloi5XIknaUgcMJ9l7B3gR+ tb9ulG7je6MCmauLfeYYPWYT7lm1ZAB6UvMbFqNygAlW/4BcPmVsKDRjTMAsSq0gOIMTAw ihzQgYXT3kDRBlZn6kYEfneYjwI/zvJJ5Du6onZKRiP4BmCPegkaP+ZeeLGYrwOkbCHsta AtAowDf4jyvxx36MvFQgR0JoQ4P1GNAjRtLoa7TZSYlZ3j3Czxlk8YmTW8iUlg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704160600; 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=wmYbzJI1e8AmAZHBnh3EGyPwy+gAmNFpTIWxtUKctLQ=; b=avcvPwVNx4PuckgMFOHtvYUdO4VmkTLjR1RSoSaO2YPTioBoDu57SRVURvsrfjyTBzf8en QzEV55+Sn2vm4Ku1YXdc3iCRcGh06aMz3ePezW69Qq13krPzW84S05ftUau5F2TI1kqstt 9APW7xLPfH+0kTxo8tkQ38szHjeRH9yhNW/WKvk/+HLt1kD+HfGFVdzDlYtGsJdBQXz++/ sVuIBkqydSOkLDh/qUE5vbf+EEnG5q/zEk7YbzrHfzzBzHEGLBOHlZt/WpyTzBchIGZtuq hbZJ3/U5asNCeVcZxV2LSt0nscpvGZj47zn8yLsHfKT9oiqe+5XOrMZIIOkzLQ== 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 4T3wvD4bkNzhgZ; Tue, 2 Jan 2024 01:56:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4021ueWc022933; Tue, 2 Jan 2024 01:56:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4021ueXj022931; Tue, 2 Jan 2024 01:56:40 GMT (envelope-from git) Date: Tue, 2 Jan 2024 01:56:40 GMT Message-Id: <202401020156.4021ueXj022931@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: 263ed87413ae - stable/12 - nfscl: Fix handling of expired Kerberos credentials (NFSv4.1/4.2) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/12 X-Git-Reftype: branch X-Git-Commit: 263ed87413aece1786df7275cc541dad324c76a5 Auto-Submitted: auto-generated The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=263ed87413aece1786df7275cc541dad324c76a5 commit 263ed87413aece1786df7275cc541dad324c76a5 Author: Rick Macklem AuthorDate: 2023-12-26 22:33:39 +0000 Commit: Rick Macklem CommitDate: 2024-01-02 01:55:14 +0000 nfscl: Fix handling of expired Kerberos credentials (NFSv4.1/4.2) If the NFS server detects that the Kerberos credentials provided by a NFSv4.1/4.2 mount using sec=krb5[ip] have expired, the NFS server replies with a krpc layer error of RPC_AUTHERROR. When this happened, the client erroneously left the NFSv4.1/4.2 session slot busy, so that it could not be used by other RPCs. If this happened for all session slots, the mount point would hang. This patch fixes the problem by releasing the session slot and resetting its sequence# upon receiving a RPC_AUTHERROR reply. This bug only affects NFSv4.1/4.2 mounts using sec=krb5[ip], but has existed since NFSv4.1 client support was added to FreeBSD. So, why has the bug remained undetected for so long? I cannot be sure, but I suspect that, often, the client detected the Kerberos credential expiration before attempting the RPC. For this case, the client would not do the RPC and, as such, there would be no busy session slot. Also, no hang would occur until all session slots are busied (64 for a FreeBSD client/server), so many cases of the bug probably went undetected? Also, use of sec=krb5[ip] mounts are not that common. PR: 275905 (cherry picked from commit a558130881e9d574dc5f37827fe2284667d5aba8) --- sys/fs/nfs/nfs_commonkrpc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index bc38f9aab6b1..3d6ea9efafd0 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -878,6 +878,22 @@ tryagain: } NFSINCRGLOBAL(nfsstatsv1.rpcinvalid); error = ENXIO; + } else if (stat == RPC_AUTHERROR) { + /* Check for a session slot that needs to be free'd. */ + if ((nd->nd_flag & (ND_NFSV41 | ND_HASSLOTID)) == + (ND_NFSV41 | ND_HASSLOTID) && nmp != NULL && + nd->nd_procnum != NFSPROC_NULL) { + /* + * This can occur when a Kerberos/RPCSEC_GSS session + * expires, due to TGT expiration. + * Free the slot, resetting the slot's sequence#. + */ + if (sep == NULL) + sep = nfsmnt_mdssession(nmp); + nfsv4_freeslot(sep, nd->nd_slotid, true); + } + NFSINCRGLOBAL(nfsstatsv1.rpcinvalid); + error = EACCES; } else { NFSINCRGLOBAL(nfsstatsv1.rpcinvalid); error = EACCES;