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 A5FFD19047A for ; Sat, 11 Jan 2025 12:36:27 +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=1736598988; cv=none; b=b8oCFrNTkgprXDN7S1WehdQ3m2yRc2I1amTppv8TCKU/rMVoGeedTW8DS62ZpMs/iDLKdY++w15lVEsiazPo7TCjhei7ItYfeOBaJX+lBK6tyF5mOtQ5QZAJNDmhJsWP2VWuraYNXjdfsDGv1MNIB6yWB79Mub8r2nkeOINEm+Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736598988; c=relaxed/simple; bh=0HFn8usaFGzm53twtrNvxtGiIPi2QakATGlMZKQNyRA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=K1ymuwLcndUuZCtP7b/EVnABJJ8H1S2sPGbGzKTjckVN470HvfHuDUOnW/8uBcZ5eu4yEcRoE3HQnqJJAWs59krqNgTtEo8HxbMIWoMvg0cLtqsimyJrvRRXX9Lu0Wsm8rlMKJbQ/E9D9lJnOe6Ll3j9THhsNNIg122/wQfFa7I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GPFo17Hg; 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="GPFo17Hg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A69C9C4CED2; Sat, 11 Jan 2025 12:36:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1736598987; bh=0HFn8usaFGzm53twtrNvxtGiIPi2QakATGlMZKQNyRA=; h=From:To:Cc:Subject:Date:Reply-to:From; b=GPFo17HgYkGLsrT6bN1JWWAsY4truRfK+A3+JaKL2St3CECh1fHTnjQ5EVyqHdd65 FDIUdvtiUYjyzoM6c8g0DpHdWXA0JGcJJ4+fSeGVzGVhogicJwp3I08ZpgDXoZuMXG YAfgLGp9l3WW3awph41L6nX+wUgOzcWaEOycJDPY= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-56788: net: ethernet: oa_tc6: fix tx skb race condition between reference pointers Date: Sat, 11 Jan 2025 13:36:00 +0100 Message-ID: <2025011147-CVE-2024-56788-7a74@gregkh> X-Mailer: git-send-email 2.48.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=4742; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=0HFn8usaFGzm53twtrNvxtGiIPi2QakATGlMZKQNyRA=; b=owGbwMvMwCRo6H6F97bub03G02pJDOlNqYu9hQ9/kb52OLiS/aa4wMaOs1wBr+V/W9jl8FqqK TUdbN7bEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABMJZ2aYXyFe457Uwbf8VeSc ia0blhYJ6O5aw7BgZmNoou4rk2XvGJMf/JBQ2+Z3TOYSAA== 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: ethernet: oa_tc6: fix tx skb race condition between reference pointers There are two skb pointers to manage tx skb's enqueued from n/w stack. waiting_tx_skb pointer points to the tx skb which needs to be processed and ongoing_tx_skb pointer points to the tx skb which is being processed. SPI thread prepares the tx data chunks from the tx skb pointed by the ongoing_tx_skb pointer. When the tx skb pointed by the ongoing_tx_skb is processed, the tx skb pointed by the waiting_tx_skb is assigned to ongoing_tx_skb and the waiting_tx_skb pointer is assigned with NULL. Whenever there is a new tx skb from n/w stack, it will be assigned to waiting_tx_skb pointer if it is NULL. Enqueuing and processing of a tx skb handled in two different threads. Consider a scenario where the SPI thread processed an ongoing_tx_skb and it moves next tx skb from waiting_tx_skb pointer to ongoing_tx_skb pointer without doing any NULL check. At this time, if the waiting_tx_skb pointer is NULL then ongoing_tx_skb pointer is also assigned with NULL. After that, if a new tx skb is assigned to waiting_tx_skb pointer by the n/w stack and there is a chance to overwrite the tx skb pointer with NULL in the SPI thread. Finally one of the tx skb will be left as unhandled, resulting packet missing and memory leak. - Consider the below scenario where the TXC reported from the previous transfer is 10 and ongoing_tx_skb holds an tx ethernet frame which can be transported in 20 TXCs and waiting_tx_skb is still NULL. tx_credits = 10; /* 21 are filled in the previous transfer */ ongoing_tx_skb = 20; waiting_tx_skb = NULL; /* Still NULL */ - So, (tc6->ongoing_tx_skb || tc6->waiting_tx_skb) becomes true. - After oa_tc6_prepare_spi_tx_buf_for_tx_skbs() ongoing_tx_skb = 10; waiting_tx_skb = NULL; /* Still NULL */ - Perform SPI transfer. - Process SPI rx buffer to get the TXC from footers. - Now let's assume previously filled 21 TXCs are freed so we are good to transport the next remaining 10 tx chunks from ongoing_tx_skb. tx_credits = 21; ongoing_tx_skb = 10; waiting_tx_skb = NULL; - So, (tc6->ongoing_tx_skb || tc6->waiting_tx_skb) becomes true again. - In the oa_tc6_prepare_spi_tx_buf_for_tx_skbs() ongoing_tx_skb = NULL; waiting_tx_skb = NULL; - Now the below bad case might happen, Thread1 (oa_tc6_start_xmit) Thread2 (oa_tc6_spi_thread_handler) --------------------------- ----------------------------------- - if waiting_tx_skb is NULL - if ongoing_tx_skb is NULL - ongoing_tx_skb = waiting_tx_skb - waiting_tx_skb = skb - waiting_tx_skb = NULL ... - ongoing_tx_skb = NULL - if waiting_tx_skb is NULL - waiting_tx_skb = skb To overcome the above issue, protect the moving of tx skb reference from waiting_tx_skb pointer to ongoing_tx_skb pointer and assigning new tx skb to waiting_tx_skb pointer, so that the other thread can't access the waiting_tx_skb pointer until the current thread completes moving the tx skb reference safely. The Linux kernel CVE team has assigned CVE-2024-56788 to this issue. Affected and fixed versions =========================== Issue introduced in 6.12 with commit 53fbde8ab21e8c2c6187159cc17fc10cbf20900a and fixed in 6.12.7 with commit 1f2eb6c32bae04b375bb7a0aedbeefb6dbbcb775 Issue introduced in 6.12 with commit 53fbde8ab21e8c2c6187159cc17fc10cbf20900a and fixed in 6.13-rc4 with commit e592b5110b3e9393881b0a019d86832bbf71a47f 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-56788 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/oa_tc6.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/1f2eb6c32bae04b375bb7a0aedbeefb6dbbcb775 https://git.kernel.org/stable/c/e592b5110b3e9393881b0a019d86832bbf71a47f