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 35F761F4717 for ; Fri, 27 Dec 2024 13:56:51 +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=1735307811; cv=none; b=Fzwwk2unyD6rVYwjwCU+L7Znck3eGOkxEXR6Jxtj6qo9cNQpwTzsZQu+X5B+C87vj7nW5MQRp9vRY9tMMoQzWVT+GV+CGgZ4DTOG2YOvwGLbYNVmDvF6X7Lbwog3k1fTaDRcanjLupr0zpRExOCD8Rr7hI5pVfE3KcD4g0r7ssM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735307811; c=relaxed/simple; bh=A28odbZLEfwciOwlmiZscjReMvpK1JHqoQyz4PzvaKg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CRtViV/poceBTZvyOyRSwWmj6zi2TPIo1SLNCpmKUZ9gCqGG1ulpE+7Jd3dWaWyHTzGCgd68TQkVuj9c9Xkujq+KSMpY26TN+eot+ItznKcvjZHjm0PQlUtMVWcs5TU59AliLp87+rrFrDhMF9x1CI2dOXpPK40sTX2jlRhKd1c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nuUeI4+P; 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="nuUeI4+P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B757AC4CED0; Fri, 27 Dec 2024 13:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1735307811; bh=A28odbZLEfwciOwlmiZscjReMvpK1JHqoQyz4PzvaKg=; h=From:To:Cc:Subject:Date:Reply-to:From; b=nuUeI4+PL68pgnNCQb8BM0WwNaw0R8MdeT/biPixqdVdiOvExwj7kriJ+fooVYmg1 E8HCJpqCh2LjrODUFt18YhFrQImOQS/H//s4r2z1q/5GMcESqSfu2g3xWkBuBOdIcY CxyCbmoEUN2Ujxk3SO/MraypZIi/P4X9AW24QTIQ= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-53218: f2fs: fix race in concurrent f2fs_stop_gc_thread Date: Fri, 27 Dec 2024 14:53:04 +0100 Message-ID: <2024122732-CVE-2024-53218-4330@gregkh> X-Mailer: git-send-email 2.47.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=3865; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=A28odbZLEfwciOwlmiZscjReMvpK1JHqoQyz4PzvaKg=; b=owGbwMvMwCRo6H6F97bub03G02pJDOl5GxXYzVdlf7hnJPqr8wSHfm+tpfS1D/z7G2aELd/y/ /ifNfP/dsSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBElnMyLJiw5KPupj17NDnm P3+wJJL7Q1LAxjaG+eXflq6su9tswrYiMfKaqq+7T/2/YAA= 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: f2fs: fix race in concurrent f2fs_stop_gc_thread In my test case, concurrent calls to f2fs shutdown report the following stack trace: Oops: general protection fault, probably for non-canonical address 0xc6cfff63bb5513fc: 0000 [#1] PREEMPT SMP PTI CPU: 0 UID: 0 PID: 678 Comm: f2fs_rep_shutdo Not tainted 6.12.0-rc5-next-20241029-g6fb2fa9805c5-dirty #85 Call Trace: ? show_regs+0x8b/0xa0 ? __die_body+0x26/0xa0 ? die_addr+0x54/0x90 ? exc_general_protection+0x24b/0x5c0 ? asm_exc_general_protection+0x26/0x30 ? kthread_stop+0x46/0x390 f2fs_stop_gc_thread+0x6c/0x110 f2fs_do_shutdown+0x309/0x3a0 f2fs_ioc_shutdown+0x150/0x1c0 __f2fs_ioctl+0xffd/0x2ac0 f2fs_ioctl+0x76/0xe0 vfs_ioctl+0x23/0x60 __x64_sys_ioctl+0xce/0xf0 x64_sys_call+0x2b1b/0x4540 do_syscall_64+0xa7/0x240 entry_SYSCALL_64_after_hwframe+0x76/0x7e The root cause is a race condition in f2fs_stop_gc_thread() called from different f2fs shutdown paths: [CPU0] [CPU1] ---------------------- ----------------------- f2fs_stop_gc_thread f2fs_stop_gc_thread gc_th = sbi->gc_thread gc_th = sbi->gc_thread kfree(gc_th) sbi->gc_thread = NULL < gc_th != NULL > kthread_stop(gc_th->f2fs_gc_task) //UAF The commit c7f114d864ac ("f2fs: fix to avoid use-after-free in f2fs_stop_gc_thread()") attempted to fix this issue by using a read semaphore to prevent races between shutdown and remount threads, but it fails to prevent all race conditions. Fix it by converting to write lock of s_umount in f2fs_do_shutdown(). The Linux kernel CVE team has assigned CVE-2024-53218 to this issue. Affected and fixed versions =========================== Issue introduced in 4.16 with commit 7950e9ac638e84518fbdd5c930939ad46a1068c5 and fixed in 6.6.64 with commit 794fa8792d4eacac191f1cbcc2e81b7369e4662a Issue introduced in 4.16 with commit 7950e9ac638e84518fbdd5c930939ad46a1068c5 and fixed in 6.11.11 with commit 60457ed6c67625c87861f96912b4179dc2293896 Issue introduced in 4.16 with commit 7950e9ac638e84518fbdd5c930939ad46a1068c5 and fixed in 6.12.2 with commit c631207897a9b3d41167ceca58e07f8f94720e42 Issue introduced in 4.16 with commit 7950e9ac638e84518fbdd5c930939ad46a1068c5 and fixed in 6.13-rc1 with commit 7b0033dbc48340a1c1c3f12448ba17d6587ca092 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-53218 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/f2fs/file.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/794fa8792d4eacac191f1cbcc2e81b7369e4662a https://git.kernel.org/stable/c/60457ed6c67625c87861f96912b4179dc2293896 https://git.kernel.org/stable/c/c631207897a9b3d41167ceca58e07f8f94720e42 https://git.kernel.org/stable/c/7b0033dbc48340a1c1c3f12448ba17d6587ca092