Skip to content

dax: fix race condition on the tuning buffer - #11056

Draft
checkupup wants to merge 2 commits into
thesofproject:mainfrom
checkupup:main_dax_fixes
Draft

dax: fix race condition on the tuning buffer#11056
checkupup wants to merge 2 commits into
thesofproject:mainfrom
checkupup:main_dax_fixes

Conversation

@checkupup

Copy link
Copy Markdown
Contributor

No description provided.

It is necessary cause p_dax is used in dax.c now.

Signed-off-by: Jun Lai <jun.lai@dolby.com>
@sofci

sofci commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

reply test this please to run this test once

size);
if (adapter_data->tmp_tuning_buf.addr && adapter_data->tmp_tuning_buf.size > 0) {
dax_buffer_release(mod, &dax_ctx->tuning_file_buffer);
dax_ctx->tuning_file_buffer = adapter_data->tmp_tuning_buf;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how this fixes the race... dax_buffer_release() in line 253 itself is racy - it frees directly the dax_buff->addr pointer and only then assigns NULL to it, so there's a use-after-free potential there. Also here line 254 isn't atomic - it's still the same old memcpy(), so, not very clear to me how this commit fixes any racing issues?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uha, my bad, I miss some changes. A spinlock is added to protect access to set_tuning_file.

set_tuning_file now works in process thread which has lower thread priority than set configuration, hence I dont add a spinlock in dax_set_param_wrapper.

for dax_buffer_release(), use-after-free will not happen because tuning buffer is only used in process thread through dax_find_params interface. They are always in the same thread.

While the tuning buffer is being updated, it may also
be being used simultaneously in the process thread.

Signed-off-by: Jun Lai <jun.lai@dolby.com>
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.

3 participants