|
From: Steven Stewart-G. <sst...@my...> - 2014-08-27 01:21:30
|
As containers get more and more important supporting system calls like
pivot_root and unshare get more important. This patch adds support for
the system call to unshare namespaces and containerize applications,
and adds support for pivot_root which switches mount points around in
the container.
Signed-off-by: Steven Stewart-Gallus <sst...@my...>
---
Hello! I'm not sure if I should add support for other architectures if I
only tested on amd64. It should probably work though.
Thank you,
Steven Stewart-Gallus
diff -upr
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/priv_syswrap-linux.h
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/priv_syswrap-linux.h
---
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/priv_syswrap-linux.h
2013-10-23 03:50:12.000000000 -0700
+++
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/priv_syswrap-linux.h
2014-08-26 16:46:03.192454569 -0700
@@ -87,6 +87,7 @@ DECL_TEMPLATE(linux, sys_syslog);
DECL_TEMPLATE(linux, sys_vhangup);
DECL_TEMPLATE(linux, sys_sysinfo);
DECL_TEMPLATE(linux, sys_personality);
+DECL_TEMPLATE(linux, sys_pivot_root);
DECL_TEMPLATE(linux, sys_sysctl);
DECL_TEMPLATE(linux, sys_prctl);
DECL_TEMPLATE(linux, sys_sendfile);
@@ -231,6 +232,8 @@ DECL_TEMPLATE(linux, sys_sched_rr_get_in
DECL_TEMPLATE(linux, sys_sched_setaffinity);
DECL_TEMPLATE(linux, sys_sched_getaffinity);
+DECL_TEMPLATE(linux, sys_unshare);
+
// These ones have different parameters and/or return values on Darwin.
// Also, some archs on Linux do not match the generic wrapper for sys_pipe.
DECL_TEMPLATE(linux, sys_munlockall);
diff -upr
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-amd64-linux.c
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-amd64-linux.c
---
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-amd64-linux.c
2013-10-23 03:50:12.000000000 -0700
+++
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-amd64-linux.c
2014-08-26 16:51:50.732439954 -0700
@@ -894,7 +894,7 @@ static SyscallTableEntry syscall_table[]
LINX_(__NR_vhangup, sys_vhangup), // 153
// (__NR_modify_ldt, sys_modify_ldt), // 154
- // (__NR_pivot_root, sys_pivot_root), // 155
+ LINX_(__NR_pivot_root, sys_pivot_root), // 155
LINXY(__NR__sysctl, sys_sysctl), // 156
LINXY(__NR_prctl, sys_prctl), // 157
PLAX_(__NR_arch_prctl, sys_arch_prctl), // 158
@@ -1034,7 +1034,7 @@ static SyscallTableEntry syscall_table[]
LINX_(__NR_pselect6, sys_pselect6), // 270
LINXY(__NR_ppoll, sys_ppoll), // 271
-// LINX_(__NR_unshare, sys_unshare), // 272
+ LINX_(__NR_unshare, sys_unshare), // 272
LINX_(__NR_set_robust_list, sys_set_robust_list), // 273
LINXY(__NR_get_robust_list, sys_get_robust_list), // 274
diff -upr
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-arm-linux.c
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-arm-linux.c
---
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-arm-linux.c
2013-10-23 03:50:12.000000000 -0700
+++
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-arm-linux.c
2014-08-26 17:02:37.744412744 -0700
@@ -1036,7 +1036,7 @@ static SyscallTableEntry syscall_main_ta
LINX_(__NR_setfsuid32, sys_setfsuid), // 215
LINX_(__NR_setfsgid32, sys_setfsgid), // 216
-//zz // (__NR_pivot_root, sys_pivot_root), // 217 */Linux
+ LINX_(__NR_pivot_root, sys_pivot_root), // 217
GENXY(__NR_mincore, sys_mincore), // 218
GENX_(__NR_madvise, sys_madvise), // 219
@@ -1175,7 +1175,7 @@ static SyscallTableEntry syscall_main_ta
LINXY(__NR_shmctl, sys_shmctl), // 308
// LINX_(__NR_pselect6, sys_pselect6), //
-// LINX_(__NR_unshare, sys_unshare), // 310
+ LINX_(__NR_unshare, sys_unshare), // 310
LINX_(__NR_set_robust_list, sys_set_robust_list), // 311
LINXY(__NR_get_robust_list, sys_get_robust_list), // 312
// LINX_(__NR_splice, sys_ni_syscall), // 313
diff -upr
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-linux.c
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-linux.c
---
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-linux.c
2013-10-23 03:50:12.000000000 -0700
+++
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-linux.c
2014-08-26 16:47:32.680450806 -0700
@@ -540,6 +540,18 @@ PRE(sys_umount)
PRE_MEM_RASCIIZ( "umount2(path)", ARG1);
}
+/* Not actually wrapped by GLibc but does things with the system
+ * mounts so it is put here.
+ */
+PRE(sys_pivot_root)
+{
+ PRINT("sys_pivot_root ( %s %s )", (HChar*)ARG1, (HChar*)ARG2);
+ PRE_REG_READ2(int, "pivot_root", char *, new_root, char *, old_root);
+ PRE_MEM_RASCIIZ( "pivot_root(new_root)", ARG1);
+ PRE_MEM_RASCIIZ( "pivot_root(old_root)", ARG2);
+}
+
+
/* ---------------------------------------------------------------------
16- and 32-bit uid/gid wrappers
------------------------------------------------------------------ */
@@ -2690,6 +2702,12 @@ POST(sys_sched_getaffinity)
POST_MEM_WRITE(ARG3, ARG2);
}
+PRE(sys_unshare)
+{
+ PRINT("sys_unshare ( %ld )", ARG1);
+ PRE_REG_READ1(int, "unshare", int, flags);
+}
+
/* ---------------------------------------------------------------------
miscellaneous wrappers
------------------------------------------------------------------ */
diff -upr
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-mips64-linux.c
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-mips64-linux.c
---
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-mips64-linux.c
2013-10-23 03:50:12.000000000 -0700
+++
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-mips64-linux.c
2014-08-26 17:04:27.692408120 -0700
@@ -796,7 +796,7 @@ static SyscallTableEntry syscall_main_ta
GENX_ (__NR_mlockall, sys_mlockall),
LINX_ (__NR_munlockall, sys_munlockall),
LINX_ (__NR_vhangup, sys_vhangup),
- /* GENX_(__NR_pivot_root,sys_pivot_root), */
+ LINX_ (__NR_pivot_root,sys_pivot_root),
LINXY (__NR__sysctl, sys_sysctl),
LINXY (__NR_prctl, sys_prctl),
LINXY (__NR_adjtimex, sys_adjtimex),
diff -upr
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-ppc32-linux.c
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-ppc32-linux.c
---
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-ppc32-linux.c
2013-10-23 03:50:12.000000000 -0700
+++
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-ppc32-linux.c
2014-08-26 17:04:03.100409154 -0700
@@ -1124,7 +1124,7 @@ static SyscallTableEntry syscall_table[]
// __NR_multiplexer // 201
GENXY(__NR_getdents64, sys_getdents64), // 202
-//.. // (__NR_pivot_root, sys_pivot_root), // 203 */Linux
+ LINX_(__NR_pivot_root, sys_pivot_root), // 203
LINXY(__NR_fcntl64, sys_fcntl64), // 204
GENX_(__NR_madvise, sys_madvise), // 205
GENXY(__NR_mincore, sys_mincore), // 206
diff -upr
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-ppc64-linux.c
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-ppc64-linux.c
---
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-ppc64-linux.c
2013-10-23 03:50:12.000000000 -0700
+++
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-ppc64-linux.c
2014-08-26 17:03:47.188409823 -0700
@@ -920,7 +920,7 @@ static SyscallTableEntry syscall_table[]
// _____(__NR_pciconfig_iobase, sys_pciconfig_iobase), // 200
// _____(__NR_multiplexer, sys_multiplexer), // 201
GENXY(__NR_getdents64, sys_getdents64), // 202
-// _____(__NR_pivot_root, sys_pivot_root), // 203
+ LINX_(__NR_pivot_root, sys_pivot_root), // 203
LINXY(__NR_fcntl64, sys_fcntl64), // 204 !!!!?? 32bit
only */
GENX_(__NR_madvise, sys_madvise), // 205
diff -upr
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-x86-linux.c
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-x86-linux.c
---
/home/sstewartgallus/root/home/others/src/valgrind-3.9.0/coregrind/m_syswrap/syswrap-x86-linux.c
2013-10-23 03:50:12.000000000 -0700
+++
/home/sstewartgallus/root/usr/build/valgrind-3.9.0/coregrind/m_syswrap/syswrap-x86-linux.c
2014-08-26 17:02:55.616411992 -0700
@@ -1676,7 +1676,7 @@ static SyscallTableEntry syscall_table[]
LINX_(__NR_setfsuid32, sys_setfsuid), // 215
LINX_(__NR_setfsgid32, sys_setfsgid), // 216
-//zz // (__NR_pivot_root, sys_pivot_root), // 217 */Linux
+ LINX_(__NR_pivot_root, sys_pivot_root), // 217
GENXY(__NR_mincore, sys_mincore), // 218
GENX_(__NR_madvise, sys_madvise), // 219
@@ -1788,7 +1788,7 @@ static SyscallTableEntry syscall_table[]
LINX_(__NR_pselect6, sys_pselect6), // 308
LINXY(__NR_ppoll, sys_ppoll), // 309
-// LINX_(__NR_unshare, sys_unshare), // 310
+ LINX_(__NR_unshare, sys_unshare), // 310
LINX_(__NR_set_robust_list, sys_set_robust_list), // 311
LINXY(__NR_get_robust_list, sys_get_robust_list), // 312
LINX_(__NR_splice, sys_splice), // 313
|