1 diff -NurpP --minimal linux-3.10.15/Documentation/vserver/debug.txt linux-3.10.15-vs2.3.6.6/Documentation/vserver/debug.txt
2 --- linux-3.10.15/Documentation/vserver/debug.txt 1970-01-01 00:00:00.000000000 +0000
3 +++ linux-3.10.15-vs2.3.6.6/Documentation/vserver/debug.txt 2013-08-22 20:29:59.000000000 +0000
8 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
9 + "vx_rmap_tgid: %p/%llx: %d -> %d"
13 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
14 + "FREE (%p,#%d)%c inode"
15 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
16 + "FREE (%p,#%d)%c %lld bytes"
17 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
18 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
19 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
20 + "rcu_free_dl_info(%p)"
21 + 4 10 "alloc_dl_info(%p,%d) = %p"
22 + "dealloc_dl_info(%p)"
23 + "get_dl_info(%p[#%d.%d])"
24 + "put_dl_info(%p[#%d.%d])"
25 + 5 20 "alloc_dl_info(%p,%d)*"
26 + 6 40 "__hash_dl_info: %p[#%d]"
27 + "__unhash_dl_info: %p[#%d]"
28 + 7 80 "locate_dl_info(%p,#%d) = %p"
32 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
33 + "new_dqhash: %p [#0x%08x]"
34 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
35 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
36 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
37 + "vroot_get_real_bdev not set"
38 + 1 2 "cow_break_link(»%s«)"
40 + 2 4 "dentry_open(new): %p"
41 + "dentry_open(old): %p"
42 + "lookup_create(new): %p"
44 + "path_lookup(old): %d"
45 + "vfs_create(new): %d"
48 + 3 8 "fput(new_file=%p[#%d])"
49 + "fput(old_file=%p[#%d])"
50 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
51 + "vx_info_kill(%p[#%d],%d,%d)*"
52 + 5 20 "vs_reboot(%p[#%d],%d)"
53 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
57 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
58 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
59 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
60 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
61 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
62 + 6 40 "sk,egf: %p [#%d] (from %d)"
63 + "sk,egn: %p [#%d] (from %d)"
64 + "sk,req: %p [#%d] (from %d)"
65 + "sk: %p [#%d] (from %d)"
66 + "tw: %p [#%d] (from %d)"
67 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
68 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
72 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
73 + "alloc_nx_info(%d) = %p"
74 + "create_nx_info(%d) (dynamic rejected)"
75 + "create_nx_info(%d) = %p (already there)"
76 + "create_nx_info(%d) = %p (new)"
77 + "dealloc_nx_info(%p)"
78 + 1 2 "alloc_nx_info(%d)*"
79 + "create_nx_info(%d)*"
80 + 2 4 "get_nx_info(%p[#%d.%d])"
81 + "put_nx_info(%p[#%d.%d])"
82 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
83 + "clr_nx_info(%p[#%d.%d])"
84 + "init_nx_info(%p[#%d.%d])"
85 + "release_nx_info(%p[#%d.%d.%d]) %p"
86 + "set_nx_info(%p[#%d.%d])"
87 + 4 10 "__hash_nx_info: %p[#%d]"
88 + "__nx_dynamic_id: [#%d]"
89 + "__unhash_nx_info: %p[#%d.%d.%d]"
90 + 5 20 "moved task %p into nxi:%p[#%d]"
91 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
92 + "task_get_nx_info(%p)"
93 + 6 40 "nx_clear_persistent(%p[#%d])"
97 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
98 + 1 2 "quota_sync_dqh(%p,%d)"
99 + "sync_dquots(%p,%d)"
100 + "sync_dquots_dqh(%p,%d)"
101 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
105 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
106 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
107 + 4 10 "%s: (%s %s) returned %s with %d"
111 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
112 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
116 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
117 + "alloc_vx_info(%d) = %p"
118 + "alloc_vx_info(%d)*"
119 + "create_vx_info(%d) (dynamic rejected)"
120 + "create_vx_info(%d) = %p (already there)"
121 + "create_vx_info(%d) = %p (new)"
122 + "dealloc_vx_info(%p)"
123 + "loc_vx_info(%d) = %p (found)"
124 + "loc_vx_info(%d) = %p (new)"
125 + "loc_vx_info(%d) = %p (not available)"
126 + 1 2 "create_vx_info(%d)*"
128 + 2 4 "get_vx_info(%p[#%d.%d])"
129 + "put_vx_info(%p[#%d.%d])"
130 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
131 + "clr_vx_info(%p[#%d.%d])"
132 + "init_vx_info(%p[#%d.%d])"
133 + "release_vx_info(%p[#%d.%d.%d]) %p"
134 + "set_vx_info(%p[#%d.%d])"
135 + 4 10 "__hash_vx_info: %p[#%d]"
136 + "__unhash_vx_info: %p[#%d.%d.%d]"
137 + "__vx_dynamic_id: [#%d]"
138 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
139 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
140 + "moved task %p into vxi:%p[#%d]"
141 + "task_get_vx_info(%p)"
142 + "vx_migrate_task(%p,%p[#%d.%d])"
143 + 6 40 "vx_clear_persistent(%p[#%d])"
144 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
145 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
146 + "vx_set_persistent(%p[#%d])"
147 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
148 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
153 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
154 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
156 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
157 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
158 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
159 diff -NurpP --minimal linux-3.10.15/arch/alpha/Kconfig linux-3.10.15-vs2.3.6.6/arch/alpha/Kconfig
160 --- linux-3.10.15/arch/alpha/Kconfig 2013-07-14 17:00:13.000000000 +0000
161 +++ linux-3.10.15-vs2.3.6.6/arch/alpha/Kconfig 2013-08-22 20:29:59.000000000 +0000
162 @@ -665,6 +665,8 @@ config DUMMY_CONSOLE
166 +source "kernel/vserver/Kconfig"
168 source "security/Kconfig"
170 source "crypto/Kconfig"
171 diff -NurpP --minimal linux-3.10.15/arch/alpha/kernel/systbls.S linux-3.10.15-vs2.3.6.6/arch/alpha/kernel/systbls.S
172 --- linux-3.10.15/arch/alpha/kernel/systbls.S 2013-02-19 13:56:11.000000000 +0000
173 +++ linux-3.10.15-vs2.3.6.6/arch/alpha/kernel/systbls.S 2013-08-22 20:29:59.000000000 +0000
174 @@ -446,7 +446,7 @@ sys_call_table:
175 .quad sys_stat64 /* 425 */
178 - .quad sys_ni_syscall /* sys_vserver */
179 + .quad sys_vserver /* sys_vserver */
180 .quad sys_ni_syscall /* sys_mbind */
181 .quad sys_ni_syscall /* sys_get_mempolicy */
182 .quad sys_ni_syscall /* sys_set_mempolicy */
183 diff -NurpP --minimal linux-3.10.15/arch/alpha/kernel/traps.c linux-3.10.15-vs2.3.6.6/arch/alpha/kernel/traps.c
184 --- linux-3.10.15/arch/alpha/kernel/traps.c 2013-07-14 17:00:13.000000000 +0000
185 +++ linux-3.10.15-vs2.3.6.6/arch/alpha/kernel/traps.c 2013-08-22 20:29:59.000000000 +0000
186 @@ -177,7 +177,8 @@ die_if_kernel(char * str, struct pt_regs
188 printk("CPU %d ", hard_smp_processor_id());
190 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
191 + printk("%s(%d:#%u): %s %ld\n", current->comm,
192 + task_pid_nr(current), current->xid, str, err);
193 dik_show_regs(regs, r9_15);
194 add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
195 dik_show_trace((unsigned long *)(regs+1));
196 diff -NurpP --minimal linux-3.10.15/arch/arm/Kconfig linux-3.10.15-vs2.3.6.6/arch/arm/Kconfig
197 --- linux-3.10.15/arch/arm/Kconfig 2013-10-09 17:35:15.000000000 +0000
198 +++ linux-3.10.15-vs2.3.6.6/arch/arm/Kconfig 2013-08-22 20:29:59.000000000 +0000
199 @@ -2238,6 +2238,8 @@ source "fs/Kconfig"
201 source "arch/arm/Kconfig.debug"
203 +source "kernel/vserver/Kconfig"
205 source "security/Kconfig"
207 source "crypto/Kconfig"
208 diff -NurpP --minimal linux-3.10.15/arch/arm/kernel/calls.S linux-3.10.15-vs2.3.6.6/arch/arm/kernel/calls.S
209 --- linux-3.10.15/arch/arm/kernel/calls.S 2013-05-31 13:44:29.000000000 +0000
210 +++ linux-3.10.15-vs2.3.6.6/arch/arm/kernel/calls.S 2013-08-22 20:29:59.000000000 +0000
212 /* 310 */ CALL(sys_request_key)
214 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
215 -/* vserver */ CALL(sys_ni_syscall)
218 /* 315 */ CALL(sys_ioprio_get)
219 CALL(sys_inotify_init)
220 diff -NurpP --minimal linux-3.10.15/arch/arm/kernel/traps.c linux-3.10.15-vs2.3.6.6/arch/arm/kernel/traps.c
221 --- linux-3.10.15/arch/arm/kernel/traps.c 2013-10-09 17:35:15.000000000 +0000
222 +++ linux-3.10.15-vs2.3.6.6/arch/arm/kernel/traps.c 2013-08-22 20:29:59.000000000 +0000
223 @@ -240,8 +240,8 @@ static int __die(const char *str, int er
227 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
228 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), end_of_stack(tsk));
229 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
230 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, end_of_stack(tsk));
232 if (!user_mode(regs) || in_interrupt()) {
233 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
234 diff -NurpP --minimal linux-3.10.15/arch/cris/Kconfig linux-3.10.15-vs2.3.6.6/arch/cris/Kconfig
235 --- linux-3.10.15/arch/cris/Kconfig 2013-07-14 17:00:25.000000000 +0000
236 +++ linux-3.10.15-vs2.3.6.6/arch/cris/Kconfig 2013-08-22 20:29:59.000000000 +0000
237 @@ -673,6 +673,8 @@ source "drivers/staging/Kconfig"
239 source "arch/cris/Kconfig.debug"
241 +source "kernel/vserver/Kconfig"
243 source "security/Kconfig"
245 source "crypto/Kconfig"
246 diff -NurpP --minimal linux-3.10.15/arch/h8300/Kconfig linux-3.10.15-vs2.3.6.6/arch/h8300/Kconfig
247 --- linux-3.10.15/arch/h8300/Kconfig 2013-07-14 17:00:25.000000000 +0000
248 +++ linux-3.10.15-vs2.3.6.6/arch/h8300/Kconfig 2013-08-22 20:29:59.000000000 +0000
249 @@ -218,6 +218,8 @@ source "fs/Kconfig"
251 source "arch/h8300/Kconfig.debug"
253 +source "kernel/vserver/Kconfig"
255 source "security/Kconfig"
257 source "crypto/Kconfig"
258 diff -NurpP --minimal linux-3.10.15/arch/ia64/Kconfig linux-3.10.15-vs2.3.6.6/arch/ia64/Kconfig
259 --- linux-3.10.15/arch/ia64/Kconfig 2013-07-14 17:00:25.000000000 +0000
260 +++ linux-3.10.15-vs2.3.6.6/arch/ia64/Kconfig 2013-08-22 20:29:59.000000000 +0000
261 @@ -643,6 +643,8 @@ source "fs/Kconfig"
263 source "arch/ia64/Kconfig.debug"
265 +source "kernel/vserver/Kconfig"
267 source "security/Kconfig"
269 source "crypto/Kconfig"
270 diff -NurpP --minimal linux-3.10.15/arch/ia64/kernel/entry.S linux-3.10.15-vs2.3.6.6/arch/ia64/kernel/entry.S
271 --- linux-3.10.15/arch/ia64/kernel/entry.S 2013-05-31 13:44:38.000000000 +0000
272 +++ linux-3.10.15-vs2.3.6.6/arch/ia64/kernel/entry.S 2013-08-22 20:29:59.000000000 +0000
273 @@ -1719,7 +1719,7 @@ sys_call_table:
275 data8 sys_mq_getsetattr
277 - data8 sys_ni_syscall // reserved for vserver
279 data8 sys_waitid // 1270
281 data8 sys_request_key
282 diff -NurpP --minimal linux-3.10.15/arch/ia64/kernel/ptrace.c linux-3.10.15-vs2.3.6.6/arch/ia64/kernel/ptrace.c
283 --- linux-3.10.15/arch/ia64/kernel/ptrace.c 2013-02-19 13:56:51.000000000 +0000
284 +++ linux-3.10.15-vs2.3.6.6/arch/ia64/kernel/ptrace.c 2013-08-22 20:29:59.000000000 +0000
286 #include <linux/regset.h>
287 #include <linux/elf.h>
288 #include <linux/tracehook.h>
289 +#include <linux/vs_base.h>
291 #include <asm/pgtable.h>
292 #include <asm/processor.h>
293 diff -NurpP --minimal linux-3.10.15/arch/ia64/kernel/traps.c linux-3.10.15-vs2.3.6.6/arch/ia64/kernel/traps.c
294 --- linux-3.10.15/arch/ia64/kernel/traps.c 2013-05-31 13:44:38.000000000 +0000
295 +++ linux-3.10.15-vs2.3.6.6/arch/ia64/kernel/traps.c 2013-08-22 20:29:59.000000000 +0000
296 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
299 if (++die.lock_owner_depth < 3) {
300 - printk("%s[%d]: %s %ld [%d]\n",
301 - current->comm, task_pid_nr(current), str, err, ++die_counter);
302 + printk("%s[%d:#%u]: %s %ld [%d]\n",
303 + current->comm, task_pid_nr(current), current->xid,
304 + str, err, ++die_counter);
305 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
308 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
309 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
310 last.time = current_jiffies + 5 * HZ;
312 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
313 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
314 + "%s(%d:#%u): floating-point assist fault at ip %016lx, isr %016lx\n",
315 + current->comm, task_pid_nr(current), current->xid,
316 + regs->cr_iip + ia64_psr(regs)->ri, isr);
320 diff -NurpP --minimal linux-3.10.15/arch/m32r/kernel/traps.c linux-3.10.15-vs2.3.6.6/arch/m32r/kernel/traps.c
321 --- linux-3.10.15/arch/m32r/kernel/traps.c 2013-07-14 17:00:26.000000000 +0000
322 +++ linux-3.10.15-vs2.3.6.6/arch/m32r/kernel/traps.c 2013-08-22 20:29:59.000000000 +0000
323 @@ -184,8 +184,9 @@ static void show_registers(struct pt_reg
325 printk("SPI: %08lx\n", sp);
327 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
328 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
329 + printk("Process %s (pid: %d:#%u, process nr: %d, stackpage=%08lx)",
330 + current->comm, task_pid_nr(current), current->xid,
331 + 0xffff & i, 4096+(unsigned long)current);
334 * When in-kernel, we also print out the stack and code at the
335 diff -NurpP --minimal linux-3.10.15/arch/m68k/Kconfig linux-3.10.15-vs2.3.6.6/arch/m68k/Kconfig
336 --- linux-3.10.15/arch/m68k/Kconfig 2013-07-14 17:00:26.000000000 +0000
337 +++ linux-3.10.15-vs2.3.6.6/arch/m68k/Kconfig 2013-08-22 20:29:59.000000000 +0000
338 @@ -134,6 +134,8 @@ source "fs/Kconfig"
340 source "arch/m68k/Kconfig.debug"
342 +source "kernel/vserver/Kconfig"
344 source "security/Kconfig"
346 source "crypto/Kconfig"
347 diff -NurpP --minimal linux-3.10.15/arch/mips/Kconfig linux-3.10.15-vs2.3.6.6/arch/mips/Kconfig
348 --- linux-3.10.15/arch/mips/Kconfig 2013-10-09 17:35:16.000000000 +0000
349 +++ linux-3.10.15-vs2.3.6.6/arch/mips/Kconfig 2013-08-22 20:29:59.000000000 +0000
350 @@ -2583,6 +2583,8 @@ source "fs/Kconfig"
352 source "arch/mips/Kconfig.debug"
354 +source "kernel/vserver/Kconfig"
356 source "security/Kconfig"
358 source "crypto/Kconfig"
359 diff -NurpP --minimal linux-3.10.15/arch/mips/kernel/ptrace.c linux-3.10.15-vs2.3.6.6/arch/mips/kernel/ptrace.c
360 --- linux-3.10.15/arch/mips/kernel/ptrace.c 2013-05-31 13:44:42.000000000 +0000
361 +++ linux-3.10.15-vs2.3.6.6/arch/mips/kernel/ptrace.c 2013-08-22 20:29:59.000000000 +0000
363 #include <linux/security.h>
364 #include <linux/audit.h>
365 #include <linux/seccomp.h>
366 +#include <linux/vs_base.h>
368 #include <asm/byteorder.h>
370 @@ -262,6 +263,9 @@ long arch_ptrace(struct task_struct *chi
371 void __user *datavp = (void __user *) data;
372 unsigned long __user *datalp = (void __user *) data;
374 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
378 /* when I and D space are separate, these will need to be fixed. */
379 case PTRACE_PEEKTEXT: /* read word at location addr. */
380 diff -NurpP --minimal linux-3.10.15/arch/mips/kernel/scall32-o32.S linux-3.10.15-vs2.3.6.6/arch/mips/kernel/scall32-o32.S
381 --- linux-3.10.15/arch/mips/kernel/scall32-o32.S 2013-07-14 17:00:28.000000000 +0000
382 +++ linux-3.10.15-vs2.3.6.6/arch/mips/kernel/scall32-o32.S 2013-08-22 20:29:59.000000000 +0000
383 @@ -521,7 +521,7 @@ einval: li v0, -ENOSYS
384 sys sys_mq_timedreceive 5
385 sys sys_mq_notify 2 /* 4275 */
386 sys sys_mq_getsetattr 3
387 - sys sys_ni_syscall 0 /* sys_vserver */
390 sys sys_ni_syscall 0 /* available, was setaltroot */
391 sys sys_add_key 5 /* 4280 */
392 diff -NurpP --minimal linux-3.10.15/arch/mips/kernel/scall64-64.S linux-3.10.15-vs2.3.6.6/arch/mips/kernel/scall64-64.S
393 --- linux-3.10.15/arch/mips/kernel/scall64-64.S 2013-07-14 17:00:28.000000000 +0000
394 +++ linux-3.10.15-vs2.3.6.6/arch/mips/kernel/scall64-64.S 2013-08-22 20:29:59.000000000 +0000
395 @@ -351,7 +351,7 @@ sys_call_table:
396 PTR sys_mq_timedreceive
398 PTR sys_mq_getsetattr /* 5235 */
399 - PTR sys_ni_syscall /* sys_vserver */
402 PTR sys_ni_syscall /* available, was setaltroot */
404 diff -NurpP --minimal linux-3.10.15/arch/mips/kernel/scall64-n32.S linux-3.10.15-vs2.3.6.6/arch/mips/kernel/scall64-n32.S
405 --- linux-3.10.15/arch/mips/kernel/scall64-n32.S 2013-07-14 17:00:28.000000000 +0000
406 +++ linux-3.10.15-vs2.3.6.6/arch/mips/kernel/scall64-n32.S 2013-08-22 20:29:59.000000000 +0000
407 @@ -344,7 +344,7 @@ EXPORT(sysn32_call_table)
408 PTR compat_sys_mq_timedreceive
409 PTR compat_sys_mq_notify
410 PTR compat_sys_mq_getsetattr
411 - PTR sys_ni_syscall /* 6240, sys_vserver */
412 + PTR sys32_vserver /* 6240 */
413 PTR compat_sys_waitid
414 PTR sys_ni_syscall /* available, was setaltroot */
416 diff -NurpP --minimal linux-3.10.15/arch/mips/kernel/scall64-o32.S linux-3.10.15-vs2.3.6.6/arch/mips/kernel/scall64-o32.S
417 --- linux-3.10.15/arch/mips/kernel/scall64-o32.S 2013-07-14 17:00:28.000000000 +0000
418 +++ linux-3.10.15-vs2.3.6.6/arch/mips/kernel/scall64-o32.S 2013-08-22 20:29:59.000000000 +0000
419 @@ -469,7 +469,7 @@ sys_call_table:
420 PTR compat_sys_mq_timedreceive
421 PTR compat_sys_mq_notify /* 4275 */
422 PTR compat_sys_mq_getsetattr
423 - PTR sys_ni_syscall /* sys_vserver */
425 PTR compat_sys_waitid
426 PTR sys_ni_syscall /* available, was setaltroot */
427 PTR sys_add_key /* 4280 */
428 diff -NurpP --minimal linux-3.10.15/arch/mips/kernel/traps.c linux-3.10.15-vs2.3.6.6/arch/mips/kernel/traps.c
429 --- linux-3.10.15/arch/mips/kernel/traps.c 2013-07-14 17:00:28.000000000 +0000
430 +++ linux-3.10.15-vs2.3.6.6/arch/mips/kernel/traps.c 2013-08-22 20:29:59.000000000 +0000
431 @@ -331,9 +331,10 @@ void show_registers(struct pt_regs *regs
435 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
436 - current->comm, current->pid, current_thread_info(), current,
437 - field, current_thread_info()->tp_value);
438 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
439 + current->comm, task_pid_nr(current), current->xid,
440 + current_thread_info(), current,
441 + field, current_thread_info()->tp_value);
442 if (cpu_has_userlocal) {
445 diff -NurpP --minimal linux-3.10.15/arch/parisc/Kconfig linux-3.10.15-vs2.3.6.6/arch/parisc/Kconfig
446 --- linux-3.10.15/arch/parisc/Kconfig 2013-07-14 17:00:29.000000000 +0000
447 +++ linux-3.10.15-vs2.3.6.6/arch/parisc/Kconfig 2013-08-22 20:29:59.000000000 +0000
448 @@ -318,6 +318,8 @@ source "fs/Kconfig"
450 source "arch/parisc/Kconfig.debug"
452 +source "kernel/vserver/Kconfig"
454 source "security/Kconfig"
456 source "crypto/Kconfig"
457 diff -NurpP --minimal linux-3.10.15/arch/parisc/kernel/syscall_table.S linux-3.10.15-vs2.3.6.6/arch/parisc/kernel/syscall_table.S
458 --- linux-3.10.15/arch/parisc/kernel/syscall_table.S 2013-07-14 17:00:31.000000000 +0000
459 +++ linux-3.10.15-vs2.3.6.6/arch/parisc/kernel/syscall_table.S 2013-08-22 20:29:59.000000000 +0000
461 ENTRY_COMP(mbind) /* 260 */
462 ENTRY_COMP(get_mempolicy)
463 ENTRY_COMP(set_mempolicy)
464 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
465 + ENTRY_DIFF(vserver)
467 ENTRY_SAME(request_key) /* 265 */
469 diff -NurpP --minimal linux-3.10.15/arch/parisc/kernel/traps.c linux-3.10.15-vs2.3.6.6/arch/parisc/kernel/traps.c
470 --- linux-3.10.15/arch/parisc/kernel/traps.c 2013-07-14 17:00:31.000000000 +0000
471 +++ linux-3.10.15-vs2.3.6.6/arch/parisc/kernel/traps.c 2013-08-22 20:29:59.000000000 +0000
472 @@ -229,8 +229,9 @@ void die_if_kernel(char *str, struct pt_
476 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
477 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
478 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
479 + current->comm, task_pid_nr(current), current->xid,
480 + str, err, regs->iaoq[0]);
481 #ifdef PRINT_USER_FAULTS
482 /* XXX for debugging only */
484 @@ -263,8 +264,8 @@ void die_if_kernel(char *str, struct pt_
485 pdc_console_restart();
488 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
489 - current->comm, task_pid_nr(current), str, err);
490 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
491 + current->comm, task_pid_nr(current), current->xid, str, err);
493 /* Wot's wrong wif bein' racy? */
494 if (current->thread.flags & PARISC_KERNEL_DEATH) {
495 diff -NurpP --minimal linux-3.10.15/arch/parisc/mm/fault.c linux-3.10.15-vs2.3.6.6/arch/parisc/mm/fault.c
496 --- linux-3.10.15/arch/parisc/mm/fault.c 2013-05-31 13:44:44.000000000 +0000
497 +++ linux-3.10.15-vs2.3.6.6/arch/parisc/mm/fault.c 2013-08-22 20:29:59.000000000 +0000
498 @@ -257,8 +257,9 @@ bad_area:
500 #ifdef PRINT_USER_FAULTS
501 printk(KERN_DEBUG "\n");
502 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
503 - task_pid_nr(tsk), tsk->comm, code, address);
504 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
505 + "command='%s' type=%lu address=0x%08lx\n",
506 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
508 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
509 vma->vm_start, vma->vm_end);
510 diff -NurpP --minimal linux-3.10.15/arch/powerpc/Kconfig linux-3.10.15-vs2.3.6.6/arch/powerpc/Kconfig
511 --- linux-3.10.15/arch/powerpc/Kconfig 2013-10-09 17:35:16.000000000 +0000
512 +++ linux-3.10.15-vs2.3.6.6/arch/powerpc/Kconfig 2013-10-09 17:37:21.000000000 +0000
513 @@ -1010,6 +1010,8 @@ source "lib/Kconfig"
515 source "arch/powerpc/Kconfig.debug"
517 +source "kernel/vserver/Kconfig"
519 source "security/Kconfig"
522 diff -NurpP --minimal linux-3.10.15/arch/powerpc/include/uapi/asm/unistd.h linux-3.10.15-vs2.3.6.6/arch/powerpc/include/uapi/asm/unistd.h
523 --- linux-3.10.15/arch/powerpc/include/uapi/asm/unistd.h 2013-05-31 13:44:44.000000000 +0000
524 +++ linux-3.10.15-vs2.3.6.6/arch/powerpc/include/uapi/asm/unistd.h 2013-08-22 20:29:59.000000000 +0000
527 #define __NR_rtas 255
528 #define __NR_sys_debug_setcontext 256
529 -/* Number 257 is reserved for vserver */
530 +#define __NR_vserver 257
531 #define __NR_migrate_pages 258
532 #define __NR_mbind 259
533 #define __NR_get_mempolicy 260
534 diff -NurpP --minimal linux-3.10.15/arch/powerpc/kernel/traps.c linux-3.10.15-vs2.3.6.6/arch/powerpc/kernel/traps.c
535 --- linux-3.10.15/arch/powerpc/kernel/traps.c 2013-10-09 17:35:16.000000000 +0000
536 +++ linux-3.10.15-vs2.3.6.6/arch/powerpc/kernel/traps.c 2013-08-22 20:29:59.000000000 +0000
537 @@ -1231,8 +1231,9 @@ void nonrecoverable_exception(struct pt_
539 void trace_syscall(struct pt_regs *regs)
541 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
542 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
543 + printk("Task: %p(%d:#%u), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
544 + current, task_pid_nr(current), current->xid,
545 + regs->nip, regs->link, regs->gpr[0],
546 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
549 diff -NurpP --minimal linux-3.10.15/arch/s390/Kconfig linux-3.10.15-vs2.3.6.6/arch/s390/Kconfig
550 --- linux-3.10.15/arch/s390/Kconfig 2013-10-09 17:35:16.000000000 +0000
551 +++ linux-3.10.15-vs2.3.6.6/arch/s390/Kconfig 2013-08-22 20:29:59.000000000 +0000
552 @@ -579,6 +579,8 @@ source "fs/Kconfig"
554 source "arch/s390/Kconfig.debug"
556 +source "kernel/vserver/Kconfig"
558 source "security/Kconfig"
560 source "crypto/Kconfig"
561 diff -NurpP --minimal linux-3.10.15/arch/s390/include/asm/tlb.h linux-3.10.15-vs2.3.6.6/arch/s390/include/asm/tlb.h
562 --- linux-3.10.15/arch/s390/include/asm/tlb.h 2013-10-09 17:35:16.000000000 +0000
563 +++ linux-3.10.15-vs2.3.6.6/arch/s390/include/asm/tlb.h 2013-08-22 20:29:59.000000000 +0000
565 #include <linux/mm.h>
566 #include <linux/pagemap.h>
567 #include <linux/swap.h>
569 #include <asm/processor.h>
570 #include <asm/pgalloc.h>
571 #include <asm/tlbflush.h>
572 diff -NurpP --minimal linux-3.10.15/arch/s390/include/uapi/asm/unistd.h linux-3.10.15-vs2.3.6.6/arch/s390/include/uapi/asm/unistd.h
573 --- linux-3.10.15/arch/s390/include/uapi/asm/unistd.h 2013-02-19 13:57:16.000000000 +0000
574 +++ linux-3.10.15-vs2.3.6.6/arch/s390/include/uapi/asm/unistd.h 2013-08-22 20:29:59.000000000 +0000
576 #define __NR_clock_gettime (__NR_timer_create+6)
577 #define __NR_clock_getres (__NR_timer_create+7)
578 #define __NR_clock_nanosleep (__NR_timer_create+8)
579 -/* Number 263 is reserved for vserver */
580 +#define __NR_vserver 263
581 #define __NR_statfs64 265
582 #define __NR_fstatfs64 266
583 #define __NR_remap_file_pages 267
584 diff -NurpP --minimal linux-3.10.15/arch/s390/kernel/ptrace.c linux-3.10.15-vs2.3.6.6/arch/s390/kernel/ptrace.c
585 --- linux-3.10.15/arch/s390/kernel/ptrace.c 2012-12-11 03:30:57.000000000 +0000
586 +++ linux-3.10.15-vs2.3.6.6/arch/s390/kernel/ptrace.c 2013-08-22 20:29:59.000000000 +0000
588 #include <linux/tracehook.h>
589 #include <linux/seccomp.h>
590 #include <linux/compat.h>
591 +#include <linux/vs_base.h>
592 #include <trace/syscall.h>
593 #include <asm/segment.h>
594 #include <asm/page.h>
595 diff -NurpP --minimal linux-3.10.15/arch/s390/kernel/syscalls.S linux-3.10.15-vs2.3.6.6/arch/s390/kernel/syscalls.S
596 --- linux-3.10.15/arch/s390/kernel/syscalls.S 2013-07-14 17:00:34.000000000 +0000
597 +++ linux-3.10.15-vs2.3.6.6/arch/s390/kernel/syscalls.S 2013-08-22 20:29:59.000000000 +0000
598 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
599 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
600 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
601 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
602 -NI_SYSCALL /* reserved for vserver */
603 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
604 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
605 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
606 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
607 diff -NurpP --minimal linux-3.10.15/arch/sh/Kconfig linux-3.10.15-vs2.3.6.6/arch/sh/Kconfig
608 --- linux-3.10.15/arch/sh/Kconfig 2013-07-14 17:00:35.000000000 +0000
609 +++ linux-3.10.15-vs2.3.6.6/arch/sh/Kconfig 2013-08-22 20:29:59.000000000 +0000
610 @@ -928,6 +928,8 @@ source "fs/Kconfig"
612 source "arch/sh/Kconfig.debug"
614 +source "kernel/vserver/Kconfig"
616 source "security/Kconfig"
618 source "crypto/Kconfig"
619 diff -NurpP --minimal linux-3.10.15/arch/sh/kernel/irq.c linux-3.10.15-vs2.3.6.6/arch/sh/kernel/irq.c
620 --- linux-3.10.15/arch/sh/kernel/irq.c 2012-12-11 03:30:57.000000000 +0000
621 +++ linux-3.10.15-vs2.3.6.6/arch/sh/kernel/irq.c 2013-08-22 20:29:59.000000000 +0000
623 #include <linux/ftrace.h>
624 #include <linux/delay.h>
625 #include <linux/ratelimit.h>
626 +// #include <linux/vs_context.h>
627 #include <asm/processor.h>
628 #include <asm/machvec.h>
629 #include <asm/uaccess.h>
630 diff -NurpP --minimal linux-3.10.15/arch/sparc/Kconfig linux-3.10.15-vs2.3.6.6/arch/sparc/Kconfig
631 --- linux-3.10.15/arch/sparc/Kconfig 2013-07-14 17:00:35.000000000 +0000
632 +++ linux-3.10.15-vs2.3.6.6/arch/sparc/Kconfig 2013-08-22 20:29:59.000000000 +0000
633 @@ -550,6 +550,8 @@ source "fs/Kconfig"
635 source "arch/sparc/Kconfig.debug"
637 +source "kernel/vserver/Kconfig"
639 source "security/Kconfig"
641 source "crypto/Kconfig"
642 diff -NurpP --minimal linux-3.10.15/arch/sparc/include/uapi/asm/unistd.h linux-3.10.15-vs2.3.6.6/arch/sparc/include/uapi/asm/unistd.h
643 --- linux-3.10.15/arch/sparc/include/uapi/asm/unistd.h 2013-02-19 13:57:17.000000000 +0000
644 +++ linux-3.10.15-vs2.3.6.6/arch/sparc/include/uapi/asm/unistd.h 2013-08-22 20:29:59.000000000 +0000
646 #define __NR_timer_getoverrun 264
647 #define __NR_timer_delete 265
648 #define __NR_timer_create 266
649 -/* #define __NR_vserver 267 Reserved for VSERVER */
650 +#define __NR_vserver 267
651 #define __NR_io_setup 268
652 #define __NR_io_destroy 269
653 #define __NR_io_submit 270
654 diff -NurpP --minimal linux-3.10.15/arch/sparc/kernel/systbls_32.S linux-3.10.15-vs2.3.6.6/arch/sparc/kernel/systbls_32.S
655 --- linux-3.10.15/arch/sparc/kernel/systbls_32.S 2013-05-31 13:44:48.000000000 +0000
656 +++ linux-3.10.15-vs2.3.6.6/arch/sparc/kernel/systbls_32.S 2013-08-22 20:29:59.000000000 +0000
657 @@ -70,7 +70,7 @@ sys_call_table:
658 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_ni_syscall
659 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
660 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
661 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
662 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
663 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
664 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
665 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
666 diff -NurpP --minimal linux-3.10.15/arch/sparc/kernel/systbls_64.S linux-3.10.15-vs2.3.6.6/arch/sparc/kernel/systbls_64.S
667 --- linux-3.10.15/arch/sparc/kernel/systbls_64.S 2013-07-14 17:00:35.000000000 +0000
668 +++ linux-3.10.15-vs2.3.6.6/arch/sparc/kernel/systbls_64.S 2013-08-22 20:29:59.000000000 +0000
669 @@ -71,7 +71,7 @@ sys_call_table32:
670 /*250*/ .word sys_mremap, compat_sys_sysctl, sys_getsid, sys_fdatasync, sys_nis_syscall
671 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
672 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
673 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
674 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
675 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
676 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
677 /*280*/ .word sys_tee, sys_add_key, sys_request_key, compat_sys_keyctl, compat_sys_openat
678 @@ -149,7 +149,7 @@ sys_call_table:
679 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nis_syscall
680 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
681 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
682 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
683 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
684 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
685 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
686 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
687 diff -NurpP --minimal linux-3.10.15/arch/um/Kconfig.rest linux-3.10.15-vs2.3.6.6/arch/um/Kconfig.rest
688 --- linux-3.10.15/arch/um/Kconfig.rest 2012-12-11 03:30:57.000000000 +0000
689 +++ linux-3.10.15-vs2.3.6.6/arch/um/Kconfig.rest 2013-08-22 20:29:59.000000000 +0000
690 @@ -12,6 +12,8 @@ source "arch/um/Kconfig.net"
694 +source "kernel/vserver/Kconfig"
696 source "security/Kconfig"
698 source "crypto/Kconfig"
699 diff -NurpP --minimal linux-3.10.15/arch/x86/Kconfig linux-3.10.15-vs2.3.6.6/arch/x86/Kconfig
700 --- linux-3.10.15/arch/x86/Kconfig 2013-07-14 17:00:36.000000000 +0000
701 +++ linux-3.10.15-vs2.3.6.6/arch/x86/Kconfig 2013-08-22 20:29:59.000000000 +0000
702 @@ -2339,6 +2339,8 @@ source "fs/Kconfig"
704 source "arch/x86/Kconfig.debug"
706 +source "kernel/vserver/Kconfig"
708 source "security/Kconfig"
710 source "crypto/Kconfig"
711 diff -NurpP --minimal linux-3.10.15/arch/x86/syscalls/syscall_32.tbl linux-3.10.15-vs2.3.6.6/arch/x86/syscalls/syscall_32.tbl
712 --- linux-3.10.15/arch/x86/syscalls/syscall_32.tbl 2013-07-14 17:00:37.000000000 +0000
713 +++ linux-3.10.15-vs2.3.6.6/arch/x86/syscalls/syscall_32.tbl 2013-08-22 20:29:59.000000000 +0000
715 270 i386 tgkill sys_tgkill
716 271 i386 utimes sys_utimes compat_sys_utimes
717 272 i386 fadvise64_64 sys_fadvise64_64 sys32_fadvise64_64
719 +273 i386 vserver sys_vserver sys32_vserver
720 274 i386 mbind sys_mbind
721 275 i386 get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy
722 276 i386 set_mempolicy sys_set_mempolicy
723 diff -NurpP --minimal linux-3.10.15/arch/x86/syscalls/syscall_64.tbl linux-3.10.15-vs2.3.6.6/arch/x86/syscalls/syscall_64.tbl
724 --- linux-3.10.15/arch/x86/syscalls/syscall_64.tbl 2013-05-31 13:44:50.000000000 +0000
725 +++ linux-3.10.15-vs2.3.6.6/arch/x86/syscalls/syscall_64.tbl 2013-08-22 20:29:59.000000000 +0000
727 233 common epoll_ctl sys_epoll_ctl
728 234 common tgkill sys_tgkill
729 235 common utimes sys_utimes
731 +236 64 vserver sys_vserver
732 237 common mbind sys_mbind
733 238 common set_mempolicy sys_set_mempolicy
734 239 common get_mempolicy sys_get_mempolicy
735 diff -NurpP --minimal linux-3.10.15/drivers/block/Kconfig linux-3.10.15-vs2.3.6.6/drivers/block/Kconfig
736 --- linux-3.10.15/drivers/block/Kconfig 2013-05-31 13:44:51.000000000 +0000
737 +++ linux-3.10.15-vs2.3.6.6/drivers/block/Kconfig 2013-08-22 20:29:59.000000000 +0000
738 @@ -278,6 +278,13 @@ config BLK_DEV_CRYPTOLOOP
740 source "drivers/block/drbd/Kconfig"
742 +config BLK_DEV_VROOT
743 + tristate "Virtual Root device support"
744 + depends on QUOTACTL
746 + Saying Y here will allow you to use quota/fs ioctls on a shared
747 + partition within a virtual server without compromising security.
750 tristate "Network block device support"
752 diff -NurpP --minimal linux-3.10.15/drivers/block/Makefile linux-3.10.15-vs2.3.6.6/drivers/block/Makefile
753 --- linux-3.10.15/drivers/block/Makefile 2013-07-14 17:00:41.000000000 +0000
754 +++ linux-3.10.15-vs2.3.6.6/drivers/block/Makefile 2013-08-22 20:29:59.000000000 +0000
755 @@ -33,6 +33,7 @@ obj-$(CONFIG_VIRTIO_BLK) += virtio_blk.o
756 obj-$(CONFIG_VIODASD) += viodasd.o
757 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
758 obj-$(CONFIG_BLK_DEV_HD) += hd.o
759 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
761 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
762 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
763 diff -NurpP --minimal linux-3.10.15/drivers/block/loop.c linux-3.10.15-vs2.3.6.6/drivers/block/loop.c
764 --- linux-3.10.15/drivers/block/loop.c 2013-07-14 17:00:41.000000000 +0000
765 +++ linux-3.10.15-vs2.3.6.6/drivers/block/loop.c 2013-08-22 20:29:59.000000000 +0000
767 #include <linux/sysfs.h>
768 #include <linux/miscdevice.h>
769 #include <linux/falloc.h>
770 +#include <linux/vs_context.h>
772 #include <asm/uaccess.h>
774 @@ -884,6 +885,7 @@ static int loop_set_fd(struct loop_devic
775 lo->lo_blocksize = lo_blocksize;
776 lo->lo_device = bdev;
777 lo->lo_flags = lo_flags;
778 + lo->lo_xid = vx_current_xid();
779 lo->lo_backing_file = file;
780 lo->transfer = transfer_none;
782 @@ -1035,6 +1037,7 @@ static int loop_clr_fd(struct loop_devic
783 lo->lo_sizelimit = 0;
784 lo->lo_encrypt_key_size = 0;
785 lo->lo_thread = NULL;
787 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
788 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
789 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
790 @@ -1078,7 +1081,7 @@ loop_set_status(struct loop_device *lo,
792 if (lo->lo_encrypt_key_size &&
793 !uid_eq(lo->lo_key_owner, uid) &&
794 - !capable(CAP_SYS_ADMIN))
795 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
797 if (lo->lo_state != Lo_bound)
799 @@ -1168,7 +1171,8 @@ loop_get_status(struct loop_device *lo,
800 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
801 info->lo_encrypt_type =
802 lo->lo_encryption ? lo->lo_encryption->number : 0;
803 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
804 + if (lo->lo_encrypt_key_size &&
805 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
806 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
807 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
808 lo->lo_encrypt_key_size);
809 @@ -1510,6 +1514,11 @@ static int lo_open(struct block_device *
813 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P)) {
818 mutex_lock(&lo->lo_ctl_mutex);
820 mutex_unlock(&lo->lo_ctl_mutex);
821 diff -NurpP --minimal linux-3.10.15/drivers/block/vroot.c linux-3.10.15-vs2.3.6.6/drivers/block/vroot.c
822 --- linux-3.10.15/drivers/block/vroot.c 1970-01-01 00:00:00.000000000 +0000
823 +++ linux-3.10.15-vs2.3.6.6/drivers/block/vroot.c 2013-08-23 00:23:45.000000000 +0000
826 + * linux/drivers/block/vroot.c
828 + * written by Herbert Pötzl, 9/11/2002
829 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
831 + * based on the loop.c code by Theodore Ts'o.
833 + * Copyright (C) 2002-2007 by Herbert Pötzl.
834 + * Redistribution of this file is permitted under the
835 + * GNU General Public License.
839 +#include <linux/module.h>
840 +#include <linux/moduleparam.h>
841 +#include <linux/file.h>
842 +#include <linux/major.h>
843 +#include <linux/blkdev.h>
844 +#include <linux/slab.h>
846 +#include <linux/vroot.h>
847 +#include <linux/vs_context.h>
850 +static int max_vroot = 8;
852 +static struct vroot_device *vroot_dev;
853 +static struct gendisk **disks;
856 +static int vroot_set_dev(
857 + struct vroot_device *vr,
858 + struct block_device *bdev,
861 + struct block_device *real_bdev;
863 + struct inode *inode;
867 + if (vr->vr_state != Vr_unbound)
876 + inode = file->f_dentry->d_inode;
879 + if (S_ISBLK(inode->i_mode)) {
880 + real_bdev = inode->i_bdev;
881 + vr->vr_device = real_bdev;
882 + __iget(real_bdev->bd_inode);
886 + vxdprintk(VXD_CBIT(misc, 0),
887 + "vroot[%d]_set_dev: dev=" VXF_DEV,
888 + vr->vr_number, VXD_DEV(real_bdev));
890 + vr->vr_state = Vr_bound;
899 +static int vroot_clr_dev(
900 + struct vroot_device *vr,
901 + struct block_device *bdev)
903 + struct block_device *real_bdev;
905 + if (vr->vr_state != Vr_bound)
907 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
910 + real_bdev = vr->vr_device;
912 + vxdprintk(VXD_CBIT(misc, 0),
913 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
914 + vr->vr_number, VXD_DEV(real_bdev));
917 + vr->vr_state = Vr_unbound;
918 + vr->vr_device = NULL;
923 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
924 + unsigned int cmd, unsigned long arg)
926 + struct vroot_device *vr = bdev->bd_disk->private_data;
929 + down(&vr->vr_ctl_mutex);
931 + case VROOT_SET_DEV:
932 + err = vroot_set_dev(vr, bdev, arg);
934 + case VROOT_CLR_DEV:
935 + err = vroot_clr_dev(vr, bdev);
941 + up(&vr->vr_ctl_mutex);
945 +static int vr_open(struct block_device *bdev, fmode_t mode)
947 + struct vroot_device *vr = bdev->bd_disk->private_data;
949 + down(&vr->vr_ctl_mutex);
951 + up(&vr->vr_ctl_mutex);
955 +static void vr_release(struct gendisk *disk, fmode_t mode)
957 + struct vroot_device *vr = disk->private_data;
959 + down(&vr->vr_ctl_mutex);
961 + up(&vr->vr_ctl_mutex);
964 +static struct block_device_operations vr_fops = {
965 + .owner = THIS_MODULE,
967 + .release = vr_release,
971 +static void vroot_make_request(struct request_queue *q, struct bio *bio)
973 + printk("vroot_make_request %p, %p\n", q, bio);
977 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
979 + struct inode *inode = bdev->bd_inode;
980 + struct vroot_device *vr;
981 + struct block_device *real_bdev;
982 + int minor = iminor(inode);
984 + vr = &vroot_dev[minor];
985 + real_bdev = vr->vr_device;
987 + vxdprintk(VXD_CBIT(misc, 0),
988 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
989 + vr->vr_number, VXD_DEV(real_bdev));
991 + if (vr->vr_state != Vr_bound)
992 + return ERR_PTR(-ENXIO);
994 + __iget(real_bdev->bd_inode);
1001 + * And now the modules code and kernel interface.
1004 +module_param(max_vroot, int, 0);
1006 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1007 +MODULE_LICENSE("GPL");
1008 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1010 +MODULE_AUTHOR ("Herbert Pötzl");
1011 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1014 +int __init vroot_init(void)
1018 + if (max_vroot < 1 || max_vroot > 256) {
1019 + max_vroot = MAX_VROOT_DEFAULT;
1020 + printk(KERN_WARNING "vroot: invalid max_vroot "
1021 + "(must be between 1 and 256), "
1022 + "using default (%d)\n", max_vroot);
1025 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1029 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1032 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1034 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1038 + for (i = 0; i < max_vroot; i++) {
1039 + disks[i] = alloc_disk(1);
1042 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1043 + if (!disks[i]->queue)
1045 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1048 + for (i = 0; i < max_vroot; i++) {
1049 + struct vroot_device *vr = &vroot_dev[i];
1050 + struct gendisk *disk = disks[i];
1052 + memset(vr, 0, sizeof(*vr));
1053 + sema_init(&vr->vr_ctl_mutex, 1);
1054 + vr->vr_number = i;
1055 + disk->major = VROOT_MAJOR;
1056 + disk->first_minor = i;
1057 + disk->fops = &vr_fops;
1058 + sprintf(disk->disk_name, "vroot%d", i);
1059 + disk->private_data = vr;
1062 + err = register_vroot_grb(&__vroot_get_real_bdev);
1066 + for (i = 0; i < max_vroot; i++)
1067 + add_disk(disks[i]);
1068 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1073 + put_disk(disks[i]);
1078 + unregister_blkdev(VROOT_MAJOR, "vroot");
1079 + printk(KERN_ERR "vroot: ran out of memory\n");
1083 +void vroot_exit(void)
1087 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1088 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1090 + for (i = 0; i < max_vroot; i++) {
1091 + del_gendisk(disks[i]);
1092 + put_disk(disks[i]);
1094 + unregister_blkdev(VROOT_MAJOR, "vroot");
1100 +module_init(vroot_init);
1101 +module_exit(vroot_exit);
1105 +static int __init max_vroot_setup(char *str)
1107 + max_vroot = simple_strtol(str, NULL, 0);
1111 +__setup("max_vroot=", max_vroot_setup);
1115 diff -NurpP --minimal linux-3.10.15/drivers/infiniband/Kconfig linux-3.10.15-vs2.3.6.6/drivers/infiniband/Kconfig
1116 --- linux-3.10.15/drivers/infiniband/Kconfig 2013-07-14 17:00:49.000000000 +0000
1117 +++ linux-3.10.15-vs2.3.6.6/drivers/infiniband/Kconfig 2013-08-22 20:29:59.000000000 +0000
1118 @@ -39,7 +39,7 @@ config INFINIBAND_USER_MEM
1119 config INFINIBAND_ADDR_TRANS
1122 - depends on !(INFINIBAND = y && IPV6 = m)
1123 + depends on !(INFINIBAND = y && IPV6 = y)
1126 source "drivers/infiniband/hw/mthca/Kconfig"
1127 diff -NurpP --minimal linux-3.10.15/drivers/infiniband/core/addr.c linux-3.10.15-vs2.3.6.6/drivers/infiniband/core/addr.c
1128 --- linux-3.10.15/drivers/infiniband/core/addr.c 2012-12-11 03:30:57.000000000 +0000
1129 +++ linux-3.10.15-vs2.3.6.6/drivers/infiniband/core/addr.c 2013-08-22 20:29:59.000000000 +0000
1130 @@ -261,7 +261,7 @@ static int addr6_resolve(struct sockaddr
1132 if (ipv6_addr_any(&fl6.saddr)) {
1133 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1134 - &fl6.daddr, 0, &fl6.saddr);
1135 + &fl6.daddr, 0, &fl6.saddr, NULL);
1139 diff -NurpP --minimal linux-3.10.15/drivers/md/dm-ioctl.c linux-3.10.15-vs2.3.6.6/drivers/md/dm-ioctl.c
1140 --- linux-3.10.15/drivers/md/dm-ioctl.c 2013-10-09 17:35:19.000000000 +0000
1141 +++ linux-3.10.15-vs2.3.6.6/drivers/md/dm-ioctl.c 2013-08-22 20:29:59.000000000 +0000
1143 #include <linux/dm-ioctl.h>
1144 #include <linux/hdreg.h>
1145 #include <linux/compat.h>
1146 +#include <linux/vs_context.h>
1148 #include <asm/uaccess.h>
1150 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1151 unsigned int h = hash_str(str);
1153 list_for_each_entry (hc, _name_buckets + h, name_list)
1154 - if (!strcmp(hc->name, str)) {
1155 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1156 + !strcmp(hc->name, str)) {
1160 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1161 unsigned int h = hash_str(str);
1163 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1164 - if (!strcmp(hc->uuid, str)) {
1165 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1166 + !strcmp(hc->uuid, str)) {
1170 @@ -131,13 +134,15 @@ static struct hash_cell *__get_uuid_cell
1171 static struct hash_cell *__get_dev_cell(uint64_t dev)
1173 struct mapped_device *md;
1174 - struct hash_cell *hc;
1175 + struct hash_cell *hc = NULL;
1177 md = dm_get_md(huge_decode_dev(dev));
1181 - hc = dm_get_mdptr(md);
1182 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1183 + hc = dm_get_mdptr(md);
1188 @@ -445,6 +450,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1190 static int remove_all(struct dm_ioctl *param, size_t param_size)
1192 + if (!vx_check(0, VS_ADMIN))
1195 dm_hash_remove_all(1);
1196 param->data_size = 0;
1198 @@ -492,6 +500,8 @@ static int list_devices(struct dm_ioctl
1200 for (i = 0; i < NUM_BUCKETS; i++) {
1201 list_for_each_entry (hc, _name_buckets + i, name_list) {
1202 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1204 needed += sizeof(struct dm_name_list);
1205 needed += strlen(hc->name) + 1;
1206 needed += ALIGN_MASK;
1207 @@ -515,6 +525,8 @@ static int list_devices(struct dm_ioctl
1209 for (i = 0; i < NUM_BUCKETS; i++) {
1210 list_for_each_entry (hc, _name_buckets + i, name_list) {
1211 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1214 old_nl->next = (uint32_t) ((void *) nl -
1216 @@ -1725,8 +1737,8 @@ static int ctl_ioctl(uint command, struc
1217 size_t input_param_size;
1218 struct dm_ioctl param_kernel;
1220 - /* only root can play with this */
1221 - if (!capable(CAP_SYS_ADMIN))
1222 + /* only root and certain contexts can play with this */
1223 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1226 if (_IOC_TYPE(command) != DM_IOCTL)
1227 diff -NurpP --minimal linux-3.10.15/drivers/md/dm.c linux-3.10.15-vs2.3.6.6/drivers/md/dm.c
1228 --- linux-3.10.15/drivers/md/dm.c 2013-10-09 17:35:19.000000000 +0000
1229 +++ linux-3.10.15-vs2.3.6.6/drivers/md/dm.c 2013-10-09 17:37:21.000000000 +0000
1231 #include <linux/idr.h>
1232 #include <linux/hdreg.h>
1233 #include <linux/delay.h>
1234 +#include <linux/vs_base.h>
1236 #include <trace/events/block.h>
1238 @@ -125,6 +126,7 @@ struct mapped_device {
1241 atomic_t open_count;
1244 unsigned long flags;
1246 @@ -317,6 +319,7 @@ int dm_deleting_md(struct mapped_device
1247 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1249 struct mapped_device *md;
1252 spin_lock(&_minor_lock);
1254 @@ -325,18 +328,19 @@ static int dm_blk_open(struct block_devi
1257 if (test_bit(DMF_FREEING, &md->flags) ||
1258 - dm_deleting_md(md)) {
1260 + dm_deleting_md(md))
1264 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1269 atomic_inc(&md->open_count);
1273 spin_unlock(&_minor_lock);
1275 - return md ? 0 : -ENXIO;
1279 static void dm_blk_close(struct gendisk *disk, fmode_t mode)
1280 @@ -552,6 +556,14 @@ int dm_set_geometry(struct mapped_device
1285 + * Get the xid associated with a dm device
1287 +vxid_t dm_get_xid(struct mapped_device *md)
1292 /*-----------------------------------------------------------------
1294 * A more elegant soln is in the works that uses the queue
1295 @@ -1889,6 +1901,7 @@ static struct mapped_device *alloc_dev(i
1296 INIT_LIST_HEAD(&md->uevent_list);
1297 spin_lock_init(&md->uevent_lock);
1299 + md->xid = vx_current_xid();
1300 md->queue = blk_alloc_queue(GFP_KERNEL);
1303 diff -NurpP --minimal linux-3.10.15/drivers/md/dm.h linux-3.10.15-vs2.3.6.6/drivers/md/dm.h
1304 --- linux-3.10.15/drivers/md/dm.h 2013-02-19 13:57:51.000000000 +0000
1305 +++ linux-3.10.15-vs2.3.6.6/drivers/md/dm.h 2013-08-22 20:29:59.000000000 +0000
1306 @@ -46,6 +46,8 @@ struct dm_dev_internal {
1308 struct dm_md_mempools;
1310 +vxid_t dm_get_xid(struct mapped_device *md);
1312 /*-----------------------------------------------------------------
1313 * Internal table functions.
1314 *---------------------------------------------------------------*/
1315 diff -NurpP --minimal linux-3.10.15/drivers/net/tun.c linux-3.10.15-vs2.3.6.6/drivers/net/tun.c
1316 --- linux-3.10.15/drivers/net/tun.c 2013-10-09 17:35:20.000000000 +0000
1317 +++ linux-3.10.15-vs2.3.6.6/drivers/net/tun.c 2013-10-09 17:37:21.000000000 +0000
1319 #include <linux/nsproxy.h>
1320 #include <linux/virtio_net.h>
1321 #include <linux/rcupdate.h>
1322 +#include <linux/vs_network.h>
1323 #include <net/net_namespace.h>
1324 #include <net/netns/generic.h>
1325 #include <net/rtnetlink.h>
1326 @@ -164,6 +165,7 @@ struct tun_struct {
1332 struct net_device *dev;
1333 netdev_features_t set_features;
1334 @@ -380,6 +382,7 @@ static inline bool tun_not_capable(struc
1335 return ((uid_valid(tun->owner) && !uid_eq(cred->euid, tun->owner)) ||
1336 (gid_valid(tun->group) && !in_egroup_p(tun->group))) &&
1337 !ns_capable(net->user_ns, CAP_NET_ADMIN);
1338 + /* !cap_raised(current_cap(), CAP_NET_ADMIN) */
1341 static void tun_set_real_num_queues(struct tun_struct *tun)
1342 @@ -1425,6 +1428,7 @@ static void tun_setup(struct net_device
1344 tun->owner = INVALID_UID;
1345 tun->group = INVALID_GID;
1346 + tun->nid = nx_current_nid();
1348 dev->ethtool_ops = &tun_ethtool_ops;
1349 dev->destructor = tun_free_netdev;
1350 @@ -1616,6 +1620,9 @@ static int tun_set_iff(struct net *net,
1354 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1357 err = tun_attach(tun, file);
1360 @@ -1634,7 +1641,7 @@ static int tun_set_iff(struct net *net,
1361 int queues = ifr->ifr_flags & IFF_MULTI_QUEUE ?
1364 - if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
1365 + if (!vx_ns_capable(net->user_ns, CAP_NET_ADMIN, NXC_TUN_CREATE))
1367 err = security_tun_dev_create();
1369 @@ -1980,6 +1987,16 @@ static long __tun_chr_ioctl(struct file
1370 from_kgid(&init_user_ns, tun->group));
1374 + if (!capable(CAP_CONTEXT))
1377 + /* Set nid owner of the device */
1378 + tun->nid = (vnid_t) arg;
1380 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1384 /* Only allow setting the type when the interface is down */
1385 if (tun->dev->flags & IFF_UP) {
1386 diff -NurpP --minimal linux-3.10.15/drivers/tty/sysrq.c linux-3.10.15-vs2.3.6.6/drivers/tty/sysrq.c
1387 --- linux-3.10.15/drivers/tty/sysrq.c 2013-07-14 17:01:22.000000000 +0000
1388 +++ linux-3.10.15-vs2.3.6.6/drivers/tty/sysrq.c 2013-08-22 20:58:35.000000000 +0000
1390 #include <linux/uaccess.h>
1391 #include <linux/moduleparam.h>
1392 #include <linux/jiffies.h>
1393 +#include <linux/vserver/debug.h>
1395 #include <asm/ptrace.h>
1396 #include <asm/irq_regs.h>
1397 @@ -405,6 +406,21 @@ static struct sysrq_key_op sysrq_unrt_op
1398 .enable_mask = SYSRQ_ENABLE_RTNICE,
1402 +#ifdef CONFIG_VSERVER_DEBUG
1403 +static void sysrq_handle_vxinfo(int key)
1405 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1408 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1409 + .handler = sysrq_handle_vxinfo,
1410 + .help_msg = "conteXt",
1411 + .action_msg = "Show Context Info",
1412 + .enable_mask = SYSRQ_ENABLE_DUMP,
1416 /* Key Operations table and lock */
1417 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1419 @@ -460,7 +476,11 @@ static struct sysrq_key_op *sysrq_key_ta
1420 &sysrq_showstate_blocked_op, /* w */
1421 /* x: May be registered on ppc/powerpc for xmon */
1422 /* x: May be registered on sparc64 for global PMU dump */
1423 +#ifdef CONFIG_VSERVER_DEBUG
1424 + &sysrq_showvxinfo_op, /* x */
1428 /* y: May be registered on sparc64 for global register dump */
1430 &sysrq_ftrace_dump_op, /* z */
1431 @@ -475,6 +495,8 @@ static int sysrq_key_table_key2index(int
1433 else if ((key >= 'a') && (key <= 'z'))
1434 retval = key + 10 - 'a';
1435 + else if ((key >= 'A') && (key <= 'Z'))
1436 + retval = key + 10 - 'A';
1440 diff -NurpP --minimal linux-3.10.15/drivers/tty/tty_io.c linux-3.10.15-vs2.3.6.6/drivers/tty/tty_io.c
1441 --- linux-3.10.15/drivers/tty/tty_io.c 2013-10-09 17:35:21.000000000 +0000
1442 +++ linux-3.10.15-vs2.3.6.6/drivers/tty/tty_io.c 2013-10-09 17:37:22.000000000 +0000
1445 #include <linux/kmod.h>
1446 #include <linux/nsproxy.h>
1447 +#include <linux/vs_pid.h>
1449 #undef TTY_DEBUG_HANGUP
1451 @@ -2213,7 +2214,8 @@ static int tiocsti(struct tty_struct *tt
1453 struct tty_ldisc *ld;
1455 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1456 + if (((current->signal->tty != tty) &&
1457 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1459 if (get_user(ch, p))
1461 @@ -2501,6 +2503,7 @@ static int tiocspgrp(struct tty_struct *
1463 if (get_user(pgrp_nr, p))
1465 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1469 diff -NurpP --minimal linux-3.10.15/fs/attr.c linux-3.10.15-vs2.3.6.6/fs/attr.c
1470 --- linux-3.10.15/fs/attr.c 2013-02-19 13:58:46.000000000 +0000
1471 +++ linux-3.10.15-vs2.3.6.6/fs/attr.c 2013-08-22 20:29:59.000000000 +0000
1473 #include <linux/security.h>
1474 #include <linux/evm.h>
1475 #include <linux/ima.h>
1476 +#include <linux/proc_fs.h>
1477 +#include <linux/devpts_fs.h>
1478 +#include <linux/vs_tag.h>
1481 * inode_change_ok - check if attribute changes to an inode are allowed
1482 @@ -77,6 +80,10 @@ int inode_change_ok(const struct inode *
1486 + /* check for inode tag permission */
1487 + if (dx_permission(inode, MAY_WRITE))
1492 EXPORT_SYMBOL(inode_change_ok);
1493 @@ -147,6 +154,8 @@ void setattr_copy(struct inode *inode, c
1494 inode->i_uid = attr->ia_uid;
1495 if (ia_valid & ATTR_GID)
1496 inode->i_gid = attr->ia_gid;
1497 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1498 + inode->i_tag = attr->ia_tag;
1499 if (ia_valid & ATTR_ATIME)
1500 inode->i_atime = timespec_trunc(attr->ia_atime,
1501 inode->i_sb->s_time_gran);
1502 @@ -177,7 +186,8 @@ int notify_change(struct dentry * dentry
1504 WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
1506 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1507 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1508 + ATTR_TAG | ATTR_TIMES_SET)) {
1509 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1512 diff -NurpP --minimal linux-3.10.15/fs/block_dev.c linux-3.10.15-vs2.3.6.6/fs/block_dev.c
1513 --- linux-3.10.15/fs/block_dev.c 2013-10-09 17:35:22.000000000 +0000
1514 +++ linux-3.10.15-vs2.3.6.6/fs/block_dev.c 2013-08-22 21:20:35.000000000 +0000
1516 #include <linux/log2.h>
1517 #include <linux/cleancache.h>
1518 #include <linux/aio.h>
1519 +#include <linux/vs_device.h>
1520 #include <asm/uaccess.h>
1521 #include "internal.h"
1523 @@ -536,6 +537,7 @@ struct block_device *bdget(dev_t dev)
1524 bdev->bd_invalidated = 0;
1525 inode->i_mode = S_IFBLK;
1526 inode->i_rdev = dev;
1527 + inode->i_mdev = dev;
1528 inode->i_bdev = bdev;
1529 inode->i_data.a_ops = &def_blk_aops;
1530 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1531 @@ -583,6 +585,11 @@ EXPORT_SYMBOL(bdput);
1532 static struct block_device *bd_acquire(struct inode *inode)
1534 struct block_device *bdev;
1537 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1539 + inode->i_mdev = mdev;
1541 spin_lock(&bdev_lock);
1542 bdev = inode->i_bdev;
1543 @@ -593,7 +600,7 @@ static struct block_device *bd_acquire(s
1545 spin_unlock(&bdev_lock);
1547 - bdev = bdget(inode->i_rdev);
1548 + bdev = bdget(mdev);
1550 spin_lock(&bdev_lock);
1551 if (!inode->i_bdev) {
1552 diff -NurpP --minimal linux-3.10.15/fs/btrfs/ctree.h linux-3.10.15-vs2.3.6.6/fs/btrfs/ctree.h
1553 --- linux-3.10.15/fs/btrfs/ctree.h 2013-07-14 17:01:26.000000000 +0000
1554 +++ linux-3.10.15-vs2.3.6.6/fs/btrfs/ctree.h 2013-08-22 20:29:59.000000000 +0000
1555 @@ -707,11 +707,14 @@ struct btrfs_inode_item {
1556 /* modification sequence number for NFS */
1561 * a little future expansion, for more than this we can
1562 * just grow the inode item and version it
1564 - __le64 reserved[4];
1565 + __le16 reserved16;
1566 + __le32 reserved32;
1567 + __le64 reserved[3];
1568 struct btrfs_timespec atime;
1569 struct btrfs_timespec ctime;
1570 struct btrfs_timespec mtime;
1571 @@ -1928,6 +1931,8 @@ struct btrfs_ioctl_defrag_range_args {
1572 #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
1573 #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22)
1575 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1577 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1578 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1579 #define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt)
1580 @@ -2197,6 +2202,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1581 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1582 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1583 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1584 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1585 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1586 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1587 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1588 @@ -2250,6 +2256,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1590 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1592 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1593 +#define BTRFS_INODE_BARRIER (1 << 25)
1594 +#define BTRFS_INODE_COW (1 << 26)
1597 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1599 @@ -3578,6 +3588,7 @@ extern const struct dentry_operations bt
1600 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1601 void btrfs_update_iflags(struct inode *inode);
1602 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1603 +int btrfs_sync_flags(struct inode *inode, int, int);
1604 int btrfs_defrag_file(struct inode *inode, struct file *file,
1605 struct btrfs_ioctl_defrag_range_args *range,
1606 u64 newer_than, unsigned long max_pages);
1607 diff -NurpP --minimal linux-3.10.15/fs/btrfs/disk-io.c linux-3.10.15-vs2.3.6.6/fs/btrfs/disk-io.c
1608 --- linux-3.10.15/fs/btrfs/disk-io.c 2013-07-14 17:01:26.000000000 +0000
1609 +++ linux-3.10.15-vs2.3.6.6/fs/btrfs/disk-io.c 2013-08-22 20:29:59.000000000 +0000
1610 @@ -2360,6 +2360,9 @@ int open_ctree(struct super_block *sb,
1614 + if (btrfs_test_opt(tree_root, TAGGED))
1615 + sb->s_flags |= MS_TAGGED;
1617 features = btrfs_super_incompat_flags(disk_super) &
1618 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1620 diff -NurpP --minimal linux-3.10.15/fs/btrfs/inode.c linux-3.10.15-vs2.3.6.6/fs/btrfs/inode.c
1621 --- linux-3.10.15/fs/btrfs/inode.c 2013-07-14 17:01:26.000000000 +0000
1622 +++ linux-3.10.15-vs2.3.6.6/fs/btrfs/inode.c 2013-08-22 20:29:59.000000000 +0000
1624 #include <linux/mount.h>
1625 #include <linux/btrfs.h>
1626 #include <linux/blkdev.h>
1627 +#include <linux/vs_tag.h>
1630 #include "disk-io.h"
1631 @@ -3327,6 +3328,9 @@ static void btrfs_read_locked_inode(stru
1632 struct btrfs_key location;
1639 bool filled = false;
1641 @@ -3354,8 +3358,14 @@ static void btrfs_read_locked_inode(stru
1642 struct btrfs_inode_item);
1643 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1644 set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
1645 - i_uid_write(inode, btrfs_inode_uid(leaf, inode_item));
1646 - i_gid_write(inode, btrfs_inode_gid(leaf, inode_item));
1648 + kuid = make_kuid(&init_user_ns, btrfs_inode_uid(leaf, inode_item));
1649 + kgid = make_kgid(&init_user_ns, btrfs_inode_gid(leaf, inode_item));
1650 + ktag = make_ktag(&init_user_ns, btrfs_inode_tag(leaf, inode_item));
1652 + inode->i_uid = INOTAG_KUID(DX_TAG(inode), kuid, kgid);
1653 + inode->i_gid = INOTAG_KGID(DX_TAG(inode), kuid, kgid);
1654 + inode->i_tag = INOTAG_KTAG(DX_TAG(inode), kuid, kgid, ktag);
1655 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1657 tspec = btrfs_inode_atime(inode_item);
1658 @@ -3446,11 +3456,18 @@ static void fill_inode_item(struct btrfs
1659 struct inode *inode)
1661 struct btrfs_map_token token;
1662 + uid_t uid = from_kuid(&init_user_ns,
1663 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
1664 + gid_t gid = from_kgid(&init_user_ns,
1665 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
1667 btrfs_init_map_token(&token);
1669 - btrfs_set_token_inode_uid(leaf, item, i_uid_read(inode), &token);
1670 - btrfs_set_token_inode_gid(leaf, item, i_gid_read(inode), &token);
1671 + btrfs_set_token_inode_uid(leaf, item, uid, &token);
1672 + btrfs_set_token_inode_gid(leaf, item, gid, &token);
1673 +#ifdef CONFIG_TAGGING_INTERN
1674 + btrfs_set_token_inode_tag(leaf, item, i_tag_read(inode), &token);
1676 btrfs_set_token_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size,
1678 btrfs_set_token_inode_mode(leaf, item, inode->i_mode, &token);
1679 @@ -8720,11 +8737,13 @@ static const struct inode_operations btr
1680 .listxattr = btrfs_listxattr,
1681 .removexattr = btrfs_removexattr,
1682 .permission = btrfs_permission,
1683 + .sync_flags = btrfs_sync_flags,
1684 .get_acl = btrfs_get_acl,
1686 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1687 .lookup = btrfs_lookup,
1688 .permission = btrfs_permission,
1689 + .sync_flags = btrfs_sync_flags,
1690 .get_acl = btrfs_get_acl,
1693 diff -NurpP --minimal linux-3.10.15/fs/btrfs/ioctl.c linux-3.10.15-vs2.3.6.6/fs/btrfs/ioctl.c
1694 --- linux-3.10.15/fs/btrfs/ioctl.c 2013-10-09 17:35:22.000000000 +0000
1695 +++ linux-3.10.15-vs2.3.6.6/fs/btrfs/ioctl.c 2013-10-09 17:37:22.000000000 +0000
1696 @@ -75,10 +75,13 @@ static unsigned int btrfs_flags_to_ioctl
1698 unsigned int iflags = 0;
1700 - if (flags & BTRFS_INODE_SYNC)
1701 - iflags |= FS_SYNC_FL;
1702 if (flags & BTRFS_INODE_IMMUTABLE)
1703 iflags |= FS_IMMUTABLE_FL;
1704 + if (flags & BTRFS_INODE_IXUNLINK)
1705 + iflags |= FS_IXUNLINK_FL;
1707 + if (flags & BTRFS_INODE_SYNC)
1708 + iflags |= FS_SYNC_FL;
1709 if (flags & BTRFS_INODE_APPEND)
1710 iflags |= FS_APPEND_FL;
1711 if (flags & BTRFS_INODE_NODUMP)
1712 @@ -95,28 +98,78 @@ static unsigned int btrfs_flags_to_ioctl
1713 else if (flags & BTRFS_INODE_NOCOMPRESS)
1714 iflags |= FS_NOCOMP_FL;
1716 + if (flags & BTRFS_INODE_BARRIER)
1717 + iflags |= FS_BARRIER_FL;
1718 + if (flags & BTRFS_INODE_COW)
1719 + iflags |= FS_COW_FL;
1724 - * Update inode->i_flags based on the btrfs internal flags.
1725 + * Update inode->i_(v)flags based on the btrfs internal flags.
1727 void btrfs_update_iflags(struct inode *inode)
1729 struct btrfs_inode *ip = BTRFS_I(inode);
1731 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
1732 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
1733 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
1735 - if (ip->flags & BTRFS_INODE_SYNC)
1736 - inode->i_flags |= S_SYNC;
1737 if (ip->flags & BTRFS_INODE_IMMUTABLE)
1738 inode->i_flags |= S_IMMUTABLE;
1739 + if (ip->flags & BTRFS_INODE_IXUNLINK)
1740 + inode->i_flags |= S_IXUNLINK;
1742 + if (ip->flags & BTRFS_INODE_SYNC)
1743 + inode->i_flags |= S_SYNC;
1744 if (ip->flags & BTRFS_INODE_APPEND)
1745 inode->i_flags |= S_APPEND;
1746 if (ip->flags & BTRFS_INODE_NOATIME)
1747 inode->i_flags |= S_NOATIME;
1748 if (ip->flags & BTRFS_INODE_DIRSYNC)
1749 inode->i_flags |= S_DIRSYNC;
1751 + inode->i_vflags &= ~(V_BARRIER | V_COW);
1753 + if (ip->flags & BTRFS_INODE_BARRIER)
1754 + inode->i_vflags |= V_BARRIER;
1755 + if (ip->flags & BTRFS_INODE_COW)
1756 + inode->i_vflags |= V_COW;
1760 + * Update btrfs internal flags from inode->i_(v)flags.
1762 +void btrfs_update_flags(struct inode *inode)
1764 + struct btrfs_inode *ip = BTRFS_I(inode);
1766 + unsigned int flags = inode->i_flags;
1767 + unsigned int vflags = inode->i_vflags;
1769 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
1770 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
1771 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
1772 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
1774 + if (flags & S_IMMUTABLE)
1775 + ip->flags |= BTRFS_INODE_IMMUTABLE;
1776 + if (flags & S_IXUNLINK)
1777 + ip->flags |= BTRFS_INODE_IXUNLINK;
1779 + if (flags & S_SYNC)
1780 + ip->flags |= BTRFS_INODE_SYNC;
1781 + if (flags & S_APPEND)
1782 + ip->flags |= BTRFS_INODE_APPEND;
1783 + if (flags & S_NOATIME)
1784 + ip->flags |= BTRFS_INODE_NOATIME;
1785 + if (flags & S_DIRSYNC)
1786 + ip->flags |= BTRFS_INODE_DIRSYNC;
1788 + if (vflags & V_BARRIER)
1789 + ip->flags |= BTRFS_INODE_BARRIER;
1790 + if (vflags & V_COW)
1791 + ip->flags |= BTRFS_INODE_COW;
1795 @@ -132,6 +185,7 @@ void btrfs_inherit_iflags(struct inode *
1798 flags = BTRFS_I(dir)->flags;
1799 + flags &= ~BTRFS_INODE_BARRIER;
1801 if (flags & BTRFS_INODE_NOCOMPRESS) {
1802 BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
1803 @@ -150,6 +204,30 @@ void btrfs_inherit_iflags(struct inode *
1804 btrfs_update_iflags(inode);
1807 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
1809 + struct btrfs_inode *ip = BTRFS_I(inode);
1810 + struct btrfs_root *root = ip->root;
1811 + struct btrfs_trans_handle *trans;
1814 + trans = btrfs_join_transaction(root);
1817 + inode->i_flags = flags;
1818 + inode->i_vflags = vflags;
1819 + btrfs_update_flags(inode);
1821 + ret = btrfs_update_inode(trans, root, inode);
1824 + btrfs_update_iflags(inode);
1825 + inode->i_ctime = CURRENT_TIME;
1826 + btrfs_end_transaction(trans, root);
1831 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
1833 struct btrfs_inode *ip = BTRFS_I(file_inode(file));
1834 @@ -212,21 +290,27 @@ static int btrfs_ioctl_setflags(struct f
1836 flags = btrfs_mask_flags(inode->i_mode, flags);
1837 oldflags = btrfs_flags_to_ioctl(ip->flags);
1838 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
1839 + if ((flags ^ oldflags) & (FS_APPEND_FL |
1840 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
1841 if (!capable(CAP_LINUX_IMMUTABLE)) {
1847 - if (flags & FS_SYNC_FL)
1848 - ip->flags |= BTRFS_INODE_SYNC;
1850 - ip->flags &= ~BTRFS_INODE_SYNC;
1851 if (flags & FS_IMMUTABLE_FL)
1852 ip->flags |= BTRFS_INODE_IMMUTABLE;
1854 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
1855 + if (flags & FS_IXUNLINK_FL)
1856 + ip->flags |= BTRFS_INODE_IXUNLINK;
1858 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
1860 + if (flags & FS_SYNC_FL)
1861 + ip->flags |= BTRFS_INODE_SYNC;
1863 + ip->flags &= ~BTRFS_INODE_SYNC;
1864 if (flags & FS_APPEND_FL)
1865 ip->flags |= BTRFS_INODE_APPEND;
1867 diff -NurpP --minimal linux-3.10.15/fs/btrfs/super.c linux-3.10.15-vs2.3.6.6/fs/btrfs/super.c
1868 --- linux-3.10.15/fs/btrfs/super.c 2013-07-14 17:01:26.000000000 +0000
1869 +++ linux-3.10.15-vs2.3.6.6/fs/btrfs/super.c 2013-08-22 20:29:59.000000000 +0000
1870 @@ -319,7 +319,7 @@ enum {
1871 Opt_no_space_cache, Opt_recovery, Opt_skip_balance,
1872 Opt_check_integrity, Opt_check_integrity_including_extent_data,
1873 Opt_check_integrity_print_mask, Opt_fatal_errors,
1875 + Opt_tag, Opt_notag, Opt_tagid, Opt_err,
1878 static match_table_t tokens = {
1879 @@ -359,6 +359,9 @@ static match_table_t tokens = {
1880 {Opt_check_integrity_including_extent_data, "check_int_data"},
1881 {Opt_check_integrity_print_mask, "check_int_print_mask=%d"},
1882 {Opt_fatal_errors, "fatal_errors=%s"},
1884 + {Opt_notag, "notag"},
1885 + {Opt_tagid, "tagid=%u"},
1889 @@ -624,6 +627,22 @@ int btrfs_parse_options(struct btrfs_roo
1893 +#ifndef CONFIG_TAGGING_NONE
1895 + printk(KERN_INFO "btrfs: use tagging\n");
1896 + btrfs_set_opt(info->mount_opt, TAGGED);
1899 + printk(KERN_INFO "btrfs: disabled tagging\n");
1900 + btrfs_clear_opt(info->mount_opt, TAGGED);
1903 +#ifdef CONFIG_PROPAGATE
1906 + btrfs_set_opt(info->mount_opt, TAGGED);
1910 printk(KERN_INFO "btrfs: unrecognized mount option "
1912 @@ -1251,6 +1270,12 @@ static int btrfs_remount(struct super_bl
1913 btrfs_resize_thread_pool(fs_info,
1914 fs_info->thread_pool_size, old_thread_pool_size);
1916 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
1917 + printk("btrfs: %s: tagging not permitted on remount.\n",
1922 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
1925 diff -NurpP --minimal linux-3.10.15/fs/char_dev.c linux-3.10.15-vs2.3.6.6/fs/char_dev.c
1926 --- linux-3.10.15/fs/char_dev.c 2012-12-11 03:30:57.000000000 +0000
1927 +++ linux-3.10.15-vs2.3.6.6/fs/char_dev.c 2013-08-22 20:29:59.000000000 +0000
1929 #include <linux/mutex.h>
1930 #include <linux/backing-dev.h>
1931 #include <linux/tty.h>
1932 +#include <linux/vs_context.h>
1933 +#include <linux/vs_device.h>
1935 #include "internal.h"
1937 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
1939 struct cdev *new = NULL;
1943 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
1945 + inode->i_mdev = mdev;
1947 spin_lock(&cdev_lock);
1950 struct kobject *kobj;
1953 spin_unlock(&cdev_lock);
1954 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
1956 + kobj = kobj_lookup(cdev_map, mdev, &idx);
1959 new = container_of(kobj, struct cdev, kobj);
1960 diff -NurpP --minimal linux-3.10.15/fs/dcache.c linux-3.10.15-vs2.3.6.6/fs/dcache.c
1961 --- linux-3.10.15/fs/dcache.c 2013-07-14 17:01:27.000000000 +0000
1962 +++ linux-3.10.15-vs2.3.6.6/fs/dcache.c 2013-08-22 20:29:59.000000000 +0000
1964 #include <linux/rculist_bl.h>
1965 #include <linux/prefetch.h>
1966 #include <linux/ratelimit.h>
1967 +#include <linux/vs_limit.h>
1968 #include "internal.h"
1971 @@ -578,6 +579,8 @@ int d_invalidate(struct dentry * dentry)
1972 spin_lock(&dentry->d_lock);
1975 + vx_dentry_dec(dentry);
1978 * Somebody else still using it?
1980 @@ -607,6 +610,7 @@ EXPORT_SYMBOL(d_invalidate);
1981 static inline void __dget_dlock(struct dentry *dentry)
1984 + vx_dentry_inc(dentry);
1987 static inline void __dget(struct dentry *dentry)
1988 @@ -1239,6 +1243,9 @@ struct dentry *__d_alloc(struct super_bl
1989 struct dentry *dentry;
1992 + if (!vx_dentry_avail(1))
1995 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
1998 @@ -1271,6 +1278,7 @@ struct dentry *__d_alloc(struct super_bl
2000 dentry->d_count = 1;
2001 dentry->d_flags = 0;
2002 + vx_dentry_inc(dentry);
2003 spin_lock_init(&dentry->d_lock);
2004 seqcount_init(&dentry->d_seq);
2005 dentry->d_inode = NULL;
2006 @@ -1971,6 +1979,7 @@ struct dentry *__d_lookup(const struct d
2010 + vx_dentry_inc(dentry);
2012 spin_unlock(&dentry->d_lock);
2014 diff -NurpP --minimal linux-3.10.15/fs/devpts/inode.c linux-3.10.15-vs2.3.6.6/fs/devpts/inode.c
2015 --- linux-3.10.15/fs/devpts/inode.c 2013-05-31 13:45:23.000000000 +0000
2016 +++ linux-3.10.15-vs2.3.6.6/fs/devpts/inode.c 2013-08-22 20:29:59.000000000 +0000
2018 #include <linux/parser.h>
2019 #include <linux/fsnotify.h>
2020 #include <linux/seq_file.h>
2021 +#include <linux/vs_base.h>
2023 #define DEVPTS_DEFAULT_MODE 0600
2026 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2027 #define PTMX_MINOR 2
2029 +static int devpts_permission(struct inode *inode, int mask)
2031 + int ret = -EACCES;
2033 + /* devpts is xid tagged */
2034 + if (vx_check((vxid_t)i_tag_read(inode), VS_WATCH_P | VS_IDENT))
2035 + ret = generic_permission(inode, mask);
2039 +static struct inode_operations devpts_file_inode_operations = {
2040 + .permission = devpts_permission,
2045 * sysctl support for setting limits on the number of Unix98 ptys allocated.
2046 * Otherwise one can eat up all kernel memory by opening /dev/ptmx repeatedly.
2047 @@ -345,6 +361,34 @@ static int devpts_show_options(struct se
2051 +static int devpts_filter(struct dentry *de)
2055 + /* devpts is xid tagged */
2056 + if (de && de->d_inode)
2057 + xid = (vxid_t)i_tag_read(de->d_inode);
2058 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2060 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2061 + de->d_name.len, de->d_name.name);
2063 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2066 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2068 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2071 +static struct file_operations devpts_dir_operations = {
2072 + .open = dcache_dir_open,
2073 + .release = dcache_dir_close,
2074 + .llseek = dcache_dir_lseek,
2075 + .read = generic_read_dir,
2076 + .readdir = devpts_readdir,
2079 static const struct super_operations devpts_sops = {
2080 .statfs = simple_statfs,
2081 .remount_fs = devpts_remount,
2082 @@ -388,8 +432,10 @@ devpts_fill_super(struct super_block *s,
2083 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2084 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2085 inode->i_op = &simple_dir_inode_operations;
2086 - inode->i_fop = &simple_dir_operations;
2087 + inode->i_fop = &devpts_dir_operations;
2088 set_nlink(inode, 2);
2089 + /* devpts is xid tagged */
2090 + i_tag_write(inode, (vtag_t)vx_current_xid());
2092 s->s_root = d_make_root(inode);
2094 @@ -592,6 +638,9 @@ struct inode *devpts_pty_new(struct inod
2095 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2096 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2097 init_special_inode(inode, S_IFCHR|opts->mode, device);
2098 + /* devpts is xid tagged */
2099 + i_tag_write(inode, (vtag_t)vx_current_xid());
2100 + inode->i_op = &devpts_file_inode_operations;
2101 inode->i_private = priv;
2103 sprintf(s, "%d", index);
2104 diff -NurpP --minimal linux-3.10.15/fs/ext2/balloc.c linux-3.10.15-vs2.3.6.6/fs/ext2/balloc.c
2105 --- linux-3.10.15/fs/ext2/balloc.c 2013-05-31 13:45:23.000000000 +0000
2106 +++ linux-3.10.15-vs2.3.6.6/fs/ext2/balloc.c 2013-08-22 20:29:59.000000000 +0000
2107 @@ -693,7 +693,6 @@ ext2_try_to_allocate(struct super_block
2109 end = EXT2_BLOCKS_PER_GROUP(sb);
2112 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2115 diff -NurpP --minimal linux-3.10.15/fs/ext2/ext2.h linux-3.10.15-vs2.3.6.6/fs/ext2/ext2.h
2116 --- linux-3.10.15/fs/ext2/ext2.h 2012-12-11 03:30:57.000000000 +0000
2117 +++ linux-3.10.15-vs2.3.6.6/fs/ext2/ext2.h 2013-08-22 20:29:59.000000000 +0000
2118 @@ -244,8 +244,12 @@ struct ext2_group_desc
2119 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
2120 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
2121 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
2122 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
2123 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
2125 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
2126 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
2128 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
2129 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
2131 @@ -329,7 +333,8 @@ struct ext2_inode {
2133 __le16 l_i_uid_high; /* these 2 fields */
2134 __le16 l_i_gid_high; /* were reserved2[0] */
2135 - __u32 l_i_reserved2;
2136 + __le16 l_i_tag; /* Context Tag */
2137 + __u16 l_i_reserved2;
2140 __u8 h_i_frag; /* Fragment number */
2141 @@ -357,6 +362,7 @@ struct ext2_inode {
2142 #define i_gid_low i_gid
2143 #define i_uid_high osd2.linux2.l_i_uid_high
2144 #define i_gid_high osd2.linux2.l_i_gid_high
2145 +#define i_raw_tag osd2.linux2.l_i_tag
2146 #define i_reserved2 osd2.linux2.l_i_reserved2
2149 @@ -384,6 +390,7 @@ struct ext2_inode {
2150 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
2151 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
2152 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
2153 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2156 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
2157 @@ -757,6 +764,7 @@ extern void ext2_set_inode_flags(struct
2158 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2159 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2160 u64 start, u64 len);
2161 +extern int ext2_sync_flags(struct inode *, int, int);
2164 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2165 diff -NurpP --minimal linux-3.10.15/fs/ext2/file.c linux-3.10.15-vs2.3.6.6/fs/ext2/file.c
2166 --- linux-3.10.15/fs/ext2/file.c 2012-12-11 03:30:57.000000000 +0000
2167 +++ linux-3.10.15-vs2.3.6.6/fs/ext2/file.c 2013-08-22 20:29:59.000000000 +0000
2168 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2169 .setattr = ext2_setattr,
2170 .get_acl = ext2_get_acl,
2171 .fiemap = ext2_fiemap,
2172 + .sync_flags = ext2_sync_flags,
2174 diff -NurpP --minimal linux-3.10.15/fs/ext2/ialloc.c linux-3.10.15-vs2.3.6.6/fs/ext2/ialloc.c
2175 --- linux-3.10.15/fs/ext2/ialloc.c 2013-05-31 13:45:23.000000000 +0000
2176 +++ linux-3.10.15-vs2.3.6.6/fs/ext2/ialloc.c 2013-08-22 20:29:59.000000000 +0000
2178 #include <linux/backing-dev.h>
2179 #include <linux/buffer_head.h>
2180 #include <linux/random.h>
2181 +#include <linux/vs_tag.h>
2185 @@ -546,6 +547,7 @@ got:
2186 inode->i_mode = mode;
2187 inode->i_uid = current_fsuid();
2188 inode->i_gid = dir->i_gid;
2189 + i_tag_write(inode, dx_current_fstag(sb));
2191 inode_init_owner(inode, dir, mode);
2193 diff -NurpP --minimal linux-3.10.15/fs/ext2/inode.c linux-3.10.15-vs2.3.6.6/fs/ext2/inode.c
2194 --- linux-3.10.15/fs/ext2/inode.c 2013-07-14 17:01:27.000000000 +0000
2195 +++ linux-3.10.15-vs2.3.6.6/fs/ext2/inode.c 2013-08-22 21:46:54.000000000 +0000
2197 #include <linux/fiemap.h>
2198 #include <linux/namei.h>
2199 #include <linux/aio.h>
2200 +#include <linux/vs_tag.h>
2204 @@ -1180,7 +1181,7 @@ static void ext2_truncate_blocks(struct
2206 if (ext2_inode_is_fast_symlink(inode))
2208 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2209 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2211 __ext2_truncate_blocks(inode, offset);
2213 @@ -1271,36 +1272,61 @@ void ext2_set_inode_flags(struct inode *
2215 unsigned int flags = EXT2_I(inode)->i_flags;
2217 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2218 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2219 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2222 + if (flags & EXT2_IMMUTABLE_FL)
2223 + inode->i_flags |= S_IMMUTABLE;
2224 + if (flags & EXT2_IXUNLINK_FL)
2225 + inode->i_flags |= S_IXUNLINK;
2227 if (flags & EXT2_SYNC_FL)
2228 inode->i_flags |= S_SYNC;
2229 if (flags & EXT2_APPEND_FL)
2230 inode->i_flags |= S_APPEND;
2231 - if (flags & EXT2_IMMUTABLE_FL)
2232 - inode->i_flags |= S_IMMUTABLE;
2233 if (flags & EXT2_NOATIME_FL)
2234 inode->i_flags |= S_NOATIME;
2235 if (flags & EXT2_DIRSYNC_FL)
2236 inode->i_flags |= S_DIRSYNC;
2238 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2240 + if (flags & EXT2_BARRIER_FL)
2241 + inode->i_vflags |= V_BARRIER;
2242 + if (flags & EXT2_COW_FL)
2243 + inode->i_vflags |= V_COW;
2246 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2247 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2249 unsigned int flags = ei->vfs_inode.i_flags;
2250 + unsigned int vflags = ei->vfs_inode.i_vflags;
2252 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2253 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2254 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2255 + EXT2_BARRIER_FL | EXT2_COW_FL);
2257 + if (flags & S_IMMUTABLE)
2258 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2259 + if (flags & S_IXUNLINK)
2260 + ei->i_flags |= EXT2_IXUNLINK_FL;
2262 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2263 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2265 ei->i_flags |= EXT2_SYNC_FL;
2266 if (flags & S_APPEND)
2267 ei->i_flags |= EXT2_APPEND_FL;
2268 - if (flags & S_IMMUTABLE)
2269 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2270 if (flags & S_NOATIME)
2271 ei->i_flags |= EXT2_NOATIME_FL;
2272 if (flags & S_DIRSYNC)
2273 ei->i_flags |= EXT2_DIRSYNC_FL;
2275 + if (vflags & V_BARRIER)
2276 + ei->i_flags |= EXT2_BARRIER_FL;
2277 + if (vflags & V_COW)
2278 + ei->i_flags |= EXT2_COW_FL;
2281 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2282 @@ -1336,8 +1362,10 @@ struct inode *ext2_iget (struct super_bl
2283 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2284 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2286 - i_uid_write(inode, i_uid);
2287 - i_gid_write(inode, i_gid);
2288 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2289 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2290 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2291 + le16_to_cpu(raw_inode->i_raw_tag)));
2292 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2293 inode->i_size = le32_to_cpu(raw_inode->i_size);
2294 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2295 @@ -1435,8 +1463,10 @@ static int __ext2_write_inode(struct ino
2296 struct ext2_inode_info *ei = EXT2_I(inode);
2297 struct super_block *sb = inode->i_sb;
2298 ino_t ino = inode->i_ino;
2299 - uid_t uid = i_uid_read(inode);
2300 - gid_t gid = i_gid_read(inode);
2301 + uid_t uid = from_kuid(&init_user_ns,
2302 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
2303 + gid_t gid = from_kgid(&init_user_ns,
2304 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
2305 struct buffer_head * bh;
2306 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2308 @@ -1472,6 +1502,9 @@ static int __ext2_write_inode(struct ino
2309 raw_inode->i_uid_high = 0;
2310 raw_inode->i_gid_high = 0;
2312 +#ifdef CONFIG_TAGGING_INTERN
2313 + raw_inode->i_raw_tag = cpu_to_le16(i_tag_read(inode));
2315 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2316 raw_inode->i_size = cpu_to_le32(inode->i_size);
2317 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2318 @@ -1552,7 +1585,8 @@ int ext2_setattr(struct dentry *dentry,
2319 if (is_quota_modification(inode, iattr))
2320 dquot_initialize(inode);
2321 if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||
2322 - (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {
2323 + (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid)) ||
2324 + (iattr->ia_valid & ATTR_TAG && !tag_eq(iattr->ia_tag, inode->i_tag))) {
2325 error = dquot_transfer(inode, iattr);
2328 diff -NurpP --minimal linux-3.10.15/fs/ext2/ioctl.c linux-3.10.15-vs2.3.6.6/fs/ext2/ioctl.c
2329 --- linux-3.10.15/fs/ext2/ioctl.c 2013-05-31 13:45:23.000000000 +0000
2330 +++ linux-3.10.15-vs2.3.6.6/fs/ext2/ioctl.c 2013-08-22 20:29:59.000000000 +0000
2332 #include <asm/uaccess.h>
2335 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2337 + inode->i_flags = flags;
2338 + inode->i_vflags = vflags;
2339 + ext2_get_inode_flags(EXT2_I(inode));
2340 + inode->i_ctime = CURRENT_TIME_SEC;
2341 + mark_inode_dirty(inode);
2345 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2347 struct inode *inode = file_inode(filp);
2348 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2350 flags = ext2_mask_flags(inode->i_mode, flags);
2352 + if (IS_BARRIER(inode)) {
2353 + vxwprintk_task(1, "messing with the barrier.");
2357 mutex_lock(&inode->i_mutex);
2358 /* Is it quota file? Do not allow user to mess with it */
2359 if (IS_NOQUOTA(inode)) {
2360 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2362 * This test looks nicer. Thanks to Pauline Middelink
2364 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2365 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2366 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2367 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2368 if (!capable(CAP_LINUX_IMMUTABLE)) {
2369 mutex_unlock(&inode->i_mutex);
2371 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2375 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2376 + flags &= EXT2_FL_USER_MODIFIABLE;
2377 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2378 ei->i_flags = flags;
2380 diff -NurpP --minimal linux-3.10.15/fs/ext2/namei.c linux-3.10.15-vs2.3.6.6/fs/ext2/namei.c
2381 --- linux-3.10.15/fs/ext2/namei.c 2012-12-11 03:30:57.000000000 +0000
2382 +++ linux-3.10.15-vs2.3.6.6/fs/ext2/namei.c 2013-08-22 20:29:59.000000000 +0000
2385 #include <linux/pagemap.h>
2386 #include <linux/quotaops.h>
2387 +#include <linux/vs_tag.h>
2391 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
2392 (unsigned long) ino);
2393 return ERR_PTR(-EIO);
2395 + dx_propagate_tag(nd, inode);
2397 return d_splice_alias(inode, dentry);
2399 @@ -397,6 +399,7 @@ const struct inode_operations ext2_dir_i
2400 .removexattr = generic_removexattr,
2402 .setattr = ext2_setattr,
2403 + .sync_flags = ext2_sync_flags,
2404 .get_acl = ext2_get_acl,
2407 diff -NurpP --minimal linux-3.10.15/fs/ext2/super.c linux-3.10.15-vs2.3.6.6/fs/ext2/super.c
2408 --- linux-3.10.15/fs/ext2/super.c 2013-05-31 13:45:23.000000000 +0000
2409 +++ linux-3.10.15-vs2.3.6.6/fs/ext2/super.c 2013-08-22 20:29:59.000000000 +0000
2410 @@ -395,7 +395,8 @@ enum {
2411 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2412 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2413 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2414 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2415 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2416 + Opt_tag, Opt_notag, Opt_tagid
2419 static const match_table_t tokens = {
2420 @@ -423,6 +424,9 @@ static const match_table_t tokens = {
2422 {Opt_noacl, "noacl"},
2425 + {Opt_notag, "notag"},
2426 + {Opt_tagid, "tagid=%u"},
2427 {Opt_grpquota, "grpquota"},
2428 {Opt_ignore, "noquota"},
2429 {Opt_quota, "quota"},
2430 @@ -506,6 +510,20 @@ static int parse_options(char *options,
2432 set_opt (sbi->s_mount_opt, NO_UID32);
2434 +#ifndef CONFIG_TAGGING_NONE
2436 + set_opt (sbi->s_mount_opt, TAGGED);
2439 + clear_opt (sbi->s_mount_opt, TAGGED);
2442 +#ifdef CONFIG_PROPAGATE
2445 + set_opt (sbi->s_mount_opt, TAGGED);
2449 clear_opt (sbi->s_mount_opt, CHECK);
2451 @@ -864,6 +882,8 @@ static int ext2_fill_super(struct super_
2452 if (!parse_options((char *) data, sb))
2455 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2456 + sb->s_flags |= MS_TAGGED;
2457 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2458 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2460 @@ -1269,6 +1289,14 @@ static int ext2_remount (struct super_bl
2465 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2466 + !(sb->s_flags & MS_TAGGED)) {
2467 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2470 + goto restore_opts;
2473 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2474 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2475 diff -NurpP --minimal linux-3.10.15/fs/ext3/ext3.h linux-3.10.15-vs2.3.6.6/fs/ext3/ext3.h
2476 --- linux-3.10.15/fs/ext3/ext3.h 2012-12-11 03:30:57.000000000 +0000
2477 +++ linux-3.10.15-vs2.3.6.6/fs/ext3/ext3.h 2013-08-22 20:29:59.000000000 +0000
2478 @@ -151,10 +151,14 @@ struct ext3_group_desc
2479 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
2480 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
2481 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
2482 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2483 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
2485 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
2486 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
2487 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2488 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
2490 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
2491 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
2493 /* Flags that should be inherited by new inodes from their parent. */
2494 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
2495 @@ -290,7 +294,8 @@ struct ext3_inode {
2497 __le16 l_i_uid_high; /* these 2 fields */
2498 __le16 l_i_gid_high; /* were reserved2[0] */
2499 - __u32 l_i_reserved2;
2500 + __le16 l_i_tag; /* Context Tag */
2501 + __u16 l_i_reserved2;
2504 __u8 h_i_frag; /* Fragment number */
2505 @@ -320,6 +325,7 @@ struct ext3_inode {
2506 #define i_gid_low i_gid
2507 #define i_uid_high osd2.linux2.l_i_uid_high
2508 #define i_gid_high osd2.linux2.l_i_gid_high
2509 +#define i_raw_tag osd2.linux2.l_i_tag
2510 #define i_reserved2 osd2.linux2.l_i_reserved2
2513 @@ -364,6 +370,7 @@ struct ext3_inode {
2514 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
2515 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
2516 * error in ordered mode */
2517 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2519 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
2520 #ifndef _LINUX_EXT2_FS_H
2521 @@ -1061,6 +1068,7 @@ extern void ext3_get_inode_flags(struct
2522 extern void ext3_set_aops(struct inode *inode);
2523 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2524 u64 start, u64 len);
2525 +extern int ext3_sync_flags(struct inode *, int, int);
2528 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
2529 diff -NurpP --minimal linux-3.10.15/fs/ext3/file.c linux-3.10.15-vs2.3.6.6/fs/ext3/file.c
2530 --- linux-3.10.15/fs/ext3/file.c 2012-12-11 03:30:57.000000000 +0000
2531 +++ linux-3.10.15-vs2.3.6.6/fs/ext3/file.c 2013-08-22 20:29:59.000000000 +0000
2532 @@ -76,5 +76,6 @@ const struct inode_operations ext3_file_
2534 .get_acl = ext3_get_acl,
2535 .fiemap = ext3_fiemap,
2536 + .sync_flags = ext3_sync_flags,
2539 diff -NurpP --minimal linux-3.10.15/fs/ext3/ialloc.c linux-3.10.15-vs2.3.6.6/fs/ext3/ialloc.c
2540 --- linux-3.10.15/fs/ext3/ialloc.c 2012-12-11 03:30:57.000000000 +0000
2541 +++ linux-3.10.15-vs2.3.6.6/fs/ext3/ialloc.c 2013-08-22 20:29:59.000000000 +0000
2544 #include <linux/quotaops.h>
2545 #include <linux/random.h>
2546 +#include <linux/vs_tag.h>
2550 @@ -469,6 +470,7 @@ got:
2551 inode->i_mode = mode;
2552 inode->i_uid = current_fsuid();
2553 inode->i_gid = dir->i_gid;
2554 + i_tag_write(inode, dx_current_fstag(sb));
2556 inode_init_owner(inode, dir, mode);
2558 diff -NurpP --minimal linux-3.10.15/fs/ext3/inode.c linux-3.10.15-vs2.3.6.6/fs/ext3/inode.c
2559 --- linux-3.10.15/fs/ext3/inode.c 2013-07-14 17:01:27.000000000 +0000
2560 +++ linux-3.10.15-vs2.3.6.6/fs/ext3/inode.c 2013-08-22 21:21:18.000000000 +0000
2562 #include <linux/mpage.h>
2563 #include <linux/namei.h>
2564 #include <linux/aio.h>
2565 +#include <linux/vs_tag.h>
2570 @@ -2853,36 +2855,60 @@ void ext3_set_inode_flags(struct inode *
2572 unsigned int flags = EXT3_I(inode)->i_flags;
2574 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2575 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2576 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2578 + if (flags & EXT3_IMMUTABLE_FL)
2579 + inode->i_flags |= S_IMMUTABLE;
2580 + if (flags & EXT3_IXUNLINK_FL)
2581 + inode->i_flags |= S_IXUNLINK;
2583 if (flags & EXT3_SYNC_FL)
2584 inode->i_flags |= S_SYNC;
2585 if (flags & EXT3_APPEND_FL)
2586 inode->i_flags |= S_APPEND;
2587 - if (flags & EXT3_IMMUTABLE_FL)
2588 - inode->i_flags |= S_IMMUTABLE;
2589 if (flags & EXT3_NOATIME_FL)
2590 inode->i_flags |= S_NOATIME;
2591 if (flags & EXT3_DIRSYNC_FL)
2592 inode->i_flags |= S_DIRSYNC;
2594 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2596 + if (flags & EXT3_BARRIER_FL)
2597 + inode->i_vflags |= V_BARRIER;
2598 + if (flags & EXT3_COW_FL)
2599 + inode->i_vflags |= V_COW;
2602 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2603 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2605 unsigned int flags = ei->vfs_inode.i_flags;
2606 + unsigned int vflags = ei->vfs_inode.i_vflags;
2608 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2609 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2610 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2611 + EXT3_BARRIER_FL | EXT3_COW_FL);
2613 + if (flags & S_IMMUTABLE)
2614 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2615 + if (flags & S_IXUNLINK)
2616 + ei->i_flags |= EXT3_IXUNLINK_FL;
2618 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2619 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2621 ei->i_flags |= EXT3_SYNC_FL;
2622 if (flags & S_APPEND)
2623 ei->i_flags |= EXT3_APPEND_FL;
2624 - if (flags & S_IMMUTABLE)
2625 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2626 if (flags & S_NOATIME)
2627 ei->i_flags |= EXT3_NOATIME_FL;
2628 if (flags & S_DIRSYNC)
2629 ei->i_flags |= EXT3_DIRSYNC_FL;
2631 + if (vflags & V_BARRIER)
2632 + ei->i_flags |= EXT3_BARRIER_FL;
2633 + if (vflags & V_COW)
2634 + ei->i_flags |= EXT3_COW_FL;
2637 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2638 @@ -2920,8 +2946,10 @@ struct inode *ext3_iget(struct super_blo
2639 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2640 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2642 - i_uid_write(inode, i_uid);
2643 - i_gid_write(inode, i_gid);
2644 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2645 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2646 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2647 + le16_to_cpu(raw_inode->i_raw_tag)));
2648 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2649 inode->i_size = le32_to_cpu(raw_inode->i_size);
2650 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2651 @@ -3093,8 +3121,10 @@ again:
2653 ext3_get_inode_flags(ei);
2654 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2655 - i_uid = i_uid_read(inode);
2656 - i_gid = i_gid_read(inode);
2657 + i_uid = from_kuid(&init_user_ns,
2658 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
2659 + i_gid = from_kgid(&init_user_ns,
2660 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
2661 if(!(test_opt(inode->i_sb, NO_UID32))) {
2662 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
2663 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
2664 @@ -3119,6 +3149,9 @@ again:
2665 raw_inode->i_uid_high = 0;
2666 raw_inode->i_gid_high = 0;
2668 +#ifdef CONFIG_TAGGING_INTERN
2669 + raw_inode->i_raw_tag = cpu_to_le16(i_tag_read(inode));
2671 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2672 disksize = cpu_to_le32(ei->i_disksize);
2673 if (disksize != raw_inode->i_size) {
2674 @@ -3287,7 +3320,8 @@ int ext3_setattr(struct dentry *dentry,
2675 if (is_quota_modification(inode, attr))
2676 dquot_initialize(inode);
2677 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
2678 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
2679 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
2680 + (ia_valid & ATTR_TAG && !tag_eq(attr->ia_tag, inode->i_tag))) {
2683 /* (user+group)*(old+new) structure, inode write (sb,
2684 @@ -3309,6 +3343,8 @@ int ext3_setattr(struct dentry *dentry,
2685 inode->i_uid = attr->ia_uid;
2686 if (attr->ia_valid & ATTR_GID)
2687 inode->i_gid = attr->ia_gid;
2688 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2689 + inode->i_tag = attr->ia_tag;
2690 error = ext3_mark_inode_dirty(handle, inode);
2691 ext3_journal_stop(handle);
2693 diff -NurpP --minimal linux-3.10.15/fs/ext3/ioctl.c linux-3.10.15-vs2.3.6.6/fs/ext3/ioctl.c
2694 --- linux-3.10.15/fs/ext3/ioctl.c 2013-05-31 13:45:23.000000000 +0000
2695 +++ linux-3.10.15-vs2.3.6.6/fs/ext3/ioctl.c 2013-08-22 20:29:59.000000000 +0000
2697 #include <asm/uaccess.h>
2701 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2703 + handle_t *handle = NULL;
2704 + struct ext3_iloc iloc;
2707 + handle = ext3_journal_start(inode, 1);
2708 + if (IS_ERR(handle))
2709 + return PTR_ERR(handle);
2711 + if (IS_SYNC(inode))
2712 + handle->h_sync = 1;
2713 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2717 + inode->i_flags = flags;
2718 + inode->i_vflags = vflags;
2719 + ext3_get_inode_flags(EXT3_I(inode));
2720 + inode->i_ctime = CURRENT_TIME_SEC;
2722 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2724 + ext3_journal_stop(handle);
2728 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2730 struct inode *inode = file_inode(filp);
2731 @@ -45,6 +73,11 @@ long ext3_ioctl(struct file *filp, unsig
2733 flags = ext3_mask_flags(inode->i_mode, flags);
2735 + if (IS_BARRIER(inode)) {
2736 + vxwprintk_task(1, "messing with the barrier.");
2740 mutex_lock(&inode->i_mutex);
2742 /* Is it quota file? Do not allow user to mess with it */
2743 @@ -63,7 +96,9 @@ long ext3_ioctl(struct file *filp, unsig
2745 * This test looks nicer. Thanks to Pauline Middelink
2747 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2748 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2749 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2750 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2751 if (!capable(CAP_LINUX_IMMUTABLE))
2754 @@ -88,7 +123,7 @@ long ext3_ioctl(struct file *filp, unsig
2758 - flags = flags & EXT3_FL_USER_MODIFIABLE;
2759 + flags &= EXT3_FL_USER_MODIFIABLE;
2760 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
2761 ei->i_flags = flags;
2763 diff -NurpP --minimal linux-3.10.15/fs/ext3/namei.c linux-3.10.15-vs2.3.6.6/fs/ext3/namei.c
2764 --- linux-3.10.15/fs/ext3/namei.c 2013-10-09 17:35:22.000000000 +0000
2765 +++ linux-3.10.15-vs2.3.6.6/fs/ext3/namei.c 2013-08-22 20:29:59.000000000 +0000
2769 #include <linux/quotaops.h>
2770 +#include <linux/vs_tag.h>
2775 @@ -915,6 +917,7 @@ restart:
2776 submit_bh(READ | REQ_META | REQ_PRIO,
2779 + dx_propagate_tag(nd, inode);
2782 if ((bh = bh_use[ra_ptr++]) == NULL)
2783 @@ -2524,6 +2527,7 @@ const struct inode_operations ext3_dir_i
2784 .listxattr = ext3_listxattr,
2785 .removexattr = generic_removexattr,
2787 + .sync_flags = ext3_sync_flags,
2788 .get_acl = ext3_get_acl,
2791 diff -NurpP --minimal linux-3.10.15/fs/ext3/super.c linux-3.10.15-vs2.3.6.6/fs/ext3/super.c
2792 --- linux-3.10.15/fs/ext3/super.c 2013-07-14 17:01:27.000000000 +0000
2793 +++ linux-3.10.15-vs2.3.6.6/fs/ext3/super.c 2013-08-22 20:29:59.000000000 +0000
2794 @@ -813,7 +813,8 @@ enum {
2795 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2796 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
2797 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
2798 - Opt_resize, Opt_usrquota, Opt_grpquota
2799 + Opt_resize, Opt_usrquota, Opt_grpquota,
2800 + Opt_tag, Opt_notag, Opt_tagid
2803 static const match_table_t tokens = {
2804 @@ -870,6 +871,9 @@ static const match_table_t tokens = {
2805 {Opt_barrier, "barrier"},
2806 {Opt_nobarrier, "nobarrier"},
2807 {Opt_resize, "resize"},
2809 + {Opt_notag, "notag"},
2810 + {Opt_tagid, "tagid=%u"},
2814 @@ -1037,6 +1041,20 @@ static int parse_options (char *options,
2816 set_opt (sbi->s_mount_opt, NO_UID32);
2818 +#ifndef CONFIG_TAGGING_NONE
2820 + set_opt (sbi->s_mount_opt, TAGGED);
2823 + clear_opt (sbi->s_mount_opt, TAGGED);
2826 +#ifdef CONFIG_PROPAGATE
2829 + set_opt (sbi->s_mount_opt, TAGGED);
2833 clear_opt (sbi->s_mount_opt, CHECK);
2835 @@ -1734,6 +1752,9 @@ static int ext3_fill_super (struct super
2839 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
2840 + sb->s_flags |= MS_TAGGED;
2842 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2843 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2845 @@ -2629,6 +2650,14 @@ static int ext3_remount (struct super_bl
2846 if (test_opt(sb, ABORT))
2847 ext3_abort(sb, __func__, "Abort forced by user");
2849 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
2850 + !(sb->s_flags & MS_TAGGED)) {
2851 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
2854 + goto restore_opts;
2857 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2858 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2860 diff -NurpP --minimal linux-3.10.15/fs/ext4/ext4.h linux-3.10.15-vs2.3.6.6/fs/ext4/ext4.h
2861 --- linux-3.10.15/fs/ext4/ext4.h 2013-07-14 17:01:27.000000000 +0000
2862 +++ linux-3.10.15-vs2.3.6.6/fs/ext4/ext4.h 2013-08-22 20:29:59.000000000 +0000
2863 @@ -387,7 +387,10 @@ struct flex_groups {
2864 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
2865 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
2866 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
2867 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2868 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2869 #define EXT4_INLINE_DATA_FL 0x10000000 /* Inode has inline data. */
2870 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
2871 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
2873 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
2874 @@ -663,7 +666,7 @@ struct ext4_inode {
2875 __le16 l_i_uid_high; /* these 2 fields */
2876 __le16 l_i_gid_high; /* were reserved2[0] */
2877 __le16 l_i_checksum_lo;/* crc32c(uuid+inum+inode) LE */
2878 - __le16 l_i_reserved;
2879 + __le16 l_i_tag; /* Context Tag */
2882 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
2883 @@ -781,6 +784,7 @@ do { \
2884 #define i_gid_low i_gid
2885 #define i_uid_high osd2.linux2.l_i_uid_high
2886 #define i_gid_high osd2.linux2.l_i_gid_high
2887 +#define i_raw_tag osd2.linux2.l_i_tag
2888 #define i_checksum_lo osd2.linux2.l_i_checksum_lo
2890 #elif defined(__GNU__)
2891 @@ -958,6 +962,7 @@ struct ext4_inode_info {
2892 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
2893 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
2894 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
2895 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
2896 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
2897 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
2898 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
2899 @@ -2538,6 +2543,7 @@ extern struct buffer_head *ext4_get_firs
2900 extern int ext4_inline_data_fiemap(struct inode *inode,
2901 struct fiemap_extent_info *fieinfo,
2903 +extern int ext4_sync_flags(struct inode *, int, int);
2904 extern int ext4_try_to_evict_inline_data(handle_t *handle,
2905 struct inode *inode,
2907 diff -NurpP --minimal linux-3.10.15/fs/ext4/file.c linux-3.10.15-vs2.3.6.6/fs/ext4/file.c
2908 --- linux-3.10.15/fs/ext4/file.c 2013-10-09 17:35:22.000000000 +0000
2909 +++ linux-3.10.15-vs2.3.6.6/fs/ext4/file.c 2013-08-22 20:29:59.000000000 +0000
2910 @@ -651,5 +651,6 @@ const struct inode_operations ext4_file_
2911 .removexattr = generic_removexattr,
2912 .get_acl = ext4_get_acl,
2913 .fiemap = ext4_fiemap,
2914 + .sync_flags = ext4_sync_flags,
2917 diff -NurpP --minimal linux-3.10.15/fs/ext4/ialloc.c linux-3.10.15-vs2.3.6.6/fs/ext4/ialloc.c
2918 --- linux-3.10.15/fs/ext4/ialloc.c 2013-10-09 17:35:22.000000000 +0000
2919 +++ linux-3.10.15-vs2.3.6.6/fs/ext4/ialloc.c 2013-08-22 20:29:59.000000000 +0000
2921 #include <linux/random.h>
2922 #include <linux/bitops.h>
2923 #include <linux/blkdev.h>
2924 +#include <linux/vs_tag.h>
2925 #include <asm/byteorder.h>
2928 @@ -679,6 +680,7 @@ struct inode *__ext4_new_inode(handle_t
2929 inode->i_mode = mode;
2930 inode->i_uid = current_fsuid();
2931 inode->i_gid = dir->i_gid;
2932 + i_tag_write(inode, dx_current_fstag(sb));
2934 inode_init_owner(inode, dir, mode);
2935 dquot_initialize(inode);
2936 diff -NurpP --minimal linux-3.10.15/fs/ext4/inode.c linux-3.10.15-vs2.3.6.6/fs/ext4/inode.c
2937 --- linux-3.10.15/fs/ext4/inode.c 2013-10-09 17:35:22.000000000 +0000
2938 +++ linux-3.10.15-vs2.3.6.6/fs/ext4/inode.c 2013-10-09 17:37:22.000000000 +0000
2940 #include <linux/slab.h>
2941 #include <linux/ratelimit.h>
2942 #include <linux/aio.h>
2943 +#include <linux/vs_tag.h>
2945 #include "ext4_jbd2.h"
2947 @@ -4057,41 +4058,64 @@ void ext4_set_inode_flags(struct inode *
2949 unsigned int flags = EXT4_I(inode)->i_flags;
2951 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2952 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2953 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2955 + if (flags & EXT4_IMMUTABLE_FL)
2956 + inode->i_flags |= S_IMMUTABLE;
2957 + if (flags & EXT4_IXUNLINK_FL)
2958 + inode->i_flags |= S_IXUNLINK;
2960 if (flags & EXT4_SYNC_FL)
2961 inode->i_flags |= S_SYNC;
2962 if (flags & EXT4_APPEND_FL)
2963 inode->i_flags |= S_APPEND;
2964 - if (flags & EXT4_IMMUTABLE_FL)
2965 - inode->i_flags |= S_IMMUTABLE;
2966 if (flags & EXT4_NOATIME_FL)
2967 inode->i_flags |= S_NOATIME;
2968 if (flags & EXT4_DIRSYNC_FL)
2969 inode->i_flags |= S_DIRSYNC;
2971 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2973 + if (flags & EXT4_BARRIER_FL)
2974 + inode->i_vflags |= V_BARRIER;
2975 + if (flags & EXT4_COW_FL)
2976 + inode->i_vflags |= V_COW;
2979 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
2980 void ext4_get_inode_flags(struct ext4_inode_info *ei)
2982 - unsigned int vfs_fl;
2983 + unsigned int vfs_fl, vfs_vf;
2984 unsigned long old_fl, new_fl;
2987 vfs_fl = ei->vfs_inode.i_flags;
2988 + vfs_vf = ei->vfs_inode.i_vflags;
2989 old_fl = ei->i_flags;
2990 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
2991 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
2993 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
2996 + if (vfs_fl & S_IMMUTABLE)
2997 + new_fl |= EXT4_IMMUTABLE_FL;
2998 + if (vfs_fl & S_IXUNLINK)
2999 + new_fl |= EXT4_IXUNLINK_FL;
3001 if (vfs_fl & S_SYNC)
3002 new_fl |= EXT4_SYNC_FL;
3003 if (vfs_fl & S_APPEND)
3004 new_fl |= EXT4_APPEND_FL;
3005 - if (vfs_fl & S_IMMUTABLE)
3006 - new_fl |= EXT4_IMMUTABLE_FL;
3007 if (vfs_fl & S_NOATIME)
3008 new_fl |= EXT4_NOATIME_FL;
3009 if (vfs_fl & S_DIRSYNC)
3010 new_fl |= EXT4_DIRSYNC_FL;
3012 + if (vfs_vf & V_BARRIER)
3013 + new_fl |= EXT4_BARRIER_FL;
3014 + if (vfs_vf & V_COW)
3015 + new_fl |= EXT4_COW_FL;
3016 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3019 @@ -4196,8 +4220,10 @@ struct inode *ext4_iget(struct super_blo
3020 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3021 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3023 - i_uid_write(inode, i_uid);
3024 - i_gid_write(inode, i_gid);
3025 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
3026 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
3027 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
3028 + le16_to_cpu(raw_inode->i_raw_tag)));
3029 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
3031 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3032 @@ -4425,8 +4451,10 @@ static int ext4_do_update_inode(handle_t
3034 ext4_get_inode_flags(ei);
3035 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3036 - i_uid = i_uid_read(inode);
3037 - i_gid = i_gid_read(inode);
3038 + i_uid = from_kuid(&init_user_ns,
3039 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
3040 + i_gid = from_kgid(&init_user_ns,
3041 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
3042 if (!(test_opt(inode->i_sb, NO_UID32))) {
3043 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
3044 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
3045 @@ -4449,6 +4477,9 @@ static int ext4_do_update_inode(handle_t
3046 raw_inode->i_uid_high = 0;
3047 raw_inode->i_gid_high = 0;
3049 +#ifdef CONFIG_TAGGING_INTERN
3050 + raw_inode->i_raw_tag = cpu_to_le16(i_tag_read(inode));
3052 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3054 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3055 @@ -4679,7 +4710,8 @@ int ext4_setattr(struct dentry *dentry,
3056 if (is_quota_modification(inode, attr))
3057 dquot_initialize(inode);
3058 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
3059 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
3060 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
3061 + (ia_valid & ATTR_TAG && !tag_eq(attr->ia_tag, inode->i_tag))) {
3064 /* (user+group)*(old+new) structure, inode write (sb,
3065 @@ -4702,6 +4734,8 @@ int ext4_setattr(struct dentry *dentry,
3066 inode->i_uid = attr->ia_uid;
3067 if (attr->ia_valid & ATTR_GID)
3068 inode->i_gid = attr->ia_gid;
3069 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3070 + inode->i_tag = attr->ia_tag;
3071 error = ext4_mark_inode_dirty(handle, inode);
3072 ext4_journal_stop(handle);
3074 diff -NurpP --minimal linux-3.10.15/fs/ext4/ioctl.c linux-3.10.15-vs2.3.6.6/fs/ext4/ioctl.c
3075 --- linux-3.10.15/fs/ext4/ioctl.c 2013-10-09 17:35:22.000000000 +0000
3076 +++ linux-3.10.15-vs2.3.6.6/fs/ext4/ioctl.c 2013-08-22 22:22:39.000000000 +0000
3078 #include <linux/compat.h>
3079 #include <linux/mount.h>
3080 #include <linux/file.h>
3081 +#include <linux/vs_tag.h>
3082 #include <asm/uaccess.h>
3083 #include "ext4_jbd2.h"
3085 @@ -214,6 +215,33 @@ swap_boot_out:
3089 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3091 + handle_t *handle = NULL;
3092 + struct ext4_iloc iloc;
3095 + handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
3096 + if (IS_ERR(handle))
3097 + return PTR_ERR(handle);
3099 + if (IS_SYNC(inode))
3100 + ext4_handle_sync(handle);
3101 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3105 + inode->i_flags = flags;
3106 + inode->i_vflags = vflags;
3107 + ext4_get_inode_flags(EXT4_I(inode));
3108 + inode->i_ctime = ext4_current_time(inode);
3110 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3112 + ext4_journal_stop(handle);
3116 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3118 struct inode *inode = file_inode(filp);
3119 @@ -247,6 +275,11 @@ long ext4_ioctl(struct file *filp, unsig
3121 flags = ext4_mask_flags(inode->i_mode, flags);
3123 + if (IS_BARRIER(inode)) {
3124 + vxwprintk_task(1, "messing with the barrier.");
3129 mutex_lock(&inode->i_mutex);
3130 /* Is it quota file? Do not allow user to mess with it */
3131 @@ -264,7 +297,9 @@ long ext4_ioctl(struct file *filp, unsig
3133 * This test looks nicer. Thanks to Pauline Middelink
3135 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3136 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3137 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3138 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3139 if (!capable(CAP_LINUX_IMMUTABLE))
3142 diff -NurpP --minimal linux-3.10.15/fs/ext4/namei.c linux-3.10.15-vs2.3.6.6/fs/ext4/namei.c
3143 --- linux-3.10.15/fs/ext4/namei.c 2013-10-09 17:35:22.000000000 +0000
3144 +++ linux-3.10.15-vs2.3.6.6/fs/ext4/namei.c 2013-08-22 20:29:59.000000000 +0000
3146 #include <linux/quotaops.h>
3147 #include <linux/buffer_head.h>
3148 #include <linux/bio.h>
3149 +#include <linux/vs_tag.h>
3151 #include "ext4_jbd2.h"
3153 @@ -1299,6 +1300,7 @@ restart:
3154 ll_rw_block(READ | REQ_META | REQ_PRIO,
3157 + dx_propagate_tag(nd, inode);
3159 if ((bh = bh_use[ra_ptr++]) == NULL)
3161 @@ -3177,6 +3179,7 @@ const struct inode_operations ext4_dir_i
3162 .removexattr = generic_removexattr,
3163 .get_acl = ext4_get_acl,
3164 .fiemap = ext4_fiemap,
3165 + .sync_flags = ext4_sync_flags,
3168 const struct inode_operations ext4_special_inode_operations = {
3169 diff -NurpP --minimal linux-3.10.15/fs/ext4/super.c linux-3.10.15-vs2.3.6.6/fs/ext4/super.c
3170 --- linux-3.10.15/fs/ext4/super.c 2013-10-09 17:35:22.000000000 +0000
3171 +++ linux-3.10.15-vs2.3.6.6/fs/ext4/super.c 2013-08-22 20:29:59.000000000 +0000
3172 @@ -1129,7 +1129,7 @@ enum {
3173 Opt_inode_readahead_blks, Opt_journal_ioprio,
3174 Opt_dioread_nolock, Opt_dioread_lock,
3175 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
3176 - Opt_max_dir_size_kb,
3177 + Opt_max_dir_size_kb, Opt_tag, Opt_notag, Opt_tagid
3180 static const match_table_t tokens = {
3181 @@ -1209,6 +1209,9 @@ static const match_table_t tokens = {
3182 {Opt_removed, "reservation"}, /* mount option from ext2/3 */
3183 {Opt_removed, "noreservation"}, /* mount option from ext2/3 */
3184 {Opt_removed, "journal=%u"}, /* mount option from ext2/3 */
3186 + {Opt_notag, "notag"},
3187 + {Opt_tagid, "tagid=%u"},
3191 @@ -1439,6 +1442,20 @@ static int handle_mount_opt(struct super
3193 sb->s_flags |= MS_I_VERSION;
3195 +#ifndef CONFIG_TAGGING_NONE
3197 + set_opt(sb, TAGGED);
3200 + clear_opt(sb, TAGGED);
3203 +#ifdef CONFIG_PROPAGATE
3206 + set_opt(sb, TAGGED);
3211 for (m = ext4_mount_opts; m->token != Opt_err; m++)
3212 @@ -3452,6 +3469,9 @@ static int ext4_fill_super(struct super_
3213 clear_opt(sb, DELALLOC);
3216 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3217 + sb->s_flags |= MS_TAGGED;
3219 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3220 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3222 @@ -4664,6 +4684,14 @@ static int ext4_remount(struct super_blo
3223 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3224 ext4_abort(sb, "Abort forced by user");
3226 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3227 + !(sb->s_flags & MS_TAGGED)) {
3228 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3231 + goto restore_opts;
3234 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3235 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3237 diff -NurpP --minimal linux-3.10.15/fs/fcntl.c linux-3.10.15-vs2.3.6.6/fs/fcntl.c
3238 --- linux-3.10.15/fs/fcntl.c 2013-05-31 13:45:23.000000000 +0000
3239 +++ linux-3.10.15-vs2.3.6.6/fs/fcntl.c 2013-08-22 20:29:59.000000000 +0000
3241 #include <linux/rcupdate.h>
3242 #include <linux/pid_namespace.h>
3243 #include <linux/user_namespace.h>
3244 +#include <linux/vs_limit.h>
3246 #include <asm/poll.h>
3247 #include <asm/siginfo.h>
3248 @@ -378,6 +379,8 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, f
3252 + if (!vx_files_avail(1))
3255 if (unlikely(f.file->f_mode & FMODE_PATH)) {
3256 if (!check_fcntl_cmd(cmd))
3257 diff -NurpP --minimal linux-3.10.15/fs/file.c linux-3.10.15-vs2.3.6.6/fs/file.c
3258 --- linux-3.10.15/fs/file.c 2013-07-14 17:01:28.000000000 +0000
3259 +++ linux-3.10.15-vs2.3.6.6/fs/file.c 2013-08-22 20:29:59.000000000 +0000
3261 #include <linux/spinlock.h>
3262 #include <linux/rcupdate.h>
3263 #include <linux/workqueue.h>
3264 +#include <linux/vs_limit.h>
3266 int sysctl_nr_open __read_mostly = 1024*1024;
3267 int sysctl_nr_open_min = BITS_PER_LONG;
3268 @@ -311,6 +312,8 @@ struct files_struct *dup_fd(struct files
3269 struct file *f = *old_fds++;
3272 + /* TODO: sum it first for check and performance */
3273 + vx_openfd_inc(open_files - i);
3276 * The fd may be claimed in the fd bitmap but not yet
3277 @@ -376,9 +379,11 @@ static void close_files(struct files_str
3278 filp_close(file, files);
3289 @@ -503,6 +508,7 @@ repeat:
3291 __clear_close_on_exec(fd, fdt);
3293 + vx_openfd_inc(fd);
3296 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3297 @@ -533,6 +539,7 @@ static void __put_unused_fd(struct files
3298 __clear_open_fd(fd, fdt);
3299 if (fd < files->next_fd)
3300 files->next_fd = fd;
3301 + vx_openfd_dec(fd);
3304 void put_unused_fd(unsigned int fd)
3305 @@ -812,6 +819,8 @@ static int do_dup2(struct files_struct *
3308 filp_close(tofree, files);
3310 + vx_openfd_inc(fd); /* fd was unused */
3314 diff -NurpP --minimal linux-3.10.15/fs/file_table.c linux-3.10.15-vs2.3.6.6/fs/file_table.c
3315 --- linux-3.10.15/fs/file_table.c 2013-07-14 17:01:28.000000000 +0000
3316 +++ linux-3.10.15-vs2.3.6.6/fs/file_table.c 2013-08-22 20:29:59.000000000 +0000
3318 #include <linux/hardirq.h>
3319 #include <linux/task_work.h>
3320 #include <linux/ima.h>
3321 +#include <linux/vs_limit.h>
3322 +#include <linux/vs_context.h>
3324 #include <linux/atomic.h>
3326 @@ -140,6 +142,8 @@ struct file *get_empty_filp(void)
3327 spin_lock_init(&f->f_lock);
3328 eventpoll_init_file(f);
3329 /* f->f_version: 0 */
3330 + f->f_xid = vx_current_xid();
3335 @@ -257,6 +261,8 @@ static void __fput(struct file *file)
3336 i_readcount_dec(inode);
3337 if (file->f_mode & FMODE_WRITE)
3338 drop_file_write_access(file);
3339 + vx_files_dec(file);
3341 file->f_path.dentry = NULL;
3342 file->f_path.mnt = NULL;
3343 file->f_inode = NULL;
3344 @@ -345,6 +351,8 @@ void put_filp(struct file *file)
3346 if (atomic_long_dec_and_test(&file->f_count)) {
3347 security_file_free(file);
3348 + vx_files_dec(file);
3350 file_sb_list_del(file);
3353 diff -NurpP --minimal linux-3.10.15/fs/fs_struct.c linux-3.10.15-vs2.3.6.6/fs/fs_struct.c
3354 --- linux-3.10.15/fs/fs_struct.c 2013-05-31 13:45:23.000000000 +0000
3355 +++ linux-3.10.15-vs2.3.6.6/fs/fs_struct.c 2013-08-22 20:29:59.000000000 +0000
3357 #include <linux/path.h>
3358 #include <linux/slab.h>
3359 #include <linux/fs_struct.h>
3360 +#include <linux/vserver/global.h>
3361 #include "internal.h"
3364 @@ -87,6 +88,7 @@ void free_fs_struct(struct fs_struct *fs
3366 path_put(&fs->root);
3368 + atomic_dec(&vs_global_fs);
3369 kmem_cache_free(fs_cachep, fs);
3372 @@ -124,6 +126,7 @@ struct fs_struct *copy_fs_struct(struct
3375 spin_unlock(&old->lock);
3376 + atomic_inc(&vs_global_fs);
3380 diff -NurpP --minimal linux-3.10.15/fs/gfs2/file.c linux-3.10.15-vs2.3.6.6/fs/gfs2/file.c
3381 --- linux-3.10.15/fs/gfs2/file.c 2013-07-14 17:01:28.000000000 +0000
3382 +++ linux-3.10.15-vs2.3.6.6/fs/gfs2/file.c 2013-08-22 20:29:59.000000000 +0000
3383 @@ -144,6 +144,9 @@ static const u32 fsflags_to_gfs2[32] = {
3384 [12] = GFS2_DIF_EXHASH,
3385 [14] = GFS2_DIF_INHERIT_JDATA,
3386 [17] = GFS2_DIF_TOPDIR,
3387 + [27] = GFS2_DIF_IXUNLINK,
3388 + [26] = GFS2_DIF_BARRIER,
3389 + [29] = GFS2_DIF_COW,
3392 static const u32 gfs2_to_fsflags[32] = {
3393 @@ -154,6 +157,9 @@ static const u32 gfs2_to_fsflags[32] = {
3394 [gfs2fl_ExHash] = FS_INDEX_FL,
3395 [gfs2fl_TopLevel] = FS_TOPDIR_FL,
3396 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3397 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3398 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3399 + [gfs2fl_Cow] = FS_COW_FL,
3402 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3403 @@ -184,12 +190,18 @@ void gfs2_set_inode_flags(struct inode *
3405 struct gfs2_inode *ip = GFS2_I(inode);
3406 unsigned int flags = inode->i_flags;
3407 + unsigned int vflags = inode->i_vflags;
3409 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3410 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
3412 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
3413 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
3414 inode->i_flags |= S_NOSEC;
3415 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3416 flags |= S_IMMUTABLE;
3417 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3418 + flags |= S_IXUNLINK;
3420 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3422 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3423 @@ -197,6 +209,43 @@ void gfs2_set_inode_flags(struct inode *
3424 if (ip->i_diskflags & GFS2_DIF_SYNC)
3426 inode->i_flags = flags;
3428 + vflags &= ~(V_BARRIER | V_COW);
3430 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3431 + vflags |= V_BARRIER;
3432 + if (ip->i_diskflags & GFS2_DIF_COW)
3434 + inode->i_vflags = vflags;
3437 +void gfs2_get_inode_flags(struct inode *inode)
3439 + struct gfs2_inode *ip = GFS2_I(inode);
3440 + unsigned int flags = inode->i_flags;
3441 + unsigned int vflags = inode->i_vflags;
3443 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3444 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3445 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3446 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3448 + if (flags & S_IMMUTABLE)
3449 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3450 + if (flags & S_IXUNLINK)
3451 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3453 + if (flags & S_APPEND)
3454 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3455 + if (flags & S_NOATIME)
3456 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3457 + if (flags & S_SYNC)
3458 + ip->i_diskflags |= GFS2_DIF_SYNC;
3460 + if (vflags & V_BARRIER)
3461 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3462 + if (vflags & V_COW)
3463 + ip->i_diskflags |= GFS2_DIF_COW;
3466 /* Flags that can be set by user space */
3467 @@ -310,6 +359,37 @@ static int gfs2_set_flags(struct file *f
3468 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3471 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3473 + struct gfs2_inode *ip = GFS2_I(inode);
3474 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3475 + struct buffer_head *bh;
3476 + struct gfs2_holder gh;
3479 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3482 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3485 + error = gfs2_meta_inode_buffer(ip, &bh);
3487 + goto out_trans_end;
3488 + gfs2_trans_add_meta(ip->i_gl, bh);
3489 + inode->i_flags = flags;
3490 + inode->i_vflags = vflags;
3491 + gfs2_get_inode_flags(inode);
3492 + gfs2_dinode_out(ip, bh->b_data);
3494 + gfs2_set_aops(inode);
3496 + gfs2_trans_end(sdp);
3498 + gfs2_glock_dq_uninit(&gh);
3502 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3505 diff -NurpP --minimal linux-3.10.15/fs/gfs2/inode.h linux-3.10.15-vs2.3.6.6/fs/gfs2/inode.h
3506 --- linux-3.10.15/fs/gfs2/inode.h 2012-12-11 03:30:57.000000000 +0000
3507 +++ linux-3.10.15-vs2.3.6.6/fs/gfs2/inode.h 2013-08-22 20:29:59.000000000 +0000
3508 @@ -117,6 +117,7 @@ extern const struct file_operations gfs2
3509 extern const struct file_operations gfs2_dir_fops_nolock;
3511 extern void gfs2_set_inode_flags(struct inode *inode);
3512 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3514 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3515 extern const struct file_operations gfs2_file_fops;
3516 diff -NurpP --minimal linux-3.10.15/fs/hostfs/hostfs.h linux-3.10.15-vs2.3.6.6/fs/hostfs/hostfs.h
3517 --- linux-3.10.15/fs/hostfs/hostfs.h 2012-12-11 03:30:57.000000000 +0000
3518 +++ linux-3.10.15-vs2.3.6.6/fs/hostfs/hostfs.h 2013-08-22 20:29:59.000000000 +0000
3519 @@ -42,6 +42,7 @@ struct hostfs_iattr {
3520 unsigned short ia_mode;
3525 struct timespec ia_atime;
3526 struct timespec ia_mtime;
3527 diff -NurpP --minimal linux-3.10.15/fs/inode.c linux-3.10.15-vs2.3.6.6/fs/inode.c
3528 --- linux-3.10.15/fs/inode.c 2013-07-14 17:01:28.000000000 +0000
3529 +++ linux-3.10.15-vs2.3.6.6/fs/inode.c 2013-08-22 20:29:59.000000000 +0000
3531 #include <linux/prefetch.h>
3532 #include <linux/buffer_head.h> /* for inode_has_buffers */
3533 #include <linux/ratelimit.h>
3534 +#include <linux/vs_tag.h>
3535 #include "internal.h"
3538 @@ -128,6 +129,8 @@ int inode_init_always(struct super_block
3539 struct address_space *const mapping = &inode->i_data;
3543 + /* essential because of inode slab reuse */
3544 inode->i_blkbits = sb->s_blocksize_bits;
3546 atomic_set(&inode->i_count, 1);
3547 @@ -137,6 +140,7 @@ int inode_init_always(struct super_block
3548 inode->i_opflags = 0;
3549 i_uid_write(inode, 0);
3550 i_gid_write(inode, 0);
3551 + i_tag_write(inode, 0);
3552 atomic_set(&inode->i_writecount, 0);
3554 inode->i_blocks = 0;
3555 @@ -149,6 +153,7 @@ int inode_init_always(struct super_block
3556 inode->i_bdev = NULL;
3557 inode->i_cdev = NULL;
3559 + inode->i_mdev = 0;
3560 inode->dirtied_when = 0;
3562 if (security_inode_alloc(inode))
3563 @@ -483,6 +488,8 @@ void __insert_inode_hash(struct inode *i
3565 EXPORT_SYMBOL(__insert_inode_hash);
3567 +EXPORT_SYMBOL_GPL(__iget);
3570 * __remove_inode_hash - remove an inode from the hash
3571 * @inode: inode to unhash
3572 @@ -1799,9 +1806,11 @@ void init_special_inode(struct inode *in
3573 if (S_ISCHR(mode)) {
3574 inode->i_fop = &def_chr_fops;
3575 inode->i_rdev = rdev;
3576 + inode->i_mdev = rdev;
3577 } else if (S_ISBLK(mode)) {
3578 inode->i_fop = &def_blk_fops;
3579 inode->i_rdev = rdev;
3580 + inode->i_mdev = rdev;
3581 } else if (S_ISFIFO(mode))
3582 inode->i_fop = &pipefifo_fops;
3583 else if (S_ISSOCK(mode))
3584 @@ -1830,6 +1839,7 @@ void inode_init_owner(struct inode *inod
3586 inode->i_gid = current_fsgid();
3587 inode->i_mode = mode;
3588 + i_tag_write(inode, dx_current_fstag(inode->i_sb));
3590 EXPORT_SYMBOL(inode_init_owner);
3592 diff -NurpP --minimal linux-3.10.15/fs/ioctl.c linux-3.10.15-vs2.3.6.6/fs/ioctl.c
3593 --- linux-3.10.15/fs/ioctl.c 2013-05-31 13:45:24.000000000 +0000
3594 +++ linux-3.10.15-vs2.3.6.6/fs/ioctl.c 2013-08-22 20:29:59.000000000 +0000
3596 #include <linux/writeback.h>
3597 #include <linux/buffer_head.h>
3598 #include <linux/falloc.h>
3599 +#include <linux/proc_fs.h>
3600 +#include <linux/vserver/inode.h>
3601 +#include <linux/vs_tag.h>
3603 #include <asm/ioctls.h>
3605 diff -NurpP --minimal linux-3.10.15/fs/ioprio.c linux-3.10.15-vs2.3.6.6/fs/ioprio.c
3606 --- linux-3.10.15/fs/ioprio.c 2012-12-11 03:30:57.000000000 +0000
3607 +++ linux-3.10.15-vs2.3.6.6/fs/ioprio.c 2013-08-22 20:29:59.000000000 +0000
3609 #include <linux/syscalls.h>
3610 #include <linux/security.h>
3611 #include <linux/pid_namespace.h>
3612 +#include <linux/vs_base.h>
3614 int set_task_ioprio(struct task_struct *task, int ioprio)
3616 @@ -105,6 +106,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3618 pgrp = find_vpid(who);
3619 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3620 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3622 ret = set_task_ioprio(p, ioprio);
3625 @@ -198,6 +201,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3627 pgrp = find_vpid(who);
3628 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3629 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3631 tmpio = get_task_ioprio(p);
3634 diff -NurpP --minimal linux-3.10.15/fs/jfs/file.c linux-3.10.15-vs2.3.6.6/fs/jfs/file.c
3635 --- linux-3.10.15/fs/jfs/file.c 2013-02-19 13:58:48.000000000 +0000
3636 +++ linux-3.10.15-vs2.3.6.6/fs/jfs/file.c 2013-08-22 20:29:59.000000000 +0000
3637 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
3638 if (is_quota_modification(inode, iattr))
3639 dquot_initialize(inode);
3640 if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||
3641 - (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {
3642 + (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid)) ||
3643 + (iattr->ia_valid & ATTR_TAG && !tag_eq(iattr->ia_tag, inode->i_tag))) {
3644 rc = dquot_transfer(inode, iattr);
3647 @@ -144,6 +145,7 @@ const struct inode_operations jfs_file_i
3648 #ifdef CONFIG_JFS_POSIX_ACL
3649 .get_acl = jfs_get_acl,
3651 + .sync_flags = jfs_sync_flags,
3654 const struct file_operations jfs_file_operations = {
3655 diff -NurpP --minimal linux-3.10.15/fs/jfs/ioctl.c linux-3.10.15-vs2.3.6.6/fs/jfs/ioctl.c
3656 --- linux-3.10.15/fs/jfs/ioctl.c 2013-05-31 13:45:24.000000000 +0000
3657 +++ linux-3.10.15-vs2.3.6.6/fs/jfs/ioctl.c 2013-08-22 20:29:59.000000000 +0000
3659 #include <linux/time.h>
3660 #include <linux/sched.h>
3661 #include <linux/blkdev.h>
3662 +#include <linux/mount.h>
3663 #include <asm/current.h>
3664 #include <asm/uaccess.h>
3666 @@ -56,6 +57,16 @@ static long jfs_map_ext2(unsigned long f
3670 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3672 + inode->i_flags = flags;
3673 + inode->i_vflags = vflags;
3674 + jfs_get_inode_flags(JFS_IP(inode));
3675 + inode->i_ctime = CURRENT_TIME_SEC;
3676 + mark_inode_dirty(inode);
3680 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3682 struct inode *inode = file_inode(filp);
3683 @@ -89,6 +100,11 @@ long jfs_ioctl(struct file *filp, unsign
3684 if (!S_ISDIR(inode->i_mode))
3685 flags &= ~JFS_DIRSYNC_FL;
3687 + if (IS_BARRIER(inode)) {
3688 + vxwprintk_task(1, "messing with the barrier.");
3692 /* Is it quota file? Do not allow user to mess with it */
3693 if (IS_NOQUOTA(inode)) {
3695 @@ -106,8 +122,8 @@ long jfs_ioctl(struct file *filp, unsign
3696 * the relevant capability.
3698 if ((oldflags & JFS_IMMUTABLE_FL) ||
3699 - ((flags ^ oldflags) &
3700 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3701 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3702 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3703 if (!capable(CAP_LINUX_IMMUTABLE)) {
3704 mutex_unlock(&inode->i_mutex);
3706 @@ -115,7 +131,7 @@ long jfs_ioctl(struct file *filp, unsign
3710 - flags = flags & JFS_FL_USER_MODIFIABLE;
3711 + flags &= JFS_FL_USER_MODIFIABLE;
3712 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3713 jfs_inode->mode2 = flags;
3715 diff -NurpP --minimal linux-3.10.15/fs/jfs/jfs_dinode.h linux-3.10.15-vs2.3.6.6/fs/jfs/jfs_dinode.h
3716 --- linux-3.10.15/fs/jfs/jfs_dinode.h 2012-12-11 03:30:57.000000000 +0000
3717 +++ linux-3.10.15-vs2.3.6.6/fs/jfs/jfs_dinode.h 2013-08-22 20:29:59.000000000 +0000
3718 @@ -161,9 +161,13 @@ struct dinode {
3720 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3721 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3722 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3724 -#define JFS_FL_USER_VISIBLE 0x03F80000
3725 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3726 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3727 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3729 +#define JFS_FL_USER_VISIBLE 0x07F80000
3730 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3731 #define JFS_FL_INHERIT 0x03C80000
3733 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3734 diff -NurpP --minimal linux-3.10.15/fs/jfs/jfs_filsys.h linux-3.10.15-vs2.3.6.6/fs/jfs/jfs_filsys.h
3735 --- linux-3.10.15/fs/jfs/jfs_filsys.h 2012-12-11 03:30:57.000000000 +0000
3736 +++ linux-3.10.15-vs2.3.6.6/fs/jfs/jfs_filsys.h 2013-08-22 20:29:59.000000000 +0000
3738 #define JFS_NAME_MAX 255
3739 #define JFS_PATH_MAX BPSIZE
3741 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
3744 * file system state (superblock state)
3745 diff -NurpP --minimal linux-3.10.15/fs/jfs/jfs_imap.c linux-3.10.15-vs2.3.6.6/fs/jfs/jfs_imap.c
3746 --- linux-3.10.15/fs/jfs/jfs_imap.c 2013-07-14 17:01:28.000000000 +0000
3747 +++ linux-3.10.15-vs2.3.6.6/fs/jfs/jfs_imap.c 2013-08-22 20:29:59.000000000 +0000
3749 #include <linux/pagemap.h>
3750 #include <linux/quotaops.h>
3751 #include <linux/slab.h>
3752 +#include <linux/vs_tag.h>
3754 #include "jfs_incore.h"
3755 #include "jfs_inode.h"
3756 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
3758 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3759 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
3763 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3764 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3765 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
3767 set_nlink(ip, le32_to_cpu(dip->di_nlink));
3769 - jfs_ip->saved_uid = make_kuid(&init_user_ns, le32_to_cpu(dip->di_uid));
3770 + kuid = make_kuid(&init_user_ns, le32_to_cpu(dip->di_uid));
3771 + kgid = make_kgid(&init_user_ns, le32_to_cpu(dip->di_gid));
3772 + ip->i_tag = INOTAG_KTAG(DX_TAG(ip), kuid, kgid, GLOBAL_ROOT_TAG);
3774 + jfs_ip->saved_uid = INOTAG_KUID(DX_TAG(ip), kuid, kgid);
3775 if (!uid_valid(sbi->uid))
3776 ip->i_uid = jfs_ip->saved_uid;
3778 ip->i_uid = sbi->uid;
3781 - jfs_ip->saved_gid = make_kgid(&init_user_ns, le32_to_cpu(dip->di_gid));
3782 + jfs_ip->saved_gid = INOTAG_KGID(DX_TAG(ip), kuid, kgid);
3783 if (!gid_valid(sbi->gid))
3784 ip->i_gid = jfs_ip->saved_gid;
3786 @@ -3150,16 +3157,14 @@ static void copy_to_dinode(struct dinode
3787 dip->di_size = cpu_to_le64(ip->i_size);
3788 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
3789 dip->di_nlink = cpu_to_le32(ip->i_nlink);
3790 - if (!uid_valid(sbi->uid))
3791 - dip->di_uid = cpu_to_le32(i_uid_read(ip));
3793 - dip->di_uid =cpu_to_le32(from_kuid(&init_user_ns,
3794 - jfs_ip->saved_uid));
3795 - if (!gid_valid(sbi->gid))
3796 - dip->di_gid = cpu_to_le32(i_gid_read(ip));
3798 - dip->di_gid = cpu_to_le32(from_kgid(&init_user_ns,
3799 - jfs_ip->saved_gid));
3800 + dip->di_uid = cpu_to_le32(from_kuid(&init_user_ns,
3801 + TAGINO_KUID(DX_TAG(ip),
3802 + !uid_valid(sbi->uid) ? ip->i_uid : jfs_ip->saved_uid,
3804 + dip->di_gid = cpu_to_le32(from_kgid(&init_user_ns,
3805 + TAGINO_KGID(DX_TAG(ip),
3806 + !gid_valid(sbi->gid) ? ip->i_gid : jfs_ip->saved_gid,
3808 jfs_get_inode_flags(jfs_ip);
3810 * mode2 is only needed for storing the higher order bits.
3811 diff -NurpP --minimal linux-3.10.15/fs/jfs/jfs_inode.c linux-3.10.15-vs2.3.6.6/fs/jfs/jfs_inode.c
3812 --- linux-3.10.15/fs/jfs/jfs_inode.c 2012-12-11 03:30:57.000000000 +0000
3813 +++ linux-3.10.15-vs2.3.6.6/fs/jfs/jfs_inode.c 2013-08-22 20:29:59.000000000 +0000
3816 #include <linux/fs.h>
3817 #include <linux/quotaops.h>
3818 +#include <linux/vs_tag.h>
3819 #include "jfs_incore.h"
3820 #include "jfs_inode.h"
3821 #include "jfs_filsys.h"
3822 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
3824 unsigned int flags = JFS_IP(inode)->mode2;
3826 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
3827 - S_NOATIME | S_DIRSYNC | S_SYNC);
3828 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3829 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3831 if (flags & JFS_IMMUTABLE_FL)
3832 inode->i_flags |= S_IMMUTABLE;
3833 + if (flags & JFS_IXUNLINK_FL)
3834 + inode->i_flags |= S_IXUNLINK;
3836 + if (flags & JFS_SYNC_FL)
3837 + inode->i_flags |= S_SYNC;
3838 if (flags & JFS_APPEND_FL)
3839 inode->i_flags |= S_APPEND;
3840 if (flags & JFS_NOATIME_FL)
3841 inode->i_flags |= S_NOATIME;
3842 if (flags & JFS_DIRSYNC_FL)
3843 inode->i_flags |= S_DIRSYNC;
3844 - if (flags & JFS_SYNC_FL)
3845 - inode->i_flags |= S_SYNC;
3847 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3849 + if (flags & JFS_BARRIER_FL)
3850 + inode->i_vflags |= V_BARRIER;
3851 + if (flags & JFS_COW_FL)
3852 + inode->i_vflags |= V_COW;
3855 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
3857 unsigned int flags = jfs_ip->vfs_inode.i_flags;
3858 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
3860 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
3861 + JFS_APPEND_FL | JFS_NOATIME_FL |
3862 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
3863 + JFS_BARRIER_FL | JFS_COW_FL);
3865 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
3866 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
3867 if (flags & S_IMMUTABLE)
3868 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
3869 + if (flags & S_IXUNLINK)
3870 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
3872 if (flags & S_APPEND)
3873 jfs_ip->mode2 |= JFS_APPEND_FL;
3874 if (flags & S_NOATIME)
3875 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
3876 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
3878 jfs_ip->mode2 |= JFS_SYNC_FL;
3880 + if (vflags & V_BARRIER)
3881 + jfs_ip->mode2 |= JFS_BARRIER_FL;
3882 + if (vflags & V_COW)
3883 + jfs_ip->mode2 |= JFS_COW_FL;
3887 diff -NurpP --minimal linux-3.10.15/fs/jfs/jfs_inode.h linux-3.10.15-vs2.3.6.6/fs/jfs/jfs_inode.h
3888 --- linux-3.10.15/fs/jfs/jfs_inode.h 2012-12-11 03:30:57.000000000 +0000
3889 +++ linux-3.10.15-vs2.3.6.6/fs/jfs/jfs_inode.h 2013-08-22 20:29:59.000000000 +0000
3890 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
3891 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
3892 int fh_len, int fh_type);
3893 extern void jfs_set_inode_flags(struct inode *);
3894 +extern int jfs_sync_flags(struct inode *, int, int);
3895 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
3896 extern int jfs_setattr(struct dentry *, struct iattr *);
3898 diff -NurpP --minimal linux-3.10.15/fs/jfs/namei.c linux-3.10.15-vs2.3.6.6/fs/jfs/namei.c
3899 --- linux-3.10.15/fs/jfs/namei.c 2012-12-11 03:30:57.000000000 +0000
3900 +++ linux-3.10.15-vs2.3.6.6/fs/jfs/namei.c 2013-08-22 20:29:59.000000000 +0000
3902 #include <linux/ctype.h>
3903 #include <linux/quotaops.h>
3904 #include <linux/exportfs.h>
3905 +#include <linux/vs_tag.h>
3906 #include "jfs_incore.h"
3907 #include "jfs_superblock.h"
3908 #include "jfs_inode.h"
3909 @@ -1461,6 +1462,7 @@ static struct dentry *jfs_lookup(struct
3910 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
3913 + dx_propagate_tag(nd, ip);
3914 return d_splice_alias(ip, dentry);
3917 @@ -1525,6 +1527,7 @@ const struct inode_operations jfs_dir_in
3918 #ifdef CONFIG_JFS_POSIX_ACL
3919 .get_acl = jfs_get_acl,
3921 + .sync_flags = jfs_sync_flags,
3924 const struct file_operations jfs_dir_operations = {
3925 diff -NurpP --minimal linux-3.10.15/fs/jfs/super.c linux-3.10.15-vs2.3.6.6/fs/jfs/super.c
3926 --- linux-3.10.15/fs/jfs/super.c 2013-07-14 17:01:28.000000000 +0000
3927 +++ linux-3.10.15-vs2.3.6.6/fs/jfs/super.c 2013-08-22 20:29:59.000000000 +0000
3928 @@ -199,7 +199,8 @@ enum {
3929 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
3930 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
3931 Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
3932 - Opt_discard, Opt_nodiscard, Opt_discard_minblk
3933 + Opt_discard, Opt_nodiscard, Opt_discard_minblk,
3934 + Opt_tag, Opt_notag, Opt_tagid
3937 static const match_table_t tokens = {
3938 @@ -209,6 +210,10 @@ static const match_table_t tokens = {
3939 {Opt_resize, "resize=%u"},
3940 {Opt_resize_nosize, "resize"},
3941 {Opt_errors, "errors=%s"},
3943 + {Opt_notag, "notag"},
3944 + {Opt_tagid, "tagid=%u"},
3945 + {Opt_tag, "tagxid"},
3946 {Opt_ignore, "noquota"},
3947 {Opt_ignore, "quota"},
3948 {Opt_usrquota, "usrquota"},
3949 @@ -385,7 +390,20 @@ static int parse_options(char *options,
3954 +#ifndef CONFIG_TAGGING_NONE
3956 + *flag |= JFS_TAGGED;
3959 + *flag &= JFS_TAGGED;
3962 +#ifdef CONFIG_PROPAGATE
3965 + *flag |= JFS_TAGGED;
3969 printk("jfs: Unrecognized mount option \"%s\" "
3970 " or missing value\n", p);
3971 @@ -417,6 +435,12 @@ static int jfs_remount(struct super_bloc
3975 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
3976 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
3982 if (sb->s_flags & MS_RDONLY) {
3983 pr_err("JFS: resize requires volume" \
3984 @@ -502,6 +526,9 @@ static int jfs_fill_super(struct super_b
3985 #ifdef CONFIG_JFS_POSIX_ACL
3986 sb->s_flags |= MS_POSIXACL;
3988 + /* map mount option tagxid */
3989 + if (sbi->flag & JFS_TAGGED)
3990 + sb->s_flags |= MS_TAGGED;
3993 pr_err("resize option for remount only\n");
3994 diff -NurpP --minimal linux-3.10.15/fs/libfs.c linux-3.10.15-vs2.3.6.6/fs/libfs.c
3995 --- linux-3.10.15/fs/libfs.c 2013-02-19 13:58:48.000000000 +0000
3996 +++ linux-3.10.15-vs2.3.6.6/fs/libfs.c 2013-08-22 20:29:59.000000000 +0000
3997 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
3998 * both impossible due to the lock on directory.
4001 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4002 +static inline int do_dcache_readdir_filter(struct file *filp,
4003 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4005 struct dentry *dentry = filp->f_path.dentry;
4006 struct dentry *cursor = filp->private_data;
4007 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
4008 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4009 struct dentry *next;
4010 next = list_entry(p, struct dentry, d_u.d_child);
4011 + if (filter && !filter(next))
4013 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4014 if (!simple_positive(next)) {
4015 spin_unlock(&next->d_lock);
4016 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
4020 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4022 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4025 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4026 + int (*filter)(struct dentry *))
4028 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4031 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4034 @@ -981,6 +995,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4035 EXPORT_SYMBOL(dcache_dir_lseek);
4036 EXPORT_SYMBOL(dcache_dir_open);
4037 EXPORT_SYMBOL(dcache_readdir);
4038 +EXPORT_SYMBOL(dcache_readdir_filter);
4039 EXPORT_SYMBOL(generic_read_dir);
4040 EXPORT_SYMBOL(mount_pseudo);
4041 EXPORT_SYMBOL(simple_write_begin);
4042 diff -NurpP --minimal linux-3.10.15/fs/locks.c linux-3.10.15-vs2.3.6.6/fs/locks.c
4043 --- linux-3.10.15/fs/locks.c 2013-05-31 13:45:24.000000000 +0000
4044 +++ linux-3.10.15-vs2.3.6.6/fs/locks.c 2013-08-22 20:29:59.000000000 +0000
4046 #include <linux/time.h>
4047 #include <linux/rcupdate.h>
4048 #include <linux/pid_namespace.h>
4049 +#include <linux/vs_base.h>
4050 +#include <linux/vs_limit.h>
4052 #include <asm/uaccess.h>
4054 @@ -184,11 +186,17 @@ static void locks_init_lock_heads(struct
4055 /* Allocate an empty lock structure. */
4056 struct file_lock *locks_alloc_lock(void)
4058 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4059 + struct file_lock *fl;
4062 - locks_init_lock_heads(fl);
4063 + if (!vx_locks_avail(1))
4066 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4069 + locks_init_lock_heads(fl);
4074 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4075 @@ -212,6 +220,7 @@ void locks_free_lock(struct file_lock *f
4076 BUG_ON(!list_empty(&fl->fl_block));
4077 BUG_ON(!list_empty(&fl->fl_link));
4080 locks_release_private(fl);
4081 kmem_cache_free(filelock_cache, fl);
4083 @@ -221,6 +230,7 @@ void locks_init_lock(struct file_lock *f
4085 memset(fl, 0, sizeof(struct file_lock));
4086 locks_init_lock_heads(fl);
4090 EXPORT_SYMBOL(locks_init_lock);
4091 @@ -261,6 +271,7 @@ void locks_copy_lock(struct file_lock *n
4092 new->fl_file = fl->fl_file;
4093 new->fl_ops = fl->fl_ops;
4094 new->fl_lmops = fl->fl_lmops;
4095 + new->fl_xid = fl->fl_xid;
4097 locks_copy_private(new, fl);
4099 @@ -299,6 +310,11 @@ static int flock_make_lock(struct file *
4100 fl->fl_flags = FL_FLOCK;
4102 fl->fl_end = OFFSET_MAX;
4104 + vxd_assert(filp->f_xid == vx_current_xid(),
4105 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4106 + fl->fl_xid = filp->f_xid;
4111 @@ -438,6 +454,7 @@ static int lease_init(struct file *filp,
4113 fl->fl_owner = current->files;
4114 fl->fl_pid = current->tgid;
4115 + fl->fl_xid = vx_current_xid();
4118 fl->fl_flags = FL_LEASE;
4119 @@ -457,6 +474,11 @@ static struct file_lock *lease_alloc(str
4121 return ERR_PTR(error);
4123 + fl->fl_xid = vx_current_xid();
4125 + vxd_assert(filp->f_xid == fl->fl_xid,
4126 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4128 error = lease_init(filp, type, fl);
4130 locks_free_lock(fl);
4131 @@ -753,6 +775,7 @@ static int flock_lock_file(struct file *
4135 + new_fl->fl_xid = -1;
4137 for_each_lock(inode, before) {
4138 struct file_lock *fl = *before;
4139 @@ -773,6 +796,7 @@ find_conflict:
4141 locks_copy_lock(new_fl, request);
4142 locks_insert_lock(before, new_fl);
4143 + vx_locks_inc(new_fl);
4147 @@ -783,7 +807,8 @@ out:
4151 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4152 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4153 + struct file_lock *conflock, vxid_t xid)
4155 struct file_lock *fl;
4156 struct file_lock *new_fl = NULL;
4157 @@ -793,6 +818,8 @@ static int __posix_lock_file(struct inod
4158 struct file_lock **before;
4159 int error, added = 0;
4161 + vxd_assert(xid == vx_current_xid(),
4162 + "xid(%d) == current(%d)", xid, vx_current_xid());
4164 * We may need two file_lock structures for this operation,
4165 * so we get them in advance to avoid races.
4166 @@ -803,7 +830,11 @@ static int __posix_lock_file(struct inod
4167 (request->fl_type != F_UNLCK ||
4168 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4169 new_fl = locks_alloc_lock();
4170 + new_fl->fl_xid = xid;
4171 + vx_locks_inc(new_fl);
4172 new_fl2 = locks_alloc_lock();
4173 + new_fl2->fl_xid = xid;
4174 + vx_locks_inc(new_fl2);
4178 @@ -1002,7 +1033,8 @@ static int __posix_lock_file(struct inod
4179 int posix_lock_file(struct file *filp, struct file_lock *fl,
4180 struct file_lock *conflock)
4182 - return __posix_lock_file(file_inode(filp), fl, conflock);
4183 + return __posix_lock_file(file_inode(filp),
4184 + fl, conflock, filp->f_xid);
4186 EXPORT_SYMBOL(posix_lock_file);
4188 @@ -1092,7 +1124,7 @@ int locks_mandatory_area(int read_write,
4189 fl.fl_end = offset + count - 1;
4192 - error = __posix_lock_file(inode, &fl, NULL);
4193 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4194 if (error != FILE_LOCK_DEFERRED)
4196 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4197 @@ -1397,6 +1429,7 @@ int generic_add_lease(struct file *filp,
4200 locks_insert_lock(before, lease);
4201 + vx_locks_inc(lease);
4205 @@ -1836,6 +1869,11 @@ int fcntl_setlk(unsigned int fd, struct
4206 if (file_lock == NULL)
4209 + vxd_assert(filp->f_xid == vx_current_xid(),
4210 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4211 + file_lock->fl_xid = filp->f_xid;
4212 + vx_locks_inc(file_lock);
4215 * This might block, so we do it before checking the inode.
4217 @@ -1954,6 +1992,11 @@ int fcntl_setlk64(unsigned int fd, struc
4218 if (file_lock == NULL)
4221 + vxd_assert(filp->f_xid == vx_current_xid(),
4222 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4223 + file_lock->fl_xid = filp->f_xid;
4224 + vx_locks_inc(file_lock);
4227 * This might block, so we do it before checking the inode.
4229 @@ -2219,8 +2262,11 @@ static int locks_show(struct seq_file *f
4231 lock_get_status(f, fl, *((loff_t *)f->private), "");
4233 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4234 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4235 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4237 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4242 diff -NurpP --minimal linux-3.10.15/fs/mount.h linux-3.10.15-vs2.3.6.6/fs/mount.h
4243 --- linux-3.10.15/fs/mount.h 2013-07-14 17:01:28.000000000 +0000
4244 +++ linux-3.10.15-vs2.3.6.6/fs/mount.h 2013-08-22 20:29:59.000000000 +0000
4245 @@ -56,6 +56,7 @@ struct mount {
4246 int mnt_expiry_mark; /* true if marked for expiry */
4249 + vtag_t mnt_tag; /* tagging used for vfsmount */
4252 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
4253 diff -NurpP --minimal linux-3.10.15/fs/namei.c linux-3.10.15-vs2.3.6.6/fs/namei.c
4254 --- linux-3.10.15/fs/namei.c 2013-07-14 17:01:28.000000000 +0000
4255 +++ linux-3.10.15-vs2.3.6.6/fs/namei.c 2013-08-22 23:36:09.000000000 +0000
4257 #include <linux/device_cgroup.h>
4258 #include <linux/fs_struct.h>
4259 #include <linux/posix_acl.h>
4260 +#include <linux/proc_fs.h>
4261 +#include <linux/magic.h>
4262 +#include <linux/vserver/inode.h>
4263 +#include <linux/vs_base.h>
4264 +#include <linux/vs_tag.h>
4265 +#include <linux/vs_cowbl.h>
4266 +#include <linux/vs_device.h>
4267 +#include <linux/vs_context.h>
4268 +#include <linux/pid_namespace.h>
4269 #include <asm/uaccess.h>
4271 #include "internal.h"
4272 +#include "proc/internal.h"
4275 /* [Feb-1997 T. Schoebel-Theuer]
4276 @@ -266,6 +276,89 @@ static int check_acl(struct inode *inode
4280 +static inline int dx_barrier(const struct inode *inode)
4282 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4283 + vxwprintk_task(1, "did hit the barrier.");
4289 +static int __dx_permission(const struct inode *inode, int mask)
4291 + if (dx_barrier(inode))
4294 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4295 + /* devpts is xid tagged */
4296 + if (S_ISDIR(inode->i_mode) ||
4297 + vx_check((vxid_t)i_tag_read(inode), VS_IDENT | VS_WATCH_P))
4300 + /* just pretend we didn't find anything */
4303 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4304 + struct proc_dir_entry *de = PDE(inode);
4306 + if (de && !vx_hide_check(0, de->vx_flags))
4309 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4311 + struct task_struct *tsk;
4313 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4314 + vx_flags(VXF_STATE_SETUP, 0))
4317 + pid = PROC_I(inode)->pid;
4322 + tsk = pid_task(pid, PIDTYPE_PID);
4323 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4324 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4326 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4327 + rcu_read_unlock();
4330 + rcu_read_unlock();
4333 + /* FIXME: Should we block some entries here? */
4338 + if (dx_notagcheck(inode->i_sb) ||
4339 + dx_check((vxid_t)i_tag_read(inode),
4340 + DX_HOSTID | DX_ADMIN | DX_WATCH | DX_IDENT))
4348 +int dx_permission(const struct inode *inode, int mask)
4350 + int ret = __dx_permission(inode, mask);
4351 + if (unlikely(ret)) {
4352 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4353 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4356 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4357 + mask, inode->i_sb->s_id, inode,
4358 + i_tag_read(inode), inode->i_ino);
4364 * This does the basic permission checking
4366 @@ -388,10 +481,14 @@ int __inode_permission(struct inode *ino
4368 * Nobody gets write access to an immutable file.
4370 - if (IS_IMMUTABLE(inode))
4371 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4375 + retval = dx_permission(inode, mask);
4379 retval = do_inode_permission(inode, mask);
4382 @@ -1238,7 +1335,8 @@ static void follow_dotdot(struct nameida
4384 if (nd->path.dentry == nd->root.dentry &&
4385 nd->path.mnt == nd->root.mnt) {
4387 + /* for sane '/' avoid follow_mount() */
4390 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4391 /* rare case of legitimate dget_parent()... */
4392 @@ -1383,6 +1481,9 @@ static int lookup_fast(struct nameidata
4397 + /* FIXME: check dx permission */
4400 path->dentry = dentry;
4401 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4402 @@ -1413,6 +1514,8 @@ unlazy:
4406 + /* FIXME: check dx permission */
4409 path->dentry = dentry;
4410 err = follow_managed(path, nd->flags);
4411 @@ -2237,7 +2340,7 @@ static int may_delete(struct inode *dir,
4414 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4415 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4416 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4419 if (!S_ISDIR(victim->d_inode->i_mode))
4420 @@ -2316,19 +2419,25 @@ int vfs_create(struct inode *dir, struct
4423 int error = may_create(dir, dentry);
4426 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
4430 if (!dir->i_op->create)
4431 return -EACCES; /* shouldn't it be ENOSYS? */
4434 error = security_inode_create(dir, dentry, mode);
4437 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
4440 error = dir->i_op->create(dir, dentry, mode, want_excl);
4442 fsnotify_create(dir, dentry);
4444 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
4448 @@ -2363,6 +2472,15 @@ static int may_open(struct path *path, i
4452 +#ifdef CONFIG_VSERVER_COWBL
4453 + if (IS_COW(inode) &&
4454 + ((flag & O_ACCMODE) != O_RDONLY)) {
4455 + if (IS_COW_LINK(inode))
4457 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4458 + mark_inode_dirty(inode);
4461 error = inode_permission(inode, acc_mode);
4464 @@ -2865,6 +2983,16 @@ finish_open:
4466 finish_open_created:
4467 error = may_open(&nd->path, acc_mode, open_flag);
4468 +#ifdef CONFIG_VSERVER_COWBL
4469 + if (error == -EMLINK) {
4470 + struct dentry *dentry;
4471 + dentry = cow_break_link(name->name);
4472 + if (IS_ERR(dentry))
4473 + error = PTR_ERR(dentry);
4480 file->f_path.mnt = nd->path.mnt;
4481 @@ -2929,6 +3057,7 @@ static struct file *path_openat(int dfd,
4486 file = get_empty_filp();
4489 @@ -2965,6 +3094,16 @@ static struct file *path_openat(int dfd,
4490 error = do_last(nd, &path, file, op, &opened, pathname);
4491 put_link(nd, &link, cookie);
4494 +#ifdef CONFIG_VSERVER_COWBL
4495 + if (error == -EMLINK) {
4496 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4497 + path_put(&nd->root);
4504 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4505 path_put(&nd->root);
4506 @@ -3079,6 +3218,11 @@ struct dentry *kern_path_create(int dfd,
4510 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
4511 + path->dentry, path->dentry->d_name.len,
4512 + path->dentry->d_name.name, dentry,
4513 + dentry->d_name.len, dentry->d_name.name,
4514 + path->dentry->d_inode);
4518 @@ -3573,7 +3717,7 @@ int vfs_link(struct dentry *old_dentry,
4520 * A link to an append-only or immutable file cannot be created.
4522 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4523 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4525 if (!dir->i_op->link)
4527 @@ -3976,6 +4120,287 @@ int vfs_follow_link(struct nameidata *nd
4528 return __vfs_follow_link(nd, link);
4532 +#ifdef CONFIG_VSERVER_COWBL
4535 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4540 + return do_splice_direct(in, &ppos, out, &opos, len, 0);
4543 +struct dentry *cow_break_link(const char *pathname)
4545 + int ret, mode, pathlen, redo = 0, drop = 1;
4546 + struct nameidata old_nd, dir_nd;
4547 + struct path dir_path, *old_path, *new_path;
4548 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4549 + struct file *old_file;
4550 + struct file *new_file;
4551 + char *to, *path, pad='\251';
4554 + vxdprintk(VXD_CBIT(misc, 1),
4555 + "cow_break_link(" VS_Q("%s") ")", pathname);
4557 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4562 + /* old_nd.path will have refs to dentry and mnt */
4563 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4564 + vxdprintk(VXD_CBIT(misc, 2),
4565 + "do_path_lookup(old): %d", ret);
4567 + goto out_free_path;
4569 + /* dentry/mnt refs handed over to old_path */
4570 + old_path = &old_nd.path;
4571 + /* no explicit reference for old_dentry here */
4572 + old_dentry = old_path->dentry;
4574 + mode = old_dentry->d_inode->i_mode;
4575 + to = d_path(old_path, path, PATH_MAX-2);
4576 + pathlen = strlen(to);
4577 + vxdprintk(VXD_CBIT(misc, 2),
4578 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4580 + old_dentry->d_name.len, old_dentry->d_name.name,
4581 + old_dentry->d_name.len);
4583 + to[pathlen + 1] = 0;
4585 + new_dentry = NULL;
4586 + to[pathlen] = pad--;
4588 + if (pad <= '\240')
4591 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4593 + /* dir_nd.path will have refs to dentry and mnt */
4594 + ret = do_path_lookup(AT_FDCWD, to,
4595 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4596 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4600 + /* this puppy downs the dir inode mutex if successful.
4601 + dir_path will hold refs to dentry and mnt and
4602 + we'll have write access to the mnt */
4603 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
4604 + if (!new_dentry || IS_ERR(new_dentry)) {
4605 + path_put(&dir_nd.path);
4606 + vxdprintk(VXD_CBIT(misc, 2),
4607 + "kern_path_create(new) failed with %ld",
4608 + PTR_ERR(new_dentry));
4611 + vxdprintk(VXD_CBIT(misc, 2),
4612 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
4614 + new_dentry->d_name.len, new_dentry->d_name.name,
4615 + new_dentry->d_name.len);
4617 + /* take a reference on new_dentry */
4620 + /* dentry/mnt refs handed over to new_path */
4621 + new_path = &dir_path;
4623 + /* dentry for old/new dir */
4624 + dir = dir_nd.path.dentry;
4626 + /* give up reference on dir */
4627 + dput(new_path->dentry);
4629 + /* new_dentry already has a reference */
4630 + new_path->dentry = new_dentry;
4632 + ret = vfs_create(dir->d_inode, new_dentry, mode, 1);
4633 + vxdprintk(VXD_CBIT(misc, 2),
4634 + "vfs_create(new): %d", ret);
4635 + if (ret == -EEXIST) {
4636 + path_put(&dir_nd.path);
4637 + mutex_unlock(&dir->d_inode->i_mutex);
4638 + mnt_drop_write(new_path->mnt);
4639 + path_put(new_path);
4640 + new_dentry = NULL;
4644 + goto out_unlock_new;
4646 + /* drop out early, ret passes ENOENT */
4648 + if ((redo = d_unhashed(old_dentry)))
4649 + goto out_unlock_new;
4651 + /* doesn't change refs for old_path */
4652 + old_file = dentry_open(old_path, O_RDONLY, current_cred());
4653 + vxdprintk(VXD_CBIT(misc, 2),
4654 + "dentry_open(old): %p", old_file);
4655 + if (IS_ERR(old_file)) {
4656 + ret = PTR_ERR(old_file);
4657 + goto out_unlock_new;
4660 + /* doesn't change refs for new_path */
4661 + new_file = dentry_open(new_path, O_WRONLY, current_cred());
4662 + vxdprintk(VXD_CBIT(misc, 2),
4663 + "dentry_open(new): %p", new_file);
4664 + if (IS_ERR(new_file)) {
4665 + ret = PTR_ERR(new_file);
4666 + goto out_fput_old;
4669 + /* unlock the inode mutex from kern_path_create() */
4670 + mutex_unlock(&dir->d_inode->i_mutex);
4672 + /* drop write access to mnt */
4673 + mnt_drop_write(new_path->mnt);
4677 + size = i_size_read(old_file->f_dentry->d_inode);
4678 + ret = do_cow_splice(old_file, new_file, size);
4679 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4681 + goto out_fput_both;
4682 + } else if (ret < size) {
4684 + goto out_fput_both;
4686 + struct inode *old_inode = old_dentry->d_inode;
4687 + struct inode *new_inode = new_dentry->d_inode;
4688 + struct iattr attr = {
4689 + .ia_uid = old_inode->i_uid,
4690 + .ia_gid = old_inode->i_gid,
4691 + .ia_valid = ATTR_UID | ATTR_GID
4694 + setattr_copy(new_inode, &attr);
4695 + mark_inode_dirty(new_inode);
4698 + /* lock rename mutex */
4699 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4701 + /* drop out late */
4703 + if ((redo = d_unhashed(old_dentry)))
4706 + vxdprintk(VXD_CBIT(misc, 2),
4707 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4708 + new_dentry->d_name.len, new_dentry->d_name.name,
4709 + new_dentry->d_name.len,
4710 + old_dentry->d_name.len, old_dentry->d_name.name,
4711 + old_dentry->d_name.len);
4712 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4713 + old_dentry->d_parent->d_inode, old_dentry);
4714 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4717 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4720 + vxdprintk(VXD_CBIT(misc, 3),
4721 + "fput(new_file=%p[#%ld])", new_file,
4722 + atomic_long_read(&new_file->f_count));
4726 + vxdprintk(VXD_CBIT(misc, 3),
4727 + "fput(old_file=%p[#%ld])", old_file,
4728 + atomic_long_read(&old_file->f_count));
4732 + /* drop references from dir_nd.path */
4733 + path_put(&dir_nd.path);
4736 + /* unlock the inode mutex from kern_path_create() */
4737 + mutex_unlock(&dir->d_inode->i_mutex);
4739 + /* drop write access to mnt */
4740 + mnt_drop_write(new_path->mnt);
4746 + /* error path cleanup */
4747 + vfs_unlink(dir->d_inode, new_dentry);
4751 + goto out_rel_both;
4753 + /* lookup dentry once again
4754 + old_nd.path will be freed as old_path in out_rel_old */
4755 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4757 + goto out_rel_both;
4759 + /* drop reference on new_dentry */
4761 + new_dentry = old_path->dentry;
4763 + vxdprintk(VXD_CBIT(misc, 2),
4764 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4766 + new_dentry->d_name.len, new_dentry->d_name.name,
4767 + new_dentry->d_name.len);
4771 + path_put(new_path);
4773 + path_put(old_path);
4779 + new_dentry = ERR_PTR(ret);
4781 + vxdprintk(VXD_CBIT(misc, 3),
4782 + "cow_break_link returning with %p", new_dentry);
4783 + return new_dentry;
4788 +int vx_info_mnt_namespace(struct mnt_namespace *ns, char *buffer)
4791 + struct vfsmount *vmnt;
4792 + char *pstr, *root;
4795 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
4799 + vmnt = &ns->root->mnt;
4801 + path.dentry = vmnt->mnt_root;
4802 + root = d_path(&path, pstr, PATH_MAX - 2);
4803 + length = sprintf(buffer + length,
4804 + "Namespace:\t%p [#%u]\n"
4805 + "RootPath:\t%s\n",
4806 + ns, atomic_read(&ns->count),
4812 /* get the link contents into pagecache */
4813 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4815 @@ -4099,3 +4524,4 @@ EXPORT_SYMBOL(vfs_symlink);
4816 EXPORT_SYMBOL(vfs_unlink);
4817 EXPORT_SYMBOL(dentry_unhash);
4818 EXPORT_SYMBOL(generic_readlink);
4819 +EXPORT_SYMBOL(vx_info_mnt_namespace);
4820 diff -NurpP --minimal linux-3.10.15/fs/namespace.c linux-3.10.15-vs2.3.6.6/fs/namespace.c
4821 --- linux-3.10.15/fs/namespace.c 2013-10-09 17:35:22.000000000 +0000
4822 +++ linux-3.10.15-vs2.3.6.6/fs/namespace.c 2013-10-09 17:37:22.000000000 +0000
4824 #include <linux/uaccess.h>
4825 #include <linux/proc_ns.h>
4826 #include <linux/magic.h>
4827 +#include <linux/vs_base.h>
4828 +#include <linux/vs_context.h>
4829 +#include <linux/vs_tag.h>
4830 +#include <linux/vserver/space.h>
4831 +#include <linux/vserver/global.h>
4833 #include "internal.h"
4835 @@ -780,6 +785,10 @@ vfs_kern_mount(struct file_system_type *
4837 return ERR_PTR(-ENODEV);
4839 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
4840 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
4841 + return ERR_PTR(-EPERM);
4843 mnt = alloc_vfsmnt(name);
4845 return ERR_PTR(-ENOMEM);
4846 @@ -836,6 +845,7 @@ static struct mount *clone_mnt(struct mo
4847 mnt->mnt.mnt_root = dget(root);
4848 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
4849 mnt->mnt_parent = mnt;
4850 + mnt->mnt_tag = old->mnt_tag;
4851 br_write_lock(&vfsmount_lock);
4852 list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
4853 br_write_unlock(&vfsmount_lock);
4854 @@ -1685,6 +1695,7 @@ static int do_change_type(struct path *p
4858 + // mnt->mnt_flags = mnt_flags;
4860 br_write_lock(&vfsmount_lock);
4861 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
4862 @@ -1700,12 +1711,14 @@ static int do_change_type(struct path *p
4863 * do loopback mount.
4865 static int do_loopback(struct path *path, const char *old_name,
4867 + vtag_t tag, unsigned long flags, int mnt_flags)
4869 struct path old_path;
4870 struct mount *mnt = NULL, *old, *parent;
4871 struct mountpoint *mp;
4872 + int recurse = flags & MS_REC;
4875 if (!old_name || !*old_name)
4877 err = kern_path(old_name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &old_path);
4878 @@ -1780,7 +1793,7 @@ static int change_mount_flags(struct vfs
4879 * on it - tough luck.
4881 static int do_remount(struct path *path, int flags, int mnt_flags,
4883 + void *data, vxid_t xid)
4886 struct super_block *sb = path->mnt->mnt_sb;
4887 @@ -2264,6 +2277,7 @@ long do_mount(const char *dev_name, cons
4894 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
4895 @@ -2293,6 +2307,12 @@ long do_mount(const char *dev_name, cons
4896 if (!(flags & MS_NOATIME))
4897 mnt_flags |= MNT_RELATIME;
4899 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
4900 + /* FIXME: bind and re-mounts get the tag flag? */
4901 + if (flags & (MS_BIND|MS_REMOUNT))
4902 + flags |= MS_TAGID;
4905 /* Separate the per-mountpoint flags */
4906 if (flags & MS_NOSUID)
4907 mnt_flags |= MNT_NOSUID;
4908 @@ -2309,15 +2329,17 @@ long do_mount(const char *dev_name, cons
4909 if (flags & MS_RDONLY)
4910 mnt_flags |= MNT_READONLY;
4912 + if (!vx_capable(CAP_SYS_ADMIN, VXC_DEV_MOUNT))
4913 + mnt_flags |= MNT_NODEV;
4914 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
4915 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
4918 if (flags & MS_REMOUNT)
4919 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
4922 else if (flags & MS_BIND)
4923 - retval = do_loopback(&path, dev_name, flags & MS_REC);
4924 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
4925 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
4926 retval = do_change_type(&path, flags);
4927 else if (flags & MS_MOVE)
4928 @@ -2426,6 +2448,7 @@ static struct mnt_namespace *dup_mnt_ns(
4929 q = next_mnt(q, new);
4932 + atomic_inc(&vs_global_mnt_ns);
4936 @@ -2624,9 +2647,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
4937 new_mnt = real_mount(new.mnt);
4938 root_mnt = real_mount(root.mnt);
4939 old_mnt = real_mount(old.mnt);
4940 - if (IS_MNT_SHARED(old_mnt) ||
4941 + if ((IS_MNT_SHARED(old_mnt) ||
4942 IS_MNT_SHARED(new_mnt->mnt_parent) ||
4943 - IS_MNT_SHARED(root_mnt->mnt_parent))
4944 + IS_MNT_SHARED(root_mnt->mnt_parent)) &&
4945 + !vx_flags(VXF_STATE_SETUP, 0))
4947 if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
4949 @@ -2752,6 +2776,7 @@ void put_mnt_ns(struct mnt_namespace *ns
4950 umount_tree(ns->root, 0);
4951 br_write_unlock(&vfsmount_lock);
4953 + atomic_dec(&vs_global_mnt_ns);
4957 diff -NurpP --minimal linux-3.10.15/fs/nfs/client.c linux-3.10.15-vs2.3.6.6/fs/nfs/client.c
4958 --- linux-3.10.15/fs/nfs/client.c 2013-07-14 17:01:28.000000000 +0000
4959 +++ linux-3.10.15-vs2.3.6.6/fs/nfs/client.c 2013-08-22 20:29:59.000000000 +0000
4960 @@ -684,6 +684,9 @@ int nfs_init_server_rpcclient(struct nfs
4961 if (server->flags & NFS_MOUNT_SOFT)
4962 server->client->cl_softrtry = 1;
4964 + server->client->cl_tag = 0;
4965 + if (server->flags & NFS_MOUNT_TAGGED)
4966 + server->client->cl_tag = 1;
4969 EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient);
4970 @@ -863,6 +866,10 @@ static void nfs_server_set_fsinfo(struct
4971 server->acdirmin = server->acdirmax = 0;
4974 + /* FIXME: needs fsinfo
4975 + if (server->flags & NFS_MOUNT_TAGGED)
4976 + sb->s_flags |= MS_TAGGED; */
4978 server->maxfilesize = fsinfo->maxfilesize;
4980 server->time_delta = fsinfo->time_delta;
4981 diff -NurpP --minimal linux-3.10.15/fs/nfs/dir.c linux-3.10.15-vs2.3.6.6/fs/nfs/dir.c
4982 --- linux-3.10.15/fs/nfs/dir.c 2013-07-14 17:01:28.000000000 +0000
4983 +++ linux-3.10.15-vs2.3.6.6/fs/nfs/dir.c 2013-08-22 20:29:59.000000000 +0000
4985 #include <linux/sched.h>
4986 #include <linux/kmemleak.h>
4987 #include <linux/xattr.h>
4988 +#include <linux/vs_tag.h>
4990 #include "delegation.h"
4992 @@ -1300,6 +1301,7 @@ struct dentry *nfs_lookup(struct inode *
4993 /* Success: notify readdir to use READDIRPLUS */
4994 nfs_advise_use_readdirplus(dir);
4996 + dx_propagate_tag(nd, inode);
4998 res = d_materialise_unique(dentry, inode);
5000 diff -NurpP --minimal linux-3.10.15/fs/nfs/inode.c linux-3.10.15-vs2.3.6.6/fs/nfs/inode.c
5001 --- linux-3.10.15/fs/nfs/inode.c 2013-07-14 17:01:28.000000000 +0000
5002 +++ linux-3.10.15-vs2.3.6.6/fs/nfs/inode.c 2013-08-22 20:29:59.000000000 +0000
5004 #include <linux/compat.h>
5005 #include <linux/freezer.h>
5006 #include <linux/crc32.h>
5007 +#include <linux/vs_tag.h>
5009 #include <asm/uaccess.h>
5011 @@ -290,6 +291,8 @@ nfs_fhget(struct super_block *sb, struct
5012 if (inode->i_state & I_NEW) {
5013 struct nfs_inode *nfsi = NFS_I(inode);
5014 unsigned long now = jiffies;
5018 /* We set i_ino for the few things that still rely on it,
5019 * such as stat(2) */
5020 @@ -334,8 +337,8 @@ nfs_fhget(struct super_block *sb, struct
5021 inode->i_version = 0;
5024 - inode->i_uid = make_kuid(&init_user_ns, -2);
5025 - inode->i_gid = make_kgid(&init_user_ns, -2);
5026 + kuid = make_kuid(&init_user_ns, -2);
5027 + kgid = make_kgid(&init_user_ns, -2);
5028 inode->i_blocks = 0;
5029 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5031 @@ -369,11 +372,11 @@ nfs_fhget(struct super_block *sb, struct
5032 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5033 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5034 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5035 - inode->i_uid = fattr->uid;
5036 + kuid = fattr->uid;
5037 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5038 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5039 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5040 - inode->i_gid = fattr->gid;
5041 + kgid = fattr->gid;
5042 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5043 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5044 if (fattr->valid & NFS_ATTR_FATTR_BLOCKS_USED)
5045 @@ -384,6 +387,11 @@ nfs_fhget(struct super_block *sb, struct
5047 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5049 + inode->i_uid = INOTAG_KUID(DX_TAG(inode), kuid, kgid);
5050 + inode->i_gid = INOTAG_KGID(DX_TAG(inode), kuid, kgid);
5051 + inode->i_tag = INOTAG_KTAG(DX_TAG(inode), kuid, kgid, GLOBAL_ROOT_TAG);
5052 + /* maybe fattr->xid someday */
5054 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5055 nfsi->attrtimeo_timestamp = now;
5056 nfsi->access_cache = RB_ROOT;
5057 @@ -505,6 +513,8 @@ void nfs_setattr_update_inode(struct ino
5058 inode->i_uid = attr->ia_uid;
5059 if ((attr->ia_valid & ATTR_GID) != 0)
5060 inode->i_gid = attr->ia_gid;
5061 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5062 + inode->i_tag = attr->ia_tag;
5063 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5064 spin_unlock(&inode->i_lock);
5066 @@ -982,7 +992,9 @@ static int nfs_check_inode_attributes(st
5067 struct nfs_inode *nfsi = NFS_I(inode);
5068 loff_t cur_size, new_isize;
5069 unsigned long invalid = 0;
5075 if (nfs_have_delegated_attributes(inode))
5077 @@ -1007,13 +1019,18 @@ static int nfs_check_inode_attributes(st
5078 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5081 + kuid = INOTAG_KUID(DX_TAG(inode), fattr->uid, fattr->gid);
5082 + kgid = INOTAG_KGID(DX_TAG(inode), fattr->uid, fattr->gid);
5083 + ktag = INOTAG_KTAG(DX_TAG(inode), fattr->uid, fattr->gid, GLOBAL_ROOT_TAG);
5085 /* Have any file permissions changed? */
5086 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5087 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5088 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && !uid_eq(inode->i_uid, fattr->uid))
5089 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && !uid_eq(inode->i_uid, kuid))
5090 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5091 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && !gid_eq(inode->i_gid, fattr->gid))
5092 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && !gid_eq(inode->i_gid, kgid))
5093 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5094 + /* maybe check for tag too? */
5096 /* Has the link count changed? */
5097 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5098 @@ -1319,6 +1336,9 @@ static int nfs_update_inode(struct inode
5099 unsigned long invalid = 0;
5100 unsigned long now = jiffies;
5101 unsigned long save_cache_validity;
5106 dfprintk(VFS, "NFS: %s(%s/%ld fh_crc=0x%08x ct=%d info=0x%x)\n",
5107 __func__, inode->i_sb->s_id, inode->i_ino,
5108 @@ -1420,6 +1440,9 @@ static int nfs_update_inode(struct inode
5109 | NFS_INO_REVAL_PAGECACHE
5110 | NFS_INO_REVAL_FORCED);
5112 + kuid = TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5113 + kgid = TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5114 + ktag = TAGINO_KTAG(DX_TAG(inode), inode->i_tag);
5116 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5117 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5118 @@ -1462,6 +1485,10 @@ static int nfs_update_inode(struct inode
5119 | NFS_INO_INVALID_ACL
5120 | NFS_INO_REVAL_FORCED);
5122 + inode->i_uid = INOTAG_KUID(DX_TAG(inode), kuid, kgid);
5123 + inode->i_gid = INOTAG_KGID(DX_TAG(inode), kuid, kgid);
5124 + inode->i_tag = INOTAG_KTAG(DX_TAG(inode), kuid, kgid, ktag);
5126 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5127 if (inode->i_nlink != fattr->nlink) {
5128 invalid |= NFS_INO_INVALID_ATTR;
5129 diff -NurpP --minimal linux-3.10.15/fs/nfs/nfs3xdr.c linux-3.10.15-vs2.3.6.6/fs/nfs/nfs3xdr.c
5130 --- linux-3.10.15/fs/nfs/nfs3xdr.c 2013-05-31 13:45:24.000000000 +0000
5131 +++ linux-3.10.15-vs2.3.6.6/fs/nfs/nfs3xdr.c 2013-08-22 20:29:59.000000000 +0000
5133 #include <linux/nfs3.h>
5134 #include <linux/nfs_fs.h>
5135 #include <linux/nfsacl.h>
5136 +#include <linux/vs_tag.h>
5137 #include "internal.h"
5139 #define NFSDBG_FACILITY NFSDBG_XDR
5140 @@ -558,7 +559,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5144 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5145 +static void encode_sattr3(struct xdr_stream *xdr,
5146 + const struct iattr *attr, int tag)
5150 @@ -590,15 +592,19 @@ static void encode_sattr3(struct xdr_str
5154 - if (attr->ia_valid & ATTR_UID) {
5155 + if (attr->ia_valid & ATTR_UID ||
5156 + (tag && (attr->ia_valid & ATTR_TAG))) {
5158 - *p++ = cpu_to_be32(from_kuid(&init_user_ns, attr->ia_uid));
5159 + *p++ = cpu_to_be32(from_kuid(&init_user_ns,
5160 + TAGINO_KUID(tag, attr->ia_uid, attr->ia_tag)));
5164 - if (attr->ia_valid & ATTR_GID) {
5165 + if (attr->ia_valid & ATTR_GID ||
5166 + (tag && (attr->ia_valid & ATTR_TAG))) {
5168 - *p++ = cpu_to_be32(from_kgid(&init_user_ns, attr->ia_gid));
5169 + *p++ = cpu_to_be32(from_kgid(&init_user_ns,
5170 + TAGINO_KGID(tag, attr->ia_gid, attr->ia_tag)));
5174 @@ -887,7 +893,7 @@ static void nfs3_xdr_enc_setattr3args(st
5175 const struct nfs3_sattrargs *args)
5177 encode_nfs_fh3(xdr, args->fh);
5178 - encode_sattr3(xdr, args->sattr);
5179 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5180 encode_sattrguard3(xdr, args);
5183 @@ -1037,13 +1043,13 @@ static void nfs3_xdr_enc_write3args(stru
5186 static void encode_createhow3(struct xdr_stream *xdr,
5187 - const struct nfs3_createargs *args)
5188 + const struct nfs3_createargs *args, int tag)
5190 encode_uint32(xdr, args->createmode);
5191 switch (args->createmode) {
5192 case NFS3_CREATE_UNCHECKED:
5193 case NFS3_CREATE_GUARDED:
5194 - encode_sattr3(xdr, args->sattr);
5195 + encode_sattr3(xdr, args->sattr, tag);
5197 case NFS3_CREATE_EXCLUSIVE:
5198 encode_createverf3(xdr, args->verifier);
5199 @@ -1058,7 +1064,7 @@ static void nfs3_xdr_enc_create3args(str
5200 const struct nfs3_createargs *args)
5202 encode_diropargs3(xdr, args->fh, args->name, args->len);
5203 - encode_createhow3(xdr, args);
5204 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5208 @@ -1074,7 +1080,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5209 const struct nfs3_mkdirargs *args)
5211 encode_diropargs3(xdr, args->fh, args->name, args->len);
5212 - encode_sattr3(xdr, args->sattr);
5213 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5217 @@ -1091,9 +1097,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5220 static void encode_symlinkdata3(struct xdr_stream *xdr,
5221 - const struct nfs3_symlinkargs *args)
5222 + const struct nfs3_symlinkargs *args, int tag)
5224 - encode_sattr3(xdr, args->sattr);
5225 + encode_sattr3(xdr, args->sattr, tag);
5226 encode_nfspath3(xdr, args->pages, args->pathlen);
5229 @@ -1102,7 +1108,7 @@ static void nfs3_xdr_enc_symlink3args(st
5230 const struct nfs3_symlinkargs *args)
5232 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5233 - encode_symlinkdata3(xdr, args);
5234 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5238 @@ -1130,24 +1136,24 @@ static void nfs3_xdr_enc_symlink3args(st
5241 static void encode_devicedata3(struct xdr_stream *xdr,
5242 - const struct nfs3_mknodargs *args)
5243 + const struct nfs3_mknodargs *args, int tag)
5245 - encode_sattr3(xdr, args->sattr);
5246 + encode_sattr3(xdr, args->sattr, tag);
5247 encode_specdata3(xdr, args->rdev);
5250 static void encode_mknoddata3(struct xdr_stream *xdr,
5251 - const struct nfs3_mknodargs *args)
5252 + const struct nfs3_mknodargs *args, int tag)
5254 encode_ftype3(xdr, args->type);
5255 switch (args->type) {
5258 - encode_devicedata3(xdr, args);
5259 + encode_devicedata3(xdr, args, tag);
5263 - encode_sattr3(xdr, args->sattr);
5264 + encode_sattr3(xdr, args->sattr, tag);
5268 @@ -1162,7 +1168,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5269 const struct nfs3_mknodargs *args)
5271 encode_diropargs3(xdr, args->fh, args->name, args->len);
5272 - encode_mknoddata3(xdr, args);
5273 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5277 diff -NurpP --minimal linux-3.10.15/fs/nfs/super.c linux-3.10.15-vs2.3.6.6/fs/nfs/super.c
5278 --- linux-3.10.15/fs/nfs/super.c 2013-07-14 17:01:28.000000000 +0000
5279 +++ linux-3.10.15-vs2.3.6.6/fs/nfs/super.c 2013-08-22 20:29:59.000000000 +0000
5281 #include <linux/parser.h>
5282 #include <linux/nsproxy.h>
5283 #include <linux/rcupdate.h>
5284 +#include <linux/vs_tag.h>
5286 #include <asm/uaccess.h>
5288 @@ -103,6 +104,7 @@ enum {
5294 /* Mount options that take string arguments */
5296 @@ -115,6 +117,9 @@ enum {
5297 /* Special mount options */
5298 Opt_userspace, Opt_deprecated, Opt_sloppy,
5300 + /* Linux-VServer tagging options */
5301 + Opt_tag, Opt_notag,
5306 @@ -184,6 +189,10 @@ static const match_table_t nfs_mount_opt
5307 { Opt_fscache_uniq, "fsc=%s" },
5308 { Opt_local_lock, "local_lock=%s" },
5310 + { Opt_tag, "tag" },
5311 + { Opt_notag, "notag" },
5312 + { Opt_tagid, "tagid=%u" },
5314 /* The following needs to be listed after all other options */
5315 { Opt_nfsvers, "v%s" },
5317 @@ -635,6 +644,7 @@ static void nfs_show_mount_options(struc
5318 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5319 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5320 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5321 + { NFS_MOUNT_TAGGED, ",tag", "" },
5324 const struct proc_nfs_info *nfs_infop;
5325 @@ -1261,6 +1271,14 @@ static int nfs_parse_mount_options(char
5326 case Opt_nomigration:
5327 mnt->options &= NFS_OPTION_MIGRATION;
5329 +#ifndef CONFIG_TAGGING_NONE
5331 + mnt->flags |= NFS_MOUNT_TAGGED;
5334 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5339 * options that take numeric values
5340 @@ -1347,6 +1365,12 @@ static int nfs_parse_mount_options(char
5341 goto out_invalid_value;
5342 mnt->minorversion = option;
5344 +#ifdef CONFIG_PROPAGATE
5347 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5352 * options that take text values
5353 diff -NurpP --minimal linux-3.10.15/fs/nfsd/auth.c linux-3.10.15-vs2.3.6.6/fs/nfsd/auth.c
5354 --- linux-3.10.15/fs/nfsd/auth.c 2013-05-31 13:45:24.000000000 +0000
5355 +++ linux-3.10.15-vs2.3.6.6/fs/nfsd/auth.c 2013-08-22 20:29:59.000000000 +0000
5358 #include <linux/sched.h>
5359 #include <linux/user_namespace.h>
5360 +#include <linux/vs_tag.h>
5364 @@ -37,6 +38,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5366 new->fsuid = rqstp->rq_cred.cr_uid;
5367 new->fsgid = rqstp->rq_cred.cr_gid;
5368 + /* FIXME: this desperately needs a tag :)
5369 + new->xid = (vxid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5372 rqgi = rqstp->rq_cred.cr_group_info;
5374 diff -NurpP --minimal linux-3.10.15/fs/nfsd/nfs3xdr.c linux-3.10.15-vs2.3.6.6/fs/nfsd/nfs3xdr.c
5375 --- linux-3.10.15/fs/nfsd/nfs3xdr.c 2013-05-31 13:45:24.000000000 +0000
5376 +++ linux-3.10.15-vs2.3.6.6/fs/nfsd/nfs3xdr.c 2013-08-22 20:29:59.000000000 +0000
5379 #include <linux/namei.h>
5380 #include <linux/sunrpc/svc_xprt.h>
5381 +#include <linux/vs_tag.h>
5385 @@ -98,6 +99,8 @@ static __be32 *
5386 decode_sattr3(__be32 *p, struct iattr *iap)
5389 + kuid_t kuid = GLOBAL_ROOT_UID;
5390 + kgid_t kgid = GLOBAL_ROOT_GID;
5394 @@ -106,15 +109,18 @@ decode_sattr3(__be32 *p, struct iattr *i
5395 iap->ia_mode = ntohl(*p++);
5398 - iap->ia_uid = make_kuid(&init_user_ns, ntohl(*p++));
5399 + kuid = make_kuid(&init_user_ns, ntohl(*p++));
5400 if (uid_valid(iap->ia_uid))
5401 iap->ia_valid |= ATTR_UID;
5404 - iap->ia_gid = make_kgid(&init_user_ns, ntohl(*p++));
5405 + kgid = make_kgid(&init_user_ns, ntohl(*p++));
5406 if (gid_valid(iap->ia_gid))
5407 iap->ia_valid |= ATTR_GID;
5409 + iap->ia_uid = INOTAG_KUID(DX_TAG_NFSD, kuid, kgid);
5410 + iap->ia_gid = INOTAG_KGID(DX_TAG_NFSD, kuid, kgid);
5411 + iap->ia_tag = INOTAG_KTAG(DX_TAG_NFSD, kuid, kgid, GLOBAL_ROOT_TAG);
5415 @@ -170,8 +176,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5416 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5417 *p++ = htonl((u32) stat->mode);
5418 *p++ = htonl((u32) stat->nlink);
5419 - *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
5420 - *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
5421 + *p++ = htonl((u32) from_kuid(&init_user_ns,
5422 + TAGINO_KUID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5423 + stat->uid, stat->tag)));
5424 + *p++ = htonl((u32) from_kgid(&init_user_ns,
5425 + TAGINO_KGID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5426 + stat->gid, stat->tag)));
5427 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5428 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5430 diff -NurpP --minimal linux-3.10.15/fs/nfsd/nfs4xdr.c linux-3.10.15-vs2.3.6.6/fs/nfsd/nfs4xdr.c
5431 --- linux-3.10.15/fs/nfsd/nfs4xdr.c 2013-10-09 17:35:22.000000000 +0000
5432 +++ linux-3.10.15-vs2.3.6.6/fs/nfsd/nfs4xdr.c 2013-08-22 20:29:59.000000000 +0000
5434 #include <linux/utsname.h>
5435 #include <linux/pagemap.h>
5436 #include <linux/sunrpc/svcauth_gss.h>
5437 +#include <linux/vs_tag.h>
5441 @@ -2320,14 +2321,18 @@ out_acl:
5442 WRITE32(stat.nlink);
5444 if (bmval1 & FATTR4_WORD1_OWNER) {
5445 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5446 + status = nfsd4_encode_user(rqstp,
5447 + TAGINO_KUID(DX_TAG(dentry->d_inode),
5448 + stat.uid, stat.tag), &p, &buflen);
5449 if (status == nfserr_resource)
5454 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5455 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5456 + status = nfsd4_encode_group(rqstp,
5457 + TAGINO_KGID(DX_TAG(dentry->d_inode),
5458 + stat.gid, stat.tag), &p, &buflen);
5459 if (status == nfserr_resource)
5462 diff -NurpP --minimal linux-3.10.15/fs/nfsd/nfsxdr.c linux-3.10.15-vs2.3.6.6/fs/nfsd/nfsxdr.c
5463 --- linux-3.10.15/fs/nfsd/nfsxdr.c 2013-05-31 13:45:24.000000000 +0000
5464 +++ linux-3.10.15-vs2.3.6.6/fs/nfsd/nfsxdr.c 2013-08-22 20:29:59.000000000 +0000
5469 +#include <linux/vs_tag.h>
5471 #define NFSDDBG_FACILITY NFSDDBG_XDR
5473 @@ -89,6 +90,8 @@ static __be32 *
5474 decode_sattr(__be32 *p, struct iattr *iap)
5477 + kuid_t kuid = GLOBAL_ROOT_UID;
5478 + kgid_t kgid = GLOBAL_ROOT_GID;
5482 @@ -101,15 +104,18 @@ decode_sattr(__be32 *p, struct iattr *ia
5485 if ((tmp = ntohl(*p++)) != (u32)-1) {
5486 - iap->ia_uid = make_kuid(&init_user_ns, tmp);
5487 + kuid = make_kuid(&init_user_ns, tmp);
5488 if (uid_valid(iap->ia_uid))
5489 iap->ia_valid |= ATTR_UID;
5491 if ((tmp = ntohl(*p++)) != (u32)-1) {
5492 - iap->ia_gid = make_kgid(&init_user_ns, tmp);
5493 + kgid = make_kgid(&init_user_ns, tmp);
5494 if (gid_valid(iap->ia_gid))
5495 iap->ia_valid |= ATTR_GID;
5497 + iap->ia_uid = INOTAG_KUID(DX_TAG_NFSD, kuid, kgid);
5498 + iap->ia_gid = INOTAG_KGID(DX_TAG_NFSD, kuid, kgid);
5499 + iap->ia_tag = INOTAG_KTAG(DX_TAG_NFSD, kuid, kgid, GLOBAL_ROOT_TAG);
5500 if ((tmp = ntohl(*p++)) != (u32)-1) {
5501 iap->ia_valid |= ATTR_SIZE;
5503 @@ -154,8 +160,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5504 *p++ = htonl(nfs_ftypes[type >> 12]);
5505 *p++ = htonl((u32) stat->mode);
5506 *p++ = htonl((u32) stat->nlink);
5507 - *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
5508 - *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
5509 + *p++ = htonl((u32) from_kuid(&init_user_ns,
5510 + TAGINO_KUID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5511 + *p++ = htonl((u32) from_kgid(&init_user_ns,
5512 + TAGINO_KGID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5514 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5515 *p++ = htonl(NFS_MAXPATHLEN);
5516 diff -NurpP --minimal linux-3.10.15/fs/ocfs2/dlmglue.c linux-3.10.15-vs2.3.6.6/fs/ocfs2/dlmglue.c
5517 --- linux-3.10.15/fs/ocfs2/dlmglue.c 2013-07-14 17:01:29.000000000 +0000
5518 +++ linux-3.10.15-vs2.3.6.6/fs/ocfs2/dlmglue.c 2013-08-22 20:29:59.000000000 +0000
5519 @@ -2047,6 +2047,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5520 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5521 lvb->lvb_iuid = cpu_to_be32(i_uid_read(inode));
5522 lvb->lvb_igid = cpu_to_be32(i_gid_read(inode));
5523 + lvb->lvb_itag = cpu_to_be16(i_tag_read(inode));
5524 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5525 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5526 lvb->lvb_iatime_packed =
5527 @@ -2097,6 +2098,7 @@ static void ocfs2_refresh_inode_from_lvb
5529 i_uid_write(inode, be32_to_cpu(lvb->lvb_iuid));
5530 i_gid_write(inode, be32_to_cpu(lvb->lvb_igid));
5531 + i_tag_write(inode, be16_to_cpu(lvb->lvb_itag));
5532 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5533 set_nlink(inode, be16_to_cpu(lvb->lvb_inlink));
5534 ocfs2_unpack_timespec(&inode->i_atime,
5535 diff -NurpP --minimal linux-3.10.15/fs/ocfs2/dlmglue.h linux-3.10.15-vs2.3.6.6/fs/ocfs2/dlmglue.h
5536 --- linux-3.10.15/fs/ocfs2/dlmglue.h 2012-12-11 03:30:57.000000000 +0000
5537 +++ linux-3.10.15-vs2.3.6.6/fs/ocfs2/dlmglue.h 2013-08-22 20:29:59.000000000 +0000
5538 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5541 __be32 lvb_igeneration;
5542 - __be32 lvb_reserved2;
5544 + __be16 lvb_reserved2;
5547 #define OCFS2_QINFO_LVB_VERSION 1
5548 diff -NurpP --minimal linux-3.10.15/fs/ocfs2/file.c linux-3.10.15-vs2.3.6.6/fs/ocfs2/file.c
5549 --- linux-3.10.15/fs/ocfs2/file.c 2013-07-14 17:01:29.000000000 +0000
5550 +++ linux-3.10.15-vs2.3.6.6/fs/ocfs2/file.c 2013-08-22 20:29:59.000000000 +0000
5551 @@ -1124,7 +1124,7 @@ int ocfs2_setattr(struct dentry *dentry,
5552 attr->ia_valid &= ~ATTR_SIZE;
5554 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5555 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5556 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5557 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5560 diff -NurpP --minimal linux-3.10.15/fs/ocfs2/inode.c linux-3.10.15-vs2.3.6.6/fs/ocfs2/inode.c
5561 --- linux-3.10.15/fs/ocfs2/inode.c 2013-05-31 13:45:24.000000000 +0000
5562 +++ linux-3.10.15-vs2.3.6.6/fs/ocfs2/inode.c 2013-08-22 20:29:59.000000000 +0000
5564 #include <linux/highmem.h>
5565 #include <linux/pagemap.h>
5566 #include <linux/quotaops.h>
5567 +#include <linux/vs_tag.h>
5569 #include <asm/byteorder.h>
5571 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5573 unsigned int flags = OCFS2_I(inode)->ip_attr;
5575 - inode->i_flags &= ~(S_IMMUTABLE |
5576 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5577 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5579 if (flags & OCFS2_IMMUTABLE_FL)
5580 inode->i_flags |= S_IMMUTABLE;
5581 + if (flags & OCFS2_IXUNLINK_FL)
5582 + inode->i_flags |= S_IXUNLINK;
5584 if (flags & OCFS2_SYNC_FL)
5585 inode->i_flags |= S_SYNC;
5586 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5587 inode->i_flags |= S_NOATIME;
5588 if (flags & OCFS2_DIRSYNC_FL)
5589 inode->i_flags |= S_DIRSYNC;
5591 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5593 + if (flags & OCFS2_BARRIER_FL)
5594 + inode->i_vflags |= V_BARRIER;
5595 + if (flags & OCFS2_COW_FL)
5596 + inode->i_vflags |= V_COW;
5599 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5600 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5602 unsigned int flags = oi->vfs_inode.i_flags;
5603 + unsigned int vflags = oi->vfs_inode.i_vflags;
5605 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5606 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5607 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5608 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5610 + if (flags & S_IMMUTABLE)
5611 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5612 + if (flags & S_IXUNLINK)
5613 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5615 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5616 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5618 oi->ip_attr |= OCFS2_SYNC_FL;
5619 if (flags & S_APPEND)
5620 oi->ip_attr |= OCFS2_APPEND_FL;
5621 - if (flags & S_IMMUTABLE)
5622 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5623 if (flags & S_NOATIME)
5624 oi->ip_attr |= OCFS2_NOATIME_FL;
5625 if (flags & S_DIRSYNC)
5626 oi->ip_attr |= OCFS2_DIRSYNC_FL;
5628 + if (vflags & V_BARRIER)
5629 + oi->ip_attr |= OCFS2_BARRIER_FL;
5630 + if (vflags & V_COW)
5631 + oi->ip_attr |= OCFS2_COW_FL;
5634 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
5635 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
5636 struct super_block *sb;
5637 struct ocfs2_super *osb;
5644 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
5645 inode->i_generation = le32_to_cpu(fe->i_generation);
5646 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
5647 inode->i_mode = le16_to_cpu(fe->i_mode);
5648 - i_uid_write(inode, le32_to_cpu(fe->i_uid));
5649 - i_gid_write(inode, le32_to_cpu(fe->i_gid));
5650 + uid = le32_to_cpu(fe->i_uid);
5651 + gid = le32_to_cpu(fe->i_gid);
5652 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), uid, gid));
5653 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), uid, gid));
5654 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), uid, gid,
5655 + /* le16_to_cpu(raw_inode->i_raw_tag) */ 0));
5657 /* Fast symlinks will have i_size but no allocated clusters. */
5658 if (S_ISLNK(inode->i_mode) && !fe->i_clusters) {
5659 diff -NurpP --minimal linux-3.10.15/fs/ocfs2/inode.h linux-3.10.15-vs2.3.6.6/fs/ocfs2/inode.h
5660 --- linux-3.10.15/fs/ocfs2/inode.h 2013-07-14 17:01:29.000000000 +0000
5661 +++ linux-3.10.15-vs2.3.6.6/fs/ocfs2/inode.h 2013-08-22 20:29:59.000000000 +0000
5662 @@ -152,6 +152,7 @@ struct buffer_head *ocfs2_bread(struct i
5664 void ocfs2_set_inode_flags(struct inode *inode);
5665 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
5666 +int ocfs2_sync_flags(struct inode *inode, int, int);
5668 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
5670 diff -NurpP --minimal linux-3.10.15/fs/ocfs2/ioctl.c linux-3.10.15-vs2.3.6.6/fs/ocfs2/ioctl.c
5671 --- linux-3.10.15/fs/ocfs2/ioctl.c 2013-07-14 17:01:29.000000000 +0000
5672 +++ linux-3.10.15-vs2.3.6.6/fs/ocfs2/ioctl.c 2013-08-22 20:29:59.000000000 +0000
5673 @@ -76,7 +76,41 @@ static int ocfs2_get_inode_attr(struct i
5677 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5678 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
5680 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5681 + struct buffer_head *bh = NULL;
5682 + handle_t *handle = NULL;
5685 + status = ocfs2_inode_lock(inode, &bh, 1);
5687 + mlog_errno(status);
5690 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5691 + if (IS_ERR(handle)) {
5692 + status = PTR_ERR(handle);
5693 + mlog_errno(status);
5697 + inode->i_flags = flags;
5698 + inode->i_vflags = vflags;
5699 + ocfs2_get_inode_flags(OCFS2_I(inode));
5701 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
5703 + mlog_errno(status);
5705 + ocfs2_commit_trans(osb, handle);
5707 + ocfs2_inode_unlock(inode, 1);
5712 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5715 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
5716 @@ -116,6 +150,11 @@ static int ocfs2_set_inode_attr(struct i
5720 + if (IS_BARRIER(inode)) {
5721 + vxwprintk_task(1, "messing with the barrier.");
5725 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5726 if (IS_ERR(handle)) {
5727 status = PTR_ERR(handle);
5728 @@ -881,6 +920,7 @@ bail:
5733 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5735 struct inode *inode = file_inode(filp);
5736 diff -NurpP --minimal linux-3.10.15/fs/ocfs2/namei.c linux-3.10.15-vs2.3.6.6/fs/ocfs2/namei.c
5737 --- linux-3.10.15/fs/ocfs2/namei.c 2013-07-14 17:01:29.000000000 +0000
5738 +++ linux-3.10.15-vs2.3.6.6/fs/ocfs2/namei.c 2013-08-22 20:29:59.000000000 +0000
5740 #include <linux/slab.h>
5741 #include <linux/highmem.h>
5742 #include <linux/quotaops.h>
5743 +#include <linux/vs_tag.h>
5745 #include <cluster/masklog.h>
5747 @@ -475,6 +476,7 @@ static int __ocfs2_mknod_locked(struct i
5748 struct ocfs2_dinode *fe = NULL;
5749 struct ocfs2_extent_list *fel;
5755 @@ -512,8 +514,13 @@ static int __ocfs2_mknod_locked(struct i
5756 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
5757 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
5758 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
5759 - fe->i_uid = cpu_to_le32(i_uid_read(inode));
5760 - fe->i_gid = cpu_to_le32(i_gid_read(inode));
5762 + ktag = make_ktag(&init_user_ns, dx_current_fstag(osb->sb));
5763 + fe->i_uid = cpu_to_le32(from_kuid(&init_user_ns,
5764 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, ktag)));
5765 + fe->i_gid = cpu_to_le32(from_kgid(&init_user_ns,
5766 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, ktag)));
5767 + inode->i_tag = ktag; /* is this correct? */
5768 fe->i_mode = cpu_to_le16(inode->i_mode);
5769 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
5770 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
5771 diff -NurpP --minimal linux-3.10.15/fs/ocfs2/ocfs2.h linux-3.10.15-vs2.3.6.6/fs/ocfs2/ocfs2.h
5772 --- linux-3.10.15/fs/ocfs2/ocfs2.h 2012-12-11 03:30:57.000000000 +0000
5773 +++ linux-3.10.15-vs2.3.6.6/fs/ocfs2/ocfs2.h 2013-08-22 20:29:59.000000000 +0000
5774 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
5776 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
5777 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
5778 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
5781 #define OCFS2_OSB_SOFT_RO 0x0001
5782 diff -NurpP --minimal linux-3.10.15/fs/ocfs2/ocfs2_fs.h linux-3.10.15-vs2.3.6.6/fs/ocfs2/ocfs2_fs.h
5783 --- linux-3.10.15/fs/ocfs2/ocfs2_fs.h 2012-12-11 03:30:57.000000000 +0000
5784 +++ linux-3.10.15-vs2.3.6.6/fs/ocfs2/ocfs2_fs.h 2013-08-22 20:29:59.000000000 +0000
5785 @@ -266,6 +266,11 @@
5786 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
5787 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
5789 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
5791 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
5792 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
5794 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
5795 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
5797 diff -NurpP --minimal linux-3.10.15/fs/ocfs2/super.c linux-3.10.15-vs2.3.6.6/fs/ocfs2/super.c
5798 --- linux-3.10.15/fs/ocfs2/super.c 2013-05-31 13:45:25.000000000 +0000
5799 +++ linux-3.10.15-vs2.3.6.6/fs/ocfs2/super.c 2013-08-22 20:29:59.000000000 +0000
5800 @@ -185,6 +185,7 @@ enum {
5804 + Opt_tag, Opt_notag, Opt_tagid,
5808 @@ -216,6 +217,9 @@ static const match_table_t tokens = {
5809 {Opt_coherency_full, "coherency=full"},
5810 {Opt_resv_level, "resv_level=%u"},
5811 {Opt_dir_resv_level, "dir_resv_level=%u"},
5813 + {Opt_notag, "notag"},
5814 + {Opt_tagid, "tagid=%u"},
5818 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
5822 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
5823 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
5825 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
5829 /* We're going to/from readonly mode. */
5830 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
5831 /* Disable quota accounting before remounting RO */
5832 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
5834 ocfs2_complete_mount_recovery(osb);
5836 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
5837 + sb->s_flags |= MS_TAGGED;
5839 if (ocfs2_mount_local(osb))
5840 snprintf(nodestr, sizeof(nodestr), "local");
5842 @@ -1504,6 +1518,20 @@ static int ocfs2_parse_options(struct su
5843 option < OCFS2_MAX_RESV_LEVEL)
5844 mopt->dir_resv_level = option;
5846 +#ifndef CONFIG_TAGGING_NONE
5848 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
5851 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
5854 +#ifdef CONFIG_PROPAGATE
5857 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
5862 "Unrecognized mount option \"%s\" "
5863 diff -NurpP --minimal linux-3.10.15/fs/open.c linux-3.10.15-vs2.3.6.6/fs/open.c
5864 --- linux-3.10.15/fs/open.c 2013-07-14 17:01:29.000000000 +0000
5865 +++ linux-3.10.15-vs2.3.6.6/fs/open.c 2013-08-22 20:29:59.000000000 +0000
5867 #include <linux/ima.h>
5868 #include <linux/dnotify.h>
5869 #include <linux/compat.h>
5870 +#include <linux/vs_base.h>
5871 +#include <linux/vs_limit.h>
5872 +#include <linux/vs_tag.h>
5873 +#include <linux/vs_cowbl.h>
5874 +#include <linux/vserver/dlimit.h>
5876 #include "internal.h"
5878 @@ -67,6 +72,11 @@ long vfs_truncate(struct path *path, lof
5879 struct inode *inode;
5882 +#ifdef CONFIG_VSERVER_COWBL
5883 + error = cow_check_and_break(path);
5887 inode = path->dentry->d_inode;
5889 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
5890 @@ -504,6 +514,13 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
5891 unsigned int lookup_flags = LOOKUP_FOLLOW;
5893 error = user_path_at(dfd, filename, lookup_flags, &path);
5894 +#ifdef CONFIG_VSERVER_COWBL
5896 + error = cow_check_and_break(&path);
5902 error = chmod_common(&path, mode);
5904 @@ -536,13 +553,15 @@ static int chown_common(struct path *pat
5905 if (!uid_valid(uid))
5907 newattrs.ia_valid |= ATTR_UID;
5908 - newattrs.ia_uid = uid;
5909 + newattrs.ia_uid = make_kuid(&init_user_ns,
5910 + dx_map_uid(user));
5912 if (group != (gid_t) -1) {
5913 if (!gid_valid(gid))
5915 newattrs.ia_valid |= ATTR_GID;
5916 - newattrs.ia_gid = gid;
5917 + newattrs.ia_gid = make_kgid(&init_user_ns,
5918 + dx_map_gid(group));
5920 if (!S_ISDIR(inode->i_mode))
5921 newattrs.ia_valid |=
5922 @@ -576,6 +595,18 @@ retry:
5923 error = mnt_want_write(path.mnt);
5926 +#ifdef CONFIG_VSERVER_COWBL
5927 + error = cow_check_and_break(&path);
5930 +#ifdef CONFIG_VSERVER_COWBL
5931 + error = cow_check_and_break(&path);
5934 +#ifdef CONFIG_VSERVER_COWBL
5935 + error = cow_check_and_break(&path);
5938 error = chown_common(&path, user, group);
5939 mnt_drop_write(path.mnt);
5941 diff -NurpP --minimal linux-3.10.15/fs/proc/array.c linux-3.10.15-vs2.3.6.6/fs/proc/array.c
5942 --- linux-3.10.15/fs/proc/array.c 2013-05-31 13:45:25.000000000 +0000
5943 +++ linux-3.10.15-vs2.3.6.6/fs/proc/array.c 2013-08-22 20:29:59.000000000 +0000
5945 #include <linux/ptrace.h>
5946 #include <linux/tracehook.h>
5947 #include <linux/user_namespace.h>
5948 +#include <linux/vs_context.h>
5949 +#include <linux/vs_network.h>
5951 #include <asm/pgtable.h>
5952 #include <asm/processor.h>
5953 @@ -173,6 +175,9 @@ static inline void task_state(struct seq
5955 ppid = pid_alive(p) ?
5956 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
5957 + if (unlikely(vx_current_initpid(p->pid)))
5962 struct task_struct *tracer = ptrace_parent(p);
5963 @@ -297,7 +302,7 @@ static inline void task_sig(struct seq_f
5966 static void render_cap_t(struct seq_file *m, const char *header,
5968 + struct vx_info *vxi, kernel_cap_t *a)
5972 @@ -331,10 +336,11 @@ static inline void task_cap(struct seq_f
5973 NORM_CAPS(cap_effective);
5974 NORM_CAPS(cap_bset);
5976 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
5977 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
5978 - render_cap_t(m, "CapEff:\t", &cap_effective);
5979 - render_cap_t(m, "CapBnd:\t", &cap_bset);
5980 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
5981 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
5982 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
5983 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
5984 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
5987 static inline void task_seccomp(struct seq_file *m, struct task_struct *p)
5988 @@ -363,6 +369,42 @@ static void task_cpus_allowed(struct seq
5992 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
5993 + struct pid *pid, struct task_struct *task)
5995 + seq_printf(m, "Proxy:\t%p(%c)\n"
6003 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6004 + atomic_read(&task->nsproxy->count),
6005 + task->nsproxy->uts_ns,
6006 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6007 + task->nsproxy->ipc_ns,
6008 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6009 + task->nsproxy->mnt_ns,
6010 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6011 + task->nsproxy->pid_ns,
6012 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6013 + task->nsproxy->net_ns,
6014 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6018 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6020 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6023 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6024 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6028 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6029 struct pid *pid, struct task_struct *task)
6031 @@ -380,6 +422,7 @@ int proc_pid_status(struct seq_file *m,
6032 task_seccomp(m, task);
6033 task_cpus_allowed(m, task);
6034 cpuset_task_status_allowed(m, task);
6035 + task_vs_id(m, task);
6036 task_context_switch_counts(m, task);
6039 @@ -489,6 +532,17 @@ static int do_task_stat(struct seq_file
6040 /* convert nsec -> ticks */
6041 start_time = nsec_to_clock_t(start_time);
6043 + /* fixup start time for virt uptime */
6044 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6045 + unsigned long long bias =
6046 + current->vx_info->cvirt.bias_clock;
6048 + if (start_time > bias)
6049 + start_time -= bias;
6054 seq_printf(m, "%d (%s) %c", pid_nr_ns(pid, ns), tcomm, state);
6055 seq_put_decimal_ll(m, ' ', ppid);
6056 seq_put_decimal_ll(m, ' ', pgid);
6057 diff -NurpP --minimal linux-3.10.15/fs/proc/base.c linux-3.10.15-vs2.3.6.6/fs/proc/base.c
6058 --- linux-3.10.15/fs/proc/base.c 2013-07-14 17:01:29.000000000 +0000
6059 +++ linux-3.10.15-vs2.3.6.6/fs/proc/base.c 2013-08-22 22:18:21.000000000 +0000
6061 #include <linux/slab.h>
6062 #include <linux/flex_array.h>
6063 #include <linux/posix-timers.h>
6064 +#include <linux/vs_context.h>
6065 +#include <linux/vs_network.h>
6066 #ifdef CONFIG_HARDWALL
6067 #include <asm/hardwall.h>
6069 @@ -976,11 +978,15 @@ static ssize_t oom_adj_write(struct file
6070 oom_adj = (oom_adj * OOM_SCORE_ADJ_MAX) / -OOM_DISABLE;
6072 if (oom_adj < task->signal->oom_score_adj &&
6073 - !capable(CAP_SYS_RESOURCE)) {
6074 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6079 + /* prevent guest processes from circumventing the oom killer */
6080 + if (vx_current_xid() && (oom_adj == OOM_DISABLE))
6081 + oom_adj = OOM_ADJUST_MIN;
6084 * /proc/pid/oom_adj is provided for legacy purposes, ask users to use
6085 * /proc/pid/oom_score_adj instead.
6086 @@ -1559,6 +1565,8 @@ struct inode *proc_pid_make_inode(struct
6087 inode->i_gid = cred->egid;
6090 + /* procfs is xid tagged */
6091 + i_tag_write(inode, (vtag_t)vx_task_xid(task));
6092 security_task_to_inode(task, inode);
6095 @@ -1604,6 +1612,8 @@ int pid_getattr(struct vfsmount *mnt, st
6099 +static unsigned name_to_int(struct dentry *dentry);
6102 * Exceptional case: normally we are not allowed to unhash a busy
6103 * directory. In this case, however, we can do it - no aliasing problems
6104 @@ -1632,6 +1642,12 @@ int pid_revalidate(struct dentry *dentry
6105 task = get_proc_task(inode);
6108 + unsigned pid = name_to_int(dentry);
6110 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6111 + put_task_struct(task);
6114 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6115 task_dumpable(task)) {
6117 @@ -1648,6 +1664,7 @@ int pid_revalidate(struct dentry *dentry
6118 put_task_struct(task);
6125 @@ -2196,6 +2213,13 @@ static struct dentry *proc_pident_lookup
6129 + /* TODO: maybe we can come up with a generic approach? */
6130 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6131 + (dentry->d_name.len == 5) &&
6132 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6133 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6137 * Yes, it does not scale. And it should not. Don't add
6138 * new entries into /proc/<tgid>/ without very good reasons.
6139 @@ -2630,6 +2654,9 @@ static int proc_pid_personality(struct s
6140 static const struct file_operations proc_task_operations;
6141 static const struct inode_operations proc_task_inode_operations;
6143 +extern int proc_pid_vx_info(struct task_struct *, char *);
6144 +extern int proc_pid_nx_info(struct task_struct *, char *);
6146 static const struct pid_entry tgid_base_stuff[] = {
6147 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6148 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6149 @@ -2696,6 +2723,8 @@ static const struct pid_entry tgid_base_
6150 #ifdef CONFIG_CGROUPS
6151 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6153 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6154 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6155 INF("oom_score", S_IRUGO, proc_oom_score),
6156 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations),
6157 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6158 @@ -2910,7 +2939,7 @@ retry:
6160 pid = find_ge_pid(iter.tgid, ns);
6162 - iter.tgid = pid_nr_ns(pid, ns);
6163 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6164 iter.task = pid_task(pid, PIDTYPE_PID);
6165 /* What we to know is if the pid we have find is the
6166 * pid of a thread_group_leader. Testing for task
6167 @@ -2940,7 +2969,7 @@ static int proc_pid_fill_cache(struct fi
6168 struct tgid_iter iter)
6170 char name[PROC_NUMBUF];
6171 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6172 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6173 return proc_fill_cache(filp, dirent, filldir, name, len,
6174 proc_pid_instantiate, iter.task, NULL);
6176 @@ -2981,6 +3010,8 @@ int proc_pid_readdir(struct file * filp,
6177 __filldir = fake_filldir;
6179 filp->f_pos = iter.tgid + TGID_OFFSET;
6180 + if (!vx_proc_task_visible(iter.task))
6182 if (proc_pid_fill_cache(filp, dirent, __filldir, iter) < 0) {
6183 put_task_struct(iter.task);
6185 @@ -3073,6 +3104,7 @@ static const struct pid_entry tid_base_s
6186 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
6187 REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations),
6189 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6192 static int proc_tid_base_readdir(struct file * filp,
6193 @@ -3141,6 +3173,8 @@ static struct dentry *proc_task_lookup(s
6194 tid = name_to_int(dentry);
6197 + if (vx_current_initpid(tid))
6200 ns = dentry->d_sb->s_fs_info;
6202 diff -NurpP --minimal linux-3.10.15/fs/proc/generic.c linux-3.10.15-vs2.3.6.6/fs/proc/generic.c
6203 --- linux-3.10.15/fs/proc/generic.c 2013-07-14 17:01:29.000000000 +0000
6204 +++ linux-3.10.15-vs2.3.6.6/fs/proc/generic.c 2013-08-22 20:29:59.000000000 +0000
6206 #include <linux/bitops.h>
6207 #include <linux/spinlock.h>
6208 #include <linux/completion.h>
6209 +#include <linux/vserver/inode.h>
6210 #include <asm/uaccess.h>
6212 #include "internal.h"
6213 @@ -203,6 +204,8 @@ struct dentry *proc_lookup_de(struct pro
6214 for (de = de->subdir; de ; de = de->next) {
6215 if (de->namelen != dentry->d_name.len)
6217 + if (!vx_hide_check(0, de->vx_flags))
6219 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6221 spin_unlock(&proc_subdir_lock);
6222 @@ -211,6 +214,8 @@ struct dentry *proc_lookup_de(struct pro
6223 return ERR_PTR(-ENOMEM);
6224 d_set_d_op(dentry, &proc_dentry_operations);
6225 d_add(dentry, inode);
6226 + /* generic proc entries belong to the host */
6227 + i_tag_write(inode, 0);
6231 @@ -279,6 +284,8 @@ int proc_readdir_de(struct proc_dir_entr
6233 /* filldir passes info to user space */
6235 + if (!vx_hide_check(0, de->vx_flags))
6237 spin_unlock(&proc_subdir_lock);
6238 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6239 de->low_ino, de->mode >> 12) < 0) {
6240 @@ -286,6 +293,7 @@ int proc_readdir_de(struct proc_dir_entr
6243 spin_lock(&proc_subdir_lock);
6248 @@ -395,6 +403,7 @@ static struct proc_dir_entry *__proc_cre
6252 + ent->vx_flags = IATTR_PROC_DEFAULT;
6253 atomic_set(&ent->count, 1);
6254 spin_lock_init(&ent->pde_unload_lock);
6255 INIT_LIST_HEAD(&ent->pde_openers);
6256 @@ -418,7 +427,8 @@ struct proc_dir_entry *proc_symlink(cons
6262 + ent->vx_flags = IATTR_PROC_SYMLINK;
6266 diff -NurpP --minimal linux-3.10.15/fs/proc/inode.c linux-3.10.15-vs2.3.6.6/fs/proc/inode.c
6267 --- linux-3.10.15/fs/proc/inode.c 2013-07-14 17:01:29.000000000 +0000
6268 +++ linux-3.10.15-vs2.3.6.6/fs/proc/inode.c 2013-08-22 20:29:59.000000000 +0000
6269 @@ -387,6 +387,8 @@ struct inode *proc_get_inode(struct supe
6270 inode->i_uid = de->uid;
6271 inode->i_gid = de->gid;
6274 + PROC_I(inode)->vx_flags = de->vx_flags;
6276 inode->i_size = de->size;
6278 diff -NurpP --minimal linux-3.10.15/fs/proc/internal.h linux-3.10.15-vs2.3.6.6/fs/proc/internal.h
6279 --- linux-3.10.15/fs/proc/internal.h 2013-07-14 17:01:29.000000000 +0000
6280 +++ linux-3.10.15-vs2.3.6.6/fs/proc/internal.h 2013-08-22 21:52:30.000000000 +0000
6282 #include <linux/spinlock.h>
6283 #include <linux/atomic.h>
6284 #include <linux/binfmts.h>
6285 +#include <linux/vs_pid.h>
6287 struct ctl_table_header;
6289 @@ -35,6 +36,7 @@ struct proc_dir_entry {
6295 const struct inode_operations *proc_iops;
6296 const struct file_operations *proc_fops;
6297 @@ -50,16 +52,23 @@ struct proc_dir_entry {
6305 int (*proc_get_link)(struct dentry *, struct path *);
6306 int (*proc_read)(struct task_struct *task, char *page);
6307 int (*proc_show)(struct seq_file *m,
6308 struct pid_namespace *ns, struct pid *pid,
6309 struct task_struct *task);
6310 + int (*proc_vs_read)(char *page);
6311 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
6312 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
6320 struct proc_dir_entry *pde;
6321 @@ -92,11 +101,16 @@ static inline struct pid *proc_pid(struc
6322 return PROC_I(inode)->pid;
6325 -static inline struct task_struct *get_proc_task(struct inode *inode)
6326 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6328 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6331 +static inline struct task_struct *get_proc_task(struct inode *inode)
6333 + return vx_get_proc_task(inode, proc_pid(inode));
6336 static inline int task_dumpable(struct task_struct *task)
6339 @@ -155,6 +169,8 @@ extern int proc_pid_status(struct seq_fi
6340 struct pid *, struct task_struct *);
6341 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
6342 struct pid *, struct task_struct *);
6343 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6344 + struct pid *pid, struct task_struct *task);
6348 diff -NurpP --minimal linux-3.10.15/fs/proc/loadavg.c linux-3.10.15-vs2.3.6.6/fs/proc/loadavg.c
6349 --- linux-3.10.15/fs/proc/loadavg.c 2012-12-11 03:30:57.000000000 +0000
6350 +++ linux-3.10.15-vs2.3.6.6/fs/proc/loadavg.c 2013-08-22 20:30:00.000000000 +0000
6353 static int loadavg_proc_show(struct seq_file *m, void *v)
6355 + unsigned long running;
6356 + unsigned int threads;
6357 unsigned long avnrun[3];
6359 get_avenrun(avnrun, FIXED_1/200, 0);
6361 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6362 + struct vx_info *vxi = current_vx_info();
6364 + running = atomic_read(&vxi->cvirt.nr_running);
6365 + threads = atomic_read(&vxi->cvirt.nr_threads);
6367 + running = nr_running();
6368 + threads = nr_threads;
6371 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6372 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6373 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6374 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6375 - nr_running(), nr_threads,
6377 task_active_pid_ns(current)->last_pid);
6380 diff -NurpP --minimal linux-3.10.15/fs/proc/meminfo.c linux-3.10.15-vs2.3.6.6/fs/proc/meminfo.c
6381 --- linux-3.10.15/fs/proc/meminfo.c 2013-07-14 17:01:29.000000000 +0000
6382 +++ linux-3.10.15-vs2.3.6.6/fs/proc/meminfo.c 2013-08-22 20:30:00.000000000 +0000
6383 @@ -40,7 +40,8 @@ static int meminfo_proc_show(struct seq_
6384 allowed = ((totalram_pages - hugetlb_total_pages())
6385 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6387 - cached = global_page_state(NR_FILE_PAGES) -
6388 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6389 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6390 total_swapcache_pages() - i.bufferram;
6393 diff -NurpP --minimal linux-3.10.15/fs/proc/root.c linux-3.10.15-vs2.3.6.6/fs/proc/root.c
6394 --- linux-3.10.15/fs/proc/root.c 2013-10-09 17:35:22.000000000 +0000
6395 +++ linux-3.10.15-vs2.3.6.6/fs/proc/root.c 2013-10-09 17:37:22.000000000 +0000
6397 #include <linux/mount.h>
6398 #include <linux/pid_namespace.h>
6399 #include <linux/parser.h>
6400 +#include <linux/vserver/inode.h>
6402 #include "internal.h"
6404 +struct proc_dir_entry *proc_virtual;
6406 +extern void proc_vx_init(void);
6408 static int proc_test_super(struct super_block *sb, void *data)
6410 return sb->s_fs_info == data;
6411 @@ -185,6 +190,7 @@ void __init proc_root_init(void)
6413 proc_mkdir("bus", NULL);
6418 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6419 @@ -251,6 +257,7 @@ struct proc_dir_entry proc_root = {
6420 .proc_iops = &proc_root_inode_operations,
6421 .proc_fops = &proc_root_operations,
6422 .parent = &proc_root,
6423 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6427 diff -NurpP --minimal linux-3.10.15/fs/proc/self.c linux-3.10.15-vs2.3.6.6/fs/proc/self.c
6428 --- linux-3.10.15/fs/proc/self.c 2013-07-14 17:01:29.000000000 +0000
6429 +++ linux-3.10.15-vs2.3.6.6/fs/proc/self.c 2013-08-23 00:07:45.000000000 +0000
6431 #include <linux/namei.h>
6432 #include <linux/slab.h>
6433 #include <linux/pid_namespace.h>
6434 +#include <linux/vserver/inode.h>
6435 #include "internal.h"
6438 @@ -62,6 +63,8 @@ int proc_setup_self(struct super_block *
6439 self = d_alloc_name(s->s_root, "self");
6441 struct inode *inode = new_inode_pseudo(s);
6443 + // self->vx_flags = IATTR_PROC_SYMLINK;
6445 inode->i_ino = self_inum;
6446 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
6447 diff -NurpP --minimal linux-3.10.15/fs/proc/stat.c linux-3.10.15-vs2.3.6.6/fs/proc/stat.c
6448 --- linux-3.10.15/fs/proc/stat.c 2013-07-14 17:01:29.000000000 +0000
6449 +++ linux-3.10.15-vs2.3.6.6/fs/proc/stat.c 2013-08-22 20:30:00.000000000 +0000
6451 #include <linux/slab.h>
6452 #include <linux/time.h>
6453 #include <linux/irqnr.h>
6454 +#include <linux/vserver/cvirt.h>
6455 #include <asm/cputime.h>
6456 #include <linux/tick.h>
6457 +#include <linux/cpuset.h>
6459 #ifndef arch_irq_stat_cpu
6460 #define arch_irq_stat_cpu(cpu) 0
6461 @@ -87,14 +89,26 @@ static int show_stat(struct seq_file *p,
6462 u64 sum_softirq = 0;
6463 unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
6464 struct timespec boottime;
6465 + cpumask_var_t cpus_allowed;
6466 + bool virt_cpu = vx_flags(VXF_VIRT_CPU, 0);
6468 user = nice = system = idle = iowait =
6469 irq = softirq = steal = 0;
6470 guest = guest_nice = 0;
6471 getboottime(&boottime);
6473 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6474 + vx_vsi_boottime(&boottime);
6477 + cpuset_cpus_allowed(current, cpus_allowed);
6479 jif = boottime.tv_sec;
6481 for_each_possible_cpu(i) {
6482 + if (virt_cpu && !cpumask_test_cpu(i, cpus_allowed))
6485 user += kcpustat_cpu(i).cpustat[CPUTIME_USER];
6486 nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE];
6487 system += kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
6488 @@ -131,6 +145,9 @@ static int show_stat(struct seq_file *p,
6491 for_each_online_cpu(i) {
6492 + if (virt_cpu && !cpumask_test_cpu(i, cpus_allowed))
6495 /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
6496 user = kcpustat_cpu(i).cpustat[CPUTIME_USER];
6497 nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE];
6498 diff -NurpP --minimal linux-3.10.15/fs/proc/uptime.c linux-3.10.15-vs2.3.6.6/fs/proc/uptime.c
6499 --- linux-3.10.15/fs/proc/uptime.c 2012-12-11 03:30:57.000000000 +0000
6500 +++ linux-3.10.15-vs2.3.6.6/fs/proc/uptime.c 2013-08-22 20:30:00.000000000 +0000
6502 #include <linux/seq_file.h>
6503 #include <linux/time.h>
6504 #include <linux/kernel_stat.h>
6505 +#include <linux/vserver/cvirt.h>
6506 #include <asm/cputime.h>
6508 static int uptime_proc_show(struct seq_file *m, void *v)
6509 @@ -25,6 +26,10 @@ static int uptime_proc_show(struct seq_f
6510 nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
6511 idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
6514 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6515 + vx_vsi_uptime(&uptime, &idle);
6517 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6518 (unsigned long) uptime.tv_sec,
6519 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6520 diff -NurpP --minimal linux-3.10.15/fs/proc_namespace.c linux-3.10.15-vs2.3.6.6/fs/proc_namespace.c
6521 --- linux-3.10.15/fs/proc_namespace.c 2012-12-11 03:30:57.000000000 +0000
6522 +++ linux-3.10.15-vs2.3.6.6/fs/proc_namespace.c 2013-08-22 20:30:00.000000000 +0000
6523 @@ -44,6 +44,8 @@ static int show_sb_opts(struct seq_file
6524 { MS_SYNCHRONOUS, ",sync" },
6525 { MS_DIRSYNC, ",dirsync" },
6526 { MS_MANDLOCK, ",mand" },
6527 + { MS_TAGGED, ",tag" },
6528 + { MS_NOTAGCHECK, ",notagcheck" },
6531 const struct proc_fs_info *fs_infop;
6532 @@ -80,6 +82,40 @@ static inline void mangle(struct seq_fil
6533 seq_escape(m, s, " \t\n\\");
6536 +#ifdef CONFIG_VSERVER_EXTRA_MNT_CHECK
6538 +static int mnt_is_reachable(struct vfsmount *vfsmnt)
6541 + struct dentry *point;
6542 + struct mount *mnt = real_mount(vfsmnt);
6543 + struct mount *root_mnt;
6546 + if (mnt == mnt->mnt_ns->root)
6549 + br_read_lock(&vfsmount_lock);
6550 + root = current->fs->root;
6551 + root_mnt = real_mount(root.mnt);
6552 + point = root.dentry;
6554 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
6555 + point = mnt->mnt_mountpoint;
6556 + mnt = mnt->mnt_parent;
6559 + ret = (mnt == root_mnt) && is_subdir(point, root.dentry);
6561 + br_read_unlock(&vfsmount_lock);
6567 +#define mnt_is_reachable(v) (1)
6570 static void show_type(struct seq_file *m, struct super_block *sb)
6572 mangle(m, sb->s_type->name);
6573 @@ -96,6 +132,17 @@ static int show_vfsmnt(struct seq_file *
6574 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6575 struct super_block *sb = mnt_path.dentry->d_sb;
6577 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6579 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6582 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6583 + mnt == current->fs->root.mnt) {
6584 + seq_puts(m, "/dev/root / ");
6588 if (sb->s_op->show_devname) {
6589 err = sb->s_op->show_devname(m, mnt_path.dentry);
6591 @@ -106,6 +153,7 @@ static int show_vfsmnt(struct seq_file *
6593 seq_path(m, &mnt_path, " \t\n\\");
6597 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6598 err = show_sb_opts(m, sb);
6599 @@ -128,6 +176,11 @@ static int show_mountinfo(struct seq_fil
6600 struct path root = p->root;
6603 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6605 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6608 seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
6609 MAJOR(sb->s_dev), MINOR(sb->s_dev));
6610 if (sb->s_op->show_path)
6611 @@ -187,6 +240,17 @@ static int show_vfsstat(struct seq_file
6612 struct super_block *sb = mnt_path.dentry->d_sb;
6615 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6617 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6620 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6621 + mnt == current->fs->root.mnt) {
6622 + seq_puts(m, "device /dev/root mounted on / ");
6627 if (sb->s_op->show_devname) {
6628 seq_puts(m, "device ");
6629 @@ -203,7 +267,7 @@ static int show_vfsstat(struct seq_file
6630 seq_puts(m, " mounted on ");
6631 seq_path(m, &mnt_path, " \t\n\\");
6635 /* file system type */
6636 seq_puts(m, "with fstype ");
6638 diff -NurpP --minimal linux-3.10.15/fs/quota/dquot.c linux-3.10.15-vs2.3.6.6/fs/quota/dquot.c
6639 --- linux-3.10.15/fs/quota/dquot.c 2013-05-31 13:45:25.000000000 +0000
6640 +++ linux-3.10.15-vs2.3.6.6/fs/quota/dquot.c 2013-08-22 20:30:00.000000000 +0000
6641 @@ -1585,6 +1585,9 @@ int __dquot_alloc_space(struct inode *in
6642 struct dquot **dquots = inode->i_dquot;
6643 int reserve = flags & DQUOT_SPACE_RESERVE;
6645 + if ((ret = dl_alloc_space(inode, number)))
6649 * First test before acquiring mutex - solves deadlocks when we
6650 * re-enter the quota code and are already holding the mutex
6651 @@ -1640,6 +1643,9 @@ int dquot_alloc_inode(const struct inode
6652 struct dquot_warn warn[MAXQUOTAS];
6653 struct dquot * const *dquots = inode->i_dquot;
6655 + if ((ret = dl_alloc_inode(inode)))
6658 /* First test before acquiring mutex - solves deadlocks when we
6659 * re-enter the quota code and are already holding the mutex */
6660 if (!dquot_active(inode))
6661 @@ -1711,6 +1717,8 @@ void __dquot_free_space(struct inode *in
6662 struct dquot **dquots = inode->i_dquot;
6663 int reserve = flags & DQUOT_SPACE_RESERVE;
6665 + dl_free_space(inode, number);
6667 /* First test before acquiring mutex - solves deadlocks when we
6668 * re-enter the quota code and are already holding the mutex */
6669 if (!dquot_active(inode)) {
6670 @@ -1755,6 +1763,8 @@ void dquot_free_inode(const struct inode
6671 struct dquot_warn warn[MAXQUOTAS];
6672 struct dquot * const *dquots = inode->i_dquot;
6674 + dl_free_inode(inode);
6676 /* First test before acquiring mutex - solves deadlocks when we
6677 * re-enter the quota code and are already holding the mutex */
6678 if (!dquot_active(inode))
6679 diff -NurpP --minimal linux-3.10.15/fs/quota/quota.c linux-3.10.15-vs2.3.6.6/fs/quota/quota.c
6680 --- linux-3.10.15/fs/quota/quota.c 2013-02-19 13:58:49.000000000 +0000
6681 +++ linux-3.10.15-vs2.3.6.6/fs/quota/quota.c 2013-08-22 20:30:00.000000000 +0000
6683 #include <linux/fs.h>
6684 #include <linux/namei.h>
6685 #include <linux/slab.h>
6686 +#include <linux/vs_context.h>
6687 #include <asm/current.h>
6688 #include <linux/uaccess.h>
6689 #include <linux/kernel.h>
6690 @@ -37,7 +38,7 @@ static int check_quotactl_permission(str
6694 - if (!capable(CAP_SYS_ADMIN))
6695 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6699 @@ -309,6 +310,46 @@ static int do_quotactl(struct super_bloc
6703 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6705 +#include <linux/vroot.h>
6706 +#include <linux/major.h>
6707 +#include <linux/module.h>
6708 +#include <linux/kallsyms.h>
6709 +#include <linux/vserver/debug.h>
6711 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6713 +static DEFINE_SPINLOCK(vroot_grb_lock);
6715 +int register_vroot_grb(vroot_grb_func *func) {
6718 + spin_lock(&vroot_grb_lock);
6719 + if (!vroot_get_real_bdev) {
6720 + vroot_get_real_bdev = func;
6723 + spin_unlock(&vroot_grb_lock);
6726 +EXPORT_SYMBOL(register_vroot_grb);
6728 +int unregister_vroot_grb(vroot_grb_func *func) {
6729 + int ret = -EINVAL;
6731 + spin_lock(&vroot_grb_lock);
6732 + if (vroot_get_real_bdev) {
6733 + vroot_get_real_bdev = NULL;
6736 + spin_unlock(&vroot_grb_lock);
6739 +EXPORT_SYMBOL(unregister_vroot_grb);
6743 /* Return 1 if 'cmd' will block on frozen filesystem */
6744 static int quotactl_cmd_write(int cmd)
6746 @@ -343,6 +384,22 @@ static struct super_block *quotactl_bloc
6749 return ERR_CAST(bdev);
6750 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6751 + if (bdev && bdev->bd_inode &&
6752 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6753 + struct block_device *bdnew = (void *)-EINVAL;
6755 + if (vroot_get_real_bdev)
6756 + bdnew = vroot_get_real_bdev(bdev);
6758 + vxdprintk(VXD_CBIT(misc, 0),
6759 + "vroot_get_real_bdev not set");
6761 + if (IS_ERR(bdnew))
6762 + return ERR_PTR(PTR_ERR(bdnew));
6766 if (quotactl_cmd_write(cmd))
6767 sb = get_super_thawed(bdev);
6769 diff -NurpP --minimal linux-3.10.15/fs/stat.c linux-3.10.15-vs2.3.6.6/fs/stat.c
6770 --- linux-3.10.15/fs/stat.c 2013-05-31 13:45:25.000000000 +0000
6771 +++ linux-3.10.15-vs2.3.6.6/fs/stat.c 2013-08-22 20:30:00.000000000 +0000
6772 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
6773 stat->nlink = inode->i_nlink;
6774 stat->uid = inode->i_uid;
6775 stat->gid = inode->i_gid;
6776 + stat->tag = inode->i_tag;
6777 stat->rdev = inode->i_rdev;
6778 stat->size = i_size_read(inode);
6779 stat->atime = inode->i_atime;
6780 diff -NurpP --minimal linux-3.10.15/fs/statfs.c linux-3.10.15-vs2.3.6.6/fs/statfs.c
6781 --- linux-3.10.15/fs/statfs.c 2013-02-19 13:58:49.000000000 +0000
6782 +++ linux-3.10.15-vs2.3.6.6/fs/statfs.c 2013-08-22 20:30:00.000000000 +0000
6784 #include <linux/statfs.h>
6785 #include <linux/security.h>
6786 #include <linux/uaccess.h>
6787 +#include <linux/vs_base.h>
6788 +#include <linux/vs_dlimit.h>
6789 #include "internal.h"
6791 static int flags_by_mnt(int mnt_flags)
6792 @@ -60,6 +62,8 @@ static int statfs_by_dentry(struct dentr
6793 retval = dentry->d_sb->s_op->statfs(dentry, buf);
6794 if (retval == 0 && buf->f_frsize == 0)
6795 buf->f_frsize = buf->f_bsize;
6796 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6797 + vx_vsi_statfs(dentry->d_sb, buf);
6801 diff -NurpP --minimal linux-3.10.15/fs/super.c linux-3.10.15-vs2.3.6.6/fs/super.c
6802 --- linux-3.10.15/fs/super.c 2013-10-09 17:35:23.000000000 +0000
6803 +++ linux-3.10.15-vs2.3.6.6/fs/super.c 2013-08-22 20:30:00.000000000 +0000
6805 #include <linux/cleancache.h>
6806 #include <linux/fsnotify.h>
6807 #include <linux/lockdep.h>
6808 +#include <linux/magic.h>
6809 +#include <linux/vs_context.h>
6810 #include "internal.h"
6813 @@ -1112,6 +1114,13 @@ mount_fs(struct file_system_type *type,
6814 WARN_ON(sb->s_bdi == &default_backing_dev_info);
6815 sb->s_flags |= MS_BORN;
6818 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
6820 + (sb->s_magic != PROC_SUPER_MAGIC) &&
6821 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
6824 error = security_sb_kern_mount(sb, flags, secdata);
6827 diff -NurpP --minimal linux-3.10.15/fs/sysfs/mount.c linux-3.10.15-vs2.3.6.6/fs/sysfs/mount.c
6828 --- linux-3.10.15/fs/sysfs/mount.c 2013-05-31 13:45:25.000000000 +0000
6829 +++ linux-3.10.15-vs2.3.6.6/fs/sysfs/mount.c 2013-08-22 20:30:00.000000000 +0000
6830 @@ -48,7 +48,7 @@ static int sysfs_fill_super(struct super
6832 sb->s_blocksize = PAGE_CACHE_SIZE;
6833 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
6834 - sb->s_magic = SYSFS_MAGIC;
6835 + sb->s_magic = SYSFS_SUPER_MAGIC;
6836 sb->s_op = &sysfs_ops;
6837 sb->s_time_gran = 1;
6839 diff -NurpP --minimal linux-3.10.15/fs/utimes.c linux-3.10.15-vs2.3.6.6/fs/utimes.c
6840 --- linux-3.10.15/fs/utimes.c 2013-02-19 13:58:49.000000000 +0000
6841 +++ linux-3.10.15-vs2.3.6.6/fs/utimes.c 2013-08-22 20:30:00.000000000 +0000
6843 #include <linux/stat.h>
6844 #include <linux/utime.h>
6845 #include <linux/syscalls.h>
6846 +#include <linux/mount.h>
6847 +#include <linux/vs_cowbl.h>
6848 #include <asm/uaccess.h>
6849 #include <asm/unistd.h>
6851 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
6854 struct iattr newattrs;
6855 - struct inode *inode = path->dentry->d_inode;
6856 + struct inode *inode;
6858 + error = cow_check_and_break(path);
6862 error = mnt_want_write(path->mnt);
6866 + inode = path->dentry->d_inode;
6868 if (times && times[0].tv_nsec == UTIME_NOW &&
6869 times[1].tv_nsec == UTIME_NOW)
6871 diff -NurpP --minimal linux-3.10.15/fs/xattr.c linux-3.10.15-vs2.3.6.6/fs/xattr.c
6872 --- linux-3.10.15/fs/xattr.c 2013-02-19 13:58:49.000000000 +0000
6873 +++ linux-3.10.15-vs2.3.6.6/fs/xattr.c 2013-08-22 20:30:00.000000000 +0000
6875 #include <linux/audit.h>
6876 #include <linux/vmalloc.h>
6877 #include <linux/posix_acl_xattr.h>
6878 +#include <linux/mount.h>
6880 #include <asm/uaccess.h>
6882 @@ -52,7 +53,7 @@ xattr_permission(struct inode *inode, co
6883 * The trusted.* namespace can only be accessed by privileged users.
6885 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
6886 - if (!capable(CAP_SYS_ADMIN))
6887 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
6888 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
6891 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_dinode.h linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_dinode.h
6892 --- linux-3.10.15/fs/xfs/xfs_dinode.h 2013-07-14 17:01:29.000000000 +0000
6893 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_dinode.h 2013-08-22 20:30:00.000000000 +0000
6894 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
6895 __be32 di_nlink; /* number of links to file */
6896 __be16 di_projid_lo; /* lower part of owner's project id */
6897 __be16 di_projid_hi; /* higher part owner's project id */
6898 - __u8 di_pad[6]; /* unused, zeroed space */
6899 + __u8 di_pad[2]; /* unused, zeroed space */
6900 + __be16 di_tag; /* context tagging */
6901 + __be16 di_vflags; /* vserver specific flags */
6902 __be16 di_flushiter; /* incremented on flush */
6903 xfs_timestamp_t di_atime; /* time last accessed */
6904 xfs_timestamp_t di_mtime; /* time last modified */
6905 @@ -209,6 +211,8 @@ static inline void xfs_dinode_put_rdev(s
6906 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
6907 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
6908 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
6909 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
6911 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
6912 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
6913 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
6914 @@ -224,6 +228,7 @@ static inline void xfs_dinode_put_rdev(s
6915 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
6916 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
6917 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
6918 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
6920 #ifdef CONFIG_XFS_RT
6921 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
6922 @@ -236,6 +241,10 @@ static inline void xfs_dinode_put_rdev(s
6923 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
6924 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
6925 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
6926 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
6927 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
6928 + XFS_DIFLAG_IXUNLINK)
6930 +#define XFS_DIVFLAG_BARRIER 0x01
6931 +#define XFS_DIVFLAG_COW 0x02
6933 #endif /* __XFS_DINODE_H__ */
6934 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_fs.h linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_fs.h
6935 --- linux-3.10.15/fs/xfs/xfs_fs.h 2013-07-14 17:01:29.000000000 +0000
6936 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_fs.h 2013-08-22 20:30:00.000000000 +0000
6937 @@ -67,6 +67,9 @@ struct fsxattr {
6938 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
6939 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
6940 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
6941 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
6942 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
6943 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
6944 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
6947 @@ -304,7 +307,8 @@ typedef struct xfs_bstat {
6948 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
6949 __u16 bs_forkoff; /* inode fork offset in bytes */
6950 __u16 bs_projid_hi; /* higher part of project id */
6951 - unsigned char bs_pad[10]; /* pad space, unused */
6952 + unsigned char bs_pad[8]; /* pad space, unused */
6953 + __u16 bs_tag; /* context tagging */
6954 __u32 bs_dmevmask; /* DMIG event mask */
6955 __u16 bs_dmstate; /* DMIG state info */
6956 __u16 bs_aextents; /* attribute number of extents */
6957 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_ialloc.c linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_ialloc.c
6958 --- linux-3.10.15/fs/xfs/xfs_ialloc.c 2013-07-14 17:01:29.000000000 +0000
6959 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_ialloc.c 2013-08-22 20:30:00.000000000 +0000
6961 #include "xfs_cksum.h"
6962 #include "xfs_buf_item.h"
6966 * Allocation group level functions.
6968 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_inode.c linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_inode.c
6969 --- linux-3.10.15/fs/xfs/xfs_inode.c 2013-07-14 17:01:29.000000000 +0000
6970 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_inode.c 2013-08-22 21:50:34.000000000 +0000
6972 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
6974 #include <linux/log2.h>
6975 +#include <linux/vs_tag.h>
6979 @@ -836,15 +837,25 @@ xfs_iformat_btree(
6981 xfs_dinode_from_disk(
6983 - xfs_dinode_t *from)
6984 + xfs_dinode_t *from,
6987 + uint32_t uid, gid, tag;
6989 to->di_magic = be16_to_cpu(from->di_magic);
6990 to->di_mode = be16_to_cpu(from->di_mode);
6991 to->di_version = from ->di_version;
6992 to->di_format = from->di_format;
6993 to->di_onlink = be16_to_cpu(from->di_onlink);
6994 - to->di_uid = be32_to_cpu(from->di_uid);
6995 - to->di_gid = be32_to_cpu(from->di_gid);
6997 + uid = be32_to_cpu(from->di_uid);
6998 + gid = be32_to_cpu(from->di_gid);
6999 + tag = be16_to_cpu(from->di_tag);
7001 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7002 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7003 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7005 to->di_nlink = be32_to_cpu(from->di_nlink);
7006 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7007 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7008 @@ -866,6 +877,7 @@ xfs_dinode_from_disk(
7009 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7010 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7011 to->di_flags = be16_to_cpu(from->di_flags);
7012 + to->di_vflags = be16_to_cpu(from->di_vflags);
7013 to->di_gen = be32_to_cpu(from->di_gen);
7015 if (to->di_version == 3) {
7016 @@ -883,15 +895,19 @@ xfs_dinode_from_disk(
7020 - xfs_icdinode_t *from)
7021 + xfs_icdinode_t *from,
7024 to->di_magic = cpu_to_be16(from->di_magic);
7025 to->di_mode = cpu_to_be16(from->di_mode);
7026 to->di_version = from ->di_version;
7027 to->di_format = from->di_format;
7028 to->di_onlink = cpu_to_be16(from->di_onlink);
7029 - to->di_uid = cpu_to_be32(from->di_uid);
7030 - to->di_gid = cpu_to_be32(from->di_gid);
7032 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
7033 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
7034 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
7036 to->di_nlink = cpu_to_be32(from->di_nlink);
7037 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
7038 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
7039 @@ -913,6 +929,7 @@ xfs_dinode_to_disk(
7040 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
7041 to->di_dmstate = cpu_to_be16(from->di_dmstate);
7042 to->di_flags = cpu_to_be16(from->di_flags);
7043 + to->di_vflags = cpu_to_be16(from->di_vflags);
7044 to->di_gen = cpu_to_be32(from->di_gen);
7046 if (from->di_version == 3) {
7047 @@ -929,7 +946,8 @@ xfs_dinode_to_disk(
7051 - __uint16_t di_flags)
7052 + __uint16_t di_flags,
7053 + __uint16_t di_vflags)
7057 @@ -940,6 +958,8 @@ _xfs_dic2xflags(
7058 flags |= XFS_XFLAG_PREALLOC;
7059 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7060 flags |= XFS_XFLAG_IMMUTABLE;
7061 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7062 + flags |= XFS_XFLAG_IXUNLINK;
7063 if (di_flags & XFS_DIFLAG_APPEND)
7064 flags |= XFS_XFLAG_APPEND;
7065 if (di_flags & XFS_DIFLAG_SYNC)
7066 @@ -964,6 +984,10 @@ _xfs_dic2xflags(
7067 flags |= XFS_XFLAG_FILESTREAM;
7070 + if (di_vflags & XFS_DIVFLAG_BARRIER)
7071 + flags |= FS_BARRIER_FL;
7072 + if (di_vflags & XFS_DIVFLAG_COW)
7073 + flags |= FS_COW_FL;
7077 @@ -973,7 +997,7 @@ xfs_ip2xflags(
7079 xfs_icdinode_t *dic = &ip->i_d;
7081 - return _xfs_dic2xflags(dic->di_flags) |
7082 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
7083 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
7086 @@ -981,7 +1005,8 @@ uint
7090 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
7091 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
7092 + be16_to_cpu(dip->di_vflags)) |
7093 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
7096 @@ -1072,7 +1097,8 @@ xfs_iread(
7097 * Otherwise, just get the truly permanent information.
7100 - xfs_dinode_from_disk(&ip->i_d, dip);
7101 + xfs_dinode_from_disk(&ip->i_d, dip,
7102 + mp->m_flags & XFS_MOUNT_TAGGED);
7103 error = xfs_iformat(ip, dip);
7106 @@ -1270,6 +1296,7 @@ xfs_ialloc(
7107 ASSERT(ip->i_d.di_nlink == nlink);
7108 ip->i_d.di_uid = current_fsuid();
7109 ip->i_d.di_gid = current_fsgid();
7110 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
7111 xfs_set_projid(ip, prid);
7112 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
7114 @@ -1329,6 +1356,7 @@ xfs_ialloc(
7115 ip->i_d.di_dmevmask = 0;
7116 ip->i_d.di_dmstate = 0;
7117 ip->i_d.di_flags = 0;
7118 + ip->i_d.di_vflags = 0;
7120 if (ip->i_d.di_version == 3) {
7121 ASSERT(ip->i_d.di_ino == ino);
7122 @@ -2052,6 +2080,7 @@ xfs_ifree(
7124 ip->i_d.di_mode = 0; /* mark incore inode as free */
7125 ip->i_d.di_flags = 0;
7126 + ip->i_d.di_vflags = 0;
7127 ip->i_d.di_dmevmask = 0;
7128 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
7129 ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
7130 @@ -2219,7 +2248,6 @@ xfs_iroot_realloc(
7136 * This is called when the amount of space needed for if_data
7137 * is increased or decreased. The change in size is indicated by
7138 @@ -2899,7 +2927,8 @@ xfs_iflush_int(
7139 * because if the inode is dirty at all the core must
7142 - xfs_dinode_to_disk(dip, &ip->i_d);
7143 + xfs_dinode_to_disk(dip, &ip->i_d,
7144 + mp->m_flags & XFS_MOUNT_TAGGED);
7146 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7147 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7148 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_inode.h linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_inode.h
7149 --- linux-3.10.15/fs/xfs/xfs_inode.h 2013-07-14 17:01:30.000000000 +0000
7150 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_inode.h 2013-08-22 20:30:00.000000000 +0000
7151 @@ -134,7 +134,9 @@ typedef struct xfs_icdinode {
7152 __uint32_t di_nlink; /* number of links to file */
7153 __uint16_t di_projid_lo; /* lower part of owner's project id */
7154 __uint16_t di_projid_hi; /* higher part of owner's project id */
7155 - __uint8_t di_pad[6]; /* unused, zeroed space */
7156 + __uint8_t di_pad[2]; /* unused, zeroed space */
7157 + __uint16_t di_tag; /* context tagging */
7158 + __uint16_t di_vflags; /* vserver specific flags */
7159 __uint16_t di_flushiter; /* incremented on flush */
7160 xfs_ictimestamp_t di_atime; /* time last accessed */
7161 xfs_ictimestamp_t di_mtime; /* time last modified */
7162 @@ -583,7 +585,7 @@ int xfs_iread(struct xfs_mount *, struc
7163 struct xfs_inode *, uint);
7164 void xfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *);
7165 void xfs_dinode_to_disk(struct xfs_dinode *,
7166 - struct xfs_icdinode *);
7167 + struct xfs_icdinode *, int);
7168 void xfs_idestroy_fork(struct xfs_inode *, int);
7169 void xfs_idata_realloc(struct xfs_inode *, int, int);
7170 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7171 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_ioctl.c linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_ioctl.c
7172 --- linux-3.10.15/fs/xfs/xfs_ioctl.c 2013-07-14 17:01:30.000000000 +0000
7173 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_ioctl.c 2013-08-22 20:30:00.000000000 +0000
7175 #include "xfs_bmap_btree.h"
7176 #include "xfs_dinode.h"
7177 #include "xfs_inode.h"
7178 -#include "xfs_ioctl.h"
7179 +// #include "xfs_ioctl.h"
7180 #include "xfs_rtalloc.h"
7181 #include "xfs_itable.h"
7182 #include "xfs_error.h"
7183 @@ -769,6 +769,10 @@ xfs_merge_ioc_xflags(
7184 xflags |= XFS_XFLAG_IMMUTABLE;
7186 xflags &= ~XFS_XFLAG_IMMUTABLE;
7187 + if (flags & FS_IXUNLINK_FL)
7188 + xflags |= XFS_XFLAG_IXUNLINK;
7190 + xflags &= ~XFS_XFLAG_IXUNLINK;
7191 if (flags & FS_APPEND_FL)
7192 xflags |= XFS_XFLAG_APPEND;
7194 @@ -797,6 +801,8 @@ xfs_di2lxflags(
7196 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7197 flags |= FS_IMMUTABLE_FL;
7198 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7199 + flags |= FS_IXUNLINK_FL;
7200 if (di_flags & XFS_DIFLAG_APPEND)
7201 flags |= FS_APPEND_FL;
7202 if (di_flags & XFS_DIFLAG_SYNC)
7203 @@ -857,6 +863,8 @@ xfs_set_diflags(
7204 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7205 if (xflags & XFS_XFLAG_IMMUTABLE)
7206 di_flags |= XFS_DIFLAG_IMMUTABLE;
7207 + if (xflags & XFS_XFLAG_IXUNLINK)
7208 + di_flags |= XFS_DIFLAG_IXUNLINK;
7209 if (xflags & XFS_XFLAG_APPEND)
7210 di_flags |= XFS_DIFLAG_APPEND;
7211 if (xflags & XFS_XFLAG_SYNC)
7212 @@ -899,6 +907,10 @@ xfs_diflags_to_linux(
7213 inode->i_flags |= S_IMMUTABLE;
7215 inode->i_flags &= ~S_IMMUTABLE;
7216 + if (xflags & XFS_XFLAG_IXUNLINK)
7217 + inode->i_flags |= S_IXUNLINK;
7219 + inode->i_flags &= ~S_IXUNLINK;
7220 if (xflags & XFS_XFLAG_APPEND)
7221 inode->i_flags |= S_APPEND;
7223 @@ -1403,10 +1415,18 @@ xfs_file_ioctl(
7224 case XFS_IOC_FSGETXATTRA:
7225 return xfs_ioc_fsgetxattr(ip, 1, arg);
7226 case XFS_IOC_FSSETXATTR:
7227 + if (IS_BARRIER(inode)) {
7228 + vxwprintk_task(1, "messing with the barrier.");
7229 + return -XFS_ERROR(EACCES);
7231 return xfs_ioc_fssetxattr(ip, filp, arg);
7232 case XFS_IOC_GETXFLAGS:
7233 return xfs_ioc_getxflags(ip, arg);
7234 case XFS_IOC_SETXFLAGS:
7235 + if (IS_BARRIER(inode)) {
7236 + vxwprintk_task(1, "messing with the barrier.");
7237 + return -XFS_ERROR(EACCES);
7239 return xfs_ioc_setxflags(ip, filp, arg);
7241 case XFS_IOC_FSSETDM: {
7242 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_ioctl.h linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_ioctl.h
7243 --- linux-3.10.15/fs/xfs/xfs_ioctl.h 2012-12-11 03:30:57.000000000 +0000
7244 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_ioctl.h 2013-08-22 20:30:00.000000000 +0000
7245 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7246 void __user *uhandle,
7251 + struct inode *inode,
7258 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_iops.c linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_iops.c
7259 --- linux-3.10.15/fs/xfs/xfs_iops.c 2013-07-14 17:01:30.000000000 +0000
7260 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_iops.c 2013-08-22 20:30:00.000000000 +0000
7262 #include "xfs_bmap_btree.h"
7263 #include "xfs_dinode.h"
7264 #include "xfs_inode.h"
7265 +#include "xfs_ioctl.h"
7266 #include "xfs_bmap.h"
7267 #include "xfs_rtalloc.h"
7268 #include "xfs_error.h"
7270 #include <linux/security.h>
7271 #include <linux/fiemap.h>
7272 #include <linux/slab.h>
7273 +#include <linux/vs_tag.h>
7277 @@ -422,6 +424,7 @@ xfs_vn_getattr(
7278 stat->nlink = ip->i_d.di_nlink;
7279 stat->uid = ip->i_d.di_uid;
7280 stat->gid = ip->i_d.di_gid;
7281 + stat->tag = ip->i_d.di_tag;
7282 stat->ino = ip->i_ino;
7283 stat->atime = inode->i_atime;
7284 stat->mtime = inode->i_mtime;
7285 @@ -1054,6 +1057,7 @@ static const struct inode_operations xfs
7286 .listxattr = xfs_vn_listxattr,
7287 .fiemap = xfs_vn_fiemap,
7288 .update_time = xfs_vn_update_time,
7289 + .sync_flags = xfs_sync_flags,
7292 static const struct inode_operations xfs_dir_inode_operations = {
7293 @@ -1080,6 +1084,7 @@ static const struct inode_operations xfs
7294 .removexattr = generic_removexattr,
7295 .listxattr = xfs_vn_listxattr,
7296 .update_time = xfs_vn_update_time,
7297 + .sync_flags = xfs_sync_flags,
7300 static const struct inode_operations xfs_dir_ci_inode_operations = {
7301 @@ -1131,6 +1136,10 @@ xfs_diflags_to_iflags(
7302 inode->i_flags |= S_IMMUTABLE;
7304 inode->i_flags &= ~S_IMMUTABLE;
7305 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7306 + inode->i_flags |= S_IXUNLINK;
7308 + inode->i_flags &= ~S_IXUNLINK;
7309 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7310 inode->i_flags |= S_APPEND;
7312 @@ -1143,6 +1152,15 @@ xfs_diflags_to_iflags(
7313 inode->i_flags |= S_NOATIME;
7315 inode->i_flags &= ~S_NOATIME;
7317 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7318 + inode->i_vflags |= V_BARRIER;
7320 + inode->i_vflags &= ~V_BARRIER;
7321 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7322 + inode->i_vflags |= V_COW;
7324 + inode->i_vflags &= ~V_COW;
7328 @@ -1174,6 +1192,7 @@ xfs_setup_inode(
7329 set_nlink(inode, ip->i_d.di_nlink);
7330 inode->i_uid = ip->i_d.di_uid;
7331 inode->i_gid = ip->i_d.di_gid;
7332 + inode->i_tag = ip->i_d.di_tag;
7334 switch (inode->i_mode & S_IFMT) {
7336 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_itable.c linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_itable.c
7337 --- linux-3.10.15/fs/xfs/xfs_itable.c 2013-02-19 13:58:49.000000000 +0000
7338 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_itable.c 2013-08-22 20:30:00.000000000 +0000
7339 @@ -97,6 +97,7 @@ xfs_bulkstat_one_int(
7340 buf->bs_mode = dic->di_mode;
7341 buf->bs_uid = dic->di_uid;
7342 buf->bs_gid = dic->di_gid;
7343 + buf->bs_tag = dic->di_tag;
7344 buf->bs_size = dic->di_size;
7345 buf->bs_atime.tv_sec = dic->di_atime.t_sec;
7346 buf->bs_atime.tv_nsec = dic->di_atime.t_nsec;
7347 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_linux.h linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_linux.h
7348 --- linux-3.10.15/fs/xfs/xfs_linux.h 2013-07-14 17:01:30.000000000 +0000
7349 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_linux.h 2013-08-22 20:30:00.000000000 +0000
7352 #define current_cpu() (raw_smp_processor_id())
7353 #define current_pid() (current->pid)
7354 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7355 #define current_test_flags(f) (current->flags & (f))
7356 #define current_set_flags_nested(sp, f) \
7357 (*(sp) = current->flags, current->flags |= (f))
7358 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_log_recover.c linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_log_recover.c
7359 --- linux-3.10.15/fs/xfs/xfs_log_recover.c 2013-07-14 17:01:31.000000000 +0000
7360 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_log_recover.c 2013-08-22 21:48:01.000000000 +0000
7361 @@ -2662,7 +2662,7 @@ xlog_recover_inode_pass2(
7364 /* The core is in in-core format */
7365 - xfs_dinode_to_disk(dip, dicp);
7366 + xfs_dinode_to_disk(dip, dicp, mp->m_flags & XFS_MOUNT_TAGGED);
7368 /* the rest is in on-disk format */
7369 if (item->ri_buf[1].i_len > isize) {
7370 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_mount.h linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_mount.h
7371 --- linux-3.10.15/fs/xfs/xfs_mount.h 2013-07-14 17:01:31.000000000 +0000
7372 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_mount.h 2013-08-22 20:30:00.000000000 +0000
7373 @@ -253,6 +253,7 @@ typedef struct xfs_mount {
7375 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7377 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7380 * Default minimum read and write sizes.
7381 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_super.c linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_super.c
7382 --- linux-3.10.15/fs/xfs/xfs_super.c 2013-07-14 17:01:31.000000000 +0000
7383 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_super.c 2013-08-22 20:30:00.000000000 +0000
7384 @@ -114,6 +114,9 @@ mempool_t *xfs_ioend_pool;
7385 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7386 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7387 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7388 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7389 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7390 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7393 * Table driven mount option parser.
7394 @@ -126,6 +129,8 @@ enum {
7403 @@ -134,6 +139,9 @@ static const match_table_t tokens = {
7404 {Opt_nobarrier, "nobarrier"},
7405 {Opt_inode64, "inode64"},
7406 {Opt_inode32, "inode32"},
7407 + {Opt_tag, "tagxid"},
7409 + {Opt_notag, "notag"},
7413 @@ -392,6 +400,19 @@ xfs_parseargs(
7414 } else if (!strcmp(this_char, "irixsgid")) {
7416 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7417 +#ifndef CONFIG_TAGGING_NONE
7418 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7419 + mp->m_flags |= XFS_MOUNT_TAGGED;
7420 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7421 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7422 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7423 + mp->m_flags |= XFS_MOUNT_TAGGED;
7425 +#ifdef CONFIG_PROPAGATE
7426 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7428 + mp->m_flags |= XFS_MOUNT_TAGGED;
7431 xfs_warn(mp, "unknown mount option [%s].", this_char);
7433 @@ -1238,6 +1259,16 @@ xfs_fs_remount(
7435 mp->m_maxagi = xfs_set_inode32(mp);
7438 + if (!(sb->s_flags & MS_TAGGED)) {
7440 + "XFS: %s: tagging not permitted on remount.\n",
7449 * Logically we would return an error here to prevent
7450 @@ -1469,6 +1500,9 @@ xfs_fs_fill_super(
7454 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7455 + sb->s_flags |= MS_TAGGED;
7458 * we must configure the block size in the superblock before we run the
7459 * full mount process as the mount process can lookup and cache inodes.
7460 diff -NurpP --minimal linux-3.10.15/fs/xfs/xfs_vnodeops.c linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_vnodeops.c
7461 --- linux-3.10.15/fs/xfs/xfs_vnodeops.c 2013-07-14 17:01:31.000000000 +0000
7462 +++ linux-3.10.15-vs2.3.6.6/fs/xfs/xfs_vnodeops.c 2013-08-22 20:30:00.000000000 +0000
7463 @@ -155,6 +155,77 @@ xfs_free_eofblocks(
7469 +xfs_get_inode_flags(
7472 + struct inode *inode = VFS_I(ip);
7473 + unsigned int flags = inode->i_flags;
7474 + unsigned int vflags = inode->i_vflags;
7476 + if (flags & S_IMMUTABLE)
7477 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7479 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7480 + if (flags & S_IXUNLINK)
7481 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
7483 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
7485 + if (vflags & V_BARRIER)
7486 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
7488 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
7489 + if (vflags & V_COW)
7490 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
7492 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
7497 + struct inode *inode,
7501 + struct xfs_inode *ip = XFS_I(inode);
7502 + struct xfs_mount *mp = ip->i_mount;
7503 + struct xfs_trans *tp;
7504 + unsigned int lock_flags = 0;
7507 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
7508 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
7512 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7513 + xfs_trans_ijoin(tp, ip, 0);
7515 + inode->i_flags = flags;
7516 + inode->i_vflags = vflags;
7517 + xfs_get_inode_flags(ip);
7519 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
7520 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
7522 + XFS_STATS_INC(xs_ig_attrchg);
7524 + if (mp->m_flags & XFS_MOUNT_WSYNC)
7525 + xfs_trans_set_sync(tp);
7526 + code = xfs_trans_commit(tp, 0);
7527 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7531 + xfs_trans_cancel(tp, 0);
7533 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7541 diff -NurpP --minimal linux-3.10.15/include/linux/cred.h linux-3.10.15-vs2.3.6.6/include/linux/cred.h
7542 --- linux-3.10.15/include/linux/cred.h 2013-02-19 13:58:50.000000000 +0000
7543 +++ linux-3.10.15-vs2.3.6.6/include/linux/cred.h 2013-08-22 20:30:00.000000000 +0000
7544 @@ -143,6 +143,7 @@ extern void exit_creds(struct task_struc
7545 extern int copy_creds(struct task_struct *, unsigned long);
7546 extern const struct cred *get_task_cred(struct task_struct *);
7547 extern struct cred *cred_alloc_blank(void);
7548 +extern struct cred *__prepare_creds(const struct cred *);
7549 extern struct cred *prepare_creds(void);
7550 extern struct cred *prepare_exec_creds(void);
7551 extern int commit_creds(struct cred *);
7552 @@ -196,6 +197,31 @@ static inline void validate_process_cred
7556 +static inline void set_cred_subscribers(struct cred *cred, int n)
7558 +#ifdef CONFIG_DEBUG_CREDENTIALS
7559 + atomic_set(&cred->subscribers, n);
7563 +static inline int read_cred_subscribers(const struct cred *cred)
7565 +#ifdef CONFIG_DEBUG_CREDENTIALS
7566 + return atomic_read(&cred->subscribers);
7572 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
7574 +#ifdef CONFIG_DEBUG_CREDENTIALS
7575 + struct cred *cred = (struct cred *) _cred;
7577 + atomic_add(n, &cred->subscribers);
7582 * get_new_cred - Get a reference on a new set of credentials
7583 * @cred: The new credentials to reference
7584 diff -NurpP --minimal linux-3.10.15/include/linux/devpts_fs.h linux-3.10.15-vs2.3.6.6/include/linux/devpts_fs.h
7585 --- linux-3.10.15/include/linux/devpts_fs.h 2013-02-19 13:58:50.000000000 +0000
7586 +++ linux-3.10.15-vs2.3.6.6/include/linux/devpts_fs.h 2013-08-22 20:30:00.000000000 +0000
7587 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
7592 #endif /* _LINUX_DEVPTS_FS_H */
7593 diff -NurpP --minimal linux-3.10.15/include/linux/fs.h linux-3.10.15-vs2.3.6.6/include/linux/fs.h
7594 --- linux-3.10.15/include/linux/fs.h 2013-07-14 17:01:32.000000000 +0000
7595 +++ linux-3.10.15-vs2.3.6.6/include/linux/fs.h 2013-08-22 20:30:00.000000000 +0000
7596 @@ -211,6 +211,7 @@ typedef void (dio_iodone_t)(struct kiocb
7597 #define ATTR_KILL_PRIV (1 << 14)
7598 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
7599 #define ATTR_TIMES_SET (1 << 16)
7600 +#define ATTR_TAG (1 << 17)
7603 * This is the Inode Attributes structure, used for notify_change(). It
7604 @@ -226,6 +227,7 @@ struct iattr {
7610 struct timespec ia_atime;
7611 struct timespec ia_mtime;
7612 @@ -523,7 +525,9 @@ struct inode {
7613 unsigned short i_opflags;
7616 - unsigned int i_flags;
7618 + unsigned short i_flags;
7619 + unsigned short i_vflags;
7621 #ifdef CONFIG_FS_POSIX_ACL
7622 struct posix_acl *i_acl;
7623 @@ -552,6 +556,7 @@ struct inode {
7624 unsigned int __i_nlink;
7629 struct timespec i_atime;
7630 struct timespec i_mtime;
7631 @@ -704,6 +709,11 @@ static inline gid_t i_gid_read(const str
7632 return from_kgid(&init_user_ns, inode->i_gid);
7635 +static inline vtag_t i_tag_read(const struct inode *inode)
7637 + return from_ktag(&init_user_ns, inode->i_tag);
7640 static inline void i_uid_write(struct inode *inode, uid_t uid)
7642 inode->i_uid = make_kuid(&init_user_ns, uid);
7643 @@ -714,14 +724,19 @@ static inline void i_gid_write(struct in
7644 inode->i_gid = make_kgid(&init_user_ns, gid);
7647 +static inline void i_tag_write(struct inode *inode, vtag_t tag)
7649 + inode->i_tag = make_ktag(&init_user_ns, tag);
7652 static inline unsigned iminor(const struct inode *inode)
7654 - return MINOR(inode->i_rdev);
7655 + return MINOR(inode->i_mdev);
7658 static inline unsigned imajor(const struct inode *inode)
7660 - return MAJOR(inode->i_rdev);
7661 + return MAJOR(inode->i_mdev);
7664 extern struct block_device *I_BDEV(struct inode *inode);
7665 @@ -788,6 +803,7 @@ struct file {
7667 struct fown_struct f_owner;
7668 const struct cred *f_cred;
7670 struct file_ra_state f_ra;
7673 @@ -939,6 +955,7 @@ struct file_lock {
7674 struct file *fl_file;
7679 struct fasync_struct * fl_fasync; /* for lease break notifications */
7680 /* for lease breaks: */
7681 @@ -1569,6 +1586,7 @@ struct inode_operations {
7682 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
7683 ssize_t (*listxattr) (struct dentry *, char *, size_t);
7684 int (*removexattr) (struct dentry *, const char *);
7685 + int (*sync_flags) (struct inode *, int, int);
7686 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
7688 int (*update_time)(struct inode *, struct timespec *, int);
7689 @@ -1581,6 +1599,7 @@ ssize_t rw_copy_check_uvector(int type,
7690 unsigned long nr_segs, unsigned long fast_segs,
7691 struct iovec *fast_pointer,
7692 struct iovec **ret_pointer);
7693 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
7695 extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
7696 extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
7697 @@ -1634,6 +1653,14 @@ struct super_operations {
7698 #define S_IMA 1024 /* Inode has an associated IMA struct */
7699 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
7700 #define S_NOSEC 4096 /* no suid or xattr security attributes */
7701 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
7703 +/* Linux-VServer related Inode flags */
7707 +#define V_BARRIER 4 /* Barrier for chroot() */
7708 +#define V_COW 8 /* Copy on Write */
7711 * Note that nosuid etc flags are inode-specific: setting some file-system
7712 @@ -1658,10 +1685,13 @@ struct super_operations {
7713 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
7714 #define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
7715 #define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
7716 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
7718 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
7719 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
7720 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
7721 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
7722 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
7723 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
7725 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
7726 @@ -1672,6 +1702,16 @@ struct super_operations {
7727 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
7728 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
7730 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
7732 +#ifdef CONFIG_VSERVER_COWBL
7733 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
7734 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
7736 +# define IS_COW(inode) (0)
7737 +# define IS_COW_LINK(inode) (0)
7741 * Inode state bits. Protected by inode->i_lock
7743 @@ -1900,6 +1940,9 @@ extern int rw_verify_area(int, struct fi
7744 extern int locks_mandatory_locked(struct inode *);
7745 extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
7747 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
7748 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
7751 * Candidates for mandatory locking have the setgid bit set
7752 * but no group execute bit - an otherwise meaningless combination.
7753 @@ -2525,6 +2568,7 @@ extern int dcache_dir_open(struct inode
7754 extern int dcache_dir_close(struct inode *, struct file *);
7755 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
7756 extern int dcache_readdir(struct file *, void *, filldir_t);
7757 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
7758 extern int simple_setattr(struct dentry *, struct iattr *);
7759 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
7760 extern int simple_statfs(struct dentry *, struct kstatfs *);
7761 diff -NurpP --minimal linux-3.10.15/include/linux/init_task.h linux-3.10.15-vs2.3.6.6/include/linux/init_task.h
7762 --- linux-3.10.15/include/linux/init_task.h 2013-05-31 13:45:27.000000000 +0000
7763 +++ linux-3.10.15-vs2.3.6.6/include/linux/init_task.h 2013-08-22 20:30:00.000000000 +0000
7764 @@ -222,6 +222,10 @@ extern struct task_group root_task_group
7765 INIT_TASK_RCU_PREEMPT(tsk) \
7769 + .vx_info = NULL, \
7771 + .nx_info = NULL, \
7775 diff -NurpP --minimal linux-3.10.15/include/linux/ipc.h linux-3.10.15-vs2.3.6.6/include/linux/ipc.h
7776 --- linux-3.10.15/include/linux/ipc.h 2012-12-11 03:30:57.000000000 +0000
7777 +++ linux-3.10.15-vs2.3.6.6/include/linux/ipc.h 2013-08-22 20:30:00.000000000 +0000
7778 @@ -16,6 +16,7 @@ struct kern_ipc_perm
7786 diff -NurpP --minimal linux-3.10.15/include/linux/loop.h linux-3.10.15-vs2.3.6.6/include/linux/loop.h
7787 --- linux-3.10.15/include/linux/loop.h 2013-02-19 13:58:51.000000000 +0000
7788 +++ linux-3.10.15-vs2.3.6.6/include/linux/loop.h 2013-08-22 20:30:00.000000000 +0000
7789 @@ -41,6 +41,7 @@ struct loop_device {
7790 struct loop_func_table *lo_encryption;
7792 kuid_t lo_key_owner; /* Who set the key */
7794 int (*ioctl)(struct loop_device *, int cmd,
7797 diff -NurpP --minimal linux-3.10.15/include/linux/memcontrol.h linux-3.10.15-vs2.3.6.6/include/linux/memcontrol.h
7798 --- linux-3.10.15/include/linux/memcontrol.h 2013-05-31 13:45:28.000000000 +0000
7799 +++ linux-3.10.15-vs2.3.6.6/include/linux/memcontrol.h 2013-08-22 20:30:00.000000000 +0000
7800 @@ -86,6 +86,13 @@ extern struct mem_cgroup *try_get_mem_cg
7801 extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg);
7802 extern struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont);
7804 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
7805 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
7807 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
7808 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
7809 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
7812 bool mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *memcg)
7814 diff -NurpP --minimal linux-3.10.15/include/linux/mm_types.h linux-3.10.15-vs2.3.6.6/include/linux/mm_types.h
7815 --- linux-3.10.15/include/linux/mm_types.h 2013-10-09 17:35:23.000000000 +0000
7816 +++ linux-3.10.15-vs2.3.6.6/include/linux/mm_types.h 2013-10-09 17:37:22.000000000 +0000
7817 @@ -381,6 +381,7 @@ struct mm_struct {
7819 /* Architecture-specific MM context */
7820 mm_context_t context;
7821 + struct vx_info *mm_vx_info;
7823 unsigned long flags; /* Must use atomic bitops to access the bits */
7825 diff -NurpP --minimal linux-3.10.15/include/linux/mount.h linux-3.10.15-vs2.3.6.6/include/linux/mount.h
7826 --- linux-3.10.15/include/linux/mount.h 2013-05-31 13:45:28.000000000 +0000
7827 +++ linux-3.10.15-vs2.3.6.6/include/linux/mount.h 2013-08-22 20:30:00.000000000 +0000
7828 @@ -49,6 +49,9 @@ struct mnt_namespace;
7830 #define MNT_LOCK_READONLY 0x400000
7832 +#define MNT_TAGID 0x10000
7833 +#define MNT_NOTAG 0x20000
7836 struct dentry *mnt_root; /* root of the mounted tree */
7837 struct super_block *mnt_sb; /* pointer to superblock */
7838 diff -NurpP --minimal linux-3.10.15/include/linux/net.h linux-3.10.15-vs2.3.6.6/include/linux/net.h
7839 --- linux-3.10.15/include/linux/net.h 2013-07-14 17:01:32.000000000 +0000
7840 +++ linux-3.10.15-vs2.3.6.6/include/linux/net.h 2013-08-22 20:30:00.000000000 +0000
7841 @@ -38,6 +38,7 @@ struct net;
7842 #define SOCK_PASSCRED 3
7843 #define SOCK_PASSSEC 4
7844 #define SOCK_EXTERNALLY_ALLOCATED 5
7845 +#define SOCK_USER_SOCKET 6
7847 #ifndef ARCH_HAS_SOCKET_TYPES
7849 diff -NurpP --minimal linux-3.10.15/include/linux/netdevice.h linux-3.10.15-vs2.3.6.6/include/linux/netdevice.h
7850 --- linux-3.10.15/include/linux/netdevice.h 2013-07-14 17:01:32.000000000 +0000
7851 +++ linux-3.10.15-vs2.3.6.6/include/linux/netdevice.h 2013-08-22 20:30:00.000000000 +0000
7852 @@ -1694,6 +1694,7 @@ extern int init_dummy_netdev(struct net
7854 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
7855 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
7856 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
7857 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
7858 extern int netdev_get_name(struct net *net, char *name, int ifindex);
7859 extern int dev_restart(struct net_device *dev);
7860 diff -NurpP --minimal linux-3.10.15/include/linux/nsproxy.h linux-3.10.15-vs2.3.6.6/include/linux/nsproxy.h
7861 --- linux-3.10.15/include/linux/nsproxy.h 2013-02-19 13:58:51.000000000 +0000
7862 +++ linux-3.10.15-vs2.3.6.6/include/linux/nsproxy.h 2013-08-22 20:30:00.000000000 +0000
7865 #include <linux/spinlock.h>
7866 #include <linux/sched.h>
7867 +#include <linux/vserver/debug.h>
7869 struct mnt_namespace;
7870 struct uts_namespace;
7871 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
7874 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
7875 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
7876 void exit_task_namespaces(struct task_struct *tsk);
7877 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
7878 void free_nsproxy(struct nsproxy *ns);
7879 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
7880 struct cred *, struct fs_struct *);
7881 int __init nsproxy_cache_init(void);
7883 -static inline void put_nsproxy(struct nsproxy *ns)
7884 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
7886 +static inline void __get_nsproxy(struct nsproxy *ns,
7887 + const char *_file, int _line)
7889 - if (atomic_dec_and_test(&ns->count)) {
7892 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
7893 + ns, atomic_read(&ns->count), _file, _line);
7894 + atomic_inc(&ns->count);
7897 -static inline void get_nsproxy(struct nsproxy *ns)
7898 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
7900 +static inline void __put_nsproxy(struct nsproxy *ns,
7901 + const char *_file, int _line)
7903 - atomic_inc(&ns->count);
7904 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
7905 + ns, atomic_read(&ns->count), _file, _line);
7906 + if (atomic_dec_and_test(&ns->count)) {
7912 diff -NurpP --minimal linux-3.10.15/include/linux/pid.h linux-3.10.15-vs2.3.6.6/include/linux/pid.h
7913 --- linux-3.10.15/include/linux/pid.h 2013-05-31 13:45:28.000000000 +0000
7914 +++ linux-3.10.15-vs2.3.6.6/include/linux/pid.h 2013-08-22 20:30:00.000000000 +0000
7915 @@ -8,7 +8,8 @@ enum pid_type
7925 @@ -172,6 +173,7 @@ static inline pid_t pid_nr(struct pid *p
7928 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
7929 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
7930 pid_t pid_vnr(struct pid *pid);
7932 #define do_each_pid_task(pid, type, task) \
7933 diff -NurpP --minimal linux-3.10.15/include/linux/quotaops.h linux-3.10.15-vs2.3.6.6/include/linux/quotaops.h
7934 --- linux-3.10.15/include/linux/quotaops.h 2012-12-11 03:30:57.000000000 +0000
7935 +++ linux-3.10.15-vs2.3.6.6/include/linux/quotaops.h 2013-08-22 20:30:00.000000000 +0000
7937 #define _LINUX_QUOTAOPS_
7939 #include <linux/fs.h>
7940 +#include <linux/vs_dlimit.h>
7942 #define DQUOT_SPACE_WARN 0x1
7943 #define DQUOT_SPACE_RESERVE 0x2
7944 @@ -205,11 +206,12 @@ static inline void dquot_drop(struct ino
7946 static inline int dquot_alloc_inode(const struct inode *inode)
7949 + return dl_alloc_inode(inode);
7952 static inline void dquot_free_inode(const struct inode *inode)
7954 + dl_free_inode(inode);
7957 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
7958 @@ -220,6 +222,10 @@ static inline int dquot_transfer(struct
7959 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
7964 + if ((ret = dl_alloc_space(inode, number)))
7966 if (!(flags & DQUOT_SPACE_RESERVE))
7967 inode_add_bytes(inode, number);
7969 @@ -230,6 +236,7 @@ static inline void __dquot_free_space(st
7971 if (!(flags & DQUOT_SPACE_RESERVE))
7972 inode_sub_bytes(inode, number);
7973 + dl_free_space(inode, number);
7976 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
7977 diff -NurpP --minimal linux-3.10.15/include/linux/sched.h linux-3.10.15-vs2.3.6.6/include/linux/sched.h
7978 --- linux-3.10.15/include/linux/sched.h 2013-07-14 17:01:33.000000000 +0000
7979 +++ linux-3.10.15-vs2.3.6.6/include/linux/sched.h 2013-10-09 17:37:22.000000000 +0000
7980 @@ -1233,6 +1233,14 @@ struct task_struct {
7982 struct seccomp seccomp;
7984 +/* vserver context data */
7985 + struct vx_info *vx_info;
7986 + struct nx_info *nx_info;
7992 /* Thread group tracking */
7995 @@ -1476,6 +1484,11 @@ struct pid_namespace;
7996 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
7997 struct pid_namespace *ns);
7999 +#include <linux/vserver/base.h>
8000 +#include <linux/vserver/context.h>
8001 +#include <linux/vserver/debug.h>
8002 +#include <linux/vserver/pid.h>
8004 static inline pid_t task_pid_nr(struct task_struct *tsk)
8007 @@ -1489,7 +1502,8 @@ static inline pid_t task_pid_nr_ns(struc
8009 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8011 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8012 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8013 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8017 @@ -1502,7 +1516,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8019 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8021 - return pid_vnr(task_tgid(tsk));
8022 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8026 diff -NurpP --minimal linux-3.10.15/include/linux/shmem_fs.h linux-3.10.15-vs2.3.6.6/include/linux/shmem_fs.h
8027 --- linux-3.10.15/include/linux/shmem_fs.h 2012-12-11 03:30:57.000000000 +0000
8028 +++ linux-3.10.15-vs2.3.6.6/include/linux/shmem_fs.h 2013-08-22 20:30:00.000000000 +0000
8031 /* inode in-kernel data */
8033 +#define TMPFS_SUPER_MAGIC 0x01021994
8036 struct shmem_inode_info {
8038 unsigned long flags;
8039 diff -NurpP --minimal linux-3.10.15/include/linux/stat.h linux-3.10.15-vs2.3.6.6/include/linux/stat.h
8040 --- linux-3.10.15/include/linux/stat.h 2012-12-11 03:30:57.000000000 +0000
8041 +++ linux-3.10.15-vs2.3.6.6/include/linux/stat.h 2013-08-22 20:30:00.000000000 +0000
8042 @@ -25,6 +25,7 @@ struct kstat {
8049 struct timespec atime;
8050 diff -NurpP --minimal linux-3.10.15/include/linux/sunrpc/auth.h linux-3.10.15-vs2.3.6.6/include/linux/sunrpc/auth.h
8051 --- linux-3.10.15/include/linux/sunrpc/auth.h 2013-07-14 17:01:33.000000000 +0000
8052 +++ linux-3.10.15-vs2.3.6.6/include/linux/sunrpc/auth.h 2013-08-22 20:30:00.000000000 +0000
8053 @@ -28,6 +28,7 @@ struct rpcsec_gss_info;
8058 struct group_info *group_info;
8059 const char *principal;
8060 unsigned char machine_cred : 1;
8061 diff -NurpP --minimal linux-3.10.15/include/linux/sunrpc/clnt.h linux-3.10.15-vs2.3.6.6/include/linux/sunrpc/clnt.h
8062 --- linux-3.10.15/include/linux/sunrpc/clnt.h 2013-07-14 17:01:33.000000000 +0000
8063 +++ linux-3.10.15-vs2.3.6.6/include/linux/sunrpc/clnt.h 2013-08-22 20:30:00.000000000 +0000
8064 @@ -49,7 +49,8 @@ struct rpc_clnt {
8065 unsigned int cl_softrtry : 1,/* soft timeouts */
8066 cl_discrtry : 1,/* disconnect before retry */
8067 cl_autobind : 1,/* use getport() */
8068 - cl_chatty : 1;/* be verbose */
8069 + cl_chatty : 1,/* be verbose */
8070 + cl_tag : 1;/* context tagging */
8072 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8073 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8074 diff -NurpP --minimal linux-3.10.15/include/linux/sysfs.h linux-3.10.15-vs2.3.6.6/include/linux/sysfs.h
8075 --- linux-3.10.15/include/linux/sysfs.h 2013-05-31 13:45:28.000000000 +0000
8076 +++ linux-3.10.15-vs2.3.6.6/include/linux/sysfs.h 2013-08-22 20:30:00.000000000 +0000
8078 #include <linux/kobject_ns.h>
8079 #include <linux/atomic.h>
8081 +#define SYSFS_SUPER_MAGIC 0x62656572
8086 diff -NurpP --minimal linux-3.10.15/include/linux/types.h linux-3.10.15-vs2.3.6.6/include/linux/types.h
8087 --- linux-3.10.15/include/linux/types.h 2013-02-19 13:58:52.000000000 +0000
8088 +++ linux-3.10.15-vs2.3.6.6/include/linux/types.h 2013-08-22 20:30:00.000000000 +0000
8089 @@ -32,6 +32,9 @@ typedef __kernel_uid32_t uid_t;
8090 typedef __kernel_gid32_t gid_t;
8091 typedef __kernel_uid16_t uid16_t;
8092 typedef __kernel_gid16_t gid16_t;
8093 +typedef unsigned int vxid_t;
8094 +typedef unsigned int vnid_t;
8095 +typedef unsigned int vtag_t;
8097 typedef unsigned long uintptr_t;
8099 diff -NurpP --minimal linux-3.10.15/include/linux/uidgid.h linux-3.10.15-vs2.3.6.6/include/linux/uidgid.h
8100 --- linux-3.10.15/include/linux/uidgid.h 2012-12-11 03:30:57.000000000 +0000
8101 +++ linux-3.10.15-vs2.3.6.6/include/linux/uidgid.h 2013-08-22 20:30:00.000000000 +0000
8102 @@ -23,13 +23,17 @@ typedef struct {
8115 #define KUIDT_INIT(value) (kuid_t){ value }
8116 #define KGIDT_INIT(value) (kgid_t){ value }
8117 +#define KTAGT_INIT(value) (ktag_t){ value }
8119 static inline uid_t __kuid_val(kuid_t uid)
8121 @@ -41,10 +45,16 @@ static inline gid_t __kgid_val(kgid_t gi
8125 +static inline vtag_t __ktag_val(ktag_t tag)
8132 typedef uid_t kuid_t;
8133 typedef gid_t kgid_t;
8134 +typedef vtag_t ktag_t;
8136 static inline uid_t __kuid_val(kuid_t uid)
8138 @@ -56,16 +66,24 @@ static inline gid_t __kgid_val(kgid_t gi
8142 +static inline vtag_t __ktag_val(ktag_t tag)
8147 #define KUIDT_INIT(value) ((kuid_t) value )
8148 #define KGIDT_INIT(value) ((kgid_t) value )
8149 +#define KTAGT_INIT(value) ((ktag_t) value )
8153 #define GLOBAL_ROOT_UID KUIDT_INIT(0)
8154 #define GLOBAL_ROOT_GID KGIDT_INIT(0)
8155 +#define GLOBAL_ROOT_TAG KTAGT_INIT(0)
8157 #define INVALID_UID KUIDT_INIT(-1)
8158 #define INVALID_GID KGIDT_INIT(-1)
8159 +#define INVALID_TAG KTAGT_INIT(-1)
8161 static inline bool uid_eq(kuid_t left, kuid_t right)
8163 @@ -77,6 +95,11 @@ static inline bool gid_eq(kgid_t left, k
8164 return __kgid_val(left) == __kgid_val(right);
8167 +static inline bool tag_eq(ktag_t left, ktag_t right)
8169 + return __ktag_val(left) == __ktag_val(right);
8172 static inline bool uid_gt(kuid_t left, kuid_t right)
8174 return __kuid_val(left) > __kuid_val(right);
8175 @@ -127,13 +150,21 @@ static inline bool gid_valid(kgid_t gid)
8176 return !gid_eq(gid, INVALID_GID);
8179 +static inline bool tag_valid(ktag_t tag)
8181 + return !tag_eq(tag, INVALID_TAG);
8184 #ifdef CONFIG_USER_NS
8186 extern kuid_t make_kuid(struct user_namespace *from, uid_t uid);
8187 extern kgid_t make_kgid(struct user_namespace *from, gid_t gid);
8188 +extern krag_t make_ktag(struct user_namespace *from, gid_t gid);
8190 extern uid_t from_kuid(struct user_namespace *to, kuid_t uid);
8191 extern gid_t from_kgid(struct user_namespace *to, kgid_t gid);
8192 +extern vtag_t from_ktag(struct user_namespace *to, ktag_t tag);
8194 extern uid_t from_kuid_munged(struct user_namespace *to, kuid_t uid);
8195 extern gid_t from_kgid_munged(struct user_namespace *to, kgid_t gid);
8197 @@ -159,6 +190,11 @@ static inline kgid_t make_kgid(struct us
8198 return KGIDT_INIT(gid);
8201 +static inline ktag_t make_ktag(struct user_namespace *from, vtag_t tag)
8203 + return KTAGT_INIT(tag);
8206 static inline uid_t from_kuid(struct user_namespace *to, kuid_t kuid)
8208 return __kuid_val(kuid);
8209 @@ -169,6 +205,11 @@ static inline gid_t from_kgid(struct use
8210 return __kgid_val(kgid);
8213 +static inline vtag_t from_ktag(struct user_namespace *to, ktag_t ktag)
8215 + return __ktag_val(ktag);
8218 static inline uid_t from_kuid_munged(struct user_namespace *to, kuid_t kuid)
8220 uid_t uid = from_kuid(to, kuid);
8221 diff -NurpP --minimal linux-3.10.15/include/linux/vroot.h linux-3.10.15-vs2.3.6.6/include/linux/vroot.h
8222 --- linux-3.10.15/include/linux/vroot.h 1970-01-01 00:00:00.000000000 +0000
8223 +++ linux-3.10.15-vs2.3.6.6/include/linux/vroot.h 2013-08-22 20:30:00.000000000 +0000
8227 + * include/linux/vroot.h
8229 + * written by Herbert Pötzl, 9/11/2002
8230 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
8232 + * Copyright (C) 2002-2007 by Herbert Pötzl.
8233 + * Redistribution of this file is permitted under the
8234 + * GNU General Public License.
8237 +#ifndef _LINUX_VROOT_H
8238 +#define _LINUX_VROOT_H
8243 +/* Possible states of device */
8249 +struct vroot_device {
8253 + struct semaphore vr_ctl_mutex;
8254 + struct block_device *vr_device;
8259 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
8261 +extern int register_vroot_grb(vroot_grb_func *);
8262 +extern int unregister_vroot_grb(vroot_grb_func *);
8264 +#endif /* __KERNEL__ */
8266 +#define MAX_VROOT_DEFAULT 8
8269 + * IOCTL commands --- we will commandeer 0x56 ('V')
8272 +#define VROOT_SET_DEV 0x5600
8273 +#define VROOT_CLR_DEV 0x5601
8275 +#endif /* _LINUX_VROOT_H */
8276 diff -NurpP --minimal linux-3.10.15/include/linux/vs_base.h linux-3.10.15-vs2.3.6.6/include/linux/vs_base.h
8277 --- linux-3.10.15/include/linux/vs_base.h 1970-01-01 00:00:00.000000000 +0000
8278 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_base.h 2013-08-22 20:30:00.000000000 +0000
8283 +#include "vserver/base.h"
8284 +#include "vserver/check.h"
8285 +#include "vserver/debug.h"
8288 +#warning duplicate inclusion
8290 diff -NurpP --minimal linux-3.10.15/include/linux/vs_context.h linux-3.10.15-vs2.3.6.6/include/linux/vs_context.h
8291 --- linux-3.10.15/include/linux/vs_context.h 1970-01-01 00:00:00.000000000 +0000
8292 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_context.h 2013-08-22 20:30:00.000000000 +0000
8294 +#ifndef _VS_CONTEXT_H
8295 +#define _VS_CONTEXT_H
8297 +#include "vserver/base.h"
8298 +#include "vserver/check.h"
8299 +#include "vserver/context.h"
8300 +#include "vserver/history.h"
8301 +#include "vserver/debug.h"
8303 +#include <linux/sched.h>
8306 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
8308 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
8309 + const char *_file, int _line, void *_here)
8314 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
8315 + vxi, vxi ? vxi->vx_id : 0,
8316 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8318 + __vxh_get_vx_info(vxi, _here);
8320 + atomic_inc(&vxi->vx_usecnt);
8325 +extern void free_vx_info(struct vx_info *);
8327 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
8329 +static inline void __put_vx_info(struct vx_info *vxi,
8330 + const char *_file, int _line, void *_here)
8335 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
8336 + vxi, vxi ? vxi->vx_id : 0,
8337 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8339 + __vxh_put_vx_info(vxi, _here);
8341 + if (atomic_dec_and_test(&vxi->vx_usecnt))
8342 + free_vx_info(vxi);
8346 +#define init_vx_info(p, i) \
8347 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8349 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8350 + const char *_file, int _line, void *_here)
8353 + vxlprintk(VXD_CBIT(xid, 3),
8354 + "init_vx_info(%p[#%d.%d])",
8355 + vxi, vxi ? vxi->vx_id : 0,
8356 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8358 + __vxh_init_vx_info(vxi, vxp, _here);
8360 + atomic_inc(&vxi->vx_usecnt);
8366 +#define set_vx_info(p, i) \
8367 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8369 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8370 + const char *_file, int _line, void *_here)
8372 + struct vx_info *vxo;
8377 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
8378 + vxi, vxi ? vxi->vx_id : 0,
8379 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8381 + __vxh_set_vx_info(vxi, vxp, _here);
8383 + atomic_inc(&vxi->vx_usecnt);
8384 + vxo = xchg(vxp, vxi);
8389 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
8391 +static inline void __clr_vx_info(struct vx_info **vxp,
8392 + const char *_file, int _line, void *_here)
8394 + struct vx_info *vxo;
8396 + vxo = xchg(vxp, NULL);
8400 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
8401 + vxo, vxo ? vxo->vx_id : 0,
8402 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
8404 + __vxh_clr_vx_info(vxo, vxp, _here);
8406 + if (atomic_dec_and_test(&vxo->vx_usecnt))
8407 + free_vx_info(vxo);
8411 +#define claim_vx_info(v, p) \
8412 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
8414 +static inline void __claim_vx_info(struct vx_info *vxi,
8415 + struct task_struct *task,
8416 + const char *_file, int _line, void *_here)
8418 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
8419 + vxi, vxi ? vxi->vx_id : 0,
8420 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8421 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
8422 + task, _file, _line);
8423 + __vxh_claim_vx_info(vxi, task, _here);
8425 + atomic_inc(&vxi->vx_tasks);
8429 +extern void unhash_vx_info(struct vx_info *);
8431 +#define release_vx_info(v, p) \
8432 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
8434 +static inline void __release_vx_info(struct vx_info *vxi,
8435 + struct task_struct *task,
8436 + const char *_file, int _line, void *_here)
8438 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
8439 + vxi, vxi ? vxi->vx_id : 0,
8440 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8441 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
8442 + task, _file, _line);
8443 + __vxh_release_vx_info(vxi, task, _here);
8447 + if (atomic_dec_and_test(&vxi->vx_tasks))
8448 + unhash_vx_info(vxi);
8452 +#define task_get_vx_info(p) \
8453 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
8455 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
8456 + const char *_file, int _line, void *_here)
8458 + struct vx_info *vxi;
8461 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
8463 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
8469 +static inline void __wakeup_vx_info(struct vx_info *vxi)
8471 + if (waitqueue_active(&vxi->vx_wait))
8472 + wake_up_interruptible(&vxi->vx_wait);
8476 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
8478 +static inline void __enter_vx_info(struct vx_info *vxi,
8479 + struct vx_info_save *vxis, const char *_file, int _line)
8481 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
8482 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
8483 + current->xid, current->vx_info, _file, _line);
8484 + vxis->vxi = xchg(¤t->vx_info, vxi);
8485 + vxis->xid = current->xid;
8486 + current->xid = vxi ? vxi->vx_id : 0;
8489 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
8491 +static inline void __leave_vx_info(struct vx_info_save *vxis,
8492 + const char *_file, int _line)
8494 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
8495 + vxis, vxis->xid, vxis->vxi, current,
8496 + current->xid, current->vx_info, _file, _line);
8497 + (void)xchg(¤t->vx_info, vxis->vxi);
8498 + current->xid = vxis->xid;
8502 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
8504 + vxis->vxi = xchg(¤t->vx_info, NULL);
8505 + vxis->xid = xchg(¤t->xid, (vxid_t)0);
8508 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
8510 + (void)xchg(¤t->xid, vxis->xid);
8511 + (void)xchg(¤t->vx_info, vxis->vxi);
8514 +#define task_is_init(p) \
8515 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
8517 +static inline int __task_is_init(struct task_struct *p,
8518 + const char *_file, int _line, void *_here)
8520 + int is_init = is_global_init(p);
8524 + is_init = p->vx_info->vx_initpid == p->pid;
8529 +extern void exit_vx_info(struct task_struct *, int);
8530 +extern void exit_vx_info_early(struct task_struct *, int);
8534 +#warning duplicate inclusion
8536 diff -NurpP --minimal linux-3.10.15/include/linux/vs_cowbl.h linux-3.10.15-vs2.3.6.6/include/linux/vs_cowbl.h
8537 --- linux-3.10.15/include/linux/vs_cowbl.h 1970-01-01 00:00:00.000000000 +0000
8538 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_cowbl.h 2013-08-22 20:30:00.000000000 +0000
8540 +#ifndef _VS_COWBL_H
8541 +#define _VS_COWBL_H
8543 +#include <linux/fs.h>
8544 +#include <linux/dcache.h>
8545 +#include <linux/namei.h>
8546 +#include <linux/slab.h>
8548 +extern struct dentry *cow_break_link(const char *pathname);
8550 +static inline int cow_check_and_break(struct path *path)
8552 + struct inode *inode = path->dentry->d_inode;
8555 + /* do we need this check? */
8556 + if (IS_RDONLY(inode))
8559 + if (IS_COW(inode)) {
8560 + if (IS_COW_LINK(inode)) {
8561 + struct dentry *new_dentry, *old_dentry = path->dentry;
8564 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
8568 + pp = d_path(path, buf, PATH_MAX);
8569 + new_dentry = cow_break_link(pp);
8571 + if (!IS_ERR(new_dentry)) {
8572 + path->dentry = new_dentry;
8575 + error = PTR_ERR(new_dentry);
8577 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
8578 + inode->i_ctime = CURRENT_TIME;
8579 + mark_inode_dirty(inode);
8586 +#warning duplicate inclusion
8588 diff -NurpP --minimal linux-3.10.15/include/linux/vs_cvirt.h linux-3.10.15-vs2.3.6.6/include/linux/vs_cvirt.h
8589 --- linux-3.10.15/include/linux/vs_cvirt.h 1970-01-01 00:00:00.000000000 +0000
8590 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_cvirt.h 2013-08-22 20:30:00.000000000 +0000
8592 +#ifndef _VS_CVIRT_H
8593 +#define _VS_CVIRT_H
8595 +#include "vserver/cvirt.h"
8596 +#include "vserver/context.h"
8597 +#include "vserver/base.h"
8598 +#include "vserver/check.h"
8599 +#include "vserver/debug.h"
8602 +static inline void vx_activate_task(struct task_struct *p)
8604 + struct vx_info *vxi;
8606 + if ((vxi = p->vx_info)) {
8607 + vx_update_load(vxi);
8608 + atomic_inc(&vxi->cvirt.nr_running);
8612 +static inline void vx_deactivate_task(struct task_struct *p)
8614 + struct vx_info *vxi;
8616 + if ((vxi = p->vx_info)) {
8617 + vx_update_load(vxi);
8618 + atomic_dec(&vxi->cvirt.nr_running);
8622 +static inline void vx_uninterruptible_inc(struct task_struct *p)
8624 + struct vx_info *vxi;
8626 + if ((vxi = p->vx_info))
8627 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
8630 +static inline void vx_uninterruptible_dec(struct task_struct *p)
8632 + struct vx_info *vxi;
8634 + if ((vxi = p->vx_info))
8635 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
8640 +#warning duplicate inclusion
8642 diff -NurpP --minimal linux-3.10.15/include/linux/vs_device.h linux-3.10.15-vs2.3.6.6/include/linux/vs_device.h
8643 --- linux-3.10.15/include/linux/vs_device.h 1970-01-01 00:00:00.000000000 +0000
8644 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_device.h 2013-08-22 20:30:00.000000000 +0000
8646 +#ifndef _VS_DEVICE_H
8647 +#define _VS_DEVICE_H
8649 +#include "vserver/base.h"
8650 +#include "vserver/device.h"
8651 +#include "vserver/debug.h"
8654 +#ifdef CONFIG_VSERVER_DEVICE
8656 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
8658 +#define vs_device_perm(v, d, m, p) \
8659 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
8664 +int vs_map_device(struct vx_info *vxi,
8665 + dev_t device, dev_t *target, umode_t mode)
8672 +#define vs_device_perm(v, d, m, p) ((p) == (p))
8677 +#define vs_map_chrdev(d, t, p) \
8678 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
8679 +#define vs_map_blkdev(d, t, p) \
8680 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
8682 +#define vs_chrdev_perm(d, p) \
8683 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
8684 +#define vs_blkdev_perm(d, p) \
8685 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
8689 +#warning duplicate inclusion
8691 diff -NurpP --minimal linux-3.10.15/include/linux/vs_dlimit.h linux-3.10.15-vs2.3.6.6/include/linux/vs_dlimit.h
8692 --- linux-3.10.15/include/linux/vs_dlimit.h 1970-01-01 00:00:00.000000000 +0000
8693 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_dlimit.h 2013-08-22 20:30:00.000000000 +0000
8695 +#ifndef _VS_DLIMIT_H
8696 +#define _VS_DLIMIT_H
8698 +#include <linux/fs.h>
8700 +#include "vserver/dlimit.h"
8701 +#include "vserver/base.h"
8702 +#include "vserver/debug.h"
8705 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
8707 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
8708 + const char *_file, int _line)
8712 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
8713 + dli, dli ? dli->dl_tag : 0,
8714 + dli ? atomic_read(&dli->dl_usecnt) : 0,
8716 + atomic_inc(&dli->dl_usecnt);
8721 +#define free_dl_info(i) \
8722 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
8724 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
8726 +static inline void __put_dl_info(struct dl_info *dli,
8727 + const char *_file, int _line)
8731 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
8732 + dli, dli ? dli->dl_tag : 0,
8733 + dli ? atomic_read(&dli->dl_usecnt) : 0,
8735 + if (atomic_dec_and_test(&dli->dl_usecnt))
8736 + free_dl_info(dli);
8740 +#define __dlimit_char(d) ((d) ? '*' : ' ')
8742 +static inline int __dl_alloc_space(struct super_block *sb,
8743 + vtag_t tag, dlsize_t nr, const char *file, int line)
8745 + struct dl_info *dli = NULL;
8750 + dli = locate_dl_info(sb, tag);
8754 + spin_lock(&dli->dl_lock);
8755 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
8757 + dli->dl_space_used += nr;
8758 + spin_unlock(&dli->dl_lock);
8761 + vxlprintk(VXD_CBIT(dlim, 1),
8762 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
8763 + sb, tag, __dlimit_char(dli), (long long)nr,
8765 + return ret ? -ENOSPC : 0;
8768 +static inline void __dl_free_space(struct super_block *sb,
8769 + vtag_t tag, dlsize_t nr, const char *_file, int _line)
8771 + struct dl_info *dli = NULL;
8775 + dli = locate_dl_info(sb, tag);
8779 + spin_lock(&dli->dl_lock);
8780 + if (dli->dl_space_used > nr)
8781 + dli->dl_space_used -= nr;
8783 + dli->dl_space_used = 0;
8784 + spin_unlock(&dli->dl_lock);
8787 + vxlprintk(VXD_CBIT(dlim, 1),
8788 + "FREE (%p,#%d)%c %lld bytes",
8789 + sb, tag, __dlimit_char(dli), (long long)nr,
8793 +static inline int __dl_alloc_inode(struct super_block *sb,
8794 + vtag_t tag, const char *_file, int _line)
8796 + struct dl_info *dli;
8799 + dli = locate_dl_info(sb, tag);
8803 + spin_lock(&dli->dl_lock);
8804 + dli->dl_inodes_used++;
8805 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
8806 + spin_unlock(&dli->dl_lock);
8809 + vxlprintk(VXD_CBIT(dlim, 0),
8810 + "ALLOC (%p,#%d)%c inode (%d)",
8811 + sb, tag, __dlimit_char(dli), ret, _file, _line);
8812 + return ret ? -ENOSPC : 0;
8815 +static inline void __dl_free_inode(struct super_block *sb,
8816 + vtag_t tag, const char *_file, int _line)
8818 + struct dl_info *dli;
8820 + dli = locate_dl_info(sb, tag);
8824 + spin_lock(&dli->dl_lock);
8825 + if (dli->dl_inodes_used > 1)
8826 + dli->dl_inodes_used--;
8828 + dli->dl_inodes_used = 0;
8829 + spin_unlock(&dli->dl_lock);
8832 + vxlprintk(VXD_CBIT(dlim, 0),
8833 + "FREE (%p,#%d)%c inode",
8834 + sb, tag, __dlimit_char(dli), _file, _line);
8837 +static inline void __dl_adjust_block(struct super_block *sb, vtag_t tag,
8838 + unsigned long long *free_blocks, unsigned long long *root_blocks,
8839 + const char *_file, int _line)
8841 + struct dl_info *dli;
8842 + uint64_t broot, bfree;
8844 + dli = locate_dl_info(sb, tag);
8848 + spin_lock(&dli->dl_lock);
8849 + broot = (dli->dl_space_total -
8850 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
8851 + >> sb->s_blocksize_bits;
8852 + bfree = (dli->dl_space_total - dli->dl_space_used)
8853 + >> sb->s_blocksize_bits;
8854 + spin_unlock(&dli->dl_lock);
8856 + vxlprintk(VXD_CBIT(dlim, 2),
8857 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
8858 + (long long)bfree, (long long)broot,
8859 + *free_blocks, *root_blocks, dli->dl_nrlmult,
8861 + if (free_blocks) {
8862 + if (*free_blocks > bfree)
8863 + *free_blocks = bfree;
8865 + if (root_blocks) {
8866 + if (*root_blocks > broot)
8867 + *root_blocks = broot;
8872 +#define dl_prealloc_space(in, bytes) \
8873 + __dl_alloc_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8874 + __FILE__, __LINE__ )
8876 +#define dl_alloc_space(in, bytes) \
8877 + __dl_alloc_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8878 + __FILE__, __LINE__ )
8880 +#define dl_reserve_space(in, bytes) \
8881 + __dl_alloc_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8882 + __FILE__, __LINE__ )
8884 +#define dl_claim_space(in, bytes) (0)
8886 +#define dl_release_space(in, bytes) \
8887 + __dl_free_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8888 + __FILE__, __LINE__ )
8890 +#define dl_free_space(in, bytes) \
8891 + __dl_free_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8892 + __FILE__, __LINE__ )
8896 +#define dl_alloc_inode(in) \
8897 + __dl_alloc_inode((in)->i_sb, i_tag_read(in), __FILE__, __LINE__ )
8899 +#define dl_free_inode(in) \
8900 + __dl_free_inode((in)->i_sb, i_tag_read(in), __FILE__, __LINE__ )
8903 +#define dl_adjust_block(sb, tag, fb, rb) \
8904 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
8908 +#warning duplicate inclusion
8910 diff -NurpP --minimal linux-3.10.15/include/linux/vs_inet.h linux-3.10.15-vs2.3.6.6/include/linux/vs_inet.h
8911 --- linux-3.10.15/include/linux/vs_inet.h 1970-01-01 00:00:00.000000000 +0000
8912 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_inet.h 2013-08-22 20:30:00.000000000 +0000
8917 +#include "vserver/base.h"
8918 +#include "vserver/network.h"
8919 +#include "vserver/debug.h"
8921 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
8923 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
8924 + NIPQUAD((a)->mask), (a)->type
8925 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
8927 +#define NIPQUAD(addr) \
8928 + ((unsigned char *)&addr)[0], \
8929 + ((unsigned char *)&addr)[1], \
8930 + ((unsigned char *)&addr)[2], \
8931 + ((unsigned char *)&addr)[3]
8933 +#define NIPQUAD_FMT "%u.%u.%u.%u"
8937 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
8939 + __be32 ip = nxa->ip[0].s_addr;
8940 + __be32 mask = nxa->mask.s_addr;
8941 + __be32 bcast = ip | ~mask;
8944 + switch (nxa->type & tmask) {
8945 + case NXA_TYPE_MASK:
8946 + ret = (ip == (addr & mask));
8948 + case NXA_TYPE_ADDR:
8952 + /* fall through to broadcast */
8953 + case NXA_MOD_BCAST:
8954 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
8956 + case NXA_TYPE_RANGE:
8957 + ret = ((nxa->ip[0].s_addr <= addr) &&
8958 + (nxa->ip[1].s_addr > addr));
8960 + case NXA_TYPE_ANY:
8965 + vxdprintk(VXD_CBIT(net, 0),
8966 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
8967 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
8972 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
8974 + struct nx_addr_v4 *nxa;
8975 + unsigned long irqflags;
8982 + /* allow 127.0.0.1 when remapping lback */
8983 + if ((tmask & NXA_LOOPBACK) &&
8984 + (addr == IPI_LOOPBACK) &&
8985 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
8988 + /* check for lback address */
8989 + if ((tmask & NXA_MOD_LBACK) &&
8990 + (nxi->v4_lback.s_addr == addr))
8993 + /* check for broadcast address */
8994 + if ((tmask & NXA_MOD_BCAST) &&
8995 + (nxi->v4_bcast.s_addr == addr))
8999 + /* check for v4 addresses */
9000 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9001 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9002 + if (v4_addr_match(nxa, addr, tmask))
9006 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9008 + vxdprintk(VXD_CBIT(net, 0),
9009 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9010 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9015 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9017 + /* FIXME: needs full range checks */
9018 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9022 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9024 + struct nx_addr_v4 *ptr;
9025 + unsigned long irqflags;
9028 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9029 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9030 + if (v4_nx_addr_match(ptr, nxa, mask))
9034 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9038 +#include <net/inet_sock.h>
9041 + * Check if a given address matches for a socket
9043 + * nxi: the socket's nx_info if any
9044 + * addr: to be verified address
9047 +int v4_sock_addr_match (
9048 + struct nx_info *nxi,
9049 + struct inet_sock *inet,
9052 + __be32 saddr = inet->inet_rcv_saddr;
9053 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9055 + if (addr && (saddr == addr || bcast == addr))
9058 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9063 +/* inet related checks and helpers */
9072 +#include <linux/netdevice.h>
9073 +#include <linux/inetdevice.h>
9074 +#include <net/inet_sock.h>
9075 +#include <net/inet_timewait_sock.h>
9078 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9079 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9080 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9084 + * check if address is covered by socket
9086 + * sk: the socket to check against
9087 + * addr: the address in question (must be != 0)
9091 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9093 + struct nx_info *nxi = sk->sk_nx_info;
9094 + __be32 saddr = sk_rcv_saddr(sk);
9096 + vxdprintk(VXD_CBIT(net, 5),
9097 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9098 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9099 + (sk->sk_socket?sk->sk_socket->flags:0));
9101 + if (saddr) { /* direct address match */
9102 + return v4_addr_match(nxa, saddr, -1);
9103 + } else if (nxi) { /* match against nx_info */
9104 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9105 + } else { /* unrestricted any socket */
9113 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9115 + vxdprintk(VXD_CBIT(net, 1),
9116 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9117 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9118 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9120 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9122 + if (dev_in_nx_info(dev, nxi))
9129 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9135 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9139 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
9141 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
9142 + nxi, nxi ? nxi->nx_id : 0, ifa,
9143 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
9145 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9147 + if (v4_ifa_in_nx_info(ifa, nxi))
9153 +struct nx_v4_sock_addr {
9154 + __be32 saddr; /* Address used for validation */
9155 + __be32 baddr; /* Address used for socket bind */
9159 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
9160 + struct nx_v4_sock_addr *nsa)
9162 + struct sock *sk = &inet->sk;
9163 + struct nx_info *nxi = sk->sk_nx_info;
9164 + __be32 saddr = addr->sin_addr.s_addr;
9165 + __be32 baddr = saddr;
9167 + vxdprintk(VXD_CBIT(net, 3),
9168 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
9169 + sk, sk->sk_nx_info, sk->sk_socket,
9170 + (sk->sk_socket ? sk->sk_socket->flags : 0),
9174 + if (saddr == INADDR_ANY) {
9175 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
9176 + baddr = nxi->v4.ip[0].s_addr;
9177 + } else if (saddr == IPI_LOOPBACK) {
9178 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9179 + baddr = nxi->v4_lback.s_addr;
9180 + } else if (!ipv4_is_multicast(saddr) ||
9181 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
9182 + /* normal address bind */
9183 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
9184 + return -EADDRNOTAVAIL;
9188 + vxdprintk(VXD_CBIT(net, 3),
9189 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
9190 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
9192 + nsa->saddr = saddr;
9193 + nsa->baddr = baddr;
9198 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
9200 + inet->inet_saddr = nsa->baddr;
9201 + inet->inet_rcv_saddr = nsa->baddr;
9206 + * helper to simplify inet_lookup_listener
9208 + * nxi: the socket's nx_info if any
9209 + * addr: to be verified address
9210 + * saddr: socket address
9212 +static inline int v4_inet_addr_match (
9213 + struct nx_info *nxi,
9217 + if (addr && (saddr == addr))
9220 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
9224 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
9226 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
9227 + (addr == nxi->v4_lback.s_addr))
9228 + return IPI_LOOPBACK;
9233 +int nx_info_has_v4(struct nx_info *nxi)
9239 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9244 +#else /* CONFIG_INET */
9247 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
9253 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9259 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9265 +int nx_info_has_v4(struct nx_info *nxi)
9270 +#endif /* CONFIG_INET */
9272 +#define current_nx_info_has_v4() \
9273 + nx_info_has_v4(current_nx_info())
9276 +// #warning duplicate inclusion
9278 diff -NurpP --minimal linux-3.10.15/include/linux/vs_inet6.h linux-3.10.15-vs2.3.6.6/include/linux/vs_inet6.h
9279 --- linux-3.10.15/include/linux/vs_inet6.h 1970-01-01 00:00:00.000000000 +0000
9280 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_inet6.h 2013-08-22 20:30:00.000000000 +0000
9282 +#ifndef _VS_INET6_H
9283 +#define _VS_INET6_H
9285 +#include "vserver/base.h"
9286 +#include "vserver/network.h"
9287 +#include "vserver/debug.h"
9289 +#include <net/ipv6.h>
9291 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
9292 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
9298 +int v6_addr_match(struct nx_addr_v6 *nxa,
9299 + const struct in6_addr *addr, uint16_t mask)
9303 + switch (nxa->type & mask) {
9304 + case NXA_TYPE_MASK:
9305 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
9307 + case NXA_TYPE_ADDR:
9308 + ret = ipv6_addr_equal(&nxa->ip, addr);
9310 + case NXA_TYPE_ANY:
9314 + vxdprintk(VXD_CBIT(net, 0),
9315 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
9316 + nxa, NXAV6(nxa), addr, mask, ret);
9321 +int v6_addr_in_nx_info(struct nx_info *nxi,
9322 + const struct in6_addr *addr, uint16_t mask)
9324 + struct nx_addr_v6 *nxa;
9325 + unsigned long irqflags;
9331 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9332 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
9333 + if (v6_addr_match(nxa, addr, mask))
9337 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9339 + vxdprintk(VXD_CBIT(net, 0),
9340 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
9341 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
9346 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
9348 + /* FIXME: needs full range checks */
9349 + return v6_addr_match(nxa, &addr->ip, mask);
9353 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
9355 + struct nx_addr_v6 *ptr;
9356 + unsigned long irqflags;
9359 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9360 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
9361 + if (v6_nx_addr_match(ptr, nxa, mask))
9365 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9371 + * Check if a given address matches for a socket
9373 + * nxi: the socket's nx_info if any
9374 + * addr: to be verified address
9377 +int v6_sock_addr_match (
9378 + struct nx_info *nxi,
9379 + struct inet_sock *inet,
9380 + struct in6_addr *addr)
9382 + struct sock *sk = &inet->sk;
9383 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9385 + if (!ipv6_addr_any(addr) &&
9386 + ipv6_addr_equal(saddr, addr))
9388 + if (ipv6_addr_any(saddr))
9389 + return v6_addr_in_nx_info(nxi, addr, -1);
9394 + * check if address is covered by socket
9396 + * sk: the socket to check against
9397 + * addr: the address in question (must be != 0)
9401 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
9403 + struct nx_info *nxi = sk->sk_nx_info;
9404 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9406 + vxdprintk(VXD_CBIT(net, 5),
9407 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
9408 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
9409 + (sk->sk_socket?sk->sk_socket->flags:0));
9411 + if (!ipv6_addr_any(saddr)) { /* direct address match */
9412 + return v6_addr_match(nxa, saddr, -1);
9413 + } else if (nxi) { /* match against nx_info */
9414 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
9415 + } else { /* unrestricted any socket */
9421 +/* inet related checks and helpers */
9429 +#include <linux/netdevice.h>
9430 +#include <linux/inetdevice.h>
9431 +#include <net/inet_timewait_sock.h>
9434 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9435 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
9436 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
9441 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
9447 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
9451 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
9453 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
9454 + nxi, nxi ? nxi->nx_id : 0, ifa,
9455 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
9457 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9459 + if (v6_ifa_in_nx_info(ifa, nxi))
9465 +struct nx_v6_sock_addr {
9466 + struct in6_addr saddr; /* Address used for validation */
9467 + struct in6_addr baddr; /* Address used for socket bind */
9471 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
9472 + struct nx_v6_sock_addr *nsa)
9474 + // struct sock *sk = &inet->sk;
9475 + // struct nx_info *nxi = sk->sk_nx_info;
9476 + struct in6_addr saddr = addr->sin6_addr;
9477 + struct in6_addr baddr = saddr;
9479 + nsa->saddr = saddr;
9480 + nsa->baddr = baddr;
9485 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
9487 + // struct sock *sk = &inet->sk;
9488 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
9490 + // *saddr = nsa->baddr;
9491 + // inet->inet_saddr = nsa->baddr;
9495 +int nx_info_has_v6(struct nx_info *nxi)
9504 +#else /* CONFIG_IPV6 */
9507 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
9514 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9520 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9526 +int nx_info_has_v6(struct nx_info *nxi)
9531 +#endif /* CONFIG_IPV6 */
9533 +#define current_nx_info_has_v6() \
9534 + nx_info_has_v6(current_nx_info())
9537 +#warning duplicate inclusion
9539 diff -NurpP --minimal linux-3.10.15/include/linux/vs_limit.h linux-3.10.15-vs2.3.6.6/include/linux/vs_limit.h
9540 --- linux-3.10.15/include/linux/vs_limit.h 1970-01-01 00:00:00.000000000 +0000
9541 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_limit.h 2013-08-22 20:30:00.000000000 +0000
9543 +#ifndef _VS_LIMIT_H
9544 +#define _VS_LIMIT_H
9546 +#include "vserver/limit.h"
9547 +#include "vserver/base.h"
9548 +#include "vserver/context.h"
9549 +#include "vserver/debug.h"
9550 +#include "vserver/context.h"
9551 +#include "vserver/limit_int.h"
9554 +#define vx_acc_cres(v, d, p, r) \
9555 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
9557 +#define vx_acc_cres_cond(x, d, p, r) \
9558 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
9559 + r, d, p, __FILE__, __LINE__)
9562 +#define vx_add_cres(v, a, p, r) \
9563 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
9564 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
9566 +#define vx_add_cres_cond(x, a, p, r) \
9567 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
9568 + r, a, p, __FILE__, __LINE__)
9569 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
9572 +/* process and file limits */
9574 +#define vx_nproc_inc(p) \
9575 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
9577 +#define vx_nproc_dec(p) \
9578 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
9580 +#define vx_files_inc(f) \
9581 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
9583 +#define vx_files_dec(f) \
9584 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
9586 +#define vx_locks_inc(l) \
9587 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
9589 +#define vx_locks_dec(l) \
9590 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
9592 +#define vx_openfd_inc(f) \
9593 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
9595 +#define vx_openfd_dec(f) \
9596 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
9599 +#define vx_cres_avail(v, n, r) \
9600 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
9603 +#define vx_nproc_avail(n) \
9604 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
9606 +#define vx_files_avail(n) \
9607 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
9609 +#define vx_locks_avail(n) \
9610 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
9612 +#define vx_openfd_avail(n) \
9613 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
9616 +/* dentry limits */
9618 +#define vx_dentry_inc(d) do { \
9619 + if ((d)->d_count == 1) \
9620 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
9623 +#define vx_dentry_dec(d) do { \
9624 + if ((d)->d_count == 0) \
9625 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
9628 +#define vx_dentry_avail(n) \
9629 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
9632 +/* socket limits */
9634 +#define vx_sock_inc(s) \
9635 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
9637 +#define vx_sock_dec(s) \
9638 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
9640 +#define vx_sock_avail(n) \
9641 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
9644 +/* ipc resource limits */
9646 +#define vx_ipcmsg_add(v, u, a) \
9647 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
9649 +#define vx_ipcmsg_sub(v, u, a) \
9650 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
9652 +#define vx_ipcmsg_avail(v, a) \
9653 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
9656 +#define vx_ipcshm_add(v, k, a) \
9657 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
9659 +#define vx_ipcshm_sub(v, k, a) \
9660 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
9662 +#define vx_ipcshm_avail(v, a) \
9663 + vx_cres_avail(v, a, VLIMIT_SHMEM)
9666 +#define vx_semary_inc(a) \
9667 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
9669 +#define vx_semary_dec(a) \
9670 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
9673 +#define vx_nsems_add(a,n) \
9674 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
9676 +#define vx_nsems_sub(a,n) \
9677 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
9681 +#warning duplicate inclusion
9683 diff -NurpP --minimal linux-3.10.15/include/linux/vs_network.h linux-3.10.15-vs2.3.6.6/include/linux/vs_network.h
9684 --- linux-3.10.15/include/linux/vs_network.h 1970-01-01 00:00:00.000000000 +0000
9685 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_network.h 2013-08-22 20:30:00.000000000 +0000
9687 +#ifndef _NX_VS_NETWORK_H
9688 +#define _NX_VS_NETWORK_H
9690 +#include "vserver/context.h"
9691 +#include "vserver/network.h"
9692 +#include "vserver/base.h"
9693 +#include "vserver/check.h"
9694 +#include "vserver/debug.h"
9696 +#include <linux/sched.h>
9699 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
9701 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
9702 + const char *_file, int _line)
9707 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
9708 + nxi, nxi ? nxi->nx_id : 0,
9709 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9712 + atomic_inc(&nxi->nx_usecnt);
9717 +extern void free_nx_info(struct nx_info *);
9719 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
9721 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
9726 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
9727 + nxi, nxi ? nxi->nx_id : 0,
9728 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9731 + if (atomic_dec_and_test(&nxi->nx_usecnt))
9732 + free_nx_info(nxi);
9736 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
9738 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
9739 + const char *_file, int _line)
9742 + vxlprintk(VXD_CBIT(nid, 3),
9743 + "init_nx_info(%p[#%d.%d])",
9744 + nxi, nxi ? nxi->nx_id : 0,
9745 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9748 + atomic_inc(&nxi->nx_usecnt);
9754 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
9756 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
9757 + const char *_file, int _line)
9759 + struct nx_info *nxo;
9764 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
9765 + nxi, nxi ? nxi->nx_id : 0,
9766 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9769 + atomic_inc(&nxi->nx_usecnt);
9770 + nxo = xchg(nxp, nxi);
9774 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
9776 +static inline void __clr_nx_info(struct nx_info **nxp,
9777 + const char *_file, int _line)
9779 + struct nx_info *nxo;
9781 + nxo = xchg(nxp, NULL);
9785 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
9786 + nxo, nxo ? nxo->nx_id : 0,
9787 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
9790 + if (atomic_dec_and_test(&nxo->nx_usecnt))
9791 + free_nx_info(nxo);
9795 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
9797 +static inline void __claim_nx_info(struct nx_info *nxi,
9798 + struct task_struct *task, const char *_file, int _line)
9800 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
9801 + nxi, nxi ? nxi->nx_id : 0,
9802 + nxi?atomic_read(&nxi->nx_usecnt):0,
9803 + nxi?atomic_read(&nxi->nx_tasks):0,
9804 + task, _file, _line);
9806 + atomic_inc(&nxi->nx_tasks);
9810 +extern void unhash_nx_info(struct nx_info *);
9812 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
9814 +static inline void __release_nx_info(struct nx_info *nxi,
9815 + struct task_struct *task, const char *_file, int _line)
9817 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
9818 + nxi, nxi ? nxi->nx_id : 0,
9819 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9820 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
9821 + task, _file, _line);
9825 + if (atomic_dec_and_test(&nxi->nx_tasks))
9826 + unhash_nx_info(nxi);
9830 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
9832 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
9833 + const char *_file, int _line)
9835 + struct nx_info *nxi;
9838 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
9840 + nxi = __get_nx_info(p->nx_info, _file, _line);
9846 +static inline void exit_nx_info(struct task_struct *p)
9849 + release_nx_info(p->nx_info, p);
9854 +#warning duplicate inclusion
9856 diff -NurpP --minimal linux-3.10.15/include/linux/vs_pid.h linux-3.10.15-vs2.3.6.6/include/linux/vs_pid.h
9857 --- linux-3.10.15/include/linux/vs_pid.h 1970-01-01 00:00:00.000000000 +0000
9858 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_pid.h 2013-08-22 20:30:00.000000000 +0000
9863 +#include "vserver/base.h"
9864 +#include "vserver/check.h"
9865 +#include "vserver/context.h"
9866 +#include "vserver/debug.h"
9867 +#include "vserver/pid.h"
9868 +#include <linux/pid_namespace.h>
9871 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
9874 +int vx_proc_task_visible(struct task_struct *task)
9876 + if ((task->pid == 1) &&
9877 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
9878 + /* show a blend through init */
9880 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
9887 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
9891 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
9893 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
9895 + if (task && !vx_proc_task_visible(task)) {
9896 + vxdprintk(VXD_CBIT(misc, 6),
9897 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
9898 + task, task->xid, task->pid,
9899 + current, current->xid, current->pid);
9900 + put_task_struct(task);
9908 +#warning duplicate inclusion
9910 diff -NurpP --minimal linux-3.10.15/include/linux/vs_sched.h linux-3.10.15-vs2.3.6.6/include/linux/vs_sched.h
9911 --- linux-3.10.15/include/linux/vs_sched.h 1970-01-01 00:00:00.000000000 +0000
9912 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_sched.h 2013-08-22 20:30:00.000000000 +0000
9914 +#ifndef _VS_SCHED_H
9915 +#define _VS_SCHED_H
9917 +#include "vserver/base.h"
9918 +#include "vserver/context.h"
9919 +#include "vserver/sched.h"
9922 +#define MAX_PRIO_BIAS 20
9923 +#define MIN_PRIO_BIAS -20
9926 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
9928 + struct vx_info *vxi = p->vx_info;
9931 + prio += vx_cpu(vxi, sched_pc).prio_bias;
9935 +static inline void vx_account_user(struct vx_info *vxi,
9936 + cputime_t cputime, int nice)
9940 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
9943 +static inline void vx_account_system(struct vx_info *vxi,
9944 + cputime_t cputime, int idle)
9948 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
9952 +#warning duplicate inclusion
9954 diff -NurpP --minimal linux-3.10.15/include/linux/vs_socket.h linux-3.10.15-vs2.3.6.6/include/linux/vs_socket.h
9955 --- linux-3.10.15/include/linux/vs_socket.h 1970-01-01 00:00:00.000000000 +0000
9956 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_socket.h 2013-08-22 20:30:00.000000000 +0000
9958 +#ifndef _VS_SOCKET_H
9959 +#define _VS_SOCKET_H
9961 +#include "vserver/debug.h"
9962 +#include "vserver/base.h"
9963 +#include "vserver/cacct.h"
9964 +#include "vserver/context.h"
9965 +#include "vserver/tag.h"
9968 +/* socket accounting */
9970 +#include <linux/socket.h>
9972 +static inline int vx_sock_type(int family)
9976 + return VXA_SOCK_UNSPEC;
9978 + return VXA_SOCK_UNIX;
9980 + return VXA_SOCK_INET;
9982 + return VXA_SOCK_INET6;
9984 + return VXA_SOCK_PACKET;
9986 + return VXA_SOCK_OTHER;
9990 +#define vx_acc_sock(v, f, p, s) \
9991 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
9993 +static inline void __vx_acc_sock(struct vx_info *vxi,
9994 + int family, int pos, int size, char *file, int line)
9997 + int type = vx_sock_type(family);
9999 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10000 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10004 +#define vx_sock_recv(sk, s) \
10005 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10006 +#define vx_sock_send(sk, s) \
10007 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10008 +#define vx_sock_fail(sk, s) \
10009 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10012 +#define sock_vx_init(s) do { \
10013 + (s)->sk_xid = 0; \
10014 + (s)->sk_vx_info = NULL; \
10017 +#define sock_nx_init(s) do { \
10018 + (s)->sk_nid = 0; \
10019 + (s)->sk_nx_info = NULL; \
10023 +#warning duplicate inclusion
10025 diff -NurpP --minimal linux-3.10.15/include/linux/vs_tag.h linux-3.10.15-vs2.3.6.6/include/linux/vs_tag.h
10026 --- linux-3.10.15/include/linux/vs_tag.h 1970-01-01 00:00:00.000000000 +0000
10027 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_tag.h 2013-08-22 20:30:00.000000000 +0000
10032 +#include <linux/vserver/tag.h>
10034 +/* check conditions */
10036 +#define DX_ADMIN 0x0001
10037 +#define DX_WATCH 0x0002
10038 +#define DX_HOSTID 0x0008
10040 +#define DX_IDENT 0x0010
10042 +#define DX_ARG_MASK 0x0010
10045 +#define dx_task_tag(t) ((t)->tag)
10047 +#define dx_current_tag() dx_task_tag(current)
10049 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10051 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10055 + * check current context for ADMIN/WATCH and
10056 + * optionally against supplied argument
10058 +static inline int __dx_check(vtag_t cid, vtag_t id, unsigned int mode)
10060 + if (mode & DX_ARG_MASK) {
10061 + if ((mode & DX_IDENT) && (id == cid))
10064 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10065 + ((mode & DX_WATCH) && (cid == 1)) ||
10066 + ((mode & DX_HOSTID) && (id == 0)));
10070 +int dx_permission(const struct inode *inode, int mask);
10074 +#warning duplicate inclusion
10076 diff -NurpP --minimal linux-3.10.15/include/linux/vs_time.h linux-3.10.15-vs2.3.6.6/include/linux/vs_time.h
10077 --- linux-3.10.15/include/linux/vs_time.h 1970-01-01 00:00:00.000000000 +0000
10078 +++ linux-3.10.15-vs2.3.6.6/include/linux/vs_time.h 2013-08-22 20:30:00.000000000 +0000
10080 +#ifndef _VS_TIME_H
10081 +#define _VS_TIME_H
10084 +/* time faking stuff */
10086 +#ifdef CONFIG_VSERVER_VTIME
10088 +extern void vx_adjust_timespec(struct timespec *ts);
10089 +extern int vx_settimeofday(const struct timespec *ts);
10092 +#define vx_adjust_timespec(t) do { } while (0)
10093 +#define vx_settimeofday(t) do_settimeofday(t)
10097 +#warning duplicate inclusion
10099 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/base.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/base.h
10100 --- linux-3.10.15/include/linux/vserver/base.h 1970-01-01 00:00:00.000000000 +0000
10101 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/base.h 2013-08-22 20:30:00.000000000 +0000
10103 +#ifndef _VSERVER_BASE_H
10104 +#define _VSERVER_BASE_H
10107 +/* context state changes */
10119 +#define vx_task_xid(t) ((t)->xid)
10121 +#define vx_current_xid() vx_task_xid(current)
10123 +#define current_vx_info() (current->vx_info)
10126 +#define nx_task_nid(t) ((t)->nid)
10128 +#define nx_current_nid() nx_task_nid(current)
10130 +#define current_nx_info() (current->nx_info)
10133 +/* generic flag merging */
10135 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10137 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10139 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10141 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10144 +/* context flags */
10146 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10148 +#define vx_current_flags() __vx_flags(current_vx_info())
10150 +#define vx_info_flags(v, m, f) \
10151 + vs_check_flags(__vx_flags(v), m, f)
10153 +#define task_vx_flags(t, m, f) \
10154 + ((t) && vx_info_flags((t)->vx_info, m, f))
10156 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10159 +/* context caps */
10161 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10163 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10165 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10167 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10171 +/* network flags */
10173 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10175 +#define nx_current_flags() __nx_flags(current_nx_info())
10177 +#define nx_info_flags(n, m, f) \
10178 + vs_check_flags(__nx_flags(n), m, f)
10180 +#define task_nx_flags(t, m, f) \
10181 + ((t) && nx_info_flags((t)->nx_info, m, f))
10183 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10186 +/* network caps */
10188 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10190 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10192 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10194 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10197 +/* context mask capabilities */
10199 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10201 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10203 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10206 +/* context bcap mask */
10208 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10210 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10213 +/* mask given bcaps */
10215 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10217 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10220 +/* masked cap_bset */
10222 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10224 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10227 +#define vx_info_mbcap(v, b) \
10228 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10229 + vx_info_bcaps(v, b) : (b))
10231 +#define task_vx_mbcap(t, b) \
10232 + vx_info_mbcap((t)->vx_info, (t)->b)
10234 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10237 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10239 +#define vx_capable(b, c) (capable(b) || \
10240 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10242 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
10243 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10245 +#define nx_capable(b, c) (capable(b) || \
10246 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10248 +#define vx_task_initpid(t, n) \
10249 + ((t)->vx_info && \
10250 + ((t)->vx_info->vx_initpid == (n)))
10252 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10255 +/* context unshare mask */
10257 +#define __vx_umask(v) ((v)->vx_umask)
10259 +#define vx_current_umask() __vx_umask(current_vx_info())
10261 +#define vx_can_unshare(b, f) (capable(b) || \
10262 + (cap_raised(current_cap(), b) && \
10263 + !((f) & ~vx_current_umask())))
10265 +#define vx_ns_can_unshare(n, b, f) (ns_capable(n, b) || \
10266 + (cap_raised(current_cap(), b) && \
10267 + !((f) & ~vx_current_umask())))
10269 +#define __vx_wmask(v) ((v)->vx_wmask)
10271 +#define vx_current_wmask() __vx_wmask(current_vx_info())
10274 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10276 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10279 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10281 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10284 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/cacct.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/cacct.h
10285 --- linux-3.10.15/include/linux/vserver/cacct.h 1970-01-01 00:00:00.000000000 +0000
10286 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/cacct.h 2013-08-22 20:30:00.000000000 +0000
10288 +#ifndef _VSERVER_CACCT_H
10289 +#define _VSERVER_CACCT_H
10292 +enum sock_acc_field {
10293 + VXA_SOCK_UNSPEC = 0,
10299 + VXA_SOCK_SIZE /* array size */
10302 +#endif /* _VSERVER_CACCT_H */
10303 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/cacct_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/cacct_cmd.h
10304 --- linux-3.10.15/include/linux/vserver/cacct_cmd.h 1970-01-01 00:00:00.000000000 +0000
10305 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/cacct_cmd.h 2013-08-22 20:30:00.000000000 +0000
10307 +#ifndef _VSERVER_CACCT_CMD_H
10308 +#define _VSERVER_CACCT_CMD_H
10311 +#include <linux/compiler.h>
10312 +#include <uapi/vserver/cacct_cmd.h>
10314 +extern int vc_sock_stat(struct vx_info *, void __user *);
10316 +#endif /* _VSERVER_CACCT_CMD_H */
10317 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/cacct_def.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/cacct_def.h
10318 --- linux-3.10.15/include/linux/vserver/cacct_def.h 1970-01-01 00:00:00.000000000 +0000
10319 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/cacct_def.h 2013-08-22 20:30:00.000000000 +0000
10321 +#ifndef _VSERVER_CACCT_DEF_H
10322 +#define _VSERVER_CACCT_DEF_H
10324 +#include <asm/atomic.h>
10325 +#include <linux/vserver/cacct.h>
10328 +struct _vx_sock_acc {
10329 + atomic_long_t count;
10330 + atomic_long_t total;
10333 +/* context sub struct */
10335 +struct _vx_cacct {
10336 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10337 + atomic_t slab[8];
10338 + atomic_t page[6][8];
10341 +#ifdef CONFIG_VSERVER_DEBUG
10343 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10347 + printk("\t_vx_cacct:");
10348 + for (i = 0; i < 6; i++) {
10349 + struct _vx_sock_acc *ptr = cacct->sock[i];
10351 + printk("\t [%d] =", i);
10352 + for (j = 0; j < 3; j++) {
10353 + printk(" [%d] = %8lu, %8lu", j,
10354 + atomic_long_read(&ptr[j].count),
10355 + atomic_long_read(&ptr[j].total));
10363 +#endif /* _VSERVER_CACCT_DEF_H */
10364 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/cacct_int.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/cacct_int.h
10365 --- linux-3.10.15/include/linux/vserver/cacct_int.h 1970-01-01 00:00:00.000000000 +0000
10366 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/cacct_int.h 2013-08-22 20:30:00.000000000 +0000
10368 +#ifndef _VSERVER_CACCT_INT_H
10369 +#define _VSERVER_CACCT_INT_H
10372 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10374 + return atomic_long_read(&cacct->sock[type][pos].count);
10379 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10381 + return atomic_long_read(&cacct->sock[type][pos].total);
10384 +#endif /* _VSERVER_CACCT_INT_H */
10385 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/check.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/check.h
10386 --- linux-3.10.15/include/linux/vserver/check.h 1970-01-01 00:00:00.000000000 +0000
10387 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/check.h 2013-08-22 20:30:00.000000000 +0000
10389 +#ifndef _VSERVER_CHECK_H
10390 +#define _VSERVER_CHECK_H
10393 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10395 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10396 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10398 +#define MIN_D_CONTEXT 65536
10401 +/* check conditions */
10403 +#define VS_ADMIN 0x0001
10404 +#define VS_WATCH 0x0002
10405 +#define VS_HIDE 0x0004
10406 +#define VS_HOSTID 0x0008
10408 +#define VS_IDENT 0x0010
10409 +#define VS_EQUIV 0x0020
10410 +#define VS_PARENT 0x0040
10411 +#define VS_CHILD 0x0080
10413 +#define VS_ARG_MASK 0x00F0
10415 +#define VS_DYNAMIC 0x0100
10416 +#define VS_STATIC 0x0200
10418 +#define VS_ATR_MASK 0x0F00
10420 +#ifdef CONFIG_VSERVER_PRIVACY
10421 +#define VS_ADMIN_P (0)
10422 +#define VS_WATCH_P (0)
10424 +#define VS_ADMIN_P VS_ADMIN
10425 +#define VS_WATCH_P VS_WATCH
10428 +#define VS_HARDIRQ 0x1000
10429 +#define VS_SOFTIRQ 0x2000
10430 +#define VS_IRQ 0x4000
10432 +#define VS_IRQ_MASK 0xF000
10434 +#include <linux/hardirq.h>
10437 + * check current context for ADMIN/WATCH and
10438 + * optionally against supplied argument
10440 +static inline int __vs_check(int cid, int id, unsigned int mode)
10442 + if (mode & VS_ARG_MASK) {
10443 + if ((mode & VS_IDENT) && (id == cid))
10446 + if (mode & VS_ATR_MASK) {
10447 + if ((mode & VS_DYNAMIC) &&
10448 + (id >= MIN_D_CONTEXT) &&
10449 + (id <= MAX_S_CONTEXT))
10451 + if ((mode & VS_STATIC) &&
10452 + (id > 1) && (id < MIN_D_CONTEXT))
10455 + if (mode & VS_IRQ_MASK) {
10456 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10458 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10460 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10463 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10464 + ((mode & VS_WATCH) && (cid == 1)) ||
10465 + ((mode & VS_HOSTID) && (id == 0)));
10468 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10470 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10473 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10475 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10478 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/context.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/context.h
10479 --- linux-3.10.15/include/linux/vserver/context.h 1970-01-01 00:00:00.000000000 +0000
10480 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/context.h 2013-08-22 20:30:00.000000000 +0000
10482 +#ifndef _VSERVER_CONTEXT_H
10483 +#define _VSERVER_CONTEXT_H
10486 +#include <linux/list.h>
10487 +#include <linux/spinlock.h>
10488 +#include <linux/rcupdate.h>
10489 +#include <uapi/vserver/context.h>
10491 +#include "limit_def.h"
10492 +#include "sched_def.h"
10493 +#include "cvirt_def.h"
10494 +#include "cacct_def.h"
10495 +#include "device_def.h"
10497 +#define VX_SPACES 2
10499 +struct _vx_info_pc {
10500 + struct _vx_sched_pc sched_pc;
10501 + struct _vx_cvirt_pc cvirt_pc;
10504 +struct _vx_space {
10505 + unsigned long vx_nsmask; /* assignment mask */
10506 + struct nsproxy *vx_nsproxy; /* private namespaces */
10507 + struct fs_struct *vx_fs; /* private namespace fs */
10508 + const struct cred *vx_cred; /* task credentials */
10512 + struct hlist_node vx_hlist; /* linked list of contexts */
10513 + vxid_t vx_id; /* context id */
10514 + atomic_t vx_usecnt; /* usage count */
10515 + atomic_t vx_tasks; /* tasks count */
10516 + struct vx_info *vx_parent; /* parent context */
10517 + int vx_state; /* context state */
10519 + struct _vx_space space[VX_SPACES]; /* namespace store */
10521 + uint64_t vx_flags; /* context flags */
10522 + uint64_t vx_ccaps; /* context caps (vserver) */
10523 + uint64_t vx_umask; /* unshare mask (guest) */
10524 + uint64_t vx_wmask; /* warn mask (guest) */
10525 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10527 + struct task_struct *vx_reaper; /* guest reaper process */
10528 + pid_t vx_initpid; /* PID of guest init */
10529 + int64_t vx_badness_bias; /* OOM points bias */
10531 + struct _vx_limit limit; /* vserver limits */
10532 + struct _vx_sched sched; /* vserver scheduler */
10533 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10534 + struct _vx_cacct cacct; /* context accounting */
10536 + struct _vx_device dmap; /* default device map targets */
10538 +#ifndef CONFIG_SMP
10539 + struct _vx_info_pc info_pc; /* per cpu data */
10541 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10544 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10545 + int reboot_cmd; /* last sys_reboot() cmd */
10546 + int exit_code; /* last process exit code */
10548 + char vx_name[65]; /* vserver name */
10551 +#ifndef CONFIG_SMP
10552 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10553 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10555 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10556 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10559 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10562 +struct vx_info_save {
10563 + struct vx_info *vxi;
10568 +/* status flags */
10570 +#define VXS_HASHED 0x0001
10571 +#define VXS_PAUSED 0x0010
10572 +#define VXS_SHUTDOWN 0x0100
10573 +#define VXS_HELPER 0x1000
10574 +#define VXS_RELEASED 0x8000
10577 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10578 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10580 +extern struct vx_info *lookup_vx_info(int);
10581 +extern struct vx_info *lookup_or_create_vx_info(int);
10583 +extern int get_xid_list(int, unsigned int *, int);
10584 +extern int xid_is_hashed(vxid_t);
10586 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10588 +extern long vs_state_change(struct vx_info *, unsigned int);
10591 +#endif /* _VSERVER_CONTEXT_H */
10592 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/context_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/context_cmd.h
10593 --- linux-3.10.15/include/linux/vserver/context_cmd.h 1970-01-01 00:00:00.000000000 +0000
10594 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/context_cmd.h 2013-08-22 20:30:00.000000000 +0000
10596 +#ifndef _VSERVER_CONTEXT_CMD_H
10597 +#define _VSERVER_CONTEXT_CMD_H
10599 +#include <uapi/vserver/context_cmd.h>
10601 +extern int vc_task_xid(uint32_t);
10603 +extern int vc_vx_info(struct vx_info *, void __user *);
10605 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10607 +extern int vc_ctx_create(uint32_t, void __user *);
10608 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10610 +extern int vc_get_cflags(struct vx_info *, void __user *);
10611 +extern int vc_set_cflags(struct vx_info *, void __user *);
10613 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10614 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10616 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10617 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10619 +extern int vc_get_umask(struct vx_info *, void __user *);
10620 +extern int vc_set_umask(struct vx_info *, void __user *);
10622 +extern int vc_get_wmask(struct vx_info *, void __user *);
10623 +extern int vc_set_wmask(struct vx_info *, void __user *);
10625 +extern int vc_get_badness(struct vx_info *, void __user *);
10626 +extern int vc_set_badness(struct vx_info *, void __user *);
10628 +#endif /* _VSERVER_CONTEXT_CMD_H */
10629 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/cvirt.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/cvirt.h
10630 --- linux-3.10.15/include/linux/vserver/cvirt.h 1970-01-01 00:00:00.000000000 +0000
10631 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/cvirt.h 2013-08-22 20:30:00.000000000 +0000
10633 +#ifndef _VSERVER_CVIRT_H
10634 +#define _VSERVER_CVIRT_H
10638 +void vx_vsi_boottime(struct timespec *);
10640 +void vx_vsi_uptime(struct timespec *, struct timespec *);
10645 +void vx_update_load(struct vx_info *);
10648 +int vx_do_syslog(int, char __user *, int);
10650 +#endif /* _VSERVER_CVIRT_H */
10651 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/cvirt_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/cvirt_cmd.h
10652 --- linux-3.10.15/include/linux/vserver/cvirt_cmd.h 1970-01-01 00:00:00.000000000 +0000
10653 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/cvirt_cmd.h 2013-08-22 20:30:00.000000000 +0000
10655 +#ifndef _VSERVER_CVIRT_CMD_H
10656 +#define _VSERVER_CVIRT_CMD_H
10659 +#include <linux/compiler.h>
10660 +#include <uapi/vserver/cvirt_cmd.h>
10662 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10663 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10665 +extern int vc_virt_stat(struct vx_info *, void __user *);
10667 +#endif /* _VSERVER_CVIRT_CMD_H */
10668 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/cvirt_def.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/cvirt_def.h
10669 --- linux-3.10.15/include/linux/vserver/cvirt_def.h 1970-01-01 00:00:00.000000000 +0000
10670 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/cvirt_def.h 2013-08-22 20:30:00.000000000 +0000
10672 +#ifndef _VSERVER_CVIRT_DEF_H
10673 +#define _VSERVER_CVIRT_DEF_H
10675 +#include <linux/jiffies.h>
10676 +#include <linux/spinlock.h>
10677 +#include <linux/wait.h>
10678 +#include <linux/time.h>
10679 +#include <asm/atomic.h>
10682 +struct _vx_usage_stat {
10686 + uint64_t softirq;
10692 +struct _vx_syslog {
10693 + wait_queue_head_t log_wait;
10694 + spinlock_t logbuf_lock; /* lock for the log buffer */
10696 + unsigned long log_start; /* next char to be read by syslog() */
10697 + unsigned long con_start; /* next char to be sent to consoles */
10698 + unsigned long log_end; /* most-recently-written-char + 1 */
10699 + unsigned long logged_chars; /* #chars since last read+clear operation */
10701 + char log_buf[1024];
10705 +/* context sub struct */
10707 +struct _vx_cvirt {
10708 + atomic_t nr_threads; /* number of current threads */
10709 + atomic_t nr_running; /* number of running threads */
10710 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10712 + atomic_t nr_onhold; /* processes on hold */
10713 + uint32_t onhold_last; /* jiffies when put on hold */
10715 + struct timespec bias_ts; /* time offset to the host */
10716 + struct timespec bias_idle;
10717 + struct timespec bias_uptime; /* context creation point */
10718 + uint64_t bias_clock; /* offset in clock_t */
10720 + spinlock_t load_lock; /* lock for the load averages */
10721 + atomic_t load_updates; /* nr of load updates done so far */
10722 + uint32_t load_last; /* last time load was calculated */
10723 + uint32_t load[3]; /* load averages 1,5,15 */
10725 + atomic_t total_forks; /* number of forks so far */
10727 + struct _vx_syslog syslog;
10730 +struct _vx_cvirt_pc {
10731 + struct _vx_usage_stat cpustat;
10735 +#ifdef CONFIG_VSERVER_DEBUG
10737 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
10739 + printk("\t_vx_cvirt:\n");
10740 + printk("\t threads: %4d, %4d, %4d, %4d\n",
10741 + atomic_read(&cvirt->nr_threads),
10742 + atomic_read(&cvirt->nr_running),
10743 + atomic_read(&cvirt->nr_uninterruptible),
10744 + atomic_read(&cvirt->nr_onhold));
10745 + /* add rest here */
10746 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
10751 +#endif /* _VSERVER_CVIRT_DEF_H */
10752 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/debug.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/debug.h
10753 --- linux-3.10.15/include/linux/vserver/debug.h 1970-01-01 00:00:00.000000000 +0000
10754 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/debug.h 2013-08-22 20:30:00.000000000 +0000
10756 +#ifndef _VSERVER_DEBUG_H
10757 +#define _VSERVER_DEBUG_H
10760 +#define VXD_CBIT(n, m) (vs_debug_ ## n & (1 << (m)))
10761 +#define VXD_CMIN(n, m) (vs_debug_ ## n > (m))
10762 +#define VXD_MASK(n, m) (vs_debug_ ## n & (m))
10764 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
10765 + imajor((d)->bd_inode), iminor((d)->bd_inode)
10766 +#define VXF_DEV "%p[%lu,%d:%d]"
10768 +#if defined(CONFIG_QUOTES_UTF8)
10769 +#define VS_Q_LQM "\xc2\xbb"
10770 +#define VS_Q_RQM "\xc2\xab"
10771 +#elif defined(CONFIG_QUOTES_ASCII)
10772 +#define VS_Q_LQM "\x27"
10773 +#define VS_Q_RQM "\x27"
10775 +#define VS_Q_LQM "\xbb"
10776 +#define VS_Q_RQM "\xab"
10779 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
10782 +#define vxd_path(p) \
10783 + ({ static char _buffer[PATH_MAX]; \
10784 + d_path(p, _buffer, sizeof(_buffer)); })
10786 +#define vxd_cond_path(n) \
10787 + ((n) ? vxd_path(&(n)->path) : "<null>" )
10790 +#ifdef CONFIG_VSERVER_DEBUG
10792 +extern unsigned int vs_debug_switch;
10793 +extern unsigned int vs_debug_xid;
10794 +extern unsigned int vs_debug_nid;
10795 +extern unsigned int vs_debug_tag;
10796 +extern unsigned int vs_debug_net;
10797 +extern unsigned int vs_debug_limit;
10798 +extern unsigned int vs_debug_cres;
10799 +extern unsigned int vs_debug_dlim;
10800 +extern unsigned int vs_debug_quota;
10801 +extern unsigned int vs_debug_cvirt;
10802 +extern unsigned int vs_debug_space;
10803 +extern unsigned int vs_debug_perm;
10804 +extern unsigned int vs_debug_misc;
10807 +#define VX_LOGLEVEL "vxD: "
10808 +#define VX_PROC_FMT "%p: "
10809 +#define VX_PROCESS current
10811 +#define vxdprintk(c, f, x...) \
10814 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
10815 + VX_PROCESS , ##x); \
10818 +#define vxlprintk(c, f, x...) \
10821 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
10824 +#define vxfprintk(c, f, x...) \
10827 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
10833 +void dump_vx_info(struct vx_info *, int);
10834 +void dump_vx_info_inactive(int);
10836 +#else /* CONFIG_VSERVER_DEBUG */
10838 +#define vs_debug_switch 0
10839 +#define vs_debug_xid 0
10840 +#define vs_debug_nid 0
10841 +#define vs_debug_tag 0
10842 +#define vs_debug_net 0
10843 +#define vs_debug_limit 0
10844 +#define vs_debug_cres 0
10845 +#define vs_debug_dlim 0
10846 +#define vs_debug_quota 0
10847 +#define vs_debug_cvirt 0
10848 +#define vs_debug_space 0
10849 +#define vs_debug_perm 0
10850 +#define vs_debug_misc 0
10852 +#define vxdprintk(x...) do { } while (0)
10853 +#define vxlprintk(x...) do { } while (0)
10854 +#define vxfprintk(x...) do { } while (0)
10856 +#endif /* CONFIG_VSERVER_DEBUG */
10859 +#ifdef CONFIG_VSERVER_WARN
10861 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
10862 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
10863 +#define VX_WARN_XID "[xid #%u] "
10864 +#define VX_WARN_NID "[nid #%u] "
10865 +#define VX_WARN_TAG "[tag #%u] "
10867 +#define vxwprintk(c, f, x...) \
10870 + printk(VX_WARNLEVEL f "\n", ##x); \
10873 +#else /* CONFIG_VSERVER_WARN */
10875 +#define vxwprintk(x...) do { } while (0)
10877 +#endif /* CONFIG_VSERVER_WARN */
10879 +#define vxwprintk_task(c, f, x...) \
10880 + vxwprintk(c, VX_WARN_TASK f, \
10881 + current->comm, current->pid, \
10882 + current->xid, current->nid, \
10883 + current->tag, ##x)
10884 +#define vxwprintk_xid(c, f, x...) \
10885 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
10886 +#define vxwprintk_nid(c, f, x...) \
10887 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
10888 +#define vxwprintk_tag(c, f, x...) \
10889 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
10891 +#ifdef CONFIG_VSERVER_DEBUG
10892 +#define vxd_assert_lock(l) assert_spin_locked(l)
10893 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
10894 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
10896 +#define vxd_assert_lock(l) do { } while (0)
10897 +#define vxd_assert(c, f, x...) do { } while (0)
10901 +#endif /* _VSERVER_DEBUG_H */
10902 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/debug_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/debug_cmd.h
10903 --- linux-3.10.15/include/linux/vserver/debug_cmd.h 1970-01-01 00:00:00.000000000 +0000
10904 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/debug_cmd.h 2013-08-22 20:30:00.000000000 +0000
10906 +#ifndef _VSERVER_DEBUG_CMD_H
10907 +#define _VSERVER_DEBUG_CMD_H
10909 +#include <uapi/vserver/debug_cmd.h>
10912 +#ifdef CONFIG_COMPAT
10914 +#include <asm/compat.h>
10916 +struct vcmd_read_history_v0_x32 {
10919 + compat_uptr_t data_ptr;
10922 +struct vcmd_read_monitor_v0_x32 {
10925 + compat_uptr_t data_ptr;
10928 +#endif /* CONFIG_COMPAT */
10930 +extern int vc_dump_history(uint32_t);
10932 +extern int vc_read_history(uint32_t, void __user *);
10933 +extern int vc_read_monitor(uint32_t, void __user *);
10935 +#ifdef CONFIG_COMPAT
10937 +extern int vc_read_history_x32(uint32_t, void __user *);
10938 +extern int vc_read_monitor_x32(uint32_t, void __user *);
10940 +#endif /* CONFIG_COMPAT */
10942 +#endif /* _VSERVER_DEBUG_CMD_H */
10943 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/device.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/device.h
10944 --- linux-3.10.15/include/linux/vserver/device.h 1970-01-01 00:00:00.000000000 +0000
10945 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/device.h 2013-08-22 20:30:00.000000000 +0000
10947 +#ifndef _VSERVER_DEVICE_H
10948 +#define _VSERVER_DEVICE_H
10951 +#include <uapi/vserver/device.h>
10953 +#else /* _VSERVER_DEVICE_H */
10954 +#warning duplicate inclusion
10955 +#endif /* _VSERVER_DEVICE_H */
10956 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/device_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/device_cmd.h
10957 --- linux-3.10.15/include/linux/vserver/device_cmd.h 1970-01-01 00:00:00.000000000 +0000
10958 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/device_cmd.h 2013-08-22 20:30:00.000000000 +0000
10960 +#ifndef _VSERVER_DEVICE_CMD_H
10961 +#define _VSERVER_DEVICE_CMD_H
10963 +#include <uapi/vserver/device_cmd.h>
10966 +#ifdef CONFIG_COMPAT
10968 +#include <asm/compat.h>
10970 +struct vcmd_set_mapping_v0_x32 {
10971 + compat_uptr_t device_ptr;
10972 + compat_uptr_t target_ptr;
10976 +#endif /* CONFIG_COMPAT */
10978 +#include <linux/compiler.h>
10980 +extern int vc_set_mapping(struct vx_info *, void __user *);
10981 +extern int vc_unset_mapping(struct vx_info *, void __user *);
10983 +#ifdef CONFIG_COMPAT
10985 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
10986 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
10988 +#endif /* CONFIG_COMPAT */
10990 +#endif /* _VSERVER_DEVICE_CMD_H */
10991 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/device_def.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/device_def.h
10992 --- linux-3.10.15/include/linux/vserver/device_def.h 1970-01-01 00:00:00.000000000 +0000
10993 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/device_def.h 2013-08-22 20:30:00.000000000 +0000
10995 +#ifndef _VSERVER_DEVICE_DEF_H
10996 +#define _VSERVER_DEVICE_DEF_H
10998 +#include <linux/types.h>
11000 +struct vx_dmap_target {
11005 +struct _vx_device {
11006 +#ifdef CONFIG_VSERVER_DEVICE
11007 + struct vx_dmap_target targets[2];
11011 +#endif /* _VSERVER_DEVICE_DEF_H */
11012 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/dlimit.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/dlimit.h
11013 --- linux-3.10.15/include/linux/vserver/dlimit.h 1970-01-01 00:00:00.000000000 +0000
11014 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/dlimit.h 2013-08-22 20:30:00.000000000 +0000
11016 +#ifndef _VSERVER_DLIMIT_H
11017 +#define _VSERVER_DLIMIT_H
11019 +#include "switch.h"
11024 +/* keep in sync with CDLIM_INFINITY */
11026 +#define DLIM_INFINITY (~0ULL)
11028 +#include <linux/spinlock.h>
11029 +#include <linux/rcupdate.h>
11031 +struct super_block;
11034 + struct hlist_node dl_hlist; /* linked list of contexts */
11035 + struct rcu_head dl_rcu; /* the rcu head */
11036 + vtag_t dl_tag; /* context tag */
11037 + atomic_t dl_usecnt; /* usage count */
11038 + atomic_t dl_refcnt; /* reference count */
11040 + struct super_block *dl_sb; /* associated superblock */
11042 + spinlock_t dl_lock; /* protect the values */
11044 + unsigned long long dl_space_used; /* used space in bytes */
11045 + unsigned long long dl_space_total; /* maximum space in bytes */
11046 + unsigned long dl_inodes_used; /* used inodes */
11047 + unsigned long dl_inodes_total; /* maximum inodes */
11049 + unsigned int dl_nrlmult; /* non root limit mult */
11054 +extern void rcu_free_dl_info(struct rcu_head *);
11055 +extern void unhash_dl_info(struct dl_info *);
11057 +extern struct dl_info *locate_dl_info(struct super_block *, vtag_t);
11062 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11064 +typedef uint64_t dlsize_t;
11066 +#endif /* __KERNEL__ */
11067 +#else /* _VSERVER_DLIMIT_H */
11068 +#warning duplicate inclusion
11069 +#endif /* _VSERVER_DLIMIT_H */
11070 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/dlimit_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/dlimit_cmd.h
11071 --- linux-3.10.15/include/linux/vserver/dlimit_cmd.h 1970-01-01 00:00:00.000000000 +0000
11072 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/dlimit_cmd.h 2013-08-22 20:30:00.000000000 +0000
11074 +#ifndef _VSERVER_DLIMIT_CMD_H
11075 +#define _VSERVER_DLIMIT_CMD_H
11077 +#include <uapi/vserver/dlimit_cmd.h>
11080 +#ifdef CONFIG_COMPAT
11082 +#include <asm/compat.h>
11084 +struct vcmd_ctx_dlimit_base_v0_x32 {
11085 + compat_uptr_t name_ptr;
11089 +struct vcmd_ctx_dlimit_v0_x32 {
11090 + compat_uptr_t name_ptr;
11091 + uint32_t space_used; /* used space in kbytes */
11092 + uint32_t space_total; /* maximum space in kbytes */
11093 + uint32_t inodes_used; /* used inodes */
11094 + uint32_t inodes_total; /* maximum inodes */
11095 + uint32_t reserved; /* reserved for root in % */
11099 +#endif /* CONFIG_COMPAT */
11101 +#include <linux/compiler.h>
11103 +extern int vc_add_dlimit(uint32_t, void __user *);
11104 +extern int vc_rem_dlimit(uint32_t, void __user *);
11106 +extern int vc_set_dlimit(uint32_t, void __user *);
11107 +extern int vc_get_dlimit(uint32_t, void __user *);
11109 +#ifdef CONFIG_COMPAT
11111 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11112 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11114 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11115 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11117 +#endif /* CONFIG_COMPAT */
11119 +#endif /* _VSERVER_DLIMIT_CMD_H */
11120 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/global.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/global.h
11121 --- linux-3.10.15/include/linux/vserver/global.h 1970-01-01 00:00:00.000000000 +0000
11122 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/global.h 2013-08-22 20:30:00.000000000 +0000
11124 +#ifndef _VSERVER_GLOBAL_H
11125 +#define _VSERVER_GLOBAL_H
11128 +extern atomic_t vx_global_ctotal;
11129 +extern atomic_t vx_global_cactive;
11131 +extern atomic_t nx_global_ctotal;
11132 +extern atomic_t nx_global_cactive;
11134 +extern atomic_t vs_global_nsproxy;
11135 +extern atomic_t vs_global_fs;
11136 +extern atomic_t vs_global_mnt_ns;
11137 +extern atomic_t vs_global_uts_ns;
11138 +extern atomic_t vs_global_user_ns;
11139 +extern atomic_t vs_global_pid_ns;
11142 +#endif /* _VSERVER_GLOBAL_H */
11143 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/history.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/history.h
11144 --- linux-3.10.15/include/linux/vserver/history.h 1970-01-01 00:00:00.000000000 +0000
11145 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/history.h 2013-08-22 20:30:00.000000000 +0000
11147 +#ifndef _VSERVER_HISTORY_H
11148 +#define _VSERVER_HISTORY_H
11153 + VXH_THROW_OOPS = 1,
11157 + VXH_INIT_VX_INFO,
11160 + VXH_CLAIM_VX_INFO,
11161 + VXH_RELEASE_VX_INFO,
11162 + VXH_ALLOC_VX_INFO,
11163 + VXH_DEALLOC_VX_INFO,
11164 + VXH_HASH_VX_INFO,
11165 + VXH_UNHASH_VX_INFO,
11167 + VXH_LOOKUP_VX_INFO,
11168 + VXH_CREATE_VX_INFO,
11171 +struct _vxhe_vxi {
11172 + struct vx_info *ptr;
11178 +struct _vxhe_set_clr {
11182 +struct _vxhe_loc_lookup {
11186 +struct _vx_hist_entry {
11188 + unsigned short seq;
11189 + unsigned short type;
11190 + struct _vxhe_vxi vxi;
11192 + struct _vxhe_set_clr sc;
11193 + struct _vxhe_loc_lookup ll;
11197 +#ifdef CONFIG_VSERVER_HISTORY
11199 +extern unsigned volatile int vxh_active;
11201 +struct _vx_hist_entry *vxh_advance(void *loc);
11205 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11207 + entry->vxi.ptr = vxi;
11209 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11210 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11211 + entry->vxi.xid = vxi->vx_id;
11216 +#define __HERE__ current_text_addr()
11218 +#define __VXH_BODY(__type, __data, __here) \
11219 + struct _vx_hist_entry *entry; \
11221 + preempt_disable(); \
11222 + entry = vxh_advance(__here); \
11224 + entry->type = __type; \
11225 + preempt_enable();
11228 + /* pass vxi only */
11230 +#define __VXH_SMPL \
11231 + __vxh_copy_vxi(entry, vxi)
11234 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11236 + __VXH_BODY(__type, __VXH_SMPL, __here)
11239 + /* pass vxi and data (void *) */
11241 +#define __VXH_DATA \
11242 + __vxh_copy_vxi(entry, vxi); \
11243 + entry->sc.data = data
11246 +void __vxh_data(struct vx_info *vxi, void *data,
11247 + int __type, void *__here)
11249 + __VXH_BODY(__type, __VXH_DATA, __here)
11252 + /* pass vxi and arg (long) */
11254 +#define __VXH_LONG \
11255 + __vxh_copy_vxi(entry, vxi); \
11256 + entry->ll.arg = arg
11259 +void __vxh_long(struct vx_info *vxi, long arg,
11260 + int __type, void *__here)
11262 + __VXH_BODY(__type, __VXH_LONG, __here)
11267 +void __vxh_throw_oops(void *__here)
11269 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11270 + /* prevent further acquisition */
11275 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11277 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11278 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11280 +#define __vxh_init_vx_info(v, d, h) \
11281 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11282 +#define __vxh_set_vx_info(v, d, h) \
11283 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11284 +#define __vxh_clr_vx_info(v, d, h) \
11285 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11287 +#define __vxh_claim_vx_info(v, d, h) \
11288 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11289 +#define __vxh_release_vx_info(v, d, h) \
11290 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11292 +#define vxh_alloc_vx_info(v) \
11293 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11294 +#define vxh_dealloc_vx_info(v) \
11295 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11297 +#define vxh_hash_vx_info(v) \
11298 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11299 +#define vxh_unhash_vx_info(v) \
11300 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11302 +#define vxh_loc_vx_info(v, l) \
11303 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11304 +#define vxh_lookup_vx_info(v, l) \
11305 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11306 +#define vxh_create_vx_info(v, l) \
11307 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11309 +extern void vxh_dump_history(void);
11312 +#else /* CONFIG_VSERVER_HISTORY */
11314 +#define __HERE__ 0
11316 +#define vxh_throw_oops() do { } while (0)
11318 +#define __vxh_get_vx_info(v, h) do { } while (0)
11319 +#define __vxh_put_vx_info(v, h) do { } while (0)
11321 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11322 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11323 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11325 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11326 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11328 +#define vxh_alloc_vx_info(v) do { } while (0)
11329 +#define vxh_dealloc_vx_info(v) do { } while (0)
11331 +#define vxh_hash_vx_info(v) do { } while (0)
11332 +#define vxh_unhash_vx_info(v) do { } while (0)
11334 +#define vxh_loc_vx_info(v, l) do { } while (0)
11335 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11336 +#define vxh_create_vx_info(v, l) do { } while (0)
11338 +#define vxh_dump_history() do { } while (0)
11341 +#endif /* CONFIG_VSERVER_HISTORY */
11343 +#endif /* _VSERVER_HISTORY_H */
11344 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/inode.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/inode.h
11345 --- linux-3.10.15/include/linux/vserver/inode.h 1970-01-01 00:00:00.000000000 +0000
11346 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/inode.h 2013-08-22 20:30:00.000000000 +0000
11348 +#ifndef _VSERVER_INODE_H
11349 +#define _VSERVER_INODE_H
11351 +#include <uapi/vserver/inode.h>
11354 +#ifdef CONFIG_VSERVER_PROC_SECURE
11355 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11356 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11358 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11359 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11362 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11364 +#else /* _VSERVER_INODE_H */
11365 +#warning duplicate inclusion
11366 +#endif /* _VSERVER_INODE_H */
11367 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/inode_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/inode_cmd.h
11368 --- linux-3.10.15/include/linux/vserver/inode_cmd.h 1970-01-01 00:00:00.000000000 +0000
11369 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/inode_cmd.h 2013-08-22 20:30:00.000000000 +0000
11371 +#ifndef _VSERVER_INODE_CMD_H
11372 +#define _VSERVER_INODE_CMD_H
11374 +#include <uapi/vserver/inode_cmd.h>
11378 +#ifdef CONFIG_COMPAT
11380 +#include <asm/compat.h>
11382 +struct vcmd_ctx_iattr_v1_x32 {
11383 + compat_uptr_t name_ptr;
11389 +#endif /* CONFIG_COMPAT */
11391 +#include <linux/compiler.h>
11393 +extern int vc_get_iattr(void __user *);
11394 +extern int vc_set_iattr(void __user *);
11396 +extern int vc_fget_iattr(uint32_t, void __user *);
11397 +extern int vc_fset_iattr(uint32_t, void __user *);
11399 +#ifdef CONFIG_COMPAT
11401 +extern int vc_get_iattr_x32(void __user *);
11402 +extern int vc_set_iattr_x32(void __user *);
11404 +#endif /* CONFIG_COMPAT */
11406 +#endif /* _VSERVER_INODE_CMD_H */
11407 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/limit.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/limit.h
11408 --- linux-3.10.15/include/linux/vserver/limit.h 1970-01-01 00:00:00.000000000 +0000
11409 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/limit.h 2013-08-22 20:30:00.000000000 +0000
11411 +#ifndef _VSERVER_LIMIT_H
11412 +#define _VSERVER_LIMIT_H
11414 +#include <uapi/vserver/limit.h>
11417 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
11419 +/* keep in sync with CRLIM_INFINITY */
11421 +#define VLIM_INFINITY (~0ULL)
11423 +#include <asm/atomic.h>
11424 +#include <asm/resource.h>
11426 +#ifndef RLIM_INFINITY
11427 +#warning RLIM_INFINITY is undefined
11430 +#define __rlim_val(l, r, v) ((l)->res[r].v)
11432 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
11433 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
11435 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
11436 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
11437 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
11439 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
11440 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
11442 +typedef atomic_long_t rlim_atomic_t;
11443 +typedef unsigned long rlim_t;
11445 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
11446 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
11447 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
11448 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
11449 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
11450 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
11453 +#if (RLIM_INFINITY == VLIM_INFINITY)
11454 +#define VX_VLIM(r) ((long long)(long)(r))
11455 +#define VX_RLIM(v) ((rlim_t)(v))
11457 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
11458 + ? VLIM_INFINITY : (long long)(r))
11459 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
11460 + ? RLIM_INFINITY : (rlim_t)(v))
11465 +void vx_vsi_meminfo(struct sysinfo *);
11466 +void vx_vsi_swapinfo(struct sysinfo *);
11467 +long vx_vsi_cached(struct sysinfo *);
11469 +#define NUM_LIMITS 24
11471 +#endif /* _VSERVER_LIMIT_H */
11472 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/limit_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/limit_cmd.h
11473 --- linux-3.10.15/include/linux/vserver/limit_cmd.h 1970-01-01 00:00:00.000000000 +0000
11474 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/limit_cmd.h 2013-08-22 20:30:00.000000000 +0000
11476 +#ifndef _VSERVER_LIMIT_CMD_H
11477 +#define _VSERVER_LIMIT_CMD_H
11479 +#include <uapi/vserver/limit_cmd.h>
11482 +#ifdef CONFIG_IA32_EMULATION
11484 +struct vcmd_ctx_rlimit_v0_x32 {
11486 + uint64_t minimum;
11487 + uint64_t softlimit;
11488 + uint64_t maximum;
11489 +} __attribute__ ((packed));
11491 +#endif /* CONFIG_IA32_EMULATION */
11493 +#include <linux/compiler.h>
11495 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11496 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11497 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11498 +extern int vc_reset_hits(struct vx_info *, void __user *);
11499 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11501 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11503 +#ifdef CONFIG_IA32_EMULATION
11505 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11506 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11508 +#endif /* CONFIG_IA32_EMULATION */
11510 +#endif /* _VSERVER_LIMIT_CMD_H */
11511 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/limit_def.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/limit_def.h
11512 --- linux-3.10.15/include/linux/vserver/limit_def.h 1970-01-01 00:00:00.000000000 +0000
11513 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/limit_def.h 2013-08-22 20:30:00.000000000 +0000
11515 +#ifndef _VSERVER_LIMIT_DEF_H
11516 +#define _VSERVER_LIMIT_DEF_H
11518 +#include <asm/atomic.h>
11519 +#include <asm/resource.h>
11521 +#include "limit.h"
11524 +struct _vx_res_limit {
11525 + rlim_t soft; /* Context soft limit */
11526 + rlim_t hard; /* Context hard limit */
11528 + rlim_atomic_t rcur; /* Current value */
11529 + rlim_t rmin; /* Context minimum */
11530 + rlim_t rmax; /* Context maximum */
11532 + atomic_t lhit; /* Limit hits */
11535 +/* context sub struct */
11537 +struct _vx_limit {
11538 + struct _vx_res_limit res[NUM_LIMITS];
11541 +#ifdef CONFIG_VSERVER_DEBUG
11543 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11547 + printk("\t_vx_limit:");
11548 + for (i = 0; i < NUM_LIMITS; i++) {
11549 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11550 + i, (unsigned long)__rlim_get(limit, i),
11551 + (unsigned long)__rlim_rmin(limit, i),
11552 + (unsigned long)__rlim_rmax(limit, i),
11553 + (long)__rlim_soft(limit, i),
11554 + (long)__rlim_hard(limit, i),
11555 + atomic_read(&__rlim_lhit(limit, i)));
11561 +#endif /* _VSERVER_LIMIT_DEF_H */
11562 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/limit_int.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/limit_int.h
11563 --- linux-3.10.15/include/linux/vserver/limit_int.h 1970-01-01 00:00:00.000000000 +0000
11564 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/limit_int.h 2013-08-22 20:30:00.000000000 +0000
11566 +#ifndef _VSERVER_LIMIT_INT_H
11567 +#define _VSERVER_LIMIT_INT_H
11569 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
11570 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
11572 +extern const char *vlimit_name[NUM_LIMITS];
11574 +static inline void __vx_acc_cres(struct vx_info *vxi,
11575 + int res, int dir, void *_data, char *_file, int _line)
11577 + if (VXD_RCRES_COND(res))
11578 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
11579 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11580 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11581 + (dir > 0) ? "++" : "--", _data, _file, _line);
11586 + __rlim_inc(&vxi->limit, res);
11588 + __rlim_dec(&vxi->limit, res);
11591 +static inline void __vx_add_cres(struct vx_info *vxi,
11592 + int res, int amount, void *_data, char *_file, int _line)
11594 + if (VXD_RCRES_COND(res))
11595 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
11596 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11597 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11598 + amount, _data, _file, _line);
11603 + __rlim_add(&vxi->limit, res, amount);
11607 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
11609 + int cond = (value > __rlim_rmax(limit, res));
11612 + __rlim_rmax(limit, res) = value;
11617 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
11619 + int cond = (value < __rlim_rmin(limit, res));
11622 + __rlim_rmin(limit, res) = value;
11627 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
11629 + if (!__vx_cres_adjust_max(limit, res, value))
11630 + __vx_cres_adjust_min(limit, res, value);
11635 + +1 ... no limit hit
11636 + -1 ... over soft limit
11637 + 0 ... over hard limit */
11639 +static inline int __vx_cres_avail(struct vx_info *vxi,
11640 + int res, int num, char *_file, int _line)
11642 + struct _vx_limit *limit;
11645 + if (VXD_RLIMIT_COND(res))
11646 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
11647 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11648 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
11649 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
11650 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11651 + num, _file, _line);
11655 + limit = &vxi->limit;
11656 + value = __rlim_get(limit, res);
11658 + if (!__vx_cres_adjust_max(limit, res, value))
11659 + __vx_cres_adjust_min(limit, res, value);
11664 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
11666 + if (value + num <= __rlim_soft(limit, res))
11669 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
11671 + if (value + num <= __rlim_hard(limit, res))
11674 + __rlim_hit(limit, res);
11679 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
11682 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
11684 + rlim_t value, sum = 0;
11687 + while ((res = *array++)) {
11688 + value = __rlim_get(limit, res);
11689 + __vx_cres_fixup(limit, res, value);
11696 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
11698 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
11699 + int res = *array;
11701 + if (value == __rlim_get(limit, res))
11704 + __rlim_set(limit, res, value);
11705 + /* now adjust min/max */
11706 + if (!__vx_cres_adjust_max(limit, res, value))
11707 + __vx_cres_adjust_min(limit, res, value);
11712 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
11713 + const int *array, int num, char *_file, int _line)
11715 + struct _vx_limit *limit;
11716 + rlim_t value = 0;
11724 + limit = &vxi->limit;
11726 + value = __vx_cres_array_sum(limit, array + 1);
11728 + __rlim_set(limit, res, value);
11729 + __vx_cres_fixup(limit, res, value);
11731 + return __vx_cres_avail(vxi, res, num, _file, _line);
11735 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
11740 + /* complex resources first */
11741 + if ((id < 0) || (id == RLIMIT_RSS))
11742 + __vx_cres_array_fixup(limit, VLA_RSS);
11744 + for (res = 0; res < NUM_LIMITS; res++) {
11745 + if ((id > 0) && (res != id))
11748 + value = __rlim_get(limit, res);
11749 + __vx_cres_fixup(limit, res, value);
11751 + /* not supposed to happen, maybe warn? */
11752 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
11753 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
11758 +#endif /* _VSERVER_LIMIT_INT_H */
11759 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/monitor.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/monitor.h
11760 --- linux-3.10.15/include/linux/vserver/monitor.h 1970-01-01 00:00:00.000000000 +0000
11761 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/monitor.h 2013-08-22 20:30:00.000000000 +0000
11763 +#ifndef _VSERVER_MONITOR_H
11764 +#define _VSERVER_MONITOR_H
11766 +#include <uapi/vserver/monitor.h>
11768 +#endif /* _VSERVER_MONITOR_H */
11769 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/network.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/network.h
11770 --- linux-3.10.15/include/linux/vserver/network.h 1970-01-01 00:00:00.000000000 +0000
11771 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/network.h 2013-08-22 20:30:00.000000000 +0000
11773 +#ifndef _VSERVER_NETWORK_H
11774 +#define _VSERVER_NETWORK_H
11777 +#include <linux/list.h>
11778 +#include <linux/spinlock.h>
11779 +#include <linux/rcupdate.h>
11780 +#include <linux/in.h>
11781 +#include <linux/in6.h>
11782 +#include <asm/atomic.h>
11783 +#include <uapi/vserver/network.h>
11785 +struct nx_addr_v4 {
11786 + struct nx_addr_v4 *next;
11787 + struct in_addr ip[2];
11788 + struct in_addr mask;
11793 +struct nx_addr_v6 {
11794 + struct nx_addr_v6 *next;
11795 + struct in6_addr ip;
11796 + struct in6_addr mask;
11803 + struct hlist_node nx_hlist; /* linked list of nxinfos */
11804 + vnid_t nx_id; /* vnet id */
11805 + atomic_t nx_usecnt; /* usage count */
11806 + atomic_t nx_tasks; /* tasks count */
11807 + int nx_state; /* context state */
11809 + uint64_t nx_flags; /* network flag word */
11810 + uint64_t nx_ncaps; /* network capabilities */
11812 + spinlock_t addr_lock; /* protect address changes */
11813 + struct in_addr v4_lback; /* Loopback address */
11814 + struct in_addr v4_bcast; /* Broadcast address */
11815 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
11816 +#ifdef CONFIG_IPV6
11817 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
11819 + char nx_name[65]; /* network context name */
11823 +/* status flags */
11825 +#define NXS_HASHED 0x0001
11826 +#define NXS_SHUTDOWN 0x0100
11827 +#define NXS_RELEASED 0x8000
11829 +extern struct nx_info *lookup_nx_info(int);
11831 +extern int get_nid_list(int, unsigned int *, int);
11832 +extern int nid_is_hashed(vnid_t);
11834 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
11836 +extern long vs_net_change(struct nx_info *, unsigned int);
11841 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
11842 +#ifdef CONFIG_IPV6
11843 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
11845 +#define NX_IPV6(n) (0)
11848 +#endif /* _VSERVER_NETWORK_H */
11849 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/network_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/network_cmd.h
11850 --- linux-3.10.15/include/linux/vserver/network_cmd.h 1970-01-01 00:00:00.000000000 +0000
11851 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/network_cmd.h 2013-08-22 20:30:00.000000000 +0000
11853 +#ifndef _VSERVER_NETWORK_CMD_H
11854 +#define _VSERVER_NETWORK_CMD_H
11856 +#include <uapi/vserver/network_cmd.h>
11858 +extern int vc_task_nid(uint32_t);
11860 +extern int vc_nx_info(struct nx_info *, void __user *);
11862 +extern int vc_net_create(uint32_t, void __user *);
11863 +extern int vc_net_migrate(struct nx_info *, void __user *);
11865 +extern int vc_net_add(struct nx_info *, void __user *);
11866 +extern int vc_net_remove(struct nx_info *, void __user *);
11868 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
11869 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
11871 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
11872 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
11874 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
11875 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
11877 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
11878 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
11880 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
11881 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
11883 +extern int vc_get_nflags(struct nx_info *, void __user *);
11884 +extern int vc_set_nflags(struct nx_info *, void __user *);
11886 +extern int vc_get_ncaps(struct nx_info *, void __user *);
11887 +extern int vc_set_ncaps(struct nx_info *, void __user *);
11889 +#endif /* _VSERVER_CONTEXT_CMD_H */
11890 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/percpu.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/percpu.h
11891 --- linux-3.10.15/include/linux/vserver/percpu.h 1970-01-01 00:00:00.000000000 +0000
11892 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/percpu.h 2013-08-22 20:30:00.000000000 +0000
11894 +#ifndef _VSERVER_PERCPU_H
11895 +#define _VSERVER_PERCPU_H
11897 +#include "cvirt_def.h"
11898 +#include "sched_def.h"
11900 +struct _vx_percpu {
11901 + struct _vx_cvirt_pc cvirt;
11902 + struct _vx_sched_pc sched;
11905 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
11907 +#endif /* _VSERVER_PERCPU_H */
11908 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/pid.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/pid.h
11909 --- linux-3.10.15/include/linux/vserver/pid.h 1970-01-01 00:00:00.000000000 +0000
11910 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/pid.h 2013-08-22 20:30:00.000000000 +0000
11912 +#ifndef _VSERVER_PID_H
11913 +#define _VSERVER_PID_H
11915 +/* pid faking stuff */
11917 +#define vx_info_map_pid(v, p) \
11918 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
11919 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
11920 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
11921 +#define vx_map_tgid(p) vx_map_pid(p)
11923 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
11924 + const char *func, const char *file, int line)
11926 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
11927 + vxfprintk(VXD_CBIT(cvirt, 2),
11928 + "vx_map_tgid: %p/%llx: %d -> %d",
11929 + vxi, (long long)vxi->vx_flags, pid,
11930 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
11931 + func, file, line);
11934 + if (pid == vxi->vx_initpid)
11940 +#define vx_info_rmap_pid(v, p) \
11941 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
11942 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
11943 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
11945 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
11946 + const char *func, const char *file, int line)
11948 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
11949 + vxfprintk(VXD_CBIT(cvirt, 2),
11950 + "vx_rmap_tgid: %p/%llx: %d -> %d",
11951 + vxi, (long long)vxi->vx_flags, pid,
11952 + (pid == 1) ? vxi->vx_initpid : pid,
11953 + func, file, line);
11954 + if ((pid == 1) && vxi->vx_initpid)
11955 + return vxi->vx_initpid;
11956 + if (pid == vxi->vx_initpid)
11963 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/sched.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/sched.h
11964 --- linux-3.10.15/include/linux/vserver/sched.h 1970-01-01 00:00:00.000000000 +0000
11965 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/sched.h 2013-08-22 20:30:00.000000000 +0000
11967 +#ifndef _VSERVER_SCHED_H
11968 +#define _VSERVER_SCHED_H
11975 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11980 +void vx_update_load(struct vx_info *);
11983 +void vx_update_sched_param(struct _vx_sched *sched,
11984 + struct _vx_sched_pc *sched_pc);
11986 +#endif /* __KERNEL__ */
11987 +#else /* _VSERVER_SCHED_H */
11988 +#warning duplicate inclusion
11989 +#endif /* _VSERVER_SCHED_H */
11990 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/sched_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/sched_cmd.h
11991 --- linux-3.10.15/include/linux/vserver/sched_cmd.h 1970-01-01 00:00:00.000000000 +0000
11992 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/sched_cmd.h 2013-08-22 20:30:00.000000000 +0000
11994 +#ifndef _VSERVER_SCHED_CMD_H
11995 +#define _VSERVER_SCHED_CMD_H
11998 +#include <linux/compiler.h>
11999 +#include <uapi/vserver/sched_cmd.h>
12001 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
12002 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
12004 +#endif /* _VSERVER_SCHED_CMD_H */
12005 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/sched_def.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/sched_def.h
12006 --- linux-3.10.15/include/linux/vserver/sched_def.h 1970-01-01 00:00:00.000000000 +0000
12007 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/sched_def.h 2013-08-22 20:30:00.000000000 +0000
12009 +#ifndef _VSERVER_SCHED_DEF_H
12010 +#define _VSERVER_SCHED_DEF_H
12012 +#include <linux/spinlock.h>
12013 +#include <linux/jiffies.h>
12014 +#include <linux/cpumask.h>
12015 +#include <asm/atomic.h>
12016 +#include <asm/param.h>
12019 +/* context sub struct */
12021 +struct _vx_sched {
12022 + int prio_bias; /* bias offset for priority */
12024 + cpumask_t update; /* CPUs which should update */
12027 +struct _vx_sched_pc {
12028 + int prio_bias; /* bias offset for priority */
12030 + uint64_t user_ticks; /* token tick events */
12031 + uint64_t sys_ticks; /* token tick events */
12032 + uint64_t hold_ticks; /* token ticks paused */
12036 +#ifdef CONFIG_VSERVER_DEBUG
12038 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12040 + printk("\t_vx_sched:\n");
12041 + printk("\t priority = %4d\n", sched->prio_bias);
12046 +#endif /* _VSERVER_SCHED_DEF_H */
12047 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/signal.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/signal.h
12048 --- linux-3.10.15/include/linux/vserver/signal.h 1970-01-01 00:00:00.000000000 +0000
12049 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/signal.h 2013-08-22 20:30:00.000000000 +0000
12051 +#ifndef _VSERVER_SIGNAL_H
12052 +#define _VSERVER_SIGNAL_H
12059 +int vx_info_kill(struct vx_info *, int, int);
12061 +#endif /* __KERNEL__ */
12062 +#else /* _VSERVER_SIGNAL_H */
12063 +#warning duplicate inclusion
12064 +#endif /* _VSERVER_SIGNAL_H */
12065 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/signal_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/signal_cmd.h
12066 --- linux-3.10.15/include/linux/vserver/signal_cmd.h 1970-01-01 00:00:00.000000000 +0000
12067 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/signal_cmd.h 2013-08-22 20:30:00.000000000 +0000
12069 +#ifndef _VSERVER_SIGNAL_CMD_H
12070 +#define _VSERVER_SIGNAL_CMD_H
12072 +#include <uapi/vserver/signal_cmd.h>
12075 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12076 +extern int vc_wait_exit(struct vx_info *, void __user *);
12079 +extern int vc_get_pflags(uint32_t pid, void __user *);
12080 +extern int vc_set_pflags(uint32_t pid, void __user *);
12082 +#endif /* _VSERVER_SIGNAL_CMD_H */
12083 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/space.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/space.h
12084 --- linux-3.10.15/include/linux/vserver/space.h 1970-01-01 00:00:00.000000000 +0000
12085 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/space.h 2013-08-22 20:30:00.000000000 +0000
12087 +#ifndef _VSERVER_SPACE_H
12088 +#define _VSERVER_SPACE_H
12090 +#include <linux/types.h>
12094 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
12096 +#else /* _VSERVER_SPACE_H */
12097 +#warning duplicate inclusion
12098 +#endif /* _VSERVER_SPACE_H */
12099 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/space_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/space_cmd.h
12100 --- linux-3.10.15/include/linux/vserver/space_cmd.h 1970-01-01 00:00:00.000000000 +0000
12101 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/space_cmd.h 2013-08-22 20:30:00.000000000 +0000
12103 +#ifndef _VSERVER_SPACE_CMD_H
12104 +#define _VSERVER_SPACE_CMD_H
12106 +#include <uapi/vserver/space_cmd.h>
12109 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
12110 +extern int vc_set_space_v1(struct vx_info *, void __user *);
12111 +extern int vc_enter_space(struct vx_info *, void __user *);
12112 +extern int vc_set_space(struct vx_info *, void __user *);
12113 +extern int vc_get_space_mask(void __user *, int);
12115 +#endif /* _VSERVER_SPACE_CMD_H */
12116 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/switch.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/switch.h
12117 --- linux-3.10.15/include/linux/vserver/switch.h 1970-01-01 00:00:00.000000000 +0000
12118 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/switch.h 2013-08-22 20:30:00.000000000 +0000
12120 +#ifndef _VSERVER_SWITCH_H
12121 +#define _VSERVER_SWITCH_H
12124 +#include <linux/errno.h>
12125 +#include <uapi/vserver/switch.h>
12127 +#endif /* _VSERVER_SWITCH_H */
12128 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/tag.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/tag.h
12129 --- linux-3.10.15/include/linux/vserver/tag.h 1970-01-01 00:00:00.000000000 +0000
12130 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/tag.h 2013-08-22 20:30:00.000000000 +0000
12135 +#include <linux/types.h>
12136 +#include <linux/uidgid.h>
12139 +#define DX_TAG(in) (IS_TAGGED(in))
12142 +#ifdef CONFIG_TAG_NFSD
12143 +#define DX_TAG_NFSD 1
12145 +#define DX_TAG_NFSD 0
12149 +#ifdef CONFIG_TAGGING_NONE
12151 +#define MAX_UID 0xFFFFFFFF
12152 +#define MAX_GID 0xFFFFFFFF
12154 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
12156 +#define TAGINO_UID(cond, uid, tag) (uid)
12157 +#define TAGINO_GID(cond, gid, tag) (gid)
12162 +#ifdef CONFIG_TAGGING_GID16
12164 +#define MAX_UID 0xFFFFFFFF
12165 +#define MAX_GID 0x0000FFFF
12167 +#define INOTAG_TAG(cond, uid, gid, tag) \
12168 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
12170 +#define TAGINO_UID(cond, uid, tag) (uid)
12171 +#define TAGINO_GID(cond, gid, tag) \
12172 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
12177 +#ifdef CONFIG_TAGGING_ID24
12179 +#define MAX_UID 0x00FFFFFF
12180 +#define MAX_GID 0x00FFFFFF
12182 +#define INOTAG_TAG(cond, uid, gid, tag) \
12183 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
12185 +#define TAGINO_UID(cond, uid, tag) \
12186 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
12187 +#define TAGINO_GID(cond, gid, tag) \
12188 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
12193 +#ifdef CONFIG_TAGGING_UID16
12195 +#define MAX_UID 0x0000FFFF
12196 +#define MAX_GID 0xFFFFFFFF
12198 +#define INOTAG_TAG(cond, uid, gid, tag) \
12199 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
12201 +#define TAGINO_UID(cond, uid, tag) \
12202 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
12203 +#define TAGINO_GID(cond, gid, tag) (gid)
12208 +#ifdef CONFIG_TAGGING_INTERN
12210 +#define MAX_UID 0xFFFFFFFF
12211 +#define MAX_GID 0xFFFFFFFF
12213 +#define INOTAG_TAG(cond, uid, gid, tag) \
12214 + ((cond) ? (tag) : 0)
12216 +#define TAGINO_UID(cond, uid, tag) (uid)
12217 +#define TAGINO_GID(cond, gid, tag) (gid)
12222 +#ifndef CONFIG_TAGGING_NONE
12223 +#define dx_current_fstag(sb) \
12224 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
12226 +#define dx_current_fstag(sb) (0)
12229 +#ifndef CONFIG_TAGGING_INTERN
12230 +#define TAGINO_TAG(cond, tag) (0)
12232 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
12235 +#define TAGINO_KUID(cond, kuid, ktag) \
12236 + KUIDT_INIT(TAGINO_UID(cond, __kuid_val(kuid), __ktag_val(ktag)))
12237 +#define TAGINO_KGID(cond, kgid, ktag) \
12238 + KGIDT_INIT(TAGINO_GID(cond, __kgid_val(kgid), __ktag_val(ktag)))
12239 +#define TAGINO_KTAG(cond, ktag) \
12240 + KTAGT_INIT(TAGINO_TAG(cond, __ktag_val(ktag)))
12243 +#define INOTAG_UID(cond, uid, gid) \
12244 + ((cond) ? ((uid) & MAX_UID) : (uid))
12245 +#define INOTAG_GID(cond, uid, gid) \
12246 + ((cond) ? ((gid) & MAX_GID) : (gid))
12248 +#define INOTAG_KUID(cond, kuid, kgid) \
12249 + KUIDT_INIT(INOTAG_UID(cond, __kuid_val(kuid), __kgid_val(kgid)))
12250 +#define INOTAG_KGID(cond, kuid, kgid) \
12251 + KGIDT_INIT(INOTAG_GID(cond, __kuid_val(kuid), __kgid_val(kgid)))
12252 +#define INOTAG_KTAG(cond, kuid, kgid, ktag) \
12253 + KTAGT_INIT(INOTAG_TAG(cond, \
12254 + __kuid_val(kuid), __kgid_val(kgid), __ktag_val(ktag)))
12257 +static inline uid_t dx_map_uid(uid_t uid)
12259 + if ((uid > MAX_UID) && (uid != -1))
12261 + return (uid & MAX_UID);
12264 +static inline gid_t dx_map_gid(gid_t gid)
12266 + if ((gid > MAX_GID) && (gid != -1))
12268 + return (gid & MAX_GID);
12276 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
12278 +int dx_parse_tag(char *string, vtag_t *tag, int remove, int *mnt_flags,
12279 + unsigned long *flags);
12281 +#ifdef CONFIG_PROPAGATE
12283 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
12285 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
12288 +#define dx_propagate_tag(n, i) do { } while (0)
12291 +#endif /* _DX_TAG_H */
12292 diff -NurpP --minimal linux-3.10.15/include/linux/vserver/tag_cmd.h linux-3.10.15-vs2.3.6.6/include/linux/vserver/tag_cmd.h
12293 --- linux-3.10.15/include/linux/vserver/tag_cmd.h 1970-01-01 00:00:00.000000000 +0000
12294 +++ linux-3.10.15-vs2.3.6.6/include/linux/vserver/tag_cmd.h 2013-08-22 20:30:00.000000000 +0000
12296 +#ifndef _VSERVER_TAG_CMD_H
12297 +#define _VSERVER_TAG_CMD_H
12299 +#include <uapi/vserver/tag_cmd.h>
12301 +extern int vc_task_tag(uint32_t);
12303 +extern int vc_tag_migrate(uint32_t);
12305 +#endif /* _VSERVER_TAG_CMD_H */
12306 diff -NurpP --minimal linux-3.10.15/include/net/addrconf.h linux-3.10.15-vs2.3.6.6/include/net/addrconf.h
12307 --- linux-3.10.15/include/net/addrconf.h 2013-10-09 17:35:23.000000000 +0000
12308 +++ linux-3.10.15-vs2.3.6.6/include/net/addrconf.h 2013-08-22 20:32:06.000000000 +0000
12309 @@ -85,7 +85,8 @@ extern int ipv6_dev_get_saddr(struct n
12310 const struct net_device *dev,
12311 const struct in6_addr *daddr,
12312 unsigned int srcprefs,
12313 - struct in6_addr *saddr);
12314 + struct in6_addr *saddr,
12315 + struct nx_info *nxi);
12316 extern int __ipv6_get_lladdr(struct inet6_dev *idev,
12317 struct in6_addr *addr,
12318 unsigned char banned_flags);
12319 diff -NurpP --minimal linux-3.10.15/include/net/af_unix.h linux-3.10.15-vs2.3.6.6/include/net/af_unix.h
12320 --- linux-3.10.15/include/net/af_unix.h 2013-07-14 17:01:33.000000000 +0000
12321 +++ linux-3.10.15-vs2.3.6.6/include/net/af_unix.h 2013-08-22 20:30:00.000000000 +0000
12323 #include <linux/socket.h>
12324 #include <linux/un.h>
12325 #include <linux/mutex.h>
12326 +#include <linux/vs_base.h>
12327 #include <net/sock.h>
12329 extern void unix_inflight(struct file *fp);
12330 diff -NurpP --minimal linux-3.10.15/include/net/inet_timewait_sock.h linux-3.10.15-vs2.3.6.6/include/net/inet_timewait_sock.h
12331 --- linux-3.10.15/include/net/inet_timewait_sock.h 2013-05-31 13:45:28.000000000 +0000
12332 +++ linux-3.10.15-vs2.3.6.6/include/net/inet_timewait_sock.h 2013-08-22 20:30:00.000000000 +0000
12333 @@ -116,6 +116,10 @@ struct inet_timewait_sock {
12334 #define tw_dport __tw_common.skc_dport
12335 #define tw_num __tw_common.skc_num
12336 #define tw_portpair __tw_common.skc_portpair
12337 +#define tw_xid __tw_common.skc_xid
12338 +#define tw_vx_info __tw_common.skc_vx_info
12339 +#define tw_nid __tw_common.skc_nid
12340 +#define tw_nx_info __tw_common.skc_nx_info
12343 volatile unsigned char tw_substate;
12344 diff -NurpP --minimal linux-3.10.15/include/net/ip6_route.h linux-3.10.15-vs2.3.6.6/include/net/ip6_route.h
12345 --- linux-3.10.15/include/net/ip6_route.h 2013-05-31 13:45:28.000000000 +0000
12346 +++ linux-3.10.15-vs2.3.6.6/include/net/ip6_route.h 2013-08-22 20:30:00.000000000 +0000
12347 @@ -95,7 +95,8 @@ extern int ip6_route_get_saddr(struct
12348 struct rt6_info *rt,
12349 const struct in6_addr *daddr,
12350 unsigned int prefs,
12351 - struct in6_addr *saddr);
12352 + struct in6_addr *saddr,
12353 + struct nx_info *nxi);
12355 extern struct rt6_info *rt6_lookup(struct net *net,
12356 const struct in6_addr *daddr,
12357 diff -NurpP --minimal linux-3.10.15/include/net/route.h linux-3.10.15-vs2.3.6.6/include/net/route.h
12358 --- linux-3.10.15/include/net/route.h 2013-02-19 13:58:52.000000000 +0000
12359 +++ linux-3.10.15-vs2.3.6.6/include/net/route.h 2013-08-22 20:30:00.000000000 +0000
12360 @@ -207,6 +207,9 @@ static inline void ip_rt_put(struct rtab
12361 dst_release(&rt->dst);
12364 +#include <linux/vs_base.h>
12365 +#include <linux/vs_inet.h>
12367 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
12369 extern const __u8 ip_tos2prio[16];
12370 @@ -256,6 +259,9 @@ static inline void ip_route_connect_init
12371 protocol, flow_flags, dst, src, dport, sport);
12374 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
12375 + struct flowi4 *);
12377 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
12378 __be32 dst, __be32 src, u32 tos,
12379 int oif, u8 protocol,
12380 @@ -264,11 +270,25 @@ static inline struct rtable *ip_route_co
12382 struct net *net = sock_net(sk);
12384 + struct nx_info *nx_info = current_nx_info();
12386 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
12387 sport, dport, sk, can_sleep);
12389 - if (!dst || !src) {
12391 + nx_info = sk->sk_nx_info;
12393 + vxdprintk(VXD_CBIT(net, 4),
12394 + "ip_route_connect(%p) %p,%p;%lx",
12395 + sk, nx_info, sk->sk_socket,
12396 + (sk->sk_socket?sk->sk_socket->flags:0));
12398 + rt = ip_v4_find_src(net, nx_info, fl4);
12403 + if (!fl4->daddr || !fl4->saddr) {
12404 rt = __ip_route_output_key(net, fl4);
12407 diff -NurpP --minimal linux-3.10.15/include/net/sock.h linux-3.10.15-vs2.3.6.6/include/net/sock.h
12408 --- linux-3.10.15/include/net/sock.h 2013-07-14 17:01:33.000000000 +0000
12409 +++ linux-3.10.15-vs2.3.6.6/include/net/sock.h 2013-08-22 20:30:00.000000000 +0000
12410 @@ -191,6 +191,10 @@ struct sock_common {
12411 #ifdef CONFIG_NET_NS
12412 struct net *skc_net;
12415 + struct vx_info *skc_vx_info;
12417 + struct nx_info *skc_nx_info;
12419 * fields between dontcopy_begin/dontcopy_end
12420 * are not copied in sock_copy()
12421 @@ -304,6 +308,10 @@ struct sock {
12422 #define sk_bind_node __sk_common.skc_bind_node
12423 #define sk_prot __sk_common.skc_prot
12424 #define sk_net __sk_common.skc_net
12425 +#define sk_xid __sk_common.skc_xid
12426 +#define sk_vx_info __sk_common.skc_vx_info
12427 +#define sk_nid __sk_common.skc_nid
12428 +#define sk_nx_info __sk_common.skc_nx_info
12429 socket_lock_t sk_lock;
12430 struct sk_buff_head sk_receive_queue;
12432 diff -NurpP --minimal linux-3.10.15/include/uapi/Kbuild linux-3.10.15-vs2.3.6.6/include/uapi/Kbuild
12433 --- linux-3.10.15/include/uapi/Kbuild 2012-12-11 03:30:57.000000000 +0000
12434 +++ linux-3.10.15-vs2.3.6.6/include/uapi/Kbuild 2013-08-22 20:30:00.000000000 +0000
12435 @@ -12,3 +12,4 @@ header-y += video/
12439 +header-y += vserver/
12440 diff -NurpP --minimal linux-3.10.15/include/uapi/linux/capability.h linux-3.10.15-vs2.3.6.6/include/uapi/linux/capability.h
12441 --- linux-3.10.15/include/uapi/linux/capability.h 2012-12-11 03:30:57.000000000 +0000
12442 +++ linux-3.10.15-vs2.3.6.6/include/uapi/linux/capability.h 2013-08-22 20:30:00.000000000 +0000
12443 @@ -259,6 +259,7 @@ struct vfs_cap_data {
12444 arbitrary SCSI commands */
12445 /* Allow setting encryption key on loopback filesystem */
12446 /* Allow setting zone reclaim policy */
12447 +/* Allow the selection of a security context */
12449 #define CAP_SYS_ADMIN 21
12451 @@ -345,7 +346,12 @@ struct vfs_cap_data {
12453 #define CAP_LAST_CAP CAP_BLOCK_SUSPEND
12455 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
12456 +/* Allow context manipulations */
12457 +/* Allow changing context info on files */
12459 +#define CAP_CONTEXT 63
12461 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
12464 * Bit location of each capability (used by user-space library and kernel)
12465 diff -NurpP --minimal linux-3.10.15/include/uapi/linux/fs.h linux-3.10.15-vs2.3.6.6/include/uapi/linux/fs.h
12466 --- linux-3.10.15/include/uapi/linux/fs.h 2013-07-14 17:01:34.000000000 +0000
12467 +++ linux-3.10.15-vs2.3.6.6/include/uapi/linux/fs.h 2013-08-22 20:30:00.000000000 +0000
12468 @@ -86,6 +86,9 @@ struct inodes_stat_t {
12469 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
12470 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
12471 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
12472 +#define MS_TAGGED (1<<8) /* use generic inode tagging */
12473 +#define MS_NOTAGCHECK (1<<9) /* don't check tags */
12474 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
12476 /* These sb flags are internal to the kernel */
12477 #define MS_NOSEC (1<<28)
12478 @@ -191,11 +194,14 @@ struct inodes_stat_t {
12479 #define FS_EXTENT_FL 0x00080000 /* Extents */
12480 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
12481 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
12482 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
12483 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
12485 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
12486 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
12487 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
12488 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
12490 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
12491 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
12493 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
12494 #define SYNC_FILE_RANGE_WRITE 2
12495 diff -NurpP --minimal linux-3.10.15/include/uapi/linux/gfs2_ondisk.h linux-3.10.15-vs2.3.6.6/include/uapi/linux/gfs2_ondisk.h
12496 --- linux-3.10.15/include/uapi/linux/gfs2_ondisk.h 2012-12-11 03:30:57.000000000 +0000
12497 +++ linux-3.10.15-vs2.3.6.6/include/uapi/linux/gfs2_ondisk.h 2013-08-22 20:30:00.000000000 +0000
12498 @@ -225,6 +225,9 @@ enum {
12501 gfs2fl_TopLevel = 10,
12502 + gfs2fl_IXUnlink = 16,
12503 + gfs2fl_Barrier = 17,
12505 gfs2fl_TruncInProg = 29,
12506 gfs2fl_InheritDirectio = 30,
12507 gfs2fl_InheritJdata = 31,
12508 @@ -242,6 +245,9 @@ enum {
12509 #define GFS2_DIF_SYNC 0x00000100
12510 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
12511 #define GFS2_DIF_TOPDIR 0x00000400 /* New in gfs2 */
12512 +#define GFS2_DIF_IXUNLINK 0x00010000
12513 +#define GFS2_DIF_BARRIER 0x00020000
12514 +#define GFS2_DIF_COW 0x00040000
12515 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
12516 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000 /* only in gfs1 */
12517 #define GFS2_DIF_INHERIT_JDATA 0x80000000
12518 diff -NurpP --minimal linux-3.10.15/include/uapi/linux/if_tun.h linux-3.10.15-vs2.3.6.6/include/uapi/linux/if_tun.h
12519 --- linux-3.10.15/include/uapi/linux/if_tun.h 2013-02-19 13:58:55.000000000 +0000
12520 +++ linux-3.10.15-vs2.3.6.6/include/uapi/linux/if_tun.h 2013-08-22 20:30:00.000000000 +0000
12522 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
12523 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
12524 #define TUNSETQUEUE _IOW('T', 217, int)
12525 +#define TUNSETNID _IOW('T', 218, int)
12527 /* TUNSETIFF ifr flags */
12528 #define IFF_TUN 0x0001
12529 diff -NurpP --minimal linux-3.10.15/include/uapi/linux/major.h linux-3.10.15-vs2.3.6.6/include/uapi/linux/major.h
12530 --- linux-3.10.15/include/uapi/linux/major.h 2012-12-11 03:30:57.000000000 +0000
12531 +++ linux-3.10.15-vs2.3.6.6/include/uapi/linux/major.h 2013-08-22 20:30:00.000000000 +0000
12533 #define HD_MAJOR IDE0_MAJOR
12534 #define PTY_SLAVE_MAJOR 3
12535 #define TTY_MAJOR 4
12536 +#define VROOT_MAJOR 4
12537 #define TTYAUX_MAJOR 5
12539 #define VCS_MAJOR 7
12540 diff -NurpP --minimal linux-3.10.15/include/uapi/linux/nfs_mount.h linux-3.10.15-vs2.3.6.6/include/uapi/linux/nfs_mount.h
12541 --- linux-3.10.15/include/uapi/linux/nfs_mount.h 2012-12-11 03:30:57.000000000 +0000
12542 +++ linux-3.10.15-vs2.3.6.6/include/uapi/linux/nfs_mount.h 2013-08-22 20:30:00.000000000 +0000
12543 @@ -63,7 +63,8 @@ struct nfs_mount_data {
12544 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
12545 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
12546 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
12547 -#define NFS_MOUNT_FLAGMASK 0xFFFF
12548 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
12549 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
12551 /* The following are for internal use only */
12552 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
12553 diff -NurpP --minimal linux-3.10.15/include/uapi/linux/reboot.h linux-3.10.15-vs2.3.6.6/include/uapi/linux/reboot.h
12554 --- linux-3.10.15/include/uapi/linux/reboot.h 2012-12-11 03:30:57.000000000 +0000
12555 +++ linux-3.10.15-vs2.3.6.6/include/uapi/linux/reboot.h 2013-08-22 20:30:00.000000000 +0000
12557 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
12558 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
12559 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
12561 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
12564 #endif /* _UAPI_LINUX_REBOOT_H */
12565 diff -NurpP --minimal linux-3.10.15/include/uapi/linux/sysctl.h linux-3.10.15-vs2.3.6.6/include/uapi/linux/sysctl.h
12566 --- linux-3.10.15/include/uapi/linux/sysctl.h 2012-12-11 03:30:57.000000000 +0000
12567 +++ linux-3.10.15-vs2.3.6.6/include/uapi/linux/sysctl.h 2013-08-22 20:30:00.000000000 +0000
12568 @@ -60,6 +60,7 @@ enum
12569 CTL_ABI=9, /* Binary emulation */
12570 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
12571 CTL_ARLAN=254, /* arlan wireless driver */
12572 + CTL_VSERVER=4242, /* Linux-VServer debug */
12573 CTL_S390DBF=5677, /* s390 debug */
12574 CTL_SUNRPC=7249, /* sunrpc debug */
12575 CTL_PM=9899, /* frv power management */
12576 @@ -94,6 +95,7 @@ enum
12578 KERN_PANIC=15, /* int: panic timeout */
12579 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
12580 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
12582 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
12583 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
12584 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/Kbuild linux-3.10.15-vs2.3.6.6/include/uapi/vserver/Kbuild
12585 --- linux-3.10.15/include/uapi/vserver/Kbuild 1970-01-01 00:00:00.000000000 +0000
12586 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/Kbuild 2013-08-22 20:30:00.000000000 +0000
12589 +header-y += context_cmd.h network_cmd.h space_cmd.h \
12590 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
12591 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
12592 + debug_cmd.h device_cmd.h
12594 +header-y += switch.h context.h network.h monitor.h \
12595 + limit.h inode.h device.h
12597 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/cacct_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/cacct_cmd.h
12598 --- linux-3.10.15/include/uapi/vserver/cacct_cmd.h 1970-01-01 00:00:00.000000000 +0000
12599 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/cacct_cmd.h 2013-08-22 20:30:00.000000000 +0000
12601 +#ifndef _UAPI_VS_CACCT_CMD_H
12602 +#define _UAPI_VS_CACCT_CMD_H
12605 +/* virtual host info name commands */
12607 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
12609 +struct vcmd_sock_stat_v0 {
12611 + uint32_t count[3];
12612 + uint64_t total[3];
12615 +#endif /* _UAPI_VS_CACCT_CMD_H */
12616 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/context.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/context.h
12617 --- linux-3.10.15/include/uapi/vserver/context.h 1970-01-01 00:00:00.000000000 +0000
12618 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/context.h 2013-08-22 20:30:00.000000000 +0000
12620 +#ifndef _UAPI_VS_CONTEXT_H
12621 +#define _UAPI_VS_CONTEXT_H
12623 +#include <linux/types.h>
12624 +#include <linux/capability.h>
12627 +/* context flags */
12629 +#define VXF_INFO_SCHED 0x00000002
12630 +#define VXF_INFO_NPROC 0x00000004
12631 +#define VXF_INFO_PRIVATE 0x00000008
12633 +#define VXF_INFO_INIT 0x00000010
12634 +#define VXF_INFO_HIDE 0x00000020
12635 +#define VXF_INFO_ULIMIT 0x00000040
12636 +#define VXF_INFO_NSPACE 0x00000080
12638 +#define VXF_SCHED_HARD 0x00000100
12639 +#define VXF_SCHED_PRIO 0x00000200
12640 +#define VXF_SCHED_PAUSE 0x00000400
12642 +#define VXF_VIRT_MEM 0x00010000
12643 +#define VXF_VIRT_UPTIME 0x00020000
12644 +#define VXF_VIRT_CPU 0x00040000
12645 +#define VXF_VIRT_LOAD 0x00080000
12646 +#define VXF_VIRT_TIME 0x00100000
12648 +#define VXF_HIDE_MOUNT 0x01000000
12649 +/* was VXF_HIDE_NETIF 0x02000000 */
12650 +#define VXF_HIDE_VINFO 0x04000000
12652 +#define VXF_STATE_SETUP (1ULL << 32)
12653 +#define VXF_STATE_INIT (1ULL << 33)
12654 +#define VXF_STATE_ADMIN (1ULL << 34)
12656 +#define VXF_SC_HELPER (1ULL << 36)
12657 +#define VXF_REBOOT_KILL (1ULL << 37)
12658 +#define VXF_PERSISTENT (1ULL << 38)
12660 +#define VXF_FORK_RSS (1ULL << 48)
12661 +#define VXF_PROLIFIC (1ULL << 49)
12663 +#define VXF_IGNEG_NICE (1ULL << 52)
12665 +#define VXF_ONE_TIME (0x0007ULL << 32)
12667 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
12670 +/* context migration */
12672 +#define VXM_SET_INIT 0x00000001
12673 +#define VXM_SET_REAPER 0x00000002
12675 +/* context caps */
12677 +#define VXC_SET_UTSNAME 0x00000001
12678 +#define VXC_SET_RLIMIT 0x00000002
12679 +#define VXC_FS_SECURITY 0x00000004
12680 +#define VXC_FS_TRUSTED 0x00000008
12681 +#define VXC_TIOCSTI 0x00000010
12683 +/* was VXC_RAW_ICMP 0x00000100 */
12684 +#define VXC_SYSLOG 0x00001000
12685 +#define VXC_OOM_ADJUST 0x00002000
12686 +#define VXC_AUDIT_CONTROL 0x00004000
12688 +/* #define VXC_SECURE_MOUNT 0x00010000
12689 +#define VXC_SECURE_REMOUNT 0x00020000 */
12690 +#define VXC_BINARY_MOUNT 0x00040000
12691 +#define VXC_DEV_MOUNT 0x00080000
12693 +#define VXC_QUOTA_CTL 0x00100000
12694 +#define VXC_ADMIN_MAPPER 0x00200000
12695 +#define VXC_ADMIN_CLOOP 0x00400000
12697 +#define VXC_KTHREAD 0x01000000
12698 +#define VXC_NAMESPACE 0x02000000
12700 +#endif /* _UAPI_VS_CONTEXT_H */
12701 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/context_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/context_cmd.h
12702 --- linux-3.10.15/include/uapi/vserver/context_cmd.h 1970-01-01 00:00:00.000000000 +0000
12703 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/context_cmd.h 2013-08-22 20:30:00.000000000 +0000
12705 +#ifndef _UAPI_VS_CONTEXT_CMD_H
12706 +#define _UAPI_VS_CONTEXT_CMD_H
12709 +/* vinfo commands */
12711 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
12714 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
12716 +struct vcmd_vx_info_v0 {
12718 + uint32_t initpid;
12719 + /* more to come */
12723 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
12725 +struct vcmd_ctx_stat_v0 {
12728 + /* more to come */
12732 +/* context commands */
12734 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
12735 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
12737 +struct vcmd_ctx_create {
12738 + uint64_t flagword;
12741 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
12742 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
12744 +struct vcmd_ctx_migrate {
12745 + uint64_t flagword;
12750 +/* flag commands */
12752 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
12753 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
12755 +struct vcmd_ctx_flags_v0 {
12756 + uint64_t flagword;
12762 +/* context caps commands */
12764 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
12765 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
12767 +struct vcmd_ctx_caps_v1 {
12774 +/* bcaps commands */
12776 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
12777 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
12779 +struct vcmd_bcaps {
12786 +/* umask commands */
12788 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
12789 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
12791 +struct vcmd_umask {
12798 +/* wmask commands */
12800 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
12801 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
12803 +struct vcmd_wmask {
12812 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
12813 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
12815 +struct vcmd_badness_v0 {
12819 +#endif /* _UAPI_VS_CONTEXT_CMD_H */
12820 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/cvirt_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/cvirt_cmd.h
12821 --- linux-3.10.15/include/uapi/vserver/cvirt_cmd.h 1970-01-01 00:00:00.000000000 +0000
12822 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/cvirt_cmd.h 2013-08-22 20:30:00.000000000 +0000
12824 +#ifndef _UAPI_VS_CVIRT_CMD_H
12825 +#define _UAPI_VS_CVIRT_CMD_H
12828 +/* virtual host info name commands */
12830 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
12831 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
12833 +struct vcmd_vhi_name_v0 {
12839 +enum vhi_name_field {
12840 + VHIN_CONTEXT = 0,
12851 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
12853 +struct vcmd_virt_stat_v0 {
12856 + uint32_t nr_threads;
12857 + uint32_t nr_running;
12858 + uint32_t nr_uninterruptible;
12859 + uint32_t nr_onhold;
12860 + uint32_t nr_forks;
12861 + uint32_t load[3];
12864 +#endif /* _UAPI_VS_CVIRT_CMD_H */
12865 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/debug_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/debug_cmd.h
12866 --- linux-3.10.15/include/uapi/vserver/debug_cmd.h 1970-01-01 00:00:00.000000000 +0000
12867 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/debug_cmd.h 2013-08-22 20:30:00.000000000 +0000
12869 +#ifndef _UAPI_VS_DEBUG_CMD_H
12870 +#define _UAPI_VS_DEBUG_CMD_H
12873 +/* debug commands */
12875 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
12877 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
12878 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
12880 +struct vcmd_read_history_v0 {
12883 + char __user *data;
12886 +struct vcmd_read_monitor_v0 {
12889 + char __user *data;
12892 +#endif /* _UAPI_VS_DEBUG_CMD_H */
12893 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/device.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/device.h
12894 --- linux-3.10.15/include/uapi/vserver/device.h 1970-01-01 00:00:00.000000000 +0000
12895 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/device.h 2013-08-22 20:30:00.000000000 +0000
12897 +#ifndef _UAPI_VS_DEVICE_H
12898 +#define _UAPI_VS_DEVICE_H
12901 +#define DATTR_CREATE 0x00000001
12902 +#define DATTR_OPEN 0x00000002
12904 +#define DATTR_REMAP 0x00000010
12906 +#define DATTR_MASK 0x00000013
12908 +#endif /* _UAPI_VS_DEVICE_H */
12909 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/device_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/device_cmd.h
12910 --- linux-3.10.15/include/uapi/vserver/device_cmd.h 1970-01-01 00:00:00.000000000 +0000
12911 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/device_cmd.h 2013-08-22 20:30:00.000000000 +0000
12913 +#ifndef _UAPI_VS_DEVICE_CMD_H
12914 +#define _UAPI_VS_DEVICE_CMD_H
12917 +/* device vserver commands */
12919 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
12920 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
12922 +struct vcmd_set_mapping_v0 {
12923 + const char __user *device;
12924 + const char __user *target;
12928 +#endif /* _UAPI_VS_DEVICE_CMD_H */
12929 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/dlimit_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/dlimit_cmd.h
12930 --- linux-3.10.15/include/uapi/vserver/dlimit_cmd.h 1970-01-01 00:00:00.000000000 +0000
12931 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/dlimit_cmd.h 2013-08-22 20:30:00.000000000 +0000
12933 +#ifndef _UAPI_VS_DLIMIT_CMD_H
12934 +#define _UAPI_VS_DLIMIT_CMD_H
12937 +/* dlimit vserver commands */
12939 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12940 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12942 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12943 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12945 +struct vcmd_ctx_dlimit_base_v0 {
12946 + const char __user *name;
12950 +struct vcmd_ctx_dlimit_v0 {
12951 + const char __user *name;
12952 + uint32_t space_used; /* used space in kbytes */
12953 + uint32_t space_total; /* maximum space in kbytes */
12954 + uint32_t inodes_used; /* used inodes */
12955 + uint32_t inodes_total; /* maximum inodes */
12956 + uint32_t reserved; /* reserved for root in % */
12960 +#define CDLIM_UNSET ((uint32_t)0UL)
12961 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12962 +#define CDLIM_KEEP ((uint32_t)~1UL)
12964 +#define DLIME_UNIT 0
12965 +#define DLIME_KILO 1
12966 +#define DLIME_MEGA 2
12967 +#define DLIME_GIGA 3
12969 +#define DLIMF_SHIFT 0x10
12971 +#define DLIMS_USED 0
12972 +#define DLIMS_TOTAL 2
12975 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12977 + int exp = (flags & DLIMF_SHIFT) ?
12978 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12979 + return ((uint64_t)val) << (10 * exp);
12983 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12987 + if (*flags & DLIMF_SHIFT) {
12988 + while (val > (1LL << 32) && (exp < 3)) {
12992 + *flags &= ~(DLIME_GIGA << shift);
12993 + *flags |= exp << shift;
12999 +#endif /* _UAPI_VS_DLIMIT_CMD_H */
13000 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/inode.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/inode.h
13001 --- linux-3.10.15/include/uapi/vserver/inode.h 1970-01-01 00:00:00.000000000 +0000
13002 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/inode.h 2013-08-22 20:30:00.000000000 +0000
13004 +#ifndef _UAPI_VS_INODE_H
13005 +#define _UAPI_VS_INODE_H
13008 +#define IATTR_TAG 0x01000000
13010 +#define IATTR_ADMIN 0x00000001
13011 +#define IATTR_WATCH 0x00000002
13012 +#define IATTR_HIDE 0x00000004
13013 +#define IATTR_FLAGS 0x00000007
13015 +#define IATTR_BARRIER 0x00010000
13016 +#define IATTR_IXUNLINK 0x00020000
13017 +#define IATTR_IMMUTABLE 0x00040000
13018 +#define IATTR_COW 0x00080000
13021 +/* inode ioctls */
13023 +#define FIOC_GETXFLG _IOR('x', 5, long)
13024 +#define FIOC_SETXFLG _IOW('x', 6, long)
13026 +#endif /* _UAPI_VS_INODE_H */
13027 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/inode_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/inode_cmd.h
13028 --- linux-3.10.15/include/uapi/vserver/inode_cmd.h 1970-01-01 00:00:00.000000000 +0000
13029 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/inode_cmd.h 2013-08-22 20:30:00.000000000 +0000
13031 +#ifndef _UAPI_VS_INODE_CMD_H
13032 +#define _UAPI_VS_INODE_CMD_H
13035 +/* inode vserver commands */
13037 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
13038 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
13040 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
13041 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
13043 +struct vcmd_ctx_iattr_v1 {
13044 + const char __user *name;
13050 +struct vcmd_ctx_fiattr_v0 {
13056 +#endif /* _UAPI_VS_INODE_CMD_H */
13057 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/limit.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/limit.h
13058 --- linux-3.10.15/include/uapi/vserver/limit.h 1970-01-01 00:00:00.000000000 +0000
13059 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/limit.h 2013-08-22 20:30:00.000000000 +0000
13061 +#ifndef _UAPI_VS_LIMIT_H
13062 +#define _UAPI_VS_LIMIT_H
13065 +#define VLIMIT_NSOCK 16
13066 +#define VLIMIT_OPENFD 17
13067 +#define VLIMIT_ANON 18
13068 +#define VLIMIT_SHMEM 19
13069 +#define VLIMIT_SEMARY 20
13070 +#define VLIMIT_NSEMS 21
13071 +#define VLIMIT_DENTRY 22
13072 +#define VLIMIT_MAPPED 23
13074 +#endif /* _UAPI_VS_LIMIT_H */
13075 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/limit_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/limit_cmd.h
13076 --- linux-3.10.15/include/uapi/vserver/limit_cmd.h 1970-01-01 00:00:00.000000000 +0000
13077 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/limit_cmd.h 2013-08-22 20:30:00.000000000 +0000
13079 +#ifndef _UAPI_VS_LIMIT_CMD_H
13080 +#define _UAPI_VS_LIMIT_CMD_H
13083 +/* rlimit vserver commands */
13085 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
13086 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
13087 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
13088 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
13089 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
13091 +struct vcmd_ctx_rlimit_v0 {
13093 + uint64_t minimum;
13094 + uint64_t softlimit;
13095 + uint64_t maximum;
13098 +struct vcmd_ctx_rlimit_mask_v0 {
13099 + uint32_t minimum;
13100 + uint32_t softlimit;
13101 + uint32_t maximum;
13104 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
13106 +struct vcmd_rlimit_stat_v0 {
13110 + uint64_t minimum;
13111 + uint64_t maximum;
13114 +#define CRLIM_UNSET (0ULL)
13115 +#define CRLIM_INFINITY (~0ULL)
13116 +#define CRLIM_KEEP (~1ULL)
13118 +#endif /* _UAPI_VS_LIMIT_CMD_H */
13119 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/monitor.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/monitor.h
13120 --- linux-3.10.15/include/uapi/vserver/monitor.h 1970-01-01 00:00:00.000000000 +0000
13121 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/monitor.h 2013-08-22 20:30:00.000000000 +0000
13123 +#ifndef _UAPI_VS_MONITOR_H
13124 +#define _UAPI_VS_MONITOR_H
13126 +#include <linux/types.h>
13134 + VXM_UPDATE = 0x20,
13138 + VXM_RQINFO_1 = 0x24,
13141 + VXM_ACTIVATE = 0x40,
13148 + VXM_MIGRATE = 0x48,
13151 + /* all other bits are flags */
13152 + VXM_SCHED = 0x80,
13155 +struct _vxm_update_1 {
13156 + uint32_t tokens_max;
13157 + uint32_t fill_rate;
13158 + uint32_t interval;
13161 +struct _vxm_update_2 {
13162 + uint32_t tokens_min;
13163 + uint32_t fill_rate;
13164 + uint32_t interval;
13167 +struct _vxm_rqinfo_1 {
13168 + uint16_t running;
13172 + uint32_t idle_tokens;
13175 +struct _vxm_rqinfo_2 {
13176 + uint32_t norm_time;
13177 + uint32_t idle_time;
13178 + uint32_t idle_skip;
13181 +struct _vxm_sched {
13183 + uint32_t norm_time;
13184 + uint32_t idle_time;
13187 +struct _vxm_task {
13192 +struct _vxm_event {
13201 + struct _vxm_task tsk;
13205 +struct _vx_mon_entry {
13209 + struct _vxm_event ev;
13210 + struct _vxm_sched sd;
13211 + struct _vxm_update_1 u1;
13212 + struct _vxm_update_2 u2;
13213 + struct _vxm_rqinfo_1 q1;
13214 + struct _vxm_rqinfo_2 q2;
13218 +#endif /* _UAPI_VS_MONITOR_H */
13219 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/network.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/network.h
13220 --- linux-3.10.15/include/uapi/vserver/network.h 1970-01-01 00:00:00.000000000 +0000
13221 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/network.h 2013-08-22 20:30:00.000000000 +0000
13223 +#ifndef _UAPI_VS_NETWORK_H
13224 +#define _UAPI_VS_NETWORK_H
13226 +#include <linux/types.h>
13229 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13232 +/* network flags */
13234 +#define NXF_INFO_PRIVATE 0x00000008
13236 +#define NXF_SINGLE_IP 0x00000100
13237 +#define NXF_LBACK_REMAP 0x00000200
13238 +#define NXF_LBACK_ALLOW 0x00000400
13240 +#define NXF_HIDE_NETIF 0x02000000
13241 +#define NXF_HIDE_LBACK 0x04000000
13243 +#define NXF_STATE_SETUP (1ULL << 32)
13244 +#define NXF_STATE_ADMIN (1ULL << 34)
13246 +#define NXF_SC_HELPER (1ULL << 36)
13247 +#define NXF_PERSISTENT (1ULL << 38)
13249 +#define NXF_ONE_TIME (0x0005ULL << 32)
13252 +#define NXF_INIT_SET (__nxf_init_set())
13254 +static inline uint64_t __nxf_init_set(void) {
13255 + return NXF_STATE_ADMIN
13256 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13257 + | NXF_LBACK_REMAP
13260 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13263 + | NXF_HIDE_NETIF;
13267 +/* network caps */
13269 +#define NXC_TUN_CREATE 0x00000001
13271 +#define NXC_RAW_ICMP 0x00000100
13273 +#define NXC_MULTICAST 0x00001000
13276 +/* address types */
13278 +#define NXA_TYPE_IPV4 0x0001
13279 +#define NXA_TYPE_IPV6 0x0002
13281 +#define NXA_TYPE_NONE 0x0000
13282 +#define NXA_TYPE_ANY 0x00FF
13284 +#define NXA_TYPE_ADDR 0x0010
13285 +#define NXA_TYPE_MASK 0x0020
13286 +#define NXA_TYPE_RANGE 0x0040
13288 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13290 +#define NXA_MOD_BCAST 0x0100
13291 +#define NXA_MOD_LBACK 0x0200
13293 +#define NXA_LOOPBACK 0x1000
13295 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13296 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13298 +#endif /* _UAPI_VS_NETWORK_H */
13299 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/network_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/network_cmd.h
13300 --- linux-3.10.15/include/uapi/vserver/network_cmd.h 1970-01-01 00:00:00.000000000 +0000
13301 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/network_cmd.h 2013-08-22 20:30:00.000000000 +0000
13303 +#ifndef _UAPI_VS_NETWORK_CMD_H
13304 +#define _UAPI_VS_NETWORK_CMD_H
13307 +/* vinfo commands */
13309 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13312 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13314 +struct vcmd_nx_info_v0 {
13316 + /* more to come */
13320 +#include <linux/in.h>
13321 +#include <linux/in6.h>
13323 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13324 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13326 +struct vcmd_net_create {
13327 + uint64_t flagword;
13330 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13332 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13333 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13335 +struct vcmd_net_addr_v0 {
13338 + struct in_addr ip[4];
13339 + struct in_addr mask[4];
13342 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13343 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13345 +struct vcmd_net_addr_ipv4_v1 {
13348 + struct in_addr ip;
13349 + struct in_addr mask;
13352 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13353 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13355 +struct vcmd_net_addr_ipv4_v2 {
13358 + struct in_addr ip;
13359 + struct in_addr ip2;
13360 + struct in_addr mask;
13363 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13364 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13366 +struct vcmd_net_addr_ipv6_v1 {
13370 + struct in6_addr ip;
13371 + struct in6_addr mask;
13374 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13375 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13377 +struct vcmd_match_ipv4_v0 {
13382 + struct in_addr ip;
13383 + struct in_addr ip2;
13384 + struct in_addr mask;
13387 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13388 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13390 +struct vcmd_match_ipv6_v0 {
13395 + struct in6_addr ip;
13396 + struct in6_addr ip2;
13397 + struct in6_addr mask;
13403 +/* flag commands */
13405 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13406 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13408 +struct vcmd_net_flags_v0 {
13409 + uint64_t flagword;
13415 +/* network caps commands */
13417 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13418 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13420 +struct vcmd_net_caps_v0 {
13425 +#endif /* _UAPI_VS_NETWORK_CMD_H */
13426 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/sched_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/sched_cmd.h
13427 --- linux-3.10.15/include/uapi/vserver/sched_cmd.h 1970-01-01 00:00:00.000000000 +0000
13428 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/sched_cmd.h 2013-08-22 20:30:00.000000000 +0000
13430 +#ifndef _UAPI_VS_SCHED_CMD_H
13431 +#define _UAPI_VS_SCHED_CMD_H
13434 +struct vcmd_prio_bias {
13436 + int32_t prio_bias;
13439 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13440 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13442 +#endif /* _UAPI_VS_SCHED_CMD_H */
13443 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/signal_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/signal_cmd.h
13444 --- linux-3.10.15/include/uapi/vserver/signal_cmd.h 1970-01-01 00:00:00.000000000 +0000
13445 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/signal_cmd.h 2013-08-22 20:30:00.000000000 +0000
13447 +#ifndef _UAPI_VS_SIGNAL_CMD_H
13448 +#define _UAPI_VS_SIGNAL_CMD_H
13451 +/* signalling vserver commands */
13453 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13454 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13456 +struct vcmd_ctx_kill_v0 {
13461 +struct vcmd_wait_exit_v0 {
13462 + int32_t reboot_cmd;
13463 + int32_t exit_code;
13467 +/* process alteration commands */
13469 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13470 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13472 +struct vcmd_pflags_v0 {
13473 + uint32_t flagword;
13477 +#endif /* _UAPI_VS_SIGNAL_CMD_H */
13478 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/space_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/space_cmd.h
13479 --- linux-3.10.15/include/uapi/vserver/space_cmd.h 1970-01-01 00:00:00.000000000 +0000
13480 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/space_cmd.h 2013-08-22 20:30:00.000000000 +0000
13482 +#ifndef _UAPI_VS_SPACE_CMD_H
13483 +#define _UAPI_VS_SPACE_CMD_H
13486 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13487 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13488 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13490 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13491 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13492 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13494 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13496 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13497 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13500 +struct vcmd_space_mask_v1 {
13504 +struct vcmd_space_mask_v2 {
13509 +#endif /* _UAPI_VS_SPACE_CMD_H */
13510 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/switch.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/switch.h
13511 --- linux-3.10.15/include/uapi/vserver/switch.h 1970-01-01 00:00:00.000000000 +0000
13512 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/switch.h 2013-08-22 20:30:00.000000000 +0000
13514 +#ifndef _UAPI_VS_SWITCH_H
13515 +#define _UAPI_VS_SWITCH_H
13517 +#include <linux/types.h>
13520 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13521 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13522 +#define VC_VERSION(c) ((c) & 0xFFF)
13524 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13525 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13529 + Syscall Matrix V2.8
13531 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13532 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13533 + |INFO |SETUP | |MOVE | | | | | |
13534 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13535 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13536 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13537 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13538 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13539 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13540 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13541 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13542 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13543 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13544 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13545 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13546 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13547 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13548 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13549 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13550 + OTHER |VSTAT | | | | | | |VINFO | |
13551 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13552 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13553 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13554 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13555 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13556 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13557 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13558 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13562 +#define VC_CAT_VERSION 0
13564 +#define VC_CAT_VSETUP 1
13565 +#define VC_CAT_VHOST 2
13567 +#define VC_CAT_DEVICE 6
13569 +#define VC_CAT_VPROC 9
13570 +#define VC_CAT_PROCALT 10
13571 +#define VC_CAT_PROCMIG 11
13572 +#define VC_CAT_PROCTRL 12
13574 +#define VC_CAT_SCHED 14
13575 +#define VC_CAT_MEMCTRL 20
13577 +#define VC_CAT_VNET 25
13578 +#define VC_CAT_NETALT 26
13579 +#define VC_CAT_NETMIG 27
13580 +#define VC_CAT_NETCTRL 28
13582 +#define VC_CAT_TAGMIG 35
13583 +#define VC_CAT_DLIMIT 36
13584 +#define VC_CAT_INODE 38
13586 +#define VC_CAT_VSTAT 40
13587 +#define VC_CAT_VINFO 46
13588 +#define VC_CAT_EVENT 48
13590 +#define VC_CAT_FLAGS 52
13591 +#define VC_CAT_VSPACE 54
13592 +#define VC_CAT_DEBUG 56
13593 +#define VC_CAT_RLIMIT 60
13595 +#define VC_CAT_SYSTEST 61
13596 +#define VC_CAT_COMPAT 63
13598 +/* query version */
13600 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13601 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13603 +#endif /* _UAPI_VS_SWITCH_H */
13604 diff -NurpP --minimal linux-3.10.15/include/uapi/vserver/tag_cmd.h linux-3.10.15-vs2.3.6.6/include/uapi/vserver/tag_cmd.h
13605 --- linux-3.10.15/include/uapi/vserver/tag_cmd.h 1970-01-01 00:00:00.000000000 +0000
13606 +++ linux-3.10.15-vs2.3.6.6/include/uapi/vserver/tag_cmd.h 2013-08-22 20:30:00.000000000 +0000
13608 +#ifndef _UAPI_VS_TAG_CMD_H
13609 +#define _UAPI_VS_TAG_CMD_H
13612 +/* vinfo commands */
13614 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13617 +/* context commands */
13619 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13621 +#endif /* _UAPI_VS_TAG_CMD_H */
13622 diff -NurpP --minimal linux-3.10.15/init/Kconfig linux-3.10.15-vs2.3.6.6/init/Kconfig
13623 --- linux-3.10.15/init/Kconfig 2013-07-14 17:01:34.000000000 +0000
13624 +++ linux-3.10.15-vs2.3.6.6/init/Kconfig 2013-08-22 20:30:00.000000000 +0000
13625 @@ -805,6 +805,7 @@ config NUMA_BALANCING
13627 boolean "Control Group support"
13631 This option adds support for grouping sets of processes together, for
13632 use with process control subsystems such as Cpusets, CFS, memory
13633 @@ -1067,6 +1068,7 @@ config IPC_NS
13635 bool "User namespace"
13636 depends on UIDGID_CONVERTED
13637 + depends on VSERVER_DISABLED
13638 select UIDGID_STRICT_TYPE_CHECKS
13641 diff -NurpP --minimal linux-3.10.15/init/main.c linux-3.10.15-vs2.3.6.6/init/main.c
13642 --- linux-3.10.15/init/main.c 2013-07-14 17:01:34.000000000 +0000
13643 +++ linux-3.10.15-vs2.3.6.6/init/main.c 2013-08-22 20:30:00.000000000 +0000
13645 #include <linux/blkdev.h>
13646 #include <linux/elevator.h>
13647 #include <linux/random.h>
13648 +#include <linux/vserver/percpu.h>
13650 #include <asm/io.h>
13651 #include <asm/bugs.h>
13652 diff -NurpP --minimal linux-3.10.15/ipc/mqueue.c linux-3.10.15-vs2.3.6.6/ipc/mqueue.c
13653 --- linux-3.10.15/ipc/mqueue.c 2013-05-31 13:45:29.000000000 +0000
13654 +++ linux-3.10.15-vs2.3.6.6/ipc/mqueue.c 2013-08-22 20:30:00.000000000 +0000
13656 #include <linux/ipc_namespace.h>
13657 #include <linux/user_namespace.h>
13658 #include <linux/slab.h>
13659 +#include <linux/vs_context.h>
13660 +#include <linux/vs_limit.h>
13662 #include <net/sock.h>
13664 @@ -76,6 +78,7 @@ struct mqueue_inode_info {
13665 struct pid* notify_owner;
13666 struct user_namespace *notify_user_ns;
13667 struct user_struct *user; /* user who created, for accounting */
13668 + struct vx_info *vxi;
13669 struct sock *notify_sock;
13670 struct sk_buff *notify_cookie;
13672 @@ -234,6 +237,7 @@ static struct inode *mqueue_get_inode(st
13673 if (S_ISREG(mode)) {
13674 struct mqueue_inode_info *info;
13675 unsigned long mq_bytes, mq_treesize;
13676 + struct vx_info *vxi = current_vx_info();
13678 inode->i_fop = &mqueue_file_operations;
13679 inode->i_size = FILENT_SIZE;
13680 @@ -247,6 +251,7 @@ static struct inode *mqueue_get_inode(st
13681 info->notify_user_ns = NULL;
13683 info->user = NULL; /* set when all is ok */
13684 + info->vxi = NULL;
13685 info->msg_tree = RB_ROOT;
13686 info->node_cache = NULL;
13687 memset(&info->attr, 0, sizeof(info->attr));
13688 @@ -280,17 +285,20 @@ static struct inode *mqueue_get_inode(st
13690 spin_lock(&mq_lock);
13691 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
13692 - u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
13693 + u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE) ||
13694 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
13695 spin_unlock(&mq_lock);
13696 /* mqueue_evict_inode() releases info->messages */
13700 u->mq_bytes += mq_bytes;
13701 + vx_ipcmsg_add(vxi, u, mq_bytes);
13702 spin_unlock(&mq_lock);
13705 info->user = get_uid(u);
13706 + info->vxi = get_vx_info(vxi);
13707 } else if (S_ISDIR(mode)) {
13709 /* Some things misbehave if size == 0 on a directory */
13710 @@ -402,8 +410,11 @@ static void mqueue_evict_inode(struct in
13714 + struct vx_info *vxi = info->vxi;
13716 spin_lock(&mq_lock);
13717 user->mq_bytes -= mq_bytes;
13718 + vx_ipcmsg_sub(vxi, user, mq_bytes);
13720 * get_ns_from_inode() ensures that the
13721 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
13722 @@ -413,6 +424,7 @@ static void mqueue_evict_inode(struct in
13724 ipc_ns->mq_queues_count--;
13725 spin_unlock(&mq_lock);
13726 + put_vx_info(vxi);
13730 diff -NurpP --minimal linux-3.10.15/ipc/msg.c linux-3.10.15-vs2.3.6.6/ipc/msg.c
13731 --- linux-3.10.15/ipc/msg.c 2013-10-09 17:35:23.000000000 +0000
13732 +++ linux-3.10.15-vs2.3.6.6/ipc/msg.c 2013-10-09 17:37:22.000000000 +0000
13734 #include <linux/rwsem.h>
13735 #include <linux/nsproxy.h>
13736 #include <linux/ipc_namespace.h>
13737 +#include <linux/vs_base.h>
13739 #include <asm/current.h>
13740 #include <asm/uaccess.h>
13741 @@ -191,6 +192,7 @@ static int newque(struct ipc_namespace *
13743 msq->q_perm.mode = msgflg & S_IRWXUGO;
13744 msq->q_perm.key = key;
13745 + msq->q_perm.xid = vx_current_xid();
13747 msq->q_perm.security = NULL;
13748 retval = security_msg_queue_alloc(msq);
13749 diff -NurpP --minimal linux-3.10.15/ipc/sem.c linux-3.10.15-vs2.3.6.6/ipc/sem.c
13750 --- linux-3.10.15/ipc/sem.c 2013-07-14 17:01:34.000000000 +0000
13751 +++ linux-3.10.15-vs2.3.6.6/ipc/sem.c 2013-08-22 20:30:00.000000000 +0000
13753 #include <linux/rwsem.h>
13754 #include <linux/nsproxy.h>
13755 #include <linux/ipc_namespace.h>
13756 +#include <linux/vs_base.h>
13757 +#include <linux/vs_limit.h>
13759 #include <asm/uaccess.h>
13761 @@ -399,6 +401,7 @@ static int newary(struct ipc_namespace *
13763 sma->sem_perm.mode = (semflg & S_IRWXUGO);
13764 sma->sem_perm.key = key;
13765 + sma->sem_perm.xid = vx_current_xid();
13767 sma->sem_perm.security = NULL;
13768 retval = security_sem_alloc(sma);
13769 @@ -414,6 +417,9 @@ static int newary(struct ipc_namespace *
13772 ns->used_sems += nsems;
13773 + /* FIXME: obsoleted? */
13774 + vx_semary_inc(sma);
13775 + vx_nsems_add(sma, nsems);
13777 sma->sem_base = (struct sem *) &sma[1];
13779 @@ -903,6 +909,9 @@ static void freeary(struct ipc_namespace
13781 wake_up_sem_queue_do(&tasks);
13782 ns->used_sems -= sma->sem_nsems;
13783 + /* FIXME: obsoleted? */
13784 + vx_nsems_sub(sma, sma->sem_nsems);
13785 + vx_semary_dec(sma);
13786 ipc_rcu_putref(sma, sem_rcu_free);
13789 diff -NurpP --minimal linux-3.10.15/ipc/shm.c linux-3.10.15-vs2.3.6.6/ipc/shm.c
13790 --- linux-3.10.15/ipc/shm.c 2013-07-14 17:01:34.000000000 +0000
13791 +++ linux-3.10.15-vs2.3.6.6/ipc/shm.c 2013-08-22 20:30:00.000000000 +0000
13793 #include <linux/nsproxy.h>
13794 #include <linux/mount.h>
13795 #include <linux/ipc_namespace.h>
13796 +#include <linux/vs_context.h>
13797 +#include <linux/vs_limit.h>
13799 #include <asm/uaccess.h>
13801 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
13803 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
13805 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
13806 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
13807 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
13809 + vx_ipcshm_sub(vxi, shp, numpages);
13810 + ns->shm_tot -= numpages;
13814 if (!is_file_hugepages(shp->shm_file))
13815 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
13816 user_shm_unlock(file_inode(shp->shm_file)->i_size,
13818 fput (shp->shm_file);
13819 + put_vx_info(vxi);
13820 ipc_rcu_putref(shp, shm_rcu_free);
13823 @@ -474,11 +482,15 @@ static int newseg(struct ipc_namespace *
13824 if (ns->shm_tot + numpages > ns->shm_ctlall)
13827 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
13830 shp = ipc_rcu_alloc(sizeof(*shp));
13834 shp->shm_perm.key = key;
13835 + shp->shm_perm.xid = vx_current_xid();
13836 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
13837 shp->mlock_user = NULL;
13839 @@ -544,6 +556,7 @@ static int newseg(struct ipc_namespace *
13841 ipc_unlock_object(&shp->shm_perm);
13843 + vx_ipcshm_add(current_vx_info(), key, numpages);
13847 diff -NurpP --minimal linux-3.10.15/kernel/Makefile linux-3.10.15-vs2.3.6.6/kernel/Makefile
13848 --- linux-3.10.15/kernel/Makefile 2013-07-14 17:01:34.000000000 +0000
13849 +++ linux-3.10.15-vs2.3.6.6/kernel/Makefile 2013-08-22 21:18:32.000000000 +0000
13850 @@ -25,6 +25,7 @@ endif
13856 obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
13857 obj-$(CONFIG_FREEZER) += freezer.o
13858 diff -NurpP --minimal linux-3.10.15/kernel/auditsc.c linux-3.10.15-vs2.3.6.6/kernel/auditsc.c
13859 --- linux-3.10.15/kernel/auditsc.c 2013-07-14 17:01:34.000000000 +0000
13860 +++ linux-3.10.15-vs2.3.6.6/kernel/auditsc.c 2013-08-22 20:30:00.000000000 +0000
13861 @@ -1976,7 +1976,7 @@ int audit_set_loginuid(kuid_t loginuid)
13862 if (audit_loginuid_set(task))
13864 #else /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
13865 - if (!capable(CAP_AUDIT_CONTROL))
13866 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
13868 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
13870 diff -NurpP --minimal linux-3.10.15/kernel/capability.c linux-3.10.15-vs2.3.6.6/kernel/capability.c
13871 --- linux-3.10.15/kernel/capability.c 2013-05-31 13:45:29.000000000 +0000
13872 +++ linux-3.10.15-vs2.3.6.6/kernel/capability.c 2013-08-22 20:30:00.000000000 +0000
13874 #include <linux/syscalls.h>
13875 #include <linux/pid_namespace.h>
13876 #include <linux/user_namespace.h>
13877 +#include <linux/vs_context.h>
13878 #include <asm/uaccess.h>
13881 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
13887 * The only thing that can change the capabilities of the current
13888 * process is the current process. As such, we can't be in this code
13889 @@ -349,6 +351,8 @@ bool has_ns_capability_noaudit(struct ta
13893 +#include <linux/vserver/base.h>
13896 * has_capability_noaudit - Does a task have a capability (unaudited) in the
13898 diff -NurpP --minimal linux-3.10.15/kernel/compat.c linux-3.10.15-vs2.3.6.6/kernel/compat.c
13899 --- linux-3.10.15/kernel/compat.c 2013-07-14 17:01:34.000000000 +0000
13900 +++ linux-3.10.15-vs2.3.6.6/kernel/compat.c 2013-08-22 20:30:00.000000000 +0000
13902 #include <linux/times.h>
13903 #include <linux/ptrace.h>
13904 #include <linux/gfp.h>
13905 +#include <linux/vs_time.h>
13907 #include <asm/uaccess.h>
13909 @@ -1040,7 +1041,7 @@ asmlinkage long compat_sys_stime(compat_
13913 - do_settimeofday(&tv);
13914 + vx_settimeofday(&tv);
13918 diff -NurpP --minimal linux-3.10.15/kernel/cred.c linux-3.10.15-vs2.3.6.6/kernel/cred.c
13919 --- linux-3.10.15/kernel/cred.c 2013-02-19 13:58:56.000000000 +0000
13920 +++ linux-3.10.15-vs2.3.6.6/kernel/cred.c 2013-08-22 20:30:00.000000000 +0000
13921 @@ -56,31 +56,6 @@ struct cred init_cred = {
13922 .group_info = &init_groups,
13925 -static inline void set_cred_subscribers(struct cred *cred, int n)
13927 -#ifdef CONFIG_DEBUG_CREDENTIALS
13928 - atomic_set(&cred->subscribers, n);
13932 -static inline int read_cred_subscribers(const struct cred *cred)
13934 -#ifdef CONFIG_DEBUG_CREDENTIALS
13935 - return atomic_read(&cred->subscribers);
13941 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
13943 -#ifdef CONFIG_DEBUG_CREDENTIALS
13944 - struct cred *cred = (struct cred *) _cred;
13946 - atomic_add(n, &cred->subscribers);
13951 * The RCU callback to actually dispose of a set of credentials
13953 @@ -232,21 +207,16 @@ error:
13955 * Call commit_creds() or abort_creds() to clean up.
13957 -struct cred *prepare_creds(void)
13958 +struct cred *__prepare_creds(const struct cred *old)
13960 - struct task_struct *task = current;
13961 - const struct cred *old;
13964 - validate_process_creds();
13966 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
13970 kdebug("prepare_creds() alloc %p", new);
13972 - old = task->cred;
13973 memcpy(new, old, sizeof(struct cred));
13975 atomic_set(&new->usage, 1);
13976 @@ -275,6 +245,13 @@ error:
13981 +struct cred *prepare_creds(void)
13983 + validate_process_creds();
13985 + return __prepare_creds(current->cred);
13987 EXPORT_SYMBOL(prepare_creds);
13990 diff -NurpP --minimal linux-3.10.15/kernel/exit.c linux-3.10.15-vs2.3.6.6/kernel/exit.c
13991 --- linux-3.10.15/kernel/exit.c 2013-07-14 17:01:35.000000000 +0000
13992 +++ linux-3.10.15-vs2.3.6.6/kernel/exit.c 2013-08-22 20:30:00.000000000 +0000
13994 #include <linux/fs_struct.h>
13995 #include <linux/init_task.h>
13996 #include <linux/perf_event.h>
13997 +#include <linux/vs_limit.h>
13998 +#include <linux/vs_context.h>
13999 +#include <linux/vs_network.h>
14000 +#include <linux/vs_pid.h>
14001 #include <trace/events/sched.h>
14002 #include <linux/hw_breakpoint.h>
14003 #include <linux/oom.h>
14004 @@ -514,15 +518,25 @@ static struct task_struct *find_new_reap
14005 __acquires(&tasklist_lock)
14007 struct pid_namespace *pid_ns = task_active_pid_ns(father);
14008 - struct task_struct *thread;
14009 + struct vx_info *vxi = task_get_vx_info(father);
14010 + struct task_struct *thread = father;
14011 + struct task_struct *reaper;
14014 while_each_thread(father, thread) {
14015 if (thread->flags & PF_EXITING)
14017 if (unlikely(pid_ns->child_reaper == father))
14018 pid_ns->child_reaper = thread;
14024 + reaper = pid_ns->child_reaper;
14026 + BUG_ON(!vxi->vx_reaper);
14027 + if (vxi->vx_reaper != init_pid_ns.child_reaper &&
14028 + vxi->vx_reaper != father)
14029 + reaper = vxi->vx_reaper;
14032 if (unlikely(pid_ns->child_reaper == father)) {
14033 @@ -560,7 +574,9 @@ static struct task_struct *find_new_reap
14037 - return pid_ns->child_reaper;
14039 + put_vx_info(vxi);
14044 @@ -611,10 +627,15 @@ static void forget_original_parent(struc
14045 list_for_each_entry_safe(p, n, &father->children, sibling) {
14046 struct task_struct *t = p;
14048 - t->real_parent = reaper;
14049 + struct task_struct *new_parent = reaper;
14051 + if (unlikely(p == reaper))
14052 + new_parent = task_active_pid_ns(p)->child_reaper;
14054 + t->real_parent = new_parent;
14055 if (t->parent == father) {
14057 - t->parent = t->real_parent;
14058 + t->parent = new_parent;
14060 if (t->pdeath_signal)
14061 group_send_sig_info(t->pdeath_signal,
14062 @@ -821,6 +842,9 @@ void do_exit(long code)
14064 ptrace_put_breakpoints(tsk);
14066 + /* needs to stay before exit_notify() */
14067 + exit_vx_info_early(tsk, code);
14069 exit_notify(tsk, group_dead);
14072 @@ -874,10 +898,15 @@ void do_exit(long code)
14074 raw_spin_unlock_wait(&tsk->pi_lock);
14076 + /* needs to stay after exit_notify() */
14077 + exit_vx_info(tsk, code);
14078 + exit_nx_info(tsk);
14080 /* causes final put_task_struct in finish_task_switch(). */
14081 tsk->state = TASK_DEAD;
14082 tsk->flags |= PF_NOFREEZE; /* tell freezer to ignore us */
14084 + printk("bad task: %p [%lx]\n", current, current->state);
14086 /* Avoid "noreturn function does return". */
14088 diff -NurpP --minimal linux-3.10.15/kernel/fork.c linux-3.10.15-vs2.3.6.6/kernel/fork.c
14089 --- linux-3.10.15/kernel/fork.c 2013-10-09 17:35:23.000000000 +0000
14090 +++ linux-3.10.15-vs2.3.6.6/kernel/fork.c 2013-10-09 17:37:22.000000000 +0000
14092 #include <linux/signalfd.h>
14093 #include <linux/uprobes.h>
14094 #include <linux/aio.h>
14095 +#include <linux/vs_context.h>
14096 +#include <linux/vs_network.h>
14097 +#include <linux/vs_limit.h>
14099 #include <asm/pgtable.h>
14100 #include <asm/pgalloc.h>
14101 @@ -211,6 +214,8 @@ void free_task(struct task_struct *tsk)
14102 arch_release_thread_info(tsk->stack);
14103 free_thread_info(tsk->stack);
14104 rt_mutex_debug_task_free(tsk);
14105 + clr_vx_info(&tsk->vx_info);
14106 + clr_nx_info(&tsk->nx_info);
14107 ftrace_graph_exit_task(tsk);
14108 put_seccomp_filter(tsk);
14109 arch_release_task_struct(tsk);
14110 @@ -548,6 +553,7 @@ static struct mm_struct *mm_init(struct
14111 if (likely(!mm_alloc_pgd(mm))) {
14113 mmu_notifier_mm_init(mm);
14114 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14118 @@ -600,6 +606,7 @@ void __mmdrop(struct mm_struct *mm)
14119 destroy_context(mm);
14120 mmu_notifier_mm_destroy(mm);
14122 + clr_vx_info(&mm->mm_vx_info);
14125 EXPORT_SYMBOL_GPL(__mmdrop);
14126 @@ -819,6 +826,7 @@ struct mm_struct *dup_mm(struct task_str
14129 memcpy(mm, oldmm, sizeof(*mm));
14130 + mm->mm_vx_info = NULL;
14131 mm_init_cpumask(mm);
14133 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14134 @@ -860,6 +868,7 @@ fail_nocontext:
14135 * If init_new_context() failed, we cannot use mmput() to free the mm
14136 * because it calls destroy_context()
14138 + clr_vx_info(&mm->mm_vx_info);
14142 @@ -1138,6 +1147,8 @@ static struct task_struct *copy_process(
14145 struct task_struct *p;
14146 + struct vx_info *vxi;
14147 + struct nx_info *nxi;
14149 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14150 return ERR_PTR(-EINVAL);
14151 @@ -1197,7 +1208,12 @@ static struct task_struct *copy_process(
14152 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14153 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14155 + init_vx_info(&p->vx_info, current_vx_info());
14156 + init_nx_info(&p->nx_info, current_nx_info());
14159 + if (!vx_nproc_avail(1))
14160 + goto bad_fork_free;
14161 if (atomic_read(&p->real_cred->user->processes) >=
14162 task_rlimit(p, RLIMIT_NPROC)) {
14163 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14164 @@ -1478,6 +1494,18 @@ static struct task_struct *copy_process(
14167 spin_unlock(¤t->sighand->siglock);
14169 + /* p is copy of current */
14170 + vxi = p->vx_info;
14172 + claim_vx_info(vxi, p);
14173 + atomic_inc(&vxi->cvirt.nr_threads);
14174 + atomic_inc(&vxi->cvirt.total_forks);
14177 + nxi = p->nx_info;
14179 + claim_nx_info(nxi, p);
14180 write_unlock_irq(&tasklist_lock);
14181 proc_fork_connector(p);
14182 cgroup_post_fork(p);
14183 diff -NurpP --minimal linux-3.10.15/kernel/kthread.c linux-3.10.15-vs2.3.6.6/kernel/kthread.c
14184 --- linux-3.10.15/kernel/kthread.c 2013-07-14 17:01:35.000000000 +0000
14185 +++ linux-3.10.15-vs2.3.6.6/kernel/kthread.c 2013-08-22 21:14:28.000000000 +0000
14187 #include <linux/freezer.h>
14188 #include <linux/ptrace.h>
14189 #include <linux/uaccess.h>
14190 +#include <linux/vs_pid.h>
14191 #include <trace/events/sched.h>
14193 static DEFINE_SPINLOCK(kthread_create_lock);
14194 diff -NurpP --minimal linux-3.10.15/kernel/nsproxy.c linux-3.10.15-vs2.3.6.6/kernel/nsproxy.c
14195 --- linux-3.10.15/kernel/nsproxy.c 2013-07-14 17:01:35.000000000 +0000
14196 +++ linux-3.10.15-vs2.3.6.6/kernel/nsproxy.c 2013-08-22 21:09:55.000000000 +0000
14197 @@ -20,11 +20,14 @@
14198 #include <linux/mnt_namespace.h>
14199 #include <linux/utsname.h>
14200 #include <linux/pid_namespace.h>
14201 +#include <linux/vserver/global.h>
14202 +#include <linux/vserver/debug.h>
14203 #include <net/net_namespace.h>
14204 #include <linux/ipc_namespace.h>
14205 #include <linux/proc_ns.h>
14206 #include <linux/file.h>
14207 #include <linux/syscalls.h>
14208 +#include "../fs/mount.h"
14210 static struct kmem_cache *nsproxy_cachep;
14212 @@ -46,8 +49,11 @@ static inline struct nsproxy *create_nsp
14213 struct nsproxy *nsproxy;
14215 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14218 atomic_set(&nsproxy->count, 1);
14219 + atomic_inc(&vs_global_nsproxy);
14221 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14225 @@ -56,9 +62,12 @@ static inline struct nsproxy *create_nsp
14226 * Return the newly created nsproxy. Do not attach this to the task,
14227 * leave it to the caller to do proper locking and attach it to task.
14229 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14230 - struct task_struct *tsk, struct user_namespace *user_ns,
14231 - struct fs_struct *new_fs)
14232 +static struct nsproxy *unshare_namespaces(
14233 + unsigned long flags,
14234 + struct nsproxy *orig,
14235 + struct fs_struct *new_fs,
14236 + struct user_namespace *new_user,
14237 + struct pid_namespace *new_pid)
14239 struct nsproxy *new_nsp;
14241 @@ -67,31 +76,31 @@ static struct nsproxy *create_new_namesp
14243 return ERR_PTR(-ENOMEM);
14245 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, user_ns, new_fs);
14246 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_user, new_fs);
14247 if (IS_ERR(new_nsp->mnt_ns)) {
14248 err = PTR_ERR(new_nsp->mnt_ns);
14252 - new_nsp->uts_ns = copy_utsname(flags, user_ns, tsk->nsproxy->uts_ns);
14253 + new_nsp->uts_ns = copy_utsname(flags, new_user, orig->uts_ns);
14254 if (IS_ERR(new_nsp->uts_ns)) {
14255 err = PTR_ERR(new_nsp->uts_ns);
14259 - new_nsp->ipc_ns = copy_ipcs(flags, user_ns, tsk->nsproxy->ipc_ns);
14260 + new_nsp->ipc_ns = copy_ipcs(flags, new_user, orig->ipc_ns);
14261 if (IS_ERR(new_nsp->ipc_ns)) {
14262 err = PTR_ERR(new_nsp->ipc_ns);
14266 - new_nsp->pid_ns = copy_pid_ns(flags, user_ns, tsk->nsproxy->pid_ns);
14267 + new_nsp->pid_ns = copy_pid_ns(flags, new_user, new_pid);
14268 if (IS_ERR(new_nsp->pid_ns)) {
14269 err = PTR_ERR(new_nsp->pid_ns);
14273 - new_nsp->net_ns = copy_net_ns(flags, user_ns, tsk->nsproxy->net_ns);
14274 + new_nsp->net_ns = copy_net_ns(flags, new_user, orig->net_ns);
14275 if (IS_ERR(new_nsp->net_ns)) {
14276 err = PTR_ERR(new_nsp->net_ns);
14278 @@ -116,6 +125,41 @@ out_ns:
14279 return ERR_PTR(err);
14282 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14283 + struct task_struct *tsk, struct user_namespace *user_ns,
14284 + struct fs_struct *new_fs)
14287 + return unshare_namespaces(flags, tsk->nsproxy,
14288 + new_fs, user_ns, task_active_pid_ns(tsk));
14292 + * copies the nsproxy, setting refcount to 1, and grabbing a
14293 + * reference to all contained namespaces.
14295 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14297 + struct nsproxy *ns = create_nsproxy();
14300 + memcpy(ns, orig, sizeof(struct nsproxy));
14301 + atomic_set(&ns->count, 1);
14304 + get_mnt_ns(ns->mnt_ns);
14306 + get_uts_ns(ns->uts_ns);
14308 + get_ipc_ns(ns->ipc_ns);
14310 + get_pid_ns(ns->pid_ns);
14312 + get_net(ns->net_ns);
14318 * called from clone. This now handles copy for nsproxy and all
14319 * namespaces therein.
14320 @@ -124,9 +168,12 @@ int copy_namespaces(unsigned long flags,
14322 struct nsproxy *old_ns = tsk->nsproxy;
14323 struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
14324 - struct nsproxy *new_ns;
14325 + struct nsproxy *new_ns = NULL;
14328 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14329 + flags, tsk, old_ns);
14334 @@ -136,7 +183,7 @@ int copy_namespaces(unsigned long flags,
14335 CLONE_NEWPID | CLONE_NEWNET)))
14338 - if (!ns_capable(user_ns, CAP_SYS_ADMIN)) {
14339 + if (!vx_ns_can_unshare(user_ns, CAP_SYS_ADMIN, flags)) {
14343 @@ -163,6 +210,9 @@ int copy_namespaces(unsigned long flags,
14346 put_nsproxy(old_ns);
14347 + vxdprintk(VXD_CBIT(space, 3),
14348 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14349 + flags, tsk, old_ns, err, new_ns);
14353 @@ -176,7 +226,9 @@ void free_nsproxy(struct nsproxy *ns)
14354 put_ipc_ns(ns->ipc_ns);
14356 put_pid_ns(ns->pid_ns);
14357 - put_net(ns->net_ns);
14359 + put_net(ns->net_ns);
14360 + atomic_dec(&vs_global_nsproxy);
14361 kmem_cache_free(nsproxy_cachep, ns);
14364 @@ -190,12 +242,16 @@ int unshare_nsproxy_namespaces(unsigned
14365 struct user_namespace *user_ns;
14368 + vxdprintk(VXD_CBIT(space, 4),
14369 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14370 + unshare_flags, current->nsproxy);
14372 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14373 CLONE_NEWNET | CLONE_NEWPID)))
14376 user_ns = new_cred ? new_cred->user_ns : current_user_ns();
14377 - if (!ns_capable(user_ns, CAP_SYS_ADMIN))
14378 + if (!vx_ns_can_unshare(user_ns, CAP_SYS_ADMIN, unshare_flags))
14381 *new_nsp = create_new_namespaces(unshare_flags, current, user_ns,
14382 diff -NurpP --minimal linux-3.10.15/kernel/pid.c linux-3.10.15-vs2.3.6.6/kernel/pid.c
14383 --- linux-3.10.15/kernel/pid.c 2013-10-09 17:35:23.000000000 +0000
14384 +++ linux-3.10.15-vs2.3.6.6/kernel/pid.c 2013-10-09 17:37:22.000000000 +0000
14386 #include <linux/syscalls.h>
14387 #include <linux/proc_ns.h>
14388 #include <linux/proc_fs.h>
14389 +#include <linux/vs_pid.h>
14391 #define pid_hashfn(nr, ns) \
14392 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14393 @@ -367,7 +368,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14395 struct pid *find_vpid(int nr)
14397 - return find_pid_ns(nr, task_active_pid_ns(current));
14398 + return find_pid_ns(vx_rmap_pid(nr), task_active_pid_ns(current));
14400 EXPORT_SYMBOL_GPL(find_vpid);
14402 @@ -427,6 +428,9 @@ void transfer_pid(struct task_struct *ol
14403 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14405 struct task_struct *result = NULL;
14407 + if (type == PIDTYPE_REALPID)
14408 + type = PIDTYPE_PID;
14410 struct hlist_node *first;
14411 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
14412 @@ -446,7 +450,7 @@ struct task_struct *find_task_by_pid_ns(
14413 rcu_lockdep_assert(rcu_read_lock_held(),
14414 "find_task_by_pid_ns() needs rcu_read_lock()"
14416 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
14417 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
14420 struct task_struct *find_task_by_vpid(pid_t vnr)
14421 @@ -490,7 +494,7 @@ struct pid *find_get_pid(pid_t nr)
14423 EXPORT_SYMBOL_GPL(find_get_pid);
14425 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14426 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
14430 @@ -504,6 +508,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
14432 EXPORT_SYMBOL_GPL(pid_nr_ns);
14434 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14436 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
14439 pid_t pid_vnr(struct pid *pid)
14441 return pid_nr_ns(pid, task_active_pid_ns(current));
14442 diff -NurpP --minimal linux-3.10.15/kernel/pid_namespace.c linux-3.10.15-vs2.3.6.6/kernel/pid_namespace.c
14443 --- linux-3.10.15/kernel/pid_namespace.c 2013-07-14 17:01:35.000000000 +0000
14444 +++ linux-3.10.15-vs2.3.6.6/kernel/pid_namespace.c 2013-08-22 20:30:00.000000000 +0000
14446 #include <linux/proc_ns.h>
14447 #include <linux/reboot.h>
14448 #include <linux/export.h>
14449 +#include <linux/vserver/global.h>
14453 @@ -110,6 +111,7 @@ static struct pid_namespace *create_pid_
14456 kref_init(&ns->kref);
14457 + atomic_inc(&vs_global_pid_ns);
14459 ns->parent = get_pid_ns(parent_pid_ns);
14460 ns->user_ns = get_user_ns(user_ns);
14461 @@ -140,6 +142,7 @@ static void destroy_pid_namespace(struct
14462 for (i = 0; i < PIDMAP_ENTRIES; i++)
14463 kfree(ns->pidmap[i].page);
14464 put_user_ns(ns->user_ns);
14465 + atomic_dec(&vs_global_pid_ns);
14466 kmem_cache_free(pid_ns_cachep, ns);
14469 diff -NurpP --minimal linux-3.10.15/kernel/posix-timers.c linux-3.10.15-vs2.3.6.6/kernel/posix-timers.c
14470 --- linux-3.10.15/kernel/posix-timers.c 2013-07-14 17:01:35.000000000 +0000
14471 +++ linux-3.10.15-vs2.3.6.6/kernel/posix-timers.c 2013-08-22 21:10:34.000000000 +0000
14473 #include <linux/workqueue.h>
14474 #include <linux/export.h>
14475 #include <linux/hashtable.h>
14476 +#include <linux/vs_context.h>
14479 * Management arrays for POSIX timers. Timers are now kept in static hash table
14480 @@ -398,6 +399,7 @@ int posix_timer_event(struct k_itimer *t
14482 struct task_struct *task;
14483 int shared, ret = -1;
14486 * FIXME: if ->sigq is queued we can race with
14487 * dequeue_signal()->do_schedule_next_timer().
14488 @@ -414,10 +416,18 @@ int posix_timer_event(struct k_itimer *t
14490 task = pid_task(timr->it_pid, PIDTYPE_PID);
14492 + struct vx_info_save vxis;
14493 + struct vx_info *vxi;
14495 + vxi = get_vx_info(task->vx_info);
14496 + enter_vx_info(vxi, &vxis);
14497 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
14498 ret = send_sigqueue(timr->sigq, task, shared);
14499 + leave_vx_info(&vxis);
14500 + put_vx_info(vxi);
14504 /* If we failed to send the signal the timer stops. */
14507 diff -NurpP --minimal linux-3.10.15/kernel/printk.c linux-3.10.15-vs2.3.6.6/kernel/printk.c
14508 --- linux-3.10.15/kernel/printk.c 2013-10-09 17:35:23.000000000 +0000
14509 +++ linux-3.10.15-vs2.3.6.6/kernel/printk.c 2013-08-22 21:14:57.000000000 +0000
14511 #include <linux/poll.h>
14512 #include <linux/irq_work.h>
14513 #include <linux/utsname.h>
14514 +#include <linux/vs_cvirt.h>
14516 #include <asm/uaccess.h>
14518 @@ -391,7 +392,7 @@ static int check_syslog_permissions(int
14521 if (syslog_action_restricted(type)) {
14522 - if (capable(CAP_SYSLOG))
14523 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
14526 * For historical reasons, accept CAP_SYS_ADMIN too, with
14527 @@ -1140,12 +1141,9 @@ int do_syslog(int type, char __user *buf
14532 - case SYSLOG_ACTION_CLOSE: /* Close log */
14534 - case SYSLOG_ACTION_OPEN: /* Open log */
14536 - case SYSLOG_ACTION_READ: /* Read from log */
14537 + if ((type == SYSLOG_ACTION_READ) ||
14538 + (type == SYSLOG_ACTION_READ_ALL) ||
14539 + (type == SYSLOG_ACTION_READ_CLEAR)) {
14541 if (!buf || len < 0)
14543 @@ -1156,6 +1154,16 @@ int do_syslog(int type, char __user *buf
14548 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14549 + return vx_do_syslog(type, buf, len);
14552 + case SYSLOG_ACTION_CLOSE: /* Close log */
14554 + case SYSLOG_ACTION_OPEN: /* Open log */
14556 + case SYSLOG_ACTION_READ: /* Read from log */
14557 error = wait_event_interruptible(log_wait,
14558 syslog_seq != log_next_seq);
14560 @@ -1168,16 +1176,6 @@ int do_syslog(int type, char __user *buf
14562 /* Read last kernel messages */
14563 case SYSLOG_ACTION_READ_ALL:
14565 - if (!buf || len < 0)
14570 - if (!access_ok(VERIFY_WRITE, buf, len)) {
14574 error = syslog_print_all(buf, len, clear);
14576 /* Clear ring buffer */
14577 diff -NurpP --minimal linux-3.10.15/kernel/ptrace.c linux-3.10.15-vs2.3.6.6/kernel/ptrace.c
14578 --- linux-3.10.15/kernel/ptrace.c 2013-07-14 17:01:35.000000000 +0000
14579 +++ linux-3.10.15-vs2.3.6.6/kernel/ptrace.c 2013-08-22 20:30:00.000000000 +0000
14581 #include <linux/syscalls.h>
14582 #include <linux/uaccess.h>
14583 #include <linux/regset.h>
14584 +#include <linux/vs_context.h>
14585 #include <linux/hw_breakpoint.h>
14586 #include <linux/cn_proc.h>
14587 #include <linux/compat.h>
14588 @@ -263,6 +264,11 @@ ok:
14592 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
14594 + if (!vx_check(task->xid, VS_IDENT) &&
14595 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
14597 return security_ptrace_access_check(task, mode);
14600 diff -NurpP --minimal linux-3.10.15/kernel/sched/core.c linux-3.10.15-vs2.3.6.6/kernel/sched/core.c
14601 --- linux-3.10.15/kernel/sched/core.c 2013-07-14 17:01:35.000000000 +0000
14602 +++ linux-3.10.15-vs2.3.6.6/kernel/sched/core.c 2013-08-22 20:30:00.000000000 +0000
14604 #include <linux/init_task.h>
14605 #include <linux/binfmts.h>
14606 #include <linux/context_tracking.h>
14607 +#include <linux/vs_sched.h>
14608 +#include <linux/vs_cvirt.h>
14610 #include <asm/switch_to.h>
14611 #include <asm/tlb.h>
14612 @@ -2139,9 +2141,17 @@ EXPORT_SYMBOL(avenrun); /* should be rem
14614 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
14616 - loads[0] = (avenrun[0] + offset) << shift;
14617 - loads[1] = (avenrun[1] + offset) << shift;
14618 - loads[2] = (avenrun[2] + offset) << shift;
14619 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
14620 + struct vx_info *vxi = current_vx_info();
14622 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
14623 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
14624 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
14626 + loads[0] = (avenrun[0] + offset) << shift;
14627 + loads[1] = (avenrun[1] + offset) << shift;
14628 + loads[2] = (avenrun[2] + offset) << shift;
14632 static long calc_load_fold_active(struct rq *this_rq)
14633 @@ -3738,7 +3748,7 @@ SYSCALL_DEFINE1(nice, int, increment)
14636 if (increment < 0 && !can_nice(current, nice))
14638 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
14640 retval = security_task_setnice(current, nice);
14642 diff -NurpP --minimal linux-3.10.15/kernel/sched/cputime.c linux-3.10.15-vs2.3.6.6/kernel/sched/cputime.c
14643 --- linux-3.10.15/kernel/sched/cputime.c 2013-10-09 17:35:23.000000000 +0000
14644 +++ linux-3.10.15-vs2.3.6.6/kernel/sched/cputime.c 2013-10-09 17:37:22.000000000 +0000
14646 #include <linux/kernel_stat.h>
14647 #include <linux/static_key.h>
14648 #include <linux/context_tracking.h>
14649 +#include <linux/vs_sched.h>
14653 @@ -135,14 +136,17 @@ static inline void task_group_account_fi
14654 void account_user_time(struct task_struct *p, cputime_t cputime,
14655 cputime_t cputime_scaled)
14657 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14658 + int nice = (TASK_NICE(p) > 0);
14661 /* Add user time to process. */
14662 p->utime += cputime;
14663 p->utimescaled += cputime_scaled;
14664 + vx_account_user(vxi, cputime, nice);
14665 account_group_user_time(p, cputime);
14667 - index = (TASK_NICE(p) > 0) ? CPUTIME_NICE : CPUTIME_USER;
14668 + index = (nice) ? CPUTIME_NICE : CPUTIME_USER;
14670 /* Add user time to cpustat. */
14671 task_group_account_field(p, index, (__force u64) cputime);
14672 @@ -189,9 +193,12 @@ static inline
14673 void __account_system_time(struct task_struct *p, cputime_t cputime,
14674 cputime_t cputime_scaled, int index)
14676 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14678 /* Add system time to process. */
14679 p->stime += cputime;
14680 p->stimescaled += cputime_scaled;
14681 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
14682 account_group_system_time(p, cputime);
14684 /* Add system time to cpustat. */
14685 diff -NurpP --minimal linux-3.10.15/kernel/sched/fair.c linux-3.10.15-vs2.3.6.6/kernel/sched/fair.c
14686 --- linux-3.10.15/kernel/sched/fair.c 2013-10-09 17:35:23.000000000 +0000
14687 +++ linux-3.10.15-vs2.3.6.6/kernel/sched/fair.c 2013-10-09 17:37:22.000000000 +0000
14689 #include <linux/mempolicy.h>
14690 #include <linux/migrate.h>
14691 #include <linux/task_work.h>
14692 +#include <linux/vs_cvirt.h>
14694 #include <trace/events/sched.h>
14696 @@ -1736,6 +1737,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
14697 __enqueue_entity(cfs_rq, se);
14700 + if (entity_is_task(se))
14701 + vx_activate_task(task_of(se));
14702 if (cfs_rq->nr_running == 1) {
14703 list_add_leaf_cfs_rq(cfs_rq);
14704 check_enqueue_throttle(cfs_rq);
14705 @@ -1817,6 +1820,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
14706 if (se != cfs_rq->curr)
14707 __dequeue_entity(cfs_rq, se);
14709 + if (entity_is_task(se))
14710 + vx_deactivate_task(task_of(se));
14711 account_entity_dequeue(cfs_rq, se);
14714 diff -NurpP --minimal linux-3.10.15/kernel/signal.c linux-3.10.15-vs2.3.6.6/kernel/signal.c
14715 --- linux-3.10.15/kernel/signal.c 2013-07-14 17:01:35.000000000 +0000
14716 +++ linux-3.10.15-vs2.3.6.6/kernel/signal.c 2013-08-22 21:13:50.000000000 +0000
14718 #include <linux/uprobes.h>
14719 #include <linux/compat.h>
14720 #include <linux/cn_proc.h>
14721 +#include <linux/vs_context.h>
14722 +#include <linux/vs_pid.h>
14723 #define CREATE_TRACE_POINTS
14724 #include <trace/events/signal.h>
14726 @@ -790,9 +792,18 @@ static int check_kill_permission(int sig
14730 + vxdprintk(VXD_CBIT(misc, 7),
14731 + "check_kill_permission(%d,%p,%p[#%u,%u])",
14732 + sig, info, t, vx_task_xid(t), t->pid);
14734 if (!valid_signal(sig))
14737 +/* FIXME: needed? if so, why?
14738 + if ((info != SEND_SIG_NOINFO) &&
14739 + (is_si_special(info) || !si_fromuser(info)))
14742 if (!si_fromuser(info))
14745 @@ -816,6 +827,20 @@ static int check_kill_permission(int sig
14750 + if (t->pid == 1 && current->xid)
14754 + /* FIXME: we shouldn't return ESRCH ever, to avoid
14755 + loops, maybe ENOENT or EACCES? */
14756 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
14757 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
14758 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
14759 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
14763 return security_task_kill(t, info, sig, 0);
14766 @@ -1353,7 +1378,7 @@ int kill_pid_info(int sig, struct siginf
14769 p = pid_task(pid, PIDTYPE_PID);
14771 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
14772 error = group_send_sig_info(sig, info, p);
14773 if (unlikely(error == -ESRCH))
14775 @@ -1401,7 +1426,7 @@ int kill_pid_info_as_cred(int sig, struc
14778 p = pid_task(pid, PIDTYPE_PID);
14780 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
14784 @@ -1453,8 +1478,10 @@ static int kill_something_info(int sig,
14785 struct task_struct * p;
14787 for_each_process(p) {
14788 - if (task_pid_vnr(p) > 1 &&
14789 - !same_thread_group(p, current)) {
14790 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
14791 + task_pid_vnr(p) > 1 &&
14792 + !same_thread_group(p, current) &&
14793 + !vx_current_initpid(p->pid)) {
14794 int err = group_send_sig_info(sig, info, p);
14797 @@ -2308,6 +2335,11 @@ relock:
14798 !sig_kernel_only(signr))
14801 + /* virtual init is protected against user signals */
14802 + if ((info->si_code == SI_USER) &&
14803 + vx_current_initpid(current->pid))
14806 if (sig_kernel_stop(signr)) {
14808 * The default action is to stop all threads in
14809 diff -NurpP --minimal linux-3.10.15/kernel/softirq.c linux-3.10.15-vs2.3.6.6/kernel/softirq.c
14810 --- linux-3.10.15/kernel/softirq.c 2013-07-14 17:01:35.000000000 +0000
14811 +++ linux-3.10.15-vs2.3.6.6/kernel/softirq.c 2013-08-22 20:30:00.000000000 +0000
14813 #include <linux/smp.h>
14814 #include <linux/smpboot.h>
14815 #include <linux/tick.h>
14816 +#include <linux/vs_context.h>
14818 #define CREATE_TRACE_POINTS
14819 #include <trace/events/irq.h>
14820 diff -NurpP --minimal linux-3.10.15/kernel/sys.c linux-3.10.15-vs2.3.6.6/kernel/sys.c
14821 --- linux-3.10.15/kernel/sys.c 2013-07-14 17:01:35.000000000 +0000
14822 +++ linux-3.10.15-vs2.3.6.6/kernel/sys.c 2013-08-22 20:30:00.000000000 +0000
14824 #include <linux/cred.h>
14826 #include <linux/kmsg_dump.h>
14827 +#include <linux/vs_pid.h>
14828 /* Move somewhere else to avoid recompiling? */
14829 #include <generated/utsrelease.h>
14831 @@ -160,7 +161,10 @@ static int set_one_prio(struct task_stru
14834 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
14836 + if (vx_flags(VXF_IGNEG_NICE, 0))
14842 no_nice = security_task_setnice(p, niceval);
14843 @@ -211,6 +215,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
14845 pgrp = task_pgrp(current);
14846 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
14847 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
14849 error = set_one_prio(p, niceval, error);
14850 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
14852 @@ -276,6 +282,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
14854 pgrp = task_pgrp(current);
14855 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
14856 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
14858 niceval = 20 - task_nice(p);
14859 if (niceval > retval)
14861 @@ -452,6 +460,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
14863 static DEFINE_MUTEX(reboot_mutex);
14865 +long vs_reboot(unsigned int, void __user *);
14868 * Reboot system call: for obvious reasons only root may call it,
14869 * and even root needs to set up some magic numbers in the registers
14870 @@ -494,6 +504,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
14871 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
14872 cmd = LINUX_REBOOT_CMD_HALT;
14874 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14875 + return vs_reboot(cmd, arg);
14877 mutex_lock(&reboot_mutex);
14879 case LINUX_REBOOT_CMD_RESTART:
14880 @@ -1462,7 +1475,8 @@ SYSCALL_DEFINE2(sethostname, char __user
14882 char tmp[__NEW_UTS_LEN];
14884 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
14885 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
14886 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
14889 if (len < 0 || len > __NEW_UTS_LEN)
14890 @@ -1513,7 +1527,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
14892 char tmp[__NEW_UTS_LEN];
14894 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
14895 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
14896 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
14898 if (len < 0 || len > __NEW_UTS_LEN)
14900 @@ -1632,7 +1647,7 @@ int do_prlimit(struct task_struct *tsk,
14901 /* Keep the capable check against init_user_ns until
14902 cgroups can contain all limits */
14903 if (new_rlim->rlim_max > rlim->rlim_max &&
14904 - !capable(CAP_SYS_RESOURCE))
14905 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
14908 retval = security_task_setrlimit(tsk->group_leader,
14909 @@ -1685,7 +1700,8 @@ static int check_prlimit_permission(stru
14910 gid_eq(cred->gid, tcred->sgid) &&
14911 gid_eq(cred->gid, tcred->gid))
14913 - if (ns_capable(tcred->user_ns, CAP_SYS_RESOURCE))
14914 + if (vx_ns_capable(tcred->user_ns,
14915 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
14919 diff -NurpP --minimal linux-3.10.15/kernel/sysctl.c linux-3.10.15-vs2.3.6.6/kernel/sysctl.c
14920 --- linux-3.10.15/kernel/sysctl.c 2013-07-14 17:01:35.000000000 +0000
14921 +++ linux-3.10.15-vs2.3.6.6/kernel/sysctl.c 2013-08-22 20:30:00.000000000 +0000
14923 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
14924 #include <linux/lockdep.h>
14926 +extern char vshelper_path[];
14927 #ifdef CONFIG_CHR_DEV_SG
14928 #include <scsi/sg.h>
14930 @@ -628,6 +629,13 @@ static struct ctl_table kern_table[] = {
14932 .proc_handler = proc_dostring,
14935 + .procname = "vshelper",
14936 + .data = &vshelper_path,
14939 + .proc_handler = &proc_dostring,
14942 #ifdef CONFIG_CHR_DEV_SG
14944 diff -NurpP --minimal linux-3.10.15/kernel/sysctl_binary.c linux-3.10.15-vs2.3.6.6/kernel/sysctl_binary.c
14945 --- linux-3.10.15/kernel/sysctl_binary.c 2013-07-14 17:01:35.000000000 +0000
14946 +++ linux-3.10.15-vs2.3.6.6/kernel/sysctl_binary.c 2013-08-22 20:30:00.000000000 +0000
14947 @@ -74,6 +74,7 @@ static const struct bin_table bin_kern_t
14949 { CTL_INT, KERN_PANIC, "panic" },
14950 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
14951 + { CTL_STR, KERN_VSHELPER, "vshelper" },
14953 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
14954 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
14955 diff -NurpP --minimal linux-3.10.15/kernel/time/timekeeping.c linux-3.10.15-vs2.3.6.6/kernel/time/timekeeping.c
14956 --- linux-3.10.15/kernel/time/timekeeping.c 2013-10-09 17:35:23.000000000 +0000
14957 +++ linux-3.10.15-vs2.3.6.6/kernel/time/timekeeping.c 2013-10-09 17:37:22.000000000 +0000
14959 #include <linux/tick.h>
14960 #include <linux/stop_machine.h>
14961 #include <linux/pvclock_gtod.h>
14962 +#include <linux/vs_time.h>
14964 #include "tick-internal.h"
14965 #include "ntp_internal.h"
14966 @@ -693,6 +694,7 @@ void getrawmonotonic(struct timespec *ts
14967 } while (read_seqcount_retry(&timekeeper_seq, seq));
14969 timespec_add_ns(ts, nsecs);
14970 + vx_adjust_timespec(ts);
14972 EXPORT_SYMBOL(getrawmonotonic);
14974 diff -NurpP --minimal linux-3.10.15/kernel/time.c linux-3.10.15-vs2.3.6.6/kernel/time.c
14975 --- linux-3.10.15/kernel/time.c 2013-07-14 17:01:35.000000000 +0000
14976 +++ linux-3.10.15-vs2.3.6.6/kernel/time.c 2013-08-22 20:30:00.000000000 +0000
14978 #include <linux/fs.h>
14979 #include <linux/math64.h>
14980 #include <linux/ptrace.h>
14981 +#include <linux/vs_time.h>
14983 #include <asm/uaccess.h>
14984 #include <asm/unistd.h>
14985 @@ -92,7 +93,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
14989 - do_settimeofday(&tv);
14990 + vx_settimeofday(&tv);
14994 @@ -181,7 +182,7 @@ int do_sys_settimeofday(const struct tim
14998 - return do_settimeofday(tv);
14999 + return vx_settimeofday(tv);
15003 diff -NurpP --minimal linux-3.10.15/kernel/timer.c linux-3.10.15-vs2.3.6.6/kernel/timer.c
15004 --- linux-3.10.15/kernel/timer.c 2013-10-09 17:35:23.000000000 +0000
15005 +++ linux-3.10.15-vs2.3.6.6/kernel/timer.c 2013-08-22 21:17:56.000000000 +0000
15007 #include <linux/sched/sysctl.h>
15008 #include <linux/slab.h>
15009 #include <linux/compat.h>
15010 +#include <linux/vs_base.h>
15011 +#include <linux/vs_cvirt.h>
15012 +#include <linux/vs_pid.h>
15013 +#include <linux/vserver/sched.h>
15015 #include <asm/uaccess.h>
15016 #include <asm/unistd.h>
15017 diff -NurpP --minimal linux-3.10.15/kernel/user_namespace.c linux-3.10.15-vs2.3.6.6/kernel/user_namespace.c
15018 --- linux-3.10.15/kernel/user_namespace.c 2013-10-09 17:35:23.000000000 +0000
15019 +++ linux-3.10.15-vs2.3.6.6/kernel/user_namespace.c 2013-08-22 20:30:00.000000000 +0000
15021 #include <linux/ctype.h>
15022 #include <linux/projid.h>
15023 #include <linux/fs_struct.h>
15024 +#include <linux/vserver/global.h>
15026 static struct kmem_cache *user_ns_cachep __read_mostly;
15028 @@ -94,6 +95,7 @@ int create_user_ns(struct cred *new)
15030 atomic_set(&ns->count, 1);
15031 /* Leave the new->user_ns reference with the new user namespace. */
15032 + atomic_inc(&vs_global_user_ns);
15033 ns->parent = parent_ns;
15034 ns->level = parent_ns->level + 1;
15036 @@ -844,6 +846,8 @@ static void *userns_get(struct task_stru
15038 static void userns_put(void *ns)
15040 + /* FIXME: maybe move into destroyer? */
15041 + atomic_dec(&vs_global_user_ns);
15045 diff -NurpP --minimal linux-3.10.15/kernel/utsname.c linux-3.10.15-vs2.3.6.6/kernel/utsname.c
15046 --- linux-3.10.15/kernel/utsname.c 2013-07-14 17:01:35.000000000 +0000
15047 +++ linux-3.10.15-vs2.3.6.6/kernel/utsname.c 2013-08-22 21:03:08.000000000 +0000
15048 @@ -16,14 +16,17 @@
15049 #include <linux/slab.h>
15050 #include <linux/user_namespace.h>
15051 #include <linux/proc_ns.h>
15052 +#include <linux/vserver/global.h>
15054 static struct uts_namespace *create_uts_ns(void)
15056 struct uts_namespace *uts_ns;
15058 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15060 - kref_init(&uts_ns->kref);
15062 + kref_init(&uts_ns->kref);
15063 + atomic_inc(&vs_global_uts_ns);
15068 @@ -85,6 +88,7 @@ void free_uts_ns(struct kref *kref)
15069 ns = container_of(kref, struct uts_namespace, kref);
15070 put_user_ns(ns->user_ns);
15071 proc_free_inum(ns->proc_inum);
15072 + atomic_dec(&vs_global_uts_ns);
15076 diff -NurpP --minimal linux-3.10.15/kernel/vserver/Kconfig linux-3.10.15-vs2.3.6.6/kernel/vserver/Kconfig
15077 --- linux-3.10.15/kernel/vserver/Kconfig 1970-01-01 00:00:00.000000000 +0000
15078 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/Kconfig 2013-08-22 20:30:00.000000000 +0000
15081 +# Linux VServer configuration
15084 +menu "Linux VServer"
15086 +config VSERVER_AUTO_LBACK
15087 + bool "Automatically Assign Loopback IP"
15090 + Automatically assign a guest specific loopback
15091 + IP and add it to the kernel network stack on
15094 +config VSERVER_AUTO_SINGLE
15095 + bool "Automatic Single IP Special Casing"
15096 + depends on EXPERIMENTAL
15099 + This allows network contexts with a single IP to
15100 + automatically remap 0.0.0.0 bindings to that IP,
15101 + avoiding further network checks and improving
15104 + (note: such guests do not allow to change the ip
15105 + on the fly and do not show loopback addresses)
15107 +config VSERVER_COWBL
15108 + bool "Enable COW Immutable Link Breaking"
15111 + This enables the COW (Copy-On-Write) link break code.
15112 + It allows you to treat unified files like normal files
15113 + when writing to them (which will implicitely break the
15114 + link and create a copy of the unified file)
15116 +config VSERVER_VTIME
15117 + bool "Enable Virtualized Guest Time"
15118 + depends on EXPERIMENTAL
15121 + This enables per guest time offsets to allow for
15122 + adjusting the system clock individually per guest.
15123 + this adds some overhead to the time functions and
15124 + therefore should not be enabled without good reason.
15126 +config VSERVER_DEVICE
15127 + bool "Enable Guest Device Mapping"
15128 + depends on EXPERIMENTAL
15131 + This enables generic device remapping.
15133 +config VSERVER_PROC_SECURE
15134 + bool "Enable Proc Security"
15135 + depends on PROC_FS
15138 + This configures ProcFS security to initially hide
15139 + non-process entries for all contexts except the main and
15140 + spectator context (i.e. for all guests), which is a secure
15143 + (note: on 1.2x the entries were visible by default)
15146 + prompt "Persistent Inode Tagging"
15147 + default TAGGING_ID24
15149 + This adds persistent context information to filesystems
15150 + mounted with the tagxid option. Tagging is a requirement
15151 + for per-context disk limits and per-context quota.
15154 +config TAGGING_NONE
15157 + do not store per-context information in inodes.
15159 +config TAGGING_UID16
15160 + bool "UID16/GID32"
15162 + reduces UID to 16 bit, but leaves GID at 32 bit.
15164 +config TAGGING_GID16
15165 + bool "UID32/GID16"
15167 + reduces GID to 16 bit, but leaves UID at 32 bit.
15169 +config TAGGING_ID24
15170 + bool "UID24/GID24"
15172 + uses the upper 8bit from UID and GID for XID tagging
15173 + which leaves 24bit for UID/GID each, which should be
15174 + more than sufficient for normal use.
15176 +config TAGGING_INTERN
15177 + bool "UID32/GID32"
15179 + this uses otherwise reserved inode fields in the on
15180 + disk representation, which limits the use to a few
15181 + filesystems (currently ext2 and ext3)
15186 + bool "Tag NFSD User Auth and Files"
15189 + Enable this if you do want the in-kernel NFS
15190 + Server to use the tagging specified above.
15191 + (will require patched clients too)
15193 +config VSERVER_PRIVACY
15194 + bool "Honor Privacy Aspects of Guests"
15197 + When enabled, most context checks will disallow
15198 + access to structures assigned to a specific context,
15199 + like ptys or loop devices.
15201 +config VSERVER_CONTEXTS
15202 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15204 + default "768" if 64BIT
15207 + This setting will optimize certain data structures
15208 + and memory allocations according to the expected
15211 + note: this is not a strict upper limit.
15213 +config VSERVER_WARN
15214 + bool "VServer Warnings"
15217 + This enables various runtime warnings, which will
15218 + notify about potential manipulation attempts or
15219 + resource shortage. It is generally considered to
15220 + be a good idea to have that enabled.
15222 +config VSERVER_WARN_DEVPTS
15223 + bool "VServer DevPTS Warnings"
15224 + depends on VSERVER_WARN
15227 + This enables DevPTS related warnings, issued when a
15228 + process inside a context tries to lookup or access
15229 + a dynamic pts from the host or a different context.
15231 +config VSERVER_DEBUG
15232 + bool "VServer Debugging Code"
15235 + Set this to yes if you want to be able to activate
15236 + debugging output at runtime. It adds a very small
15237 + overhead to all vserver related functions and
15238 + increases the kernel size by about 20k.
15240 +config VSERVER_HISTORY
15241 + bool "VServer History Tracing"
15242 + depends on VSERVER_DEBUG
15245 + Set this to yes if you want to record the history of
15246 + linux-vserver activities, so they can be replayed in
15247 + the event of a kernel panic or oops.
15249 +config VSERVER_HISTORY_SIZE
15250 + int "Per-CPU History Size (32-65536)"
15251 + depends on VSERVER_HISTORY
15255 + This allows you to specify the number of entries in
15256 + the per-CPU history buffer.
15258 +config VSERVER_EXTRA_MNT_CHECK
15259 + bool "Extra Checks for Reachability"
15262 + Set this to yes if you want to do extra checks for
15263 + vfsmount reachability in the proc filesystem code.
15264 + This shouldn't be required on any setup utilizing
15268 + prompt "Quotes used in debug and warn messages"
15269 + default QUOTES_ISO8859
15271 +config QUOTES_ISO8859
15272 + bool "Extended ASCII (ISO 8859) angle quotes"
15274 + This uses the extended ASCII characters \xbb
15275 + and \xab for quoting file and process names.
15277 +config QUOTES_UTF8
15278 + bool "UTF-8 angle quotes"
15280 + This uses the the UTF-8 sequences for angle
15281 + quotes to quote file and process names.
15283 +config QUOTES_ASCII
15284 + bool "ASCII single quotes"
15286 + This uses the ASCII single quote character
15287 + (\x27) to quote file and process names.
15297 + select NAMESPACES
15303 +config VSERVER_SECURITY
15305 + depends on SECURITY
15307 + select SECURITY_CAPABILITIES
15309 +config VSERVER_DISABLED
15313 diff -NurpP --minimal linux-3.10.15/kernel/vserver/Makefile linux-3.10.15-vs2.3.6.6/kernel/vserver/Makefile
15314 --- linux-3.10.15/kernel/vserver/Makefile 1970-01-01 00:00:00.000000000 +0000
15315 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/Makefile 2013-08-22 20:30:00.000000000 +0000
15318 +# Makefile for the Linux vserver routines.
15322 +obj-y += vserver.o
15324 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15325 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15328 +vserver-$(CONFIG_INET) += inet.o
15329 +vserver-$(CONFIG_PROC_FS) += proc.o
15330 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15331 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15332 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15333 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
15335 diff -NurpP --minimal linux-3.10.15/kernel/vserver/cacct.c linux-3.10.15-vs2.3.6.6/kernel/vserver/cacct.c
15336 --- linux-3.10.15/kernel/vserver/cacct.c 1970-01-01 00:00:00.000000000 +0000
15337 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/cacct.c 2013-08-22 20:30:00.000000000 +0000
15340 + * linux/kernel/vserver/cacct.c
15342 + * Virtual Server: Context Accounting
15344 + * Copyright (C) 2006-2007 Herbert Pötzl
15346 + * V0.01 added accounting stats
15350 +#include <linux/types.h>
15351 +#include <linux/vs_context.h>
15352 +#include <linux/vserver/cacct_cmd.h>
15353 +#include <linux/vserver/cacct_int.h>
15355 +#include <asm/errno.h>
15356 +#include <asm/uaccess.h>
15359 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15361 + struct vcmd_sock_stat_v0 vc_data;
15364 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15367 + field = vc_data.field;
15368 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15371 + for (j = 0; j < 3; j++) {
15372 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15373 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15376 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15381 diff -NurpP --minimal linux-3.10.15/kernel/vserver/cacct_init.h linux-3.10.15-vs2.3.6.6/kernel/vserver/cacct_init.h
15382 --- linux-3.10.15/kernel/vserver/cacct_init.h 1970-01-01 00:00:00.000000000 +0000
15383 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/cacct_init.h 2013-08-22 20:30:00.000000000 +0000
15387 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
15392 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15393 + for (j = 0; j < 3; j++) {
15394 + atomic_long_set(&cacct->sock[i][j].count, 0);
15395 + atomic_long_set(&cacct->sock[i][j].total, 0);
15398 + for (i = 0; i < 8; i++)
15399 + atomic_set(&cacct->slab[i], 0);
15400 + for (i = 0; i < 5; i++)
15401 + for (j = 0; j < 4; j++)
15402 + atomic_set(&cacct->page[i][j], 0);
15405 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
15410 diff -NurpP --minimal linux-3.10.15/kernel/vserver/cacct_proc.h linux-3.10.15-vs2.3.6.6/kernel/vserver/cacct_proc.h
15411 --- linux-3.10.15/kernel/vserver/cacct_proc.h 1970-01-01 00:00:00.000000000 +0000
15412 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/cacct_proc.h 2013-08-22 20:30:00.000000000 +0000
15414 +#ifndef _VX_CACCT_PROC_H
15415 +#define _VX_CACCT_PROC_H
15417 +#include <linux/vserver/cacct_int.h>
15420 +#define VX_SOCKA_TOP \
15421 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
15423 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
15425 + int i, j, length = 0;
15426 + static char *type[VXA_SOCK_SIZE] = {
15427 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
15430 + length += sprintf(buffer + length, VX_SOCKA_TOP);
15431 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15432 + length += sprintf(buffer + length, "%s:", type[i]);
15433 + for (j = 0; j < 3; j++) {
15434 + length += sprintf(buffer + length,
15435 + "\t%10lu/%-10lu",
15436 + vx_sock_count(cacct, i, j),
15437 + vx_sock_total(cacct, i, j));
15439 + buffer[length++] = '\n';
15442 + length += sprintf(buffer + length, "\n");
15443 + length += sprintf(buffer + length,
15444 + "slab:\t %8u %8u %8u %8u\n",
15445 + atomic_read(&cacct->slab[1]),
15446 + atomic_read(&cacct->slab[4]),
15447 + atomic_read(&cacct->slab[0]),
15448 + atomic_read(&cacct->slab[2]));
15450 + length += sprintf(buffer + length, "\n");
15451 + for (i = 0; i < 5; i++) {
15452 + length += sprintf(buffer + length,
15453 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
15454 + atomic_read(&cacct->page[i][0]),
15455 + atomic_read(&cacct->page[i][1]),
15456 + atomic_read(&cacct->page[i][2]),
15457 + atomic_read(&cacct->page[i][3]),
15458 + atomic_read(&cacct->page[i][4]),
15459 + atomic_read(&cacct->page[i][5]),
15460 + atomic_read(&cacct->page[i][6]),
15461 + atomic_read(&cacct->page[i][7]));
15466 +#endif /* _VX_CACCT_PROC_H */
15467 diff -NurpP --minimal linux-3.10.15/kernel/vserver/context.c linux-3.10.15-vs2.3.6.6/kernel/vserver/context.c
15468 --- linux-3.10.15/kernel/vserver/context.c 1970-01-01 00:00:00.000000000 +0000
15469 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/context.c 2013-08-22 20:30:00.000000000 +0000
15472 + * linux/kernel/vserver/context.c
15474 + * Virtual Server: Context Support
15476 + * Copyright (C) 2003-2011 Herbert Pötzl
15478 + * V0.01 context helper
15479 + * V0.02 vx_ctx_kill syscall command
15480 + * V0.03 replaced context_info calls
15481 + * V0.04 redesign of struct (de)alloc
15482 + * V0.05 rlimit basic implementation
15483 + * V0.06 task_xid and info commands
15484 + * V0.07 context flags and caps
15485 + * V0.08 switch to RCU based hash
15486 + * V0.09 revert to non RCU for now
15487 + * V0.10 and back to working RCU hash
15488 + * V0.11 and back to locking again
15489 + * V0.12 referenced context store
15490 + * V0.13 separate per cpu data
15491 + * V0.14 changed vcmds to vxi arg
15492 + * V0.15 added context stat
15493 + * V0.16 have __create claim() the vxi
15494 + * V0.17 removed older and legacy stuff
15495 + * V0.18 added user credentials
15496 + * V0.19 added warn mask
15500 +#include <linux/slab.h>
15501 +#include <linux/types.h>
15502 +#include <linux/security.h>
15503 +#include <linux/pid_namespace.h>
15504 +#include <linux/capability.h>
15506 +#include <linux/vserver/context.h>
15507 +#include <linux/vserver/network.h>
15508 +#include <linux/vserver/debug.h>
15509 +#include <linux/vserver/limit.h>
15510 +#include <linux/vserver/limit_int.h>
15511 +#include <linux/vserver/space.h>
15512 +#include <linux/init_task.h>
15513 +#include <linux/fs_struct.h>
15514 +#include <linux/cred.h>
15516 +#include <linux/vs_context.h>
15517 +#include <linux/vs_limit.h>
15518 +#include <linux/vs_pid.h>
15519 +#include <linux/vserver/context_cmd.h>
15521 +#include "cvirt_init.h"
15522 +#include "cacct_init.h"
15523 +#include "limit_init.h"
15524 +#include "sched_init.h"
15527 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
15528 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
15531 +/* now inactive context structures */
15533 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
15535 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
15538 +/* __alloc_vx_info()
15540 + * allocate an initialized vx_info struct
15541 + * doesn't make it visible (hash) */
15543 +static struct vx_info *__alloc_vx_info(vxid_t xid)
15545 + struct vx_info *new = NULL;
15548 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
15550 + /* would this benefit from a slab cache? */
15551 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
15555 + memset(new, 0, sizeof(struct vx_info));
15557 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
15558 + if (!new->ptr_pc)
15561 + new->vx_id = xid;
15562 + INIT_HLIST_NODE(&new->vx_hlist);
15563 + atomic_set(&new->vx_usecnt, 0);
15564 + atomic_set(&new->vx_tasks, 0);
15565 + new->vx_parent = NULL;
15566 + new->vx_state = 0;
15567 + init_waitqueue_head(&new->vx_wait);
15569 + /* prepare reaper */
15570 + get_task_struct(init_pid_ns.child_reaper);
15571 + new->vx_reaper = init_pid_ns.child_reaper;
15572 + new->vx_badness_bias = 0;
15574 + /* rest of init goes here */
15575 + vx_info_init_limit(&new->limit);
15576 + vx_info_init_sched(&new->sched);
15577 + vx_info_init_cvirt(&new->cvirt);
15578 + vx_info_init_cacct(&new->cacct);
15580 + /* per cpu data structures */
15581 + for_each_possible_cpu(cpu) {
15582 + vx_info_init_sched_pc(
15583 + &vx_per_cpu(new, sched_pc, cpu), cpu);
15584 + vx_info_init_cvirt_pc(
15585 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
15588 + new->vx_flags = VXF_INIT_SET;
15589 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
15590 + new->vx_ccaps = 0;
15591 + new->vx_umask = 0;
15592 + new->vx_wmask = 0;
15594 + new->reboot_cmd = 0;
15595 + new->exit_code = 0;
15597 + // preconfig spaces
15598 + for (index = 0; index < VX_SPACES; index++) {
15599 + struct _vx_space *space = &new->space[index];
15602 + spin_lock(&init_fs.lock);
15604 + spin_unlock(&init_fs.lock);
15605 + space->vx_fs = &init_fs;
15607 + /* FIXME: do we want defaults? */
15608 + // space->vx_real_cred = 0;
15609 + // space->vx_cred = 0;
15613 + vxdprintk(VXD_CBIT(xid, 0),
15614 + "alloc_vx_info(%d) = %p", xid, new);
15615 + vxh_alloc_vx_info(new);
15616 + atomic_inc(&vx_global_ctotal);
15625 +/* __dealloc_vx_info()
15627 + * final disposal of vx_info */
15629 +static void __dealloc_vx_info(struct vx_info *vxi)
15631 +#ifdef CONFIG_VSERVER_WARN
15632 + struct vx_info_save vxis;
15635 + vxdprintk(VXD_CBIT(xid, 0),
15636 + "dealloc_vx_info(%p)", vxi);
15637 + vxh_dealloc_vx_info(vxi);
15639 +#ifdef CONFIG_VSERVER_WARN
15640 + enter_vx_info(vxi, &vxis);
15641 + vx_info_exit_limit(&vxi->limit);
15642 + vx_info_exit_sched(&vxi->sched);
15643 + vx_info_exit_cvirt(&vxi->cvirt);
15644 + vx_info_exit_cacct(&vxi->cacct);
15646 + for_each_possible_cpu(cpu) {
15647 + vx_info_exit_sched_pc(
15648 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
15649 + vx_info_exit_cvirt_pc(
15650 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
15652 + leave_vx_info(&vxis);
15656 + vxi->vx_state |= VXS_RELEASED;
15659 + free_percpu(vxi->ptr_pc);
15662 + atomic_dec(&vx_global_ctotal);
15665 +static void __shutdown_vx_info(struct vx_info *vxi)
15667 + struct nsproxy *nsproxy;
15668 + struct fs_struct *fs;
15669 + struct cred *cred;
15674 + vxi->vx_state |= VXS_SHUTDOWN;
15675 + vs_state_change(vxi, VSC_SHUTDOWN);
15677 + for (index = 0; index < VX_SPACES; index++) {
15678 + struct _vx_space *space = &vxi->space[index];
15680 + nsproxy = xchg(&space->vx_nsproxy, NULL);
15682 + put_nsproxy(nsproxy);
15684 + fs = xchg(&space->vx_fs, NULL);
15685 + spin_lock(&fs->lock);
15686 + kill = !--fs->users;
15687 + spin_unlock(&fs->lock);
15689 + free_fs_struct(fs);
15691 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
15693 + abort_creds(cred);
15697 +/* exported stuff */
15699 +void free_vx_info(struct vx_info *vxi)
15701 + unsigned long flags;
15704 + /* check for reference counts first */
15705 + BUG_ON(atomic_read(&vxi->vx_usecnt));
15706 + BUG_ON(atomic_read(&vxi->vx_tasks));
15708 + /* context must not be hashed */
15709 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
15711 + /* context shutdown is mandatory */
15712 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
15714 + /* spaces check */
15715 + for (index = 0; index < VX_SPACES; index++) {
15716 + struct _vx_space *space = &vxi->space[index];
15718 + BUG_ON(space->vx_nsproxy);
15719 + BUG_ON(space->vx_fs);
15720 + // BUG_ON(space->vx_real_cred);
15721 + // BUG_ON(space->vx_cred);
15724 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
15725 + hlist_del(&vxi->vx_hlist);
15726 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
15728 + __dealloc_vx_info(vxi);
15732 +/* hash table for vx_info hash */
15734 +#define VX_HASH_SIZE 13
15736 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
15737 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
15739 +static DEFINE_SPINLOCK(vx_info_hash_lock);
15742 +static inline unsigned int __hashval(vxid_t xid)
15744 + return (xid % VX_HASH_SIZE);
15749 +/* __hash_vx_info()
15751 + * add the vxi to the global hash table
15752 + * requires the hash_lock to be held */
15754 +static inline void __hash_vx_info(struct vx_info *vxi)
15756 + struct hlist_head *head;
15758 + vxd_assert_lock(&vx_info_hash_lock);
15759 + vxdprintk(VXD_CBIT(xid, 4),
15760 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
15761 + vxh_hash_vx_info(vxi);
15763 + /* context must not be hashed */
15764 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
15766 + vxi->vx_state |= VXS_HASHED;
15767 + head = &vx_info_hash[__hashval(vxi->vx_id)];
15768 + hlist_add_head(&vxi->vx_hlist, head);
15769 + atomic_inc(&vx_global_cactive);
15772 +/* __unhash_vx_info()
15774 + * remove the vxi from the global hash table
15775 + * requires the hash_lock to be held */
15777 +static inline void __unhash_vx_info(struct vx_info *vxi)
15779 + unsigned long flags;
15781 + vxd_assert_lock(&vx_info_hash_lock);
15782 + vxdprintk(VXD_CBIT(xid, 4),
15783 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
15784 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
15785 + vxh_unhash_vx_info(vxi);
15787 + /* context must be hashed */
15788 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
15789 + /* but without tasks */
15790 + BUG_ON(atomic_read(&vxi->vx_tasks));
15792 + vxi->vx_state &= ~VXS_HASHED;
15793 + hlist_del_init(&vxi->vx_hlist);
15794 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
15795 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
15796 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
15797 + atomic_dec(&vx_global_cactive);
15801 +/* __lookup_vx_info()
15803 + * requires the hash_lock to be held
15804 + * doesn't increment the vx_refcnt */
15806 +static inline struct vx_info *__lookup_vx_info(vxid_t xid)
15808 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
15809 + struct hlist_node *pos;
15810 + struct vx_info *vxi;
15812 + vxd_assert_lock(&vx_info_hash_lock);
15813 + hlist_for_each(pos, head) {
15814 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
15816 + if (vxi->vx_id == xid)
15821 + vxdprintk(VXD_CBIT(xid, 0),
15822 + "__lookup_vx_info(#%u): %p[#%u]",
15823 + xid, vxi, vxi ? vxi->vx_id : 0);
15824 + vxh_lookup_vx_info(vxi, xid);
15829 +/* __create_vx_info()
15831 + * create the requested context
15832 + * get(), claim() and hash it */
15834 +static struct vx_info *__create_vx_info(int id)
15836 + struct vx_info *new, *vxi = NULL;
15838 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
15840 + if (!(new = __alloc_vx_info(id)))
15841 + return ERR_PTR(-ENOMEM);
15843 + /* required to make dynamic xids unique */
15844 + spin_lock(&vx_info_hash_lock);
15846 + /* static context requested */
15847 + if ((vxi = __lookup_vx_info(id))) {
15848 + vxdprintk(VXD_CBIT(xid, 0),
15849 + "create_vx_info(%d) = %p (already there)", id, vxi);
15850 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
15851 + vxi = ERR_PTR(-EBUSY);
15853 + vxi = ERR_PTR(-EEXIST);
15856 + /* new context */
15857 + vxdprintk(VXD_CBIT(xid, 0),
15858 + "create_vx_info(%d) = %p (new)", id, new);
15859 + claim_vx_info(new, NULL);
15860 + __hash_vx_info(get_vx_info(new));
15861 + vxi = new, new = NULL;
15864 + spin_unlock(&vx_info_hash_lock);
15865 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
15867 + __dealloc_vx_info(new);
15872 +/* exported stuff */
15875 +void unhash_vx_info(struct vx_info *vxi)
15877 + spin_lock(&vx_info_hash_lock);
15878 + __unhash_vx_info(vxi);
15879 + spin_unlock(&vx_info_hash_lock);
15880 + __shutdown_vx_info(vxi);
15881 + __wakeup_vx_info(vxi);
15885 +/* lookup_vx_info()
15887 + * search for a vx_info and get() it
15888 + * negative id means current */
15890 +struct vx_info *lookup_vx_info(int id)
15892 + struct vx_info *vxi = NULL;
15895 + vxi = get_vx_info(current_vx_info());
15896 + } else if (id > 1) {
15897 + spin_lock(&vx_info_hash_lock);
15898 + vxi = get_vx_info(__lookup_vx_info(id));
15899 + spin_unlock(&vx_info_hash_lock);
15904 +/* xid_is_hashed()
15906 + * verify that xid is still hashed */
15908 +int xid_is_hashed(vxid_t xid)
15912 + spin_lock(&vx_info_hash_lock);
15913 + hashed = (__lookup_vx_info(xid) != NULL);
15914 + spin_unlock(&vx_info_hash_lock);
15918 +#ifdef CONFIG_PROC_FS
15922 + * get a subset of hashed xids for proc
15923 + * assumes size is at least one */
15925 +int get_xid_list(int index, unsigned int *xids, int size)
15927 + int hindex, nr_xids = 0;
15929 + /* only show current and children */
15930 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
15933 + xids[nr_xids] = vx_current_xid();
15937 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
15938 + struct hlist_head *head = &vx_info_hash[hindex];
15939 + struct hlist_node *pos;
15941 + spin_lock(&vx_info_hash_lock);
15942 + hlist_for_each(pos, head) {
15943 + struct vx_info *vxi;
15948 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
15949 + xids[nr_xids] = vxi->vx_id;
15950 + if (++nr_xids >= size) {
15951 + spin_unlock(&vx_info_hash_lock);
15955 + /* keep the lock time short */
15956 + spin_unlock(&vx_info_hash_lock);
15963 +#ifdef CONFIG_VSERVER_DEBUG
15965 +void dump_vx_info_inactive(int level)
15967 + struct hlist_node *entry, *next;
15969 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
15970 + struct vx_info *vxi =
15971 + list_entry(entry, struct vx_info, vx_hlist);
15973 + dump_vx_info(vxi, level);
15980 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
15982 + struct user_struct *new_user, *old_user;
15987 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
15990 + new_user = alloc_uid(vxi->vx_id, p->uid);
15994 + old_user = p->user;
15995 + if (new_user != old_user) {
15996 + atomic_inc(&new_user->processes);
15997 + atomic_dec(&old_user->processes);
15998 + p->user = new_user;
16000 + free_uid(old_user);
16006 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16008 + // p->cap_effective &= vxi->vx_cap_bset;
16009 + p->cap_effective =
16010 + cap_intersect(p->cap_effective, vxi->cap_bset);
16011 + // p->cap_inheritable &= vxi->vx_cap_bset;
16012 + p->cap_inheritable =
16013 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16014 + // p->cap_permitted &= vxi->vx_cap_bset;
16015 + p->cap_permitted =
16016 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16021 +#include <linux/file.h>
16022 +#include <linux/fdtable.h>
16024 +static int vx_openfd_task(struct task_struct *tsk)
16026 + struct files_struct *files = tsk->files;
16027 + struct fdtable *fdt;
16028 + const unsigned long *bptr;
16029 + int count, total;
16031 + /* no rcu_read_lock() because of spin_lock() */
16032 + spin_lock(&files->file_lock);
16033 + fdt = files_fdtable(files);
16034 + bptr = fdt->open_fds;
16035 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16036 + for (total = 0; count > 0; count--) {
16038 + total += hweight_long(*bptr);
16041 + spin_unlock(&files->file_lock);
16046 +/* for *space compatibility */
16048 +asmlinkage long sys_unshare(unsigned long);
16051 + * migrate task to new context
16052 + * gets vxi, puts old_vxi on change
16053 + * optionally unshares namespaces (hack)
16056 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16058 + struct vx_info *old_vxi;
16064 + vxdprintk(VXD_CBIT(xid, 5),
16065 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16066 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16068 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16069 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16072 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16075 + old_vxi = task_get_vx_info(p);
16076 + if (old_vxi == vxi)
16079 +// if (!(ret = vx_migrate_user(p, vxi))) {
16084 + openfd = vx_openfd_task(p);
16087 + atomic_dec(&old_vxi->cvirt.nr_threads);
16088 + atomic_dec(&old_vxi->cvirt.nr_running);
16089 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16090 + /* FIXME: what about the struct files here? */
16091 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16092 + /* account for the executable */
16093 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16095 + atomic_inc(&vxi->cvirt.nr_threads);
16096 + atomic_inc(&vxi->cvirt.nr_running);
16097 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16098 + /* FIXME: what about the struct files here? */
16099 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16100 + /* account for the executable */
16101 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16104 + release_vx_info(old_vxi, p);
16105 + clr_vx_info(&p->vx_info);
16107 + claim_vx_info(vxi, p);
16108 + set_vx_info(&p->vx_info, vxi);
16109 + p->xid = vxi->vx_id;
16111 + vxdprintk(VXD_CBIT(xid, 5),
16112 + "moved task %p into vxi:%p[#%d]",
16113 + p, vxi, vxi->vx_id);
16115 + // vx_mask_cap_bset(vxi, p);
16118 + /* hack for *spaces to provide compatibility */
16120 + struct nsproxy *old_nsp, *new_nsp;
16122 + ret = unshare_nsproxy_namespaces(
16123 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16124 + &new_nsp, NULL, NULL);
16128 + old_nsp = xchg(&p->nsproxy, new_nsp);
16129 + vx_set_space(vxi,
16130 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16131 + put_nsproxy(old_nsp);
16135 + put_vx_info(old_vxi);
16139 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16141 + struct task_struct *old_reaper;
16142 + struct vx_info *reaper_vxi;
16147 + vxdprintk(VXD_CBIT(xid, 6),
16148 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16149 + vxi, vxi->vx_id, p, p->xid, p->pid);
16151 + old_reaper = vxi->vx_reaper;
16152 + if (old_reaper == p)
16155 + reaper_vxi = task_get_vx_info(p);
16156 + if (reaper_vxi && reaper_vxi != vxi) {
16158 + "Unsuitable reaper [" VS_Q("%s") ",%u:#%u] "
16160 + p->comm, p->pid, p->xid, vx_current_xid());
16164 + /* set new child reaper */
16165 + get_task_struct(p);
16166 + vxi->vx_reaper = p;
16167 + put_task_struct(old_reaper);
16169 + put_vx_info(reaper_vxi);
16173 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16178 + vxdprintk(VXD_CBIT(xid, 6),
16179 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16180 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16182 + vxi->vx_flags &= ~VXF_STATE_INIT;
16183 + // vxi->vx_initpid = p->tgid;
16184 + vxi->vx_initpid = p->pid;
16188 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16190 + vxdprintk(VXD_CBIT(xid, 6),
16191 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16192 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16194 + vxi->exit_code = code;
16195 + vxi->vx_initpid = 0;
16199 +void vx_set_persistent(struct vx_info *vxi)
16201 + vxdprintk(VXD_CBIT(xid, 6),
16202 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16204 + get_vx_info(vxi);
16205 + claim_vx_info(vxi, NULL);
16208 +void vx_clear_persistent(struct vx_info *vxi)
16210 + vxdprintk(VXD_CBIT(xid, 6),
16211 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16213 + release_vx_info(vxi, NULL);
16214 + put_vx_info(vxi);
16217 +void vx_update_persistent(struct vx_info *vxi)
16219 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16220 + vx_set_persistent(vxi);
16222 + vx_clear_persistent(vxi);
16226 +/* task must be current or locked */
16228 +void exit_vx_info(struct task_struct *p, int code)
16230 + struct vx_info *vxi = p->vx_info;
16233 + atomic_dec(&vxi->cvirt.nr_threads);
16236 + vxi->exit_code = code;
16237 + release_vx_info(vxi, p);
16241 +void exit_vx_info_early(struct task_struct *p, int code)
16243 + struct vx_info *vxi = p->vx_info;
16246 + if (vxi->vx_initpid == p->pid)
16247 + vx_exit_init(vxi, p, code);
16248 + if (vxi->vx_reaper == p)
16249 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16254 +/* vserver syscall commands below here */
16256 +/* taks xid and vx_info functions */
16258 +#include <asm/uaccess.h>
16261 +int vc_task_xid(uint32_t id)
16266 + struct task_struct *tsk;
16269 + tsk = find_task_by_real_pid(id);
16270 + xid = (tsk) ? tsk->xid : -ESRCH;
16271 + rcu_read_unlock();
16273 + xid = vx_current_xid();
16278 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16280 + struct vcmd_vx_info_v0 vc_data;
16282 + vc_data.xid = vxi->vx_id;
16283 + vc_data.initpid = vxi->vx_initpid;
16285 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16291 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16293 + struct vcmd_ctx_stat_v0 vc_data;
16295 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16296 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16298 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16304 +/* context functions */
16306 +int vc_ctx_create(uint32_t xid, void __user *data)
16308 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16309 + struct vx_info *new_vxi;
16312 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16315 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16318 + new_vxi = __create_vx_info(xid);
16319 + if (IS_ERR(new_vxi))
16320 + return PTR_ERR(new_vxi);
16322 + /* initial flags */
16323 + new_vxi->vx_flags = vc_data.flagword;
16326 + if (vs_state_change(new_vxi, VSC_STARTUP))
16329 + ret = vx_migrate_task(current, new_vxi, (!data));
16333 + /* return context id on success */
16334 + ret = new_vxi->vx_id;
16336 + /* get a reference for persistent contexts */
16337 + if ((vc_data.flagword & VXF_PERSISTENT))
16338 + vx_set_persistent(new_vxi);
16340 + release_vx_info(new_vxi, NULL);
16341 + put_vx_info(new_vxi);
16346 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16348 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16351 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16354 + ret = vx_migrate_task(current, vxi, 0);
16357 + if (vc_data.flagword & VXM_SET_INIT)
16358 + ret = vx_set_init(vxi, current);
16361 + if (vc_data.flagword & VXM_SET_REAPER)
16362 + ret = vx_set_reaper(vxi, current);
16367 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16369 + struct vcmd_ctx_flags_v0 vc_data;
16371 + vc_data.flagword = vxi->vx_flags;
16373 + /* special STATE flag handling */
16374 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16376 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16381 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16383 + struct vcmd_ctx_flags_v0 vc_data;
16384 + uint64_t mask, trigger;
16386 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16389 + /* special STATE flag handling */
16390 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16391 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16393 + if (vxi == current_vx_info()) {
16394 + /* if (trigger & VXF_STATE_SETUP)
16395 + vx_mask_cap_bset(vxi, current); */
16396 + if (trigger & VXF_STATE_INIT) {
16399 + ret = vx_set_init(vxi, current);
16402 + ret = vx_set_reaper(vxi, current);
16408 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
16409 + vc_data.flagword, mask);
16410 + if (trigger & VXF_PERSISTENT)
16411 + vx_update_persistent(vxi);
16417 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
16419 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
16421 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
16425 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
16427 + kernel_cap_t c = __cap_empty_set;
16429 + c.cap[0] = v & 0xFFFFFFFF;
16430 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
16432 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
16437 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
16440 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
16442 + *ccaps = vxi->vx_ccaps;
16447 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
16449 + struct vcmd_ctx_caps_v1 vc_data;
16452 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
16455 + vc_data.cmask = ~0ULL;
16457 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16462 +static int do_set_caps(struct vx_info *vxi,
16463 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
16465 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
16468 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
16469 + bcaps, bmask, ccaps, cmask);
16471 + vxi->vx_bcaps = cap_t_from_caps(
16472 + vs_mask_flags(bcold, bcaps, bmask));
16473 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
16478 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
16480 + struct vcmd_ctx_caps_v1 vc_data;
16482 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16485 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
16488 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
16490 + struct vcmd_bcaps vc_data;
16493 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
16496 + vc_data.bmask = ~0ULL;
16498 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16503 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
16505 + struct vcmd_bcaps vc_data;
16507 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16510 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
16514 +int vc_get_umask(struct vx_info *vxi, void __user *data)
16516 + struct vcmd_umask vc_data;
16518 + vc_data.umask = vxi->vx_umask;
16519 + vc_data.mask = ~0ULL;
16521 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16526 +int vc_set_umask(struct vx_info *vxi, void __user *data)
16528 + struct vcmd_umask vc_data;
16530 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16533 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
16534 + vc_data.umask, vc_data.mask);
16539 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
16541 + struct vcmd_wmask vc_data;
16543 + vc_data.wmask = vxi->vx_wmask;
16544 + vc_data.mask = ~0ULL;
16546 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16551 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
16553 + struct vcmd_wmask vc_data;
16555 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16558 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
16559 + vc_data.wmask, vc_data.mask);
16564 +int vc_get_badness(struct vx_info *vxi, void __user *data)
16566 + struct vcmd_badness_v0 vc_data;
16568 + vc_data.bias = vxi->vx_badness_bias;
16570 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16575 +int vc_set_badness(struct vx_info *vxi, void __user *data)
16577 + struct vcmd_badness_v0 vc_data;
16579 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16582 + vxi->vx_badness_bias = vc_data.bias;
16586 +#include <linux/module.h>
16588 +EXPORT_SYMBOL_GPL(free_vx_info);
16590 diff -NurpP --minimal linux-3.10.15/kernel/vserver/cvirt.c linux-3.10.15-vs2.3.6.6/kernel/vserver/cvirt.c
16591 --- linux-3.10.15/kernel/vserver/cvirt.c 1970-01-01 00:00:00.000000000 +0000
16592 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/cvirt.c 2013-08-22 20:30:00.000000000 +0000
16595 + * linux/kernel/vserver/cvirt.c
16597 + * Virtual Server: Context Virtualization
16599 + * Copyright (C) 2004-2007 Herbert Pötzl
16601 + * V0.01 broken out from limit.c
16602 + * V0.02 added utsname stuff
16603 + * V0.03 changed vcmds to vxi arg
16607 +#include <linux/types.h>
16608 +#include <linux/utsname.h>
16609 +#include <linux/vs_cvirt.h>
16610 +#include <linux/vserver/switch.h>
16611 +#include <linux/vserver/cvirt_cmd.h>
16613 +#include <asm/uaccess.h>
16616 +void vx_vsi_boottime(struct timespec *boottime)
16618 + struct vx_info *vxi = current_vx_info();
16620 + set_normalized_timespec(boottime,
16621 + boottime->tv_sec + vxi->cvirt.bias_uptime.tv_sec,
16622 + boottime->tv_nsec + vxi->cvirt.bias_uptime.tv_nsec);
16626 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
16628 + struct vx_info *vxi = current_vx_info();
16630 + set_normalized_timespec(uptime,
16631 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
16632 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
16635 + set_normalized_timespec(idle,
16636 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
16637 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
16641 +uint64_t vx_idle_jiffies(void)
16643 + return init_task.utime + init_task.stime;
16648 +static inline uint32_t __update_loadavg(uint32_t load,
16649 + int wsize, int delta, int n)
16651 + unsigned long long calc, prev;
16653 + /* just set it to n */
16654 + if (unlikely(delta >= wsize))
16655 + return (n << FSHIFT);
16657 + calc = delta * n;
16659 + prev = (wsize - delta);
16662 + do_div(calc, wsize);
16667 +void vx_update_load(struct vx_info *vxi)
16669 + uint32_t now, last, delta;
16670 + unsigned int nr_running, nr_uninterruptible;
16671 + unsigned int total;
16672 + unsigned long flags;
16674 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
16677 + last = vxi->cvirt.load_last;
16678 + delta = now - last;
16680 + if (delta < 5*HZ)
16683 + nr_running = atomic_read(&vxi->cvirt.nr_running);
16684 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
16685 + total = nr_running + nr_uninterruptible;
16687 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
16688 + 60*HZ, delta, total);
16689 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
16690 + 5*60*HZ, delta, total);
16691 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
16692 + 15*60*HZ, delta, total);
16694 + vxi->cvirt.load_last = now;
16696 + atomic_inc(&vxi->cvirt.load_updates);
16697 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
16702 + * Commands to do_syslog:
16704 + * 0 -- Close the log. Currently a NOP.
16705 + * 1 -- Open the log. Currently a NOP.
16706 + * 2 -- Read from the log.
16707 + * 3 -- Read all messages remaining in the ring buffer.
16708 + * 4 -- Read and clear all messages remaining in the ring buffer
16709 + * 5 -- Clear ring buffer.
16710 + * 6 -- Disable printk's to console
16711 + * 7 -- Enable printk's to console
16712 + * 8 -- Set level of messages printed to console
16713 + * 9 -- Return number of unread characters in the log buffer
16714 + * 10 -- Return size of the log buffer
16716 +int vx_do_syslog(int type, char __user *buf, int len)
16719 + int do_clear = 0;
16720 + struct vx_info *vxi = current_vx_info();
16721 + struct _vx_syslog *log;
16725 + log = &vxi->cvirt.syslog;
16728 + case 0: /* Close log */
16729 + case 1: /* Open log */
16731 + case 2: /* Read from log */
16732 + error = wait_event_interruptible(log->log_wait,
16733 + (log->log_start - log->log_end));
16736 + spin_lock_irq(&log->logbuf_lock);
16737 + spin_unlock_irq(&log->logbuf_lock);
16739 + case 4: /* Read/clear last kernel messages */
16741 + /* fall through */
16742 + case 3: /* Read last kernel messages */
16745 + case 5: /* Clear ring buffer */
16748 + case 6: /* Disable logging to console */
16749 + case 7: /* Enable logging to console */
16750 + case 8: /* Set level of messages printed to console */
16753 + case 9: /* Number of chars in the log buffer */
16755 + case 10: /* Size of the log buffer */
16765 +/* virtual host info names */
16767 +static char *vx_vhi_name(struct vx_info *vxi, int id)
16769 + struct nsproxy *nsproxy;
16770 + struct uts_namespace *uts;
16772 + if (id == VHIN_CONTEXT)
16773 + return vxi->vx_name;
16775 + nsproxy = vxi->space[0].vx_nsproxy;
16779 + uts = nsproxy->uts_ns;
16784 + case VHIN_SYSNAME:
16785 + return uts->name.sysname;
16786 + case VHIN_NODENAME:
16787 + return uts->name.nodename;
16788 + case VHIN_RELEASE:
16789 + return uts->name.release;
16790 + case VHIN_VERSION:
16791 + return uts->name.version;
16792 + case VHIN_MACHINE:
16793 + return uts->name.machine;
16794 + case VHIN_DOMAINNAME:
16795 + return uts->name.domainname;
16802 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
16804 + struct vcmd_vhi_name_v0 vc_data;
16807 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16810 + name = vx_vhi_name(vxi, vc_data.field);
16814 + memcpy(name, vc_data.name, 65);
16818 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
16820 + struct vcmd_vhi_name_v0 vc_data;
16823 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16826 + name = vx_vhi_name(vxi, vc_data.field);
16830 + memcpy(vc_data.name, name, 65);
16831 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16837 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
16839 + struct vcmd_virt_stat_v0 vc_data;
16840 + struct _vx_cvirt *cvirt = &vxi->cvirt;
16841 + struct timespec uptime;
16843 + do_posix_clock_monotonic_gettime(&uptime);
16844 + set_normalized_timespec(&uptime,
16845 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
16846 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
16848 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
16849 + vc_data.uptime = timespec_to_ns(&uptime);
16850 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
16851 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
16852 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
16853 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
16854 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
16855 + vc_data.load[0] = cvirt->load[0];
16856 + vc_data.load[1] = cvirt->load[1];
16857 + vc_data.load[2] = cvirt->load[2];
16859 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16865 +#ifdef CONFIG_VSERVER_VTIME
16867 +/* virtualized time base */
16869 +void vx_adjust_timespec(struct timespec *ts)
16871 + struct vx_info *vxi;
16873 + if (!vx_flags(VXF_VIRT_TIME, 0))
16876 + vxi = current_vx_info();
16877 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
16878 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
16880 + if (ts->tv_nsec >= NSEC_PER_SEC) {
16882 + ts->tv_nsec -= NSEC_PER_SEC;
16883 + } else if (ts->tv_nsec < 0) {
16885 + ts->tv_nsec += NSEC_PER_SEC;
16889 +int vx_settimeofday(const struct timespec *ts)
16891 + struct timespec ats, delta;
16892 + struct vx_info *vxi;
16894 + if (!vx_flags(VXF_VIRT_TIME, 0))
16895 + return do_settimeofday(ts);
16897 + getnstimeofday(&ats);
16898 + delta = timespec_sub(*ts, ats);
16900 + vxi = current_vx_info();
16901 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
16907 diff -NurpP --minimal linux-3.10.15/kernel/vserver/cvirt_init.h linux-3.10.15-vs2.3.6.6/kernel/vserver/cvirt_init.h
16908 --- linux-3.10.15/kernel/vserver/cvirt_init.h 1970-01-01 00:00:00.000000000 +0000
16909 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/cvirt_init.h 2013-08-22 20:30:00.000000000 +0000
16913 +extern uint64_t vx_idle_jiffies(void);
16915 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
16917 + uint64_t idle_jiffies = vx_idle_jiffies();
16918 + uint64_t nsuptime;
16920 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
16921 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
16922 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
16923 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
16924 + cvirt->bias_ts.tv_sec = 0;
16925 + cvirt->bias_ts.tv_nsec = 0;
16927 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
16928 + atomic_set(&cvirt->nr_threads, 0);
16929 + atomic_set(&cvirt->nr_running, 0);
16930 + atomic_set(&cvirt->nr_uninterruptible, 0);
16931 + atomic_set(&cvirt->nr_onhold, 0);
16933 + spin_lock_init(&cvirt->load_lock);
16934 + cvirt->load_last = jiffies;
16935 + atomic_set(&cvirt->load_updates, 0);
16936 + cvirt->load[0] = 0;
16937 + cvirt->load[1] = 0;
16938 + cvirt->load[2] = 0;
16939 + atomic_set(&cvirt->total_forks, 0);
16941 + spin_lock_init(&cvirt->syslog.logbuf_lock);
16942 + init_waitqueue_head(&cvirt->syslog.log_wait);
16943 + cvirt->syslog.log_start = 0;
16944 + cvirt->syslog.log_end = 0;
16945 + cvirt->syslog.con_start = 0;
16946 + cvirt->syslog.logged_chars = 0;
16950 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
16952 + // cvirt_pc->cpustat = { 0 };
16955 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
16957 +#ifdef CONFIG_VSERVER_WARN
16960 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
16961 + "!!! cvirt: %p[nr_threads] = %d on exit.",
16963 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
16964 + "!!! cvirt: %p[nr_running] = %d on exit.",
16966 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
16967 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
16969 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
16970 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
16976 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
16981 diff -NurpP --minimal linux-3.10.15/kernel/vserver/cvirt_proc.h linux-3.10.15-vs2.3.6.6/kernel/vserver/cvirt_proc.h
16982 --- linux-3.10.15/kernel/vserver/cvirt_proc.h 1970-01-01 00:00:00.000000000 +0000
16983 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/cvirt_proc.h 2013-08-22 20:30:00.000000000 +0000
16985 +#ifndef _VX_CVIRT_PROC_H
16986 +#define _VX_CVIRT_PROC_H
16988 +#include <linux/nsproxy.h>
16989 +#include <linux/mnt_namespace.h>
16990 +#include <linux/ipc_namespace.h>
16991 +#include <linux/utsname.h>
16992 +#include <linux/ipc.h>
16994 +extern int vx_info_mnt_namespace(struct mnt_namespace *, char *);
16997 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
16999 + struct mnt_namespace *ns;
17000 + struct uts_namespace *uts;
17001 + struct ipc_namespace *ipc;
17007 + length += sprintf(buffer + length,
17008 + "NSProxy:\t%p [%p,%p,%p]\n",
17009 + nsproxy, nsproxy->mnt_ns,
17010 + nsproxy->uts_ns, nsproxy->ipc_ns);
17012 + ns = nsproxy->mnt_ns;
17016 + length += vx_info_mnt_namespace(ns, buffer + length);
17020 + uts = nsproxy->uts_ns;
17024 + length += sprintf(buffer + length,
17025 + "SysName:\t%.*s\n"
17026 + "NodeName:\t%.*s\n"
17027 + "Release:\t%.*s\n"
17028 + "Version:\t%.*s\n"
17029 + "Machine:\t%.*s\n"
17030 + "DomainName:\t%.*s\n",
17031 + __NEW_UTS_LEN, uts->name.sysname,
17032 + __NEW_UTS_LEN, uts->name.nodename,
17033 + __NEW_UTS_LEN, uts->name.release,
17034 + __NEW_UTS_LEN, uts->name.version,
17035 + __NEW_UTS_LEN, uts->name.machine,
17036 + __NEW_UTS_LEN, uts->name.domainname);
17039 + ipc = nsproxy->ipc_ns;
17043 + length += sprintf(buffer + length,
17044 + "SEMS:\t\t%d %d %d %d %d\n"
17045 + "MSG:\t\t%d %d %d\n"
17046 + "SHM:\t\t%lu %lu %d %ld\n",
17047 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17048 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17050 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17051 + (unsigned long)ipc->shm_ctlmax,
17052 + (unsigned long)ipc->shm_ctlall,
17053 + ipc->shm_ctlmni, ipc->shm_tot);
17060 +#include <linux/sched.h>
17062 +#define LOAD_INT(x) ((x) >> FSHIFT)
17063 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17066 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17071 + length += sprintf(buffer + length,
17072 + "BiasUptime:\t%lu.%02lu\n",
17073 + (unsigned long)cvirt->bias_uptime.tv_sec,
17074 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17076 + a = cvirt->load[0] + (FIXED_1 / 200);
17077 + b = cvirt->load[1] + (FIXED_1 / 200);
17078 + c = cvirt->load[2] + (FIXED_1 / 200);
17079 + length += sprintf(buffer + length,
17080 + "nr_threads:\t%d\n"
17081 + "nr_running:\t%d\n"
17082 + "nr_unintr:\t%d\n"
17083 + "nr_onhold:\t%d\n"
17084 + "load_updates:\t%d\n"
17085 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17086 + "total_forks:\t%d\n",
17087 + atomic_read(&cvirt->nr_threads),
17088 + atomic_read(&cvirt->nr_running),
17089 + atomic_read(&cvirt->nr_uninterruptible),
17090 + atomic_read(&cvirt->nr_onhold),
17091 + atomic_read(&cvirt->load_updates),
17092 + LOAD_INT(a), LOAD_FRAC(a),
17093 + LOAD_INT(b), LOAD_FRAC(b),
17094 + LOAD_INT(c), LOAD_FRAC(c),
17095 + atomic_read(&cvirt->total_forks));
17100 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17101 + char *buffer, int cpu)
17107 +#endif /* _VX_CVIRT_PROC_H */
17108 diff -NurpP --minimal linux-3.10.15/kernel/vserver/debug.c linux-3.10.15-vs2.3.6.6/kernel/vserver/debug.c
17109 --- linux-3.10.15/kernel/vserver/debug.c 1970-01-01 00:00:00.000000000 +0000
17110 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/debug.c 2013-08-22 20:30:00.000000000 +0000
17113 + * kernel/vserver/debug.c
17115 + * Copyright (C) 2005-2007 Herbert Pötzl
17117 + * V0.01 vx_info dump support
17121 +#include <linux/module.h>
17123 +#include <linux/vserver/context.h>
17126 +void dump_vx_info(struct vx_info *vxi, int level)
17128 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17129 + atomic_read(&vxi->vx_usecnt),
17130 + atomic_read(&vxi->vx_tasks),
17133 + __dump_vx_limit(&vxi->limit);
17134 + __dump_vx_sched(&vxi->sched);
17135 + __dump_vx_cvirt(&vxi->cvirt);
17136 + __dump_vx_cacct(&vxi->cacct);
17142 +EXPORT_SYMBOL_GPL(dump_vx_info);
17144 diff -NurpP --minimal linux-3.10.15/kernel/vserver/device.c linux-3.10.15-vs2.3.6.6/kernel/vserver/device.c
17145 --- linux-3.10.15/kernel/vserver/device.c 1970-01-01 00:00:00.000000000 +0000
17146 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/device.c 2013-08-22 20:30:00.000000000 +0000
17149 + * linux/kernel/vserver/device.c
17151 + * Linux-VServer: Device Support
17153 + * Copyright (C) 2006 Herbert Pötzl
17154 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17156 + * V0.01 device mapping basics
17157 + * V0.02 added defaults
17161 +#include <linux/slab.h>
17162 +#include <linux/rcupdate.h>
17163 +#include <linux/fs.h>
17164 +#include <linux/namei.h>
17165 +#include <linux/hash.h>
17167 +#include <asm/errno.h>
17168 +#include <asm/uaccess.h>
17169 +#include <linux/vserver/base.h>
17170 +#include <linux/vserver/debug.h>
17171 +#include <linux/vserver/context.h>
17172 +#include <linux/vserver/device.h>
17173 +#include <linux/vserver/device_cmd.h>
17176 +#define DMAP_HASH_BITS 4
17179 +struct vs_mapping {
17181 + struct hlist_node hlist;
17182 + struct list_head list;
17184 +#define dm_hlist u.hlist
17185 +#define dm_list u.list
17188 + struct vx_dmap_target target;
17192 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17194 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17196 +static struct vx_dmap_target dmap_defaults[2] = {
17197 + { .flags = DATTR_OPEN },
17198 + { .flags = DATTR_OPEN },
17202 +struct kmem_cache *dmap_cachep __read_mostly;
17204 +int __init dmap_cache_init(void)
17206 + dmap_cachep = kmem_cache_create("dmap_cache",
17207 + sizeof(struct vs_mapping), 0,
17208 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17212 +__initcall(dmap_cache_init);
17215 +static inline unsigned int __hashval(dev_t dev, int bits)
17217 + return hash_long((unsigned long)dev, bits);
17221 +/* __hash_mapping()
17222 + * add the mapping to the hash table
17224 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17226 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17227 + struct hlist_head *head, *hash = dmap_main_hash;
17228 + int device = vdm->device;
17230 + spin_lock(hash_lock);
17231 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17232 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17234 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17235 + hlist_add_head(&vdm->dm_hlist, head);
17236 + spin_unlock(hash_lock);
17240 +static inline int __mode_to_default(umode_t mode)
17253 +/* __set_default()
17256 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17257 + struct vx_dmap_target *vdmt)
17259 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17260 + spin_lock(hash_lock);
17263 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17265 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17268 + spin_unlock(hash_lock);
17270 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17271 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17275 +/* __remove_default()
17276 + * remove a default
17278 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17280 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17281 + spin_lock(hash_lock);
17284 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17285 + else /* remove == reset */
17286 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17288 + spin_unlock(hash_lock);
17293 +/* __find_mapping()
17294 + * find a mapping in the hash table
17296 + * caller must hold hash_lock
17298 +static inline int __find_mapping(vxid_t xid, dev_t device, umode_t mode,
17299 + struct vs_mapping **local, struct vs_mapping **global)
17301 + struct hlist_head *hash = dmap_main_hash;
17302 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17303 + struct hlist_node *pos;
17304 + struct vs_mapping *vdm;
17310 + hlist_for_each(pos, head) {
17311 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17313 + if ((vdm->device == device) &&
17314 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17315 + if (vdm->xid == xid) {
17318 + } else if (global && vdm->xid == 0)
17323 + if (global && *global)
17330 +/* __lookup_mapping()
17331 + * find a mapping and store the result in target and flags
17333 +static inline int __lookup_mapping(struct vx_info *vxi,
17334 + dev_t device, dev_t *target, int *flags, umode_t mode)
17336 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17337 + struct vs_mapping *vdm, *global;
17338 + struct vx_dmap_target *vdmt;
17340 + vxid_t xid = vxi->vx_id;
17343 + spin_lock(hash_lock);
17344 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17346 + vdmt = &vdm->target;
17350 + index = __mode_to_default(mode);
17351 + if (vxi && vxi->dmap.targets[index].flags) {
17353 + vdmt = &vxi->dmap.targets[index];
17354 + } else if (global) {
17356 + vdmt = &global->target;
17360 + vdmt = &dmap_defaults[index];
17364 + if (target && (vdmt->flags & DATTR_REMAP))
17365 + *target = vdmt->target;
17367 + *target = device;
17369 + *flags = vdmt->flags;
17371 + spin_unlock(hash_lock);
17377 +/* __remove_mapping()
17378 + * remove a mapping from the hash table
17380 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17383 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17384 + struct vs_mapping *vdm = NULL;
17387 + spin_lock(hash_lock);
17389 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17391 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
17392 + vxi, vxi ? vxi->vx_id : 0, device, mode);
17395 + hlist_del(&vdm->dm_hlist);
17398 + spin_unlock(hash_lock);
17400 + kmem_cache_free(dmap_cachep, vdm);
17406 +int vs_map_device(struct vx_info *vxi,
17407 + dev_t device, dev_t *target, umode_t mode)
17409 + int ret, flags = DATTR_MASK;
17413 + *target = device;
17416 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
17417 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
17418 + device, target ? *target : 0, flags, mode, ret);
17420 + return (flags & DATTR_MASK);
17425 +static int do_set_mapping(struct vx_info *vxi,
17426 + dev_t device, dev_t target, int flags, umode_t mode)
17429 + struct vs_mapping *new;
17431 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
17435 + INIT_HLIST_NODE(&new->dm_hlist);
17436 + new->device = device;
17437 + new->target.target = target;
17438 + new->target.flags = flags | mode;
17439 + new->xid = (vxi ? vxi->vx_id : 0);
17441 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
17442 + __hash_mapping(vxi, new);
17444 + struct vx_dmap_target new = {
17445 + .target = target,
17446 + .flags = flags | mode,
17448 + __set_default(vxi, mode, &new);
17454 +static int do_unset_mapping(struct vx_info *vxi,
17455 + dev_t device, dev_t target, int flags, umode_t mode)
17457 + int ret = -EINVAL;
17460 + ret = __remove_mapping(vxi, device, mode);
17464 + ret = __remove_default(vxi, mode);
17474 +static inline int __user_device(const char __user *name, dev_t *dev,
17477 + struct nameidata nd;
17484 + ret = user_lpath(name, &nd.path);
17487 + if (nd.path.dentry->d_inode) {
17488 + *dev = nd.path.dentry->d_inode->i_rdev;
17489 + *mode = nd.path.dentry->d_inode->i_mode;
17491 + path_put(&nd.path);
17495 +static inline int __mapping_mode(dev_t device, dev_t target,
17496 + umode_t device_mode, umode_t target_mode, umode_t *mode)
17499 + *mode = device_mode & S_IFMT;
17501 + *mode = target_mode & S_IFMT;
17505 + /* if both given, device and target mode have to match */
17506 + if (device && target &&
17507 + ((device_mode ^ target_mode) & S_IFMT))
17513 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
17514 + const char __user *target_path, int flags, int set)
17516 + dev_t device = ~0, target = ~0;
17517 + umode_t device_mode = 0, target_mode = 0, mode;
17520 + ret = __user_device(device_path, &device, &device_mode);
17523 + ret = __user_device(target_path, &target, &target_mode);
17527 + ret = __mapping_mode(device, target,
17528 + device_mode, target_mode, &mode);
17533 + return do_set_mapping(vxi, device, target,
17536 + return do_unset_mapping(vxi, device, target,
17541 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
17543 + struct vcmd_set_mapping_v0 vc_data;
17545 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17548 + return do_mapping(vxi, vc_data.device, vc_data.target,
17549 + vc_data.flags, 1);
17552 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
17554 + struct vcmd_set_mapping_v0 vc_data;
17556 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17559 + return do_mapping(vxi, vc_data.device, vc_data.target,
17560 + vc_data.flags, 0);
17564 +#ifdef CONFIG_COMPAT
17566 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
17568 + struct vcmd_set_mapping_v0_x32 vc_data;
17570 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17573 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17574 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
17577 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
17579 + struct vcmd_set_mapping_v0_x32 vc_data;
17581 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17584 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17585 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
17588 +#endif /* CONFIG_COMPAT */
17591 diff -NurpP --minimal linux-3.10.15/kernel/vserver/dlimit.c linux-3.10.15-vs2.3.6.6/kernel/vserver/dlimit.c
17592 --- linux-3.10.15/kernel/vserver/dlimit.c 1970-01-01 00:00:00.000000000 +0000
17593 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/dlimit.c 2013-08-22 20:30:00.000000000 +0000
17596 + * linux/kernel/vserver/dlimit.c
17598 + * Virtual Server: Context Disk Limits
17600 + * Copyright (C) 2004-2009 Herbert Pötzl
17602 + * V0.01 initial version
17603 + * V0.02 compat32 splitup
17604 + * V0.03 extended interface
17608 +#include <linux/statfs.h>
17609 +#include <linux/sched.h>
17610 +#include <linux/namei.h>
17611 +#include <linux/vs_tag.h>
17612 +#include <linux/vs_dlimit.h>
17613 +#include <linux/vserver/dlimit_cmd.h>
17614 +#include <linux/slab.h>
17615 +// #include <linux/gfp.h>
17617 +#include <asm/uaccess.h>
17619 +/* __alloc_dl_info()
17621 + * allocate an initialized dl_info struct
17622 + * doesn't make it visible (hash) */
17624 +static struct dl_info *__alloc_dl_info(struct super_block *sb, vtag_t tag)
17626 + struct dl_info *new = NULL;
17628 + vxdprintk(VXD_CBIT(dlim, 5),
17629 + "alloc_dl_info(%p,%d)*", sb, tag);
17631 + /* would this benefit from a slab cache? */
17632 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
17636 + memset(new, 0, sizeof(struct dl_info));
17637 + new->dl_tag = tag;
17639 + // INIT_RCU_HEAD(&new->dl_rcu);
17640 + INIT_HLIST_NODE(&new->dl_hlist);
17641 + spin_lock_init(&new->dl_lock);
17642 + atomic_set(&new->dl_refcnt, 0);
17643 + atomic_set(&new->dl_usecnt, 0);
17645 + /* rest of init goes here */
17647 + vxdprintk(VXD_CBIT(dlim, 4),
17648 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
17652 +/* __dealloc_dl_info()
17654 + * final disposal of dl_info */
17656 +static void __dealloc_dl_info(struct dl_info *dli)
17658 + vxdprintk(VXD_CBIT(dlim, 4),
17659 + "dealloc_dl_info(%p)", dli);
17661 + dli->dl_hlist.next = LIST_POISON1;
17662 + dli->dl_tag = -1;
17665 + BUG_ON(atomic_read(&dli->dl_usecnt));
17666 + BUG_ON(atomic_read(&dli->dl_refcnt));
17672 +/* hash table for dl_info hash */
17674 +#define DL_HASH_SIZE 13
17676 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
17678 +static DEFINE_SPINLOCK(dl_info_hash_lock);
17681 +static inline unsigned int __hashval(struct super_block *sb, vtag_t tag)
17683 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
17688 +/* __hash_dl_info()
17690 + * add the dli to the global hash table
17691 + * requires the hash_lock to be held */
17693 +static inline void __hash_dl_info(struct dl_info *dli)
17695 + struct hlist_head *head;
17697 + vxdprintk(VXD_CBIT(dlim, 6),
17698 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
17699 + get_dl_info(dli);
17700 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
17701 + hlist_add_head_rcu(&dli->dl_hlist, head);
17704 +/* __unhash_dl_info()
17706 + * remove the dli from the global hash table
17707 + * requires the hash_lock to be held */
17709 +static inline void __unhash_dl_info(struct dl_info *dli)
17711 + vxdprintk(VXD_CBIT(dlim, 6),
17712 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
17713 + hlist_del_rcu(&dli->dl_hlist);
17714 + put_dl_info(dli);
17718 +/* __lookup_dl_info()
17720 + * requires the rcu_read_lock()
17721 + * doesn't increment the dl_refcnt */
17723 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, vtag_t tag)
17725 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
17726 + struct dl_info *dli;
17728 + hlist_for_each_entry_rcu(dli, head, dl_hlist) {
17729 + if (dli->dl_tag == tag && dli->dl_sb == sb)
17736 +struct dl_info *locate_dl_info(struct super_block *sb, vtag_t tag)
17738 + struct dl_info *dli;
17741 + dli = get_dl_info(__lookup_dl_info(sb, tag));
17742 + vxdprintk(VXD_CBIT(dlim, 7),
17743 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
17744 + rcu_read_unlock();
17748 +void rcu_free_dl_info(struct rcu_head *head)
17750 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
17751 + int usecnt, refcnt;
17753 + BUG_ON(!dli || !head);
17755 + usecnt = atomic_read(&dli->dl_usecnt);
17756 + BUG_ON(usecnt < 0);
17758 + refcnt = atomic_read(&dli->dl_refcnt);
17759 + BUG_ON(refcnt < 0);
17761 + vxdprintk(VXD_CBIT(dlim, 3),
17762 + "rcu_free_dl_info(%p)", dli);
17764 + __dealloc_dl_info(dli);
17766 + printk("!!! rcu didn't free\n");
17772 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
17773 + uint32_t flags, int add)
17775 + struct path path;
17778 + ret = user_lpath(name, &path);
17780 + struct super_block *sb;
17781 + struct dl_info *dli;
17784 + if (!path.dentry->d_inode)
17785 + goto out_release;
17786 + if (!(sb = path.dentry->d_inode->i_sb))
17787 + goto out_release;
17790 + dli = __alloc_dl_info(sb, id);
17791 + spin_lock(&dl_info_hash_lock);
17794 + if (__lookup_dl_info(sb, id))
17796 + __hash_dl_info(dli);
17799 + spin_lock(&dl_info_hash_lock);
17800 + dli = __lookup_dl_info(sb, id);
17805 + __unhash_dl_info(dli);
17809 + spin_unlock(&dl_info_hash_lock);
17811 + __dealloc_dl_info(dli);
17818 +int vc_add_dlimit(uint32_t id, void __user *data)
17820 + struct vcmd_ctx_dlimit_base_v0 vc_data;
17822 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17825 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
17828 +int vc_rem_dlimit(uint32_t id, void __user *data)
17830 + struct vcmd_ctx_dlimit_base_v0 vc_data;
17832 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17835 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
17838 +#ifdef CONFIG_COMPAT
17840 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
17842 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
17844 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17847 + return do_addrem_dlimit(id,
17848 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
17851 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
17853 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
17855 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17858 + return do_addrem_dlimit(id,
17859 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
17862 +#endif /* CONFIG_COMPAT */
17866 +int do_set_dlimit(uint32_t id, const char __user *name,
17867 + uint32_t space_used, uint32_t space_total,
17868 + uint32_t inodes_used, uint32_t inodes_total,
17869 + uint32_t reserved, uint32_t flags)
17871 + struct path path;
17874 + ret = user_lpath(name, &path);
17876 + struct super_block *sb;
17877 + struct dl_info *dli;
17880 + if (!path.dentry->d_inode)
17881 + goto out_release;
17882 + if (!(sb = path.dentry->d_inode->i_sb))
17883 + goto out_release;
17885 + /* sanity checks */
17886 + if ((reserved != CDLIM_KEEP &&
17887 + reserved > 100) ||
17888 + (inodes_used != CDLIM_KEEP &&
17889 + inodes_used > inodes_total) ||
17890 + (space_used != CDLIM_KEEP &&
17891 + space_used > space_total))
17892 + goto out_release;
17895 + dli = locate_dl_info(sb, id);
17897 + goto out_release;
17899 + spin_lock(&dli->dl_lock);
17901 + if (inodes_used != CDLIM_KEEP)
17902 + dli->dl_inodes_used = inodes_used;
17903 + if (inodes_total != CDLIM_KEEP)
17904 + dli->dl_inodes_total = inodes_total;
17905 + if (space_used != CDLIM_KEEP)
17906 + dli->dl_space_used = dlimit_space_32to64(
17907 + space_used, flags, DLIMS_USED);
17909 + if (space_total == CDLIM_INFINITY)
17910 + dli->dl_space_total = DLIM_INFINITY;
17911 + else if (space_total != CDLIM_KEEP)
17912 + dli->dl_space_total = dlimit_space_32to64(
17913 + space_total, flags, DLIMS_TOTAL);
17915 + if (reserved != CDLIM_KEEP)
17916 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
17918 + spin_unlock(&dli->dl_lock);
17920 + put_dl_info(dli);
17929 +int vc_set_dlimit(uint32_t id, void __user *data)
17931 + struct vcmd_ctx_dlimit_v0 vc_data;
17933 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17936 + return do_set_dlimit(id, vc_data.name,
17937 + vc_data.space_used, vc_data.space_total,
17938 + vc_data.inodes_used, vc_data.inodes_total,
17939 + vc_data.reserved, vc_data.flags);
17942 +#ifdef CONFIG_COMPAT
17944 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
17946 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
17948 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17951 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
17952 + vc_data.space_used, vc_data.space_total,
17953 + vc_data.inodes_used, vc_data.inodes_total,
17954 + vc_data.reserved, vc_data.flags);
17957 +#endif /* CONFIG_COMPAT */
17961 +int do_get_dlimit(uint32_t id, const char __user *name,
17962 + uint32_t *space_used, uint32_t *space_total,
17963 + uint32_t *inodes_used, uint32_t *inodes_total,
17964 + uint32_t *reserved, uint32_t *flags)
17966 + struct path path;
17969 + ret = user_lpath(name, &path);
17971 + struct super_block *sb;
17972 + struct dl_info *dli;
17975 + if (!path.dentry->d_inode)
17976 + goto out_release;
17977 + if (!(sb = path.dentry->d_inode->i_sb))
17978 + goto out_release;
17981 + dli = locate_dl_info(sb, id);
17983 + goto out_release;
17985 + spin_lock(&dli->dl_lock);
17986 + *inodes_used = dli->dl_inodes_used;
17987 + *inodes_total = dli->dl_inodes_total;
17989 + *space_used = dlimit_space_64to32(
17990 + dli->dl_space_used, flags, DLIMS_USED);
17992 + if (dli->dl_space_total == DLIM_INFINITY)
17993 + *space_total = CDLIM_INFINITY;
17995 + *space_total = dlimit_space_64to32(
17996 + dli->dl_space_total, flags, DLIMS_TOTAL);
17998 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
17999 + spin_unlock(&dli->dl_lock);
18001 + put_dl_info(dli);
18012 +int vc_get_dlimit(uint32_t id, void __user *data)
18014 + struct vcmd_ctx_dlimit_v0 vc_data;
18017 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18020 + ret = do_get_dlimit(id, vc_data.name,
18021 + &vc_data.space_used, &vc_data.space_total,
18022 + &vc_data.inodes_used, &vc_data.inodes_total,
18023 + &vc_data.reserved, &vc_data.flags);
18027 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18032 +#ifdef CONFIG_COMPAT
18034 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18036 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18039 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18042 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18043 + &vc_data.space_used, &vc_data.space_total,
18044 + &vc_data.inodes_used, &vc_data.inodes_total,
18045 + &vc_data.reserved, &vc_data.flags);
18049 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18054 +#endif /* CONFIG_COMPAT */
18057 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18059 + struct dl_info *dli;
18060 + __u64 blimit, bfree, bavail;
18063 + dli = locate_dl_info(sb, dx_current_tag());
18067 + spin_lock(&dli->dl_lock);
18068 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18071 + /* reduce max inodes available to limit */
18072 + if (buf->f_files > dli->dl_inodes_total)
18073 + buf->f_files = dli->dl_inodes_total;
18075 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18076 + /* reduce free inodes to min */
18077 + if (ifree < buf->f_ffree)
18078 + buf->f_ffree = ifree;
18081 + if (dli->dl_space_total == DLIM_INFINITY)
18084 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18086 + if (dli->dl_space_total < dli->dl_space_used)
18089 + bfree = (dli->dl_space_total - dli->dl_space_used)
18090 + >> sb->s_blocksize_bits;
18092 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18093 + if (bavail < dli->dl_space_used)
18096 + bavail = (bavail - dli->dl_space_used)
18097 + >> sb->s_blocksize_bits;
18099 + /* reduce max space available to limit */
18100 + if (buf->f_blocks > blimit)
18101 + buf->f_blocks = blimit;
18103 + /* reduce free space to min */
18104 + if (bfree < buf->f_bfree)
18105 + buf->f_bfree = bfree;
18107 + /* reduce avail space to min */
18108 + if (bavail < buf->f_bavail)
18109 + buf->f_bavail = bavail;
18112 + spin_unlock(&dli->dl_lock);
18113 + put_dl_info(dli);
18118 +#include <linux/module.h>
18120 +EXPORT_SYMBOL_GPL(locate_dl_info);
18121 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18123 diff -NurpP --minimal linux-3.10.15/kernel/vserver/helper.c linux-3.10.15-vs2.3.6.6/kernel/vserver/helper.c
18124 --- linux-3.10.15/kernel/vserver/helper.c 1970-01-01 00:00:00.000000000 +0000
18125 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/helper.c 2013-08-23 00:55:48.000000000 +0000
18128 + * linux/kernel/vserver/helper.c
18130 + * Virtual Context Support
18132 + * Copyright (C) 2004-2007 Herbert Pötzl
18134 + * V0.01 basic helper
18138 +#include <linux/kmod.h>
18139 +#include <linux/reboot.h>
18140 +#include <linux/vs_context.h>
18141 +#include <linux/vs_network.h>
18142 +#include <linux/vserver/signal.h>
18145 +char vshelper_path[255] = "/sbin/vshelper";
18147 +static int vshelper_init(struct subprocess_info *info, struct cred *new_cred)
18149 + current->flags &= ~PF_NO_SETAFFINITY;
18153 +static int vs_call_usermodehelper(char *path, char **argv, char **envp, int wait)
18155 + struct subprocess_info *info;
18156 + gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
18158 + info = call_usermodehelper_setup(path, argv, envp, gfp_mask,
18159 + vshelper_init, NULL, NULL);
18160 + if (info == NULL)
18163 + return call_usermodehelper_exec(info, wait);
18166 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18170 + if ((ret = vs_call_usermodehelper(name, argv, envp,
18171 + sync ? UMH_WAIT_PROC : UMH_WAIT_EXEC))) {
18172 + printk(KERN_WARNING "%s: (%s %s) returned %s with %d\n",
18173 + name, argv[1], argv[2],
18174 + sync ? "sync" : "async", ret);
18176 + vxdprintk(VXD_CBIT(switch, 4),
18177 + "%s: (%s %s) returned %s with %d",
18178 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18183 + * vshelper path is set via /proc/sys
18184 + * invoked by vserver sys_reboot(), with
18185 + * the following arguments
18187 + * argv [0] = vshelper_path;
18188 + * argv [1] = action: "restart", "halt", "poweroff", ...
18189 + * argv [2] = context identifier
18191 + * envp [*] = type-specific parameters
18194 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18196 + char id_buf[8], cmd_buf[16];
18197 + char uid_buf[16], pid_buf[16];
18200 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18201 + char *envp[] = {"HOME=/", "TERM=linux",
18202 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18203 + uid_buf, pid_buf, cmd_buf, 0};
18205 + if (vx_info_state(vxi, VXS_HELPER))
18207 + vxi->vx_state |= VXS_HELPER;
18209 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18211 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18212 + snprintf(uid_buf, sizeof(uid_buf), "VS_UID=%d",
18213 + from_kuid(&init_user_ns, current_uid()));
18214 + snprintf(pid_buf, sizeof(pid_buf), "VS_PID=%d", current->pid);
18217 + case LINUX_REBOOT_CMD_RESTART:
18218 + argv[1] = "restart";
18221 + case LINUX_REBOOT_CMD_HALT:
18222 + argv[1] = "halt";
18225 + case LINUX_REBOOT_CMD_POWER_OFF:
18226 + argv[1] = "poweroff";
18229 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18230 + argv[1] = "swsusp";
18233 + case LINUX_REBOOT_CMD_OOM:
18238 + vxi->vx_state &= ~VXS_HELPER;
18242 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18243 + vxi->vx_state &= ~VXS_HELPER;
18244 + __wakeup_vx_info(vxi);
18245 + return (ret) ? -EPERM : 0;
18249 +long vs_reboot(unsigned int cmd, void __user *arg)
18251 + struct vx_info *vxi = current_vx_info();
18254 + vxdprintk(VXD_CBIT(misc, 5),
18255 + "vs_reboot(%p[#%d],%u)",
18256 + vxi, vxi ? vxi->vx_id : 0, cmd);
18258 + ret = vs_reboot_helper(vxi, cmd, arg);
18262 + vxi->reboot_cmd = cmd;
18263 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18265 + case LINUX_REBOOT_CMD_RESTART:
18266 + case LINUX_REBOOT_CMD_HALT:
18267 + case LINUX_REBOOT_CMD_POWER_OFF:
18268 + vx_info_kill(vxi, 0, SIGKILL);
18269 + vx_info_kill(vxi, 1, SIGKILL);
18277 +long vs_oom_action(unsigned int cmd)
18279 + struct vx_info *vxi = current_vx_info();
18282 + vxdprintk(VXD_CBIT(misc, 5),
18283 + "vs_oom_action(%p[#%d],%u)",
18284 + vxi, vxi ? vxi->vx_id : 0, cmd);
18286 + ret = vs_reboot_helper(vxi, cmd, NULL);
18290 + vxi->reboot_cmd = cmd;
18291 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18292 + vx_info_kill(vxi, 0, SIGKILL);
18293 + vx_info_kill(vxi, 1, SIGKILL);
18299 + * argv [0] = vshelper_path;
18300 + * argv [1] = action: "startup", "shutdown"
18301 + * argv [2] = context identifier
18303 + * envp [*] = type-specific parameters
18306 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18308 + char id_buf[8], cmd_buf[16];
18309 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18310 + char *envp[] = {"HOME=/", "TERM=linux",
18311 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18313 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18316 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18317 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18320 + case VSC_STARTUP:
18321 + argv[1] = "startup";
18323 + case VSC_SHUTDOWN:
18324 + argv[1] = "shutdown";
18330 + return do_vshelper(vshelper_path, argv, envp, 1);
18335 + * argv [0] = vshelper_path;
18336 + * argv [1] = action: "netup", "netdown"
18337 + * argv [2] = context identifier
18339 + * envp [*] = type-specific parameters
18342 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18344 + char id_buf[8], cmd_buf[16];
18345 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18346 + char *envp[] = {"HOME=/", "TERM=linux",
18347 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18349 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18352 + snprintf(id_buf, sizeof(id_buf), "%d", nxi->nx_id);
18353 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18357 + argv[1] = "netup";
18359 + case VSC_NETDOWN:
18360 + argv[1] = "netdown";
18366 + return do_vshelper(vshelper_path, argv, envp, 1);
18369 diff -NurpP --minimal linux-3.10.15/kernel/vserver/history.c linux-3.10.15-vs2.3.6.6/kernel/vserver/history.c
18370 --- linux-3.10.15/kernel/vserver/history.c 1970-01-01 00:00:00.000000000 +0000
18371 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/history.c 2013-08-22 20:30:00.000000000 +0000
18374 + * kernel/vserver/history.c
18376 + * Virtual Context History Backtrace
18378 + * Copyright (C) 2004-2007 Herbert Pötzl
18380 + * V0.01 basic structure
18381 + * V0.02 hash/unhash and trace
18382 + * V0.03 preemption fixes
18386 +#include <linux/module.h>
18387 +#include <asm/uaccess.h>
18389 +#include <linux/vserver/context.h>
18390 +#include <linux/vserver/debug.h>
18391 +#include <linux/vserver/debug_cmd.h>
18392 +#include <linux/vserver/history.h>
18395 +#ifdef CONFIG_VSERVER_HISTORY
18396 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18398 +#define VXH_SIZE 64
18401 +struct _vx_history {
18402 + unsigned int counter;
18404 + struct _vx_hist_entry entry[VXH_SIZE + 1];
18408 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
18410 +unsigned volatile int vxh_active = 1;
18412 +static atomic_t sequence = ATOMIC_INIT(0);
18417 + * requires disabled preemption */
18419 +struct _vx_hist_entry *vxh_advance(void *loc)
18421 + unsigned int cpu = smp_processor_id();
18422 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18423 + struct _vx_hist_entry *entry;
18424 + unsigned int index;
18426 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
18427 + entry = &hist->entry[index];
18429 + entry->seq = atomic_inc_return(&sequence);
18430 + entry->loc = loc;
18434 +EXPORT_SYMBOL_GPL(vxh_advance);
18437 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
18439 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
18442 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
18444 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
18445 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
18446 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
18447 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
18449 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
18451 + switch (e->type) {
18452 + case VXH_THROW_OOPS:
18453 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
18456 + case VXH_GET_VX_INFO:
18457 + case VXH_PUT_VX_INFO:
18458 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18460 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
18461 + VXH_VXI_ARGS(e));
18464 + case VXH_INIT_VX_INFO:
18465 + case VXH_SET_VX_INFO:
18466 + case VXH_CLR_VX_INFO:
18467 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18469 + (e->type == VXH_INIT_VX_INFO) ? "init" :
18470 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
18471 + VXH_VXI_ARGS(e), e->sc.data);
18474 + case VXH_CLAIM_VX_INFO:
18475 + case VXH_RELEASE_VX_INFO:
18476 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18478 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
18479 + VXH_VXI_ARGS(e), e->sc.data);
18482 + case VXH_ALLOC_VX_INFO:
18483 + case VXH_DEALLOC_VX_INFO:
18484 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18486 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
18487 + VXH_VXI_ARGS(e));
18490 + case VXH_HASH_VX_INFO:
18491 + case VXH_UNHASH_VX_INFO:
18492 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
18494 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
18495 + VXH_VXI_ARGS(e));
18498 + case VXH_LOC_VX_INFO:
18499 + case VXH_LOOKUP_VX_INFO:
18500 + case VXH_CREATE_VX_INFO:
18501 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
18503 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
18504 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
18505 + e->ll.arg, VXH_VXI_ARGS(e));
18510 +static void __vxh_dump_history(void)
18512 + unsigned int i, cpu;
18514 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
18515 + atomic_read(&sequence), NR_CPUS);
18517 + for (i = 0; i < VXH_SIZE; i++) {
18518 + for_each_online_cpu(cpu) {
18519 + struct _vx_history *hist =
18520 + &per_cpu(vx_history_buffer, cpu);
18521 + unsigned int index = (hist->counter - i) % VXH_SIZE;
18522 + struct _vx_hist_entry *entry = &hist->entry[index];
18524 + vxh_dump_entry(entry, cpu);
18529 +void vxh_dump_history(void)
18533 + local_irq_enable();
18535 + local_irq_disable();
18537 + __vxh_dump_history();
18541 +/* vserver syscall commands below here */
18544 +int vc_dump_history(uint32_t id)
18547 + __vxh_dump_history();
18554 +int do_read_history(struct __user _vx_hist_entry *data,
18555 + int cpu, uint32_t *index, uint32_t *count)
18557 + int pos, ret = 0;
18558 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18559 + int end = hist->counter;
18560 + int start = end - VXH_SIZE + 2;
18561 + int idx = *index;
18563 + /* special case: get current pos */
18569 + /* have we lost some data? */
18573 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
18574 + struct _vx_hist_entry *entry =
18575 + &hist->entry[idx % VXH_SIZE];
18577 + /* send entry to userspace */
18578 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
18582 + /* save new index and count */
18585 + return ret ? ret : (*index < end);
18588 +int vc_read_history(uint32_t id, void __user *data)
18590 + struct vcmd_read_history_v0 vc_data;
18593 + if (id >= NR_CPUS)
18596 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18599 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
18600 + id, &vc_data.index, &vc_data.count);
18602 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18607 +#ifdef CONFIG_COMPAT
18609 +int vc_read_history_x32(uint32_t id, void __user *data)
18611 + struct vcmd_read_history_v0_x32 vc_data;
18614 + if (id >= NR_CPUS)
18617 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18620 + ret = do_read_history((struct __user _vx_hist_entry *)
18621 + compat_ptr(vc_data.data_ptr),
18622 + id, &vc_data.index, &vc_data.count);
18624 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18629 +#endif /* CONFIG_COMPAT */
18631 diff -NurpP --minimal linux-3.10.15/kernel/vserver/inet.c linux-3.10.15-vs2.3.6.6/kernel/vserver/inet.c
18632 --- linux-3.10.15/kernel/vserver/inet.c 1970-01-01 00:00:00.000000000 +0000
18633 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/inet.c 2013-08-22 20:30:00.000000000 +0000
18636 +#include <linux/in.h>
18637 +#include <linux/inetdevice.h>
18638 +#include <linux/export.h>
18639 +#include <linux/vs_inet.h>
18640 +#include <linux/vs_inet6.h>
18641 +#include <linux/vserver/debug.h>
18642 +#include <net/route.h>
18643 +#include <net/addrconf.h>
18646 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
18650 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
18653 + struct nx_addr_v4 *ptr;
18654 + unsigned long irqflags;
18656 + spin_lock_irqsave(&nxi1->addr_lock, irqflags);
18657 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
18658 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
18663 + spin_unlock_irqrestore(&nxi1->addr_lock, irqflags);
18666 + vxdprintk(VXD_CBIT(net, 2),
18667 + "nx_v4_addr_conflict(%p,%p): %d",
18668 + nxi1, nxi2, ret);
18674 +#ifdef CONFIG_IPV6
18676 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
18680 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
18683 + struct nx_addr_v6 *ptr;
18684 + unsigned long irqflags;
18686 + spin_lock_irqsave(&nxi1->addr_lock, irqflags);
18687 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
18688 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
18693 + spin_unlock_irqrestore(&nxi1->addr_lock, irqflags);
18696 + vxdprintk(VXD_CBIT(net, 2),
18697 + "nx_v6_addr_conflict(%p,%p): %d",
18698 + nxi1, nxi2, ret);
18705 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18707 + struct in_device *in_dev;
18708 + struct in_ifaddr **ifap;
18709 + struct in_ifaddr *ifa;
18714 + in_dev = in_dev_get(dev);
18718 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
18719 + ifap = &ifa->ifa_next) {
18720 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
18725 + in_dev_put(in_dev);
18731 +#ifdef CONFIG_IPV6
18733 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18735 + struct inet6_dev *in_dev;
18736 + struct inet6_ifaddr *ifa;
18741 + in_dev = in6_dev_get(dev);
18745 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
18746 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
18747 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
18752 + in6_dev_put(in_dev);
18759 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18765 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
18767 +#ifdef CONFIG_IPV6
18769 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
18774 + vxdprintk(VXD_CBIT(net, 3),
18775 + "dev_in_nx_info(%p,%p[#%d]) = %d",
18776 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
18780 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
18781 + struct flowi4 *fl4)
18783 + struct rtable *rt;
18788 + /* FIXME: handle lback only case */
18789 + if (!NX_IPV4(nxi))
18790 + return ERR_PTR(-EPERM);
18792 + vxdprintk(VXD_CBIT(net, 4),
18793 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
18794 + nxi, nxi ? nxi->nx_id : 0,
18795 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
18797 + /* single IP is unconditional */
18798 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
18799 + (fl4->saddr == INADDR_ANY))
18800 + fl4->saddr = nxi->v4.ip[0].s_addr;
18802 + if (fl4->saddr == INADDR_ANY) {
18803 + struct nx_addr_v4 *ptr;
18804 + __be32 found = 0;
18806 + rt = __ip_route_output_key(net, fl4);
18807 + if (!IS_ERR(rt)) {
18808 + found = fl4->saddr;
18810 + vxdprintk(VXD_CBIT(net, 4),
18811 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
18812 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
18813 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
18817 + WARN_ON_ONCE(in_irq());
18818 + spin_lock_bh(&nxi->addr_lock);
18819 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
18820 + __be32 primary = ptr->ip[0].s_addr;
18821 + __be32 mask = ptr->mask.s_addr;
18822 + __be32 neta = primary & mask;
18824 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
18825 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
18826 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
18827 + NIPQUAD(mask), NIPQUAD(neta));
18828 + if ((found & mask) != neta)
18831 + fl4->saddr = primary;
18832 + rt = __ip_route_output_key(net, fl4);
18833 + vxdprintk(VXD_CBIT(net, 4),
18834 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
18835 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
18836 + if (!IS_ERR(rt)) {
18837 + found = fl4->saddr;
18839 + if (found == primary)
18840 + goto found_unlock;
18843 + /* still no source ip? */
18844 + found = ipv4_is_loopback(fl4->daddr)
18845 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
18847 + spin_unlock_bh(&nxi->addr_lock);
18849 + /* assign src ip to flow */
18850 + fl4->saddr = found;
18853 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
18854 + return ERR_PTR(-EPERM);
18857 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
18858 + if (ipv4_is_loopback(fl4->daddr))
18859 + fl4->daddr = nxi->v4_lback.s_addr;
18860 + if (ipv4_is_loopback(fl4->saddr))
18861 + fl4->saddr = nxi->v4_lback.s_addr;
18862 + } else if (ipv4_is_loopback(fl4->daddr) &&
18863 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
18864 + return ERR_PTR(-EPERM);
18869 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
18871 diff -NurpP --minimal linux-3.10.15/kernel/vserver/init.c linux-3.10.15-vs2.3.6.6/kernel/vserver/init.c
18872 --- linux-3.10.15/kernel/vserver/init.c 1970-01-01 00:00:00.000000000 +0000
18873 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/init.c 2013-08-22 20:30:00.000000000 +0000
18876 + * linux/kernel/init.c
18878 + * Virtual Server Init
18880 + * Copyright (C) 2004-2007 Herbert Pötzl
18882 + * V0.01 basic structure
18886 +#include <linux/init.h>
18888 +int vserver_register_sysctl(void);
18889 +void vserver_unregister_sysctl(void);
18892 +static int __init init_vserver(void)
18896 +#ifdef CONFIG_VSERVER_DEBUG
18897 + vserver_register_sysctl();
18903 +static void __exit exit_vserver(void)
18906 +#ifdef CONFIG_VSERVER_DEBUG
18907 + vserver_unregister_sysctl();
18912 +/* FIXME: GFP_ZONETYPES gone
18913 +long vx_slab[GFP_ZONETYPES]; */
18917 +module_init(init_vserver);
18918 +module_exit(exit_vserver);
18920 diff -NurpP --minimal linux-3.10.15/kernel/vserver/inode.c linux-3.10.15-vs2.3.6.6/kernel/vserver/inode.c
18921 --- linux-3.10.15/kernel/vserver/inode.c 1970-01-01 00:00:00.000000000 +0000
18922 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/inode.c 2013-08-22 23:14:01.000000000 +0000
18925 + * linux/kernel/vserver/inode.c
18927 + * Virtual Server: File System Support
18929 + * Copyright (C) 2004-2007 Herbert Pötzl
18931 + * V0.01 separated from vcontext V0.05
18932 + * V0.02 moved to tag (instead of xid)
18936 +#include <linux/tty.h>
18937 +#include <linux/proc_fs.h>
18938 +#include <linux/devpts_fs.h>
18939 +#include <linux/fs.h>
18940 +#include <linux/file.h>
18941 +#include <linux/mount.h>
18942 +#include <linux/parser.h>
18943 +#include <linux/namei.h>
18944 +#include <linux/magic.h>
18945 +#include <linux/slab.h>
18946 +#include <linux/vserver/inode.h>
18947 +#include <linux/vserver/inode_cmd.h>
18948 +#include <linux/vs_base.h>
18949 +#include <linux/vs_tag.h>
18951 +#include <asm/uaccess.h>
18952 +#include <../../fs/proc/internal.h>
18955 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
18957 + struct proc_dir_entry *entry;
18959 + if (!in || !in->i_sb)
18962 + *flags = IATTR_TAG
18963 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
18964 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
18965 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
18966 + | (IS_COW(in) ? IATTR_COW : 0);
18967 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
18969 + if (S_ISDIR(in->i_mode))
18970 + *mask |= IATTR_BARRIER;
18972 + if (IS_TAGGED(in)) {
18973 + *tag = i_tag_read(in);
18974 + *mask |= IATTR_TAG;
18977 + switch (in->i_sb->s_magic) {
18978 + case PROC_SUPER_MAGIC:
18979 + entry = PROC_I(in)->pde;
18981 + /* check for specific inodes? */
18983 + *mask |= IATTR_FLAGS;
18985 + *flags |= (entry->vx_flags & IATTR_FLAGS);
18987 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
18990 + case DEVPTS_SUPER_MAGIC:
18991 + *tag = i_tag_read(in);
18992 + *mask |= IATTR_TAG;
19001 +int vc_get_iattr(void __user *data)
19003 + struct path path;
19004 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19007 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19010 + ret = user_lpath(vc_data.name, &path);
19012 + ret = __vc_get_iattr(path.dentry->d_inode,
19013 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19019 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19024 +#ifdef CONFIG_COMPAT
19026 +int vc_get_iattr_x32(void __user *data)
19028 + struct path path;
19029 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19032 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19035 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19037 + ret = __vc_get_iattr(path.dentry->d_inode,
19038 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19044 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19049 +#endif /* CONFIG_COMPAT */
19052 +int vc_fget_iattr(uint32_t fd, void __user *data)
19054 + struct file *filp;
19055 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19058 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19062 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19065 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19066 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19070 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19076 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19078 + struct inode *in = de->d_inode;
19079 + int error = 0, is_proc = 0, has_tag = 0;
19080 + struct iattr attr = { 0 };
19082 + if (!in || !in->i_sb)
19085 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19086 + if ((*mask & IATTR_FLAGS) && !is_proc)
19089 + has_tag = IS_TAGGED(in) ||
19090 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19091 + if ((*mask & IATTR_TAG) && !has_tag)
19094 + mutex_lock(&in->i_mutex);
19095 + if (*mask & IATTR_TAG) {
19096 + attr.ia_tag = make_ktag(&init_user_ns, *tag);
19097 + attr.ia_valid |= ATTR_TAG;
19100 + if (*mask & IATTR_FLAGS) {
19101 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19102 + unsigned int iflags = PROC_I(in)->vx_flags;
19104 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19105 + | (*flags & IATTR_FLAGS);
19106 + PROC_I(in)->vx_flags = iflags;
19108 + entry->vx_flags = iflags;
19111 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19112 + IATTR_BARRIER | IATTR_COW)) {
19113 + int iflags = in->i_flags;
19114 + int vflags = in->i_vflags;
19116 + if (*mask & IATTR_IMMUTABLE) {
19117 + if (*flags & IATTR_IMMUTABLE)
19118 + iflags |= S_IMMUTABLE;
19120 + iflags &= ~S_IMMUTABLE;
19122 + if (*mask & IATTR_IXUNLINK) {
19123 + if (*flags & IATTR_IXUNLINK)
19124 + iflags |= S_IXUNLINK;
19126 + iflags &= ~S_IXUNLINK;
19128 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19129 + if (*flags & IATTR_BARRIER)
19130 + vflags |= V_BARRIER;
19132 + vflags &= ~V_BARRIER;
19134 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19135 + if (*flags & IATTR_COW)
19138 + vflags &= ~V_COW;
19140 + if (in->i_op && in->i_op->sync_flags) {
19141 + error = in->i_op->sync_flags(in, iflags, vflags);
19147 + if (attr.ia_valid) {
19148 + if (in->i_op && in->i_op->setattr)
19149 + error = in->i_op->setattr(de, &attr);
19151 + error = inode_change_ok(in, &attr);
19153 + setattr_copy(in, &attr);
19154 + mark_inode_dirty(in);
19160 + mutex_unlock(&in->i_mutex);
19164 +int vc_set_iattr(void __user *data)
19166 + struct path path;
19167 + struct vcmd_ctx_iattr_v1 vc_data;
19170 + if (!capable(CAP_LINUX_IMMUTABLE))
19172 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19175 + ret = user_lpath(vc_data.name, &path);
19177 + ret = __vc_set_iattr(path.dentry,
19178 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19182 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19187 +#ifdef CONFIG_COMPAT
19189 +int vc_set_iattr_x32(void __user *data)
19191 + struct path path;
19192 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19195 + if (!capable(CAP_LINUX_IMMUTABLE))
19197 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19200 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19202 + ret = __vc_set_iattr(path.dentry,
19203 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19207 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19212 +#endif /* CONFIG_COMPAT */
19214 +int vc_fset_iattr(uint32_t fd, void __user *data)
19216 + struct file *filp;
19217 + struct vcmd_ctx_fiattr_v0 vc_data;
19220 + if (!capable(CAP_LINUX_IMMUTABLE))
19222 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19226 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19229 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19230 + &vc_data.flags, &vc_data.mask);
19234 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19240 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19242 +static match_table_t tokens = {
19243 + {Opt_notagcheck, "notagcheck"},
19244 +#ifdef CONFIG_PROPAGATE
19245 + {Opt_notag, "notag"},
19246 + {Opt_tag, "tag"},
19247 + {Opt_tagid, "tagid=%u"},
19253 +static void __dx_parse_remove(char *string, char *opt)
19255 + char *p = strstr(string, opt);
19259 + while (*q != '\0' && *q != ',')
19268 +int dx_parse_tag(char *string, vtag_t *tag, int remove, int *mnt_flags,
19269 + unsigned long *flags)
19272 + substring_t args[MAX_OPT_ARGS];
19274 + char *s, *p, *opts;
19275 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19281 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19286 + while ((p = strsep(&opts, ",")) != NULL) {
19287 + token = match_token(p, tokens, args);
19290 +#ifdef CONFIG_PROPAGATE
19295 + __dx_parse_remove(s, "tag");
19296 + *mnt_flags |= MNT_TAGID;
19297 + set |= MNT_TAGID;
19301 + __dx_parse_remove(s, "notag");
19302 + *mnt_flags |= MNT_NOTAG;
19303 + set |= MNT_NOTAG;
19306 + if (tag && !match_int(args, &option))
19309 + __dx_parse_remove(s, "tagid");
19310 + *mnt_flags |= MNT_TAGID;
19311 + set |= MNT_TAGID;
19313 +#endif /* CONFIG_PROPAGATE */
19314 + case Opt_notagcheck:
19316 + __dx_parse_remove(s, "notagcheck");
19317 + *flags |= MS_NOTAGCHECK;
19318 + set |= MS_NOTAGCHECK;
19321 + vxdprintk(VXD_CBIT(tag, 7),
19322 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19323 + p, token, option);
19326 + strcpy(string, s);
19331 +#ifdef CONFIG_PROPAGATE
19333 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19335 + vtag_t new_tag = 0;
19336 + struct vfsmount *mnt;
19341 + mnt = nd->path.mnt;
19345 + propagate = (mnt->mnt_flags & MNT_TAGID);
19347 + new_tag = mnt->mnt_tag;
19349 + vxdprintk(VXD_CBIT(tag, 7),
19350 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19351 + inode, inode->i_ino, inode->i_tag,
19352 + new_tag, (propagate) ? 1 : 0);
19355 + i_tag_write(inode, new_tag);
19358 +#include <linux/module.h>
19360 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19362 +#endif /* CONFIG_PROPAGATE */
19364 diff -NurpP --minimal linux-3.10.15/kernel/vserver/limit.c linux-3.10.15-vs2.3.6.6/kernel/vserver/limit.c
19365 --- linux-3.10.15/kernel/vserver/limit.c 1970-01-01 00:00:00.000000000 +0000
19366 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/limit.c 2013-08-22 20:30:00.000000000 +0000
19369 + * linux/kernel/vserver/limit.c
19371 + * Virtual Server: Context Limits
19373 + * Copyright (C) 2004-2010 Herbert Pötzl
19375 + * V0.01 broken out from vcontext V0.05
19376 + * V0.02 changed vcmds to vxi arg
19377 + * V0.03 added memory cgroup support
19381 +#include <linux/sched.h>
19382 +#include <linux/module.h>
19383 +#include <linux/memcontrol.h>
19384 +#include <linux/res_counter.h>
19385 +#include <linux/vs_limit.h>
19386 +#include <linux/vserver/limit.h>
19387 +#include <linux/vserver/limit_cmd.h>
19389 +#include <asm/uaccess.h>
19392 +const char *vlimit_name[NUM_LIMITS] = {
19393 + [RLIMIT_CPU] = "CPU",
19394 + [RLIMIT_NPROC] = "NPROC",
19395 + [RLIMIT_NOFILE] = "NOFILE",
19396 + [RLIMIT_LOCKS] = "LOCKS",
19397 + [RLIMIT_SIGPENDING] = "SIGP",
19398 + [RLIMIT_MSGQUEUE] = "MSGQ",
19400 + [VLIMIT_NSOCK] = "NSOCK",
19401 + [VLIMIT_OPENFD] = "OPENFD",
19402 + [VLIMIT_SHMEM] = "SHMEM",
19403 + [VLIMIT_DENTRY] = "DENTRY",
19406 +EXPORT_SYMBOL_GPL(vlimit_name);
19408 +#define MASK_ENTRY(x) (1 << (x))
19410 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
19413 + , /* softlimit */
19416 + MASK_ENTRY( RLIMIT_NPROC ) |
19417 + MASK_ENTRY( RLIMIT_NOFILE ) |
19418 + MASK_ENTRY( RLIMIT_LOCKS ) |
19419 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
19421 + MASK_ENTRY( VLIMIT_NSOCK ) |
19422 + MASK_ENTRY( VLIMIT_OPENFD ) |
19423 + MASK_ENTRY( VLIMIT_SHMEM ) |
19424 + MASK_ENTRY( VLIMIT_DENTRY ) |
19427 + /* accounting only */
19428 +uint32_t account_mask =
19429 + MASK_ENTRY( VLIMIT_SEMARY ) |
19430 + MASK_ENTRY( VLIMIT_NSEMS ) |
19431 + MASK_ENTRY( VLIMIT_MAPPED ) |
19435 +static int is_valid_vlimit(int id)
19437 + uint32_t mask = vlimit_mask.minimum |
19438 + vlimit_mask.softlimit | vlimit_mask.maximum;
19439 + return mask & (1 << id);
19442 +static int is_accounted_vlimit(int id)
19444 + if (is_valid_vlimit(id))
19446 + return account_mask & (1 << id);
19450 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
19452 + rlim_t limit = __rlim_soft(&vxi->limit, id);
19453 + return VX_VLIM(limit);
19456 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
19458 + rlim_t limit = __rlim_hard(&vxi->limit, id);
19459 + return VX_VLIM(limit);
19462 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
19463 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
19465 + if (!is_valid_vlimit(id))
19469 + *minimum = CRLIM_UNSET;
19471 + *softlimit = vc_get_soft(vxi, id);
19473 + *maximum = vc_get_hard(vxi, id);
19477 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
19479 + struct vcmd_ctx_rlimit_v0 vc_data;
19482 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19485 + ret = do_get_rlimit(vxi, vc_data.id,
19486 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19490 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19495 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
19496 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
19498 + if (!is_valid_vlimit(id))
19501 + if (maximum != CRLIM_KEEP)
19502 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
19503 + if (softlimit != CRLIM_KEEP)
19504 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
19506 + /* clamp soft limit */
19507 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
19508 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
19513 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
19515 + struct vcmd_ctx_rlimit_v0 vc_data;
19517 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19520 + return do_set_rlimit(vxi, vc_data.id,
19521 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19524 +#ifdef CONFIG_IA32_EMULATION
19526 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
19528 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19530 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19533 + return do_set_rlimit(vxi, vc_data.id,
19534 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19537 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
19539 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19542 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19545 + ret = do_get_rlimit(vxi, vc_data.id,
19546 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19550 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19555 +#endif /* CONFIG_IA32_EMULATION */
19558 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
19560 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
19566 +static inline void vx_reset_hits(struct _vx_limit *limit)
19570 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19571 + atomic_set(&__rlim_lhit(limit, lim), 0);
19575 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
19577 + vx_reset_hits(&vxi->limit);
19581 +static inline void vx_reset_minmax(struct _vx_limit *limit)
19586 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19587 + value = __rlim_get(limit, lim);
19588 + __rlim_rmax(limit, lim) = value;
19589 + __rlim_rmin(limit, lim) = value;
19593 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
19595 + vx_reset_minmax(&vxi->limit);
19600 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
19602 + struct vcmd_rlimit_stat_v0 vc_data;
19603 + struct _vx_limit *limit = &vxi->limit;
19606 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19610 + if (!is_accounted_vlimit(id))
19613 + vx_limit_fixup(limit, id);
19614 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
19615 + vc_data.value = __rlim_get(limit, id);
19616 + vc_data.minimum = __rlim_rmin(limit, id);
19617 + vc_data.maximum = __rlim_rmax(limit, id);
19619 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19625 +void vx_vsi_meminfo(struct sysinfo *val)
19627 +#ifdef CONFIG_MEMCG
19628 + struct mem_cgroup *mcg;
19629 + u64 res_limit, res_usage;
19632 + mcg = mem_cgroup_from_task(current);
19633 + rcu_read_unlock();
19637 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19638 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19640 + if (res_limit != RESOURCE_MAX)
19641 + val->totalram = (res_limit >> PAGE_SHIFT);
19642 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
19643 + val->bufferram = 0;
19644 + val->totalhigh = 0;
19645 + val->freehigh = 0;
19647 +#endif /* CONFIG_MEMCG */
19651 +void vx_vsi_swapinfo(struct sysinfo *val)
19653 +#ifdef CONFIG_MEMCG
19654 +#ifdef CONFIG_MEMCG_SWAP
19655 + struct mem_cgroup *mcg;
19656 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
19657 + s64 swap_limit, swap_usage;
19660 + mcg = mem_cgroup_from_task(current);
19661 + rcu_read_unlock();
19665 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19666 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19667 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
19668 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
19670 + /* memory unlimited */
19671 + if (res_limit == RESOURCE_MAX)
19674 + swap_limit = memsw_limit - res_limit;
19675 + /* we have a swap limit? */
19676 + if (memsw_limit != RESOURCE_MAX)
19677 + val->totalswap = swap_limit >> PAGE_SHIFT;
19679 + /* calculate swap part */
19680 + swap_usage = (memsw_usage > res_usage) ?
19681 + memsw_usage - res_usage : 0;
19683 + /* total shown minus usage gives free swap */
19684 + val->freeswap = (swap_usage < swap_limit) ?
19685 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
19687 +#else /* !CONFIG_MEMCG_SWAP */
19688 + val->totalswap = 0;
19689 + val->freeswap = 0;
19690 +#endif /* !CONFIG_MEMCG_SWAP */
19691 +#endif /* CONFIG_MEMCG */
19695 +long vx_vsi_cached(struct sysinfo *val)
19698 +#ifdef CONFIG_MEMCG
19699 + struct mem_cgroup *mcg;
19702 + mcg = mem_cgroup_from_task(current);
19703 + rcu_read_unlock();
19707 + cache = mem_cgroup_stat_read_cache(mcg);
19713 diff -NurpP --minimal linux-3.10.15/kernel/vserver/limit_init.h linux-3.10.15-vs2.3.6.6/kernel/vserver/limit_init.h
19714 --- linux-3.10.15/kernel/vserver/limit_init.h 1970-01-01 00:00:00.000000000 +0000
19715 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/limit_init.h 2013-08-22 20:30:00.000000000 +0000
19719 +static inline void vx_info_init_limit(struct _vx_limit *limit)
19723 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19724 + __rlim_soft(limit, lim) = RLIM_INFINITY;
19725 + __rlim_hard(limit, lim) = RLIM_INFINITY;
19726 + __rlim_set(limit, lim, 0);
19727 + atomic_set(&__rlim_lhit(limit, lim), 0);
19728 + __rlim_rmin(limit, lim) = 0;
19729 + __rlim_rmax(limit, lim) = 0;
19733 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
19738 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19739 + if ((1 << lim) & VLIM_NOCHECK)
19741 + value = __rlim_get(limit, lim);
19742 + vxwprintk_xid(value,
19743 + "!!! limit: %p[%s,%d] = %ld on exit.",
19744 + limit, vlimit_name[lim], lim, (long)value);
19748 diff -NurpP --minimal linux-3.10.15/kernel/vserver/limit_proc.h linux-3.10.15-vs2.3.6.6/kernel/vserver/limit_proc.h
19749 --- linux-3.10.15/kernel/vserver/limit_proc.h 1970-01-01 00:00:00.000000000 +0000
19750 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/limit_proc.h 2013-08-22 20:30:00.000000000 +0000
19752 +#ifndef _VX_LIMIT_PROC_H
19753 +#define _VX_LIMIT_PROC_H
19755 +#include <linux/vserver/limit_int.h>
19758 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
19759 +#define VX_LIMIT_TOP \
19760 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
19762 +#define VX_LIMIT_ARG(r) \
19763 + (unsigned long)__rlim_get(limit, r), \
19764 + (unsigned long)__rlim_rmin(limit, r), \
19765 + (unsigned long)__rlim_rmax(limit, r), \
19766 + VX_VLIM(__rlim_soft(limit, r)), \
19767 + VX_VLIM(__rlim_hard(limit, r)), \
19768 + atomic_read(&__rlim_lhit(limit, r))
19770 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
19772 + vx_limit_fixup(limit, -1);
19773 + return sprintf(buffer, VX_LIMIT_TOP
19774 + "PROC" VX_LIMIT_FMT
19775 + "VM" VX_LIMIT_FMT
19776 + "VML" VX_LIMIT_FMT
19777 + "RSS" VX_LIMIT_FMT
19778 + "ANON" VX_LIMIT_FMT
19779 + "RMAP" VX_LIMIT_FMT
19780 + "FILES" VX_LIMIT_FMT
19781 + "OFD" VX_LIMIT_FMT
19782 + "LOCKS" VX_LIMIT_FMT
19783 + "SOCK" VX_LIMIT_FMT
19784 + "MSGQ" VX_LIMIT_FMT
19785 + "SHM" VX_LIMIT_FMT
19786 + "SEMA" VX_LIMIT_FMT
19787 + "SEMS" VX_LIMIT_FMT
19788 + "DENT" VX_LIMIT_FMT,
19789 + VX_LIMIT_ARG(RLIMIT_NPROC),
19790 + VX_LIMIT_ARG(RLIMIT_AS),
19791 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
19792 + VX_LIMIT_ARG(RLIMIT_RSS),
19793 + VX_LIMIT_ARG(VLIMIT_ANON),
19794 + VX_LIMIT_ARG(VLIMIT_MAPPED),
19795 + VX_LIMIT_ARG(RLIMIT_NOFILE),
19796 + VX_LIMIT_ARG(VLIMIT_OPENFD),
19797 + VX_LIMIT_ARG(RLIMIT_LOCKS),
19798 + VX_LIMIT_ARG(VLIMIT_NSOCK),
19799 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
19800 + VX_LIMIT_ARG(VLIMIT_SHMEM),
19801 + VX_LIMIT_ARG(VLIMIT_SEMARY),
19802 + VX_LIMIT_ARG(VLIMIT_NSEMS),
19803 + VX_LIMIT_ARG(VLIMIT_DENTRY));
19806 +#endif /* _VX_LIMIT_PROC_H */
19809 diff -NurpP --minimal linux-3.10.15/kernel/vserver/network.c linux-3.10.15-vs2.3.6.6/kernel/vserver/network.c
19810 --- linux-3.10.15/kernel/vserver/network.c 1970-01-01 00:00:00.000000000 +0000
19811 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/network.c 2013-08-22 20:30:00.000000000 +0000
19814 + * linux/kernel/vserver/network.c
19816 + * Virtual Server: Network Support
19818 + * Copyright (C) 2003-2007 Herbert Pötzl
19820 + * V0.01 broken out from vcontext V0.05
19821 + * V0.02 cleaned up implementation
19822 + * V0.03 added equiv nx commands
19823 + * V0.04 switch to RCU based hash
19824 + * V0.05 and back to locking again
19825 + * V0.06 changed vcmds to nxi arg
19826 + * V0.07 have __create claim() the nxi
19830 +#include <linux/err.h>
19831 +#include <linux/slab.h>
19832 +#include <linux/rcupdate.h>
19833 +#include <net/ipv6.h>
19835 +#include <linux/vs_network.h>
19836 +#include <linux/vs_pid.h>
19837 +#include <linux/vserver/network_cmd.h>
19840 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
19841 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
19843 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
19844 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
19847 +static int __init init_network(void)
19849 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
19850 + sizeof(struct nx_addr_v4), 0,
19851 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19852 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
19853 + sizeof(struct nx_addr_v6), 0,
19854 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19859 +/* __alloc_nx_addr_v4() */
19861 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
19863 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
19864 + nx_addr_v4_cachep, GFP_KERNEL);
19866 + if (!IS_ERR(nxa))
19867 + memset(nxa, 0, sizeof(*nxa));
19871 +/* __dealloc_nx_addr_v4() */
19873 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
19875 + kmem_cache_free(nx_addr_v4_cachep, nxa);
19878 +/* __dealloc_nx_addr_v4_all() */
19880 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
19883 + struct nx_addr_v4 *next = nxa->next;
19885 + __dealloc_nx_addr_v4(nxa);
19891 +#ifdef CONFIG_IPV6
19893 +/* __alloc_nx_addr_v6() */
19895 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
19897 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
19898 + nx_addr_v6_cachep, GFP_KERNEL);
19900 + if (!IS_ERR(nxa))
19901 + memset(nxa, 0, sizeof(*nxa));
19905 +/* __dealloc_nx_addr_v6() */
19907 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
19909 + kmem_cache_free(nx_addr_v6_cachep, nxa);
19912 +/* __dealloc_nx_addr_v6_all() */
19914 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
19917 + struct nx_addr_v6 *next = nxa->next;
19919 + __dealloc_nx_addr_v6(nxa);
19924 +#endif /* CONFIG_IPV6 */
19926 +/* __alloc_nx_info()
19928 + * allocate an initialized nx_info struct
19929 + * doesn't make it visible (hash) */
19931 +static struct nx_info *__alloc_nx_info(vnid_t nid)
19933 + struct nx_info *new = NULL;
19935 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
19937 + /* would this benefit from a slab cache? */
19938 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
19942 + memset(new, 0, sizeof(struct nx_info));
19943 + new->nx_id = nid;
19944 + INIT_HLIST_NODE(&new->nx_hlist);
19945 + atomic_set(&new->nx_usecnt, 0);
19946 + atomic_set(&new->nx_tasks, 0);
19947 + spin_lock_init(&new->addr_lock);
19948 + new->nx_state = 0;
19950 + new->nx_flags = NXF_INIT_SET;
19952 + /* rest of init goes here */
19954 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
19955 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
19957 + vxdprintk(VXD_CBIT(nid, 0),
19958 + "alloc_nx_info(%d) = %p", nid, new);
19959 + atomic_inc(&nx_global_ctotal);
19963 +/* __dealloc_nx_info()
19965 + * final disposal of nx_info */
19967 +static void __dealloc_nx_info(struct nx_info *nxi)
19969 + vxdprintk(VXD_CBIT(nid, 0),
19970 + "dealloc_nx_info(%p)", nxi);
19972 + nxi->nx_hlist.next = LIST_POISON1;
19975 + BUG_ON(atomic_read(&nxi->nx_usecnt));
19976 + BUG_ON(atomic_read(&nxi->nx_tasks));
19978 + __dealloc_nx_addr_v4_all(nxi->v4.next);
19979 +#ifdef CONFIG_IPV6
19980 + __dealloc_nx_addr_v6_all(nxi->v6.next);
19983 + nxi->nx_state |= NXS_RELEASED;
19985 + atomic_dec(&nx_global_ctotal);
19988 +static void __shutdown_nx_info(struct nx_info *nxi)
19990 + nxi->nx_state |= NXS_SHUTDOWN;
19991 + vs_net_change(nxi, VSC_NETDOWN);
19994 +/* exported stuff */
19996 +void free_nx_info(struct nx_info *nxi)
19998 + /* context shutdown is mandatory */
19999 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20001 + /* context must not be hashed */
20002 + BUG_ON(nxi->nx_state & NXS_HASHED);
20004 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20005 + BUG_ON(atomic_read(&nxi->nx_tasks));
20007 + __dealloc_nx_info(nxi);
20011 +void __nx_set_lback(struct nx_info *nxi)
20013 + int nid = nxi->nx_id;
20014 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20016 + nxi->v4_lback.s_addr = lback;
20019 +extern int __nx_inet_add_lback(__be32 addr);
20020 +extern int __nx_inet_del_lback(__be32 addr);
20023 +/* hash table for nx_info hash */
20025 +#define NX_HASH_SIZE 13
20027 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20029 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20032 +static inline unsigned int __hashval(vnid_t nid)
20034 + return (nid % NX_HASH_SIZE);
20039 +/* __hash_nx_info()
20041 + * add the nxi to the global hash table
20042 + * requires the hash_lock to be held */
20044 +static inline void __hash_nx_info(struct nx_info *nxi)
20046 + struct hlist_head *head;
20048 + vxd_assert_lock(&nx_info_hash_lock);
20049 + vxdprintk(VXD_CBIT(nid, 4),
20050 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20052 + /* context must not be hashed */
20053 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20055 + nxi->nx_state |= NXS_HASHED;
20056 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20057 + hlist_add_head(&nxi->nx_hlist, head);
20058 + atomic_inc(&nx_global_cactive);
20061 +/* __unhash_nx_info()
20063 + * remove the nxi from the global hash table
20064 + * requires the hash_lock to be held */
20066 +static inline void __unhash_nx_info(struct nx_info *nxi)
20068 + vxd_assert_lock(&nx_info_hash_lock);
20069 + vxdprintk(VXD_CBIT(nid, 4),
20070 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20071 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20073 + /* context must be hashed */
20074 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20075 + /* but without tasks */
20076 + BUG_ON(atomic_read(&nxi->nx_tasks));
20078 + nxi->nx_state &= ~NXS_HASHED;
20079 + hlist_del(&nxi->nx_hlist);
20080 + atomic_dec(&nx_global_cactive);
20084 +/* __lookup_nx_info()
20086 + * requires the hash_lock to be held
20087 + * doesn't increment the nx_refcnt */
20089 +static inline struct nx_info *__lookup_nx_info(vnid_t nid)
20091 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20092 + struct hlist_node *pos;
20093 + struct nx_info *nxi;
20095 + vxd_assert_lock(&nx_info_hash_lock);
20096 + hlist_for_each(pos, head) {
20097 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20099 + if (nxi->nx_id == nid)
20104 + vxdprintk(VXD_CBIT(nid, 0),
20105 + "__lookup_nx_info(#%u): %p[#%u]",
20106 + nid, nxi, nxi ? nxi->nx_id : 0);
20111 +/* __create_nx_info()
20113 + * create the requested context
20114 + * get(), claim() and hash it */
20116 +static struct nx_info *__create_nx_info(int id)
20118 + struct nx_info *new, *nxi = NULL;
20120 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20122 + if (!(new = __alloc_nx_info(id)))
20123 + return ERR_PTR(-ENOMEM);
20125 + /* required to make dynamic xids unique */
20126 + spin_lock(&nx_info_hash_lock);
20128 + /* static context requested */
20129 + if ((nxi = __lookup_nx_info(id))) {
20130 + vxdprintk(VXD_CBIT(nid, 0),
20131 + "create_nx_info(%d) = %p (already there)", id, nxi);
20132 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20133 + nxi = ERR_PTR(-EBUSY);
20135 + nxi = ERR_PTR(-EEXIST);
20138 + /* new context */
20139 + vxdprintk(VXD_CBIT(nid, 0),
20140 + "create_nx_info(%d) = %p (new)", id, new);
20141 + claim_nx_info(new, NULL);
20142 + __nx_set_lback(new);
20143 + __hash_nx_info(get_nx_info(new));
20144 + nxi = new, new = NULL;
20147 + spin_unlock(&nx_info_hash_lock);
20149 + __dealloc_nx_info(new);
20155 +/* exported stuff */
20158 +void unhash_nx_info(struct nx_info *nxi)
20160 + __shutdown_nx_info(nxi);
20161 + spin_lock(&nx_info_hash_lock);
20162 + __unhash_nx_info(nxi);
20163 + spin_unlock(&nx_info_hash_lock);
20166 +/* lookup_nx_info()
20168 + * search for a nx_info and get() it
20169 + * negative id means current */
20171 +struct nx_info *lookup_nx_info(int id)
20173 + struct nx_info *nxi = NULL;
20176 + nxi = get_nx_info(current_nx_info());
20177 + } else if (id > 1) {
20178 + spin_lock(&nx_info_hash_lock);
20179 + nxi = get_nx_info(__lookup_nx_info(id));
20180 + spin_unlock(&nx_info_hash_lock);
20185 +/* nid_is_hashed()
20187 + * verify that nid is still hashed */
20189 +int nid_is_hashed(vnid_t nid)
20193 + spin_lock(&nx_info_hash_lock);
20194 + hashed = (__lookup_nx_info(nid) != NULL);
20195 + spin_unlock(&nx_info_hash_lock);
20200 +#ifdef CONFIG_PROC_FS
20204 + * get a subset of hashed nids for proc
20205 + * assumes size is at least one */
20207 +int get_nid_list(int index, unsigned int *nids, int size)
20209 + int hindex, nr_nids = 0;
20211 + /* only show current and children */
20212 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20215 + nids[nr_nids] = nx_current_nid();
20219 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20220 + struct hlist_head *head = &nx_info_hash[hindex];
20221 + struct hlist_node *pos;
20223 + spin_lock(&nx_info_hash_lock);
20224 + hlist_for_each(pos, head) {
20225 + struct nx_info *nxi;
20230 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20231 + nids[nr_nids] = nxi->nx_id;
20232 + if (++nr_nids >= size) {
20233 + spin_unlock(&nx_info_hash_lock);
20237 + /* keep the lock time short */
20238 + spin_unlock(&nx_info_hash_lock);
20247 + * migrate task to new network
20248 + * gets nxi, puts old_nxi on change
20251 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20253 + struct nx_info *old_nxi;
20259 + vxdprintk(VXD_CBIT(nid, 5),
20260 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20261 + p, nxi, nxi->nx_id,
20262 + atomic_read(&nxi->nx_usecnt),
20263 + atomic_read(&nxi->nx_tasks));
20265 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20266 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20269 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20272 + /* maybe disallow this completely? */
20273 + old_nxi = task_get_nx_info(p);
20274 + if (old_nxi == nxi)
20279 + clr_nx_info(&p->nx_info);
20280 + claim_nx_info(nxi, p);
20281 + set_nx_info(&p->nx_info, nxi);
20282 + p->nid = nxi->nx_id;
20285 + vxdprintk(VXD_CBIT(nid, 5),
20286 + "moved task %p into nxi:%p[#%d]",
20287 + p, nxi, nxi->nx_id);
20290 + release_nx_info(old_nxi, p);
20293 + put_nx_info(old_nxi);
20298 +void nx_set_persistent(struct nx_info *nxi)
20300 + vxdprintk(VXD_CBIT(nid, 6),
20301 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20303 + get_nx_info(nxi);
20304 + claim_nx_info(nxi, NULL);
20307 +void nx_clear_persistent(struct nx_info *nxi)
20309 + vxdprintk(VXD_CBIT(nid, 6),
20310 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20312 + release_nx_info(nxi, NULL);
20313 + put_nx_info(nxi);
20316 +void nx_update_persistent(struct nx_info *nxi)
20318 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20319 + nx_set_persistent(nxi);
20321 + nx_clear_persistent(nxi);
20324 +/* vserver syscall commands below here */
20326 +/* taks nid and nx_info functions */
20328 +#include <asm/uaccess.h>
20331 +int vc_task_nid(uint32_t id)
20336 + struct task_struct *tsk;
20339 + tsk = find_task_by_real_pid(id);
20340 + nid = (tsk) ? tsk->nid : -ESRCH;
20341 + rcu_read_unlock();
20343 + nid = nx_current_nid();
20348 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20350 + struct vcmd_nx_info_v0 vc_data;
20352 + vc_data.nid = nxi->nx_id;
20354 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20360 +/* network functions */
20362 +int vc_net_create(uint32_t nid, void __user *data)
20364 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
20365 + struct nx_info *new_nxi;
20368 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20371 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
20374 + new_nxi = __create_nx_info(nid);
20375 + if (IS_ERR(new_nxi))
20376 + return PTR_ERR(new_nxi);
20378 + /* initial flags */
20379 + new_nxi->nx_flags = vc_data.flagword;
20382 + if (vs_net_change(new_nxi, VSC_NETUP))
20385 + ret = nx_migrate_task(current, new_nxi);
20389 + /* return context id on success */
20390 + ret = new_nxi->nx_id;
20392 + /* get a reference for persistent contexts */
20393 + if ((vc_data.flagword & NXF_PERSISTENT))
20394 + nx_set_persistent(new_nxi);
20396 + release_nx_info(new_nxi, NULL);
20397 + put_nx_info(new_nxi);
20402 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
20404 + return nx_migrate_task(current, nxi);
20409 +struct nx_addr_v4 *__find_v4_addr(struct nx_info *nxi,
20410 + __be32 ip, __be32 ip2, __be32 mask, uint16_t type, uint16_t flags,
20411 + struct nx_addr_v4 **prev)
20413 + struct nx_addr_v4 *nxa = &nxi->v4;
20415 + for (; nxa; nxa = nxa->next) {
20416 + if ((nxa->ip[0].s_addr == ip) &&
20417 + (nxa->ip[1].s_addr == ip2) &&
20418 + (nxa->mask.s_addr == mask) &&
20419 + (nxa->type == type) &&
20420 + (nxa->flags == flags))
20423 + /* save previous entry */
20430 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20431 + uint16_t type, uint16_t flags)
20433 + struct nx_addr_v4 *nxa = NULL;
20434 + struct nx_addr_v4 *new = __alloc_nx_addr_v4();
20435 + unsigned long irqflags;
20436 + int ret = -EEXIST;
20439 + return PTR_ERR(new);
20441 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20442 + if (__find_v4_addr(nxi, ip, ip2, mask, type, flags, &nxa))
20445 + if (NX_IPV4(nxi)) {
20450 + /* remove single ip for ip list */
20451 + nxi->nx_flags &= ~NXF_SINGLE_IP;
20454 + nxa->ip[0].s_addr = ip;
20455 + nxa->ip[1].s_addr = ip2;
20456 + nxa->mask.s_addr = mask;
20457 + nxa->type = type;
20458 + nxa->flags = flags;
20461 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20463 + __dealloc_nx_addr_v4(new);
20467 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20468 + uint16_t type, uint16_t flags)
20470 + struct nx_addr_v4 *nxa = NULL;
20471 + struct nx_addr_v4 *old = NULL;
20472 + unsigned long irqflags;
20475 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20477 + case NXA_TYPE_ADDR:
20478 + old = __find_v4_addr(nxi, ip, ip2, mask, type, flags, &nxa);
20481 + nxa->next = old->next;
20482 + old->next = NULL;
20488 + old->next = NULL;
20490 + memset(old, 0, sizeof(*old));
20498 + case NXA_TYPE_ANY:
20501 + memset(nxa, 0, sizeof(*nxa));
20507 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20508 + __dealloc_nx_addr_v4_all(old);
20513 +int vc_net_add(struct nx_info *nxi, void __user *data)
20515 + struct vcmd_net_addr_v0 vc_data;
20516 + int index, ret = 0;
20518 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20521 + switch (vc_data.type) {
20522 + case NXA_TYPE_IPV4:
20523 + if ((vc_data.count < 1) || (vc_data.count > 4))
20527 + while (index < vc_data.count) {
20528 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
20529 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
20537 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
20538 + nxi->v4_bcast = vc_data.ip[0];
20542 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
20543 + nxi->v4_lback = vc_data.ip[0];
20554 +int vc_net_remove(struct nx_info *nxi, void __user *data)
20556 + struct vcmd_net_addr_v0 vc_data;
20558 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20561 + switch (vc_data.type) {
20562 + case NXA_TYPE_ANY:
20563 + return do_remove_v4_addr(nxi, 0, 0, 0, vc_data.type, 0);
20571 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
20573 + struct vcmd_net_addr_ipv4_v1 vc_data;
20575 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20578 + switch (vc_data.type) {
20579 + case NXA_TYPE_ADDR:
20580 + case NXA_TYPE_MASK:
20581 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
20582 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20584 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20585 + nxi->v4_bcast = vc_data.ip;
20588 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20589 + nxi->v4_lback = vc_data.ip;
20598 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
20600 + struct vcmd_net_addr_ipv4_v2 vc_data;
20602 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20605 + switch (vc_data.type) {
20606 + case NXA_TYPE_ADDR:
20607 + case NXA_TYPE_MASK:
20608 + case NXA_TYPE_RANGE:
20609 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20610 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20612 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20613 + nxi->v4_bcast = vc_data.ip;
20616 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20617 + nxi->v4_lback = vc_data.ip;
20626 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
20628 + struct vcmd_net_addr_ipv4_v1 vc_data;
20630 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20633 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
20634 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20637 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
20639 + struct vcmd_net_addr_ipv4_v2 vc_data;
20641 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20644 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20645 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20648 +#ifdef CONFIG_IPV6
20651 +struct nx_addr_v6 *__find_v6_addr(struct nx_info *nxi,
20652 + struct in6_addr *ip, struct in6_addr *mask,
20653 + uint32_t prefix, uint16_t type, uint16_t flags,
20654 + struct nx_addr_v6 **prev)
20656 + struct nx_addr_v6 *nxa = &nxi->v6;
20658 + for (; nxa; nxa = nxa->next) {
20659 + if (ipv6_addr_equal(&nxa->ip, ip) &&
20660 + ipv6_addr_equal(&nxa->mask, mask) &&
20661 + (nxa->prefix == prefix) &&
20662 + (nxa->type == type) &&
20663 + (nxa->flags == flags))
20666 + /* save previous entry */
20674 +int do_add_v6_addr(struct nx_info *nxi,
20675 + struct in6_addr *ip, struct in6_addr *mask,
20676 + uint32_t prefix, uint16_t type, uint16_t flags)
20678 + struct nx_addr_v6 *nxa = NULL;
20679 + struct nx_addr_v6 *new = __alloc_nx_addr_v6();
20680 + unsigned long irqflags;
20681 + int ret = -EEXIST;
20684 + return PTR_ERR(new);
20686 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20687 + if (__find_v6_addr(nxi, ip, mask, prefix, type, flags, &nxa))
20690 + if (NX_IPV6(nxi)) {
20697 + nxa->mask = *mask;
20698 + nxa->prefix = prefix;
20699 + nxa->type = type;
20700 + nxa->flags = flags;
20703 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20705 + __dealloc_nx_addr_v6(new);
20709 +int do_remove_v6_addr(struct nx_info *nxi,
20710 + struct in6_addr *ip, struct in6_addr *mask,
20711 + uint32_t prefix, uint16_t type, uint16_t flags)
20713 + struct nx_addr_v6 *nxa = NULL;
20714 + struct nx_addr_v6 *old = NULL;
20715 + unsigned long irqflags;
20718 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20720 + case NXA_TYPE_ADDR:
20721 + old = __find_v6_addr(nxi, ip, mask, prefix, type, flags, &nxa);
20724 + nxa->next = old->next;
20725 + old->next = NULL;
20731 + old->next = NULL;
20733 + memset(old, 0, sizeof(*old));
20741 + case NXA_TYPE_ANY:
20744 + memset(nxa, 0, sizeof(*nxa));
20750 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20751 + __dealloc_nx_addr_v6_all(old);
20755 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
20757 + struct vcmd_net_addr_ipv6_v1 vc_data;
20759 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20762 + switch (vc_data.type) {
20763 + case NXA_TYPE_ADDR:
20764 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20765 + /* fallthrough */
20766 + case NXA_TYPE_MASK:
20767 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20768 + vc_data.prefix, vc_data.type, vc_data.flags);
20775 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
20777 + struct vcmd_net_addr_ipv6_v1 vc_data;
20779 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20782 + switch (vc_data.type) {
20783 + case NXA_TYPE_ADDR:
20784 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20785 + /* fallthrough */
20786 + case NXA_TYPE_MASK:
20787 + return do_remove_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20788 + vc_data.prefix, vc_data.type, vc_data.flags);
20789 + case NXA_TYPE_ANY:
20790 + return do_remove_v6_addr(nxi, NULL, NULL, 0, vc_data.type, 0);
20797 +#endif /* CONFIG_IPV6 */
20800 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
20802 + struct vcmd_net_flags_v0 vc_data;
20804 + vc_data.flagword = nxi->nx_flags;
20806 + /* special STATE flag handling */
20807 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
20809 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20814 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
20816 + struct vcmd_net_flags_v0 vc_data;
20817 + uint64_t mask, trigger;
20819 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20822 + /* special STATE flag handling */
20823 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
20824 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
20826 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
20827 + vc_data.flagword, mask);
20828 + if (trigger & NXF_PERSISTENT)
20829 + nx_update_persistent(nxi);
20834 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
20836 + struct vcmd_net_caps_v0 vc_data;
20838 + vc_data.ncaps = nxi->nx_ncaps;
20839 + vc_data.cmask = ~0ULL;
20841 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20846 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
20848 + struct vcmd_net_caps_v0 vc_data;
20850 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20853 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
20854 + vc_data.ncaps, vc_data.cmask);
20859 +#include <linux/module.h>
20861 +module_init(init_network);
20863 +EXPORT_SYMBOL_GPL(free_nx_info);
20864 +EXPORT_SYMBOL_GPL(unhash_nx_info);
20866 diff -NurpP --minimal linux-3.10.15/kernel/vserver/proc.c linux-3.10.15-vs2.3.6.6/kernel/vserver/proc.c
20867 --- linux-3.10.15/kernel/vserver/proc.c 1970-01-01 00:00:00.000000000 +0000
20868 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/proc.c 2013-08-22 23:31:37.000000000 +0000
20871 + * linux/kernel/vserver/proc.c
20873 + * Virtual Context Support
20875 + * Copyright (C) 2003-2011 Herbert Pötzl
20877 + * V0.01 basic structure
20878 + * V0.02 adaptation vs1.3.0
20879 + * V0.03 proc permissions
20880 + * V0.04 locking/generic
20881 + * V0.05 next generation procfs
20882 + * V0.06 inode validation
20883 + * V0.07 generic rewrite vid
20884 + * V0.08 remove inode type
20885 + * V0.09 added u/wmask info
20889 +#include <linux/proc_fs.h>
20890 +#include <linux/fs_struct.h>
20891 +#include <linux/mount.h>
20892 +#include <linux/namei.h>
20893 +#include <asm/unistd.h>
20895 +#include <linux/vs_context.h>
20896 +#include <linux/vs_network.h>
20897 +#include <linux/vs_cvirt.h>
20899 +#include <linux/in.h>
20900 +#include <linux/inetdevice.h>
20901 +#include <linux/vs_inet.h>
20902 +#include <linux/vs_inet6.h>
20904 +#include <linux/vserver/global.h>
20906 +#include "cvirt_proc.h"
20907 +#include "cacct_proc.h"
20908 +#include "limit_proc.h"
20909 +#include "sched_proc.h"
20910 +#include "vci_config.h"
20912 +#include <../../fs/proc/internal.h>
20915 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
20919 + CAP_FOR_EACH_U32(__capi) {
20920 + buffer += sprintf(buffer, "%08x",
20921 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
20927 +static struct proc_dir_entry *proc_virtual;
20929 +static struct proc_dir_entry *proc_virtnet;
20932 +/* first the actual feeds */
20935 +static int proc_vci(char *buffer)
20937 + return sprintf(buffer,
20938 + "VCIVersion:\t%04x:%04x\n"
20939 + "VCISyscall:\t%d\n"
20940 + "VCIKernel:\t%08x\n",
20941 + VCI_VERSION >> 16,
20942 + VCI_VERSION & 0xFFFF,
20944 + vci_kernel_config());
20947 +static int proc_virtual_info(char *buffer)
20949 + return proc_vci(buffer);
20952 +static int proc_virtual_status(char *buffer)
20954 + return sprintf(buffer,
20956 + "#CActive:\t%d\n"
20957 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
20958 + "#InitTask:\t%d\t%d %d\n",
20959 + atomic_read(&vx_global_ctotal),
20960 + atomic_read(&vx_global_cactive),
20961 + atomic_read(&vs_global_nsproxy),
20962 + atomic_read(&vs_global_fs),
20963 + atomic_read(&vs_global_mnt_ns),
20964 + atomic_read(&vs_global_uts_ns),
20965 + atomic_read(&nr_ipc_ns),
20966 + atomic_read(&vs_global_user_ns),
20967 + atomic_read(&vs_global_pid_ns),
20968 + atomic_read(&init_task.usage),
20969 + atomic_read(&init_task.nsproxy->count),
20970 + init_task.fs->users);
20974 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
20978 + length = sprintf(buffer,
20986 + vxi->vx_badness_bias);
20990 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
20992 + char *orig = buffer;
20994 + buffer += sprintf(buffer,
20997 + "Flags:\t%016llx\n",
20998 + atomic_read(&vxi->vx_usecnt),
20999 + atomic_read(&vxi->vx_tasks),
21000 + (unsigned long long)vxi->vx_flags);
21002 + buffer += sprintf(buffer, "BCaps:\t");
21003 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21004 + buffer += sprintf(buffer, "\n");
21006 + buffer += sprintf(buffer,
21007 + "CCaps:\t%016llx\n"
21008 + "Umask:\t%16llx\n"
21009 + "Wmask:\t%16llx\n"
21010 + "Spaces:\t%08lx %08lx\n",
21011 + (unsigned long long)vxi->vx_ccaps,
21012 + (unsigned long long)vxi->vx_umask,
21013 + (unsigned long long)vxi->vx_wmask,
21014 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21015 + return buffer - orig;
21018 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21020 + return vx_info_proc_limit(&vxi->limit, buffer);
21023 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21027 + length = vx_info_proc_sched(&vxi->sched, buffer);
21028 + for_each_online_cpu(cpu) {
21029 + length += vx_info_proc_sched_pc(
21030 + &vx_per_cpu(vxi, sched_pc, cpu),
21031 + buffer + length, cpu);
21036 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21038 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21041 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21043 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21046 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21050 + vx_update_load(vxi);
21051 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21052 + for_each_online_cpu(cpu) {
21053 + length += vx_info_proc_cvirt_pc(
21054 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21055 + buffer + length, cpu);
21060 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21062 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21066 +static int proc_virtnet_info(char *buffer)
21068 + return proc_vci(buffer);
21071 +static int proc_virtnet_status(char *buffer)
21073 + return sprintf(buffer,
21075 + "#CActive:\t%d\n",
21076 + atomic_read(&nx_global_ctotal),
21077 + atomic_read(&nx_global_cactive));
21080 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21082 + struct nx_addr_v4 *v4a;
21083 +#ifdef CONFIG_IPV6
21084 + struct nx_addr_v6 *v6a;
21088 + length = sprintf(buffer,
21091 + "Bcast:\t" NIPQUAD_FMT "\n"
21092 + "Lback:\t" NIPQUAD_FMT "\n",
21095 + NIPQUAD(nxi->v4_bcast.s_addr),
21096 + NIPQUAD(nxi->v4_lback.s_addr));
21098 + if (!NX_IPV4(nxi))
21100 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21101 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21104 +#ifdef CONFIG_IPV6
21105 + if (!NX_IPV6(nxi))
21107 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21108 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21115 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21119 + length = sprintf(buffer,
21122 + "Flags:\t%016llx\n"
21123 + "NCaps:\t%016llx\n",
21124 + atomic_read(&nxi->nx_usecnt),
21125 + atomic_read(&nxi->nx_tasks),
21126 + (unsigned long long)nxi->nx_flags,
21127 + (unsigned long long)nxi->nx_ncaps);
21133 +/* here the inode helpers */
21139 + struct inode_operations *iop;
21140 + struct file_operations *fop;
21141 + union proc_op op;
21144 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21146 + struct inode *inode = new_inode(sb);
21151 + inode->i_mode = p->mode;
21153 + inode->i_op = p->iop;
21155 + inode->i_fop = p->fop;
21157 + set_nlink(inode, (p->mode & S_IFDIR) ? 2 : 1);
21158 + inode->i_flags |= S_IMMUTABLE;
21160 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21162 + i_uid_write(inode, 0);
21163 + i_gid_write(inode, 0);
21164 + i_tag_write(inode, 0);
21169 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21170 + struct dentry *dentry, int id, void *ptr)
21172 + struct vs_entry *p = ptr;
21173 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21174 + struct dentry *error = ERR_PTR(-EINVAL);
21179 + PROC_I(inode)->op = p->op;
21180 + PROC_I(inode)->fd = id;
21181 + d_add(dentry, inode);
21189 +typedef struct dentry *vx_instantiate_t(struct inode *, struct dentry *, int, void *);
21193 + * Fill a directory entry.
21195 + * If possible create the dcache entry and derive our inode number and
21196 + * file type from dcache entry.
21198 + * Since all of the proc inode numbers are dynamically generated, the inode
21199 + * numbers do not exist until the inode is cache. This means creating the
21200 + * the dcache entry in readdir is necessary to keep the inode numbers
21201 + * reported by readdir in sync with the inode numbers reported
21204 +static int vx_proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21205 + char *name, int len, vx_instantiate_t instantiate, int id, void *ptr)
21207 + struct dentry *child, *dir = filp->f_dentry;
21208 + struct inode *inode;
21209 + struct qstr qname;
21211 + unsigned type = DT_UNKNOWN;
21213 + qname.name = name;
21215 + qname.hash = full_name_hash(name, len);
21217 + child = d_lookup(dir, &qname);
21219 + struct dentry *new;
21220 + new = d_alloc(dir, &qname);
21222 + child = instantiate(dir->d_inode, new, id, ptr);
21229 + if (!child || IS_ERR(child) || !child->d_inode)
21230 + goto end_instantiate;
21231 + inode = child->d_inode;
21233 + ino = inode->i_ino;
21234 + type = inode->i_mode >> 12;
21239 + ino = find_inode_number(dir, &qname);
21242 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21247 +/* get and revalidate vx_info/xid */
21250 +struct vx_info *get_proc_vx_info(struct inode *inode)
21252 + return lookup_vx_info(PROC_I(inode)->fd);
21255 +static int proc_xid_revalidate(struct dentry *dentry, unsigned int flags)
21257 + struct inode *inode = dentry->d_inode;
21258 + vxid_t xid = PROC_I(inode)->fd;
21260 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21263 + if (!xid || xid_is_hashed(xid))
21270 +/* get and revalidate nx_info/nid */
21272 +static int proc_nid_revalidate(struct dentry *dentry, unsigned int flags)
21274 + struct inode *inode = dentry->d_inode;
21275 + vnid_t nid = PROC_I(inode)->fd;
21277 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21280 + if (!nid || nid_is_hashed(nid))
21288 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21290 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21291 + size_t count, loff_t *ppos)
21293 + struct inode *inode = file->f_dentry->d_inode;
21294 + unsigned long page;
21295 + ssize_t length = 0;
21297 + if (count > PROC_BLOCK_SIZE)
21298 + count = PROC_BLOCK_SIZE;
21300 + /* fade that out as soon as stable */
21301 + WARN_ON(PROC_I(inode)->fd);
21303 + if (!(page = __get_free_page(GFP_KERNEL)))
21306 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21307 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21310 + length = simple_read_from_buffer(buf, count, ppos,
21311 + (char *)page, length);
21317 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21318 + size_t count, loff_t *ppos)
21320 + struct inode *inode = file->f_dentry->d_inode;
21321 + struct vx_info *vxi = NULL;
21322 + vxid_t xid = PROC_I(inode)->fd;
21323 + unsigned long page;
21324 + ssize_t length = 0;
21326 + if (count > PROC_BLOCK_SIZE)
21327 + count = PROC_BLOCK_SIZE;
21329 + /* fade that out as soon as stable */
21331 + vxi = lookup_vx_info(xid);
21335 + length = -ENOMEM;
21336 + if (!(page = __get_free_page(GFP_KERNEL)))
21339 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21340 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21343 + length = simple_read_from_buffer(buf, count, ppos,
21344 + (char *)page, length);
21348 + put_vx_info(vxi);
21353 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21354 + size_t count, loff_t *ppos)
21356 + struct inode *inode = file->f_dentry->d_inode;
21357 + struct nx_info *nxi = NULL;
21358 + vnid_t nid = PROC_I(inode)->fd;
21359 + unsigned long page;
21360 + ssize_t length = 0;
21362 + if (count > PROC_BLOCK_SIZE)
21363 + count = PROC_BLOCK_SIZE;
21365 + /* fade that out as soon as stable */
21367 + nxi = lookup_nx_info(nid);
21371 + length = -ENOMEM;
21372 + if (!(page = __get_free_page(GFP_KERNEL)))
21375 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21376 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21379 + length = simple_read_from_buffer(buf, count, ppos,
21380 + (char *)page, length);
21384 + put_nx_info(nxi);
21391 +/* here comes the lower level */
21394 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21395 + .len = sizeof(NAME) - 1, \
21396 + .name = (NAME), \
21404 +#define DIR(NAME, MODE, OTYPE) \
21405 + NOD(NAME, (S_IFDIR | (MODE)), \
21406 + &proc_ ## OTYPE ## _inode_operations, \
21407 + &proc_ ## OTYPE ## _file_operations, { } )
21409 +#define INF(NAME, MODE, OTYPE) \
21410 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21411 + &proc_vs_info_file_operations, \
21412 + { .proc_vs_read = &proc_##OTYPE } )
21414 +#define VINF(NAME, MODE, OTYPE) \
21415 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21416 + &proc_vx_info_file_operations, \
21417 + { .proc_vxi_read = &proc_##OTYPE } )
21419 +#define NINF(NAME, MODE, OTYPE) \
21420 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21421 + &proc_nx_info_file_operations, \
21422 + { .proc_nxi_read = &proc_##OTYPE } )
21425 +static struct file_operations proc_vs_info_file_operations = {
21426 + .read = proc_vs_info_read,
21429 +static struct file_operations proc_vx_info_file_operations = {
21430 + .read = proc_vx_info_read,
21433 +static struct dentry_operations proc_xid_dentry_operations = {
21434 + .d_revalidate = proc_xid_revalidate,
21437 +static struct vs_entry vx_base_stuff[] = {
21438 + VINF("info", S_IRUGO, vxi_info),
21439 + VINF("status", S_IRUGO, vxi_status),
21440 + VINF("limit", S_IRUGO, vxi_limit),
21441 + VINF("sched", S_IRUGO, vxi_sched),
21442 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21443 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21444 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21445 + VINF("cacct", S_IRUGO, vxi_cacct),
21452 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21453 + struct dentry *dentry, int id, void *ptr)
21455 + dentry->d_op = &proc_xid_dentry_operations;
21456 + return vs_proc_instantiate(dir, dentry, id, ptr);
21459 +static struct dentry *proc_xid_lookup(struct inode *dir,
21460 + struct dentry *dentry, unsigned int flags)
21462 + struct vs_entry *p = vx_base_stuff;
21463 + struct dentry *error = ERR_PTR(-ENOENT);
21465 + for (; p->name; p++) {
21466 + if (p->len != dentry->d_name.len)
21468 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21474 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21479 +static int proc_xid_readdir(struct file *filp,
21480 + void *dirent, filldir_t filldir)
21482 + struct dentry *dentry = filp->f_dentry;
21483 + struct inode *inode = dentry->d_inode;
21484 + struct vs_entry *p = vx_base_stuff;
21485 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21489 + pos = filp->f_pos;
21492 + ino = inode->i_ino;
21493 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21496 + /* fall through */
21498 + ino = parent_ino(dentry);
21499 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21502 + /* fall through */
21505 + if (index >= size)
21507 + for (p += index; p->name; p++) {
21508 + if (vx_proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21509 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21515 + filp->f_pos = pos;
21521 +static struct file_operations proc_nx_info_file_operations = {
21522 + .read = proc_nx_info_read,
21525 +static struct dentry_operations proc_nid_dentry_operations = {
21526 + .d_revalidate = proc_nid_revalidate,
21529 +static struct vs_entry nx_base_stuff[] = {
21530 + NINF("info", S_IRUGO, nxi_info),
21531 + NINF("status", S_IRUGO, nxi_status),
21536 +static struct dentry *proc_nid_instantiate(struct inode *dir,
21537 + struct dentry *dentry, int id, void *ptr)
21539 + dentry->d_op = &proc_nid_dentry_operations;
21540 + return vs_proc_instantiate(dir, dentry, id, ptr);
21543 +static struct dentry *proc_nid_lookup(struct inode *dir,
21544 + struct dentry *dentry, unsigned int flags)
21546 + struct vs_entry *p = nx_base_stuff;
21547 + struct dentry *error = ERR_PTR(-ENOENT);
21549 + for (; p->name; p++) {
21550 + if (p->len != dentry->d_name.len)
21552 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21558 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21563 +static int proc_nid_readdir(struct file *filp,
21564 + void *dirent, filldir_t filldir)
21566 + struct dentry *dentry = filp->f_dentry;
21567 + struct inode *inode = dentry->d_inode;
21568 + struct vs_entry *p = nx_base_stuff;
21569 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
21573 + pos = filp->f_pos;
21576 + ino = inode->i_ino;
21577 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21580 + /* fall through */
21582 + ino = parent_ino(dentry);
21583 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21586 + /* fall through */
21589 + if (index >= size)
21591 + for (p += index; p->name; p++) {
21592 + if (vx_proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21593 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21599 + filp->f_pos = pos;
21604 +#define MAX_MULBY10 ((~0U - 9) / 10)
21606 +static inline int atovid(const char *str, int len)
21611 + while (len-- > 0) {
21616 + if (vid >= MAX_MULBY10)
21626 +/* now the upper level (virtual) */
21629 +static struct file_operations proc_xid_file_operations = {
21630 + .read = generic_read_dir,
21631 + .readdir = proc_xid_readdir,
21634 +static struct inode_operations proc_xid_inode_operations = {
21635 + .lookup = proc_xid_lookup,
21638 +static struct vs_entry vx_virtual_stuff[] = {
21639 + INF("info", S_IRUGO, virtual_info),
21640 + INF("status", S_IRUGO, virtual_status),
21641 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
21645 +static struct dentry *proc_virtual_lookup(struct inode *dir,
21646 + struct dentry *dentry, unsigned int flags)
21648 + struct vs_entry *p = vx_virtual_stuff;
21649 + struct dentry *error = ERR_PTR(-ENOENT);
21652 + for (; p->name; p++) {
21653 + if (p->len != dentry->d_name.len)
21655 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21659 + goto instantiate;
21661 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21662 + if ((id < 0) || !xid_is_hashed(id))
21666 + error = proc_xid_instantiate(dir, dentry, id, p);
21671 +static struct file_operations proc_nid_file_operations = {
21672 + .read = generic_read_dir,
21673 + .readdir = proc_nid_readdir,
21676 +static struct inode_operations proc_nid_inode_operations = {
21677 + .lookup = proc_nid_lookup,
21680 +static struct vs_entry nx_virtnet_stuff[] = {
21681 + INF("info", S_IRUGO, virtnet_info),
21682 + INF("status", S_IRUGO, virtnet_status),
21683 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
21687 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
21688 + struct dentry *dentry, unsigned int flags)
21690 + struct vs_entry *p = nx_virtnet_stuff;
21691 + struct dentry *error = ERR_PTR(-ENOENT);
21694 + for (; p->name; p++) {
21695 + if (p->len != dentry->d_name.len)
21697 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21701 + goto instantiate;
21703 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21704 + if ((id < 0) || !nid_is_hashed(id))
21708 + error = proc_nid_instantiate(dir, dentry, id, p);
21714 +#define PROC_MAXVIDS 32
21716 +int proc_virtual_readdir(struct file *filp,
21717 + void *dirent, filldir_t filldir)
21719 + struct dentry *dentry = filp->f_dentry;
21720 + struct inode *inode = dentry->d_inode;
21721 + struct vs_entry *p = vx_virtual_stuff;
21722 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
21724 + unsigned int xid_array[PROC_MAXVIDS];
21725 + char buf[PROC_NUMBUF];
21726 + unsigned int nr_xids, i;
21729 + pos = filp->f_pos;
21732 + ino = inode->i_ino;
21733 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21736 + /* fall through */
21738 + ino = parent_ino(dentry);
21739 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21742 + /* fall through */
21745 + if (index >= size)
21747 + for (p += index; p->name; p++) {
21748 + if (vx_proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21749 + vs_proc_instantiate, 0, p))
21754 + index = pos - size;
21755 + p = &vx_virtual_stuff[size - 1];
21756 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
21757 + for (i = 0; i < nr_xids; i++) {
21758 + int n, xid = xid_array[i];
21759 + unsigned int j = PROC_NUMBUF;
21763 + buf[--j] = '0' + (n % 10);
21766 + if (vx_proc_fill_cache(filp, dirent, filldir,
21767 + buf + j, PROC_NUMBUF - j,
21768 + vs_proc_instantiate, xid, p))
21774 + filp->f_pos = pos;
21778 +static int proc_virtual_getattr(struct vfsmount *mnt,
21779 + struct dentry *dentry, struct kstat *stat)
21781 + struct inode *inode = dentry->d_inode;
21783 + generic_fillattr(inode, stat);
21784 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
21788 +static struct file_operations proc_virtual_dir_operations = {
21789 + .read = generic_read_dir,
21790 + .readdir = proc_virtual_readdir,
21793 +static struct inode_operations proc_virtual_dir_inode_operations = {
21794 + .getattr = proc_virtual_getattr,
21795 + .lookup = proc_virtual_lookup,
21802 +int proc_virtnet_readdir(struct file *filp,
21803 + void *dirent, filldir_t filldir)
21805 + struct dentry *dentry = filp->f_dentry;
21806 + struct inode *inode = dentry->d_inode;
21807 + struct vs_entry *p = nx_virtnet_stuff;
21808 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
21810 + unsigned int nid_array[PROC_MAXVIDS];
21811 + char buf[PROC_NUMBUF];
21812 + unsigned int nr_nids, i;
21815 + pos = filp->f_pos;
21818 + ino = inode->i_ino;
21819 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21822 + /* fall through */
21824 + ino = parent_ino(dentry);
21825 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21828 + /* fall through */
21831 + if (index >= size)
21833 + for (p += index; p->name; p++) {
21834 + if (vx_proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21835 + vs_proc_instantiate, 0, p))
21840 + index = pos - size;
21841 + p = &nx_virtnet_stuff[size - 1];
21842 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
21843 + for (i = 0; i < nr_nids; i++) {
21844 + int n, nid = nid_array[i];
21845 + unsigned int j = PROC_NUMBUF;
21849 + buf[--j] = '0' + (n % 10);
21852 + if (vx_proc_fill_cache(filp, dirent, filldir,
21853 + buf + j, PROC_NUMBUF - j,
21854 + vs_proc_instantiate, nid, p))
21860 + filp->f_pos = pos;
21864 +static int proc_virtnet_getattr(struct vfsmount *mnt,
21865 + struct dentry *dentry, struct kstat *stat)
21867 + struct inode *inode = dentry->d_inode;
21869 + generic_fillattr(inode, stat);
21870 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
21874 +static struct file_operations proc_virtnet_dir_operations = {
21875 + .read = generic_read_dir,
21876 + .readdir = proc_virtnet_readdir,
21879 +static struct inode_operations proc_virtnet_dir_inode_operations = {
21880 + .getattr = proc_virtnet_getattr,
21881 + .lookup = proc_virtnet_lookup,
21886 +void proc_vx_init(void)
21888 + struct proc_dir_entry *ent;
21890 + ent = proc_mkdir("virtual", 0);
21892 + ent->proc_fops = &proc_virtual_dir_operations;
21893 + ent->proc_iops = &proc_virtual_dir_inode_operations;
21895 + proc_virtual = ent;
21897 + ent = proc_mkdir("virtnet", 0);
21899 + ent->proc_fops = &proc_virtnet_dir_operations;
21900 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
21902 + proc_virtnet = ent;
21908 +/* per pid info */
21911 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
21913 + struct vx_info *vxi;
21914 + char *orig = buffer;
21916 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
21918 + vxi = task_get_vx_info(p);
21922 + buffer += sprintf(buffer, "BCaps:\t");
21923 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21924 + buffer += sprintf(buffer, "\n");
21925 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
21926 + (unsigned long long)vxi->vx_ccaps);
21927 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
21928 + (unsigned long long)vxi->vx_flags);
21929 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
21931 + put_vx_info(vxi);
21933 + return buffer - orig;
21937 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
21939 + struct nx_info *nxi;
21940 + struct nx_addr_v4 *v4a;
21941 +#ifdef CONFIG_IPV6
21942 + struct nx_addr_v6 *v6a;
21944 + char *orig = buffer;
21947 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
21949 + nxi = task_get_nx_info(p);
21953 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
21954 + (unsigned long long)nxi->nx_ncaps);
21955 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
21956 + (unsigned long long)nxi->nx_flags);
21958 + buffer += sprintf(buffer,
21959 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
21960 + NIPQUAD(nxi->v4_bcast.s_addr));
21961 + buffer += sprintf (buffer,
21962 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
21963 + NIPQUAD(nxi->v4_lback.s_addr));
21964 + if (!NX_IPV4(nxi))
21966 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21967 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
21970 +#ifdef CONFIG_IPV6
21971 + if (!NX_IPV6(nxi))
21973 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21974 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
21978 + put_nx_info(nxi);
21980 + return buffer - orig;
21983 diff -NurpP --minimal linux-3.10.15/kernel/vserver/sched.c linux-3.10.15-vs2.3.6.6/kernel/vserver/sched.c
21984 --- linux-3.10.15/kernel/vserver/sched.c 1970-01-01 00:00:00.000000000 +0000
21985 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/sched.c 2013-08-22 20:30:00.000000000 +0000
21988 + * linux/kernel/vserver/sched.c
21990 + * Virtual Server: Scheduler Support
21992 + * Copyright (C) 2004-2010 Herbert Pötzl
21994 + * V0.01 adapted Sam Vilains version to 2.6.3
21995 + * V0.02 removed legacy interface
21996 + * V0.03 changed vcmds to vxi arg
21997 + * V0.04 removed older and legacy interfaces
21998 + * V0.05 removed scheduler code/commands
22002 +#include <linux/vs_context.h>
22003 +#include <linux/vs_sched.h>
22004 +#include <linux/cpumask.h>
22005 +#include <linux/vserver/sched_cmd.h>
22007 +#include <asm/uaccess.h>
22010 +void vx_update_sched_param(struct _vx_sched *sched,
22011 + struct _vx_sched_pc *sched_pc)
22013 + sched_pc->prio_bias = sched->prio_bias;
22016 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22020 + if (data->prio_bias > MAX_PRIO_BIAS)
22021 + data->prio_bias = MAX_PRIO_BIAS;
22022 + if (data->prio_bias < MIN_PRIO_BIAS)
22023 + data->prio_bias = MIN_PRIO_BIAS;
22025 + if (data->cpu_id != ~0) {
22026 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22027 + cpumask_and(&vxi->sched.update, &vxi->sched.update,
22028 + cpu_online_mask);
22030 + cpumask_copy(&vxi->sched.update, cpu_online_mask);
22032 + for_each_cpu_mask(cpu, vxi->sched.update)
22033 + vx_update_sched_param(&vxi->sched,
22034 + &vx_per_cpu(vxi, sched_pc, cpu));
22038 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22040 + struct vcmd_prio_bias vc_data;
22042 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22045 + return do_set_prio_bias(vxi, &vc_data);
22048 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22050 + struct vcmd_prio_bias vc_data;
22051 + struct _vx_sched_pc *pcd;
22054 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22057 + cpu = vc_data.cpu_id;
22059 + if (!cpu_possible(cpu))
22062 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22063 + vc_data.prio_bias = pcd->prio_bias;
22065 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22070 diff -NurpP --minimal linux-3.10.15/kernel/vserver/sched_init.h linux-3.10.15-vs2.3.6.6/kernel/vserver/sched_init.h
22071 --- linux-3.10.15/kernel/vserver/sched_init.h 1970-01-01 00:00:00.000000000 +0000
22072 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/sched_init.h 2013-08-22 20:30:00.000000000 +0000
22075 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22077 + /* scheduling; hard code starting values as constants */
22078 + sched->prio_bias = 0;
22082 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22084 + sched_pc->prio_bias = 0;
22086 + sched_pc->user_ticks = 0;
22087 + sched_pc->sys_ticks = 0;
22088 + sched_pc->hold_ticks = 0;
22091 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22097 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22101 diff -NurpP --minimal linux-3.10.15/kernel/vserver/sched_proc.h linux-3.10.15-vs2.3.6.6/kernel/vserver/sched_proc.h
22102 --- linux-3.10.15/kernel/vserver/sched_proc.h 1970-01-01 00:00:00.000000000 +0000
22103 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/sched_proc.h 2013-08-22 20:30:00.000000000 +0000
22105 +#ifndef _VX_SCHED_PROC_H
22106 +#define _VX_SCHED_PROC_H
22110 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22114 + length += sprintf(buffer,
22115 + "PrioBias:\t%8d\n",
22116 + sched->prio_bias);
22121 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22122 + char *buffer, int cpu)
22126 + length += sprintf(buffer + length,
22127 + "cpu %d: %lld %lld %lld", cpu,
22128 + (unsigned long long)sched_pc->user_ticks,
22129 + (unsigned long long)sched_pc->sys_ticks,
22130 + (unsigned long long)sched_pc->hold_ticks);
22131 + length += sprintf(buffer + length,
22132 + " %d\n", sched_pc->prio_bias);
22136 +#endif /* _VX_SCHED_PROC_H */
22137 diff -NurpP --minimal linux-3.10.15/kernel/vserver/signal.c linux-3.10.15-vs2.3.6.6/kernel/vserver/signal.c
22138 --- linux-3.10.15/kernel/vserver/signal.c 1970-01-01 00:00:00.000000000 +0000
22139 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/signal.c 2013-08-22 20:30:00.000000000 +0000
22142 + * linux/kernel/vserver/signal.c
22144 + * Virtual Server: Signal Support
22146 + * Copyright (C) 2003-2007 Herbert Pötzl
22148 + * V0.01 broken out from vcontext V0.05
22149 + * V0.02 changed vcmds to vxi arg
22150 + * V0.03 adjusted siginfo for kill
22154 +#include <asm/uaccess.h>
22156 +#include <linux/vs_context.h>
22157 +#include <linux/vs_pid.h>
22158 +#include <linux/vserver/signal_cmd.h>
22161 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22163 + int retval, count = 0;
22164 + struct task_struct *p;
22165 + struct siginfo *sip = SEND_SIG_PRIV;
22168 + vxdprintk(VXD_CBIT(misc, 4),
22169 + "vx_info_kill(%p[#%d],%d,%d)*",
22170 + vxi, vxi->vx_id, pid, sig);
22171 + read_lock(&tasklist_lock);
22175 + for_each_process(p) {
22178 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22179 + (pid && vxi->vx_initpid == p->pid))
22182 + err = group_send_sig_info(sig, sip, p);
22184 + if (err != -EPERM)
22190 + if (vxi->vx_initpid) {
22191 + pid = vxi->vx_initpid;
22192 + /* for now, only SIGINT to private init ... */
22193 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22194 + /* ... as long as there are tasks left */
22195 + (atomic_read(&vxi->vx_tasks) > 1))
22198 + /* fallthrough */
22201 + p = find_task_by_real_pid(pid);
22202 + rcu_read_unlock();
22204 + if (vx_task_xid(p) == vxi->vx_id)
22205 + retval = group_send_sig_info(sig, sip, p);
22209 + read_unlock(&tasklist_lock);
22210 + vxdprintk(VXD_CBIT(misc, 4),
22211 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22212 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22216 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22218 + struct vcmd_ctx_kill_v0 vc_data;
22220 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22223 + /* special check to allow guest shutdown */
22224 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22225 + /* forbid killall pid=0 when init is present */
22226 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22227 + (vc_data.pid > 1)))
22230 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22234 +static int __wait_exit(struct vx_info *vxi)
22236 + DECLARE_WAITQUEUE(wait, current);
22239 + add_wait_queue(&vxi->vx_wait, &wait);
22240 + set_current_state(TASK_INTERRUPTIBLE);
22243 + if (vx_info_state(vxi,
22244 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22246 + if (signal_pending(current)) {
22247 + ret = -ERESTARTSYS;
22254 + set_current_state(TASK_RUNNING);
22255 + remove_wait_queue(&vxi->vx_wait, &wait);
22261 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22263 + struct vcmd_wait_exit_v0 vc_data;
22266 + ret = __wait_exit(vxi);
22267 + vc_data.reboot_cmd = vxi->reboot_cmd;
22268 + vc_data.exit_code = vxi->exit_code;
22270 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22275 diff -NurpP --minimal linux-3.10.15/kernel/vserver/space.c linux-3.10.15-vs2.3.6.6/kernel/vserver/space.c
22276 --- linux-3.10.15/kernel/vserver/space.c 1970-01-01 00:00:00.000000000 +0000
22277 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/space.c 2013-08-22 20:30:00.000000000 +0000
22280 + * linux/kernel/vserver/space.c
22282 + * Virtual Server: Context Space Support
22284 + * Copyright (C) 2003-2010 Herbert Pötzl
22286 + * V0.01 broken out from context.c 0.07
22287 + * V0.02 added task locking for namespace
22288 + * V0.03 broken out vx_enter_namespace
22289 + * V0.04 added *space support and commands
22290 + * V0.05 added credential support
22294 +#include <linux/utsname.h>
22295 +#include <linux/nsproxy.h>
22296 +#include <linux/err.h>
22297 +#include <linux/fs_struct.h>
22298 +#include <linux/cred.h>
22299 +#include <asm/uaccess.h>
22301 +#include <linux/vs_context.h>
22302 +#include <linux/vserver/space.h>
22303 +#include <linux/vserver/space_cmd.h>
22305 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22306 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22307 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22308 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22309 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22310 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22313 +/* namespace functions */
22315 +#include <linux/mnt_namespace.h>
22316 +#include <linux/user_namespace.h>
22317 +#include <linux/pid_namespace.h>
22318 +#include <linux/ipc_namespace.h>
22319 +#include <net/net_namespace.h>
22320 +#include "../fs/mount.h"
22323 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22324 + .mask = CLONE_FS |
22326 +#ifdef CONFIG_UTS_NS
22329 +#ifdef CONFIG_IPC_NS
22332 +#ifdef CONFIG_USER_NS
22338 +static const struct vcmd_space_mask_v1 space_mask = {
22339 + .mask = CLONE_FS |
22341 +#ifdef CONFIG_UTS_NS
22344 +#ifdef CONFIG_IPC_NS
22347 +#ifdef CONFIG_USER_NS
22350 +#ifdef CONFIG_PID_NS
22353 +#ifdef CONFIG_NET_NS
22359 +static const struct vcmd_space_mask_v1 default_space_mask = {
22360 + .mask = CLONE_FS |
22362 +#ifdef CONFIG_UTS_NS
22365 +#ifdef CONFIG_IPC_NS
22368 +#ifdef CONFIG_USER_NS
22371 +#ifdef CONFIG_PID_NS
22378 + * build a new nsproxy mix
22379 + * assumes that both proxies are 'const'
22380 + * does not touch nsproxy refcounts
22381 + * will hold a reference on the result.
22384 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22385 + struct nsproxy *new_nsproxy, unsigned long mask)
22387 + struct mnt_namespace *old_ns;
22388 + struct uts_namespace *old_uts;
22389 + struct ipc_namespace *old_ipc;
22390 +#ifdef CONFIG_PID_NS
22391 + struct pid_namespace *old_pid;
22393 +#ifdef CONFIG_NET_NS
22394 + struct net *old_net;
22396 + struct nsproxy *nsproxy;
22398 + nsproxy = copy_nsproxy(old_nsproxy);
22402 + if (mask & CLONE_NEWNS) {
22403 + old_ns = nsproxy->mnt_ns;
22404 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22405 + if (nsproxy->mnt_ns)
22406 + get_mnt_ns(nsproxy->mnt_ns);
22410 + if (mask & CLONE_NEWUTS) {
22411 + old_uts = nsproxy->uts_ns;
22412 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22413 + if (nsproxy->uts_ns)
22414 + get_uts_ns(nsproxy->uts_ns);
22418 + if (mask & CLONE_NEWIPC) {
22419 + old_ipc = nsproxy->ipc_ns;
22420 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22421 + if (nsproxy->ipc_ns)
22422 + get_ipc_ns(nsproxy->ipc_ns);
22426 +#ifdef CONFIG_PID_NS
22427 + if (mask & CLONE_NEWPID) {
22428 + old_pid = nsproxy->pid_ns;
22429 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22430 + if (nsproxy->pid_ns)
22431 + get_pid_ns(nsproxy->pid_ns);
22435 +#ifdef CONFIG_NET_NS
22436 + if (mask & CLONE_NEWNET) {
22437 + old_net = nsproxy->net_ns;
22438 + nsproxy->net_ns = new_nsproxy->net_ns;
22439 + if (nsproxy->net_ns)
22440 + get_net(nsproxy->net_ns);
22445 + put_mnt_ns(old_ns);
22447 + put_uts_ns(old_uts);
22449 + put_ipc_ns(old_ipc);
22450 +#ifdef CONFIG_PID_NS
22452 + put_pid_ns(old_pid);
22454 +#ifdef CONFIG_NET_NS
22456 + put_net(old_net);
22464 + * merge two nsproxy structs into a new one.
22465 + * will hold a reference on the result.
22469 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22470 + struct nsproxy *proxy, unsigned long mask)
22472 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22478 + /* vs_mix_nsproxy returns with reference */
22479 + return vs_mix_nsproxy(old ? old : &null_proxy,
22482 + get_nsproxy(proxy);
22487 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22489 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22490 + struct fs_struct *fs_cur, *fs = NULL;
22491 + struct _vx_space *space;
22492 + int ret, kill = 0;
22494 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22495 + vxi, vxi->vx_id, mask, index);
22497 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22500 + if (index >= VX_SPACES)
22503 + space = &vxi->space[index];
22506 + mask = space->vx_nsmask;
22508 + if ((mask & space->vx_nsmask) != mask)
22511 + if (mask & CLONE_FS) {
22512 + fs = copy_fs_struct(space->vx_fs);
22516 + proxy = space->vx_nsproxy;
22518 + vxdprintk(VXD_CBIT(space, 9),
22519 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
22520 + vxi, vxi->vx_id, mask, index, proxy, fs);
22522 + task_lock(current);
22523 + fs_cur = current->fs;
22525 + if (mask & CLONE_FS) {
22526 + spin_lock(&fs_cur->lock);
22527 + current->fs = fs;
22528 + kill = !--fs_cur->users;
22529 + spin_unlock(&fs_cur->lock);
22532 + proxy_cur = current->nsproxy;
22533 + get_nsproxy(proxy_cur);
22534 + task_unlock(current);
22537 + free_fs_struct(fs_cur);
22539 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
22540 + if (IS_ERR(proxy_new)) {
22541 + ret = PTR_ERR(proxy_new);
22545 + proxy_new = xchg(¤t->nsproxy, proxy_new);
22547 + if (mask & CLONE_NEWUSER) {
22548 + struct cred *cred;
22550 + vxdprintk(VXD_CBIT(space, 10),
22551 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
22552 + vxi, vxi->vx_id, space->vx_cred,
22553 + current->real_cred, current->cred);
22555 + if (space->vx_cred) {
22556 + cred = __prepare_creds(space->vx_cred);
22558 + commit_creds(cred);
22565 + put_nsproxy(proxy_new);
22568 + put_nsproxy(proxy_cur);
22573 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22575 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
22576 + struct fs_struct *fs_vxi, *fs = NULL;
22577 + struct _vx_space *space;
22578 + int ret, kill = 0;
22580 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
22581 + vxi, vxi->vx_id, mask, index);
22583 + if ((mask & space_mask.mask) != mask)
22586 + if (index >= VX_SPACES)
22589 + space = &vxi->space[index];
22591 + proxy_vxi = space->vx_nsproxy;
22592 + fs_vxi = space->vx_fs;
22594 + if (mask & CLONE_FS) {
22595 + fs = copy_fs_struct(current->fs);
22600 + task_lock(current);
22602 + if (mask & CLONE_FS) {
22603 + spin_lock(&fs_vxi->lock);
22604 + space->vx_fs = fs;
22605 + kill = !--fs_vxi->users;
22606 + spin_unlock(&fs_vxi->lock);
22609 + proxy_cur = current->nsproxy;
22610 + get_nsproxy(proxy_cur);
22611 + task_unlock(current);
22614 + free_fs_struct(fs_vxi);
22616 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
22617 + if (IS_ERR(proxy_new)) {
22618 + ret = PTR_ERR(proxy_new);
22622 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
22623 + space->vx_nsmask |= mask;
22625 + if (mask & CLONE_NEWUSER) {
22626 + struct cred *cred;
22628 + vxdprintk(VXD_CBIT(space, 10),
22629 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
22630 + vxi, vxi->vx_id, space->vx_cred,
22631 + current->real_cred, current->cred);
22633 + cred = prepare_creds();
22634 + cred = (struct cred *)xchg(&space->vx_cred, cred);
22636 + abort_creds(cred);
22642 + put_nsproxy(proxy_new);
22645 + put_nsproxy(proxy_cur);
22650 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
22652 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22654 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22657 + return vx_enter_space(vxi, vc_data.mask, 0);
22660 +int vc_enter_space(struct vx_info *vxi, void __user *data)
22662 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22664 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22667 + if (vc_data.index >= VX_SPACES)
22670 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
22673 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
22675 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22677 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22680 + return vx_set_space(vxi, vc_data.mask, 0);
22683 +int vc_set_space(struct vx_info *vxi, void __user *data)
22685 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22687 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22690 + if (vc_data.index >= VX_SPACES)
22693 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
22696 +int vc_get_space_mask(void __user *data, int type)
22698 + const struct vcmd_space_mask_v1 *mask;
22701 + mask = &space_mask_v0;
22702 + else if (type == 1)
22703 + mask = &space_mask;
22705 + mask = &default_space_mask;
22707 + vxdprintk(VXD_CBIT(space, 10),
22708 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
22710 + if (copy_to_user(data, mask, sizeof(*mask)))
22715 diff -NurpP --minimal linux-3.10.15/kernel/vserver/switch.c linux-3.10.15-vs2.3.6.6/kernel/vserver/switch.c
22716 --- linux-3.10.15/kernel/vserver/switch.c 1970-01-01 00:00:00.000000000 +0000
22717 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/switch.c 2013-08-22 20:30:00.000000000 +0000
22720 + * linux/kernel/vserver/switch.c
22722 + * Virtual Server: Syscall Switch
22724 + * Copyright (C) 2003-2011 Herbert Pötzl
22726 + * V0.01 syscall switch
22727 + * V0.02 added signal to context
22728 + * V0.03 added rlimit functions
22729 + * V0.04 added iattr, task/xid functions
22730 + * V0.05 added debug/history stuff
22731 + * V0.06 added compat32 layer
22732 + * V0.07 vcmd args and perms
22733 + * V0.08 added status commands
22734 + * V0.09 added tag commands
22735 + * V0.10 added oom bias
22736 + * V0.11 added device commands
22737 + * V0.12 added warn mask
22741 +#include <linux/vs_context.h>
22742 +#include <linux/vs_network.h>
22743 +#include <linux/vserver/switch.h>
22745 +#include "vci_config.h"
22749 +int vc_get_version(uint32_t id)
22751 + return VCI_VERSION;
22755 +int vc_get_vci(uint32_t id)
22757 + return vci_kernel_config();
22760 +#include <linux/vserver/context_cmd.h>
22761 +#include <linux/vserver/cvirt_cmd.h>
22762 +#include <linux/vserver/cacct_cmd.h>
22763 +#include <linux/vserver/limit_cmd.h>
22764 +#include <linux/vserver/network_cmd.h>
22765 +#include <linux/vserver/sched_cmd.h>
22766 +#include <linux/vserver/debug_cmd.h>
22767 +#include <linux/vserver/inode_cmd.h>
22768 +#include <linux/vserver/dlimit_cmd.h>
22769 +#include <linux/vserver/signal_cmd.h>
22770 +#include <linux/vserver/space_cmd.h>
22771 +#include <linux/vserver/tag_cmd.h>
22772 +#include <linux/vserver/device_cmd.h>
22774 +#include <linux/vserver/inode.h>
22775 +#include <linux/vserver/dlimit.h>
22778 +#ifdef CONFIG_COMPAT
22779 +#define __COMPAT(name, id, data, compat) \
22780 + (compat) ? name ## _x32(id, data) : name(id, data)
22781 +#define __COMPAT_NO_ID(name, data, compat) \
22782 + (compat) ? name ## _x32(data) : name(data)
22784 +#define __COMPAT(name, id, data, compat) \
22786 +#define __COMPAT_NO_ID(name, data, compat) \
22792 +long do_vcmd(uint32_t cmd, uint32_t id,
22793 + struct vx_info *vxi, struct nx_info *nxi,
22794 + void __user *data, int compat)
22798 + case VCMD_get_version:
22799 + return vc_get_version(id);
22800 + case VCMD_get_vci:
22801 + return vc_get_vci(id);
22803 + case VCMD_task_xid:
22804 + return vc_task_xid(id);
22805 + case VCMD_vx_info:
22806 + return vc_vx_info(vxi, data);
22808 + case VCMD_task_nid:
22809 + return vc_task_nid(id);
22810 + case VCMD_nx_info:
22811 + return vc_nx_info(nxi, data);
22813 + case VCMD_task_tag:
22814 + return vc_task_tag(id);
22816 + case VCMD_set_space_v1:
22817 + return vc_set_space_v1(vxi, data);
22818 + /* this is version 2 */
22819 + case VCMD_set_space:
22820 + return vc_set_space(vxi, data);
22822 + case VCMD_get_space_mask_v0:
22823 + return vc_get_space_mask(data, 0);
22824 + /* this is version 1 */
22825 + case VCMD_get_space_mask:
22826 + return vc_get_space_mask(data, 1);
22828 + case VCMD_get_space_default:
22829 + return vc_get_space_mask(data, -1);
22831 + case VCMD_set_umask:
22832 + return vc_set_umask(vxi, data);
22834 + case VCMD_get_umask:
22835 + return vc_get_umask(vxi, data);
22837 + case VCMD_set_wmask:
22838 + return vc_set_wmask(vxi, data);
22840 + case VCMD_get_wmask:
22841 + return vc_get_wmask(vxi, data);
22842 +#ifdef CONFIG_IA32_EMULATION
22843 + case VCMD_get_rlimit:
22844 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
22845 + case VCMD_set_rlimit:
22846 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
22848 + case VCMD_get_rlimit:
22849 + return vc_get_rlimit(vxi, data);
22850 + case VCMD_set_rlimit:
22851 + return vc_set_rlimit(vxi, data);
22853 + case VCMD_get_rlimit_mask:
22854 + return vc_get_rlimit_mask(id, data);
22855 + case VCMD_reset_hits:
22856 + return vc_reset_hits(vxi, data);
22857 + case VCMD_reset_minmax:
22858 + return vc_reset_minmax(vxi, data);
22860 + case VCMD_get_vhi_name:
22861 + return vc_get_vhi_name(vxi, data);
22862 + case VCMD_set_vhi_name:
22863 + return vc_set_vhi_name(vxi, data);
22865 + case VCMD_ctx_stat:
22866 + return vc_ctx_stat(vxi, data);
22867 + case VCMD_virt_stat:
22868 + return vc_virt_stat(vxi, data);
22869 + case VCMD_sock_stat:
22870 + return vc_sock_stat(vxi, data);
22871 + case VCMD_rlimit_stat:
22872 + return vc_rlimit_stat(vxi, data);
22874 + case VCMD_set_cflags:
22875 + return vc_set_cflags(vxi, data);
22876 + case VCMD_get_cflags:
22877 + return vc_get_cflags(vxi, data);
22879 + /* this is version 1 */
22880 + case VCMD_set_ccaps:
22881 + return vc_set_ccaps(vxi, data);
22882 + /* this is version 1 */
22883 + case VCMD_get_ccaps:
22884 + return vc_get_ccaps(vxi, data);
22885 + case VCMD_set_bcaps:
22886 + return vc_set_bcaps(vxi, data);
22887 + case VCMD_get_bcaps:
22888 + return vc_get_bcaps(vxi, data);
22890 + case VCMD_set_badness:
22891 + return vc_set_badness(vxi, data);
22892 + case VCMD_get_badness:
22893 + return vc_get_badness(vxi, data);
22895 + case VCMD_set_nflags:
22896 + return vc_set_nflags(nxi, data);
22897 + case VCMD_get_nflags:
22898 + return vc_get_nflags(nxi, data);
22900 + case VCMD_set_ncaps:
22901 + return vc_set_ncaps(nxi, data);
22902 + case VCMD_get_ncaps:
22903 + return vc_get_ncaps(nxi, data);
22905 + case VCMD_set_prio_bias:
22906 + return vc_set_prio_bias(vxi, data);
22907 + case VCMD_get_prio_bias:
22908 + return vc_get_prio_bias(vxi, data);
22909 + case VCMD_add_dlimit:
22910 + return __COMPAT(vc_add_dlimit, id, data, compat);
22911 + case VCMD_rem_dlimit:
22912 + return __COMPAT(vc_rem_dlimit, id, data, compat);
22913 + case VCMD_set_dlimit:
22914 + return __COMPAT(vc_set_dlimit, id, data, compat);
22915 + case VCMD_get_dlimit:
22916 + return __COMPAT(vc_get_dlimit, id, data, compat);
22918 + case VCMD_ctx_kill:
22919 + return vc_ctx_kill(vxi, data);
22921 + case VCMD_wait_exit:
22922 + return vc_wait_exit(vxi, data);
22924 + case VCMD_get_iattr:
22925 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
22926 + case VCMD_set_iattr:
22927 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
22929 + case VCMD_fget_iattr:
22930 + return vc_fget_iattr(id, data);
22931 + case VCMD_fset_iattr:
22932 + return vc_fset_iattr(id, data);
22934 + case VCMD_enter_space_v0:
22935 + return vc_enter_space_v1(vxi, NULL);
22936 + case VCMD_enter_space_v1:
22937 + return vc_enter_space_v1(vxi, data);
22938 + /* this is version 2 */
22939 + case VCMD_enter_space:
22940 + return vc_enter_space(vxi, data);
22942 + case VCMD_ctx_create_v0:
22943 + return vc_ctx_create(id, NULL);
22944 + case VCMD_ctx_create:
22945 + return vc_ctx_create(id, data);
22946 + case VCMD_ctx_migrate_v0:
22947 + return vc_ctx_migrate(vxi, NULL);
22948 + case VCMD_ctx_migrate:
22949 + return vc_ctx_migrate(vxi, data);
22951 + case VCMD_net_create_v0:
22952 + return vc_net_create(id, NULL);
22953 + case VCMD_net_create:
22954 + return vc_net_create(id, data);
22955 + case VCMD_net_migrate:
22956 + return vc_net_migrate(nxi, data);
22958 + case VCMD_tag_migrate:
22959 + return vc_tag_migrate(id);
22961 + case VCMD_net_add:
22962 + return vc_net_add(nxi, data);
22963 + case VCMD_net_remove:
22964 + return vc_net_remove(nxi, data);
22966 + case VCMD_net_add_ipv4_v1:
22967 + return vc_net_add_ipv4_v1(nxi, data);
22968 + /* this is version 2 */
22969 + case VCMD_net_add_ipv4:
22970 + return vc_net_add_ipv4(nxi, data);
22972 + case VCMD_net_rem_ipv4_v1:
22973 + return vc_net_rem_ipv4_v1(nxi, data);
22974 + /* this is version 2 */
22975 + case VCMD_net_rem_ipv4:
22976 + return vc_net_rem_ipv4(nxi, data);
22977 +#ifdef CONFIG_IPV6
22978 + case VCMD_net_add_ipv6:
22979 + return vc_net_add_ipv6(nxi, data);
22980 + case VCMD_net_remove_ipv6:
22981 + return vc_net_remove_ipv6(nxi, data);
22983 +/* case VCMD_add_match_ipv4:
22984 + return vc_add_match_ipv4(nxi, data);
22985 + case VCMD_get_match_ipv4:
22986 + return vc_get_match_ipv4(nxi, data);
22987 +#ifdef CONFIG_IPV6
22988 + case VCMD_add_match_ipv6:
22989 + return vc_add_match_ipv6(nxi, data);
22990 + case VCMD_get_match_ipv6:
22991 + return vc_get_match_ipv6(nxi, data);
22994 +#ifdef CONFIG_VSERVER_DEVICE
22995 + case VCMD_set_mapping:
22996 + return __COMPAT(vc_set_mapping, vxi, data, compat);
22997 + case VCMD_unset_mapping:
22998 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23000 +#ifdef CONFIG_VSERVER_HISTORY
23001 + case VCMD_dump_history:
23002 + return vc_dump_history(id);
23003 + case VCMD_read_history:
23004 + return __COMPAT(vc_read_history, id, data, compat);
23007 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23008 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23014 +#define __VCMD(vcmd, _perm, _args, _flags) \
23015 + case VCMD_ ## vcmd: perm = _perm; \
23016 + args = _args; flags = _flags; break
23019 +#define VCA_NONE 0x00
23020 +#define VCA_VXI 0x01
23021 +#define VCA_NXI 0x02
23023 +#define VCF_NONE 0x00
23024 +#define VCF_INFO 0x01
23025 +#define VCF_ADMIN 0x02
23026 +#define VCF_ARES 0x06 /* includes admin */
23027 +#define VCF_SETUP 0x08
23029 +#define VCF_ZIDOK 0x10 /* zero id okay */
23033 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23036 + int permit = -1, state = 0;
23037 + int perm = -1, args = 0, flags = 0;
23038 + struct vx_info *vxi = NULL;
23039 + struct nx_info *nxi = NULL;
23042 + /* unpriviledged commands */
23043 + __VCMD(get_version, 0, VCA_NONE, 0);
23044 + __VCMD(get_vci, 0, VCA_NONE, 0);
23045 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23046 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23047 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23048 + __VCMD(get_space_default,0, VCA_NONE, 0);
23050 + /* info commands */
23051 + __VCMD(task_xid, 2, VCA_NONE, 0);
23052 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23053 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23054 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23055 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23056 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23057 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23058 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23059 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23060 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23061 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23062 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23064 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23065 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23066 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23067 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23069 + __VCMD(task_nid, 2, VCA_NONE, 0);
23070 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23071 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23072 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23074 + __VCMD(task_tag, 2, VCA_NONE, 0);
23076 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23077 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23078 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23079 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23081 + /* lower admin commands */
23082 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23083 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23084 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23085 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23086 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23087 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23088 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23089 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23091 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23092 + __VCMD(net_create, 5, VCA_NONE, 0);
23093 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23095 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23097 + /* higher admin commands */
23098 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23099 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23100 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23102 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23103 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23104 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23105 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23106 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23107 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23109 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23110 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23111 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23113 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23114 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23115 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23116 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23117 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23118 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23119 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23120 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23121 +#ifdef CONFIG_IPV6
23122 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23123 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23125 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23126 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23127 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23128 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23129 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23131 +#ifdef CONFIG_VSERVER_DEVICE
23132 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23133 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23135 + /* debug level admin commands */
23136 +#ifdef CONFIG_VSERVER_HISTORY
23137 + __VCMD(dump_history, 9, VCA_NONE, 0);
23138 + __VCMD(read_history, 9, VCA_NONE, 0);
23145 + vxdprintk(VXD_CBIT(switch, 0),
23146 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23147 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23148 + VC_VERSION(cmd), id, data, compat,
23149 + perm, args, flags);
23156 + if (!capable(CAP_CONTEXT))
23160 + /* moved here from the individual commands */
23162 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23166 + /* vcmd involves resource management */
23168 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23172 + /* various legacy exceptions */
23174 + /* will go away when spectator is a cap */
23175 + case VCMD_ctx_migrate_v0:
23176 + case VCMD_ctx_migrate:
23178 + current->xid = 1;
23184 + /* will go away when spectator is a cap */
23185 + case VCMD_net_migrate:
23187 + current->nid = 1;
23194 + /* vcmds are fine by default */
23197 + /* admin type vcmds require admin ... */
23198 + if (flags & VCF_ADMIN)
23199 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23201 + /* ... but setup type vcmds override that */
23202 + if (!permit && (flags & VCF_SETUP))
23203 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23211 + if (!id && (flags & VCF_ZIDOK))
23215 + if (args & VCA_VXI) {
23216 + vxi = lookup_vx_info(id);
23220 + if ((flags & VCF_ADMIN) &&
23221 + /* special case kill for shutdown */
23222 + (cmd != VCMD_ctx_kill) &&
23223 + /* can context be administrated? */
23224 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23230 + if (args & VCA_NXI) {
23231 + nxi = lookup_nx_info(id);
23235 + if ((flags & VCF_ADMIN) &&
23236 + /* can context be administrated? */
23237 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23244 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23247 + if ((args & VCA_NXI) && nxi)
23248 + put_nx_info(nxi);
23250 + if ((args & VCA_VXI) && vxi)
23251 + put_vx_info(vxi);
23253 + vxdprintk(VXD_CBIT(switch, 1),
23254 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23255 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23256 + VC_VERSION(cmd), ret, ret, state, permit);
23261 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23263 + return do_vserver(cmd, id, data, 0);
23266 +#ifdef CONFIG_COMPAT
23269 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23271 + return do_vserver(cmd, id, data, 1);
23274 +#endif /* CONFIG_COMPAT */
23275 diff -NurpP --minimal linux-3.10.15/kernel/vserver/sysctl.c linux-3.10.15-vs2.3.6.6/kernel/vserver/sysctl.c
23276 --- linux-3.10.15/kernel/vserver/sysctl.c 1970-01-01 00:00:00.000000000 +0000
23277 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/sysctl.c 2013-08-22 20:30:00.000000000 +0000
23280 + * kernel/vserver/sysctl.c
23282 + * Virtual Context Support
23284 + * Copyright (C) 2004-2007 Herbert Pötzl
23286 + * V0.01 basic structure
23290 +#include <linux/module.h>
23291 +#include <linux/ctype.h>
23292 +#include <linux/sysctl.h>
23293 +#include <linux/parser.h>
23294 +#include <asm/uaccess.h>
23297 + CTL_DEBUG_ERROR = 0,
23298 + CTL_DEBUG_SWITCH = 1,
23314 +unsigned int vs_debug_switch = 0;
23315 +unsigned int vs_debug_xid = 0;
23316 +unsigned int vs_debug_nid = 0;
23317 +unsigned int vs_debug_tag = 0;
23318 +unsigned int vs_debug_net = 0;
23319 +unsigned int vs_debug_limit = 0;
23320 +unsigned int vs_debug_cres = 0;
23321 +unsigned int vs_debug_dlim = 0;
23322 +unsigned int vs_debug_quota = 0;
23323 +unsigned int vs_debug_cvirt = 0;
23324 +unsigned int vs_debug_space = 0;
23325 +unsigned int vs_debug_perm = 0;
23326 +unsigned int vs_debug_misc = 0;
23329 +static struct ctl_table_header *vserver_table_header;
23330 +static ctl_table vserver_root_table[];
23333 +void vserver_register_sysctl(void)
23335 + if (!vserver_table_header) {
23336 + vserver_table_header = register_sysctl_table(vserver_root_table);
23341 +void vserver_unregister_sysctl(void)
23343 + if (vserver_table_header) {
23344 + unregister_sysctl_table(vserver_table_header);
23345 + vserver_table_header = NULL;
23350 +static int proc_dodebug(ctl_table *table, int write,
23351 + void __user *buffer, size_t *lenp, loff_t *ppos)
23353 + char tmpbuf[20], *p, c;
23354 + unsigned int value;
23355 + size_t left, len;
23357 + if ((*ppos && !write) || !*lenp) {
23365 + if (!access_ok(VERIFY_READ, buffer, left))
23367 + p = (char *)buffer;
23368 + while (left && __get_user(c, p) >= 0 && isspace(c))
23373 + if (left > sizeof(tmpbuf) - 1)
23375 + if (copy_from_user(tmpbuf, p, left))
23377 + tmpbuf[left] = '\0';
23379 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23380 + value = 10 * value + (*p - '0');
23381 + if (*p && !isspace(*p))
23383 + while (left && isspace(*p))
23385 + *(unsigned int *)table->data = value;
23387 + if (!access_ok(VERIFY_WRITE, buffer, left))
23389 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23392 + if (__copy_to_user(buffer, tmpbuf, len))
23394 + if ((left -= len) > 0) {
23395 + if (put_user('\n', (char *)buffer + len))
23409 +#define CTL_ENTRY(ctl, name) \
23411 + .procname = #name, \
23412 + .data = &vs_ ## name, \
23413 + .maxlen = sizeof(int), \
23415 + .proc_handler = &proc_dodebug, \
23416 + .extra1 = &zero, \
23417 + .extra2 = &zero, \
23420 +static ctl_table vserver_debug_table[] = {
23421 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23422 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23423 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23424 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23425 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23426 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23427 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23428 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23429 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23430 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23431 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23432 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23433 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23437 +static ctl_table vserver_root_table[] = {
23439 + .procname = "vserver",
23441 + .child = vserver_debug_table
23447 +static match_table_t tokens = {
23448 + { CTL_DEBUG_SWITCH, "switch=%x" },
23449 + { CTL_DEBUG_XID, "xid=%x" },
23450 + { CTL_DEBUG_NID, "nid=%x" },
23451 + { CTL_DEBUG_TAG, "tag=%x" },
23452 + { CTL_DEBUG_NET, "net=%x" },
23453 + { CTL_DEBUG_LIMIT, "limit=%x" },
23454 + { CTL_DEBUG_CRES, "cres=%x" },
23455 + { CTL_DEBUG_DLIM, "dlim=%x" },
23456 + { CTL_DEBUG_QUOTA, "quota=%x" },
23457 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23458 + { CTL_DEBUG_SPACE, "space=%x" },
23459 + { CTL_DEBUG_PERM, "perm=%x" },
23460 + { CTL_DEBUG_MISC, "misc=%x" },
23461 + { CTL_DEBUG_ERROR, NULL }
23464 +#define HANDLE_CASE(id, name, val) \
23465 + case CTL_DEBUG_ ## id: \
23466 + vs_debug_ ## name = val; \
23467 + printk("vs_debug_" #name "=0x%x\n", val); \
23471 +static int __init vs_debug_setup(char *str)
23476 + printk("vs_debug_setup(%s)\n", str);
23477 + while ((p = strsep(&str, ",")) != NULL) {
23478 + substring_t args[MAX_OPT_ARGS];
23479 + unsigned int value;
23484 + token = match_token(p, tokens, args);
23485 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23488 + HANDLE_CASE(SWITCH, switch, value);
23489 + HANDLE_CASE(XID, xid, value);
23490 + HANDLE_CASE(NID, nid, value);
23491 + HANDLE_CASE(TAG, tag, value);
23492 + HANDLE_CASE(NET, net, value);
23493 + HANDLE_CASE(LIMIT, limit, value);
23494 + HANDLE_CASE(CRES, cres, value);
23495 + HANDLE_CASE(DLIM, dlim, value);
23496 + HANDLE_CASE(QUOTA, quota, value);
23497 + HANDLE_CASE(CVIRT, cvirt, value);
23498 + HANDLE_CASE(SPACE, space, value);
23499 + HANDLE_CASE(PERM, perm, value);
23500 + HANDLE_CASE(MISC, misc, value);
23509 +__setup("vsdebug=", vs_debug_setup);
23513 +EXPORT_SYMBOL_GPL(vs_debug_switch);
23514 +EXPORT_SYMBOL_GPL(vs_debug_xid);
23515 +EXPORT_SYMBOL_GPL(vs_debug_nid);
23516 +EXPORT_SYMBOL_GPL(vs_debug_net);
23517 +EXPORT_SYMBOL_GPL(vs_debug_limit);
23518 +EXPORT_SYMBOL_GPL(vs_debug_cres);
23519 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
23520 +EXPORT_SYMBOL_GPL(vs_debug_quota);
23521 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
23522 +EXPORT_SYMBOL_GPL(vs_debug_space);
23523 +EXPORT_SYMBOL_GPL(vs_debug_perm);
23524 +EXPORT_SYMBOL_GPL(vs_debug_misc);
23526 diff -NurpP --minimal linux-3.10.15/kernel/vserver/tag.c linux-3.10.15-vs2.3.6.6/kernel/vserver/tag.c
23527 --- linux-3.10.15/kernel/vserver/tag.c 1970-01-01 00:00:00.000000000 +0000
23528 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/tag.c 2013-08-22 20:30:00.000000000 +0000
23531 + * linux/kernel/vserver/tag.c
23533 + * Virtual Server: Shallow Tag Space
23535 + * Copyright (C) 2007 Herbert Pötzl
23537 + * V0.01 basic implementation
23541 +#include <linux/sched.h>
23542 +#include <linux/vserver/debug.h>
23543 +#include <linux/vs_pid.h>
23544 +#include <linux/vs_tag.h>
23546 +#include <linux/vserver/tag_cmd.h>
23549 +int dx_migrate_task(struct task_struct *p, vtag_t tag)
23554 + vxdprintk(VXD_CBIT(tag, 5),
23555 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23561 + vxdprintk(VXD_CBIT(tag, 5),
23562 + "moved task %p into [#%d]", p, tag);
23566 +/* vserver syscall commands below here */
23568 +/* taks xid and vx_info functions */
23571 +int vc_task_tag(uint32_t id)
23576 + struct task_struct *tsk;
23578 + tsk = find_task_by_real_pid(id);
23579 + tag = (tsk) ? tsk->tag : -ESRCH;
23580 + rcu_read_unlock();
23582 + tag = dx_current_tag();
23587 +int vc_tag_migrate(uint32_t tag)
23589 + return dx_migrate_task(current, tag & 0xFFFF);
23593 diff -NurpP --minimal linux-3.10.15/kernel/vserver/vci_config.h linux-3.10.15-vs2.3.6.6/kernel/vserver/vci_config.h
23594 --- linux-3.10.15/kernel/vserver/vci_config.h 1970-01-01 00:00:00.000000000 +0000
23595 +++ linux-3.10.15-vs2.3.6.6/kernel/vserver/vci_config.h 2013-08-22 20:30:00.000000000 +0000
23598 +/* interface version */
23600 +#define VCI_VERSION 0x00020308
23604 + VCI_KCBIT_NO_DYNAMIC = 0,
23606 + VCI_KCBIT_PROC_SECURE = 4,
23607 + /* VCI_KCBIT_HARDCPU = 5, */
23608 + /* VCI_KCBIT_IDLELIMIT = 6, */
23609 + /* VCI_KCBIT_IDLETIME = 7, */
23611 + VCI_KCBIT_COWBL = 8,
23612 + VCI_KCBIT_FULLCOWBL = 9,
23613 + VCI_KCBIT_SPACES = 10,
23614 + VCI_KCBIT_NETV2 = 11,
23615 + VCI_KCBIT_MEMCG = 12,
23616 + VCI_KCBIT_MEMCG_SWAP = 13,
23618 + VCI_KCBIT_DEBUG = 16,
23619 + VCI_KCBIT_HISTORY = 20,
23620 + VCI_KCBIT_TAGGED = 24,
23621 + VCI_KCBIT_PPTAG = 28,
23623 + VCI_KCBIT_MORE = 31,
23627 +static inline uint32_t vci_kernel_config(void)
23630 + (1 << VCI_KCBIT_NO_DYNAMIC) |
23632 + /* configured features */
23633 +#ifdef CONFIG_VSERVER_PROC_SECURE
23634 + (1 << VCI_KCBIT_PROC_SECURE) |
23636 +#ifdef CONFIG_VSERVER_COWBL
23637 + (1 << VCI_KCBIT_COWBL) |
23638 + (1 << VCI_KCBIT_FULLCOWBL) |
23640 + (1 << VCI_KCBIT_SPACES) |
23641 + (1 << VCI_KCBIT_NETV2) |
23642 +#ifdef CONFIG_MEMCG
23643 + (1 << VCI_KCBIT_MEMCG) |
23645 +#ifdef CONFIG_MEMCG_SWAP
23646 + (1 << VCI_KCBIT_MEMCG_SWAP) |
23649 + /* debug options */
23650 +#ifdef CONFIG_VSERVER_DEBUG
23651 + (1 << VCI_KCBIT_DEBUG) |
23653 +#ifdef CONFIG_VSERVER_HISTORY
23654 + (1 << VCI_KCBIT_HISTORY) |
23657 + /* inode context tagging */
23658 +#if defined(CONFIG_TAGGING_NONE)
23659 + (0 << VCI_KCBIT_TAGGED) |
23660 +#elif defined(CONFIG_TAGGING_UID16)
23661 + (1 << VCI_KCBIT_TAGGED) |
23662 +#elif defined(CONFIG_TAGGING_GID16)
23663 + (2 << VCI_KCBIT_TAGGED) |
23664 +#elif defined(CONFIG_TAGGING_ID24)
23665 + (3 << VCI_KCBIT_TAGGED) |
23666 +#elif defined(CONFIG_TAGGING_INTERN)
23667 + (4 << VCI_KCBIT_TAGGED) |
23668 +#elif defined(CONFIG_TAGGING_RUNTIME)
23669 + (5 << VCI_KCBIT_TAGGED) |
23671 + (7 << VCI_KCBIT_TAGGED) |
23673 + (1 << VCI_KCBIT_PPTAG) |
23677 diff -NurpP --minimal linux-3.10.15/mm/memcontrol.c linux-3.10.15-vs2.3.6.6/mm/memcontrol.c
23678 --- linux-3.10.15/mm/memcontrol.c 2013-10-09 17:35:23.000000000 +0000
23679 +++ linux-3.10.15-vs2.3.6.6/mm/memcontrol.c 2013-10-09 17:37:22.000000000 +0000
23680 @@ -1082,6 +1082,31 @@ struct mem_cgroup *mem_cgroup_from_task(
23681 return mem_cgroup_from_css(task_subsys_state(p, mem_cgroup_subsys_id));
23684 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
23686 + return res_counter_read_u64(&mem->res, member);
23689 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
23691 + return res_counter_read_u64(&mem->memsw, member);
23694 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
23696 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
23699 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
23701 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
23704 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
23706 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
23709 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
23711 struct mem_cgroup *memcg = NULL;
23712 diff -NurpP --minimal linux-3.10.15/mm/oom_kill.c linux-3.10.15-vs2.3.6.6/mm/oom_kill.c
23713 --- linux-3.10.15/mm/oom_kill.c 2013-05-31 13:45:31.000000000 +0000
23714 +++ linux-3.10.15-vs2.3.6.6/mm/oom_kill.c 2013-08-22 20:30:00.000000000 +0000
23716 #include <linux/freezer.h>
23717 #include <linux/ftrace.h>
23718 #include <linux/ratelimit.h>
23719 +#include <linux/reboot.h>
23720 +#include <linux/vs_context.h>
23722 #define CREATE_TRACE_POINTS
23723 #include <trace/events/oom.h>
23724 @@ -113,11 +115,18 @@ struct task_struct *find_lock_task_mm(st
23725 static bool oom_unkillable_task(struct task_struct *p,
23726 const struct mem_cgroup *memcg, const nodemask_t *nodemask)
23728 - if (is_global_init(p))
23729 + unsigned xid = vx_current_xid();
23731 + /* skip the init task, global and per guest */
23732 + if (task_is_init(p))
23734 if (p->flags & PF_KTHREAD)
23737 + /* skip other guest and host processes if oom in guest */
23738 + if (xid && vx_task_xid(p) != xid)
23741 /* When mem_cgroup_out_of_memory() and p is not member of the group */
23742 if (memcg && !task_in_mem_cgroup(p, memcg))
23744 @@ -426,8 +435,8 @@ void oom_kill_process(struct task_struct
23745 dump_header(p, gfp_mask, order, memcg, nodemask);
23748 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
23749 - message, task_pid_nr(p), p->comm, points);
23750 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
23751 + message, task_pid_nr(p), p->xid, p->comm, points);
23755 @@ -472,8 +481,8 @@ void oom_kill_process(struct task_struct
23757 /* mm cannot safely be dereferenced after task_unlock(victim) */
23759 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23760 - task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
23761 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23762 + task_pid_nr(victim), victim->xid, victim->comm, K(victim->mm->total_vm),
23763 K(get_mm_counter(victim->mm, MM_ANONPAGES)),
23764 K(get_mm_counter(victim->mm, MM_FILEPAGES)));
23765 task_unlock(victim);
23766 @@ -543,6 +552,8 @@ int unregister_oom_notifier(struct notif
23768 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
23770 +long vs_oom_action(unsigned int);
23773 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
23774 * if a parallel OOM killing is already taking place that includes a zone in
23775 @@ -655,7 +666,12 @@ void out_of_memory(struct zonelist *zone
23776 /* Found nothing?!?! Either we hang forever, or we panic. */
23778 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
23779 - panic("Out of memory and no killable processes...\n");
23781 + /* avoid panic for guest OOM */
23782 + if (vx_current_xid())
23783 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
23785 + panic("Out of memory and no killable processes...\n");
23787 if (PTR_ERR(p) != -1UL) {
23788 oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
23789 diff -NurpP --minimal linux-3.10.15/mm/page_alloc.c linux-3.10.15-vs2.3.6.6/mm/page_alloc.c
23790 --- linux-3.10.15/mm/page_alloc.c 2013-10-09 17:35:23.000000000 +0000
23791 +++ linux-3.10.15-vs2.3.6.6/mm/page_alloc.c 2013-08-22 20:30:00.000000000 +0000
23793 #include <linux/page-debug-flags.h>
23794 #include <linux/hugetlb.h>
23795 #include <linux/sched/rt.h>
23796 +#include <linux/vs_base.h>
23797 +#include <linux/vs_limit.h>
23799 #include <asm/tlbflush.h>
23800 #include <asm/div64.h>
23801 @@ -2899,6 +2901,9 @@ void si_meminfo(struct sysinfo *val)
23802 val->totalhigh = totalhigh_pages;
23803 val->freehigh = nr_free_highpages();
23804 val->mem_unit = PAGE_SIZE;
23806 + if (vx_flags(VXF_VIRT_MEM, 0))
23807 + vx_vsi_meminfo(val);
23810 EXPORT_SYMBOL(si_meminfo);
23811 @@ -2919,6 +2924,9 @@ void si_meminfo_node(struct sysinfo *val
23814 val->mem_unit = PAGE_SIZE;
23816 + if (vx_flags(VXF_VIRT_MEM, 0))
23817 + vx_vsi_meminfo(val);
23821 diff -NurpP --minimal linux-3.10.15/mm/pgtable-generic.c linux-3.10.15-vs2.3.6.6/mm/pgtable-generic.c
23822 --- linux-3.10.15/mm/pgtable-generic.c 2013-02-19 13:58:57.000000000 +0000
23823 +++ linux-3.10.15-vs2.3.6.6/mm/pgtable-generic.c 2013-08-22 20:30:00.000000000 +0000
23825 * Copyright (C) 2010 Linus Torvalds
23828 +#include <linux/mm.h>
23830 #include <linux/pagemap.h>
23831 #include <asm/tlb.h>
23832 #include <asm-generic/pgtable.h>
23833 diff -NurpP --minimal linux-3.10.15/mm/shmem.c linux-3.10.15-vs2.3.6.6/mm/shmem.c
23834 --- linux-3.10.15/mm/shmem.c 2013-07-14 17:01:36.000000000 +0000
23835 +++ linux-3.10.15-vs2.3.6.6/mm/shmem.c 2013-08-22 20:30:00.000000000 +0000
23836 @@ -1911,7 +1911,7 @@ static int shmem_statfs(struct dentry *d
23838 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
23840 - buf->f_type = TMPFS_MAGIC;
23841 + buf->f_type = TMPFS_SUPER_MAGIC;
23842 buf->f_bsize = PAGE_CACHE_SIZE;
23843 buf->f_namelen = NAME_MAX;
23844 if (sbinfo->max_blocks) {
23845 @@ -2608,7 +2608,7 @@ int shmem_fill_super(struct super_block
23846 sb->s_maxbytes = MAX_LFS_FILESIZE;
23847 sb->s_blocksize = PAGE_CACHE_SIZE;
23848 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
23849 - sb->s_magic = TMPFS_MAGIC;
23850 + sb->s_magic = TMPFS_SUPER_MAGIC;
23851 sb->s_op = &shmem_ops;
23852 sb->s_time_gran = 1;
23853 #ifdef CONFIG_TMPFS_XATTR
23854 diff -NurpP --minimal linux-3.10.15/mm/slab.c linux-3.10.15-vs2.3.6.6/mm/slab.c
23855 --- linux-3.10.15/mm/slab.c 2013-10-09 17:35:23.000000000 +0000
23856 +++ linux-3.10.15-vs2.3.6.6/mm/slab.c 2013-08-22 21:01:54.000000000 +0000
23857 @@ -388,6 +388,8 @@ static void kmem_cache_node_init(struct
23858 #define STATS_INC_FREEMISS(x) do { } while (0)
23861 +#include "slab_vs.h"
23866 @@ -3314,6 +3316,7 @@ retry:
23868 obj = slab_get_obj(cachep, slabp, nodeid);
23869 check_slabp(cachep, slabp);
23870 + vx_slab_alloc(cachep, flags);
23872 /* move slabp to correct slabp list: */
23873 list_del(&slabp->list);
23874 @@ -3393,6 +3396,7 @@ slab_alloc_node(struct kmem_cache *cache
23875 /* ___cache_alloc_node can fall back to other nodes */
23876 ptr = ____cache_alloc_node(cachep, flags, nodeid);
23878 + vx_slab_alloc(cachep, flags);
23879 local_irq_restore(save_flags);
23880 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
23881 kmemleak_alloc_recursive(ptr, cachep->object_size, 1, cachep->flags,
23882 @@ -3585,6 +3589,7 @@ static inline void __cache_free(struct k
23884 kmemleak_free_recursive(objp, cachep->flags);
23885 objp = cache_free_debugcheck(cachep, objp, caller);
23886 + vx_slab_free(cachep);
23888 kmemcheck_slab_free(cachep, objp, cachep->object_size);
23890 diff -NurpP --minimal linux-3.10.15/mm/slab_vs.h linux-3.10.15-vs2.3.6.6/mm/slab_vs.h
23891 --- linux-3.10.15/mm/slab_vs.h 1970-01-01 00:00:00.000000000 +0000
23892 +++ linux-3.10.15-vs2.3.6.6/mm/slab_vs.h 2013-08-22 20:30:00.000000000 +0000
23895 +#include <linux/vserver/context.h>
23897 +#include <linux/vs_context.h>
23900 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
23902 + int what = gfp_zone(cachep->allocflags);
23903 + struct vx_info *vxi = current_vx_info();
23908 + atomic_add(cachep->size, &vxi->cacct.slab[what]);
23912 +void vx_slab_free(struct kmem_cache *cachep)
23914 + int what = gfp_zone(cachep->allocflags);
23915 + struct vx_info *vxi = current_vx_info();
23920 + atomic_sub(cachep->size, &vxi->cacct.slab[what]);
23923 diff -NurpP --minimal linux-3.10.15/mm/swapfile.c linux-3.10.15-vs2.3.6.6/mm/swapfile.c
23924 --- linux-3.10.15/mm/swapfile.c 2013-07-14 17:01:36.000000000 +0000
23925 +++ linux-3.10.15-vs2.3.6.6/mm/swapfile.c 2013-08-22 20:30:00.000000000 +0000
23927 #include <asm/tlbflush.h>
23928 #include <linux/swapops.h>
23929 #include <linux/page_cgroup.h>
23930 +#include <linux/vs_base.h>
23932 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
23934 @@ -1768,6 +1769,16 @@ static int swap_show(struct seq_file *sw
23936 if (si == SEQ_START_TOKEN) {
23937 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
23938 + if (vx_flags(VXF_VIRT_MEM, 0)) {
23939 + struct sysinfo si;
23941 + vx_vsi_swapinfo(&si);
23942 + if (si.totalswap < (1 << 10))
23944 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
23945 + "hdv0", "partition", si.totalswap >> 10,
23946 + (si.totalswap - si.freeswap) >> 10, -1);
23951 @@ -2196,6 +2207,8 @@ void si_swapinfo(struct sysinfo *val)
23952 val->freeswap = atomic_long_read(&nr_swap_pages) + nr_to_be_unused;
23953 val->totalswap = total_swap_pages + nr_to_be_unused;
23954 spin_unlock(&swap_lock);
23955 + if (vx_flags(VXF_VIRT_MEM, 0))
23956 + vx_vsi_swapinfo(val);
23960 diff -NurpP --minimal linux-3.10.15/net/bridge/br_multicast.c linux-3.10.15-vs2.3.6.6/net/bridge/br_multicast.c
23961 --- linux-3.10.15/net/bridge/br_multicast.c 2013-10-09 17:35:23.000000000 +0000
23962 +++ linux-3.10.15-vs2.3.6.6/net/bridge/br_multicast.c 2013-10-09 17:37:22.000000000 +0000
23963 @@ -443,7 +443,7 @@ static struct sk_buff *br_ip6_multicast_
23964 ip6h->hop_limit = 1;
23965 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
23966 if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
23968 + &ip6h->saddr, NULL)) {
23972 diff -NurpP --minimal linux-3.10.15/net/core/dev.c linux-3.10.15-vs2.3.6.6/net/core/dev.c
23973 --- linux-3.10.15/net/core/dev.c 2013-10-09 17:35:23.000000000 +0000
23974 +++ linux-3.10.15-vs2.3.6.6/net/core/dev.c 2013-08-22 20:30:00.000000000 +0000
23975 @@ -122,6 +122,7 @@
23976 #include <linux/in.h>
23977 #include <linux/jhash.h>
23978 #include <linux/random.h>
23979 +#include <linux/vs_inet.h>
23980 #include <trace/events/napi.h>
23981 #include <trace/events/net.h>
23982 #include <trace/events/skb.h>
23983 @@ -660,7 +661,8 @@ struct net_device *__dev_get_by_name(str
23984 struct hlist_head *head = dev_name_hash(net, name);
23986 hlist_for_each_entry(dev, head, name_hlist)
23987 - if (!strncmp(dev->name, name, IFNAMSIZ))
23988 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
23989 + nx_dev_visible(current_nx_info(), dev))
23993 @@ -685,7 +687,8 @@ struct net_device *dev_get_by_name_rcu(s
23994 struct hlist_head *head = dev_name_hash(net, name);
23996 hlist_for_each_entry_rcu(dev, head, name_hlist)
23997 - if (!strncmp(dev->name, name, IFNAMSIZ))
23998 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
23999 + nx_dev_visible(current_nx_info(), dev))
24003 @@ -735,7 +738,8 @@ struct net_device *__dev_get_by_index(st
24004 struct hlist_head *head = dev_index_hash(net, ifindex);
24006 hlist_for_each_entry(dev, head, index_hlist)
24007 - if (dev->ifindex == ifindex)
24008 + if ((dev->ifindex == ifindex) &&
24009 + nx_dev_visible(current_nx_info(), dev))
24013 @@ -753,7 +757,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24014 * about locking. The caller must hold RCU lock.
24017 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24018 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24020 struct net_device *dev;
24021 struct hlist_head *head = dev_index_hash(net, ifindex);
24022 @@ -764,6 +768,16 @@ struct net_device *dev_get_by_index_rcu(
24026 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24028 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24030 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24032 + if (nx_dev_visible(current_nx_info(), dev))
24036 EXPORT_SYMBOL(dev_get_by_index_rcu);
24039 @@ -846,7 +860,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24041 for_each_netdev_rcu(net, dev)
24042 if (dev->type == type &&
24043 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24044 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24045 + nx_dev_visible(current_nx_info(), dev))
24049 @@ -858,9 +873,11 @@ struct net_device *__dev_getfirstbyhwtyp
24050 struct net_device *dev;
24053 - for_each_netdev(net, dev)
24054 - if (dev->type == type)
24055 + for_each_netdev(net, dev) {
24056 + if ((dev->type == type) &&
24057 + nx_dev_visible(current_nx_info(), dev))
24063 @@ -872,7 +889,8 @@ struct net_device *dev_getfirstbyhwtype(
24066 for_each_netdev_rcu(net, dev)
24067 - if (dev->type == type) {
24068 + if ((dev->type == type) &&
24069 + nx_dev_visible(current_nx_info(), dev)) {
24073 @@ -900,7 +918,8 @@ struct net_device *dev_get_by_flags_rcu(
24076 for_each_netdev_rcu(net, dev) {
24077 - if (((dev->flags ^ if_flags) & mask) == 0) {
24078 + if ((((dev->flags ^ if_flags) & mask) == 0) &&
24079 + nx_dev_visible(current_nx_info(), dev)) {
24083 @@ -978,6 +997,8 @@ static int __dev_alloc_name(struct net *
24085 if (i < 0 || i >= max_netdevices)
24087 + if (!nx_dev_visible(current_nx_info(), d))
24090 /* avoid cases where sscanf is not exact inverse of printf */
24091 snprintf(buf, IFNAMSIZ, name, i);
24092 diff -NurpP --minimal linux-3.10.15/net/core/net-procfs.c linux-3.10.15-vs2.3.6.6/net/core/net-procfs.c
24093 --- linux-3.10.15/net/core/net-procfs.c 2013-07-14 17:01:37.000000000 +0000
24094 +++ linux-3.10.15-vs2.3.6.6/net/core/net-procfs.c 2013-08-22 20:30:00.000000000 +0000
24096 #include <linux/netdevice.h>
24097 #include <linux/proc_fs.h>
24098 #include <linux/seq_file.h>
24099 +#include <linux/vs_inet.h>
24100 #include <net/wext.h>
24102 #define BUCKET_SPACE (32 - NETDEV_HASHBITS - 1)
24103 @@ -77,8 +78,13 @@ static void dev_seq_stop(struct seq_file
24104 static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
24106 struct rtnl_link_stats64 temp;
24107 - const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24108 + const struct rtnl_link_stats64 *stats;
24110 + /* device visible inside network context? */
24111 + if (!nx_dev_visible(current_nx_info(), dev))
24114 + stats = dev_get_stats(dev, &temp);
24115 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24116 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24117 dev->name, stats->rx_bytes, stats->rx_packets,
24118 diff -NurpP --minimal linux-3.10.15/net/core/rtnetlink.c linux-3.10.15-vs2.3.6.6/net/core/rtnetlink.c
24119 --- linux-3.10.15/net/core/rtnetlink.c 2013-10-09 17:35:23.000000000 +0000
24120 +++ linux-3.10.15-vs2.3.6.6/net/core/rtnetlink.c 2013-10-09 17:37:22.000000000 +0000
24121 @@ -1059,6 +1059,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24122 hlist_for_each_entry_rcu(dev, head, index_hlist) {
24125 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24127 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24128 NETLINK_CB(cb->skb).portid,
24129 cb->nlh->nlmsg_seq, 0,
24130 @@ -1951,6 +1953,9 @@ void rtmsg_ifinfo(int type, struct net_d
24131 int err = -ENOBUFS;
24132 size_t if_info_size;
24134 + if (!nx_dev_visible(current_nx_info(), dev))
24137 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), GFP_KERNEL);
24140 diff -NurpP --minimal linux-3.10.15/net/core/sock.c linux-3.10.15-vs2.3.6.6/net/core/sock.c
24141 --- linux-3.10.15/net/core/sock.c 2013-07-14 17:01:37.000000000 +0000
24142 +++ linux-3.10.15-vs2.3.6.6/net/core/sock.c 2013-08-22 20:30:00.000000000 +0000
24143 @@ -132,6 +132,10 @@
24144 #include <net/netprio_cgroup.h>
24146 #include <linux/filter.h>
24147 +#include <linux/vs_socket.h>
24148 +#include <linux/vs_limit.h>
24149 +#include <linux/vs_context.h>
24150 +#include <linux/vs_network.h>
24152 #include <trace/events/sock.h>
24154 @@ -1252,6 +1256,8 @@ static struct sock *sk_prot_alloc(struct
24156 sk_tx_queue_clear(sk);
24158 + sock_vx_init(sk);
24159 + sock_nx_init(sk);
24163 @@ -1360,6 +1366,11 @@ static void __sk_free(struct sock *sk)
24164 put_cred(sk->sk_peer_cred);
24165 put_pid(sk->sk_peer_pid);
24166 put_net(sock_net(sk));
24168 + clr_vx_info(&sk->sk_vx_info);
24170 + clr_nx_info(&sk->sk_nx_info);
24172 sk_prot_free(sk->sk_prot_creator, sk);
24175 @@ -1420,6 +1431,8 @@ struct sock *sk_clone_lock(const struct
24178 get_net(sock_net(newsk));
24179 + sock_vx_init(newsk);
24180 + sock_nx_init(newsk);
24181 sk_node_init(&newsk->sk_node);
24182 sock_lock_init(newsk);
24183 bh_lock_sock(newsk);
24184 @@ -1476,6 +1489,12 @@ struct sock *sk_clone_lock(const struct
24186 atomic_set(&newsk->sk_refcnt, 2);
24188 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24189 + newsk->sk_xid = sk->sk_xid;
24190 + vx_sock_inc(newsk);
24191 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24192 + newsk->sk_nid = sk->sk_nid;
24195 * Increment the counter in the same struct proto as the master
24196 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24197 @@ -2271,6 +2290,12 @@ void sock_init_data(struct socket *sock,
24199 sk->sk_stamp = ktime_set(-1L, 0);
24201 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24202 + sk->sk_xid = vx_current_xid();
24204 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24205 + sk->sk_nid = nx_current_nid();
24208 * Before updating sk_refcnt, we must commit prior changes to memory
24209 * (Documentation/RCU/rculist_nulls.txt for details)
24210 diff -NurpP --minimal linux-3.10.15/net/ipv4/af_inet.c linux-3.10.15-vs2.3.6.6/net/ipv4/af_inet.c
24211 --- linux-3.10.15/net/ipv4/af_inet.c 2013-07-14 17:01:37.000000000 +0000
24212 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/af_inet.c 2013-08-22 20:30:00.000000000 +0000
24213 @@ -118,6 +118,7 @@
24214 #ifdef CONFIG_IP_MROUTE
24215 #include <linux/mroute.h>
24217 +#include <linux/vs_limit.h>
24220 /* The inetsw table contains everything that inet_create needs to
24221 @@ -338,10 +339,13 @@ lookup_protocol:
24225 + if ((protocol == IPPROTO_ICMP) &&
24226 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24228 if (sock->type == SOCK_RAW && !kern &&
24229 !ns_capable(net->user_ns, CAP_NET_RAW))
24230 goto out_rcu_unlock;
24233 sock->ops = answer->ops;
24234 answer_prot = answer->prot;
24235 answer_no_check = answer->no_check;
24236 @@ -462,6 +466,7 @@ int inet_bind(struct socket *sock, struc
24237 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24238 struct sock *sk = sock->sk;
24239 struct inet_sock *inet = inet_sk(sk);
24240 + struct nx_v4_sock_addr nsa;
24241 struct net *net = sock_net(sk);
24242 unsigned short snum;
24244 @@ -486,7 +491,11 @@ int inet_bind(struct socket *sock, struc
24248 - chk_addr_ret = inet_addr_type(net, addr->sin_addr.s_addr);
24249 + err = v4_map_sock_addr(inet, addr, &nsa);
24253 + chk_addr_ret = inet_addr_type(net, nsa.saddr);
24255 /* Not specified by any standard per-se, however it breaks too
24256 * many applications when removed. It is unfortunate since
24257 @@ -498,7 +507,7 @@ int inet_bind(struct socket *sock, struc
24258 err = -EADDRNOTAVAIL;
24259 if (!sysctl_ip_nonlocal_bind &&
24260 !(inet->freebind || inet->transparent) &&
24261 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24262 + nsa.saddr != htonl(INADDR_ANY) &&
24263 chk_addr_ret != RTN_LOCAL &&
24264 chk_addr_ret != RTN_MULTICAST &&
24265 chk_addr_ret != RTN_BROADCAST)
24266 @@ -524,7 +533,7 @@ int inet_bind(struct socket *sock, struc
24267 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24268 goto out_release_sock;
24270 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24271 + v4_set_sock_addr(inet, &nsa);
24272 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24273 inet->inet_saddr = 0; /* Use device */
24275 @@ -743,11 +752,13 @@ int inet_getname(struct socket *sock, st
24278 sin->sin_port = inet->inet_dport;
24279 - sin->sin_addr.s_addr = inet->inet_daddr;
24280 + sin->sin_addr.s_addr =
24281 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24283 __be32 addr = inet->inet_rcv_saddr;
24285 addr = inet->inet_saddr;
24286 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24287 sin->sin_port = inet->inet_sport;
24288 sin->sin_addr.s_addr = addr;
24290 diff -NurpP --minimal linux-3.10.15/net/ipv4/arp.c linux-3.10.15-vs2.3.6.6/net/ipv4/arp.c
24291 --- linux-3.10.15/net/ipv4/arp.c 2013-07-14 17:01:37.000000000 +0000
24292 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/arp.c 2013-08-22 20:30:00.000000000 +0000
24293 @@ -1332,6 +1332,7 @@ static void arp_format_neigh_entry(struc
24294 struct net_device *dev = n->dev;
24295 int hatype = dev->type;
24297 + /* FIXME: check for network context */
24298 read_lock(&n->lock);
24299 /* Convert hardware address to XX:XX:XX:XX ... form. */
24300 #if IS_ENABLED(CONFIG_AX25)
24301 @@ -1363,6 +1364,7 @@ static void arp_format_pneigh_entry(stru
24302 int hatype = dev ? dev->type : 0;
24305 + /* FIXME: check for network context */
24306 sprintf(tbuf, "%pI4", n->key);
24307 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24308 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24309 diff -NurpP --minimal linux-3.10.15/net/ipv4/devinet.c linux-3.10.15-vs2.3.6.6/net/ipv4/devinet.c
24310 --- linux-3.10.15/net/ipv4/devinet.c 2013-10-09 17:35:23.000000000 +0000
24311 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/devinet.c 2013-10-09 17:37:22.000000000 +0000
24312 @@ -522,6 +522,7 @@ struct in_device *inetdev_by_index(struc
24314 EXPORT_SYMBOL(inetdev_by_index);
24317 /* Called only from RTNL semaphored context. No locks. */
24319 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24320 @@ -942,6 +943,8 @@ int devinet_ioctl(struct net *net, unsig
24322 in_dev = __in_dev_get_rtnl(dev);
24324 + struct nx_info *nxi = current_nx_info();
24326 if (tryaddrmatch) {
24327 /* Matthias Andree */
24328 /* compare label and address (4.4BSD style) */
24329 @@ -950,6 +953,8 @@ int devinet_ioctl(struct net *net, unsig
24330 This is checked above. */
24331 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24332 ifap = &ifa->ifa_next) {
24333 + if (!nx_v4_ifa_visible(nxi, ifa))
24335 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24336 sin_orig.sin_addr.s_addr ==
24338 @@ -962,9 +967,12 @@ int devinet_ioctl(struct net *net, unsig
24339 comparing just the label */
24341 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24342 - ifap = &ifa->ifa_next)
24343 + ifap = &ifa->ifa_next) {
24344 + if (!nx_v4_ifa_visible(nxi, ifa))
24346 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24352 @@ -1118,6 +1126,8 @@ static int inet_gifconf(struct net_devic
24355 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24356 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24359 done += sizeof(ifr);
24361 @@ -1521,6 +1531,7 @@ static int inet_dump_ifaddr(struct sk_bu
24362 struct net_device *dev;
24363 struct in_device *in_dev;
24364 struct in_ifaddr *ifa;
24365 + struct sock *sk = skb->sk;
24366 struct hlist_head *head;
24369 @@ -1544,6 +1555,8 @@ static int inet_dump_ifaddr(struct sk_bu
24371 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24372 ifa = ifa->ifa_next, ip_idx++) {
24373 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24375 if (ip_idx < s_ip_idx)
24377 if (inet_fill_ifaddr(skb, ifa,
24378 diff -NurpP --minimal linux-3.10.15/net/ipv4/fib_trie.c linux-3.10.15-vs2.3.6.6/net/ipv4/fib_trie.c
24379 --- linux-3.10.15/net/ipv4/fib_trie.c 2013-10-09 17:35:23.000000000 +0000
24380 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/fib_trie.c 2013-10-09 17:37:22.000000000 +0000
24381 @@ -2536,6 +2536,7 @@ static int fib_route_seq_show(struct seq
24382 || fa->fa_type == RTN_MULTICAST)
24385 + /* FIXME: check for network context? */
24388 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24389 diff -NurpP --minimal linux-3.10.15/net/ipv4/inet_connection_sock.c linux-3.10.15-vs2.3.6.6/net/ipv4/inet_connection_sock.c
24390 --- linux-3.10.15/net/ipv4/inet_connection_sock.c 2013-07-14 17:01:37.000000000 +0000
24391 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/inet_connection_sock.c 2013-08-22 20:30:00.000000000 +0000
24392 @@ -53,6 +53,37 @@ void inet_get_local_port_range(int *low,
24394 EXPORT_SYMBOL(inet_get_local_port_range);
24396 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24398 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24399 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24401 + if (inet_v6_ipv6only(sk2))
24404 + if (sk1_rcv_saddr &&
24406 + sk1_rcv_saddr == sk2_rcv_saddr)
24409 + if (sk1_rcv_saddr &&
24410 + !sk2_rcv_saddr &&
24411 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24414 + if (sk2_rcv_saddr &&
24415 + !sk1_rcv_saddr &&
24416 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24419 + if (!sk1_rcv_saddr &&
24420 + !sk2_rcv_saddr &&
24421 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24427 int inet_csk_bind_conflict(const struct sock *sk,
24428 const struct inet_bind_bucket *tb, bool relax)
24430 @@ -79,17 +110,12 @@ int inet_csk_bind_conflict(const struct
24431 (!reuseport || !sk2->sk_reuseport ||
24432 (sk2->sk_state != TCP_TIME_WAIT &&
24433 !uid_eq(uid, sock_i_uid(sk2))))) {
24434 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24435 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24436 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24437 + if (ipv4_rcv_saddr_equal(sk, sk2))
24440 if (!relax && reuse && sk2->sk_reuse &&
24441 sk2->sk_state != TCP_LISTEN) {
24442 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24444 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24445 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24446 + if (ipv4_rcv_saddr_equal(sk, sk2))
24450 diff -NurpP --minimal linux-3.10.15/net/ipv4/inet_diag.c linux-3.10.15-vs2.3.6.6/net/ipv4/inet_diag.c
24451 --- linux-3.10.15/net/ipv4/inet_diag.c 2013-07-14 17:01:37.000000000 +0000
24452 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/inet_diag.c 2013-08-22 20:30:00.000000000 +0000
24455 #include <linux/inet.h>
24456 #include <linux/stddef.h>
24457 +#include <linux/vs_network.h>
24458 +#include <linux/vs_inet.h>
24460 #include <linux/inet_diag.h>
24461 #include <linux/sock_diag.h>
24462 @@ -106,8 +108,10 @@ int inet_sk_diag_fill(struct sock *sk, s
24464 r->id.idiag_sport = inet->inet_sport;
24465 r->id.idiag_dport = inet->inet_dport;
24466 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24467 - r->id.idiag_dst[0] = inet->inet_daddr;
24468 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24469 + inet->inet_rcv_saddr);
24470 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24471 + inet->inet_daddr);
24473 if (nla_put_u8(skb, INET_DIAG_SHUTDOWN, sk->sk_shutdown))
24475 @@ -244,8 +248,8 @@ static int inet_twsk_diag_fill(struct in
24476 sock_diag_save_cookie(tw, r->id.idiag_cookie);
24477 r->id.idiag_sport = tw->tw_sport;
24478 r->id.idiag_dport = tw->tw_dport;
24479 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24480 - r->id.idiag_dst[0] = tw->tw_daddr;
24481 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24482 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24483 r->idiag_state = tw->tw_substate;
24484 r->idiag_timer = 3;
24485 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
24486 @@ -289,12 +293,14 @@ int inet_diag_dump_one_icsk(struct inet_
24489 if (req->sdiag_family == AF_INET) {
24490 + /* TODO: lback */
24491 sk = inet_lookup(net, hashinfo, req->id.idiag_dst[0],
24492 req->id.idiag_dport, req->id.idiag_src[0],
24493 req->id.idiag_sport, req->id.idiag_if);
24495 #if IS_ENABLED(CONFIG_IPV6)
24496 else if (req->sdiag_family == AF_INET6) {
24497 + /* TODO: lback */
24498 sk = inet6_lookup(net, hashinfo,
24499 (struct in6_addr *)req->id.idiag_dst,
24500 req->id.idiag_dport,
24501 @@ -496,6 +502,7 @@ int inet_diag_bc_sk(const struct nlattr
24505 + /* TODO: lback */
24506 entry.saddr = &inet->inet_rcv_saddr;
24507 entry.daddr = &inet->inet_daddr;
24509 @@ -654,6 +661,7 @@ static int inet_twsk_diag_dump(struct in
24513 + /* TODO: lback */
24514 entry.saddr = &tw->tw_rcv_saddr;
24515 entry.daddr = &tw->tw_daddr;
24517 @@ -732,8 +740,8 @@ static int inet_diag_fill_req(struct sk_
24519 r->id.idiag_sport = inet->inet_sport;
24520 r->id.idiag_dport = ireq->rmt_port;
24521 - r->id.idiag_src[0] = ireq->loc_addr;
24522 - r->id.idiag_dst[0] = ireq->rmt_addr;
24523 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
24524 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
24525 r->idiag_expires = jiffies_to_msecs(tmo);
24526 r->idiag_rqueue = 0;
24527 r->idiag_wqueue = 0;
24528 @@ -796,6 +804,7 @@ static int inet_diag_dump_reqs(struct sk
24532 + /* TODO: lback */
24534 inet_diag_req_addrs(sk, req, &entry);
24535 entry.dport = ntohs(ireq->rmt_port);
24536 @@ -852,6 +861,8 @@ void inet_diag_dump_icsk(struct inet_has
24537 if (!net_eq(sock_net(sk), net))
24540 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24545 @@ -924,6 +935,8 @@ skip_listen_ht:
24547 if (!net_eq(sock_net(sk), net))
24549 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24553 if (!(r->idiag_states & (1 << sk->sk_state)))
24554 @@ -952,7 +965,8 @@ next_normal:
24556 if (!net_eq(twsk_net(tw), net))
24559 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24563 if (r->sdiag_family != AF_UNSPEC &&
24564 diff -NurpP --minimal linux-3.10.15/net/ipv4/inet_hashtables.c linux-3.10.15-vs2.3.6.6/net/ipv4/inet_hashtables.c
24565 --- linux-3.10.15/net/ipv4/inet_hashtables.c 2013-05-31 13:45:32.000000000 +0000
24566 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/inet_hashtables.c 2013-08-22 20:30:00.000000000 +0000
24568 #include <net/inet_connection_sock.h>
24569 #include <net/inet_hashtables.h>
24570 #include <net/secure_seq.h>
24571 +#include <net/route.h>
24572 #include <net/ip.h>
24575 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
24576 if (rcv_saddr != daddr)
24580 + /* block non nx_info ips */
24581 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24582 + daddr, NXA_MASK_BIND))
24585 if (sk->sk_bound_dev_if) {
24586 if (sk->sk_bound_dev_if != dif)
24587 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
24588 * wildcarded during the search since they can never be otherwise.
24592 struct sock *__inet_lookup_listener(struct net *net,
24593 struct inet_hashinfo *hashinfo,
24594 const __be32 saddr, __be16 sport,
24595 @@ -209,6 +214,7 @@ begin:
24596 phash = next_pseudo_random32(phash);
24601 * if the nulls value we got at the end of this lookup is
24602 * not the expected one, we must restart lookup.
24603 diff -NurpP --minimal linux-3.10.15/net/ipv4/netfilter.c linux-3.10.15-vs2.3.6.6/net/ipv4/netfilter.c
24604 --- linux-3.10.15/net/ipv4/netfilter.c 2013-07-14 17:01:37.000000000 +0000
24605 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/netfilter.c 2013-08-22 20:30:00.000000000 +0000
24607 #include <linux/skbuff.h>
24608 #include <linux/gfp.h>
24609 #include <linux/export.h>
24610 -#include <net/route.h>
24611 +// #include <net/route.h>
24612 #include <net/xfrm.h>
24613 #include <net/ip.h>
24614 #include <net/netfilter/nf_queue.h>
24615 diff -NurpP --minimal linux-3.10.15/net/ipv4/raw.c linux-3.10.15-vs2.3.6.6/net/ipv4/raw.c
24616 --- linux-3.10.15/net/ipv4/raw.c 2013-10-09 17:35:23.000000000 +0000
24617 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/raw.c 2013-10-09 17:37:22.000000000 +0000
24618 @@ -116,7 +116,7 @@ static struct sock *__raw_v4_lookup(stru
24620 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
24621 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
24622 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
24623 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
24624 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
24625 goto found; /* gotcha */
24627 @@ -395,6 +395,12 @@ static int raw_send_hdrinc(struct sock *
24628 icmp_out_count(net, ((struct icmphdr *)
24629 skb_transport_header(skb))->type);
24632 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
24633 + sk->sk_nx_info &&
24634 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
24637 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
24638 rt->dst.dev, dst_output);
24640 @@ -581,6 +587,16 @@ static int raw_sendmsg(struct kiocb *ioc
24644 + if (sk->sk_nx_info) {
24645 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
24646 + if (IS_ERR(rt)) {
24647 + err = PTR_ERR(rt);
24654 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
24655 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
24657 @@ -657,17 +673,19 @@ static int raw_bind(struct sock *sk, str
24659 struct inet_sock *inet = inet_sk(sk);
24660 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
24661 + struct nx_v4_sock_addr nsa = { 0 };
24665 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
24667 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24668 + v4_map_sock_addr(inet, addr, &nsa);
24669 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24670 ret = -EADDRNOTAVAIL;
24671 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
24672 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
24673 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
24675 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24676 + v4_set_sock_addr(inet, &nsa);
24677 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24678 inet->inet_saddr = 0; /* Use device */
24680 @@ -719,7 +737,8 @@ static int raw_recvmsg(struct kiocb *ioc
24681 /* Copy the address. */
24683 sin->sin_family = AF_INET;
24684 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24685 + sin->sin_addr.s_addr =
24686 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
24688 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
24690 @@ -914,7 +933,8 @@ static struct sock *raw_get_first(struct
24691 for (state->bucket = 0; state->bucket < RAW_HTABLE_SIZE;
24693 sk_for_each(sk, &state->h->ht[state->bucket])
24694 - if (sock_net(sk) == seq_file_net(seq))
24695 + if ((sock_net(sk) == seq_file_net(seq)) &&
24696 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24700 @@ -930,7 +950,8 @@ static struct sock *raw_get_next(struct
24704 - } while (sk && sock_net(sk) != seq_file_net(seq));
24705 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
24706 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24708 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
24709 sk = sk_head(&state->h->ht[state->bucket]);
24710 diff -NurpP --minimal linux-3.10.15/net/ipv4/route.c linux-3.10.15-vs2.3.6.6/net/ipv4/route.c
24711 --- linux-3.10.15/net/ipv4/route.c 2013-07-14 17:01:37.000000000 +0000
24712 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/route.c 2013-08-22 20:30:00.000000000 +0000
24713 @@ -2003,7 +2003,7 @@ struct rtable *__ip_route_output_key(str
24716 if (fl4->flowi4_oif) {
24717 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
24718 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
24719 rth = ERR_PTR(-ENODEV);
24720 if (dev_out == NULL)
24722 diff -NurpP --minimal linux-3.10.15/net/ipv4/tcp.c linux-3.10.15-vs2.3.6.6/net/ipv4/tcp.c
24723 --- linux-3.10.15/net/ipv4/tcp.c 2013-10-09 17:35:24.000000000 +0000
24724 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/tcp.c 2013-10-09 17:37:22.000000000 +0000
24725 @@ -268,6 +268,7 @@
24726 #include <linux/crypto.h>
24727 #include <linux/time.h>
24728 #include <linux/slab.h>
24729 +#include <linux/in.h>
24731 #include <net/icmp.h>
24732 #include <net/inet_common.h>
24733 diff -NurpP --minimal linux-3.10.15/net/ipv4/tcp_ipv4.c linux-3.10.15-vs2.3.6.6/net/ipv4/tcp_ipv4.c
24734 --- linux-3.10.15/net/ipv4/tcp_ipv4.c 2013-07-14 17:01:37.000000000 +0000
24735 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/tcp_ipv4.c 2013-08-22 20:30:00.000000000 +0000
24736 @@ -2263,6 +2263,12 @@ static void *listening_get_next(struct s
24737 req = req->dl_next;
24740 + vxdprintk(VXD_CBIT(net, 6),
24741 + "sk,req: %p [#%d] (from %d)", req->sk,
24742 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
24744 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
24746 if (req->rsk_ops->family == st->family) {
24749 @@ -2287,6 +2293,10 @@ get_req:
24752 sk_nulls_for_each_from(sk, node) {
24753 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
24754 + sk, sk->sk_nid, nx_current_nid());
24755 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24757 if (!net_eq(sock_net(sk), net))
24759 if (sk->sk_family == st->family) {
24760 @@ -2363,6 +2373,11 @@ static void *established_get_first(struc
24762 spin_lock_bh(lock);
24763 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
24764 + vxdprintk(VXD_CBIT(net, 6),
24765 + "sk,egf: %p [#%d] (from %d)",
24766 + sk, sk->sk_nid, nx_current_nid());
24767 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24769 if (sk->sk_family != st->family ||
24770 !net_eq(sock_net(sk), net)) {
24772 @@ -2373,6 +2388,11 @@ static void *established_get_first(struc
24773 st->state = TCP_SEQ_STATE_TIME_WAIT;
24774 inet_twsk_for_each(tw, node,
24775 &tcp_hashinfo.ehash[st->bucket].twchain) {
24776 + vxdprintk(VXD_CBIT(net, 6),
24777 + "tw: %p [#%d] (from %d)",
24778 + tw, tw->tw_nid, nx_current_nid());
24779 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24781 if (tw->tw_family != st->family ||
24782 !net_eq(twsk_net(tw), net)) {
24784 @@ -2402,7 +2422,9 @@ static void *established_get_next(struct
24788 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
24789 + while (tw && (tw->tw_family != st->family ||
24790 + !net_eq(twsk_net(tw), net) ||
24791 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
24795 @@ -2426,6 +2448,11 @@ get_tw:
24796 sk = sk_nulls_next(sk);
24798 sk_nulls_for_each_from(sk, node) {
24799 + vxdprintk(VXD_CBIT(net, 6),
24800 + "sk,egn: %p [#%d] (from %d)",
24801 + sk, sk->sk_nid, nx_current_nid());
24802 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24804 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
24807 @@ -2631,9 +2658,9 @@ static void get_openreq4(const struct so
24808 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
24809 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
24812 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
24813 ntohs(inet_sk(sk)->inet_sport),
24815 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
24816 ntohs(ireq->rmt_port),
24818 0, 0, /* could print option size, but that is af dependent. */
24819 @@ -2656,8 +2683,8 @@ static void get_tcp4_sock(struct sock *s
24820 const struct inet_connection_sock *icsk = inet_csk(sk);
24821 const struct inet_sock *inet = inet_sk(sk);
24822 struct fastopen_queue *fastopenq = icsk->icsk_accept_queue.fastopenq;
24823 - __be32 dest = inet->inet_daddr;
24824 - __be32 src = inet->inet_rcv_saddr;
24825 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
24826 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
24827 __u16 destp = ntohs(inet->inet_dport);
24828 __u16 srcp = ntohs(inet->inet_sport);
24830 @@ -2715,8 +2742,8 @@ static void get_timewait4_sock(const str
24832 long delta = tw->tw_ttd - jiffies;
24834 - dest = tw->tw_daddr;
24835 - src = tw->tw_rcv_saddr;
24836 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
24837 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
24838 destp = ntohs(tw->tw_dport);
24839 srcp = ntohs(tw->tw_sport);
24841 diff -NurpP --minimal linux-3.10.15/net/ipv4/tcp_minisocks.c linux-3.10.15-vs2.3.6.6/net/ipv4/tcp_minisocks.c
24842 --- linux-3.10.15/net/ipv4/tcp_minisocks.c 2013-07-14 17:01:37.000000000 +0000
24843 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/tcp_minisocks.c 2013-08-22 20:30:00.000000000 +0000
24845 #include <linux/slab.h>
24846 #include <linux/sysctl.h>
24847 #include <linux/workqueue.h>
24848 +#include <linux/vs_limit.h>
24849 +#include <linux/vs_socket.h>
24850 +#include <linux/vs_context.h>
24851 #include <net/tcp.h>
24852 #include <net/inet_common.h>
24853 #include <net/xfrm.h>
24854 @@ -290,6 +293,11 @@ void tcp_time_wait(struct sock *sk, int
24855 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
24856 tcptw->tw_ts_offset = tp->tsoffset;
24858 + tw->tw_xid = sk->sk_xid;
24859 + tw->tw_vx_info = NULL;
24860 + tw->tw_nid = sk->sk_nid;
24861 + tw->tw_nx_info = NULL;
24863 #if IS_ENABLED(CONFIG_IPV6)
24864 if (tw->tw_family == PF_INET6) {
24865 struct ipv6_pinfo *np = inet6_sk(sk);
24866 diff -NurpP --minimal linux-3.10.15/net/ipv4/udp.c linux-3.10.15-vs2.3.6.6/net/ipv4/udp.c
24867 --- linux-3.10.15/net/ipv4/udp.c 2013-10-09 17:35:24.000000000 +0000
24868 +++ linux-3.10.15-vs2.3.6.6/net/ipv4/udp.c 2013-08-22 20:30:00.000000000 +0000
24869 @@ -306,14 +306,7 @@ fail:
24871 EXPORT_SYMBOL(udp_lib_get_port);
24873 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24875 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
24877 - return (!ipv6_only_sock(sk2) &&
24878 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
24879 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
24881 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
24883 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
24885 @@ -348,6 +341,11 @@ static inline int compute_score(struct s
24886 if (inet->inet_rcv_saddr != daddr)
24890 + /* block non nx_info ips */
24891 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24892 + daddr, NXA_MASK_BIND))
24895 if (inet->inet_daddr) {
24896 if (inet->inet_daddr != saddr)
24897 @@ -458,6 +456,7 @@ begin:
24902 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
24903 * harder than this. -DaveM
24905 @@ -504,6 +503,11 @@ begin:
24906 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
24907 score = compute_score(sk, net, saddr, hnum, sport,
24908 daddr, dport, dif);
24909 + /* FIXME: disabled?
24910 + if (score == 9) {
24914 if (score > badness) {
24917 @@ -528,6 +532,7 @@ begin:
24918 if (get_nulls_value(node) != slot)
24923 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
24925 @@ -537,6 +542,7 @@ begin:
24933 @@ -580,8 +586,7 @@ static inline struct sock *udp_v4_mcast_
24934 udp_sk(s)->udp_port_hash != hnum ||
24935 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
24936 (inet->inet_dport != rmt_port && inet->inet_dport) ||
24937 - (inet->inet_rcv_saddr &&
24938 - inet->inet_rcv_saddr != loc_addr) ||
24939 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
24940 ipv6_only_sock(s) ||
24941 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
24943 @@ -965,6 +970,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
24944 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
24945 faddr, saddr, dport, inet->inet_sport);
24947 + if (sk->sk_nx_info) {
24948 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
24949 + if (IS_ERR(rt)) {
24950 + err = PTR_ERR(rt);
24957 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
24958 rt = ip_route_output_flow(net, fl4, sk);
24960 @@ -1272,7 +1287,8 @@ try_again:
24962 sin->sin_family = AF_INET;
24963 sin->sin_port = udp_hdr(skb)->source;
24964 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24965 + sin->sin_addr.s_addr = nx_map_sock_lback(
24966 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
24967 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
24969 if (inet->cmsg_flags)
24970 @@ -2033,6 +2049,8 @@ static struct sock *udp_get_first(struct
24971 sk_nulls_for_each(sk, node, &hslot->head) {
24972 if (!net_eq(sock_net(sk), net))
24974 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24976 if (sk->sk_family == state->family)
24979 @@ -2050,7 +2068,9 @@ static struct sock *udp_get_next(struct
24982 sk = sk_nulls_next(sk);
24983 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
24984 + } while (sk && (!net_eq(sock_net(sk), net) ||
24985 + sk->sk_family != state->family ||
24986 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24989 if (state->bucket <= state->udp_table->mask)
24990 @@ -2146,8 +2166,8 @@ static void udp4_format_sock(struct sock
24991 int bucket, int *len)
24993 struct inet_sock *inet = inet_sk(sp);
24994 - __be32 dest = inet->inet_daddr;
24995 - __be32 src = inet->inet_rcv_saddr;
24996 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
24997 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
24998 __u16 destp = ntohs(inet->inet_dport);
24999 __u16 srcp = ntohs(inet->inet_sport);
25001 diff -NurpP --minimal linux-3.10.15/net/ipv6/Kconfig linux-3.10.15-vs2.3.6.6/net/ipv6/Kconfig
25002 --- linux-3.10.15/net/ipv6/Kconfig 2013-07-14 17:01:38.000000000 +0000
25003 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/Kconfig 2013-08-22 20:30:00.000000000 +0000
25006 # IPv6 as module will cause a CRASH if you try to unload it
25008 - tristate "The IPv6 protocol"
25010 + bool "The IPv6 protocol"
25013 This is complemental support for the IP version 6.
25014 You will still be able to do traditional IPv4 networking as well.
25015 diff -NurpP --minimal linux-3.10.15/net/ipv6/addrconf.c linux-3.10.15-vs2.3.6.6/net/ipv6/addrconf.c
25016 --- linux-3.10.15/net/ipv6/addrconf.c 2013-10-09 17:35:24.000000000 +0000
25017 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/addrconf.c 2013-10-09 17:37:22.000000000 +0000
25019 #include <linux/proc_fs.h>
25020 #include <linux/seq_file.h>
25021 #include <linux/export.h>
25022 +#include <linux/vs_network.h>
25023 +#include <linux/vs_inet6.h>
25025 /* Set to 3 to get tracing... */
25026 #define ACONF_DEBUG 2
25027 @@ -1321,7 +1323,7 @@ out:
25029 int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
25030 const struct in6_addr *daddr, unsigned int prefs,
25031 - struct in6_addr *saddr)
25032 + struct in6_addr *saddr, struct nx_info *nxi)
25034 struct ipv6_saddr_score scores[2],
25035 *score = &scores[0], *hiscore = &scores[1];
25036 @@ -1393,6 +1395,8 @@ int ipv6_dev_get_saddr(struct net *net,
25040 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25044 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25045 @@ -3421,7 +3425,10 @@ static void if6_seq_stop(struct seq_file
25046 static int if6_seq_show(struct seq_file *seq, void *v)
25048 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25049 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25051 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25052 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25053 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25055 ifp->idev->dev->ifindex,
25057 @@ -3925,6 +3932,11 @@ static int in6_dump_addrs(struct inet6_d
25058 struct ifacaddr6 *ifaca;
25060 int ip_idx = *p_ip_idx;
25061 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25063 + /* disable ipv6 on non v6 guests */
25064 + if (nxi && !nx_info_has_v6(nxi))
25067 read_lock_bh(&idev->lock);
25069 @@ -3935,6 +3947,8 @@ static int in6_dump_addrs(struct inet6_d
25070 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25071 if (++ip_idx < s_ip_idx)
25073 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25075 err = inet6_fill_ifaddr(skb, ifa,
25076 NETLINK_CB(cb->skb).portid,
25077 cb->nlh->nlmsg_seq,
25078 @@ -3952,6 +3966,8 @@ static int in6_dump_addrs(struct inet6_d
25079 ifmca = ifmca->next, ip_idx++) {
25080 if (ip_idx < s_ip_idx)
25082 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25084 err = inet6_fill_ifmcaddr(skb, ifmca,
25085 NETLINK_CB(cb->skb).portid,
25086 cb->nlh->nlmsg_seq,
25087 @@ -3967,6 +3983,8 @@ static int in6_dump_addrs(struct inet6_d
25088 ifaca = ifaca->aca_next, ip_idx++) {
25089 if (ip_idx < s_ip_idx)
25091 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25093 err = inet6_fill_ifacaddr(skb, ifaca,
25094 NETLINK_CB(cb->skb).portid,
25095 cb->nlh->nlmsg_seq,
25096 @@ -3995,6 +4013,10 @@ static int inet6_dump_addr(struct sk_buf
25097 struct inet6_dev *idev;
25098 struct hlist_head *head;
25100 + /* FIXME: maybe disable ipv6 on non v6 guests?
25101 + if (skb->sk && skb->sk->sk_vx_info)
25102 + return skb->len; */
25105 s_idx = idx = cb->args[1];
25106 s_ip_idx = ip_idx = cb->args[2];
25107 @@ -4430,6 +4452,7 @@ static int inet6_dump_ifinfo(struct sk_b
25108 struct net_device *dev;
25109 struct inet6_dev *idev;
25110 struct hlist_head *head;
25111 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25114 s_idx = cb->args[1];
25115 @@ -4441,6 +4464,8 @@ static int inet6_dump_ifinfo(struct sk_b
25116 hlist_for_each_entry_rcu(dev, head, index_hlist) {
25119 + if (!v6_dev_in_nx_info(dev, nxi))
25121 idev = __in6_dev_get(dev);
25124 diff -NurpP --minimal linux-3.10.15/net/ipv6/af_inet6.c linux-3.10.15-vs2.3.6.6/net/ipv6/af_inet6.c
25125 --- linux-3.10.15/net/ipv6/af_inet6.c 2013-07-14 17:01:38.000000000 +0000
25126 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/af_inet6.c 2013-08-22 20:30:00.000000000 +0000
25128 #include <linux/netdevice.h>
25129 #include <linux/icmpv6.h>
25130 #include <linux/netfilter_ipv6.h>
25131 +#include <linux/vs_inet.h>
25132 +#include <linux/vs_inet6.h>
25134 #include <net/ip.h>
25135 #include <net/ipv6.h>
25136 @@ -159,10 +161,13 @@ lookup_protocol:
25140 + if ((protocol == IPPROTO_ICMPV6) &&
25141 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25143 if (sock->type == SOCK_RAW && !kern &&
25144 !ns_capable(net->user_ns, CAP_NET_RAW))
25145 goto out_rcu_unlock;
25148 sock->ops = answer->ops;
25149 answer_prot = answer->prot;
25150 answer_no_check = answer->no_check;
25151 @@ -262,6 +267,7 @@ int inet6_bind(struct socket *sock, stru
25152 struct inet_sock *inet = inet_sk(sk);
25153 struct ipv6_pinfo *np = inet6_sk(sk);
25154 struct net *net = sock_net(sk);
25155 + struct nx_v6_sock_addr nsa;
25157 unsigned short snum;
25159 @@ -277,6 +283,10 @@ int inet6_bind(struct socket *sock, stru
25160 if (addr->sin6_family != AF_INET6)
25161 return -EAFNOSUPPORT;
25163 + err = v6_map_sock_addr(inet, addr, &nsa);
25167 addr_type = ipv6_addr_type(&addr->sin6_addr);
25168 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25170 @@ -308,6 +318,7 @@ int inet6_bind(struct socket *sock, stru
25171 /* Reproduce AF_INET checks to make the bindings consistent */
25172 v4addr = addr->sin6_addr.s6_addr32[3];
25173 chk_addr_ret = inet_addr_type(net, v4addr);
25175 if (!sysctl_ip_nonlocal_bind &&
25176 !(inet->freebind || inet->transparent) &&
25177 v4addr != htonl(INADDR_ANY) &&
25178 @@ -317,6 +328,10 @@ int inet6_bind(struct socket *sock, stru
25179 err = -EADDRNOTAVAIL;
25182 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25183 + err = -EADDRNOTAVAIL;
25187 if (addr_type != IPV6_ADDR_ANY) {
25188 struct net_device *dev = NULL;
25189 @@ -343,6 +358,11 @@ int inet6_bind(struct socket *sock, stru
25193 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25194 + err = -EADDRNOTAVAIL;
25198 /* ipv4 addr of the socket is invalid. Only the
25199 * unspecified and mapped address have a v4 equivalent.
25201 @@ -359,6 +379,9 @@ int inet6_bind(struct socket *sock, stru
25205 + /* what's that for? */
25206 + v6_set_sock_addr(inet, &nsa);
25208 inet->inet_rcv_saddr = v4addr;
25209 inet->inet_saddr = v4addr;
25211 @@ -460,9 +483,11 @@ int inet6_getname(struct socket *sock, s
25213 sin->sin6_port = inet->inet_dport;
25214 sin->sin6_addr = np->daddr;
25215 + /* FIXME: remap lback? */
25217 sin->sin6_flowinfo = np->flow_label;
25219 + /* FIXME: remap lback? */
25220 if (ipv6_addr_any(&np->rcv_saddr))
25221 sin->sin6_addr = np->saddr;
25223 diff -NurpP --minimal linux-3.10.15/net/ipv6/datagram.c linux-3.10.15-vs2.3.6.6/net/ipv6/datagram.c
25224 --- linux-3.10.15/net/ipv6/datagram.c 2013-07-14 17:01:38.000000000 +0000
25225 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/datagram.c 2013-08-22 20:30:00.000000000 +0000
25226 @@ -652,7 +652,7 @@ int ip6_datagram_send_ctl(struct net *ne
25229 if (fl6->flowi6_oif) {
25230 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25231 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25235 diff -NurpP --minimal linux-3.10.15/net/ipv6/fib6_rules.c linux-3.10.15-vs2.3.6.6/net/ipv6/fib6_rules.c
25236 --- linux-3.10.15/net/ipv6/fib6_rules.c 2013-02-19 13:58:58.000000000 +0000
25237 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/fib6_rules.c 2013-08-22 20:30:00.000000000 +0000
25238 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
25239 ip6_dst_idev(&rt->dst)->dev,
25241 rt6_flags2srcprefs(flags),
25245 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25247 diff -NurpP --minimal linux-3.10.15/net/ipv6/inet6_hashtables.c linux-3.10.15-vs2.3.6.6/net/ipv6/inet6_hashtables.c
25248 --- linux-3.10.15/net/ipv6/inet6_hashtables.c 2013-05-31 13:45:32.000000000 +0000
25249 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/inet6_hashtables.c 2013-08-22 20:30:00.000000000 +0000
25252 #include <linux/module.h>
25253 #include <linux/random.h>
25254 +#include <linux/vs_inet6.h>
25256 #include <net/inet_connection_sock.h>
25257 #include <net/inet_hashtables.h>
25258 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25259 unsigned int slot = hash & hashinfo->ehash_mask;
25260 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25265 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25266 @@ -97,7 +97,7 @@ begin:
25274 if (get_nulls_value(node) != slot)
25275 @@ -147,6 +147,9 @@ static inline int compute_score(struct s
25276 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25280 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25283 if (sk->sk_bound_dev_if) {
25284 if (sk->sk_bound_dev_if != dif)
25285 diff -NurpP --minimal linux-3.10.15/net/ipv6/ip6_output.c linux-3.10.15-vs2.3.6.6/net/ipv6/ip6_output.c
25286 --- linux-3.10.15/net/ipv6/ip6_output.c 2013-10-09 17:35:24.000000000 +0000
25287 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/ip6_output.c 2013-08-22 20:30:00.000000000 +0000
25288 @@ -882,7 +882,8 @@ static int ip6_dst_lookup_tail(struct so
25289 struct rt6_info *rt = (struct rt6_info *) *dst;
25290 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25291 sk ? inet6_sk(sk)->srcprefs : 0,
25294 + sk ? sk->sk_nx_info : NULL);
25296 goto out_err_release;
25298 diff -NurpP --minimal linux-3.10.15/net/ipv6/ndisc.c linux-3.10.15-vs2.3.6.6/net/ipv6/ndisc.c
25299 --- linux-3.10.15/net/ipv6/ndisc.c 2013-10-09 17:35:24.000000000 +0000
25300 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/ndisc.c 2013-10-09 17:37:22.000000000 +0000
25301 @@ -487,7 +487,7 @@ static void ndisc_send_na(struct net_dev
25303 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25304 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25308 src_addr = &tmpaddr;
25310 diff -NurpP --minimal linux-3.10.15/net/ipv6/netfilter/ip6t_MASQUERADE.c linux-3.10.15-vs2.3.6.6/net/ipv6/netfilter/ip6t_MASQUERADE.c
25311 --- linux-3.10.15/net/ipv6/netfilter/ip6t_MASQUERADE.c 2012-12-11 03:30:57.000000000 +0000
25312 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/netfilter/ip6t_MASQUERADE.c 2013-08-22 20:30:00.000000000 +0000
25313 @@ -34,7 +34,7 @@ masquerade_tg6(struct sk_buff *skb, cons
25314 ctinfo == IP_CT_RELATED_REPLY));
25316 if (ipv6_dev_get_saddr(dev_net(par->out), par->out,
25317 - &ipv6_hdr(skb)->daddr, 0, &src) < 0)
25318 + &ipv6_hdr(skb)->daddr, 0, &src, NULL) < 0)
25321 nfct_nat(ct)->masq_index = par->out->ifindex;
25322 diff -NurpP --minimal linux-3.10.15/net/ipv6/raw.c linux-3.10.15-vs2.3.6.6/net/ipv6/raw.c
25323 --- linux-3.10.15/net/ipv6/raw.c 2013-07-14 17:01:38.000000000 +0000
25324 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/raw.c 2013-08-22 20:30:00.000000000 +0000
25326 #include <linux/icmpv6.h>
25327 #include <linux/netfilter.h>
25328 #include <linux/netfilter_ipv6.h>
25329 +#include <linux/vs_inet6.h>
25330 #include <linux/skbuff.h>
25331 #include <linux/compat.h>
25332 #include <asm/uaccess.h>
25333 @@ -283,6 +284,13 @@ static int rawv6_bind(struct sock *sk, s
25337 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25338 + err = -EADDRNOTAVAIL;
25344 /* ipv4 addr of the socket is invalid. Only the
25345 * unspecified and mapped address have a v4 equivalent.
25347 diff -NurpP --minimal linux-3.10.15/net/ipv6/route.c linux-3.10.15-vs2.3.6.6/net/ipv6/route.c
25348 --- linux-3.10.15/net/ipv6/route.c 2013-10-09 17:35:24.000000000 +0000
25349 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/route.c 2013-08-22 20:30:00.000000000 +0000
25351 #include <net/netevent.h>
25352 #include <net/netlink.h>
25353 #include <net/nexthop.h>
25354 +#include <linux/vs_inet6.h>
25356 #include <asm/uaccess.h>
25358 @@ -2101,15 +2102,17 @@ int ip6_route_get_saddr(struct net *net,
25359 struct rt6_info *rt,
25360 const struct in6_addr *daddr,
25361 unsigned int prefs,
25362 - struct in6_addr *saddr)
25363 + struct in6_addr *saddr,
25364 + struct nx_info *nxi)
25366 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25368 - if (rt->rt6i_prefsrc.plen)
25369 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25370 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25371 *saddr = rt->rt6i_prefsrc.addr;
25373 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25374 - daddr, prefs, saddr);
25375 + daddr, prefs, saddr, nxi);
25379 @@ -2529,7 +2532,8 @@ static int rt6_fill_node(struct net *net
25380 goto nla_put_failure;
25382 struct in6_addr saddr_buf;
25383 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0 &&
25384 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25385 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0 &&
25386 nla_put(skb, RTA_PREFSRC, 16, &saddr_buf))
25387 goto nla_put_failure;
25389 @@ -2741,6 +2745,7 @@ static int rt6_info_route(struct rt6_inf
25391 struct seq_file *m = p_arg;
25393 + /* FIXME: check for network context? */
25394 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25396 #ifdef CONFIG_IPV6_SUBTREES
25397 diff -NurpP --minimal linux-3.10.15/net/ipv6/tcp_ipv6.c linux-3.10.15-vs2.3.6.6/net/ipv6/tcp_ipv6.c
25398 --- linux-3.10.15/net/ipv6/tcp_ipv6.c 2013-10-09 17:35:24.000000000 +0000
25399 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/tcp_ipv6.c 2013-10-09 17:37:22.000000000 +0000
25402 #include <linux/crypto.h>
25403 #include <linux/scatterlist.h>
25404 +#include <linux/vs_inet6.h>
25406 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25407 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25408 @@ -164,8 +165,15 @@ static int tcp_v6_connect(struct sock *s
25409 * connect() to INADDR_ANY means loopback (BSD'ism).
25412 - if(ipv6_addr_any(&usin->sin6_addr))
25413 - usin->sin6_addr.s6_addr[15] = 0x1;
25414 + if(ipv6_addr_any(&usin->sin6_addr)) {
25415 + struct nx_info *nxi = sk->sk_nx_info;
25417 + if (nxi && nx_info_has_v6(nxi))
25418 + /* FIXME: remap lback? */
25419 + usin->sin6_addr = nxi->v6.ip;
25421 + usin->sin6_addr.s6_addr[15] = 0x1;
25424 addr_type = ipv6_addr_type(&usin->sin6_addr);
25426 diff -NurpP --minimal linux-3.10.15/net/ipv6/udp.c linux-3.10.15-vs2.3.6.6/net/ipv6/udp.c
25427 --- linux-3.10.15/net/ipv6/udp.c 2013-10-09 17:35:24.000000000 +0000
25428 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/udp.c 2013-08-22 20:30:00.000000000 +0000
25429 @@ -46,42 +46,68 @@
25430 #include <net/ip6_checksum.h>
25431 #include <net/xfrm.h>
25432 #include <net/inet6_hashtables.h>
25433 +#include <linux/vs_inet6.h>
25435 #include <linux/proc_fs.h>
25436 #include <linux/seq_file.h>
25437 #include <trace/events/skb.h>
25438 #include "udp_impl.h"
25440 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25441 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25443 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25444 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25445 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25446 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25447 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25448 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25449 - int sk_ipv6only = ipv6_only_sock(sk);
25450 + int sk1_ipv6only = ipv6_only_sock(sk1);
25451 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25452 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25453 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25454 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25456 /* if both are mapped, treat as IPv4 */
25457 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25458 - return (!sk2_ipv6only &&
25459 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25460 + if (!sk2_ipv6only &&
25461 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25462 - sk1_rcv_saddr == sk2_rcv_saddr));
25463 + sk1_rcv_saddr == sk2_rcv_saddr))
25469 if (addr_type2 == IPV6_ADDR_ANY &&
25470 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25474 if (addr_type == IPV6_ADDR_ANY &&
25475 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25477 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25480 if (sk2_rcv_saddr6 &&
25481 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25483 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25489 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25490 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25491 + if (!sk2_rcv_saddr)
25492 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25493 + if (!sk1_rcv_saddr)
25494 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25497 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25498 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25499 + else if (addr_type2 == IPV6_ADDR_ANY)
25500 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25501 + else if (addr_type == IPV6_ADDR_ANY) {
25502 + if (addr_type2 == IPV6_ADDR_MAPPED)
25503 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25505 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25510 static unsigned int udp6_portaddr_hash(struct net *net,
25511 @@ -145,6 +171,10 @@ static inline int compute_score(struct s
25512 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25516 + /* block non nx_info ips */
25517 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25520 if (!ipv6_addr_any(&np->daddr)) {
25521 if (!ipv6_addr_equal(&np->daddr, saddr))
25522 diff -NurpP --minimal linux-3.10.15/net/ipv6/xfrm6_policy.c linux-3.10.15-vs2.3.6.6/net/ipv6/xfrm6_policy.c
25523 --- linux-3.10.15/net/ipv6/xfrm6_policy.c 2013-07-14 17:01:38.000000000 +0000
25524 +++ linux-3.10.15-vs2.3.6.6/net/ipv6/xfrm6_policy.c 2013-08-22 20:30:00.000000000 +0000
25525 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
25526 dev = ip6_dst_idev(dst)->dev;
25527 ipv6_dev_get_saddr(dev_net(dev), dev,
25528 (struct in6_addr *)&daddr->a6, 0,
25529 - (struct in6_addr *)&saddr->a6);
25530 + (struct in6_addr *)&saddr->a6, NULL);
25534 diff -NurpP --minimal linux-3.10.15/net/netfilter/ipvs/ip_vs_xmit.c linux-3.10.15-vs2.3.6.6/net/netfilter/ipvs/ip_vs_xmit.c
25535 --- linux-3.10.15/net/netfilter/ipvs/ip_vs_xmit.c 2013-07-14 17:01:38.000000000 +0000
25536 +++ linux-3.10.15-vs2.3.6.6/net/netfilter/ipvs/ip_vs_xmit.c 2013-08-22 20:30:00.000000000 +0000
25537 @@ -316,7 +316,7 @@ __ip_vs_route_output_v6(struct net *net,
25539 if (ipv6_addr_any(&fl6.saddr) &&
25540 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
25541 - &fl6.daddr, 0, &fl6.saddr) < 0)
25542 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
25545 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
25546 diff -NurpP --minimal linux-3.10.15/net/netlink/af_netlink.c linux-3.10.15-vs2.3.6.6/net/netlink/af_netlink.c
25547 --- linux-3.10.15/net/netlink/af_netlink.c 2013-07-14 17:01:39.000000000 +0000
25548 +++ linux-3.10.15-vs2.3.6.6/net/netlink/af_netlink.c 2013-08-22 21:19:02.000000000 +0000
25550 #include <linux/audit.h>
25551 #include <linux/mutex.h>
25552 #include <linux/vmalloc.h>
25553 +#include <linux/vs_context.h>
25554 +#include <linux/vs_network.h>
25555 +#include <linux/vs_limit.h>
25556 #include <asm/cacheflush.h>
25558 #include <net/net_namespace.h>
25559 @@ -2684,6 +2687,8 @@ static struct sock *netlink_seq_socket_i
25560 sk_for_each(s, &hash->table[j]) {
25561 if (sock_net(s) != seq_file_net(seq))
25563 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25567 iter->hash_idx = j;
25568 @@ -2718,7 +2723,8 @@ static void *netlink_seq_next(struct seq
25572 - } while (s && sock_net(s) != seq_file_net(seq));
25573 + } while (s && (sock_net(s) != seq_file_net(seq) ||
25574 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
25578 @@ -2730,7 +2736,8 @@ static void *netlink_seq_next(struct seq
25580 for (; j <= hash->mask; j++) {
25581 s = sk_head(&hash->table[j]);
25582 - while (s && sock_net(s) != seq_file_net(seq))
25583 + while (s && (sock_net(s) != seq_file_net(seq) ||
25584 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
25588 diff -NurpP --minimal linux-3.10.15/net/socket.c linux-3.10.15-vs2.3.6.6/net/socket.c
25589 --- linux-3.10.15/net/socket.c 2013-07-14 17:01:39.000000000 +0000
25590 +++ linux-3.10.15-vs2.3.6.6/net/socket.c 2013-08-22 20:30:00.000000000 +0000
25593 #include <net/sock.h>
25594 #include <linux/netfilter.h>
25595 +#include <linux/vs_base.h>
25596 +#include <linux/vs_socket.h>
25597 +#include <linux/vs_inet.h>
25598 +#include <linux/vs_inet6.h>
25600 #include <linux/if_tun.h>
25601 #include <linux/ipv6_route.h>
25602 @@ -616,13 +620,29 @@ static inline int __sock_sendmsg_nosec(s
25603 struct msghdr *msg, size_t size)
25605 struct sock_iocb *si = kiocb_to_siocb(iocb);
25613 - return sock->ops->sendmsg(iocb, sock, msg, size);
25614 + len = sock->ops->sendmsg(iocb, sock, msg, size);
25617 + vx_sock_send(sock->sk, size);
25619 + vx_sock_fail(sock->sk, size);
25621 + vxdprintk(VXD_CBIT(net, 7),
25622 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
25624 + (sock->sk)?sock->sk->sk_nx_info:0,
25625 + (sock->sk)?sock->sk->sk_vx_info:0,
25626 + (sock->sk)?sock->sk->sk_xid:0,
25627 + (sock->sk)?sock->sk->sk_nid:0,
25628 + (unsigned int)size, len);
25632 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
25633 @@ -766,6 +786,7 @@ static inline int __sock_recvmsg_nosec(s
25634 struct msghdr *msg, size_t size, int flags)
25636 struct sock_iocb *si = kiocb_to_siocb(iocb);
25641 @@ -773,7 +794,18 @@ static inline int __sock_recvmsg_nosec(s
25645 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
25646 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
25647 + if ((len >= 0) && sock->sk)
25648 + vx_sock_recv(sock->sk, len);
25649 + vxdprintk(VXD_CBIT(net, 7),
25650 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
25652 + (sock->sk)?sock->sk->sk_nx_info:0,
25653 + (sock->sk)?sock->sk->sk_vx_info:0,
25654 + (sock->sk)?sock->sk->sk_xid:0,
25655 + (sock->sk)?sock->sk->sk_nid:0,
25656 + (unsigned int)size, len);
25660 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
25661 @@ -1247,6 +1279,13 @@ int __sock_create(struct net *net, int f
25662 if (type < 0 || type >= SOCK_MAX)
25665 + if (!nx_check(0, VS_ADMIN)) {
25666 + if (family == PF_INET && !current_nx_info_has_v4())
25667 + return -EAFNOSUPPORT;
25668 + if (family == PF_INET6 && !current_nx_info_has_v6())
25669 + return -EAFNOSUPPORT;
25674 This uglymoron is moved from INET layer to here to avoid
25675 @@ -1381,6 +1420,7 @@ SYSCALL_DEFINE3(socket, int, family, int
25679 + set_bit(SOCK_USER_SOCKET, &sock->flags);
25680 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
25683 @@ -1422,10 +1462,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
25684 err = sock_create(family, type, protocol, &sock1);
25687 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
25689 err = sock_create(family, type, protocol, &sock2);
25691 goto out_release_1;
25692 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
25694 err = sock1->ops->socketpair(sock1, sock2);
25696 diff -NurpP --minimal linux-3.10.15/net/sunrpc/auth.c linux-3.10.15-vs2.3.6.6/net/sunrpc/auth.c
25697 --- linux-3.10.15/net/sunrpc/auth.c 2013-07-14 17:01:39.000000000 +0000
25698 +++ linux-3.10.15-vs2.3.6.6/net/sunrpc/auth.c 2013-08-22 20:30:00.000000000 +0000
25700 #include <linux/sunrpc/clnt.h>
25701 #include <linux/sunrpc/gss_api.h>
25702 #include <linux/spinlock.h>
25703 +#include <linux/vs_tag.h>
25706 # define RPCDBG_FACILITY RPCDBG_AUTH
25707 @@ -553,6 +554,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
25708 memset(&acred, 0, sizeof(acred));
25709 acred.uid = cred->fsuid;
25710 acred.gid = cred->fsgid;
25711 + acred.tag = make_ktag(&init_user_ns, dx_current_tag());
25712 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
25714 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
25715 @@ -593,6 +595,7 @@ rpcauth_bind_root_cred(struct rpc_task *
25716 struct auth_cred acred = {
25717 .uid = GLOBAL_ROOT_UID,
25718 .gid = GLOBAL_ROOT_GID,
25719 + .tag = KTAGT_INIT(dx_current_tag()),
25722 dprintk("RPC: %5u looking up %s cred\n",
25723 diff -NurpP --minimal linux-3.10.15/net/sunrpc/auth_unix.c linux-3.10.15-vs2.3.6.6/net/sunrpc/auth_unix.c
25724 --- linux-3.10.15/net/sunrpc/auth_unix.c 2013-05-31 13:45:33.000000000 +0000
25725 +++ linux-3.10.15-vs2.3.6.6/net/sunrpc/auth_unix.c 2013-08-22 20:30:00.000000000 +0000
25726 @@ -13,11 +13,13 @@
25727 #include <linux/sunrpc/clnt.h>
25728 #include <linux/sunrpc/auth.h>
25729 #include <linux/user_namespace.h>
25730 +#include <linux/vs_tag.h>
25732 #define NFS_NGROUPS 16
25735 struct rpc_cred uc_base;
25738 kgid_t uc_gids[NFS_NGROUPS];
25740 @@ -80,6 +82,7 @@ unx_create_cred(struct rpc_auth *auth, s
25741 groups = NFS_NGROUPS;
25743 cred->uc_gid = acred->gid;
25744 + cred->uc_tag = acred->tag;
25745 for (i = 0; i < groups; i++)
25746 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
25747 if (i < NFS_NGROUPS)
25748 @@ -121,7 +124,9 @@ unx_match(struct auth_cred *acred, struc
25752 - if (!uid_eq(cred->uc_uid, acred->uid) || !gid_eq(cred->uc_gid, acred->gid))
25753 + if (!uid_eq(cred->uc_uid, acred->uid) ||
25754 + !gid_eq(cred->uc_gid, acred->gid) ||
25755 + !tag_eq(cred->uc_tag, acred->tag))
25758 if (acred->group_info != NULL)
25759 @@ -146,7 +151,7 @@ unx_marshal(struct rpc_task *task, __be3
25760 struct rpc_clnt *clnt = task->tk_client;
25761 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
25762 __be32 *base, *hold;
25766 *p++ = htonl(RPC_AUTH_UNIX);
25768 @@ -157,8 +162,11 @@ unx_marshal(struct rpc_task *task, __be3
25770 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
25772 - *p++ = htonl((u32) from_kuid(&init_user_ns, cred->uc_uid));
25773 - *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gid));
25774 + tag = task->tk_client->cl_tag;
25775 + *p++ = htonl((u32) from_kuid(&init_user_ns,
25776 + TAGINO_KUID(tag, cred->uc_uid, cred->uc_tag)));
25777 + *p++ = htonl((u32) from_kgid(&init_user_ns,
25778 + TAGINO_KGID(tag, cred->uc_gid, cred->uc_tag)));
25780 for (i = 0; i < 16 && gid_valid(cred->uc_gids[i]); i++)
25781 *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gids[i]));
25782 diff -NurpP --minimal linux-3.10.15/net/sunrpc/clnt.c linux-3.10.15-vs2.3.6.6/net/sunrpc/clnt.c
25783 --- linux-3.10.15/net/sunrpc/clnt.c 2013-10-09 17:35:24.000000000 +0000
25784 +++ linux-3.10.15-vs2.3.6.6/net/sunrpc/clnt.c 2013-08-22 20:30:00.000000000 +0000
25786 #include <linux/in6.h>
25787 #include <linux/un.h>
25788 #include <linux/rcupdate.h>
25789 +#include <linux/vs_cvirt.h>
25791 #include <linux/sunrpc/clnt.h>
25792 #include <linux/sunrpc/addr.h>
25793 @@ -486,6 +487,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
25794 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
25795 clnt->cl_chatty = 1;
25797 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
25798 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
25799 + clnt->cl_tag = 1; */
25802 EXPORT_SYMBOL_GPL(rpc_create);
25803 diff -NurpP --minimal linux-3.10.15/net/unix/af_unix.c linux-3.10.15-vs2.3.6.6/net/unix/af_unix.c
25804 --- linux-3.10.15/net/unix/af_unix.c 2013-07-14 17:01:39.000000000 +0000
25805 +++ linux-3.10.15-vs2.3.6.6/net/unix/af_unix.c 2013-08-22 20:30:00.000000000 +0000
25806 @@ -114,6 +114,8 @@
25807 #include <linux/mount.h>
25808 #include <net/checksum.h>
25809 #include <linux/security.h>
25810 +#include <linux/vs_context.h>
25811 +#include <linux/vs_limit.h>
25813 struct hlist_head unix_socket_table[2 * UNIX_HASH_SIZE];
25814 EXPORT_SYMBOL_GPL(unix_socket_table);
25815 @@ -270,6 +272,8 @@ static struct sock *__unix_find_socket_b
25816 if (!net_eq(sock_net(s), net))
25819 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25821 if (u->addr->len == len &&
25822 !memcmp(u->addr->name, sunname, len))
25824 @@ -2257,6 +2261,8 @@ static struct sock *unix_from_bucket(str
25825 for (sk = sk_head(&unix_socket_table[bucket]); sk; sk = sk_next(sk)) {
25826 if (sock_net(sk) != seq_file_net(seq))
25828 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25830 if (++count == offset)
25833 @@ -2274,6 +2280,8 @@ static struct sock *unix_next_socket(str
25837 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25839 if (sock_net(sk) == seq_file_net(seq))
25842 diff -NurpP --minimal linux-3.10.15/scripts/checksyscalls.sh linux-3.10.15-vs2.3.6.6/scripts/checksyscalls.sh
25843 --- linux-3.10.15/scripts/checksyscalls.sh 2012-12-11 03:30:57.000000000 +0000
25844 +++ linux-3.10.15-vs2.3.6.6/scripts/checksyscalls.sh 2013-08-22 20:30:00.000000000 +0000
25845 @@ -193,7 +193,6 @@ cat << EOF
25846 #define __IGNORE_afs_syscall
25847 #define __IGNORE_getpmsg
25848 #define __IGNORE_putpmsg
25849 -#define __IGNORE_vserver
25853 diff -NurpP --minimal linux-3.10.15/security/commoncap.c linux-3.10.15-vs2.3.6.6/security/commoncap.c
25854 --- linux-3.10.15/security/commoncap.c 2013-05-31 13:45:34.000000000 +0000
25855 +++ linux-3.10.15-vs2.3.6.6/security/commoncap.c 2013-08-22 20:30:00.000000000 +0000
25856 @@ -76,6 +76,7 @@ int cap_netlink_send(struct sock *sk, st
25857 int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
25858 int cap, int audit)
25860 + struct vx_info *vxi = current_vx_info(); /* FIXME: get vxi from cred? */
25861 struct user_namespace *ns = targ_ns;
25863 /* See if cred has the capability in the target user namespace
25864 @@ -84,8 +85,12 @@ int cap_capable(const struct cred *cred,
25867 /* Do we have the necessary capabilities? */
25868 - if (ns == cred->user_ns)
25869 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
25870 + if (ns == cred->user_ns) {
25871 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
25872 + cap_raised(cred->cap_effective, cap))
25874 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
25877 /* Have we tried all of the parent namespaces? */
25878 if (ns == &init_user_ns)
25879 @@ -628,7 +633,7 @@ int cap_inode_setxattr(struct dentry *de
25881 if (!strncmp(name, XATTR_SECURITY_PREFIX,
25882 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
25883 - !capable(CAP_SYS_ADMIN))
25884 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
25888 @@ -654,7 +659,7 @@ int cap_inode_removexattr(struct dentry
25890 if (!strncmp(name, XATTR_SECURITY_PREFIX,
25891 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
25892 - !capable(CAP_SYS_ADMIN))
25893 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
25897 diff -NurpP --minimal linux-3.10.15/security/selinux/hooks.c linux-3.10.15-vs2.3.6.6/security/selinux/hooks.c
25898 --- linux-3.10.15/security/selinux/hooks.c 2013-07-14 17:01:42.000000000 +0000
25899 +++ linux-3.10.15-vs2.3.6.6/security/selinux/hooks.c 2013-08-22 20:30:00.000000000 +0000
25901 #include <linux/dccp.h>
25902 #include <linux/quota.h>
25903 #include <linux/un.h> /* for Unix socket types */
25904 -#include <net/af_unix.h> /* for Unix socket types */
25905 #include <linux/parser.h>
25906 #include <linux/nfs_mount.h>
25907 #include <net/ipv6.h>