Skip to contentSkip to conversation

vmdk: refuse to open higher version than supported

PATCH Superseded Fam Zheng 3 participants 3 messages Jun 9, 2013 – Jun 10, 2013 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 vmdk: refuse to open higher version than supported

Refuse to open higher version for safety.

Although we try to be compatible with published VMDK spec, VMware has newer version from ESXi 5.1 exported OVF/OVA, which we have no knowledge what's changed in it. And it is very likely to have more new versions in the future, so it's not safe to open them blindly.

---
 block/vmdk.c | 4 ++++
 1 file changed, 4 insertions(+)
block/vmdk.c +4 -0
index 608daaf..d9c2368 100644
@@ -558,6 +558,10 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
         header = footer.header;
     }
 
+    if (le32_to_cpu(header.version) >= 3) {
+        return -EINVAL;
+    }
+
     l1_entry_sectors = le32_to_cpu(header.num_gtes_per_gte)
                         * le64_to_cpu(header.granularity);
     if (l1_entry_sectors == 0) {
Signature · 1 line
1.8.3 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Fam Zheng

Although we try to be compatible with published VMDK spec, VMware has newer version from ESXi 5.1 exported OVF/OVA, which we have no knowledge what's changed in it. And it is very likely to have more new versions in the future, so it's not safe to open them blindly.

The best I could find was this high-level overview:
http://myvirtualcloud.net/?p=3829

Quoted 10 lines
---
 block/vmdk.c | 4 ++++
 1 file changed, 4 insertions(+)
block/vmdk.c +0 -0
index 608daaf..d9c2368 100644

block/vmdk.c static int vmdk_open_vmdk4(BlockDriverState *bs, · line 564

Quoted 7 lines
block/vmdk.c +4 -0
@@ -558,6 +558,10 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
         header = footer.header;
     }
 
+    if (le32_to_cpu(header.version) >= 3) {
+        return -EINVAL;
+    }
+

Looks fine, the VMDK 5.0 spec says header.version may be 1 or 2.

#2 lore raw
In reply to Fam Zheng

Am 09.06.2013 um 03:44 hat Fam Zheng geschrieben:

Quoted 8 lines

Refuse to open higher version for safety.

Although we try to be compatible with published VMDK spec, VMware has newer version from ESXi 5.1 exported OVF/OVA, which we have no knowledge what's changed in it. And it is very likely to have more new versions in the future, so it's not safe to open them blindly.

Yes, it's definitely a good idea to add a check.

block/vmdk.c static int vmdk_open_vmdk4(BlockDriverState *bs, · line 564

Quoted 8 lines
block/vmdk.c +4 -0
@@ -558,6 +558,10 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
         header = footer.header;
     }
 
+    if (le32_to_cpu(header.version) >= 3) {
+        return -EINVAL;
+    }
+

Other block drivers return -ENOTSUP for this case, and also call qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, ...) so that you get a meaningful error message. Can you model the VMDK code after them?

Kevin