[CRIU] [PATCH 21/23] restorer: wrapped the syscall sys_setrlimit

Alexander Kartashov alekskartashov at parallels.com
Mon Jan 14 02:26:03 EST 2013


The layout of the struct rlimit depends on the value
of the macro FILE_OFFSET_BITS. If FILE_OFFSET_BITS is 64
the userspace and kernel definitions becomes incoherent
on a 32-bit platform. The following is proposed
to address the issue:

* The syscall sys_setrlimit is wrapped into the macro arch_setrlimit
  that is designated to convert the userspace representation
  of the struct rlimit to the kernel one.

* Introduced the struct krlimit to represent the kernel version
  of the struct rlimit.

Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
 arch/x86/include/asm/restorer.h |    2 ++
 include/syscall-types.h         |    2 ++
 pie/restorer.c                  |    2 +-
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/restorer.h b/arch/x86/include/asm/restorer.h
index 08b53ca..5270807 100644
--- a/arch/x86/include/asm/restorer.h
+++ b/arch/x86/include/asm/restorer.h
@@ -140,4 +140,6 @@ int restore_fpu(struct rt_sigframe *sigframe, struct thread_restore_args *args);
 
 static inline void restore_tls(u32 tls) { }
 
+#define arch_setrlimit sys_setrlimit
+
 #endif
diff --git a/include/syscall-types.h b/include/syscall-types.h
index 7ef56bd..27dd395 100644
--- a/include/syscall-types.h
+++ b/include/syscall-types.h
@@ -59,4 +59,6 @@ struct robust_list_head;
 
 struct rlimit;
 
+struct krlimit;
+
 #endif /* __CR_SYSCALL_TYPES_H__ */
diff --git a/pie/restorer.c b/pie/restorer.c
index c8ceb6c..aec78ba 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -148,7 +148,7 @@ static void restore_rlims(struct task_restore_core_args *ta)
 	int r;
 
 	for (r = 0; r < ta->nr_rlim; r++)
-		sys_setrlimit(r, &ta->rlims[r]);
+		arch_setrlimit(r, &ta->rlims[r]);
 }
 
 static int restore_thread_common(struct rt_sigframe *sigframe,
-- 
1.7.10.4



More information about the CRIU mailing list