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

mesh: Fix possible race condition and other issues #28

Merged
merged 5 commits into from Apr 10, 2018

Conversation

michal-narajowski
Copy link

@michal-narajowski michal-narajowski commented Apr 6, 2018

There's a small but real chance of a race-condition when sending
messages to the local node (through the local network interface) that
expected parameters will be NULL in the message handles. Add
appropriate NULL checks for them.

Fix Node Identity advertising with PB-ADV:
The Node Identity advertising should only be automatically enabled when provisioning happened over PB-GATT, but not when it happened over PB-ADV. Move the enabling of Node Identity to the provisioning code, where we know the bearer that was used (this information does not get passed to the bt_mesh_provision function).

@michal-narajowski michal-narajowski changed the title mesh: Fix possible NULL dereferences in client models mesh: Fix possible race condition and other issues Apr 10, 2018
Michał Narajowski added 4 commits April 10, 2018 12:32
It's not always guaranteed that param->status will be non-NULL,
especially not after a subsequent patch to fix a race condition with
the response waiting.
If the thread that sends the configuration messages has low priority
and is sending to the local node (a common use case currently) it's
possible that the response arrives before the cli->op_* state
variables are set, resulting in the message never getting properly
processed and the client API call timing out.

Split the initialization into a separete cli_prepare() call and add a
cli_reset() to clean up the variables in case of premature completion
of the client operation (e.g. due to message sending failure).
There's a small but real chance of a race-condition when sending
messages to the local node (through the local network interface) that
expected parameters will be NULL in the message handles. Add
appropriate NULL checks for them.
The Node Identity advertising should only be automatically enabled
when provisioning happened over PB-GATT, but not when it happened over
PB-ADV. Move the enabling of Node Identity to the provisioning code,
where we know the bearer that was used (this information does not get
passed to the bt_mesh_provision function).
Copy link
Contributor

@rymanluk rymanluk left a comment

Choose a reason for hiding this comment

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

looks good to me

@michal-narajowski michal-narajowski merged commit 4d90654 into apache:master Apr 10, 2018
@michal-narajowski michal-narajowski deleted the mesh_cli branch April 10, 2018 11:35
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

3 participants