mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-28 12:53:14 +01:00
tee: shm: fix shm leak in register_shm_helper()
register_shm_helper() allocates shm before calling
iov_iter_npages(). If iov_iter_npages() returns 0, the function
jumps to err_ctx_put and leaks shm.
This can be triggered by TEE_IOC_SHM_REGISTER with
struct tee_ioctl_shm_register_data where length is 0.
Jump to err_free_shm instead.
Fixes: 7bdee41575 ("tee: Use iov_iter to better support shared buffer registration")
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Georgiy Osokin <[email protected]>
Reviewed-by: Sumit Garg <[email protected]>
Signed-off-by: Jens Wiklander <[email protected]>
This commit is contained in:
1 parent
c15d7a2a11
commit
26682f5efc
1 file changed
+1
-1
@@ -435,7 +435,7 @@ register_shm_helper(struct tee_context *ctx, struct iov_iter *iter, u32 flags,
|
||||
num_pages = iov_iter_npages(iter, INT_MAX);
|
||||
if (!num_pages) {
|
||||
ret = ERR_PTR(-ENOMEM);
|
||||
goto err_ctx_put;
|
||||
goto err_free_shm;
|
||||
}
|
||||
|
||||
shm->pages = kzalloc_objs(*shm->pages, num_pages);
|
||||
|
||||
Reference in new issue
Block a user