From nobody Fri Jan 21 02:26:54 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 A5DC71968FA3; Fri, 21 Jan 2022 02:26:59 +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 4Jg3DJ64Snz4p5b; Fri, 21 Jan 2022 02:26:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642732017; 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=eqXGBYS9hVbL6Aa7qYxWmLj5JxloEqjU8cyAH3ezTBI=; b=B841TiOvKov822THXjL6fyD8lbVa4HpWalAOle+rL7YvfrQ9i7/tzXBXbkfdm1g28d95ze C//u2eR3l9pb2HFfj++Iqk3wWBjMS2feDpCp2nM2KPH0VMtyk0hm4mqJ5a1gDmKlKx0o5u upf80k1cjJKfU3uWsFNAK0iYQyOX9lNodoE7AtFjtWtkD1vAD/aZRRW13PfxAf3027fHkF j3u1ujXebuq7erkeS0krLwaNsB1OK+bNR1ngjthjScqT72uLpb3FNaCUnh1S/H3ZvI1K0f an/E7pxr6Kkevs6b55VBwbvT+Hjx81ubX1LTJCaaEqqo1DxqA2fk1l/IGAc5gA== 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 1774E13624; Fri, 21 Jan 2022 02:26:55 +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 20L2Qs04001282; Fri, 21 Jan 2022 02:26:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20L2Qslh001281; Fri, 21 Jan 2022 02:26:54 GMT (envelope-from git) Date: Fri, 21 Jan 2022 02:26:54 GMT Message-Id: <202201210226.20L2Qslh001281@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: 1397c8ebb7ef - stable/13 - nvme: Sanity check completion id 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: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1397c8ebb7ef4da83bd2d4fd3a2d4a7725075480 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642732017; 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=eqXGBYS9hVbL6Aa7qYxWmLj5JxloEqjU8cyAH3ezTBI=; b=tGS78hOPpXUc52tNpxswz13DUC+BXG1jTI6EpKKMK1bEX4GoAdNxvdHqd1Pxu7tT9VLVaf fORxhIAlZflopzJUfz/ls4zbtjAARbr8M3959EygQlzRGfdO2yQLnrbpUhX/e758LlH1P7 41sOCmCquBnDhXIYUjuhk+HYybFcpOwUT2qJXerKW0GB2i56JGEkHcLRr84QHn3Tnxp6+J lLd0hnDTJaLo1GD9h27YG3lSNUBQdmz8+2eoAyqQdBWP3IwwAzFjuf+2XDD49W5tJTPRXX XxVdM4JDwZHPNTzX8+N8Ms/icgeXh0GC3bIggMoMydiNvY1kr2gX1dRGomckXw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642732017; a=rsa-sha256; cv=none; b=nr9QMDtNU8l6RHFbwYqD1WEOOMPTBGh5Wlu6Io4Eil4zYO7qbuhXRhZMiyhpSkPo5LSIkc wyYiypXQhhMTgeCaEniFisM+XlGNtcRhz0gF7Wa4khUY1HMWo8pS1g1vZttVkuBdmNcpqp b8sOEO/8Y9vepml+IGmjBn/pNB6K+vVYUzrkXDnYxCa4ZQYLMpQmYAMMjwrR+/XSTlJYbX rxmWlHizmkpc2WKoOMfGAgtJP140c5UrGbsJC9bH4ioMQB7azM6vJrGrbG9hHeEF/kyhPv UUaJ4jgVBRufNAdaRh1tlLk+Bzy1TZhQ6iN3XnfjFfy1CqcLU8kmeJPunCXmow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=1397c8ebb7ef4da83bd2d4fd3a2d4a7725075480 commit 1397c8ebb7ef4da83bd2d4fd3a2d4a7725075480 Author: Warner Losh AuthorDate: 2021-09-29 03:21:50 +0000 Commit: Alexander Motin CommitDate: 2022-01-21 02:07:30 +0000 nvme: Sanity check completion id Make sure the completion ID is in the range of [0..num_trackers) since the values past the end of the act_tr array are never going to be valid trackers and will lead to pain and suffering if we try to dereference them to get the tracker or to set the tracker back to NULL as we complete the I/O. Sponsored by: Netflix Reviewed by: mav, chs, chuck Differential Revision: https://reviews.freebsd.org/D32088 (cherry picked from commit 36a87d0c6fe9d65de23f177ef84000b205f87e39) --- sys/dev/nvme/nvme_qpair.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c index 788322092f88..8041731099df 100644 --- a/sys/dev/nvme/nvme_qpair.c +++ b/sys/dev/nvme/nvme_qpair.c @@ -624,7 +624,10 @@ nvme_qpair_process_completions(struct nvme_qpair *qpair) NVME_STATUS_GET_P(status) == NVME_STATUS_GET_P(cpl.status), ("Phase unexpectedly inconsistent")); - tr = qpair->act_tr[cpl.cid]; + if (cpl.cid < qpair->num_trackers) + tr = qpair->act_tr[cpl.cid]; + else + tr = NULL; if (tr != NULL) { nvme_qpair_complete_tracker(tr, &cpl, ERROR_PRINT_ALL); @@ -644,7 +647,8 @@ nvme_qpair_process_completions(struct nvme_qpair *qpair) * ignore this condition because it's not unexpected. */ nvme_printf(qpair->ctrlr, - "cpl does not map to outstanding cmd\n"); + "cpl (cid = %u) does not map to outstanding cmd\n", + cpl.cid); /* nvme_dump_completion expects device endianess */ nvme_dump_completion(&qpair->cpl[qpair->cq_head]); KASSERT(0, ("received completion for unknown cmd"));