[CRIU] [PATCH 2/5] seize: Reorder struct proc_status_creds
Kirill Tkhai
ktkhai at virtuozzo.com
Sat Apr 15 10:15:44 PDT 2017
Time goes, and new fields are being implemented
in /proc/[pid]/status file. Some of them may be
variable len, e.g. NSpid and friends.
Next patches will allow struct seize_task_status
be extensible to confirm the time challenges. So,
in this case simple comparation in creds_dumpable()
won't work, as we're interested in currently known
fields there.
The patch reorders struct proc_status_creds and
places proc_status_creds::s before uncompared fields.
This will allow to continue use memcpy() to compare
the data from beginning of struct proc_status_creds
to proc_status_creds::s::seccomp_mode.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/include/proc_parse.h | 7 +++----
criu/seize.c | 5 ++++-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/criu/include/proc_parse.h b/criu/include/proc_parse.h
index d67ac5e56..91f2adb51 100644
--- a/criu/include/proc_parse.h
+++ b/criu/include/proc_parse.h
@@ -73,17 +73,16 @@ struct seccomp_info {
#define PROC_CAP_SIZE 2
struct proc_status_creds {
- struct seize_task_status s;
-
unsigned int uids[4];
unsigned int gids[4];
u32 last_filter;
/*
- * Keep them at the end of structure
- * for fast comparison reason.
+ * Keep them at the end of structure for fast comparison
+ * reason (see creds_dumpable()); and place s before caps.
*/
+ struct seize_task_status s;
u32 cap_inh[PROC_CAP_SIZE];
u32 cap_prm[PROC_CAP_SIZE];
u32 cap_eff[PROC_CAP_SIZE];
diff --git a/criu/seize.c b/criu/seize.c
index eda4e8a27..5727b8ff8 100644
--- a/criu/seize.c
+++ b/criu/seize.c
@@ -629,7 +629,10 @@ 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 = offsetof(struct proc_status_creds, cap_inh);
+ /* From beginning of struct to proc_status_creds::s::seccomp_mode */
+ const size_t size = ((unsigned long)&parent->s.seccomp_mode) -
+ ((unsigned long)parent) +
+ sizeof(parent->s.seccomp_mode);
/*
* The comparison rules are the following
More information about the CRIU
mailing list