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 4EF16EAC0 for ; Wed, 21 Aug 2024 00:07:42 +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=1724198862; cv=none; b=qLnCKHT2pGYQXun06b2x1jpxMLDztF3x1DwHbx9ob+C6ppyVsCQnQQemsqvs8fWjaFc51+hkzkB9EPKCl45IvzZT1azD+ZW21/iu+AkfgFhna16QqWrqG2aJW6ND68onqpeg0/mEl19lUZnYqyifeZ3ztgKaMcA0W3OzUQXbOtk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724198862; c=relaxed/simple; bh=+WgJmtIy06qmeU9bRU9LKQDntQqgndrYH81QYysl45U=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lFICKur50eciTrPlbJsNgKK5vRKrdmJd2D0HJv2bIpkLCChAQCwj3LeGONcgibewSMr+us6BE3KB578ug8K3qpKoDCcv86TDTvtg4A1XRDND68xlYpnNFNDzOPo/ONQ8iyAbnjzgyQFXWt2R9fWSoX1u6Jj/DXVdUYi5xG+S7p4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tZC6bwc3; 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="tZC6bwc3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F994C4AF09; Wed, 21 Aug 2024 00:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1724198862; bh=+WgJmtIy06qmeU9bRU9LKQDntQqgndrYH81QYysl45U=; h=From:To:Cc:Subject:Date:Reply-to:From; b=tZC6bwc3YeWKzTEkZzWIC3C9+LoMfgaUdeCn+r66vS67UfW8DFbGd+b9npaCgSdPq zLjdhgF+WV5bTHgzBL2ruFCshTH6ZR/ZkNjL/4UKe2q6mc+akU7EGSlkdk+CkgjRYn HEEyKrxmeq4mT1+Wvxp0iTtMF1ymEjB+9ev/PIT0= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-43870: perf: Fix event leak upon exit Date: Wed, 21 Aug 2024 08:07:34 +0800 Message-ID: <2024082135-CVE-2024-43870-2b6f@gregkh> X-Mailer: git-send-email 2.46.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=3673; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=+WgJmtIy06qmeU9bRU9LKQDntQqgndrYH81QYysl45U=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlH9Y+XqyaHOfmuSdxetXDS121PhcxEdsgFzK5uudful H4kaMuNjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjIgSMMc/guHLja4bO4K3/V jls7vfsdsn8sucuw4JzXgZ6WBbeYl53Rz5lt8mmSjjhHAAA= 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: perf: Fix event leak upon exit When a task is scheduled out, pending sigtrap deliveries are deferred to the target task upon resume to userspace via task_work. However failures while adding an event's callback to the task_work engine are ignored. And since the last call for events exit happen after task work is eventually closed, there is a small window during which pending sigtrap can be queued though ignored, leaking the event refcount addition such as in the following scenario: TASK A ----- do_exit() exit_task_work(tsk); perf_event_overflow() event->pending_sigtrap = pending_id; irq_work_queue(&event->pending_irq); =========> PREEMPTION: TASK A -> TASK B event_sched_out() event->pending_sigtrap = 0; atomic_long_inc_not_zero(&event->refcount) // FAILS: task work has exited task_work_add(&event->pending_task) [...] perf_pending_irq() // early return: event->oncpu = -1 [...] =========> TASK B -> TASK A perf_event_exit_task(tsk) perf_event_exit_event() free_event() WARN(atomic_long_cmpxchg(&event->refcount, 1, 0) != 1) // leak event due to unexpected refcount == 2 As a result the event is never released while the task exits. Fix this with appropriate task_work_add()'s error handling. The Linux kernel CVE team has assigned CVE-2024-43870 to this issue. Affected and fixed versions =========================== Issue introduced in 5.15.84 with commit 8bffa95ac19f and fixed in 5.15.165 with commit 67fad724f1b5 Issue introduced in 6.1 with commit 517e6a301f34 and fixed in 6.1.103 with commit 70882d7fa74f Issue introduced in 6.1 with commit 517e6a301f34 and fixed in 6.6.44 with commit 05d3fd599594 Issue introduced in 6.1 with commit 517e6a301f34 and fixed in 6.10.3 with commit 3d7a63352a93 Issue introduced in 6.1 with commit 517e6a301f34 and fixed in 6.11-rc1 with commit 2fd5ad3f310d Issue introduced in 6.0.14 with commit 78e1317a174e 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-43870 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: kernel/events/core.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/67fad724f1b568b356c1065d50df46e6b30eb2f7 https://git.kernel.org/stable/c/70882d7fa74f0731492a0d493e8515a4f7131831 https://git.kernel.org/stable/c/05d3fd599594abf79aad4484bccb2b26e1cb0b51 https://git.kernel.org/stable/c/3d7a63352a93bdb8a1cdf29606bf617d3ac1c22a https://git.kernel.org/stable/c/2fd5ad3f310de22836cdacae919dd99d758a1f1b