-
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
core: fix race in mobj_reg_shm_dec_map() #6137
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Another fix for #6120 |
f9c6a65
to
64bf7b9
Compare
Updated the commit message for |
omasse-linaro
approved these changes
Jun 27, 2023
jforissier
reviewed
Jun 27, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-by: Jerome Forissier <[email protected]>
64bf7b9
to
be4b7e1
Compare
Tag applied. |
|
Fixes a race in mobj_reg_shm_dec_map() when r->mm is NULL. This is similar to the race fixed by commit 06ea466 ("core: fix race in mobj_reg_shm_inc_map()"), but with one more possibility. The problem goes like: A. Thread 1 calls mobj_reg_shm_dec_map() at the same time as thread 2 calls mobj_reg_shm_inc_map(). B. Thread 1 decreases mapcount to zero and tries to take the spinlock, but thread 1 is suspended before it has acquired the spinlock. C. Thread 2 sees that mapcount is zero and takes the spinlock and maps the memory. D. Thread 2 calls mobj_reg_shm_dec_map(), mapcount reaches zero again and the shared memory is unmapped and r->mm is set to NULL. E. Thread 1 is finally resumed and acquires the spinlock, mapcount is still zero but r->mm is also NULL. To fix the problem at step E above check that r->mm is still non-NULL. Note that the same fix isn't needed for ffa_dec_map() since unmap_helper() checks that mf->mm is non-NULL first. Fixes: 06ea466 ("core: fix race in mobj_reg_shm_inc_map()") Signed-off-by: Jens Wiklander <[email protected]> Reviewed-by: Jerome Forissier <[email protected]> Acked-by: Olivier Masse <[email protected]>
be4b7e1
to
6859eb9
Compare
Tag applied |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a race in mobj_reg_shm_dec_map() when r->mm is NULL. This is similar to the race fixed by commit 06ea466 ("core: fix race in mobj_reg_shm_inc_map()"), but with one more possibility.
The problem goes like:
A. Thread 1 calls mobj_reg_shm_dec_map() at the same time as thread 2
calls mobj_reg_shm_inc_map().
B. Thread 1 decreases mapcount to zero and tries to take the spinlock,
but thread 1 is suspended before it has acquired the spinlock.
C. Thread 2 sees that mapcount is zero and takes the spinlock and maps
the memory.
D. Thread 2 calls mobj_reg_shm_dec_map(), mapcount reaches zero again
and the shared memory is unmapped and r->mm is set to NULL.
E. Thread 1 is finally resumed and acquires the spinlock, mapcount is still
zero but r->mm is also NULL.
To fix the problem at step E above check that r->mm is still non-NULL.
Fixes: 06ea466 ("core: fix race in mobj_reg_shm_inc_map()")