[rh7] ploop: Sanity check that raw delta is not zero-length

Submitted by Kirill Tkhai on Feb. 10, 2020, 4:52 p.m.

Details

Message ID 158135355368.788320.16905214277882859711.stgit@localhost.localdomain
State New
Series "ploop: Sanity check that raw delta is not zero-length"
Headers show

Commit Message

Kirill Tkhai Feb. 10, 2020, 4:52 p.m.
https://jira.sw.ru/browse/PSBM-100675

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/fmt_raw.c |    5 +++++
 1 file changed, 5 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/fmt_raw.c b/drivers/block/ploop/fmt_raw.c
index da1f50465ff1..65e16aeaf66c 100644
--- a/drivers/block/ploop/fmt_raw.c
+++ b/drivers/block/ploop/fmt_raw.c
@@ -56,6 +56,11 @@  raw_open(struct ploop_delta * delta)
 	pos += (1 << (cluster_log + 9)) - 1;
 	delta->io.alloc_head = pos >> (cluster_log + 9);
 
+	if (!delta->io.alloc_head) {
+		pr_err("ploop: zero length file\n");
+		return -EINVAL;
+	}
+
 	if (delta->io.ops->id == PLOOP_IO_DIRECT)
 		set_bit(PLOOP_S_NO_FALLOC_DISCARD, &delta->plo->state);