Skip to content

Commit 4fdcfab

Browse files
author
Al Viro
committed
jffs2: 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>
1 parent 9e98c67 commit 4fdcfab

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

fs/jffs2/readinode.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,11 +1414,6 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f)
14141414

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

1417-
if (f->target) {
1418-
kfree(f->target);
1419-
f->target = NULL;
1420-
}
1421-
14221417
fds = f->dents;
14231418
while(fds) {
14241419
fd = fds;

fs/jffs2/super.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ static struct inode *jffs2_alloc_inode(struct super_block *sb)
4747
static void jffs2_i_callback(struct rcu_head *head)
4848
{
4949
struct inode *inode = container_of(head, struct inode, i_rcu);
50-
kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode));
50+
struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
51+
52+
kfree(f->target);
53+
kmem_cache_free(jffs2_inode_cachep, f);
5154
}
5255

5356
static void jffs2_destroy_inode(struct inode *inode)

0 commit comments

Comments
 (0)