Skip to content

Commit

Permalink
jffs2: 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 <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Apr 1, 2019
1 parent 9e98c67 commit 4fdcfab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 0 additions & 5 deletions fs/jffs2/readinode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,11 +1414,6 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f)

jffs2_kill_fragtree(&f->fragtree, deleted?c:NULL);

if (f->target) {
kfree(f->target);
f->target = NULL;
}

fds = f->dents;
while(fds) {
fd = fds;
Expand Down
5 changes: 4 additions & 1 deletion fs/jffs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ static struct inode *jffs2_alloc_inode(struct super_block *sb)
static void jffs2_i_callback(struct rcu_head *head)
{
struct inode *inode = container_of(head, struct inode, i_rcu);
kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode));
struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);

kfree(f->target);
kmem_cache_free(jffs2_inode_cachep, f);
}

static void jffs2_destroy_inode(struct inode *inode)
Expand Down

0 comments on commit 4fdcfab

Please sign in to comment.