From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796221064; b=3tkHrF35H1xnp2HaSHnrFrr0EcuEaeqUG1j4NKHYWmt/UUnXOQbfYGi7Y53Y+D7o1a8k VkPI5Xdnx3p7pFFHjGplNyWQdXEWuaeZgmYDfW2+aRg5ab9EhfA4tzuER8nq7eTjbrLPB uOVxFvV4Yu3bxtl+uNC4OaXe01KEkvCAzVFcwKmgxc1Hna/KLuI2bT3XjiJe3Xrc8SIpE PLxBGk+WGU4QkNKPSWFnXjVQ5Q2YS6yVRFSCpTNhpeF7G0hMhSavq729Otsk/JaG9MLsw f+YamZ/UC4eh22nZ+oX1Rofl1v4HyouONMzI01vb1HlQ8HERcgB4V6ipJ6fiXkY80Iw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221064; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=riGEQgKG8yMNQETT+Tmbl0mSlK7fX7ICI3O4sSZsbRs=; b=ZgOGPNfVOweQJEMPdH9T+kC3YNFojPGyyZ7XqMC7c5HSoP7z+/GPbYGfiGBj6O9L0Ppv pBP/N6Wq1Ziw0+8P+0G9Y88/8RUpJYoe+yqEpYT9Ck2lz7uvIWxr4cN7jvd2hplCaB+QK eIuWAu4TESbOw6dSylY25iRCrchwl3Gq0ogyXsk51I/ZkkaNxBk82MGKfzGrnNNGt/MBF 0vRSG7b8ww75udzazErkw44hcmMfAdFCpPBDJLqt0bSJTgBkKkoq3gLp/NVRpyIhrFNru yDFRasIx/JrRTiO88XT5lpPNHMI7Re1uy+kIfaqBt3tk3S29wnj30P9Dl/gpFBmF5jw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=G6c8cvti; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62E5A606A31A for ; Wed, 2 Dec 2026 14:17:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=G6c8cvti Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF29C1F0089A; Wed, 2 Dec 2026 14:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221063; bh=riGEQgKG8yMNQETT+Tmbl0mSlK7fX7ICI3O4sSZsbRs=; h=Subject:To:Cc:From:Date; b=G6c8cvti1ASYlPGj3bNr+R0/WKTBA9La27igaq45BGpg9DNgtD4/0+zLR+PUGImOz 7Snl3HkW7NSEC/Ia1JUrGr11Q9tEMGNkR6zg+M81KGa9O1EYtawKhpYFfYkdY8unTv NiDT8lJ+X9z1Ol4ZmXQzAbCjI1dNF3Yy85KAid3A= Subject: FAILED: patch "[PATCH] fscrypt: Initialize ->ci_master_key before publication" failed to apply to 6.1-stable tree To: ebiggers@kernel.org,adasmithgt@gmail.com Cc: From: Date: Wed, 02 Dec 2026 14:01:48 +0100 Message-ID: <2026120248-commotion-crazily-371e@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y git checkout FETCH_HEAD git cherry-pick -x 2de253924266eeedb798fb662173726c90b0cf04 # git commit -s git send-email --to '' --in-reply-to '2026120248-commotion-crazily-371e@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 2de253924266eeedb798fb662173726c90b0cf04 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Tue, 10 Nov 2026 13:20:11 -0800 Subject: [PATCH] fscrypt: Initialize ->ci_master_key before publication fscrypt_prepare_setflags() assumes that if the key for an inode with a v2 encryption policy has been set up, then ->ci_master_key is non-NULL. This is a reasonable assumption, but it does not take into account the very short gap in fscrypt_setup_encryption_info() between the inode's fscrypt_inode_info being set and ->ci_master_key being initialized. Thus, a NULL pointer dereference was possible. Fix this by closing the gap: make fscrypt_setup_encryption_info() initialize ->ci_master_key before publication. If it loses the cmpxchg race afterwards, set it back to NULL so that put_crypt_info() continues to have the same behavior. Fixes: b1c0ec3599f4 ("fscrypt: add FS_IOC_REMOVE_ENCRYPTION_KEY ioctl") Cc: stable@vger.kernel.org Reported-by: Ada Smith Link: https://patch.msgid.link/20261110212011.35487-1-ebiggers@kernel.org Signed-off-by: Eric Biggers diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c index a77b889d7578..0beec01c0418 100644 --- a/fs/crypto/keysetup.c +++ b/fs/crypto/keysetup.c @@ -621,6 +621,13 @@ fscrypt_setup_encryption_info(struct inode *inode, if (res) goto out; + /* + * Preemptively initialize ->ci_master_key, even though we don't know + * whether we'll win the race below yet, because if we do win the race + * then other tasks can see it right away and need ->ci_master_key. + */ + crypt_info->ci_master_key = mk; + /* * For existing inodes, multiple tasks may race to set the inode's * fscrypt info pointer. So use cmpxchg_release(). This pairs with the @@ -634,7 +641,6 @@ fscrypt_setup_encryption_info(struct inode *inode, * crypt_info. Now link it into the master key's inode list. */ if (mk) { - crypt_info->ci_master_key = mk; refcount_inc(&mk->mk_active_refs); spin_lock(&mk->mk_decrypted_inodes_lock); list_add(&crypt_info->ci_master_key_link, @@ -642,6 +648,12 @@ fscrypt_setup_encryption_info(struct inode *inode, spin_unlock(&mk->mk_decrypted_inodes_lock); } crypt_info = NULL; + } else { + /* + * Lost the race, so we won't be taking an active reference to + * the master key. Clear ->ci_master_key accordingly. + */ + crypt_info->ci_master_key = NULL; } res = 0; out: