Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

better lockdep annotations for simple_recursive_removal()

We want a class that nests outside of I_MUTEX_NORMAL (for the sake of
callbacks that might want to lock the victim) and inside I_MUTEX_PARENT
(so that a variant of that could be used with parent of the victim
held locked by the caller).

In reality, simple_recursive_removal()
* never holds two locks at once
* holds the lock on parent of dentry passed to callback
* is used only on the trees with fixed topology, so the depths
are not changing.

So the locking order is actually fine.

AFAICS, the best solution is to assign I_MUTEX_CHILD to the locks
grabbed by that thing.

Reported-by: syzbot+169de184e9defe7fe709@syzkaller.appspotmail.com
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

+2 -2
+2 -2
fs/libfs.c
··· 613 613 struct dentry *victim = NULL, *child; 614 614 struct inode *inode = this->d_inode; 615 615 616 - inode_lock(inode); 616 + inode_lock_nested(inode, I_MUTEX_CHILD); 617 617 if (d_is_dir(this)) 618 618 inode->i_flags |= S_DEAD; 619 619 while ((child = find_next_child(this, victim)) == NULL) { ··· 625 625 victim = this; 626 626 this = this->d_parent; 627 627 inode = this->d_inode; 628 - inode_lock(inode); 628 + inode_lock_nested(inode, I_MUTEX_CHILD); 629 629 if (simple_positive(victim)) { 630 630 d_invalidate(victim); // avoid lost mounts 631 631 if (callback)