Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 520CC134CC2 for ; Wed, 10 Apr 2024 18:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712775492; cv=none; b=FoZDG5VHpuvJghH8wppZB3FCNcGPr2bGpWMgbBpqPxjyKKNyWgBVabxq6v24QK4fJ5Zd++tvOsTpaVXaVRRjuaNlTk7lTcZbUVfkcXCXu/fBnllRN1XsF1edftxl3XqG5jJwNE434A0h8DYtUXFHnYaZN9iIH6qgkAIT2hCTUIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712775492; c=relaxed/simple; bh=JcXRi3rZH31XoS/EFndQjmhSCQgrudNz4yj3quNuLCU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kAtPPF2Pvn68vvebm5mw64nd/kyHl2LAaCfH3bat/gYYMR5N6rSwCSZ2fgPsgBDFuSm1sGpyNKVOwcxBE7nL2OvahBi/xLZ0pUWkvbRti1sZQBiHQj/SX5ObdVODAjrZAks13u3TDmM91JLTHxHLZSTT0uaDVCQ3PGdQmAo6Ix8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NL6milgb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NL6milgb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC7BDC433F1; Wed, 10 Apr 2024 18:58:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712775492; bh=JcXRi3rZH31XoS/EFndQjmhSCQgrudNz4yj3quNuLCU=; h=From:To:Cc:Subject:Date:Reply-to:From; b=NL6milgbzWPuwFfDiX6VIEBBZpGtbBRwo7a/ydRzm06WSKWwsU/eNkuVLnd1hgHlb u0NAozGalnDFmcRjF7NlOW822fQNvFL78GhHg5fFaAaegJyKW6ihOk6eHDx4uVNvB5 9HNGp73hA6IWgD+FalDgVjIVhHgt0Xy2faVORVVs= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-47199: net/mlx5e: CT, Fix multiple allocations and memleak of mod acts Date: Wed, 10 Apr 2024 20:57:48 +0200 Message-ID: <2024041036-CVE-2021-47199-604a@gregkh> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3259; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=JcXRi3rZH31XoS/EFndQjmhSCQgrudNz4yj3quNuLCU=; b=owGbwMvMwCRo6H6F97bub03G02pJDGliDxUmHIm51vrS57TWxW7ed3v+SyZXHmKT2cZw68o5q YttRlG7OmJZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiXEIMCzZwLBZ++9b1aee/ /nj5FsPLRfZFEgwLdnq9y67PLpz95cC8r3HTAtcE7f7bCQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: net/mlx5e: CT, Fix multiple allocations and memleak of mod acts CT clear action offload adds additional mod hdr actions to the flow's original mod actions in order to clear the registers which hold ct_state. When such flow also includes encap action, a neigh update event can cause the driver to unoffload the flow and then reoffload it. Each time this happens, the ct clear handling adds that same set of mod hdr actions to reset ct_state until the max of mod hdr actions is reached. Also the driver never releases the allocated mod hdr actions and causing a memleak. Fix above two issues by moving CT clear mod acts allocation into the parsing actions phase and only use it when offloading the rule. The release of mod acts will be done in the normal flow_put(). backtrace: [<000000007316e2f3>] krealloc+0x83/0xd0 [<00000000ef157de1>] mlx5e_mod_hdr_alloc+0x147/0x300 [mlx5_core] [<00000000970ce4ae>] mlx5e_tc_match_to_reg_set_and_get_id+0xd7/0x240 [mlx5_core] [<0000000067c5fa17>] mlx5e_tc_match_to_reg_set+0xa/0x20 [mlx5_core] [<00000000d032eb98>] mlx5_tc_ct_entry_set_registers.isra.0+0x36/0xc0 [mlx5_core] [<00000000fd23b869>] mlx5_tc_ct_flow_offload+0x272/0x1f10 [mlx5_core] [<000000004fc24acc>] mlx5e_tc_offload_fdb_rules.part.0+0x150/0x620 [mlx5_core] [<00000000dc741c17>] mlx5e_tc_encap_flows_add+0x489/0x690 [mlx5_core] [<00000000e92e49d7>] mlx5e_rep_update_flows+0x6e4/0x9b0 [mlx5_core] [<00000000f60f5602>] mlx5e_rep_neigh_update+0x39a/0x5d0 [mlx5_core] The Linux kernel CVE team has assigned CVE-2021-47199 to this issue. Affected and fixed versions =========================== Issue introduced in 5.7 with commit 1ef3018f5af3 and fixed in 5.15.5 with commit 486e8de6e233 Issue introduced in 5.7 with commit 1ef3018f5af3 and fixed in 5.16 with commit 806401c20a0f Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2021-47199 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h drivers/net/ethernet/mellanox/mlx5/core/en_tc.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/486e8de6e233ff2999493533c6259d1cb538653b https://git.kernel.org/stable/c/806401c20a0f9c51b6c8fd7035671e6ca841f6c2