From nobody Fri Dec 17 10:03:47 2021 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 6377A18F73CF; Fri, 17 Dec 2021 10:03:48 +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 4JFl1b6dRbz3sqP; Fri, 17 Dec 2021 10:03:47 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AD6B619675; Fri, 17 Dec 2021 10:03:47 +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 1BHA3lNp051914; Fri, 17 Dec 2021 10:03:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BHA3lt6051913; Fri, 17 Dec 2021 10:03:47 GMT (envelope-from git) Date: Fri, 17 Dec 2021 10:03:47 GMT Message-Id: <202112171003.1BHA3lt6051913@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ram Kishore Vegesna Subject: git: fa3e66e9f7cd - stable/12 - ocs_fc: Fix use after free bug in ocs_hw_async_call() 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: ram X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: fa3e66e9f7cd903050454fc284e2709a9e28e651 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639735428; 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=AszDwJUKdSX1VbRAY7QmoID05rvDDhZA+LF3fb40vFs=; b=mhN7xaLCsqoIaaoZwVch4ZIZk4Db/QRcSGUAXyOQIxmmb6MWi1B9D69ev+M6CvIwgDDQ4a NIUJIh7EhCNOFLdMhGG+3XenLVuFoVubQdATbTSryrrMBWjtLdK1XGHSwqDbcxiRd0Zpk5 sXBRDv56v5OpGXDdeNZOjcnIPI4aajNMOoWMzPB8Yh0dqocp/FzhVJP+hzDleRwBe9MrkC Ilgw8ewzCdakiNBI6Kqk5pVtjH4ZWwBCFQKinN1wSE3SjHz6ePt8nAIH4ctDTT6LkrjzjV HYzB981gtEqoyYHfR3ij4Z8dfFfk1avaM1YArb9ePKo7FKdgeWw6d+h1K299+Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639735428; a=rsa-sha256; cv=none; b=hkxlLugaT2BZ0ytmWnAkgl1gXyk2L83rN65I+EJo9Odd1MbGjzllCWHQNekb4fKl0Jy7qe Ji6RVX6zBEJPErsalvD0hxsYzF8gcPNhR8hSDM1Ci3GeBLmwvaKIoxoq0p/lWWIGAKms/8 x0pPtGOlwLf7TX2ZrUdqyia588WIaMc+wNtriGix7cR8XphO8BlLpy843r8jOEI9N/CIP6 d4djn+/6fbMMYFtToDLTwwly/3MBfwTa+0uR8Fxafty3g40cQanH54ekVi7vux0XNjoF2e c4/8nI10ID+M4R5KMfxyhylJBqMuNbKQfR7Cf0FNV8IushO5yD0szd0WAexJcA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by ram: URL: https://cgit.FreeBSD.org/src/commit/?id=fa3e66e9f7cd903050454fc284e2709a9e28e651 commit fa3e66e9f7cd903050454fc284e2709a9e28e651 Author: Ram Kishore Vegesna AuthorDate: 2021-05-28 05:51:10 +0000 Commit: Ram Kishore Vegesna CommitDate: 2021-12-17 09:45:59 +0000 ocs_fc: Fix use after free bug in ocs_hw_async_call() Freed ctx is used in the later callee ocs_hw_command(), which is a use after free bug. Return error if sli_cmd_common_nop() failed. PR: 255865 Reported by: lylgood@foxmail.com Approved by:: markj (cherry picked from commit 7377d3831bc8abec2d6e5fee359d7383d4551feb) --- sys/dev/ocs_fc/ocs_hw.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/dev/ocs_fc/ocs_hw.c b/sys/dev/ocs_fc/ocs_hw.c index 9cbb3f67e306..c77e17663836 100644 --- a/sys/dev/ocs_fc/ocs_hw.c +++ b/sys/dev/ocs_fc/ocs_hw.c @@ -11808,7 +11808,6 @@ ocs_hw_async_cb(ocs_hw_t *hw, int32_t status, uint8_t *mqe, void *arg) int32_t ocs_hw_async_call(ocs_hw_t *hw, ocs_hw_async_cb_t callback, void *arg) { - int32_t rc = 0; ocs_hw_async_call_ctx_t *ctx; /* @@ -11828,15 +11827,15 @@ ocs_hw_async_call(ocs_hw_t *hw, ocs_hw_async_cb_t callback, void *arg) if (sli_cmd_common_nop(&hw->sli, ctx->cmd, sizeof(ctx->cmd), 0) == 0) { ocs_log_err(hw->os, "COMMON_NOP format failure\n"); ocs_free(hw->os, ctx, sizeof(*ctx)); - rc = -1; + return OCS_HW_RTN_ERROR; } if (ocs_hw_command(hw, ctx->cmd, OCS_CMD_NOWAIT, ocs_hw_async_cb, ctx)) { ocs_log_err(hw->os, "COMMON_NOP command failure\n"); ocs_free(hw->os, ctx, sizeof(*ctx)); - rc = -1; + return OCS_HW_RTN_ERROR; } - return rc; + return OCS_HW_RTN_SUCCESS; } /**