All of lore.kernel.org
 help / color / mirror / Atom feed
[parent not found: < <CAHUa44Hm4WNg3JE6phOo_qcKmq3Pq8N1d6ntStQ4nh6DnpqLFw@mail.gmail.com>]
[parent not found: < <CAFA6WYPEjQDyt4g-dftMyzd8RKkagDs3hj5ThQfvdpmmV5dF7A@mail.gmail.com>]
[parent not found: < <CAFA6WYNh6WmkeZFCOPJpu69ypyWc7itMBdhTg3yqnH0MbOhFcQ@mail.gmail.com>]
[parent not found: < <CAFA6WYPfjGqY6GJqLmrhU7CBjBTEYZzuCptHLJe2aEGUM_kOBA@mail.gmail.com>]
[parent not found: < <CAFA6WYM1oCs9gE4b5DaRez+jhCXPb_c25ausj0yWdS5tawX0MA@mail.gmail.com>]
[parent not found: < <CAFA6WYNZAbDpFJVnmNGm7aqCc82ZQEeUXvVW4r1+svm8rfRn7w@mail.gmail.com>]
[parent not found: < <CAN5uoS9xv-kKpC4E6-muYdh59g8XPSDfbquk5=DbQ4GmiVk-PA@mail.gmail.com>]
[parent not found: < <CAFA6WYMOHUEve8cbZdwzsijer3fRsy=50q67ndsC6U2JD6gK5Q@mail.gmail.com>]
[parent not found: <=?utf-8?q?=3CPH0PR11MB507734019F54C2BB24D1456F95719=40PH0PR11MB?= =?utf-8?q?5077=2Enamprd11=2Eprod=2Eoutlook=2Ecom=3E?=>]
[parent not found: < <CAFA6WYN+0751=feb-O9Drmm5V_Gz-1qsgiHmLsA88=49MoK_dg@mail.gmail.com>]
* Re: [PATCH] optee: Suppress false positive kmemleak report in optee_handle_rpc()
@ 2021-12-09 15:31 Wang, Xiaolei
  0 siblings, 0 replies; 54+ messages in thread
From: Wang, Xiaolei @ 2021-12-09 15:31 UTC (permalink / raw)
  To: op-tee

[-- Attachment #1: Type: text/plain, Size: 3303 bytes --]

-----Original Message-----
From: Sumit Garg<sumit.garg@linaro.org>  
Sent: Thursday, December 9, 2021 7:41 PM
To: Wang, Xiaolei<Xiaolei.Wang@windriver.com>
Cc:jens.wiklander(a)linaro.org;op-tee(a)lists.trustedfirmware.org;linux-kernel(a)vger.kernel.org
Subject: Re: [PATCH] optee: Suppress false positive kmemleak report in optee_handle_rpc()

[Please note: This e-mail is from an EXTERNAL e-mail address]

On Mon, 6 Dec 2021 at 17:35, Xiaolei Wang<xiaolei.wang@windriver.com>  wrote:

> We observed the following kmemleak report:
> unreferenced object 0xffff000007904500 (size 128):
>    comm "swapper/0", pid 1, jiffies 4294892671 (age 44.036s)
>    hex dump (first 32 bytes):
>      00 47 90 07 00 00 ff ff 60 00 c0 ff 00 00 00 00  .G......`.......
>      60 00 80 13 00 80 ff ff a0 00 00 00 00 00 00 00  `...............
>    backtrace:
>      [<000000004c12b1c7>] kmem_cache_alloc+0x1ac/0x2f4
>      [<000000005d23eb4f>] tee_shm_alloc+0x78/0x230
>      [<00000000794dd22c>] optee_handle_rpc+0x60/0x6f0
>      [<00000000d9f7c52d>] optee_do_call_with_arg+0x17c/0x1dc
>      [<00000000c35884da>] optee_open_session+0x128/0x1ec
>      [<000000001748f2ff>] tee_client_open_session+0x28/0x40
>      [<00000000aecb5389>] optee_enumerate_devices+0x84/0x2a0
>      [<000000003df18bf1>] optee_probe+0x674/0x6cc
>      [<000000003a4a534a>] platform_drv_probe+0x54/0xb0
>      [<000000000c51ce7d>] really_probe+0xe4/0x4d0
>      [<000000002f04c865>] driver_probe_device+0x58/0xc0
>      [<00000000b485397d>] device_driver_attach+0xc0/0xd0
>      [<00000000c835f0df>] __driver_attach+0x84/0x124
>      [<000000008e5a429c>] bus_for_each_dev+0x70/0xc0
>      [<000000001735e8a8>] driver_attach+0x24/0x30
>      [<000000006d94b04f>] bus_add_driver+0x104/0x1ec
>
> This is not a memory leak because we pass the share memory pointer to
> secure world and would get it from secure world before releasing it.
>
> IMO, we need to cross-check optee-os if it's responsible for leaking kernel memory.

Hi Sumit

You mean we need to check whether there is a real memory leak,

if being secure world just allocates kernel memory via 
OPTEE_SMC_RPC_FUNC_ALLOC

and until the end, there is no free it via OPTEE_SMC_RPC_FUNC_FREE,

then we should judge it as a memory leak.


thanks

xiaolei


>
>
> -Sumit
>
>> Signed-off-by: Xiaolei Wang<xiaolei.wang@windriver.com>
>> ---
>>   drivers/tee/optee/smc_abi.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
>> index 6196d7c3888f..cf2e3293567d 100644
>> --- a/drivers/tee/optee/smc_abi.c
>> +++ b/drivers/tee/optee/smc_abi.c
>> @@ -23,6 +23,7 @@
>>   #include "optee_private.h"
>>   #include "optee_smc.h"
>>   #include "optee_rpc_cmd.h"
>> +#include <linux/kmemleak.h>
>>   #define CREATE_TRACE_POINTS
>>   #include "optee_trace.h"
>>
>> @@ -783,6 +784,7 @@ static void optee_handle_rpc(struct tee_context *ctx,
>>                          param->a4 = 0;
>>                          param->a5 = 0;
>>                  }
>> +               kmemleak_not_leak(shm);
>>                  break;
>>          case OPTEE_SMC_RPC_FUNC_FREE:
>>                  shm = reg_pair_to_ptr(param->a1, param->a2);
>> --
>> 2.25.1
>>

^ permalink raw reply	[flat|nested] 54+ messages in thread
* [PATCH] optee: Suppress false positive kmemleak report in optee_handle_rpc()
@ 2021-12-06 12:05 ` Xiaolei Wang
  0 siblings, 0 replies; 54+ messages in thread
From: Xiaolei Wang @ 2021-12-06 12:05 UTC (permalink / raw)
  To: op-tee

[-- Attachment #1: Type: text/plain, Size: 2077 bytes --]

We observed the following kmemleak report:
unreferenced object 0xffff000007904500 (size 128):
  comm "swapper/0", pid 1, jiffies 4294892671 (age 44.036s)
  hex dump (first 32 bytes):
    00 47 90 07 00 00 ff ff 60 00 c0 ff 00 00 00 00  .G......`.......
    60 00 80 13 00 80 ff ff a0 00 00 00 00 00 00 00  `...............
  backtrace:
    [<000000004c12b1c7>] kmem_cache_alloc+0x1ac/0x2f4
    [<000000005d23eb4f>] tee_shm_alloc+0x78/0x230
    [<00000000794dd22c>] optee_handle_rpc+0x60/0x6f0
    [<00000000d9f7c52d>] optee_do_call_with_arg+0x17c/0x1dc
    [<00000000c35884da>] optee_open_session+0x128/0x1ec
    [<000000001748f2ff>] tee_client_open_session+0x28/0x40
    [<00000000aecb5389>] optee_enumerate_devices+0x84/0x2a0
    [<000000003df18bf1>] optee_probe+0x674/0x6cc
    [<000000003a4a534a>] platform_drv_probe+0x54/0xb0
    [<000000000c51ce7d>] really_probe+0xe4/0x4d0
    [<000000002f04c865>] driver_probe_device+0x58/0xc0
    [<00000000b485397d>] device_driver_attach+0xc0/0xd0
    [<00000000c835f0df>] __driver_attach+0x84/0x124
    [<000000008e5a429c>] bus_for_each_dev+0x70/0xc0
    [<000000001735e8a8>] driver_attach+0x24/0x30
    [<000000006d94b04f>] bus_add_driver+0x104/0x1ec

This is not a memory leak because we pass the share memory pointer
to secure world and would get it from secure world before releasing it.

Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
---
 drivers/tee/optee/smc_abi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
index 6196d7c3888f..cf2e3293567d 100644
--- a/drivers/tee/optee/smc_abi.c
+++ b/drivers/tee/optee/smc_abi.c
@@ -23,6 +23,7 @@
 #include "optee_private.h"
 #include "optee_smc.h"
 #include "optee_rpc_cmd.h"
+#include <linux/kmemleak.h>
 #define CREATE_TRACE_POINTS
 #include "optee_trace.h"
 
@@ -783,6 +784,7 @@ static void optee_handle_rpc(struct tee_context *ctx,
 			param->a4 = 0;
 			param->a5 = 0;
 		}
+		kmemleak_not_leak(shm);
 		break;
 	case OPTEE_SMC_RPC_FUNC_FREE:
 		shm = reg_pair_to_ptr(param->a1, param->a2);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2021-12-16 14:55 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] < <CAFA6WYPd+SLT+XZgLPVjLph27P1D5RpYuLwNu4KC+2nOQH07_Q@mail.gmail.com>
2021-12-13 13:04 ` [PATCH] optee: Suppress false positive kmemleak report in optee_handle_rpc() Daniel Thompson
2021-12-13 13:04   ` Daniel Thompson
2021-12-14  7:03   ` Sumit Garg
2021-12-14  7:03     ` Sumit Garg
     [not found] < <CAHUa44Hm4WNg3JE6phOo_qcKmq3Pq8N1d6ntStQ4nh6DnpqLFw@mail.gmail.com>
2021-12-15 13:42 ` Sumit Garg
2021-12-15 13:42   ` Sumit Garg
     [not found] < <CAFA6WYPEjQDyt4g-dftMyzd8RKkagDs3hj5ThQfvdpmmV5dF7A@mail.gmail.com>
2021-12-15 10:19 ` Daniel Thompson
2021-12-15 10:19   ` Daniel Thompson
2021-12-15 12:25   ` Jens Wiklander
2021-12-15 12:25     ` Jens Wiklander
     [not found] < <CAFA6WYNh6WmkeZFCOPJpu69ypyWc7itMBdhTg3yqnH0MbOhFcQ@mail.gmail.com>
2021-12-14  7:41 ` wangxiaolei
2021-12-14  7:41   ` wangxiaolei
     [not found] < <CAFA6WYPfjGqY6GJqLmrhU7CBjBTEYZzuCptHLJe2aEGUM_kOBA@mail.gmail.com>
2021-12-14  7:11 ` wangxiaolei
2021-12-14  7:11   ` wangxiaolei
2021-12-14  7:29   ` Sumit Garg
2021-12-14  7:29     ` Sumit Garg
     [not found] < <CAFA6WYM1oCs9gE4b5DaRez+jhCXPb_c25ausj0yWdS5tawX0MA@mail.gmail.com>
2021-12-10 15:49 ` Daniel Thompson
2021-12-10 15:49   ` Daniel Thompson
2021-12-13  8:58   ` Sumit Garg
2021-12-13  8:58     ` Sumit Garg
2021-12-13  8:55 ` wangxiaolei
2021-12-13  8:55   ` wangxiaolei
2021-12-13  9:04   ` Sumit Garg
2021-12-13  9:04     ` Sumit Garg
     [not found] < <CAFA6WYNZAbDpFJVnmNGm7aqCc82ZQEeUXvVW4r1+svm8rfRn7w@mail.gmail.com>
2021-12-10 10:39 ` Etienne Carriere
2021-12-10 10:39   ` Etienne Carriere
2021-12-10 10:41 ` Jens Wiklander
2021-12-10 10:41   ` Jens Wiklander
     [not found] < <CAN5uoS9xv-kKpC4E6-muYdh59g8XPSDfbquk5=DbQ4GmiVk-PA@mail.gmail.com>
2021-12-10  9:43 ` Etienne Carriere
2021-12-10  9:43   ` Etienne Carriere
2021-12-10 10:28 ` Sumit Garg
2021-12-10 10:28   ` Sumit Garg
     [not found] < <CAFA6WYMOHUEve8cbZdwzsijer3fRsy=50q67ndsC6U2JD6gK5Q@mail.gmail.com>
2021-12-10  8:10 ` Jerome Forissier
2021-12-10  8:10   ` Jerome Forissier
2021-12-10  9:38   ` Etienne Carriere
2021-12-10  9:38     ` Etienne Carriere
2021-12-10  9:38   ` Sumit Garg
2021-12-10  9:38     ` Sumit Garg
     [not found] <=?utf-8?q?=3CPH0PR11MB507734019F54C2BB24D1456F95719=40PH0PR11MB?= =?utf-8?q?5077=2Enamprd11=2Eprod=2Eoutlook=2Ecom=3E?=>
2021-12-10  5:00 ` Sumit Garg
2021-12-10  5:00   ` Sumit Garg
     [not found] < <CAFA6WYN+0751=feb-O9Drmm5V_Gz-1qsgiHmLsA88=49MoK_dg@mail.gmail.com>
2021-12-09 14:40 ` Wang, Xiaolei
2021-12-10  4:12 ` Wang, Xiaolei
2021-12-10  4:12   ` Wang, Xiaolei
2021-12-09 15:31 Wang, Xiaolei
  -- strict thread matches above, loose matches on Subject: below --
2021-12-06 12:05 Xiaolei Wang
2021-12-06 12:05 ` Xiaolei Wang
2021-12-09 11:40 ` Sumit Garg
2021-12-09 11:40   ` Sumit Garg
2021-12-15 12:29 ` Jens Wiklander
2021-12-15 12:29   ` Jens Wiklander
2021-12-15 13:33   ` Wang, Xiaolei
2021-12-15 13:33     ` Wang, Xiaolei
2021-12-16 14:55 ` Jens Wiklander
2021-12-16 14:55   ` Jens Wiklander

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.