[CRIU] [PATCH 1/2] timerfd: move the clockid check to dump time too
Tycho Andersen
tycho.andersen at canonical.com
Thu Oct 6 15:27:56 PDT 2016
but let's keep it during restore, since there might be images around that
were generated before we did this check at dump.
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
CC: Cyrill Gorcunov <gorcunov at openvz.org>
---
criu/include/timerfd.h | 14 ++++++++++++++
criu/proc_parse.c | 4 ++++
criu/timerfd.c | 11 -----------
3 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/criu/include/timerfd.h b/criu/include/timerfd.h
index 9a7829f..f31d7a1 100644
--- a/criu/include/timerfd.h
+++ b/criu/include/timerfd.h
@@ -6,6 +6,8 @@
#include "files.h"
+#include "images/timerfd.pb-c.h"
+
struct pstree_item;
struct restore_timerfd {
@@ -34,4 +36,16 @@ extern int is_timerfd_link(char *link);
# define TFD_IOC_SET_TICKS _IOW('T', 0, u64)
#endif
+static inline int verify_timerfd(TimerfdEntry *tfe)
+{
+ if (tfe->clockid != CLOCK_REALTIME &&
+ tfe->clockid != CLOCK_MONOTONIC) {
+ pr_err("Unknown clock type %d for %#x\n", tfe->clockid, tfe->id);
+ return -1;
+ }
+
+ return 0;
+}
+
+
#endif /* __CR_TIMERFD_H__ */
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index 204c31e..17a3ca2 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -36,6 +36,7 @@
#include "files-reg.h"
#include "cgroup.h"
#include "cgroup-props.h"
+#include "timerfd.h"
#include "protobuf.h"
#include "images/fdinfo.pb-c.h"
@@ -1572,6 +1573,9 @@ static int parse_timerfd(struct bfd *f, char *str, TimerfdEntry *tfy)
if (sscanf(str, "clockid: %d", &tfy->clockid) != 1)
goto parse_err;
+ if (verify_timerfd(tfy) < 0)
+ goto parse_err;
+
str = breadline(f);
if (IS_ERR_OR_NULL(str))
goto nodata;
diff --git a/criu/timerfd.c b/criu/timerfd.c
index 83b92b3..53be2af 100644
--- a/criu/timerfd.c
+++ b/criu/timerfd.c
@@ -176,17 +176,6 @@ static struct file_desc_ops timerfd_desc_ops = {
.post_open = timerfd_post_open,
};
-static int verify_timerfd(TimerfdEntry *tfe)
-{
- if (tfe->clockid != CLOCK_REALTIME &&
- tfe->clockid != CLOCK_MONOTONIC) {
- pr_err("Unknown clock type %d for %#x\n", tfe->clockid, tfe->id);
- return -1;
- }
-
- return 0;
-}
-
static int collect_one_timerfd(void *o, ProtobufCMessage *msg, struct cr_img *i)
{
struct timerfd_info *info = o;
--
2.9.3
More information about the CRIU
mailing list