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 4F6CD2628C for ; Thu, 18 Sep 2025 13:34:56 +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=1758202496; cv=none; b=HtQyaYC0cBjmGmjQWeM8POdkchyVlyLiOyj8XnM7sOqRfJAzKqMB8h4E5PFY7AwRqINy3wv4RAAJmTqPV2/GT8l2Z5fwHYtB6phkXk8G1vKLfGkFPejt9wCyMJZ2nOpxxxukufawh0mlk3MOWLNXQoqeSXLFFFoyf9eT7YV1yVw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758202496; c=relaxed/simple; bh=AvZZEWGc6pYIONcZPyRjHA9DSfZ4uZCUVG83rE3++bs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=N26iFHaape4/c/MBTyxmAAUsbKSwnPJK5ZVR53uco+Swp3XlNrkvjxOi2nz+lBzNn9T+xhJUQ8/AfoNOitL+JU+c0UxaZDiaIuI52ORoRFPUKYRgVG+n/1fok7TtbI4SNNHFbohWc47XnxUQ7XQ28pqqW1ZR3x3w8E53p5ulKzs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JpIjf1A3; 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="JpIjf1A3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BADE7C4CEEB; Thu, 18 Sep 2025 13:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1758202496; bh=AvZZEWGc6pYIONcZPyRjHA9DSfZ4uZCUVG83rE3++bs=; h=From:To:Cc:Subject:Date:Reply-to:From; b=JpIjf1A3zU6ScpAJgLEtsWtxt7IucoASSNisVr0fLxdjtk/MIggYG0VqJv1+K9yaJ YV1uNTKte3yBWoCguQzHrN/XPvpHmz7Cehd36X7wqDcWJG8IKidYSy1nEehrR3wQ5Y 21gby9W79iqJkOAmI60J8lDGHBtv3DCss2bHIqHU= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-50396: net: sched: fix memory leak in tcindex_set_parms Date: Thu, 18 Sep 2025 15:34:10 +0200 Message-ID: <2025091854-CVE-2022-50396-8b1b@gregkh> X-Mailer: git-send-email 2.51.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=7230; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=UBZx9DPKA4FZzQwfQRoVgbL04NOkiWxbYtn1UCniACM=; b=owGbwMvMwCRo6H6F97bub03G02pJDBlnuJyaNXXCnbUv77Bm3Kx3JEZ/X+ypFpY9la+e8H+zV s3/y3KrI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACZiaMEwT8lT5rd88ZYAbubf bQ/m5y6bU5QrzDDfMWryvJULdERNJWfe3b3wU9+TZ9zXAQ== 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: net: sched: fix memory leak in tcindex_set_parms Syzkaller reports a memory leak as follows: ==================================== BUG: memory leak unreferenced object 0xffff88810c287f00 (size 256): comm "syz-executor105", pid 3600, jiffies 4294943292 (age 12.990s) 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: [] kmalloc_trace+0x20/0x90 mm/slab_common.c:1046 [] kmalloc include/linux/slab.h:576 [inline] [] kmalloc_array include/linux/slab.h:627 [inline] [] kcalloc include/linux/slab.h:659 [inline] [] tcf_exts_init include/net/pkt_cls.h:250 [inline] [] tcindex_set_parms+0xa7/0xbe0 net/sched/cls_tcindex.c:342 [] tcindex_change+0xdf/0x120 net/sched/cls_tcindex.c:553 [] tc_new_tfilter+0x4f2/0x1100 net/sched/cls_api.c:2147 [] rtnetlink_rcv_msg+0x4dc/0x5d0 net/core/rtnetlink.c:6082 [] netlink_rcv_skb+0x87/0x1d0 net/netlink/af_netlink.c:2540 [] netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline] [] netlink_unicast+0x397/0x4c0 net/netlink/af_netlink.c:1345 [] netlink_sendmsg+0x396/0x710 net/netlink/af_netlink.c:1921 [] sock_sendmsg_nosec net/socket.c:714 [inline] [] sock_sendmsg+0x56/0x80 net/socket.c:734 [] ____sys_sendmsg+0x178/0x410 net/socket.c:2482 [] ___sys_sendmsg+0xa8/0x110 net/socket.c:2536 [] __sys_sendmmsg+0x105/0x330 net/socket.c:2622 [] __do_sys_sendmmsg net/socket.c:2651 [inline] [] __se_sys_sendmmsg net/socket.c:2648 [inline] [] __x64_sys_sendmmsg+0x24/0x30 net/socket.c:2648 [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] [] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 [] entry_SYSCALL_64_after_hwframe+0x63/0xcd ==================================== Kernel uses tcindex_change() to change an existing filter properties. Yet the problem is that, during the process of changing, if `old_r` is retrieved from `p->perfect`, then kernel uses tcindex_alloc_perfect_hash() to newly allocate filter results, uses tcindex_filter_result_init() to clear the old filter result, without destroying its tcf_exts structure, which triggers the above memory leak. To be more specific, there are only two source for the `old_r`, according to the tcindex_lookup(). `old_r` is retrieved from `p->perfect`, or `old_r` is retrieved from `p->h`. * If `old_r` is retrieved from `p->perfect`, kernel uses tcindex_alloc_perfect_hash() to newly allocate the filter results. Then `r` is assigned with `cp->perfect + handle`, which is newly allocated. So condition `old_r && old_r != r` is true in this situation, and kernel uses tcindex_filter_result_init() to clear the old filter result, without destroying its tcf_exts structure * If `old_r` is retrieved from `p->h`, then `p->perfect` is NULL according to the tcindex_lookup(). Considering that `cp->h` is directly copied from `p->h` and `p->perfect` is NULL, `r` is assigned with `tcindex_lookup(cp, handle)`, whose value should be the same as `old_r`, so condition `old_r && old_r != r` is false in this situation, kernel ignores using tcindex_filter_result_init() to clear the old filter result. So only when `old_r` is retrieved from `p->perfect` does kernel use tcindex_filter_result_init() to clear the old filter result, which triggers the above memory leak. Considering that there already exists a tc_filter_wq workqueue to destroy the old tcindex_data by tcindex_partial_destroy_work() at the end of tcindex_set_parms(), this patch solves this memory leak bug by removing this old filter result clearing part and delegating it to the tc_filter_wq workqueue. Note that this patch doesn't introduce any other issues. If `old_r` is retrieved from `p->perfect`, this patch just delegates old filter result clearing part to the tc_filter_wq workqueue; If `old_r` is retrieved from `p->h`, kernel doesn't reach the old filter result clearing part, so removing this part has no effect. [Thanks to the suggestion from Jakub Kicinski, Cong Wang, Paolo Abeni and Dmitry Vyukov] The Linux kernel CVE team has assigned CVE-2022-50396 to this issue. Affected and fixed versions =========================== Issue introduced in 4.9 with commit b9a24bb76bf611a5268ceffe04219e6ad264559b and fixed in 5.4.229 with commit 55ac68b53f1cea1926ee2313afc5d66b91daad71 Issue introduced in 4.9 with commit b9a24bb76bf611a5268ceffe04219e6ad264559b and fixed in 5.10.163 with commit b314f6c3512108d7a656c5caf07c82d1bbbdc0f1 Issue introduced in 4.9 with commit b9a24bb76bf611a5268ceffe04219e6ad264559b and fixed in 5.15.87 with commit 6c55953e232ea668731091d111066521f3b7719b Issue introduced in 4.9 with commit b9a24bb76bf611a5268ceffe04219e6ad264559b and fixed in 6.0.19 with commit c4de6057e7c6654983acb63d939d26ac0d7bbf39 Issue introduced in 4.9 with commit b9a24bb76bf611a5268ceffe04219e6ad264559b and fixed in 6.1.5 with commit facc4405e8b7407e03216207b1d1d640127de0c8 Issue introduced in 4.9 with commit b9a24bb76bf611a5268ceffe04219e6ad264559b and fixed in 6.2 with commit 399ab7fe0fa0d846881685fd4e57e9a8ef7559f7 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-50396 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/sched/cls_tcindex.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/55ac68b53f1cea1926ee2313afc5d66b91daad71 https://git.kernel.org/stable/c/b314f6c3512108d7a656c5caf07c82d1bbbdc0f1 https://git.kernel.org/stable/c/6c55953e232ea668731091d111066521f3b7719b https://git.kernel.org/stable/c/c4de6057e7c6654983acb63d939d26ac0d7bbf39 https://git.kernel.org/stable/c/facc4405e8b7407e03216207b1d1d640127de0c8 https://git.kernel.org/stable/c/399ab7fe0fa0d846881685fd4e57e9a8ef7559f7