2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00

seize: Fix size error in creds_dumpable()

The goal of this function is to compare everything except caps,
but caps size is took to compare. It's wrong, there must be
used offsetof(struct proc_status_creds, cap_inh) instead.

Also, sigpnd may be different too.

v3: Move excluding sigpnd from comparation in this patch (was in another patch).
    Reorder fields in seize_task_status().

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Kirill Tkhai
2017-05-03 15:48:14 +03:00
committed by Andrei Vagin
parent 6329e660a4
commit 0469a46a55
2 changed files with 8 additions and 8 deletions

View File

@@ -16,10 +16,10 @@
extern int compel_interrupt_task(int pid);
struct seize_task_status {
char state;
int ppid;
unsigned long long sigpnd;
unsigned long long shdpnd;
char state;
int ppid;
int seccomp_mode;
};

View File

@@ -629,9 +629,7 @@ static inline bool thread_collected(struct pstree_item *i, pid_t tid)
static bool creds_dumpable(struct proc_status_creds *parent,
struct proc_status_creds *child)
{
const size_t size = sizeof(struct proc_status_creds) -
offsetof(struct proc_status_creds, cap_inh);
size_t size;
/*
* The comparison rules are the following
*
@@ -640,17 +638,20 @@ static bool creds_dumpable(struct proc_status_creds *parent,
* semantic comparison (FIXME) but for
* now we require them to be exactly
* identical
* - sigpnd may be different
* - the rest of members must match
*/
if (memcmp(parent, child, size)) {
size = offsetof(struct proc_status_creds, cap_inh) -
sizeof(parent->s.sigpnd);
if (memcmp(&parent->s.sigpnd, &child->s.sigpnd, size)) {
if (!pr_quelled(LOG_DEBUG)) {
pr_debug("Creds undumpable (parent:child)\n"
" uids: %d:%d %d:%d %d:%d %d:%d\n"
" gids: %d:%d %d:%d %d:%d %d:%d\n"
" state: %d:%d"
" ppid: %d:%d\n"
" sigpnd: %llu:%llu\n"
" shdpnd: %llu:%llu\n"
" seccomp_mode: %d:%d\n"
" last_filter: %u:%u\n",
@@ -664,7 +665,6 @@ static bool creds_dumpable(struct proc_status_creds *parent,
parent->gids[3], child->gids[3],
parent->s.state, child->s.state,
parent->s.ppid, child->s.ppid,
parent->s.sigpnd, child->s.sigpnd,
parent->s.shdpnd, child->s.shdpnd,
parent->s.seccomp_mode, child->s.seccomp_mode,
parent->last_filter, child->last_filter);