Skip to content

Commit aff3bea

Browse files
committed
ext4: add lockdep annotations for i_data_sem for ea_inode's
Treat i_data_sem for ea_inodes as being in their own lockdep class to avoid lockdep complaints about ext4_setattr's use of inode_lock() on normal inodes potentially causing lock ordering with i_data_sem on ea_inodes in ext4_xattr_inode_write(). However, ea_inodes will be operated on by ext4_setattr(), so this isn't a problem. Cc: stable@kernel.org Link: https://syzkaller.appspot.com/bug?extid=298c5d8fb4a128bc27b0 Reported-by: syzbot+298c5d8fb4a128bc27b0@syzkaller.appspotmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Link: https://lore.kernel.org/r/20230524034951.779531-5-tytso@mit.edu Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 2bc7e7c commit aff3bea

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

fs/ext4/ext4.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,11 +918,13 @@ do { \
918918
* where the second inode has larger inode number
919919
* than the first
920920
* I_DATA_SEM_QUOTA - Used for quota inodes only
921+
* I_DATA_SEM_EA - Used for ea_inodes only
921922
*/
922923
enum {
923924
I_DATA_SEM_NORMAL = 0,
924925
I_DATA_SEM_OTHER,
925926
I_DATA_SEM_QUOTA,
927+
I_DATA_SEM_EA
926928
};
927929

928930

fs/ext4/xattr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ ext4_expand_inode_array(struct ext4_xattr_inode_array **ea_inode_array,
121121
#ifdef CONFIG_LOCKDEP
122122
void ext4_xattr_inode_set_class(struct inode *ea_inode)
123123
{
124+
struct ext4_inode_info *ei = EXT4_I(ea_inode);
125+
124126
lockdep_set_subclass(&ea_inode->i_rwsem, 1);
127+
(void) ei; /* shut up clang warning if !CONFIG_LOCKDEP */
128+
lockdep_set_subclass(&ei->i_data_sem, I_DATA_SEM_EA);
125129
}
126130
#endif
127131

0 commit comments

Comments
 (0)