Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take this commits in mainstream pls #1

Merged
merged 8 commits into from Nov 30, 2011
Merged

Conversation

avagin
Copy link
Collaborator

@avagin avagin commented Nov 30, 2011

  • dump/restore sigactions
  • some small fixes

ZDTM tests redirect standart descriptors to /dev/null

v2: * Skip tty only if it's a standard descriptor.
    * No strcmps on names.

Acked-by: Pavel Emelyanov <xemul@parallels.com>
It will be used for dumping sigactions too.
A parasite code dumps all sigactions in sigact.pid.

v2: remove hard code for sizeof(sigset_t)

Acked-by: Pavel Emelyanov <xemul@parallels.com>
It's because this mask will be restored as rt_sigframe->uc.uc_sigmask.
uc_sigmask will be set as current->blocked in sigreturn, so we should
dump SigBlk in this case.
It's work for /dev/zero, /dev/null and other simple devices.
pipe_loop00 passed with this patch.

When we restore a regular fd (not pipe) we do use flags
directly in open() call.

Acked-by: Pavel Emelyanov <xemul@parallels.com>
If I understand correct, they don't differ in linux.
@cyrillos cyrillos merged this pull request into cyrillos:master Nov 30, 2011
avagin added a commit to avagin/crtools that referenced this pull request Apr 5, 2013
CID 996207 (cyrillos#1 of 1): Out-of-bounds access (OVERRUN)
5. alloc_strlen: Allocating insufficient memory for the terminating null of the string.
avagin added a commit to avagin/crtools that referenced this pull request Apr 5, 2013
CID 996205 (cyrillos#1-2 of 2): Resource leak (RESOURCE_LEAK)
14. leaked_storage: Variable "core" going out of scope leaks the storage it points to.
avagin added a commit to avagin/crtools that referenced this pull request Apr 5, 2013
CID 996204 (cyrillos#1 of 1): Resource leak (RESOURCE_LEAK)
11. leaked_storage: Variable "ch" going out of scope leaks the storage it points to.
avagin added a commit to avagin/crtools that referenced this pull request Apr 5, 2013
CID 996203 (cyrillos#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_storage: Variable "vma" going out of scope leaks the storage it points to.
avagin added a commit to avagin/crtools that referenced this pull request Apr 5, 2013
CID 996201 (cyrillos#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable "fd" going out of scope leaks the handle.

CID 996202 (cyrillos#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable "fd" going out of scope leaks the handle.
avagin added a commit to avagin/crtools that referenced this pull request Apr 5, 2013
CID 996197 (cyrillos#1 of 1): Resource leak (RESOURCE_LEAK)
8. leaked_storage: Variable ppb going out of scope leaks the storage it points to.
cyrillos pushed a commit that referenced this pull request Apr 5, 2013
CID 996207 (#1 of 1): Out-of-bounds access (OVERRUN)
5. alloc_strlen: Allocating insufficient memory for the terminating null of the string.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cyrillos pushed a commit that referenced this pull request Apr 5, 2013
CID 996205 (#1-2 of 2): Resource leak (RESOURCE_LEAK)
14. leaked_storage: Variable "core" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cyrillos pushed a commit that referenced this pull request Apr 5, 2013
CID 996204 (#1 of 1): Resource leak (RESOURCE_LEAK)
11. leaked_storage: Variable "ch" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cyrillos pushed a commit that referenced this pull request Apr 5, 2013
CID 996203 (#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_storage: Variable "vma" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cyrillos pushed a commit that referenced this pull request Apr 5, 2013
CID 996201 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable "fd" going out of scope leaks the handle.

CID 996202 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable "fd" going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cyrillos pushed a commit that referenced this pull request Apr 5, 2013
CID 996197 (#1 of 1): Resource leak (RESOURCE_LEAK)
8. leaked_storage: Variable ppb going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
avagin added a commit to avagin/crtools that referenced this pull request Apr 6, 2013
* Call restore_ns on error paths.
* Use close_safe for the socket, because it can be reused

CID 996194 (cyrillos#1 of 3): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable "rst" going out of scope leaks the
handle.
avagin added a commit to avagin/crtools that referenced this pull request Apr 6, 2013
mnt_entry contains a few strings and they should be release too

CID 996198 (cyrillos#4 of 4): Resource leak (RESOURCE_LEAK)
20. leaked_storage: Variable "pm" going out of scope leaks the storage
it points to.

CID 996190 (cyrillos#1 of 1): Resource leak (RESOURCE_LEAK)
13. leaked_storage: Variable "new" going out of scope leaks the storage
it points to.
cyrillos pushed a commit that referenced this pull request Apr 10, 2013
CID 996187 (#1 of 1): Resource leak (RESOURCE_LEAK)
10. leaked_storage: Variable "buf" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cyrillos pushed a commit that referenced this pull request Apr 10, 2013
CID 996188 (#1 of 1): Resource leak (RESOURCE_LEAK)
13. leaked_storage: Variable sd going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cyrillos pushed a commit that referenced this pull request Apr 10, 2013
mnt_entry contains a few strings and they should be release too

CID 996198 (#4 of 4): Resource leak (RESOURCE_LEAK)
20. leaked_storage: Variable "pm" going out of scope leaks the storage
it points to.

CID 996190 (#1 of 1): Resource leak (RESOURCE_LEAK)
13. leaked_storage: Variable "new" going out of scope leaks the storage
it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cyrillos pushed a commit that referenced this pull request Apr 11, 2013
* Call restore_ns on error paths.
* Use close_safe for the socket, because it can be reused

CID 996194 (#1 of 3): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable "rst" going out of scope leaks the
handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cyrillos pushed a commit that referenced this pull request Apr 16, 2013
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>
cyrillos pushed a commit that referenced this pull request Apr 16, 2013
Don't call close() with degative fd. For consistency
simply use close_safe here. All fds touched are initialized
either to valid fd or to value < 0 which pretty good handled
by close_safe helper.

CID 996212 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
10. negative_returns: "fd" 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>
cyrillos pushed a commit that referenced this pull request Feb 20, 2018
CID 154076 (#1 of 1): Unchecked return value from library (CHECKED_RETURN)
1. check_return: Calling setsockopt(sk, 6, 1, &val, 4U) without checking return value. This library function may fail and return an error code.
cyrillos pushed a commit that referenced this pull request Feb 20, 2018
CID 73358 (#1 of 1): Improper use of negative value (NEGATIVE_RETURNS)
8. negative_returns: sk is passed to a parameter that cannot be negative. [hide details]
cyrillos pushed a commit that referenced this pull request Feb 20, 2018
CID 172198 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_storage: Variable sk going out of scope leaks the storage it points to.
cyrillos pushed a commit that referenced this pull request Feb 20, 2018
CID 181219 (#1 of 1): Dereference null return value (NULL_RETURNS)
3. dereference: Dereferencing a null pointer ns.
cyrillos pushed a commit that referenced this pull request Feb 20, 2018
CID 155804 (#1 of 1): Unchecked return value (CHECKED_RETURN)
2. check_return: Calling umount2 without checking return value (as is done elsewhere 8 out of 9 times).
cyrillos pushed a commit that referenced this pull request Feb 20, 2018
CID 85039 (#1 of 1): Unchecked return value (CHECKED_RETURN)
6. check_return: Calling ptrace without checking return value (as is done elsewhere 44 out of 49 times).
cyrillos pushed a commit that referenced this pull request May 10, 2018
In addition to writing the CRIU version to the log file this adds the
current kernel version to the log file:

(00.000008) Version: 3.5 (gitid v3.5-511-ga8cc6cf)
(00.000303) Running on node01 Linux 3.10.0-513.el7.x86_64 #1 SMP Tue Feb 29 06:78:90 EST 2017 x86_64

v2:
 - small changes as suggested by Dmitry (thanks)

Signed-off-by: Adrian Reber <areber@redhat.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request May 10, 2018
CID 161693 (#1 of 1): Resource leak (RESOURCE_LEAK)
5. leaked_storage: Variable new going out of scope leaks the storage it points to.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request May 10, 2018
CID 154076 (#1 of 1): Unchecked return value from library (CHECKED_RETURN)
1. check_return: Calling setsockopt(sk, 6, 1, &val, 4U) without checking return value. This library function may fail and return an error code.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request May 10, 2018
CID 172198 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_storage: Variable sk going out of scope leaks the storage it points to.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request May 10, 2018
CID 155804 (#1 of 1): Unchecked return value (CHECKED_RETURN)
2. check_return: Calling umount2 without checking return value (as is done elsewhere 8 out of 9 times).

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request May 10, 2018
CID 85039 (#1 of 1): Unchecked return value (CHECKED_RETURN)
6. check_return: Calling ptrace without checking return value (as is done elsewhere 44 out of 49 times).

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request May 17, 2018
CID 84654 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable fd going out of scope leaks the handle.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request May 17, 2018
CID 190175 (#1 of 1): Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement: goto err;.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request May 17, 2018
CID 190174 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
6. negative_returns: fd is passed to a parameter that cannot be negative.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Jul 19, 2018
CID 84654 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable fd going out of scope leaks the handle.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Jul 19, 2018
CID 190175 (#1 of 1): Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement: goto err;.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Jul 19, 2018
CID 190174 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
6. negative_returns: fd is passed to a parameter that cannot be negative.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Aug 7, 2018
CID 190778 (#1 of 1): Read from pointer after free (USE_AFTER_FREE)
7. deref_after_free: Dereferencing freed pointer rop.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Aug 7, 2018
CID 190777 (#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_handle: Handle variable server_fd going out of scope leaks the handle.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Aug 7, 2018
CID 190775 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking m->parent suggests that it may be null,
but it has already been dereferenced on all paths leading to the check.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Aug 7, 2018
CID 190774 (#1 of 1): Out-of-bounds access (OVERRUN)
5. overrun-buffer-arg: Overrunning array addr.sun_path of 108 bytes by
passing it to a function which accesses it at byte offset 4094 using
argument ui->ue->name.len (which evaluates to 4095).

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Dec 7, 2018
CID 190777 (#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_handle: Handle variable server_fd going out of scope leaks the handle.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Dec 7, 2018
CID 190775 (#1 of 1): Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking m->parent suggests that it may be null,
but it has already been dereferenced on all paths leading to the check.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Dec 7, 2018
CID 190774 (#1 of 1): Out-of-bounds access (OVERRUN)
5. overrun-buffer-arg: Overrunning array addr.sun_path of 108 bytes by
passing it to a function which accesses it at byte offset 4094 using
argument ui->ue->name.len (which evaluates to 4095).

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Dec 7, 2018
CID 190778 (#1 of 1): Read from pointer after free (USE_AFTER_FREE)
7. deref_after_free: Dereferencing freed pointer rop.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request May 16, 2019
CID 190778 (#1 of 1): Read from pointer after free (USE_AFTER_FREE)
7. deref_after_free: Dereferencing freed pointer rop.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
cyrillos pushed a commit that referenced this pull request Jul 5, 2019
Segmentation fault was raised while trying to restore a process with
tty. Coredump file says this is caused by uninitialized tty_mutex:
        (gdb) where
        #0  0x00000000004d7270 in atomic_add_return (i=1, v=0x0) at
        include/common/asm/atomic.h:34
        #1  0x00000000004d7398 in mutex_lock (m=0x0) at
        include/common/lock.h:151
        #2  0x00000000004d840c in __pty_open_ptmx_index (index=3, flags=2,
        cb=0x4dce50 <open_pty>, arg=0x11, path=0x5562e0 "ptmx") at
        criu/tty.c:603
        #3  0x00000000004dced8 in pty_create_ptmx_index (dfd=17, index=3,
        flags=2) at criu/tty.c:2384

since init_tty_mutex() is reentrantable, just calling it before
mutex_lock()

Signed-off-by: Deng Guangxing <dengguangxing@huawei.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
cyrillos pushed a commit that referenced this pull request May 31, 2020
Segmentation fault was raised while trying to restore a process with
tty. Coredump file says this is caused by uninitialized tty_mutex:
        (gdb) where
        #0  0x00000000004d7270 in atomic_add_return (i=1, v=0x0) at
        include/common/asm/atomic.h:34
        #1  0x00000000004d7398 in mutex_lock (m=0x0) at
        include/common/lock.h:151
        #2  0x00000000004d840c in __pty_open_ptmx_index (index=3, flags=2,
        cb=0x4dce50 <open_pty>, arg=0x11, path=0x5562e0 "ptmx") at
        criu/tty.c:603
        #3  0x00000000004dced8 in pty_create_ptmx_index (dfd=17, index=3,
        flags=2) at criu/tty.c:2384

since init_tty_mutex() is reentrantable, just calling it before
mutex_lock()

Signed-off-by: Deng Guangxing <dengguangxing@huawei.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
cyrillos pushed a commit that referenced this pull request May 31, 2020
CID 190778 (#1 of 1): Read from pointer after free (USE_AFTER_FREE)
7. deref_after_free: Dereferencing freed pointer rop.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants