nvdimm: allow read/write zero-size namespace label
PATCH 1/1 nvdimm: allow read/write zero-size namespace label
From: Li Qiang <[email protected]>
The spec doesn't say the namespace label can't be zero when read/write it. As this is no harmful, just allow it.
--- hw/mem/nvdimm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/mem/nvdimm.c +1 -1
@@ -114,7 +114,7 @@ static void nvdimm_realize(PCDIMMDevice *dimm, Error **errp)static void nvdimm_validate_rw_label_data (NVDIMMDevice *nvdimm,uint64_t size,uint64_t offset) { -assert ((nvdimm->label_size >= size + offset) && (offset + size > offset)); +assert ((nvdimm->label_size >= size + offset) && (offset + size >= offset)); } static void nvdimm_read_label_data(NVDIMMDevice *nvdimm, void *buf,
Signature · 1 line
1.8.3.1
Quoted 6 lines · Li Qiang
From: Li Qiang <[email protected]>
The spec doesn't say the namespace label can't be zero when read/write it. As this is no harmful, just allow it.
WHY?
The spec said that the label should be at least 128K.
Hello Guangrong,
2017-01-13 17:00 GMT+08:00 Xiao Guangrong <[email protected]>:
Quoted 15 lines · Li Qiang
Quoted 8 lines
From: Li Qiang <[email protected]>
The spec doesn't say the namespace label can't be zero when read/write it. As this is no harmful, just allow it.
WHY?
The spec said that the label should be at least 128K.
Yes, the label size has a limit, but in NVDIMM_DSM_Interface_Example.pdf section 4.5.1
When the guest get namespace label data, the 'Length' is not limited, if it is 0, it will trigger
this assert.
static void nvdimm_validate_rw_label_data(NVDIMMDevice *nvdimm, uint64_t size,
uint64_t offset)
{
assert((nvdimm->label_size >= size + offset) && (offset + size >offset));
}
Though I don't know what the exact behavior of this action in real hardware. I just think it should not
trigger assert and exit when the guest get 0-size label data.
Anyway, this is just a suggestion, If my understand is wrong, just ignore this.
Thanks.
Quoted 35 lines · Li Qiang
Hello Guangrong,
2017-01-13 17:00 GMT+08:00 Xiao Guangrong <[email protected]>:
Quoted 15 lines · Li Qiang
Quoted 8 lines
From: Li Qiang <[email protected]>
The spec doesn't say the namespace label can't be zero when read/write it. As this is no harmful, just allow it.
WHY?
The spec said that the label should be at least 128K.
Yes, the label size has a limit, but in NVDIMM_DSM_Interface_Example.pdf section 4.5.1
When the guest get namespace label data, the 'Length' is not limited, if it is 0, it will trigger
this assert.static void nvdimm_validate_rw_label_data(NVDIMMDevice *nvdimm,
uint64_tsize,
uint64_toffset){ assert((nvdimm->label_size >= size + offset) && (offset + size >offset));
}
Quoted 6 lines
Though I don't know what the exact behavior of this action in real hardware. I just think it should not
trigger assert and exit when the guest get 0-size label data.Anyway, this is just a suggestion, If my understand is wrong, just ignore this.
QEMU must prevent guests from triggering assertions. If the assertion causes a core dump then host resources are consumed and this could be a denial-of-service. An assertion failure in nested virtualization can kill sibling VMs and is therefore also a denial-of-service.
The size=0 case must be handled in some way (either an error or a nop).
Stefan