Skip to content

Commit 51884d1

Browse files
lxbszidryomov
authored andcommitted
ceph: avoid putting the realm twice when decoding snaps fails
When decoding the snaps fails it maybe leaving the 'first_realm' and 'realm' pointing to the same snaprealm memory. And then it'll put it twice and could cause random use-after-free, BUG_ON, etc issues. Cc: [email protected] Link: https://tracker.ceph.com/issues/57686 Signed-off-by: Xiubo Li <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent f86a486 commit 51884d1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/ceph/snap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,
763763
struct ceph_mds_snap_realm *ri; /* encoded */
764764
__le64 *snaps; /* encoded */
765765
__le64 *prior_parent_snaps; /* encoded */
766-
struct ceph_snap_realm *realm = NULL;
766+
struct ceph_snap_realm *realm;
767767
struct ceph_snap_realm *first_realm = NULL;
768768
struct ceph_snap_realm *realm_to_rebuild = NULL;
769769
int rebuild_snapcs;
@@ -774,6 +774,7 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,
774774

775775
dout("%s deletion=%d\n", __func__, deletion);
776776
more:
777+
realm = NULL;
777778
rebuild_snapcs = 0;
778779
ceph_decode_need(&p, e, sizeof(*ri), bad);
779780
ri = p;

0 commit comments

Comments
 (0)