[CRIU] [PATCH v3 1/2] seize: Fix size error in creds_dumpable()
Kirill Tkhai
ktkhai at virtuozzo.com
Wed May 3 05:48:14 PDT 2017
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 at virtuozzo.com>
---
compel/include/uapi/infect.h | 4 ++--
criu/seize.c | 12 ++++++------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/compel/include/uapi/infect.h b/compel/include/uapi/infect.h
index 005d6bda6..0d79f1346 100644
--- a/compel/include/uapi/infect.h
+++ b/compel/include/uapi/infect.h
@@ -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;
};
diff --git a/criu/seize.c b/criu/seize.c
index 7e44d136c..450b83af5 100644
--- a/criu/seize.c
+++ b/criu/seize.c
@@ -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);
More information about the CRIU
mailing list