ubifs: fix use-after-free on symlink traversal
diff mbox series

Message ID 20190326014038.GW2217@ZenIV.linux.org.uk
State New
Headers show
Series
  • ubifs: fix use-after-free on symlink traversal
Related show

Commit Message

Al Viro March 26, 2019, 1:40 a.m. UTC
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>
---

Patch
diff mbox series

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 8dc2818fdd84..12628184772c 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -276,14 +276,12 @@  static void ubifs_i_callback(struct rcu_head *head)
 {
 	struct inode *inode = container_of(head, struct inode, i_rcu);
 	struct ubifs_inode *ui = ubifs_inode(inode);
+	kfree(ui->data);
 	kmem_cache_free(ubifs_inode_slab, ui);
 }
 
 static void ubifs_destroy_inode(struct inode *inode)
 {
-	struct ubifs_inode *ui = ubifs_inode(inode);
-
-	kfree(ui->data);
 	call_rcu(&inode->i_rcu, ubifs_i_callback);
 }