-
Notifications
You must be signed in to change notification settings - Fork 200
sdt_task: Avoid use-after-free after deleting task_storage #2006
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
Conversation
6b3af3b to
337508c
Compare
75b61a9 to
a167059
Compare
a167059 to
8d18907
Compare
|
Hi @etsal , PTAL thanks! |
227b752 to
3a029c9
Compare
|
This looks ok but I will give it a closer look, thank you! |
a655c75 to
7c6cda1
Compare
|
I think if we delete then we should not be fixing up the fields of mval, this is a use-after-free. I suspect the only reason this works fine and passes verification is because of RCU preventing the use-after-free from having side effects. Can you adjust to only keep the delete call? I am also wondering whether this has performance implications. If the kernel caches task_struct allocations and reuses deallocated task struct instances often, then this patch will add a BPF map allocation on the process initialization path. This is in addition to slowing down exit(). In the end, it all depends on how much reuse there is in the kernel of task_struct. @htejun, what do you think? |
I think it's best to wait for @htejun 's feedback before adjusting it. |
|
Yeah, no need to update mval if the elem is being deleted. |
Remove redundant mval field updates after deletion. Suggested-by: Tejun Heo <tj@kernel.org> Suggested-by: Emil Tsalapatis <emil@etsalapatis.com> Co-authored-by: Po-Ying Chiu <charlie910417@gmail.com> Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
7c6cda1 to
5c16eb5
Compare
Ok, I only kept the |
In scx_task_free(), after releasing the allocator index, invoke bpf_task_storage_delete() to remove the task's entry from the BPF map.Also zero-initializemval->tidso that no stale identifier remains in local storage.Edit: Remove redundant mval field updates after deletion.