Commit caf933bf authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

timerfd: move the clockid check to dump time too

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: 's avatarTycho Andersen <tycho.andersen@canonical.com>
CC: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 78a3670b
......@@ -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__ */
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment