[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 09/17] qcow2/overlaps: Protect snapshot table
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v4 09/17] qcow2/overlaps: Protect snapshot table |
Date: |
Mon, 4 May 2015 21:15:45 +0200 |
Keep track of the snapshot table in the metadata list to protect it
against accidental modifications.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block/qcow2-snapshot.c | 10 ++++++++++
block/qcow2.c | 6 ++++++
2 files changed, 16 insertions(+)
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index aa211e3..966982f 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -262,8 +262,18 @@ static int qcow2_write_snapshots(BlockDriverState *bs)
/* free the old snapshot table */
qcow2_free_clusters(bs, s->snapshots_offset, s->snapshots_size,
QCOW2_DISCARD_SNAPSHOT);
+
+ qcow2_metadata_list_remove(bs, s->snapshots_offset,
+ size_to_clusters(s, s->snapshots_size),
+ QCOW2_OL_SNAPSHOT_TABLE);
+
s->snapshots_offset = snapshots_offset;
s->snapshots_size = snapshots_size;
+
+ qcow2_metadata_list_enter(bs, s->snapshots_offset,
+ size_to_clusters(s, s->snapshots_size),
+ QCOW2_OL_SNAPSHOT_TABLE);
+
return 0;
fail:
diff --git a/block/qcow2.c b/block/qcow2.c
index 1e173a3..4e7005e 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -803,6 +803,12 @@ static int qcow2_open(BlockDriverState *bs, QDict
*options, int flags,
error_setg(errp, "Invalid snapshot table offset");
goto fail;
}
+ if (header.nb_snapshots) {
+ qcow2_metadata_list_enter(bs, header.snapshots_offset,
+ size_to_clusters(s, header.nb_snapshots *
+ sizeof(QCowSnapshotHeader)),
+ QCOW2_OL_SNAPSHOT_TABLE);
+ }
/* read the level 1 table */
if (header.l1_size > QCOW_MAX_L1_SIZE / sizeof(uint64_t)) {
--
2.3.7
- [Qemu-devel] [PATCH v4 00/17] qcow2: Add new overlap check functions, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 02/17] qcow2: Pull up overlap check option evaluation, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 01/17] qcow2: Add new overlap check functions, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 03/17] qcow2: Create metadata list, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 04/17] qcow2/overlaps: Protect image header, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 05/17] qcow2/overlaps: Protect refcount table, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 06/17] qcow2/overlaps: Protect refcount blocks, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 07/17] qcow2/overlaps: Protect active L1 table, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 08/17] qcow2/overlaps: Protect active L2 tables, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 09/17] qcow2/overlaps: Protect snapshot table,
Max Reitz <=
- [Qemu-devel] [PATCH v4 10/17] qcow2/overlaps: Protect inactive L1 tables, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 11/17] qcow2/overlaps: Protect inactive L2 tables, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 12/17] qcow2: Use new metadata overlap check function, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 13/17] qcow2/overlaps: Add "memory limit reached" event, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 15/17] qcow2: Add overlap structure memory size options, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 14/17] qcow2/overlaps: Add memory usage limit, Max Reitz, 2015/05/04
- [Qemu-devel] [PATCH v4 16/17] qapi: Expose new qcow2 overlap check options, Max Reitz, 2015/05/04