Skip to content
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

Fix: race upon task->real_parent accessing #171

Merged
merged 1 commit into from
Jan 20, 2022
Merged

Fix: race upon task->real_parent accessing #171

merged 1 commit into from
Jan 20, 2022

Conversation

shenping-bd
Copy link
Collaborator

@shenping-bd shenping-bd commented Jan 20, 2022

get_process_socket() and smith_get_pid_tree() could grab a task_struct
which is being released, i.e. increment task->usage while it's already
zero-valued. The race window is very small.

The solution is: don't increment task->usage if it's already zero to
avoid the race conditions. Any access of task->real_parent also has
the same risk of races, but not fatal, only gets inconsistent data.

Signed-off-by: shenping.matt shenping.matt@bytedance.com

A similar PR may already be submitted!
Please search among the Pull request before creating one.

Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:

For more information, see the CONTRIBUTING guide.

Summary

This PR fixes/implements the following bugs/features

  • Bug 1
  • Bug 2
  • Feature 1
  • Feature 2
  • Breaking changes

Explain the motivation for making this change. What existing problem does the pull request solve?

Test plan (required)

Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.

Code formatting

Closing issues

Fixes #

get_process_socket() and smith_get_pid_tree() could grab a task_struct
which is being released, i.e. increment task->usage while it's already
zero-valued. The race window is very small.

The solution is: don't increment task->usage if it's already zero to
avoid the race conditions. Any access of task->real_parent also has
the same risk of races, but not fatal, only gets inconsistent data.

Signed-off-by: shenping.matt <shenping.matt@bytedance.com>
@EBWi11 EBWi11 merged commit 73c88d2 into main Jan 20, 2022
@EBWi11 EBWi11 deleted the b_task_ref_nz branch January 20, 2022 06:13
@EBWi11 EBWi11 restored the b_task_ref_nz branch January 20, 2022 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants