This is a note to let you know that I've just added the patch titled ext4: make sure to reset inode lockdep class when quota enabling fails to the 5.16-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ext4-make-sure-to-reset-inode-lockdep-class-when-quota-enabling-fails.patch and it can be found in the queue-5.16 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 4013d47a5307fdb5c13370b5392498b00fedd274 Mon Sep 17 00:00:00 2001 From: Jan Kara <jack@xxxxxxx> Date: Thu, 7 Oct 2021 17:53:36 +0200 Subject: ext4: make sure to reset inode lockdep class when quota enabling fails From: Jan Kara <jack@xxxxxxx> commit 4013d47a5307fdb5c13370b5392498b00fedd274 upstream. When we succeed in enabling some quota type but fail to enable another one with quota feature, we correctly disable all enabled quota types. However we forget to reset i_data_sem lockdep class. When the inode gets freed and reused, it will inherit this lockdep class (i_data_sem is initialized only when a slab is created) and thus eventually lockdep barfs about possible deadlocks. Reported-and-tested-by: syzbot+3b6f9218b1301ddda3e2@xxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Jan Kara <jack@xxxxxxx> Cc: stable@xxxxxxxxxx Link: https://lore.kernel.org/r/20211007155336.12493-3-jack@xxxxxxx Signed-off-by: Theodore Ts'o <tytso@xxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/ext4/super.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -6361,8 +6361,19 @@ int ext4_enable_quotas(struct super_bloc "Failed to enable quota tracking " "(type=%d, err=%d). Please run " "e2fsck to fix.", type, err); - for (type--; type >= 0; type--) + for (type--; type >= 0; type--) { + struct inode *inode; + + inode = sb_dqopt(sb)->files[type]; + if (inode) + inode = igrab(inode); dquot_quota_off(sb, type); + if (inode) { + lockdep_set_quota_inode(inode, + I_DATA_SEM_NORMAL); + iput(inode); + } + } return err; } Patches currently in stable-queue which might be from jack@xxxxxxx are queue-5.16/ext4-avoid-trim-error-on-fs-with-small-groups.patch queue-5.16/ext4-make-sure-quota-gets-properly-shutdown-on-error.patch queue-5.16/udf-fix-error-handling-in-udf_new_inode.patch queue-5.16/ext4-make-sure-to-reset-inode-lockdep-class-when-quota-enabling-fails.patch queue-5.16/ext4-fix-a-possible-abba-deadlock-due-to-busy-pa.patch queue-5.16/bfq-do-not-let-waker-requests-skip-proper-accounting.patch