1 diff -NurpP --minimal linux-3.9.5/Documentation/vserver/debug.txt linux-3.9.5-vs2.3.6.5/Documentation/vserver/debug.txt
2 --- linux-3.9.5/Documentation/vserver/debug.txt 1970-01-01 00:00:00.000000000 +0000
3 +++ linux-3.9.5-vs2.3.6.5/Documentation/vserver/debug.txt 2013-05-31 14:47:10.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.9.5/arch/alpha/Kconfig linux-3.9.5-vs2.3.6.5/arch/alpha/Kconfig
160 --- linux-3.9.5/arch/alpha/Kconfig 2013-05-31 13:44:28.000000000 +0000
161 +++ linux-3.9.5-vs2.3.6.5/arch/alpha/Kconfig 2013-05-31 14:47:10.000000000 +0000
162 @@ -669,6 +669,8 @@ config DUMMY_CONSOLE
166 +source "kernel/vserver/Kconfig"
168 source "security/Kconfig"
170 source "crypto/Kconfig"
171 diff -NurpP --minimal linux-3.9.5/arch/alpha/kernel/systbls.S linux-3.9.5-vs2.3.6.5/arch/alpha/kernel/systbls.S
172 --- linux-3.9.5/arch/alpha/kernel/systbls.S 2013-02-19 13:56:11.000000000 +0000
173 +++ linux-3.9.5-vs2.3.6.5/arch/alpha/kernel/systbls.S 2013-05-31 14:47:11.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.9.5/arch/alpha/kernel/traps.c linux-3.9.5-vs2.3.6.5/arch/alpha/kernel/traps.c
184 --- linux-3.9.5/arch/alpha/kernel/traps.c 2013-05-31 13:44:28.000000000 +0000
185 +++ linux-3.9.5-vs2.3.6.5/arch/alpha/kernel/traps.c 2013-06-12 09:32:34.000000000 +0000
186 @@ -184,7 +184,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.9.5/arch/arm/Kconfig linux-3.9.5-vs2.3.6.5/arch/arm/Kconfig
197 --- linux-3.9.5/arch/arm/Kconfig 2013-05-31 13:44:29.000000000 +0000
198 +++ linux-3.9.5-vs2.3.6.5/arch/arm/Kconfig 2013-05-31 14:47:11.000000000 +0000
199 @@ -2353,6 +2353,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.9.5/arch/arm/kernel/calls.S linux-3.9.5-vs2.3.6.5/arch/arm/kernel/calls.S
209 --- linux-3.9.5/arch/arm/kernel/calls.S 2013-05-31 13:44:29.000000000 +0000
210 +++ linux-3.9.5-vs2.3.6.5/arch/arm/kernel/calls.S 2013-05-31 14:47:11.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.9.5/arch/arm/kernel/process.c linux-3.9.5-vs2.3.6.5/arch/arm/kernel/process.c
221 --- linux-3.9.5/arch/arm/kernel/process.c 2013-05-31 13:44:29.000000000 +0000
222 +++ linux-3.9.5-vs2.3.6.5/arch/arm/kernel/process.c 2013-06-12 09:33:04.000000000 +0000
223 @@ -332,7 +332,8 @@ void __show_regs(struct pt_regs *regs)
224 void show_regs(struct pt_regs * regs)
227 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
228 + printk("Pid: %d:#%u, comm: %20s\n",
229 + task_pid_nr(current), current->xid, current->comm);
233 diff -NurpP --minimal linux-3.9.5/arch/arm/kernel/traps.c linux-3.9.5-vs2.3.6.5/arch/arm/kernel/traps.c
234 --- linux-3.9.5/arch/arm/kernel/traps.c 2013-05-31 13:44:29.000000000 +0000
235 +++ linux-3.9.5-vs2.3.6.5/arch/arm/kernel/traps.c 2013-05-31 14:47:11.000000000 +0000
236 @@ -249,8 +249,8 @@ static int __die(const char *str, int er
240 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
241 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), end_of_stack(tsk));
242 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
243 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, end_of_stack(tsk));
245 if (!user_mode(regs) || in_interrupt()) {
246 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
247 diff -NurpP --minimal linux-3.9.5/arch/cris/Kconfig linux-3.9.5-vs2.3.6.5/arch/cris/Kconfig
248 --- linux-3.9.5/arch/cris/Kconfig 2013-05-31 13:44:37.000000000 +0000
249 +++ linux-3.9.5-vs2.3.6.5/arch/cris/Kconfig 2013-05-31 14:47:11.000000000 +0000
250 @@ -674,6 +674,8 @@ source "drivers/staging/Kconfig"
252 source "arch/cris/Kconfig.debug"
254 +source "kernel/vserver/Kconfig"
256 source "security/Kconfig"
258 source "crypto/Kconfig"
259 diff -NurpP --minimal linux-3.9.5/arch/h8300/Kconfig linux-3.9.5-vs2.3.6.5/arch/h8300/Kconfig
260 --- linux-3.9.5/arch/h8300/Kconfig 2013-05-31 13:44:38.000000000 +0000
261 +++ linux-3.9.5-vs2.3.6.5/arch/h8300/Kconfig 2013-05-31 14:47:11.000000000 +0000
262 @@ -221,6 +221,8 @@ source "fs/Kconfig"
264 source "arch/h8300/Kconfig.debug"
266 +source "kernel/vserver/Kconfig"
268 source "security/Kconfig"
270 source "crypto/Kconfig"
271 diff -NurpP --minimal linux-3.9.5/arch/ia64/Kconfig linux-3.9.5-vs2.3.6.5/arch/ia64/Kconfig
272 --- linux-3.9.5/arch/ia64/Kconfig 2013-05-31 13:44:38.000000000 +0000
273 +++ linux-3.9.5-vs2.3.6.5/arch/ia64/Kconfig 2013-05-31 14:47:11.000000000 +0000
274 @@ -645,6 +645,8 @@ source "fs/Kconfig"
276 source "arch/ia64/Kconfig.debug"
278 +source "kernel/vserver/Kconfig"
280 source "security/Kconfig"
282 source "crypto/Kconfig"
283 diff -NurpP --minimal linux-3.9.5/arch/ia64/kernel/entry.S linux-3.9.5-vs2.3.6.5/arch/ia64/kernel/entry.S
284 --- linux-3.9.5/arch/ia64/kernel/entry.S 2013-05-31 13:44:38.000000000 +0000
285 +++ linux-3.9.5-vs2.3.6.5/arch/ia64/kernel/entry.S 2013-05-31 14:47:11.000000000 +0000
286 @@ -1719,7 +1719,7 @@ sys_call_table:
288 data8 sys_mq_getsetattr
290 - data8 sys_ni_syscall // reserved for vserver
292 data8 sys_waitid // 1270
294 data8 sys_request_key
295 diff -NurpP --minimal linux-3.9.5/arch/ia64/kernel/process.c linux-3.9.5-vs2.3.6.5/arch/ia64/kernel/process.c
296 --- linux-3.9.5/arch/ia64/kernel/process.c 2013-05-31 13:44:38.000000000 +0000
297 +++ linux-3.9.5-vs2.3.6.5/arch/ia64/kernel/process.c 2013-06-12 09:33:32.000000000 +0000
298 @@ -109,8 +109,8 @@ show_regs (struct pt_regs *regs)
299 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
302 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
303 - smp_processor_id(), current->comm);
304 + printk("\nPid: %d:#%u, CPU %d, comm: %20s\n", task_pid_nr(current),
305 + current->xid, smp_processor_id(), current->comm);
306 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
307 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
308 init_utsname()->release);
309 diff -NurpP --minimal linux-3.9.5/arch/ia64/kernel/ptrace.c linux-3.9.5-vs2.3.6.5/arch/ia64/kernel/ptrace.c
310 --- linux-3.9.5/arch/ia64/kernel/ptrace.c 2013-02-19 13:56:51.000000000 +0000
311 +++ linux-3.9.5-vs2.3.6.5/arch/ia64/kernel/ptrace.c 2013-05-31 14:47:11.000000000 +0000
313 #include <linux/regset.h>
314 #include <linux/elf.h>
315 #include <linux/tracehook.h>
316 +#include <linux/vs_base.h>
318 #include <asm/pgtable.h>
319 #include <asm/processor.h>
320 diff -NurpP --minimal linux-3.9.5/arch/ia64/kernel/traps.c linux-3.9.5-vs2.3.6.5/arch/ia64/kernel/traps.c
321 --- linux-3.9.5/arch/ia64/kernel/traps.c 2013-05-31 13:44:38.000000000 +0000
322 +++ linux-3.9.5-vs2.3.6.5/arch/ia64/kernel/traps.c 2013-06-12 09:33:50.000000000 +0000
323 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
326 if (++die.lock_owner_depth < 3) {
327 - printk("%s[%d]: %s %ld [%d]\n",
328 - current->comm, task_pid_nr(current), str, err, ++die_counter);
329 + printk("%s[%d:#%u]: %s %ld [%d]\n",
330 + current->comm, task_pid_nr(current), current->xid,
331 + str, err, ++die_counter);
332 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
335 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
336 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
337 last.time = current_jiffies + 5 * HZ;
339 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
340 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
341 + "%s(%d:#%u): floating-point assist fault at ip %016lx, isr %016lx\n",
342 + current->comm, task_pid_nr(current), current->xid,
343 + regs->cr_iip + ia64_psr(regs)->ri, isr);
347 diff -NurpP --minimal linux-3.9.5/arch/m32r/kernel/traps.c linux-3.9.5-vs2.3.6.5/arch/m32r/kernel/traps.c
348 --- linux-3.9.5/arch/m32r/kernel/traps.c 2012-12-11 03:30:57.000000000 +0000
349 +++ linux-3.9.5-vs2.3.6.5/arch/m32r/kernel/traps.c 2013-06-12 09:33:58.000000000 +0000
350 @@ -195,8 +195,9 @@ static void show_registers(struct pt_reg
352 printk("SPI: %08lx\n", sp);
354 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
355 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
356 + printk("Process %s (pid: %d:#%u, process nr: %d, stackpage=%08lx)",
357 + current->comm, task_pid_nr(current), current->xid,
358 + 0xffff & i, 4096+(unsigned long)current);
361 * When in-kernel, we also print out the stack and code at the
362 diff -NurpP --minimal linux-3.9.5/arch/m68k/Kconfig linux-3.9.5-vs2.3.6.5/arch/m68k/Kconfig
363 --- linux-3.9.5/arch/m68k/Kconfig 2013-05-31 13:44:38.000000000 +0000
364 +++ linux-3.9.5-vs2.3.6.5/arch/m68k/Kconfig 2013-05-31 14:47:11.000000000 +0000
365 @@ -137,6 +137,8 @@ source "fs/Kconfig"
367 source "arch/m68k/Kconfig.debug"
369 +source "kernel/vserver/Kconfig"
371 source "security/Kconfig"
373 source "crypto/Kconfig"
374 diff -NurpP --minimal linux-3.9.5/arch/mips/Kconfig linux-3.9.5-vs2.3.6.5/arch/mips/Kconfig
375 --- linux-3.9.5/arch/mips/Kconfig 2013-05-31 13:44:39.000000000 +0000
376 +++ linux-3.9.5-vs2.3.6.5/arch/mips/Kconfig 2013-05-31 14:47:11.000000000 +0000
377 @@ -2550,6 +2550,8 @@ source "fs/Kconfig"
379 source "arch/mips/Kconfig.debug"
381 +source "kernel/vserver/Kconfig"
383 source "security/Kconfig"
385 source "crypto/Kconfig"
386 diff -NurpP --minimal linux-3.9.5/arch/mips/kernel/ptrace.c linux-3.9.5-vs2.3.6.5/arch/mips/kernel/ptrace.c
387 --- linux-3.9.5/arch/mips/kernel/ptrace.c 2013-05-31 13:44:42.000000000 +0000
388 +++ linux-3.9.5-vs2.3.6.5/arch/mips/kernel/ptrace.c 2013-05-31 14:47:11.000000000 +0000
390 #include <linux/security.h>
391 #include <linux/audit.h>
392 #include <linux/seccomp.h>
393 +#include <linux/vs_base.h>
395 #include <asm/byteorder.h>
397 @@ -262,6 +263,9 @@ long arch_ptrace(struct task_struct *chi
398 void __user *datavp = (void __user *) data;
399 unsigned long __user *datalp = (void __user *) data;
401 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
405 /* when I and D space are separate, these will need to be fixed. */
406 case PTRACE_PEEKTEXT: /* read word at location addr. */
407 diff -NurpP --minimal linux-3.9.5/arch/mips/kernel/scall32-o32.S linux-3.9.5-vs2.3.6.5/arch/mips/kernel/scall32-o32.S
408 --- linux-3.9.5/arch/mips/kernel/scall32-o32.S 2013-05-31 13:44:42.000000000 +0000
409 +++ linux-3.9.5-vs2.3.6.5/arch/mips/kernel/scall32-o32.S 2013-05-31 14:47:11.000000000 +0000
410 @@ -512,7 +512,7 @@ einval: li v0, -ENOSYS
411 sys sys_mq_timedreceive 5
412 sys sys_mq_notify 2 /* 4275 */
413 sys sys_mq_getsetattr 3
414 - sys sys_ni_syscall 0 /* sys_vserver */
417 sys sys_ni_syscall 0 /* available, was setaltroot */
418 sys sys_add_key 5 /* 4280 */
419 diff -NurpP --minimal linux-3.9.5/arch/mips/kernel/scall64-64.S linux-3.9.5-vs2.3.6.5/arch/mips/kernel/scall64-64.S
420 --- linux-3.9.5/arch/mips/kernel/scall64-64.S 2013-05-31 13:44:42.000000000 +0000
421 +++ linux-3.9.5-vs2.3.6.5/arch/mips/kernel/scall64-64.S 2013-05-31 14:47:11.000000000 +0000
422 @@ -351,7 +351,7 @@ sys_call_table:
423 PTR sys_mq_timedreceive
425 PTR sys_mq_getsetattr /* 5235 */
426 - PTR sys_ni_syscall /* sys_vserver */
429 PTR sys_ni_syscall /* available, was setaltroot */
431 diff -NurpP --minimal linux-3.9.5/arch/mips/kernel/scall64-n32.S linux-3.9.5-vs2.3.6.5/arch/mips/kernel/scall64-n32.S
432 --- linux-3.9.5/arch/mips/kernel/scall64-n32.S 2013-05-31 13:44:42.000000000 +0000
433 +++ linux-3.9.5-vs2.3.6.5/arch/mips/kernel/scall64-n32.S 2013-05-31 14:47:11.000000000 +0000
434 @@ -344,7 +344,7 @@ EXPORT(sysn32_call_table)
435 PTR compat_sys_mq_timedreceive
436 PTR compat_sys_mq_notify
437 PTR compat_sys_mq_getsetattr
438 - PTR sys_ni_syscall /* 6240, sys_vserver */
439 + PTR sys32_vserver /* 6240 */
440 PTR compat_sys_waitid
441 PTR sys_ni_syscall /* available, was setaltroot */
443 diff -NurpP --minimal linux-3.9.5/arch/mips/kernel/scall64-o32.S linux-3.9.5-vs2.3.6.5/arch/mips/kernel/scall64-o32.S
444 --- linux-3.9.5/arch/mips/kernel/scall64-o32.S 2013-05-31 13:44:42.000000000 +0000
445 +++ linux-3.9.5-vs2.3.6.5/arch/mips/kernel/scall64-o32.S 2013-05-31 15:07:53.000000000 +0000
446 @@ -469,7 +469,7 @@ sys_call_table:
447 PTR compat_sys_mq_timedreceive
448 PTR compat_sys_mq_notify /* 4275 */
449 PTR compat_sys_mq_getsetattr
450 - PTR sys_ni_syscall /* sys_vserver */
452 PTR compat_sys_waitid
453 PTR sys_ni_syscall /* available, was setaltroot */
454 PTR sys_add_key /* 4280 */
455 diff -NurpP --minimal linux-3.9.5/arch/mips/kernel/traps.c linux-3.9.5-vs2.3.6.5/arch/mips/kernel/traps.c
456 --- linux-3.9.5/arch/mips/kernel/traps.c 2013-05-31 13:44:42.000000000 +0000
457 +++ linux-3.9.5-vs2.3.6.5/arch/mips/kernel/traps.c 2013-05-31 14:47:11.000000000 +0000
458 @@ -348,9 +348,10 @@ void show_registers(struct pt_regs *regs
462 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
463 - current->comm, current->pid, current_thread_info(), current,
464 - field, current_thread_info()->tp_value);
465 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
466 + current->comm, task_pid_nr(current), current->xid,
467 + current_thread_info(), current,
468 + field, current_thread_info()->tp_value);
469 if (cpu_has_userlocal) {
472 diff -NurpP --minimal linux-3.9.5/arch/parisc/Kconfig linux-3.9.5-vs2.3.6.5/arch/parisc/Kconfig
473 --- linux-3.9.5/arch/parisc/Kconfig 2013-05-31 13:44:44.000000000 +0000
474 +++ linux-3.9.5-vs2.3.6.5/arch/parisc/Kconfig 2013-05-31 14:47:11.000000000 +0000
475 @@ -308,6 +308,8 @@ source "fs/Kconfig"
477 source "arch/parisc/Kconfig.debug"
479 +source "kernel/vserver/Kconfig"
481 source "security/Kconfig"
483 source "crypto/Kconfig"
484 diff -NurpP --minimal linux-3.9.5/arch/parisc/kernel/syscall_table.S linux-3.9.5-vs2.3.6.5/arch/parisc/kernel/syscall_table.S
485 --- linux-3.9.5/arch/parisc/kernel/syscall_table.S 2013-05-31 13:44:44.000000000 +0000
486 +++ linux-3.9.5-vs2.3.6.5/arch/parisc/kernel/syscall_table.S 2013-05-31 14:47:11.000000000 +0000
488 ENTRY_COMP(mbind) /* 260 */
489 ENTRY_COMP(get_mempolicy)
490 ENTRY_COMP(set_mempolicy)
491 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
492 + ENTRY_DIFF(vserver)
494 ENTRY_SAME(request_key) /* 265 */
496 diff -NurpP --minimal linux-3.9.5/arch/parisc/kernel/traps.c linux-3.9.5-vs2.3.6.5/arch/parisc/kernel/traps.c
497 --- linux-3.9.5/arch/parisc/kernel/traps.c 2013-05-31 13:44:44.000000000 +0000
498 +++ linux-3.9.5-vs2.3.6.5/arch/parisc/kernel/traps.c 2013-05-31 14:47:11.000000000 +0000
499 @@ -235,8 +235,9 @@ void die_if_kernel(char *str, struct pt_
503 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
504 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
505 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
506 + current->comm, task_pid_nr(current), current->xid,
507 + str, err, regs->iaoq[0]);
508 #ifdef PRINT_USER_FAULTS
509 /* XXX for debugging only */
511 @@ -269,8 +270,8 @@ void die_if_kernel(char *str, struct pt_
512 pdc_console_restart();
515 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
516 - current->comm, task_pid_nr(current), str, err);
517 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
518 + current->comm, task_pid_nr(current), current->xid, str, err);
520 /* Wot's wrong wif bein' racy? */
521 if (current->thread.flags & PARISC_KERNEL_DEATH) {
522 diff -NurpP --minimal linux-3.9.5/arch/parisc/mm/fault.c linux-3.9.5-vs2.3.6.5/arch/parisc/mm/fault.c
523 --- linux-3.9.5/arch/parisc/mm/fault.c 2013-05-31 13:44:44.000000000 +0000
524 +++ linux-3.9.5-vs2.3.6.5/arch/parisc/mm/fault.c 2013-05-31 14:47:11.000000000 +0000
525 @@ -257,8 +257,9 @@ bad_area:
527 #ifdef PRINT_USER_FAULTS
528 printk(KERN_DEBUG "\n");
529 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
530 - task_pid_nr(tsk), tsk->comm, code, address);
531 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
532 + "command='%s' type=%lu address=0x%08lx\n",
533 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
535 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
536 vma->vm_start, vma->vm_end);
537 diff -NurpP --minimal linux-3.9.5/arch/powerpc/Kconfig linux-3.9.5-vs2.3.6.5/arch/powerpc/Kconfig
538 --- linux-3.9.5/arch/powerpc/Kconfig 2013-05-31 13:44:44.000000000 +0000
539 +++ linux-3.9.5-vs2.3.6.5/arch/powerpc/Kconfig 2013-05-31 14:47:11.000000000 +0000
540 @@ -1027,6 +1027,8 @@ source "lib/Kconfig"
542 source "arch/powerpc/Kconfig.debug"
544 +source "kernel/vserver/Kconfig"
546 source "security/Kconfig"
549 diff -NurpP --minimal linux-3.9.5/arch/powerpc/include/uapi/asm/unistd.h linux-3.9.5-vs2.3.6.5/arch/powerpc/include/uapi/asm/unistd.h
550 --- linux-3.9.5/arch/powerpc/include/uapi/asm/unistd.h 2013-05-31 13:44:44.000000000 +0000
551 +++ linux-3.9.5-vs2.3.6.5/arch/powerpc/include/uapi/asm/unistd.h 2013-05-31 14:47:11.000000000 +0000
554 #define __NR_rtas 255
555 #define __NR_sys_debug_setcontext 256
556 -/* Number 257 is reserved for vserver */
557 +#define __NR_vserver 257
558 #define __NR_migrate_pages 258
559 #define __NR_mbind 259
560 #define __NR_get_mempolicy 260
561 diff -NurpP --minimal linux-3.9.5/arch/powerpc/kernel/process.c linux-3.9.5-vs2.3.6.5/arch/powerpc/kernel/process.c
562 --- linux-3.9.5/arch/powerpc/kernel/process.c 2013-05-31 13:44:44.000000000 +0000
563 +++ linux-3.9.5-vs2.3.6.5/arch/powerpc/kernel/process.c 2013-06-12 09:34:39.000000000 +0000
564 @@ -850,8 +850,9 @@ void show_regs(struct pt_regs * regs)
566 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
568 - printk("TASK = %p[%d] '%s' THREAD: %p",
569 - current, task_pid_nr(current), current->comm, task_thread_info(current));
570 + printk("TASK = %p[%d:#%u] '%s' THREAD: %p",
571 + current, task_pid_nr(current), current->xid,
572 + current->comm, task_thread_info(current));
575 printk(" CPU: %d", raw_smp_processor_id());
576 diff -NurpP --minimal linux-3.9.5/arch/powerpc/kernel/traps.c linux-3.9.5-vs2.3.6.5/arch/powerpc/kernel/traps.c
577 --- linux-3.9.5/arch/powerpc/kernel/traps.c 2013-06-11 12:22:35.000000000 +0000
578 +++ linux-3.9.5-vs2.3.6.5/arch/powerpc/kernel/traps.c 2013-06-13 00:14:31.000000000 +0000
579 @@ -1196,8 +1196,9 @@ void nonrecoverable_exception(struct pt_
581 void trace_syscall(struct pt_regs *regs)
583 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
584 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
585 + printk("Task: %p(%d:#%u), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
586 + current, task_pid_nr(current), current->xid,
587 + regs->nip, regs->link, regs->gpr[0],
588 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
591 diff -NurpP --minimal linux-3.9.5/arch/s390/Kconfig linux-3.9.5-vs2.3.6.5/arch/s390/Kconfig
592 --- linux-3.9.5/arch/s390/Kconfig 2013-05-31 13:44:45.000000000 +0000
593 +++ linux-3.9.5-vs2.3.6.5/arch/s390/Kconfig 2013-05-31 14:47:11.000000000 +0000
594 @@ -592,6 +592,8 @@ source "fs/Kconfig"
596 source "arch/s390/Kconfig.debug"
598 +source "kernel/vserver/Kconfig"
600 source "security/Kconfig"
602 source "crypto/Kconfig"
603 diff -NurpP --minimal linux-3.9.5/arch/s390/include/asm/tlb.h linux-3.9.5-vs2.3.6.5/arch/s390/include/asm/tlb.h
604 --- linux-3.9.5/arch/s390/include/asm/tlb.h 2012-12-11 03:30:57.000000000 +0000
605 +++ linux-3.9.5-vs2.3.6.5/arch/s390/include/asm/tlb.h 2013-05-31 14:47:11.000000000 +0000
607 #include <linux/mm.h>
608 #include <linux/pagemap.h>
609 #include <linux/swap.h>
611 #include <asm/processor.h>
612 #include <asm/pgalloc.h>
613 #include <asm/tlbflush.h>
614 diff -NurpP --minimal linux-3.9.5/arch/s390/include/uapi/asm/unistd.h linux-3.9.5-vs2.3.6.5/arch/s390/include/uapi/asm/unistd.h
615 --- linux-3.9.5/arch/s390/include/uapi/asm/unistd.h 2013-02-19 13:57:16.000000000 +0000
616 +++ linux-3.9.5-vs2.3.6.5/arch/s390/include/uapi/asm/unistd.h 2013-05-31 14:47:11.000000000 +0000
618 #define __NR_clock_gettime (__NR_timer_create+6)
619 #define __NR_clock_getres (__NR_timer_create+7)
620 #define __NR_clock_nanosleep (__NR_timer_create+8)
621 -/* Number 263 is reserved for vserver */
622 +#define __NR_vserver 263
623 #define __NR_statfs64 265
624 #define __NR_fstatfs64 266
625 #define __NR_remap_file_pages 267
626 diff -NurpP --minimal linux-3.9.5/arch/s390/kernel/ptrace.c linux-3.9.5-vs2.3.6.5/arch/s390/kernel/ptrace.c
627 --- linux-3.9.5/arch/s390/kernel/ptrace.c 2012-12-11 03:30:57.000000000 +0000
628 +++ linux-3.9.5-vs2.3.6.5/arch/s390/kernel/ptrace.c 2013-05-31 14:47:11.000000000 +0000
630 #include <linux/tracehook.h>
631 #include <linux/seccomp.h>
632 #include <linux/compat.h>
633 +#include <linux/vs_base.h>
634 #include <trace/syscall.h>
635 #include <asm/segment.h>
636 #include <asm/page.h>
637 diff -NurpP --minimal linux-3.9.5/arch/s390/kernel/syscalls.S linux-3.9.5-vs2.3.6.5/arch/s390/kernel/syscalls.S
638 --- linux-3.9.5/arch/s390/kernel/syscalls.S 2013-05-31 13:44:45.000000000 +0000
639 +++ linux-3.9.5-vs2.3.6.5/arch/s390/kernel/syscalls.S 2013-05-31 14:47:11.000000000 +0000
640 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
641 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
642 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
643 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
644 -NI_SYSCALL /* reserved for vserver */
645 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
646 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
647 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
648 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
649 diff -NurpP --minimal linux-3.9.5/arch/sh/Kconfig linux-3.9.5-vs2.3.6.5/arch/sh/Kconfig
650 --- linux-3.9.5/arch/sh/Kconfig 2013-05-31 13:44:45.000000000 +0000
651 +++ linux-3.9.5-vs2.3.6.5/arch/sh/Kconfig 2013-05-31 14:47:11.000000000 +0000
652 @@ -951,6 +951,8 @@ source "fs/Kconfig"
654 source "arch/sh/Kconfig.debug"
656 +source "kernel/vserver/Kconfig"
658 source "security/Kconfig"
660 source "crypto/Kconfig"
661 diff -NurpP --minimal linux-3.9.5/arch/sh/kernel/irq.c linux-3.9.5-vs2.3.6.5/arch/sh/kernel/irq.c
662 --- linux-3.9.5/arch/sh/kernel/irq.c 2012-12-11 03:30:57.000000000 +0000
663 +++ linux-3.9.5-vs2.3.6.5/arch/sh/kernel/irq.c 2013-05-31 14:47:11.000000000 +0000
665 #include <linux/ftrace.h>
666 #include <linux/delay.h>
667 #include <linux/ratelimit.h>
668 +// #include <linux/vs_context.h>
669 #include <asm/processor.h>
670 #include <asm/machvec.h>
671 #include <asm/uaccess.h>
672 diff -NurpP --minimal linux-3.9.5/arch/sparc/Kconfig linux-3.9.5-vs2.3.6.5/arch/sparc/Kconfig
673 --- linux-3.9.5/arch/sparc/Kconfig 2013-05-31 13:44:47.000000000 +0000
674 +++ linux-3.9.5-vs2.3.6.5/arch/sparc/Kconfig 2013-05-31 14:47:11.000000000 +0000
675 @@ -559,6 +559,8 @@ source "fs/Kconfig"
677 source "arch/sparc/Kconfig.debug"
679 +source "kernel/vserver/Kconfig"
681 source "security/Kconfig"
683 source "crypto/Kconfig"
684 diff -NurpP --minimal linux-3.9.5/arch/sparc/include/uapi/asm/unistd.h linux-3.9.5-vs2.3.6.5/arch/sparc/include/uapi/asm/unistd.h
685 --- linux-3.9.5/arch/sparc/include/uapi/asm/unistd.h 2013-02-19 13:57:17.000000000 +0000
686 +++ linux-3.9.5-vs2.3.6.5/arch/sparc/include/uapi/asm/unistd.h 2013-05-31 14:47:11.000000000 +0000
688 #define __NR_timer_getoverrun 264
689 #define __NR_timer_delete 265
690 #define __NR_timer_create 266
691 -/* #define __NR_vserver 267 Reserved for VSERVER */
692 +#define __NR_vserver 267
693 #define __NR_io_setup 268
694 #define __NR_io_destroy 269
695 #define __NR_io_submit 270
696 diff -NurpP --minimal linux-3.9.5/arch/sparc/kernel/systbls_32.S linux-3.9.5-vs2.3.6.5/arch/sparc/kernel/systbls_32.S
697 --- linux-3.9.5/arch/sparc/kernel/systbls_32.S 2013-05-31 13:44:48.000000000 +0000
698 +++ linux-3.9.5-vs2.3.6.5/arch/sparc/kernel/systbls_32.S 2013-05-31 14:47:11.000000000 +0000
699 @@ -70,7 +70,7 @@ sys_call_table:
700 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_ni_syscall
701 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
702 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
703 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
704 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
705 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
706 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
707 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
708 diff -NurpP --minimal linux-3.9.5/arch/sparc/kernel/systbls_64.S linux-3.9.5-vs2.3.6.5/arch/sparc/kernel/systbls_64.S
709 --- linux-3.9.5/arch/sparc/kernel/systbls_64.S 2013-05-31 13:44:48.000000000 +0000
710 +++ linux-3.9.5-vs2.3.6.5/arch/sparc/kernel/systbls_64.S 2013-05-31 14:47:11.000000000 +0000
711 @@ -71,7 +71,7 @@ sys_call_table32:
712 /*250*/ .word sys_mremap, compat_sys_sysctl, sys_getsid, sys_fdatasync, sys_nis_syscall
713 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
714 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
715 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
716 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
717 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
718 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
719 /*280*/ .word sys_tee, sys_add_key, sys_request_key, compat_sys_keyctl, compat_sys_openat
720 @@ -149,7 +149,7 @@ sys_call_table:
721 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nis_syscall
722 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
723 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
724 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
725 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
726 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
727 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
728 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
729 diff -NurpP --minimal linux-3.9.5/arch/um/Kconfig.rest linux-3.9.5-vs2.3.6.5/arch/um/Kconfig.rest
730 --- linux-3.9.5/arch/um/Kconfig.rest 2012-12-11 03:30:57.000000000 +0000
731 +++ linux-3.9.5-vs2.3.6.5/arch/um/Kconfig.rest 2013-05-31 14:47:11.000000000 +0000
732 @@ -12,6 +12,8 @@ source "arch/um/Kconfig.net"
736 +source "kernel/vserver/Kconfig"
738 source "security/Kconfig"
740 source "crypto/Kconfig"
741 diff -NurpP --minimal linux-3.9.5/arch/x86/Kconfig linux-3.9.5-vs2.3.6.5/arch/x86/Kconfig
742 --- linux-3.9.5/arch/x86/Kconfig 2013-06-11 12:22:36.000000000 +0000
743 +++ linux-3.9.5-vs2.3.6.5/arch/x86/Kconfig 2013-05-31 14:47:11.000000000 +0000
744 @@ -2341,6 +2341,8 @@ source "fs/Kconfig"
746 source "arch/x86/Kconfig.debug"
748 +source "kernel/vserver/Kconfig"
750 source "security/Kconfig"
752 source "crypto/Kconfig"
753 diff -NurpP --minimal linux-3.9.5/arch/x86/kernel/dumpstack.c linux-3.9.5-vs2.3.6.5/arch/x86/kernel/dumpstack.c
754 --- linux-3.9.5/arch/x86/kernel/dumpstack.c 2013-05-31 13:44:49.000000000 +0000
755 +++ linux-3.9.5-vs2.3.6.5/arch/x86/kernel/dumpstack.c 2013-06-12 11:03:19.000000000 +0000
756 @@ -188,8 +188,8 @@ void dump_stack(void)
759 bp = stack_frame(current, NULL);
760 - printk("Pid: %d, comm: %.20s %s %s %.*s\n",
761 - current->pid, current->comm, print_tainted(),
762 + printk("Pid: %d:#%u, comm: %.20s %s %s %.*s\n",
763 + current->pid, current->xid, current->comm, print_tainted(),
764 init_utsname()->release,
765 (int)strcspn(init_utsname()->version, " "),
766 init_utsname()->version);
767 diff -NurpP --minimal linux-3.9.5/arch/x86/kernel/process.c linux-3.9.5-vs2.3.6.5/arch/x86/kernel/process.c
768 --- linux-3.9.5/arch/x86/kernel/process.c 2013-05-31 13:44:49.000000000 +0000
769 +++ linux-3.9.5-vs2.3.6.5/arch/x86/kernel/process.c 2013-06-12 11:02:45.000000000 +0000
770 @@ -135,8 +135,8 @@ void show_regs_common(void)
771 /* Board Name is optional */
772 board = dmi_get_system_info(DMI_BOARD_NAME);
774 - printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
775 - current->pid, current->comm, print_tainted(),
776 + printk(KERN_DEFAULT "Pid: %d:#%u, comm: %.20s %s %s %.*s %s %s%s%s\n",
777 + current->pid, current->xid, current->comm, print_tainted(),
778 init_utsname()->release,
779 (int)strcspn(init_utsname()->version, " "),
780 init_utsname()->version,
781 diff -NurpP --minimal linux-3.9.5/arch/x86/syscalls/syscall_32.tbl linux-3.9.5-vs2.3.6.5/arch/x86/syscalls/syscall_32.tbl
782 --- linux-3.9.5/arch/x86/syscalls/syscall_32.tbl 2013-05-31 13:44:50.000000000 +0000
783 +++ linux-3.9.5-vs2.3.6.5/arch/x86/syscalls/syscall_32.tbl 2013-05-31 14:47:11.000000000 +0000
785 270 i386 tgkill sys_tgkill
786 271 i386 utimes sys_utimes compat_sys_utimes
787 272 i386 fadvise64_64 sys_fadvise64_64 sys32_fadvise64_64
789 +273 i386 vserver sys_vserver sys32_vserver
790 274 i386 mbind sys_mbind
791 275 i386 get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy
792 276 i386 set_mempolicy sys_set_mempolicy
793 diff -NurpP --minimal linux-3.9.5/arch/x86/syscalls/syscall_64.tbl linux-3.9.5-vs2.3.6.5/arch/x86/syscalls/syscall_64.tbl
794 --- linux-3.9.5/arch/x86/syscalls/syscall_64.tbl 2013-05-31 13:44:50.000000000 +0000
795 +++ linux-3.9.5-vs2.3.6.5/arch/x86/syscalls/syscall_64.tbl 2013-05-31 14:47:11.000000000 +0000
797 233 common epoll_ctl sys_epoll_ctl
798 234 common tgkill sys_tgkill
799 235 common utimes sys_utimes
801 +236 64 vserver sys_vserver
802 237 common mbind sys_mbind
803 238 common set_mempolicy sys_set_mempolicy
804 239 common get_mempolicy sys_get_mempolicy
805 diff -NurpP --minimal linux-3.9.5/drivers/block/Kconfig linux-3.9.5-vs2.3.6.5/drivers/block/Kconfig
806 --- linux-3.9.5/drivers/block/Kconfig 2013-05-31 13:44:51.000000000 +0000
807 +++ linux-3.9.5-vs2.3.6.5/drivers/block/Kconfig 2013-05-31 14:47:11.000000000 +0000
808 @@ -278,6 +278,13 @@ config BLK_DEV_CRYPTOLOOP
810 source "drivers/block/drbd/Kconfig"
812 +config BLK_DEV_VROOT
813 + tristate "Virtual Root device support"
814 + depends on QUOTACTL
816 + Saying Y here will allow you to use quota/fs ioctls on a shared
817 + partition within a virtual server without compromising security.
820 tristate "Network block device support"
822 diff -NurpP --minimal linux-3.9.5/drivers/block/Makefile linux-3.9.5-vs2.3.6.5/drivers/block/Makefile
823 --- linux-3.9.5/drivers/block/Makefile 2013-05-31 13:44:51.000000000 +0000
824 +++ linux-3.9.5-vs2.3.6.5/drivers/block/Makefile 2013-05-31 14:47:11.000000000 +0000
825 @@ -33,6 +33,7 @@ obj-$(CONFIG_VIRTIO_BLK) += virtio_blk.o
826 obj-$(CONFIG_VIODASD) += viodasd.o
827 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
828 obj-$(CONFIG_BLK_DEV_HD) += hd.o
829 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
831 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
832 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
833 diff -NurpP --minimal linux-3.9.5/drivers/block/loop.c linux-3.9.5-vs2.3.6.5/drivers/block/loop.c
834 --- linux-3.9.5/drivers/block/loop.c 2013-05-31 13:44:51.000000000 +0000
835 +++ linux-3.9.5-vs2.3.6.5/drivers/block/loop.c 2013-05-31 14:47:11.000000000 +0000
837 #include <linux/sysfs.h>
838 #include <linux/miscdevice.h>
839 #include <linux/falloc.h>
840 +#include <linux/vs_context.h>
842 #include <asm/uaccess.h>
844 @@ -882,6 +883,7 @@ static int loop_set_fd(struct loop_devic
845 lo->lo_blocksize = lo_blocksize;
846 lo->lo_device = bdev;
847 lo->lo_flags = lo_flags;
848 + lo->lo_xid = vx_current_xid();
849 lo->lo_backing_file = file;
850 lo->transfer = transfer_none;
852 @@ -1033,6 +1035,7 @@ static int loop_clr_fd(struct loop_devic
853 lo->lo_sizelimit = 0;
854 lo->lo_encrypt_key_size = 0;
855 lo->lo_thread = NULL;
857 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
858 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
859 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
860 @@ -1076,7 +1079,7 @@ loop_set_status(struct loop_device *lo,
862 if (lo->lo_encrypt_key_size &&
863 !uid_eq(lo->lo_key_owner, uid) &&
864 - !capable(CAP_SYS_ADMIN))
865 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
867 if (lo->lo_state != Lo_bound)
869 @@ -1166,7 +1169,8 @@ loop_get_status(struct loop_device *lo,
870 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
871 info->lo_encrypt_type =
872 lo->lo_encryption ? lo->lo_encryption->number : 0;
873 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
874 + if (lo->lo_encrypt_key_size &&
875 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
876 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
877 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
878 lo->lo_encrypt_key_size);
879 @@ -1508,6 +1512,11 @@ static int lo_open(struct block_device *
883 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P)) {
888 mutex_lock(&lo->lo_ctl_mutex);
890 mutex_unlock(&lo->lo_ctl_mutex);
891 diff -NurpP --minimal linux-3.9.5/drivers/block/vroot.c linux-3.9.5-vs2.3.6.5/drivers/block/vroot.c
892 --- linux-3.9.5/drivers/block/vroot.c 1970-01-01 00:00:00.000000000 +0000
893 +++ linux-3.9.5-vs2.3.6.5/drivers/block/vroot.c 2013-05-31 14:47:11.000000000 +0000
896 + * linux/drivers/block/vroot.c
898 + * written by Herbert Pötzl, 9/11/2002
899 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
901 + * based on the loop.c code by Theodore Ts'o.
903 + * Copyright (C) 2002-2007 by Herbert Pötzl.
904 + * Redistribution of this file is permitted under the
905 + * GNU General Public License.
909 +#include <linux/module.h>
910 +#include <linux/moduleparam.h>
911 +#include <linux/file.h>
912 +#include <linux/major.h>
913 +#include <linux/blkdev.h>
914 +#include <linux/slab.h>
916 +#include <linux/vroot.h>
917 +#include <linux/vs_context.h>
920 +static int max_vroot = 8;
922 +static struct vroot_device *vroot_dev;
923 +static struct gendisk **disks;
926 +static int vroot_set_dev(
927 + struct vroot_device *vr,
928 + struct block_device *bdev,
931 + struct block_device *real_bdev;
933 + struct inode *inode;
937 + if (vr->vr_state != Vr_unbound)
946 + inode = file->f_dentry->d_inode;
949 + if (S_ISBLK(inode->i_mode)) {
950 + real_bdev = inode->i_bdev;
951 + vr->vr_device = real_bdev;
952 + __iget(real_bdev->bd_inode);
956 + vxdprintk(VXD_CBIT(misc, 0),
957 + "vroot[%d]_set_dev: dev=" VXF_DEV,
958 + vr->vr_number, VXD_DEV(real_bdev));
960 + vr->vr_state = Vr_bound;
969 +static int vroot_clr_dev(
970 + struct vroot_device *vr,
971 + struct block_device *bdev)
973 + struct block_device *real_bdev;
975 + if (vr->vr_state != Vr_bound)
977 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
980 + real_bdev = vr->vr_device;
982 + vxdprintk(VXD_CBIT(misc, 0),
983 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
984 + vr->vr_number, VXD_DEV(real_bdev));
987 + vr->vr_state = Vr_unbound;
988 + vr->vr_device = NULL;
993 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
994 + unsigned int cmd, unsigned long arg)
996 + struct vroot_device *vr = bdev->bd_disk->private_data;
999 + down(&vr->vr_ctl_mutex);
1001 + case VROOT_SET_DEV:
1002 + err = vroot_set_dev(vr, bdev, arg);
1004 + case VROOT_CLR_DEV:
1005 + err = vroot_clr_dev(vr, bdev);
1011 + up(&vr->vr_ctl_mutex);
1015 +static int vr_open(struct block_device *bdev, fmode_t mode)
1017 + struct vroot_device *vr = bdev->bd_disk->private_data;
1019 + down(&vr->vr_ctl_mutex);
1021 + up(&vr->vr_ctl_mutex);
1025 +static int vr_release(struct gendisk *disk, fmode_t mode)
1027 + struct vroot_device *vr = disk->private_data;
1029 + down(&vr->vr_ctl_mutex);
1031 + up(&vr->vr_ctl_mutex);
1035 +static struct block_device_operations vr_fops = {
1036 + .owner = THIS_MODULE,
1038 + .release = vr_release,
1039 + .ioctl = vr_ioctl,
1042 +static void vroot_make_request(struct request_queue *q, struct bio *bio)
1044 + printk("vroot_make_request %p, %p\n", q, bio);
1045 + bio_io_error(bio);
1048 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1050 + struct inode *inode = bdev->bd_inode;
1051 + struct vroot_device *vr;
1052 + struct block_device *real_bdev;
1053 + int minor = iminor(inode);
1055 + vr = &vroot_dev[minor];
1056 + real_bdev = vr->vr_device;
1058 + vxdprintk(VXD_CBIT(misc, 0),
1059 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1060 + vr->vr_number, VXD_DEV(real_bdev));
1062 + if (vr->vr_state != Vr_bound)
1063 + return ERR_PTR(-ENXIO);
1065 + __iget(real_bdev->bd_inode);
1072 + * And now the modules code and kernel interface.
1075 +module_param(max_vroot, int, 0);
1077 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1078 +MODULE_LICENSE("GPL");
1079 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1081 +MODULE_AUTHOR ("Herbert Pötzl");
1082 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1085 +int __init vroot_init(void)
1089 + if (max_vroot < 1 || max_vroot > 256) {
1090 + max_vroot = MAX_VROOT_DEFAULT;
1091 + printk(KERN_WARNING "vroot: invalid max_vroot "
1092 + "(must be between 1 and 256), "
1093 + "using default (%d)\n", max_vroot);
1096 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1100 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1103 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1105 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1109 + for (i = 0; i < max_vroot; i++) {
1110 + disks[i] = alloc_disk(1);
1113 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1114 + if (!disks[i]->queue)
1116 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1119 + for (i = 0; i < max_vroot; i++) {
1120 + struct vroot_device *vr = &vroot_dev[i];
1121 + struct gendisk *disk = disks[i];
1123 + memset(vr, 0, sizeof(*vr));
1124 + sema_init(&vr->vr_ctl_mutex, 1);
1125 + vr->vr_number = i;
1126 + disk->major = VROOT_MAJOR;
1127 + disk->first_minor = i;
1128 + disk->fops = &vr_fops;
1129 + sprintf(disk->disk_name, "vroot%d", i);
1130 + disk->private_data = vr;
1133 + err = register_vroot_grb(&__vroot_get_real_bdev);
1137 + for (i = 0; i < max_vroot; i++)
1138 + add_disk(disks[i]);
1139 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1144 + put_disk(disks[i]);
1149 + unregister_blkdev(VROOT_MAJOR, "vroot");
1150 + printk(KERN_ERR "vroot: ran out of memory\n");
1154 +void vroot_exit(void)
1158 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1159 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1161 + for (i = 0; i < max_vroot; i++) {
1162 + del_gendisk(disks[i]);
1163 + put_disk(disks[i]);
1165 + unregister_blkdev(VROOT_MAJOR, "vroot");
1171 +module_init(vroot_init);
1172 +module_exit(vroot_exit);
1176 +static int __init max_vroot_setup(char *str)
1178 + max_vroot = simple_strtol(str, NULL, 0);
1182 +__setup("max_vroot=", max_vroot_setup);
1186 diff -NurpP --minimal linux-3.9.5/drivers/infiniband/Kconfig linux-3.9.5-vs2.3.6.5/drivers/infiniband/Kconfig
1187 --- linux-3.9.5/drivers/infiniband/Kconfig 2012-12-11 03:30:57.000000000 +0000
1188 +++ linux-3.9.5-vs2.3.6.5/drivers/infiniband/Kconfig 2013-05-31 14:47:11.000000000 +0000
1189 @@ -39,7 +39,7 @@ config INFINIBAND_USER_MEM
1190 config INFINIBAND_ADDR_TRANS
1193 - depends on !(INFINIBAND = y && IPV6 = m)
1194 + depends on !(INFINIBAND = y && IPV6 = y)
1197 source "drivers/infiniband/hw/mthca/Kconfig"
1198 diff -NurpP --minimal linux-3.9.5/drivers/infiniband/core/addr.c linux-3.9.5-vs2.3.6.5/drivers/infiniband/core/addr.c
1199 --- linux-3.9.5/drivers/infiniband/core/addr.c 2012-12-11 03:30:57.000000000 +0000
1200 +++ linux-3.9.5-vs2.3.6.5/drivers/infiniband/core/addr.c 2013-05-31 14:47:11.000000000 +0000
1201 @@ -261,7 +261,7 @@ static int addr6_resolve(struct sockaddr
1203 if (ipv6_addr_any(&fl6.saddr)) {
1204 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1205 - &fl6.daddr, 0, &fl6.saddr);
1206 + &fl6.daddr, 0, &fl6.saddr, NULL);
1210 diff -NurpP --minimal linux-3.9.5/drivers/md/dm-ioctl.c linux-3.9.5-vs2.3.6.5/drivers/md/dm-ioctl.c
1211 --- linux-3.9.5/drivers/md/dm-ioctl.c 2013-05-31 13:44:59.000000000 +0000
1212 +++ linux-3.9.5-vs2.3.6.5/drivers/md/dm-ioctl.c 2013-05-31 14:47:11.000000000 +0000
1214 #include <linux/dm-ioctl.h>
1215 #include <linux/hdreg.h>
1216 #include <linux/compat.h>
1217 +#include <linux/vs_context.h>
1219 #include <asm/uaccess.h>
1221 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1222 unsigned int h = hash_str(str);
1224 list_for_each_entry (hc, _name_buckets + h, name_list)
1225 - if (!strcmp(hc->name, str)) {
1226 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1227 + !strcmp(hc->name, str)) {
1231 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1232 unsigned int h = hash_str(str);
1234 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1235 - if (!strcmp(hc->uuid, str)) {
1236 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1237 + !strcmp(hc->uuid, str)) {
1241 @@ -131,13 +134,15 @@ static struct hash_cell *__get_uuid_cell
1242 static struct hash_cell *__get_dev_cell(uint64_t dev)
1244 struct mapped_device *md;
1245 - struct hash_cell *hc;
1246 + struct hash_cell *hc = NULL;
1248 md = dm_get_md(huge_decode_dev(dev));
1252 - hc = dm_get_mdptr(md);
1253 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1254 + hc = dm_get_mdptr(md);
1259 @@ -445,6 +450,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1261 static int remove_all(struct dm_ioctl *param, size_t param_size)
1263 + if (!vx_check(0, VS_ADMIN))
1266 dm_hash_remove_all(1);
1267 param->data_size = 0;
1269 @@ -492,6 +500,8 @@ static int list_devices(struct dm_ioctl
1271 for (i = 0; i < NUM_BUCKETS; i++) {
1272 list_for_each_entry (hc, _name_buckets + i, name_list) {
1273 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1275 needed += sizeof(struct dm_name_list);
1276 needed += strlen(hc->name) + 1;
1277 needed += ALIGN_MASK;
1278 @@ -515,6 +525,8 @@ static int list_devices(struct dm_ioctl
1280 for (i = 0; i < NUM_BUCKETS; i++) {
1281 list_for_each_entry (hc, _name_buckets + i, name_list) {
1282 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1285 old_nl->next = (uint32_t) ((void *) nl -
1287 @@ -1722,8 +1734,8 @@ static int ctl_ioctl(uint command, struc
1288 size_t input_param_size;
1289 struct dm_ioctl param_kernel;
1291 - /* only root can play with this */
1292 - if (!capable(CAP_SYS_ADMIN))
1293 + /* only root and certain contexts can play with this */
1294 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1297 if (_IOC_TYPE(command) != DM_IOCTL)
1298 diff -NurpP --minimal linux-3.9.5/drivers/md/dm.c linux-3.9.5-vs2.3.6.5/drivers/md/dm.c
1299 --- linux-3.9.5/drivers/md/dm.c 2013-05-31 13:44:59.000000000 +0000
1300 +++ linux-3.9.5-vs2.3.6.5/drivers/md/dm.c 2013-06-12 23:49:08.000000000 +0000
1302 #include <linux/idr.h>
1303 #include <linux/hdreg.h>
1304 #include <linux/delay.h>
1305 +#include <linux/vs_base.h>
1307 #include <trace/events/block.h>
1309 @@ -125,6 +126,7 @@ struct mapped_device {
1312 atomic_t open_count;
1315 unsigned long flags;
1317 @@ -317,6 +319,7 @@ int dm_deleting_md(struct mapped_device
1318 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1320 struct mapped_device *md;
1323 spin_lock(&_minor_lock);
1325 @@ -325,18 +328,19 @@ static int dm_blk_open(struct block_devi
1328 if (test_bit(DMF_FREEING, &md->flags) ||
1329 - dm_deleting_md(md)) {
1331 + dm_deleting_md(md))
1335 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1340 atomic_inc(&md->open_count);
1344 spin_unlock(&_minor_lock);
1346 - return md ? 0 : -ENXIO;
1350 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1351 @@ -547,6 +551,14 @@ int dm_set_geometry(struct mapped_device
1356 + * Get the xid associated with a dm device
1358 +vxid_t dm_get_xid(struct mapped_device *md)
1363 /*-----------------------------------------------------------------
1365 * A more elegant soln is in the works that uses the queue
1366 @@ -1884,6 +1896,7 @@ static struct mapped_device *alloc_dev(i
1367 INIT_LIST_HEAD(&md->uevent_list);
1368 spin_lock_init(&md->uevent_lock);
1370 + md->xid = vx_current_xid();
1371 md->queue = blk_alloc_queue(GFP_KERNEL);
1374 diff -NurpP --minimal linux-3.9.5/drivers/md/dm.h linux-3.9.5-vs2.3.6.5/drivers/md/dm.h
1375 --- linux-3.9.5/drivers/md/dm.h 2013-02-19 13:57:51.000000000 +0000
1376 +++ linux-3.9.5-vs2.3.6.5/drivers/md/dm.h 2013-06-12 23:49:08.000000000 +0000
1377 @@ -46,6 +46,8 @@ struct dm_dev_internal {
1379 struct dm_md_mempools;
1381 +vxid_t dm_get_xid(struct mapped_device *md);
1383 /*-----------------------------------------------------------------
1384 * Internal table functions.
1385 *---------------------------------------------------------------*/
1386 diff -NurpP --minimal linux-3.9.5/drivers/net/tun.c linux-3.9.5-vs2.3.6.5/drivers/net/tun.c
1387 --- linux-3.9.5/drivers/net/tun.c 2013-06-11 12:22:38.000000000 +0000
1388 +++ linux-3.9.5-vs2.3.6.5/drivers/net/tun.c 2013-06-12 23:49:08.000000000 +0000
1390 #include <linux/nsproxy.h>
1391 #include <linux/virtio_net.h>
1392 #include <linux/rcupdate.h>
1393 +#include <linux/vs_network.h>
1394 #include <net/net_namespace.h>
1395 #include <net/netns/generic.h>
1396 #include <net/rtnetlink.h>
1397 @@ -164,6 +165,7 @@ struct tun_struct {
1403 struct net_device *dev;
1404 netdev_features_t set_features;
1405 @@ -380,6 +382,7 @@ static inline bool tun_not_capable(struc
1406 return ((uid_valid(tun->owner) && !uid_eq(cred->euid, tun->owner)) ||
1407 (gid_valid(tun->group) && !in_egroup_p(tun->group))) &&
1408 !ns_capable(net->user_ns, CAP_NET_ADMIN);
1409 + /* !cap_raised(current_cap(), CAP_NET_ADMIN) */
1412 static void tun_set_real_num_queues(struct tun_struct *tun)
1413 @@ -1404,6 +1407,7 @@ static void tun_setup(struct net_device
1415 tun->owner = INVALID_UID;
1416 tun->group = INVALID_GID;
1417 + tun->nid = nx_current_nid();
1419 dev->ethtool_ops = &tun_ethtool_ops;
1420 dev->destructor = tun_free_netdev;
1421 @@ -1591,6 +1595,9 @@ static int tun_set_iff(struct net *net,
1425 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1428 err = tun_attach(tun, file);
1431 @@ -1605,7 +1612,7 @@ static int tun_set_iff(struct net *net,
1432 int queues = ifr->ifr_flags & IFF_MULTI_QUEUE ?
1435 - if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
1436 + if (!vx_ns_capable(net->user_ns, CAP_NET_ADMIN, NXC_TUN_CREATE))
1438 err = security_tun_dev_create();
1440 @@ -1950,6 +1957,16 @@ static long __tun_chr_ioctl(struct file
1441 from_kgid(&init_user_ns, tun->group));
1445 + if (!capable(CAP_CONTEXT))
1448 + /* Set nid owner of the device */
1449 + tun->nid = (vnid_t) arg;
1451 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1455 /* Only allow setting the type when the interface is down */
1456 if (tun->dev->flags & IFF_UP) {
1457 diff -NurpP --minimal linux-3.9.5/drivers/tty/sysrq.c linux-3.9.5-vs2.3.6.5/drivers/tty/sysrq.c
1458 --- linux-3.9.5/drivers/tty/sysrq.c 2013-05-31 13:45:19.000000000 +0000
1459 +++ linux-3.9.5-vs2.3.6.5/drivers/tty/sysrq.c 2013-05-31 15:08:19.000000000 +0000
1461 #include <linux/input.h>
1462 #include <linux/uaccess.h>
1463 #include <linux/moduleparam.h>
1464 +#include <linux/vserver/debug.h>
1466 #include <asm/ptrace.h>
1467 #include <asm/irq_regs.h>
1468 @@ -401,6 +402,21 @@ static struct sysrq_key_op sysrq_unrt_op
1469 .enable_mask = SYSRQ_ENABLE_RTNICE,
1473 +#ifdef CONFIG_VSERVER_DEBUG
1474 +static void sysrq_handle_vxinfo(int key)
1476 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1479 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1480 + .handler = sysrq_handle_vxinfo,
1481 + .help_msg = "conteXt",
1482 + .action_msg = "Show Context Info",
1483 + .enable_mask = SYSRQ_ENABLE_DUMP,
1487 /* Key Operations table and lock */
1488 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1490 @@ -456,7 +472,11 @@ static struct sysrq_key_op *sysrq_key_ta
1491 &sysrq_showstate_blocked_op, /* w */
1492 /* x: May be registered on ppc/powerpc for xmon */
1493 /* x: May be registered on sparc64 for global PMU dump */
1494 +#ifdef CONFIG_VSERVER_DEBUG
1495 + &sysrq_showvxinfo_op, /* x */
1499 /* y: May be registered on sparc64 for global register dump */
1501 &sysrq_ftrace_dump_op, /* z */
1502 @@ -471,6 +491,8 @@ static int sysrq_key_table_key2index(int
1504 else if ((key >= 'a') && (key <= 'z'))
1505 retval = key + 10 - 'a';
1506 + else if ((key >= 'A') && (key <= 'Z'))
1507 + retval = key + 10 - 'A';
1511 diff -NurpP --minimal linux-3.9.5/drivers/tty/tty_io.c linux-3.9.5-vs2.3.6.5/drivers/tty/tty_io.c
1512 --- linux-3.9.5/drivers/tty/tty_io.c 2013-06-11 12:22:39.000000000 +0000
1513 +++ linux-3.9.5-vs2.3.6.5/drivers/tty/tty_io.c 2013-05-31 14:47:11.000000000 +0000
1516 #include <linux/kmod.h>
1517 #include <linux/nsproxy.h>
1518 +#include <linux/vs_pid.h>
1520 #undef TTY_DEBUG_HANGUP
1522 @@ -2144,7 +2145,8 @@ static int tiocsti(struct tty_struct *tt
1524 struct tty_ldisc *ld;
1526 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1527 + if (((current->signal->tty != tty) &&
1528 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1530 if (get_user(ch, p))
1532 @@ -2432,6 +2434,7 @@ static int tiocspgrp(struct tty_struct *
1534 if (get_user(pgrp_nr, p))
1536 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1540 diff -NurpP --minimal linux-3.9.5/fs/attr.c linux-3.9.5-vs2.3.6.5/fs/attr.c
1541 --- linux-3.9.5/fs/attr.c 2013-02-19 13:58:46.000000000 +0000
1542 +++ linux-3.9.5-vs2.3.6.5/fs/attr.c 2013-05-31 14:47:11.000000000 +0000
1544 #include <linux/security.h>
1545 #include <linux/evm.h>
1546 #include <linux/ima.h>
1547 +#include <linux/proc_fs.h>
1548 +#include <linux/devpts_fs.h>
1549 +#include <linux/vs_tag.h>
1552 * inode_change_ok - check if attribute changes to an inode are allowed
1553 @@ -77,6 +80,10 @@ int inode_change_ok(const struct inode *
1557 + /* check for inode tag permission */
1558 + if (dx_permission(inode, MAY_WRITE))
1563 EXPORT_SYMBOL(inode_change_ok);
1564 @@ -147,6 +154,8 @@ void setattr_copy(struct inode *inode, c
1565 inode->i_uid = attr->ia_uid;
1566 if (ia_valid & ATTR_GID)
1567 inode->i_gid = attr->ia_gid;
1568 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1569 + inode->i_tag = attr->ia_tag;
1570 if (ia_valid & ATTR_ATIME)
1571 inode->i_atime = timespec_trunc(attr->ia_atime,
1572 inode->i_sb->s_time_gran);
1573 @@ -177,7 +186,8 @@ int notify_change(struct dentry * dentry
1575 WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
1577 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1578 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1579 + ATTR_TAG | ATTR_TIMES_SET)) {
1580 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1583 diff -NurpP --minimal linux-3.9.5/fs/block_dev.c linux-3.9.5-vs2.3.6.5/fs/block_dev.c
1584 --- linux-3.9.5/fs/block_dev.c 2013-05-31 13:45:22.000000000 +0000
1585 +++ linux-3.9.5-vs2.3.6.5/fs/block_dev.c 2013-05-31 14:47:11.000000000 +0000
1587 #include <linux/namei.h>
1588 #include <linux/log2.h>
1589 #include <linux/cleancache.h>
1590 +#include <linux/vs_device.h>
1591 #include <asm/uaccess.h>
1592 #include "internal.h"
1594 @@ -528,6 +529,7 @@ struct block_device *bdget(dev_t dev)
1595 bdev->bd_invalidated = 0;
1596 inode->i_mode = S_IFBLK;
1597 inode->i_rdev = dev;
1598 + inode->i_mdev = dev;
1599 inode->i_bdev = bdev;
1600 inode->i_data.a_ops = &def_blk_aops;
1601 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1602 @@ -575,6 +577,11 @@ EXPORT_SYMBOL(bdput);
1603 static struct block_device *bd_acquire(struct inode *inode)
1605 struct block_device *bdev;
1608 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1610 + inode->i_mdev = mdev;
1612 spin_lock(&bdev_lock);
1613 bdev = inode->i_bdev;
1614 @@ -585,7 +592,7 @@ static struct block_device *bd_acquire(s
1616 spin_unlock(&bdev_lock);
1618 - bdev = bdget(inode->i_rdev);
1619 + bdev = bdget(mdev);
1621 spin_lock(&bdev_lock);
1622 if (!inode->i_bdev) {
1623 diff -NurpP --minimal linux-3.9.5/fs/btrfs/ctree.h linux-3.9.5-vs2.3.6.5/fs/btrfs/ctree.h
1624 --- linux-3.9.5/fs/btrfs/ctree.h 2013-05-31 13:45:22.000000000 +0000
1625 +++ linux-3.9.5-vs2.3.6.5/fs/btrfs/ctree.h 2013-05-31 14:47:11.000000000 +0000
1626 @@ -705,11 +705,14 @@ struct btrfs_inode_item {
1627 /* modification sequence number for NFS */
1632 * a little future expansion, for more than this we can
1633 * just grow the inode item and version it
1635 - __le64 reserved[4];
1636 + __le16 reserved16;
1637 + __le32 reserved32;
1638 + __le64 reserved[3];
1639 struct btrfs_timespec atime;
1640 struct btrfs_timespec ctime;
1641 struct btrfs_timespec mtime;
1642 @@ -1901,6 +1904,8 @@ struct btrfs_ioctl_defrag_range_args {
1643 #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
1644 #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22)
1646 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1648 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1649 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1650 #define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt)
1651 @@ -2170,6 +2175,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1652 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1653 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1654 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1655 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1656 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1657 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1658 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1659 @@ -2223,6 +2229,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1661 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1663 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1664 +#define BTRFS_INODE_BARRIER (1 << 25)
1665 +#define BTRFS_INODE_COW (1 << 26)
1668 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1670 @@ -3581,6 +3591,7 @@ extern const struct dentry_operations bt
1671 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1672 void btrfs_update_iflags(struct inode *inode);
1673 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1674 +int btrfs_sync_flags(struct inode *inode, int, int);
1675 int btrfs_defrag_file(struct inode *inode, struct file *file,
1676 struct btrfs_ioctl_defrag_range_args *range,
1677 u64 newer_than, unsigned long max_pages);
1678 diff -NurpP --minimal linux-3.9.5/fs/btrfs/disk-io.c linux-3.9.5-vs2.3.6.5/fs/btrfs/disk-io.c
1679 --- linux-3.9.5/fs/btrfs/disk-io.c 2013-05-31 13:45:22.000000000 +0000
1680 +++ linux-3.9.5-vs2.3.6.5/fs/btrfs/disk-io.c 2013-05-31 14:47:11.000000000 +0000
1681 @@ -2258,6 +2258,9 @@ int open_ctree(struct super_block *sb,
1685 + if (btrfs_test_opt(tree_root, TAGGED))
1686 + sb->s_flags |= MS_TAGGED;
1688 features = btrfs_super_incompat_flags(disk_super) &
1689 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1691 diff -NurpP --minimal linux-3.9.5/fs/btrfs/inode.c linux-3.9.5-vs2.3.6.5/fs/btrfs/inode.c
1692 --- linux-3.9.5/fs/btrfs/inode.c 2013-06-11 12:22:39.000000000 +0000
1693 +++ linux-3.9.5-vs2.3.6.5/fs/btrfs/inode.c 2013-06-03 19:37:03.000000000 +0000
1695 #include <linux/mount.h>
1696 #include <linux/btrfs.h>
1697 #include <linux/blkdev.h>
1698 +#include <linux/vs_tag.h>
1701 #include "disk-io.h"
1702 @@ -3312,6 +3313,9 @@ static void btrfs_read_locked_inode(stru
1703 struct btrfs_key location;
1710 bool filled = false;
1712 @@ -3339,8 +3343,14 @@ static void btrfs_read_locked_inode(stru
1713 struct btrfs_inode_item);
1714 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1715 set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
1716 - i_uid_write(inode, btrfs_inode_uid(leaf, inode_item));
1717 - i_gid_write(inode, btrfs_inode_gid(leaf, inode_item));
1719 + kuid = make_kuid(&init_user_ns, btrfs_inode_uid(leaf, inode_item));
1720 + kgid = make_kgid(&init_user_ns, btrfs_inode_gid(leaf, inode_item));
1721 + ktag = make_ktag(&init_user_ns, btrfs_inode_tag(leaf, inode_item));
1723 + inode->i_uid = INOTAG_KUID(DX_TAG(inode), kuid, kgid);
1724 + inode->i_gid = INOTAG_KGID(DX_TAG(inode), kuid, kgid);
1725 + inode->i_tag = INOTAG_KTAG(DX_TAG(inode), kuid, kgid, ktag);
1726 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1728 tspec = btrfs_inode_atime(inode_item);
1729 @@ -3431,11 +3441,18 @@ static void fill_inode_item(struct btrfs
1730 struct inode *inode)
1732 struct btrfs_map_token token;
1733 + uid_t uid = from_kuid(&init_user_ns,
1734 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
1735 + gid_t gid = from_kgid(&init_user_ns,
1736 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
1738 btrfs_init_map_token(&token);
1740 - btrfs_set_token_inode_uid(leaf, item, i_uid_read(inode), &token);
1741 - btrfs_set_token_inode_gid(leaf, item, i_gid_read(inode), &token);
1742 + btrfs_set_token_inode_uid(leaf, item, uid, &token);
1743 + btrfs_set_token_inode_gid(leaf, item, gid, &token);
1744 +#ifdef CONFIG_TAGGING_INTERN
1745 + btrfs_set_token_inode_tag(leaf, item, i_tag_read(inode), &token);
1747 btrfs_set_token_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size,
1749 btrfs_set_token_inode_mode(leaf, item, inode->i_mode, &token);
1750 @@ -8683,11 +8700,13 @@ static const struct inode_operations btr
1751 .listxattr = btrfs_listxattr,
1752 .removexattr = btrfs_removexattr,
1753 .permission = btrfs_permission,
1754 + .sync_flags = btrfs_sync_flags,
1755 .get_acl = btrfs_get_acl,
1757 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1758 .lookup = btrfs_lookup,
1759 .permission = btrfs_permission,
1760 + .sync_flags = btrfs_sync_flags,
1761 .get_acl = btrfs_get_acl,
1764 diff -NurpP --minimal linux-3.9.5/fs/btrfs/ioctl.c linux-3.9.5-vs2.3.6.5/fs/btrfs/ioctl.c
1765 --- linux-3.9.5/fs/btrfs/ioctl.c 2013-06-11 12:22:39.000000000 +0000
1766 +++ linux-3.9.5-vs2.3.6.5/fs/btrfs/ioctl.c 2013-05-31 14:47:11.000000000 +0000
1767 @@ -75,10 +75,13 @@ static unsigned int btrfs_flags_to_ioctl
1769 unsigned int iflags = 0;
1771 - if (flags & BTRFS_INODE_SYNC)
1772 - iflags |= FS_SYNC_FL;
1773 if (flags & BTRFS_INODE_IMMUTABLE)
1774 iflags |= FS_IMMUTABLE_FL;
1775 + if (flags & BTRFS_INODE_IXUNLINK)
1776 + iflags |= FS_IXUNLINK_FL;
1778 + if (flags & BTRFS_INODE_SYNC)
1779 + iflags |= FS_SYNC_FL;
1780 if (flags & BTRFS_INODE_APPEND)
1781 iflags |= FS_APPEND_FL;
1782 if (flags & BTRFS_INODE_NODUMP)
1783 @@ -95,28 +98,78 @@ static unsigned int btrfs_flags_to_ioctl
1784 else if (flags & BTRFS_INODE_NOCOMPRESS)
1785 iflags |= FS_NOCOMP_FL;
1787 + if (flags & BTRFS_INODE_BARRIER)
1788 + iflags |= FS_BARRIER_FL;
1789 + if (flags & BTRFS_INODE_COW)
1790 + iflags |= FS_COW_FL;
1795 - * Update inode->i_flags based on the btrfs internal flags.
1796 + * Update inode->i_(v)flags based on the btrfs internal flags.
1798 void btrfs_update_iflags(struct inode *inode)
1800 struct btrfs_inode *ip = BTRFS_I(inode);
1802 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
1803 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
1804 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
1806 - if (ip->flags & BTRFS_INODE_SYNC)
1807 - inode->i_flags |= S_SYNC;
1808 if (ip->flags & BTRFS_INODE_IMMUTABLE)
1809 inode->i_flags |= S_IMMUTABLE;
1810 + if (ip->flags & BTRFS_INODE_IXUNLINK)
1811 + inode->i_flags |= S_IXUNLINK;
1813 + if (ip->flags & BTRFS_INODE_SYNC)
1814 + inode->i_flags |= S_SYNC;
1815 if (ip->flags & BTRFS_INODE_APPEND)
1816 inode->i_flags |= S_APPEND;
1817 if (ip->flags & BTRFS_INODE_NOATIME)
1818 inode->i_flags |= S_NOATIME;
1819 if (ip->flags & BTRFS_INODE_DIRSYNC)
1820 inode->i_flags |= S_DIRSYNC;
1822 + inode->i_vflags &= ~(V_BARRIER | V_COW);
1824 + if (ip->flags & BTRFS_INODE_BARRIER)
1825 + inode->i_vflags |= V_BARRIER;
1826 + if (ip->flags & BTRFS_INODE_COW)
1827 + inode->i_vflags |= V_COW;
1831 + * Update btrfs internal flags from inode->i_(v)flags.
1833 +void btrfs_update_flags(struct inode *inode)
1835 + struct btrfs_inode *ip = BTRFS_I(inode);
1837 + unsigned int flags = inode->i_flags;
1838 + unsigned int vflags = inode->i_vflags;
1840 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
1841 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
1842 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
1843 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
1845 + if (flags & S_IMMUTABLE)
1846 + ip->flags |= BTRFS_INODE_IMMUTABLE;
1847 + if (flags & S_IXUNLINK)
1848 + ip->flags |= BTRFS_INODE_IXUNLINK;
1850 + if (flags & S_SYNC)
1851 + ip->flags |= BTRFS_INODE_SYNC;
1852 + if (flags & S_APPEND)
1853 + ip->flags |= BTRFS_INODE_APPEND;
1854 + if (flags & S_NOATIME)
1855 + ip->flags |= BTRFS_INODE_NOATIME;
1856 + if (flags & S_DIRSYNC)
1857 + ip->flags |= BTRFS_INODE_DIRSYNC;
1859 + if (vflags & V_BARRIER)
1860 + ip->flags |= BTRFS_INODE_BARRIER;
1861 + if (vflags & V_COW)
1862 + ip->flags |= BTRFS_INODE_COW;
1866 @@ -132,6 +185,7 @@ void btrfs_inherit_iflags(struct inode *
1869 flags = BTRFS_I(dir)->flags;
1870 + flags &= ~BTRFS_INODE_BARRIER;
1872 if (flags & BTRFS_INODE_NOCOMPRESS) {
1873 BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
1874 @@ -150,6 +204,30 @@ void btrfs_inherit_iflags(struct inode *
1875 btrfs_update_iflags(inode);
1878 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
1880 + struct btrfs_inode *ip = BTRFS_I(inode);
1881 + struct btrfs_root *root = ip->root;
1882 + struct btrfs_trans_handle *trans;
1885 + trans = btrfs_join_transaction(root);
1888 + inode->i_flags = flags;
1889 + inode->i_vflags = vflags;
1890 + btrfs_update_flags(inode);
1892 + ret = btrfs_update_inode(trans, root, inode);
1895 + btrfs_update_iflags(inode);
1896 + inode->i_ctime = CURRENT_TIME;
1897 + btrfs_end_transaction(trans, root);
1902 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
1904 struct btrfs_inode *ip = BTRFS_I(file_inode(file));
1905 @@ -212,21 +290,27 @@ static int btrfs_ioctl_setflags(struct f
1907 flags = btrfs_mask_flags(inode->i_mode, flags);
1908 oldflags = btrfs_flags_to_ioctl(ip->flags);
1909 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
1910 + if ((flags ^ oldflags) & (FS_APPEND_FL |
1911 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
1912 if (!capable(CAP_LINUX_IMMUTABLE)) {
1918 - if (flags & FS_SYNC_FL)
1919 - ip->flags |= BTRFS_INODE_SYNC;
1921 - ip->flags &= ~BTRFS_INODE_SYNC;
1922 if (flags & FS_IMMUTABLE_FL)
1923 ip->flags |= BTRFS_INODE_IMMUTABLE;
1925 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
1926 + if (flags & FS_IXUNLINK_FL)
1927 + ip->flags |= BTRFS_INODE_IXUNLINK;
1929 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
1931 + if (flags & FS_SYNC_FL)
1932 + ip->flags |= BTRFS_INODE_SYNC;
1934 + ip->flags &= ~BTRFS_INODE_SYNC;
1935 if (flags & FS_APPEND_FL)
1936 ip->flags |= BTRFS_INODE_APPEND;
1938 diff -NurpP --minimal linux-3.9.5/fs/btrfs/super.c linux-3.9.5-vs2.3.6.5/fs/btrfs/super.c
1939 --- linux-3.9.5/fs/btrfs/super.c 2013-05-31 13:45:22.000000000 +0000
1940 +++ linux-3.9.5-vs2.3.6.5/fs/btrfs/super.c 2013-05-31 14:47:11.000000000 +0000
1941 @@ -321,7 +321,7 @@ enum {
1942 Opt_no_space_cache, Opt_recovery, Opt_skip_balance,
1943 Opt_check_integrity, Opt_check_integrity_including_extent_data,
1944 Opt_check_integrity_print_mask, Opt_fatal_errors,
1946 + Opt_tag, Opt_notag, Opt_tagid, Opt_err,
1949 static match_table_t tokens = {
1950 @@ -361,6 +361,9 @@ static match_table_t tokens = {
1951 {Opt_check_integrity_including_extent_data, "check_int_data"},
1952 {Opt_check_integrity_print_mask, "check_int_print_mask=%d"},
1953 {Opt_fatal_errors, "fatal_errors=%s"},
1955 + {Opt_notag, "notag"},
1956 + {Opt_tagid, "tagid=%u"},
1960 @@ -626,6 +629,22 @@ int btrfs_parse_options(struct btrfs_roo
1964 +#ifndef CONFIG_TAGGING_NONE
1966 + printk(KERN_INFO "btrfs: use tagging\n");
1967 + btrfs_set_opt(info->mount_opt, TAGGED);
1970 + printk(KERN_INFO "btrfs: disabled tagging\n");
1971 + btrfs_clear_opt(info->mount_opt, TAGGED);
1974 +#ifdef CONFIG_PROPAGATE
1977 + btrfs_set_opt(info->mount_opt, TAGGED);
1981 printk(KERN_INFO "btrfs: unrecognized mount option "
1983 @@ -1258,6 +1277,12 @@ static int btrfs_remount(struct super_bl
1984 btrfs_resize_thread_pool(fs_info,
1985 fs_info->thread_pool_size, old_thread_pool_size);
1987 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
1988 + printk("btrfs: %s: tagging not permitted on remount.\n",
1993 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
1996 diff -NurpP --minimal linux-3.9.5/fs/char_dev.c linux-3.9.5-vs2.3.6.5/fs/char_dev.c
1997 --- linux-3.9.5/fs/char_dev.c 2012-12-11 03:30:57.000000000 +0000
1998 +++ linux-3.9.5-vs2.3.6.5/fs/char_dev.c 2013-05-31 14:47:11.000000000 +0000
2000 #include <linux/mutex.h>
2001 #include <linux/backing-dev.h>
2002 #include <linux/tty.h>
2003 +#include <linux/vs_context.h>
2004 +#include <linux/vs_device.h>
2006 #include "internal.h"
2008 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2010 struct cdev *new = NULL;
2014 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2016 + inode->i_mdev = mdev;
2018 spin_lock(&cdev_lock);
2021 struct kobject *kobj;
2024 spin_unlock(&cdev_lock);
2025 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2027 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2030 new = container_of(kobj, struct cdev, kobj);
2031 diff -NurpP --minimal linux-3.9.5/fs/dcache.c linux-3.9.5-vs2.3.6.5/fs/dcache.c
2032 --- linux-3.9.5/fs/dcache.c 2013-06-11 12:22:39.000000000 +0000
2033 +++ linux-3.9.5-vs2.3.6.5/fs/dcache.c 2013-05-31 14:47:11.000000000 +0000
2035 #include <linux/rculist_bl.h>
2036 #include <linux/prefetch.h>
2037 #include <linux/ratelimit.h>
2038 +#include <linux/vs_limit.h>
2039 #include "internal.h"
2042 @@ -593,6 +594,8 @@ int d_invalidate(struct dentry * dentry)
2043 spin_lock(&dentry->d_lock);
2046 + vx_dentry_dec(dentry);
2049 * Somebody else still using it?
2051 @@ -622,6 +625,7 @@ EXPORT_SYMBOL(d_invalidate);
2052 static inline void __dget_dlock(struct dentry *dentry)
2055 + vx_dentry_inc(dentry);
2058 static inline void __dget(struct dentry *dentry)
2059 @@ -1252,6 +1256,9 @@ struct dentry *__d_alloc(struct super_bl
2060 struct dentry *dentry;
2063 + if (!vx_dentry_avail(1))
2066 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2069 @@ -1284,6 +1291,7 @@ struct dentry *__d_alloc(struct super_bl
2071 dentry->d_count = 1;
2072 dentry->d_flags = 0;
2073 + vx_dentry_inc(dentry);
2074 spin_lock_init(&dentry->d_lock);
2075 seqcount_init(&dentry->d_seq);
2076 dentry->d_inode = NULL;
2077 @@ -1984,6 +1992,7 @@ struct dentry *__d_lookup(const struct d
2081 + vx_dentry_inc(dentry);
2083 spin_unlock(&dentry->d_lock);
2085 diff -NurpP --minimal linux-3.9.5/fs/devpts/inode.c linux-3.9.5-vs2.3.6.5/fs/devpts/inode.c
2086 --- linux-3.9.5/fs/devpts/inode.c 2013-05-31 13:45:23.000000000 +0000
2087 +++ linux-3.9.5-vs2.3.6.5/fs/devpts/inode.c 2013-06-12 23:49:08.000000000 +0000
2089 #include <linux/parser.h>
2090 #include <linux/fsnotify.h>
2091 #include <linux/seq_file.h>
2092 +#include <linux/vs_base.h>
2094 #define DEVPTS_DEFAULT_MODE 0600
2097 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2098 #define PTMX_MINOR 2
2100 +static int devpts_permission(struct inode *inode, int mask)
2102 + int ret = -EACCES;
2104 + /* devpts is xid tagged */
2105 + if (vx_check((vxid_t)i_tag_read(inode), VS_WATCH_P | VS_IDENT))
2106 + ret = generic_permission(inode, mask);
2110 +static struct inode_operations devpts_file_inode_operations = {
2111 + .permission = devpts_permission,
2116 * sysctl support for setting limits on the number of Unix98 ptys allocated.
2117 * Otherwise one can eat up all kernel memory by opening /dev/ptmx repeatedly.
2118 @@ -345,6 +361,34 @@ static int devpts_show_options(struct se
2122 +static int devpts_filter(struct dentry *de)
2126 + /* devpts is xid tagged */
2127 + if (de && de->d_inode)
2128 + xid = (vxid_t)i_tag_read(de->d_inode);
2129 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2131 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2132 + de->d_name.len, de->d_name.name);
2134 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2137 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2139 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2142 +static struct file_operations devpts_dir_operations = {
2143 + .open = dcache_dir_open,
2144 + .release = dcache_dir_close,
2145 + .llseek = dcache_dir_lseek,
2146 + .read = generic_read_dir,
2147 + .readdir = devpts_readdir,
2150 static const struct super_operations devpts_sops = {
2151 .statfs = simple_statfs,
2152 .remount_fs = devpts_remount,
2153 @@ -388,8 +432,10 @@ devpts_fill_super(struct super_block *s,
2154 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2155 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2156 inode->i_op = &simple_dir_inode_operations;
2157 - inode->i_fop = &simple_dir_operations;
2158 + inode->i_fop = &devpts_dir_operations;
2159 set_nlink(inode, 2);
2160 + /* devpts is xid tagged */
2161 + i_tag_write(inode, (vtag_t)vx_current_xid());
2163 s->s_root = d_make_root(inode);
2165 @@ -592,6 +638,9 @@ struct inode *devpts_pty_new(struct inod
2166 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2167 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2168 init_special_inode(inode, S_IFCHR|opts->mode, device);
2169 + /* devpts is xid tagged */
2170 + i_tag_write(inode, (vtag_t)vx_current_xid());
2171 + inode->i_op = &devpts_file_inode_operations;
2172 inode->i_private = priv;
2174 sprintf(s, "%d", index);
2175 diff -NurpP --minimal linux-3.9.5/fs/ext2/balloc.c linux-3.9.5-vs2.3.6.5/fs/ext2/balloc.c
2176 --- linux-3.9.5/fs/ext2/balloc.c 2013-05-31 13:45:23.000000000 +0000
2177 +++ linux-3.9.5-vs2.3.6.5/fs/ext2/balloc.c 2013-05-31 14:47:11.000000000 +0000
2178 @@ -693,7 +693,6 @@ ext2_try_to_allocate(struct super_block
2180 end = EXT2_BLOCKS_PER_GROUP(sb);
2183 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2186 diff -NurpP --minimal linux-3.9.5/fs/ext2/ext2.h linux-3.9.5-vs2.3.6.5/fs/ext2/ext2.h
2187 --- linux-3.9.5/fs/ext2/ext2.h 2012-12-11 03:30:57.000000000 +0000
2188 +++ linux-3.9.5-vs2.3.6.5/fs/ext2/ext2.h 2013-05-31 14:47:11.000000000 +0000
2189 @@ -244,8 +244,12 @@ struct ext2_group_desc
2190 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
2191 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
2192 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
2193 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
2194 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
2196 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
2197 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
2199 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
2200 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
2202 @@ -329,7 +333,8 @@ struct ext2_inode {
2204 __le16 l_i_uid_high; /* these 2 fields */
2205 __le16 l_i_gid_high; /* were reserved2[0] */
2206 - __u32 l_i_reserved2;
2207 + __le16 l_i_tag; /* Context Tag */
2208 + __u16 l_i_reserved2;
2211 __u8 h_i_frag; /* Fragment number */
2212 @@ -357,6 +362,7 @@ struct ext2_inode {
2213 #define i_gid_low i_gid
2214 #define i_uid_high osd2.linux2.l_i_uid_high
2215 #define i_gid_high osd2.linux2.l_i_gid_high
2216 +#define i_raw_tag osd2.linux2.l_i_tag
2217 #define i_reserved2 osd2.linux2.l_i_reserved2
2220 @@ -384,6 +390,7 @@ struct ext2_inode {
2221 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
2222 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
2223 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
2224 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2227 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
2228 @@ -757,6 +764,7 @@ extern void ext2_set_inode_flags(struct
2229 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2230 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2231 u64 start, u64 len);
2232 +extern int ext2_sync_flags(struct inode *, int, int);
2235 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2236 diff -NurpP --minimal linux-3.9.5/fs/ext2/file.c linux-3.9.5-vs2.3.6.5/fs/ext2/file.c
2237 --- linux-3.9.5/fs/ext2/file.c 2012-12-11 03:30:57.000000000 +0000
2238 +++ linux-3.9.5-vs2.3.6.5/fs/ext2/file.c 2013-05-31 14:47:11.000000000 +0000
2239 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2240 .setattr = ext2_setattr,
2241 .get_acl = ext2_get_acl,
2242 .fiemap = ext2_fiemap,
2243 + .sync_flags = ext2_sync_flags,
2245 diff -NurpP --minimal linux-3.9.5/fs/ext2/ialloc.c linux-3.9.5-vs2.3.6.5/fs/ext2/ialloc.c
2246 --- linux-3.9.5/fs/ext2/ialloc.c 2013-05-31 13:45:23.000000000 +0000
2247 +++ linux-3.9.5-vs2.3.6.5/fs/ext2/ialloc.c 2013-06-03 18:58:16.000000000 +0000
2249 #include <linux/backing-dev.h>
2250 #include <linux/buffer_head.h>
2251 #include <linux/random.h>
2252 +#include <linux/vs_tag.h>
2256 @@ -546,6 +547,7 @@ got:
2257 inode->i_mode = mode;
2258 inode->i_uid = current_fsuid();
2259 inode->i_gid = dir->i_gid;
2260 + i_tag_write(inode, dx_current_fstag(sb));
2262 inode_init_owner(inode, dir, mode);
2264 diff -NurpP --minimal linux-3.9.5/fs/ext2/inode.c linux-3.9.5-vs2.3.6.5/fs/ext2/inode.c
2265 --- linux-3.9.5/fs/ext2/inode.c 2013-05-31 13:45:23.000000000 +0000
2266 +++ linux-3.9.5-vs2.3.6.5/fs/ext2/inode.c 2013-06-03 19:42:51.000000000 +0000
2268 #include <linux/mpage.h>
2269 #include <linux/fiemap.h>
2270 #include <linux/namei.h>
2271 +#include <linux/vs_tag.h>
2275 @@ -1179,7 +1180,7 @@ static void ext2_truncate_blocks(struct
2277 if (ext2_inode_is_fast_symlink(inode))
2279 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2280 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2282 __ext2_truncate_blocks(inode, offset);
2284 @@ -1270,36 +1271,61 @@ void ext2_set_inode_flags(struct inode *
2286 unsigned int flags = EXT2_I(inode)->i_flags;
2288 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2289 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2290 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2293 + if (flags & EXT2_IMMUTABLE_FL)
2294 + inode->i_flags |= S_IMMUTABLE;
2295 + if (flags & EXT2_IXUNLINK_FL)
2296 + inode->i_flags |= S_IXUNLINK;
2298 if (flags & EXT2_SYNC_FL)
2299 inode->i_flags |= S_SYNC;
2300 if (flags & EXT2_APPEND_FL)
2301 inode->i_flags |= S_APPEND;
2302 - if (flags & EXT2_IMMUTABLE_FL)
2303 - inode->i_flags |= S_IMMUTABLE;
2304 if (flags & EXT2_NOATIME_FL)
2305 inode->i_flags |= S_NOATIME;
2306 if (flags & EXT2_DIRSYNC_FL)
2307 inode->i_flags |= S_DIRSYNC;
2309 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2311 + if (flags & EXT2_BARRIER_FL)
2312 + inode->i_vflags |= V_BARRIER;
2313 + if (flags & EXT2_COW_FL)
2314 + inode->i_vflags |= V_COW;
2317 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2318 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2320 unsigned int flags = ei->vfs_inode.i_flags;
2321 + unsigned int vflags = ei->vfs_inode.i_vflags;
2323 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2324 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2325 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2326 + EXT2_BARRIER_FL | EXT2_COW_FL);
2328 + if (flags & S_IMMUTABLE)
2329 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2330 + if (flags & S_IXUNLINK)
2331 + ei->i_flags |= EXT2_IXUNLINK_FL;
2333 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2334 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2336 ei->i_flags |= EXT2_SYNC_FL;
2337 if (flags & S_APPEND)
2338 ei->i_flags |= EXT2_APPEND_FL;
2339 - if (flags & S_IMMUTABLE)
2340 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2341 if (flags & S_NOATIME)
2342 ei->i_flags |= EXT2_NOATIME_FL;
2343 if (flags & S_DIRSYNC)
2344 ei->i_flags |= EXT2_DIRSYNC_FL;
2346 + if (vflags & V_BARRIER)
2347 + ei->i_flags |= EXT2_BARRIER_FL;
2348 + if (vflags & V_COW)
2349 + ei->i_flags |= EXT2_COW_FL;
2352 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2353 @@ -1335,8 +1361,10 @@ struct inode *ext2_iget (struct super_bl
2354 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2355 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2357 - i_uid_write(inode, i_uid);
2358 - i_gid_write(inode, i_gid);
2359 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2360 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2361 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2362 + le16_to_cpu(raw_inode->i_raw_tag)));
2363 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2364 inode->i_size = le32_to_cpu(raw_inode->i_size);
2365 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2366 @@ -1434,8 +1462,10 @@ static int __ext2_write_inode(struct ino
2367 struct ext2_inode_info *ei = EXT2_I(inode);
2368 struct super_block *sb = inode->i_sb;
2369 ino_t ino = inode->i_ino;
2370 - uid_t uid = i_uid_read(inode);
2371 - gid_t gid = i_gid_read(inode);
2372 + uid_t uid = from_kuid(&init_user_ns,
2373 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
2374 + gid_t gid = from_kgid(&init_user_ns,
2375 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
2376 struct buffer_head * bh;
2377 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2379 @@ -1471,6 +1501,9 @@ static int __ext2_write_inode(struct ino
2380 raw_inode->i_uid_high = 0;
2381 raw_inode->i_gid_high = 0;
2383 +#ifdef CONFIG_TAGGING_INTERN
2384 + raw_inode->i_raw_tag = cpu_to_le16(i_tag_read(inode));
2386 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2387 raw_inode->i_size = cpu_to_le32(inode->i_size);
2388 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2389 @@ -1551,7 +1584,8 @@ int ext2_setattr(struct dentry *dentry,
2390 if (is_quota_modification(inode, iattr))
2391 dquot_initialize(inode);
2392 if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||
2393 - (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {
2394 + (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid)) ||
2395 + (iattr->ia_valid & ATTR_TAG && !tag_eq(iattr->ia_tag, inode->i_tag))) {
2396 error = dquot_transfer(inode, iattr);
2399 diff -NurpP --minimal linux-3.9.5/fs/ext2/ioctl.c linux-3.9.5-vs2.3.6.5/fs/ext2/ioctl.c
2400 --- linux-3.9.5/fs/ext2/ioctl.c 2013-05-31 13:45:23.000000000 +0000
2401 +++ linux-3.9.5-vs2.3.6.5/fs/ext2/ioctl.c 2013-05-31 14:47:11.000000000 +0000
2403 #include <asm/uaccess.h>
2406 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2408 + inode->i_flags = flags;
2409 + inode->i_vflags = vflags;
2410 + ext2_get_inode_flags(EXT2_I(inode));
2411 + inode->i_ctime = CURRENT_TIME_SEC;
2412 + mark_inode_dirty(inode);
2416 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2418 struct inode *inode = file_inode(filp);
2419 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2421 flags = ext2_mask_flags(inode->i_mode, flags);
2423 + if (IS_BARRIER(inode)) {
2424 + vxwprintk_task(1, "messing with the barrier.");
2428 mutex_lock(&inode->i_mutex);
2429 /* Is it quota file? Do not allow user to mess with it */
2430 if (IS_NOQUOTA(inode)) {
2431 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2433 * This test looks nicer. Thanks to Pauline Middelink
2435 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2436 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2437 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2438 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2439 if (!capable(CAP_LINUX_IMMUTABLE)) {
2440 mutex_unlock(&inode->i_mutex);
2442 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2446 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2447 + flags &= EXT2_FL_USER_MODIFIABLE;
2448 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2449 ei->i_flags = flags;
2451 diff -NurpP --minimal linux-3.9.5/fs/ext2/namei.c linux-3.9.5-vs2.3.6.5/fs/ext2/namei.c
2452 --- linux-3.9.5/fs/ext2/namei.c 2012-12-11 03:30:57.000000000 +0000
2453 +++ linux-3.9.5-vs2.3.6.5/fs/ext2/namei.c 2013-05-31 14:47:11.000000000 +0000
2456 #include <linux/pagemap.h>
2457 #include <linux/quotaops.h>
2458 +#include <linux/vs_tag.h>
2462 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
2463 (unsigned long) ino);
2464 return ERR_PTR(-EIO);
2466 + dx_propagate_tag(nd, inode);
2468 return d_splice_alias(inode, dentry);
2470 @@ -397,6 +399,7 @@ const struct inode_operations ext2_dir_i
2471 .removexattr = generic_removexattr,
2473 .setattr = ext2_setattr,
2474 + .sync_flags = ext2_sync_flags,
2475 .get_acl = ext2_get_acl,
2478 diff -NurpP --minimal linux-3.9.5/fs/ext2/super.c linux-3.9.5-vs2.3.6.5/fs/ext2/super.c
2479 --- linux-3.9.5/fs/ext2/super.c 2013-05-31 13:45:23.000000000 +0000
2480 +++ linux-3.9.5-vs2.3.6.5/fs/ext2/super.c 2013-05-31 14:47:11.000000000 +0000
2481 @@ -395,7 +395,8 @@ enum {
2482 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2483 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2484 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2485 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2486 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2487 + Opt_tag, Opt_notag, Opt_tagid
2490 static const match_table_t tokens = {
2491 @@ -423,6 +424,9 @@ static const match_table_t tokens = {
2493 {Opt_noacl, "noacl"},
2496 + {Opt_notag, "notag"},
2497 + {Opt_tagid, "tagid=%u"},
2498 {Opt_grpquota, "grpquota"},
2499 {Opt_ignore, "noquota"},
2500 {Opt_quota, "quota"},
2501 @@ -506,6 +510,20 @@ static int parse_options(char *options,
2503 set_opt (sbi->s_mount_opt, NO_UID32);
2505 +#ifndef CONFIG_TAGGING_NONE
2507 + set_opt (sbi->s_mount_opt, TAGGED);
2510 + clear_opt (sbi->s_mount_opt, TAGGED);
2513 +#ifdef CONFIG_PROPAGATE
2516 + set_opt (sbi->s_mount_opt, TAGGED);
2520 clear_opt (sbi->s_mount_opt, CHECK);
2522 @@ -864,6 +882,8 @@ static int ext2_fill_super(struct super_
2523 if (!parse_options((char *) data, sb))
2526 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2527 + sb->s_flags |= MS_TAGGED;
2528 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2529 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2531 @@ -1269,6 +1289,14 @@ static int ext2_remount (struct super_bl
2536 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2537 + !(sb->s_flags & MS_TAGGED)) {
2538 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2541 + goto restore_opts;
2544 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2545 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2546 diff -NurpP --minimal linux-3.9.5/fs/ext3/ext3.h linux-3.9.5-vs2.3.6.5/fs/ext3/ext3.h
2547 --- linux-3.9.5/fs/ext3/ext3.h 2012-12-11 03:30:57.000000000 +0000
2548 +++ linux-3.9.5-vs2.3.6.5/fs/ext3/ext3.h 2013-05-31 14:47:11.000000000 +0000
2549 @@ -151,10 +151,14 @@ struct ext3_group_desc
2550 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
2551 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
2552 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
2553 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2554 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
2556 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
2557 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
2558 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2559 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
2561 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
2562 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
2564 /* Flags that should be inherited by new inodes from their parent. */
2565 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
2566 @@ -290,7 +294,8 @@ struct ext3_inode {
2568 __le16 l_i_uid_high; /* these 2 fields */
2569 __le16 l_i_gid_high; /* were reserved2[0] */
2570 - __u32 l_i_reserved2;
2571 + __le16 l_i_tag; /* Context Tag */
2572 + __u16 l_i_reserved2;
2575 __u8 h_i_frag; /* Fragment number */
2576 @@ -320,6 +325,7 @@ struct ext3_inode {
2577 #define i_gid_low i_gid
2578 #define i_uid_high osd2.linux2.l_i_uid_high
2579 #define i_gid_high osd2.linux2.l_i_gid_high
2580 +#define i_raw_tag osd2.linux2.l_i_tag
2581 #define i_reserved2 osd2.linux2.l_i_reserved2
2584 @@ -364,6 +370,7 @@ struct ext3_inode {
2585 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
2586 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
2587 * error in ordered mode */
2588 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2590 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
2591 #ifndef _LINUX_EXT2_FS_H
2592 @@ -1061,6 +1068,7 @@ extern void ext3_get_inode_flags(struct
2593 extern void ext3_set_aops(struct inode *inode);
2594 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2595 u64 start, u64 len);
2596 +extern int ext3_sync_flags(struct inode *, int, int);
2599 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
2600 diff -NurpP --minimal linux-3.9.5/fs/ext3/file.c linux-3.9.5-vs2.3.6.5/fs/ext3/file.c
2601 --- linux-3.9.5/fs/ext3/file.c 2012-12-11 03:30:57.000000000 +0000
2602 +++ linux-3.9.5-vs2.3.6.5/fs/ext3/file.c 2013-05-31 14:47:11.000000000 +0000
2603 @@ -76,5 +76,6 @@ const struct inode_operations ext3_file_
2605 .get_acl = ext3_get_acl,
2606 .fiemap = ext3_fiemap,
2607 + .sync_flags = ext3_sync_flags,
2610 diff -NurpP --minimal linux-3.9.5/fs/ext3/ialloc.c linux-3.9.5-vs2.3.6.5/fs/ext3/ialloc.c
2611 --- linux-3.9.5/fs/ext3/ialloc.c 2012-12-11 03:30:57.000000000 +0000
2612 +++ linux-3.9.5-vs2.3.6.5/fs/ext3/ialloc.c 2013-06-03 19:43:33.000000000 +0000
2615 #include <linux/quotaops.h>
2616 #include <linux/random.h>
2617 +#include <linux/vs_tag.h>
2621 @@ -469,6 +470,7 @@ got:
2622 inode->i_mode = mode;
2623 inode->i_uid = current_fsuid();
2624 inode->i_gid = dir->i_gid;
2625 + i_tag_write(inode, dx_current_fstag(sb));
2627 inode_init_owner(inode, dir, mode);
2629 diff -NurpP --minimal linux-3.9.5/fs/ext3/inode.c linux-3.9.5-vs2.3.6.5/fs/ext3/inode.c
2630 --- linux-3.9.5/fs/ext3/inode.c 2013-05-31 13:45:23.000000000 +0000
2631 +++ linux-3.9.5-vs2.3.6.5/fs/ext3/inode.c 2013-06-03 19:44:35.000000000 +0000
2633 #include <linux/writeback.h>
2634 #include <linux/mpage.h>
2635 #include <linux/namei.h>
2636 +#include <linux/vs_tag.h>
2641 @@ -2851,36 +2853,60 @@ void ext3_set_inode_flags(struct inode *
2643 unsigned int flags = EXT3_I(inode)->i_flags;
2645 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2646 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2647 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2649 + if (flags & EXT3_IMMUTABLE_FL)
2650 + inode->i_flags |= S_IMMUTABLE;
2651 + if (flags & EXT3_IXUNLINK_FL)
2652 + inode->i_flags |= S_IXUNLINK;
2654 if (flags & EXT3_SYNC_FL)
2655 inode->i_flags |= S_SYNC;
2656 if (flags & EXT3_APPEND_FL)
2657 inode->i_flags |= S_APPEND;
2658 - if (flags & EXT3_IMMUTABLE_FL)
2659 - inode->i_flags |= S_IMMUTABLE;
2660 if (flags & EXT3_NOATIME_FL)
2661 inode->i_flags |= S_NOATIME;
2662 if (flags & EXT3_DIRSYNC_FL)
2663 inode->i_flags |= S_DIRSYNC;
2665 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2667 + if (flags & EXT3_BARRIER_FL)
2668 + inode->i_vflags |= V_BARRIER;
2669 + if (flags & EXT3_COW_FL)
2670 + inode->i_vflags |= V_COW;
2673 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2674 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2676 unsigned int flags = ei->vfs_inode.i_flags;
2677 + unsigned int vflags = ei->vfs_inode.i_vflags;
2679 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2680 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2681 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2682 + EXT3_BARRIER_FL | EXT3_COW_FL);
2684 + if (flags & S_IMMUTABLE)
2685 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2686 + if (flags & S_IXUNLINK)
2687 + ei->i_flags |= EXT3_IXUNLINK_FL;
2689 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2690 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2692 ei->i_flags |= EXT3_SYNC_FL;
2693 if (flags & S_APPEND)
2694 ei->i_flags |= EXT3_APPEND_FL;
2695 - if (flags & S_IMMUTABLE)
2696 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2697 if (flags & S_NOATIME)
2698 ei->i_flags |= EXT3_NOATIME_FL;
2699 if (flags & S_DIRSYNC)
2700 ei->i_flags |= EXT3_DIRSYNC_FL;
2702 + if (vflags & V_BARRIER)
2703 + ei->i_flags |= EXT3_BARRIER_FL;
2704 + if (vflags & V_COW)
2705 + ei->i_flags |= EXT3_COW_FL;
2708 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2709 @@ -2918,8 +2944,10 @@ struct inode *ext3_iget(struct super_blo
2710 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2711 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2713 - i_uid_write(inode, i_uid);
2714 - i_gid_write(inode, i_gid);
2715 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2716 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2717 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2718 + le16_to_cpu(raw_inode->i_raw_tag)));
2719 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2720 inode->i_size = le32_to_cpu(raw_inode->i_size);
2721 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2722 @@ -3091,8 +3119,10 @@ again:
2724 ext3_get_inode_flags(ei);
2725 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2726 - i_uid = i_uid_read(inode);
2727 - i_gid = i_gid_read(inode);
2728 + i_uid = from_kuid(&init_user_ns,
2729 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
2730 + i_gid = from_kgid(&init_user_ns,
2731 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
2732 if(!(test_opt(inode->i_sb, NO_UID32))) {
2733 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
2734 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
2735 @@ -3117,6 +3147,9 @@ again:
2736 raw_inode->i_uid_high = 0;
2737 raw_inode->i_gid_high = 0;
2739 +#ifdef CONFIG_TAGGING_INTERN
2740 + raw_inode->i_raw_tag = cpu_to_le16(i_tag_read(inode));
2742 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2743 disksize = cpu_to_le32(ei->i_disksize);
2744 if (disksize != raw_inode->i_size) {
2745 @@ -3285,7 +3318,8 @@ int ext3_setattr(struct dentry *dentry,
2746 if (is_quota_modification(inode, attr))
2747 dquot_initialize(inode);
2748 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
2749 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
2750 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
2751 + (ia_valid & ATTR_TAG && !tag_eq(attr->ia_tag, inode->i_tag))) {
2754 /* (user+group)*(old+new) structure, inode write (sb,
2755 @@ -3307,6 +3341,8 @@ int ext3_setattr(struct dentry *dentry,
2756 inode->i_uid = attr->ia_uid;
2757 if (attr->ia_valid & ATTR_GID)
2758 inode->i_gid = attr->ia_gid;
2759 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2760 + inode->i_tag = attr->ia_tag;
2761 error = ext3_mark_inode_dirty(handle, inode);
2762 ext3_journal_stop(handle);
2764 diff -NurpP --minimal linux-3.9.5/fs/ext3/ioctl.c linux-3.9.5-vs2.3.6.5/fs/ext3/ioctl.c
2765 --- linux-3.9.5/fs/ext3/ioctl.c 2013-05-31 13:45:23.000000000 +0000
2766 +++ linux-3.9.5-vs2.3.6.5/fs/ext3/ioctl.c 2013-05-31 14:47:11.000000000 +0000
2768 #include <asm/uaccess.h>
2772 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2774 + handle_t *handle = NULL;
2775 + struct ext3_iloc iloc;
2778 + handle = ext3_journal_start(inode, 1);
2779 + if (IS_ERR(handle))
2780 + return PTR_ERR(handle);
2782 + if (IS_SYNC(inode))
2783 + handle->h_sync = 1;
2784 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2788 + inode->i_flags = flags;
2789 + inode->i_vflags = vflags;
2790 + ext3_get_inode_flags(EXT3_I(inode));
2791 + inode->i_ctime = CURRENT_TIME_SEC;
2793 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2795 + ext3_journal_stop(handle);
2799 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2801 struct inode *inode = file_inode(filp);
2802 @@ -45,6 +73,11 @@ long ext3_ioctl(struct file *filp, unsig
2804 flags = ext3_mask_flags(inode->i_mode, flags);
2806 + if (IS_BARRIER(inode)) {
2807 + vxwprintk_task(1, "messing with the barrier.");
2811 mutex_lock(&inode->i_mutex);
2813 /* Is it quota file? Do not allow user to mess with it */
2814 @@ -63,7 +96,9 @@ long ext3_ioctl(struct file *filp, unsig
2816 * This test looks nicer. Thanks to Pauline Middelink
2818 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2819 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2820 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2821 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2822 if (!capable(CAP_LINUX_IMMUTABLE))
2825 @@ -88,7 +123,7 @@ long ext3_ioctl(struct file *filp, unsig
2829 - flags = flags & EXT3_FL_USER_MODIFIABLE;
2830 + flags &= EXT3_FL_USER_MODIFIABLE;
2831 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
2832 ei->i_flags = flags;
2834 diff -NurpP --minimal linux-3.9.5/fs/ext3/namei.c linux-3.9.5-vs2.3.6.5/fs/ext3/namei.c
2835 --- linux-3.9.5/fs/ext3/namei.c 2013-05-31 13:45:23.000000000 +0000
2836 +++ linux-3.9.5-vs2.3.6.5/fs/ext3/namei.c 2013-05-31 14:47:11.000000000 +0000
2840 #include <linux/quotaops.h>
2841 +#include <linux/vs_tag.h>
2846 @@ -918,6 +920,7 @@ restart:
2847 submit_bh(READ | REQ_META | REQ_PRIO,
2850 + dx_propagate_tag(nd, inode);
2853 if ((bh = bh_use[ra_ptr++]) == NULL)
2854 @@ -2527,6 +2530,7 @@ const struct inode_operations ext3_dir_i
2855 .listxattr = ext3_listxattr,
2856 .removexattr = generic_removexattr,
2858 + .sync_flags = ext3_sync_flags,
2859 .get_acl = ext3_get_acl,
2862 diff -NurpP --minimal linux-3.9.5/fs/ext3/super.c linux-3.9.5-vs2.3.6.5/fs/ext3/super.c
2863 --- linux-3.9.5/fs/ext3/super.c 2013-05-31 13:45:23.000000000 +0000
2864 +++ linux-3.9.5-vs2.3.6.5/fs/ext3/super.c 2013-05-31 14:47:11.000000000 +0000
2865 @@ -816,7 +816,8 @@ enum {
2866 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2867 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
2868 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
2869 - Opt_resize, Opt_usrquota, Opt_grpquota
2870 + Opt_resize, Opt_usrquota, Opt_grpquota,
2871 + Opt_tag, Opt_notag, Opt_tagid
2874 static const match_table_t tokens = {
2875 @@ -873,6 +874,9 @@ static const match_table_t tokens = {
2876 {Opt_barrier, "barrier"},
2877 {Opt_nobarrier, "nobarrier"},
2878 {Opt_resize, "resize"},
2880 + {Opt_notag, "notag"},
2881 + {Opt_tagid, "tagid=%u"},
2885 @@ -1040,6 +1044,20 @@ static int parse_options (char *options,
2887 set_opt (sbi->s_mount_opt, NO_UID32);
2889 +#ifndef CONFIG_TAGGING_NONE
2891 + set_opt (sbi->s_mount_opt, TAGGED);
2894 + clear_opt (sbi->s_mount_opt, TAGGED);
2897 +#ifdef CONFIG_PROPAGATE
2900 + set_opt (sbi->s_mount_opt, TAGGED);
2904 clear_opt (sbi->s_mount_opt, CHECK);
2906 @@ -1737,6 +1755,9 @@ static int ext3_fill_super (struct super
2910 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
2911 + sb->s_flags |= MS_TAGGED;
2913 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2914 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2916 @@ -2633,6 +2654,14 @@ static int ext3_remount (struct super_bl
2917 if (test_opt(sb, ABORT))
2918 ext3_abort(sb, __func__, "Abort forced by user");
2920 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
2921 + !(sb->s_flags & MS_TAGGED)) {
2922 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
2925 + goto restore_opts;
2928 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2929 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2931 diff -NurpP --minimal linux-3.9.5/fs/ext4/ext4.h linux-3.9.5-vs2.3.6.5/fs/ext4/ext4.h
2932 --- linux-3.9.5/fs/ext4/ext4.h 2013-05-31 13:45:23.000000000 +0000
2933 +++ linux-3.9.5-vs2.3.6.5/fs/ext4/ext4.h 2013-05-31 16:22:49.000000000 +0000
2934 @@ -399,7 +399,10 @@ struct flex_groups {
2935 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
2936 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
2937 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
2938 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2939 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2940 #define EXT4_INLINE_DATA_FL 0x10000000 /* Inode has inline data. */
2941 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
2942 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
2944 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
2945 @@ -674,7 +677,7 @@ struct ext4_inode {
2946 __le16 l_i_uid_high; /* these 2 fields */
2947 __le16 l_i_gid_high; /* were reserved2[0] */
2948 __le16 l_i_checksum_lo;/* crc32c(uuid+inum+inode) LE */
2949 - __le16 l_i_reserved;
2950 + __le16 l_i_tag; /* Context Tag */
2953 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
2954 @@ -792,6 +795,7 @@ do { \
2955 #define i_gid_low i_gid
2956 #define i_uid_high osd2.linux2.l_i_uid_high
2957 #define i_gid_high osd2.linux2.l_i_gid_high
2958 +#define i_raw_tag osd2.linux2.l_i_tag
2959 #define i_checksum_lo osd2.linux2.l_i_checksum_lo
2961 #elif defined(__GNU__)
2962 @@ -969,6 +973,7 @@ struct ext4_inode_info {
2963 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
2964 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
2965 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
2966 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
2967 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
2968 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
2969 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
2970 @@ -2527,6 +2532,7 @@ extern struct buffer_head *ext4_get_firs
2971 extern int ext4_inline_data_fiemap(struct inode *inode,
2972 struct fiemap_extent_info *fieinfo,
2974 +extern int ext4_sync_flags(struct inode *, int, int);
2975 extern int ext4_try_to_evict_inline_data(handle_t *handle,
2976 struct inode *inode,
2978 diff -NurpP --minimal linux-3.9.5/fs/ext4/file.c linux-3.9.5-vs2.3.6.5/fs/ext4/file.c
2979 --- linux-3.9.5/fs/ext4/file.c 2013-05-31 13:45:23.000000000 +0000
2980 +++ linux-3.9.5-vs2.3.6.5/fs/ext4/file.c 2013-05-31 14:47:11.000000000 +0000
2981 @@ -650,5 +650,6 @@ const struct inode_operations ext4_file_
2982 .removexattr = generic_removexattr,
2983 .get_acl = ext4_get_acl,
2984 .fiemap = ext4_fiemap,
2985 + .sync_flags = ext4_sync_flags,
2988 diff -NurpP --minimal linux-3.9.5/fs/ext4/ialloc.c linux-3.9.5-vs2.3.6.5/fs/ext4/ialloc.c
2989 --- linux-3.9.5/fs/ext4/ialloc.c 2013-05-31 13:45:23.000000000 +0000
2990 +++ linux-3.9.5-vs2.3.6.5/fs/ext4/ialloc.c 2013-06-03 19:45:15.000000000 +0000
2992 #include <linux/random.h>
2993 #include <linux/bitops.h>
2994 #include <linux/blkdev.h>
2995 +#include <linux/vs_tag.h>
2996 #include <asm/byteorder.h>
2999 @@ -859,6 +860,7 @@ got:
3000 inode->i_mode = mode;
3001 inode->i_uid = current_fsuid();
3002 inode->i_gid = dir->i_gid;
3003 + i_tag_write(inode, dx_current_fstag(sb));
3005 inode_init_owner(inode, dir, mode);
3007 diff -NurpP --minimal linux-3.9.5/fs/ext4/inode.c linux-3.9.5-vs2.3.6.5/fs/ext4/inode.c
3008 --- linux-3.9.5/fs/ext4/inode.c 2013-06-11 12:22:39.000000000 +0000
3009 +++ linux-3.9.5-vs2.3.6.5/fs/ext4/inode.c 2013-06-03 19:45:35.000000000 +0000
3011 #include <linux/printk.h>
3012 #include <linux/slab.h>
3013 #include <linux/ratelimit.h>
3014 +#include <linux/vs_tag.h>
3016 #include "ext4_jbd2.h"
3018 @@ -3870,41 +3871,64 @@ void ext4_set_inode_flags(struct inode *
3020 unsigned int flags = EXT4_I(inode)->i_flags;
3022 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3023 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3024 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3026 + if (flags & EXT4_IMMUTABLE_FL)
3027 + inode->i_flags |= S_IMMUTABLE;
3028 + if (flags & EXT4_IXUNLINK_FL)
3029 + inode->i_flags |= S_IXUNLINK;
3031 if (flags & EXT4_SYNC_FL)
3032 inode->i_flags |= S_SYNC;
3033 if (flags & EXT4_APPEND_FL)
3034 inode->i_flags |= S_APPEND;
3035 - if (flags & EXT4_IMMUTABLE_FL)
3036 - inode->i_flags |= S_IMMUTABLE;
3037 if (flags & EXT4_NOATIME_FL)
3038 inode->i_flags |= S_NOATIME;
3039 if (flags & EXT4_DIRSYNC_FL)
3040 inode->i_flags |= S_DIRSYNC;
3042 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3044 + if (flags & EXT4_BARRIER_FL)
3045 + inode->i_vflags |= V_BARRIER;
3046 + if (flags & EXT4_COW_FL)
3047 + inode->i_vflags |= V_COW;
3050 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3051 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3053 - unsigned int vfs_fl;
3054 + unsigned int vfs_fl, vfs_vf;
3055 unsigned long old_fl, new_fl;
3058 vfs_fl = ei->vfs_inode.i_flags;
3059 + vfs_vf = ei->vfs_inode.i_vflags;
3060 old_fl = ei->i_flags;
3061 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3062 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3064 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3067 + if (vfs_fl & S_IMMUTABLE)
3068 + new_fl |= EXT4_IMMUTABLE_FL;
3069 + if (vfs_fl & S_IXUNLINK)
3070 + new_fl |= EXT4_IXUNLINK_FL;
3072 if (vfs_fl & S_SYNC)
3073 new_fl |= EXT4_SYNC_FL;
3074 if (vfs_fl & S_APPEND)
3075 new_fl |= EXT4_APPEND_FL;
3076 - if (vfs_fl & S_IMMUTABLE)
3077 - new_fl |= EXT4_IMMUTABLE_FL;
3078 if (vfs_fl & S_NOATIME)
3079 new_fl |= EXT4_NOATIME_FL;
3080 if (vfs_fl & S_DIRSYNC)
3081 new_fl |= EXT4_DIRSYNC_FL;
3083 + if (vfs_vf & V_BARRIER)
3084 + new_fl |= EXT4_BARRIER_FL;
3085 + if (vfs_vf & V_COW)
3086 + new_fl |= EXT4_COW_FL;
3087 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3090 @@ -4009,8 +4033,10 @@ struct inode *ext4_iget(struct super_blo
3091 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3092 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3094 - i_uid_write(inode, i_uid);
3095 - i_gid_write(inode, i_gid);
3096 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
3097 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
3098 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
3099 + le16_to_cpu(raw_inode->i_raw_tag)));
3100 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
3102 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3103 @@ -4233,8 +4259,10 @@ static int ext4_do_update_inode(handle_t
3105 ext4_get_inode_flags(ei);
3106 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3107 - i_uid = i_uid_read(inode);
3108 - i_gid = i_gid_read(inode);
3109 + i_uid = from_kuid(&init_user_ns,
3110 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
3111 + i_gid = from_kgid(&init_user_ns,
3112 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
3113 if (!(test_opt(inode->i_sb, NO_UID32))) {
3114 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
3115 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
3116 @@ -4257,6 +4285,9 @@ static int ext4_do_update_inode(handle_t
3117 raw_inode->i_uid_high = 0;
3118 raw_inode->i_gid_high = 0;
3120 +#ifdef CONFIG_TAGGING_INTERN
3121 + raw_inode->i_raw_tag = cpu_to_le16(i_tag_read(inode));
3123 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3125 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3126 @@ -4487,7 +4518,8 @@ int ext4_setattr(struct dentry *dentry,
3127 if (is_quota_modification(inode, attr))
3128 dquot_initialize(inode);
3129 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
3130 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
3131 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
3132 + (ia_valid & ATTR_TAG && !tag_eq(attr->ia_tag, inode->i_tag))) {
3135 /* (user+group)*(old+new) structure, inode write (sb,
3136 @@ -4510,6 +4542,8 @@ int ext4_setattr(struct dentry *dentry,
3137 inode->i_uid = attr->ia_uid;
3138 if (attr->ia_valid & ATTR_GID)
3139 inode->i_gid = attr->ia_gid;
3140 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3141 + inode->i_tag = attr->ia_tag;
3142 error = ext4_mark_inode_dirty(handle, inode);
3143 ext4_journal_stop(handle);
3145 diff -NurpP --minimal linux-3.9.5/fs/ext4/ioctl.c linux-3.9.5-vs2.3.6.5/fs/ext4/ioctl.c
3146 --- linux-3.9.5/fs/ext4/ioctl.c 2013-05-31 13:45:23.000000000 +0000
3147 +++ linux-3.9.5-vs2.3.6.5/fs/ext4/ioctl.c 2013-05-31 19:50:08.000000000 +0000
3149 #include <linux/compat.h>
3150 #include <linux/mount.h>
3151 #include <linux/file.h>
3152 +#include <linux/vs_tag.h>
3153 #include <asm/uaccess.h>
3154 #include "ext4_jbd2.h"
3157 #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1)
3159 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3161 + handle_t *handle = NULL;
3162 + struct ext4_iloc iloc;
3165 + handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
3166 + if (IS_ERR(handle))
3167 + return PTR_ERR(handle);
3169 + if (IS_SYNC(inode))
3170 + ext4_handle_sync(handle);
3171 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3175 + inode->i_flags = flags;
3176 + inode->i_vflags = vflags;
3177 + ext4_get_inode_flags(EXT4_I(inode));
3178 + inode->i_ctime = ext4_current_time(inode);
3180 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3182 + ext4_journal_stop(handle);
3186 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3188 struct inode *inode = file_inode(filp);
3189 @@ -53,6 +81,11 @@ long ext4_ioctl(struct file *filp, unsig
3191 flags = ext4_mask_flags(inode->i_mode, flags);
3193 + if (IS_BARRIER(inode)) {
3194 + vxwprintk_task(1, "messing with the barrier.");
3199 mutex_lock(&inode->i_mutex);
3200 /* Is it quota file? Do not allow user to mess with it */
3201 @@ -70,7 +103,9 @@ long ext4_ioctl(struct file *filp, unsig
3203 * This test looks nicer. Thanks to Pauline Middelink
3205 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3206 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3207 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3208 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3209 if (!capable(CAP_LINUX_IMMUTABLE))
3212 diff -NurpP --minimal linux-3.9.5/fs/ext4/namei.c linux-3.9.5-vs2.3.6.5/fs/ext4/namei.c
3213 --- linux-3.9.5/fs/ext4/namei.c 2013-05-31 13:45:23.000000000 +0000
3214 +++ linux-3.9.5-vs2.3.6.5/fs/ext4/namei.c 2013-05-31 14:47:11.000000000 +0000
3216 #include <linux/quotaops.h>
3217 #include <linux/buffer_head.h>
3218 #include <linux/bio.h>
3219 +#include <linux/vs_tag.h>
3221 #include "ext4_jbd2.h"
3223 @@ -1290,6 +1291,7 @@ restart:
3224 ll_rw_block(READ | REQ_META | REQ_PRIO,
3227 + dx_propagate_tag(nd, inode);
3229 if ((bh = bh_use[ra_ptr++]) == NULL)
3231 @@ -3190,6 +3192,7 @@ const struct inode_operations ext4_dir_i
3232 .removexattr = generic_removexattr,
3233 .get_acl = ext4_get_acl,
3234 .fiemap = ext4_fiemap,
3235 + .sync_flags = ext4_sync_flags,
3238 const struct inode_operations ext4_special_inode_operations = {
3239 diff -NurpP --minimal linux-3.9.5/fs/ext4/super.c linux-3.9.5-vs2.3.6.5/fs/ext4/super.c
3240 --- linux-3.9.5/fs/ext4/super.c 2013-06-11 12:22:39.000000000 +0000
3241 +++ linux-3.9.5-vs2.3.6.5/fs/ext4/super.c 2013-05-31 14:47:11.000000000 +0000
3242 @@ -1131,7 +1131,7 @@ enum {
3243 Opt_inode_readahead_blks, Opt_journal_ioprio,
3244 Opt_dioread_nolock, Opt_dioread_lock,
3245 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
3246 - Opt_max_dir_size_kb,
3247 + Opt_max_dir_size_kb, Opt_tag, Opt_notag, Opt_tagid
3250 static const match_table_t tokens = {
3251 @@ -1211,6 +1211,9 @@ static const match_table_t tokens = {
3252 {Opt_removed, "reservation"}, /* mount option from ext2/3 */
3253 {Opt_removed, "noreservation"}, /* mount option from ext2/3 */
3254 {Opt_removed, "journal=%u"}, /* mount option from ext2/3 */
3256 + {Opt_notag, "notag"},
3257 + {Opt_tagid, "tagid=%u"},
3261 @@ -1441,6 +1444,20 @@ static int handle_mount_opt(struct super
3263 sb->s_flags |= MS_I_VERSION;
3265 +#ifndef CONFIG_TAGGING_NONE
3267 + set_opt(sb, TAGGED);
3270 + clear_opt(sb, TAGGED);
3273 +#ifdef CONFIG_PROPAGATE
3276 + set_opt(sb, TAGGED);
3281 for (m = ext4_mount_opts; m->token != Opt_err; m++)
3282 @@ -3401,6 +3418,9 @@ static int ext4_fill_super(struct super_
3283 clear_opt(sb, DELALLOC);
3286 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3287 + sb->s_flags |= MS_TAGGED;
3289 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3290 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3292 @@ -4587,6 +4607,14 @@ static int ext4_remount(struct super_blo
3293 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3294 ext4_abort(sb, "Abort forced by user");
3296 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3297 + !(sb->s_flags & MS_TAGGED)) {
3298 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3301 + goto restore_opts;
3304 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3305 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3307 diff -NurpP --minimal linux-3.9.5/fs/fcntl.c linux-3.9.5-vs2.3.6.5/fs/fcntl.c
3308 --- linux-3.9.5/fs/fcntl.c 2013-05-31 13:45:23.000000000 +0000
3309 +++ linux-3.9.5-vs2.3.6.5/fs/fcntl.c 2013-05-31 14:47:11.000000000 +0000
3311 #include <linux/rcupdate.h>
3312 #include <linux/pid_namespace.h>
3313 #include <linux/user_namespace.h>
3314 +#include <linux/vs_limit.h>
3316 #include <asm/poll.h>
3317 #include <asm/siginfo.h>
3318 @@ -378,6 +379,8 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, f
3322 + if (!vx_files_avail(1))
3325 if (unlikely(f.file->f_mode & FMODE_PATH)) {
3326 if (!check_fcntl_cmd(cmd))
3327 diff -NurpP --minimal linux-3.9.5/fs/file.c linux-3.9.5-vs2.3.6.5/fs/file.c
3328 --- linux-3.9.5/fs/file.c 2013-05-31 13:45:23.000000000 +0000
3329 +++ linux-3.9.5-vs2.3.6.5/fs/file.c 2013-05-31 14:47:11.000000000 +0000
3331 #include <linux/spinlock.h>
3332 #include <linux/rcupdate.h>
3333 #include <linux/workqueue.h>
3334 +#include <linux/vs_limit.h>
3336 struct fdtable_defer {
3338 @@ -364,6 +365,8 @@ struct files_struct *dup_fd(struct files
3339 struct file *f = *old_fds++;
3342 + /* TODO: sum it first for check and performance */
3343 + vx_openfd_inc(open_files - i);
3346 * The fd may be claimed in the fd bitmap but not yet
3347 @@ -429,9 +432,11 @@ static void close_files(struct files_str
3348 filp_close(file, files);
3359 @@ -567,6 +572,7 @@ repeat:
3361 __clear_close_on_exec(fd, fdt);
3363 + vx_openfd_inc(fd);
3366 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3367 @@ -597,6 +603,7 @@ static void __put_unused_fd(struct files
3368 __clear_open_fd(fd, fdt);
3369 if (fd < files->next_fd)
3370 files->next_fd = fd;
3371 + vx_openfd_dec(fd);
3374 void put_unused_fd(unsigned int fd)
3375 @@ -876,6 +883,8 @@ static int do_dup2(struct files_struct *
3378 filp_close(tofree, files);
3380 + vx_openfd_inc(fd); /* fd was unused */
3384 diff -NurpP --minimal linux-3.9.5/fs/file_table.c linux-3.9.5-vs2.3.6.5/fs/file_table.c
3385 --- linux-3.9.5/fs/file_table.c 2013-05-31 13:45:23.000000000 +0000
3386 +++ linux-3.9.5-vs2.3.6.5/fs/file_table.c 2013-05-31 14:47:11.000000000 +0000
3388 #include <linux/hardirq.h>
3389 #include <linux/task_work.h>
3390 #include <linux/ima.h>
3391 +#include <linux/vs_limit.h>
3392 +#include <linux/vs_context.h>
3394 #include <linux/atomic.h>
3396 @@ -140,6 +142,8 @@ struct file *get_empty_filp(void)
3397 spin_lock_init(&f->f_lock);
3398 eventpoll_init_file(f);
3399 /* f->f_version: 0 */
3400 + f->f_xid = vx_current_xid();
3405 @@ -257,6 +261,8 @@ static void __fput(struct file *file)
3406 i_readcount_dec(inode);
3407 if (file->f_mode & FMODE_WRITE)
3408 drop_file_write_access(file);
3409 + vx_files_dec(file);
3411 file->f_path.dentry = NULL;
3412 file->f_path.mnt = NULL;
3413 file->f_inode = NULL;
3414 @@ -344,6 +350,8 @@ void put_filp(struct file *file)
3416 if (atomic_long_dec_and_test(&file->f_count)) {
3417 security_file_free(file);
3418 + vx_files_dec(file);
3420 file_sb_list_del(file);
3423 diff -NurpP --minimal linux-3.9.5/fs/fs_struct.c linux-3.9.5-vs2.3.6.5/fs/fs_struct.c
3424 --- linux-3.9.5/fs/fs_struct.c 2013-05-31 13:45:23.000000000 +0000
3425 +++ linux-3.9.5-vs2.3.6.5/fs/fs_struct.c 2013-05-31 14:47:11.000000000 +0000
3427 #include <linux/path.h>
3428 #include <linux/slab.h>
3429 #include <linux/fs_struct.h>
3430 +#include <linux/vserver/global.h>
3431 #include "internal.h"
3434 @@ -87,6 +88,7 @@ void free_fs_struct(struct fs_struct *fs
3436 path_put(&fs->root);
3438 + atomic_dec(&vs_global_fs);
3439 kmem_cache_free(fs_cachep, fs);
3442 @@ -124,6 +126,7 @@ struct fs_struct *copy_fs_struct(struct
3445 spin_unlock(&old->lock);
3446 + atomic_inc(&vs_global_fs);
3450 diff -NurpP --minimal linux-3.9.5/fs/gfs2/file.c linux-3.9.5-vs2.3.6.5/fs/gfs2/file.c
3451 --- linux-3.9.5/fs/gfs2/file.c 2013-05-31 13:45:23.000000000 +0000
3452 +++ linux-3.9.5-vs2.3.6.5/fs/gfs2/file.c 2013-05-31 19:54:27.000000000 +0000
3453 @@ -143,6 +143,9 @@ static const u32 fsflags_to_gfs2[32] = {
3454 [12] = GFS2_DIF_EXHASH,
3455 [14] = GFS2_DIF_INHERIT_JDATA,
3456 [17] = GFS2_DIF_TOPDIR,
3457 + [27] = GFS2_DIF_IXUNLINK,
3458 + [26] = GFS2_DIF_BARRIER,
3459 + [29] = GFS2_DIF_COW,
3462 static const u32 gfs2_to_fsflags[32] = {
3463 @@ -153,6 +156,9 @@ static const u32 gfs2_to_fsflags[32] = {
3464 [gfs2fl_ExHash] = FS_INDEX_FL,
3465 [gfs2fl_TopLevel] = FS_TOPDIR_FL,
3466 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3467 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3468 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3469 + [gfs2fl_Cow] = FS_COW_FL,
3472 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3473 @@ -183,12 +189,18 @@ void gfs2_set_inode_flags(struct inode *
3475 struct gfs2_inode *ip = GFS2_I(inode);
3476 unsigned int flags = inode->i_flags;
3477 + unsigned int vflags = inode->i_vflags;
3479 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3480 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
3482 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
3483 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
3484 inode->i_flags |= S_NOSEC;
3485 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3486 flags |= S_IMMUTABLE;
3487 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3488 + flags |= S_IXUNLINK;
3490 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3492 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3493 @@ -196,6 +208,43 @@ void gfs2_set_inode_flags(struct inode *
3494 if (ip->i_diskflags & GFS2_DIF_SYNC)
3496 inode->i_flags = flags;
3498 + vflags &= ~(V_BARRIER | V_COW);
3500 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3501 + vflags |= V_BARRIER;
3502 + if (ip->i_diskflags & GFS2_DIF_COW)
3504 + inode->i_vflags = vflags;
3507 +void gfs2_get_inode_flags(struct inode *inode)
3509 + struct gfs2_inode *ip = GFS2_I(inode);
3510 + unsigned int flags = inode->i_flags;
3511 + unsigned int vflags = inode->i_vflags;
3513 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3514 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3515 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3516 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3518 + if (flags & S_IMMUTABLE)
3519 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3520 + if (flags & S_IXUNLINK)
3521 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3523 + if (flags & S_APPEND)
3524 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3525 + if (flags & S_NOATIME)
3526 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3527 + if (flags & S_SYNC)
3528 + ip->i_diskflags |= GFS2_DIF_SYNC;
3530 + if (vflags & V_BARRIER)
3531 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3532 + if (vflags & V_COW)
3533 + ip->i_diskflags |= GFS2_DIF_COW;
3536 /* Flags that can be set by user space */
3537 @@ -309,6 +358,37 @@ static int gfs2_set_flags(struct file *f
3538 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3541 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3543 + struct gfs2_inode *ip = GFS2_I(inode);
3544 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3545 + struct buffer_head *bh;
3546 + struct gfs2_holder gh;
3549 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3552 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3555 + error = gfs2_meta_inode_buffer(ip, &bh);
3557 + goto out_trans_end;
3558 + gfs2_trans_add_meta(ip->i_gl, bh);
3559 + inode->i_flags = flags;
3560 + inode->i_vflags = vflags;
3561 + gfs2_get_inode_flags(inode);
3562 + gfs2_dinode_out(ip, bh->b_data);
3564 + gfs2_set_aops(inode);
3566 + gfs2_trans_end(sdp);
3568 + gfs2_glock_dq_uninit(&gh);
3572 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3575 diff -NurpP --minimal linux-3.9.5/fs/gfs2/inode.h linux-3.9.5-vs2.3.6.5/fs/gfs2/inode.h
3576 --- linux-3.9.5/fs/gfs2/inode.h 2012-12-11 03:30:57.000000000 +0000
3577 +++ linux-3.9.5-vs2.3.6.5/fs/gfs2/inode.h 2013-05-31 14:47:11.000000000 +0000
3578 @@ -117,6 +117,7 @@ extern const struct file_operations gfs2
3579 extern const struct file_operations gfs2_dir_fops_nolock;
3581 extern void gfs2_set_inode_flags(struct inode *inode);
3582 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3584 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3585 extern const struct file_operations gfs2_file_fops;
3586 diff -NurpP --minimal linux-3.9.5/fs/hostfs/hostfs.h linux-3.9.5-vs2.3.6.5/fs/hostfs/hostfs.h
3587 --- linux-3.9.5/fs/hostfs/hostfs.h 2012-12-11 03:30:57.000000000 +0000
3588 +++ linux-3.9.5-vs2.3.6.5/fs/hostfs/hostfs.h 2013-06-12 23:49:08.000000000 +0000
3589 @@ -42,6 +42,7 @@ struct hostfs_iattr {
3590 unsigned short ia_mode;
3595 struct timespec ia_atime;
3596 struct timespec ia_mtime;
3597 diff -NurpP --minimal linux-3.9.5/fs/inode.c linux-3.9.5-vs2.3.6.5/fs/inode.c
3598 --- linux-3.9.5/fs/inode.c 2013-05-31 13:45:24.000000000 +0000
3599 +++ linux-3.9.5-vs2.3.6.5/fs/inode.c 2013-06-03 18:32:17.000000000 +0000
3601 #include <linux/prefetch.h>
3602 #include <linux/buffer_head.h> /* for inode_has_buffers */
3603 #include <linux/ratelimit.h>
3604 +#include <linux/vs_tag.h>
3605 #include "internal.h"
3608 @@ -128,6 +129,8 @@ int inode_init_always(struct super_block
3609 struct address_space *const mapping = &inode->i_data;
3613 + /* essential because of inode slab reuse */
3614 inode->i_blkbits = sb->s_blocksize_bits;
3616 atomic_set(&inode->i_count, 1);
3617 @@ -137,6 +140,7 @@ int inode_init_always(struct super_block
3618 inode->i_opflags = 0;
3619 i_uid_write(inode, 0);
3620 i_gid_write(inode, 0);
3621 + i_tag_write(inode, 0);
3622 atomic_set(&inode->i_writecount, 0);
3624 inode->i_blocks = 0;
3625 @@ -149,6 +153,7 @@ int inode_init_always(struct super_block
3626 inode->i_bdev = NULL;
3627 inode->i_cdev = NULL;
3629 + inode->i_mdev = 0;
3630 inode->dirtied_when = 0;
3632 if (security_inode_alloc(inode))
3633 @@ -483,6 +488,8 @@ void __insert_inode_hash(struct inode *i
3635 EXPORT_SYMBOL(__insert_inode_hash);
3637 +EXPORT_SYMBOL_GPL(__iget);
3640 * __remove_inode_hash - remove an inode from the hash
3641 * @inode: inode to unhash
3642 @@ -1799,9 +1806,11 @@ void init_special_inode(struct inode *in
3643 if (S_ISCHR(mode)) {
3644 inode->i_fop = &def_chr_fops;
3645 inode->i_rdev = rdev;
3646 + inode->i_mdev = rdev;
3647 } else if (S_ISBLK(mode)) {
3648 inode->i_fop = &def_blk_fops;
3649 inode->i_rdev = rdev;
3650 + inode->i_mdev = rdev;
3651 } else if (S_ISFIFO(mode))
3652 inode->i_fop = &def_fifo_fops;
3653 else if (S_ISSOCK(mode))
3654 @@ -1830,6 +1839,7 @@ void inode_init_owner(struct inode *inod
3656 inode->i_gid = current_fsgid();
3657 inode->i_mode = mode;
3658 + i_tag_write(inode, dx_current_fstag(inode->i_sb));
3660 EXPORT_SYMBOL(inode_init_owner);
3662 diff -NurpP --minimal linux-3.9.5/fs/ioctl.c linux-3.9.5-vs2.3.6.5/fs/ioctl.c
3663 --- linux-3.9.5/fs/ioctl.c 2013-05-31 13:45:24.000000000 +0000
3664 +++ linux-3.9.5-vs2.3.6.5/fs/ioctl.c 2013-05-31 14:47:11.000000000 +0000
3666 #include <linux/writeback.h>
3667 #include <linux/buffer_head.h>
3668 #include <linux/falloc.h>
3669 +#include <linux/proc_fs.h>
3670 +#include <linux/vserver/inode.h>
3671 +#include <linux/vs_tag.h>
3673 #include <asm/ioctls.h>
3675 diff -NurpP --minimal linux-3.9.5/fs/ioprio.c linux-3.9.5-vs2.3.6.5/fs/ioprio.c
3676 --- linux-3.9.5/fs/ioprio.c 2012-12-11 03:30:57.000000000 +0000
3677 +++ linux-3.9.5-vs2.3.6.5/fs/ioprio.c 2013-05-31 14:47:11.000000000 +0000
3679 #include <linux/syscalls.h>
3680 #include <linux/security.h>
3681 #include <linux/pid_namespace.h>
3682 +#include <linux/vs_base.h>
3684 int set_task_ioprio(struct task_struct *task, int ioprio)
3686 @@ -105,6 +106,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3688 pgrp = find_vpid(who);
3689 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3690 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3692 ret = set_task_ioprio(p, ioprio);
3695 @@ -198,6 +201,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3697 pgrp = find_vpid(who);
3698 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3699 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3701 tmpio = get_task_ioprio(p);
3704 diff -NurpP --minimal linux-3.9.5/fs/jfs/file.c linux-3.9.5-vs2.3.6.5/fs/jfs/file.c
3705 --- linux-3.9.5/fs/jfs/file.c 2013-02-19 13:58:48.000000000 +0000
3706 +++ linux-3.9.5-vs2.3.6.5/fs/jfs/file.c 2013-05-31 14:47:11.000000000 +0000
3707 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
3708 if (is_quota_modification(inode, iattr))
3709 dquot_initialize(inode);
3710 if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||
3711 - (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {
3712 + (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid)) ||
3713 + (iattr->ia_valid & ATTR_TAG && !tag_eq(iattr->ia_tag, inode->i_tag))) {
3714 rc = dquot_transfer(inode, iattr);
3717 @@ -144,6 +145,7 @@ const struct inode_operations jfs_file_i
3718 #ifdef CONFIG_JFS_POSIX_ACL
3719 .get_acl = jfs_get_acl,
3721 + .sync_flags = jfs_sync_flags,
3724 const struct file_operations jfs_file_operations = {
3725 diff -NurpP --minimal linux-3.9.5/fs/jfs/ioctl.c linux-3.9.5-vs2.3.6.5/fs/jfs/ioctl.c
3726 --- linux-3.9.5/fs/jfs/ioctl.c 2013-05-31 13:45:24.000000000 +0000
3727 +++ linux-3.9.5-vs2.3.6.5/fs/jfs/ioctl.c 2013-05-31 14:47:11.000000000 +0000
3729 #include <linux/time.h>
3730 #include <linux/sched.h>
3731 #include <linux/blkdev.h>
3732 +#include <linux/mount.h>
3733 #include <asm/current.h>
3734 #include <asm/uaccess.h>
3736 @@ -56,6 +57,16 @@ static long jfs_map_ext2(unsigned long f
3740 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3742 + inode->i_flags = flags;
3743 + inode->i_vflags = vflags;
3744 + jfs_get_inode_flags(JFS_IP(inode));
3745 + inode->i_ctime = CURRENT_TIME_SEC;
3746 + mark_inode_dirty(inode);
3750 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3752 struct inode *inode = file_inode(filp);
3753 @@ -89,6 +100,11 @@ long jfs_ioctl(struct file *filp, unsign
3754 if (!S_ISDIR(inode->i_mode))
3755 flags &= ~JFS_DIRSYNC_FL;
3757 + if (IS_BARRIER(inode)) {
3758 + vxwprintk_task(1, "messing with the barrier.");
3762 /* Is it quota file? Do not allow user to mess with it */
3763 if (IS_NOQUOTA(inode)) {
3765 @@ -106,8 +122,8 @@ long jfs_ioctl(struct file *filp, unsign
3766 * the relevant capability.
3768 if ((oldflags & JFS_IMMUTABLE_FL) ||
3769 - ((flags ^ oldflags) &
3770 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3771 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3772 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3773 if (!capable(CAP_LINUX_IMMUTABLE)) {
3774 mutex_unlock(&inode->i_mutex);
3776 @@ -115,7 +131,7 @@ long jfs_ioctl(struct file *filp, unsign
3780 - flags = flags & JFS_FL_USER_MODIFIABLE;
3781 + flags &= JFS_FL_USER_MODIFIABLE;
3782 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3783 jfs_inode->mode2 = flags;
3785 diff -NurpP --minimal linux-3.9.5/fs/jfs/jfs_dinode.h linux-3.9.5-vs2.3.6.5/fs/jfs/jfs_dinode.h
3786 --- linux-3.9.5/fs/jfs/jfs_dinode.h 2012-12-11 03:30:57.000000000 +0000
3787 +++ linux-3.9.5-vs2.3.6.5/fs/jfs/jfs_dinode.h 2013-05-31 14:47:11.000000000 +0000
3788 @@ -161,9 +161,13 @@ struct dinode {
3790 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3791 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3792 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3794 -#define JFS_FL_USER_VISIBLE 0x03F80000
3795 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3796 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3797 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3799 +#define JFS_FL_USER_VISIBLE 0x07F80000
3800 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3801 #define JFS_FL_INHERIT 0x03C80000
3803 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3804 diff -NurpP --minimal linux-3.9.5/fs/jfs/jfs_filsys.h linux-3.9.5-vs2.3.6.5/fs/jfs/jfs_filsys.h
3805 --- linux-3.9.5/fs/jfs/jfs_filsys.h 2012-12-11 03:30:57.000000000 +0000
3806 +++ linux-3.9.5-vs2.3.6.5/fs/jfs/jfs_filsys.h 2013-05-31 14:47:11.000000000 +0000
3808 #define JFS_NAME_MAX 255
3809 #define JFS_PATH_MAX BPSIZE
3811 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
3814 * file system state (superblock state)
3815 diff -NurpP --minimal linux-3.9.5/fs/jfs/jfs_imap.c linux-3.9.5-vs2.3.6.5/fs/jfs/jfs_imap.c
3816 --- linux-3.9.5/fs/jfs/jfs_imap.c 2012-12-11 03:30:57.000000000 +0000
3817 +++ linux-3.9.5-vs2.3.6.5/fs/jfs/jfs_imap.c 2013-06-03 19:53:45.000000000 +0000
3819 #include <linux/pagemap.h>
3820 #include <linux/quotaops.h>
3821 #include <linux/slab.h>
3822 +#include <linux/vs_tag.h>
3824 #include "jfs_incore.h"
3825 #include "jfs_inode.h"
3826 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
3828 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3829 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
3833 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3834 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3835 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
3837 set_nlink(ip, le32_to_cpu(dip->di_nlink));
3839 - jfs_ip->saved_uid = make_kuid(&init_user_ns, le32_to_cpu(dip->di_uid));
3840 + kuid = make_kuid(&init_user_ns, le32_to_cpu(dip->di_uid));
3841 + kgid = make_kgid(&init_user_ns, le32_to_cpu(dip->di_gid));
3842 + ip->i_tag = INOTAG_KTAG(DX_TAG(ip), kuid, kgid, GLOBAL_ROOT_TAG);
3844 + jfs_ip->saved_uid = INOTAG_KUID(DX_TAG(ip), kuid, kgid);
3845 if (!uid_valid(sbi->uid))
3846 ip->i_uid = jfs_ip->saved_uid;
3848 ip->i_uid = sbi->uid;
3851 - jfs_ip->saved_gid = make_kgid(&init_user_ns, le32_to_cpu(dip->di_gid));
3852 + jfs_ip->saved_gid = INOTAG_KGID(DX_TAG(ip), kuid, kgid);
3853 if (!gid_valid(sbi->gid))
3854 ip->i_gid = jfs_ip->saved_gid;
3856 @@ -3150,16 +3157,14 @@ static void copy_to_dinode(struct dinode
3857 dip->di_size = cpu_to_le64(ip->i_size);
3858 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
3859 dip->di_nlink = cpu_to_le32(ip->i_nlink);
3860 - if (!uid_valid(sbi->uid))
3861 - dip->di_uid = cpu_to_le32(i_uid_read(ip));
3863 - dip->di_uid =cpu_to_le32(from_kuid(&init_user_ns,
3864 - jfs_ip->saved_uid));
3865 - if (!gid_valid(sbi->gid))
3866 - dip->di_gid = cpu_to_le32(i_gid_read(ip));
3868 - dip->di_gid = cpu_to_le32(from_kgid(&init_user_ns,
3869 - jfs_ip->saved_gid));
3870 + dip->di_uid = cpu_to_le32(from_kuid(&init_user_ns,
3871 + TAGINO_KUID(DX_TAG(ip),
3872 + !uid_valid(sbi->uid) ? ip->i_uid : jfs_ip->saved_uid,
3874 + dip->di_gid = cpu_to_le32(from_kgid(&init_user_ns,
3875 + TAGINO_KGID(DX_TAG(ip),
3876 + !gid_valid(sbi->gid) ? ip->i_gid : jfs_ip->saved_gid,
3878 jfs_get_inode_flags(jfs_ip);
3880 * mode2 is only needed for storing the higher order bits.
3881 diff -NurpP --minimal linux-3.9.5/fs/jfs/jfs_inode.c linux-3.9.5-vs2.3.6.5/fs/jfs/jfs_inode.c
3882 --- linux-3.9.5/fs/jfs/jfs_inode.c 2012-12-11 03:30:57.000000000 +0000
3883 +++ linux-3.9.5-vs2.3.6.5/fs/jfs/jfs_inode.c 2013-05-31 14:47:11.000000000 +0000
3886 #include <linux/fs.h>
3887 #include <linux/quotaops.h>
3888 +#include <linux/vs_tag.h>
3889 #include "jfs_incore.h"
3890 #include "jfs_inode.h"
3891 #include "jfs_filsys.h"
3892 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
3894 unsigned int flags = JFS_IP(inode)->mode2;
3896 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
3897 - S_NOATIME | S_DIRSYNC | S_SYNC);
3898 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3899 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3901 if (flags & JFS_IMMUTABLE_FL)
3902 inode->i_flags |= S_IMMUTABLE;
3903 + if (flags & JFS_IXUNLINK_FL)
3904 + inode->i_flags |= S_IXUNLINK;
3906 + if (flags & JFS_SYNC_FL)
3907 + inode->i_flags |= S_SYNC;
3908 if (flags & JFS_APPEND_FL)
3909 inode->i_flags |= S_APPEND;
3910 if (flags & JFS_NOATIME_FL)
3911 inode->i_flags |= S_NOATIME;
3912 if (flags & JFS_DIRSYNC_FL)
3913 inode->i_flags |= S_DIRSYNC;
3914 - if (flags & JFS_SYNC_FL)
3915 - inode->i_flags |= S_SYNC;
3917 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3919 + if (flags & JFS_BARRIER_FL)
3920 + inode->i_vflags |= V_BARRIER;
3921 + if (flags & JFS_COW_FL)
3922 + inode->i_vflags |= V_COW;
3925 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
3927 unsigned int flags = jfs_ip->vfs_inode.i_flags;
3928 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
3930 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
3931 + JFS_APPEND_FL | JFS_NOATIME_FL |
3932 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
3933 + JFS_BARRIER_FL | JFS_COW_FL);
3935 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
3936 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
3937 if (flags & S_IMMUTABLE)
3938 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
3939 + if (flags & S_IXUNLINK)
3940 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
3942 if (flags & S_APPEND)
3943 jfs_ip->mode2 |= JFS_APPEND_FL;
3944 if (flags & S_NOATIME)
3945 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
3946 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
3948 jfs_ip->mode2 |= JFS_SYNC_FL;
3950 + if (vflags & V_BARRIER)
3951 + jfs_ip->mode2 |= JFS_BARRIER_FL;
3952 + if (vflags & V_COW)
3953 + jfs_ip->mode2 |= JFS_COW_FL;
3957 diff -NurpP --minimal linux-3.9.5/fs/jfs/jfs_inode.h linux-3.9.5-vs2.3.6.5/fs/jfs/jfs_inode.h
3958 --- linux-3.9.5/fs/jfs/jfs_inode.h 2012-12-11 03:30:57.000000000 +0000
3959 +++ linux-3.9.5-vs2.3.6.5/fs/jfs/jfs_inode.h 2013-05-31 14:47:11.000000000 +0000
3960 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
3961 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
3962 int fh_len, int fh_type);
3963 extern void jfs_set_inode_flags(struct inode *);
3964 +extern int jfs_sync_flags(struct inode *, int, int);
3965 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
3966 extern int jfs_setattr(struct dentry *, struct iattr *);
3968 diff -NurpP --minimal linux-3.9.5/fs/jfs/namei.c linux-3.9.5-vs2.3.6.5/fs/jfs/namei.c
3969 --- linux-3.9.5/fs/jfs/namei.c 2012-12-11 03:30:57.000000000 +0000
3970 +++ linux-3.9.5-vs2.3.6.5/fs/jfs/namei.c 2013-05-31 14:47:11.000000000 +0000
3972 #include <linux/ctype.h>
3973 #include <linux/quotaops.h>
3974 #include <linux/exportfs.h>
3975 +#include <linux/vs_tag.h>
3976 #include "jfs_incore.h"
3977 #include "jfs_superblock.h"
3978 #include "jfs_inode.h"
3979 @@ -1461,6 +1462,7 @@ static struct dentry *jfs_lookup(struct
3980 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
3983 + dx_propagate_tag(nd, ip);
3984 return d_splice_alias(ip, dentry);
3987 @@ -1525,6 +1527,7 @@ const struct inode_operations jfs_dir_in
3988 #ifdef CONFIG_JFS_POSIX_ACL
3989 .get_acl = jfs_get_acl,
3991 + .sync_flags = jfs_sync_flags,
3994 const struct file_operations jfs_dir_operations = {
3995 diff -NurpP --minimal linux-3.9.5/fs/jfs/super.c linux-3.9.5-vs2.3.6.5/fs/jfs/super.c
3996 --- linux-3.9.5/fs/jfs/super.c 2013-05-31 13:45:24.000000000 +0000
3997 +++ linux-3.9.5-vs2.3.6.5/fs/jfs/super.c 2013-05-31 14:47:11.000000000 +0000
3998 @@ -199,7 +199,8 @@ enum {
3999 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4000 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4001 Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4002 - Opt_discard, Opt_nodiscard, Opt_discard_minblk
4003 + Opt_discard, Opt_nodiscard, Opt_discard_minblk,
4004 + Opt_tag, Opt_notag, Opt_tagid
4007 static const match_table_t tokens = {
4008 @@ -209,6 +210,10 @@ static const match_table_t tokens = {
4009 {Opt_resize, "resize=%u"},
4010 {Opt_resize_nosize, "resize"},
4011 {Opt_errors, "errors=%s"},
4013 + {Opt_notag, "notag"},
4014 + {Opt_tagid, "tagid=%u"},
4015 + {Opt_tag, "tagxid"},
4016 {Opt_ignore, "noquota"},
4017 {Opt_ignore, "quota"},
4018 {Opt_usrquota, "usrquota"},
4019 @@ -385,7 +390,20 @@ static int parse_options(char *options,
4024 +#ifndef CONFIG_TAGGING_NONE
4026 + *flag |= JFS_TAGGED;
4029 + *flag &= JFS_TAGGED;
4032 +#ifdef CONFIG_PROPAGATE
4035 + *flag |= JFS_TAGGED;
4039 printk("jfs: Unrecognized mount option \"%s\" "
4040 " or missing value\n", p);
4041 @@ -417,6 +435,12 @@ static int jfs_remount(struct super_bloc
4045 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4046 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4052 if (sb->s_flags & MS_RDONLY) {
4053 pr_err("JFS: resize requires volume" \
4054 @@ -502,6 +526,9 @@ static int jfs_fill_super(struct super_b
4055 #ifdef CONFIG_JFS_POSIX_ACL
4056 sb->s_flags |= MS_POSIXACL;
4058 + /* map mount option tagxid */
4059 + if (sbi->flag & JFS_TAGGED)
4060 + sb->s_flags |= MS_TAGGED;
4063 pr_err("resize option for remount only\n");
4064 diff -NurpP --minimal linux-3.9.5/fs/libfs.c linux-3.9.5-vs2.3.6.5/fs/libfs.c
4065 --- linux-3.9.5/fs/libfs.c 2013-02-19 13:58:48.000000000 +0000
4066 +++ linux-3.9.5-vs2.3.6.5/fs/libfs.c 2013-05-31 14:47:11.000000000 +0000
4067 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
4068 * both impossible due to the lock on directory.
4071 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4072 +static inline int do_dcache_readdir_filter(struct file *filp,
4073 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4075 struct dentry *dentry = filp->f_path.dentry;
4076 struct dentry *cursor = filp->private_data;
4077 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
4078 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4079 struct dentry *next;
4080 next = list_entry(p, struct dentry, d_u.d_child);
4081 + if (filter && !filter(next))
4083 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4084 if (!simple_positive(next)) {
4085 spin_unlock(&next->d_lock);
4086 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
4090 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4092 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4095 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4096 + int (*filter)(struct dentry *))
4098 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4101 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4104 @@ -981,6 +995,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4105 EXPORT_SYMBOL(dcache_dir_lseek);
4106 EXPORT_SYMBOL(dcache_dir_open);
4107 EXPORT_SYMBOL(dcache_readdir);
4108 +EXPORT_SYMBOL(dcache_readdir_filter);
4109 EXPORT_SYMBOL(generic_read_dir);
4110 EXPORT_SYMBOL(mount_pseudo);
4111 EXPORT_SYMBOL(simple_write_begin);
4112 diff -NurpP --minimal linux-3.9.5/fs/locks.c linux-3.9.5-vs2.3.6.5/fs/locks.c
4113 --- linux-3.9.5/fs/locks.c 2013-05-31 13:45:24.000000000 +0000
4114 +++ linux-3.9.5-vs2.3.6.5/fs/locks.c 2013-06-12 23:49:08.000000000 +0000
4116 #include <linux/time.h>
4117 #include <linux/rcupdate.h>
4118 #include <linux/pid_namespace.h>
4119 +#include <linux/vs_base.h>
4120 +#include <linux/vs_limit.h>
4122 #include <asm/uaccess.h>
4124 @@ -184,11 +186,17 @@ static void locks_init_lock_heads(struct
4125 /* Allocate an empty lock structure. */
4126 struct file_lock *locks_alloc_lock(void)
4128 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4129 + struct file_lock *fl;
4132 - locks_init_lock_heads(fl);
4133 + if (!vx_locks_avail(1))
4136 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4139 + locks_init_lock_heads(fl);
4144 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4145 @@ -212,6 +220,7 @@ void locks_free_lock(struct file_lock *f
4146 BUG_ON(!list_empty(&fl->fl_block));
4147 BUG_ON(!list_empty(&fl->fl_link));
4150 locks_release_private(fl);
4151 kmem_cache_free(filelock_cache, fl);
4153 @@ -221,6 +230,7 @@ void locks_init_lock(struct file_lock *f
4155 memset(fl, 0, sizeof(struct file_lock));
4156 locks_init_lock_heads(fl);
4160 EXPORT_SYMBOL(locks_init_lock);
4161 @@ -261,6 +271,7 @@ void locks_copy_lock(struct file_lock *n
4162 new->fl_file = fl->fl_file;
4163 new->fl_ops = fl->fl_ops;
4164 new->fl_lmops = fl->fl_lmops;
4165 + new->fl_xid = fl->fl_xid;
4167 locks_copy_private(new, fl);
4169 @@ -299,6 +310,11 @@ static int flock_make_lock(struct file *
4170 fl->fl_flags = FL_FLOCK;
4172 fl->fl_end = OFFSET_MAX;
4174 + vxd_assert(filp->f_xid == vx_current_xid(),
4175 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4176 + fl->fl_xid = filp->f_xid;
4181 @@ -438,6 +454,7 @@ static int lease_init(struct file *filp,
4183 fl->fl_owner = current->files;
4184 fl->fl_pid = current->tgid;
4185 + fl->fl_xid = vx_current_xid();
4188 fl->fl_flags = FL_LEASE;
4189 @@ -457,6 +474,11 @@ static struct file_lock *lease_alloc(str
4191 return ERR_PTR(error);
4193 + fl->fl_xid = vx_current_xid();
4195 + vxd_assert(filp->f_xid == fl->fl_xid,
4196 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4198 error = lease_init(filp, type, fl);
4200 locks_free_lock(fl);
4201 @@ -753,6 +775,7 @@ static int flock_lock_file(struct file *
4205 + new_fl->fl_xid = -1;
4207 for_each_lock(inode, before) {
4208 struct file_lock *fl = *before;
4209 @@ -773,6 +796,7 @@ find_conflict:
4211 locks_copy_lock(new_fl, request);
4212 locks_insert_lock(before, new_fl);
4213 + vx_locks_inc(new_fl);
4217 @@ -783,7 +807,8 @@ out:
4221 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4222 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4223 + struct file_lock *conflock, vxid_t xid)
4225 struct file_lock *fl;
4226 struct file_lock *new_fl = NULL;
4227 @@ -793,6 +818,8 @@ static int __posix_lock_file(struct inod
4228 struct file_lock **before;
4229 int error, added = 0;
4231 + vxd_assert(xid == vx_current_xid(),
4232 + "xid(%d) == current(%d)", xid, vx_current_xid());
4234 * We may need two file_lock structures for this operation,
4235 * so we get them in advance to avoid races.
4236 @@ -803,7 +830,11 @@ static int __posix_lock_file(struct inod
4237 (request->fl_type != F_UNLCK ||
4238 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4239 new_fl = locks_alloc_lock();
4240 + new_fl->fl_xid = xid;
4241 + vx_locks_inc(new_fl);
4242 new_fl2 = locks_alloc_lock();
4243 + new_fl2->fl_xid = xid;
4244 + vx_locks_inc(new_fl2);
4248 @@ -1002,7 +1033,8 @@ static int __posix_lock_file(struct inod
4249 int posix_lock_file(struct file *filp, struct file_lock *fl,
4250 struct file_lock *conflock)
4252 - return __posix_lock_file(file_inode(filp), fl, conflock);
4253 + return __posix_lock_file(file_inode(filp),
4254 + fl, conflock, filp->f_xid);
4256 EXPORT_SYMBOL(posix_lock_file);
4258 @@ -1092,7 +1124,7 @@ int locks_mandatory_area(int read_write,
4259 fl.fl_end = offset + count - 1;
4262 - error = __posix_lock_file(inode, &fl, NULL);
4263 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4264 if (error != FILE_LOCK_DEFERRED)
4266 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4267 @@ -1397,6 +1429,7 @@ int generic_add_lease(struct file *filp,
4270 locks_insert_lock(before, lease);
4271 + vx_locks_inc(lease);
4275 @@ -1836,6 +1869,11 @@ int fcntl_setlk(unsigned int fd, struct
4276 if (file_lock == NULL)
4279 + vxd_assert(filp->f_xid == vx_current_xid(),
4280 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4281 + file_lock->fl_xid = filp->f_xid;
4282 + vx_locks_inc(file_lock);
4285 * This might block, so we do it before checking the inode.
4287 @@ -1954,6 +1992,11 @@ int fcntl_setlk64(unsigned int fd, struc
4288 if (file_lock == NULL)
4291 + vxd_assert(filp->f_xid == vx_current_xid(),
4292 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4293 + file_lock->fl_xid = filp->f_xid;
4294 + vx_locks_inc(file_lock);
4297 * This might block, so we do it before checking the inode.
4299 @@ -2219,8 +2262,11 @@ static int locks_show(struct seq_file *f
4301 lock_get_status(f, fl, *((loff_t *)f->private), "");
4303 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4304 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4305 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4307 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4312 diff -NurpP --minimal linux-3.9.5/fs/mount.h linux-3.9.5-vs2.3.6.5/fs/mount.h
4313 --- linux-3.9.5/fs/mount.h 2013-02-19 13:58:48.000000000 +0000
4314 +++ linux-3.9.5-vs2.3.6.5/fs/mount.h 2013-06-12 23:49:08.000000000 +0000
4315 @@ -49,6 +49,7 @@ struct mount {
4316 int mnt_expiry_mark; /* true if marked for expiry */
4319 + vtag_t mnt_tag; /* tagging used for vfsmount */
4322 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
4323 diff -NurpP --minimal linux-3.9.5/fs/namei.c linux-3.9.5-vs2.3.6.5/fs/namei.c
4324 --- linux-3.9.5/fs/namei.c 2013-06-11 12:22:39.000000000 +0000
4325 +++ linux-3.9.5-vs2.3.6.5/fs/namei.c 2013-06-12 23:49:08.000000000 +0000
4327 #include <linux/device_cgroup.h>
4328 #include <linux/fs_struct.h>
4329 #include <linux/posix_acl.h>
4330 +#include <linux/proc_fs.h>
4331 +#include <linux/vserver/inode.h>
4332 +#include <linux/vs_base.h>
4333 +#include <linux/vs_tag.h>
4334 +#include <linux/vs_cowbl.h>
4335 +#include <linux/vs_device.h>
4336 +#include <linux/vs_context.h>
4337 +#include <linux/pid_namespace.h>
4338 #include <asm/uaccess.h>
4340 #include "internal.h"
4341 @@ -266,6 +274,89 @@ static int check_acl(struct inode *inode
4345 +static inline int dx_barrier(const struct inode *inode)
4347 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4348 + vxwprintk_task(1, "did hit the barrier.");
4354 +static int __dx_permission(const struct inode *inode, int mask)
4356 + if (dx_barrier(inode))
4359 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4360 + /* devpts is xid tagged */
4361 + if (S_ISDIR(inode->i_mode) ||
4362 + vx_check((vxid_t)i_tag_read(inode), VS_IDENT | VS_WATCH_P))
4365 + /* just pretend we didn't find anything */
4368 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4369 + struct proc_dir_entry *de = PDE(inode);
4371 + if (de && !vx_hide_check(0, de->vx_flags))
4374 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4376 + struct task_struct *tsk;
4378 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4379 + vx_flags(VXF_STATE_SETUP, 0))
4382 + pid = PROC_I(inode)->pid;
4387 + tsk = pid_task(pid, PIDTYPE_PID);
4388 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4389 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4391 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4392 + rcu_read_unlock();
4395 + rcu_read_unlock();
4398 + /* FIXME: Should we block some entries here? */
4403 + if (dx_notagcheck(inode->i_sb) ||
4404 + dx_check((vxid_t)i_tag_read(inode),
4405 + DX_HOSTID | DX_ADMIN | DX_WATCH | DX_IDENT))
4413 +int dx_permission(const struct inode *inode, int mask)
4415 + int ret = __dx_permission(inode, mask);
4416 + if (unlikely(ret)) {
4417 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4418 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4421 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4422 + mask, inode->i_sb->s_id, inode,
4423 + i_tag_read(inode), inode->i_ino);
4429 * This does the basic permission checking
4431 @@ -388,10 +479,14 @@ int __inode_permission(struct inode *ino
4433 * Nobody gets write access to an immutable file.
4435 - if (IS_IMMUTABLE(inode))
4436 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4440 + retval = dx_permission(inode, mask);
4444 retval = do_inode_permission(inode, mask);
4447 @@ -1238,7 +1333,8 @@ static void follow_dotdot(struct nameida
4449 if (nd->path.dentry == nd->root.dentry &&
4450 nd->path.mnt == nd->root.mnt) {
4452 + /* for sane '/' avoid follow_mount() */
4455 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4456 /* rare case of legitimate dget_parent()... */
4457 @@ -1383,6 +1479,9 @@ static int lookup_fast(struct nameidata
4462 + /* FIXME: check dx permission */
4465 path->dentry = dentry;
4466 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4467 @@ -1413,6 +1512,8 @@ unlazy:
4471 + /* FIXME: check dx permission */
4474 path->dentry = dentry;
4475 err = follow_managed(path, nd->flags);
4476 @@ -2237,7 +2338,7 @@ static int may_delete(struct inode *dir,
4479 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4480 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4481 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4484 if (!S_ISDIR(victim->d_inode->i_mode))
4485 @@ -2316,19 +2417,25 @@ int vfs_create(struct inode *dir, struct
4488 int error = may_create(dir, dentry);
4491 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
4495 if (!dir->i_op->create)
4496 return -EACCES; /* shouldn't it be ENOSYS? */
4499 error = security_inode_create(dir, dentry, mode);
4502 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
4505 error = dir->i_op->create(dir, dentry, mode, want_excl);
4507 fsnotify_create(dir, dentry);
4509 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
4513 @@ -2363,6 +2470,15 @@ static int may_open(struct path *path, i
4517 +#ifdef CONFIG_VSERVER_COWBL
4518 + if (IS_COW(inode) &&
4519 + ((flag & O_ACCMODE) != O_RDONLY)) {
4520 + if (IS_COW_LINK(inode))
4522 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4523 + mark_inode_dirty(inode);
4526 error = inode_permission(inode, acc_mode);
4529 @@ -2865,6 +2981,16 @@ finish_open:
4531 finish_open_created:
4532 error = may_open(&nd->path, acc_mode, open_flag);
4533 +#ifdef CONFIG_VSERVER_COWBL
4534 + if (error == -EMLINK) {
4535 + struct dentry *dentry;
4536 + dentry = cow_break_link(name->name);
4537 + if (IS_ERR(dentry))
4538 + error = PTR_ERR(dentry);
4545 file->f_path.mnt = nd->path.mnt;
4546 @@ -2929,6 +3055,7 @@ static struct file *path_openat(int dfd,
4551 file = get_empty_filp();
4554 @@ -2965,6 +3092,16 @@ static struct file *path_openat(int dfd,
4555 error = do_last(nd, &path, file, op, &opened, pathname);
4556 put_link(nd, &link, cookie);
4559 +#ifdef CONFIG_VSERVER_COWBL
4560 + if (error == -EMLINK) {
4561 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4562 + path_put(&nd->root);
4569 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4570 path_put(&nd->root);
4571 @@ -3079,6 +3216,11 @@ struct dentry *kern_path_create(int dfd,
4575 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
4576 + path->dentry, path->dentry->d_name.len,
4577 + path->dentry->d_name.name, dentry,
4578 + dentry->d_name.len, dentry->d_name.name,
4579 + path->dentry->d_inode);
4583 @@ -3573,7 +3715,7 @@ int vfs_link(struct dentry *old_dentry,
4585 * A link to an append-only or immutable file cannot be created.
4587 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4588 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4590 if (!dir->i_op->link)
4592 @@ -3976,6 +4118,286 @@ int vfs_follow_link(struct nameidata *nd
4593 return __vfs_follow_link(nd, link);
4597 +#ifdef CONFIG_VSERVER_COWBL
4600 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4604 + return do_splice_direct(in, &ppos, out, len, 0);
4607 +struct dentry *cow_break_link(const char *pathname)
4609 + int ret, mode, pathlen, redo = 0, drop = 1;
4610 + struct nameidata old_nd, dir_nd;
4611 + struct path dir_path, *old_path, *new_path;
4612 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4613 + struct file *old_file;
4614 + struct file *new_file;
4615 + char *to, *path, pad='\251';
4618 + vxdprintk(VXD_CBIT(misc, 1),
4619 + "cow_break_link(" VS_Q("%s") ")", pathname);
4621 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4626 + /* old_nd.path will have refs to dentry and mnt */
4627 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4628 + vxdprintk(VXD_CBIT(misc, 2),
4629 + "do_path_lookup(old): %d", ret);
4631 + goto out_free_path;
4633 + /* dentry/mnt refs handed over to old_path */
4634 + old_path = &old_nd.path;
4635 + /* no explicit reference for old_dentry here */
4636 + old_dentry = old_path->dentry;
4638 + mode = old_dentry->d_inode->i_mode;
4639 + to = d_path(old_path, path, PATH_MAX-2);
4640 + pathlen = strlen(to);
4641 + vxdprintk(VXD_CBIT(misc, 2),
4642 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4644 + old_dentry->d_name.len, old_dentry->d_name.name,
4645 + old_dentry->d_name.len);
4647 + to[pathlen + 1] = 0;
4649 + new_dentry = NULL;
4650 + to[pathlen] = pad--;
4652 + if (pad <= '\240')
4655 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4657 + /* dir_nd.path will have refs to dentry and mnt */
4658 + ret = do_path_lookup(AT_FDCWD, to,
4659 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4660 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4664 + /* this puppy downs the dir inode mutex if successful.
4665 + dir_path will hold refs to dentry and mnt and
4666 + we'll have write access to the mnt */
4667 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
4668 + if (!new_dentry || IS_ERR(new_dentry)) {
4669 + path_put(&dir_nd.path);
4670 + vxdprintk(VXD_CBIT(misc, 2),
4671 + "kern_path_create(new) failed with %ld",
4672 + PTR_ERR(new_dentry));
4675 + vxdprintk(VXD_CBIT(misc, 2),
4676 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
4678 + new_dentry->d_name.len, new_dentry->d_name.name,
4679 + new_dentry->d_name.len);
4681 + /* take a reference on new_dentry */
4684 + /* dentry/mnt refs handed over to new_path */
4685 + new_path = &dir_path;
4687 + /* dentry for old/new dir */
4688 + dir = dir_nd.path.dentry;
4690 + /* give up reference on dir */
4691 + dput(new_path->dentry);
4693 + /* new_dentry already has a reference */
4694 + new_path->dentry = new_dentry;
4696 + ret = vfs_create(dir->d_inode, new_dentry, mode, 1);
4697 + vxdprintk(VXD_CBIT(misc, 2),
4698 + "vfs_create(new): %d", ret);
4699 + if (ret == -EEXIST) {
4700 + path_put(&dir_nd.path);
4701 + mutex_unlock(&dir->d_inode->i_mutex);
4702 + mnt_drop_write(new_path->mnt);
4703 + path_put(new_path);
4704 + new_dentry = NULL;
4708 + goto out_unlock_new;
4710 + /* drop out early, ret passes ENOENT */
4712 + if ((redo = d_unhashed(old_dentry)))
4713 + goto out_unlock_new;
4715 + /* doesn't change refs for old_path */
4716 + old_file = dentry_open(old_path, O_RDONLY, current_cred());
4717 + vxdprintk(VXD_CBIT(misc, 2),
4718 + "dentry_open(old): %p", old_file);
4719 + if (IS_ERR(old_file)) {
4720 + ret = PTR_ERR(old_file);
4721 + goto out_unlock_new;
4724 + /* doesn't change refs for new_path */
4725 + new_file = dentry_open(new_path, O_WRONLY, current_cred());
4726 + vxdprintk(VXD_CBIT(misc, 2),
4727 + "dentry_open(new): %p", new_file);
4728 + if (IS_ERR(new_file)) {
4729 + ret = PTR_ERR(new_file);
4730 + goto out_fput_old;
4733 + /* unlock the inode mutex from kern_path_create() */
4734 + mutex_unlock(&dir->d_inode->i_mutex);
4736 + /* drop write access to mnt */
4737 + mnt_drop_write(new_path->mnt);
4741 + size = i_size_read(old_file->f_dentry->d_inode);
4742 + ret = do_cow_splice(old_file, new_file, size);
4743 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4745 + goto out_fput_both;
4746 + } else if (ret < size) {
4748 + goto out_fput_both;
4750 + struct inode *old_inode = old_dentry->d_inode;
4751 + struct inode *new_inode = new_dentry->d_inode;
4752 + struct iattr attr = {
4753 + .ia_uid = old_inode->i_uid,
4754 + .ia_gid = old_inode->i_gid,
4755 + .ia_valid = ATTR_UID | ATTR_GID
4758 + setattr_copy(new_inode, &attr);
4759 + mark_inode_dirty(new_inode);
4762 + /* lock rename mutex */
4763 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4765 + /* drop out late */
4767 + if ((redo = d_unhashed(old_dentry)))
4770 + vxdprintk(VXD_CBIT(misc, 2),
4771 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4772 + new_dentry->d_name.len, new_dentry->d_name.name,
4773 + new_dentry->d_name.len,
4774 + old_dentry->d_name.len, old_dentry->d_name.name,
4775 + old_dentry->d_name.len);
4776 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4777 + old_dentry->d_parent->d_inode, old_dentry);
4778 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4781 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4784 + vxdprintk(VXD_CBIT(misc, 3),
4785 + "fput(new_file=%p[#%ld])", new_file,
4786 + atomic_long_read(&new_file->f_count));
4790 + vxdprintk(VXD_CBIT(misc, 3),
4791 + "fput(old_file=%p[#%ld])", old_file,
4792 + atomic_long_read(&old_file->f_count));
4796 + /* drop references from dir_nd.path */
4797 + path_put(&dir_nd.path);
4800 + /* unlock the inode mutex from kern_path_create() */
4801 + mutex_unlock(&dir->d_inode->i_mutex);
4803 + /* drop write access to mnt */
4804 + mnt_drop_write(new_path->mnt);
4810 + /* error path cleanup */
4811 + vfs_unlink(dir->d_inode, new_dentry);
4815 + goto out_rel_both;
4817 + /* lookup dentry once again
4818 + old_nd.path will be freed as old_path in out_rel_old */
4819 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4821 + goto out_rel_both;
4823 + /* drop reference on new_dentry */
4825 + new_dentry = old_path->dentry;
4827 + vxdprintk(VXD_CBIT(misc, 2),
4828 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4830 + new_dentry->d_name.len, new_dentry->d_name.name,
4831 + new_dentry->d_name.len);
4835 + path_put(new_path);
4837 + path_put(old_path);
4843 + new_dentry = ERR_PTR(ret);
4845 + vxdprintk(VXD_CBIT(misc, 3),
4846 + "cow_break_link returning with %p", new_dentry);
4847 + return new_dentry;
4852 +int vx_info_mnt_namespace(struct mnt_namespace *ns, char *buffer)
4855 + struct vfsmount *vmnt;
4856 + char *pstr, *root;
4859 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
4863 + vmnt = &ns->root->mnt;
4865 + path.dentry = vmnt->mnt_root;
4866 + root = d_path(&path, pstr, PATH_MAX - 2);
4867 + length = sprintf(buffer + length,
4868 + "Namespace:\t%p [#%u]\n"
4869 + "RootPath:\t%s\n",
4870 + ns, atomic_read(&ns->count),
4876 /* get the link contents into pagecache */
4877 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4879 @@ -4099,3 +4521,4 @@ EXPORT_SYMBOL(vfs_symlink);
4880 EXPORT_SYMBOL(vfs_unlink);
4881 EXPORT_SYMBOL(dentry_unhash);
4882 EXPORT_SYMBOL(generic_readlink);
4883 +EXPORT_SYMBOL(vx_info_mnt_namespace);
4884 diff -NurpP --minimal linux-3.9.5/fs/namespace.c linux-3.9.5-vs2.3.6.5/fs/namespace.c
4885 --- linux-3.9.5/fs/namespace.c 2013-06-11 12:22:39.000000000 +0000
4886 +++ linux-3.9.5-vs2.3.6.5/fs/namespace.c 2013-06-12 23:49:08.000000000 +0000
4888 #include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */
4889 #include <linux/uaccess.h>
4890 #include <linux/proc_fs.h>
4891 +#include <linux/vs_base.h>
4892 +#include <linux/vs_context.h>
4893 +#include <linux/vs_tag.h>
4894 +#include <linux/vserver/space.h>
4895 +#include <linux/vserver/global.h>
4897 #include "internal.h"
4899 @@ -751,6 +756,10 @@ vfs_kern_mount(struct file_system_type *
4901 return ERR_PTR(-ENODEV);
4903 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
4904 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
4905 + return ERR_PTR(-EPERM);
4907 mnt = alloc_vfsmnt(name);
4909 return ERR_PTR(-ENOMEM);
4910 @@ -807,6 +816,7 @@ static struct mount *clone_mnt(struct mo
4911 mnt->mnt.mnt_root = dget(root);
4912 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
4913 mnt->mnt_parent = mnt;
4914 + mnt->mnt_tag = old->mnt_tag;
4915 br_write_lock(&vfsmount_lock);
4916 list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
4917 br_write_unlock(&vfsmount_lock);
4918 @@ -1639,6 +1649,7 @@ static int do_change_type(struct path *p
4922 + // mnt->mnt_flags = mnt_flags;
4924 br_write_lock(&vfsmount_lock);
4925 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
4926 @@ -1654,12 +1665,14 @@ static int do_change_type(struct path *p
4927 * do loopback mount.
4929 static int do_loopback(struct path *path, const char *old_name,
4931 + vtag_t tag, unsigned long flags, int mnt_flags)
4933 LIST_HEAD(umount_list);
4934 struct path old_path;
4935 struct mount *mnt = NULL, *old;
4936 + int recurse = flags & MS_REC;
4939 if (!old_name || !*old_name)
4941 err = kern_path(old_name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &old_path);
4942 @@ -1733,7 +1746,7 @@ static int change_mount_flags(struct vfs
4943 * on it - tough luck.
4945 static int do_remount(struct path *path, int flags, int mnt_flags,
4947 + void *data, vxid_t xid)
4950 struct super_block *sb = path->mnt->mnt_sb;
4951 @@ -2046,7 +2059,6 @@ void mark_mounts_for_expiry(struct list_
4953 br_write_unlock(&vfsmount_lock);
4954 up_write(&namespace_sem);
4956 release_mounts(&umounts);
4959 @@ -2218,6 +2230,7 @@ long do_mount(const char *dev_name, cons
4966 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
4967 @@ -2247,6 +2260,12 @@ long do_mount(const char *dev_name, cons
4968 if (!(flags & MS_NOATIME))
4969 mnt_flags |= MNT_RELATIME;
4971 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
4972 + /* FIXME: bind and re-mounts get the tag flag? */
4973 + if (flags & (MS_BIND|MS_REMOUNT))
4974 + flags |= MS_TAGID;
4977 /* Separate the per-mountpoint flags */
4978 if (flags & MS_NOSUID)
4979 mnt_flags |= MNT_NOSUID;
4980 @@ -2263,15 +2282,17 @@ long do_mount(const char *dev_name, cons
4981 if (flags & MS_RDONLY)
4982 mnt_flags |= MNT_READONLY;
4984 + if (!vx_capable(CAP_SYS_ADMIN, VXC_DEV_MOUNT))
4985 + mnt_flags |= MNT_NODEV;
4986 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
4987 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
4990 if (flags & MS_REMOUNT)
4991 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
4994 else if (flags & MS_BIND)
4995 - retval = do_loopback(&path, dev_name, flags & MS_REC);
4996 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
4997 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
4998 retval = do_change_type(&path, flags);
4999 else if (flags & MS_MOVE)
5000 @@ -2380,6 +2401,7 @@ static struct mnt_namespace *dup_mnt_ns(
5001 q = next_mnt(q, new);
5003 up_write(&namespace_sem);
5004 + atomic_inc(&vs_global_mnt_ns);
5008 @@ -2575,9 +2597,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5010 new_mnt = real_mount(new.mnt);
5011 root_mnt = real_mount(root.mnt);
5012 - if (IS_MNT_SHARED(real_mount(old.mnt)) ||
5013 + if ((IS_MNT_SHARED(real_mount(old.mnt)) ||
5014 IS_MNT_SHARED(new_mnt->mnt_parent) ||
5015 - IS_MNT_SHARED(root_mnt->mnt_parent))
5016 + IS_MNT_SHARED(root_mnt->mnt_parent)) &&
5017 + !vx_flags(VXF_STATE_SETUP, 0))
5019 if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
5021 @@ -2703,6 +2726,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5022 br_write_unlock(&vfsmount_lock);
5023 up_write(&namespace_sem);
5024 release_mounts(&umount_list);
5025 + atomic_dec(&vs_global_mnt_ns);
5029 diff -NurpP --minimal linux-3.9.5/fs/nfs/client.c linux-3.9.5-vs2.3.6.5/fs/nfs/client.c
5030 --- linux-3.9.5/fs/nfs/client.c 2013-05-31 13:45:24.000000000 +0000
5031 +++ linux-3.9.5-vs2.3.6.5/fs/nfs/client.c 2013-05-31 14:47:11.000000000 +0000
5032 @@ -682,6 +682,9 @@ int nfs_init_server_rpcclient(struct nfs
5033 if (server->flags & NFS_MOUNT_SOFT)
5034 server->client->cl_softrtry = 1;
5036 + server->client->cl_tag = 0;
5037 + if (server->flags & NFS_MOUNT_TAGGED)
5038 + server->client->cl_tag = 1;
5041 EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient);
5042 @@ -861,6 +864,10 @@ static void nfs_server_set_fsinfo(struct
5043 server->acdirmin = server->acdirmax = 0;
5046 + /* FIXME: needs fsinfo
5047 + if (server->flags & NFS_MOUNT_TAGGED)
5048 + sb->s_flags |= MS_TAGGED; */
5050 server->maxfilesize = fsinfo->maxfilesize;
5052 server->time_delta = fsinfo->time_delta;
5053 diff -NurpP --minimal linux-3.9.5/fs/nfs/dir.c linux-3.9.5-vs2.3.6.5/fs/nfs/dir.c
5054 --- linux-3.9.5/fs/nfs/dir.c 2013-05-31 13:45:24.000000000 +0000
5055 +++ linux-3.9.5-vs2.3.6.5/fs/nfs/dir.c 2013-05-31 14:47:11.000000000 +0000
5057 #include <linux/sched.h>
5058 #include <linux/kmemleak.h>
5059 #include <linux/xattr.h>
5060 +#include <linux/vs_tag.h>
5062 #include "delegation.h"
5064 @@ -1300,6 +1301,7 @@ struct dentry *nfs_lookup(struct inode *
5065 /* Success: notify readdir to use READDIRPLUS */
5066 nfs_advise_use_readdirplus(dir);
5068 + dx_propagate_tag(nd, inode);
5070 res = d_materialise_unique(dentry, inode);
5072 diff -NurpP --minimal linux-3.9.5/fs/nfs/inode.c linux-3.9.5-vs2.3.6.5/fs/nfs/inode.c
5073 --- linux-3.9.5/fs/nfs/inode.c 2013-05-31 13:45:24.000000000 +0000
5074 +++ linux-3.9.5-vs2.3.6.5/fs/nfs/inode.c 2013-06-03 19:32:53.000000000 +0000
5076 #include <linux/compat.h>
5077 #include <linux/freezer.h>
5078 #include <linux/crc32.h>
5079 +#include <linux/vs_tag.h>
5081 #include <asm/uaccess.h>
5083 @@ -290,6 +291,8 @@ nfs_fhget(struct super_block *sb, struct
5084 if (inode->i_state & I_NEW) {
5085 struct nfs_inode *nfsi = NFS_I(inode);
5086 unsigned long now = jiffies;
5090 /* We set i_ino for the few things that still rely on it,
5091 * such as stat(2) */
5092 @@ -334,8 +337,8 @@ nfs_fhget(struct super_block *sb, struct
5093 inode->i_version = 0;
5096 - inode->i_uid = make_kuid(&init_user_ns, -2);
5097 - inode->i_gid = make_kgid(&init_user_ns, -2);
5098 + kuid = make_kuid(&init_user_ns, -2);
5099 + kgid = make_kgid(&init_user_ns, -2);
5100 inode->i_blocks = 0;
5101 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5103 @@ -369,11 +372,11 @@ nfs_fhget(struct super_block *sb, struct
5104 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5105 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5106 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5107 - inode->i_uid = fattr->uid;
5108 + kuid = fattr->uid;
5109 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5110 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5111 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5112 - inode->i_gid = fattr->gid;
5113 + kgid = fattr->gid;
5114 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5115 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5116 if (fattr->valid & NFS_ATTR_FATTR_BLOCKS_USED)
5117 @@ -384,6 +387,11 @@ nfs_fhget(struct super_block *sb, struct
5119 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5121 + inode->i_uid = INOTAG_KUID(DX_TAG(inode), kuid, kgid);
5122 + inode->i_gid = INOTAG_KGID(DX_TAG(inode), kuid, kgid);
5123 + inode->i_tag = INOTAG_KTAG(DX_TAG(inode), kuid, kgid, GLOBAL_ROOT_TAG);
5124 + /* maybe fattr->xid someday */
5126 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5127 nfsi->attrtimeo_timestamp = now;
5128 nfsi->access_cache = RB_ROOT;
5129 @@ -505,6 +513,8 @@ void nfs_setattr_update_inode(struct ino
5130 inode->i_uid = attr->ia_uid;
5131 if ((attr->ia_valid & ATTR_GID) != 0)
5132 inode->i_gid = attr->ia_gid;
5133 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5134 + inode->i_tag = attr->ia_tag;
5135 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5136 spin_unlock(&inode->i_lock);
5138 @@ -980,7 +990,9 @@ static int nfs_check_inode_attributes(st
5139 struct nfs_inode *nfsi = NFS_I(inode);
5140 loff_t cur_size, new_isize;
5141 unsigned long invalid = 0;
5147 if (nfs_have_delegated_attributes(inode))
5149 @@ -1005,13 +1017,18 @@ static int nfs_check_inode_attributes(st
5150 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5153 + kuid = INOTAG_KUID(DX_TAG(inode), fattr->uid, fattr->gid);
5154 + kgid = INOTAG_KGID(DX_TAG(inode), fattr->uid, fattr->gid);
5155 + ktag = INOTAG_KTAG(DX_TAG(inode), fattr->uid, fattr->gid, GLOBAL_ROOT_TAG);
5157 /* Have any file permissions changed? */
5158 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5159 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5160 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && !uid_eq(inode->i_uid, fattr->uid))
5161 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && !uid_eq(inode->i_uid, kuid))
5162 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5163 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && !gid_eq(inode->i_gid, fattr->gid))
5164 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && !gid_eq(inode->i_gid, kgid))
5165 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5166 + /* maybe check for tag too? */
5168 /* Has the link count changed? */
5169 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5170 @@ -1317,6 +1334,9 @@ static int nfs_update_inode(struct inode
5171 unsigned long invalid = 0;
5172 unsigned long now = jiffies;
5173 unsigned long save_cache_validity;
5178 dfprintk(VFS, "NFS: %s(%s/%ld fh_crc=0x%08x ct=%d info=0x%x)\n",
5179 __func__, inode->i_sb->s_id, inode->i_ino,
5180 @@ -1418,6 +1438,9 @@ static int nfs_update_inode(struct inode
5181 | NFS_INO_REVAL_PAGECACHE
5182 | NFS_INO_REVAL_FORCED);
5184 + kuid = TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5185 + kgid = TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5186 + ktag = TAGINO_KTAG(DX_TAG(inode), inode->i_tag);
5188 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5189 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5190 @@ -1460,6 +1483,10 @@ static int nfs_update_inode(struct inode
5191 | NFS_INO_INVALID_ACL
5192 | NFS_INO_REVAL_FORCED);
5194 + inode->i_uid = INOTAG_KUID(DX_TAG(inode), kuid, kgid);
5195 + inode->i_gid = INOTAG_KGID(DX_TAG(inode), kuid, kgid);
5196 + inode->i_tag = INOTAG_KTAG(DX_TAG(inode), kuid, kgid, ktag);
5198 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5199 if (inode->i_nlink != fattr->nlink) {
5200 invalid |= NFS_INO_INVALID_ATTR;
5201 diff -NurpP --minimal linux-3.9.5/fs/nfs/nfs3xdr.c linux-3.9.5-vs2.3.6.5/fs/nfs/nfs3xdr.c
5202 --- linux-3.9.5/fs/nfs/nfs3xdr.c 2013-05-31 13:45:24.000000000 +0000
5203 +++ linux-3.9.5-vs2.3.6.5/fs/nfs/nfs3xdr.c 2013-06-03 19:33:10.000000000 +0000
5205 #include <linux/nfs3.h>
5206 #include <linux/nfs_fs.h>
5207 #include <linux/nfsacl.h>
5208 +#include <linux/vs_tag.h>
5209 #include "internal.h"
5211 #define NFSDBG_FACILITY NFSDBG_XDR
5212 @@ -558,7 +559,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5216 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5217 +static void encode_sattr3(struct xdr_stream *xdr,
5218 + const struct iattr *attr, int tag)
5222 @@ -590,15 +592,19 @@ static void encode_sattr3(struct xdr_str
5226 - if (attr->ia_valid & ATTR_UID) {
5227 + if (attr->ia_valid & ATTR_UID ||
5228 + (tag && (attr->ia_valid & ATTR_TAG))) {
5230 - *p++ = cpu_to_be32(from_kuid(&init_user_ns, attr->ia_uid));
5231 + *p++ = cpu_to_be32(from_kuid(&init_user_ns,
5232 + TAGINO_KUID(tag, attr->ia_uid, attr->ia_tag)));
5236 - if (attr->ia_valid & ATTR_GID) {
5237 + if (attr->ia_valid & ATTR_GID ||
5238 + (tag && (attr->ia_valid & ATTR_TAG))) {
5240 - *p++ = cpu_to_be32(from_kgid(&init_user_ns, attr->ia_gid));
5241 + *p++ = cpu_to_be32(from_kgid(&init_user_ns,
5242 + TAGINO_KGID(tag, attr->ia_gid, attr->ia_tag)));
5246 @@ -887,7 +893,7 @@ static void nfs3_xdr_enc_setattr3args(st
5247 const struct nfs3_sattrargs *args)
5249 encode_nfs_fh3(xdr, args->fh);
5250 - encode_sattr3(xdr, args->sattr);
5251 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5252 encode_sattrguard3(xdr, args);
5255 @@ -1037,13 +1043,13 @@ static void nfs3_xdr_enc_write3args(stru
5258 static void encode_createhow3(struct xdr_stream *xdr,
5259 - const struct nfs3_createargs *args)
5260 + const struct nfs3_createargs *args, int tag)
5262 encode_uint32(xdr, args->createmode);
5263 switch (args->createmode) {
5264 case NFS3_CREATE_UNCHECKED:
5265 case NFS3_CREATE_GUARDED:
5266 - encode_sattr3(xdr, args->sattr);
5267 + encode_sattr3(xdr, args->sattr, tag);
5269 case NFS3_CREATE_EXCLUSIVE:
5270 encode_createverf3(xdr, args->verifier);
5271 @@ -1058,7 +1064,7 @@ static void nfs3_xdr_enc_create3args(str
5272 const struct nfs3_createargs *args)
5274 encode_diropargs3(xdr, args->fh, args->name, args->len);
5275 - encode_createhow3(xdr, args);
5276 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5280 @@ -1074,7 +1080,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5281 const struct nfs3_mkdirargs *args)
5283 encode_diropargs3(xdr, args->fh, args->name, args->len);
5284 - encode_sattr3(xdr, args->sattr);
5285 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5289 @@ -1091,9 +1097,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5292 static void encode_symlinkdata3(struct xdr_stream *xdr,
5293 - const struct nfs3_symlinkargs *args)
5294 + const struct nfs3_symlinkargs *args, int tag)
5296 - encode_sattr3(xdr, args->sattr);
5297 + encode_sattr3(xdr, args->sattr, tag);
5298 encode_nfspath3(xdr, args->pages, args->pathlen);
5301 @@ -1102,7 +1108,7 @@ static void nfs3_xdr_enc_symlink3args(st
5302 const struct nfs3_symlinkargs *args)
5304 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5305 - encode_symlinkdata3(xdr, args);
5306 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5310 @@ -1130,24 +1136,24 @@ static void nfs3_xdr_enc_symlink3args(st
5313 static void encode_devicedata3(struct xdr_stream *xdr,
5314 - const struct nfs3_mknodargs *args)
5315 + const struct nfs3_mknodargs *args, int tag)
5317 - encode_sattr3(xdr, args->sattr);
5318 + encode_sattr3(xdr, args->sattr, tag);
5319 encode_specdata3(xdr, args->rdev);
5322 static void encode_mknoddata3(struct xdr_stream *xdr,
5323 - const struct nfs3_mknodargs *args)
5324 + const struct nfs3_mknodargs *args, int tag)
5326 encode_ftype3(xdr, args->type);
5327 switch (args->type) {
5330 - encode_devicedata3(xdr, args);
5331 + encode_devicedata3(xdr, args, tag);
5335 - encode_sattr3(xdr, args->sattr);
5336 + encode_sattr3(xdr, args->sattr, tag);
5340 @@ -1162,7 +1168,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5341 const struct nfs3_mknodargs *args)
5343 encode_diropargs3(xdr, args->fh, args->name, args->len);
5344 - encode_mknoddata3(xdr, args);
5345 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5349 diff -NurpP --minimal linux-3.9.5/fs/nfs/super.c linux-3.9.5-vs2.3.6.5/fs/nfs/super.c
5350 --- linux-3.9.5/fs/nfs/super.c 2013-05-31 13:45:24.000000000 +0000
5351 +++ linux-3.9.5-vs2.3.6.5/fs/nfs/super.c 2013-05-31 15:41:34.000000000 +0000
5353 #include <linux/parser.h>
5354 #include <linux/nsproxy.h>
5355 #include <linux/rcupdate.h>
5356 +#include <linux/vs_tag.h>
5358 #include <asm/uaccess.h>
5360 @@ -103,6 +104,7 @@ enum {
5366 /* Mount options that take string arguments */
5368 @@ -115,6 +117,9 @@ enum {
5369 /* Special mount options */
5370 Opt_userspace, Opt_deprecated, Opt_sloppy,
5372 + /* Linux-VServer tagging options */
5373 + Opt_tag, Opt_notag,
5378 @@ -184,6 +189,10 @@ static const match_table_t nfs_mount_opt
5379 { Opt_fscache_uniq, "fsc=%s" },
5380 { Opt_local_lock, "local_lock=%s" },
5382 + { Opt_tag, "tag" },
5383 + { Opt_notag, "notag" },
5384 + { Opt_tagid, "tagid=%u" },
5386 /* The following needs to be listed after all other options */
5387 { Opt_nfsvers, "v%s" },
5389 @@ -635,6 +644,7 @@ static void nfs_show_mount_options(struc
5390 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5391 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5392 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5393 + { NFS_MOUNT_TAGGED, ",tag", "" },
5396 const struct proc_nfs_info *nfs_infop;
5397 @@ -1261,6 +1271,14 @@ static int nfs_parse_mount_options(char
5398 case Opt_nomigration:
5399 mnt->options &= NFS_OPTION_MIGRATION;
5401 +#ifndef CONFIG_TAGGING_NONE
5403 + mnt->flags |= NFS_MOUNT_TAGGED;
5406 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5411 * options that take numeric values
5412 @@ -1347,6 +1365,12 @@ static int nfs_parse_mount_options(char
5413 goto out_invalid_value;
5414 mnt->minorversion = option;
5416 +#ifdef CONFIG_PROPAGATE
5419 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5424 * options that take text values
5425 diff -NurpP --minimal linux-3.9.5/fs/nfsd/auth.c linux-3.9.5-vs2.3.6.5/fs/nfsd/auth.c
5426 --- linux-3.9.5/fs/nfsd/auth.c 2013-05-31 13:45:24.000000000 +0000
5427 +++ linux-3.9.5-vs2.3.6.5/fs/nfsd/auth.c 2013-06-12 23:49:08.000000000 +0000
5430 #include <linux/sched.h>
5431 #include <linux/user_namespace.h>
5432 +#include <linux/vs_tag.h>
5436 @@ -37,6 +38,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5438 new->fsuid = rqstp->rq_cred.cr_uid;
5439 new->fsgid = rqstp->rq_cred.cr_gid;
5440 + /* FIXME: this desperately needs a tag :)
5441 + new->xid = (vxid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5444 rqgi = rqstp->rq_cred.cr_group_info;
5446 diff -NurpP --minimal linux-3.9.5/fs/nfsd/nfs3xdr.c linux-3.9.5-vs2.3.6.5/fs/nfsd/nfs3xdr.c
5447 --- linux-3.9.5/fs/nfsd/nfs3xdr.c 2013-05-31 13:45:24.000000000 +0000
5448 +++ linux-3.9.5-vs2.3.6.5/fs/nfsd/nfs3xdr.c 2013-06-03 19:57:43.000000000 +0000
5451 #include <linux/namei.h>
5452 #include <linux/sunrpc/svc_xprt.h>
5453 +#include <linux/vs_tag.h>
5457 @@ -98,6 +99,8 @@ static __be32 *
5458 decode_sattr3(__be32 *p, struct iattr *iap)
5461 + kuid_t kuid = GLOBAL_ROOT_UID;
5462 + kgid_t kgid = GLOBAL_ROOT_GID;
5466 @@ -106,15 +109,18 @@ decode_sattr3(__be32 *p, struct iattr *i
5467 iap->ia_mode = ntohl(*p++);
5470 - iap->ia_uid = make_kuid(&init_user_ns, ntohl(*p++));
5471 + kuid = make_kuid(&init_user_ns, ntohl(*p++));
5472 if (uid_valid(iap->ia_uid))
5473 iap->ia_valid |= ATTR_UID;
5476 - iap->ia_gid = make_kgid(&init_user_ns, ntohl(*p++));
5477 + kgid = make_kgid(&init_user_ns, ntohl(*p++));
5478 if (gid_valid(iap->ia_gid))
5479 iap->ia_valid |= ATTR_GID;
5481 + iap->ia_uid = INOTAG_KUID(DX_TAG_NFSD, kuid, kgid);
5482 + iap->ia_gid = INOTAG_KGID(DX_TAG_NFSD, kuid, kgid);
5483 + iap->ia_tag = INOTAG_KTAG(DX_TAG_NFSD, kuid, kgid, GLOBAL_ROOT_TAG);
5487 @@ -170,8 +176,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5488 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5489 *p++ = htonl((u32) stat->mode);
5490 *p++ = htonl((u32) stat->nlink);
5491 - *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
5492 - *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
5493 + *p++ = htonl((u32) from_kuid(&init_user_ns,
5494 + TAGINO_KUID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5495 + stat->uid, stat->tag)));
5496 + *p++ = htonl((u32) from_kgid(&init_user_ns,
5497 + TAGINO_KGID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5498 + stat->gid, stat->tag)));
5499 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5500 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5502 diff -NurpP --minimal linux-3.9.5/fs/nfsd/nfs4xdr.c linux-3.9.5-vs2.3.6.5/fs/nfsd/nfs4xdr.c
5503 --- linux-3.9.5/fs/nfsd/nfs4xdr.c 2013-06-11 12:22:39.000000000 +0000
5504 +++ linux-3.9.5-vs2.3.6.5/fs/nfsd/nfs4xdr.c 2013-06-03 19:33:44.000000000 +0000
5506 #include <linux/utsname.h>
5507 #include <linux/pagemap.h>
5508 #include <linux/sunrpc/svcauth_gss.h>
5509 +#include <linux/vs_tag.h>
5513 @@ -2349,14 +2350,18 @@ out_acl:
5514 WRITE32(stat.nlink);
5516 if (bmval1 & FATTR4_WORD1_OWNER) {
5517 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5518 + status = nfsd4_encode_user(rqstp,
5519 + TAGINO_KUID(DX_TAG(dentry->d_inode),
5520 + stat.uid, stat.tag), &p, &buflen);
5521 if (status == nfserr_resource)
5526 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5527 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5528 + status = nfsd4_encode_group(rqstp,
5529 + TAGINO_KGID(DX_TAG(dentry->d_inode),
5530 + stat.gid, stat.tag), &p, &buflen);
5531 if (status == nfserr_resource)
5534 diff -NurpP --minimal linux-3.9.5/fs/nfsd/nfsxdr.c linux-3.9.5-vs2.3.6.5/fs/nfsd/nfsxdr.c
5535 --- linux-3.9.5/fs/nfsd/nfsxdr.c 2013-05-31 13:45:24.000000000 +0000
5536 +++ linux-3.9.5-vs2.3.6.5/fs/nfsd/nfsxdr.c 2013-06-03 19:56:35.000000000 +0000
5541 +#include <linux/vs_tag.h>
5543 #define NFSDDBG_FACILITY NFSDDBG_XDR
5545 @@ -89,6 +90,8 @@ static __be32 *
5546 decode_sattr(__be32 *p, struct iattr *iap)
5549 + kuid_t kuid = GLOBAL_ROOT_UID;
5550 + kgid_t kgid = GLOBAL_ROOT_GID;
5554 @@ -101,15 +104,18 @@ decode_sattr(__be32 *p, struct iattr *ia
5557 if ((tmp = ntohl(*p++)) != (u32)-1) {
5558 - iap->ia_uid = make_kuid(&init_user_ns, tmp);
5559 + kuid = make_kuid(&init_user_ns, tmp);
5560 if (uid_valid(iap->ia_uid))
5561 iap->ia_valid |= ATTR_UID;
5563 if ((tmp = ntohl(*p++)) != (u32)-1) {
5564 - iap->ia_gid = make_kgid(&init_user_ns, tmp);
5565 + kgid = make_kgid(&init_user_ns, tmp);
5566 if (gid_valid(iap->ia_gid))
5567 iap->ia_valid |= ATTR_GID;
5569 + iap->ia_uid = INOTAG_KUID(DX_TAG_NFSD, kuid, kgid);
5570 + iap->ia_gid = INOTAG_KGID(DX_TAG_NFSD, kuid, kgid);
5571 + iap->ia_tag = INOTAG_KTAG(DX_TAG_NFSD, kuid, kgid, GLOBAL_ROOT_TAG);
5572 if ((tmp = ntohl(*p++)) != (u32)-1) {
5573 iap->ia_valid |= ATTR_SIZE;
5575 @@ -154,8 +160,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5576 *p++ = htonl(nfs_ftypes[type >> 12]);
5577 *p++ = htonl((u32) stat->mode);
5578 *p++ = htonl((u32) stat->nlink);
5579 - *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
5580 - *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
5581 + *p++ = htonl((u32) from_kuid(&init_user_ns,
5582 + TAGINO_KUID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5583 + *p++ = htonl((u32) from_kgid(&init_user_ns,
5584 + TAGINO_KGID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5586 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5587 *p++ = htonl(NFS_MAXPATHLEN);
5588 diff -NurpP --minimal linux-3.9.5/fs/ocfs2/dlmglue.c linux-3.9.5-vs2.3.6.5/fs/ocfs2/dlmglue.c
5589 --- linux-3.9.5/fs/ocfs2/dlmglue.c 2013-05-31 13:45:24.000000000 +0000
5590 +++ linux-3.9.5-vs2.3.6.5/fs/ocfs2/dlmglue.c 2013-06-03 19:59:20.000000000 +0000
5591 @@ -2047,6 +2047,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5592 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5593 lvb->lvb_iuid = cpu_to_be32(i_uid_read(inode));
5594 lvb->lvb_igid = cpu_to_be32(i_gid_read(inode));
5595 + lvb->lvb_itag = cpu_to_be16(i_tag_read(inode));
5596 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5597 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5598 lvb->lvb_iatime_packed =
5599 @@ -2097,6 +2098,7 @@ static void ocfs2_refresh_inode_from_lvb
5601 i_uid_write(inode, be32_to_cpu(lvb->lvb_iuid));
5602 i_gid_write(inode, be32_to_cpu(lvb->lvb_igid));
5603 + i_tag_write(inode, be16_to_cpu(lvb->lvb_itag));
5604 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5605 set_nlink(inode, be16_to_cpu(lvb->lvb_inlink));
5606 ocfs2_unpack_timespec(&inode->i_atime,
5607 diff -NurpP --minimal linux-3.9.5/fs/ocfs2/dlmglue.h linux-3.9.5-vs2.3.6.5/fs/ocfs2/dlmglue.h
5608 --- linux-3.9.5/fs/ocfs2/dlmglue.h 2012-12-11 03:30:57.000000000 +0000
5609 +++ linux-3.9.5-vs2.3.6.5/fs/ocfs2/dlmglue.h 2013-05-31 14:47:11.000000000 +0000
5610 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5613 __be32 lvb_igeneration;
5614 - __be32 lvb_reserved2;
5616 + __be16 lvb_reserved2;
5619 #define OCFS2_QINFO_LVB_VERSION 1
5620 diff -NurpP --minimal linux-3.9.5/fs/ocfs2/file.c linux-3.9.5-vs2.3.6.5/fs/ocfs2/file.c
5621 --- linux-3.9.5/fs/ocfs2/file.c 2013-05-31 13:45:24.000000000 +0000
5622 +++ linux-3.9.5-vs2.3.6.5/fs/ocfs2/file.c 2013-05-31 14:47:11.000000000 +0000
5623 @@ -1124,7 +1124,7 @@ int ocfs2_setattr(struct dentry *dentry,
5624 attr->ia_valid &= ~ATTR_SIZE;
5626 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5627 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5628 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5629 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5632 diff -NurpP --minimal linux-3.9.5/fs/ocfs2/inode.c linux-3.9.5-vs2.3.6.5/fs/ocfs2/inode.c
5633 --- linux-3.9.5/fs/ocfs2/inode.c 2013-05-31 13:45:24.000000000 +0000
5634 +++ linux-3.9.5-vs2.3.6.5/fs/ocfs2/inode.c 2013-05-31 20:39:47.000000000 +0000
5636 #include <linux/highmem.h>
5637 #include <linux/pagemap.h>
5638 #include <linux/quotaops.h>
5639 +#include <linux/vs_tag.h>
5641 #include <asm/byteorder.h>
5643 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5645 unsigned int flags = OCFS2_I(inode)->ip_attr;
5647 - inode->i_flags &= ~(S_IMMUTABLE |
5648 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5649 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5651 if (flags & OCFS2_IMMUTABLE_FL)
5652 inode->i_flags |= S_IMMUTABLE;
5653 + if (flags & OCFS2_IXUNLINK_FL)
5654 + inode->i_flags |= S_IXUNLINK;
5656 if (flags & OCFS2_SYNC_FL)
5657 inode->i_flags |= S_SYNC;
5658 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5659 inode->i_flags |= S_NOATIME;
5660 if (flags & OCFS2_DIRSYNC_FL)
5661 inode->i_flags |= S_DIRSYNC;
5663 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5665 + if (flags & OCFS2_BARRIER_FL)
5666 + inode->i_vflags |= V_BARRIER;
5667 + if (flags & OCFS2_COW_FL)
5668 + inode->i_vflags |= V_COW;
5671 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5672 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5674 unsigned int flags = oi->vfs_inode.i_flags;
5675 + unsigned int vflags = oi->vfs_inode.i_vflags;
5677 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5678 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5679 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5680 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5682 + if (flags & S_IMMUTABLE)
5683 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5684 + if (flags & S_IXUNLINK)
5685 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5687 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5688 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5690 oi->ip_attr |= OCFS2_SYNC_FL;
5691 if (flags & S_APPEND)
5692 oi->ip_attr |= OCFS2_APPEND_FL;
5693 - if (flags & S_IMMUTABLE)
5694 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5695 if (flags & S_NOATIME)
5696 oi->ip_attr |= OCFS2_NOATIME_FL;
5697 if (flags & S_DIRSYNC)
5698 oi->ip_attr |= OCFS2_DIRSYNC_FL;
5700 + if (vflags & V_BARRIER)
5701 + oi->ip_attr |= OCFS2_BARRIER_FL;
5702 + if (vflags & V_COW)
5703 + oi->ip_attr |= OCFS2_COW_FL;
5706 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
5707 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
5708 struct super_block *sb;
5709 struct ocfs2_super *osb;
5716 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
5717 inode->i_generation = le32_to_cpu(fe->i_generation);
5718 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
5719 inode->i_mode = le16_to_cpu(fe->i_mode);
5720 - i_uid_write(inode, le32_to_cpu(fe->i_uid));
5721 - i_gid_write(inode, le32_to_cpu(fe->i_gid));
5722 + uid = le32_to_cpu(fe->i_uid);
5723 + gid = le32_to_cpu(fe->i_gid);
5724 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), uid, gid));
5725 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), uid, gid));
5726 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), uid, gid,
5727 + /* le16_to_cpu(raw_inode->i_raw_tag) */ 0));
5729 /* Fast symlinks will have i_size but no allocated clusters. */
5730 if (S_ISLNK(inode->i_mode) && !fe->i_clusters) {
5731 diff -NurpP --minimal linux-3.9.5/fs/ocfs2/inode.h linux-3.9.5-vs2.3.6.5/fs/ocfs2/inode.h
5732 --- linux-3.9.5/fs/ocfs2/inode.h 2012-12-11 03:30:57.000000000 +0000
5733 +++ linux-3.9.5-vs2.3.6.5/fs/ocfs2/inode.h 2013-05-31 14:47:11.000000000 +0000
5734 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
5736 void ocfs2_set_inode_flags(struct inode *inode);
5737 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
5738 +int ocfs2_sync_flags(struct inode *inode, int, int);
5740 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
5742 diff -NurpP --minimal linux-3.9.5/fs/ocfs2/ioctl.c linux-3.9.5-vs2.3.6.5/fs/ocfs2/ioctl.c
5743 --- linux-3.9.5/fs/ocfs2/ioctl.c 2013-05-31 13:45:24.000000000 +0000
5744 +++ linux-3.9.5-vs2.3.6.5/fs/ocfs2/ioctl.c 2013-05-31 14:47:11.000000000 +0000
5745 @@ -76,7 +76,41 @@ static int ocfs2_get_inode_attr(struct i
5749 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5750 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
5752 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5753 + struct buffer_head *bh = NULL;
5754 + handle_t *handle = NULL;
5757 + status = ocfs2_inode_lock(inode, &bh, 1);
5759 + mlog_errno(status);
5762 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5763 + if (IS_ERR(handle)) {
5764 + status = PTR_ERR(handle);
5765 + mlog_errno(status);
5769 + inode->i_flags = flags;
5770 + inode->i_vflags = vflags;
5771 + ocfs2_get_inode_flags(OCFS2_I(inode));
5773 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
5775 + mlog_errno(status);
5777 + ocfs2_commit_trans(osb, handle);
5779 + ocfs2_inode_unlock(inode, 1);
5784 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5787 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
5788 @@ -101,6 +135,11 @@ static int ocfs2_set_inode_attr(struct i
5789 if (!S_ISDIR(inode->i_mode))
5790 flags &= ~OCFS2_DIRSYNC_FL;
5792 + if (IS_BARRIER(inode)) {
5793 + vxwprintk_task(1, "messing with the barrier.");
5797 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5798 if (IS_ERR(handle)) {
5799 status = PTR_ERR(handle);
5800 @@ -879,6 +918,7 @@ bail:
5805 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5807 struct inode *inode = file_inode(filp);
5808 diff -NurpP --minimal linux-3.9.5/fs/ocfs2/namei.c linux-3.9.5-vs2.3.6.5/fs/ocfs2/namei.c
5809 --- linux-3.9.5/fs/ocfs2/namei.c 2013-05-31 13:45:24.000000000 +0000
5810 +++ linux-3.9.5-vs2.3.6.5/fs/ocfs2/namei.c 2013-06-03 20:00:35.000000000 +0000
5812 #include <linux/slab.h>
5813 #include <linux/highmem.h>
5814 #include <linux/quotaops.h>
5815 +#include <linux/vs_tag.h>
5817 #include <cluster/masklog.h>
5819 @@ -475,6 +476,7 @@ static int __ocfs2_mknod_locked(struct i
5820 struct ocfs2_dinode *fe = NULL;
5821 struct ocfs2_extent_list *fel;
5827 @@ -512,8 +514,13 @@ static int __ocfs2_mknod_locked(struct i
5828 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
5829 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
5830 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
5831 - fe->i_uid = cpu_to_le32(i_uid_read(inode));
5832 - fe->i_gid = cpu_to_le32(i_gid_read(inode));
5834 + ktag = make_ktag(&init_user_ns, dx_current_fstag(osb->sb));
5835 + fe->i_uid = cpu_to_le32(from_kuid(&init_user_ns,
5836 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, ktag)));
5837 + fe->i_gid = cpu_to_le32(from_kgid(&init_user_ns,
5838 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, ktag)));
5839 + inode->i_tag = ktag; /* is this correct? */
5840 fe->i_mode = cpu_to_le16(inode->i_mode);
5841 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
5842 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
5843 diff -NurpP --minimal linux-3.9.5/fs/ocfs2/ocfs2.h linux-3.9.5-vs2.3.6.5/fs/ocfs2/ocfs2.h
5844 --- linux-3.9.5/fs/ocfs2/ocfs2.h 2012-12-11 03:30:57.000000000 +0000
5845 +++ linux-3.9.5-vs2.3.6.5/fs/ocfs2/ocfs2.h 2013-05-31 14:47:11.000000000 +0000
5846 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
5848 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
5849 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
5850 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
5853 #define OCFS2_OSB_SOFT_RO 0x0001
5854 diff -NurpP --minimal linux-3.9.5/fs/ocfs2/ocfs2_fs.h linux-3.9.5-vs2.3.6.5/fs/ocfs2/ocfs2_fs.h
5855 --- linux-3.9.5/fs/ocfs2/ocfs2_fs.h 2012-12-11 03:30:57.000000000 +0000
5856 +++ linux-3.9.5-vs2.3.6.5/fs/ocfs2/ocfs2_fs.h 2013-05-31 14:47:11.000000000 +0000
5857 @@ -266,6 +266,11 @@
5858 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
5859 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
5861 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
5863 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
5864 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
5866 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
5867 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
5869 diff -NurpP --minimal linux-3.9.5/fs/ocfs2/super.c linux-3.9.5-vs2.3.6.5/fs/ocfs2/super.c
5870 --- linux-3.9.5/fs/ocfs2/super.c 2013-05-31 13:45:25.000000000 +0000
5871 +++ linux-3.9.5-vs2.3.6.5/fs/ocfs2/super.c 2013-05-31 14:47:11.000000000 +0000
5872 @@ -185,6 +185,7 @@ enum {
5876 + Opt_tag, Opt_notag, Opt_tagid,
5880 @@ -216,6 +217,9 @@ static const match_table_t tokens = {
5881 {Opt_coherency_full, "coherency=full"},
5882 {Opt_resv_level, "resv_level=%u"},
5883 {Opt_dir_resv_level, "dir_resv_level=%u"},
5885 + {Opt_notag, "notag"},
5886 + {Opt_tagid, "tagid=%u"},
5890 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
5894 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
5895 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
5897 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
5901 /* We're going to/from readonly mode. */
5902 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
5903 /* Disable quota accounting before remounting RO */
5904 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
5906 ocfs2_complete_mount_recovery(osb);
5908 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
5909 + sb->s_flags |= MS_TAGGED;
5911 if (ocfs2_mount_local(osb))
5912 snprintf(nodestr, sizeof(nodestr), "local");
5914 @@ -1504,6 +1518,20 @@ static int ocfs2_parse_options(struct su
5915 option < OCFS2_MAX_RESV_LEVEL)
5916 mopt->dir_resv_level = option;
5918 +#ifndef CONFIG_TAGGING_NONE
5920 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
5923 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
5926 +#ifdef CONFIG_PROPAGATE
5929 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
5934 "Unrecognized mount option \"%s\" "
5935 diff -NurpP --minimal linux-3.9.5/fs/open.c linux-3.9.5-vs2.3.6.5/fs/open.c
5936 --- linux-3.9.5/fs/open.c 2013-05-31 13:45:25.000000000 +0000
5937 +++ linux-3.9.5-vs2.3.6.5/fs/open.c 2013-06-01 08:41:29.000000000 +0000
5939 #include <linux/ima.h>
5940 #include <linux/dnotify.h>
5941 #include <linux/compat.h>
5942 +#include <linux/vs_base.h>
5943 +#include <linux/vs_limit.h>
5944 +#include <linux/vs_tag.h>
5945 +#include <linux/vs_cowbl.h>
5946 +#include <linux/vserver/dlimit.h>
5948 #include "internal.h"
5950 @@ -67,6 +72,11 @@ long vfs_truncate(struct path *path, lof
5951 struct inode *inode;
5954 +#ifdef CONFIG_VSERVER_COWBL
5955 + error = cow_check_and_break(path);
5959 inode = path->dentry->d_inode;
5961 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
5962 @@ -532,6 +542,13 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
5963 unsigned int lookup_flags = LOOKUP_FOLLOW;
5965 error = user_path_at(dfd, filename, lookup_flags, &path);
5966 +#ifdef CONFIG_VSERVER_COWBL
5968 + error = cow_check_and_break(&path);
5974 error = chmod_common(&path, mode);
5976 @@ -564,13 +581,15 @@ static int chown_common(struct path *pat
5977 if (!uid_valid(uid))
5979 newattrs.ia_valid |= ATTR_UID;
5980 - newattrs.ia_uid = uid;
5981 + newattrs.ia_uid = make_kuid(&init_user_ns,
5982 + dx_map_uid(user));
5984 if (group != (gid_t) -1) {
5985 if (!gid_valid(gid))
5987 newattrs.ia_valid |= ATTR_GID;
5988 - newattrs.ia_gid = gid;
5989 + newattrs.ia_gid = make_kgid(&init_user_ns,
5990 + dx_map_gid(group));
5992 if (!S_ISDIR(inode->i_mode))
5993 newattrs.ia_valid |=
5994 @@ -604,6 +623,18 @@ retry:
5995 error = mnt_want_write(path.mnt);
5998 +#ifdef CONFIG_VSERVER_COWBL
5999 + error = cow_check_and_break(&path);
6002 +#ifdef CONFIG_VSERVER_COWBL
6003 + error = cow_check_and_break(&path);
6006 +#ifdef CONFIG_VSERVER_COWBL
6007 + error = cow_check_and_break(&path);
6010 error = chown_common(&path, user, group);
6011 mnt_drop_write(path.mnt);
6013 diff -NurpP --minimal linux-3.9.5/fs/proc/array.c linux-3.9.5-vs2.3.6.5/fs/proc/array.c
6014 --- linux-3.9.5/fs/proc/array.c 2013-05-31 13:45:25.000000000 +0000
6015 +++ linux-3.9.5-vs2.3.6.5/fs/proc/array.c 2013-05-31 14:47:11.000000000 +0000
6017 #include <linux/ptrace.h>
6018 #include <linux/tracehook.h>
6019 #include <linux/user_namespace.h>
6020 +#include <linux/vs_context.h>
6021 +#include <linux/vs_network.h>
6023 #include <asm/pgtable.h>
6024 #include <asm/processor.h>
6025 @@ -173,6 +175,9 @@ static inline void task_state(struct seq
6027 ppid = pid_alive(p) ?
6028 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6029 + if (unlikely(vx_current_initpid(p->pid)))
6034 struct task_struct *tracer = ptrace_parent(p);
6035 @@ -297,7 +302,7 @@ static inline void task_sig(struct seq_f
6038 static void render_cap_t(struct seq_file *m, const char *header,
6040 + struct vx_info *vxi, kernel_cap_t *a)
6044 @@ -331,10 +336,11 @@ static inline void task_cap(struct seq_f
6045 NORM_CAPS(cap_effective);
6046 NORM_CAPS(cap_bset);
6048 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6049 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6050 - render_cap_t(m, "CapEff:\t", &cap_effective);
6051 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6052 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6053 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6054 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6055 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6056 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6059 static inline void task_seccomp(struct seq_file *m, struct task_struct *p)
6060 @@ -363,6 +369,42 @@ static void task_cpus_allowed(struct seq
6064 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6065 + struct pid *pid, struct task_struct *task)
6067 + seq_printf(m, "Proxy:\t%p(%c)\n"
6075 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6076 + atomic_read(&task->nsproxy->count),
6077 + task->nsproxy->uts_ns,
6078 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6079 + task->nsproxy->ipc_ns,
6080 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6081 + task->nsproxy->mnt_ns,
6082 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6083 + task->nsproxy->pid_ns,
6084 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6085 + task->nsproxy->net_ns,
6086 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6090 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6092 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6095 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6096 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6100 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6101 struct pid *pid, struct task_struct *task)
6103 @@ -380,6 +422,7 @@ int proc_pid_status(struct seq_file *m,
6104 task_seccomp(m, task);
6105 task_cpus_allowed(m, task);
6106 cpuset_task_status_allowed(m, task);
6107 + task_vs_id(m, task);
6108 task_context_switch_counts(m, task);
6111 @@ -489,6 +532,17 @@ static int do_task_stat(struct seq_file
6112 /* convert nsec -> ticks */
6113 start_time = nsec_to_clock_t(start_time);
6115 + /* fixup start time for virt uptime */
6116 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6117 + unsigned long long bias =
6118 + current->vx_info->cvirt.bias_clock;
6120 + if (start_time > bias)
6121 + start_time -= bias;
6126 seq_printf(m, "%d (%s) %c", pid_nr_ns(pid, ns), tcomm, state);
6127 seq_put_decimal_ll(m, ' ', ppid);
6128 seq_put_decimal_ll(m, ' ', pgid);
6129 diff -NurpP --minimal linux-3.9.5/fs/proc/base.c linux-3.9.5-vs2.3.6.5/fs/proc/base.c
6130 --- linux-3.9.5/fs/proc/base.c 2013-05-31 13:45:25.000000000 +0000
6131 +++ linux-3.9.5-vs2.3.6.5/fs/proc/base.c 2013-06-12 23:49:08.000000000 +0000
6133 #include <linux/fs_struct.h>
6134 #include <linux/slab.h>
6135 #include <linux/flex_array.h>
6136 +#include <linux/vs_context.h>
6137 +#include <linux/vs_network.h>
6138 #ifdef CONFIG_HARDWALL
6139 #include <asm/hardwall.h>
6141 @@ -944,11 +946,15 @@ static ssize_t oom_adj_write(struct file
6142 oom_adj = (oom_adj * OOM_SCORE_ADJ_MAX) / -OOM_DISABLE;
6144 if (oom_adj < task->signal->oom_score_adj &&
6145 - !capable(CAP_SYS_RESOURCE)) {
6146 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6151 + /* prevent guest processes from circumventing the oom killer */
6152 + if (vx_current_xid() && (oom_adj == OOM_DISABLE))
6153 + oom_adj = OOM_ADJUST_MIN;
6156 * /proc/pid/oom_adj is provided for legacy purposes, ask users to use
6157 * /proc/pid/oom_score_adj instead.
6158 @@ -1528,6 +1534,8 @@ struct inode *proc_pid_make_inode(struct
6159 inode->i_gid = cred->egid;
6162 + /* procfs is xid tagged */
6163 + i_tag_write(inode, (vtag_t)vx_task_xid(task));
6164 security_task_to_inode(task, inode);
6167 @@ -1573,6 +1581,8 @@ int pid_getattr(struct vfsmount *mnt, st
6171 +static unsigned name_to_int(struct dentry *dentry);
6174 * Exceptional case: normally we are not allowed to unhash a busy
6175 * directory. In this case, however, we can do it - no aliasing problems
6176 @@ -1601,6 +1611,12 @@ int pid_revalidate(struct dentry *dentry
6177 task = get_proc_task(inode);
6180 + unsigned pid = name_to_int(dentry);
6182 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6183 + put_task_struct(task);
6186 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6187 task_dumpable(task)) {
6189 @@ -1617,6 +1633,7 @@ int pid_revalidate(struct dentry *dentry
6190 put_task_struct(task);
6197 @@ -2059,6 +2076,13 @@ static struct dentry *proc_pident_lookup
6201 + /* TODO: maybe we can come up with a generic approach? */
6202 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6203 + (dentry->d_name.len == 5) &&
6204 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6205 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6209 * Yes, it does not scale. And it should not. Don't add
6210 * new entries into /proc/<tgid>/ without very good reasons.
6211 @@ -2493,6 +2517,9 @@ static int proc_pid_personality(struct s
6212 static const struct file_operations proc_task_operations;
6213 static const struct inode_operations proc_task_inode_operations;
6215 +extern int proc_pid_vx_info(struct task_struct *, char *);
6216 +extern int proc_pid_nx_info(struct task_struct *, char *);
6218 static const struct pid_entry tgid_base_stuff[] = {
6219 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6220 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6221 @@ -2559,6 +2586,8 @@ static const struct pid_entry tgid_base_
6222 #ifdef CONFIG_CGROUPS
6223 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6225 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6226 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6227 INF("oom_score", S_IRUGO, proc_oom_score),
6228 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations),
6229 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6230 @@ -2583,6 +2612,7 @@ static const struct pid_entry tgid_base_
6231 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
6232 REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations),
6234 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6237 static int proc_tgid_base_readdir(struct file * filp,
6238 @@ -2770,7 +2800,7 @@ retry:
6240 pid = find_ge_pid(iter.tgid, ns);
6242 - iter.tgid = pid_nr_ns(pid, ns);
6243 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6244 iter.task = pid_task(pid, PIDTYPE_PID);
6245 /* What we to know is if the pid we have find is the
6246 * pid of a thread_group_leader. Testing for task
6247 @@ -2800,7 +2830,7 @@ static int proc_pid_fill_cache(struct fi
6248 struct tgid_iter iter)
6250 char name[PROC_NUMBUF];
6251 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6252 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6253 return proc_fill_cache(filp, dirent, filldir, name, len,
6254 proc_pid_instantiate, iter.task, NULL);
6256 @@ -2833,6 +2863,8 @@ int proc_pid_readdir(struct file * filp,
6257 __filldir = fake_filldir;
6259 filp->f_pos = iter.tgid + TGID_OFFSET;
6260 + if (!vx_proc_task_visible(iter.task))
6262 if (proc_pid_fill_cache(filp, dirent, __filldir, iter) < 0) {
6263 put_task_struct(iter.task);
6265 @@ -2993,6 +3025,8 @@ static struct dentry *proc_task_lookup(s
6266 tid = name_to_int(dentry);
6269 + if (vx_current_initpid(tid))
6272 ns = dentry->d_sb->s_fs_info;
6274 diff -NurpP --minimal linux-3.9.5/fs/proc/generic.c linux-3.9.5-vs2.3.6.5/fs/proc/generic.c
6275 --- linux-3.9.5/fs/proc/generic.c 2013-05-31 13:45:25.000000000 +0000
6276 +++ linux-3.9.5-vs2.3.6.5/fs/proc/generic.c 2013-05-31 16:13:42.000000000 +0000
6278 #include <linux/bitops.h>
6279 #include <linux/spinlock.h>
6280 #include <linux/completion.h>
6281 +#include <linux/vserver/inode.h>
6282 #include <asm/uaccess.h>
6284 #include "internal.h"
6285 @@ -409,6 +410,8 @@ struct dentry *proc_lookup_de(struct pro
6286 for (de = de->subdir; de ; de = de->next) {
6287 if (de->namelen != dentry->d_name.len)
6289 + if (!vx_hide_check(0, de->vx_flags))
6291 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6293 spin_unlock(&proc_subdir_lock);
6294 @@ -417,6 +420,8 @@ struct dentry *proc_lookup_de(struct pro
6295 return ERR_PTR(-ENOMEM);
6296 d_set_d_op(dentry, &proc_dentry_operations);
6297 d_add(dentry, inode);
6298 + /* generic proc entries belong to the host */
6299 + i_tag_write(inode, 0);
6303 @@ -485,6 +490,8 @@ int proc_readdir_de(struct proc_dir_entr
6305 /* filldir passes info to user space */
6307 + if (!vx_hide_check(0, de->vx_flags))
6309 spin_unlock(&proc_subdir_lock);
6310 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6311 de->low_ino, de->mode >> 12) < 0) {
6312 @@ -492,6 +499,7 @@ int proc_readdir_de(struct proc_dir_entr
6315 spin_lock(&proc_subdir_lock);
6320 @@ -603,6 +611,7 @@ static struct proc_dir_entry *__proc_cre
6324 + ent->vx_flags = IATTR_PROC_DEFAULT;
6325 atomic_set(&ent->count, 1);
6326 spin_lock_init(&ent->pde_unload_lock);
6327 INIT_LIST_HEAD(&ent->pde_openers);
6328 @@ -626,7 +635,8 @@ struct proc_dir_entry *proc_symlink(cons
6334 + ent->vx_flags = IATTR_PROC_SYMLINK;
6338 diff -NurpP --minimal linux-3.9.5/fs/proc/inode.c linux-3.9.5-vs2.3.6.5/fs/proc/inode.c
6339 --- linux-3.9.5/fs/proc/inode.c 2013-05-31 13:45:25.000000000 +0000
6340 +++ linux-3.9.5-vs2.3.6.5/fs/proc/inode.c 2013-05-31 14:47:11.000000000 +0000
6341 @@ -458,6 +458,8 @@ struct inode *proc_get_inode(struct supe
6342 inode->i_uid = de->uid;
6343 inode->i_gid = de->gid;
6346 + PROC_I(inode)->vx_flags = de->vx_flags;
6348 inode->i_size = de->size;
6350 diff -NurpP --minimal linux-3.9.5/fs/proc/internal.h linux-3.9.5-vs2.3.6.5/fs/proc/internal.h
6351 --- linux-3.9.5/fs/proc/internal.h 2013-05-31 13:45:25.000000000 +0000
6352 +++ linux-3.9.5-vs2.3.6.5/fs/proc/internal.h 2013-05-31 16:04:34.000000000 +0000
6354 #include <linux/sched.h>
6355 #include <linux/proc_fs.h>
6356 #include <linux/binfmts.h>
6357 +#include <linux/vs_pid.h>
6359 struct ctl_table_header;
6362 @@ -56,6 +58,9 @@ extern int proc_pid_status(struct seq_fi
6363 struct pid *pid, struct task_struct *task);
6364 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6365 struct pid *pid, struct task_struct *task);
6366 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6367 + struct pid *pid, struct task_struct *task);
6369 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6371 extern const struct file_operations proc_tid_children_operations;
6372 @@ -89,11 +94,16 @@ static inline struct pid *proc_pid(struc
6373 return PROC_I(inode)->pid;
6376 -static inline struct task_struct *get_proc_task(struct inode *inode)
6377 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6379 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6382 +static inline struct task_struct *get_proc_task(struct inode *inode)
6384 + return vx_get_proc_task(inode, proc_pid(inode));
6387 static inline int proc_fd(struct inode *inode)
6389 return PROC_I(inode)->fd;
6390 diff -NurpP --minimal linux-3.9.5/fs/proc/loadavg.c linux-3.9.5-vs2.3.6.5/fs/proc/loadavg.c
6391 --- linux-3.9.5/fs/proc/loadavg.c 2012-12-11 03:30:57.000000000 +0000
6392 +++ linux-3.9.5-vs2.3.6.5/fs/proc/loadavg.c 2013-05-31 14:47:11.000000000 +0000
6395 static int loadavg_proc_show(struct seq_file *m, void *v)
6397 + unsigned long running;
6398 + unsigned int threads;
6399 unsigned long avnrun[3];
6401 get_avenrun(avnrun, FIXED_1/200, 0);
6403 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6404 + struct vx_info *vxi = current_vx_info();
6406 + running = atomic_read(&vxi->cvirt.nr_running);
6407 + threads = atomic_read(&vxi->cvirt.nr_threads);
6409 + running = nr_running();
6410 + threads = nr_threads;
6413 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6414 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6415 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6416 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6417 - nr_running(), nr_threads,
6419 task_active_pid_ns(current)->last_pid);
6422 diff -NurpP --minimal linux-3.9.5/fs/proc/meminfo.c linux-3.9.5-vs2.3.6.5/fs/proc/meminfo.c
6423 --- linux-3.9.5/fs/proc/meminfo.c 2013-05-31 13:45:25.000000000 +0000
6424 +++ linux-3.9.5-vs2.3.6.5/fs/proc/meminfo.c 2013-05-31 16:05:39.000000000 +0000
6425 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6426 allowed = ((totalram_pages - hugetlb_total_pages())
6427 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6429 - cached = global_page_state(NR_FILE_PAGES) -
6430 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6431 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6432 total_swapcache_pages() - i.bufferram;
6435 diff -NurpP --minimal linux-3.9.5/fs/proc/root.c linux-3.9.5-vs2.3.6.5/fs/proc/root.c
6436 --- linux-3.9.5/fs/proc/root.c 2013-05-31 13:45:25.000000000 +0000
6437 +++ linux-3.9.5-vs2.3.6.5/fs/proc/root.c 2013-05-31 14:47:11.000000000 +0000
6439 #include <linux/mount.h>
6440 #include <linux/pid_namespace.h>
6441 #include <linux/parser.h>
6442 +#include <linux/vserver/inode.h>
6444 #include "internal.h"
6446 +struct proc_dir_entry *proc_virtual;
6448 +extern void proc_vx_init(void);
6450 static int proc_test_super(struct super_block *sb, void *data)
6452 return sb->s_fs_info == data;
6453 @@ -182,6 +187,7 @@ void __init proc_root_init(void)
6455 proc_mkdir("bus", NULL);
6460 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6461 @@ -248,6 +254,7 @@ struct proc_dir_entry proc_root = {
6462 .proc_iops = &proc_root_inode_operations,
6463 .proc_fops = &proc_root_operations,
6464 .parent = &proc_root,
6465 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6469 diff -NurpP --minimal linux-3.9.5/fs/proc/self.c linux-3.9.5-vs2.3.6.5/fs/proc/self.c
6470 --- linux-3.9.5/fs/proc/self.c 2013-02-19 13:58:49.000000000 +0000
6471 +++ linux-3.9.5-vs2.3.6.5/fs/proc/self.c 2013-05-31 20:57:54.000000000 +0000
6473 #include <linux/proc_fs.h>
6474 #include <linux/sched.h>
6475 #include <linux/namei.h>
6476 +#include <linux/vserver/inode.h>
6480 @@ -56,4 +57,5 @@ void __init proc_self_init(void)
6481 mode = S_IFLNK | S_IRWXUGO;
6482 proc_self_symlink = proc_create("self", mode, NULL, NULL );
6483 proc_self_symlink->proc_iops = &proc_self_inode_operations;
6484 + proc_self_symlink->vx_flags = IATTR_PROC_SYMLINK;
6486 diff -NurpP --minimal linux-3.9.5/fs/proc/stat.c linux-3.9.5-vs2.3.6.5/fs/proc/stat.c
6487 --- linux-3.9.5/fs/proc/stat.c 2012-12-11 03:30:57.000000000 +0000
6488 +++ linux-3.9.5-vs2.3.6.5/fs/proc/stat.c 2013-05-31 14:47:11.000000000 +0000
6490 #include <linux/slab.h>
6491 #include <linux/time.h>
6492 #include <linux/irqnr.h>
6493 +#include <linux/vserver/cvirt.h>
6494 #include <asm/cputime.h>
6495 #include <linux/tick.h>
6496 +#include <linux/cpuset.h>
6498 #ifndef arch_irq_stat_cpu
6499 #define arch_irq_stat_cpu(cpu) 0
6500 @@ -87,14 +89,26 @@ static int show_stat(struct seq_file *p,
6501 u64 sum_softirq = 0;
6502 unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
6503 struct timespec boottime;
6504 + cpumask_var_t cpus_allowed;
6505 + bool virt_cpu = vx_flags(VXF_VIRT_CPU, 0);
6507 user = nice = system = idle = iowait =
6508 irq = softirq = steal = 0;
6509 guest = guest_nice = 0;
6510 getboottime(&boottime);
6512 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6513 + vx_vsi_boottime(&boottime);
6516 + cpuset_cpus_allowed(current, cpus_allowed);
6518 jif = boottime.tv_sec;
6520 for_each_possible_cpu(i) {
6521 + if (virt_cpu && !cpumask_test_cpu(i, cpus_allowed))
6524 user += kcpustat_cpu(i).cpustat[CPUTIME_USER];
6525 nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE];
6526 system += kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
6527 @@ -131,6 +145,9 @@ static int show_stat(struct seq_file *p,
6530 for_each_online_cpu(i) {
6531 + if (virt_cpu && !cpumask_test_cpu(i, cpus_allowed))
6534 /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
6535 user = kcpustat_cpu(i).cpustat[CPUTIME_USER];
6536 nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE];
6537 diff -NurpP --minimal linux-3.9.5/fs/proc/uptime.c linux-3.9.5-vs2.3.6.5/fs/proc/uptime.c
6538 --- linux-3.9.5/fs/proc/uptime.c 2012-12-11 03:30:57.000000000 +0000
6539 +++ linux-3.9.5-vs2.3.6.5/fs/proc/uptime.c 2013-05-31 14:47:11.000000000 +0000
6541 #include <linux/seq_file.h>
6542 #include <linux/time.h>
6543 #include <linux/kernel_stat.h>
6544 +#include <linux/vserver/cvirt.h>
6545 #include <asm/cputime.h>
6547 static int uptime_proc_show(struct seq_file *m, void *v)
6548 @@ -25,6 +26,10 @@ static int uptime_proc_show(struct seq_f
6549 nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
6550 idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
6553 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6554 + vx_vsi_uptime(&uptime, &idle);
6556 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6557 (unsigned long) uptime.tv_sec,
6558 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6559 diff -NurpP --minimal linux-3.9.5/fs/proc_namespace.c linux-3.9.5-vs2.3.6.5/fs/proc_namespace.c
6560 --- linux-3.9.5/fs/proc_namespace.c 2012-12-11 03:30:57.000000000 +0000
6561 +++ linux-3.9.5-vs2.3.6.5/fs/proc_namespace.c 2013-05-31 17:17:53.000000000 +0000
6562 @@ -44,6 +44,8 @@ static int show_sb_opts(struct seq_file
6563 { MS_SYNCHRONOUS, ",sync" },
6564 { MS_DIRSYNC, ",dirsync" },
6565 { MS_MANDLOCK, ",mand" },
6566 + { MS_TAGGED, ",tag" },
6567 + { MS_NOTAGCHECK, ",notagcheck" },
6570 const struct proc_fs_info *fs_infop;
6571 @@ -80,6 +82,40 @@ static inline void mangle(struct seq_fil
6572 seq_escape(m, s, " \t\n\\");
6575 +#ifdef CONFIG_VSERVER_EXTRA_MNT_CHECK
6577 +static int mnt_is_reachable(struct vfsmount *vfsmnt)
6580 + struct dentry *point;
6581 + struct mount *mnt = real_mount(vfsmnt);
6582 + struct mount *root_mnt;
6585 + if (mnt == mnt->mnt_ns->root)
6588 + br_read_lock(&vfsmount_lock);
6589 + root = current->fs->root;
6590 + root_mnt = real_mount(root.mnt);
6591 + point = root.dentry;
6593 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
6594 + point = mnt->mnt_mountpoint;
6595 + mnt = mnt->mnt_parent;
6598 + ret = (mnt == root_mnt) && is_subdir(point, root.dentry);
6600 + br_read_unlock(&vfsmount_lock);
6606 +#define mnt_is_reachable(v) (1)
6609 static void show_type(struct seq_file *m, struct super_block *sb)
6611 mangle(m, sb->s_type->name);
6612 @@ -96,6 +132,17 @@ static int show_vfsmnt(struct seq_file *
6613 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6614 struct super_block *sb = mnt_path.dentry->d_sb;
6616 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6618 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6621 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6622 + mnt == current->fs->root.mnt) {
6623 + seq_puts(m, "/dev/root / ");
6627 if (sb->s_op->show_devname) {
6628 err = sb->s_op->show_devname(m, mnt_path.dentry);
6630 @@ -106,6 +153,7 @@ static int show_vfsmnt(struct seq_file *
6632 seq_path(m, &mnt_path, " \t\n\\");
6636 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6637 err = show_sb_opts(m, sb);
6638 @@ -128,6 +176,11 @@ static int show_mountinfo(struct seq_fil
6639 struct path root = p->root;
6642 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6644 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6647 seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
6648 MAJOR(sb->s_dev), MINOR(sb->s_dev));
6649 if (sb->s_op->show_path)
6650 @@ -187,6 +240,17 @@ static int show_vfsstat(struct seq_file
6651 struct super_block *sb = mnt_path.dentry->d_sb;
6654 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6656 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6659 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6660 + mnt == current->fs->root.mnt) {
6661 + seq_puts(m, "device /dev/root mounted on / ");
6666 if (sb->s_op->show_devname) {
6667 seq_puts(m, "device ");
6668 @@ -203,7 +267,7 @@ static int show_vfsstat(struct seq_file
6669 seq_puts(m, " mounted on ");
6670 seq_path(m, &mnt_path, " \t\n\\");
6674 /* file system type */
6675 seq_puts(m, "with fstype ");
6677 diff -NurpP --minimal linux-3.9.5/fs/quota/dquot.c linux-3.9.5-vs2.3.6.5/fs/quota/dquot.c
6678 --- linux-3.9.5/fs/quota/dquot.c 2013-05-31 13:45:25.000000000 +0000
6679 +++ linux-3.9.5-vs2.3.6.5/fs/quota/dquot.c 2013-05-31 14:47:11.000000000 +0000
6680 @@ -1585,6 +1585,9 @@ int __dquot_alloc_space(struct inode *in
6681 struct dquot **dquots = inode->i_dquot;
6682 int reserve = flags & DQUOT_SPACE_RESERVE;
6684 + if ((ret = dl_alloc_space(inode, number)))
6688 * First test before acquiring mutex - solves deadlocks when we
6689 * re-enter the quota code and are already holding the mutex
6690 @@ -1640,6 +1643,9 @@ int dquot_alloc_inode(const struct inode
6691 struct dquot_warn warn[MAXQUOTAS];
6692 struct dquot * const *dquots = inode->i_dquot;
6694 + if ((ret = dl_alloc_inode(inode)))
6697 /* First test before acquiring mutex - solves deadlocks when we
6698 * re-enter the quota code and are already holding the mutex */
6699 if (!dquot_active(inode))
6700 @@ -1711,6 +1717,8 @@ void __dquot_free_space(struct inode *in
6701 struct dquot **dquots = inode->i_dquot;
6702 int reserve = flags & DQUOT_SPACE_RESERVE;
6704 + dl_free_space(inode, number);
6706 /* First test before acquiring mutex - solves deadlocks when we
6707 * re-enter the quota code and are already holding the mutex */
6708 if (!dquot_active(inode)) {
6709 @@ -1755,6 +1763,8 @@ void dquot_free_inode(const struct inode
6710 struct dquot_warn warn[MAXQUOTAS];
6711 struct dquot * const *dquots = inode->i_dquot;
6713 + dl_free_inode(inode);
6715 /* First test before acquiring mutex - solves deadlocks when we
6716 * re-enter the quota code and are already holding the mutex */
6717 if (!dquot_active(inode))
6718 diff -NurpP --minimal linux-3.9.5/fs/quota/quota.c linux-3.9.5-vs2.3.6.5/fs/quota/quota.c
6719 --- linux-3.9.5/fs/quota/quota.c 2013-02-19 13:58:49.000000000 +0000
6720 +++ linux-3.9.5-vs2.3.6.5/fs/quota/quota.c 2013-05-31 14:47:11.000000000 +0000
6722 #include <linux/fs.h>
6723 #include <linux/namei.h>
6724 #include <linux/slab.h>
6725 +#include <linux/vs_context.h>
6726 #include <asm/current.h>
6727 #include <linux/uaccess.h>
6728 #include <linux/kernel.h>
6729 @@ -37,7 +38,7 @@ static int check_quotactl_permission(str
6733 - if (!capable(CAP_SYS_ADMIN))
6734 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6738 @@ -309,6 +310,46 @@ static int do_quotactl(struct super_bloc
6742 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6744 +#include <linux/vroot.h>
6745 +#include <linux/major.h>
6746 +#include <linux/module.h>
6747 +#include <linux/kallsyms.h>
6748 +#include <linux/vserver/debug.h>
6750 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6752 +static DEFINE_SPINLOCK(vroot_grb_lock);
6754 +int register_vroot_grb(vroot_grb_func *func) {
6757 + spin_lock(&vroot_grb_lock);
6758 + if (!vroot_get_real_bdev) {
6759 + vroot_get_real_bdev = func;
6762 + spin_unlock(&vroot_grb_lock);
6765 +EXPORT_SYMBOL(register_vroot_grb);
6767 +int unregister_vroot_grb(vroot_grb_func *func) {
6768 + int ret = -EINVAL;
6770 + spin_lock(&vroot_grb_lock);
6771 + if (vroot_get_real_bdev) {
6772 + vroot_get_real_bdev = NULL;
6775 + spin_unlock(&vroot_grb_lock);
6778 +EXPORT_SYMBOL(unregister_vroot_grb);
6782 /* Return 1 if 'cmd' will block on frozen filesystem */
6783 static int quotactl_cmd_write(int cmd)
6785 @@ -343,6 +384,22 @@ static struct super_block *quotactl_bloc
6788 return ERR_CAST(bdev);
6789 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6790 + if (bdev && bdev->bd_inode &&
6791 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6792 + struct block_device *bdnew = (void *)-EINVAL;
6794 + if (vroot_get_real_bdev)
6795 + bdnew = vroot_get_real_bdev(bdev);
6797 + vxdprintk(VXD_CBIT(misc, 0),
6798 + "vroot_get_real_bdev not set");
6800 + if (IS_ERR(bdnew))
6801 + return ERR_PTR(PTR_ERR(bdnew));
6805 if (quotactl_cmd_write(cmd))
6806 sb = get_super_thawed(bdev);
6808 diff -NurpP --minimal linux-3.9.5/fs/stat.c linux-3.9.5-vs2.3.6.5/fs/stat.c
6809 --- linux-3.9.5/fs/stat.c 2013-05-31 13:45:25.000000000 +0000
6810 +++ linux-3.9.5-vs2.3.6.5/fs/stat.c 2013-06-01 08:53:01.000000000 +0000
6811 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
6812 stat->nlink = inode->i_nlink;
6813 stat->uid = inode->i_uid;
6814 stat->gid = inode->i_gid;
6815 + stat->tag = inode->i_tag;
6816 stat->rdev = inode->i_rdev;
6817 stat->size = i_size_read(inode);
6818 stat->atime = inode->i_atime;
6819 diff -NurpP --minimal linux-3.9.5/fs/statfs.c linux-3.9.5-vs2.3.6.5/fs/statfs.c
6820 --- linux-3.9.5/fs/statfs.c 2013-02-19 13:58:49.000000000 +0000
6821 +++ linux-3.9.5-vs2.3.6.5/fs/statfs.c 2013-05-31 14:47:11.000000000 +0000
6823 #include <linux/statfs.h>
6824 #include <linux/security.h>
6825 #include <linux/uaccess.h>
6826 +#include <linux/vs_base.h>
6827 +#include <linux/vs_dlimit.h>
6828 #include "internal.h"
6830 static int flags_by_mnt(int mnt_flags)
6831 @@ -60,6 +62,8 @@ static int statfs_by_dentry(struct dentr
6832 retval = dentry->d_sb->s_op->statfs(dentry, buf);
6833 if (retval == 0 && buf->f_frsize == 0)
6834 buf->f_frsize = buf->f_bsize;
6835 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6836 + vx_vsi_statfs(dentry->d_sb, buf);
6840 diff -NurpP --minimal linux-3.9.5/fs/super.c linux-3.9.5-vs2.3.6.5/fs/super.c
6841 --- linux-3.9.5/fs/super.c 2013-05-31 13:45:25.000000000 +0000
6842 +++ linux-3.9.5-vs2.3.6.5/fs/super.c 2013-05-31 14:47:11.000000000 +0000
6844 #include <linux/cleancache.h>
6845 #include <linux/fsnotify.h>
6846 #include <linux/lockdep.h>
6847 +#include <linux/magic.h>
6848 +#include <linux/vs_context.h>
6849 #include "internal.h"
6852 @@ -1117,6 +1119,13 @@ mount_fs(struct file_system_type *type,
6853 WARN_ON(sb->s_bdi == &default_backing_dev_info);
6854 sb->s_flags |= MS_BORN;
6857 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
6859 + (sb->s_magic != PROC_SUPER_MAGIC) &&
6860 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
6863 error = security_sb_kern_mount(sb, flags, secdata);
6866 diff -NurpP --minimal linux-3.9.5/fs/sysfs/mount.c linux-3.9.5-vs2.3.6.5/fs/sysfs/mount.c
6867 --- linux-3.9.5/fs/sysfs/mount.c 2013-05-31 13:45:25.000000000 +0000
6868 +++ linux-3.9.5-vs2.3.6.5/fs/sysfs/mount.c 2013-05-31 14:47:11.000000000 +0000
6869 @@ -48,7 +48,7 @@ static int sysfs_fill_super(struct super
6871 sb->s_blocksize = PAGE_CACHE_SIZE;
6872 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
6873 - sb->s_magic = SYSFS_MAGIC;
6874 + sb->s_magic = SYSFS_SUPER_MAGIC;
6875 sb->s_op = &sysfs_ops;
6876 sb->s_time_gran = 1;
6878 diff -NurpP --minimal linux-3.9.5/fs/utimes.c linux-3.9.5-vs2.3.6.5/fs/utimes.c
6879 --- linux-3.9.5/fs/utimes.c 2013-02-19 13:58:49.000000000 +0000
6880 +++ linux-3.9.5-vs2.3.6.5/fs/utimes.c 2013-05-31 22:40:16.000000000 +0000
6882 #include <linux/stat.h>
6883 #include <linux/utime.h>
6884 #include <linux/syscalls.h>
6885 +#include <linux/mount.h>
6886 +#include <linux/vs_cowbl.h>
6887 #include <asm/uaccess.h>
6888 #include <asm/unistd.h>
6890 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
6893 struct iattr newattrs;
6894 - struct inode *inode = path->dentry->d_inode;
6895 + struct inode *inode;
6897 + error = cow_check_and_break(path);
6901 error = mnt_want_write(path->mnt);
6905 + inode = path->dentry->d_inode;
6907 if (times && times[0].tv_nsec == UTIME_NOW &&
6908 times[1].tv_nsec == UTIME_NOW)
6910 diff -NurpP --minimal linux-3.9.5/fs/xattr.c linux-3.9.5-vs2.3.6.5/fs/xattr.c
6911 --- linux-3.9.5/fs/xattr.c 2013-02-19 13:58:49.000000000 +0000
6912 +++ linux-3.9.5-vs2.3.6.5/fs/xattr.c 2013-05-31 14:47:11.000000000 +0000
6914 #include <linux/audit.h>
6915 #include <linux/vmalloc.h>
6916 #include <linux/posix_acl_xattr.h>
6917 +#include <linux/mount.h>
6919 #include <asm/uaccess.h>
6921 @@ -52,7 +53,7 @@ xattr_permission(struct inode *inode, co
6922 * The trusted.* namespace can only be accessed by privileged users.
6924 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
6925 - if (!capable(CAP_SYS_ADMIN))
6926 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
6927 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
6930 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_dinode.h linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_dinode.h
6931 --- linux-3.9.5/fs/xfs/xfs_dinode.h 2012-12-11 03:30:57.000000000 +0000
6932 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_dinode.h 2013-05-31 14:47:11.000000000 +0000
6933 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
6934 __be32 di_nlink; /* number of links to file */
6935 __be16 di_projid_lo; /* lower part of owner's project id */
6936 __be16 di_projid_hi; /* higher part owner's project id */
6937 - __u8 di_pad[6]; /* unused, zeroed space */
6938 + __u8 di_pad[2]; /* unused, zeroed space */
6939 + __be16 di_tag; /* context tagging */
6940 + __be16 di_vflags; /* vserver specific flags */
6941 __be16 di_flushiter; /* incremented on flush */
6942 xfs_timestamp_t di_atime; /* time last accessed */
6943 xfs_timestamp_t di_mtime; /* time last modified */
6944 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
6945 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
6946 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
6947 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
6948 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
6950 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
6951 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
6952 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
6953 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
6954 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
6955 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
6956 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
6957 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
6959 #ifdef CONFIG_XFS_RT
6960 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
6961 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
6962 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
6963 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
6964 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
6965 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
6966 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
6967 + XFS_DIFLAG_IXUNLINK)
6969 +#define XFS_DIVFLAG_BARRIER 0x01
6970 +#define XFS_DIVFLAG_COW 0x02
6972 #endif /* __XFS_DINODE_H__ */
6973 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_fs.h linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_fs.h
6974 --- linux-3.9.5/fs/xfs/xfs_fs.h 2013-02-19 13:58:49.000000000 +0000
6975 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_fs.h 2013-05-31 14:47:11.000000000 +0000
6976 @@ -67,6 +67,9 @@ struct fsxattr {
6977 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
6978 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
6979 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
6980 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
6981 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
6982 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
6983 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
6986 @@ -303,7 +306,8 @@ typedef struct xfs_bstat {
6987 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
6988 __u16 bs_forkoff; /* inode fork offset in bytes */
6989 __u16 bs_projid_hi; /* higher part of project id */
6990 - unsigned char bs_pad[10]; /* pad space, unused */
6991 + unsigned char bs_pad[8]; /* pad space, unused */
6992 + __u16 bs_tag; /* context tagging */
6993 __u32 bs_dmevmask; /* DMIG event mask */
6994 __u16 bs_dmstate; /* DMIG state info */
6995 __u16 bs_aextents; /* attribute number of extents */
6996 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_ialloc.c linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_ialloc.c
6997 --- linux-3.9.5/fs/xfs/xfs_ialloc.c 2013-05-31 13:45:25.000000000 +0000
6998 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_ialloc.c 2013-05-31 14:47:11.000000000 +0000
7000 #include "xfs_error.h"
7001 #include "xfs_bmap.h"
7005 * Allocation group level functions.
7007 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_inode.c linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_inode.c
7008 --- linux-3.9.5/fs/xfs/xfs_inode.c 2013-05-31 13:45:25.000000000 +0000
7009 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_inode.c 2013-06-03 19:35:13.000000000 +0000
7011 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
7013 #include <linux/log2.h>
7014 +#include <linux/vs_tag.h>
7018 @@ -835,15 +836,25 @@ xfs_iformat_btree(
7020 xfs_dinode_from_disk(
7022 - xfs_dinode_t *from)
7023 + xfs_dinode_t *from,
7026 + uint32_t uid, gid, tag;
7028 to->di_magic = be16_to_cpu(from->di_magic);
7029 to->di_mode = be16_to_cpu(from->di_mode);
7030 to->di_version = from ->di_version;
7031 to->di_format = from->di_format;
7032 to->di_onlink = be16_to_cpu(from->di_onlink);
7033 - to->di_uid = be32_to_cpu(from->di_uid);
7034 - to->di_gid = be32_to_cpu(from->di_gid);
7036 + uid = be32_to_cpu(from->di_uid);
7037 + gid = be32_to_cpu(from->di_gid);
7038 + tag = be16_to_cpu(from->di_tag);
7040 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7041 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7042 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7044 to->di_nlink = be32_to_cpu(from->di_nlink);
7045 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7046 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7047 @@ -865,21 +876,26 @@ xfs_dinode_from_disk(
7048 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7049 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7050 to->di_flags = be16_to_cpu(from->di_flags);
7051 + to->di_vflags = be16_to_cpu(from->di_vflags);
7052 to->di_gen = be32_to_cpu(from->di_gen);
7058 - xfs_icdinode_t *from)
7059 + xfs_icdinode_t *from,
7062 to->di_magic = cpu_to_be16(from->di_magic);
7063 to->di_mode = cpu_to_be16(from->di_mode);
7064 to->di_version = from ->di_version;
7065 to->di_format = from->di_format;
7066 to->di_onlink = cpu_to_be16(from->di_onlink);
7067 - to->di_uid = cpu_to_be32(from->di_uid);
7068 - to->di_gid = cpu_to_be32(from->di_gid);
7070 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
7071 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
7072 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
7074 to->di_nlink = cpu_to_be32(from->di_nlink);
7075 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
7076 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
7077 @@ -901,12 +917,14 @@ xfs_dinode_to_disk(
7078 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
7079 to->di_dmstate = cpu_to_be16(from->di_dmstate);
7080 to->di_flags = cpu_to_be16(from->di_flags);
7081 + to->di_vflags = cpu_to_be16(from->di_vflags);
7082 to->di_gen = cpu_to_be32(from->di_gen);
7087 - __uint16_t di_flags)
7088 + __uint16_t di_flags,
7089 + __uint16_t di_vflags)
7093 @@ -917,6 +935,8 @@ _xfs_dic2xflags(
7094 flags |= XFS_XFLAG_PREALLOC;
7095 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7096 flags |= XFS_XFLAG_IMMUTABLE;
7097 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7098 + flags |= XFS_XFLAG_IXUNLINK;
7099 if (di_flags & XFS_DIFLAG_APPEND)
7100 flags |= XFS_XFLAG_APPEND;
7101 if (di_flags & XFS_DIFLAG_SYNC)
7102 @@ -941,6 +961,10 @@ _xfs_dic2xflags(
7103 flags |= XFS_XFLAG_FILESTREAM;
7106 + if (di_vflags & XFS_DIVFLAG_BARRIER)
7107 + flags |= FS_BARRIER_FL;
7108 + if (di_vflags & XFS_DIVFLAG_COW)
7109 + flags |= FS_COW_FL;
7113 @@ -950,7 +974,7 @@ xfs_ip2xflags(
7115 xfs_icdinode_t *dic = &ip->i_d;
7117 - return _xfs_dic2xflags(dic->di_flags) |
7118 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
7119 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
7122 @@ -958,7 +982,8 @@ uint
7126 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
7127 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
7128 + be16_to_cpu(dip->di_vflags)) |
7129 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
7132 @@ -1012,7 +1037,8 @@ xfs_iread(
7133 * Otherwise, just get the truly permanent information.
7136 - xfs_dinode_from_disk(&ip->i_d, dip);
7137 + xfs_dinode_from_disk(&ip->i_d, dip,
7138 + mp->m_flags & XFS_MOUNT_TAGGED);
7139 error = xfs_iformat(ip, dip);
7142 @@ -1199,6 +1225,7 @@ xfs_ialloc(
7143 ASSERT(ip->i_d.di_nlink == nlink);
7144 ip->i_d.di_uid = current_fsuid();
7145 ip->i_d.di_gid = current_fsgid();
7146 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
7147 xfs_set_projid(ip, prid);
7148 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
7150 @@ -1258,6 +1285,7 @@ xfs_ialloc(
7151 ip->i_d.di_dmevmask = 0;
7152 ip->i_d.di_dmstate = 0;
7153 ip->i_d.di_flags = 0;
7154 + ip->i_d.di_vflags = 0;
7155 flags = XFS_ILOG_CORE;
7156 switch (mode & S_IFMT) {
7158 @@ -1952,6 +1980,7 @@ xfs_ifree(
7160 ip->i_d.di_mode = 0; /* mark incore inode as free */
7161 ip->i_d.di_flags = 0;
7162 + ip->i_d.di_vflags = 0;
7163 ip->i_d.di_dmevmask = 0;
7164 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
7165 ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
7166 @@ -2118,7 +2147,6 @@ xfs_iroot_realloc(
7172 * This is called when the amount of space needed for if_data
7173 * is increased or decreased. The change in size is indicated by
7174 @@ -2800,7 +2828,8 @@ xfs_iflush_int(
7175 * because if the inode is dirty at all the core must
7178 - xfs_dinode_to_disk(dip, &ip->i_d);
7179 + xfs_dinode_to_disk(dip, &ip->i_d,
7180 + mp->m_flags & XFS_MOUNT_TAGGED);
7182 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7183 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7184 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_inode.h linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_inode.h
7185 --- linux-3.9.5/fs/xfs/xfs_inode.h 2013-05-31 13:45:25.000000000 +0000
7186 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_inode.h 2013-05-31 14:47:11.000000000 +0000
7187 @@ -134,7 +134,9 @@ typedef struct xfs_icdinode {
7188 __uint32_t di_nlink; /* number of links to file */
7189 __uint16_t di_projid_lo; /* lower part of owner's project id */
7190 __uint16_t di_projid_hi; /* higher part of owner's project id */
7191 - __uint8_t di_pad[6]; /* unused, zeroed space */
7192 + __uint8_t di_pad[2]; /* unused, zeroed space */
7193 + __uint16_t di_tag; /* context tagging */
7194 + __uint16_t di_vflags; /* vserver specific flags */
7195 __uint16_t di_flushiter; /* incremented on flush */
7196 xfs_ictimestamp_t di_atime; /* time last accessed */
7197 xfs_ictimestamp_t di_mtime; /* time last modified */
7198 @@ -556,7 +558,7 @@ int xfs_imap_to_bp(struct xfs_mount *,
7199 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
7200 struct xfs_inode *, uint);
7201 void xfs_dinode_to_disk(struct xfs_dinode *,
7202 - struct xfs_icdinode *);
7203 + struct xfs_icdinode *, int);
7204 void xfs_idestroy_fork(struct xfs_inode *, int);
7205 void xfs_idata_realloc(struct xfs_inode *, int, int);
7206 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7207 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_ioctl.c linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_ioctl.c
7208 --- linux-3.9.5/fs/xfs/xfs_ioctl.c 2013-05-31 13:45:25.000000000 +0000
7209 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_ioctl.c 2013-05-31 14:47:11.000000000 +0000
7211 #include "xfs_bmap_btree.h"
7212 #include "xfs_dinode.h"
7213 #include "xfs_inode.h"
7214 -#include "xfs_ioctl.h"
7215 +// #include "xfs_ioctl.h"
7216 #include "xfs_rtalloc.h"
7217 #include "xfs_itable.h"
7218 #include "xfs_error.h"
7219 @@ -763,6 +763,10 @@ xfs_merge_ioc_xflags(
7220 xflags |= XFS_XFLAG_IMMUTABLE;
7222 xflags &= ~XFS_XFLAG_IMMUTABLE;
7223 + if (flags & FS_IXUNLINK_FL)
7224 + xflags |= XFS_XFLAG_IXUNLINK;
7226 + xflags &= ~XFS_XFLAG_IXUNLINK;
7227 if (flags & FS_APPEND_FL)
7228 xflags |= XFS_XFLAG_APPEND;
7230 @@ -791,6 +795,8 @@ xfs_di2lxflags(
7232 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7233 flags |= FS_IMMUTABLE_FL;
7234 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7235 + flags |= FS_IXUNLINK_FL;
7236 if (di_flags & XFS_DIFLAG_APPEND)
7237 flags |= FS_APPEND_FL;
7238 if (di_flags & XFS_DIFLAG_SYNC)
7239 @@ -851,6 +857,8 @@ xfs_set_diflags(
7240 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7241 if (xflags & XFS_XFLAG_IMMUTABLE)
7242 di_flags |= XFS_DIFLAG_IMMUTABLE;
7243 + if (xflags & XFS_XFLAG_IXUNLINK)
7244 + di_flags |= XFS_DIFLAG_IXUNLINK;
7245 if (xflags & XFS_XFLAG_APPEND)
7246 di_flags |= XFS_DIFLAG_APPEND;
7247 if (xflags & XFS_XFLAG_SYNC)
7248 @@ -893,6 +901,10 @@ xfs_diflags_to_linux(
7249 inode->i_flags |= S_IMMUTABLE;
7251 inode->i_flags &= ~S_IMMUTABLE;
7252 + if (xflags & XFS_XFLAG_IXUNLINK)
7253 + inode->i_flags |= S_IXUNLINK;
7255 + inode->i_flags &= ~S_IXUNLINK;
7256 if (xflags & XFS_XFLAG_APPEND)
7257 inode->i_flags |= S_APPEND;
7259 @@ -1397,10 +1409,18 @@ xfs_file_ioctl(
7260 case XFS_IOC_FSGETXATTRA:
7261 return xfs_ioc_fsgetxattr(ip, 1, arg);
7262 case XFS_IOC_FSSETXATTR:
7263 + if (IS_BARRIER(inode)) {
7264 + vxwprintk_task(1, "messing with the barrier.");
7265 + return -XFS_ERROR(EACCES);
7267 return xfs_ioc_fssetxattr(ip, filp, arg);
7268 case XFS_IOC_GETXFLAGS:
7269 return xfs_ioc_getxflags(ip, arg);
7270 case XFS_IOC_SETXFLAGS:
7271 + if (IS_BARRIER(inode)) {
7272 + vxwprintk_task(1, "messing with the barrier.");
7273 + return -XFS_ERROR(EACCES);
7275 return xfs_ioc_setxflags(ip, filp, arg);
7277 case XFS_IOC_FSSETDM: {
7278 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_ioctl.h linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_ioctl.h
7279 --- linux-3.9.5/fs/xfs/xfs_ioctl.h 2012-12-11 03:30:57.000000000 +0000
7280 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_ioctl.h 2013-05-31 14:47:11.000000000 +0000
7281 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7282 void __user *uhandle,
7287 + struct inode *inode,
7294 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_iops.c linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_iops.c
7295 --- linux-3.9.5/fs/xfs/xfs_iops.c 2013-06-11 12:22:40.000000000 +0000
7296 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_iops.c 2013-06-13 00:14:32.000000000 +0000
7298 #include "xfs_bmap_btree.h"
7299 #include "xfs_dinode.h"
7300 #include "xfs_inode.h"
7301 +#include "xfs_ioctl.h"
7302 #include "xfs_bmap.h"
7303 #include "xfs_rtalloc.h"
7304 #include "xfs_error.h"
7306 #include <linux/security.h>
7307 #include <linux/fiemap.h>
7308 #include <linux/slab.h>
7309 +#include <linux/vs_tag.h>
7313 @@ -422,6 +424,7 @@ xfs_vn_getattr(
7314 stat->nlink = ip->i_d.di_nlink;
7315 stat->uid = ip->i_d.di_uid;
7316 stat->gid = ip->i_d.di_gid;
7317 + stat->tag = ip->i_d.di_tag;
7318 stat->ino = ip->i_ino;
7319 stat->atime = inode->i_atime;
7320 stat->mtime = inode->i_mtime;
7321 @@ -1054,6 +1057,7 @@ static const struct inode_operations xfs
7322 .listxattr = xfs_vn_listxattr,
7323 .fiemap = xfs_vn_fiemap,
7324 .update_time = xfs_vn_update_time,
7325 + .sync_flags = xfs_sync_flags,
7328 static const struct inode_operations xfs_dir_inode_operations = {
7329 @@ -1080,6 +1084,7 @@ static const struct inode_operations xfs
7330 .removexattr = generic_removexattr,
7331 .listxattr = xfs_vn_listxattr,
7332 .update_time = xfs_vn_update_time,
7333 + .sync_flags = xfs_sync_flags,
7336 static const struct inode_operations xfs_dir_ci_inode_operations = {
7337 @@ -1131,6 +1136,10 @@ xfs_diflags_to_iflags(
7338 inode->i_flags |= S_IMMUTABLE;
7340 inode->i_flags &= ~S_IMMUTABLE;
7341 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7342 + inode->i_flags |= S_IXUNLINK;
7344 + inode->i_flags &= ~S_IXUNLINK;
7345 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7346 inode->i_flags |= S_APPEND;
7348 @@ -1143,6 +1152,15 @@ xfs_diflags_to_iflags(
7349 inode->i_flags |= S_NOATIME;
7351 inode->i_flags &= ~S_NOATIME;
7353 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7354 + inode->i_vflags |= V_BARRIER;
7356 + inode->i_vflags &= ~V_BARRIER;
7357 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7358 + inode->i_vflags |= V_COW;
7360 + inode->i_vflags &= ~V_COW;
7364 @@ -1174,6 +1192,7 @@ xfs_setup_inode(
7365 set_nlink(inode, ip->i_d.di_nlink);
7366 inode->i_uid = ip->i_d.di_uid;
7367 inode->i_gid = ip->i_d.di_gid;
7368 + inode->i_tag = ip->i_d.di_tag;
7370 switch (inode->i_mode & S_IFMT) {
7372 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_itable.c linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_itable.c
7373 --- linux-3.9.5/fs/xfs/xfs_itable.c 2013-02-19 13:58:49.000000000 +0000
7374 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_itable.c 2013-05-31 14:47:11.000000000 +0000
7375 @@ -97,6 +97,7 @@ xfs_bulkstat_one_int(
7376 buf->bs_mode = dic->di_mode;
7377 buf->bs_uid = dic->di_uid;
7378 buf->bs_gid = dic->di_gid;
7379 + buf->bs_tag = dic->di_tag;
7380 buf->bs_size = dic->di_size;
7381 buf->bs_atime.tv_sec = dic->di_atime.t_sec;
7382 buf->bs_atime.tv_nsec = dic->di_atime.t_nsec;
7383 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_linux.h linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_linux.h
7384 --- linux-3.9.5/fs/xfs/xfs_linux.h 2013-02-19 13:58:49.000000000 +0000
7385 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_linux.h 2013-05-31 14:47:11.000000000 +0000
7388 #define current_cpu() (raw_smp_processor_id())
7389 #define current_pid() (current->pid)
7390 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7391 #define current_test_flags(f) (current->flags & (f))
7392 #define current_set_flags_nested(sp, f) \
7393 (*(sp) = current->flags, current->flags |= (f))
7394 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_log_recover.c linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_log_recover.c
7395 --- linux-3.9.5/fs/xfs/xfs_log_recover.c 2013-05-31 13:45:25.000000000 +0000
7396 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_log_recover.c 2013-05-31 14:47:11.000000000 +0000
7397 @@ -2361,7 +2361,8 @@ xlog_recover_inode_pass2(
7400 /* The core is in in-core format */
7401 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
7402 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
7403 + mp->m_flags & XFS_MOUNT_TAGGED);
7405 /* the rest is in on-disk format */
7406 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
7407 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_mount.h linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_mount.h
7408 --- linux-3.9.5/fs/xfs/xfs_mount.h 2013-05-31 13:45:25.000000000 +0000
7409 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_mount.h 2013-05-31 14:47:11.000000000 +0000
7410 @@ -254,6 +254,7 @@ typedef struct xfs_mount {
7412 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7414 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7417 * Default minimum read and write sizes.
7418 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_super.c linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_super.c
7419 --- linux-3.9.5/fs/xfs/xfs_super.c 2013-05-31 13:45:25.000000000 +0000
7420 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_super.c 2013-05-31 14:47:11.000000000 +0000
7421 @@ -114,6 +114,9 @@ mempool_t *xfs_ioend_pool;
7422 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7423 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7424 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7425 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7426 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7427 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7430 * Table driven mount option parser.
7431 @@ -126,6 +129,8 @@ enum {
7440 @@ -134,6 +139,9 @@ static const match_table_t tokens = {
7441 {Opt_nobarrier, "nobarrier"},
7442 {Opt_inode64, "inode64"},
7443 {Opt_inode32, "inode32"},
7444 + {Opt_tag, "tagxid"},
7446 + {Opt_notag, "notag"},
7450 @@ -392,6 +400,19 @@ xfs_parseargs(
7451 } else if (!strcmp(this_char, "irixsgid")) {
7453 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7454 +#ifndef CONFIG_TAGGING_NONE
7455 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7456 + mp->m_flags |= XFS_MOUNT_TAGGED;
7457 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7458 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7459 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7460 + mp->m_flags |= XFS_MOUNT_TAGGED;
7462 +#ifdef CONFIG_PROPAGATE
7463 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7465 + mp->m_flags |= XFS_MOUNT_TAGGED;
7468 xfs_warn(mp, "unknown mount option [%s].", this_char);
7470 @@ -1238,6 +1259,16 @@ xfs_fs_remount(
7472 mp->m_maxagi = xfs_set_inode32(mp);
7475 + if (!(sb->s_flags & MS_TAGGED)) {
7477 + "XFS: %s: tagging not permitted on remount.\n",
7486 * Logically we would return an error here to prevent
7487 @@ -1458,6 +1489,9 @@ xfs_fs_fill_super(
7491 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7492 + sb->s_flags |= MS_TAGGED;
7495 * we must configure the block size in the superblock before we run the
7496 * full mount process as the mount process can lookup and cache inodes.
7497 diff -NurpP --minimal linux-3.9.5/fs/xfs/xfs_vnodeops.c linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_vnodeops.c
7498 --- linux-3.9.5/fs/xfs/xfs_vnodeops.c 2013-05-31 13:45:25.000000000 +0000
7499 +++ linux-3.9.5-vs2.3.6.5/fs/xfs/xfs_vnodeops.c 2013-05-31 14:47:11.000000000 +0000
7500 @@ -104,6 +104,77 @@ xfs_readlink_bmap(
7506 +xfs_get_inode_flags(
7509 + struct inode *inode = VFS_I(ip);
7510 + unsigned int flags = inode->i_flags;
7511 + unsigned int vflags = inode->i_vflags;
7513 + if (flags & S_IMMUTABLE)
7514 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7516 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7517 + if (flags & S_IXUNLINK)
7518 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
7520 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
7522 + if (vflags & V_BARRIER)
7523 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
7525 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
7526 + if (vflags & V_COW)
7527 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
7529 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
7534 + struct inode *inode,
7538 + struct xfs_inode *ip = XFS_I(inode);
7539 + struct xfs_mount *mp = ip->i_mount;
7540 + struct xfs_trans *tp;
7541 + unsigned int lock_flags = 0;
7544 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
7545 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
7549 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7550 + xfs_trans_ijoin(tp, ip, 0);
7552 + inode->i_flags = flags;
7553 + inode->i_vflags = vflags;
7554 + xfs_get_inode_flags(ip);
7556 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
7557 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
7559 + XFS_STATS_INC(xs_ig_attrchg);
7561 + if (mp->m_flags & XFS_MOUNT_WSYNC)
7562 + xfs_trans_set_sync(tp);
7563 + code = xfs_trans_commit(tp, 0);
7564 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7568 + xfs_trans_cancel(tp, 0);
7570 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7578 diff -NurpP --minimal linux-3.9.5/include/linux/cred.h linux-3.9.5-vs2.3.6.5/include/linux/cred.h
7579 --- linux-3.9.5/include/linux/cred.h 2013-02-19 13:58:50.000000000 +0000
7580 +++ linux-3.9.5-vs2.3.6.5/include/linux/cred.h 2013-05-31 14:47:11.000000000 +0000
7581 @@ -143,6 +143,7 @@ extern void exit_creds(struct task_struc
7582 extern int copy_creds(struct task_struct *, unsigned long);
7583 extern const struct cred *get_task_cred(struct task_struct *);
7584 extern struct cred *cred_alloc_blank(void);
7585 +extern struct cred *__prepare_creds(const struct cred *);
7586 extern struct cred *prepare_creds(void);
7587 extern struct cred *prepare_exec_creds(void);
7588 extern int commit_creds(struct cred *);
7589 @@ -196,6 +197,31 @@ static inline void validate_process_cred
7593 +static inline void set_cred_subscribers(struct cred *cred, int n)
7595 +#ifdef CONFIG_DEBUG_CREDENTIALS
7596 + atomic_set(&cred->subscribers, n);
7600 +static inline int read_cred_subscribers(const struct cred *cred)
7602 +#ifdef CONFIG_DEBUG_CREDENTIALS
7603 + return atomic_read(&cred->subscribers);
7609 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
7611 +#ifdef CONFIG_DEBUG_CREDENTIALS
7612 + struct cred *cred = (struct cred *) _cred;
7614 + atomic_add(n, &cred->subscribers);
7619 * get_new_cred - Get a reference on a new set of credentials
7620 * @cred: The new credentials to reference
7621 diff -NurpP --minimal linux-3.9.5/include/linux/devpts_fs.h linux-3.9.5-vs2.3.6.5/include/linux/devpts_fs.h
7622 --- linux-3.9.5/include/linux/devpts_fs.h 2013-02-19 13:58:50.000000000 +0000
7623 +++ linux-3.9.5-vs2.3.6.5/include/linux/devpts_fs.h 2013-05-31 14:47:11.000000000 +0000
7624 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
7629 #endif /* _LINUX_DEVPTS_FS_H */
7630 diff -NurpP --minimal linux-3.9.5/include/linux/fs.h linux-3.9.5-vs2.3.6.5/include/linux/fs.h
7631 --- linux-3.9.5/include/linux/fs.h 2013-05-31 13:45:27.000000000 +0000
7632 +++ linux-3.9.5-vs2.3.6.5/include/linux/fs.h 2013-06-12 23:49:08.000000000 +0000
7633 @@ -211,6 +211,7 @@ typedef void (dio_iodone_t)(struct kiocb
7634 #define ATTR_KILL_PRIV (1 << 14)
7635 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
7636 #define ATTR_TIMES_SET (1 << 16)
7637 +#define ATTR_TAG (1 << 17)
7640 * This is the Inode Attributes structure, used for notify_change(). It
7641 @@ -226,6 +227,7 @@ struct iattr {
7647 struct timespec ia_atime;
7648 struct timespec ia_mtime;
7649 @@ -523,7 +525,9 @@ struct inode {
7650 unsigned short i_opflags;
7653 - unsigned int i_flags;
7655 + unsigned short i_flags;
7656 + unsigned short i_vflags;
7658 #ifdef CONFIG_FS_POSIX_ACL
7659 struct posix_acl *i_acl;
7660 @@ -552,6 +556,7 @@ struct inode {
7661 unsigned int __i_nlink;
7666 struct timespec i_atime;
7667 struct timespec i_mtime;
7668 @@ -702,6 +707,11 @@ static inline gid_t i_gid_read(const str
7669 return from_kgid(&init_user_ns, inode->i_gid);
7672 +static inline vtag_t i_tag_read(const struct inode *inode)
7674 + return from_ktag(&init_user_ns, inode->i_tag);
7677 static inline void i_uid_write(struct inode *inode, uid_t uid)
7679 inode->i_uid = make_kuid(&init_user_ns, uid);
7680 @@ -712,14 +722,19 @@ static inline void i_gid_write(struct in
7681 inode->i_gid = make_kgid(&init_user_ns, gid);
7684 +static inline void i_tag_write(struct inode *inode, vtag_t tag)
7686 + inode->i_tag = make_ktag(&init_user_ns, tag);
7689 static inline unsigned iminor(const struct inode *inode)
7691 - return MINOR(inode->i_rdev);
7692 + return MINOR(inode->i_mdev);
7695 static inline unsigned imajor(const struct inode *inode)
7697 - return MAJOR(inode->i_rdev);
7698 + return MAJOR(inode->i_mdev);
7701 extern struct block_device *I_BDEV(struct inode *inode);
7702 @@ -786,6 +801,7 @@ struct file {
7704 struct fown_struct f_owner;
7705 const struct cred *f_cred;
7707 struct file_ra_state f_ra;
7710 @@ -937,6 +953,7 @@ struct file_lock {
7711 struct file *fl_file;
7716 struct fasync_struct * fl_fasync; /* for lease break notifications */
7717 /* for lease breaks: */
7718 @@ -1567,6 +1584,7 @@ struct inode_operations {
7719 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
7720 ssize_t (*listxattr) (struct dentry *, char *, size_t);
7721 int (*removexattr) (struct dentry *, const char *);
7722 + int (*sync_flags) (struct inode *, int, int);
7723 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
7725 int (*update_time)(struct inode *, struct timespec *, int);
7726 @@ -1579,6 +1597,7 @@ ssize_t rw_copy_check_uvector(int type,
7727 unsigned long nr_segs, unsigned long fast_segs,
7728 struct iovec *fast_pointer,
7729 struct iovec **ret_pointer);
7730 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
7732 extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
7733 extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
7734 @@ -1632,6 +1651,14 @@ struct super_operations {
7735 #define S_IMA 1024 /* Inode has an associated IMA struct */
7736 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
7737 #define S_NOSEC 4096 /* no suid or xattr security attributes */
7738 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
7740 +/* Linux-VServer related Inode flags */
7744 +#define V_BARRIER 4 /* Barrier for chroot() */
7745 +#define V_COW 8 /* Copy on Write */
7748 * Note that nosuid etc flags are inode-specific: setting some file-system
7749 @@ -1656,10 +1683,13 @@ struct super_operations {
7750 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
7751 #define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
7752 #define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
7753 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
7755 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
7756 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
7757 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
7758 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
7759 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
7760 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
7762 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
7763 @@ -1670,6 +1700,16 @@ struct super_operations {
7764 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
7765 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
7767 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
7769 +#ifdef CONFIG_VSERVER_COWBL
7770 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
7771 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
7773 +# define IS_COW(inode) (0)
7774 +# define IS_COW_LINK(inode) (0)
7778 * Inode state bits. Protected by inode->i_lock
7780 @@ -1898,6 +1938,9 @@ extern int rw_verify_area(int, struct fi
7781 extern int locks_mandatory_locked(struct inode *);
7782 extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
7784 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
7785 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
7788 * Candidates for mandatory locking have the setgid bit set
7789 * but no group execute bit - an otherwise meaningless combination.
7790 @@ -2509,6 +2552,7 @@ extern int dcache_dir_open(struct inode
7791 extern int dcache_dir_close(struct inode *, struct file *);
7792 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
7793 extern int dcache_readdir(struct file *, void *, filldir_t);
7794 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
7795 extern int simple_setattr(struct dentry *, struct iattr *);
7796 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
7797 extern int simple_statfs(struct dentry *, struct kstatfs *);
7798 diff -NurpP --minimal linux-3.9.5/include/linux/init_task.h linux-3.9.5-vs2.3.6.5/include/linux/init_task.h
7799 --- linux-3.9.5/include/linux/init_task.h 2013-05-31 13:45:27.000000000 +0000
7800 +++ linux-3.9.5-vs2.3.6.5/include/linux/init_task.h 2013-05-31 14:53:41.000000000 +0000
7801 @@ -222,6 +222,10 @@ extern struct task_group root_task_group
7802 INIT_TASK_RCU_PREEMPT(tsk) \
7806 + .vx_info = NULL, \
7808 + .nx_info = NULL, \
7812 diff -NurpP --minimal linux-3.9.5/include/linux/ipc.h linux-3.9.5-vs2.3.6.5/include/linux/ipc.h
7813 --- linux-3.9.5/include/linux/ipc.h 2012-12-11 03:30:57.000000000 +0000
7814 +++ linux-3.9.5-vs2.3.6.5/include/linux/ipc.h 2013-06-12 23:49:08.000000000 +0000
7815 @@ -16,6 +16,7 @@ struct kern_ipc_perm
7823 diff -NurpP --minimal linux-3.9.5/include/linux/loop.h linux-3.9.5-vs2.3.6.5/include/linux/loop.h
7824 --- linux-3.9.5/include/linux/loop.h 2013-02-19 13:58:51.000000000 +0000
7825 +++ linux-3.9.5-vs2.3.6.5/include/linux/loop.h 2013-06-12 23:49:08.000000000 +0000
7826 @@ -41,6 +41,7 @@ struct loop_device {
7827 struct loop_func_table *lo_encryption;
7829 kuid_t lo_key_owner; /* Who set the key */
7831 int (*ioctl)(struct loop_device *, int cmd,
7834 diff -NurpP --minimal linux-3.9.5/include/linux/memcontrol.h linux-3.9.5-vs2.3.6.5/include/linux/memcontrol.h
7835 --- linux-3.9.5/include/linux/memcontrol.h 2013-05-31 13:45:28.000000000 +0000
7836 +++ linux-3.9.5-vs2.3.6.5/include/linux/memcontrol.h 2013-05-31 14:47:11.000000000 +0000
7837 @@ -86,6 +86,13 @@ extern struct mem_cgroup *try_get_mem_cg
7838 extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg);
7839 extern struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont);
7841 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
7842 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
7844 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
7845 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
7846 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
7849 bool mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *memcg)
7851 diff -NurpP --minimal linux-3.9.5/include/linux/mm_types.h linux-3.9.5-vs2.3.6.5/include/linux/mm_types.h
7852 --- linux-3.9.5/include/linux/mm_types.h 2013-05-31 13:45:28.000000000 +0000
7853 +++ linux-3.9.5-vs2.3.6.5/include/linux/mm_types.h 2013-05-31 14:47:11.000000000 +0000
7854 @@ -380,6 +380,7 @@ struct mm_struct {
7856 /* Architecture-specific MM context */
7857 mm_context_t context;
7858 + struct vx_info *mm_vx_info;
7860 unsigned long flags; /* Must use atomic bitops to access the bits */
7862 diff -NurpP --minimal linux-3.9.5/include/linux/mount.h linux-3.9.5-vs2.3.6.5/include/linux/mount.h
7863 --- linux-3.9.5/include/linux/mount.h 2013-05-31 13:45:28.000000000 +0000
7864 +++ linux-3.9.5-vs2.3.6.5/include/linux/mount.h 2013-05-31 14:47:11.000000000 +0000
7865 @@ -49,6 +49,9 @@ struct mnt_namespace;
7867 #define MNT_LOCK_READONLY 0x400000
7869 +#define MNT_TAGID 0x10000
7870 +#define MNT_NOTAG 0x20000
7873 struct dentry *mnt_root; /* root of the mounted tree */
7874 struct super_block *mnt_sb; /* pointer to superblock */
7875 diff -NurpP --minimal linux-3.9.5/include/linux/net.h linux-3.9.5-vs2.3.6.5/include/linux/net.h
7876 --- linux-3.9.5/include/linux/net.h 2012-12-11 03:30:57.000000000 +0000
7877 +++ linux-3.9.5-vs2.3.6.5/include/linux/net.h 2013-05-31 14:47:11.000000000 +0000
7878 @@ -38,6 +38,7 @@ struct net;
7879 #define SOCK_PASSCRED 3
7880 #define SOCK_PASSSEC 4
7881 #define SOCK_EXTERNALLY_ALLOCATED 5
7882 +#define SOCK_USER_SOCKET 6
7884 #ifndef ARCH_HAS_SOCKET_TYPES
7886 diff -NurpP --minimal linux-3.9.5/include/linux/netdevice.h linux-3.9.5-vs2.3.6.5/include/linux/netdevice.h
7887 --- linux-3.9.5/include/linux/netdevice.h 2013-05-31 13:45:28.000000000 +0000
7888 +++ linux-3.9.5-vs2.3.6.5/include/linux/netdevice.h 2013-05-31 14:47:11.000000000 +0000
7889 @@ -1688,6 +1688,7 @@ extern void netdev_resync_ops(struct ne
7891 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
7892 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
7893 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
7894 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
7895 extern int dev_restart(struct net_device *dev);
7896 #ifdef CONFIG_NETPOLL_TRAP
7897 diff -NurpP --minimal linux-3.9.5/include/linux/nsproxy.h linux-3.9.5-vs2.3.6.5/include/linux/nsproxy.h
7898 --- linux-3.9.5/include/linux/nsproxy.h 2013-02-19 13:58:51.000000000 +0000
7899 +++ linux-3.9.5-vs2.3.6.5/include/linux/nsproxy.h 2013-05-31 17:17:53.000000000 +0000
7902 #include <linux/spinlock.h>
7903 #include <linux/sched.h>
7904 +#include <linux/vserver/debug.h>
7906 struct mnt_namespace;
7907 struct uts_namespace;
7908 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
7911 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
7912 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
7913 void exit_task_namespaces(struct task_struct *tsk);
7914 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
7915 void free_nsproxy(struct nsproxy *ns);
7916 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
7917 struct cred *, struct fs_struct *);
7918 int __init nsproxy_cache_init(void);
7920 -static inline void put_nsproxy(struct nsproxy *ns)
7921 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
7923 +static inline void __get_nsproxy(struct nsproxy *ns,
7924 + const char *_file, int _line)
7926 - if (atomic_dec_and_test(&ns->count)) {
7929 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
7930 + ns, atomic_read(&ns->count), _file, _line);
7931 + atomic_inc(&ns->count);
7934 -static inline void get_nsproxy(struct nsproxy *ns)
7935 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
7937 +static inline void __put_nsproxy(struct nsproxy *ns,
7938 + const char *_file, int _line)
7940 - atomic_inc(&ns->count);
7941 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
7942 + ns, atomic_read(&ns->count), _file, _line);
7943 + if (atomic_dec_and_test(&ns->count)) {
7949 diff -NurpP --minimal linux-3.9.5/include/linux/pid.h linux-3.9.5-vs2.3.6.5/include/linux/pid.h
7950 --- linux-3.9.5/include/linux/pid.h 2013-05-31 13:45:28.000000000 +0000
7951 +++ linux-3.9.5-vs2.3.6.5/include/linux/pid.h 2013-05-31 14:47:11.000000000 +0000
7952 @@ -8,7 +8,8 @@ enum pid_type
7962 @@ -172,6 +173,7 @@ static inline pid_t pid_nr(struct pid *p
7965 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
7966 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
7967 pid_t pid_vnr(struct pid *pid);
7969 #define do_each_pid_task(pid, type, task) \
7970 diff -NurpP --minimal linux-3.9.5/include/linux/proc_fs.h linux-3.9.5-vs2.3.6.5/include/linux/proc_fs.h
7971 --- linux-3.9.5/include/linux/proc_fs.h 2013-05-31 13:45:28.000000000 +0000
7972 +++ linux-3.9.5-vs2.3.6.5/include/linux/proc_fs.h 2013-05-31 14:47:11.000000000 +0000
7973 @@ -58,6 +58,7 @@ struct proc_dir_entry {
7979 const struct inode_operations *proc_iops;
7981 @@ -274,12 +275,18 @@ extern const struct proc_ns_operations p
7982 extern const struct proc_ns_operations userns_operations;
7983 extern const struct proc_ns_operations mntns_operations;
7989 int (*proc_get_link)(struct dentry *, struct path *);
7990 int (*proc_read)(struct task_struct *task, char *page);
7991 int (*proc_show)(struct seq_file *m,
7992 struct pid_namespace *ns, struct pid *pid,
7993 struct task_struct *task);
7994 + int (*proc_vs_read)(char *page);
7995 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
7996 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
7999 struct ctl_table_header;
8000 @@ -287,6 +294,7 @@ struct ctl_table;
8007 struct proc_dir_entry *pde;
8008 diff -NurpP --minimal linux-3.9.5/include/linux/quotaops.h linux-3.9.5-vs2.3.6.5/include/linux/quotaops.h
8009 --- linux-3.9.5/include/linux/quotaops.h 2012-12-11 03:30:57.000000000 +0000
8010 +++ linux-3.9.5-vs2.3.6.5/include/linux/quotaops.h 2013-05-31 14:47:11.000000000 +0000
8012 #define _LINUX_QUOTAOPS_
8014 #include <linux/fs.h>
8015 +#include <linux/vs_dlimit.h>
8017 #define DQUOT_SPACE_WARN 0x1
8018 #define DQUOT_SPACE_RESERVE 0x2
8019 @@ -205,11 +206,12 @@ static inline void dquot_drop(struct ino
8021 static inline int dquot_alloc_inode(const struct inode *inode)
8024 + return dl_alloc_inode(inode);
8027 static inline void dquot_free_inode(const struct inode *inode)
8029 + dl_free_inode(inode);
8032 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
8033 @@ -220,6 +222,10 @@ static inline int dquot_transfer(struct
8034 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
8039 + if ((ret = dl_alloc_space(inode, number)))
8041 if (!(flags & DQUOT_SPACE_RESERVE))
8042 inode_add_bytes(inode, number);
8044 @@ -230,6 +236,7 @@ static inline void __dquot_free_space(st
8046 if (!(flags & DQUOT_SPACE_RESERVE))
8047 inode_sub_bytes(inode, number);
8048 + dl_free_space(inode, number);
8051 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
8052 diff -NurpP --minimal linux-3.9.5/include/linux/sched.h linux-3.9.5-vs2.3.6.5/include/linux/sched.h
8053 --- linux-3.9.5/include/linux/sched.h 2013-06-11 12:22:40.000000000 +0000
8054 +++ linux-3.9.5-vs2.3.6.5/include/linux/sched.h 2013-06-12 23:49:08.000000000 +0000
8055 @@ -1398,6 +1398,14 @@ struct task_struct {
8057 struct seccomp seccomp;
8059 +/* vserver context data */
8060 + struct vx_info *vx_info;
8061 + struct nx_info *nx_info;
8067 /* Thread group tracking */
8070 @@ -1637,6 +1645,11 @@ struct pid_namespace;
8071 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
8072 struct pid_namespace *ns);
8074 +#include <linux/vserver/base.h>
8075 +#include <linux/vserver/context.h>
8076 +#include <linux/vserver/debug.h>
8077 +#include <linux/vserver/pid.h>
8079 static inline pid_t task_pid_nr(struct task_struct *tsk)
8082 @@ -1650,7 +1663,8 @@ static inline pid_t task_pid_nr_ns(struc
8084 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8086 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8087 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8088 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8092 @@ -1663,7 +1677,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8094 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8096 - return pid_vnr(task_tgid(tsk));
8097 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8101 diff -NurpP --minimal linux-3.9.5/include/linux/shmem_fs.h linux-3.9.5-vs2.3.6.5/include/linux/shmem_fs.h
8102 --- linux-3.9.5/include/linux/shmem_fs.h 2012-12-11 03:30:57.000000000 +0000
8103 +++ linux-3.9.5-vs2.3.6.5/include/linux/shmem_fs.h 2013-05-31 14:47:11.000000000 +0000
8106 /* inode in-kernel data */
8108 +#define TMPFS_SUPER_MAGIC 0x01021994
8111 struct shmem_inode_info {
8113 unsigned long flags;
8114 diff -NurpP --minimal linux-3.9.5/include/linux/stat.h linux-3.9.5-vs2.3.6.5/include/linux/stat.h
8115 --- linux-3.9.5/include/linux/stat.h 2012-12-11 03:30:57.000000000 +0000
8116 +++ linux-3.9.5-vs2.3.6.5/include/linux/stat.h 2013-06-01 08:53:13.000000000 +0000
8117 @@ -25,6 +25,7 @@ struct kstat {
8124 struct timespec atime;
8125 diff -NurpP --minimal linux-3.9.5/include/linux/sunrpc/auth.h linux-3.9.5-vs2.3.6.5/include/linux/sunrpc/auth.h
8126 --- linux-3.9.5/include/linux/sunrpc/auth.h 2013-05-31 13:45:28.000000000 +0000
8127 +++ linux-3.9.5-vs2.3.6.5/include/linux/sunrpc/auth.h 2013-05-31 14:52:57.000000000 +0000
8133 struct group_info *group_info;
8134 const char *principal;
8135 unsigned char machine_cred : 1;
8136 diff -NurpP --minimal linux-3.9.5/include/linux/sunrpc/clnt.h linux-3.9.5-vs2.3.6.5/include/linux/sunrpc/clnt.h
8137 --- linux-3.9.5/include/linux/sunrpc/clnt.h 2013-05-31 13:45:28.000000000 +0000
8138 +++ linux-3.9.5-vs2.3.6.5/include/linux/sunrpc/clnt.h 2013-05-31 14:47:11.000000000 +0000
8139 @@ -49,7 +49,8 @@ struct rpc_clnt {
8140 unsigned int cl_softrtry : 1,/* soft timeouts */
8141 cl_discrtry : 1,/* disconnect before retry */
8142 cl_autobind : 1,/* use getport() */
8143 - cl_chatty : 1;/* be verbose */
8144 + cl_chatty : 1,/* be verbose */
8145 + cl_tag : 1;/* context tagging */
8147 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8148 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8149 diff -NurpP --minimal linux-3.9.5/include/linux/sysfs.h linux-3.9.5-vs2.3.6.5/include/linux/sysfs.h
8150 --- linux-3.9.5/include/linux/sysfs.h 2013-05-31 13:45:28.000000000 +0000
8151 +++ linux-3.9.5-vs2.3.6.5/include/linux/sysfs.h 2013-05-31 14:47:11.000000000 +0000
8153 #include <linux/kobject_ns.h>
8154 #include <linux/atomic.h>
8156 +#define SYSFS_SUPER_MAGIC 0x62656572
8161 diff -NurpP --minimal linux-3.9.5/include/linux/types.h linux-3.9.5-vs2.3.6.5/include/linux/types.h
8162 --- linux-3.9.5/include/linux/types.h 2013-02-19 13:58:52.000000000 +0000
8163 +++ linux-3.9.5-vs2.3.6.5/include/linux/types.h 2013-06-12 23:49:08.000000000 +0000
8164 @@ -32,6 +32,9 @@ typedef __kernel_uid32_t uid_t;
8165 typedef __kernel_gid32_t gid_t;
8166 typedef __kernel_uid16_t uid16_t;
8167 typedef __kernel_gid16_t gid16_t;
8168 +typedef unsigned int vxid_t;
8169 +typedef unsigned int vnid_t;
8170 +typedef unsigned int vtag_t;
8172 typedef unsigned long uintptr_t;
8174 diff -NurpP --minimal linux-3.9.5/include/linux/uidgid.h linux-3.9.5-vs2.3.6.5/include/linux/uidgid.h
8175 --- linux-3.9.5/include/linux/uidgid.h 2012-12-11 03:30:57.000000000 +0000
8176 +++ linux-3.9.5-vs2.3.6.5/include/linux/uidgid.h 2013-06-12 23:49:08.000000000 +0000
8177 @@ -23,13 +23,17 @@ typedef struct {
8190 #define KUIDT_INIT(value) (kuid_t){ value }
8191 #define KGIDT_INIT(value) (kgid_t){ value }
8192 +#define KTAGT_INIT(value) (ktag_t){ value }
8194 static inline uid_t __kuid_val(kuid_t uid)
8196 @@ -41,10 +45,16 @@ static inline gid_t __kgid_val(kgid_t gi
8200 +static inline vtag_t __ktag_val(ktag_t tag)
8207 typedef uid_t kuid_t;
8208 typedef gid_t kgid_t;
8209 +typedef vtag_t ktag_t;
8211 static inline uid_t __kuid_val(kuid_t uid)
8213 @@ -56,16 +66,24 @@ static inline gid_t __kgid_val(kgid_t gi
8217 +static inline vtag_t __ktag_val(ktag_t tag)
8222 #define KUIDT_INIT(value) ((kuid_t) value )
8223 #define KGIDT_INIT(value) ((kgid_t) value )
8224 +#define KTAGT_INIT(value) ((ktag_t) value )
8228 #define GLOBAL_ROOT_UID KUIDT_INIT(0)
8229 #define GLOBAL_ROOT_GID KGIDT_INIT(0)
8230 +#define GLOBAL_ROOT_TAG KTAGT_INIT(0)
8232 #define INVALID_UID KUIDT_INIT(-1)
8233 #define INVALID_GID KGIDT_INIT(-1)
8234 +#define INVALID_TAG KTAGT_INIT(-1)
8236 static inline bool uid_eq(kuid_t left, kuid_t right)
8238 @@ -77,6 +95,11 @@ static inline bool gid_eq(kgid_t left, k
8239 return __kgid_val(left) == __kgid_val(right);
8242 +static inline bool tag_eq(ktag_t left, ktag_t right)
8244 + return __ktag_val(left) == __ktag_val(right);
8247 static inline bool uid_gt(kuid_t left, kuid_t right)
8249 return __kuid_val(left) > __kuid_val(right);
8250 @@ -127,13 +150,21 @@ static inline bool gid_valid(kgid_t gid)
8251 return !gid_eq(gid, INVALID_GID);
8254 +static inline bool tag_valid(ktag_t tag)
8256 + return !tag_eq(tag, INVALID_TAG);
8259 #ifdef CONFIG_USER_NS
8261 extern kuid_t make_kuid(struct user_namespace *from, uid_t uid);
8262 extern kgid_t make_kgid(struct user_namespace *from, gid_t gid);
8263 +extern krag_t make_ktag(struct user_namespace *from, gid_t gid);
8265 extern uid_t from_kuid(struct user_namespace *to, kuid_t uid);
8266 extern gid_t from_kgid(struct user_namespace *to, kgid_t gid);
8267 +extern vtag_t from_ktag(struct user_namespace *to, ktag_t tag);
8269 extern uid_t from_kuid_munged(struct user_namespace *to, kuid_t uid);
8270 extern gid_t from_kgid_munged(struct user_namespace *to, kgid_t gid);
8272 @@ -159,6 +190,11 @@ static inline kgid_t make_kgid(struct us
8273 return KGIDT_INIT(gid);
8276 +static inline ktag_t make_ktag(struct user_namespace *from, vtag_t tag)
8278 + return KTAGT_INIT(tag);
8281 static inline uid_t from_kuid(struct user_namespace *to, kuid_t kuid)
8283 return __kuid_val(kuid);
8284 @@ -169,6 +205,11 @@ static inline gid_t from_kgid(struct use
8285 return __kgid_val(kgid);
8288 +static inline vtag_t from_ktag(struct user_namespace *to, ktag_t ktag)
8290 + return __ktag_val(ktag);
8293 static inline uid_t from_kuid_munged(struct user_namespace *to, kuid_t kuid)
8295 uid_t uid = from_kuid(to, kuid);
8296 diff -NurpP --minimal linux-3.9.5/include/linux/vroot.h linux-3.9.5-vs2.3.6.5/include/linux/vroot.h
8297 --- linux-3.9.5/include/linux/vroot.h 1970-01-01 00:00:00.000000000 +0000
8298 +++ linux-3.9.5-vs2.3.6.5/include/linux/vroot.h 2013-05-31 14:47:11.000000000 +0000
8302 + * include/linux/vroot.h
8304 + * written by Herbert Pötzl, 9/11/2002
8305 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
8307 + * Copyright (C) 2002-2007 by Herbert Pötzl.
8308 + * Redistribution of this file is permitted under the
8309 + * GNU General Public License.
8312 +#ifndef _LINUX_VROOT_H
8313 +#define _LINUX_VROOT_H
8318 +/* Possible states of device */
8324 +struct vroot_device {
8328 + struct semaphore vr_ctl_mutex;
8329 + struct block_device *vr_device;
8334 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
8336 +extern int register_vroot_grb(vroot_grb_func *);
8337 +extern int unregister_vroot_grb(vroot_grb_func *);
8339 +#endif /* __KERNEL__ */
8341 +#define MAX_VROOT_DEFAULT 8
8344 + * IOCTL commands --- we will commandeer 0x56 ('V')
8347 +#define VROOT_SET_DEV 0x5600
8348 +#define VROOT_CLR_DEV 0x5601
8350 +#endif /* _LINUX_VROOT_H */
8351 diff -NurpP --minimal linux-3.9.5/include/linux/vs_base.h linux-3.9.5-vs2.3.6.5/include/linux/vs_base.h
8352 --- linux-3.9.5/include/linux/vs_base.h 1970-01-01 00:00:00.000000000 +0000
8353 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_base.h 2013-05-31 14:47:11.000000000 +0000
8358 +#include "vserver/base.h"
8359 +#include "vserver/check.h"
8360 +#include "vserver/debug.h"
8363 +#warning duplicate inclusion
8365 diff -NurpP --minimal linux-3.9.5/include/linux/vs_context.h linux-3.9.5-vs2.3.6.5/include/linux/vs_context.h
8366 --- linux-3.9.5/include/linux/vs_context.h 1970-01-01 00:00:00.000000000 +0000
8367 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_context.h 2013-06-12 23:49:08.000000000 +0000
8369 +#ifndef _VS_CONTEXT_H
8370 +#define _VS_CONTEXT_H
8372 +#include "vserver/base.h"
8373 +#include "vserver/check.h"
8374 +#include "vserver/context.h"
8375 +#include "vserver/history.h"
8376 +#include "vserver/debug.h"
8378 +#include <linux/sched.h>
8381 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
8383 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
8384 + const char *_file, int _line, void *_here)
8389 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
8390 + vxi, vxi ? vxi->vx_id : 0,
8391 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8393 + __vxh_get_vx_info(vxi, _here);
8395 + atomic_inc(&vxi->vx_usecnt);
8400 +extern void free_vx_info(struct vx_info *);
8402 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
8404 +static inline void __put_vx_info(struct vx_info *vxi,
8405 + const char *_file, int _line, void *_here)
8410 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
8411 + vxi, vxi ? vxi->vx_id : 0,
8412 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8414 + __vxh_put_vx_info(vxi, _here);
8416 + if (atomic_dec_and_test(&vxi->vx_usecnt))
8417 + free_vx_info(vxi);
8421 +#define init_vx_info(p, i) \
8422 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8424 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8425 + const char *_file, int _line, void *_here)
8428 + vxlprintk(VXD_CBIT(xid, 3),
8429 + "init_vx_info(%p[#%d.%d])",
8430 + vxi, vxi ? vxi->vx_id : 0,
8431 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8433 + __vxh_init_vx_info(vxi, vxp, _here);
8435 + atomic_inc(&vxi->vx_usecnt);
8441 +#define set_vx_info(p, i) \
8442 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8444 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8445 + const char *_file, int _line, void *_here)
8447 + struct vx_info *vxo;
8452 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
8453 + vxi, vxi ? vxi->vx_id : 0,
8454 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8456 + __vxh_set_vx_info(vxi, vxp, _here);
8458 + atomic_inc(&vxi->vx_usecnt);
8459 + vxo = xchg(vxp, vxi);
8464 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
8466 +static inline void __clr_vx_info(struct vx_info **vxp,
8467 + const char *_file, int _line, void *_here)
8469 + struct vx_info *vxo;
8471 + vxo = xchg(vxp, NULL);
8475 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
8476 + vxo, vxo ? vxo->vx_id : 0,
8477 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
8479 + __vxh_clr_vx_info(vxo, vxp, _here);
8481 + if (atomic_dec_and_test(&vxo->vx_usecnt))
8482 + free_vx_info(vxo);
8486 +#define claim_vx_info(v, p) \
8487 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
8489 +static inline void __claim_vx_info(struct vx_info *vxi,
8490 + struct task_struct *task,
8491 + const char *_file, int _line, void *_here)
8493 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
8494 + vxi, vxi ? vxi->vx_id : 0,
8495 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8496 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
8497 + task, _file, _line);
8498 + __vxh_claim_vx_info(vxi, task, _here);
8500 + atomic_inc(&vxi->vx_tasks);
8504 +extern void unhash_vx_info(struct vx_info *);
8506 +#define release_vx_info(v, p) \
8507 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
8509 +static inline void __release_vx_info(struct vx_info *vxi,
8510 + struct task_struct *task,
8511 + const char *_file, int _line, void *_here)
8513 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
8514 + vxi, vxi ? vxi->vx_id : 0,
8515 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8516 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
8517 + task, _file, _line);
8518 + __vxh_release_vx_info(vxi, task, _here);
8522 + if (atomic_dec_and_test(&vxi->vx_tasks))
8523 + unhash_vx_info(vxi);
8527 +#define task_get_vx_info(p) \
8528 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
8530 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
8531 + const char *_file, int _line, void *_here)
8533 + struct vx_info *vxi;
8536 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
8538 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
8544 +static inline void __wakeup_vx_info(struct vx_info *vxi)
8546 + if (waitqueue_active(&vxi->vx_wait))
8547 + wake_up_interruptible(&vxi->vx_wait);
8551 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
8553 +static inline void __enter_vx_info(struct vx_info *vxi,
8554 + struct vx_info_save *vxis, const char *_file, int _line)
8556 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
8557 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
8558 + current->xid, current->vx_info, _file, _line);
8559 + vxis->vxi = xchg(¤t->vx_info, vxi);
8560 + vxis->xid = current->xid;
8561 + current->xid = vxi ? vxi->vx_id : 0;
8564 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
8566 +static inline void __leave_vx_info(struct vx_info_save *vxis,
8567 + const char *_file, int _line)
8569 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
8570 + vxis, vxis->xid, vxis->vxi, current,
8571 + current->xid, current->vx_info, _file, _line);
8572 + (void)xchg(¤t->vx_info, vxis->vxi);
8573 + current->xid = vxis->xid;
8577 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
8579 + vxis->vxi = xchg(¤t->vx_info, NULL);
8580 + vxis->xid = xchg(¤t->xid, (vxid_t)0);
8583 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
8585 + (void)xchg(¤t->xid, vxis->xid);
8586 + (void)xchg(¤t->vx_info, vxis->vxi);
8589 +#define task_is_init(p) \
8590 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
8592 +static inline int __task_is_init(struct task_struct *p,
8593 + const char *_file, int _line, void *_here)
8595 + int is_init = is_global_init(p);
8599 + is_init = p->vx_info->vx_initpid == p->pid;
8604 +extern void exit_vx_info(struct task_struct *, int);
8605 +extern void exit_vx_info_early(struct task_struct *, int);
8609 +#warning duplicate inclusion
8611 diff -NurpP --minimal linux-3.9.5/include/linux/vs_cowbl.h linux-3.9.5-vs2.3.6.5/include/linux/vs_cowbl.h
8612 --- linux-3.9.5/include/linux/vs_cowbl.h 1970-01-01 00:00:00.000000000 +0000
8613 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_cowbl.h 2013-05-31 14:47:11.000000000 +0000
8615 +#ifndef _VS_COWBL_H
8616 +#define _VS_COWBL_H
8618 +#include <linux/fs.h>
8619 +#include <linux/dcache.h>
8620 +#include <linux/namei.h>
8621 +#include <linux/slab.h>
8623 +extern struct dentry *cow_break_link(const char *pathname);
8625 +static inline int cow_check_and_break(struct path *path)
8627 + struct inode *inode = path->dentry->d_inode;
8630 + /* do we need this check? */
8631 + if (IS_RDONLY(inode))
8634 + if (IS_COW(inode)) {
8635 + if (IS_COW_LINK(inode)) {
8636 + struct dentry *new_dentry, *old_dentry = path->dentry;
8639 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
8643 + pp = d_path(path, buf, PATH_MAX);
8644 + new_dentry = cow_break_link(pp);
8646 + if (!IS_ERR(new_dentry)) {
8647 + path->dentry = new_dentry;
8650 + error = PTR_ERR(new_dentry);
8652 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
8653 + inode->i_ctime = CURRENT_TIME;
8654 + mark_inode_dirty(inode);
8661 +#warning duplicate inclusion
8663 diff -NurpP --minimal linux-3.9.5/include/linux/vs_cvirt.h linux-3.9.5-vs2.3.6.5/include/linux/vs_cvirt.h
8664 --- linux-3.9.5/include/linux/vs_cvirt.h 1970-01-01 00:00:00.000000000 +0000
8665 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_cvirt.h 2013-05-31 14:47:11.000000000 +0000
8667 +#ifndef _VS_CVIRT_H
8668 +#define _VS_CVIRT_H
8670 +#include "vserver/cvirt.h"
8671 +#include "vserver/context.h"
8672 +#include "vserver/base.h"
8673 +#include "vserver/check.h"
8674 +#include "vserver/debug.h"
8677 +static inline void vx_activate_task(struct task_struct *p)
8679 + struct vx_info *vxi;
8681 + if ((vxi = p->vx_info)) {
8682 + vx_update_load(vxi);
8683 + atomic_inc(&vxi->cvirt.nr_running);
8687 +static inline void vx_deactivate_task(struct task_struct *p)
8689 + struct vx_info *vxi;
8691 + if ((vxi = p->vx_info)) {
8692 + vx_update_load(vxi);
8693 + atomic_dec(&vxi->cvirt.nr_running);
8697 +static inline void vx_uninterruptible_inc(struct task_struct *p)
8699 + struct vx_info *vxi;
8701 + if ((vxi = p->vx_info))
8702 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
8705 +static inline void vx_uninterruptible_dec(struct task_struct *p)
8707 + struct vx_info *vxi;
8709 + if ((vxi = p->vx_info))
8710 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
8715 +#warning duplicate inclusion
8717 diff -NurpP --minimal linux-3.9.5/include/linux/vs_device.h linux-3.9.5-vs2.3.6.5/include/linux/vs_device.h
8718 --- linux-3.9.5/include/linux/vs_device.h 1970-01-01 00:00:00.000000000 +0000
8719 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_device.h 2013-05-31 14:47:11.000000000 +0000
8721 +#ifndef _VS_DEVICE_H
8722 +#define _VS_DEVICE_H
8724 +#include "vserver/base.h"
8725 +#include "vserver/device.h"
8726 +#include "vserver/debug.h"
8729 +#ifdef CONFIG_VSERVER_DEVICE
8731 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
8733 +#define vs_device_perm(v, d, m, p) \
8734 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
8739 +int vs_map_device(struct vx_info *vxi,
8740 + dev_t device, dev_t *target, umode_t mode)
8747 +#define vs_device_perm(v, d, m, p) ((p) == (p))
8752 +#define vs_map_chrdev(d, t, p) \
8753 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
8754 +#define vs_map_blkdev(d, t, p) \
8755 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
8757 +#define vs_chrdev_perm(d, p) \
8758 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
8759 +#define vs_blkdev_perm(d, p) \
8760 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
8764 +#warning duplicate inclusion
8766 diff -NurpP --minimal linux-3.9.5/include/linux/vs_dlimit.h linux-3.9.5-vs2.3.6.5/include/linux/vs_dlimit.h
8767 --- linux-3.9.5/include/linux/vs_dlimit.h 1970-01-01 00:00:00.000000000 +0000
8768 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_dlimit.h 2013-06-12 23:49:08.000000000 +0000
8770 +#ifndef _VS_DLIMIT_H
8771 +#define _VS_DLIMIT_H
8773 +#include <linux/fs.h>
8775 +#include "vserver/dlimit.h"
8776 +#include "vserver/base.h"
8777 +#include "vserver/debug.h"
8780 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
8782 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
8783 + const char *_file, int _line)
8787 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
8788 + dli, dli ? dli->dl_tag : 0,
8789 + dli ? atomic_read(&dli->dl_usecnt) : 0,
8791 + atomic_inc(&dli->dl_usecnt);
8796 +#define free_dl_info(i) \
8797 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
8799 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
8801 +static inline void __put_dl_info(struct dl_info *dli,
8802 + const char *_file, int _line)
8806 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
8807 + dli, dli ? dli->dl_tag : 0,
8808 + dli ? atomic_read(&dli->dl_usecnt) : 0,
8810 + if (atomic_dec_and_test(&dli->dl_usecnt))
8811 + free_dl_info(dli);
8815 +#define __dlimit_char(d) ((d) ? '*' : ' ')
8817 +static inline int __dl_alloc_space(struct super_block *sb,
8818 + vtag_t tag, dlsize_t nr, const char *file, int line)
8820 + struct dl_info *dli = NULL;
8825 + dli = locate_dl_info(sb, tag);
8829 + spin_lock(&dli->dl_lock);
8830 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
8832 + dli->dl_space_used += nr;
8833 + spin_unlock(&dli->dl_lock);
8836 + vxlprintk(VXD_CBIT(dlim, 1),
8837 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
8838 + sb, tag, __dlimit_char(dli), (long long)nr,
8840 + return ret ? -ENOSPC : 0;
8843 +static inline void __dl_free_space(struct super_block *sb,
8844 + vtag_t tag, dlsize_t nr, const char *_file, int _line)
8846 + struct dl_info *dli = NULL;
8850 + dli = locate_dl_info(sb, tag);
8854 + spin_lock(&dli->dl_lock);
8855 + if (dli->dl_space_used > nr)
8856 + dli->dl_space_used -= nr;
8858 + dli->dl_space_used = 0;
8859 + spin_unlock(&dli->dl_lock);
8862 + vxlprintk(VXD_CBIT(dlim, 1),
8863 + "FREE (%p,#%d)%c %lld bytes",
8864 + sb, tag, __dlimit_char(dli), (long long)nr,
8868 +static inline int __dl_alloc_inode(struct super_block *sb,
8869 + vtag_t tag, const char *_file, int _line)
8871 + struct dl_info *dli;
8874 + dli = locate_dl_info(sb, tag);
8878 + spin_lock(&dli->dl_lock);
8879 + dli->dl_inodes_used++;
8880 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
8881 + spin_unlock(&dli->dl_lock);
8884 + vxlprintk(VXD_CBIT(dlim, 0),
8885 + "ALLOC (%p,#%d)%c inode (%d)",
8886 + sb, tag, __dlimit_char(dli), ret, _file, _line);
8887 + return ret ? -ENOSPC : 0;
8890 +static inline void __dl_free_inode(struct super_block *sb,
8891 + vtag_t tag, const char *_file, int _line)
8893 + struct dl_info *dli;
8895 + dli = locate_dl_info(sb, tag);
8899 + spin_lock(&dli->dl_lock);
8900 + if (dli->dl_inodes_used > 1)
8901 + dli->dl_inodes_used--;
8903 + dli->dl_inodes_used = 0;
8904 + spin_unlock(&dli->dl_lock);
8907 + vxlprintk(VXD_CBIT(dlim, 0),
8908 + "FREE (%p,#%d)%c inode",
8909 + sb, tag, __dlimit_char(dli), _file, _line);
8912 +static inline void __dl_adjust_block(struct super_block *sb, vtag_t tag,
8913 + unsigned long long *free_blocks, unsigned long long *root_blocks,
8914 + const char *_file, int _line)
8916 + struct dl_info *dli;
8917 + uint64_t broot, bfree;
8919 + dli = locate_dl_info(sb, tag);
8923 + spin_lock(&dli->dl_lock);
8924 + broot = (dli->dl_space_total -
8925 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
8926 + >> sb->s_blocksize_bits;
8927 + bfree = (dli->dl_space_total - dli->dl_space_used)
8928 + >> sb->s_blocksize_bits;
8929 + spin_unlock(&dli->dl_lock);
8931 + vxlprintk(VXD_CBIT(dlim, 2),
8932 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
8933 + (long long)bfree, (long long)broot,
8934 + *free_blocks, *root_blocks, dli->dl_nrlmult,
8936 + if (free_blocks) {
8937 + if (*free_blocks > bfree)
8938 + *free_blocks = bfree;
8940 + if (root_blocks) {
8941 + if (*root_blocks > broot)
8942 + *root_blocks = broot;
8947 +#define dl_prealloc_space(in, bytes) \
8948 + __dl_alloc_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8949 + __FILE__, __LINE__ )
8951 +#define dl_alloc_space(in, bytes) \
8952 + __dl_alloc_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8953 + __FILE__, __LINE__ )
8955 +#define dl_reserve_space(in, bytes) \
8956 + __dl_alloc_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8957 + __FILE__, __LINE__ )
8959 +#define dl_claim_space(in, bytes) (0)
8961 +#define dl_release_space(in, bytes) \
8962 + __dl_free_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8963 + __FILE__, __LINE__ )
8965 +#define dl_free_space(in, bytes) \
8966 + __dl_free_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8967 + __FILE__, __LINE__ )
8971 +#define dl_alloc_inode(in) \
8972 + __dl_alloc_inode((in)->i_sb, i_tag_read(in), __FILE__, __LINE__ )
8974 +#define dl_free_inode(in) \
8975 + __dl_free_inode((in)->i_sb, i_tag_read(in), __FILE__, __LINE__ )
8978 +#define dl_adjust_block(sb, tag, fb, rb) \
8979 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
8983 +#warning duplicate inclusion
8985 diff -NurpP --minimal linux-3.9.5/include/linux/vs_inet.h linux-3.9.5-vs2.3.6.5/include/linux/vs_inet.h
8986 --- linux-3.9.5/include/linux/vs_inet.h 1970-01-01 00:00:00.000000000 +0000
8987 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_inet.h 2013-05-31 14:47:11.000000000 +0000
8992 +#include "vserver/base.h"
8993 +#include "vserver/network.h"
8994 +#include "vserver/debug.h"
8996 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
8998 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
8999 + NIPQUAD((a)->mask), (a)->type
9000 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
9002 +#define NIPQUAD(addr) \
9003 + ((unsigned char *)&addr)[0], \
9004 + ((unsigned char *)&addr)[1], \
9005 + ((unsigned char *)&addr)[2], \
9006 + ((unsigned char *)&addr)[3]
9008 +#define NIPQUAD_FMT "%u.%u.%u.%u"
9012 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
9014 + __be32 ip = nxa->ip[0].s_addr;
9015 + __be32 mask = nxa->mask.s_addr;
9016 + __be32 bcast = ip | ~mask;
9019 + switch (nxa->type & tmask) {
9020 + case NXA_TYPE_MASK:
9021 + ret = (ip == (addr & mask));
9023 + case NXA_TYPE_ADDR:
9027 + /* fall through to broadcast */
9028 + case NXA_MOD_BCAST:
9029 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
9031 + case NXA_TYPE_RANGE:
9032 + ret = ((nxa->ip[0].s_addr <= addr) &&
9033 + (nxa->ip[1].s_addr > addr));
9035 + case NXA_TYPE_ANY:
9040 + vxdprintk(VXD_CBIT(net, 0),
9041 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
9042 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
9047 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
9049 + struct nx_addr_v4 *nxa;
9050 + unsigned long irqflags;
9057 + /* allow 127.0.0.1 when remapping lback */
9058 + if ((tmask & NXA_LOOPBACK) &&
9059 + (addr == IPI_LOOPBACK) &&
9060 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9063 + /* check for lback address */
9064 + if ((tmask & NXA_MOD_LBACK) &&
9065 + (nxi->v4_lback.s_addr == addr))
9068 + /* check for broadcast address */
9069 + if ((tmask & NXA_MOD_BCAST) &&
9070 + (nxi->v4_bcast.s_addr == addr))
9074 + /* check for v4 addresses */
9075 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9076 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9077 + if (v4_addr_match(nxa, addr, tmask))
9081 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9083 + vxdprintk(VXD_CBIT(net, 0),
9084 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9085 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9090 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9092 + /* FIXME: needs full range checks */
9093 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9097 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9099 + struct nx_addr_v4 *ptr;
9100 + unsigned long irqflags;
9103 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9104 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9105 + if (v4_nx_addr_match(ptr, nxa, mask))
9109 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9113 +#include <net/inet_sock.h>
9116 + * Check if a given address matches for a socket
9118 + * nxi: the socket's nx_info if any
9119 + * addr: to be verified address
9122 +int v4_sock_addr_match (
9123 + struct nx_info *nxi,
9124 + struct inet_sock *inet,
9127 + __be32 saddr = inet->inet_rcv_saddr;
9128 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9130 + if (addr && (saddr == addr || bcast == addr))
9133 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9138 +/* inet related checks and helpers */
9147 +#include <linux/netdevice.h>
9148 +#include <linux/inetdevice.h>
9149 +#include <net/inet_sock.h>
9150 +#include <net/inet_timewait_sock.h>
9153 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9154 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9155 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9159 + * check if address is covered by socket
9161 + * sk: the socket to check against
9162 + * addr: the address in question (must be != 0)
9166 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9168 + struct nx_info *nxi = sk->sk_nx_info;
9169 + __be32 saddr = sk_rcv_saddr(sk);
9171 + vxdprintk(VXD_CBIT(net, 5),
9172 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9173 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9174 + (sk->sk_socket?sk->sk_socket->flags:0));
9176 + if (saddr) { /* direct address match */
9177 + return v4_addr_match(nxa, saddr, -1);
9178 + } else if (nxi) { /* match against nx_info */
9179 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9180 + } else { /* unrestricted any socket */
9188 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9190 + vxdprintk(VXD_CBIT(net, 1),
9191 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9192 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9193 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9195 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9197 + if (dev_in_nx_info(dev, nxi))
9204 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9210 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9214 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
9216 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
9217 + nxi, nxi ? nxi->nx_id : 0, ifa,
9218 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
9220 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9222 + if (v4_ifa_in_nx_info(ifa, nxi))
9228 +struct nx_v4_sock_addr {
9229 + __be32 saddr; /* Address used for validation */
9230 + __be32 baddr; /* Address used for socket bind */
9234 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
9235 + struct nx_v4_sock_addr *nsa)
9237 + struct sock *sk = &inet->sk;
9238 + struct nx_info *nxi = sk->sk_nx_info;
9239 + __be32 saddr = addr->sin_addr.s_addr;
9240 + __be32 baddr = saddr;
9242 + vxdprintk(VXD_CBIT(net, 3),
9243 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
9244 + sk, sk->sk_nx_info, sk->sk_socket,
9245 + (sk->sk_socket ? sk->sk_socket->flags : 0),
9249 + if (saddr == INADDR_ANY) {
9250 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
9251 + baddr = nxi->v4.ip[0].s_addr;
9252 + } else if (saddr == IPI_LOOPBACK) {
9253 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9254 + baddr = nxi->v4_lback.s_addr;
9255 + } else if (!ipv4_is_multicast(saddr) ||
9256 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
9257 + /* normal address bind */
9258 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
9259 + return -EADDRNOTAVAIL;
9263 + vxdprintk(VXD_CBIT(net, 3),
9264 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
9265 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
9267 + nsa->saddr = saddr;
9268 + nsa->baddr = baddr;
9273 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
9275 + inet->inet_saddr = nsa->baddr;
9276 + inet->inet_rcv_saddr = nsa->baddr;
9281 + * helper to simplify inet_lookup_listener
9283 + * nxi: the socket's nx_info if any
9284 + * addr: to be verified address
9285 + * saddr: socket address
9287 +static inline int v4_inet_addr_match (
9288 + struct nx_info *nxi,
9292 + if (addr && (saddr == addr))
9295 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
9299 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
9301 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
9302 + (addr == nxi->v4_lback.s_addr))
9303 + return IPI_LOOPBACK;
9308 +int nx_info_has_v4(struct nx_info *nxi)
9314 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9319 +#else /* CONFIG_INET */
9322 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
9328 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9334 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9340 +int nx_info_has_v4(struct nx_info *nxi)
9345 +#endif /* CONFIG_INET */
9347 +#define current_nx_info_has_v4() \
9348 + nx_info_has_v4(current_nx_info())
9351 +// #warning duplicate inclusion
9353 diff -NurpP --minimal linux-3.9.5/include/linux/vs_inet6.h linux-3.9.5-vs2.3.6.5/include/linux/vs_inet6.h
9354 --- linux-3.9.5/include/linux/vs_inet6.h 1970-01-01 00:00:00.000000000 +0000
9355 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_inet6.h 2013-05-31 14:47:11.000000000 +0000
9357 +#ifndef _VS_INET6_H
9358 +#define _VS_INET6_H
9360 +#include "vserver/base.h"
9361 +#include "vserver/network.h"
9362 +#include "vserver/debug.h"
9364 +#include <net/ipv6.h>
9366 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
9367 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
9373 +int v6_addr_match(struct nx_addr_v6 *nxa,
9374 + const struct in6_addr *addr, uint16_t mask)
9378 + switch (nxa->type & mask) {
9379 + case NXA_TYPE_MASK:
9380 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
9382 + case NXA_TYPE_ADDR:
9383 + ret = ipv6_addr_equal(&nxa->ip, addr);
9385 + case NXA_TYPE_ANY:
9389 + vxdprintk(VXD_CBIT(net, 0),
9390 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
9391 + nxa, NXAV6(nxa), addr, mask, ret);
9396 +int v6_addr_in_nx_info(struct nx_info *nxi,
9397 + const struct in6_addr *addr, uint16_t mask)
9399 + struct nx_addr_v6 *nxa;
9400 + unsigned long irqflags;
9406 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9407 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
9408 + if (v6_addr_match(nxa, addr, mask))
9412 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9414 + vxdprintk(VXD_CBIT(net, 0),
9415 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
9416 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
9421 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
9423 + /* FIXME: needs full range checks */
9424 + return v6_addr_match(nxa, &addr->ip, mask);
9428 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
9430 + struct nx_addr_v6 *ptr;
9431 + unsigned long irqflags;
9434 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9435 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
9436 + if (v6_nx_addr_match(ptr, nxa, mask))
9440 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9446 + * Check if a given address matches for a socket
9448 + * nxi: the socket's nx_info if any
9449 + * addr: to be verified address
9452 +int v6_sock_addr_match (
9453 + struct nx_info *nxi,
9454 + struct inet_sock *inet,
9455 + struct in6_addr *addr)
9457 + struct sock *sk = &inet->sk;
9458 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9460 + if (!ipv6_addr_any(addr) &&
9461 + ipv6_addr_equal(saddr, addr))
9463 + if (ipv6_addr_any(saddr))
9464 + return v6_addr_in_nx_info(nxi, addr, -1);
9469 + * check if address is covered by socket
9471 + * sk: the socket to check against
9472 + * addr: the address in question (must be != 0)
9476 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
9478 + struct nx_info *nxi = sk->sk_nx_info;
9479 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9481 + vxdprintk(VXD_CBIT(net, 5),
9482 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
9483 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
9484 + (sk->sk_socket?sk->sk_socket->flags:0));
9486 + if (!ipv6_addr_any(saddr)) { /* direct address match */
9487 + return v6_addr_match(nxa, saddr, -1);
9488 + } else if (nxi) { /* match against nx_info */
9489 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
9490 + } else { /* unrestricted any socket */
9496 +/* inet related checks and helpers */
9504 +#include <linux/netdevice.h>
9505 +#include <linux/inetdevice.h>
9506 +#include <net/inet_timewait_sock.h>
9509 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9510 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
9511 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
9516 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
9522 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
9526 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
9528 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
9529 + nxi, nxi ? nxi->nx_id : 0, ifa,
9530 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
9532 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9534 + if (v6_ifa_in_nx_info(ifa, nxi))
9540 +struct nx_v6_sock_addr {
9541 + struct in6_addr saddr; /* Address used for validation */
9542 + struct in6_addr baddr; /* Address used for socket bind */
9546 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
9547 + struct nx_v6_sock_addr *nsa)
9549 + // struct sock *sk = &inet->sk;
9550 + // struct nx_info *nxi = sk->sk_nx_info;
9551 + struct in6_addr saddr = addr->sin6_addr;
9552 + struct in6_addr baddr = saddr;
9554 + nsa->saddr = saddr;
9555 + nsa->baddr = baddr;
9560 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
9562 + // struct sock *sk = &inet->sk;
9563 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
9565 + // *saddr = nsa->baddr;
9566 + // inet->inet_saddr = nsa->baddr;
9570 +int nx_info_has_v6(struct nx_info *nxi)
9579 +#else /* CONFIG_IPV6 */
9582 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
9589 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9595 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9601 +int nx_info_has_v6(struct nx_info *nxi)
9606 +#endif /* CONFIG_IPV6 */
9608 +#define current_nx_info_has_v6() \
9609 + nx_info_has_v6(current_nx_info())
9612 +#warning duplicate inclusion
9614 diff -NurpP --minimal linux-3.9.5/include/linux/vs_limit.h linux-3.9.5-vs2.3.6.5/include/linux/vs_limit.h
9615 --- linux-3.9.5/include/linux/vs_limit.h 1970-01-01 00:00:00.000000000 +0000
9616 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_limit.h 2013-05-31 14:47:11.000000000 +0000
9618 +#ifndef _VS_LIMIT_H
9619 +#define _VS_LIMIT_H
9621 +#include "vserver/limit.h"
9622 +#include "vserver/base.h"
9623 +#include "vserver/context.h"
9624 +#include "vserver/debug.h"
9625 +#include "vserver/context.h"
9626 +#include "vserver/limit_int.h"
9629 +#define vx_acc_cres(v, d, p, r) \
9630 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
9632 +#define vx_acc_cres_cond(x, d, p, r) \
9633 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
9634 + r, d, p, __FILE__, __LINE__)
9637 +#define vx_add_cres(v, a, p, r) \
9638 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
9639 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
9641 +#define vx_add_cres_cond(x, a, p, r) \
9642 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
9643 + r, a, p, __FILE__, __LINE__)
9644 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
9647 +/* process and file limits */
9649 +#define vx_nproc_inc(p) \
9650 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
9652 +#define vx_nproc_dec(p) \
9653 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
9655 +#define vx_files_inc(f) \
9656 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
9658 +#define vx_files_dec(f) \
9659 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
9661 +#define vx_locks_inc(l) \
9662 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
9664 +#define vx_locks_dec(l) \
9665 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
9667 +#define vx_openfd_inc(f) \
9668 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
9670 +#define vx_openfd_dec(f) \
9671 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
9674 +#define vx_cres_avail(v, n, r) \
9675 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
9678 +#define vx_nproc_avail(n) \
9679 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
9681 +#define vx_files_avail(n) \
9682 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
9684 +#define vx_locks_avail(n) \
9685 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
9687 +#define vx_openfd_avail(n) \
9688 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
9691 +/* dentry limits */
9693 +#define vx_dentry_inc(d) do { \
9694 + if ((d)->d_count == 1) \
9695 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
9698 +#define vx_dentry_dec(d) do { \
9699 + if ((d)->d_count == 0) \
9700 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
9703 +#define vx_dentry_avail(n) \
9704 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
9707 +/* socket limits */
9709 +#define vx_sock_inc(s) \
9710 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
9712 +#define vx_sock_dec(s) \
9713 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
9715 +#define vx_sock_avail(n) \
9716 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
9719 +/* ipc resource limits */
9721 +#define vx_ipcmsg_add(v, u, a) \
9722 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
9724 +#define vx_ipcmsg_sub(v, u, a) \
9725 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
9727 +#define vx_ipcmsg_avail(v, a) \
9728 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
9731 +#define vx_ipcshm_add(v, k, a) \
9732 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
9734 +#define vx_ipcshm_sub(v, k, a) \
9735 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
9737 +#define vx_ipcshm_avail(v, a) \
9738 + vx_cres_avail(v, a, VLIMIT_SHMEM)
9741 +#define vx_semary_inc(a) \
9742 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
9744 +#define vx_semary_dec(a) \
9745 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
9748 +#define vx_nsems_add(a,n) \
9749 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
9751 +#define vx_nsems_sub(a,n) \
9752 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
9756 +#warning duplicate inclusion
9758 diff -NurpP --minimal linux-3.9.5/include/linux/vs_network.h linux-3.9.5-vs2.3.6.5/include/linux/vs_network.h
9759 --- linux-3.9.5/include/linux/vs_network.h 1970-01-01 00:00:00.000000000 +0000
9760 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_network.h 2013-05-31 14:47:11.000000000 +0000
9762 +#ifndef _NX_VS_NETWORK_H
9763 +#define _NX_VS_NETWORK_H
9765 +#include "vserver/context.h"
9766 +#include "vserver/network.h"
9767 +#include "vserver/base.h"
9768 +#include "vserver/check.h"
9769 +#include "vserver/debug.h"
9771 +#include <linux/sched.h>
9774 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
9776 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
9777 + const char *_file, int _line)
9782 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
9783 + nxi, nxi ? nxi->nx_id : 0,
9784 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9787 + atomic_inc(&nxi->nx_usecnt);
9792 +extern void free_nx_info(struct nx_info *);
9794 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
9796 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
9801 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
9802 + nxi, nxi ? nxi->nx_id : 0,
9803 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9806 + if (atomic_dec_and_test(&nxi->nx_usecnt))
9807 + free_nx_info(nxi);
9811 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
9813 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
9814 + const char *_file, int _line)
9817 + vxlprintk(VXD_CBIT(nid, 3),
9818 + "init_nx_info(%p[#%d.%d])",
9819 + nxi, nxi ? nxi->nx_id : 0,
9820 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9823 + atomic_inc(&nxi->nx_usecnt);
9829 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
9831 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
9832 + const char *_file, int _line)
9834 + struct nx_info *nxo;
9839 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
9840 + nxi, nxi ? nxi->nx_id : 0,
9841 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9844 + atomic_inc(&nxi->nx_usecnt);
9845 + nxo = xchg(nxp, nxi);
9849 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
9851 +static inline void __clr_nx_info(struct nx_info **nxp,
9852 + const char *_file, int _line)
9854 + struct nx_info *nxo;
9856 + nxo = xchg(nxp, NULL);
9860 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
9861 + nxo, nxo ? nxo->nx_id : 0,
9862 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
9865 + if (atomic_dec_and_test(&nxo->nx_usecnt))
9866 + free_nx_info(nxo);
9870 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
9872 +static inline void __claim_nx_info(struct nx_info *nxi,
9873 + struct task_struct *task, const char *_file, int _line)
9875 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
9876 + nxi, nxi ? nxi->nx_id : 0,
9877 + nxi?atomic_read(&nxi->nx_usecnt):0,
9878 + nxi?atomic_read(&nxi->nx_tasks):0,
9879 + task, _file, _line);
9881 + atomic_inc(&nxi->nx_tasks);
9885 +extern void unhash_nx_info(struct nx_info *);
9887 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
9889 +static inline void __release_nx_info(struct nx_info *nxi,
9890 + struct task_struct *task, const char *_file, int _line)
9892 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
9893 + nxi, nxi ? nxi->nx_id : 0,
9894 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9895 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
9896 + task, _file, _line);
9900 + if (atomic_dec_and_test(&nxi->nx_tasks))
9901 + unhash_nx_info(nxi);
9905 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
9907 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
9908 + const char *_file, int _line)
9910 + struct nx_info *nxi;
9913 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
9915 + nxi = __get_nx_info(p->nx_info, _file, _line);
9921 +static inline void exit_nx_info(struct task_struct *p)
9924 + release_nx_info(p->nx_info, p);
9929 +#warning duplicate inclusion
9931 diff -NurpP --minimal linux-3.9.5/include/linux/vs_pid.h linux-3.9.5-vs2.3.6.5/include/linux/vs_pid.h
9932 --- linux-3.9.5/include/linux/vs_pid.h 1970-01-01 00:00:00.000000000 +0000
9933 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_pid.h 2013-05-31 14:47:11.000000000 +0000
9938 +#include "vserver/base.h"
9939 +#include "vserver/check.h"
9940 +#include "vserver/context.h"
9941 +#include "vserver/debug.h"
9942 +#include "vserver/pid.h"
9943 +#include <linux/pid_namespace.h>
9946 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
9949 +int vx_proc_task_visible(struct task_struct *task)
9951 + if ((task->pid == 1) &&
9952 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
9953 + /* show a blend through init */
9955 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
9962 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
9966 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
9968 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
9970 + if (task && !vx_proc_task_visible(task)) {
9971 + vxdprintk(VXD_CBIT(misc, 6),
9972 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
9973 + task, task->xid, task->pid,
9974 + current, current->xid, current->pid);
9975 + put_task_struct(task);
9983 +#warning duplicate inclusion
9985 diff -NurpP --minimal linux-3.9.5/include/linux/vs_sched.h linux-3.9.5-vs2.3.6.5/include/linux/vs_sched.h
9986 --- linux-3.9.5/include/linux/vs_sched.h 1970-01-01 00:00:00.000000000 +0000
9987 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_sched.h 2013-05-31 14:47:11.000000000 +0000
9989 +#ifndef _VS_SCHED_H
9990 +#define _VS_SCHED_H
9992 +#include "vserver/base.h"
9993 +#include "vserver/context.h"
9994 +#include "vserver/sched.h"
9997 +#define MAX_PRIO_BIAS 20
9998 +#define MIN_PRIO_BIAS -20
10001 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
10003 + struct vx_info *vxi = p->vx_info;
10006 + prio += vx_cpu(vxi, sched_pc).prio_bias;
10010 +static inline void vx_account_user(struct vx_info *vxi,
10011 + cputime_t cputime, int nice)
10015 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
10018 +static inline void vx_account_system(struct vx_info *vxi,
10019 + cputime_t cputime, int idle)
10023 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
10027 +#warning duplicate inclusion
10029 diff -NurpP --minimal linux-3.9.5/include/linux/vs_socket.h linux-3.9.5-vs2.3.6.5/include/linux/vs_socket.h
10030 --- linux-3.9.5/include/linux/vs_socket.h 1970-01-01 00:00:00.000000000 +0000
10031 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_socket.h 2013-05-31 14:47:11.000000000 +0000
10033 +#ifndef _VS_SOCKET_H
10034 +#define _VS_SOCKET_H
10036 +#include "vserver/debug.h"
10037 +#include "vserver/base.h"
10038 +#include "vserver/cacct.h"
10039 +#include "vserver/context.h"
10040 +#include "vserver/tag.h"
10043 +/* socket accounting */
10045 +#include <linux/socket.h>
10047 +static inline int vx_sock_type(int family)
10049 + switch (family) {
10051 + return VXA_SOCK_UNSPEC;
10053 + return VXA_SOCK_UNIX;
10055 + return VXA_SOCK_INET;
10057 + return VXA_SOCK_INET6;
10059 + return VXA_SOCK_PACKET;
10061 + return VXA_SOCK_OTHER;
10065 +#define vx_acc_sock(v, f, p, s) \
10066 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
10068 +static inline void __vx_acc_sock(struct vx_info *vxi,
10069 + int family, int pos, int size, char *file, int line)
10072 + int type = vx_sock_type(family);
10074 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10075 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10079 +#define vx_sock_recv(sk, s) \
10080 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10081 +#define vx_sock_send(sk, s) \
10082 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10083 +#define vx_sock_fail(sk, s) \
10084 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10087 +#define sock_vx_init(s) do { \
10088 + (s)->sk_xid = 0; \
10089 + (s)->sk_vx_info = NULL; \
10092 +#define sock_nx_init(s) do { \
10093 + (s)->sk_nid = 0; \
10094 + (s)->sk_nx_info = NULL; \
10098 +#warning duplicate inclusion
10100 diff -NurpP --minimal linux-3.9.5/include/linux/vs_tag.h linux-3.9.5-vs2.3.6.5/include/linux/vs_tag.h
10101 --- linux-3.9.5/include/linux/vs_tag.h 1970-01-01 00:00:00.000000000 +0000
10102 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_tag.h 2013-06-12 23:49:08.000000000 +0000
10107 +#include <linux/vserver/tag.h>
10109 +/* check conditions */
10111 +#define DX_ADMIN 0x0001
10112 +#define DX_WATCH 0x0002
10113 +#define DX_HOSTID 0x0008
10115 +#define DX_IDENT 0x0010
10117 +#define DX_ARG_MASK 0x0010
10120 +#define dx_task_tag(t) ((t)->tag)
10122 +#define dx_current_tag() dx_task_tag(current)
10124 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10126 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10130 + * check current context for ADMIN/WATCH and
10131 + * optionally against supplied argument
10133 +static inline int __dx_check(vtag_t cid, vtag_t id, unsigned int mode)
10135 + if (mode & DX_ARG_MASK) {
10136 + if ((mode & DX_IDENT) && (id == cid))
10139 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10140 + ((mode & DX_WATCH) && (cid == 1)) ||
10141 + ((mode & DX_HOSTID) && (id == 0)));
10145 +int dx_permission(const struct inode *inode, int mask);
10149 +#warning duplicate inclusion
10151 diff -NurpP --minimal linux-3.9.5/include/linux/vs_time.h linux-3.9.5-vs2.3.6.5/include/linux/vs_time.h
10152 --- linux-3.9.5/include/linux/vs_time.h 1970-01-01 00:00:00.000000000 +0000
10153 +++ linux-3.9.5-vs2.3.6.5/include/linux/vs_time.h 2013-05-31 14:47:11.000000000 +0000
10155 +#ifndef _VS_TIME_H
10156 +#define _VS_TIME_H
10159 +/* time faking stuff */
10161 +#ifdef CONFIG_VSERVER_VTIME
10163 +extern void vx_adjust_timespec(struct timespec *ts);
10164 +extern int vx_settimeofday(const struct timespec *ts);
10167 +#define vx_adjust_timespec(t) do { } while (0)
10168 +#define vx_settimeofday(t) do_settimeofday(t)
10172 +#warning duplicate inclusion
10174 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/base.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/base.h
10175 --- linux-3.9.5/include/linux/vserver/base.h 1970-01-01 00:00:00.000000000 +0000
10176 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/base.h 2013-05-31 17:55:09.000000000 +0000
10178 +#ifndef _VSERVER_BASE_H
10179 +#define _VSERVER_BASE_H
10182 +/* context state changes */
10194 +#define vx_task_xid(t) ((t)->xid)
10196 +#define vx_current_xid() vx_task_xid(current)
10198 +#define current_vx_info() (current->vx_info)
10201 +#define nx_task_nid(t) ((t)->nid)
10203 +#define nx_current_nid() nx_task_nid(current)
10205 +#define current_nx_info() (current->nx_info)
10208 +/* generic flag merging */
10210 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10212 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10214 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10216 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10219 +/* context flags */
10221 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10223 +#define vx_current_flags() __vx_flags(current_vx_info())
10225 +#define vx_info_flags(v, m, f) \
10226 + vs_check_flags(__vx_flags(v), m, f)
10228 +#define task_vx_flags(t, m, f) \
10229 + ((t) && vx_info_flags((t)->vx_info, m, f))
10231 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10234 +/* context caps */
10236 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10238 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10240 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10242 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10246 +/* network flags */
10248 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10250 +#define nx_current_flags() __nx_flags(current_nx_info())
10252 +#define nx_info_flags(n, m, f) \
10253 + vs_check_flags(__nx_flags(n), m, f)
10255 +#define task_nx_flags(t, m, f) \
10256 + ((t) && nx_info_flags((t)->nx_info, m, f))
10258 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10261 +/* network caps */
10263 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10265 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10267 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10269 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10272 +/* context mask capabilities */
10274 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10276 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10278 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10281 +/* context bcap mask */
10283 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10285 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10288 +/* mask given bcaps */
10290 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10292 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10295 +/* masked cap_bset */
10297 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10299 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10302 +#define vx_info_mbcap(v, b) \
10303 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10304 + vx_info_bcaps(v, b) : (b))
10306 +#define task_vx_mbcap(t, b) \
10307 + vx_info_mbcap((t)->vx_info, (t)->b)
10309 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10312 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10314 +#define vx_capable(b, c) (capable(b) || \
10315 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10317 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
10318 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10320 +#define nx_capable(b, c) (capable(b) || \
10321 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10323 +#define vx_task_initpid(t, n) \
10324 + ((t)->vx_info && \
10325 + ((t)->vx_info->vx_initpid == (n)))
10327 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10330 +/* context unshare mask */
10332 +#define __vx_umask(v) ((v)->vx_umask)
10334 +#define vx_current_umask() __vx_umask(current_vx_info())
10336 +#define vx_can_unshare(b, f) (capable(b) || \
10337 + (cap_raised(current_cap(), b) && \
10338 + !((f) & ~vx_current_umask())))
10340 +#define vx_ns_can_unshare(n, b, f) (ns_capable(n, b) || \
10341 + (cap_raised(current_cap(), b) && \
10342 + !((f) & ~vx_current_umask())))
10344 +#define __vx_wmask(v) ((v)->vx_wmask)
10346 +#define vx_current_wmask() __vx_wmask(current_vx_info())
10349 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10351 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10354 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10356 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10359 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/cacct.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/cacct.h
10360 --- linux-3.9.5/include/linux/vserver/cacct.h 1970-01-01 00:00:00.000000000 +0000
10361 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/cacct.h 2013-05-31 14:47:11.000000000 +0000
10363 +#ifndef _VSERVER_CACCT_H
10364 +#define _VSERVER_CACCT_H
10367 +enum sock_acc_field {
10368 + VXA_SOCK_UNSPEC = 0,
10374 + VXA_SOCK_SIZE /* array size */
10377 +#endif /* _VSERVER_CACCT_H */
10378 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/cacct_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/cacct_cmd.h
10379 --- linux-3.9.5/include/linux/vserver/cacct_cmd.h 1970-01-01 00:00:00.000000000 +0000
10380 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/cacct_cmd.h 2013-05-31 14:47:11.000000000 +0000
10382 +#ifndef _VSERVER_CACCT_CMD_H
10383 +#define _VSERVER_CACCT_CMD_H
10386 +#include <linux/compiler.h>
10387 +#include <uapi/vserver/cacct_cmd.h>
10389 +extern int vc_sock_stat(struct vx_info *, void __user *);
10391 +#endif /* _VSERVER_CACCT_CMD_H */
10392 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/cacct_def.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/cacct_def.h
10393 --- linux-3.9.5/include/linux/vserver/cacct_def.h 1970-01-01 00:00:00.000000000 +0000
10394 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/cacct_def.h 2013-05-31 14:47:11.000000000 +0000
10396 +#ifndef _VSERVER_CACCT_DEF_H
10397 +#define _VSERVER_CACCT_DEF_H
10399 +#include <asm/atomic.h>
10400 +#include <linux/vserver/cacct.h>
10403 +struct _vx_sock_acc {
10404 + atomic_long_t count;
10405 + atomic_long_t total;
10408 +/* context sub struct */
10410 +struct _vx_cacct {
10411 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10412 + atomic_t slab[8];
10413 + atomic_t page[6][8];
10416 +#ifdef CONFIG_VSERVER_DEBUG
10418 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10422 + printk("\t_vx_cacct:");
10423 + for (i = 0; i < 6; i++) {
10424 + struct _vx_sock_acc *ptr = cacct->sock[i];
10426 + printk("\t [%d] =", i);
10427 + for (j = 0; j < 3; j++) {
10428 + printk(" [%d] = %8lu, %8lu", j,
10429 + atomic_long_read(&ptr[j].count),
10430 + atomic_long_read(&ptr[j].total));
10438 +#endif /* _VSERVER_CACCT_DEF_H */
10439 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/cacct_int.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/cacct_int.h
10440 --- linux-3.9.5/include/linux/vserver/cacct_int.h 1970-01-01 00:00:00.000000000 +0000
10441 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/cacct_int.h 2013-05-31 14:47:11.000000000 +0000
10443 +#ifndef _VSERVER_CACCT_INT_H
10444 +#define _VSERVER_CACCT_INT_H
10447 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10449 + return atomic_long_read(&cacct->sock[type][pos].count);
10454 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10456 + return atomic_long_read(&cacct->sock[type][pos].total);
10459 +#endif /* _VSERVER_CACCT_INT_H */
10460 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/check.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/check.h
10461 --- linux-3.9.5/include/linux/vserver/check.h 1970-01-01 00:00:00.000000000 +0000
10462 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/check.h 2013-05-31 14:47:11.000000000 +0000
10464 +#ifndef _VSERVER_CHECK_H
10465 +#define _VSERVER_CHECK_H
10468 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10470 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10471 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10473 +#define MIN_D_CONTEXT 65536
10476 +/* check conditions */
10478 +#define VS_ADMIN 0x0001
10479 +#define VS_WATCH 0x0002
10480 +#define VS_HIDE 0x0004
10481 +#define VS_HOSTID 0x0008
10483 +#define VS_IDENT 0x0010
10484 +#define VS_EQUIV 0x0020
10485 +#define VS_PARENT 0x0040
10486 +#define VS_CHILD 0x0080
10488 +#define VS_ARG_MASK 0x00F0
10490 +#define VS_DYNAMIC 0x0100
10491 +#define VS_STATIC 0x0200
10493 +#define VS_ATR_MASK 0x0F00
10495 +#ifdef CONFIG_VSERVER_PRIVACY
10496 +#define VS_ADMIN_P (0)
10497 +#define VS_WATCH_P (0)
10499 +#define VS_ADMIN_P VS_ADMIN
10500 +#define VS_WATCH_P VS_WATCH
10503 +#define VS_HARDIRQ 0x1000
10504 +#define VS_SOFTIRQ 0x2000
10505 +#define VS_IRQ 0x4000
10507 +#define VS_IRQ_MASK 0xF000
10509 +#include <linux/hardirq.h>
10512 + * check current context for ADMIN/WATCH and
10513 + * optionally against supplied argument
10515 +static inline int __vs_check(int cid, int id, unsigned int mode)
10517 + if (mode & VS_ARG_MASK) {
10518 + if ((mode & VS_IDENT) && (id == cid))
10521 + if (mode & VS_ATR_MASK) {
10522 + if ((mode & VS_DYNAMIC) &&
10523 + (id >= MIN_D_CONTEXT) &&
10524 + (id <= MAX_S_CONTEXT))
10526 + if ((mode & VS_STATIC) &&
10527 + (id > 1) && (id < MIN_D_CONTEXT))
10530 + if (mode & VS_IRQ_MASK) {
10531 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10533 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10535 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10538 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10539 + ((mode & VS_WATCH) && (cid == 1)) ||
10540 + ((mode & VS_HOSTID) && (id == 0)));
10543 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10545 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10548 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10550 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10553 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/context.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/context.h
10554 --- linux-3.9.5/include/linux/vserver/context.h 1970-01-01 00:00:00.000000000 +0000
10555 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/context.h 2013-06-12 23:49:08.000000000 +0000
10557 +#ifndef _VSERVER_CONTEXT_H
10558 +#define _VSERVER_CONTEXT_H
10561 +#include <linux/list.h>
10562 +#include <linux/spinlock.h>
10563 +#include <linux/rcupdate.h>
10564 +#include <uapi/vserver/context.h>
10566 +#include "limit_def.h"
10567 +#include "sched_def.h"
10568 +#include "cvirt_def.h"
10569 +#include "cacct_def.h"
10570 +#include "device_def.h"
10572 +#define VX_SPACES 2
10574 +struct _vx_info_pc {
10575 + struct _vx_sched_pc sched_pc;
10576 + struct _vx_cvirt_pc cvirt_pc;
10579 +struct _vx_space {
10580 + unsigned long vx_nsmask; /* assignment mask */
10581 + struct nsproxy *vx_nsproxy; /* private namespaces */
10582 + struct fs_struct *vx_fs; /* private namespace fs */
10583 + const struct cred *vx_cred; /* task credentials */
10587 + struct hlist_node vx_hlist; /* linked list of contexts */
10588 + vxid_t vx_id; /* context id */
10589 + atomic_t vx_usecnt; /* usage count */
10590 + atomic_t vx_tasks; /* tasks count */
10591 + struct vx_info *vx_parent; /* parent context */
10592 + int vx_state; /* context state */
10594 + struct _vx_space space[VX_SPACES]; /* namespace store */
10596 + uint64_t vx_flags; /* context flags */
10597 + uint64_t vx_ccaps; /* context caps (vserver) */
10598 + uint64_t vx_umask; /* unshare mask (guest) */
10599 + uint64_t vx_wmask; /* warn mask (guest) */
10600 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10602 + struct task_struct *vx_reaper; /* guest reaper process */
10603 + pid_t vx_initpid; /* PID of guest init */
10604 + int64_t vx_badness_bias; /* OOM points bias */
10606 + struct _vx_limit limit; /* vserver limits */
10607 + struct _vx_sched sched; /* vserver scheduler */
10608 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10609 + struct _vx_cacct cacct; /* context accounting */
10611 + struct _vx_device dmap; /* default device map targets */
10613 +#ifndef CONFIG_SMP
10614 + struct _vx_info_pc info_pc; /* per cpu data */
10616 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10619 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10620 + int reboot_cmd; /* last sys_reboot() cmd */
10621 + int exit_code; /* last process exit code */
10623 + char vx_name[65]; /* vserver name */
10626 +#ifndef CONFIG_SMP
10627 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10628 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10630 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10631 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10634 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10637 +struct vx_info_save {
10638 + struct vx_info *vxi;
10643 +/* status flags */
10645 +#define VXS_HASHED 0x0001
10646 +#define VXS_PAUSED 0x0010
10647 +#define VXS_SHUTDOWN 0x0100
10648 +#define VXS_HELPER 0x1000
10649 +#define VXS_RELEASED 0x8000
10652 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10653 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10655 +extern struct vx_info *lookup_vx_info(int);
10656 +extern struct vx_info *lookup_or_create_vx_info(int);
10658 +extern int get_xid_list(int, unsigned int *, int);
10659 +extern int xid_is_hashed(vxid_t);
10661 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10663 +extern long vs_state_change(struct vx_info *, unsigned int);
10666 +#endif /* _VSERVER_CONTEXT_H */
10667 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/context_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/context_cmd.h
10668 --- linux-3.9.5/include/linux/vserver/context_cmd.h 1970-01-01 00:00:00.000000000 +0000
10669 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/context_cmd.h 2013-05-31 14:47:11.000000000 +0000
10671 +#ifndef _VSERVER_CONTEXT_CMD_H
10672 +#define _VSERVER_CONTEXT_CMD_H
10674 +#include <uapi/vserver/context_cmd.h>
10676 +extern int vc_task_xid(uint32_t);
10678 +extern int vc_vx_info(struct vx_info *, void __user *);
10680 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10682 +extern int vc_ctx_create(uint32_t, void __user *);
10683 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10685 +extern int vc_get_cflags(struct vx_info *, void __user *);
10686 +extern int vc_set_cflags(struct vx_info *, void __user *);
10688 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10689 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10691 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10692 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10694 +extern int vc_get_umask(struct vx_info *, void __user *);
10695 +extern int vc_set_umask(struct vx_info *, void __user *);
10697 +extern int vc_get_wmask(struct vx_info *, void __user *);
10698 +extern int vc_set_wmask(struct vx_info *, void __user *);
10700 +extern int vc_get_badness(struct vx_info *, void __user *);
10701 +extern int vc_set_badness(struct vx_info *, void __user *);
10703 +#endif /* _VSERVER_CONTEXT_CMD_H */
10704 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/cvirt.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/cvirt.h
10705 --- linux-3.9.5/include/linux/vserver/cvirt.h 1970-01-01 00:00:00.000000000 +0000
10706 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/cvirt.h 2013-05-31 14:47:11.000000000 +0000
10708 +#ifndef _VSERVER_CVIRT_H
10709 +#define _VSERVER_CVIRT_H
10713 +void vx_vsi_boottime(struct timespec *);
10715 +void vx_vsi_uptime(struct timespec *, struct timespec *);
10720 +void vx_update_load(struct vx_info *);
10723 +int vx_do_syslog(int, char __user *, int);
10725 +#endif /* _VSERVER_CVIRT_H */
10726 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/cvirt_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/cvirt_cmd.h
10727 --- linux-3.9.5/include/linux/vserver/cvirt_cmd.h 1970-01-01 00:00:00.000000000 +0000
10728 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/cvirt_cmd.h 2013-05-31 14:47:11.000000000 +0000
10730 +#ifndef _VSERVER_CVIRT_CMD_H
10731 +#define _VSERVER_CVIRT_CMD_H
10734 +#include <linux/compiler.h>
10735 +#include <uapi/vserver/cvirt_cmd.h>
10737 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10738 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10740 +extern int vc_virt_stat(struct vx_info *, void __user *);
10742 +#endif /* _VSERVER_CVIRT_CMD_H */
10743 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/cvirt_def.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/cvirt_def.h
10744 --- linux-3.9.5/include/linux/vserver/cvirt_def.h 1970-01-01 00:00:00.000000000 +0000
10745 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/cvirt_def.h 2013-05-31 14:47:11.000000000 +0000
10747 +#ifndef _VSERVER_CVIRT_DEF_H
10748 +#define _VSERVER_CVIRT_DEF_H
10750 +#include <linux/jiffies.h>
10751 +#include <linux/spinlock.h>
10752 +#include <linux/wait.h>
10753 +#include <linux/time.h>
10754 +#include <asm/atomic.h>
10757 +struct _vx_usage_stat {
10761 + uint64_t softirq;
10767 +struct _vx_syslog {
10768 + wait_queue_head_t log_wait;
10769 + spinlock_t logbuf_lock; /* lock for the log buffer */
10771 + unsigned long log_start; /* next char to be read by syslog() */
10772 + unsigned long con_start; /* next char to be sent to consoles */
10773 + unsigned long log_end; /* most-recently-written-char + 1 */
10774 + unsigned long logged_chars; /* #chars since last read+clear operation */
10776 + char log_buf[1024];
10780 +/* context sub struct */
10782 +struct _vx_cvirt {
10783 + atomic_t nr_threads; /* number of current threads */
10784 + atomic_t nr_running; /* number of running threads */
10785 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10787 + atomic_t nr_onhold; /* processes on hold */
10788 + uint32_t onhold_last; /* jiffies when put on hold */
10790 + struct timespec bias_ts; /* time offset to the host */
10791 + struct timespec bias_idle;
10792 + struct timespec bias_uptime; /* context creation point */
10793 + uint64_t bias_clock; /* offset in clock_t */
10795 + spinlock_t load_lock; /* lock for the load averages */
10796 + atomic_t load_updates; /* nr of load updates done so far */
10797 + uint32_t load_last; /* last time load was calculated */
10798 + uint32_t load[3]; /* load averages 1,5,15 */
10800 + atomic_t total_forks; /* number of forks so far */
10802 + struct _vx_syslog syslog;
10805 +struct _vx_cvirt_pc {
10806 + struct _vx_usage_stat cpustat;
10810 +#ifdef CONFIG_VSERVER_DEBUG
10812 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
10814 + printk("\t_vx_cvirt:\n");
10815 + printk("\t threads: %4d, %4d, %4d, %4d\n",
10816 + atomic_read(&cvirt->nr_threads),
10817 + atomic_read(&cvirt->nr_running),
10818 + atomic_read(&cvirt->nr_uninterruptible),
10819 + atomic_read(&cvirt->nr_onhold));
10820 + /* add rest here */
10821 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
10826 +#endif /* _VSERVER_CVIRT_DEF_H */
10827 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/debug.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/debug.h
10828 --- linux-3.9.5/include/linux/vserver/debug.h 1970-01-01 00:00:00.000000000 +0000
10829 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/debug.h 2013-06-03 18:27:34.000000000 +0000
10831 +#ifndef _VSERVER_DEBUG_H
10832 +#define _VSERVER_DEBUG_H
10835 +#define VXD_CBIT(n, m) (vs_debug_ ## n & (1 << (m)))
10836 +#define VXD_CMIN(n, m) (vs_debug_ ## n > (m))
10837 +#define VXD_MASK(n, m) (vs_debug_ ## n & (m))
10839 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
10840 + imajor((d)->bd_inode), iminor((d)->bd_inode)
10841 +#define VXF_DEV "%p[%lu,%d:%d]"
10843 +#if defined(CONFIG_QUOTES_UTF8)
10844 +#define VS_Q_LQM "\xc2\xbb"
10845 +#define VS_Q_RQM "\xc2\xab"
10846 +#elif defined(CONFIG_QUOTES_ASCII)
10847 +#define VS_Q_LQM "\x27"
10848 +#define VS_Q_RQM "\x27"
10850 +#define VS_Q_LQM "\xbb"
10851 +#define VS_Q_RQM "\xab"
10854 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
10857 +#define vxd_path(p) \
10858 + ({ static char _buffer[PATH_MAX]; \
10859 + d_path(p, _buffer, sizeof(_buffer)); })
10861 +#define vxd_cond_path(n) \
10862 + ((n) ? vxd_path(&(n)->path) : "<null>" )
10865 +#ifdef CONFIG_VSERVER_DEBUG
10867 +extern unsigned int vs_debug_switch;
10868 +extern unsigned int vs_debug_xid;
10869 +extern unsigned int vs_debug_nid;
10870 +extern unsigned int vs_debug_tag;
10871 +extern unsigned int vs_debug_net;
10872 +extern unsigned int vs_debug_limit;
10873 +extern unsigned int vs_debug_cres;
10874 +extern unsigned int vs_debug_dlim;
10875 +extern unsigned int vs_debug_quota;
10876 +extern unsigned int vs_debug_cvirt;
10877 +extern unsigned int vs_debug_space;
10878 +extern unsigned int vs_debug_perm;
10879 +extern unsigned int vs_debug_misc;
10882 +#define VX_LOGLEVEL "vxD: "
10883 +#define VX_PROC_FMT "%p: "
10884 +#define VX_PROCESS current
10886 +#define vxdprintk(c, f, x...) \
10889 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
10890 + VX_PROCESS , ##x); \
10893 +#define vxlprintk(c, f, x...) \
10896 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
10899 +#define vxfprintk(c, f, x...) \
10902 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
10908 +void dump_vx_info(struct vx_info *, int);
10909 +void dump_vx_info_inactive(int);
10911 +#else /* CONFIG_VSERVER_DEBUG */
10913 +#define vs_debug_switch 0
10914 +#define vs_debug_xid 0
10915 +#define vs_debug_nid 0
10916 +#define vs_debug_tag 0
10917 +#define vs_debug_net 0
10918 +#define vs_debug_limit 0
10919 +#define vs_debug_cres 0
10920 +#define vs_debug_dlim 0
10921 +#define vs_debug_quota 0
10922 +#define vs_debug_cvirt 0
10923 +#define vs_debug_space 0
10924 +#define vs_debug_perm 0
10925 +#define vs_debug_misc 0
10927 +#define vxdprintk(x...) do { } while (0)
10928 +#define vxlprintk(x...) do { } while (0)
10929 +#define vxfprintk(x...) do { } while (0)
10931 +#endif /* CONFIG_VSERVER_DEBUG */
10934 +#ifdef CONFIG_VSERVER_WARN
10936 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
10937 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
10938 +#define VX_WARN_XID "[xid #%u] "
10939 +#define VX_WARN_NID "[nid #%u] "
10940 +#define VX_WARN_TAG "[tag #%u] "
10942 +#define vxwprintk(c, f, x...) \
10945 + printk(VX_WARNLEVEL f "\n", ##x); \
10948 +#else /* CONFIG_VSERVER_WARN */
10950 +#define vxwprintk(x...) do { } while (0)
10952 +#endif /* CONFIG_VSERVER_WARN */
10954 +#define vxwprintk_task(c, f, x...) \
10955 + vxwprintk(c, VX_WARN_TASK f, \
10956 + current->comm, current->pid, \
10957 + current->xid, current->nid, \
10958 + current->tag, ##x)
10959 +#define vxwprintk_xid(c, f, x...) \
10960 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
10961 +#define vxwprintk_nid(c, f, x...) \
10962 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
10963 +#define vxwprintk_tag(c, f, x...) \
10964 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
10966 +#ifdef CONFIG_VSERVER_DEBUG
10967 +#define vxd_assert_lock(l) assert_spin_locked(l)
10968 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
10969 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
10971 +#define vxd_assert_lock(l) do { } while (0)
10972 +#define vxd_assert(c, f, x...) do { } while (0)
10976 +#endif /* _VSERVER_DEBUG_H */
10977 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/debug_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/debug_cmd.h
10978 --- linux-3.9.5/include/linux/vserver/debug_cmd.h 1970-01-01 00:00:00.000000000 +0000
10979 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/debug_cmd.h 2013-05-31 14:47:11.000000000 +0000
10981 +#ifndef _VSERVER_DEBUG_CMD_H
10982 +#define _VSERVER_DEBUG_CMD_H
10984 +#include <uapi/vserver/debug_cmd.h>
10987 +#ifdef CONFIG_COMPAT
10989 +#include <asm/compat.h>
10991 +struct vcmd_read_history_v0_x32 {
10994 + compat_uptr_t data_ptr;
10997 +struct vcmd_read_monitor_v0_x32 {
11000 + compat_uptr_t data_ptr;
11003 +#endif /* CONFIG_COMPAT */
11005 +extern int vc_dump_history(uint32_t);
11007 +extern int vc_read_history(uint32_t, void __user *);
11008 +extern int vc_read_monitor(uint32_t, void __user *);
11010 +#ifdef CONFIG_COMPAT
11012 +extern int vc_read_history_x32(uint32_t, void __user *);
11013 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11015 +#endif /* CONFIG_COMPAT */
11017 +#endif /* _VSERVER_DEBUG_CMD_H */
11018 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/device.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/device.h
11019 --- linux-3.9.5/include/linux/vserver/device.h 1970-01-01 00:00:00.000000000 +0000
11020 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/device.h 2013-05-31 14:47:11.000000000 +0000
11022 +#ifndef _VSERVER_DEVICE_H
11023 +#define _VSERVER_DEVICE_H
11026 +#include <uapi/vserver/device.h>
11028 +#else /* _VSERVER_DEVICE_H */
11029 +#warning duplicate inclusion
11030 +#endif /* _VSERVER_DEVICE_H */
11031 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/device_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/device_cmd.h
11032 --- linux-3.9.5/include/linux/vserver/device_cmd.h 1970-01-01 00:00:00.000000000 +0000
11033 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/device_cmd.h 2013-05-31 14:47:11.000000000 +0000
11035 +#ifndef _VSERVER_DEVICE_CMD_H
11036 +#define _VSERVER_DEVICE_CMD_H
11038 +#include <uapi/vserver/device_cmd.h>
11041 +#ifdef CONFIG_COMPAT
11043 +#include <asm/compat.h>
11045 +struct vcmd_set_mapping_v0_x32 {
11046 + compat_uptr_t device_ptr;
11047 + compat_uptr_t target_ptr;
11051 +#endif /* CONFIG_COMPAT */
11053 +#include <linux/compiler.h>
11055 +extern int vc_set_mapping(struct vx_info *, void __user *);
11056 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11058 +#ifdef CONFIG_COMPAT
11060 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11061 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11063 +#endif /* CONFIG_COMPAT */
11065 +#endif /* _VSERVER_DEVICE_CMD_H */
11066 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/device_def.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/device_def.h
11067 --- linux-3.9.5/include/linux/vserver/device_def.h 1970-01-01 00:00:00.000000000 +0000
11068 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/device_def.h 2013-05-31 14:47:11.000000000 +0000
11070 +#ifndef _VSERVER_DEVICE_DEF_H
11071 +#define _VSERVER_DEVICE_DEF_H
11073 +#include <linux/types.h>
11075 +struct vx_dmap_target {
11080 +struct _vx_device {
11081 +#ifdef CONFIG_VSERVER_DEVICE
11082 + struct vx_dmap_target targets[2];
11086 +#endif /* _VSERVER_DEVICE_DEF_H */
11087 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/dlimit.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/dlimit.h
11088 --- linux-3.9.5/include/linux/vserver/dlimit.h 1970-01-01 00:00:00.000000000 +0000
11089 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/dlimit.h 2013-06-12 23:49:09.000000000 +0000
11091 +#ifndef _VSERVER_DLIMIT_H
11092 +#define _VSERVER_DLIMIT_H
11094 +#include "switch.h"
11099 +/* keep in sync with CDLIM_INFINITY */
11101 +#define DLIM_INFINITY (~0ULL)
11103 +#include <linux/spinlock.h>
11104 +#include <linux/rcupdate.h>
11106 +struct super_block;
11109 + struct hlist_node dl_hlist; /* linked list of contexts */
11110 + struct rcu_head dl_rcu; /* the rcu head */
11111 + vtag_t dl_tag; /* context tag */
11112 + atomic_t dl_usecnt; /* usage count */
11113 + atomic_t dl_refcnt; /* reference count */
11115 + struct super_block *dl_sb; /* associated superblock */
11117 + spinlock_t dl_lock; /* protect the values */
11119 + unsigned long long dl_space_used; /* used space in bytes */
11120 + unsigned long long dl_space_total; /* maximum space in bytes */
11121 + unsigned long dl_inodes_used; /* used inodes */
11122 + unsigned long dl_inodes_total; /* maximum inodes */
11124 + unsigned int dl_nrlmult; /* non root limit mult */
11129 +extern void rcu_free_dl_info(struct rcu_head *);
11130 +extern void unhash_dl_info(struct dl_info *);
11132 +extern struct dl_info *locate_dl_info(struct super_block *, vtag_t);
11137 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11139 +typedef uint64_t dlsize_t;
11141 +#endif /* __KERNEL__ */
11142 +#else /* _VSERVER_DLIMIT_H */
11143 +#warning duplicate inclusion
11144 +#endif /* _VSERVER_DLIMIT_H */
11145 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/dlimit_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/dlimit_cmd.h
11146 --- linux-3.9.5/include/linux/vserver/dlimit_cmd.h 1970-01-01 00:00:00.000000000 +0000
11147 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/dlimit_cmd.h 2013-05-31 14:47:11.000000000 +0000
11149 +#ifndef _VSERVER_DLIMIT_CMD_H
11150 +#define _VSERVER_DLIMIT_CMD_H
11152 +#include <uapi/vserver/dlimit_cmd.h>
11155 +#ifdef CONFIG_COMPAT
11157 +#include <asm/compat.h>
11159 +struct vcmd_ctx_dlimit_base_v0_x32 {
11160 + compat_uptr_t name_ptr;
11164 +struct vcmd_ctx_dlimit_v0_x32 {
11165 + compat_uptr_t name_ptr;
11166 + uint32_t space_used; /* used space in kbytes */
11167 + uint32_t space_total; /* maximum space in kbytes */
11168 + uint32_t inodes_used; /* used inodes */
11169 + uint32_t inodes_total; /* maximum inodes */
11170 + uint32_t reserved; /* reserved for root in % */
11174 +#endif /* CONFIG_COMPAT */
11176 +#include <linux/compiler.h>
11178 +extern int vc_add_dlimit(uint32_t, void __user *);
11179 +extern int vc_rem_dlimit(uint32_t, void __user *);
11181 +extern int vc_set_dlimit(uint32_t, void __user *);
11182 +extern int vc_get_dlimit(uint32_t, void __user *);
11184 +#ifdef CONFIG_COMPAT
11186 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11187 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11189 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11190 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11192 +#endif /* CONFIG_COMPAT */
11194 +#endif /* _VSERVER_DLIMIT_CMD_H */
11195 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/global.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/global.h
11196 --- linux-3.9.5/include/linux/vserver/global.h 1970-01-01 00:00:00.000000000 +0000
11197 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/global.h 2013-05-31 14:47:11.000000000 +0000
11199 +#ifndef _VSERVER_GLOBAL_H
11200 +#define _VSERVER_GLOBAL_H
11203 +extern atomic_t vx_global_ctotal;
11204 +extern atomic_t vx_global_cactive;
11206 +extern atomic_t nx_global_ctotal;
11207 +extern atomic_t nx_global_cactive;
11209 +extern atomic_t vs_global_nsproxy;
11210 +extern atomic_t vs_global_fs;
11211 +extern atomic_t vs_global_mnt_ns;
11212 +extern atomic_t vs_global_uts_ns;
11213 +extern atomic_t vs_global_user_ns;
11214 +extern atomic_t vs_global_pid_ns;
11217 +#endif /* _VSERVER_GLOBAL_H */
11218 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/history.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/history.h
11219 --- linux-3.9.5/include/linux/vserver/history.h 1970-01-01 00:00:00.000000000 +0000
11220 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/history.h 2013-05-31 14:47:11.000000000 +0000
11222 +#ifndef _VSERVER_HISTORY_H
11223 +#define _VSERVER_HISTORY_H
11228 + VXH_THROW_OOPS = 1,
11232 + VXH_INIT_VX_INFO,
11235 + VXH_CLAIM_VX_INFO,
11236 + VXH_RELEASE_VX_INFO,
11237 + VXH_ALLOC_VX_INFO,
11238 + VXH_DEALLOC_VX_INFO,
11239 + VXH_HASH_VX_INFO,
11240 + VXH_UNHASH_VX_INFO,
11242 + VXH_LOOKUP_VX_INFO,
11243 + VXH_CREATE_VX_INFO,
11246 +struct _vxhe_vxi {
11247 + struct vx_info *ptr;
11253 +struct _vxhe_set_clr {
11257 +struct _vxhe_loc_lookup {
11261 +struct _vx_hist_entry {
11263 + unsigned short seq;
11264 + unsigned short type;
11265 + struct _vxhe_vxi vxi;
11267 + struct _vxhe_set_clr sc;
11268 + struct _vxhe_loc_lookup ll;
11272 +#ifdef CONFIG_VSERVER_HISTORY
11274 +extern unsigned volatile int vxh_active;
11276 +struct _vx_hist_entry *vxh_advance(void *loc);
11280 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11282 + entry->vxi.ptr = vxi;
11284 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11285 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11286 + entry->vxi.xid = vxi->vx_id;
11291 +#define __HERE__ current_text_addr()
11293 +#define __VXH_BODY(__type, __data, __here) \
11294 + struct _vx_hist_entry *entry; \
11296 + preempt_disable(); \
11297 + entry = vxh_advance(__here); \
11299 + entry->type = __type; \
11300 + preempt_enable();
11303 + /* pass vxi only */
11305 +#define __VXH_SMPL \
11306 + __vxh_copy_vxi(entry, vxi)
11309 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11311 + __VXH_BODY(__type, __VXH_SMPL, __here)
11314 + /* pass vxi and data (void *) */
11316 +#define __VXH_DATA \
11317 + __vxh_copy_vxi(entry, vxi); \
11318 + entry->sc.data = data
11321 +void __vxh_data(struct vx_info *vxi, void *data,
11322 + int __type, void *__here)
11324 + __VXH_BODY(__type, __VXH_DATA, __here)
11327 + /* pass vxi and arg (long) */
11329 +#define __VXH_LONG \
11330 + __vxh_copy_vxi(entry, vxi); \
11331 + entry->ll.arg = arg
11334 +void __vxh_long(struct vx_info *vxi, long arg,
11335 + int __type, void *__here)
11337 + __VXH_BODY(__type, __VXH_LONG, __here)
11342 +void __vxh_throw_oops(void *__here)
11344 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11345 + /* prevent further acquisition */
11350 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11352 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11353 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11355 +#define __vxh_init_vx_info(v, d, h) \
11356 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11357 +#define __vxh_set_vx_info(v, d, h) \
11358 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11359 +#define __vxh_clr_vx_info(v, d, h) \
11360 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11362 +#define __vxh_claim_vx_info(v, d, h) \
11363 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11364 +#define __vxh_release_vx_info(v, d, h) \
11365 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11367 +#define vxh_alloc_vx_info(v) \
11368 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11369 +#define vxh_dealloc_vx_info(v) \
11370 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11372 +#define vxh_hash_vx_info(v) \
11373 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11374 +#define vxh_unhash_vx_info(v) \
11375 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11377 +#define vxh_loc_vx_info(v, l) \
11378 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11379 +#define vxh_lookup_vx_info(v, l) \
11380 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11381 +#define vxh_create_vx_info(v, l) \
11382 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11384 +extern void vxh_dump_history(void);
11387 +#else /* CONFIG_VSERVER_HISTORY */
11389 +#define __HERE__ 0
11391 +#define vxh_throw_oops() do { } while (0)
11393 +#define __vxh_get_vx_info(v, h) do { } while (0)
11394 +#define __vxh_put_vx_info(v, h) do { } while (0)
11396 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11397 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11398 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11400 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11401 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11403 +#define vxh_alloc_vx_info(v) do { } while (0)
11404 +#define vxh_dealloc_vx_info(v) do { } while (0)
11406 +#define vxh_hash_vx_info(v) do { } while (0)
11407 +#define vxh_unhash_vx_info(v) do { } while (0)
11409 +#define vxh_loc_vx_info(v, l) do { } while (0)
11410 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11411 +#define vxh_create_vx_info(v, l) do { } while (0)
11413 +#define vxh_dump_history() do { } while (0)
11416 +#endif /* CONFIG_VSERVER_HISTORY */
11418 +#endif /* _VSERVER_HISTORY_H */
11419 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/inode.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/inode.h
11420 --- linux-3.9.5/include/linux/vserver/inode.h 1970-01-01 00:00:00.000000000 +0000
11421 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/inode.h 2013-05-31 14:47:11.000000000 +0000
11423 +#ifndef _VSERVER_INODE_H
11424 +#define _VSERVER_INODE_H
11426 +#include <uapi/vserver/inode.h>
11429 +#ifdef CONFIG_VSERVER_PROC_SECURE
11430 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11431 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11433 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11434 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11437 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11439 +#else /* _VSERVER_INODE_H */
11440 +#warning duplicate inclusion
11441 +#endif /* _VSERVER_INODE_H */
11442 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/inode_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/inode_cmd.h
11443 --- linux-3.9.5/include/linux/vserver/inode_cmd.h 1970-01-01 00:00:00.000000000 +0000
11444 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/inode_cmd.h 2013-05-31 14:47:11.000000000 +0000
11446 +#ifndef _VSERVER_INODE_CMD_H
11447 +#define _VSERVER_INODE_CMD_H
11449 +#include <uapi/vserver/inode_cmd.h>
11453 +#ifdef CONFIG_COMPAT
11455 +#include <asm/compat.h>
11457 +struct vcmd_ctx_iattr_v1_x32 {
11458 + compat_uptr_t name_ptr;
11464 +#endif /* CONFIG_COMPAT */
11466 +#include <linux/compiler.h>
11468 +extern int vc_get_iattr(void __user *);
11469 +extern int vc_set_iattr(void __user *);
11471 +extern int vc_fget_iattr(uint32_t, void __user *);
11472 +extern int vc_fset_iattr(uint32_t, void __user *);
11474 +#ifdef CONFIG_COMPAT
11476 +extern int vc_get_iattr_x32(void __user *);
11477 +extern int vc_set_iattr_x32(void __user *);
11479 +#endif /* CONFIG_COMPAT */
11481 +#endif /* _VSERVER_INODE_CMD_H */
11482 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/limit.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/limit.h
11483 --- linux-3.9.5/include/linux/vserver/limit.h 1970-01-01 00:00:00.000000000 +0000
11484 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/limit.h 2013-05-31 14:47:11.000000000 +0000
11486 +#ifndef _VSERVER_LIMIT_H
11487 +#define _VSERVER_LIMIT_H
11489 +#include <uapi/vserver/limit.h>
11492 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
11494 +/* keep in sync with CRLIM_INFINITY */
11496 +#define VLIM_INFINITY (~0ULL)
11498 +#include <asm/atomic.h>
11499 +#include <asm/resource.h>
11501 +#ifndef RLIM_INFINITY
11502 +#warning RLIM_INFINITY is undefined
11505 +#define __rlim_val(l, r, v) ((l)->res[r].v)
11507 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
11508 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
11510 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
11511 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
11512 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
11514 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
11515 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
11517 +typedef atomic_long_t rlim_atomic_t;
11518 +typedef unsigned long rlim_t;
11520 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
11521 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
11522 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
11523 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
11524 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
11525 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
11528 +#if (RLIM_INFINITY == VLIM_INFINITY)
11529 +#define VX_VLIM(r) ((long long)(long)(r))
11530 +#define VX_RLIM(v) ((rlim_t)(v))
11532 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
11533 + ? VLIM_INFINITY : (long long)(r))
11534 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
11535 + ? RLIM_INFINITY : (rlim_t)(v))
11540 +void vx_vsi_meminfo(struct sysinfo *);
11541 +void vx_vsi_swapinfo(struct sysinfo *);
11542 +long vx_vsi_cached(struct sysinfo *);
11544 +#define NUM_LIMITS 24
11546 +#endif /* _VSERVER_LIMIT_H */
11547 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/limit_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/limit_cmd.h
11548 --- linux-3.9.5/include/linux/vserver/limit_cmd.h 1970-01-01 00:00:00.000000000 +0000
11549 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/limit_cmd.h 2013-05-31 14:47:11.000000000 +0000
11551 +#ifndef _VSERVER_LIMIT_CMD_H
11552 +#define _VSERVER_LIMIT_CMD_H
11554 +#include <uapi/vserver/limit_cmd.h>
11557 +#ifdef CONFIG_IA32_EMULATION
11559 +struct vcmd_ctx_rlimit_v0_x32 {
11561 + uint64_t minimum;
11562 + uint64_t softlimit;
11563 + uint64_t maximum;
11564 +} __attribute__ ((packed));
11566 +#endif /* CONFIG_IA32_EMULATION */
11568 +#include <linux/compiler.h>
11570 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11571 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11572 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11573 +extern int vc_reset_hits(struct vx_info *, void __user *);
11574 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11576 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11578 +#ifdef CONFIG_IA32_EMULATION
11580 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11581 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11583 +#endif /* CONFIG_IA32_EMULATION */
11585 +#endif /* _VSERVER_LIMIT_CMD_H */
11586 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/limit_def.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/limit_def.h
11587 --- linux-3.9.5/include/linux/vserver/limit_def.h 1970-01-01 00:00:00.000000000 +0000
11588 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/limit_def.h 2013-05-31 14:47:11.000000000 +0000
11590 +#ifndef _VSERVER_LIMIT_DEF_H
11591 +#define _VSERVER_LIMIT_DEF_H
11593 +#include <asm/atomic.h>
11594 +#include <asm/resource.h>
11596 +#include "limit.h"
11599 +struct _vx_res_limit {
11600 + rlim_t soft; /* Context soft limit */
11601 + rlim_t hard; /* Context hard limit */
11603 + rlim_atomic_t rcur; /* Current value */
11604 + rlim_t rmin; /* Context minimum */
11605 + rlim_t rmax; /* Context maximum */
11607 + atomic_t lhit; /* Limit hits */
11610 +/* context sub struct */
11612 +struct _vx_limit {
11613 + struct _vx_res_limit res[NUM_LIMITS];
11616 +#ifdef CONFIG_VSERVER_DEBUG
11618 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11622 + printk("\t_vx_limit:");
11623 + for (i = 0; i < NUM_LIMITS; i++) {
11624 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11625 + i, (unsigned long)__rlim_get(limit, i),
11626 + (unsigned long)__rlim_rmin(limit, i),
11627 + (unsigned long)__rlim_rmax(limit, i),
11628 + (long)__rlim_soft(limit, i),
11629 + (long)__rlim_hard(limit, i),
11630 + atomic_read(&__rlim_lhit(limit, i)));
11636 +#endif /* _VSERVER_LIMIT_DEF_H */
11637 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/limit_int.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/limit_int.h
11638 --- linux-3.9.5/include/linux/vserver/limit_int.h 1970-01-01 00:00:00.000000000 +0000
11639 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/limit_int.h 2013-05-31 14:47:11.000000000 +0000
11641 +#ifndef _VSERVER_LIMIT_INT_H
11642 +#define _VSERVER_LIMIT_INT_H
11644 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
11645 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
11647 +extern const char *vlimit_name[NUM_LIMITS];
11649 +static inline void __vx_acc_cres(struct vx_info *vxi,
11650 + int res, int dir, void *_data, char *_file, int _line)
11652 + if (VXD_RCRES_COND(res))
11653 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
11654 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11655 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11656 + (dir > 0) ? "++" : "--", _data, _file, _line);
11661 + __rlim_inc(&vxi->limit, res);
11663 + __rlim_dec(&vxi->limit, res);
11666 +static inline void __vx_add_cres(struct vx_info *vxi,
11667 + int res, int amount, void *_data, char *_file, int _line)
11669 + if (VXD_RCRES_COND(res))
11670 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
11671 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11672 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11673 + amount, _data, _file, _line);
11678 + __rlim_add(&vxi->limit, res, amount);
11682 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
11684 + int cond = (value > __rlim_rmax(limit, res));
11687 + __rlim_rmax(limit, res) = value;
11692 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
11694 + int cond = (value < __rlim_rmin(limit, res));
11697 + __rlim_rmin(limit, res) = value;
11702 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
11704 + if (!__vx_cres_adjust_max(limit, res, value))
11705 + __vx_cres_adjust_min(limit, res, value);
11710 + +1 ... no limit hit
11711 + -1 ... over soft limit
11712 + 0 ... over hard limit */
11714 +static inline int __vx_cres_avail(struct vx_info *vxi,
11715 + int res, int num, char *_file, int _line)
11717 + struct _vx_limit *limit;
11720 + if (VXD_RLIMIT_COND(res))
11721 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
11722 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11723 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
11724 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
11725 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11726 + num, _file, _line);
11730 + limit = &vxi->limit;
11731 + value = __rlim_get(limit, res);
11733 + if (!__vx_cres_adjust_max(limit, res, value))
11734 + __vx_cres_adjust_min(limit, res, value);
11739 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
11741 + if (value + num <= __rlim_soft(limit, res))
11744 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
11746 + if (value + num <= __rlim_hard(limit, res))
11749 + __rlim_hit(limit, res);
11754 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
11757 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
11759 + rlim_t value, sum = 0;
11762 + while ((res = *array++)) {
11763 + value = __rlim_get(limit, res);
11764 + __vx_cres_fixup(limit, res, value);
11771 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
11773 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
11774 + int res = *array;
11776 + if (value == __rlim_get(limit, res))
11779 + __rlim_set(limit, res, value);
11780 + /* now adjust min/max */
11781 + if (!__vx_cres_adjust_max(limit, res, value))
11782 + __vx_cres_adjust_min(limit, res, value);
11787 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
11788 + const int *array, int num, char *_file, int _line)
11790 + struct _vx_limit *limit;
11791 + rlim_t value = 0;
11799 + limit = &vxi->limit;
11801 + value = __vx_cres_array_sum(limit, array + 1);
11803 + __rlim_set(limit, res, value);
11804 + __vx_cres_fixup(limit, res, value);
11806 + return __vx_cres_avail(vxi, res, num, _file, _line);
11810 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
11815 + /* complex resources first */
11816 + if ((id < 0) || (id == RLIMIT_RSS))
11817 + __vx_cres_array_fixup(limit, VLA_RSS);
11819 + for (res = 0; res < NUM_LIMITS; res++) {
11820 + if ((id > 0) && (res != id))
11823 + value = __rlim_get(limit, res);
11824 + __vx_cres_fixup(limit, res, value);
11826 + /* not supposed to happen, maybe warn? */
11827 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
11828 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
11833 +#endif /* _VSERVER_LIMIT_INT_H */
11834 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/monitor.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/monitor.h
11835 --- linux-3.9.5/include/linux/vserver/monitor.h 1970-01-01 00:00:00.000000000 +0000
11836 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/monitor.h 2013-05-31 14:47:11.000000000 +0000
11838 +#ifndef _VSERVER_MONITOR_H
11839 +#define _VSERVER_MONITOR_H
11841 +#include <uapi/vserver/monitor.h>
11843 +#endif /* _VSERVER_MONITOR_H */
11844 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/network.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/network.h
11845 --- linux-3.9.5/include/linux/vserver/network.h 1970-01-01 00:00:00.000000000 +0000
11846 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/network.h 2013-06-12 23:49:09.000000000 +0000
11848 +#ifndef _VSERVER_NETWORK_H
11849 +#define _VSERVER_NETWORK_H
11852 +#include <linux/list.h>
11853 +#include <linux/spinlock.h>
11854 +#include <linux/rcupdate.h>
11855 +#include <linux/in.h>
11856 +#include <linux/in6.h>
11857 +#include <asm/atomic.h>
11858 +#include <uapi/vserver/network.h>
11860 +struct nx_addr_v4 {
11861 + struct nx_addr_v4 *next;
11862 + struct in_addr ip[2];
11863 + struct in_addr mask;
11868 +struct nx_addr_v6 {
11869 + struct nx_addr_v6 *next;
11870 + struct in6_addr ip;
11871 + struct in6_addr mask;
11878 + struct hlist_node nx_hlist; /* linked list of nxinfos */
11879 + vnid_t nx_id; /* vnet id */
11880 + atomic_t nx_usecnt; /* usage count */
11881 + atomic_t nx_tasks; /* tasks count */
11882 + int nx_state; /* context state */
11884 + uint64_t nx_flags; /* network flag word */
11885 + uint64_t nx_ncaps; /* network capabilities */
11887 + spinlock_t addr_lock; /* protect address changes */
11888 + struct in_addr v4_lback; /* Loopback address */
11889 + struct in_addr v4_bcast; /* Broadcast address */
11890 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
11891 +#ifdef CONFIG_IPV6
11892 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
11894 + char nx_name[65]; /* network context name */
11898 +/* status flags */
11900 +#define NXS_HASHED 0x0001
11901 +#define NXS_SHUTDOWN 0x0100
11902 +#define NXS_RELEASED 0x8000
11904 +extern struct nx_info *lookup_nx_info(int);
11906 +extern int get_nid_list(int, unsigned int *, int);
11907 +extern int nid_is_hashed(vnid_t);
11909 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
11911 +extern long vs_net_change(struct nx_info *, unsigned int);
11916 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
11917 +#ifdef CONFIG_IPV6
11918 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
11920 +#define NX_IPV6(n) (0)
11923 +#endif /* _VSERVER_NETWORK_H */
11924 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/network_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/network_cmd.h
11925 --- linux-3.9.5/include/linux/vserver/network_cmd.h 1970-01-01 00:00:00.000000000 +0000
11926 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/network_cmd.h 2013-05-31 14:47:11.000000000 +0000
11928 +#ifndef _VSERVER_NETWORK_CMD_H
11929 +#define _VSERVER_NETWORK_CMD_H
11931 +#include <uapi/vserver/network_cmd.h>
11933 +extern int vc_task_nid(uint32_t);
11935 +extern int vc_nx_info(struct nx_info *, void __user *);
11937 +extern int vc_net_create(uint32_t, void __user *);
11938 +extern int vc_net_migrate(struct nx_info *, void __user *);
11940 +extern int vc_net_add(struct nx_info *, void __user *);
11941 +extern int vc_net_remove(struct nx_info *, void __user *);
11943 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
11944 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
11946 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
11947 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
11949 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
11950 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
11952 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
11953 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
11955 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
11956 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
11958 +extern int vc_get_nflags(struct nx_info *, void __user *);
11959 +extern int vc_set_nflags(struct nx_info *, void __user *);
11961 +extern int vc_get_ncaps(struct nx_info *, void __user *);
11962 +extern int vc_set_ncaps(struct nx_info *, void __user *);
11964 +#endif /* _VSERVER_CONTEXT_CMD_H */
11965 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/percpu.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/percpu.h
11966 --- linux-3.9.5/include/linux/vserver/percpu.h 1970-01-01 00:00:00.000000000 +0000
11967 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/percpu.h 2013-05-31 14:47:11.000000000 +0000
11969 +#ifndef _VSERVER_PERCPU_H
11970 +#define _VSERVER_PERCPU_H
11972 +#include "cvirt_def.h"
11973 +#include "sched_def.h"
11975 +struct _vx_percpu {
11976 + struct _vx_cvirt_pc cvirt;
11977 + struct _vx_sched_pc sched;
11980 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
11982 +#endif /* _VSERVER_PERCPU_H */
11983 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/pid.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/pid.h
11984 --- linux-3.9.5/include/linux/vserver/pid.h 1970-01-01 00:00:00.000000000 +0000
11985 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/pid.h 2013-05-31 14:47:11.000000000 +0000
11987 +#ifndef _VSERVER_PID_H
11988 +#define _VSERVER_PID_H
11990 +/* pid faking stuff */
11992 +#define vx_info_map_pid(v, p) \
11993 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
11994 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
11995 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
11996 +#define vx_map_tgid(p) vx_map_pid(p)
11998 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
11999 + const char *func, const char *file, int line)
12001 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12002 + vxfprintk(VXD_CBIT(cvirt, 2),
12003 + "vx_map_tgid: %p/%llx: %d -> %d",
12004 + vxi, (long long)vxi->vx_flags, pid,
12005 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12006 + func, file, line);
12009 + if (pid == vxi->vx_initpid)
12015 +#define vx_info_rmap_pid(v, p) \
12016 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12017 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
12018 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12020 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12021 + const char *func, const char *file, int line)
12023 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12024 + vxfprintk(VXD_CBIT(cvirt, 2),
12025 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12026 + vxi, (long long)vxi->vx_flags, pid,
12027 + (pid == 1) ? vxi->vx_initpid : pid,
12028 + func, file, line);
12029 + if ((pid == 1) && vxi->vx_initpid)
12030 + return vxi->vx_initpid;
12031 + if (pid == vxi->vx_initpid)
12038 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/sched.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/sched.h
12039 --- linux-3.9.5/include/linux/vserver/sched.h 1970-01-01 00:00:00.000000000 +0000
12040 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/sched.h 2013-05-31 14:47:11.000000000 +0000
12042 +#ifndef _VSERVER_SCHED_H
12043 +#define _VSERVER_SCHED_H
12050 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12055 +void vx_update_load(struct vx_info *);
12058 +void vx_update_sched_param(struct _vx_sched *sched,
12059 + struct _vx_sched_pc *sched_pc);
12061 +#endif /* __KERNEL__ */
12062 +#else /* _VSERVER_SCHED_H */
12063 +#warning duplicate inclusion
12064 +#endif /* _VSERVER_SCHED_H */
12065 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/sched_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/sched_cmd.h
12066 --- linux-3.9.5/include/linux/vserver/sched_cmd.h 1970-01-01 00:00:00.000000000 +0000
12067 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/sched_cmd.h 2013-05-31 14:47:11.000000000 +0000
12069 +#ifndef _VSERVER_SCHED_CMD_H
12070 +#define _VSERVER_SCHED_CMD_H
12073 +#include <linux/compiler.h>
12074 +#include <uapi/vserver/sched_cmd.h>
12076 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
12077 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
12079 +#endif /* _VSERVER_SCHED_CMD_H */
12080 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/sched_def.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/sched_def.h
12081 --- linux-3.9.5/include/linux/vserver/sched_def.h 1970-01-01 00:00:00.000000000 +0000
12082 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/sched_def.h 2013-05-31 14:47:11.000000000 +0000
12084 +#ifndef _VSERVER_SCHED_DEF_H
12085 +#define _VSERVER_SCHED_DEF_H
12087 +#include <linux/spinlock.h>
12088 +#include <linux/jiffies.h>
12089 +#include <linux/cpumask.h>
12090 +#include <asm/atomic.h>
12091 +#include <asm/param.h>
12094 +/* context sub struct */
12096 +struct _vx_sched {
12097 + int prio_bias; /* bias offset for priority */
12099 + cpumask_t update; /* CPUs which should update */
12102 +struct _vx_sched_pc {
12103 + int prio_bias; /* bias offset for priority */
12105 + uint64_t user_ticks; /* token tick events */
12106 + uint64_t sys_ticks; /* token tick events */
12107 + uint64_t hold_ticks; /* token ticks paused */
12111 +#ifdef CONFIG_VSERVER_DEBUG
12113 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12115 + printk("\t_vx_sched:\n");
12116 + printk("\t priority = %4d\n", sched->prio_bias);
12121 +#endif /* _VSERVER_SCHED_DEF_H */
12122 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/signal.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/signal.h
12123 --- linux-3.9.5/include/linux/vserver/signal.h 1970-01-01 00:00:00.000000000 +0000
12124 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/signal.h 2013-05-31 14:47:11.000000000 +0000
12126 +#ifndef _VSERVER_SIGNAL_H
12127 +#define _VSERVER_SIGNAL_H
12134 +int vx_info_kill(struct vx_info *, int, int);
12136 +#endif /* __KERNEL__ */
12137 +#else /* _VSERVER_SIGNAL_H */
12138 +#warning duplicate inclusion
12139 +#endif /* _VSERVER_SIGNAL_H */
12140 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/signal_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/signal_cmd.h
12141 --- linux-3.9.5/include/linux/vserver/signal_cmd.h 1970-01-01 00:00:00.000000000 +0000
12142 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/signal_cmd.h 2013-05-31 14:47:11.000000000 +0000
12144 +#ifndef _VSERVER_SIGNAL_CMD_H
12145 +#define _VSERVER_SIGNAL_CMD_H
12147 +#include <uapi/vserver/signal_cmd.h>
12150 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12151 +extern int vc_wait_exit(struct vx_info *, void __user *);
12154 +extern int vc_get_pflags(uint32_t pid, void __user *);
12155 +extern int vc_set_pflags(uint32_t pid, void __user *);
12157 +#endif /* _VSERVER_SIGNAL_CMD_H */
12158 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/space.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/space.h
12159 --- linux-3.9.5/include/linux/vserver/space.h 1970-01-01 00:00:00.000000000 +0000
12160 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/space.h 2013-05-31 14:47:11.000000000 +0000
12162 +#ifndef _VSERVER_SPACE_H
12163 +#define _VSERVER_SPACE_H
12165 +#include <linux/types.h>
12169 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
12171 +#else /* _VSERVER_SPACE_H */
12172 +#warning duplicate inclusion
12173 +#endif /* _VSERVER_SPACE_H */
12174 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/space_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/space_cmd.h
12175 --- linux-3.9.5/include/linux/vserver/space_cmd.h 1970-01-01 00:00:00.000000000 +0000
12176 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/space_cmd.h 2013-05-31 14:47:11.000000000 +0000
12178 +#ifndef _VSERVER_SPACE_CMD_H
12179 +#define _VSERVER_SPACE_CMD_H
12181 +#include <uapi/vserver/space_cmd.h>
12184 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
12185 +extern int vc_set_space_v1(struct vx_info *, void __user *);
12186 +extern int vc_enter_space(struct vx_info *, void __user *);
12187 +extern int vc_set_space(struct vx_info *, void __user *);
12188 +extern int vc_get_space_mask(void __user *, int);
12190 +#endif /* _VSERVER_SPACE_CMD_H */
12191 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/switch.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/switch.h
12192 --- linux-3.9.5/include/linux/vserver/switch.h 1970-01-01 00:00:00.000000000 +0000
12193 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/switch.h 2013-05-31 14:47:11.000000000 +0000
12195 +#ifndef _VSERVER_SWITCH_H
12196 +#define _VSERVER_SWITCH_H
12199 +#include <linux/errno.h>
12200 +#include <uapi/vserver/switch.h>
12202 +#endif /* _VSERVER_SWITCH_H */
12203 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/tag.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/tag.h
12204 --- linux-3.9.5/include/linux/vserver/tag.h 1970-01-01 00:00:00.000000000 +0000
12205 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/tag.h 2013-06-12 23:49:09.000000000 +0000
12210 +#include <linux/types.h>
12211 +#include <linux/uidgid.h>
12214 +#define DX_TAG(in) (IS_TAGGED(in))
12217 +#ifdef CONFIG_TAG_NFSD
12218 +#define DX_TAG_NFSD 1
12220 +#define DX_TAG_NFSD 0
12224 +#ifdef CONFIG_TAGGING_NONE
12226 +#define MAX_UID 0xFFFFFFFF
12227 +#define MAX_GID 0xFFFFFFFF
12229 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
12231 +#define TAGINO_UID(cond, uid, tag) (uid)
12232 +#define TAGINO_GID(cond, gid, tag) (gid)
12237 +#ifdef CONFIG_TAGGING_GID16
12239 +#define MAX_UID 0xFFFFFFFF
12240 +#define MAX_GID 0x0000FFFF
12242 +#define INOTAG_TAG(cond, uid, gid, tag) \
12243 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
12245 +#define TAGINO_UID(cond, uid, tag) (uid)
12246 +#define TAGINO_GID(cond, gid, tag) \
12247 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
12252 +#ifdef CONFIG_TAGGING_ID24
12254 +#define MAX_UID 0x00FFFFFF
12255 +#define MAX_GID 0x00FFFFFF
12257 +#define INOTAG_TAG(cond, uid, gid, tag) \
12258 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
12260 +#define TAGINO_UID(cond, uid, tag) \
12261 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
12262 +#define TAGINO_GID(cond, gid, tag) \
12263 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
12268 +#ifdef CONFIG_TAGGING_UID16
12270 +#define MAX_UID 0x0000FFFF
12271 +#define MAX_GID 0xFFFFFFFF
12273 +#define INOTAG_TAG(cond, uid, gid, tag) \
12274 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
12276 +#define TAGINO_UID(cond, uid, tag) \
12277 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
12278 +#define TAGINO_GID(cond, gid, tag) (gid)
12283 +#ifdef CONFIG_TAGGING_INTERN
12285 +#define MAX_UID 0xFFFFFFFF
12286 +#define MAX_GID 0xFFFFFFFF
12288 +#define INOTAG_TAG(cond, uid, gid, tag) \
12289 + ((cond) ? (tag) : 0)
12291 +#define TAGINO_UID(cond, uid, tag) (uid)
12292 +#define TAGINO_GID(cond, gid, tag) (gid)
12297 +#ifndef CONFIG_TAGGING_NONE
12298 +#define dx_current_fstag(sb) \
12299 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
12301 +#define dx_current_fstag(sb) (0)
12304 +#ifndef CONFIG_TAGGING_INTERN
12305 +#define TAGINO_TAG(cond, tag) (0)
12307 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
12310 +#define TAGINO_KUID(cond, kuid, ktag) \
12311 + KUIDT_INIT(TAGINO_UID(cond, __kuid_val(kuid), __ktag_val(ktag)))
12312 +#define TAGINO_KGID(cond, kgid, ktag) \
12313 + KGIDT_INIT(TAGINO_GID(cond, __kgid_val(kgid), __ktag_val(ktag)))
12314 +#define TAGINO_KTAG(cond, ktag) \
12315 + KTAGT_INIT(TAGINO_TAG(cond, __ktag_val(ktag)))
12318 +#define INOTAG_UID(cond, uid, gid) \
12319 + ((cond) ? ((uid) & MAX_UID) : (uid))
12320 +#define INOTAG_GID(cond, uid, gid) \
12321 + ((cond) ? ((gid) & MAX_GID) : (gid))
12323 +#define INOTAG_KUID(cond, kuid, kgid) \
12324 + KUIDT_INIT(INOTAG_UID(cond, __kuid_val(kuid), __kgid_val(kgid)))
12325 +#define INOTAG_KGID(cond, kuid, kgid) \
12326 + KGIDT_INIT(INOTAG_GID(cond, __kuid_val(kuid), __kgid_val(kgid)))
12327 +#define INOTAG_KTAG(cond, kuid, kgid, ktag) \
12328 + KTAGT_INIT(INOTAG_TAG(cond, \
12329 + __kuid_val(kuid), __kgid_val(kgid), __ktag_val(ktag)))
12332 +static inline uid_t dx_map_uid(uid_t uid)
12334 + if ((uid > MAX_UID) && (uid != -1))
12336 + return (uid & MAX_UID);
12339 +static inline gid_t dx_map_gid(gid_t gid)
12341 + if ((gid > MAX_GID) && (gid != -1))
12343 + return (gid & MAX_GID);
12351 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
12353 +int dx_parse_tag(char *string, vtag_t *tag, int remove, int *mnt_flags,
12354 + unsigned long *flags);
12356 +#ifdef CONFIG_PROPAGATE
12358 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
12360 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
12363 +#define dx_propagate_tag(n, i) do { } while (0)
12366 +#endif /* _DX_TAG_H */
12367 diff -NurpP --minimal linux-3.9.5/include/linux/vserver/tag_cmd.h linux-3.9.5-vs2.3.6.5/include/linux/vserver/tag_cmd.h
12368 --- linux-3.9.5/include/linux/vserver/tag_cmd.h 1970-01-01 00:00:00.000000000 +0000
12369 +++ linux-3.9.5-vs2.3.6.5/include/linux/vserver/tag_cmd.h 2013-05-31 14:47:11.000000000 +0000
12371 +#ifndef _VSERVER_TAG_CMD_H
12372 +#define _VSERVER_TAG_CMD_H
12374 +#include <uapi/vserver/tag_cmd.h>
12376 +extern int vc_task_tag(uint32_t);
12378 +extern int vc_tag_migrate(uint32_t);
12380 +#endif /* _VSERVER_TAG_CMD_H */
12381 diff -NurpP --minimal linux-3.9.5/include/net/addrconf.h linux-3.9.5-vs2.3.6.5/include/net/addrconf.h
12382 --- linux-3.9.5/include/net/addrconf.h 2013-05-31 13:45:28.000000000 +0000
12383 +++ linux-3.9.5-vs2.3.6.5/include/net/addrconf.h 2013-05-31 17:17:53.000000000 +0000
12384 @@ -85,7 +85,8 @@ extern int ipv6_dev_get_saddr(struct n
12385 const struct net_device *dev,
12386 const struct in6_addr *daddr,
12387 unsigned int srcprefs,
12388 - struct in6_addr *saddr);
12389 + struct in6_addr *saddr,
12390 + struct nx_info *nxi);
12391 extern int ipv6_get_lladdr(struct net_device *dev,
12392 struct in6_addr *addr,
12393 unsigned char banned_flags);
12394 diff -NurpP --minimal linux-3.9.5/include/net/af_unix.h linux-3.9.5-vs2.3.6.5/include/net/af_unix.h
12395 --- linux-3.9.5/include/net/af_unix.h 2013-02-19 13:58:52.000000000 +0000
12396 +++ linux-3.9.5-vs2.3.6.5/include/net/af_unix.h 2013-05-31 17:17:53.000000000 +0000
12398 #include <linux/socket.h>
12399 #include <linux/un.h>
12400 #include <linux/mutex.h>
12401 +#include <linux/vs_base.h>
12402 #include <net/sock.h>
12404 extern void unix_inflight(struct file *fp);
12405 diff -NurpP --minimal linux-3.9.5/include/net/inet_timewait_sock.h linux-3.9.5-vs2.3.6.5/include/net/inet_timewait_sock.h
12406 --- linux-3.9.5/include/net/inet_timewait_sock.h 2013-05-31 13:45:28.000000000 +0000
12407 +++ linux-3.9.5-vs2.3.6.5/include/net/inet_timewait_sock.h 2013-05-31 17:18:34.000000000 +0000
12408 @@ -116,6 +116,10 @@ struct inet_timewait_sock {
12409 #define tw_dport __tw_common.skc_dport
12410 #define tw_num __tw_common.skc_num
12411 #define tw_portpair __tw_common.skc_portpair
12412 +#define tw_xid __tw_common.skc_xid
12413 +#define tw_vx_info __tw_common.skc_vx_info
12414 +#define tw_nid __tw_common.skc_nid
12415 +#define tw_nx_info __tw_common.skc_nx_info
12418 volatile unsigned char tw_substate;
12419 diff -NurpP --minimal linux-3.9.5/include/net/ip6_route.h linux-3.9.5-vs2.3.6.5/include/net/ip6_route.h
12420 --- linux-3.9.5/include/net/ip6_route.h 2013-05-31 13:45:28.000000000 +0000
12421 +++ linux-3.9.5-vs2.3.6.5/include/net/ip6_route.h 2013-05-31 17:17:53.000000000 +0000
12422 @@ -95,7 +95,8 @@ extern int ip6_route_get_saddr(struct
12423 struct rt6_info *rt,
12424 const struct in6_addr *daddr,
12425 unsigned int prefs,
12426 - struct in6_addr *saddr);
12427 + struct in6_addr *saddr,
12428 + struct nx_info *nxi);
12430 extern struct rt6_info *rt6_lookup(struct net *net,
12431 const struct in6_addr *daddr,
12432 diff -NurpP --minimal linux-3.9.5/include/net/route.h linux-3.9.5-vs2.3.6.5/include/net/route.h
12433 --- linux-3.9.5/include/net/route.h 2013-02-19 13:58:52.000000000 +0000
12434 +++ linux-3.9.5-vs2.3.6.5/include/net/route.h 2013-05-31 17:17:53.000000000 +0000
12435 @@ -207,6 +207,9 @@ static inline void ip_rt_put(struct rtab
12436 dst_release(&rt->dst);
12439 +#include <linux/vs_base.h>
12440 +#include <linux/vs_inet.h>
12442 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
12444 extern const __u8 ip_tos2prio[16];
12445 @@ -256,6 +259,9 @@ static inline void ip_route_connect_init
12446 protocol, flow_flags, dst, src, dport, sport);
12449 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
12450 + struct flowi4 *);
12452 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
12453 __be32 dst, __be32 src, u32 tos,
12454 int oif, u8 protocol,
12455 @@ -264,11 +270,25 @@ static inline struct rtable *ip_route_co
12457 struct net *net = sock_net(sk);
12459 + struct nx_info *nx_info = current_nx_info();
12461 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
12462 sport, dport, sk, can_sleep);
12464 - if (!dst || !src) {
12466 + nx_info = sk->sk_nx_info;
12468 + vxdprintk(VXD_CBIT(net, 4),
12469 + "ip_route_connect(%p) %p,%p;%lx",
12470 + sk, nx_info, sk->sk_socket,
12471 + (sk->sk_socket?sk->sk_socket->flags:0));
12473 + rt = ip_v4_find_src(net, nx_info, fl4);
12478 + if (!fl4->daddr || !fl4->saddr) {
12479 rt = __ip_route_output_key(net, fl4);
12482 diff -NurpP --minimal linux-3.9.5/include/net/sock.h linux-3.9.5-vs2.3.6.5/include/net/sock.h
12483 --- linux-3.9.5/include/net/sock.h 2013-06-11 12:22:40.000000000 +0000
12484 +++ linux-3.9.5-vs2.3.6.5/include/net/sock.h 2013-06-12 23:49:09.000000000 +0000
12485 @@ -191,6 +191,10 @@ struct sock_common {
12486 #ifdef CONFIG_NET_NS
12487 struct net *skc_net;
12490 + struct vx_info *skc_vx_info;
12492 + struct nx_info *skc_nx_info;
12494 * fields between dontcopy_begin/dontcopy_end
12495 * are not copied in sock_copy()
12496 @@ -304,6 +308,10 @@ struct sock {
12497 #define sk_bind_node __sk_common.skc_bind_node
12498 #define sk_prot __sk_common.skc_prot
12499 #define sk_net __sk_common.skc_net
12500 +#define sk_xid __sk_common.skc_xid
12501 +#define sk_vx_info __sk_common.skc_vx_info
12502 +#define sk_nid __sk_common.skc_nid
12503 +#define sk_nx_info __sk_common.skc_nx_info
12504 socket_lock_t sk_lock;
12505 struct sk_buff_head sk_receive_queue;
12507 diff -NurpP --minimal linux-3.9.5/include/uapi/Kbuild linux-3.9.5-vs2.3.6.5/include/uapi/Kbuild
12508 --- linux-3.9.5/include/uapi/Kbuild 2012-12-11 03:30:57.000000000 +0000
12509 +++ linux-3.9.5-vs2.3.6.5/include/uapi/Kbuild 2013-05-31 14:47:11.000000000 +0000
12510 @@ -12,3 +12,4 @@ header-y += video/
12514 +header-y += vserver/
12515 diff -NurpP --minimal linux-3.9.5/include/uapi/linux/capability.h linux-3.9.5-vs2.3.6.5/include/uapi/linux/capability.h
12516 --- linux-3.9.5/include/uapi/linux/capability.h 2012-12-11 03:30:57.000000000 +0000
12517 +++ linux-3.9.5-vs2.3.6.5/include/uapi/linux/capability.h 2013-05-31 14:47:11.000000000 +0000
12518 @@ -259,6 +259,7 @@ struct vfs_cap_data {
12519 arbitrary SCSI commands */
12520 /* Allow setting encryption key on loopback filesystem */
12521 /* Allow setting zone reclaim policy */
12522 +/* Allow the selection of a security context */
12524 #define CAP_SYS_ADMIN 21
12526 @@ -345,7 +346,12 @@ struct vfs_cap_data {
12528 #define CAP_LAST_CAP CAP_BLOCK_SUSPEND
12530 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
12531 +/* Allow context manipulations */
12532 +/* Allow changing context info on files */
12534 +#define CAP_CONTEXT 63
12536 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
12539 * Bit location of each capability (used by user-space library and kernel)
12540 diff -NurpP --minimal linux-3.9.5/include/uapi/linux/fs.h linux-3.9.5-vs2.3.6.5/include/uapi/linux/fs.h
12541 --- linux-3.9.5/include/uapi/linux/fs.h 2013-05-31 13:45:29.000000000 +0000
12542 +++ linux-3.9.5-vs2.3.6.5/include/uapi/linux/fs.h 2013-05-31 23:07:43.000000000 +0000
12543 @@ -86,6 +86,9 @@ struct inodes_stat_t {
12544 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
12545 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
12546 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
12547 +#define MS_TAGGED (1<<8) /* use generic inode tagging */
12548 +#define MS_NOTAGCHECK (1<<9) /* don't check tags */
12549 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
12551 /* These sb flags are internal to the kernel */
12552 #define MS_SNAP_STABLE (1<<27) /* Snapshot pages during writeback, if needed */
12553 @@ -192,11 +195,14 @@ struct inodes_stat_t {
12554 #define FS_EXTENT_FL 0x00080000 /* Extents */
12555 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
12556 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
12557 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
12558 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
12560 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
12561 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
12562 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
12563 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
12565 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
12566 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
12568 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
12569 #define SYNC_FILE_RANGE_WRITE 2
12570 diff -NurpP --minimal linux-3.9.5/include/uapi/linux/gfs2_ondisk.h linux-3.9.5-vs2.3.6.5/include/uapi/linux/gfs2_ondisk.h
12571 --- linux-3.9.5/include/uapi/linux/gfs2_ondisk.h 2012-12-11 03:30:57.000000000 +0000
12572 +++ linux-3.9.5-vs2.3.6.5/include/uapi/linux/gfs2_ondisk.h 2013-05-31 14:47:11.000000000 +0000
12573 @@ -225,6 +225,9 @@ enum {
12576 gfs2fl_TopLevel = 10,
12577 + gfs2fl_IXUnlink = 16,
12578 + gfs2fl_Barrier = 17,
12580 gfs2fl_TruncInProg = 29,
12581 gfs2fl_InheritDirectio = 30,
12582 gfs2fl_InheritJdata = 31,
12583 @@ -242,6 +245,9 @@ enum {
12584 #define GFS2_DIF_SYNC 0x00000100
12585 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
12586 #define GFS2_DIF_TOPDIR 0x00000400 /* New in gfs2 */
12587 +#define GFS2_DIF_IXUNLINK 0x00010000
12588 +#define GFS2_DIF_BARRIER 0x00020000
12589 +#define GFS2_DIF_COW 0x00040000
12590 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
12591 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000 /* only in gfs1 */
12592 #define GFS2_DIF_INHERIT_JDATA 0x80000000
12593 diff -NurpP --minimal linux-3.9.5/include/uapi/linux/if_tun.h linux-3.9.5-vs2.3.6.5/include/uapi/linux/if_tun.h
12594 --- linux-3.9.5/include/uapi/linux/if_tun.h 2013-02-19 13:58:55.000000000 +0000
12595 +++ linux-3.9.5-vs2.3.6.5/include/uapi/linux/if_tun.h 2013-05-31 15:00:16.000000000 +0000
12597 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
12598 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
12599 #define TUNSETQUEUE _IOW('T', 217, int)
12600 +#define TUNSETNID _IOW('T', 218, int)
12602 /* TUNSETIFF ifr flags */
12603 #define IFF_TUN 0x0001
12604 diff -NurpP --minimal linux-3.9.5/include/uapi/linux/major.h linux-3.9.5-vs2.3.6.5/include/uapi/linux/major.h
12605 --- linux-3.9.5/include/uapi/linux/major.h 2012-12-11 03:30:57.000000000 +0000
12606 +++ linux-3.9.5-vs2.3.6.5/include/uapi/linux/major.h 2013-05-31 14:47:11.000000000 +0000
12608 #define HD_MAJOR IDE0_MAJOR
12609 #define PTY_SLAVE_MAJOR 3
12610 #define TTY_MAJOR 4
12611 +#define VROOT_MAJOR 4
12612 #define TTYAUX_MAJOR 5
12614 #define VCS_MAJOR 7
12615 diff -NurpP --minimal linux-3.9.5/include/uapi/linux/nfs_mount.h linux-3.9.5-vs2.3.6.5/include/uapi/linux/nfs_mount.h
12616 --- linux-3.9.5/include/uapi/linux/nfs_mount.h 2012-12-11 03:30:57.000000000 +0000
12617 +++ linux-3.9.5-vs2.3.6.5/include/uapi/linux/nfs_mount.h 2013-05-31 14:47:11.000000000 +0000
12618 @@ -63,7 +63,8 @@ struct nfs_mount_data {
12619 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
12620 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
12621 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
12622 -#define NFS_MOUNT_FLAGMASK 0xFFFF
12623 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
12624 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
12626 /* The following are for internal use only */
12627 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
12628 diff -NurpP --minimal linux-3.9.5/include/uapi/linux/reboot.h linux-3.9.5-vs2.3.6.5/include/uapi/linux/reboot.h
12629 --- linux-3.9.5/include/uapi/linux/reboot.h 2012-12-11 03:30:57.000000000 +0000
12630 +++ linux-3.9.5-vs2.3.6.5/include/uapi/linux/reboot.h 2013-05-31 14:47:11.000000000 +0000
12632 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
12633 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
12634 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
12636 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
12639 #endif /* _UAPI_LINUX_REBOOT_H */
12640 diff -NurpP --minimal linux-3.9.5/include/uapi/linux/sysctl.h linux-3.9.5-vs2.3.6.5/include/uapi/linux/sysctl.h
12641 --- linux-3.9.5/include/uapi/linux/sysctl.h 2012-12-11 03:30:57.000000000 +0000
12642 +++ linux-3.9.5-vs2.3.6.5/include/uapi/linux/sysctl.h 2013-05-31 14:47:11.000000000 +0000
12643 @@ -60,6 +60,7 @@ enum
12644 CTL_ABI=9, /* Binary emulation */
12645 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
12646 CTL_ARLAN=254, /* arlan wireless driver */
12647 + CTL_VSERVER=4242, /* Linux-VServer debug */
12648 CTL_S390DBF=5677, /* s390 debug */
12649 CTL_SUNRPC=7249, /* sunrpc debug */
12650 CTL_PM=9899, /* frv power management */
12651 @@ -94,6 +95,7 @@ enum
12653 KERN_PANIC=15, /* int: panic timeout */
12654 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
12655 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
12657 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
12658 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
12659 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/Kbuild linux-3.9.5-vs2.3.6.5/include/uapi/vserver/Kbuild
12660 --- linux-3.9.5/include/uapi/vserver/Kbuild 1970-01-01 00:00:00.000000000 +0000
12661 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/Kbuild 2013-05-31 14:47:11.000000000 +0000
12664 +header-y += context_cmd.h network_cmd.h space_cmd.h \
12665 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
12666 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
12667 + debug_cmd.h device_cmd.h
12669 +header-y += switch.h context.h network.h monitor.h \
12670 + limit.h inode.h device.h
12672 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/cacct_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/cacct_cmd.h
12673 --- linux-3.9.5/include/uapi/vserver/cacct_cmd.h 1970-01-01 00:00:00.000000000 +0000
12674 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/cacct_cmd.h 2013-05-31 14:47:11.000000000 +0000
12676 +#ifndef _UAPI_VS_CACCT_CMD_H
12677 +#define _UAPI_VS_CACCT_CMD_H
12680 +/* virtual host info name commands */
12682 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
12684 +struct vcmd_sock_stat_v0 {
12686 + uint32_t count[3];
12687 + uint64_t total[3];
12690 +#endif /* _UAPI_VS_CACCT_CMD_H */
12691 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/context.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/context.h
12692 --- linux-3.9.5/include/uapi/vserver/context.h 1970-01-01 00:00:00.000000000 +0000
12693 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/context.h 2013-05-31 19:44:13.000000000 +0000
12695 +#ifndef _UAPI_VS_CONTEXT_H
12696 +#define _UAPI_VS_CONTEXT_H
12698 +#include <linux/types.h>
12699 +#include <linux/capability.h>
12702 +/* context flags */
12704 +#define VXF_INFO_SCHED 0x00000002
12705 +#define VXF_INFO_NPROC 0x00000004
12706 +#define VXF_INFO_PRIVATE 0x00000008
12708 +#define VXF_INFO_INIT 0x00000010
12709 +#define VXF_INFO_HIDE 0x00000020
12710 +#define VXF_INFO_ULIMIT 0x00000040
12711 +#define VXF_INFO_NSPACE 0x00000080
12713 +#define VXF_SCHED_HARD 0x00000100
12714 +#define VXF_SCHED_PRIO 0x00000200
12715 +#define VXF_SCHED_PAUSE 0x00000400
12717 +#define VXF_VIRT_MEM 0x00010000
12718 +#define VXF_VIRT_UPTIME 0x00020000
12719 +#define VXF_VIRT_CPU 0x00040000
12720 +#define VXF_VIRT_LOAD 0x00080000
12721 +#define VXF_VIRT_TIME 0x00100000
12723 +#define VXF_HIDE_MOUNT 0x01000000
12724 +/* was VXF_HIDE_NETIF 0x02000000 */
12725 +#define VXF_HIDE_VINFO 0x04000000
12727 +#define VXF_STATE_SETUP (1ULL << 32)
12728 +#define VXF_STATE_INIT (1ULL << 33)
12729 +#define VXF_STATE_ADMIN (1ULL << 34)
12731 +#define VXF_SC_HELPER (1ULL << 36)
12732 +#define VXF_REBOOT_KILL (1ULL << 37)
12733 +#define VXF_PERSISTENT (1ULL << 38)
12735 +#define VXF_FORK_RSS (1ULL << 48)
12736 +#define VXF_PROLIFIC (1ULL << 49)
12738 +#define VXF_IGNEG_NICE (1ULL << 52)
12740 +#define VXF_ONE_TIME (0x0007ULL << 32)
12742 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
12745 +/* context migration */
12747 +#define VXM_SET_INIT 0x00000001
12748 +#define VXM_SET_REAPER 0x00000002
12750 +/* context caps */
12752 +#define VXC_SET_UTSNAME 0x00000001
12753 +#define VXC_SET_RLIMIT 0x00000002
12754 +#define VXC_FS_SECURITY 0x00000004
12755 +#define VXC_FS_TRUSTED 0x00000008
12756 +#define VXC_TIOCSTI 0x00000010
12758 +/* was VXC_RAW_ICMP 0x00000100 */
12759 +#define VXC_SYSLOG 0x00001000
12760 +#define VXC_OOM_ADJUST 0x00002000
12761 +#define VXC_AUDIT_CONTROL 0x00004000
12763 +/* #define VXC_SECURE_MOUNT 0x00010000
12764 +#define VXC_SECURE_REMOUNT 0x00020000 */
12765 +#define VXC_BINARY_MOUNT 0x00040000
12766 +#define VXC_DEV_MOUNT 0x00080000
12768 +#define VXC_QUOTA_CTL 0x00100000
12769 +#define VXC_ADMIN_MAPPER 0x00200000
12770 +#define VXC_ADMIN_CLOOP 0x00400000
12772 +#define VXC_KTHREAD 0x01000000
12773 +#define VXC_NAMESPACE 0x02000000
12775 +#endif /* _UAPI_VS_CONTEXT_H */
12776 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/context_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/context_cmd.h
12777 --- linux-3.9.5/include/uapi/vserver/context_cmd.h 1970-01-01 00:00:00.000000000 +0000
12778 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/context_cmd.h 2013-05-31 14:47:11.000000000 +0000
12780 +#ifndef _UAPI_VS_CONTEXT_CMD_H
12781 +#define _UAPI_VS_CONTEXT_CMD_H
12784 +/* vinfo commands */
12786 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
12789 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
12791 +struct vcmd_vx_info_v0 {
12793 + uint32_t initpid;
12794 + /* more to come */
12798 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
12800 +struct vcmd_ctx_stat_v0 {
12803 + /* more to come */
12807 +/* context commands */
12809 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
12810 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
12812 +struct vcmd_ctx_create {
12813 + uint64_t flagword;
12816 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
12817 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
12819 +struct vcmd_ctx_migrate {
12820 + uint64_t flagword;
12825 +/* flag commands */
12827 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
12828 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
12830 +struct vcmd_ctx_flags_v0 {
12831 + uint64_t flagword;
12837 +/* context caps commands */
12839 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
12840 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
12842 +struct vcmd_ctx_caps_v1 {
12849 +/* bcaps commands */
12851 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
12852 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
12854 +struct vcmd_bcaps {
12861 +/* umask commands */
12863 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
12864 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
12866 +struct vcmd_umask {
12873 +/* wmask commands */
12875 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
12876 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
12878 +struct vcmd_wmask {
12887 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
12888 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
12890 +struct vcmd_badness_v0 {
12894 +#endif /* _UAPI_VS_CONTEXT_CMD_H */
12895 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/cvirt_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/cvirt_cmd.h
12896 --- linux-3.9.5/include/uapi/vserver/cvirt_cmd.h 1970-01-01 00:00:00.000000000 +0000
12897 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/cvirt_cmd.h 2013-05-31 14:47:11.000000000 +0000
12899 +#ifndef _UAPI_VS_CVIRT_CMD_H
12900 +#define _UAPI_VS_CVIRT_CMD_H
12903 +/* virtual host info name commands */
12905 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
12906 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
12908 +struct vcmd_vhi_name_v0 {
12914 +enum vhi_name_field {
12915 + VHIN_CONTEXT = 0,
12926 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
12928 +struct vcmd_virt_stat_v0 {
12931 + uint32_t nr_threads;
12932 + uint32_t nr_running;
12933 + uint32_t nr_uninterruptible;
12934 + uint32_t nr_onhold;
12935 + uint32_t nr_forks;
12936 + uint32_t load[3];
12939 +#endif /* _UAPI_VS_CVIRT_CMD_H */
12940 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/debug_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/debug_cmd.h
12941 --- linux-3.9.5/include/uapi/vserver/debug_cmd.h 1970-01-01 00:00:00.000000000 +0000
12942 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/debug_cmd.h 2013-05-31 14:47:11.000000000 +0000
12944 +#ifndef _UAPI_VS_DEBUG_CMD_H
12945 +#define _UAPI_VS_DEBUG_CMD_H
12948 +/* debug commands */
12950 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
12952 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
12953 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
12955 +struct vcmd_read_history_v0 {
12958 + char __user *data;
12961 +struct vcmd_read_monitor_v0 {
12964 + char __user *data;
12967 +#endif /* _UAPI_VS_DEBUG_CMD_H */
12968 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/device.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/device.h
12969 --- linux-3.9.5/include/uapi/vserver/device.h 1970-01-01 00:00:00.000000000 +0000
12970 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/device.h 2013-05-31 14:47:11.000000000 +0000
12972 +#ifndef _UAPI_VS_DEVICE_H
12973 +#define _UAPI_VS_DEVICE_H
12976 +#define DATTR_CREATE 0x00000001
12977 +#define DATTR_OPEN 0x00000002
12979 +#define DATTR_REMAP 0x00000010
12981 +#define DATTR_MASK 0x00000013
12983 +#endif /* _UAPI_VS_DEVICE_H */
12984 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/device_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/device_cmd.h
12985 --- linux-3.9.5/include/uapi/vserver/device_cmd.h 1970-01-01 00:00:00.000000000 +0000
12986 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/device_cmd.h 2013-05-31 14:47:11.000000000 +0000
12988 +#ifndef _UAPI_VS_DEVICE_CMD_H
12989 +#define _UAPI_VS_DEVICE_CMD_H
12992 +/* device vserver commands */
12994 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
12995 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
12997 +struct vcmd_set_mapping_v0 {
12998 + const char __user *device;
12999 + const char __user *target;
13003 +#endif /* _UAPI_VS_DEVICE_CMD_H */
13004 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/dlimit_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/dlimit_cmd.h
13005 --- linux-3.9.5/include/uapi/vserver/dlimit_cmd.h 1970-01-01 00:00:00.000000000 +0000
13006 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/dlimit_cmd.h 2013-05-31 14:47:11.000000000 +0000
13008 +#ifndef _UAPI_VS_DLIMIT_CMD_H
13009 +#define _UAPI_VS_DLIMIT_CMD_H
13012 +/* dlimit vserver commands */
13014 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
13015 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
13017 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
13018 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
13020 +struct vcmd_ctx_dlimit_base_v0 {
13021 + const char __user *name;
13025 +struct vcmd_ctx_dlimit_v0 {
13026 + const char __user *name;
13027 + uint32_t space_used; /* used space in kbytes */
13028 + uint32_t space_total; /* maximum space in kbytes */
13029 + uint32_t inodes_used; /* used inodes */
13030 + uint32_t inodes_total; /* maximum inodes */
13031 + uint32_t reserved; /* reserved for root in % */
13035 +#define CDLIM_UNSET ((uint32_t)0UL)
13036 +#define CDLIM_INFINITY ((uint32_t)~0UL)
13037 +#define CDLIM_KEEP ((uint32_t)~1UL)
13039 +#define DLIME_UNIT 0
13040 +#define DLIME_KILO 1
13041 +#define DLIME_MEGA 2
13042 +#define DLIME_GIGA 3
13044 +#define DLIMF_SHIFT 0x10
13046 +#define DLIMS_USED 0
13047 +#define DLIMS_TOTAL 2
13050 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
13052 + int exp = (flags & DLIMF_SHIFT) ?
13053 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
13054 + return ((uint64_t)val) << (10 * exp);
13058 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
13062 + if (*flags & DLIMF_SHIFT) {
13063 + while (val > (1LL << 32) && (exp < 3)) {
13067 + *flags &= ~(DLIME_GIGA << shift);
13068 + *flags |= exp << shift;
13074 +#endif /* _UAPI_VS_DLIMIT_CMD_H */
13075 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/inode.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/inode.h
13076 --- linux-3.9.5/include/uapi/vserver/inode.h 1970-01-01 00:00:00.000000000 +0000
13077 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/inode.h 2013-05-31 14:47:11.000000000 +0000
13079 +#ifndef _UAPI_VS_INODE_H
13080 +#define _UAPI_VS_INODE_H
13083 +#define IATTR_TAG 0x01000000
13085 +#define IATTR_ADMIN 0x00000001
13086 +#define IATTR_WATCH 0x00000002
13087 +#define IATTR_HIDE 0x00000004
13088 +#define IATTR_FLAGS 0x00000007
13090 +#define IATTR_BARRIER 0x00010000
13091 +#define IATTR_IXUNLINK 0x00020000
13092 +#define IATTR_IMMUTABLE 0x00040000
13093 +#define IATTR_COW 0x00080000
13096 +/* inode ioctls */
13098 +#define FIOC_GETXFLG _IOR('x', 5, long)
13099 +#define FIOC_SETXFLG _IOW('x', 6, long)
13101 +#endif /* _UAPI_VS_INODE_H */
13102 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/inode_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/inode_cmd.h
13103 --- linux-3.9.5/include/uapi/vserver/inode_cmd.h 1970-01-01 00:00:00.000000000 +0000
13104 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/inode_cmd.h 2013-05-31 14:47:11.000000000 +0000
13106 +#ifndef _UAPI_VS_INODE_CMD_H
13107 +#define _UAPI_VS_INODE_CMD_H
13110 +/* inode vserver commands */
13112 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
13113 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
13115 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
13116 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
13118 +struct vcmd_ctx_iattr_v1 {
13119 + const char __user *name;
13125 +struct vcmd_ctx_fiattr_v0 {
13131 +#endif /* _UAPI_VS_INODE_CMD_H */
13132 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/limit.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/limit.h
13133 --- linux-3.9.5/include/uapi/vserver/limit.h 1970-01-01 00:00:00.000000000 +0000
13134 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/limit.h 2013-05-31 14:47:11.000000000 +0000
13136 +#ifndef _UAPI_VS_LIMIT_H
13137 +#define _UAPI_VS_LIMIT_H
13140 +#define VLIMIT_NSOCK 16
13141 +#define VLIMIT_OPENFD 17
13142 +#define VLIMIT_ANON 18
13143 +#define VLIMIT_SHMEM 19
13144 +#define VLIMIT_SEMARY 20
13145 +#define VLIMIT_NSEMS 21
13146 +#define VLIMIT_DENTRY 22
13147 +#define VLIMIT_MAPPED 23
13149 +#endif /* _UAPI_VS_LIMIT_H */
13150 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/limit_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/limit_cmd.h
13151 --- linux-3.9.5/include/uapi/vserver/limit_cmd.h 1970-01-01 00:00:00.000000000 +0000
13152 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/limit_cmd.h 2013-05-31 14:47:11.000000000 +0000
13154 +#ifndef _UAPI_VS_LIMIT_CMD_H
13155 +#define _UAPI_VS_LIMIT_CMD_H
13158 +/* rlimit vserver commands */
13160 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
13161 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
13162 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
13163 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
13164 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
13166 +struct vcmd_ctx_rlimit_v0 {
13168 + uint64_t minimum;
13169 + uint64_t softlimit;
13170 + uint64_t maximum;
13173 +struct vcmd_ctx_rlimit_mask_v0 {
13174 + uint32_t minimum;
13175 + uint32_t softlimit;
13176 + uint32_t maximum;
13179 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
13181 +struct vcmd_rlimit_stat_v0 {
13185 + uint64_t minimum;
13186 + uint64_t maximum;
13189 +#define CRLIM_UNSET (0ULL)
13190 +#define CRLIM_INFINITY (~0ULL)
13191 +#define CRLIM_KEEP (~1ULL)
13193 +#endif /* _UAPI_VS_LIMIT_CMD_H */
13194 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/monitor.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/monitor.h
13195 --- linux-3.9.5/include/uapi/vserver/monitor.h 1970-01-01 00:00:00.000000000 +0000
13196 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/monitor.h 2013-05-31 14:47:11.000000000 +0000
13198 +#ifndef _UAPI_VS_MONITOR_H
13199 +#define _UAPI_VS_MONITOR_H
13201 +#include <linux/types.h>
13209 + VXM_UPDATE = 0x20,
13213 + VXM_RQINFO_1 = 0x24,
13216 + VXM_ACTIVATE = 0x40,
13223 + VXM_MIGRATE = 0x48,
13226 + /* all other bits are flags */
13227 + VXM_SCHED = 0x80,
13230 +struct _vxm_update_1 {
13231 + uint32_t tokens_max;
13232 + uint32_t fill_rate;
13233 + uint32_t interval;
13236 +struct _vxm_update_2 {
13237 + uint32_t tokens_min;
13238 + uint32_t fill_rate;
13239 + uint32_t interval;
13242 +struct _vxm_rqinfo_1 {
13243 + uint16_t running;
13247 + uint32_t idle_tokens;
13250 +struct _vxm_rqinfo_2 {
13251 + uint32_t norm_time;
13252 + uint32_t idle_time;
13253 + uint32_t idle_skip;
13256 +struct _vxm_sched {
13258 + uint32_t norm_time;
13259 + uint32_t idle_time;
13262 +struct _vxm_task {
13267 +struct _vxm_event {
13276 + struct _vxm_task tsk;
13280 +struct _vx_mon_entry {
13284 + struct _vxm_event ev;
13285 + struct _vxm_sched sd;
13286 + struct _vxm_update_1 u1;
13287 + struct _vxm_update_2 u2;
13288 + struct _vxm_rqinfo_1 q1;
13289 + struct _vxm_rqinfo_2 q2;
13293 +#endif /* _UAPI_VS_MONITOR_H */
13294 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/network.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/network.h
13295 --- linux-3.9.5/include/uapi/vserver/network.h 1970-01-01 00:00:00.000000000 +0000
13296 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/network.h 2013-05-31 14:47:11.000000000 +0000
13298 +#ifndef _UAPI_VS_NETWORK_H
13299 +#define _UAPI_VS_NETWORK_H
13301 +#include <linux/types.h>
13304 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13307 +/* network flags */
13309 +#define NXF_INFO_PRIVATE 0x00000008
13311 +#define NXF_SINGLE_IP 0x00000100
13312 +#define NXF_LBACK_REMAP 0x00000200
13313 +#define NXF_LBACK_ALLOW 0x00000400
13315 +#define NXF_HIDE_NETIF 0x02000000
13316 +#define NXF_HIDE_LBACK 0x04000000
13318 +#define NXF_STATE_SETUP (1ULL << 32)
13319 +#define NXF_STATE_ADMIN (1ULL << 34)
13321 +#define NXF_SC_HELPER (1ULL << 36)
13322 +#define NXF_PERSISTENT (1ULL << 38)
13324 +#define NXF_ONE_TIME (0x0005ULL << 32)
13327 +#define NXF_INIT_SET (__nxf_init_set())
13329 +static inline uint64_t __nxf_init_set(void) {
13330 + return NXF_STATE_ADMIN
13331 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13332 + | NXF_LBACK_REMAP
13335 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13338 + | NXF_HIDE_NETIF;
13342 +/* network caps */
13344 +#define NXC_TUN_CREATE 0x00000001
13346 +#define NXC_RAW_ICMP 0x00000100
13348 +#define NXC_MULTICAST 0x00001000
13351 +/* address types */
13353 +#define NXA_TYPE_IPV4 0x0001
13354 +#define NXA_TYPE_IPV6 0x0002
13356 +#define NXA_TYPE_NONE 0x0000
13357 +#define NXA_TYPE_ANY 0x00FF
13359 +#define NXA_TYPE_ADDR 0x0010
13360 +#define NXA_TYPE_MASK 0x0020
13361 +#define NXA_TYPE_RANGE 0x0040
13363 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13365 +#define NXA_MOD_BCAST 0x0100
13366 +#define NXA_MOD_LBACK 0x0200
13368 +#define NXA_LOOPBACK 0x1000
13370 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13371 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13373 +#endif /* _UAPI_VS_NETWORK_H */
13374 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/network_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/network_cmd.h
13375 --- linux-3.9.5/include/uapi/vserver/network_cmd.h 1970-01-01 00:00:00.000000000 +0000
13376 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/network_cmd.h 2013-05-31 14:47:11.000000000 +0000
13378 +#ifndef _UAPI_VS_NETWORK_CMD_H
13379 +#define _UAPI_VS_NETWORK_CMD_H
13382 +/* vinfo commands */
13384 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13387 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13389 +struct vcmd_nx_info_v0 {
13391 + /* more to come */
13395 +#include <linux/in.h>
13396 +#include <linux/in6.h>
13398 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13399 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13401 +struct vcmd_net_create {
13402 + uint64_t flagword;
13405 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13407 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13408 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13410 +struct vcmd_net_addr_v0 {
13413 + struct in_addr ip[4];
13414 + struct in_addr mask[4];
13417 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13418 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13420 +struct vcmd_net_addr_ipv4_v1 {
13423 + struct in_addr ip;
13424 + struct in_addr mask;
13427 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13428 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13430 +struct vcmd_net_addr_ipv4_v2 {
13433 + struct in_addr ip;
13434 + struct in_addr ip2;
13435 + struct in_addr mask;
13438 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13439 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13441 +struct vcmd_net_addr_ipv6_v1 {
13445 + struct in6_addr ip;
13446 + struct in6_addr mask;
13449 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13450 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13452 +struct vcmd_match_ipv4_v0 {
13457 + struct in_addr ip;
13458 + struct in_addr ip2;
13459 + struct in_addr mask;
13462 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13463 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13465 +struct vcmd_match_ipv6_v0 {
13470 + struct in6_addr ip;
13471 + struct in6_addr ip2;
13472 + struct in6_addr mask;
13478 +/* flag commands */
13480 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13481 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13483 +struct vcmd_net_flags_v0 {
13484 + uint64_t flagword;
13490 +/* network caps commands */
13492 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13493 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13495 +struct vcmd_net_caps_v0 {
13500 +#endif /* _UAPI_VS_NETWORK_CMD_H */
13501 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/sched_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/sched_cmd.h
13502 --- linux-3.9.5/include/uapi/vserver/sched_cmd.h 1970-01-01 00:00:00.000000000 +0000
13503 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/sched_cmd.h 2013-05-31 14:47:11.000000000 +0000
13505 +#ifndef _UAPI_VS_SCHED_CMD_H
13506 +#define _UAPI_VS_SCHED_CMD_H
13509 +struct vcmd_prio_bias {
13511 + int32_t prio_bias;
13514 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13515 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13517 +#endif /* _UAPI_VS_SCHED_CMD_H */
13518 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/signal_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/signal_cmd.h
13519 --- linux-3.9.5/include/uapi/vserver/signal_cmd.h 1970-01-01 00:00:00.000000000 +0000
13520 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/signal_cmd.h 2013-05-31 14:47:11.000000000 +0000
13522 +#ifndef _UAPI_VS_SIGNAL_CMD_H
13523 +#define _UAPI_VS_SIGNAL_CMD_H
13526 +/* signalling vserver commands */
13528 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13529 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13531 +struct vcmd_ctx_kill_v0 {
13536 +struct vcmd_wait_exit_v0 {
13537 + int32_t reboot_cmd;
13538 + int32_t exit_code;
13542 +/* process alteration commands */
13544 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13545 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13547 +struct vcmd_pflags_v0 {
13548 + uint32_t flagword;
13552 +#endif /* _UAPI_VS_SIGNAL_CMD_H */
13553 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/space_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/space_cmd.h
13554 --- linux-3.9.5/include/uapi/vserver/space_cmd.h 1970-01-01 00:00:00.000000000 +0000
13555 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/space_cmd.h 2013-05-31 14:47:11.000000000 +0000
13557 +#ifndef _UAPI_VS_SPACE_CMD_H
13558 +#define _UAPI_VS_SPACE_CMD_H
13561 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13562 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13563 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13565 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13566 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13567 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13569 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13571 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13572 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13575 +struct vcmd_space_mask_v1 {
13579 +struct vcmd_space_mask_v2 {
13584 +#endif /* _UAPI_VS_SPACE_CMD_H */
13585 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/switch.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/switch.h
13586 --- linux-3.9.5/include/uapi/vserver/switch.h 1970-01-01 00:00:00.000000000 +0000
13587 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/switch.h 2013-05-31 14:47:11.000000000 +0000
13589 +#ifndef _UAPI_VS_SWITCH_H
13590 +#define _UAPI_VS_SWITCH_H
13592 +#include <linux/types.h>
13595 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13596 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13597 +#define VC_VERSION(c) ((c) & 0xFFF)
13599 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13600 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13604 + Syscall Matrix V2.8
13606 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13607 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13608 + |INFO |SETUP | |MOVE | | | | | |
13609 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13610 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13611 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13612 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13613 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13614 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13615 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13616 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13617 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13618 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13619 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13620 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13621 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13622 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13623 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13624 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13625 + OTHER |VSTAT | | | | | | |VINFO | |
13626 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13627 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13628 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13629 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13630 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13631 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13632 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13633 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13637 +#define VC_CAT_VERSION 0
13639 +#define VC_CAT_VSETUP 1
13640 +#define VC_CAT_VHOST 2
13642 +#define VC_CAT_DEVICE 6
13644 +#define VC_CAT_VPROC 9
13645 +#define VC_CAT_PROCALT 10
13646 +#define VC_CAT_PROCMIG 11
13647 +#define VC_CAT_PROCTRL 12
13649 +#define VC_CAT_SCHED 14
13650 +#define VC_CAT_MEMCTRL 20
13652 +#define VC_CAT_VNET 25
13653 +#define VC_CAT_NETALT 26
13654 +#define VC_CAT_NETMIG 27
13655 +#define VC_CAT_NETCTRL 28
13657 +#define VC_CAT_TAGMIG 35
13658 +#define VC_CAT_DLIMIT 36
13659 +#define VC_CAT_INODE 38
13661 +#define VC_CAT_VSTAT 40
13662 +#define VC_CAT_VINFO 46
13663 +#define VC_CAT_EVENT 48
13665 +#define VC_CAT_FLAGS 52
13666 +#define VC_CAT_VSPACE 54
13667 +#define VC_CAT_DEBUG 56
13668 +#define VC_CAT_RLIMIT 60
13670 +#define VC_CAT_SYSTEST 61
13671 +#define VC_CAT_COMPAT 63
13673 +/* query version */
13675 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13676 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13678 +#endif /* _UAPI_VS_SWITCH_H */
13679 diff -NurpP --minimal linux-3.9.5/include/uapi/vserver/tag_cmd.h linux-3.9.5-vs2.3.6.5/include/uapi/vserver/tag_cmd.h
13680 --- linux-3.9.5/include/uapi/vserver/tag_cmd.h 1970-01-01 00:00:00.000000000 +0000
13681 +++ linux-3.9.5-vs2.3.6.5/include/uapi/vserver/tag_cmd.h 2013-05-31 14:47:11.000000000 +0000
13683 +#ifndef _UAPI_VS_TAG_CMD_H
13684 +#define _UAPI_VS_TAG_CMD_H
13687 +/* vinfo commands */
13689 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13692 +/* context commands */
13694 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13696 +#endif /* _UAPI_VS_TAG_CMD_H */
13697 diff -NurpP --minimal linux-3.9.5/init/Kconfig linux-3.9.5-vs2.3.6.5/init/Kconfig
13698 --- linux-3.9.5/init/Kconfig 2013-05-31 13:45:29.000000000 +0000
13699 +++ linux-3.9.5-vs2.3.6.5/init/Kconfig 2013-05-31 14:47:11.000000000 +0000
13700 @@ -760,6 +760,7 @@ config NUMA_BALANCING
13702 boolean "Control Group support"
13706 This option adds support for grouping sets of processes together, for
13707 use with process control subsystems such as Cpusets, CFS, memory
13708 @@ -1022,6 +1023,7 @@ config IPC_NS
13710 bool "User namespace"
13711 depends on UIDGID_CONVERTED
13712 + depends on VSERVER_DISABLED
13713 select UIDGID_STRICT_TYPE_CHECKS
13716 diff -NurpP --minimal linux-3.9.5/init/main.c linux-3.9.5-vs2.3.6.5/init/main.c
13717 --- linux-3.9.5/init/main.c 2013-05-31 13:45:29.000000000 +0000
13718 +++ linux-3.9.5-vs2.3.6.5/init/main.c 2013-05-31 15:09:17.000000000 +0000
13720 #include <linux/ptrace.h>
13721 #include <linux/blkdev.h>
13722 #include <linux/elevator.h>
13723 +#include <linux/vserver/percpu.h>
13725 #include <asm/io.h>
13726 #include <asm/bugs.h>
13727 diff -NurpP --minimal linux-3.9.5/ipc/mqueue.c linux-3.9.5-vs2.3.6.5/ipc/mqueue.c
13728 --- linux-3.9.5/ipc/mqueue.c 2013-05-31 13:45:29.000000000 +0000
13729 +++ linux-3.9.5-vs2.3.6.5/ipc/mqueue.c 2013-05-31 14:47:11.000000000 +0000
13731 #include <linux/ipc_namespace.h>
13732 #include <linux/user_namespace.h>
13733 #include <linux/slab.h>
13734 +#include <linux/vs_context.h>
13735 +#include <linux/vs_limit.h>
13737 #include <net/sock.h>
13739 @@ -76,6 +78,7 @@ struct mqueue_inode_info {
13740 struct pid* notify_owner;
13741 struct user_namespace *notify_user_ns;
13742 struct user_struct *user; /* user who created, for accounting */
13743 + struct vx_info *vxi;
13744 struct sock *notify_sock;
13745 struct sk_buff *notify_cookie;
13747 @@ -234,6 +237,7 @@ static struct inode *mqueue_get_inode(st
13748 if (S_ISREG(mode)) {
13749 struct mqueue_inode_info *info;
13750 unsigned long mq_bytes, mq_treesize;
13751 + struct vx_info *vxi = current_vx_info();
13753 inode->i_fop = &mqueue_file_operations;
13754 inode->i_size = FILENT_SIZE;
13755 @@ -247,6 +251,7 @@ static struct inode *mqueue_get_inode(st
13756 info->notify_user_ns = NULL;
13758 info->user = NULL; /* set when all is ok */
13759 + info->vxi = NULL;
13760 info->msg_tree = RB_ROOT;
13761 info->node_cache = NULL;
13762 memset(&info->attr, 0, sizeof(info->attr));
13763 @@ -280,17 +285,20 @@ static struct inode *mqueue_get_inode(st
13765 spin_lock(&mq_lock);
13766 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
13767 - u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
13768 + u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE) ||
13769 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
13770 spin_unlock(&mq_lock);
13771 /* mqueue_evict_inode() releases info->messages */
13775 u->mq_bytes += mq_bytes;
13776 + vx_ipcmsg_add(vxi, u, mq_bytes);
13777 spin_unlock(&mq_lock);
13780 info->user = get_uid(u);
13781 + info->vxi = get_vx_info(vxi);
13782 } else if (S_ISDIR(mode)) {
13784 /* Some things misbehave if size == 0 on a directory */
13785 @@ -402,8 +410,11 @@ static void mqueue_evict_inode(struct in
13789 + struct vx_info *vxi = info->vxi;
13791 spin_lock(&mq_lock);
13792 user->mq_bytes -= mq_bytes;
13793 + vx_ipcmsg_sub(vxi, user, mq_bytes);
13795 * get_ns_from_inode() ensures that the
13796 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
13797 @@ -413,6 +424,7 @@ static void mqueue_evict_inode(struct in
13799 ipc_ns->mq_queues_count--;
13800 spin_unlock(&mq_lock);
13801 + put_vx_info(vxi);
13805 diff -NurpP --minimal linux-3.9.5/ipc/msg.c linux-3.9.5-vs2.3.6.5/ipc/msg.c
13806 --- linux-3.9.5/ipc/msg.c 2013-05-31 13:45:29.000000000 +0000
13807 +++ linux-3.9.5-vs2.3.6.5/ipc/msg.c 2013-05-31 14:47:11.000000000 +0000
13809 #include <linux/rwsem.h>
13810 #include <linux/nsproxy.h>
13811 #include <linux/ipc_namespace.h>
13812 +#include <linux/vs_base.h>
13814 #include <asm/current.h>
13815 #include <asm/uaccess.h>
13816 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
13818 msq->q_perm.mode = msgflg & S_IRWXUGO;
13819 msq->q_perm.key = key;
13820 + msq->q_perm.xid = vx_current_xid();
13822 msq->q_perm.security = NULL;
13823 retval = security_msg_queue_alloc(msq);
13824 diff -NurpP --minimal linux-3.9.5/ipc/sem.c linux-3.9.5-vs2.3.6.5/ipc/sem.c
13825 --- linux-3.9.5/ipc/sem.c 2012-12-11 03:30:57.000000000 +0000
13826 +++ linux-3.9.5-vs2.3.6.5/ipc/sem.c 2013-05-31 14:47:11.000000000 +0000
13828 #include <linux/rwsem.h>
13829 #include <linux/nsproxy.h>
13830 #include <linux/ipc_namespace.h>
13831 +#include <linux/vs_base.h>
13832 +#include <linux/vs_limit.h>
13834 #include <asm/uaccess.h>
13836 @@ -306,6 +308,7 @@ static int newary(struct ipc_namespace *
13838 sma->sem_perm.mode = (semflg & S_IRWXUGO);
13839 sma->sem_perm.key = key;
13840 + sma->sem_perm.xid = vx_current_xid();
13842 sma->sem_perm.security = NULL;
13843 retval = security_sem_alloc(sma);
13844 @@ -321,6 +324,9 @@ static int newary(struct ipc_namespace *
13847 ns->used_sems += nsems;
13848 + /* FIXME: obsoleted? */
13849 + vx_semary_inc(sma);
13850 + vx_nsems_add(sma, nsems);
13852 sma->sem_base = (struct sem *) &sma[1];
13854 @@ -770,6 +776,9 @@ static void freeary(struct ipc_namespace
13856 wake_up_sem_queue_do(&tasks);
13857 ns->used_sems -= sma->sem_nsems;
13858 + /* FIXME: obsoleted? */
13859 + vx_nsems_sub(sma, sma->sem_nsems);
13860 + vx_semary_dec(sma);
13861 security_sem_free(sma);
13862 ipc_rcu_putref(sma);
13864 diff -NurpP --minimal linux-3.9.5/ipc/shm.c linux-3.9.5-vs2.3.6.5/ipc/shm.c
13865 --- linux-3.9.5/ipc/shm.c 2013-06-11 12:22:40.000000000 +0000
13866 +++ linux-3.9.5-vs2.3.6.5/ipc/shm.c 2013-05-31 14:47:11.000000000 +0000
13868 #include <linux/nsproxy.h>
13869 #include <linux/mount.h>
13870 #include <linux/ipc_namespace.h>
13871 +#include <linux/vs_context.h>
13872 +#include <linux/vs_limit.h>
13874 #include <asm/uaccess.h>
13876 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
13878 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
13880 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
13881 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
13882 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
13884 + vx_ipcshm_sub(vxi, shp, numpages);
13885 + ns->shm_tot -= numpages;
13889 if (!is_file_hugepages(shp->shm_file))
13890 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
13892 fput (shp->shm_file);
13893 security_shm_free(shp);
13894 + put_vx_info(vxi);
13895 ipc_rcu_putref(shp);
13898 @@ -474,11 +482,15 @@ static int newseg(struct ipc_namespace *
13899 if (ns->shm_tot + numpages > ns->shm_ctlall)
13902 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
13905 shp = ipc_rcu_alloc(sizeof(*shp));
13909 shp->shm_perm.key = key;
13910 + shp->shm_perm.xid = vx_current_xid();
13911 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
13912 shp->mlock_user = NULL;
13914 @@ -544,6 +556,7 @@ static int newseg(struct ipc_namespace *
13915 ns->shm_tot += numpages;
13916 error = shp->shm_perm.id;
13918 + vx_ipcshm_add(current_vx_info(), key, numpages);
13922 diff -NurpP --minimal linux-3.9.5/kernel/Makefile linux-3.9.5-vs2.3.6.5/kernel/Makefile
13923 --- linux-3.9.5/kernel/Makefile 2013-06-11 12:22:40.000000000 +0000
13924 +++ linux-3.9.5-vs2.3.6.5/kernel/Makefile 2013-05-31 14:47:11.000000000 +0000
13925 @@ -24,6 +24,7 @@ endif
13931 obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
13932 obj-$(CONFIG_FREEZER) += freezer.o
13933 diff -NurpP --minimal linux-3.9.5/kernel/auditsc.c linux-3.9.5-vs2.3.6.5/kernel/auditsc.c
13934 --- linux-3.9.5/kernel/auditsc.c 2013-06-11 12:22:40.000000000 +0000
13935 +++ linux-3.9.5-vs2.3.6.5/kernel/auditsc.c 2013-05-31 14:47:11.000000000 +0000
13936 @@ -2315,7 +2315,7 @@ int audit_set_loginuid(kuid_t loginuid)
13937 if (audit_loginuid_set(task))
13939 #else /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
13940 - if (!capable(CAP_AUDIT_CONTROL))
13941 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
13943 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
13945 diff -NurpP --minimal linux-3.9.5/kernel/capability.c linux-3.9.5-vs2.3.6.5/kernel/capability.c
13946 --- linux-3.9.5/kernel/capability.c 2013-05-31 13:45:29.000000000 +0000
13947 +++ linux-3.9.5-vs2.3.6.5/kernel/capability.c 2013-05-31 14:47:11.000000000 +0000
13949 #include <linux/syscalls.h>
13950 #include <linux/pid_namespace.h>
13951 #include <linux/user_namespace.h>
13952 +#include <linux/vs_context.h>
13953 #include <asm/uaccess.h>
13956 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
13962 * The only thing that can change the capabilities of the current
13963 * process is the current process. As such, we can't be in this code
13964 @@ -349,6 +351,8 @@ bool has_ns_capability_noaudit(struct ta
13968 +#include <linux/vserver/base.h>
13971 * has_capability_noaudit - Does a task have a capability (unaudited) in the
13973 diff -NurpP --minimal linux-3.9.5/kernel/compat.c linux-3.9.5-vs2.3.6.5/kernel/compat.c
13974 --- linux-3.9.5/kernel/compat.c 2013-05-31 13:45:29.000000000 +0000
13975 +++ linux-3.9.5-vs2.3.6.5/kernel/compat.c 2013-05-31 14:47:11.000000000 +0000
13977 #include <linux/times.h>
13978 #include <linux/ptrace.h>
13979 #include <linux/gfp.h>
13980 +#include <linux/vs_time.h>
13982 #include <asm/uaccess.h>
13984 @@ -1059,7 +1060,7 @@ asmlinkage long compat_sys_stime(compat_
13988 - do_settimeofday(&tv);
13989 + vx_settimeofday(&tv);
13993 diff -NurpP --minimal linux-3.9.5/kernel/cred.c linux-3.9.5-vs2.3.6.5/kernel/cred.c
13994 --- linux-3.9.5/kernel/cred.c 2013-02-19 13:58:56.000000000 +0000
13995 +++ linux-3.9.5-vs2.3.6.5/kernel/cred.c 2013-05-31 14:47:11.000000000 +0000
13996 @@ -56,31 +56,6 @@ struct cred init_cred = {
13997 .group_info = &init_groups,
14000 -static inline void set_cred_subscribers(struct cred *cred, int n)
14002 -#ifdef CONFIG_DEBUG_CREDENTIALS
14003 - atomic_set(&cred->subscribers, n);
14007 -static inline int read_cred_subscribers(const struct cred *cred)
14009 -#ifdef CONFIG_DEBUG_CREDENTIALS
14010 - return atomic_read(&cred->subscribers);
14016 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14018 -#ifdef CONFIG_DEBUG_CREDENTIALS
14019 - struct cred *cred = (struct cred *) _cred;
14021 - atomic_add(n, &cred->subscribers);
14026 * The RCU callback to actually dispose of a set of credentials
14028 @@ -232,21 +207,16 @@ error:
14030 * Call commit_creds() or abort_creds() to clean up.
14032 -struct cred *prepare_creds(void)
14033 +struct cred *__prepare_creds(const struct cred *old)
14035 - struct task_struct *task = current;
14036 - const struct cred *old;
14039 - validate_process_creds();
14041 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14045 kdebug("prepare_creds() alloc %p", new);
14047 - old = task->cred;
14048 memcpy(new, old, sizeof(struct cred));
14050 atomic_set(&new->usage, 1);
14051 @@ -275,6 +245,13 @@ error:
14056 +struct cred *prepare_creds(void)
14058 + validate_process_creds();
14060 + return __prepare_creds(current->cred);
14062 EXPORT_SYMBOL(prepare_creds);
14065 diff -NurpP --minimal linux-3.9.5/kernel/exit.c linux-3.9.5-vs2.3.6.5/kernel/exit.c
14066 --- linux-3.9.5/kernel/exit.c 2013-05-31 13:45:29.000000000 +0000
14067 +++ linux-3.9.5-vs2.3.6.5/kernel/exit.c 2013-05-31 14:47:11.000000000 +0000
14069 #include <linux/fs_struct.h>
14070 #include <linux/init_task.h>
14071 #include <linux/perf_event.h>
14072 +#include <linux/vs_limit.h>
14073 +#include <linux/vs_context.h>
14074 +#include <linux/vs_network.h>
14075 +#include <linux/vs_pid.h>
14076 #include <trace/events/sched.h>
14077 #include <linux/hw_breakpoint.h>
14078 #include <linux/oom.h>
14079 @@ -514,15 +518,25 @@ static struct task_struct *find_new_reap
14080 __acquires(&tasklist_lock)
14082 struct pid_namespace *pid_ns = task_active_pid_ns(father);
14083 - struct task_struct *thread;
14084 + struct vx_info *vxi = task_get_vx_info(father);
14085 + struct task_struct *thread = father;
14086 + struct task_struct *reaper;
14089 while_each_thread(father, thread) {
14090 if (thread->flags & PF_EXITING)
14092 if (unlikely(pid_ns->child_reaper == father))
14093 pid_ns->child_reaper = thread;
14099 + reaper = pid_ns->child_reaper;
14101 + BUG_ON(!vxi->vx_reaper);
14102 + if (vxi->vx_reaper != init_pid_ns.child_reaper &&
14103 + vxi->vx_reaper != father)
14104 + reaper = vxi->vx_reaper;
14107 if (unlikely(pid_ns->child_reaper == father)) {
14108 @@ -560,7 +574,9 @@ static struct task_struct *find_new_reap
14112 - return pid_ns->child_reaper;
14114 + put_vx_info(vxi);
14119 @@ -611,10 +627,15 @@ static void forget_original_parent(struc
14120 list_for_each_entry_safe(p, n, &father->children, sibling) {
14121 struct task_struct *t = p;
14123 - t->real_parent = reaper;
14124 + struct task_struct *new_parent = reaper;
14126 + if (unlikely(p == reaper))
14127 + new_parent = task_active_pid_ns(p)->child_reaper;
14129 + t->real_parent = new_parent;
14130 if (t->parent == father) {
14132 - t->parent = t->real_parent;
14133 + t->parent = new_parent;
14135 if (t->pdeath_signal)
14136 group_send_sig_info(t->pdeath_signal,
14137 @@ -821,6 +842,9 @@ void do_exit(long code)
14139 ptrace_put_breakpoints(tsk);
14141 + /* needs to stay before exit_notify() */
14142 + exit_vx_info_early(tsk, code);
14144 exit_notify(tsk, group_dead);
14147 @@ -874,10 +898,15 @@ void do_exit(long code)
14149 raw_spin_unlock_wait(&tsk->pi_lock);
14151 + /* needs to stay after exit_notify() */
14152 + exit_vx_info(tsk, code);
14153 + exit_nx_info(tsk);
14155 /* causes final put_task_struct in finish_task_switch(). */
14156 tsk->state = TASK_DEAD;
14157 tsk->flags |= PF_NOFREEZE; /* tell freezer to ignore us */
14159 + printk("bad task: %p [%lx]\n", current, current->state);
14161 /* Avoid "noreturn function does return". */
14163 diff -NurpP --minimal linux-3.9.5/kernel/fork.c linux-3.9.5-vs2.3.6.5/kernel/fork.c
14164 --- linux-3.9.5/kernel/fork.c 2013-05-31 13:45:29.000000000 +0000
14165 +++ linux-3.9.5-vs2.3.6.5/kernel/fork.c 2013-05-31 14:47:11.000000000 +0000
14167 #include <linux/khugepaged.h>
14168 #include <linux/signalfd.h>
14169 #include <linux/uprobes.h>
14170 +#include <linux/vs_context.h>
14171 +#include <linux/vs_network.h>
14172 +#include <linux/vs_limit.h>
14174 #include <asm/pgtable.h>
14175 #include <asm/pgalloc.h>
14176 @@ -210,6 +213,8 @@ void free_task(struct task_struct *tsk)
14177 arch_release_thread_info(tsk->stack);
14178 free_thread_info(tsk->stack);
14179 rt_mutex_debug_task_free(tsk);
14180 + clr_vx_info(&tsk->vx_info);
14181 + clr_nx_info(&tsk->nx_info);
14182 ftrace_graph_exit_task(tsk);
14183 put_seccomp_filter(tsk);
14184 arch_release_task_struct(tsk);
14185 @@ -547,6 +552,7 @@ static struct mm_struct *mm_init(struct
14186 if (likely(!mm_alloc_pgd(mm))) {
14188 mmu_notifier_mm_init(mm);
14189 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14193 @@ -599,6 +605,7 @@ void __mmdrop(struct mm_struct *mm)
14194 destroy_context(mm);
14195 mmu_notifier_mm_destroy(mm);
14197 + clr_vx_info(&mm->mm_vx_info);
14200 EXPORT_SYMBOL_GPL(__mmdrop);
14201 @@ -818,6 +825,7 @@ struct mm_struct *dup_mm(struct task_str
14204 memcpy(mm, oldmm, sizeof(*mm));
14205 + mm->mm_vx_info = NULL;
14206 mm_init_cpumask(mm);
14208 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14209 @@ -859,6 +867,7 @@ fail_nocontext:
14210 * If init_new_context() failed, we cannot use mmput() to free the mm
14211 * because it calls destroy_context()
14213 + clr_vx_info(&mm->mm_vx_info);
14217 @@ -1137,6 +1146,8 @@ static struct task_struct *copy_process(
14220 struct task_struct *p;
14221 + struct vx_info *vxi;
14222 + struct nx_info *nxi;
14224 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14225 return ERR_PTR(-EINVAL);
14226 @@ -1195,7 +1206,12 @@ static struct task_struct *copy_process(
14227 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14228 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14230 + init_vx_info(&p->vx_info, current_vx_info());
14231 + init_nx_info(&p->nx_info, current_nx_info());
14234 + if (!vx_nproc_avail(1))
14235 + goto bad_fork_free;
14236 if (atomic_read(&p->real_cred->user->processes) >=
14237 task_rlimit(p, RLIMIT_NPROC)) {
14238 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14239 @@ -1472,6 +1488,18 @@ static struct task_struct *copy_process(
14242 spin_unlock(¤t->sighand->siglock);
14244 + /* p is copy of current */
14245 + vxi = p->vx_info;
14247 + claim_vx_info(vxi, p);
14248 + atomic_inc(&vxi->cvirt.nr_threads);
14249 + atomic_inc(&vxi->cvirt.total_forks);
14252 + nxi = p->nx_info;
14254 + claim_nx_info(nxi, p);
14255 write_unlock_irq(&tasklist_lock);
14256 proc_fork_connector(p);
14257 cgroup_post_fork(p);
14258 diff -NurpP --minimal linux-3.9.5/kernel/kthread.c linux-3.9.5-vs2.3.6.5/kernel/kthread.c
14259 --- linux-3.9.5/kernel/kthread.c 2013-05-31 13:45:30.000000000 +0000
14260 +++ linux-3.9.5-vs2.3.6.5/kernel/kthread.c 2013-05-31 14:47:11.000000000 +0000
14262 #include <linux/slab.h>
14263 #include <linux/freezer.h>
14264 #include <linux/ptrace.h>
14265 +#include <linux/vs_pid.h>
14266 #include <trace/events/sched.h>
14268 static DEFINE_SPINLOCK(kthread_create_lock);
14269 diff -NurpP --minimal linux-3.9.5/kernel/nsproxy.c linux-3.9.5-vs2.3.6.5/kernel/nsproxy.c
14270 --- linux-3.9.5/kernel/nsproxy.c 2013-05-31 13:45:30.000000000 +0000
14271 +++ linux-3.9.5-vs2.3.6.5/kernel/nsproxy.c 2013-05-31 19:28:43.000000000 +0000
14272 @@ -20,11 +20,14 @@
14273 #include <linux/mnt_namespace.h>
14274 #include <linux/utsname.h>
14275 #include <linux/pid_namespace.h>
14276 +#include <linux/vserver/global.h>
14277 +#include <linux/vserver/debug.h>
14278 #include <net/net_namespace.h>
14279 #include <linux/ipc_namespace.h>
14280 #include <linux/proc_fs.h>
14281 #include <linux/file.h>
14282 #include <linux/syscalls.h>
14283 +#include "../fs/mount.h"
14285 static struct kmem_cache *nsproxy_cachep;
14287 @@ -46,8 +49,11 @@ static inline struct nsproxy *create_nsp
14288 struct nsproxy *nsproxy;
14290 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14293 atomic_set(&nsproxy->count, 1);
14294 + atomic_inc(&vs_global_nsproxy);
14296 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14300 @@ -56,9 +62,12 @@ static inline struct nsproxy *create_nsp
14301 * Return the newly created nsproxy. Do not attach this to the task,
14302 * leave it to the caller to do proper locking and attach it to task.
14304 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14305 - struct task_struct *tsk, struct user_namespace *user_ns,
14306 - struct fs_struct *new_fs)
14307 +static struct nsproxy *unshare_namespaces(
14308 + unsigned long flags,
14309 + struct nsproxy *orig,
14310 + struct fs_struct *new_fs,
14311 + struct user_namespace *new_user,
14312 + struct pid_namespace *new_pid)
14314 struct nsproxy *new_nsp;
14316 @@ -67,31 +76,31 @@ static struct nsproxy *create_new_namesp
14318 return ERR_PTR(-ENOMEM);
14320 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, user_ns, new_fs);
14321 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_user, new_fs);
14322 if (IS_ERR(new_nsp->mnt_ns)) {
14323 err = PTR_ERR(new_nsp->mnt_ns);
14327 - new_nsp->uts_ns = copy_utsname(flags, user_ns, tsk->nsproxy->uts_ns);
14328 + new_nsp->uts_ns = copy_utsname(flags, new_user, orig->uts_ns);
14329 if (IS_ERR(new_nsp->uts_ns)) {
14330 err = PTR_ERR(new_nsp->uts_ns);
14334 - new_nsp->ipc_ns = copy_ipcs(flags, user_ns, tsk->nsproxy->ipc_ns);
14335 + new_nsp->ipc_ns = copy_ipcs(flags, new_user, orig->ipc_ns);
14336 if (IS_ERR(new_nsp->ipc_ns)) {
14337 err = PTR_ERR(new_nsp->ipc_ns);
14341 - new_nsp->pid_ns = copy_pid_ns(flags, user_ns, tsk->nsproxy->pid_ns);
14342 + new_nsp->pid_ns = copy_pid_ns(flags, new_user, new_pid);
14343 if (IS_ERR(new_nsp->pid_ns)) {
14344 err = PTR_ERR(new_nsp->pid_ns);
14348 - new_nsp->net_ns = copy_net_ns(flags, user_ns, tsk->nsproxy->net_ns);
14349 + new_nsp->net_ns = copy_net_ns(flags, new_user, orig->net_ns);
14350 if (IS_ERR(new_nsp->net_ns)) {
14351 err = PTR_ERR(new_nsp->net_ns);
14353 @@ -116,6 +125,41 @@ out_ns:
14354 return ERR_PTR(err);
14357 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14358 + struct task_struct *tsk, struct user_namespace *user_ns,
14359 + struct fs_struct *new_fs)
14362 + return unshare_namespaces(flags, tsk->nsproxy,
14363 + new_fs, user_ns, task_active_pid_ns(tsk));
14367 + * copies the nsproxy, setting refcount to 1, and grabbing a
14368 + * reference to all contained namespaces.
14370 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14372 + struct nsproxy *ns = create_nsproxy();
14375 + memcpy(ns, orig, sizeof(struct nsproxy));
14376 + atomic_set(&ns->count, 1);
14379 + get_mnt_ns(ns->mnt_ns);
14381 + get_uts_ns(ns->uts_ns);
14383 + get_ipc_ns(ns->ipc_ns);
14385 + get_pid_ns(ns->pid_ns);
14387 + get_net(ns->net_ns);
14393 * called from clone. This now handles copy for nsproxy and all
14394 * namespaces therein.
14395 @@ -124,9 +168,12 @@ int copy_namespaces(unsigned long flags,
14397 struct nsproxy *old_ns = tsk->nsproxy;
14398 struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
14399 - struct nsproxy *new_ns;
14400 + struct nsproxy *new_ns = NULL;
14403 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14404 + flags, tsk, old_ns);
14409 @@ -136,7 +183,7 @@ int copy_namespaces(unsigned long flags,
14410 CLONE_NEWPID | CLONE_NEWNET)))
14413 - if (!ns_capable(user_ns, CAP_SYS_ADMIN)) {
14414 + if (!vx_ns_can_unshare(user_ns, CAP_SYS_ADMIN, flags)) {
14418 @@ -163,6 +210,9 @@ int copy_namespaces(unsigned long flags,
14421 put_nsproxy(old_ns);
14422 + vxdprintk(VXD_CBIT(space, 3),
14423 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14424 + flags, tsk, old_ns, err, new_ns);
14428 @@ -176,7 +226,9 @@ void free_nsproxy(struct nsproxy *ns)
14429 put_ipc_ns(ns->ipc_ns);
14431 put_pid_ns(ns->pid_ns);
14432 - put_net(ns->net_ns);
14434 + put_net(ns->net_ns);
14435 + atomic_dec(&vs_global_nsproxy);
14436 kmem_cache_free(nsproxy_cachep, ns);
14439 @@ -190,12 +242,16 @@ int unshare_nsproxy_namespaces(unsigned
14440 struct user_namespace *user_ns;
14443 + vxdprintk(VXD_CBIT(space, 4),
14444 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14445 + unshare_flags, current->nsproxy);
14447 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14448 CLONE_NEWNET | CLONE_NEWPID)))
14451 user_ns = new_cred ? new_cred->user_ns : current_user_ns();
14452 - if (!ns_capable(user_ns, CAP_SYS_ADMIN))
14453 + if (!vx_ns_can_unshare(user_ns, CAP_SYS_ADMIN, unshare_flags))
14456 *new_nsp = create_new_namespaces(unshare_flags, current, user_ns,
14457 diff -NurpP --minimal linux-3.9.5/kernel/pid.c linux-3.9.5-vs2.3.6.5/kernel/pid.c
14458 --- linux-3.9.5/kernel/pid.c 2013-05-31 13:45:30.000000000 +0000
14459 +++ linux-3.9.5-vs2.3.6.5/kernel/pid.c 2013-05-31 15:24:34.000000000 +0000
14461 #include <linux/init_task.h>
14462 #include <linux/syscalls.h>
14463 #include <linux/proc_fs.h>
14464 +#include <linux/vs_pid.h>
14466 #define pid_hashfn(nr, ns) \
14467 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14468 @@ -364,7 +365,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14470 struct pid *find_vpid(int nr)
14472 - return find_pid_ns(nr, task_active_pid_ns(current));
14473 + return find_pid_ns(vx_rmap_pid(nr), task_active_pid_ns(current));
14475 EXPORT_SYMBOL_GPL(find_vpid);
14477 @@ -424,6 +425,9 @@ void transfer_pid(struct task_struct *ol
14478 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14480 struct task_struct *result = NULL;
14482 + if (type == PIDTYPE_REALPID)
14483 + type = PIDTYPE_PID;
14485 struct hlist_node *first;
14486 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
14487 @@ -443,7 +447,7 @@ struct task_struct *find_task_by_pid_ns(
14488 rcu_lockdep_assert(rcu_read_lock_held(),
14489 "find_task_by_pid_ns() needs rcu_read_lock()"
14491 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
14492 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
14495 struct task_struct *find_task_by_vpid(pid_t vnr)
14496 @@ -487,7 +491,7 @@ struct pid *find_get_pid(pid_t nr)
14498 EXPORT_SYMBOL_GPL(find_get_pid);
14500 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14501 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
14505 @@ -501,6 +505,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
14507 EXPORT_SYMBOL_GPL(pid_nr_ns);
14509 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14511 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
14514 pid_t pid_vnr(struct pid *pid)
14516 return pid_nr_ns(pid, task_active_pid_ns(current));
14517 diff -NurpP --minimal linux-3.9.5/kernel/pid_namespace.c linux-3.9.5-vs2.3.6.5/kernel/pid_namespace.c
14518 --- linux-3.9.5/kernel/pid_namespace.c 2013-05-31 13:45:30.000000000 +0000
14519 +++ linux-3.9.5-vs2.3.6.5/kernel/pid_namespace.c 2013-05-31 17:59:48.000000000 +0000
14521 #include <linux/proc_fs.h>
14522 #include <linux/reboot.h>
14523 #include <linux/export.h>
14524 +#include <linux/vserver/global.h>
14526 #define BITS_PER_PAGE (PAGE_SIZE*8)
14528 @@ -112,6 +113,7 @@ static struct pid_namespace *create_pid_
14531 kref_init(&ns->kref);
14532 + atomic_inc(&vs_global_pid_ns);
14534 ns->parent = get_pid_ns(parent_pid_ns);
14535 ns->user_ns = get_user_ns(user_ns);
14536 @@ -142,6 +144,7 @@ static void destroy_pid_namespace(struct
14537 for (i = 0; i < PIDMAP_ENTRIES; i++)
14538 kfree(ns->pidmap[i].page);
14539 put_user_ns(ns->user_ns);
14540 + atomic_dec(&vs_global_pid_ns);
14541 kmem_cache_free(pid_ns_cachep, ns);
14544 diff -NurpP --minimal linux-3.9.5/kernel/posix-timers.c linux-3.9.5-vs2.3.6.5/kernel/posix-timers.c
14545 --- linux-3.9.5/kernel/posix-timers.c 2013-05-31 13:45:30.000000000 +0000
14546 +++ linux-3.9.5-vs2.3.6.5/kernel/posix-timers.c 2013-05-31 14:47:11.000000000 +0000
14548 #include <linux/wait.h>
14549 #include <linux/workqueue.h>
14550 #include <linux/export.h>
14551 +#include <linux/vs_context.h>
14554 * Management arrays for POSIX timers. Timers are kept in slab memory
14555 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
14557 struct task_struct *task;
14558 int shared, ret = -1;
14561 * FIXME: if ->sigq is queued we can race with
14562 * dequeue_signal()->do_schedule_next_timer().
14563 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
14565 task = pid_task(timr->it_pid, PIDTYPE_PID);
14567 + struct vx_info_save vxis;
14568 + struct vx_info *vxi;
14570 + vxi = get_vx_info(task->vx_info);
14571 + enter_vx_info(vxi, &vxis);
14572 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
14573 ret = send_sigqueue(timr->sigq, task, shared);
14574 + leave_vx_info(&vxis);
14575 + put_vx_info(vxi);
14579 /* If we failed to send the signal the timer stops. */
14582 diff -NurpP --minimal linux-3.9.5/kernel/printk.c linux-3.9.5-vs2.3.6.5/kernel/printk.c
14583 --- linux-3.9.5/kernel/printk.c 2013-05-31 13:45:30.000000000 +0000
14584 +++ linux-3.9.5-vs2.3.6.5/kernel/printk.c 2013-05-31 15:23:35.000000000 +0000
14586 #include <linux/rculist.h>
14587 #include <linux/poll.h>
14588 #include <linux/irq_work.h>
14589 +#include <linux/vs_cvirt.h>
14591 #include <asm/uaccess.h>
14593 @@ -841,7 +842,7 @@ static int check_syslog_permissions(int
14596 if (syslog_action_restricted(type)) {
14597 - if (capable(CAP_SYSLOG))
14598 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
14600 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
14601 if (capable(CAP_SYS_ADMIN)) {
14602 @@ -1135,12 +1136,9 @@ int do_syslog(int type, char __user *buf
14607 - case SYSLOG_ACTION_CLOSE: /* Close log */
14609 - case SYSLOG_ACTION_OPEN: /* Open log */
14611 - case SYSLOG_ACTION_READ: /* Read from log */
14612 + if ((type == SYSLOG_ACTION_READ) ||
14613 + (type == SYSLOG_ACTION_READ_ALL) ||
14614 + (type == SYSLOG_ACTION_READ_CLEAR)) {
14616 if (!buf || len < 0)
14618 @@ -1151,6 +1149,16 @@ int do_syslog(int type, char __user *buf
14623 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14624 + return vx_do_syslog(type, buf, len);
14627 + case SYSLOG_ACTION_CLOSE: /* Close log */
14629 + case SYSLOG_ACTION_OPEN: /* Open log */
14631 + case SYSLOG_ACTION_READ: /* Read from log */
14632 error = wait_event_interruptible(log_wait,
14633 syslog_seq != log_next_seq);
14635 @@ -1163,16 +1171,6 @@ int do_syslog(int type, char __user *buf
14637 /* Read last kernel messages */
14638 case SYSLOG_ACTION_READ_ALL:
14640 - if (!buf || len < 0)
14645 - if (!access_ok(VERIFY_WRITE, buf, len)) {
14649 error = syslog_print_all(buf, len, clear);
14651 /* Clear ring buffer */
14652 diff -NurpP --minimal linux-3.9.5/kernel/ptrace.c linux-3.9.5-vs2.3.6.5/kernel/ptrace.c
14653 --- linux-3.9.5/kernel/ptrace.c 2013-05-31 13:45:30.000000000 +0000
14654 +++ linux-3.9.5-vs2.3.6.5/kernel/ptrace.c 2013-05-31 15:22:34.000000000 +0000
14656 #include <linux/syscalls.h>
14657 #include <linux/uaccess.h>
14658 #include <linux/regset.h>
14659 +#include <linux/vs_context.h>
14660 #include <linux/hw_breakpoint.h>
14661 #include <linux/cn_proc.h>
14663 @@ -261,6 +262,11 @@ ok:
14667 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
14669 + if (!vx_check(task->xid, VS_IDENT) &&
14670 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
14672 return security_ptrace_access_check(task, mode);
14675 diff -NurpP --minimal linux-3.9.5/kernel/sched/core.c linux-3.9.5-vs2.3.6.5/kernel/sched/core.c
14676 --- linux-3.9.5/kernel/sched/core.c 2013-05-31 13:45:30.000000000 +0000
14677 +++ linux-3.9.5-vs2.3.6.5/kernel/sched/core.c 2013-05-31 15:17:22.000000000 +0000
14679 #include <linux/init_task.h>
14680 #include <linux/binfmts.h>
14681 #include <linux/context_tracking.h>
14682 +#include <linux/vs_sched.h>
14683 +#include <linux/vs_cvirt.h>
14685 #include <asm/switch_to.h>
14686 #include <asm/tlb.h>
14687 @@ -2091,9 +2093,17 @@ EXPORT_SYMBOL(avenrun); /* should be rem
14689 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
14691 - loads[0] = (avenrun[0] + offset) << shift;
14692 - loads[1] = (avenrun[1] + offset) << shift;
14693 - loads[2] = (avenrun[2] + offset) << shift;
14694 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
14695 + struct vx_info *vxi = current_vx_info();
14697 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
14698 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
14699 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
14701 + loads[0] = (avenrun[0] + offset) << shift;
14702 + loads[1] = (avenrun[1] + offset) << shift;
14703 + loads[2] = (avenrun[2] + offset) << shift;
14707 static long calc_load_fold_active(struct rq *this_rq)
14708 @@ -3704,7 +3714,7 @@ SYSCALL_DEFINE1(nice, int, increment)
14711 if (increment < 0 && !can_nice(current, nice))
14713 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
14715 retval = security_task_setnice(current, nice);
14717 diff -NurpP --minimal linux-3.9.5/kernel/sched/cputime.c linux-3.9.5-vs2.3.6.5/kernel/sched/cputime.c
14718 --- linux-3.9.5/kernel/sched/cputime.c 2013-06-11 12:22:40.000000000 +0000
14719 +++ linux-3.9.5-vs2.3.6.5/kernel/sched/cputime.c 2013-05-31 15:17:55.000000000 +0000
14721 #include <linux/kernel_stat.h>
14722 #include <linux/static_key.h>
14723 #include <linux/context_tracking.h>
14724 +#include <linux/vs_sched.h>
14728 @@ -151,14 +152,17 @@ static inline void task_group_account_fi
14729 void account_user_time(struct task_struct *p, cputime_t cputime,
14730 cputime_t cputime_scaled)
14732 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14733 + int nice = (TASK_NICE(p) > 0);
14736 /* Add user time to process. */
14737 p->utime += cputime;
14738 p->utimescaled += cputime_scaled;
14739 + vx_account_user(vxi, cputime, nice);
14740 account_group_user_time(p, cputime);
14742 - index = (TASK_NICE(p) > 0) ? CPUTIME_NICE : CPUTIME_USER;
14743 + index = (nice) ? CPUTIME_NICE : CPUTIME_USER;
14745 /* Add user time to cpustat. */
14746 task_group_account_field(p, index, (__force u64) cputime);
14747 @@ -205,9 +209,12 @@ static inline
14748 void __account_system_time(struct task_struct *p, cputime_t cputime,
14749 cputime_t cputime_scaled, int index)
14751 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14753 /* Add system time to process. */
14754 p->stime += cputime;
14755 p->stimescaled += cputime_scaled;
14756 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
14757 account_group_system_time(p, cputime);
14759 /* Add system time to cpustat. */
14760 diff -NurpP --minimal linux-3.9.5/kernel/sched/fair.c linux-3.9.5-vs2.3.6.5/kernel/sched/fair.c
14761 --- linux-3.9.5/kernel/sched/fair.c 2013-05-31 13:45:30.000000000 +0000
14762 +++ linux-3.9.5-vs2.3.6.5/kernel/sched/fair.c 2013-05-31 15:19:37.000000000 +0000
14764 #include <linux/mempolicy.h>
14765 #include <linux/migrate.h>
14766 #include <linux/task_work.h>
14767 +#include <linux/vs_cvirt.h>
14769 #include <trace/events/sched.h>
14771 @@ -1714,6 +1715,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
14772 __enqueue_entity(cfs_rq, se);
14775 + if (entity_is_task(se))
14776 + vx_activate_task(task_of(se));
14777 if (cfs_rq->nr_running == 1) {
14778 list_add_leaf_cfs_rq(cfs_rq);
14779 check_enqueue_throttle(cfs_rq);
14780 @@ -1795,6 +1798,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
14781 if (se != cfs_rq->curr)
14782 __dequeue_entity(cfs_rq, se);
14784 + if (entity_is_task(se))
14785 + vx_deactivate_task(task_of(se));
14786 account_entity_dequeue(cfs_rq, se);
14789 diff -NurpP --minimal linux-3.9.5/kernel/signal.c linux-3.9.5-vs2.3.6.5/kernel/signal.c
14790 --- linux-3.9.5/kernel/signal.c 2013-05-31 13:45:30.000000000 +0000
14791 +++ linux-3.9.5-vs2.3.6.5/kernel/signal.c 2013-05-31 15:20:05.000000000 +0000
14793 #include <linux/user_namespace.h>
14794 #include <linux/uprobes.h>
14795 #include <linux/compat.h>
14796 +#include <linux/vs_context.h>
14797 +#include <linux/vs_pid.h>
14798 #define CREATE_TRACE_POINTS
14799 #include <trace/events/signal.h>
14801 @@ -789,9 +791,18 @@ static int check_kill_permission(int sig
14805 + vxdprintk(VXD_CBIT(misc, 7),
14806 + "check_kill_permission(%d,%p,%p[#%u,%u])",
14807 + sig, info, t, vx_task_xid(t), t->pid);
14809 if (!valid_signal(sig))
14812 +/* FIXME: needed? if so, why?
14813 + if ((info != SEND_SIG_NOINFO) &&
14814 + (is_si_special(info) || !si_fromuser(info)))
14817 if (!si_fromuser(info))
14820 @@ -815,6 +826,20 @@ static int check_kill_permission(int sig
14825 + if (t->pid == 1 && current->xid)
14829 + /* FIXME: we shouldn't return ESRCH ever, to avoid
14830 + loops, maybe ENOENT or EACCES? */
14831 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
14832 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
14833 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
14834 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
14838 return security_task_kill(t, info, sig, 0);
14841 @@ -1351,7 +1376,7 @@ int kill_pid_info(int sig, struct siginf
14844 p = pid_task(pid, PIDTYPE_PID);
14846 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
14847 error = group_send_sig_info(sig, info, p);
14848 if (unlikely(error == -ESRCH))
14850 @@ -1399,7 +1424,7 @@ int kill_pid_info_as_cred(int sig, struc
14853 p = pid_task(pid, PIDTYPE_PID);
14855 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
14859 @@ -1451,8 +1476,10 @@ static int kill_something_info(int sig,
14860 struct task_struct * p;
14862 for_each_process(p) {
14863 - if (task_pid_vnr(p) > 1 &&
14864 - !same_thread_group(p, current)) {
14865 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
14866 + task_pid_vnr(p) > 1 &&
14867 + !same_thread_group(p, current) &&
14868 + !vx_current_initpid(p->pid)) {
14869 int err = group_send_sig_info(sig, info, p);
14872 @@ -2306,6 +2333,11 @@ relock:
14873 !sig_kernel_only(signr))
14876 + /* virtual init is protected against user signals */
14877 + if ((info->si_code == SI_USER) &&
14878 + vx_current_initpid(current->pid))
14881 if (sig_kernel_stop(signr)) {
14883 * The default action is to stop all threads in
14884 diff -NurpP --minimal linux-3.9.5/kernel/softirq.c linux-3.9.5-vs2.3.6.5/kernel/softirq.c
14885 --- linux-3.9.5/kernel/softirq.c 2013-05-31 13:45:30.000000000 +0000
14886 +++ linux-3.9.5-vs2.3.6.5/kernel/softirq.c 2013-05-31 14:47:11.000000000 +0000
14888 #include <linux/smp.h>
14889 #include <linux/smpboot.h>
14890 #include <linux/tick.h>
14891 +#include <linux/vs_context.h>
14893 #define CREATE_TRACE_POINTS
14894 #include <trace/events/irq.h>
14895 diff -NurpP --minimal linux-3.9.5/kernel/sys.c linux-3.9.5-vs2.3.6.5/kernel/sys.c
14896 --- linux-3.9.5/kernel/sys.c 2013-05-31 13:45:30.000000000 +0000
14897 +++ linux-3.9.5-vs2.3.6.5/kernel/sys.c 2013-05-31 15:23:14.000000000 +0000
14899 #include <linux/binfmts.h>
14901 #include <linux/kmsg_dump.h>
14902 +#include <linux/vs_pid.h>
14903 /* Move somewhere else to avoid recompiling? */
14904 #include <generated/utsrelease.h>
14906 @@ -155,7 +156,10 @@ static int set_one_prio(struct task_stru
14909 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
14911 + if (vx_flags(VXF_IGNEG_NICE, 0))
14917 no_nice = security_task_setnice(p, niceval);
14918 @@ -206,6 +210,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
14920 pgrp = task_pgrp(current);
14921 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
14922 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
14924 error = set_one_prio(p, niceval, error);
14925 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
14927 @@ -271,6 +277,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
14929 pgrp = task_pgrp(current);
14930 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
14931 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
14933 niceval = 20 - task_nice(p);
14934 if (niceval > retval)
14936 @@ -424,6 +432,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
14938 static DEFINE_MUTEX(reboot_mutex);
14940 +long vs_reboot(unsigned int, void __user *);
14943 * Reboot system call: for obvious reasons only root may call it,
14944 * and even root needs to set up some magic numbers in the registers
14945 @@ -466,6 +476,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
14946 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
14947 cmd = LINUX_REBOOT_CMD_HALT;
14949 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14950 + return vs_reboot(cmd, arg);
14952 mutex_lock(&reboot_mutex);
14954 case LINUX_REBOOT_CMD_RESTART:
14955 @@ -1373,7 +1386,8 @@ SYSCALL_DEFINE2(sethostname, char __user
14957 char tmp[__NEW_UTS_LEN];
14959 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
14960 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
14961 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
14964 if (len < 0 || len > __NEW_UTS_LEN)
14965 @@ -1424,7 +1438,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
14967 char tmp[__NEW_UTS_LEN];
14969 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
14970 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
14971 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
14973 if (len < 0 || len > __NEW_UTS_LEN)
14975 @@ -1543,7 +1558,7 @@ int do_prlimit(struct task_struct *tsk,
14976 /* Keep the capable check against init_user_ns until
14977 cgroups can contain all limits */
14978 if (new_rlim->rlim_max > rlim->rlim_max &&
14979 - !capable(CAP_SYS_RESOURCE))
14980 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
14983 retval = security_task_setrlimit(tsk->group_leader,
14984 @@ -1596,7 +1611,8 @@ static int check_prlimit_permission(stru
14985 gid_eq(cred->gid, tcred->sgid) &&
14986 gid_eq(cred->gid, tcred->gid))
14988 - if (ns_capable(tcred->user_ns, CAP_SYS_RESOURCE))
14989 + if (vx_ns_capable(tcred->user_ns,
14990 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
14994 diff -NurpP --minimal linux-3.9.5/kernel/sysctl.c linux-3.9.5-vs2.3.6.5/kernel/sysctl.c
14995 --- linux-3.9.5/kernel/sysctl.c 2013-05-31 13:45:30.000000000 +0000
14996 +++ linux-3.9.5-vs2.3.6.5/kernel/sysctl.c 2013-05-31 15:28:39.000000000 +0000
14998 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
14999 #include <linux/lockdep.h>
15001 +extern char vshelper_path[];
15002 #ifdef CONFIG_CHR_DEV_SG
15003 #include <scsi/sg.h>
15005 @@ -629,6 +630,13 @@ static struct ctl_table kern_table[] = {
15007 .proc_handler = proc_dostring,
15010 + .procname = "vshelper",
15011 + .data = &vshelper_path,
15014 + .proc_handler = &proc_dostring,
15017 #ifdef CONFIG_CHR_DEV_SG
15019 diff -NurpP --minimal linux-3.9.5/kernel/sysctl_binary.c linux-3.9.5-vs2.3.6.5/kernel/sysctl_binary.c
15020 --- linux-3.9.5/kernel/sysctl_binary.c 2013-05-31 13:45:30.000000000 +0000
15021 +++ linux-3.9.5-vs2.3.6.5/kernel/sysctl_binary.c 2013-05-31 14:47:11.000000000 +0000
15022 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15024 { CTL_INT, KERN_PANIC, "panic" },
15025 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15026 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15028 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15029 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15030 diff -NurpP --minimal linux-3.9.5/kernel/time/timekeeping.c linux-3.9.5-vs2.3.6.5/kernel/time/timekeeping.c
15031 --- linux-3.9.5/kernel/time/timekeeping.c 2013-05-31 13:45:30.000000000 +0000
15032 +++ linux-3.9.5-vs2.3.6.5/kernel/time/timekeeping.c 2013-05-31 15:24:55.000000000 +0000
15034 #include <linux/tick.h>
15035 #include <linux/stop_machine.h>
15036 #include <linux/pvclock_gtod.h>
15037 +#include <linux/vs_time.h>
15040 static struct timekeeper timekeeper;
15041 @@ -594,6 +595,7 @@ void getrawmonotonic(struct timespec *ts
15042 } while (read_seqretry(&tk->lock, seq));
15044 timespec_add_ns(ts, nsecs);
15045 + vx_adjust_timespec(ts);
15047 EXPORT_SYMBOL(getrawmonotonic);
15049 diff -NurpP --minimal linux-3.9.5/kernel/time.c linux-3.9.5-vs2.3.6.5/kernel/time.c
15050 --- linux-3.9.5/kernel/time.c 2013-05-31 13:45:30.000000000 +0000
15051 +++ linux-3.9.5-vs2.3.6.5/kernel/time.c 2013-05-31 14:47:11.000000000 +0000
15053 #include <linux/fs.h>
15054 #include <linux/math64.h>
15055 #include <linux/ptrace.h>
15056 +#include <linux/vs_time.h>
15058 #include <asm/uaccess.h>
15059 #include <asm/unistd.h>
15060 @@ -92,7 +93,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15064 - do_settimeofday(&tv);
15065 + vx_settimeofday(&tv);
15069 @@ -180,7 +181,7 @@ int do_sys_settimeofday(const struct tim
15073 - return do_settimeofday(tv);
15074 + return vx_settimeofday(tv);
15078 diff -NurpP --minimal linux-3.9.5/kernel/timer.c linux-3.9.5-vs2.3.6.5/kernel/timer.c
15079 --- linux-3.9.5/kernel/timer.c 2013-06-11 12:22:40.000000000 +0000
15080 +++ linux-3.9.5-vs2.3.6.5/kernel/timer.c 2013-05-31 14:47:11.000000000 +0000
15082 #include <linux/sched.h>
15083 #include <linux/sched/sysctl.h>
15084 #include <linux/slab.h>
15085 +#include <linux/vs_base.h>
15086 +#include <linux/vs_cvirt.h>
15087 +#include <linux/vs_pid.h>
15088 +#include <linux/vserver/sched.h>
15090 #include <asm/uaccess.h>
15091 #include <asm/unistd.h>
15092 diff -NurpP --minimal linux-3.9.5/kernel/user_namespace.c linux-3.9.5-vs2.3.6.5/kernel/user_namespace.c
15093 --- linux-3.9.5/kernel/user_namespace.c 2013-05-31 13:45:30.000000000 +0000
15094 +++ linux-3.9.5-vs2.3.6.5/kernel/user_namespace.c 2013-05-31 17:44:56.000000000 +0000
15096 #include <linux/ctype.h>
15097 #include <linux/projid.h>
15098 #include <linux/fs_struct.h>
15099 +#include <linux/vserver/global.h>
15101 static struct kmem_cache *user_ns_cachep __read_mostly;
15103 @@ -91,6 +92,7 @@ int create_user_ns(struct cred *new)
15105 atomic_set(&ns->count, 1);
15106 /* Leave the new->user_ns reference with the new user namespace. */
15107 + atomic_inc(&vs_global_user_ns);
15108 ns->parent = parent_ns;
15111 @@ -835,6 +837,8 @@ static void *userns_get(struct task_stru
15113 static void userns_put(void *ns)
15115 + /* FIXME: maybe move into destroyer? */
15116 + atomic_dec(&vs_global_user_ns);
15120 diff -NurpP --minimal linux-3.9.5/kernel/utsname.c linux-3.9.5-vs2.3.6.5/kernel/utsname.c
15121 --- linux-3.9.5/kernel/utsname.c 2013-05-31 13:45:30.000000000 +0000
15122 +++ linux-3.9.5-vs2.3.6.5/kernel/utsname.c 2013-05-31 15:15:55.000000000 +0000
15123 @@ -16,14 +16,17 @@
15124 #include <linux/slab.h>
15125 #include <linux/user_namespace.h>
15126 #include <linux/proc_fs.h>
15127 +#include <linux/vserver/global.h>
15129 static struct uts_namespace *create_uts_ns(void)
15131 struct uts_namespace *uts_ns;
15133 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15136 kref_init(&uts_ns->kref);
15137 + atomic_inc(&vs_global_uts_ns);
15142 @@ -85,6 +88,7 @@ void free_uts_ns(struct kref *kref)
15143 ns = container_of(kref, struct uts_namespace, kref);
15144 put_user_ns(ns->user_ns);
15145 proc_free_inum(ns->proc_inum);
15146 + atomic_dec(&vs_global_uts_ns);
15150 diff -NurpP --minimal linux-3.9.5/kernel/vserver/Kconfig linux-3.9.5-vs2.3.6.5/kernel/vserver/Kconfig
15151 --- linux-3.9.5/kernel/vserver/Kconfig 1970-01-01 00:00:00.000000000 +0000
15152 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/Kconfig 2013-05-31 14:47:11.000000000 +0000
15155 +# Linux VServer configuration
15158 +menu "Linux VServer"
15160 +config VSERVER_AUTO_LBACK
15161 + bool "Automatically Assign Loopback IP"
15164 + Automatically assign a guest specific loopback
15165 + IP and add it to the kernel network stack on
15168 +config VSERVER_AUTO_SINGLE
15169 + bool "Automatic Single IP Special Casing"
15170 + depends on EXPERIMENTAL
15173 + This allows network contexts with a single IP to
15174 + automatically remap 0.0.0.0 bindings to that IP,
15175 + avoiding further network checks and improving
15178 + (note: such guests do not allow to change the ip
15179 + on the fly and do not show loopback addresses)
15181 +config VSERVER_COWBL
15182 + bool "Enable COW Immutable Link Breaking"
15185 + This enables the COW (Copy-On-Write) link break code.
15186 + It allows you to treat unified files like normal files
15187 + when writing to them (which will implicitely break the
15188 + link and create a copy of the unified file)
15190 +config VSERVER_VTIME
15191 + bool "Enable Virtualized Guest Time"
15192 + depends on EXPERIMENTAL
15195 + This enables per guest time offsets to allow for
15196 + adjusting the system clock individually per guest.
15197 + this adds some overhead to the time functions and
15198 + therefore should not be enabled without good reason.
15200 +config VSERVER_DEVICE
15201 + bool "Enable Guest Device Mapping"
15202 + depends on EXPERIMENTAL
15205 + This enables generic device remapping.
15207 +config VSERVER_PROC_SECURE
15208 + bool "Enable Proc Security"
15209 + depends on PROC_FS
15212 + This configures ProcFS security to initially hide
15213 + non-process entries for all contexts except the main and
15214 + spectator context (i.e. for all guests), which is a secure
15217 + (note: on 1.2x the entries were visible by default)
15220 + prompt "Persistent Inode Tagging"
15221 + default TAGGING_ID24
15223 + This adds persistent context information to filesystems
15224 + mounted with the tagxid option. Tagging is a requirement
15225 + for per-context disk limits and per-context quota.
15228 +config TAGGING_NONE
15231 + do not store per-context information in inodes.
15233 +config TAGGING_UID16
15234 + bool "UID16/GID32"
15236 + reduces UID to 16 bit, but leaves GID at 32 bit.
15238 +config TAGGING_GID16
15239 + bool "UID32/GID16"
15241 + reduces GID to 16 bit, but leaves UID at 32 bit.
15243 +config TAGGING_ID24
15244 + bool "UID24/GID24"
15246 + uses the upper 8bit from UID and GID for XID tagging
15247 + which leaves 24bit for UID/GID each, which should be
15248 + more than sufficient for normal use.
15250 +config TAGGING_INTERN
15251 + bool "UID32/GID32"
15253 + this uses otherwise reserved inode fields in the on
15254 + disk representation, which limits the use to a few
15255 + filesystems (currently ext2 and ext3)
15260 + bool "Tag NFSD User Auth and Files"
15263 + Enable this if you do want the in-kernel NFS
15264 + Server to use the tagging specified above.
15265 + (will require patched clients too)
15267 +config VSERVER_PRIVACY
15268 + bool "Honor Privacy Aspects of Guests"
15271 + When enabled, most context checks will disallow
15272 + access to structures assigned to a specific context,
15273 + like ptys or loop devices.
15275 +config VSERVER_CONTEXTS
15276 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15278 + default "768" if 64BIT
15281 + This setting will optimize certain data structures
15282 + and memory allocations according to the expected
15285 + note: this is not a strict upper limit.
15287 +config VSERVER_WARN
15288 + bool "VServer Warnings"
15291 + This enables various runtime warnings, which will
15292 + notify about potential manipulation attempts or
15293 + resource shortage. It is generally considered to
15294 + be a good idea to have that enabled.
15296 +config VSERVER_WARN_DEVPTS
15297 + bool "VServer DevPTS Warnings"
15298 + depends on VSERVER_WARN
15301 + This enables DevPTS related warnings, issued when a
15302 + process inside a context tries to lookup or access
15303 + a dynamic pts from the host or a different context.
15305 +config VSERVER_DEBUG
15306 + bool "VServer Debugging Code"
15309 + Set this to yes if you want to be able to activate
15310 + debugging output at runtime. It adds a very small
15311 + overhead to all vserver related functions and
15312 + increases the kernel size by about 20k.
15314 +config VSERVER_HISTORY
15315 + bool "VServer History Tracing"
15316 + depends on VSERVER_DEBUG
15319 + Set this to yes if you want to record the history of
15320 + linux-vserver activities, so they can be replayed in
15321 + the event of a kernel panic or oops.
15323 +config VSERVER_HISTORY_SIZE
15324 + int "Per-CPU History Size (32-65536)"
15325 + depends on VSERVER_HISTORY
15329 + This allows you to specify the number of entries in
15330 + the per-CPU history buffer.
15332 +config VSERVER_EXTRA_MNT_CHECK
15333 + bool "Extra Checks for Reachability"
15336 + Set this to yes if you want to do extra checks for
15337 + vfsmount reachability in the proc filesystem code.
15338 + This shouldn't be required on any setup utilizing
15342 + prompt "Quotes used in debug and warn messages"
15343 + default QUOTES_ISO8859
15345 +config QUOTES_ISO8859
15346 + bool "Extended ASCII (ISO 8859) angle quotes"
15348 + This uses the extended ASCII characters \xbb
15349 + and \xab for quoting file and process names.
15351 +config QUOTES_UTF8
15352 + bool "UTF-8 angle quotes"
15354 + This uses the the UTF-8 sequences for angle
15355 + quotes to quote file and process names.
15357 +config QUOTES_ASCII
15358 + bool "ASCII single quotes"
15360 + This uses the ASCII single quote character
15361 + (\x27) to quote file and process names.
15371 + select NAMESPACES
15377 +config VSERVER_SECURITY
15379 + depends on SECURITY
15381 + select SECURITY_CAPABILITIES
15383 +config VSERVER_DISABLED
15387 diff -NurpP --minimal linux-3.9.5/kernel/vserver/Makefile linux-3.9.5-vs2.3.6.5/kernel/vserver/Makefile
15388 --- linux-3.9.5/kernel/vserver/Makefile 1970-01-01 00:00:00.000000000 +0000
15389 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/Makefile 2013-05-31 14:47:11.000000000 +0000
15392 +# Makefile for the Linux vserver routines.
15396 +obj-y += vserver.o
15398 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15399 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15402 +vserver-$(CONFIG_INET) += inet.o
15403 +vserver-$(CONFIG_PROC_FS) += proc.o
15404 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15405 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15406 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15407 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
15409 diff -NurpP --minimal linux-3.9.5/kernel/vserver/cacct.c linux-3.9.5-vs2.3.6.5/kernel/vserver/cacct.c
15410 --- linux-3.9.5/kernel/vserver/cacct.c 1970-01-01 00:00:00.000000000 +0000
15411 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/cacct.c 2013-05-31 14:47:11.000000000 +0000
15414 + * linux/kernel/vserver/cacct.c
15416 + * Virtual Server: Context Accounting
15418 + * Copyright (C) 2006-2007 Herbert Pötzl
15420 + * V0.01 added accounting stats
15424 +#include <linux/types.h>
15425 +#include <linux/vs_context.h>
15426 +#include <linux/vserver/cacct_cmd.h>
15427 +#include <linux/vserver/cacct_int.h>
15429 +#include <asm/errno.h>
15430 +#include <asm/uaccess.h>
15433 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15435 + struct vcmd_sock_stat_v0 vc_data;
15438 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15441 + field = vc_data.field;
15442 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15445 + for (j = 0; j < 3; j++) {
15446 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15447 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15450 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15455 diff -NurpP --minimal linux-3.9.5/kernel/vserver/cacct_init.h linux-3.9.5-vs2.3.6.5/kernel/vserver/cacct_init.h
15456 --- linux-3.9.5/kernel/vserver/cacct_init.h 1970-01-01 00:00:00.000000000 +0000
15457 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/cacct_init.h 2013-05-31 14:47:11.000000000 +0000
15461 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
15466 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15467 + for (j = 0; j < 3; j++) {
15468 + atomic_long_set(&cacct->sock[i][j].count, 0);
15469 + atomic_long_set(&cacct->sock[i][j].total, 0);
15472 + for (i = 0; i < 8; i++)
15473 + atomic_set(&cacct->slab[i], 0);
15474 + for (i = 0; i < 5; i++)
15475 + for (j = 0; j < 4; j++)
15476 + atomic_set(&cacct->page[i][j], 0);
15479 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
15484 diff -NurpP --minimal linux-3.9.5/kernel/vserver/cacct_proc.h linux-3.9.5-vs2.3.6.5/kernel/vserver/cacct_proc.h
15485 --- linux-3.9.5/kernel/vserver/cacct_proc.h 1970-01-01 00:00:00.000000000 +0000
15486 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/cacct_proc.h 2013-05-31 14:47:11.000000000 +0000
15488 +#ifndef _VX_CACCT_PROC_H
15489 +#define _VX_CACCT_PROC_H
15491 +#include <linux/vserver/cacct_int.h>
15494 +#define VX_SOCKA_TOP \
15495 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
15497 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
15499 + int i, j, length = 0;
15500 + static char *type[VXA_SOCK_SIZE] = {
15501 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
15504 + length += sprintf(buffer + length, VX_SOCKA_TOP);
15505 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15506 + length += sprintf(buffer + length, "%s:", type[i]);
15507 + for (j = 0; j < 3; j++) {
15508 + length += sprintf(buffer + length,
15509 + "\t%10lu/%-10lu",
15510 + vx_sock_count(cacct, i, j),
15511 + vx_sock_total(cacct, i, j));
15513 + buffer[length++] = '\n';
15516 + length += sprintf(buffer + length, "\n");
15517 + length += sprintf(buffer + length,
15518 + "slab:\t %8u %8u %8u %8u\n",
15519 + atomic_read(&cacct->slab[1]),
15520 + atomic_read(&cacct->slab[4]),
15521 + atomic_read(&cacct->slab[0]),
15522 + atomic_read(&cacct->slab[2]));
15524 + length += sprintf(buffer + length, "\n");
15525 + for (i = 0; i < 5; i++) {
15526 + length += sprintf(buffer + length,
15527 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
15528 + atomic_read(&cacct->page[i][0]),
15529 + atomic_read(&cacct->page[i][1]),
15530 + atomic_read(&cacct->page[i][2]),
15531 + atomic_read(&cacct->page[i][3]),
15532 + atomic_read(&cacct->page[i][4]),
15533 + atomic_read(&cacct->page[i][5]),
15534 + atomic_read(&cacct->page[i][6]),
15535 + atomic_read(&cacct->page[i][7]));
15540 +#endif /* _VX_CACCT_PROC_H */
15541 diff -NurpP --minimal linux-3.9.5/kernel/vserver/context.c linux-3.9.5-vs2.3.6.5/kernel/vserver/context.c
15542 --- linux-3.9.5/kernel/vserver/context.c 1970-01-01 00:00:00.000000000 +0000
15543 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/context.c 2013-06-12 23:49:09.000000000 +0000
15546 + * linux/kernel/vserver/context.c
15548 + * Virtual Server: Context Support
15550 + * Copyright (C) 2003-2011 Herbert Pötzl
15552 + * V0.01 context helper
15553 + * V0.02 vx_ctx_kill syscall command
15554 + * V0.03 replaced context_info calls
15555 + * V0.04 redesign of struct (de)alloc
15556 + * V0.05 rlimit basic implementation
15557 + * V0.06 task_xid and info commands
15558 + * V0.07 context flags and caps
15559 + * V0.08 switch to RCU based hash
15560 + * V0.09 revert to non RCU for now
15561 + * V0.10 and back to working RCU hash
15562 + * V0.11 and back to locking again
15563 + * V0.12 referenced context store
15564 + * V0.13 separate per cpu data
15565 + * V0.14 changed vcmds to vxi arg
15566 + * V0.15 added context stat
15567 + * V0.16 have __create claim() the vxi
15568 + * V0.17 removed older and legacy stuff
15569 + * V0.18 added user credentials
15570 + * V0.19 added warn mask
15574 +#include <linux/slab.h>
15575 +#include <linux/types.h>
15576 +#include <linux/security.h>
15577 +#include <linux/pid_namespace.h>
15578 +#include <linux/capability.h>
15580 +#include <linux/vserver/context.h>
15581 +#include <linux/vserver/network.h>
15582 +#include <linux/vserver/debug.h>
15583 +#include <linux/vserver/limit.h>
15584 +#include <linux/vserver/limit_int.h>
15585 +#include <linux/vserver/space.h>
15586 +#include <linux/init_task.h>
15587 +#include <linux/fs_struct.h>
15588 +#include <linux/cred.h>
15590 +#include <linux/vs_context.h>
15591 +#include <linux/vs_limit.h>
15592 +#include <linux/vs_pid.h>
15593 +#include <linux/vserver/context_cmd.h>
15595 +#include "cvirt_init.h"
15596 +#include "cacct_init.h"
15597 +#include "limit_init.h"
15598 +#include "sched_init.h"
15601 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
15602 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
15605 +/* now inactive context structures */
15607 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
15609 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
15612 +/* __alloc_vx_info()
15614 + * allocate an initialized vx_info struct
15615 + * doesn't make it visible (hash) */
15617 +static struct vx_info *__alloc_vx_info(vxid_t xid)
15619 + struct vx_info *new = NULL;
15622 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
15624 + /* would this benefit from a slab cache? */
15625 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
15629 + memset(new, 0, sizeof(struct vx_info));
15631 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
15632 + if (!new->ptr_pc)
15635 + new->vx_id = xid;
15636 + INIT_HLIST_NODE(&new->vx_hlist);
15637 + atomic_set(&new->vx_usecnt, 0);
15638 + atomic_set(&new->vx_tasks, 0);
15639 + new->vx_parent = NULL;
15640 + new->vx_state = 0;
15641 + init_waitqueue_head(&new->vx_wait);
15643 + /* prepare reaper */
15644 + get_task_struct(init_pid_ns.child_reaper);
15645 + new->vx_reaper = init_pid_ns.child_reaper;
15646 + new->vx_badness_bias = 0;
15648 + /* rest of init goes here */
15649 + vx_info_init_limit(&new->limit);
15650 + vx_info_init_sched(&new->sched);
15651 + vx_info_init_cvirt(&new->cvirt);
15652 + vx_info_init_cacct(&new->cacct);
15654 + /* per cpu data structures */
15655 + for_each_possible_cpu(cpu) {
15656 + vx_info_init_sched_pc(
15657 + &vx_per_cpu(new, sched_pc, cpu), cpu);
15658 + vx_info_init_cvirt_pc(
15659 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
15662 + new->vx_flags = VXF_INIT_SET;
15663 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
15664 + new->vx_ccaps = 0;
15665 + new->vx_umask = 0;
15666 + new->vx_wmask = 0;
15668 + new->reboot_cmd = 0;
15669 + new->exit_code = 0;
15671 + // preconfig spaces
15672 + for (index = 0; index < VX_SPACES; index++) {
15673 + struct _vx_space *space = &new->space[index];
15676 + spin_lock(&init_fs.lock);
15678 + spin_unlock(&init_fs.lock);
15679 + space->vx_fs = &init_fs;
15681 + /* FIXME: do we want defaults? */
15682 + // space->vx_real_cred = 0;
15683 + // space->vx_cred = 0;
15687 + vxdprintk(VXD_CBIT(xid, 0),
15688 + "alloc_vx_info(%d) = %p", xid, new);
15689 + vxh_alloc_vx_info(new);
15690 + atomic_inc(&vx_global_ctotal);
15699 +/* __dealloc_vx_info()
15701 + * final disposal of vx_info */
15703 +static void __dealloc_vx_info(struct vx_info *vxi)
15705 +#ifdef CONFIG_VSERVER_WARN
15706 + struct vx_info_save vxis;
15709 + vxdprintk(VXD_CBIT(xid, 0),
15710 + "dealloc_vx_info(%p)", vxi);
15711 + vxh_dealloc_vx_info(vxi);
15713 +#ifdef CONFIG_VSERVER_WARN
15714 + enter_vx_info(vxi, &vxis);
15715 + vx_info_exit_limit(&vxi->limit);
15716 + vx_info_exit_sched(&vxi->sched);
15717 + vx_info_exit_cvirt(&vxi->cvirt);
15718 + vx_info_exit_cacct(&vxi->cacct);
15720 + for_each_possible_cpu(cpu) {
15721 + vx_info_exit_sched_pc(
15722 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
15723 + vx_info_exit_cvirt_pc(
15724 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
15726 + leave_vx_info(&vxis);
15730 + vxi->vx_state |= VXS_RELEASED;
15733 + free_percpu(vxi->ptr_pc);
15736 + atomic_dec(&vx_global_ctotal);
15739 +static void __shutdown_vx_info(struct vx_info *vxi)
15741 + struct nsproxy *nsproxy;
15742 + struct fs_struct *fs;
15743 + struct cred *cred;
15748 + vxi->vx_state |= VXS_SHUTDOWN;
15749 + vs_state_change(vxi, VSC_SHUTDOWN);
15751 + for (index = 0; index < VX_SPACES; index++) {
15752 + struct _vx_space *space = &vxi->space[index];
15754 + nsproxy = xchg(&space->vx_nsproxy, NULL);
15756 + put_nsproxy(nsproxy);
15758 + fs = xchg(&space->vx_fs, NULL);
15759 + spin_lock(&fs->lock);
15760 + kill = !--fs->users;
15761 + spin_unlock(&fs->lock);
15763 + free_fs_struct(fs);
15765 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
15767 + abort_creds(cred);
15771 +/* exported stuff */
15773 +void free_vx_info(struct vx_info *vxi)
15775 + unsigned long flags;
15778 + /* check for reference counts first */
15779 + BUG_ON(atomic_read(&vxi->vx_usecnt));
15780 + BUG_ON(atomic_read(&vxi->vx_tasks));
15782 + /* context must not be hashed */
15783 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
15785 + /* context shutdown is mandatory */
15786 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
15788 + /* spaces check */
15789 + for (index = 0; index < VX_SPACES; index++) {
15790 + struct _vx_space *space = &vxi->space[index];
15792 + BUG_ON(space->vx_nsproxy);
15793 + BUG_ON(space->vx_fs);
15794 + // BUG_ON(space->vx_real_cred);
15795 + // BUG_ON(space->vx_cred);
15798 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
15799 + hlist_del(&vxi->vx_hlist);
15800 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
15802 + __dealloc_vx_info(vxi);
15806 +/* hash table for vx_info hash */
15808 +#define VX_HASH_SIZE 13
15810 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
15811 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
15813 +static DEFINE_SPINLOCK(vx_info_hash_lock);
15816 +static inline unsigned int __hashval(vxid_t xid)
15818 + return (xid % VX_HASH_SIZE);
15823 +/* __hash_vx_info()
15825 + * add the vxi to the global hash table
15826 + * requires the hash_lock to be held */
15828 +static inline void __hash_vx_info(struct vx_info *vxi)
15830 + struct hlist_head *head;
15832 + vxd_assert_lock(&vx_info_hash_lock);
15833 + vxdprintk(VXD_CBIT(xid, 4),
15834 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
15835 + vxh_hash_vx_info(vxi);
15837 + /* context must not be hashed */
15838 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
15840 + vxi->vx_state |= VXS_HASHED;
15841 + head = &vx_info_hash[__hashval(vxi->vx_id)];
15842 + hlist_add_head(&vxi->vx_hlist, head);
15843 + atomic_inc(&vx_global_cactive);
15846 +/* __unhash_vx_info()
15848 + * remove the vxi from the global hash table
15849 + * requires the hash_lock to be held */
15851 +static inline void __unhash_vx_info(struct vx_info *vxi)
15853 + unsigned long flags;
15855 + vxd_assert_lock(&vx_info_hash_lock);
15856 + vxdprintk(VXD_CBIT(xid, 4),
15857 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
15858 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
15859 + vxh_unhash_vx_info(vxi);
15861 + /* context must be hashed */
15862 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
15863 + /* but without tasks */
15864 + BUG_ON(atomic_read(&vxi->vx_tasks));
15866 + vxi->vx_state &= ~VXS_HASHED;
15867 + hlist_del_init(&vxi->vx_hlist);
15868 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
15869 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
15870 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
15871 + atomic_dec(&vx_global_cactive);
15875 +/* __lookup_vx_info()
15877 + * requires the hash_lock to be held
15878 + * doesn't increment the vx_refcnt */
15880 +static inline struct vx_info *__lookup_vx_info(vxid_t xid)
15882 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
15883 + struct hlist_node *pos;
15884 + struct vx_info *vxi;
15886 + vxd_assert_lock(&vx_info_hash_lock);
15887 + hlist_for_each(pos, head) {
15888 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
15890 + if (vxi->vx_id == xid)
15895 + vxdprintk(VXD_CBIT(xid, 0),
15896 + "__lookup_vx_info(#%u): %p[#%u]",
15897 + xid, vxi, vxi ? vxi->vx_id : 0);
15898 + vxh_lookup_vx_info(vxi, xid);
15903 +/* __create_vx_info()
15905 + * create the requested context
15906 + * get(), claim() and hash it */
15908 +static struct vx_info *__create_vx_info(int id)
15910 + struct vx_info *new, *vxi = NULL;
15912 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
15914 + if (!(new = __alloc_vx_info(id)))
15915 + return ERR_PTR(-ENOMEM);
15917 + /* required to make dynamic xids unique */
15918 + spin_lock(&vx_info_hash_lock);
15920 + /* static context requested */
15921 + if ((vxi = __lookup_vx_info(id))) {
15922 + vxdprintk(VXD_CBIT(xid, 0),
15923 + "create_vx_info(%d) = %p (already there)", id, vxi);
15924 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
15925 + vxi = ERR_PTR(-EBUSY);
15927 + vxi = ERR_PTR(-EEXIST);
15930 + /* new context */
15931 + vxdprintk(VXD_CBIT(xid, 0),
15932 + "create_vx_info(%d) = %p (new)", id, new);
15933 + claim_vx_info(new, NULL);
15934 + __hash_vx_info(get_vx_info(new));
15935 + vxi = new, new = NULL;
15938 + spin_unlock(&vx_info_hash_lock);
15939 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
15941 + __dealloc_vx_info(new);
15946 +/* exported stuff */
15949 +void unhash_vx_info(struct vx_info *vxi)
15951 + spin_lock(&vx_info_hash_lock);
15952 + __unhash_vx_info(vxi);
15953 + spin_unlock(&vx_info_hash_lock);
15954 + __shutdown_vx_info(vxi);
15955 + __wakeup_vx_info(vxi);
15959 +/* lookup_vx_info()
15961 + * search for a vx_info and get() it
15962 + * negative id means current */
15964 +struct vx_info *lookup_vx_info(int id)
15966 + struct vx_info *vxi = NULL;
15969 + vxi = get_vx_info(current_vx_info());
15970 + } else if (id > 1) {
15971 + spin_lock(&vx_info_hash_lock);
15972 + vxi = get_vx_info(__lookup_vx_info(id));
15973 + spin_unlock(&vx_info_hash_lock);
15978 +/* xid_is_hashed()
15980 + * verify that xid is still hashed */
15982 +int xid_is_hashed(vxid_t xid)
15986 + spin_lock(&vx_info_hash_lock);
15987 + hashed = (__lookup_vx_info(xid) != NULL);
15988 + spin_unlock(&vx_info_hash_lock);
15992 +#ifdef CONFIG_PROC_FS
15996 + * get a subset of hashed xids for proc
15997 + * assumes size is at least one */
15999 +int get_xid_list(int index, unsigned int *xids, int size)
16001 + int hindex, nr_xids = 0;
16003 + /* only show current and children */
16004 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16007 + xids[nr_xids] = vx_current_xid();
16011 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16012 + struct hlist_head *head = &vx_info_hash[hindex];
16013 + struct hlist_node *pos;
16015 + spin_lock(&vx_info_hash_lock);
16016 + hlist_for_each(pos, head) {
16017 + struct vx_info *vxi;
16022 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16023 + xids[nr_xids] = vxi->vx_id;
16024 + if (++nr_xids >= size) {
16025 + spin_unlock(&vx_info_hash_lock);
16029 + /* keep the lock time short */
16030 + spin_unlock(&vx_info_hash_lock);
16037 +#ifdef CONFIG_VSERVER_DEBUG
16039 +void dump_vx_info_inactive(int level)
16041 + struct hlist_node *entry, *next;
16043 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16044 + struct vx_info *vxi =
16045 + list_entry(entry, struct vx_info, vx_hlist);
16047 + dump_vx_info(vxi, level);
16054 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16056 + struct user_struct *new_user, *old_user;
16061 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16064 + new_user = alloc_uid(vxi->vx_id, p->uid);
16068 + old_user = p->user;
16069 + if (new_user != old_user) {
16070 + atomic_inc(&new_user->processes);
16071 + atomic_dec(&old_user->processes);
16072 + p->user = new_user;
16074 + free_uid(old_user);
16080 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16082 + // p->cap_effective &= vxi->vx_cap_bset;
16083 + p->cap_effective =
16084 + cap_intersect(p->cap_effective, vxi->cap_bset);
16085 + // p->cap_inheritable &= vxi->vx_cap_bset;
16086 + p->cap_inheritable =
16087 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16088 + // p->cap_permitted &= vxi->vx_cap_bset;
16089 + p->cap_permitted =
16090 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16095 +#include <linux/file.h>
16096 +#include <linux/fdtable.h>
16098 +static int vx_openfd_task(struct task_struct *tsk)
16100 + struct files_struct *files = tsk->files;
16101 + struct fdtable *fdt;
16102 + const unsigned long *bptr;
16103 + int count, total;
16105 + /* no rcu_read_lock() because of spin_lock() */
16106 + spin_lock(&files->file_lock);
16107 + fdt = files_fdtable(files);
16108 + bptr = fdt->open_fds;
16109 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16110 + for (total = 0; count > 0; count--) {
16112 + total += hweight_long(*bptr);
16115 + spin_unlock(&files->file_lock);
16120 +/* for *space compatibility */
16122 +asmlinkage long sys_unshare(unsigned long);
16125 + * migrate task to new context
16126 + * gets vxi, puts old_vxi on change
16127 + * optionally unshares namespaces (hack)
16130 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16132 + struct vx_info *old_vxi;
16138 + vxdprintk(VXD_CBIT(xid, 5),
16139 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16140 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16142 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16143 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16146 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16149 + old_vxi = task_get_vx_info(p);
16150 + if (old_vxi == vxi)
16153 +// if (!(ret = vx_migrate_user(p, vxi))) {
16158 + openfd = vx_openfd_task(p);
16161 + atomic_dec(&old_vxi->cvirt.nr_threads);
16162 + atomic_dec(&old_vxi->cvirt.nr_running);
16163 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16164 + /* FIXME: what about the struct files here? */
16165 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16166 + /* account for the executable */
16167 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16169 + atomic_inc(&vxi->cvirt.nr_threads);
16170 + atomic_inc(&vxi->cvirt.nr_running);
16171 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16172 + /* FIXME: what about the struct files here? */
16173 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16174 + /* account for the executable */
16175 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16178 + release_vx_info(old_vxi, p);
16179 + clr_vx_info(&p->vx_info);
16181 + claim_vx_info(vxi, p);
16182 + set_vx_info(&p->vx_info, vxi);
16183 + p->xid = vxi->vx_id;
16185 + vxdprintk(VXD_CBIT(xid, 5),
16186 + "moved task %p into vxi:%p[#%d]",
16187 + p, vxi, vxi->vx_id);
16189 + // vx_mask_cap_bset(vxi, p);
16192 + /* hack for *spaces to provide compatibility */
16194 + struct nsproxy *old_nsp, *new_nsp;
16196 + ret = unshare_nsproxy_namespaces(
16197 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16198 + &new_nsp, NULL, NULL);
16202 + old_nsp = xchg(&p->nsproxy, new_nsp);
16203 + vx_set_space(vxi,
16204 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16205 + put_nsproxy(old_nsp);
16209 + put_vx_info(old_vxi);
16213 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16215 + struct task_struct *old_reaper;
16216 + struct vx_info *reaper_vxi;
16221 + vxdprintk(VXD_CBIT(xid, 6),
16222 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16223 + vxi, vxi->vx_id, p, p->xid, p->pid);
16225 + old_reaper = vxi->vx_reaper;
16226 + if (old_reaper == p)
16229 + reaper_vxi = task_get_vx_info(p);
16230 + if (reaper_vxi && reaper_vxi != vxi) {
16232 + "Unsuitable reaper [" VS_Q("%s") ",%u:#%u] "
16234 + p->comm, p->pid, p->xid, vx_current_xid());
16238 + /* set new child reaper */
16239 + get_task_struct(p);
16240 + vxi->vx_reaper = p;
16241 + put_task_struct(old_reaper);
16243 + put_vx_info(reaper_vxi);
16247 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16252 + vxdprintk(VXD_CBIT(xid, 6),
16253 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16254 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16256 + vxi->vx_flags &= ~VXF_STATE_INIT;
16257 + // vxi->vx_initpid = p->tgid;
16258 + vxi->vx_initpid = p->pid;
16262 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16264 + vxdprintk(VXD_CBIT(xid, 6),
16265 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16266 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16268 + vxi->exit_code = code;
16269 + vxi->vx_initpid = 0;
16273 +void vx_set_persistent(struct vx_info *vxi)
16275 + vxdprintk(VXD_CBIT(xid, 6),
16276 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16278 + get_vx_info(vxi);
16279 + claim_vx_info(vxi, NULL);
16282 +void vx_clear_persistent(struct vx_info *vxi)
16284 + vxdprintk(VXD_CBIT(xid, 6),
16285 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16287 + release_vx_info(vxi, NULL);
16288 + put_vx_info(vxi);
16291 +void vx_update_persistent(struct vx_info *vxi)
16293 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16294 + vx_set_persistent(vxi);
16296 + vx_clear_persistent(vxi);
16300 +/* task must be current or locked */
16302 +void exit_vx_info(struct task_struct *p, int code)
16304 + struct vx_info *vxi = p->vx_info;
16307 + atomic_dec(&vxi->cvirt.nr_threads);
16310 + vxi->exit_code = code;
16311 + release_vx_info(vxi, p);
16315 +void exit_vx_info_early(struct task_struct *p, int code)
16317 + struct vx_info *vxi = p->vx_info;
16320 + if (vxi->vx_initpid == p->pid)
16321 + vx_exit_init(vxi, p, code);
16322 + if (vxi->vx_reaper == p)
16323 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16328 +/* vserver syscall commands below here */
16330 +/* taks xid and vx_info functions */
16332 +#include <asm/uaccess.h>
16335 +int vc_task_xid(uint32_t id)
16340 + struct task_struct *tsk;
16343 + tsk = find_task_by_real_pid(id);
16344 + xid = (tsk) ? tsk->xid : -ESRCH;
16345 + rcu_read_unlock();
16347 + xid = vx_current_xid();
16352 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16354 + struct vcmd_vx_info_v0 vc_data;
16356 + vc_data.xid = vxi->vx_id;
16357 + vc_data.initpid = vxi->vx_initpid;
16359 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16365 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16367 + struct vcmd_ctx_stat_v0 vc_data;
16369 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16370 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16372 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16378 +/* context functions */
16380 +int vc_ctx_create(uint32_t xid, void __user *data)
16382 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16383 + struct vx_info *new_vxi;
16386 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16389 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16392 + new_vxi = __create_vx_info(xid);
16393 + if (IS_ERR(new_vxi))
16394 + return PTR_ERR(new_vxi);
16396 + /* initial flags */
16397 + new_vxi->vx_flags = vc_data.flagword;
16400 + if (vs_state_change(new_vxi, VSC_STARTUP))
16403 + ret = vx_migrate_task(current, new_vxi, (!data));
16407 + /* return context id on success */
16408 + ret = new_vxi->vx_id;
16410 + /* get a reference for persistent contexts */
16411 + if ((vc_data.flagword & VXF_PERSISTENT))
16412 + vx_set_persistent(new_vxi);
16414 + release_vx_info(new_vxi, NULL);
16415 + put_vx_info(new_vxi);
16420 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16422 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16425 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16428 + ret = vx_migrate_task(current, vxi, 0);
16431 + if (vc_data.flagword & VXM_SET_INIT)
16432 + ret = vx_set_init(vxi, current);
16435 + if (vc_data.flagword & VXM_SET_REAPER)
16436 + ret = vx_set_reaper(vxi, current);
16441 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16443 + struct vcmd_ctx_flags_v0 vc_data;
16445 + vc_data.flagword = vxi->vx_flags;
16447 + /* special STATE flag handling */
16448 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16450 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16455 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16457 + struct vcmd_ctx_flags_v0 vc_data;
16458 + uint64_t mask, trigger;
16460 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16463 + /* special STATE flag handling */
16464 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16465 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16467 + if (vxi == current_vx_info()) {
16468 + /* if (trigger & VXF_STATE_SETUP)
16469 + vx_mask_cap_bset(vxi, current); */
16470 + if (trigger & VXF_STATE_INIT) {
16473 + ret = vx_set_init(vxi, current);
16476 + ret = vx_set_reaper(vxi, current);
16482 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
16483 + vc_data.flagword, mask);
16484 + if (trigger & VXF_PERSISTENT)
16485 + vx_update_persistent(vxi);
16491 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
16493 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
16495 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
16499 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
16501 + kernel_cap_t c = __cap_empty_set;
16503 + c.cap[0] = v & 0xFFFFFFFF;
16504 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
16506 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
16511 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
16514 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
16516 + *ccaps = vxi->vx_ccaps;
16521 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
16523 + struct vcmd_ctx_caps_v1 vc_data;
16526 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
16529 + vc_data.cmask = ~0ULL;
16531 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16536 +static int do_set_caps(struct vx_info *vxi,
16537 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
16539 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
16542 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
16543 + bcaps, bmask, ccaps, cmask);
16545 + vxi->vx_bcaps = cap_t_from_caps(
16546 + vs_mask_flags(bcold, bcaps, bmask));
16547 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
16552 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
16554 + struct vcmd_ctx_caps_v1 vc_data;
16556 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16559 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
16562 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
16564 + struct vcmd_bcaps vc_data;
16567 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
16570 + vc_data.bmask = ~0ULL;
16572 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16577 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
16579 + struct vcmd_bcaps vc_data;
16581 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16584 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
16588 +int vc_get_umask(struct vx_info *vxi, void __user *data)
16590 + struct vcmd_umask vc_data;
16592 + vc_data.umask = vxi->vx_umask;
16593 + vc_data.mask = ~0ULL;
16595 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16600 +int vc_set_umask(struct vx_info *vxi, void __user *data)
16602 + struct vcmd_umask vc_data;
16604 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16607 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
16608 + vc_data.umask, vc_data.mask);
16613 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
16615 + struct vcmd_wmask vc_data;
16617 + vc_data.wmask = vxi->vx_wmask;
16618 + vc_data.mask = ~0ULL;
16620 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16625 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
16627 + struct vcmd_wmask vc_data;
16629 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16632 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
16633 + vc_data.wmask, vc_data.mask);
16638 +int vc_get_badness(struct vx_info *vxi, void __user *data)
16640 + struct vcmd_badness_v0 vc_data;
16642 + vc_data.bias = vxi->vx_badness_bias;
16644 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16649 +int vc_set_badness(struct vx_info *vxi, void __user *data)
16651 + struct vcmd_badness_v0 vc_data;
16653 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16656 + vxi->vx_badness_bias = vc_data.bias;
16660 +#include <linux/module.h>
16662 +EXPORT_SYMBOL_GPL(free_vx_info);
16664 diff -NurpP --minimal linux-3.9.5/kernel/vserver/cvirt.c linux-3.9.5-vs2.3.6.5/kernel/vserver/cvirt.c
16665 --- linux-3.9.5/kernel/vserver/cvirt.c 1970-01-01 00:00:00.000000000 +0000
16666 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/cvirt.c 2013-05-31 14:47:11.000000000 +0000
16669 + * linux/kernel/vserver/cvirt.c
16671 + * Virtual Server: Context Virtualization
16673 + * Copyright (C) 2004-2007 Herbert Pötzl
16675 + * V0.01 broken out from limit.c
16676 + * V0.02 added utsname stuff
16677 + * V0.03 changed vcmds to vxi arg
16681 +#include <linux/types.h>
16682 +#include <linux/utsname.h>
16683 +#include <linux/vs_cvirt.h>
16684 +#include <linux/vserver/switch.h>
16685 +#include <linux/vserver/cvirt_cmd.h>
16687 +#include <asm/uaccess.h>
16690 +void vx_vsi_boottime(struct timespec *boottime)
16692 + struct vx_info *vxi = current_vx_info();
16694 + set_normalized_timespec(boottime,
16695 + boottime->tv_sec + vxi->cvirt.bias_uptime.tv_sec,
16696 + boottime->tv_nsec + vxi->cvirt.bias_uptime.tv_nsec);
16700 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
16702 + struct vx_info *vxi = current_vx_info();
16704 + set_normalized_timespec(uptime,
16705 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
16706 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
16709 + set_normalized_timespec(idle,
16710 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
16711 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
16715 +uint64_t vx_idle_jiffies(void)
16717 + return init_task.utime + init_task.stime;
16722 +static inline uint32_t __update_loadavg(uint32_t load,
16723 + int wsize, int delta, int n)
16725 + unsigned long long calc, prev;
16727 + /* just set it to n */
16728 + if (unlikely(delta >= wsize))
16729 + return (n << FSHIFT);
16731 + calc = delta * n;
16733 + prev = (wsize - delta);
16736 + do_div(calc, wsize);
16741 +void vx_update_load(struct vx_info *vxi)
16743 + uint32_t now, last, delta;
16744 + unsigned int nr_running, nr_uninterruptible;
16745 + unsigned int total;
16746 + unsigned long flags;
16748 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
16751 + last = vxi->cvirt.load_last;
16752 + delta = now - last;
16754 + if (delta < 5*HZ)
16757 + nr_running = atomic_read(&vxi->cvirt.nr_running);
16758 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
16759 + total = nr_running + nr_uninterruptible;
16761 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
16762 + 60*HZ, delta, total);
16763 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
16764 + 5*60*HZ, delta, total);
16765 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
16766 + 15*60*HZ, delta, total);
16768 + vxi->cvirt.load_last = now;
16770 + atomic_inc(&vxi->cvirt.load_updates);
16771 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
16776 + * Commands to do_syslog:
16778 + * 0 -- Close the log. Currently a NOP.
16779 + * 1 -- Open the log. Currently a NOP.
16780 + * 2 -- Read from the log.
16781 + * 3 -- Read all messages remaining in the ring buffer.
16782 + * 4 -- Read and clear all messages remaining in the ring buffer
16783 + * 5 -- Clear ring buffer.
16784 + * 6 -- Disable printk's to console
16785 + * 7 -- Enable printk's to console
16786 + * 8 -- Set level of messages printed to console
16787 + * 9 -- Return number of unread characters in the log buffer
16788 + * 10 -- Return size of the log buffer
16790 +int vx_do_syslog(int type, char __user *buf, int len)
16793 + int do_clear = 0;
16794 + struct vx_info *vxi = current_vx_info();
16795 + struct _vx_syslog *log;
16799 + log = &vxi->cvirt.syslog;
16802 + case 0: /* Close log */
16803 + case 1: /* Open log */
16805 + case 2: /* Read from log */
16806 + error = wait_event_interruptible(log->log_wait,
16807 + (log->log_start - log->log_end));
16810 + spin_lock_irq(&log->logbuf_lock);
16811 + spin_unlock_irq(&log->logbuf_lock);
16813 + case 4: /* Read/clear last kernel messages */
16815 + /* fall through */
16816 + case 3: /* Read last kernel messages */
16819 + case 5: /* Clear ring buffer */
16822 + case 6: /* Disable logging to console */
16823 + case 7: /* Enable logging to console */
16824 + case 8: /* Set level of messages printed to console */
16827 + case 9: /* Number of chars in the log buffer */
16829 + case 10: /* Size of the log buffer */
16839 +/* virtual host info names */
16841 +static char *vx_vhi_name(struct vx_info *vxi, int id)
16843 + struct nsproxy *nsproxy;
16844 + struct uts_namespace *uts;
16846 + if (id == VHIN_CONTEXT)
16847 + return vxi->vx_name;
16849 + nsproxy = vxi->space[0].vx_nsproxy;
16853 + uts = nsproxy->uts_ns;
16858 + case VHIN_SYSNAME:
16859 + return uts->name.sysname;
16860 + case VHIN_NODENAME:
16861 + return uts->name.nodename;
16862 + case VHIN_RELEASE:
16863 + return uts->name.release;
16864 + case VHIN_VERSION:
16865 + return uts->name.version;
16866 + case VHIN_MACHINE:
16867 + return uts->name.machine;
16868 + case VHIN_DOMAINNAME:
16869 + return uts->name.domainname;
16876 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
16878 + struct vcmd_vhi_name_v0 vc_data;
16881 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16884 + name = vx_vhi_name(vxi, vc_data.field);
16888 + memcpy(name, vc_data.name, 65);
16892 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
16894 + struct vcmd_vhi_name_v0 vc_data;
16897 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16900 + name = vx_vhi_name(vxi, vc_data.field);
16904 + memcpy(vc_data.name, name, 65);
16905 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16911 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
16913 + struct vcmd_virt_stat_v0 vc_data;
16914 + struct _vx_cvirt *cvirt = &vxi->cvirt;
16915 + struct timespec uptime;
16917 + do_posix_clock_monotonic_gettime(&uptime);
16918 + set_normalized_timespec(&uptime,
16919 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
16920 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
16922 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
16923 + vc_data.uptime = timespec_to_ns(&uptime);
16924 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
16925 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
16926 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
16927 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
16928 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
16929 + vc_data.load[0] = cvirt->load[0];
16930 + vc_data.load[1] = cvirt->load[1];
16931 + vc_data.load[2] = cvirt->load[2];
16933 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16939 +#ifdef CONFIG_VSERVER_VTIME
16941 +/* virtualized time base */
16943 +void vx_adjust_timespec(struct timespec *ts)
16945 + struct vx_info *vxi;
16947 + if (!vx_flags(VXF_VIRT_TIME, 0))
16950 + vxi = current_vx_info();
16951 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
16952 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
16954 + if (ts->tv_nsec >= NSEC_PER_SEC) {
16956 + ts->tv_nsec -= NSEC_PER_SEC;
16957 + } else if (ts->tv_nsec < 0) {
16959 + ts->tv_nsec += NSEC_PER_SEC;
16963 +int vx_settimeofday(const struct timespec *ts)
16965 + struct timespec ats, delta;
16966 + struct vx_info *vxi;
16968 + if (!vx_flags(VXF_VIRT_TIME, 0))
16969 + return do_settimeofday(ts);
16971 + getnstimeofday(&ats);
16972 + delta = timespec_sub(*ts, ats);
16974 + vxi = current_vx_info();
16975 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
16981 diff -NurpP --minimal linux-3.9.5/kernel/vserver/cvirt_init.h linux-3.9.5-vs2.3.6.5/kernel/vserver/cvirt_init.h
16982 --- linux-3.9.5/kernel/vserver/cvirt_init.h 1970-01-01 00:00:00.000000000 +0000
16983 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/cvirt_init.h 2013-05-31 14:47:11.000000000 +0000
16987 +extern uint64_t vx_idle_jiffies(void);
16989 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
16991 + uint64_t idle_jiffies = vx_idle_jiffies();
16992 + uint64_t nsuptime;
16994 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
16995 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
16996 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
16997 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
16998 + cvirt->bias_ts.tv_sec = 0;
16999 + cvirt->bias_ts.tv_nsec = 0;
17001 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17002 + atomic_set(&cvirt->nr_threads, 0);
17003 + atomic_set(&cvirt->nr_running, 0);
17004 + atomic_set(&cvirt->nr_uninterruptible, 0);
17005 + atomic_set(&cvirt->nr_onhold, 0);
17007 + spin_lock_init(&cvirt->load_lock);
17008 + cvirt->load_last = jiffies;
17009 + atomic_set(&cvirt->load_updates, 0);
17010 + cvirt->load[0] = 0;
17011 + cvirt->load[1] = 0;
17012 + cvirt->load[2] = 0;
17013 + atomic_set(&cvirt->total_forks, 0);
17015 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17016 + init_waitqueue_head(&cvirt->syslog.log_wait);
17017 + cvirt->syslog.log_start = 0;
17018 + cvirt->syslog.log_end = 0;
17019 + cvirt->syslog.con_start = 0;
17020 + cvirt->syslog.logged_chars = 0;
17024 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17026 + // cvirt_pc->cpustat = { 0 };
17029 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17031 +#ifdef CONFIG_VSERVER_WARN
17034 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17035 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17037 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17038 + "!!! cvirt: %p[nr_running] = %d on exit.",
17040 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17041 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17043 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17044 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17050 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17055 diff -NurpP --minimal linux-3.9.5/kernel/vserver/cvirt_proc.h linux-3.9.5-vs2.3.6.5/kernel/vserver/cvirt_proc.h
17056 --- linux-3.9.5/kernel/vserver/cvirt_proc.h 1970-01-01 00:00:00.000000000 +0000
17057 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/cvirt_proc.h 2013-05-31 19:38:26.000000000 +0000
17059 +#ifndef _VX_CVIRT_PROC_H
17060 +#define _VX_CVIRT_PROC_H
17062 +#include <linux/nsproxy.h>
17063 +#include <linux/mnt_namespace.h>
17064 +#include <linux/ipc_namespace.h>
17065 +#include <linux/utsname.h>
17066 +#include <linux/ipc.h>
17068 +extern int vx_info_mnt_namespace(struct mnt_namespace *, char *);
17071 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17073 + struct mnt_namespace *ns;
17074 + struct uts_namespace *uts;
17075 + struct ipc_namespace *ipc;
17081 + length += sprintf(buffer + length,
17082 + "NSProxy:\t%p [%p,%p,%p]\n",
17083 + nsproxy, nsproxy->mnt_ns,
17084 + nsproxy->uts_ns, nsproxy->ipc_ns);
17086 + ns = nsproxy->mnt_ns;
17090 + length += vx_info_mnt_namespace(ns, buffer + length);
17094 + uts = nsproxy->uts_ns;
17098 + length += sprintf(buffer + length,
17099 + "SysName:\t%.*s\n"
17100 + "NodeName:\t%.*s\n"
17101 + "Release:\t%.*s\n"
17102 + "Version:\t%.*s\n"
17103 + "Machine:\t%.*s\n"
17104 + "DomainName:\t%.*s\n",
17105 + __NEW_UTS_LEN, uts->name.sysname,
17106 + __NEW_UTS_LEN, uts->name.nodename,
17107 + __NEW_UTS_LEN, uts->name.release,
17108 + __NEW_UTS_LEN, uts->name.version,
17109 + __NEW_UTS_LEN, uts->name.machine,
17110 + __NEW_UTS_LEN, uts->name.domainname);
17113 + ipc = nsproxy->ipc_ns;
17117 + length += sprintf(buffer + length,
17118 + "SEMS:\t\t%d %d %d %d %d\n"
17119 + "MSG:\t\t%d %d %d\n"
17120 + "SHM:\t\t%lu %lu %d %ld\n",
17121 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17122 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17124 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17125 + (unsigned long)ipc->shm_ctlmax,
17126 + (unsigned long)ipc->shm_ctlall,
17127 + ipc->shm_ctlmni, ipc->shm_tot);
17134 +#include <linux/sched.h>
17136 +#define LOAD_INT(x) ((x) >> FSHIFT)
17137 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17140 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17145 + length += sprintf(buffer + length,
17146 + "BiasUptime:\t%lu.%02lu\n",
17147 + (unsigned long)cvirt->bias_uptime.tv_sec,
17148 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17150 + a = cvirt->load[0] + (FIXED_1 / 200);
17151 + b = cvirt->load[1] + (FIXED_1 / 200);
17152 + c = cvirt->load[2] + (FIXED_1 / 200);
17153 + length += sprintf(buffer + length,
17154 + "nr_threads:\t%d\n"
17155 + "nr_running:\t%d\n"
17156 + "nr_unintr:\t%d\n"
17157 + "nr_onhold:\t%d\n"
17158 + "load_updates:\t%d\n"
17159 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17160 + "total_forks:\t%d\n",
17161 + atomic_read(&cvirt->nr_threads),
17162 + atomic_read(&cvirt->nr_running),
17163 + atomic_read(&cvirt->nr_uninterruptible),
17164 + atomic_read(&cvirt->nr_onhold),
17165 + atomic_read(&cvirt->load_updates),
17166 + LOAD_INT(a), LOAD_FRAC(a),
17167 + LOAD_INT(b), LOAD_FRAC(b),
17168 + LOAD_INT(c), LOAD_FRAC(c),
17169 + atomic_read(&cvirt->total_forks));
17174 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17175 + char *buffer, int cpu)
17181 +#endif /* _VX_CVIRT_PROC_H */
17182 diff -NurpP --minimal linux-3.9.5/kernel/vserver/debug.c linux-3.9.5-vs2.3.6.5/kernel/vserver/debug.c
17183 --- linux-3.9.5/kernel/vserver/debug.c 1970-01-01 00:00:00.000000000 +0000
17184 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/debug.c 2013-05-31 14:47:11.000000000 +0000
17187 + * kernel/vserver/debug.c
17189 + * Copyright (C) 2005-2007 Herbert Pötzl
17191 + * V0.01 vx_info dump support
17195 +#include <linux/module.h>
17197 +#include <linux/vserver/context.h>
17200 +void dump_vx_info(struct vx_info *vxi, int level)
17202 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17203 + atomic_read(&vxi->vx_usecnt),
17204 + atomic_read(&vxi->vx_tasks),
17207 + __dump_vx_limit(&vxi->limit);
17208 + __dump_vx_sched(&vxi->sched);
17209 + __dump_vx_cvirt(&vxi->cvirt);
17210 + __dump_vx_cacct(&vxi->cacct);
17216 +EXPORT_SYMBOL_GPL(dump_vx_info);
17218 diff -NurpP --minimal linux-3.9.5/kernel/vserver/device.c linux-3.9.5-vs2.3.6.5/kernel/vserver/device.c
17219 --- linux-3.9.5/kernel/vserver/device.c 1970-01-01 00:00:00.000000000 +0000
17220 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/device.c 2013-06-12 23:49:09.000000000 +0000
17223 + * linux/kernel/vserver/device.c
17225 + * Linux-VServer: Device Support
17227 + * Copyright (C) 2006 Herbert Pötzl
17228 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17230 + * V0.01 device mapping basics
17231 + * V0.02 added defaults
17235 +#include <linux/slab.h>
17236 +#include <linux/rcupdate.h>
17237 +#include <linux/fs.h>
17238 +#include <linux/namei.h>
17239 +#include <linux/hash.h>
17241 +#include <asm/errno.h>
17242 +#include <asm/uaccess.h>
17243 +#include <linux/vserver/base.h>
17244 +#include <linux/vserver/debug.h>
17245 +#include <linux/vserver/context.h>
17246 +#include <linux/vserver/device.h>
17247 +#include <linux/vserver/device_cmd.h>
17250 +#define DMAP_HASH_BITS 4
17253 +struct vs_mapping {
17255 + struct hlist_node hlist;
17256 + struct list_head list;
17258 +#define dm_hlist u.hlist
17259 +#define dm_list u.list
17262 + struct vx_dmap_target target;
17266 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17268 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17270 +static struct vx_dmap_target dmap_defaults[2] = {
17271 + { .flags = DATTR_OPEN },
17272 + { .flags = DATTR_OPEN },
17276 +struct kmem_cache *dmap_cachep __read_mostly;
17278 +int __init dmap_cache_init(void)
17280 + dmap_cachep = kmem_cache_create("dmap_cache",
17281 + sizeof(struct vs_mapping), 0,
17282 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17286 +__initcall(dmap_cache_init);
17289 +static inline unsigned int __hashval(dev_t dev, int bits)
17291 + return hash_long((unsigned long)dev, bits);
17295 +/* __hash_mapping()
17296 + * add the mapping to the hash table
17298 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17300 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17301 + struct hlist_head *head, *hash = dmap_main_hash;
17302 + int device = vdm->device;
17304 + spin_lock(hash_lock);
17305 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17306 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17308 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17309 + hlist_add_head(&vdm->dm_hlist, head);
17310 + spin_unlock(hash_lock);
17314 +static inline int __mode_to_default(umode_t mode)
17327 +/* __set_default()
17330 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17331 + struct vx_dmap_target *vdmt)
17333 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17334 + spin_lock(hash_lock);
17337 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17339 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17342 + spin_unlock(hash_lock);
17344 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17345 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17349 +/* __remove_default()
17350 + * remove a default
17352 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17354 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17355 + spin_lock(hash_lock);
17358 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17359 + else /* remove == reset */
17360 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17362 + spin_unlock(hash_lock);
17367 +/* __find_mapping()
17368 + * find a mapping in the hash table
17370 + * caller must hold hash_lock
17372 +static inline int __find_mapping(vxid_t xid, dev_t device, umode_t mode,
17373 + struct vs_mapping **local, struct vs_mapping **global)
17375 + struct hlist_head *hash = dmap_main_hash;
17376 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17377 + struct hlist_node *pos;
17378 + struct vs_mapping *vdm;
17384 + hlist_for_each(pos, head) {
17385 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17387 + if ((vdm->device == device) &&
17388 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17389 + if (vdm->xid == xid) {
17392 + } else if (global && vdm->xid == 0)
17397 + if (global && *global)
17404 +/* __lookup_mapping()
17405 + * find a mapping and store the result in target and flags
17407 +static inline int __lookup_mapping(struct vx_info *vxi,
17408 + dev_t device, dev_t *target, int *flags, umode_t mode)
17410 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17411 + struct vs_mapping *vdm, *global;
17412 + struct vx_dmap_target *vdmt;
17414 + vxid_t xid = vxi->vx_id;
17417 + spin_lock(hash_lock);
17418 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17420 + vdmt = &vdm->target;
17424 + index = __mode_to_default(mode);
17425 + if (vxi && vxi->dmap.targets[index].flags) {
17427 + vdmt = &vxi->dmap.targets[index];
17428 + } else if (global) {
17430 + vdmt = &global->target;
17434 + vdmt = &dmap_defaults[index];
17438 + if (target && (vdmt->flags & DATTR_REMAP))
17439 + *target = vdmt->target;
17441 + *target = device;
17443 + *flags = vdmt->flags;
17445 + spin_unlock(hash_lock);
17451 +/* __remove_mapping()
17452 + * remove a mapping from the hash table
17454 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17457 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17458 + struct vs_mapping *vdm = NULL;
17461 + spin_lock(hash_lock);
17463 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17465 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
17466 + vxi, vxi ? vxi->vx_id : 0, device, mode);
17469 + hlist_del(&vdm->dm_hlist);
17472 + spin_unlock(hash_lock);
17474 + kmem_cache_free(dmap_cachep, vdm);
17480 +int vs_map_device(struct vx_info *vxi,
17481 + dev_t device, dev_t *target, umode_t mode)
17483 + int ret, flags = DATTR_MASK;
17487 + *target = device;
17490 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
17491 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
17492 + device, target ? *target : 0, flags, mode, ret);
17494 + return (flags & DATTR_MASK);
17499 +static int do_set_mapping(struct vx_info *vxi,
17500 + dev_t device, dev_t target, int flags, umode_t mode)
17503 + struct vs_mapping *new;
17505 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
17509 + INIT_HLIST_NODE(&new->dm_hlist);
17510 + new->device = device;
17511 + new->target.target = target;
17512 + new->target.flags = flags | mode;
17513 + new->xid = (vxi ? vxi->vx_id : 0);
17515 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
17516 + __hash_mapping(vxi, new);
17518 + struct vx_dmap_target new = {
17519 + .target = target,
17520 + .flags = flags | mode,
17522 + __set_default(vxi, mode, &new);
17528 +static int do_unset_mapping(struct vx_info *vxi,
17529 + dev_t device, dev_t target, int flags, umode_t mode)
17531 + int ret = -EINVAL;
17534 + ret = __remove_mapping(vxi, device, mode);
17538 + ret = __remove_default(vxi, mode);
17548 +static inline int __user_device(const char __user *name, dev_t *dev,
17551 + struct nameidata nd;
17558 + ret = user_lpath(name, &nd.path);
17561 + if (nd.path.dentry->d_inode) {
17562 + *dev = nd.path.dentry->d_inode->i_rdev;
17563 + *mode = nd.path.dentry->d_inode->i_mode;
17565 + path_put(&nd.path);
17569 +static inline int __mapping_mode(dev_t device, dev_t target,
17570 + umode_t device_mode, umode_t target_mode, umode_t *mode)
17573 + *mode = device_mode & S_IFMT;
17575 + *mode = target_mode & S_IFMT;
17579 + /* if both given, device and target mode have to match */
17580 + if (device && target &&
17581 + ((device_mode ^ target_mode) & S_IFMT))
17587 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
17588 + const char __user *target_path, int flags, int set)
17590 + dev_t device = ~0, target = ~0;
17591 + umode_t device_mode = 0, target_mode = 0, mode;
17594 + ret = __user_device(device_path, &device, &device_mode);
17597 + ret = __user_device(target_path, &target, &target_mode);
17601 + ret = __mapping_mode(device, target,
17602 + device_mode, target_mode, &mode);
17607 + return do_set_mapping(vxi, device, target,
17610 + return do_unset_mapping(vxi, device, target,
17615 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
17617 + struct vcmd_set_mapping_v0 vc_data;
17619 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17622 + return do_mapping(vxi, vc_data.device, vc_data.target,
17623 + vc_data.flags, 1);
17626 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
17628 + struct vcmd_set_mapping_v0 vc_data;
17630 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17633 + return do_mapping(vxi, vc_data.device, vc_data.target,
17634 + vc_data.flags, 0);
17638 +#ifdef CONFIG_COMPAT
17640 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
17642 + struct vcmd_set_mapping_v0_x32 vc_data;
17644 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17647 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17648 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
17651 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
17653 + struct vcmd_set_mapping_v0_x32 vc_data;
17655 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17658 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17659 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
17662 +#endif /* CONFIG_COMPAT */
17665 diff -NurpP --minimal linux-3.9.5/kernel/vserver/dlimit.c linux-3.9.5-vs2.3.6.5/kernel/vserver/dlimit.c
17666 --- linux-3.9.5/kernel/vserver/dlimit.c 1970-01-01 00:00:00.000000000 +0000
17667 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/dlimit.c 2013-06-12 23:49:09.000000000 +0000
17670 + * linux/kernel/vserver/dlimit.c
17672 + * Virtual Server: Context Disk Limits
17674 + * Copyright (C) 2004-2009 Herbert Pötzl
17676 + * V0.01 initial version
17677 + * V0.02 compat32 splitup
17678 + * V0.03 extended interface
17682 +#include <linux/statfs.h>
17683 +#include <linux/sched.h>
17684 +#include <linux/namei.h>
17685 +#include <linux/vs_tag.h>
17686 +#include <linux/vs_dlimit.h>
17687 +#include <linux/vserver/dlimit_cmd.h>
17688 +#include <linux/slab.h>
17689 +// #include <linux/gfp.h>
17691 +#include <asm/uaccess.h>
17693 +/* __alloc_dl_info()
17695 + * allocate an initialized dl_info struct
17696 + * doesn't make it visible (hash) */
17698 +static struct dl_info *__alloc_dl_info(struct super_block *sb, vtag_t tag)
17700 + struct dl_info *new = NULL;
17702 + vxdprintk(VXD_CBIT(dlim, 5),
17703 + "alloc_dl_info(%p,%d)*", sb, tag);
17705 + /* would this benefit from a slab cache? */
17706 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
17710 + memset(new, 0, sizeof(struct dl_info));
17711 + new->dl_tag = tag;
17713 + // INIT_RCU_HEAD(&new->dl_rcu);
17714 + INIT_HLIST_NODE(&new->dl_hlist);
17715 + spin_lock_init(&new->dl_lock);
17716 + atomic_set(&new->dl_refcnt, 0);
17717 + atomic_set(&new->dl_usecnt, 0);
17719 + /* rest of init goes here */
17721 + vxdprintk(VXD_CBIT(dlim, 4),
17722 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
17726 +/* __dealloc_dl_info()
17728 + * final disposal of dl_info */
17730 +static void __dealloc_dl_info(struct dl_info *dli)
17732 + vxdprintk(VXD_CBIT(dlim, 4),
17733 + "dealloc_dl_info(%p)", dli);
17735 + dli->dl_hlist.next = LIST_POISON1;
17736 + dli->dl_tag = -1;
17739 + BUG_ON(atomic_read(&dli->dl_usecnt));
17740 + BUG_ON(atomic_read(&dli->dl_refcnt));
17746 +/* hash table for dl_info hash */
17748 +#define DL_HASH_SIZE 13
17750 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
17752 +static DEFINE_SPINLOCK(dl_info_hash_lock);
17755 +static inline unsigned int __hashval(struct super_block *sb, vtag_t tag)
17757 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
17762 +/* __hash_dl_info()
17764 + * add the dli to the global hash table
17765 + * requires the hash_lock to be held */
17767 +static inline void __hash_dl_info(struct dl_info *dli)
17769 + struct hlist_head *head;
17771 + vxdprintk(VXD_CBIT(dlim, 6),
17772 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
17773 + get_dl_info(dli);
17774 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
17775 + hlist_add_head_rcu(&dli->dl_hlist, head);
17778 +/* __unhash_dl_info()
17780 + * remove the dli from the global hash table
17781 + * requires the hash_lock to be held */
17783 +static inline void __unhash_dl_info(struct dl_info *dli)
17785 + vxdprintk(VXD_CBIT(dlim, 6),
17786 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
17787 + hlist_del_rcu(&dli->dl_hlist);
17788 + put_dl_info(dli);
17792 +/* __lookup_dl_info()
17794 + * requires the rcu_read_lock()
17795 + * doesn't increment the dl_refcnt */
17797 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, vtag_t tag)
17799 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
17800 + struct dl_info *dli;
17802 + hlist_for_each_entry_rcu(dli, head, dl_hlist) {
17803 + if (dli->dl_tag == tag && dli->dl_sb == sb)
17810 +struct dl_info *locate_dl_info(struct super_block *sb, vtag_t tag)
17812 + struct dl_info *dli;
17815 + dli = get_dl_info(__lookup_dl_info(sb, tag));
17816 + vxdprintk(VXD_CBIT(dlim, 7),
17817 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
17818 + rcu_read_unlock();
17822 +void rcu_free_dl_info(struct rcu_head *head)
17824 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
17825 + int usecnt, refcnt;
17827 + BUG_ON(!dli || !head);
17829 + usecnt = atomic_read(&dli->dl_usecnt);
17830 + BUG_ON(usecnt < 0);
17832 + refcnt = atomic_read(&dli->dl_refcnt);
17833 + BUG_ON(refcnt < 0);
17835 + vxdprintk(VXD_CBIT(dlim, 3),
17836 + "rcu_free_dl_info(%p)", dli);
17838 + __dealloc_dl_info(dli);
17840 + printk("!!! rcu didn't free\n");
17846 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
17847 + uint32_t flags, int add)
17849 + struct path path;
17852 + ret = user_lpath(name, &path);
17854 + struct super_block *sb;
17855 + struct dl_info *dli;
17858 + if (!path.dentry->d_inode)
17859 + goto out_release;
17860 + if (!(sb = path.dentry->d_inode->i_sb))
17861 + goto out_release;
17864 + dli = __alloc_dl_info(sb, id);
17865 + spin_lock(&dl_info_hash_lock);
17868 + if (__lookup_dl_info(sb, id))
17870 + __hash_dl_info(dli);
17873 + spin_lock(&dl_info_hash_lock);
17874 + dli = __lookup_dl_info(sb, id);
17879 + __unhash_dl_info(dli);
17883 + spin_unlock(&dl_info_hash_lock);
17885 + __dealloc_dl_info(dli);
17892 +int vc_add_dlimit(uint32_t id, void __user *data)
17894 + struct vcmd_ctx_dlimit_base_v0 vc_data;
17896 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17899 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
17902 +int vc_rem_dlimit(uint32_t id, void __user *data)
17904 + struct vcmd_ctx_dlimit_base_v0 vc_data;
17906 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17909 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
17912 +#ifdef CONFIG_COMPAT
17914 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
17916 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
17918 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17921 + return do_addrem_dlimit(id,
17922 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
17925 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
17927 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
17929 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17932 + return do_addrem_dlimit(id,
17933 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
17936 +#endif /* CONFIG_COMPAT */
17940 +int do_set_dlimit(uint32_t id, const char __user *name,
17941 + uint32_t space_used, uint32_t space_total,
17942 + uint32_t inodes_used, uint32_t inodes_total,
17943 + uint32_t reserved, uint32_t flags)
17945 + struct path path;
17948 + ret = user_lpath(name, &path);
17950 + struct super_block *sb;
17951 + struct dl_info *dli;
17954 + if (!path.dentry->d_inode)
17955 + goto out_release;
17956 + if (!(sb = path.dentry->d_inode->i_sb))
17957 + goto out_release;
17959 + /* sanity checks */
17960 + if ((reserved != CDLIM_KEEP &&
17961 + reserved > 100) ||
17962 + (inodes_used != CDLIM_KEEP &&
17963 + inodes_used > inodes_total) ||
17964 + (space_used != CDLIM_KEEP &&
17965 + space_used > space_total))
17966 + goto out_release;
17969 + dli = locate_dl_info(sb, id);
17971 + goto out_release;
17973 + spin_lock(&dli->dl_lock);
17975 + if (inodes_used != CDLIM_KEEP)
17976 + dli->dl_inodes_used = inodes_used;
17977 + if (inodes_total != CDLIM_KEEP)
17978 + dli->dl_inodes_total = inodes_total;
17979 + if (space_used != CDLIM_KEEP)
17980 + dli->dl_space_used = dlimit_space_32to64(
17981 + space_used, flags, DLIMS_USED);
17983 + if (space_total == CDLIM_INFINITY)
17984 + dli->dl_space_total = DLIM_INFINITY;
17985 + else if (space_total != CDLIM_KEEP)
17986 + dli->dl_space_total = dlimit_space_32to64(
17987 + space_total, flags, DLIMS_TOTAL);
17989 + if (reserved != CDLIM_KEEP)
17990 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
17992 + spin_unlock(&dli->dl_lock);
17994 + put_dl_info(dli);
18003 +int vc_set_dlimit(uint32_t id, void __user *data)
18005 + struct vcmd_ctx_dlimit_v0 vc_data;
18007 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18010 + return do_set_dlimit(id, vc_data.name,
18011 + vc_data.space_used, vc_data.space_total,
18012 + vc_data.inodes_used, vc_data.inodes_total,
18013 + vc_data.reserved, vc_data.flags);
18016 +#ifdef CONFIG_COMPAT
18018 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18020 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18022 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18025 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18026 + vc_data.space_used, vc_data.space_total,
18027 + vc_data.inodes_used, vc_data.inodes_total,
18028 + vc_data.reserved, vc_data.flags);
18031 +#endif /* CONFIG_COMPAT */
18035 +int do_get_dlimit(uint32_t id, const char __user *name,
18036 + uint32_t *space_used, uint32_t *space_total,
18037 + uint32_t *inodes_used, uint32_t *inodes_total,
18038 + uint32_t *reserved, uint32_t *flags)
18040 + struct path path;
18043 + ret = user_lpath(name, &path);
18045 + struct super_block *sb;
18046 + struct dl_info *dli;
18049 + if (!path.dentry->d_inode)
18050 + goto out_release;
18051 + if (!(sb = path.dentry->d_inode->i_sb))
18052 + goto out_release;
18055 + dli = locate_dl_info(sb, id);
18057 + goto out_release;
18059 + spin_lock(&dli->dl_lock);
18060 + *inodes_used = dli->dl_inodes_used;
18061 + *inodes_total = dli->dl_inodes_total;
18063 + *space_used = dlimit_space_64to32(
18064 + dli->dl_space_used, flags, DLIMS_USED);
18066 + if (dli->dl_space_total == DLIM_INFINITY)
18067 + *space_total = CDLIM_INFINITY;
18069 + *space_total = dlimit_space_64to32(
18070 + dli->dl_space_total, flags, DLIMS_TOTAL);
18072 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18073 + spin_unlock(&dli->dl_lock);
18075 + put_dl_info(dli);
18086 +int vc_get_dlimit(uint32_t id, void __user *data)
18088 + struct vcmd_ctx_dlimit_v0 vc_data;
18091 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18094 + ret = do_get_dlimit(id, vc_data.name,
18095 + &vc_data.space_used, &vc_data.space_total,
18096 + &vc_data.inodes_used, &vc_data.inodes_total,
18097 + &vc_data.reserved, &vc_data.flags);
18101 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18106 +#ifdef CONFIG_COMPAT
18108 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18110 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18113 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18116 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18117 + &vc_data.space_used, &vc_data.space_total,
18118 + &vc_data.inodes_used, &vc_data.inodes_total,
18119 + &vc_data.reserved, &vc_data.flags);
18123 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18128 +#endif /* CONFIG_COMPAT */
18131 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18133 + struct dl_info *dli;
18134 + __u64 blimit, bfree, bavail;
18137 + dli = locate_dl_info(sb, dx_current_tag());
18141 + spin_lock(&dli->dl_lock);
18142 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18145 + /* reduce max inodes available to limit */
18146 + if (buf->f_files > dli->dl_inodes_total)
18147 + buf->f_files = dli->dl_inodes_total;
18149 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18150 + /* reduce free inodes to min */
18151 + if (ifree < buf->f_ffree)
18152 + buf->f_ffree = ifree;
18155 + if (dli->dl_space_total == DLIM_INFINITY)
18158 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18160 + if (dli->dl_space_total < dli->dl_space_used)
18163 + bfree = (dli->dl_space_total - dli->dl_space_used)
18164 + >> sb->s_blocksize_bits;
18166 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18167 + if (bavail < dli->dl_space_used)
18170 + bavail = (bavail - dli->dl_space_used)
18171 + >> sb->s_blocksize_bits;
18173 + /* reduce max space available to limit */
18174 + if (buf->f_blocks > blimit)
18175 + buf->f_blocks = blimit;
18177 + /* reduce free space to min */
18178 + if (bfree < buf->f_bfree)
18179 + buf->f_bfree = bfree;
18181 + /* reduce avail space to min */
18182 + if (bavail < buf->f_bavail)
18183 + buf->f_bavail = bavail;
18186 + spin_unlock(&dli->dl_lock);
18187 + put_dl_info(dli);
18192 +#include <linux/module.h>
18194 +EXPORT_SYMBOL_GPL(locate_dl_info);
18195 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18197 diff -NurpP --minimal linux-3.9.5/kernel/vserver/helper.c linux-3.9.5-vs2.3.6.5/kernel/vserver/helper.c
18198 --- linux-3.9.5/kernel/vserver/helper.c 1970-01-01 00:00:00.000000000 +0000
18199 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/helper.c 2013-06-01 08:27:59.000000000 +0000
18202 + * linux/kernel/vserver/helper.c
18204 + * Virtual Context Support
18206 + * Copyright (C) 2004-2007 Herbert Pötzl
18208 + * V0.01 basic helper
18212 +#include <linux/kmod.h>
18213 +#include <linux/reboot.h>
18214 +#include <linux/vs_context.h>
18215 +#include <linux/vs_network.h>
18216 +#include <linux/vserver/signal.h>
18219 +char vshelper_path[255] = "/sbin/vshelper";
18221 +static int vshelper_init(struct subprocess_info *info, struct cred *new_cred)
18223 + current->flags &= ~PF_THREAD_BOUND;
18227 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18231 + if ((ret = call_usermodehelper_fns(name, argv, envp,
18232 + sync ? UMH_WAIT_PROC : UMH_WAIT_EXEC,
18233 + vshelper_init, NULL, NULL))) {
18234 + printk(KERN_WARNING "%s: (%s %s) returned %s with %d\n",
18235 + name, argv[1], argv[2],
18236 + sync ? "sync" : "async", ret);
18238 + vxdprintk(VXD_CBIT(switch, 4),
18239 + "%s: (%s %s) returned %s with %d",
18240 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18245 + * vshelper path is set via /proc/sys
18246 + * invoked by vserver sys_reboot(), with
18247 + * the following arguments
18249 + * argv [0] = vshelper_path;
18250 + * argv [1] = action: "restart", "halt", "poweroff", ...
18251 + * argv [2] = context identifier
18253 + * envp [*] = type-specific parameters
18256 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18258 + char id_buf[8], cmd_buf[16];
18259 + char uid_buf[16], pid_buf[16];
18262 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18263 + char *envp[] = {"HOME=/", "TERM=linux",
18264 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18265 + uid_buf, pid_buf, cmd_buf, 0};
18267 + if (vx_info_state(vxi, VXS_HELPER))
18269 + vxi->vx_state |= VXS_HELPER;
18271 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18273 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18274 + snprintf(uid_buf, sizeof(uid_buf), "VS_UID=%d",
18275 + from_kuid(&init_user_ns, current_uid()));
18276 + snprintf(pid_buf, sizeof(pid_buf), "VS_PID=%d", current->pid);
18279 + case LINUX_REBOOT_CMD_RESTART:
18280 + argv[1] = "restart";
18283 + case LINUX_REBOOT_CMD_HALT:
18284 + argv[1] = "halt";
18287 + case LINUX_REBOOT_CMD_POWER_OFF:
18288 + argv[1] = "poweroff";
18291 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18292 + argv[1] = "swsusp";
18295 + case LINUX_REBOOT_CMD_OOM:
18300 + vxi->vx_state &= ~VXS_HELPER;
18304 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18305 + vxi->vx_state &= ~VXS_HELPER;
18306 + __wakeup_vx_info(vxi);
18307 + return (ret) ? -EPERM : 0;
18311 +long vs_reboot(unsigned int cmd, void __user *arg)
18313 + struct vx_info *vxi = current_vx_info();
18316 + vxdprintk(VXD_CBIT(misc, 5),
18317 + "vs_reboot(%p[#%d],%u)",
18318 + vxi, vxi ? vxi->vx_id : 0, cmd);
18320 + ret = vs_reboot_helper(vxi, cmd, arg);
18324 + vxi->reboot_cmd = cmd;
18325 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18327 + case LINUX_REBOOT_CMD_RESTART:
18328 + case LINUX_REBOOT_CMD_HALT:
18329 + case LINUX_REBOOT_CMD_POWER_OFF:
18330 + vx_info_kill(vxi, 0, SIGKILL);
18331 + vx_info_kill(vxi, 1, SIGKILL);
18339 +long vs_oom_action(unsigned int cmd)
18341 + struct vx_info *vxi = current_vx_info();
18344 + vxdprintk(VXD_CBIT(misc, 5),
18345 + "vs_oom_action(%p[#%d],%u)",
18346 + vxi, vxi ? vxi->vx_id : 0, cmd);
18348 + ret = vs_reboot_helper(vxi, cmd, NULL);
18352 + vxi->reboot_cmd = cmd;
18353 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18354 + vx_info_kill(vxi, 0, SIGKILL);
18355 + vx_info_kill(vxi, 1, SIGKILL);
18361 + * argv [0] = vshelper_path;
18362 + * argv [1] = action: "startup", "shutdown"
18363 + * argv [2] = context identifier
18365 + * envp [*] = type-specific parameters
18368 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18370 + char id_buf[8], cmd_buf[16];
18371 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18372 + char *envp[] = {"HOME=/", "TERM=linux",
18373 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18375 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18378 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18379 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18382 + case VSC_STARTUP:
18383 + argv[1] = "startup";
18385 + case VSC_SHUTDOWN:
18386 + argv[1] = "shutdown";
18392 + return do_vshelper(vshelper_path, argv, envp, 1);
18397 + * argv [0] = vshelper_path;
18398 + * argv [1] = action: "netup", "netdown"
18399 + * argv [2] = context identifier
18401 + * envp [*] = type-specific parameters
18404 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18406 + char id_buf[8], cmd_buf[16];
18407 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18408 + char *envp[] = {"HOME=/", "TERM=linux",
18409 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18411 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18414 + snprintf(id_buf, sizeof(id_buf), "%d", nxi->nx_id);
18415 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18419 + argv[1] = "netup";
18421 + case VSC_NETDOWN:
18422 + argv[1] = "netdown";
18428 + return do_vshelper(vshelper_path, argv, envp, 1);
18431 diff -NurpP --minimal linux-3.9.5/kernel/vserver/history.c linux-3.9.5-vs2.3.6.5/kernel/vserver/history.c
18432 --- linux-3.9.5/kernel/vserver/history.c 1970-01-01 00:00:00.000000000 +0000
18433 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/history.c 2013-05-31 14:47:11.000000000 +0000
18436 + * kernel/vserver/history.c
18438 + * Virtual Context History Backtrace
18440 + * Copyright (C) 2004-2007 Herbert Pötzl
18442 + * V0.01 basic structure
18443 + * V0.02 hash/unhash and trace
18444 + * V0.03 preemption fixes
18448 +#include <linux/module.h>
18449 +#include <asm/uaccess.h>
18451 +#include <linux/vserver/context.h>
18452 +#include <linux/vserver/debug.h>
18453 +#include <linux/vserver/debug_cmd.h>
18454 +#include <linux/vserver/history.h>
18457 +#ifdef CONFIG_VSERVER_HISTORY
18458 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18460 +#define VXH_SIZE 64
18463 +struct _vx_history {
18464 + unsigned int counter;
18466 + struct _vx_hist_entry entry[VXH_SIZE + 1];
18470 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
18472 +unsigned volatile int vxh_active = 1;
18474 +static atomic_t sequence = ATOMIC_INIT(0);
18479 + * requires disabled preemption */
18481 +struct _vx_hist_entry *vxh_advance(void *loc)
18483 + unsigned int cpu = smp_processor_id();
18484 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18485 + struct _vx_hist_entry *entry;
18486 + unsigned int index;
18488 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
18489 + entry = &hist->entry[index];
18491 + entry->seq = atomic_inc_return(&sequence);
18492 + entry->loc = loc;
18496 +EXPORT_SYMBOL_GPL(vxh_advance);
18499 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
18501 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
18504 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
18506 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
18507 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
18508 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
18509 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
18511 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
18513 + switch (e->type) {
18514 + case VXH_THROW_OOPS:
18515 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
18518 + case VXH_GET_VX_INFO:
18519 + case VXH_PUT_VX_INFO:
18520 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18522 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
18523 + VXH_VXI_ARGS(e));
18526 + case VXH_INIT_VX_INFO:
18527 + case VXH_SET_VX_INFO:
18528 + case VXH_CLR_VX_INFO:
18529 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18531 + (e->type == VXH_INIT_VX_INFO) ? "init" :
18532 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
18533 + VXH_VXI_ARGS(e), e->sc.data);
18536 + case VXH_CLAIM_VX_INFO:
18537 + case VXH_RELEASE_VX_INFO:
18538 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18540 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
18541 + VXH_VXI_ARGS(e), e->sc.data);
18544 + case VXH_ALLOC_VX_INFO:
18545 + case VXH_DEALLOC_VX_INFO:
18546 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18548 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
18549 + VXH_VXI_ARGS(e));
18552 + case VXH_HASH_VX_INFO:
18553 + case VXH_UNHASH_VX_INFO:
18554 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
18556 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
18557 + VXH_VXI_ARGS(e));
18560 + case VXH_LOC_VX_INFO:
18561 + case VXH_LOOKUP_VX_INFO:
18562 + case VXH_CREATE_VX_INFO:
18563 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
18565 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
18566 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
18567 + e->ll.arg, VXH_VXI_ARGS(e));
18572 +static void __vxh_dump_history(void)
18574 + unsigned int i, cpu;
18576 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
18577 + atomic_read(&sequence), NR_CPUS);
18579 + for (i = 0; i < VXH_SIZE; i++) {
18580 + for_each_online_cpu(cpu) {
18581 + struct _vx_history *hist =
18582 + &per_cpu(vx_history_buffer, cpu);
18583 + unsigned int index = (hist->counter - i) % VXH_SIZE;
18584 + struct _vx_hist_entry *entry = &hist->entry[index];
18586 + vxh_dump_entry(entry, cpu);
18591 +void vxh_dump_history(void)
18595 + local_irq_enable();
18597 + local_irq_disable();
18599 + __vxh_dump_history();
18603 +/* vserver syscall commands below here */
18606 +int vc_dump_history(uint32_t id)
18609 + __vxh_dump_history();
18616 +int do_read_history(struct __user _vx_hist_entry *data,
18617 + int cpu, uint32_t *index, uint32_t *count)
18619 + int pos, ret = 0;
18620 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18621 + int end = hist->counter;
18622 + int start = end - VXH_SIZE + 2;
18623 + int idx = *index;
18625 + /* special case: get current pos */
18631 + /* have we lost some data? */
18635 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
18636 + struct _vx_hist_entry *entry =
18637 + &hist->entry[idx % VXH_SIZE];
18639 + /* send entry to userspace */
18640 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
18644 + /* save new index and count */
18647 + return ret ? ret : (*index < end);
18650 +int vc_read_history(uint32_t id, void __user *data)
18652 + struct vcmd_read_history_v0 vc_data;
18655 + if (id >= NR_CPUS)
18658 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18661 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
18662 + id, &vc_data.index, &vc_data.count);
18664 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18669 +#ifdef CONFIG_COMPAT
18671 +int vc_read_history_x32(uint32_t id, void __user *data)
18673 + struct vcmd_read_history_v0_x32 vc_data;
18676 + if (id >= NR_CPUS)
18679 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18682 + ret = do_read_history((struct __user _vx_hist_entry *)
18683 + compat_ptr(vc_data.data_ptr),
18684 + id, &vc_data.index, &vc_data.count);
18686 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18691 +#endif /* CONFIG_COMPAT */
18693 diff -NurpP --minimal linux-3.9.5/kernel/vserver/inet.c linux-3.9.5-vs2.3.6.5/kernel/vserver/inet.c
18694 --- linux-3.9.5/kernel/vserver/inet.c 1970-01-01 00:00:00.000000000 +0000
18695 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/inet.c 2013-05-31 22:43:05.000000000 +0000
18698 +#include <linux/in.h>
18699 +#include <linux/inetdevice.h>
18700 +#include <linux/export.h>
18701 +#include <linux/vs_inet.h>
18702 +#include <linux/vs_inet6.h>
18703 +#include <linux/vserver/debug.h>
18704 +#include <net/route.h>
18705 +#include <net/addrconf.h>
18708 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
18712 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
18715 + struct nx_addr_v4 *ptr;
18716 + unsigned long irqflags;
18718 + spin_lock_irqsave(&nxi1->addr_lock, irqflags);
18719 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
18720 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
18725 + spin_unlock_irqrestore(&nxi1->addr_lock, irqflags);
18728 + vxdprintk(VXD_CBIT(net, 2),
18729 + "nx_v4_addr_conflict(%p,%p): %d",
18730 + nxi1, nxi2, ret);
18736 +#ifdef CONFIG_IPV6
18738 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
18742 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
18745 + struct nx_addr_v6 *ptr;
18746 + unsigned long irqflags;
18748 + spin_lock_irqsave(&nxi1->addr_lock, irqflags);
18749 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
18750 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
18755 + spin_unlock_irqrestore(&nxi1->addr_lock, irqflags);
18758 + vxdprintk(VXD_CBIT(net, 2),
18759 + "nx_v6_addr_conflict(%p,%p): %d",
18760 + nxi1, nxi2, ret);
18767 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18769 + struct in_device *in_dev;
18770 + struct in_ifaddr **ifap;
18771 + struct in_ifaddr *ifa;
18776 + in_dev = in_dev_get(dev);
18780 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
18781 + ifap = &ifa->ifa_next) {
18782 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
18787 + in_dev_put(in_dev);
18793 +#ifdef CONFIG_IPV6
18795 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18797 + struct inet6_dev *in_dev;
18798 + struct inet6_ifaddr *ifa;
18803 + in_dev = in6_dev_get(dev);
18807 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
18808 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
18809 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
18814 + in6_dev_put(in_dev);
18821 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18827 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
18829 +#ifdef CONFIG_IPV6
18831 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
18836 + vxdprintk(VXD_CBIT(net, 3),
18837 + "dev_in_nx_info(%p,%p[#%d]) = %d",
18838 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
18842 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
18843 + struct flowi4 *fl4)
18845 + struct rtable *rt;
18850 + /* FIXME: handle lback only case */
18851 + if (!NX_IPV4(nxi))
18852 + return ERR_PTR(-EPERM);
18854 + vxdprintk(VXD_CBIT(net, 4),
18855 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
18856 + nxi, nxi ? nxi->nx_id : 0,
18857 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
18859 + /* single IP is unconditional */
18860 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
18861 + (fl4->saddr == INADDR_ANY))
18862 + fl4->saddr = nxi->v4.ip[0].s_addr;
18864 + if (fl4->saddr == INADDR_ANY) {
18865 + struct nx_addr_v4 *ptr;
18866 + __be32 found = 0;
18868 + rt = __ip_route_output_key(net, fl4);
18869 + if (!IS_ERR(rt)) {
18870 + found = fl4->saddr;
18872 + vxdprintk(VXD_CBIT(net, 4),
18873 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
18874 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
18875 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
18879 + WARN_ON_ONCE(in_irq());
18880 + spin_lock_bh(&nxi->addr_lock);
18881 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
18882 + __be32 primary = ptr->ip[0].s_addr;
18883 + __be32 mask = ptr->mask.s_addr;
18884 + __be32 neta = primary & mask;
18886 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
18887 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
18888 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
18889 + NIPQUAD(mask), NIPQUAD(neta));
18890 + if ((found & mask) != neta)
18893 + fl4->saddr = primary;
18894 + rt = __ip_route_output_key(net, fl4);
18895 + vxdprintk(VXD_CBIT(net, 4),
18896 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
18897 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
18898 + if (!IS_ERR(rt)) {
18899 + found = fl4->saddr;
18901 + if (found == primary)
18902 + goto found_unlock;
18905 + /* still no source ip? */
18906 + found = ipv4_is_loopback(fl4->daddr)
18907 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
18909 + spin_unlock_bh(&nxi->addr_lock);
18911 + /* assign src ip to flow */
18912 + fl4->saddr = found;
18915 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
18916 + return ERR_PTR(-EPERM);
18919 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
18920 + if (ipv4_is_loopback(fl4->daddr))
18921 + fl4->daddr = nxi->v4_lback.s_addr;
18922 + if (ipv4_is_loopback(fl4->saddr))
18923 + fl4->saddr = nxi->v4_lback.s_addr;
18924 + } else if (ipv4_is_loopback(fl4->daddr) &&
18925 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
18926 + return ERR_PTR(-EPERM);
18931 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
18933 diff -NurpP --minimal linux-3.9.5/kernel/vserver/init.c linux-3.9.5-vs2.3.6.5/kernel/vserver/init.c
18934 --- linux-3.9.5/kernel/vserver/init.c 1970-01-01 00:00:00.000000000 +0000
18935 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/init.c 2013-05-31 14:47:11.000000000 +0000
18938 + * linux/kernel/init.c
18940 + * Virtual Server Init
18942 + * Copyright (C) 2004-2007 Herbert Pötzl
18944 + * V0.01 basic structure
18948 +#include <linux/init.h>
18950 +int vserver_register_sysctl(void);
18951 +void vserver_unregister_sysctl(void);
18954 +static int __init init_vserver(void)
18958 +#ifdef CONFIG_VSERVER_DEBUG
18959 + vserver_register_sysctl();
18965 +static void __exit exit_vserver(void)
18968 +#ifdef CONFIG_VSERVER_DEBUG
18969 + vserver_unregister_sysctl();
18974 +/* FIXME: GFP_ZONETYPES gone
18975 +long vx_slab[GFP_ZONETYPES]; */
18979 +module_init(init_vserver);
18980 +module_exit(exit_vserver);
18982 diff -NurpP --minimal linux-3.9.5/kernel/vserver/inode.c linux-3.9.5-vs2.3.6.5/kernel/vserver/inode.c
18983 --- linux-3.9.5/kernel/vserver/inode.c 1970-01-01 00:00:00.000000000 +0000
18984 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/inode.c 2013-06-12 23:49:09.000000000 +0000
18987 + * linux/kernel/vserver/inode.c
18989 + * Virtual Server: File System Support
18991 + * Copyright (C) 2004-2007 Herbert Pötzl
18993 + * V0.01 separated from vcontext V0.05
18994 + * V0.02 moved to tag (instead of xid)
18998 +#include <linux/tty.h>
18999 +#include <linux/proc_fs.h>
19000 +#include <linux/devpts_fs.h>
19001 +#include <linux/fs.h>
19002 +#include <linux/file.h>
19003 +#include <linux/mount.h>
19004 +#include <linux/parser.h>
19005 +#include <linux/namei.h>
19006 +#include <linux/vserver/inode.h>
19007 +#include <linux/vserver/inode_cmd.h>
19008 +#include <linux/vs_base.h>
19009 +#include <linux/vs_tag.h>
19011 +#include <asm/uaccess.h>
19014 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19016 + struct proc_dir_entry *entry;
19018 + if (!in || !in->i_sb)
19021 + *flags = IATTR_TAG
19022 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19023 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19024 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19025 + | (IS_COW(in) ? IATTR_COW : 0);
19026 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19028 + if (S_ISDIR(in->i_mode))
19029 + *mask |= IATTR_BARRIER;
19031 + if (IS_TAGGED(in)) {
19032 + *tag = i_tag_read(in);
19033 + *mask |= IATTR_TAG;
19036 + switch (in->i_sb->s_magic) {
19037 + case PROC_SUPER_MAGIC:
19038 + entry = PROC_I(in)->pde;
19040 + /* check for specific inodes? */
19042 + *mask |= IATTR_FLAGS;
19044 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19046 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19049 + case DEVPTS_SUPER_MAGIC:
19050 + *tag = i_tag_read(in);
19051 + *mask |= IATTR_TAG;
19060 +int vc_get_iattr(void __user *data)
19062 + struct path path;
19063 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19066 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19069 + ret = user_lpath(vc_data.name, &path);
19071 + ret = __vc_get_iattr(path.dentry->d_inode,
19072 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19078 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19083 +#ifdef CONFIG_COMPAT
19085 +int vc_get_iattr_x32(void __user *data)
19087 + struct path path;
19088 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19091 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19094 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19096 + ret = __vc_get_iattr(path.dentry->d_inode,
19097 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19103 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19108 +#endif /* CONFIG_COMPAT */
19111 +int vc_fget_iattr(uint32_t fd, void __user *data)
19113 + struct file *filp;
19114 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19117 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19121 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19124 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19125 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19129 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19135 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19137 + struct inode *in = de->d_inode;
19138 + int error = 0, is_proc = 0, has_tag = 0;
19139 + struct iattr attr = { 0 };
19141 + if (!in || !in->i_sb)
19144 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19145 + if ((*mask & IATTR_FLAGS) && !is_proc)
19148 + has_tag = IS_TAGGED(in) ||
19149 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19150 + if ((*mask & IATTR_TAG) && !has_tag)
19153 + mutex_lock(&in->i_mutex);
19154 + if (*mask & IATTR_TAG) {
19155 + attr.ia_tag = make_ktag(&init_user_ns, *tag);
19156 + attr.ia_valid |= ATTR_TAG;
19159 + if (*mask & IATTR_FLAGS) {
19160 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19161 + unsigned int iflags = PROC_I(in)->vx_flags;
19163 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19164 + | (*flags & IATTR_FLAGS);
19165 + PROC_I(in)->vx_flags = iflags;
19167 + entry->vx_flags = iflags;
19170 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19171 + IATTR_BARRIER | IATTR_COW)) {
19172 + int iflags = in->i_flags;
19173 + int vflags = in->i_vflags;
19175 + if (*mask & IATTR_IMMUTABLE) {
19176 + if (*flags & IATTR_IMMUTABLE)
19177 + iflags |= S_IMMUTABLE;
19179 + iflags &= ~S_IMMUTABLE;
19181 + if (*mask & IATTR_IXUNLINK) {
19182 + if (*flags & IATTR_IXUNLINK)
19183 + iflags |= S_IXUNLINK;
19185 + iflags &= ~S_IXUNLINK;
19187 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19188 + if (*flags & IATTR_BARRIER)
19189 + vflags |= V_BARRIER;
19191 + vflags &= ~V_BARRIER;
19193 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19194 + if (*flags & IATTR_COW)
19197 + vflags &= ~V_COW;
19199 + if (in->i_op && in->i_op->sync_flags) {
19200 + error = in->i_op->sync_flags(in, iflags, vflags);
19206 + if (attr.ia_valid) {
19207 + if (in->i_op && in->i_op->setattr)
19208 + error = in->i_op->setattr(de, &attr);
19210 + error = inode_change_ok(in, &attr);
19212 + setattr_copy(in, &attr);
19213 + mark_inode_dirty(in);
19219 + mutex_unlock(&in->i_mutex);
19223 +int vc_set_iattr(void __user *data)
19225 + struct path path;
19226 + struct vcmd_ctx_iattr_v1 vc_data;
19229 + if (!capable(CAP_LINUX_IMMUTABLE))
19231 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19234 + ret = user_lpath(vc_data.name, &path);
19236 + ret = __vc_set_iattr(path.dentry,
19237 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19241 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19246 +#ifdef CONFIG_COMPAT
19248 +int vc_set_iattr_x32(void __user *data)
19250 + struct path path;
19251 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19254 + if (!capable(CAP_LINUX_IMMUTABLE))
19256 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19259 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19261 + ret = __vc_set_iattr(path.dentry,
19262 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19266 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19271 +#endif /* CONFIG_COMPAT */
19273 +int vc_fset_iattr(uint32_t fd, void __user *data)
19275 + struct file *filp;
19276 + struct vcmd_ctx_fiattr_v0 vc_data;
19279 + if (!capable(CAP_LINUX_IMMUTABLE))
19281 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19285 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19288 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19289 + &vc_data.flags, &vc_data.mask);
19293 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19299 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19301 +static match_table_t tokens = {
19302 + {Opt_notagcheck, "notagcheck"},
19303 +#ifdef CONFIG_PROPAGATE
19304 + {Opt_notag, "notag"},
19305 + {Opt_tag, "tag"},
19306 + {Opt_tagid, "tagid=%u"},
19312 +static void __dx_parse_remove(char *string, char *opt)
19314 + char *p = strstr(string, opt);
19318 + while (*q != '\0' && *q != ',')
19327 +int dx_parse_tag(char *string, vtag_t *tag, int remove, int *mnt_flags,
19328 + unsigned long *flags)
19331 + substring_t args[MAX_OPT_ARGS];
19333 + char *s, *p, *opts;
19334 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19340 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19345 + while ((p = strsep(&opts, ",")) != NULL) {
19346 + token = match_token(p, tokens, args);
19349 +#ifdef CONFIG_PROPAGATE
19354 + __dx_parse_remove(s, "tag");
19355 + *mnt_flags |= MNT_TAGID;
19356 + set |= MNT_TAGID;
19360 + __dx_parse_remove(s, "notag");
19361 + *mnt_flags |= MNT_NOTAG;
19362 + set |= MNT_NOTAG;
19365 + if (tag && !match_int(args, &option))
19368 + __dx_parse_remove(s, "tagid");
19369 + *mnt_flags |= MNT_TAGID;
19370 + set |= MNT_TAGID;
19372 +#endif /* CONFIG_PROPAGATE */
19373 + case Opt_notagcheck:
19375 + __dx_parse_remove(s, "notagcheck");
19376 + *flags |= MS_NOTAGCHECK;
19377 + set |= MS_NOTAGCHECK;
19380 + vxdprintk(VXD_CBIT(tag, 7),
19381 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19382 + p, token, option);
19385 + strcpy(string, s);
19390 +#ifdef CONFIG_PROPAGATE
19392 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19394 + vtag_t new_tag = 0;
19395 + struct vfsmount *mnt;
19400 + mnt = nd->path.mnt;
19404 + propagate = (mnt->mnt_flags & MNT_TAGID);
19406 + new_tag = mnt->mnt_tag;
19408 + vxdprintk(VXD_CBIT(tag, 7),
19409 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19410 + inode, inode->i_ino, inode->i_tag,
19411 + new_tag, (propagate) ? 1 : 0);
19414 + i_tag_write(inode, new_tag);
19417 +#include <linux/module.h>
19419 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19421 +#endif /* CONFIG_PROPAGATE */
19423 diff -NurpP --minimal linux-3.9.5/kernel/vserver/limit.c linux-3.9.5-vs2.3.6.5/kernel/vserver/limit.c
19424 --- linux-3.9.5/kernel/vserver/limit.c 1970-01-01 00:00:00.000000000 +0000
19425 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/limit.c 2013-05-31 14:47:11.000000000 +0000
19428 + * linux/kernel/vserver/limit.c
19430 + * Virtual Server: Context Limits
19432 + * Copyright (C) 2004-2010 Herbert Pötzl
19434 + * V0.01 broken out from vcontext V0.05
19435 + * V0.02 changed vcmds to vxi arg
19436 + * V0.03 added memory cgroup support
19440 +#include <linux/sched.h>
19441 +#include <linux/module.h>
19442 +#include <linux/memcontrol.h>
19443 +#include <linux/res_counter.h>
19444 +#include <linux/vs_limit.h>
19445 +#include <linux/vserver/limit.h>
19446 +#include <linux/vserver/limit_cmd.h>
19448 +#include <asm/uaccess.h>
19451 +const char *vlimit_name[NUM_LIMITS] = {
19452 + [RLIMIT_CPU] = "CPU",
19453 + [RLIMIT_NPROC] = "NPROC",
19454 + [RLIMIT_NOFILE] = "NOFILE",
19455 + [RLIMIT_LOCKS] = "LOCKS",
19456 + [RLIMIT_SIGPENDING] = "SIGP",
19457 + [RLIMIT_MSGQUEUE] = "MSGQ",
19459 + [VLIMIT_NSOCK] = "NSOCK",
19460 + [VLIMIT_OPENFD] = "OPENFD",
19461 + [VLIMIT_SHMEM] = "SHMEM",
19462 + [VLIMIT_DENTRY] = "DENTRY",
19465 +EXPORT_SYMBOL_GPL(vlimit_name);
19467 +#define MASK_ENTRY(x) (1 << (x))
19469 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
19472 + , /* softlimit */
19475 + MASK_ENTRY( RLIMIT_NPROC ) |
19476 + MASK_ENTRY( RLIMIT_NOFILE ) |
19477 + MASK_ENTRY( RLIMIT_LOCKS ) |
19478 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
19480 + MASK_ENTRY( VLIMIT_NSOCK ) |
19481 + MASK_ENTRY( VLIMIT_OPENFD ) |
19482 + MASK_ENTRY( VLIMIT_SHMEM ) |
19483 + MASK_ENTRY( VLIMIT_DENTRY ) |
19486 + /* accounting only */
19487 +uint32_t account_mask =
19488 + MASK_ENTRY( VLIMIT_SEMARY ) |
19489 + MASK_ENTRY( VLIMIT_NSEMS ) |
19490 + MASK_ENTRY( VLIMIT_MAPPED ) |
19494 +static int is_valid_vlimit(int id)
19496 + uint32_t mask = vlimit_mask.minimum |
19497 + vlimit_mask.softlimit | vlimit_mask.maximum;
19498 + return mask & (1 << id);
19501 +static int is_accounted_vlimit(int id)
19503 + if (is_valid_vlimit(id))
19505 + return account_mask & (1 << id);
19509 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
19511 + rlim_t limit = __rlim_soft(&vxi->limit, id);
19512 + return VX_VLIM(limit);
19515 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
19517 + rlim_t limit = __rlim_hard(&vxi->limit, id);
19518 + return VX_VLIM(limit);
19521 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
19522 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
19524 + if (!is_valid_vlimit(id))
19528 + *minimum = CRLIM_UNSET;
19530 + *softlimit = vc_get_soft(vxi, id);
19532 + *maximum = vc_get_hard(vxi, id);
19536 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
19538 + struct vcmd_ctx_rlimit_v0 vc_data;
19541 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19544 + ret = do_get_rlimit(vxi, vc_data.id,
19545 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19549 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19554 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
19555 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
19557 + if (!is_valid_vlimit(id))
19560 + if (maximum != CRLIM_KEEP)
19561 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
19562 + if (softlimit != CRLIM_KEEP)
19563 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
19565 + /* clamp soft limit */
19566 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
19567 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
19572 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
19574 + struct vcmd_ctx_rlimit_v0 vc_data;
19576 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19579 + return do_set_rlimit(vxi, vc_data.id,
19580 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19583 +#ifdef CONFIG_IA32_EMULATION
19585 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
19587 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19589 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19592 + return do_set_rlimit(vxi, vc_data.id,
19593 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19596 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
19598 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19601 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19604 + ret = do_get_rlimit(vxi, vc_data.id,
19605 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19609 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19614 +#endif /* CONFIG_IA32_EMULATION */
19617 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
19619 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
19625 +static inline void vx_reset_hits(struct _vx_limit *limit)
19629 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19630 + atomic_set(&__rlim_lhit(limit, lim), 0);
19634 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
19636 + vx_reset_hits(&vxi->limit);
19640 +static inline void vx_reset_minmax(struct _vx_limit *limit)
19645 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19646 + value = __rlim_get(limit, lim);
19647 + __rlim_rmax(limit, lim) = value;
19648 + __rlim_rmin(limit, lim) = value;
19652 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
19654 + vx_reset_minmax(&vxi->limit);
19659 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
19661 + struct vcmd_rlimit_stat_v0 vc_data;
19662 + struct _vx_limit *limit = &vxi->limit;
19665 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19669 + if (!is_accounted_vlimit(id))
19672 + vx_limit_fixup(limit, id);
19673 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
19674 + vc_data.value = __rlim_get(limit, id);
19675 + vc_data.minimum = __rlim_rmin(limit, id);
19676 + vc_data.maximum = __rlim_rmax(limit, id);
19678 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19684 +void vx_vsi_meminfo(struct sysinfo *val)
19686 +#ifdef CONFIG_MEMCG
19687 + struct mem_cgroup *mcg;
19688 + u64 res_limit, res_usage;
19691 + mcg = mem_cgroup_from_task(current);
19692 + rcu_read_unlock();
19696 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19697 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19699 + if (res_limit != RESOURCE_MAX)
19700 + val->totalram = (res_limit >> PAGE_SHIFT);
19701 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
19702 + val->bufferram = 0;
19703 + val->totalhigh = 0;
19704 + val->freehigh = 0;
19706 +#endif /* CONFIG_MEMCG */
19710 +void vx_vsi_swapinfo(struct sysinfo *val)
19712 +#ifdef CONFIG_MEMCG
19713 +#ifdef CONFIG_MEMCG_SWAP
19714 + struct mem_cgroup *mcg;
19715 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
19716 + s64 swap_limit, swap_usage;
19719 + mcg = mem_cgroup_from_task(current);
19720 + rcu_read_unlock();
19724 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19725 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19726 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
19727 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
19729 + /* memory unlimited */
19730 + if (res_limit == RESOURCE_MAX)
19733 + swap_limit = memsw_limit - res_limit;
19734 + /* we have a swap limit? */
19735 + if (memsw_limit != RESOURCE_MAX)
19736 + val->totalswap = swap_limit >> PAGE_SHIFT;
19738 + /* calculate swap part */
19739 + swap_usage = (memsw_usage > res_usage) ?
19740 + memsw_usage - res_usage : 0;
19742 + /* total shown minus usage gives free swap */
19743 + val->freeswap = (swap_usage < swap_limit) ?
19744 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
19746 +#else /* !CONFIG_MEMCG_SWAP */
19747 + val->totalswap = 0;
19748 + val->freeswap = 0;
19749 +#endif /* !CONFIG_MEMCG_SWAP */
19750 +#endif /* CONFIG_MEMCG */
19754 +long vx_vsi_cached(struct sysinfo *val)
19757 +#ifdef CONFIG_MEMCG
19758 + struct mem_cgroup *mcg;
19761 + mcg = mem_cgroup_from_task(current);
19762 + rcu_read_unlock();
19766 + cache = mem_cgroup_stat_read_cache(mcg);
19772 diff -NurpP --minimal linux-3.9.5/kernel/vserver/limit_init.h linux-3.9.5-vs2.3.6.5/kernel/vserver/limit_init.h
19773 --- linux-3.9.5/kernel/vserver/limit_init.h 1970-01-01 00:00:00.000000000 +0000
19774 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/limit_init.h 2013-05-31 14:47:11.000000000 +0000
19778 +static inline void vx_info_init_limit(struct _vx_limit *limit)
19782 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19783 + __rlim_soft(limit, lim) = RLIM_INFINITY;
19784 + __rlim_hard(limit, lim) = RLIM_INFINITY;
19785 + __rlim_set(limit, lim, 0);
19786 + atomic_set(&__rlim_lhit(limit, lim), 0);
19787 + __rlim_rmin(limit, lim) = 0;
19788 + __rlim_rmax(limit, lim) = 0;
19792 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
19797 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19798 + if ((1 << lim) & VLIM_NOCHECK)
19800 + value = __rlim_get(limit, lim);
19801 + vxwprintk_xid(value,
19802 + "!!! limit: %p[%s,%d] = %ld on exit.",
19803 + limit, vlimit_name[lim], lim, (long)value);
19807 diff -NurpP --minimal linux-3.9.5/kernel/vserver/limit_proc.h linux-3.9.5-vs2.3.6.5/kernel/vserver/limit_proc.h
19808 --- linux-3.9.5/kernel/vserver/limit_proc.h 1970-01-01 00:00:00.000000000 +0000
19809 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/limit_proc.h 2013-05-31 14:47:11.000000000 +0000
19811 +#ifndef _VX_LIMIT_PROC_H
19812 +#define _VX_LIMIT_PROC_H
19814 +#include <linux/vserver/limit_int.h>
19817 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
19818 +#define VX_LIMIT_TOP \
19819 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
19821 +#define VX_LIMIT_ARG(r) \
19822 + (unsigned long)__rlim_get(limit, r), \
19823 + (unsigned long)__rlim_rmin(limit, r), \
19824 + (unsigned long)__rlim_rmax(limit, r), \
19825 + VX_VLIM(__rlim_soft(limit, r)), \
19826 + VX_VLIM(__rlim_hard(limit, r)), \
19827 + atomic_read(&__rlim_lhit(limit, r))
19829 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
19831 + vx_limit_fixup(limit, -1);
19832 + return sprintf(buffer, VX_LIMIT_TOP
19833 + "PROC" VX_LIMIT_FMT
19834 + "VM" VX_LIMIT_FMT
19835 + "VML" VX_LIMIT_FMT
19836 + "RSS" VX_LIMIT_FMT
19837 + "ANON" VX_LIMIT_FMT
19838 + "RMAP" VX_LIMIT_FMT
19839 + "FILES" VX_LIMIT_FMT
19840 + "OFD" VX_LIMIT_FMT
19841 + "LOCKS" VX_LIMIT_FMT
19842 + "SOCK" VX_LIMIT_FMT
19843 + "MSGQ" VX_LIMIT_FMT
19844 + "SHM" VX_LIMIT_FMT
19845 + "SEMA" VX_LIMIT_FMT
19846 + "SEMS" VX_LIMIT_FMT
19847 + "DENT" VX_LIMIT_FMT,
19848 + VX_LIMIT_ARG(RLIMIT_NPROC),
19849 + VX_LIMIT_ARG(RLIMIT_AS),
19850 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
19851 + VX_LIMIT_ARG(RLIMIT_RSS),
19852 + VX_LIMIT_ARG(VLIMIT_ANON),
19853 + VX_LIMIT_ARG(VLIMIT_MAPPED),
19854 + VX_LIMIT_ARG(RLIMIT_NOFILE),
19855 + VX_LIMIT_ARG(VLIMIT_OPENFD),
19856 + VX_LIMIT_ARG(RLIMIT_LOCKS),
19857 + VX_LIMIT_ARG(VLIMIT_NSOCK),
19858 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
19859 + VX_LIMIT_ARG(VLIMIT_SHMEM),
19860 + VX_LIMIT_ARG(VLIMIT_SEMARY),
19861 + VX_LIMIT_ARG(VLIMIT_NSEMS),
19862 + VX_LIMIT_ARG(VLIMIT_DENTRY));
19865 +#endif /* _VX_LIMIT_PROC_H */
19868 diff -NurpP --minimal linux-3.9.5/kernel/vserver/network.c linux-3.9.5-vs2.3.6.5/kernel/vserver/network.c
19869 --- linux-3.9.5/kernel/vserver/network.c 1970-01-01 00:00:00.000000000 +0000
19870 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/network.c 2013-06-12 23:49:09.000000000 +0000
19873 + * linux/kernel/vserver/network.c
19875 + * Virtual Server: Network Support
19877 + * Copyright (C) 2003-2007 Herbert Pötzl
19879 + * V0.01 broken out from vcontext V0.05
19880 + * V0.02 cleaned up implementation
19881 + * V0.03 added equiv nx commands
19882 + * V0.04 switch to RCU based hash
19883 + * V0.05 and back to locking again
19884 + * V0.06 changed vcmds to nxi arg
19885 + * V0.07 have __create claim() the nxi
19889 +#include <linux/err.h>
19890 +#include <linux/slab.h>
19891 +#include <linux/rcupdate.h>
19892 +#include <net/ipv6.h>
19894 +#include <linux/vs_network.h>
19895 +#include <linux/vs_pid.h>
19896 +#include <linux/vserver/network_cmd.h>
19899 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
19900 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
19902 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
19903 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
19906 +static int __init init_network(void)
19908 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
19909 + sizeof(struct nx_addr_v4), 0,
19910 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19911 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
19912 + sizeof(struct nx_addr_v6), 0,
19913 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19918 +/* __alloc_nx_addr_v4() */
19920 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
19922 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
19923 + nx_addr_v4_cachep, GFP_KERNEL);
19925 + if (!IS_ERR(nxa))
19926 + memset(nxa, 0, sizeof(*nxa));
19930 +/* __dealloc_nx_addr_v4() */
19932 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
19934 + kmem_cache_free(nx_addr_v4_cachep, nxa);
19937 +/* __dealloc_nx_addr_v4_all() */
19939 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
19942 + struct nx_addr_v4 *next = nxa->next;
19944 + __dealloc_nx_addr_v4(nxa);
19950 +#ifdef CONFIG_IPV6
19952 +/* __alloc_nx_addr_v6() */
19954 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
19956 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
19957 + nx_addr_v6_cachep, GFP_KERNEL);
19959 + if (!IS_ERR(nxa))
19960 + memset(nxa, 0, sizeof(*nxa));
19964 +/* __dealloc_nx_addr_v6() */
19966 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
19968 + kmem_cache_free(nx_addr_v6_cachep, nxa);
19971 +/* __dealloc_nx_addr_v6_all() */
19973 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
19976 + struct nx_addr_v6 *next = nxa->next;
19978 + __dealloc_nx_addr_v6(nxa);
19983 +#endif /* CONFIG_IPV6 */
19985 +/* __alloc_nx_info()
19987 + * allocate an initialized nx_info struct
19988 + * doesn't make it visible (hash) */
19990 +static struct nx_info *__alloc_nx_info(vnid_t nid)
19992 + struct nx_info *new = NULL;
19994 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
19996 + /* would this benefit from a slab cache? */
19997 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20001 + memset(new, 0, sizeof(struct nx_info));
20002 + new->nx_id = nid;
20003 + INIT_HLIST_NODE(&new->nx_hlist);
20004 + atomic_set(&new->nx_usecnt, 0);
20005 + atomic_set(&new->nx_tasks, 0);
20006 + spin_lock_init(&new->addr_lock);
20007 + new->nx_state = 0;
20009 + new->nx_flags = NXF_INIT_SET;
20011 + /* rest of init goes here */
20013 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20014 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20016 + vxdprintk(VXD_CBIT(nid, 0),
20017 + "alloc_nx_info(%d) = %p", nid, new);
20018 + atomic_inc(&nx_global_ctotal);
20022 +/* __dealloc_nx_info()
20024 + * final disposal of nx_info */
20026 +static void __dealloc_nx_info(struct nx_info *nxi)
20028 + vxdprintk(VXD_CBIT(nid, 0),
20029 + "dealloc_nx_info(%p)", nxi);
20031 + nxi->nx_hlist.next = LIST_POISON1;
20034 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20035 + BUG_ON(atomic_read(&nxi->nx_tasks));
20037 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20038 +#ifdef CONFIG_IPV6
20039 + __dealloc_nx_addr_v6_all(nxi->v6.next);
20042 + nxi->nx_state |= NXS_RELEASED;
20044 + atomic_dec(&nx_global_ctotal);
20047 +static void __shutdown_nx_info(struct nx_info *nxi)
20049 + nxi->nx_state |= NXS_SHUTDOWN;
20050 + vs_net_change(nxi, VSC_NETDOWN);
20053 +/* exported stuff */
20055 +void free_nx_info(struct nx_info *nxi)
20057 + /* context shutdown is mandatory */
20058 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20060 + /* context must not be hashed */
20061 + BUG_ON(nxi->nx_state & NXS_HASHED);
20063 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20064 + BUG_ON(atomic_read(&nxi->nx_tasks));
20066 + __dealloc_nx_info(nxi);
20070 +void __nx_set_lback(struct nx_info *nxi)
20072 + int nid = nxi->nx_id;
20073 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20075 + nxi->v4_lback.s_addr = lback;
20078 +extern int __nx_inet_add_lback(__be32 addr);
20079 +extern int __nx_inet_del_lback(__be32 addr);
20082 +/* hash table for nx_info hash */
20084 +#define NX_HASH_SIZE 13
20086 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20088 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20091 +static inline unsigned int __hashval(vnid_t nid)
20093 + return (nid % NX_HASH_SIZE);
20098 +/* __hash_nx_info()
20100 + * add the nxi to the global hash table
20101 + * requires the hash_lock to be held */
20103 +static inline void __hash_nx_info(struct nx_info *nxi)
20105 + struct hlist_head *head;
20107 + vxd_assert_lock(&nx_info_hash_lock);
20108 + vxdprintk(VXD_CBIT(nid, 4),
20109 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20111 + /* context must not be hashed */
20112 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20114 + nxi->nx_state |= NXS_HASHED;
20115 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20116 + hlist_add_head(&nxi->nx_hlist, head);
20117 + atomic_inc(&nx_global_cactive);
20120 +/* __unhash_nx_info()
20122 + * remove the nxi from the global hash table
20123 + * requires the hash_lock to be held */
20125 +static inline void __unhash_nx_info(struct nx_info *nxi)
20127 + vxd_assert_lock(&nx_info_hash_lock);
20128 + vxdprintk(VXD_CBIT(nid, 4),
20129 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20130 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20132 + /* context must be hashed */
20133 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20134 + /* but without tasks */
20135 + BUG_ON(atomic_read(&nxi->nx_tasks));
20137 + nxi->nx_state &= ~NXS_HASHED;
20138 + hlist_del(&nxi->nx_hlist);
20139 + atomic_dec(&nx_global_cactive);
20143 +/* __lookup_nx_info()
20145 + * requires the hash_lock to be held
20146 + * doesn't increment the nx_refcnt */
20148 +static inline struct nx_info *__lookup_nx_info(vnid_t nid)
20150 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20151 + struct hlist_node *pos;
20152 + struct nx_info *nxi;
20154 + vxd_assert_lock(&nx_info_hash_lock);
20155 + hlist_for_each(pos, head) {
20156 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20158 + if (nxi->nx_id == nid)
20163 + vxdprintk(VXD_CBIT(nid, 0),
20164 + "__lookup_nx_info(#%u): %p[#%u]",
20165 + nid, nxi, nxi ? nxi->nx_id : 0);
20170 +/* __create_nx_info()
20172 + * create the requested context
20173 + * get(), claim() and hash it */
20175 +static struct nx_info *__create_nx_info(int id)
20177 + struct nx_info *new, *nxi = NULL;
20179 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20181 + if (!(new = __alloc_nx_info(id)))
20182 + return ERR_PTR(-ENOMEM);
20184 + /* required to make dynamic xids unique */
20185 + spin_lock(&nx_info_hash_lock);
20187 + /* static context requested */
20188 + if ((nxi = __lookup_nx_info(id))) {
20189 + vxdprintk(VXD_CBIT(nid, 0),
20190 + "create_nx_info(%d) = %p (already there)", id, nxi);
20191 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20192 + nxi = ERR_PTR(-EBUSY);
20194 + nxi = ERR_PTR(-EEXIST);
20197 + /* new context */
20198 + vxdprintk(VXD_CBIT(nid, 0),
20199 + "create_nx_info(%d) = %p (new)", id, new);
20200 + claim_nx_info(new, NULL);
20201 + __nx_set_lback(new);
20202 + __hash_nx_info(get_nx_info(new));
20203 + nxi = new, new = NULL;
20206 + spin_unlock(&nx_info_hash_lock);
20208 + __dealloc_nx_info(new);
20214 +/* exported stuff */
20217 +void unhash_nx_info(struct nx_info *nxi)
20219 + __shutdown_nx_info(nxi);
20220 + spin_lock(&nx_info_hash_lock);
20221 + __unhash_nx_info(nxi);
20222 + spin_unlock(&nx_info_hash_lock);
20225 +/* lookup_nx_info()
20227 + * search for a nx_info and get() it
20228 + * negative id means current */
20230 +struct nx_info *lookup_nx_info(int id)
20232 + struct nx_info *nxi = NULL;
20235 + nxi = get_nx_info(current_nx_info());
20236 + } else if (id > 1) {
20237 + spin_lock(&nx_info_hash_lock);
20238 + nxi = get_nx_info(__lookup_nx_info(id));
20239 + spin_unlock(&nx_info_hash_lock);
20244 +/* nid_is_hashed()
20246 + * verify that nid is still hashed */
20248 +int nid_is_hashed(vnid_t nid)
20252 + spin_lock(&nx_info_hash_lock);
20253 + hashed = (__lookup_nx_info(nid) != NULL);
20254 + spin_unlock(&nx_info_hash_lock);
20259 +#ifdef CONFIG_PROC_FS
20263 + * get a subset of hashed nids for proc
20264 + * assumes size is at least one */
20266 +int get_nid_list(int index, unsigned int *nids, int size)
20268 + int hindex, nr_nids = 0;
20270 + /* only show current and children */
20271 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20274 + nids[nr_nids] = nx_current_nid();
20278 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20279 + struct hlist_head *head = &nx_info_hash[hindex];
20280 + struct hlist_node *pos;
20282 + spin_lock(&nx_info_hash_lock);
20283 + hlist_for_each(pos, head) {
20284 + struct nx_info *nxi;
20289 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20290 + nids[nr_nids] = nxi->nx_id;
20291 + if (++nr_nids >= size) {
20292 + spin_unlock(&nx_info_hash_lock);
20296 + /* keep the lock time short */
20297 + spin_unlock(&nx_info_hash_lock);
20306 + * migrate task to new network
20307 + * gets nxi, puts old_nxi on change
20310 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20312 + struct nx_info *old_nxi;
20318 + vxdprintk(VXD_CBIT(nid, 5),
20319 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20320 + p, nxi, nxi->nx_id,
20321 + atomic_read(&nxi->nx_usecnt),
20322 + atomic_read(&nxi->nx_tasks));
20324 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20325 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20328 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20331 + /* maybe disallow this completely? */
20332 + old_nxi = task_get_nx_info(p);
20333 + if (old_nxi == nxi)
20338 + clr_nx_info(&p->nx_info);
20339 + claim_nx_info(nxi, p);
20340 + set_nx_info(&p->nx_info, nxi);
20341 + p->nid = nxi->nx_id;
20344 + vxdprintk(VXD_CBIT(nid, 5),
20345 + "moved task %p into nxi:%p[#%d]",
20346 + p, nxi, nxi->nx_id);
20349 + release_nx_info(old_nxi, p);
20352 + put_nx_info(old_nxi);
20357 +void nx_set_persistent(struct nx_info *nxi)
20359 + vxdprintk(VXD_CBIT(nid, 6),
20360 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20362 + get_nx_info(nxi);
20363 + claim_nx_info(nxi, NULL);
20366 +void nx_clear_persistent(struct nx_info *nxi)
20368 + vxdprintk(VXD_CBIT(nid, 6),
20369 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20371 + release_nx_info(nxi, NULL);
20372 + put_nx_info(nxi);
20375 +void nx_update_persistent(struct nx_info *nxi)
20377 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20378 + nx_set_persistent(nxi);
20380 + nx_clear_persistent(nxi);
20383 +/* vserver syscall commands below here */
20385 +/* taks nid and nx_info functions */
20387 +#include <asm/uaccess.h>
20390 +int vc_task_nid(uint32_t id)
20395 + struct task_struct *tsk;
20398 + tsk = find_task_by_real_pid(id);
20399 + nid = (tsk) ? tsk->nid : -ESRCH;
20400 + rcu_read_unlock();
20402 + nid = nx_current_nid();
20407 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20409 + struct vcmd_nx_info_v0 vc_data;
20411 + vc_data.nid = nxi->nx_id;
20413 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20419 +/* network functions */
20421 +int vc_net_create(uint32_t nid, void __user *data)
20423 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
20424 + struct nx_info *new_nxi;
20427 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20430 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
20433 + new_nxi = __create_nx_info(nid);
20434 + if (IS_ERR(new_nxi))
20435 + return PTR_ERR(new_nxi);
20437 + /* initial flags */
20438 + new_nxi->nx_flags = vc_data.flagword;
20441 + if (vs_net_change(new_nxi, VSC_NETUP))
20444 + ret = nx_migrate_task(current, new_nxi);
20448 + /* return context id on success */
20449 + ret = new_nxi->nx_id;
20451 + /* get a reference for persistent contexts */
20452 + if ((vc_data.flagword & NXF_PERSISTENT))
20453 + nx_set_persistent(new_nxi);
20455 + release_nx_info(new_nxi, NULL);
20456 + put_nx_info(new_nxi);
20461 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
20463 + return nx_migrate_task(current, nxi);
20468 +struct nx_addr_v4 *__find_v4_addr(struct nx_info *nxi,
20469 + __be32 ip, __be32 ip2, __be32 mask, uint16_t type, uint16_t flags,
20470 + struct nx_addr_v4 **prev)
20472 + struct nx_addr_v4 *nxa = &nxi->v4;
20474 + for (; nxa; nxa = nxa->next) {
20475 + if ((nxa->ip[0].s_addr == ip) &&
20476 + (nxa->ip[1].s_addr == ip2) &&
20477 + (nxa->mask.s_addr == mask) &&
20478 + (nxa->type == type) &&
20479 + (nxa->flags == flags))
20482 + /* save previous entry */
20489 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20490 + uint16_t type, uint16_t flags)
20492 + struct nx_addr_v4 *nxa = NULL;
20493 + struct nx_addr_v4 *new = __alloc_nx_addr_v4();
20494 + unsigned long irqflags;
20495 + int ret = -EEXIST;
20498 + return PTR_ERR(new);
20500 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20501 + if (__find_v4_addr(nxi, ip, ip2, mask, type, flags, &nxa))
20504 + if (NX_IPV4(nxi)) {
20509 + /* remove single ip for ip list */
20510 + nxi->nx_flags &= ~NXF_SINGLE_IP;
20513 + nxa->ip[0].s_addr = ip;
20514 + nxa->ip[1].s_addr = ip2;
20515 + nxa->mask.s_addr = mask;
20516 + nxa->type = type;
20517 + nxa->flags = flags;
20520 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20522 + __dealloc_nx_addr_v4(new);
20526 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20527 + uint16_t type, uint16_t flags)
20529 + struct nx_addr_v4 *nxa = NULL;
20530 + struct nx_addr_v4 *old = NULL;
20531 + unsigned long irqflags;
20534 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20536 + case NXA_TYPE_ADDR:
20537 + old = __find_v4_addr(nxi, ip, ip2, mask, type, flags, &nxa);
20540 + nxa->next = old->next;
20541 + old->next = NULL;
20547 + old->next = NULL;
20549 + memset(old, 0, sizeof(*old));
20557 + case NXA_TYPE_ANY:
20560 + memset(nxa, 0, sizeof(*nxa));
20566 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20567 + __dealloc_nx_addr_v4_all(old);
20572 +int vc_net_add(struct nx_info *nxi, void __user *data)
20574 + struct vcmd_net_addr_v0 vc_data;
20575 + int index, ret = 0;
20577 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20580 + switch (vc_data.type) {
20581 + case NXA_TYPE_IPV4:
20582 + if ((vc_data.count < 1) || (vc_data.count > 4))
20586 + while (index < vc_data.count) {
20587 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
20588 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
20596 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
20597 + nxi->v4_bcast = vc_data.ip[0];
20601 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
20602 + nxi->v4_lback = vc_data.ip[0];
20613 +int vc_net_remove(struct nx_info *nxi, void __user *data)
20615 + struct vcmd_net_addr_v0 vc_data;
20617 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20620 + switch (vc_data.type) {
20621 + case NXA_TYPE_ANY:
20622 + return do_remove_v4_addr(nxi, 0, 0, 0, vc_data.type, 0);
20630 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
20632 + struct vcmd_net_addr_ipv4_v1 vc_data;
20634 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20637 + switch (vc_data.type) {
20638 + case NXA_TYPE_ADDR:
20639 + case NXA_TYPE_MASK:
20640 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
20641 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20643 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20644 + nxi->v4_bcast = vc_data.ip;
20647 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20648 + nxi->v4_lback = vc_data.ip;
20657 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
20659 + struct vcmd_net_addr_ipv4_v2 vc_data;
20661 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20664 + switch (vc_data.type) {
20665 + case NXA_TYPE_ADDR:
20666 + case NXA_TYPE_MASK:
20667 + case NXA_TYPE_RANGE:
20668 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20669 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20671 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20672 + nxi->v4_bcast = vc_data.ip;
20675 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20676 + nxi->v4_lback = vc_data.ip;
20685 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
20687 + struct vcmd_net_addr_ipv4_v1 vc_data;
20689 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20692 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
20693 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20696 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
20698 + struct vcmd_net_addr_ipv4_v2 vc_data;
20700 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20703 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20704 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20707 +#ifdef CONFIG_IPV6
20710 +struct nx_addr_v6 *__find_v6_addr(struct nx_info *nxi,
20711 + struct in6_addr *ip, struct in6_addr *mask,
20712 + uint32_t prefix, uint16_t type, uint16_t flags,
20713 + struct nx_addr_v6 **prev)
20715 + struct nx_addr_v6 *nxa = &nxi->v6;
20717 + for (; nxa; nxa = nxa->next) {
20718 + if (ipv6_addr_equal(&nxa->ip, ip) &&
20719 + ipv6_addr_equal(&nxa->mask, mask) &&
20720 + (nxa->prefix == prefix) &&
20721 + (nxa->type == type) &&
20722 + (nxa->flags == flags))
20725 + /* save previous entry */
20733 +int do_add_v6_addr(struct nx_info *nxi,
20734 + struct in6_addr *ip, struct in6_addr *mask,
20735 + uint32_t prefix, uint16_t type, uint16_t flags)
20737 + struct nx_addr_v6 *nxa = NULL;
20738 + struct nx_addr_v6 *new = __alloc_nx_addr_v6();
20739 + unsigned long irqflags;
20740 + int ret = -EEXIST;
20743 + return PTR_ERR(new);
20745 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20746 + if (__find_v6_addr(nxi, ip, mask, prefix, type, flags, &nxa))
20749 + if (NX_IPV6(nxi)) {
20756 + nxa->mask = *mask;
20757 + nxa->prefix = prefix;
20758 + nxa->type = type;
20759 + nxa->flags = flags;
20762 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20764 + __dealloc_nx_addr_v6(new);
20768 +int do_remove_v6_addr(struct nx_info *nxi,
20769 + struct in6_addr *ip, struct in6_addr *mask,
20770 + uint32_t prefix, uint16_t type, uint16_t flags)
20772 + struct nx_addr_v6 *nxa = NULL;
20773 + struct nx_addr_v6 *old = NULL;
20774 + unsigned long irqflags;
20777 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20779 + case NXA_TYPE_ADDR:
20780 + old = __find_v6_addr(nxi, ip, mask, prefix, type, flags, &nxa);
20783 + nxa->next = old->next;
20784 + old->next = NULL;
20790 + old->next = NULL;
20792 + memset(old, 0, sizeof(*old));
20800 + case NXA_TYPE_ANY:
20803 + memset(nxa, 0, sizeof(*nxa));
20809 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20810 + __dealloc_nx_addr_v6_all(old);
20814 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
20816 + struct vcmd_net_addr_ipv6_v1 vc_data;
20818 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20821 + switch (vc_data.type) {
20822 + case NXA_TYPE_ADDR:
20823 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20824 + /* fallthrough */
20825 + case NXA_TYPE_MASK:
20826 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20827 + vc_data.prefix, vc_data.type, vc_data.flags);
20834 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
20836 + struct vcmd_net_addr_ipv6_v1 vc_data;
20838 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20841 + switch (vc_data.type) {
20842 + case NXA_TYPE_ADDR:
20843 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20844 + /* fallthrough */
20845 + case NXA_TYPE_MASK:
20846 + return do_remove_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20847 + vc_data.prefix, vc_data.type, vc_data.flags);
20848 + case NXA_TYPE_ANY:
20849 + return do_remove_v6_addr(nxi, NULL, NULL, 0, vc_data.type, 0);
20856 +#endif /* CONFIG_IPV6 */
20859 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
20861 + struct vcmd_net_flags_v0 vc_data;
20863 + vc_data.flagword = nxi->nx_flags;
20865 + /* special STATE flag handling */
20866 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
20868 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20873 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
20875 + struct vcmd_net_flags_v0 vc_data;
20876 + uint64_t mask, trigger;
20878 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20881 + /* special STATE flag handling */
20882 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
20883 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
20885 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
20886 + vc_data.flagword, mask);
20887 + if (trigger & NXF_PERSISTENT)
20888 + nx_update_persistent(nxi);
20893 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
20895 + struct vcmd_net_caps_v0 vc_data;
20897 + vc_data.ncaps = nxi->nx_ncaps;
20898 + vc_data.cmask = ~0ULL;
20900 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20905 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
20907 + struct vcmd_net_caps_v0 vc_data;
20909 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20912 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
20913 + vc_data.ncaps, vc_data.cmask);
20918 +#include <linux/module.h>
20920 +module_init(init_network);
20922 +EXPORT_SYMBOL_GPL(free_nx_info);
20923 +EXPORT_SYMBOL_GPL(unhash_nx_info);
20925 diff -NurpP --minimal linux-3.9.5/kernel/vserver/proc.c linux-3.9.5-vs2.3.6.5/kernel/vserver/proc.c
20926 --- linux-3.9.5/kernel/vserver/proc.c 1970-01-01 00:00:00.000000000 +0000
20927 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/proc.c 2013-06-12 23:49:09.000000000 +0000
20930 + * linux/kernel/vserver/proc.c
20932 + * Virtual Context Support
20934 + * Copyright (C) 2003-2011 Herbert Pötzl
20936 + * V0.01 basic structure
20937 + * V0.02 adaptation vs1.3.0
20938 + * V0.03 proc permissions
20939 + * V0.04 locking/generic
20940 + * V0.05 next generation procfs
20941 + * V0.06 inode validation
20942 + * V0.07 generic rewrite vid
20943 + * V0.08 remove inode type
20944 + * V0.09 added u/wmask info
20948 +#include <linux/proc_fs.h>
20949 +#include <linux/fs_struct.h>
20950 +#include <linux/mount.h>
20951 +#include <linux/namei.h>
20952 +#include <asm/unistd.h>
20954 +#include <linux/vs_context.h>
20955 +#include <linux/vs_network.h>
20956 +#include <linux/vs_cvirt.h>
20958 +#include <linux/in.h>
20959 +#include <linux/inetdevice.h>
20960 +#include <linux/vs_inet.h>
20961 +#include <linux/vs_inet6.h>
20963 +#include <linux/vserver/global.h>
20965 +#include "cvirt_proc.h"
20966 +#include "cacct_proc.h"
20967 +#include "limit_proc.h"
20968 +#include "sched_proc.h"
20969 +#include "vci_config.h"
20972 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
20976 + CAP_FOR_EACH_U32(__capi) {
20977 + buffer += sprintf(buffer, "%08x",
20978 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
20984 +static struct proc_dir_entry *proc_virtual;
20986 +static struct proc_dir_entry *proc_virtnet;
20989 +/* first the actual feeds */
20992 +static int proc_vci(char *buffer)
20994 + return sprintf(buffer,
20995 + "VCIVersion:\t%04x:%04x\n"
20996 + "VCISyscall:\t%d\n"
20997 + "VCIKernel:\t%08x\n",
20998 + VCI_VERSION >> 16,
20999 + VCI_VERSION & 0xFFFF,
21001 + vci_kernel_config());
21004 +static int proc_virtual_info(char *buffer)
21006 + return proc_vci(buffer);
21009 +static int proc_virtual_status(char *buffer)
21011 + return sprintf(buffer,
21013 + "#CActive:\t%d\n"
21014 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21015 + "#InitTask:\t%d\t%d %d\n",
21016 + atomic_read(&vx_global_ctotal),
21017 + atomic_read(&vx_global_cactive),
21018 + atomic_read(&vs_global_nsproxy),
21019 + atomic_read(&vs_global_fs),
21020 + atomic_read(&vs_global_mnt_ns),
21021 + atomic_read(&vs_global_uts_ns),
21022 + atomic_read(&nr_ipc_ns),
21023 + atomic_read(&vs_global_user_ns),
21024 + atomic_read(&vs_global_pid_ns),
21025 + atomic_read(&init_task.usage),
21026 + atomic_read(&init_task.nsproxy->count),
21027 + init_task.fs->users);
21031 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21035 + length = sprintf(buffer,
21043 + vxi->vx_badness_bias);
21047 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21049 + char *orig = buffer;
21051 + buffer += sprintf(buffer,
21054 + "Flags:\t%016llx\n",
21055 + atomic_read(&vxi->vx_usecnt),
21056 + atomic_read(&vxi->vx_tasks),
21057 + (unsigned long long)vxi->vx_flags);
21059 + buffer += sprintf(buffer, "BCaps:\t");
21060 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21061 + buffer += sprintf(buffer, "\n");
21063 + buffer += sprintf(buffer,
21064 + "CCaps:\t%016llx\n"
21065 + "Umask:\t%16llx\n"
21066 + "Wmask:\t%16llx\n"
21067 + "Spaces:\t%08lx %08lx\n",
21068 + (unsigned long long)vxi->vx_ccaps,
21069 + (unsigned long long)vxi->vx_umask,
21070 + (unsigned long long)vxi->vx_wmask,
21071 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21072 + return buffer - orig;
21075 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21077 + return vx_info_proc_limit(&vxi->limit, buffer);
21080 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21084 + length = vx_info_proc_sched(&vxi->sched, buffer);
21085 + for_each_online_cpu(cpu) {
21086 + length += vx_info_proc_sched_pc(
21087 + &vx_per_cpu(vxi, sched_pc, cpu),
21088 + buffer + length, cpu);
21093 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21095 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21098 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21100 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21103 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21107 + vx_update_load(vxi);
21108 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21109 + for_each_online_cpu(cpu) {
21110 + length += vx_info_proc_cvirt_pc(
21111 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21112 + buffer + length, cpu);
21117 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21119 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21123 +static int proc_virtnet_info(char *buffer)
21125 + return proc_vci(buffer);
21128 +static int proc_virtnet_status(char *buffer)
21130 + return sprintf(buffer,
21132 + "#CActive:\t%d\n",
21133 + atomic_read(&nx_global_ctotal),
21134 + atomic_read(&nx_global_cactive));
21137 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21139 + struct nx_addr_v4 *v4a;
21140 +#ifdef CONFIG_IPV6
21141 + struct nx_addr_v6 *v6a;
21145 + length = sprintf(buffer,
21148 + "Bcast:\t" NIPQUAD_FMT "\n"
21149 + "Lback:\t" NIPQUAD_FMT "\n",
21152 + NIPQUAD(nxi->v4_bcast.s_addr),
21153 + NIPQUAD(nxi->v4_lback.s_addr));
21155 + if (!NX_IPV4(nxi))
21157 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21158 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21161 +#ifdef CONFIG_IPV6
21162 + if (!NX_IPV6(nxi))
21164 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21165 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21172 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21176 + length = sprintf(buffer,
21179 + "Flags:\t%016llx\n"
21180 + "NCaps:\t%016llx\n",
21181 + atomic_read(&nxi->nx_usecnt),
21182 + atomic_read(&nxi->nx_tasks),
21183 + (unsigned long long)nxi->nx_flags,
21184 + (unsigned long long)nxi->nx_ncaps);
21190 +/* here the inode helpers */
21196 + struct inode_operations *iop;
21197 + struct file_operations *fop;
21198 + union proc_op op;
21201 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21203 + struct inode *inode = new_inode(sb);
21208 + inode->i_mode = p->mode;
21210 + inode->i_op = p->iop;
21212 + inode->i_fop = p->fop;
21214 + set_nlink(inode, (p->mode & S_IFDIR) ? 2 : 1);
21215 + inode->i_flags |= S_IMMUTABLE;
21217 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21219 + i_uid_write(inode, 0);
21220 + i_gid_write(inode, 0);
21221 + i_tag_write(inode, 0);
21226 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21227 + struct dentry *dentry, int id, void *ptr)
21229 + struct vs_entry *p = ptr;
21230 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21231 + struct dentry *error = ERR_PTR(-EINVAL);
21236 + PROC_I(inode)->op = p->op;
21237 + PROC_I(inode)->fd = id;
21238 + d_add(dentry, inode);
21246 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21249 + * Fill a directory entry.
21251 + * If possible create the dcache entry and derive our inode number and
21252 + * file type from dcache entry.
21254 + * Since all of the proc inode numbers are dynamically generated, the inode
21255 + * numbers do not exist until the inode is cache. This means creating the
21256 + * the dcache entry in readdir is necessary to keep the inode numbers
21257 + * reported by readdir in sync with the inode numbers reported
21260 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21261 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21263 + struct dentry *child, *dir = filp->f_dentry;
21264 + struct inode *inode;
21265 + struct qstr qname;
21267 + unsigned type = DT_UNKNOWN;
21269 + qname.name = name;
21271 + qname.hash = full_name_hash(name, len);
21273 + child = d_lookup(dir, &qname);
21275 + struct dentry *new;
21276 + new = d_alloc(dir, &qname);
21278 + child = instantiate(dir->d_inode, new, id, ptr);
21285 + if (!child || IS_ERR(child) || !child->d_inode)
21286 + goto end_instantiate;
21287 + inode = child->d_inode;
21289 + ino = inode->i_ino;
21290 + type = inode->i_mode >> 12;
21295 + ino = find_inode_number(dir, &qname);
21298 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21303 +/* get and revalidate vx_info/xid */
21306 +struct vx_info *get_proc_vx_info(struct inode *inode)
21308 + return lookup_vx_info(PROC_I(inode)->fd);
21311 +static int proc_xid_revalidate(struct dentry *dentry, unsigned int flags)
21313 + struct inode *inode = dentry->d_inode;
21314 + vxid_t xid = PROC_I(inode)->fd;
21316 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21319 + if (!xid || xid_is_hashed(xid))
21326 +/* get and revalidate nx_info/nid */
21328 +static int proc_nid_revalidate(struct dentry *dentry, unsigned int flags)
21330 + struct inode *inode = dentry->d_inode;
21331 + vnid_t nid = PROC_I(inode)->fd;
21333 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21336 + if (!nid || nid_is_hashed(nid))
21344 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21346 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21347 + size_t count, loff_t *ppos)
21349 + struct inode *inode = file->f_dentry->d_inode;
21350 + unsigned long page;
21351 + ssize_t length = 0;
21353 + if (count > PROC_BLOCK_SIZE)
21354 + count = PROC_BLOCK_SIZE;
21356 + /* fade that out as soon as stable */
21357 + WARN_ON(PROC_I(inode)->fd);
21359 + if (!(page = __get_free_page(GFP_KERNEL)))
21362 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21363 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21366 + length = simple_read_from_buffer(buf, count, ppos,
21367 + (char *)page, length);
21373 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21374 + size_t count, loff_t *ppos)
21376 + struct inode *inode = file->f_dentry->d_inode;
21377 + struct vx_info *vxi = NULL;
21378 + vxid_t xid = PROC_I(inode)->fd;
21379 + unsigned long page;
21380 + ssize_t length = 0;
21382 + if (count > PROC_BLOCK_SIZE)
21383 + count = PROC_BLOCK_SIZE;
21385 + /* fade that out as soon as stable */
21387 + vxi = lookup_vx_info(xid);
21391 + length = -ENOMEM;
21392 + if (!(page = __get_free_page(GFP_KERNEL)))
21395 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21396 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21399 + length = simple_read_from_buffer(buf, count, ppos,
21400 + (char *)page, length);
21404 + put_vx_info(vxi);
21409 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21410 + size_t count, loff_t *ppos)
21412 + struct inode *inode = file->f_dentry->d_inode;
21413 + struct nx_info *nxi = NULL;
21414 + vnid_t nid = PROC_I(inode)->fd;
21415 + unsigned long page;
21416 + ssize_t length = 0;
21418 + if (count > PROC_BLOCK_SIZE)
21419 + count = PROC_BLOCK_SIZE;
21421 + /* fade that out as soon as stable */
21423 + nxi = lookup_nx_info(nid);
21427 + length = -ENOMEM;
21428 + if (!(page = __get_free_page(GFP_KERNEL)))
21431 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21432 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21435 + length = simple_read_from_buffer(buf, count, ppos,
21436 + (char *)page, length);
21440 + put_nx_info(nxi);
21447 +/* here comes the lower level */
21450 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21451 + .len = sizeof(NAME) - 1, \
21452 + .name = (NAME), \
21460 +#define DIR(NAME, MODE, OTYPE) \
21461 + NOD(NAME, (S_IFDIR | (MODE)), \
21462 + &proc_ ## OTYPE ## _inode_operations, \
21463 + &proc_ ## OTYPE ## _file_operations, { } )
21465 +#define INF(NAME, MODE, OTYPE) \
21466 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21467 + &proc_vs_info_file_operations, \
21468 + { .proc_vs_read = &proc_##OTYPE } )
21470 +#define VINF(NAME, MODE, OTYPE) \
21471 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21472 + &proc_vx_info_file_operations, \
21473 + { .proc_vxi_read = &proc_##OTYPE } )
21475 +#define NINF(NAME, MODE, OTYPE) \
21476 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21477 + &proc_nx_info_file_operations, \
21478 + { .proc_nxi_read = &proc_##OTYPE } )
21481 +static struct file_operations proc_vs_info_file_operations = {
21482 + .read = proc_vs_info_read,
21485 +static struct file_operations proc_vx_info_file_operations = {
21486 + .read = proc_vx_info_read,
21489 +static struct dentry_operations proc_xid_dentry_operations = {
21490 + .d_revalidate = proc_xid_revalidate,
21493 +static struct vs_entry vx_base_stuff[] = {
21494 + VINF("info", S_IRUGO, vxi_info),
21495 + VINF("status", S_IRUGO, vxi_status),
21496 + VINF("limit", S_IRUGO, vxi_limit),
21497 + VINF("sched", S_IRUGO, vxi_sched),
21498 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21499 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21500 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21501 + VINF("cacct", S_IRUGO, vxi_cacct),
21508 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21509 + struct dentry *dentry, int id, void *ptr)
21511 + dentry->d_op = &proc_xid_dentry_operations;
21512 + return vs_proc_instantiate(dir, dentry, id, ptr);
21515 +static struct dentry *proc_xid_lookup(struct inode *dir,
21516 + struct dentry *dentry, unsigned int flags)
21518 + struct vs_entry *p = vx_base_stuff;
21519 + struct dentry *error = ERR_PTR(-ENOENT);
21521 + for (; p->name; p++) {
21522 + if (p->len != dentry->d_name.len)
21524 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21530 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21535 +static int proc_xid_readdir(struct file *filp,
21536 + void *dirent, filldir_t filldir)
21538 + struct dentry *dentry = filp->f_dentry;
21539 + struct inode *inode = dentry->d_inode;
21540 + struct vs_entry *p = vx_base_stuff;
21541 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21545 + pos = filp->f_pos;
21548 + ino = inode->i_ino;
21549 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21552 + /* fall through */
21554 + ino = parent_ino(dentry);
21555 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21558 + /* fall through */
21561 + if (index >= size)
21563 + for (p += index; p->name; p++) {
21564 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21565 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21571 + filp->f_pos = pos;
21577 +static struct file_operations proc_nx_info_file_operations = {
21578 + .read = proc_nx_info_read,
21581 +static struct dentry_operations proc_nid_dentry_operations = {
21582 + .d_revalidate = proc_nid_revalidate,
21585 +static struct vs_entry nx_base_stuff[] = {
21586 + NINF("info", S_IRUGO, nxi_info),
21587 + NINF("status", S_IRUGO, nxi_status),
21592 +static struct dentry *proc_nid_instantiate(struct inode *dir,
21593 + struct dentry *dentry, int id, void *ptr)
21595 + dentry->d_op = &proc_nid_dentry_operations;
21596 + return vs_proc_instantiate(dir, dentry, id, ptr);
21599 +static struct dentry *proc_nid_lookup(struct inode *dir,
21600 + struct dentry *dentry, unsigned int flags)
21602 + struct vs_entry *p = nx_base_stuff;
21603 + struct dentry *error = ERR_PTR(-ENOENT);
21605 + for (; p->name; p++) {
21606 + if (p->len != dentry->d_name.len)
21608 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21614 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21619 +static int proc_nid_readdir(struct file *filp,
21620 + void *dirent, filldir_t filldir)
21622 + struct dentry *dentry = filp->f_dentry;
21623 + struct inode *inode = dentry->d_inode;
21624 + struct vs_entry *p = nx_base_stuff;
21625 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
21629 + pos = filp->f_pos;
21632 + ino = inode->i_ino;
21633 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21636 + /* fall through */
21638 + ino = parent_ino(dentry);
21639 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21642 + /* fall through */
21645 + if (index >= size)
21647 + for (p += index; p->name; p++) {
21648 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21649 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21655 + filp->f_pos = pos;
21660 +#define MAX_MULBY10 ((~0U - 9) / 10)
21662 +static inline int atovid(const char *str, int len)
21667 + while (len-- > 0) {
21672 + if (vid >= MAX_MULBY10)
21682 +/* now the upper level (virtual) */
21685 +static struct file_operations proc_xid_file_operations = {
21686 + .read = generic_read_dir,
21687 + .readdir = proc_xid_readdir,
21690 +static struct inode_operations proc_xid_inode_operations = {
21691 + .lookup = proc_xid_lookup,
21694 +static struct vs_entry vx_virtual_stuff[] = {
21695 + INF("info", S_IRUGO, virtual_info),
21696 + INF("status", S_IRUGO, virtual_status),
21697 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
21701 +static struct dentry *proc_virtual_lookup(struct inode *dir,
21702 + struct dentry *dentry, unsigned int flags)
21704 + struct vs_entry *p = vx_virtual_stuff;
21705 + struct dentry *error = ERR_PTR(-ENOENT);
21708 + for (; p->name; p++) {
21709 + if (p->len != dentry->d_name.len)
21711 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21715 + goto instantiate;
21717 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21718 + if ((id < 0) || !xid_is_hashed(id))
21722 + error = proc_xid_instantiate(dir, dentry, id, p);
21727 +static struct file_operations proc_nid_file_operations = {
21728 + .read = generic_read_dir,
21729 + .readdir = proc_nid_readdir,
21732 +static struct inode_operations proc_nid_inode_operations = {
21733 + .lookup = proc_nid_lookup,
21736 +static struct vs_entry nx_virtnet_stuff[] = {
21737 + INF("info", S_IRUGO, virtnet_info),
21738 + INF("status", S_IRUGO, virtnet_status),
21739 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
21743 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
21744 + struct dentry *dentry, unsigned int flags)
21746 + struct vs_entry *p = nx_virtnet_stuff;
21747 + struct dentry *error = ERR_PTR(-ENOENT);
21750 + for (; p->name; p++) {
21751 + if (p->len != dentry->d_name.len)
21753 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21757 + goto instantiate;
21759 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21760 + if ((id < 0) || !nid_is_hashed(id))
21764 + error = proc_nid_instantiate(dir, dentry, id, p);
21770 +#define PROC_MAXVIDS 32
21772 +int proc_virtual_readdir(struct file *filp,
21773 + void *dirent, filldir_t filldir)
21775 + struct dentry *dentry = filp->f_dentry;
21776 + struct inode *inode = dentry->d_inode;
21777 + struct vs_entry *p = vx_virtual_stuff;
21778 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
21780 + unsigned int xid_array[PROC_MAXVIDS];
21781 + char buf[PROC_NUMBUF];
21782 + unsigned int nr_xids, i;
21785 + pos = filp->f_pos;
21788 + ino = inode->i_ino;
21789 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21792 + /* fall through */
21794 + ino = parent_ino(dentry);
21795 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21798 + /* fall through */
21801 + if (index >= size)
21803 + for (p += index; p->name; p++) {
21804 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21805 + vs_proc_instantiate, 0, p))
21810 + index = pos - size;
21811 + p = &vx_virtual_stuff[size - 1];
21812 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
21813 + for (i = 0; i < nr_xids; i++) {
21814 + int n, xid = xid_array[i];
21815 + unsigned int j = PROC_NUMBUF;
21819 + buf[--j] = '0' + (n % 10);
21822 + if (proc_fill_cache(filp, dirent, filldir,
21823 + buf + j, PROC_NUMBUF - j,
21824 + vs_proc_instantiate, xid, p))
21830 + filp->f_pos = pos;
21834 +static int proc_virtual_getattr(struct vfsmount *mnt,
21835 + struct dentry *dentry, struct kstat *stat)
21837 + struct inode *inode = dentry->d_inode;
21839 + generic_fillattr(inode, stat);
21840 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
21844 +static struct file_operations proc_virtual_dir_operations = {
21845 + .read = generic_read_dir,
21846 + .readdir = proc_virtual_readdir,
21849 +static struct inode_operations proc_virtual_dir_inode_operations = {
21850 + .getattr = proc_virtual_getattr,
21851 + .lookup = proc_virtual_lookup,
21858 +int proc_virtnet_readdir(struct file *filp,
21859 + void *dirent, filldir_t filldir)
21861 + struct dentry *dentry = filp->f_dentry;
21862 + struct inode *inode = dentry->d_inode;
21863 + struct vs_entry *p = nx_virtnet_stuff;
21864 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
21866 + unsigned int nid_array[PROC_MAXVIDS];
21867 + char buf[PROC_NUMBUF];
21868 + unsigned int nr_nids, i;
21871 + pos = filp->f_pos;
21874 + ino = inode->i_ino;
21875 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21878 + /* fall through */
21880 + ino = parent_ino(dentry);
21881 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21884 + /* fall through */
21887 + if (index >= size)
21889 + for (p += index; p->name; p++) {
21890 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21891 + vs_proc_instantiate, 0, p))
21896 + index = pos - size;
21897 + p = &nx_virtnet_stuff[size - 1];
21898 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
21899 + for (i = 0; i < nr_nids; i++) {
21900 + int n, nid = nid_array[i];
21901 + unsigned int j = PROC_NUMBUF;
21905 + buf[--j] = '0' + (n % 10);
21908 + if (proc_fill_cache(filp, dirent, filldir,
21909 + buf + j, PROC_NUMBUF - j,
21910 + vs_proc_instantiate, nid, p))
21916 + filp->f_pos = pos;
21920 +static int proc_virtnet_getattr(struct vfsmount *mnt,
21921 + struct dentry *dentry, struct kstat *stat)
21923 + struct inode *inode = dentry->d_inode;
21925 + generic_fillattr(inode, stat);
21926 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
21930 +static struct file_operations proc_virtnet_dir_operations = {
21931 + .read = generic_read_dir,
21932 + .readdir = proc_virtnet_readdir,
21935 +static struct inode_operations proc_virtnet_dir_inode_operations = {
21936 + .getattr = proc_virtnet_getattr,
21937 + .lookup = proc_virtnet_lookup,
21942 +void proc_vx_init(void)
21944 + struct proc_dir_entry *ent;
21946 + ent = proc_mkdir("virtual", 0);
21948 + ent->proc_fops = &proc_virtual_dir_operations;
21949 + ent->proc_iops = &proc_virtual_dir_inode_operations;
21951 + proc_virtual = ent;
21953 + ent = proc_mkdir("virtnet", 0);
21955 + ent->proc_fops = &proc_virtnet_dir_operations;
21956 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
21958 + proc_virtnet = ent;
21964 +/* per pid info */
21967 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
21969 + struct vx_info *vxi;
21970 + char *orig = buffer;
21972 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
21974 + vxi = task_get_vx_info(p);
21978 + buffer += sprintf(buffer, "BCaps:\t");
21979 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21980 + buffer += sprintf(buffer, "\n");
21981 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
21982 + (unsigned long long)vxi->vx_ccaps);
21983 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
21984 + (unsigned long long)vxi->vx_flags);
21985 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
21987 + put_vx_info(vxi);
21989 + return buffer - orig;
21993 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
21995 + struct nx_info *nxi;
21996 + struct nx_addr_v4 *v4a;
21997 +#ifdef CONFIG_IPV6
21998 + struct nx_addr_v6 *v6a;
22000 + char *orig = buffer;
22003 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22005 + nxi = task_get_nx_info(p);
22009 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22010 + (unsigned long long)nxi->nx_ncaps);
22011 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22012 + (unsigned long long)nxi->nx_flags);
22014 + buffer += sprintf(buffer,
22015 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22016 + NIPQUAD(nxi->v4_bcast.s_addr));
22017 + buffer += sprintf (buffer,
22018 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22019 + NIPQUAD(nxi->v4_lback.s_addr));
22020 + if (!NX_IPV4(nxi))
22022 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22023 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22026 +#ifdef CONFIG_IPV6
22027 + if (!NX_IPV6(nxi))
22029 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22030 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22034 + put_nx_info(nxi);
22036 + return buffer - orig;
22039 diff -NurpP --minimal linux-3.9.5/kernel/vserver/sched.c linux-3.9.5-vs2.3.6.5/kernel/vserver/sched.c
22040 --- linux-3.9.5/kernel/vserver/sched.c 1970-01-01 00:00:00.000000000 +0000
22041 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/sched.c 2013-05-31 14:47:11.000000000 +0000
22044 + * linux/kernel/vserver/sched.c
22046 + * Virtual Server: Scheduler Support
22048 + * Copyright (C) 2004-2010 Herbert Pötzl
22050 + * V0.01 adapted Sam Vilains version to 2.6.3
22051 + * V0.02 removed legacy interface
22052 + * V0.03 changed vcmds to vxi arg
22053 + * V0.04 removed older and legacy interfaces
22054 + * V0.05 removed scheduler code/commands
22058 +#include <linux/vs_context.h>
22059 +#include <linux/vs_sched.h>
22060 +#include <linux/cpumask.h>
22061 +#include <linux/vserver/sched_cmd.h>
22063 +#include <asm/uaccess.h>
22066 +void vx_update_sched_param(struct _vx_sched *sched,
22067 + struct _vx_sched_pc *sched_pc)
22069 + sched_pc->prio_bias = sched->prio_bias;
22072 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22076 + if (data->prio_bias > MAX_PRIO_BIAS)
22077 + data->prio_bias = MAX_PRIO_BIAS;
22078 + if (data->prio_bias < MIN_PRIO_BIAS)
22079 + data->prio_bias = MIN_PRIO_BIAS;
22081 + if (data->cpu_id != ~0) {
22082 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22083 + cpumask_and(&vxi->sched.update, &vxi->sched.update,
22084 + cpu_online_mask);
22086 + cpumask_copy(&vxi->sched.update, cpu_online_mask);
22088 + for_each_cpu_mask(cpu, vxi->sched.update)
22089 + vx_update_sched_param(&vxi->sched,
22090 + &vx_per_cpu(vxi, sched_pc, cpu));
22094 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22096 + struct vcmd_prio_bias vc_data;
22098 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22101 + return do_set_prio_bias(vxi, &vc_data);
22104 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22106 + struct vcmd_prio_bias vc_data;
22107 + struct _vx_sched_pc *pcd;
22110 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22113 + cpu = vc_data.cpu_id;
22115 + if (!cpu_possible(cpu))
22118 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22119 + vc_data.prio_bias = pcd->prio_bias;
22121 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22126 diff -NurpP --minimal linux-3.9.5/kernel/vserver/sched_init.h linux-3.9.5-vs2.3.6.5/kernel/vserver/sched_init.h
22127 --- linux-3.9.5/kernel/vserver/sched_init.h 1970-01-01 00:00:00.000000000 +0000
22128 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/sched_init.h 2013-05-31 14:47:11.000000000 +0000
22131 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22133 + /* scheduling; hard code starting values as constants */
22134 + sched->prio_bias = 0;
22138 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22140 + sched_pc->prio_bias = 0;
22142 + sched_pc->user_ticks = 0;
22143 + sched_pc->sys_ticks = 0;
22144 + sched_pc->hold_ticks = 0;
22147 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22153 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22157 diff -NurpP --minimal linux-3.9.5/kernel/vserver/sched_proc.h linux-3.9.5-vs2.3.6.5/kernel/vserver/sched_proc.h
22158 --- linux-3.9.5/kernel/vserver/sched_proc.h 1970-01-01 00:00:00.000000000 +0000
22159 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/sched_proc.h 2013-05-31 14:47:11.000000000 +0000
22161 +#ifndef _VX_SCHED_PROC_H
22162 +#define _VX_SCHED_PROC_H
22166 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22170 + length += sprintf(buffer,
22171 + "PrioBias:\t%8d\n",
22172 + sched->prio_bias);
22177 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22178 + char *buffer, int cpu)
22182 + length += sprintf(buffer + length,
22183 + "cpu %d: %lld %lld %lld", cpu,
22184 + (unsigned long long)sched_pc->user_ticks,
22185 + (unsigned long long)sched_pc->sys_ticks,
22186 + (unsigned long long)sched_pc->hold_ticks);
22187 + length += sprintf(buffer + length,
22188 + " %d\n", sched_pc->prio_bias);
22192 +#endif /* _VX_SCHED_PROC_H */
22193 diff -NurpP --minimal linux-3.9.5/kernel/vserver/signal.c linux-3.9.5-vs2.3.6.5/kernel/vserver/signal.c
22194 --- linux-3.9.5/kernel/vserver/signal.c 1970-01-01 00:00:00.000000000 +0000
22195 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/signal.c 2013-05-31 14:47:11.000000000 +0000
22198 + * linux/kernel/vserver/signal.c
22200 + * Virtual Server: Signal Support
22202 + * Copyright (C) 2003-2007 Herbert Pötzl
22204 + * V0.01 broken out from vcontext V0.05
22205 + * V0.02 changed vcmds to vxi arg
22206 + * V0.03 adjusted siginfo for kill
22210 +#include <asm/uaccess.h>
22212 +#include <linux/vs_context.h>
22213 +#include <linux/vs_pid.h>
22214 +#include <linux/vserver/signal_cmd.h>
22217 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22219 + int retval, count = 0;
22220 + struct task_struct *p;
22221 + struct siginfo *sip = SEND_SIG_PRIV;
22224 + vxdprintk(VXD_CBIT(misc, 4),
22225 + "vx_info_kill(%p[#%d],%d,%d)*",
22226 + vxi, vxi->vx_id, pid, sig);
22227 + read_lock(&tasklist_lock);
22231 + for_each_process(p) {
22234 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22235 + (pid && vxi->vx_initpid == p->pid))
22238 + err = group_send_sig_info(sig, sip, p);
22240 + if (err != -EPERM)
22246 + if (vxi->vx_initpid) {
22247 + pid = vxi->vx_initpid;
22248 + /* for now, only SIGINT to private init ... */
22249 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22250 + /* ... as long as there are tasks left */
22251 + (atomic_read(&vxi->vx_tasks) > 1))
22254 + /* fallthrough */
22257 + p = find_task_by_real_pid(pid);
22258 + rcu_read_unlock();
22260 + if (vx_task_xid(p) == vxi->vx_id)
22261 + retval = group_send_sig_info(sig, sip, p);
22265 + read_unlock(&tasklist_lock);
22266 + vxdprintk(VXD_CBIT(misc, 4),
22267 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22268 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22272 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22274 + struct vcmd_ctx_kill_v0 vc_data;
22276 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22279 + /* special check to allow guest shutdown */
22280 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22281 + /* forbid killall pid=0 when init is present */
22282 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22283 + (vc_data.pid > 1)))
22286 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22290 +static int __wait_exit(struct vx_info *vxi)
22292 + DECLARE_WAITQUEUE(wait, current);
22295 + add_wait_queue(&vxi->vx_wait, &wait);
22296 + set_current_state(TASK_INTERRUPTIBLE);
22299 + if (vx_info_state(vxi,
22300 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22302 + if (signal_pending(current)) {
22303 + ret = -ERESTARTSYS;
22310 + set_current_state(TASK_RUNNING);
22311 + remove_wait_queue(&vxi->vx_wait, &wait);
22317 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22319 + struct vcmd_wait_exit_v0 vc_data;
22322 + ret = __wait_exit(vxi);
22323 + vc_data.reboot_cmd = vxi->reboot_cmd;
22324 + vc_data.exit_code = vxi->exit_code;
22326 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22331 diff -NurpP --minimal linux-3.9.5/kernel/vserver/space.c linux-3.9.5-vs2.3.6.5/kernel/vserver/space.c
22332 --- linux-3.9.5/kernel/vserver/space.c 1970-01-01 00:00:00.000000000 +0000
22333 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/space.c 2013-05-31 14:47:11.000000000 +0000
22336 + * linux/kernel/vserver/space.c
22338 + * Virtual Server: Context Space Support
22340 + * Copyright (C) 2003-2010 Herbert Pötzl
22342 + * V0.01 broken out from context.c 0.07
22343 + * V0.02 added task locking for namespace
22344 + * V0.03 broken out vx_enter_namespace
22345 + * V0.04 added *space support and commands
22346 + * V0.05 added credential support
22350 +#include <linux/utsname.h>
22351 +#include <linux/nsproxy.h>
22352 +#include <linux/err.h>
22353 +#include <linux/fs_struct.h>
22354 +#include <linux/cred.h>
22355 +#include <asm/uaccess.h>
22357 +#include <linux/vs_context.h>
22358 +#include <linux/vserver/space.h>
22359 +#include <linux/vserver/space_cmd.h>
22361 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22362 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22363 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22364 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22365 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22366 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22369 +/* namespace functions */
22371 +#include <linux/mnt_namespace.h>
22372 +#include <linux/user_namespace.h>
22373 +#include <linux/pid_namespace.h>
22374 +#include <linux/ipc_namespace.h>
22375 +#include <net/net_namespace.h>
22376 +#include "../fs/mount.h"
22379 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22380 + .mask = CLONE_FS |
22382 +#ifdef CONFIG_UTS_NS
22385 +#ifdef CONFIG_IPC_NS
22388 +#ifdef CONFIG_USER_NS
22394 +static const struct vcmd_space_mask_v1 space_mask = {
22395 + .mask = CLONE_FS |
22397 +#ifdef CONFIG_UTS_NS
22400 +#ifdef CONFIG_IPC_NS
22403 +#ifdef CONFIG_USER_NS
22406 +#ifdef CONFIG_PID_NS
22409 +#ifdef CONFIG_NET_NS
22415 +static const struct vcmd_space_mask_v1 default_space_mask = {
22416 + .mask = CLONE_FS |
22418 +#ifdef CONFIG_UTS_NS
22421 +#ifdef CONFIG_IPC_NS
22424 +#ifdef CONFIG_USER_NS
22427 +#ifdef CONFIG_PID_NS
22434 + * build a new nsproxy mix
22435 + * assumes that both proxies are 'const'
22436 + * does not touch nsproxy refcounts
22437 + * will hold a reference on the result.
22440 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22441 + struct nsproxy *new_nsproxy, unsigned long mask)
22443 + struct mnt_namespace *old_ns;
22444 + struct uts_namespace *old_uts;
22445 + struct ipc_namespace *old_ipc;
22446 +#ifdef CONFIG_PID_NS
22447 + struct pid_namespace *old_pid;
22449 +#ifdef CONFIG_NET_NS
22450 + struct net *old_net;
22452 + struct nsproxy *nsproxy;
22454 + nsproxy = copy_nsproxy(old_nsproxy);
22458 + if (mask & CLONE_NEWNS) {
22459 + old_ns = nsproxy->mnt_ns;
22460 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22461 + if (nsproxy->mnt_ns)
22462 + get_mnt_ns(nsproxy->mnt_ns);
22466 + if (mask & CLONE_NEWUTS) {
22467 + old_uts = nsproxy->uts_ns;
22468 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22469 + if (nsproxy->uts_ns)
22470 + get_uts_ns(nsproxy->uts_ns);
22474 + if (mask & CLONE_NEWIPC) {
22475 + old_ipc = nsproxy->ipc_ns;
22476 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22477 + if (nsproxy->ipc_ns)
22478 + get_ipc_ns(nsproxy->ipc_ns);
22482 +#ifdef CONFIG_PID_NS
22483 + if (mask & CLONE_NEWPID) {
22484 + old_pid = nsproxy->pid_ns;
22485 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22486 + if (nsproxy->pid_ns)
22487 + get_pid_ns(nsproxy->pid_ns);
22491 +#ifdef CONFIG_NET_NS
22492 + if (mask & CLONE_NEWNET) {
22493 + old_net = nsproxy->net_ns;
22494 + nsproxy->net_ns = new_nsproxy->net_ns;
22495 + if (nsproxy->net_ns)
22496 + get_net(nsproxy->net_ns);
22501 + put_mnt_ns(old_ns);
22503 + put_uts_ns(old_uts);
22505 + put_ipc_ns(old_ipc);
22506 +#ifdef CONFIG_PID_NS
22508 + put_pid_ns(old_pid);
22510 +#ifdef CONFIG_NET_NS
22512 + put_net(old_net);
22520 + * merge two nsproxy structs into a new one.
22521 + * will hold a reference on the result.
22525 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22526 + struct nsproxy *proxy, unsigned long mask)
22528 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22534 + /* vs_mix_nsproxy returns with reference */
22535 + return vs_mix_nsproxy(old ? old : &null_proxy,
22538 + get_nsproxy(proxy);
22543 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22545 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22546 + struct fs_struct *fs_cur, *fs = NULL;
22547 + struct _vx_space *space;
22548 + int ret, kill = 0;
22550 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22551 + vxi, vxi->vx_id, mask, index);
22553 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22556 + if (index >= VX_SPACES)
22559 + space = &vxi->space[index];
22562 + mask = space->vx_nsmask;
22564 + if ((mask & space->vx_nsmask) != mask)
22567 + if (mask & CLONE_FS) {
22568 + fs = copy_fs_struct(space->vx_fs);
22572 + proxy = space->vx_nsproxy;
22574 + vxdprintk(VXD_CBIT(space, 9),
22575 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
22576 + vxi, vxi->vx_id, mask, index, proxy, fs);
22578 + task_lock(current);
22579 + fs_cur = current->fs;
22581 + if (mask & CLONE_FS) {
22582 + spin_lock(&fs_cur->lock);
22583 + current->fs = fs;
22584 + kill = !--fs_cur->users;
22585 + spin_unlock(&fs_cur->lock);
22588 + proxy_cur = current->nsproxy;
22589 + get_nsproxy(proxy_cur);
22590 + task_unlock(current);
22593 + free_fs_struct(fs_cur);
22595 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
22596 + if (IS_ERR(proxy_new)) {
22597 + ret = PTR_ERR(proxy_new);
22601 + proxy_new = xchg(¤t->nsproxy, proxy_new);
22603 + if (mask & CLONE_NEWUSER) {
22604 + struct cred *cred;
22606 + vxdprintk(VXD_CBIT(space, 10),
22607 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
22608 + vxi, vxi->vx_id, space->vx_cred,
22609 + current->real_cred, current->cred);
22611 + if (space->vx_cred) {
22612 + cred = __prepare_creds(space->vx_cred);
22614 + commit_creds(cred);
22621 + put_nsproxy(proxy_new);
22624 + put_nsproxy(proxy_cur);
22629 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22631 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
22632 + struct fs_struct *fs_vxi, *fs = NULL;
22633 + struct _vx_space *space;
22634 + int ret, kill = 0;
22636 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
22637 + vxi, vxi->vx_id, mask, index);
22639 + if ((mask & space_mask.mask) != mask)
22642 + if (index >= VX_SPACES)
22645 + space = &vxi->space[index];
22647 + proxy_vxi = space->vx_nsproxy;
22648 + fs_vxi = space->vx_fs;
22650 + if (mask & CLONE_FS) {
22651 + fs = copy_fs_struct(current->fs);
22656 + task_lock(current);
22658 + if (mask & CLONE_FS) {
22659 + spin_lock(&fs_vxi->lock);
22660 + space->vx_fs = fs;
22661 + kill = !--fs_vxi->users;
22662 + spin_unlock(&fs_vxi->lock);
22665 + proxy_cur = current->nsproxy;
22666 + get_nsproxy(proxy_cur);
22667 + task_unlock(current);
22670 + free_fs_struct(fs_vxi);
22672 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
22673 + if (IS_ERR(proxy_new)) {
22674 + ret = PTR_ERR(proxy_new);
22678 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
22679 + space->vx_nsmask |= mask;
22681 + if (mask & CLONE_NEWUSER) {
22682 + struct cred *cred;
22684 + vxdprintk(VXD_CBIT(space, 10),
22685 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
22686 + vxi, vxi->vx_id, space->vx_cred,
22687 + current->real_cred, current->cred);
22689 + cred = prepare_creds();
22690 + cred = (struct cred *)xchg(&space->vx_cred, cred);
22692 + abort_creds(cred);
22698 + put_nsproxy(proxy_new);
22701 + put_nsproxy(proxy_cur);
22706 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
22708 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22710 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22713 + return vx_enter_space(vxi, vc_data.mask, 0);
22716 +int vc_enter_space(struct vx_info *vxi, void __user *data)
22718 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22720 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22723 + if (vc_data.index >= VX_SPACES)
22726 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
22729 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
22731 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22733 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22736 + return vx_set_space(vxi, vc_data.mask, 0);
22739 +int vc_set_space(struct vx_info *vxi, void __user *data)
22741 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22743 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22746 + if (vc_data.index >= VX_SPACES)
22749 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
22752 +int vc_get_space_mask(void __user *data, int type)
22754 + const struct vcmd_space_mask_v1 *mask;
22757 + mask = &space_mask_v0;
22758 + else if (type == 1)
22759 + mask = &space_mask;
22761 + mask = &default_space_mask;
22763 + vxdprintk(VXD_CBIT(space, 10),
22764 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
22766 + if (copy_to_user(data, mask, sizeof(*mask)))
22771 diff -NurpP --minimal linux-3.9.5/kernel/vserver/switch.c linux-3.9.5-vs2.3.6.5/kernel/vserver/switch.c
22772 --- linux-3.9.5/kernel/vserver/switch.c 1970-01-01 00:00:00.000000000 +0000
22773 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/switch.c 2013-05-31 14:47:11.000000000 +0000
22776 + * linux/kernel/vserver/switch.c
22778 + * Virtual Server: Syscall Switch
22780 + * Copyright (C) 2003-2011 Herbert Pötzl
22782 + * V0.01 syscall switch
22783 + * V0.02 added signal to context
22784 + * V0.03 added rlimit functions
22785 + * V0.04 added iattr, task/xid functions
22786 + * V0.05 added debug/history stuff
22787 + * V0.06 added compat32 layer
22788 + * V0.07 vcmd args and perms
22789 + * V0.08 added status commands
22790 + * V0.09 added tag commands
22791 + * V0.10 added oom bias
22792 + * V0.11 added device commands
22793 + * V0.12 added warn mask
22797 +#include <linux/vs_context.h>
22798 +#include <linux/vs_network.h>
22799 +#include <linux/vserver/switch.h>
22801 +#include "vci_config.h"
22805 +int vc_get_version(uint32_t id)
22807 + return VCI_VERSION;
22811 +int vc_get_vci(uint32_t id)
22813 + return vci_kernel_config();
22816 +#include <linux/vserver/context_cmd.h>
22817 +#include <linux/vserver/cvirt_cmd.h>
22818 +#include <linux/vserver/cacct_cmd.h>
22819 +#include <linux/vserver/limit_cmd.h>
22820 +#include <linux/vserver/network_cmd.h>
22821 +#include <linux/vserver/sched_cmd.h>
22822 +#include <linux/vserver/debug_cmd.h>
22823 +#include <linux/vserver/inode_cmd.h>
22824 +#include <linux/vserver/dlimit_cmd.h>
22825 +#include <linux/vserver/signal_cmd.h>
22826 +#include <linux/vserver/space_cmd.h>
22827 +#include <linux/vserver/tag_cmd.h>
22828 +#include <linux/vserver/device_cmd.h>
22830 +#include <linux/vserver/inode.h>
22831 +#include <linux/vserver/dlimit.h>
22834 +#ifdef CONFIG_COMPAT
22835 +#define __COMPAT(name, id, data, compat) \
22836 + (compat) ? name ## _x32(id, data) : name(id, data)
22837 +#define __COMPAT_NO_ID(name, data, compat) \
22838 + (compat) ? name ## _x32(data) : name(data)
22840 +#define __COMPAT(name, id, data, compat) \
22842 +#define __COMPAT_NO_ID(name, data, compat) \
22848 +long do_vcmd(uint32_t cmd, uint32_t id,
22849 + struct vx_info *vxi, struct nx_info *nxi,
22850 + void __user *data, int compat)
22854 + case VCMD_get_version:
22855 + return vc_get_version(id);
22856 + case VCMD_get_vci:
22857 + return vc_get_vci(id);
22859 + case VCMD_task_xid:
22860 + return vc_task_xid(id);
22861 + case VCMD_vx_info:
22862 + return vc_vx_info(vxi, data);
22864 + case VCMD_task_nid:
22865 + return vc_task_nid(id);
22866 + case VCMD_nx_info:
22867 + return vc_nx_info(nxi, data);
22869 + case VCMD_task_tag:
22870 + return vc_task_tag(id);
22872 + case VCMD_set_space_v1:
22873 + return vc_set_space_v1(vxi, data);
22874 + /* this is version 2 */
22875 + case VCMD_set_space:
22876 + return vc_set_space(vxi, data);
22878 + case VCMD_get_space_mask_v0:
22879 + return vc_get_space_mask(data, 0);
22880 + /* this is version 1 */
22881 + case VCMD_get_space_mask:
22882 + return vc_get_space_mask(data, 1);
22884 + case VCMD_get_space_default:
22885 + return vc_get_space_mask(data, -1);
22887 + case VCMD_set_umask:
22888 + return vc_set_umask(vxi, data);
22890 + case VCMD_get_umask:
22891 + return vc_get_umask(vxi, data);
22893 + case VCMD_set_wmask:
22894 + return vc_set_wmask(vxi, data);
22896 + case VCMD_get_wmask:
22897 + return vc_get_wmask(vxi, data);
22898 +#ifdef CONFIG_IA32_EMULATION
22899 + case VCMD_get_rlimit:
22900 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
22901 + case VCMD_set_rlimit:
22902 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
22904 + case VCMD_get_rlimit:
22905 + return vc_get_rlimit(vxi, data);
22906 + case VCMD_set_rlimit:
22907 + return vc_set_rlimit(vxi, data);
22909 + case VCMD_get_rlimit_mask:
22910 + return vc_get_rlimit_mask(id, data);
22911 + case VCMD_reset_hits:
22912 + return vc_reset_hits(vxi, data);
22913 + case VCMD_reset_minmax:
22914 + return vc_reset_minmax(vxi, data);
22916 + case VCMD_get_vhi_name:
22917 + return vc_get_vhi_name(vxi, data);
22918 + case VCMD_set_vhi_name:
22919 + return vc_set_vhi_name(vxi, data);
22921 + case VCMD_ctx_stat:
22922 + return vc_ctx_stat(vxi, data);
22923 + case VCMD_virt_stat:
22924 + return vc_virt_stat(vxi, data);
22925 + case VCMD_sock_stat:
22926 + return vc_sock_stat(vxi, data);
22927 + case VCMD_rlimit_stat:
22928 + return vc_rlimit_stat(vxi, data);
22930 + case VCMD_set_cflags:
22931 + return vc_set_cflags(vxi, data);
22932 + case VCMD_get_cflags:
22933 + return vc_get_cflags(vxi, data);
22935 + /* this is version 1 */
22936 + case VCMD_set_ccaps:
22937 + return vc_set_ccaps(vxi, data);
22938 + /* this is version 1 */
22939 + case VCMD_get_ccaps:
22940 + return vc_get_ccaps(vxi, data);
22941 + case VCMD_set_bcaps:
22942 + return vc_set_bcaps(vxi, data);
22943 + case VCMD_get_bcaps:
22944 + return vc_get_bcaps(vxi, data);
22946 + case VCMD_set_badness:
22947 + return vc_set_badness(vxi, data);
22948 + case VCMD_get_badness:
22949 + return vc_get_badness(vxi, data);
22951 + case VCMD_set_nflags:
22952 + return vc_set_nflags(nxi, data);
22953 + case VCMD_get_nflags:
22954 + return vc_get_nflags(nxi, data);
22956 + case VCMD_set_ncaps:
22957 + return vc_set_ncaps(nxi, data);
22958 + case VCMD_get_ncaps:
22959 + return vc_get_ncaps(nxi, data);
22961 + case VCMD_set_prio_bias:
22962 + return vc_set_prio_bias(vxi, data);
22963 + case VCMD_get_prio_bias:
22964 + return vc_get_prio_bias(vxi, data);
22965 + case VCMD_add_dlimit:
22966 + return __COMPAT(vc_add_dlimit, id, data, compat);
22967 + case VCMD_rem_dlimit:
22968 + return __COMPAT(vc_rem_dlimit, id, data, compat);
22969 + case VCMD_set_dlimit:
22970 + return __COMPAT(vc_set_dlimit, id, data, compat);
22971 + case VCMD_get_dlimit:
22972 + return __COMPAT(vc_get_dlimit, id, data, compat);
22974 + case VCMD_ctx_kill:
22975 + return vc_ctx_kill(vxi, data);
22977 + case VCMD_wait_exit:
22978 + return vc_wait_exit(vxi, data);
22980 + case VCMD_get_iattr:
22981 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
22982 + case VCMD_set_iattr:
22983 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
22985 + case VCMD_fget_iattr:
22986 + return vc_fget_iattr(id, data);
22987 + case VCMD_fset_iattr:
22988 + return vc_fset_iattr(id, data);
22990 + case VCMD_enter_space_v0:
22991 + return vc_enter_space_v1(vxi, NULL);
22992 + case VCMD_enter_space_v1:
22993 + return vc_enter_space_v1(vxi, data);
22994 + /* this is version 2 */
22995 + case VCMD_enter_space:
22996 + return vc_enter_space(vxi, data);
22998 + case VCMD_ctx_create_v0:
22999 + return vc_ctx_create(id, NULL);
23000 + case VCMD_ctx_create:
23001 + return vc_ctx_create(id, data);
23002 + case VCMD_ctx_migrate_v0:
23003 + return vc_ctx_migrate(vxi, NULL);
23004 + case VCMD_ctx_migrate:
23005 + return vc_ctx_migrate(vxi, data);
23007 + case VCMD_net_create_v0:
23008 + return vc_net_create(id, NULL);
23009 + case VCMD_net_create:
23010 + return vc_net_create(id, data);
23011 + case VCMD_net_migrate:
23012 + return vc_net_migrate(nxi, data);
23014 + case VCMD_tag_migrate:
23015 + return vc_tag_migrate(id);
23017 + case VCMD_net_add:
23018 + return vc_net_add(nxi, data);
23019 + case VCMD_net_remove:
23020 + return vc_net_remove(nxi, data);
23022 + case VCMD_net_add_ipv4_v1:
23023 + return vc_net_add_ipv4_v1(nxi, data);
23024 + /* this is version 2 */
23025 + case VCMD_net_add_ipv4:
23026 + return vc_net_add_ipv4(nxi, data);
23028 + case VCMD_net_rem_ipv4_v1:
23029 + return vc_net_rem_ipv4_v1(nxi, data);
23030 + /* this is version 2 */
23031 + case VCMD_net_rem_ipv4:
23032 + return vc_net_rem_ipv4(nxi, data);
23033 +#ifdef CONFIG_IPV6
23034 + case VCMD_net_add_ipv6:
23035 + return vc_net_add_ipv6(nxi, data);
23036 + case VCMD_net_remove_ipv6:
23037 + return vc_net_remove_ipv6(nxi, data);
23039 +/* case VCMD_add_match_ipv4:
23040 + return vc_add_match_ipv4(nxi, data);
23041 + case VCMD_get_match_ipv4:
23042 + return vc_get_match_ipv4(nxi, data);
23043 +#ifdef CONFIG_IPV6
23044 + case VCMD_add_match_ipv6:
23045 + return vc_add_match_ipv6(nxi, data);
23046 + case VCMD_get_match_ipv6:
23047 + return vc_get_match_ipv6(nxi, data);
23050 +#ifdef CONFIG_VSERVER_DEVICE
23051 + case VCMD_set_mapping:
23052 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23053 + case VCMD_unset_mapping:
23054 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23056 +#ifdef CONFIG_VSERVER_HISTORY
23057 + case VCMD_dump_history:
23058 + return vc_dump_history(id);
23059 + case VCMD_read_history:
23060 + return __COMPAT(vc_read_history, id, data, compat);
23063 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23064 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23070 +#define __VCMD(vcmd, _perm, _args, _flags) \
23071 + case VCMD_ ## vcmd: perm = _perm; \
23072 + args = _args; flags = _flags; break
23075 +#define VCA_NONE 0x00
23076 +#define VCA_VXI 0x01
23077 +#define VCA_NXI 0x02
23079 +#define VCF_NONE 0x00
23080 +#define VCF_INFO 0x01
23081 +#define VCF_ADMIN 0x02
23082 +#define VCF_ARES 0x06 /* includes admin */
23083 +#define VCF_SETUP 0x08
23085 +#define VCF_ZIDOK 0x10 /* zero id okay */
23089 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23092 + int permit = -1, state = 0;
23093 + int perm = -1, args = 0, flags = 0;
23094 + struct vx_info *vxi = NULL;
23095 + struct nx_info *nxi = NULL;
23098 + /* unpriviledged commands */
23099 + __VCMD(get_version, 0, VCA_NONE, 0);
23100 + __VCMD(get_vci, 0, VCA_NONE, 0);
23101 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23102 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23103 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23104 + __VCMD(get_space_default,0, VCA_NONE, 0);
23106 + /* info commands */
23107 + __VCMD(task_xid, 2, VCA_NONE, 0);
23108 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23109 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23110 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23111 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23112 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23113 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23114 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23115 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23116 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23117 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23118 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23120 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23121 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23122 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23123 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23125 + __VCMD(task_nid, 2, VCA_NONE, 0);
23126 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23127 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23128 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23130 + __VCMD(task_tag, 2, VCA_NONE, 0);
23132 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23133 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23134 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23135 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23137 + /* lower admin commands */
23138 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23139 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23140 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23141 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23142 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23143 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23144 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23145 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23147 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23148 + __VCMD(net_create, 5, VCA_NONE, 0);
23149 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23151 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23153 + /* higher admin commands */
23154 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23155 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23156 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23158 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23159 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23160 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23161 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23162 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23163 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23165 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23166 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23167 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23169 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23170 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23171 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23172 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23173 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23174 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23175 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23176 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23177 +#ifdef CONFIG_IPV6
23178 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23179 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23181 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23182 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23183 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23184 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23185 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23187 +#ifdef CONFIG_VSERVER_DEVICE
23188 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23189 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23191 + /* debug level admin commands */
23192 +#ifdef CONFIG_VSERVER_HISTORY
23193 + __VCMD(dump_history, 9, VCA_NONE, 0);
23194 + __VCMD(read_history, 9, VCA_NONE, 0);
23201 + vxdprintk(VXD_CBIT(switch, 0),
23202 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23203 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23204 + VC_VERSION(cmd), id, data, compat,
23205 + perm, args, flags);
23212 + if (!capable(CAP_CONTEXT))
23216 + /* moved here from the individual commands */
23218 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23222 + /* vcmd involves resource management */
23224 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23228 + /* various legacy exceptions */
23230 + /* will go away when spectator is a cap */
23231 + case VCMD_ctx_migrate_v0:
23232 + case VCMD_ctx_migrate:
23234 + current->xid = 1;
23240 + /* will go away when spectator is a cap */
23241 + case VCMD_net_migrate:
23243 + current->nid = 1;
23250 + /* vcmds are fine by default */
23253 + /* admin type vcmds require admin ... */
23254 + if (flags & VCF_ADMIN)
23255 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23257 + /* ... but setup type vcmds override that */
23258 + if (!permit && (flags & VCF_SETUP))
23259 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23267 + if (!id && (flags & VCF_ZIDOK))
23271 + if (args & VCA_VXI) {
23272 + vxi = lookup_vx_info(id);
23276 + if ((flags & VCF_ADMIN) &&
23277 + /* special case kill for shutdown */
23278 + (cmd != VCMD_ctx_kill) &&
23279 + /* can context be administrated? */
23280 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23286 + if (args & VCA_NXI) {
23287 + nxi = lookup_nx_info(id);
23291 + if ((flags & VCF_ADMIN) &&
23292 + /* can context be administrated? */
23293 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23300 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23303 + if ((args & VCA_NXI) && nxi)
23304 + put_nx_info(nxi);
23306 + if ((args & VCA_VXI) && vxi)
23307 + put_vx_info(vxi);
23309 + vxdprintk(VXD_CBIT(switch, 1),
23310 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23311 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23312 + VC_VERSION(cmd), ret, ret, state, permit);
23317 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23319 + return do_vserver(cmd, id, data, 0);
23322 +#ifdef CONFIG_COMPAT
23325 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23327 + return do_vserver(cmd, id, data, 1);
23330 +#endif /* CONFIG_COMPAT */
23331 diff -NurpP --minimal linux-3.9.5/kernel/vserver/sysctl.c linux-3.9.5-vs2.3.6.5/kernel/vserver/sysctl.c
23332 --- linux-3.9.5/kernel/vserver/sysctl.c 1970-01-01 00:00:00.000000000 +0000
23333 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/sysctl.c 2013-05-31 14:47:11.000000000 +0000
23336 + * kernel/vserver/sysctl.c
23338 + * Virtual Context Support
23340 + * Copyright (C) 2004-2007 Herbert Pötzl
23342 + * V0.01 basic structure
23346 +#include <linux/module.h>
23347 +#include <linux/ctype.h>
23348 +#include <linux/sysctl.h>
23349 +#include <linux/parser.h>
23350 +#include <asm/uaccess.h>
23353 + CTL_DEBUG_ERROR = 0,
23354 + CTL_DEBUG_SWITCH = 1,
23370 +unsigned int vs_debug_switch = 0;
23371 +unsigned int vs_debug_xid = 0;
23372 +unsigned int vs_debug_nid = 0;
23373 +unsigned int vs_debug_tag = 0;
23374 +unsigned int vs_debug_net = 0;
23375 +unsigned int vs_debug_limit = 0;
23376 +unsigned int vs_debug_cres = 0;
23377 +unsigned int vs_debug_dlim = 0;
23378 +unsigned int vs_debug_quota = 0;
23379 +unsigned int vs_debug_cvirt = 0;
23380 +unsigned int vs_debug_space = 0;
23381 +unsigned int vs_debug_perm = 0;
23382 +unsigned int vs_debug_misc = 0;
23385 +static struct ctl_table_header *vserver_table_header;
23386 +static ctl_table vserver_root_table[];
23389 +void vserver_register_sysctl(void)
23391 + if (!vserver_table_header) {
23392 + vserver_table_header = register_sysctl_table(vserver_root_table);
23397 +void vserver_unregister_sysctl(void)
23399 + if (vserver_table_header) {
23400 + unregister_sysctl_table(vserver_table_header);
23401 + vserver_table_header = NULL;
23406 +static int proc_dodebug(ctl_table *table, int write,
23407 + void __user *buffer, size_t *lenp, loff_t *ppos)
23409 + char tmpbuf[20], *p, c;
23410 + unsigned int value;
23411 + size_t left, len;
23413 + if ((*ppos && !write) || !*lenp) {
23421 + if (!access_ok(VERIFY_READ, buffer, left))
23423 + p = (char *)buffer;
23424 + while (left && __get_user(c, p) >= 0 && isspace(c))
23429 + if (left > sizeof(tmpbuf) - 1)
23431 + if (copy_from_user(tmpbuf, p, left))
23433 + tmpbuf[left] = '\0';
23435 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23436 + value = 10 * value + (*p - '0');
23437 + if (*p && !isspace(*p))
23439 + while (left && isspace(*p))
23441 + *(unsigned int *)table->data = value;
23443 + if (!access_ok(VERIFY_WRITE, buffer, left))
23445 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23448 + if (__copy_to_user(buffer, tmpbuf, len))
23450 + if ((left -= len) > 0) {
23451 + if (put_user('\n', (char *)buffer + len))
23465 +#define CTL_ENTRY(ctl, name) \
23467 + .procname = #name, \
23468 + .data = &vs_ ## name, \
23469 + .maxlen = sizeof(int), \
23471 + .proc_handler = &proc_dodebug, \
23472 + .extra1 = &zero, \
23473 + .extra2 = &zero, \
23476 +static ctl_table vserver_debug_table[] = {
23477 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23478 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23479 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23480 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23481 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23482 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23483 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23484 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23485 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23486 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23487 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23488 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23489 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23493 +static ctl_table vserver_root_table[] = {
23495 + .procname = "vserver",
23497 + .child = vserver_debug_table
23503 +static match_table_t tokens = {
23504 + { CTL_DEBUG_SWITCH, "switch=%x" },
23505 + { CTL_DEBUG_XID, "xid=%x" },
23506 + { CTL_DEBUG_NID, "nid=%x" },
23507 + { CTL_DEBUG_TAG, "tag=%x" },
23508 + { CTL_DEBUG_NET, "net=%x" },
23509 + { CTL_DEBUG_LIMIT, "limit=%x" },
23510 + { CTL_DEBUG_CRES, "cres=%x" },
23511 + { CTL_DEBUG_DLIM, "dlim=%x" },
23512 + { CTL_DEBUG_QUOTA, "quota=%x" },
23513 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23514 + { CTL_DEBUG_SPACE, "space=%x" },
23515 + { CTL_DEBUG_PERM, "perm=%x" },
23516 + { CTL_DEBUG_MISC, "misc=%x" },
23517 + { CTL_DEBUG_ERROR, NULL }
23520 +#define HANDLE_CASE(id, name, val) \
23521 + case CTL_DEBUG_ ## id: \
23522 + vs_debug_ ## name = val; \
23523 + printk("vs_debug_" #name "=0x%x\n", val); \
23527 +static int __init vs_debug_setup(char *str)
23532 + printk("vs_debug_setup(%s)\n", str);
23533 + while ((p = strsep(&str, ",")) != NULL) {
23534 + substring_t args[MAX_OPT_ARGS];
23535 + unsigned int value;
23540 + token = match_token(p, tokens, args);
23541 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23544 + HANDLE_CASE(SWITCH, switch, value);
23545 + HANDLE_CASE(XID, xid, value);
23546 + HANDLE_CASE(NID, nid, value);
23547 + HANDLE_CASE(TAG, tag, value);
23548 + HANDLE_CASE(NET, net, value);
23549 + HANDLE_CASE(LIMIT, limit, value);
23550 + HANDLE_CASE(CRES, cres, value);
23551 + HANDLE_CASE(DLIM, dlim, value);
23552 + HANDLE_CASE(QUOTA, quota, value);
23553 + HANDLE_CASE(CVIRT, cvirt, value);
23554 + HANDLE_CASE(SPACE, space, value);
23555 + HANDLE_CASE(PERM, perm, value);
23556 + HANDLE_CASE(MISC, misc, value);
23565 +__setup("vsdebug=", vs_debug_setup);
23569 +EXPORT_SYMBOL_GPL(vs_debug_switch);
23570 +EXPORT_SYMBOL_GPL(vs_debug_xid);
23571 +EXPORT_SYMBOL_GPL(vs_debug_nid);
23572 +EXPORT_SYMBOL_GPL(vs_debug_net);
23573 +EXPORT_SYMBOL_GPL(vs_debug_limit);
23574 +EXPORT_SYMBOL_GPL(vs_debug_cres);
23575 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
23576 +EXPORT_SYMBOL_GPL(vs_debug_quota);
23577 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
23578 +EXPORT_SYMBOL_GPL(vs_debug_space);
23579 +EXPORT_SYMBOL_GPL(vs_debug_perm);
23580 +EXPORT_SYMBOL_GPL(vs_debug_misc);
23582 diff -NurpP --minimal linux-3.9.5/kernel/vserver/tag.c linux-3.9.5-vs2.3.6.5/kernel/vserver/tag.c
23583 --- linux-3.9.5/kernel/vserver/tag.c 1970-01-01 00:00:00.000000000 +0000
23584 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/tag.c 2013-06-12 23:49:09.000000000 +0000
23587 + * linux/kernel/vserver/tag.c
23589 + * Virtual Server: Shallow Tag Space
23591 + * Copyright (C) 2007 Herbert Pötzl
23593 + * V0.01 basic implementation
23597 +#include <linux/sched.h>
23598 +#include <linux/vserver/debug.h>
23599 +#include <linux/vs_pid.h>
23600 +#include <linux/vs_tag.h>
23602 +#include <linux/vserver/tag_cmd.h>
23605 +int dx_migrate_task(struct task_struct *p, vtag_t tag)
23610 + vxdprintk(VXD_CBIT(tag, 5),
23611 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23617 + vxdprintk(VXD_CBIT(tag, 5),
23618 + "moved task %p into [#%d]", p, tag);
23622 +/* vserver syscall commands below here */
23624 +/* taks xid and vx_info functions */
23627 +int vc_task_tag(uint32_t id)
23632 + struct task_struct *tsk;
23634 + tsk = find_task_by_real_pid(id);
23635 + tag = (tsk) ? tsk->tag : -ESRCH;
23636 + rcu_read_unlock();
23638 + tag = dx_current_tag();
23643 +int vc_tag_migrate(uint32_t tag)
23645 + return dx_migrate_task(current, tag & 0xFFFF);
23649 diff -NurpP --minimal linux-3.9.5/kernel/vserver/vci_config.h linux-3.9.5-vs2.3.6.5/kernel/vserver/vci_config.h
23650 --- linux-3.9.5/kernel/vserver/vci_config.h 1970-01-01 00:00:00.000000000 +0000
23651 +++ linux-3.9.5-vs2.3.6.5/kernel/vserver/vci_config.h 2013-05-31 14:47:11.000000000 +0000
23654 +/* interface version */
23656 +#define VCI_VERSION 0x00020308
23660 + VCI_KCBIT_NO_DYNAMIC = 0,
23662 + VCI_KCBIT_PROC_SECURE = 4,
23663 + /* VCI_KCBIT_HARDCPU = 5, */
23664 + /* VCI_KCBIT_IDLELIMIT = 6, */
23665 + /* VCI_KCBIT_IDLETIME = 7, */
23667 + VCI_KCBIT_COWBL = 8,
23668 + VCI_KCBIT_FULLCOWBL = 9,
23669 + VCI_KCBIT_SPACES = 10,
23670 + VCI_KCBIT_NETV2 = 11,
23671 + VCI_KCBIT_MEMCG = 12,
23672 + VCI_KCBIT_MEMCG_SWAP = 13,
23674 + VCI_KCBIT_DEBUG = 16,
23675 + VCI_KCBIT_HISTORY = 20,
23676 + VCI_KCBIT_TAGGED = 24,
23677 + VCI_KCBIT_PPTAG = 28,
23679 + VCI_KCBIT_MORE = 31,
23683 +static inline uint32_t vci_kernel_config(void)
23686 + (1 << VCI_KCBIT_NO_DYNAMIC) |
23688 + /* configured features */
23689 +#ifdef CONFIG_VSERVER_PROC_SECURE
23690 + (1 << VCI_KCBIT_PROC_SECURE) |
23692 +#ifdef CONFIG_VSERVER_COWBL
23693 + (1 << VCI_KCBIT_COWBL) |
23694 + (1 << VCI_KCBIT_FULLCOWBL) |
23696 + (1 << VCI_KCBIT_SPACES) |
23697 + (1 << VCI_KCBIT_NETV2) |
23698 +#ifdef CONFIG_MEMCG
23699 + (1 << VCI_KCBIT_MEMCG) |
23701 +#ifdef CONFIG_MEMCG_SWAP
23702 + (1 << VCI_KCBIT_MEMCG_SWAP) |
23705 + /* debug options */
23706 +#ifdef CONFIG_VSERVER_DEBUG
23707 + (1 << VCI_KCBIT_DEBUG) |
23709 +#ifdef CONFIG_VSERVER_HISTORY
23710 + (1 << VCI_KCBIT_HISTORY) |
23713 + /* inode context tagging */
23714 +#if defined(CONFIG_TAGGING_NONE)
23715 + (0 << VCI_KCBIT_TAGGED) |
23716 +#elif defined(CONFIG_TAGGING_UID16)
23717 + (1 << VCI_KCBIT_TAGGED) |
23718 +#elif defined(CONFIG_TAGGING_GID16)
23719 + (2 << VCI_KCBIT_TAGGED) |
23720 +#elif defined(CONFIG_TAGGING_ID24)
23721 + (3 << VCI_KCBIT_TAGGED) |
23722 +#elif defined(CONFIG_TAGGING_INTERN)
23723 + (4 << VCI_KCBIT_TAGGED) |
23724 +#elif defined(CONFIG_TAGGING_RUNTIME)
23725 + (5 << VCI_KCBIT_TAGGED) |
23727 + (7 << VCI_KCBIT_TAGGED) |
23729 + (1 << VCI_KCBIT_PPTAG) |
23733 diff -NurpP --minimal linux-3.9.5/mm/memcontrol.c linux-3.9.5-vs2.3.6.5/mm/memcontrol.c
23734 --- linux-3.9.5/mm/memcontrol.c 2013-06-11 12:22:40.000000000 +0000
23735 +++ linux-3.9.5-vs2.3.6.5/mm/memcontrol.c 2013-06-13 00:14:32.000000000 +0000
23736 @@ -1046,6 +1046,31 @@ struct mem_cgroup *mem_cgroup_from_task(
23737 return mem_cgroup_from_css(task_subsys_state(p, mem_cgroup_subsys_id));
23740 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
23742 + return res_counter_read_u64(&mem->res, member);
23745 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
23747 + return res_counter_read_u64(&mem->memsw, member);
23750 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
23752 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
23755 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
23757 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
23760 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
23762 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
23765 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
23767 struct mem_cgroup *memcg = NULL;
23768 diff -NurpP --minimal linux-3.9.5/mm/oom_kill.c linux-3.9.5-vs2.3.6.5/mm/oom_kill.c
23769 --- linux-3.9.5/mm/oom_kill.c 2013-05-31 13:45:31.000000000 +0000
23770 +++ linux-3.9.5-vs2.3.6.5/mm/oom_kill.c 2013-05-31 14:47:11.000000000 +0000
23772 #include <linux/freezer.h>
23773 #include <linux/ftrace.h>
23774 #include <linux/ratelimit.h>
23775 +#include <linux/reboot.h>
23776 +#include <linux/vs_context.h>
23778 #define CREATE_TRACE_POINTS
23779 #include <trace/events/oom.h>
23780 @@ -113,11 +115,18 @@ struct task_struct *find_lock_task_mm(st
23781 static bool oom_unkillable_task(struct task_struct *p,
23782 const struct mem_cgroup *memcg, const nodemask_t *nodemask)
23784 - if (is_global_init(p))
23785 + unsigned xid = vx_current_xid();
23787 + /* skip the init task, global and per guest */
23788 + if (task_is_init(p))
23790 if (p->flags & PF_KTHREAD)
23793 + /* skip other guest and host processes if oom in guest */
23794 + if (xid && vx_task_xid(p) != xid)
23797 /* When mem_cgroup_out_of_memory() and p is not member of the group */
23798 if (memcg && !task_in_mem_cgroup(p, memcg))
23800 @@ -426,8 +435,8 @@ void oom_kill_process(struct task_struct
23801 dump_header(p, gfp_mask, order, memcg, nodemask);
23804 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
23805 - message, task_pid_nr(p), p->comm, points);
23806 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
23807 + message, task_pid_nr(p), p->xid, p->comm, points);
23811 @@ -472,8 +481,8 @@ void oom_kill_process(struct task_struct
23813 /* mm cannot safely be dereferenced after task_unlock(victim) */
23815 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23816 - task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
23817 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23818 + task_pid_nr(victim), victim->xid, victim->comm, K(victim->mm->total_vm),
23819 K(get_mm_counter(victim->mm, MM_ANONPAGES)),
23820 K(get_mm_counter(victim->mm, MM_FILEPAGES)));
23821 task_unlock(victim);
23822 @@ -543,6 +552,8 @@ int unregister_oom_notifier(struct notif
23824 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
23826 +long vs_oom_action(unsigned int);
23829 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
23830 * if a parallel OOM killing is already taking place that includes a zone in
23831 @@ -655,7 +666,12 @@ void out_of_memory(struct zonelist *zone
23832 /* Found nothing?!?! Either we hang forever, or we panic. */
23834 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
23835 - panic("Out of memory and no killable processes...\n");
23837 + /* avoid panic for guest OOM */
23838 + if (vx_current_xid())
23839 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
23841 + panic("Out of memory and no killable processes...\n");
23843 if (PTR_ERR(p) != -1UL) {
23844 oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
23845 diff -NurpP --minimal linux-3.9.5/mm/page_alloc.c linux-3.9.5-vs2.3.6.5/mm/page_alloc.c
23846 --- linux-3.9.5/mm/page_alloc.c 2013-05-31 13:45:31.000000000 +0000
23847 +++ linux-3.9.5-vs2.3.6.5/mm/page_alloc.c 2013-05-31 15:08:50.000000000 +0000
23849 #include <linux/migrate.h>
23850 #include <linux/page-debug-flags.h>
23851 #include <linux/sched/rt.h>
23852 +#include <linux/vs_base.h>
23853 +#include <linux/vs_limit.h>
23855 #include <asm/tlbflush.h>
23856 #include <asm/div64.h>
23857 @@ -2873,6 +2875,9 @@ void si_meminfo(struct sysinfo *val)
23858 val->totalhigh = totalhigh_pages;
23859 val->freehigh = nr_free_highpages();
23860 val->mem_unit = PAGE_SIZE;
23862 + if (vx_flags(VXF_VIRT_MEM, 0))
23863 + vx_vsi_meminfo(val);
23866 EXPORT_SYMBOL(si_meminfo);
23867 @@ -2893,6 +2898,9 @@ void si_meminfo_node(struct sysinfo *val
23870 val->mem_unit = PAGE_SIZE;
23872 + if (vx_flags(VXF_VIRT_MEM, 0))
23873 + vx_vsi_meminfo(val);
23877 diff -NurpP --minimal linux-3.9.5/mm/pgtable-generic.c linux-3.9.5-vs2.3.6.5/mm/pgtable-generic.c
23878 --- linux-3.9.5/mm/pgtable-generic.c 2013-02-19 13:58:57.000000000 +0000
23879 +++ linux-3.9.5-vs2.3.6.5/mm/pgtable-generic.c 2013-05-31 14:47:11.000000000 +0000
23881 * Copyright (C) 2010 Linus Torvalds
23884 +#include <linux/mm.h>
23886 #include <linux/pagemap.h>
23887 #include <asm/tlb.h>
23888 #include <asm-generic/pgtable.h>
23889 diff -NurpP --minimal linux-3.9.5/mm/shmem.c linux-3.9.5-vs2.3.6.5/mm/shmem.c
23890 --- linux-3.9.5/mm/shmem.c 2013-05-31 13:45:31.000000000 +0000
23891 +++ linux-3.9.5-vs2.3.6.5/mm/shmem.c 2013-05-31 14:47:11.000000000 +0000
23892 @@ -1909,7 +1909,7 @@ static int shmem_statfs(struct dentry *d
23894 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
23896 - buf->f_type = TMPFS_MAGIC;
23897 + buf->f_type = TMPFS_SUPER_MAGIC;
23898 buf->f_bsize = PAGE_CACHE_SIZE;
23899 buf->f_namelen = NAME_MAX;
23900 if (sbinfo->max_blocks) {
23901 @@ -2606,7 +2606,7 @@ int shmem_fill_super(struct super_block
23902 sb->s_maxbytes = MAX_LFS_FILESIZE;
23903 sb->s_blocksize = PAGE_CACHE_SIZE;
23904 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
23905 - sb->s_magic = TMPFS_MAGIC;
23906 + sb->s_magic = TMPFS_SUPER_MAGIC;
23907 sb->s_op = &shmem_ops;
23908 sb->s_time_gran = 1;
23909 #ifdef CONFIG_TMPFS_XATTR
23910 diff -NurpP --minimal linux-3.9.5/mm/slab.c linux-3.9.5-vs2.3.6.5/mm/slab.c
23911 --- linux-3.9.5/mm/slab.c 2013-05-31 13:45:31.000000000 +0000
23912 +++ linux-3.9.5-vs2.3.6.5/mm/slab.c 2013-05-31 14:47:11.000000000 +0000
23913 @@ -429,6 +429,8 @@ static void kmem_list3_init(struct kmem_
23914 #define STATS_INC_FREEMISS(x) do { } while (0)
23917 +#include "slab_vs.h"
23922 @@ -3438,6 +3440,7 @@ retry:
23924 obj = slab_get_obj(cachep, slabp, nodeid);
23925 check_slabp(cachep, slabp);
23926 + vx_slab_alloc(cachep, flags);
23927 l3->free_objects--;
23928 /* move slabp to correct slabp list: */
23929 list_del(&slabp->list);
23930 @@ -3517,6 +3520,7 @@ slab_alloc_node(struct kmem_cache *cache
23931 /* ___cache_alloc_node can fall back to other nodes */
23932 ptr = ____cache_alloc_node(cachep, flags, nodeid);
23934 + vx_slab_alloc(cachep, flags);
23935 local_irq_restore(save_flags);
23936 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
23937 kmemleak_alloc_recursive(ptr, cachep->object_size, 1, cachep->flags,
23938 @@ -3709,6 +3713,7 @@ static inline void __cache_free(struct k
23940 kmemleak_free_recursive(objp, cachep->flags);
23941 objp = cache_free_debugcheck(cachep, objp, caller);
23942 + vx_slab_free(cachep);
23944 kmemcheck_slab_free(cachep, objp, cachep->object_size);
23946 diff -NurpP --minimal linux-3.9.5/mm/slab_vs.h linux-3.9.5-vs2.3.6.5/mm/slab_vs.h
23947 --- linux-3.9.5/mm/slab_vs.h 1970-01-01 00:00:00.000000000 +0000
23948 +++ linux-3.9.5-vs2.3.6.5/mm/slab_vs.h 2013-05-31 14:47:11.000000000 +0000
23951 +#include <linux/vserver/context.h>
23953 +#include <linux/vs_context.h>
23956 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
23958 + int what = gfp_zone(cachep->allocflags);
23959 + struct vx_info *vxi = current_vx_info();
23964 + atomic_add(cachep->size, &vxi->cacct.slab[what]);
23968 +void vx_slab_free(struct kmem_cache *cachep)
23970 + int what = gfp_zone(cachep->allocflags);
23971 + struct vx_info *vxi = current_vx_info();
23976 + atomic_sub(cachep->size, &vxi->cacct.slab[what]);
23979 diff -NurpP --minimal linux-3.9.5/mm/swapfile.c linux-3.9.5-vs2.3.6.5/mm/swapfile.c
23980 --- linux-3.9.5/mm/swapfile.c 2013-05-31 13:45:31.000000000 +0000
23981 +++ linux-3.9.5-vs2.3.6.5/mm/swapfile.c 2013-05-31 14:47:11.000000000 +0000
23983 #include <asm/tlbflush.h>
23984 #include <linux/swapops.h>
23985 #include <linux/page_cgroup.h>
23986 +#include <linux/vs_base.h>
23988 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
23990 @@ -1767,6 +1768,16 @@ static int swap_show(struct seq_file *sw
23992 if (si == SEQ_START_TOKEN) {
23993 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
23994 + if (vx_flags(VXF_VIRT_MEM, 0)) {
23995 + struct sysinfo si;
23997 + vx_vsi_swapinfo(&si);
23998 + if (si.totalswap < (1 << 10))
24000 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24001 + "hdv0", "partition", si.totalswap >> 10,
24002 + (si.totalswap - si.freeswap) >> 10, -1);
24007 @@ -2195,6 +2206,8 @@ void si_swapinfo(struct sysinfo *val)
24008 val->freeswap = atomic_long_read(&nr_swap_pages) + nr_to_be_unused;
24009 val->totalswap = total_swap_pages + nr_to_be_unused;
24010 spin_unlock(&swap_lock);
24011 + if (vx_flags(VXF_VIRT_MEM, 0))
24012 + vx_vsi_swapinfo(val);
24016 diff -NurpP --minimal linux-3.9.5/net/bridge/br_multicast.c linux-3.9.5-vs2.3.6.5/net/bridge/br_multicast.c
24017 --- linux-3.9.5/net/bridge/br_multicast.c 2013-05-31 13:45:31.000000000 +0000
24018 +++ linux-3.9.5-vs2.3.6.5/net/bridge/br_multicast.c 2013-05-31 17:17:53.000000000 +0000
24019 @@ -443,7 +443,7 @@ static struct sk_buff *br_ip6_multicast_
24020 ip6h->hop_limit = 1;
24021 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24022 if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24024 + &ip6h->saddr, NULL)) {
24028 diff -NurpP --minimal linux-3.9.5/net/core/dev.c linux-3.9.5-vs2.3.6.5/net/core/dev.c
24029 --- linux-3.9.5/net/core/dev.c 2013-06-11 12:22:40.000000000 +0000
24030 +++ linux-3.9.5-vs2.3.6.5/net/core/dev.c 2013-05-31 18:37:38.000000000 +0000
24031 @@ -122,6 +122,7 @@
24032 #include <linux/in.h>
24033 #include <linux/jhash.h>
24034 #include <linux/random.h>
24035 +#include <linux/vs_inet.h>
24036 #include <trace/events/napi.h>
24037 #include <trace/events/net.h>
24038 #include <trace/events/skb.h>
24039 @@ -662,7 +663,8 @@ struct net_device *__dev_get_by_name(str
24040 struct hlist_head *head = dev_name_hash(net, name);
24042 hlist_for_each_entry(dev, head, name_hlist)
24043 - if (!strncmp(dev->name, name, IFNAMSIZ))
24044 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24045 + nx_dev_visible(current_nx_info(), dev))
24049 @@ -687,7 +689,8 @@ struct net_device *dev_get_by_name_rcu(s
24050 struct hlist_head *head = dev_name_hash(net, name);
24052 hlist_for_each_entry_rcu(dev, head, name_hlist)
24053 - if (!strncmp(dev->name, name, IFNAMSIZ))
24054 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24055 + nx_dev_visible(current_nx_info(), dev))
24059 @@ -737,7 +740,8 @@ struct net_device *__dev_get_by_index(st
24060 struct hlist_head *head = dev_index_hash(net, ifindex);
24062 hlist_for_each_entry(dev, head, index_hlist)
24063 - if (dev->ifindex == ifindex)
24064 + if ((dev->ifindex == ifindex) &&
24065 + nx_dev_visible(current_nx_info(), dev))
24069 @@ -755,7 +759,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24070 * about locking. The caller must hold RCU lock.
24073 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24074 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24076 struct net_device *dev;
24077 struct hlist_head *head = dev_index_hash(net, ifindex);
24078 @@ -766,6 +770,16 @@ struct net_device *dev_get_by_index_rcu(
24082 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24084 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24086 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24088 + if (nx_dev_visible(current_nx_info(), dev))
24092 EXPORT_SYMBOL(dev_get_by_index_rcu);
24095 @@ -814,7 +828,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24097 for_each_netdev_rcu(net, dev)
24098 if (dev->type == type &&
24099 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24100 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24101 + nx_dev_visible(current_nx_info(), dev))
24105 @@ -826,9 +841,11 @@ struct net_device *__dev_getfirstbyhwtyp
24106 struct net_device *dev;
24109 - for_each_netdev(net, dev)
24110 - if (dev->type == type)
24111 + for_each_netdev(net, dev) {
24112 + if ((dev->type == type) &&
24113 + nx_dev_visible(current_nx_info(), dev))
24119 @@ -840,7 +857,8 @@ struct net_device *dev_getfirstbyhwtype(
24122 for_each_netdev_rcu(net, dev)
24123 - if (dev->type == type) {
24124 + if ((dev->type == type) &&
24125 + nx_dev_visible(current_nx_info(), dev)) {
24129 @@ -868,7 +886,8 @@ struct net_device *dev_get_by_flags_rcu(
24132 for_each_netdev_rcu(net, dev) {
24133 - if (((dev->flags ^ if_flags) & mask) == 0) {
24134 + if ((((dev->flags ^ if_flags) & mask) == 0) &&
24135 + nx_dev_visible(current_nx_info(), dev)) {
24139 @@ -946,6 +965,8 @@ static int __dev_alloc_name(struct net *
24141 if (i < 0 || i >= max_netdevices)
24143 + if (!nx_dev_visible(current_nx_info(), d))
24146 /* avoid cases where sscanf is not exact inverse of printf */
24147 snprintf(buf, IFNAMSIZ, name, i);
24148 diff -NurpP --minimal linux-3.9.5/net/core/net-procfs.c linux-3.9.5-vs2.3.6.5/net/core/net-procfs.c
24149 --- linux-3.9.5/net/core/net-procfs.c 2013-05-31 13:45:32.000000000 +0000
24150 +++ linux-3.9.5-vs2.3.6.5/net/core/net-procfs.c 2013-06-01 10:40:52.000000000 +0000
24152 #include <linux/netdevice.h>
24153 #include <linux/proc_fs.h>
24154 #include <linux/seq_file.h>
24155 +#include <linux/vs_inet.h>
24156 #include <net/wext.h>
24158 #define BUCKET_SPACE (32 - NETDEV_HASHBITS - 1)
24159 @@ -77,8 +78,13 @@ static void dev_seq_stop(struct seq_file
24160 static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
24162 struct rtnl_link_stats64 temp;
24163 - const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24164 + const struct rtnl_link_stats64 *stats;
24166 + /* device visible inside network context? */
24167 + if (!nx_dev_visible(current_nx_info(), dev))
24170 + stats = dev_get_stats(dev, &temp);
24171 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24172 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24173 dev->name, stats->rx_bytes, stats->rx_packets,
24174 diff -NurpP --minimal linux-3.9.5/net/core/rtnetlink.c linux-3.9.5-vs2.3.6.5/net/core/rtnetlink.c
24175 --- linux-3.9.5/net/core/rtnetlink.c 2013-05-31 13:45:32.000000000 +0000
24176 +++ linux-3.9.5-vs2.3.6.5/net/core/rtnetlink.c 2013-05-31 17:17:54.000000000 +0000
24177 @@ -1085,6 +1085,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24178 hlist_for_each_entry_rcu(dev, head, index_hlist) {
24181 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24183 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24184 NETLINK_CB(cb->skb).portid,
24185 cb->nlh->nlmsg_seq, 0,
24186 @@ -1974,6 +1976,9 @@ void rtmsg_ifinfo(int type, struct net_d
24187 int err = -ENOBUFS;
24188 size_t if_info_size;
24190 + if (!nx_dev_visible(current_nx_info(), dev))
24193 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), GFP_KERNEL);
24196 diff -NurpP --minimal linux-3.9.5/net/core/sock.c linux-3.9.5-vs2.3.6.5/net/core/sock.c
24197 --- linux-3.9.5/net/core/sock.c 2013-06-11 12:22:40.000000000 +0000
24198 +++ linux-3.9.5-vs2.3.6.5/net/core/sock.c 2013-05-31 17:17:54.000000000 +0000
24199 @@ -132,6 +132,10 @@
24200 #include <net/netprio_cgroup.h>
24202 #include <linux/filter.h>
24203 +#include <linux/vs_socket.h>
24204 +#include <linux/vs_limit.h>
24205 +#include <linux/vs_context.h>
24206 +#include <linux/vs_network.h>
24208 #include <trace/events/sock.h>
24210 @@ -1257,6 +1261,8 @@ static struct sock *sk_prot_alloc(struct
24212 sk_tx_queue_clear(sk);
24214 + sock_vx_init(sk);
24215 + sock_nx_init(sk);
24219 @@ -1367,6 +1373,11 @@ static void __sk_free(struct sock *sk)
24220 put_cred(sk->sk_peer_cred);
24221 put_pid(sk->sk_peer_pid);
24222 put_net(sock_net(sk));
24224 + clr_vx_info(&sk->sk_vx_info);
24226 + clr_nx_info(&sk->sk_nx_info);
24228 sk_prot_free(sk->sk_prot_creator, sk);
24231 @@ -1427,6 +1438,8 @@ struct sock *sk_clone_lock(const struct
24234 get_net(sock_net(newsk));
24235 + sock_vx_init(newsk);
24236 + sock_nx_init(newsk);
24237 sk_node_init(&newsk->sk_node);
24238 sock_lock_init(newsk);
24239 bh_lock_sock(newsk);
24240 @@ -1483,6 +1496,12 @@ struct sock *sk_clone_lock(const struct
24242 atomic_set(&newsk->sk_refcnt, 2);
24244 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24245 + newsk->sk_xid = sk->sk_xid;
24246 + vx_sock_inc(newsk);
24247 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24248 + newsk->sk_nid = sk->sk_nid;
24251 * Increment the counter in the same struct proto as the master
24252 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24253 @@ -2278,6 +2297,12 @@ void sock_init_data(struct socket *sock,
24255 sk->sk_stamp = ktime_set(-1L, 0);
24257 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24258 + sk->sk_xid = vx_current_xid();
24260 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24261 + sk->sk_nid = nx_current_nid();
24264 * Before updating sk_refcnt, we must commit prior changes to memory
24265 * (Documentation/RCU/rculist_nulls.txt for details)
24266 diff -NurpP --minimal linux-3.9.5/net/ipv4/af_inet.c linux-3.9.5-vs2.3.6.5/net/ipv4/af_inet.c
24267 --- linux-3.9.5/net/ipv4/af_inet.c 2013-05-31 13:45:32.000000000 +0000
24268 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/af_inet.c 2013-06-03 17:22:33.000000000 +0000
24269 @@ -118,6 +118,7 @@
24270 #ifdef CONFIG_IP_MROUTE
24271 #include <linux/mroute.h>
24273 +#include <linux/vs_limit.h>
24276 /* The inetsw table contains everything that inet_create needs to
24277 @@ -336,10 +337,13 @@ lookup_protocol:
24281 + if ((protocol == IPPROTO_ICMP) &&
24282 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24284 if (sock->type == SOCK_RAW && !kern &&
24285 !ns_capable(net->user_ns, CAP_NET_RAW))
24286 goto out_rcu_unlock;
24289 sock->ops = answer->ops;
24290 answer_prot = answer->prot;
24291 answer_no_check = answer->no_check;
24292 @@ -460,6 +464,7 @@ int inet_bind(struct socket *sock, struc
24293 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24294 struct sock *sk = sock->sk;
24295 struct inet_sock *inet = inet_sk(sk);
24296 + struct nx_v4_sock_addr nsa;
24297 struct net *net = sock_net(sk);
24298 unsigned short snum;
24300 @@ -484,7 +489,11 @@ int inet_bind(struct socket *sock, struc
24304 - chk_addr_ret = inet_addr_type(net, addr->sin_addr.s_addr);
24305 + err = v4_map_sock_addr(inet, addr, &nsa);
24309 + chk_addr_ret = inet_addr_type(net, nsa.saddr);
24311 /* Not specified by any standard per-se, however it breaks too
24312 * many applications when removed. It is unfortunate since
24313 @@ -496,7 +505,7 @@ int inet_bind(struct socket *sock, struc
24314 err = -EADDRNOTAVAIL;
24315 if (!sysctl_ip_nonlocal_bind &&
24316 !(inet->freebind || inet->transparent) &&
24317 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24318 + nsa.saddr != htonl(INADDR_ANY) &&
24319 chk_addr_ret != RTN_LOCAL &&
24320 chk_addr_ret != RTN_MULTICAST &&
24321 chk_addr_ret != RTN_BROADCAST)
24322 @@ -522,7 +531,7 @@ int inet_bind(struct socket *sock, struc
24323 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24324 goto out_release_sock;
24326 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24327 + v4_set_sock_addr(inet, &nsa);
24328 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24329 inet->inet_saddr = 0; /* Use device */
24331 @@ -741,11 +750,13 @@ int inet_getname(struct socket *sock, st
24334 sin->sin_port = inet->inet_dport;
24335 - sin->sin_addr.s_addr = inet->inet_daddr;
24336 + sin->sin_addr.s_addr =
24337 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24339 __be32 addr = inet->inet_rcv_saddr;
24341 addr = inet->inet_saddr;
24342 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24343 sin->sin_port = inet->inet_sport;
24344 sin->sin_addr.s_addr = addr;
24346 diff -NurpP --minimal linux-3.9.5/net/ipv4/arp.c linux-3.9.5-vs2.3.6.5/net/ipv4/arp.c
24347 --- linux-3.9.5/net/ipv4/arp.c 2013-05-31 13:45:32.000000000 +0000
24348 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/arp.c 2013-05-31 17:17:54.000000000 +0000
24349 @@ -1317,6 +1317,7 @@ static void arp_format_neigh_entry(struc
24350 struct net_device *dev = n->dev;
24351 int hatype = dev->type;
24353 + /* FIXME: check for network context */
24354 read_lock(&n->lock);
24355 /* Convert hardware address to XX:XX:XX:XX ... form. */
24356 #if IS_ENABLED(CONFIG_AX25)
24357 @@ -1348,6 +1349,7 @@ static void arp_format_pneigh_entry(stru
24358 int hatype = dev ? dev->type : 0;
24361 + /* FIXME: check for network context */
24362 sprintf(tbuf, "%pI4", n->key);
24363 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24364 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24365 diff -NurpP --minimal linux-3.9.5/net/ipv4/devinet.c linux-3.9.5-vs2.3.6.5/net/ipv4/devinet.c
24366 --- linux-3.9.5/net/ipv4/devinet.c 2013-05-31 13:45:32.000000000 +0000
24367 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/devinet.c 2013-05-31 17:17:54.000000000 +0000
24368 @@ -522,6 +522,7 @@ struct in_device *inetdev_by_index(struc
24370 EXPORT_SYMBOL(inetdev_by_index);
24373 /* Called only from RTNL semaphored context. No locks. */
24375 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24376 @@ -940,6 +941,8 @@ int devinet_ioctl(struct net *net, unsig
24378 in_dev = __in_dev_get_rtnl(dev);
24380 + struct nx_info *nxi = current_nx_info();
24382 if (tryaddrmatch) {
24383 /* Matthias Andree */
24384 /* compare label and address (4.4BSD style) */
24385 @@ -948,6 +951,8 @@ int devinet_ioctl(struct net *net, unsig
24386 This is checked above. */
24387 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24388 ifap = &ifa->ifa_next) {
24389 + if (!nx_v4_ifa_visible(nxi, ifa))
24391 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24392 sin_orig.sin_addr.s_addr ==
24394 @@ -960,9 +965,12 @@ int devinet_ioctl(struct net *net, unsig
24395 comparing just the label */
24397 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24398 - ifap = &ifa->ifa_next)
24399 + ifap = &ifa->ifa_next) {
24400 + if (!nx_v4_ifa_visible(nxi, ifa))
24402 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24408 @@ -1116,6 +1124,8 @@ static int inet_gifconf(struct net_devic
24411 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24412 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24415 done += sizeof(ifr);
24417 @@ -1519,6 +1529,7 @@ static int inet_dump_ifaddr(struct sk_bu
24418 struct net_device *dev;
24419 struct in_device *in_dev;
24420 struct in_ifaddr *ifa;
24421 + struct sock *sk = skb->sk;
24422 struct hlist_head *head;
24425 @@ -1540,6 +1551,8 @@ static int inet_dump_ifaddr(struct sk_bu
24427 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24428 ifa = ifa->ifa_next, ip_idx++) {
24429 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24431 if (ip_idx < s_ip_idx)
24433 if (inet_fill_ifaddr(skb, ifa,
24434 diff -NurpP --minimal linux-3.9.5/net/ipv4/fib_trie.c linux-3.9.5-vs2.3.6.5/net/ipv4/fib_trie.c
24435 --- linux-3.9.5/net/ipv4/fib_trie.c 2013-05-31 13:45:32.000000000 +0000
24436 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/fib_trie.c 2013-05-31 17:17:54.000000000 +0000
24437 @@ -2548,6 +2548,7 @@ static int fib_route_seq_show(struct seq
24438 || fa->fa_type == RTN_MULTICAST)
24441 + /* FIXME: check for network context? */
24444 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24445 diff -NurpP --minimal linux-3.9.5/net/ipv4/inet_connection_sock.c linux-3.9.5-vs2.3.6.5/net/ipv4/inet_connection_sock.c
24446 --- linux-3.9.5/net/ipv4/inet_connection_sock.c 2013-05-31 13:45:32.000000000 +0000
24447 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/inet_connection_sock.c 2013-05-31 18:29:56.000000000 +0000
24448 @@ -53,6 +53,37 @@ void inet_get_local_port_range(int *low,
24450 EXPORT_SYMBOL(inet_get_local_port_range);
24452 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24454 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24455 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24457 + if (inet_v6_ipv6only(sk2))
24460 + if (sk1_rcv_saddr &&
24462 + sk1_rcv_saddr == sk2_rcv_saddr)
24465 + if (sk1_rcv_saddr &&
24466 + !sk2_rcv_saddr &&
24467 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24470 + if (sk2_rcv_saddr &&
24471 + !sk1_rcv_saddr &&
24472 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24475 + if (!sk1_rcv_saddr &&
24476 + !sk2_rcv_saddr &&
24477 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24483 int inet_csk_bind_conflict(const struct sock *sk,
24484 const struct inet_bind_bucket *tb, bool relax)
24486 @@ -79,17 +110,12 @@ int inet_csk_bind_conflict(const struct
24487 (!reuseport || !sk2->sk_reuseport ||
24488 (sk2->sk_state != TCP_TIME_WAIT &&
24489 !uid_eq(uid, sock_i_uid(sk2))))) {
24490 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24491 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24492 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24493 + if (ipv4_rcv_saddr_equal(sk, sk2))
24496 if (!relax && reuse && sk2->sk_reuse &&
24497 sk2->sk_state != TCP_LISTEN) {
24498 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24500 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24501 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24502 + if (ipv4_rcv_saddr_equal(sk, sk2))
24506 diff -NurpP --minimal linux-3.9.5/net/ipv4/inet_diag.c linux-3.9.5-vs2.3.6.5/net/ipv4/inet_diag.c
24507 --- linux-3.9.5/net/ipv4/inet_diag.c 2013-02-19 13:58:58.000000000 +0000
24508 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/inet_diag.c 2013-05-31 17:17:54.000000000 +0000
24511 #include <linux/inet.h>
24512 #include <linux/stddef.h>
24513 +#include <linux/vs_network.h>
24514 +#include <linux/vs_inet.h>
24516 #include <linux/inet_diag.h>
24517 #include <linux/sock_diag.h>
24518 @@ -106,8 +108,10 @@ int inet_sk_diag_fill(struct sock *sk, s
24520 r->id.idiag_sport = inet->inet_sport;
24521 r->id.idiag_dport = inet->inet_dport;
24522 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24523 - r->id.idiag_dst[0] = inet->inet_daddr;
24524 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24525 + inet->inet_rcv_saddr);
24526 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24527 + inet->inet_daddr);
24529 if (nla_put_u8(skb, INET_DIAG_SHUTDOWN, sk->sk_shutdown))
24531 @@ -242,8 +246,8 @@ static int inet_twsk_diag_fill(struct in
24532 sock_diag_save_cookie(tw, r->id.idiag_cookie);
24533 r->id.idiag_sport = tw->tw_sport;
24534 r->id.idiag_dport = tw->tw_dport;
24535 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24536 - r->id.idiag_dst[0] = tw->tw_daddr;
24537 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24538 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24539 r->idiag_state = tw->tw_substate;
24540 r->idiag_timer = 3;
24541 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
24542 @@ -287,12 +291,14 @@ int inet_diag_dump_one_icsk(struct inet_
24545 if (req->sdiag_family == AF_INET) {
24546 + /* TODO: lback */
24547 sk = inet_lookup(net, hashinfo, req->id.idiag_dst[0],
24548 req->id.idiag_dport, req->id.idiag_src[0],
24549 req->id.idiag_sport, req->id.idiag_if);
24551 #if IS_ENABLED(CONFIG_IPV6)
24552 else if (req->sdiag_family == AF_INET6) {
24553 + /* TODO: lback */
24554 sk = inet6_lookup(net, hashinfo,
24555 (struct in6_addr *)req->id.idiag_dst,
24556 req->id.idiag_dport,
24557 @@ -494,6 +500,7 @@ int inet_diag_bc_sk(const struct nlattr
24561 + /* TODO: lback */
24562 entry.saddr = &inet->inet_rcv_saddr;
24563 entry.daddr = &inet->inet_daddr;
24565 @@ -652,6 +659,7 @@ static int inet_twsk_diag_dump(struct in
24569 + /* TODO: lback */
24570 entry.saddr = &tw->tw_rcv_saddr;
24571 entry.daddr = &tw->tw_daddr;
24573 @@ -730,8 +738,8 @@ static int inet_diag_fill_req(struct sk_
24575 r->id.idiag_sport = inet->inet_sport;
24576 r->id.idiag_dport = ireq->rmt_port;
24577 - r->id.idiag_src[0] = ireq->loc_addr;
24578 - r->id.idiag_dst[0] = ireq->rmt_addr;
24579 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
24580 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
24581 r->idiag_expires = jiffies_to_msecs(tmo);
24582 r->idiag_rqueue = 0;
24583 r->idiag_wqueue = 0;
24584 @@ -794,6 +802,7 @@ static int inet_diag_dump_reqs(struct sk
24588 + /* TODO: lback */
24590 inet_diag_req_addrs(sk, req, &entry);
24591 entry.dport = ntohs(ireq->rmt_port);
24592 @@ -850,6 +859,8 @@ void inet_diag_dump_icsk(struct inet_has
24593 if (!net_eq(sock_net(sk), net))
24596 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24601 @@ -922,6 +933,8 @@ skip_listen_ht:
24603 if (!net_eq(sock_net(sk), net))
24605 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24609 if (!(r->idiag_states & (1 << sk->sk_state)))
24610 @@ -950,7 +963,8 @@ next_normal:
24612 if (!net_eq(twsk_net(tw), net))
24615 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24619 if (r->sdiag_family != AF_UNSPEC &&
24620 diff -NurpP --minimal linux-3.9.5/net/ipv4/inet_hashtables.c linux-3.9.5-vs2.3.6.5/net/ipv4/inet_hashtables.c
24621 --- linux-3.9.5/net/ipv4/inet_hashtables.c 2013-05-31 13:45:32.000000000 +0000
24622 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/inet_hashtables.c 2013-05-31 18:20:50.000000000 +0000
24624 #include <net/inet_connection_sock.h>
24625 #include <net/inet_hashtables.h>
24626 #include <net/secure_seq.h>
24627 +#include <net/route.h>
24628 #include <net/ip.h>
24631 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
24632 if (rcv_saddr != daddr)
24636 + /* block non nx_info ips */
24637 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24638 + daddr, NXA_MASK_BIND))
24641 if (sk->sk_bound_dev_if) {
24642 if (sk->sk_bound_dev_if != dif)
24643 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
24644 * wildcarded during the search since they can never be otherwise.
24648 struct sock *__inet_lookup_listener(struct net *net,
24649 struct inet_hashinfo *hashinfo,
24650 const __be32 saddr, __be16 sport,
24651 @@ -209,6 +214,7 @@ begin:
24652 phash = next_pseudo_random32(phash);
24657 * if the nulls value we got at the end of this lookup is
24658 * not the expected one, we must restart lookup.
24659 diff -NurpP --minimal linux-3.9.5/net/ipv4/netfilter.c linux-3.9.5-vs2.3.6.5/net/ipv4/netfilter.c
24660 --- linux-3.9.5/net/ipv4/netfilter.c 2012-12-11 03:30:57.000000000 +0000
24661 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/netfilter.c 2013-05-31 17:17:54.000000000 +0000
24663 #include <linux/skbuff.h>
24664 #include <linux/gfp.h>
24665 #include <linux/export.h>
24666 -#include <net/route.h>
24667 +// #include <net/route.h>
24668 #include <net/xfrm.h>
24669 #include <net/ip.h>
24670 #include <net/netfilter/nf_queue.h>
24671 diff -NurpP --minimal linux-3.9.5/net/ipv4/raw.c linux-3.9.5-vs2.3.6.5/net/ipv4/raw.c
24672 --- linux-3.9.5/net/ipv4/raw.c 2013-05-31 13:45:32.000000000 +0000
24673 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/raw.c 2013-05-31 18:19:38.000000000 +0000
24674 @@ -116,7 +116,7 @@ static struct sock *__raw_v4_lookup(stru
24676 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
24677 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
24678 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
24679 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
24680 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
24681 goto found; /* gotcha */
24683 @@ -395,6 +395,12 @@ static int raw_send_hdrinc(struct sock *
24684 icmp_out_count(net, ((struct icmphdr *)
24685 skb_transport_header(skb))->type);
24688 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
24689 + sk->sk_nx_info &&
24690 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
24693 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
24694 rt->dst.dev, dst_output);
24696 @@ -580,6 +586,16 @@ static int raw_sendmsg(struct kiocb *ioc
24700 + if (sk->sk_nx_info) {
24701 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
24702 + if (IS_ERR(rt)) {
24703 + err = PTR_ERR(rt);
24710 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
24711 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
24713 @@ -656,17 +672,19 @@ static int raw_bind(struct sock *sk, str
24715 struct inet_sock *inet = inet_sk(sk);
24716 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
24717 + struct nx_v4_sock_addr nsa = { 0 };
24721 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
24723 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24724 + v4_map_sock_addr(inet, addr, &nsa);
24725 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24726 ret = -EADDRNOTAVAIL;
24727 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
24728 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
24729 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
24731 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24732 + v4_set_sock_addr(inet, &nsa);
24733 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24734 inet->inet_saddr = 0; /* Use device */
24736 @@ -718,7 +736,8 @@ static int raw_recvmsg(struct kiocb *ioc
24737 /* Copy the address. */
24739 sin->sin_family = AF_INET;
24740 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24741 + sin->sin_addr.s_addr =
24742 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
24744 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
24746 @@ -913,7 +932,8 @@ static struct sock *raw_get_first(struct
24747 for (state->bucket = 0; state->bucket < RAW_HTABLE_SIZE;
24749 sk_for_each(sk, &state->h->ht[state->bucket])
24750 - if (sock_net(sk) == seq_file_net(seq))
24751 + if ((sock_net(sk) == seq_file_net(seq)) &&
24752 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24756 @@ -929,7 +949,8 @@ static struct sock *raw_get_next(struct
24760 - } while (sk && sock_net(sk) != seq_file_net(seq));
24761 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
24762 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24764 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
24765 sk = sk_head(&state->h->ht[state->bucket]);
24766 diff -NurpP --minimal linux-3.9.5/net/ipv4/route.c linux-3.9.5-vs2.3.6.5/net/ipv4/route.c
24767 --- linux-3.9.5/net/ipv4/route.c 2013-05-31 13:45:32.000000000 +0000
24768 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/route.c 2013-05-31 17:17:54.000000000 +0000
24769 @@ -1998,7 +1998,7 @@ struct rtable *__ip_route_output_key(str
24772 if (fl4->flowi4_oif) {
24773 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
24774 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
24775 rth = ERR_PTR(-ENODEV);
24776 if (dev_out == NULL)
24778 diff -NurpP --minimal linux-3.9.5/net/ipv4/tcp.c linux-3.9.5-vs2.3.6.5/net/ipv4/tcp.c
24779 --- linux-3.9.5/net/ipv4/tcp.c 2013-05-31 13:45:32.000000000 +0000
24780 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/tcp.c 2013-05-31 17:17:54.000000000 +0000
24781 @@ -268,6 +268,7 @@
24782 #include <linux/crypto.h>
24783 #include <linux/time.h>
24784 #include <linux/slab.h>
24785 +#include <linux/in.h>
24787 #include <net/icmp.h>
24788 #include <net/inet_common.h>
24789 diff -NurpP --minimal linux-3.9.5/net/ipv4/tcp_ipv4.c linux-3.9.5-vs2.3.6.5/net/ipv4/tcp_ipv4.c
24790 --- linux-3.9.5/net/ipv4/tcp_ipv4.c 2013-05-31 13:45:32.000000000 +0000
24791 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/tcp_ipv4.c 2013-05-31 17:17:54.000000000 +0000
24792 @@ -2260,6 +2260,12 @@ static void *listening_get_next(struct s
24793 req = req->dl_next;
24796 + vxdprintk(VXD_CBIT(net, 6),
24797 + "sk,req: %p [#%d] (from %d)", req->sk,
24798 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
24800 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
24802 if (req->rsk_ops->family == st->family) {
24805 @@ -2284,6 +2290,10 @@ get_req:
24808 sk_nulls_for_each_from(sk, node) {
24809 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
24810 + sk, sk->sk_nid, nx_current_nid());
24811 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24813 if (!net_eq(sock_net(sk), net))
24815 if (sk->sk_family == st->family) {
24816 @@ -2360,6 +2370,11 @@ static void *established_get_first(struc
24818 spin_lock_bh(lock);
24819 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
24820 + vxdprintk(VXD_CBIT(net, 6),
24821 + "sk,egf: %p [#%d] (from %d)",
24822 + sk, sk->sk_nid, nx_current_nid());
24823 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24825 if (sk->sk_family != st->family ||
24826 !net_eq(sock_net(sk), net)) {
24828 @@ -2370,6 +2385,11 @@ static void *established_get_first(struc
24829 st->state = TCP_SEQ_STATE_TIME_WAIT;
24830 inet_twsk_for_each(tw, node,
24831 &tcp_hashinfo.ehash[st->bucket].twchain) {
24832 + vxdprintk(VXD_CBIT(net, 6),
24833 + "tw: %p [#%d] (from %d)",
24834 + tw, tw->tw_nid, nx_current_nid());
24835 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24837 if (tw->tw_family != st->family ||
24838 !net_eq(twsk_net(tw), net)) {
24840 @@ -2399,7 +2419,9 @@ static void *established_get_next(struct
24844 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
24845 + while (tw && (tw->tw_family != st->family ||
24846 + !net_eq(twsk_net(tw), net) ||
24847 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
24851 @@ -2423,6 +2445,11 @@ get_tw:
24852 sk = sk_nulls_next(sk);
24854 sk_nulls_for_each_from(sk, node) {
24855 + vxdprintk(VXD_CBIT(net, 6),
24856 + "sk,egn: %p [#%d] (from %d)",
24857 + sk, sk->sk_nid, nx_current_nid());
24858 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24860 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
24863 @@ -2628,9 +2655,9 @@ static void get_openreq4(const struct so
24864 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
24865 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
24868 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
24869 ntohs(inet_sk(sk)->inet_sport),
24871 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
24872 ntohs(ireq->rmt_port),
24874 0, 0, /* could print option size, but that is af dependent. */
24875 @@ -2653,8 +2680,8 @@ static void get_tcp4_sock(struct sock *s
24876 const struct inet_connection_sock *icsk = inet_csk(sk);
24877 const struct inet_sock *inet = inet_sk(sk);
24878 struct fastopen_queue *fastopenq = icsk->icsk_accept_queue.fastopenq;
24879 - __be32 dest = inet->inet_daddr;
24880 - __be32 src = inet->inet_rcv_saddr;
24881 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
24882 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
24883 __u16 destp = ntohs(inet->inet_dport);
24884 __u16 srcp = ntohs(inet->inet_sport);
24886 @@ -2710,8 +2737,8 @@ static void get_timewait4_sock(const str
24888 long delta = tw->tw_ttd - jiffies;
24890 - dest = tw->tw_daddr;
24891 - src = tw->tw_rcv_saddr;
24892 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
24893 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
24894 destp = ntohs(tw->tw_dport);
24895 srcp = ntohs(tw->tw_sport);
24897 diff -NurpP --minimal linux-3.9.5/net/ipv4/tcp_minisocks.c linux-3.9.5-vs2.3.6.5/net/ipv4/tcp_minisocks.c
24898 --- linux-3.9.5/net/ipv4/tcp_minisocks.c 2013-06-11 12:22:40.000000000 +0000
24899 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/tcp_minisocks.c 2013-05-31 17:17:54.000000000 +0000
24901 #include <linux/slab.h>
24902 #include <linux/sysctl.h>
24903 #include <linux/workqueue.h>
24904 +#include <linux/vs_limit.h>
24905 +#include <linux/vs_socket.h>
24906 +#include <linux/vs_context.h>
24907 #include <net/tcp.h>
24908 #include <net/inet_common.h>
24909 #include <net/xfrm.h>
24910 @@ -291,6 +294,11 @@ void tcp_time_wait(struct sock *sk, int
24911 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
24912 tcptw->tw_ts_offset = tp->tsoffset;
24914 + tw->tw_xid = sk->sk_xid;
24915 + tw->tw_vx_info = NULL;
24916 + tw->tw_nid = sk->sk_nid;
24917 + tw->tw_nx_info = NULL;
24919 #if IS_ENABLED(CONFIG_IPV6)
24920 if (tw->tw_family == PF_INET6) {
24921 struct ipv6_pinfo *np = inet6_sk(sk);
24922 diff -NurpP --minimal linux-3.9.5/net/ipv4/udp.c linux-3.9.5-vs2.3.6.5/net/ipv4/udp.c
24923 --- linux-3.9.5/net/ipv4/udp.c 2013-05-31 13:45:32.000000000 +0000
24924 +++ linux-3.9.5-vs2.3.6.5/net/ipv4/udp.c 2013-05-31 18:26:00.000000000 +0000
24925 @@ -306,14 +306,7 @@ fail:
24927 EXPORT_SYMBOL(udp_lib_get_port);
24929 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24931 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
24933 - return (!ipv6_only_sock(sk2) &&
24934 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
24935 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
24937 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
24939 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
24941 @@ -348,6 +341,11 @@ static inline int compute_score(struct s
24942 if (inet->inet_rcv_saddr != daddr)
24946 + /* block non nx_info ips */
24947 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24948 + daddr, NXA_MASK_BIND))
24951 if (inet->inet_daddr) {
24952 if (inet->inet_daddr != saddr)
24953 @@ -458,6 +456,7 @@ begin:
24958 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
24959 * harder than this. -DaveM
24961 @@ -504,6 +503,11 @@ begin:
24962 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
24963 score = compute_score(sk, net, saddr, hnum, sport,
24964 daddr, dport, dif);
24965 + /* FIXME: disabled?
24966 + if (score == 9) {
24970 if (score > badness) {
24973 @@ -528,6 +532,7 @@ begin:
24974 if (get_nulls_value(node) != slot)
24979 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
24981 @@ -537,6 +542,7 @@ begin:
24989 @@ -580,8 +586,7 @@ static inline struct sock *udp_v4_mcast_
24990 udp_sk(s)->udp_port_hash != hnum ||
24991 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
24992 (inet->inet_dport != rmt_port && inet->inet_dport) ||
24993 - (inet->inet_rcv_saddr &&
24994 - inet->inet_rcv_saddr != loc_addr) ||
24995 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
24996 ipv6_only_sock(s) ||
24997 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
24999 @@ -964,6 +969,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
25000 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
25001 faddr, saddr, dport, inet->inet_sport);
25003 + if (sk->sk_nx_info) {
25004 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
25005 + if (IS_ERR(rt)) {
25006 + err = PTR_ERR(rt);
25013 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
25014 rt = ip_route_output_flow(net, fl4, sk);
25016 @@ -1269,7 +1284,8 @@ try_again:
25018 sin->sin_family = AF_INET;
25019 sin->sin_port = udp_hdr(skb)->source;
25020 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25021 + sin->sin_addr.s_addr = nx_map_sock_lback(
25022 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25023 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25025 if (inet->cmsg_flags)
25026 @@ -2025,6 +2041,8 @@ static struct sock *udp_get_first(struct
25027 sk_nulls_for_each(sk, node, &hslot->head) {
25028 if (!net_eq(sock_net(sk), net))
25030 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25032 if (sk->sk_family == state->family)
25035 @@ -2042,7 +2060,9 @@ static struct sock *udp_get_next(struct
25038 sk = sk_nulls_next(sk);
25039 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25040 + } while (sk && (!net_eq(sock_net(sk), net) ||
25041 + sk->sk_family != state->family ||
25042 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25045 if (state->bucket <= state->udp_table->mask)
25046 @@ -2138,8 +2158,8 @@ static void udp4_format_sock(struct sock
25047 int bucket, int *len)
25049 struct inet_sock *inet = inet_sk(sp);
25050 - __be32 dest = inet->inet_daddr;
25051 - __be32 src = inet->inet_rcv_saddr;
25052 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
25053 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
25054 __u16 destp = ntohs(inet->inet_dport);
25055 __u16 srcp = ntohs(inet->inet_sport);
25057 diff -NurpP --minimal linux-3.9.5/net/ipv6/Kconfig linux-3.9.5-vs2.3.6.5/net/ipv6/Kconfig
25058 --- linux-3.9.5/net/ipv6/Kconfig 2013-05-31 13:45:32.000000000 +0000
25059 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/Kconfig 2013-05-31 17:17:54.000000000 +0000
25062 # IPv6 as module will cause a CRASH if you try to unload it
25064 - tristate "The IPv6 protocol"
25066 + bool "The IPv6 protocol"
25069 This is complemental support for the IP version 6.
25070 You will still be able to do traditional IPv4 networking as well.
25071 diff -NurpP --minimal linux-3.9.5/net/ipv6/addrconf.c linux-3.9.5-vs2.3.6.5/net/ipv6/addrconf.c
25072 --- linux-3.9.5/net/ipv6/addrconf.c 2013-05-31 13:45:32.000000000 +0000
25073 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/addrconf.c 2013-05-31 20:07:39.000000000 +0000
25075 #include <linux/proc_fs.h>
25076 #include <linux/seq_file.h>
25077 #include <linux/export.h>
25078 +#include <linux/vs_network.h>
25079 +#include <linux/vs_inet6.h>
25081 /* Set to 3 to get tracing... */
25082 #define ACONF_DEBUG 2
25083 @@ -1250,7 +1252,7 @@ out:
25085 int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
25086 const struct in6_addr *daddr, unsigned int prefs,
25087 - struct in6_addr *saddr)
25088 + struct in6_addr *saddr, struct nx_info *nxi)
25090 struct ipv6_saddr_score scores[2],
25091 *score = &scores[0], *hiscore = &scores[1];
25092 @@ -1322,6 +1324,8 @@ int ipv6_dev_get_saddr(struct net *net,
25096 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25100 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25101 @@ -3311,7 +3315,10 @@ static void if6_seq_stop(struct seq_file
25102 static int if6_seq_show(struct seq_file *seq, void *v)
25104 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25105 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25107 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25108 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25109 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25111 ifp->idev->dev->ifindex,
25113 @@ -3815,6 +3822,11 @@ static int in6_dump_addrs(struct inet6_d
25114 struct ifacaddr6 *ifaca;
25116 int ip_idx = *p_ip_idx;
25117 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25119 + /* disable ipv6 on non v6 guests */
25120 + if (nxi && !nx_info_has_v6(nxi))
25123 read_lock_bh(&idev->lock);
25125 @@ -3825,6 +3837,8 @@ static int in6_dump_addrs(struct inet6_d
25126 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25127 if (++ip_idx < s_ip_idx)
25129 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25131 err = inet6_fill_ifaddr(skb, ifa,
25132 NETLINK_CB(cb->skb).portid,
25133 cb->nlh->nlmsg_seq,
25134 @@ -3841,6 +3855,8 @@ static int in6_dump_addrs(struct inet6_d
25135 ifmca = ifmca->next, ip_idx++) {
25136 if (ip_idx < s_ip_idx)
25138 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25140 err = inet6_fill_ifmcaddr(skb, ifmca,
25141 NETLINK_CB(cb->skb).portid,
25142 cb->nlh->nlmsg_seq,
25143 @@ -3856,6 +3872,8 @@ static int in6_dump_addrs(struct inet6_d
25144 ifaca = ifaca->aca_next, ip_idx++) {
25145 if (ip_idx < s_ip_idx)
25147 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25149 err = inet6_fill_ifacaddr(skb, ifaca,
25150 NETLINK_CB(cb->skb).portid,
25151 cb->nlh->nlmsg_seq,
25152 @@ -3884,6 +3902,10 @@ static int inet6_dump_addr(struct sk_buf
25153 struct inet6_dev *idev;
25154 struct hlist_head *head;
25156 + /* FIXME: maybe disable ipv6 on non v6 guests?
25157 + if (skb->sk && skb->sk->sk_vx_info)
25158 + return skb->len; */
25161 s_idx = idx = cb->args[1];
25162 s_ip_idx = ip_idx = cb->args[2];
25163 @@ -4238,6 +4260,7 @@ static int inet6_dump_ifinfo(struct sk_b
25164 struct net_device *dev;
25165 struct inet6_dev *idev;
25166 struct hlist_head *head;
25167 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25170 s_idx = cb->args[1];
25171 @@ -4249,6 +4272,8 @@ static int inet6_dump_ifinfo(struct sk_b
25172 hlist_for_each_entry_rcu(dev, head, index_hlist) {
25175 + if (!v6_dev_in_nx_info(dev, nxi))
25177 idev = __in6_dev_get(dev);
25180 diff -NurpP --minimal linux-3.9.5/net/ipv6/af_inet6.c linux-3.9.5-vs2.3.6.5/net/ipv6/af_inet6.c
25181 --- linux-3.9.5/net/ipv6/af_inet6.c 2013-05-31 13:45:32.000000000 +0000
25182 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/af_inet6.c 2013-05-31 20:04:41.000000000 +0000
25184 #include <linux/netdevice.h>
25185 #include <linux/icmpv6.h>
25186 #include <linux/netfilter_ipv6.h>
25187 +#include <linux/vs_inet.h>
25188 +#include <linux/vs_inet6.h>
25190 #include <net/ip.h>
25191 #include <net/ipv6.h>
25192 @@ -160,10 +162,13 @@ lookup_protocol:
25196 + if ((protocol == IPPROTO_ICMPV6) &&
25197 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25199 if (sock->type == SOCK_RAW && !kern &&
25200 !ns_capable(net->user_ns, CAP_NET_RAW))
25201 goto out_rcu_unlock;
25204 sock->ops = answer->ops;
25205 answer_prot = answer->prot;
25206 answer_no_check = answer->no_check;
25207 @@ -263,6 +268,7 @@ int inet6_bind(struct socket *sock, stru
25208 struct inet_sock *inet = inet_sk(sk);
25209 struct ipv6_pinfo *np = inet6_sk(sk);
25210 struct net *net = sock_net(sk);
25211 + struct nx_v6_sock_addr nsa;
25213 unsigned short snum;
25215 @@ -278,6 +284,10 @@ int inet6_bind(struct socket *sock, stru
25216 if (addr->sin6_family != AF_INET6)
25217 return -EAFNOSUPPORT;
25219 + err = v6_map_sock_addr(inet, addr, &nsa);
25223 addr_type = ipv6_addr_type(&addr->sin6_addr);
25224 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25226 @@ -309,6 +319,7 @@ int inet6_bind(struct socket *sock, stru
25227 /* Reproduce AF_INET checks to make the bindings consistent */
25228 v4addr = addr->sin6_addr.s6_addr32[3];
25229 chk_addr_ret = inet_addr_type(net, v4addr);
25231 if (!sysctl_ip_nonlocal_bind &&
25232 !(inet->freebind || inet->transparent) &&
25233 v4addr != htonl(INADDR_ANY) &&
25234 @@ -318,6 +329,10 @@ int inet6_bind(struct socket *sock, stru
25235 err = -EADDRNOTAVAIL;
25238 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25239 + err = -EADDRNOTAVAIL;
25243 if (addr_type != IPV6_ADDR_ANY) {
25244 struct net_device *dev = NULL;
25245 @@ -344,6 +359,11 @@ int inet6_bind(struct socket *sock, stru
25249 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25250 + err = -EADDRNOTAVAIL;
25254 /* ipv4 addr of the socket is invalid. Only the
25255 * unspecified and mapped address have a v4 equivalent.
25257 @@ -360,6 +380,9 @@ int inet6_bind(struct socket *sock, stru
25261 + /* what's that for? */
25262 + v6_set_sock_addr(inet, &nsa);
25264 inet->inet_rcv_saddr = v4addr;
25265 inet->inet_saddr = v4addr;
25267 @@ -461,9 +484,11 @@ int inet6_getname(struct socket *sock, s
25269 sin->sin6_port = inet->inet_dport;
25270 sin->sin6_addr = np->daddr;
25271 + /* FIXME: remap lback? */
25273 sin->sin6_flowinfo = np->flow_label;
25275 + /* FIXME: remap lback? */
25276 if (ipv6_addr_any(&np->rcv_saddr))
25277 sin->sin6_addr = np->saddr;
25279 diff -NurpP --minimal linux-3.9.5/net/ipv6/datagram.c linux-3.9.5-vs2.3.6.5/net/ipv6/datagram.c
25280 --- linux-3.9.5/net/ipv6/datagram.c 2013-05-31 13:45:32.000000000 +0000
25281 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/datagram.c 2013-05-31 17:17:54.000000000 +0000
25282 @@ -648,7 +648,7 @@ int ip6_datagram_send_ctl(struct net *ne
25285 if (fl6->flowi6_oif) {
25286 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25287 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25291 diff -NurpP --minimal linux-3.9.5/net/ipv6/fib6_rules.c linux-3.9.5-vs2.3.6.5/net/ipv6/fib6_rules.c
25292 --- linux-3.9.5/net/ipv6/fib6_rules.c 2013-02-19 13:58:58.000000000 +0000
25293 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/fib6_rules.c 2013-05-31 17:17:54.000000000 +0000
25294 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
25295 ip6_dst_idev(&rt->dst)->dev,
25297 rt6_flags2srcprefs(flags),
25301 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25303 diff -NurpP --minimal linux-3.9.5/net/ipv6/inet6_hashtables.c linux-3.9.5-vs2.3.6.5/net/ipv6/inet6_hashtables.c
25304 --- linux-3.9.5/net/ipv6/inet6_hashtables.c 2013-05-31 13:45:32.000000000 +0000
25305 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/inet6_hashtables.c 2013-05-31 17:17:54.000000000 +0000
25308 #include <linux/module.h>
25309 #include <linux/random.h>
25310 +#include <linux/vs_inet6.h>
25312 #include <net/inet_connection_sock.h>
25313 #include <net/inet_hashtables.h>
25314 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25315 unsigned int slot = hash & hashinfo->ehash_mask;
25316 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25321 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25322 @@ -97,7 +97,7 @@ begin:
25330 if (get_nulls_value(node) != slot)
25331 @@ -147,6 +147,9 @@ static inline int compute_score(struct s
25332 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25336 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25339 if (sk->sk_bound_dev_if) {
25340 if (sk->sk_bound_dev_if != dif)
25341 diff -NurpP --minimal linux-3.9.5/net/ipv6/ip6_output.c linux-3.9.5-vs2.3.6.5/net/ipv6/ip6_output.c
25342 --- linux-3.9.5/net/ipv6/ip6_output.c 2013-05-31 13:45:32.000000000 +0000
25343 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/ip6_output.c 2013-05-31 17:17:54.000000000 +0000
25344 @@ -877,7 +877,8 @@ static int ip6_dst_lookup_tail(struct so
25345 struct rt6_info *rt = (struct rt6_info *) *dst;
25346 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25347 sk ? inet6_sk(sk)->srcprefs : 0,
25350 + sk ? sk->sk_nx_info : NULL);
25352 goto out_err_release;
25354 diff -NurpP --minimal linux-3.9.5/net/ipv6/ndisc.c linux-3.9.5-vs2.3.6.5/net/ipv6/ndisc.c
25355 --- linux-3.9.5/net/ipv6/ndisc.c 2013-05-31 13:45:32.000000000 +0000
25356 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/ndisc.c 2013-05-31 17:17:54.000000000 +0000
25357 @@ -485,7 +485,7 @@ static void ndisc_send_na(struct net_dev
25359 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25360 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25364 src_addr = &tmpaddr;
25366 diff -NurpP --minimal linux-3.9.5/net/ipv6/netfilter/ip6t_MASQUERADE.c linux-3.9.5-vs2.3.6.5/net/ipv6/netfilter/ip6t_MASQUERADE.c
25367 --- linux-3.9.5/net/ipv6/netfilter/ip6t_MASQUERADE.c 2012-12-11 03:30:57.000000000 +0000
25368 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/netfilter/ip6t_MASQUERADE.c 2013-05-31 17:17:54.000000000 +0000
25369 @@ -34,7 +34,7 @@ masquerade_tg6(struct sk_buff *skb, cons
25370 ctinfo == IP_CT_RELATED_REPLY));
25372 if (ipv6_dev_get_saddr(dev_net(par->out), par->out,
25373 - &ipv6_hdr(skb)->daddr, 0, &src) < 0)
25374 + &ipv6_hdr(skb)->daddr, 0, &src, NULL) < 0)
25377 nfct_nat(ct)->masq_index = par->out->ifindex;
25378 diff -NurpP --minimal linux-3.9.5/net/ipv6/raw.c linux-3.9.5-vs2.3.6.5/net/ipv6/raw.c
25379 --- linux-3.9.5/net/ipv6/raw.c 2013-05-31 13:45:32.000000000 +0000
25380 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/raw.c 2013-05-31 17:17:54.000000000 +0000
25382 #include <linux/icmpv6.h>
25383 #include <linux/netfilter.h>
25384 #include <linux/netfilter_ipv6.h>
25385 +#include <linux/vs_inet6.h>
25386 #include <linux/skbuff.h>
25387 #include <linux/compat.h>
25388 #include <asm/uaccess.h>
25389 @@ -283,6 +284,13 @@ static int rawv6_bind(struct sock *sk, s
25393 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25394 + err = -EADDRNOTAVAIL;
25400 /* ipv4 addr of the socket is invalid. Only the
25401 * unspecified and mapped address have a v4 equivalent.
25403 diff -NurpP --minimal linux-3.9.5/net/ipv6/route.c linux-3.9.5-vs2.3.6.5/net/ipv6/route.c
25404 --- linux-3.9.5/net/ipv6/route.c 2013-05-31 13:45:32.000000000 +0000
25405 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/route.c 2013-05-31 18:10:38.000000000 +0000
25407 #include <net/netevent.h>
25408 #include <net/netlink.h>
25409 #include <net/nexthop.h>
25410 +#include <linux/vs_inet6.h>
25412 #include <asm/uaccess.h>
25414 @@ -2079,15 +2080,17 @@ int ip6_route_get_saddr(struct net *net,
25415 struct rt6_info *rt,
25416 const struct in6_addr *daddr,
25417 unsigned int prefs,
25418 - struct in6_addr *saddr)
25419 + struct in6_addr *saddr,
25420 + struct nx_info *nxi)
25422 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25424 - if (rt->rt6i_prefsrc.plen)
25425 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25426 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25427 *saddr = rt->rt6i_prefsrc.addr;
25429 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25430 - daddr, prefs, saddr);
25431 + daddr, prefs, saddr, nxi);
25435 @@ -2507,7 +2510,8 @@ static int rt6_fill_node(struct net *net
25436 goto nla_put_failure;
25438 struct in6_addr saddr_buf;
25439 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0 &&
25440 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25441 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0 &&
25442 nla_put(skb, RTA_PREFSRC, 16, &saddr_buf))
25443 goto nla_put_failure;
25445 @@ -2719,6 +2723,7 @@ static int rt6_info_route(struct rt6_inf
25447 struct seq_file *m = p_arg;
25449 + /* FIXME: check for network context? */
25450 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25452 #ifdef CONFIG_IPV6_SUBTREES
25453 diff -NurpP --minimal linux-3.9.5/net/ipv6/tcp_ipv6.c linux-3.9.5-vs2.3.6.5/net/ipv6/tcp_ipv6.c
25454 --- linux-3.9.5/net/ipv6/tcp_ipv6.c 2013-06-11 12:22:40.000000000 +0000
25455 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/tcp_ipv6.c 2013-05-31 17:17:54.000000000 +0000
25458 #include <linux/crypto.h>
25459 #include <linux/scatterlist.h>
25460 +#include <linux/vs_inet6.h>
25462 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25463 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25464 @@ -164,8 +165,15 @@ static int tcp_v6_connect(struct sock *s
25465 * connect() to INADDR_ANY means loopback (BSD'ism).
25468 - if(ipv6_addr_any(&usin->sin6_addr))
25469 - usin->sin6_addr.s6_addr[15] = 0x1;
25470 + if(ipv6_addr_any(&usin->sin6_addr)) {
25471 + struct nx_info *nxi = sk->sk_nx_info;
25473 + if (nxi && nx_info_has_v6(nxi))
25474 + /* FIXME: remap lback? */
25475 + usin->sin6_addr = nxi->v6.ip;
25477 + usin->sin6_addr.s6_addr[15] = 0x1;
25480 addr_type = ipv6_addr_type(&usin->sin6_addr);
25482 diff -NurpP --minimal linux-3.9.5/net/ipv6/udp.c linux-3.9.5-vs2.3.6.5/net/ipv6/udp.c
25483 --- linux-3.9.5/net/ipv6/udp.c 2013-06-11 12:22:40.000000000 +0000
25484 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/udp.c 2013-05-31 18:16:01.000000000 +0000
25485 @@ -46,42 +46,68 @@
25486 #include <net/ip6_checksum.h>
25487 #include <net/xfrm.h>
25488 #include <net/inet6_hashtables.h>
25489 +#include <linux/vs_inet6.h>
25491 #include <linux/proc_fs.h>
25492 #include <linux/seq_file.h>
25493 #include <trace/events/skb.h>
25494 #include "udp_impl.h"
25496 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25497 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25499 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25500 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25501 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25502 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25503 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25504 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25505 - int sk_ipv6only = ipv6_only_sock(sk);
25506 + int sk1_ipv6only = ipv6_only_sock(sk1);
25507 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25508 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25509 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25510 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25512 /* if both are mapped, treat as IPv4 */
25513 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25514 - return (!sk2_ipv6only &&
25515 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25516 + if (!sk2_ipv6only &&
25517 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25518 - sk1_rcv_saddr == sk2_rcv_saddr));
25519 + sk1_rcv_saddr == sk2_rcv_saddr))
25525 if (addr_type2 == IPV6_ADDR_ANY &&
25526 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25530 if (addr_type == IPV6_ADDR_ANY &&
25531 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25533 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25536 if (sk2_rcv_saddr6 &&
25537 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25539 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25545 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25546 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25547 + if (!sk2_rcv_saddr)
25548 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25549 + if (!sk1_rcv_saddr)
25550 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25553 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25554 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25555 + else if (addr_type2 == IPV6_ADDR_ANY)
25556 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25557 + else if (addr_type == IPV6_ADDR_ANY) {
25558 + if (addr_type2 == IPV6_ADDR_MAPPED)
25559 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25561 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25566 static unsigned int udp6_portaddr_hash(struct net *net,
25567 @@ -145,6 +171,10 @@ static inline int compute_score(struct s
25568 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25572 + /* block non nx_info ips */
25573 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25576 if (!ipv6_addr_any(&np->daddr)) {
25577 if (!ipv6_addr_equal(&np->daddr, saddr))
25578 diff -NurpP --minimal linux-3.9.5/net/ipv6/xfrm6_policy.c linux-3.9.5-vs2.3.6.5/net/ipv6/xfrm6_policy.c
25579 --- linux-3.9.5/net/ipv6/xfrm6_policy.c 2013-06-11 12:22:40.000000000 +0000
25580 +++ linux-3.9.5-vs2.3.6.5/net/ipv6/xfrm6_policy.c 2013-05-31 17:17:54.000000000 +0000
25581 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
25582 dev = ip6_dst_idev(dst)->dev;
25583 ipv6_dev_get_saddr(dev_net(dev), dev,
25584 (struct in6_addr *)&daddr->a6, 0,
25585 - (struct in6_addr *)&saddr->a6);
25586 + (struct in6_addr *)&saddr->a6, NULL);
25590 diff -NurpP --minimal linux-3.9.5/net/netfilter/ipvs/ip_vs_xmit.c linux-3.9.5-vs2.3.6.5/net/netfilter/ipvs/ip_vs_xmit.c
25591 --- linux-3.9.5/net/netfilter/ipvs/ip_vs_xmit.c 2013-02-19 13:58:59.000000000 +0000
25592 +++ linux-3.9.5-vs2.3.6.5/net/netfilter/ipvs/ip_vs_xmit.c 2013-05-31 17:17:54.000000000 +0000
25593 @@ -273,7 +273,7 @@ __ip_vs_route_output_v6(struct net *net,
25595 if (ipv6_addr_any(&fl6.saddr) &&
25596 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
25597 - &fl6.daddr, 0, &fl6.saddr) < 0)
25598 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
25601 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
25602 diff -NurpP --minimal linux-3.9.5/net/netlink/af_netlink.c linux-3.9.5-vs2.3.6.5/net/netlink/af_netlink.c
25603 --- linux-3.9.5/net/netlink/af_netlink.c 2013-05-31 13:45:33.000000000 +0000
25604 +++ linux-3.9.5-vs2.3.6.5/net/netlink/af_netlink.c 2013-05-31 17:17:54.000000000 +0000
25606 #include <linux/types.h>
25607 #include <linux/audit.h>
25608 #include <linux/mutex.h>
25609 +#include <linux/vs_context.h>
25610 +#include <linux/vs_network.h>
25611 +#include <linux/vs_limit.h>
25613 #include <net/net_namespace.h>
25614 #include <net/sock.h>
25615 @@ -1976,6 +1979,8 @@ static struct sock *netlink_seq_socket_i
25616 sk_for_each(s, &hash->table[j]) {
25617 if (sock_net(s) != seq_file_net(seq))
25619 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25623 iter->hash_idx = j;
25624 @@ -2010,7 +2015,8 @@ static void *netlink_seq_next(struct seq
25628 - } while (s && sock_net(s) != seq_file_net(seq));
25629 + } while (s && (sock_net(s) != seq_file_net(seq) ||
25630 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
25634 @@ -2022,7 +2028,8 @@ static void *netlink_seq_next(struct seq
25636 for (; j <= hash->mask; j++) {
25637 s = sk_head(&hash->table[j]);
25638 - while (s && sock_net(s) != seq_file_net(seq))
25639 + while (s && (sock_net(s) != seq_file_net(seq) ||
25640 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
25644 diff -NurpP --minimal linux-3.9.5/net/socket.c linux-3.9.5-vs2.3.6.5/net/socket.c
25645 --- linux-3.9.5/net/socket.c 2013-05-31 13:45:33.000000000 +0000
25646 +++ linux-3.9.5-vs2.3.6.5/net/socket.c 2013-05-31 17:17:54.000000000 +0000
25649 #include <net/sock.h>
25650 #include <linux/netfilter.h>
25651 +#include <linux/vs_base.h>
25652 +#include <linux/vs_socket.h>
25653 +#include <linux/vs_inet.h>
25654 +#include <linux/vs_inet6.h>
25656 #include <linux/if_tun.h>
25657 #include <linux/ipv6_route.h>
25658 @@ -617,13 +621,29 @@ static inline int __sock_sendmsg_nosec(s
25659 struct msghdr *msg, size_t size)
25661 struct sock_iocb *si = kiocb_to_siocb(iocb);
25669 - return sock->ops->sendmsg(iocb, sock, msg, size);
25670 + len = sock->ops->sendmsg(iocb, sock, msg, size);
25673 + vx_sock_send(sock->sk, size);
25675 + vx_sock_fail(sock->sk, size);
25677 + vxdprintk(VXD_CBIT(net, 7),
25678 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
25680 + (sock->sk)?sock->sk->sk_nx_info:0,
25681 + (sock->sk)?sock->sk->sk_vx_info:0,
25682 + (sock->sk)?sock->sk->sk_xid:0,
25683 + (sock->sk)?sock->sk->sk_nid:0,
25684 + (unsigned int)size, len);
25688 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
25689 @@ -779,6 +799,7 @@ static inline int __sock_recvmsg_nosec(s
25690 struct msghdr *msg, size_t size, int flags)
25692 struct sock_iocb *si = kiocb_to_siocb(iocb);
25697 @@ -786,7 +807,18 @@ static inline int __sock_recvmsg_nosec(s
25701 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
25702 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
25703 + if ((len >= 0) && sock->sk)
25704 + vx_sock_recv(sock->sk, len);
25705 + vxdprintk(VXD_CBIT(net, 7),
25706 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
25708 + (sock->sk)?sock->sk->sk_nx_info:0,
25709 + (sock->sk)?sock->sk->sk_vx_info:0,
25710 + (sock->sk)?sock->sk->sk_xid:0,
25711 + (sock->sk)?sock->sk->sk_nid:0,
25712 + (unsigned int)size, len);
25716 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
25717 @@ -1269,6 +1301,13 @@ int __sock_create(struct net *net, int f
25718 if (type < 0 || type >= SOCK_MAX)
25721 + if (!nx_check(0, VS_ADMIN)) {
25722 + if (family == PF_INET && !current_nx_info_has_v4())
25723 + return -EAFNOSUPPORT;
25724 + if (family == PF_INET6 && !current_nx_info_has_v6())
25725 + return -EAFNOSUPPORT;
25730 This uglymoron is moved from INET layer to here to avoid
25731 @@ -1403,6 +1442,7 @@ SYSCALL_DEFINE3(socket, int, family, int
25735 + set_bit(SOCK_USER_SOCKET, &sock->flags);
25736 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
25739 @@ -1444,10 +1484,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
25740 err = sock_create(family, type, protocol, &sock1);
25743 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
25745 err = sock_create(family, type, protocol, &sock2);
25747 goto out_release_1;
25748 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
25750 err = sock1->ops->socketpair(sock1, sock2);
25752 diff -NurpP --minimal linux-3.9.5/net/sunrpc/auth.c linux-3.9.5-vs2.3.6.5/net/sunrpc/auth.c
25753 --- linux-3.9.5/net/sunrpc/auth.c 2013-05-31 13:45:33.000000000 +0000
25754 +++ linux-3.9.5-vs2.3.6.5/net/sunrpc/auth.c 2013-06-03 20:11:37.000000000 +0000
25756 #include <linux/sunrpc/clnt.h>
25757 #include <linux/sunrpc/gss_api.h>
25758 #include <linux/spinlock.h>
25759 +#include <linux/vs_tag.h>
25762 # define RPCDBG_FACILITY RPCDBG_AUTH
25763 @@ -480,6 +481,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
25764 memset(&acred, 0, sizeof(acred));
25765 acred.uid = cred->fsuid;
25766 acred.gid = cred->fsgid;
25767 + acred.tag = make_ktag(&init_user_ns, dx_current_tag());
25768 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
25770 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
25771 @@ -520,6 +522,7 @@ rpcauth_bind_root_cred(struct rpc_task *
25772 struct auth_cred acred = {
25773 .uid = GLOBAL_ROOT_UID,
25774 .gid = GLOBAL_ROOT_GID,
25775 + .tag = KTAGT_INIT(dx_current_tag()),
25778 dprintk("RPC: %5u looking up %s cred\n",
25779 diff -NurpP --minimal linux-3.9.5/net/sunrpc/auth_unix.c linux-3.9.5-vs2.3.6.5/net/sunrpc/auth_unix.c
25780 --- linux-3.9.5/net/sunrpc/auth_unix.c 2013-05-31 13:45:33.000000000 +0000
25781 +++ linux-3.9.5-vs2.3.6.5/net/sunrpc/auth_unix.c 2013-06-03 19:35:29.000000000 +0000
25782 @@ -13,11 +13,13 @@
25783 #include <linux/sunrpc/clnt.h>
25784 #include <linux/sunrpc/auth.h>
25785 #include <linux/user_namespace.h>
25786 +#include <linux/vs_tag.h>
25788 #define NFS_NGROUPS 16
25791 struct rpc_cred uc_base;
25794 kgid_t uc_gids[NFS_NGROUPS];
25796 @@ -80,6 +82,7 @@ unx_create_cred(struct rpc_auth *auth, s
25797 groups = NFS_NGROUPS;
25799 cred->uc_gid = acred->gid;
25800 + cred->uc_tag = acred->tag;
25801 for (i = 0; i < groups; i++)
25802 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
25803 if (i < NFS_NGROUPS)
25804 @@ -121,7 +124,9 @@ unx_match(struct auth_cred *acred, struc
25808 - if (!uid_eq(cred->uc_uid, acred->uid) || !gid_eq(cred->uc_gid, acred->gid))
25809 + if (!uid_eq(cred->uc_uid, acred->uid) ||
25810 + !gid_eq(cred->uc_gid, acred->gid) ||
25811 + !tag_eq(cred->uc_tag, acred->tag))
25814 if (acred->group_info != NULL)
25815 @@ -146,7 +151,7 @@ unx_marshal(struct rpc_task *task, __be3
25816 struct rpc_clnt *clnt = task->tk_client;
25817 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
25818 __be32 *base, *hold;
25822 *p++ = htonl(RPC_AUTH_UNIX);
25824 @@ -157,8 +162,11 @@ unx_marshal(struct rpc_task *task, __be3
25826 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
25828 - *p++ = htonl((u32) from_kuid(&init_user_ns, cred->uc_uid));
25829 - *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gid));
25830 + tag = task->tk_client->cl_tag;
25831 + *p++ = htonl((u32) from_kuid(&init_user_ns,
25832 + TAGINO_KUID(tag, cred->uc_uid, cred->uc_tag)));
25833 + *p++ = htonl((u32) from_kgid(&init_user_ns,
25834 + TAGINO_KGID(tag, cred->uc_gid, cred->uc_tag)));
25836 for (i = 0; i < 16 && gid_valid(cred->uc_gids[i]); i++)
25837 *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gids[i]));
25838 diff -NurpP --minimal linux-3.9.5/net/sunrpc/clnt.c linux-3.9.5-vs2.3.6.5/net/sunrpc/clnt.c
25839 --- linux-3.9.5/net/sunrpc/clnt.c 2013-05-31 13:45:33.000000000 +0000
25840 +++ linux-3.9.5-vs2.3.6.5/net/sunrpc/clnt.c 2013-05-31 17:17:54.000000000 +0000
25842 #include <linux/in6.h>
25843 #include <linux/un.h>
25844 #include <linux/rcupdate.h>
25845 +#include <linux/vs_cvirt.h>
25847 #include <linux/sunrpc/clnt.h>
25848 #include <linux/sunrpc/addr.h>
25849 @@ -482,6 +483,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
25850 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
25851 clnt->cl_chatty = 1;
25853 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
25854 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
25855 + clnt->cl_tag = 1; */
25858 EXPORT_SYMBOL_GPL(rpc_create);
25859 diff -NurpP --minimal linux-3.9.5/net/unix/af_unix.c linux-3.9.5-vs2.3.6.5/net/unix/af_unix.c
25860 --- linux-3.9.5/net/unix/af_unix.c 2013-05-31 13:45:33.000000000 +0000
25861 +++ linux-3.9.5-vs2.3.6.5/net/unix/af_unix.c 2013-05-31 17:17:54.000000000 +0000
25862 @@ -114,6 +114,8 @@
25863 #include <linux/mount.h>
25864 #include <net/checksum.h>
25865 #include <linux/security.h>
25866 +#include <linux/vs_context.h>
25867 +#include <linux/vs_limit.h>
25869 struct hlist_head unix_socket_table[2 * UNIX_HASH_SIZE];
25870 EXPORT_SYMBOL_GPL(unix_socket_table);
25871 @@ -270,6 +272,8 @@ static struct sock *__unix_find_socket_b
25872 if (!net_eq(sock_net(s), net))
25875 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25877 if (u->addr->len == len &&
25878 !memcmp(u->addr->name, sunname, len))
25880 @@ -2256,6 +2260,8 @@ static struct sock *unix_from_bucket(str
25881 for (sk = sk_head(&unix_socket_table[bucket]); sk; sk = sk_next(sk)) {
25882 if (sock_net(sk) != seq_file_net(seq))
25884 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25886 if (++count == offset)
25889 @@ -2273,6 +2279,8 @@ static struct sock *unix_next_socket(str
25893 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25895 if (sock_net(sk) == seq_file_net(seq))
25898 diff -NurpP --minimal linux-3.9.5/scripts/checksyscalls.sh linux-3.9.5-vs2.3.6.5/scripts/checksyscalls.sh
25899 --- linux-3.9.5/scripts/checksyscalls.sh 2012-12-11 03:30:57.000000000 +0000
25900 +++ linux-3.9.5-vs2.3.6.5/scripts/checksyscalls.sh 2013-05-31 14:47:11.000000000 +0000
25901 @@ -193,7 +193,6 @@ cat << EOF
25902 #define __IGNORE_afs_syscall
25903 #define __IGNORE_getpmsg
25904 #define __IGNORE_putpmsg
25905 -#define __IGNORE_vserver
25909 diff -NurpP --minimal linux-3.9.5/security/commoncap.c linux-3.9.5-vs2.3.6.5/security/commoncap.c
25910 --- linux-3.9.5/security/commoncap.c 2013-05-31 13:45:34.000000000 +0000
25911 +++ linux-3.9.5-vs2.3.6.5/security/commoncap.c 2013-05-31 15:07:02.000000000 +0000
25912 @@ -76,6 +76,7 @@ int cap_netlink_send(struct sock *sk, st
25913 int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
25914 int cap, int audit)
25916 + struct vx_info *vxi = current_vx_info(); /* FIXME: get vxi from cred? */
25917 struct user_namespace *ns = targ_ns;
25919 /* See if cred has the capability in the target user namespace
25920 @@ -84,8 +85,12 @@ int cap_capable(const struct cred *cred,
25923 /* Do we have the necessary capabilities? */
25924 - if (ns == cred->user_ns)
25925 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
25926 + if (ns == cred->user_ns) {
25927 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
25928 + cap_raised(cred->cap_effective, cap))
25930 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
25933 /* Have we tried all of the parent namespaces? */
25934 if (ns == &init_user_ns)
25935 @@ -628,7 +633,7 @@ int cap_inode_setxattr(struct dentry *de
25937 if (!strncmp(name, XATTR_SECURITY_PREFIX,
25938 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
25939 - !capable(CAP_SYS_ADMIN))
25940 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
25944 @@ -654,7 +659,7 @@ int cap_inode_removexattr(struct dentry
25946 if (!strncmp(name, XATTR_SECURITY_PREFIX,
25947 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
25948 - !capable(CAP_SYS_ADMIN))
25949 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
25953 diff -NurpP --minimal linux-3.9.5/security/selinux/hooks.c linux-3.9.5-vs2.3.6.5/security/selinux/hooks.c
25954 --- linux-3.9.5/security/selinux/hooks.c 2013-05-31 13:45:34.000000000 +0000
25955 +++ linux-3.9.5-vs2.3.6.5/security/selinux/hooks.c 2013-05-31 14:47:11.000000000 +0000
25957 #include <linux/dccp.h>
25958 #include <linux/quota.h>
25959 #include <linux/un.h> /* for Unix socket types */
25960 -#include <net/af_unix.h> /* for Unix socket types */
25961 #include <linux/parser.h>
25962 #include <linux/nfs_mount.h>
25963 #include <net/ipv6.h>