Skip to content

Commit

Permalink
ceph: fix use-after-free on symlink traversal
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Jeff Layton <[email protected]>
Signed-off-by: Ilya Dryomov <[email protected]>
  • Loading branch information
Al Viro authored and idryomov committed Mar 27, 2019
1 parent 187df76 commit daf5cc2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ceph/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ static void ceph_i_callback(struct rcu_head *head)
struct inode *inode = container_of(head, struct inode, i_rcu);
struct ceph_inode_info *ci = ceph_inode(inode);

kfree(ci->i_symlink);
kmem_cache_free(ceph_inode_cachep, ci);
}

Expand Down Expand Up @@ -566,7 +567,6 @@ void ceph_destroy_inode(struct inode *inode)
}
}

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

0 comments on commit daf5cc2

Please sign in to comment.