Skip to content

Commit 9a8dee3

Browse files
ceph: avoid putting the realm twice when decoding snaps fails
jira VULN-65927 cve CVE-2022-49770 commit-author Xiubo Li <[email protected]> commit 51884d1 upstream-diff Absence of the following commit caused a merge conflict: 2e58664 ("ceph: do not update snapshot context when there is no new snapshot") 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]> (cherry picked from commit 51884d1) Signed-off-by: Pratham Patel <[email protected]>
1 parent d93daad commit 9a8dee3

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
@@ -665,14 +665,15 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,
665665
struct ceph_mds_snap_realm *ri; /* encoded */
666666
__le64 *snaps; /* encoded */
667667
__le64 *prior_parent_snaps; /* encoded */
668-
struct ceph_snap_realm *realm = NULL;
668+
struct ceph_snap_realm *realm;
669669
struct ceph_snap_realm *first_realm = NULL;
670670
int invalidate = 0;
671671
int err = -ENOMEM;
672672
LIST_HEAD(dirty_realms);
673673

674674
dout("update_snap_trace deletion=%d\n", deletion);
675675
more:
676+
realm = NULL;
676677
ceph_decode_need(&p, e, sizeof(*ri), bad);
677678
ri = p;
678679
p += sizeof(*ri);

0 commit comments

Comments
 (0)