Skip to content

Commit db5481e

Browse files
committed
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull symlink fixes from Al Viro: "The ceph fix is already in mainline, Daniel's bpf fix is in bpf tree (1da6c4d "bpf: fix use after free in bpf_evict_inode"), the rest is in here" * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: debugfs: fix use-after-free on symlink traversal ubifs: fix use-after-free on symlink traversal jffs2: fix use-after-free on symlink traversal
2 parents 79a3aaa + 93b919d commit db5481e

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

fs/debugfs/inode.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,24 @@ static int debugfs_show_options(struct seq_file *m, struct dentry *root)
163163
return 0;
164164
}
165165

166-
static void debugfs_evict_inode(struct inode *inode)
166+
static void debugfs_i_callback(struct rcu_head *head)
167167
{
168-
truncate_inode_pages_final(&inode->i_data);
169-
clear_inode(inode);
168+
struct inode *inode = container_of(head, struct inode, i_rcu);
170169
if (S_ISLNK(inode->i_mode))
171170
kfree(inode->i_link);
171+
free_inode_nonrcu(inode);
172+
}
173+
174+
static void debugfs_destroy_inode(struct inode *inode)
175+
{
176+
call_rcu(&inode->i_rcu, debugfs_i_callback);
172177
}
173178

174179
static const struct super_operations debugfs_super_operations = {
175180
.statfs = simple_statfs,
176181
.remount_fs = debugfs_remount,
177182
.show_options = debugfs_show_options,
178-
.evict_inode = debugfs_evict_inode,
183+
.destroy_inode = debugfs_destroy_inode,
179184
};
180185

181186
static void debugfs_release_dentry(struct dentry *dentry)

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)

fs/ubifs/super.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,12 @@ static void ubifs_i_callback(struct rcu_head *head)
276276
{
277277
struct inode *inode = container_of(head, struct inode, i_rcu);
278278
struct ubifs_inode *ui = ubifs_inode(inode);
279+
kfree(ui->data);
279280
kmem_cache_free(ubifs_inode_slab, ui);
280281
}
281282

282283
static void ubifs_destroy_inode(struct inode *inode)
283284
{
284-
struct ubifs_inode *ui = ubifs_inode(inode);
285-
286-
kfree(ui->data);
287285
call_rcu(&inode->i_rcu, ubifs_i_callback);
288286
}
289287

0 commit comments

Comments
 (0)