Skip to content

Commit

Permalink
[Tizen] Call mDNS resolve callback under stack lock (#19947)
Browse files Browse the repository at this point in the history
Changes in dc3862a has uncovered potential race condition in Tizen mDNS
resolver. The callback function was called outside of the Matter stack
lock. This callback might perform PASE session paring which involves
message exchanges, which requires locking. Simple fix for that is to
call the callback under the lock.
  • Loading branch information
arkq authored and pull[bot] committed Jul 2, 2022
1 parent ec43b45 commit fce8111
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/platform/Tizen/DnssdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,12 @@ void OnResolve(dnssd_error_e result, dnssd_service_h service, void * data)
dnssdService.mTextEntries = textEntries.empty() ? nullptr : textEntries.data();
dnssdService.mTextEntrySize = textEntries.size();

rCtx->mCallback(rCtx->mCbContext, &dnssdService, chip::Span<chip::Inet::IPAddress>(&ipAddr, 1), CHIP_NO_ERROR);
{ // Lock the stack mutex when calling the callback function, so that the callback
// function could safely perform message exchange (e.g. PASE session pairing).
chip::DeviceLayer::StackLock lock;
rCtx->mCallback(rCtx->mCbContext, &dnssdService, chip::Span<chip::Inet::IPAddress>(&ipAddr, 1), CHIP_NO_ERROR);
}

rCtx->mInstance->RemoveContext(rCtx);
return;

Expand Down

0 comments on commit fce8111

Please sign in to comment.