linaro-swg / linux

Linux kernel source tree
Other
41 stars 79 forks source link

[TEE driver] avoid kmemleak false alarm #99

Closed soso7885 closed 2 years ago

soso7885 commented 2 years ago

Hi

Currently the "optee_enable_shm_cache" cause the kmemleak false alarm, This API pre alloc shm buffer for better performance, but if linux kernel enable CONFIG_DEBUG_KMEMLEAK, show the leak record likes:

cat /sys/kernel/debug/kmemleak

unreferenced object 0xffffff8108ecd600 (size 128): comm "android.hardwar", pid 229, jiffies 4294893003 (age 919.340s) hex dump (first 32 bytes): 00 d1 ec 08 81 ff ff ff 00 d0 5c 07 01 00 00 00 ............... 00 d0 5c 07 81 ff ff ff 00 10 00 00 00 00 00 00 ............... backtrace: [<000000001e549164>] optee_handle_rpc+0x78/0x828 [optee] [<0000000092ae58d4>] optee_do_call_with_arg+0x1ec/0x330 [optee] [<00000000385ef677>] optee_open_session+0x1bc/0x28c [optee] [<0000000038996787>] tee_ioctl_open_session+0x16c/0x5a0 [tee] [<0000000080aeafb5>] tee_ioctl+0x78/0x450 [tee] [<0000000074d1f571>] __arm64_compat_sys_ioctl+0x170/0x584 [<00000000b390ddec>] el0_svc_common+0xc8/0x22c [<00000000131581a6>] el0_svc_compat_handler+0x1c/0x28

the backtrace should be like that: optee_handle_rpc handle_rpc_func_cmd handle_rpc_func_cmd_shm_alloc tee_shm_alloc shm = kzalloc(sizeof(*shm), GFP_KERNEL);

is any better way to avoid it ? or just disable the shm cache method if CONFIG_DEBUG_KMEMLEAK=y ?

thanks

jenswi-linaro commented 2 years ago

Do you have 6add87fdae9b ("optee: Suppress false positive kmemleak report in optee_handle_rpc()"), from v5.16?

soso7885 commented 2 years ago

yes, this patch should fix it, thanks