[CRIU] [PATCH] syscall: fix arguments for preadv()

Andrei Vagin avagin at openvz.org
Fri Dec 15 05:30:03 MSK 2017


It has two arguments "pos_l and "pos_h" instead of one "off". It is used
to handle 64-bit offsets on 32-bit kernels.

SYSCALL_DEFINE5(preadv, unsigned long, fd, const struct iovec __user *, vec,
                unsigned long, vlen, unsigned long, pos_l, unsigned long, pos_h)

https://github.com/checkpoint-restore/criu/issues/424
Signed-off-by: Andrei Vagin <avagin at openvz.org>
---
 compel/arch/arm/plugins/std/syscalls/syscall.def     |  2 +-
 .../ppc64/plugins/std/syscalls/syscall-ppc64.tbl     |  2 +-
 .../arch/s390/plugins/std/syscalls/syscall-s390.tbl  |  2 +-
 compel/arch/x86/plugins/std/syscalls/syscall_32.tbl  |  2 +-
 compel/arch/x86/plugins/std/syscalls/syscall_64.tbl  |  2 +-
 compel/plugins/include/uapi/std/syscall-types.h      | 20 ++++++++++++++++++++
 criu/pie/restorer.c                                  |  2 +-
 7 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/compel/arch/arm/plugins/std/syscalls/syscall.def b/compel/arch/arm/plugins/std/syscalls/syscall.def
index 9d0e758ae..b68f9f2f2 100644
--- a/compel/arch/arm/plugins/std/syscalls/syscall.def
+++ b/compel/arch/arm/plugins/std/syscalls/syscall.def
@@ -107,5 +107,5 @@ io_submit			2	246	(aio_context_t ctx_id, long nr, struct iocb **iocbpp)
 io_getevents			4	245	(aio_context_t ctx, long min_nr, long nr, struct io_event *evs, struct timespec *tmo)
 seccomp				277	383	(unsigned int op, unsigned int flags, const char *uargs)
 gettimeofday			169	78	(struct timeval *tv, struct timezone *tz)
-preadv				69	361	(int fd, struct iovec *iov, unsigned long nr, loff_t off)
+preadv_raw			69	361	(int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
 userfaultfd			282	388	(int flags)
diff --git a/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl b/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
index 17cfdc6ec..fa0b034ee 100644
--- a/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
+++ b/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
@@ -104,5 +104,5 @@ __NR_io_getevents	229		sys_io_getevents	(aio_context_t ctx_id, long min_nr, long
 __NR_io_submit		230		sys_io_submit		(aio_context_t ctx_id, long nr, struct iocb **iocbpp)
 __NR_ipc		117		sys_ipc			(unsigned int call, int first, unsigned long second, unsigned long third, const void *ptr, long fifth)
 __NR_gettimeofday	78		sys_gettimeofday	(struct timeval *tv, struct timezone *tz)
-__NR_preadv		320		sys_preadv		(int fd, struct iovec *iov, unsigned long nr, loff_t off)
+__NR_preadv		320		sys_preadv_raw		(int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
 __NR_userfaultfd	364		sys_userfaultfd		(int flags)
diff --git a/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl b/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl
index 1670450ce..bc77ae970 100644
--- a/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl
+++ b/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl
@@ -104,5 +104,5 @@ __NR_io_getevents	245		sys_io_getevents	(aio_context_t ctx_id, long min_nr, long
 __NR_io_submit		246		sys_io_submit		(aio_context_t ctx_id, long nr, struct iocb **iocbpp)
 __NR_ipc		117		sys_ipc			(unsigned int call, int first, unsigned long second, unsigned long third, const void *ptr, long fifth)
 __NR_userfaultfd	355		sys_userfaultfd		(int flags)
-__NR_preadv		328		sys_preadv		(int fd, struct iovec *iov, unsigned long nr, loff_t off)
+__NR_preadv		328		sys_preadv_raw		(int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
 __NR_gettimeofday	78		sys_gettimeofday	(struct timeval *tv, struct timezone *tz)
diff --git a/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl b/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
index c67fc4955..9e1de2815 100644
--- a/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
+++ b/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
@@ -84,7 +84,7 @@ __NR_get_robust_list	312		sys_get_robust_list	(int pid, struct robust_list_head
 __NR_vmsplice		316		sys_vmsplice		(int fd, const struct iovec *iov, unsigned int nr_segs, unsigned int flags)
 __NR_signalfd		321		sys_signalfd		(int ufd, const k_rtsigset_t *sigmask, size_t sigsetsize)
 __NR_timerfd_settime	325		sys_timerfd_settime	(int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
-__NR_preadv		333		sys_preadv		(int fd, struct iovec *iov, unsigned long nr, loff_t off)
+__NR_preadv		333		sys_preadv_raw		(int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
 __NR_rt_tgsigqueueinfo	335		sys_rt_tgsigqueueinfo	(pid_t tgid, pid_t pid, int sig, siginfo_t *uinfo)
 __NR_fanotify_init	338		sys_fanotify_init	(unsigned int flags, unsigned int event_f_flags)
 __NR_fanotify_mark	339		sys_fanotify_mark	(int fanotify_fd, unsigned int flag, uint32_t mask, int dfd, const char *pathname)
diff --git a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
index e1c198929..0200111c7 100644
--- a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
+++ b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
@@ -96,7 +96,7 @@ __NR_seccomp			317		sys_seccomp		(unsigned int op, unsigned int flags, const cha
 __NR_vmsplice			278		sys_vmsplice		(int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags)
 __NR_timerfd_settime		286		sys_timerfd_settime	(int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
 __NR_signalfd4			289		sys_signalfd		(int fd, k_rtsigset_t *mask, size_t sizemask, int flags)
-__NR_preadv			295		sys_preadv		(int fd, struct iovec *iov, unsigned long nr, loff_t off)
+__NR_preadv			295		sys_preadv_raw		(int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
 __NR_rt_tgsigqueueinfo		297		sys_rt_tgsigqueueinfo	(pid_t tgid, pid_t pid, int sig, siginfo_t *info)
 __NR_fanotify_init		300		sys_fanotify_init	(unsigned int flags, unsigned int event_f_flags)
 __NR_fanotify_mark		301		sys_fanotify_mark	(int fanotify_fd, unsigned int flags, uint64_t mask, int dfd, const char *pathname)
diff --git a/compel/plugins/include/uapi/std/syscall-types.h b/compel/plugins/include/uapi/std/syscall-types.h
index 119edb77e..a4b988989 100644
--- a/compel/plugins/include/uapi/std/syscall-types.h
+++ b/compel/plugins/include/uapi/std/syscall-types.h
@@ -15,6 +15,8 @@
 #include <fcntl.h>
 #include <time.h>
 
+#include "common/bitsperlong.h"
+
 struct cap_header {
 	uint32_t version;
 	int pid;
@@ -53,4 +55,22 @@ typedef int kernel_timer_t;
 
 #include <compel/plugins/std/asm/syscall-types.h>
 
+
+extern long sys_preadv_raw(int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h);
+
+#ifndef BITS_PER_LONG
+# error "BITS_PER_LONG isn't defined"
+#endif
+
+#if BITS_PER_LONG == 64
+#define LO_HI_LONG(val) (val), 0
+# else
+#define LO_HI_LONG(val) (long) (val), (((uint64_t) (val)) >> 32)
+#endif
+
+static inline long sys_preadv(int fd, struct iovec *iov, unsigned long nr, off_t off)
+{
+	return sys_preadv_raw(fd, iov, nr, LO_HI_LONG(off));
+}
+
 #endif /* COMPEL_SYSCALL_TYPES_H__ */
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index c2e5b38a5..625a8f4dc 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -1325,7 +1325,7 @@ long __export_restore_task(struct task_restore_args *args)
 					(unsigned long)iovs->iov_base,
 					(int)iovs->iov_len, nr);
 			r = sys_preadv(args->vma_ios_fd, iovs, nr, rio->off);
-			if (r < 0) {
+			if (r <= 0) {
 				pr_err("Can't read pages data (%d)\n", (int)r);
 				goto core_restore_end;
 			}
-- 
2.13.6



More information about the CRIU mailing list