-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optee 3.21.0: core: mobj_reg_shm_dec_map #6120
Comments
Each call to I believe the real problem is that the |
indeed, I see that you have fix a race issue in mobj_reg_shm_inc_map, but why not just get the reg_shm_map_lock spin lock before incrementing or decrementing the map refcount ? |
Does that fix your problem? The point with refcount_inc() and refcount_dec() is that they can be called without holding a lock. If we're going to hold a lock then we can access the counter directly instead. |
draft submitted here #6133 |
What's regression case 1040? |
It's a dedicated added test that ping a TA with an input shared memory. |
Thanks |
What are the steps needed to reproduce the problem on QEMU? Edit: sorry I see now that it has nothing to do with OP-TEE/optee_test#663 (which has a 1040 case by the way). I'll apply your patch and test. |
Test was done on optee os master branch at revision 504f159 OP-TEE is build with CFG_TEE_CORE_LOG_LEVEL set to 1. |
The race condition could be reproduced by running two xtest clients as follow: NB: issue could but reproduce quicker with more running xtest clients. |
Can you reproduce the problem with #6137? |
No, issue is fixed with that patch. |
Thanks, let's use #6137 instead then. |
Thanks, let's close this issue. |
Hi
I'm getting an assert in reg_shm_unmap_helper when performing a simple stress test with two threads which invoke in a infinite loop a ping command to a TA with an input shared memory as parameter.
E/TC:1 1 assertion 'r->mm' failed at core/arch/arm/mm/mobj_dyn_shm.c:117 <reg_s>
E/TC:1 1 Panic at core/kernel/assert.c:28 <_assert_break>
E/TC:1 1 TEE load address @ 0xe1b32000
it seems that reg_shm_unmap_helper is called by mobj_reg_shm_dec_map when the mapcount reach 0 with an already unmapped object.
looking at the refcount.h (core/include/kernel/refcount.h) it is specify that when refcount_dec(r) is true, the object o is uninitialize if refcount_val(r) is still 0 AND o is not NULL.
however mobj_reg_shm_dec_map in core/arch/arm/mm/mobj_dyn_shm.c do not check if r->mm is not NULL before calling reg_shm_unmap_helper.
doing so, my stress test run fine without assert.
could we have a race condition when two threads call to mobj_reg_shm_dec_map occur at the same time ?
after doing refcount_dec on mapcount, thread 1 take the lock before thread 2 and call reg_shm_unmap_helper and release the lock.
thread 2 then take the lock and call reg_shm_unmap_helper as well, which fail with assert(r->mm).
The text was updated successfully, but these errors were encountered: