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 02DC547A62 for ; Wed, 1 May 2024 05:24:17 +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=1714541058; cv=none; b=N7fjW7QNP2tcSZPo3HbOL1ynAjPlbk0PKH7w7QsjcEsDOYBc3arMaKx80OW/4iUYQ+rZQ3KMwLTKnQFXUu6EpPQDJP/HCW71NmX9eNL5lcn7AFFP30P/sURZ1PPv6/Y/o5aRgmfodGWDQiRCH1FkC1zJfj1IQYYi+MsXL1cqZVo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714541058; c=relaxed/simple; bh=k+mineSLqq2GbxM9vgQm5xEqQKwSlyE/X9HwXwanFg4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MQ6QwvTQq24W5OADORzc0Jrjy0kiXaU4113msWstw7dmsEMKdTaKWpKgC6AeIKnDz/IQnQQVNxjI6hL7CSLutHGybrL+URAo7hHA20x3NLuonu6VCwvx0HfbQZRoACwTe40kBgl43DgwanLLwWYrxFKG4lnW+8cTKv80FbTb/M8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=N3dhF9Ik; 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="N3dhF9Ik" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79148C113CC; Wed, 1 May 2024 05:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1714541057; bh=k+mineSLqq2GbxM9vgQm5xEqQKwSlyE/X9HwXwanFg4=; h=From:To:Cc:Subject:Date:Reply-to:From; b=N3dhF9IkcO5egi8nxnjIXFUlx9+EZfn0oj2pSGf1p4HmT9RnGsRoaFXrSihvF8Cdl e37zG2OCeQonShzO2GsphDaf2dEooNrwuZfJMWeGMF7pSPhl4t0cvCH/q9/RcIIf6v psOCvupvM+Ap7Kh1E5EDt6q2zrRfAr8hZ6/EB+lg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-26972: ubifs: ubifs_symlink: Fix memleak of inode->i_link in error path Date: Wed, 1 May 2024 07:22:02 +0200 Message-ID: <2024050132-CVE-2024-26972-bf6c@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=2832; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=k+mineSLqq2GbxM9vgQm5xEqQKwSlyE/X9HwXwanFg4=; b=owGbwMvMwCRo6H6F97bub03G02pJDGmGF2NuLV3E6HTbc9/uv+4ayrO/zLh4w+uv0181DcXff Ktqjd7yd8SyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEVoYxzDOVC1rZwKU596jJ UZ78hW1qk9WmlTDMZlneq6Zfw7k1WDDh6Y2V26fMaPOPBQA= 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: ubifs: ubifs_symlink: Fix memleak of inode->i_link in error path For error handling path in ubifs_symlink(), inode will be marked as bad first, then iput() is invoked. If inode->i_link is initialized by fscrypt_encrypt_symlink() in encryption scenario, inode->i_link won't be freed by callchain ubifs_free_inode -> fscrypt_free_inode in error handling path, because make_bad_inode() has changed 'inode->i_mode' as 'S_IFREG'. Following kmemleak is easy to be reproduced by injecting error in ubifs_jnl_update() when doing symlink in encryption scenario: unreferenced object 0xffff888103da3d98 (size 8): comm "ln", pid 1692, jiffies 4294914701 (age 12.045s) backtrace: kmemdup+0x32/0x70 __fscrypt_encrypt_symlink+0xed/0x1c0 ubifs_symlink+0x210/0x300 [ubifs] vfs_symlink+0x216/0x360 do_symlinkat+0x11a/0x190 do_syscall_64+0x3b/0xe0 There are two ways fixing it: 1. Remove make_bad_inode() in error handling path. We can do that because ubifs_evict_inode() will do same processes for good symlink inode and bad symlink inode, for inode->i_nlink checking is before is_bad_inode(). 2. Free inode->i_link before marking inode bad. Method 2 is picked, it has less influence, personally, I think. The Linux kernel CVE team has assigned CVE-2024-26972 to this issue. Affected and fixed versions =========================== Issue introduced in 5.2 with commit 2c58d548f570 and fixed in 6.8.3 with commit 62b5ae00c2b8 Issue introduced in 5.2 with commit 2c58d548f570 and fixed in 6.9-rc1 with commit 6379b44cdcd6 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-26972 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/ubifs/dir.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/62b5ae00c2b835639002ce898ccb5d82c51073ae https://git.kernel.org/stable/c/6379b44cdcd67f5f5d986b73953e99700591edfa