3142 Commits

Author SHA1 Message Date
Rainer Gerhards
b57db5ce3c ratelimiting: data race in Linux-like ratelimiter
access to the Linux-like ratelimiter was not properly synchronized, and
the system rate-limiter was not using it in any case.

This could lead to the rate-limit settings not being properly
respected, but no "hard error".
2017-11-10 19:03:09 +01:00
Rainer Gerhards
3701e7ec91 core/wrkr threads: fix race condition
During e.g. shutdown it could happen that a worker thread was started
and immediately be requested to terminate. In such situations there was
a race the prevented proper initialization. This could lead to follow-on
problems.

We believe (but could not proof) that this also could lead to a hang of
the termination process. Thus we claim to close an issue tracker down
here below, but are not 100% certain it really closes it (we hope for
user feedback on this). In any case, the thread debuger showed invalid
operations and this has been fixed, so it is useful in any case.

closes https://github.com/rsyslog/rsyslog/issues/1959
2017-11-10 19:03:09 +01:00
Rainer Gerhards
8c0875347d
Merge pull request #2000 from rgerhards/threading-fixes2
core/queue: fix potential race during shutdown
2017-11-10 13:24:04 +01:00
Rainer Gerhards
a3bf5204c9
Merge pull request #2004 from rgerhards/coverity-14
Coverity scan inspired changes
2017-11-10 09:03:02 +01:00
Rainer Gerhards
12343a2210
Merge pull request #2003 from rgerhards/cid-185395
remove unnecessary code
2017-11-10 09:02:24 +01:00
Rainer Gerhards
520264a500 core/queue: fix potential race during shutdown
more or less cosmetic, but pollutes thread debuggers
2017-11-10 08:59:41 +01:00
Rainer Gerhards
b787724a24
Merge pull request #1999 from rgerhards/threading-fixes
core/tcpsrv: fix potential hang on shutdown
2017-11-10 08:54:45 +01:00
Rainer Gerhards
2a6ec450aa remove currently unnecessary code
Detected by Coverity scan, CID 185397
2017-11-09 19:11:51 +01:00
Rainer Gerhards
44c05ab8bc fix too long lines 2017-11-09 19:08:59 +01:00
Rainer Gerhards
e9b547f6ad remove unnecessary code
Detected by Coverity scan, CID 185395
2017-11-09 18:53:17 +01:00
Rainer Gerhards
2dac66085c comment: describe coverty scan false positive 2017-11-09 18:47:46 +01:00
Allan Park
d5bafd1917 BUGFIX: fix issues in ksi ls12 pluginreported by coverity scan 2017-11-09 17:28:13 +02:00
Rainer Gerhards
3e418b148b core/tcpsrv: fix potential hang on shutdown
During shutdown of a tcpsrv, a race could occur, resulting in
a hang on shutdown of rsyslog as whole.

Detected via valgrind's helgrind thread debugger.
2017-11-09 16:05:17 +01:00
Rainer Gerhards
10825c470a core: enable SEGV handler to aid in getting core dumps
also simplified thread-specific signal setup
2017-11-08 11:27:19 +01:00
Rainer Gerhards
4fff51eeac cosmetic: fix close(-1) call
commit 5caee540222e5aa49a13f5bc052362f380d17d3f overlooked that the
file is also closed in error case.

Detected by Coverity scan, CID 185733
2017-11-08 09:06:15 +01:00
Rainer Gerhards
dd1026c1dc file writer: improved error message
if a file cannot be opened but would need to be for the crypto provider
to work correctly, an error message is now emitted.

Root issue detected by Coverity scan, CID 185338
2017-11-07 17:35:18 +01:00
Rainer Gerhards
5caee54022 ptcp driver: fix socket leak (highly improbable to occur)
If the ptcp object creation fails, the socket is already open and
not freed upon error return. This scenario is extremely unlikely,
but we still should fix it.

Detected by Coverity scan, CID 158389
2017-11-07 17:25:00 +01:00
Rainer Gerhards
a56edb37f3
Merge pull request #1969 from rgerhards/cid-185322
tcpsrv: fix potential memory leak on startup
2017-11-05 17:14:40 +01:00
Rainer Gerhards
6d89c9cdbe imdiag: fix cosmetic race in termination processing
This is not a real problem because imdiag intentionally does multiple
tries to validate predicate validity. However, this is reported in
clang thread sanitizer and so we need to fix it.
2017-11-05 15:57:38 +01:00
Art O Cathain
ba0436eb63 Merge remote-tracking branch 'origin/master' into tls-client-sni
# Conflicts:
#	tests/Makefile.am
2017-11-05 14:55:57 +00:00
Rainer Gerhards
b8a9c014db tcpsrv: fix potential memory leak on startup
small leak, can theoretically occur during rsyslog startup; will not
grow afterwards. Prime trigger would be out of process memory, which is
fatal in any case if it already occurs on startup.

Deteced by Coverity scan, CID 185322
2017-11-05 12:46:54 +01:00
Rainer Gerhards
18262d01f1
Merge pull request #1965 from rgerhards/cid-185423
file stream handler: ensure multiline read is kept valid
2017-11-05 11:09:45 +01:00
Rainer Gerhards
e54e6f8f38
Merge pull request #1960 from rgerhards/185393
ruleset: "fix" coverity scan issue
2017-11-05 11:09:23 +01:00
Rainer Gerhards
167c57f17e build: remove #pragmas which can cause build issues 2017-11-04 15:28:41 +01:00
Rainer Gerhards
b0d9c79b89 ruleset: "fix" coverity scan issue
while the issue is valid, this was not a bug but rather a
safeguard. Doing it slightly differntly this time.

CID 185393
2017-11-03 19:19:10 +01:00
Rainer Gerhards
a71913029e file stream handler: ensure multiline read is kept valid
We ensure that the previous line segment is always valid... actually this
was already done with existing code, but Coverity scan did not detect this.
Maybe we now get a control flow issue because we do what already happened
in this case...

CID 185423
2017-11-03 19:01:13 +01:00
Rainer Gerhards
4a9fdf172a
Merge pull request #1958 from rgerhards/cid-185378
core/net: potential memory leak when adding AllowedSenders
2017-11-03 18:34:08 +01:00
Rainer Gerhards
6b42e3cf86
Merge pull request #1957 from PascalWithopf/i-1920
Segfault when variable path consists of variables
2017-11-03 18:31:53 +01:00
Rainer Gerhards
355a9f32f2 core/net: potential memory leak when adding AllowedSenders
This is a small static leak that happens during config reading. At
most one leak for each configured but invalid allowed sender.

Detectec by Coverity scan, CID 185378
2017-11-02 17:46:42 +01:00
PascalWithopf
c7a5085a7e Segfault when variable path consists of variables
When no variables exist and a variable with at least one variable in its path was used, then rsyslog was searching for that non existant variable
Rsyslog now aborts it when no variables exist.
closes https://github.com/rsyslog/rsyslog/issues/1920
2017-11-02 17:38:25 +01:00
Rainer Gerhards
debeb5d9cb gcry crypto provider: fix potential NULL pointer addressing
happens only during out of memory condition

Detected by Coverity scan, CID 185422
2017-11-02 13:01:50 +01:00
Rainer Gerhards
ff32dcdb74 dnscache: refactor locking
keep a simple lock ... unlock scheme within the function. That is
easier to follow for both humans as well as static analyzers.

Also removes Coverity scan CID 185419
2017-11-01 19:35:37 +01:00
Rainer Gerhards
7c4adc5598 imdiag bugfix: double mutex unlock
This was caused by double-evaluation of a macro argument; macro changed

Detected by Coverity scan, CID 185348 and 185350
2017-11-01 17:12:54 +01:00
Rainer Gerhards
7b5b00a759 core/msg: refactor locking for json variable access
refactored the method so that it consistent in all functions and easier
to follow. Most importantly, now an as simple as possible locking paradigm
of lock ... unlock within the function. Hopefully easier to understand
both for humans and static code analyzers.
2017-11-01 13:12:57 +01:00
Rainer Gerhards
3f6a8d6b1b core: fix theoretical locking error
could theoretically happen if data structure was corrupted before
entering function. If so, would have lead to double unlock.

This is an experimental "solution" - if it works, we may consider
applying it to other places as well or working on a better one.

Detected by Coverity scan, CID 185469
2017-10-31 13:17:04 +01:00
Rainer Gerhards
3df324aaeb core/msg: potential race in variable handling
Commit 1090c5a68a4da705c91f33a1288610e23b6f3e1d was incomplete, fixing
it with this commit here. See previous commit for more details.
2017-10-31 13:08:39 +01:00
Rainer Gerhards
1090c5a68a core/msg: potential race in variable handling
Root of variable tree is accessed prior to locking access to it.
This introduces a race that may result in various kinds of
misadressing.

Found while reviewing code, no bug report exists.
2017-10-31 11:22:52 +01:00
Rainer Gerhards
8597d15898
Merge pull request #1931 from rgerhards/coverity-8
another set of Coverity scan patches
2017-10-31 10:33:41 +01:00
Rainer Gerhards
a2101e9d52 core/file stream object bugfix: memory leak
If a multiline read errored out, a line buffer could be leaked.

Detected by Coverity scan, CID 185328
2017-10-30 18:53:21 +01:00
Rainer Gerhards
1ae7b72241 file crypto provider: fix potential misadressing and memory leak
If the config parameters were invalid, a misadressing could occur. If so,
this happens only during startup.

Also, a memory leak existed when the crypto provider errored out. This could
build up if it were used in frequently-changing dynafiles. This was
detected by Coverity scan, CID 185360.

Finally some light code simplification (free handling).
2017-10-30 18:53:21 +01:00
Rainer Gerhards
67e6dc3379
Merge pull request #1927 from rgerhards/fix-thread
fix issues seen by clang thread sanitizer
2017-10-30 14:25:25 +01:00
Rainer Gerhards
267cb74580 core/queue: fix potential race in queue shutdown
detected by clang thread sanitizer
2017-10-30 09:56:11 +01:00
Rainer Gerhards
cff20639b7 file encryption: file handle leak
If file encryption was turned on and the state file larger 64K a
file handle leak occured.

Detected by Coverity scan, CID 185383
2017-10-29 19:13:04 +01:00
Rainer Gerhards
e0c0886a6e core/stats: memory leak if sender tracking is enabled
Detected by Coverity scan, CID 185439
2017-10-29 19:13:04 +01:00
Rainer Gerhards
03412875e2 core/stats: memory leak if sender stats are enabled
Detected by Coverity scan, CID 185438
2017-10-29 19:13:04 +01:00
Rainer Gerhards
975ca5fedc core/file stream: fix potential infinite loop
Detected by Coverty scan (albeit as different issue), CID 185328
2017-10-29 19:13:04 +01:00
Rainer Gerhards
573af0da93
Merge pull request #1924 from rgerhards/coverty-6
fixes based on Coverity scan
2017-10-28 18:12:33 +02:00
Rainer Gerhards
bacdc9beb4
Merge pull request #1922 from rgerhards/cid-185330
cosmetic: ensure strmOpenFile() has opened file when returning RS_RET_OK
2017-10-28 18:11:53 +02:00
Rainer Gerhards
4bc24fb952 core/tcp: fix potential buffer overflow
Detected by Coverity scan, CID 182329
2017-10-28 14:30:13 +02:00
Rainer Gerhards
2b5510b074 cosmetic: remove unnecessary cleanup detected by Coverity Scan
This removes what Coverity scan correctly identified as unnecessary.
However, it might have been there to prevent a clang static analyzer
false positive, so we check if this causes issues and merge only
if not. I keep this note in any case because it later might become
important info.

CID 185313
2017-10-28 13:04:47 +02:00