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

Kirill Tkhai ktkhai at virtuozzo.com
Mon Feb 10 19:52:49 MSK 2020


https://jira.sw.ru/browse/PSBM-100675

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

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);
 




More information about the Devel mailing list