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 62BB61F9A91 for ; Wed, 26 Feb 2025 02:00:02 +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=1740535202; cv=none; b=RcHX4OoyQmGhGEy5bv4TU8TwQ6K4U98NNvwQ9+HIgyOwZpisIbMz5f4i/COPscJQKszMI9/Sbim6kPRMgDUXIO0rfgQ+OEg60rs+sq1KY6M34deTHbl0fl11c1fBdp22fP8XaUFv9/VnQZXuu6TyXbgaLQkduY3BvuA3sypmNak= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535202; c=relaxed/simple; bh=PjZNIb/UBKziIR3wNB6ipkUlmDMcArClAhaKqB9uX6Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=LVZ2NP/fzpDWCS7+WoyRaF/rG5Gs03rG9v8Wo7m9C2kVKNCjnOL0fxVukR/7dS3ub22i3i+x9PlrqKe31CwW5oEtH8USipPfzfdNhMyEtpOwFi7WMRiQw9tnQUCH9jNqPdvYEXWkG+IrTlrTHWzACMQhF+6VHKeqwhl5DRPb5gw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZIhHuVqA; 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="ZIhHuVqA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DD28C4CEDD; Wed, 26 Feb 2025 02:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740535202; bh=PjZNIb/UBKziIR3wNB6ipkUlmDMcArClAhaKqB9uX6Q=; h=From:To:Cc:Subject:Date:Reply-to:From; b=ZIhHuVqA4BoD0rL/e95YNBvYdnr8qpw3BzWBXB41PF6z+z9pvxHC6GAVzHn/wHj66 M+/MUQiI/hY7qgeQLC3Su9jLhEYQXThS9D6TnoA8Drua6Ul1VYnqs6Yl/2Wxm2BMXP hTjVADjg2bMCGFl/pkBohYBD0DzakPJNkFaepeZs= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49209: bpf, sockmap: Fix memleak in tcp_bpf_sendmsg while sk msg is full Date: Wed, 26 Feb 2025 02:56:54 +0100 Message-ID: <2025022619-CVE-2022-49209-85dc@gregkh> X-Mailer: git-send-email 2.48.1 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=4093; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=PjZNIb/UBKziIR3wNB6ipkUlmDMcArClAhaKqB9uX6Q=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7SrybSxsCt3132Kl+rDu0x0oqSEbNeHFA5XGn4j+My Tnpc6I7YlkYBJkYZMUUWb5s4zm6v+KQopeh7WmYOaxMIEMYuDgFYCIvOxgWLHue2Hoy5puZYFXP 1dvb5v8xz3DQZZhnEVdyhPOvL6fztPKWA5lrdP8FO60HAA== 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: bpf, sockmap: Fix memleak in tcp_bpf_sendmsg while sk msg is full If tcp_bpf_sendmsg() is running while sk msg is full. When sk_msg_alloc() returns -ENOMEM error, tcp_bpf_sendmsg() goes to wait_for_memory. If partial memory has been alloced by sk_msg_alloc(), that is, msg_tx->sg.size is greater than osize after sk_msg_alloc(), memleak occurs. To fix we use sk_msg_trim() to release the allocated memory, then goto wait for memory. Other call paths of sk_msg_alloc() have the similar issue, such as tls_sw_sendmsg(), so handle sk_msg_trim logic inside sk_msg_alloc(), as Cong Wang suggested. This issue can cause the following info: WARNING: CPU: 3 PID: 7950 at net/core/stream.c:208 sk_stream_kill_queues+0xd4/0x1a0 Call Trace: inet_csk_destroy_sock+0x55/0x110 __tcp_close+0x279/0x470 tcp_close+0x1f/0x60 inet_release+0x3f/0x80 __sock_release+0x3d/0xb0 sock_close+0x11/0x20 __fput+0x92/0x250 task_work_run+0x6a/0xa0 do_exit+0x33b/0xb60 do_group_exit+0x2f/0xa0 get_signal+0xb6/0x950 arch_do_signal_or_restart+0xac/0x2a0 exit_to_user_mode_prepare+0xa9/0x200 syscall_exit_to_user_mode+0x12/0x30 do_syscall_64+0x46/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xae WARNING: CPU: 3 PID: 2094 at net/ipv4/af_inet.c:155 inet_sock_destruct+0x13c/0x260 Call Trace: __sk_destruct+0x24/0x1f0 sk_psock_destroy+0x19b/0x1c0 process_one_work+0x1b3/0x3c0 kthread+0xe6/0x110 ret_from_fork+0x22/0x30 The Linux kernel CVE team has assigned CVE-2022-49209 to this issue. Affected and fixed versions =========================== Issue introduced in 4.20 with commit 604326b41a6fb9b4a78b6179335decee0365cd8c and fixed in 5.4.189 with commit 6d03722c34d9603df325f67c6d30dc1b7b3c6067 Issue introduced in 4.20 with commit 604326b41a6fb9b4a78b6179335decee0365cd8c and fixed in 5.10.110 with commit bec34a91eba3483e1830c02bdd36f8f968642047 Issue introduced in 4.20 with commit 604326b41a6fb9b4a78b6179335decee0365cd8c and fixed in 5.15.33 with commit de3a8d8fab0710186f7864ec812836d8d70da3c9 Issue introduced in 4.20 with commit 604326b41a6fb9b4a78b6179335decee0365cd8c and fixed in 5.16.19 with commit f677328f05f52d535cbdc15cb04476db49477eb4 Issue introduced in 4.20 with commit 604326b41a6fb9b4a78b6179335decee0365cd8c and fixed in 5.17.2 with commit d0b85dfc6f01d26808e2576c6537c131b590e270 Issue introduced in 4.20 with commit 604326b41a6fb9b4a78b6179335decee0365cd8c and fixed in 5.18 with commit 9c34e38c4a870eb30b13f42f5b44f42e9d19ccb8 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-49209 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: net/core/skmsg.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/6d03722c34d9603df325f67c6d30dc1b7b3c6067 https://git.kernel.org/stable/c/bec34a91eba3483e1830c02bdd36f8f968642047 https://git.kernel.org/stable/c/de3a8d8fab0710186f7864ec812836d8d70da3c9 https://git.kernel.org/stable/c/f677328f05f52d535cbdc15cb04476db49477eb4 https://git.kernel.org/stable/c/d0b85dfc6f01d26808e2576c6537c131b590e270 https://git.kernel.org/stable/c/9c34e38c4a870eb30b13f42f5b44f42e9d19ccb8