[RHEL7,COMMIT] ploop: Sanity check that raw delta is not zero-length

Submitted by Konstantin Khorenko on Feb. 11, 2020, 1:19 p.m.

Details

Message ID 202002111319.01BDJI70009838@finist-ce7.sw.ru
State New
Series "ploop: Sanity check that raw delta is not zero-length"
Headers show

Commit Message

Konstantin Khorenko Feb. 11, 2020, 1:19 p.m.
The commit is pushed to "branch-rh7-3.10.0-1062.12.1.vz7.131.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.12.1.vz7.131.1
------>
commit fa496d688cc5dfd44879b5974cdabbaa699c8cb4
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue Feb 11 16:19:18 2020 +0300

    ploop: Sanity check that raw delta is not zero-length
    
    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 da1f50465ff10..65e16aeaf66c4 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);