Commit Graph

26 Commits

Author SHA1 Message Date
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 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
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
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
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
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
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
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
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
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
CHEN Gang 7d13e5be1b tools: acrn-crashlog: add documents for acrn-crashlog
This patch adds the documents for acrn-crashlog:
README.rst: General introduction for acrn-crashlog.
acrnprobe/README.rst: Introduction for acrnprobe in detail.
usercrash/README.rst: Introduction for usercrash in detail.

Signed-off-by: xiaojin2 <xiaojing.liu@intel.com>
Signed-off-by: Liu Xinwu <xinwu.liu@intel.com>
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Acked-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-06-11 21:46:56 -07:00
Geoffroy Van Cutsem 7f2a7d47dd Tools Makefiles: enhancement to keep source code tree clean
Running 'make' will leave 3 files in the source code tree that
are not cleaned by a subsequent 'make clean'. These are:
* tools/acrn-crashlog/acrnprobe/include/version.h
* tools/acrn-crashlog/usercrash/include/version.h
* tools/acrn-manager/acrn_mngr.o
(as reported by 'git status' after 'make')

This patch changes the location of these files so they are
created in the target build directory and hence properly
cleaned when running 'make clean'

Other minor changes to the Makefiles include:
* Remove BASEDIR by the built-in CURDIR variable
* Add .PHONY targets

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
2018-06-05 10:22:24 +08:00
Liu, Xinwu 05927b1592 tools: acrn-crashlog: compile without telemetrics client
Define a macro HAVE_TELEMETRICS_CLIENT to distinguish the compiling
environment which is not include telemetrics client.

Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Reviewed-by: Jack Ren <jack.ren@intel.com>
2018-05-23 21:21:51 +08:00
CHEN Gang a9e36bdb4e tools: acrn-crashlog: add service/config files and scripts
This patch adds the service files, config files and script
to run automatically at boot. And it adds install/uninstall
part in Makefile. Compatiblity code for libsystemd.so and
libsystemd-journal.so is added in Makefile also.

Signed-off-by: Jin Zhi <zhi.jin@intel.com>
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhang Yanmin <yanmin.zhang@intel.com>
Reviewed-by: Liu Chuansheng <chuansheng.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-23 17:10:51 +08:00
CHEN Gang d4b4c03cde tools: acrn-crashlog: version control patch for binaries
This patch is the version control patch for the binaries
of acrn-crashlog.

Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhang Yanmin <yanmin.zhang@intel.com>
Reviewed-by: Liu Chuansheng <chuansheng.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-23 17:10:51 +08:00
xiaojin2 6e656dfd3c tools: acrn-crashlog: implementation for the server of usercrash
This patch is the implementation patch for the server of usercrash.

Usercrash works in C/S model: usercrash_s works as usercrash server,
which is to handle events from client in endless loop. Once server
receives dump request from client, it will create usercrash_0x file
under /var/log/usercrashes/ and send file fd to client.

Signed-off-by: xiaojin2 <xiaojing.liu@intel.com>
Reviewed-by: Zhang Yanmin <yanmin.zhang@intel.com>
Reviewed-by: Liu Chuansheng <chuansheng.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-23 17:10:51 +08:00
xiaojin2 14cf505a01 tools: acrn-crashlog: implementation for debugger
This patch is the implementation patch for debugger.

Debugger is the extra feature of usercrash tool. It could be run
without server in command line "debugger pid" to debug the running
process. It will dump the process info on the screen, and also the
info could be reloacted to a file.

Signed-off-by: xiaojin2 <xiaojing.liu@intel.com>
Reviewed-by: Zhang Yanmin <yanmin.zhang@intel.com>
Reviewed-by: Liu Chuansheng <chuansheng.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-23 17:10:51 +08:00
xiaojin2 6627fdf772 tools: acrn-crashlog: implementation for the client of usercrash
This patch is the implementation patch for the client of usercrash.

The usercrash_c works as the client of usercrash to collect crash logs
and information once crash event occurs in the userspace. For each
time, usercrash_c receives 3 params from core_dump and sends connect
request event to the server, then it receives file fd from server to
save crash info into the file. After this work is done, it will notify
server that the dump work is completed.

Signed-off-by: xiaojin2 <xiaojing.liu@intel.com>
Reviewed-by: Zhang Yanmin <yanmin.zhang@intel.com>
Reviewed-by: Liu Chuansheng <chuansheng.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-23 17:10:51 +08:00
xiaojin2 afe1a64948 tools: acrn-crashlog: add APIs for client and debugger
This patch is the initial patch for some APIs for client and debugger.

Usercrash works as C/S model. The usercrash_c runs as the client of
usercrash. File crash_dump.c provides the APIs for client and
debugger to dump some crash information.

Signed-off-by: xiaojin2 <xiaojing.liu@intel.com>
Reviewed-by: Zhang Yanmin <yanmin.zhang@intel.com>
Reviewed-by: Liu Chuansheng <chuansheng.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-23 17:10:51 +08:00
xiaojin2 2ccb5e3887 tools: acrn-crashlog: socket APIs for client/server
This patch is the initialization patch for socket protocol APIs.
It adds the socket APIs for client and server.

Signed-off-by: xiaojin2 <xiaojing.liu@intel.com>
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhang Yanmin <yanmin.zhang@intel.com>
Reviewed-by: Liu Chuansheng <chuansheng.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-23 17:10:51 +08:00
Liu Xinwu 6f9dfa49bf tools: acrn-crashlog: framework of acrn-crashlog
This is the first patch of acrn-crashlog.

This patch initializes the framework of acrn-crashlog: acrnprobe,
common, data, and usercrash. And it initializes the Makefile for
each part.

Signed-off-by: Liu Xinwu <xinwu.liu@intel.com>
Signed-off-by: CHEN Gang <gang.c.chen@intel.com>
Reviewed-by: Zhang Yanmin <yanmin.zhang@intel.com>
Reviewed-by: Liu Chuansheng <chuansheng.liu@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
2018-05-23 17:10:51 +08:00