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

update rotating-id-generation #22

Merged
merged 22 commits into from
Feb 18, 2021

Conversation

hnnajh
Copy link
Owner

@hnnajh hnnajh commented Feb 18, 2021

Problem

<<<<<FILL ME IN - the issue this PR is intended to address>>>>>

Summary of Changes

<<<<<FILL ME IN - what's in this PR>>>>>

Fixes #<<<<<FILL ME IN - issue number(s). If no issue, please create one>>>>>

kkasperczyk-no and others added 22 commits February 15, 2021 15:36
The nrfconnect and Zephyr platforms do not have implemented
KeyValueStoreManagerImpl.

* Added KeyValueStoreManagerImpl for Zephyr and nrfconnect
* Copied tests from examples/persistent-storage/KeyValueStorageTest.cpp
to the TestKeyValueStoreMgr unit test suite.
* Added test checking getting too small buffer error, as nrfconnect
and ESP32 platforms do not support read offsets.
* Added running TestKeyValueStoreMgr unit test on the Zephyr/nrfconnect
platform.
As of a868187 ("Reduce use of maximum-sized packet buffers (#4434)"),
network provisioning does not allocate enough space to encrypt the WiFi
credentials payload, resulting in the following error:

 CHIP:NP: Failed in sending Network Creds. error Error 4047 (0x00000FCF)

Pending API improvements to make these errors less likely, manually add
the needed extra space at allocation time.

Fixes #4823
#4856)

* Fix build warning when building the Darwin Framework on some platforms

* Address review comments
* Add a device selector view in CHIPTool iOS app

* add a TODO to remove repeated calls to set persistent storage delegate

* address TODO, and review comments
Thread provisioning message construction needs fixing in
the same way as Wi-Fi provisioning in #4868.
By the way, fix rendezvous clean up to make sure that
the app doesn't crash when trying to commision a device
for the second time.
…te (#4858)

#### Problem
The latest submodules update from #4826 has broken the current `.zap` configuration. The manufacturer specific command `MfgSpecificPing` is gone.
As a result trying to regenerate the configuration with `./scripts/tool/zap_regen_all.py` results into generated content without this command.

 #### Summary of changes
* Add back the command to `examples/chip-tool/chip-tool.zap`
* Add back the command to `src/darwin/Framework/CHIP/chip-tool.zap`
* Add back the command to `examples/all-clusters-app/all-clusters-common/all-clusters-app.zap`
* Add an adapter iterator class to bluez

* code review updates

* Fix typo in method

* Fix compilation and off-by-one error

* Ensure we unref the adapter during listing

* Remove unused variable

* Fix typos in comments - I clobbered the fixes that Justin pushed

* Fix typos in comments - I clobbered the fixes that Justin pushed

* Add support for native adapter listing

* Restyle fixes

* Update the init logic

* Do not auto-import GetAdapters. ble is a stand alone package for now

* Update typing

* Move iterator values to std::string and fix typo in linux impl

* Switch reinterpret cast to static cast
* Add Bridge app to the set of defaults apps built on mac/linux when running ./gn_build.sh

* Disable ZLL OnOff specific commands in bridge-app.zap

 #### Problem
 #4858 has updated some `.zap` files since a ZAP submodule update has made some unwanted changes to the generated content. Sadly by *saving* the `bridge-app.zap` file to disk some ZLL specific commands for the On/Off cluster got enabled...
While there is some code to handle those ZLL commands in the tree (under `src/app/clusters/zll-on-off-server`)  it has not been yet updated to compile. So one can't *just* add it to `examples/bridge-app/bridge-common/BUILD.gn`.
The simpler fix as the moment, is to revert back the `.zap` file with those commands disabled.

 #### Summary of changes
  * Add `bridge-app` to the list of apps built by default with the `gn_build.sh` script. So it will be easy to spot this kind of issue next time
  * Remove the 3 ZLL On/Off commands from the `bridge-app.zap` config file
* Enable opening of pairing window on multiple devices

* increment device ID only on successful pairing

* address review comments
* Revise PacketBufferWriter interface

#### Problem

The `PacketBufferWriter` constructor that takes a size and allocates the
`PacketBuffer` internally is awkward for some cases, and useless for the
case of an existing `PacketBufferHandle`.

#### Summary of Changes

- `PacketBufferWriter()` takes ownership of an existing `PacketBufferHandle`
  (same as `PacketBufferTLVWriter`).
- Added a `Finalize()` overload that matches that of `PacketBufferTLVWriter`.

* * fix doxygen

* * review

* * review 2
In the spec there is no "payload length".  You just have the message
length, and then determine the payload boundary based on the
encryption type (which tells you the MIC footer length).
* Add support/BytesToHex.h -> lightweight hex conversion

* Lean on stack
* Supports safe output to buffers of any size
* Support uppercase/lowercase
* Support non-nul-terminated and nul-terminated

* Add missing build file updates

* Restyled by clang-format

* Fix warning about int-vs-char

* Fix warning about int-vs-char

* Update src/lib/support/BytesToHex.h

Co-authored-by: Boris Zbarsky <[email protected]>

* Address review comments with extra errors/APIs

* Added error handling for size too large that would wrap-around
* Use flags instead of 2 bools
* Add a few helpers for the specific cases
* Replace `nul-terminated` with `null-terminated` everywhere
* Fix a few typos in comments
* Add tests for above

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Justin Wood <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
* Update GSDK from 2.7 to 3.1

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* fix cirque

* Restyled by shfmt

Co-authored-by: Restyled.io <[email protected]>
* Use unidirectional encryption keys in secure session

* Add specific methods to encrypt/decrypt using correct secure session objects

* remove const getters, and change encrypt/decrypt to const functions
* Fix unwinding on Android

Android isn't able to unwind the CHIP native stack, which interferes
with debugging. Turn on unwind tables to fix this.  Unclear if we want
this in optimized builds, but Android OS seems to be able to unwind all
of its frameworks and native libraries, so for now assume we do. There's
only a space cost, and we can revisit that later.

This is the difference between this:

backtrace:
02-16 20:49:34.628  3872  3872 F DEBUG   : backtrace:
02-16 20:49:34.628  3872  3872 F DEBUG   :       #00 pc 000000000008246c  /apex/com.android.runtime/lib64/bionic/libc.so (abort+160) (BuildId: 5812256023147338b8a9538321d4c456)
02-16 20:49:34.628  3872  3872 F DEBUG   :       #1 pc 00000000000a836c  /data/app/com.google.chip.chiptool-rPVLWEFRvE413khV9YptWg==/base.apk (offset 0x97a000) (chip::NetworkProvisioning::SendNetworkCredentials(char const*, char const*)+96)

and this:
02-16 20:56:04.323  5040  5040 F DEBUG   : backtrace:
02-16 20:56:04.323  5040  5040 F DEBUG   :       #00 pc 000000000008246c  /apex/com.android.runtime/lib64/bionic/libc.so (abort+160) (BuildId: 5812256023147338b8a9538321d4c456)
02-16 20:56:04.323  5040  5040 F DEBUG   :       #1 pc 00000000000a839c  /data/app/com.google.chip.chiptool-dz3iwqwmItgQDBBaEcevJw==/base.apk (offset 0x97a000) (chip::NetworkProvisioning::SendNetworkCredentials(char const*, char const*)+96)
02-16 20:56:04.323  5040  5040 F DEBUG   :       #2 pc 000000000009bb58  /data/app/com.google.chip.chiptool-dz3iwqwmItgQDBBaEcevJw==/base.apk (offset 0x97a000) (chip::RendezvousSession::SendNetworkCredentials(char const*, char const*)+44)
02-16 20:56:04.323  5040  5040 F DEBUG   :       #3 pc 000000000009bb94  /data/app/com.google.chip.chiptool-dz3iwqwmItgQDBBaEcevJw==/base.apk (offset 0x97a000) (non-virtual thunk to chip::RendezvousSession::SendNetworkCredentials(char const*, char const*)+44)
02-16 20:56:04.323  5040  5040 F DEBUG   :       #4 pc 0000000000051488  /data/app/com.google.chip.chiptool-dz3iwqwmItgQDBBaEcevJw==/base.apk (offset 0x97a000) (AndroidDeviceControllerWrapper::SendNetworkCredentials(char const*, char const*)+128)
02-16 20:56:04.323  5040  5040 F DEBUG   :       #5 pc 0000000000054188  /data/app/com.google.chip.chiptool-dz3iwqwmItgQDBBaEcevJw==/base.apk (offset 0x97a000) (Java_chip_devicecontroller_ChipDeviceController_sendWiFiCredentials+188)
02-16 20:56:04.323  5040  5040 F DEBUG   :       #6 pc 000000000013f350  /apex/com.android.runtime/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: ccd73e8ae9b59d5596b3b8aeef234d43)
<snip>
02-16 20:56:04.327  5040  5040 F DEBUG   :       #75 pc 00000000000be560  /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+116) (BuildId: e5b25f8fb9f6bb45ccbeca8c07061dad)
02-16 20:56:04.327  5040  5040 F DEBUG   :       #76 pc 00000000000c13d0  /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+776) (BuildId: e5b25f8fb9f6bb45ccbeca8c07061dad)
02-16 20:56:04.327  5040  5040 F DEBUG   :       #77 pc 00000000000034e0  /system/bin/app_process64 (main+1168) (BuildId: ade4367f7cc82a88f668180d34ce79fe)
02-16 20:56:04.327  5040  5040 F DEBUG   :       #78 pc 000000000007dc24  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) (BuildId: 5812256023147338b8a9538321d4c456)

* Make it an argument
Problem
We do not have media playback cluster which is needed for Chip to control media on TV

Summary of Changes
- Added Media Playback cluster.xml file
- Added Media Playback client and server.cpp files
- Updated example chip-tool so you can use media playback cluster
- Created example tv-app so you can start a TV server
…4887)

This is to match spec (and be compatible with avahi).

Spec update already specifies underscores:
CHIP-Specifications/connectedhomeip-spec#834
* CC26X2X7 Initial support of BLE Rendezvous

Migrate to the new Texas Instruments CC26X2X7 LaunchPad. This allows
concurrent Full Thread Device and BLE operation. This Enables BLE
rendezvous on the CC26X2X7.

Thanks to Alexander D'Abreu for work on the DMM integration and CHIPoBLE
profile development for the TI platform.

Co-Authored-by: Alexander D'Abreu <[email protected]>

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* fixup doxygen issues

* remove commented out code

* Update return cases

* Removed parens around return values.
* Propagated an error if possible.
* used assert() macro otherwise.

* Restyled by whitespace

* Restyled by clang-format

* remove unneded TI-POSIX conifg

* free correct buffer in error case

Co-authored-by: Alexander D'Abreu <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
@hnnajh hnnajh merged commit e467c01 into hnnajh:rotating-id-generation Feb 18, 2021
hnnajh pushed a commit that referenced this pull request Jul 22, 2022
It's not safe to access line editing state from the IO thread while
inside readline() on the main thread.

Remove the code that attempts to redraw readline after printing logs.
This avoids segfaults during logging at the cost of those logs
overwriting the prompt (this is not trivial to fix as readline
is a blocking API).

==================
WARNING: ThreadSanitizer: data race (pid=63005)
  Write of size 1 at 0x55f81c7745ff by main thread:
    #0 InteractiveStartCommand::ParseCommand(char*) ../../examples/chip-tool/commands/interactive/InteractiveCommands.cpp:127 (chip-tool+0x874911)
    #1 InteractiveStartCommand::RunCommand() ../../examples/chip-tool/commands/interactive/InteractiveCommands.cpp:85 (chip-tool+0x874594)
    #2 CHIPCommand::StartWaiting(std::chrono::duration<unsigned int, std::ratio<1l, 1000l> >) ../../examples/chip-tool/commands/common/CHIPCommand.cpp:408 (chip-tool+0x83e478)
    #3 CHIPCommand::Run() ../../examples/chip-tool/commands/common/CHIPCommand.cpp:187 (chip-tool+0x83c839)
    #4 Commands::RunCommand(int, char**, bool) ../../examples/chip-tool/commands/common/Commands.cpp:147 (chip-tool+0x85d4f7)
    #5 Commands::Run(int, char**) ../../examples/chip-tool/commands/common/Commands.cpp:51 (chip-tool+0x85c288)
    #6 main <null> (chip-tool+0x569c0a)

  Previous read of size 1 at 0x55f81c7745ff by thread T5 (mutexes: write M185):
    #0 LoggingCallback ../../examples/chip-tool/commands/interactive/InteractiveCommands.cpp:46 (chip-tool+0x874479)
    #1 chip::Logging::LogV(unsigned char, unsigned char, char const*, __va_list_tag*) ../../src/lib/support/logging/CHIPLogging.cpp:221 (chip-tool+0x8ee4dc)
    #2 chip::Logging::Log(unsigned char, unsigned char, char const*, ...) ../../src/lib/support/logging/CHIPLogging.cpp:172 (chip-tool+0x8ee30a)
    #3 chip::app::ReadClient::RefreshLivenessCheckTimer() <null> (chip-tool+0x8b1746)
    #4 chip::app::ReadClient::ProcessSubscribeResponse(chip::System::PacketBufferHandle&&) ../../src/app/ReadClient.cpp:845 (chip-tool+0x8b20ec)
    #5 chip::app::ReadClient::OnMessageReceived(chip::Messaging::ExchangeContext*, chip::PayloadHeader const&, chip::System::PacketBufferHandle&&) ../../src/app/ReadClient.cpp:409 (chip-tool+0x8ae2a4)
    #6 chip::Messaging::ExchangeContext::HandleMessage(unsigned int, chip::PayloadHeader const&, chip::BitFlags<chip::Messaging::MessageFlagValues, unsigned int>, chip::System::PacketBufferHandle&&) <null> (chip-tool+0xa0517a)
    #7 operator()<chip::Messaging::ExchangeContext> ../../src/messaging/ExchangeMgr.cpp:219 (chip-tool+0xa08c73)
    #8 Call ../../src/lib/support/Pool.h:126 (chip-tool+0xa0912d)
    #9 chip::internal::HeapObjectList::ForEachNode(void*, chip::Loop (*)(void*, void*)) ../../src/lib/support/Pool.cpp:127 (chip-tool+0x8ee05a)
    #10 ForEachActiveObject<chip::Messaging::ExchangeManager::OnMessageReceived(const chip::PacketHeader&, const chip::PayloadHeader&, const chip::SessionHandle&, chip::SessionMessageDelegate::DuplicateMessage, chip::System::PacketBufferHandle&&)::<lambda(auto:2*)> > ../../src/lib/support/Pool.h:396 (chip-tool+0xa08d10)
    #11 chip::Messaging::ExchangeManager::OnMessageReceived(chip::PacketHeader const&, chip::PayloadHeader const&, chip::SessionHandle const&, chip::SessionMessageDelegate::DuplicateMessage, chip::System::PacketBufferHandle&&) ../../src/messaging/ExchangeMgr.cpp:212 (chip-tool+0xa07e91)
    #12 chip::SessionManager::SecureUnicastMessageDispatch(chip::PacketHeader const&, chip::Transport::PeerAddress const&, chip::System::PacketBufferHandle&&) ../../src/transport/SessionManager.cpp:616 (chip-tool+0xa1548b)
    #13 chip::SessionManager::OnMessageReceived(chip::Transport::PeerAddress const&, chip::System::PacketBufferHandle&&) ../../src/transport/SessionManager.cpp:443 (chip-tool+0xa14426)
    #14 chip::TransportMgrBase::HandleMessageReceived(chip::Transport::PeerAddress const&, chip::System::PacketBufferHandle&&) ../../src/transport/TransportMgrBase.cpp:76 (chip-tool+0xa17dfa)
    #15 chip::Transport::Base::HandleMessageReceived(chip::Transport::PeerAddress const&, chip::System::PacketBufferHandle&&) ../../src/transport/raw/Base.h:102 (chip-tool+0xb19728)
    #16 chip::Transport::UDP::OnUdpReceive(chip::Inet::UDPEndPoint*, chip::System::PacketBufferHandle&&, chip::Inet::IPPacketInfo const*) ../../src/transport/raw/UDP.cpp:122 (chip-tool+0xb1a48b)
    #17 chip::Inet::UDPEndPointImplSockets::HandlePendingIO(chip::BitFlags<chip::System::SocketEventFlags, unsigned char>) ../../src/inet/UDPEndPointImplSockets.cpp:688 (chip-tool+0xb00aa0)
    #18 chip::Inet::UDPEndPointImplSockets::HandlePendingIO(chip::BitFlags<chip::System::SocketEventFlags, unsigned char>, long) ../../src/inet/UDPEndPointImplSockets.cpp:569 (chip-tool+0xafff89)
    #19 chip::System::LayerImplSelect::HandleEvents() ../../src/system/SystemLayerImplSelect.cpp:406 (chip-tool+0xb07563)
    #20 chip::DeviceLayer::Internal::GenericPlatformManagerImpl_POSIX<chip::DeviceLayer::PlatformManagerImpl>::_RunEventLoop() ../../src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp:181 (chip-tool+0x98a227)
    #21 chip::DeviceLayer::PlatformManager::RunEventLoop() ../../src/include/platform/PlatformManager.h:362 (chip-tool+0x988f75)
    #22 chip::DeviceLayer::Internal::GenericPlatformManagerImpl_POSIX<chip::DeviceLayer::PlatformManagerImpl>::EventLoopTaskMain(void*) ../../src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp:205 (chip-tool+0x98a87c)

  Location is global '(anonymous namespace)::gIsCommandRunning' of size 1 at 0x55f81c7745ff (chip-tool+0x000000c485ff)

  Mutex M185 (0x55f81c776180) created at:
    #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4240 (libtsan.so.0+0x4f30a)
    #1 chip::DeviceLayer::Internal::GenericPlatformManagerImpl_POSIX<chip::DeviceLayer::PlatformManagerImpl>::_LockChipStack() ../../src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp:78 (chip-tool+0x989e90)
    #2 chip::DeviceLayer::PlatformManager::LockChipStack() ../../src/include/platform/PlatformManager.h:410 (chip-tool+0x988fa5)
    #3 chip::DeviceLayer::Internal::GenericPlatformManagerImpl_POSIX<chip::DeviceLayer::PlatformManagerImpl>::_RunEventLoop() ../../src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp:170 (chip-tool+0x98a147)
    #4 chip::DeviceLayer::PlatformManager::RunEventLoop() ../../src/include/platform/PlatformManager.h:362 (chip-tool+0x988f75)
    #5 chip::DeviceLayer::Internal::GenericPlatformManagerImpl_POSIX<chip::DeviceLayer::PlatformManagerImpl>::EventLoopTaskMain(void*) ../../src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp:205 (chip-tool+0x98a87c)

  Thread T5 (tid=63013, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:969 (libtsan.so.0+0x5ad75)
    #1 chip::DeviceLayer::Internal::GenericPlatformManagerImpl_POSIX<chip::DeviceLayer::PlatformManagerImpl>::_StartEventLoopTask() ../../src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp:231 (chip-tool+0x98a40a)
    #2 chip::DeviceLayer::PlatformManager::StartEventLoopTask() ../../src/include/platform/PlatformManager.h:375 (chip-tool+0xaacca2)
    #3 chip::Controller::DeviceControllerFactory::ServiceEvents() ../../src/controller/CHIPDeviceControllerFactory.cpp:331 (chip-tool+0xab0417)
    #4 CHIPCommand::StartWaiting(std::chrono::duration<unsigned int, std::ratio<1l, 1000l> >) ../../examples/chip-tool/commands/common/CHIPCommand.cpp:403 (chip-tool+0x83e353)
    #5 CHIPCommand::Run() ../../examples/chip-tool/commands/common/CHIPCommand.cpp:187 (chip-tool+0x83c839)
    #6 Commands::RunCommand(int, char**, bool) ../../examples/chip-tool/commands/common/Commands.cpp:147 (chip-tool+0x85d4f7)
    #7 Commands::Run(int, char**) ../../examples/chip-tool/commands/common/Commands.cpp:51 (chip-tool+0x85c288)
    #8 main <null> (chip-tool+0x569c0a)

SUMMARY: ThreadSanitizer: data race ../../examples/chip-tool/commands/interactive/InteractiveCommands.cpp:127 in InteractiveStartCommand::ParseCommand(char*)
==================
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.