From nobody Thu Nov 2 23:36:18 2023 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 4SM0cz17zpz4yqHg; Thu, 2 Nov 2023 23:36:19 +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 4SM0cz0jkPz3HnH; Thu, 2 Nov 2023 23:36:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698968179; 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=9m7x9ss2tE73a3NwDGCit7OAjQfu3oTlM9JLrfCK8q8=; b=A5xORFAGDfdtLx1rlRzekpUU0YOMBBPm1k0nAbIVTe+ZdF57DzvjDZlwObIPxS/8OGz0M4 XO3yO4WRSY0XnC3KY1IoLDMOTF1DPbYTFvwNriOtNAEzKxWtz1hivI1dNYpZrX+RtMarpL ZEeQrV0EzOiHJmKYbUfnWXwdjTFb13prHZ9wyxX25AHMIhlQeeYJzijkQTfCa8ETgB+fX/ dAPH5fWHt63zQjG1BI0XKZpZZR9P8PHz1xce3jZAb8+GvycNWLK8GLhfh8m9J5p06EQ7Tn J674n9KERTNiPl7By5EpAYjfeqnetpkkatDF2WMwZ1xSUSRWXqebVBXUCQzbSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698968179; 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=9m7x9ss2tE73a3NwDGCit7OAjQfu3oTlM9JLrfCK8q8=; b=Jk1oFU0iqyB+ZKeDwtYPsXvT39oIn0b/MrEePzy3idFkhUyI/ylPFC7+9GXw3Va9+dQD9o 7ZI7vanWIMwQFek1kFdZjz79ebHdoMXoKI1IvIBTJ/P6E/lWpqegdy0jCw+HuMxZe9zt6Y cBhPKKjilMZ7LaHnp9QtVk8xkUouM7GF8DPo3ZR+zGOT98nqtiQPeQOriiN8CuWExxayn7 +6MnGp9l2OtfXcwjPBDDeMKXVTZJQ/Q5YuwSu5AYfaRXt5zXuqLTelntkj37SslJ8yZiql GHsKVrI56Nnp92cji+yOsOH84GJI3q2bVgRarwKF3chstGkOnsD7OGbGocTmXA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698968179; a=rsa-sha256; cv=none; b=U5gen7zQCR3iPJgc5KPXVx4oKQYTSbIoThuYSZ0ncZBfo0mQ2HREuWkcGAzKuXsWN5uLDV Elm2yf/+MkZ9ygAKJjK2sLF1zXPcYjJ3RYofm5ifNg6RKYLbJdJ8+NSg106Fos3rt/YXDM hj4QqHQOFh/2Kdb29pw0bzj6wdwWBzPWgDc3XEAZkA3tEqjT8YqcPoD4tcPn/BvyizJ1ZV hAtzHoK9IP9qVW7xuxYjpIG8Nvqmrb8KwUEjhi1A/dMnEqBUjsYmWcs0SrWM4F/cfl+6ZE 0A/7lhGK0nEgMBjbeuIQtukB+sPNmx5YLI9DZzR2BgdPpYABnvpaxH8yLDygNg== 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 4SM0cy6w4tzpXk; Thu, 2 Nov 2023 23:36:18 +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 3A2NaIS3029073; Thu, 2 Nov 2023 23:36:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A2NaIID029070; Thu, 2 Nov 2023 23:36:18 GMT (envelope-from git) Date: Thu, 2 Nov 2023 23:36:18 GMT Message-Id: <202311022336.3A2NaIID029070@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: 18d51c3c305f - stable/13 - nfsd: Fix a server crash 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: 18d51c3c305f233a75fc64f8e5711306dd05a8fc Auto-Submitted: auto-generated The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=18d51c3c305f233a75fc64f8e5711306dd05a8fc commit 18d51c3c305f233a75fc64f8e5711306dd05a8fc Author: Rick Macklem AuthorDate: 2023-10-18 02:40:23 +0000 Commit: Rick Macklem CommitDate: 2023-11-02 23:35:25 +0000 nfsd: Fix a server crash PR#274346 reports a crash which appears to be caused by a NULL default session being destroyed. This patch should avoid the crash. PR: 274346 (cherry picked from commit db7257ef972ed75e33929d39fd791d3699b53c63) --- sys/fs/nfs/nfs_commonkrpc.c | 9 +++++++++ sys/fs/nfs/nfs_commonsubs.c | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index 936373c79366..29c7cdbd671c 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -1208,6 +1208,14 @@ tryagain: NFSCL_DEBUG(1, "Got badsession\n"); NFSLOCKCLSTATE(); NFSLOCKMNT(nmp); + if (TAILQ_EMPTY(&nmp->nm_sess)) { + NFSUNLOCKMNT(nmp); + NFSUNLOCKCLSTATE(); + printf("If server has not rebooted, " + "check NFS clients for unique " + "/etc/hostid's\n"); + goto out; + } sep = NFSMNT_MDSSESSION(nmp); if (bcmp(sep->nfsess_sessionid, nd->nd_sequence, NFSX_V4SESSIONID) == 0) { @@ -1388,6 +1396,7 @@ tryagain: nd->nd_repstat = NFSERR_STALEDONTRECOVER; } } +out: #ifdef KDTRACE_HOOKS if (nmp != NULL && dtrace_nfscl_nfs234_done_probe != NULL) { diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index 44cddc6d5b34..a9659079ed5f 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -5083,11 +5083,13 @@ nfsrpc_destroysession(struct nfsmount *nmp, struct nfsclsession *tsep, struct nfsrv_descript *nd = &nfsd; int error; + if (tsep == NULL) + tsep = nfsmnt_mdssession(nmp); + if (tsep == NULL) + return (0); nfscl_reqstart(nd, NFSPROC_DESTROYSESSION, nmp, NULL, 0, NULL, NULL, 0, 0, NULL); NFSM_BUILD(tl, uint32_t *, NFSX_V4SESSIONID); - if (tsep == NULL) - tsep = nfsmnt_mdssession(nmp); bcopy(tsep->nfsess_sessionid, tl, NFSX_V4SESSIONID); nd->nd_flag |= ND_USEGSSNAME; error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,