lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230517031856.19660-1-xiaoming.ding@mediatek.com>
Date:   Wed, 17 May 2023 11:18:56 +0800
From:   Xiaoming Ding <xiaoming.ding@...iatek.com>
To:     Jens Wiklander <jens.wiklander@...aro.org>,
        Sumit Garg <sumit.garg@...aro.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>,
        <op-tee@...ts.trustedfirmware.org>, <linux-kernel@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-mediatek@...ts.infradead.org>
CC:     <fei.xu@...iatek.com>, <srv_heupstream@...iatek.com>,
        Xiaoming Ding <xiaoming.ding@...iatek.com>
Subject: [PATCH] tee: add FOLL_LONGTERM for CMA case when alloc shm

FOLL_LONGTERM will avoid share memory alloc from CMA region,
which may be used in secure playback case.
if part of CMA region taken by share memory for long term usage,
CMA will failed to get whole buffer back.

Signed-off-by: Xiaoming Ding <xiaoming.ding@...iatek.com>
---
 drivers/tee/tee_shm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
index 673cf0359494..ddd3947e2229 100644
--- a/drivers/tee/tee_shm.c
+++ b/drivers/tee/tee_shm.c
@@ -223,6 +223,7 @@ register_shm_helper(struct tee_context *ctx, unsigned long addr,
 	size_t num_pages;
 	void *ret;
 	int rc;
+	u32 page_flag = FOLL_WRITE;
 
 	if (!tee_device_get(teedev))
 		return ERR_PTR(-EINVAL);
@@ -255,9 +256,11 @@ register_shm_helper(struct tee_context *ctx, unsigned long addr,
 		ret = ERR_PTR(-ENOMEM);
 		goto err_free_shm;
 	}
-
+#if IS_ENABLED(CONFIG_CMA)
+	page_flag |= FOLL_LONGTERM;
+#endif
 	if (flags & TEE_SHM_USER_MAPPED)
-		rc = pin_user_pages_fast(start, num_pages, FOLL_WRITE,
+		rc = pin_user_pages_fast(start, num_pages, page_flag,
 					 shm->pages);
 	else
 		rc = shm_get_kernel_pages(start, num_pages, shm->pages);
-- 
2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ