Commit Graph

83 Commits

Author SHA1 Message Date
Liu, Xinwu d5b578fd84 tools: acrn-crashlog: Limit the log size of kmsg
Dmesg collects too much log when kernel meets log storm.
This patch reads kernel log from "/dev/kmsg" intead of dmesg and limits
the generated log size.

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
2019-01-10 12:22:28 +08:00
Liu, Xinwu 156ea70821 tools: acrn-crashlog: Reboot system to cold after collecting reserve log
After panic, kernel will do warm boot to reserve memory for log collecting.
Need to cold reboot system as the original behaviour.

Tracked-On:#1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
2019-01-10 11:01:40 +08:00
Liu, Xinwu 3d1332f392 tools: acrn-crashlog: refine the log storage
1. remove watching TOMBSTONE in AaaG.
2. add a configurable parameter "foldersize" in MB, sender will drop
   all events when the storaged log size exceeds this parameter.

Tracked-On:#1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Chen Gang <gang.c.chen@intel.com>
Acked-by: Zhang Di <di.zhang@intel.com>
2018-11-27 14:26:25 +08:00
zhonghua 9dacc4a57d tools:acrn-crashlog:fix potential issue
this patch fix potential issue of initialization
about local variable in fsutils.c

Tracked-On: #1024
Signed-off-by: Zhonghua <zhonghua.sun@intel.com>
Reviewed-by: Huang, Yonghua <yonghua.huang@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
2018-11-15 16:39:54 +08:00
Liu, Xinwu 3ffa9686ca tools: acrn-crashlog: fix potential issues
Changes include:
1. check the parameter of snprintf
2. remove atoi
3. remove sscanf
4. fix one memleak

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Huang, Yonghua <yonghua.huang@intel.com>
Acked-by: Chen, Gang <gang.c.chen@intel.com>
2018-11-02 11:52:01 +08:00
CHEN Gang 2f8c31f6b4 tools: acrn-crashlog: update the documents
This patch updates the documents according to the latest implementation
of crashlogctl.

Tracked-On: #1024
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
2018-10-25 10:03:40 -07:00
xiaojin2 6d076caaa6 tools: acrn-crashlog: remove unsafe apis in usercrash
Since strlen/vsnprintf/ato* api are not safe, so use strnlen instead of
strlen, use vasprintf instead of vsnprintf and use strtol instead of
atoi.

Tracked-On: #1254
Signed-off-by: xiaojin2 <xiaojing.liu@intel.com>
Reviewed-by: Huang Yonghua <yonghua.huang@intel.com>
Reviewed-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-25 13:43:04 +08:00
Liu, Xinwu 9368373fd9 tools: acrn-crashlog: check the pointer after getting sender
get_sender_from_name would return NULL if the name of sender is not
configured in acrnprobe.xml.
This patch check the return value of it.

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Huang Yonghua <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-23 09:11:48 +08:00
Liu, Xinwu 40dbdcde4f tools: acrn-crashlog: remove unsafe strlen in common
Remove strlen in common apis, and change their caller if necessary.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu f25bc50e68 tools: acrn-crashlog: update string operation in acrnprobe
Remove unsafe api strlen except the parameter is a static string.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu 6938caa25f tools: acrn-crashlog: refine the configuration structure
1. get string size when parsing configuration.
2. add 'const' for strings got from configuration.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu fe4d503c3d tools: acrn-crashlog: remove unsafe api sscanf
Use str_split_ere instead of sscanf.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu fb0292846d tools: acrn-crashlog: remove unsafe api sprintf
Using snprintf intead of sprintf.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu 5ecf1078ca tools: acrn-crashlog: remove unsafe apis from android_events.c
1. Refine strings operation.
2. Remove sscanf, sprintf and strlen.

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Liu, Xinwu 48ce01a52f tools: acrn-crashlog: new api in strutils
This patch provides an new api to split string by extended regexp(ere).

Tracked-On: #1254
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-19 22:49:04 +08:00
Miguel Bernal Marin b115546b45 crashlog: deprecate acrnprobe_prepare and update Makefile
The `crashlogctl` command is replacing acrnprobe_prepare script.
So, let's remove from the project, and update the Makefile with
the new content.

Tracked-On: #1386
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-08 09:43:03 +08:00
Miguel Bernal Marin f3fc857f56 crashlog: introducing crashlogctl
This patch introduce the command `crashlogctl`,
it is used to enable/disable the ACRN crashlog services.

Also a systemd-tmpfile config file is introduced to create the
/var/log/crashlog directory, and a sysctl config file where
the usercrash-wrapper will be configured at boot time.

Tracked-On: #1386
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-08 09:43:03 +08:00
Miguel Bernal Marin b1a05d17ed crashlog: re-write usercrash-wrapper
Using an O(n^2) function for look up the values from the arguments
simplify the complexity code of the userchrash-wrapper.

Tracked-On: #1386
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-08 09:43:03 +08:00
Miguel Bernal Marin 6981a4dff7 crashlog: do not alter system behavior with watchdog
Instead of installing to systemd config directory, install to
/usr/share/acrn/crashlog. Using this way we not alter the system if it
is not used as a debug platform.

Tracked-On: #1386
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-10-08 09:43:03 +08:00
Ming Liu f1cce6710a Makefile: fix cross-compiling issues
Replace all the host paths with a prefix sysroot directory, it defaults
to be empty, but can be overridden by the variable set in
environment(make -e) or being passed to make command.

Tracked-On: #1307
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
2018-09-26 11:04:19 +08:00
CHEN Gang 5affe53a9f tools: acrn-crashlog: update Makefile flags
This patch is to sync the compiler options as the Makefile of device model.

Tracked-On: #1122
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Reviewed-by: Liu, Xinwu <xinwu.liu@intel.com>
2018-09-25 13:07:43 +08:00
CHEN Gang 726711e27d tools: acrn-crashlog: fix some compiler warnings
This patch is to fix some compiler warnings before enabling the flag to make
compiler warning as compiler error.

The warning message is like:
ignoring return value of ‘write’, declared with attribute warn_unused_result.

Tracked-On: #1122
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Reviewed-by: Liu, Xinwu <xinwu.liu@intel.com>
2018-09-25 13:07:43 +08:00
Liu, Xinwu 876cc68311 tools:acrn-crashlog: Change the algorithm of generating event key
Acrnprobe is using SHA to generate ids for events. These ids are only used
to index events, not for cryptographic purpose.

This patch unify the generating algorithm of short and long ids to
SHA256.

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-09-13 10:03:23 +08:00
wenshelx 6ee9321bd8 security: Enable '-fpie -pie' options
To be sure acrn debug tools are position independent
and executable.

Tracked-On: #1122
Signed-off-by: wenshelx <wenshengx.wang@intel.com>
Acked-by: CHEN Gang <gang.c.chen@intel.com>
Acked-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-09-07 10:23:54 +08:00
CHEN Gang 56f2c1a717 tools: acrn-crashlog: correct usercrash-wrapper path
This patch is to correct the path of usercrash-wrapper.

Tracked-On: #1024
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Zhang Di <di.zhang@intel.com>
2018-09-04 16:46:38 +08:00
CHEN Gang 37fd3871b7 tools: acrn-crashlog: add usercrash_c in the pipe of core_pattern
This patch adds the usercrash client in the pipe of core_pattern
without affecting default core_pattern program.

In acrnprobe_prepare.sh, core_pattern will be set as usercrash-wrapper
with all of the arguments, which parses the parameters of the default
core_pattern program and the usercrash client, and then invokes them
separately.

Tracked-On: #1024
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Reviewed-by: xiaojin2 <xiaojing.liu@intel.com>
Acked-by: Zhang Di <di.zhang@intel.com>
2018-09-04 11:19:33 +08:00
David B. Kinder 348422dba6 doc: fix graphviz scanning and processing
The doc build process copies files using script/extract-content.py from
outside of the doc/ folder (specifically content in the tools/ folders).
The script was not copying graphviz directive files.  This has been
fixed and the embedded graphviz directives are not (properly) stored in
separate image/*.dot files.

Note the extract-content.py file is derived from the Zephyr project.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-08-30 14:05:50 -07:00
Liu, Xinwu fa7eb1f6ae tools:acrn-crashlog: Document of configuration file
This document explains all fields in acrnprobe.xml.
User could use it to control acrnprobe's behavior and configure their
own events.

Tracked-On: #1024
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: David B. Kinder <david.b.kinder@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
Acked-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-08-29 09:16:44 -07:00
CHEN Gang 4ecbdf06fb tools: acrn-crashlog: update core_pattern content conditionally
This patch is to improve the way of updating the core_pattern content
in the shell script, since the previous configuration in core_pattern
will block coredumpctl.
This patch adds an inspection before changing the content of
core_pattern.

Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Reviewed-by: xiaojin2 <xiaojing.liu@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Zhang Di <di.zhang@intel.com>
2018-08-16 08:26:05 -07:00
Liu, Xinwu 5e32c0227f tools:acrn-crashlog: Enhance some functions
The changes include:

1. modify the outparam only in successful cases.
2. return -1 instead of  a errno-style value if error happens.
3. check return value of strrchr.

Tracked-On: #971
Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-08-09 14:48:36 +08:00
Tan Yew Wayne 8af90e0154 misc: Remove unnecessary ExecStop in systemd services
From systemd documentation: https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStop=
> If this option is not specified, the process is terminated by sending the signal specified in KillSignal= when service stop is requested.

https://www.freedesktop.org/software/systemd/man/systemd.kill.html#KillSignal=
> Defaults to SIGTERM.

Signed-off-by: Tan Yew Wayne <yew.wayne.tan@intel.com>
2018-08-09 08:58:12 +08:00
CHEN Gang 87a4abdd9d tools: acrn-crashlog: fix build warnings with gcc8.1.1
This patch is to fix the build warning with gcc8.1.1. Most of them are
warnings for buffer overflow from snprintf and strncpy.

Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Reviewed-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: xiaojin2 <xiaojing.liu@intel.com>
2018-07-31 11:24:11 +08:00
Liu, Xinwu 42c77e4cf4 Documentation: add needed library for acrnprobe
Two packages are needed in compiling environment with replacing commands
fdisk and debugfs.

On clear linux, they belong to os-core-dev.

Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
Acked-by: Yang Ailin <ailin.yang@intel.com>
2018-07-27 16:38:21 +08:00
Liu, Xinwu a4aed4535a tools: acrn-crashlog: replace debugfs with api
Replace debugfs with api in loop.c.
There is no functional change.

Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-07-27 16:38:21 +08:00
Liu, Xinwu ea8cb410c5 tools: acrn-crashlog: replace fdisk and losetup with api
Use api in loop.c to replace fdisk and losetup.
There is no functional change.

Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-07-27 16:38:21 +08:00
Liu, Xinwu 134e79aca2 tools: acrn-crashlog: New apis to replace debugfs
This patch impletement apis with libext2fs, which are for dumping and
reading files or dirs in extfs.

Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-07-27 16:38:21 +08:00
Liu, Xinwu db05675f38 tools: acrn-crashlog: New apis to replace losetup and fdisk
This patch adds new apis to replace commands losetup and fdisk.
Main changes include:
1. impletement apis to operate loop devices directly.
2. impletement apis to get partition information from image file.

Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-07-27 16:38:21 +08:00
David B. Kinder e2ad788f63 doc: clean up tools docs
Made the titles consistent across the tools (some had capital letters).
Fixed heading levels in acrnctl/acrnd doc  (had two H1 headings).
Changed a text-based drawing to use graphviz.
Some general grammar tweaks as well.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-07-20 11:42:21 -07:00
David B. Kinder 988a3fe0d6 doc: use code-block:: none for command examples
The ``.. code-block::`` directive can specify a highlight language for
the body of the directive.  Previously the languages "none" and
"console" were the same, but we're now using "console" for creating
terminal-looking output (rather than doing images of terminal windows)
with a black background and white text.

This PR replaces unintended uses of the "console" highlighting language
with "none".

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-07-18 09:31:29 -07:00
Liu, Xinwu b30ba3db15 tools:acrn-crashlog: Detect and classify the crash in ACRN and kernel
Since ACRN has the capability to reboot and reboot reason is available
in SOS, acrnprobe could detect the crash of acrn and SOS kernel.

List of added crash types:

1. ACRNCRASH            - crashed in hypervisor, this detection depends on
                          files in /tmp/acrnlog_last(provided by acrnlog).
2. IPANIC               - crashed in SOS kernel, this detection depends on
                          pstore.
3. SWWDT_IPANIC         - crashed in SOS kernel and reboot reason is wdt.
4. HWWDT_UNHANDLE       - only recognize reboot reason is global, there is no
                          further clues that it's a SOS kernel crash or a
                          hypervisor crash.
5. SWWDT_UNHANDLE       - only recognize reboot reason is wdt, there is no
                          further clues that it's a SOS kernel crash or a
                          hypervisor crash.
6. UNKNOWN              - only recognize reboot reason is warm, there is no
                          further clues that it's a SOS kernel crash or a
                          hypervisor crash.

Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-07-12 17:29:51 +08:00
Liu, Xinwu a5853d6d8a tools:acrn-crashlog: Improve the process of crash reclassify
1. Reload the trigger file(s) of subcrash while doing crash reclassify.
2. Support simple format for trigger file.

Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-07-12 17:29:51 +08:00
Liu, Xinwu 0683b16573 tools:acrn-crashlog: Get reboot reason in acrnprobe
Get system reboot reason from kernel commandline.

Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-07-12 17:29:51 +08:00
CHEN Gang 6494708f2f tools: acrn-crashlog: fix potential buffer overflow issues
This patch is to fix the potential buffer overflow issues.

Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Reviewed-by: xiaojin2 <xiaojing.liu@intel.com>
2018-07-09 09:25:15 +08:00
CHEN Gang 31ebd98797 tools: acrn-crashlog: replace ldconfig with pkg-config in Makefile
This patch is to fix the dependency issue with autospec.

Using ldconfig in the autospec build environment is not
going to work as the packages do not have the cache
generate after a rpm install. This patch replaces ldconfig
with pkg-config to check the existance of the libraries.

Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Jin Zhi <zhi.jin@intel.com>
Reviewed-by: Liu Xinwu <xinwu.liu@intel.com>
Acked-by: Zhang Di <di.zhang@intel.com>
2018-07-03 16:44:58 +08:00
Liu, Xinwu 41b39c5e1f tools: acrn-crashlog: Defer the vm events processing when failed
In the original design, acrnprobe marked all handled VMs'events as "synced"
in file vmrecordid(this patch changes the name to VM_eventsID.log).
Currently, the Android log events are not logged if the first attempt at
reading collecting them from the VM fails. This patch changes the logic
so that the acrn-crashlog tool will retry continuously.

This patch defines different tags for handled VMs'events, and only marks
VMs'events "synced" after it returns successfully.

Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: xiaojin2 <xiaojing.liu@intel.com>
Reviewed-by: Jin Zhi <zhi.jin@intel.com>
Acked-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Chen gang <gang.c.chen@intel.com>
2018-06-29 15:23:18 +08:00
Shuo Liu 1c605a4f50 build: Using id tool to get builder username
Some build environment might has no USER pre-defined. So use id tool to
get builder username instead of USER environemnt.

Also add a version cleanup for tools to keep them updated.

Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-06-29 11:55:03 +08:00
xiaojin2 cb39badf82 tools: acrn-crashlog: fix potential issues under common and usercrash
This patch is to fix buffer overflow, return value not unified and
variable type not matched issues. And add some judge logic to improve
code quality.

Changes:
1. Handle the fd properly in the failing case.
2. Fix buffer overflow issues and null pointer access issues.
3. Fix the format issue in log_sys.c.
4. Remove the useless branch and adjust the function logic.
5. Add some checks for the string length before using strcpy/strcat/memcpy.
6. Fix strncpy null-terminated issues.
7. Change the return value to unify the return type.

Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Signed-off-by: xiaojin2 <xiaojing.liu@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Reviewed-by: Liu Xinwu <xinwu.liu@intel.com>
Acked-by: Zhang Di <di.zhang@intel.com>
2018-06-21 11:29:20 +08:00
Kaige Fu 6137ccd6d6 tools: acrn-crashlog: fix format-security warning
We will get the following warning when build acrn. This patch fix it.
No functional change.

In file included from log_sys.c:8:0:
log_sys.c: In function ‘do_log’:
log_sys.c:44:26: warning: format not a string literal and no format arguments [-Wformat-security]
  sd_journal_print(level, log);
                          ^

Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2018-06-20 12:27:58 +08:00
xiaojin2 3e8e607d5b tools: acrn-crashlog: Fix potential issues under acrnprobe
This patch is to fix potential issues, which are reported by static
analysis tool, for acrnprobe.

Changes:
1. Check the return value of sender_id() and get_sender_by_name(),
   since it could be -1 or NULL.
2. Remove the parameter len from create_event, take parameter path
   as a NULL-terminated string as default.
3. Modify for_each_* functions to avoid overflow.

Signed-off-by: Liu Xinwu <xinwu.liu@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-06-20 11:27:55 +08:00
xiaojin2 0c39b9cddc tools: acrn-crashlog: Fix potential issues for load_conf module of acrnprobe
This patch is to fix potential issues, which are reported by static
analysis tool, for load_conf module of acrnprobe.

Changes:
1. Check the range of id while loading configuration, to avoid
   memory corruption.
2. Use strncpy instead of strcpy to avoid buf overflow.

Signed-off-by: Liu Xinwu <xinwu.liu@intel.com>
Reviewed-by: Zhi Jin <zhi.jin@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
2018-06-20 11:27:55 +08:00