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 7945A208D7 for ; Mon, 20 May 2024 09:43:08 +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=1716198188; cv=none; b=uoLQ3khEjDZ94qXBT9yl7MMSVFKkf/AyZIBWVJRShq1dif0DFCvO+7y0FCGbFAjRlhLN7Nxdei/fes5jttr9O//XJFOwZDqP27UQmOCQDiTD1PYDG6NHwUgCb+mD7xVVxOn7yYuJwSOC8yzO3Q8dJtCeqoRt9UqpNQNzDrXMS+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716198188; c=relaxed/simple; bh=V+0YOQ/ay/ecUJlr2bXqXsmhMHIun+zIZKlGscMBTaw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nMMAnfxcx//OXJ0maPdqPiiIq6UrUtFG3yMrI141xwpnuoWtwcZvO+K6Fpl2LYKXoYxeQdDIxvLBVIgUcVdd7mxLH6rB3zPiJUNB3A+KADFALVzNePTqKuBE+YrNnOcBn95R/FxfuBCZ5Rksgsxv38+MtXb0JJjpWEYMZ5+Jqcg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yM6UFDEF; 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="yM6UFDEF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3C02C2BD10; Mon, 20 May 2024 09:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716198188; bh=V+0YOQ/ay/ecUJlr2bXqXsmhMHIun+zIZKlGscMBTaw=; h=From:To:Cc:Subject:Date:Reply-to:From; b=yM6UFDEFE+Hl/ELzAApy8FAkQsY/5zGcmpOJ8WWPpdSr8sSKmiWUvY2WPjgW5JvHA n+I9mH34JFfy65iL1DyLfw/GoLy96LJg9IFWZaZBWqc122/q7kLzaRTNaXBpOdQvV0 bEbmuwDOpwKGtES/apN8JRyBlibWcmfdgsGwvgRk= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-35971: net: ks8851: Handle softirqs at the end of IRQ thread to fix hang Date: Mon, 20 May 2024 11:42:36 +0200 Message-ID: <2024052023-CVE-2024-35971-fb84@gregkh> X-Mailer: git-send-email 2.45.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=4272; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=V+0YOQ/ay/ecUJlr2bXqXsmhMHIun+zIZKlGscMBTaw=; b=owGbwMvMwCRo6H6F97bub03G02pJDGneUv9/THkc2PRqu4LFvZVTasJmlgSy70906HRRirWOf LHKsnh7RywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAExEP4phrljIc6s7z2dtT9O4 6/Lsk8X3CweXzmKYK+dxhrszeA1rb/TJlu9Nx3Y4/Y/pBQA= 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: ks8851: Handle softirqs at the end of IRQ thread to fix hang The ks8851_irq() thread may call ks8851_rx_pkts() in case there are any packets in the MAC FIFO, which calls netif_rx(). This netif_rx() implementation is guarded by local_bh_disable() and local_bh_enable(). The local_bh_enable() may call do_softirq() to run softirqs in case any are pending. One of the softirqs is net_rx_action, which ultimately reaches the driver .start_xmit callback. If that happens, the system hangs. The entire call chain is below: ks8851_start_xmit_par from netdev_start_xmit netdev_start_xmit from dev_hard_start_xmit dev_hard_start_xmit from sch_direct_xmit sch_direct_xmit from __dev_queue_xmit __dev_queue_xmit from __neigh_update __neigh_update from neigh_update neigh_update from arp_process.constprop.0 arp_process.constprop.0 from __netif_receive_skb_one_core __netif_receive_skb_one_core from process_backlog process_backlog from __napi_poll.constprop.0 __napi_poll.constprop.0 from net_rx_action net_rx_action from __do_softirq __do_softirq from call_with_stack call_with_stack from do_softirq do_softirq from __local_bh_enable_ip __local_bh_enable_ip from netif_rx netif_rx from ks8851_irq ks8851_irq from irq_thread_fn irq_thread_fn from irq_thread irq_thread from kthread kthread from ret_from_fork The hang happens because ks8851_irq() first locks a spinlock in ks8851_par.c ks8851_lock_par() spin_lock_irqsave(&ksp->lock, ...) and with that spinlock locked, calls netif_rx(). Once the execution reaches ks8851_start_xmit_par(), it calls ks8851_lock_par() again which attempts to claim the already locked spinlock again, and the hang happens. Move the do_softirq() call outside of the spinlock protected section of ks8851_irq() by disabling BHs around the entire spinlock protected section of ks8851_irq() handler. Place local_bh_enable() outside of the spinlock protected section, so that it can trigger do_softirq() without the ks8851_par.c ks8851_lock_par() spinlock being held, and safely call ks8851_start_xmit_par() without attempting to lock the already locked spinlock. Since ks8851_irq() is protected by local_bh_disable()/local_bh_enable() now, replace netif_rx() with __netif_rx() which is not duplicating the local_bh_disable()/local_bh_enable() calls. The Linux kernel CVE team has assigned CVE-2024-35971 to this issue. Affected and fixed versions =========================== Issue introduced in 5.8 with commit 797047f875b5 and fixed in 6.1.87 with commit 492337a4fbd1 Issue introduced in 5.8 with commit 797047f875b5 and fixed in 6.6.28 with commit cba376eb036c Issue introduced in 5.8 with commit 797047f875b5 and fixed in 6.8.7 with commit 49d5d70538b6 Issue introduced in 5.8 with commit 797047f875b5 and fixed in 6.9 with commit be0384bf599c 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-35971 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/micrel/ks8851_common.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/492337a4fbd1421b42df684ee9b34be2a2722540 https://git.kernel.org/stable/c/cba376eb036c2c20077b41d47b317d8218fe754f https://git.kernel.org/stable/c/49d5d70538b6b8f2a3f8f1ac30c1f921d4a0929b https://git.kernel.org/stable/c/be0384bf599cf1eb8d337517feeb732d71f75a6f