Skip to content

Commit 7376e39

Browse files
committed
Merge tag 'ceph-for-5.1-rc3' of git://github.com/ceph/ceph-client
Pull ceph fixes from Ilya Dryomov: "A patch to avoid choking on multipage bvecs in the messenger and a small use-after-free fix" * tag 'ceph-for-5.1-rc3' of git://github.com/ceph/ceph-client: ceph: fix use-after-free on symlink traversal libceph: fix breakage caused by multipage bvecs
2 parents c6503f1 + daf5cc2 commit 7376e39

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

fs/ceph/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ static void ceph_i_callback(struct rcu_head *head)
524524
struct inode *inode = container_of(head, struct inode, i_rcu);
525525
struct ceph_inode_info *ci = ceph_inode(inode);
526526

527+
kfree(ci->i_symlink);
527528
kmem_cache_free(ceph_inode_cachep, ci);
528529
}
529530

@@ -566,7 +567,6 @@ void ceph_destroy_inode(struct inode *inode)
566567
}
567568
}
568569

569-
kfree(ci->i_symlink);
570570
while ((n = rb_first(&ci->i_fragtree)) != NULL) {
571571
frag = rb_entry(n, struct ceph_inode_frag, node);
572572
rb_erase(n, &ci->i_fragtree);

net/ceph/messenger.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor,
840840
size_t bytes)
841841
{
842842
struct ceph_bio_iter *it = &cursor->bio_iter;
843+
struct page *page = bio_iter_page(it->bio, it->iter);
843844

844845
BUG_ON(bytes > cursor->resid);
845846
BUG_ON(bytes > bio_iter_len(it->bio, it->iter));
@@ -851,7 +852,8 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor,
851852
return false; /* no more data */
852853
}
853854

854-
if (!bytes || (it->iter.bi_size && it->iter.bi_bvec_done))
855+
if (!bytes || (it->iter.bi_size && it->iter.bi_bvec_done &&
856+
page == bio_iter_page(it->bio, it->iter)))
855857
return false; /* more bytes to process in this segment */
856858

857859
if (!it->iter.bi_size) {
@@ -899,6 +901,7 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor,
899901
size_t bytes)
900902
{
901903
struct bio_vec *bvecs = cursor->data->bvec_pos.bvecs;
904+
struct page *page = bvec_iter_page(bvecs, cursor->bvec_iter);
902905

903906
BUG_ON(bytes > cursor->resid);
904907
BUG_ON(bytes > bvec_iter_len(bvecs, cursor->bvec_iter));
@@ -910,7 +913,8 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor,
910913
return false; /* no more data */
911914
}
912915

913-
if (!bytes || cursor->bvec_iter.bi_bvec_done)
916+
if (!bytes || (cursor->bvec_iter.bi_bvec_done &&
917+
page == bvec_iter_page(bvecs, cursor->bvec_iter)))
914918
return false; /* more bytes to process in this segment */
915919

916920
BUG_ON(cursor->last_piece);

0 commit comments

Comments
 (0)