1 diff -NurpP --minimal linux-3.9.4/Documentation/vserver/debug.txt linux-3.9.4-vs2.3.6.3/Documentation/vserver/debug.txt
2 --- linux-3.9.4/Documentation/vserver/debug.txt 1970-01-01 00:00:00.000000000 +0000
3 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/alpha/Kconfig linux-3.9.4-vs2.3.6.3/arch/alpha/Kconfig
160 --- linux-3.9.4/arch/alpha/Kconfig 2013-05-31 13:44:28.000000000 +0000
161 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/alpha/kernel/systbls.S linux-3.9.4-vs2.3.6.3/arch/alpha/kernel/systbls.S
172 --- linux-3.9.4/arch/alpha/kernel/systbls.S 2013-02-19 13:56:11.000000000 +0000
173 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/alpha/kernel/traps.c linux-3.9.4-vs2.3.6.3/arch/alpha/kernel/traps.c
184 --- linux-3.9.4/arch/alpha/kernel/traps.c 2013-05-31 13:44:28.000000000 +0000
185 +++ linux-3.9.4-vs2.3.6.3/arch/alpha/kernel/traps.c 2013-05-31 14:47:11.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.4/arch/arm/Kconfig linux-3.9.4-vs2.3.6.3/arch/arm/Kconfig
197 --- linux-3.9.4/arch/arm/Kconfig 2013-05-31 13:44:29.000000000 +0000
198 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/arm/kernel/calls.S linux-3.9.4-vs2.3.6.3/arch/arm/kernel/calls.S
209 --- linux-3.9.4/arch/arm/kernel/calls.S 2013-05-31 13:44:29.000000000 +0000
210 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/arm/kernel/process.c linux-3.9.4-vs2.3.6.3/arch/arm/kernel/process.c
221 --- linux-3.9.4/arch/arm/kernel/process.c 2013-05-31 13:44:29.000000000 +0000
222 +++ linux-3.9.4-vs2.3.6.3/arch/arm/kernel/process.c 2013-05-31 14:47:11.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.4/arch/arm/kernel/traps.c linux-3.9.4-vs2.3.6.3/arch/arm/kernel/traps.c
234 --- linux-3.9.4/arch/arm/kernel/traps.c 2013-05-31 13:44:29.000000000 +0000
235 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/cris/Kconfig linux-3.9.4-vs2.3.6.3/arch/cris/Kconfig
248 --- linux-3.9.4/arch/cris/Kconfig 2013-05-31 13:44:37.000000000 +0000
249 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/h8300/Kconfig linux-3.9.4-vs2.3.6.3/arch/h8300/Kconfig
260 --- linux-3.9.4/arch/h8300/Kconfig 2013-05-31 13:44:38.000000000 +0000
261 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/ia64/Kconfig linux-3.9.4-vs2.3.6.3/arch/ia64/Kconfig
272 --- linux-3.9.4/arch/ia64/Kconfig 2013-05-31 13:44:38.000000000 +0000
273 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/ia64/kernel/entry.S linux-3.9.4-vs2.3.6.3/arch/ia64/kernel/entry.S
284 --- linux-3.9.4/arch/ia64/kernel/entry.S 2013-05-31 13:44:38.000000000 +0000
285 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/ia64/kernel/process.c linux-3.9.4-vs2.3.6.3/arch/ia64/kernel/process.c
296 --- linux-3.9.4/arch/ia64/kernel/process.c 2013-05-31 13:44:38.000000000 +0000
297 +++ linux-3.9.4-vs2.3.6.3/arch/ia64/kernel/process.c 2013-05-31 14:47:11.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.4/arch/ia64/kernel/ptrace.c linux-3.9.4-vs2.3.6.3/arch/ia64/kernel/ptrace.c
310 --- linux-3.9.4/arch/ia64/kernel/ptrace.c 2013-02-19 13:56:51.000000000 +0000
311 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/ia64/kernel/traps.c linux-3.9.4-vs2.3.6.3/arch/ia64/kernel/traps.c
321 --- linux-3.9.4/arch/ia64/kernel/traps.c 2013-05-31 13:44:38.000000000 +0000
322 +++ linux-3.9.4-vs2.3.6.3/arch/ia64/kernel/traps.c 2013-05-31 14:47:11.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.4/arch/m32r/kernel/traps.c linux-3.9.4-vs2.3.6.3/arch/m32r/kernel/traps.c
348 --- linux-3.9.4/arch/m32r/kernel/traps.c 2012-12-11 03:30:57.000000000 +0000
349 +++ linux-3.9.4-vs2.3.6.3/arch/m32r/kernel/traps.c 2013-05-31 14:47:11.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.4/arch/m68k/Kconfig linux-3.9.4-vs2.3.6.3/arch/m68k/Kconfig
363 --- linux-3.9.4/arch/m68k/Kconfig 2013-05-31 13:44:38.000000000 +0000
364 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/mips/Kconfig linux-3.9.4-vs2.3.6.3/arch/mips/Kconfig
375 --- linux-3.9.4/arch/mips/Kconfig 2013-05-31 13:44:39.000000000 +0000
376 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/mips/kernel/ptrace.c linux-3.9.4-vs2.3.6.3/arch/mips/kernel/ptrace.c
387 --- linux-3.9.4/arch/mips/kernel/ptrace.c 2013-05-31 13:44:42.000000000 +0000
388 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/mips/kernel/scall32-o32.S linux-3.9.4-vs2.3.6.3/arch/mips/kernel/scall32-o32.S
408 --- linux-3.9.4/arch/mips/kernel/scall32-o32.S 2013-05-31 13:44:42.000000000 +0000
409 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/mips/kernel/scall64-64.S linux-3.9.4-vs2.3.6.3/arch/mips/kernel/scall64-64.S
420 --- linux-3.9.4/arch/mips/kernel/scall64-64.S 2013-05-31 13:44:42.000000000 +0000
421 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/mips/kernel/scall64-n32.S linux-3.9.4-vs2.3.6.3/arch/mips/kernel/scall64-n32.S
432 --- linux-3.9.4/arch/mips/kernel/scall64-n32.S 2013-05-31 13:44:42.000000000 +0000
433 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/mips/kernel/scall64-o32.S linux-3.9.4-vs2.3.6.3/arch/mips/kernel/scall64-o32.S
444 --- linux-3.9.4/arch/mips/kernel/scall64-o32.S 2013-05-31 13:44:42.000000000 +0000
445 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/mips/kernel/traps.c linux-3.9.4-vs2.3.6.3/arch/mips/kernel/traps.c
456 --- linux-3.9.4/arch/mips/kernel/traps.c 2013-05-31 13:44:42.000000000 +0000
457 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/parisc/Kconfig linux-3.9.4-vs2.3.6.3/arch/parisc/Kconfig
473 --- linux-3.9.4/arch/parisc/Kconfig 2013-05-31 13:44:44.000000000 +0000
474 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/parisc/kernel/syscall_table.S linux-3.9.4-vs2.3.6.3/arch/parisc/kernel/syscall_table.S
485 --- linux-3.9.4/arch/parisc/kernel/syscall_table.S 2013-05-31 13:44:44.000000000 +0000
486 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/parisc/kernel/traps.c linux-3.9.4-vs2.3.6.3/arch/parisc/kernel/traps.c
497 --- linux-3.9.4/arch/parisc/kernel/traps.c 2013-05-31 13:44:44.000000000 +0000
498 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/parisc/mm/fault.c linux-3.9.4-vs2.3.6.3/arch/parisc/mm/fault.c
523 --- linux-3.9.4/arch/parisc/mm/fault.c 2013-05-31 13:44:44.000000000 +0000
524 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/powerpc/Kconfig linux-3.9.4-vs2.3.6.3/arch/powerpc/Kconfig
538 --- linux-3.9.4/arch/powerpc/Kconfig 2013-05-31 13:44:44.000000000 +0000
539 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/powerpc/include/uapi/asm/unistd.h linux-3.9.4-vs2.3.6.3/arch/powerpc/include/uapi/asm/unistd.h
550 --- linux-3.9.4/arch/powerpc/include/uapi/asm/unistd.h 2013-05-31 13:44:44.000000000 +0000
551 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/powerpc/kernel/process.c linux-3.9.4-vs2.3.6.3/arch/powerpc/kernel/process.c
562 --- linux-3.9.4/arch/powerpc/kernel/process.c 2013-05-31 13:44:44.000000000 +0000
563 +++ linux-3.9.4-vs2.3.6.3/arch/powerpc/kernel/process.c 2013-05-31 14:47:11.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.4/arch/powerpc/kernel/traps.c linux-3.9.4-vs2.3.6.3/arch/powerpc/kernel/traps.c
577 --- linux-3.9.4/arch/powerpc/kernel/traps.c 2013-05-31 14:22:26.000000000 +0000
578 +++ linux-3.9.4-vs2.3.6.3/arch/powerpc/kernel/traps.c 2013-05-31 14:47:11.000000000 +0000
579 @@ -1167,8 +1167,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.4/arch/s390/Kconfig linux-3.9.4-vs2.3.6.3/arch/s390/Kconfig
592 --- linux-3.9.4/arch/s390/Kconfig 2013-05-31 13:44:45.000000000 +0000
593 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/s390/include/asm/tlb.h linux-3.9.4-vs2.3.6.3/arch/s390/include/asm/tlb.h
604 --- linux-3.9.4/arch/s390/include/asm/tlb.h 2012-12-11 03:30:57.000000000 +0000
605 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/s390/include/uapi/asm/unistd.h linux-3.9.4-vs2.3.6.3/arch/s390/include/uapi/asm/unistd.h
615 --- linux-3.9.4/arch/s390/include/uapi/asm/unistd.h 2013-02-19 13:57:16.000000000 +0000
616 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/s390/kernel/ptrace.c linux-3.9.4-vs2.3.6.3/arch/s390/kernel/ptrace.c
627 --- linux-3.9.4/arch/s390/kernel/ptrace.c 2012-12-11 03:30:57.000000000 +0000
628 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/s390/kernel/syscalls.S linux-3.9.4-vs2.3.6.3/arch/s390/kernel/syscalls.S
638 --- linux-3.9.4/arch/s390/kernel/syscalls.S 2013-05-31 13:44:45.000000000 +0000
639 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/sh/Kconfig linux-3.9.4-vs2.3.6.3/arch/sh/Kconfig
650 --- linux-3.9.4/arch/sh/Kconfig 2013-05-31 13:44:45.000000000 +0000
651 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/sh/kernel/irq.c linux-3.9.4-vs2.3.6.3/arch/sh/kernel/irq.c
662 --- linux-3.9.4/arch/sh/kernel/irq.c 2012-12-11 03:30:57.000000000 +0000
663 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/sparc/Kconfig linux-3.9.4-vs2.3.6.3/arch/sparc/Kconfig
673 --- linux-3.9.4/arch/sparc/Kconfig 2013-05-31 13:44:47.000000000 +0000
674 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/sparc/include/uapi/asm/unistd.h linux-3.9.4-vs2.3.6.3/arch/sparc/include/uapi/asm/unistd.h
685 --- linux-3.9.4/arch/sparc/include/uapi/asm/unistd.h 2013-02-19 13:57:17.000000000 +0000
686 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/sparc/kernel/systbls_32.S linux-3.9.4-vs2.3.6.3/arch/sparc/kernel/systbls_32.S
697 --- linux-3.9.4/arch/sparc/kernel/systbls_32.S 2013-05-31 13:44:48.000000000 +0000
698 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/sparc/kernel/systbls_64.S linux-3.9.4-vs2.3.6.3/arch/sparc/kernel/systbls_64.S
709 --- linux-3.9.4/arch/sparc/kernel/systbls_64.S 2013-05-31 13:44:48.000000000 +0000
710 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/um/Kconfig.rest linux-3.9.4-vs2.3.6.3/arch/um/Kconfig.rest
730 --- linux-3.9.4/arch/um/Kconfig.rest 2012-12-11 03:30:57.000000000 +0000
731 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/x86/Kconfig linux-3.9.4-vs2.3.6.3/arch/x86/Kconfig
742 --- linux-3.9.4/arch/x86/Kconfig 2013-05-31 14:22:26.000000000 +0000
743 +++ linux-3.9.4-vs2.3.6.3/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.4/arch/x86/syscalls/syscall_32.tbl linux-3.9.4-vs2.3.6.3/arch/x86/syscalls/syscall_32.tbl
754 --- linux-3.9.4/arch/x86/syscalls/syscall_32.tbl 2013-05-31 13:44:50.000000000 +0000
755 +++ linux-3.9.4-vs2.3.6.3/arch/x86/syscalls/syscall_32.tbl 2013-05-31 14:47:11.000000000 +0000
757 270 i386 tgkill sys_tgkill
758 271 i386 utimes sys_utimes compat_sys_utimes
759 272 i386 fadvise64_64 sys_fadvise64_64 sys32_fadvise64_64
761 +273 i386 vserver sys_vserver sys32_vserver
762 274 i386 mbind sys_mbind
763 275 i386 get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy
764 276 i386 set_mempolicy sys_set_mempolicy
765 diff -NurpP --minimal linux-3.9.4/arch/x86/syscalls/syscall_64.tbl linux-3.9.4-vs2.3.6.3/arch/x86/syscalls/syscall_64.tbl
766 --- linux-3.9.4/arch/x86/syscalls/syscall_64.tbl 2013-05-31 13:44:50.000000000 +0000
767 +++ linux-3.9.4-vs2.3.6.3/arch/x86/syscalls/syscall_64.tbl 2013-05-31 14:47:11.000000000 +0000
769 233 common epoll_ctl sys_epoll_ctl
770 234 common tgkill sys_tgkill
771 235 common utimes sys_utimes
773 +236 64 vserver sys_vserver
774 237 common mbind sys_mbind
775 238 common set_mempolicy sys_set_mempolicy
776 239 common get_mempolicy sys_get_mempolicy
777 diff -NurpP --minimal linux-3.9.4/drivers/block/Kconfig linux-3.9.4-vs2.3.6.3/drivers/block/Kconfig
778 --- linux-3.9.4/drivers/block/Kconfig 2013-05-31 13:44:51.000000000 +0000
779 +++ linux-3.9.4-vs2.3.6.3/drivers/block/Kconfig 2013-05-31 14:47:11.000000000 +0000
780 @@ -278,6 +278,13 @@ config BLK_DEV_CRYPTOLOOP
782 source "drivers/block/drbd/Kconfig"
784 +config BLK_DEV_VROOT
785 + tristate "Virtual Root device support"
786 + depends on QUOTACTL
788 + Saying Y here will allow you to use quota/fs ioctls on a shared
789 + partition within a virtual server without compromising security.
792 tristate "Network block device support"
794 diff -NurpP --minimal linux-3.9.4/drivers/block/Makefile linux-3.9.4-vs2.3.6.3/drivers/block/Makefile
795 --- linux-3.9.4/drivers/block/Makefile 2013-05-31 13:44:51.000000000 +0000
796 +++ linux-3.9.4-vs2.3.6.3/drivers/block/Makefile 2013-05-31 14:47:11.000000000 +0000
797 @@ -33,6 +33,7 @@ obj-$(CONFIG_VIRTIO_BLK) += virtio_blk.o
798 obj-$(CONFIG_VIODASD) += viodasd.o
799 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
800 obj-$(CONFIG_BLK_DEV_HD) += hd.o
801 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
803 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
804 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
805 diff -NurpP --minimal linux-3.9.4/drivers/block/loop.c linux-3.9.4-vs2.3.6.3/drivers/block/loop.c
806 --- linux-3.9.4/drivers/block/loop.c 2013-05-31 13:44:51.000000000 +0000
807 +++ linux-3.9.4-vs2.3.6.3/drivers/block/loop.c 2013-05-31 14:47:11.000000000 +0000
809 #include <linux/sysfs.h>
810 #include <linux/miscdevice.h>
811 #include <linux/falloc.h>
812 +#include <linux/vs_context.h>
814 #include <asm/uaccess.h>
816 @@ -882,6 +883,7 @@ static int loop_set_fd(struct loop_devic
817 lo->lo_blocksize = lo_blocksize;
818 lo->lo_device = bdev;
819 lo->lo_flags = lo_flags;
820 + lo->lo_xid = vx_current_xid();
821 lo->lo_backing_file = file;
822 lo->transfer = transfer_none;
824 @@ -1033,6 +1035,7 @@ static int loop_clr_fd(struct loop_devic
825 lo->lo_sizelimit = 0;
826 lo->lo_encrypt_key_size = 0;
827 lo->lo_thread = NULL;
829 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
830 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
831 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
832 @@ -1076,7 +1079,7 @@ loop_set_status(struct loop_device *lo,
834 if (lo->lo_encrypt_key_size &&
835 !uid_eq(lo->lo_key_owner, uid) &&
836 - !capable(CAP_SYS_ADMIN))
837 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
839 if (lo->lo_state != Lo_bound)
841 @@ -1166,7 +1169,8 @@ loop_get_status(struct loop_device *lo,
842 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
843 info->lo_encrypt_type =
844 lo->lo_encryption ? lo->lo_encryption->number : 0;
845 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
846 + if (lo->lo_encrypt_key_size &&
847 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
848 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
849 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
850 lo->lo_encrypt_key_size);
851 @@ -1508,6 +1512,11 @@ static int lo_open(struct block_device *
855 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P)) {
860 mutex_lock(&lo->lo_ctl_mutex);
862 mutex_unlock(&lo->lo_ctl_mutex);
863 diff -NurpP --minimal linux-3.9.4/drivers/block/vroot.c linux-3.9.4-vs2.3.6.3/drivers/block/vroot.c
864 --- linux-3.9.4/drivers/block/vroot.c 1970-01-01 00:00:00.000000000 +0000
865 +++ linux-3.9.4-vs2.3.6.3/drivers/block/vroot.c 2013-05-31 14:47:11.000000000 +0000
868 + * linux/drivers/block/vroot.c
870 + * written by Herbert Pötzl, 9/11/2002
871 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
873 + * based on the loop.c code by Theodore Ts'o.
875 + * Copyright (C) 2002-2007 by Herbert Pötzl.
876 + * Redistribution of this file is permitted under the
877 + * GNU General Public License.
881 +#include <linux/module.h>
882 +#include <linux/moduleparam.h>
883 +#include <linux/file.h>
884 +#include <linux/major.h>
885 +#include <linux/blkdev.h>
886 +#include <linux/slab.h>
888 +#include <linux/vroot.h>
889 +#include <linux/vs_context.h>
892 +static int max_vroot = 8;
894 +static struct vroot_device *vroot_dev;
895 +static struct gendisk **disks;
898 +static int vroot_set_dev(
899 + struct vroot_device *vr,
900 + struct block_device *bdev,
903 + struct block_device *real_bdev;
905 + struct inode *inode;
909 + if (vr->vr_state != Vr_unbound)
918 + inode = file->f_dentry->d_inode;
921 + if (S_ISBLK(inode->i_mode)) {
922 + real_bdev = inode->i_bdev;
923 + vr->vr_device = real_bdev;
924 + __iget(real_bdev->bd_inode);
928 + vxdprintk(VXD_CBIT(misc, 0),
929 + "vroot[%d]_set_dev: dev=" VXF_DEV,
930 + vr->vr_number, VXD_DEV(real_bdev));
932 + vr->vr_state = Vr_bound;
941 +static int vroot_clr_dev(
942 + struct vroot_device *vr,
943 + struct block_device *bdev)
945 + struct block_device *real_bdev;
947 + if (vr->vr_state != Vr_bound)
949 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
952 + real_bdev = vr->vr_device;
954 + vxdprintk(VXD_CBIT(misc, 0),
955 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
956 + vr->vr_number, VXD_DEV(real_bdev));
959 + vr->vr_state = Vr_unbound;
960 + vr->vr_device = NULL;
965 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
966 + unsigned int cmd, unsigned long arg)
968 + struct vroot_device *vr = bdev->bd_disk->private_data;
971 + down(&vr->vr_ctl_mutex);
973 + case VROOT_SET_DEV:
974 + err = vroot_set_dev(vr, bdev, arg);
976 + case VROOT_CLR_DEV:
977 + err = vroot_clr_dev(vr, bdev);
983 + up(&vr->vr_ctl_mutex);
987 +static int vr_open(struct block_device *bdev, fmode_t mode)
989 + struct vroot_device *vr = bdev->bd_disk->private_data;
991 + down(&vr->vr_ctl_mutex);
993 + up(&vr->vr_ctl_mutex);
997 +static int vr_release(struct gendisk *disk, fmode_t mode)
999 + struct vroot_device *vr = disk->private_data;
1001 + down(&vr->vr_ctl_mutex);
1003 + up(&vr->vr_ctl_mutex);
1007 +static struct block_device_operations vr_fops = {
1008 + .owner = THIS_MODULE,
1010 + .release = vr_release,
1011 + .ioctl = vr_ioctl,
1014 +static void vroot_make_request(struct request_queue *q, struct bio *bio)
1016 + printk("vroot_make_request %p, %p\n", q, bio);
1017 + bio_io_error(bio);
1020 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1022 + struct inode *inode = bdev->bd_inode;
1023 + struct vroot_device *vr;
1024 + struct block_device *real_bdev;
1025 + int minor = iminor(inode);
1027 + vr = &vroot_dev[minor];
1028 + real_bdev = vr->vr_device;
1030 + vxdprintk(VXD_CBIT(misc, 0),
1031 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1032 + vr->vr_number, VXD_DEV(real_bdev));
1034 + if (vr->vr_state != Vr_bound)
1035 + return ERR_PTR(-ENXIO);
1037 + __iget(real_bdev->bd_inode);
1044 + * And now the modules code and kernel interface.
1047 +module_param(max_vroot, int, 0);
1049 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1050 +MODULE_LICENSE("GPL");
1051 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1053 +MODULE_AUTHOR ("Herbert Pötzl");
1054 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1057 +int __init vroot_init(void)
1061 + if (max_vroot < 1 || max_vroot > 256) {
1062 + max_vroot = MAX_VROOT_DEFAULT;
1063 + printk(KERN_WARNING "vroot: invalid max_vroot "
1064 + "(must be between 1 and 256), "
1065 + "using default (%d)\n", max_vroot);
1068 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1072 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1075 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1077 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1081 + for (i = 0; i < max_vroot; i++) {
1082 + disks[i] = alloc_disk(1);
1085 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1086 + if (!disks[i]->queue)
1088 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1091 + for (i = 0; i < max_vroot; i++) {
1092 + struct vroot_device *vr = &vroot_dev[i];
1093 + struct gendisk *disk = disks[i];
1095 + memset(vr, 0, sizeof(*vr));
1096 + sema_init(&vr->vr_ctl_mutex, 1);
1097 + vr->vr_number = i;
1098 + disk->major = VROOT_MAJOR;
1099 + disk->first_minor = i;
1100 + disk->fops = &vr_fops;
1101 + sprintf(disk->disk_name, "vroot%d", i);
1102 + disk->private_data = vr;
1105 + err = register_vroot_grb(&__vroot_get_real_bdev);
1109 + for (i = 0; i < max_vroot; i++)
1110 + add_disk(disks[i]);
1111 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1116 + put_disk(disks[i]);
1121 + unregister_blkdev(VROOT_MAJOR, "vroot");
1122 + printk(KERN_ERR "vroot: ran out of memory\n");
1126 +void vroot_exit(void)
1130 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1131 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1133 + for (i = 0; i < max_vroot; i++) {
1134 + del_gendisk(disks[i]);
1135 + put_disk(disks[i]);
1137 + unregister_blkdev(VROOT_MAJOR, "vroot");
1143 +module_init(vroot_init);
1144 +module_exit(vroot_exit);
1148 +static int __init max_vroot_setup(char *str)
1150 + max_vroot = simple_strtol(str, NULL, 0);
1154 +__setup("max_vroot=", max_vroot_setup);
1158 diff -NurpP --minimal linux-3.9.4/drivers/infiniband/Kconfig linux-3.9.4-vs2.3.6.3/drivers/infiniband/Kconfig
1159 --- linux-3.9.4/drivers/infiniband/Kconfig 2012-12-11 03:30:57.000000000 +0000
1160 +++ linux-3.9.4-vs2.3.6.3/drivers/infiniband/Kconfig 2013-05-31 14:47:11.000000000 +0000
1161 @@ -39,7 +39,7 @@ config INFINIBAND_USER_MEM
1162 config INFINIBAND_ADDR_TRANS
1165 - depends on !(INFINIBAND = y && IPV6 = m)
1166 + depends on !(INFINIBAND = y && IPV6 = y)
1169 source "drivers/infiniband/hw/mthca/Kconfig"
1170 diff -NurpP --minimal linux-3.9.4/drivers/infiniband/core/addr.c linux-3.9.4-vs2.3.6.3/drivers/infiniband/core/addr.c
1171 --- linux-3.9.4/drivers/infiniband/core/addr.c 2012-12-11 03:30:57.000000000 +0000
1172 +++ linux-3.9.4-vs2.3.6.3/drivers/infiniband/core/addr.c 2013-05-31 14:47:11.000000000 +0000
1173 @@ -261,7 +261,7 @@ static int addr6_resolve(struct sockaddr
1175 if (ipv6_addr_any(&fl6.saddr)) {
1176 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1177 - &fl6.daddr, 0, &fl6.saddr);
1178 + &fl6.daddr, 0, &fl6.saddr, NULL);
1182 diff -NurpP --minimal linux-3.9.4/drivers/md/dm-ioctl.c linux-3.9.4-vs2.3.6.3/drivers/md/dm-ioctl.c
1183 --- linux-3.9.4/drivers/md/dm-ioctl.c 2013-05-31 13:44:59.000000000 +0000
1184 +++ linux-3.9.4-vs2.3.6.3/drivers/md/dm-ioctl.c 2013-05-31 14:47:11.000000000 +0000
1186 #include <linux/dm-ioctl.h>
1187 #include <linux/hdreg.h>
1188 #include <linux/compat.h>
1189 +#include <linux/vs_context.h>
1191 #include <asm/uaccess.h>
1193 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1194 unsigned int h = hash_str(str);
1196 list_for_each_entry (hc, _name_buckets + h, name_list)
1197 - if (!strcmp(hc->name, str)) {
1198 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1199 + !strcmp(hc->name, str)) {
1203 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1204 unsigned int h = hash_str(str);
1206 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1207 - if (!strcmp(hc->uuid, str)) {
1208 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1209 + !strcmp(hc->uuid, str)) {
1213 @@ -131,13 +134,15 @@ static struct hash_cell *__get_uuid_cell
1214 static struct hash_cell *__get_dev_cell(uint64_t dev)
1216 struct mapped_device *md;
1217 - struct hash_cell *hc;
1218 + struct hash_cell *hc = NULL;
1220 md = dm_get_md(huge_decode_dev(dev));
1224 - hc = dm_get_mdptr(md);
1225 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1226 + hc = dm_get_mdptr(md);
1231 @@ -445,6 +450,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1233 static int remove_all(struct dm_ioctl *param, size_t param_size)
1235 + if (!vx_check(0, VS_ADMIN))
1238 dm_hash_remove_all(1);
1239 param->data_size = 0;
1241 @@ -492,6 +500,8 @@ static int list_devices(struct dm_ioctl
1243 for (i = 0; i < NUM_BUCKETS; i++) {
1244 list_for_each_entry (hc, _name_buckets + i, name_list) {
1245 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1247 needed += sizeof(struct dm_name_list);
1248 needed += strlen(hc->name) + 1;
1249 needed += ALIGN_MASK;
1250 @@ -515,6 +525,8 @@ static int list_devices(struct dm_ioctl
1252 for (i = 0; i < NUM_BUCKETS; i++) {
1253 list_for_each_entry (hc, _name_buckets + i, name_list) {
1254 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1257 old_nl->next = (uint32_t) ((void *) nl -
1259 @@ -1722,8 +1734,8 @@ static int ctl_ioctl(uint command, struc
1260 size_t input_param_size;
1261 struct dm_ioctl param_kernel;
1263 - /* only root can play with this */
1264 - if (!capable(CAP_SYS_ADMIN))
1265 + /* only root and certain contexts can play with this */
1266 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1269 if (_IOC_TYPE(command) != DM_IOCTL)
1270 diff -NurpP --minimal linux-3.9.4/drivers/md/dm.c linux-3.9.4-vs2.3.6.3/drivers/md/dm.c
1271 --- linux-3.9.4/drivers/md/dm.c 2013-05-31 13:44:59.000000000 +0000
1272 +++ linux-3.9.4-vs2.3.6.3/drivers/md/dm.c 2013-05-31 14:47:11.000000000 +0000
1274 #include <linux/idr.h>
1275 #include <linux/hdreg.h>
1276 #include <linux/delay.h>
1277 +#include <linux/vs_base.h>
1279 #include <trace/events/block.h>
1281 @@ -125,6 +126,7 @@ struct mapped_device {
1284 atomic_t open_count;
1287 unsigned long flags;
1289 @@ -317,6 +319,7 @@ int dm_deleting_md(struct mapped_device
1290 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1292 struct mapped_device *md;
1295 spin_lock(&_minor_lock);
1297 @@ -325,18 +328,19 @@ static int dm_blk_open(struct block_devi
1300 if (test_bit(DMF_FREEING, &md->flags) ||
1301 - dm_deleting_md(md)) {
1303 + dm_deleting_md(md))
1307 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1312 atomic_inc(&md->open_count);
1316 spin_unlock(&_minor_lock);
1318 - return md ? 0 : -ENXIO;
1322 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1323 @@ -547,6 +551,14 @@ int dm_set_geometry(struct mapped_device
1328 + * Get the xid associated with a dm device
1330 +xid_t dm_get_xid(struct mapped_device *md)
1335 /*-----------------------------------------------------------------
1337 * A more elegant soln is in the works that uses the queue
1338 @@ -1884,6 +1896,7 @@ static struct mapped_device *alloc_dev(i
1339 INIT_LIST_HEAD(&md->uevent_list);
1340 spin_lock_init(&md->uevent_lock);
1342 + md->xid = vx_current_xid();
1343 md->queue = blk_alloc_queue(GFP_KERNEL);
1346 diff -NurpP --minimal linux-3.9.4/drivers/md/dm.h linux-3.9.4-vs2.3.6.3/drivers/md/dm.h
1347 --- linux-3.9.4/drivers/md/dm.h 2013-02-19 13:57:51.000000000 +0000
1348 +++ linux-3.9.4-vs2.3.6.3/drivers/md/dm.h 2013-05-31 14:47:11.000000000 +0000
1349 @@ -46,6 +46,8 @@ struct dm_dev_internal {
1351 struct dm_md_mempools;
1353 +xid_t dm_get_xid(struct mapped_device *md);
1355 /*-----------------------------------------------------------------
1356 * Internal table functions.
1357 *---------------------------------------------------------------*/
1358 diff -NurpP --minimal linux-3.9.4/drivers/net/tun.c linux-3.9.4-vs2.3.6.3/drivers/net/tun.c
1359 --- linux-3.9.4/drivers/net/tun.c 2013-05-31 14:22:27.000000000 +0000
1360 +++ linux-3.9.4-vs2.3.6.3/drivers/net/tun.c 2013-05-31 20:01:45.000000000 +0000
1362 #include <linux/nsproxy.h>
1363 #include <linux/virtio_net.h>
1364 #include <linux/rcupdate.h>
1365 +#include <linux/vs_network.h>
1366 #include <net/net_namespace.h>
1367 #include <net/netns/generic.h>
1368 #include <net/rtnetlink.h>
1369 @@ -164,6 +165,7 @@ struct tun_struct {
1375 struct net_device *dev;
1376 netdev_features_t set_features;
1377 @@ -380,6 +382,7 @@ static inline bool tun_not_capable(struc
1378 return ((uid_valid(tun->owner) && !uid_eq(cred->euid, tun->owner)) ||
1379 (gid_valid(tun->group) && !in_egroup_p(tun->group))) &&
1380 !ns_capable(net->user_ns, CAP_NET_ADMIN);
1381 + /* !cap_raised(current_cap(), CAP_NET_ADMIN) */
1384 static void tun_set_real_num_queues(struct tun_struct *tun)
1385 @@ -1404,6 +1407,7 @@ static void tun_setup(struct net_device
1387 tun->owner = INVALID_UID;
1388 tun->group = INVALID_GID;
1389 + tun->nid = nx_current_nid();
1391 dev->ethtool_ops = &tun_ethtool_ops;
1392 dev->destructor = tun_free_netdev;
1393 @@ -1591,6 +1595,9 @@ static int tun_set_iff(struct net *net,
1397 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1400 err = tun_attach(tun, file);
1403 @@ -1605,7 +1612,7 @@ static int tun_set_iff(struct net *net,
1404 int queues = ifr->ifr_flags & IFF_MULTI_QUEUE ?
1407 - if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
1408 + if (!vx_ns_capable(net->user_ns, CAP_NET_ADMIN, NXC_TUN_CREATE))
1410 err = security_tun_dev_create();
1412 @@ -1950,6 +1957,16 @@ static long __tun_chr_ioctl(struct file
1413 from_kgid(&init_user_ns, tun->group));
1417 + if (!capable(CAP_CONTEXT))
1420 + /* Set nid owner of the device */
1421 + tun->nid = (nid_t) arg;
1423 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1427 /* Only allow setting the type when the interface is down */
1428 if (tun->dev->flags & IFF_UP) {
1429 diff -NurpP --minimal linux-3.9.4/drivers/staging/csr/csr_wifi_hip_xbv.c linux-3.9.4-vs2.3.6.3/drivers/staging/csr/csr_wifi_hip_xbv.c
1430 --- linux-3.9.4/drivers/staging/csr/csr_wifi_hip_xbv.c 2013-02-19 13:58:32.000000000 +0000
1431 +++ linux-3.9.4-vs2.3.6.3/drivers/staging/csr/csr_wifi_hip_xbv.c 2013-05-31 14:47:11.000000000 +0000
1432 @@ -55,7 +55,7 @@ typedef struct
1440 #define TAG_EQ(i, v) (((i)[0] == (v)[0]) && \
1441 @@ -90,7 +90,7 @@ typedef struct
1445 -static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag);
1446 +static s32 read_tag(card_t *card, ct_t *ct, ctag_t *tag);
1447 static s32 read_bytes(card_t *card, ct_t *ct, void *buf, u32 len);
1448 static s32 read_uint(card_t *card, ct_t *ct, u32 *u, u32 len);
1449 static s32 xbv_check(xbv1_t *fwinfo, const xbv_stack_t *stack,
1450 @@ -160,7 +160,7 @@ static u32 write_fwdl_to_ptdl(void *buf,
1451 CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo)
1459 @@ -505,7 +505,7 @@ static u32 xbv2uint(u8 *ptr, s32 len)
1463 -static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag)
1464 +static s32 read_tag(card_t *card, ct_t *ct, ctag_t *tag)
1468 diff -NurpP --minimal linux-3.9.4/drivers/tty/sysrq.c linux-3.9.4-vs2.3.6.3/drivers/tty/sysrq.c
1469 --- linux-3.9.4/drivers/tty/sysrq.c 2013-05-31 13:45:19.000000000 +0000
1470 +++ linux-3.9.4-vs2.3.6.3/drivers/tty/sysrq.c 2013-05-31 15:08:19.000000000 +0000
1472 #include <linux/input.h>
1473 #include <linux/uaccess.h>
1474 #include <linux/moduleparam.h>
1475 +#include <linux/vserver/debug.h>
1477 #include <asm/ptrace.h>
1478 #include <asm/irq_regs.h>
1479 @@ -401,6 +402,21 @@ static struct sysrq_key_op sysrq_unrt_op
1480 .enable_mask = SYSRQ_ENABLE_RTNICE,
1484 +#ifdef CONFIG_VSERVER_DEBUG
1485 +static void sysrq_handle_vxinfo(int key)
1487 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1490 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1491 + .handler = sysrq_handle_vxinfo,
1492 + .help_msg = "conteXt",
1493 + .action_msg = "Show Context Info",
1494 + .enable_mask = SYSRQ_ENABLE_DUMP,
1498 /* Key Operations table and lock */
1499 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1501 @@ -456,7 +472,11 @@ static struct sysrq_key_op *sysrq_key_ta
1502 &sysrq_showstate_blocked_op, /* w */
1503 /* x: May be registered on ppc/powerpc for xmon */
1504 /* x: May be registered on sparc64 for global PMU dump */
1505 +#ifdef CONFIG_VSERVER_DEBUG
1506 + &sysrq_showvxinfo_op, /* x */
1510 /* y: May be registered on sparc64 for global register dump */
1512 &sysrq_ftrace_dump_op, /* z */
1513 @@ -471,6 +491,8 @@ static int sysrq_key_table_key2index(int
1515 else if ((key >= 'a') && (key <= 'z'))
1516 retval = key + 10 - 'a';
1517 + else if ((key >= 'A') && (key <= 'Z'))
1518 + retval = key + 10 - 'A';
1522 diff -NurpP --minimal linux-3.9.4/drivers/tty/tty_io.c linux-3.9.4-vs2.3.6.3/drivers/tty/tty_io.c
1523 --- linux-3.9.4/drivers/tty/tty_io.c 2013-05-31 14:22:27.000000000 +0000
1524 +++ linux-3.9.4-vs2.3.6.3/drivers/tty/tty_io.c 2013-05-31 14:47:11.000000000 +0000
1527 #include <linux/kmod.h>
1528 #include <linux/nsproxy.h>
1529 +#include <linux/vs_pid.h>
1531 #undef TTY_DEBUG_HANGUP
1533 @@ -2144,7 +2145,8 @@ static int tiocsti(struct tty_struct *tt
1535 struct tty_ldisc *ld;
1537 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1538 + if (((current->signal->tty != tty) &&
1539 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1541 if (get_user(ch, p))
1543 @@ -2432,6 +2434,7 @@ static int tiocspgrp(struct tty_struct *
1545 if (get_user(pgrp_nr, p))
1547 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1551 diff -NurpP --minimal linux-3.9.4/fs/attr.c linux-3.9.4-vs2.3.6.3/fs/attr.c
1552 --- linux-3.9.4/fs/attr.c 2013-02-19 13:58:46.000000000 +0000
1553 +++ linux-3.9.4-vs2.3.6.3/fs/attr.c 2013-05-31 14:47:11.000000000 +0000
1555 #include <linux/security.h>
1556 #include <linux/evm.h>
1557 #include <linux/ima.h>
1558 +#include <linux/proc_fs.h>
1559 +#include <linux/devpts_fs.h>
1560 +#include <linux/vs_tag.h>
1563 * inode_change_ok - check if attribute changes to an inode are allowed
1564 @@ -77,6 +80,10 @@ int inode_change_ok(const struct inode *
1568 + /* check for inode tag permission */
1569 + if (dx_permission(inode, MAY_WRITE))
1574 EXPORT_SYMBOL(inode_change_ok);
1575 @@ -147,6 +154,8 @@ void setattr_copy(struct inode *inode, c
1576 inode->i_uid = attr->ia_uid;
1577 if (ia_valid & ATTR_GID)
1578 inode->i_gid = attr->ia_gid;
1579 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1580 + inode->i_tag = attr->ia_tag;
1581 if (ia_valid & ATTR_ATIME)
1582 inode->i_atime = timespec_trunc(attr->ia_atime,
1583 inode->i_sb->s_time_gran);
1584 @@ -177,7 +186,8 @@ int notify_change(struct dentry * dentry
1586 WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
1588 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1589 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1590 + ATTR_TAG | ATTR_TIMES_SET)) {
1591 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1594 diff -NurpP --minimal linux-3.9.4/fs/block_dev.c linux-3.9.4-vs2.3.6.3/fs/block_dev.c
1595 --- linux-3.9.4/fs/block_dev.c 2013-05-31 13:45:22.000000000 +0000
1596 +++ linux-3.9.4-vs2.3.6.3/fs/block_dev.c 2013-05-31 14:47:11.000000000 +0000
1598 #include <linux/namei.h>
1599 #include <linux/log2.h>
1600 #include <linux/cleancache.h>
1601 +#include <linux/vs_device.h>
1602 #include <asm/uaccess.h>
1603 #include "internal.h"
1605 @@ -528,6 +529,7 @@ struct block_device *bdget(dev_t dev)
1606 bdev->bd_invalidated = 0;
1607 inode->i_mode = S_IFBLK;
1608 inode->i_rdev = dev;
1609 + inode->i_mdev = dev;
1610 inode->i_bdev = bdev;
1611 inode->i_data.a_ops = &def_blk_aops;
1612 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1613 @@ -575,6 +577,11 @@ EXPORT_SYMBOL(bdput);
1614 static struct block_device *bd_acquire(struct inode *inode)
1616 struct block_device *bdev;
1619 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1621 + inode->i_mdev = mdev;
1623 spin_lock(&bdev_lock);
1624 bdev = inode->i_bdev;
1625 @@ -585,7 +592,7 @@ static struct block_device *bd_acquire(s
1627 spin_unlock(&bdev_lock);
1629 - bdev = bdget(inode->i_rdev);
1630 + bdev = bdget(mdev);
1632 spin_lock(&bdev_lock);
1633 if (!inode->i_bdev) {
1634 diff -NurpP --minimal linux-3.9.4/fs/btrfs/ctree.h linux-3.9.4-vs2.3.6.3/fs/btrfs/ctree.h
1635 --- linux-3.9.4/fs/btrfs/ctree.h 2013-05-31 13:45:22.000000000 +0000
1636 +++ linux-3.9.4-vs2.3.6.3/fs/btrfs/ctree.h 2013-05-31 14:47:11.000000000 +0000
1637 @@ -705,11 +705,14 @@ struct btrfs_inode_item {
1638 /* modification sequence number for NFS */
1643 * a little future expansion, for more than this we can
1644 * just grow the inode item and version it
1646 - __le64 reserved[4];
1647 + __le16 reserved16;
1648 + __le32 reserved32;
1649 + __le64 reserved[3];
1650 struct btrfs_timespec atime;
1651 struct btrfs_timespec ctime;
1652 struct btrfs_timespec mtime;
1653 @@ -1901,6 +1904,8 @@ struct btrfs_ioctl_defrag_range_args {
1654 #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
1655 #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22)
1657 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1659 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1660 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1661 #define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt)
1662 @@ -2170,6 +2175,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1663 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1664 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1665 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1666 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1667 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1668 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1669 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1670 @@ -2223,6 +2229,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1672 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1674 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1675 +#define BTRFS_INODE_BARRIER (1 << 25)
1676 +#define BTRFS_INODE_COW (1 << 26)
1679 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1681 @@ -3581,6 +3591,7 @@ extern const struct dentry_operations bt
1682 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1683 void btrfs_update_iflags(struct inode *inode);
1684 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1685 +int btrfs_sync_flags(struct inode *inode, int, int);
1686 int btrfs_defrag_file(struct inode *inode, struct file *file,
1687 struct btrfs_ioctl_defrag_range_args *range,
1688 u64 newer_than, unsigned long max_pages);
1689 diff -NurpP --minimal linux-3.9.4/fs/btrfs/disk-io.c linux-3.9.4-vs2.3.6.3/fs/btrfs/disk-io.c
1690 --- linux-3.9.4/fs/btrfs/disk-io.c 2013-05-31 13:45:22.000000000 +0000
1691 +++ linux-3.9.4-vs2.3.6.3/fs/btrfs/disk-io.c 2013-05-31 14:47:11.000000000 +0000
1692 @@ -2258,6 +2258,9 @@ int open_ctree(struct super_block *sb,
1696 + if (btrfs_test_opt(tree_root, TAGGED))
1697 + sb->s_flags |= MS_TAGGED;
1699 features = btrfs_super_incompat_flags(disk_super) &
1700 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1702 diff -NurpP --minimal linux-3.9.4/fs/btrfs/inode.c linux-3.9.4-vs2.3.6.3/fs/btrfs/inode.c
1703 --- linux-3.9.4/fs/btrfs/inode.c 2013-05-31 14:22:27.000000000 +0000
1704 +++ linux-3.9.4-vs2.3.6.3/fs/btrfs/inode.c 2013-06-03 19:37:03.000000000 +0000
1706 #include <linux/mount.h>
1707 #include <linux/btrfs.h>
1708 #include <linux/blkdev.h>
1709 +#include <linux/vs_tag.h>
1712 #include "disk-io.h"
1713 @@ -3312,6 +3313,9 @@ static void btrfs_read_locked_inode(stru
1714 struct btrfs_key location;
1721 bool filled = false;
1723 @@ -3339,8 +3343,14 @@ static void btrfs_read_locked_inode(stru
1724 struct btrfs_inode_item);
1725 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1726 set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
1727 - i_uid_write(inode, btrfs_inode_uid(leaf, inode_item));
1728 - i_gid_write(inode, btrfs_inode_gid(leaf, inode_item));
1730 + kuid = make_kuid(&init_user_ns, btrfs_inode_uid(leaf, inode_item));
1731 + kgid = make_kgid(&init_user_ns, btrfs_inode_gid(leaf, inode_item));
1732 + ktag = make_ktag(&init_user_ns, btrfs_inode_tag(leaf, inode_item));
1734 + inode->i_uid = INOTAG_KUID(DX_TAG(inode), kuid, kgid);
1735 + inode->i_gid = INOTAG_KGID(DX_TAG(inode), kuid, kgid);
1736 + inode->i_tag = INOTAG_KTAG(DX_TAG(inode), kuid, kgid, ktag);
1737 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1739 tspec = btrfs_inode_atime(inode_item);
1740 @@ -3431,11 +3441,18 @@ static void fill_inode_item(struct btrfs
1741 struct inode *inode)
1743 struct btrfs_map_token token;
1744 + uid_t uid = from_kuid(&init_user_ns,
1745 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
1746 + gid_t gid = from_kgid(&init_user_ns,
1747 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
1749 btrfs_init_map_token(&token);
1751 - btrfs_set_token_inode_uid(leaf, item, i_uid_read(inode), &token);
1752 - btrfs_set_token_inode_gid(leaf, item, i_gid_read(inode), &token);
1753 + btrfs_set_token_inode_uid(leaf, item, uid, &token);
1754 + btrfs_set_token_inode_gid(leaf, item, gid, &token);
1755 +#ifdef CONFIG_TAGGING_INTERN
1756 + btrfs_set_token_inode_tag(leaf, item, i_tag_read(inode), &token);
1758 btrfs_set_token_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size,
1760 btrfs_set_token_inode_mode(leaf, item, inode->i_mode, &token);
1761 @@ -8683,11 +8700,13 @@ static const struct inode_operations btr
1762 .listxattr = btrfs_listxattr,
1763 .removexattr = btrfs_removexattr,
1764 .permission = btrfs_permission,
1765 + .sync_flags = btrfs_sync_flags,
1766 .get_acl = btrfs_get_acl,
1768 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1769 .lookup = btrfs_lookup,
1770 .permission = btrfs_permission,
1771 + .sync_flags = btrfs_sync_flags,
1772 .get_acl = btrfs_get_acl,
1775 diff -NurpP --minimal linux-3.9.4/fs/btrfs/ioctl.c linux-3.9.4-vs2.3.6.3/fs/btrfs/ioctl.c
1776 --- linux-3.9.4/fs/btrfs/ioctl.c 2013-05-31 14:22:27.000000000 +0000
1777 +++ linux-3.9.4-vs2.3.6.3/fs/btrfs/ioctl.c 2013-05-31 14:47:11.000000000 +0000
1778 @@ -75,10 +75,13 @@ static unsigned int btrfs_flags_to_ioctl
1780 unsigned int iflags = 0;
1782 - if (flags & BTRFS_INODE_SYNC)
1783 - iflags |= FS_SYNC_FL;
1784 if (flags & BTRFS_INODE_IMMUTABLE)
1785 iflags |= FS_IMMUTABLE_FL;
1786 + if (flags & BTRFS_INODE_IXUNLINK)
1787 + iflags |= FS_IXUNLINK_FL;
1789 + if (flags & BTRFS_INODE_SYNC)
1790 + iflags |= FS_SYNC_FL;
1791 if (flags & BTRFS_INODE_APPEND)
1792 iflags |= FS_APPEND_FL;
1793 if (flags & BTRFS_INODE_NODUMP)
1794 @@ -95,28 +98,78 @@ static unsigned int btrfs_flags_to_ioctl
1795 else if (flags & BTRFS_INODE_NOCOMPRESS)
1796 iflags |= FS_NOCOMP_FL;
1798 + if (flags & BTRFS_INODE_BARRIER)
1799 + iflags |= FS_BARRIER_FL;
1800 + if (flags & BTRFS_INODE_COW)
1801 + iflags |= FS_COW_FL;
1806 - * Update inode->i_flags based on the btrfs internal flags.
1807 + * Update inode->i_(v)flags based on the btrfs internal flags.
1809 void btrfs_update_iflags(struct inode *inode)
1811 struct btrfs_inode *ip = BTRFS_I(inode);
1813 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
1814 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
1815 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
1817 - if (ip->flags & BTRFS_INODE_SYNC)
1818 - inode->i_flags |= S_SYNC;
1819 if (ip->flags & BTRFS_INODE_IMMUTABLE)
1820 inode->i_flags |= S_IMMUTABLE;
1821 + if (ip->flags & BTRFS_INODE_IXUNLINK)
1822 + inode->i_flags |= S_IXUNLINK;
1824 + if (ip->flags & BTRFS_INODE_SYNC)
1825 + inode->i_flags |= S_SYNC;
1826 if (ip->flags & BTRFS_INODE_APPEND)
1827 inode->i_flags |= S_APPEND;
1828 if (ip->flags & BTRFS_INODE_NOATIME)
1829 inode->i_flags |= S_NOATIME;
1830 if (ip->flags & BTRFS_INODE_DIRSYNC)
1831 inode->i_flags |= S_DIRSYNC;
1833 + inode->i_vflags &= ~(V_BARRIER | V_COW);
1835 + if (ip->flags & BTRFS_INODE_BARRIER)
1836 + inode->i_vflags |= V_BARRIER;
1837 + if (ip->flags & BTRFS_INODE_COW)
1838 + inode->i_vflags |= V_COW;
1842 + * Update btrfs internal flags from inode->i_(v)flags.
1844 +void btrfs_update_flags(struct inode *inode)
1846 + struct btrfs_inode *ip = BTRFS_I(inode);
1848 + unsigned int flags = inode->i_flags;
1849 + unsigned int vflags = inode->i_vflags;
1851 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
1852 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
1853 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
1854 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
1856 + if (flags & S_IMMUTABLE)
1857 + ip->flags |= BTRFS_INODE_IMMUTABLE;
1858 + if (flags & S_IXUNLINK)
1859 + ip->flags |= BTRFS_INODE_IXUNLINK;
1861 + if (flags & S_SYNC)
1862 + ip->flags |= BTRFS_INODE_SYNC;
1863 + if (flags & S_APPEND)
1864 + ip->flags |= BTRFS_INODE_APPEND;
1865 + if (flags & S_NOATIME)
1866 + ip->flags |= BTRFS_INODE_NOATIME;
1867 + if (flags & S_DIRSYNC)
1868 + ip->flags |= BTRFS_INODE_DIRSYNC;
1870 + if (vflags & V_BARRIER)
1871 + ip->flags |= BTRFS_INODE_BARRIER;
1872 + if (vflags & V_COW)
1873 + ip->flags |= BTRFS_INODE_COW;
1877 @@ -132,6 +185,7 @@ void btrfs_inherit_iflags(struct inode *
1880 flags = BTRFS_I(dir)->flags;
1881 + flags &= ~BTRFS_INODE_BARRIER;
1883 if (flags & BTRFS_INODE_NOCOMPRESS) {
1884 BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
1885 @@ -150,6 +204,30 @@ void btrfs_inherit_iflags(struct inode *
1886 btrfs_update_iflags(inode);
1889 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
1891 + struct btrfs_inode *ip = BTRFS_I(inode);
1892 + struct btrfs_root *root = ip->root;
1893 + struct btrfs_trans_handle *trans;
1896 + trans = btrfs_join_transaction(root);
1899 + inode->i_flags = flags;
1900 + inode->i_vflags = vflags;
1901 + btrfs_update_flags(inode);
1903 + ret = btrfs_update_inode(trans, root, inode);
1906 + btrfs_update_iflags(inode);
1907 + inode->i_ctime = CURRENT_TIME;
1908 + btrfs_end_transaction(trans, root);
1913 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
1915 struct btrfs_inode *ip = BTRFS_I(file_inode(file));
1916 @@ -212,21 +290,27 @@ static int btrfs_ioctl_setflags(struct f
1918 flags = btrfs_mask_flags(inode->i_mode, flags);
1919 oldflags = btrfs_flags_to_ioctl(ip->flags);
1920 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
1921 + if ((flags ^ oldflags) & (FS_APPEND_FL |
1922 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
1923 if (!capable(CAP_LINUX_IMMUTABLE)) {
1929 - if (flags & FS_SYNC_FL)
1930 - ip->flags |= BTRFS_INODE_SYNC;
1932 - ip->flags &= ~BTRFS_INODE_SYNC;
1933 if (flags & FS_IMMUTABLE_FL)
1934 ip->flags |= BTRFS_INODE_IMMUTABLE;
1936 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
1937 + if (flags & FS_IXUNLINK_FL)
1938 + ip->flags |= BTRFS_INODE_IXUNLINK;
1940 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
1942 + if (flags & FS_SYNC_FL)
1943 + ip->flags |= BTRFS_INODE_SYNC;
1945 + ip->flags &= ~BTRFS_INODE_SYNC;
1946 if (flags & FS_APPEND_FL)
1947 ip->flags |= BTRFS_INODE_APPEND;
1949 diff -NurpP --minimal linux-3.9.4/fs/btrfs/super.c linux-3.9.4-vs2.3.6.3/fs/btrfs/super.c
1950 --- linux-3.9.4/fs/btrfs/super.c 2013-05-31 13:45:22.000000000 +0000
1951 +++ linux-3.9.4-vs2.3.6.3/fs/btrfs/super.c 2013-05-31 14:47:11.000000000 +0000
1952 @@ -321,7 +321,7 @@ enum {
1953 Opt_no_space_cache, Opt_recovery, Opt_skip_balance,
1954 Opt_check_integrity, Opt_check_integrity_including_extent_data,
1955 Opt_check_integrity_print_mask, Opt_fatal_errors,
1957 + Opt_tag, Opt_notag, Opt_tagid, Opt_err,
1960 static match_table_t tokens = {
1961 @@ -361,6 +361,9 @@ static match_table_t tokens = {
1962 {Opt_check_integrity_including_extent_data, "check_int_data"},
1963 {Opt_check_integrity_print_mask, "check_int_print_mask=%d"},
1964 {Opt_fatal_errors, "fatal_errors=%s"},
1966 + {Opt_notag, "notag"},
1967 + {Opt_tagid, "tagid=%u"},
1971 @@ -626,6 +629,22 @@ int btrfs_parse_options(struct btrfs_roo
1975 +#ifndef CONFIG_TAGGING_NONE
1977 + printk(KERN_INFO "btrfs: use tagging\n");
1978 + btrfs_set_opt(info->mount_opt, TAGGED);
1981 + printk(KERN_INFO "btrfs: disabled tagging\n");
1982 + btrfs_clear_opt(info->mount_opt, TAGGED);
1985 +#ifdef CONFIG_PROPAGATE
1988 + btrfs_set_opt(info->mount_opt, TAGGED);
1992 printk(KERN_INFO "btrfs: unrecognized mount option "
1994 @@ -1258,6 +1277,12 @@ static int btrfs_remount(struct super_bl
1995 btrfs_resize_thread_pool(fs_info,
1996 fs_info->thread_pool_size, old_thread_pool_size);
1998 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
1999 + printk("btrfs: %s: tagging not permitted on remount.\n",
2004 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2007 diff -NurpP --minimal linux-3.9.4/fs/char_dev.c linux-3.9.4-vs2.3.6.3/fs/char_dev.c
2008 --- linux-3.9.4/fs/char_dev.c 2012-12-11 03:30:57.000000000 +0000
2009 +++ linux-3.9.4-vs2.3.6.3/fs/char_dev.c 2013-05-31 14:47:11.000000000 +0000
2011 #include <linux/mutex.h>
2012 #include <linux/backing-dev.h>
2013 #include <linux/tty.h>
2014 +#include <linux/vs_context.h>
2015 +#include <linux/vs_device.h>
2017 #include "internal.h"
2019 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2021 struct cdev *new = NULL;
2025 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2027 + inode->i_mdev = mdev;
2029 spin_lock(&cdev_lock);
2032 struct kobject *kobj;
2035 spin_unlock(&cdev_lock);
2036 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2038 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2041 new = container_of(kobj, struct cdev, kobj);
2042 diff -NurpP --minimal linux-3.9.4/fs/dcache.c linux-3.9.4-vs2.3.6.3/fs/dcache.c
2043 --- linux-3.9.4/fs/dcache.c 2013-05-31 14:22:27.000000000 +0000
2044 +++ linux-3.9.4-vs2.3.6.3/fs/dcache.c 2013-05-31 14:47:11.000000000 +0000
2046 #include <linux/rculist_bl.h>
2047 #include <linux/prefetch.h>
2048 #include <linux/ratelimit.h>
2049 +#include <linux/vs_limit.h>
2050 #include "internal.h"
2053 @@ -593,6 +594,8 @@ int d_invalidate(struct dentry * dentry)
2054 spin_lock(&dentry->d_lock);
2057 + vx_dentry_dec(dentry);
2060 * Somebody else still using it?
2062 @@ -622,6 +625,7 @@ EXPORT_SYMBOL(d_invalidate);
2063 static inline void __dget_dlock(struct dentry *dentry)
2066 + vx_dentry_inc(dentry);
2069 static inline void __dget(struct dentry *dentry)
2070 @@ -1252,6 +1256,9 @@ struct dentry *__d_alloc(struct super_bl
2071 struct dentry *dentry;
2074 + if (!vx_dentry_avail(1))
2077 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2080 @@ -1284,6 +1291,7 @@ struct dentry *__d_alloc(struct super_bl
2082 dentry->d_count = 1;
2083 dentry->d_flags = 0;
2084 + vx_dentry_inc(dentry);
2085 spin_lock_init(&dentry->d_lock);
2086 seqcount_init(&dentry->d_seq);
2087 dentry->d_inode = NULL;
2088 @@ -1984,6 +1992,7 @@ struct dentry *__d_lookup(const struct d
2092 + vx_dentry_inc(dentry);
2094 spin_unlock(&dentry->d_lock);
2096 diff -NurpP --minimal linux-3.9.4/fs/devpts/inode.c linux-3.9.4-vs2.3.6.3/fs/devpts/inode.c
2097 --- linux-3.9.4/fs/devpts/inode.c 2013-05-31 13:45:23.000000000 +0000
2098 +++ linux-3.9.4-vs2.3.6.3/fs/devpts/inode.c 2013-05-31 15:42:25.000000000 +0000
2100 #include <linux/parser.h>
2101 #include <linux/fsnotify.h>
2102 #include <linux/seq_file.h>
2103 +#include <linux/vs_base.h>
2105 #define DEVPTS_DEFAULT_MODE 0600
2108 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2109 #define PTMX_MINOR 2
2111 +static int devpts_permission(struct inode *inode, int mask)
2113 + int ret = -EACCES;
2115 + /* devpts is xid tagged */
2116 + if (vx_check((xid_t)i_tag_read(inode), VS_WATCH_P | VS_IDENT))
2117 + ret = generic_permission(inode, mask);
2121 +static struct inode_operations devpts_file_inode_operations = {
2122 + .permission = devpts_permission,
2127 * sysctl support for setting limits on the number of Unix98 ptys allocated.
2128 * Otherwise one can eat up all kernel memory by opening /dev/ptmx repeatedly.
2129 @@ -345,6 +361,34 @@ static int devpts_show_options(struct se
2133 +static int devpts_filter(struct dentry *de)
2137 + /* devpts is xid tagged */
2138 + if (de && de->d_inode)
2139 + xid = (xid_t)i_tag_read(de->d_inode);
2140 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2142 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2143 + de->d_name.len, de->d_name.name);
2145 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2148 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2150 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2153 +static struct file_operations devpts_dir_operations = {
2154 + .open = dcache_dir_open,
2155 + .release = dcache_dir_close,
2156 + .llseek = dcache_dir_lseek,
2157 + .read = generic_read_dir,
2158 + .readdir = devpts_readdir,
2161 static const struct super_operations devpts_sops = {
2162 .statfs = simple_statfs,
2163 .remount_fs = devpts_remount,
2164 @@ -388,8 +432,10 @@ devpts_fill_super(struct super_block *s,
2165 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2166 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2167 inode->i_op = &simple_dir_inode_operations;
2168 - inode->i_fop = &simple_dir_operations;
2169 + inode->i_fop = &devpts_dir_operations;
2170 set_nlink(inode, 2);
2171 + /* devpts is xid tagged */
2172 + i_tag_write(inode, (tag_t)vx_current_xid());
2174 s->s_root = d_make_root(inode);
2176 @@ -592,6 +638,9 @@ struct inode *devpts_pty_new(struct inod
2177 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2178 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2179 init_special_inode(inode, S_IFCHR|opts->mode, device);
2180 + /* devpts is xid tagged */
2181 + i_tag_write(inode, (tag_t)vx_current_xid());
2182 + inode->i_op = &devpts_file_inode_operations;
2183 inode->i_private = priv;
2185 sprintf(s, "%d", index);
2186 diff -NurpP --minimal linux-3.9.4/fs/ext2/balloc.c linux-3.9.4-vs2.3.6.3/fs/ext2/balloc.c
2187 --- linux-3.9.4/fs/ext2/balloc.c 2013-05-31 13:45:23.000000000 +0000
2188 +++ linux-3.9.4-vs2.3.6.3/fs/ext2/balloc.c 2013-05-31 14:47:11.000000000 +0000
2189 @@ -693,7 +693,6 @@ ext2_try_to_allocate(struct super_block
2191 end = EXT2_BLOCKS_PER_GROUP(sb);
2194 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2197 diff -NurpP --minimal linux-3.9.4/fs/ext2/ext2.h linux-3.9.4-vs2.3.6.3/fs/ext2/ext2.h
2198 --- linux-3.9.4/fs/ext2/ext2.h 2012-12-11 03:30:57.000000000 +0000
2199 +++ linux-3.9.4-vs2.3.6.3/fs/ext2/ext2.h 2013-05-31 14:47:11.000000000 +0000
2200 @@ -244,8 +244,12 @@ struct ext2_group_desc
2201 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
2202 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
2203 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
2204 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
2205 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
2207 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
2208 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
2210 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
2211 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
2213 @@ -329,7 +333,8 @@ struct ext2_inode {
2215 __le16 l_i_uid_high; /* these 2 fields */
2216 __le16 l_i_gid_high; /* were reserved2[0] */
2217 - __u32 l_i_reserved2;
2218 + __le16 l_i_tag; /* Context Tag */
2219 + __u16 l_i_reserved2;
2222 __u8 h_i_frag; /* Fragment number */
2223 @@ -357,6 +362,7 @@ struct ext2_inode {
2224 #define i_gid_low i_gid
2225 #define i_uid_high osd2.linux2.l_i_uid_high
2226 #define i_gid_high osd2.linux2.l_i_gid_high
2227 +#define i_raw_tag osd2.linux2.l_i_tag
2228 #define i_reserved2 osd2.linux2.l_i_reserved2
2231 @@ -384,6 +390,7 @@ struct ext2_inode {
2232 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
2233 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
2234 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
2235 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2238 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
2239 @@ -757,6 +764,7 @@ extern void ext2_set_inode_flags(struct
2240 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2241 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2242 u64 start, u64 len);
2243 +extern int ext2_sync_flags(struct inode *, int, int);
2246 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2247 diff -NurpP --minimal linux-3.9.4/fs/ext2/file.c linux-3.9.4-vs2.3.6.3/fs/ext2/file.c
2248 --- linux-3.9.4/fs/ext2/file.c 2012-12-11 03:30:57.000000000 +0000
2249 +++ linux-3.9.4-vs2.3.6.3/fs/ext2/file.c 2013-05-31 14:47:11.000000000 +0000
2250 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2251 .setattr = ext2_setattr,
2252 .get_acl = ext2_get_acl,
2253 .fiemap = ext2_fiemap,
2254 + .sync_flags = ext2_sync_flags,
2256 diff -NurpP --minimal linux-3.9.4/fs/ext2/ialloc.c linux-3.9.4-vs2.3.6.3/fs/ext2/ialloc.c
2257 --- linux-3.9.4/fs/ext2/ialloc.c 2013-05-31 13:45:23.000000000 +0000
2258 +++ linux-3.9.4-vs2.3.6.3/fs/ext2/ialloc.c 2013-06-03 18:58:16.000000000 +0000
2260 #include <linux/backing-dev.h>
2261 #include <linux/buffer_head.h>
2262 #include <linux/random.h>
2263 +#include <linux/vs_tag.h>
2267 @@ -546,6 +547,7 @@ got:
2268 inode->i_mode = mode;
2269 inode->i_uid = current_fsuid();
2270 inode->i_gid = dir->i_gid;
2271 + i_tag_write(inode, dx_current_fstag(sb));
2273 inode_init_owner(inode, dir, mode);
2275 diff -NurpP --minimal linux-3.9.4/fs/ext2/inode.c linux-3.9.4-vs2.3.6.3/fs/ext2/inode.c
2276 --- linux-3.9.4/fs/ext2/inode.c 2013-05-31 13:45:23.000000000 +0000
2277 +++ linux-3.9.4-vs2.3.6.3/fs/ext2/inode.c 2013-06-03 19:42:51.000000000 +0000
2279 #include <linux/mpage.h>
2280 #include <linux/fiemap.h>
2281 #include <linux/namei.h>
2282 +#include <linux/vs_tag.h>
2286 @@ -1179,7 +1180,7 @@ static void ext2_truncate_blocks(struct
2288 if (ext2_inode_is_fast_symlink(inode))
2290 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2291 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2293 __ext2_truncate_blocks(inode, offset);
2295 @@ -1270,36 +1271,61 @@ void ext2_set_inode_flags(struct inode *
2297 unsigned int flags = EXT2_I(inode)->i_flags;
2299 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2300 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2301 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2304 + if (flags & EXT2_IMMUTABLE_FL)
2305 + inode->i_flags |= S_IMMUTABLE;
2306 + if (flags & EXT2_IXUNLINK_FL)
2307 + inode->i_flags |= S_IXUNLINK;
2309 if (flags & EXT2_SYNC_FL)
2310 inode->i_flags |= S_SYNC;
2311 if (flags & EXT2_APPEND_FL)
2312 inode->i_flags |= S_APPEND;
2313 - if (flags & EXT2_IMMUTABLE_FL)
2314 - inode->i_flags |= S_IMMUTABLE;
2315 if (flags & EXT2_NOATIME_FL)
2316 inode->i_flags |= S_NOATIME;
2317 if (flags & EXT2_DIRSYNC_FL)
2318 inode->i_flags |= S_DIRSYNC;
2320 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2322 + if (flags & EXT2_BARRIER_FL)
2323 + inode->i_vflags |= V_BARRIER;
2324 + if (flags & EXT2_COW_FL)
2325 + inode->i_vflags |= V_COW;
2328 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2329 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2331 unsigned int flags = ei->vfs_inode.i_flags;
2332 + unsigned int vflags = ei->vfs_inode.i_vflags;
2334 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2335 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2336 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2337 + EXT2_BARRIER_FL | EXT2_COW_FL);
2339 + if (flags & S_IMMUTABLE)
2340 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2341 + if (flags & S_IXUNLINK)
2342 + ei->i_flags |= EXT2_IXUNLINK_FL;
2344 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2345 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2347 ei->i_flags |= EXT2_SYNC_FL;
2348 if (flags & S_APPEND)
2349 ei->i_flags |= EXT2_APPEND_FL;
2350 - if (flags & S_IMMUTABLE)
2351 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2352 if (flags & S_NOATIME)
2353 ei->i_flags |= EXT2_NOATIME_FL;
2354 if (flags & S_DIRSYNC)
2355 ei->i_flags |= EXT2_DIRSYNC_FL;
2357 + if (vflags & V_BARRIER)
2358 + ei->i_flags |= EXT2_BARRIER_FL;
2359 + if (vflags & V_COW)
2360 + ei->i_flags |= EXT2_COW_FL;
2363 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2364 @@ -1335,8 +1361,10 @@ struct inode *ext2_iget (struct super_bl
2365 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2366 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2368 - i_uid_write(inode, i_uid);
2369 - i_gid_write(inode, i_gid);
2370 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2371 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2372 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2373 + le16_to_cpu(raw_inode->i_raw_tag)));
2374 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2375 inode->i_size = le32_to_cpu(raw_inode->i_size);
2376 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2377 @@ -1434,8 +1462,10 @@ static int __ext2_write_inode(struct ino
2378 struct ext2_inode_info *ei = EXT2_I(inode);
2379 struct super_block *sb = inode->i_sb;
2380 ino_t ino = inode->i_ino;
2381 - uid_t uid = i_uid_read(inode);
2382 - gid_t gid = i_gid_read(inode);
2383 + uid_t uid = from_kuid(&init_user_ns,
2384 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
2385 + gid_t gid = from_kgid(&init_user_ns,
2386 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
2387 struct buffer_head * bh;
2388 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2390 @@ -1471,6 +1501,9 @@ static int __ext2_write_inode(struct ino
2391 raw_inode->i_uid_high = 0;
2392 raw_inode->i_gid_high = 0;
2394 +#ifdef CONFIG_TAGGING_INTERN
2395 + raw_inode->i_raw_tag = cpu_to_le16(i_tag_read(inode));
2397 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2398 raw_inode->i_size = cpu_to_le32(inode->i_size);
2399 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2400 @@ -1551,7 +1584,8 @@ int ext2_setattr(struct dentry *dentry,
2401 if (is_quota_modification(inode, iattr))
2402 dquot_initialize(inode);
2403 if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||
2404 - (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {
2405 + (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid)) ||
2406 + (iattr->ia_valid & ATTR_TAG && !tag_eq(iattr->ia_tag, inode->i_tag))) {
2407 error = dquot_transfer(inode, iattr);
2410 diff -NurpP --minimal linux-3.9.4/fs/ext2/ioctl.c linux-3.9.4-vs2.3.6.3/fs/ext2/ioctl.c
2411 --- linux-3.9.4/fs/ext2/ioctl.c 2013-05-31 13:45:23.000000000 +0000
2412 +++ linux-3.9.4-vs2.3.6.3/fs/ext2/ioctl.c 2013-05-31 14:47:11.000000000 +0000
2414 #include <asm/uaccess.h>
2417 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2419 + inode->i_flags = flags;
2420 + inode->i_vflags = vflags;
2421 + ext2_get_inode_flags(EXT2_I(inode));
2422 + inode->i_ctime = CURRENT_TIME_SEC;
2423 + mark_inode_dirty(inode);
2427 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2429 struct inode *inode = file_inode(filp);
2430 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2432 flags = ext2_mask_flags(inode->i_mode, flags);
2434 + if (IS_BARRIER(inode)) {
2435 + vxwprintk_task(1, "messing with the barrier.");
2439 mutex_lock(&inode->i_mutex);
2440 /* Is it quota file? Do not allow user to mess with it */
2441 if (IS_NOQUOTA(inode)) {
2442 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2444 * This test looks nicer. Thanks to Pauline Middelink
2446 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2447 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2448 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2449 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2450 if (!capable(CAP_LINUX_IMMUTABLE)) {
2451 mutex_unlock(&inode->i_mutex);
2453 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2457 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2458 + flags &= EXT2_FL_USER_MODIFIABLE;
2459 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2460 ei->i_flags = flags;
2462 diff -NurpP --minimal linux-3.9.4/fs/ext2/namei.c linux-3.9.4-vs2.3.6.3/fs/ext2/namei.c
2463 --- linux-3.9.4/fs/ext2/namei.c 2012-12-11 03:30:57.000000000 +0000
2464 +++ linux-3.9.4-vs2.3.6.3/fs/ext2/namei.c 2013-05-31 14:47:11.000000000 +0000
2467 #include <linux/pagemap.h>
2468 #include <linux/quotaops.h>
2469 +#include <linux/vs_tag.h>
2473 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
2474 (unsigned long) ino);
2475 return ERR_PTR(-EIO);
2477 + dx_propagate_tag(nd, inode);
2479 return d_splice_alias(inode, dentry);
2481 @@ -397,6 +399,7 @@ const struct inode_operations ext2_dir_i
2482 .removexattr = generic_removexattr,
2484 .setattr = ext2_setattr,
2485 + .sync_flags = ext2_sync_flags,
2486 .get_acl = ext2_get_acl,
2489 diff -NurpP --minimal linux-3.9.4/fs/ext2/super.c linux-3.9.4-vs2.3.6.3/fs/ext2/super.c
2490 --- linux-3.9.4/fs/ext2/super.c 2013-05-31 13:45:23.000000000 +0000
2491 +++ linux-3.9.4-vs2.3.6.3/fs/ext2/super.c 2013-05-31 14:47:11.000000000 +0000
2492 @@ -395,7 +395,8 @@ enum {
2493 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2494 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2495 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2496 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2497 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2498 + Opt_tag, Opt_notag, Opt_tagid
2501 static const match_table_t tokens = {
2502 @@ -423,6 +424,9 @@ static const match_table_t tokens = {
2504 {Opt_noacl, "noacl"},
2507 + {Opt_notag, "notag"},
2508 + {Opt_tagid, "tagid=%u"},
2509 {Opt_grpquota, "grpquota"},
2510 {Opt_ignore, "noquota"},
2511 {Opt_quota, "quota"},
2512 @@ -506,6 +510,20 @@ static int parse_options(char *options,
2514 set_opt (sbi->s_mount_opt, NO_UID32);
2516 +#ifndef CONFIG_TAGGING_NONE
2518 + set_opt (sbi->s_mount_opt, TAGGED);
2521 + clear_opt (sbi->s_mount_opt, TAGGED);
2524 +#ifdef CONFIG_PROPAGATE
2527 + set_opt (sbi->s_mount_opt, TAGGED);
2531 clear_opt (sbi->s_mount_opt, CHECK);
2533 @@ -864,6 +882,8 @@ static int ext2_fill_super(struct super_
2534 if (!parse_options((char *) data, sb))
2537 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2538 + sb->s_flags |= MS_TAGGED;
2539 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2540 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2542 @@ -1269,6 +1289,14 @@ static int ext2_remount (struct super_bl
2547 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2548 + !(sb->s_flags & MS_TAGGED)) {
2549 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2552 + goto restore_opts;
2555 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2556 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2557 diff -NurpP --minimal linux-3.9.4/fs/ext3/ext3.h linux-3.9.4-vs2.3.6.3/fs/ext3/ext3.h
2558 --- linux-3.9.4/fs/ext3/ext3.h 2012-12-11 03:30:57.000000000 +0000
2559 +++ linux-3.9.4-vs2.3.6.3/fs/ext3/ext3.h 2013-05-31 14:47:11.000000000 +0000
2560 @@ -151,10 +151,14 @@ struct ext3_group_desc
2561 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
2562 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
2563 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
2564 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2565 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
2567 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
2568 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
2569 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2570 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
2572 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
2573 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
2575 /* Flags that should be inherited by new inodes from their parent. */
2576 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
2577 @@ -290,7 +294,8 @@ struct ext3_inode {
2579 __le16 l_i_uid_high; /* these 2 fields */
2580 __le16 l_i_gid_high; /* were reserved2[0] */
2581 - __u32 l_i_reserved2;
2582 + __le16 l_i_tag; /* Context Tag */
2583 + __u16 l_i_reserved2;
2586 __u8 h_i_frag; /* Fragment number */
2587 @@ -320,6 +325,7 @@ struct ext3_inode {
2588 #define i_gid_low i_gid
2589 #define i_uid_high osd2.linux2.l_i_uid_high
2590 #define i_gid_high osd2.linux2.l_i_gid_high
2591 +#define i_raw_tag osd2.linux2.l_i_tag
2592 #define i_reserved2 osd2.linux2.l_i_reserved2
2595 @@ -364,6 +370,7 @@ struct ext3_inode {
2596 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
2597 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
2598 * error in ordered mode */
2599 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2601 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
2602 #ifndef _LINUX_EXT2_FS_H
2603 @@ -1061,6 +1068,7 @@ extern void ext3_get_inode_flags(struct
2604 extern void ext3_set_aops(struct inode *inode);
2605 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2606 u64 start, u64 len);
2607 +extern int ext3_sync_flags(struct inode *, int, int);
2610 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
2611 diff -NurpP --minimal linux-3.9.4/fs/ext3/file.c linux-3.9.4-vs2.3.6.3/fs/ext3/file.c
2612 --- linux-3.9.4/fs/ext3/file.c 2012-12-11 03:30:57.000000000 +0000
2613 +++ linux-3.9.4-vs2.3.6.3/fs/ext3/file.c 2013-05-31 14:47:11.000000000 +0000
2614 @@ -76,5 +76,6 @@ const struct inode_operations ext3_file_
2616 .get_acl = ext3_get_acl,
2617 .fiemap = ext3_fiemap,
2618 + .sync_flags = ext3_sync_flags,
2621 diff -NurpP --minimal linux-3.9.4/fs/ext3/ialloc.c linux-3.9.4-vs2.3.6.3/fs/ext3/ialloc.c
2622 --- linux-3.9.4/fs/ext3/ialloc.c 2012-12-11 03:30:57.000000000 +0000
2623 +++ linux-3.9.4-vs2.3.6.3/fs/ext3/ialloc.c 2013-06-03 19:43:33.000000000 +0000
2626 #include <linux/quotaops.h>
2627 #include <linux/random.h>
2628 +#include <linux/vs_tag.h>
2632 @@ -469,6 +470,7 @@ got:
2633 inode->i_mode = mode;
2634 inode->i_uid = current_fsuid();
2635 inode->i_gid = dir->i_gid;
2636 + i_tag_write(inode, dx_current_fstag(sb));
2638 inode_init_owner(inode, dir, mode);
2640 diff -NurpP --minimal linux-3.9.4/fs/ext3/inode.c linux-3.9.4-vs2.3.6.3/fs/ext3/inode.c
2641 --- linux-3.9.4/fs/ext3/inode.c 2013-05-31 13:45:23.000000000 +0000
2642 +++ linux-3.9.4-vs2.3.6.3/fs/ext3/inode.c 2013-06-03 19:44:35.000000000 +0000
2644 #include <linux/writeback.h>
2645 #include <linux/mpage.h>
2646 #include <linux/namei.h>
2647 +#include <linux/vs_tag.h>
2652 @@ -2851,36 +2853,60 @@ void ext3_set_inode_flags(struct inode *
2654 unsigned int flags = EXT3_I(inode)->i_flags;
2656 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2657 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2658 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2660 + if (flags & EXT3_IMMUTABLE_FL)
2661 + inode->i_flags |= S_IMMUTABLE;
2662 + if (flags & EXT3_IXUNLINK_FL)
2663 + inode->i_flags |= S_IXUNLINK;
2665 if (flags & EXT3_SYNC_FL)
2666 inode->i_flags |= S_SYNC;
2667 if (flags & EXT3_APPEND_FL)
2668 inode->i_flags |= S_APPEND;
2669 - if (flags & EXT3_IMMUTABLE_FL)
2670 - inode->i_flags |= S_IMMUTABLE;
2671 if (flags & EXT3_NOATIME_FL)
2672 inode->i_flags |= S_NOATIME;
2673 if (flags & EXT3_DIRSYNC_FL)
2674 inode->i_flags |= S_DIRSYNC;
2676 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2678 + if (flags & EXT3_BARRIER_FL)
2679 + inode->i_vflags |= V_BARRIER;
2680 + if (flags & EXT3_COW_FL)
2681 + inode->i_vflags |= V_COW;
2684 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2685 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2687 unsigned int flags = ei->vfs_inode.i_flags;
2688 + unsigned int vflags = ei->vfs_inode.i_vflags;
2690 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2691 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2692 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2693 + EXT3_BARRIER_FL | EXT3_COW_FL);
2695 + if (flags & S_IMMUTABLE)
2696 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2697 + if (flags & S_IXUNLINK)
2698 + ei->i_flags |= EXT3_IXUNLINK_FL;
2700 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2701 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2703 ei->i_flags |= EXT3_SYNC_FL;
2704 if (flags & S_APPEND)
2705 ei->i_flags |= EXT3_APPEND_FL;
2706 - if (flags & S_IMMUTABLE)
2707 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2708 if (flags & S_NOATIME)
2709 ei->i_flags |= EXT3_NOATIME_FL;
2710 if (flags & S_DIRSYNC)
2711 ei->i_flags |= EXT3_DIRSYNC_FL;
2713 + if (vflags & V_BARRIER)
2714 + ei->i_flags |= EXT3_BARRIER_FL;
2715 + if (vflags & V_COW)
2716 + ei->i_flags |= EXT3_COW_FL;
2719 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2720 @@ -2918,8 +2944,10 @@ struct inode *ext3_iget(struct super_blo
2721 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2722 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2724 - i_uid_write(inode, i_uid);
2725 - i_gid_write(inode, i_gid);
2726 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2727 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2728 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2729 + le16_to_cpu(raw_inode->i_raw_tag)));
2730 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2731 inode->i_size = le32_to_cpu(raw_inode->i_size);
2732 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2733 @@ -3091,8 +3119,10 @@ again:
2735 ext3_get_inode_flags(ei);
2736 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2737 - i_uid = i_uid_read(inode);
2738 - i_gid = i_gid_read(inode);
2739 + i_uid = from_kuid(&init_user_ns,
2740 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
2741 + i_gid = from_kgid(&init_user_ns,
2742 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
2743 if(!(test_opt(inode->i_sb, NO_UID32))) {
2744 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
2745 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
2746 @@ -3117,6 +3147,9 @@ again:
2747 raw_inode->i_uid_high = 0;
2748 raw_inode->i_gid_high = 0;
2750 +#ifdef CONFIG_TAGGING_INTERN
2751 + raw_inode->i_raw_tag = cpu_to_le16(i_tag_read(inode));
2753 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2754 disksize = cpu_to_le32(ei->i_disksize);
2755 if (disksize != raw_inode->i_size) {
2756 @@ -3285,7 +3318,8 @@ int ext3_setattr(struct dentry *dentry,
2757 if (is_quota_modification(inode, attr))
2758 dquot_initialize(inode);
2759 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
2760 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
2761 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
2762 + (ia_valid & ATTR_TAG && !tag_eq(attr->ia_tag, inode->i_tag))) {
2765 /* (user+group)*(old+new) structure, inode write (sb,
2766 @@ -3307,6 +3341,8 @@ int ext3_setattr(struct dentry *dentry,
2767 inode->i_uid = attr->ia_uid;
2768 if (attr->ia_valid & ATTR_GID)
2769 inode->i_gid = attr->ia_gid;
2770 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2771 + inode->i_tag = attr->ia_tag;
2772 error = ext3_mark_inode_dirty(handle, inode);
2773 ext3_journal_stop(handle);
2775 diff -NurpP --minimal linux-3.9.4/fs/ext3/ioctl.c linux-3.9.4-vs2.3.6.3/fs/ext3/ioctl.c
2776 --- linux-3.9.4/fs/ext3/ioctl.c 2013-05-31 13:45:23.000000000 +0000
2777 +++ linux-3.9.4-vs2.3.6.3/fs/ext3/ioctl.c 2013-05-31 14:47:11.000000000 +0000
2779 #include <asm/uaccess.h>
2783 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2785 + handle_t *handle = NULL;
2786 + struct ext3_iloc iloc;
2789 + handle = ext3_journal_start(inode, 1);
2790 + if (IS_ERR(handle))
2791 + return PTR_ERR(handle);
2793 + if (IS_SYNC(inode))
2794 + handle->h_sync = 1;
2795 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2799 + inode->i_flags = flags;
2800 + inode->i_vflags = vflags;
2801 + ext3_get_inode_flags(EXT3_I(inode));
2802 + inode->i_ctime = CURRENT_TIME_SEC;
2804 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2806 + ext3_journal_stop(handle);
2810 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2812 struct inode *inode = file_inode(filp);
2813 @@ -45,6 +73,11 @@ long ext3_ioctl(struct file *filp, unsig
2815 flags = ext3_mask_flags(inode->i_mode, flags);
2817 + if (IS_BARRIER(inode)) {
2818 + vxwprintk_task(1, "messing with the barrier.");
2822 mutex_lock(&inode->i_mutex);
2824 /* Is it quota file? Do not allow user to mess with it */
2825 @@ -63,7 +96,9 @@ long ext3_ioctl(struct file *filp, unsig
2827 * This test looks nicer. Thanks to Pauline Middelink
2829 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2830 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2831 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2832 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2833 if (!capable(CAP_LINUX_IMMUTABLE))
2836 @@ -88,7 +123,7 @@ long ext3_ioctl(struct file *filp, unsig
2840 - flags = flags & EXT3_FL_USER_MODIFIABLE;
2841 + flags &= EXT3_FL_USER_MODIFIABLE;
2842 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
2843 ei->i_flags = flags;
2845 diff -NurpP --minimal linux-3.9.4/fs/ext3/namei.c linux-3.9.4-vs2.3.6.3/fs/ext3/namei.c
2846 --- linux-3.9.4/fs/ext3/namei.c 2013-05-31 13:45:23.000000000 +0000
2847 +++ linux-3.9.4-vs2.3.6.3/fs/ext3/namei.c 2013-05-31 14:47:11.000000000 +0000
2851 #include <linux/quotaops.h>
2852 +#include <linux/vs_tag.h>
2857 @@ -918,6 +920,7 @@ restart:
2858 submit_bh(READ | REQ_META | REQ_PRIO,
2861 + dx_propagate_tag(nd, inode);
2864 if ((bh = bh_use[ra_ptr++]) == NULL)
2865 @@ -2527,6 +2530,7 @@ const struct inode_operations ext3_dir_i
2866 .listxattr = ext3_listxattr,
2867 .removexattr = generic_removexattr,
2869 + .sync_flags = ext3_sync_flags,
2870 .get_acl = ext3_get_acl,
2873 diff -NurpP --minimal linux-3.9.4/fs/ext3/super.c linux-3.9.4-vs2.3.6.3/fs/ext3/super.c
2874 --- linux-3.9.4/fs/ext3/super.c 2013-05-31 13:45:23.000000000 +0000
2875 +++ linux-3.9.4-vs2.3.6.3/fs/ext3/super.c 2013-05-31 14:47:11.000000000 +0000
2876 @@ -816,7 +816,8 @@ enum {
2877 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2878 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
2879 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
2880 - Opt_resize, Opt_usrquota, Opt_grpquota
2881 + Opt_resize, Opt_usrquota, Opt_grpquota,
2882 + Opt_tag, Opt_notag, Opt_tagid
2885 static const match_table_t tokens = {
2886 @@ -873,6 +874,9 @@ static const match_table_t tokens = {
2887 {Opt_barrier, "barrier"},
2888 {Opt_nobarrier, "nobarrier"},
2889 {Opt_resize, "resize"},
2891 + {Opt_notag, "notag"},
2892 + {Opt_tagid, "tagid=%u"},
2896 @@ -1040,6 +1044,20 @@ static int parse_options (char *options,
2898 set_opt (sbi->s_mount_opt, NO_UID32);
2900 +#ifndef CONFIG_TAGGING_NONE
2902 + set_opt (sbi->s_mount_opt, TAGGED);
2905 + clear_opt (sbi->s_mount_opt, TAGGED);
2908 +#ifdef CONFIG_PROPAGATE
2911 + set_opt (sbi->s_mount_opt, TAGGED);
2915 clear_opt (sbi->s_mount_opt, CHECK);
2917 @@ -1737,6 +1755,9 @@ static int ext3_fill_super (struct super
2921 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
2922 + sb->s_flags |= MS_TAGGED;
2924 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2925 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2927 @@ -2633,6 +2654,14 @@ static int ext3_remount (struct super_bl
2928 if (test_opt(sb, ABORT))
2929 ext3_abort(sb, __func__, "Abort forced by user");
2931 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
2932 + !(sb->s_flags & MS_TAGGED)) {
2933 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
2936 + goto restore_opts;
2939 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2940 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2942 diff -NurpP --minimal linux-3.9.4/fs/ext4/ext4.h linux-3.9.4-vs2.3.6.3/fs/ext4/ext4.h
2943 --- linux-3.9.4/fs/ext4/ext4.h 2013-05-31 13:45:23.000000000 +0000
2944 +++ linux-3.9.4-vs2.3.6.3/fs/ext4/ext4.h 2013-05-31 16:22:49.000000000 +0000
2945 @@ -399,7 +399,10 @@ struct flex_groups {
2946 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
2947 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
2948 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
2949 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2950 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2951 #define EXT4_INLINE_DATA_FL 0x10000000 /* Inode has inline data. */
2952 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
2953 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
2955 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
2956 @@ -674,7 +677,7 @@ struct ext4_inode {
2957 __le16 l_i_uid_high; /* these 2 fields */
2958 __le16 l_i_gid_high; /* were reserved2[0] */
2959 __le16 l_i_checksum_lo;/* crc32c(uuid+inum+inode) LE */
2960 - __le16 l_i_reserved;
2961 + __le16 l_i_tag; /* Context Tag */
2964 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
2965 @@ -792,6 +795,7 @@ do { \
2966 #define i_gid_low i_gid
2967 #define i_uid_high osd2.linux2.l_i_uid_high
2968 #define i_gid_high osd2.linux2.l_i_gid_high
2969 +#define i_raw_tag osd2.linux2.l_i_tag
2970 #define i_checksum_lo osd2.linux2.l_i_checksum_lo
2972 #elif defined(__GNU__)
2973 @@ -969,6 +973,7 @@ struct ext4_inode_info {
2974 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
2975 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
2976 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
2977 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
2978 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
2979 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
2980 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
2981 @@ -2527,6 +2532,7 @@ extern struct buffer_head *ext4_get_firs
2982 extern int ext4_inline_data_fiemap(struct inode *inode,
2983 struct fiemap_extent_info *fieinfo,
2985 +extern int ext4_sync_flags(struct inode *, int, int);
2986 extern int ext4_try_to_evict_inline_data(handle_t *handle,
2987 struct inode *inode,
2989 diff -NurpP --minimal linux-3.9.4/fs/ext4/file.c linux-3.9.4-vs2.3.6.3/fs/ext4/file.c
2990 --- linux-3.9.4/fs/ext4/file.c 2013-05-31 13:45:23.000000000 +0000
2991 +++ linux-3.9.4-vs2.3.6.3/fs/ext4/file.c 2013-05-31 14:47:11.000000000 +0000
2992 @@ -650,5 +650,6 @@ const struct inode_operations ext4_file_
2993 .removexattr = generic_removexattr,
2994 .get_acl = ext4_get_acl,
2995 .fiemap = ext4_fiemap,
2996 + .sync_flags = ext4_sync_flags,
2999 diff -NurpP --minimal linux-3.9.4/fs/ext4/ialloc.c linux-3.9.4-vs2.3.6.3/fs/ext4/ialloc.c
3000 --- linux-3.9.4/fs/ext4/ialloc.c 2013-05-31 13:45:23.000000000 +0000
3001 +++ linux-3.9.4-vs2.3.6.3/fs/ext4/ialloc.c 2013-06-03 19:45:15.000000000 +0000
3003 #include <linux/random.h>
3004 #include <linux/bitops.h>
3005 #include <linux/blkdev.h>
3006 +#include <linux/vs_tag.h>
3007 #include <asm/byteorder.h>
3010 @@ -859,6 +860,7 @@ got:
3011 inode->i_mode = mode;
3012 inode->i_uid = current_fsuid();
3013 inode->i_gid = dir->i_gid;
3014 + i_tag_write(inode, dx_current_fstag(sb));
3016 inode_init_owner(inode, dir, mode);
3018 diff -NurpP --minimal linux-3.9.4/fs/ext4/inode.c linux-3.9.4-vs2.3.6.3/fs/ext4/inode.c
3019 --- linux-3.9.4/fs/ext4/inode.c 2013-05-31 14:22:27.000000000 +0000
3020 +++ linux-3.9.4-vs2.3.6.3/fs/ext4/inode.c 2013-06-03 19:45:35.000000000 +0000
3022 #include <linux/printk.h>
3023 #include <linux/slab.h>
3024 #include <linux/ratelimit.h>
3025 +#include <linux/vs_tag.h>
3027 #include "ext4_jbd2.h"
3029 @@ -3870,41 +3871,64 @@ void ext4_set_inode_flags(struct inode *
3031 unsigned int flags = EXT4_I(inode)->i_flags;
3033 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3034 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3035 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3037 + if (flags & EXT4_IMMUTABLE_FL)
3038 + inode->i_flags |= S_IMMUTABLE;
3039 + if (flags & EXT4_IXUNLINK_FL)
3040 + inode->i_flags |= S_IXUNLINK;
3042 if (flags & EXT4_SYNC_FL)
3043 inode->i_flags |= S_SYNC;
3044 if (flags & EXT4_APPEND_FL)
3045 inode->i_flags |= S_APPEND;
3046 - if (flags & EXT4_IMMUTABLE_FL)
3047 - inode->i_flags |= S_IMMUTABLE;
3048 if (flags & EXT4_NOATIME_FL)
3049 inode->i_flags |= S_NOATIME;
3050 if (flags & EXT4_DIRSYNC_FL)
3051 inode->i_flags |= S_DIRSYNC;
3053 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3055 + if (flags & EXT4_BARRIER_FL)
3056 + inode->i_vflags |= V_BARRIER;
3057 + if (flags & EXT4_COW_FL)
3058 + inode->i_vflags |= V_COW;
3061 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3062 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3064 - unsigned int vfs_fl;
3065 + unsigned int vfs_fl, vfs_vf;
3066 unsigned long old_fl, new_fl;
3069 vfs_fl = ei->vfs_inode.i_flags;
3070 + vfs_vf = ei->vfs_inode.i_vflags;
3071 old_fl = ei->i_flags;
3072 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3073 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3075 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3078 + if (vfs_fl & S_IMMUTABLE)
3079 + new_fl |= EXT4_IMMUTABLE_FL;
3080 + if (vfs_fl & S_IXUNLINK)
3081 + new_fl |= EXT4_IXUNLINK_FL;
3083 if (vfs_fl & S_SYNC)
3084 new_fl |= EXT4_SYNC_FL;
3085 if (vfs_fl & S_APPEND)
3086 new_fl |= EXT4_APPEND_FL;
3087 - if (vfs_fl & S_IMMUTABLE)
3088 - new_fl |= EXT4_IMMUTABLE_FL;
3089 if (vfs_fl & S_NOATIME)
3090 new_fl |= EXT4_NOATIME_FL;
3091 if (vfs_fl & S_DIRSYNC)
3092 new_fl |= EXT4_DIRSYNC_FL;
3094 + if (vfs_vf & V_BARRIER)
3095 + new_fl |= EXT4_BARRIER_FL;
3096 + if (vfs_vf & V_COW)
3097 + new_fl |= EXT4_COW_FL;
3098 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3101 @@ -4009,8 +4033,10 @@ struct inode *ext4_iget(struct super_blo
3102 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3103 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3105 - i_uid_write(inode, i_uid);
3106 - i_gid_write(inode, i_gid);
3107 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
3108 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
3109 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
3110 + le16_to_cpu(raw_inode->i_raw_tag)));
3111 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
3113 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3114 @@ -4233,8 +4259,10 @@ static int ext4_do_update_inode(handle_t
3116 ext4_get_inode_flags(ei);
3117 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3118 - i_uid = i_uid_read(inode);
3119 - i_gid = i_gid_read(inode);
3120 + i_uid = from_kuid(&init_user_ns,
3121 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag));
3122 + i_gid = from_kgid(&init_user_ns,
3123 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag));
3124 if (!(test_opt(inode->i_sb, NO_UID32))) {
3125 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
3126 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
3127 @@ -4257,6 +4285,9 @@ static int ext4_do_update_inode(handle_t
3128 raw_inode->i_uid_high = 0;
3129 raw_inode->i_gid_high = 0;
3131 +#ifdef CONFIG_TAGGING_INTERN
3132 + raw_inode->i_raw_tag = cpu_to_le16(i_tag_read(inode));
3134 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3136 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3137 @@ -4487,7 +4518,8 @@ int ext4_setattr(struct dentry *dentry,
3138 if (is_quota_modification(inode, attr))
3139 dquot_initialize(inode);
3140 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
3141 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
3142 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
3143 + (ia_valid & ATTR_TAG && !tag_eq(attr->ia_tag, inode->i_tag))) {
3146 /* (user+group)*(old+new) structure, inode write (sb,
3147 @@ -4510,6 +4542,8 @@ int ext4_setattr(struct dentry *dentry,
3148 inode->i_uid = attr->ia_uid;
3149 if (attr->ia_valid & ATTR_GID)
3150 inode->i_gid = attr->ia_gid;
3151 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3152 + inode->i_tag = attr->ia_tag;
3153 error = ext4_mark_inode_dirty(handle, inode);
3154 ext4_journal_stop(handle);
3156 diff -NurpP --minimal linux-3.9.4/fs/ext4/ioctl.c linux-3.9.4-vs2.3.6.3/fs/ext4/ioctl.c
3157 --- linux-3.9.4/fs/ext4/ioctl.c 2013-05-31 13:45:23.000000000 +0000
3158 +++ linux-3.9.4-vs2.3.6.3/fs/ext4/ioctl.c 2013-05-31 19:50:08.000000000 +0000
3160 #include <linux/compat.h>
3161 #include <linux/mount.h>
3162 #include <linux/file.h>
3163 +#include <linux/vs_tag.h>
3164 #include <asm/uaccess.h>
3165 #include "ext4_jbd2.h"
3168 #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1)
3170 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3172 + handle_t *handle = NULL;
3173 + struct ext4_iloc iloc;
3176 + handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
3177 + if (IS_ERR(handle))
3178 + return PTR_ERR(handle);
3180 + if (IS_SYNC(inode))
3181 + ext4_handle_sync(handle);
3182 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3186 + inode->i_flags = flags;
3187 + inode->i_vflags = vflags;
3188 + ext4_get_inode_flags(EXT4_I(inode));
3189 + inode->i_ctime = ext4_current_time(inode);
3191 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3193 + ext4_journal_stop(handle);
3197 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3199 struct inode *inode = file_inode(filp);
3200 @@ -53,6 +81,11 @@ long ext4_ioctl(struct file *filp, unsig
3202 flags = ext4_mask_flags(inode->i_mode, flags);
3204 + if (IS_BARRIER(inode)) {
3205 + vxwprintk_task(1, "messing with the barrier.");
3210 mutex_lock(&inode->i_mutex);
3211 /* Is it quota file? Do not allow user to mess with it */
3212 @@ -70,7 +103,9 @@ long ext4_ioctl(struct file *filp, unsig
3214 * This test looks nicer. Thanks to Pauline Middelink
3216 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3217 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3218 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3219 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3220 if (!capable(CAP_LINUX_IMMUTABLE))
3223 diff -NurpP --minimal linux-3.9.4/fs/ext4/namei.c linux-3.9.4-vs2.3.6.3/fs/ext4/namei.c
3224 --- linux-3.9.4/fs/ext4/namei.c 2013-05-31 13:45:23.000000000 +0000
3225 +++ linux-3.9.4-vs2.3.6.3/fs/ext4/namei.c 2013-05-31 14:47:11.000000000 +0000
3227 #include <linux/quotaops.h>
3228 #include <linux/buffer_head.h>
3229 #include <linux/bio.h>
3230 +#include <linux/vs_tag.h>
3232 #include "ext4_jbd2.h"
3234 @@ -1290,6 +1291,7 @@ restart:
3235 ll_rw_block(READ | REQ_META | REQ_PRIO,
3238 + dx_propagate_tag(nd, inode);
3240 if ((bh = bh_use[ra_ptr++]) == NULL)
3242 @@ -3190,6 +3192,7 @@ const struct inode_operations ext4_dir_i
3243 .removexattr = generic_removexattr,
3244 .get_acl = ext4_get_acl,
3245 .fiemap = ext4_fiemap,
3246 + .sync_flags = ext4_sync_flags,
3249 const struct inode_operations ext4_special_inode_operations = {
3250 diff -NurpP --minimal linux-3.9.4/fs/ext4/super.c linux-3.9.4-vs2.3.6.3/fs/ext4/super.c
3251 --- linux-3.9.4/fs/ext4/super.c 2013-05-31 14:22:27.000000000 +0000
3252 +++ linux-3.9.4-vs2.3.6.3/fs/ext4/super.c 2013-05-31 14:47:11.000000000 +0000
3253 @@ -1131,7 +1131,7 @@ enum {
3254 Opt_inode_readahead_blks, Opt_journal_ioprio,
3255 Opt_dioread_nolock, Opt_dioread_lock,
3256 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
3257 - Opt_max_dir_size_kb,
3258 + Opt_max_dir_size_kb, Opt_tag, Opt_notag, Opt_tagid
3261 static const match_table_t tokens = {
3262 @@ -1211,6 +1211,9 @@ static const match_table_t tokens = {
3263 {Opt_removed, "reservation"}, /* mount option from ext2/3 */
3264 {Opt_removed, "noreservation"}, /* mount option from ext2/3 */
3265 {Opt_removed, "journal=%u"}, /* mount option from ext2/3 */
3267 + {Opt_notag, "notag"},
3268 + {Opt_tagid, "tagid=%u"},
3272 @@ -1441,6 +1444,20 @@ static int handle_mount_opt(struct super
3274 sb->s_flags |= MS_I_VERSION;
3276 +#ifndef CONFIG_TAGGING_NONE
3278 + set_opt(sb, TAGGED);
3281 + clear_opt(sb, TAGGED);
3284 +#ifdef CONFIG_PROPAGATE
3287 + set_opt(sb, TAGGED);
3292 for (m = ext4_mount_opts; m->token != Opt_err; m++)
3293 @@ -3401,6 +3418,9 @@ static int ext4_fill_super(struct super_
3294 clear_opt(sb, DELALLOC);
3297 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3298 + sb->s_flags |= MS_TAGGED;
3300 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3301 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3303 @@ -4587,6 +4607,14 @@ static int ext4_remount(struct super_blo
3304 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3305 ext4_abort(sb, "Abort forced by user");
3307 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3308 + !(sb->s_flags & MS_TAGGED)) {
3309 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3312 + goto restore_opts;
3315 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3316 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3318 diff -NurpP --minimal linux-3.9.4/fs/fcntl.c linux-3.9.4-vs2.3.6.3/fs/fcntl.c
3319 --- linux-3.9.4/fs/fcntl.c 2013-05-31 13:45:23.000000000 +0000
3320 +++ linux-3.9.4-vs2.3.6.3/fs/fcntl.c 2013-05-31 14:47:11.000000000 +0000
3322 #include <linux/rcupdate.h>
3323 #include <linux/pid_namespace.h>
3324 #include <linux/user_namespace.h>
3325 +#include <linux/vs_limit.h>
3327 #include <asm/poll.h>
3328 #include <asm/siginfo.h>
3329 @@ -378,6 +379,8 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, f
3333 + if (!vx_files_avail(1))
3336 if (unlikely(f.file->f_mode & FMODE_PATH)) {
3337 if (!check_fcntl_cmd(cmd))
3338 diff -NurpP --minimal linux-3.9.4/fs/file.c linux-3.9.4-vs2.3.6.3/fs/file.c
3339 --- linux-3.9.4/fs/file.c 2013-05-31 13:45:23.000000000 +0000
3340 +++ linux-3.9.4-vs2.3.6.3/fs/file.c 2013-05-31 14:47:11.000000000 +0000
3342 #include <linux/spinlock.h>
3343 #include <linux/rcupdate.h>
3344 #include <linux/workqueue.h>
3345 +#include <linux/vs_limit.h>
3347 struct fdtable_defer {
3349 @@ -364,6 +365,8 @@ struct files_struct *dup_fd(struct files
3350 struct file *f = *old_fds++;
3353 + /* TODO: sum it first for check and performance */
3354 + vx_openfd_inc(open_files - i);
3357 * The fd may be claimed in the fd bitmap but not yet
3358 @@ -429,9 +432,11 @@ static void close_files(struct files_str
3359 filp_close(file, files);
3370 @@ -567,6 +572,7 @@ repeat:
3372 __clear_close_on_exec(fd, fdt);
3374 + vx_openfd_inc(fd);
3377 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3378 @@ -597,6 +603,7 @@ static void __put_unused_fd(struct files
3379 __clear_open_fd(fd, fdt);
3380 if (fd < files->next_fd)
3381 files->next_fd = fd;
3382 + vx_openfd_dec(fd);
3385 void put_unused_fd(unsigned int fd)
3386 @@ -876,6 +883,8 @@ static int do_dup2(struct files_struct *
3389 filp_close(tofree, files);
3391 + vx_openfd_inc(fd); /* fd was unused */
3395 diff -NurpP --minimal linux-3.9.4/fs/file_table.c linux-3.9.4-vs2.3.6.3/fs/file_table.c
3396 --- linux-3.9.4/fs/file_table.c 2013-05-31 13:45:23.000000000 +0000
3397 +++ linux-3.9.4-vs2.3.6.3/fs/file_table.c 2013-05-31 14:47:11.000000000 +0000
3399 #include <linux/hardirq.h>
3400 #include <linux/task_work.h>
3401 #include <linux/ima.h>
3402 +#include <linux/vs_limit.h>
3403 +#include <linux/vs_context.h>
3405 #include <linux/atomic.h>
3407 @@ -140,6 +142,8 @@ struct file *get_empty_filp(void)
3408 spin_lock_init(&f->f_lock);
3409 eventpoll_init_file(f);
3410 /* f->f_version: 0 */
3411 + f->f_xid = vx_current_xid();
3416 @@ -257,6 +261,8 @@ static void __fput(struct file *file)
3417 i_readcount_dec(inode);
3418 if (file->f_mode & FMODE_WRITE)
3419 drop_file_write_access(file);
3420 + vx_files_dec(file);
3422 file->f_path.dentry = NULL;
3423 file->f_path.mnt = NULL;
3424 file->f_inode = NULL;
3425 @@ -344,6 +350,8 @@ void put_filp(struct file *file)
3427 if (atomic_long_dec_and_test(&file->f_count)) {
3428 security_file_free(file);
3429 + vx_files_dec(file);
3431 file_sb_list_del(file);
3434 diff -NurpP --minimal linux-3.9.4/fs/fs_struct.c linux-3.9.4-vs2.3.6.3/fs/fs_struct.c
3435 --- linux-3.9.4/fs/fs_struct.c 2013-05-31 13:45:23.000000000 +0000
3436 +++ linux-3.9.4-vs2.3.6.3/fs/fs_struct.c 2013-05-31 14:47:11.000000000 +0000
3438 #include <linux/path.h>
3439 #include <linux/slab.h>
3440 #include <linux/fs_struct.h>
3441 +#include <linux/vserver/global.h>
3442 #include "internal.h"
3445 @@ -87,6 +88,7 @@ void free_fs_struct(struct fs_struct *fs
3447 path_put(&fs->root);
3449 + atomic_dec(&vs_global_fs);
3450 kmem_cache_free(fs_cachep, fs);
3453 @@ -124,6 +126,7 @@ struct fs_struct *copy_fs_struct(struct
3456 spin_unlock(&old->lock);
3457 + atomic_inc(&vs_global_fs);
3461 diff -NurpP --minimal linux-3.9.4/fs/gfs2/file.c linux-3.9.4-vs2.3.6.3/fs/gfs2/file.c
3462 --- linux-3.9.4/fs/gfs2/file.c 2013-05-31 13:45:23.000000000 +0000
3463 +++ linux-3.9.4-vs2.3.6.3/fs/gfs2/file.c 2013-05-31 19:54:27.000000000 +0000
3464 @@ -143,6 +143,9 @@ static const u32 fsflags_to_gfs2[32] = {
3465 [12] = GFS2_DIF_EXHASH,
3466 [14] = GFS2_DIF_INHERIT_JDATA,
3467 [17] = GFS2_DIF_TOPDIR,
3468 + [27] = GFS2_DIF_IXUNLINK,
3469 + [26] = GFS2_DIF_BARRIER,
3470 + [29] = GFS2_DIF_COW,
3473 static const u32 gfs2_to_fsflags[32] = {
3474 @@ -153,6 +156,9 @@ static const u32 gfs2_to_fsflags[32] = {
3475 [gfs2fl_ExHash] = FS_INDEX_FL,
3476 [gfs2fl_TopLevel] = FS_TOPDIR_FL,
3477 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3478 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3479 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3480 + [gfs2fl_Cow] = FS_COW_FL,
3483 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3484 @@ -183,12 +189,18 @@ void gfs2_set_inode_flags(struct inode *
3486 struct gfs2_inode *ip = GFS2_I(inode);
3487 unsigned int flags = inode->i_flags;
3488 + unsigned int vflags = inode->i_vflags;
3490 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3491 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
3493 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
3494 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
3495 inode->i_flags |= S_NOSEC;
3496 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3497 flags |= S_IMMUTABLE;
3498 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3499 + flags |= S_IXUNLINK;
3501 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3503 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3504 @@ -196,6 +208,43 @@ void gfs2_set_inode_flags(struct inode *
3505 if (ip->i_diskflags & GFS2_DIF_SYNC)
3507 inode->i_flags = flags;
3509 + vflags &= ~(V_BARRIER | V_COW);
3511 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3512 + vflags |= V_BARRIER;
3513 + if (ip->i_diskflags & GFS2_DIF_COW)
3515 + inode->i_vflags = vflags;
3518 +void gfs2_get_inode_flags(struct inode *inode)
3520 + struct gfs2_inode *ip = GFS2_I(inode);
3521 + unsigned int flags = inode->i_flags;
3522 + unsigned int vflags = inode->i_vflags;
3524 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3525 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3526 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3527 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3529 + if (flags & S_IMMUTABLE)
3530 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3531 + if (flags & S_IXUNLINK)
3532 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3534 + if (flags & S_APPEND)
3535 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3536 + if (flags & S_NOATIME)
3537 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3538 + if (flags & S_SYNC)
3539 + ip->i_diskflags |= GFS2_DIF_SYNC;
3541 + if (vflags & V_BARRIER)
3542 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3543 + if (vflags & V_COW)
3544 + ip->i_diskflags |= GFS2_DIF_COW;
3547 /* Flags that can be set by user space */
3548 @@ -309,6 +358,37 @@ static int gfs2_set_flags(struct file *f
3549 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3552 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3554 + struct gfs2_inode *ip = GFS2_I(inode);
3555 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3556 + struct buffer_head *bh;
3557 + struct gfs2_holder gh;
3560 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3563 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3566 + error = gfs2_meta_inode_buffer(ip, &bh);
3568 + goto out_trans_end;
3569 + gfs2_trans_add_meta(ip->i_gl, bh);
3570 + inode->i_flags = flags;
3571 + inode->i_vflags = vflags;
3572 + gfs2_get_inode_flags(inode);
3573 + gfs2_dinode_out(ip, bh->b_data);
3575 + gfs2_set_aops(inode);
3577 + gfs2_trans_end(sdp);
3579 + gfs2_glock_dq_uninit(&gh);
3583 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3586 diff -NurpP --minimal linux-3.9.4/fs/gfs2/inode.h linux-3.9.4-vs2.3.6.3/fs/gfs2/inode.h
3587 --- linux-3.9.4/fs/gfs2/inode.h 2012-12-11 03:30:57.000000000 +0000
3588 +++ linux-3.9.4-vs2.3.6.3/fs/gfs2/inode.h 2013-05-31 14:47:11.000000000 +0000
3589 @@ -117,6 +117,7 @@ extern const struct file_operations gfs2
3590 extern const struct file_operations gfs2_dir_fops_nolock;
3592 extern void gfs2_set_inode_flags(struct inode *inode);
3593 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3595 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3596 extern const struct file_operations gfs2_file_fops;
3597 diff -NurpP --minimal linux-3.9.4/fs/hostfs/hostfs.h linux-3.9.4-vs2.3.6.3/fs/hostfs/hostfs.h
3598 --- linux-3.9.4/fs/hostfs/hostfs.h 2012-12-11 03:30:57.000000000 +0000
3599 +++ linux-3.9.4-vs2.3.6.3/fs/hostfs/hostfs.h 2013-05-31 14:47:11.000000000 +0000
3600 @@ -42,6 +42,7 @@ struct hostfs_iattr {
3601 unsigned short ia_mode;
3606 struct timespec ia_atime;
3607 struct timespec ia_mtime;
3608 diff -NurpP --minimal linux-3.9.4/fs/inode.c linux-3.9.4-vs2.3.6.3/fs/inode.c
3609 --- linux-3.9.4/fs/inode.c 2013-05-31 13:45:24.000000000 +0000
3610 +++ linux-3.9.4-vs2.3.6.3/fs/inode.c 2013-06-03 18:32:17.000000000 +0000
3612 #include <linux/prefetch.h>
3613 #include <linux/buffer_head.h> /* for inode_has_buffers */
3614 #include <linux/ratelimit.h>
3615 +#include <linux/vs_tag.h>
3616 #include "internal.h"
3619 @@ -128,6 +129,8 @@ int inode_init_always(struct super_block
3620 struct address_space *const mapping = &inode->i_data;
3624 + /* essential because of inode slab reuse */
3625 inode->i_blkbits = sb->s_blocksize_bits;
3627 atomic_set(&inode->i_count, 1);
3628 @@ -137,6 +140,7 @@ int inode_init_always(struct super_block
3629 inode->i_opflags = 0;
3630 i_uid_write(inode, 0);
3631 i_gid_write(inode, 0);
3632 + i_tag_write(inode, 0);
3633 atomic_set(&inode->i_writecount, 0);
3635 inode->i_blocks = 0;
3636 @@ -149,6 +153,7 @@ int inode_init_always(struct super_block
3637 inode->i_bdev = NULL;
3638 inode->i_cdev = NULL;
3640 + inode->i_mdev = 0;
3641 inode->dirtied_when = 0;
3643 if (security_inode_alloc(inode))
3644 @@ -483,6 +488,8 @@ void __insert_inode_hash(struct inode *i
3646 EXPORT_SYMBOL(__insert_inode_hash);
3648 +EXPORT_SYMBOL_GPL(__iget);
3651 * __remove_inode_hash - remove an inode from the hash
3652 * @inode: inode to unhash
3653 @@ -1799,9 +1806,11 @@ void init_special_inode(struct inode *in
3654 if (S_ISCHR(mode)) {
3655 inode->i_fop = &def_chr_fops;
3656 inode->i_rdev = rdev;
3657 + inode->i_mdev = rdev;
3658 } else if (S_ISBLK(mode)) {
3659 inode->i_fop = &def_blk_fops;
3660 inode->i_rdev = rdev;
3661 + inode->i_mdev = rdev;
3662 } else if (S_ISFIFO(mode))
3663 inode->i_fop = &def_fifo_fops;
3664 else if (S_ISSOCK(mode))
3665 @@ -1830,6 +1839,7 @@ void inode_init_owner(struct inode *inod
3667 inode->i_gid = current_fsgid();
3668 inode->i_mode = mode;
3669 + i_tag_write(inode, dx_current_fstag(inode->i_sb));
3671 EXPORT_SYMBOL(inode_init_owner);
3673 diff -NurpP --minimal linux-3.9.4/fs/ioctl.c linux-3.9.4-vs2.3.6.3/fs/ioctl.c
3674 --- linux-3.9.4/fs/ioctl.c 2013-05-31 13:45:24.000000000 +0000
3675 +++ linux-3.9.4-vs2.3.6.3/fs/ioctl.c 2013-05-31 14:47:11.000000000 +0000
3677 #include <linux/writeback.h>
3678 #include <linux/buffer_head.h>
3679 #include <linux/falloc.h>
3680 +#include <linux/proc_fs.h>
3681 +#include <linux/vserver/inode.h>
3682 +#include <linux/vs_tag.h>
3684 #include <asm/ioctls.h>
3686 diff -NurpP --minimal linux-3.9.4/fs/ioprio.c linux-3.9.4-vs2.3.6.3/fs/ioprio.c
3687 --- linux-3.9.4/fs/ioprio.c 2012-12-11 03:30:57.000000000 +0000
3688 +++ linux-3.9.4-vs2.3.6.3/fs/ioprio.c 2013-05-31 14:47:11.000000000 +0000
3690 #include <linux/syscalls.h>
3691 #include <linux/security.h>
3692 #include <linux/pid_namespace.h>
3693 +#include <linux/vs_base.h>
3695 int set_task_ioprio(struct task_struct *task, int ioprio)
3697 @@ -105,6 +106,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3699 pgrp = find_vpid(who);
3700 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3701 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3703 ret = set_task_ioprio(p, ioprio);
3706 @@ -198,6 +201,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3708 pgrp = find_vpid(who);
3709 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3710 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3712 tmpio = get_task_ioprio(p);
3715 diff -NurpP --minimal linux-3.9.4/fs/jfs/file.c linux-3.9.4-vs2.3.6.3/fs/jfs/file.c
3716 --- linux-3.9.4/fs/jfs/file.c 2013-02-19 13:58:48.000000000 +0000
3717 +++ linux-3.9.4-vs2.3.6.3/fs/jfs/file.c 2013-05-31 14:47:11.000000000 +0000
3718 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
3719 if (is_quota_modification(inode, iattr))
3720 dquot_initialize(inode);
3721 if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||
3722 - (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {
3723 + (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid)) ||
3724 + (iattr->ia_valid & ATTR_TAG && !tag_eq(iattr->ia_tag, inode->i_tag))) {
3725 rc = dquot_transfer(inode, iattr);
3728 @@ -144,6 +145,7 @@ const struct inode_operations jfs_file_i
3729 #ifdef CONFIG_JFS_POSIX_ACL
3730 .get_acl = jfs_get_acl,
3732 + .sync_flags = jfs_sync_flags,
3735 const struct file_operations jfs_file_operations = {
3736 diff -NurpP --minimal linux-3.9.4/fs/jfs/ioctl.c linux-3.9.4-vs2.3.6.3/fs/jfs/ioctl.c
3737 --- linux-3.9.4/fs/jfs/ioctl.c 2013-05-31 13:45:24.000000000 +0000
3738 +++ linux-3.9.4-vs2.3.6.3/fs/jfs/ioctl.c 2013-05-31 14:47:11.000000000 +0000
3740 #include <linux/time.h>
3741 #include <linux/sched.h>
3742 #include <linux/blkdev.h>
3743 +#include <linux/mount.h>
3744 #include <asm/current.h>
3745 #include <asm/uaccess.h>
3747 @@ -56,6 +57,16 @@ static long jfs_map_ext2(unsigned long f
3751 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3753 + inode->i_flags = flags;
3754 + inode->i_vflags = vflags;
3755 + jfs_get_inode_flags(JFS_IP(inode));
3756 + inode->i_ctime = CURRENT_TIME_SEC;
3757 + mark_inode_dirty(inode);
3761 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3763 struct inode *inode = file_inode(filp);
3764 @@ -89,6 +100,11 @@ long jfs_ioctl(struct file *filp, unsign
3765 if (!S_ISDIR(inode->i_mode))
3766 flags &= ~JFS_DIRSYNC_FL;
3768 + if (IS_BARRIER(inode)) {
3769 + vxwprintk_task(1, "messing with the barrier.");
3773 /* Is it quota file? Do not allow user to mess with it */
3774 if (IS_NOQUOTA(inode)) {
3776 @@ -106,8 +122,8 @@ long jfs_ioctl(struct file *filp, unsign
3777 * the relevant capability.
3779 if ((oldflags & JFS_IMMUTABLE_FL) ||
3780 - ((flags ^ oldflags) &
3781 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3782 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3783 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3784 if (!capable(CAP_LINUX_IMMUTABLE)) {
3785 mutex_unlock(&inode->i_mutex);
3787 @@ -115,7 +131,7 @@ long jfs_ioctl(struct file *filp, unsign
3791 - flags = flags & JFS_FL_USER_MODIFIABLE;
3792 + flags &= JFS_FL_USER_MODIFIABLE;
3793 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3794 jfs_inode->mode2 = flags;
3796 diff -NurpP --minimal linux-3.9.4/fs/jfs/jfs_dinode.h linux-3.9.4-vs2.3.6.3/fs/jfs/jfs_dinode.h
3797 --- linux-3.9.4/fs/jfs/jfs_dinode.h 2012-12-11 03:30:57.000000000 +0000
3798 +++ linux-3.9.4-vs2.3.6.3/fs/jfs/jfs_dinode.h 2013-05-31 14:47:11.000000000 +0000
3799 @@ -161,9 +161,13 @@ struct dinode {
3801 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3802 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3803 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3805 -#define JFS_FL_USER_VISIBLE 0x03F80000
3806 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3807 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3808 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3810 +#define JFS_FL_USER_VISIBLE 0x07F80000
3811 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3812 #define JFS_FL_INHERIT 0x03C80000
3814 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3815 diff -NurpP --minimal linux-3.9.4/fs/jfs/jfs_filsys.h linux-3.9.4-vs2.3.6.3/fs/jfs/jfs_filsys.h
3816 --- linux-3.9.4/fs/jfs/jfs_filsys.h 2012-12-11 03:30:57.000000000 +0000
3817 +++ linux-3.9.4-vs2.3.6.3/fs/jfs/jfs_filsys.h 2013-05-31 14:47:11.000000000 +0000
3819 #define JFS_NAME_MAX 255
3820 #define JFS_PATH_MAX BPSIZE
3822 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
3825 * file system state (superblock state)
3826 diff -NurpP --minimal linux-3.9.4/fs/jfs/jfs_imap.c linux-3.9.4-vs2.3.6.3/fs/jfs/jfs_imap.c
3827 --- linux-3.9.4/fs/jfs/jfs_imap.c 2012-12-11 03:30:57.000000000 +0000
3828 +++ linux-3.9.4-vs2.3.6.3/fs/jfs/jfs_imap.c 2013-06-03 19:53:45.000000000 +0000
3830 #include <linux/pagemap.h>
3831 #include <linux/quotaops.h>
3832 #include <linux/slab.h>
3833 +#include <linux/vs_tag.h>
3835 #include "jfs_incore.h"
3836 #include "jfs_inode.h"
3837 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
3839 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3840 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
3844 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3845 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3846 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
3848 set_nlink(ip, le32_to_cpu(dip->di_nlink));
3850 - jfs_ip->saved_uid = make_kuid(&init_user_ns, le32_to_cpu(dip->di_uid));
3851 + kuid = make_kuid(&init_user_ns, le32_to_cpu(dip->di_uid));
3852 + kgid = make_kgid(&init_user_ns, le32_to_cpu(dip->di_gid));
3853 + ip->i_tag = INOTAG_KTAG(DX_TAG(ip), kuid, kgid, GLOBAL_ROOT_TAG);
3855 + jfs_ip->saved_uid = INOTAG_KUID(DX_TAG(ip), kuid, kgid);
3856 if (!uid_valid(sbi->uid))
3857 ip->i_uid = jfs_ip->saved_uid;
3859 ip->i_uid = sbi->uid;
3862 - jfs_ip->saved_gid = make_kgid(&init_user_ns, le32_to_cpu(dip->di_gid));
3863 + jfs_ip->saved_gid = INOTAG_KGID(DX_TAG(ip), kuid, kgid);
3864 if (!gid_valid(sbi->gid))
3865 ip->i_gid = jfs_ip->saved_gid;
3867 @@ -3150,16 +3157,14 @@ static void copy_to_dinode(struct dinode
3868 dip->di_size = cpu_to_le64(ip->i_size);
3869 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
3870 dip->di_nlink = cpu_to_le32(ip->i_nlink);
3871 - if (!uid_valid(sbi->uid))
3872 - dip->di_uid = cpu_to_le32(i_uid_read(ip));
3874 - dip->di_uid =cpu_to_le32(from_kuid(&init_user_ns,
3875 - jfs_ip->saved_uid));
3876 - if (!gid_valid(sbi->gid))
3877 - dip->di_gid = cpu_to_le32(i_gid_read(ip));
3879 - dip->di_gid = cpu_to_le32(from_kgid(&init_user_ns,
3880 - jfs_ip->saved_gid));
3881 + dip->di_uid = cpu_to_le32(from_kuid(&init_user_ns,
3882 + TAGINO_KUID(DX_TAG(ip),
3883 + !uid_valid(sbi->uid) ? ip->i_uid : jfs_ip->saved_uid,
3885 + dip->di_gid = cpu_to_le32(from_kgid(&init_user_ns,
3886 + TAGINO_KGID(DX_TAG(ip),
3887 + !gid_valid(sbi->gid) ? ip->i_gid : jfs_ip->saved_gid,
3889 jfs_get_inode_flags(jfs_ip);
3891 * mode2 is only needed for storing the higher order bits.
3892 diff -NurpP --minimal linux-3.9.4/fs/jfs/jfs_inode.c linux-3.9.4-vs2.3.6.3/fs/jfs/jfs_inode.c
3893 --- linux-3.9.4/fs/jfs/jfs_inode.c 2012-12-11 03:30:57.000000000 +0000
3894 +++ linux-3.9.4-vs2.3.6.3/fs/jfs/jfs_inode.c 2013-05-31 14:47:11.000000000 +0000
3897 #include <linux/fs.h>
3898 #include <linux/quotaops.h>
3899 +#include <linux/vs_tag.h>
3900 #include "jfs_incore.h"
3901 #include "jfs_inode.h"
3902 #include "jfs_filsys.h"
3903 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
3905 unsigned int flags = JFS_IP(inode)->mode2;
3907 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
3908 - S_NOATIME | S_DIRSYNC | S_SYNC);
3909 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3910 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3912 if (flags & JFS_IMMUTABLE_FL)
3913 inode->i_flags |= S_IMMUTABLE;
3914 + if (flags & JFS_IXUNLINK_FL)
3915 + inode->i_flags |= S_IXUNLINK;
3917 + if (flags & JFS_SYNC_FL)
3918 + inode->i_flags |= S_SYNC;
3919 if (flags & JFS_APPEND_FL)
3920 inode->i_flags |= S_APPEND;
3921 if (flags & JFS_NOATIME_FL)
3922 inode->i_flags |= S_NOATIME;
3923 if (flags & JFS_DIRSYNC_FL)
3924 inode->i_flags |= S_DIRSYNC;
3925 - if (flags & JFS_SYNC_FL)
3926 - inode->i_flags |= S_SYNC;
3928 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3930 + if (flags & JFS_BARRIER_FL)
3931 + inode->i_vflags |= V_BARRIER;
3932 + if (flags & JFS_COW_FL)
3933 + inode->i_vflags |= V_COW;
3936 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
3938 unsigned int flags = jfs_ip->vfs_inode.i_flags;
3939 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
3941 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
3942 + JFS_APPEND_FL | JFS_NOATIME_FL |
3943 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
3944 + JFS_BARRIER_FL | JFS_COW_FL);
3946 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
3947 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
3948 if (flags & S_IMMUTABLE)
3949 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
3950 + if (flags & S_IXUNLINK)
3951 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
3953 if (flags & S_APPEND)
3954 jfs_ip->mode2 |= JFS_APPEND_FL;
3955 if (flags & S_NOATIME)
3956 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
3957 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
3959 jfs_ip->mode2 |= JFS_SYNC_FL;
3961 + if (vflags & V_BARRIER)
3962 + jfs_ip->mode2 |= JFS_BARRIER_FL;
3963 + if (vflags & V_COW)
3964 + jfs_ip->mode2 |= JFS_COW_FL;
3968 diff -NurpP --minimal linux-3.9.4/fs/jfs/jfs_inode.h linux-3.9.4-vs2.3.6.3/fs/jfs/jfs_inode.h
3969 --- linux-3.9.4/fs/jfs/jfs_inode.h 2012-12-11 03:30:57.000000000 +0000
3970 +++ linux-3.9.4-vs2.3.6.3/fs/jfs/jfs_inode.h 2013-05-31 14:47:11.000000000 +0000
3971 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
3972 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
3973 int fh_len, int fh_type);
3974 extern void jfs_set_inode_flags(struct inode *);
3975 +extern int jfs_sync_flags(struct inode *, int, int);
3976 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
3977 extern int jfs_setattr(struct dentry *, struct iattr *);
3979 diff -NurpP --minimal linux-3.9.4/fs/jfs/namei.c linux-3.9.4-vs2.3.6.3/fs/jfs/namei.c
3980 --- linux-3.9.4/fs/jfs/namei.c 2012-12-11 03:30:57.000000000 +0000
3981 +++ linux-3.9.4-vs2.3.6.3/fs/jfs/namei.c 2013-05-31 14:47:11.000000000 +0000
3983 #include <linux/ctype.h>
3984 #include <linux/quotaops.h>
3985 #include <linux/exportfs.h>
3986 +#include <linux/vs_tag.h>
3987 #include "jfs_incore.h"
3988 #include "jfs_superblock.h"
3989 #include "jfs_inode.h"
3990 @@ -1461,6 +1462,7 @@ static struct dentry *jfs_lookup(struct
3991 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
3994 + dx_propagate_tag(nd, ip);
3995 return d_splice_alias(ip, dentry);
3998 @@ -1525,6 +1527,7 @@ const struct inode_operations jfs_dir_in
3999 #ifdef CONFIG_JFS_POSIX_ACL
4000 .get_acl = jfs_get_acl,
4002 + .sync_flags = jfs_sync_flags,
4005 const struct file_operations jfs_dir_operations = {
4006 diff -NurpP --minimal linux-3.9.4/fs/jfs/super.c linux-3.9.4-vs2.3.6.3/fs/jfs/super.c
4007 --- linux-3.9.4/fs/jfs/super.c 2013-05-31 13:45:24.000000000 +0000
4008 +++ linux-3.9.4-vs2.3.6.3/fs/jfs/super.c 2013-05-31 14:47:11.000000000 +0000
4009 @@ -199,7 +199,8 @@ enum {
4010 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4011 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4012 Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4013 - Opt_discard, Opt_nodiscard, Opt_discard_minblk
4014 + Opt_discard, Opt_nodiscard, Opt_discard_minblk,
4015 + Opt_tag, Opt_notag, Opt_tagid
4018 static const match_table_t tokens = {
4019 @@ -209,6 +210,10 @@ static const match_table_t tokens = {
4020 {Opt_resize, "resize=%u"},
4021 {Opt_resize_nosize, "resize"},
4022 {Opt_errors, "errors=%s"},
4024 + {Opt_notag, "notag"},
4025 + {Opt_tagid, "tagid=%u"},
4026 + {Opt_tag, "tagxid"},
4027 {Opt_ignore, "noquota"},
4028 {Opt_ignore, "quota"},
4029 {Opt_usrquota, "usrquota"},
4030 @@ -385,7 +390,20 @@ static int parse_options(char *options,
4035 +#ifndef CONFIG_TAGGING_NONE
4037 + *flag |= JFS_TAGGED;
4040 + *flag &= JFS_TAGGED;
4043 +#ifdef CONFIG_PROPAGATE
4046 + *flag |= JFS_TAGGED;
4050 printk("jfs: Unrecognized mount option \"%s\" "
4051 " or missing value\n", p);
4052 @@ -417,6 +435,12 @@ static int jfs_remount(struct super_bloc
4056 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4057 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4063 if (sb->s_flags & MS_RDONLY) {
4064 pr_err("JFS: resize requires volume" \
4065 @@ -502,6 +526,9 @@ static int jfs_fill_super(struct super_b
4066 #ifdef CONFIG_JFS_POSIX_ACL
4067 sb->s_flags |= MS_POSIXACL;
4069 + /* map mount option tagxid */
4070 + if (sbi->flag & JFS_TAGGED)
4071 + sb->s_flags |= MS_TAGGED;
4074 pr_err("resize option for remount only\n");
4075 diff -NurpP --minimal linux-3.9.4/fs/libfs.c linux-3.9.4-vs2.3.6.3/fs/libfs.c
4076 --- linux-3.9.4/fs/libfs.c 2013-02-19 13:58:48.000000000 +0000
4077 +++ linux-3.9.4-vs2.3.6.3/fs/libfs.c 2013-05-31 14:47:11.000000000 +0000
4078 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
4079 * both impossible due to the lock on directory.
4082 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4083 +static inline int do_dcache_readdir_filter(struct file *filp,
4084 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4086 struct dentry *dentry = filp->f_path.dentry;
4087 struct dentry *cursor = filp->private_data;
4088 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
4089 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4090 struct dentry *next;
4091 next = list_entry(p, struct dentry, d_u.d_child);
4092 + if (filter && !filter(next))
4094 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4095 if (!simple_positive(next)) {
4096 spin_unlock(&next->d_lock);
4097 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
4101 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4103 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4106 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4107 + int (*filter)(struct dentry *))
4109 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4112 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4115 @@ -981,6 +995,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4116 EXPORT_SYMBOL(dcache_dir_lseek);
4117 EXPORT_SYMBOL(dcache_dir_open);
4118 EXPORT_SYMBOL(dcache_readdir);
4119 +EXPORT_SYMBOL(dcache_readdir_filter);
4120 EXPORT_SYMBOL(generic_read_dir);
4121 EXPORT_SYMBOL(mount_pseudo);
4122 EXPORT_SYMBOL(simple_write_begin);
4123 diff -NurpP --minimal linux-3.9.4/fs/locks.c linux-3.9.4-vs2.3.6.3/fs/locks.c
4124 --- linux-3.9.4/fs/locks.c 2013-05-31 13:45:24.000000000 +0000
4125 +++ linux-3.9.4-vs2.3.6.3/fs/locks.c 2013-05-31 15:53:57.000000000 +0000
4127 #include <linux/time.h>
4128 #include <linux/rcupdate.h>
4129 #include <linux/pid_namespace.h>
4130 +#include <linux/vs_base.h>
4131 +#include <linux/vs_limit.h>
4133 #include <asm/uaccess.h>
4135 @@ -184,11 +186,17 @@ static void locks_init_lock_heads(struct
4136 /* Allocate an empty lock structure. */
4137 struct file_lock *locks_alloc_lock(void)
4139 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4140 + struct file_lock *fl;
4143 - locks_init_lock_heads(fl);
4144 + if (!vx_locks_avail(1))
4147 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4150 + locks_init_lock_heads(fl);
4155 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4156 @@ -212,6 +220,7 @@ void locks_free_lock(struct file_lock *f
4157 BUG_ON(!list_empty(&fl->fl_block));
4158 BUG_ON(!list_empty(&fl->fl_link));
4161 locks_release_private(fl);
4162 kmem_cache_free(filelock_cache, fl);
4164 @@ -221,6 +230,7 @@ void locks_init_lock(struct file_lock *f
4166 memset(fl, 0, sizeof(struct file_lock));
4167 locks_init_lock_heads(fl);
4171 EXPORT_SYMBOL(locks_init_lock);
4172 @@ -261,6 +271,7 @@ void locks_copy_lock(struct file_lock *n
4173 new->fl_file = fl->fl_file;
4174 new->fl_ops = fl->fl_ops;
4175 new->fl_lmops = fl->fl_lmops;
4176 + new->fl_xid = fl->fl_xid;
4178 locks_copy_private(new, fl);
4180 @@ -299,6 +310,11 @@ static int flock_make_lock(struct file *
4181 fl->fl_flags = FL_FLOCK;
4183 fl->fl_end = OFFSET_MAX;
4185 + vxd_assert(filp->f_xid == vx_current_xid(),
4186 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4187 + fl->fl_xid = filp->f_xid;
4192 @@ -438,6 +454,7 @@ static int lease_init(struct file *filp,
4194 fl->fl_owner = current->files;
4195 fl->fl_pid = current->tgid;
4196 + fl->fl_xid = vx_current_xid();
4199 fl->fl_flags = FL_LEASE;
4200 @@ -457,6 +474,11 @@ static struct file_lock *lease_alloc(str
4202 return ERR_PTR(error);
4204 + fl->fl_xid = vx_current_xid();
4206 + vxd_assert(filp->f_xid == fl->fl_xid,
4207 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4209 error = lease_init(filp, type, fl);
4211 locks_free_lock(fl);
4212 @@ -753,6 +775,7 @@ static int flock_lock_file(struct file *
4216 + new_fl->fl_xid = -1;
4218 for_each_lock(inode, before) {
4219 struct file_lock *fl = *before;
4220 @@ -773,6 +796,7 @@ find_conflict:
4222 locks_copy_lock(new_fl, request);
4223 locks_insert_lock(before, new_fl);
4224 + vx_locks_inc(new_fl);
4228 @@ -783,7 +807,8 @@ out:
4232 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4233 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4234 + struct file_lock *conflock, xid_t xid)
4236 struct file_lock *fl;
4237 struct file_lock *new_fl = NULL;
4238 @@ -793,6 +818,8 @@ static int __posix_lock_file(struct inod
4239 struct file_lock **before;
4240 int error, added = 0;
4242 + vxd_assert(xid == vx_current_xid(),
4243 + "xid(%d) == current(%d)", xid, vx_current_xid());
4245 * We may need two file_lock structures for this operation,
4246 * so we get them in advance to avoid races.
4247 @@ -803,7 +830,11 @@ static int __posix_lock_file(struct inod
4248 (request->fl_type != F_UNLCK ||
4249 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4250 new_fl = locks_alloc_lock();
4251 + new_fl->fl_xid = xid;
4252 + vx_locks_inc(new_fl);
4253 new_fl2 = locks_alloc_lock();
4254 + new_fl2->fl_xid = xid;
4255 + vx_locks_inc(new_fl2);
4259 @@ -1002,7 +1033,8 @@ static int __posix_lock_file(struct inod
4260 int posix_lock_file(struct file *filp, struct file_lock *fl,
4261 struct file_lock *conflock)
4263 - return __posix_lock_file(file_inode(filp), fl, conflock);
4264 + return __posix_lock_file(file_inode(filp),
4265 + fl, conflock, filp->f_xid);
4267 EXPORT_SYMBOL(posix_lock_file);
4269 @@ -1092,7 +1124,7 @@ int locks_mandatory_area(int read_write,
4270 fl.fl_end = offset + count - 1;
4273 - error = __posix_lock_file(inode, &fl, NULL);
4274 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4275 if (error != FILE_LOCK_DEFERRED)
4277 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4278 @@ -1397,6 +1429,7 @@ int generic_add_lease(struct file *filp,
4281 locks_insert_lock(before, lease);
4282 + vx_locks_inc(lease);
4286 @@ -1836,6 +1869,11 @@ int fcntl_setlk(unsigned int fd, struct
4287 if (file_lock == NULL)
4290 + vxd_assert(filp->f_xid == vx_current_xid(),
4291 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4292 + file_lock->fl_xid = filp->f_xid;
4293 + vx_locks_inc(file_lock);
4296 * This might block, so we do it before checking the inode.
4298 @@ -1954,6 +1992,11 @@ int fcntl_setlk64(unsigned int fd, struc
4299 if (file_lock == NULL)
4302 + vxd_assert(filp->f_xid == vx_current_xid(),
4303 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4304 + file_lock->fl_xid = filp->f_xid;
4305 + vx_locks_inc(file_lock);
4308 * This might block, so we do it before checking the inode.
4310 @@ -2219,8 +2262,11 @@ static int locks_show(struct seq_file *f
4312 lock_get_status(f, fl, *((loff_t *)f->private), "");
4314 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4315 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4316 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4318 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4323 diff -NurpP --minimal linux-3.9.4/fs/mount.h linux-3.9.4-vs2.3.6.3/fs/mount.h
4324 --- linux-3.9.4/fs/mount.h 2013-02-19 13:58:48.000000000 +0000
4325 +++ linux-3.9.4-vs2.3.6.3/fs/mount.h 2013-05-31 14:47:11.000000000 +0000
4326 @@ -49,6 +49,7 @@ struct mount {
4327 int mnt_expiry_mark; /* true if marked for expiry */
4330 + tag_t mnt_tag; /* tagging used for vfsmount */
4333 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
4334 diff -NurpP --minimal linux-3.9.4/fs/namei.c linux-3.9.4-vs2.3.6.3/fs/namei.c
4335 --- linux-3.9.4/fs/namei.c 2013-05-31 14:22:27.000000000 +0000
4336 +++ linux-3.9.4-vs2.3.6.3/fs/namei.c 2013-06-01 09:00:16.000000000 +0000
4338 #include <linux/device_cgroup.h>
4339 #include <linux/fs_struct.h>
4340 #include <linux/posix_acl.h>
4341 +#include <linux/proc_fs.h>
4342 +#include <linux/vserver/inode.h>
4343 +#include <linux/vs_base.h>
4344 +#include <linux/vs_tag.h>
4345 +#include <linux/vs_cowbl.h>
4346 +#include <linux/vs_device.h>
4347 +#include <linux/vs_context.h>
4348 +#include <linux/pid_namespace.h>
4349 #include <asm/uaccess.h>
4351 #include "internal.h"
4352 @@ -266,6 +274,89 @@ static int check_acl(struct inode *inode
4356 +static inline int dx_barrier(const struct inode *inode)
4358 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4359 + vxwprintk_task(1, "did hit the barrier.");
4365 +static int __dx_permission(const struct inode *inode, int mask)
4367 + if (dx_barrier(inode))
4370 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4371 + /* devpts is xid tagged */
4372 + if (S_ISDIR(inode->i_mode) ||
4373 + vx_check((xid_t)i_tag_read(inode), VS_IDENT | VS_WATCH_P))
4376 + /* just pretend we didn't find anything */
4379 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4380 + struct proc_dir_entry *de = PDE(inode);
4382 + if (de && !vx_hide_check(0, de->vx_flags))
4385 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4387 + struct task_struct *tsk;
4389 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4390 + vx_flags(VXF_STATE_SETUP, 0))
4393 + pid = PROC_I(inode)->pid;
4398 + tsk = pid_task(pid, PIDTYPE_PID);
4399 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4400 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4402 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4403 + rcu_read_unlock();
4406 + rcu_read_unlock();
4409 + /* FIXME: Should we block some entries here? */
4414 + if (dx_notagcheck(inode->i_sb) ||
4415 + dx_check((xid_t)i_tag_read(inode),
4416 + DX_HOSTID | DX_ADMIN | DX_WATCH | DX_IDENT))
4424 +int dx_permission(const struct inode *inode, int mask)
4426 + int ret = __dx_permission(inode, mask);
4427 + if (unlikely(ret)) {
4428 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4429 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4432 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4433 + mask, inode->i_sb->s_id, inode,
4434 + i_tag_read(inode), inode->i_ino);
4440 * This does the basic permission checking
4442 @@ -388,10 +479,14 @@ int __inode_permission(struct inode *ino
4444 * Nobody gets write access to an immutable file.
4446 - if (IS_IMMUTABLE(inode))
4447 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4451 + retval = dx_permission(inode, mask);
4455 retval = do_inode_permission(inode, mask);
4458 @@ -1238,7 +1333,8 @@ static void follow_dotdot(struct nameida
4460 if (nd->path.dentry == nd->root.dentry &&
4461 nd->path.mnt == nd->root.mnt) {
4463 + /* for sane '/' avoid follow_mount() */
4466 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4467 /* rare case of legitimate dget_parent()... */
4468 @@ -1383,6 +1479,9 @@ static int lookup_fast(struct nameidata
4473 + /* FIXME: check dx permission */
4476 path->dentry = dentry;
4477 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4478 @@ -1413,6 +1512,8 @@ unlazy:
4482 + /* FIXME: check dx permission */
4485 path->dentry = dentry;
4486 err = follow_managed(path, nd->flags);
4487 @@ -2237,7 +2338,7 @@ static int may_delete(struct inode *dir,
4490 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4491 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4492 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4495 if (!S_ISDIR(victim->d_inode->i_mode))
4496 @@ -2316,19 +2417,25 @@ int vfs_create(struct inode *dir, struct
4499 int error = may_create(dir, dentry);
4502 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
4506 if (!dir->i_op->create)
4507 return -EACCES; /* shouldn't it be ENOSYS? */
4510 error = security_inode_create(dir, dentry, mode);
4513 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
4516 error = dir->i_op->create(dir, dentry, mode, want_excl);
4518 fsnotify_create(dir, dentry);
4520 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
4524 @@ -2363,6 +2470,15 @@ static int may_open(struct path *path, i
4528 +#ifdef CONFIG_VSERVER_COWBL
4529 + if (IS_COW(inode) &&
4530 + ((flag & O_ACCMODE) != O_RDONLY)) {
4531 + if (IS_COW_LINK(inode))
4533 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4534 + mark_inode_dirty(inode);
4537 error = inode_permission(inode, acc_mode);
4540 @@ -2865,6 +2981,16 @@ finish_open:
4542 finish_open_created:
4543 error = may_open(&nd->path, acc_mode, open_flag);
4544 +#ifdef CONFIG_VSERVER_COWBL
4545 + if (error == -EMLINK) {
4546 + struct dentry *dentry;
4547 + dentry = cow_break_link(name->name);
4548 + if (IS_ERR(dentry))
4549 + error = PTR_ERR(dentry);
4556 file->f_path.mnt = nd->path.mnt;
4557 @@ -2929,6 +3055,7 @@ static struct file *path_openat(int dfd,
4562 file = get_empty_filp();
4565 @@ -2965,6 +3092,16 @@ static struct file *path_openat(int dfd,
4566 error = do_last(nd, &path, file, op, &opened, pathname);
4567 put_link(nd, &link, cookie);
4570 +#ifdef CONFIG_VSERVER_COWBL
4571 + if (error == -EMLINK) {
4572 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4573 + path_put(&nd->root);
4580 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4581 path_put(&nd->root);
4582 @@ -3079,6 +3216,11 @@ struct dentry *kern_path_create(int dfd,
4586 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
4587 + path->dentry, path->dentry->d_name.len,
4588 + path->dentry->d_name.name, dentry,
4589 + dentry->d_name.len, dentry->d_name.name,
4590 + path->dentry->d_inode);
4594 @@ -3573,7 +3715,7 @@ int vfs_link(struct dentry *old_dentry,
4596 * A link to an append-only or immutable file cannot be created.
4598 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4599 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4601 if (!dir->i_op->link)
4603 @@ -3976,6 +4118,286 @@ int vfs_follow_link(struct nameidata *nd
4604 return __vfs_follow_link(nd, link);
4608 +#ifdef CONFIG_VSERVER_COWBL
4611 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4615 + return do_splice_direct(in, &ppos, out, len, 0);
4618 +struct dentry *cow_break_link(const char *pathname)
4620 + int ret, mode, pathlen, redo = 0, drop = 1;
4621 + struct nameidata old_nd, dir_nd;
4622 + struct path dir_path, *old_path, *new_path;
4623 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4624 + struct file *old_file;
4625 + struct file *new_file;
4626 + char *to, *path, pad='\251';
4629 + vxdprintk(VXD_CBIT(misc, 1),
4630 + "cow_break_link(" VS_Q("%s") ")", pathname);
4632 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4637 + /* old_nd.path will have refs to dentry and mnt */
4638 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4639 + vxdprintk(VXD_CBIT(misc, 2),
4640 + "do_path_lookup(old): %d", ret);
4642 + goto out_free_path;
4644 + /* dentry/mnt refs handed over to old_path */
4645 + old_path = &old_nd.path;
4646 + /* no explicit reference for old_dentry here */
4647 + old_dentry = old_path->dentry;
4649 + mode = old_dentry->d_inode->i_mode;
4650 + to = d_path(old_path, path, PATH_MAX-2);
4651 + pathlen = strlen(to);
4652 + vxdprintk(VXD_CBIT(misc, 2),
4653 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4655 + old_dentry->d_name.len, old_dentry->d_name.name,
4656 + old_dentry->d_name.len);
4658 + to[pathlen + 1] = 0;
4660 + new_dentry = NULL;
4661 + to[pathlen] = pad--;
4663 + if (pad <= '\240')
4666 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4668 + /* dir_nd.path will have refs to dentry and mnt */
4669 + ret = do_path_lookup(AT_FDCWD, to,
4670 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4671 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4675 + /* this puppy downs the dir inode mutex if successful.
4676 + dir_path will hold refs to dentry and mnt and
4677 + we'll have write access to the mnt */
4678 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
4679 + if (!new_dentry || IS_ERR(new_dentry)) {
4680 + path_put(&dir_nd.path);
4681 + vxdprintk(VXD_CBIT(misc, 2),
4682 + "kern_path_create(new) failed with %ld",
4683 + PTR_ERR(new_dentry));
4686 + vxdprintk(VXD_CBIT(misc, 2),
4687 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
4689 + new_dentry->d_name.len, new_dentry->d_name.name,
4690 + new_dentry->d_name.len);
4692 + /* take a reference on new_dentry */
4695 + /* dentry/mnt refs handed over to new_path */
4696 + new_path = &dir_path;
4698 + /* dentry for old/new dir */
4699 + dir = dir_nd.path.dentry;
4701 + /* give up reference on dir */
4702 + dput(new_path->dentry);
4704 + /* new_dentry already has a reference */
4705 + new_path->dentry = new_dentry;
4707 + ret = vfs_create(dir->d_inode, new_dentry, mode, 1);
4708 + vxdprintk(VXD_CBIT(misc, 2),
4709 + "vfs_create(new): %d", ret);
4710 + if (ret == -EEXIST) {
4711 + path_put(&dir_nd.path);
4712 + mutex_unlock(&dir->d_inode->i_mutex);
4713 + mnt_drop_write(new_path->mnt);
4714 + path_put(new_path);
4715 + new_dentry = NULL;
4719 + goto out_unlock_new;
4721 + /* drop out early, ret passes ENOENT */
4723 + if ((redo = d_unhashed(old_dentry)))
4724 + goto out_unlock_new;
4726 + /* doesn't change refs for old_path */
4727 + old_file = dentry_open(old_path, O_RDONLY, current_cred());
4728 + vxdprintk(VXD_CBIT(misc, 2),
4729 + "dentry_open(old): %p", old_file);
4730 + if (IS_ERR(old_file)) {
4731 + ret = PTR_ERR(old_file);
4732 + goto out_unlock_new;
4735 + /* doesn't change refs for new_path */
4736 + new_file = dentry_open(new_path, O_WRONLY, current_cred());
4737 + vxdprintk(VXD_CBIT(misc, 2),
4738 + "dentry_open(new): %p", new_file);
4739 + if (IS_ERR(new_file)) {
4740 + ret = PTR_ERR(new_file);
4741 + goto out_fput_old;
4744 + /* unlock the inode mutex from kern_path_create() */
4745 + mutex_unlock(&dir->d_inode->i_mutex);
4747 + /* drop write access to mnt */
4748 + mnt_drop_write(new_path->mnt);
4752 + size = i_size_read(old_file->f_dentry->d_inode);
4753 + ret = do_cow_splice(old_file, new_file, size);
4754 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4756 + goto out_fput_both;
4757 + } else if (ret < size) {
4759 + goto out_fput_both;
4761 + struct inode *old_inode = old_dentry->d_inode;
4762 + struct inode *new_inode = new_dentry->d_inode;
4763 + struct iattr attr = {
4764 + .ia_uid = old_inode->i_uid,
4765 + .ia_gid = old_inode->i_gid,
4766 + .ia_valid = ATTR_UID | ATTR_GID
4769 + setattr_copy(new_inode, &attr);
4770 + mark_inode_dirty(new_inode);
4773 + /* lock rename mutex */
4774 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4776 + /* drop out late */
4778 + if ((redo = d_unhashed(old_dentry)))
4781 + vxdprintk(VXD_CBIT(misc, 2),
4782 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4783 + new_dentry->d_name.len, new_dentry->d_name.name,
4784 + new_dentry->d_name.len,
4785 + old_dentry->d_name.len, old_dentry->d_name.name,
4786 + old_dentry->d_name.len);
4787 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4788 + old_dentry->d_parent->d_inode, old_dentry);
4789 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4792 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4795 + vxdprintk(VXD_CBIT(misc, 3),
4796 + "fput(new_file=%p[#%ld])", new_file,
4797 + atomic_long_read(&new_file->f_count));
4801 + vxdprintk(VXD_CBIT(misc, 3),
4802 + "fput(old_file=%p[#%ld])", old_file,
4803 + atomic_long_read(&old_file->f_count));
4807 + /* drop references from dir_nd.path */
4808 + path_put(&dir_nd.path);
4811 + /* unlock the inode mutex from kern_path_create() */
4812 + mutex_unlock(&dir->d_inode->i_mutex);
4814 + /* drop write access to mnt */
4815 + mnt_drop_write(new_path->mnt);
4821 + /* error path cleanup */
4822 + vfs_unlink(dir->d_inode, new_dentry);
4826 + goto out_rel_both;
4828 + /* lookup dentry once again
4829 + old_nd.path will be freed as old_path in out_rel_old */
4830 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4832 + goto out_rel_both;
4834 + /* drop reference on new_dentry */
4836 + new_dentry = old_path->dentry;
4838 + vxdprintk(VXD_CBIT(misc, 2),
4839 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4841 + new_dentry->d_name.len, new_dentry->d_name.name,
4842 + new_dentry->d_name.len);
4846 + path_put(new_path);
4848 + path_put(old_path);
4854 + new_dentry = ERR_PTR(ret);
4856 + vxdprintk(VXD_CBIT(misc, 3),
4857 + "cow_break_link returning with %p", new_dentry);
4858 + return new_dentry;
4863 +int vx_info_mnt_namespace(struct mnt_namespace *ns, char *buffer)
4866 + struct vfsmount *vmnt;
4867 + char *pstr, *root;
4870 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
4874 + vmnt = &ns->root->mnt;
4876 + path.dentry = vmnt->mnt_root;
4877 + root = d_path(&path, pstr, PATH_MAX - 2);
4878 + length = sprintf(buffer + length,
4879 + "Namespace:\t%p [#%u]\n"
4880 + "RootPath:\t%s\n",
4881 + ns, atomic_read(&ns->count),
4887 /* get the link contents into pagecache */
4888 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4890 @@ -4099,3 +4521,4 @@ EXPORT_SYMBOL(vfs_symlink);
4891 EXPORT_SYMBOL(vfs_unlink);
4892 EXPORT_SYMBOL(dentry_unhash);
4893 EXPORT_SYMBOL(generic_readlink);
4894 +EXPORT_SYMBOL(vx_info_mnt_namespace);
4895 diff -NurpP --minimal linux-3.9.4/fs/namespace.c linux-3.9.4-vs2.3.6.3/fs/namespace.c
4896 --- linux-3.9.4/fs/namespace.c 2013-05-31 14:22:27.000000000 +0000
4897 +++ linux-3.9.4-vs2.3.6.3/fs/namespace.c 2013-05-31 18:47:18.000000000 +0000
4899 #include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */
4900 #include <linux/uaccess.h>
4901 #include <linux/proc_fs.h>
4902 +#include <linux/vs_base.h>
4903 +#include <linux/vs_context.h>
4904 +#include <linux/vs_tag.h>
4905 +#include <linux/vserver/space.h>
4906 +#include <linux/vserver/global.h>
4908 #include "internal.h"
4910 @@ -751,6 +756,10 @@ vfs_kern_mount(struct file_system_type *
4912 return ERR_PTR(-ENODEV);
4914 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
4915 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
4916 + return ERR_PTR(-EPERM);
4918 mnt = alloc_vfsmnt(name);
4920 return ERR_PTR(-ENOMEM);
4921 @@ -807,6 +816,7 @@ static struct mount *clone_mnt(struct mo
4922 mnt->mnt.mnt_root = dget(root);
4923 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
4924 mnt->mnt_parent = mnt;
4925 + mnt->mnt_tag = old->mnt_tag;
4926 br_write_lock(&vfsmount_lock);
4927 list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
4928 br_write_unlock(&vfsmount_lock);
4929 @@ -1639,6 +1649,7 @@ static int do_change_type(struct path *p
4933 + // mnt->mnt_flags = mnt_flags;
4935 br_write_lock(&vfsmount_lock);
4936 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
4937 @@ -1654,12 +1665,14 @@ static int do_change_type(struct path *p
4938 * do loopback mount.
4940 static int do_loopback(struct path *path, const char *old_name,
4942 + tag_t tag, unsigned long flags, int mnt_flags)
4944 LIST_HEAD(umount_list);
4945 struct path old_path;
4946 struct mount *mnt = NULL, *old;
4947 + int recurse = flags & MS_REC;
4950 if (!old_name || !*old_name)
4952 err = kern_path(old_name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &old_path);
4953 @@ -1733,7 +1746,7 @@ static int change_mount_flags(struct vfs
4954 * on it - tough luck.
4956 static int do_remount(struct path *path, int flags, int mnt_flags,
4958 + void *data, xid_t xid)
4961 struct super_block *sb = path->mnt->mnt_sb;
4962 @@ -2046,7 +2059,6 @@ void mark_mounts_for_expiry(struct list_
4964 br_write_unlock(&vfsmount_lock);
4965 up_write(&namespace_sem);
4967 release_mounts(&umounts);
4970 @@ -2218,6 +2230,7 @@ long do_mount(const char *dev_name, cons
4977 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
4978 @@ -2247,6 +2260,12 @@ long do_mount(const char *dev_name, cons
4979 if (!(flags & MS_NOATIME))
4980 mnt_flags |= MNT_RELATIME;
4982 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
4983 + /* FIXME: bind and re-mounts get the tag flag? */
4984 + if (flags & (MS_BIND|MS_REMOUNT))
4985 + flags |= MS_TAGID;
4988 /* Separate the per-mountpoint flags */
4989 if (flags & MS_NOSUID)
4990 mnt_flags |= MNT_NOSUID;
4991 @@ -2263,15 +2282,17 @@ long do_mount(const char *dev_name, cons
4992 if (flags & MS_RDONLY)
4993 mnt_flags |= MNT_READONLY;
4995 + if (!vx_capable(CAP_SYS_ADMIN, VXC_DEV_MOUNT))
4996 + mnt_flags |= MNT_NODEV;
4997 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
4998 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5001 if (flags & MS_REMOUNT)
5002 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5005 else if (flags & MS_BIND)
5006 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5007 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5008 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5009 retval = do_change_type(&path, flags);
5010 else if (flags & MS_MOVE)
5011 @@ -2380,6 +2401,7 @@ static struct mnt_namespace *dup_mnt_ns(
5012 q = next_mnt(q, new);
5014 up_write(&namespace_sem);
5015 + atomic_inc(&vs_global_mnt_ns);
5019 @@ -2575,9 +2597,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5021 new_mnt = real_mount(new.mnt);
5022 root_mnt = real_mount(root.mnt);
5023 - if (IS_MNT_SHARED(real_mount(old.mnt)) ||
5024 + if ((IS_MNT_SHARED(real_mount(old.mnt)) ||
5025 IS_MNT_SHARED(new_mnt->mnt_parent) ||
5026 - IS_MNT_SHARED(root_mnt->mnt_parent))
5027 + IS_MNT_SHARED(root_mnt->mnt_parent)) &&
5028 + !vx_flags(VXF_STATE_SETUP, 0))
5030 if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
5032 @@ -2703,6 +2726,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5033 br_write_unlock(&vfsmount_lock);
5034 up_write(&namespace_sem);
5035 release_mounts(&umount_list);
5036 + atomic_dec(&vs_global_mnt_ns);
5040 diff -NurpP --minimal linux-3.9.4/fs/nfs/client.c linux-3.9.4-vs2.3.6.3/fs/nfs/client.c
5041 --- linux-3.9.4/fs/nfs/client.c 2013-05-31 13:45:24.000000000 +0000
5042 +++ linux-3.9.4-vs2.3.6.3/fs/nfs/client.c 2013-05-31 14:47:11.000000000 +0000
5043 @@ -682,6 +682,9 @@ int nfs_init_server_rpcclient(struct nfs
5044 if (server->flags & NFS_MOUNT_SOFT)
5045 server->client->cl_softrtry = 1;
5047 + server->client->cl_tag = 0;
5048 + if (server->flags & NFS_MOUNT_TAGGED)
5049 + server->client->cl_tag = 1;
5052 EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient);
5053 @@ -861,6 +864,10 @@ static void nfs_server_set_fsinfo(struct
5054 server->acdirmin = server->acdirmax = 0;
5057 + /* FIXME: needs fsinfo
5058 + if (server->flags & NFS_MOUNT_TAGGED)
5059 + sb->s_flags |= MS_TAGGED; */
5061 server->maxfilesize = fsinfo->maxfilesize;
5063 server->time_delta = fsinfo->time_delta;
5064 diff -NurpP --minimal linux-3.9.4/fs/nfs/dir.c linux-3.9.4-vs2.3.6.3/fs/nfs/dir.c
5065 --- linux-3.9.4/fs/nfs/dir.c 2013-05-31 13:45:24.000000000 +0000
5066 +++ linux-3.9.4-vs2.3.6.3/fs/nfs/dir.c 2013-05-31 14:47:11.000000000 +0000
5068 #include <linux/sched.h>
5069 #include <linux/kmemleak.h>
5070 #include <linux/xattr.h>
5071 +#include <linux/vs_tag.h>
5073 #include "delegation.h"
5075 @@ -1300,6 +1301,7 @@ struct dentry *nfs_lookup(struct inode *
5076 /* Success: notify readdir to use READDIRPLUS */
5077 nfs_advise_use_readdirplus(dir);
5079 + dx_propagate_tag(nd, inode);
5081 res = d_materialise_unique(dentry, inode);
5083 diff -NurpP --minimal linux-3.9.4/fs/nfs/inode.c linux-3.9.4-vs2.3.6.3/fs/nfs/inode.c
5084 --- linux-3.9.4/fs/nfs/inode.c 2013-05-31 13:45:24.000000000 +0000
5085 +++ linux-3.9.4-vs2.3.6.3/fs/nfs/inode.c 2013-06-03 19:32:53.000000000 +0000
5087 #include <linux/compat.h>
5088 #include <linux/freezer.h>
5089 #include <linux/crc32.h>
5090 +#include <linux/vs_tag.h>
5092 #include <asm/uaccess.h>
5094 @@ -290,6 +291,8 @@ nfs_fhget(struct super_block *sb, struct
5095 if (inode->i_state & I_NEW) {
5096 struct nfs_inode *nfsi = NFS_I(inode);
5097 unsigned long now = jiffies;
5101 /* We set i_ino for the few things that still rely on it,
5102 * such as stat(2) */
5103 @@ -334,8 +337,8 @@ nfs_fhget(struct super_block *sb, struct
5104 inode->i_version = 0;
5107 - inode->i_uid = make_kuid(&init_user_ns, -2);
5108 - inode->i_gid = make_kgid(&init_user_ns, -2);
5109 + kuid = make_kuid(&init_user_ns, -2);
5110 + kgid = make_kgid(&init_user_ns, -2);
5111 inode->i_blocks = 0;
5112 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5114 @@ -369,11 +372,11 @@ nfs_fhget(struct super_block *sb, struct
5115 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5116 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5117 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5118 - inode->i_uid = fattr->uid;
5119 + kuid = fattr->uid;
5120 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5121 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5122 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5123 - inode->i_gid = fattr->gid;
5124 + kgid = fattr->gid;
5125 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5126 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5127 if (fattr->valid & NFS_ATTR_FATTR_BLOCKS_USED)
5128 @@ -384,6 +387,11 @@ nfs_fhget(struct super_block *sb, struct
5130 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5132 + inode->i_uid = INOTAG_KUID(DX_TAG(inode), kuid, kgid);
5133 + inode->i_gid = INOTAG_KGID(DX_TAG(inode), kuid, kgid);
5134 + inode->i_tag = INOTAG_KTAG(DX_TAG(inode), kuid, kgid, GLOBAL_ROOT_TAG);
5135 + /* maybe fattr->xid someday */
5137 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5138 nfsi->attrtimeo_timestamp = now;
5139 nfsi->access_cache = RB_ROOT;
5140 @@ -505,6 +513,8 @@ void nfs_setattr_update_inode(struct ino
5141 inode->i_uid = attr->ia_uid;
5142 if ((attr->ia_valid & ATTR_GID) != 0)
5143 inode->i_gid = attr->ia_gid;
5144 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5145 + inode->i_tag = attr->ia_tag;
5146 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5147 spin_unlock(&inode->i_lock);
5149 @@ -980,7 +990,9 @@ static int nfs_check_inode_attributes(st
5150 struct nfs_inode *nfsi = NFS_I(inode);
5151 loff_t cur_size, new_isize;
5152 unsigned long invalid = 0;
5158 if (nfs_have_delegated_attributes(inode))
5160 @@ -1005,13 +1017,18 @@ static int nfs_check_inode_attributes(st
5161 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5164 + kuid = INOTAG_KUID(DX_TAG(inode), fattr->uid, fattr->gid);
5165 + kgid = INOTAG_KGID(DX_TAG(inode), fattr->uid, fattr->gid);
5166 + ktag = INOTAG_KTAG(DX_TAG(inode), fattr->uid, fattr->gid, GLOBAL_ROOT_TAG);
5168 /* Have any file permissions changed? */
5169 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5170 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5171 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && !uid_eq(inode->i_uid, fattr->uid))
5172 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && !uid_eq(inode->i_uid, kuid))
5173 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5174 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && !gid_eq(inode->i_gid, fattr->gid))
5175 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && !gid_eq(inode->i_gid, kgid))
5176 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5177 + /* maybe check for tag too? */
5179 /* Has the link count changed? */
5180 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5181 @@ -1317,6 +1334,9 @@ static int nfs_update_inode(struct inode
5182 unsigned long invalid = 0;
5183 unsigned long now = jiffies;
5184 unsigned long save_cache_validity;
5189 dfprintk(VFS, "NFS: %s(%s/%ld fh_crc=0x%08x ct=%d info=0x%x)\n",
5190 __func__, inode->i_sb->s_id, inode->i_ino,
5191 @@ -1418,6 +1438,9 @@ static int nfs_update_inode(struct inode
5192 | NFS_INO_REVAL_PAGECACHE
5193 | NFS_INO_REVAL_FORCED);
5195 + kuid = TAGINO_KUID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5196 + kgid = TAGINO_KGID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5197 + ktag = TAGINO_KTAG(DX_TAG(inode), inode->i_tag);
5199 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5200 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5201 @@ -1460,6 +1483,10 @@ static int nfs_update_inode(struct inode
5202 | NFS_INO_INVALID_ACL
5203 | NFS_INO_REVAL_FORCED);
5205 + inode->i_uid = INOTAG_KUID(DX_TAG(inode), kuid, kgid);
5206 + inode->i_gid = INOTAG_KGID(DX_TAG(inode), kuid, kgid);
5207 + inode->i_tag = INOTAG_KTAG(DX_TAG(inode), kuid, kgid, ktag);
5209 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5210 if (inode->i_nlink != fattr->nlink) {
5211 invalid |= NFS_INO_INVALID_ATTR;
5212 diff -NurpP --minimal linux-3.9.4/fs/nfs/nfs3xdr.c linux-3.9.4-vs2.3.6.3/fs/nfs/nfs3xdr.c
5213 --- linux-3.9.4/fs/nfs/nfs3xdr.c 2013-05-31 13:45:24.000000000 +0000
5214 +++ linux-3.9.4-vs2.3.6.3/fs/nfs/nfs3xdr.c 2013-06-03 19:33:10.000000000 +0000
5216 #include <linux/nfs3.h>
5217 #include <linux/nfs_fs.h>
5218 #include <linux/nfsacl.h>
5219 +#include <linux/vs_tag.h>
5220 #include "internal.h"
5222 #define NFSDBG_FACILITY NFSDBG_XDR
5223 @@ -558,7 +559,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5227 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5228 +static void encode_sattr3(struct xdr_stream *xdr,
5229 + const struct iattr *attr, int tag)
5233 @@ -590,15 +592,19 @@ static void encode_sattr3(struct xdr_str
5237 - if (attr->ia_valid & ATTR_UID) {
5238 + if (attr->ia_valid & ATTR_UID ||
5239 + (tag && (attr->ia_valid & ATTR_TAG))) {
5241 - *p++ = cpu_to_be32(from_kuid(&init_user_ns, attr->ia_uid));
5242 + *p++ = cpu_to_be32(from_kuid(&init_user_ns,
5243 + TAGINO_KUID(tag, attr->ia_uid, attr->ia_tag)));
5247 - if (attr->ia_valid & ATTR_GID) {
5248 + if (attr->ia_valid & ATTR_GID ||
5249 + (tag && (attr->ia_valid & ATTR_TAG))) {
5251 - *p++ = cpu_to_be32(from_kgid(&init_user_ns, attr->ia_gid));
5252 + *p++ = cpu_to_be32(from_kgid(&init_user_ns,
5253 + TAGINO_KGID(tag, attr->ia_gid, attr->ia_tag)));
5257 @@ -887,7 +893,7 @@ static void nfs3_xdr_enc_setattr3args(st
5258 const struct nfs3_sattrargs *args)
5260 encode_nfs_fh3(xdr, args->fh);
5261 - encode_sattr3(xdr, args->sattr);
5262 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5263 encode_sattrguard3(xdr, args);
5266 @@ -1037,13 +1043,13 @@ static void nfs3_xdr_enc_write3args(stru
5269 static void encode_createhow3(struct xdr_stream *xdr,
5270 - const struct nfs3_createargs *args)
5271 + const struct nfs3_createargs *args, int tag)
5273 encode_uint32(xdr, args->createmode);
5274 switch (args->createmode) {
5275 case NFS3_CREATE_UNCHECKED:
5276 case NFS3_CREATE_GUARDED:
5277 - encode_sattr3(xdr, args->sattr);
5278 + encode_sattr3(xdr, args->sattr, tag);
5280 case NFS3_CREATE_EXCLUSIVE:
5281 encode_createverf3(xdr, args->verifier);
5282 @@ -1058,7 +1064,7 @@ static void nfs3_xdr_enc_create3args(str
5283 const struct nfs3_createargs *args)
5285 encode_diropargs3(xdr, args->fh, args->name, args->len);
5286 - encode_createhow3(xdr, args);
5287 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5291 @@ -1074,7 +1080,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5292 const struct nfs3_mkdirargs *args)
5294 encode_diropargs3(xdr, args->fh, args->name, args->len);
5295 - encode_sattr3(xdr, args->sattr);
5296 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5300 @@ -1091,9 +1097,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5303 static void encode_symlinkdata3(struct xdr_stream *xdr,
5304 - const struct nfs3_symlinkargs *args)
5305 + const struct nfs3_symlinkargs *args, int tag)
5307 - encode_sattr3(xdr, args->sattr);
5308 + encode_sattr3(xdr, args->sattr, tag);
5309 encode_nfspath3(xdr, args->pages, args->pathlen);
5312 @@ -1102,7 +1108,7 @@ static void nfs3_xdr_enc_symlink3args(st
5313 const struct nfs3_symlinkargs *args)
5315 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5316 - encode_symlinkdata3(xdr, args);
5317 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5321 @@ -1130,24 +1136,24 @@ static void nfs3_xdr_enc_symlink3args(st
5324 static void encode_devicedata3(struct xdr_stream *xdr,
5325 - const struct nfs3_mknodargs *args)
5326 + const struct nfs3_mknodargs *args, int tag)
5328 - encode_sattr3(xdr, args->sattr);
5329 + encode_sattr3(xdr, args->sattr, tag);
5330 encode_specdata3(xdr, args->rdev);
5333 static void encode_mknoddata3(struct xdr_stream *xdr,
5334 - const struct nfs3_mknodargs *args)
5335 + const struct nfs3_mknodargs *args, int tag)
5337 encode_ftype3(xdr, args->type);
5338 switch (args->type) {
5341 - encode_devicedata3(xdr, args);
5342 + encode_devicedata3(xdr, args, tag);
5346 - encode_sattr3(xdr, args->sattr);
5347 + encode_sattr3(xdr, args->sattr, tag);
5351 @@ -1162,7 +1168,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5352 const struct nfs3_mknodargs *args)
5354 encode_diropargs3(xdr, args->fh, args->name, args->len);
5355 - encode_mknoddata3(xdr, args);
5356 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5360 diff -NurpP --minimal linux-3.9.4/fs/nfs/super.c linux-3.9.4-vs2.3.6.3/fs/nfs/super.c
5361 --- linux-3.9.4/fs/nfs/super.c 2013-05-31 13:45:24.000000000 +0000
5362 +++ linux-3.9.4-vs2.3.6.3/fs/nfs/super.c 2013-05-31 15:41:34.000000000 +0000
5364 #include <linux/parser.h>
5365 #include <linux/nsproxy.h>
5366 #include <linux/rcupdate.h>
5367 +#include <linux/vs_tag.h>
5369 #include <asm/uaccess.h>
5371 @@ -103,6 +104,7 @@ enum {
5377 /* Mount options that take string arguments */
5379 @@ -115,6 +117,9 @@ enum {
5380 /* Special mount options */
5381 Opt_userspace, Opt_deprecated, Opt_sloppy,
5383 + /* Linux-VServer tagging options */
5384 + Opt_tag, Opt_notag,
5389 @@ -184,6 +189,10 @@ static const match_table_t nfs_mount_opt
5390 { Opt_fscache_uniq, "fsc=%s" },
5391 { Opt_local_lock, "local_lock=%s" },
5393 + { Opt_tag, "tag" },
5394 + { Opt_notag, "notag" },
5395 + { Opt_tagid, "tagid=%u" },
5397 /* The following needs to be listed after all other options */
5398 { Opt_nfsvers, "v%s" },
5400 @@ -635,6 +644,7 @@ static void nfs_show_mount_options(struc
5401 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5402 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5403 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5404 + { NFS_MOUNT_TAGGED, ",tag", "" },
5407 const struct proc_nfs_info *nfs_infop;
5408 @@ -1261,6 +1271,14 @@ static int nfs_parse_mount_options(char
5409 case Opt_nomigration:
5410 mnt->options &= NFS_OPTION_MIGRATION;
5412 +#ifndef CONFIG_TAGGING_NONE
5414 + mnt->flags |= NFS_MOUNT_TAGGED;
5417 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5422 * options that take numeric values
5423 @@ -1347,6 +1365,12 @@ static int nfs_parse_mount_options(char
5424 goto out_invalid_value;
5425 mnt->minorversion = option;
5427 +#ifdef CONFIG_PROPAGATE
5430 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5435 * options that take text values
5436 diff -NurpP --minimal linux-3.9.4/fs/nfsd/auth.c linux-3.9.4-vs2.3.6.3/fs/nfsd/auth.c
5437 --- linux-3.9.4/fs/nfsd/auth.c 2013-05-31 13:45:24.000000000 +0000
5438 +++ linux-3.9.4-vs2.3.6.3/fs/nfsd/auth.c 2013-05-31 14:47:11.000000000 +0000
5441 #include <linux/sched.h>
5442 #include <linux/user_namespace.h>
5443 +#include <linux/vs_tag.h>
5447 @@ -37,6 +38,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5449 new->fsuid = rqstp->rq_cred.cr_uid;
5450 new->fsgid = rqstp->rq_cred.cr_gid;
5451 + /* FIXME: this desperately needs a tag :)
5452 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5455 rqgi = rqstp->rq_cred.cr_group_info;
5457 diff -NurpP --minimal linux-3.9.4/fs/nfsd/nfs3xdr.c linux-3.9.4-vs2.3.6.3/fs/nfsd/nfs3xdr.c
5458 --- linux-3.9.4/fs/nfsd/nfs3xdr.c 2013-05-31 13:45:24.000000000 +0000
5459 +++ linux-3.9.4-vs2.3.6.3/fs/nfsd/nfs3xdr.c 2013-06-03 19:57:43.000000000 +0000
5462 #include <linux/namei.h>
5463 #include <linux/sunrpc/svc_xprt.h>
5464 +#include <linux/vs_tag.h>
5468 @@ -98,6 +99,8 @@ static __be32 *
5469 decode_sattr3(__be32 *p, struct iattr *iap)
5472 + kuid_t kuid = GLOBAL_ROOT_UID;
5473 + kgid_t kgid = GLOBAL_ROOT_GID;
5477 @@ -106,15 +109,18 @@ decode_sattr3(__be32 *p, struct iattr *i
5478 iap->ia_mode = ntohl(*p++);
5481 - iap->ia_uid = make_kuid(&init_user_ns, ntohl(*p++));
5482 + kuid = make_kuid(&init_user_ns, ntohl(*p++));
5483 if (uid_valid(iap->ia_uid))
5484 iap->ia_valid |= ATTR_UID;
5487 - iap->ia_gid = make_kgid(&init_user_ns, ntohl(*p++));
5488 + kgid = make_kgid(&init_user_ns, ntohl(*p++));
5489 if (gid_valid(iap->ia_gid))
5490 iap->ia_valid |= ATTR_GID;
5492 + iap->ia_uid = INOTAG_KUID(DX_TAG_NFSD, kuid, kgid);
5493 + iap->ia_gid = INOTAG_KGID(DX_TAG_NFSD, kuid, kgid);
5494 + iap->ia_tag = INOTAG_KTAG(DX_TAG_NFSD, kuid, kgid, GLOBAL_ROOT_TAG);
5498 @@ -170,8 +176,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5499 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5500 *p++ = htonl((u32) stat->mode);
5501 *p++ = htonl((u32) stat->nlink);
5502 - *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
5503 - *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
5504 + *p++ = htonl((u32) from_kuid(&init_user_ns,
5505 + TAGINO_KUID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5506 + stat->uid, stat->tag)));
5507 + *p++ = htonl((u32) from_kgid(&init_user_ns,
5508 + TAGINO_KGID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5509 + stat->gid, stat->tag)));
5510 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5511 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5513 diff -NurpP --minimal linux-3.9.4/fs/nfsd/nfs4xdr.c linux-3.9.4-vs2.3.6.3/fs/nfsd/nfs4xdr.c
5514 --- linux-3.9.4/fs/nfsd/nfs4xdr.c 2013-05-31 14:22:27.000000000 +0000
5515 +++ linux-3.9.4-vs2.3.6.3/fs/nfsd/nfs4xdr.c 2013-06-03 19:33:44.000000000 +0000
5517 #include <linux/utsname.h>
5518 #include <linux/pagemap.h>
5519 #include <linux/sunrpc/svcauth_gss.h>
5520 +#include <linux/vs_tag.h>
5524 @@ -2349,14 +2350,18 @@ out_acl:
5525 WRITE32(stat.nlink);
5527 if (bmval1 & FATTR4_WORD1_OWNER) {
5528 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5529 + status = nfsd4_encode_user(rqstp,
5530 + TAGINO_KUID(DX_TAG(dentry->d_inode),
5531 + stat.uid, stat.tag), &p, &buflen);
5532 if (status == nfserr_resource)
5537 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5538 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5539 + status = nfsd4_encode_group(rqstp,
5540 + TAGINO_KGID(DX_TAG(dentry->d_inode),
5541 + stat.gid, stat.tag), &p, &buflen);
5542 if (status == nfserr_resource)
5545 diff -NurpP --minimal linux-3.9.4/fs/nfsd/nfsxdr.c linux-3.9.4-vs2.3.6.3/fs/nfsd/nfsxdr.c
5546 --- linux-3.9.4/fs/nfsd/nfsxdr.c 2013-05-31 13:45:24.000000000 +0000
5547 +++ linux-3.9.4-vs2.3.6.3/fs/nfsd/nfsxdr.c 2013-06-03 19:56:35.000000000 +0000
5552 +#include <linux/vs_tag.h>
5554 #define NFSDDBG_FACILITY NFSDDBG_XDR
5556 @@ -89,6 +90,8 @@ static __be32 *
5557 decode_sattr(__be32 *p, struct iattr *iap)
5560 + kuid_t kuid = GLOBAL_ROOT_UID;
5561 + kgid_t kgid = GLOBAL_ROOT_GID;
5565 @@ -101,15 +104,18 @@ decode_sattr(__be32 *p, struct iattr *ia
5568 if ((tmp = ntohl(*p++)) != (u32)-1) {
5569 - iap->ia_uid = make_kuid(&init_user_ns, tmp);
5570 + kuid = make_kuid(&init_user_ns, tmp);
5571 if (uid_valid(iap->ia_uid))
5572 iap->ia_valid |= ATTR_UID;
5574 if ((tmp = ntohl(*p++)) != (u32)-1) {
5575 - iap->ia_gid = make_kgid(&init_user_ns, tmp);
5576 + kgid = make_kgid(&init_user_ns, tmp);
5577 if (gid_valid(iap->ia_gid))
5578 iap->ia_valid |= ATTR_GID;
5580 + iap->ia_uid = INOTAG_KUID(DX_TAG_NFSD, kuid, kgid);
5581 + iap->ia_gid = INOTAG_KGID(DX_TAG_NFSD, kuid, kgid);
5582 + iap->ia_tag = INOTAG_KTAG(DX_TAG_NFSD, kuid, kgid, GLOBAL_ROOT_TAG);
5583 if ((tmp = ntohl(*p++)) != (u32)-1) {
5584 iap->ia_valid |= ATTR_SIZE;
5586 @@ -154,8 +160,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5587 *p++ = htonl(nfs_ftypes[type >> 12]);
5588 *p++ = htonl((u32) stat->mode);
5589 *p++ = htonl((u32) stat->nlink);
5590 - *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
5591 - *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
5592 + *p++ = htonl((u32) from_kuid(&init_user_ns,
5593 + TAGINO_KUID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5594 + *p++ = htonl((u32) from_kgid(&init_user_ns,
5595 + TAGINO_KGID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5597 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5598 *p++ = htonl(NFS_MAXPATHLEN);
5599 diff -NurpP --minimal linux-3.9.4/fs/ocfs2/dlmglue.c linux-3.9.4-vs2.3.6.3/fs/ocfs2/dlmglue.c
5600 --- linux-3.9.4/fs/ocfs2/dlmglue.c 2013-05-31 13:45:24.000000000 +0000
5601 +++ linux-3.9.4-vs2.3.6.3/fs/ocfs2/dlmglue.c 2013-06-03 19:59:20.000000000 +0000
5602 @@ -2047,6 +2047,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5603 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5604 lvb->lvb_iuid = cpu_to_be32(i_uid_read(inode));
5605 lvb->lvb_igid = cpu_to_be32(i_gid_read(inode));
5606 + lvb->lvb_itag = cpu_to_be16(i_tag_read(inode));
5607 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5608 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5609 lvb->lvb_iatime_packed =
5610 @@ -2097,6 +2098,7 @@ static void ocfs2_refresh_inode_from_lvb
5612 i_uid_write(inode, be32_to_cpu(lvb->lvb_iuid));
5613 i_gid_write(inode, be32_to_cpu(lvb->lvb_igid));
5614 + i_tag_write(inode, be16_to_cpu(lvb->lvb_itag));
5615 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5616 set_nlink(inode, be16_to_cpu(lvb->lvb_inlink));
5617 ocfs2_unpack_timespec(&inode->i_atime,
5618 diff -NurpP --minimal linux-3.9.4/fs/ocfs2/dlmglue.h linux-3.9.4-vs2.3.6.3/fs/ocfs2/dlmglue.h
5619 --- linux-3.9.4/fs/ocfs2/dlmglue.h 2012-12-11 03:30:57.000000000 +0000
5620 +++ linux-3.9.4-vs2.3.6.3/fs/ocfs2/dlmglue.h 2013-05-31 14:47:11.000000000 +0000
5621 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5624 __be32 lvb_igeneration;
5625 - __be32 lvb_reserved2;
5627 + __be16 lvb_reserved2;
5630 #define OCFS2_QINFO_LVB_VERSION 1
5631 diff -NurpP --minimal linux-3.9.4/fs/ocfs2/file.c linux-3.9.4-vs2.3.6.3/fs/ocfs2/file.c
5632 --- linux-3.9.4/fs/ocfs2/file.c 2013-05-31 13:45:24.000000000 +0000
5633 +++ linux-3.9.4-vs2.3.6.3/fs/ocfs2/file.c 2013-05-31 14:47:11.000000000 +0000
5634 @@ -1124,7 +1124,7 @@ int ocfs2_setattr(struct dentry *dentry,
5635 attr->ia_valid &= ~ATTR_SIZE;
5637 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5638 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5639 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5640 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5643 diff -NurpP --minimal linux-3.9.4/fs/ocfs2/inode.c linux-3.9.4-vs2.3.6.3/fs/ocfs2/inode.c
5644 --- linux-3.9.4/fs/ocfs2/inode.c 2013-05-31 13:45:24.000000000 +0000
5645 +++ linux-3.9.4-vs2.3.6.3/fs/ocfs2/inode.c 2013-05-31 20:39:47.000000000 +0000
5647 #include <linux/highmem.h>
5648 #include <linux/pagemap.h>
5649 #include <linux/quotaops.h>
5650 +#include <linux/vs_tag.h>
5652 #include <asm/byteorder.h>
5654 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5656 unsigned int flags = OCFS2_I(inode)->ip_attr;
5658 - inode->i_flags &= ~(S_IMMUTABLE |
5659 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5660 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5662 if (flags & OCFS2_IMMUTABLE_FL)
5663 inode->i_flags |= S_IMMUTABLE;
5664 + if (flags & OCFS2_IXUNLINK_FL)
5665 + inode->i_flags |= S_IXUNLINK;
5667 if (flags & OCFS2_SYNC_FL)
5668 inode->i_flags |= S_SYNC;
5669 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5670 inode->i_flags |= S_NOATIME;
5671 if (flags & OCFS2_DIRSYNC_FL)
5672 inode->i_flags |= S_DIRSYNC;
5674 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5676 + if (flags & OCFS2_BARRIER_FL)
5677 + inode->i_vflags |= V_BARRIER;
5678 + if (flags & OCFS2_COW_FL)
5679 + inode->i_vflags |= V_COW;
5682 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5683 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5685 unsigned int flags = oi->vfs_inode.i_flags;
5686 + unsigned int vflags = oi->vfs_inode.i_vflags;
5688 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5689 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5690 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5691 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5693 + if (flags & S_IMMUTABLE)
5694 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5695 + if (flags & S_IXUNLINK)
5696 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5698 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5699 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5701 oi->ip_attr |= OCFS2_SYNC_FL;
5702 if (flags & S_APPEND)
5703 oi->ip_attr |= OCFS2_APPEND_FL;
5704 - if (flags & S_IMMUTABLE)
5705 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5706 if (flags & S_NOATIME)
5707 oi->ip_attr |= OCFS2_NOATIME_FL;
5708 if (flags & S_DIRSYNC)
5709 oi->ip_attr |= OCFS2_DIRSYNC_FL;
5711 + if (vflags & V_BARRIER)
5712 + oi->ip_attr |= OCFS2_BARRIER_FL;
5713 + if (vflags & V_COW)
5714 + oi->ip_attr |= OCFS2_COW_FL;
5717 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
5718 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
5719 struct super_block *sb;
5720 struct ocfs2_super *osb;
5727 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
5728 inode->i_generation = le32_to_cpu(fe->i_generation);
5729 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
5730 inode->i_mode = le16_to_cpu(fe->i_mode);
5731 - i_uid_write(inode, le32_to_cpu(fe->i_uid));
5732 - i_gid_write(inode, le32_to_cpu(fe->i_gid));
5733 + uid = le32_to_cpu(fe->i_uid);
5734 + gid = le32_to_cpu(fe->i_gid);
5735 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), uid, gid));
5736 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), uid, gid));
5737 + i_tag_write(inode, INOTAG_TAG(DX_TAG(inode), uid, gid,
5738 + /* le16_to_cpu(raw_inode->i_raw_tag) */ 0));
5740 /* Fast symlinks will have i_size but no allocated clusters. */
5741 if (S_ISLNK(inode->i_mode) && !fe->i_clusters) {
5742 diff -NurpP --minimal linux-3.9.4/fs/ocfs2/inode.h linux-3.9.4-vs2.3.6.3/fs/ocfs2/inode.h
5743 --- linux-3.9.4/fs/ocfs2/inode.h 2012-12-11 03:30:57.000000000 +0000
5744 +++ linux-3.9.4-vs2.3.6.3/fs/ocfs2/inode.h 2013-05-31 14:47:11.000000000 +0000
5745 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
5747 void ocfs2_set_inode_flags(struct inode *inode);
5748 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
5749 +int ocfs2_sync_flags(struct inode *inode, int, int);
5751 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
5753 diff -NurpP --minimal linux-3.9.4/fs/ocfs2/ioctl.c linux-3.9.4-vs2.3.6.3/fs/ocfs2/ioctl.c
5754 --- linux-3.9.4/fs/ocfs2/ioctl.c 2013-05-31 13:45:24.000000000 +0000
5755 +++ linux-3.9.4-vs2.3.6.3/fs/ocfs2/ioctl.c 2013-05-31 14:47:11.000000000 +0000
5756 @@ -76,7 +76,41 @@ static int ocfs2_get_inode_attr(struct i
5760 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5761 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
5763 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5764 + struct buffer_head *bh = NULL;
5765 + handle_t *handle = NULL;
5768 + status = ocfs2_inode_lock(inode, &bh, 1);
5770 + mlog_errno(status);
5773 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5774 + if (IS_ERR(handle)) {
5775 + status = PTR_ERR(handle);
5776 + mlog_errno(status);
5780 + inode->i_flags = flags;
5781 + inode->i_vflags = vflags;
5782 + ocfs2_get_inode_flags(OCFS2_I(inode));
5784 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
5786 + mlog_errno(status);
5788 + ocfs2_commit_trans(osb, handle);
5790 + ocfs2_inode_unlock(inode, 1);
5795 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5798 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
5799 @@ -101,6 +135,11 @@ static int ocfs2_set_inode_attr(struct i
5800 if (!S_ISDIR(inode->i_mode))
5801 flags &= ~OCFS2_DIRSYNC_FL;
5803 + if (IS_BARRIER(inode)) {
5804 + vxwprintk_task(1, "messing with the barrier.");
5808 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5809 if (IS_ERR(handle)) {
5810 status = PTR_ERR(handle);
5811 @@ -879,6 +918,7 @@ bail:
5816 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5818 struct inode *inode = file_inode(filp);
5819 diff -NurpP --minimal linux-3.9.4/fs/ocfs2/namei.c linux-3.9.4-vs2.3.6.3/fs/ocfs2/namei.c
5820 --- linux-3.9.4/fs/ocfs2/namei.c 2013-05-31 13:45:24.000000000 +0000
5821 +++ linux-3.9.4-vs2.3.6.3/fs/ocfs2/namei.c 2013-06-03 20:00:35.000000000 +0000
5823 #include <linux/slab.h>
5824 #include <linux/highmem.h>
5825 #include <linux/quotaops.h>
5826 +#include <linux/vs_tag.h>
5828 #include <cluster/masklog.h>
5830 @@ -475,6 +476,7 @@ static int __ocfs2_mknod_locked(struct i
5831 struct ocfs2_dinode *fe = NULL;
5832 struct ocfs2_extent_list *fel;
5838 @@ -512,8 +514,13 @@ static int __ocfs2_mknod_locked(struct i
5839 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
5840 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
5841 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
5842 - fe->i_uid = cpu_to_le32(i_uid_read(inode));
5843 - fe->i_gid = cpu_to_le32(i_gid_read(inode));
5845 + ktag = make_ktag(&init_user_ns, dx_current_fstag(osb->sb));
5846 + fe->i_uid = cpu_to_le32(from_kuid(&init_user_ns,
5847 + TAGINO_KUID(DX_TAG(inode), inode->i_uid, ktag)));
5848 + fe->i_gid = cpu_to_le32(from_kgid(&init_user_ns,
5849 + TAGINO_KGID(DX_TAG(inode), inode->i_gid, ktag)));
5850 + inode->i_tag = ktag; /* is this correct? */
5851 fe->i_mode = cpu_to_le16(inode->i_mode);
5852 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
5853 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
5854 diff -NurpP --minimal linux-3.9.4/fs/ocfs2/ocfs2.h linux-3.9.4-vs2.3.6.3/fs/ocfs2/ocfs2.h
5855 --- linux-3.9.4/fs/ocfs2/ocfs2.h 2012-12-11 03:30:57.000000000 +0000
5856 +++ linux-3.9.4-vs2.3.6.3/fs/ocfs2/ocfs2.h 2013-05-31 14:47:11.000000000 +0000
5857 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
5859 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
5860 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
5861 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
5864 #define OCFS2_OSB_SOFT_RO 0x0001
5865 diff -NurpP --minimal linux-3.9.4/fs/ocfs2/ocfs2_fs.h linux-3.9.4-vs2.3.6.3/fs/ocfs2/ocfs2_fs.h
5866 --- linux-3.9.4/fs/ocfs2/ocfs2_fs.h 2012-12-11 03:30:57.000000000 +0000
5867 +++ linux-3.9.4-vs2.3.6.3/fs/ocfs2/ocfs2_fs.h 2013-05-31 14:47:11.000000000 +0000
5868 @@ -266,6 +266,11 @@
5869 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
5870 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
5872 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
5874 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
5875 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
5877 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
5878 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
5880 diff -NurpP --minimal linux-3.9.4/fs/ocfs2/super.c linux-3.9.4-vs2.3.6.3/fs/ocfs2/super.c
5881 --- linux-3.9.4/fs/ocfs2/super.c 2013-05-31 13:45:25.000000000 +0000
5882 +++ linux-3.9.4-vs2.3.6.3/fs/ocfs2/super.c 2013-05-31 14:47:11.000000000 +0000
5883 @@ -185,6 +185,7 @@ enum {
5887 + Opt_tag, Opt_notag, Opt_tagid,
5891 @@ -216,6 +217,9 @@ static const match_table_t tokens = {
5892 {Opt_coherency_full, "coherency=full"},
5893 {Opt_resv_level, "resv_level=%u"},
5894 {Opt_dir_resv_level, "dir_resv_level=%u"},
5896 + {Opt_notag, "notag"},
5897 + {Opt_tagid, "tagid=%u"},
5901 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
5905 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
5906 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
5908 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
5912 /* We're going to/from readonly mode. */
5913 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
5914 /* Disable quota accounting before remounting RO */
5915 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
5917 ocfs2_complete_mount_recovery(osb);
5919 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
5920 + sb->s_flags |= MS_TAGGED;
5922 if (ocfs2_mount_local(osb))
5923 snprintf(nodestr, sizeof(nodestr), "local");
5925 @@ -1504,6 +1518,20 @@ static int ocfs2_parse_options(struct su
5926 option < OCFS2_MAX_RESV_LEVEL)
5927 mopt->dir_resv_level = option;
5929 +#ifndef CONFIG_TAGGING_NONE
5931 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
5934 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
5937 +#ifdef CONFIG_PROPAGATE
5940 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
5945 "Unrecognized mount option \"%s\" "
5946 diff -NurpP --minimal linux-3.9.4/fs/open.c linux-3.9.4-vs2.3.6.3/fs/open.c
5947 --- linux-3.9.4/fs/open.c 2013-05-31 13:45:25.000000000 +0000
5948 +++ linux-3.9.4-vs2.3.6.3/fs/open.c 2013-06-01 08:41:29.000000000 +0000
5950 #include <linux/ima.h>
5951 #include <linux/dnotify.h>
5952 #include <linux/compat.h>
5953 +#include <linux/vs_base.h>
5954 +#include <linux/vs_limit.h>
5955 +#include <linux/vs_tag.h>
5956 +#include <linux/vs_cowbl.h>
5957 +#include <linux/vserver/dlimit.h>
5959 #include "internal.h"
5961 @@ -67,6 +72,11 @@ long vfs_truncate(struct path *path, lof
5962 struct inode *inode;
5965 +#ifdef CONFIG_VSERVER_COWBL
5966 + error = cow_check_and_break(path);
5970 inode = path->dentry->d_inode;
5972 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
5973 @@ -532,6 +542,13 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
5974 unsigned int lookup_flags = LOOKUP_FOLLOW;
5976 error = user_path_at(dfd, filename, lookup_flags, &path);
5977 +#ifdef CONFIG_VSERVER_COWBL
5979 + error = cow_check_and_break(&path);
5985 error = chmod_common(&path, mode);
5987 @@ -564,13 +581,15 @@ static int chown_common(struct path *pat
5988 if (!uid_valid(uid))
5990 newattrs.ia_valid |= ATTR_UID;
5991 - newattrs.ia_uid = uid;
5992 + newattrs.ia_uid = make_kuid(&init_user_ns,
5993 + dx_map_uid(user));
5995 if (group != (gid_t) -1) {
5996 if (!gid_valid(gid))
5998 newattrs.ia_valid |= ATTR_GID;
5999 - newattrs.ia_gid = gid;
6000 + newattrs.ia_gid = make_kgid(&init_user_ns,
6001 + dx_map_gid(group));
6003 if (!S_ISDIR(inode->i_mode))
6004 newattrs.ia_valid |=
6005 @@ -604,6 +623,18 @@ retry:
6006 error = mnt_want_write(path.mnt);
6009 +#ifdef CONFIG_VSERVER_COWBL
6010 + error = cow_check_and_break(&path);
6013 +#ifdef CONFIG_VSERVER_COWBL
6014 + error = cow_check_and_break(&path);
6017 +#ifdef CONFIG_VSERVER_COWBL
6018 + error = cow_check_and_break(&path);
6021 error = chown_common(&path, user, group);
6022 mnt_drop_write(path.mnt);
6024 diff -NurpP --minimal linux-3.9.4/fs/proc/array.c linux-3.9.4-vs2.3.6.3/fs/proc/array.c
6025 --- linux-3.9.4/fs/proc/array.c 2013-05-31 13:45:25.000000000 +0000
6026 +++ linux-3.9.4-vs2.3.6.3/fs/proc/array.c 2013-05-31 14:47:11.000000000 +0000
6028 #include <linux/ptrace.h>
6029 #include <linux/tracehook.h>
6030 #include <linux/user_namespace.h>
6031 +#include <linux/vs_context.h>
6032 +#include <linux/vs_network.h>
6034 #include <asm/pgtable.h>
6035 #include <asm/processor.h>
6036 @@ -173,6 +175,9 @@ static inline void task_state(struct seq
6038 ppid = pid_alive(p) ?
6039 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6040 + if (unlikely(vx_current_initpid(p->pid)))
6045 struct task_struct *tracer = ptrace_parent(p);
6046 @@ -297,7 +302,7 @@ static inline void task_sig(struct seq_f
6049 static void render_cap_t(struct seq_file *m, const char *header,
6051 + struct vx_info *vxi, kernel_cap_t *a)
6055 @@ -331,10 +336,11 @@ static inline void task_cap(struct seq_f
6056 NORM_CAPS(cap_effective);
6057 NORM_CAPS(cap_bset);
6059 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6060 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6061 - render_cap_t(m, "CapEff:\t", &cap_effective);
6062 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6063 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6064 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6065 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6066 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6067 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6070 static inline void task_seccomp(struct seq_file *m, struct task_struct *p)
6071 @@ -363,6 +369,42 @@ static void task_cpus_allowed(struct seq
6075 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6076 + struct pid *pid, struct task_struct *task)
6078 + seq_printf(m, "Proxy:\t%p(%c)\n"
6086 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6087 + atomic_read(&task->nsproxy->count),
6088 + task->nsproxy->uts_ns,
6089 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6090 + task->nsproxy->ipc_ns,
6091 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6092 + task->nsproxy->mnt_ns,
6093 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6094 + task->nsproxy->pid_ns,
6095 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6096 + task->nsproxy->net_ns,
6097 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6101 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6103 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6106 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6107 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6111 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6112 struct pid *pid, struct task_struct *task)
6114 @@ -380,6 +422,7 @@ int proc_pid_status(struct seq_file *m,
6115 task_seccomp(m, task);
6116 task_cpus_allowed(m, task);
6117 cpuset_task_status_allowed(m, task);
6118 + task_vs_id(m, task);
6119 task_context_switch_counts(m, task);
6122 @@ -489,6 +532,17 @@ static int do_task_stat(struct seq_file
6123 /* convert nsec -> ticks */
6124 start_time = nsec_to_clock_t(start_time);
6126 + /* fixup start time for virt uptime */
6127 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6128 + unsigned long long bias =
6129 + current->vx_info->cvirt.bias_clock;
6131 + if (start_time > bias)
6132 + start_time -= bias;
6137 seq_printf(m, "%d (%s) %c", pid_nr_ns(pid, ns), tcomm, state);
6138 seq_put_decimal_ll(m, ' ', ppid);
6139 seq_put_decimal_ll(m, ' ', pgid);
6140 diff -NurpP --minimal linux-3.9.4/fs/proc/base.c linux-3.9.4-vs2.3.6.3/fs/proc/base.c
6141 --- linux-3.9.4/fs/proc/base.c 2013-05-31 13:45:25.000000000 +0000
6142 +++ linux-3.9.4-vs2.3.6.3/fs/proc/base.c 2013-05-31 14:47:11.000000000 +0000
6144 #include <linux/fs_struct.h>
6145 #include <linux/slab.h>
6146 #include <linux/flex_array.h>
6147 +#include <linux/vs_context.h>
6148 +#include <linux/vs_network.h>
6149 #ifdef CONFIG_HARDWALL
6150 #include <asm/hardwall.h>
6152 @@ -944,11 +946,15 @@ static ssize_t oom_adj_write(struct file
6153 oom_adj = (oom_adj * OOM_SCORE_ADJ_MAX) / -OOM_DISABLE;
6155 if (oom_adj < task->signal->oom_score_adj &&
6156 - !capable(CAP_SYS_RESOURCE)) {
6157 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6162 + /* prevent guest processes from circumventing the oom killer */
6163 + if (vx_current_xid() && (oom_adj == OOM_DISABLE))
6164 + oom_adj = OOM_ADJUST_MIN;
6167 * /proc/pid/oom_adj is provided for legacy purposes, ask users to use
6168 * /proc/pid/oom_score_adj instead.
6169 @@ -1528,6 +1534,8 @@ struct inode *proc_pid_make_inode(struct
6170 inode->i_gid = cred->egid;
6173 + /* procfs is xid tagged */
6174 + i_tag_write(inode, (tag_t)vx_task_xid(task));
6175 security_task_to_inode(task, inode);
6178 @@ -1573,6 +1581,8 @@ int pid_getattr(struct vfsmount *mnt, st
6182 +static unsigned name_to_int(struct dentry *dentry);
6185 * Exceptional case: normally we are not allowed to unhash a busy
6186 * directory. In this case, however, we can do it - no aliasing problems
6187 @@ -1601,6 +1611,12 @@ int pid_revalidate(struct dentry *dentry
6188 task = get_proc_task(inode);
6191 + unsigned pid = name_to_int(dentry);
6193 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6194 + put_task_struct(task);
6197 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6198 task_dumpable(task)) {
6200 @@ -1617,6 +1633,7 @@ int pid_revalidate(struct dentry *dentry
6201 put_task_struct(task);
6208 @@ -2059,6 +2076,13 @@ static struct dentry *proc_pident_lookup
6212 + /* TODO: maybe we can come up with a generic approach? */
6213 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6214 + (dentry->d_name.len == 5) &&
6215 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6216 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6220 * Yes, it does not scale. And it should not. Don't add
6221 * new entries into /proc/<tgid>/ without very good reasons.
6222 @@ -2493,6 +2517,9 @@ static int proc_pid_personality(struct s
6223 static const struct file_operations proc_task_operations;
6224 static const struct inode_operations proc_task_inode_operations;
6226 +extern int proc_pid_vx_info(struct task_struct *, char *);
6227 +extern int proc_pid_nx_info(struct task_struct *, char *);
6229 static const struct pid_entry tgid_base_stuff[] = {
6230 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6231 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6232 @@ -2559,6 +2586,8 @@ static const struct pid_entry tgid_base_
6233 #ifdef CONFIG_CGROUPS
6234 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6236 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6237 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6238 INF("oom_score", S_IRUGO, proc_oom_score),
6239 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations),
6240 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6241 @@ -2583,6 +2612,7 @@ static const struct pid_entry tgid_base_
6242 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
6243 REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations),
6245 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6248 static int proc_tgid_base_readdir(struct file * filp,
6249 @@ -2770,7 +2800,7 @@ retry:
6251 pid = find_ge_pid(iter.tgid, ns);
6253 - iter.tgid = pid_nr_ns(pid, ns);
6254 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6255 iter.task = pid_task(pid, PIDTYPE_PID);
6256 /* What we to know is if the pid we have find is the
6257 * pid of a thread_group_leader. Testing for task
6258 @@ -2800,7 +2830,7 @@ static int proc_pid_fill_cache(struct fi
6259 struct tgid_iter iter)
6261 char name[PROC_NUMBUF];
6262 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6263 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6264 return proc_fill_cache(filp, dirent, filldir, name, len,
6265 proc_pid_instantiate, iter.task, NULL);
6267 @@ -2833,6 +2863,8 @@ int proc_pid_readdir(struct file * filp,
6268 __filldir = fake_filldir;
6270 filp->f_pos = iter.tgid + TGID_OFFSET;
6271 + if (!vx_proc_task_visible(iter.task))
6273 if (proc_pid_fill_cache(filp, dirent, __filldir, iter) < 0) {
6274 put_task_struct(iter.task);
6276 @@ -2993,6 +3025,8 @@ static struct dentry *proc_task_lookup(s
6277 tid = name_to_int(dentry);
6280 + if (vx_current_initpid(tid))
6283 ns = dentry->d_sb->s_fs_info;
6285 diff -NurpP --minimal linux-3.9.4/fs/proc/generic.c linux-3.9.4-vs2.3.6.3/fs/proc/generic.c
6286 --- linux-3.9.4/fs/proc/generic.c 2013-05-31 13:45:25.000000000 +0000
6287 +++ linux-3.9.4-vs2.3.6.3/fs/proc/generic.c 2013-05-31 16:13:42.000000000 +0000
6289 #include <linux/bitops.h>
6290 #include <linux/spinlock.h>
6291 #include <linux/completion.h>
6292 +#include <linux/vserver/inode.h>
6293 #include <asm/uaccess.h>
6295 #include "internal.h"
6296 @@ -409,6 +410,8 @@ struct dentry *proc_lookup_de(struct pro
6297 for (de = de->subdir; de ; de = de->next) {
6298 if (de->namelen != dentry->d_name.len)
6300 + if (!vx_hide_check(0, de->vx_flags))
6302 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6304 spin_unlock(&proc_subdir_lock);
6305 @@ -417,6 +420,8 @@ struct dentry *proc_lookup_de(struct pro
6306 return ERR_PTR(-ENOMEM);
6307 d_set_d_op(dentry, &proc_dentry_operations);
6308 d_add(dentry, inode);
6309 + /* generic proc entries belong to the host */
6310 + i_tag_write(inode, 0);
6314 @@ -485,6 +490,8 @@ int proc_readdir_de(struct proc_dir_entr
6316 /* filldir passes info to user space */
6318 + if (!vx_hide_check(0, de->vx_flags))
6320 spin_unlock(&proc_subdir_lock);
6321 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6322 de->low_ino, de->mode >> 12) < 0) {
6323 @@ -492,6 +499,7 @@ int proc_readdir_de(struct proc_dir_entr
6326 spin_lock(&proc_subdir_lock);
6331 @@ -603,6 +611,7 @@ static struct proc_dir_entry *__proc_cre
6335 + ent->vx_flags = IATTR_PROC_DEFAULT;
6336 atomic_set(&ent->count, 1);
6337 spin_lock_init(&ent->pde_unload_lock);
6338 INIT_LIST_HEAD(&ent->pde_openers);
6339 @@ -626,7 +635,8 @@ struct proc_dir_entry *proc_symlink(cons
6345 + ent->vx_flags = IATTR_PROC_SYMLINK;
6349 diff -NurpP --minimal linux-3.9.4/fs/proc/inode.c linux-3.9.4-vs2.3.6.3/fs/proc/inode.c
6350 --- linux-3.9.4/fs/proc/inode.c 2013-05-31 13:45:25.000000000 +0000
6351 +++ linux-3.9.4-vs2.3.6.3/fs/proc/inode.c 2013-05-31 14:47:11.000000000 +0000
6352 @@ -458,6 +458,8 @@ struct inode *proc_get_inode(struct supe
6353 inode->i_uid = de->uid;
6354 inode->i_gid = de->gid;
6357 + PROC_I(inode)->vx_flags = de->vx_flags;
6359 inode->i_size = de->size;
6361 diff -NurpP --minimal linux-3.9.4/fs/proc/internal.h linux-3.9.4-vs2.3.6.3/fs/proc/internal.h
6362 --- linux-3.9.4/fs/proc/internal.h 2013-05-31 13:45:25.000000000 +0000
6363 +++ linux-3.9.4-vs2.3.6.3/fs/proc/internal.h 2013-05-31 16:04:34.000000000 +0000
6365 #include <linux/sched.h>
6366 #include <linux/proc_fs.h>
6367 #include <linux/binfmts.h>
6368 +#include <linux/vs_pid.h>
6370 struct ctl_table_header;
6373 @@ -56,6 +58,9 @@ extern int proc_pid_status(struct seq_fi
6374 struct pid *pid, struct task_struct *task);
6375 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6376 struct pid *pid, struct task_struct *task);
6377 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6378 + struct pid *pid, struct task_struct *task);
6380 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6382 extern const struct file_operations proc_tid_children_operations;
6383 @@ -89,11 +94,16 @@ static inline struct pid *proc_pid(struc
6384 return PROC_I(inode)->pid;
6387 -static inline struct task_struct *get_proc_task(struct inode *inode)
6388 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6390 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6393 +static inline struct task_struct *get_proc_task(struct inode *inode)
6395 + return vx_get_proc_task(inode, proc_pid(inode));
6398 static inline int proc_fd(struct inode *inode)
6400 return PROC_I(inode)->fd;
6401 diff -NurpP --minimal linux-3.9.4/fs/proc/loadavg.c linux-3.9.4-vs2.3.6.3/fs/proc/loadavg.c
6402 --- linux-3.9.4/fs/proc/loadavg.c 2012-12-11 03:30:57.000000000 +0000
6403 +++ linux-3.9.4-vs2.3.6.3/fs/proc/loadavg.c 2013-05-31 14:47:11.000000000 +0000
6406 static int loadavg_proc_show(struct seq_file *m, void *v)
6408 + unsigned long running;
6409 + unsigned int threads;
6410 unsigned long avnrun[3];
6412 get_avenrun(avnrun, FIXED_1/200, 0);
6414 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6415 + struct vx_info *vxi = current_vx_info();
6417 + running = atomic_read(&vxi->cvirt.nr_running);
6418 + threads = atomic_read(&vxi->cvirt.nr_threads);
6420 + running = nr_running();
6421 + threads = nr_threads;
6424 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6425 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6426 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6427 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6428 - nr_running(), nr_threads,
6430 task_active_pid_ns(current)->last_pid);
6433 diff -NurpP --minimal linux-3.9.4/fs/proc/meminfo.c linux-3.9.4-vs2.3.6.3/fs/proc/meminfo.c
6434 --- linux-3.9.4/fs/proc/meminfo.c 2013-05-31 13:45:25.000000000 +0000
6435 +++ linux-3.9.4-vs2.3.6.3/fs/proc/meminfo.c 2013-05-31 16:05:39.000000000 +0000
6436 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6437 allowed = ((totalram_pages - hugetlb_total_pages())
6438 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6440 - cached = global_page_state(NR_FILE_PAGES) -
6441 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6442 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6443 total_swapcache_pages() - i.bufferram;
6446 diff -NurpP --minimal linux-3.9.4/fs/proc/root.c linux-3.9.4-vs2.3.6.3/fs/proc/root.c
6447 --- linux-3.9.4/fs/proc/root.c 2013-05-31 13:45:25.000000000 +0000
6448 +++ linux-3.9.4-vs2.3.6.3/fs/proc/root.c 2013-05-31 14:47:11.000000000 +0000
6450 #include <linux/mount.h>
6451 #include <linux/pid_namespace.h>
6452 #include <linux/parser.h>
6453 +#include <linux/vserver/inode.h>
6455 #include "internal.h"
6457 +struct proc_dir_entry *proc_virtual;
6459 +extern void proc_vx_init(void);
6461 static int proc_test_super(struct super_block *sb, void *data)
6463 return sb->s_fs_info == data;
6464 @@ -182,6 +187,7 @@ void __init proc_root_init(void)
6466 proc_mkdir("bus", NULL);
6471 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6472 @@ -248,6 +254,7 @@ struct proc_dir_entry proc_root = {
6473 .proc_iops = &proc_root_inode_operations,
6474 .proc_fops = &proc_root_operations,
6475 .parent = &proc_root,
6476 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6480 diff -NurpP --minimal linux-3.9.4/fs/proc/self.c linux-3.9.4-vs2.3.6.3/fs/proc/self.c
6481 --- linux-3.9.4/fs/proc/self.c 2013-02-19 13:58:49.000000000 +0000
6482 +++ linux-3.9.4-vs2.3.6.3/fs/proc/self.c 2013-05-31 20:57:54.000000000 +0000
6484 #include <linux/proc_fs.h>
6485 #include <linux/sched.h>
6486 #include <linux/namei.h>
6487 +#include <linux/vserver/inode.h>
6491 @@ -56,4 +57,5 @@ void __init proc_self_init(void)
6492 mode = S_IFLNK | S_IRWXUGO;
6493 proc_self_symlink = proc_create("self", mode, NULL, NULL );
6494 proc_self_symlink->proc_iops = &proc_self_inode_operations;
6495 + proc_self_symlink->vx_flags = IATTR_PROC_SYMLINK;
6497 diff -NurpP --minimal linux-3.9.4/fs/proc/stat.c linux-3.9.4-vs2.3.6.3/fs/proc/stat.c
6498 --- linux-3.9.4/fs/proc/stat.c 2012-12-11 03:30:57.000000000 +0000
6499 +++ linux-3.9.4-vs2.3.6.3/fs/proc/stat.c 2013-05-31 14:47:11.000000000 +0000
6501 #include <linux/slab.h>
6502 #include <linux/time.h>
6503 #include <linux/irqnr.h>
6504 +#include <linux/vserver/cvirt.h>
6505 #include <asm/cputime.h>
6506 #include <linux/tick.h>
6507 +#include <linux/cpuset.h>
6509 #ifndef arch_irq_stat_cpu
6510 #define arch_irq_stat_cpu(cpu) 0
6511 @@ -87,14 +89,26 @@ static int show_stat(struct seq_file *p,
6512 u64 sum_softirq = 0;
6513 unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
6514 struct timespec boottime;
6515 + cpumask_var_t cpus_allowed;
6516 + bool virt_cpu = vx_flags(VXF_VIRT_CPU, 0);
6518 user = nice = system = idle = iowait =
6519 irq = softirq = steal = 0;
6520 guest = guest_nice = 0;
6521 getboottime(&boottime);
6523 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6524 + vx_vsi_boottime(&boottime);
6527 + cpuset_cpus_allowed(current, cpus_allowed);
6529 jif = boottime.tv_sec;
6531 for_each_possible_cpu(i) {
6532 + if (virt_cpu && !cpumask_test_cpu(i, cpus_allowed))
6535 user += kcpustat_cpu(i).cpustat[CPUTIME_USER];
6536 nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE];
6537 system += kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM];
6538 @@ -131,6 +145,9 @@ static int show_stat(struct seq_file *p,
6541 for_each_online_cpu(i) {
6542 + if (virt_cpu && !cpumask_test_cpu(i, cpus_allowed))
6545 /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
6546 user = kcpustat_cpu(i).cpustat[CPUTIME_USER];
6547 nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE];
6548 diff -NurpP --minimal linux-3.9.4/fs/proc/uptime.c linux-3.9.4-vs2.3.6.3/fs/proc/uptime.c
6549 --- linux-3.9.4/fs/proc/uptime.c 2012-12-11 03:30:57.000000000 +0000
6550 +++ linux-3.9.4-vs2.3.6.3/fs/proc/uptime.c 2013-05-31 14:47:11.000000000 +0000
6552 #include <linux/seq_file.h>
6553 #include <linux/time.h>
6554 #include <linux/kernel_stat.h>
6555 +#include <linux/vserver/cvirt.h>
6556 #include <asm/cputime.h>
6558 static int uptime_proc_show(struct seq_file *m, void *v)
6559 @@ -25,6 +26,10 @@ static int uptime_proc_show(struct seq_f
6560 nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
6561 idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
6564 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6565 + vx_vsi_uptime(&uptime, &idle);
6567 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6568 (unsigned long) uptime.tv_sec,
6569 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6570 diff -NurpP --minimal linux-3.9.4/fs/proc_namespace.c linux-3.9.4-vs2.3.6.3/fs/proc_namespace.c
6571 --- linux-3.9.4/fs/proc_namespace.c 2012-12-11 03:30:57.000000000 +0000
6572 +++ linux-3.9.4-vs2.3.6.3/fs/proc_namespace.c 2013-05-31 17:17:53.000000000 +0000
6573 @@ -44,6 +44,8 @@ static int show_sb_opts(struct seq_file
6574 { MS_SYNCHRONOUS, ",sync" },
6575 { MS_DIRSYNC, ",dirsync" },
6576 { MS_MANDLOCK, ",mand" },
6577 + { MS_TAGGED, ",tag" },
6578 + { MS_NOTAGCHECK, ",notagcheck" },
6581 const struct proc_fs_info *fs_infop;
6582 @@ -80,6 +82,40 @@ static inline void mangle(struct seq_fil
6583 seq_escape(m, s, " \t\n\\");
6586 +#ifdef CONFIG_VSERVER_EXTRA_MNT_CHECK
6588 +static int mnt_is_reachable(struct vfsmount *vfsmnt)
6591 + struct dentry *point;
6592 + struct mount *mnt = real_mount(vfsmnt);
6593 + struct mount *root_mnt;
6596 + if (mnt == mnt->mnt_ns->root)
6599 + br_read_lock(&vfsmount_lock);
6600 + root = current->fs->root;
6601 + root_mnt = real_mount(root.mnt);
6602 + point = root.dentry;
6604 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
6605 + point = mnt->mnt_mountpoint;
6606 + mnt = mnt->mnt_parent;
6609 + ret = (mnt == root_mnt) && is_subdir(point, root.dentry);
6611 + br_read_unlock(&vfsmount_lock);
6617 +#define mnt_is_reachable(v) (1)
6620 static void show_type(struct seq_file *m, struct super_block *sb)
6622 mangle(m, sb->s_type->name);
6623 @@ -96,6 +132,17 @@ static int show_vfsmnt(struct seq_file *
6624 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6625 struct super_block *sb = mnt_path.dentry->d_sb;
6627 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6629 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6632 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6633 + mnt == current->fs->root.mnt) {
6634 + seq_puts(m, "/dev/root / ");
6638 if (sb->s_op->show_devname) {
6639 err = sb->s_op->show_devname(m, mnt_path.dentry);
6641 @@ -106,6 +153,7 @@ static int show_vfsmnt(struct seq_file *
6643 seq_path(m, &mnt_path, " \t\n\\");
6647 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6648 err = show_sb_opts(m, sb);
6649 @@ -128,6 +176,11 @@ static int show_mountinfo(struct seq_fil
6650 struct path root = p->root;
6653 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6655 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6658 seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
6659 MAJOR(sb->s_dev), MINOR(sb->s_dev));
6660 if (sb->s_op->show_path)
6661 @@ -187,6 +240,17 @@ static int show_vfsstat(struct seq_file
6662 struct super_block *sb = mnt_path.dentry->d_sb;
6665 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6667 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6670 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6671 + mnt == current->fs->root.mnt) {
6672 + seq_puts(m, "device /dev/root mounted on / ");
6677 if (sb->s_op->show_devname) {
6678 seq_puts(m, "device ");
6679 @@ -203,7 +267,7 @@ static int show_vfsstat(struct seq_file
6680 seq_puts(m, " mounted on ");
6681 seq_path(m, &mnt_path, " \t\n\\");
6685 /* file system type */
6686 seq_puts(m, "with fstype ");
6688 diff -NurpP --minimal linux-3.9.4/fs/quota/dquot.c linux-3.9.4-vs2.3.6.3/fs/quota/dquot.c
6689 --- linux-3.9.4/fs/quota/dquot.c 2013-05-31 13:45:25.000000000 +0000
6690 +++ linux-3.9.4-vs2.3.6.3/fs/quota/dquot.c 2013-05-31 14:47:11.000000000 +0000
6691 @@ -1585,6 +1585,9 @@ int __dquot_alloc_space(struct inode *in
6692 struct dquot **dquots = inode->i_dquot;
6693 int reserve = flags & DQUOT_SPACE_RESERVE;
6695 + if ((ret = dl_alloc_space(inode, number)))
6699 * First test before acquiring mutex - solves deadlocks when we
6700 * re-enter the quota code and are already holding the mutex
6701 @@ -1640,6 +1643,9 @@ int dquot_alloc_inode(const struct inode
6702 struct dquot_warn warn[MAXQUOTAS];
6703 struct dquot * const *dquots = inode->i_dquot;
6705 + if ((ret = dl_alloc_inode(inode)))
6708 /* First test before acquiring mutex - solves deadlocks when we
6709 * re-enter the quota code and are already holding the mutex */
6710 if (!dquot_active(inode))
6711 @@ -1711,6 +1717,8 @@ void __dquot_free_space(struct inode *in
6712 struct dquot **dquots = inode->i_dquot;
6713 int reserve = flags & DQUOT_SPACE_RESERVE;
6715 + dl_free_space(inode, number);
6717 /* First test before acquiring mutex - solves deadlocks when we
6718 * re-enter the quota code and are already holding the mutex */
6719 if (!dquot_active(inode)) {
6720 @@ -1755,6 +1763,8 @@ void dquot_free_inode(const struct inode
6721 struct dquot_warn warn[MAXQUOTAS];
6722 struct dquot * const *dquots = inode->i_dquot;
6724 + dl_free_inode(inode);
6726 /* First test before acquiring mutex - solves deadlocks when we
6727 * re-enter the quota code and are already holding the mutex */
6728 if (!dquot_active(inode))
6729 diff -NurpP --minimal linux-3.9.4/fs/quota/quota.c linux-3.9.4-vs2.3.6.3/fs/quota/quota.c
6730 --- linux-3.9.4/fs/quota/quota.c 2013-02-19 13:58:49.000000000 +0000
6731 +++ linux-3.9.4-vs2.3.6.3/fs/quota/quota.c 2013-05-31 14:47:11.000000000 +0000
6733 #include <linux/fs.h>
6734 #include <linux/namei.h>
6735 #include <linux/slab.h>
6736 +#include <linux/vs_context.h>
6737 #include <asm/current.h>
6738 #include <linux/uaccess.h>
6739 #include <linux/kernel.h>
6740 @@ -37,7 +38,7 @@ static int check_quotactl_permission(str
6744 - if (!capable(CAP_SYS_ADMIN))
6745 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6749 @@ -309,6 +310,46 @@ static int do_quotactl(struct super_bloc
6753 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6755 +#include <linux/vroot.h>
6756 +#include <linux/major.h>
6757 +#include <linux/module.h>
6758 +#include <linux/kallsyms.h>
6759 +#include <linux/vserver/debug.h>
6761 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6763 +static DEFINE_SPINLOCK(vroot_grb_lock);
6765 +int register_vroot_grb(vroot_grb_func *func) {
6768 + spin_lock(&vroot_grb_lock);
6769 + if (!vroot_get_real_bdev) {
6770 + vroot_get_real_bdev = func;
6773 + spin_unlock(&vroot_grb_lock);
6776 +EXPORT_SYMBOL(register_vroot_grb);
6778 +int unregister_vroot_grb(vroot_grb_func *func) {
6779 + int ret = -EINVAL;
6781 + spin_lock(&vroot_grb_lock);
6782 + if (vroot_get_real_bdev) {
6783 + vroot_get_real_bdev = NULL;
6786 + spin_unlock(&vroot_grb_lock);
6789 +EXPORT_SYMBOL(unregister_vroot_grb);
6793 /* Return 1 if 'cmd' will block on frozen filesystem */
6794 static int quotactl_cmd_write(int cmd)
6796 @@ -343,6 +384,22 @@ static struct super_block *quotactl_bloc
6799 return ERR_CAST(bdev);
6800 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6801 + if (bdev && bdev->bd_inode &&
6802 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6803 + struct block_device *bdnew = (void *)-EINVAL;
6805 + if (vroot_get_real_bdev)
6806 + bdnew = vroot_get_real_bdev(bdev);
6808 + vxdprintk(VXD_CBIT(misc, 0),
6809 + "vroot_get_real_bdev not set");
6811 + if (IS_ERR(bdnew))
6812 + return ERR_PTR(PTR_ERR(bdnew));
6816 if (quotactl_cmd_write(cmd))
6817 sb = get_super_thawed(bdev);
6819 diff -NurpP --minimal linux-3.9.4/fs/stat.c linux-3.9.4-vs2.3.6.3/fs/stat.c
6820 --- linux-3.9.4/fs/stat.c 2013-05-31 13:45:25.000000000 +0000
6821 +++ linux-3.9.4-vs2.3.6.3/fs/stat.c 2013-06-01 08:53:01.000000000 +0000
6822 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
6823 stat->nlink = inode->i_nlink;
6824 stat->uid = inode->i_uid;
6825 stat->gid = inode->i_gid;
6826 + stat->tag = inode->i_tag;
6827 stat->rdev = inode->i_rdev;
6828 stat->size = i_size_read(inode);
6829 stat->atime = inode->i_atime;
6830 diff -NurpP --minimal linux-3.9.4/fs/statfs.c linux-3.9.4-vs2.3.6.3/fs/statfs.c
6831 --- linux-3.9.4/fs/statfs.c 2013-02-19 13:58:49.000000000 +0000
6832 +++ linux-3.9.4-vs2.3.6.3/fs/statfs.c 2013-05-31 14:47:11.000000000 +0000
6834 #include <linux/statfs.h>
6835 #include <linux/security.h>
6836 #include <linux/uaccess.h>
6837 +#include <linux/vs_base.h>
6838 +#include <linux/vs_dlimit.h>
6839 #include "internal.h"
6841 static int flags_by_mnt(int mnt_flags)
6842 @@ -60,6 +62,8 @@ static int statfs_by_dentry(struct dentr
6843 retval = dentry->d_sb->s_op->statfs(dentry, buf);
6844 if (retval == 0 && buf->f_frsize == 0)
6845 buf->f_frsize = buf->f_bsize;
6846 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
6847 + vx_vsi_statfs(dentry->d_sb, buf);
6851 diff -NurpP --minimal linux-3.9.4/fs/super.c linux-3.9.4-vs2.3.6.3/fs/super.c
6852 --- linux-3.9.4/fs/super.c 2013-05-31 13:45:25.000000000 +0000
6853 +++ linux-3.9.4-vs2.3.6.3/fs/super.c 2013-05-31 14:47:11.000000000 +0000
6855 #include <linux/cleancache.h>
6856 #include <linux/fsnotify.h>
6857 #include <linux/lockdep.h>
6858 +#include <linux/magic.h>
6859 +#include <linux/vs_context.h>
6860 #include "internal.h"
6863 @@ -1117,6 +1119,13 @@ mount_fs(struct file_system_type *type,
6864 WARN_ON(sb->s_bdi == &default_backing_dev_info);
6865 sb->s_flags |= MS_BORN;
6868 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
6870 + (sb->s_magic != PROC_SUPER_MAGIC) &&
6871 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
6874 error = security_sb_kern_mount(sb, flags, secdata);
6877 diff -NurpP --minimal linux-3.9.4/fs/sysfs/mount.c linux-3.9.4-vs2.3.6.3/fs/sysfs/mount.c
6878 --- linux-3.9.4/fs/sysfs/mount.c 2013-05-31 13:45:25.000000000 +0000
6879 +++ linux-3.9.4-vs2.3.6.3/fs/sysfs/mount.c 2013-05-31 14:47:11.000000000 +0000
6880 @@ -48,7 +48,7 @@ static int sysfs_fill_super(struct super
6882 sb->s_blocksize = PAGE_CACHE_SIZE;
6883 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
6884 - sb->s_magic = SYSFS_MAGIC;
6885 + sb->s_magic = SYSFS_SUPER_MAGIC;
6886 sb->s_op = &sysfs_ops;
6887 sb->s_time_gran = 1;
6889 diff -NurpP --minimal linux-3.9.4/fs/utimes.c linux-3.9.4-vs2.3.6.3/fs/utimes.c
6890 --- linux-3.9.4/fs/utimes.c 2013-02-19 13:58:49.000000000 +0000
6891 +++ linux-3.9.4-vs2.3.6.3/fs/utimes.c 2013-05-31 22:40:16.000000000 +0000
6893 #include <linux/stat.h>
6894 #include <linux/utime.h>
6895 #include <linux/syscalls.h>
6896 +#include <linux/mount.h>
6897 +#include <linux/vs_cowbl.h>
6898 #include <asm/uaccess.h>
6899 #include <asm/unistd.h>
6901 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
6904 struct iattr newattrs;
6905 - struct inode *inode = path->dentry->d_inode;
6906 + struct inode *inode;
6908 + error = cow_check_and_break(path);
6912 error = mnt_want_write(path->mnt);
6916 + inode = path->dentry->d_inode;
6918 if (times && times[0].tv_nsec == UTIME_NOW &&
6919 times[1].tv_nsec == UTIME_NOW)
6921 diff -NurpP --minimal linux-3.9.4/fs/xattr.c linux-3.9.4-vs2.3.6.3/fs/xattr.c
6922 --- linux-3.9.4/fs/xattr.c 2013-02-19 13:58:49.000000000 +0000
6923 +++ linux-3.9.4-vs2.3.6.3/fs/xattr.c 2013-05-31 14:47:11.000000000 +0000
6925 #include <linux/audit.h>
6926 #include <linux/vmalloc.h>
6927 #include <linux/posix_acl_xattr.h>
6928 +#include <linux/mount.h>
6930 #include <asm/uaccess.h>
6932 @@ -52,7 +53,7 @@ xattr_permission(struct inode *inode, co
6933 * The trusted.* namespace can only be accessed by privileged users.
6935 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
6936 - if (!capable(CAP_SYS_ADMIN))
6937 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
6938 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
6941 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_dinode.h linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_dinode.h
6942 --- linux-3.9.4/fs/xfs/xfs_dinode.h 2012-12-11 03:30:57.000000000 +0000
6943 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_dinode.h 2013-05-31 14:47:11.000000000 +0000
6944 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
6945 __be32 di_nlink; /* number of links to file */
6946 __be16 di_projid_lo; /* lower part of owner's project id */
6947 __be16 di_projid_hi; /* higher part owner's project id */
6948 - __u8 di_pad[6]; /* unused, zeroed space */
6949 + __u8 di_pad[2]; /* unused, zeroed space */
6950 + __be16 di_tag; /* context tagging */
6951 + __be16 di_vflags; /* vserver specific flags */
6952 __be16 di_flushiter; /* incremented on flush */
6953 xfs_timestamp_t di_atime; /* time last accessed */
6954 xfs_timestamp_t di_mtime; /* time last modified */
6955 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
6956 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
6957 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
6958 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
6959 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
6961 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
6962 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
6963 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
6964 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
6965 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
6966 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
6967 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
6968 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
6970 #ifdef CONFIG_XFS_RT
6971 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
6972 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
6973 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
6974 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
6975 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
6976 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
6977 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
6978 + XFS_DIFLAG_IXUNLINK)
6980 +#define XFS_DIVFLAG_BARRIER 0x01
6981 +#define XFS_DIVFLAG_COW 0x02
6983 #endif /* __XFS_DINODE_H__ */
6984 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_fs.h linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_fs.h
6985 --- linux-3.9.4/fs/xfs/xfs_fs.h 2013-02-19 13:58:49.000000000 +0000
6986 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_fs.h 2013-05-31 14:47:11.000000000 +0000
6987 @@ -67,6 +67,9 @@ struct fsxattr {
6988 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
6989 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
6990 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
6991 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
6992 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
6993 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
6994 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
6997 @@ -303,7 +306,8 @@ typedef struct xfs_bstat {
6998 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
6999 __u16 bs_forkoff; /* inode fork offset in bytes */
7000 __u16 bs_projid_hi; /* higher part of project id */
7001 - unsigned char bs_pad[10]; /* pad space, unused */
7002 + unsigned char bs_pad[8]; /* pad space, unused */
7003 + __u16 bs_tag; /* context tagging */
7004 __u32 bs_dmevmask; /* DMIG event mask */
7005 __u16 bs_dmstate; /* DMIG state info */
7006 __u16 bs_aextents; /* attribute number of extents */
7007 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_ialloc.c linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_ialloc.c
7008 --- linux-3.9.4/fs/xfs/xfs_ialloc.c 2013-05-31 13:45:25.000000000 +0000
7009 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_ialloc.c 2013-05-31 14:47:11.000000000 +0000
7011 #include "xfs_error.h"
7012 #include "xfs_bmap.h"
7016 * Allocation group level functions.
7018 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_inode.c linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_inode.c
7019 --- linux-3.9.4/fs/xfs/xfs_inode.c 2013-05-31 13:45:25.000000000 +0000
7020 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_inode.c 2013-06-03 19:35:13.000000000 +0000
7022 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
7024 #include <linux/log2.h>
7025 +#include <linux/vs_tag.h>
7029 @@ -835,15 +836,25 @@ xfs_iformat_btree(
7031 xfs_dinode_from_disk(
7033 - xfs_dinode_t *from)
7034 + xfs_dinode_t *from,
7037 + uint32_t uid, gid, tag;
7039 to->di_magic = be16_to_cpu(from->di_magic);
7040 to->di_mode = be16_to_cpu(from->di_mode);
7041 to->di_version = from ->di_version;
7042 to->di_format = from->di_format;
7043 to->di_onlink = be16_to_cpu(from->di_onlink);
7044 - to->di_uid = be32_to_cpu(from->di_uid);
7045 - to->di_gid = be32_to_cpu(from->di_gid);
7047 + uid = be32_to_cpu(from->di_uid);
7048 + gid = be32_to_cpu(from->di_gid);
7049 + tag = be16_to_cpu(from->di_tag);
7051 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7052 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7053 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7055 to->di_nlink = be32_to_cpu(from->di_nlink);
7056 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7057 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7058 @@ -865,21 +876,26 @@ xfs_dinode_from_disk(
7059 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7060 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7061 to->di_flags = be16_to_cpu(from->di_flags);
7062 + to->di_vflags = be16_to_cpu(from->di_vflags);
7063 to->di_gen = be32_to_cpu(from->di_gen);
7069 - xfs_icdinode_t *from)
7070 + xfs_icdinode_t *from,
7073 to->di_magic = cpu_to_be16(from->di_magic);
7074 to->di_mode = cpu_to_be16(from->di_mode);
7075 to->di_version = from ->di_version;
7076 to->di_format = from->di_format;
7077 to->di_onlink = cpu_to_be16(from->di_onlink);
7078 - to->di_uid = cpu_to_be32(from->di_uid);
7079 - to->di_gid = cpu_to_be32(from->di_gid);
7081 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
7082 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
7083 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
7085 to->di_nlink = cpu_to_be32(from->di_nlink);
7086 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
7087 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
7088 @@ -901,12 +917,14 @@ xfs_dinode_to_disk(
7089 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
7090 to->di_dmstate = cpu_to_be16(from->di_dmstate);
7091 to->di_flags = cpu_to_be16(from->di_flags);
7092 + to->di_vflags = cpu_to_be16(from->di_vflags);
7093 to->di_gen = cpu_to_be32(from->di_gen);
7098 - __uint16_t di_flags)
7099 + __uint16_t di_flags,
7100 + __uint16_t di_vflags)
7104 @@ -917,6 +935,8 @@ _xfs_dic2xflags(
7105 flags |= XFS_XFLAG_PREALLOC;
7106 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7107 flags |= XFS_XFLAG_IMMUTABLE;
7108 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7109 + flags |= XFS_XFLAG_IXUNLINK;
7110 if (di_flags & XFS_DIFLAG_APPEND)
7111 flags |= XFS_XFLAG_APPEND;
7112 if (di_flags & XFS_DIFLAG_SYNC)
7113 @@ -941,6 +961,10 @@ _xfs_dic2xflags(
7114 flags |= XFS_XFLAG_FILESTREAM;
7117 + if (di_vflags & XFS_DIVFLAG_BARRIER)
7118 + flags |= FS_BARRIER_FL;
7119 + if (di_vflags & XFS_DIVFLAG_COW)
7120 + flags |= FS_COW_FL;
7124 @@ -950,7 +974,7 @@ xfs_ip2xflags(
7126 xfs_icdinode_t *dic = &ip->i_d;
7128 - return _xfs_dic2xflags(dic->di_flags) |
7129 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
7130 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
7133 @@ -958,7 +982,8 @@ uint
7137 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
7138 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
7139 + be16_to_cpu(dip->di_vflags)) |
7140 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
7143 @@ -1012,7 +1037,8 @@ xfs_iread(
7144 * Otherwise, just get the truly permanent information.
7147 - xfs_dinode_from_disk(&ip->i_d, dip);
7148 + xfs_dinode_from_disk(&ip->i_d, dip,
7149 + mp->m_flags & XFS_MOUNT_TAGGED);
7150 error = xfs_iformat(ip, dip);
7153 @@ -1199,6 +1225,7 @@ xfs_ialloc(
7154 ASSERT(ip->i_d.di_nlink == nlink);
7155 ip->i_d.di_uid = current_fsuid();
7156 ip->i_d.di_gid = current_fsgid();
7157 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
7158 xfs_set_projid(ip, prid);
7159 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
7161 @@ -1258,6 +1285,7 @@ xfs_ialloc(
7162 ip->i_d.di_dmevmask = 0;
7163 ip->i_d.di_dmstate = 0;
7164 ip->i_d.di_flags = 0;
7165 + ip->i_d.di_vflags = 0;
7166 flags = XFS_ILOG_CORE;
7167 switch (mode & S_IFMT) {
7169 @@ -1952,6 +1980,7 @@ xfs_ifree(
7171 ip->i_d.di_mode = 0; /* mark incore inode as free */
7172 ip->i_d.di_flags = 0;
7173 + ip->i_d.di_vflags = 0;
7174 ip->i_d.di_dmevmask = 0;
7175 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
7176 ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
7177 @@ -2118,7 +2147,6 @@ xfs_iroot_realloc(
7183 * This is called when the amount of space needed for if_data
7184 * is increased or decreased. The change in size is indicated by
7185 @@ -2800,7 +2828,8 @@ xfs_iflush_int(
7186 * because if the inode is dirty at all the core must
7189 - xfs_dinode_to_disk(dip, &ip->i_d);
7190 + xfs_dinode_to_disk(dip, &ip->i_d,
7191 + mp->m_flags & XFS_MOUNT_TAGGED);
7193 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7194 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7195 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_inode.h linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_inode.h
7196 --- linux-3.9.4/fs/xfs/xfs_inode.h 2013-05-31 13:45:25.000000000 +0000
7197 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_inode.h 2013-05-31 14:47:11.000000000 +0000
7198 @@ -134,7 +134,9 @@ typedef struct xfs_icdinode {
7199 __uint32_t di_nlink; /* number of links to file */
7200 __uint16_t di_projid_lo; /* lower part of owner's project id */
7201 __uint16_t di_projid_hi; /* higher part of owner's project id */
7202 - __uint8_t di_pad[6]; /* unused, zeroed space */
7203 + __uint8_t di_pad[2]; /* unused, zeroed space */
7204 + __uint16_t di_tag; /* context tagging */
7205 + __uint16_t di_vflags; /* vserver specific flags */
7206 __uint16_t di_flushiter; /* incremented on flush */
7207 xfs_ictimestamp_t di_atime; /* time last accessed */
7208 xfs_ictimestamp_t di_mtime; /* time last modified */
7209 @@ -556,7 +558,7 @@ int xfs_imap_to_bp(struct xfs_mount *,
7210 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
7211 struct xfs_inode *, uint);
7212 void xfs_dinode_to_disk(struct xfs_dinode *,
7213 - struct xfs_icdinode *);
7214 + struct xfs_icdinode *, int);
7215 void xfs_idestroy_fork(struct xfs_inode *, int);
7216 void xfs_idata_realloc(struct xfs_inode *, int, int);
7217 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7218 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_ioctl.c linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_ioctl.c
7219 --- linux-3.9.4/fs/xfs/xfs_ioctl.c 2013-05-31 13:45:25.000000000 +0000
7220 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_ioctl.c 2013-05-31 14:47:11.000000000 +0000
7222 #include "xfs_bmap_btree.h"
7223 #include "xfs_dinode.h"
7224 #include "xfs_inode.h"
7225 -#include "xfs_ioctl.h"
7226 +// #include "xfs_ioctl.h"
7227 #include "xfs_rtalloc.h"
7228 #include "xfs_itable.h"
7229 #include "xfs_error.h"
7230 @@ -763,6 +763,10 @@ xfs_merge_ioc_xflags(
7231 xflags |= XFS_XFLAG_IMMUTABLE;
7233 xflags &= ~XFS_XFLAG_IMMUTABLE;
7234 + if (flags & FS_IXUNLINK_FL)
7235 + xflags |= XFS_XFLAG_IXUNLINK;
7237 + xflags &= ~XFS_XFLAG_IXUNLINK;
7238 if (flags & FS_APPEND_FL)
7239 xflags |= XFS_XFLAG_APPEND;
7241 @@ -791,6 +795,8 @@ xfs_di2lxflags(
7243 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7244 flags |= FS_IMMUTABLE_FL;
7245 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7246 + flags |= FS_IXUNLINK_FL;
7247 if (di_flags & XFS_DIFLAG_APPEND)
7248 flags |= FS_APPEND_FL;
7249 if (di_flags & XFS_DIFLAG_SYNC)
7250 @@ -851,6 +857,8 @@ xfs_set_diflags(
7251 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7252 if (xflags & XFS_XFLAG_IMMUTABLE)
7253 di_flags |= XFS_DIFLAG_IMMUTABLE;
7254 + if (xflags & XFS_XFLAG_IXUNLINK)
7255 + di_flags |= XFS_DIFLAG_IXUNLINK;
7256 if (xflags & XFS_XFLAG_APPEND)
7257 di_flags |= XFS_DIFLAG_APPEND;
7258 if (xflags & XFS_XFLAG_SYNC)
7259 @@ -893,6 +901,10 @@ xfs_diflags_to_linux(
7260 inode->i_flags |= S_IMMUTABLE;
7262 inode->i_flags &= ~S_IMMUTABLE;
7263 + if (xflags & XFS_XFLAG_IXUNLINK)
7264 + inode->i_flags |= S_IXUNLINK;
7266 + inode->i_flags &= ~S_IXUNLINK;
7267 if (xflags & XFS_XFLAG_APPEND)
7268 inode->i_flags |= S_APPEND;
7270 @@ -1397,10 +1409,18 @@ xfs_file_ioctl(
7271 case XFS_IOC_FSGETXATTRA:
7272 return xfs_ioc_fsgetxattr(ip, 1, arg);
7273 case XFS_IOC_FSSETXATTR:
7274 + if (IS_BARRIER(inode)) {
7275 + vxwprintk_task(1, "messing with the barrier.");
7276 + return -XFS_ERROR(EACCES);
7278 return xfs_ioc_fssetxattr(ip, filp, arg);
7279 case XFS_IOC_GETXFLAGS:
7280 return xfs_ioc_getxflags(ip, arg);
7281 case XFS_IOC_SETXFLAGS:
7282 + if (IS_BARRIER(inode)) {
7283 + vxwprintk_task(1, "messing with the barrier.");
7284 + return -XFS_ERROR(EACCES);
7286 return xfs_ioc_setxflags(ip, filp, arg);
7288 case XFS_IOC_FSSETDM: {
7289 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_ioctl.h linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_ioctl.h
7290 --- linux-3.9.4/fs/xfs/xfs_ioctl.h 2012-12-11 03:30:57.000000000 +0000
7291 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_ioctl.h 2013-05-31 14:47:11.000000000 +0000
7292 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7293 void __user *uhandle,
7298 + struct inode *inode,
7305 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_iops.c linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_iops.c
7306 --- linux-3.9.4/fs/xfs/xfs_iops.c 2013-02-19 13:58:49.000000000 +0000
7307 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_iops.c 2013-05-31 14:47:11.000000000 +0000
7309 #include "xfs_bmap_btree.h"
7310 #include "xfs_dinode.h"
7311 #include "xfs_inode.h"
7312 +#include "xfs_ioctl.h"
7313 #include "xfs_bmap.h"
7314 #include "xfs_rtalloc.h"
7315 #include "xfs_error.h"
7317 #include <linux/security.h>
7318 #include <linux/fiemap.h>
7319 #include <linux/slab.h>
7320 +#include <linux/vs_tag.h>
7324 @@ -422,6 +424,7 @@ xfs_vn_getattr(
7325 stat->nlink = ip->i_d.di_nlink;
7326 stat->uid = ip->i_d.di_uid;
7327 stat->gid = ip->i_d.di_gid;
7328 + stat->tag = ip->i_d.di_tag;
7329 stat->ino = ip->i_ino;
7330 stat->atime = inode->i_atime;
7331 stat->mtime = inode->i_mtime;
7332 @@ -1037,6 +1040,7 @@ static const struct inode_operations xfs
7333 .listxattr = xfs_vn_listxattr,
7334 .fiemap = xfs_vn_fiemap,
7335 .update_time = xfs_vn_update_time,
7336 + .sync_flags = xfs_sync_flags,
7339 static const struct inode_operations xfs_dir_inode_operations = {
7340 @@ -1063,6 +1067,7 @@ static const struct inode_operations xfs
7341 .removexattr = generic_removexattr,
7342 .listxattr = xfs_vn_listxattr,
7343 .update_time = xfs_vn_update_time,
7344 + .sync_flags = xfs_sync_flags,
7347 static const struct inode_operations xfs_dir_ci_inode_operations = {
7348 @@ -1114,6 +1119,10 @@ xfs_diflags_to_iflags(
7349 inode->i_flags |= S_IMMUTABLE;
7351 inode->i_flags &= ~S_IMMUTABLE;
7352 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7353 + inode->i_flags |= S_IXUNLINK;
7355 + inode->i_flags &= ~S_IXUNLINK;
7356 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7357 inode->i_flags |= S_APPEND;
7359 @@ -1126,6 +1135,15 @@ xfs_diflags_to_iflags(
7360 inode->i_flags |= S_NOATIME;
7362 inode->i_flags &= ~S_NOATIME;
7364 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7365 + inode->i_vflags |= V_BARRIER;
7367 + inode->i_vflags &= ~V_BARRIER;
7368 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7369 + inode->i_vflags |= V_COW;
7371 + inode->i_vflags &= ~V_COW;
7375 @@ -1157,6 +1175,7 @@ xfs_setup_inode(
7376 set_nlink(inode, ip->i_d.di_nlink);
7377 inode->i_uid = ip->i_d.di_uid;
7378 inode->i_gid = ip->i_d.di_gid;
7379 + inode->i_tag = ip->i_d.di_tag;
7381 switch (inode->i_mode & S_IFMT) {
7383 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_itable.c linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_itable.c
7384 --- linux-3.9.4/fs/xfs/xfs_itable.c 2013-02-19 13:58:49.000000000 +0000
7385 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_itable.c 2013-05-31 14:47:11.000000000 +0000
7386 @@ -97,6 +97,7 @@ xfs_bulkstat_one_int(
7387 buf->bs_mode = dic->di_mode;
7388 buf->bs_uid = dic->di_uid;
7389 buf->bs_gid = dic->di_gid;
7390 + buf->bs_tag = dic->di_tag;
7391 buf->bs_size = dic->di_size;
7392 buf->bs_atime.tv_sec = dic->di_atime.t_sec;
7393 buf->bs_atime.tv_nsec = dic->di_atime.t_nsec;
7394 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_linux.h linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_linux.h
7395 --- linux-3.9.4/fs/xfs/xfs_linux.h 2013-02-19 13:58:49.000000000 +0000
7396 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_linux.h 2013-05-31 14:47:11.000000000 +0000
7399 #define current_cpu() (raw_smp_processor_id())
7400 #define current_pid() (current->pid)
7401 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7402 #define current_test_flags(f) (current->flags & (f))
7403 #define current_set_flags_nested(sp, f) \
7404 (*(sp) = current->flags, current->flags |= (f))
7405 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_log_recover.c linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_log_recover.c
7406 --- linux-3.9.4/fs/xfs/xfs_log_recover.c 2013-05-31 13:45:25.000000000 +0000
7407 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_log_recover.c 2013-05-31 14:47:11.000000000 +0000
7408 @@ -2361,7 +2361,8 @@ xlog_recover_inode_pass2(
7411 /* The core is in in-core format */
7412 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
7413 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
7414 + mp->m_flags & XFS_MOUNT_TAGGED);
7416 /* the rest is in on-disk format */
7417 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
7418 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_mount.h linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_mount.h
7419 --- linux-3.9.4/fs/xfs/xfs_mount.h 2013-05-31 13:45:25.000000000 +0000
7420 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_mount.h 2013-05-31 14:47:11.000000000 +0000
7421 @@ -254,6 +254,7 @@ typedef struct xfs_mount {
7423 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7425 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7428 * Default minimum read and write sizes.
7429 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_super.c linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_super.c
7430 --- linux-3.9.4/fs/xfs/xfs_super.c 2013-05-31 13:45:25.000000000 +0000
7431 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_super.c 2013-05-31 14:47:11.000000000 +0000
7432 @@ -114,6 +114,9 @@ mempool_t *xfs_ioend_pool;
7433 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7434 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7435 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7436 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7437 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7438 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7441 * Table driven mount option parser.
7442 @@ -126,6 +129,8 @@ enum {
7451 @@ -134,6 +139,9 @@ static const match_table_t tokens = {
7452 {Opt_nobarrier, "nobarrier"},
7453 {Opt_inode64, "inode64"},
7454 {Opt_inode32, "inode32"},
7455 + {Opt_tag, "tagxid"},
7457 + {Opt_notag, "notag"},
7461 @@ -392,6 +400,19 @@ xfs_parseargs(
7462 } else if (!strcmp(this_char, "irixsgid")) {
7464 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7465 +#ifndef CONFIG_TAGGING_NONE
7466 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7467 + mp->m_flags |= XFS_MOUNT_TAGGED;
7468 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7469 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7470 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7471 + mp->m_flags |= XFS_MOUNT_TAGGED;
7473 +#ifdef CONFIG_PROPAGATE
7474 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7476 + mp->m_flags |= XFS_MOUNT_TAGGED;
7479 xfs_warn(mp, "unknown mount option [%s].", this_char);
7481 @@ -1238,6 +1259,16 @@ xfs_fs_remount(
7483 mp->m_maxagi = xfs_set_inode32(mp);
7486 + if (!(sb->s_flags & MS_TAGGED)) {
7488 + "XFS: %s: tagging not permitted on remount.\n",
7497 * Logically we would return an error here to prevent
7498 @@ -1458,6 +1489,9 @@ xfs_fs_fill_super(
7502 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7503 + sb->s_flags |= MS_TAGGED;
7506 * we must configure the block size in the superblock before we run the
7507 * full mount process as the mount process can lookup and cache inodes.
7508 diff -NurpP --minimal linux-3.9.4/fs/xfs/xfs_vnodeops.c linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_vnodeops.c
7509 --- linux-3.9.4/fs/xfs/xfs_vnodeops.c 2013-05-31 13:45:25.000000000 +0000
7510 +++ linux-3.9.4-vs2.3.6.3/fs/xfs/xfs_vnodeops.c 2013-05-31 14:47:11.000000000 +0000
7511 @@ -104,6 +104,77 @@ xfs_readlink_bmap(
7517 +xfs_get_inode_flags(
7520 + struct inode *inode = VFS_I(ip);
7521 + unsigned int flags = inode->i_flags;
7522 + unsigned int vflags = inode->i_vflags;
7524 + if (flags & S_IMMUTABLE)
7525 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7527 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7528 + if (flags & S_IXUNLINK)
7529 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
7531 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
7533 + if (vflags & V_BARRIER)
7534 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
7536 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
7537 + if (vflags & V_COW)
7538 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
7540 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
7545 + struct inode *inode,
7549 + struct xfs_inode *ip = XFS_I(inode);
7550 + struct xfs_mount *mp = ip->i_mount;
7551 + struct xfs_trans *tp;
7552 + unsigned int lock_flags = 0;
7555 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
7556 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
7560 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7561 + xfs_trans_ijoin(tp, ip, 0);
7563 + inode->i_flags = flags;
7564 + inode->i_vflags = vflags;
7565 + xfs_get_inode_flags(ip);
7567 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
7568 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
7570 + XFS_STATS_INC(xs_ig_attrchg);
7572 + if (mp->m_flags & XFS_MOUNT_WSYNC)
7573 + xfs_trans_set_sync(tp);
7574 + code = xfs_trans_commit(tp, 0);
7575 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7579 + xfs_trans_cancel(tp, 0);
7581 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7589 diff -NurpP --minimal linux-3.9.4/include/linux/cred.h linux-3.9.4-vs2.3.6.3/include/linux/cred.h
7590 --- linux-3.9.4/include/linux/cred.h 2013-02-19 13:58:50.000000000 +0000
7591 +++ linux-3.9.4-vs2.3.6.3/include/linux/cred.h 2013-05-31 14:47:11.000000000 +0000
7592 @@ -143,6 +143,7 @@ extern void exit_creds(struct task_struc
7593 extern int copy_creds(struct task_struct *, unsigned long);
7594 extern const struct cred *get_task_cred(struct task_struct *);
7595 extern struct cred *cred_alloc_blank(void);
7596 +extern struct cred *__prepare_creds(const struct cred *);
7597 extern struct cred *prepare_creds(void);
7598 extern struct cred *prepare_exec_creds(void);
7599 extern int commit_creds(struct cred *);
7600 @@ -196,6 +197,31 @@ static inline void validate_process_cred
7604 +static inline void set_cred_subscribers(struct cred *cred, int n)
7606 +#ifdef CONFIG_DEBUG_CREDENTIALS
7607 + atomic_set(&cred->subscribers, n);
7611 +static inline int read_cred_subscribers(const struct cred *cred)
7613 +#ifdef CONFIG_DEBUG_CREDENTIALS
7614 + return atomic_read(&cred->subscribers);
7620 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
7622 +#ifdef CONFIG_DEBUG_CREDENTIALS
7623 + struct cred *cred = (struct cred *) _cred;
7625 + atomic_add(n, &cred->subscribers);
7630 * get_new_cred - Get a reference on a new set of credentials
7631 * @cred: The new credentials to reference
7632 diff -NurpP --minimal linux-3.9.4/include/linux/devpts_fs.h linux-3.9.4-vs2.3.6.3/include/linux/devpts_fs.h
7633 --- linux-3.9.4/include/linux/devpts_fs.h 2013-02-19 13:58:50.000000000 +0000
7634 +++ linux-3.9.4-vs2.3.6.3/include/linux/devpts_fs.h 2013-05-31 14:47:11.000000000 +0000
7635 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
7640 #endif /* _LINUX_DEVPTS_FS_H */
7641 diff -NurpP --minimal linux-3.9.4/include/linux/fs.h linux-3.9.4-vs2.3.6.3/include/linux/fs.h
7642 --- linux-3.9.4/include/linux/fs.h 2013-05-31 13:45:27.000000000 +0000
7643 +++ linux-3.9.4-vs2.3.6.3/include/linux/fs.h 2013-05-31 14:47:11.000000000 +0000
7644 @@ -211,6 +211,7 @@ typedef void (dio_iodone_t)(struct kiocb
7645 #define ATTR_KILL_PRIV (1 << 14)
7646 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
7647 #define ATTR_TIMES_SET (1 << 16)
7648 +#define ATTR_TAG (1 << 17)
7651 * This is the Inode Attributes structure, used for notify_change(). It
7652 @@ -226,6 +227,7 @@ struct iattr {
7658 struct timespec ia_atime;
7659 struct timespec ia_mtime;
7660 @@ -523,7 +525,9 @@ struct inode {
7661 unsigned short i_opflags;
7664 - unsigned int i_flags;
7666 + unsigned short i_flags;
7667 + unsigned short i_vflags;
7669 #ifdef CONFIG_FS_POSIX_ACL
7670 struct posix_acl *i_acl;
7671 @@ -552,6 +556,7 @@ struct inode {
7672 unsigned int __i_nlink;
7677 struct timespec i_atime;
7678 struct timespec i_mtime;
7679 @@ -702,6 +707,11 @@ static inline gid_t i_gid_read(const str
7680 return from_kgid(&init_user_ns, inode->i_gid);
7683 +static inline tag_t i_tag_read(const struct inode *inode)
7685 + return from_ktag(&init_user_ns, inode->i_tag);
7688 static inline void i_uid_write(struct inode *inode, uid_t uid)
7690 inode->i_uid = make_kuid(&init_user_ns, uid);
7691 @@ -712,14 +722,19 @@ static inline void i_gid_write(struct in
7692 inode->i_gid = make_kgid(&init_user_ns, gid);
7695 +static inline void i_tag_write(struct inode *inode, tag_t tag)
7697 + inode->i_tag = make_ktag(&init_user_ns, tag);
7700 static inline unsigned iminor(const struct inode *inode)
7702 - return MINOR(inode->i_rdev);
7703 + return MINOR(inode->i_mdev);
7706 static inline unsigned imajor(const struct inode *inode)
7708 - return MAJOR(inode->i_rdev);
7709 + return MAJOR(inode->i_mdev);
7712 extern struct block_device *I_BDEV(struct inode *inode);
7713 @@ -786,6 +801,7 @@ struct file {
7715 struct fown_struct f_owner;
7716 const struct cred *f_cred;
7718 struct file_ra_state f_ra;
7721 @@ -937,6 +953,7 @@ struct file_lock {
7722 struct file *fl_file;
7727 struct fasync_struct * fl_fasync; /* for lease break notifications */
7728 /* for lease breaks: */
7729 @@ -1567,6 +1584,7 @@ struct inode_operations {
7730 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
7731 ssize_t (*listxattr) (struct dentry *, char *, size_t);
7732 int (*removexattr) (struct dentry *, const char *);
7733 + int (*sync_flags) (struct inode *, int, int);
7734 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
7736 int (*update_time)(struct inode *, struct timespec *, int);
7737 @@ -1579,6 +1597,7 @@ ssize_t rw_copy_check_uvector(int type,
7738 unsigned long nr_segs, unsigned long fast_segs,
7739 struct iovec *fast_pointer,
7740 struct iovec **ret_pointer);
7741 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
7743 extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
7744 extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
7745 @@ -1632,6 +1651,14 @@ struct super_operations {
7746 #define S_IMA 1024 /* Inode has an associated IMA struct */
7747 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
7748 #define S_NOSEC 4096 /* no suid or xattr security attributes */
7749 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
7751 +/* Linux-VServer related Inode flags */
7755 +#define V_BARRIER 4 /* Barrier for chroot() */
7756 +#define V_COW 8 /* Copy on Write */
7759 * Note that nosuid etc flags are inode-specific: setting some file-system
7760 @@ -1656,10 +1683,13 @@ struct super_operations {
7761 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
7762 #define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
7763 #define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
7764 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
7766 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
7767 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
7768 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
7769 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
7770 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
7771 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
7773 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
7774 @@ -1670,6 +1700,16 @@ struct super_operations {
7775 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
7776 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
7778 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
7780 +#ifdef CONFIG_VSERVER_COWBL
7781 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
7782 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
7784 +# define IS_COW(inode) (0)
7785 +# define IS_COW_LINK(inode) (0)
7789 * Inode state bits. Protected by inode->i_lock
7791 @@ -1898,6 +1938,9 @@ extern int rw_verify_area(int, struct fi
7792 extern int locks_mandatory_locked(struct inode *);
7793 extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
7795 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
7796 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
7799 * Candidates for mandatory locking have the setgid bit set
7800 * but no group execute bit - an otherwise meaningless combination.
7801 @@ -2509,6 +2552,7 @@ extern int dcache_dir_open(struct inode
7802 extern int dcache_dir_close(struct inode *, struct file *);
7803 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
7804 extern int dcache_readdir(struct file *, void *, filldir_t);
7805 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
7806 extern int simple_setattr(struct dentry *, struct iattr *);
7807 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
7808 extern int simple_statfs(struct dentry *, struct kstatfs *);
7809 diff -NurpP --minimal linux-3.9.4/include/linux/init_task.h linux-3.9.4-vs2.3.6.3/include/linux/init_task.h
7810 --- linux-3.9.4/include/linux/init_task.h 2013-05-31 13:45:27.000000000 +0000
7811 +++ linux-3.9.4-vs2.3.6.3/include/linux/init_task.h 2013-05-31 14:53:41.000000000 +0000
7812 @@ -222,6 +222,10 @@ extern struct task_group root_task_group
7813 INIT_TASK_RCU_PREEMPT(tsk) \
7817 + .vx_info = NULL, \
7819 + .nx_info = NULL, \
7823 diff -NurpP --minimal linux-3.9.4/include/linux/ipc.h linux-3.9.4-vs2.3.6.3/include/linux/ipc.h
7824 --- linux-3.9.4/include/linux/ipc.h 2012-12-11 03:30:57.000000000 +0000
7825 +++ linux-3.9.4-vs2.3.6.3/include/linux/ipc.h 2013-05-31 14:47:11.000000000 +0000
7826 @@ -16,6 +16,7 @@ struct kern_ipc_perm
7834 diff -NurpP --minimal linux-3.9.4/include/linux/loop.h linux-3.9.4-vs2.3.6.3/include/linux/loop.h
7835 --- linux-3.9.4/include/linux/loop.h 2013-02-19 13:58:51.000000000 +0000
7836 +++ linux-3.9.4-vs2.3.6.3/include/linux/loop.h 2013-05-31 14:47:11.000000000 +0000
7837 @@ -41,6 +41,7 @@ struct loop_device {
7838 struct loop_func_table *lo_encryption;
7840 kuid_t lo_key_owner; /* Who set the key */
7842 int (*ioctl)(struct loop_device *, int cmd,
7845 diff -NurpP --minimal linux-3.9.4/include/linux/memcontrol.h linux-3.9.4-vs2.3.6.3/include/linux/memcontrol.h
7846 --- linux-3.9.4/include/linux/memcontrol.h 2013-05-31 13:45:28.000000000 +0000
7847 +++ linux-3.9.4-vs2.3.6.3/include/linux/memcontrol.h 2013-05-31 14:47:11.000000000 +0000
7848 @@ -86,6 +86,13 @@ extern struct mem_cgroup *try_get_mem_cg
7849 extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg);
7850 extern struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont);
7852 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
7853 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
7855 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
7856 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
7857 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
7860 bool mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *memcg)
7862 diff -NurpP --minimal linux-3.9.4/include/linux/mm_types.h linux-3.9.4-vs2.3.6.3/include/linux/mm_types.h
7863 --- linux-3.9.4/include/linux/mm_types.h 2013-05-31 13:45:28.000000000 +0000
7864 +++ linux-3.9.4-vs2.3.6.3/include/linux/mm_types.h 2013-05-31 14:47:11.000000000 +0000
7865 @@ -380,6 +380,7 @@ struct mm_struct {
7867 /* Architecture-specific MM context */
7868 mm_context_t context;
7869 + struct vx_info *mm_vx_info;
7871 unsigned long flags; /* Must use atomic bitops to access the bits */
7873 diff -NurpP --minimal linux-3.9.4/include/linux/mount.h linux-3.9.4-vs2.3.6.3/include/linux/mount.h
7874 --- linux-3.9.4/include/linux/mount.h 2013-05-31 13:45:28.000000000 +0000
7875 +++ linux-3.9.4-vs2.3.6.3/include/linux/mount.h 2013-05-31 14:47:11.000000000 +0000
7876 @@ -49,6 +49,9 @@ struct mnt_namespace;
7878 #define MNT_LOCK_READONLY 0x400000
7880 +#define MNT_TAGID 0x10000
7881 +#define MNT_NOTAG 0x20000
7884 struct dentry *mnt_root; /* root of the mounted tree */
7885 struct super_block *mnt_sb; /* pointer to superblock */
7886 diff -NurpP --minimal linux-3.9.4/include/linux/net.h linux-3.9.4-vs2.3.6.3/include/linux/net.h
7887 --- linux-3.9.4/include/linux/net.h 2012-12-11 03:30:57.000000000 +0000
7888 +++ linux-3.9.4-vs2.3.6.3/include/linux/net.h 2013-05-31 14:47:11.000000000 +0000
7889 @@ -38,6 +38,7 @@ struct net;
7890 #define SOCK_PASSCRED 3
7891 #define SOCK_PASSSEC 4
7892 #define SOCK_EXTERNALLY_ALLOCATED 5
7893 +#define SOCK_USER_SOCKET 6
7895 #ifndef ARCH_HAS_SOCKET_TYPES
7897 diff -NurpP --minimal linux-3.9.4/include/linux/netdevice.h linux-3.9.4-vs2.3.6.3/include/linux/netdevice.h
7898 --- linux-3.9.4/include/linux/netdevice.h 2013-05-31 13:45:28.000000000 +0000
7899 +++ linux-3.9.4-vs2.3.6.3/include/linux/netdevice.h 2013-05-31 14:47:11.000000000 +0000
7900 @@ -1688,6 +1688,7 @@ extern void netdev_resync_ops(struct ne
7902 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
7903 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
7904 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
7905 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
7906 extern int dev_restart(struct net_device *dev);
7907 #ifdef CONFIG_NETPOLL_TRAP
7908 diff -NurpP --minimal linux-3.9.4/include/linux/nsproxy.h linux-3.9.4-vs2.3.6.3/include/linux/nsproxy.h
7909 --- linux-3.9.4/include/linux/nsproxy.h 2013-02-19 13:58:51.000000000 +0000
7910 +++ linux-3.9.4-vs2.3.6.3/include/linux/nsproxy.h 2013-05-31 17:17:53.000000000 +0000
7913 #include <linux/spinlock.h>
7914 #include <linux/sched.h>
7915 +#include <linux/vserver/debug.h>
7917 struct mnt_namespace;
7918 struct uts_namespace;
7919 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
7922 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
7923 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
7924 void exit_task_namespaces(struct task_struct *tsk);
7925 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
7926 void free_nsproxy(struct nsproxy *ns);
7927 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
7928 struct cred *, struct fs_struct *);
7929 int __init nsproxy_cache_init(void);
7931 -static inline void put_nsproxy(struct nsproxy *ns)
7932 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
7934 +static inline void __get_nsproxy(struct nsproxy *ns,
7935 + const char *_file, int _line)
7937 - if (atomic_dec_and_test(&ns->count)) {
7940 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
7941 + ns, atomic_read(&ns->count), _file, _line);
7942 + atomic_inc(&ns->count);
7945 -static inline void get_nsproxy(struct nsproxy *ns)
7946 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
7948 +static inline void __put_nsproxy(struct nsproxy *ns,
7949 + const char *_file, int _line)
7951 - atomic_inc(&ns->count);
7952 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
7953 + ns, atomic_read(&ns->count), _file, _line);
7954 + if (atomic_dec_and_test(&ns->count)) {
7960 diff -NurpP --minimal linux-3.9.4/include/linux/pid.h linux-3.9.4-vs2.3.6.3/include/linux/pid.h
7961 --- linux-3.9.4/include/linux/pid.h 2013-05-31 13:45:28.000000000 +0000
7962 +++ linux-3.9.4-vs2.3.6.3/include/linux/pid.h 2013-05-31 14:47:11.000000000 +0000
7963 @@ -8,7 +8,8 @@ enum pid_type
7973 @@ -172,6 +173,7 @@ static inline pid_t pid_nr(struct pid *p
7976 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
7977 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
7978 pid_t pid_vnr(struct pid *pid);
7980 #define do_each_pid_task(pid, type, task) \
7981 diff -NurpP --minimal linux-3.9.4/include/linux/proc_fs.h linux-3.9.4-vs2.3.6.3/include/linux/proc_fs.h
7982 --- linux-3.9.4/include/linux/proc_fs.h 2013-05-31 13:45:28.000000000 +0000
7983 +++ linux-3.9.4-vs2.3.6.3/include/linux/proc_fs.h 2013-05-31 14:47:11.000000000 +0000
7984 @@ -58,6 +58,7 @@ struct proc_dir_entry {
7990 const struct inode_operations *proc_iops;
7992 @@ -274,12 +275,18 @@ extern const struct proc_ns_operations p
7993 extern const struct proc_ns_operations userns_operations;
7994 extern const struct proc_ns_operations mntns_operations;
8000 int (*proc_get_link)(struct dentry *, struct path *);
8001 int (*proc_read)(struct task_struct *task, char *page);
8002 int (*proc_show)(struct seq_file *m,
8003 struct pid_namespace *ns, struct pid *pid,
8004 struct task_struct *task);
8005 + int (*proc_vs_read)(char *page);
8006 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8007 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8010 struct ctl_table_header;
8011 @@ -287,6 +294,7 @@ struct ctl_table;
8018 struct proc_dir_entry *pde;
8019 diff -NurpP --minimal linux-3.9.4/include/linux/quotaops.h linux-3.9.4-vs2.3.6.3/include/linux/quotaops.h
8020 --- linux-3.9.4/include/linux/quotaops.h 2012-12-11 03:30:57.000000000 +0000
8021 +++ linux-3.9.4-vs2.3.6.3/include/linux/quotaops.h 2013-05-31 14:47:11.000000000 +0000
8023 #define _LINUX_QUOTAOPS_
8025 #include <linux/fs.h>
8026 +#include <linux/vs_dlimit.h>
8028 #define DQUOT_SPACE_WARN 0x1
8029 #define DQUOT_SPACE_RESERVE 0x2
8030 @@ -205,11 +206,12 @@ static inline void dquot_drop(struct ino
8032 static inline int dquot_alloc_inode(const struct inode *inode)
8035 + return dl_alloc_inode(inode);
8038 static inline void dquot_free_inode(const struct inode *inode)
8040 + dl_free_inode(inode);
8043 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
8044 @@ -220,6 +222,10 @@ static inline int dquot_transfer(struct
8045 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
8050 + if ((ret = dl_alloc_space(inode, number)))
8052 if (!(flags & DQUOT_SPACE_RESERVE))
8053 inode_add_bytes(inode, number);
8055 @@ -230,6 +236,7 @@ static inline void __dquot_free_space(st
8057 if (!(flags & DQUOT_SPACE_RESERVE))
8058 inode_sub_bytes(inode, number);
8059 + dl_free_space(inode, number);
8062 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
8063 diff -NurpP --minimal linux-3.9.4/include/linux/sched.h linux-3.9.4-vs2.3.6.3/include/linux/sched.h
8064 --- linux-3.9.4/include/linux/sched.h 2013-05-31 14:22:27.000000000 +0000
8065 +++ linux-3.9.4-vs2.3.6.3/include/linux/sched.h 2013-06-03 17:32:54.000000000 +0000
8066 @@ -1398,6 +1398,14 @@ struct task_struct {
8068 struct seccomp seccomp;
8070 +/* vserver context data */
8071 + struct vx_info *vx_info;
8072 + struct nx_info *nx_info;
8078 /* Thread group tracking */
8081 @@ -1637,6 +1645,11 @@ struct pid_namespace;
8082 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
8083 struct pid_namespace *ns);
8085 +#include <linux/vserver/base.h>
8086 +#include <linux/vserver/context.h>
8087 +#include <linux/vserver/debug.h>
8088 +#include <linux/vserver/pid.h>
8090 static inline pid_t task_pid_nr(struct task_struct *tsk)
8093 @@ -1650,7 +1663,8 @@ static inline pid_t task_pid_nr_ns(struc
8095 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8097 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8098 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8099 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8103 @@ -1663,7 +1677,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8105 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8107 - return pid_vnr(task_tgid(tsk));
8108 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8112 diff -NurpP --minimal linux-3.9.4/include/linux/shmem_fs.h linux-3.9.4-vs2.3.6.3/include/linux/shmem_fs.h
8113 --- linux-3.9.4/include/linux/shmem_fs.h 2012-12-11 03:30:57.000000000 +0000
8114 +++ linux-3.9.4-vs2.3.6.3/include/linux/shmem_fs.h 2013-05-31 14:47:11.000000000 +0000
8117 /* inode in-kernel data */
8119 +#define TMPFS_SUPER_MAGIC 0x01021994
8122 struct shmem_inode_info {
8124 unsigned long flags;
8125 diff -NurpP --minimal linux-3.9.4/include/linux/stat.h linux-3.9.4-vs2.3.6.3/include/linux/stat.h
8126 --- linux-3.9.4/include/linux/stat.h 2012-12-11 03:30:57.000000000 +0000
8127 +++ linux-3.9.4-vs2.3.6.3/include/linux/stat.h 2013-06-01 08:53:13.000000000 +0000
8128 @@ -25,6 +25,7 @@ struct kstat {
8135 struct timespec atime;
8136 diff -NurpP --minimal linux-3.9.4/include/linux/sunrpc/auth.h linux-3.9.4-vs2.3.6.3/include/linux/sunrpc/auth.h
8137 --- linux-3.9.4/include/linux/sunrpc/auth.h 2013-05-31 13:45:28.000000000 +0000
8138 +++ linux-3.9.4-vs2.3.6.3/include/linux/sunrpc/auth.h 2013-05-31 14:52:57.000000000 +0000
8144 struct group_info *group_info;
8145 const char *principal;
8146 unsigned char machine_cred : 1;
8147 diff -NurpP --minimal linux-3.9.4/include/linux/sunrpc/clnt.h linux-3.9.4-vs2.3.6.3/include/linux/sunrpc/clnt.h
8148 --- linux-3.9.4/include/linux/sunrpc/clnt.h 2013-05-31 13:45:28.000000000 +0000
8149 +++ linux-3.9.4-vs2.3.6.3/include/linux/sunrpc/clnt.h 2013-05-31 14:47:11.000000000 +0000
8150 @@ -49,7 +49,8 @@ struct rpc_clnt {
8151 unsigned int cl_softrtry : 1,/* soft timeouts */
8152 cl_discrtry : 1,/* disconnect before retry */
8153 cl_autobind : 1,/* use getport() */
8154 - cl_chatty : 1;/* be verbose */
8155 + cl_chatty : 1,/* be verbose */
8156 + cl_tag : 1;/* context tagging */
8158 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8159 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8160 diff -NurpP --minimal linux-3.9.4/include/linux/sysfs.h linux-3.9.4-vs2.3.6.3/include/linux/sysfs.h
8161 --- linux-3.9.4/include/linux/sysfs.h 2013-05-31 13:45:28.000000000 +0000
8162 +++ linux-3.9.4-vs2.3.6.3/include/linux/sysfs.h 2013-05-31 14:47:11.000000000 +0000
8164 #include <linux/kobject_ns.h>
8165 #include <linux/atomic.h>
8167 +#define SYSFS_SUPER_MAGIC 0x62656572
8172 diff -NurpP --minimal linux-3.9.4/include/linux/types.h linux-3.9.4-vs2.3.6.3/include/linux/types.h
8173 --- linux-3.9.4/include/linux/types.h 2013-02-19 13:58:52.000000000 +0000
8174 +++ linux-3.9.4-vs2.3.6.3/include/linux/types.h 2013-05-31 14:47:11.000000000 +0000
8175 @@ -32,6 +32,9 @@ typedef __kernel_uid32_t uid_t;
8176 typedef __kernel_gid32_t gid_t;
8177 typedef __kernel_uid16_t uid16_t;
8178 typedef __kernel_gid16_t gid16_t;
8179 +typedef unsigned int xid_t;
8180 +typedef unsigned int nid_t;
8181 +typedef unsigned int tag_t;
8183 typedef unsigned long uintptr_t;
8185 diff -NurpP --minimal linux-3.9.4/include/linux/uidgid.h linux-3.9.4-vs2.3.6.3/include/linux/uidgid.h
8186 --- linux-3.9.4/include/linux/uidgid.h 2012-12-11 03:30:57.000000000 +0000
8187 +++ linux-3.9.4-vs2.3.6.3/include/linux/uidgid.h 2013-05-31 14:47:11.000000000 +0000
8188 @@ -23,13 +23,17 @@ typedef struct {
8201 #define KUIDT_INIT(value) (kuid_t){ value }
8202 #define KGIDT_INIT(value) (kgid_t){ value }
8203 +#define KTAGT_INIT(value) (ktag_t){ value }
8205 static inline uid_t __kuid_val(kuid_t uid)
8207 @@ -41,10 +45,16 @@ static inline gid_t __kgid_val(kgid_t gi
8211 +static inline tag_t __ktag_val(ktag_t tag)
8218 typedef uid_t kuid_t;
8219 typedef gid_t kgid_t;
8220 +typedef tag_t ktag_t;
8222 static inline uid_t __kuid_val(kuid_t uid)
8224 @@ -56,16 +66,24 @@ static inline gid_t __kgid_val(kgid_t gi
8228 +static inline tag_t __ktag_val(ktag_t tag)
8233 #define KUIDT_INIT(value) ((kuid_t) value )
8234 #define KGIDT_INIT(value) ((kgid_t) value )
8235 +#define KTAGT_INIT(value) ((ktag_t) value )
8239 #define GLOBAL_ROOT_UID KUIDT_INIT(0)
8240 #define GLOBAL_ROOT_GID KGIDT_INIT(0)
8241 +#define GLOBAL_ROOT_TAG KTAGT_INIT(0)
8243 #define INVALID_UID KUIDT_INIT(-1)
8244 #define INVALID_GID KGIDT_INIT(-1)
8245 +#define INVALID_TAG KTAGT_INIT(-1)
8247 static inline bool uid_eq(kuid_t left, kuid_t right)
8249 @@ -77,6 +95,11 @@ static inline bool gid_eq(kgid_t left, k
8250 return __kgid_val(left) == __kgid_val(right);
8253 +static inline bool tag_eq(ktag_t left, ktag_t right)
8255 + return __ktag_val(left) == __ktag_val(right);
8258 static inline bool uid_gt(kuid_t left, kuid_t right)
8260 return __kuid_val(left) > __kuid_val(right);
8261 @@ -127,13 +150,21 @@ static inline bool gid_valid(kgid_t gid)
8262 return !gid_eq(gid, INVALID_GID);
8265 +static inline bool tag_valid(ktag_t tag)
8267 + return !tag_eq(tag, INVALID_TAG);
8270 #ifdef CONFIG_USER_NS
8272 extern kuid_t make_kuid(struct user_namespace *from, uid_t uid);
8273 extern kgid_t make_kgid(struct user_namespace *from, gid_t gid);
8274 +extern krag_t make_ktag(struct user_namespace *from, gid_t gid);
8276 extern uid_t from_kuid(struct user_namespace *to, kuid_t uid);
8277 extern gid_t from_kgid(struct user_namespace *to, kgid_t gid);
8278 +extern tag_t from_ktag(struct user_namespace *to, ktag_t tag);
8280 extern uid_t from_kuid_munged(struct user_namespace *to, kuid_t uid);
8281 extern gid_t from_kgid_munged(struct user_namespace *to, kgid_t gid);
8283 @@ -159,6 +190,11 @@ static inline kgid_t make_kgid(struct us
8284 return KGIDT_INIT(gid);
8287 +static inline ktag_t make_ktag(struct user_namespace *from, tag_t tag)
8289 + return KTAGT_INIT(tag);
8292 static inline uid_t from_kuid(struct user_namespace *to, kuid_t kuid)
8294 return __kuid_val(kuid);
8295 @@ -169,6 +205,11 @@ static inline gid_t from_kgid(struct use
8296 return __kgid_val(kgid);
8299 +static inline tag_t from_ktag(struct user_namespace *to, ktag_t ktag)
8301 + return __ktag_val(ktag);
8304 static inline uid_t from_kuid_munged(struct user_namespace *to, kuid_t kuid)
8306 uid_t uid = from_kuid(to, kuid);
8307 diff -NurpP --minimal linux-3.9.4/include/linux/vroot.h linux-3.9.4-vs2.3.6.3/include/linux/vroot.h
8308 --- linux-3.9.4/include/linux/vroot.h 1970-01-01 00:00:00.000000000 +0000
8309 +++ linux-3.9.4-vs2.3.6.3/include/linux/vroot.h 2013-05-31 14:47:11.000000000 +0000
8313 + * include/linux/vroot.h
8315 + * written by Herbert Pötzl, 9/11/2002
8316 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
8318 + * Copyright (C) 2002-2007 by Herbert Pötzl.
8319 + * Redistribution of this file is permitted under the
8320 + * GNU General Public License.
8323 +#ifndef _LINUX_VROOT_H
8324 +#define _LINUX_VROOT_H
8329 +/* Possible states of device */
8335 +struct vroot_device {
8339 + struct semaphore vr_ctl_mutex;
8340 + struct block_device *vr_device;
8345 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
8347 +extern int register_vroot_grb(vroot_grb_func *);
8348 +extern int unregister_vroot_grb(vroot_grb_func *);
8350 +#endif /* __KERNEL__ */
8352 +#define MAX_VROOT_DEFAULT 8
8355 + * IOCTL commands --- we will commandeer 0x56 ('V')
8358 +#define VROOT_SET_DEV 0x5600
8359 +#define VROOT_CLR_DEV 0x5601
8361 +#endif /* _LINUX_VROOT_H */
8362 diff -NurpP --minimal linux-3.9.4/include/linux/vs_base.h linux-3.9.4-vs2.3.6.3/include/linux/vs_base.h
8363 --- linux-3.9.4/include/linux/vs_base.h 1970-01-01 00:00:00.000000000 +0000
8364 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_base.h 2013-05-31 14:47:11.000000000 +0000
8369 +#include "vserver/base.h"
8370 +#include "vserver/check.h"
8371 +#include "vserver/debug.h"
8374 +#warning duplicate inclusion
8376 diff -NurpP --minimal linux-3.9.4/include/linux/vs_context.h linux-3.9.4-vs2.3.6.3/include/linux/vs_context.h
8377 --- linux-3.9.4/include/linux/vs_context.h 1970-01-01 00:00:00.000000000 +0000
8378 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_context.h 2013-05-31 14:47:11.000000000 +0000
8380 +#ifndef _VS_CONTEXT_H
8381 +#define _VS_CONTEXT_H
8383 +#include "vserver/base.h"
8384 +#include "vserver/check.h"
8385 +#include "vserver/context.h"
8386 +#include "vserver/history.h"
8387 +#include "vserver/debug.h"
8389 +#include <linux/sched.h>
8392 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
8394 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
8395 + const char *_file, int _line, void *_here)
8400 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
8401 + vxi, vxi ? vxi->vx_id : 0,
8402 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8404 + __vxh_get_vx_info(vxi, _here);
8406 + atomic_inc(&vxi->vx_usecnt);
8411 +extern void free_vx_info(struct vx_info *);
8413 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
8415 +static inline void __put_vx_info(struct vx_info *vxi,
8416 + const char *_file, int _line, void *_here)
8421 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
8422 + vxi, vxi ? vxi->vx_id : 0,
8423 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8425 + __vxh_put_vx_info(vxi, _here);
8427 + if (atomic_dec_and_test(&vxi->vx_usecnt))
8428 + free_vx_info(vxi);
8432 +#define init_vx_info(p, i) \
8433 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8435 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8436 + const char *_file, int _line, void *_here)
8439 + vxlprintk(VXD_CBIT(xid, 3),
8440 + "init_vx_info(%p[#%d.%d])",
8441 + vxi, vxi ? vxi->vx_id : 0,
8442 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8444 + __vxh_init_vx_info(vxi, vxp, _here);
8446 + atomic_inc(&vxi->vx_usecnt);
8452 +#define set_vx_info(p, i) \
8453 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8455 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8456 + const char *_file, int _line, void *_here)
8458 + struct vx_info *vxo;
8463 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
8464 + vxi, vxi ? vxi->vx_id : 0,
8465 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8467 + __vxh_set_vx_info(vxi, vxp, _here);
8469 + atomic_inc(&vxi->vx_usecnt);
8470 + vxo = xchg(vxp, vxi);
8475 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
8477 +static inline void __clr_vx_info(struct vx_info **vxp,
8478 + const char *_file, int _line, void *_here)
8480 + struct vx_info *vxo;
8482 + vxo = xchg(vxp, NULL);
8486 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
8487 + vxo, vxo ? vxo->vx_id : 0,
8488 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
8490 + __vxh_clr_vx_info(vxo, vxp, _here);
8492 + if (atomic_dec_and_test(&vxo->vx_usecnt))
8493 + free_vx_info(vxo);
8497 +#define claim_vx_info(v, p) \
8498 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
8500 +static inline void __claim_vx_info(struct vx_info *vxi,
8501 + struct task_struct *task,
8502 + const char *_file, int _line, void *_here)
8504 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
8505 + vxi, vxi ? vxi->vx_id : 0,
8506 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8507 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
8508 + task, _file, _line);
8509 + __vxh_claim_vx_info(vxi, task, _here);
8511 + atomic_inc(&vxi->vx_tasks);
8515 +extern void unhash_vx_info(struct vx_info *);
8517 +#define release_vx_info(v, p) \
8518 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
8520 +static inline void __release_vx_info(struct vx_info *vxi,
8521 + struct task_struct *task,
8522 + const char *_file, int _line, void *_here)
8524 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
8525 + vxi, vxi ? vxi->vx_id : 0,
8526 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8527 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
8528 + task, _file, _line);
8529 + __vxh_release_vx_info(vxi, task, _here);
8533 + if (atomic_dec_and_test(&vxi->vx_tasks))
8534 + unhash_vx_info(vxi);
8538 +#define task_get_vx_info(p) \
8539 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
8541 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
8542 + const char *_file, int _line, void *_here)
8544 + struct vx_info *vxi;
8547 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
8549 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
8555 +static inline void __wakeup_vx_info(struct vx_info *vxi)
8557 + if (waitqueue_active(&vxi->vx_wait))
8558 + wake_up_interruptible(&vxi->vx_wait);
8562 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
8564 +static inline void __enter_vx_info(struct vx_info *vxi,
8565 + struct vx_info_save *vxis, const char *_file, int _line)
8567 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
8568 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
8569 + current->xid, current->vx_info, _file, _line);
8570 + vxis->vxi = xchg(¤t->vx_info, vxi);
8571 + vxis->xid = current->xid;
8572 + current->xid = vxi ? vxi->vx_id : 0;
8575 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
8577 +static inline void __leave_vx_info(struct vx_info_save *vxis,
8578 + const char *_file, int _line)
8580 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
8581 + vxis, vxis->xid, vxis->vxi, current,
8582 + current->xid, current->vx_info, _file, _line);
8583 + (void)xchg(¤t->vx_info, vxis->vxi);
8584 + current->xid = vxis->xid;
8588 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
8590 + vxis->vxi = xchg(¤t->vx_info, NULL);
8591 + vxis->xid = xchg(¤t->xid, (xid_t)0);
8594 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
8596 + (void)xchg(¤t->xid, vxis->xid);
8597 + (void)xchg(¤t->vx_info, vxis->vxi);
8600 +#define task_is_init(p) \
8601 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
8603 +static inline int __task_is_init(struct task_struct *p,
8604 + const char *_file, int _line, void *_here)
8606 + int is_init = is_global_init(p);
8610 + is_init = p->vx_info->vx_initpid == p->pid;
8615 +extern void exit_vx_info(struct task_struct *, int);
8616 +extern void exit_vx_info_early(struct task_struct *, int);
8620 +#warning duplicate inclusion
8622 diff -NurpP --minimal linux-3.9.4/include/linux/vs_cowbl.h linux-3.9.4-vs2.3.6.3/include/linux/vs_cowbl.h
8623 --- linux-3.9.4/include/linux/vs_cowbl.h 1970-01-01 00:00:00.000000000 +0000
8624 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_cowbl.h 2013-05-31 14:47:11.000000000 +0000
8626 +#ifndef _VS_COWBL_H
8627 +#define _VS_COWBL_H
8629 +#include <linux/fs.h>
8630 +#include <linux/dcache.h>
8631 +#include <linux/namei.h>
8632 +#include <linux/slab.h>
8634 +extern struct dentry *cow_break_link(const char *pathname);
8636 +static inline int cow_check_and_break(struct path *path)
8638 + struct inode *inode = path->dentry->d_inode;
8641 + /* do we need this check? */
8642 + if (IS_RDONLY(inode))
8645 + if (IS_COW(inode)) {
8646 + if (IS_COW_LINK(inode)) {
8647 + struct dentry *new_dentry, *old_dentry = path->dentry;
8650 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
8654 + pp = d_path(path, buf, PATH_MAX);
8655 + new_dentry = cow_break_link(pp);
8657 + if (!IS_ERR(new_dentry)) {
8658 + path->dentry = new_dentry;
8661 + error = PTR_ERR(new_dentry);
8663 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
8664 + inode->i_ctime = CURRENT_TIME;
8665 + mark_inode_dirty(inode);
8672 +#warning duplicate inclusion
8674 diff -NurpP --minimal linux-3.9.4/include/linux/vs_cvirt.h linux-3.9.4-vs2.3.6.3/include/linux/vs_cvirt.h
8675 --- linux-3.9.4/include/linux/vs_cvirt.h 1970-01-01 00:00:00.000000000 +0000
8676 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_cvirt.h 2013-05-31 14:47:11.000000000 +0000
8678 +#ifndef _VS_CVIRT_H
8679 +#define _VS_CVIRT_H
8681 +#include "vserver/cvirt.h"
8682 +#include "vserver/context.h"
8683 +#include "vserver/base.h"
8684 +#include "vserver/check.h"
8685 +#include "vserver/debug.h"
8688 +static inline void vx_activate_task(struct task_struct *p)
8690 + struct vx_info *vxi;
8692 + if ((vxi = p->vx_info)) {
8693 + vx_update_load(vxi);
8694 + atomic_inc(&vxi->cvirt.nr_running);
8698 +static inline void vx_deactivate_task(struct task_struct *p)
8700 + struct vx_info *vxi;
8702 + if ((vxi = p->vx_info)) {
8703 + vx_update_load(vxi);
8704 + atomic_dec(&vxi->cvirt.nr_running);
8708 +static inline void vx_uninterruptible_inc(struct task_struct *p)
8710 + struct vx_info *vxi;
8712 + if ((vxi = p->vx_info))
8713 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
8716 +static inline void vx_uninterruptible_dec(struct task_struct *p)
8718 + struct vx_info *vxi;
8720 + if ((vxi = p->vx_info))
8721 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
8726 +#warning duplicate inclusion
8728 diff -NurpP --minimal linux-3.9.4/include/linux/vs_device.h linux-3.9.4-vs2.3.6.3/include/linux/vs_device.h
8729 --- linux-3.9.4/include/linux/vs_device.h 1970-01-01 00:00:00.000000000 +0000
8730 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_device.h 2013-05-31 14:47:11.000000000 +0000
8732 +#ifndef _VS_DEVICE_H
8733 +#define _VS_DEVICE_H
8735 +#include "vserver/base.h"
8736 +#include "vserver/device.h"
8737 +#include "vserver/debug.h"
8740 +#ifdef CONFIG_VSERVER_DEVICE
8742 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
8744 +#define vs_device_perm(v, d, m, p) \
8745 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
8750 +int vs_map_device(struct vx_info *vxi,
8751 + dev_t device, dev_t *target, umode_t mode)
8758 +#define vs_device_perm(v, d, m, p) ((p) == (p))
8763 +#define vs_map_chrdev(d, t, p) \
8764 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
8765 +#define vs_map_blkdev(d, t, p) \
8766 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
8768 +#define vs_chrdev_perm(d, p) \
8769 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
8770 +#define vs_blkdev_perm(d, p) \
8771 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
8775 +#warning duplicate inclusion
8777 diff -NurpP --minimal linux-3.9.4/include/linux/vs_dlimit.h linux-3.9.4-vs2.3.6.3/include/linux/vs_dlimit.h
8778 --- linux-3.9.4/include/linux/vs_dlimit.h 1970-01-01 00:00:00.000000000 +0000
8779 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_dlimit.h 2013-05-31 14:47:11.000000000 +0000
8781 +#ifndef _VS_DLIMIT_H
8782 +#define _VS_DLIMIT_H
8784 +#include <linux/fs.h>
8786 +#include "vserver/dlimit.h"
8787 +#include "vserver/base.h"
8788 +#include "vserver/debug.h"
8791 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
8793 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
8794 + const char *_file, int _line)
8798 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
8799 + dli, dli ? dli->dl_tag : 0,
8800 + dli ? atomic_read(&dli->dl_usecnt) : 0,
8802 + atomic_inc(&dli->dl_usecnt);
8807 +#define free_dl_info(i) \
8808 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
8810 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
8812 +static inline void __put_dl_info(struct dl_info *dli,
8813 + const char *_file, int _line)
8817 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
8818 + dli, dli ? dli->dl_tag : 0,
8819 + dli ? atomic_read(&dli->dl_usecnt) : 0,
8821 + if (atomic_dec_and_test(&dli->dl_usecnt))
8822 + free_dl_info(dli);
8826 +#define __dlimit_char(d) ((d) ? '*' : ' ')
8828 +static inline int __dl_alloc_space(struct super_block *sb,
8829 + tag_t tag, dlsize_t nr, const char *file, int line)
8831 + struct dl_info *dli = NULL;
8836 + dli = locate_dl_info(sb, tag);
8840 + spin_lock(&dli->dl_lock);
8841 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
8843 + dli->dl_space_used += nr;
8844 + spin_unlock(&dli->dl_lock);
8847 + vxlprintk(VXD_CBIT(dlim, 1),
8848 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
8849 + sb, tag, __dlimit_char(dli), (long long)nr,
8851 + return ret ? -ENOSPC : 0;
8854 +static inline void __dl_free_space(struct super_block *sb,
8855 + tag_t tag, dlsize_t nr, const char *_file, int _line)
8857 + struct dl_info *dli = NULL;
8861 + dli = locate_dl_info(sb, tag);
8865 + spin_lock(&dli->dl_lock);
8866 + if (dli->dl_space_used > nr)
8867 + dli->dl_space_used -= nr;
8869 + dli->dl_space_used = 0;
8870 + spin_unlock(&dli->dl_lock);
8873 + vxlprintk(VXD_CBIT(dlim, 1),
8874 + "FREE (%p,#%d)%c %lld bytes",
8875 + sb, tag, __dlimit_char(dli), (long long)nr,
8879 +static inline int __dl_alloc_inode(struct super_block *sb,
8880 + tag_t tag, const char *_file, int _line)
8882 + struct dl_info *dli;
8885 + dli = locate_dl_info(sb, tag);
8889 + spin_lock(&dli->dl_lock);
8890 + dli->dl_inodes_used++;
8891 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
8892 + spin_unlock(&dli->dl_lock);
8895 + vxlprintk(VXD_CBIT(dlim, 0),
8896 + "ALLOC (%p,#%d)%c inode (%d)",
8897 + sb, tag, __dlimit_char(dli), ret, _file, _line);
8898 + return ret ? -ENOSPC : 0;
8901 +static inline void __dl_free_inode(struct super_block *sb,
8902 + tag_t tag, const char *_file, int _line)
8904 + struct dl_info *dli;
8906 + dli = locate_dl_info(sb, tag);
8910 + spin_lock(&dli->dl_lock);
8911 + if (dli->dl_inodes_used > 1)
8912 + dli->dl_inodes_used--;
8914 + dli->dl_inodes_used = 0;
8915 + spin_unlock(&dli->dl_lock);
8918 + vxlprintk(VXD_CBIT(dlim, 0),
8919 + "FREE (%p,#%d)%c inode",
8920 + sb, tag, __dlimit_char(dli), _file, _line);
8923 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
8924 + unsigned long long *free_blocks, unsigned long long *root_blocks,
8925 + const char *_file, int _line)
8927 + struct dl_info *dli;
8928 + uint64_t broot, bfree;
8930 + dli = locate_dl_info(sb, tag);
8934 + spin_lock(&dli->dl_lock);
8935 + broot = (dli->dl_space_total -
8936 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
8937 + >> sb->s_blocksize_bits;
8938 + bfree = (dli->dl_space_total - dli->dl_space_used)
8939 + >> sb->s_blocksize_bits;
8940 + spin_unlock(&dli->dl_lock);
8942 + vxlprintk(VXD_CBIT(dlim, 2),
8943 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
8944 + (long long)bfree, (long long)broot,
8945 + *free_blocks, *root_blocks, dli->dl_nrlmult,
8947 + if (free_blocks) {
8948 + if (*free_blocks > bfree)
8949 + *free_blocks = bfree;
8951 + if (root_blocks) {
8952 + if (*root_blocks > broot)
8953 + *root_blocks = broot;
8958 +#define dl_prealloc_space(in, bytes) \
8959 + __dl_alloc_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8960 + __FILE__, __LINE__ )
8962 +#define dl_alloc_space(in, bytes) \
8963 + __dl_alloc_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8964 + __FILE__, __LINE__ )
8966 +#define dl_reserve_space(in, bytes) \
8967 + __dl_alloc_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8968 + __FILE__, __LINE__ )
8970 +#define dl_claim_space(in, bytes) (0)
8972 +#define dl_release_space(in, bytes) \
8973 + __dl_free_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8974 + __FILE__, __LINE__ )
8976 +#define dl_free_space(in, bytes) \
8977 + __dl_free_space((in)->i_sb, i_tag_read(in), (dlsize_t)(bytes), \
8978 + __FILE__, __LINE__ )
8982 +#define dl_alloc_inode(in) \
8983 + __dl_alloc_inode((in)->i_sb, i_tag_read(in), __FILE__, __LINE__ )
8985 +#define dl_free_inode(in) \
8986 + __dl_free_inode((in)->i_sb, i_tag_read(in), __FILE__, __LINE__ )
8989 +#define dl_adjust_block(sb, tag, fb, rb) \
8990 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
8994 +#warning duplicate inclusion
8996 diff -NurpP --minimal linux-3.9.4/include/linux/vs_inet.h linux-3.9.4-vs2.3.6.3/include/linux/vs_inet.h
8997 --- linux-3.9.4/include/linux/vs_inet.h 1970-01-01 00:00:00.000000000 +0000
8998 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_inet.h 2013-05-31 14:47:11.000000000 +0000
9003 +#include "vserver/base.h"
9004 +#include "vserver/network.h"
9005 +#include "vserver/debug.h"
9007 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
9009 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
9010 + NIPQUAD((a)->mask), (a)->type
9011 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
9013 +#define NIPQUAD(addr) \
9014 + ((unsigned char *)&addr)[0], \
9015 + ((unsigned char *)&addr)[1], \
9016 + ((unsigned char *)&addr)[2], \
9017 + ((unsigned char *)&addr)[3]
9019 +#define NIPQUAD_FMT "%u.%u.%u.%u"
9023 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
9025 + __be32 ip = nxa->ip[0].s_addr;
9026 + __be32 mask = nxa->mask.s_addr;
9027 + __be32 bcast = ip | ~mask;
9030 + switch (nxa->type & tmask) {
9031 + case NXA_TYPE_MASK:
9032 + ret = (ip == (addr & mask));
9034 + case NXA_TYPE_ADDR:
9038 + /* fall through to broadcast */
9039 + case NXA_MOD_BCAST:
9040 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
9042 + case NXA_TYPE_RANGE:
9043 + ret = ((nxa->ip[0].s_addr <= addr) &&
9044 + (nxa->ip[1].s_addr > addr));
9046 + case NXA_TYPE_ANY:
9051 + vxdprintk(VXD_CBIT(net, 0),
9052 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
9053 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
9058 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
9060 + struct nx_addr_v4 *nxa;
9061 + unsigned long irqflags;
9068 + /* allow 127.0.0.1 when remapping lback */
9069 + if ((tmask & NXA_LOOPBACK) &&
9070 + (addr == IPI_LOOPBACK) &&
9071 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9074 + /* check for lback address */
9075 + if ((tmask & NXA_MOD_LBACK) &&
9076 + (nxi->v4_lback.s_addr == addr))
9079 + /* check for broadcast address */
9080 + if ((tmask & NXA_MOD_BCAST) &&
9081 + (nxi->v4_bcast.s_addr == addr))
9085 + /* check for v4 addresses */
9086 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9087 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9088 + if (v4_addr_match(nxa, addr, tmask))
9092 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9094 + vxdprintk(VXD_CBIT(net, 0),
9095 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9096 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9101 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9103 + /* FIXME: needs full range checks */
9104 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9108 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9110 + struct nx_addr_v4 *ptr;
9111 + unsigned long irqflags;
9114 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9115 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9116 + if (v4_nx_addr_match(ptr, nxa, mask))
9120 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9124 +#include <net/inet_sock.h>
9127 + * Check if a given address matches for a socket
9129 + * nxi: the socket's nx_info if any
9130 + * addr: to be verified address
9133 +int v4_sock_addr_match (
9134 + struct nx_info *nxi,
9135 + struct inet_sock *inet,
9138 + __be32 saddr = inet->inet_rcv_saddr;
9139 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9141 + if (addr && (saddr == addr || bcast == addr))
9144 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9149 +/* inet related checks and helpers */
9158 +#include <linux/netdevice.h>
9159 +#include <linux/inetdevice.h>
9160 +#include <net/inet_sock.h>
9161 +#include <net/inet_timewait_sock.h>
9164 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9165 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9166 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9170 + * check if address is covered by socket
9172 + * sk: the socket to check against
9173 + * addr: the address in question (must be != 0)
9177 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9179 + struct nx_info *nxi = sk->sk_nx_info;
9180 + __be32 saddr = sk_rcv_saddr(sk);
9182 + vxdprintk(VXD_CBIT(net, 5),
9183 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9184 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9185 + (sk->sk_socket?sk->sk_socket->flags:0));
9187 + if (saddr) { /* direct address match */
9188 + return v4_addr_match(nxa, saddr, -1);
9189 + } else if (nxi) { /* match against nx_info */
9190 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9191 + } else { /* unrestricted any socket */
9199 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9201 + vxdprintk(VXD_CBIT(net, 1),
9202 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9203 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9204 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9206 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9208 + if (dev_in_nx_info(dev, nxi))
9215 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9221 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9225 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
9227 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
9228 + nxi, nxi ? nxi->nx_id : 0, ifa,
9229 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
9231 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9233 + if (v4_ifa_in_nx_info(ifa, nxi))
9239 +struct nx_v4_sock_addr {
9240 + __be32 saddr; /* Address used for validation */
9241 + __be32 baddr; /* Address used for socket bind */
9245 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
9246 + struct nx_v4_sock_addr *nsa)
9248 + struct sock *sk = &inet->sk;
9249 + struct nx_info *nxi = sk->sk_nx_info;
9250 + __be32 saddr = addr->sin_addr.s_addr;
9251 + __be32 baddr = saddr;
9253 + vxdprintk(VXD_CBIT(net, 3),
9254 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
9255 + sk, sk->sk_nx_info, sk->sk_socket,
9256 + (sk->sk_socket ? sk->sk_socket->flags : 0),
9260 + if (saddr == INADDR_ANY) {
9261 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
9262 + baddr = nxi->v4.ip[0].s_addr;
9263 + } else if (saddr == IPI_LOOPBACK) {
9264 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9265 + baddr = nxi->v4_lback.s_addr;
9266 + } else if (!ipv4_is_multicast(saddr) ||
9267 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
9268 + /* normal address bind */
9269 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
9270 + return -EADDRNOTAVAIL;
9274 + vxdprintk(VXD_CBIT(net, 3),
9275 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
9276 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
9278 + nsa->saddr = saddr;
9279 + nsa->baddr = baddr;
9284 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
9286 + inet->inet_saddr = nsa->baddr;
9287 + inet->inet_rcv_saddr = nsa->baddr;
9292 + * helper to simplify inet_lookup_listener
9294 + * nxi: the socket's nx_info if any
9295 + * addr: to be verified address
9296 + * saddr: socket address
9298 +static inline int v4_inet_addr_match (
9299 + struct nx_info *nxi,
9303 + if (addr && (saddr == addr))
9306 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
9310 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
9312 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
9313 + (addr == nxi->v4_lback.s_addr))
9314 + return IPI_LOOPBACK;
9319 +int nx_info_has_v4(struct nx_info *nxi)
9325 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9330 +#else /* CONFIG_INET */
9333 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
9339 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9345 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9351 +int nx_info_has_v4(struct nx_info *nxi)
9356 +#endif /* CONFIG_INET */
9358 +#define current_nx_info_has_v4() \
9359 + nx_info_has_v4(current_nx_info())
9362 +// #warning duplicate inclusion
9364 diff -NurpP --minimal linux-3.9.4/include/linux/vs_inet6.h linux-3.9.4-vs2.3.6.3/include/linux/vs_inet6.h
9365 --- linux-3.9.4/include/linux/vs_inet6.h 1970-01-01 00:00:00.000000000 +0000
9366 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_inet6.h 2013-05-31 14:47:11.000000000 +0000
9368 +#ifndef _VS_INET6_H
9369 +#define _VS_INET6_H
9371 +#include "vserver/base.h"
9372 +#include "vserver/network.h"
9373 +#include "vserver/debug.h"
9375 +#include <net/ipv6.h>
9377 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
9378 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
9384 +int v6_addr_match(struct nx_addr_v6 *nxa,
9385 + const struct in6_addr *addr, uint16_t mask)
9389 + switch (nxa->type & mask) {
9390 + case NXA_TYPE_MASK:
9391 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
9393 + case NXA_TYPE_ADDR:
9394 + ret = ipv6_addr_equal(&nxa->ip, addr);
9396 + case NXA_TYPE_ANY:
9400 + vxdprintk(VXD_CBIT(net, 0),
9401 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
9402 + nxa, NXAV6(nxa), addr, mask, ret);
9407 +int v6_addr_in_nx_info(struct nx_info *nxi,
9408 + const struct in6_addr *addr, uint16_t mask)
9410 + struct nx_addr_v6 *nxa;
9411 + unsigned long irqflags;
9417 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9418 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
9419 + if (v6_addr_match(nxa, addr, mask))
9423 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9425 + vxdprintk(VXD_CBIT(net, 0),
9426 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
9427 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
9432 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
9434 + /* FIXME: needs full range checks */
9435 + return v6_addr_match(nxa, &addr->ip, mask);
9439 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
9441 + struct nx_addr_v6 *ptr;
9442 + unsigned long irqflags;
9445 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
9446 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
9447 + if (v6_nx_addr_match(ptr, nxa, mask))
9451 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
9457 + * Check if a given address matches for a socket
9459 + * nxi: the socket's nx_info if any
9460 + * addr: to be verified address
9463 +int v6_sock_addr_match (
9464 + struct nx_info *nxi,
9465 + struct inet_sock *inet,
9466 + struct in6_addr *addr)
9468 + struct sock *sk = &inet->sk;
9469 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9471 + if (!ipv6_addr_any(addr) &&
9472 + ipv6_addr_equal(saddr, addr))
9474 + if (ipv6_addr_any(saddr))
9475 + return v6_addr_in_nx_info(nxi, addr, -1);
9480 + * check if address is covered by socket
9482 + * sk: the socket to check against
9483 + * addr: the address in question (must be != 0)
9487 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
9489 + struct nx_info *nxi = sk->sk_nx_info;
9490 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9492 + vxdprintk(VXD_CBIT(net, 5),
9493 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
9494 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
9495 + (sk->sk_socket?sk->sk_socket->flags:0));
9497 + if (!ipv6_addr_any(saddr)) { /* direct address match */
9498 + return v6_addr_match(nxa, saddr, -1);
9499 + } else if (nxi) { /* match against nx_info */
9500 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
9501 + } else { /* unrestricted any socket */
9507 +/* inet related checks and helpers */
9515 +#include <linux/netdevice.h>
9516 +#include <linux/inetdevice.h>
9517 +#include <net/inet_timewait_sock.h>
9520 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9521 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
9522 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
9527 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
9533 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
9537 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
9539 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
9540 + nxi, nxi ? nxi->nx_id : 0, ifa,
9541 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
9543 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9545 + if (v6_ifa_in_nx_info(ifa, nxi))
9551 +struct nx_v6_sock_addr {
9552 + struct in6_addr saddr; /* Address used for validation */
9553 + struct in6_addr baddr; /* Address used for socket bind */
9557 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
9558 + struct nx_v6_sock_addr *nsa)
9560 + // struct sock *sk = &inet->sk;
9561 + // struct nx_info *nxi = sk->sk_nx_info;
9562 + struct in6_addr saddr = addr->sin6_addr;
9563 + struct in6_addr baddr = saddr;
9565 + nsa->saddr = saddr;
9566 + nsa->baddr = baddr;
9571 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
9573 + // struct sock *sk = &inet->sk;
9574 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
9576 + // *saddr = nsa->baddr;
9577 + // inet->inet_saddr = nsa->baddr;
9581 +int nx_info_has_v6(struct nx_info *nxi)
9590 +#else /* CONFIG_IPV6 */
9593 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
9600 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9606 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9612 +int nx_info_has_v6(struct nx_info *nxi)
9617 +#endif /* CONFIG_IPV6 */
9619 +#define current_nx_info_has_v6() \
9620 + nx_info_has_v6(current_nx_info())
9623 +#warning duplicate inclusion
9625 diff -NurpP --minimal linux-3.9.4/include/linux/vs_limit.h linux-3.9.4-vs2.3.6.3/include/linux/vs_limit.h
9626 --- linux-3.9.4/include/linux/vs_limit.h 1970-01-01 00:00:00.000000000 +0000
9627 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_limit.h 2013-05-31 14:47:11.000000000 +0000
9629 +#ifndef _VS_LIMIT_H
9630 +#define _VS_LIMIT_H
9632 +#include "vserver/limit.h"
9633 +#include "vserver/base.h"
9634 +#include "vserver/context.h"
9635 +#include "vserver/debug.h"
9636 +#include "vserver/context.h"
9637 +#include "vserver/limit_int.h"
9640 +#define vx_acc_cres(v, d, p, r) \
9641 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
9643 +#define vx_acc_cres_cond(x, d, p, r) \
9644 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
9645 + r, d, p, __FILE__, __LINE__)
9648 +#define vx_add_cres(v, a, p, r) \
9649 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
9650 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
9652 +#define vx_add_cres_cond(x, a, p, r) \
9653 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
9654 + r, a, p, __FILE__, __LINE__)
9655 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
9658 +/* process and file limits */
9660 +#define vx_nproc_inc(p) \
9661 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
9663 +#define vx_nproc_dec(p) \
9664 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
9666 +#define vx_files_inc(f) \
9667 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
9669 +#define vx_files_dec(f) \
9670 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
9672 +#define vx_locks_inc(l) \
9673 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
9675 +#define vx_locks_dec(l) \
9676 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
9678 +#define vx_openfd_inc(f) \
9679 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
9681 +#define vx_openfd_dec(f) \
9682 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
9685 +#define vx_cres_avail(v, n, r) \
9686 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
9689 +#define vx_nproc_avail(n) \
9690 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
9692 +#define vx_files_avail(n) \
9693 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
9695 +#define vx_locks_avail(n) \
9696 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
9698 +#define vx_openfd_avail(n) \
9699 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
9702 +/* dentry limits */
9704 +#define vx_dentry_inc(d) do { \
9705 + if ((d)->d_count == 1) \
9706 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
9709 +#define vx_dentry_dec(d) do { \
9710 + if ((d)->d_count == 0) \
9711 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
9714 +#define vx_dentry_avail(n) \
9715 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
9718 +/* socket limits */
9720 +#define vx_sock_inc(s) \
9721 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
9723 +#define vx_sock_dec(s) \
9724 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
9726 +#define vx_sock_avail(n) \
9727 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
9730 +/* ipc resource limits */
9732 +#define vx_ipcmsg_add(v, u, a) \
9733 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
9735 +#define vx_ipcmsg_sub(v, u, a) \
9736 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
9738 +#define vx_ipcmsg_avail(v, a) \
9739 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
9742 +#define vx_ipcshm_add(v, k, a) \
9743 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
9745 +#define vx_ipcshm_sub(v, k, a) \
9746 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
9748 +#define vx_ipcshm_avail(v, a) \
9749 + vx_cres_avail(v, a, VLIMIT_SHMEM)
9752 +#define vx_semary_inc(a) \
9753 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
9755 +#define vx_semary_dec(a) \
9756 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
9759 +#define vx_nsems_add(a,n) \
9760 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
9762 +#define vx_nsems_sub(a,n) \
9763 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
9767 +#warning duplicate inclusion
9769 diff -NurpP --minimal linux-3.9.4/include/linux/vs_network.h linux-3.9.4-vs2.3.6.3/include/linux/vs_network.h
9770 --- linux-3.9.4/include/linux/vs_network.h 1970-01-01 00:00:00.000000000 +0000
9771 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_network.h 2013-05-31 14:47:11.000000000 +0000
9773 +#ifndef _NX_VS_NETWORK_H
9774 +#define _NX_VS_NETWORK_H
9776 +#include "vserver/context.h"
9777 +#include "vserver/network.h"
9778 +#include "vserver/base.h"
9779 +#include "vserver/check.h"
9780 +#include "vserver/debug.h"
9782 +#include <linux/sched.h>
9785 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
9787 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
9788 + const char *_file, int _line)
9793 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
9794 + nxi, nxi ? nxi->nx_id : 0,
9795 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9798 + atomic_inc(&nxi->nx_usecnt);
9803 +extern void free_nx_info(struct nx_info *);
9805 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
9807 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
9812 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
9813 + nxi, nxi ? nxi->nx_id : 0,
9814 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9817 + if (atomic_dec_and_test(&nxi->nx_usecnt))
9818 + free_nx_info(nxi);
9822 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
9824 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
9825 + const char *_file, int _line)
9828 + vxlprintk(VXD_CBIT(nid, 3),
9829 + "init_nx_info(%p[#%d.%d])",
9830 + nxi, nxi ? nxi->nx_id : 0,
9831 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9834 + atomic_inc(&nxi->nx_usecnt);
9840 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
9842 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
9843 + const char *_file, int _line)
9845 + struct nx_info *nxo;
9850 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
9851 + nxi, nxi ? nxi->nx_id : 0,
9852 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9855 + atomic_inc(&nxi->nx_usecnt);
9856 + nxo = xchg(nxp, nxi);
9860 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
9862 +static inline void __clr_nx_info(struct nx_info **nxp,
9863 + const char *_file, int _line)
9865 + struct nx_info *nxo;
9867 + nxo = xchg(nxp, NULL);
9871 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
9872 + nxo, nxo ? nxo->nx_id : 0,
9873 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
9876 + if (atomic_dec_and_test(&nxo->nx_usecnt))
9877 + free_nx_info(nxo);
9881 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
9883 +static inline void __claim_nx_info(struct nx_info *nxi,
9884 + struct task_struct *task, const char *_file, int _line)
9886 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
9887 + nxi, nxi ? nxi->nx_id : 0,
9888 + nxi?atomic_read(&nxi->nx_usecnt):0,
9889 + nxi?atomic_read(&nxi->nx_tasks):0,
9890 + task, _file, _line);
9892 + atomic_inc(&nxi->nx_tasks);
9896 +extern void unhash_nx_info(struct nx_info *);
9898 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
9900 +static inline void __release_nx_info(struct nx_info *nxi,
9901 + struct task_struct *task, const char *_file, int _line)
9903 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
9904 + nxi, nxi ? nxi->nx_id : 0,
9905 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
9906 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
9907 + task, _file, _line);
9911 + if (atomic_dec_and_test(&nxi->nx_tasks))
9912 + unhash_nx_info(nxi);
9916 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
9918 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
9919 + const char *_file, int _line)
9921 + struct nx_info *nxi;
9924 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
9926 + nxi = __get_nx_info(p->nx_info, _file, _line);
9932 +static inline void exit_nx_info(struct task_struct *p)
9935 + release_nx_info(p->nx_info, p);
9940 +#warning duplicate inclusion
9942 diff -NurpP --minimal linux-3.9.4/include/linux/vs_pid.h linux-3.9.4-vs2.3.6.3/include/linux/vs_pid.h
9943 --- linux-3.9.4/include/linux/vs_pid.h 1970-01-01 00:00:00.000000000 +0000
9944 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_pid.h 2013-05-31 14:47:11.000000000 +0000
9949 +#include "vserver/base.h"
9950 +#include "vserver/check.h"
9951 +#include "vserver/context.h"
9952 +#include "vserver/debug.h"
9953 +#include "vserver/pid.h"
9954 +#include <linux/pid_namespace.h>
9957 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
9960 +int vx_proc_task_visible(struct task_struct *task)
9962 + if ((task->pid == 1) &&
9963 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
9964 + /* show a blend through init */
9966 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
9973 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
9977 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
9979 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
9981 + if (task && !vx_proc_task_visible(task)) {
9982 + vxdprintk(VXD_CBIT(misc, 6),
9983 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
9984 + task, task->xid, task->pid,
9985 + current, current->xid, current->pid);
9986 + put_task_struct(task);
9994 +#warning duplicate inclusion
9996 diff -NurpP --minimal linux-3.9.4/include/linux/vs_sched.h linux-3.9.4-vs2.3.6.3/include/linux/vs_sched.h
9997 --- linux-3.9.4/include/linux/vs_sched.h 1970-01-01 00:00:00.000000000 +0000
9998 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_sched.h 2013-05-31 14:47:11.000000000 +0000
10000 +#ifndef _VS_SCHED_H
10001 +#define _VS_SCHED_H
10003 +#include "vserver/base.h"
10004 +#include "vserver/context.h"
10005 +#include "vserver/sched.h"
10008 +#define MAX_PRIO_BIAS 20
10009 +#define MIN_PRIO_BIAS -20
10012 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
10014 + struct vx_info *vxi = p->vx_info;
10017 + prio += vx_cpu(vxi, sched_pc).prio_bias;
10021 +static inline void vx_account_user(struct vx_info *vxi,
10022 + cputime_t cputime, int nice)
10026 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
10029 +static inline void vx_account_system(struct vx_info *vxi,
10030 + cputime_t cputime, int idle)
10034 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
10038 +#warning duplicate inclusion
10040 diff -NurpP --minimal linux-3.9.4/include/linux/vs_socket.h linux-3.9.4-vs2.3.6.3/include/linux/vs_socket.h
10041 --- linux-3.9.4/include/linux/vs_socket.h 1970-01-01 00:00:00.000000000 +0000
10042 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_socket.h 2013-05-31 14:47:11.000000000 +0000
10044 +#ifndef _VS_SOCKET_H
10045 +#define _VS_SOCKET_H
10047 +#include "vserver/debug.h"
10048 +#include "vserver/base.h"
10049 +#include "vserver/cacct.h"
10050 +#include "vserver/context.h"
10051 +#include "vserver/tag.h"
10054 +/* socket accounting */
10056 +#include <linux/socket.h>
10058 +static inline int vx_sock_type(int family)
10060 + switch (family) {
10062 + return VXA_SOCK_UNSPEC;
10064 + return VXA_SOCK_UNIX;
10066 + return VXA_SOCK_INET;
10068 + return VXA_SOCK_INET6;
10070 + return VXA_SOCK_PACKET;
10072 + return VXA_SOCK_OTHER;
10076 +#define vx_acc_sock(v, f, p, s) \
10077 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
10079 +static inline void __vx_acc_sock(struct vx_info *vxi,
10080 + int family, int pos, int size, char *file, int line)
10083 + int type = vx_sock_type(family);
10085 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10086 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10090 +#define vx_sock_recv(sk, s) \
10091 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10092 +#define vx_sock_send(sk, s) \
10093 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10094 +#define vx_sock_fail(sk, s) \
10095 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10098 +#define sock_vx_init(s) do { \
10099 + (s)->sk_xid = 0; \
10100 + (s)->sk_vx_info = NULL; \
10103 +#define sock_nx_init(s) do { \
10104 + (s)->sk_nid = 0; \
10105 + (s)->sk_nx_info = NULL; \
10109 +#warning duplicate inclusion
10111 diff -NurpP --minimal linux-3.9.4/include/linux/vs_tag.h linux-3.9.4-vs2.3.6.3/include/linux/vs_tag.h
10112 --- linux-3.9.4/include/linux/vs_tag.h 1970-01-01 00:00:00.000000000 +0000
10113 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_tag.h 2013-05-31 14:47:11.000000000 +0000
10118 +#include <linux/vserver/tag.h>
10120 +/* check conditions */
10122 +#define DX_ADMIN 0x0001
10123 +#define DX_WATCH 0x0002
10124 +#define DX_HOSTID 0x0008
10126 +#define DX_IDENT 0x0010
10128 +#define DX_ARG_MASK 0x0010
10131 +#define dx_task_tag(t) ((t)->tag)
10133 +#define dx_current_tag() dx_task_tag(current)
10135 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10137 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10141 + * check current context for ADMIN/WATCH and
10142 + * optionally against supplied argument
10144 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
10146 + if (mode & DX_ARG_MASK) {
10147 + if ((mode & DX_IDENT) && (id == cid))
10150 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10151 + ((mode & DX_WATCH) && (cid == 1)) ||
10152 + ((mode & DX_HOSTID) && (id == 0)));
10156 +int dx_permission(const struct inode *inode, int mask);
10160 +#warning duplicate inclusion
10162 diff -NurpP --minimal linux-3.9.4/include/linux/vs_time.h linux-3.9.4-vs2.3.6.3/include/linux/vs_time.h
10163 --- linux-3.9.4/include/linux/vs_time.h 1970-01-01 00:00:00.000000000 +0000
10164 +++ linux-3.9.4-vs2.3.6.3/include/linux/vs_time.h 2013-05-31 14:47:11.000000000 +0000
10166 +#ifndef _VS_TIME_H
10167 +#define _VS_TIME_H
10170 +/* time faking stuff */
10172 +#ifdef CONFIG_VSERVER_VTIME
10174 +extern void vx_adjust_timespec(struct timespec *ts);
10175 +extern int vx_settimeofday(const struct timespec *ts);
10178 +#define vx_adjust_timespec(t) do { } while (0)
10179 +#define vx_settimeofday(t) do_settimeofday(t)
10183 +#warning duplicate inclusion
10185 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/base.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/base.h
10186 --- linux-3.9.4/include/linux/vserver/base.h 1970-01-01 00:00:00.000000000 +0000
10187 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/base.h 2013-05-31 17:55:09.000000000 +0000
10189 +#ifndef _VSERVER_BASE_H
10190 +#define _VSERVER_BASE_H
10193 +/* context state changes */
10205 +#define vx_task_xid(t) ((t)->xid)
10207 +#define vx_current_xid() vx_task_xid(current)
10209 +#define current_vx_info() (current->vx_info)
10212 +#define nx_task_nid(t) ((t)->nid)
10214 +#define nx_current_nid() nx_task_nid(current)
10216 +#define current_nx_info() (current->nx_info)
10219 +/* generic flag merging */
10221 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10223 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10225 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10227 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10230 +/* context flags */
10232 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10234 +#define vx_current_flags() __vx_flags(current_vx_info())
10236 +#define vx_info_flags(v, m, f) \
10237 + vs_check_flags(__vx_flags(v), m, f)
10239 +#define task_vx_flags(t, m, f) \
10240 + ((t) && vx_info_flags((t)->vx_info, m, f))
10242 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10245 +/* context caps */
10247 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10249 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10251 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10253 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10257 +/* network flags */
10259 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10261 +#define nx_current_flags() __nx_flags(current_nx_info())
10263 +#define nx_info_flags(n, m, f) \
10264 + vs_check_flags(__nx_flags(n), m, f)
10266 +#define task_nx_flags(t, m, f) \
10267 + ((t) && nx_info_flags((t)->nx_info, m, f))
10269 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10272 +/* network caps */
10274 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10276 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10278 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10280 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10283 +/* context mask capabilities */
10285 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10287 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10289 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10292 +/* context bcap mask */
10294 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10296 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10299 +/* mask given bcaps */
10301 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10303 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10306 +/* masked cap_bset */
10308 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10310 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10313 +#define vx_info_mbcap(v, b) \
10314 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10315 + vx_info_bcaps(v, b) : (b))
10317 +#define task_vx_mbcap(t, b) \
10318 + vx_info_mbcap((t)->vx_info, (t)->b)
10320 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10323 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10325 +#define vx_capable(b, c) (capable(b) || \
10326 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10328 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
10329 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10331 +#define nx_capable(b, c) (capable(b) || \
10332 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10334 +#define vx_task_initpid(t, n) \
10335 + ((t)->vx_info && \
10336 + ((t)->vx_info->vx_initpid == (n)))
10338 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10341 +/* context unshare mask */
10343 +#define __vx_umask(v) ((v)->vx_umask)
10345 +#define vx_current_umask() __vx_umask(current_vx_info())
10347 +#define vx_can_unshare(b, f) (capable(b) || \
10348 + (cap_raised(current_cap(), b) && \
10349 + !((f) & ~vx_current_umask())))
10351 +#define vx_ns_can_unshare(n, b, f) (ns_capable(n, b) || \
10352 + (cap_raised(current_cap(), b) && \
10353 + !((f) & ~vx_current_umask())))
10355 +#define __vx_wmask(v) ((v)->vx_wmask)
10357 +#define vx_current_wmask() __vx_wmask(current_vx_info())
10360 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10362 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10365 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10367 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10370 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/cacct.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/cacct.h
10371 --- linux-3.9.4/include/linux/vserver/cacct.h 1970-01-01 00:00:00.000000000 +0000
10372 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/cacct.h 2013-05-31 14:47:11.000000000 +0000
10374 +#ifndef _VSERVER_CACCT_H
10375 +#define _VSERVER_CACCT_H
10378 +enum sock_acc_field {
10379 + VXA_SOCK_UNSPEC = 0,
10385 + VXA_SOCK_SIZE /* array size */
10388 +#endif /* _VSERVER_CACCT_H */
10389 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/cacct_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/cacct_cmd.h
10390 --- linux-3.9.4/include/linux/vserver/cacct_cmd.h 1970-01-01 00:00:00.000000000 +0000
10391 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/cacct_cmd.h 2013-05-31 14:47:11.000000000 +0000
10393 +#ifndef _VSERVER_CACCT_CMD_H
10394 +#define _VSERVER_CACCT_CMD_H
10397 +#include <linux/compiler.h>
10398 +#include <uapi/vserver/cacct_cmd.h>
10400 +extern int vc_sock_stat(struct vx_info *, void __user *);
10402 +#endif /* _VSERVER_CACCT_CMD_H */
10403 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/cacct_def.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/cacct_def.h
10404 --- linux-3.9.4/include/linux/vserver/cacct_def.h 1970-01-01 00:00:00.000000000 +0000
10405 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/cacct_def.h 2013-05-31 14:47:11.000000000 +0000
10407 +#ifndef _VSERVER_CACCT_DEF_H
10408 +#define _VSERVER_CACCT_DEF_H
10410 +#include <asm/atomic.h>
10411 +#include <linux/vserver/cacct.h>
10414 +struct _vx_sock_acc {
10415 + atomic_long_t count;
10416 + atomic_long_t total;
10419 +/* context sub struct */
10421 +struct _vx_cacct {
10422 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10423 + atomic_t slab[8];
10424 + atomic_t page[6][8];
10427 +#ifdef CONFIG_VSERVER_DEBUG
10429 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10433 + printk("\t_vx_cacct:");
10434 + for (i = 0; i < 6; i++) {
10435 + struct _vx_sock_acc *ptr = cacct->sock[i];
10437 + printk("\t [%d] =", i);
10438 + for (j = 0; j < 3; j++) {
10439 + printk(" [%d] = %8lu, %8lu", j,
10440 + atomic_long_read(&ptr[j].count),
10441 + atomic_long_read(&ptr[j].total));
10449 +#endif /* _VSERVER_CACCT_DEF_H */
10450 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/cacct_int.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/cacct_int.h
10451 --- linux-3.9.4/include/linux/vserver/cacct_int.h 1970-01-01 00:00:00.000000000 +0000
10452 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/cacct_int.h 2013-05-31 14:47:11.000000000 +0000
10454 +#ifndef _VSERVER_CACCT_INT_H
10455 +#define _VSERVER_CACCT_INT_H
10458 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10460 + return atomic_long_read(&cacct->sock[type][pos].count);
10465 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10467 + return atomic_long_read(&cacct->sock[type][pos].total);
10470 +#endif /* _VSERVER_CACCT_INT_H */
10471 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/check.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/check.h
10472 --- linux-3.9.4/include/linux/vserver/check.h 1970-01-01 00:00:00.000000000 +0000
10473 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/check.h 2013-05-31 14:47:11.000000000 +0000
10475 +#ifndef _VSERVER_CHECK_H
10476 +#define _VSERVER_CHECK_H
10479 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10481 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10482 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10484 +#define MIN_D_CONTEXT 65536
10487 +/* check conditions */
10489 +#define VS_ADMIN 0x0001
10490 +#define VS_WATCH 0x0002
10491 +#define VS_HIDE 0x0004
10492 +#define VS_HOSTID 0x0008
10494 +#define VS_IDENT 0x0010
10495 +#define VS_EQUIV 0x0020
10496 +#define VS_PARENT 0x0040
10497 +#define VS_CHILD 0x0080
10499 +#define VS_ARG_MASK 0x00F0
10501 +#define VS_DYNAMIC 0x0100
10502 +#define VS_STATIC 0x0200
10504 +#define VS_ATR_MASK 0x0F00
10506 +#ifdef CONFIG_VSERVER_PRIVACY
10507 +#define VS_ADMIN_P (0)
10508 +#define VS_WATCH_P (0)
10510 +#define VS_ADMIN_P VS_ADMIN
10511 +#define VS_WATCH_P VS_WATCH
10514 +#define VS_HARDIRQ 0x1000
10515 +#define VS_SOFTIRQ 0x2000
10516 +#define VS_IRQ 0x4000
10518 +#define VS_IRQ_MASK 0xF000
10520 +#include <linux/hardirq.h>
10523 + * check current context for ADMIN/WATCH and
10524 + * optionally against supplied argument
10526 +static inline int __vs_check(int cid, int id, unsigned int mode)
10528 + if (mode & VS_ARG_MASK) {
10529 + if ((mode & VS_IDENT) && (id == cid))
10532 + if (mode & VS_ATR_MASK) {
10533 + if ((mode & VS_DYNAMIC) &&
10534 + (id >= MIN_D_CONTEXT) &&
10535 + (id <= MAX_S_CONTEXT))
10537 + if ((mode & VS_STATIC) &&
10538 + (id > 1) && (id < MIN_D_CONTEXT))
10541 + if (mode & VS_IRQ_MASK) {
10542 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
10544 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
10546 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
10549 + return (((mode & VS_ADMIN) && (cid == 0)) ||
10550 + ((mode & VS_WATCH) && (cid == 1)) ||
10551 + ((mode & VS_HOSTID) && (id == 0)));
10554 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
10556 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
10559 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
10561 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
10564 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/context.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/context.h
10565 --- linux-3.9.4/include/linux/vserver/context.h 1970-01-01 00:00:00.000000000 +0000
10566 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/context.h 2013-05-31 14:47:11.000000000 +0000
10568 +#ifndef _VSERVER_CONTEXT_H
10569 +#define _VSERVER_CONTEXT_H
10572 +#include <linux/list.h>
10573 +#include <linux/spinlock.h>
10574 +#include <linux/rcupdate.h>
10575 +#include <uapi/vserver/context.h>
10577 +#include "limit_def.h"
10578 +#include "sched_def.h"
10579 +#include "cvirt_def.h"
10580 +#include "cacct_def.h"
10581 +#include "device_def.h"
10583 +#define VX_SPACES 2
10585 +struct _vx_info_pc {
10586 + struct _vx_sched_pc sched_pc;
10587 + struct _vx_cvirt_pc cvirt_pc;
10590 +struct _vx_space {
10591 + unsigned long vx_nsmask; /* assignment mask */
10592 + struct nsproxy *vx_nsproxy; /* private namespaces */
10593 + struct fs_struct *vx_fs; /* private namespace fs */
10594 + const struct cred *vx_cred; /* task credentials */
10598 + struct hlist_node vx_hlist; /* linked list of contexts */
10599 + xid_t vx_id; /* context id */
10600 + atomic_t vx_usecnt; /* usage count */
10601 + atomic_t vx_tasks; /* tasks count */
10602 + struct vx_info *vx_parent; /* parent context */
10603 + int vx_state; /* context state */
10605 + struct _vx_space space[VX_SPACES]; /* namespace store */
10607 + uint64_t vx_flags; /* context flags */
10608 + uint64_t vx_ccaps; /* context caps (vserver) */
10609 + uint64_t vx_umask; /* unshare mask (guest) */
10610 + uint64_t vx_wmask; /* warn mask (guest) */
10611 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
10613 + struct task_struct *vx_reaper; /* guest reaper process */
10614 + pid_t vx_initpid; /* PID of guest init */
10615 + int64_t vx_badness_bias; /* OOM points bias */
10617 + struct _vx_limit limit; /* vserver limits */
10618 + struct _vx_sched sched; /* vserver scheduler */
10619 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
10620 + struct _vx_cacct cacct; /* context accounting */
10622 + struct _vx_device dmap; /* default device map targets */
10624 +#ifndef CONFIG_SMP
10625 + struct _vx_info_pc info_pc; /* per cpu data */
10627 + struct _vx_info_pc *ptr_pc; /* per cpu array */
10630 + wait_queue_head_t vx_wait; /* context exit waitqueue */
10631 + int reboot_cmd; /* last sys_reboot() cmd */
10632 + int exit_code; /* last process exit code */
10634 + char vx_name[65]; /* vserver name */
10637 +#ifndef CONFIG_SMP
10638 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
10639 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
10641 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
10642 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
10645 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
10648 +struct vx_info_save {
10649 + struct vx_info *vxi;
10654 +/* status flags */
10656 +#define VXS_HASHED 0x0001
10657 +#define VXS_PAUSED 0x0010
10658 +#define VXS_SHUTDOWN 0x0100
10659 +#define VXS_HELPER 0x1000
10660 +#define VXS_RELEASED 0x8000
10663 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
10664 +extern void release_vx_info(struct vx_info *, struct task_struct *);
10666 +extern struct vx_info *lookup_vx_info(int);
10667 +extern struct vx_info *lookup_or_create_vx_info(int);
10669 +extern int get_xid_list(int, unsigned int *, int);
10670 +extern int xid_is_hashed(xid_t);
10672 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
10674 +extern long vs_state_change(struct vx_info *, unsigned int);
10677 +#endif /* _VSERVER_CONTEXT_H */
10678 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/context_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/context_cmd.h
10679 --- linux-3.9.4/include/linux/vserver/context_cmd.h 1970-01-01 00:00:00.000000000 +0000
10680 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/context_cmd.h 2013-05-31 14:47:11.000000000 +0000
10682 +#ifndef _VSERVER_CONTEXT_CMD_H
10683 +#define _VSERVER_CONTEXT_CMD_H
10685 +#include <uapi/vserver/context_cmd.h>
10687 +extern int vc_task_xid(uint32_t);
10689 +extern int vc_vx_info(struct vx_info *, void __user *);
10691 +extern int vc_ctx_stat(struct vx_info *, void __user *);
10693 +extern int vc_ctx_create(uint32_t, void __user *);
10694 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
10696 +extern int vc_get_cflags(struct vx_info *, void __user *);
10697 +extern int vc_set_cflags(struct vx_info *, void __user *);
10699 +extern int vc_get_ccaps(struct vx_info *, void __user *);
10700 +extern int vc_set_ccaps(struct vx_info *, void __user *);
10702 +extern int vc_get_bcaps(struct vx_info *, void __user *);
10703 +extern int vc_set_bcaps(struct vx_info *, void __user *);
10705 +extern int vc_get_umask(struct vx_info *, void __user *);
10706 +extern int vc_set_umask(struct vx_info *, void __user *);
10708 +extern int vc_get_wmask(struct vx_info *, void __user *);
10709 +extern int vc_set_wmask(struct vx_info *, void __user *);
10711 +extern int vc_get_badness(struct vx_info *, void __user *);
10712 +extern int vc_set_badness(struct vx_info *, void __user *);
10714 +#endif /* _VSERVER_CONTEXT_CMD_H */
10715 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/cvirt.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/cvirt.h
10716 --- linux-3.9.4/include/linux/vserver/cvirt.h 1970-01-01 00:00:00.000000000 +0000
10717 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/cvirt.h 2013-05-31 14:47:11.000000000 +0000
10719 +#ifndef _VSERVER_CVIRT_H
10720 +#define _VSERVER_CVIRT_H
10724 +void vx_vsi_boottime(struct timespec *);
10726 +void vx_vsi_uptime(struct timespec *, struct timespec *);
10731 +void vx_update_load(struct vx_info *);
10734 +int vx_do_syslog(int, char __user *, int);
10736 +#endif /* _VSERVER_CVIRT_H */
10737 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/cvirt_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/cvirt_cmd.h
10738 --- linux-3.9.4/include/linux/vserver/cvirt_cmd.h 1970-01-01 00:00:00.000000000 +0000
10739 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/cvirt_cmd.h 2013-05-31 14:47:11.000000000 +0000
10741 +#ifndef _VSERVER_CVIRT_CMD_H
10742 +#define _VSERVER_CVIRT_CMD_H
10745 +#include <linux/compiler.h>
10746 +#include <uapi/vserver/cvirt_cmd.h>
10748 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
10749 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
10751 +extern int vc_virt_stat(struct vx_info *, void __user *);
10753 +#endif /* _VSERVER_CVIRT_CMD_H */
10754 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/cvirt_def.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/cvirt_def.h
10755 --- linux-3.9.4/include/linux/vserver/cvirt_def.h 1970-01-01 00:00:00.000000000 +0000
10756 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/cvirt_def.h 2013-05-31 14:47:11.000000000 +0000
10758 +#ifndef _VSERVER_CVIRT_DEF_H
10759 +#define _VSERVER_CVIRT_DEF_H
10761 +#include <linux/jiffies.h>
10762 +#include <linux/spinlock.h>
10763 +#include <linux/wait.h>
10764 +#include <linux/time.h>
10765 +#include <asm/atomic.h>
10768 +struct _vx_usage_stat {
10772 + uint64_t softirq;
10778 +struct _vx_syslog {
10779 + wait_queue_head_t log_wait;
10780 + spinlock_t logbuf_lock; /* lock for the log buffer */
10782 + unsigned long log_start; /* next char to be read by syslog() */
10783 + unsigned long con_start; /* next char to be sent to consoles */
10784 + unsigned long log_end; /* most-recently-written-char + 1 */
10785 + unsigned long logged_chars; /* #chars since last read+clear operation */
10787 + char log_buf[1024];
10791 +/* context sub struct */
10793 +struct _vx_cvirt {
10794 + atomic_t nr_threads; /* number of current threads */
10795 + atomic_t nr_running; /* number of running threads */
10796 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
10798 + atomic_t nr_onhold; /* processes on hold */
10799 + uint32_t onhold_last; /* jiffies when put on hold */
10801 + struct timespec bias_ts; /* time offset to the host */
10802 + struct timespec bias_idle;
10803 + struct timespec bias_uptime; /* context creation point */
10804 + uint64_t bias_clock; /* offset in clock_t */
10806 + spinlock_t load_lock; /* lock for the load averages */
10807 + atomic_t load_updates; /* nr of load updates done so far */
10808 + uint32_t load_last; /* last time load was calculated */
10809 + uint32_t load[3]; /* load averages 1,5,15 */
10811 + atomic_t total_forks; /* number of forks so far */
10813 + struct _vx_syslog syslog;
10816 +struct _vx_cvirt_pc {
10817 + struct _vx_usage_stat cpustat;
10821 +#ifdef CONFIG_VSERVER_DEBUG
10823 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
10825 + printk("\t_vx_cvirt:\n");
10826 + printk("\t threads: %4d, %4d, %4d, %4d\n",
10827 + atomic_read(&cvirt->nr_threads),
10828 + atomic_read(&cvirt->nr_running),
10829 + atomic_read(&cvirt->nr_uninterruptible),
10830 + atomic_read(&cvirt->nr_onhold));
10831 + /* add rest here */
10832 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
10837 +#endif /* _VSERVER_CVIRT_DEF_H */
10838 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/debug.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/debug.h
10839 --- linux-3.9.4/include/linux/vserver/debug.h 1970-01-01 00:00:00.000000000 +0000
10840 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/debug.h 2013-06-03 18:27:34.000000000 +0000
10842 +#ifndef _VSERVER_DEBUG_H
10843 +#define _VSERVER_DEBUG_H
10846 +#define VXD_CBIT(n, m) (vs_debug_ ## n & (1 << (m)))
10847 +#define VXD_CMIN(n, m) (vs_debug_ ## n > (m))
10848 +#define VXD_MASK(n, m) (vs_debug_ ## n & (m))
10850 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
10851 + imajor((d)->bd_inode), iminor((d)->bd_inode)
10852 +#define VXF_DEV "%p[%lu,%d:%d]"
10854 +#if defined(CONFIG_QUOTES_UTF8)
10855 +#define VS_Q_LQM "\xc2\xbb"
10856 +#define VS_Q_RQM "\xc2\xab"
10857 +#elif defined(CONFIG_QUOTES_ASCII)
10858 +#define VS_Q_LQM "\x27"
10859 +#define VS_Q_RQM "\x27"
10861 +#define VS_Q_LQM "\xbb"
10862 +#define VS_Q_RQM "\xab"
10865 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
10868 +#define vxd_path(p) \
10869 + ({ static char _buffer[PATH_MAX]; \
10870 + d_path(p, _buffer, sizeof(_buffer)); })
10872 +#define vxd_cond_path(n) \
10873 + ((n) ? vxd_path(&(n)->path) : "<null>" )
10876 +#ifdef CONFIG_VSERVER_DEBUG
10878 +extern unsigned int vs_debug_switch;
10879 +extern unsigned int vs_debug_xid;
10880 +extern unsigned int vs_debug_nid;
10881 +extern unsigned int vs_debug_tag;
10882 +extern unsigned int vs_debug_net;
10883 +extern unsigned int vs_debug_limit;
10884 +extern unsigned int vs_debug_cres;
10885 +extern unsigned int vs_debug_dlim;
10886 +extern unsigned int vs_debug_quota;
10887 +extern unsigned int vs_debug_cvirt;
10888 +extern unsigned int vs_debug_space;
10889 +extern unsigned int vs_debug_perm;
10890 +extern unsigned int vs_debug_misc;
10893 +#define VX_LOGLEVEL "vxD: "
10894 +#define VX_PROC_FMT "%p: "
10895 +#define VX_PROCESS current
10897 +#define vxdprintk(c, f, x...) \
10900 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
10901 + VX_PROCESS , ##x); \
10904 +#define vxlprintk(c, f, x...) \
10907 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
10910 +#define vxfprintk(c, f, x...) \
10913 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
10919 +void dump_vx_info(struct vx_info *, int);
10920 +void dump_vx_info_inactive(int);
10922 +#else /* CONFIG_VSERVER_DEBUG */
10924 +#define vs_debug_switch 0
10925 +#define vs_debug_xid 0
10926 +#define vs_debug_nid 0
10927 +#define vs_debug_tag 0
10928 +#define vs_debug_net 0
10929 +#define vs_debug_limit 0
10930 +#define vs_debug_cres 0
10931 +#define vs_debug_dlim 0
10932 +#define vs_debug_quota 0
10933 +#define vs_debug_cvirt 0
10934 +#define vs_debug_space 0
10935 +#define vs_debug_perm 0
10936 +#define vs_debug_misc 0
10938 +#define vxdprintk(x...) do { } while (0)
10939 +#define vxlprintk(x...) do { } while (0)
10940 +#define vxfprintk(x...) do { } while (0)
10942 +#endif /* CONFIG_VSERVER_DEBUG */
10945 +#ifdef CONFIG_VSERVER_WARN
10947 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
10948 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
10949 +#define VX_WARN_XID "[xid #%u] "
10950 +#define VX_WARN_NID "[nid #%u] "
10951 +#define VX_WARN_TAG "[tag #%u] "
10953 +#define vxwprintk(c, f, x...) \
10956 + printk(VX_WARNLEVEL f "\n", ##x); \
10959 +#else /* CONFIG_VSERVER_WARN */
10961 +#define vxwprintk(x...) do { } while (0)
10963 +#endif /* CONFIG_VSERVER_WARN */
10965 +#define vxwprintk_task(c, f, x...) \
10966 + vxwprintk(c, VX_WARN_TASK f, \
10967 + current->comm, current->pid, \
10968 + current->xid, current->nid, \
10969 + current->tag, ##x)
10970 +#define vxwprintk_xid(c, f, x...) \
10971 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
10972 +#define vxwprintk_nid(c, f, x...) \
10973 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
10974 +#define vxwprintk_tag(c, f, x...) \
10975 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
10977 +#ifdef CONFIG_VSERVER_DEBUG
10978 +#define vxd_assert_lock(l) assert_spin_locked(l)
10979 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
10980 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
10982 +#define vxd_assert_lock(l) do { } while (0)
10983 +#define vxd_assert(c, f, x...) do { } while (0)
10987 +#endif /* _VSERVER_DEBUG_H */
10988 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/debug_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/debug_cmd.h
10989 --- linux-3.9.4/include/linux/vserver/debug_cmd.h 1970-01-01 00:00:00.000000000 +0000
10990 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/debug_cmd.h 2013-05-31 14:47:11.000000000 +0000
10992 +#ifndef _VSERVER_DEBUG_CMD_H
10993 +#define _VSERVER_DEBUG_CMD_H
10995 +#include <uapi/vserver/debug_cmd.h>
10998 +#ifdef CONFIG_COMPAT
11000 +#include <asm/compat.h>
11002 +struct vcmd_read_history_v0_x32 {
11005 + compat_uptr_t data_ptr;
11008 +struct vcmd_read_monitor_v0_x32 {
11011 + compat_uptr_t data_ptr;
11014 +#endif /* CONFIG_COMPAT */
11016 +extern int vc_dump_history(uint32_t);
11018 +extern int vc_read_history(uint32_t, void __user *);
11019 +extern int vc_read_monitor(uint32_t, void __user *);
11021 +#ifdef CONFIG_COMPAT
11023 +extern int vc_read_history_x32(uint32_t, void __user *);
11024 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11026 +#endif /* CONFIG_COMPAT */
11028 +#endif /* _VSERVER_DEBUG_CMD_H */
11029 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/device.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/device.h
11030 --- linux-3.9.4/include/linux/vserver/device.h 1970-01-01 00:00:00.000000000 +0000
11031 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/device.h 2013-05-31 14:47:11.000000000 +0000
11033 +#ifndef _VSERVER_DEVICE_H
11034 +#define _VSERVER_DEVICE_H
11037 +#include <uapi/vserver/device.h>
11039 +#else /* _VSERVER_DEVICE_H */
11040 +#warning duplicate inclusion
11041 +#endif /* _VSERVER_DEVICE_H */
11042 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/device_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/device_cmd.h
11043 --- linux-3.9.4/include/linux/vserver/device_cmd.h 1970-01-01 00:00:00.000000000 +0000
11044 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/device_cmd.h 2013-05-31 14:47:11.000000000 +0000
11046 +#ifndef _VSERVER_DEVICE_CMD_H
11047 +#define _VSERVER_DEVICE_CMD_H
11049 +#include <uapi/vserver/device_cmd.h>
11052 +#ifdef CONFIG_COMPAT
11054 +#include <asm/compat.h>
11056 +struct vcmd_set_mapping_v0_x32 {
11057 + compat_uptr_t device_ptr;
11058 + compat_uptr_t target_ptr;
11062 +#endif /* CONFIG_COMPAT */
11064 +#include <linux/compiler.h>
11066 +extern int vc_set_mapping(struct vx_info *, void __user *);
11067 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11069 +#ifdef CONFIG_COMPAT
11071 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11072 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11074 +#endif /* CONFIG_COMPAT */
11076 +#endif /* _VSERVER_DEVICE_CMD_H */
11077 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/device_def.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/device_def.h
11078 --- linux-3.9.4/include/linux/vserver/device_def.h 1970-01-01 00:00:00.000000000 +0000
11079 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/device_def.h 2013-05-31 14:47:11.000000000 +0000
11081 +#ifndef _VSERVER_DEVICE_DEF_H
11082 +#define _VSERVER_DEVICE_DEF_H
11084 +#include <linux/types.h>
11086 +struct vx_dmap_target {
11091 +struct _vx_device {
11092 +#ifdef CONFIG_VSERVER_DEVICE
11093 + struct vx_dmap_target targets[2];
11097 +#endif /* _VSERVER_DEVICE_DEF_H */
11098 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/dlimit.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/dlimit.h
11099 --- linux-3.9.4/include/linux/vserver/dlimit.h 1970-01-01 00:00:00.000000000 +0000
11100 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/dlimit.h 2013-05-31 14:47:11.000000000 +0000
11102 +#ifndef _VSERVER_DLIMIT_H
11103 +#define _VSERVER_DLIMIT_H
11105 +#include "switch.h"
11110 +/* keep in sync with CDLIM_INFINITY */
11112 +#define DLIM_INFINITY (~0ULL)
11114 +#include <linux/spinlock.h>
11115 +#include <linux/rcupdate.h>
11117 +struct super_block;
11120 + struct hlist_node dl_hlist; /* linked list of contexts */
11121 + struct rcu_head dl_rcu; /* the rcu head */
11122 + tag_t dl_tag; /* context tag */
11123 + atomic_t dl_usecnt; /* usage count */
11124 + atomic_t dl_refcnt; /* reference count */
11126 + struct super_block *dl_sb; /* associated superblock */
11128 + spinlock_t dl_lock; /* protect the values */
11130 + unsigned long long dl_space_used; /* used space in bytes */
11131 + unsigned long long dl_space_total; /* maximum space in bytes */
11132 + unsigned long dl_inodes_used; /* used inodes */
11133 + unsigned long dl_inodes_total; /* maximum inodes */
11135 + unsigned int dl_nrlmult; /* non root limit mult */
11140 +extern void rcu_free_dl_info(struct rcu_head *);
11141 +extern void unhash_dl_info(struct dl_info *);
11143 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11148 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11150 +typedef uint64_t dlsize_t;
11152 +#endif /* __KERNEL__ */
11153 +#else /* _VSERVER_DLIMIT_H */
11154 +#warning duplicate inclusion
11155 +#endif /* _VSERVER_DLIMIT_H */
11156 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/dlimit_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/dlimit_cmd.h
11157 --- linux-3.9.4/include/linux/vserver/dlimit_cmd.h 1970-01-01 00:00:00.000000000 +0000
11158 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/dlimit_cmd.h 2013-05-31 14:47:11.000000000 +0000
11160 +#ifndef _VSERVER_DLIMIT_CMD_H
11161 +#define _VSERVER_DLIMIT_CMD_H
11163 +#include <uapi/vserver/dlimit_cmd.h>
11166 +#ifdef CONFIG_COMPAT
11168 +#include <asm/compat.h>
11170 +struct vcmd_ctx_dlimit_base_v0_x32 {
11171 + compat_uptr_t name_ptr;
11175 +struct vcmd_ctx_dlimit_v0_x32 {
11176 + compat_uptr_t name_ptr;
11177 + uint32_t space_used; /* used space in kbytes */
11178 + uint32_t space_total; /* maximum space in kbytes */
11179 + uint32_t inodes_used; /* used inodes */
11180 + uint32_t inodes_total; /* maximum inodes */
11181 + uint32_t reserved; /* reserved for root in % */
11185 +#endif /* CONFIG_COMPAT */
11187 +#include <linux/compiler.h>
11189 +extern int vc_add_dlimit(uint32_t, void __user *);
11190 +extern int vc_rem_dlimit(uint32_t, void __user *);
11192 +extern int vc_set_dlimit(uint32_t, void __user *);
11193 +extern int vc_get_dlimit(uint32_t, void __user *);
11195 +#ifdef CONFIG_COMPAT
11197 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
11198 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
11200 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
11201 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
11203 +#endif /* CONFIG_COMPAT */
11205 +#endif /* _VSERVER_DLIMIT_CMD_H */
11206 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/global.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/global.h
11207 --- linux-3.9.4/include/linux/vserver/global.h 1970-01-01 00:00:00.000000000 +0000
11208 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/global.h 2013-05-31 14:47:11.000000000 +0000
11210 +#ifndef _VSERVER_GLOBAL_H
11211 +#define _VSERVER_GLOBAL_H
11214 +extern atomic_t vx_global_ctotal;
11215 +extern atomic_t vx_global_cactive;
11217 +extern atomic_t nx_global_ctotal;
11218 +extern atomic_t nx_global_cactive;
11220 +extern atomic_t vs_global_nsproxy;
11221 +extern atomic_t vs_global_fs;
11222 +extern atomic_t vs_global_mnt_ns;
11223 +extern atomic_t vs_global_uts_ns;
11224 +extern atomic_t vs_global_user_ns;
11225 +extern atomic_t vs_global_pid_ns;
11228 +#endif /* _VSERVER_GLOBAL_H */
11229 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/history.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/history.h
11230 --- linux-3.9.4/include/linux/vserver/history.h 1970-01-01 00:00:00.000000000 +0000
11231 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/history.h 2013-05-31 14:47:11.000000000 +0000
11233 +#ifndef _VSERVER_HISTORY_H
11234 +#define _VSERVER_HISTORY_H
11239 + VXH_THROW_OOPS = 1,
11243 + VXH_INIT_VX_INFO,
11246 + VXH_CLAIM_VX_INFO,
11247 + VXH_RELEASE_VX_INFO,
11248 + VXH_ALLOC_VX_INFO,
11249 + VXH_DEALLOC_VX_INFO,
11250 + VXH_HASH_VX_INFO,
11251 + VXH_UNHASH_VX_INFO,
11253 + VXH_LOOKUP_VX_INFO,
11254 + VXH_CREATE_VX_INFO,
11257 +struct _vxhe_vxi {
11258 + struct vx_info *ptr;
11264 +struct _vxhe_set_clr {
11268 +struct _vxhe_loc_lookup {
11272 +struct _vx_hist_entry {
11274 + unsigned short seq;
11275 + unsigned short type;
11276 + struct _vxhe_vxi vxi;
11278 + struct _vxhe_set_clr sc;
11279 + struct _vxhe_loc_lookup ll;
11283 +#ifdef CONFIG_VSERVER_HISTORY
11285 +extern unsigned volatile int vxh_active;
11287 +struct _vx_hist_entry *vxh_advance(void *loc);
11291 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
11293 + entry->vxi.ptr = vxi;
11295 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
11296 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
11297 + entry->vxi.xid = vxi->vx_id;
11302 +#define __HERE__ current_text_addr()
11304 +#define __VXH_BODY(__type, __data, __here) \
11305 + struct _vx_hist_entry *entry; \
11307 + preempt_disable(); \
11308 + entry = vxh_advance(__here); \
11310 + entry->type = __type; \
11311 + preempt_enable();
11314 + /* pass vxi only */
11316 +#define __VXH_SMPL \
11317 + __vxh_copy_vxi(entry, vxi)
11320 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
11322 + __VXH_BODY(__type, __VXH_SMPL, __here)
11325 + /* pass vxi and data (void *) */
11327 +#define __VXH_DATA \
11328 + __vxh_copy_vxi(entry, vxi); \
11329 + entry->sc.data = data
11332 +void __vxh_data(struct vx_info *vxi, void *data,
11333 + int __type, void *__here)
11335 + __VXH_BODY(__type, __VXH_DATA, __here)
11338 + /* pass vxi and arg (long) */
11340 +#define __VXH_LONG \
11341 + __vxh_copy_vxi(entry, vxi); \
11342 + entry->ll.arg = arg
11345 +void __vxh_long(struct vx_info *vxi, long arg,
11346 + int __type, void *__here)
11348 + __VXH_BODY(__type, __VXH_LONG, __here)
11353 +void __vxh_throw_oops(void *__here)
11355 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
11356 + /* prevent further acquisition */
11361 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
11363 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
11364 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
11366 +#define __vxh_init_vx_info(v, d, h) \
11367 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
11368 +#define __vxh_set_vx_info(v, d, h) \
11369 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
11370 +#define __vxh_clr_vx_info(v, d, h) \
11371 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
11373 +#define __vxh_claim_vx_info(v, d, h) \
11374 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
11375 +#define __vxh_release_vx_info(v, d, h) \
11376 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
11378 +#define vxh_alloc_vx_info(v) \
11379 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
11380 +#define vxh_dealloc_vx_info(v) \
11381 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
11383 +#define vxh_hash_vx_info(v) \
11384 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
11385 +#define vxh_unhash_vx_info(v) \
11386 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
11388 +#define vxh_loc_vx_info(v, l) \
11389 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
11390 +#define vxh_lookup_vx_info(v, l) \
11391 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
11392 +#define vxh_create_vx_info(v, l) \
11393 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
11395 +extern void vxh_dump_history(void);
11398 +#else /* CONFIG_VSERVER_HISTORY */
11400 +#define __HERE__ 0
11402 +#define vxh_throw_oops() do { } while (0)
11404 +#define __vxh_get_vx_info(v, h) do { } while (0)
11405 +#define __vxh_put_vx_info(v, h) do { } while (0)
11407 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
11408 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
11409 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
11411 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
11412 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
11414 +#define vxh_alloc_vx_info(v) do { } while (0)
11415 +#define vxh_dealloc_vx_info(v) do { } while (0)
11417 +#define vxh_hash_vx_info(v) do { } while (0)
11418 +#define vxh_unhash_vx_info(v) do { } while (0)
11420 +#define vxh_loc_vx_info(v, l) do { } while (0)
11421 +#define vxh_lookup_vx_info(v, l) do { } while (0)
11422 +#define vxh_create_vx_info(v, l) do { } while (0)
11424 +#define vxh_dump_history() do { } while (0)
11427 +#endif /* CONFIG_VSERVER_HISTORY */
11429 +#endif /* _VSERVER_HISTORY_H */
11430 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/inode.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/inode.h
11431 --- linux-3.9.4/include/linux/vserver/inode.h 1970-01-01 00:00:00.000000000 +0000
11432 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/inode.h 2013-05-31 14:47:11.000000000 +0000
11434 +#ifndef _VSERVER_INODE_H
11435 +#define _VSERVER_INODE_H
11437 +#include <uapi/vserver/inode.h>
11440 +#ifdef CONFIG_VSERVER_PROC_SECURE
11441 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
11442 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11444 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
11445 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
11448 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
11450 +#else /* _VSERVER_INODE_H */
11451 +#warning duplicate inclusion
11452 +#endif /* _VSERVER_INODE_H */
11453 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/inode_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/inode_cmd.h
11454 --- linux-3.9.4/include/linux/vserver/inode_cmd.h 1970-01-01 00:00:00.000000000 +0000
11455 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/inode_cmd.h 2013-05-31 14:47:11.000000000 +0000
11457 +#ifndef _VSERVER_INODE_CMD_H
11458 +#define _VSERVER_INODE_CMD_H
11460 +#include <uapi/vserver/inode_cmd.h>
11464 +#ifdef CONFIG_COMPAT
11466 +#include <asm/compat.h>
11468 +struct vcmd_ctx_iattr_v1_x32 {
11469 + compat_uptr_t name_ptr;
11475 +#endif /* CONFIG_COMPAT */
11477 +#include <linux/compiler.h>
11479 +extern int vc_get_iattr(void __user *);
11480 +extern int vc_set_iattr(void __user *);
11482 +extern int vc_fget_iattr(uint32_t, void __user *);
11483 +extern int vc_fset_iattr(uint32_t, void __user *);
11485 +#ifdef CONFIG_COMPAT
11487 +extern int vc_get_iattr_x32(void __user *);
11488 +extern int vc_set_iattr_x32(void __user *);
11490 +#endif /* CONFIG_COMPAT */
11492 +#endif /* _VSERVER_INODE_CMD_H */
11493 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/limit.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/limit.h
11494 --- linux-3.9.4/include/linux/vserver/limit.h 1970-01-01 00:00:00.000000000 +0000
11495 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/limit.h 2013-05-31 14:47:11.000000000 +0000
11497 +#ifndef _VSERVER_LIMIT_H
11498 +#define _VSERVER_LIMIT_H
11500 +#include <uapi/vserver/limit.h>
11503 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
11505 +/* keep in sync with CRLIM_INFINITY */
11507 +#define VLIM_INFINITY (~0ULL)
11509 +#include <asm/atomic.h>
11510 +#include <asm/resource.h>
11512 +#ifndef RLIM_INFINITY
11513 +#warning RLIM_INFINITY is undefined
11516 +#define __rlim_val(l, r, v) ((l)->res[r].v)
11518 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
11519 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
11521 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
11522 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
11523 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
11525 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
11526 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
11528 +typedef atomic_long_t rlim_atomic_t;
11529 +typedef unsigned long rlim_t;
11531 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
11532 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
11533 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
11534 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
11535 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
11536 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
11539 +#if (RLIM_INFINITY == VLIM_INFINITY)
11540 +#define VX_VLIM(r) ((long long)(long)(r))
11541 +#define VX_RLIM(v) ((rlim_t)(v))
11543 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
11544 + ? VLIM_INFINITY : (long long)(r))
11545 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
11546 + ? RLIM_INFINITY : (rlim_t)(v))
11551 +void vx_vsi_meminfo(struct sysinfo *);
11552 +void vx_vsi_swapinfo(struct sysinfo *);
11553 +long vx_vsi_cached(struct sysinfo *);
11555 +#define NUM_LIMITS 24
11557 +#endif /* _VSERVER_LIMIT_H */
11558 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/limit_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/limit_cmd.h
11559 --- linux-3.9.4/include/linux/vserver/limit_cmd.h 1970-01-01 00:00:00.000000000 +0000
11560 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/limit_cmd.h 2013-05-31 14:47:11.000000000 +0000
11562 +#ifndef _VSERVER_LIMIT_CMD_H
11563 +#define _VSERVER_LIMIT_CMD_H
11565 +#include <uapi/vserver/limit_cmd.h>
11568 +#ifdef CONFIG_IA32_EMULATION
11570 +struct vcmd_ctx_rlimit_v0_x32 {
11572 + uint64_t minimum;
11573 + uint64_t softlimit;
11574 + uint64_t maximum;
11575 +} __attribute__ ((packed));
11577 +#endif /* CONFIG_IA32_EMULATION */
11579 +#include <linux/compiler.h>
11581 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
11582 +extern int vc_get_rlimit(struct vx_info *, void __user *);
11583 +extern int vc_set_rlimit(struct vx_info *, void __user *);
11584 +extern int vc_reset_hits(struct vx_info *, void __user *);
11585 +extern int vc_reset_minmax(struct vx_info *, void __user *);
11587 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
11589 +#ifdef CONFIG_IA32_EMULATION
11591 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
11592 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
11594 +#endif /* CONFIG_IA32_EMULATION */
11596 +#endif /* _VSERVER_LIMIT_CMD_H */
11597 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/limit_def.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/limit_def.h
11598 --- linux-3.9.4/include/linux/vserver/limit_def.h 1970-01-01 00:00:00.000000000 +0000
11599 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/limit_def.h 2013-05-31 14:47:11.000000000 +0000
11601 +#ifndef _VSERVER_LIMIT_DEF_H
11602 +#define _VSERVER_LIMIT_DEF_H
11604 +#include <asm/atomic.h>
11605 +#include <asm/resource.h>
11607 +#include "limit.h"
11610 +struct _vx_res_limit {
11611 + rlim_t soft; /* Context soft limit */
11612 + rlim_t hard; /* Context hard limit */
11614 + rlim_atomic_t rcur; /* Current value */
11615 + rlim_t rmin; /* Context minimum */
11616 + rlim_t rmax; /* Context maximum */
11618 + atomic_t lhit; /* Limit hits */
11621 +/* context sub struct */
11623 +struct _vx_limit {
11624 + struct _vx_res_limit res[NUM_LIMITS];
11627 +#ifdef CONFIG_VSERVER_DEBUG
11629 +static inline void __dump_vx_limit(struct _vx_limit *limit)
11633 + printk("\t_vx_limit:");
11634 + for (i = 0; i < NUM_LIMITS; i++) {
11635 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
11636 + i, (unsigned long)__rlim_get(limit, i),
11637 + (unsigned long)__rlim_rmin(limit, i),
11638 + (unsigned long)__rlim_rmax(limit, i),
11639 + (long)__rlim_soft(limit, i),
11640 + (long)__rlim_hard(limit, i),
11641 + atomic_read(&__rlim_lhit(limit, i)));
11647 +#endif /* _VSERVER_LIMIT_DEF_H */
11648 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/limit_int.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/limit_int.h
11649 --- linux-3.9.4/include/linux/vserver/limit_int.h 1970-01-01 00:00:00.000000000 +0000
11650 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/limit_int.h 2013-05-31 14:47:11.000000000 +0000
11652 +#ifndef _VSERVER_LIMIT_INT_H
11653 +#define _VSERVER_LIMIT_INT_H
11655 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
11656 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
11658 +extern const char *vlimit_name[NUM_LIMITS];
11660 +static inline void __vx_acc_cres(struct vx_info *vxi,
11661 + int res, int dir, void *_data, char *_file, int _line)
11663 + if (VXD_RCRES_COND(res))
11664 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
11665 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11666 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11667 + (dir > 0) ? "++" : "--", _data, _file, _line);
11672 + __rlim_inc(&vxi->limit, res);
11674 + __rlim_dec(&vxi->limit, res);
11677 +static inline void __vx_add_cres(struct vx_info *vxi,
11678 + int res, int amount, void *_data, char *_file, int _line)
11680 + if (VXD_RCRES_COND(res))
11681 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
11682 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11683 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11684 + amount, _data, _file, _line);
11689 + __rlim_add(&vxi->limit, res, amount);
11693 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
11695 + int cond = (value > __rlim_rmax(limit, res));
11698 + __rlim_rmax(limit, res) = value;
11703 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
11705 + int cond = (value < __rlim_rmin(limit, res));
11708 + __rlim_rmin(limit, res) = value;
11713 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
11715 + if (!__vx_cres_adjust_max(limit, res, value))
11716 + __vx_cres_adjust_min(limit, res, value);
11721 + +1 ... no limit hit
11722 + -1 ... over soft limit
11723 + 0 ... over hard limit */
11725 +static inline int __vx_cres_avail(struct vx_info *vxi,
11726 + int res, int num, char *_file, int _line)
11728 + struct _vx_limit *limit;
11731 + if (VXD_RLIMIT_COND(res))
11732 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
11733 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
11734 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
11735 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
11736 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
11737 + num, _file, _line);
11741 + limit = &vxi->limit;
11742 + value = __rlim_get(limit, res);
11744 + if (!__vx_cres_adjust_max(limit, res, value))
11745 + __vx_cres_adjust_min(limit, res, value);
11750 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
11752 + if (value + num <= __rlim_soft(limit, res))
11755 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
11757 + if (value + num <= __rlim_hard(limit, res))
11760 + __rlim_hit(limit, res);
11765 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
11768 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
11770 + rlim_t value, sum = 0;
11773 + while ((res = *array++)) {
11774 + value = __rlim_get(limit, res);
11775 + __vx_cres_fixup(limit, res, value);
11782 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
11784 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
11785 + int res = *array;
11787 + if (value == __rlim_get(limit, res))
11790 + __rlim_set(limit, res, value);
11791 + /* now adjust min/max */
11792 + if (!__vx_cres_adjust_max(limit, res, value))
11793 + __vx_cres_adjust_min(limit, res, value);
11798 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
11799 + const int *array, int num, char *_file, int _line)
11801 + struct _vx_limit *limit;
11802 + rlim_t value = 0;
11810 + limit = &vxi->limit;
11812 + value = __vx_cres_array_sum(limit, array + 1);
11814 + __rlim_set(limit, res, value);
11815 + __vx_cres_fixup(limit, res, value);
11817 + return __vx_cres_avail(vxi, res, num, _file, _line);
11821 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
11826 + /* complex resources first */
11827 + if ((id < 0) || (id == RLIMIT_RSS))
11828 + __vx_cres_array_fixup(limit, VLA_RSS);
11830 + for (res = 0; res < NUM_LIMITS; res++) {
11831 + if ((id > 0) && (res != id))
11834 + value = __rlim_get(limit, res);
11835 + __vx_cres_fixup(limit, res, value);
11837 + /* not supposed to happen, maybe warn? */
11838 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
11839 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
11844 +#endif /* _VSERVER_LIMIT_INT_H */
11845 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/monitor.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/monitor.h
11846 --- linux-3.9.4/include/linux/vserver/monitor.h 1970-01-01 00:00:00.000000000 +0000
11847 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/monitor.h 2013-05-31 14:47:11.000000000 +0000
11849 +#ifndef _VSERVER_MONITOR_H
11850 +#define _VSERVER_MONITOR_H
11852 +#include <uapi/vserver/monitor.h>
11854 +#endif /* _VSERVER_MONITOR_H */
11855 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/network.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/network.h
11856 --- linux-3.9.4/include/linux/vserver/network.h 1970-01-01 00:00:00.000000000 +0000
11857 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/network.h 2013-05-31 14:47:11.000000000 +0000
11859 +#ifndef _VSERVER_NETWORK_H
11860 +#define _VSERVER_NETWORK_H
11863 +#include <linux/list.h>
11864 +#include <linux/spinlock.h>
11865 +#include <linux/rcupdate.h>
11866 +#include <linux/in.h>
11867 +#include <linux/in6.h>
11868 +#include <asm/atomic.h>
11869 +#include <uapi/vserver/network.h>
11871 +struct nx_addr_v4 {
11872 + struct nx_addr_v4 *next;
11873 + struct in_addr ip[2];
11874 + struct in_addr mask;
11879 +struct nx_addr_v6 {
11880 + struct nx_addr_v6 *next;
11881 + struct in6_addr ip;
11882 + struct in6_addr mask;
11889 + struct hlist_node nx_hlist; /* linked list of nxinfos */
11890 + nid_t nx_id; /* vnet id */
11891 + atomic_t nx_usecnt; /* usage count */
11892 + atomic_t nx_tasks; /* tasks count */
11893 + int nx_state; /* context state */
11895 + uint64_t nx_flags; /* network flag word */
11896 + uint64_t nx_ncaps; /* network capabilities */
11898 + spinlock_t addr_lock; /* protect address changes */
11899 + struct in_addr v4_lback; /* Loopback address */
11900 + struct in_addr v4_bcast; /* Broadcast address */
11901 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
11902 +#ifdef CONFIG_IPV6
11903 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
11905 + char nx_name[65]; /* network context name */
11909 +/* status flags */
11911 +#define NXS_HASHED 0x0001
11912 +#define NXS_SHUTDOWN 0x0100
11913 +#define NXS_RELEASED 0x8000
11915 +extern struct nx_info *lookup_nx_info(int);
11917 +extern int get_nid_list(int, unsigned int *, int);
11918 +extern int nid_is_hashed(nid_t);
11920 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
11922 +extern long vs_net_change(struct nx_info *, unsigned int);
11927 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
11928 +#ifdef CONFIG_IPV6
11929 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
11931 +#define NX_IPV6(n) (0)
11934 +#endif /* _VSERVER_NETWORK_H */
11935 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/network_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/network_cmd.h
11936 --- linux-3.9.4/include/linux/vserver/network_cmd.h 1970-01-01 00:00:00.000000000 +0000
11937 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/network_cmd.h 2013-05-31 14:47:11.000000000 +0000
11939 +#ifndef _VSERVER_NETWORK_CMD_H
11940 +#define _VSERVER_NETWORK_CMD_H
11942 +#include <uapi/vserver/network_cmd.h>
11944 +extern int vc_task_nid(uint32_t);
11946 +extern int vc_nx_info(struct nx_info *, void __user *);
11948 +extern int vc_net_create(uint32_t, void __user *);
11949 +extern int vc_net_migrate(struct nx_info *, void __user *);
11951 +extern int vc_net_add(struct nx_info *, void __user *);
11952 +extern int vc_net_remove(struct nx_info *, void __user *);
11954 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
11955 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
11957 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
11958 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
11960 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
11961 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
11963 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
11964 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
11966 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
11967 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
11969 +extern int vc_get_nflags(struct nx_info *, void __user *);
11970 +extern int vc_set_nflags(struct nx_info *, void __user *);
11972 +extern int vc_get_ncaps(struct nx_info *, void __user *);
11973 +extern int vc_set_ncaps(struct nx_info *, void __user *);
11975 +#endif /* _VSERVER_CONTEXT_CMD_H */
11976 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/percpu.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/percpu.h
11977 --- linux-3.9.4/include/linux/vserver/percpu.h 1970-01-01 00:00:00.000000000 +0000
11978 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/percpu.h 2013-05-31 14:47:11.000000000 +0000
11980 +#ifndef _VSERVER_PERCPU_H
11981 +#define _VSERVER_PERCPU_H
11983 +#include "cvirt_def.h"
11984 +#include "sched_def.h"
11986 +struct _vx_percpu {
11987 + struct _vx_cvirt_pc cvirt;
11988 + struct _vx_sched_pc sched;
11991 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
11993 +#endif /* _VSERVER_PERCPU_H */
11994 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/pid.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/pid.h
11995 --- linux-3.9.4/include/linux/vserver/pid.h 1970-01-01 00:00:00.000000000 +0000
11996 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/pid.h 2013-05-31 14:47:11.000000000 +0000
11998 +#ifndef _VSERVER_PID_H
11999 +#define _VSERVER_PID_H
12001 +/* pid faking stuff */
12003 +#define vx_info_map_pid(v, p) \
12004 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
12005 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
12006 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
12007 +#define vx_map_tgid(p) vx_map_pid(p)
12009 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
12010 + const char *func, const char *file, int line)
12012 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12013 + vxfprintk(VXD_CBIT(cvirt, 2),
12014 + "vx_map_tgid: %p/%llx: %d -> %d",
12015 + vxi, (long long)vxi->vx_flags, pid,
12016 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
12017 + func, file, line);
12020 + if (pid == vxi->vx_initpid)
12026 +#define vx_info_rmap_pid(v, p) \
12027 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
12028 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
12029 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
12031 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
12032 + const char *func, const char *file, int line)
12034 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
12035 + vxfprintk(VXD_CBIT(cvirt, 2),
12036 + "vx_rmap_tgid: %p/%llx: %d -> %d",
12037 + vxi, (long long)vxi->vx_flags, pid,
12038 + (pid == 1) ? vxi->vx_initpid : pid,
12039 + func, file, line);
12040 + if ((pid == 1) && vxi->vx_initpid)
12041 + return vxi->vx_initpid;
12042 + if (pid == vxi->vx_initpid)
12049 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/sched.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/sched.h
12050 --- linux-3.9.4/include/linux/vserver/sched.h 1970-01-01 00:00:00.000000000 +0000
12051 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/sched.h 2013-05-31 14:47:11.000000000 +0000
12053 +#ifndef _VSERVER_SCHED_H
12054 +#define _VSERVER_SCHED_H
12061 +void vx_vsi_uptime(struct timespec *, struct timespec *);
12066 +void vx_update_load(struct vx_info *);
12069 +void vx_update_sched_param(struct _vx_sched *sched,
12070 + struct _vx_sched_pc *sched_pc);
12072 +#endif /* __KERNEL__ */
12073 +#else /* _VSERVER_SCHED_H */
12074 +#warning duplicate inclusion
12075 +#endif /* _VSERVER_SCHED_H */
12076 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/sched_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/sched_cmd.h
12077 --- linux-3.9.4/include/linux/vserver/sched_cmd.h 1970-01-01 00:00:00.000000000 +0000
12078 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/sched_cmd.h 2013-05-31 14:47:11.000000000 +0000
12080 +#ifndef _VSERVER_SCHED_CMD_H
12081 +#define _VSERVER_SCHED_CMD_H
12084 +#include <linux/compiler.h>
12085 +#include <uapi/vserver/sched_cmd.h>
12087 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
12088 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
12090 +#endif /* _VSERVER_SCHED_CMD_H */
12091 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/sched_def.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/sched_def.h
12092 --- linux-3.9.4/include/linux/vserver/sched_def.h 1970-01-01 00:00:00.000000000 +0000
12093 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/sched_def.h 2013-05-31 14:47:11.000000000 +0000
12095 +#ifndef _VSERVER_SCHED_DEF_H
12096 +#define _VSERVER_SCHED_DEF_H
12098 +#include <linux/spinlock.h>
12099 +#include <linux/jiffies.h>
12100 +#include <linux/cpumask.h>
12101 +#include <asm/atomic.h>
12102 +#include <asm/param.h>
12105 +/* context sub struct */
12107 +struct _vx_sched {
12108 + int prio_bias; /* bias offset for priority */
12110 + cpumask_t update; /* CPUs which should update */
12113 +struct _vx_sched_pc {
12114 + int prio_bias; /* bias offset for priority */
12116 + uint64_t user_ticks; /* token tick events */
12117 + uint64_t sys_ticks; /* token tick events */
12118 + uint64_t hold_ticks; /* token ticks paused */
12122 +#ifdef CONFIG_VSERVER_DEBUG
12124 +static inline void __dump_vx_sched(struct _vx_sched *sched)
12126 + printk("\t_vx_sched:\n");
12127 + printk("\t priority = %4d\n", sched->prio_bias);
12132 +#endif /* _VSERVER_SCHED_DEF_H */
12133 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/signal.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/signal.h
12134 --- linux-3.9.4/include/linux/vserver/signal.h 1970-01-01 00:00:00.000000000 +0000
12135 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/signal.h 2013-05-31 14:47:11.000000000 +0000
12137 +#ifndef _VSERVER_SIGNAL_H
12138 +#define _VSERVER_SIGNAL_H
12145 +int vx_info_kill(struct vx_info *, int, int);
12147 +#endif /* __KERNEL__ */
12148 +#else /* _VSERVER_SIGNAL_H */
12149 +#warning duplicate inclusion
12150 +#endif /* _VSERVER_SIGNAL_H */
12151 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/signal_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/signal_cmd.h
12152 --- linux-3.9.4/include/linux/vserver/signal_cmd.h 1970-01-01 00:00:00.000000000 +0000
12153 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/signal_cmd.h 2013-05-31 14:47:11.000000000 +0000
12155 +#ifndef _VSERVER_SIGNAL_CMD_H
12156 +#define _VSERVER_SIGNAL_CMD_H
12158 +#include <uapi/vserver/signal_cmd.h>
12161 +extern int vc_ctx_kill(struct vx_info *, void __user *);
12162 +extern int vc_wait_exit(struct vx_info *, void __user *);
12165 +extern int vc_get_pflags(uint32_t pid, void __user *);
12166 +extern int vc_set_pflags(uint32_t pid, void __user *);
12168 +#endif /* _VSERVER_SIGNAL_CMD_H */
12169 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/space.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/space.h
12170 --- linux-3.9.4/include/linux/vserver/space.h 1970-01-01 00:00:00.000000000 +0000
12171 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/space.h 2013-05-31 14:47:11.000000000 +0000
12173 +#ifndef _VSERVER_SPACE_H
12174 +#define _VSERVER_SPACE_H
12176 +#include <linux/types.h>
12180 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
12182 +#else /* _VSERVER_SPACE_H */
12183 +#warning duplicate inclusion
12184 +#endif /* _VSERVER_SPACE_H */
12185 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/space_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/space_cmd.h
12186 --- linux-3.9.4/include/linux/vserver/space_cmd.h 1970-01-01 00:00:00.000000000 +0000
12187 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/space_cmd.h 2013-05-31 14:47:11.000000000 +0000
12189 +#ifndef _VSERVER_SPACE_CMD_H
12190 +#define _VSERVER_SPACE_CMD_H
12192 +#include <uapi/vserver/space_cmd.h>
12195 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
12196 +extern int vc_set_space_v1(struct vx_info *, void __user *);
12197 +extern int vc_enter_space(struct vx_info *, void __user *);
12198 +extern int vc_set_space(struct vx_info *, void __user *);
12199 +extern int vc_get_space_mask(void __user *, int);
12201 +#endif /* _VSERVER_SPACE_CMD_H */
12202 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/switch.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/switch.h
12203 --- linux-3.9.4/include/linux/vserver/switch.h 1970-01-01 00:00:00.000000000 +0000
12204 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/switch.h 2013-05-31 14:47:11.000000000 +0000
12206 +#ifndef _VSERVER_SWITCH_H
12207 +#define _VSERVER_SWITCH_H
12210 +#include <linux/errno.h>
12211 +#include <uapi/vserver/switch.h>
12213 +#endif /* _VSERVER_SWITCH_H */
12214 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/tag.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/tag.h
12215 --- linux-3.9.4/include/linux/vserver/tag.h 1970-01-01 00:00:00.000000000 +0000
12216 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/tag.h 2013-06-03 20:23:02.000000000 +0000
12221 +#include <linux/types.h>
12222 +#include <linux/uidgid.h>
12225 +#define DX_TAG(in) (IS_TAGGED(in))
12228 +#ifdef CONFIG_TAG_NFSD
12229 +#define DX_TAG_NFSD 1
12231 +#define DX_TAG_NFSD 0
12235 +#ifdef CONFIG_TAGGING_NONE
12237 +#define MAX_UID 0xFFFFFFFF
12238 +#define MAX_GID 0xFFFFFFFF
12240 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
12242 +#define TAGINO_UID(cond, uid, tag) (uid)
12243 +#define TAGINO_GID(cond, gid, tag) (gid)
12248 +#ifdef CONFIG_TAGGING_GID16
12250 +#define MAX_UID 0xFFFFFFFF
12251 +#define MAX_GID 0x0000FFFF
12253 +#define INOTAG_TAG(cond, uid, gid, tag) \
12254 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
12256 +#define TAGINO_UID(cond, uid, tag) (uid)
12257 +#define TAGINO_GID(cond, gid, tag) \
12258 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
12263 +#ifdef CONFIG_TAGGING_ID24
12265 +#define MAX_UID 0x00FFFFFF
12266 +#define MAX_GID 0x00FFFFFF
12268 +#define INOTAG_TAG(cond, uid, gid, tag) \
12269 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
12271 +#define TAGINO_UID(cond, uid, tag) \
12272 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
12273 +#define TAGINO_GID(cond, gid, tag) \
12274 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
12279 +#ifdef CONFIG_TAGGING_UID16
12281 +#define MAX_UID 0x0000FFFF
12282 +#define MAX_GID 0xFFFFFFFF
12284 +#define INOTAG_TAG(cond, uid, gid, tag) \
12285 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
12287 +#define TAGINO_UID(cond, uid, tag) \
12288 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
12289 +#define TAGINO_GID(cond, gid, tag) (gid)
12294 +#ifdef CONFIG_TAGGING_INTERN
12296 +#define MAX_UID 0xFFFFFFFF
12297 +#define MAX_GID 0xFFFFFFFF
12299 +#define INOTAG_TAG(cond, uid, gid, tag) \
12300 + ((cond) ? (tag) : 0)
12302 +#define TAGINO_UID(cond, uid, tag) (uid)
12303 +#define TAGINO_GID(cond, gid, tag) (gid)
12308 +#ifndef CONFIG_TAGGING_NONE
12309 +#define dx_current_fstag(sb) \
12310 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
12312 +#define dx_current_fstag(sb) (0)
12315 +#ifndef CONFIG_TAGGING_INTERN
12316 +#define TAGINO_TAG(cond, tag) (0)
12318 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
12321 +#define TAGINO_KUID(cond, kuid, ktag) \
12322 + KUIDT_INIT(TAGINO_UID(cond, __kuid_val(kuid), __ktag_val(ktag)))
12323 +#define TAGINO_KGID(cond, kgid, ktag) \
12324 + KGIDT_INIT(TAGINO_GID(cond, __kgid_val(kgid), __ktag_val(ktag)))
12325 +#define TAGINO_KTAG(cond, ktag) \
12326 + KTAGT_INIT(TAGINO_TAG(cond, __ktag_val(ktag)))
12329 +#define INOTAG_UID(cond, uid, gid) \
12330 + ((cond) ? ((uid) & MAX_UID) : (uid))
12331 +#define INOTAG_GID(cond, uid, gid) \
12332 + ((cond) ? ((gid) & MAX_GID) : (gid))
12334 +#define INOTAG_KUID(cond, kuid, kgid) \
12335 + KUIDT_INIT(INOTAG_UID(cond, __kuid_val(kuid), __kgid_val(kgid)))
12336 +#define INOTAG_KGID(cond, kuid, kgid) \
12337 + KGIDT_INIT(INOTAG_GID(cond, __kuid_val(kuid), __kgid_val(kgid)))
12338 +#define INOTAG_KTAG(cond, kuid, kgid, ktag) \
12339 + KTAGT_INIT(INOTAG_TAG(cond, \
12340 + __kuid_val(kuid), __kgid_val(kgid), __ktag_val(ktag)))
12343 +static inline uid_t dx_map_uid(uid_t uid)
12345 + if ((uid > MAX_UID) && (uid != -1))
12347 + return (uid & MAX_UID);
12350 +static inline gid_t dx_map_gid(gid_t gid)
12352 + if ((gid > MAX_GID) && (gid != -1))
12354 + return (gid & MAX_GID);
12362 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
12364 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
12365 + unsigned long *flags);
12367 +#ifdef CONFIG_PROPAGATE
12369 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
12371 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
12374 +#define dx_propagate_tag(n, i) do { } while (0)
12377 +#endif /* _DX_TAG_H */
12378 diff -NurpP --minimal linux-3.9.4/include/linux/vserver/tag_cmd.h linux-3.9.4-vs2.3.6.3/include/linux/vserver/tag_cmd.h
12379 --- linux-3.9.4/include/linux/vserver/tag_cmd.h 1970-01-01 00:00:00.000000000 +0000
12380 +++ linux-3.9.4-vs2.3.6.3/include/linux/vserver/tag_cmd.h 2013-05-31 14:47:11.000000000 +0000
12382 +#ifndef _VSERVER_TAG_CMD_H
12383 +#define _VSERVER_TAG_CMD_H
12385 +#include <uapi/vserver/tag_cmd.h>
12387 +extern int vc_task_tag(uint32_t);
12389 +extern int vc_tag_migrate(uint32_t);
12391 +#endif /* _VSERVER_TAG_CMD_H */
12392 diff -NurpP --minimal linux-3.9.4/include/net/addrconf.h linux-3.9.4-vs2.3.6.3/include/net/addrconf.h
12393 --- linux-3.9.4/include/net/addrconf.h 2013-05-31 13:45:28.000000000 +0000
12394 +++ linux-3.9.4-vs2.3.6.3/include/net/addrconf.h 2013-05-31 17:17:53.000000000 +0000
12395 @@ -85,7 +85,8 @@ extern int ipv6_dev_get_saddr(struct n
12396 const struct net_device *dev,
12397 const struct in6_addr *daddr,
12398 unsigned int srcprefs,
12399 - struct in6_addr *saddr);
12400 + struct in6_addr *saddr,
12401 + struct nx_info *nxi);
12402 extern int ipv6_get_lladdr(struct net_device *dev,
12403 struct in6_addr *addr,
12404 unsigned char banned_flags);
12405 diff -NurpP --minimal linux-3.9.4/include/net/af_unix.h linux-3.9.4-vs2.3.6.3/include/net/af_unix.h
12406 --- linux-3.9.4/include/net/af_unix.h 2013-02-19 13:58:52.000000000 +0000
12407 +++ linux-3.9.4-vs2.3.6.3/include/net/af_unix.h 2013-05-31 17:17:53.000000000 +0000
12409 #include <linux/socket.h>
12410 #include <linux/un.h>
12411 #include <linux/mutex.h>
12412 +#include <linux/vs_base.h>
12413 #include <net/sock.h>
12415 extern void unix_inflight(struct file *fp);
12416 diff -NurpP --minimal linux-3.9.4/include/net/inet_timewait_sock.h linux-3.9.4-vs2.3.6.3/include/net/inet_timewait_sock.h
12417 --- linux-3.9.4/include/net/inet_timewait_sock.h 2013-05-31 13:45:28.000000000 +0000
12418 +++ linux-3.9.4-vs2.3.6.3/include/net/inet_timewait_sock.h 2013-05-31 17:18:34.000000000 +0000
12419 @@ -116,6 +116,10 @@ struct inet_timewait_sock {
12420 #define tw_dport __tw_common.skc_dport
12421 #define tw_num __tw_common.skc_num
12422 #define tw_portpair __tw_common.skc_portpair
12423 +#define tw_xid __tw_common.skc_xid
12424 +#define tw_vx_info __tw_common.skc_vx_info
12425 +#define tw_nid __tw_common.skc_nid
12426 +#define tw_nx_info __tw_common.skc_nx_info
12429 volatile unsigned char tw_substate;
12430 diff -NurpP --minimal linux-3.9.4/include/net/ip6_route.h linux-3.9.4-vs2.3.6.3/include/net/ip6_route.h
12431 --- linux-3.9.4/include/net/ip6_route.h 2013-05-31 13:45:28.000000000 +0000
12432 +++ linux-3.9.4-vs2.3.6.3/include/net/ip6_route.h 2013-05-31 17:17:53.000000000 +0000
12433 @@ -95,7 +95,8 @@ extern int ip6_route_get_saddr(struct
12434 struct rt6_info *rt,
12435 const struct in6_addr *daddr,
12436 unsigned int prefs,
12437 - struct in6_addr *saddr);
12438 + struct in6_addr *saddr,
12439 + struct nx_info *nxi);
12441 extern struct rt6_info *rt6_lookup(struct net *net,
12442 const struct in6_addr *daddr,
12443 diff -NurpP --minimal linux-3.9.4/include/net/route.h linux-3.9.4-vs2.3.6.3/include/net/route.h
12444 --- linux-3.9.4/include/net/route.h 2013-02-19 13:58:52.000000000 +0000
12445 +++ linux-3.9.4-vs2.3.6.3/include/net/route.h 2013-05-31 17:17:53.000000000 +0000
12446 @@ -207,6 +207,9 @@ static inline void ip_rt_put(struct rtab
12447 dst_release(&rt->dst);
12450 +#include <linux/vs_base.h>
12451 +#include <linux/vs_inet.h>
12453 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
12455 extern const __u8 ip_tos2prio[16];
12456 @@ -256,6 +259,9 @@ static inline void ip_route_connect_init
12457 protocol, flow_flags, dst, src, dport, sport);
12460 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
12461 + struct flowi4 *);
12463 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
12464 __be32 dst, __be32 src, u32 tos,
12465 int oif, u8 protocol,
12466 @@ -264,11 +270,25 @@ static inline struct rtable *ip_route_co
12468 struct net *net = sock_net(sk);
12470 + struct nx_info *nx_info = current_nx_info();
12472 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
12473 sport, dport, sk, can_sleep);
12475 - if (!dst || !src) {
12477 + nx_info = sk->sk_nx_info;
12479 + vxdprintk(VXD_CBIT(net, 4),
12480 + "ip_route_connect(%p) %p,%p;%lx",
12481 + sk, nx_info, sk->sk_socket,
12482 + (sk->sk_socket?sk->sk_socket->flags:0));
12484 + rt = ip_v4_find_src(net, nx_info, fl4);
12489 + if (!fl4->daddr || !fl4->saddr) {
12490 rt = __ip_route_output_key(net, fl4);
12493 diff -NurpP --minimal linux-3.9.4/include/net/sock.h linux-3.9.4-vs2.3.6.3/include/net/sock.h
12494 --- linux-3.9.4/include/net/sock.h 2013-05-31 14:22:27.000000000 +0000
12495 +++ linux-3.9.4-vs2.3.6.3/include/net/sock.h 2013-05-31 17:17:53.000000000 +0000
12496 @@ -191,6 +191,10 @@ struct sock_common {
12497 #ifdef CONFIG_NET_NS
12498 struct net *skc_net;
12501 + struct vx_info *skc_vx_info;
12503 + struct nx_info *skc_nx_info;
12505 * fields between dontcopy_begin/dontcopy_end
12506 * are not copied in sock_copy()
12507 @@ -304,6 +308,10 @@ struct sock {
12508 #define sk_bind_node __sk_common.skc_bind_node
12509 #define sk_prot __sk_common.skc_prot
12510 #define sk_net __sk_common.skc_net
12511 +#define sk_xid __sk_common.skc_xid
12512 +#define sk_vx_info __sk_common.skc_vx_info
12513 +#define sk_nid __sk_common.skc_nid
12514 +#define sk_nx_info __sk_common.skc_nx_info
12515 socket_lock_t sk_lock;
12516 struct sk_buff_head sk_receive_queue;
12518 diff -NurpP --minimal linux-3.9.4/include/uapi/Kbuild linux-3.9.4-vs2.3.6.3/include/uapi/Kbuild
12519 --- linux-3.9.4/include/uapi/Kbuild 2012-12-11 03:30:57.000000000 +0000
12520 +++ linux-3.9.4-vs2.3.6.3/include/uapi/Kbuild 2013-05-31 14:47:11.000000000 +0000
12521 @@ -12,3 +12,4 @@ header-y += video/
12525 +header-y += vserver/
12526 diff -NurpP --minimal linux-3.9.4/include/uapi/linux/capability.h linux-3.9.4-vs2.3.6.3/include/uapi/linux/capability.h
12527 --- linux-3.9.4/include/uapi/linux/capability.h 2012-12-11 03:30:57.000000000 +0000
12528 +++ linux-3.9.4-vs2.3.6.3/include/uapi/linux/capability.h 2013-05-31 14:47:11.000000000 +0000
12529 @@ -259,6 +259,7 @@ struct vfs_cap_data {
12530 arbitrary SCSI commands */
12531 /* Allow setting encryption key on loopback filesystem */
12532 /* Allow setting zone reclaim policy */
12533 +/* Allow the selection of a security context */
12535 #define CAP_SYS_ADMIN 21
12537 @@ -345,7 +346,12 @@ struct vfs_cap_data {
12539 #define CAP_LAST_CAP CAP_BLOCK_SUSPEND
12541 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
12542 +/* Allow context manipulations */
12543 +/* Allow changing context info on files */
12545 +#define CAP_CONTEXT 63
12547 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
12550 * Bit location of each capability (used by user-space library and kernel)
12551 diff -NurpP --minimal linux-3.9.4/include/uapi/linux/fs.h linux-3.9.4-vs2.3.6.3/include/uapi/linux/fs.h
12552 --- linux-3.9.4/include/uapi/linux/fs.h 2013-05-31 13:45:29.000000000 +0000
12553 +++ linux-3.9.4-vs2.3.6.3/include/uapi/linux/fs.h 2013-05-31 23:07:43.000000000 +0000
12554 @@ -86,6 +86,9 @@ struct inodes_stat_t {
12555 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
12556 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
12557 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
12558 +#define MS_TAGGED (1<<8) /* use generic inode tagging */
12559 +#define MS_NOTAGCHECK (1<<9) /* don't check tags */
12560 +#define MS_TAGID (1<<25) /* use specific tag for this mount */
12562 /* These sb flags are internal to the kernel */
12563 #define MS_SNAP_STABLE (1<<27) /* Snapshot pages during writeback, if needed */
12564 @@ -192,11 +195,14 @@ struct inodes_stat_t {
12565 #define FS_EXTENT_FL 0x00080000 /* Extents */
12566 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
12567 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
12568 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
12569 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
12571 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
12572 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
12573 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
12574 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
12576 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
12577 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
12579 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
12580 #define SYNC_FILE_RANGE_WRITE 2
12581 diff -NurpP --minimal linux-3.9.4/include/uapi/linux/gfs2_ondisk.h linux-3.9.4-vs2.3.6.3/include/uapi/linux/gfs2_ondisk.h
12582 --- linux-3.9.4/include/uapi/linux/gfs2_ondisk.h 2012-12-11 03:30:57.000000000 +0000
12583 +++ linux-3.9.4-vs2.3.6.3/include/uapi/linux/gfs2_ondisk.h 2013-05-31 14:47:11.000000000 +0000
12584 @@ -225,6 +225,9 @@ enum {
12587 gfs2fl_TopLevel = 10,
12588 + gfs2fl_IXUnlink = 16,
12589 + gfs2fl_Barrier = 17,
12591 gfs2fl_TruncInProg = 29,
12592 gfs2fl_InheritDirectio = 30,
12593 gfs2fl_InheritJdata = 31,
12594 @@ -242,6 +245,9 @@ enum {
12595 #define GFS2_DIF_SYNC 0x00000100
12596 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
12597 #define GFS2_DIF_TOPDIR 0x00000400 /* New in gfs2 */
12598 +#define GFS2_DIF_IXUNLINK 0x00010000
12599 +#define GFS2_DIF_BARRIER 0x00020000
12600 +#define GFS2_DIF_COW 0x00040000
12601 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
12602 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000 /* only in gfs1 */
12603 #define GFS2_DIF_INHERIT_JDATA 0x80000000
12604 diff -NurpP --minimal linux-3.9.4/include/uapi/linux/if_tun.h linux-3.9.4-vs2.3.6.3/include/uapi/linux/if_tun.h
12605 --- linux-3.9.4/include/uapi/linux/if_tun.h 2013-02-19 13:58:55.000000000 +0000
12606 +++ linux-3.9.4-vs2.3.6.3/include/uapi/linux/if_tun.h 2013-05-31 15:00:16.000000000 +0000
12608 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
12609 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
12610 #define TUNSETQUEUE _IOW('T', 217, int)
12611 +#define TUNSETNID _IOW('T', 218, int)
12613 /* TUNSETIFF ifr flags */
12614 #define IFF_TUN 0x0001
12615 diff -NurpP --minimal linux-3.9.4/include/uapi/linux/major.h linux-3.9.4-vs2.3.6.3/include/uapi/linux/major.h
12616 --- linux-3.9.4/include/uapi/linux/major.h 2012-12-11 03:30:57.000000000 +0000
12617 +++ linux-3.9.4-vs2.3.6.3/include/uapi/linux/major.h 2013-05-31 14:47:11.000000000 +0000
12619 #define HD_MAJOR IDE0_MAJOR
12620 #define PTY_SLAVE_MAJOR 3
12621 #define TTY_MAJOR 4
12622 +#define VROOT_MAJOR 4
12623 #define TTYAUX_MAJOR 5
12625 #define VCS_MAJOR 7
12626 diff -NurpP --minimal linux-3.9.4/include/uapi/linux/nfs_mount.h linux-3.9.4-vs2.3.6.3/include/uapi/linux/nfs_mount.h
12627 --- linux-3.9.4/include/uapi/linux/nfs_mount.h 2012-12-11 03:30:57.000000000 +0000
12628 +++ linux-3.9.4-vs2.3.6.3/include/uapi/linux/nfs_mount.h 2013-05-31 14:47:11.000000000 +0000
12629 @@ -63,7 +63,8 @@ struct nfs_mount_data {
12630 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
12631 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
12632 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
12633 -#define NFS_MOUNT_FLAGMASK 0xFFFF
12634 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
12635 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
12637 /* The following are for internal use only */
12638 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
12639 diff -NurpP --minimal linux-3.9.4/include/uapi/linux/reboot.h linux-3.9.4-vs2.3.6.3/include/uapi/linux/reboot.h
12640 --- linux-3.9.4/include/uapi/linux/reboot.h 2012-12-11 03:30:57.000000000 +0000
12641 +++ linux-3.9.4-vs2.3.6.3/include/uapi/linux/reboot.h 2013-05-31 14:47:11.000000000 +0000
12643 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
12644 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
12645 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
12647 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
12650 #endif /* _UAPI_LINUX_REBOOT_H */
12651 diff -NurpP --minimal linux-3.9.4/include/uapi/linux/sysctl.h linux-3.9.4-vs2.3.6.3/include/uapi/linux/sysctl.h
12652 --- linux-3.9.4/include/uapi/linux/sysctl.h 2012-12-11 03:30:57.000000000 +0000
12653 +++ linux-3.9.4-vs2.3.6.3/include/uapi/linux/sysctl.h 2013-05-31 14:47:11.000000000 +0000
12654 @@ -60,6 +60,7 @@ enum
12655 CTL_ABI=9, /* Binary emulation */
12656 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
12657 CTL_ARLAN=254, /* arlan wireless driver */
12658 + CTL_VSERVER=4242, /* Linux-VServer debug */
12659 CTL_S390DBF=5677, /* s390 debug */
12660 CTL_SUNRPC=7249, /* sunrpc debug */
12661 CTL_PM=9899, /* frv power management */
12662 @@ -94,6 +95,7 @@ enum
12664 KERN_PANIC=15, /* int: panic timeout */
12665 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
12666 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
12668 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
12669 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
12670 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/Kbuild linux-3.9.4-vs2.3.6.3/include/uapi/vserver/Kbuild
12671 --- linux-3.9.4/include/uapi/vserver/Kbuild 1970-01-01 00:00:00.000000000 +0000
12672 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/Kbuild 2013-05-31 14:47:11.000000000 +0000
12675 +header-y += context_cmd.h network_cmd.h space_cmd.h \
12676 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
12677 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
12678 + debug_cmd.h device_cmd.h
12680 +header-y += switch.h context.h network.h monitor.h \
12681 + limit.h inode.h device.h
12683 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/cacct_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/cacct_cmd.h
12684 --- linux-3.9.4/include/uapi/vserver/cacct_cmd.h 1970-01-01 00:00:00.000000000 +0000
12685 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/cacct_cmd.h 2013-05-31 14:47:11.000000000 +0000
12687 +#ifndef _UAPI_VS_CACCT_CMD_H
12688 +#define _UAPI_VS_CACCT_CMD_H
12691 +/* virtual host info name commands */
12693 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
12695 +struct vcmd_sock_stat_v0 {
12697 + uint32_t count[3];
12698 + uint64_t total[3];
12701 +#endif /* _UAPI_VS_CACCT_CMD_H */
12702 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/context.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/context.h
12703 --- linux-3.9.4/include/uapi/vserver/context.h 1970-01-01 00:00:00.000000000 +0000
12704 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/context.h 2013-05-31 19:44:13.000000000 +0000
12706 +#ifndef _UAPI_VS_CONTEXT_H
12707 +#define _UAPI_VS_CONTEXT_H
12709 +#include <linux/types.h>
12710 +#include <linux/capability.h>
12713 +/* context flags */
12715 +#define VXF_INFO_SCHED 0x00000002
12716 +#define VXF_INFO_NPROC 0x00000004
12717 +#define VXF_INFO_PRIVATE 0x00000008
12719 +#define VXF_INFO_INIT 0x00000010
12720 +#define VXF_INFO_HIDE 0x00000020
12721 +#define VXF_INFO_ULIMIT 0x00000040
12722 +#define VXF_INFO_NSPACE 0x00000080
12724 +#define VXF_SCHED_HARD 0x00000100
12725 +#define VXF_SCHED_PRIO 0x00000200
12726 +#define VXF_SCHED_PAUSE 0x00000400
12728 +#define VXF_VIRT_MEM 0x00010000
12729 +#define VXF_VIRT_UPTIME 0x00020000
12730 +#define VXF_VIRT_CPU 0x00040000
12731 +#define VXF_VIRT_LOAD 0x00080000
12732 +#define VXF_VIRT_TIME 0x00100000
12734 +#define VXF_HIDE_MOUNT 0x01000000
12735 +/* was VXF_HIDE_NETIF 0x02000000 */
12736 +#define VXF_HIDE_VINFO 0x04000000
12738 +#define VXF_STATE_SETUP (1ULL << 32)
12739 +#define VXF_STATE_INIT (1ULL << 33)
12740 +#define VXF_STATE_ADMIN (1ULL << 34)
12742 +#define VXF_SC_HELPER (1ULL << 36)
12743 +#define VXF_REBOOT_KILL (1ULL << 37)
12744 +#define VXF_PERSISTENT (1ULL << 38)
12746 +#define VXF_FORK_RSS (1ULL << 48)
12747 +#define VXF_PROLIFIC (1ULL << 49)
12749 +#define VXF_IGNEG_NICE (1ULL << 52)
12751 +#define VXF_ONE_TIME (0x0007ULL << 32)
12753 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
12756 +/* context migration */
12758 +#define VXM_SET_INIT 0x00000001
12759 +#define VXM_SET_REAPER 0x00000002
12761 +/* context caps */
12763 +#define VXC_SET_UTSNAME 0x00000001
12764 +#define VXC_SET_RLIMIT 0x00000002
12765 +#define VXC_FS_SECURITY 0x00000004
12766 +#define VXC_FS_TRUSTED 0x00000008
12767 +#define VXC_TIOCSTI 0x00000010
12769 +/* was VXC_RAW_ICMP 0x00000100 */
12770 +#define VXC_SYSLOG 0x00001000
12771 +#define VXC_OOM_ADJUST 0x00002000
12772 +#define VXC_AUDIT_CONTROL 0x00004000
12774 +/* #define VXC_SECURE_MOUNT 0x00010000
12775 +#define VXC_SECURE_REMOUNT 0x00020000 */
12776 +#define VXC_BINARY_MOUNT 0x00040000
12777 +#define VXC_DEV_MOUNT 0x00080000
12779 +#define VXC_QUOTA_CTL 0x00100000
12780 +#define VXC_ADMIN_MAPPER 0x00200000
12781 +#define VXC_ADMIN_CLOOP 0x00400000
12783 +#define VXC_KTHREAD 0x01000000
12784 +#define VXC_NAMESPACE 0x02000000
12786 +#endif /* _UAPI_VS_CONTEXT_H */
12787 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/context_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/context_cmd.h
12788 --- linux-3.9.4/include/uapi/vserver/context_cmd.h 1970-01-01 00:00:00.000000000 +0000
12789 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/context_cmd.h 2013-05-31 14:47:11.000000000 +0000
12791 +#ifndef _UAPI_VS_CONTEXT_CMD_H
12792 +#define _UAPI_VS_CONTEXT_CMD_H
12795 +/* vinfo commands */
12797 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
12800 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
12802 +struct vcmd_vx_info_v0 {
12804 + uint32_t initpid;
12805 + /* more to come */
12809 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
12811 +struct vcmd_ctx_stat_v0 {
12814 + /* more to come */
12818 +/* context commands */
12820 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
12821 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
12823 +struct vcmd_ctx_create {
12824 + uint64_t flagword;
12827 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
12828 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
12830 +struct vcmd_ctx_migrate {
12831 + uint64_t flagword;
12836 +/* flag commands */
12838 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
12839 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
12841 +struct vcmd_ctx_flags_v0 {
12842 + uint64_t flagword;
12848 +/* context caps commands */
12850 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
12851 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
12853 +struct vcmd_ctx_caps_v1 {
12860 +/* bcaps commands */
12862 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
12863 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
12865 +struct vcmd_bcaps {
12872 +/* umask commands */
12874 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
12875 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
12877 +struct vcmd_umask {
12884 +/* wmask commands */
12886 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
12887 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
12889 +struct vcmd_wmask {
12898 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
12899 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
12901 +struct vcmd_badness_v0 {
12905 +#endif /* _UAPI_VS_CONTEXT_CMD_H */
12906 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/cvirt_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/cvirt_cmd.h
12907 --- linux-3.9.4/include/uapi/vserver/cvirt_cmd.h 1970-01-01 00:00:00.000000000 +0000
12908 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/cvirt_cmd.h 2013-05-31 14:47:11.000000000 +0000
12910 +#ifndef _UAPI_VS_CVIRT_CMD_H
12911 +#define _UAPI_VS_CVIRT_CMD_H
12914 +/* virtual host info name commands */
12916 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
12917 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
12919 +struct vcmd_vhi_name_v0 {
12925 +enum vhi_name_field {
12926 + VHIN_CONTEXT = 0,
12937 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
12939 +struct vcmd_virt_stat_v0 {
12942 + uint32_t nr_threads;
12943 + uint32_t nr_running;
12944 + uint32_t nr_uninterruptible;
12945 + uint32_t nr_onhold;
12946 + uint32_t nr_forks;
12947 + uint32_t load[3];
12950 +#endif /* _UAPI_VS_CVIRT_CMD_H */
12951 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/debug_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/debug_cmd.h
12952 --- linux-3.9.4/include/uapi/vserver/debug_cmd.h 1970-01-01 00:00:00.000000000 +0000
12953 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/debug_cmd.h 2013-05-31 14:47:11.000000000 +0000
12955 +#ifndef _UAPI_VS_DEBUG_CMD_H
12956 +#define _UAPI_VS_DEBUG_CMD_H
12959 +/* debug commands */
12961 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
12963 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
12964 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
12966 +struct vcmd_read_history_v0 {
12969 + char __user *data;
12972 +struct vcmd_read_monitor_v0 {
12975 + char __user *data;
12978 +#endif /* _UAPI_VS_DEBUG_CMD_H */
12979 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/device.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/device.h
12980 --- linux-3.9.4/include/uapi/vserver/device.h 1970-01-01 00:00:00.000000000 +0000
12981 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/device.h 2013-05-31 14:47:11.000000000 +0000
12983 +#ifndef _UAPI_VS_DEVICE_H
12984 +#define _UAPI_VS_DEVICE_H
12987 +#define DATTR_CREATE 0x00000001
12988 +#define DATTR_OPEN 0x00000002
12990 +#define DATTR_REMAP 0x00000010
12992 +#define DATTR_MASK 0x00000013
12994 +#endif /* _UAPI_VS_DEVICE_H */
12995 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/device_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/device_cmd.h
12996 --- linux-3.9.4/include/uapi/vserver/device_cmd.h 1970-01-01 00:00:00.000000000 +0000
12997 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/device_cmd.h 2013-05-31 14:47:11.000000000 +0000
12999 +#ifndef _UAPI_VS_DEVICE_CMD_H
13000 +#define _UAPI_VS_DEVICE_CMD_H
13003 +/* device vserver commands */
13005 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
13006 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
13008 +struct vcmd_set_mapping_v0 {
13009 + const char __user *device;
13010 + const char __user *target;
13014 +#endif /* _UAPI_VS_DEVICE_CMD_H */
13015 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/dlimit_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/dlimit_cmd.h
13016 --- linux-3.9.4/include/uapi/vserver/dlimit_cmd.h 1970-01-01 00:00:00.000000000 +0000
13017 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/dlimit_cmd.h 2013-05-31 14:47:11.000000000 +0000
13019 +#ifndef _UAPI_VS_DLIMIT_CMD_H
13020 +#define _UAPI_VS_DLIMIT_CMD_H
13023 +/* dlimit vserver commands */
13025 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
13026 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
13028 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
13029 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
13031 +struct vcmd_ctx_dlimit_base_v0 {
13032 + const char __user *name;
13036 +struct vcmd_ctx_dlimit_v0 {
13037 + const char __user *name;
13038 + uint32_t space_used; /* used space in kbytes */
13039 + uint32_t space_total; /* maximum space in kbytes */
13040 + uint32_t inodes_used; /* used inodes */
13041 + uint32_t inodes_total; /* maximum inodes */
13042 + uint32_t reserved; /* reserved for root in % */
13046 +#define CDLIM_UNSET ((uint32_t)0UL)
13047 +#define CDLIM_INFINITY ((uint32_t)~0UL)
13048 +#define CDLIM_KEEP ((uint32_t)~1UL)
13050 +#define DLIME_UNIT 0
13051 +#define DLIME_KILO 1
13052 +#define DLIME_MEGA 2
13053 +#define DLIME_GIGA 3
13055 +#define DLIMF_SHIFT 0x10
13057 +#define DLIMS_USED 0
13058 +#define DLIMS_TOTAL 2
13061 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
13063 + int exp = (flags & DLIMF_SHIFT) ?
13064 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
13065 + return ((uint64_t)val) << (10 * exp);
13069 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
13073 + if (*flags & DLIMF_SHIFT) {
13074 + while (val > (1LL << 32) && (exp < 3)) {
13078 + *flags &= ~(DLIME_GIGA << shift);
13079 + *flags |= exp << shift;
13085 +#endif /* _UAPI_VS_DLIMIT_CMD_H */
13086 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/inode.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/inode.h
13087 --- linux-3.9.4/include/uapi/vserver/inode.h 1970-01-01 00:00:00.000000000 +0000
13088 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/inode.h 2013-05-31 14:47:11.000000000 +0000
13090 +#ifndef _UAPI_VS_INODE_H
13091 +#define _UAPI_VS_INODE_H
13094 +#define IATTR_TAG 0x01000000
13096 +#define IATTR_ADMIN 0x00000001
13097 +#define IATTR_WATCH 0x00000002
13098 +#define IATTR_HIDE 0x00000004
13099 +#define IATTR_FLAGS 0x00000007
13101 +#define IATTR_BARRIER 0x00010000
13102 +#define IATTR_IXUNLINK 0x00020000
13103 +#define IATTR_IMMUTABLE 0x00040000
13104 +#define IATTR_COW 0x00080000
13107 +/* inode ioctls */
13109 +#define FIOC_GETXFLG _IOR('x', 5, long)
13110 +#define FIOC_SETXFLG _IOW('x', 6, long)
13112 +#endif /* _UAPI_VS_INODE_H */
13113 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/inode_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/inode_cmd.h
13114 --- linux-3.9.4/include/uapi/vserver/inode_cmd.h 1970-01-01 00:00:00.000000000 +0000
13115 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/inode_cmd.h 2013-05-31 14:47:11.000000000 +0000
13117 +#ifndef _UAPI_VS_INODE_CMD_H
13118 +#define _UAPI_VS_INODE_CMD_H
13121 +/* inode vserver commands */
13123 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
13124 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
13126 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
13127 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
13129 +struct vcmd_ctx_iattr_v1 {
13130 + const char __user *name;
13136 +struct vcmd_ctx_fiattr_v0 {
13142 +#endif /* _UAPI_VS_INODE_CMD_H */
13143 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/limit.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/limit.h
13144 --- linux-3.9.4/include/uapi/vserver/limit.h 1970-01-01 00:00:00.000000000 +0000
13145 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/limit.h 2013-05-31 14:47:11.000000000 +0000
13147 +#ifndef _UAPI_VS_LIMIT_H
13148 +#define _UAPI_VS_LIMIT_H
13151 +#define VLIMIT_NSOCK 16
13152 +#define VLIMIT_OPENFD 17
13153 +#define VLIMIT_ANON 18
13154 +#define VLIMIT_SHMEM 19
13155 +#define VLIMIT_SEMARY 20
13156 +#define VLIMIT_NSEMS 21
13157 +#define VLIMIT_DENTRY 22
13158 +#define VLIMIT_MAPPED 23
13160 +#endif /* _UAPI_VS_LIMIT_H */
13161 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/limit_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/limit_cmd.h
13162 --- linux-3.9.4/include/uapi/vserver/limit_cmd.h 1970-01-01 00:00:00.000000000 +0000
13163 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/limit_cmd.h 2013-05-31 14:47:11.000000000 +0000
13165 +#ifndef _UAPI_VS_LIMIT_CMD_H
13166 +#define _UAPI_VS_LIMIT_CMD_H
13169 +/* rlimit vserver commands */
13171 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
13172 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
13173 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
13174 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
13175 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
13177 +struct vcmd_ctx_rlimit_v0 {
13179 + uint64_t minimum;
13180 + uint64_t softlimit;
13181 + uint64_t maximum;
13184 +struct vcmd_ctx_rlimit_mask_v0 {
13185 + uint32_t minimum;
13186 + uint32_t softlimit;
13187 + uint32_t maximum;
13190 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
13192 +struct vcmd_rlimit_stat_v0 {
13196 + uint64_t minimum;
13197 + uint64_t maximum;
13200 +#define CRLIM_UNSET (0ULL)
13201 +#define CRLIM_INFINITY (~0ULL)
13202 +#define CRLIM_KEEP (~1ULL)
13204 +#endif /* _UAPI_VS_LIMIT_CMD_H */
13205 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/monitor.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/monitor.h
13206 --- linux-3.9.4/include/uapi/vserver/monitor.h 1970-01-01 00:00:00.000000000 +0000
13207 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/monitor.h 2013-05-31 14:47:11.000000000 +0000
13209 +#ifndef _UAPI_VS_MONITOR_H
13210 +#define _UAPI_VS_MONITOR_H
13212 +#include <linux/types.h>
13220 + VXM_UPDATE = 0x20,
13224 + VXM_RQINFO_1 = 0x24,
13227 + VXM_ACTIVATE = 0x40,
13234 + VXM_MIGRATE = 0x48,
13237 + /* all other bits are flags */
13238 + VXM_SCHED = 0x80,
13241 +struct _vxm_update_1 {
13242 + uint32_t tokens_max;
13243 + uint32_t fill_rate;
13244 + uint32_t interval;
13247 +struct _vxm_update_2 {
13248 + uint32_t tokens_min;
13249 + uint32_t fill_rate;
13250 + uint32_t interval;
13253 +struct _vxm_rqinfo_1 {
13254 + uint16_t running;
13258 + uint32_t idle_tokens;
13261 +struct _vxm_rqinfo_2 {
13262 + uint32_t norm_time;
13263 + uint32_t idle_time;
13264 + uint32_t idle_skip;
13267 +struct _vxm_sched {
13269 + uint32_t norm_time;
13270 + uint32_t idle_time;
13273 +struct _vxm_task {
13278 +struct _vxm_event {
13287 + struct _vxm_task tsk;
13291 +struct _vx_mon_entry {
13295 + struct _vxm_event ev;
13296 + struct _vxm_sched sd;
13297 + struct _vxm_update_1 u1;
13298 + struct _vxm_update_2 u2;
13299 + struct _vxm_rqinfo_1 q1;
13300 + struct _vxm_rqinfo_2 q2;
13304 +#endif /* _UAPI_VS_MONITOR_H */
13305 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/network.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/network.h
13306 --- linux-3.9.4/include/uapi/vserver/network.h 1970-01-01 00:00:00.000000000 +0000
13307 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/network.h 2013-05-31 14:47:11.000000000 +0000
13309 +#ifndef _UAPI_VS_NETWORK_H
13310 +#define _UAPI_VS_NETWORK_H
13312 +#include <linux/types.h>
13315 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13318 +/* network flags */
13320 +#define NXF_INFO_PRIVATE 0x00000008
13322 +#define NXF_SINGLE_IP 0x00000100
13323 +#define NXF_LBACK_REMAP 0x00000200
13324 +#define NXF_LBACK_ALLOW 0x00000400
13326 +#define NXF_HIDE_NETIF 0x02000000
13327 +#define NXF_HIDE_LBACK 0x04000000
13329 +#define NXF_STATE_SETUP (1ULL << 32)
13330 +#define NXF_STATE_ADMIN (1ULL << 34)
13332 +#define NXF_SC_HELPER (1ULL << 36)
13333 +#define NXF_PERSISTENT (1ULL << 38)
13335 +#define NXF_ONE_TIME (0x0005ULL << 32)
13338 +#define NXF_INIT_SET (__nxf_init_set())
13340 +static inline uint64_t __nxf_init_set(void) {
13341 + return NXF_STATE_ADMIN
13342 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13343 + | NXF_LBACK_REMAP
13346 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13349 + | NXF_HIDE_NETIF;
13353 +/* network caps */
13355 +#define NXC_TUN_CREATE 0x00000001
13357 +#define NXC_RAW_ICMP 0x00000100
13359 +#define NXC_MULTICAST 0x00001000
13362 +/* address types */
13364 +#define NXA_TYPE_IPV4 0x0001
13365 +#define NXA_TYPE_IPV6 0x0002
13367 +#define NXA_TYPE_NONE 0x0000
13368 +#define NXA_TYPE_ANY 0x00FF
13370 +#define NXA_TYPE_ADDR 0x0010
13371 +#define NXA_TYPE_MASK 0x0020
13372 +#define NXA_TYPE_RANGE 0x0040
13374 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13376 +#define NXA_MOD_BCAST 0x0100
13377 +#define NXA_MOD_LBACK 0x0200
13379 +#define NXA_LOOPBACK 0x1000
13381 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13382 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13384 +#endif /* _UAPI_VS_NETWORK_H */
13385 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/network_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/network_cmd.h
13386 --- linux-3.9.4/include/uapi/vserver/network_cmd.h 1970-01-01 00:00:00.000000000 +0000
13387 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/network_cmd.h 2013-05-31 14:47:11.000000000 +0000
13389 +#ifndef _UAPI_VS_NETWORK_CMD_H
13390 +#define _UAPI_VS_NETWORK_CMD_H
13393 +/* vinfo commands */
13395 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13398 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13400 +struct vcmd_nx_info_v0 {
13402 + /* more to come */
13406 +#include <linux/in.h>
13407 +#include <linux/in6.h>
13409 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13410 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13412 +struct vcmd_net_create {
13413 + uint64_t flagword;
13416 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13418 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13419 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13421 +struct vcmd_net_addr_v0 {
13424 + struct in_addr ip[4];
13425 + struct in_addr mask[4];
13428 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13429 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13431 +struct vcmd_net_addr_ipv4_v1 {
13434 + struct in_addr ip;
13435 + struct in_addr mask;
13438 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13439 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13441 +struct vcmd_net_addr_ipv4_v2 {
13444 + struct in_addr ip;
13445 + struct in_addr ip2;
13446 + struct in_addr mask;
13449 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13450 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13452 +struct vcmd_net_addr_ipv6_v1 {
13456 + struct in6_addr ip;
13457 + struct in6_addr mask;
13460 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13461 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13463 +struct vcmd_match_ipv4_v0 {
13468 + struct in_addr ip;
13469 + struct in_addr ip2;
13470 + struct in_addr mask;
13473 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13474 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13476 +struct vcmd_match_ipv6_v0 {
13481 + struct in6_addr ip;
13482 + struct in6_addr ip2;
13483 + struct in6_addr mask;
13489 +/* flag commands */
13491 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13492 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13494 +struct vcmd_net_flags_v0 {
13495 + uint64_t flagword;
13501 +/* network caps commands */
13503 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13504 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13506 +struct vcmd_net_caps_v0 {
13511 +#endif /* _UAPI_VS_NETWORK_CMD_H */
13512 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/sched_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/sched_cmd.h
13513 --- linux-3.9.4/include/uapi/vserver/sched_cmd.h 1970-01-01 00:00:00.000000000 +0000
13514 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/sched_cmd.h 2013-05-31 14:47:11.000000000 +0000
13516 +#ifndef _UAPI_VS_SCHED_CMD_H
13517 +#define _UAPI_VS_SCHED_CMD_H
13520 +struct vcmd_prio_bias {
13522 + int32_t prio_bias;
13525 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13526 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13528 +#endif /* _UAPI_VS_SCHED_CMD_H */
13529 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/signal_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/signal_cmd.h
13530 --- linux-3.9.4/include/uapi/vserver/signal_cmd.h 1970-01-01 00:00:00.000000000 +0000
13531 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/signal_cmd.h 2013-05-31 14:47:11.000000000 +0000
13533 +#ifndef _UAPI_VS_SIGNAL_CMD_H
13534 +#define _UAPI_VS_SIGNAL_CMD_H
13537 +/* signalling vserver commands */
13539 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13540 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13542 +struct vcmd_ctx_kill_v0 {
13547 +struct vcmd_wait_exit_v0 {
13548 + int32_t reboot_cmd;
13549 + int32_t exit_code;
13553 +/* process alteration commands */
13555 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13556 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13558 +struct vcmd_pflags_v0 {
13559 + uint32_t flagword;
13563 +#endif /* _UAPI_VS_SIGNAL_CMD_H */
13564 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/space_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/space_cmd.h
13565 --- linux-3.9.4/include/uapi/vserver/space_cmd.h 1970-01-01 00:00:00.000000000 +0000
13566 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/space_cmd.h 2013-05-31 14:47:11.000000000 +0000
13568 +#ifndef _UAPI_VS_SPACE_CMD_H
13569 +#define _UAPI_VS_SPACE_CMD_H
13572 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13573 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13574 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13576 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13577 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13578 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13580 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13582 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13583 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13586 +struct vcmd_space_mask_v1 {
13590 +struct vcmd_space_mask_v2 {
13595 +#endif /* _UAPI_VS_SPACE_CMD_H */
13596 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/switch.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/switch.h
13597 --- linux-3.9.4/include/uapi/vserver/switch.h 1970-01-01 00:00:00.000000000 +0000
13598 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/switch.h 2013-05-31 14:47:11.000000000 +0000
13600 +#ifndef _UAPI_VS_SWITCH_H
13601 +#define _UAPI_VS_SWITCH_H
13603 +#include <linux/types.h>
13606 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13607 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13608 +#define VC_VERSION(c) ((c) & 0xFFF)
13610 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13611 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13615 + Syscall Matrix V2.8
13617 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13618 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13619 + |INFO |SETUP | |MOVE | | | | | |
13620 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13621 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13622 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13623 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13624 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13625 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13626 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13627 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13628 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13629 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13630 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13631 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13632 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13633 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13634 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13635 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13636 + OTHER |VSTAT | | | | | | |VINFO | |
13637 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13638 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13639 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13640 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13641 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13642 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13643 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13644 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13648 +#define VC_CAT_VERSION 0
13650 +#define VC_CAT_VSETUP 1
13651 +#define VC_CAT_VHOST 2
13653 +#define VC_CAT_DEVICE 6
13655 +#define VC_CAT_VPROC 9
13656 +#define VC_CAT_PROCALT 10
13657 +#define VC_CAT_PROCMIG 11
13658 +#define VC_CAT_PROCTRL 12
13660 +#define VC_CAT_SCHED 14
13661 +#define VC_CAT_MEMCTRL 20
13663 +#define VC_CAT_VNET 25
13664 +#define VC_CAT_NETALT 26
13665 +#define VC_CAT_NETMIG 27
13666 +#define VC_CAT_NETCTRL 28
13668 +#define VC_CAT_TAGMIG 35
13669 +#define VC_CAT_DLIMIT 36
13670 +#define VC_CAT_INODE 38
13672 +#define VC_CAT_VSTAT 40
13673 +#define VC_CAT_VINFO 46
13674 +#define VC_CAT_EVENT 48
13676 +#define VC_CAT_FLAGS 52
13677 +#define VC_CAT_VSPACE 54
13678 +#define VC_CAT_DEBUG 56
13679 +#define VC_CAT_RLIMIT 60
13681 +#define VC_CAT_SYSTEST 61
13682 +#define VC_CAT_COMPAT 63
13684 +/* query version */
13686 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13687 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13689 +#endif /* _UAPI_VS_SWITCH_H */
13690 diff -NurpP --minimal linux-3.9.4/include/uapi/vserver/tag_cmd.h linux-3.9.4-vs2.3.6.3/include/uapi/vserver/tag_cmd.h
13691 --- linux-3.9.4/include/uapi/vserver/tag_cmd.h 1970-01-01 00:00:00.000000000 +0000
13692 +++ linux-3.9.4-vs2.3.6.3/include/uapi/vserver/tag_cmd.h 2013-05-31 14:47:11.000000000 +0000
13694 +#ifndef _UAPI_VS_TAG_CMD_H
13695 +#define _UAPI_VS_TAG_CMD_H
13698 +/* vinfo commands */
13700 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13703 +/* context commands */
13705 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13707 +#endif /* _UAPI_VS_TAG_CMD_H */
13708 diff -NurpP --minimal linux-3.9.4/init/Kconfig linux-3.9.4-vs2.3.6.3/init/Kconfig
13709 --- linux-3.9.4/init/Kconfig 2013-05-31 13:45:29.000000000 +0000
13710 +++ linux-3.9.4-vs2.3.6.3/init/Kconfig 2013-05-31 14:47:11.000000000 +0000
13711 @@ -760,6 +760,7 @@ config NUMA_BALANCING
13713 boolean "Control Group support"
13717 This option adds support for grouping sets of processes together, for
13718 use with process control subsystems such as Cpusets, CFS, memory
13719 @@ -1022,6 +1023,7 @@ config IPC_NS
13721 bool "User namespace"
13722 depends on UIDGID_CONVERTED
13723 + depends on VSERVER_DISABLED
13724 select UIDGID_STRICT_TYPE_CHECKS
13727 diff -NurpP --minimal linux-3.9.4/init/main.c linux-3.9.4-vs2.3.6.3/init/main.c
13728 --- linux-3.9.4/init/main.c 2013-05-31 13:45:29.000000000 +0000
13729 +++ linux-3.9.4-vs2.3.6.3/init/main.c 2013-05-31 15:09:17.000000000 +0000
13731 #include <linux/ptrace.h>
13732 #include <linux/blkdev.h>
13733 #include <linux/elevator.h>
13734 +#include <linux/vserver/percpu.h>
13736 #include <asm/io.h>
13737 #include <asm/bugs.h>
13738 diff -NurpP --minimal linux-3.9.4/ipc/mqueue.c linux-3.9.4-vs2.3.6.3/ipc/mqueue.c
13739 --- linux-3.9.4/ipc/mqueue.c 2013-05-31 13:45:29.000000000 +0000
13740 +++ linux-3.9.4-vs2.3.6.3/ipc/mqueue.c 2013-05-31 14:47:11.000000000 +0000
13742 #include <linux/ipc_namespace.h>
13743 #include <linux/user_namespace.h>
13744 #include <linux/slab.h>
13745 +#include <linux/vs_context.h>
13746 +#include <linux/vs_limit.h>
13748 #include <net/sock.h>
13750 @@ -76,6 +78,7 @@ struct mqueue_inode_info {
13751 struct pid* notify_owner;
13752 struct user_namespace *notify_user_ns;
13753 struct user_struct *user; /* user who created, for accounting */
13754 + struct vx_info *vxi;
13755 struct sock *notify_sock;
13756 struct sk_buff *notify_cookie;
13758 @@ -234,6 +237,7 @@ static struct inode *mqueue_get_inode(st
13759 if (S_ISREG(mode)) {
13760 struct mqueue_inode_info *info;
13761 unsigned long mq_bytes, mq_treesize;
13762 + struct vx_info *vxi = current_vx_info();
13764 inode->i_fop = &mqueue_file_operations;
13765 inode->i_size = FILENT_SIZE;
13766 @@ -247,6 +251,7 @@ static struct inode *mqueue_get_inode(st
13767 info->notify_user_ns = NULL;
13769 info->user = NULL; /* set when all is ok */
13770 + info->vxi = NULL;
13771 info->msg_tree = RB_ROOT;
13772 info->node_cache = NULL;
13773 memset(&info->attr, 0, sizeof(info->attr));
13774 @@ -280,17 +285,20 @@ static struct inode *mqueue_get_inode(st
13776 spin_lock(&mq_lock);
13777 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
13778 - u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
13779 + u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE) ||
13780 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
13781 spin_unlock(&mq_lock);
13782 /* mqueue_evict_inode() releases info->messages */
13786 u->mq_bytes += mq_bytes;
13787 + vx_ipcmsg_add(vxi, u, mq_bytes);
13788 spin_unlock(&mq_lock);
13791 info->user = get_uid(u);
13792 + info->vxi = get_vx_info(vxi);
13793 } else if (S_ISDIR(mode)) {
13795 /* Some things misbehave if size == 0 on a directory */
13796 @@ -402,8 +410,11 @@ static void mqueue_evict_inode(struct in
13800 + struct vx_info *vxi = info->vxi;
13802 spin_lock(&mq_lock);
13803 user->mq_bytes -= mq_bytes;
13804 + vx_ipcmsg_sub(vxi, user, mq_bytes);
13806 * get_ns_from_inode() ensures that the
13807 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
13808 @@ -413,6 +424,7 @@ static void mqueue_evict_inode(struct in
13810 ipc_ns->mq_queues_count--;
13811 spin_unlock(&mq_lock);
13812 + put_vx_info(vxi);
13816 diff -NurpP --minimal linux-3.9.4/ipc/msg.c linux-3.9.4-vs2.3.6.3/ipc/msg.c
13817 --- linux-3.9.4/ipc/msg.c 2013-05-31 13:45:29.000000000 +0000
13818 +++ linux-3.9.4-vs2.3.6.3/ipc/msg.c 2013-05-31 14:47:11.000000000 +0000
13820 #include <linux/rwsem.h>
13821 #include <linux/nsproxy.h>
13822 #include <linux/ipc_namespace.h>
13823 +#include <linux/vs_base.h>
13825 #include <asm/current.h>
13826 #include <asm/uaccess.h>
13827 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
13829 msq->q_perm.mode = msgflg & S_IRWXUGO;
13830 msq->q_perm.key = key;
13831 + msq->q_perm.xid = vx_current_xid();
13833 msq->q_perm.security = NULL;
13834 retval = security_msg_queue_alloc(msq);
13835 diff -NurpP --minimal linux-3.9.4/ipc/sem.c linux-3.9.4-vs2.3.6.3/ipc/sem.c
13836 --- linux-3.9.4/ipc/sem.c 2012-12-11 03:30:57.000000000 +0000
13837 +++ linux-3.9.4-vs2.3.6.3/ipc/sem.c 2013-05-31 14:47:11.000000000 +0000
13839 #include <linux/rwsem.h>
13840 #include <linux/nsproxy.h>
13841 #include <linux/ipc_namespace.h>
13842 +#include <linux/vs_base.h>
13843 +#include <linux/vs_limit.h>
13845 #include <asm/uaccess.h>
13847 @@ -306,6 +308,7 @@ static int newary(struct ipc_namespace *
13849 sma->sem_perm.mode = (semflg & S_IRWXUGO);
13850 sma->sem_perm.key = key;
13851 + sma->sem_perm.xid = vx_current_xid();
13853 sma->sem_perm.security = NULL;
13854 retval = security_sem_alloc(sma);
13855 @@ -321,6 +324,9 @@ static int newary(struct ipc_namespace *
13858 ns->used_sems += nsems;
13859 + /* FIXME: obsoleted? */
13860 + vx_semary_inc(sma);
13861 + vx_nsems_add(sma, nsems);
13863 sma->sem_base = (struct sem *) &sma[1];
13865 @@ -770,6 +776,9 @@ static void freeary(struct ipc_namespace
13867 wake_up_sem_queue_do(&tasks);
13868 ns->used_sems -= sma->sem_nsems;
13869 + /* FIXME: obsoleted? */
13870 + vx_nsems_sub(sma, sma->sem_nsems);
13871 + vx_semary_dec(sma);
13872 security_sem_free(sma);
13873 ipc_rcu_putref(sma);
13875 diff -NurpP --minimal linux-3.9.4/ipc/shm.c linux-3.9.4-vs2.3.6.3/ipc/shm.c
13876 --- linux-3.9.4/ipc/shm.c 2013-05-31 14:22:27.000000000 +0000
13877 +++ linux-3.9.4-vs2.3.6.3/ipc/shm.c 2013-05-31 14:47:11.000000000 +0000
13879 #include <linux/nsproxy.h>
13880 #include <linux/mount.h>
13881 #include <linux/ipc_namespace.h>
13882 +#include <linux/vs_context.h>
13883 +#include <linux/vs_limit.h>
13885 #include <asm/uaccess.h>
13887 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
13889 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
13891 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
13892 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
13893 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
13895 + vx_ipcshm_sub(vxi, shp, numpages);
13896 + ns->shm_tot -= numpages;
13900 if (!is_file_hugepages(shp->shm_file))
13901 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
13903 fput (shp->shm_file);
13904 security_shm_free(shp);
13905 + put_vx_info(vxi);
13906 ipc_rcu_putref(shp);
13909 @@ -474,11 +482,15 @@ static int newseg(struct ipc_namespace *
13910 if (ns->shm_tot + numpages > ns->shm_ctlall)
13913 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
13916 shp = ipc_rcu_alloc(sizeof(*shp));
13920 shp->shm_perm.key = key;
13921 + shp->shm_perm.xid = vx_current_xid();
13922 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
13923 shp->mlock_user = NULL;
13925 @@ -544,6 +556,7 @@ static int newseg(struct ipc_namespace *
13926 ns->shm_tot += numpages;
13927 error = shp->shm_perm.id;
13929 + vx_ipcshm_add(current_vx_info(), key, numpages);
13933 diff -NurpP --minimal linux-3.9.4/kernel/Makefile linux-3.9.4-vs2.3.6.3/kernel/Makefile
13934 --- linux-3.9.4/kernel/Makefile 2013-05-31 14:22:27.000000000 +0000
13935 +++ linux-3.9.4-vs2.3.6.3/kernel/Makefile 2013-05-31 14:47:11.000000000 +0000
13936 @@ -24,6 +24,7 @@ endif
13942 obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
13943 obj-$(CONFIG_FREEZER) += freezer.o
13944 diff -NurpP --minimal linux-3.9.4/kernel/auditsc.c linux-3.9.4-vs2.3.6.3/kernel/auditsc.c
13945 --- linux-3.9.4/kernel/auditsc.c 2013-05-31 14:22:27.000000000 +0000
13946 +++ linux-3.9.4-vs2.3.6.3/kernel/auditsc.c 2013-05-31 14:47:11.000000000 +0000
13947 @@ -2315,7 +2315,7 @@ int audit_set_loginuid(kuid_t loginuid)
13948 if (audit_loginuid_set(task))
13950 #else /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
13951 - if (!capable(CAP_AUDIT_CONTROL))
13952 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
13954 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
13956 diff -NurpP --minimal linux-3.9.4/kernel/capability.c linux-3.9.4-vs2.3.6.3/kernel/capability.c
13957 --- linux-3.9.4/kernel/capability.c 2013-05-31 13:45:29.000000000 +0000
13958 +++ linux-3.9.4-vs2.3.6.3/kernel/capability.c 2013-05-31 14:47:11.000000000 +0000
13960 #include <linux/syscalls.h>
13961 #include <linux/pid_namespace.h>
13962 #include <linux/user_namespace.h>
13963 +#include <linux/vs_context.h>
13964 #include <asm/uaccess.h>
13967 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
13973 * The only thing that can change the capabilities of the current
13974 * process is the current process. As such, we can't be in this code
13975 @@ -349,6 +351,8 @@ bool has_ns_capability_noaudit(struct ta
13979 +#include <linux/vserver/base.h>
13982 * has_capability_noaudit - Does a task have a capability (unaudited) in the
13984 diff -NurpP --minimal linux-3.9.4/kernel/compat.c linux-3.9.4-vs2.3.6.3/kernel/compat.c
13985 --- linux-3.9.4/kernel/compat.c 2013-05-31 13:45:29.000000000 +0000
13986 +++ linux-3.9.4-vs2.3.6.3/kernel/compat.c 2013-05-31 14:47:11.000000000 +0000
13988 #include <linux/times.h>
13989 #include <linux/ptrace.h>
13990 #include <linux/gfp.h>
13991 +#include <linux/vs_time.h>
13993 #include <asm/uaccess.h>
13995 @@ -1059,7 +1060,7 @@ asmlinkage long compat_sys_stime(compat_
13999 - do_settimeofday(&tv);
14000 + vx_settimeofday(&tv);
14004 diff -NurpP --minimal linux-3.9.4/kernel/cred.c linux-3.9.4-vs2.3.6.3/kernel/cred.c
14005 --- linux-3.9.4/kernel/cred.c 2013-02-19 13:58:56.000000000 +0000
14006 +++ linux-3.9.4-vs2.3.6.3/kernel/cred.c 2013-05-31 14:47:11.000000000 +0000
14007 @@ -56,31 +56,6 @@ struct cred init_cred = {
14008 .group_info = &init_groups,
14011 -static inline void set_cred_subscribers(struct cred *cred, int n)
14013 -#ifdef CONFIG_DEBUG_CREDENTIALS
14014 - atomic_set(&cred->subscribers, n);
14018 -static inline int read_cred_subscribers(const struct cred *cred)
14020 -#ifdef CONFIG_DEBUG_CREDENTIALS
14021 - return atomic_read(&cred->subscribers);
14027 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14029 -#ifdef CONFIG_DEBUG_CREDENTIALS
14030 - struct cred *cred = (struct cred *) _cred;
14032 - atomic_add(n, &cred->subscribers);
14037 * The RCU callback to actually dispose of a set of credentials
14039 @@ -232,21 +207,16 @@ error:
14041 * Call commit_creds() or abort_creds() to clean up.
14043 -struct cred *prepare_creds(void)
14044 +struct cred *__prepare_creds(const struct cred *old)
14046 - struct task_struct *task = current;
14047 - const struct cred *old;
14050 - validate_process_creds();
14052 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14056 kdebug("prepare_creds() alloc %p", new);
14058 - old = task->cred;
14059 memcpy(new, old, sizeof(struct cred));
14061 atomic_set(&new->usage, 1);
14062 @@ -275,6 +245,13 @@ error:
14067 +struct cred *prepare_creds(void)
14069 + validate_process_creds();
14071 + return __prepare_creds(current->cred);
14073 EXPORT_SYMBOL(prepare_creds);
14076 diff -NurpP --minimal linux-3.9.4/kernel/exit.c linux-3.9.4-vs2.3.6.3/kernel/exit.c
14077 --- linux-3.9.4/kernel/exit.c 2013-05-31 13:45:29.000000000 +0000
14078 +++ linux-3.9.4-vs2.3.6.3/kernel/exit.c 2013-05-31 14:47:11.000000000 +0000
14080 #include <linux/fs_struct.h>
14081 #include <linux/init_task.h>
14082 #include <linux/perf_event.h>
14083 +#include <linux/vs_limit.h>
14084 +#include <linux/vs_context.h>
14085 +#include <linux/vs_network.h>
14086 +#include <linux/vs_pid.h>
14087 #include <trace/events/sched.h>
14088 #include <linux/hw_breakpoint.h>
14089 #include <linux/oom.h>
14090 @@ -514,15 +518,25 @@ static struct task_struct *find_new_reap
14091 __acquires(&tasklist_lock)
14093 struct pid_namespace *pid_ns = task_active_pid_ns(father);
14094 - struct task_struct *thread;
14095 + struct vx_info *vxi = task_get_vx_info(father);
14096 + struct task_struct *thread = father;
14097 + struct task_struct *reaper;
14100 while_each_thread(father, thread) {
14101 if (thread->flags & PF_EXITING)
14103 if (unlikely(pid_ns->child_reaper == father))
14104 pid_ns->child_reaper = thread;
14110 + reaper = pid_ns->child_reaper;
14112 + BUG_ON(!vxi->vx_reaper);
14113 + if (vxi->vx_reaper != init_pid_ns.child_reaper &&
14114 + vxi->vx_reaper != father)
14115 + reaper = vxi->vx_reaper;
14118 if (unlikely(pid_ns->child_reaper == father)) {
14119 @@ -560,7 +574,9 @@ static struct task_struct *find_new_reap
14123 - return pid_ns->child_reaper;
14125 + put_vx_info(vxi);
14130 @@ -611,10 +627,15 @@ static void forget_original_parent(struc
14131 list_for_each_entry_safe(p, n, &father->children, sibling) {
14132 struct task_struct *t = p;
14134 - t->real_parent = reaper;
14135 + struct task_struct *new_parent = reaper;
14137 + if (unlikely(p == reaper))
14138 + new_parent = task_active_pid_ns(p)->child_reaper;
14140 + t->real_parent = new_parent;
14141 if (t->parent == father) {
14143 - t->parent = t->real_parent;
14144 + t->parent = new_parent;
14146 if (t->pdeath_signal)
14147 group_send_sig_info(t->pdeath_signal,
14148 @@ -821,6 +842,9 @@ void do_exit(long code)
14150 ptrace_put_breakpoints(tsk);
14152 + /* needs to stay before exit_notify() */
14153 + exit_vx_info_early(tsk, code);
14155 exit_notify(tsk, group_dead);
14158 @@ -874,10 +898,15 @@ void do_exit(long code)
14160 raw_spin_unlock_wait(&tsk->pi_lock);
14162 + /* needs to stay after exit_notify() */
14163 + exit_vx_info(tsk, code);
14164 + exit_nx_info(tsk);
14166 /* causes final put_task_struct in finish_task_switch(). */
14167 tsk->state = TASK_DEAD;
14168 tsk->flags |= PF_NOFREEZE; /* tell freezer to ignore us */
14170 + printk("bad task: %p [%lx]\n", current, current->state);
14172 /* Avoid "noreturn function does return". */
14174 diff -NurpP --minimal linux-3.9.4/kernel/fork.c linux-3.9.4-vs2.3.6.3/kernel/fork.c
14175 --- linux-3.9.4/kernel/fork.c 2013-05-31 13:45:29.000000000 +0000
14176 +++ linux-3.9.4-vs2.3.6.3/kernel/fork.c 2013-05-31 14:47:11.000000000 +0000
14178 #include <linux/khugepaged.h>
14179 #include <linux/signalfd.h>
14180 #include <linux/uprobes.h>
14181 +#include <linux/vs_context.h>
14182 +#include <linux/vs_network.h>
14183 +#include <linux/vs_limit.h>
14185 #include <asm/pgtable.h>
14186 #include <asm/pgalloc.h>
14187 @@ -210,6 +213,8 @@ void free_task(struct task_struct *tsk)
14188 arch_release_thread_info(tsk->stack);
14189 free_thread_info(tsk->stack);
14190 rt_mutex_debug_task_free(tsk);
14191 + clr_vx_info(&tsk->vx_info);
14192 + clr_nx_info(&tsk->nx_info);
14193 ftrace_graph_exit_task(tsk);
14194 put_seccomp_filter(tsk);
14195 arch_release_task_struct(tsk);
14196 @@ -547,6 +552,7 @@ static struct mm_struct *mm_init(struct
14197 if (likely(!mm_alloc_pgd(mm))) {
14199 mmu_notifier_mm_init(mm);
14200 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14204 @@ -599,6 +605,7 @@ void __mmdrop(struct mm_struct *mm)
14205 destroy_context(mm);
14206 mmu_notifier_mm_destroy(mm);
14208 + clr_vx_info(&mm->mm_vx_info);
14211 EXPORT_SYMBOL_GPL(__mmdrop);
14212 @@ -818,6 +825,7 @@ struct mm_struct *dup_mm(struct task_str
14215 memcpy(mm, oldmm, sizeof(*mm));
14216 + mm->mm_vx_info = NULL;
14217 mm_init_cpumask(mm);
14219 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14220 @@ -859,6 +867,7 @@ fail_nocontext:
14221 * If init_new_context() failed, we cannot use mmput() to free the mm
14222 * because it calls destroy_context()
14224 + clr_vx_info(&mm->mm_vx_info);
14228 @@ -1137,6 +1146,8 @@ static struct task_struct *copy_process(
14231 struct task_struct *p;
14232 + struct vx_info *vxi;
14233 + struct nx_info *nxi;
14235 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14236 return ERR_PTR(-EINVAL);
14237 @@ -1195,7 +1206,12 @@ static struct task_struct *copy_process(
14238 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14239 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14241 + init_vx_info(&p->vx_info, current_vx_info());
14242 + init_nx_info(&p->nx_info, current_nx_info());
14245 + if (!vx_nproc_avail(1))
14246 + goto bad_fork_free;
14247 if (atomic_read(&p->real_cred->user->processes) >=
14248 task_rlimit(p, RLIMIT_NPROC)) {
14249 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14250 @@ -1472,6 +1488,18 @@ static struct task_struct *copy_process(
14253 spin_unlock(¤t->sighand->siglock);
14255 + /* p is copy of current */
14256 + vxi = p->vx_info;
14258 + claim_vx_info(vxi, p);
14259 + atomic_inc(&vxi->cvirt.nr_threads);
14260 + atomic_inc(&vxi->cvirt.total_forks);
14263 + nxi = p->nx_info;
14265 + claim_nx_info(nxi, p);
14266 write_unlock_irq(&tasklist_lock);
14267 proc_fork_connector(p);
14268 cgroup_post_fork(p);
14269 diff -NurpP --minimal linux-3.9.4/kernel/kthread.c linux-3.9.4-vs2.3.6.3/kernel/kthread.c
14270 --- linux-3.9.4/kernel/kthread.c 2013-05-31 13:45:30.000000000 +0000
14271 +++ linux-3.9.4-vs2.3.6.3/kernel/kthread.c 2013-05-31 14:47:11.000000000 +0000
14273 #include <linux/slab.h>
14274 #include <linux/freezer.h>
14275 #include <linux/ptrace.h>
14276 +#include <linux/vs_pid.h>
14277 #include <trace/events/sched.h>
14279 static DEFINE_SPINLOCK(kthread_create_lock);
14280 diff -NurpP --minimal linux-3.9.4/kernel/nsproxy.c linux-3.9.4-vs2.3.6.3/kernel/nsproxy.c
14281 --- linux-3.9.4/kernel/nsproxy.c 2013-05-31 13:45:30.000000000 +0000
14282 +++ linux-3.9.4-vs2.3.6.3/kernel/nsproxy.c 2013-05-31 19:28:43.000000000 +0000
14283 @@ -20,11 +20,14 @@
14284 #include <linux/mnt_namespace.h>
14285 #include <linux/utsname.h>
14286 #include <linux/pid_namespace.h>
14287 +#include <linux/vserver/global.h>
14288 +#include <linux/vserver/debug.h>
14289 #include <net/net_namespace.h>
14290 #include <linux/ipc_namespace.h>
14291 #include <linux/proc_fs.h>
14292 #include <linux/file.h>
14293 #include <linux/syscalls.h>
14294 +#include "../fs/mount.h"
14296 static struct kmem_cache *nsproxy_cachep;
14298 @@ -46,8 +49,11 @@ static inline struct nsproxy *create_nsp
14299 struct nsproxy *nsproxy;
14301 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14304 atomic_set(&nsproxy->count, 1);
14305 + atomic_inc(&vs_global_nsproxy);
14307 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14311 @@ -56,9 +62,12 @@ static inline struct nsproxy *create_nsp
14312 * Return the newly created nsproxy. Do not attach this to the task,
14313 * leave it to the caller to do proper locking and attach it to task.
14315 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14316 - struct task_struct *tsk, struct user_namespace *user_ns,
14317 - struct fs_struct *new_fs)
14318 +static struct nsproxy *unshare_namespaces(
14319 + unsigned long flags,
14320 + struct nsproxy *orig,
14321 + struct fs_struct *new_fs,
14322 + struct user_namespace *new_user,
14323 + struct pid_namespace *new_pid)
14325 struct nsproxy *new_nsp;
14327 @@ -67,31 +76,31 @@ static struct nsproxy *create_new_namesp
14329 return ERR_PTR(-ENOMEM);
14331 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, user_ns, new_fs);
14332 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_user, new_fs);
14333 if (IS_ERR(new_nsp->mnt_ns)) {
14334 err = PTR_ERR(new_nsp->mnt_ns);
14338 - new_nsp->uts_ns = copy_utsname(flags, user_ns, tsk->nsproxy->uts_ns);
14339 + new_nsp->uts_ns = copy_utsname(flags, new_user, orig->uts_ns);
14340 if (IS_ERR(new_nsp->uts_ns)) {
14341 err = PTR_ERR(new_nsp->uts_ns);
14345 - new_nsp->ipc_ns = copy_ipcs(flags, user_ns, tsk->nsproxy->ipc_ns);
14346 + new_nsp->ipc_ns = copy_ipcs(flags, new_user, orig->ipc_ns);
14347 if (IS_ERR(new_nsp->ipc_ns)) {
14348 err = PTR_ERR(new_nsp->ipc_ns);
14352 - new_nsp->pid_ns = copy_pid_ns(flags, user_ns, tsk->nsproxy->pid_ns);
14353 + new_nsp->pid_ns = copy_pid_ns(flags, new_user, new_pid);
14354 if (IS_ERR(new_nsp->pid_ns)) {
14355 err = PTR_ERR(new_nsp->pid_ns);
14359 - new_nsp->net_ns = copy_net_ns(flags, user_ns, tsk->nsproxy->net_ns);
14360 + new_nsp->net_ns = copy_net_ns(flags, new_user, orig->net_ns);
14361 if (IS_ERR(new_nsp->net_ns)) {
14362 err = PTR_ERR(new_nsp->net_ns);
14364 @@ -116,6 +125,41 @@ out_ns:
14365 return ERR_PTR(err);
14368 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14369 + struct task_struct *tsk, struct user_namespace *user_ns,
14370 + struct fs_struct *new_fs)
14373 + return unshare_namespaces(flags, tsk->nsproxy,
14374 + new_fs, user_ns, task_active_pid_ns(tsk));
14378 + * copies the nsproxy, setting refcount to 1, and grabbing a
14379 + * reference to all contained namespaces.
14381 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14383 + struct nsproxy *ns = create_nsproxy();
14386 + memcpy(ns, orig, sizeof(struct nsproxy));
14387 + atomic_set(&ns->count, 1);
14390 + get_mnt_ns(ns->mnt_ns);
14392 + get_uts_ns(ns->uts_ns);
14394 + get_ipc_ns(ns->ipc_ns);
14396 + get_pid_ns(ns->pid_ns);
14398 + get_net(ns->net_ns);
14404 * called from clone. This now handles copy for nsproxy and all
14405 * namespaces therein.
14406 @@ -124,9 +168,12 @@ int copy_namespaces(unsigned long flags,
14408 struct nsproxy *old_ns = tsk->nsproxy;
14409 struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
14410 - struct nsproxy *new_ns;
14411 + struct nsproxy *new_ns = NULL;
14414 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14415 + flags, tsk, old_ns);
14420 @@ -136,7 +183,7 @@ int copy_namespaces(unsigned long flags,
14421 CLONE_NEWPID | CLONE_NEWNET)))
14424 - if (!ns_capable(user_ns, CAP_SYS_ADMIN)) {
14425 + if (!vx_ns_can_unshare(user_ns, CAP_SYS_ADMIN, flags)) {
14429 @@ -163,6 +210,9 @@ int copy_namespaces(unsigned long flags,
14432 put_nsproxy(old_ns);
14433 + vxdprintk(VXD_CBIT(space, 3),
14434 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14435 + flags, tsk, old_ns, err, new_ns);
14439 @@ -176,7 +226,9 @@ void free_nsproxy(struct nsproxy *ns)
14440 put_ipc_ns(ns->ipc_ns);
14442 put_pid_ns(ns->pid_ns);
14443 - put_net(ns->net_ns);
14445 + put_net(ns->net_ns);
14446 + atomic_dec(&vs_global_nsproxy);
14447 kmem_cache_free(nsproxy_cachep, ns);
14450 @@ -190,12 +242,16 @@ int unshare_nsproxy_namespaces(unsigned
14451 struct user_namespace *user_ns;
14454 + vxdprintk(VXD_CBIT(space, 4),
14455 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14456 + unshare_flags, current->nsproxy);
14458 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14459 CLONE_NEWNET | CLONE_NEWPID)))
14462 user_ns = new_cred ? new_cred->user_ns : current_user_ns();
14463 - if (!ns_capable(user_ns, CAP_SYS_ADMIN))
14464 + if (!vx_ns_can_unshare(user_ns, CAP_SYS_ADMIN, unshare_flags))
14467 *new_nsp = create_new_namespaces(unshare_flags, current, user_ns,
14468 diff -NurpP --minimal linux-3.9.4/kernel/pid.c linux-3.9.4-vs2.3.6.3/kernel/pid.c
14469 --- linux-3.9.4/kernel/pid.c 2013-05-31 13:45:30.000000000 +0000
14470 +++ linux-3.9.4-vs2.3.6.3/kernel/pid.c 2013-05-31 15:24:34.000000000 +0000
14472 #include <linux/init_task.h>
14473 #include <linux/syscalls.h>
14474 #include <linux/proc_fs.h>
14475 +#include <linux/vs_pid.h>
14477 #define pid_hashfn(nr, ns) \
14478 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14479 @@ -364,7 +365,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14481 struct pid *find_vpid(int nr)
14483 - return find_pid_ns(nr, task_active_pid_ns(current));
14484 + return find_pid_ns(vx_rmap_pid(nr), task_active_pid_ns(current));
14486 EXPORT_SYMBOL_GPL(find_vpid);
14488 @@ -424,6 +425,9 @@ void transfer_pid(struct task_struct *ol
14489 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14491 struct task_struct *result = NULL;
14493 + if (type == PIDTYPE_REALPID)
14494 + type = PIDTYPE_PID;
14496 struct hlist_node *first;
14497 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
14498 @@ -443,7 +447,7 @@ struct task_struct *find_task_by_pid_ns(
14499 rcu_lockdep_assert(rcu_read_lock_held(),
14500 "find_task_by_pid_ns() needs rcu_read_lock()"
14502 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
14503 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
14506 struct task_struct *find_task_by_vpid(pid_t vnr)
14507 @@ -487,7 +491,7 @@ struct pid *find_get_pid(pid_t nr)
14509 EXPORT_SYMBOL_GPL(find_get_pid);
14511 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14512 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
14516 @@ -501,6 +505,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
14518 EXPORT_SYMBOL_GPL(pid_nr_ns);
14520 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14522 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
14525 pid_t pid_vnr(struct pid *pid)
14527 return pid_nr_ns(pid, task_active_pid_ns(current));
14528 diff -NurpP --minimal linux-3.9.4/kernel/pid_namespace.c linux-3.9.4-vs2.3.6.3/kernel/pid_namespace.c
14529 --- linux-3.9.4/kernel/pid_namespace.c 2013-05-31 13:45:30.000000000 +0000
14530 +++ linux-3.9.4-vs2.3.6.3/kernel/pid_namespace.c 2013-05-31 17:59:48.000000000 +0000
14532 #include <linux/proc_fs.h>
14533 #include <linux/reboot.h>
14534 #include <linux/export.h>
14535 +#include <linux/vserver/global.h>
14537 #define BITS_PER_PAGE (PAGE_SIZE*8)
14539 @@ -112,6 +113,7 @@ static struct pid_namespace *create_pid_
14542 kref_init(&ns->kref);
14543 + atomic_inc(&vs_global_pid_ns);
14545 ns->parent = get_pid_ns(parent_pid_ns);
14546 ns->user_ns = get_user_ns(user_ns);
14547 @@ -142,6 +144,7 @@ static void destroy_pid_namespace(struct
14548 for (i = 0; i < PIDMAP_ENTRIES; i++)
14549 kfree(ns->pidmap[i].page);
14550 put_user_ns(ns->user_ns);
14551 + atomic_dec(&vs_global_pid_ns);
14552 kmem_cache_free(pid_ns_cachep, ns);
14555 diff -NurpP --minimal linux-3.9.4/kernel/posix-timers.c linux-3.9.4-vs2.3.6.3/kernel/posix-timers.c
14556 --- linux-3.9.4/kernel/posix-timers.c 2013-05-31 13:45:30.000000000 +0000
14557 +++ linux-3.9.4-vs2.3.6.3/kernel/posix-timers.c 2013-05-31 14:47:11.000000000 +0000
14559 #include <linux/wait.h>
14560 #include <linux/workqueue.h>
14561 #include <linux/export.h>
14562 +#include <linux/vs_context.h>
14565 * Management arrays for POSIX timers. Timers are kept in slab memory
14566 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
14568 struct task_struct *task;
14569 int shared, ret = -1;
14572 * FIXME: if ->sigq is queued we can race with
14573 * dequeue_signal()->do_schedule_next_timer().
14574 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
14576 task = pid_task(timr->it_pid, PIDTYPE_PID);
14578 + struct vx_info_save vxis;
14579 + struct vx_info *vxi;
14581 + vxi = get_vx_info(task->vx_info);
14582 + enter_vx_info(vxi, &vxis);
14583 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
14584 ret = send_sigqueue(timr->sigq, task, shared);
14585 + leave_vx_info(&vxis);
14586 + put_vx_info(vxi);
14590 /* If we failed to send the signal the timer stops. */
14593 diff -NurpP --minimal linux-3.9.4/kernel/printk.c linux-3.9.4-vs2.3.6.3/kernel/printk.c
14594 --- linux-3.9.4/kernel/printk.c 2013-05-31 13:45:30.000000000 +0000
14595 +++ linux-3.9.4-vs2.3.6.3/kernel/printk.c 2013-05-31 15:23:35.000000000 +0000
14597 #include <linux/rculist.h>
14598 #include <linux/poll.h>
14599 #include <linux/irq_work.h>
14600 +#include <linux/vs_cvirt.h>
14602 #include <asm/uaccess.h>
14604 @@ -841,7 +842,7 @@ static int check_syslog_permissions(int
14607 if (syslog_action_restricted(type)) {
14608 - if (capable(CAP_SYSLOG))
14609 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
14611 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
14612 if (capable(CAP_SYS_ADMIN)) {
14613 @@ -1135,12 +1136,9 @@ int do_syslog(int type, char __user *buf
14618 - case SYSLOG_ACTION_CLOSE: /* Close log */
14620 - case SYSLOG_ACTION_OPEN: /* Open log */
14622 - case SYSLOG_ACTION_READ: /* Read from log */
14623 + if ((type == SYSLOG_ACTION_READ) ||
14624 + (type == SYSLOG_ACTION_READ_ALL) ||
14625 + (type == SYSLOG_ACTION_READ_CLEAR)) {
14627 if (!buf || len < 0)
14629 @@ -1151,6 +1149,16 @@ int do_syslog(int type, char __user *buf
14634 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14635 + return vx_do_syslog(type, buf, len);
14638 + case SYSLOG_ACTION_CLOSE: /* Close log */
14640 + case SYSLOG_ACTION_OPEN: /* Open log */
14642 + case SYSLOG_ACTION_READ: /* Read from log */
14643 error = wait_event_interruptible(log_wait,
14644 syslog_seq != log_next_seq);
14646 @@ -1163,16 +1171,6 @@ int do_syslog(int type, char __user *buf
14648 /* Read last kernel messages */
14649 case SYSLOG_ACTION_READ_ALL:
14651 - if (!buf || len < 0)
14656 - if (!access_ok(VERIFY_WRITE, buf, len)) {
14660 error = syslog_print_all(buf, len, clear);
14662 /* Clear ring buffer */
14663 diff -NurpP --minimal linux-3.9.4/kernel/ptrace.c linux-3.9.4-vs2.3.6.3/kernel/ptrace.c
14664 --- linux-3.9.4/kernel/ptrace.c 2013-05-31 13:45:30.000000000 +0000
14665 +++ linux-3.9.4-vs2.3.6.3/kernel/ptrace.c 2013-05-31 15:22:34.000000000 +0000
14667 #include <linux/syscalls.h>
14668 #include <linux/uaccess.h>
14669 #include <linux/regset.h>
14670 +#include <linux/vs_context.h>
14671 #include <linux/hw_breakpoint.h>
14672 #include <linux/cn_proc.h>
14674 @@ -261,6 +262,11 @@ ok:
14678 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
14680 + if (!vx_check(task->xid, VS_IDENT) &&
14681 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
14683 return security_ptrace_access_check(task, mode);
14686 diff -NurpP --minimal linux-3.9.4/kernel/sched/core.c linux-3.9.4-vs2.3.6.3/kernel/sched/core.c
14687 --- linux-3.9.4/kernel/sched/core.c 2013-05-31 13:45:30.000000000 +0000
14688 +++ linux-3.9.4-vs2.3.6.3/kernel/sched/core.c 2013-05-31 15:17:22.000000000 +0000
14690 #include <linux/init_task.h>
14691 #include <linux/binfmts.h>
14692 #include <linux/context_tracking.h>
14693 +#include <linux/vs_sched.h>
14694 +#include <linux/vs_cvirt.h>
14696 #include <asm/switch_to.h>
14697 #include <asm/tlb.h>
14698 @@ -2091,9 +2093,17 @@ EXPORT_SYMBOL(avenrun); /* should be rem
14700 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
14702 - loads[0] = (avenrun[0] + offset) << shift;
14703 - loads[1] = (avenrun[1] + offset) << shift;
14704 - loads[2] = (avenrun[2] + offset) << shift;
14705 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
14706 + struct vx_info *vxi = current_vx_info();
14708 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
14709 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
14710 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
14712 + loads[0] = (avenrun[0] + offset) << shift;
14713 + loads[1] = (avenrun[1] + offset) << shift;
14714 + loads[2] = (avenrun[2] + offset) << shift;
14718 static long calc_load_fold_active(struct rq *this_rq)
14719 @@ -3704,7 +3714,7 @@ SYSCALL_DEFINE1(nice, int, increment)
14722 if (increment < 0 && !can_nice(current, nice))
14724 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
14726 retval = security_task_setnice(current, nice);
14728 diff -NurpP --minimal linux-3.9.4/kernel/sched/cputime.c linux-3.9.4-vs2.3.6.3/kernel/sched/cputime.c
14729 --- linux-3.9.4/kernel/sched/cputime.c 2013-05-31 14:22:27.000000000 +0000
14730 +++ linux-3.9.4-vs2.3.6.3/kernel/sched/cputime.c 2013-05-31 15:17:55.000000000 +0000
14732 #include <linux/kernel_stat.h>
14733 #include <linux/static_key.h>
14734 #include <linux/context_tracking.h>
14735 +#include <linux/vs_sched.h>
14739 @@ -151,14 +152,17 @@ static inline void task_group_account_fi
14740 void account_user_time(struct task_struct *p, cputime_t cputime,
14741 cputime_t cputime_scaled)
14743 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14744 + int nice = (TASK_NICE(p) > 0);
14747 /* Add user time to process. */
14748 p->utime += cputime;
14749 p->utimescaled += cputime_scaled;
14750 + vx_account_user(vxi, cputime, nice);
14751 account_group_user_time(p, cputime);
14753 - index = (TASK_NICE(p) > 0) ? CPUTIME_NICE : CPUTIME_USER;
14754 + index = (nice) ? CPUTIME_NICE : CPUTIME_USER;
14756 /* Add user time to cpustat. */
14757 task_group_account_field(p, index, (__force u64) cputime);
14758 @@ -205,9 +209,12 @@ static inline
14759 void __account_system_time(struct task_struct *p, cputime_t cputime,
14760 cputime_t cputime_scaled, int index)
14762 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14764 /* Add system time to process. */
14765 p->stime += cputime;
14766 p->stimescaled += cputime_scaled;
14767 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
14768 account_group_system_time(p, cputime);
14770 /* Add system time to cpustat. */
14771 diff -NurpP --minimal linux-3.9.4/kernel/sched/fair.c linux-3.9.4-vs2.3.6.3/kernel/sched/fair.c
14772 --- linux-3.9.4/kernel/sched/fair.c 2013-05-31 13:45:30.000000000 +0000
14773 +++ linux-3.9.4-vs2.3.6.3/kernel/sched/fair.c 2013-05-31 15:19:37.000000000 +0000
14775 #include <linux/mempolicy.h>
14776 #include <linux/migrate.h>
14777 #include <linux/task_work.h>
14778 +#include <linux/vs_cvirt.h>
14780 #include <trace/events/sched.h>
14782 @@ -1714,6 +1715,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
14783 __enqueue_entity(cfs_rq, se);
14786 + if (entity_is_task(se))
14787 + vx_activate_task(task_of(se));
14788 if (cfs_rq->nr_running == 1) {
14789 list_add_leaf_cfs_rq(cfs_rq);
14790 check_enqueue_throttle(cfs_rq);
14791 @@ -1795,6 +1798,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
14792 if (se != cfs_rq->curr)
14793 __dequeue_entity(cfs_rq, se);
14795 + if (entity_is_task(se))
14796 + vx_deactivate_task(task_of(se));
14797 account_entity_dequeue(cfs_rq, se);
14800 diff -NurpP --minimal linux-3.9.4/kernel/signal.c linux-3.9.4-vs2.3.6.3/kernel/signal.c
14801 --- linux-3.9.4/kernel/signal.c 2013-05-31 13:45:30.000000000 +0000
14802 +++ linux-3.9.4-vs2.3.6.3/kernel/signal.c 2013-05-31 15:20:05.000000000 +0000
14804 #include <linux/user_namespace.h>
14805 #include <linux/uprobes.h>
14806 #include <linux/compat.h>
14807 +#include <linux/vs_context.h>
14808 +#include <linux/vs_pid.h>
14809 #define CREATE_TRACE_POINTS
14810 #include <trace/events/signal.h>
14812 @@ -789,9 +791,18 @@ static int check_kill_permission(int sig
14816 + vxdprintk(VXD_CBIT(misc, 7),
14817 + "check_kill_permission(%d,%p,%p[#%u,%u])",
14818 + sig, info, t, vx_task_xid(t), t->pid);
14820 if (!valid_signal(sig))
14823 +/* FIXME: needed? if so, why?
14824 + if ((info != SEND_SIG_NOINFO) &&
14825 + (is_si_special(info) || !si_fromuser(info)))
14828 if (!si_fromuser(info))
14831 @@ -815,6 +826,20 @@ static int check_kill_permission(int sig
14836 + if (t->pid == 1 && current->xid)
14840 + /* FIXME: we shouldn't return ESRCH ever, to avoid
14841 + loops, maybe ENOENT or EACCES? */
14842 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
14843 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
14844 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
14845 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
14849 return security_task_kill(t, info, sig, 0);
14852 @@ -1351,7 +1376,7 @@ int kill_pid_info(int sig, struct siginf
14855 p = pid_task(pid, PIDTYPE_PID);
14857 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
14858 error = group_send_sig_info(sig, info, p);
14859 if (unlikely(error == -ESRCH))
14861 @@ -1399,7 +1424,7 @@ int kill_pid_info_as_cred(int sig, struc
14864 p = pid_task(pid, PIDTYPE_PID);
14866 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
14870 @@ -1451,8 +1476,10 @@ static int kill_something_info(int sig,
14871 struct task_struct * p;
14873 for_each_process(p) {
14874 - if (task_pid_vnr(p) > 1 &&
14875 - !same_thread_group(p, current)) {
14876 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
14877 + task_pid_vnr(p) > 1 &&
14878 + !same_thread_group(p, current) &&
14879 + !vx_current_initpid(p->pid)) {
14880 int err = group_send_sig_info(sig, info, p);
14883 @@ -2306,6 +2333,11 @@ relock:
14884 !sig_kernel_only(signr))
14887 + /* virtual init is protected against user signals */
14888 + if ((info->si_code == SI_USER) &&
14889 + vx_current_initpid(current->pid))
14892 if (sig_kernel_stop(signr)) {
14894 * The default action is to stop all threads in
14895 diff -NurpP --minimal linux-3.9.4/kernel/softirq.c linux-3.9.4-vs2.3.6.3/kernel/softirq.c
14896 --- linux-3.9.4/kernel/softirq.c 2013-05-31 13:45:30.000000000 +0000
14897 +++ linux-3.9.4-vs2.3.6.3/kernel/softirq.c 2013-05-31 14:47:11.000000000 +0000
14899 #include <linux/smp.h>
14900 #include <linux/smpboot.h>
14901 #include <linux/tick.h>
14902 +#include <linux/vs_context.h>
14904 #define CREATE_TRACE_POINTS
14905 #include <trace/events/irq.h>
14906 diff -NurpP --minimal linux-3.9.4/kernel/sys.c linux-3.9.4-vs2.3.6.3/kernel/sys.c
14907 --- linux-3.9.4/kernel/sys.c 2013-05-31 13:45:30.000000000 +0000
14908 +++ linux-3.9.4-vs2.3.6.3/kernel/sys.c 2013-05-31 15:23:14.000000000 +0000
14910 #include <linux/binfmts.h>
14912 #include <linux/kmsg_dump.h>
14913 +#include <linux/vs_pid.h>
14914 /* Move somewhere else to avoid recompiling? */
14915 #include <generated/utsrelease.h>
14917 @@ -155,7 +156,10 @@ static int set_one_prio(struct task_stru
14920 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
14922 + if (vx_flags(VXF_IGNEG_NICE, 0))
14928 no_nice = security_task_setnice(p, niceval);
14929 @@ -206,6 +210,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
14931 pgrp = task_pgrp(current);
14932 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
14933 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
14935 error = set_one_prio(p, niceval, error);
14936 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
14938 @@ -271,6 +277,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
14940 pgrp = task_pgrp(current);
14941 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
14942 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
14944 niceval = 20 - task_nice(p);
14945 if (niceval > retval)
14947 @@ -424,6 +432,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
14949 static DEFINE_MUTEX(reboot_mutex);
14951 +long vs_reboot(unsigned int, void __user *);
14954 * Reboot system call: for obvious reasons only root may call it,
14955 * and even root needs to set up some magic numbers in the registers
14956 @@ -466,6 +476,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
14957 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
14958 cmd = LINUX_REBOOT_CMD_HALT;
14960 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14961 + return vs_reboot(cmd, arg);
14963 mutex_lock(&reboot_mutex);
14965 case LINUX_REBOOT_CMD_RESTART:
14966 @@ -1373,7 +1386,8 @@ SYSCALL_DEFINE2(sethostname, char __user
14968 char tmp[__NEW_UTS_LEN];
14970 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
14971 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
14972 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
14975 if (len < 0 || len > __NEW_UTS_LEN)
14976 @@ -1424,7 +1438,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
14978 char tmp[__NEW_UTS_LEN];
14980 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
14981 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
14982 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
14984 if (len < 0 || len > __NEW_UTS_LEN)
14986 @@ -1543,7 +1558,7 @@ int do_prlimit(struct task_struct *tsk,
14987 /* Keep the capable check against init_user_ns until
14988 cgroups can contain all limits */
14989 if (new_rlim->rlim_max > rlim->rlim_max &&
14990 - !capable(CAP_SYS_RESOURCE))
14991 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
14994 retval = security_task_setrlimit(tsk->group_leader,
14995 @@ -1596,7 +1611,8 @@ static int check_prlimit_permission(stru
14996 gid_eq(cred->gid, tcred->sgid) &&
14997 gid_eq(cred->gid, tcred->gid))
14999 - if (ns_capable(tcred->user_ns, CAP_SYS_RESOURCE))
15000 + if (vx_ns_capable(tcred->user_ns,
15001 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15005 diff -NurpP --minimal linux-3.9.4/kernel/sysctl.c linux-3.9.4-vs2.3.6.3/kernel/sysctl.c
15006 --- linux-3.9.4/kernel/sysctl.c 2013-05-31 13:45:30.000000000 +0000
15007 +++ linux-3.9.4-vs2.3.6.3/kernel/sysctl.c 2013-05-31 15:28:39.000000000 +0000
15009 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15010 #include <linux/lockdep.h>
15012 +extern char vshelper_path[];
15013 #ifdef CONFIG_CHR_DEV_SG
15014 #include <scsi/sg.h>
15016 @@ -629,6 +630,13 @@ static struct ctl_table kern_table[] = {
15018 .proc_handler = proc_dostring,
15021 + .procname = "vshelper",
15022 + .data = &vshelper_path,
15025 + .proc_handler = &proc_dostring,
15028 #ifdef CONFIG_CHR_DEV_SG
15030 diff -NurpP --minimal linux-3.9.4/kernel/sysctl_binary.c linux-3.9.4-vs2.3.6.3/kernel/sysctl_binary.c
15031 --- linux-3.9.4/kernel/sysctl_binary.c 2013-05-31 13:45:30.000000000 +0000
15032 +++ linux-3.9.4-vs2.3.6.3/kernel/sysctl_binary.c 2013-05-31 14:47:11.000000000 +0000
15033 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15035 { CTL_INT, KERN_PANIC, "panic" },
15036 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15037 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15039 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15040 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15041 diff -NurpP --minimal linux-3.9.4/kernel/time/timekeeping.c linux-3.9.4-vs2.3.6.3/kernel/time/timekeeping.c
15042 --- linux-3.9.4/kernel/time/timekeeping.c 2013-05-31 13:45:30.000000000 +0000
15043 +++ linux-3.9.4-vs2.3.6.3/kernel/time/timekeeping.c 2013-05-31 15:24:55.000000000 +0000
15045 #include <linux/tick.h>
15046 #include <linux/stop_machine.h>
15047 #include <linux/pvclock_gtod.h>
15048 +#include <linux/vs_time.h>
15051 static struct timekeeper timekeeper;
15052 @@ -594,6 +595,7 @@ void getrawmonotonic(struct timespec *ts
15053 } while (read_seqretry(&tk->lock, seq));
15055 timespec_add_ns(ts, nsecs);
15056 + vx_adjust_timespec(ts);
15058 EXPORT_SYMBOL(getrawmonotonic);
15060 diff -NurpP --minimal linux-3.9.4/kernel/time.c linux-3.9.4-vs2.3.6.3/kernel/time.c
15061 --- linux-3.9.4/kernel/time.c 2013-05-31 13:45:30.000000000 +0000
15062 +++ linux-3.9.4-vs2.3.6.3/kernel/time.c 2013-05-31 14:47:11.000000000 +0000
15064 #include <linux/fs.h>
15065 #include <linux/math64.h>
15066 #include <linux/ptrace.h>
15067 +#include <linux/vs_time.h>
15069 #include <asm/uaccess.h>
15070 #include <asm/unistd.h>
15071 @@ -92,7 +93,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15075 - do_settimeofday(&tv);
15076 + vx_settimeofday(&tv);
15080 @@ -180,7 +181,7 @@ int do_sys_settimeofday(const struct tim
15084 - return do_settimeofday(tv);
15085 + return vx_settimeofday(tv);
15089 diff -NurpP --minimal linux-3.9.4/kernel/timer.c linux-3.9.4-vs2.3.6.3/kernel/timer.c
15090 --- linux-3.9.4/kernel/timer.c 2013-05-31 14:22:27.000000000 +0000
15091 +++ linux-3.9.4-vs2.3.6.3/kernel/timer.c 2013-05-31 14:47:11.000000000 +0000
15093 #include <linux/sched.h>
15094 #include <linux/sched/sysctl.h>
15095 #include <linux/slab.h>
15096 +#include <linux/vs_base.h>
15097 +#include <linux/vs_cvirt.h>
15098 +#include <linux/vs_pid.h>
15099 +#include <linux/vserver/sched.h>
15101 #include <asm/uaccess.h>
15102 #include <asm/unistd.h>
15103 diff -NurpP --minimal linux-3.9.4/kernel/user_namespace.c linux-3.9.4-vs2.3.6.3/kernel/user_namespace.c
15104 --- linux-3.9.4/kernel/user_namespace.c 2013-05-31 13:45:30.000000000 +0000
15105 +++ linux-3.9.4-vs2.3.6.3/kernel/user_namespace.c 2013-05-31 17:44:56.000000000 +0000
15107 #include <linux/ctype.h>
15108 #include <linux/projid.h>
15109 #include <linux/fs_struct.h>
15110 +#include <linux/vserver/global.h>
15112 static struct kmem_cache *user_ns_cachep __read_mostly;
15114 @@ -91,6 +92,7 @@ int create_user_ns(struct cred *new)
15116 atomic_set(&ns->count, 1);
15117 /* Leave the new->user_ns reference with the new user namespace. */
15118 + atomic_inc(&vs_global_user_ns);
15119 ns->parent = parent_ns;
15122 @@ -835,6 +837,8 @@ static void *userns_get(struct task_stru
15124 static void userns_put(void *ns)
15126 + /* FIXME: maybe move into destroyer? */
15127 + atomic_dec(&vs_global_user_ns);
15131 diff -NurpP --minimal linux-3.9.4/kernel/utsname.c linux-3.9.4-vs2.3.6.3/kernel/utsname.c
15132 --- linux-3.9.4/kernel/utsname.c 2013-05-31 13:45:30.000000000 +0000
15133 +++ linux-3.9.4-vs2.3.6.3/kernel/utsname.c 2013-05-31 15:15:55.000000000 +0000
15134 @@ -16,14 +16,17 @@
15135 #include <linux/slab.h>
15136 #include <linux/user_namespace.h>
15137 #include <linux/proc_fs.h>
15138 +#include <linux/vserver/global.h>
15140 static struct uts_namespace *create_uts_ns(void)
15142 struct uts_namespace *uts_ns;
15144 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15147 kref_init(&uts_ns->kref);
15148 + atomic_inc(&vs_global_uts_ns);
15153 @@ -85,6 +88,7 @@ void free_uts_ns(struct kref *kref)
15154 ns = container_of(kref, struct uts_namespace, kref);
15155 put_user_ns(ns->user_ns);
15156 proc_free_inum(ns->proc_inum);
15157 + atomic_dec(&vs_global_uts_ns);
15161 diff -NurpP --minimal linux-3.9.4/kernel/vserver/Kconfig linux-3.9.4-vs2.3.6.3/kernel/vserver/Kconfig
15162 --- linux-3.9.4/kernel/vserver/Kconfig 1970-01-01 00:00:00.000000000 +0000
15163 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/Kconfig 2013-05-31 14:47:11.000000000 +0000
15166 +# Linux VServer configuration
15169 +menu "Linux VServer"
15171 +config VSERVER_AUTO_LBACK
15172 + bool "Automatically Assign Loopback IP"
15175 + Automatically assign a guest specific loopback
15176 + IP and add it to the kernel network stack on
15179 +config VSERVER_AUTO_SINGLE
15180 + bool "Automatic Single IP Special Casing"
15181 + depends on EXPERIMENTAL
15184 + This allows network contexts with a single IP to
15185 + automatically remap 0.0.0.0 bindings to that IP,
15186 + avoiding further network checks and improving
15189 + (note: such guests do not allow to change the ip
15190 + on the fly and do not show loopback addresses)
15192 +config VSERVER_COWBL
15193 + bool "Enable COW Immutable Link Breaking"
15196 + This enables the COW (Copy-On-Write) link break code.
15197 + It allows you to treat unified files like normal files
15198 + when writing to them (which will implicitely break the
15199 + link and create a copy of the unified file)
15201 +config VSERVER_VTIME
15202 + bool "Enable Virtualized Guest Time"
15203 + depends on EXPERIMENTAL
15206 + This enables per guest time offsets to allow for
15207 + adjusting the system clock individually per guest.
15208 + this adds some overhead to the time functions and
15209 + therefore should not be enabled without good reason.
15211 +config VSERVER_DEVICE
15212 + bool "Enable Guest Device Mapping"
15213 + depends on EXPERIMENTAL
15216 + This enables generic device remapping.
15218 +config VSERVER_PROC_SECURE
15219 + bool "Enable Proc Security"
15220 + depends on PROC_FS
15223 + This configures ProcFS security to initially hide
15224 + non-process entries for all contexts except the main and
15225 + spectator context (i.e. for all guests), which is a secure
15228 + (note: on 1.2x the entries were visible by default)
15231 + prompt "Persistent Inode Tagging"
15232 + default TAGGING_ID24
15234 + This adds persistent context information to filesystems
15235 + mounted with the tagxid option. Tagging is a requirement
15236 + for per-context disk limits and per-context quota.
15239 +config TAGGING_NONE
15242 + do not store per-context information in inodes.
15244 +config TAGGING_UID16
15245 + bool "UID16/GID32"
15247 + reduces UID to 16 bit, but leaves GID at 32 bit.
15249 +config TAGGING_GID16
15250 + bool "UID32/GID16"
15252 + reduces GID to 16 bit, but leaves UID at 32 bit.
15254 +config TAGGING_ID24
15255 + bool "UID24/GID24"
15257 + uses the upper 8bit from UID and GID for XID tagging
15258 + which leaves 24bit for UID/GID each, which should be
15259 + more than sufficient for normal use.
15261 +config TAGGING_INTERN
15262 + bool "UID32/GID32"
15264 + this uses otherwise reserved inode fields in the on
15265 + disk representation, which limits the use to a few
15266 + filesystems (currently ext2 and ext3)
15271 + bool "Tag NFSD User Auth and Files"
15274 + Enable this if you do want the in-kernel NFS
15275 + Server to use the tagging specified above.
15276 + (will require patched clients too)
15278 +config VSERVER_PRIVACY
15279 + bool "Honor Privacy Aspects of Guests"
15282 + When enabled, most context checks will disallow
15283 + access to structures assigned to a specific context,
15284 + like ptys or loop devices.
15286 +config VSERVER_CONTEXTS
15287 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15289 + default "768" if 64BIT
15292 + This setting will optimize certain data structures
15293 + and memory allocations according to the expected
15296 + note: this is not a strict upper limit.
15298 +config VSERVER_WARN
15299 + bool "VServer Warnings"
15302 + This enables various runtime warnings, which will
15303 + notify about potential manipulation attempts or
15304 + resource shortage. It is generally considered to
15305 + be a good idea to have that enabled.
15307 +config VSERVER_WARN_DEVPTS
15308 + bool "VServer DevPTS Warnings"
15309 + depends on VSERVER_WARN
15312 + This enables DevPTS related warnings, issued when a
15313 + process inside a context tries to lookup or access
15314 + a dynamic pts from the host or a different context.
15316 +config VSERVER_DEBUG
15317 + bool "VServer Debugging Code"
15320 + Set this to yes if you want to be able to activate
15321 + debugging output at runtime. It adds a very small
15322 + overhead to all vserver related functions and
15323 + increases the kernel size by about 20k.
15325 +config VSERVER_HISTORY
15326 + bool "VServer History Tracing"
15327 + depends on VSERVER_DEBUG
15330 + Set this to yes if you want to record the history of
15331 + linux-vserver activities, so they can be replayed in
15332 + the event of a kernel panic or oops.
15334 +config VSERVER_HISTORY_SIZE
15335 + int "Per-CPU History Size (32-65536)"
15336 + depends on VSERVER_HISTORY
15340 + This allows you to specify the number of entries in
15341 + the per-CPU history buffer.
15343 +config VSERVER_EXTRA_MNT_CHECK
15344 + bool "Extra Checks for Reachability"
15347 + Set this to yes if you want to do extra checks for
15348 + vfsmount reachability in the proc filesystem code.
15349 + This shouldn't be required on any setup utilizing
15353 + prompt "Quotes used in debug and warn messages"
15354 + default QUOTES_ISO8859
15356 +config QUOTES_ISO8859
15357 + bool "Extended ASCII (ISO 8859) angle quotes"
15359 + This uses the extended ASCII characters \xbb
15360 + and \xab for quoting file and process names.
15362 +config QUOTES_UTF8
15363 + bool "UTF-8 angle quotes"
15365 + This uses the the UTF-8 sequences for angle
15366 + quotes to quote file and process names.
15368 +config QUOTES_ASCII
15369 + bool "ASCII single quotes"
15371 + This uses the ASCII single quote character
15372 + (\x27) to quote file and process names.
15382 + select NAMESPACES
15388 +config VSERVER_SECURITY
15390 + depends on SECURITY
15392 + select SECURITY_CAPABILITIES
15394 +config VSERVER_DISABLED
15398 diff -NurpP --minimal linux-3.9.4/kernel/vserver/Makefile linux-3.9.4-vs2.3.6.3/kernel/vserver/Makefile
15399 --- linux-3.9.4/kernel/vserver/Makefile 1970-01-01 00:00:00.000000000 +0000
15400 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/Makefile 2013-05-31 14:47:11.000000000 +0000
15403 +# Makefile for the Linux vserver routines.
15407 +obj-y += vserver.o
15409 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15410 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15413 +vserver-$(CONFIG_INET) += inet.o
15414 +vserver-$(CONFIG_PROC_FS) += proc.o
15415 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15416 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15417 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15418 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
15420 diff -NurpP --minimal linux-3.9.4/kernel/vserver/cacct.c linux-3.9.4-vs2.3.6.3/kernel/vserver/cacct.c
15421 --- linux-3.9.4/kernel/vserver/cacct.c 1970-01-01 00:00:00.000000000 +0000
15422 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/cacct.c 2013-05-31 14:47:11.000000000 +0000
15425 + * linux/kernel/vserver/cacct.c
15427 + * Virtual Server: Context Accounting
15429 + * Copyright (C) 2006-2007 Herbert Pötzl
15431 + * V0.01 added accounting stats
15435 +#include <linux/types.h>
15436 +#include <linux/vs_context.h>
15437 +#include <linux/vserver/cacct_cmd.h>
15438 +#include <linux/vserver/cacct_int.h>
15440 +#include <asm/errno.h>
15441 +#include <asm/uaccess.h>
15444 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15446 + struct vcmd_sock_stat_v0 vc_data;
15449 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15452 + field = vc_data.field;
15453 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15456 + for (j = 0; j < 3; j++) {
15457 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15458 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15461 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15466 diff -NurpP --minimal linux-3.9.4/kernel/vserver/cacct_init.h linux-3.9.4-vs2.3.6.3/kernel/vserver/cacct_init.h
15467 --- linux-3.9.4/kernel/vserver/cacct_init.h 1970-01-01 00:00:00.000000000 +0000
15468 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/cacct_init.h 2013-05-31 14:47:11.000000000 +0000
15472 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
15477 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15478 + for (j = 0; j < 3; j++) {
15479 + atomic_long_set(&cacct->sock[i][j].count, 0);
15480 + atomic_long_set(&cacct->sock[i][j].total, 0);
15483 + for (i = 0; i < 8; i++)
15484 + atomic_set(&cacct->slab[i], 0);
15485 + for (i = 0; i < 5; i++)
15486 + for (j = 0; j < 4; j++)
15487 + atomic_set(&cacct->page[i][j], 0);
15490 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
15495 diff -NurpP --minimal linux-3.9.4/kernel/vserver/cacct_proc.h linux-3.9.4-vs2.3.6.3/kernel/vserver/cacct_proc.h
15496 --- linux-3.9.4/kernel/vserver/cacct_proc.h 1970-01-01 00:00:00.000000000 +0000
15497 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/cacct_proc.h 2013-05-31 14:47:11.000000000 +0000
15499 +#ifndef _VX_CACCT_PROC_H
15500 +#define _VX_CACCT_PROC_H
15502 +#include <linux/vserver/cacct_int.h>
15505 +#define VX_SOCKA_TOP \
15506 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
15508 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
15510 + int i, j, length = 0;
15511 + static char *type[VXA_SOCK_SIZE] = {
15512 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
15515 + length += sprintf(buffer + length, VX_SOCKA_TOP);
15516 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15517 + length += sprintf(buffer + length, "%s:", type[i]);
15518 + for (j = 0; j < 3; j++) {
15519 + length += sprintf(buffer + length,
15520 + "\t%10lu/%-10lu",
15521 + vx_sock_count(cacct, i, j),
15522 + vx_sock_total(cacct, i, j));
15524 + buffer[length++] = '\n';
15527 + length += sprintf(buffer + length, "\n");
15528 + length += sprintf(buffer + length,
15529 + "slab:\t %8u %8u %8u %8u\n",
15530 + atomic_read(&cacct->slab[1]),
15531 + atomic_read(&cacct->slab[4]),
15532 + atomic_read(&cacct->slab[0]),
15533 + atomic_read(&cacct->slab[2]));
15535 + length += sprintf(buffer + length, "\n");
15536 + for (i = 0; i < 5; i++) {
15537 + length += sprintf(buffer + length,
15538 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
15539 + atomic_read(&cacct->page[i][0]),
15540 + atomic_read(&cacct->page[i][1]),
15541 + atomic_read(&cacct->page[i][2]),
15542 + atomic_read(&cacct->page[i][3]),
15543 + atomic_read(&cacct->page[i][4]),
15544 + atomic_read(&cacct->page[i][5]),
15545 + atomic_read(&cacct->page[i][6]),
15546 + atomic_read(&cacct->page[i][7]));
15551 +#endif /* _VX_CACCT_PROC_H */
15552 diff -NurpP --minimal linux-3.9.4/kernel/vserver/context.c linux-3.9.4-vs2.3.6.3/kernel/vserver/context.c
15553 --- linux-3.9.4/kernel/vserver/context.c 1970-01-01 00:00:00.000000000 +0000
15554 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/context.c 2013-05-31 19:34:32.000000000 +0000
15557 + * linux/kernel/vserver/context.c
15559 + * Virtual Server: Context Support
15561 + * Copyright (C) 2003-2011 Herbert Pötzl
15563 + * V0.01 context helper
15564 + * V0.02 vx_ctx_kill syscall command
15565 + * V0.03 replaced context_info calls
15566 + * V0.04 redesign of struct (de)alloc
15567 + * V0.05 rlimit basic implementation
15568 + * V0.06 task_xid and info commands
15569 + * V0.07 context flags and caps
15570 + * V0.08 switch to RCU based hash
15571 + * V0.09 revert to non RCU for now
15572 + * V0.10 and back to working RCU hash
15573 + * V0.11 and back to locking again
15574 + * V0.12 referenced context store
15575 + * V0.13 separate per cpu data
15576 + * V0.14 changed vcmds to vxi arg
15577 + * V0.15 added context stat
15578 + * V0.16 have __create claim() the vxi
15579 + * V0.17 removed older and legacy stuff
15580 + * V0.18 added user credentials
15581 + * V0.19 added warn mask
15585 +#include <linux/slab.h>
15586 +#include <linux/types.h>
15587 +#include <linux/security.h>
15588 +#include <linux/pid_namespace.h>
15589 +#include <linux/capability.h>
15591 +#include <linux/vserver/context.h>
15592 +#include <linux/vserver/network.h>
15593 +#include <linux/vserver/debug.h>
15594 +#include <linux/vserver/limit.h>
15595 +#include <linux/vserver/limit_int.h>
15596 +#include <linux/vserver/space.h>
15597 +#include <linux/init_task.h>
15598 +#include <linux/fs_struct.h>
15599 +#include <linux/cred.h>
15601 +#include <linux/vs_context.h>
15602 +#include <linux/vs_limit.h>
15603 +#include <linux/vs_pid.h>
15604 +#include <linux/vserver/context_cmd.h>
15606 +#include "cvirt_init.h"
15607 +#include "cacct_init.h"
15608 +#include "limit_init.h"
15609 +#include "sched_init.h"
15612 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
15613 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
15616 +/* now inactive context structures */
15618 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
15620 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
15623 +/* __alloc_vx_info()
15625 + * allocate an initialized vx_info struct
15626 + * doesn't make it visible (hash) */
15628 +static struct vx_info *__alloc_vx_info(xid_t xid)
15630 + struct vx_info *new = NULL;
15633 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
15635 + /* would this benefit from a slab cache? */
15636 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
15640 + memset(new, 0, sizeof(struct vx_info));
15642 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
15643 + if (!new->ptr_pc)
15646 + new->vx_id = xid;
15647 + INIT_HLIST_NODE(&new->vx_hlist);
15648 + atomic_set(&new->vx_usecnt, 0);
15649 + atomic_set(&new->vx_tasks, 0);
15650 + new->vx_parent = NULL;
15651 + new->vx_state = 0;
15652 + init_waitqueue_head(&new->vx_wait);
15654 + /* prepare reaper */
15655 + get_task_struct(init_pid_ns.child_reaper);
15656 + new->vx_reaper = init_pid_ns.child_reaper;
15657 + new->vx_badness_bias = 0;
15659 + /* rest of init goes here */
15660 + vx_info_init_limit(&new->limit);
15661 + vx_info_init_sched(&new->sched);
15662 + vx_info_init_cvirt(&new->cvirt);
15663 + vx_info_init_cacct(&new->cacct);
15665 + /* per cpu data structures */
15666 + for_each_possible_cpu(cpu) {
15667 + vx_info_init_sched_pc(
15668 + &vx_per_cpu(new, sched_pc, cpu), cpu);
15669 + vx_info_init_cvirt_pc(
15670 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
15673 + new->vx_flags = VXF_INIT_SET;
15674 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
15675 + new->vx_ccaps = 0;
15676 + new->vx_umask = 0;
15677 + new->vx_wmask = 0;
15679 + new->reboot_cmd = 0;
15680 + new->exit_code = 0;
15682 + // preconfig spaces
15683 + for (index = 0; index < VX_SPACES; index++) {
15684 + struct _vx_space *space = &new->space[index];
15687 + spin_lock(&init_fs.lock);
15689 + spin_unlock(&init_fs.lock);
15690 + space->vx_fs = &init_fs;
15692 + /* FIXME: do we want defaults? */
15693 + // space->vx_real_cred = 0;
15694 + // space->vx_cred = 0;
15698 + vxdprintk(VXD_CBIT(xid, 0),
15699 + "alloc_vx_info(%d) = %p", xid, new);
15700 + vxh_alloc_vx_info(new);
15701 + atomic_inc(&vx_global_ctotal);
15710 +/* __dealloc_vx_info()
15712 + * final disposal of vx_info */
15714 +static void __dealloc_vx_info(struct vx_info *vxi)
15716 +#ifdef CONFIG_VSERVER_WARN
15717 + struct vx_info_save vxis;
15720 + vxdprintk(VXD_CBIT(xid, 0),
15721 + "dealloc_vx_info(%p)", vxi);
15722 + vxh_dealloc_vx_info(vxi);
15724 +#ifdef CONFIG_VSERVER_WARN
15725 + enter_vx_info(vxi, &vxis);
15726 + vx_info_exit_limit(&vxi->limit);
15727 + vx_info_exit_sched(&vxi->sched);
15728 + vx_info_exit_cvirt(&vxi->cvirt);
15729 + vx_info_exit_cacct(&vxi->cacct);
15731 + for_each_possible_cpu(cpu) {
15732 + vx_info_exit_sched_pc(
15733 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
15734 + vx_info_exit_cvirt_pc(
15735 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
15737 + leave_vx_info(&vxis);
15741 + vxi->vx_state |= VXS_RELEASED;
15744 + free_percpu(vxi->ptr_pc);
15747 + atomic_dec(&vx_global_ctotal);
15750 +static void __shutdown_vx_info(struct vx_info *vxi)
15752 + struct nsproxy *nsproxy;
15753 + struct fs_struct *fs;
15754 + struct cred *cred;
15759 + vxi->vx_state |= VXS_SHUTDOWN;
15760 + vs_state_change(vxi, VSC_SHUTDOWN);
15762 + for (index = 0; index < VX_SPACES; index++) {
15763 + struct _vx_space *space = &vxi->space[index];
15765 + nsproxy = xchg(&space->vx_nsproxy, NULL);
15767 + put_nsproxy(nsproxy);
15769 + fs = xchg(&space->vx_fs, NULL);
15770 + spin_lock(&fs->lock);
15771 + kill = !--fs->users;
15772 + spin_unlock(&fs->lock);
15774 + free_fs_struct(fs);
15776 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
15778 + abort_creds(cred);
15782 +/* exported stuff */
15784 +void free_vx_info(struct vx_info *vxi)
15786 + unsigned long flags;
15789 + /* check for reference counts first */
15790 + BUG_ON(atomic_read(&vxi->vx_usecnt));
15791 + BUG_ON(atomic_read(&vxi->vx_tasks));
15793 + /* context must not be hashed */
15794 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
15796 + /* context shutdown is mandatory */
15797 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
15799 + /* spaces check */
15800 + for (index = 0; index < VX_SPACES; index++) {
15801 + struct _vx_space *space = &vxi->space[index];
15803 + BUG_ON(space->vx_nsproxy);
15804 + BUG_ON(space->vx_fs);
15805 + // BUG_ON(space->vx_real_cred);
15806 + // BUG_ON(space->vx_cred);
15809 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
15810 + hlist_del(&vxi->vx_hlist);
15811 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
15813 + __dealloc_vx_info(vxi);
15817 +/* hash table for vx_info hash */
15819 +#define VX_HASH_SIZE 13
15821 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
15822 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
15824 +static DEFINE_SPINLOCK(vx_info_hash_lock);
15827 +static inline unsigned int __hashval(xid_t xid)
15829 + return (xid % VX_HASH_SIZE);
15834 +/* __hash_vx_info()
15836 + * add the vxi to the global hash table
15837 + * requires the hash_lock to be held */
15839 +static inline void __hash_vx_info(struct vx_info *vxi)
15841 + struct hlist_head *head;
15843 + vxd_assert_lock(&vx_info_hash_lock);
15844 + vxdprintk(VXD_CBIT(xid, 4),
15845 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
15846 + vxh_hash_vx_info(vxi);
15848 + /* context must not be hashed */
15849 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
15851 + vxi->vx_state |= VXS_HASHED;
15852 + head = &vx_info_hash[__hashval(vxi->vx_id)];
15853 + hlist_add_head(&vxi->vx_hlist, head);
15854 + atomic_inc(&vx_global_cactive);
15857 +/* __unhash_vx_info()
15859 + * remove the vxi from the global hash table
15860 + * requires the hash_lock to be held */
15862 +static inline void __unhash_vx_info(struct vx_info *vxi)
15864 + unsigned long flags;
15866 + vxd_assert_lock(&vx_info_hash_lock);
15867 + vxdprintk(VXD_CBIT(xid, 4),
15868 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
15869 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
15870 + vxh_unhash_vx_info(vxi);
15872 + /* context must be hashed */
15873 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
15874 + /* but without tasks */
15875 + BUG_ON(atomic_read(&vxi->vx_tasks));
15877 + vxi->vx_state &= ~VXS_HASHED;
15878 + hlist_del_init(&vxi->vx_hlist);
15879 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
15880 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
15881 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
15882 + atomic_dec(&vx_global_cactive);
15886 +/* __lookup_vx_info()
15888 + * requires the hash_lock to be held
15889 + * doesn't increment the vx_refcnt */
15891 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
15893 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
15894 + struct hlist_node *pos;
15895 + struct vx_info *vxi;
15897 + vxd_assert_lock(&vx_info_hash_lock);
15898 + hlist_for_each(pos, head) {
15899 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
15901 + if (vxi->vx_id == xid)
15906 + vxdprintk(VXD_CBIT(xid, 0),
15907 + "__lookup_vx_info(#%u): %p[#%u]",
15908 + xid, vxi, vxi ? vxi->vx_id : 0);
15909 + vxh_lookup_vx_info(vxi, xid);
15914 +/* __create_vx_info()
15916 + * create the requested context
15917 + * get(), claim() and hash it */
15919 +static struct vx_info *__create_vx_info(int id)
15921 + struct vx_info *new, *vxi = NULL;
15923 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
15925 + if (!(new = __alloc_vx_info(id)))
15926 + return ERR_PTR(-ENOMEM);
15928 + /* required to make dynamic xids unique */
15929 + spin_lock(&vx_info_hash_lock);
15931 + /* static context requested */
15932 + if ((vxi = __lookup_vx_info(id))) {
15933 + vxdprintk(VXD_CBIT(xid, 0),
15934 + "create_vx_info(%d) = %p (already there)", id, vxi);
15935 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
15936 + vxi = ERR_PTR(-EBUSY);
15938 + vxi = ERR_PTR(-EEXIST);
15941 + /* new context */
15942 + vxdprintk(VXD_CBIT(xid, 0),
15943 + "create_vx_info(%d) = %p (new)", id, new);
15944 + claim_vx_info(new, NULL);
15945 + __hash_vx_info(get_vx_info(new));
15946 + vxi = new, new = NULL;
15949 + spin_unlock(&vx_info_hash_lock);
15950 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
15952 + __dealloc_vx_info(new);
15957 +/* exported stuff */
15960 +void unhash_vx_info(struct vx_info *vxi)
15962 + spin_lock(&vx_info_hash_lock);
15963 + __unhash_vx_info(vxi);
15964 + spin_unlock(&vx_info_hash_lock);
15965 + __shutdown_vx_info(vxi);
15966 + __wakeup_vx_info(vxi);
15970 +/* lookup_vx_info()
15972 + * search for a vx_info and get() it
15973 + * negative id means current */
15975 +struct vx_info *lookup_vx_info(int id)
15977 + struct vx_info *vxi = NULL;
15980 + vxi = get_vx_info(current_vx_info());
15981 + } else if (id > 1) {
15982 + spin_lock(&vx_info_hash_lock);
15983 + vxi = get_vx_info(__lookup_vx_info(id));
15984 + spin_unlock(&vx_info_hash_lock);
15989 +/* xid_is_hashed()
15991 + * verify that xid is still hashed */
15993 +int xid_is_hashed(xid_t xid)
15997 + spin_lock(&vx_info_hash_lock);
15998 + hashed = (__lookup_vx_info(xid) != NULL);
15999 + spin_unlock(&vx_info_hash_lock);
16003 +#ifdef CONFIG_PROC_FS
16007 + * get a subset of hashed xids for proc
16008 + * assumes size is at least one */
16010 +int get_xid_list(int index, unsigned int *xids, int size)
16012 + int hindex, nr_xids = 0;
16014 + /* only show current and children */
16015 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16018 + xids[nr_xids] = vx_current_xid();
16022 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16023 + struct hlist_head *head = &vx_info_hash[hindex];
16024 + struct hlist_node *pos;
16026 + spin_lock(&vx_info_hash_lock);
16027 + hlist_for_each(pos, head) {
16028 + struct vx_info *vxi;
16033 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16034 + xids[nr_xids] = vxi->vx_id;
16035 + if (++nr_xids >= size) {
16036 + spin_unlock(&vx_info_hash_lock);
16040 + /* keep the lock time short */
16041 + spin_unlock(&vx_info_hash_lock);
16048 +#ifdef CONFIG_VSERVER_DEBUG
16050 +void dump_vx_info_inactive(int level)
16052 + struct hlist_node *entry, *next;
16054 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16055 + struct vx_info *vxi =
16056 + list_entry(entry, struct vx_info, vx_hlist);
16058 + dump_vx_info(vxi, level);
16065 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16067 + struct user_struct *new_user, *old_user;
16072 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16075 + new_user = alloc_uid(vxi->vx_id, p->uid);
16079 + old_user = p->user;
16080 + if (new_user != old_user) {
16081 + atomic_inc(&new_user->processes);
16082 + atomic_dec(&old_user->processes);
16083 + p->user = new_user;
16085 + free_uid(old_user);
16091 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16093 + // p->cap_effective &= vxi->vx_cap_bset;
16094 + p->cap_effective =
16095 + cap_intersect(p->cap_effective, vxi->cap_bset);
16096 + // p->cap_inheritable &= vxi->vx_cap_bset;
16097 + p->cap_inheritable =
16098 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16099 + // p->cap_permitted &= vxi->vx_cap_bset;
16100 + p->cap_permitted =
16101 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16106 +#include <linux/file.h>
16107 +#include <linux/fdtable.h>
16109 +static int vx_openfd_task(struct task_struct *tsk)
16111 + struct files_struct *files = tsk->files;
16112 + struct fdtable *fdt;
16113 + const unsigned long *bptr;
16114 + int count, total;
16116 + /* no rcu_read_lock() because of spin_lock() */
16117 + spin_lock(&files->file_lock);
16118 + fdt = files_fdtable(files);
16119 + bptr = fdt->open_fds;
16120 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16121 + for (total = 0; count > 0; count--) {
16123 + total += hweight_long(*bptr);
16126 + spin_unlock(&files->file_lock);
16131 +/* for *space compatibility */
16133 +asmlinkage long sys_unshare(unsigned long);
16136 + * migrate task to new context
16137 + * gets vxi, puts old_vxi on change
16138 + * optionally unshares namespaces (hack)
16141 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16143 + struct vx_info *old_vxi;
16149 + vxdprintk(VXD_CBIT(xid, 5),
16150 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16151 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16153 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16154 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16157 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16160 + old_vxi = task_get_vx_info(p);
16161 + if (old_vxi == vxi)
16164 +// if (!(ret = vx_migrate_user(p, vxi))) {
16169 + openfd = vx_openfd_task(p);
16172 + atomic_dec(&old_vxi->cvirt.nr_threads);
16173 + atomic_dec(&old_vxi->cvirt.nr_running);
16174 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16175 + /* FIXME: what about the struct files here? */
16176 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16177 + /* account for the executable */
16178 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16180 + atomic_inc(&vxi->cvirt.nr_threads);
16181 + atomic_inc(&vxi->cvirt.nr_running);
16182 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16183 + /* FIXME: what about the struct files here? */
16184 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16185 + /* account for the executable */
16186 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16189 + release_vx_info(old_vxi, p);
16190 + clr_vx_info(&p->vx_info);
16192 + claim_vx_info(vxi, p);
16193 + set_vx_info(&p->vx_info, vxi);
16194 + p->xid = vxi->vx_id;
16196 + vxdprintk(VXD_CBIT(xid, 5),
16197 + "moved task %p into vxi:%p[#%d]",
16198 + p, vxi, vxi->vx_id);
16200 + // vx_mask_cap_bset(vxi, p);
16203 + /* hack for *spaces to provide compatibility */
16205 + struct nsproxy *old_nsp, *new_nsp;
16207 + ret = unshare_nsproxy_namespaces(
16208 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16209 + &new_nsp, NULL, NULL);
16213 + old_nsp = xchg(&p->nsproxy, new_nsp);
16214 + vx_set_space(vxi,
16215 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16216 + put_nsproxy(old_nsp);
16220 + put_vx_info(old_vxi);
16224 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16226 + struct task_struct *old_reaper;
16227 + struct vx_info *reaper_vxi;
16232 + vxdprintk(VXD_CBIT(xid, 6),
16233 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16234 + vxi, vxi->vx_id, p, p->xid, p->pid);
16236 + old_reaper = vxi->vx_reaper;
16237 + if (old_reaper == p)
16240 + reaper_vxi = task_get_vx_info(p);
16241 + if (reaper_vxi && reaper_vxi != vxi) {
16243 + "Unsuitable reaper [" VS_Q("%s") ",%u:#%u] "
16245 + p->comm, p->pid, p->xid, vx_current_xid());
16249 + /* set new child reaper */
16250 + get_task_struct(p);
16251 + vxi->vx_reaper = p;
16252 + put_task_struct(old_reaper);
16254 + put_vx_info(reaper_vxi);
16258 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16263 + vxdprintk(VXD_CBIT(xid, 6),
16264 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16265 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16267 + vxi->vx_flags &= ~VXF_STATE_INIT;
16268 + // vxi->vx_initpid = p->tgid;
16269 + vxi->vx_initpid = p->pid;
16273 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16275 + vxdprintk(VXD_CBIT(xid, 6),
16276 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16277 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16279 + vxi->exit_code = code;
16280 + vxi->vx_initpid = 0;
16284 +void vx_set_persistent(struct vx_info *vxi)
16286 + vxdprintk(VXD_CBIT(xid, 6),
16287 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16289 + get_vx_info(vxi);
16290 + claim_vx_info(vxi, NULL);
16293 +void vx_clear_persistent(struct vx_info *vxi)
16295 + vxdprintk(VXD_CBIT(xid, 6),
16296 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16298 + release_vx_info(vxi, NULL);
16299 + put_vx_info(vxi);
16302 +void vx_update_persistent(struct vx_info *vxi)
16304 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16305 + vx_set_persistent(vxi);
16307 + vx_clear_persistent(vxi);
16311 +/* task must be current or locked */
16313 +void exit_vx_info(struct task_struct *p, int code)
16315 + struct vx_info *vxi = p->vx_info;
16318 + atomic_dec(&vxi->cvirt.nr_threads);
16321 + vxi->exit_code = code;
16322 + release_vx_info(vxi, p);
16326 +void exit_vx_info_early(struct task_struct *p, int code)
16328 + struct vx_info *vxi = p->vx_info;
16331 + if (vxi->vx_initpid == p->pid)
16332 + vx_exit_init(vxi, p, code);
16333 + if (vxi->vx_reaper == p)
16334 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16339 +/* vserver syscall commands below here */
16341 +/* taks xid and vx_info functions */
16343 +#include <asm/uaccess.h>
16346 +int vc_task_xid(uint32_t id)
16351 + struct task_struct *tsk;
16354 + tsk = find_task_by_real_pid(id);
16355 + xid = (tsk) ? tsk->xid : -ESRCH;
16356 + rcu_read_unlock();
16358 + xid = vx_current_xid();
16363 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16365 + struct vcmd_vx_info_v0 vc_data;
16367 + vc_data.xid = vxi->vx_id;
16368 + vc_data.initpid = vxi->vx_initpid;
16370 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16376 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16378 + struct vcmd_ctx_stat_v0 vc_data;
16380 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16381 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16383 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16389 +/* context functions */
16391 +int vc_ctx_create(uint32_t xid, void __user *data)
16393 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16394 + struct vx_info *new_vxi;
16397 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16400 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16403 + new_vxi = __create_vx_info(xid);
16404 + if (IS_ERR(new_vxi))
16405 + return PTR_ERR(new_vxi);
16407 + /* initial flags */
16408 + new_vxi->vx_flags = vc_data.flagword;
16411 + if (vs_state_change(new_vxi, VSC_STARTUP))
16414 + ret = vx_migrate_task(current, new_vxi, (!data));
16418 + /* return context id on success */
16419 + ret = new_vxi->vx_id;
16421 + /* get a reference for persistent contexts */
16422 + if ((vc_data.flagword & VXF_PERSISTENT))
16423 + vx_set_persistent(new_vxi);
16425 + release_vx_info(new_vxi, NULL);
16426 + put_vx_info(new_vxi);
16431 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16433 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16436 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16439 + ret = vx_migrate_task(current, vxi, 0);
16442 + if (vc_data.flagword & VXM_SET_INIT)
16443 + ret = vx_set_init(vxi, current);
16446 + if (vc_data.flagword & VXM_SET_REAPER)
16447 + ret = vx_set_reaper(vxi, current);
16452 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16454 + struct vcmd_ctx_flags_v0 vc_data;
16456 + vc_data.flagword = vxi->vx_flags;
16458 + /* special STATE flag handling */
16459 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16461 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16466 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16468 + struct vcmd_ctx_flags_v0 vc_data;
16469 + uint64_t mask, trigger;
16471 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16474 + /* special STATE flag handling */
16475 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16476 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16478 + if (vxi == current_vx_info()) {
16479 + /* if (trigger & VXF_STATE_SETUP)
16480 + vx_mask_cap_bset(vxi, current); */
16481 + if (trigger & VXF_STATE_INIT) {
16484 + ret = vx_set_init(vxi, current);
16487 + ret = vx_set_reaper(vxi, current);
16493 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
16494 + vc_data.flagword, mask);
16495 + if (trigger & VXF_PERSISTENT)
16496 + vx_update_persistent(vxi);
16502 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
16504 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
16506 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
16510 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
16512 + kernel_cap_t c = __cap_empty_set;
16514 + c.cap[0] = v & 0xFFFFFFFF;
16515 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
16517 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
16522 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
16525 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
16527 + *ccaps = vxi->vx_ccaps;
16532 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
16534 + struct vcmd_ctx_caps_v1 vc_data;
16537 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
16540 + vc_data.cmask = ~0ULL;
16542 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16547 +static int do_set_caps(struct vx_info *vxi,
16548 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
16550 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
16553 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
16554 + bcaps, bmask, ccaps, cmask);
16556 + vxi->vx_bcaps = cap_t_from_caps(
16557 + vs_mask_flags(bcold, bcaps, bmask));
16558 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
16563 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
16565 + struct vcmd_ctx_caps_v1 vc_data;
16567 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16570 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
16573 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
16575 + struct vcmd_bcaps vc_data;
16578 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
16581 + vc_data.bmask = ~0ULL;
16583 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16588 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
16590 + struct vcmd_bcaps vc_data;
16592 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16595 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
16599 +int vc_get_umask(struct vx_info *vxi, void __user *data)
16601 + struct vcmd_umask vc_data;
16603 + vc_data.umask = vxi->vx_umask;
16604 + vc_data.mask = ~0ULL;
16606 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16611 +int vc_set_umask(struct vx_info *vxi, void __user *data)
16613 + struct vcmd_umask vc_data;
16615 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16618 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
16619 + vc_data.umask, vc_data.mask);
16624 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
16626 + struct vcmd_wmask vc_data;
16628 + vc_data.wmask = vxi->vx_wmask;
16629 + vc_data.mask = ~0ULL;
16631 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16636 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
16638 + struct vcmd_wmask vc_data;
16640 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16643 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
16644 + vc_data.wmask, vc_data.mask);
16649 +int vc_get_badness(struct vx_info *vxi, void __user *data)
16651 + struct vcmd_badness_v0 vc_data;
16653 + vc_data.bias = vxi->vx_badness_bias;
16655 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16660 +int vc_set_badness(struct vx_info *vxi, void __user *data)
16662 + struct vcmd_badness_v0 vc_data;
16664 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16667 + vxi->vx_badness_bias = vc_data.bias;
16671 +#include <linux/module.h>
16673 +EXPORT_SYMBOL_GPL(free_vx_info);
16675 diff -NurpP --minimal linux-3.9.4/kernel/vserver/cvirt.c linux-3.9.4-vs2.3.6.3/kernel/vserver/cvirt.c
16676 --- linux-3.9.4/kernel/vserver/cvirt.c 1970-01-01 00:00:00.000000000 +0000
16677 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/cvirt.c 2013-05-31 14:47:11.000000000 +0000
16680 + * linux/kernel/vserver/cvirt.c
16682 + * Virtual Server: Context Virtualization
16684 + * Copyright (C) 2004-2007 Herbert Pötzl
16686 + * V0.01 broken out from limit.c
16687 + * V0.02 added utsname stuff
16688 + * V0.03 changed vcmds to vxi arg
16692 +#include <linux/types.h>
16693 +#include <linux/utsname.h>
16694 +#include <linux/vs_cvirt.h>
16695 +#include <linux/vserver/switch.h>
16696 +#include <linux/vserver/cvirt_cmd.h>
16698 +#include <asm/uaccess.h>
16701 +void vx_vsi_boottime(struct timespec *boottime)
16703 + struct vx_info *vxi = current_vx_info();
16705 + set_normalized_timespec(boottime,
16706 + boottime->tv_sec + vxi->cvirt.bias_uptime.tv_sec,
16707 + boottime->tv_nsec + vxi->cvirt.bias_uptime.tv_nsec);
16711 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
16713 + struct vx_info *vxi = current_vx_info();
16715 + set_normalized_timespec(uptime,
16716 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
16717 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
16720 + set_normalized_timespec(idle,
16721 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
16722 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
16726 +uint64_t vx_idle_jiffies(void)
16728 + return init_task.utime + init_task.stime;
16733 +static inline uint32_t __update_loadavg(uint32_t load,
16734 + int wsize, int delta, int n)
16736 + unsigned long long calc, prev;
16738 + /* just set it to n */
16739 + if (unlikely(delta >= wsize))
16740 + return (n << FSHIFT);
16742 + calc = delta * n;
16744 + prev = (wsize - delta);
16747 + do_div(calc, wsize);
16752 +void vx_update_load(struct vx_info *vxi)
16754 + uint32_t now, last, delta;
16755 + unsigned int nr_running, nr_uninterruptible;
16756 + unsigned int total;
16757 + unsigned long flags;
16759 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
16762 + last = vxi->cvirt.load_last;
16763 + delta = now - last;
16765 + if (delta < 5*HZ)
16768 + nr_running = atomic_read(&vxi->cvirt.nr_running);
16769 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
16770 + total = nr_running + nr_uninterruptible;
16772 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
16773 + 60*HZ, delta, total);
16774 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
16775 + 5*60*HZ, delta, total);
16776 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
16777 + 15*60*HZ, delta, total);
16779 + vxi->cvirt.load_last = now;
16781 + atomic_inc(&vxi->cvirt.load_updates);
16782 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
16787 + * Commands to do_syslog:
16789 + * 0 -- Close the log. Currently a NOP.
16790 + * 1 -- Open the log. Currently a NOP.
16791 + * 2 -- Read from the log.
16792 + * 3 -- Read all messages remaining in the ring buffer.
16793 + * 4 -- Read and clear all messages remaining in the ring buffer
16794 + * 5 -- Clear ring buffer.
16795 + * 6 -- Disable printk's to console
16796 + * 7 -- Enable printk's to console
16797 + * 8 -- Set level of messages printed to console
16798 + * 9 -- Return number of unread characters in the log buffer
16799 + * 10 -- Return size of the log buffer
16801 +int vx_do_syslog(int type, char __user *buf, int len)
16804 + int do_clear = 0;
16805 + struct vx_info *vxi = current_vx_info();
16806 + struct _vx_syslog *log;
16810 + log = &vxi->cvirt.syslog;
16813 + case 0: /* Close log */
16814 + case 1: /* Open log */
16816 + case 2: /* Read from log */
16817 + error = wait_event_interruptible(log->log_wait,
16818 + (log->log_start - log->log_end));
16821 + spin_lock_irq(&log->logbuf_lock);
16822 + spin_unlock_irq(&log->logbuf_lock);
16824 + case 4: /* Read/clear last kernel messages */
16826 + /* fall through */
16827 + case 3: /* Read last kernel messages */
16830 + case 5: /* Clear ring buffer */
16833 + case 6: /* Disable logging to console */
16834 + case 7: /* Enable logging to console */
16835 + case 8: /* Set level of messages printed to console */
16838 + case 9: /* Number of chars in the log buffer */
16840 + case 10: /* Size of the log buffer */
16850 +/* virtual host info names */
16852 +static char *vx_vhi_name(struct vx_info *vxi, int id)
16854 + struct nsproxy *nsproxy;
16855 + struct uts_namespace *uts;
16857 + if (id == VHIN_CONTEXT)
16858 + return vxi->vx_name;
16860 + nsproxy = vxi->space[0].vx_nsproxy;
16864 + uts = nsproxy->uts_ns;
16869 + case VHIN_SYSNAME:
16870 + return uts->name.sysname;
16871 + case VHIN_NODENAME:
16872 + return uts->name.nodename;
16873 + case VHIN_RELEASE:
16874 + return uts->name.release;
16875 + case VHIN_VERSION:
16876 + return uts->name.version;
16877 + case VHIN_MACHINE:
16878 + return uts->name.machine;
16879 + case VHIN_DOMAINNAME:
16880 + return uts->name.domainname;
16887 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
16889 + struct vcmd_vhi_name_v0 vc_data;
16892 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16895 + name = vx_vhi_name(vxi, vc_data.field);
16899 + memcpy(name, vc_data.name, 65);
16903 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
16905 + struct vcmd_vhi_name_v0 vc_data;
16908 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16911 + name = vx_vhi_name(vxi, vc_data.field);
16915 + memcpy(vc_data.name, name, 65);
16916 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16922 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
16924 + struct vcmd_virt_stat_v0 vc_data;
16925 + struct _vx_cvirt *cvirt = &vxi->cvirt;
16926 + struct timespec uptime;
16928 + do_posix_clock_monotonic_gettime(&uptime);
16929 + set_normalized_timespec(&uptime,
16930 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
16931 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
16933 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
16934 + vc_data.uptime = timespec_to_ns(&uptime);
16935 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
16936 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
16937 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
16938 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
16939 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
16940 + vc_data.load[0] = cvirt->load[0];
16941 + vc_data.load[1] = cvirt->load[1];
16942 + vc_data.load[2] = cvirt->load[2];
16944 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16950 +#ifdef CONFIG_VSERVER_VTIME
16952 +/* virtualized time base */
16954 +void vx_adjust_timespec(struct timespec *ts)
16956 + struct vx_info *vxi;
16958 + if (!vx_flags(VXF_VIRT_TIME, 0))
16961 + vxi = current_vx_info();
16962 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
16963 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
16965 + if (ts->tv_nsec >= NSEC_PER_SEC) {
16967 + ts->tv_nsec -= NSEC_PER_SEC;
16968 + } else if (ts->tv_nsec < 0) {
16970 + ts->tv_nsec += NSEC_PER_SEC;
16974 +int vx_settimeofday(const struct timespec *ts)
16976 + struct timespec ats, delta;
16977 + struct vx_info *vxi;
16979 + if (!vx_flags(VXF_VIRT_TIME, 0))
16980 + return do_settimeofday(ts);
16982 + getnstimeofday(&ats);
16983 + delta = timespec_sub(*ts, ats);
16985 + vxi = current_vx_info();
16986 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
16992 diff -NurpP --minimal linux-3.9.4/kernel/vserver/cvirt_init.h linux-3.9.4-vs2.3.6.3/kernel/vserver/cvirt_init.h
16993 --- linux-3.9.4/kernel/vserver/cvirt_init.h 1970-01-01 00:00:00.000000000 +0000
16994 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/cvirt_init.h 2013-05-31 14:47:11.000000000 +0000
16998 +extern uint64_t vx_idle_jiffies(void);
17000 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17002 + uint64_t idle_jiffies = vx_idle_jiffies();
17003 + uint64_t nsuptime;
17005 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17006 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17007 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17008 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17009 + cvirt->bias_ts.tv_sec = 0;
17010 + cvirt->bias_ts.tv_nsec = 0;
17012 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17013 + atomic_set(&cvirt->nr_threads, 0);
17014 + atomic_set(&cvirt->nr_running, 0);
17015 + atomic_set(&cvirt->nr_uninterruptible, 0);
17016 + atomic_set(&cvirt->nr_onhold, 0);
17018 + spin_lock_init(&cvirt->load_lock);
17019 + cvirt->load_last = jiffies;
17020 + atomic_set(&cvirt->load_updates, 0);
17021 + cvirt->load[0] = 0;
17022 + cvirt->load[1] = 0;
17023 + cvirt->load[2] = 0;
17024 + atomic_set(&cvirt->total_forks, 0);
17026 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17027 + init_waitqueue_head(&cvirt->syslog.log_wait);
17028 + cvirt->syslog.log_start = 0;
17029 + cvirt->syslog.log_end = 0;
17030 + cvirt->syslog.con_start = 0;
17031 + cvirt->syslog.logged_chars = 0;
17035 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17037 + // cvirt_pc->cpustat = { 0 };
17040 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17042 +#ifdef CONFIG_VSERVER_WARN
17045 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17046 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17048 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17049 + "!!! cvirt: %p[nr_running] = %d on exit.",
17051 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17052 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17054 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17055 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17061 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17066 diff -NurpP --minimal linux-3.9.4/kernel/vserver/cvirt_proc.h linux-3.9.4-vs2.3.6.3/kernel/vserver/cvirt_proc.h
17067 --- linux-3.9.4/kernel/vserver/cvirt_proc.h 1970-01-01 00:00:00.000000000 +0000
17068 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/cvirt_proc.h 2013-05-31 19:38:26.000000000 +0000
17070 +#ifndef _VX_CVIRT_PROC_H
17071 +#define _VX_CVIRT_PROC_H
17073 +#include <linux/nsproxy.h>
17074 +#include <linux/mnt_namespace.h>
17075 +#include <linux/ipc_namespace.h>
17076 +#include <linux/utsname.h>
17077 +#include <linux/ipc.h>
17079 +extern int vx_info_mnt_namespace(struct mnt_namespace *, char *);
17082 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17084 + struct mnt_namespace *ns;
17085 + struct uts_namespace *uts;
17086 + struct ipc_namespace *ipc;
17092 + length += sprintf(buffer + length,
17093 + "NSProxy:\t%p [%p,%p,%p]\n",
17094 + nsproxy, nsproxy->mnt_ns,
17095 + nsproxy->uts_ns, nsproxy->ipc_ns);
17097 + ns = nsproxy->mnt_ns;
17101 + length += vx_info_mnt_namespace(ns, buffer + length);
17105 + uts = nsproxy->uts_ns;
17109 + length += sprintf(buffer + length,
17110 + "SysName:\t%.*s\n"
17111 + "NodeName:\t%.*s\n"
17112 + "Release:\t%.*s\n"
17113 + "Version:\t%.*s\n"
17114 + "Machine:\t%.*s\n"
17115 + "DomainName:\t%.*s\n",
17116 + __NEW_UTS_LEN, uts->name.sysname,
17117 + __NEW_UTS_LEN, uts->name.nodename,
17118 + __NEW_UTS_LEN, uts->name.release,
17119 + __NEW_UTS_LEN, uts->name.version,
17120 + __NEW_UTS_LEN, uts->name.machine,
17121 + __NEW_UTS_LEN, uts->name.domainname);
17124 + ipc = nsproxy->ipc_ns;
17128 + length += sprintf(buffer + length,
17129 + "SEMS:\t\t%d %d %d %d %d\n"
17130 + "MSG:\t\t%d %d %d\n"
17131 + "SHM:\t\t%lu %lu %d %ld\n",
17132 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17133 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17135 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17136 + (unsigned long)ipc->shm_ctlmax,
17137 + (unsigned long)ipc->shm_ctlall,
17138 + ipc->shm_ctlmni, ipc->shm_tot);
17145 +#include <linux/sched.h>
17147 +#define LOAD_INT(x) ((x) >> FSHIFT)
17148 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17151 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17156 + length += sprintf(buffer + length,
17157 + "BiasUptime:\t%lu.%02lu\n",
17158 + (unsigned long)cvirt->bias_uptime.tv_sec,
17159 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17161 + a = cvirt->load[0] + (FIXED_1 / 200);
17162 + b = cvirt->load[1] + (FIXED_1 / 200);
17163 + c = cvirt->load[2] + (FIXED_1 / 200);
17164 + length += sprintf(buffer + length,
17165 + "nr_threads:\t%d\n"
17166 + "nr_running:\t%d\n"
17167 + "nr_unintr:\t%d\n"
17168 + "nr_onhold:\t%d\n"
17169 + "load_updates:\t%d\n"
17170 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17171 + "total_forks:\t%d\n",
17172 + atomic_read(&cvirt->nr_threads),
17173 + atomic_read(&cvirt->nr_running),
17174 + atomic_read(&cvirt->nr_uninterruptible),
17175 + atomic_read(&cvirt->nr_onhold),
17176 + atomic_read(&cvirt->load_updates),
17177 + LOAD_INT(a), LOAD_FRAC(a),
17178 + LOAD_INT(b), LOAD_FRAC(b),
17179 + LOAD_INT(c), LOAD_FRAC(c),
17180 + atomic_read(&cvirt->total_forks));
17185 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17186 + char *buffer, int cpu)
17192 +#endif /* _VX_CVIRT_PROC_H */
17193 diff -NurpP --minimal linux-3.9.4/kernel/vserver/debug.c linux-3.9.4-vs2.3.6.3/kernel/vserver/debug.c
17194 --- linux-3.9.4/kernel/vserver/debug.c 1970-01-01 00:00:00.000000000 +0000
17195 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/debug.c 2013-05-31 14:47:11.000000000 +0000
17198 + * kernel/vserver/debug.c
17200 + * Copyright (C) 2005-2007 Herbert Pötzl
17202 + * V0.01 vx_info dump support
17206 +#include <linux/module.h>
17208 +#include <linux/vserver/context.h>
17211 +void dump_vx_info(struct vx_info *vxi, int level)
17213 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17214 + atomic_read(&vxi->vx_usecnt),
17215 + atomic_read(&vxi->vx_tasks),
17218 + __dump_vx_limit(&vxi->limit);
17219 + __dump_vx_sched(&vxi->sched);
17220 + __dump_vx_cvirt(&vxi->cvirt);
17221 + __dump_vx_cacct(&vxi->cacct);
17227 +EXPORT_SYMBOL_GPL(dump_vx_info);
17229 diff -NurpP --minimal linux-3.9.4/kernel/vserver/device.c linux-3.9.4-vs2.3.6.3/kernel/vserver/device.c
17230 --- linux-3.9.4/kernel/vserver/device.c 1970-01-01 00:00:00.000000000 +0000
17231 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/device.c 2013-05-31 14:47:11.000000000 +0000
17234 + * linux/kernel/vserver/device.c
17236 + * Linux-VServer: Device Support
17238 + * Copyright (C) 2006 Herbert Pötzl
17239 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17241 + * V0.01 device mapping basics
17242 + * V0.02 added defaults
17246 +#include <linux/slab.h>
17247 +#include <linux/rcupdate.h>
17248 +#include <linux/fs.h>
17249 +#include <linux/namei.h>
17250 +#include <linux/hash.h>
17252 +#include <asm/errno.h>
17253 +#include <asm/uaccess.h>
17254 +#include <linux/vserver/base.h>
17255 +#include <linux/vserver/debug.h>
17256 +#include <linux/vserver/context.h>
17257 +#include <linux/vserver/device.h>
17258 +#include <linux/vserver/device_cmd.h>
17261 +#define DMAP_HASH_BITS 4
17264 +struct vs_mapping {
17266 + struct hlist_node hlist;
17267 + struct list_head list;
17269 +#define dm_hlist u.hlist
17270 +#define dm_list u.list
17273 + struct vx_dmap_target target;
17277 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17279 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17281 +static struct vx_dmap_target dmap_defaults[2] = {
17282 + { .flags = DATTR_OPEN },
17283 + { .flags = DATTR_OPEN },
17287 +struct kmem_cache *dmap_cachep __read_mostly;
17289 +int __init dmap_cache_init(void)
17291 + dmap_cachep = kmem_cache_create("dmap_cache",
17292 + sizeof(struct vs_mapping), 0,
17293 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17297 +__initcall(dmap_cache_init);
17300 +static inline unsigned int __hashval(dev_t dev, int bits)
17302 + return hash_long((unsigned long)dev, bits);
17306 +/* __hash_mapping()
17307 + * add the mapping to the hash table
17309 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17311 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17312 + struct hlist_head *head, *hash = dmap_main_hash;
17313 + int device = vdm->device;
17315 + spin_lock(hash_lock);
17316 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17317 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17319 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17320 + hlist_add_head(&vdm->dm_hlist, head);
17321 + spin_unlock(hash_lock);
17325 +static inline int __mode_to_default(umode_t mode)
17338 +/* __set_default()
17341 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17342 + struct vx_dmap_target *vdmt)
17344 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17345 + spin_lock(hash_lock);
17348 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17350 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17353 + spin_unlock(hash_lock);
17355 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17356 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17360 +/* __remove_default()
17361 + * remove a default
17363 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17365 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17366 + spin_lock(hash_lock);
17369 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17370 + else /* remove == reset */
17371 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17373 + spin_unlock(hash_lock);
17378 +/* __find_mapping()
17379 + * find a mapping in the hash table
17381 + * caller must hold hash_lock
17383 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17384 + struct vs_mapping **local, struct vs_mapping **global)
17386 + struct hlist_head *hash = dmap_main_hash;
17387 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17388 + struct hlist_node *pos;
17389 + struct vs_mapping *vdm;
17395 + hlist_for_each(pos, head) {
17396 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17398 + if ((vdm->device == device) &&
17399 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17400 + if (vdm->xid == xid) {
17403 + } else if (global && vdm->xid == 0)
17408 + if (global && *global)
17415 +/* __lookup_mapping()
17416 + * find a mapping and store the result in target and flags
17418 +static inline int __lookup_mapping(struct vx_info *vxi,
17419 + dev_t device, dev_t *target, int *flags, umode_t mode)
17421 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17422 + struct vs_mapping *vdm, *global;
17423 + struct vx_dmap_target *vdmt;
17425 + xid_t xid = vxi->vx_id;
17428 + spin_lock(hash_lock);
17429 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17431 + vdmt = &vdm->target;
17435 + index = __mode_to_default(mode);
17436 + if (vxi && vxi->dmap.targets[index].flags) {
17438 + vdmt = &vxi->dmap.targets[index];
17439 + } else if (global) {
17441 + vdmt = &global->target;
17445 + vdmt = &dmap_defaults[index];
17449 + if (target && (vdmt->flags & DATTR_REMAP))
17450 + *target = vdmt->target;
17452 + *target = device;
17454 + *flags = vdmt->flags;
17456 + spin_unlock(hash_lock);
17462 +/* __remove_mapping()
17463 + * remove a mapping from the hash table
17465 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17468 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17469 + struct vs_mapping *vdm = NULL;
17472 + spin_lock(hash_lock);
17474 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17476 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
17477 + vxi, vxi ? vxi->vx_id : 0, device, mode);
17480 + hlist_del(&vdm->dm_hlist);
17483 + spin_unlock(hash_lock);
17485 + kmem_cache_free(dmap_cachep, vdm);
17491 +int vs_map_device(struct vx_info *vxi,
17492 + dev_t device, dev_t *target, umode_t mode)
17494 + int ret, flags = DATTR_MASK;
17498 + *target = device;
17501 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
17502 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
17503 + device, target ? *target : 0, flags, mode, ret);
17505 + return (flags & DATTR_MASK);
17510 +static int do_set_mapping(struct vx_info *vxi,
17511 + dev_t device, dev_t target, int flags, umode_t mode)
17514 + struct vs_mapping *new;
17516 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
17520 + INIT_HLIST_NODE(&new->dm_hlist);
17521 + new->device = device;
17522 + new->target.target = target;
17523 + new->target.flags = flags | mode;
17524 + new->xid = (vxi ? vxi->vx_id : 0);
17526 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
17527 + __hash_mapping(vxi, new);
17529 + struct vx_dmap_target new = {
17530 + .target = target,
17531 + .flags = flags | mode,
17533 + __set_default(vxi, mode, &new);
17539 +static int do_unset_mapping(struct vx_info *vxi,
17540 + dev_t device, dev_t target, int flags, umode_t mode)
17542 + int ret = -EINVAL;
17545 + ret = __remove_mapping(vxi, device, mode);
17549 + ret = __remove_default(vxi, mode);
17559 +static inline int __user_device(const char __user *name, dev_t *dev,
17562 + struct nameidata nd;
17569 + ret = user_lpath(name, &nd.path);
17572 + if (nd.path.dentry->d_inode) {
17573 + *dev = nd.path.dentry->d_inode->i_rdev;
17574 + *mode = nd.path.dentry->d_inode->i_mode;
17576 + path_put(&nd.path);
17580 +static inline int __mapping_mode(dev_t device, dev_t target,
17581 + umode_t device_mode, umode_t target_mode, umode_t *mode)
17584 + *mode = device_mode & S_IFMT;
17586 + *mode = target_mode & S_IFMT;
17590 + /* if both given, device and target mode have to match */
17591 + if (device && target &&
17592 + ((device_mode ^ target_mode) & S_IFMT))
17598 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
17599 + const char __user *target_path, int flags, int set)
17601 + dev_t device = ~0, target = ~0;
17602 + umode_t device_mode = 0, target_mode = 0, mode;
17605 + ret = __user_device(device_path, &device, &device_mode);
17608 + ret = __user_device(target_path, &target, &target_mode);
17612 + ret = __mapping_mode(device, target,
17613 + device_mode, target_mode, &mode);
17618 + return do_set_mapping(vxi, device, target,
17621 + return do_unset_mapping(vxi, device, target,
17626 +int vc_set_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, 1);
17637 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
17639 + struct vcmd_set_mapping_v0 vc_data;
17641 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17644 + return do_mapping(vxi, vc_data.device, vc_data.target,
17645 + vc_data.flags, 0);
17649 +#ifdef CONFIG_COMPAT
17651 +int vc_set_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, 1);
17662 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
17664 + struct vcmd_set_mapping_v0_x32 vc_data;
17666 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17669 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17670 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
17673 +#endif /* CONFIG_COMPAT */
17676 diff -NurpP --minimal linux-3.9.4/kernel/vserver/dlimit.c linux-3.9.4-vs2.3.6.3/kernel/vserver/dlimit.c
17677 --- linux-3.9.4/kernel/vserver/dlimit.c 1970-01-01 00:00:00.000000000 +0000
17678 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/dlimit.c 2013-05-31 19:37:39.000000000 +0000
17681 + * linux/kernel/vserver/dlimit.c
17683 + * Virtual Server: Context Disk Limits
17685 + * Copyright (C) 2004-2009 Herbert Pötzl
17687 + * V0.01 initial version
17688 + * V0.02 compat32 splitup
17689 + * V0.03 extended interface
17693 +#include <linux/statfs.h>
17694 +#include <linux/sched.h>
17695 +#include <linux/namei.h>
17696 +#include <linux/vs_tag.h>
17697 +#include <linux/vs_dlimit.h>
17698 +#include <linux/vserver/dlimit_cmd.h>
17699 +#include <linux/slab.h>
17700 +// #include <linux/gfp.h>
17702 +#include <asm/uaccess.h>
17704 +/* __alloc_dl_info()
17706 + * allocate an initialized dl_info struct
17707 + * doesn't make it visible (hash) */
17709 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
17711 + struct dl_info *new = NULL;
17713 + vxdprintk(VXD_CBIT(dlim, 5),
17714 + "alloc_dl_info(%p,%d)*", sb, tag);
17716 + /* would this benefit from a slab cache? */
17717 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
17721 + memset(new, 0, sizeof(struct dl_info));
17722 + new->dl_tag = tag;
17724 + // INIT_RCU_HEAD(&new->dl_rcu);
17725 + INIT_HLIST_NODE(&new->dl_hlist);
17726 + spin_lock_init(&new->dl_lock);
17727 + atomic_set(&new->dl_refcnt, 0);
17728 + atomic_set(&new->dl_usecnt, 0);
17730 + /* rest of init goes here */
17732 + vxdprintk(VXD_CBIT(dlim, 4),
17733 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
17737 +/* __dealloc_dl_info()
17739 + * final disposal of dl_info */
17741 +static void __dealloc_dl_info(struct dl_info *dli)
17743 + vxdprintk(VXD_CBIT(dlim, 4),
17744 + "dealloc_dl_info(%p)", dli);
17746 + dli->dl_hlist.next = LIST_POISON1;
17747 + dli->dl_tag = -1;
17750 + BUG_ON(atomic_read(&dli->dl_usecnt));
17751 + BUG_ON(atomic_read(&dli->dl_refcnt));
17757 +/* hash table for dl_info hash */
17759 +#define DL_HASH_SIZE 13
17761 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
17763 +static DEFINE_SPINLOCK(dl_info_hash_lock);
17766 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
17768 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
17773 +/* __hash_dl_info()
17775 + * add the dli to the global hash table
17776 + * requires the hash_lock to be held */
17778 +static inline void __hash_dl_info(struct dl_info *dli)
17780 + struct hlist_head *head;
17782 + vxdprintk(VXD_CBIT(dlim, 6),
17783 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
17784 + get_dl_info(dli);
17785 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
17786 + hlist_add_head_rcu(&dli->dl_hlist, head);
17789 +/* __unhash_dl_info()
17791 + * remove the dli from the global hash table
17792 + * requires the hash_lock to be held */
17794 +static inline void __unhash_dl_info(struct dl_info *dli)
17796 + vxdprintk(VXD_CBIT(dlim, 6),
17797 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
17798 + hlist_del_rcu(&dli->dl_hlist);
17799 + put_dl_info(dli);
17803 +/* __lookup_dl_info()
17805 + * requires the rcu_read_lock()
17806 + * doesn't increment the dl_refcnt */
17808 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
17810 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
17811 + struct dl_info *dli;
17813 + hlist_for_each_entry_rcu(dli, head, dl_hlist) {
17814 + if (dli->dl_tag == tag && dli->dl_sb == sb)
17821 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
17823 + struct dl_info *dli;
17826 + dli = get_dl_info(__lookup_dl_info(sb, tag));
17827 + vxdprintk(VXD_CBIT(dlim, 7),
17828 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
17829 + rcu_read_unlock();
17833 +void rcu_free_dl_info(struct rcu_head *head)
17835 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
17836 + int usecnt, refcnt;
17838 + BUG_ON(!dli || !head);
17840 + usecnt = atomic_read(&dli->dl_usecnt);
17841 + BUG_ON(usecnt < 0);
17843 + refcnt = atomic_read(&dli->dl_refcnt);
17844 + BUG_ON(refcnt < 0);
17846 + vxdprintk(VXD_CBIT(dlim, 3),
17847 + "rcu_free_dl_info(%p)", dli);
17849 + __dealloc_dl_info(dli);
17851 + printk("!!! rcu didn't free\n");
17857 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
17858 + uint32_t flags, int add)
17860 + struct path path;
17863 + ret = user_lpath(name, &path);
17865 + struct super_block *sb;
17866 + struct dl_info *dli;
17869 + if (!path.dentry->d_inode)
17870 + goto out_release;
17871 + if (!(sb = path.dentry->d_inode->i_sb))
17872 + goto out_release;
17875 + dli = __alloc_dl_info(sb, id);
17876 + spin_lock(&dl_info_hash_lock);
17879 + if (__lookup_dl_info(sb, id))
17881 + __hash_dl_info(dli);
17884 + spin_lock(&dl_info_hash_lock);
17885 + dli = __lookup_dl_info(sb, id);
17890 + __unhash_dl_info(dli);
17894 + spin_unlock(&dl_info_hash_lock);
17896 + __dealloc_dl_info(dli);
17903 +int vc_add_dlimit(uint32_t id, void __user *data)
17905 + struct vcmd_ctx_dlimit_base_v0 vc_data;
17907 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17910 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
17913 +int vc_rem_dlimit(uint32_t id, void __user *data)
17915 + struct vcmd_ctx_dlimit_base_v0 vc_data;
17917 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17920 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
17923 +#ifdef CONFIG_COMPAT
17925 +int vc_add_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, 1);
17936 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
17938 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
17940 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17943 + return do_addrem_dlimit(id,
17944 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
17947 +#endif /* CONFIG_COMPAT */
17951 +int do_set_dlimit(uint32_t id, const char __user *name,
17952 + uint32_t space_used, uint32_t space_total,
17953 + uint32_t inodes_used, uint32_t inodes_total,
17954 + uint32_t reserved, uint32_t flags)
17956 + struct path path;
17959 + ret = user_lpath(name, &path);
17961 + struct super_block *sb;
17962 + struct dl_info *dli;
17965 + if (!path.dentry->d_inode)
17966 + goto out_release;
17967 + if (!(sb = path.dentry->d_inode->i_sb))
17968 + goto out_release;
17970 + /* sanity checks */
17971 + if ((reserved != CDLIM_KEEP &&
17972 + reserved > 100) ||
17973 + (inodes_used != CDLIM_KEEP &&
17974 + inodes_used > inodes_total) ||
17975 + (space_used != CDLIM_KEEP &&
17976 + space_used > space_total))
17977 + goto out_release;
17980 + dli = locate_dl_info(sb, id);
17982 + goto out_release;
17984 + spin_lock(&dli->dl_lock);
17986 + if (inodes_used != CDLIM_KEEP)
17987 + dli->dl_inodes_used = inodes_used;
17988 + if (inodes_total != CDLIM_KEEP)
17989 + dli->dl_inodes_total = inodes_total;
17990 + if (space_used != CDLIM_KEEP)
17991 + dli->dl_space_used = dlimit_space_32to64(
17992 + space_used, flags, DLIMS_USED);
17994 + if (space_total == CDLIM_INFINITY)
17995 + dli->dl_space_total = DLIM_INFINITY;
17996 + else if (space_total != CDLIM_KEEP)
17997 + dli->dl_space_total = dlimit_space_32to64(
17998 + space_total, flags, DLIMS_TOTAL);
18000 + if (reserved != CDLIM_KEEP)
18001 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18003 + spin_unlock(&dli->dl_lock);
18005 + put_dl_info(dli);
18014 +int vc_set_dlimit(uint32_t id, void __user *data)
18016 + struct vcmd_ctx_dlimit_v0 vc_data;
18018 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18021 + return do_set_dlimit(id, vc_data.name,
18022 + vc_data.space_used, vc_data.space_total,
18023 + vc_data.inodes_used, vc_data.inodes_total,
18024 + vc_data.reserved, vc_data.flags);
18027 +#ifdef CONFIG_COMPAT
18029 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18031 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18033 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18036 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18037 + vc_data.space_used, vc_data.space_total,
18038 + vc_data.inodes_used, vc_data.inodes_total,
18039 + vc_data.reserved, vc_data.flags);
18042 +#endif /* CONFIG_COMPAT */
18046 +int do_get_dlimit(uint32_t id, const char __user *name,
18047 + uint32_t *space_used, uint32_t *space_total,
18048 + uint32_t *inodes_used, uint32_t *inodes_total,
18049 + uint32_t *reserved, uint32_t *flags)
18051 + struct path path;
18054 + ret = user_lpath(name, &path);
18056 + struct super_block *sb;
18057 + struct dl_info *dli;
18060 + if (!path.dentry->d_inode)
18061 + goto out_release;
18062 + if (!(sb = path.dentry->d_inode->i_sb))
18063 + goto out_release;
18066 + dli = locate_dl_info(sb, id);
18068 + goto out_release;
18070 + spin_lock(&dli->dl_lock);
18071 + *inodes_used = dli->dl_inodes_used;
18072 + *inodes_total = dli->dl_inodes_total;
18074 + *space_used = dlimit_space_64to32(
18075 + dli->dl_space_used, flags, DLIMS_USED);
18077 + if (dli->dl_space_total == DLIM_INFINITY)
18078 + *space_total = CDLIM_INFINITY;
18080 + *space_total = dlimit_space_64to32(
18081 + dli->dl_space_total, flags, DLIMS_TOTAL);
18083 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18084 + spin_unlock(&dli->dl_lock);
18086 + put_dl_info(dli);
18097 +int vc_get_dlimit(uint32_t id, void __user *data)
18099 + struct vcmd_ctx_dlimit_v0 vc_data;
18102 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18105 + ret = do_get_dlimit(id, vc_data.name,
18106 + &vc_data.space_used, &vc_data.space_total,
18107 + &vc_data.inodes_used, &vc_data.inodes_total,
18108 + &vc_data.reserved, &vc_data.flags);
18112 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18117 +#ifdef CONFIG_COMPAT
18119 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18121 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18124 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18127 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18128 + &vc_data.space_used, &vc_data.space_total,
18129 + &vc_data.inodes_used, &vc_data.inodes_total,
18130 + &vc_data.reserved, &vc_data.flags);
18134 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18139 +#endif /* CONFIG_COMPAT */
18142 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18144 + struct dl_info *dli;
18145 + __u64 blimit, bfree, bavail;
18148 + dli = locate_dl_info(sb, dx_current_tag());
18152 + spin_lock(&dli->dl_lock);
18153 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18156 + /* reduce max inodes available to limit */
18157 + if (buf->f_files > dli->dl_inodes_total)
18158 + buf->f_files = dli->dl_inodes_total;
18160 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18161 + /* reduce free inodes to min */
18162 + if (ifree < buf->f_ffree)
18163 + buf->f_ffree = ifree;
18166 + if (dli->dl_space_total == DLIM_INFINITY)
18169 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18171 + if (dli->dl_space_total < dli->dl_space_used)
18174 + bfree = (dli->dl_space_total - dli->dl_space_used)
18175 + >> sb->s_blocksize_bits;
18177 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18178 + if (bavail < dli->dl_space_used)
18181 + bavail = (bavail - dli->dl_space_used)
18182 + >> sb->s_blocksize_bits;
18184 + /* reduce max space available to limit */
18185 + if (buf->f_blocks > blimit)
18186 + buf->f_blocks = blimit;
18188 + /* reduce free space to min */
18189 + if (bfree < buf->f_bfree)
18190 + buf->f_bfree = bfree;
18192 + /* reduce avail space to min */
18193 + if (bavail < buf->f_bavail)
18194 + buf->f_bavail = bavail;
18197 + spin_unlock(&dli->dl_lock);
18198 + put_dl_info(dli);
18203 +#include <linux/module.h>
18205 +EXPORT_SYMBOL_GPL(locate_dl_info);
18206 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18208 diff -NurpP --minimal linux-3.9.4/kernel/vserver/helper.c linux-3.9.4-vs2.3.6.3/kernel/vserver/helper.c
18209 --- linux-3.9.4/kernel/vserver/helper.c 1970-01-01 00:00:00.000000000 +0000
18210 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/helper.c 2013-06-01 08:27:59.000000000 +0000
18213 + * linux/kernel/vserver/helper.c
18215 + * Virtual Context Support
18217 + * Copyright (C) 2004-2007 Herbert Pötzl
18219 + * V0.01 basic helper
18223 +#include <linux/kmod.h>
18224 +#include <linux/reboot.h>
18225 +#include <linux/vs_context.h>
18226 +#include <linux/vs_network.h>
18227 +#include <linux/vserver/signal.h>
18230 +char vshelper_path[255] = "/sbin/vshelper";
18232 +static int vshelper_init(struct subprocess_info *info, struct cred *new_cred)
18234 + current->flags &= ~PF_THREAD_BOUND;
18238 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18242 + if ((ret = call_usermodehelper_fns(name, argv, envp,
18243 + sync ? UMH_WAIT_PROC : UMH_WAIT_EXEC,
18244 + vshelper_init, NULL, NULL))) {
18245 + printk(KERN_WARNING "%s: (%s %s) returned %s with %d\n",
18246 + name, argv[1], argv[2],
18247 + sync ? "sync" : "async", ret);
18249 + vxdprintk(VXD_CBIT(switch, 4),
18250 + "%s: (%s %s) returned %s with %d",
18251 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18256 + * vshelper path is set via /proc/sys
18257 + * invoked by vserver sys_reboot(), with
18258 + * the following arguments
18260 + * argv [0] = vshelper_path;
18261 + * argv [1] = action: "restart", "halt", "poweroff", ...
18262 + * argv [2] = context identifier
18264 + * envp [*] = type-specific parameters
18267 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18269 + char id_buf[8], cmd_buf[16];
18270 + char uid_buf[16], pid_buf[16];
18273 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18274 + char *envp[] = {"HOME=/", "TERM=linux",
18275 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18276 + uid_buf, pid_buf, cmd_buf, 0};
18278 + if (vx_info_state(vxi, VXS_HELPER))
18280 + vxi->vx_state |= VXS_HELPER;
18282 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18284 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18285 + snprintf(uid_buf, sizeof(uid_buf), "VS_UID=%d",
18286 + from_kuid(&init_user_ns, current_uid()));
18287 + snprintf(pid_buf, sizeof(pid_buf), "VS_PID=%d", current->pid);
18290 + case LINUX_REBOOT_CMD_RESTART:
18291 + argv[1] = "restart";
18294 + case LINUX_REBOOT_CMD_HALT:
18295 + argv[1] = "halt";
18298 + case LINUX_REBOOT_CMD_POWER_OFF:
18299 + argv[1] = "poweroff";
18302 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18303 + argv[1] = "swsusp";
18306 + case LINUX_REBOOT_CMD_OOM:
18311 + vxi->vx_state &= ~VXS_HELPER;
18315 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18316 + vxi->vx_state &= ~VXS_HELPER;
18317 + __wakeup_vx_info(vxi);
18318 + return (ret) ? -EPERM : 0;
18322 +long vs_reboot(unsigned int cmd, void __user *arg)
18324 + struct vx_info *vxi = current_vx_info();
18327 + vxdprintk(VXD_CBIT(misc, 5),
18328 + "vs_reboot(%p[#%d],%u)",
18329 + vxi, vxi ? vxi->vx_id : 0, cmd);
18331 + ret = vs_reboot_helper(vxi, cmd, arg);
18335 + vxi->reboot_cmd = cmd;
18336 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18338 + case LINUX_REBOOT_CMD_RESTART:
18339 + case LINUX_REBOOT_CMD_HALT:
18340 + case LINUX_REBOOT_CMD_POWER_OFF:
18341 + vx_info_kill(vxi, 0, SIGKILL);
18342 + vx_info_kill(vxi, 1, SIGKILL);
18350 +long vs_oom_action(unsigned int cmd)
18352 + struct vx_info *vxi = current_vx_info();
18355 + vxdprintk(VXD_CBIT(misc, 5),
18356 + "vs_oom_action(%p[#%d],%u)",
18357 + vxi, vxi ? vxi->vx_id : 0, cmd);
18359 + ret = vs_reboot_helper(vxi, cmd, NULL);
18363 + vxi->reboot_cmd = cmd;
18364 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18365 + vx_info_kill(vxi, 0, SIGKILL);
18366 + vx_info_kill(vxi, 1, SIGKILL);
18372 + * argv [0] = vshelper_path;
18373 + * argv [1] = action: "startup", "shutdown"
18374 + * argv [2] = context identifier
18376 + * envp [*] = type-specific parameters
18379 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18381 + char id_buf[8], cmd_buf[16];
18382 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18383 + char *envp[] = {"HOME=/", "TERM=linux",
18384 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18386 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18389 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18390 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18393 + case VSC_STARTUP:
18394 + argv[1] = "startup";
18396 + case VSC_SHUTDOWN:
18397 + argv[1] = "shutdown";
18403 + return do_vshelper(vshelper_path, argv, envp, 1);
18408 + * argv [0] = vshelper_path;
18409 + * argv [1] = action: "netup", "netdown"
18410 + * argv [2] = context identifier
18412 + * envp [*] = type-specific parameters
18415 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18417 + char id_buf[8], cmd_buf[16];
18418 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18419 + char *envp[] = {"HOME=/", "TERM=linux",
18420 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18422 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18425 + snprintf(id_buf, sizeof(id_buf), "%d", nxi->nx_id);
18426 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18430 + argv[1] = "netup";
18432 + case VSC_NETDOWN:
18433 + argv[1] = "netdown";
18439 + return do_vshelper(vshelper_path, argv, envp, 1);
18442 diff -NurpP --minimal linux-3.9.4/kernel/vserver/history.c linux-3.9.4-vs2.3.6.3/kernel/vserver/history.c
18443 --- linux-3.9.4/kernel/vserver/history.c 1970-01-01 00:00:00.000000000 +0000
18444 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/history.c 2013-05-31 14:47:11.000000000 +0000
18447 + * kernel/vserver/history.c
18449 + * Virtual Context History Backtrace
18451 + * Copyright (C) 2004-2007 Herbert Pötzl
18453 + * V0.01 basic structure
18454 + * V0.02 hash/unhash and trace
18455 + * V0.03 preemption fixes
18459 +#include <linux/module.h>
18460 +#include <asm/uaccess.h>
18462 +#include <linux/vserver/context.h>
18463 +#include <linux/vserver/debug.h>
18464 +#include <linux/vserver/debug_cmd.h>
18465 +#include <linux/vserver/history.h>
18468 +#ifdef CONFIG_VSERVER_HISTORY
18469 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18471 +#define VXH_SIZE 64
18474 +struct _vx_history {
18475 + unsigned int counter;
18477 + struct _vx_hist_entry entry[VXH_SIZE + 1];
18481 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
18483 +unsigned volatile int vxh_active = 1;
18485 +static atomic_t sequence = ATOMIC_INIT(0);
18490 + * requires disabled preemption */
18492 +struct _vx_hist_entry *vxh_advance(void *loc)
18494 + unsigned int cpu = smp_processor_id();
18495 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18496 + struct _vx_hist_entry *entry;
18497 + unsigned int index;
18499 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
18500 + entry = &hist->entry[index];
18502 + entry->seq = atomic_inc_return(&sequence);
18503 + entry->loc = loc;
18507 +EXPORT_SYMBOL_GPL(vxh_advance);
18510 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
18512 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
18515 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
18517 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
18518 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
18519 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
18520 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
18522 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
18524 + switch (e->type) {
18525 + case VXH_THROW_OOPS:
18526 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
18529 + case VXH_GET_VX_INFO:
18530 + case VXH_PUT_VX_INFO:
18531 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18533 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
18534 + VXH_VXI_ARGS(e));
18537 + case VXH_INIT_VX_INFO:
18538 + case VXH_SET_VX_INFO:
18539 + case VXH_CLR_VX_INFO:
18540 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18542 + (e->type == VXH_INIT_VX_INFO) ? "init" :
18543 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
18544 + VXH_VXI_ARGS(e), e->sc.data);
18547 + case VXH_CLAIM_VX_INFO:
18548 + case VXH_RELEASE_VX_INFO:
18549 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18551 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
18552 + VXH_VXI_ARGS(e), e->sc.data);
18555 + case VXH_ALLOC_VX_INFO:
18556 + case VXH_DEALLOC_VX_INFO:
18557 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18559 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
18560 + VXH_VXI_ARGS(e));
18563 + case VXH_HASH_VX_INFO:
18564 + case VXH_UNHASH_VX_INFO:
18565 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
18567 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
18568 + VXH_VXI_ARGS(e));
18571 + case VXH_LOC_VX_INFO:
18572 + case VXH_LOOKUP_VX_INFO:
18573 + case VXH_CREATE_VX_INFO:
18574 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
18576 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
18577 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
18578 + e->ll.arg, VXH_VXI_ARGS(e));
18583 +static void __vxh_dump_history(void)
18585 + unsigned int i, cpu;
18587 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
18588 + atomic_read(&sequence), NR_CPUS);
18590 + for (i = 0; i < VXH_SIZE; i++) {
18591 + for_each_online_cpu(cpu) {
18592 + struct _vx_history *hist =
18593 + &per_cpu(vx_history_buffer, cpu);
18594 + unsigned int index = (hist->counter - i) % VXH_SIZE;
18595 + struct _vx_hist_entry *entry = &hist->entry[index];
18597 + vxh_dump_entry(entry, cpu);
18602 +void vxh_dump_history(void)
18606 + local_irq_enable();
18608 + local_irq_disable();
18610 + __vxh_dump_history();
18614 +/* vserver syscall commands below here */
18617 +int vc_dump_history(uint32_t id)
18620 + __vxh_dump_history();
18627 +int do_read_history(struct __user _vx_hist_entry *data,
18628 + int cpu, uint32_t *index, uint32_t *count)
18630 + int pos, ret = 0;
18631 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18632 + int end = hist->counter;
18633 + int start = end - VXH_SIZE + 2;
18634 + int idx = *index;
18636 + /* special case: get current pos */
18642 + /* have we lost some data? */
18646 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
18647 + struct _vx_hist_entry *entry =
18648 + &hist->entry[idx % VXH_SIZE];
18650 + /* send entry to userspace */
18651 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
18655 + /* save new index and count */
18658 + return ret ? ret : (*index < end);
18661 +int vc_read_history(uint32_t id, void __user *data)
18663 + struct vcmd_read_history_v0 vc_data;
18666 + if (id >= NR_CPUS)
18669 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18672 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
18673 + id, &vc_data.index, &vc_data.count);
18675 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18680 +#ifdef CONFIG_COMPAT
18682 +int vc_read_history_x32(uint32_t id, void __user *data)
18684 + struct vcmd_read_history_v0_x32 vc_data;
18687 + if (id >= NR_CPUS)
18690 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18693 + ret = do_read_history((struct __user _vx_hist_entry *)
18694 + compat_ptr(vc_data.data_ptr),
18695 + id, &vc_data.index, &vc_data.count);
18697 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18702 +#endif /* CONFIG_COMPAT */
18704 diff -NurpP --minimal linux-3.9.4/kernel/vserver/inet.c linux-3.9.4-vs2.3.6.3/kernel/vserver/inet.c
18705 --- linux-3.9.4/kernel/vserver/inet.c 1970-01-01 00:00:00.000000000 +0000
18706 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/inet.c 2013-05-31 22:43:05.000000000 +0000
18709 +#include <linux/in.h>
18710 +#include <linux/inetdevice.h>
18711 +#include <linux/export.h>
18712 +#include <linux/vs_inet.h>
18713 +#include <linux/vs_inet6.h>
18714 +#include <linux/vserver/debug.h>
18715 +#include <net/route.h>
18716 +#include <net/addrconf.h>
18719 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
18723 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
18726 + struct nx_addr_v4 *ptr;
18727 + unsigned long irqflags;
18729 + spin_lock_irqsave(&nxi1->addr_lock, irqflags);
18730 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
18731 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
18736 + spin_unlock_irqrestore(&nxi1->addr_lock, irqflags);
18739 + vxdprintk(VXD_CBIT(net, 2),
18740 + "nx_v4_addr_conflict(%p,%p): %d",
18741 + nxi1, nxi2, ret);
18747 +#ifdef CONFIG_IPV6
18749 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
18753 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
18756 + struct nx_addr_v6 *ptr;
18757 + unsigned long irqflags;
18759 + spin_lock_irqsave(&nxi1->addr_lock, irqflags);
18760 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
18761 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
18766 + spin_unlock_irqrestore(&nxi1->addr_lock, irqflags);
18769 + vxdprintk(VXD_CBIT(net, 2),
18770 + "nx_v6_addr_conflict(%p,%p): %d",
18771 + nxi1, nxi2, ret);
18778 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18780 + struct in_device *in_dev;
18781 + struct in_ifaddr **ifap;
18782 + struct in_ifaddr *ifa;
18787 + in_dev = in_dev_get(dev);
18791 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
18792 + ifap = &ifa->ifa_next) {
18793 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
18798 + in_dev_put(in_dev);
18804 +#ifdef CONFIG_IPV6
18806 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18808 + struct inet6_dev *in_dev;
18809 + struct inet6_ifaddr *ifa;
18814 + in_dev = in6_dev_get(dev);
18818 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
18819 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
18820 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
18825 + in6_dev_put(in_dev);
18832 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18838 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
18840 +#ifdef CONFIG_IPV6
18842 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
18847 + vxdprintk(VXD_CBIT(net, 3),
18848 + "dev_in_nx_info(%p,%p[#%d]) = %d",
18849 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
18853 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
18854 + struct flowi4 *fl4)
18856 + struct rtable *rt;
18861 + /* FIXME: handle lback only case */
18862 + if (!NX_IPV4(nxi))
18863 + return ERR_PTR(-EPERM);
18865 + vxdprintk(VXD_CBIT(net, 4),
18866 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
18867 + nxi, nxi ? nxi->nx_id : 0,
18868 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
18870 + /* single IP is unconditional */
18871 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
18872 + (fl4->saddr == INADDR_ANY))
18873 + fl4->saddr = nxi->v4.ip[0].s_addr;
18875 + if (fl4->saddr == INADDR_ANY) {
18876 + struct nx_addr_v4 *ptr;
18877 + __be32 found = 0;
18879 + rt = __ip_route_output_key(net, fl4);
18880 + if (!IS_ERR(rt)) {
18881 + found = fl4->saddr;
18883 + vxdprintk(VXD_CBIT(net, 4),
18884 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
18885 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
18886 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
18890 + WARN_ON_ONCE(in_irq());
18891 + spin_lock_bh(&nxi->addr_lock);
18892 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
18893 + __be32 primary = ptr->ip[0].s_addr;
18894 + __be32 mask = ptr->mask.s_addr;
18895 + __be32 neta = primary & mask;
18897 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
18898 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
18899 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
18900 + NIPQUAD(mask), NIPQUAD(neta));
18901 + if ((found & mask) != neta)
18904 + fl4->saddr = primary;
18905 + rt = __ip_route_output_key(net, fl4);
18906 + vxdprintk(VXD_CBIT(net, 4),
18907 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
18908 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
18909 + if (!IS_ERR(rt)) {
18910 + found = fl4->saddr;
18912 + if (found == primary)
18913 + goto found_unlock;
18916 + /* still no source ip? */
18917 + found = ipv4_is_loopback(fl4->daddr)
18918 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
18920 + spin_unlock_bh(&nxi->addr_lock);
18922 + /* assign src ip to flow */
18923 + fl4->saddr = found;
18926 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
18927 + return ERR_PTR(-EPERM);
18930 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
18931 + if (ipv4_is_loopback(fl4->daddr))
18932 + fl4->daddr = nxi->v4_lback.s_addr;
18933 + if (ipv4_is_loopback(fl4->saddr))
18934 + fl4->saddr = nxi->v4_lback.s_addr;
18935 + } else if (ipv4_is_loopback(fl4->daddr) &&
18936 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
18937 + return ERR_PTR(-EPERM);
18942 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
18944 diff -NurpP --minimal linux-3.9.4/kernel/vserver/init.c linux-3.9.4-vs2.3.6.3/kernel/vserver/init.c
18945 --- linux-3.9.4/kernel/vserver/init.c 1970-01-01 00:00:00.000000000 +0000
18946 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/init.c 2013-05-31 14:47:11.000000000 +0000
18949 + * linux/kernel/init.c
18951 + * Virtual Server Init
18953 + * Copyright (C) 2004-2007 Herbert Pötzl
18955 + * V0.01 basic structure
18959 +#include <linux/init.h>
18961 +int vserver_register_sysctl(void);
18962 +void vserver_unregister_sysctl(void);
18965 +static int __init init_vserver(void)
18969 +#ifdef CONFIG_VSERVER_DEBUG
18970 + vserver_register_sysctl();
18976 +static void __exit exit_vserver(void)
18979 +#ifdef CONFIG_VSERVER_DEBUG
18980 + vserver_unregister_sysctl();
18985 +/* FIXME: GFP_ZONETYPES gone
18986 +long vx_slab[GFP_ZONETYPES]; */
18990 +module_init(init_vserver);
18991 +module_exit(exit_vserver);
18993 diff -NurpP --minimal linux-3.9.4/kernel/vserver/inode.c linux-3.9.4-vs2.3.6.3/kernel/vserver/inode.c
18994 --- linux-3.9.4/kernel/vserver/inode.c 1970-01-01 00:00:00.000000000 +0000
18995 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/inode.c 2013-06-01 08:26:06.000000000 +0000
18998 + * linux/kernel/vserver/inode.c
19000 + * Virtual Server: File System Support
19002 + * Copyright (C) 2004-2007 Herbert Pötzl
19004 + * V0.01 separated from vcontext V0.05
19005 + * V0.02 moved to tag (instead of xid)
19009 +#include <linux/tty.h>
19010 +#include <linux/proc_fs.h>
19011 +#include <linux/devpts_fs.h>
19012 +#include <linux/fs.h>
19013 +#include <linux/file.h>
19014 +#include <linux/mount.h>
19015 +#include <linux/parser.h>
19016 +#include <linux/namei.h>
19017 +#include <linux/vserver/inode.h>
19018 +#include <linux/vserver/inode_cmd.h>
19019 +#include <linux/vs_base.h>
19020 +#include <linux/vs_tag.h>
19022 +#include <asm/uaccess.h>
19025 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19027 + struct proc_dir_entry *entry;
19029 + if (!in || !in->i_sb)
19032 + *flags = IATTR_TAG
19033 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19034 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19035 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19036 + | (IS_COW(in) ? IATTR_COW : 0);
19037 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19039 + if (S_ISDIR(in->i_mode))
19040 + *mask |= IATTR_BARRIER;
19042 + if (IS_TAGGED(in)) {
19043 + *tag = i_tag_read(in);
19044 + *mask |= IATTR_TAG;
19047 + switch (in->i_sb->s_magic) {
19048 + case PROC_SUPER_MAGIC:
19049 + entry = PROC_I(in)->pde;
19051 + /* check for specific inodes? */
19053 + *mask |= IATTR_FLAGS;
19055 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19057 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19060 + case DEVPTS_SUPER_MAGIC:
19061 + *tag = i_tag_read(in);
19062 + *mask |= IATTR_TAG;
19071 +int vc_get_iattr(void __user *data)
19073 + struct path path;
19074 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19077 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19080 + ret = user_lpath(vc_data.name, &path);
19082 + ret = __vc_get_iattr(path.dentry->d_inode,
19083 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19089 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19094 +#ifdef CONFIG_COMPAT
19096 +int vc_get_iattr_x32(void __user *data)
19098 + struct path path;
19099 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19102 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19105 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19107 + ret = __vc_get_iattr(path.dentry->d_inode,
19108 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19114 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19119 +#endif /* CONFIG_COMPAT */
19122 +int vc_fget_iattr(uint32_t fd, void __user *data)
19124 + struct file *filp;
19125 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19128 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19132 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19135 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19136 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19140 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19146 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19148 + struct inode *in = de->d_inode;
19149 + int error = 0, is_proc = 0, has_tag = 0;
19150 + struct iattr attr = { 0 };
19152 + if (!in || !in->i_sb)
19155 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19156 + if ((*mask & IATTR_FLAGS) && !is_proc)
19159 + has_tag = IS_TAGGED(in) ||
19160 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19161 + if ((*mask & IATTR_TAG) && !has_tag)
19164 + mutex_lock(&in->i_mutex);
19165 + if (*mask & IATTR_TAG) {
19166 + attr.ia_tag = make_ktag(&init_user_ns, *tag);
19167 + attr.ia_valid |= ATTR_TAG;
19170 + if (*mask & IATTR_FLAGS) {
19171 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19172 + unsigned int iflags = PROC_I(in)->vx_flags;
19174 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19175 + | (*flags & IATTR_FLAGS);
19176 + PROC_I(in)->vx_flags = iflags;
19178 + entry->vx_flags = iflags;
19181 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19182 + IATTR_BARRIER | IATTR_COW)) {
19183 + int iflags = in->i_flags;
19184 + int vflags = in->i_vflags;
19186 + if (*mask & IATTR_IMMUTABLE) {
19187 + if (*flags & IATTR_IMMUTABLE)
19188 + iflags |= S_IMMUTABLE;
19190 + iflags &= ~S_IMMUTABLE;
19192 + if (*mask & IATTR_IXUNLINK) {
19193 + if (*flags & IATTR_IXUNLINK)
19194 + iflags |= S_IXUNLINK;
19196 + iflags &= ~S_IXUNLINK;
19198 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19199 + if (*flags & IATTR_BARRIER)
19200 + vflags |= V_BARRIER;
19202 + vflags &= ~V_BARRIER;
19204 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19205 + if (*flags & IATTR_COW)
19208 + vflags &= ~V_COW;
19210 + if (in->i_op && in->i_op->sync_flags) {
19211 + error = in->i_op->sync_flags(in, iflags, vflags);
19217 + if (attr.ia_valid) {
19218 + if (in->i_op && in->i_op->setattr)
19219 + error = in->i_op->setattr(de, &attr);
19221 + error = inode_change_ok(in, &attr);
19223 + setattr_copy(in, &attr);
19224 + mark_inode_dirty(in);
19230 + mutex_unlock(&in->i_mutex);
19234 +int vc_set_iattr(void __user *data)
19236 + struct path path;
19237 + struct vcmd_ctx_iattr_v1 vc_data;
19240 + if (!capable(CAP_LINUX_IMMUTABLE))
19242 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19245 + ret = user_lpath(vc_data.name, &path);
19247 + ret = __vc_set_iattr(path.dentry,
19248 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19252 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19257 +#ifdef CONFIG_COMPAT
19259 +int vc_set_iattr_x32(void __user *data)
19261 + struct path path;
19262 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19265 + if (!capable(CAP_LINUX_IMMUTABLE))
19267 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19270 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19272 + ret = __vc_set_iattr(path.dentry,
19273 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19277 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19282 +#endif /* CONFIG_COMPAT */
19284 +int vc_fset_iattr(uint32_t fd, void __user *data)
19286 + struct file *filp;
19287 + struct vcmd_ctx_fiattr_v0 vc_data;
19290 + if (!capable(CAP_LINUX_IMMUTABLE))
19292 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19296 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19299 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19300 + &vc_data.flags, &vc_data.mask);
19304 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19310 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19312 +static match_table_t tokens = {
19313 + {Opt_notagcheck, "notagcheck"},
19314 +#ifdef CONFIG_PROPAGATE
19315 + {Opt_notag, "notag"},
19316 + {Opt_tag, "tag"},
19317 + {Opt_tagid, "tagid=%u"},
19323 +static void __dx_parse_remove(char *string, char *opt)
19325 + char *p = strstr(string, opt);
19329 + while (*q != '\0' && *q != ',')
19338 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19339 + unsigned long *flags)
19342 + substring_t args[MAX_OPT_ARGS];
19344 + char *s, *p, *opts;
19345 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19351 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19356 + while ((p = strsep(&opts, ",")) != NULL) {
19357 + token = match_token(p, tokens, args);
19360 +#ifdef CONFIG_PROPAGATE
19365 + __dx_parse_remove(s, "tag");
19366 + *mnt_flags |= MNT_TAGID;
19367 + set |= MNT_TAGID;
19371 + __dx_parse_remove(s, "notag");
19372 + *mnt_flags |= MNT_NOTAG;
19373 + set |= MNT_NOTAG;
19376 + if (tag && !match_int(args, &option))
19379 + __dx_parse_remove(s, "tagid");
19380 + *mnt_flags |= MNT_TAGID;
19381 + set |= MNT_TAGID;
19383 +#endif /* CONFIG_PROPAGATE */
19384 + case Opt_notagcheck:
19386 + __dx_parse_remove(s, "notagcheck");
19387 + *flags |= MS_NOTAGCHECK;
19388 + set |= MS_NOTAGCHECK;
19391 + vxdprintk(VXD_CBIT(tag, 7),
19392 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19393 + p, token, option);
19396 + strcpy(string, s);
19401 +#ifdef CONFIG_PROPAGATE
19403 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19405 + tag_t new_tag = 0;
19406 + struct vfsmount *mnt;
19411 + mnt = nd->path.mnt;
19415 + propagate = (mnt->mnt_flags & MNT_TAGID);
19417 + new_tag = mnt->mnt_tag;
19419 + vxdprintk(VXD_CBIT(tag, 7),
19420 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19421 + inode, inode->i_ino, inode->i_tag,
19422 + new_tag, (propagate) ? 1 : 0);
19425 + i_tag_write(inode, new_tag);
19428 +#include <linux/module.h>
19430 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19432 +#endif /* CONFIG_PROPAGATE */
19434 diff -NurpP --minimal linux-3.9.4/kernel/vserver/limit.c linux-3.9.4-vs2.3.6.3/kernel/vserver/limit.c
19435 --- linux-3.9.4/kernel/vserver/limit.c 1970-01-01 00:00:00.000000000 +0000
19436 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/limit.c 2013-05-31 14:47:11.000000000 +0000
19439 + * linux/kernel/vserver/limit.c
19441 + * Virtual Server: Context Limits
19443 + * Copyright (C) 2004-2010 Herbert Pötzl
19445 + * V0.01 broken out from vcontext V0.05
19446 + * V0.02 changed vcmds to vxi arg
19447 + * V0.03 added memory cgroup support
19451 +#include <linux/sched.h>
19452 +#include <linux/module.h>
19453 +#include <linux/memcontrol.h>
19454 +#include <linux/res_counter.h>
19455 +#include <linux/vs_limit.h>
19456 +#include <linux/vserver/limit.h>
19457 +#include <linux/vserver/limit_cmd.h>
19459 +#include <asm/uaccess.h>
19462 +const char *vlimit_name[NUM_LIMITS] = {
19463 + [RLIMIT_CPU] = "CPU",
19464 + [RLIMIT_NPROC] = "NPROC",
19465 + [RLIMIT_NOFILE] = "NOFILE",
19466 + [RLIMIT_LOCKS] = "LOCKS",
19467 + [RLIMIT_SIGPENDING] = "SIGP",
19468 + [RLIMIT_MSGQUEUE] = "MSGQ",
19470 + [VLIMIT_NSOCK] = "NSOCK",
19471 + [VLIMIT_OPENFD] = "OPENFD",
19472 + [VLIMIT_SHMEM] = "SHMEM",
19473 + [VLIMIT_DENTRY] = "DENTRY",
19476 +EXPORT_SYMBOL_GPL(vlimit_name);
19478 +#define MASK_ENTRY(x) (1 << (x))
19480 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
19483 + , /* softlimit */
19486 + MASK_ENTRY( RLIMIT_NPROC ) |
19487 + MASK_ENTRY( RLIMIT_NOFILE ) |
19488 + MASK_ENTRY( RLIMIT_LOCKS ) |
19489 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
19491 + MASK_ENTRY( VLIMIT_NSOCK ) |
19492 + MASK_ENTRY( VLIMIT_OPENFD ) |
19493 + MASK_ENTRY( VLIMIT_SHMEM ) |
19494 + MASK_ENTRY( VLIMIT_DENTRY ) |
19497 + /* accounting only */
19498 +uint32_t account_mask =
19499 + MASK_ENTRY( VLIMIT_SEMARY ) |
19500 + MASK_ENTRY( VLIMIT_NSEMS ) |
19501 + MASK_ENTRY( VLIMIT_MAPPED ) |
19505 +static int is_valid_vlimit(int id)
19507 + uint32_t mask = vlimit_mask.minimum |
19508 + vlimit_mask.softlimit | vlimit_mask.maximum;
19509 + return mask & (1 << id);
19512 +static int is_accounted_vlimit(int id)
19514 + if (is_valid_vlimit(id))
19516 + return account_mask & (1 << id);
19520 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
19522 + rlim_t limit = __rlim_soft(&vxi->limit, id);
19523 + return VX_VLIM(limit);
19526 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
19528 + rlim_t limit = __rlim_hard(&vxi->limit, id);
19529 + return VX_VLIM(limit);
19532 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
19533 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
19535 + if (!is_valid_vlimit(id))
19539 + *minimum = CRLIM_UNSET;
19541 + *softlimit = vc_get_soft(vxi, id);
19543 + *maximum = vc_get_hard(vxi, id);
19547 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
19549 + struct vcmd_ctx_rlimit_v0 vc_data;
19552 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19555 + ret = do_get_rlimit(vxi, vc_data.id,
19556 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19560 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19565 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
19566 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
19568 + if (!is_valid_vlimit(id))
19571 + if (maximum != CRLIM_KEEP)
19572 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
19573 + if (softlimit != CRLIM_KEEP)
19574 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
19576 + /* clamp soft limit */
19577 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
19578 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
19583 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
19585 + struct vcmd_ctx_rlimit_v0 vc_data;
19587 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19590 + return do_set_rlimit(vxi, vc_data.id,
19591 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19594 +#ifdef CONFIG_IA32_EMULATION
19596 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
19598 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19600 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19603 + return do_set_rlimit(vxi, vc_data.id,
19604 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19607 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
19609 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19612 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19615 + ret = do_get_rlimit(vxi, vc_data.id,
19616 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19620 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19625 +#endif /* CONFIG_IA32_EMULATION */
19628 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
19630 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
19636 +static inline void vx_reset_hits(struct _vx_limit *limit)
19640 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19641 + atomic_set(&__rlim_lhit(limit, lim), 0);
19645 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
19647 + vx_reset_hits(&vxi->limit);
19651 +static inline void vx_reset_minmax(struct _vx_limit *limit)
19656 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19657 + value = __rlim_get(limit, lim);
19658 + __rlim_rmax(limit, lim) = value;
19659 + __rlim_rmin(limit, lim) = value;
19663 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
19665 + vx_reset_minmax(&vxi->limit);
19670 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
19672 + struct vcmd_rlimit_stat_v0 vc_data;
19673 + struct _vx_limit *limit = &vxi->limit;
19676 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19680 + if (!is_accounted_vlimit(id))
19683 + vx_limit_fixup(limit, id);
19684 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
19685 + vc_data.value = __rlim_get(limit, id);
19686 + vc_data.minimum = __rlim_rmin(limit, id);
19687 + vc_data.maximum = __rlim_rmax(limit, id);
19689 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19695 +void vx_vsi_meminfo(struct sysinfo *val)
19697 +#ifdef CONFIG_MEMCG
19698 + struct mem_cgroup *mcg;
19699 + u64 res_limit, res_usage;
19702 + mcg = mem_cgroup_from_task(current);
19703 + rcu_read_unlock();
19707 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19708 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19710 + if (res_limit != RESOURCE_MAX)
19711 + val->totalram = (res_limit >> PAGE_SHIFT);
19712 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
19713 + val->bufferram = 0;
19714 + val->totalhigh = 0;
19715 + val->freehigh = 0;
19717 +#endif /* CONFIG_MEMCG */
19721 +void vx_vsi_swapinfo(struct sysinfo *val)
19723 +#ifdef CONFIG_MEMCG
19724 +#ifdef CONFIG_MEMCG_SWAP
19725 + struct mem_cgroup *mcg;
19726 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
19727 + s64 swap_limit, swap_usage;
19730 + mcg = mem_cgroup_from_task(current);
19731 + rcu_read_unlock();
19735 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19736 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19737 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
19738 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
19740 + /* memory unlimited */
19741 + if (res_limit == RESOURCE_MAX)
19744 + swap_limit = memsw_limit - res_limit;
19745 + /* we have a swap limit? */
19746 + if (memsw_limit != RESOURCE_MAX)
19747 + val->totalswap = swap_limit >> PAGE_SHIFT;
19749 + /* calculate swap part */
19750 + swap_usage = (memsw_usage > res_usage) ?
19751 + memsw_usage - res_usage : 0;
19753 + /* total shown minus usage gives free swap */
19754 + val->freeswap = (swap_usage < swap_limit) ?
19755 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
19757 +#else /* !CONFIG_MEMCG_SWAP */
19758 + val->totalswap = 0;
19759 + val->freeswap = 0;
19760 +#endif /* !CONFIG_MEMCG_SWAP */
19761 +#endif /* CONFIG_MEMCG */
19765 +long vx_vsi_cached(struct sysinfo *val)
19768 +#ifdef CONFIG_MEMCG
19769 + struct mem_cgroup *mcg;
19772 + mcg = mem_cgroup_from_task(current);
19773 + rcu_read_unlock();
19777 + cache = mem_cgroup_stat_read_cache(mcg);
19783 diff -NurpP --minimal linux-3.9.4/kernel/vserver/limit_init.h linux-3.9.4-vs2.3.6.3/kernel/vserver/limit_init.h
19784 --- linux-3.9.4/kernel/vserver/limit_init.h 1970-01-01 00:00:00.000000000 +0000
19785 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/limit_init.h 2013-05-31 14:47:11.000000000 +0000
19789 +static inline void vx_info_init_limit(struct _vx_limit *limit)
19793 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19794 + __rlim_soft(limit, lim) = RLIM_INFINITY;
19795 + __rlim_hard(limit, lim) = RLIM_INFINITY;
19796 + __rlim_set(limit, lim, 0);
19797 + atomic_set(&__rlim_lhit(limit, lim), 0);
19798 + __rlim_rmin(limit, lim) = 0;
19799 + __rlim_rmax(limit, lim) = 0;
19803 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
19808 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19809 + if ((1 << lim) & VLIM_NOCHECK)
19811 + value = __rlim_get(limit, lim);
19812 + vxwprintk_xid(value,
19813 + "!!! limit: %p[%s,%d] = %ld on exit.",
19814 + limit, vlimit_name[lim], lim, (long)value);
19818 diff -NurpP --minimal linux-3.9.4/kernel/vserver/limit_proc.h linux-3.9.4-vs2.3.6.3/kernel/vserver/limit_proc.h
19819 --- linux-3.9.4/kernel/vserver/limit_proc.h 1970-01-01 00:00:00.000000000 +0000
19820 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/limit_proc.h 2013-05-31 14:47:11.000000000 +0000
19822 +#ifndef _VX_LIMIT_PROC_H
19823 +#define _VX_LIMIT_PROC_H
19825 +#include <linux/vserver/limit_int.h>
19828 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
19829 +#define VX_LIMIT_TOP \
19830 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
19832 +#define VX_LIMIT_ARG(r) \
19833 + (unsigned long)__rlim_get(limit, r), \
19834 + (unsigned long)__rlim_rmin(limit, r), \
19835 + (unsigned long)__rlim_rmax(limit, r), \
19836 + VX_VLIM(__rlim_soft(limit, r)), \
19837 + VX_VLIM(__rlim_hard(limit, r)), \
19838 + atomic_read(&__rlim_lhit(limit, r))
19840 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
19842 + vx_limit_fixup(limit, -1);
19843 + return sprintf(buffer, VX_LIMIT_TOP
19844 + "PROC" VX_LIMIT_FMT
19845 + "VM" VX_LIMIT_FMT
19846 + "VML" VX_LIMIT_FMT
19847 + "RSS" VX_LIMIT_FMT
19848 + "ANON" VX_LIMIT_FMT
19849 + "RMAP" VX_LIMIT_FMT
19850 + "FILES" VX_LIMIT_FMT
19851 + "OFD" VX_LIMIT_FMT
19852 + "LOCKS" VX_LIMIT_FMT
19853 + "SOCK" VX_LIMIT_FMT
19854 + "MSGQ" VX_LIMIT_FMT
19855 + "SHM" VX_LIMIT_FMT
19856 + "SEMA" VX_LIMIT_FMT
19857 + "SEMS" VX_LIMIT_FMT
19858 + "DENT" VX_LIMIT_FMT,
19859 + VX_LIMIT_ARG(RLIMIT_NPROC),
19860 + VX_LIMIT_ARG(RLIMIT_AS),
19861 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
19862 + VX_LIMIT_ARG(RLIMIT_RSS),
19863 + VX_LIMIT_ARG(VLIMIT_ANON),
19864 + VX_LIMIT_ARG(VLIMIT_MAPPED),
19865 + VX_LIMIT_ARG(RLIMIT_NOFILE),
19866 + VX_LIMIT_ARG(VLIMIT_OPENFD),
19867 + VX_LIMIT_ARG(RLIMIT_LOCKS),
19868 + VX_LIMIT_ARG(VLIMIT_NSOCK),
19869 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
19870 + VX_LIMIT_ARG(VLIMIT_SHMEM),
19871 + VX_LIMIT_ARG(VLIMIT_SEMARY),
19872 + VX_LIMIT_ARG(VLIMIT_NSEMS),
19873 + VX_LIMIT_ARG(VLIMIT_DENTRY));
19876 +#endif /* _VX_LIMIT_PROC_H */
19879 diff -NurpP --minimal linux-3.9.4/kernel/vserver/network.c linux-3.9.4-vs2.3.6.3/kernel/vserver/network.c
19880 --- linux-3.9.4/kernel/vserver/network.c 1970-01-01 00:00:00.000000000 +0000
19881 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/network.c 2013-05-31 14:47:11.000000000 +0000
19884 + * linux/kernel/vserver/network.c
19886 + * Virtual Server: Network Support
19888 + * Copyright (C) 2003-2007 Herbert Pötzl
19890 + * V0.01 broken out from vcontext V0.05
19891 + * V0.02 cleaned up implementation
19892 + * V0.03 added equiv nx commands
19893 + * V0.04 switch to RCU based hash
19894 + * V0.05 and back to locking again
19895 + * V0.06 changed vcmds to nxi arg
19896 + * V0.07 have __create claim() the nxi
19900 +#include <linux/err.h>
19901 +#include <linux/slab.h>
19902 +#include <linux/rcupdate.h>
19903 +#include <net/ipv6.h>
19905 +#include <linux/vs_network.h>
19906 +#include <linux/vs_pid.h>
19907 +#include <linux/vserver/network_cmd.h>
19910 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
19911 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
19913 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
19914 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
19917 +static int __init init_network(void)
19919 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
19920 + sizeof(struct nx_addr_v4), 0,
19921 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19922 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
19923 + sizeof(struct nx_addr_v6), 0,
19924 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19929 +/* __alloc_nx_addr_v4() */
19931 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
19933 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
19934 + nx_addr_v4_cachep, GFP_KERNEL);
19936 + if (!IS_ERR(nxa))
19937 + memset(nxa, 0, sizeof(*nxa));
19941 +/* __dealloc_nx_addr_v4() */
19943 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
19945 + kmem_cache_free(nx_addr_v4_cachep, nxa);
19948 +/* __dealloc_nx_addr_v4_all() */
19950 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
19953 + struct nx_addr_v4 *next = nxa->next;
19955 + __dealloc_nx_addr_v4(nxa);
19961 +#ifdef CONFIG_IPV6
19963 +/* __alloc_nx_addr_v6() */
19965 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
19967 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
19968 + nx_addr_v6_cachep, GFP_KERNEL);
19970 + if (!IS_ERR(nxa))
19971 + memset(nxa, 0, sizeof(*nxa));
19975 +/* __dealloc_nx_addr_v6() */
19977 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
19979 + kmem_cache_free(nx_addr_v6_cachep, nxa);
19982 +/* __dealloc_nx_addr_v6_all() */
19984 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
19987 + struct nx_addr_v6 *next = nxa->next;
19989 + __dealloc_nx_addr_v6(nxa);
19994 +#endif /* CONFIG_IPV6 */
19996 +/* __alloc_nx_info()
19998 + * allocate an initialized nx_info struct
19999 + * doesn't make it visible (hash) */
20001 +static struct nx_info *__alloc_nx_info(nid_t nid)
20003 + struct nx_info *new = NULL;
20005 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20007 + /* would this benefit from a slab cache? */
20008 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20012 + memset(new, 0, sizeof(struct nx_info));
20013 + new->nx_id = nid;
20014 + INIT_HLIST_NODE(&new->nx_hlist);
20015 + atomic_set(&new->nx_usecnt, 0);
20016 + atomic_set(&new->nx_tasks, 0);
20017 + spin_lock_init(&new->addr_lock);
20018 + new->nx_state = 0;
20020 + new->nx_flags = NXF_INIT_SET;
20022 + /* rest of init goes here */
20024 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20025 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20027 + vxdprintk(VXD_CBIT(nid, 0),
20028 + "alloc_nx_info(%d) = %p", nid, new);
20029 + atomic_inc(&nx_global_ctotal);
20033 +/* __dealloc_nx_info()
20035 + * final disposal of nx_info */
20037 +static void __dealloc_nx_info(struct nx_info *nxi)
20039 + vxdprintk(VXD_CBIT(nid, 0),
20040 + "dealloc_nx_info(%p)", nxi);
20042 + nxi->nx_hlist.next = LIST_POISON1;
20045 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20046 + BUG_ON(atomic_read(&nxi->nx_tasks));
20048 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20049 +#ifdef CONFIG_IPV6
20050 + __dealloc_nx_addr_v6_all(nxi->v6.next);
20053 + nxi->nx_state |= NXS_RELEASED;
20055 + atomic_dec(&nx_global_ctotal);
20058 +static void __shutdown_nx_info(struct nx_info *nxi)
20060 + nxi->nx_state |= NXS_SHUTDOWN;
20061 + vs_net_change(nxi, VSC_NETDOWN);
20064 +/* exported stuff */
20066 +void free_nx_info(struct nx_info *nxi)
20068 + /* context shutdown is mandatory */
20069 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20071 + /* context must not be hashed */
20072 + BUG_ON(nxi->nx_state & NXS_HASHED);
20074 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20075 + BUG_ON(atomic_read(&nxi->nx_tasks));
20077 + __dealloc_nx_info(nxi);
20081 +void __nx_set_lback(struct nx_info *nxi)
20083 + int nid = nxi->nx_id;
20084 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20086 + nxi->v4_lback.s_addr = lback;
20089 +extern int __nx_inet_add_lback(__be32 addr);
20090 +extern int __nx_inet_del_lback(__be32 addr);
20093 +/* hash table for nx_info hash */
20095 +#define NX_HASH_SIZE 13
20097 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20099 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20102 +static inline unsigned int __hashval(nid_t nid)
20104 + return (nid % NX_HASH_SIZE);
20109 +/* __hash_nx_info()
20111 + * add the nxi to the global hash table
20112 + * requires the hash_lock to be held */
20114 +static inline void __hash_nx_info(struct nx_info *nxi)
20116 + struct hlist_head *head;
20118 + vxd_assert_lock(&nx_info_hash_lock);
20119 + vxdprintk(VXD_CBIT(nid, 4),
20120 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20122 + /* context must not be hashed */
20123 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20125 + nxi->nx_state |= NXS_HASHED;
20126 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20127 + hlist_add_head(&nxi->nx_hlist, head);
20128 + atomic_inc(&nx_global_cactive);
20131 +/* __unhash_nx_info()
20133 + * remove the nxi from the global hash table
20134 + * requires the hash_lock to be held */
20136 +static inline void __unhash_nx_info(struct nx_info *nxi)
20138 + vxd_assert_lock(&nx_info_hash_lock);
20139 + vxdprintk(VXD_CBIT(nid, 4),
20140 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20141 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20143 + /* context must be hashed */
20144 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20145 + /* but without tasks */
20146 + BUG_ON(atomic_read(&nxi->nx_tasks));
20148 + nxi->nx_state &= ~NXS_HASHED;
20149 + hlist_del(&nxi->nx_hlist);
20150 + atomic_dec(&nx_global_cactive);
20154 +/* __lookup_nx_info()
20156 + * requires the hash_lock to be held
20157 + * doesn't increment the nx_refcnt */
20159 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20161 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20162 + struct hlist_node *pos;
20163 + struct nx_info *nxi;
20165 + vxd_assert_lock(&nx_info_hash_lock);
20166 + hlist_for_each(pos, head) {
20167 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20169 + if (nxi->nx_id == nid)
20174 + vxdprintk(VXD_CBIT(nid, 0),
20175 + "__lookup_nx_info(#%u): %p[#%u]",
20176 + nid, nxi, nxi ? nxi->nx_id : 0);
20181 +/* __create_nx_info()
20183 + * create the requested context
20184 + * get(), claim() and hash it */
20186 +static struct nx_info *__create_nx_info(int id)
20188 + struct nx_info *new, *nxi = NULL;
20190 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20192 + if (!(new = __alloc_nx_info(id)))
20193 + return ERR_PTR(-ENOMEM);
20195 + /* required to make dynamic xids unique */
20196 + spin_lock(&nx_info_hash_lock);
20198 + /* static context requested */
20199 + if ((nxi = __lookup_nx_info(id))) {
20200 + vxdprintk(VXD_CBIT(nid, 0),
20201 + "create_nx_info(%d) = %p (already there)", id, nxi);
20202 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20203 + nxi = ERR_PTR(-EBUSY);
20205 + nxi = ERR_PTR(-EEXIST);
20208 + /* new context */
20209 + vxdprintk(VXD_CBIT(nid, 0),
20210 + "create_nx_info(%d) = %p (new)", id, new);
20211 + claim_nx_info(new, NULL);
20212 + __nx_set_lback(new);
20213 + __hash_nx_info(get_nx_info(new));
20214 + nxi = new, new = NULL;
20217 + spin_unlock(&nx_info_hash_lock);
20219 + __dealloc_nx_info(new);
20225 +/* exported stuff */
20228 +void unhash_nx_info(struct nx_info *nxi)
20230 + __shutdown_nx_info(nxi);
20231 + spin_lock(&nx_info_hash_lock);
20232 + __unhash_nx_info(nxi);
20233 + spin_unlock(&nx_info_hash_lock);
20236 +/* lookup_nx_info()
20238 + * search for a nx_info and get() it
20239 + * negative id means current */
20241 +struct nx_info *lookup_nx_info(int id)
20243 + struct nx_info *nxi = NULL;
20246 + nxi = get_nx_info(current_nx_info());
20247 + } else if (id > 1) {
20248 + spin_lock(&nx_info_hash_lock);
20249 + nxi = get_nx_info(__lookup_nx_info(id));
20250 + spin_unlock(&nx_info_hash_lock);
20255 +/* nid_is_hashed()
20257 + * verify that nid is still hashed */
20259 +int nid_is_hashed(nid_t nid)
20263 + spin_lock(&nx_info_hash_lock);
20264 + hashed = (__lookup_nx_info(nid) != NULL);
20265 + spin_unlock(&nx_info_hash_lock);
20270 +#ifdef CONFIG_PROC_FS
20274 + * get a subset of hashed nids for proc
20275 + * assumes size is at least one */
20277 +int get_nid_list(int index, unsigned int *nids, int size)
20279 + int hindex, nr_nids = 0;
20281 + /* only show current and children */
20282 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20285 + nids[nr_nids] = nx_current_nid();
20289 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20290 + struct hlist_head *head = &nx_info_hash[hindex];
20291 + struct hlist_node *pos;
20293 + spin_lock(&nx_info_hash_lock);
20294 + hlist_for_each(pos, head) {
20295 + struct nx_info *nxi;
20300 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20301 + nids[nr_nids] = nxi->nx_id;
20302 + if (++nr_nids >= size) {
20303 + spin_unlock(&nx_info_hash_lock);
20307 + /* keep the lock time short */
20308 + spin_unlock(&nx_info_hash_lock);
20317 + * migrate task to new network
20318 + * gets nxi, puts old_nxi on change
20321 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20323 + struct nx_info *old_nxi;
20329 + vxdprintk(VXD_CBIT(nid, 5),
20330 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20331 + p, nxi, nxi->nx_id,
20332 + atomic_read(&nxi->nx_usecnt),
20333 + atomic_read(&nxi->nx_tasks));
20335 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20336 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20339 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20342 + /* maybe disallow this completely? */
20343 + old_nxi = task_get_nx_info(p);
20344 + if (old_nxi == nxi)
20349 + clr_nx_info(&p->nx_info);
20350 + claim_nx_info(nxi, p);
20351 + set_nx_info(&p->nx_info, nxi);
20352 + p->nid = nxi->nx_id;
20355 + vxdprintk(VXD_CBIT(nid, 5),
20356 + "moved task %p into nxi:%p[#%d]",
20357 + p, nxi, nxi->nx_id);
20360 + release_nx_info(old_nxi, p);
20363 + put_nx_info(old_nxi);
20368 +void nx_set_persistent(struct nx_info *nxi)
20370 + vxdprintk(VXD_CBIT(nid, 6),
20371 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20373 + get_nx_info(nxi);
20374 + claim_nx_info(nxi, NULL);
20377 +void nx_clear_persistent(struct nx_info *nxi)
20379 + vxdprintk(VXD_CBIT(nid, 6),
20380 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20382 + release_nx_info(nxi, NULL);
20383 + put_nx_info(nxi);
20386 +void nx_update_persistent(struct nx_info *nxi)
20388 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20389 + nx_set_persistent(nxi);
20391 + nx_clear_persistent(nxi);
20394 +/* vserver syscall commands below here */
20396 +/* taks nid and nx_info functions */
20398 +#include <asm/uaccess.h>
20401 +int vc_task_nid(uint32_t id)
20406 + struct task_struct *tsk;
20409 + tsk = find_task_by_real_pid(id);
20410 + nid = (tsk) ? tsk->nid : -ESRCH;
20411 + rcu_read_unlock();
20413 + nid = nx_current_nid();
20418 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20420 + struct vcmd_nx_info_v0 vc_data;
20422 + vc_data.nid = nxi->nx_id;
20424 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20430 +/* network functions */
20432 +int vc_net_create(uint32_t nid, void __user *data)
20434 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
20435 + struct nx_info *new_nxi;
20438 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20441 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
20444 + new_nxi = __create_nx_info(nid);
20445 + if (IS_ERR(new_nxi))
20446 + return PTR_ERR(new_nxi);
20448 + /* initial flags */
20449 + new_nxi->nx_flags = vc_data.flagword;
20452 + if (vs_net_change(new_nxi, VSC_NETUP))
20455 + ret = nx_migrate_task(current, new_nxi);
20459 + /* return context id on success */
20460 + ret = new_nxi->nx_id;
20462 + /* get a reference for persistent contexts */
20463 + if ((vc_data.flagword & NXF_PERSISTENT))
20464 + nx_set_persistent(new_nxi);
20466 + release_nx_info(new_nxi, NULL);
20467 + put_nx_info(new_nxi);
20472 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
20474 + return nx_migrate_task(current, nxi);
20479 +struct nx_addr_v4 *__find_v4_addr(struct nx_info *nxi,
20480 + __be32 ip, __be32 ip2, __be32 mask, uint16_t type, uint16_t flags,
20481 + struct nx_addr_v4 **prev)
20483 + struct nx_addr_v4 *nxa = &nxi->v4;
20485 + for (; nxa; nxa = nxa->next) {
20486 + if ((nxa->ip[0].s_addr == ip) &&
20487 + (nxa->ip[1].s_addr == ip2) &&
20488 + (nxa->mask.s_addr == mask) &&
20489 + (nxa->type == type) &&
20490 + (nxa->flags == flags))
20493 + /* save previous entry */
20500 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20501 + uint16_t type, uint16_t flags)
20503 + struct nx_addr_v4 *nxa = NULL;
20504 + struct nx_addr_v4 *new = __alloc_nx_addr_v4();
20505 + unsigned long irqflags;
20506 + int ret = -EEXIST;
20509 + return PTR_ERR(new);
20511 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20512 + if (__find_v4_addr(nxi, ip, ip2, mask, type, flags, &nxa))
20515 + if (NX_IPV4(nxi)) {
20520 + /* remove single ip for ip list */
20521 + nxi->nx_flags &= ~NXF_SINGLE_IP;
20524 + nxa->ip[0].s_addr = ip;
20525 + nxa->ip[1].s_addr = ip2;
20526 + nxa->mask.s_addr = mask;
20527 + nxa->type = type;
20528 + nxa->flags = flags;
20531 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20533 + __dealloc_nx_addr_v4(new);
20537 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20538 + uint16_t type, uint16_t flags)
20540 + struct nx_addr_v4 *nxa = NULL;
20541 + struct nx_addr_v4 *old = NULL;
20542 + unsigned long irqflags;
20545 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20547 + case NXA_TYPE_ADDR:
20548 + old = __find_v4_addr(nxi, ip, ip2, mask, type, flags, &nxa);
20551 + nxa->next = old->next;
20552 + old->next = NULL;
20558 + old->next = NULL;
20560 + memset(old, 0, sizeof(*old));
20568 + case NXA_TYPE_ANY:
20571 + memset(nxa, 0, sizeof(*nxa));
20577 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20578 + __dealloc_nx_addr_v4_all(old);
20583 +int vc_net_add(struct nx_info *nxi, void __user *data)
20585 + struct vcmd_net_addr_v0 vc_data;
20586 + int index, ret = 0;
20588 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20591 + switch (vc_data.type) {
20592 + case NXA_TYPE_IPV4:
20593 + if ((vc_data.count < 1) || (vc_data.count > 4))
20597 + while (index < vc_data.count) {
20598 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
20599 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
20607 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
20608 + nxi->v4_bcast = vc_data.ip[0];
20612 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
20613 + nxi->v4_lback = vc_data.ip[0];
20624 +int vc_net_remove(struct nx_info *nxi, void __user *data)
20626 + struct vcmd_net_addr_v0 vc_data;
20628 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20631 + switch (vc_data.type) {
20632 + case NXA_TYPE_ANY:
20633 + return do_remove_v4_addr(nxi, 0, 0, 0, vc_data.type, 0);
20641 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
20643 + struct vcmd_net_addr_ipv4_v1 vc_data;
20645 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20648 + switch (vc_data.type) {
20649 + case NXA_TYPE_ADDR:
20650 + case NXA_TYPE_MASK:
20651 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
20652 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20654 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20655 + nxi->v4_bcast = vc_data.ip;
20658 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20659 + nxi->v4_lback = vc_data.ip;
20668 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
20670 + struct vcmd_net_addr_ipv4_v2 vc_data;
20672 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20675 + switch (vc_data.type) {
20676 + case NXA_TYPE_ADDR:
20677 + case NXA_TYPE_MASK:
20678 + case NXA_TYPE_RANGE:
20679 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20680 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20682 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20683 + nxi->v4_bcast = vc_data.ip;
20686 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20687 + nxi->v4_lback = vc_data.ip;
20696 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
20698 + struct vcmd_net_addr_ipv4_v1 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, 0,
20704 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20707 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
20709 + struct vcmd_net_addr_ipv4_v2 vc_data;
20711 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20714 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20715 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20718 +#ifdef CONFIG_IPV6
20721 +struct nx_addr_v6 *__find_v6_addr(struct nx_info *nxi,
20722 + struct in6_addr *ip, struct in6_addr *mask,
20723 + uint32_t prefix, uint16_t type, uint16_t flags,
20724 + struct nx_addr_v6 **prev)
20726 + struct nx_addr_v6 *nxa = &nxi->v6;
20728 + for (; nxa; nxa = nxa->next) {
20729 + if (ipv6_addr_equal(&nxa->ip, ip) &&
20730 + ipv6_addr_equal(&nxa->mask, mask) &&
20731 + (nxa->prefix == prefix) &&
20732 + (nxa->type == type) &&
20733 + (nxa->flags == flags))
20736 + /* save previous entry */
20744 +int do_add_v6_addr(struct nx_info *nxi,
20745 + struct in6_addr *ip, struct in6_addr *mask,
20746 + uint32_t prefix, uint16_t type, uint16_t flags)
20748 + struct nx_addr_v6 *nxa = NULL;
20749 + struct nx_addr_v6 *new = __alloc_nx_addr_v6();
20750 + unsigned long irqflags;
20751 + int ret = -EEXIST;
20754 + return PTR_ERR(new);
20756 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20757 + if (__find_v6_addr(nxi, ip, mask, prefix, type, flags, &nxa))
20760 + if (NX_IPV6(nxi)) {
20767 + nxa->mask = *mask;
20768 + nxa->prefix = prefix;
20769 + nxa->type = type;
20770 + nxa->flags = flags;
20773 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20775 + __dealloc_nx_addr_v6(new);
20779 +int do_remove_v6_addr(struct nx_info *nxi,
20780 + struct in6_addr *ip, struct in6_addr *mask,
20781 + uint32_t prefix, uint16_t type, uint16_t flags)
20783 + struct nx_addr_v6 *nxa = NULL;
20784 + struct nx_addr_v6 *old = NULL;
20785 + unsigned long irqflags;
20788 + spin_lock_irqsave(&nxi->addr_lock, irqflags);
20790 + case NXA_TYPE_ADDR:
20791 + old = __find_v6_addr(nxi, ip, mask, prefix, type, flags, &nxa);
20794 + nxa->next = old->next;
20795 + old->next = NULL;
20801 + old->next = NULL;
20803 + memset(old, 0, sizeof(*old));
20811 + case NXA_TYPE_ANY:
20814 + memset(nxa, 0, sizeof(*nxa));
20820 + spin_unlock_irqrestore(&nxi->addr_lock, irqflags);
20821 + __dealloc_nx_addr_v6_all(old);
20825 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
20827 + struct vcmd_net_addr_ipv6_v1 vc_data;
20829 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20832 + switch (vc_data.type) {
20833 + case NXA_TYPE_ADDR:
20834 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20835 + /* fallthrough */
20836 + case NXA_TYPE_MASK:
20837 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20838 + vc_data.prefix, vc_data.type, vc_data.flags);
20845 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
20847 + struct vcmd_net_addr_ipv6_v1 vc_data;
20849 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20852 + switch (vc_data.type) {
20853 + case NXA_TYPE_ADDR:
20854 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20855 + /* fallthrough */
20856 + case NXA_TYPE_MASK:
20857 + return do_remove_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20858 + vc_data.prefix, vc_data.type, vc_data.flags);
20859 + case NXA_TYPE_ANY:
20860 + return do_remove_v6_addr(nxi, NULL, NULL, 0, vc_data.type, 0);
20867 +#endif /* CONFIG_IPV6 */
20870 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
20872 + struct vcmd_net_flags_v0 vc_data;
20874 + vc_data.flagword = nxi->nx_flags;
20876 + /* special STATE flag handling */
20877 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
20879 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20884 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
20886 + struct vcmd_net_flags_v0 vc_data;
20887 + uint64_t mask, trigger;
20889 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20892 + /* special STATE flag handling */
20893 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
20894 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
20896 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
20897 + vc_data.flagword, mask);
20898 + if (trigger & NXF_PERSISTENT)
20899 + nx_update_persistent(nxi);
20904 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
20906 + struct vcmd_net_caps_v0 vc_data;
20908 + vc_data.ncaps = nxi->nx_ncaps;
20909 + vc_data.cmask = ~0ULL;
20911 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20916 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
20918 + struct vcmd_net_caps_v0 vc_data;
20920 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20923 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
20924 + vc_data.ncaps, vc_data.cmask);
20929 +#include <linux/module.h>
20931 +module_init(init_network);
20933 +EXPORT_SYMBOL_GPL(free_nx_info);
20934 +EXPORT_SYMBOL_GPL(unhash_nx_info);
20936 diff -NurpP --minimal linux-3.9.4/kernel/vserver/proc.c linux-3.9.4-vs2.3.6.3/kernel/vserver/proc.c
20937 --- linux-3.9.4/kernel/vserver/proc.c 1970-01-01 00:00:00.000000000 +0000
20938 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/proc.c 2013-06-01 08:30:38.000000000 +0000
20941 + * linux/kernel/vserver/proc.c
20943 + * Virtual Context Support
20945 + * Copyright (C) 2003-2011 Herbert Pötzl
20947 + * V0.01 basic structure
20948 + * V0.02 adaptation vs1.3.0
20949 + * V0.03 proc permissions
20950 + * V0.04 locking/generic
20951 + * V0.05 next generation procfs
20952 + * V0.06 inode validation
20953 + * V0.07 generic rewrite vid
20954 + * V0.08 remove inode type
20955 + * V0.09 added u/wmask info
20959 +#include <linux/proc_fs.h>
20960 +#include <linux/fs_struct.h>
20961 +#include <linux/mount.h>
20962 +#include <linux/namei.h>
20963 +#include <asm/unistd.h>
20965 +#include <linux/vs_context.h>
20966 +#include <linux/vs_network.h>
20967 +#include <linux/vs_cvirt.h>
20969 +#include <linux/in.h>
20970 +#include <linux/inetdevice.h>
20971 +#include <linux/vs_inet.h>
20972 +#include <linux/vs_inet6.h>
20974 +#include <linux/vserver/global.h>
20976 +#include "cvirt_proc.h"
20977 +#include "cacct_proc.h"
20978 +#include "limit_proc.h"
20979 +#include "sched_proc.h"
20980 +#include "vci_config.h"
20983 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
20987 + CAP_FOR_EACH_U32(__capi) {
20988 + buffer += sprintf(buffer, "%08x",
20989 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
20995 +static struct proc_dir_entry *proc_virtual;
20997 +static struct proc_dir_entry *proc_virtnet;
21000 +/* first the actual feeds */
21003 +static int proc_vci(char *buffer)
21005 + return sprintf(buffer,
21006 + "VCIVersion:\t%04x:%04x\n"
21007 + "VCISyscall:\t%d\n"
21008 + "VCIKernel:\t%08x\n",
21009 + VCI_VERSION >> 16,
21010 + VCI_VERSION & 0xFFFF,
21012 + vci_kernel_config());
21015 +static int proc_virtual_info(char *buffer)
21017 + return proc_vci(buffer);
21020 +static int proc_virtual_status(char *buffer)
21022 + return sprintf(buffer,
21024 + "#CActive:\t%d\n"
21025 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21026 + "#InitTask:\t%d\t%d %d\n",
21027 + atomic_read(&vx_global_ctotal),
21028 + atomic_read(&vx_global_cactive),
21029 + atomic_read(&vs_global_nsproxy),
21030 + atomic_read(&vs_global_fs),
21031 + atomic_read(&vs_global_mnt_ns),
21032 + atomic_read(&vs_global_uts_ns),
21033 + atomic_read(&nr_ipc_ns),
21034 + atomic_read(&vs_global_user_ns),
21035 + atomic_read(&vs_global_pid_ns),
21036 + atomic_read(&init_task.usage),
21037 + atomic_read(&init_task.nsproxy->count),
21038 + init_task.fs->users);
21042 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21046 + length = sprintf(buffer,
21054 + vxi->vx_badness_bias);
21058 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21060 + char *orig = buffer;
21062 + buffer += sprintf(buffer,
21065 + "Flags:\t%016llx\n",
21066 + atomic_read(&vxi->vx_usecnt),
21067 + atomic_read(&vxi->vx_tasks),
21068 + (unsigned long long)vxi->vx_flags);
21070 + buffer += sprintf(buffer, "BCaps:\t");
21071 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21072 + buffer += sprintf(buffer, "\n");
21074 + buffer += sprintf(buffer,
21075 + "CCaps:\t%016llx\n"
21076 + "Umask:\t%16llx\n"
21077 + "Wmask:\t%16llx\n"
21078 + "Spaces:\t%08lx %08lx\n",
21079 + (unsigned long long)vxi->vx_ccaps,
21080 + (unsigned long long)vxi->vx_umask,
21081 + (unsigned long long)vxi->vx_wmask,
21082 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21083 + return buffer - orig;
21086 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21088 + return vx_info_proc_limit(&vxi->limit, buffer);
21091 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21095 + length = vx_info_proc_sched(&vxi->sched, buffer);
21096 + for_each_online_cpu(cpu) {
21097 + length += vx_info_proc_sched_pc(
21098 + &vx_per_cpu(vxi, sched_pc, cpu),
21099 + buffer + length, cpu);
21104 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21106 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21109 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21111 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21114 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21118 + vx_update_load(vxi);
21119 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21120 + for_each_online_cpu(cpu) {
21121 + length += vx_info_proc_cvirt_pc(
21122 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21123 + buffer + length, cpu);
21128 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21130 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21134 +static int proc_virtnet_info(char *buffer)
21136 + return proc_vci(buffer);
21139 +static int proc_virtnet_status(char *buffer)
21141 + return sprintf(buffer,
21143 + "#CActive:\t%d\n",
21144 + atomic_read(&nx_global_ctotal),
21145 + atomic_read(&nx_global_cactive));
21148 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21150 + struct nx_addr_v4 *v4a;
21151 +#ifdef CONFIG_IPV6
21152 + struct nx_addr_v6 *v6a;
21156 + length = sprintf(buffer,
21159 + "Bcast:\t" NIPQUAD_FMT "\n"
21160 + "Lback:\t" NIPQUAD_FMT "\n",
21163 + NIPQUAD(nxi->v4_bcast.s_addr),
21164 + NIPQUAD(nxi->v4_lback.s_addr));
21166 + if (!NX_IPV4(nxi))
21168 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21169 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21172 +#ifdef CONFIG_IPV6
21173 + if (!NX_IPV6(nxi))
21175 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21176 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21183 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21187 + length = sprintf(buffer,
21190 + "Flags:\t%016llx\n"
21191 + "NCaps:\t%016llx\n",
21192 + atomic_read(&nxi->nx_usecnt),
21193 + atomic_read(&nxi->nx_tasks),
21194 + (unsigned long long)nxi->nx_flags,
21195 + (unsigned long long)nxi->nx_ncaps);
21201 +/* here the inode helpers */
21207 + struct inode_operations *iop;
21208 + struct file_operations *fop;
21209 + union proc_op op;
21212 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21214 + struct inode *inode = new_inode(sb);
21219 + inode->i_mode = p->mode;
21221 + inode->i_op = p->iop;
21223 + inode->i_fop = p->fop;
21225 + set_nlink(inode, (p->mode & S_IFDIR) ? 2 : 1);
21226 + inode->i_flags |= S_IMMUTABLE;
21228 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21230 + i_uid_write(inode, 0);
21231 + i_gid_write(inode, 0);
21232 + i_tag_write(inode, 0);
21237 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21238 + struct dentry *dentry, int id, void *ptr)
21240 + struct vs_entry *p = ptr;
21241 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21242 + struct dentry *error = ERR_PTR(-EINVAL);
21247 + PROC_I(inode)->op = p->op;
21248 + PROC_I(inode)->fd = id;
21249 + d_add(dentry, inode);
21257 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21260 + * Fill a directory entry.
21262 + * If possible create the dcache entry and derive our inode number and
21263 + * file type from dcache entry.
21265 + * Since all of the proc inode numbers are dynamically generated, the inode
21266 + * numbers do not exist until the inode is cache. This means creating the
21267 + * the dcache entry in readdir is necessary to keep the inode numbers
21268 + * reported by readdir in sync with the inode numbers reported
21271 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21272 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21274 + struct dentry *child, *dir = filp->f_dentry;
21275 + struct inode *inode;
21276 + struct qstr qname;
21278 + unsigned type = DT_UNKNOWN;
21280 + qname.name = name;
21282 + qname.hash = full_name_hash(name, len);
21284 + child = d_lookup(dir, &qname);
21286 + struct dentry *new;
21287 + new = d_alloc(dir, &qname);
21289 + child = instantiate(dir->d_inode, new, id, ptr);
21296 + if (!child || IS_ERR(child) || !child->d_inode)
21297 + goto end_instantiate;
21298 + inode = child->d_inode;
21300 + ino = inode->i_ino;
21301 + type = inode->i_mode >> 12;
21306 + ino = find_inode_number(dir, &qname);
21309 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21314 +/* get and revalidate vx_info/xid */
21317 +struct vx_info *get_proc_vx_info(struct inode *inode)
21319 + return lookup_vx_info(PROC_I(inode)->fd);
21322 +static int proc_xid_revalidate(struct dentry *dentry, unsigned int flags)
21324 + struct inode *inode = dentry->d_inode;
21325 + xid_t xid = PROC_I(inode)->fd;
21327 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21330 + if (!xid || xid_is_hashed(xid))
21337 +/* get and revalidate nx_info/nid */
21339 +static int proc_nid_revalidate(struct dentry *dentry, unsigned int flags)
21341 + struct inode *inode = dentry->d_inode;
21342 + nid_t nid = PROC_I(inode)->fd;
21344 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21347 + if (!nid || nid_is_hashed(nid))
21355 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21357 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21358 + size_t count, loff_t *ppos)
21360 + struct inode *inode = file->f_dentry->d_inode;
21361 + unsigned long page;
21362 + ssize_t length = 0;
21364 + if (count > PROC_BLOCK_SIZE)
21365 + count = PROC_BLOCK_SIZE;
21367 + /* fade that out as soon as stable */
21368 + WARN_ON(PROC_I(inode)->fd);
21370 + if (!(page = __get_free_page(GFP_KERNEL)))
21373 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21374 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21377 + length = simple_read_from_buffer(buf, count, ppos,
21378 + (char *)page, length);
21384 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21385 + size_t count, loff_t *ppos)
21387 + struct inode *inode = file->f_dentry->d_inode;
21388 + struct vx_info *vxi = NULL;
21389 + xid_t xid = PROC_I(inode)->fd;
21390 + unsigned long page;
21391 + ssize_t length = 0;
21393 + if (count > PROC_BLOCK_SIZE)
21394 + count = PROC_BLOCK_SIZE;
21396 + /* fade that out as soon as stable */
21398 + vxi = lookup_vx_info(xid);
21402 + length = -ENOMEM;
21403 + if (!(page = __get_free_page(GFP_KERNEL)))
21406 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21407 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21410 + length = simple_read_from_buffer(buf, count, ppos,
21411 + (char *)page, length);
21415 + put_vx_info(vxi);
21420 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21421 + size_t count, loff_t *ppos)
21423 + struct inode *inode = file->f_dentry->d_inode;
21424 + struct nx_info *nxi = NULL;
21425 + nid_t nid = PROC_I(inode)->fd;
21426 + unsigned long page;
21427 + ssize_t length = 0;
21429 + if (count > PROC_BLOCK_SIZE)
21430 + count = PROC_BLOCK_SIZE;
21432 + /* fade that out as soon as stable */
21434 + nxi = lookup_nx_info(nid);
21438 + length = -ENOMEM;
21439 + if (!(page = __get_free_page(GFP_KERNEL)))
21442 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21443 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21446 + length = simple_read_from_buffer(buf, count, ppos,
21447 + (char *)page, length);
21451 + put_nx_info(nxi);
21458 +/* here comes the lower level */
21461 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21462 + .len = sizeof(NAME) - 1, \
21463 + .name = (NAME), \
21471 +#define DIR(NAME, MODE, OTYPE) \
21472 + NOD(NAME, (S_IFDIR | (MODE)), \
21473 + &proc_ ## OTYPE ## _inode_operations, \
21474 + &proc_ ## OTYPE ## _file_operations, { } )
21476 +#define INF(NAME, MODE, OTYPE) \
21477 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21478 + &proc_vs_info_file_operations, \
21479 + { .proc_vs_read = &proc_##OTYPE } )
21481 +#define VINF(NAME, MODE, OTYPE) \
21482 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21483 + &proc_vx_info_file_operations, \
21484 + { .proc_vxi_read = &proc_##OTYPE } )
21486 +#define NINF(NAME, MODE, OTYPE) \
21487 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21488 + &proc_nx_info_file_operations, \
21489 + { .proc_nxi_read = &proc_##OTYPE } )
21492 +static struct file_operations proc_vs_info_file_operations = {
21493 + .read = proc_vs_info_read,
21496 +static struct file_operations proc_vx_info_file_operations = {
21497 + .read = proc_vx_info_read,
21500 +static struct dentry_operations proc_xid_dentry_operations = {
21501 + .d_revalidate = proc_xid_revalidate,
21504 +static struct vs_entry vx_base_stuff[] = {
21505 + VINF("info", S_IRUGO, vxi_info),
21506 + VINF("status", S_IRUGO, vxi_status),
21507 + VINF("limit", S_IRUGO, vxi_limit),
21508 + VINF("sched", S_IRUGO, vxi_sched),
21509 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21510 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21511 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21512 + VINF("cacct", S_IRUGO, vxi_cacct),
21519 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21520 + struct dentry *dentry, int id, void *ptr)
21522 + dentry->d_op = &proc_xid_dentry_operations;
21523 + return vs_proc_instantiate(dir, dentry, id, ptr);
21526 +static struct dentry *proc_xid_lookup(struct inode *dir,
21527 + struct dentry *dentry, unsigned int flags)
21529 + struct vs_entry *p = vx_base_stuff;
21530 + struct dentry *error = ERR_PTR(-ENOENT);
21532 + for (; p->name; p++) {
21533 + if (p->len != dentry->d_name.len)
21535 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21541 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21546 +static int proc_xid_readdir(struct file *filp,
21547 + void *dirent, filldir_t filldir)
21549 + struct dentry *dentry = filp->f_dentry;
21550 + struct inode *inode = dentry->d_inode;
21551 + struct vs_entry *p = vx_base_stuff;
21552 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21556 + pos = filp->f_pos;
21559 + ino = inode->i_ino;
21560 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21563 + /* fall through */
21565 + ino = parent_ino(dentry);
21566 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21569 + /* fall through */
21572 + if (index >= size)
21574 + for (p += index; p->name; p++) {
21575 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21576 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21582 + filp->f_pos = pos;
21588 +static struct file_operations proc_nx_info_file_operations = {
21589 + .read = proc_nx_info_read,
21592 +static struct dentry_operations proc_nid_dentry_operations = {
21593 + .d_revalidate = proc_nid_revalidate,
21596 +static struct vs_entry nx_base_stuff[] = {
21597 + NINF("info", S_IRUGO, nxi_info),
21598 + NINF("status", S_IRUGO, nxi_status),
21603 +static struct dentry *proc_nid_instantiate(struct inode *dir,
21604 + struct dentry *dentry, int id, void *ptr)
21606 + dentry->d_op = &proc_nid_dentry_operations;
21607 + return vs_proc_instantiate(dir, dentry, id, ptr);
21610 +static struct dentry *proc_nid_lookup(struct inode *dir,
21611 + struct dentry *dentry, unsigned int flags)
21613 + struct vs_entry *p = nx_base_stuff;
21614 + struct dentry *error = ERR_PTR(-ENOENT);
21616 + for (; p->name; p++) {
21617 + if (p->len != dentry->d_name.len)
21619 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21625 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21630 +static int proc_nid_readdir(struct file *filp,
21631 + void *dirent, filldir_t filldir)
21633 + struct dentry *dentry = filp->f_dentry;
21634 + struct inode *inode = dentry->d_inode;
21635 + struct vs_entry *p = nx_base_stuff;
21636 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
21640 + pos = filp->f_pos;
21643 + ino = inode->i_ino;
21644 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21647 + /* fall through */
21649 + ino = parent_ino(dentry);
21650 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21653 + /* fall through */
21656 + if (index >= size)
21658 + for (p += index; p->name; p++) {
21659 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21660 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21666 + filp->f_pos = pos;
21671 +#define MAX_MULBY10 ((~0U - 9) / 10)
21673 +static inline int atovid(const char *str, int len)
21678 + while (len-- > 0) {
21683 + if (vid >= MAX_MULBY10)
21693 +/* now the upper level (virtual) */
21696 +static struct file_operations proc_xid_file_operations = {
21697 + .read = generic_read_dir,
21698 + .readdir = proc_xid_readdir,
21701 +static struct inode_operations proc_xid_inode_operations = {
21702 + .lookup = proc_xid_lookup,
21705 +static struct vs_entry vx_virtual_stuff[] = {
21706 + INF("info", S_IRUGO, virtual_info),
21707 + INF("status", S_IRUGO, virtual_status),
21708 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
21712 +static struct dentry *proc_virtual_lookup(struct inode *dir,
21713 + struct dentry *dentry, unsigned int flags)
21715 + struct vs_entry *p = vx_virtual_stuff;
21716 + struct dentry *error = ERR_PTR(-ENOENT);
21719 + for (; p->name; p++) {
21720 + if (p->len != dentry->d_name.len)
21722 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21726 + goto instantiate;
21728 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21729 + if ((id < 0) || !xid_is_hashed(id))
21733 + error = proc_xid_instantiate(dir, dentry, id, p);
21738 +static struct file_operations proc_nid_file_operations = {
21739 + .read = generic_read_dir,
21740 + .readdir = proc_nid_readdir,
21743 +static struct inode_operations proc_nid_inode_operations = {
21744 + .lookup = proc_nid_lookup,
21747 +static struct vs_entry nx_virtnet_stuff[] = {
21748 + INF("info", S_IRUGO, virtnet_info),
21749 + INF("status", S_IRUGO, virtnet_status),
21750 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
21754 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
21755 + struct dentry *dentry, unsigned int flags)
21757 + struct vs_entry *p = nx_virtnet_stuff;
21758 + struct dentry *error = ERR_PTR(-ENOENT);
21761 + for (; p->name; p++) {
21762 + if (p->len != dentry->d_name.len)
21764 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21768 + goto instantiate;
21770 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21771 + if ((id < 0) || !nid_is_hashed(id))
21775 + error = proc_nid_instantiate(dir, dentry, id, p);
21781 +#define PROC_MAXVIDS 32
21783 +int proc_virtual_readdir(struct file *filp,
21784 + void *dirent, filldir_t filldir)
21786 + struct dentry *dentry = filp->f_dentry;
21787 + struct inode *inode = dentry->d_inode;
21788 + struct vs_entry *p = vx_virtual_stuff;
21789 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
21791 + unsigned int xid_array[PROC_MAXVIDS];
21792 + char buf[PROC_NUMBUF];
21793 + unsigned int nr_xids, i;
21796 + pos = filp->f_pos;
21799 + ino = inode->i_ino;
21800 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21803 + /* fall through */
21805 + ino = parent_ino(dentry);
21806 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21809 + /* fall through */
21812 + if (index >= size)
21814 + for (p += index; p->name; p++) {
21815 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21816 + vs_proc_instantiate, 0, p))
21821 + index = pos - size;
21822 + p = &vx_virtual_stuff[size - 1];
21823 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
21824 + for (i = 0; i < nr_xids; i++) {
21825 + int n, xid = xid_array[i];
21826 + unsigned int j = PROC_NUMBUF;
21830 + buf[--j] = '0' + (n % 10);
21833 + if (proc_fill_cache(filp, dirent, filldir,
21834 + buf + j, PROC_NUMBUF - j,
21835 + vs_proc_instantiate, xid, p))
21841 + filp->f_pos = pos;
21845 +static int proc_virtual_getattr(struct vfsmount *mnt,
21846 + struct dentry *dentry, struct kstat *stat)
21848 + struct inode *inode = dentry->d_inode;
21850 + generic_fillattr(inode, stat);
21851 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
21855 +static struct file_operations proc_virtual_dir_operations = {
21856 + .read = generic_read_dir,
21857 + .readdir = proc_virtual_readdir,
21860 +static struct inode_operations proc_virtual_dir_inode_operations = {
21861 + .getattr = proc_virtual_getattr,
21862 + .lookup = proc_virtual_lookup,
21869 +int proc_virtnet_readdir(struct file *filp,
21870 + void *dirent, filldir_t filldir)
21872 + struct dentry *dentry = filp->f_dentry;
21873 + struct inode *inode = dentry->d_inode;
21874 + struct vs_entry *p = nx_virtnet_stuff;
21875 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
21877 + unsigned int nid_array[PROC_MAXVIDS];
21878 + char buf[PROC_NUMBUF];
21879 + unsigned int nr_nids, i;
21882 + pos = filp->f_pos;
21885 + ino = inode->i_ino;
21886 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21889 + /* fall through */
21891 + ino = parent_ino(dentry);
21892 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21895 + /* fall through */
21898 + if (index >= size)
21900 + for (p += index; p->name; p++) {
21901 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21902 + vs_proc_instantiate, 0, p))
21907 + index = pos - size;
21908 + p = &nx_virtnet_stuff[size - 1];
21909 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
21910 + for (i = 0; i < nr_nids; i++) {
21911 + int n, nid = nid_array[i];
21912 + unsigned int j = PROC_NUMBUF;
21916 + buf[--j] = '0' + (n % 10);
21919 + if (proc_fill_cache(filp, dirent, filldir,
21920 + buf + j, PROC_NUMBUF - j,
21921 + vs_proc_instantiate, nid, p))
21927 + filp->f_pos = pos;
21931 +static int proc_virtnet_getattr(struct vfsmount *mnt,
21932 + struct dentry *dentry, struct kstat *stat)
21934 + struct inode *inode = dentry->d_inode;
21936 + generic_fillattr(inode, stat);
21937 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
21941 +static struct file_operations proc_virtnet_dir_operations = {
21942 + .read = generic_read_dir,
21943 + .readdir = proc_virtnet_readdir,
21946 +static struct inode_operations proc_virtnet_dir_inode_operations = {
21947 + .getattr = proc_virtnet_getattr,
21948 + .lookup = proc_virtnet_lookup,
21953 +void proc_vx_init(void)
21955 + struct proc_dir_entry *ent;
21957 + ent = proc_mkdir("virtual", 0);
21959 + ent->proc_fops = &proc_virtual_dir_operations;
21960 + ent->proc_iops = &proc_virtual_dir_inode_operations;
21962 + proc_virtual = ent;
21964 + ent = proc_mkdir("virtnet", 0);
21966 + ent->proc_fops = &proc_virtnet_dir_operations;
21967 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
21969 + proc_virtnet = ent;
21975 +/* per pid info */
21978 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
21980 + struct vx_info *vxi;
21981 + char *orig = buffer;
21983 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
21985 + vxi = task_get_vx_info(p);
21989 + buffer += sprintf(buffer, "BCaps:\t");
21990 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21991 + buffer += sprintf(buffer, "\n");
21992 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
21993 + (unsigned long long)vxi->vx_ccaps);
21994 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
21995 + (unsigned long long)vxi->vx_flags);
21996 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
21998 + put_vx_info(vxi);
22000 + return buffer - orig;
22004 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22006 + struct nx_info *nxi;
22007 + struct nx_addr_v4 *v4a;
22008 +#ifdef CONFIG_IPV6
22009 + struct nx_addr_v6 *v6a;
22011 + char *orig = buffer;
22014 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22016 + nxi = task_get_nx_info(p);
22020 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22021 + (unsigned long long)nxi->nx_ncaps);
22022 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22023 + (unsigned long long)nxi->nx_flags);
22025 + buffer += sprintf(buffer,
22026 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22027 + NIPQUAD(nxi->v4_bcast.s_addr));
22028 + buffer += sprintf (buffer,
22029 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22030 + NIPQUAD(nxi->v4_lback.s_addr));
22031 + if (!NX_IPV4(nxi))
22033 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22034 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22037 +#ifdef CONFIG_IPV6
22038 + if (!NX_IPV6(nxi))
22040 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22041 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22045 + put_nx_info(nxi);
22047 + return buffer - orig;
22050 diff -NurpP --minimal linux-3.9.4/kernel/vserver/sched.c linux-3.9.4-vs2.3.6.3/kernel/vserver/sched.c
22051 --- linux-3.9.4/kernel/vserver/sched.c 1970-01-01 00:00:00.000000000 +0000
22052 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/sched.c 2013-05-31 14:47:11.000000000 +0000
22055 + * linux/kernel/vserver/sched.c
22057 + * Virtual Server: Scheduler Support
22059 + * Copyright (C) 2004-2010 Herbert Pötzl
22061 + * V0.01 adapted Sam Vilains version to 2.6.3
22062 + * V0.02 removed legacy interface
22063 + * V0.03 changed vcmds to vxi arg
22064 + * V0.04 removed older and legacy interfaces
22065 + * V0.05 removed scheduler code/commands
22069 +#include <linux/vs_context.h>
22070 +#include <linux/vs_sched.h>
22071 +#include <linux/cpumask.h>
22072 +#include <linux/vserver/sched_cmd.h>
22074 +#include <asm/uaccess.h>
22077 +void vx_update_sched_param(struct _vx_sched *sched,
22078 + struct _vx_sched_pc *sched_pc)
22080 + sched_pc->prio_bias = sched->prio_bias;
22083 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22087 + if (data->prio_bias > MAX_PRIO_BIAS)
22088 + data->prio_bias = MAX_PRIO_BIAS;
22089 + if (data->prio_bias < MIN_PRIO_BIAS)
22090 + data->prio_bias = MIN_PRIO_BIAS;
22092 + if (data->cpu_id != ~0) {
22093 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22094 + cpumask_and(&vxi->sched.update, &vxi->sched.update,
22095 + cpu_online_mask);
22097 + cpumask_copy(&vxi->sched.update, cpu_online_mask);
22099 + for_each_cpu_mask(cpu, vxi->sched.update)
22100 + vx_update_sched_param(&vxi->sched,
22101 + &vx_per_cpu(vxi, sched_pc, cpu));
22105 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22107 + struct vcmd_prio_bias vc_data;
22109 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22112 + return do_set_prio_bias(vxi, &vc_data);
22115 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22117 + struct vcmd_prio_bias vc_data;
22118 + struct _vx_sched_pc *pcd;
22121 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22124 + cpu = vc_data.cpu_id;
22126 + if (!cpu_possible(cpu))
22129 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22130 + vc_data.prio_bias = pcd->prio_bias;
22132 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22137 diff -NurpP --minimal linux-3.9.4/kernel/vserver/sched_init.h linux-3.9.4-vs2.3.6.3/kernel/vserver/sched_init.h
22138 --- linux-3.9.4/kernel/vserver/sched_init.h 1970-01-01 00:00:00.000000000 +0000
22139 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/sched_init.h 2013-05-31 14:47:11.000000000 +0000
22142 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22144 + /* scheduling; hard code starting values as constants */
22145 + sched->prio_bias = 0;
22149 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22151 + sched_pc->prio_bias = 0;
22153 + sched_pc->user_ticks = 0;
22154 + sched_pc->sys_ticks = 0;
22155 + sched_pc->hold_ticks = 0;
22158 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22164 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22168 diff -NurpP --minimal linux-3.9.4/kernel/vserver/sched_proc.h linux-3.9.4-vs2.3.6.3/kernel/vserver/sched_proc.h
22169 --- linux-3.9.4/kernel/vserver/sched_proc.h 1970-01-01 00:00:00.000000000 +0000
22170 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/sched_proc.h 2013-05-31 14:47:11.000000000 +0000
22172 +#ifndef _VX_SCHED_PROC_H
22173 +#define _VX_SCHED_PROC_H
22177 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22181 + length += sprintf(buffer,
22182 + "PrioBias:\t%8d\n",
22183 + sched->prio_bias);
22188 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22189 + char *buffer, int cpu)
22193 + length += sprintf(buffer + length,
22194 + "cpu %d: %lld %lld %lld", cpu,
22195 + (unsigned long long)sched_pc->user_ticks,
22196 + (unsigned long long)sched_pc->sys_ticks,
22197 + (unsigned long long)sched_pc->hold_ticks);
22198 + length += sprintf(buffer + length,
22199 + " %d\n", sched_pc->prio_bias);
22203 +#endif /* _VX_SCHED_PROC_H */
22204 diff -NurpP --minimal linux-3.9.4/kernel/vserver/signal.c linux-3.9.4-vs2.3.6.3/kernel/vserver/signal.c
22205 --- linux-3.9.4/kernel/vserver/signal.c 1970-01-01 00:00:00.000000000 +0000
22206 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/signal.c 2013-05-31 14:47:11.000000000 +0000
22209 + * linux/kernel/vserver/signal.c
22211 + * Virtual Server: Signal Support
22213 + * Copyright (C) 2003-2007 Herbert Pötzl
22215 + * V0.01 broken out from vcontext V0.05
22216 + * V0.02 changed vcmds to vxi arg
22217 + * V0.03 adjusted siginfo for kill
22221 +#include <asm/uaccess.h>
22223 +#include <linux/vs_context.h>
22224 +#include <linux/vs_pid.h>
22225 +#include <linux/vserver/signal_cmd.h>
22228 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22230 + int retval, count = 0;
22231 + struct task_struct *p;
22232 + struct siginfo *sip = SEND_SIG_PRIV;
22235 + vxdprintk(VXD_CBIT(misc, 4),
22236 + "vx_info_kill(%p[#%d],%d,%d)*",
22237 + vxi, vxi->vx_id, pid, sig);
22238 + read_lock(&tasklist_lock);
22242 + for_each_process(p) {
22245 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22246 + (pid && vxi->vx_initpid == p->pid))
22249 + err = group_send_sig_info(sig, sip, p);
22251 + if (err != -EPERM)
22257 + if (vxi->vx_initpid) {
22258 + pid = vxi->vx_initpid;
22259 + /* for now, only SIGINT to private init ... */
22260 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22261 + /* ... as long as there are tasks left */
22262 + (atomic_read(&vxi->vx_tasks) > 1))
22265 + /* fallthrough */
22268 + p = find_task_by_real_pid(pid);
22269 + rcu_read_unlock();
22271 + if (vx_task_xid(p) == vxi->vx_id)
22272 + retval = group_send_sig_info(sig, sip, p);
22276 + read_unlock(&tasklist_lock);
22277 + vxdprintk(VXD_CBIT(misc, 4),
22278 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22279 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22283 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22285 + struct vcmd_ctx_kill_v0 vc_data;
22287 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22290 + /* special check to allow guest shutdown */
22291 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22292 + /* forbid killall pid=0 when init is present */
22293 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22294 + (vc_data.pid > 1)))
22297 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22301 +static int __wait_exit(struct vx_info *vxi)
22303 + DECLARE_WAITQUEUE(wait, current);
22306 + add_wait_queue(&vxi->vx_wait, &wait);
22307 + set_current_state(TASK_INTERRUPTIBLE);
22310 + if (vx_info_state(vxi,
22311 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22313 + if (signal_pending(current)) {
22314 + ret = -ERESTARTSYS;
22321 + set_current_state(TASK_RUNNING);
22322 + remove_wait_queue(&vxi->vx_wait, &wait);
22328 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22330 + struct vcmd_wait_exit_v0 vc_data;
22333 + ret = __wait_exit(vxi);
22334 + vc_data.reboot_cmd = vxi->reboot_cmd;
22335 + vc_data.exit_code = vxi->exit_code;
22337 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22342 diff -NurpP --minimal linux-3.9.4/kernel/vserver/space.c linux-3.9.4-vs2.3.6.3/kernel/vserver/space.c
22343 --- linux-3.9.4/kernel/vserver/space.c 1970-01-01 00:00:00.000000000 +0000
22344 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/space.c 2013-05-31 14:47:11.000000000 +0000
22347 + * linux/kernel/vserver/space.c
22349 + * Virtual Server: Context Space Support
22351 + * Copyright (C) 2003-2010 Herbert Pötzl
22353 + * V0.01 broken out from context.c 0.07
22354 + * V0.02 added task locking for namespace
22355 + * V0.03 broken out vx_enter_namespace
22356 + * V0.04 added *space support and commands
22357 + * V0.05 added credential support
22361 +#include <linux/utsname.h>
22362 +#include <linux/nsproxy.h>
22363 +#include <linux/err.h>
22364 +#include <linux/fs_struct.h>
22365 +#include <linux/cred.h>
22366 +#include <asm/uaccess.h>
22368 +#include <linux/vs_context.h>
22369 +#include <linux/vserver/space.h>
22370 +#include <linux/vserver/space_cmd.h>
22372 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22373 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22374 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22375 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22376 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22377 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22380 +/* namespace functions */
22382 +#include <linux/mnt_namespace.h>
22383 +#include <linux/user_namespace.h>
22384 +#include <linux/pid_namespace.h>
22385 +#include <linux/ipc_namespace.h>
22386 +#include <net/net_namespace.h>
22387 +#include "../fs/mount.h"
22390 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22391 + .mask = CLONE_FS |
22393 +#ifdef CONFIG_UTS_NS
22396 +#ifdef CONFIG_IPC_NS
22399 +#ifdef CONFIG_USER_NS
22405 +static const struct vcmd_space_mask_v1 space_mask = {
22406 + .mask = CLONE_FS |
22408 +#ifdef CONFIG_UTS_NS
22411 +#ifdef CONFIG_IPC_NS
22414 +#ifdef CONFIG_USER_NS
22417 +#ifdef CONFIG_PID_NS
22420 +#ifdef CONFIG_NET_NS
22426 +static const struct vcmd_space_mask_v1 default_space_mask = {
22427 + .mask = CLONE_FS |
22429 +#ifdef CONFIG_UTS_NS
22432 +#ifdef CONFIG_IPC_NS
22435 +#ifdef CONFIG_USER_NS
22438 +#ifdef CONFIG_PID_NS
22445 + * build a new nsproxy mix
22446 + * assumes that both proxies are 'const'
22447 + * does not touch nsproxy refcounts
22448 + * will hold a reference on the result.
22451 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22452 + struct nsproxy *new_nsproxy, unsigned long mask)
22454 + struct mnt_namespace *old_ns;
22455 + struct uts_namespace *old_uts;
22456 + struct ipc_namespace *old_ipc;
22457 +#ifdef CONFIG_PID_NS
22458 + struct pid_namespace *old_pid;
22460 +#ifdef CONFIG_NET_NS
22461 + struct net *old_net;
22463 + struct nsproxy *nsproxy;
22465 + nsproxy = copy_nsproxy(old_nsproxy);
22469 + if (mask & CLONE_NEWNS) {
22470 + old_ns = nsproxy->mnt_ns;
22471 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22472 + if (nsproxy->mnt_ns)
22473 + get_mnt_ns(nsproxy->mnt_ns);
22477 + if (mask & CLONE_NEWUTS) {
22478 + old_uts = nsproxy->uts_ns;
22479 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22480 + if (nsproxy->uts_ns)
22481 + get_uts_ns(nsproxy->uts_ns);
22485 + if (mask & CLONE_NEWIPC) {
22486 + old_ipc = nsproxy->ipc_ns;
22487 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22488 + if (nsproxy->ipc_ns)
22489 + get_ipc_ns(nsproxy->ipc_ns);
22493 +#ifdef CONFIG_PID_NS
22494 + if (mask & CLONE_NEWPID) {
22495 + old_pid = nsproxy->pid_ns;
22496 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22497 + if (nsproxy->pid_ns)
22498 + get_pid_ns(nsproxy->pid_ns);
22502 +#ifdef CONFIG_NET_NS
22503 + if (mask & CLONE_NEWNET) {
22504 + old_net = nsproxy->net_ns;
22505 + nsproxy->net_ns = new_nsproxy->net_ns;
22506 + if (nsproxy->net_ns)
22507 + get_net(nsproxy->net_ns);
22512 + put_mnt_ns(old_ns);
22514 + put_uts_ns(old_uts);
22516 + put_ipc_ns(old_ipc);
22517 +#ifdef CONFIG_PID_NS
22519 + put_pid_ns(old_pid);
22521 +#ifdef CONFIG_NET_NS
22523 + put_net(old_net);
22531 + * merge two nsproxy structs into a new one.
22532 + * will hold a reference on the result.
22536 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22537 + struct nsproxy *proxy, unsigned long mask)
22539 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22545 + /* vs_mix_nsproxy returns with reference */
22546 + return vs_mix_nsproxy(old ? old : &null_proxy,
22549 + get_nsproxy(proxy);
22554 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22556 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22557 + struct fs_struct *fs_cur, *fs = NULL;
22558 + struct _vx_space *space;
22559 + int ret, kill = 0;
22561 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22562 + vxi, vxi->vx_id, mask, index);
22564 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22567 + if (index >= VX_SPACES)
22570 + space = &vxi->space[index];
22573 + mask = space->vx_nsmask;
22575 + if ((mask & space->vx_nsmask) != mask)
22578 + if (mask & CLONE_FS) {
22579 + fs = copy_fs_struct(space->vx_fs);
22583 + proxy = space->vx_nsproxy;
22585 + vxdprintk(VXD_CBIT(space, 9),
22586 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
22587 + vxi, vxi->vx_id, mask, index, proxy, fs);
22589 + task_lock(current);
22590 + fs_cur = current->fs;
22592 + if (mask & CLONE_FS) {
22593 + spin_lock(&fs_cur->lock);
22594 + current->fs = fs;
22595 + kill = !--fs_cur->users;
22596 + spin_unlock(&fs_cur->lock);
22599 + proxy_cur = current->nsproxy;
22600 + get_nsproxy(proxy_cur);
22601 + task_unlock(current);
22604 + free_fs_struct(fs_cur);
22606 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
22607 + if (IS_ERR(proxy_new)) {
22608 + ret = PTR_ERR(proxy_new);
22612 + proxy_new = xchg(¤t->nsproxy, proxy_new);
22614 + if (mask & CLONE_NEWUSER) {
22615 + struct cred *cred;
22617 + vxdprintk(VXD_CBIT(space, 10),
22618 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
22619 + vxi, vxi->vx_id, space->vx_cred,
22620 + current->real_cred, current->cred);
22622 + if (space->vx_cred) {
22623 + cred = __prepare_creds(space->vx_cred);
22625 + commit_creds(cred);
22632 + put_nsproxy(proxy_new);
22635 + put_nsproxy(proxy_cur);
22640 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22642 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
22643 + struct fs_struct *fs_vxi, *fs = NULL;
22644 + struct _vx_space *space;
22645 + int ret, kill = 0;
22647 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
22648 + vxi, vxi->vx_id, mask, index);
22650 + if ((mask & space_mask.mask) != mask)
22653 + if (index >= VX_SPACES)
22656 + space = &vxi->space[index];
22658 + proxy_vxi = space->vx_nsproxy;
22659 + fs_vxi = space->vx_fs;
22661 + if (mask & CLONE_FS) {
22662 + fs = copy_fs_struct(current->fs);
22667 + task_lock(current);
22669 + if (mask & CLONE_FS) {
22670 + spin_lock(&fs_vxi->lock);
22671 + space->vx_fs = fs;
22672 + kill = !--fs_vxi->users;
22673 + spin_unlock(&fs_vxi->lock);
22676 + proxy_cur = current->nsproxy;
22677 + get_nsproxy(proxy_cur);
22678 + task_unlock(current);
22681 + free_fs_struct(fs_vxi);
22683 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
22684 + if (IS_ERR(proxy_new)) {
22685 + ret = PTR_ERR(proxy_new);
22689 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
22690 + space->vx_nsmask |= mask;
22692 + if (mask & CLONE_NEWUSER) {
22693 + struct cred *cred;
22695 + vxdprintk(VXD_CBIT(space, 10),
22696 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
22697 + vxi, vxi->vx_id, space->vx_cred,
22698 + current->real_cred, current->cred);
22700 + cred = prepare_creds();
22701 + cred = (struct cred *)xchg(&space->vx_cred, cred);
22703 + abort_creds(cred);
22709 + put_nsproxy(proxy_new);
22712 + put_nsproxy(proxy_cur);
22717 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
22719 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22721 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22724 + return vx_enter_space(vxi, vc_data.mask, 0);
22727 +int vc_enter_space(struct vx_info *vxi, void __user *data)
22729 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22731 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22734 + if (vc_data.index >= VX_SPACES)
22737 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
22740 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
22742 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22744 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22747 + return vx_set_space(vxi, vc_data.mask, 0);
22750 +int vc_set_space(struct vx_info *vxi, void __user *data)
22752 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22754 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22757 + if (vc_data.index >= VX_SPACES)
22760 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
22763 +int vc_get_space_mask(void __user *data, int type)
22765 + const struct vcmd_space_mask_v1 *mask;
22768 + mask = &space_mask_v0;
22769 + else if (type == 1)
22770 + mask = &space_mask;
22772 + mask = &default_space_mask;
22774 + vxdprintk(VXD_CBIT(space, 10),
22775 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
22777 + if (copy_to_user(data, mask, sizeof(*mask)))
22782 diff -NurpP --minimal linux-3.9.4/kernel/vserver/switch.c linux-3.9.4-vs2.3.6.3/kernel/vserver/switch.c
22783 --- linux-3.9.4/kernel/vserver/switch.c 1970-01-01 00:00:00.000000000 +0000
22784 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/switch.c 2013-05-31 14:47:11.000000000 +0000
22787 + * linux/kernel/vserver/switch.c
22789 + * Virtual Server: Syscall Switch
22791 + * Copyright (C) 2003-2011 Herbert Pötzl
22793 + * V0.01 syscall switch
22794 + * V0.02 added signal to context
22795 + * V0.03 added rlimit functions
22796 + * V0.04 added iattr, task/xid functions
22797 + * V0.05 added debug/history stuff
22798 + * V0.06 added compat32 layer
22799 + * V0.07 vcmd args and perms
22800 + * V0.08 added status commands
22801 + * V0.09 added tag commands
22802 + * V0.10 added oom bias
22803 + * V0.11 added device commands
22804 + * V0.12 added warn mask
22808 +#include <linux/vs_context.h>
22809 +#include <linux/vs_network.h>
22810 +#include <linux/vserver/switch.h>
22812 +#include "vci_config.h"
22816 +int vc_get_version(uint32_t id)
22818 + return VCI_VERSION;
22822 +int vc_get_vci(uint32_t id)
22824 + return vci_kernel_config();
22827 +#include <linux/vserver/context_cmd.h>
22828 +#include <linux/vserver/cvirt_cmd.h>
22829 +#include <linux/vserver/cacct_cmd.h>
22830 +#include <linux/vserver/limit_cmd.h>
22831 +#include <linux/vserver/network_cmd.h>
22832 +#include <linux/vserver/sched_cmd.h>
22833 +#include <linux/vserver/debug_cmd.h>
22834 +#include <linux/vserver/inode_cmd.h>
22835 +#include <linux/vserver/dlimit_cmd.h>
22836 +#include <linux/vserver/signal_cmd.h>
22837 +#include <linux/vserver/space_cmd.h>
22838 +#include <linux/vserver/tag_cmd.h>
22839 +#include <linux/vserver/device_cmd.h>
22841 +#include <linux/vserver/inode.h>
22842 +#include <linux/vserver/dlimit.h>
22845 +#ifdef CONFIG_COMPAT
22846 +#define __COMPAT(name, id, data, compat) \
22847 + (compat) ? name ## _x32(id, data) : name(id, data)
22848 +#define __COMPAT_NO_ID(name, data, compat) \
22849 + (compat) ? name ## _x32(data) : name(data)
22851 +#define __COMPAT(name, id, data, compat) \
22853 +#define __COMPAT_NO_ID(name, data, compat) \
22859 +long do_vcmd(uint32_t cmd, uint32_t id,
22860 + struct vx_info *vxi, struct nx_info *nxi,
22861 + void __user *data, int compat)
22865 + case VCMD_get_version:
22866 + return vc_get_version(id);
22867 + case VCMD_get_vci:
22868 + return vc_get_vci(id);
22870 + case VCMD_task_xid:
22871 + return vc_task_xid(id);
22872 + case VCMD_vx_info:
22873 + return vc_vx_info(vxi, data);
22875 + case VCMD_task_nid:
22876 + return vc_task_nid(id);
22877 + case VCMD_nx_info:
22878 + return vc_nx_info(nxi, data);
22880 + case VCMD_task_tag:
22881 + return vc_task_tag(id);
22883 + case VCMD_set_space_v1:
22884 + return vc_set_space_v1(vxi, data);
22885 + /* this is version 2 */
22886 + case VCMD_set_space:
22887 + return vc_set_space(vxi, data);
22889 + case VCMD_get_space_mask_v0:
22890 + return vc_get_space_mask(data, 0);
22891 + /* this is version 1 */
22892 + case VCMD_get_space_mask:
22893 + return vc_get_space_mask(data, 1);
22895 + case VCMD_get_space_default:
22896 + return vc_get_space_mask(data, -1);
22898 + case VCMD_set_umask:
22899 + return vc_set_umask(vxi, data);
22901 + case VCMD_get_umask:
22902 + return vc_get_umask(vxi, data);
22904 + case VCMD_set_wmask:
22905 + return vc_set_wmask(vxi, data);
22907 + case VCMD_get_wmask:
22908 + return vc_get_wmask(vxi, data);
22909 +#ifdef CONFIG_IA32_EMULATION
22910 + case VCMD_get_rlimit:
22911 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
22912 + case VCMD_set_rlimit:
22913 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
22915 + case VCMD_get_rlimit:
22916 + return vc_get_rlimit(vxi, data);
22917 + case VCMD_set_rlimit:
22918 + return vc_set_rlimit(vxi, data);
22920 + case VCMD_get_rlimit_mask:
22921 + return vc_get_rlimit_mask(id, data);
22922 + case VCMD_reset_hits:
22923 + return vc_reset_hits(vxi, data);
22924 + case VCMD_reset_minmax:
22925 + return vc_reset_minmax(vxi, data);
22927 + case VCMD_get_vhi_name:
22928 + return vc_get_vhi_name(vxi, data);
22929 + case VCMD_set_vhi_name:
22930 + return vc_set_vhi_name(vxi, data);
22932 + case VCMD_ctx_stat:
22933 + return vc_ctx_stat(vxi, data);
22934 + case VCMD_virt_stat:
22935 + return vc_virt_stat(vxi, data);
22936 + case VCMD_sock_stat:
22937 + return vc_sock_stat(vxi, data);
22938 + case VCMD_rlimit_stat:
22939 + return vc_rlimit_stat(vxi, data);
22941 + case VCMD_set_cflags:
22942 + return vc_set_cflags(vxi, data);
22943 + case VCMD_get_cflags:
22944 + return vc_get_cflags(vxi, data);
22946 + /* this is version 1 */
22947 + case VCMD_set_ccaps:
22948 + return vc_set_ccaps(vxi, data);
22949 + /* this is version 1 */
22950 + case VCMD_get_ccaps:
22951 + return vc_get_ccaps(vxi, data);
22952 + case VCMD_set_bcaps:
22953 + return vc_set_bcaps(vxi, data);
22954 + case VCMD_get_bcaps:
22955 + return vc_get_bcaps(vxi, data);
22957 + case VCMD_set_badness:
22958 + return vc_set_badness(vxi, data);
22959 + case VCMD_get_badness:
22960 + return vc_get_badness(vxi, data);
22962 + case VCMD_set_nflags:
22963 + return vc_set_nflags(nxi, data);
22964 + case VCMD_get_nflags:
22965 + return vc_get_nflags(nxi, data);
22967 + case VCMD_set_ncaps:
22968 + return vc_set_ncaps(nxi, data);
22969 + case VCMD_get_ncaps:
22970 + return vc_get_ncaps(nxi, data);
22972 + case VCMD_set_prio_bias:
22973 + return vc_set_prio_bias(vxi, data);
22974 + case VCMD_get_prio_bias:
22975 + return vc_get_prio_bias(vxi, data);
22976 + case VCMD_add_dlimit:
22977 + return __COMPAT(vc_add_dlimit, id, data, compat);
22978 + case VCMD_rem_dlimit:
22979 + return __COMPAT(vc_rem_dlimit, id, data, compat);
22980 + case VCMD_set_dlimit:
22981 + return __COMPAT(vc_set_dlimit, id, data, compat);
22982 + case VCMD_get_dlimit:
22983 + return __COMPAT(vc_get_dlimit, id, data, compat);
22985 + case VCMD_ctx_kill:
22986 + return vc_ctx_kill(vxi, data);
22988 + case VCMD_wait_exit:
22989 + return vc_wait_exit(vxi, data);
22991 + case VCMD_get_iattr:
22992 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
22993 + case VCMD_set_iattr:
22994 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
22996 + case VCMD_fget_iattr:
22997 + return vc_fget_iattr(id, data);
22998 + case VCMD_fset_iattr:
22999 + return vc_fset_iattr(id, data);
23001 + case VCMD_enter_space_v0:
23002 + return vc_enter_space_v1(vxi, NULL);
23003 + case VCMD_enter_space_v1:
23004 + return vc_enter_space_v1(vxi, data);
23005 + /* this is version 2 */
23006 + case VCMD_enter_space:
23007 + return vc_enter_space(vxi, data);
23009 + case VCMD_ctx_create_v0:
23010 + return vc_ctx_create(id, NULL);
23011 + case VCMD_ctx_create:
23012 + return vc_ctx_create(id, data);
23013 + case VCMD_ctx_migrate_v0:
23014 + return vc_ctx_migrate(vxi, NULL);
23015 + case VCMD_ctx_migrate:
23016 + return vc_ctx_migrate(vxi, data);
23018 + case VCMD_net_create_v0:
23019 + return vc_net_create(id, NULL);
23020 + case VCMD_net_create:
23021 + return vc_net_create(id, data);
23022 + case VCMD_net_migrate:
23023 + return vc_net_migrate(nxi, data);
23025 + case VCMD_tag_migrate:
23026 + return vc_tag_migrate(id);
23028 + case VCMD_net_add:
23029 + return vc_net_add(nxi, data);
23030 + case VCMD_net_remove:
23031 + return vc_net_remove(nxi, data);
23033 + case VCMD_net_add_ipv4_v1:
23034 + return vc_net_add_ipv4_v1(nxi, data);
23035 + /* this is version 2 */
23036 + case VCMD_net_add_ipv4:
23037 + return vc_net_add_ipv4(nxi, data);
23039 + case VCMD_net_rem_ipv4_v1:
23040 + return vc_net_rem_ipv4_v1(nxi, data);
23041 + /* this is version 2 */
23042 + case VCMD_net_rem_ipv4:
23043 + return vc_net_rem_ipv4(nxi, data);
23044 +#ifdef CONFIG_IPV6
23045 + case VCMD_net_add_ipv6:
23046 + return vc_net_add_ipv6(nxi, data);
23047 + case VCMD_net_remove_ipv6:
23048 + return vc_net_remove_ipv6(nxi, data);
23050 +/* case VCMD_add_match_ipv4:
23051 + return vc_add_match_ipv4(nxi, data);
23052 + case VCMD_get_match_ipv4:
23053 + return vc_get_match_ipv4(nxi, data);
23054 +#ifdef CONFIG_IPV6
23055 + case VCMD_add_match_ipv6:
23056 + return vc_add_match_ipv6(nxi, data);
23057 + case VCMD_get_match_ipv6:
23058 + return vc_get_match_ipv6(nxi, data);
23061 +#ifdef CONFIG_VSERVER_DEVICE
23062 + case VCMD_set_mapping:
23063 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23064 + case VCMD_unset_mapping:
23065 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23067 +#ifdef CONFIG_VSERVER_HISTORY
23068 + case VCMD_dump_history:
23069 + return vc_dump_history(id);
23070 + case VCMD_read_history:
23071 + return __COMPAT(vc_read_history, id, data, compat);
23074 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23075 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23081 +#define __VCMD(vcmd, _perm, _args, _flags) \
23082 + case VCMD_ ## vcmd: perm = _perm; \
23083 + args = _args; flags = _flags; break
23086 +#define VCA_NONE 0x00
23087 +#define VCA_VXI 0x01
23088 +#define VCA_NXI 0x02
23090 +#define VCF_NONE 0x00
23091 +#define VCF_INFO 0x01
23092 +#define VCF_ADMIN 0x02
23093 +#define VCF_ARES 0x06 /* includes admin */
23094 +#define VCF_SETUP 0x08
23096 +#define VCF_ZIDOK 0x10 /* zero id okay */
23100 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23103 + int permit = -1, state = 0;
23104 + int perm = -1, args = 0, flags = 0;
23105 + struct vx_info *vxi = NULL;
23106 + struct nx_info *nxi = NULL;
23109 + /* unpriviledged commands */
23110 + __VCMD(get_version, 0, VCA_NONE, 0);
23111 + __VCMD(get_vci, 0, VCA_NONE, 0);
23112 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23113 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23114 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23115 + __VCMD(get_space_default,0, VCA_NONE, 0);
23117 + /* info commands */
23118 + __VCMD(task_xid, 2, VCA_NONE, 0);
23119 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23120 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23121 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23122 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23123 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23124 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23125 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23126 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23127 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23128 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23129 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23131 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23132 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23133 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23134 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23136 + __VCMD(task_nid, 2, VCA_NONE, 0);
23137 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23138 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23139 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23141 + __VCMD(task_tag, 2, VCA_NONE, 0);
23143 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23144 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23145 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23146 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23148 + /* lower admin commands */
23149 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23150 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23151 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23152 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23153 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23154 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23155 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23156 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23158 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23159 + __VCMD(net_create, 5, VCA_NONE, 0);
23160 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23162 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23164 + /* higher admin commands */
23165 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23166 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23167 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23169 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23170 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23171 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23172 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23173 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23174 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23176 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23177 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23178 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23180 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23181 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23182 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23183 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23184 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23185 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23186 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23187 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23188 +#ifdef CONFIG_IPV6
23189 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23190 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23192 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23193 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23194 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23195 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23196 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23198 +#ifdef CONFIG_VSERVER_DEVICE
23199 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23200 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23202 + /* debug level admin commands */
23203 +#ifdef CONFIG_VSERVER_HISTORY
23204 + __VCMD(dump_history, 9, VCA_NONE, 0);
23205 + __VCMD(read_history, 9, VCA_NONE, 0);
23212 + vxdprintk(VXD_CBIT(switch, 0),
23213 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23214 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23215 + VC_VERSION(cmd), id, data, compat,
23216 + perm, args, flags);
23223 + if (!capable(CAP_CONTEXT))
23227 + /* moved here from the individual commands */
23229 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23233 + /* vcmd involves resource management */
23235 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23239 + /* various legacy exceptions */
23241 + /* will go away when spectator is a cap */
23242 + case VCMD_ctx_migrate_v0:
23243 + case VCMD_ctx_migrate:
23245 + current->xid = 1;
23251 + /* will go away when spectator is a cap */
23252 + case VCMD_net_migrate:
23254 + current->nid = 1;
23261 + /* vcmds are fine by default */
23264 + /* admin type vcmds require admin ... */
23265 + if (flags & VCF_ADMIN)
23266 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23268 + /* ... but setup type vcmds override that */
23269 + if (!permit && (flags & VCF_SETUP))
23270 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23278 + if (!id && (flags & VCF_ZIDOK))
23282 + if (args & VCA_VXI) {
23283 + vxi = lookup_vx_info(id);
23287 + if ((flags & VCF_ADMIN) &&
23288 + /* special case kill for shutdown */
23289 + (cmd != VCMD_ctx_kill) &&
23290 + /* can context be administrated? */
23291 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23297 + if (args & VCA_NXI) {
23298 + nxi = lookup_nx_info(id);
23302 + if ((flags & VCF_ADMIN) &&
23303 + /* can context be administrated? */
23304 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23311 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23314 + if ((args & VCA_NXI) && nxi)
23315 + put_nx_info(nxi);
23317 + if ((args & VCA_VXI) && vxi)
23318 + put_vx_info(vxi);
23320 + vxdprintk(VXD_CBIT(switch, 1),
23321 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23322 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23323 + VC_VERSION(cmd), ret, ret, state, permit);
23328 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23330 + return do_vserver(cmd, id, data, 0);
23333 +#ifdef CONFIG_COMPAT
23336 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23338 + return do_vserver(cmd, id, data, 1);
23341 +#endif /* CONFIG_COMPAT */
23342 diff -NurpP --minimal linux-3.9.4/kernel/vserver/sysctl.c linux-3.9.4-vs2.3.6.3/kernel/vserver/sysctl.c
23343 --- linux-3.9.4/kernel/vserver/sysctl.c 1970-01-01 00:00:00.000000000 +0000
23344 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/sysctl.c 2013-05-31 14:47:11.000000000 +0000
23347 + * kernel/vserver/sysctl.c
23349 + * Virtual Context Support
23351 + * Copyright (C) 2004-2007 Herbert Pötzl
23353 + * V0.01 basic structure
23357 +#include <linux/module.h>
23358 +#include <linux/ctype.h>
23359 +#include <linux/sysctl.h>
23360 +#include <linux/parser.h>
23361 +#include <asm/uaccess.h>
23364 + CTL_DEBUG_ERROR = 0,
23365 + CTL_DEBUG_SWITCH = 1,
23381 +unsigned int vs_debug_switch = 0;
23382 +unsigned int vs_debug_xid = 0;
23383 +unsigned int vs_debug_nid = 0;
23384 +unsigned int vs_debug_tag = 0;
23385 +unsigned int vs_debug_net = 0;
23386 +unsigned int vs_debug_limit = 0;
23387 +unsigned int vs_debug_cres = 0;
23388 +unsigned int vs_debug_dlim = 0;
23389 +unsigned int vs_debug_quota = 0;
23390 +unsigned int vs_debug_cvirt = 0;
23391 +unsigned int vs_debug_space = 0;
23392 +unsigned int vs_debug_perm = 0;
23393 +unsigned int vs_debug_misc = 0;
23396 +static struct ctl_table_header *vserver_table_header;
23397 +static ctl_table vserver_root_table[];
23400 +void vserver_register_sysctl(void)
23402 + if (!vserver_table_header) {
23403 + vserver_table_header = register_sysctl_table(vserver_root_table);
23408 +void vserver_unregister_sysctl(void)
23410 + if (vserver_table_header) {
23411 + unregister_sysctl_table(vserver_table_header);
23412 + vserver_table_header = NULL;
23417 +static int proc_dodebug(ctl_table *table, int write,
23418 + void __user *buffer, size_t *lenp, loff_t *ppos)
23420 + char tmpbuf[20], *p, c;
23421 + unsigned int value;
23422 + size_t left, len;
23424 + if ((*ppos && !write) || !*lenp) {
23432 + if (!access_ok(VERIFY_READ, buffer, left))
23434 + p = (char *)buffer;
23435 + while (left && __get_user(c, p) >= 0 && isspace(c))
23440 + if (left > sizeof(tmpbuf) - 1)
23442 + if (copy_from_user(tmpbuf, p, left))
23444 + tmpbuf[left] = '\0';
23446 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23447 + value = 10 * value + (*p - '0');
23448 + if (*p && !isspace(*p))
23450 + while (left && isspace(*p))
23452 + *(unsigned int *)table->data = value;
23454 + if (!access_ok(VERIFY_WRITE, buffer, left))
23456 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23459 + if (__copy_to_user(buffer, tmpbuf, len))
23461 + if ((left -= len) > 0) {
23462 + if (put_user('\n', (char *)buffer + len))
23476 +#define CTL_ENTRY(ctl, name) \
23478 + .procname = #name, \
23479 + .data = &vs_ ## name, \
23480 + .maxlen = sizeof(int), \
23482 + .proc_handler = &proc_dodebug, \
23483 + .extra1 = &zero, \
23484 + .extra2 = &zero, \
23487 +static ctl_table vserver_debug_table[] = {
23488 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23489 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23490 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23491 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23492 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23493 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23494 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23495 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23496 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23497 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23498 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23499 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23500 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23504 +static ctl_table vserver_root_table[] = {
23506 + .procname = "vserver",
23508 + .child = vserver_debug_table
23514 +static match_table_t tokens = {
23515 + { CTL_DEBUG_SWITCH, "switch=%x" },
23516 + { CTL_DEBUG_XID, "xid=%x" },
23517 + { CTL_DEBUG_NID, "nid=%x" },
23518 + { CTL_DEBUG_TAG, "tag=%x" },
23519 + { CTL_DEBUG_NET, "net=%x" },
23520 + { CTL_DEBUG_LIMIT, "limit=%x" },
23521 + { CTL_DEBUG_CRES, "cres=%x" },
23522 + { CTL_DEBUG_DLIM, "dlim=%x" },
23523 + { CTL_DEBUG_QUOTA, "quota=%x" },
23524 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23525 + { CTL_DEBUG_SPACE, "space=%x" },
23526 + { CTL_DEBUG_PERM, "perm=%x" },
23527 + { CTL_DEBUG_MISC, "misc=%x" },
23528 + { CTL_DEBUG_ERROR, NULL }
23531 +#define HANDLE_CASE(id, name, val) \
23532 + case CTL_DEBUG_ ## id: \
23533 + vs_debug_ ## name = val; \
23534 + printk("vs_debug_" #name "=0x%x\n", val); \
23538 +static int __init vs_debug_setup(char *str)
23543 + printk("vs_debug_setup(%s)\n", str);
23544 + while ((p = strsep(&str, ",")) != NULL) {
23545 + substring_t args[MAX_OPT_ARGS];
23546 + unsigned int value;
23551 + token = match_token(p, tokens, args);
23552 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23555 + HANDLE_CASE(SWITCH, switch, value);
23556 + HANDLE_CASE(XID, xid, value);
23557 + HANDLE_CASE(NID, nid, value);
23558 + HANDLE_CASE(TAG, tag, value);
23559 + HANDLE_CASE(NET, net, value);
23560 + HANDLE_CASE(LIMIT, limit, value);
23561 + HANDLE_CASE(CRES, cres, value);
23562 + HANDLE_CASE(DLIM, dlim, value);
23563 + HANDLE_CASE(QUOTA, quota, value);
23564 + HANDLE_CASE(CVIRT, cvirt, value);
23565 + HANDLE_CASE(SPACE, space, value);
23566 + HANDLE_CASE(PERM, perm, value);
23567 + HANDLE_CASE(MISC, misc, value);
23576 +__setup("vsdebug=", vs_debug_setup);
23580 +EXPORT_SYMBOL_GPL(vs_debug_switch);
23581 +EXPORT_SYMBOL_GPL(vs_debug_xid);
23582 +EXPORT_SYMBOL_GPL(vs_debug_nid);
23583 +EXPORT_SYMBOL_GPL(vs_debug_net);
23584 +EXPORT_SYMBOL_GPL(vs_debug_limit);
23585 +EXPORT_SYMBOL_GPL(vs_debug_cres);
23586 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
23587 +EXPORT_SYMBOL_GPL(vs_debug_quota);
23588 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
23589 +EXPORT_SYMBOL_GPL(vs_debug_space);
23590 +EXPORT_SYMBOL_GPL(vs_debug_perm);
23591 +EXPORT_SYMBOL_GPL(vs_debug_misc);
23593 diff -NurpP --minimal linux-3.9.4/kernel/vserver/tag.c linux-3.9.4-vs2.3.6.3/kernel/vserver/tag.c
23594 --- linux-3.9.4/kernel/vserver/tag.c 1970-01-01 00:00:00.000000000 +0000
23595 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/tag.c 2013-05-31 14:47:11.000000000 +0000
23598 + * linux/kernel/vserver/tag.c
23600 + * Virtual Server: Shallow Tag Space
23602 + * Copyright (C) 2007 Herbert Pötzl
23604 + * V0.01 basic implementation
23608 +#include <linux/sched.h>
23609 +#include <linux/vserver/debug.h>
23610 +#include <linux/vs_pid.h>
23611 +#include <linux/vs_tag.h>
23613 +#include <linux/vserver/tag_cmd.h>
23616 +int dx_migrate_task(struct task_struct *p, tag_t tag)
23621 + vxdprintk(VXD_CBIT(tag, 5),
23622 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23628 + vxdprintk(VXD_CBIT(tag, 5),
23629 + "moved task %p into [#%d]", p, tag);
23633 +/* vserver syscall commands below here */
23635 +/* taks xid and vx_info functions */
23638 +int vc_task_tag(uint32_t id)
23643 + struct task_struct *tsk;
23645 + tsk = find_task_by_real_pid(id);
23646 + tag = (tsk) ? tsk->tag : -ESRCH;
23647 + rcu_read_unlock();
23649 + tag = dx_current_tag();
23654 +int vc_tag_migrate(uint32_t tag)
23656 + return dx_migrate_task(current, tag & 0xFFFF);
23660 diff -NurpP --minimal linux-3.9.4/kernel/vserver/vci_config.h linux-3.9.4-vs2.3.6.3/kernel/vserver/vci_config.h
23661 --- linux-3.9.4/kernel/vserver/vci_config.h 1970-01-01 00:00:00.000000000 +0000
23662 +++ linux-3.9.4-vs2.3.6.3/kernel/vserver/vci_config.h 2013-05-31 14:47:11.000000000 +0000
23665 +/* interface version */
23667 +#define VCI_VERSION 0x00020308
23671 + VCI_KCBIT_NO_DYNAMIC = 0,
23673 + VCI_KCBIT_PROC_SECURE = 4,
23674 + /* VCI_KCBIT_HARDCPU = 5, */
23675 + /* VCI_KCBIT_IDLELIMIT = 6, */
23676 + /* VCI_KCBIT_IDLETIME = 7, */
23678 + VCI_KCBIT_COWBL = 8,
23679 + VCI_KCBIT_FULLCOWBL = 9,
23680 + VCI_KCBIT_SPACES = 10,
23681 + VCI_KCBIT_NETV2 = 11,
23682 + VCI_KCBIT_MEMCG = 12,
23683 + VCI_KCBIT_MEMCG_SWAP = 13,
23685 + VCI_KCBIT_DEBUG = 16,
23686 + VCI_KCBIT_HISTORY = 20,
23687 + VCI_KCBIT_TAGGED = 24,
23688 + VCI_KCBIT_PPTAG = 28,
23690 + VCI_KCBIT_MORE = 31,
23694 +static inline uint32_t vci_kernel_config(void)
23697 + (1 << VCI_KCBIT_NO_DYNAMIC) |
23699 + /* configured features */
23700 +#ifdef CONFIG_VSERVER_PROC_SECURE
23701 + (1 << VCI_KCBIT_PROC_SECURE) |
23703 +#ifdef CONFIG_VSERVER_COWBL
23704 + (1 << VCI_KCBIT_COWBL) |
23705 + (1 << VCI_KCBIT_FULLCOWBL) |
23707 + (1 << VCI_KCBIT_SPACES) |
23708 + (1 << VCI_KCBIT_NETV2) |
23709 +#ifdef CONFIG_MEMCG
23710 + (1 << VCI_KCBIT_MEMCG) |
23712 +#ifdef CONFIG_MEMCG_SWAP
23713 + (1 << VCI_KCBIT_MEMCG_SWAP) |
23716 + /* debug options */
23717 +#ifdef CONFIG_VSERVER_DEBUG
23718 + (1 << VCI_KCBIT_DEBUG) |
23720 +#ifdef CONFIG_VSERVER_HISTORY
23721 + (1 << VCI_KCBIT_HISTORY) |
23724 + /* inode context tagging */
23725 +#if defined(CONFIG_TAGGING_NONE)
23726 + (0 << VCI_KCBIT_TAGGED) |
23727 +#elif defined(CONFIG_TAGGING_UID16)
23728 + (1 << VCI_KCBIT_TAGGED) |
23729 +#elif defined(CONFIG_TAGGING_GID16)
23730 + (2 << VCI_KCBIT_TAGGED) |
23731 +#elif defined(CONFIG_TAGGING_ID24)
23732 + (3 << VCI_KCBIT_TAGGED) |
23733 +#elif defined(CONFIG_TAGGING_INTERN)
23734 + (4 << VCI_KCBIT_TAGGED) |
23735 +#elif defined(CONFIG_TAGGING_RUNTIME)
23736 + (5 << VCI_KCBIT_TAGGED) |
23738 + (7 << VCI_KCBIT_TAGGED) |
23740 + (1 << VCI_KCBIT_PPTAG) |
23744 diff -NurpP --minimal linux-3.9.4/mm/memcontrol.c linux-3.9.4-vs2.3.6.3/mm/memcontrol.c
23745 --- linux-3.9.4/mm/memcontrol.c 2013-05-31 13:45:31.000000000 +0000
23746 +++ linux-3.9.4-vs2.3.6.3/mm/memcontrol.c 2013-05-31 14:47:11.000000000 +0000
23747 @@ -1046,6 +1046,31 @@ struct mem_cgroup *mem_cgroup_from_task(
23748 return mem_cgroup_from_css(task_subsys_state(p, mem_cgroup_subsys_id));
23751 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
23753 + return res_counter_read_u64(&mem->res, member);
23756 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
23758 + return res_counter_read_u64(&mem->memsw, member);
23761 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
23763 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
23766 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
23768 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
23771 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
23773 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
23776 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
23778 struct mem_cgroup *memcg = NULL;
23779 diff -NurpP --minimal linux-3.9.4/mm/oom_kill.c linux-3.9.4-vs2.3.6.3/mm/oom_kill.c
23780 --- linux-3.9.4/mm/oom_kill.c 2013-05-31 13:45:31.000000000 +0000
23781 +++ linux-3.9.4-vs2.3.6.3/mm/oom_kill.c 2013-05-31 14:47:11.000000000 +0000
23783 #include <linux/freezer.h>
23784 #include <linux/ftrace.h>
23785 #include <linux/ratelimit.h>
23786 +#include <linux/reboot.h>
23787 +#include <linux/vs_context.h>
23789 #define CREATE_TRACE_POINTS
23790 #include <trace/events/oom.h>
23791 @@ -113,11 +115,18 @@ struct task_struct *find_lock_task_mm(st
23792 static bool oom_unkillable_task(struct task_struct *p,
23793 const struct mem_cgroup *memcg, const nodemask_t *nodemask)
23795 - if (is_global_init(p))
23796 + unsigned xid = vx_current_xid();
23798 + /* skip the init task, global and per guest */
23799 + if (task_is_init(p))
23801 if (p->flags & PF_KTHREAD)
23804 + /* skip other guest and host processes if oom in guest */
23805 + if (xid && vx_task_xid(p) != xid)
23808 /* When mem_cgroup_out_of_memory() and p is not member of the group */
23809 if (memcg && !task_in_mem_cgroup(p, memcg))
23811 @@ -426,8 +435,8 @@ void oom_kill_process(struct task_struct
23812 dump_header(p, gfp_mask, order, memcg, nodemask);
23815 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
23816 - message, task_pid_nr(p), p->comm, points);
23817 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
23818 + message, task_pid_nr(p), p->xid, p->comm, points);
23822 @@ -472,8 +481,8 @@ void oom_kill_process(struct task_struct
23824 /* mm cannot safely be dereferenced after task_unlock(victim) */
23826 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23827 - task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
23828 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23829 + task_pid_nr(victim), victim->xid, victim->comm, K(victim->mm->total_vm),
23830 K(get_mm_counter(victim->mm, MM_ANONPAGES)),
23831 K(get_mm_counter(victim->mm, MM_FILEPAGES)));
23832 task_unlock(victim);
23833 @@ -543,6 +552,8 @@ int unregister_oom_notifier(struct notif
23835 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
23837 +long vs_oom_action(unsigned int);
23840 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
23841 * if a parallel OOM killing is already taking place that includes a zone in
23842 @@ -655,7 +666,12 @@ void out_of_memory(struct zonelist *zone
23843 /* Found nothing?!?! Either we hang forever, or we panic. */
23845 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
23846 - panic("Out of memory and no killable processes...\n");
23848 + /* avoid panic for guest OOM */
23849 + if (vx_current_xid())
23850 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
23852 + panic("Out of memory and no killable processes...\n");
23854 if (PTR_ERR(p) != -1UL) {
23855 oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
23856 diff -NurpP --minimal linux-3.9.4/mm/page_alloc.c linux-3.9.4-vs2.3.6.3/mm/page_alloc.c
23857 --- linux-3.9.4/mm/page_alloc.c 2013-05-31 13:45:31.000000000 +0000
23858 +++ linux-3.9.4-vs2.3.6.3/mm/page_alloc.c 2013-05-31 15:08:50.000000000 +0000
23860 #include <linux/migrate.h>
23861 #include <linux/page-debug-flags.h>
23862 #include <linux/sched/rt.h>
23863 +#include <linux/vs_base.h>
23864 +#include <linux/vs_limit.h>
23866 #include <asm/tlbflush.h>
23867 #include <asm/div64.h>
23868 @@ -2873,6 +2875,9 @@ void si_meminfo(struct sysinfo *val)
23869 val->totalhigh = totalhigh_pages;
23870 val->freehigh = nr_free_highpages();
23871 val->mem_unit = PAGE_SIZE;
23873 + if (vx_flags(VXF_VIRT_MEM, 0))
23874 + vx_vsi_meminfo(val);
23877 EXPORT_SYMBOL(si_meminfo);
23878 @@ -2893,6 +2898,9 @@ void si_meminfo_node(struct sysinfo *val
23881 val->mem_unit = PAGE_SIZE;
23883 + if (vx_flags(VXF_VIRT_MEM, 0))
23884 + vx_vsi_meminfo(val);
23888 diff -NurpP --minimal linux-3.9.4/mm/pgtable-generic.c linux-3.9.4-vs2.3.6.3/mm/pgtable-generic.c
23889 --- linux-3.9.4/mm/pgtable-generic.c 2013-02-19 13:58:57.000000000 +0000
23890 +++ linux-3.9.4-vs2.3.6.3/mm/pgtable-generic.c 2013-05-31 14:47:11.000000000 +0000
23892 * Copyright (C) 2010 Linus Torvalds
23895 +#include <linux/mm.h>
23897 #include <linux/pagemap.h>
23898 #include <asm/tlb.h>
23899 #include <asm-generic/pgtable.h>
23900 diff -NurpP --minimal linux-3.9.4/mm/shmem.c linux-3.9.4-vs2.3.6.3/mm/shmem.c
23901 --- linux-3.9.4/mm/shmem.c 2013-05-31 13:45:31.000000000 +0000
23902 +++ linux-3.9.4-vs2.3.6.3/mm/shmem.c 2013-05-31 14:47:11.000000000 +0000
23903 @@ -1909,7 +1909,7 @@ static int shmem_statfs(struct dentry *d
23905 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
23907 - buf->f_type = TMPFS_MAGIC;
23908 + buf->f_type = TMPFS_SUPER_MAGIC;
23909 buf->f_bsize = PAGE_CACHE_SIZE;
23910 buf->f_namelen = NAME_MAX;
23911 if (sbinfo->max_blocks) {
23912 @@ -2606,7 +2606,7 @@ int shmem_fill_super(struct super_block
23913 sb->s_maxbytes = MAX_LFS_FILESIZE;
23914 sb->s_blocksize = PAGE_CACHE_SIZE;
23915 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
23916 - sb->s_magic = TMPFS_MAGIC;
23917 + sb->s_magic = TMPFS_SUPER_MAGIC;
23918 sb->s_op = &shmem_ops;
23919 sb->s_time_gran = 1;
23920 #ifdef CONFIG_TMPFS_XATTR
23921 diff -NurpP --minimal linux-3.9.4/mm/slab.c linux-3.9.4-vs2.3.6.3/mm/slab.c
23922 --- linux-3.9.4/mm/slab.c 2013-05-31 13:45:31.000000000 +0000
23923 +++ linux-3.9.4-vs2.3.6.3/mm/slab.c 2013-05-31 14:47:11.000000000 +0000
23924 @@ -429,6 +429,8 @@ static void kmem_list3_init(struct kmem_
23925 #define STATS_INC_FREEMISS(x) do { } while (0)
23928 +#include "slab_vs.h"
23933 @@ -3438,6 +3440,7 @@ retry:
23935 obj = slab_get_obj(cachep, slabp, nodeid);
23936 check_slabp(cachep, slabp);
23937 + vx_slab_alloc(cachep, flags);
23938 l3->free_objects--;
23939 /* move slabp to correct slabp list: */
23940 list_del(&slabp->list);
23941 @@ -3517,6 +3520,7 @@ slab_alloc_node(struct kmem_cache *cache
23942 /* ___cache_alloc_node can fall back to other nodes */
23943 ptr = ____cache_alloc_node(cachep, flags, nodeid);
23945 + vx_slab_alloc(cachep, flags);
23946 local_irq_restore(save_flags);
23947 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
23948 kmemleak_alloc_recursive(ptr, cachep->object_size, 1, cachep->flags,
23949 @@ -3709,6 +3713,7 @@ static inline void __cache_free(struct k
23951 kmemleak_free_recursive(objp, cachep->flags);
23952 objp = cache_free_debugcheck(cachep, objp, caller);
23953 + vx_slab_free(cachep);
23955 kmemcheck_slab_free(cachep, objp, cachep->object_size);
23957 diff -NurpP --minimal linux-3.9.4/mm/slab_vs.h linux-3.9.4-vs2.3.6.3/mm/slab_vs.h
23958 --- linux-3.9.4/mm/slab_vs.h 1970-01-01 00:00:00.000000000 +0000
23959 +++ linux-3.9.4-vs2.3.6.3/mm/slab_vs.h 2013-05-31 14:47:11.000000000 +0000
23962 +#include <linux/vserver/context.h>
23964 +#include <linux/vs_context.h>
23967 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
23969 + int what = gfp_zone(cachep->allocflags);
23970 + struct vx_info *vxi = current_vx_info();
23975 + atomic_add(cachep->size, &vxi->cacct.slab[what]);
23979 +void vx_slab_free(struct kmem_cache *cachep)
23981 + int what = gfp_zone(cachep->allocflags);
23982 + struct vx_info *vxi = current_vx_info();
23987 + atomic_sub(cachep->size, &vxi->cacct.slab[what]);
23990 diff -NurpP --minimal linux-3.9.4/mm/swapfile.c linux-3.9.4-vs2.3.6.3/mm/swapfile.c
23991 --- linux-3.9.4/mm/swapfile.c 2013-05-31 13:45:31.000000000 +0000
23992 +++ linux-3.9.4-vs2.3.6.3/mm/swapfile.c 2013-05-31 14:47:11.000000000 +0000
23994 #include <asm/tlbflush.h>
23995 #include <linux/swapops.h>
23996 #include <linux/page_cgroup.h>
23997 +#include <linux/vs_base.h>
23999 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24001 @@ -1767,6 +1768,16 @@ static int swap_show(struct seq_file *sw
24003 if (si == SEQ_START_TOKEN) {
24004 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24005 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24006 + struct sysinfo si;
24008 + vx_vsi_swapinfo(&si);
24009 + if (si.totalswap < (1 << 10))
24011 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24012 + "hdv0", "partition", si.totalswap >> 10,
24013 + (si.totalswap - si.freeswap) >> 10, -1);
24018 @@ -2195,6 +2206,8 @@ void si_swapinfo(struct sysinfo *val)
24019 val->freeswap = atomic_long_read(&nr_swap_pages) + nr_to_be_unused;
24020 val->totalswap = total_swap_pages + nr_to_be_unused;
24021 spin_unlock(&swap_lock);
24022 + if (vx_flags(VXF_VIRT_MEM, 0))
24023 + vx_vsi_swapinfo(val);
24027 diff -NurpP --minimal linux-3.9.4/net/bridge/br_multicast.c linux-3.9.4-vs2.3.6.3/net/bridge/br_multicast.c
24028 --- linux-3.9.4/net/bridge/br_multicast.c 2013-05-31 13:45:31.000000000 +0000
24029 +++ linux-3.9.4-vs2.3.6.3/net/bridge/br_multicast.c 2013-05-31 17:17:53.000000000 +0000
24030 @@ -443,7 +443,7 @@ static struct sk_buff *br_ip6_multicast_
24031 ip6h->hop_limit = 1;
24032 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24033 if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24035 + &ip6h->saddr, NULL)) {
24039 diff -NurpP --minimal linux-3.9.4/net/core/dev.c linux-3.9.4-vs2.3.6.3/net/core/dev.c
24040 --- linux-3.9.4/net/core/dev.c 2013-05-31 14:22:27.000000000 +0000
24041 +++ linux-3.9.4-vs2.3.6.3/net/core/dev.c 2013-05-31 18:37:38.000000000 +0000
24042 @@ -122,6 +122,7 @@
24043 #include <linux/in.h>
24044 #include <linux/jhash.h>
24045 #include <linux/random.h>
24046 +#include <linux/vs_inet.h>
24047 #include <trace/events/napi.h>
24048 #include <trace/events/net.h>
24049 #include <trace/events/skb.h>
24050 @@ -662,7 +663,8 @@ struct net_device *__dev_get_by_name(str
24051 struct hlist_head *head = dev_name_hash(net, name);
24053 hlist_for_each_entry(dev, head, name_hlist)
24054 - if (!strncmp(dev->name, name, IFNAMSIZ))
24055 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24056 + nx_dev_visible(current_nx_info(), dev))
24060 @@ -687,7 +689,8 @@ struct net_device *dev_get_by_name_rcu(s
24061 struct hlist_head *head = dev_name_hash(net, name);
24063 hlist_for_each_entry_rcu(dev, head, name_hlist)
24064 - if (!strncmp(dev->name, name, IFNAMSIZ))
24065 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24066 + nx_dev_visible(current_nx_info(), dev))
24070 @@ -737,7 +740,8 @@ struct net_device *__dev_get_by_index(st
24071 struct hlist_head *head = dev_index_hash(net, ifindex);
24073 hlist_for_each_entry(dev, head, index_hlist)
24074 - if (dev->ifindex == ifindex)
24075 + if ((dev->ifindex == ifindex) &&
24076 + nx_dev_visible(current_nx_info(), dev))
24080 @@ -755,7 +759,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24081 * about locking. The caller must hold RCU lock.
24084 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24085 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24087 struct net_device *dev;
24088 struct hlist_head *head = dev_index_hash(net, ifindex);
24089 @@ -766,6 +770,16 @@ struct net_device *dev_get_by_index_rcu(
24093 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24095 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24097 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24099 + if (nx_dev_visible(current_nx_info(), dev))
24103 EXPORT_SYMBOL(dev_get_by_index_rcu);
24106 @@ -814,7 +828,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24108 for_each_netdev_rcu(net, dev)
24109 if (dev->type == type &&
24110 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24111 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24112 + nx_dev_visible(current_nx_info(), dev))
24116 @@ -826,9 +841,11 @@ struct net_device *__dev_getfirstbyhwtyp
24117 struct net_device *dev;
24120 - for_each_netdev(net, dev)
24121 - if (dev->type == type)
24122 + for_each_netdev(net, dev) {
24123 + if ((dev->type == type) &&
24124 + nx_dev_visible(current_nx_info(), dev))
24130 @@ -840,7 +857,8 @@ struct net_device *dev_getfirstbyhwtype(
24133 for_each_netdev_rcu(net, dev)
24134 - if (dev->type == type) {
24135 + if ((dev->type == type) &&
24136 + nx_dev_visible(current_nx_info(), dev)) {
24140 @@ -868,7 +886,8 @@ struct net_device *dev_get_by_flags_rcu(
24143 for_each_netdev_rcu(net, dev) {
24144 - if (((dev->flags ^ if_flags) & mask) == 0) {
24145 + if ((((dev->flags ^ if_flags) & mask) == 0) &&
24146 + nx_dev_visible(current_nx_info(), dev)) {
24150 @@ -946,6 +965,8 @@ static int __dev_alloc_name(struct net *
24152 if (i < 0 || i >= max_netdevices)
24154 + if (!nx_dev_visible(current_nx_info(), d))
24157 /* avoid cases where sscanf is not exact inverse of printf */
24158 snprintf(buf, IFNAMSIZ, name, i);
24159 diff -NurpP --minimal linux-3.9.4/net/core/net-procfs.c linux-3.9.4-vs2.3.6.3/net/core/net-procfs.c
24160 --- linux-3.9.4/net/core/net-procfs.c 2013-05-31 13:45:32.000000000 +0000
24161 +++ linux-3.9.4-vs2.3.6.3/net/core/net-procfs.c 2013-06-01 10:40:52.000000000 +0000
24163 #include <linux/netdevice.h>
24164 #include <linux/proc_fs.h>
24165 #include <linux/seq_file.h>
24166 +#include <linux/vs_inet.h>
24167 #include <net/wext.h>
24169 #define BUCKET_SPACE (32 - NETDEV_HASHBITS - 1)
24170 @@ -77,8 +78,13 @@ static void dev_seq_stop(struct seq_file
24171 static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
24173 struct rtnl_link_stats64 temp;
24174 - const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24175 + const struct rtnl_link_stats64 *stats;
24177 + /* device visible inside network context? */
24178 + if (!nx_dev_visible(current_nx_info(), dev))
24181 + stats = dev_get_stats(dev, &temp);
24182 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24183 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24184 dev->name, stats->rx_bytes, stats->rx_packets,
24185 diff -NurpP --minimal linux-3.9.4/net/core/rtnetlink.c linux-3.9.4-vs2.3.6.3/net/core/rtnetlink.c
24186 --- linux-3.9.4/net/core/rtnetlink.c 2013-05-31 13:45:32.000000000 +0000
24187 +++ linux-3.9.4-vs2.3.6.3/net/core/rtnetlink.c 2013-05-31 17:17:54.000000000 +0000
24188 @@ -1085,6 +1085,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24189 hlist_for_each_entry_rcu(dev, head, index_hlist) {
24192 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24194 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24195 NETLINK_CB(cb->skb).portid,
24196 cb->nlh->nlmsg_seq, 0,
24197 @@ -1974,6 +1976,9 @@ void rtmsg_ifinfo(int type, struct net_d
24198 int err = -ENOBUFS;
24199 size_t if_info_size;
24201 + if (!nx_dev_visible(current_nx_info(), dev))
24204 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), GFP_KERNEL);
24207 diff -NurpP --minimal linux-3.9.4/net/core/sock.c linux-3.9.4-vs2.3.6.3/net/core/sock.c
24208 --- linux-3.9.4/net/core/sock.c 2013-05-31 14:22:27.000000000 +0000
24209 +++ linux-3.9.4-vs2.3.6.3/net/core/sock.c 2013-05-31 17:17:54.000000000 +0000
24210 @@ -132,6 +132,10 @@
24211 #include <net/netprio_cgroup.h>
24213 #include <linux/filter.h>
24214 +#include <linux/vs_socket.h>
24215 +#include <linux/vs_limit.h>
24216 +#include <linux/vs_context.h>
24217 +#include <linux/vs_network.h>
24219 #include <trace/events/sock.h>
24221 @@ -1257,6 +1261,8 @@ static struct sock *sk_prot_alloc(struct
24223 sk_tx_queue_clear(sk);
24225 + sock_vx_init(sk);
24226 + sock_nx_init(sk);
24230 @@ -1367,6 +1373,11 @@ static void __sk_free(struct sock *sk)
24231 put_cred(sk->sk_peer_cred);
24232 put_pid(sk->sk_peer_pid);
24233 put_net(sock_net(sk));
24235 + clr_vx_info(&sk->sk_vx_info);
24237 + clr_nx_info(&sk->sk_nx_info);
24239 sk_prot_free(sk->sk_prot_creator, sk);
24242 @@ -1427,6 +1438,8 @@ struct sock *sk_clone_lock(const struct
24245 get_net(sock_net(newsk));
24246 + sock_vx_init(newsk);
24247 + sock_nx_init(newsk);
24248 sk_node_init(&newsk->sk_node);
24249 sock_lock_init(newsk);
24250 bh_lock_sock(newsk);
24251 @@ -1483,6 +1496,12 @@ struct sock *sk_clone_lock(const struct
24253 atomic_set(&newsk->sk_refcnt, 2);
24255 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24256 + newsk->sk_xid = sk->sk_xid;
24257 + vx_sock_inc(newsk);
24258 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24259 + newsk->sk_nid = sk->sk_nid;
24262 * Increment the counter in the same struct proto as the master
24263 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24264 @@ -2278,6 +2297,12 @@ void sock_init_data(struct socket *sock,
24266 sk->sk_stamp = ktime_set(-1L, 0);
24268 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24269 + sk->sk_xid = vx_current_xid();
24271 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24272 + sk->sk_nid = nx_current_nid();
24275 * Before updating sk_refcnt, we must commit prior changes to memory
24276 * (Documentation/RCU/rculist_nulls.txt for details)
24277 diff -NurpP --minimal linux-3.9.4/net/ipv4/af_inet.c linux-3.9.4-vs2.3.6.3/net/ipv4/af_inet.c
24278 --- linux-3.9.4/net/ipv4/af_inet.c 2013-05-31 13:45:32.000000000 +0000
24279 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/af_inet.c 2013-06-03 17:22:33.000000000 +0000
24280 @@ -118,6 +118,7 @@
24281 #ifdef CONFIG_IP_MROUTE
24282 #include <linux/mroute.h>
24284 +#include <linux/vs_limit.h>
24287 /* The inetsw table contains everything that inet_create needs to
24288 @@ -336,10 +337,13 @@ lookup_protocol:
24292 + if ((protocol == IPPROTO_ICMP) &&
24293 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24295 if (sock->type == SOCK_RAW && !kern &&
24296 !ns_capable(net->user_ns, CAP_NET_RAW))
24297 goto out_rcu_unlock;
24300 sock->ops = answer->ops;
24301 answer_prot = answer->prot;
24302 answer_no_check = answer->no_check;
24303 @@ -460,6 +464,7 @@ int inet_bind(struct socket *sock, struc
24304 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24305 struct sock *sk = sock->sk;
24306 struct inet_sock *inet = inet_sk(sk);
24307 + struct nx_v4_sock_addr nsa;
24308 struct net *net = sock_net(sk);
24309 unsigned short snum;
24311 @@ -484,7 +489,11 @@ int inet_bind(struct socket *sock, struc
24315 - chk_addr_ret = inet_addr_type(net, addr->sin_addr.s_addr);
24316 + err = v4_map_sock_addr(inet, addr, &nsa);
24320 + chk_addr_ret = inet_addr_type(net, nsa.saddr);
24322 /* Not specified by any standard per-se, however it breaks too
24323 * many applications when removed. It is unfortunate since
24324 @@ -496,7 +505,7 @@ int inet_bind(struct socket *sock, struc
24325 err = -EADDRNOTAVAIL;
24326 if (!sysctl_ip_nonlocal_bind &&
24327 !(inet->freebind || inet->transparent) &&
24328 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24329 + nsa.saddr != htonl(INADDR_ANY) &&
24330 chk_addr_ret != RTN_LOCAL &&
24331 chk_addr_ret != RTN_MULTICAST &&
24332 chk_addr_ret != RTN_BROADCAST)
24333 @@ -522,7 +531,7 @@ int inet_bind(struct socket *sock, struc
24334 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24335 goto out_release_sock;
24337 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24338 + v4_set_sock_addr(inet, &nsa);
24339 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24340 inet->inet_saddr = 0; /* Use device */
24342 @@ -741,11 +750,13 @@ int inet_getname(struct socket *sock, st
24345 sin->sin_port = inet->inet_dport;
24346 - sin->sin_addr.s_addr = inet->inet_daddr;
24347 + sin->sin_addr.s_addr =
24348 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24350 __be32 addr = inet->inet_rcv_saddr;
24352 addr = inet->inet_saddr;
24353 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24354 sin->sin_port = inet->inet_sport;
24355 sin->sin_addr.s_addr = addr;
24357 diff -NurpP --minimal linux-3.9.4/net/ipv4/arp.c linux-3.9.4-vs2.3.6.3/net/ipv4/arp.c
24358 --- linux-3.9.4/net/ipv4/arp.c 2013-05-31 13:45:32.000000000 +0000
24359 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/arp.c 2013-05-31 17:17:54.000000000 +0000
24360 @@ -1317,6 +1317,7 @@ static void arp_format_neigh_entry(struc
24361 struct net_device *dev = n->dev;
24362 int hatype = dev->type;
24364 + /* FIXME: check for network context */
24365 read_lock(&n->lock);
24366 /* Convert hardware address to XX:XX:XX:XX ... form. */
24367 #if IS_ENABLED(CONFIG_AX25)
24368 @@ -1348,6 +1349,7 @@ static void arp_format_pneigh_entry(stru
24369 int hatype = dev ? dev->type : 0;
24372 + /* FIXME: check for network context */
24373 sprintf(tbuf, "%pI4", n->key);
24374 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24375 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24376 diff -NurpP --minimal linux-3.9.4/net/ipv4/devinet.c linux-3.9.4-vs2.3.6.3/net/ipv4/devinet.c
24377 --- linux-3.9.4/net/ipv4/devinet.c 2013-05-31 13:45:32.000000000 +0000
24378 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/devinet.c 2013-05-31 17:17:54.000000000 +0000
24379 @@ -522,6 +522,7 @@ struct in_device *inetdev_by_index(struc
24381 EXPORT_SYMBOL(inetdev_by_index);
24384 /* Called only from RTNL semaphored context. No locks. */
24386 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24387 @@ -940,6 +941,8 @@ int devinet_ioctl(struct net *net, unsig
24389 in_dev = __in_dev_get_rtnl(dev);
24391 + struct nx_info *nxi = current_nx_info();
24393 if (tryaddrmatch) {
24394 /* Matthias Andree */
24395 /* compare label and address (4.4BSD style) */
24396 @@ -948,6 +951,8 @@ int devinet_ioctl(struct net *net, unsig
24397 This is checked above. */
24398 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24399 ifap = &ifa->ifa_next) {
24400 + if (!nx_v4_ifa_visible(nxi, ifa))
24402 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24403 sin_orig.sin_addr.s_addr ==
24405 @@ -960,9 +965,12 @@ int devinet_ioctl(struct net *net, unsig
24406 comparing just the label */
24408 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24409 - ifap = &ifa->ifa_next)
24410 + ifap = &ifa->ifa_next) {
24411 + if (!nx_v4_ifa_visible(nxi, ifa))
24413 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24419 @@ -1116,6 +1124,8 @@ static int inet_gifconf(struct net_devic
24422 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24423 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24426 done += sizeof(ifr);
24428 @@ -1519,6 +1529,7 @@ static int inet_dump_ifaddr(struct sk_bu
24429 struct net_device *dev;
24430 struct in_device *in_dev;
24431 struct in_ifaddr *ifa;
24432 + struct sock *sk = skb->sk;
24433 struct hlist_head *head;
24436 @@ -1540,6 +1551,8 @@ static int inet_dump_ifaddr(struct sk_bu
24438 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24439 ifa = ifa->ifa_next, ip_idx++) {
24440 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24442 if (ip_idx < s_ip_idx)
24444 if (inet_fill_ifaddr(skb, ifa,
24445 diff -NurpP --minimal linux-3.9.4/net/ipv4/fib_trie.c linux-3.9.4-vs2.3.6.3/net/ipv4/fib_trie.c
24446 --- linux-3.9.4/net/ipv4/fib_trie.c 2013-05-31 13:45:32.000000000 +0000
24447 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/fib_trie.c 2013-05-31 17:17:54.000000000 +0000
24448 @@ -2548,6 +2548,7 @@ static int fib_route_seq_show(struct seq
24449 || fa->fa_type == RTN_MULTICAST)
24452 + /* FIXME: check for network context? */
24455 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24456 diff -NurpP --minimal linux-3.9.4/net/ipv4/inet_connection_sock.c linux-3.9.4-vs2.3.6.3/net/ipv4/inet_connection_sock.c
24457 --- linux-3.9.4/net/ipv4/inet_connection_sock.c 2013-05-31 13:45:32.000000000 +0000
24458 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/inet_connection_sock.c 2013-05-31 18:29:56.000000000 +0000
24459 @@ -53,6 +53,37 @@ void inet_get_local_port_range(int *low,
24461 EXPORT_SYMBOL(inet_get_local_port_range);
24463 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24465 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24466 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24468 + if (inet_v6_ipv6only(sk2))
24471 + if (sk1_rcv_saddr &&
24473 + sk1_rcv_saddr == sk2_rcv_saddr)
24476 + if (sk1_rcv_saddr &&
24477 + !sk2_rcv_saddr &&
24478 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24481 + if (sk2_rcv_saddr &&
24482 + !sk1_rcv_saddr &&
24483 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24486 + if (!sk1_rcv_saddr &&
24487 + !sk2_rcv_saddr &&
24488 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24494 int inet_csk_bind_conflict(const struct sock *sk,
24495 const struct inet_bind_bucket *tb, bool relax)
24497 @@ -79,17 +110,12 @@ int inet_csk_bind_conflict(const struct
24498 (!reuseport || !sk2->sk_reuseport ||
24499 (sk2->sk_state != TCP_TIME_WAIT &&
24500 !uid_eq(uid, sock_i_uid(sk2))))) {
24501 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24502 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24503 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24504 + if (ipv4_rcv_saddr_equal(sk, sk2))
24507 if (!relax && reuse && sk2->sk_reuse &&
24508 sk2->sk_state != TCP_LISTEN) {
24509 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24511 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24512 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24513 + if (ipv4_rcv_saddr_equal(sk, sk2))
24517 diff -NurpP --minimal linux-3.9.4/net/ipv4/inet_diag.c linux-3.9.4-vs2.3.6.3/net/ipv4/inet_diag.c
24518 --- linux-3.9.4/net/ipv4/inet_diag.c 2013-02-19 13:58:58.000000000 +0000
24519 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/inet_diag.c 2013-05-31 17:17:54.000000000 +0000
24522 #include <linux/inet.h>
24523 #include <linux/stddef.h>
24524 +#include <linux/vs_network.h>
24525 +#include <linux/vs_inet.h>
24527 #include <linux/inet_diag.h>
24528 #include <linux/sock_diag.h>
24529 @@ -106,8 +108,10 @@ int inet_sk_diag_fill(struct sock *sk, s
24531 r->id.idiag_sport = inet->inet_sport;
24532 r->id.idiag_dport = inet->inet_dport;
24533 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24534 - r->id.idiag_dst[0] = inet->inet_daddr;
24535 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24536 + inet->inet_rcv_saddr);
24537 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24538 + inet->inet_daddr);
24540 if (nla_put_u8(skb, INET_DIAG_SHUTDOWN, sk->sk_shutdown))
24542 @@ -242,8 +246,8 @@ static int inet_twsk_diag_fill(struct in
24543 sock_diag_save_cookie(tw, r->id.idiag_cookie);
24544 r->id.idiag_sport = tw->tw_sport;
24545 r->id.idiag_dport = tw->tw_dport;
24546 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24547 - r->id.idiag_dst[0] = tw->tw_daddr;
24548 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24549 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24550 r->idiag_state = tw->tw_substate;
24551 r->idiag_timer = 3;
24552 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
24553 @@ -287,12 +291,14 @@ int inet_diag_dump_one_icsk(struct inet_
24556 if (req->sdiag_family == AF_INET) {
24557 + /* TODO: lback */
24558 sk = inet_lookup(net, hashinfo, req->id.idiag_dst[0],
24559 req->id.idiag_dport, req->id.idiag_src[0],
24560 req->id.idiag_sport, req->id.idiag_if);
24562 #if IS_ENABLED(CONFIG_IPV6)
24563 else if (req->sdiag_family == AF_INET6) {
24564 + /* TODO: lback */
24565 sk = inet6_lookup(net, hashinfo,
24566 (struct in6_addr *)req->id.idiag_dst,
24567 req->id.idiag_dport,
24568 @@ -494,6 +500,7 @@ int inet_diag_bc_sk(const struct nlattr
24572 + /* TODO: lback */
24573 entry.saddr = &inet->inet_rcv_saddr;
24574 entry.daddr = &inet->inet_daddr;
24576 @@ -652,6 +659,7 @@ static int inet_twsk_diag_dump(struct in
24580 + /* TODO: lback */
24581 entry.saddr = &tw->tw_rcv_saddr;
24582 entry.daddr = &tw->tw_daddr;
24584 @@ -730,8 +738,8 @@ static int inet_diag_fill_req(struct sk_
24586 r->id.idiag_sport = inet->inet_sport;
24587 r->id.idiag_dport = ireq->rmt_port;
24588 - r->id.idiag_src[0] = ireq->loc_addr;
24589 - r->id.idiag_dst[0] = ireq->rmt_addr;
24590 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
24591 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
24592 r->idiag_expires = jiffies_to_msecs(tmo);
24593 r->idiag_rqueue = 0;
24594 r->idiag_wqueue = 0;
24595 @@ -794,6 +802,7 @@ static int inet_diag_dump_reqs(struct sk
24599 + /* TODO: lback */
24601 inet_diag_req_addrs(sk, req, &entry);
24602 entry.dport = ntohs(ireq->rmt_port);
24603 @@ -850,6 +859,8 @@ void inet_diag_dump_icsk(struct inet_has
24604 if (!net_eq(sock_net(sk), net))
24607 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24612 @@ -922,6 +933,8 @@ skip_listen_ht:
24614 if (!net_eq(sock_net(sk), net))
24616 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24620 if (!(r->idiag_states & (1 << sk->sk_state)))
24621 @@ -950,7 +963,8 @@ next_normal:
24623 if (!net_eq(twsk_net(tw), net))
24626 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24630 if (r->sdiag_family != AF_UNSPEC &&
24631 diff -NurpP --minimal linux-3.9.4/net/ipv4/inet_hashtables.c linux-3.9.4-vs2.3.6.3/net/ipv4/inet_hashtables.c
24632 --- linux-3.9.4/net/ipv4/inet_hashtables.c 2013-05-31 13:45:32.000000000 +0000
24633 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/inet_hashtables.c 2013-05-31 18:20:50.000000000 +0000
24635 #include <net/inet_connection_sock.h>
24636 #include <net/inet_hashtables.h>
24637 #include <net/secure_seq.h>
24638 +#include <net/route.h>
24639 #include <net/ip.h>
24642 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
24643 if (rcv_saddr != daddr)
24647 + /* block non nx_info ips */
24648 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24649 + daddr, NXA_MASK_BIND))
24652 if (sk->sk_bound_dev_if) {
24653 if (sk->sk_bound_dev_if != dif)
24654 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
24655 * wildcarded during the search since they can never be otherwise.
24659 struct sock *__inet_lookup_listener(struct net *net,
24660 struct inet_hashinfo *hashinfo,
24661 const __be32 saddr, __be16 sport,
24662 @@ -209,6 +214,7 @@ begin:
24663 phash = next_pseudo_random32(phash);
24668 * if the nulls value we got at the end of this lookup is
24669 * not the expected one, we must restart lookup.
24670 diff -NurpP --minimal linux-3.9.4/net/ipv4/netfilter.c linux-3.9.4-vs2.3.6.3/net/ipv4/netfilter.c
24671 --- linux-3.9.4/net/ipv4/netfilter.c 2012-12-11 03:30:57.000000000 +0000
24672 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/netfilter.c 2013-05-31 17:17:54.000000000 +0000
24674 #include <linux/skbuff.h>
24675 #include <linux/gfp.h>
24676 #include <linux/export.h>
24677 -#include <net/route.h>
24678 +// #include <net/route.h>
24679 #include <net/xfrm.h>
24680 #include <net/ip.h>
24681 #include <net/netfilter/nf_queue.h>
24682 diff -NurpP --minimal linux-3.9.4/net/ipv4/raw.c linux-3.9.4-vs2.3.6.3/net/ipv4/raw.c
24683 --- linux-3.9.4/net/ipv4/raw.c 2013-05-31 13:45:32.000000000 +0000
24684 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/raw.c 2013-05-31 18:19:38.000000000 +0000
24685 @@ -116,7 +116,7 @@ static struct sock *__raw_v4_lookup(stru
24687 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
24688 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
24689 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
24690 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
24691 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
24692 goto found; /* gotcha */
24694 @@ -395,6 +395,12 @@ static int raw_send_hdrinc(struct sock *
24695 icmp_out_count(net, ((struct icmphdr *)
24696 skb_transport_header(skb))->type);
24699 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
24700 + sk->sk_nx_info &&
24701 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
24704 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
24705 rt->dst.dev, dst_output);
24707 @@ -580,6 +586,16 @@ static int raw_sendmsg(struct kiocb *ioc
24711 + if (sk->sk_nx_info) {
24712 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
24713 + if (IS_ERR(rt)) {
24714 + err = PTR_ERR(rt);
24721 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
24722 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
24724 @@ -656,17 +672,19 @@ static int raw_bind(struct sock *sk, str
24726 struct inet_sock *inet = inet_sk(sk);
24727 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
24728 + struct nx_v4_sock_addr nsa = { 0 };
24732 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
24734 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24735 + v4_map_sock_addr(inet, addr, &nsa);
24736 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24737 ret = -EADDRNOTAVAIL;
24738 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
24739 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
24740 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
24742 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24743 + v4_set_sock_addr(inet, &nsa);
24744 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24745 inet->inet_saddr = 0; /* Use device */
24747 @@ -718,7 +736,8 @@ static int raw_recvmsg(struct kiocb *ioc
24748 /* Copy the address. */
24750 sin->sin_family = AF_INET;
24751 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24752 + sin->sin_addr.s_addr =
24753 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
24755 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
24757 @@ -913,7 +932,8 @@ static struct sock *raw_get_first(struct
24758 for (state->bucket = 0; state->bucket < RAW_HTABLE_SIZE;
24760 sk_for_each(sk, &state->h->ht[state->bucket])
24761 - if (sock_net(sk) == seq_file_net(seq))
24762 + if ((sock_net(sk) == seq_file_net(seq)) &&
24763 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24767 @@ -929,7 +949,8 @@ static struct sock *raw_get_next(struct
24771 - } while (sk && sock_net(sk) != seq_file_net(seq));
24772 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
24773 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24775 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
24776 sk = sk_head(&state->h->ht[state->bucket]);
24777 diff -NurpP --minimal linux-3.9.4/net/ipv4/route.c linux-3.9.4-vs2.3.6.3/net/ipv4/route.c
24778 --- linux-3.9.4/net/ipv4/route.c 2013-05-31 13:45:32.000000000 +0000
24779 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/route.c 2013-05-31 17:17:54.000000000 +0000
24780 @@ -1998,7 +1998,7 @@ struct rtable *__ip_route_output_key(str
24783 if (fl4->flowi4_oif) {
24784 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
24785 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
24786 rth = ERR_PTR(-ENODEV);
24787 if (dev_out == NULL)
24789 diff -NurpP --minimal linux-3.9.4/net/ipv4/tcp.c linux-3.9.4-vs2.3.6.3/net/ipv4/tcp.c
24790 --- linux-3.9.4/net/ipv4/tcp.c 2013-05-31 13:45:32.000000000 +0000
24791 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/tcp.c 2013-05-31 17:17:54.000000000 +0000
24792 @@ -268,6 +268,7 @@
24793 #include <linux/crypto.h>
24794 #include <linux/time.h>
24795 #include <linux/slab.h>
24796 +#include <linux/in.h>
24798 #include <net/icmp.h>
24799 #include <net/inet_common.h>
24800 diff -NurpP --minimal linux-3.9.4/net/ipv4/tcp_ipv4.c linux-3.9.4-vs2.3.6.3/net/ipv4/tcp_ipv4.c
24801 --- linux-3.9.4/net/ipv4/tcp_ipv4.c 2013-05-31 13:45:32.000000000 +0000
24802 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/tcp_ipv4.c 2013-05-31 17:17:54.000000000 +0000
24803 @@ -2260,6 +2260,12 @@ static void *listening_get_next(struct s
24804 req = req->dl_next;
24807 + vxdprintk(VXD_CBIT(net, 6),
24808 + "sk,req: %p [#%d] (from %d)", req->sk,
24809 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
24811 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
24813 if (req->rsk_ops->family == st->family) {
24816 @@ -2284,6 +2290,10 @@ get_req:
24819 sk_nulls_for_each_from(sk, node) {
24820 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
24821 + sk, sk->sk_nid, nx_current_nid());
24822 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24824 if (!net_eq(sock_net(sk), net))
24826 if (sk->sk_family == st->family) {
24827 @@ -2360,6 +2370,11 @@ static void *established_get_first(struc
24829 spin_lock_bh(lock);
24830 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
24831 + vxdprintk(VXD_CBIT(net, 6),
24832 + "sk,egf: %p [#%d] (from %d)",
24833 + sk, sk->sk_nid, nx_current_nid());
24834 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24836 if (sk->sk_family != st->family ||
24837 !net_eq(sock_net(sk), net)) {
24839 @@ -2370,6 +2385,11 @@ static void *established_get_first(struc
24840 st->state = TCP_SEQ_STATE_TIME_WAIT;
24841 inet_twsk_for_each(tw, node,
24842 &tcp_hashinfo.ehash[st->bucket].twchain) {
24843 + vxdprintk(VXD_CBIT(net, 6),
24844 + "tw: %p [#%d] (from %d)",
24845 + tw, tw->tw_nid, nx_current_nid());
24846 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24848 if (tw->tw_family != st->family ||
24849 !net_eq(twsk_net(tw), net)) {
24851 @@ -2399,7 +2419,9 @@ static void *established_get_next(struct
24855 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
24856 + while (tw && (tw->tw_family != st->family ||
24857 + !net_eq(twsk_net(tw), net) ||
24858 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
24862 @@ -2423,6 +2445,11 @@ get_tw:
24863 sk = sk_nulls_next(sk);
24865 sk_nulls_for_each_from(sk, node) {
24866 + vxdprintk(VXD_CBIT(net, 6),
24867 + "sk,egn: %p [#%d] (from %d)",
24868 + sk, sk->sk_nid, nx_current_nid());
24869 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24871 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
24874 @@ -2628,9 +2655,9 @@ static void get_openreq4(const struct so
24875 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
24876 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
24879 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
24880 ntohs(inet_sk(sk)->inet_sport),
24882 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
24883 ntohs(ireq->rmt_port),
24885 0, 0, /* could print option size, but that is af dependent. */
24886 @@ -2653,8 +2680,8 @@ static void get_tcp4_sock(struct sock *s
24887 const struct inet_connection_sock *icsk = inet_csk(sk);
24888 const struct inet_sock *inet = inet_sk(sk);
24889 struct fastopen_queue *fastopenq = icsk->icsk_accept_queue.fastopenq;
24890 - __be32 dest = inet->inet_daddr;
24891 - __be32 src = inet->inet_rcv_saddr;
24892 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
24893 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
24894 __u16 destp = ntohs(inet->inet_dport);
24895 __u16 srcp = ntohs(inet->inet_sport);
24897 @@ -2710,8 +2737,8 @@ static void get_timewait4_sock(const str
24899 long delta = tw->tw_ttd - jiffies;
24901 - dest = tw->tw_daddr;
24902 - src = tw->tw_rcv_saddr;
24903 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
24904 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
24905 destp = ntohs(tw->tw_dport);
24906 srcp = ntohs(tw->tw_sport);
24908 diff -NurpP --minimal linux-3.9.4/net/ipv4/tcp_minisocks.c linux-3.9.4-vs2.3.6.3/net/ipv4/tcp_minisocks.c
24909 --- linux-3.9.4/net/ipv4/tcp_minisocks.c 2013-05-31 14:22:27.000000000 +0000
24910 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/tcp_minisocks.c 2013-05-31 17:17:54.000000000 +0000
24912 #include <linux/slab.h>
24913 #include <linux/sysctl.h>
24914 #include <linux/workqueue.h>
24915 +#include <linux/vs_limit.h>
24916 +#include <linux/vs_socket.h>
24917 +#include <linux/vs_context.h>
24918 #include <net/tcp.h>
24919 #include <net/inet_common.h>
24920 #include <net/xfrm.h>
24921 @@ -291,6 +294,11 @@ void tcp_time_wait(struct sock *sk, int
24922 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
24923 tcptw->tw_ts_offset = tp->tsoffset;
24925 + tw->tw_xid = sk->sk_xid;
24926 + tw->tw_vx_info = NULL;
24927 + tw->tw_nid = sk->sk_nid;
24928 + tw->tw_nx_info = NULL;
24930 #if IS_ENABLED(CONFIG_IPV6)
24931 if (tw->tw_family == PF_INET6) {
24932 struct ipv6_pinfo *np = inet6_sk(sk);
24933 diff -NurpP --minimal linux-3.9.4/net/ipv4/udp.c linux-3.9.4-vs2.3.6.3/net/ipv4/udp.c
24934 --- linux-3.9.4/net/ipv4/udp.c 2013-05-31 13:45:32.000000000 +0000
24935 +++ linux-3.9.4-vs2.3.6.3/net/ipv4/udp.c 2013-05-31 18:26:00.000000000 +0000
24936 @@ -306,14 +306,7 @@ fail:
24938 EXPORT_SYMBOL(udp_lib_get_port);
24940 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24942 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
24944 - return (!ipv6_only_sock(sk2) &&
24945 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
24946 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
24948 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
24950 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
24952 @@ -348,6 +341,11 @@ static inline int compute_score(struct s
24953 if (inet->inet_rcv_saddr != daddr)
24957 + /* block non nx_info ips */
24958 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24959 + daddr, NXA_MASK_BIND))
24962 if (inet->inet_daddr) {
24963 if (inet->inet_daddr != saddr)
24964 @@ -458,6 +456,7 @@ begin:
24969 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
24970 * harder than this. -DaveM
24972 @@ -504,6 +503,11 @@ begin:
24973 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
24974 score = compute_score(sk, net, saddr, hnum, sport,
24975 daddr, dport, dif);
24976 + /* FIXME: disabled?
24977 + if (score == 9) {
24981 if (score > badness) {
24984 @@ -528,6 +532,7 @@ begin:
24985 if (get_nulls_value(node) != slot)
24990 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
24992 @@ -537,6 +542,7 @@ begin:
25000 @@ -580,8 +586,7 @@ static inline struct sock *udp_v4_mcast_
25001 udp_sk(s)->udp_port_hash != hnum ||
25002 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25003 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25004 - (inet->inet_rcv_saddr &&
25005 - inet->inet_rcv_saddr != loc_addr) ||
25006 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25007 ipv6_only_sock(s) ||
25008 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25010 @@ -964,6 +969,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
25011 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
25012 faddr, saddr, dport, inet->inet_sport);
25014 + if (sk->sk_nx_info) {
25015 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
25016 + if (IS_ERR(rt)) {
25017 + err = PTR_ERR(rt);
25024 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
25025 rt = ip_route_output_flow(net, fl4, sk);
25027 @@ -1269,7 +1284,8 @@ try_again:
25029 sin->sin_family = AF_INET;
25030 sin->sin_port = udp_hdr(skb)->source;
25031 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25032 + sin->sin_addr.s_addr = nx_map_sock_lback(
25033 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25034 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25036 if (inet->cmsg_flags)
25037 @@ -2025,6 +2041,8 @@ static struct sock *udp_get_first(struct
25038 sk_nulls_for_each(sk, node, &hslot->head) {
25039 if (!net_eq(sock_net(sk), net))
25041 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25043 if (sk->sk_family == state->family)
25046 @@ -2042,7 +2060,9 @@ static struct sock *udp_get_next(struct
25049 sk = sk_nulls_next(sk);
25050 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25051 + } while (sk && (!net_eq(sock_net(sk), net) ||
25052 + sk->sk_family != state->family ||
25053 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25056 if (state->bucket <= state->udp_table->mask)
25057 @@ -2138,8 +2158,8 @@ static void udp4_format_sock(struct sock
25058 int bucket, int *len)
25060 struct inet_sock *inet = inet_sk(sp);
25061 - __be32 dest = inet->inet_daddr;
25062 - __be32 src = inet->inet_rcv_saddr;
25063 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
25064 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
25065 __u16 destp = ntohs(inet->inet_dport);
25066 __u16 srcp = ntohs(inet->inet_sport);
25068 diff -NurpP --minimal linux-3.9.4/net/ipv6/Kconfig linux-3.9.4-vs2.3.6.3/net/ipv6/Kconfig
25069 --- linux-3.9.4/net/ipv6/Kconfig 2013-05-31 13:45:32.000000000 +0000
25070 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/Kconfig 2013-05-31 17:17:54.000000000 +0000
25073 # IPv6 as module will cause a CRASH if you try to unload it
25075 - tristate "The IPv6 protocol"
25077 + bool "The IPv6 protocol"
25080 This is complemental support for the IP version 6.
25081 You will still be able to do traditional IPv4 networking as well.
25082 diff -NurpP --minimal linux-3.9.4/net/ipv6/addrconf.c linux-3.9.4-vs2.3.6.3/net/ipv6/addrconf.c
25083 --- linux-3.9.4/net/ipv6/addrconf.c 2013-05-31 13:45:32.000000000 +0000
25084 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/addrconf.c 2013-05-31 20:07:39.000000000 +0000
25086 #include <linux/proc_fs.h>
25087 #include <linux/seq_file.h>
25088 #include <linux/export.h>
25089 +#include <linux/vs_network.h>
25090 +#include <linux/vs_inet6.h>
25092 /* Set to 3 to get tracing... */
25093 #define ACONF_DEBUG 2
25094 @@ -1250,7 +1252,7 @@ out:
25096 int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
25097 const struct in6_addr *daddr, unsigned int prefs,
25098 - struct in6_addr *saddr)
25099 + struct in6_addr *saddr, struct nx_info *nxi)
25101 struct ipv6_saddr_score scores[2],
25102 *score = &scores[0], *hiscore = &scores[1];
25103 @@ -1322,6 +1324,8 @@ int ipv6_dev_get_saddr(struct net *net,
25107 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25111 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25112 @@ -3311,7 +3315,10 @@ static void if6_seq_stop(struct seq_file
25113 static int if6_seq_show(struct seq_file *seq, void *v)
25115 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25116 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25118 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25119 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25120 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25122 ifp->idev->dev->ifindex,
25124 @@ -3815,6 +3822,11 @@ static int in6_dump_addrs(struct inet6_d
25125 struct ifacaddr6 *ifaca;
25127 int ip_idx = *p_ip_idx;
25128 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25130 + /* disable ipv6 on non v6 guests */
25131 + if (nxi && !nx_info_has_v6(nxi))
25134 read_lock_bh(&idev->lock);
25136 @@ -3825,6 +3837,8 @@ static int in6_dump_addrs(struct inet6_d
25137 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25138 if (++ip_idx < s_ip_idx)
25140 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25142 err = inet6_fill_ifaddr(skb, ifa,
25143 NETLINK_CB(cb->skb).portid,
25144 cb->nlh->nlmsg_seq,
25145 @@ -3841,6 +3855,8 @@ static int in6_dump_addrs(struct inet6_d
25146 ifmca = ifmca->next, ip_idx++) {
25147 if (ip_idx < s_ip_idx)
25149 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25151 err = inet6_fill_ifmcaddr(skb, ifmca,
25152 NETLINK_CB(cb->skb).portid,
25153 cb->nlh->nlmsg_seq,
25154 @@ -3856,6 +3872,8 @@ static int in6_dump_addrs(struct inet6_d
25155 ifaca = ifaca->aca_next, ip_idx++) {
25156 if (ip_idx < s_ip_idx)
25158 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25160 err = inet6_fill_ifacaddr(skb, ifaca,
25161 NETLINK_CB(cb->skb).portid,
25162 cb->nlh->nlmsg_seq,
25163 @@ -3884,6 +3902,10 @@ static int inet6_dump_addr(struct sk_buf
25164 struct inet6_dev *idev;
25165 struct hlist_head *head;
25167 + /* FIXME: maybe disable ipv6 on non v6 guests?
25168 + if (skb->sk && skb->sk->sk_vx_info)
25169 + return skb->len; */
25172 s_idx = idx = cb->args[1];
25173 s_ip_idx = ip_idx = cb->args[2];
25174 @@ -4238,6 +4260,7 @@ static int inet6_dump_ifinfo(struct sk_b
25175 struct net_device *dev;
25176 struct inet6_dev *idev;
25177 struct hlist_head *head;
25178 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25181 s_idx = cb->args[1];
25182 @@ -4249,6 +4272,8 @@ static int inet6_dump_ifinfo(struct sk_b
25183 hlist_for_each_entry_rcu(dev, head, index_hlist) {
25186 + if (!v6_dev_in_nx_info(dev, nxi))
25188 idev = __in6_dev_get(dev);
25191 diff -NurpP --minimal linux-3.9.4/net/ipv6/af_inet6.c linux-3.9.4-vs2.3.6.3/net/ipv6/af_inet6.c
25192 --- linux-3.9.4/net/ipv6/af_inet6.c 2013-05-31 13:45:32.000000000 +0000
25193 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/af_inet6.c 2013-05-31 20:04:41.000000000 +0000
25195 #include <linux/netdevice.h>
25196 #include <linux/icmpv6.h>
25197 #include <linux/netfilter_ipv6.h>
25198 +#include <linux/vs_inet.h>
25199 +#include <linux/vs_inet6.h>
25201 #include <net/ip.h>
25202 #include <net/ipv6.h>
25203 @@ -160,10 +162,13 @@ lookup_protocol:
25207 + if ((protocol == IPPROTO_ICMPV6) &&
25208 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25210 if (sock->type == SOCK_RAW && !kern &&
25211 !ns_capable(net->user_ns, CAP_NET_RAW))
25212 goto out_rcu_unlock;
25215 sock->ops = answer->ops;
25216 answer_prot = answer->prot;
25217 answer_no_check = answer->no_check;
25218 @@ -263,6 +268,7 @@ int inet6_bind(struct socket *sock, stru
25219 struct inet_sock *inet = inet_sk(sk);
25220 struct ipv6_pinfo *np = inet6_sk(sk);
25221 struct net *net = sock_net(sk);
25222 + struct nx_v6_sock_addr nsa;
25224 unsigned short snum;
25226 @@ -278,6 +284,10 @@ int inet6_bind(struct socket *sock, stru
25227 if (addr->sin6_family != AF_INET6)
25228 return -EAFNOSUPPORT;
25230 + err = v6_map_sock_addr(inet, addr, &nsa);
25234 addr_type = ipv6_addr_type(&addr->sin6_addr);
25235 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25237 @@ -309,6 +319,7 @@ int inet6_bind(struct socket *sock, stru
25238 /* Reproduce AF_INET checks to make the bindings consistent */
25239 v4addr = addr->sin6_addr.s6_addr32[3];
25240 chk_addr_ret = inet_addr_type(net, v4addr);
25242 if (!sysctl_ip_nonlocal_bind &&
25243 !(inet->freebind || inet->transparent) &&
25244 v4addr != htonl(INADDR_ANY) &&
25245 @@ -318,6 +329,10 @@ int inet6_bind(struct socket *sock, stru
25246 err = -EADDRNOTAVAIL;
25249 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25250 + err = -EADDRNOTAVAIL;
25254 if (addr_type != IPV6_ADDR_ANY) {
25255 struct net_device *dev = NULL;
25256 @@ -344,6 +359,11 @@ int inet6_bind(struct socket *sock, stru
25260 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25261 + err = -EADDRNOTAVAIL;
25265 /* ipv4 addr of the socket is invalid. Only the
25266 * unspecified and mapped address have a v4 equivalent.
25268 @@ -360,6 +380,9 @@ int inet6_bind(struct socket *sock, stru
25272 + /* what's that for? */
25273 + v6_set_sock_addr(inet, &nsa);
25275 inet->inet_rcv_saddr = v4addr;
25276 inet->inet_saddr = v4addr;
25278 @@ -461,9 +484,11 @@ int inet6_getname(struct socket *sock, s
25280 sin->sin6_port = inet->inet_dport;
25281 sin->sin6_addr = np->daddr;
25282 + /* FIXME: remap lback? */
25284 sin->sin6_flowinfo = np->flow_label;
25286 + /* FIXME: remap lback? */
25287 if (ipv6_addr_any(&np->rcv_saddr))
25288 sin->sin6_addr = np->saddr;
25290 diff -NurpP --minimal linux-3.9.4/net/ipv6/datagram.c linux-3.9.4-vs2.3.6.3/net/ipv6/datagram.c
25291 --- linux-3.9.4/net/ipv6/datagram.c 2013-05-31 13:45:32.000000000 +0000
25292 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/datagram.c 2013-05-31 17:17:54.000000000 +0000
25293 @@ -648,7 +648,7 @@ int ip6_datagram_send_ctl(struct net *ne
25296 if (fl6->flowi6_oif) {
25297 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25298 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25302 diff -NurpP --minimal linux-3.9.4/net/ipv6/fib6_rules.c linux-3.9.4-vs2.3.6.3/net/ipv6/fib6_rules.c
25303 --- linux-3.9.4/net/ipv6/fib6_rules.c 2013-02-19 13:58:58.000000000 +0000
25304 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/fib6_rules.c 2013-05-31 17:17:54.000000000 +0000
25305 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
25306 ip6_dst_idev(&rt->dst)->dev,
25308 rt6_flags2srcprefs(flags),
25312 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25314 diff -NurpP --minimal linux-3.9.4/net/ipv6/inet6_hashtables.c linux-3.9.4-vs2.3.6.3/net/ipv6/inet6_hashtables.c
25315 --- linux-3.9.4/net/ipv6/inet6_hashtables.c 2013-05-31 13:45:32.000000000 +0000
25316 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/inet6_hashtables.c 2013-05-31 17:17:54.000000000 +0000
25319 #include <linux/module.h>
25320 #include <linux/random.h>
25321 +#include <linux/vs_inet6.h>
25323 #include <net/inet_connection_sock.h>
25324 #include <net/inet_hashtables.h>
25325 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25326 unsigned int slot = hash & hashinfo->ehash_mask;
25327 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25332 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25333 @@ -97,7 +97,7 @@ begin:
25341 if (get_nulls_value(node) != slot)
25342 @@ -147,6 +147,9 @@ static inline int compute_score(struct s
25343 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25347 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25350 if (sk->sk_bound_dev_if) {
25351 if (sk->sk_bound_dev_if != dif)
25352 diff -NurpP --minimal linux-3.9.4/net/ipv6/ip6_output.c linux-3.9.4-vs2.3.6.3/net/ipv6/ip6_output.c
25353 --- linux-3.9.4/net/ipv6/ip6_output.c 2013-05-31 13:45:32.000000000 +0000
25354 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/ip6_output.c 2013-05-31 17:17:54.000000000 +0000
25355 @@ -877,7 +877,8 @@ static int ip6_dst_lookup_tail(struct so
25356 struct rt6_info *rt = (struct rt6_info *) *dst;
25357 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25358 sk ? inet6_sk(sk)->srcprefs : 0,
25361 + sk ? sk->sk_nx_info : NULL);
25363 goto out_err_release;
25365 diff -NurpP --minimal linux-3.9.4/net/ipv6/ndisc.c linux-3.9.4-vs2.3.6.3/net/ipv6/ndisc.c
25366 --- linux-3.9.4/net/ipv6/ndisc.c 2013-05-31 13:45:32.000000000 +0000
25367 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/ndisc.c 2013-05-31 17:17:54.000000000 +0000
25368 @@ -485,7 +485,7 @@ static void ndisc_send_na(struct net_dev
25370 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25371 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25375 src_addr = &tmpaddr;
25377 diff -NurpP --minimal linux-3.9.4/net/ipv6/netfilter/ip6t_MASQUERADE.c linux-3.9.4-vs2.3.6.3/net/ipv6/netfilter/ip6t_MASQUERADE.c
25378 --- linux-3.9.4/net/ipv6/netfilter/ip6t_MASQUERADE.c 2012-12-11 03:30:57.000000000 +0000
25379 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/netfilter/ip6t_MASQUERADE.c 2013-05-31 17:17:54.000000000 +0000
25380 @@ -34,7 +34,7 @@ masquerade_tg6(struct sk_buff *skb, cons
25381 ctinfo == IP_CT_RELATED_REPLY));
25383 if (ipv6_dev_get_saddr(dev_net(par->out), par->out,
25384 - &ipv6_hdr(skb)->daddr, 0, &src) < 0)
25385 + &ipv6_hdr(skb)->daddr, 0, &src, NULL) < 0)
25388 nfct_nat(ct)->masq_index = par->out->ifindex;
25389 diff -NurpP --minimal linux-3.9.4/net/ipv6/raw.c linux-3.9.4-vs2.3.6.3/net/ipv6/raw.c
25390 --- linux-3.9.4/net/ipv6/raw.c 2013-05-31 13:45:32.000000000 +0000
25391 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/raw.c 2013-05-31 17:17:54.000000000 +0000
25393 #include <linux/icmpv6.h>
25394 #include <linux/netfilter.h>
25395 #include <linux/netfilter_ipv6.h>
25396 +#include <linux/vs_inet6.h>
25397 #include <linux/skbuff.h>
25398 #include <linux/compat.h>
25399 #include <asm/uaccess.h>
25400 @@ -283,6 +284,13 @@ static int rawv6_bind(struct sock *sk, s
25404 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25405 + err = -EADDRNOTAVAIL;
25411 /* ipv4 addr of the socket is invalid. Only the
25412 * unspecified and mapped address have a v4 equivalent.
25414 diff -NurpP --minimal linux-3.9.4/net/ipv6/route.c linux-3.9.4-vs2.3.6.3/net/ipv6/route.c
25415 --- linux-3.9.4/net/ipv6/route.c 2013-05-31 13:45:32.000000000 +0000
25416 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/route.c 2013-05-31 18:10:38.000000000 +0000
25418 #include <net/netevent.h>
25419 #include <net/netlink.h>
25420 #include <net/nexthop.h>
25421 +#include <linux/vs_inet6.h>
25423 #include <asm/uaccess.h>
25425 @@ -2079,15 +2080,17 @@ int ip6_route_get_saddr(struct net *net,
25426 struct rt6_info *rt,
25427 const struct in6_addr *daddr,
25428 unsigned int prefs,
25429 - struct in6_addr *saddr)
25430 + struct in6_addr *saddr,
25431 + struct nx_info *nxi)
25433 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25435 - if (rt->rt6i_prefsrc.plen)
25436 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25437 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25438 *saddr = rt->rt6i_prefsrc.addr;
25440 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25441 - daddr, prefs, saddr);
25442 + daddr, prefs, saddr, nxi);
25446 @@ -2507,7 +2510,8 @@ static int rt6_fill_node(struct net *net
25447 goto nla_put_failure;
25449 struct in6_addr saddr_buf;
25450 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0 &&
25451 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25452 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0 &&
25453 nla_put(skb, RTA_PREFSRC, 16, &saddr_buf))
25454 goto nla_put_failure;
25456 @@ -2719,6 +2723,7 @@ static int rt6_info_route(struct rt6_inf
25458 struct seq_file *m = p_arg;
25460 + /* FIXME: check for network context? */
25461 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25463 #ifdef CONFIG_IPV6_SUBTREES
25464 diff -NurpP --minimal linux-3.9.4/net/ipv6/tcp_ipv6.c linux-3.9.4-vs2.3.6.3/net/ipv6/tcp_ipv6.c
25465 --- linux-3.9.4/net/ipv6/tcp_ipv6.c 2013-05-31 14:22:27.000000000 +0000
25466 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/tcp_ipv6.c 2013-05-31 17:17:54.000000000 +0000
25469 #include <linux/crypto.h>
25470 #include <linux/scatterlist.h>
25471 +#include <linux/vs_inet6.h>
25473 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25474 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25475 @@ -164,8 +165,15 @@ static int tcp_v6_connect(struct sock *s
25476 * connect() to INADDR_ANY means loopback (BSD'ism).
25479 - if(ipv6_addr_any(&usin->sin6_addr))
25480 - usin->sin6_addr.s6_addr[15] = 0x1;
25481 + if(ipv6_addr_any(&usin->sin6_addr)) {
25482 + struct nx_info *nxi = sk->sk_nx_info;
25484 + if (nxi && nx_info_has_v6(nxi))
25485 + /* FIXME: remap lback? */
25486 + usin->sin6_addr = nxi->v6.ip;
25488 + usin->sin6_addr.s6_addr[15] = 0x1;
25491 addr_type = ipv6_addr_type(&usin->sin6_addr);
25493 diff -NurpP --minimal linux-3.9.4/net/ipv6/udp.c linux-3.9.4-vs2.3.6.3/net/ipv6/udp.c
25494 --- linux-3.9.4/net/ipv6/udp.c 2013-05-31 14:22:27.000000000 +0000
25495 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/udp.c 2013-05-31 18:16:01.000000000 +0000
25496 @@ -46,42 +46,68 @@
25497 #include <net/ip6_checksum.h>
25498 #include <net/xfrm.h>
25499 #include <net/inet6_hashtables.h>
25500 +#include <linux/vs_inet6.h>
25502 #include <linux/proc_fs.h>
25503 #include <linux/seq_file.h>
25504 #include <trace/events/skb.h>
25505 #include "udp_impl.h"
25507 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25508 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25510 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25511 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25512 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25513 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25514 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25515 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25516 - int sk_ipv6only = ipv6_only_sock(sk);
25517 + int sk1_ipv6only = ipv6_only_sock(sk1);
25518 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25519 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25520 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25521 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25523 /* if both are mapped, treat as IPv4 */
25524 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25525 - return (!sk2_ipv6only &&
25526 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25527 + if (!sk2_ipv6only &&
25528 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25529 - sk1_rcv_saddr == sk2_rcv_saddr));
25530 + sk1_rcv_saddr == sk2_rcv_saddr))
25536 if (addr_type2 == IPV6_ADDR_ANY &&
25537 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25541 if (addr_type == IPV6_ADDR_ANY &&
25542 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25544 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25547 if (sk2_rcv_saddr6 &&
25548 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25550 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25556 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25557 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25558 + if (!sk2_rcv_saddr)
25559 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25560 + if (!sk1_rcv_saddr)
25561 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25564 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25565 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25566 + else if (addr_type2 == IPV6_ADDR_ANY)
25567 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25568 + else if (addr_type == IPV6_ADDR_ANY) {
25569 + if (addr_type2 == IPV6_ADDR_MAPPED)
25570 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25572 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25577 static unsigned int udp6_portaddr_hash(struct net *net,
25578 @@ -145,6 +171,10 @@ static inline int compute_score(struct s
25579 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25583 + /* block non nx_info ips */
25584 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25587 if (!ipv6_addr_any(&np->daddr)) {
25588 if (!ipv6_addr_equal(&np->daddr, saddr))
25589 diff -NurpP --minimal linux-3.9.4/net/ipv6/xfrm6_policy.c linux-3.9.4-vs2.3.6.3/net/ipv6/xfrm6_policy.c
25590 --- linux-3.9.4/net/ipv6/xfrm6_policy.c 2013-05-31 14:22:27.000000000 +0000
25591 +++ linux-3.9.4-vs2.3.6.3/net/ipv6/xfrm6_policy.c 2013-05-31 17:17:54.000000000 +0000
25592 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
25593 dev = ip6_dst_idev(dst)->dev;
25594 ipv6_dev_get_saddr(dev_net(dev), dev,
25595 (struct in6_addr *)&daddr->a6, 0,
25596 - (struct in6_addr *)&saddr->a6);
25597 + (struct in6_addr *)&saddr->a6, NULL);
25601 diff -NurpP --minimal linux-3.9.4/net/netfilter/ipvs/ip_vs_xmit.c linux-3.9.4-vs2.3.6.3/net/netfilter/ipvs/ip_vs_xmit.c
25602 --- linux-3.9.4/net/netfilter/ipvs/ip_vs_xmit.c 2013-02-19 13:58:59.000000000 +0000
25603 +++ linux-3.9.4-vs2.3.6.3/net/netfilter/ipvs/ip_vs_xmit.c 2013-05-31 17:17:54.000000000 +0000
25604 @@ -273,7 +273,7 @@ __ip_vs_route_output_v6(struct net *net,
25606 if (ipv6_addr_any(&fl6.saddr) &&
25607 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
25608 - &fl6.daddr, 0, &fl6.saddr) < 0)
25609 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
25612 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
25613 diff -NurpP --minimal linux-3.9.4/net/netlink/af_netlink.c linux-3.9.4-vs2.3.6.3/net/netlink/af_netlink.c
25614 --- linux-3.9.4/net/netlink/af_netlink.c 2013-05-31 13:45:33.000000000 +0000
25615 +++ linux-3.9.4-vs2.3.6.3/net/netlink/af_netlink.c 2013-05-31 17:17:54.000000000 +0000
25617 #include <linux/types.h>
25618 #include <linux/audit.h>
25619 #include <linux/mutex.h>
25620 +#include <linux/vs_context.h>
25621 +#include <linux/vs_network.h>
25622 +#include <linux/vs_limit.h>
25624 #include <net/net_namespace.h>
25625 #include <net/sock.h>
25626 @@ -1976,6 +1979,8 @@ static struct sock *netlink_seq_socket_i
25627 sk_for_each(s, &hash->table[j]) {
25628 if (sock_net(s) != seq_file_net(seq))
25630 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25634 iter->hash_idx = j;
25635 @@ -2010,7 +2015,8 @@ static void *netlink_seq_next(struct seq
25639 - } while (s && sock_net(s) != seq_file_net(seq));
25640 + } while (s && (sock_net(s) != seq_file_net(seq) ||
25641 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
25645 @@ -2022,7 +2028,8 @@ static void *netlink_seq_next(struct seq
25647 for (; j <= hash->mask; j++) {
25648 s = sk_head(&hash->table[j]);
25649 - while (s && sock_net(s) != seq_file_net(seq))
25650 + while (s && (sock_net(s) != seq_file_net(seq) ||
25651 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
25655 diff -NurpP --minimal linux-3.9.4/net/socket.c linux-3.9.4-vs2.3.6.3/net/socket.c
25656 --- linux-3.9.4/net/socket.c 2013-05-31 13:45:33.000000000 +0000
25657 +++ linux-3.9.4-vs2.3.6.3/net/socket.c 2013-05-31 17:17:54.000000000 +0000
25660 #include <net/sock.h>
25661 #include <linux/netfilter.h>
25662 +#include <linux/vs_base.h>
25663 +#include <linux/vs_socket.h>
25664 +#include <linux/vs_inet.h>
25665 +#include <linux/vs_inet6.h>
25667 #include <linux/if_tun.h>
25668 #include <linux/ipv6_route.h>
25669 @@ -617,13 +621,29 @@ static inline int __sock_sendmsg_nosec(s
25670 struct msghdr *msg, size_t size)
25672 struct sock_iocb *si = kiocb_to_siocb(iocb);
25680 - return sock->ops->sendmsg(iocb, sock, msg, size);
25681 + len = sock->ops->sendmsg(iocb, sock, msg, size);
25684 + vx_sock_send(sock->sk, size);
25686 + vx_sock_fail(sock->sk, size);
25688 + vxdprintk(VXD_CBIT(net, 7),
25689 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
25691 + (sock->sk)?sock->sk->sk_nx_info:0,
25692 + (sock->sk)?sock->sk->sk_vx_info:0,
25693 + (sock->sk)?sock->sk->sk_xid:0,
25694 + (sock->sk)?sock->sk->sk_nid:0,
25695 + (unsigned int)size, len);
25699 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
25700 @@ -779,6 +799,7 @@ static inline int __sock_recvmsg_nosec(s
25701 struct msghdr *msg, size_t size, int flags)
25703 struct sock_iocb *si = kiocb_to_siocb(iocb);
25708 @@ -786,7 +807,18 @@ static inline int __sock_recvmsg_nosec(s
25712 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
25713 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
25714 + if ((len >= 0) && sock->sk)
25715 + vx_sock_recv(sock->sk, len);
25716 + vxdprintk(VXD_CBIT(net, 7),
25717 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
25719 + (sock->sk)?sock->sk->sk_nx_info:0,
25720 + (sock->sk)?sock->sk->sk_vx_info:0,
25721 + (sock->sk)?sock->sk->sk_xid:0,
25722 + (sock->sk)?sock->sk->sk_nid:0,
25723 + (unsigned int)size, len);
25727 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
25728 @@ -1269,6 +1301,13 @@ int __sock_create(struct net *net, int f
25729 if (type < 0 || type >= SOCK_MAX)
25732 + if (!nx_check(0, VS_ADMIN)) {
25733 + if (family == PF_INET && !current_nx_info_has_v4())
25734 + return -EAFNOSUPPORT;
25735 + if (family == PF_INET6 && !current_nx_info_has_v6())
25736 + return -EAFNOSUPPORT;
25741 This uglymoron is moved from INET layer to here to avoid
25742 @@ -1403,6 +1442,7 @@ SYSCALL_DEFINE3(socket, int, family, int
25746 + set_bit(SOCK_USER_SOCKET, &sock->flags);
25747 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
25750 @@ -1444,10 +1484,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
25751 err = sock_create(family, type, protocol, &sock1);
25754 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
25756 err = sock_create(family, type, protocol, &sock2);
25758 goto out_release_1;
25759 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
25761 err = sock1->ops->socketpair(sock1, sock2);
25763 diff -NurpP --minimal linux-3.9.4/net/sunrpc/auth.c linux-3.9.4-vs2.3.6.3/net/sunrpc/auth.c
25764 --- linux-3.9.4/net/sunrpc/auth.c 2013-05-31 13:45:33.000000000 +0000
25765 +++ linux-3.9.4-vs2.3.6.3/net/sunrpc/auth.c 2013-06-03 20:11:37.000000000 +0000
25767 #include <linux/sunrpc/clnt.h>
25768 #include <linux/sunrpc/gss_api.h>
25769 #include <linux/spinlock.h>
25770 +#include <linux/vs_tag.h>
25773 # define RPCDBG_FACILITY RPCDBG_AUTH
25774 @@ -480,6 +481,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
25775 memset(&acred, 0, sizeof(acred));
25776 acred.uid = cred->fsuid;
25777 acred.gid = cred->fsgid;
25778 + acred.tag = make_ktag(&init_user_ns, dx_current_tag());
25779 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
25781 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
25782 @@ -520,6 +522,7 @@ rpcauth_bind_root_cred(struct rpc_task *
25783 struct auth_cred acred = {
25784 .uid = GLOBAL_ROOT_UID,
25785 .gid = GLOBAL_ROOT_GID,
25786 + .tag = KTAGT_INIT(dx_current_tag()),
25789 dprintk("RPC: %5u looking up %s cred\n",
25790 diff -NurpP --minimal linux-3.9.4/net/sunrpc/auth_unix.c linux-3.9.4-vs2.3.6.3/net/sunrpc/auth_unix.c
25791 --- linux-3.9.4/net/sunrpc/auth_unix.c 2013-05-31 13:45:33.000000000 +0000
25792 +++ linux-3.9.4-vs2.3.6.3/net/sunrpc/auth_unix.c 2013-06-03 19:35:29.000000000 +0000
25793 @@ -13,11 +13,13 @@
25794 #include <linux/sunrpc/clnt.h>
25795 #include <linux/sunrpc/auth.h>
25796 #include <linux/user_namespace.h>
25797 +#include <linux/vs_tag.h>
25799 #define NFS_NGROUPS 16
25802 struct rpc_cred uc_base;
25805 kgid_t uc_gids[NFS_NGROUPS];
25807 @@ -80,6 +82,7 @@ unx_create_cred(struct rpc_auth *auth, s
25808 groups = NFS_NGROUPS;
25810 cred->uc_gid = acred->gid;
25811 + cred->uc_tag = acred->tag;
25812 for (i = 0; i < groups; i++)
25813 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
25814 if (i < NFS_NGROUPS)
25815 @@ -121,7 +124,9 @@ unx_match(struct auth_cred *acred, struc
25819 - if (!uid_eq(cred->uc_uid, acred->uid) || !gid_eq(cred->uc_gid, acred->gid))
25820 + if (!uid_eq(cred->uc_uid, acred->uid) ||
25821 + !gid_eq(cred->uc_gid, acred->gid) ||
25822 + !tag_eq(cred->uc_tag, acred->tag))
25825 if (acred->group_info != NULL)
25826 @@ -146,7 +151,7 @@ unx_marshal(struct rpc_task *task, __be3
25827 struct rpc_clnt *clnt = task->tk_client;
25828 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
25829 __be32 *base, *hold;
25833 *p++ = htonl(RPC_AUTH_UNIX);
25835 @@ -157,8 +162,11 @@ unx_marshal(struct rpc_task *task, __be3
25837 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
25839 - *p++ = htonl((u32) from_kuid(&init_user_ns, cred->uc_uid));
25840 - *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gid));
25841 + tag = task->tk_client->cl_tag;
25842 + *p++ = htonl((u32) from_kuid(&init_user_ns,
25843 + TAGINO_KUID(tag, cred->uc_uid, cred->uc_tag)));
25844 + *p++ = htonl((u32) from_kgid(&init_user_ns,
25845 + TAGINO_KGID(tag, cred->uc_gid, cred->uc_tag)));
25847 for (i = 0; i < 16 && gid_valid(cred->uc_gids[i]); i++)
25848 *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gids[i]));
25849 diff -NurpP --minimal linux-3.9.4/net/sunrpc/clnt.c linux-3.9.4-vs2.3.6.3/net/sunrpc/clnt.c
25850 --- linux-3.9.4/net/sunrpc/clnt.c 2013-05-31 13:45:33.000000000 +0000
25851 +++ linux-3.9.4-vs2.3.6.3/net/sunrpc/clnt.c 2013-05-31 17:17:54.000000000 +0000
25853 #include <linux/in6.h>
25854 #include <linux/un.h>
25855 #include <linux/rcupdate.h>
25856 +#include <linux/vs_cvirt.h>
25858 #include <linux/sunrpc/clnt.h>
25859 #include <linux/sunrpc/addr.h>
25860 @@ -482,6 +483,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
25861 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
25862 clnt->cl_chatty = 1;
25864 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
25865 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
25866 + clnt->cl_tag = 1; */
25869 EXPORT_SYMBOL_GPL(rpc_create);
25870 diff -NurpP --minimal linux-3.9.4/net/unix/af_unix.c linux-3.9.4-vs2.3.6.3/net/unix/af_unix.c
25871 --- linux-3.9.4/net/unix/af_unix.c 2013-05-31 13:45:33.000000000 +0000
25872 +++ linux-3.9.4-vs2.3.6.3/net/unix/af_unix.c 2013-05-31 17:17:54.000000000 +0000
25873 @@ -114,6 +114,8 @@
25874 #include <linux/mount.h>
25875 #include <net/checksum.h>
25876 #include <linux/security.h>
25877 +#include <linux/vs_context.h>
25878 +#include <linux/vs_limit.h>
25880 struct hlist_head unix_socket_table[2 * UNIX_HASH_SIZE];
25881 EXPORT_SYMBOL_GPL(unix_socket_table);
25882 @@ -270,6 +272,8 @@ static struct sock *__unix_find_socket_b
25883 if (!net_eq(sock_net(s), net))
25886 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25888 if (u->addr->len == len &&
25889 !memcmp(u->addr->name, sunname, len))
25891 @@ -2256,6 +2260,8 @@ static struct sock *unix_from_bucket(str
25892 for (sk = sk_head(&unix_socket_table[bucket]); sk; sk = sk_next(sk)) {
25893 if (sock_net(sk) != seq_file_net(seq))
25895 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25897 if (++count == offset)
25900 @@ -2273,6 +2279,8 @@ static struct sock *unix_next_socket(str
25904 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25906 if (sock_net(sk) == seq_file_net(seq))
25909 diff -NurpP --minimal linux-3.9.4/scripts/checksyscalls.sh linux-3.9.4-vs2.3.6.3/scripts/checksyscalls.sh
25910 --- linux-3.9.4/scripts/checksyscalls.sh 2012-12-11 03:30:57.000000000 +0000
25911 +++ linux-3.9.4-vs2.3.6.3/scripts/checksyscalls.sh 2013-05-31 14:47:11.000000000 +0000
25912 @@ -193,7 +193,6 @@ cat << EOF
25913 #define __IGNORE_afs_syscall
25914 #define __IGNORE_getpmsg
25915 #define __IGNORE_putpmsg
25916 -#define __IGNORE_vserver
25920 diff -NurpP --minimal linux-3.9.4/security/commoncap.c linux-3.9.4-vs2.3.6.3/security/commoncap.c
25921 --- linux-3.9.4/security/commoncap.c 2013-05-31 13:45:34.000000000 +0000
25922 +++ linux-3.9.4-vs2.3.6.3/security/commoncap.c 2013-05-31 15:07:02.000000000 +0000
25923 @@ -76,6 +76,7 @@ int cap_netlink_send(struct sock *sk, st
25924 int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
25925 int cap, int audit)
25927 + struct vx_info *vxi = current_vx_info(); /* FIXME: get vxi from cred? */
25928 struct user_namespace *ns = targ_ns;
25930 /* See if cred has the capability in the target user namespace
25931 @@ -84,8 +85,12 @@ int cap_capable(const struct cred *cred,
25934 /* Do we have the necessary capabilities? */
25935 - if (ns == cred->user_ns)
25936 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
25937 + if (ns == cred->user_ns) {
25938 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
25939 + cap_raised(cred->cap_effective, cap))
25941 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
25944 /* Have we tried all of the parent namespaces? */
25945 if (ns == &init_user_ns)
25946 @@ -628,7 +633,7 @@ int cap_inode_setxattr(struct dentry *de
25948 if (!strncmp(name, XATTR_SECURITY_PREFIX,
25949 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
25950 - !capable(CAP_SYS_ADMIN))
25951 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
25955 @@ -654,7 +659,7 @@ int cap_inode_removexattr(struct dentry
25957 if (!strncmp(name, XATTR_SECURITY_PREFIX,
25958 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
25959 - !capable(CAP_SYS_ADMIN))
25960 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
25964 diff -NurpP --minimal linux-3.9.4/security/selinux/hooks.c linux-3.9.4-vs2.3.6.3/security/selinux/hooks.c
25965 --- linux-3.9.4/security/selinux/hooks.c 2013-05-31 13:45:34.000000000 +0000
25966 +++ linux-3.9.4-vs2.3.6.3/security/selinux/hooks.c 2013-05-31 14:47:11.000000000 +0000
25968 #include <linux/dccp.h>
25969 #include <linux/quota.h>
25970 #include <linux/un.h> /* for Unix socket types */
25971 -#include <net/af_unix.h> /* for Unix socket types */
25972 #include <linux/parser.h>
25973 #include <linux/nfs_mount.h>
25974 #include <net/ipv6.h>