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 278E71DD9BD for ; Tue, 5 Nov 2024 17:11:54 +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=1730826714; cv=none; b=NlRMGTIYnzbCB9LwrPA281cIyQuMB/qrpHcMQBDxrXeYRjCc6dyb3KoPZ1C2eG7XbyOi1WfuxE4Wa12hngtvzcNQu4k9ohYYW6DMPgTpXeCOPFI5aa8F4fZUqNvXQppXy8TGhWl/UNl0DejOCxwCgb85WQ9/2Xj4etBpPYW7vWQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730826714; c=relaxed/simple; bh=QZ/s/kDihh/JQEkt2CxeoSPe1wxowvw5q/sJZ6y6+vM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=t60ZLnb6XgCuS3Ij3Tu3Rev9B5W7eUsRRAtCKX31i+PfgUnNdT6/HVEx6jUphRiIiHOAgGWZxswEwMtjO2L41QvWKaNa3S/Be/ySRG30KE0aOwIML4kovHmy0eegOuU90xjSZG87rco5hbCSF8I1mI+6pUbgavGAuEEHvFEUznk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WUhBWLA5; 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="WUhBWLA5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A21DBC4CECF; Tue, 5 Nov 2024 17:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730826714; bh=QZ/s/kDihh/JQEkt2CxeoSPe1wxowvw5q/sJZ6y6+vM=; h=From:To:Cc:Subject:Date:Reply-to:From; b=WUhBWLA57dDghFHgVFP2gJ73DPzO5bRAc4MrgjtN9isBsfeQgTUbg0+9VT05PDvgn gAf52QTITK2mP/h89oP5L7qxRZciu0SU0/xr/1pfaAwiioU/tWlglGdW7Ft91fCZ9d JQq3FXYhf+55YPspQ6RKXM0Zg6vPJQG/QP86MAyg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-50121: nfsd: cancel nfsd_shrinker_work using sync mode in nfs4_state_shutdown_net Date: Tue, 5 Nov 2024 18:11:10 +0100 Message-ID: <2024110556-CVE-2024-50121-2a0a@gregkh> X-Mailer: git-send-email 2.47.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=4748; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=QZ/s/kDihh/JQEkt2CxeoSPe1wxowvw5q/sJZ6y6+vM=; b=owGbwMvMwCRo6H6F97bub03G02pJDOlagQtu/HC7f3juDMsiyUyNX4x5Xb8qD8UePqR/Nd3/u lrz++a/HbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjAR1z8M8+O37V+59ktHQ2bT vPlct85m85gvtGdYMCv0e5bGmlzGG7p5YoZda4T/ztGWAgA= 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: nfsd: cancel nfsd_shrinker_work using sync mode in nfs4_state_shutdown_net In the normal case, when we excute `echo 0 > /proc/fs/nfsd/threads`, the function `nfs4_state_destroy_net` in `nfs4_state_shutdown_net` will release all resources related to the hashed `nfs4_client`. If the `nfsd_client_shrinker` is running concurrently, the `expire_client` function will first unhash this client and then destroy it. This can lead to the following warning. Additionally, numerous use-after-free errors may occur as well. nfsd_client_shrinker echo 0 > /proc/fs/nfsd/threads expire_client nfsd_shutdown_net unhash_client ... nfs4_state_shutdown_net /* won't wait shrinker exit */ /* cancel_work(&nn->nfsd_shrinker_work) * nfsd_file for this /* won't destroy unhashed client1 */ * client1 still alive nfs4_state_destroy_net */ nfsd_file_cache_shutdown /* trigger warning */ kmem_cache_destroy(nfsd_file_slab) kmem_cache_destroy(nfsd_file_mark_slab) /* release nfsd_file and mark */ __destroy_client ==================================================================== BUG nfsd_file (Not tainted): Objects remaining in nfsd_file on __kmem_cache_shutdown() -------------------------------------------------------------------- CPU: 4 UID: 0 PID: 764 Comm: sh Not tainted 6.12.0-rc3+ #1 dump_stack_lvl+0x53/0x70 slab_err+0xb0/0xf0 __kmem_cache_shutdown+0x15c/0x310 kmem_cache_destroy+0x66/0x160 nfsd_file_cache_shutdown+0xac/0x210 [nfsd] nfsd_destroy_serv+0x251/0x2a0 [nfsd] nfsd_svc+0x125/0x1e0 [nfsd] write_threads+0x16a/0x2a0 [nfsd] nfsctl_transaction_write+0x74/0xa0 [nfsd] vfs_write+0x1a5/0x6d0 ksys_write+0xc1/0x160 do_syscall_64+0x5f/0x170 entry_SYSCALL_64_after_hwframe+0x76/0x7e ==================================================================== BUG nfsd_file_mark (Tainted: G B W ): Objects remaining nfsd_file_mark on __kmem_cache_shutdown() -------------------------------------------------------------------- dump_stack_lvl+0x53/0x70 slab_err+0xb0/0xf0 __kmem_cache_shutdown+0x15c/0x310 kmem_cache_destroy+0x66/0x160 nfsd_file_cache_shutdown+0xc8/0x210 [nfsd] nfsd_destroy_serv+0x251/0x2a0 [nfsd] nfsd_svc+0x125/0x1e0 [nfsd] write_threads+0x16a/0x2a0 [nfsd] nfsctl_transaction_write+0x74/0xa0 [nfsd] vfs_write+0x1a5/0x6d0 ksys_write+0xc1/0x160 do_syscall_64+0x5f/0x170 entry_SYSCALL_64_after_hwframe+0x76/0x7e To resolve this issue, cancel `nfsd_shrinker_work` using synchronous mode in nfs4_state_shutdown_net. The Linux kernel CVE team has assigned CVE-2024-50121 to this issue. Affected and fixed versions =========================== Issue introduced in 6.2 with commit 7c24fa225081 and fixed in 6.6.59 with commit f965dc0f099a Issue introduced in 6.2 with commit 7c24fa225081 and fixed in 6.11.6 with commit add1df5eba16 Issue introduced in 6.2 with commit 7c24fa225081 and fixed in 6.12-rc5 with commit d5ff2fb2e716 Issue introduced in 5.10.220 with commit 2bbf10861d51 Issue introduced in 5.15.154 with commit 958294a3eb82 Issue introduced in 6.1.81 with commit f3ea5ec83d1a 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-50121 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/nfsd/nfs4state.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/f965dc0f099a54fca100acf6909abe52d0c85328 https://git.kernel.org/stable/c/add1df5eba163a3a6ece11cb85890e2e410baaea https://git.kernel.org/stable/c/d5ff2fb2e7167e9483846e34148e60c0c016a1f6