FAILED: patch "[PATCH] fscrypt: destroy keyring after security_sb_delete()" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-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 <[email protected]>.
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-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x ccb820dc7d2236b1af0d54ae038a27b5b6d5ae5a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.10.y' HEAD^..
Possible dependencies:
ccb820dc7d22 ("fscrypt: destroy keyring after security_sb_delete()") 83e804f0bfee ("fs,security: Add sb_delete hook")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From ccb820dc7d2236b1af0d54ae038a27b5b6d5ae5a Mon Sep 17 00:00:00 2001
From: Eric Biggers <[email protected]>
Date: Mon, 13 Mar 2023 15:12:29 -0700
Subject: [PATCH] fscrypt: destroy keyring after security_sb_delete()
fscrypt_destroy_keyring() must be called after all potentially-encrypted inodes were evicted; otherwise it cannot safely destroy the keyring. Since inodes that are in-use by the Landlock LSM don't get evicted until security_sb_delete(), this means that fscrypt_destroy_keyring() must be called *after* security_sb_delete().
This fixes a WARN_ON followed by a NULL dereference, only possible if Landlock was being used on encrypted files.
fs/super.c +12 -3
@@ -475,13 +475,22 @@ void generic_shutdown_super(struct super_block *sb)cgroup_writeback_umount (); -/* evict all inodes with zero refcount */ +/* Evict all inodes with zero refcount. */ evict_inodes (sb); -/* only nonzero refcount inodes can have marks */ + +/* +* Clean up and evict any inodes that still have references due +* to fsnotify or the security policy. +*/ fsnotify_sb_delete (sb); -fscrypt_destroy_keyring (sb);security_sb_delete (sb); +/* +* Now that all potentially-encrypted inodes have been evicted, +* the fscrypt keyring can be destroyed. +*/ +fscrypt_destroy_keyring (sb); +if (sb->s_dio_done_wq) {destroy_workqueue (sb->s_dio_done_wq); sb->s_dio_done_wq =NULL ;