From nobody Thu Oct 17 16:10:11 2024 X-Original-To: dev-commits-src-main@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 4XTt8g6Pz3z5Z9Vj; Thu, 17 Oct 2024 16:10:11 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XTt8g5WP0z42HS; Thu, 17 Oct 2024 16:10:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729181411; 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=D0OyXrXc1+x31e2UBXP/fQdh0vP1Zl6bxzaopPNG4SQ=; b=TrxyKBALb1jiZaJvigyU9w4MR/TIHhori9cg1F4OYq5ag8qiZuOaHfU7BdC14LSOqmqX44 elXlEu2y7SBcBca0BhcJdDYAxiumjQeK57cUJJTcKyIs+MIhJdMOHR5CEH9JysPEWrsM/S JLCQ2wH6cAyXaoQFZChnhB8nR0pxSECFaAWA+T162g7ajTB80vVleTGpc/8B/IVPxW1RTk TGCcGGyYyiKNqePdNRJYbPlt5vgh3yTGPaTuqV716aYFaE1+f5OZZKqTUSUJ8KZcE+4KAn OqYdUfAebMTytibSzn0K0ssXeCEgXuAFfoUI9AcJ6Oy8wPVmad5DXKO3kweytQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729181411; 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=D0OyXrXc1+x31e2UBXP/fQdh0vP1Zl6bxzaopPNG4SQ=; b=XIrZF0vxpXorrR9ZSoy5YnNQgsvVbRnWxPnoNVPb/dRdcqMLP9GLNsq9N2vTeBOx0G0OTy k81BvFesuyiM3jofrqBmJb+aMOP6QpeQs0NqPcM+vZC1CkfMMbJHG3rQgEQGNuVwMRR8mI YCXYPUB3f8QdlLvv4e5YTM3kfcioKc+tARf3Ggcl4kfmDPu2ygW6yzLOEwsQZw8RBYjmuG KexbIYBMJt40sXAEcdH84b4HOq6fn5PwLPGjV2CPnvKOMFJcOQ8nUnNrfXlFO+PzBqD97/ RBpq4CZnGCQnFgV4epBXMbqYK3mOBb2YB7H3tICaUnt7cNRroZxOtUiBns3QjQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729181411; a=rsa-sha256; cv=none; b=c9UfCD4ur9M6RN1W3NOk8pC/OrY8wnDBjHkYtPDa1RVxc+64UeAkMPA8c5Xhho01xN5C++ HWCERPnqSSalpVIc60rfWDWlYNjsDLkAGKZSZWSj1ycRS+NQAz1WGyVeJXJ2Bphpbw5ky4 BlaQwCt9CUJfy+pBOFGGYVTL6LYi/1D+R/0uPIAKNs+IWxQv8OE+HpOHMnW5jQVivjI202 UCinaw8qOfEJKE/ufUl8QOPcNNbtqgGXI4Cgaz9FYtLBP66On77J1XcrvIe3EHoWGzixgt s1l4/wkibrI3DVOOwz07ZujXX/9jorlaEtXt5WNV1cU95vifQ2tmiwfyuRRKcA== 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 4XTt8g56ZfzwZF; Thu, 17 Oct 2024 16:10:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49HGABQO087571; Thu, 17 Oct 2024 16:10:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49HGAB2l087562; Thu, 17 Oct 2024 16:10:11 GMT (envelope-from git) Date: Thu, 17 Oct 2024 16:10:11 GMT Message-Id: <202410171610.49HGAB2l087562@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: d1516ec33e66 - main - nvmf: Fail pass through commands while a controller is not associated List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d1516ec33e6600f6aae3243119aeb14762dc9f97 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d1516ec33e6600f6aae3243119aeb14762dc9f97 commit d1516ec33e6600f6aae3243119aeb14762dc9f97 Author: John Baldwin AuthorDate: 2024-10-17 16:09:27 +0000 Commit: John Baldwin CommitDate: 2024-10-17 16:09:27 +0000 nvmf: Fail pass through commands while a controller is not associated Previously this just dereferenced NULL qp pointers and panicked. Instead, use a shared lock on the connection lock to protect access to the qp pointers and allocate a request. If the controller is not associated, fail the request with ECONNABORTED. Possibly this should be honoring kern.nvmf.fail_on_disconnection and block waiting for a reconnect request while disconnected if that tunable is false. Reported by: Suhas Lokesha Sponsored by: Chelsio Communications --- sys/dev/nvmf/host/nvmf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/dev/nvmf/host/nvmf.c b/sys/dev/nvmf/host/nvmf.c index 623c76954720..12023ebf96f9 100644 --- a/sys/dev/nvmf/host/nvmf.c +++ b/sys/dev/nvmf/host/nvmf.c @@ -972,12 +972,21 @@ nvmf_passthrough_cmd(struct nvmf_softc *sc, struct nvme_pt_command *pt, cmd.cdw14 = pt->cmd.cdw14; cmd.cdw15 = pt->cmd.cdw15; + sx_slock(&sc->connection_lock); + if (sc->admin == NULL || sc->detaching) { + device_printf(sc->dev, + "failed to send passthrough command\n"); + error = ECONNABORTED; + sx_sunlock(&sc->connection_lock); + goto error; + } if (admin) qp = sc->admin; else qp = nvmf_select_io_queue(sc); nvmf_status_init(&status); req = nvmf_allocate_request(qp, &cmd, nvmf_complete, &status, M_WAITOK); + sx_sunlock(&sc->connection_lock); if (req == NULL) { device_printf(sc->dev, "failed to send passthrough command\n"); error = ECONNABORTED;