Commit Graph

53 Commits

Author SHA1 Message Date
Arjan van de Ven b193344145 Make sure to strdup() the ini file keys 2017-05-26 11:11:55 -07:00
Arjan van de Ven 59c63d8c40 Replace glib ini file parsing with nica ini file parsing 2017-05-26 11:11:55 -07:00
Patrick McCarty 0af684e94e Fix bug in is_banned_path(); group conditionals
The checks in is_banned_path() for a path prefix not under /usr needed
to be connected with a logical AND, not OR, as implied by the recent
changes.

Also, use an explicit logical OR for the other two groups of
conditionals so that they are grouped similarly to the checks that
required an AND.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-11 12:55:33 -07:00
Patrick McCarty 51374db118 Remove more unused glib includes
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-11 11:22:42 -07:00
Patrick McCarty dfb40babaa Remove unneeded glib.h include
telem-record-gen no longer depends on glib, so the include can be
removed.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-11 10:29:18 -07:00
Patrick McCarty b7619e1a1c Remove glib dependency for ASCII string check
As far as I can tell, the standard library doesn't have a function to
check for an ASCII string. Equivalently, we can iterate over each
character in the string, byte by byte, and verify that only 7-bit
characters are present.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-11 10:29:18 -07:00
Patrick McCarty 3be37cebb5 Use getopt_long() in telem-record-gen
One more binary was using GOptionContext: telem-record-gen. Convert it
to use getopt_long() as well.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-11 10:29:18 -07:00
Patrick McCarty 15a32b6346 Fix code style issues in journal.c
Run uncrustify again to catch further whitespace issues.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-11 10:29:18 -07:00
Patrick McCarty e0e2aae341 Use getopt_long() in the crash probe
Continuing the removal of dependency on glib, switch to use
getopt_long() instead of the GOptionContext API for the crash probe.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-11 10:29:18 -07:00
Arjan van de Ven 4d1f6de3b5 replace the regexps with more simple tests 2017-05-11 09:19:41 -07:00
Patrick McCarty f3a641b161 Use getopt_long() in the journal probe
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-10 12:54:43 -07:00
Patrick McCarty 9018362ffb Fix style issues missed by uncrustify
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-10 12:39:48 -07:00
Patrick McCarty eedcb88cb7 Run uncrustify
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-10 12:07:44 -07:00
Patrick McCarty dab667eeea Fix distcheck
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-10 12:00:09 -07:00
Patrick McCarty 787102c4fb Clean up makefile and header references for consistency
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-05-10 11:58:55 -07:00
Arjan van de Ven 12d1c82650 Print file name / line number in backtrace 2017-05-10 11:27:52 -07:00
Arjan van de Ven 46d88d6315 more crash probe glib string removals 2017-05-10 11:27:52 -07:00
Arjan van de Ven 089183c9e0 remove some spurious glib includes 2017-05-10 11:27:52 -07:00
Arjan van de Ven f354078d3d convert the journal probe to getopt 2017-05-10 11:27:52 -07:00
Arjan van de Ven db85aa9a18 stop using g_print 2017-05-10 11:27:52 -07:00
Arjan van de Ven f5899c7ba6 convert more of the crash probe 2017-05-10 11:27:52 -07:00
Arjan van de Ven 657c8792d5 make the pstore probe use nica strings 2017-05-10 11:27:52 -07:00
Arjan van de Ven 365cfeee9a convert the journal probe to nica strings 2017-05-10 11:27:52 -07:00
Arjan van de Ven 4957452f66 convert the crash probe to nica strings 2017-05-10 11:27:52 -07:00
Arjan van de Ven e02e22f192 replace glib string operations with nica string operations 2017-05-10 11:27:52 -07:00
Arjan van de Ven bc12e6d5f7 the klog_scanner does not use glib.h 2017-05-05 12:18:42 -07:00
Arjan van de Ven e9d29a4e7b use isspace and isprint directly 2017-05-05 12:18:42 -07:00
Arjan van de Ven 6295f0f4dc a gchar is just a char typedef 2017-05-05 12:18:42 -07:00
Arjan van de Ven 4cf3c7e8ac a guint is just an uint32_t so lets use standard types 2017-05-05 12:18:42 -07:00
Patrick McCarty e699fd34e2 oops parser: support oops stack traces for Linux 4.10+
Linux 4.10 introduced some format changes for oopses; one of the changes
was removing memory addresses from each stack frame.

This commit adds support for the new format and retains compatibility
for the previous format (4.9 and earlier).

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-03-21 22:55:03 -07:00
Patrick McCarty 266039a4e5 oops parser: add/use skip_space; fix skip_spaces
The former skip_spaces() function only skipped a single space, so rename
it to skip_space(), and make skip_spaces() greedily consume spaces.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-03-21 22:55:03 -07:00
Patrick McCarty 9b435f39e5 journal probe: remove obsolete LOG_DEBUG message
A return value of 0 can also indicate send_data() failure, so remove
this log message.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 11:35:25 -08:00
Patrick McCarty 20c051fe59 Document the logical expression for journal entry matching
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 11:35:25 -08:00
Patrick McCarty 96c1cd5547 journal probe: filter LOG_EMERG logs as well
I omitted log level 0 from the filter, so add it here.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 11:35:25 -08:00
Patrick McCarty e375fe6825 journal probe: send records for every log message
The previous logic concatenates log messages on initial startup, when
the entire journal is read to process existing messages. But doing so
might run into the payload size limit (8KB), and thus fail to create a
record.

Sending one record per log message will ensure that the payload size
remains relatively small, almost always below the 8KB size limit.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 11:35:25 -08:00
Patrick McCarty 160a4d01bf journal probe: filter on EXIT_CODE as well
This field appears to be set when services fail, so filter on it as
well.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 11:35:25 -08:00
Patrick McCarty 3f7b839cd8 journal probe: use the new macros
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 11:35:25 -08:00
Patrick McCarty 07595885c4 journal probe: add macros to help with using the journal API
To avoid having to read the repetitive error handling when adding
journal filters, add some helper macros.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 11:35:25 -08:00
Patrick McCarty 625eea615e journal probe: fix formatting of some log messages
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 11:35:25 -08:00
Patrick McCarty 8a69b22895 journal probe: add newlines for to each message in the payload
The make payloads more legible, make sure separate messages are newline
separated.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 11:35:25 -08:00
Patrick McCarty b4a0989d0e journal probe: match all messages ERR or higher
Previous behavior was to only filter LOG_ERR messages from the
telemetrics crashprobe, but it will be helpful to make this probe more
generic to capture log messages with the highest log levels.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 11:35:25 -08:00
Patrick McCarty 41f53507d1 journal probe: fix error handling of read_new_entries()
The error case is negative, so fix the return code conditional check
appropriately.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 11:35:25 -08:00
Patrick McCarty 3aeb31ee3d Add opt-in feature to disable privacy filters
There are some filters in place that prevent probes from collecting
specific types of data. In particular, the oops probe will report "zero"
or "non-zero" for register values in oopses instead of the actual
values. And the crash probe does not send backtraces if binaries live
outside of /usr or under /usr/local.

This commit keeps these filters in place but offers the capability to
disable the filters by creating a file named

  /etc/telemetrics/opt-in-no-privacy-filters

Any future telemetry privacy filters can check for this file to alter
the reporting level.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 10:56:55 -08:00
Patrick McCarty 4ce8ff9990 Clarify path filtering logic in the crash probe
Since only one path is being checked for a program, and it returns a
boolean, rename the function and call site appropriately.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-17 10:56:55 -08:00
Patrick McCarty 2409452740 crash probe: retry processing when missing symbols
Missing symbols in backtraces might indicate missing debuginfo from the
crashed program, but another possibility is that on-the-fly debuginfo
has not finished downloading. The Clear Linux OS uses an on-the-fly
debuginfo setup, so this condition is likely for the first instance of a
program crashing on the system.

To decrease likelihood of missing symbols appearing, scan the backtrace
for a frame with incomplete data after first processing, and if found,
reprocess the core file after a 10 second pause.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-06 14:28:17 -08:00
Patrick McCarty ecc60b6a3c crash probe: split core process routine out of main
For future reuse of the code for processing a core file, move it to a
new function, and call it from main().

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-06 14:28:17 -08:00
Patrick McCarty 579e7a8674 crash probe: split elfutils boilerplate out of main
For future reuse of the code to initialize elfutils for processing a
core file, move it to a new function, and call it from main().

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-06 14:28:17 -08:00
Patrick McCarty 003928f52e Preserve unreliable frames for kernel oopses
When frame addresses detected during the stack scan were not previously
found by unwinding, the string "? " is added as a prefix to the function
name.

However, the current oops parsing code strips "? " if encountered, so
the backtraces from kernel oopses are missing vital information; the
presence of "? " provides a hint for debugging a stack trace and
indicates that the frame info is "unreliable".

This commit removes the "? " strip code, ensuring the prefix is retained
by the function name, and updates unit tests that check for oops lines
that should contain the prefix.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-02-02 12:22:22 -08:00
John Andersen cb622a0eb0 Validation for classification to ensure 2 slashes (#4)
* Validation for classification to ensure 2 slashes

Signed-off-by: John Andersen <john.s.andersen@intel.com>

* Update telem_record_gen.c

Fixed code style issues
2016-09-02 00:43:48 -07:00
Jeremy Rocher 44e0d4d3c5 crashprobe: fix stderr when launched from kernel
stderr could be used for logging or in libtelemetry in DEBUG mode but
when crashprobe is launched through kernel core_pattern, stderr is not
open, only stdin (fd 0), see this dump from gdb:

 (gdb) shell ls -l /proc/15478/fd
 total 0
 lr-x------ 1 root root 64 24 juin  15:02 0 -> pipe:[82555]

If stderr is not open, when socket to telemd is open it could take
fd 2 and in this case all fprint to stderr are written to socket which
is bad ... this is the case when doing static linking, which ends to
telemd crashed.

Fix it by ensuring stderr is open.

Signed-off-by: Jeremy Rocher <jeremy.rocher@intel.com>
2016-08-17 21:09:33 +00:00