Add a new ioctl called TEE_IOC_SHM_REGISTER_FD to register a
shared memory from a dmabuf file descriptor.
This new ioctl will allow the Linux Kernel to register a buffer
to be used by the Secure Data Path OPTEE OS feature.
Please find more information here:
https://static.linaro.org/connect/san19/presentations/san19-107.pdf
Patch tested on Hikey 6220.
Etienne Carriere (1):
tee: new ioctl to a register tee_shm from a dmabuf file descriptor
drivers/tee/tee_core.c | 38 +++++++++++++++
drivers/tee/tee_shm.c | 99 +++++++++++++++++++++++++++++++++++++++-
include/linux/tee_drv.h | 11 +++++
include/uapi/linux/tee.h | 29 ++++++++++++
4 files changed, 175 insertions(+), 2 deletions(-)
--
2.25.0
Hi guys,
after finding that we essentially have two separate worlds for coherent sharing
of buffer through DMA-buf I thought I will tackle that problem a bit and at
least allow the framework to reject attachments which won't work.
So those patches here add a new dma_coherent flag to each DMA-buf object
telling the framework that dev_is_dma_coherent() needs to return true for an
importing device to be able to attach. Since we should always have a fallback
path this should give userspace the chance to still keep the use case working,
either by doing a CPU copy instead or reversing the roles of exporter and
importer.
For DRM and most V4L2 devices I then fill in the dma_coherent flag based on the
return value of dev_is_dma_coherent(). Exporting drivers are allowed to clear
the flag for their buffers if special handling like the USWC flag in amdgpu or
the uncached allocations for radeon/nouveau are in use.
Additional to that importers can also check the flag if they have some
non-snooping operations like the special scanout case for amdgpu for example.
The patches are only smoke tested and the solution isn't ideal, but as far as
I can see should at least keep things working.
Please review and/or comment,
Christian.
On Fri, Dec 23, 2022 at 10:54:37PM +0800, Greg KH wrote:
>> diff --git a/drivers/usb/gadget/udc/aspeed_udc.c b/drivers/usb/gadget/udc/aspeed_udc.c
>> index 01968e2167f9..7dc2457c7460 100644
>> --- a/drivers/usb/gadget/udc/aspeed_udc.c
>> +++ b/drivers/usb/gadget/udc/aspeed_udc.c
>> @@ -1516,6 +1516,10 @@ static int ast_udc_probe(struct platform_device *pdev)
>> AST_UDC_EP_DMA_SIZE *
>> AST_UDC_NUM_ENDPOINTS,
>> &udc->ep0_buf_dma, GFP_KERNEL);
>> + if (!udc->ep0_buf) {
>> + rc = -ENOMEM;
>> + goto err;
>> + }
>>
>> udc->gadget.speed = USB_SPEED_UNKNOWN;
>> udc->gadget.max_speed = USB_SPEED_HIGH;
>> --
>> 2.25.1
>>
>
> Why is this just a duplicate of the patch previously submitted here:
> https://lore.kernel.org/r/20221125092833.74822-1-yuancan@huawei.com
>
> confused,
>
> greg k-h
Yes, it is the same as mine.
As the previous patch had not been merged into the Linux kernel,
my tool found the same error and report it.
And both of us chose the most concise way to fix the error.
That is why the patches are the same.
Thanks,
Jiang
Yes, it is the same as mine.
As the previous patch had not been merged into the Linux kernel,
my tool found the same error and report it.
And both of us chose the most concise way to fix the error.
That is why the patches are the same.
Thanks,
Jiang
Add the check for the return value of dma_alloc_coherent in order to
avoid NULL pointer dereference.
This flaw was found using an experimental static analysis tool we are
developing, APP-Miner, which has not been disclosed.
The allyesconfig build using GCC 9.3.0 shows no new warning. As we
don't have a UDC device to test with, no runtime testing was able to
be performed.
Signed-off-by: Jiasheng Jiang <jiasheng(a)iscas.ac.cn>
---
Changelog:
v2 -> v3:
1. Add information of finding tool and tests to commit message.
v1 -> v2:
1. Add "goto err;" when allocation fails.
---
drivers/usb/gadget/udc/aspeed_udc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/usb/gadget/udc/aspeed_udc.c b/drivers/usb/gadget/udc/aspeed_udc.c
index 01968e2167f9..7dc2457c7460 100644
--- a/drivers/usb/gadget/udc/aspeed_udc.c
+++ b/drivers/usb/gadget/udc/aspeed_udc.c
@@ -1516,6 +1516,10 @@ static int ast_udc_probe(struct platform_device *pdev)
AST_UDC_EP_DMA_SIZE *
AST_UDC_NUM_ENDPOINTS,
&udc->ep0_buf_dma, GFP_KERNEL);
+ if (!udc->ep0_buf) {
+ rc = -ENOMEM;
+ goto err;
+ }
udc->gadget.speed = USB_SPEED_UNKNOWN;
udc->gadget.max_speed = USB_SPEED_HIGH;
--
2.25.1