Skip to content

Commit e252ed8

Browse files
author
Al Viro
committed
coda_flag_children(): fix a UAF
if de goes negative right under us, there's nothing to prevent inode getting freed just as we call coda_flag_inode(). We are not holding ->d_lock, so it's not impossible. Not going to be reproducible on bare hardware unless it's a realtime config, but it could happen on KVM. Trivial to fix - just hold rcu_read_lock() over that loop. Signed-off-by: Al Viro <[email protected]>
1 parent e6d6836 commit e252ed8

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/coda/cache.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,14 @@ static void coda_flag_children(struct dentry *parent, int flag)
9393
struct dentry *de;
9494

9595
spin_lock(&parent->d_lock);
96+
rcu_read_lock();
9697
hlist_for_each_entry(de, &parent->d_children, d_sib) {
9798
struct inode *inode = d_inode_rcu(de);
9899
/* don't know what to do with negative dentries */
99100
if (inode)
100101
coda_flag_inode(inode, flag);
101102
}
103+
rcu_read_unlock();
102104
spin_unlock(&parent->d_lock);
103105
}
104106

0 commit comments

Comments
 (0)