Commit graph

1039 commits

Author SHA1 Message Date
Erik Boasson
9c272c98b8 decode-trace IPv6 support + some minor fixes in it
* IPv6 extensions to patterns
* use full GUID prefix for Cyclone
* pattern fixes to deal with small changes in the formatting of QoS
* suppressinof local built-in topic publications
* asymmetrical disconnect detection improvements (better chance of
  detecting it, plus better suppression of spurious notifications)

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-03-05 16:10:46 +01:00
Dennis Potman
0a9d391c64 Fixed logging in find_own_ip
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Marcel Jordense
8ca1780538 Correct problem with cleanup of security handshake
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
b8537c0d09 Add test in secure_communication suite to validate that payload/submsg/rtps-msg does not contain secret when using encryption protection kind
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
9cc128c295 Remove setting the tracing verbosity in tests and make configs in security core tests more consistent
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
e7f5ae354c Fix security handshake test
Isolate domains by using unique tags when running tests that are using security handshake.
And updated coding style and some minor refactoring in fsm and timed_cb tests.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
ea10dbd8e1 Fixes in security core tests: add check that all provided vars are used in variable expansion for test configs, add note on concurrency in authentication wrapper, replace assert by cunit assert in crypto wrapper
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
8f464e0c99 Fix writer-reader sync in secure_communication tests
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
28aa06915e Fixed bug in handshake happy-day test
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
6c9e50cf3a Fix for empty trusted CA dir
Trusted CA dir in security configuration is optional, but participant
creation currently fails if no or empty dir is provided. This commit
fixes this issue and adds some tests for various trusted_ca_dir values.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
1cf472ea06 Refactored tests for security core: introduced generic wrappers for security plugins and
updated plugin loading tests to use these instead of specific wrappers per test. Added
test for securing communication ad handshake fail (using different identity CAs)

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
323de40cba Moved add_definitions in cmake files to /src/ so that all components and tests use the same definitions when compiling sources
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
Dennis Potman
b3c5a8d4fc Refactored expand_vars so that a custom lookup function can be used, which makes it usable for replacing tags by values other than environment variables
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:25:16 +01:00
eboasson
e412f6fab2
Fix issue in dds_create_topic_arbitrary (#422)
* Fix issue in dds_create_topic_arbitrary

Changed the behaviour of dds_create_topic_arbitrary with respect to the
sertopic parameter: the existing function dds_create_topic_arbitrary is
marked deprecated and replaced by dds_create_topic_generic, which returns
the sertopic that is actually used in as an out parameter. This can be eiter
the provided sertopic (if this sertopic was not yet known in the domain) or an
existing sertopic if the sertopic was registered earlier.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>

* Fix memory leaks in case topic creation fails.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-05 15:21:02 +01:00
eboasson
24e42fd658 Fix a few typos in security documentation
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-03-03 16:51:16 +01:00
Dennis Potman
7049469289 Update security documentation
An update for the security documentation that is part of the CycloneDDS
manual:
- added openssl commands for creating a set of CA and identity certificates
- code fragment for setting security by qos and example of xml security config
- commands for signing governance and permissions documents using openssl

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-03-03 16:51:16 +01:00
Erik Boasson
a0b4245600 Fix FSM timeout test race
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-03-03 13:32:38 +01:00
Marcel Jordense
1dad535bc0 Correct misplaced lock
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-03-03 13:32:38 +01:00
Marcel Jordense
4960fbf94c Add security authentication handshake and encoding and decoding
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-03-03 13:32:38 +01:00
Christophe Bedard
dc57685ac3 Make sure USE_SANITIZER is not empty before foreach
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
2020-02-29 18:18:47 +01:00
Dan Rose
ca4b5a368f Fix undefined behavior when hash function given null pointer
[test_subscriber-12] /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/ddsrt/src/mh3.c:28:53: runtime error: applying zero offset to null pointer
[test_subscriber-12] SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/ddsrt/src/mh3.c:28:53 in
Signed-off-by: Dan Rose <dan@digilabs.io>
2020-02-29 08:48:46 +01:00
Dan Rose
e8b0931798
Don't turn on sanitizers for debug builds by default (#408)
Also, allow multiple sanitizers.
Signed-off-by: Dan Rose <dan@digilabs.io>
2020-02-29 08:38:40 +01:00
Dan Rose
d72ebb0ed3
Don't pass null to memcmp (#413)
* Don't pass null to memcmp

```
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/ros2/rmw_cyclonedds/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/serdes.hpp:135:3 in
/opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:41:15: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/string.h:64:33: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:41:15 in
/opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:41:31: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:64:33: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:41:31 in
/opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:45:15: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/string.h:64:33: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:45:15 in
/opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:45:30: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:64:33: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/core/ddsi/src/ddsi_sertopic_default.c:45:30 in
```
Signed-off-by: Dan Rose <dan@digilabs.io>

* clearer non-null check

Signed-off-by: Dan Rose <dan@digilabs.io>
2020-02-29 08:32:02 +01:00
Erik Boasson
1ee2dfe08f Avoid race causing thread-state pointer aliasing
The thread_states array resets the "state" to ZERO on thread termination
to indicate that the slot was unused, but it leaves the thread id
unchanged because some platforms don't have a defined value that will
never be used as a thread id.  A consequence is that a newly created
thread may result in multiple slots containing their own thread id, but
generally there will only be one that is not in state ZERO.

However, the code for create_thread used to set the state to ALIVE prior
to creating the thread, and so if the events get scheduled like:

1. thread A: X.state = ALIVE
2. create new thread B, storing tid in X.tid
3. thread A: Y.state = ALIVE
4. new thread B: lookup self (and cache pointer)
5. create new thread C, storing tid in Y.tid
6. new thread C: lookup self (and cache pointer)

Then B will observe two slots in the ALIVE state, with X.tid certain to
match and Y.tid undefined (and hence possibly matching).  It may
therefore pick Y.  C will (in this schedule) of course always choose Y.
They cache the pointer and never look at X and Y again, except for
updating their virtual clocks.

These virtual clocks are updated non-atomically (by design it is private
to the thread) and so if both B & C use Y they can end up racing each
other in updating the virtual clock and cause the nesting level of the
"awake" state controlling garbage collection to get stuck (or wrap
around, or do other horrible things).  The consequence can be anything,
from a somewhat benign variant where GC effectively stops and some
operations (deleting readers and writers and shutting down) block
forever, to use-after-free and the undefined behaviour that implies.

This commit avoids looking up the slot in the newly created threads,
instead passing the correct address in the argument.  It also adds an
intermediate state INIT that serves to reserve the slot until the new
thread is actually running.  It does make the look-up safe (if one were
to do it), and as it is essentially free and gives more insight in the
state of the system when viewed from a debugger, it appears a useful
addition.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-28 08:13:31 +01:00
Dan Rose
6e0faae196 Fix warning -Wimplicit-int-float-conversion
```
/opt/ros/master/src/eclipse-cyclonedds/cyclonedds/src/tools/pubsub/common.c:586:28: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
    if(nanosec > nextafter(INT64_MAX, 0)) {
                 ~~~~~~~~~ ^~~~~~~~~
/usr/include/stdint.h:134:22: note: expanded from macro 'INT64_MAX'
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdint.h:116:24: note: expanded from macro '__INT64_C'
                        ^~~~~~
<scratch space>:345:1: note: expanded from here
9223372036854775807L
^~~~~~~~~~~~~~~~~~~~
1 warning generated.
```

Signed-off-by: Dan Rose <dan@digilabs.io>
2020-02-25 19:20:33 +01:00
Erik Boasson
1c77aad39c Fix Clang static analyzer warnings
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-24 15:59:00 +01:00
Erik Boasson
0d5a8bf461 Remove built-in crypto plugin unused variables
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-24 15:59:00 +01:00
Erik Boasson
e0a9beb3cb Fix condition for validating topic access rules
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-24 15:59:00 +01:00
Erik Boasson
5aeace912b Converting to timeval/timespec need casts on 32bit
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-22 14:30:46 +01:00
Erik Boasson
6dc28db197 Fix warning by cleaning up dds_set_qos_locked_raw
gcc 5.4 correctly warned that a null pointer was being passed into the
entity-specific "set_qos" function when changing a topic QoS, where that
parameter was tagged as "non-null".  As it was never dereferenced in
this case the resulting behaviour was still correct.

It turns out that the entire function was overly complicated and that
simply passing the entity pointer round allows eliminating a few
arguments as well.

(Oddly none of the more modern toolchains used pick this up.)

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-22 14:30:46 +01:00
Dennis Potman
8bd6f34f67 Renamed unsupp config sections to internal
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-02-20 16:47:06 +01:00
Dennis Potman
754eb4090e Fixed issue that Cyclone does not receive multicast data on Windows when
the destination cache of the network stack is in a certain state. The issue
is resolved by binding unicast sockets (incoming unicast and all outgoing
traffic) to the address of the interface instead of inaddr_any (0.0.0.0).
Set the new configuration option internal/BindUnicastToInterfaceAddr to
false to get the old behavior.

Co-authored-by: Erik Boasson <eb@ilities.com>

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-02-20 16:47:06 +01:00
ChenYing Kuo
af3604dea7
Fix some typos. (#399)
* Fix some typos.

Signed-off-by: ChenYing Kuo <evshary@gmail.com>

* Also update q_config.c, cyclonedds.rnc, cyclonedds.xsd for correct
build.

Signed-off-by: ChenYing Kuo <evshary@gmail.com>

* Remove cdds.md.

Signed-off-by: ChenYing Kuo <evshary@gmail.com>
2020-02-19 12:33:39 +01:00
Erik Boasson
9a0ad5e2f5 ddsperf argument checking improvements
Inspired by Coverity warnings.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-18 13:55:44 +01:00
Erik Boasson
ef047d6bd5 Check all dds_write calls in liveliness tests
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-18 13:55:44 +01:00
eboasson
b03195ec72
Merge pull request #395 from eboasson/security
Merge "master" into "security"
2020-02-13 13:36:55 +01:00
Erik Boasson
54fad0d601 Merge remote-tracking branch 'upstream/master' into security 2020-02-13 13:13:54 +01:00
Erik Boasson
4ed0128578 Rework security code in proxy participant creation
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-13 13:12:25 +01:00
Erik Boasson
62a6004e8a Remove "CM" topic related flags reintroduced by merge
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-13 12:00:13 +01:00
Erik Boasson
9b43303d82 Remove unused "kernel sequence numbers" notion
The flag originates in OpenSplice but is meaningless in Cyclone.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-13 12:00:07 +01:00
Thijs Sassen
2cd8909beb Fixed build error on FreeRTOS
Signed-off-by: Thijs Sassen <thijs.sassen@adlinktech.com>
2020-02-13 10:59:33 +01:00
Jeroen Koekkoek
bf3d1bc270 Fix getifaddrs for non-English interface names on Windows
ddsrt_asprintf did not copy non-English interface names. To fix this memory is
allocated with ddsrt_malloc and UTF-16 encoded interface names are converted to
UTF-8.

Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2020-02-13 08:43:59 +01:00
Erik Boasson
0d3ca448ff Liveliness monitoring fixes for security FSM
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-12 20:15:49 +01:00
Erik Boasson
ad58db0721 Merge branch 'master' into security
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-12 17:30:38 +01:00
Erik Boasson
80ed351efd Add declaration prototype line for ddsrt_atomic_ function to fix armhf build warning
Thanks to @emersonknapp

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-12 17:20:04 +01:00
Erik Boasson
8d6b308199 Add more checks to ddsperf and run on Travis
This adds options to check for "unreasonable" RSS growth, receipt of a
minimum number of samples and having run a minimum number of roundtrips.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-12 17:19:48 +01:00
Erik Boasson
701c6f5a5c Retain less data in keep-last WHC in absence of ACKs
A keep-last volatile WHC retained data already overwritten by the writer
in the absence of ACKs, introduced by 231cb8c9.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-12 17:19:48 +01:00
Erik Boasson
6ed190ce2a Fix leak in converting hostname to IP address
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-12 17:19:48 +01:00
Erik Boasson
01f9c0599c Set transport in locator of TCP server sockets
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-12 17:19:48 +01:00
Erik Boasson
b84eee5abb Fix detecting remote ping/pong writers in ddsperf
The status mask on some readers got reduced to just "data available"
when used in conjunction with a waitset, but the consequence is that the
"subscription matched" listener would be suppressed.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-02-11 23:26:01 +01:00