Skip to content

Commit daf5cc2

Browse files
Al Viroidryomov
authored andcommitted
ceph: fix use-after-free on symlink traversal
free the symlink body after the same RCU delay we have for freeing the struct inode itself, so that traversal during RCU pathwalk wouldn't step into freed memory. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 187df76 commit daf5cc2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ceph/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ static void ceph_i_callback(struct rcu_head *head)
524524
struct inode *inode = container_of(head, struct inode, i_rcu);
525525
struct ceph_inode_info *ci = ceph_inode(inode);
526526

527+
kfree(ci->i_symlink);
527528
kmem_cache_free(ceph_inode_cachep, ci);
528529
}
529530

@@ -566,7 +567,6 @@ void ceph_destroy_inode(struct inode *inode)
566567
}
567568
}
568569

569-
kfree(ci->i_symlink);
570570
while ((n = rb_first(&ci->i_fragtree)) != NULL) {
571571
frag = rb_entry(n, struct ceph_inode_frag, node);
572572
rb_erase(n, &ci->i_fragtree);

0 commit comments

Comments
 (0)