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 0F2D71494C2 for ; Wed, 3 Apr 2024 14:56:34 +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=1712156195; cv=none; b=IsxeB84PSM0D2NU23hR12uUDkUA8O8ADhEzy8ZydB24y3QPBLpDKKj4TuyKO1MdI7zwcnXRTMFCqmBZgr279uO6GU5IQA/z8R7wqoLmO0dZ2PGfIPOo4DcDVS+b4ZcW9jWgYfLdH4/CcJLJ9lQWam0qP0A+Icebpk/EUrMSsuL8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712156195; c=relaxed/simple; bh=S4cNeYwug7VWkU90Svkcx0CO9m8IOHdx3fVAQhCVK9A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=La/GTvhHL+fMdN61VEtrlQz0I+jDDhuwTAo33R4KSWu+A951/SGoq6NwRqtSN4d1NLIVsPVpXbx73G7d7EDPm8j0AgU3w0ZnOdAsQjCzFLu4nPgkG+4IB0HZTgPb2jaxPWKyu35S/3abGhnoT8GMSaHo6T6rSnpCz+0gOjw9plg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kjETxpjt; 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="kjETxpjt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F27C8C43390; Wed, 3 Apr 2024 14:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712156194; bh=S4cNeYwug7VWkU90Svkcx0CO9m8IOHdx3fVAQhCVK9A=; h=From:To:Cc:Subject:Date:Reply-to:From; b=kjETxpjtVk+sY+EGnlromSjjZ75aRXpeJLu6q39r6Fk3Zo3m+QPQznsHbKTX+pIba aySRFAE8cqcVFRsgD0XAx1IEKHOgaF/1GAUrIrLQuiUM0wA/53/WSdfeaMYGJUj3AL zMQT39uLHqm416cZt660FvctJxhTvRrqQlAybQ/I= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-26701: eventfs: Do not create dentries nor inodes in iterate_shared Date: Wed, 3 Apr 2024 16:55:52 +0200 Message-ID: <2024040339-CVE-2024-26701-1f16@gregkh> X-Mailer: git-send-email 2.44.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=5177; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=S4cNeYwug7VWkU90Svkcx0CO9m8IOHdx3fVAQhCVK9A=; b=owGbwMvMwCRo6H6F97bub03G02pJDGm8ua9dOmy38+7LPrw7/90zb8FQyfBG3UcJD5XCzx4w0 Vi3XPFRRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEyEexPDgvlxW3S/qi115WK/ +8CxdVKsLmvWK4YFR78aunxpcWJKuG4iFN7kWfEypuoyAA== 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: eventfs: Do not create dentries nor inodes in iterate_shared The original eventfs code added a wrapper around the dcache_readdir open callback and created all the dentries and inodes at open, and increment their ref count. A wrapper was added around the dcache_readdir release function to decrement all the ref counts of those created inodes and dentries. But this proved to be buggy[1] for when a kprobe was created during a dir read, it would create a dentry between the open and the release, and because the release would decrement all ref counts of all files and directories, that would include the kprobe directory that was not there to have its ref count incremented in open. This would cause the ref count to go to negative and later crash the kernel. To solve this, the dentries and inodes that were created and had their ref count upped in open needed to be saved. That list needed to be passed from the open to the release, so that the release would only decrement the ref counts of the entries that were incremented in the open. Unfortunately, the dcache_readdir logic was already using the file->private_data, which is the only field that can be used to pass information from the open to the release. What was done was the eventfs created another descriptor that had a void pointer to save the dcache_readdir pointer, and it wrapped all the callbacks, so that it could save the list of entries that had their ref counts incremented in the open, and pass it to the release. The wrapped callbacks would just put back the dcache_readdir pointer and call the functions it used so it could still use its data[2]. But Linus had an issue with the "hijacking" of the file->private_data (unfortunately this discussion was on a security list, so no public link). Which we finally agreed on doing everything within the iterate_shared callback and leave the dcache_readdir out of it[3]. All the information needed for the getents() could be created then. But this ended up being buggy too[4]. The iterate_shared callback was not the right place to create the dentries and inodes. Even Christian Brauner had issues with that[5]. An attempt was to go back to creating the inodes and dentries at the open, create an array to store the information in the file->private_data, and pass that information to the other callbacks.[6] The difference between that and the original method, is that it does not use dcache_readdir. It also does not up the ref counts of the dentries and pass them. Instead, it creates an array of a structure that saves the dentry's name and inode number. That information is used in the iterate_shared callback, and the array is freed in the dir release. The dentries and inodes created in the open are not used for the iterate_share or release callbacks. Just their names and inode numbers. Linus did not like that either[7] and just wanted to remove the dentries being created in iterate_shared and use the hard coded inode numbers. [ All this while Linus enjoyed an unexpected vacation during the merge window due to lack of power. ] [1] https://lore.kernel.org/linux-trace-kernel/20230919211804.230edf1e@gandalf.local.home/ [2] https://lore.kernel.org/linux-trace-kernel/20230922163446.1431d4fa@gandalf.local.home/ [3] https://lore.kernel.org/linux-trace-kernel/20240104015435.682218477@goodmis.org/ [4] https://lore.kernel.org/all/202401152142.bfc28861-oliver.sang@intel.com/ [5] https://lore.kernel.org/all/20240111-unzahl-gefegt-433acb8a841d@brauner/ [6] https://lore.kernel.org/all/20240116114711.7e8637be@gandalf.local.home/ [7] https://lore.kernel.org/all/20240116170154.5bf0a250@gandalf.local.home/ The Linux kernel CVE team has assigned CVE-2024-26701 to this issue. Affected and fixed versions =========================== 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-26701 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: fs/tracefs/event_inode.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/c55d11ea8e074ff49f4732585b4437521ecf547c https://git.kernel.org/stable/c/f9f6478936f5bee0bad6d20500e6ad40ff6ac265 https://git.kernel.org/stable/c/852e46e239ee6db3cd220614cf8bce96e79227c2