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 B7FB216DEDA for ; Fri, 12 Jul 2024 12:27: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=1720787247; cv=none; b=ckB0aSw0BPcKa5dJt833WCUGJhsfkLzCGq+S6tUM8/jDEZeQJEMxLyti4dhUdmq6g8w9GeRZFXcx0aFiDTf+8WlR5kWR2+rlTg+w8VosG/RMXNElaS8Lb6X4+nJVojJ2v2T86k9rVvjbI7tpEgX1esrNVSzusaZQekr5AmLEwWs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720787247; c=relaxed/simple; bh=vdNnGcnXhtLUU9AeNAqs3YutsppJDE10izzlazQiDPI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=AgWvMtrlGkAkdmD98GAgs3OJ7BHaIiqj+4jqpN8LfvpEUJXOD6vbPBiM1s916JcrMjThETbsMpE4cfccjWoLHZEYgdM0FS5gHRMzaPIQJDXLxXOQsBj7OiX5AOPKKSie1LjmFQIhOUWFxR3zqZS10pS2B3/f+ZTuVROAbdy3KuA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RZbbojG/; 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="RZbbojG/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F42C4AF07; Fri, 12 Jul 2024 12:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720787247; bh=vdNnGcnXhtLUU9AeNAqs3YutsppJDE10izzlazQiDPI=; h=From:To:Cc:Subject:Date:Reply-to:From; b=RZbbojG/zZGyNNMMCzTNq06d/DhX9ejFx4c/uK7YnlzSQkXlJp0lMwnGDO11XHyu1 rmPqOj37cHo3mC9S2RZMQDmPd4F9fc5+srt/FkbztzMv1HGdkDVwm1CXrjSFA1ckHm oqePlqk9nXCEYTE8LdSOIHiDi8OxEsOEe/OtxsOQ= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-40913: cachefiles: defer exposing anon_fd until after copy_to_user() succeeds Date: Fri, 12 Jul 2024 14:27:11 +0200 Message-ID: <2024071210-CVE-2024-40913-5952@gregkh> X-Mailer: git-send-email 2.45.2 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=2566; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=vdNnGcnXhtLUU9AeNAqs3YutsppJDE10izzlazQiDPI=; b=owGbwMvMwCRo6H6F97bub03G02pJDGkTFeWM/bm1i4/fi2R2tXjOfnrG9ANiWx+rrGSsv5eyW k6DS92lI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACZSb8Iwz6pzw15N54Dkfbvu p/B2iOzcY88XxjA/z7+PSfHcxIN8J/dMTSvQ3s6iJ6IJAA== 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: cachefiles: defer exposing anon_fd until after copy_to_user() succeeds After installing the anonymous fd, we can now see it in userland and close it. However, at this point we may not have gotten the reference count of the cache, but we will put it during colse fd, so this may cause a cache UAF. So grab the cache reference count before fd_install(). In addition, by kernel convention, fd is taken over by the user land after fd_install(), and the kernel should not call close_fd() after that, i.e., it should call fd_install() after everything is ready, thus fd_install() is called after copy_to_user() succeeds. The Linux kernel CVE team has assigned CVE-2024-40913 to this issue. Affected and fixed versions =========================== Issue introduced in 5.19 with commit c8383054506c and fixed in 6.1.95 with commit eac51d9daacd Issue introduced in 5.19 with commit c8383054506c and fixed in 6.6.35 with commit d2d3eb377a5d Issue introduced in 5.19 with commit c8383054506c and fixed in 6.9.6 with commit b9f58cdae6a3 Issue introduced in 5.19 with commit c8383054506c and fixed in 6.10-rc4 with commit 4b4391e77a6b 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-40913 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/cachefiles/ondemand.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/eac51d9daacd61dcc93333ff6a890cf3efc8c1c0 https://git.kernel.org/stable/c/d2d3eb377a5d081bf2bed177d354a4f59b74da88 https://git.kernel.org/stable/c/b9f58cdae6a364a3270fd6b6a46e0fd4f7f8ce32 https://git.kernel.org/stable/c/4b4391e77a6bf24cba2ef1590e113d9b73b11039