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 959A61EDA28 for ; Thu, 1 May 2025 14:16:38 +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=1746108998; cv=none; b=DhcMw38OKshpY794iJzHVlWVEUJsoQQIHabyOHPt9bWsacNtKWAj+WFzPdoBBlGWeRy6Ld18iYpIWJyWeY7x7u1P6VRyE/pxhiCvKxpNr2jrH5CDy2UXFm4uMbgf6w++WD0CPtkRjocLdzgSntrsNmP3u+ohMrF9QKVQUl/oWk8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746108998; c=relaxed/simple; bh=HlTad37goRxl/ZxE0f6tDhY/nhA3EuXDbiM7W7rwFMc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Dl0sGdl8LlDmDW7/6QK15w53aqCG2jfaVJUCpjZcbJm4v3TjcNX09vzd9SM29aWRtRy081IdOPhGoPclWxT5uRQE4a5RctWsa8WWcMXUxI0KrQbMlsMiaG9RCKoLlZbMx31NpOigjAt87BqgFVyi0XgyA62/3TyIHKjWsVR87jw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xVao7Sfj; 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="xVao7Sfj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19A96C4CEE3; Thu, 1 May 2025 14:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1746108998; bh=HlTad37goRxl/ZxE0f6tDhY/nhA3EuXDbiM7W7rwFMc=; h=From:To:Cc:Subject:Date:Reply-to:From; b=xVao7Sfjla8c+zDg/2O9G1LBQ77IAMJaH3mBa0HRVQpMMQ4zbQJfWmn0Txx0TK+bh 8srV0FEjRU/KTGugmL6TSSart/fZg5grzITOlZ/xBjdUB8Swi5mAZIkDvYhgnyC/8l TBa5GAUsRsieTvFBeNcbETug8q9xiSEMjDGPg6mI= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49878: bpf, verifier: Fix memory leak in array reallocation for stack state Date: Thu, 1 May 2025 16:11:08 +0200 Message-ID: <2025050153-CVE-2022-49878-1e05@gregkh> X-Mailer: git-send-email 2.49.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=3328; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=mlcSbL5h44A04hy2S33XRmMleagAGh3TYNF+6lGIbhQ=; b=owGbwMvMwCRo6H6F97bub03G02pJDBnCDRsFDu5IEc3nqEjK2GWv7BntN2nL869eHV2lzXwHV vmdeM/YEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABPR4WOYn6oelbxrS2E4C2vx deciRbcaixs9DPMrZ56esFnrxLEVP0y+cs35Ol1gzXtJAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: bpf, verifier: Fix memory leak in array reallocation for stack state If an error (NULL) is returned by krealloc(), callers of realloc_array() were setting their allocation pointers to NULL, but on error krealloc() does not touch the original allocation. This would result in a memory resource leak. Instead, free the old allocation on the error handling path. The memory leak information is as follows as also reported by Zhengchao: unreferenced object 0xffff888019801800 (size 256): comm "bpf_repo", pid 6490, jiffies 4294959200 (age 17.170s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000b211474b>] __kmalloc_node_track_caller+0x45/0xc0 [<0000000086712a0b>] krealloc+0x83/0xd0 [<00000000139aab02>] realloc_array+0x82/0xe2 [<00000000b1ca41d1>] grow_stack_state+0xfb/0x186 [<00000000cd6f36d2>] check_mem_access.cold+0x141/0x1341 [<0000000081780455>] do_check_common+0x5358/0xb350 [<0000000015f6b091>] bpf_check.cold+0xc3/0x29d [<000000002973c690>] bpf_prog_load+0x13db/0x2240 [<00000000028d1644>] __sys_bpf+0x1605/0x4ce0 [<00000000053f29bd>] __x64_sys_bpf+0x75/0xb0 [<0000000056fedaf5>] do_syscall_64+0x35/0x80 [<000000002bd58261>] entry_SYSCALL_64_after_hwframe+0x63/0xcd The Linux kernel CVE team has assigned CVE-2022-49878 to this issue. Affected and fixed versions =========================== Issue introduced in 5.14 with commit c69431aab67a912836e5831f03d99a819c14c9c3 and fixed in 5.15.79 with commit 06615967d4889b08b19ff3dda96e8b131282f73d Issue introduced in 5.14 with commit c69431aab67a912836e5831f03d99a819c14c9c3 and fixed in 6.0.9 with commit 3e210891c4a4c2d858cd6f9f61d5809af251d4df Issue introduced in 5.14 with commit c69431aab67a912836e5831f03d99a819c14c9c3 and fixed in 6.1 with commit 42378a9ca55347102bbf86708776061d8fe3ece2 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-2022-49878 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: kernel/bpf/verifier.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/06615967d4889b08b19ff3dda96e8b131282f73d https://git.kernel.org/stable/c/3e210891c4a4c2d858cd6f9f61d5809af251d4df https://git.kernel.org/stable/c/42378a9ca55347102bbf86708776061d8fe3ece2