From nobody Fri Dec 17 10:37:07 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 CAF8918FF2B5; Fri, 17 Dec 2021 10:37:08 +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 4JFlm42SD7z4W4F; Fri, 17 Dec 2021 10:37:08 +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 11F471A2C7; Fri, 17 Dec 2021 10:37:08 +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 1BHAb75M092424; Fri, 17 Dec 2021 10:37:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BHAb7JO092423; Fri, 17 Dec 2021 10:37:07 GMT (envelope-from git) Date: Fri, 17 Dec 2021 10:37:07 GMT Message-Id: <202112171037.1BHAb7JO092423@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: 5749a5732606 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 5749a57326068f073555a5c043befade7bc37abf Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639737428; 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=ggmVTvZvVJ2xE7SbSKIM0pYrWW9AyJ8EaDOhRb1zgXo=; b=r2gazJvW2PnMwTylzfn9AyDze8mO6o21wstTg/Ez7Qzqtf7jXSZ8U38w2Tg7Bi7bCVIaDd 4GJe5cgzZE9i148qOu00+thehxLPVGcVeJLzyl0QqSK8z9dyEJiEA23NhnAJrj7lCyM8A5 6Ir4fovw4r5+B6BavDq8YKH1TsYAPs+WXk1dQTElrhwswZ0UxkXYUFUhTU/pLmppMFOT9o kQGi+4ueaCdPwJJDLdkTFIR8V0Nfn3Cv+TEX59yVXdLd6peQMSF9vaBJLyD+g4AyNuX5JG +L2OG/cNBG3MDgANTucIXAa/ApirGMgCd4McWU8sWv+PrgFwy3y+MXJ8bloCcQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639737428; a=rsa-sha256; cv=none; b=eutjnP22EvZfiUJ5aRnWmW60VKpAsgxJaEByXyLb0DU6auS5rAVwXzfIsjFGnutc2TFSzd SNAaseVbaS5OnVIpGe79XLSOx3immUZ71zBI1VA1b5E9iN/Z6IVIT/1OqfrioC6c4tDUQw I2Jhqj8jLuR0FUjELnuiR+4uyCcUhcOMZxEw3+oJQvRWBn+baCx7K3Uj7h1zeH8FIAxTjZ 3Kpcq5QCk1ue+/gYaPw5OsGu3wDjX/Tkc8ioEWV+Czo7fL0P1MLEsrMLpwza+YaCEji7NM +Wnfy047fvxzCi+UBsIUZB15mNUMVIDPRFTPERE89noX807SOCg9XhwnmOpeXA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by ram: URL: https://cgit.FreeBSD.org/src/commit/?id=5749a57326068f073555a5c043befade7bc37abf commit 5749a57326068f073555a5c043befade7bc37abf Author: Ram Kishore Vegesna AuthorDate: 2021-05-28 05:51:10 +0000 Commit: Ram Kishore Vegesna CommitDate: 2021-12-17 10:12:25 +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 d28d5e4a08b7..aa7d5857d9d9 100644 --- a/sys/dev/ocs_fc/ocs_hw.c +++ b/sys/dev/ocs_fc/ocs_hw.c @@ -11778,7 +11778,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; /* @@ -11798,15 +11797,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; } /**