CEPH filesystem development
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.9 24/29] ceph: fix use-after-free on symlink traversal
       [not found] <20190422194848.13049-1-sashal@kernel.org>
@ 2019-04-22 19:48 ` Sasha Levin
  0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2019-04-22 19:48 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Al Viro, Ilya Dryomov, Sasha Levin, ceph-devel

From: Al Viro <viro@zeniv.linux.org.uk>

[ Upstream commit daf5cc27eed99afdea8d96e71b89ba41f5406ef6 ]

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>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
 fs/ceph/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 30d9d9e7057d..7a4052501866 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -523,6 +523,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);
 }
 
@@ -554,7 +555,6 @@ void ceph_destroy_inode(struct inode *inode)
 		ceph_put_snap_realm(mdsc, realm);
 	}
 
-	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);
-- 
2.19.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-22 19:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20190422194848.13049-1-sashal@kernel.org>
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 24/29] ceph: fix use-after-free on symlink traversal Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox