2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 12:57:57 +00:00

42 Commits

Author SHA1 Message Date
Tycho Andersen
ae3cb4fb1f restore: open the pidfile with O_EXCL
There is a potential attack here where if someone is restoring something and
criu write the pid to a file the attacker controls, the attacker can then
re-write that to whatever pid they want. ciru should instead open the file with
O_EXCL so that the restore fails if the file exists.

We don't need O_TRUNC here since we're O_EXCL-ing the file.

Reported-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-03 20:58:24 +04:00
Pavel Emelyanov
49b427b721 log: Don't override -v0 with -v2
If we specify log level to none (0) the result is LOG_INFO (2).

Acked-by: Andrew Vagin <avagin@parallels.com>
Acked-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-02-04 20:54:25 +04:00
Kir Kolyshkin
5f9b8794e0 log: only print timestamps when verbosity increased
While timestamps can be handy, they clutter output for normal users.
Let's print them only when verbosity (-v) is increased from default.
Currently, default is 2 (-vv) so for timestamps one should use -vvv
or -v3.

Alternatively, we could introduce a separate --timestamps option.
Personally, I find it more handy for timestamps to be tied to log level.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-11 09:18:03 +04:00
Kir Kolyshkin
3d9ff2706f print_on_level(): simplify off setting code
This is a slight refactoring of commit 7de9652, which just simplifies
initialization of 'off' variable, and adds the comment why we do so.
Should make the next patch easier to read.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-11 09:17:55 +04:00
Kir Kolyshkin
5a4c1f7368 log.c: fix a typo in a comment
This is just s/and/end/ to slightly improve readability.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-01-11 09:17:26 +04:00
Pavel Emelyanov
c3b9448cf7 pidfile: Don't push opts.pidfile as write_pidfile arg
opts are criu-wide available.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-20 14:26:41 +04:00
Ruslan Kuprieiev
dc80d6f125 log: get rid of LOG_DIR_FD_OFF and opening cwd in log_init()
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-15 21:38:41 +04:00
Andrey Vagin
4850fd94a8 crtools: move cr_options in a separate header
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 18:17:52 +04:00
Andrey Vagin
824403a009 crtools: create new header for servicefd stuff (v2)
v2: generate patch relative to the official git.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-06 12:43:02 +04:00
Ruslan Kuprieiev
95a961b739 log: don't kill task, if unable to write pidfile
write_pidfile() was taken out from cr-restore.c, where it was supposed to kill
child if unable to create pidfile. Now we're also using it at service/page-server where kill is redundant. So lets take out kill() from write_pidfile() back to cr-restore.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-11-03 12:51:13 +04:00
Ruslan Kuprieiev
4eb2872b27 v2 crtools: write pidfile, when service/page server is run as daemon and "--pidfile" is set
When service/page server becomes daemon, we may need to know it's pid.

Signed-off-by: Ruslan Kuprieiev<kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:45:01 +04:00
Cyrill Gorcunov
ab0eb45d8a log: log_init -- Check for dup return code
Don't pass negative descriptor to install_service_fd

CID 996213 (#1 of 1): Improper use of negative value (NEGATIVE_RETURNS)
7. negative_returns: "new_logfd" is passed to a parameter that cannot be negative.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-12 20:50:27 +04:00
Cyrill Gorcunov
24887c6e9c log: Add generic __print_on_level helper
It accepts va_list argument and suitable to
be wrapped with another helpers.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-14 14:26:18 +04:00
Andrey Vagin
4ea6214391 crtools: add ability to create and close a service fd (v3)
A service fd should be created, otherwise get_service_fd returns -1.

This patch removes this functionality from other subsystems and
allows to clone service descriptors.

v2: rename open_service_fd to install_service_fd
v3: two patches were merged for bisecting

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-12 00:54:37 +04:00
Alexander Kartashov
6f61488f21 x86: moved x86-specific files into the directory arch/x86.
* The following files goes into the directory arch/x86/include/asm unmodified:
  - include/atomic.h,
  - include/linkage.h,
  - include/memcpy_64.h,
  - include/types.h,
  - include/bitops.h,
  - pie/parasite-head-x86-64.S,
  - include/processor-flags.h,
  - include/syscall-x86-64.def.

* Changed include directives in the source files that include the headers
  listed above.

* Modified build scripts to reflect the source moves.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:02:47 +04:00
Cyrill Gorcunov
7de965260e log: Don't show time stamp on pr_msg
In case if the pr_err happens before pr_msg,
the string buffer will have dangling timestamp
prefix. Skip it here.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-06 13:37:15 +04:00
Pavel Emelyanov
37a7b35e88 log: Move default loglevel macro to header
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-07 21:03:53 +04:00
Pavel Emelyanov
9a54d64539 log: Merge two loglevel checks
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 20:55:23 +04:00
Cyrill Gorcunov
2b56175e49 log: Don't print time-stamp on LOG_MSG
Otherwise "show" action become unreadable.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 19:22:23 +04:00
Pavel Emelyanov
87cf4ad128 log: Add relative timestamp before each log line
I find this handy.

Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-03 02:18:01 +04:00
Cyrill Gorcunov
3a00f4cdc8 log: Add log_get_loglevel() helper
Will need it to fetch log level for restorer code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-03 14:44:01 +04:00
Andrey Vagin
9ec01ff307 log: don't create a log file in a current directory
We can set a directory for log and image files.
crtools sets it as a current directory and then creates all files in it.
It works before we don't decide to change a mount name space.

I suggest to open a log dir and create files for help openat.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-09-02 01:02:30 +04:00
Pavel Emelyanov
092ae8c999 log: Remove message saying the log level set
Was added for debugging. Spoils the "show" output.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-20 13:44:30 +04:00
Pavel Emelyanov
76e7f12cb8 log: Fix loglevel assignment
For some reason the optind was misused (maybe I broke it with prev patch)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 17:25:04 +04:00
Cyrill Gorcunov
301b2fe2ce log: Open logc files with O_TRUNC
It's really confusing when one use -o option
and didn't see update on top of log file.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-30 12:29:50 +04:00
Andrey Vagin
fc7bedc50a crtools: make to be able to split messages by pid
If the option --log-pid is set, each process will have an own log file.
Otherwise PID is added to each log message.

A message can't be bigger than one page minus some bytes for pid.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-04 16:22:04 +04:00
Pavel Emelyanov
b63451e58d log: Open log file with O_APPEND
Otherwise multiple writers can screw each-other's messages.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 22:06:00 +04:00
Andrey Vagin
dcc37a09e0 log: don't fail if a log descriptor is reopened
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 23:50:33 +04:00
Andrey Vagin
c4458cb50d log: don't close STDERR
reopen_fd_as closes old descriptor.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 23:49:42 +04:00
Andrey Vagin
492da1c363 log: change a logging descriptor when it was initialized
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 23:48:28 +04:00
Pavel Emelyanov
652363d7fc log: Specify logfile mode when creating one
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-28 00:48:13 +04:00
Pavel Emelyanov
3dd8f2e659 fds: Introduce service fd-s
These are the fds that help us to do c/r. We want them not to intersect
with any "real-life" ones and thus store them close the the file rlimit
boundary. For now only the logfd one is such.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-16 20:45:42 +04:00
Cyrill Gorcunov
fede33e047 log: Simplify log_init
- drop redundant current_logfd assignment
 - assign new_logfd at the beginning

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-05 19:27:29 +04:00
Pavel Emelyanov
ba64f87bfa log: Fix logfd screwup
Broken by 7aa8e4b6 -- log was not moved to higher fd values.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Cyrill Gorcunov
7aa8e4b6e2 log: log-engine slight redesign
The messages are filtered by their type

    LOG_MSG     - plain messages, they escape any (!) log level
                  filtration and go to stdout
    LOG_ERROR   - error messages
    LOG_WARN    - warning messages
    LOG_INFO    - informative messages
    LOG_DEBUG   - debug messages

By default the LOG_WARN log level is used, thus LOG_INFO
and LOG_DEBUG messages will not appear in output stream.

pr_panic helper was replaced with pr_err, pr_warning
shorthanded to pr_warn and old printk if rather pr_msg
now.

Because we share messages between "show" and "dump" actions,
before the "show" action proceed we need to tune up
log level and set it to LOG_INFO.

Also note that printing of VMA and siginfo now
became LOG_INFO messages, it was not that correct
to print them regardless the log level.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-02 01:05:43 +04:00
Cyrill Gorcunov
9aa2252ca0 log: Fix typo in in fini_log
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-02 01:05:43 +04:00
Cyrill Gorcunov
ef97467da9 log: Add log-levels
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-20 14:23:28 +04:00
Cyrill Gorcunov
fe99f501ef Move pr_ helpers to log.[ch]
This is a place where they should belong to.
util.c is too big already.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-20 14:23:28 +04:00
Kir Kolyshkin
0b237ae9f2 pr_perror(): print error at the end of line
This is a standard convention to print error message (i.e. strerror(errno))
at the end of line, like this:

        Cannot remove file: Permission denied

So pr_perror is fixed to follow this convention (using GNU extension
%m helps a lot here). Unfortunately, due to this we have to make
pr_perror() print a new line character, too, so we had to strip it
from the all pr_perror() invocations.

That (appending a newline) also makes pr_perror() a black sheep
in the herd of pr_* helpers, but what can we do? Worst case scenario
is an extra newline after an error message, not too harmful.

An alternative approach (stripping the newline from the passed format
string and re-adding it) was discussed thoroughly, and it was decided
that such a hack looks a bit too dirty.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 15:49:15 +04:00
Andrey Vagin
f274f16081 log: close unused descriptor
This code opens a log file and duplicates the descriptor to logfd,
but forgets to close the first one.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 16:43:31 +04:00
Cyrill Gorcunov
350225a2ae log: Drop unneeded #includes
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 23:22:31 +04:00
Cyrill Gorcunov
d6eab944e3 Move logging functions to log.c
Instead of keeping all unrelated to
C/R procedure helpers in util.c move
logging related helpers to log.c.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-19 18:52:50 +04:00