From mboxrd@z Thu Jan 1 00:00:00 1970 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 289C71D174A for ; Tue, 19 Nov 2024 17:20:24 +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=1732036825; cv=none; b=LkbcOoTZTB3vqVNByx49A/rOFkP1kDEYPkM2CPO1T4vF4wEbduK9vzhrXLeGN1pe8+TNu4kqMhpwY0Hth7ttCz3yNq/Bv5I77/MQOZ1aRuhZnnlx2Qg5skm4ZxssC4P+461aWCplMuod8Pp8OYYJNQC4tmoc6nxGfjwIjx53C9k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036825; c=relaxed/simple; bh=S8r99+F13UubLanDc+JHX/moy1IbPdJxh/+ZASvcsrM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GkGDsDTkEcOJYR2M/yOFlInlD5TkTq48xwRqBFgVoTOrZ9pOnZX+0K6pbaHJh12DTTPkSpqVoUq/p3vU4/5ry7Cuh0a5GJyXJsZyU5fMFZ+q9GvBC18OXSjUvk/k6hSKjrY9LCV8hnSSgsfDgJtYqWOvY2WNrll05QFaZELfF9M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uSh5039j; 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="uSh5039j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF981C4CECF; Tue, 19 Nov 2024 17:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1732036824; bh=S8r99+F13UubLanDc+JHX/moy1IbPdJxh/+ZASvcsrM=; h=From:To:Cc:Subject:Date:Reply-to:From; b=uSh5039jLTv8CQu6ZJJV4Lbog+gzPs5cXvQYBSTEwCHN1KKCmOrNQm+jA6RlPgX0m ZFqzIsBebukj1PMklvf6U7+5muUwnxBE7emJT1XkqpEs8AvY65LKJ9i6Y6RxBZECbY i/z4h80zffDMf3rLuvW1igtdinMoanuRol0aAT2M= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-53044: net/sched: sch_api: fix xa_insert() error path in tcf_block_get_ext() Date: Tue, 19 Nov 2024 18:19:26 +0100 Message-ID: <2024111925-CVE-2024-53044-e0d1@gregkh> X-Mailer: git-send-email 2.47.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=3819; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=S8r99+F13UubLanDc+JHX/moy1IbPdJxh/+ZASvcsrM=; b=owGbwMvMwCRo6H6F97bub03G02pJDOk2J+YmnuyZeeVsVICWi3hFIkP0B94EkWWB1UUTTuTM0 Hg0p0qtI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACayoZlhfuqv4u/iM4/Yb6v4 M9N3TfsRxk8GTgwLpqfm3shtY2PkPuulf7Nw034hac07AA== 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/sched: sch_api: fix xa_insert() error path in tcf_block_get_ext() This command: $ tc qdisc replace dev eth0 ingress_block 1 egress_block 1 clsact Error: block dev insert failed: -EBUSY. fails because user space requests the same block index to be set for both ingress and egress. [ side note, I don't think it even failed prior to commit 913b47d3424e ("net/sched: Introduce tc block netdev tracking infra"), because this is a command from an old set of notes of mine which used to work, but alas, I did not scientifically bisect this ] The problem is not that it fails, but rather, that the second time around, it fails differently (and irrecoverably): $ tc qdisc replace dev eth0 ingress_block 1 egress_block 1 clsact Error: dsa_core: Flow block cb is busy. [ another note: the extack is added by me for illustration purposes. the context of the problem is that clsact_init() obtains the same &q->ingress_block pointer as &q->egress_block, and since we call tcf_block_get_ext() on both of them, "dev" will be added to the block->ports xarray twice, thus failing the operation: once through the ingress block pointer, and once again through the egress block pointer. the problem itself is that when xa_insert() fails, we have emitted a FLOW_BLOCK_BIND command through ndo_setup_tc(), but the offload never sees a corresponding FLOW_BLOCK_UNBIND. ] Even correcting the bad user input, we still cannot recover: $ tc qdisc replace dev swp3 ingress_block 1 egress_block 2 clsact Error: dsa_core: Flow block cb is busy. Basically the only way to recover is to reboot the system, or unbind and rebind the net device driver. To fix the bug, we need to fill the correct error teardown path which was missed during code movement, and call tcf_block_offload_unbind() when xa_insert() fails. [ last note, fundamentally I blame the label naming convention in tcf_block_get_ext() for the bug. The labels should be named after what they do, not after the error path that jumps to them. This way, it is obviously wrong that two labels pointing to the same code mean something is wrong, and checking the code correctness at the goto site is also easier ] The Linux kernel CVE team has assigned CVE-2024-53044 to this issue. Affected and fixed versions =========================== Issue introduced in 6.8 with commit 94e2557d086a and fixed in 6.11.7 with commit 8966eb69a143 Issue introduced in 6.8 with commit 94e2557d086a and fixed in 6.12 with commit a13e690191ea 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-2024-53044 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_api.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/8966eb69a143b1c032365fe84f2815f3c46f2590 https://git.kernel.org/stable/c/a13e690191eafc154b3f60afe9ce35aa9b9128b4