Commit graph

1046 commits

Author SHA1 Message Date
Erik Boasson
82e6a7972c Represent fragment size as uint16_t
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-06 11:40:56 +02:00
Erik Boasson
7fbbc13e65 Include receive buffer sizes in discovery
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-06 11:40:56 +02:00
Erik Boasson
eb2a273c1e Send heartbeat on NACKFRAG of latest sample
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-06 11:40:56 +02:00
Erik Boasson
18d4bc9699 Allow old NACKFRAG count after a delay
An asymmetrical disconnect where the reader undiscovers and rediscovers
the writer, but the reader remains alive all the time for the writer
results in the "count" field of NACKFRAGs restarting.  According to the
spec these must be ignored to protect against multi-pathing, but in this
scenario, ignoring them results in ignoring valid retransmit requests
until the "count" value catches up, which can take a very long time.

For ACKNACKs and HEARTBEATs the same problem exists, there it was
already handled by accepting backward jumps after some time has passed.
This reuses the same logic for NACKFRAGs.

This also changes the "count" fields to uint32_t throughout: the spec
defines them as int32_t, requires them to be strictly monotonically
increasing and omits any mention of a valid range or at what value the
counter should start.  Thus, everything in [-2^31,2^31-1] is allowed,
switching to an uint32_t merely shifts the range.  It also appears that
all implementations start at 0 or 1.  The "strictly monotonically" part
was impossible to do without disconnecting anyway.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-06 11:40:56 +02:00
Erik Boasson
fb7034e28f Do not set "present" flag in deser_locator
It is done by "do_locator" after it has decided that the locator is
well-formed and, crucially, not to be ignored.  Setting it when there
are only ignored locators (of the unicast/multicast, data/metadata
variety) causes further processing to rely on uninitialized memory.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-03 13:01:47 +02:00
Erik Boasson
22965a0fd7 Constness in transport functions
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-03 13:01:47 +02:00
Erik Boasson
bffe386f2d No extra transmit socket in MSM_NO_UNICAST mode
Reuse unicast data socket in MSM_NO_UNICAST, just like it did in all
modes before the extra socket was introduced in
d1ed8df9f3.  This restores support for the
"raw ethernet" transport on Linux by no longer requiring the transport
to create a socket with an arbitrary "port".

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-03 13:01:47 +02:00
Erik Boasson
f33867e884 Accept "raweth" locators and check vendorid
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-03 13:01:47 +02:00
Erik Boasson
e1ac4d7095 IPv6 needs scope_id for link-local addresses
This was accidentally deleted in
4df38f5bf9

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-03 13:01:47 +02:00
Erik Boasson
5c94a07771 Fix bogus deinit of security state on init error
The deinitialize would happen on most errors, but in all those cases it
would not have been initialized yet.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-03 13:01:47 +02:00
Erik Boasson
fe89d216a5 Remove IPv4/IPv6-specific code in adding peers
This removes the special handling of IP addresses in adding peer
locators from the configuration, instead relying on the general
string-to-locator conversion routines.

* This extends the common IP handling to code to handle the optional
  presence of a port and the use of brackets, allowing them always for
  IPv6 addresses, but requiring them only when needed for disambiguating
  numerical IPv6 addresses when a port is present.

* The "multicast generator" format is now handled in UDPv4 code.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-03 13:01:47 +02:00
Erik Boasson
e005c89240 Move openssl/ssl.h dependency out of the way
The src/core/ddsi/tests/locators.c test directly includes the header
files related to DDSI support for TCP and this pulled in openssl/ssl.h,
which in turn results in a build error in some environments because the
file can't be found.

There was no good reason why this dependency existed, the definitions
that relied on it were used only in the implementation of the TCP and
TLS support.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-03 13:01:47 +02:00
Erik Boasson
94c7965077 Correctly print AllowMulticast=false in config log
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-07-03 13:01:47 +02:00
Jeroen Koekkoek
f22d7974f7 Rename print to printspc to fix compile issue on Xilinx SDK
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2020-06-26 13:10:20 +02:00
Jeroen Koekkoek
f4e99f41f6 Fix xsd generation in ddsconf
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2020-06-26 13:10:20 +02:00
Jeroen Koekkoek
93c75186f0 Fix CID 304858 reported by Coverity Scan
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2020-06-26 13:10:20 +02:00
Erik Boasson
5d7f2fd438 Compile applink.c with -D_CRT_SECURE_NO_WARNINGS
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-26 11:47:56 +02:00
Erik Boasson
812fa3e42f Deal with OpenSSL in a DLL on Windows
OpenSSL doesn't support using BIOs of the "fd" or "file" type when it is
built as a DLL and the executable didn't provide it with access to the
executable's CRT.  Requiring all applications that wish to use security
to worry about this "applink.c" thing is too onerous a requirement.

* Check for the existence of "applink.c" in the OpenSSL include
  directory, adding it to the security tests if it exists.  This way,
  all of OpenSSL can be used by the tests.

* Include it in the security core and built-in plugin tests.  This way,
  the test code can use the entirety of OpenSSL.

* In the authentication and access-control plugins, load X509 and
  private keys from files by first reading them into a "mem" type BIO,
  then reading them from that BIO.

* Take care not to call ddsrt_free on OpenSSL-allocated memory, either
  by calling OPENSSL_free, or by allocating the memory using
  ddsrt_malloc and letting OpenSSL fill that buffer.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-26 11:47:56 +02:00
Jeroen Koekkoek
ad2fa331bd Remove perl and trang dependencies from package.xml
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2020-06-25 14:10:11 +02:00
Jeroen Koekkoek
b25f10ff33 Add ddsconf to generate md, rnc and xsd configuration documentation
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2020-06-25 14:10:11 +02:00
Jeroen Koekkoek
9c04099937 Enable CXX for CMake versions less than 3.12
This fixes #546. Thanks @robinlinden.

Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
2020-06-19 13:21:10 +02:00
Mikael Arguedas
768b92774f move options above where they're used to generate features header
Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
2020-06-18 12:55:36 +02:00
Robin Lindén
8029274fec Allow building without a C++ compiler
Signed-off-by: Robin Lindén <_@robinlinden.eu>
2020-06-12 16:00:19 +02:00
Marcel Jordense
c67f8bc73c Remove from ddsrt dynlib and filesystem when building FreeRTOS
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-06-11 18:04:30 +02:00
Erik Boasson
f08b4e0c5d Remove some dead stores signalled by clang analyzer
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-08 15:31:32 +02:00
Erik Boasson
ece3a78211 Help clang static analyzer in security tests
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-08 15:31:32 +02:00
Erik Boasson
8a748e1868 Fix incorrect cast of size_t* to uint32_t*
CID 304509 - it does not affect behaviour because the called function
uses it as an out parameter and the result is never inspected.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-08 15:31:32 +02:00
Erik Boasson
3705744681 Fix va_end arg in formatting security exception
CID 304494

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-08 15:31:32 +02:00
Erik Boasson
ca79eeb7b9 Fix error handling in generating test signatures
Failure to generate a signature for in handshake tests attempted to free
the address of the pointer, instead of the pointed-to memory (CID
304462).

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-08 15:31:32 +02:00
Erik Boasson
5588edb33e Move auth plug-in invalid parameter returns forward
Triggered by CID 304462, 304471, 304517: dereference before null check.
Note that it is a second-order problem because it would require the
plug-in functions to be called with a null pointer for the plug-in
instance.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-08 15:31:32 +02:00
Erik Boasson
84abf48d4a Perform type conversion for transient-local data
The changes in d92d491b83 to deal with
local readers and writers with the same topic and type name but
different underlying `struct ddsi_sertopic`s did not include the
provisioning of historical data from a (local) transient-local writer to
a (local) transient-local reader.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-06 13:52:01 +02:00
Marcel Jordense
efefb5009f Remove ssm argument when ssm not available
Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
2020-06-06 13:34:12 +02:00
Erik Boasson
9c31f48bea Build OpenSSL dependent parts only if present
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-05 09:18:46 +02:00
Erik Boasson
6161f5c44d Add some documentation to plist/xqos functions
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-05 08:51:58 +02:00
Erik Boasson
2579256535 Drop unused parameter from ddsi_plist_quickscan
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-05 08:51:58 +02:00
Erik Boasson
99d1364145 Improve chance of catching uninitialized plist/qos
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-05 08:51:58 +02:00
Erik Boasson
4cc018cfd7 Set durability_service on SPDP writer QoS
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-05 08:51:58 +02:00
Erik Boasson
8ae005a05a plist/xqos fini early out if nothing to be done
All incoming samples end up in ddsi_plist_fini, usually one with nothing
present, sometimes one containing status info or a keyhash.  The
"present" flags allow this to be a very quick operation in these simple
cases, and this should be made use of.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-05 08:51:58 +02:00
Erik Boasson
ca8742bfba Drop macOS 10.12 build from Travis CI cron job
The macOS 10.12 build was put in because of ROS2 "Dashing" specified
10.12 as the supported version, but Eloquent and later specify
10.14. The relevance of this is no longer there because of Foxy. The
build itself took an inordinate amount of time with lots of warnings
about the platform being deprecated.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-06-05 08:47:50 +02:00
eboasson
2287d7cd06
Merge pull request #491 from prasannabhat/feature/docker
Support docker build for cyclonedds
2020-06-05 08:47:24 +02:00
Prasanna Bhat (RBEI/EBB)
54c15c2b7e Add copyright headers
Signed-off-by: Prasanna Bhat (RBEI/EBB) <prasanna.bhat@in.bosch.com>
2020-06-05 07:52:03 +05:30
eboasson
3030a81528
Merge pull request #527 from eclipse-cyclonedds/security
Merge security into master
2020-06-04 17:47:28 +02:00
Dennis Potman
6260824251 Fix uninitialized use of relay_only
Fix using the variable relay_only uninitialized in the function
connect_proxy_writer_with_reader when security is disabled in the
build configuration.

Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-05-29 14:37:01 +02:00
Erik Boasson
7c7814e878 Include OpenSSL 1.0.2 in CI
Signed-off-by: Erik Boasson <eb@ilities.com>
2020-05-25 14:44:24 +02:00
Erik Boasson
6a9ebf88eb OpenSSL 1.0.2 compatibility
This addresses a number of issues with building Cyclone DDS including
DDS Security while using OpenSSL 1.0.2. Compatibility with 1.0.2 is a
courtesy towards those who are unable to move to 1.1.x or later because
of other libraries.

* On Windows, one must include Winsock2.h prior to including the OpenSSL
  header files, or it'll pull in incompatible definitions from Winsock.h
  and that breaks some of the files.

* OpenSSL 1.0.2 requires initializing the library (or more particular,
  loading all the required algorithms) but this is no longer needed in
  OpenSSL 1.1.x. It ends up being needed in a few places and having tons
  of essentially dead initialization code lying around is unpleasant.
  Hence this has been consolidated in a single function and protected
  with ddsrt_once().

* One ought to undo the above initialization on 1.0.2g and older, but it
  is impossible to know whether that can safely be done from a library.
  This is also the reason OpenSSL deprecated all the initialization and
  cleanup interfaces. So if one insists on trying it with such an old
  version, let there be some leaks.

* Thread state cleanup is sort-of required prior 1.1.0, but that suffers
  from the same problems; we'd have to do per-thread cleanup code for
  OpenSSL for any thread that could call into it (which is pretty much
  any thread). So once again, people should just use 1.1.0 or newer.

* There are some interfaces added in 1.1.0 that we use, but a few small
  workarounds those can be made to work on 1.0.2 as well. These also
  were replicated in a number of places and consolidated by this commit.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-05-25 14:44:24 +02:00
Michael Dodson
0b50928dd3 remove unused atomic pointer operations
Signed-off-by:  Michael Gary Dodson <md403@cam.ac.uk>
2020-05-20 16:07:48 +02:00
Dennis Potman
cc8308819d Refactor access control test permissions_expiry_multiple to reduce timing issues in test runs on travis
Signed-off-by: Dennis Potman <dennis.potman@adlinktech.com>
2020-05-20 15:59:15 +02:00
Erik Boasson
d4013f9c82 Handling of syntax errors in network partitions
The various network partition-related structs were left mostly
uninitialized by the various init functions (e.g., if_partition_mapping)
and these were moreover interpreted on parse errors.  This initializes
them to null pointers and skips all configuration post-processing in
case of an error.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-05-19 10:49:26 +02:00
Erik Boasson
296b49cf20 Fix use-after-free via (proxy)pp min lease pointer
This changes the handling of the removal of the lease of a manual
liveliness (proxy) writer from the (proxy) participant, such that the
invariant maintained for the "min lease" objects in the (proxy)
participant changes from: a clone of some lease with the minimum
duration, to: a clone of the lease that is returned by the
ddsrt_fibheap_min operation on the lease heap.

This fixes a use-after-free of the entity pointed to by the cloned lease
object in a scenario where the shortest lease duration is used by
multiple writers and the removal of a lease from the heap shuffles the
remaining entries around.  For example (before this change):

1. initial situation: three writers w1, w2 and w3 with equal lease
   durations:
   - pp.heap = w1.lease : w2.lease w3.lease
   - pp.minl = clone of w1.lease

2. delete w2:
   - assuming deleting w2.lease from the heap moves w3.lease to the
     front (only guarantee is that there are no smaller keys in the heap
     than that of the entry returned by minimum operation)
   - min(pp.heap) = w1.lease != w2.lease
     thus: pp.minl unchanged, pp.minl.entity = w1
   - pp.heap = w3.lease : w1.lease

3. delete w1:
   - min(pp.heap) = w3.lease != w1.lease,
     thus: pp.minl unchanged, pp.minl.entity = w1
   - pp.heap = w3
   - free w1
   - now pp.minl.entity has a dangling pointer, touched on deleting
     the (proxy) particpant or on lease expiry.

With this chamge, pp.minl is updated in step 2 to be a clone of w3.lease
because the lease returned by min(pp.heap) changes.  This ensures that
in step 3 there is no dangling pointer and no use-after-free.

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-05-18 14:54:36 +02:00
Erik Boasson
2aa70548cc Tweak timeouts in secure communication tests
* Increase the matching timeout to 5s (there are some hints the failures
  on Travis are timing related)
* Replace the relative timeout in the waitset by a timestamp so that it
  gives up after the specified timeout regardless of the number of
  events that occur

Signed-off-by: Erik Boasson <eb@ilities.com>
2020-05-16 11:38:05 +02:00