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

shadow/rdpsnd: Fix race condition in rdpsnd channel server. #3357

Merged
merged 1 commit into from May 23, 2016

Conversation

realjiangms
Copy link
Contributor

The output buffer and format parameters are not protected. This cause some data inconsistency if rdpsnd has own thread.

A typical race scenario is:

  1. Stand Alone rdpsnd server thread: In rdpsnd_server_select_format(), Run to line:

context->selected_client_format = client_format_index; // Now context->priv->out_buffer is still 0

  1. Another thread: calls rdpsnd_server_send_samples().
    It will pass the check of "if (context->selected_client_format < 0)", but will crash when try to copy samples to context->priv->out_buffer

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/1231/

{
WLog_ERR(TAG, "rdpsnd_server_send_audio_pdu failed with error %lu", error);
return error;
Copy link
Member

Choose a reason for hiding this comment

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

I think error should be set here since it is initialized with CHANNEL_RC_OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is actually correct. Here error = rdpsnd_server_send_audio_pdu(context, 0). It fail only when error is not CHANNEL_RC_OK

@bmiklautz
Copy link
Member

@realjiangms except my comment +1. Thanks.

…t buffer and format parameters are not protected. This cause some data inconsistence if rdpsnd has own thread
@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/1232/

@@ -62,7 +62,6 @@ static void rdpsnd_activated(RdpsndServerContext* context)
}

context->SelectFormat(context, i);
context->SetVolume(context, 0x7FFF, 0x7FFF);
Copy link
Member

Choose a reason for hiding this comment

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

Any specific reason to remove this one? Does not look like it is related to the locking issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually there's no reason to have this line to set client volume in rdpsnd activated handler.
I copied the code from Windows/wf_rdpsnd.c when I introduce rdpsnd for shadow server last year without much considering. So I want to remove it this time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a subsystem implementation need to set volume (future), it should post SHADOW_MSG_OUT_AUDIO_OUT_VOLUME message to clients (shadow_client_post_msg/shadow_client_boardcast_msg)

@akallabeth
Copy link
Member

@realjiangms Except my remark +1

@akallabeth akallabeth merged commit cf127eb into FreeRDP:master May 23, 2016
@realjiangms realjiangms deleted the fix_rdpsnd_race branch May 24, 2016 14:04
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.

None yet

4 participants