From 44ab3c2172f6d6587b82e439dcd3b8498a3c983a Mon Sep 17 00:00:00 2001 From: Yong Ding Date: Fri, 19 Mar 2021 13:58:24 +0800 Subject: [PATCH] soc: qcom: hab: add the buffer size sanity check for exporting a buffer hab only supports multiple page size memory export, so the exported buffer size must be N * PAGE_SIZE w/ N > 0. Change-Id: I0b59639b3ca8842ccd49deb6b32f29f68da0b7a4 Signed-off-by: Yao Jiang Signed-off-by: Yong Ding --- drivers/soc/qcom/hab/hab_mimex.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/soc/qcom/hab/hab_mimex.c b/drivers/soc/qcom/hab/hab_mimex.c index 810d4ded7b34..5b668a703a08 100644 --- a/drivers/soc/qcom/hab/hab_mimex.c +++ b/drivers/soc/qcom/hab/hab_mimex.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ #include "hab.h" #include "hab_grantable.h" @@ -241,7 +241,8 @@ int hab_mem_export(struct uhab_context *ctx, int page_count; int compressed = 0; - if (!ctx || !param || !param->buffer) + if (!ctx || !param || !param->buffer || !param->sizebytes + || ((param->sizebytes % PAGE_SIZE) != 0)) return -EINVAL; vchan = hab_get_vchan_fromvcid(param->vcid, ctx, 0);