1 diff -NurpP --minimal linux-3.0.25/Documentation/vserver/debug.txt linux-3.0.25-vs2.3.2.3/Documentation/vserver/debug.txt
2 --- linux-3.0.25/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.0.25-vs2.3.2.3/Documentation/vserver/debug.txt 2011-06-10 22:11:24.000000000 +0200
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.0.25/arch/alpha/Kconfig linux-3.0.25-vs2.3.2.3/arch/alpha/Kconfig
160 --- linux-3.0.25/arch/alpha/Kconfig 2011-07-22 11:17:32.000000000 +0200
161 +++ linux-3.0.25-vs2.3.2.3/arch/alpha/Kconfig 2011-06-10 22:11:24.000000000 +0200
162 @@ -668,6 +668,8 @@ config DUMMY_CONSOLE
166 +source "kernel/vserver/Kconfig"
168 source "security/Kconfig"
170 source "crypto/Kconfig"
171 diff -NurpP --minimal linux-3.0.25/arch/alpha/kernel/entry.S linux-3.0.25-vs2.3.2.3/arch/alpha/kernel/entry.S
172 --- linux-3.0.25/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
173 +++ linux-3.0.25-vs2.3.2.3/arch/alpha/kernel/entry.S 2011-06-10 22:11:24.000000000 +0200
174 @@ -860,24 +860,15 @@ sys_getxgid:
181 - ldq $2, TI_TASK($8)
183 - /* See linux/kernel/timer.c sys_getppid for discussion
184 - about this loop. */
185 - ldq $3, TASK_GROUP_LEADER($2)
186 - ldq $4, TASK_REAL_PARENT($3)
187 - ldl $0, TASK_TGID($2)
188 -1: ldl $1, TASK_TGID($4)
192 - ldq $3, TASK_GROUP_LEADER($2)
193 - ldq $4, TASK_REAL_PARENT($3)
199 + jsr $26, do_getxpid
206 diff -NurpP --minimal linux-3.0.25/arch/alpha/kernel/ptrace.c linux-3.0.25-vs2.3.2.3/arch/alpha/kernel/ptrace.c
207 --- linux-3.0.25/arch/alpha/kernel/ptrace.c 2011-01-05 21:48:40.000000000 +0100
208 +++ linux-3.0.25-vs2.3.2.3/arch/alpha/kernel/ptrace.c 2011-06-10 22:11:24.000000000 +0200
210 #include <linux/user.h>
211 #include <linux/security.h>
212 #include <linux/signal.h>
213 +#include <linux/vs_base.h>
215 #include <asm/uaccess.h>
216 #include <asm/pgtable.h>
217 diff -NurpP --minimal linux-3.0.25/arch/alpha/kernel/systbls.S linux-3.0.25-vs2.3.2.3/arch/alpha/kernel/systbls.S
218 --- linux-3.0.25/arch/alpha/kernel/systbls.S 2011-07-22 11:17:32.000000000 +0200
219 +++ linux-3.0.25-vs2.3.2.3/arch/alpha/kernel/systbls.S 2011-06-10 22:11:24.000000000 +0200
220 @@ -446,7 +446,7 @@ sys_call_table:
221 .quad sys_stat64 /* 425 */
224 - .quad sys_ni_syscall /* sys_vserver */
225 + .quad sys_vserver /* sys_vserver */
226 .quad sys_ni_syscall /* sys_mbind */
227 .quad sys_ni_syscall /* sys_get_mempolicy */
228 .quad sys_ni_syscall /* sys_set_mempolicy */
229 diff -NurpP --minimal linux-3.0.25/arch/alpha/kernel/traps.c linux-3.0.25-vs2.3.2.3/arch/alpha/kernel/traps.c
230 --- linux-3.0.25/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
231 +++ linux-3.0.25-vs2.3.2.3/arch/alpha/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
232 @@ -183,7 +183,8 @@ die_if_kernel(char * str, struct pt_regs
234 printk("CPU %d ", hard_smp_processor_id());
236 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
237 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
238 + task_pid_nr(current), current->xid, str, err);
239 dik_show_regs(regs, r9_15);
240 add_taint(TAINT_DIE);
241 dik_show_trace((unsigned long *)(regs+1));
242 diff -NurpP --minimal linux-3.0.25/arch/arm/Kconfig linux-3.0.25-vs2.3.2.3/arch/arm/Kconfig
243 --- linux-3.0.25/arch/arm/Kconfig 2012-03-19 21:16:33.000000000 +0100
244 +++ linux-3.0.25-vs2.3.2.3/arch/arm/Kconfig 2012-03-15 13:32:35.000000000 +0100
245 @@ -2061,6 +2061,8 @@ source "fs/Kconfig"
247 source "arch/arm/Kconfig.debug"
249 +source "kernel/vserver/Kconfig"
251 source "security/Kconfig"
253 source "crypto/Kconfig"
254 diff -NurpP --minimal linux-3.0.25/arch/arm/kernel/calls.S linux-3.0.25-vs2.3.2.3/arch/arm/kernel/calls.S
255 --- linux-3.0.25/arch/arm/kernel/calls.S 2011-07-22 11:17:32.000000000 +0200
256 +++ linux-3.0.25-vs2.3.2.3/arch/arm/kernel/calls.S 2011-06-10 22:11:24.000000000 +0200
258 /* 310 */ CALL(sys_request_key)
260 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
261 -/* vserver */ CALL(sys_ni_syscall)
264 /* 315 */ CALL(sys_ioprio_get)
265 CALL(sys_inotify_init)
266 diff -NurpP --minimal linux-3.0.25/arch/arm/kernel/process.c linux-3.0.25-vs2.3.2.3/arch/arm/kernel/process.c
267 --- linux-3.0.25/arch/arm/kernel/process.c 2012-03-19 21:16:33.000000000 +0100
268 +++ linux-3.0.25-vs2.3.2.3/arch/arm/kernel/process.c 2011-12-19 15:55:53.000000000 +0100
269 @@ -318,7 +318,8 @@ void __show_regs(struct pt_regs *regs)
270 void show_regs(struct pt_regs * regs)
273 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
274 + printk("Pid: %d[#%u], comm: %20s\n",
275 + task_pid_nr(current), current->xid, current->comm);
279 diff -NurpP --minimal linux-3.0.25/arch/arm/kernel/traps.c linux-3.0.25-vs2.3.2.3/arch/arm/kernel/traps.c
280 --- linux-3.0.25/arch/arm/kernel/traps.c 2011-07-22 11:17:32.000000000 +0200
281 +++ linux-3.0.25-vs2.3.2.3/arch/arm/kernel/traps.c 2011-06-22 12:39:12.000000000 +0200
282 @@ -242,8 +242,8 @@ static int __die(const char *str, int er
286 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
287 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
288 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
289 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
291 if (!user_mode(regs) || in_interrupt()) {
292 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
293 diff -NurpP --minimal linux-3.0.25/arch/cris/Kconfig linux-3.0.25-vs2.3.2.3/arch/cris/Kconfig
294 --- linux-3.0.25/arch/cris/Kconfig 2011-07-22 11:17:35.000000000 +0200
295 +++ linux-3.0.25-vs2.3.2.3/arch/cris/Kconfig 2011-06-10 22:11:24.000000000 +0200
296 @@ -678,6 +678,8 @@ source "drivers/staging/Kconfig"
298 source "arch/cris/Kconfig.debug"
300 +source "kernel/vserver/Kconfig"
302 source "security/Kconfig"
304 source "crypto/Kconfig"
305 diff -NurpP --minimal linux-3.0.25/arch/frv/kernel/kernel_thread.S linux-3.0.25-vs2.3.2.3/arch/frv/kernel/kernel_thread.S
306 --- linux-3.0.25/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
307 +++ linux-3.0.25-vs2.3.2.3/arch/frv/kernel/kernel_thread.S 2011-06-10 22:11:24.000000000 +0200
308 @@ -37,7 +37,7 @@ kernel_thread:
310 # start by forking the current process, but with shared VM
311 setlos.p #__NR_clone,gr7 ; syscall number
312 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
313 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
314 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
316 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
317 diff -NurpP --minimal linux-3.0.25/arch/h8300/Kconfig linux-3.0.25-vs2.3.2.3/arch/h8300/Kconfig
318 --- linux-3.0.25/arch/h8300/Kconfig 2011-07-22 11:17:35.000000000 +0200
319 +++ linux-3.0.25-vs2.3.2.3/arch/h8300/Kconfig 2011-06-10 22:11:24.000000000 +0200
320 @@ -213,6 +213,8 @@ source "fs/Kconfig"
322 source "arch/h8300/Kconfig.debug"
324 +source "kernel/vserver/Kconfig"
326 source "security/Kconfig"
328 source "crypto/Kconfig"
329 diff -NurpP --minimal linux-3.0.25/arch/ia64/Kconfig linux-3.0.25-vs2.3.2.3/arch/ia64/Kconfig
330 --- linux-3.0.25/arch/ia64/Kconfig 2011-07-22 11:17:35.000000000 +0200
331 +++ linux-3.0.25-vs2.3.2.3/arch/ia64/Kconfig 2011-06-10 22:11:24.000000000 +0200
332 @@ -671,6 +671,8 @@ source "fs/Kconfig"
334 source "arch/ia64/Kconfig.debug"
336 +source "kernel/vserver/Kconfig"
338 source "security/Kconfig"
340 source "crypto/Kconfig"
341 diff -NurpP --minimal linux-3.0.25/arch/ia64/include/asm/tlb.h linux-3.0.25-vs2.3.2.3/arch/ia64/include/asm/tlb.h
342 --- linux-3.0.25/arch/ia64/include/asm/tlb.h 2011-07-22 11:17:35.000000000 +0200
343 +++ linux-3.0.25-vs2.3.2.3/arch/ia64/include/asm/tlb.h 2011-06-10 22:11:24.000000000 +0200
345 #include <linux/mm.h>
346 #include <linux/pagemap.h>
347 #include <linux/swap.h>
348 +#include <linux/vs_memory.h>
350 #include <asm/pgalloc.h>
351 #include <asm/processor.h>
352 diff -NurpP --minimal linux-3.0.25/arch/ia64/kernel/entry.S linux-3.0.25-vs2.3.2.3/arch/ia64/kernel/entry.S
353 --- linux-3.0.25/arch/ia64/kernel/entry.S 2011-07-22 11:17:35.000000000 +0200
354 +++ linux-3.0.25-vs2.3.2.3/arch/ia64/kernel/entry.S 2011-06-10 22:11:24.000000000 +0200
355 @@ -1714,7 +1714,7 @@ sys_call_table:
357 data8 sys_mq_getsetattr
359 - data8 sys_ni_syscall // reserved for vserver
361 data8 sys_waitid // 1270
363 data8 sys_request_key
364 diff -NurpP --minimal linux-3.0.25/arch/ia64/kernel/perfmon.c linux-3.0.25-vs2.3.2.3/arch/ia64/kernel/perfmon.c
365 --- linux-3.0.25/arch/ia64/kernel/perfmon.c 2011-03-15 18:06:39.000000000 +0100
366 +++ linux-3.0.25-vs2.3.2.3/arch/ia64/kernel/perfmon.c 2011-06-10 22:11:24.000000000 +0200
368 #include <linux/completion.h>
369 #include <linux/tracehook.h>
370 #include <linux/slab.h>
371 +#include <linux/vs_memory.h>
373 #include <asm/errno.h>
374 #include <asm/intrinsics.h>
375 diff -NurpP --minimal linux-3.0.25/arch/ia64/kernel/process.c linux-3.0.25-vs2.3.2.3/arch/ia64/kernel/process.c
376 --- linux-3.0.25/arch/ia64/kernel/process.c 2011-03-15 18:06:39.000000000 +0100
377 +++ linux-3.0.25-vs2.3.2.3/arch/ia64/kernel/process.c 2011-06-10 22:11:24.000000000 +0200
378 @@ -109,8 +109,8 @@ show_regs (struct pt_regs *regs)
379 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
382 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
383 - smp_processor_id(), current->comm);
384 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
385 + current->xid, smp_processor_id(), current->comm);
386 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
387 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
388 init_utsname()->release);
389 diff -NurpP --minimal linux-3.0.25/arch/ia64/kernel/ptrace.c linux-3.0.25-vs2.3.2.3/arch/ia64/kernel/ptrace.c
390 --- linux-3.0.25/arch/ia64/kernel/ptrace.c 2011-01-05 21:48:59.000000000 +0100
391 +++ linux-3.0.25-vs2.3.2.3/arch/ia64/kernel/ptrace.c 2011-06-10 22:11:24.000000000 +0200
393 #include <linux/regset.h>
394 #include <linux/elf.h>
395 #include <linux/tracehook.h>
396 +#include <linux/vs_base.h>
398 #include <asm/pgtable.h>
399 #include <asm/processor.h>
400 diff -NurpP --minimal linux-3.0.25/arch/ia64/kernel/traps.c linux-3.0.25-vs2.3.2.3/arch/ia64/kernel/traps.c
401 --- linux-3.0.25/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
402 +++ linux-3.0.25-vs2.3.2.3/arch/ia64/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
403 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
406 if (++die.lock_owner_depth < 3) {
407 - printk("%s[%d]: %s %ld [%d]\n",
408 - current->comm, task_pid_nr(current), str, err, ++die_counter);
409 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
410 + current->comm, task_pid_nr(current), current->xid,
411 + str, err, ++die_counter);
412 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
415 @@ -323,8 +324,9 @@ handle_fpu_swa (int fp_fault, struct pt_
416 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
417 last.time = current_jiffies + 5 * HZ;
419 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
420 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
421 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
422 + current->comm, task_pid_nr(current), current->xid,
423 + regs->cr_iip + ia64_psr(regs)->ri, isr);
427 diff -NurpP --minimal linux-3.0.25/arch/ia64/mm/fault.c linux-3.0.25-vs2.3.2.3/arch/ia64/mm/fault.c
428 --- linux-3.0.25/arch/ia64/mm/fault.c 2011-07-22 11:17:35.000000000 +0200
429 +++ linux-3.0.25-vs2.3.2.3/arch/ia64/mm/fault.c 2011-06-10 22:28:23.000000000 +0200
431 #include <linux/kprobes.h>
432 #include <linux/kdebug.h>
433 #include <linux/prefetch.h>
434 +#include <linux/vs_memory.h>
436 #include <asm/pgtable.h>
437 #include <asm/processor.h>
438 diff -NurpP --minimal linux-3.0.25/arch/m32r/kernel/traps.c linux-3.0.25-vs2.3.2.3/arch/m32r/kernel/traps.c
439 --- linux-3.0.25/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
440 +++ linux-3.0.25-vs2.3.2.3/arch/m32r/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
441 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
443 printk("SPI: %08lx\n", sp);
445 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
446 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
447 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
448 + current->comm, task_pid_nr(current), current->xid,
449 + 0xffff & i, 4096+(unsigned long)current);
452 * When in-kernel, we also print out the stack and code at the
453 diff -NurpP --minimal linux-3.0.25/arch/m68k/Kconfig linux-3.0.25-vs2.3.2.3/arch/m68k/Kconfig
454 --- linux-3.0.25/arch/m68k/Kconfig 2011-07-22 11:17:35.000000000 +0200
455 +++ linux-3.0.25-vs2.3.2.3/arch/m68k/Kconfig 2011-06-10 22:11:24.000000000 +0200
456 @@ -241,6 +241,8 @@ source "fs/Kconfig"
458 source "arch/m68k/Kconfig.debug"
460 +source "kernel/vserver/Kconfig"
462 source "security/Kconfig"
464 source "crypto/Kconfig"
465 diff -NurpP --minimal linux-3.0.25/arch/mips/Kconfig linux-3.0.25-vs2.3.2.3/arch/mips/Kconfig
466 --- linux-3.0.25/arch/mips/Kconfig 2011-07-22 11:17:35.000000000 +0200
467 +++ linux-3.0.25-vs2.3.2.3/arch/mips/Kconfig 2011-06-10 22:11:24.000000000 +0200
468 @@ -2485,6 +2485,8 @@ source "fs/Kconfig"
470 source "arch/mips/Kconfig.debug"
472 +source "kernel/vserver/Kconfig"
474 source "security/Kconfig"
476 source "crypto/Kconfig"
477 diff -NurpP --minimal linux-3.0.25/arch/mips/kernel/ptrace.c linux-3.0.25-vs2.3.2.3/arch/mips/kernel/ptrace.c
478 --- linux-3.0.25/arch/mips/kernel/ptrace.c 2011-07-22 11:17:36.000000000 +0200
479 +++ linux-3.0.25-vs2.3.2.3/arch/mips/kernel/ptrace.c 2011-06-10 22:11:24.000000000 +0200
481 #include <linux/security.h>
482 #include <linux/audit.h>
483 #include <linux/seccomp.h>
484 +#include <linux/vs_base.h>
486 #include <asm/byteorder.h>
488 @@ -263,6 +264,9 @@ long arch_ptrace(struct task_struct *chi
489 void __user *datavp = (void __user *) data;
490 unsigned long __user *datalp = (void __user *) data;
492 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
496 /* when I and D space are separate, these will need to be fixed. */
497 case PTRACE_PEEKTEXT: /* read word at location addr. */
498 diff -NurpP --minimal linux-3.0.25/arch/mips/kernel/scall32-o32.S linux-3.0.25-vs2.3.2.3/arch/mips/kernel/scall32-o32.S
499 --- linux-3.0.25/arch/mips/kernel/scall32-o32.S 2011-07-22 11:17:36.000000000 +0200
500 +++ linux-3.0.25-vs2.3.2.3/arch/mips/kernel/scall32-o32.S 2011-06-10 22:11:24.000000000 +0200
501 @@ -523,7 +523,7 @@ einval: li v0, -ENOSYS
502 sys sys_mq_timedreceive 5
503 sys sys_mq_notify 2 /* 4275 */
504 sys sys_mq_getsetattr 3
505 - sys sys_ni_syscall 0 /* sys_vserver */
508 sys sys_ni_syscall 0 /* available, was setaltroot */
509 sys sys_add_key 5 /* 4280 */
510 diff -NurpP --minimal linux-3.0.25/arch/mips/kernel/scall64-64.S linux-3.0.25-vs2.3.2.3/arch/mips/kernel/scall64-64.S
511 --- linux-3.0.25/arch/mips/kernel/scall64-64.S 2011-07-22 11:17:36.000000000 +0200
512 +++ linux-3.0.25-vs2.3.2.3/arch/mips/kernel/scall64-64.S 2011-06-10 22:11:24.000000000 +0200
513 @@ -362,7 +362,7 @@ sys_call_table:
514 PTR sys_mq_timedreceive
516 PTR sys_mq_getsetattr /* 5235 */
517 - PTR sys_ni_syscall /* sys_vserver */
520 PTR sys_ni_syscall /* available, was setaltroot */
522 diff -NurpP --minimal linux-3.0.25/arch/mips/kernel/scall64-n32.S linux-3.0.25-vs2.3.2.3/arch/mips/kernel/scall64-n32.S
523 --- linux-3.0.25/arch/mips/kernel/scall64-n32.S 2011-07-22 11:17:36.000000000 +0200
524 +++ linux-3.0.25-vs2.3.2.3/arch/mips/kernel/scall64-n32.S 2011-06-10 22:11:24.000000000 +0200
525 @@ -361,7 +361,7 @@ EXPORT(sysn32_call_table)
526 PTR compat_sys_mq_timedreceive
527 PTR compat_sys_mq_notify
528 PTR compat_sys_mq_getsetattr
529 - PTR sys_ni_syscall /* 6240, sys_vserver */
530 + PTR sys32_vserver /* 6240 */
531 PTR compat_sys_waitid
532 PTR sys_ni_syscall /* available, was setaltroot */
534 diff -NurpP --minimal linux-3.0.25/arch/mips/kernel/scall64-o32.S linux-3.0.25-vs2.3.2.3/arch/mips/kernel/scall64-o32.S
535 --- linux-3.0.25/arch/mips/kernel/scall64-o32.S 2011-07-22 11:17:36.000000000 +0200
536 +++ linux-3.0.25-vs2.3.2.3/arch/mips/kernel/scall64-o32.S 2011-06-10 22:11:24.000000000 +0200
537 @@ -480,7 +480,7 @@ sys_call_table:
538 PTR compat_sys_mq_timedreceive
539 PTR compat_sys_mq_notify /* 4275 */
540 PTR compat_sys_mq_getsetattr
541 - PTR sys_ni_syscall /* sys_vserver */
544 PTR sys_ni_syscall /* available, was setaltroot */
545 PTR sys_add_key /* 4280 */
546 diff -NurpP --minimal linux-3.0.25/arch/mips/kernel/traps.c linux-3.0.25-vs2.3.2.3/arch/mips/kernel/traps.c
547 --- linux-3.0.25/arch/mips/kernel/traps.c 2011-05-22 16:17:00.000000000 +0200
548 +++ linux-3.0.25-vs2.3.2.3/arch/mips/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
549 @@ -343,9 +343,10 @@ void show_registers(struct pt_regs *regs
553 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
554 - current->comm, current->pid, current_thread_info(), current,
555 - field, current_thread_info()->tp_value);
556 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
557 + current->comm, task_pid_nr(current), current->xid,
558 + current_thread_info(), current,
559 + field, current_thread_info()->tp_value);
560 if (cpu_has_userlocal) {
563 diff -NurpP --minimal linux-3.0.25/arch/parisc/Kconfig linux-3.0.25-vs2.3.2.3/arch/parisc/Kconfig
564 --- linux-3.0.25/arch/parisc/Kconfig 2011-07-22 11:17:36.000000000 +0200
565 +++ linux-3.0.25-vs2.3.2.3/arch/parisc/Kconfig 2011-06-10 22:11:24.000000000 +0200
566 @@ -279,6 +279,8 @@ source "fs/Kconfig"
568 source "arch/parisc/Kconfig.debug"
570 +source "kernel/vserver/Kconfig"
572 source "security/Kconfig"
574 source "crypto/Kconfig"
575 diff -NurpP --minimal linux-3.0.25/arch/parisc/kernel/syscall_table.S linux-3.0.25-vs2.3.2.3/arch/parisc/kernel/syscall_table.S
576 --- linux-3.0.25/arch/parisc/kernel/syscall_table.S 2012-03-19 21:16:35.000000000 +0100
577 +++ linux-3.0.25-vs2.3.2.3/arch/parisc/kernel/syscall_table.S 2011-08-29 03:45:07.000000000 +0200
579 ENTRY_COMP(mbind) /* 260 */
580 ENTRY_COMP(get_mempolicy)
581 ENTRY_COMP(set_mempolicy)
582 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
583 + ENTRY_DIFF(vserver)
585 ENTRY_SAME(request_key) /* 265 */
587 diff -NurpP --minimal linux-3.0.25/arch/parisc/kernel/traps.c linux-3.0.25-vs2.3.2.3/arch/parisc/kernel/traps.c
588 --- linux-3.0.25/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
589 +++ linux-3.0.25-vs2.3.2.3/arch/parisc/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
590 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
594 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
595 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
596 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
597 + current->comm, task_pid_nr(current), current->xid,
598 + str, err, regs->iaoq[0]);
599 #ifdef PRINT_USER_FAULTS
600 /* XXX for debugging only */
602 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
603 pdc_console_restart();
606 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
607 - current->comm, task_pid_nr(current), str, err);
608 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
609 + current->comm, task_pid_nr(current), current->xid, str, err);
611 /* Wot's wrong wif bein' racy? */
612 if (current->thread.flags & PARISC_KERNEL_DEATH) {
613 diff -NurpP --minimal linux-3.0.25/arch/parisc/mm/fault.c linux-3.0.25-vs2.3.2.3/arch/parisc/mm/fault.c
614 --- linux-3.0.25/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
615 +++ linux-3.0.25-vs2.3.2.3/arch/parisc/mm/fault.c 2011-06-10 22:11:24.000000000 +0200
616 @@ -237,8 +237,9 @@ bad_area:
618 #ifdef PRINT_USER_FAULTS
619 printk(KERN_DEBUG "\n");
620 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
621 - task_pid_nr(tsk), tsk->comm, code, address);
622 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
623 + "command='%s' type=%lu address=0x%08lx\n",
624 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
626 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
627 vma->vm_start, vma->vm_end);
628 diff -NurpP --minimal linux-3.0.25/arch/powerpc/Kconfig linux-3.0.25-vs2.3.2.3/arch/powerpc/Kconfig
629 --- linux-3.0.25/arch/powerpc/Kconfig 2011-07-22 11:17:36.000000000 +0200
630 +++ linux-3.0.25-vs2.3.2.3/arch/powerpc/Kconfig 2011-06-10 22:11:24.000000000 +0200
631 @@ -978,6 +978,8 @@ source "lib/Kconfig"
633 source "arch/powerpc/Kconfig.debug"
635 +source "kernel/vserver/Kconfig"
637 source "security/Kconfig"
640 diff -NurpP --minimal linux-3.0.25/arch/powerpc/include/asm/unistd.h linux-3.0.25-vs2.3.2.3/arch/powerpc/include/asm/unistd.h
641 --- linux-3.0.25/arch/powerpc/include/asm/unistd.h 2011-07-22 11:17:40.000000000 +0200
642 +++ linux-3.0.25-vs2.3.2.3/arch/powerpc/include/asm/unistd.h 2011-06-10 22:11:24.000000000 +0200
645 #define __NR_rtas 255
646 #define __NR_sys_debug_setcontext 256
647 -/* Number 257 is reserved for vserver */
648 +#define __NR_vserver 257
649 #define __NR_migrate_pages 258
650 #define __NR_mbind 259
651 #define __NR_get_mempolicy 260
652 diff -NurpP --minimal linux-3.0.25/arch/powerpc/kernel/process.c linux-3.0.25-vs2.3.2.3/arch/powerpc/kernel/process.c
653 --- linux-3.0.25/arch/powerpc/kernel/process.c 2011-07-22 11:17:40.000000000 +0200
654 +++ linux-3.0.25-vs2.3.2.3/arch/powerpc/kernel/process.c 2011-06-10 22:11:24.000000000 +0200
655 @@ -656,8 +656,9 @@ void show_regs(struct pt_regs * regs)
657 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
659 - printk("TASK = %p[%d] '%s' THREAD: %p",
660 - current, task_pid_nr(current), current->comm, task_thread_info(current));
661 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
662 + current, task_pid_nr(current), current->xid,
663 + current->comm, task_thread_info(current));
666 printk(" CPU: %d", raw_smp_processor_id());
667 diff -NurpP --minimal linux-3.0.25/arch/powerpc/kernel/traps.c linux-3.0.25-vs2.3.2.3/arch/powerpc/kernel/traps.c
668 --- linux-3.0.25/arch/powerpc/kernel/traps.c 2011-07-22 11:17:40.000000000 +0200
669 +++ linux-3.0.25-vs2.3.2.3/arch/powerpc/kernel/traps.c 2011-07-19 00:44:39.000000000 +0200
670 @@ -1075,8 +1075,9 @@ void nonrecoverable_exception(struct pt_
672 void trace_syscall(struct pt_regs *regs)
674 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
675 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
676 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
677 + current, task_pid_nr(current), current->xid,
678 + regs->nip, regs->link, regs->gpr[0],
679 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
682 diff -NurpP --minimal linux-3.0.25/arch/powerpc/kernel/vdso.c linux-3.0.25-vs2.3.2.3/arch/powerpc/kernel/vdso.c
683 --- linux-3.0.25/arch/powerpc/kernel/vdso.c 2011-05-22 16:17:02.000000000 +0200
684 +++ linux-3.0.25-vs2.3.2.3/arch/powerpc/kernel/vdso.c 2011-06-10 22:11:24.000000000 +0200
686 #include <linux/security.h>
687 #include <linux/bootmem.h>
688 #include <linux/memblock.h>
689 +#include <linux/vs_memory.h>
691 #include <asm/pgtable.h>
692 #include <asm/system.h>
693 diff -NurpP --minimal linux-3.0.25/arch/s390/Kconfig linux-3.0.25-vs2.3.2.3/arch/s390/Kconfig
694 --- linux-3.0.25/arch/s390/Kconfig 2012-03-19 21:16:36.000000000 +0100
695 +++ linux-3.0.25-vs2.3.2.3/arch/s390/Kconfig 2012-03-15 13:32:35.000000000 +0100
696 @@ -631,6 +631,8 @@ source "fs/Kconfig"
698 source "arch/s390/Kconfig.debug"
700 +source "kernel/vserver/Kconfig"
702 source "security/Kconfig"
704 source "crypto/Kconfig"
705 diff -NurpP --minimal linux-3.0.25/arch/s390/include/asm/tlb.h linux-3.0.25-vs2.3.2.3/arch/s390/include/asm/tlb.h
706 --- linux-3.0.25/arch/s390/include/asm/tlb.h 2011-07-22 11:17:41.000000000 +0200
707 +++ linux-3.0.25-vs2.3.2.3/arch/s390/include/asm/tlb.h 2011-06-15 02:40:14.000000000 +0200
709 #include <linux/mm.h>
710 #include <linux/pagemap.h>
711 #include <linux/swap.h>
712 +#include <linux/vs_memory.h>
714 #include <asm/processor.h>
715 #include <asm/pgalloc.h>
716 #include <asm/tlbflush.h>
717 diff -NurpP --minimal linux-3.0.25/arch/s390/include/asm/unistd.h linux-3.0.25-vs2.3.2.3/arch/s390/include/asm/unistd.h
718 --- linux-3.0.25/arch/s390/include/asm/unistd.h 2011-07-22 11:17:41.000000000 +0200
719 +++ linux-3.0.25-vs2.3.2.3/arch/s390/include/asm/unistd.h 2011-06-10 22:11:24.000000000 +0200
721 #define __NR_clock_gettime (__NR_timer_create+6)
722 #define __NR_clock_getres (__NR_timer_create+7)
723 #define __NR_clock_nanosleep (__NR_timer_create+8)
724 -/* Number 263 is reserved for vserver */
725 +#define __NR_vserver 263
726 #define __NR_statfs64 265
727 #define __NR_fstatfs64 266
728 #define __NR_remap_file_pages 267
729 diff -NurpP --minimal linux-3.0.25/arch/s390/kernel/ptrace.c linux-3.0.25-vs2.3.2.3/arch/s390/kernel/ptrace.c
730 --- linux-3.0.25/arch/s390/kernel/ptrace.c 2012-03-19 21:16:36.000000000 +0100
731 +++ linux-3.0.25-vs2.3.2.3/arch/s390/kernel/ptrace.c 2012-03-15 13:33:10.000000000 +0100
733 #include <linux/tracehook.h>
734 #include <linux/seccomp.h>
735 #include <linux/compat.h>
736 +#include <linux/vs_base.h>
737 #include <trace/syscall.h>
738 #include <asm/segment.h>
739 #include <asm/page.h>
740 diff -NurpP --minimal linux-3.0.25/arch/s390/kernel/syscalls.S linux-3.0.25-vs2.3.2.3/arch/s390/kernel/syscalls.S
741 --- linux-3.0.25/arch/s390/kernel/syscalls.S 2011-07-22 11:17:41.000000000 +0200
742 +++ linux-3.0.25-vs2.3.2.3/arch/s390/kernel/syscalls.S 2011-06-10 22:11:24.000000000 +0200
743 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
744 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
745 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
746 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
747 -NI_SYSCALL /* reserved for vserver */
748 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
749 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
750 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
751 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
752 diff -NurpP --minimal linux-3.0.25/arch/sh/Kconfig linux-3.0.25-vs2.3.2.3/arch/sh/Kconfig
753 --- linux-3.0.25/arch/sh/Kconfig 2011-07-22 11:17:41.000000000 +0200
754 +++ linux-3.0.25-vs2.3.2.3/arch/sh/Kconfig 2011-07-19 00:44:39.000000000 +0200
755 @@ -893,6 +893,8 @@ source "fs/Kconfig"
757 source "arch/sh/Kconfig.debug"
759 +source "kernel/vserver/Kconfig"
761 source "security/Kconfig"
763 source "crypto/Kconfig"
764 diff -NurpP --minimal linux-3.0.25/arch/sh/kernel/irq.c linux-3.0.25-vs2.3.2.3/arch/sh/kernel/irq.c
765 --- linux-3.0.25/arch/sh/kernel/irq.c 2011-07-22 11:17:41.000000000 +0200
766 +++ linux-3.0.25-vs2.3.2.3/arch/sh/kernel/irq.c 2011-07-19 00:45:06.000000000 +0200
768 #include <linux/ftrace.h>
769 #include <linux/delay.h>
770 #include <linux/ratelimit.h>
771 +// #include <linux/vs_context.h>
772 #include <asm/processor.h>
773 #include <asm/machvec.h>
774 #include <asm/uaccess.h>
775 diff -NurpP --minimal linux-3.0.25/arch/sh/kernel/vsyscall/vsyscall.c linux-3.0.25-vs2.3.2.3/arch/sh/kernel/vsyscall/vsyscall.c
776 --- linux-3.0.25/arch/sh/kernel/vsyscall/vsyscall.c 2011-05-22 16:17:07.000000000 +0200
777 +++ linux-3.0.25-vs2.3.2.3/arch/sh/kernel/vsyscall/vsyscall.c 2011-06-10 22:11:24.000000000 +0200
779 #include <linux/elf.h>
780 #include <linux/sched.h>
781 #include <linux/err.h>
782 +#include <linux/vs_memory.h>
785 * Should the kernel map a VDSO page into processes and pass its
786 diff -NurpP --minimal linux-3.0.25/arch/sparc/Kconfig linux-3.0.25-vs2.3.2.3/arch/sparc/Kconfig
787 --- linux-3.0.25/arch/sparc/Kconfig 2012-03-19 21:16:36.000000000 +0100
788 +++ linux-3.0.25-vs2.3.2.3/arch/sparc/Kconfig 2011-10-18 13:51:13.000000000 +0200
789 @@ -602,6 +602,8 @@ source "fs/Kconfig"
791 source "arch/sparc/Kconfig.debug"
793 +source "kernel/vserver/Kconfig"
795 source "security/Kconfig"
797 source "crypto/Kconfig"
798 diff -NurpP --minimal linux-3.0.25/arch/sparc/include/asm/tlb_64.h linux-3.0.25-vs2.3.2.3/arch/sparc/include/asm/tlb_64.h
799 --- linux-3.0.25/arch/sparc/include/asm/tlb_64.h 2011-07-22 11:17:42.000000000 +0200
800 +++ linux-3.0.25-vs2.3.2.3/arch/sparc/include/asm/tlb_64.h 2011-06-10 22:11:24.000000000 +0200
803 #include <linux/swap.h>
804 #include <linux/pagemap.h>
805 +#include <linux/vs_memory.h>
806 #include <asm/pgalloc.h>
807 #include <asm/tlbflush.h>
808 #include <asm/mmu_context.h>
809 diff -NurpP --minimal linux-3.0.25/arch/sparc/include/asm/unistd.h linux-3.0.25-vs2.3.2.3/arch/sparc/include/asm/unistd.h
810 --- linux-3.0.25/arch/sparc/include/asm/unistd.h 2011-07-22 11:17:42.000000000 +0200
811 +++ linux-3.0.25-vs2.3.2.3/arch/sparc/include/asm/unistd.h 2011-06-10 22:11:24.000000000 +0200
813 #define __NR_timer_getoverrun 264
814 #define __NR_timer_delete 265
815 #define __NR_timer_create 266
816 -/* #define __NR_vserver 267 Reserved for VSERVER */
817 +#define __NR_vserver 267
818 #define __NR_io_setup 268
819 #define __NR_io_destroy 269
820 #define __NR_io_submit 270
821 diff -NurpP --minimal linux-3.0.25/arch/sparc/kernel/systbls_32.S linux-3.0.25-vs2.3.2.3/arch/sparc/kernel/systbls_32.S
822 --- linux-3.0.25/arch/sparc/kernel/systbls_32.S 2011-07-22 11:17:42.000000000 +0200
823 +++ linux-3.0.25-vs2.3.2.3/arch/sparc/kernel/systbls_32.S 2011-06-10 22:11:24.000000000 +0200
824 @@ -70,7 +70,7 @@ sys_call_table:
825 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
826 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
827 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
828 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
829 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
830 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
831 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
832 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
833 diff -NurpP --minimal linux-3.0.25/arch/sparc/kernel/systbls_64.S linux-3.0.25-vs2.3.2.3/arch/sparc/kernel/systbls_64.S
834 --- linux-3.0.25/arch/sparc/kernel/systbls_64.S 2011-07-22 11:17:42.000000000 +0200
835 +++ linux-3.0.25-vs2.3.2.3/arch/sparc/kernel/systbls_64.S 2011-06-10 22:11:24.000000000 +0200
836 @@ -71,7 +71,7 @@ sys_call_table32:
837 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
838 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
839 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
840 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
841 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
842 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
843 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
844 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
845 @@ -148,7 +148,7 @@ sys_call_table:
846 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
847 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
848 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
849 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
850 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
851 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
852 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
853 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
854 diff -NurpP --minimal linux-3.0.25/arch/um/Kconfig.rest linux-3.0.25-vs2.3.2.3/arch/um/Kconfig.rest
855 --- linux-3.0.25/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
856 +++ linux-3.0.25-vs2.3.2.3/arch/um/Kconfig.rest 2011-06-10 22:11:24.000000000 +0200
857 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
861 +source "kernel/vserver/Kconfig"
863 source "security/Kconfig"
865 source "crypto/Kconfig"
866 diff -NurpP --minimal linux-3.0.25/arch/um/include/asm/tlb.h linux-3.0.25-vs2.3.2.3/arch/um/include/asm/tlb.h
867 --- linux-3.0.25/arch/um/include/asm/tlb.h 2011-07-22 11:17:42.000000000 +0200
868 +++ linux-3.0.25-vs2.3.2.3/arch/um/include/asm/tlb.h 2011-06-10 22:11:24.000000000 +0200
871 #include <linux/pagemap.h>
872 #include <linux/swap.h>
873 +#include <linux/vs_memory.h>
874 #include <asm/percpu.h>
875 #include <asm/pgalloc.h>
876 #include <asm/tlbflush.h>
877 diff -NurpP --minimal linux-3.0.25/arch/x86/Kconfig linux-3.0.25-vs2.3.2.3/arch/x86/Kconfig
878 --- linux-3.0.25/arch/x86/Kconfig 2011-07-22 11:17:42.000000000 +0200
879 +++ linux-3.0.25-vs2.3.2.3/arch/x86/Kconfig 2011-07-22 11:20:39.000000000 +0200
880 @@ -2159,6 +2159,8 @@ source "fs/Kconfig"
882 source "arch/x86/Kconfig.debug"
884 +source "kernel/vserver/Kconfig"
886 source "security/Kconfig"
888 source "crypto/Kconfig"
889 diff -NurpP --minimal linux-3.0.25/arch/x86/ia32/ia32entry.S linux-3.0.25-vs2.3.2.3/arch/x86/ia32/ia32entry.S
890 --- linux-3.0.25/arch/x86/ia32/ia32entry.S 2011-07-22 11:17:42.000000000 +0200
891 +++ linux-3.0.25-vs2.3.2.3/arch/x86/ia32/ia32entry.S 2011-06-10 22:11:24.000000000 +0200
892 @@ -776,7 +776,7 @@ ia32_sys_call_table:
893 .quad sys_tgkill /* 270 */
894 .quad compat_sys_utimes
895 .quad sys32_fadvise64_64
896 - .quad quiet_ni_syscall /* sys_vserver */
897 + .quad sys32_vserver
899 .quad compat_sys_get_mempolicy /* 275 */
900 .quad sys_set_mempolicy
901 diff -NurpP --minimal linux-3.0.25/arch/x86/include/asm/unistd_64.h linux-3.0.25-vs2.3.2.3/arch/x86/include/asm/unistd_64.h
902 --- linux-3.0.25/arch/x86/include/asm/unistd_64.h 2011-07-22 11:17:43.000000000 +0200
903 +++ linux-3.0.25-vs2.3.2.3/arch/x86/include/asm/unistd_64.h 2011-06-10 22:11:24.000000000 +0200
904 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
905 #define __NR_utimes 235
906 __SYSCALL(__NR_utimes, sys_utimes)
907 #define __NR_vserver 236
908 -__SYSCALL(__NR_vserver, sys_ni_syscall)
909 +__SYSCALL(__NR_vserver, sys_vserver)
910 #define __NR_mbind 237
911 __SYSCALL(__NR_mbind, sys_mbind)
912 #define __NR_set_mempolicy 238
913 diff -NurpP --minimal linux-3.0.25/arch/x86/kernel/syscall_table_32.S linux-3.0.25-vs2.3.2.3/arch/x86/kernel/syscall_table_32.S
914 --- linux-3.0.25/arch/x86/kernel/syscall_table_32.S 2011-07-22 11:17:43.000000000 +0200
915 +++ linux-3.0.25-vs2.3.2.3/arch/x86/kernel/syscall_table_32.S 2011-06-10 22:11:24.000000000 +0200
916 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
917 .long sys_tgkill /* 270 */
919 .long sys_fadvise64_64
920 - .long sys_ni_syscall /* sys_vserver */
923 .long sys_get_mempolicy
924 .long sys_set_mempolicy
925 diff -NurpP --minimal linux-3.0.25/block/genhd.c linux-3.0.25-vs2.3.2.3/block/genhd.c
926 --- linux-3.0.25/block/genhd.c 2012-03-19 21:16:38.000000000 +0100
927 +++ linux-3.0.25-vs2.3.2.3/block/genhd.c 2012-03-23 14:54:00.000000000 +0100
928 @@ -1165,17 +1165,17 @@ static int diskstats_show(struct seq_fil
929 cpu = part_stat_lock();
930 part_round_stats(cpu, hd);
932 - seq_printf(seqf, "%4d %7d %s %lu %lu %llu "
933 - "%u %lu %lu %llu %u %u %u %u\n",
934 + seq_printf(seqf, "%4d %7d %s %lu %lu %lu "
935 + "%u %lu %lu %lu %u %u %u %u\n",
936 MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
937 disk_name(gp, hd->partno, buf),
938 part_stat_read(hd, ios[READ]),
939 part_stat_read(hd, merges[READ]),
940 - (unsigned long long)part_stat_read(hd, sectors[READ]),
941 + part_stat_read(hd, sectors[READ]),
942 jiffies_to_msecs(part_stat_read(hd, ticks[READ])),
943 part_stat_read(hd, ios[WRITE]),
944 part_stat_read(hd, merges[WRITE]),
945 - (unsigned long long)part_stat_read(hd, sectors[WRITE]),
946 + part_stat_read(hd, sectors[WRITE]),
947 jiffies_to_msecs(part_stat_read(hd, ticks[WRITE])),
949 jiffies_to_msecs(part_stat_read(hd, io_ticks)),
950 diff -NurpP --minimal linux-3.0.25/drivers/block/Kconfig linux-3.0.25-vs2.3.2.3/drivers/block/Kconfig
951 --- linux-3.0.25/drivers/block/Kconfig 2011-07-22 11:17:44.000000000 +0200
952 +++ linux-3.0.25-vs2.3.2.3/drivers/block/Kconfig 2011-06-10 22:11:24.000000000 +0200
953 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
955 source "drivers/block/drbd/Kconfig"
957 +config BLK_DEV_VROOT
958 + tristate "Virtual Root device support"
959 + depends on QUOTACTL
961 + Saying Y here will allow you to use quota/fs ioctls on a shared
962 + partition within a virtual server without compromising security.
965 tristate "Network block device support"
967 diff -NurpP --minimal linux-3.0.25/drivers/block/Makefile linux-3.0.25-vs2.3.2.3/drivers/block/Makefile
968 --- linux-3.0.25/drivers/block/Makefile 2011-07-22 11:17:44.000000000 +0200
969 +++ linux-3.0.25-vs2.3.2.3/drivers/block/Makefile 2011-06-10 22:11:24.000000000 +0200
970 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
971 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
972 obj-$(CONFIG_BLK_DEV_UB) += ub.o
973 obj-$(CONFIG_BLK_DEV_HD) += hd.o
974 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
976 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
977 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
978 diff -NurpP --minimal linux-3.0.25/drivers/block/loop.c linux-3.0.25-vs2.3.2.3/drivers/block/loop.c
979 --- linux-3.0.25/drivers/block/loop.c 2012-03-19 21:16:39.000000000 +0100
980 +++ linux-3.0.25-vs2.3.2.3/drivers/block/loop.c 2011-08-31 19:37:44.000000000 +0200
982 #include <linux/kthread.h>
983 #include <linux/splice.h>
984 #include <linux/sysfs.h>
985 +#include <linux/vs_context.h>
987 #include <asm/uaccess.h>
989 @@ -891,6 +892,7 @@ static int loop_set_fd(struct loop_devic
990 lo->lo_blocksize = lo_blocksize;
991 lo->lo_device = bdev;
992 lo->lo_flags = lo_flags;
993 + lo->lo_xid = vx_current_xid();
994 lo->lo_backing_file = file;
995 lo->transfer = transfer_none;
997 @@ -1021,6 +1023,7 @@ static int loop_clr_fd(struct loop_devic
998 lo->lo_encrypt_key_size = 0;
1000 lo->lo_thread = NULL;
1002 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1003 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1004 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1005 @@ -1059,7 +1062,7 @@ loop_set_status(struct loop_device *lo,
1007 if (lo->lo_encrypt_key_size &&
1008 lo->lo_key_owner != uid &&
1009 - !capable(CAP_SYS_ADMIN))
1010 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1012 if (lo->lo_state != Lo_bound)
1014 @@ -1143,7 +1146,8 @@ loop_get_status(struct loop_device *lo,
1015 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1016 info->lo_encrypt_type =
1017 lo->lo_encryption ? lo->lo_encryption->number : 0;
1018 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1019 + if (lo->lo_encrypt_key_size &&
1020 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1021 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1022 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1023 lo->lo_encrypt_key_size);
1024 @@ -1489,6 +1493,9 @@ static int lo_open(struct block_device *
1026 struct loop_device *lo = bdev->bd_disk->private_data;
1028 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1031 mutex_lock(&lo->lo_ctl_mutex);
1033 mutex_unlock(&lo->lo_ctl_mutex);
1034 diff -NurpP --minimal linux-3.0.25/drivers/block/vroot.c linux-3.0.25-vs2.3.2.3/drivers/block/vroot.c
1035 --- linux-3.0.25/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1036 +++ linux-3.0.25-vs2.3.2.3/drivers/block/vroot.c 2011-06-10 22:11:24.000000000 +0200
1039 + * linux/drivers/block/vroot.c
1041 + * written by Herbert Pötzl, 9/11/2002
1042 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1044 + * based on the loop.c code by Theodore Ts'o.
1046 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1047 + * Redistribution of this file is permitted under the
1048 + * GNU General Public License.
1052 +#include <linux/module.h>
1053 +#include <linux/moduleparam.h>
1054 +#include <linux/file.h>
1055 +#include <linux/major.h>
1056 +#include <linux/blkdev.h>
1057 +#include <linux/slab.h>
1059 +#include <linux/vroot.h>
1060 +#include <linux/vs_context.h>
1063 +static int max_vroot = 8;
1065 +static struct vroot_device *vroot_dev;
1066 +static struct gendisk **disks;
1069 +static int vroot_set_dev(
1070 + struct vroot_device *vr,
1071 + struct block_device *bdev,
1074 + struct block_device *real_bdev;
1075 + struct file *file;
1076 + struct inode *inode;
1080 + if (vr->vr_state != Vr_unbound)
1089 + inode = file->f_dentry->d_inode;
1092 + if (S_ISBLK(inode->i_mode)) {
1093 + real_bdev = inode->i_bdev;
1094 + vr->vr_device = real_bdev;
1095 + __iget(real_bdev->bd_inode);
1099 + vxdprintk(VXD_CBIT(misc, 0),
1100 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1101 + vr->vr_number, VXD_DEV(real_bdev));
1103 + vr->vr_state = Vr_bound;
1112 +static int vroot_clr_dev(
1113 + struct vroot_device *vr,
1114 + struct block_device *bdev)
1116 + struct block_device *real_bdev;
1118 + if (vr->vr_state != Vr_bound)
1120 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1123 + real_bdev = vr->vr_device;
1125 + vxdprintk(VXD_CBIT(misc, 0),
1126 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1127 + vr->vr_number, VXD_DEV(real_bdev));
1130 + vr->vr_state = Vr_unbound;
1131 + vr->vr_device = NULL;
1136 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1137 + unsigned int cmd, unsigned long arg)
1139 + struct vroot_device *vr = bdev->bd_disk->private_data;
1142 + down(&vr->vr_ctl_mutex);
1144 + case VROOT_SET_DEV:
1145 + err = vroot_set_dev(vr, bdev, arg);
1147 + case VROOT_CLR_DEV:
1148 + err = vroot_clr_dev(vr, bdev);
1154 + up(&vr->vr_ctl_mutex);
1158 +static int vr_open(struct block_device *bdev, fmode_t mode)
1160 + struct vroot_device *vr = bdev->bd_disk->private_data;
1162 + down(&vr->vr_ctl_mutex);
1164 + up(&vr->vr_ctl_mutex);
1168 +static int vr_release(struct gendisk *disk, fmode_t mode)
1170 + struct vroot_device *vr = disk->private_data;
1172 + down(&vr->vr_ctl_mutex);
1174 + up(&vr->vr_ctl_mutex);
1178 +static struct block_device_operations vr_fops = {
1179 + .owner = THIS_MODULE,
1181 + .release = vr_release,
1182 + .ioctl = vr_ioctl,
1185 +static int vroot_make_request(struct request_queue *q, struct bio *bio)
1187 + printk("vroot_make_request %p, %p\n", q, bio);
1188 + bio_io_error(bio);
1192 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1194 + struct inode *inode = bdev->bd_inode;
1195 + struct vroot_device *vr;
1196 + struct block_device *real_bdev;
1197 + int minor = iminor(inode);
1199 + vr = &vroot_dev[minor];
1200 + real_bdev = vr->vr_device;
1202 + vxdprintk(VXD_CBIT(misc, 0),
1203 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1204 + vr->vr_number, VXD_DEV(real_bdev));
1206 + if (vr->vr_state != Vr_bound)
1207 + return ERR_PTR(-ENXIO);
1209 + __iget(real_bdev->bd_inode);
1216 + * And now the modules code and kernel interface.
1219 +module_param(max_vroot, int, 0);
1221 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1222 +MODULE_LICENSE("GPL");
1223 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1225 +MODULE_AUTHOR ("Herbert Pötzl");
1226 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1229 +int __init vroot_init(void)
1233 + if (max_vroot < 1 || max_vroot > 256) {
1234 + max_vroot = MAX_VROOT_DEFAULT;
1235 + printk(KERN_WARNING "vroot: invalid max_vroot "
1236 + "(must be between 1 and 256), "
1237 + "using default (%d)\n", max_vroot);
1240 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1244 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1247 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1249 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1253 + for (i = 0; i < max_vroot; i++) {
1254 + disks[i] = alloc_disk(1);
1257 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1258 + if (!disks[i]->queue)
1260 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1263 + for (i = 0; i < max_vroot; i++) {
1264 + struct vroot_device *vr = &vroot_dev[i];
1265 + struct gendisk *disk = disks[i];
1267 + memset(vr, 0, sizeof(*vr));
1268 + sema_init(&vr->vr_ctl_mutex, 1);
1269 + vr->vr_number = i;
1270 + disk->major = VROOT_MAJOR;
1271 + disk->first_minor = i;
1272 + disk->fops = &vr_fops;
1273 + sprintf(disk->disk_name, "vroot%d", i);
1274 + disk->private_data = vr;
1277 + err = register_vroot_grb(&__vroot_get_real_bdev);
1281 + for (i = 0; i < max_vroot; i++)
1282 + add_disk(disks[i]);
1283 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1288 + put_disk(disks[i]);
1293 + unregister_blkdev(VROOT_MAJOR, "vroot");
1294 + printk(KERN_ERR "vroot: ran out of memory\n");
1298 +void vroot_exit(void)
1302 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1303 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1305 + for (i = 0; i < max_vroot; i++) {
1306 + del_gendisk(disks[i]);
1307 + put_disk(disks[i]);
1309 + unregister_blkdev(VROOT_MAJOR, "vroot");
1315 +module_init(vroot_init);
1316 +module_exit(vroot_exit);
1320 +static int __init max_vroot_setup(char *str)
1322 + max_vroot = simple_strtol(str, NULL, 0);
1326 +__setup("max_vroot=", max_vroot_setup);
1330 diff -NurpP --minimal linux-3.0.25/drivers/infiniband/Kconfig linux-3.0.25-vs2.3.2.3/drivers/infiniband/Kconfig
1331 --- linux-3.0.25/drivers/infiniband/Kconfig 2011-07-22 11:17:45.000000000 +0200
1332 +++ linux-3.0.25-vs2.3.2.3/drivers/infiniband/Kconfig 2012-02-15 05:19:42.000000000 +0100
1333 @@ -39,7 +39,7 @@ config INFINIBAND_USER_MEM
1334 config INFINIBAND_ADDR_TRANS
1337 - depends on !(INFINIBAND = y && IPV6 = m)
1338 + depends on !(INFINIBAND = y && IPV6 = y)
1341 source "drivers/infiniband/hw/mthca/Kconfig"
1342 diff -NurpP --minimal linux-3.0.25/drivers/infiniband/core/addr.c linux-3.0.25-vs2.3.2.3/drivers/infiniband/core/addr.c
1343 --- linux-3.0.25/drivers/infiniband/core/addr.c 2012-03-19 21:16:40.000000000 +0100
1344 +++ linux-3.0.25-vs2.3.2.3/drivers/infiniband/core/addr.c 2012-02-15 05:20:43.000000000 +0100
1345 @@ -254,7 +254,7 @@ static int addr6_resolve(struct sockaddr
1347 if (ipv6_addr_any(&fl6.saddr)) {
1348 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1349 - &fl6.daddr, 0, &fl6.saddr);
1350 + &fl6.daddr, 0, &fl6.saddr, NULL);
1354 diff -NurpP --minimal linux-3.0.25/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-3.0.25-vs2.3.2.3/drivers/infiniband/hw/ipath/ipath_user_pages.c
1355 --- linux-3.0.25/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-05-22 16:17:16.000000000 +0200
1356 +++ linux-3.0.25-vs2.3.2.3/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-06-10 22:11:24.000000000 +0200
1358 #include <linux/device.h>
1359 #include <linux/slab.h>
1360 #include <linux/sched.h>
1361 +#include <linux/vs_memory.h>
1363 #include "ipath_kernel.h"
1365 diff -NurpP --minimal linux-3.0.25/drivers/md/dm-ioctl.c linux-3.0.25-vs2.3.2.3/drivers/md/dm-ioctl.c
1366 --- linux-3.0.25/drivers/md/dm-ioctl.c 2011-05-22 16:17:18.000000000 +0200
1367 +++ linux-3.0.25-vs2.3.2.3/drivers/md/dm-ioctl.c 2011-06-10 22:11:24.000000000 +0200
1369 #include <linux/dm-ioctl.h>
1370 #include <linux/hdreg.h>
1371 #include <linux/compat.h>
1372 +#include <linux/vs_context.h>
1374 #include <asm/uaccess.h>
1376 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1377 unsigned int h = hash_str(str);
1379 list_for_each_entry (hc, _name_buckets + h, name_list)
1380 - if (!strcmp(hc->name, str)) {
1381 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1382 + !strcmp(hc->name, str)) {
1386 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1387 unsigned int h = hash_str(str);
1389 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1390 - if (!strcmp(hc->uuid, str)) {
1391 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1392 + !strcmp(hc->uuid, str)) {
1396 @@ -427,6 +430,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1398 static int remove_all(struct dm_ioctl *param, size_t param_size)
1400 + if (!vx_check(0, VS_ADMIN))
1403 dm_hash_remove_all(1);
1404 param->data_size = 0;
1406 @@ -474,6 +480,8 @@ static int list_devices(struct dm_ioctl
1408 for (i = 0; i < NUM_BUCKETS; i++) {
1409 list_for_each_entry (hc, _name_buckets + i, name_list) {
1410 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1412 needed += sizeof(struct dm_name_list);
1413 needed += strlen(hc->name) + 1;
1414 needed += ALIGN_MASK;
1415 @@ -497,6 +505,8 @@ static int list_devices(struct dm_ioctl
1417 for (i = 0; i < NUM_BUCKETS; i++) {
1418 list_for_each_entry (hc, _name_buckets + i, name_list) {
1419 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1422 old_nl->next = (uint32_t) ((void *) nl -
1424 @@ -731,10 +741,11 @@ static struct hash_cell *__find_device_h
1428 - mdptr = dm_get_mdptr(md);
1429 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1430 + mdptr = dm_get_mdptr(md);
1438 @@ -1577,8 +1588,8 @@ static int ctl_ioctl(uint command, struc
1440 size_t input_param_size;
1442 - /* only root can play with this */
1443 - if (!capable(CAP_SYS_ADMIN))
1444 + /* only root and certain contexts can play with this */
1445 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1448 if (_IOC_TYPE(command) != DM_IOCTL)
1449 diff -NurpP --minimal linux-3.0.25/drivers/md/dm.c linux-3.0.25-vs2.3.2.3/drivers/md/dm.c
1450 --- linux-3.0.25/drivers/md/dm.c 2012-03-19 21:16:41.000000000 +0100
1451 +++ linux-3.0.25-vs2.3.2.3/drivers/md/dm.c 2011-08-08 23:04:47.000000000 +0200
1453 #include <linux/idr.h>
1454 #include <linux/hdreg.h>
1455 #include <linux/delay.h>
1456 +#include <linux/vs_base.h>
1458 #include <trace/events/block.h>
1460 @@ -121,6 +122,7 @@ struct mapped_device {
1463 atomic_t open_count;
1466 unsigned long flags;
1468 @@ -334,6 +336,7 @@ int dm_deleting_md(struct mapped_device
1469 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1471 struct mapped_device *md;
1474 spin_lock(&_minor_lock);
1476 @@ -342,18 +345,19 @@ static int dm_blk_open(struct block_devi
1479 if (test_bit(DMF_FREEING, &md->flags) ||
1480 - dm_deleting_md(md)) {
1482 + dm_deleting_md(md))
1486 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1491 atomic_inc(&md->open_count);
1495 spin_unlock(&_minor_lock);
1497 - return md ? 0 : -ENXIO;
1501 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1502 @@ -574,6 +578,14 @@ int dm_set_geometry(struct mapped_device
1507 + * Get the xid associated with a dm device
1509 +xid_t dm_get_xid(struct mapped_device *md)
1514 /*-----------------------------------------------------------------
1516 * A more elegant soln is in the works that uses the queue
1517 @@ -1847,6 +1859,7 @@ static struct mapped_device *alloc_dev(i
1518 INIT_LIST_HEAD(&md->uevent_list);
1519 spin_lock_init(&md->uevent_lock);
1521 + md->xid = vx_current_xid();
1522 md->queue = blk_alloc_queue(GFP_KERNEL);
1525 diff -NurpP --minimal linux-3.0.25/drivers/md/dm.h linux-3.0.25-vs2.3.2.3/drivers/md/dm.h
1526 --- linux-3.0.25/drivers/md/dm.h 2011-05-22 16:17:18.000000000 +0200
1527 +++ linux-3.0.25-vs2.3.2.3/drivers/md/dm.h 2011-06-10 22:11:24.000000000 +0200
1528 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1530 struct dm_md_mempools;
1532 +xid_t dm_get_xid(struct mapped_device *md);
1534 /*-----------------------------------------------------------------
1535 * Internal table functions.
1536 *---------------------------------------------------------------*/
1537 diff -NurpP --minimal linux-3.0.25/drivers/net/tun.c linux-3.0.25-vs2.3.2.3/drivers/net/tun.c
1538 --- linux-3.0.25/drivers/net/tun.c 2012-03-19 21:16:45.000000000 +0100
1539 +++ linux-3.0.25-vs2.3.2.3/drivers/net/tun.c 2011-08-29 03:45:08.000000000 +0200
1541 #include <linux/nsproxy.h>
1542 #include <linux/virtio_net.h>
1543 #include <linux/rcupdate.h>
1544 +#include <linux/vs_network.h>
1545 #include <net/net_namespace.h>
1546 #include <net/netns/generic.h>
1547 #include <net/rtnetlink.h>
1548 @@ -121,6 +122,7 @@ struct tun_struct {
1554 struct net_device *dev;
1556 @@ -905,6 +907,7 @@ static void tun_setup(struct net_device
1560 + tun->nid = current->nid;
1562 dev->ethtool_ops = &tun_ethtool_ops;
1563 dev->destructor = tun_free_netdev;
1564 @@ -1055,7 +1058,7 @@ static int tun_set_iff(struct net *net,
1566 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1567 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1568 - !capable(CAP_NET_ADMIN))
1569 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1571 err = security_tun_dev_attach(tun->socket.sk);
1573 @@ -1069,7 +1072,7 @@ static int tun_set_iff(struct net *net,
1575 unsigned long flags = 0;
1577 - if (!capable(CAP_NET_ADMIN))
1578 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1580 err = security_tun_dev_create();
1582 @@ -1137,6 +1140,9 @@ static int tun_set_iff(struct net *net,
1584 sk->sk_destruct = tun_sock_destruct;
1586 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1589 err = tun_attach(tun, file);
1592 @@ -1318,6 +1324,16 @@ static long __tun_chr_ioctl(struct file
1593 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
1597 + if (!capable(CAP_CONTEXT))
1600 + /* Set nid owner of the device */
1601 + tun->nid = (nid_t) arg;
1603 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1607 /* Only allow setting the type when the interface is down */
1608 if (tun->dev->flags & IFF_UP) {
1609 diff -NurpP --minimal linux-3.0.25/drivers/tty/sysrq.c linux-3.0.25-vs2.3.2.3/drivers/tty/sysrq.c
1610 --- linux-3.0.25/drivers/tty/sysrq.c 2011-05-22 16:17:44.000000000 +0200
1611 +++ linux-3.0.25-vs2.3.2.3/drivers/tty/sysrq.c 2011-06-10 22:11:24.000000000 +0200
1613 #include <linux/oom.h>
1614 #include <linux/slab.h>
1615 #include <linux/input.h>
1616 +#include <linux/vserver/debug.h>
1618 #include <asm/ptrace.h>
1619 #include <asm/irq_regs.h>
1620 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
1621 .enable_mask = SYSRQ_ENABLE_RTNICE,
1625 +#ifdef CONFIG_VSERVER_DEBUG
1626 +static void sysrq_handle_vxinfo(int key)
1628 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1631 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1632 + .handler = sysrq_handle_vxinfo,
1633 + .help_msg = "conteXt",
1634 + .action_msg = "Show Context Info",
1635 + .enable_mask = SYSRQ_ENABLE_DUMP,
1639 /* Key Operations table and lock */
1640 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1642 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
1644 &sysrq_showstate_blocked_op, /* w */
1645 /* x: May be registered on ppc/powerpc for xmon */
1646 +#ifdef CONFIG_VSERVER_DEBUG
1647 + &sysrq_showvxinfo_op, /* x */
1651 /* y: May be registered on sparc64 for global register dump */
1653 &sysrq_ftrace_dump_op, /* z */
1654 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
1656 else if ((key >= 'a') && (key <= 'z'))
1657 retval = key + 10 - 'a';
1658 + else if ((key >= 'A') && (key <= 'Z'))
1659 + retval = key + 10 - 'A';
1663 diff -NurpP --minimal linux-3.0.25/drivers/tty/tty_io.c linux-3.0.25-vs2.3.2.3/drivers/tty/tty_io.c
1664 --- linux-3.0.25/drivers/tty/tty_io.c 2012-03-19 21:16:50.000000000 +0100
1665 +++ linux-3.0.25-vs2.3.2.3/drivers/tty/tty_io.c 2011-11-15 17:37:05.000000000 +0100
1668 #include <linux/kmod.h>
1669 #include <linux/nsproxy.h>
1670 +#include <linux/vs_pid.h>
1672 #undef TTY_DEBUG_HANGUP
1674 @@ -2080,7 +2081,8 @@ static int tiocsti(struct tty_struct *tt
1676 struct tty_ldisc *ld;
1678 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1679 + if (((current->signal->tty != tty) &&
1680 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1682 if (get_user(ch, p))
1684 @@ -2368,6 +2370,7 @@ static int tiocspgrp(struct tty_struct *
1686 if (get_user(pgrp_nr, p))
1688 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1692 diff -NurpP --minimal linux-3.0.25/fs/attr.c linux-3.0.25-vs2.3.2.3/fs/attr.c
1693 --- linux-3.0.25/fs/attr.c 2011-07-22 11:18:05.000000000 +0200
1694 +++ linux-3.0.25-vs2.3.2.3/fs/attr.c 2011-06-10 22:11:24.000000000 +0200
1696 #include <linux/fsnotify.h>
1697 #include <linux/fcntl.h>
1698 #include <linux/security.h>
1699 +#include <linux/proc_fs.h>
1700 +#include <linux/devpts_fs.h>
1701 +#include <linux/vs_tag.h>
1704 * inode_change_ok - check if attribute changes to an inode are allowed
1705 @@ -73,6 +76,10 @@ int inode_change_ok(const struct inode *
1709 + /* check for inode tag permission */
1710 + if (dx_permission(inode, MAY_WRITE))
1715 EXPORT_SYMBOL(inode_change_ok);
1716 @@ -143,6 +150,8 @@ void setattr_copy(struct inode *inode, c
1717 inode->i_uid = attr->ia_uid;
1718 if (ia_valid & ATTR_GID)
1719 inode->i_gid = attr->ia_gid;
1720 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1721 + inode->i_tag = attr->ia_tag;
1722 if (ia_valid & ATTR_ATIME)
1723 inode->i_atime = timespec_trunc(attr->ia_atime,
1724 inode->i_sb->s_time_gran);
1725 @@ -170,7 +179,8 @@ int notify_change(struct dentry * dentry
1726 struct timespec now;
1727 unsigned int ia_valid = attr->ia_valid;
1729 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1730 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1731 + ATTR_TAG | ATTR_TIMES_SET)) {
1732 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1735 diff -NurpP --minimal linux-3.0.25/fs/binfmt_aout.c linux-3.0.25-vs2.3.2.3/fs/binfmt_aout.c
1736 --- linux-3.0.25/fs/binfmt_aout.c 2010-10-21 13:07:47.000000000 +0200
1737 +++ linux-3.0.25-vs2.3.2.3/fs/binfmt_aout.c 2011-06-10 22:11:24.000000000 +0200
1739 #include <linux/init.h>
1740 #include <linux/coredump.h>
1741 #include <linux/slab.h>
1742 +#include <linux/vs_memory.h>
1744 #include <asm/system.h>
1745 #include <asm/uaccess.h>
1746 diff -NurpP --minimal linux-3.0.25/fs/binfmt_elf.c linux-3.0.25-vs2.3.2.3/fs/binfmt_elf.c
1747 --- linux-3.0.25/fs/binfmt_elf.c 2012-03-19 21:16:51.000000000 +0100
1748 +++ linux-3.0.25-vs2.3.2.3/fs/binfmt_elf.c 2012-03-15 13:32:35.000000000 +0100
1750 #include <linux/elf.h>
1751 #include <linux/utsname.h>
1752 #include <linux/coredump.h>
1753 +#include <linux/vs_memory.h>
1754 #include <asm/uaccess.h>
1755 #include <asm/param.h>
1756 #include <asm/page.h>
1757 diff -NurpP --minimal linux-3.0.25/fs/binfmt_flat.c linux-3.0.25-vs2.3.2.3/fs/binfmt_flat.c
1758 --- linux-3.0.25/fs/binfmt_flat.c 2011-07-22 11:18:05.000000000 +0200
1759 +++ linux-3.0.25-vs2.3.2.3/fs/binfmt_flat.c 2011-06-10 22:11:24.000000000 +0200
1761 #include <linux/init.h>
1762 #include <linux/flat.h>
1763 #include <linux/syscalls.h>
1764 +#include <linux/vs_memory.h>
1766 #include <asm/byteorder.h>
1767 #include <asm/system.h>
1768 diff -NurpP --minimal linux-3.0.25/fs/binfmt_som.c linux-3.0.25-vs2.3.2.3/fs/binfmt_som.c
1769 --- linux-3.0.25/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
1770 +++ linux-3.0.25-vs2.3.2.3/fs/binfmt_som.c 2011-06-10 22:11:24.000000000 +0200
1772 #include <linux/shm.h>
1773 #include <linux/personality.h>
1774 #include <linux/init.h>
1775 +#include <linux/vs_memory.h>
1777 #include <asm/uaccess.h>
1778 #include <asm/pgtable.h>
1779 diff -NurpP --minimal linux-3.0.25/fs/block_dev.c linux-3.0.25-vs2.3.2.3/fs/block_dev.c
1780 --- linux-3.0.25/fs/block_dev.c 2012-03-19 21:16:51.000000000 +0100
1781 +++ linux-3.0.25-vs2.3.2.3/fs/block_dev.c 2012-03-23 14:54:00.000000000 +0100
1783 #include <linux/namei.h>
1784 #include <linux/log2.h>
1785 #include <linux/kmemleak.h>
1786 +#include <linux/vs_device.h>
1787 #include <asm/uaccess.h>
1788 #include "internal.h"
1790 @@ -553,6 +554,7 @@ struct block_device *bdget(dev_t dev)
1791 bdev->bd_invalidated = 0;
1792 inode->i_mode = S_IFBLK;
1793 inode->i_rdev = dev;
1794 + inode->i_mdev = dev;
1795 inode->i_bdev = bdev;
1796 inode->i_data.a_ops = &def_blk_aops;
1797 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1798 @@ -599,6 +601,11 @@ EXPORT_SYMBOL(bdput);
1799 static struct block_device *bd_acquire(struct inode *inode)
1801 struct block_device *bdev;
1804 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1806 + inode->i_mdev = mdev;
1808 spin_lock(&bdev_lock);
1809 bdev = inode->i_bdev;
1810 @@ -609,7 +616,7 @@ static struct block_device *bd_acquire(s
1812 spin_unlock(&bdev_lock);
1814 - bdev = bdget(inode->i_rdev);
1815 + bdev = bdget(mdev);
1817 spin_lock(&bdev_lock);
1818 if (!inode->i_bdev) {
1819 diff -NurpP --minimal linux-3.0.25/fs/btrfs/ctree.h linux-3.0.25-vs2.3.2.3/fs/btrfs/ctree.h
1820 --- linux-3.0.25/fs/btrfs/ctree.h 2011-07-22 11:18:05.000000000 +0200
1821 +++ linux-3.0.25-vs2.3.2.3/fs/btrfs/ctree.h 2011-07-19 00:44:39.000000000 +0200
1822 @@ -600,11 +600,14 @@ struct btrfs_inode_item {
1823 /* modification sequence number for NFS */
1828 * a little future expansion, for more than this we can
1829 * just grow the inode item and version it
1831 - __le64 reserved[4];
1832 + __le16 reserved16;
1833 + __le32 reserved32;
1834 + __le64 reserved[3];
1835 struct btrfs_timespec atime;
1836 struct btrfs_timespec ctime;
1837 struct btrfs_timespec mtime;
1838 @@ -1359,6 +1362,8 @@ struct btrfs_ioctl_defrag_range_args {
1839 #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16)
1840 #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17)
1842 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1844 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1845 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1846 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
1847 @@ -1568,6 +1573,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1848 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1849 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1850 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1851 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1852 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1853 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1854 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1855 @@ -1621,6 +1627,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1857 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1859 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1860 +#define BTRFS_INODE_BARRIER (1 << 25)
1861 +#define BTRFS_INODE_COW (1 << 26)
1864 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1866 @@ -2595,6 +2605,7 @@ extern const struct dentry_operations bt
1867 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1868 void btrfs_update_iflags(struct inode *inode);
1869 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1870 +int btrfs_sync_flags(struct inode *inode, int, int);
1871 int btrfs_defrag_file(struct inode *inode, struct file *file,
1872 struct btrfs_ioctl_defrag_range_args *range,
1873 u64 newer_than, unsigned long max_pages);
1874 diff -NurpP --minimal linux-3.0.25/fs/btrfs/disk-io.c linux-3.0.25-vs2.3.2.3/fs/btrfs/disk-io.c
1875 --- linux-3.0.25/fs/btrfs/disk-io.c 2011-07-22 11:18:05.000000000 +0200
1876 +++ linux-3.0.25-vs2.3.2.3/fs/btrfs/disk-io.c 2011-06-22 12:39:15.000000000 +0200
1877 @@ -1765,6 +1765,9 @@ struct btrfs_root *open_ctree(struct sup
1881 + if (btrfs_test_opt(tree_root, TAGGED))
1882 + sb->s_flags |= MS_TAGGED;
1884 features = btrfs_super_incompat_flags(disk_super) &
1885 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1887 diff -NurpP --minimal linux-3.0.25/fs/btrfs/inode.c linux-3.0.25-vs2.3.2.3/fs/btrfs/inode.c
1888 --- linux-3.0.25/fs/btrfs/inode.c 2012-03-19 21:16:51.000000000 +0100
1889 +++ linux-3.0.25-vs2.3.2.3/fs/btrfs/inode.c 2011-10-18 13:51:13.000000000 +0200
1891 #include <linux/falloc.h>
1892 #include <linux/slab.h>
1893 #include <linux/ratelimit.h>
1894 +#include <linux/vs_tag.h>
1897 #include "disk-io.h"
1898 @@ -2508,6 +2509,8 @@ static void btrfs_read_locked_inode(stru
1899 struct btrfs_key location;
1905 bool filled = false;
1907 @@ -2540,8 +2543,13 @@ static void btrfs_read_locked_inode(stru
1909 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1910 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
1911 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
1912 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
1914 + uid = btrfs_inode_uid(leaf, inode_item);
1915 + gid = btrfs_inode_gid(leaf, inode_item);
1916 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
1917 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
1918 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
1919 + btrfs_inode_tag(leaf, inode_item));
1920 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1922 tspec = btrfs_inode_atime(inode_item);
1923 @@ -2624,6 +2632,9 @@ static void fill_inode_item(struct btrfs
1924 struct btrfs_inode_item *item,
1925 struct inode *inode)
1927 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
1928 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
1930 if (!leaf->map_token)
1931 map_private_extent_buffer(leaf, (unsigned long)item,
1932 sizeof(struct btrfs_inode_item),
1933 @@ -2631,8 +2642,11 @@ static void fill_inode_item(struct btrfs
1934 &leaf->map_start, &leaf->map_len,
1937 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
1938 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
1939 + btrfs_set_inode_uid(leaf, item, uid);
1940 + btrfs_set_inode_gid(leaf, item, gid);
1941 +#ifdef CONFIG_TAGGING_INTERN
1942 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
1944 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
1945 btrfs_set_inode_mode(leaf, item, inode->i_mode);
1946 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
1947 @@ -7360,6 +7374,7 @@ static const struct inode_operations btr
1948 .listxattr = btrfs_listxattr,
1949 .removexattr = btrfs_removexattr,
1950 .permission = btrfs_permission,
1951 + .sync_flags = btrfs_sync_flags,
1953 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1954 .lookup = btrfs_lookup,
1955 @@ -7432,6 +7447,7 @@ static const struct inode_operations btr
1956 .removexattr = btrfs_removexattr,
1957 .permission = btrfs_permission,
1958 .fiemap = btrfs_fiemap,
1959 + .sync_flags = btrfs_sync_flags,
1961 static const struct inode_operations btrfs_special_inode_operations = {
1962 .getattr = btrfs_getattr,
1963 diff -NurpP --minimal linux-3.0.25/fs/btrfs/ioctl.c linux-3.0.25-vs2.3.2.3/fs/btrfs/ioctl.c
1964 --- linux-3.0.25/fs/btrfs/ioctl.c 2011-07-22 11:18:05.000000000 +0200
1965 +++ linux-3.0.25-vs2.3.2.3/fs/btrfs/ioctl.c 2011-06-22 12:39:15.000000000 +0200
1966 @@ -70,10 +70,13 @@ static unsigned int btrfs_flags_to_ioctl
1968 unsigned int iflags = 0;
1970 - if (flags & BTRFS_INODE_SYNC)
1971 - iflags |= FS_SYNC_FL;
1972 if (flags & BTRFS_INODE_IMMUTABLE)
1973 iflags |= FS_IMMUTABLE_FL;
1974 + if (flags & BTRFS_INODE_IXUNLINK)
1975 + iflags |= FS_IXUNLINK_FL;
1977 + if (flags & BTRFS_INODE_SYNC)
1978 + iflags |= FS_SYNC_FL;
1979 if (flags & BTRFS_INODE_APPEND)
1980 iflags |= FS_APPEND_FL;
1981 if (flags & BTRFS_INODE_NODUMP)
1982 @@ -90,28 +93,78 @@ static unsigned int btrfs_flags_to_ioctl
1983 else if (flags & BTRFS_INODE_NOCOMPRESS)
1984 iflags |= FS_NOCOMP_FL;
1986 + if (flags & BTRFS_INODE_BARRIER)
1987 + iflags |= FS_BARRIER_FL;
1988 + if (flags & BTRFS_INODE_COW)
1989 + iflags |= FS_COW_FL;
1994 - * Update inode->i_flags based on the btrfs internal flags.
1995 + * Update inode->i_(v)flags based on the btrfs internal flags.
1997 void btrfs_update_iflags(struct inode *inode)
1999 struct btrfs_inode *ip = BTRFS_I(inode);
2001 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2002 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2003 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2005 - if (ip->flags & BTRFS_INODE_SYNC)
2006 - inode->i_flags |= S_SYNC;
2007 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2008 inode->i_flags |= S_IMMUTABLE;
2009 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2010 + inode->i_flags |= S_IXUNLINK;
2012 + if (ip->flags & BTRFS_INODE_SYNC)
2013 + inode->i_flags |= S_SYNC;
2014 if (ip->flags & BTRFS_INODE_APPEND)
2015 inode->i_flags |= S_APPEND;
2016 if (ip->flags & BTRFS_INODE_NOATIME)
2017 inode->i_flags |= S_NOATIME;
2018 if (ip->flags & BTRFS_INODE_DIRSYNC)
2019 inode->i_flags |= S_DIRSYNC;
2021 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2023 + if (ip->flags & BTRFS_INODE_BARRIER)
2024 + inode->i_vflags |= V_BARRIER;
2025 + if (ip->flags & BTRFS_INODE_COW)
2026 + inode->i_vflags |= V_COW;
2030 + * Update btrfs internal flags from inode->i_(v)flags.
2032 +void btrfs_update_flags(struct inode *inode)
2034 + struct btrfs_inode *ip = BTRFS_I(inode);
2036 + unsigned int flags = inode->i_flags;
2037 + unsigned int vflags = inode->i_vflags;
2039 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2040 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2041 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2042 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2044 + if (flags & S_IMMUTABLE)
2045 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2046 + if (flags & S_IXUNLINK)
2047 + ip->flags |= BTRFS_INODE_IXUNLINK;
2049 + if (flags & S_SYNC)
2050 + ip->flags |= BTRFS_INODE_SYNC;
2051 + if (flags & S_APPEND)
2052 + ip->flags |= BTRFS_INODE_APPEND;
2053 + if (flags & S_NOATIME)
2054 + ip->flags |= BTRFS_INODE_NOATIME;
2055 + if (flags & S_DIRSYNC)
2056 + ip->flags |= BTRFS_INODE_DIRSYNC;
2058 + if (vflags & V_BARRIER)
2059 + ip->flags |= BTRFS_INODE_BARRIER;
2060 + if (vflags & V_COW)
2061 + ip->flags |= BTRFS_INODE_COW;
2065 @@ -129,7 +182,7 @@ void btrfs_inherit_iflags(struct inode *
2066 flags = BTRFS_I(dir)->flags;
2068 if (S_ISREG(inode->i_mode))
2069 - flags &= ~BTRFS_INODE_DIRSYNC;
2070 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2071 else if (!S_ISDIR(inode->i_mode))
2072 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2074 @@ -137,6 +190,30 @@ void btrfs_inherit_iflags(struct inode *
2075 btrfs_update_iflags(inode);
2078 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2080 + struct btrfs_inode *ip = BTRFS_I(inode);
2081 + struct btrfs_root *root = ip->root;
2082 + struct btrfs_trans_handle *trans;
2085 + trans = btrfs_join_transaction(root);
2088 + inode->i_flags = flags;
2089 + inode->i_vflags = vflags;
2090 + btrfs_update_flags(inode);
2092 + ret = btrfs_update_inode(trans, root, inode);
2095 + btrfs_update_iflags(inode);
2096 + inode->i_ctime = CURRENT_TIME;
2097 + btrfs_end_transaction(trans, root);
2102 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2104 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2105 @@ -188,7 +265,8 @@ static int btrfs_ioctl_setflags(struct f
2107 flags = btrfs_mask_flags(inode->i_mode, flags);
2108 oldflags = btrfs_flags_to_ioctl(ip->flags);
2109 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2110 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2111 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2112 if (!capable(CAP_LINUX_IMMUTABLE)) {
2115 @@ -199,14 +277,19 @@ static int btrfs_ioctl_setflags(struct f
2119 - if (flags & FS_SYNC_FL)
2120 - ip->flags |= BTRFS_INODE_SYNC;
2122 - ip->flags &= ~BTRFS_INODE_SYNC;
2123 if (flags & FS_IMMUTABLE_FL)
2124 ip->flags |= BTRFS_INODE_IMMUTABLE;
2126 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2127 + if (flags & FS_IXUNLINK_FL)
2128 + ip->flags |= BTRFS_INODE_IXUNLINK;
2130 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2132 + if (flags & FS_SYNC_FL)
2133 + ip->flags |= BTRFS_INODE_SYNC;
2135 + ip->flags &= ~BTRFS_INODE_SYNC;
2136 if (flags & FS_APPEND_FL)
2137 ip->flags |= BTRFS_INODE_APPEND;
2139 diff -NurpP --minimal linux-3.0.25/fs/btrfs/super.c linux-3.0.25-vs2.3.2.3/fs/btrfs/super.c
2140 --- linux-3.0.25/fs/btrfs/super.c 2011-07-22 11:18:05.000000000 +0200
2141 +++ linux-3.0.25-vs2.3.2.3/fs/btrfs/super.c 2011-07-19 00:44:39.000000000 +0200
2142 @@ -162,7 +162,7 @@ enum {
2143 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
2144 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
2145 Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,
2146 - Opt_inode_cache, Opt_err,
2147 + Opt_inode_cache, Opt_tag, Opt_notag, Opt_tagid, Opt_err,
2150 static match_table_t tokens = {
2151 @@ -195,6 +195,9 @@ static match_table_t tokens = {
2152 {Opt_subvolrootid, "subvolrootid=%d"},
2153 {Opt_defrag, "autodefrag"},
2154 {Opt_inode_cache, "inode_cache"},
2156 + {Opt_notag, "notag"},
2157 + {Opt_tagid, "tagid=%u"},
2161 @@ -381,6 +384,22 @@ int btrfs_parse_options(struct btrfs_roo
2162 printk(KERN_INFO "btrfs: enabling auto defrag");
2163 btrfs_set_opt(info->mount_opt, AUTO_DEFRAG);
2165 +#ifndef CONFIG_TAGGING_NONE
2167 + printk(KERN_INFO "btrfs: use tagging\n");
2168 + btrfs_set_opt(info->mount_opt, TAGGED);
2171 + printk(KERN_INFO "btrfs: disabled tagging\n");
2172 + btrfs_clear_opt(info->mount_opt, TAGGED);
2175 +#ifdef CONFIG_PROPAGATE
2178 + btrfs_set_opt(info->mount_opt, TAGGED);
2182 printk(KERN_INFO "btrfs: unrecognized mount option "
2184 @@ -907,6 +926,12 @@ static int btrfs_remount(struct super_bl
2188 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2189 + printk("btrfs: %s: tagging not permitted on remount.\n",
2194 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2197 diff -NurpP --minimal linux-3.0.25/fs/char_dev.c linux-3.0.25-vs2.3.2.3/fs/char_dev.c
2198 --- linux-3.0.25/fs/char_dev.c 2011-03-15 18:07:31.000000000 +0100
2199 +++ linux-3.0.25-vs2.3.2.3/fs/char_dev.c 2011-06-10 22:11:24.000000000 +0200
2201 #include <linux/mutex.h>
2202 #include <linux/backing-dev.h>
2203 #include <linux/tty.h>
2204 +#include <linux/vs_context.h>
2205 +#include <linux/vs_device.h>
2207 #include "internal.h"
2209 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2211 struct cdev *new = NULL;
2215 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2217 + inode->i_mdev = mdev;
2219 spin_lock(&cdev_lock);
2222 struct kobject *kobj;
2225 spin_unlock(&cdev_lock);
2226 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2228 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2231 new = container_of(kobj, struct cdev, kobj);
2232 diff -NurpP --minimal linux-3.0.25/fs/dcache.c linux-3.0.25-vs2.3.2.3/fs/dcache.c
2233 --- linux-3.0.25/fs/dcache.c 2012-03-19 21:16:51.000000000 +0100
2234 +++ linux-3.0.25-vs2.3.2.3/fs/dcache.c 2012-01-26 08:39:53.000000000 +0100
2236 #include <linux/bit_spinlock.h>
2237 #include <linux/rculist_bl.h>
2238 #include <linux/prefetch.h>
2239 +#include <linux/vs_limit.h>
2240 #include "internal.h"
2243 @@ -480,6 +481,8 @@ int d_invalidate(struct dentry * dentry)
2244 spin_lock(&dentry->d_lock);
2247 + vx_dentry_dec(dentry);
2250 * Somebody else still using it?
2252 @@ -507,6 +510,7 @@ EXPORT_SYMBOL(d_invalidate);
2253 static inline void __dget_dlock(struct dentry *dentry)
2256 + vx_dentry_inc(dentry);
2259 static inline void __dget(struct dentry *dentry)
2260 @@ -1272,6 +1276,9 @@ struct dentry *d_alloc(struct dentry * p
2261 struct dentry *dentry;
2264 + if (!vx_dentry_avail(1))
2267 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2270 @@ -1294,6 +1301,7 @@ struct dentry *d_alloc(struct dentry * p
2272 dentry->d_count = 1;
2273 dentry->d_flags = 0;
2274 + vx_dentry_inc(dentry);
2275 spin_lock_init(&dentry->d_lock);
2276 seqcount_init(&dentry->d_seq);
2277 dentry->d_inode = NULL;
2278 @@ -1951,6 +1959,7 @@ struct dentry *__d_lookup(struct dentry
2282 + vx_dentry_inc(dentry);
2284 spin_unlock(&dentry->d_lock);
2286 diff -NurpP --minimal linux-3.0.25/fs/devpts/inode.c linux-3.0.25-vs2.3.2.3/fs/devpts/inode.c
2287 --- linux-3.0.25/fs/devpts/inode.c 2011-05-22 16:17:50.000000000 +0200
2288 +++ linux-3.0.25-vs2.3.2.3/fs/devpts/inode.c 2011-06-10 22:11:24.000000000 +0200
2290 #include <linux/parser.h>
2291 #include <linux/fsnotify.h>
2292 #include <linux/seq_file.h>
2293 +#include <linux/vs_base.h>
2295 #define DEVPTS_DEFAULT_MODE 0600
2298 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2299 #define PTMX_MINOR 2
2301 +static int devpts_permission(struct inode *inode, int mask, unsigned int flags)
2303 + int ret = -EACCES;
2305 + /* devpts is xid tagged */
2306 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2307 + ret = generic_permission(inode, mask, flags, NULL);
2311 +static struct inode_operations devpts_file_inode_operations = {
2312 + .permission = devpts_permission,
2315 extern int pty_limit; /* Config limit on Unix98 ptys */
2316 static DEFINE_MUTEX(allocated_ptys_lock);
2318 @@ -263,6 +278,34 @@ static int devpts_show_options(struct se
2322 +static int devpts_filter(struct dentry *de)
2326 + /* devpts is xid tagged */
2327 + if (de && de->d_inode)
2328 + xid = (xid_t)de->d_inode->i_tag;
2329 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2331 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2332 + de->d_name.len, de->d_name.name);
2334 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2337 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2339 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2342 +static struct file_operations devpts_dir_operations = {
2343 + .open = dcache_dir_open,
2344 + .release = dcache_dir_close,
2345 + .llseek = dcache_dir_lseek,
2346 + .read = generic_read_dir,
2347 + .readdir = devpts_readdir,
2350 static const struct super_operations devpts_sops = {
2351 .statfs = simple_statfs,
2352 .remount_fs = devpts_remount,
2353 @@ -302,12 +345,15 @@ devpts_fill_super(struct super_block *s,
2354 inode = new_inode(s);
2359 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2360 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2361 inode->i_op = &simple_dir_inode_operations;
2362 - inode->i_fop = &simple_dir_operations;
2363 + inode->i_fop = &devpts_dir_operations;
2365 + /* devpts is xid tagged */
2366 + inode->i_tag = (tag_t)vx_current_xid();
2368 s->s_root = d_alloc_root(inode);
2370 @@ -494,6 +540,9 @@ int devpts_pty_new(struct inode *ptmx_in
2371 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2372 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2373 init_special_inode(inode, S_IFCHR|opts->mode, device);
2374 + /* devpts is xid tagged */
2375 + inode->i_tag = (tag_t)vx_current_xid();
2376 + inode->i_op = &devpts_file_inode_operations;
2377 inode->i_private = tty;
2378 tty->driver_data = inode;
2380 diff -NurpP --minimal linux-3.0.25/fs/ext2/balloc.c linux-3.0.25-vs2.3.2.3/fs/ext2/balloc.c
2381 --- linux-3.0.25/fs/ext2/balloc.c 2011-05-22 16:17:51.000000000 +0200
2382 +++ linux-3.0.25-vs2.3.2.3/fs/ext2/balloc.c 2011-06-10 22:11:24.000000000 +0200
2383 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2385 end = EXT2_BLOCKS_PER_GROUP(sb);
2388 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2391 diff -NurpP --minimal linux-3.0.25/fs/ext2/ext2.h linux-3.0.25-vs2.3.2.3/fs/ext2/ext2.h
2392 --- linux-3.0.25/fs/ext2/ext2.h 2011-05-22 16:17:51.000000000 +0200
2393 +++ linux-3.0.25-vs2.3.2.3/fs/ext2/ext2.h 2011-06-10 22:11:24.000000000 +0200
2394 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct
2395 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2396 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2397 u64 start, u64 len);
2398 +extern int ext2_sync_flags(struct inode *, int, int);
2401 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2402 diff -NurpP --minimal linux-3.0.25/fs/ext2/file.c linux-3.0.25-vs2.3.2.3/fs/ext2/file.c
2403 --- linux-3.0.25/fs/ext2/file.c 2010-08-02 16:52:48.000000000 +0200
2404 +++ linux-3.0.25-vs2.3.2.3/fs/ext2/file.c 2011-06-10 22:11:24.000000000 +0200
2405 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2406 .setattr = ext2_setattr,
2407 .check_acl = ext2_check_acl,
2408 .fiemap = ext2_fiemap,
2409 + .sync_flags = ext2_sync_flags,
2411 diff -NurpP --minimal linux-3.0.25/fs/ext2/ialloc.c linux-3.0.25-vs2.3.2.3/fs/ext2/ialloc.c
2412 --- linux-3.0.25/fs/ext2/ialloc.c 2011-05-22 16:17:51.000000000 +0200
2413 +++ linux-3.0.25-vs2.3.2.3/fs/ext2/ialloc.c 2011-06-10 22:11:24.000000000 +0200
2415 #include <linux/backing-dev.h>
2416 #include <linux/buffer_head.h>
2417 #include <linux/random.h>
2418 +#include <linux/vs_tag.h>
2422 @@ -549,6 +550,7 @@ got:
2423 inode->i_mode = mode;
2424 inode->i_uid = current_fsuid();
2425 inode->i_gid = dir->i_gid;
2426 + inode->i_tag = dx_current_fstag(sb);
2428 inode_init_owner(inode, dir, mode);
2430 diff -NurpP --minimal linux-3.0.25/fs/ext2/inode.c linux-3.0.25-vs2.3.2.3/fs/ext2/inode.c
2431 --- linux-3.0.25/fs/ext2/inode.c 2011-05-22 16:17:51.000000000 +0200
2432 +++ linux-3.0.25-vs2.3.2.3/fs/ext2/inode.c 2011-06-10 22:11:24.000000000 +0200
2434 #include <linux/mpage.h>
2435 #include <linux/fiemap.h>
2436 #include <linux/namei.h>
2437 +#include <linux/vs_tag.h>
2441 @@ -1167,7 +1168,7 @@ static void ext2_truncate_blocks(struct
2443 if (ext2_inode_is_fast_symlink(inode))
2445 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2446 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2448 __ext2_truncate_blocks(inode, offset);
2450 @@ -1256,36 +1257,61 @@ void ext2_set_inode_flags(struct inode *
2452 unsigned int flags = EXT2_I(inode)->i_flags;
2454 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2455 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2456 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2459 + if (flags & EXT2_IMMUTABLE_FL)
2460 + inode->i_flags |= S_IMMUTABLE;
2461 + if (flags & EXT2_IXUNLINK_FL)
2462 + inode->i_flags |= S_IXUNLINK;
2464 if (flags & EXT2_SYNC_FL)
2465 inode->i_flags |= S_SYNC;
2466 if (flags & EXT2_APPEND_FL)
2467 inode->i_flags |= S_APPEND;
2468 - if (flags & EXT2_IMMUTABLE_FL)
2469 - inode->i_flags |= S_IMMUTABLE;
2470 if (flags & EXT2_NOATIME_FL)
2471 inode->i_flags |= S_NOATIME;
2472 if (flags & EXT2_DIRSYNC_FL)
2473 inode->i_flags |= S_DIRSYNC;
2475 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2477 + if (flags & EXT2_BARRIER_FL)
2478 + inode->i_vflags |= V_BARRIER;
2479 + if (flags & EXT2_COW_FL)
2480 + inode->i_vflags |= V_COW;
2483 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2484 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2486 unsigned int flags = ei->vfs_inode.i_flags;
2487 + unsigned int vflags = ei->vfs_inode.i_vflags;
2489 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2490 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2491 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2492 + EXT2_BARRIER_FL | EXT2_COW_FL);
2494 + if (flags & S_IMMUTABLE)
2495 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2496 + if (flags & S_IXUNLINK)
2497 + ei->i_flags |= EXT2_IXUNLINK_FL;
2499 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2500 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2502 ei->i_flags |= EXT2_SYNC_FL;
2503 if (flags & S_APPEND)
2504 ei->i_flags |= EXT2_APPEND_FL;
2505 - if (flags & S_IMMUTABLE)
2506 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2507 if (flags & S_NOATIME)
2508 ei->i_flags |= EXT2_NOATIME_FL;
2509 if (flags & S_DIRSYNC)
2510 ei->i_flags |= EXT2_DIRSYNC_FL;
2512 + if (vflags & V_BARRIER)
2513 + ei->i_flags |= EXT2_BARRIER_FL;
2514 + if (vflags & V_COW)
2515 + ei->i_flags |= EXT2_COW_FL;
2518 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2519 @@ -1295,6 +1321,8 @@ struct inode *ext2_iget (struct super_bl
2520 struct ext2_inode *raw_inode;
2521 struct inode *inode;
2527 inode = iget_locked(sb, ino);
2528 @@ -1313,12 +1341,17 @@ struct inode *ext2_iget (struct super_bl
2531 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2532 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2533 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2534 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2535 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2536 if (!(test_opt (inode->i_sb, NO_UID32))) {
2537 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2538 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2539 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2540 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2542 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2543 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2544 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2545 + le16_to_cpu(raw_inode->i_raw_tag));
2547 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2548 inode->i_size = le32_to_cpu(raw_inode->i_size);
2549 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2550 @@ -1416,8 +1449,8 @@ static int __ext2_write_inode(struct ino
2551 struct ext2_inode_info *ei = EXT2_I(inode);
2552 struct super_block *sb = inode->i_sb;
2553 ino_t ino = inode->i_ino;
2554 - uid_t uid = inode->i_uid;
2555 - gid_t gid = inode->i_gid;
2556 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2557 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2558 struct buffer_head * bh;
2559 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2561 @@ -1453,6 +1486,9 @@ static int __ext2_write_inode(struct ino
2562 raw_inode->i_uid_high = 0;
2563 raw_inode->i_gid_high = 0;
2565 +#ifdef CONFIG_TAGGING_INTERN
2566 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2568 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2569 raw_inode->i_size = cpu_to_le32(inode->i_size);
2570 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2571 @@ -1533,7 +1569,8 @@ int ext2_setattr(struct dentry *dentry,
2572 if (is_quota_modification(inode, iattr))
2573 dquot_initialize(inode);
2574 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2575 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2576 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2577 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2578 error = dquot_transfer(inode, iattr);
2581 diff -NurpP --minimal linux-3.0.25/fs/ext2/ioctl.c linux-3.0.25-vs2.3.2.3/fs/ext2/ioctl.c
2582 --- linux-3.0.25/fs/ext2/ioctl.c 2011-05-22 16:17:51.000000000 +0200
2583 +++ linux-3.0.25-vs2.3.2.3/fs/ext2/ioctl.c 2011-06-10 22:11:24.000000000 +0200
2585 #include <asm/uaccess.h>
2588 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2590 + inode->i_flags = flags;
2591 + inode->i_vflags = vflags;
2592 + ext2_get_inode_flags(EXT2_I(inode));
2593 + inode->i_ctime = CURRENT_TIME_SEC;
2594 + mark_inode_dirty(inode);
2598 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2600 struct inode *inode = filp->f_dentry->d_inode;
2601 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2603 flags = ext2_mask_flags(inode->i_mode, flags);
2605 + if (IS_BARRIER(inode)) {
2606 + vxwprintk_task(1, "messing with the barrier.");
2610 mutex_lock(&inode->i_mutex);
2611 /* Is it quota file? Do not allow user to mess with it */
2612 if (IS_NOQUOTA(inode)) {
2613 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2615 * This test looks nicer. Thanks to Pauline Middelink
2617 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2618 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2619 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2620 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2621 if (!capable(CAP_LINUX_IMMUTABLE)) {
2622 mutex_unlock(&inode->i_mutex);
2624 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2628 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2629 + flags &= EXT2_FL_USER_MODIFIABLE;
2630 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2631 ei->i_flags = flags;
2632 mutex_unlock(&inode->i_mutex);
2633 diff -NurpP --minimal linux-3.0.25/fs/ext2/namei.c linux-3.0.25-vs2.3.2.3/fs/ext2/namei.c
2634 --- linux-3.0.25/fs/ext2/namei.c 2011-05-22 16:17:51.000000000 +0200
2635 +++ linux-3.0.25-vs2.3.2.3/fs/ext2/namei.c 2011-06-10 22:11:24.000000000 +0200
2638 #include <linux/pagemap.h>
2639 #include <linux/quotaops.h>
2640 +#include <linux/vs_tag.h>
2644 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
2645 return ERR_PTR(-EIO);
2647 return ERR_CAST(inode);
2648 + dx_propagate_tag(nd, inode);
2652 @@ -413,6 +415,7 @@ const struct inode_operations ext2_dir_i
2654 .setattr = ext2_setattr,
2655 .check_acl = ext2_check_acl,
2656 + .sync_flags = ext2_sync_flags,
2659 const struct inode_operations ext2_special_inode_operations = {
2660 diff -NurpP --minimal linux-3.0.25/fs/ext2/super.c linux-3.0.25-vs2.3.2.3/fs/ext2/super.c
2661 --- linux-3.0.25/fs/ext2/super.c 2011-07-22 11:18:05.000000000 +0200
2662 +++ linux-3.0.25-vs2.3.2.3/fs/ext2/super.c 2011-06-10 22:11:24.000000000 +0200
2663 @@ -394,7 +394,8 @@ enum {
2664 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2665 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2666 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2667 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2668 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2669 + Opt_tag, Opt_notag, Opt_tagid
2672 static const match_table_t tokens = {
2673 @@ -422,6 +423,9 @@ static const match_table_t tokens = {
2675 {Opt_noacl, "noacl"},
2678 + {Opt_notag, "notag"},
2679 + {Opt_tagid, "tagid=%u"},
2680 {Opt_grpquota, "grpquota"},
2681 {Opt_ignore, "noquota"},
2682 {Opt_quota, "quota"},
2683 @@ -492,6 +496,20 @@ static int parse_options(char *options,
2685 set_opt (sbi->s_mount_opt, NO_UID32);
2687 +#ifndef CONFIG_TAGGING_NONE
2689 + set_opt (sbi->s_mount_opt, TAGGED);
2692 + clear_opt (sbi->s_mount_opt, TAGGED);
2695 +#ifdef CONFIG_PROPAGATE
2698 + set_opt (sbi->s_mount_opt, TAGGED);
2702 clear_opt (sbi->s_mount_opt, CHECK);
2704 @@ -850,6 +868,8 @@ static int ext2_fill_super(struct super_
2705 if (!parse_options((char *) data, sb))
2708 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2709 + sb->s_flags |= MS_TAGGED;
2710 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2711 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2713 @@ -1224,6 +1244,14 @@ static int ext2_remount (struct super_bl
2717 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2718 + !(sb->s_flags & MS_TAGGED)) {
2719 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2722 + goto restore_opts;
2725 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2726 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2728 diff -NurpP --minimal linux-3.0.25/fs/ext3/file.c linux-3.0.25-vs2.3.2.3/fs/ext3/file.c
2729 --- linux-3.0.25/fs/ext3/file.c 2010-07-07 18:31:51.000000000 +0200
2730 +++ linux-3.0.25-vs2.3.2.3/fs/ext3/file.c 2011-06-10 22:11:24.000000000 +0200
2731 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
2733 .check_acl = ext3_check_acl,
2734 .fiemap = ext3_fiemap,
2735 + .sync_flags = ext3_sync_flags,
2738 diff -NurpP --minimal linux-3.0.25/fs/ext3/ialloc.c linux-3.0.25-vs2.3.2.3/fs/ext3/ialloc.c
2739 --- linux-3.0.25/fs/ext3/ialloc.c 2011-05-22 16:17:52.000000000 +0200
2740 +++ linux-3.0.25-vs2.3.2.3/fs/ext3/ialloc.c 2011-06-10 22:11:24.000000000 +0200
2742 #include <linux/buffer_head.h>
2743 #include <linux/random.h>
2744 #include <linux/bitops.h>
2745 +#include <linux/vs_tag.h>
2747 #include <asm/byteorder.h>
2749 @@ -532,6 +533,7 @@ got:
2750 inode->i_mode = mode;
2751 inode->i_uid = current_fsuid();
2752 inode->i_gid = dir->i_gid;
2753 + inode->i_tag = dx_current_fstag(sb);
2755 inode_init_owner(inode, dir, mode);
2757 diff -NurpP --minimal linux-3.0.25/fs/ext3/inode.c linux-3.0.25-vs2.3.2.3/fs/ext3/inode.c
2758 --- linux-3.0.25/fs/ext3/inode.c 2012-03-19 21:16:51.000000000 +0100
2759 +++ linux-3.0.25-vs2.3.2.3/fs/ext3/inode.c 2012-01-18 02:58:46.000000000 +0100
2761 #include <linux/bio.h>
2762 #include <linux/fiemap.h>
2763 #include <linux/namei.h>
2764 +#include <linux/vs_tag.h>
2768 @@ -2409,7 +2410,7 @@ static void ext3_free_branches(handle_t
2770 int ext3_can_truncate(struct inode *inode)
2772 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2773 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2775 if (S_ISREG(inode->i_mode))
2777 @@ -2793,36 +2794,60 @@ void ext3_set_inode_flags(struct inode *
2779 unsigned int flags = EXT3_I(inode)->i_flags;
2781 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2782 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2783 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2785 + if (flags & EXT3_IMMUTABLE_FL)
2786 + inode->i_flags |= S_IMMUTABLE;
2787 + if (flags & EXT3_IXUNLINK_FL)
2788 + inode->i_flags |= S_IXUNLINK;
2790 if (flags & EXT3_SYNC_FL)
2791 inode->i_flags |= S_SYNC;
2792 if (flags & EXT3_APPEND_FL)
2793 inode->i_flags |= S_APPEND;
2794 - if (flags & EXT3_IMMUTABLE_FL)
2795 - inode->i_flags |= S_IMMUTABLE;
2796 if (flags & EXT3_NOATIME_FL)
2797 inode->i_flags |= S_NOATIME;
2798 if (flags & EXT3_DIRSYNC_FL)
2799 inode->i_flags |= S_DIRSYNC;
2801 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2803 + if (flags & EXT3_BARRIER_FL)
2804 + inode->i_vflags |= V_BARRIER;
2805 + if (flags & EXT3_COW_FL)
2806 + inode->i_vflags |= V_COW;
2809 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2810 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2812 unsigned int flags = ei->vfs_inode.i_flags;
2813 + unsigned int vflags = ei->vfs_inode.i_vflags;
2815 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2816 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2817 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2818 + EXT3_BARRIER_FL | EXT3_COW_FL);
2820 + if (flags & S_IMMUTABLE)
2821 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2822 + if (flags & S_IXUNLINK)
2823 + ei->i_flags |= EXT3_IXUNLINK_FL;
2825 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2826 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2828 ei->i_flags |= EXT3_SYNC_FL;
2829 if (flags & S_APPEND)
2830 ei->i_flags |= EXT3_APPEND_FL;
2831 - if (flags & S_IMMUTABLE)
2832 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2833 if (flags & S_NOATIME)
2834 ei->i_flags |= EXT3_NOATIME_FL;
2835 if (flags & S_DIRSYNC)
2836 ei->i_flags |= EXT3_DIRSYNC_FL;
2838 + if (vflags & V_BARRIER)
2839 + ei->i_flags |= EXT3_BARRIER_FL;
2840 + if (vflags & V_COW)
2841 + ei->i_flags |= EXT3_COW_FL;
2844 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2845 @@ -2836,6 +2861,8 @@ struct inode *ext3_iget(struct super_blo
2846 transaction_t *transaction;
2852 inode = iget_locked(sb, ino);
2854 @@ -2852,12 +2879,17 @@ struct inode *ext3_iget(struct super_blo
2856 raw_inode = ext3_raw_inode(&iloc);
2857 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2858 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2859 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2860 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2861 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2862 if(!(test_opt (inode->i_sb, NO_UID32))) {
2863 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2864 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2865 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2866 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2868 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2869 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2870 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2871 + le16_to_cpu(raw_inode->i_raw_tag));
2873 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2874 inode->i_size = le32_to_cpu(raw_inode->i_size);
2875 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2876 @@ -3012,6 +3044,8 @@ static int ext3_do_update_inode(handle_t
2877 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
2878 struct ext3_inode_info *ei = EXT3_I(inode);
2879 struct buffer_head *bh = iloc->bh;
2880 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2881 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2882 int err = 0, rc, block;
2885 @@ -3026,29 +3060,32 @@ again:
2886 ext3_get_inode_flags(ei);
2887 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2888 if(!(test_opt(inode->i_sb, NO_UID32))) {
2889 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
2890 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
2891 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
2892 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
2894 * Fix up interoperability with old kernels. Otherwise, old inodes get
2895 * re-used with the upper 16 bits of the uid/gid intact
2898 raw_inode->i_uid_high =
2899 - cpu_to_le16(high_16_bits(inode->i_uid));
2900 + cpu_to_le16(high_16_bits(uid));
2901 raw_inode->i_gid_high =
2902 - cpu_to_le16(high_16_bits(inode->i_gid));
2903 + cpu_to_le16(high_16_bits(gid));
2905 raw_inode->i_uid_high = 0;
2906 raw_inode->i_gid_high = 0;
2909 raw_inode->i_uid_low =
2910 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
2911 + cpu_to_le16(fs_high2lowuid(uid));
2912 raw_inode->i_gid_low =
2913 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
2914 + cpu_to_le16(fs_high2lowgid(gid));
2915 raw_inode->i_uid_high = 0;
2916 raw_inode->i_gid_high = 0;
2918 +#ifdef CONFIG_TAGGING_INTERN
2919 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2921 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2922 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
2923 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2924 @@ -3208,7 +3245,8 @@ int ext3_setattr(struct dentry *dentry,
2925 if (is_quota_modification(inode, attr))
2926 dquot_initialize(inode);
2927 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2928 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
2929 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2930 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
2933 /* (user+group)*(old+new) structure, inode write (sb,
2934 @@ -3230,6 +3268,8 @@ int ext3_setattr(struct dentry *dentry,
2935 inode->i_uid = attr->ia_uid;
2936 if (attr->ia_valid & ATTR_GID)
2937 inode->i_gid = attr->ia_gid;
2938 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2939 + inode->i_tag = attr->ia_tag;
2940 error = ext3_mark_inode_dirty(handle, inode);
2941 ext3_journal_stop(handle);
2943 diff -NurpP --minimal linux-3.0.25/fs/ext3/ioctl.c linux-3.0.25-vs2.3.2.3/fs/ext3/ioctl.c
2944 --- linux-3.0.25/fs/ext3/ioctl.c 2011-05-22 16:17:52.000000000 +0200
2945 +++ linux-3.0.25-vs2.3.2.3/fs/ext3/ioctl.c 2011-06-10 22:11:24.000000000 +0200
2949 #include <linux/fs.h>
2950 +#include <linux/mount.h>
2951 #include <linux/jbd.h>
2952 #include <linux/capability.h>
2953 #include <linux/ext3_fs.h>
2955 #include <linux/compat.h>
2956 #include <asm/uaccess.h>
2959 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2961 + handle_t *handle = NULL;
2962 + struct ext3_iloc iloc;
2965 + handle = ext3_journal_start(inode, 1);
2966 + if (IS_ERR(handle))
2967 + return PTR_ERR(handle);
2969 + if (IS_SYNC(inode))
2970 + handle->h_sync = 1;
2971 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2975 + inode->i_flags = flags;
2976 + inode->i_vflags = vflags;
2977 + ext3_get_inode_flags(EXT3_I(inode));
2978 + inode->i_ctime = CURRENT_TIME_SEC;
2980 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2982 + ext3_journal_stop(handle);
2986 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2988 struct inode *inode = filp->f_dentry->d_inode;
2989 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
2991 flags = ext3_mask_flags(inode->i_mode, flags);
2993 + if (IS_BARRIER(inode)) {
2994 + vxwprintk_task(1, "messing with the barrier.");
2998 mutex_lock(&inode->i_mutex);
3000 /* Is it quota file? Do not allow user to mess with it */
3001 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3003 * This test looks nicer. Thanks to Pauline Middelink
3005 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3006 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3007 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3008 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3009 if (!capable(CAP_LINUX_IMMUTABLE))
3012 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3016 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3017 + flags &= EXT3_FL_USER_MODIFIABLE;
3018 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3019 ei->i_flags = flags;
3021 diff -NurpP --minimal linux-3.0.25/fs/ext3/namei.c linux-3.0.25-vs2.3.2.3/fs/ext3/namei.c
3022 --- linux-3.0.25/fs/ext3/namei.c 2012-03-19 21:16:51.000000000 +0100
3023 +++ linux-3.0.25-vs2.3.2.3/fs/ext3/namei.c 2011-08-29 03:45:09.000000000 +0200
3025 #include <linux/quotaops.h>
3026 #include <linux/buffer_head.h>
3027 #include <linux/bio.h>
3028 +#include <linux/vs_tag.h>
3032 @@ -923,6 +924,7 @@ restart:
3034 ll_rw_block(READ_META, 1, &bh);
3036 + dx_propagate_tag(nd, inode);
3038 if ((bh = bh_use[ra_ptr++]) == NULL)
3040 @@ -2536,6 +2538,7 @@ const struct inode_operations ext3_dir_i
3041 .removexattr = generic_removexattr,
3043 .check_acl = ext3_check_acl,
3044 + .sync_flags = ext3_sync_flags,
3047 const struct inode_operations ext3_special_inode_operations = {
3048 diff -NurpP --minimal linux-3.0.25/fs/ext3/super.c linux-3.0.25-vs2.3.2.3/fs/ext3/super.c
3049 --- linux-3.0.25/fs/ext3/super.c 2011-07-22 11:18:05.000000000 +0200
3050 +++ linux-3.0.25-vs2.3.2.3/fs/ext3/super.c 2011-06-10 22:11:24.000000000 +0200
3051 @@ -821,7 +821,8 @@ enum {
3052 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3053 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
3054 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
3055 - Opt_resize, Opt_usrquota, Opt_grpquota
3056 + Opt_resize, Opt_usrquota, Opt_grpquota,
3057 + Opt_tag, Opt_notag, Opt_tagid
3060 static const match_table_t tokens = {
3061 @@ -878,6 +879,9 @@ static const match_table_t tokens = {
3062 {Opt_barrier, "barrier"},
3063 {Opt_nobarrier, "nobarrier"},
3064 {Opt_resize, "resize"},
3066 + {Opt_notag, "notag"},
3067 + {Opt_tagid, "tagid=%u"},
3071 @@ -1030,6 +1034,20 @@ static int parse_options (char *options,
3073 set_opt (sbi->s_mount_opt, NO_UID32);
3075 +#ifndef CONFIG_TAGGING_NONE
3077 + set_opt (sbi->s_mount_opt, TAGGED);
3080 + clear_opt (sbi->s_mount_opt, TAGGED);
3083 +#ifdef CONFIG_PROPAGATE
3086 + set_opt (sbi->s_mount_opt, TAGGED);
3090 clear_opt (sbi->s_mount_opt, CHECK);
3092 @@ -1724,6 +1742,9 @@ static int ext3_fill_super (struct super
3096 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3097 + sb->s_flags |= MS_TAGGED;
3099 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3100 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3102 @@ -2604,6 +2625,14 @@ static int ext3_remount (struct super_bl
3103 if (test_opt(sb, ABORT))
3104 ext3_abort(sb, __func__, "Abort forced by user");
3106 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3107 + !(sb->s_flags & MS_TAGGED)) {
3108 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3111 + goto restore_opts;
3114 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3115 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3117 diff -NurpP --minimal linux-3.0.25/fs/ext4/ext4.h linux-3.0.25-vs2.3.2.3/fs/ext4/ext4.h
3118 --- linux-3.0.25/fs/ext4/ext4.h 2012-03-19 21:16:51.000000000 +0100
3119 +++ linux-3.0.25-vs2.3.2.3/fs/ext4/ext4.h 2011-11-15 17:37:06.000000000 +0100
3120 @@ -351,8 +351,12 @@ struct flex_groups {
3121 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3122 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3123 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3124 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3125 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3127 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3128 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3130 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3131 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3133 @@ -609,7 +613,8 @@ struct ext4_inode {
3134 __le16 l_i_file_acl_high;
3135 __le16 l_i_uid_high; /* these 2 fields */
3136 __le16 l_i_gid_high; /* were reserved2[0] */
3137 - __u32 l_i_reserved2;
3138 + __le16 l_i_tag; /* Context Tag */
3139 + __u16 l_i_reserved2;
3142 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3143 @@ -727,6 +732,7 @@ do { \
3144 #define i_gid_low i_gid
3145 #define i_uid_high osd2.linux2.l_i_uid_high
3146 #define i_gid_high osd2.linux2.l_i_gid_high
3147 +#define i_raw_tag osd2.linux2.l_i_tag
3148 #define i_reserved2 osd2.linux2.l_i_reserved2
3150 #elif defined(__GNU__)
3151 @@ -903,6 +909,7 @@ struct ext4_inode_info {
3152 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3153 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3154 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3155 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3156 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3157 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3158 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3159 @@ -2173,6 +2180,7 @@ extern int ext4_map_blocks(handle_t *han
3160 struct ext4_map_blocks *map, int flags);
3161 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3162 __u64 start, __u64 len);
3163 +extern int ext4_sync_flags(struct inode *, int, int);
3165 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3166 __u64 start_orig, __u64 start_donor,
3167 diff -NurpP --minimal linux-3.0.25/fs/ext4/file.c linux-3.0.25-vs2.3.2.3/fs/ext4/file.c
3168 --- linux-3.0.25/fs/ext4/file.c 2011-07-22 11:18:05.000000000 +0200
3169 +++ linux-3.0.25-vs2.3.2.3/fs/ext4/file.c 2011-06-10 22:11:24.000000000 +0200
3170 @@ -282,5 +282,6 @@ const struct inode_operations ext4_file_
3172 .check_acl = ext4_check_acl,
3173 .fiemap = ext4_fiemap,
3174 + .sync_flags = ext4_sync_flags,
3177 diff -NurpP --minimal linux-3.0.25/fs/ext4/ialloc.c linux-3.0.25-vs2.3.2.3/fs/ext4/ialloc.c
3178 --- linux-3.0.25/fs/ext4/ialloc.c 2011-05-22 16:17:52.000000000 +0200
3179 +++ linux-3.0.25-vs2.3.2.3/fs/ext4/ialloc.c 2011-06-10 22:11:24.000000000 +0200
3181 #include <linux/random.h>
3182 #include <linux/bitops.h>
3183 #include <linux/blkdev.h>
3184 +#include <linux/vs_tag.h>
3185 #include <asm/byteorder.h>
3188 @@ -992,6 +993,7 @@ got:
3189 inode->i_mode = mode;
3190 inode->i_uid = current_fsuid();
3191 inode->i_gid = dir->i_gid;
3192 + inode->i_tag = dx_current_fstag(sb);
3194 inode_init_owner(inode, dir, mode);
3196 diff -NurpP --minimal linux-3.0.25/fs/ext4/inode.c linux-3.0.25-vs2.3.2.3/fs/ext4/inode.c
3197 --- linux-3.0.25/fs/ext4/inode.c 2012-03-19 21:16:51.000000000 +0100
3198 +++ linux-3.0.25-vs2.3.2.3/fs/ext4/inode.c 2011-12-23 16:09:00.000000000 +0100
3200 #include <linux/printk.h>
3201 #include <linux/slab.h>
3202 #include <linux/ratelimit.h>
3203 +#include <linux/vs_tag.h>
3205 #include "ext4_jbd2.h"
3207 @@ -4819,41 +4820,64 @@ void ext4_set_inode_flags(struct inode *
3209 unsigned int flags = EXT4_I(inode)->i_flags;
3211 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3212 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3213 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3215 + if (flags & EXT4_IMMUTABLE_FL)
3216 + inode->i_flags |= S_IMMUTABLE;
3217 + if (flags & EXT4_IXUNLINK_FL)
3218 + inode->i_flags |= S_IXUNLINK;
3220 if (flags & EXT4_SYNC_FL)
3221 inode->i_flags |= S_SYNC;
3222 if (flags & EXT4_APPEND_FL)
3223 inode->i_flags |= S_APPEND;
3224 - if (flags & EXT4_IMMUTABLE_FL)
3225 - inode->i_flags |= S_IMMUTABLE;
3226 if (flags & EXT4_NOATIME_FL)
3227 inode->i_flags |= S_NOATIME;
3228 if (flags & EXT4_DIRSYNC_FL)
3229 inode->i_flags |= S_DIRSYNC;
3231 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3233 + if (flags & EXT4_BARRIER_FL)
3234 + inode->i_vflags |= V_BARRIER;
3235 + if (flags & EXT4_COW_FL)
3236 + inode->i_vflags |= V_COW;
3239 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3240 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3242 - unsigned int vfs_fl;
3243 + unsigned int vfs_fl, vfs_vf;
3244 unsigned long old_fl, new_fl;
3247 vfs_fl = ei->vfs_inode.i_flags;
3248 + vfs_vf = ei->vfs_inode.i_vflags;
3249 old_fl = ei->i_flags;
3250 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3251 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3253 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3256 + if (vfs_fl & S_IMMUTABLE)
3257 + new_fl |= EXT4_IMMUTABLE_FL;
3258 + if (vfs_fl & S_IXUNLINK)
3259 + new_fl |= EXT4_IXUNLINK_FL;
3261 if (vfs_fl & S_SYNC)
3262 new_fl |= EXT4_SYNC_FL;
3263 if (vfs_fl & S_APPEND)
3264 new_fl |= EXT4_APPEND_FL;
3265 - if (vfs_fl & S_IMMUTABLE)
3266 - new_fl |= EXT4_IMMUTABLE_FL;
3267 if (vfs_fl & S_NOATIME)
3268 new_fl |= EXT4_NOATIME_FL;
3269 if (vfs_fl & S_DIRSYNC)
3270 new_fl |= EXT4_DIRSYNC_FL;
3272 + if (vfs_vf & V_BARRIER)
3273 + new_fl |= EXT4_BARRIER_FL;
3274 + if (vfs_vf & V_COW)
3275 + new_fl |= EXT4_COW_FL;
3276 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3279 @@ -4889,6 +4913,8 @@ struct inode *ext4_iget(struct super_blo
3280 journal_t *journal = EXT4_SB(sb)->s_journal;
3286 inode = iget_locked(sb, ino);
3288 @@ -4904,12 +4930,16 @@ struct inode *ext4_iget(struct super_blo
3290 raw_inode = ext4_raw_inode(&iloc);
3291 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3292 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3293 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3294 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3295 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3296 if (!(test_opt(inode->i_sb, NO_UID32))) {
3297 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3298 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3299 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3300 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3302 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3303 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3304 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3305 + le16_to_cpu(raw_inode->i_raw_tag));
3306 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3308 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3309 @@ -5128,6 +5158,8 @@ static int ext4_do_update_inode(handle_t
3310 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3311 struct ext4_inode_info *ei = EXT4_I(inode);
3312 struct buffer_head *bh = iloc->bh;
3313 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3314 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3315 int err = 0, rc, block;
3317 /* For fields not not tracking in the in-memory inode,
3318 @@ -5138,29 +5170,32 @@ static int ext4_do_update_inode(handle_t
3319 ext4_get_inode_flags(ei);
3320 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3321 if (!(test_opt(inode->i_sb, NO_UID32))) {
3322 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3323 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3324 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3325 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3327 * Fix up interoperability with old kernels. Otherwise, old inodes get
3328 * re-used with the upper 16 bits of the uid/gid intact
3331 raw_inode->i_uid_high =
3332 - cpu_to_le16(high_16_bits(inode->i_uid));
3333 + cpu_to_le16(high_16_bits(uid));
3334 raw_inode->i_gid_high =
3335 - cpu_to_le16(high_16_bits(inode->i_gid));
3336 + cpu_to_le16(high_16_bits(gid));
3338 raw_inode->i_uid_high = 0;
3339 raw_inode->i_gid_high = 0;
3342 raw_inode->i_uid_low =
3343 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3344 + cpu_to_le16(fs_high2lowuid(uid));
3345 raw_inode->i_gid_low =
3346 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3347 + cpu_to_le16(fs_high2lowgid(gid));
3348 raw_inode->i_uid_high = 0;
3349 raw_inode->i_gid_high = 0;
3351 +#ifdef CONFIG_TAGGING_INTERN
3352 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3354 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3356 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3357 @@ -5346,7 +5381,8 @@ int ext4_setattr(struct dentry *dentry,
3358 if (is_quota_modification(inode, attr))
3359 dquot_initialize(inode);
3360 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3361 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3362 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3363 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3366 /* (user+group)*(old+new) structure, inode write (sb,
3367 @@ -5368,6 +5404,8 @@ int ext4_setattr(struct dentry *dentry,
3368 inode->i_uid = attr->ia_uid;
3369 if (attr->ia_valid & ATTR_GID)
3370 inode->i_gid = attr->ia_gid;
3371 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3372 + inode->i_tag = attr->ia_tag;
3373 error = ext4_mark_inode_dirty(handle, inode);
3374 ext4_journal_stop(handle);
3376 diff -NurpP --minimal linux-3.0.25/fs/ext4/ioctl.c linux-3.0.25-vs2.3.2.3/fs/ext4/ioctl.c
3377 --- linux-3.0.25/fs/ext4/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3378 +++ linux-3.0.25-vs2.3.2.3/fs/ext4/ioctl.c 2011-06-10 22:11:24.000000000 +0200
3380 #include <linux/compat.h>
3381 #include <linux/mount.h>
3382 #include <linux/file.h>
3383 +#include <linux/vs_tag.h>
3384 #include <asm/uaccess.h>
3385 #include "ext4_jbd2.h"
3389 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3391 + handle_t *handle = NULL;
3392 + struct ext4_iloc iloc;
3395 + handle = ext4_journal_start(inode, 1);
3396 + if (IS_ERR(handle))
3397 + return PTR_ERR(handle);
3399 + if (IS_SYNC(inode))
3400 + ext4_handle_sync(handle);
3401 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3405 + inode->i_flags = flags;
3406 + inode->i_vflags = vflags;
3407 + ext4_get_inode_flags(EXT4_I(inode));
3408 + inode->i_ctime = ext4_current_time(inode);
3410 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3412 + ext4_journal_stop(handle);
3416 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3418 struct inode *inode = filp->f_dentry->d_inode;
3419 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3421 flags = ext4_mask_flags(inode->i_mode, flags);
3423 + if (IS_BARRIER(inode)) {
3424 + vxwprintk_task(1, "messing with the barrier.");
3429 mutex_lock(&inode->i_mutex);
3430 /* Is it quota file? Do not allow user to mess with it */
3431 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3433 * This test looks nicer. Thanks to Pauline Middelink
3435 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3436 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3437 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3438 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3439 if (!capable(CAP_LINUX_IMMUTABLE))
3442 diff -NurpP --minimal linux-3.0.25/fs/ext4/namei.c linux-3.0.25-vs2.3.2.3/fs/ext4/namei.c
3443 --- linux-3.0.25/fs/ext4/namei.c 2012-03-19 21:16:51.000000000 +0100
3444 +++ linux-3.0.25-vs2.3.2.3/fs/ext4/namei.c 2011-11-15 17:37:06.000000000 +0100
3446 #include <linux/quotaops.h>
3447 #include <linux/buffer_head.h>
3448 #include <linux/bio.h>
3449 +#include <linux/vs_tag.h>
3451 #include "ext4_jbd2.h"
3453 @@ -924,6 +925,7 @@ restart:
3455 ll_rw_block(READ_META, 1, &bh);
3457 + dx_propagate_tag(nd, inode);
3459 if ((bh = bh_use[ra_ptr++]) == NULL)
3461 @@ -2598,6 +2600,7 @@ const struct inode_operations ext4_dir_i
3463 .check_acl = ext4_check_acl,
3464 .fiemap = ext4_fiemap,
3465 + .sync_flags = ext4_sync_flags,
3468 const struct inode_operations ext4_special_inode_operations = {
3469 diff -NurpP --minimal linux-3.0.25/fs/ext4/super.c linux-3.0.25-vs2.3.2.3/fs/ext4/super.c
3470 --- linux-3.0.25/fs/ext4/super.c 2012-03-19 21:16:51.000000000 +0100
3471 +++ linux-3.0.25-vs2.3.2.3/fs/ext4/super.c 2012-01-26 08:39:53.000000000 +0100
3472 @@ -1292,6 +1292,7 @@ enum {
3473 Opt_inode_readahead_blks, Opt_journal_ioprio,
3474 Opt_dioread_nolock, Opt_dioread_lock,
3475 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
3476 + Opt_tag, Opt_notag, Opt_tagid
3479 static const match_table_t tokens = {
3480 @@ -1367,6 +1368,9 @@ static const match_table_t tokens = {
3481 {Opt_init_itable, "init_itable=%u"},
3482 {Opt_init_itable, "init_itable"},
3483 {Opt_noinit_itable, "noinit_itable"},
3485 + {Opt_notag, "notag"},
3486 + {Opt_tagid, "tagid=%u"},
3490 @@ -1535,6 +1539,20 @@ static int parse_options(char *options,
3492 set_opt(sb, NO_UID32);
3494 +#ifndef CONFIG_TAGGING_NONE
3496 + set_opt(sb, TAGGED);
3499 + clear_opt(sb, TAGGED);
3502 +#ifdef CONFIG_PROPAGATE
3505 + set_opt(sb, TAGGED);
3511 @@ -3191,6 +3209,9 @@ static int ext4_fill_super(struct super_
3512 &journal_ioprio, NULL, 0))
3515 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3516 + sb->s_flags |= MS_TAGGED;
3518 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3519 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3521 @@ -4321,6 +4342,14 @@ static int ext4_remount(struct super_blo
3522 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3523 ext4_abort(sb, "Abort forced by user");
3525 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3526 + !(sb->s_flags & MS_TAGGED)) {
3527 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3530 + goto restore_opts;
3533 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3534 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3536 diff -NurpP --minimal linux-3.0.25/fs/fcntl.c linux-3.0.25-vs2.3.2.3/fs/fcntl.c
3537 --- linux-3.0.25/fs/fcntl.c 2011-05-22 16:17:52.000000000 +0200
3538 +++ linux-3.0.25-vs2.3.2.3/fs/fcntl.c 2011-06-10 22:11:24.000000000 +0200
3540 #include <linux/signal.h>
3541 #include <linux/rcupdate.h>
3542 #include <linux/pid_namespace.h>
3543 +#include <linux/vs_limit.h>
3545 #include <asm/poll.h>
3546 #include <asm/siginfo.h>
3547 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3550 filp_close(tofree, files);
3552 + vx_openfd_inc(newfd); /* fd was unused */
3556 @@ -447,6 +450,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3557 filp = fget_raw(fd);
3560 + if (!vx_files_avail(1))
3563 if (unlikely(filp->f_mode & FMODE_PATH)) {
3564 if (!check_fcntl_cmd(cmd)) {
3565 diff -NurpP --minimal linux-3.0.25/fs/file.c linux-3.0.25-vs2.3.2.3/fs/file.c
3566 --- linux-3.0.25/fs/file.c 2011-05-22 16:17:52.000000000 +0200
3567 +++ linux-3.0.25-vs2.3.2.3/fs/file.c 2011-06-10 22:11:24.000000000 +0200
3569 #include <linux/spinlock.h>
3570 #include <linux/rcupdate.h>
3571 #include <linux/workqueue.h>
3572 +#include <linux/vs_limit.h>
3574 struct fdtable_defer {
3576 @@ -359,6 +360,8 @@ struct files_struct *dup_fd(struct files
3577 struct file *f = *old_fds++;
3580 + /* TODO: sum it first for check and performance */
3581 + vx_openfd_inc(open_files - i);
3584 * The fd may be claimed in the fd bitmap but not yet
3585 @@ -466,6 +469,7 @@ repeat:
3587 FD_CLR(fd, fdt->close_on_exec);
3589 + vx_openfd_inc(fd);
3592 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3593 diff -NurpP --minimal linux-3.0.25/fs/file_table.c linux-3.0.25-vs2.3.2.3/fs/file_table.c
3594 --- linux-3.0.25/fs/file_table.c 2011-05-22 16:17:52.000000000 +0200
3595 +++ linux-3.0.25-vs2.3.2.3/fs/file_table.c 2011-06-10 22:11:24.000000000 +0200
3597 #include <linux/percpu_counter.h>
3598 #include <linux/percpu.h>
3599 #include <linux/ima.h>
3600 +#include <linux/vs_limit.h>
3601 +#include <linux/vs_context.h>
3603 #include <asm/atomic.h>
3605 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
3606 spin_lock_init(&f->f_lock);
3607 eventpoll_init_file(f);
3608 /* f->f_version: 0 */
3609 + f->f_xid = vx_current_xid();
3614 @@ -253,6 +257,8 @@ static void __fput(struct file *file)
3616 fops_put(file->f_op);
3617 put_pid(file->f_owner.pid);
3618 + vx_files_dec(file);
3620 file_sb_list_del(file);
3621 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
3622 i_readcount_dec(inode);
3623 @@ -383,6 +389,8 @@ void put_filp(struct file *file)
3625 if (atomic_long_dec_and_test(&file->f_count)) {
3626 security_file_free(file);
3627 + vx_files_dec(file);
3629 file_sb_list_del(file);
3632 diff -NurpP --minimal linux-3.0.25/fs/fs_struct.c linux-3.0.25-vs2.3.2.3/fs/fs_struct.c
3633 --- linux-3.0.25/fs/fs_struct.c 2011-03-15 18:07:31.000000000 +0100
3634 +++ linux-3.0.25-vs2.3.2.3/fs/fs_struct.c 2011-06-10 22:11:24.000000000 +0200
3636 #include <linux/path.h>
3637 #include <linux/slab.h>
3638 #include <linux/fs_struct.h>
3639 +#include <linux/vserver/global.h>
3640 #include "internal.h"
3642 static inline void path_get_longterm(struct path *path)
3643 @@ -96,6 +97,7 @@ void free_fs_struct(struct fs_struct *fs
3645 path_put_longterm(&fs->root);
3646 path_put_longterm(&fs->pwd);
3647 + atomic_dec(&vs_global_fs);
3648 kmem_cache_free(fs_cachep, fs);
3651 @@ -135,6 +137,7 @@ struct fs_struct *copy_fs_struct(struct
3653 path_get_longterm(&fs->pwd);
3654 spin_unlock(&old->lock);
3655 + atomic_inc(&vs_global_fs);
3659 diff -NurpP --minimal linux-3.0.25/fs/gfs2/file.c linux-3.0.25-vs2.3.2.3/fs/gfs2/file.c
3660 --- linux-3.0.25/fs/gfs2/file.c 2011-07-22 11:18:05.000000000 +0200
3661 +++ linux-3.0.25-vs2.3.2.3/fs/gfs2/file.c 2011-06-10 22:11:24.000000000 +0200
3662 @@ -134,6 +134,9 @@ static const u32 fsflags_to_gfs2[32] = {
3663 [7] = GFS2_DIF_NOATIME,
3664 [12] = GFS2_DIF_EXHASH,
3665 [14] = GFS2_DIF_INHERIT_JDATA,
3666 + [27] = GFS2_DIF_IXUNLINK,
3667 + [26] = GFS2_DIF_BARRIER,
3668 + [29] = GFS2_DIF_COW,
3671 static const u32 gfs2_to_fsflags[32] = {
3672 @@ -143,6 +146,9 @@ static const u32 gfs2_to_fsflags[32] = {
3673 [gfs2fl_NoAtime] = FS_NOATIME_FL,
3674 [gfs2fl_ExHash] = FS_INDEX_FL,
3675 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3676 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3677 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3678 + [gfs2fl_Cow] = FS_COW_FL,
3681 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3682 @@ -173,10 +179,16 @@ void gfs2_set_inode_flags(struct inode *
3684 struct gfs2_inode *ip = GFS2_I(inode);
3685 unsigned int flags = inode->i_flags;
3686 + unsigned int vflags = inode->i_vflags;
3688 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3689 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3691 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3692 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3693 flags |= S_IMMUTABLE;
3694 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3695 + flags |= S_IXUNLINK;
3697 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3699 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3700 @@ -184,6 +196,43 @@ void gfs2_set_inode_flags(struct inode *
3701 if (ip->i_diskflags & GFS2_DIF_SYNC)
3703 inode->i_flags = flags;
3705 + vflags &= ~(V_BARRIER | V_COW);
3707 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3708 + vflags |= V_BARRIER;
3709 + if (ip->i_diskflags & GFS2_DIF_COW)
3711 + inode->i_vflags = vflags;
3714 +void gfs2_get_inode_flags(struct inode *inode)
3716 + struct gfs2_inode *ip = GFS2_I(inode);
3717 + unsigned int flags = inode->i_flags;
3718 + unsigned int vflags = inode->i_vflags;
3720 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3721 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3722 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3723 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3725 + if (flags & S_IMMUTABLE)
3726 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3727 + if (flags & S_IXUNLINK)
3728 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3730 + if (flags & S_APPEND)
3731 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3732 + if (flags & S_NOATIME)
3733 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3734 + if (flags & S_SYNC)
3735 + ip->i_diskflags |= GFS2_DIF_SYNC;
3737 + if (vflags & V_BARRIER)
3738 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3739 + if (vflags & V_COW)
3740 + ip->i_diskflags |= GFS2_DIF_COW;
3743 /* Flags that can be set by user space */
3744 @@ -295,6 +344,37 @@ static int gfs2_set_flags(struct file *f
3745 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3748 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3750 + struct gfs2_inode *ip = GFS2_I(inode);
3751 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3752 + struct buffer_head *bh;
3753 + struct gfs2_holder gh;
3756 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3759 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3762 + error = gfs2_meta_inode_buffer(ip, &bh);
3764 + goto out_trans_end;
3765 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
3766 + inode->i_flags = flags;
3767 + inode->i_vflags = vflags;
3768 + gfs2_get_inode_flags(inode);
3769 + gfs2_dinode_out(ip, bh->b_data);
3771 + gfs2_set_aops(inode);
3773 + gfs2_trans_end(sdp);
3775 + gfs2_glock_dq_uninit(&gh);
3779 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3782 diff -NurpP --minimal linux-3.0.25/fs/gfs2/inode.h linux-3.0.25-vs2.3.2.3/fs/gfs2/inode.h
3783 --- linux-3.0.25/fs/gfs2/inode.h 2011-07-22 11:18:05.000000000 +0200
3784 +++ linux-3.0.25-vs2.3.2.3/fs/gfs2/inode.h 2011-06-10 22:11:24.000000000 +0200
3785 @@ -120,6 +120,7 @@ extern const struct file_operations gfs2
3786 extern const struct file_operations gfs2_dir_fops_nolock;
3788 extern void gfs2_set_inode_flags(struct inode *inode);
3789 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3791 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3792 extern const struct file_operations gfs2_file_fops;
3793 diff -NurpP --minimal linux-3.0.25/fs/inode.c linux-3.0.25-vs2.3.2.3/fs/inode.c
3794 --- linux-3.0.25/fs/inode.c 2011-07-22 11:18:05.000000000 +0200
3795 +++ linux-3.0.25-vs2.3.2.3/fs/inode.c 2011-07-01 11:35:34.000000000 +0200
3797 #include <linux/ima.h>
3798 #include <linux/cred.h>
3799 #include <linux/buffer_head.h> /* for inode_has_buffers */
3800 +#include <linux/vs_tag.h>
3801 #include "internal.h"
3804 @@ -146,6 +147,9 @@ int inode_init_always(struct super_block
3805 struct address_space *const mapping = &inode->i_data;
3809 + /* essential because of inode slab reuse */
3811 inode->i_blkbits = sb->s_blocksize_bits;
3813 atomic_set(&inode->i_count, 1);
3814 @@ -166,6 +170,7 @@ int inode_init_always(struct super_block
3815 inode->i_bdev = NULL;
3816 inode->i_cdev = NULL;
3818 + inode->i_mdev = 0;
3819 inode->dirtied_when = 0;
3821 if (security_inode_alloc(inode))
3822 @@ -404,6 +409,8 @@ void __insert_inode_hash(struct inode *i
3824 EXPORT_SYMBOL(__insert_inode_hash);
3826 +EXPORT_SYMBOL_GPL(__iget);
3829 * remove_inode_hash - remove an inode from the hash
3830 * @inode: inode to unhash
3831 @@ -1643,9 +1650,11 @@ void init_special_inode(struct inode *in
3832 if (S_ISCHR(mode)) {
3833 inode->i_fop = &def_chr_fops;
3834 inode->i_rdev = rdev;
3835 + inode->i_mdev = rdev;
3836 } else if (S_ISBLK(mode)) {
3837 inode->i_fop = &def_blk_fops;
3838 inode->i_rdev = rdev;
3839 + inode->i_mdev = rdev;
3840 } else if (S_ISFIFO(mode))
3841 inode->i_fop = &def_fifo_fops;
3842 else if (S_ISSOCK(mode))
3843 @@ -1674,6 +1683,7 @@ void inode_init_owner(struct inode *inod
3845 inode->i_gid = current_fsgid();
3846 inode->i_mode = mode;
3847 + inode->i_tag = dx_current_fstag(inode->i_sb);
3849 EXPORT_SYMBOL(inode_init_owner);
3851 diff -NurpP --minimal linux-3.0.25/fs/ioctl.c linux-3.0.25-vs2.3.2.3/fs/ioctl.c
3852 --- linux-3.0.25/fs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3853 +++ linux-3.0.25-vs2.3.2.3/fs/ioctl.c 2011-06-10 22:11:24.000000000 +0200
3855 #include <linux/writeback.h>
3856 #include <linux/buffer_head.h>
3857 #include <linux/falloc.h>
3858 +#include <linux/proc_fs.h>
3859 +#include <linux/vserver/inode.h>
3860 +#include <linux/vs_tag.h>
3862 #include <asm/ioctls.h>
3864 diff -NurpP --minimal linux-3.0.25/fs/ioprio.c linux-3.0.25-vs2.3.2.3/fs/ioprio.c
3865 --- linux-3.0.25/fs/ioprio.c 2011-01-05 21:50:24.000000000 +0100
3866 +++ linux-3.0.25-vs2.3.2.3/fs/ioprio.c 2011-06-10 22:11:24.000000000 +0200
3868 #include <linux/syscalls.h>
3869 #include <linux/security.h>
3870 #include <linux/pid_namespace.h>
3871 +#include <linux/vs_base.h>
3873 int set_task_ioprio(struct task_struct *task, int ioprio)
3875 @@ -119,6 +120,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3877 pgrp = find_vpid(who);
3878 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3879 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3881 ret = set_task_ioprio(p, ioprio);
3884 @@ -208,6 +211,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3886 pgrp = find_vpid(who);
3887 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3888 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3890 tmpio = get_task_ioprio(p);
3893 diff -NurpP --minimal linux-3.0.25/fs/jfs/file.c linux-3.0.25-vs2.3.2.3/fs/jfs/file.c
3894 --- linux-3.0.25/fs/jfs/file.c 2011-07-22 11:18:05.000000000 +0200
3895 +++ linux-3.0.25-vs2.3.2.3/fs/jfs/file.c 2011-07-01 11:35:34.000000000 +0200
3896 @@ -102,7 +102,8 @@ int jfs_setattr(struct dentry *dentry, s
3897 if (is_quota_modification(inode, iattr))
3898 dquot_initialize(inode);
3899 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3900 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3901 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3902 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3903 rc = dquot_transfer(inode, iattr);
3906 @@ -133,6 +134,7 @@ const struct inode_operations jfs_file_i
3907 #ifdef CONFIG_JFS_POSIX_ACL
3908 .check_acl = jfs_check_acl,
3910 + .sync_flags = jfs_sync_flags,
3913 const struct file_operations jfs_file_operations = {
3914 diff -NurpP --minimal linux-3.0.25/fs/jfs/ioctl.c linux-3.0.25-vs2.3.2.3/fs/jfs/ioctl.c
3915 --- linux-3.0.25/fs/jfs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3916 +++ linux-3.0.25-vs2.3.2.3/fs/jfs/ioctl.c 2011-06-10 22:11:24.000000000 +0200
3918 #include <linux/mount.h>
3919 #include <linux/time.h>
3920 #include <linux/sched.h>
3921 +#include <linux/mount.h>
3922 #include <asm/current.h>
3923 #include <asm/uaccess.h>
3925 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
3929 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3931 + inode->i_flags = flags;
3932 + inode->i_vflags = vflags;
3933 + jfs_get_inode_flags(JFS_IP(inode));
3934 + inode->i_ctime = CURRENT_TIME_SEC;
3935 + mark_inode_dirty(inode);
3939 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3941 struct inode *inode = filp->f_dentry->d_inode;
3942 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
3943 if (!S_ISDIR(inode->i_mode))
3944 flags &= ~JFS_DIRSYNC_FL;
3946 + if (IS_BARRIER(inode)) {
3947 + vxwprintk_task(1, "messing with the barrier.");
3951 /* Is it quota file? Do not allow user to mess with it */
3952 if (IS_NOQUOTA(inode)) {
3954 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
3955 * the relevant capability.
3957 if ((oldflags & JFS_IMMUTABLE_FL) ||
3958 - ((flags ^ oldflags) &
3959 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3960 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3961 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3962 if (!capable(CAP_LINUX_IMMUTABLE)) {
3963 mutex_unlock(&inode->i_mutex);
3965 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
3969 - flags = flags & JFS_FL_USER_MODIFIABLE;
3970 + flags &= JFS_FL_USER_MODIFIABLE;
3971 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3972 jfs_inode->mode2 = flags;
3974 diff -NurpP --minimal linux-3.0.25/fs/jfs/jfs_dinode.h linux-3.0.25-vs2.3.2.3/fs/jfs/jfs_dinode.h
3975 --- linux-3.0.25/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
3976 +++ linux-3.0.25-vs2.3.2.3/fs/jfs/jfs_dinode.h 2011-06-10 22:11:24.000000000 +0200
3977 @@ -161,9 +161,13 @@ struct dinode {
3979 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3980 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3981 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3983 -#define JFS_FL_USER_VISIBLE 0x03F80000
3984 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3985 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3986 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3988 +#define JFS_FL_USER_VISIBLE 0x07F80000
3989 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3990 #define JFS_FL_INHERIT 0x03C80000
3992 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3993 diff -NurpP --minimal linux-3.0.25/fs/jfs/jfs_filsys.h linux-3.0.25-vs2.3.2.3/fs/jfs/jfs_filsys.h
3994 --- linux-3.0.25/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
3995 +++ linux-3.0.25-vs2.3.2.3/fs/jfs/jfs_filsys.h 2011-06-10 22:11:24.000000000 +0200
3997 #define JFS_NAME_MAX 255
3998 #define JFS_PATH_MAX BPSIZE
4000 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4003 * file system state (superblock state)
4004 diff -NurpP --minimal linux-3.0.25/fs/jfs/jfs_imap.c linux-3.0.25-vs2.3.2.3/fs/jfs/jfs_imap.c
4005 --- linux-3.0.25/fs/jfs/jfs_imap.c 2011-07-22 11:18:05.000000000 +0200
4006 +++ linux-3.0.25-vs2.3.2.3/fs/jfs/jfs_imap.c 2011-07-01 11:35:34.000000000 +0200
4008 #include <linux/pagemap.h>
4009 #include <linux/quotaops.h>
4010 #include <linux/slab.h>
4011 +#include <linux/vs_tag.h>
4013 #include "jfs_incore.h"
4014 #include "jfs_inode.h"
4015 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
4017 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4018 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4022 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4023 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4024 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
4026 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4028 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4029 + uid = le32_to_cpu(dip->di_uid);
4030 + gid = le32_to_cpu(dip->di_gid);
4031 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4033 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4035 ip->i_uid = jfs_ip->saved_uid;
4037 ip->i_uid = sbi->uid;
4040 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4041 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4043 ip->i_gid = jfs_ip->saved_gid;
4045 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
4046 dip->di_size = cpu_to_le64(ip->i_size);
4047 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4048 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4049 - if (sbi->uid == -1)
4050 - dip->di_uid = cpu_to_le32(ip->i_uid);
4052 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4053 - if (sbi->gid == -1)
4054 - dip->di_gid = cpu_to_le32(ip->i_gid);
4056 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4058 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4059 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4060 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4061 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4063 jfs_get_inode_flags(jfs_ip);
4065 * mode2 is only needed for storing the higher order bits.
4066 diff -NurpP --minimal linux-3.0.25/fs/jfs/jfs_inode.c linux-3.0.25-vs2.3.2.3/fs/jfs/jfs_inode.c
4067 --- linux-3.0.25/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
4068 +++ linux-3.0.25-vs2.3.2.3/fs/jfs/jfs_inode.c 2011-06-10 22:11:24.000000000 +0200
4071 #include <linux/fs.h>
4072 #include <linux/quotaops.h>
4073 +#include <linux/vs_tag.h>
4074 #include "jfs_incore.h"
4075 #include "jfs_inode.h"
4076 #include "jfs_filsys.h"
4077 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4079 unsigned int flags = JFS_IP(inode)->mode2;
4081 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4082 - S_NOATIME | S_DIRSYNC | S_SYNC);
4083 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4084 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4086 if (flags & JFS_IMMUTABLE_FL)
4087 inode->i_flags |= S_IMMUTABLE;
4088 + if (flags & JFS_IXUNLINK_FL)
4089 + inode->i_flags |= S_IXUNLINK;
4091 + if (flags & JFS_SYNC_FL)
4092 + inode->i_flags |= S_SYNC;
4093 if (flags & JFS_APPEND_FL)
4094 inode->i_flags |= S_APPEND;
4095 if (flags & JFS_NOATIME_FL)
4096 inode->i_flags |= S_NOATIME;
4097 if (flags & JFS_DIRSYNC_FL)
4098 inode->i_flags |= S_DIRSYNC;
4099 - if (flags & JFS_SYNC_FL)
4100 - inode->i_flags |= S_SYNC;
4102 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4104 + if (flags & JFS_BARRIER_FL)
4105 + inode->i_vflags |= V_BARRIER;
4106 + if (flags & JFS_COW_FL)
4107 + inode->i_vflags |= V_COW;
4110 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4112 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4113 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4115 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4116 + JFS_APPEND_FL | JFS_NOATIME_FL |
4117 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4118 + JFS_BARRIER_FL | JFS_COW_FL);
4120 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4121 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4122 if (flags & S_IMMUTABLE)
4123 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4124 + if (flags & S_IXUNLINK)
4125 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4127 if (flags & S_APPEND)
4128 jfs_ip->mode2 |= JFS_APPEND_FL;
4129 if (flags & S_NOATIME)
4130 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4131 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4133 jfs_ip->mode2 |= JFS_SYNC_FL;
4135 + if (vflags & V_BARRIER)
4136 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4137 + if (vflags & V_COW)
4138 + jfs_ip->mode2 |= JFS_COW_FL;
4142 diff -NurpP --minimal linux-3.0.25/fs/jfs/jfs_inode.h linux-3.0.25-vs2.3.2.3/fs/jfs/jfs_inode.h
4143 --- linux-3.0.25/fs/jfs/jfs_inode.h 2011-07-22 11:18:05.000000000 +0200
4144 +++ linux-3.0.25-vs2.3.2.3/fs/jfs/jfs_inode.h 2011-06-10 22:11:24.000000000 +0200
4145 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4146 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4147 int fh_len, int fh_type);
4148 extern void jfs_set_inode_flags(struct inode *);
4149 +extern int jfs_sync_flags(struct inode *, int, int);
4150 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4151 extern int jfs_setattr(struct dentry *, struct iattr *);
4153 diff -NurpP --minimal linux-3.0.25/fs/jfs/namei.c linux-3.0.25-vs2.3.2.3/fs/jfs/namei.c
4154 --- linux-3.0.25/fs/jfs/namei.c 2011-05-22 16:17:53.000000000 +0200
4155 +++ linux-3.0.25-vs2.3.2.3/fs/jfs/namei.c 2011-06-10 22:11:24.000000000 +0200
4157 #include <linux/ctype.h>
4158 #include <linux/quotaops.h>
4159 #include <linux/exportfs.h>
4160 +#include <linux/vs_tag.h>
4161 #include "jfs_incore.h"
4162 #include "jfs_superblock.h"
4163 #include "jfs_inode.h"
4164 @@ -1486,6 +1487,7 @@ static struct dentry *jfs_lookup(struct
4165 return ERR_CAST(ip);
4168 + dx_propagate_tag(nd, ip);
4169 return d_splice_alias(ip, dentry);
4172 @@ -1550,6 +1552,7 @@ const struct inode_operations jfs_dir_in
4173 #ifdef CONFIG_JFS_POSIX_ACL
4174 .check_acl = jfs_check_acl,
4176 + .sync_flags = jfs_sync_flags,
4179 const struct file_operations jfs_dir_operations = {
4180 diff -NurpP --minimal linux-3.0.25/fs/jfs/super.c linux-3.0.25-vs2.3.2.3/fs/jfs/super.c
4181 --- linux-3.0.25/fs/jfs/super.c 2011-05-22 16:17:53.000000000 +0200
4182 +++ linux-3.0.25-vs2.3.2.3/fs/jfs/super.c 2011-06-10 22:11:24.000000000 +0200
4183 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
4185 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4186 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4187 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4188 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4189 + Opt_tag, Opt_notag, Opt_tagid
4192 static const match_table_t tokens = {
4193 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
4194 {Opt_resize, "resize=%u"},
4195 {Opt_resize_nosize, "resize"},
4196 {Opt_errors, "errors=%s"},
4198 + {Opt_notag, "notag"},
4199 + {Opt_tagid, "tagid=%u"},
4200 + {Opt_tag, "tagxid"},
4201 {Opt_ignore, "noquota"},
4202 {Opt_ignore, "quota"},
4203 {Opt_usrquota, "usrquota"},
4204 @@ -342,6 +347,20 @@ static int parse_options(char *options,
4208 +#ifndef CONFIG_TAGGING_NONE
4210 + *flag |= JFS_TAGGED;
4213 + *flag &= JFS_TAGGED;
4216 +#ifdef CONFIG_PROPAGATE
4219 + *flag |= JFS_TAGGED;
4223 printk("jfs: Unrecognized mount option \"%s\" "
4224 " or missing value\n", p);
4225 @@ -373,6 +392,12 @@ static int jfs_remount(struct super_bloc
4229 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4230 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4236 if (sb->s_flags & MS_RDONLY) {
4238 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4239 #ifdef CONFIG_JFS_POSIX_ACL
4240 sb->s_flags |= MS_POSIXACL;
4242 + /* map mount option tagxid */
4243 + if (sbi->flag & JFS_TAGGED)
4244 + sb->s_flags |= MS_TAGGED;
4247 printk(KERN_ERR "resize option for remount only\n");
4248 diff -NurpP --minimal linux-3.0.25/fs/libfs.c linux-3.0.25-vs2.3.2.3/fs/libfs.c
4249 --- linux-3.0.25/fs/libfs.c 2011-07-22 11:18:05.000000000 +0200
4250 +++ linux-3.0.25-vs2.3.2.3/fs/libfs.c 2011-07-22 11:20:39.000000000 +0200
4251 @@ -133,7 +133,8 @@ static inline unsigned char dt_type(stru
4252 * both impossible due to the lock on directory.
4255 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4256 +static inline int do_dcache_readdir_filter(struct file *filp,
4257 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4259 struct dentry *dentry = filp->f_path.dentry;
4260 struct dentry *cursor = filp->private_data;
4261 @@ -164,6 +165,8 @@ int dcache_readdir(struct file * filp, v
4262 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4263 struct dentry *next;
4264 next = list_entry(p, struct dentry, d_u.d_child);
4265 + if (filter && !filter(next))
4267 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4268 if (!simple_positive(next)) {
4269 spin_unlock(&next->d_lock);
4270 @@ -190,6 +193,17 @@ int dcache_readdir(struct file * filp, v
4274 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4276 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4279 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4280 + int (*filter)(struct dentry *))
4282 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4285 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4288 @@ -965,6 +979,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4289 EXPORT_SYMBOL(dcache_dir_lseek);
4290 EXPORT_SYMBOL(dcache_dir_open);
4291 EXPORT_SYMBOL(dcache_readdir);
4292 +EXPORT_SYMBOL(dcache_readdir_filter);
4293 EXPORT_SYMBOL(generic_read_dir);
4294 EXPORT_SYMBOL(mount_pseudo);
4295 EXPORT_SYMBOL(simple_write_begin);
4296 diff -NurpP --minimal linux-3.0.25/fs/locks.c linux-3.0.25-vs2.3.2.3/fs/locks.c
4297 --- linux-3.0.25/fs/locks.c 2011-07-22 11:18:05.000000000 +0200
4298 +++ linux-3.0.25-vs2.3.2.3/fs/locks.c 2011-07-19 00:51:58.000000000 +0200
4300 #include <linux/time.h>
4301 #include <linux/rcupdate.h>
4302 #include <linux/pid_namespace.h>
4303 +#include <linux/vs_base.h>
4304 +#include <linux/vs_limit.h>
4306 #include <asm/uaccess.h>
4308 @@ -171,13 +173,19 @@ static void locks_init_lock_always(struc
4311 fl->fl_start = fl->fl_end = 0;
4316 /* Allocate an empty lock structure. */
4317 struct file_lock *locks_alloc_lock(void)
4319 - struct file_lock *fl = kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4320 + struct file_lock *fl;
4322 + if (!vx_locks_avail(1))
4325 + fl = kmem_cache_alloc(filelock_cache, GFP_KERNEL);
4327 locks_init_lock_always(fl);
4329 @@ -208,6 +216,7 @@ void locks_free_lock(struct file_lock *f
4330 BUG_ON(!list_empty(&fl->fl_block));
4331 BUG_ON(!list_empty(&fl->fl_link));
4334 locks_release_private(fl);
4335 kmem_cache_free(filelock_cache, fl);
4337 @@ -272,6 +281,7 @@ void locks_copy_lock(struct file_lock *n
4338 new->fl_file = fl->fl_file;
4339 new->fl_ops = fl->fl_ops;
4340 new->fl_lmops = fl->fl_lmops;
4341 + new->fl_xid = fl->fl_xid;
4343 locks_copy_private(new, fl);
4345 @@ -310,6 +320,11 @@ static int flock_make_lock(struct file *
4346 fl->fl_flags = FL_FLOCK;
4348 fl->fl_end = OFFSET_MAX;
4350 + vxd_assert(filp->f_xid == vx_current_xid(),
4351 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4352 + fl->fl_xid = filp->f_xid;
4357 @@ -459,6 +474,7 @@ static int lease_init(struct file *filp,
4359 fl->fl_owner = current->files;
4360 fl->fl_pid = current->tgid;
4361 + fl->fl_xid = vx_current_xid();
4364 fl->fl_flags = FL_LEASE;
4365 @@ -478,6 +494,11 @@ static struct file_lock *lease_alloc(str
4367 return ERR_PTR(error);
4369 + fl->fl_xid = vx_current_xid();
4371 + vxd_assert(filp->f_xid == fl->fl_xid,
4372 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4374 error = lease_init(filp, type, fl);
4376 locks_free_lock(fl);
4377 @@ -779,6 +800,7 @@ static int flock_lock_file(struct file *
4381 + new_fl->fl_xid = -1;
4383 for_each_lock(inode, before) {
4384 struct file_lock *fl = *before;
4385 @@ -799,6 +821,7 @@ find_conflict:
4387 locks_copy_lock(new_fl, request);
4388 locks_insert_lock(before, new_fl);
4389 + vx_locks_inc(new_fl);
4393 @@ -809,7 +832,8 @@ out:
4397 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4398 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4399 + struct file_lock *conflock, xid_t xid)
4401 struct file_lock *fl;
4402 struct file_lock *new_fl = NULL;
4403 @@ -819,6 +843,8 @@ static int __posix_lock_file(struct inod
4404 struct file_lock **before;
4405 int error, added = 0;
4407 + vxd_assert(xid == vx_current_xid(),
4408 + "xid(%d) == current(%d)", xid, vx_current_xid());
4410 * We may need two file_lock structures for this operation,
4411 * so we get them in advance to avoid races.
4412 @@ -829,7 +855,11 @@ static int __posix_lock_file(struct inod
4413 (request->fl_type != F_UNLCK ||
4414 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4415 new_fl = locks_alloc_lock();
4416 + new_fl->fl_xid = xid;
4417 + vx_locks_inc(new_fl);
4418 new_fl2 = locks_alloc_lock();
4419 + new_fl2->fl_xid = xid;
4420 + vx_locks_inc(new_fl2);
4424 @@ -1028,7 +1058,8 @@ static int __posix_lock_file(struct inod
4425 int posix_lock_file(struct file *filp, struct file_lock *fl,
4426 struct file_lock *conflock)
4428 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4429 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4430 + fl, conflock, filp->f_xid);
4432 EXPORT_SYMBOL(posix_lock_file);
4434 @@ -1118,7 +1149,7 @@ int locks_mandatory_area(int read_write,
4435 fl.fl_end = offset + count - 1;
4438 - error = __posix_lock_file(inode, &fl, NULL);
4439 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4440 if (error != FILE_LOCK_DEFERRED)
4442 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4443 @@ -1431,6 +1462,7 @@ int generic_setlease(struct file *filp,
4446 locks_insert_lock(before, lease);
4447 + vx_locks_inc(lease);
4451 @@ -1815,6 +1847,11 @@ int fcntl_setlk(unsigned int fd, struct
4452 if (file_lock == NULL)
4455 + vxd_assert(filp->f_xid == vx_current_xid(),
4456 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4457 + file_lock->fl_xid = filp->f_xid;
4458 + vx_locks_inc(file_lock);
4461 * This might block, so we do it before checking the inode.
4463 @@ -1933,6 +1970,11 @@ int fcntl_setlk64(unsigned int fd, struc
4464 if (file_lock == NULL)
4467 + vxd_assert(filp->f_xid == vx_current_xid(),
4468 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4469 + file_lock->fl_xid = filp->f_xid;
4470 + vx_locks_inc(file_lock);
4473 * This might block, so we do it before checking the inode.
4475 @@ -2198,8 +2240,11 @@ static int locks_show(struct seq_file *f
4477 lock_get_status(f, fl, *((loff_t *)f->private), "");
4479 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4480 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4481 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4483 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4488 diff -NurpP --minimal linux-3.0.25/fs/namei.c linux-3.0.25-vs2.3.2.3/fs/namei.c
4489 --- linux-3.0.25/fs/namei.c 2012-03-19 21:16:51.000000000 +0100
4490 +++ linux-3.0.25-vs2.3.2.3/fs/namei.c 2012-03-23 14:54:00.000000000 +0100
4492 #include <linux/fcntl.h>
4493 #include <linux/device_cgroup.h>
4494 #include <linux/fs_struct.h>
4495 +#include <linux/proc_fs.h>
4496 +#include <linux/vserver/inode.h>
4497 +#include <linux/vs_base.h>
4498 +#include <linux/vs_tag.h>
4499 +#include <linux/vs_cowbl.h>
4500 +#include <linux/vs_device.h>
4501 +#include <linux/vs_context.h>
4502 +#include <linux/pid_namespace.h>
4503 #include <asm/uaccess.h>
4505 #include "internal.h"
4506 @@ -175,6 +183,89 @@ void putname(const char *name)
4507 EXPORT_SYMBOL(putname);
4510 +static inline int dx_barrier(const struct inode *inode)
4512 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4513 + vxwprintk_task(1, "did hit the barrier.");
4519 +static int __dx_permission(const struct inode *inode, int mask)
4521 + if (dx_barrier(inode))
4524 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4525 + /* devpts is xid tagged */
4526 + if (S_ISDIR(inode->i_mode) ||
4527 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4530 + /* just pretend we didn't find anything */
4533 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4534 + struct proc_dir_entry *de = PDE(inode);
4536 + if (de && !vx_hide_check(0, de->vx_flags))
4539 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4541 + struct task_struct *tsk;
4543 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4544 + vx_flags(VXF_STATE_SETUP, 0))
4547 + pid = PROC_I(inode)->pid;
4552 + tsk = pid_task(pid, PIDTYPE_PID);
4553 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4554 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4556 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4557 + rcu_read_unlock();
4560 + rcu_read_unlock();
4563 + /* FIXME: Should we block some entries here? */
4568 + if (dx_notagcheck(inode->i_sb) ||
4569 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4578 +int dx_permission(const struct inode *inode, int mask)
4580 + int ret = __dx_permission(inode, mask);
4581 + if (unlikely(ret)) {
4582 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4583 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4586 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4587 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4594 * This does basic POSIX ACL permission checking
4596 @@ -285,10 +376,14 @@ int inode_permission(struct inode *inode
4598 * Nobody gets write access to an immutable file.
4600 - if (IS_IMMUTABLE(inode))
4601 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4605 + retval = dx_permission(inode, mask);
4609 if (inode->i_op->permission)
4610 retval = inode->i_op->permission(inode, mask, 0);
4612 @@ -584,6 +679,9 @@ static inline int exec_permission(struct
4614 struct user_namespace *ns = inode_userns(inode);
4616 + if (dx_barrier(inode))
4619 if (inode->i_op->permission) {
4620 ret = inode->i_op->permission(inode, MAY_EXEC, flags);
4622 @@ -1095,7 +1193,8 @@ static void follow_dotdot(struct nameida
4624 if (nd->path.dentry == nd->root.dentry &&
4625 nd->path.mnt == nd->root.mnt) {
4627 + /* for sane '/' avoid follow_mount() */
4630 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4631 /* rare case of legitimate dget_parent()... */
4632 @@ -1178,6 +1277,9 @@ static int do_lookup(struct nameidata *n
4637 + /* FIXME: check dx permission */
4640 path->dentry = dentry;
4641 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4642 @@ -1226,6 +1328,8 @@ retry:
4646 + /* FIXME: check dx permission */
4649 path->dentry = dentry;
4650 err = follow_managed(path, nd->flags);
4651 @@ -1853,7 +1957,7 @@ static int may_delete(struct inode *dir,
4654 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4655 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4656 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4659 if (!S_ISDIR(victim->d_inode->i_mode))
4660 @@ -1980,6 +2084,15 @@ static int may_open(struct path *path, i
4664 +#ifdef CONFIG_VSERVER_COWBL
4665 + if (IS_COW(inode) &&
4666 + ((flag & O_ACCMODE) != O_RDONLY)) {
4667 + if (IS_COW_LINK(inode))
4669 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4670 + mark_inode_dirty(inode);
4673 error = inode_permission(inode, acc_mode);
4676 @@ -2224,6 +2337,16 @@ ok:
4679 error = may_open(&nd->path, acc_mode, open_flag);
4680 +#ifdef CONFIG_VSERVER_COWBL
4681 + if (error == -EMLINK) {
4682 + struct dentry *dentry;
4683 + dentry = cow_break_link(pathname);
4684 + if (IS_ERR(dentry))
4685 + error = PTR_ERR(dentry);
4692 filp = nameidata_to_filp(nd);
4693 @@ -2266,6 +2389,7 @@ static struct file *path_openat(int dfd,
4698 filp = get_empty_filp();
4700 return ERR_PTR(-ENFILE);
4701 @@ -2303,6 +2427,17 @@ static struct file *path_openat(int dfd,
4702 filp = do_last(nd, &path, op, pathname);
4703 put_link(nd, &link, cookie);
4706 +#ifdef CONFIG_VSERVER_COWBL
4707 + if (filp == ERR_PTR(-EMLINK)) {
4708 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4709 + path_put(&nd->root);
4712 + release_open_intent(nd);
4717 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4718 path_put(&nd->root);
4719 @@ -2886,7 +3021,7 @@ int vfs_link(struct dentry *old_dentry,
4721 * A link to an append-only or immutable file cannot be created.
4723 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4724 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4726 if (!dir->i_op->link)
4728 @@ -3274,6 +3409,227 @@ int vfs_follow_link(struct nameidata *nd
4729 return __vfs_follow_link(nd, link);
4733 +#ifdef CONFIG_VSERVER_COWBL
4736 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4740 + return do_splice_direct(in, &ppos, out, len, 0);
4743 +struct dentry *cow_break_link(const char *pathname)
4745 + int ret, mode, pathlen, redo = 0;
4746 + struct nameidata old_nd, dir_nd;
4747 + struct path old_path;
4748 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4749 + struct file *old_file;
4750 + struct file *new_file;
4751 + char *to, *path, pad='\251';
4754 + vxdprintk(VXD_CBIT(misc, 1),
4755 + "cow_break_link(" VS_Q("%s") ")", pathname);
4756 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4761 + /* old_nd will have refs to dentry and mnt */
4762 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4763 + vxdprintk(VXD_CBIT(misc, 2),
4764 + "do_path_lookup(old): %d [r=%d]",
4765 + ret, mnt_get_count(old_nd.path.mnt));
4767 + goto out_free_path;
4769 + old_path = old_nd.path;
4770 + old_dentry = old_path.dentry;
4771 + mode = old_dentry->d_inode->i_mode;
4773 + to = d_path(&old_path, path, PATH_MAX-2);
4774 + pathlen = strlen(to);
4775 + vxdprintk(VXD_CBIT(misc, 2),
4776 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4778 + old_dentry->d_name.len, old_dentry->d_name.name,
4779 + old_dentry->d_name.len);
4781 + to[pathlen + 1] = 0;
4783 + new_dentry = NULL;
4784 + to[pathlen] = pad--;
4786 + if (pad <= '\240')
4789 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4790 + /* dir_nd will have refs to dentry and mnt */
4791 + ret = do_path_lookup(AT_FDCWD, to,
4792 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4793 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4797 + /* this puppy downs the inode mutex */
4798 + new_dentry = lookup_create(&dir_nd, 0);
4799 + if (!new_dentry || IS_ERR(new_dentry)) {
4800 + path_put(&dir_nd.path);
4801 + vxdprintk(VXD_CBIT(misc, 2),
4802 + "lookup_create(new): failed with %ld",
4803 + PTR_ERR(new_dentry));
4804 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
4807 + vxdprintk(VXD_CBIT(misc, 2),
4808 + "lookup_create(new): %p [" VS_Q("%.*s") ":%d]",
4810 + new_dentry->d_name.len, new_dentry->d_name.name,
4811 + new_dentry->d_name.len);
4813 + dir = dir_nd.path.dentry;
4815 + ret = vfs_create(dir->d_inode, new_dentry, mode, &dir_nd);
4816 + vxdprintk(VXD_CBIT(misc, 2),
4817 + "vfs_create(new): %d", ret);
4818 + if (ret == -EEXIST) {
4819 + mutex_unlock(&dir->d_inode->i_mutex);
4820 + path_put(&dir_nd.path);
4825 + goto out_unlock_new;
4827 + /* drop out early, ret passes ENOENT */
4829 + if ((redo = d_unhashed(old_dentry)))
4830 + goto out_unlock_new;
4832 + path_get(&old_path);
4833 + /* this one cleans up the dentry/mnt in case of failure */
4834 + old_file = dentry_open(old_dentry, old_path.mnt,
4835 + O_RDONLY, current_cred());
4836 + vxdprintk(VXD_CBIT(misc, 2),
4837 + "dentry_open(old): %p", old_file);
4838 + if (IS_ERR(old_file)) {
4839 + ret = PTR_ERR(old_file);
4840 + goto out_unlock_new;
4844 + mntget(old_path.mnt);
4845 + /* this one cleans up the dentry/mnt in case of failure */
4846 + new_file = dentry_open(new_dentry, old_path.mnt,
4847 + O_WRONLY, current_cred());
4848 + vxdprintk(VXD_CBIT(misc, 2),
4849 + "dentry_open(new): %p", new_file);
4850 + if (IS_ERR(new_file)) {
4851 + ret = PTR_ERR(new_file);
4852 + goto out_fput_old;
4855 + size = i_size_read(old_file->f_dentry->d_inode);
4856 + ret = do_cow_splice(old_file, new_file, size);
4857 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4859 + goto out_fput_both;
4860 + } else if (ret < size) {
4862 + goto out_fput_both;
4864 + struct inode *old_inode = old_dentry->d_inode;
4865 + struct inode *new_inode = new_dentry->d_inode;
4866 + struct iattr attr = {
4867 + .ia_uid = old_inode->i_uid,
4868 + .ia_gid = old_inode->i_gid,
4869 + .ia_valid = ATTR_UID | ATTR_GID
4872 + setattr_copy(new_inode, &attr);
4873 + mark_inode_dirty(new_inode);
4876 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4878 + /* drop out late */
4880 + if ((redo = d_unhashed(old_dentry)))
4883 + vxdprintk(VXD_CBIT(misc, 2),
4884 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4885 + new_dentry->d_name.len, new_dentry->d_name.name,
4886 + new_dentry->d_name.len,
4887 + old_dentry->d_name.len, old_dentry->d_name.name,
4888 + old_dentry->d_name.len);
4889 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4890 + old_dentry->d_parent->d_inode, old_dentry);
4891 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4894 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4897 + vxdprintk(VXD_CBIT(misc, 3),
4898 + "fput(new_file=%p[#%ld])", new_file,
4899 + atomic_long_read(&new_file->f_count));
4903 + vxdprintk(VXD_CBIT(misc, 3),
4904 + "fput(old_file=%p[#%ld])", old_file,
4905 + atomic_long_read(&old_file->f_count));
4909 + mutex_unlock(&dir->d_inode->i_mutex);
4913 + /* error path cleanup */
4914 + vfs_unlink(dir->d_inode, new_dentry);
4918 + goto out_rel_both;
4919 + /* lookup dentry once again */
4920 + /* old_nd.path is freed as old_path in out_rel_old */
4921 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4923 + goto out_rel_both;
4926 + new_dentry = old_nd.path.dentry;
4927 + vxdprintk(VXD_CBIT(misc, 2),
4928 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4930 + new_dentry->d_name.len, new_dentry->d_name.name,
4931 + new_dentry->d_name.len);
4935 + path_put(&dir_nd.path);
4937 + path_put(&old_path);
4943 + new_dentry = ERR_PTR(ret);
4945 + vxdprintk(VXD_CBIT(misc, 3),
4946 + "cow_break_link returning with %p [r=%d]",
4947 + new_dentry, mnt_get_count(old_nd.path.mnt));
4948 + return new_dentry;
4953 /* get the link contents into pagecache */
4954 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4956 diff -NurpP --minimal linux-3.0.25/fs/namespace.c linux-3.0.25-vs2.3.2.3/fs/namespace.c
4957 --- linux-3.0.25/fs/namespace.c 2012-03-19 21:16:51.000000000 +0100
4958 +++ linux-3.0.25-vs2.3.2.3/fs/namespace.c 2011-12-23 16:09:00.000000000 +0100
4960 #include <linux/idr.h>
4961 #include <linux/fs_struct.h>
4962 #include <linux/fsnotify.h>
4963 +#include <linux/vs_base.h>
4964 +#include <linux/vs_context.h>
4965 +#include <linux/vs_tag.h>
4966 +#include <linux/vserver/space.h>
4967 +#include <linux/vserver/global.h>
4968 #include <asm/uaccess.h>
4969 #include <asm/unistd.h>
4971 @@ -679,6 +684,10 @@ vfs_kern_mount(struct file_system_type *
4973 return ERR_PTR(-ENODEV);
4975 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
4976 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
4977 + return ERR_PTR(-EPERM);
4979 mnt = alloc_vfsmnt(name);
4981 return ERR_PTR(-ENOMEM);
4982 @@ -724,6 +733,7 @@ static struct vfsmount *clone_mnt(struct
4983 mnt->mnt_root = dget(root);
4984 mnt->mnt_mountpoint = mnt->mnt_root;
4985 mnt->mnt_parent = mnt;
4986 + mnt->mnt_tag = old->mnt_tag;
4988 if (flag & CL_SLAVE) {
4989 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
4990 @@ -852,6 +862,31 @@ static inline void mangle(struct seq_fil
4991 seq_escape(m, s, " \t\n\\");
4994 +static int mnt_is_reachable(struct vfsmount *mnt)
4997 + struct dentry *point;
5000 + if (mnt == mnt->mnt_ns->root)
5003 + br_read_lock(vfsmount_lock);
5004 + root = current->fs->root;
5005 + point = root.dentry;
5007 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5008 + point = mnt->mnt_mountpoint;
5009 + mnt = mnt->mnt_parent;
5012 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5014 + br_read_unlock(vfsmount_lock);
5020 * Simple .show_options callback for filesystems which don't want to
5021 * implement more complex mount option showing.
5022 @@ -954,6 +989,8 @@ static int show_sb_opts(struct seq_file
5023 { MS_SYNCHRONOUS, ",sync" },
5024 { MS_DIRSYNC, ",dirsync" },
5025 { MS_MANDLOCK, ",mand" },
5026 + { MS_TAGGED, ",tag" },
5027 + { MS_NOTAGCHECK, ",notagcheck" },
5030 const struct proc_fs_info *fs_infop;
5031 @@ -1000,16 +1037,26 @@ static int show_vfsmnt(struct seq_file *
5033 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5035 - if (mnt->mnt_sb->s_op->show_devname) {
5036 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5039 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5041 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5044 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5045 + mnt == current->fs->root.mnt) {
5046 + seq_puts(m, "/dev/root / ");
5048 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5049 + if (mnt->mnt_sb->s_op->show_devname) {
5050 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5054 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5057 + seq_path(m, &mnt_path, " \t\n\\");
5061 - seq_path(m, &mnt_path, " \t\n\\");
5063 show_type(m, mnt->mnt_sb);
5064 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5065 err = show_sb_opts(m, mnt->mnt_sb);
5066 @@ -1039,6 +1086,11 @@ static int show_mountinfo(struct seq_fil
5067 struct path root = p->root;
5070 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5072 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5075 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5076 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5077 if (sb->s_op->show_path)
5078 @@ -1104,22 +1156,32 @@ static int show_vfsstat(struct seq_file
5079 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5083 - if (mnt->mnt_sb->s_op->show_devname) {
5084 - seq_puts(m, "device ");
5085 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5086 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5088 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5091 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5092 + mnt == current->fs->root.mnt) {
5093 + seq_puts(m, "device /dev/root mounted on / ");
5095 - if (mnt->mnt_devname) {
5097 + if (mnt->mnt_sb->s_op->show_devname) {
5098 seq_puts(m, "device ");
5099 - mangle(m, mnt->mnt_devname);
5101 - seq_puts(m, "no device");
5103 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5105 + if (mnt->mnt_devname) {
5106 + seq_puts(m, "device ");
5107 + mangle(m, mnt->mnt_devname);
5109 + seq_puts(m, "no device");
5113 - seq_puts(m, " mounted on ");
5114 - seq_path(m, &mnt_path, " \t\n\\");
5117 + seq_puts(m, " mounted on ");
5118 + seq_path(m, &mnt_path, " \t\n\\");
5122 /* file system type */
5123 seq_puts(m, "with fstype ");
5124 @@ -1378,7 +1440,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5128 - if (!capable(CAP_SYS_ADMIN))
5129 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5132 retval = do_umount(path.mnt, flags);
5133 @@ -1404,7 +1466,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5135 static int mount_is_safe(struct path *path)
5137 - if (capable(CAP_SYS_ADMIN))
5138 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5142 @@ -1714,7 +1776,7 @@ static int do_change_type(struct path *p
5146 - if (!capable(CAP_SYS_ADMIN))
5147 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5150 if (path->dentry != path->mnt->mnt_root)
5151 @@ -1730,6 +1792,7 @@ static int do_change_type(struct path *p
5155 + // mnt->mnt_flags = mnt_flags;
5157 br_write_lock(vfsmount_lock);
5158 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
5159 @@ -1745,12 +1808,14 @@ static int do_change_type(struct path *p
5160 * do loopback mount.
5162 static int do_loopback(struct path *path, char *old_name,
5164 + tag_t tag, unsigned long flags, int mnt_flags)
5166 LIST_HEAD(umount_list);
5167 struct path old_path;
5168 struct vfsmount *mnt = NULL;
5169 int err = mount_is_safe(path);
5170 + int recurse = flags & MS_REC;
5174 if (!old_name || !*old_name)
5175 @@ -1816,12 +1881,12 @@ static int change_mount_flags(struct vfs
5176 * on it - tough luck.
5178 static int do_remount(struct path *path, int flags, int mnt_flags,
5180 + void *data, xid_t xid)
5183 struct super_block *sb = path->mnt->mnt_sb;
5185 - if (!capable(CAP_SYS_ADMIN))
5186 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5189 if (!check_mnt(path->mnt))
5190 @@ -1869,7 +1934,7 @@ static int do_move_mount(struct path *pa
5191 struct path old_path, parent_path;
5194 - if (!capable(CAP_SYS_ADMIN))
5195 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5197 if (!old_name || !*old_name)
5199 @@ -2020,7 +2085,7 @@ static int do_new_mount(struct path *pat
5202 /* we need capabilities... */
5203 - if (!capable(CAP_SYS_ADMIN))
5204 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5207 mnt = do_kern_mount(type, flags, name, data);
5208 @@ -2289,6 +2354,7 @@ long do_mount(char *dev_name, char *dir_
5215 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5216 @@ -2316,6 +2382,12 @@ long do_mount(char *dev_name, char *dir_
5217 if (!(flags & MS_NOATIME))
5218 mnt_flags |= MNT_RELATIME;
5220 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5221 + /* FIXME: bind and re-mounts get the tag flag? */
5222 + if (flags & (MS_BIND|MS_REMOUNT))
5223 + flags |= MS_TAGID;
5226 /* Separate the per-mountpoint flags */
5227 if (flags & MS_NOSUID)
5228 mnt_flags |= MNT_NOSUID;
5229 @@ -2332,15 +2404,17 @@ long do_mount(char *dev_name, char *dir_
5230 if (flags & MS_RDONLY)
5231 mnt_flags |= MNT_READONLY;
5233 + if (!capable(CAP_SYS_ADMIN))
5234 + mnt_flags |= MNT_NODEV;
5235 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5236 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5239 if (flags & MS_REMOUNT)
5240 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5243 else if (flags & MS_BIND)
5244 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5245 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5246 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5247 retval = do_change_type(&path, flags);
5248 else if (flags & MS_MOVE)
5249 @@ -2440,6 +2514,7 @@ static struct mnt_namespace *dup_mnt_ns(
5250 q = next_mnt(q, new_ns->root);
5252 up_write(&namespace_sem);
5253 + atomic_inc(&vs_global_mnt_ns);
5257 @@ -2579,9 +2654,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5261 - if (IS_MNT_SHARED(old.mnt) ||
5262 - IS_MNT_SHARED(new.mnt->mnt_parent) ||
5263 - IS_MNT_SHARED(root.mnt->mnt_parent))
5264 + if ((IS_MNT_SHARED(old.mnt) ||
5265 + IS_MNT_SHARED(new.mnt->mnt_parent) ||
5266 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5267 + !vx_flags(VXF_STATE_SETUP, 0))
5269 if (!check_mnt(root.mnt) || !check_mnt(new.mnt))
5271 @@ -2713,6 +2789,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5272 br_write_unlock(vfsmount_lock);
5273 up_write(&namespace_sem);
5274 release_mounts(&umount_list);
5275 + atomic_dec(&vs_global_mnt_ns);
5278 EXPORT_SYMBOL(put_mnt_ns);
5279 diff -NurpP --minimal linux-3.0.25/fs/nfs/client.c linux-3.0.25-vs2.3.2.3/fs/nfs/client.c
5280 --- linux-3.0.25/fs/nfs/client.c 2011-07-22 11:18:05.000000000 +0200
5281 +++ linux-3.0.25-vs2.3.2.3/fs/nfs/client.c 2011-06-10 22:11:24.000000000 +0200
5282 @@ -780,6 +780,9 @@ static int nfs_init_server_rpcclient(str
5283 if (server->flags & NFS_MOUNT_SOFT)
5284 server->client->cl_softrtry = 1;
5286 + server->client->cl_tag = 0;
5287 + if (server->flags & NFS_MOUNT_TAGGED)
5288 + server->client->cl_tag = 1;
5292 @@ -951,6 +954,10 @@ static void nfs_server_set_fsinfo(struct
5293 server->acdirmin = server->acdirmax = 0;
5296 + /* FIXME: needs fsinfo
5297 + if (server->flags & NFS_MOUNT_TAGGED)
5298 + sb->s_flags |= MS_TAGGED; */
5300 server->maxfilesize = fsinfo->maxfilesize;
5302 server->time_delta = fsinfo->time_delta;
5303 diff -NurpP --minimal linux-3.0.25/fs/nfs/dir.c linux-3.0.25-vs2.3.2.3/fs/nfs/dir.c
5304 --- linux-3.0.25/fs/nfs/dir.c 2012-03-19 21:16:51.000000000 +0100
5305 +++ linux-3.0.25-vs2.3.2.3/fs/nfs/dir.c 2011-12-19 15:55:53.000000000 +0100
5307 #include <linux/sched.h>
5308 #include <linux/kmemleak.h>
5309 #include <linux/xattr.h>
5310 +#include <linux/vs_tag.h>
5312 #include "delegation.h"
5314 @@ -1308,6 +1309,7 @@ static struct dentry *nfs_lookup(struct
5316 goto out_unblock_sillyrename;
5318 + dx_propagate_tag(nd, inode);
5320 res = d_materialise_unique(dentry, inode);
5322 diff -NurpP --minimal linux-3.0.25/fs/nfs/inode.c linux-3.0.25-vs2.3.2.3/fs/nfs/inode.c
5323 --- linux-3.0.25/fs/nfs/inode.c 2012-03-19 21:16:51.000000000 +0100
5324 +++ linux-3.0.25-vs2.3.2.3/fs/nfs/inode.c 2011-12-19 15:55:53.000000000 +0100
5326 #include <linux/nfs_xdr.h>
5327 #include <linux/slab.h>
5328 #include <linux/compat.h>
5329 +#include <linux/vs_tag.h>
5331 #include <asm/system.h>
5332 #include <asm/uaccess.h>
5333 @@ -273,6 +274,8 @@ nfs_fhget(struct super_block *sb, struct
5334 if (inode->i_state & I_NEW) {
5335 struct nfs_inode *nfsi = NFS_I(inode);
5336 unsigned long now = jiffies;
5340 /* We set i_ino for the few things that still rely on it,
5341 * such as stat(2) */
5342 @@ -321,8 +324,8 @@ nfs_fhget(struct super_block *sb, struct
5343 nfsi->change_attr = 0;
5346 - inode->i_uid = -2;
5347 - inode->i_gid = -2;
5350 inode->i_blocks = 0;
5351 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5353 @@ -359,13 +362,13 @@ nfs_fhget(struct super_block *sb, struct
5354 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5355 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5356 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5357 - inode->i_uid = fattr->uid;
5359 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5360 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5361 | NFS_INO_INVALID_ACCESS
5362 | NFS_INO_INVALID_ACL;
5363 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5364 - inode->i_gid = fattr->gid;
5366 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5367 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5368 | NFS_INO_INVALID_ACCESS
5369 @@ -378,6 +381,11 @@ nfs_fhget(struct super_block *sb, struct
5371 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5373 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5374 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5375 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5376 + /* maybe fattr->xid someday */
5378 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5379 nfsi->attrtimeo_timestamp = now;
5380 nfsi->access_cache = RB_ROOT;
5381 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
5382 inode->i_uid = attr->ia_uid;
5383 if ((attr->ia_valid & ATTR_GID) != 0)
5384 inode->i_gid = attr->ia_gid;
5385 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5386 + inode->i_tag = attr->ia_tag;
5387 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5388 spin_unlock(&inode->i_lock);
5390 @@ -941,6 +951,9 @@ static int nfs_check_inode_attributes(st
5391 struct nfs_inode *nfsi = NFS_I(inode);
5392 loff_t cur_size, new_isize;
5393 unsigned long invalid = 0;
5399 /* Has the inode gone and changed behind our back? */
5400 @@ -964,13 +977,18 @@ static int nfs_check_inode_attributes(st
5401 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5404 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5405 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5406 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5408 /* Have any file permissions changed? */
5409 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5410 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5411 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5412 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5413 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5414 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5415 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5416 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5417 + /* maybe check for tag too? */
5419 /* Has the link count changed? */
5420 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5421 @@ -1205,6 +1223,9 @@ static int nfs_update_inode(struct inode
5422 unsigned long invalid = 0;
5423 unsigned long now = jiffies;
5424 unsigned long save_cache_validity;
5429 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5430 __func__, inode->i_sb->s_id, inode->i_ino,
5431 @@ -1312,6 +1333,9 @@ static int nfs_update_inode(struct inode
5432 | NFS_INO_REVAL_PAGECACHE
5433 | NFS_INO_REVAL_FORCED);
5435 + uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5436 + gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5437 + tag = inode->i_tag;
5439 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5440 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5441 @@ -1333,9 +1357,9 @@ static int nfs_update_inode(struct inode
5442 | NFS_INO_REVAL_FORCED);
5444 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5445 - if (inode->i_uid != fattr->uid) {
5446 + if (uid != fattr->uid) {
5447 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5448 - inode->i_uid = fattr->uid;
5451 } else if (server->caps & NFS_CAP_OWNER)
5452 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5453 @@ -1344,9 +1368,9 @@ static int nfs_update_inode(struct inode
5454 | NFS_INO_REVAL_FORCED);
5456 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5457 - if (inode->i_gid != fattr->gid) {
5458 + if (gid != fattr->gid) {
5459 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5460 - inode->i_gid = fattr->gid;
5463 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5464 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5465 @@ -1354,6 +1378,10 @@ static int nfs_update_inode(struct inode
5466 | NFS_INO_INVALID_ACL
5467 | NFS_INO_REVAL_FORCED);
5469 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5470 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5471 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
5473 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5474 if (inode->i_nlink != fattr->nlink) {
5475 invalid |= NFS_INO_INVALID_ATTR;
5476 diff -NurpP --minimal linux-3.0.25/fs/nfs/nfs3xdr.c linux-3.0.25-vs2.3.2.3/fs/nfs/nfs3xdr.c
5477 --- linux-3.0.25/fs/nfs/nfs3xdr.c 2011-03-15 18:07:32.000000000 +0100
5478 +++ linux-3.0.25-vs2.3.2.3/fs/nfs/nfs3xdr.c 2011-06-10 22:11:24.000000000 +0200
5480 #include <linux/nfs3.h>
5481 #include <linux/nfs_fs.h>
5482 #include <linux/nfsacl.h>
5483 +#include <linux/vs_tag.h>
5484 #include "internal.h"
5486 #define NFSDBG_FACILITY NFSDBG_XDR
5487 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5491 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5492 +static void encode_sattr3(struct xdr_stream *xdr,
5493 + const struct iattr *attr, int tag)
5497 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
5501 - if (attr->ia_valid & ATTR_UID) {
5502 + if (attr->ia_valid & ATTR_UID ||
5503 + (tag && (attr->ia_valid & ATTR_TAG))) {
5505 - *p++ = cpu_to_be32(attr->ia_uid);
5506 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5507 + attr->ia_uid, attr->ia_tag));
5511 - if (attr->ia_valid & ATTR_GID) {
5512 + if (attr->ia_valid & ATTR_GID ||
5513 + (tag && (attr->ia_valid & ATTR_TAG))) {
5515 - *p++ = cpu_to_be32(attr->ia_gid);
5516 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5517 + attr->ia_gid, attr->ia_tag));
5521 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
5522 const struct nfs3_sattrargs *args)
5524 encode_nfs_fh3(xdr, args->fh);
5525 - encode_sattr3(xdr, args->sattr);
5526 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5527 encode_sattrguard3(xdr, args);
5530 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
5533 static void encode_createhow3(struct xdr_stream *xdr,
5534 - const struct nfs3_createargs *args)
5535 + const struct nfs3_createargs *args, int tag)
5537 encode_uint32(xdr, args->createmode);
5538 switch (args->createmode) {
5539 case NFS3_CREATE_UNCHECKED:
5540 case NFS3_CREATE_GUARDED:
5541 - encode_sattr3(xdr, args->sattr);
5542 + encode_sattr3(xdr, args->sattr, tag);
5544 case NFS3_CREATE_EXCLUSIVE:
5545 encode_createverf3(xdr, args->verifier);
5546 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
5547 const struct nfs3_createargs *args)
5549 encode_diropargs3(xdr, args->fh, args->name, args->len);
5550 - encode_createhow3(xdr, args);
5551 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5555 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5556 const struct nfs3_mkdirargs *args)
5558 encode_diropargs3(xdr, args->fh, args->name, args->len);
5559 - encode_sattr3(xdr, args->sattr);
5560 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5564 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5567 static void encode_symlinkdata3(struct xdr_stream *xdr,
5568 - const struct nfs3_symlinkargs *args)
5569 + const struct nfs3_symlinkargs *args, int tag)
5571 - encode_sattr3(xdr, args->sattr);
5572 + encode_sattr3(xdr, args->sattr, tag);
5573 encode_nfspath3(xdr, args->pages, args->pathlen);
5576 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
5577 const struct nfs3_symlinkargs *args)
5579 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5580 - encode_symlinkdata3(xdr, args);
5581 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5585 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
5588 static void encode_devicedata3(struct xdr_stream *xdr,
5589 - const struct nfs3_mknodargs *args)
5590 + const struct nfs3_mknodargs *args, int tag)
5592 - encode_sattr3(xdr, args->sattr);
5593 + encode_sattr3(xdr, args->sattr, tag);
5594 encode_specdata3(xdr, args->rdev);
5597 static void encode_mknoddata3(struct xdr_stream *xdr,
5598 - const struct nfs3_mknodargs *args)
5599 + const struct nfs3_mknodargs *args, int tag)
5601 encode_ftype3(xdr, args->type);
5602 switch (args->type) {
5605 - encode_devicedata3(xdr, args);
5606 + encode_devicedata3(xdr, args, tag);
5610 - encode_sattr3(xdr, args->sattr);
5611 + encode_sattr3(xdr, args->sattr, tag);
5615 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5616 const struct nfs3_mknodargs *args)
5618 encode_diropargs3(xdr, args->fh, args->name, args->len);
5619 - encode_mknoddata3(xdr, args);
5620 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5624 diff -NurpP --minimal linux-3.0.25/fs/nfs/super.c linux-3.0.25-vs2.3.2.3/fs/nfs/super.c
5625 --- linux-3.0.25/fs/nfs/super.c 2012-03-19 21:16:52.000000000 +0100
5626 +++ linux-3.0.25-vs2.3.2.3/fs/nfs/super.c 2012-01-26 08:39:53.000000000 +0100
5628 #include <linux/nfs_xdr.h>
5629 #include <linux/magic.h>
5630 #include <linux/parser.h>
5631 +#include <linux/vs_tag.h>
5633 #include <asm/system.h>
5634 #include <asm/uaccess.h>
5635 @@ -87,6 +88,7 @@ enum {
5636 Opt_sharecache, Opt_nosharecache,
5637 Opt_resvport, Opt_noresvport,
5638 Opt_fscache, Opt_nofscache,
5639 + Opt_tag, Opt_notag,
5641 /* Mount options that take integer arguments */
5643 @@ -100,6 +102,7 @@ enum {
5649 /* Mount options that take string arguments */
5650 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
5651 @@ -180,6 +183,10 @@ static const match_table_t nfs_mount_opt
5652 { Opt_fscache_uniq, "fsc=%s" },
5653 { Opt_local_lock, "local_lock=%s" },
5655 + { Opt_tag, "tag" },
5656 + { Opt_notag, "notag" },
5657 + { Opt_tagid, "tagid=%u" },
5662 @@ -650,6 +657,7 @@ static void nfs_show_mount_options(struc
5663 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5664 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5665 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5666 + { NFS_MOUNT_TAGGED, ",tag", "" },
5669 const struct proc_nfs_info *nfs_infop;
5670 @@ -1212,6 +1220,14 @@ static int nfs_parse_mount_options(char
5671 kfree(mnt->fscache_uniq);
5672 mnt->fscache_uniq = NULL;
5674 +#ifndef CONFIG_TAGGING_NONE
5676 + mnt->flags |= NFS_MOUNT_TAGGED;
5679 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5684 * options that take numeric values
5685 @@ -1318,6 +1334,12 @@ static int nfs_parse_mount_options(char
5686 goto out_invalid_value;
5687 mnt->minorversion = option;
5689 +#ifdef CONFIG_PROPAGATE
5692 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5697 * options that take text values
5698 diff -NurpP --minimal linux-3.0.25/fs/nfsd/auth.c linux-3.0.25-vs2.3.2.3/fs/nfsd/auth.c
5699 --- linux-3.0.25/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
5700 +++ linux-3.0.25-vs2.3.2.3/fs/nfsd/auth.c 2011-06-10 22:11:24.000000000 +0200
5702 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
5704 #include <linux/sched.h>
5705 +#include <linux/vs_tag.h>
5709 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5711 new->fsuid = rqstp->rq_cred.cr_uid;
5712 new->fsgid = rqstp->rq_cred.cr_gid;
5713 + /* FIXME: this desperately needs a tag :)
5714 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5717 rqgi = rqstp->rq_cred.cr_group_info;
5719 diff -NurpP --minimal linux-3.0.25/fs/nfsd/nfs3xdr.c linux-3.0.25-vs2.3.2.3/fs/nfsd/nfs3xdr.c
5720 --- linux-3.0.25/fs/nfsd/nfs3xdr.c 2011-07-22 11:18:05.000000000 +0200
5721 +++ linux-3.0.25-vs2.3.2.3/fs/nfsd/nfs3xdr.c 2011-06-10 22:11:24.000000000 +0200
5725 #include <linux/namei.h>
5726 +#include <linux/vs_tag.h>
5730 @@ -95,6 +96,8 @@ static __be32 *
5731 decode_sattr3(__be32 *p, struct iattr *iap)
5739 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
5742 iap->ia_valid |= ATTR_UID;
5743 - iap->ia_uid = ntohl(*p++);
5744 + uid = ntohl(*p++);
5747 iap->ia_valid |= ATTR_GID;
5748 - iap->ia_gid = ntohl(*p++);
5749 + gid = ntohl(*p++);
5751 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5752 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5753 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5757 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5758 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5759 *p++ = htonl((u32) stat->mode);
5760 *p++ = htonl((u32) stat->nlink);
5761 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5762 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5763 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5764 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5765 + stat->uid, stat->tag)));
5766 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5767 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5768 + stat->gid, stat->tag)));
5769 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5770 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5772 diff -NurpP --minimal linux-3.0.25/fs/nfsd/nfs4xdr.c linux-3.0.25-vs2.3.2.3/fs/nfsd/nfs4xdr.c
5773 --- linux-3.0.25/fs/nfsd/nfs4xdr.c 2012-03-19 21:16:52.000000000 +0100
5774 +++ linux-3.0.25-vs2.3.2.3/fs/nfsd/nfs4xdr.c 2011-11-15 17:37:07.000000000 +0100
5776 #include <linux/statfs.h>
5777 #include <linux/utsname.h>
5778 #include <linux/sunrpc/svcauth_gss.h>
5779 +#include <linux/vs_tag.h>
5783 @@ -2102,14 +2103,18 @@ out_acl:
5784 WRITE32(stat.nlink);
5786 if (bmval1 & FATTR4_WORD1_OWNER) {
5787 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5788 + status = nfsd4_encode_user(rqstp,
5789 + TAGINO_UID(DX_TAG(dentry->d_inode),
5790 + stat.uid, stat.tag), &p, &buflen);
5791 if (status == nfserr_resource)
5796 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5797 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5798 + status = nfsd4_encode_group(rqstp,
5799 + TAGINO_GID(DX_TAG(dentry->d_inode),
5800 + stat.gid, stat.tag), &p, &buflen);
5801 if (status == nfserr_resource)
5804 diff -NurpP --minimal linux-3.0.25/fs/nfsd/nfsxdr.c linux-3.0.25-vs2.3.2.3/fs/nfsd/nfsxdr.c
5805 --- linux-3.0.25/fs/nfsd/nfsxdr.c 2011-05-22 16:17:53.000000000 +0200
5806 +++ linux-3.0.25-vs2.3.2.3/fs/nfsd/nfsxdr.c 2011-06-10 22:11:24.000000000 +0200
5811 +#include <linux/vs_tag.h>
5813 #define NFSDDBG_FACILITY NFSDDBG_XDR
5815 @@ -88,6 +89,8 @@ static __be32 *
5816 decode_sattr(__be32 *p, struct iattr *iap)
5824 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
5826 if ((tmp = ntohl(*p++)) != (u32)-1) {
5827 iap->ia_valid |= ATTR_UID;
5828 - iap->ia_uid = tmp;
5831 if ((tmp = ntohl(*p++)) != (u32)-1) {
5832 iap->ia_valid |= ATTR_GID;
5833 - iap->ia_gid = tmp;
5836 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5837 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5838 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5839 if ((tmp = ntohl(*p++)) != (u32)-1) {
5840 iap->ia_valid |= ATTR_SIZE;
5842 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5843 *p++ = htonl(nfs_ftypes[type >> 12]);
5844 *p++ = htonl((u32) stat->mode);
5845 *p++ = htonl((u32) stat->nlink);
5846 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5847 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5848 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5849 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5850 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5851 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5853 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5854 *p++ = htonl(NFS_MAXPATHLEN);
5855 diff -NurpP --minimal linux-3.0.25/fs/ocfs2/dlmglue.c linux-3.0.25-vs2.3.2.3/fs/ocfs2/dlmglue.c
5856 --- linux-3.0.25/fs/ocfs2/dlmglue.c 2011-05-22 16:17:53.000000000 +0200
5857 +++ linux-3.0.25-vs2.3.2.3/fs/ocfs2/dlmglue.c 2011-06-10 22:11:24.000000000 +0200
5858 @@ -2041,6 +2041,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5859 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5860 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
5861 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
5862 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
5863 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5864 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5865 lvb->lvb_iatime_packed =
5866 @@ -2091,6 +2092,7 @@ static void ocfs2_refresh_inode_from_lvb
5868 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
5869 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
5870 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
5871 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5872 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
5873 ocfs2_unpack_timespec(&inode->i_atime,
5874 diff -NurpP --minimal linux-3.0.25/fs/ocfs2/dlmglue.h linux-3.0.25-vs2.3.2.3/fs/ocfs2/dlmglue.h
5875 --- linux-3.0.25/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
5876 +++ linux-3.0.25-vs2.3.2.3/fs/ocfs2/dlmglue.h 2011-06-10 22:11:24.000000000 +0200
5877 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5880 __be32 lvb_igeneration;
5881 - __be32 lvb_reserved2;
5883 + __be16 lvb_reserved2;
5886 #define OCFS2_QINFO_LVB_VERSION 1
5887 diff -NurpP --minimal linux-3.0.25/fs/ocfs2/file.c linux-3.0.25-vs2.3.2.3/fs/ocfs2/file.c
5888 --- linux-3.0.25/fs/ocfs2/file.c 2011-07-22 11:18:06.000000000 +0200
5889 +++ linux-3.0.25-vs2.3.2.3/fs/ocfs2/file.c 2011-06-10 22:43:33.000000000 +0200
5890 @@ -1111,7 +1111,7 @@ int ocfs2_setattr(struct dentry *dentry,
5891 attr->ia_valid &= ~ATTR_SIZE;
5893 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5894 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5895 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5896 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5899 diff -NurpP --minimal linux-3.0.25/fs/ocfs2/inode.c linux-3.0.25-vs2.3.2.3/fs/ocfs2/inode.c
5900 --- linux-3.0.25/fs/ocfs2/inode.c 2011-05-22 16:17:53.000000000 +0200
5901 +++ linux-3.0.25-vs2.3.2.3/fs/ocfs2/inode.c 2011-06-10 22:11:24.000000000 +0200
5903 #include <linux/highmem.h>
5904 #include <linux/pagemap.h>
5905 #include <linux/quotaops.h>
5906 +#include <linux/vs_tag.h>
5908 #include <asm/byteorder.h>
5910 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5912 unsigned int flags = OCFS2_I(inode)->ip_attr;
5914 - inode->i_flags &= ~(S_IMMUTABLE |
5915 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5916 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5918 if (flags & OCFS2_IMMUTABLE_FL)
5919 inode->i_flags |= S_IMMUTABLE;
5920 + if (flags & OCFS2_IXUNLINK_FL)
5921 + inode->i_flags |= S_IXUNLINK;
5923 if (flags & OCFS2_SYNC_FL)
5924 inode->i_flags |= S_SYNC;
5925 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5926 inode->i_flags |= S_NOATIME;
5927 if (flags & OCFS2_DIRSYNC_FL)
5928 inode->i_flags |= S_DIRSYNC;
5930 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5932 + if (flags & OCFS2_BARRIER_FL)
5933 + inode->i_vflags |= V_BARRIER;
5934 + if (flags & OCFS2_COW_FL)
5935 + inode->i_vflags |= V_COW;
5938 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5939 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5941 unsigned int flags = oi->vfs_inode.i_flags;
5942 + unsigned int vflags = oi->vfs_inode.i_vflags;
5944 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5945 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5946 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5947 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5949 + if (flags & S_IMMUTABLE)
5950 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5951 + if (flags & S_IXUNLINK)
5952 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5954 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5955 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5957 oi->ip_attr |= OCFS2_SYNC_FL;
5958 if (flags & S_APPEND)
5959 oi->ip_attr |= OCFS2_APPEND_FL;
5960 - if (flags & S_IMMUTABLE)
5961 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5962 if (flags & S_NOATIME)
5963 oi->ip_attr |= OCFS2_NOATIME_FL;
5964 if (flags & S_DIRSYNC)
5965 oi->ip_attr |= OCFS2_DIRSYNC_FL;
5967 + if (vflags & V_BARRIER)
5968 + oi->ip_attr |= OCFS2_BARRIER_FL;
5969 + if (vflags & V_COW)
5970 + oi->ip_attr |= OCFS2_COW_FL;
5973 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
5974 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
5975 struct super_block *sb;
5976 struct ocfs2_super *osb;
5983 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
5984 inode->i_generation = le32_to_cpu(fe->i_generation);
5985 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
5986 inode->i_mode = le16_to_cpu(fe->i_mode);
5987 - inode->i_uid = le32_to_cpu(fe->i_uid);
5988 - inode->i_gid = le32_to_cpu(fe->i_gid);
5989 + uid = le32_to_cpu(fe->i_uid);
5990 + gid = le32_to_cpu(fe->i_gid);
5991 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5992 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5993 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5994 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
5996 /* Fast symlinks will have i_size but no allocated clusters. */
5997 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
5998 diff -NurpP --minimal linux-3.0.25/fs/ocfs2/inode.h linux-3.0.25-vs2.3.2.3/fs/ocfs2/inode.h
5999 --- linux-3.0.25/fs/ocfs2/inode.h 2011-01-05 21:50:26.000000000 +0100
6000 +++ linux-3.0.25-vs2.3.2.3/fs/ocfs2/inode.h 2011-06-10 22:11:24.000000000 +0200
6001 @@ -151,6 +151,7 @@ struct buffer_head *ocfs2_bread(struct i
6003 void ocfs2_set_inode_flags(struct inode *inode);
6004 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6005 +int ocfs2_sync_flags(struct inode *inode, int, int);
6007 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6009 diff -NurpP --minimal linux-3.0.25/fs/ocfs2/ioctl.c linux-3.0.25-vs2.3.2.3/fs/ocfs2/ioctl.c
6010 --- linux-3.0.25/fs/ocfs2/ioctl.c 2011-07-22 11:18:06.000000000 +0200
6011 +++ linux-3.0.25-vs2.3.2.3/fs/ocfs2/ioctl.c 2011-06-10 22:11:24.000000000 +0200
6012 @@ -78,7 +78,41 @@ static int ocfs2_get_inode_attr(struct i
6016 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6017 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6019 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6020 + struct buffer_head *bh = NULL;
6021 + handle_t *handle = NULL;
6024 + status = ocfs2_inode_lock(inode, &bh, 1);
6026 + mlog_errno(status);
6029 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6030 + if (IS_ERR(handle)) {
6031 + status = PTR_ERR(handle);
6032 + mlog_errno(status);
6036 + inode->i_flags = flags;
6037 + inode->i_vflags = vflags;
6038 + ocfs2_get_inode_flags(OCFS2_I(inode));
6040 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6042 + mlog_errno(status);
6044 + ocfs2_commit_trans(osb, handle);
6046 + ocfs2_inode_unlock(inode, 1);
6051 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6054 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6055 @@ -103,6 +137,11 @@ static int ocfs2_set_inode_attr(struct i
6056 if (!S_ISDIR(inode->i_mode))
6057 flags &= ~OCFS2_DIRSYNC_FL;
6059 + if (IS_BARRIER(inode)) {
6060 + vxwprintk_task(1, "messing with the barrier.");
6064 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6065 if (IS_ERR(handle)) {
6066 status = PTR_ERR(handle);
6067 @@ -880,6 +919,7 @@ bail:
6072 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6074 struct inode *inode = filp->f_path.dentry->d_inode;
6075 diff -NurpP --minimal linux-3.0.25/fs/ocfs2/namei.c linux-3.0.25-vs2.3.2.3/fs/ocfs2/namei.c
6076 --- linux-3.0.25/fs/ocfs2/namei.c 2011-05-22 16:17:53.000000000 +0200
6077 +++ linux-3.0.25-vs2.3.2.3/fs/ocfs2/namei.c 2011-06-10 22:11:24.000000000 +0200
6079 #include <linux/slab.h>
6080 #include <linux/highmem.h>
6081 #include <linux/quotaops.h>
6082 +#include <linux/vs_tag.h>
6084 #include <cluster/masklog.h>
6086 @@ -477,6 +478,7 @@ static int __ocfs2_mknod_locked(struct i
6087 struct ocfs2_dinode *fe = NULL;
6088 struct ocfs2_extent_list *fel;
6094 @@ -514,8 +516,11 @@ static int __ocfs2_mknod_locked(struct i
6095 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
6096 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6097 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6098 - fe->i_uid = cpu_to_le32(inode->i_uid);
6099 - fe->i_gid = cpu_to_le32(inode->i_gid);
6101 + tag = dx_current_fstag(osb->sb);
6102 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6103 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6104 + inode->i_tag = tag;
6105 fe->i_mode = cpu_to_le16(inode->i_mode);
6106 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6107 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6108 diff -NurpP --minimal linux-3.0.25/fs/ocfs2/ocfs2.h linux-3.0.25-vs2.3.2.3/fs/ocfs2/ocfs2.h
6109 --- linux-3.0.25/fs/ocfs2/ocfs2.h 2011-05-22 16:17:53.000000000 +0200
6110 +++ linux-3.0.25-vs2.3.2.3/fs/ocfs2/ocfs2.h 2011-06-10 22:11:24.000000000 +0200
6111 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
6113 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
6114 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
6115 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
6118 #define OCFS2_OSB_SOFT_RO 0x0001
6119 diff -NurpP --minimal linux-3.0.25/fs/ocfs2/ocfs2_fs.h linux-3.0.25-vs2.3.2.3/fs/ocfs2/ocfs2_fs.h
6120 --- linux-3.0.25/fs/ocfs2/ocfs2_fs.h 2011-05-22 16:17:53.000000000 +0200
6121 +++ linux-3.0.25-vs2.3.2.3/fs/ocfs2/ocfs2_fs.h 2011-06-10 22:11:24.000000000 +0200
6122 @@ -266,6 +266,11 @@
6123 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
6124 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
6126 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6128 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6129 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6131 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
6132 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
6134 diff -NurpP --minimal linux-3.0.25/fs/ocfs2/super.c linux-3.0.25-vs2.3.2.3/fs/ocfs2/super.c
6135 --- linux-3.0.25/fs/ocfs2/super.c 2011-07-22 11:18:06.000000000 +0200
6136 +++ linux-3.0.25-vs2.3.2.3/fs/ocfs2/super.c 2011-06-15 02:40:14.000000000 +0200
6137 @@ -184,6 +184,7 @@ enum {
6141 + Opt_tag, Opt_notag, Opt_tagid,
6145 @@ -215,6 +216,9 @@ static const match_table_t tokens = {
6146 {Opt_coherency_full, "coherency=full"},
6147 {Opt_resv_level, "resv_level=%u"},
6148 {Opt_dir_resv_level, "dir_resv_level=%u"},
6150 + {Opt_notag, "notag"},
6151 + {Opt_tagid, "tagid=%u"},
6155 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
6159 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6160 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6162 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6166 /* We're going to/from readonly mode. */
6167 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
6168 /* Disable quota accounting before remounting RO */
6169 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
6171 ocfs2_complete_mount_recovery(osb);
6173 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6174 + sb->s_flags |= MS_TAGGED;
6176 if (ocfs2_mount_local(osb))
6177 snprintf(nodestr, sizeof(nodestr), "local");
6179 @@ -1506,6 +1520,20 @@ static int ocfs2_parse_options(struct su
6180 option < OCFS2_MAX_RESV_LEVEL)
6181 mopt->dir_resv_level = option;
6183 +#ifndef CONFIG_TAGGING_NONE
6185 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6188 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6191 +#ifdef CONFIG_PROPAGATE
6194 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6199 "Unrecognized mount option \"%s\" "
6200 diff -NurpP --minimal linux-3.0.25/fs/open.c linux-3.0.25-vs2.3.2.3/fs/open.c
6201 --- linux-3.0.25/fs/open.c 2011-05-22 16:17:53.000000000 +0200
6202 +++ linux-3.0.25-vs2.3.2.3/fs/open.c 2011-06-10 22:11:24.000000000 +0200
6204 #include <linux/fs_struct.h>
6205 #include <linux/ima.h>
6206 #include <linux/dnotify.h>
6207 +#include <linux/vs_base.h>
6208 +#include <linux/vs_limit.h>
6209 +#include <linux/vs_tag.h>
6210 +#include <linux/vs_cowbl.h>
6211 +#include <linux/vserver/dlimit.h>
6213 #include "internal.h"
6215 @@ -494,6 +499,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6216 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6220 +#ifdef CONFIG_VSERVER_COWBL
6221 + error = cow_check_and_break(&path);
6223 + goto dput_and_out;
6225 inode = path.dentry->d_inode;
6227 error = mnt_want_write(path.mnt);
6228 @@ -531,11 +542,11 @@ static int chown_common(struct path *pat
6229 newattrs.ia_valid = ATTR_CTIME;
6230 if (user != (uid_t) -1) {
6231 newattrs.ia_valid |= ATTR_UID;
6232 - newattrs.ia_uid = user;
6233 + newattrs.ia_uid = dx_map_uid(user);
6235 if (group != (gid_t) -1) {
6236 newattrs.ia_valid |= ATTR_GID;
6237 - newattrs.ia_gid = group;
6238 + newattrs.ia_gid = dx_map_gid(group);
6240 if (!S_ISDIR(inode->i_mode))
6241 newattrs.ia_valid |=
6242 @@ -560,6 +571,10 @@ SYSCALL_DEFINE3(chown, const char __user
6243 error = mnt_want_write(path.mnt);
6246 +#ifdef CONFIG_VSERVER_COWBL
6247 + error = cow_check_and_break(&path);
6250 error = chown_common(&path, user, group);
6251 mnt_drop_write(path.mnt);
6253 @@ -587,6 +602,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6254 error = mnt_want_write(path.mnt);
6257 +#ifdef CONFIG_VSERVER_COWBL
6258 + error = cow_check_and_break(&path);
6261 error = chown_common(&path, user, group);
6262 mnt_drop_write(path.mnt);
6264 @@ -606,6 +625,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6265 error = mnt_want_write(path.mnt);
6268 +#ifdef CONFIG_VSERVER_COWBL
6269 + error = cow_check_and_break(&path);
6272 error = chown_common(&path, user, group);
6273 mnt_drop_write(path.mnt);
6275 @@ -857,6 +880,7 @@ static void __put_unused_fd(struct files
6276 __FD_CLR(fd, fdt->open_fds);
6277 if (fd < files->next_fd)
6278 files->next_fd = fd;
6279 + vx_openfd_dec(fd);
6282 void put_unused_fd(unsigned int fd)
6283 diff -NurpP --minimal linux-3.0.25/fs/proc/array.c linux-3.0.25-vs2.3.2.3/fs/proc/array.c
6284 --- linux-3.0.25/fs/proc/array.c 2011-07-22 11:18:06.000000000 +0200
6285 +++ linux-3.0.25-vs2.3.2.3/fs/proc/array.c 2011-06-10 22:11:24.000000000 +0200
6287 #include <linux/pid_namespace.h>
6288 #include <linux/ptrace.h>
6289 #include <linux/tracehook.h>
6290 +#include <linux/vs_context.h>
6291 +#include <linux/vs_network.h>
6293 #include <asm/pgtable.h>
6294 #include <asm/processor.h>
6295 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6297 ppid = pid_alive(p) ?
6298 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6299 + if (unlikely(vx_current_initpid(p->pid)))
6304 struct task_struct *tracer = tracehook_tracer_task(p);
6305 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6308 static void render_cap_t(struct seq_file *m, const char *header,
6310 + struct vx_info *vxi, kernel_cap_t *a)
6314 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6315 cap_bset = cred->cap_bset;
6318 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6319 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6320 - render_cap_t(m, "CapEff:\t", &cap_effective);
6321 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6322 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6323 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6324 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6325 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6326 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6329 static inline void task_context_switch_counts(struct seq_file *m,
6330 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6334 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6335 + struct pid *pid, struct task_struct *task)
6337 + seq_printf(m, "Proxy:\t%p(%c)\n"
6345 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6346 + atomic_read(&task->nsproxy->count),
6347 + task->nsproxy->uts_ns,
6348 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6349 + task->nsproxy->ipc_ns,
6350 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6351 + task->nsproxy->mnt_ns,
6352 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6353 + task->nsproxy->pid_ns,
6354 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6355 + task->nsproxy->net_ns,
6356 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6360 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6362 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6365 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6366 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6370 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6371 struct pid *pid, struct task_struct *task)
6373 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6375 task_cpus_allowed(m, task);
6376 cpuset_task_status_allowed(m, task);
6377 + task_vs_id(m, task);
6378 task_context_switch_counts(m, task);
6381 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file
6382 /* convert nsec -> ticks */
6383 start_time = nsec_to_clock_t(start_time);
6385 + /* fixup start time for virt uptime */
6386 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6387 + unsigned long long bias =
6388 + current->vx_info->cvirt.bias_clock;
6390 + if (start_time > bias)
6391 + start_time -= bias;
6396 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6397 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6398 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6399 diff -NurpP --minimal linux-3.0.25/fs/proc/base.c linux-3.0.25-vs2.3.2.3/fs/proc/base.c
6400 --- linux-3.0.25/fs/proc/base.c 2012-03-19 21:16:52.000000000 +0100
6401 +++ linux-3.0.25-vs2.3.2.3/fs/proc/base.c 2012-02-15 05:20:43.000000000 +0100
6403 #include <linux/pid_namespace.h>
6404 #include <linux/fs_struct.h>
6405 #include <linux/slab.h>
6406 +#include <linux/vs_context.h>
6407 +#include <linux/vs_network.h>
6408 #ifdef CONFIG_HARDWALL
6409 #include <asm/hardwall.h>
6411 @@ -1021,11 +1023,16 @@ static ssize_t oom_adjust_write(struct f
6415 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6416 + if (oom_adjust < task->signal->oom_adj &&
6417 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6422 + /* prevent guest processes from circumventing the oom killer */
6423 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6424 + oom_adjust = OOM_ADJUST_MIN;
6426 if (oom_adjust != task->signal->oom_adj) {
6427 if (oom_adjust == OOM_DISABLE)
6428 atomic_inc(&task->mm->oom_disable_count);
6429 @@ -1194,7 +1201,7 @@ static ssize_t proc_loginuid_write(struc
6433 - if (!capable(CAP_AUDIT_CONTROL))
6434 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6438 @@ -1641,6 +1648,8 @@ struct inode *proc_pid_make_inode(struct
6439 inode->i_gid = cred->egid;
6442 + /* procfs is xid tagged */
6443 + inode->i_tag = (tag_t)vx_task_xid(task);
6444 security_task_to_inode(task, inode);
6447 @@ -1677,6 +1686,8 @@ int pid_getattr(struct vfsmount *mnt, st
6451 +static unsigned name_to_int(struct dentry *dentry);
6454 * Exceptional case: normally we are not allowed to unhash a busy
6455 * directory. In this case, however, we can do it - no aliasing problems
6456 @@ -1705,6 +1716,12 @@ int pid_revalidate(struct dentry *dentry
6457 task = get_proc_task(inode);
6460 + unsigned pid = name_to_int(dentry);
6462 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6463 + put_task_struct(task);
6466 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6467 task_dumpable(task)) {
6469 @@ -1721,6 +1738,7 @@ int pid_revalidate(struct dentry *dentry
6470 put_task_struct(task);
6477 @@ -2210,6 +2228,13 @@ static struct dentry *proc_pident_lookup
6481 + /* TODO: maybe we can come up with a generic approach? */
6482 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6483 + (dentry->d_name.len == 5) &&
6484 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6485 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6489 * Yes, it does not scale. And it should not. Don't add
6490 * new entries into /proc/<tgid>/ without very good reasons.
6491 @@ -2595,7 +2620,7 @@ out_iput:
6492 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6494 struct dentry *error;
6495 - struct task_struct *task = get_proc_task(dir);
6496 + struct task_struct *task = get_proc_task_real(dir);
6497 const struct pid_entry *p, *last;
6499 error = ERR_PTR(-ENOENT);
6500 @@ -2702,6 +2727,9 @@ static int proc_pid_personality(struct s
6501 static const struct file_operations proc_task_operations;
6502 static const struct inode_operations proc_task_inode_operations;
6504 +extern int proc_pid_vx_info(struct task_struct *, char *);
6505 +extern int proc_pid_nx_info(struct task_struct *, char *);
6507 static const struct pid_entry tgid_base_stuff[] = {
6508 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6509 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6510 @@ -2765,6 +2793,8 @@ static const struct pid_entry tgid_base_
6511 #ifdef CONFIG_CGROUPS
6512 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6514 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6515 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6516 INF("oom_score", S_IRUGO, proc_oom_score),
6517 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6518 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6519 @@ -2784,6 +2814,7 @@ static const struct pid_entry tgid_base_
6520 #ifdef CONFIG_HARDWALL
6521 INF("hardwall", S_IRUGO, proc_pid_hardwall),
6523 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6526 static int proc_tgid_base_readdir(struct file * filp,
6527 @@ -2976,7 +3007,7 @@ retry:
6529 pid = find_ge_pid(iter.tgid, ns);
6531 - iter.tgid = pid_nr_ns(pid, ns);
6532 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6533 iter.task = pid_task(pid, PIDTYPE_PID);
6534 /* What we to know is if the pid we have find is the
6535 * pid of a thread_group_leader. Testing for task
6536 @@ -3006,7 +3037,7 @@ static int proc_pid_fill_cache(struct fi
6537 struct tgid_iter iter)
6539 char name[PROC_NUMBUF];
6540 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6541 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6542 return proc_fill_cache(filp, dirent, filldir, name, len,
6543 proc_pid_instantiate, iter.task, NULL);
6545 @@ -3023,7 +3054,7 @@ int proc_pid_readdir(struct file * filp,
6547 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6549 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
6550 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6554 @@ -3040,6 +3071,8 @@ int proc_pid_readdir(struct file * filp,
6556 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6557 filp->f_pos = iter.tgid + TGID_OFFSET;
6558 + if (!vx_proc_task_visible(iter.task))
6560 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6561 put_task_struct(iter.task);
6563 @@ -3193,6 +3226,8 @@ static struct dentry *proc_task_lookup(s
6564 tid = name_to_int(dentry);
6567 + if (vx_current_initpid(tid))
6570 ns = dentry->d_sb->s_fs_info;
6572 diff -NurpP --minimal linux-3.0.25/fs/proc/generic.c linux-3.0.25-vs2.3.2.3/fs/proc/generic.c
6573 --- linux-3.0.25/fs/proc/generic.c 2011-07-22 11:18:06.000000000 +0200
6574 +++ linux-3.0.25-vs2.3.2.3/fs/proc/generic.c 2011-06-10 22:11:24.000000000 +0200
6576 #include <linux/bitops.h>
6577 #include <linux/spinlock.h>
6578 #include <linux/completion.h>
6579 +#include <linux/vserver/inode.h>
6580 #include <asm/uaccess.h>
6582 #include "internal.h"
6583 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
6584 for (de = de->subdir; de ; de = de->next) {
6585 if (de->namelen != dentry->d_name.len)
6587 + if (!vx_hide_check(0, de->vx_flags))
6589 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6591 spin_unlock(&proc_subdir_lock);
6593 inode = proc_get_inode(dir->i_sb, de);
6594 + /* generic proc entries belong to the host */
6599 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
6601 /* filldir passes info to user space */
6603 + if (!vx_hide_check(0, de->vx_flags))
6605 spin_unlock(&proc_subdir_lock);
6606 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6607 de->low_ino, de->mode >> 12) < 0) {
6608 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
6611 spin_lock(&proc_subdir_lock);
6616 @@ -627,6 +635,7 @@ static struct proc_dir_entry *__proc_cre
6618 atomic_set(&ent->count, 1);
6620 + ent->vx_flags = IATTR_PROC_DEFAULT;
6621 spin_lock_init(&ent->pde_unload_lock);
6622 ent->pde_unload_completion = NULL;
6623 INIT_LIST_HEAD(&ent->pde_openers);
6624 @@ -650,7 +659,8 @@ struct proc_dir_entry *proc_symlink(cons
6630 + ent->vx_flags = IATTR_PROC_SYMLINK;
6634 diff -NurpP --minimal linux-3.0.25/fs/proc/inode.c linux-3.0.25-vs2.3.2.3/fs/proc/inode.c
6635 --- linux-3.0.25/fs/proc/inode.c 2011-07-22 11:18:06.000000000 +0200
6636 +++ linux-3.0.25-vs2.3.2.3/fs/proc/inode.c 2011-06-10 22:11:24.000000000 +0200
6637 @@ -442,6 +442,8 @@ struct inode *proc_get_inode(struct supe
6638 inode->i_uid = de->uid;
6639 inode->i_gid = de->gid;
6642 + PROC_I(inode)->vx_flags = de->vx_flags;
6644 inode->i_size = de->size;
6646 diff -NurpP --minimal linux-3.0.25/fs/proc/internal.h linux-3.0.25-vs2.3.2.3/fs/proc/internal.h
6647 --- linux-3.0.25/fs/proc/internal.h 2011-07-22 11:18:06.000000000 +0200
6648 +++ linux-3.0.25-vs2.3.2.3/fs/proc/internal.h 2011-06-10 22:11:24.000000000 +0200
6652 #include <linux/proc_fs.h>
6653 +#include <linux/vs_pid.h>
6655 extern struct proc_dir_entry proc_root;
6656 #ifdef CONFIG_PROC_SYSCTL
6657 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
6658 struct pid *pid, struct task_struct *task);
6659 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6660 struct pid *pid, struct task_struct *task);
6661 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6662 + struct pid *pid, struct task_struct *task);
6664 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6666 extern const struct file_operations proc_maps_operations;
6667 @@ -76,11 +80,16 @@ static inline struct pid *proc_pid(struc
6668 return PROC_I(inode)->pid;
6671 -static inline struct task_struct *get_proc_task(struct inode *inode)
6672 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6674 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6677 +static inline struct task_struct *get_proc_task(struct inode *inode)
6679 + return vx_get_proc_task(inode, proc_pid(inode));
6682 static inline int proc_fd(struct inode *inode)
6684 return PROC_I(inode)->fd;
6685 diff -NurpP --minimal linux-3.0.25/fs/proc/loadavg.c linux-3.0.25-vs2.3.2.3/fs/proc/loadavg.c
6686 --- linux-3.0.25/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
6687 +++ linux-3.0.25-vs2.3.2.3/fs/proc/loadavg.c 2011-06-10 22:11:24.000000000 +0200
6690 static int loadavg_proc_show(struct seq_file *m, void *v)
6692 + unsigned long running;
6693 + unsigned int threads;
6694 unsigned long avnrun[3];
6696 get_avenrun(avnrun, FIXED_1/200, 0);
6698 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6699 + struct vx_info *vxi = current_vx_info();
6701 + running = atomic_read(&vxi->cvirt.nr_running);
6702 + threads = atomic_read(&vxi->cvirt.nr_threads);
6704 + running = nr_running();
6705 + threads = nr_threads;
6708 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6709 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6710 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6711 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6712 - nr_running(), nr_threads,
6714 task_active_pid_ns(current)->last_pid);
6717 diff -NurpP --minimal linux-3.0.25/fs/proc/meminfo.c linux-3.0.25-vs2.3.2.3/fs/proc/meminfo.c
6718 --- linux-3.0.25/fs/proc/meminfo.c 2012-03-19 21:16:52.000000000 +0100
6719 +++ linux-3.0.25-vs2.3.2.3/fs/proc/meminfo.c 2011-12-23 16:09:00.000000000 +0100
6720 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6721 allowed = ((totalram_pages - hugetlb_total_pages())
6722 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6724 - cached = global_page_state(NR_FILE_PAGES) -
6725 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6726 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6727 total_swapcache_pages - i.bufferram;
6730 diff -NurpP --minimal linux-3.0.25/fs/proc/root.c linux-3.0.25-vs2.3.2.3/fs/proc/root.c
6731 --- linux-3.0.25/fs/proc/root.c 2011-07-22 11:18:06.000000000 +0200
6732 +++ linux-3.0.25-vs2.3.2.3/fs/proc/root.c 2011-06-22 12:39:15.000000000 +0200
6734 #include <linux/bitops.h>
6735 #include <linux/mount.h>
6736 #include <linux/pid_namespace.h>
6737 +#include <linux/vserver/inode.h>
6739 #include "internal.h"
6741 +struct proc_dir_entry *proc_virtual;
6743 +extern void proc_vx_init(void);
6745 static int proc_test_super(struct super_block *sb, void *data)
6747 return sb->s_fs_info == data;
6748 @@ -125,6 +130,7 @@ void __init proc_root_init(void)
6750 proc_mkdir("bus", NULL);
6755 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6756 @@ -193,6 +199,7 @@ struct proc_dir_entry proc_root = {
6757 .proc_iops = &proc_root_inode_operations,
6758 .proc_fops = &proc_root_operations,
6759 .parent = &proc_root,
6760 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6763 int pid_ns_prepare_proc(struct pid_namespace *ns)
6764 diff -NurpP --minimal linux-3.0.25/fs/proc/uptime.c linux-3.0.25-vs2.3.2.3/fs/proc/uptime.c
6765 --- linux-3.0.25/fs/proc/uptime.c 2012-03-19 21:16:52.000000000 +0100
6766 +++ linux-3.0.25-vs2.3.2.3/fs/proc/uptime.c 2012-01-26 08:56:00.000000000 +0100
6768 #include <linux/seq_file.h>
6769 #include <linux/time.h>
6770 #include <linux/kernel_stat.h>
6771 +#include <linux/vserver/cvirt.h>
6772 #include <asm/cputime.h>
6774 static int uptime_proc_show(struct seq_file *m, void *v)
6775 @@ -25,6 +26,10 @@ static int uptime_proc_show(struct seq_f
6776 nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
6777 idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
6780 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6781 + vx_vsi_uptime(&uptime, &idle);
6783 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6784 (unsigned long) uptime.tv_sec,
6785 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6786 diff -NurpP --minimal linux-3.0.25/fs/quota/dquot.c linux-3.0.25-vs2.3.2.3/fs/quota/dquot.c
6787 --- linux-3.0.25/fs/quota/dquot.c 2011-07-22 11:18:06.000000000 +0200
6788 +++ linux-3.0.25-vs2.3.2.3/fs/quota/dquot.c 2011-06-10 22:11:24.000000000 +0200
6789 @@ -1548,6 +1548,9 @@ int __dquot_alloc_space(struct inode *in
6790 int reserve = flags & DQUOT_SPACE_RESERVE;
6791 int nofail = flags & DQUOT_SPACE_NOFAIL;
6793 + if ((ret = dl_alloc_space(inode, number)))
6797 * First test before acquiring mutex - solves deadlocks when we
6798 * re-enter the quota code and are already holding the mutex
6799 @@ -1602,6 +1605,9 @@ int dquot_alloc_inode(const struct inode
6801 char warntype[MAXQUOTAS];
6803 + if ((ret = dl_alloc_inode(inode)))
6806 /* First test before acquiring mutex - solves deadlocks when we
6807 * re-enter the quota code and are already holding the mutex */
6808 if (!dquot_active(inode))
6809 @@ -1672,6 +1678,8 @@ void __dquot_free_space(struct inode *in
6810 char warntype[MAXQUOTAS];
6811 int reserve = flags & DQUOT_SPACE_RESERVE;
6813 + dl_free_space(inode, number);
6815 /* First test before acquiring mutex - solves deadlocks when we
6816 * re-enter the quota code and are already holding the mutex */
6817 if (!dquot_active(inode)) {
6818 @@ -1710,6 +1718,8 @@ void dquot_free_inode(const struct inode
6820 char warntype[MAXQUOTAS];
6822 + dl_free_inode(inode);
6824 /* First test before acquiring mutex - solves deadlocks when we
6825 * re-enter the quota code and are already holding the mutex */
6826 if (!dquot_active(inode))
6827 diff -NurpP --minimal linux-3.0.25/fs/quota/quota.c linux-3.0.25-vs2.3.2.3/fs/quota/quota.c
6828 --- linux-3.0.25/fs/quota/quota.c 2012-03-19 21:16:52.000000000 +0100
6829 +++ linux-3.0.25-vs2.3.2.3/fs/quota/quota.c 2011-11-15 17:37:07.000000000 +0100
6831 #include <linux/fs.h>
6832 #include <linux/namei.h>
6833 #include <linux/slab.h>
6834 +#include <linux/vs_context.h>
6835 #include <asm/current.h>
6836 #include <asm/uaccess.h>
6837 #include <linux/kernel.h>
6838 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
6842 - if (!capable(CAP_SYS_ADMIN))
6843 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6847 @@ -293,6 +294,46 @@ static int do_quotactl(struct super_bloc
6851 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6853 +#include <linux/vroot.h>
6854 +#include <linux/major.h>
6855 +#include <linux/module.h>
6856 +#include <linux/kallsyms.h>
6857 +#include <linux/vserver/debug.h>
6859 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6861 +static DEFINE_SPINLOCK(vroot_grb_lock);
6863 +int register_vroot_grb(vroot_grb_func *func) {
6866 + spin_lock(&vroot_grb_lock);
6867 + if (!vroot_get_real_bdev) {
6868 + vroot_get_real_bdev = func;
6871 + spin_unlock(&vroot_grb_lock);
6874 +EXPORT_SYMBOL(register_vroot_grb);
6876 +int unregister_vroot_grb(vroot_grb_func *func) {
6877 + int ret = -EINVAL;
6879 + spin_lock(&vroot_grb_lock);
6880 + if (vroot_get_real_bdev) {
6881 + vroot_get_real_bdev = NULL;
6884 + spin_unlock(&vroot_grb_lock);
6887 +EXPORT_SYMBOL(unregister_vroot_grb);
6892 * look up a superblock on which quota ops will be performed
6893 * - use the name of a block device to find the superblock thereon
6894 @@ -310,6 +351,22 @@ static struct super_block *quotactl_bloc
6897 return ERR_CAST(bdev);
6898 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6899 + if (bdev && bdev->bd_inode &&
6900 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6901 + struct block_device *bdnew = (void *)-EINVAL;
6903 + if (vroot_get_real_bdev)
6904 + bdnew = vroot_get_real_bdev(bdev);
6906 + vxdprintk(VXD_CBIT(misc, 0),
6907 + "vroot_get_real_bdev not set");
6909 + if (IS_ERR(bdnew))
6910 + return ERR_PTR(PTR_ERR(bdnew));
6914 sb = get_super(bdev);
6917 diff -NurpP --minimal linux-3.0.25/fs/reiserfs/file.c linux-3.0.25-vs2.3.2.3/fs/reiserfs/file.c
6918 --- linux-3.0.25/fs/reiserfs/file.c 2011-01-05 21:50:26.000000000 +0100
6919 +++ linux-3.0.25-vs2.3.2.3/fs/reiserfs/file.c 2011-06-10 22:11:24.000000000 +0200
6920 @@ -312,4 +312,5 @@ const struct inode_operations reiserfs_f
6921 .listxattr = reiserfs_listxattr,
6922 .removexattr = reiserfs_removexattr,
6923 .permission = reiserfs_permission,
6924 + .sync_flags = reiserfs_sync_flags,
6926 diff -NurpP --minimal linux-3.0.25/fs/reiserfs/inode.c linux-3.0.25-vs2.3.2.3/fs/reiserfs/inode.c
6927 --- linux-3.0.25/fs/reiserfs/inode.c 2011-05-22 16:17:53.000000000 +0200
6928 +++ linux-3.0.25-vs2.3.2.3/fs/reiserfs/inode.c 2011-06-10 22:11:24.000000000 +0200
6930 #include <linux/writeback.h>
6931 #include <linux/quotaops.h>
6932 #include <linux/swap.h>
6933 +#include <linux/vs_tag.h>
6935 int reiserfs_commit_write(struct file *f, struct page *page,
6936 unsigned from, unsigned to);
6937 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
6938 struct buffer_head *bh;
6939 struct item_head *ih;
6943 //int version = ITEM_VERSION_1;
6945 bh = PATH_PLAST_BUFFER(path);
6946 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
6947 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
6948 unsigned long blocks;
6950 + uid = sd_v1_uid(sd);
6951 + gid = sd_v1_gid(sd);
6953 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
6954 set_inode_sd_version(inode, STAT_DATA_V1);
6955 inode->i_mode = sd_v1_mode(sd);
6956 inode->i_nlink = sd_v1_nlink(sd);
6957 - inode->i_uid = sd_v1_uid(sd);
6958 - inode->i_gid = sd_v1_gid(sd);
6959 inode->i_size = sd_v1_size(sd);
6960 inode->i_atime.tv_sec = sd_v1_atime(sd);
6961 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
6962 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
6963 // (directories and symlinks)
6964 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
6966 + uid = sd_v2_uid(sd);
6967 + gid = sd_v2_gid(sd);
6969 inode->i_mode = sd_v2_mode(sd);
6970 inode->i_nlink = sd_v2_nlink(sd);
6971 - inode->i_uid = sd_v2_uid(sd);
6972 inode->i_size = sd_v2_size(sd);
6973 - inode->i_gid = sd_v2_gid(sd);
6974 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
6975 inode->i_atime.tv_sec = sd_v2_atime(sd);
6976 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
6977 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
6978 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
6981 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6982 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6983 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
6986 if (S_ISREG(inode->i_mode)) {
6987 inode->i_op = &reiserfs_file_inode_operations;
6988 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
6989 static void inode2sd(void *sd, struct inode *inode, loff_t size)
6991 struct stat_data *sd_v2 = (struct stat_data *)sd;
6992 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
6993 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
6996 + set_sd_v2_uid(sd_v2, uid);
6997 + set_sd_v2_gid(sd_v2, gid);
6998 set_sd_v2_mode(sd_v2, inode->i_mode);
6999 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7000 - set_sd_v2_uid(sd_v2, inode->i_uid);
7001 set_sd_v2_size(sd_v2, size);
7002 - set_sd_v2_gid(sd_v2, inode->i_gid);
7003 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7004 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7005 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7006 @@ -2863,14 +2874,19 @@ int reiserfs_commit_write(struct file *f
7007 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7009 if (reiserfs_attrs(inode->i_sb)) {
7010 - if (sd_attrs & REISERFS_SYNC_FL)
7011 - inode->i_flags |= S_SYNC;
7013 - inode->i_flags &= ~S_SYNC;
7014 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7015 inode->i_flags |= S_IMMUTABLE;
7017 inode->i_flags &= ~S_IMMUTABLE;
7018 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7019 + inode->i_flags |= S_IXUNLINK;
7021 + inode->i_flags &= ~S_IXUNLINK;
7023 + if (sd_attrs & REISERFS_SYNC_FL)
7024 + inode->i_flags |= S_SYNC;
7026 + inode->i_flags &= ~S_SYNC;
7027 if (sd_attrs & REISERFS_APPEND_FL)
7028 inode->i_flags |= S_APPEND;
7030 @@ -2883,6 +2899,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7031 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7033 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7035 + if (sd_attrs & REISERFS_BARRIER_FL)
7036 + inode->i_vflags |= V_BARRIER;
7038 + inode->i_vflags &= ~V_BARRIER;
7039 + if (sd_attrs & REISERFS_COW_FL)
7040 + inode->i_vflags |= V_COW;
7042 + inode->i_vflags &= ~V_COW;
7046 @@ -2893,6 +2918,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7047 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7049 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7050 + if (inode->i_flags & S_IXUNLINK)
7051 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7053 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7055 if (inode->i_flags & S_SYNC)
7056 *sd_attrs |= REISERFS_SYNC_FL;
7058 @@ -2905,6 +2935,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7059 *sd_attrs |= REISERFS_NOTAIL_FL;
7061 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7063 + if (inode->i_vflags & V_BARRIER)
7064 + *sd_attrs |= REISERFS_BARRIER_FL;
7066 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7067 + if (inode->i_vflags & V_COW)
7068 + *sd_attrs |= REISERFS_COW_FL;
7070 + *sd_attrs &= ~REISERFS_COW_FL;
7074 @@ -3148,7 +3187,8 @@ int reiserfs_setattr(struct dentry *dent
7077 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7078 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7079 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7080 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7081 struct reiserfs_transaction_handle th;
7084 @@ -3177,6 +3217,9 @@ int reiserfs_setattr(struct dentry *dent
7085 inode->i_uid = attr->ia_uid;
7086 if (attr->ia_valid & ATTR_GID)
7087 inode->i_gid = attr->ia_gid;
7088 + if ((attr->ia_valid & ATTR_TAG) &&
7090 + inode->i_tag = attr->ia_tag;
7091 mark_inode_dirty(inode);
7092 error = journal_end(&th, inode->i_sb, jbegin_count);
7094 diff -NurpP --minimal linux-3.0.25/fs/reiserfs/ioctl.c linux-3.0.25-vs2.3.2.3/fs/reiserfs/ioctl.c
7095 --- linux-3.0.25/fs/reiserfs/ioctl.c 2011-05-22 16:17:53.000000000 +0200
7096 +++ linux-3.0.25-vs2.3.2.3/fs/reiserfs/ioctl.c 2011-06-10 22:11:24.000000000 +0200
7098 #include <linux/pagemap.h>
7099 #include <linux/compat.h>
7102 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7104 + __u16 sd_attrs = 0;
7106 + inode->i_flags = flags;
7107 + inode->i_vflags = vflags;
7109 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7110 + REISERFS_I(inode)->i_attrs = sd_attrs;
7111 + inode->i_ctime = CURRENT_TIME_SEC;
7112 + mark_inode_dirty(inode);
7117 * reiserfs_ioctl - handler for ioctl for inode
7118 * supported commands:
7120 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7122 struct inode *inode = filp->f_path.dentry->d_inode;
7123 - unsigned int flags;
7124 + unsigned int flags, oldflags;
7127 reiserfs_write_lock(inode->i_sb);
7128 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7130 flags = REISERFS_I(inode)->i_attrs;
7131 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7132 + flags &= REISERFS_FL_USER_VISIBLE;
7133 err = put_user(flags, (int __user *)arg);
7135 case REISERFS_IOC_SETFLAGS:{
7136 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7140 + if (IS_BARRIER(inode)) {
7141 + vxwprintk_task(1, "messing with the barrier.");
7145 * Is it quota file? Do not allow user to mess with it
7147 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7152 + oldflags = REISERFS_I(inode)->i_attrs;
7153 + flags &= REISERFS_FL_USER_MODIFIABLE;
7154 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7155 sd_attrs_to_i_attrs(flags, inode);
7156 REISERFS_I(inode)->i_attrs = flags;
7157 inode->i_ctime = CURRENT_TIME_SEC;
7158 diff -NurpP --minimal linux-3.0.25/fs/reiserfs/namei.c linux-3.0.25-vs2.3.2.3/fs/reiserfs/namei.c
7159 --- linux-3.0.25/fs/reiserfs/namei.c 2011-05-22 16:17:53.000000000 +0200
7160 +++ linux-3.0.25-vs2.3.2.3/fs/reiserfs/namei.c 2011-06-10 22:11:24.000000000 +0200
7162 #include <linux/reiserfs_acl.h>
7163 #include <linux/reiserfs_xattr.h>
7164 #include <linux/quotaops.h>
7165 +#include <linux/vs_tag.h>
7167 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; }
7168 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7169 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7170 if (retval == IO_ERROR) {
7171 return ERR_PTR(-EIO);
7173 + dx_propagate_tag(nd, inode);
7175 return d_splice_alias(inode, dentry);
7177 @@ -1529,6 +1531,7 @@ const struct inode_operations reiserfs_d
7178 .listxattr = reiserfs_listxattr,
7179 .removexattr = reiserfs_removexattr,
7180 .permission = reiserfs_permission,
7181 + .sync_flags = reiserfs_sync_flags,
7185 diff -NurpP --minimal linux-3.0.25/fs/reiserfs/super.c linux-3.0.25-vs2.3.2.3/fs/reiserfs/super.c
7186 --- linux-3.0.25/fs/reiserfs/super.c 2012-03-19 21:16:52.000000000 +0100
7187 +++ linux-3.0.25-vs2.3.2.3/fs/reiserfs/super.c 2012-01-18 02:58:46.000000000 +0100
7188 @@ -903,6 +903,14 @@ static int reiserfs_parse_options(struct
7189 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7190 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7192 +#ifndef CONFIG_TAGGING_NONE
7193 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7194 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7195 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7197 +#ifdef CONFIG_PROPAGATE
7198 + {"tag",.arg_required = 'T',.values = NULL},
7200 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7201 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7202 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7203 @@ -1213,6 +1221,14 @@ static int reiserfs_remount(struct super
7204 handle_quota_files(s, qf_names, &qfmt);
7207 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7208 + !(s->s_flags & MS_TAGGED)) {
7209 + reiserfs_warning(s, "super-vs01",
7210 + "reiserfs: tagging not permitted on remount.");
7217 /* Add options that are safe here */
7218 @@ -1695,6 +1711,10 @@ static int reiserfs_fill_super(struct su
7222 + /* map mount option tagxid */
7223 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7224 + s->s_flags |= MS_TAGGED;
7226 rs = SB_DISK_SUPER_BLOCK(s);
7227 /* Let's do basic sanity check to verify that underlying device is not
7228 smaller than the filesystem. If the check fails then abort and scream,
7229 diff -NurpP --minimal linux-3.0.25/fs/reiserfs/xattr.c linux-3.0.25-vs2.3.2.3/fs/reiserfs/xattr.c
7230 --- linux-3.0.25/fs/reiserfs/xattr.c 2011-07-22 11:18:06.000000000 +0200
7231 +++ linux-3.0.25-vs2.3.2.3/fs/reiserfs/xattr.c 2011-06-22 12:39:15.000000000 +0200
7233 #include <linux/errno.h>
7234 #include <linux/gfp.h>
7235 #include <linux/fs.h>
7236 +#include <linux/mount.h>
7237 #include <linux/file.h>
7238 #include <linux/pagemap.h>
7239 #include <linux/xattr.h>
7240 diff -NurpP --minimal linux-3.0.25/fs/stat.c linux-3.0.25-vs2.3.2.3/fs/stat.c
7241 --- linux-3.0.25/fs/stat.c 2012-03-19 21:16:52.000000000 +0100
7242 +++ linux-3.0.25-vs2.3.2.3/fs/stat.c 2011-11-15 17:37:07.000000000 +0100
7243 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7244 stat->nlink = inode->i_nlink;
7245 stat->uid = inode->i_uid;
7246 stat->gid = inode->i_gid;
7247 + stat->tag = inode->i_tag;
7248 stat->rdev = inode->i_rdev;
7249 stat->atime = inode->i_atime;
7250 stat->mtime = inode->i_mtime;
7251 diff -NurpP --minimal linux-3.0.25/fs/statfs.c linux-3.0.25-vs2.3.2.3/fs/statfs.c
7252 --- linux-3.0.25/fs/statfs.c 2012-03-19 21:16:52.000000000 +0100
7253 +++ linux-3.0.25-vs2.3.2.3/fs/statfs.c 2011-11-15 17:37:07.000000000 +0100
7255 #include <linux/statfs.h>
7256 #include <linux/security.h>
7257 #include <linux/uaccess.h>
7258 +#include <linux/vs_base.h>
7259 +#include <linux/vs_dlimit.h>
7261 static int flags_by_mnt(int mnt_flags)
7263 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
7264 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7265 if (retval == 0 && buf->f_frsize == 0)
7266 buf->f_frsize = buf->f_bsize;
7267 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7268 + vx_vsi_statfs(dentry->d_sb, buf);
7272 diff -NurpP --minimal linux-3.0.25/fs/super.c linux-3.0.25-vs2.3.2.3/fs/super.c
7273 --- linux-3.0.25/fs/super.c 2011-07-22 11:18:06.000000000 +0200
7274 +++ linux-3.0.25-vs2.3.2.3/fs/super.c 2011-07-23 16:49:09.000000000 +0200
7276 #include <linux/backing-dev.h>
7277 #include <linux/rculist_bl.h>
7278 #include <linux/cleancache.h>
7279 +#include <linux/devpts_fs.h>
7280 +#include <linux/proc_fs.h>
7281 +#include <linux/vs_context.h>
7282 #include "internal.h"
7285 @@ -943,6 +946,13 @@ mount_fs(struct file_system_type *type,
7286 WARN_ON(sb->s_bdi == &default_backing_dev_info);
7287 sb->s_flags |= MS_BORN;
7290 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
7292 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7293 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7296 error = security_sb_kern_mount(sb, flags, secdata);
7299 diff -NurpP --minimal linux-3.0.25/fs/sysfs/mount.c linux-3.0.25-vs2.3.2.3/fs/sysfs/mount.c
7300 --- linux-3.0.25/fs/sysfs/mount.c 2011-07-22 11:18:06.000000000 +0200
7301 +++ linux-3.0.25-vs2.3.2.3/fs/sysfs/mount.c 2011-06-22 12:39:15.000000000 +0200
7302 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7304 sb->s_blocksize = PAGE_CACHE_SIZE;
7305 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7306 - sb->s_magic = SYSFS_MAGIC;
7307 + sb->s_magic = SYSFS_SUPER_MAGIC;
7308 sb->s_op = &sysfs_ops;
7309 sb->s_time_gran = 1;
7311 diff -NurpP --minimal linux-3.0.25/fs/utimes.c linux-3.0.25-vs2.3.2.3/fs/utimes.c
7312 --- linux-3.0.25/fs/utimes.c 2011-05-22 16:17:54.000000000 +0200
7313 +++ linux-3.0.25-vs2.3.2.3/fs/utimes.c 2011-06-10 22:11:24.000000000 +0200
7315 #include <linux/stat.h>
7316 #include <linux/utime.h>
7317 #include <linux/syscalls.h>
7318 +#include <linux/mount.h>
7319 +#include <linux/vs_cowbl.h>
7320 #include <asm/uaccess.h>
7321 #include <asm/unistd.h>
7323 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7326 struct iattr newattrs;
7327 - struct inode *inode = path->dentry->d_inode;
7328 + struct inode *inode;
7330 error = mnt_want_write(path->mnt);
7334 + error = cow_check_and_break(path);
7336 + goto mnt_drop_write_and_out;
7338 + inode = path->dentry->d_inode;
7340 if (times && times[0].tv_nsec == UTIME_NOW &&
7341 times[1].tv_nsec == UTIME_NOW)
7343 diff -NurpP --minimal linux-3.0.25/fs/xattr.c linux-3.0.25-vs2.3.2.3/fs/xattr.c
7344 --- linux-3.0.25/fs/xattr.c 2011-07-22 11:18:09.000000000 +0200
7345 +++ linux-3.0.25-vs2.3.2.3/fs/xattr.c 2011-06-10 23:10:19.000000000 +0200
7347 #include <linux/module.h>
7348 #include <linux/fsnotify.h>
7349 #include <linux/audit.h>
7350 +#include <linux/mount.h>
7351 #include <asm/uaccess.h>
7354 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7355 * The trusted.* namespace can only be accessed by privileged users.
7357 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
7358 - if (!capable(CAP_SYS_ADMIN))
7359 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
7360 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
7363 diff -NurpP --minimal linux-3.0.25/fs/xfs/linux-2.6/xfs_ioctl.c linux-3.0.25-vs2.3.2.3/fs/xfs/linux-2.6/xfs_ioctl.c
7364 --- linux-3.0.25/fs/xfs/linux-2.6/xfs_ioctl.c 2011-05-22 16:17:54.000000000 +0200
7365 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/linux-2.6/xfs_ioctl.c 2011-06-10 22:11:24.000000000 +0200
7367 #include "xfs_bmap_btree.h"
7368 #include "xfs_dinode.h"
7369 #include "xfs_inode.h"
7370 -#include "xfs_ioctl.h"
7371 +// #include "xfs_ioctl.h"
7372 #include "xfs_rtalloc.h"
7373 #include "xfs_itable.h"
7374 #include "xfs_error.h"
7375 @@ -748,6 +748,10 @@ xfs_merge_ioc_xflags(
7376 xflags |= XFS_XFLAG_IMMUTABLE;
7378 xflags &= ~XFS_XFLAG_IMMUTABLE;
7379 + if (flags & FS_IXUNLINK_FL)
7380 + xflags |= XFS_XFLAG_IXUNLINK;
7382 + xflags &= ~XFS_XFLAG_IXUNLINK;
7383 if (flags & FS_APPEND_FL)
7384 xflags |= XFS_XFLAG_APPEND;
7386 @@ -776,6 +780,8 @@ xfs_di2lxflags(
7388 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7389 flags |= FS_IMMUTABLE_FL;
7390 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7391 + flags |= FS_IXUNLINK_FL;
7392 if (di_flags & XFS_DIFLAG_APPEND)
7393 flags |= FS_APPEND_FL;
7394 if (di_flags & XFS_DIFLAG_SYNC)
7395 @@ -836,6 +842,8 @@ xfs_set_diflags(
7396 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7397 if (xflags & XFS_XFLAG_IMMUTABLE)
7398 di_flags |= XFS_DIFLAG_IMMUTABLE;
7399 + if (xflags & XFS_XFLAG_IXUNLINK)
7400 + di_flags |= XFS_DIFLAG_IXUNLINK;
7401 if (xflags & XFS_XFLAG_APPEND)
7402 di_flags |= XFS_DIFLAG_APPEND;
7403 if (xflags & XFS_XFLAG_SYNC)
7404 @@ -878,6 +886,10 @@ xfs_diflags_to_linux(
7405 inode->i_flags |= S_IMMUTABLE;
7407 inode->i_flags &= ~S_IMMUTABLE;
7408 + if (xflags & XFS_XFLAG_IXUNLINK)
7409 + inode->i_flags |= S_IXUNLINK;
7411 + inode->i_flags &= ~S_IXUNLINK;
7412 if (xflags & XFS_XFLAG_APPEND)
7413 inode->i_flags |= S_APPEND;
7415 @@ -1370,10 +1382,18 @@ xfs_file_ioctl(
7416 case XFS_IOC_FSGETXATTRA:
7417 return xfs_ioc_fsgetxattr(ip, 1, arg);
7418 case XFS_IOC_FSSETXATTR:
7419 + if (IS_BARRIER(inode)) {
7420 + vxwprintk_task(1, "messing with the barrier.");
7421 + return -XFS_ERROR(EACCES);
7423 return xfs_ioc_fssetxattr(ip, filp, arg);
7424 case XFS_IOC_GETXFLAGS:
7425 return xfs_ioc_getxflags(ip, arg);
7426 case XFS_IOC_SETXFLAGS:
7427 + if (IS_BARRIER(inode)) {
7428 + vxwprintk_task(1, "messing with the barrier.");
7429 + return -XFS_ERROR(EACCES);
7431 return xfs_ioc_setxflags(ip, filp, arg);
7433 case XFS_IOC_FSSETDM: {
7434 diff -NurpP --minimal linux-3.0.25/fs/xfs/linux-2.6/xfs_ioctl.h linux-3.0.25-vs2.3.2.3/fs/xfs/linux-2.6/xfs_ioctl.h
7435 --- linux-3.0.25/fs/xfs/linux-2.6/xfs_ioctl.h 2010-07-07 18:31:54.000000000 +0200
7436 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/linux-2.6/xfs_ioctl.h 2011-06-10 22:11:24.000000000 +0200
7437 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7438 void __user *uhandle,
7443 + struct inode *inode,
7450 diff -NurpP --minimal linux-3.0.25/fs/xfs/linux-2.6/xfs_iops.c linux-3.0.25-vs2.3.2.3/fs/xfs/linux-2.6/xfs_iops.c
7451 --- linux-3.0.25/fs/xfs/linux-2.6/xfs_iops.c 2012-03-19 21:16:52.000000000 +0100
7452 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/linux-2.6/xfs_iops.c 2011-12-19 15:55:53.000000000 +0100
7454 #include "xfs_bmap_btree.h"
7455 #include "xfs_dinode.h"
7456 #include "xfs_inode.h"
7457 +#include "xfs_ioctl.h"
7458 #include "xfs_bmap.h"
7459 #include "xfs_rtalloc.h"
7460 #include "xfs_error.h"
7462 #include <linux/security.h>
7463 #include <linux/fiemap.h>
7464 #include <linux/slab.h>
7465 +#include <linux/vs_tag.h>
7468 * Bring the timestamps in the XFS inode uptodate.
7469 @@ -472,6 +474,7 @@ xfs_vn_getattr(
7470 stat->nlink = ip->i_d.di_nlink;
7471 stat->uid = ip->i_d.di_uid;
7472 stat->gid = ip->i_d.di_gid;
7473 + stat->tag = ip->i_d.di_tag;
7474 stat->ino = ip->i_ino;
7475 stat->atime = inode->i_atime;
7476 stat->mtime = inode->i_mtime;
7477 @@ -607,6 +610,7 @@ static const struct inode_operations xfs
7478 .removexattr = generic_removexattr,
7479 .listxattr = xfs_vn_listxattr,
7480 .fiemap = xfs_vn_fiemap,
7481 + .sync_flags = xfs_sync_flags,
7484 static const struct inode_operations xfs_dir_inode_operations = {
7485 @@ -632,6 +636,7 @@ static const struct inode_operations xfs
7486 .getxattr = generic_getxattr,
7487 .removexattr = generic_removexattr,
7488 .listxattr = xfs_vn_listxattr,
7489 + .sync_flags = xfs_sync_flags,
7492 static const struct inode_operations xfs_dir_ci_inode_operations = {
7493 @@ -681,6 +686,10 @@ xfs_diflags_to_iflags(
7494 inode->i_flags |= S_IMMUTABLE;
7496 inode->i_flags &= ~S_IMMUTABLE;
7497 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7498 + inode->i_flags |= S_IXUNLINK;
7500 + inode->i_flags &= ~S_IXUNLINK;
7501 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7502 inode->i_flags |= S_APPEND;
7504 @@ -693,6 +702,15 @@ xfs_diflags_to_iflags(
7505 inode->i_flags |= S_NOATIME;
7507 inode->i_flags &= ~S_NOATIME;
7509 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7510 + inode->i_vflags |= V_BARRIER;
7512 + inode->i_vflags &= ~V_BARRIER;
7513 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7514 + inode->i_vflags |= V_COW;
7516 + inode->i_vflags &= ~V_COW;
7520 @@ -724,6 +742,7 @@ xfs_setup_inode(
7521 inode->i_nlink = ip->i_d.di_nlink;
7522 inode->i_uid = ip->i_d.di_uid;
7523 inode->i_gid = ip->i_d.di_gid;
7524 + inode->i_tag = ip->i_d.di_tag;
7526 switch (inode->i_mode & S_IFMT) {
7528 diff -NurpP --minimal linux-3.0.25/fs/xfs/linux-2.6/xfs_linux.h linux-3.0.25-vs2.3.2.3/fs/xfs/linux-2.6/xfs_linux.h
7529 --- linux-3.0.25/fs/xfs/linux-2.6/xfs_linux.h 2012-03-19 21:16:52.000000000 +0100
7530 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/linux-2.6/xfs_linux.h 2011-11-15 17:37:07.000000000 +0100
7533 #define current_cpu() (raw_smp_processor_id())
7534 #define current_pid() (current->pid)
7535 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7536 #define current_test_flags(f) (current->flags & (f))
7537 #define current_set_flags_nested(sp, f) \
7538 (*(sp) = current->flags, current->flags |= (f))
7539 diff -NurpP --minimal linux-3.0.25/fs/xfs/linux-2.6/xfs_super.c linux-3.0.25-vs2.3.2.3/fs/xfs/linux-2.6/xfs_super.c
7540 --- linux-3.0.25/fs/xfs/linux-2.6/xfs_super.c 2012-03-19 21:16:52.000000000 +0100
7541 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/linux-2.6/xfs_super.c 2012-01-10 09:19:13.000000000 +0100
7542 @@ -114,6 +114,9 @@ mempool_t *xfs_ioend_pool;
7543 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7544 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7545 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7546 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7547 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7548 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7551 * Table driven mount option parser.
7552 @@ -122,10 +125,14 @@ mempool_t *xfs_ioend_pool;
7553 * in the future, too.
7556 + Opt_tag, Opt_notag,
7557 Opt_barrier, Opt_nobarrier, Opt_err
7560 static const match_table_t tokens = {
7561 + {Opt_tag, "tagxid"},
7563 + {Opt_notag, "notag"},
7564 {Opt_barrier, "barrier"},
7565 {Opt_nobarrier, "nobarrier"},
7567 @@ -373,6 +380,19 @@ xfs_parseargs(
7568 } else if (!strcmp(this_char, "irixsgid")) {
7570 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7571 +#ifndef CONFIG_TAGGING_NONE
7572 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7573 + mp->m_flags |= XFS_MOUNT_TAGGED;
7574 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7575 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7576 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7577 + mp->m_flags |= XFS_MOUNT_TAGGED;
7579 +#ifdef CONFIG_PROPAGATE
7580 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7582 + mp->m_flags |= XFS_MOUNT_TAGGED;
7585 xfs_warn(mp, "unknown mount option [%s].", this_char);
7587 @@ -1146,6 +1166,16 @@ xfs_fs_remount(
7589 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7592 + if (!(sb->s_flags & MS_TAGGED)) {
7594 + "XFS: %s: tagging not permitted on remount.\n",
7603 * Logically we would return an error here to prevent
7604 @@ -1361,6 +1391,9 @@ xfs_fs_fill_super(
7608 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7609 + sb->s_flags |= MS_TAGGED;
7612 * we must configure the block size in the superblock before we run the
7613 * full mount process as the mount process can lookup and cache inodes.
7614 diff -NurpP --minimal linux-3.0.25/fs/xfs/xfs_dinode.h linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_dinode.h
7615 --- linux-3.0.25/fs/xfs/xfs_dinode.h 2011-01-05 21:50:28.000000000 +0100
7616 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_dinode.h 2011-06-10 22:11:24.000000000 +0200
7617 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
7618 __be32 di_nlink; /* number of links to file */
7619 __be16 di_projid_lo; /* lower part of owner's project id */
7620 __be16 di_projid_hi; /* higher part owner's project id */
7621 - __u8 di_pad[6]; /* unused, zeroed space */
7622 + __u8 di_pad[2]; /* unused, zeroed space */
7623 + __be16 di_tag; /* context tagging */
7624 + __be16 di_vflags; /* vserver specific flags */
7625 __be16 di_flushiter; /* incremented on flush */
7626 xfs_timestamp_t di_atime; /* time last accessed */
7627 xfs_timestamp_t di_mtime; /* time last modified */
7628 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
7629 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7630 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7631 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7632 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7634 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7635 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7636 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7637 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
7638 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7639 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7640 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7641 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7643 #ifdef CONFIG_XFS_RT
7644 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7645 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
7646 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7647 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7648 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7649 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7650 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7651 + XFS_DIFLAG_IXUNLINK)
7653 +#define XFS_DIVFLAG_BARRIER 0x01
7654 +#define XFS_DIVFLAG_COW 0x02
7656 #endif /* __XFS_DINODE_H__ */
7657 diff -NurpP --minimal linux-3.0.25/fs/xfs/xfs_fs.h linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_fs.h
7658 --- linux-3.0.25/fs/xfs/xfs_fs.h 2011-01-05 21:50:28.000000000 +0100
7659 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_fs.h 2011-06-10 22:11:24.000000000 +0200
7660 @@ -67,6 +67,9 @@ struct fsxattr {
7661 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
7662 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
7663 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
7664 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
7665 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
7666 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
7667 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
7670 @@ -297,7 +300,8 @@ typedef struct xfs_bstat {
7671 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
7672 __u16 bs_forkoff; /* inode fork offset in bytes */
7673 __u16 bs_projid_hi; /* higher part of project id */
7674 - unsigned char bs_pad[10]; /* pad space, unused */
7675 + unsigned char bs_pad[8]; /* pad space, unused */
7676 + __u16 bs_tag; /* context tagging */
7677 __u32 bs_dmevmask; /* DMIG event mask */
7678 __u16 bs_dmstate; /* DMIG state info */
7679 __u16 bs_aextents; /* attribute number of extents */
7680 diff -NurpP --minimal linux-3.0.25/fs/xfs/xfs_ialloc.c linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_ialloc.c
7681 --- linux-3.0.25/fs/xfs/xfs_ialloc.c 2011-05-22 16:17:54.000000000 +0200
7682 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_ialloc.c 2011-06-10 22:11:24.000000000 +0200
7684 #include "xfs_error.h"
7685 #include "xfs_bmap.h"
7689 * Allocation group level functions.
7691 diff -NurpP --minimal linux-3.0.25/fs/xfs/xfs_inode.c linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_inode.c
7692 --- linux-3.0.25/fs/xfs/xfs_inode.c 2012-03-19 21:16:52.000000000 +0100
7693 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_inode.c 2011-12-23 16:09:00.000000000 +0100
7694 @@ -243,6 +243,7 @@ xfs_inotobp(
7698 +#include <linux/vs_tag.h>
7701 * This routine is called to map an inode to the buffer containing
7702 @@ -641,15 +642,25 @@ xfs_iformat_btree(
7704 xfs_dinode_from_disk(
7706 - xfs_dinode_t *from)
7707 + xfs_dinode_t *from,
7710 + uint32_t uid, gid, tag;
7712 to->di_magic = be16_to_cpu(from->di_magic);
7713 to->di_mode = be16_to_cpu(from->di_mode);
7714 to->di_version = from ->di_version;
7715 to->di_format = from->di_format;
7716 to->di_onlink = be16_to_cpu(from->di_onlink);
7717 - to->di_uid = be32_to_cpu(from->di_uid);
7718 - to->di_gid = be32_to_cpu(from->di_gid);
7720 + uid = be32_to_cpu(from->di_uid);
7721 + gid = be32_to_cpu(from->di_gid);
7722 + tag = be16_to_cpu(from->di_tag);
7724 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7725 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7726 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7728 to->di_nlink = be32_to_cpu(from->di_nlink);
7729 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7730 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7731 @@ -671,21 +682,26 @@ xfs_dinode_from_disk(
7732 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7733 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7734 to->di_flags = be16_to_cpu(from->di_flags);
7735 + to->di_vflags = be16_to_cpu(from->di_vflags);
7736 to->di_gen = be32_to_cpu(from->di_gen);
7742 - xfs_icdinode_t *from)
7743 + xfs_icdinode_t *from,
7746 to->di_magic = cpu_to_be16(from->di_magic);
7747 to->di_mode = cpu_to_be16(from->di_mode);
7748 to->di_version = from ->di_version;
7749 to->di_format = from->di_format;
7750 to->di_onlink = cpu_to_be16(from->di_onlink);
7751 - to->di_uid = cpu_to_be32(from->di_uid);
7752 - to->di_gid = cpu_to_be32(from->di_gid);
7754 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
7755 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
7756 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
7758 to->di_nlink = cpu_to_be32(from->di_nlink);
7759 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
7760 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
7761 @@ -707,12 +723,14 @@ xfs_dinode_to_disk(
7762 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
7763 to->di_dmstate = cpu_to_be16(from->di_dmstate);
7764 to->di_flags = cpu_to_be16(from->di_flags);
7765 + to->di_vflags = cpu_to_be16(from->di_vflags);
7766 to->di_gen = cpu_to_be32(from->di_gen);
7771 - __uint16_t di_flags)
7772 + __uint16_t di_flags,
7773 + __uint16_t di_vflags)
7777 @@ -723,6 +741,8 @@ _xfs_dic2xflags(
7778 flags |= XFS_XFLAG_PREALLOC;
7779 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7780 flags |= XFS_XFLAG_IMMUTABLE;
7781 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7782 + flags |= XFS_XFLAG_IXUNLINK;
7783 if (di_flags & XFS_DIFLAG_APPEND)
7784 flags |= XFS_XFLAG_APPEND;
7785 if (di_flags & XFS_DIFLAG_SYNC)
7786 @@ -747,6 +767,10 @@ _xfs_dic2xflags(
7787 flags |= XFS_XFLAG_FILESTREAM;
7790 + if (di_vflags & XFS_DIVFLAG_BARRIER)
7791 + flags |= FS_BARRIER_FL;
7792 + if (di_vflags & XFS_DIVFLAG_COW)
7793 + flags |= FS_COW_FL;
7797 @@ -756,7 +780,7 @@ xfs_ip2xflags(
7799 xfs_icdinode_t *dic = &ip->i_d;
7801 - return _xfs_dic2xflags(dic->di_flags) |
7802 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
7803 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
7806 @@ -764,7 +788,8 @@ uint
7810 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
7811 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
7812 + be16_to_cpu(dip->di_vflags)) |
7813 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
7816 @@ -797,7 +822,6 @@ xfs_iread(
7819 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
7822 * If we got something that isn't an inode it means someone
7823 * (nfs or dmi) has a stale handle.
7824 @@ -820,7 +844,8 @@ xfs_iread(
7825 * Otherwise, just get the truly permanent information.
7828 - xfs_dinode_from_disk(&ip->i_d, dip);
7829 + xfs_dinode_from_disk(&ip->i_d, dip,
7830 + mp->m_flags & XFS_MOUNT_TAGGED);
7831 error = xfs_iformat(ip, dip);
7834 @@ -1015,6 +1040,7 @@ xfs_ialloc(
7835 ASSERT(ip->i_d.di_nlink == nlink);
7836 ip->i_d.di_uid = current_fsuid();
7837 ip->i_d.di_gid = current_fsgid();
7838 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
7839 xfs_set_projid(ip, prid);
7840 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
7842 @@ -1075,6 +1101,7 @@ xfs_ialloc(
7843 ip->i_d.di_dmevmask = 0;
7844 ip->i_d.di_dmstate = 0;
7845 ip->i_d.di_flags = 0;
7846 + ip->i_d.di_vflags = 0;
7847 flags = XFS_ILOG_CORE;
7848 switch (mode & S_IFMT) {
7850 @@ -2100,6 +2127,7 @@ xfs_ifree(
7852 ip->i_d.di_mode = 0; /* mark incore inode as free */
7853 ip->i_d.di_flags = 0;
7854 + ip->i_d.di_vflags = 0;
7855 ip->i_d.di_dmevmask = 0;
7856 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
7857 ip->i_df.if_ext_max =
7858 @@ -2979,7 +3007,8 @@ xfs_iflush_int(
7859 * because if the inode is dirty at all the core must
7862 - xfs_dinode_to_disk(dip, &ip->i_d);
7863 + xfs_dinode_to_disk(dip, &ip->i_d,
7864 + mp->m_flags & XFS_MOUNT_TAGGED);
7866 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7867 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7868 diff -NurpP --minimal linux-3.0.25/fs/xfs/xfs_inode.h linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_inode.h
7869 --- linux-3.0.25/fs/xfs/xfs_inode.h 2012-03-19 21:16:52.000000000 +0100
7870 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_inode.h 2011-12-19 15:55:53.000000000 +0100
7871 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
7872 __uint32_t di_nlink; /* number of links to file */
7873 __uint16_t di_projid_lo; /* lower part of owner's project id */
7874 __uint16_t di_projid_hi; /* higher part of owner's project id */
7875 - __uint8_t di_pad[6]; /* unused, zeroed space */
7876 + __uint8_t di_pad[2]; /* unused, zeroed space */
7877 + __uint16_t di_tag; /* context tagging */
7878 + __uint16_t di_vflags; /* vserver specific flags */
7879 __uint16_t di_flushiter; /* incremented on flush */
7880 xfs_ictimestamp_t di_atime; /* time last accessed */
7881 xfs_ictimestamp_t di_mtime; /* time last modified */
7882 @@ -547,7 +549,7 @@ int xfs_itobp(struct xfs_mount *, struc
7883 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
7884 struct xfs_inode *, uint);
7885 void xfs_dinode_to_disk(struct xfs_dinode *,
7886 - struct xfs_icdinode *);
7887 + struct xfs_icdinode *, int);
7888 void xfs_idestroy_fork(struct xfs_inode *, int);
7889 void xfs_idata_realloc(struct xfs_inode *, int, int);
7890 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7891 diff -NurpP --minimal linux-3.0.25/fs/xfs/xfs_itable.c linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_itable.c
7892 --- linux-3.0.25/fs/xfs/xfs_itable.c 2011-05-22 16:17:54.000000000 +0200
7893 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_itable.c 2011-06-10 22:11:24.000000000 +0200
7894 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
7895 buf->bs_mode = dic->di_mode;
7896 buf->bs_uid = dic->di_uid;
7897 buf->bs_gid = dic->di_gid;
7898 + buf->bs_tag = dic->di_tag;
7899 buf->bs_size = dic->di_size;
7902 diff -NurpP --minimal linux-3.0.25/fs/xfs/xfs_log_recover.c linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_log_recover.c
7903 --- linux-3.0.25/fs/xfs/xfs_log_recover.c 2011-07-22 11:18:10.000000000 +0200
7904 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_log_recover.c 2011-06-10 22:11:24.000000000 +0200
7905 @@ -2343,7 +2343,8 @@ xlog_recover_inode_pass2(
7908 /* The core is in in-core format */
7909 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
7910 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
7911 + mp->m_flags & XFS_MOUNT_TAGGED);
7913 /* the rest is in on-disk format */
7914 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
7915 diff -NurpP --minimal linux-3.0.25/fs/xfs/xfs_mount.h linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_mount.h
7916 --- linux-3.0.25/fs/xfs/xfs_mount.h 2011-07-22 11:18:10.000000000 +0200
7917 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_mount.h 2011-06-10 22:11:24.000000000 +0200
7918 @@ -249,6 +249,7 @@ typedef struct xfs_mount {
7920 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7922 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7925 * Default minimum read and write sizes.
7926 diff -NurpP --minimal linux-3.0.25/fs/xfs/xfs_vnodeops.c linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_vnodeops.c
7927 --- linux-3.0.25/fs/xfs/xfs_vnodeops.c 2012-03-19 21:16:52.000000000 +0100
7928 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_vnodeops.c 2012-02-07 02:05:58.000000000 +0100
7930 #include "xfs_vnodeops.h"
7931 #include "xfs_trace.h"
7935 +xfs_get_inode_flags(
7938 + struct inode *inode = VFS_I(ip);
7939 + unsigned int flags = inode->i_flags;
7940 + unsigned int vflags = inode->i_vflags;
7942 + if (flags & S_IMMUTABLE)
7943 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7945 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7946 + if (flags & S_IXUNLINK)
7947 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
7949 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
7951 + if (vflags & V_BARRIER)
7952 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
7954 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
7955 + if (vflags & V_COW)
7956 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
7958 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
7963 + struct inode *inode,
7967 + struct xfs_inode *ip = XFS_I(inode);
7968 + struct xfs_mount *mp = ip->i_mount;
7969 + struct xfs_trans *tp;
7970 + unsigned int lock_flags = 0;
7973 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
7974 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
7978 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7980 + xfs_trans_ijoin(tp, ip);
7982 + inode->i_flags = flags;
7983 + inode->i_vflags = vflags;
7984 + xfs_get_inode_flags(ip);
7986 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
7987 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
7989 + XFS_STATS_INC(xs_ig_attrchg);
7991 + if (mp->m_flags & XFS_MOUNT_WSYNC)
7992 + xfs_trans_set_sync(tp);
7993 + code = xfs_trans_commit(tp, 0);
7994 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7998 + xfs_trans_cancel(tp, 0);
8000 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8007 struct xfs_inode *ip,
8008 @@ -65,6 +137,7 @@ xfs_setattr(
8009 uint commit_flags=0;
8010 uid_t uid=0, iuid=0;
8011 gid_t gid=0, igid=0;
8012 + tag_t tag=0, itag=0;
8013 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
8014 int need_iolock = 1;
8016 @@ -147,7 +220,7 @@ xfs_setattr(
8018 * Change file ownership. Must be the owner or privileged.
8020 - if (mask & (ATTR_UID|ATTR_GID)) {
8021 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8023 * These IDs could have changed since we last looked at them.
8024 * But, we're assured that if the ownership did change
8025 @@ -156,8 +229,10 @@ xfs_setattr(
8027 iuid = ip->i_d.di_uid;
8028 igid = ip->i_d.di_gid;
8029 + itag = ip->i_d.di_tag;
8030 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
8031 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
8032 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
8035 * Do a quota reservation only if uid/gid is actually
8036 @@ -165,7 +240,8 @@ xfs_setattr(
8038 if (XFS_IS_QUOTA_RUNNING(mp) &&
8039 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
8040 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
8041 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
8042 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
8044 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
8045 capable(CAP_FOWNER) ?
8046 @@ -329,7 +405,7 @@ xfs_setattr(
8048 * Change file ownership. Must be the owner or privileged.
8050 - if (mask & (ATTR_UID|ATTR_GID)) {
8051 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
8053 * CAP_FSETID overrides the following restrictions:
8055 @@ -345,6 +421,10 @@ xfs_setattr(
8056 * Change the ownerships and register quota modifications
8057 * in the transaction.
8059 + if (itag != tag) {
8060 + ip->i_d.di_tag = tag;
8061 + inode->i_tag = tag;
8064 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
8065 ASSERT(mask & ATTR_UID);
8066 diff -NurpP --minimal linux-3.0.25/fs/xfs/xfs_vnodeops.h linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_vnodeops.h
8067 --- linux-3.0.25/fs/xfs/xfs_vnodeops.h 2011-05-22 16:17:54.000000000 +0200
8068 +++ linux-3.0.25-vs2.3.2.3/fs/xfs/xfs_vnodeops.h 2011-06-10 22:11:24.000000000 +0200
8069 @@ -13,6 +13,7 @@ struct xfs_inode;
8073 +int xfs_sync_xflags(struct xfs_inode *ip);
8074 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
8075 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
8076 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
8077 diff -NurpP --minimal linux-3.0.25/include/asm-generic/tlb.h linux-3.0.25-vs2.3.2.3/include/asm-generic/tlb.h
8078 --- linux-3.0.25/include/asm-generic/tlb.h 2011-07-22 11:18:10.000000000 +0200
8079 +++ linux-3.0.25-vs2.3.2.3/include/asm-generic/tlb.h 2011-06-10 22:11:24.000000000 +0200
8081 #define _ASM_GENERIC__TLB_H
8083 #include <linux/swap.h>
8084 +#include <linux/vs_memory.h>
8085 #include <asm/pgalloc.h>
8086 #include <asm/tlbflush.h>
8088 diff -NurpP --minimal linux-3.0.25/include/linux/Kbuild linux-3.0.25-vs2.3.2.3/include/linux/Kbuild
8089 --- linux-3.0.25/include/linux/Kbuild 2011-07-22 11:18:10.000000000 +0200
8090 +++ linux-3.0.25-vs2.3.2.3/include/linux/Kbuild 2011-06-10 22:11:24.000000000 +0200
8091 @@ -17,6 +17,7 @@ header-y += netfilter_bridge/
8092 header-y += netfilter_ipv4/
8093 header-y += netfilter_ipv6/
8095 +header-y += vserver/
8098 objhdr-y += version.h
8099 diff -NurpP --minimal linux-3.0.25/include/linux/capability.h linux-3.0.25-vs2.3.2.3/include/linux/capability.h
8100 --- linux-3.0.25/include/linux/capability.h 2011-07-22 11:18:10.000000000 +0200
8101 +++ linux-3.0.25-vs2.3.2.3/include/linux/capability.h 2011-06-10 22:11:24.000000000 +0200
8102 @@ -279,6 +279,7 @@ struct cpu_vfs_cap_data {
8103 arbitrary SCSI commands */
8104 /* Allow setting encryption key on loopback filesystem */
8105 /* Allow setting zone reclaim policy */
8106 +/* Allow the selection of a security context */
8108 #define CAP_SYS_ADMIN 21
8110 @@ -362,7 +363,12 @@ struct cpu_vfs_cap_data {
8112 #define CAP_LAST_CAP CAP_WAKE_ALARM
8114 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8115 +/* Allow context manipulations */
8116 +/* Allow changing context info on files */
8118 +#define CAP_CONTEXT 63
8120 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
8123 * Bit location of each capability (used by user-space library and kernel)
8124 diff -NurpP --minimal linux-3.0.25/include/linux/cred.h linux-3.0.25-vs2.3.2.3/include/linux/cred.h
8125 --- linux-3.0.25/include/linux/cred.h 2011-07-22 11:18:10.000000000 +0200
8126 +++ linux-3.0.25-vs2.3.2.3/include/linux/cred.h 2011-06-10 22:11:24.000000000 +0200
8127 @@ -156,6 +156,7 @@ extern void exit_creds(struct task_struc
8128 extern int copy_creds(struct task_struct *, unsigned long);
8129 extern const struct cred *get_task_cred(struct task_struct *);
8130 extern struct cred *cred_alloc_blank(void);
8131 +extern struct cred *__prepare_creds(const struct cred *);
8132 extern struct cred *prepare_creds(void);
8133 extern struct cred *prepare_exec_creds(void);
8134 extern int commit_creds(struct cred *);
8135 @@ -209,6 +210,31 @@ static inline void validate_process_cred
8139 +static inline void set_cred_subscribers(struct cred *cred, int n)
8141 +#ifdef CONFIG_DEBUG_CREDENTIALS
8142 + atomic_set(&cred->subscribers, n);
8146 +static inline int read_cred_subscribers(const struct cred *cred)
8148 +#ifdef CONFIG_DEBUG_CREDENTIALS
8149 + return atomic_read(&cred->subscribers);
8155 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
8157 +#ifdef CONFIG_DEBUG_CREDENTIALS
8158 + struct cred *cred = (struct cred *) _cred;
8160 + atomic_add(n, &cred->subscribers);
8165 * get_new_cred - Get a reference on a new set of credentials
8166 * @cred: The new credentials to reference
8167 diff -NurpP --minimal linux-3.0.25/include/linux/devpts_fs.h linux-3.0.25-vs2.3.2.3/include/linux/devpts_fs.h
8168 --- linux-3.0.25/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8169 +++ linux-3.0.25-vs2.3.2.3/include/linux/devpts_fs.h 2011-06-10 22:11:24.000000000 +0200
8170 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8175 #endif /* _LINUX_DEVPTS_FS_H */
8176 diff -NurpP --minimal linux-3.0.25/include/linux/ext2_fs.h linux-3.0.25-vs2.3.2.3/include/linux/ext2_fs.h
8177 --- linux-3.0.25/include/linux/ext2_fs.h 2012-03-19 21:16:53.000000000 +0100
8178 +++ linux-3.0.25-vs2.3.2.3/include/linux/ext2_fs.h 2011-11-15 17:37:07.000000000 +0100
8179 @@ -189,8 +189,12 @@ struct ext2_group_desc
8180 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8181 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8182 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8183 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8184 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8186 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8187 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8189 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8190 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8192 @@ -274,7 +278,8 @@ struct ext2_inode {
8194 __le16 l_i_uid_high; /* these 2 fields */
8195 __le16 l_i_gid_high; /* were reserved2[0] */
8196 - __u32 l_i_reserved2;
8197 + __le16 l_i_tag; /* Context Tag */
8198 + __u16 l_i_reserved2;
8201 __u8 h_i_frag; /* Fragment number */
8202 @@ -303,6 +308,7 @@ struct ext2_inode {
8203 #define i_gid_low i_gid
8204 #define i_uid_high osd2.linux2.l_i_uid_high
8205 #define i_gid_high osd2.linux2.l_i_gid_high
8206 +#define i_raw_tag osd2.linux2.l_i_tag
8207 #define i_reserved2 osd2.linux2.l_i_reserved2
8210 @@ -347,6 +353,7 @@ struct ext2_inode {
8211 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8212 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8213 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8214 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8217 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8218 diff -NurpP --minimal linux-3.0.25/include/linux/ext3_fs.h linux-3.0.25-vs2.3.2.3/include/linux/ext3_fs.h
8219 --- linux-3.0.25/include/linux/ext3_fs.h 2012-03-19 21:16:53.000000000 +0100
8220 +++ linux-3.0.25-vs2.3.2.3/include/linux/ext3_fs.h 2011-11-15 17:37:07.000000000 +0100
8221 @@ -173,10 +173,14 @@ struct ext3_group_desc
8222 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8223 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8224 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8225 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8226 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8228 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8229 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8230 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8231 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8233 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8234 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8236 /* Flags that should be inherited by new inodes from their parent. */
8237 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8238 @@ -312,7 +316,8 @@ struct ext3_inode {
8240 __le16 l_i_uid_high; /* these 2 fields */
8241 __le16 l_i_gid_high; /* were reserved2[0] */
8242 - __u32 l_i_reserved2;
8243 + __le16 l_i_tag; /* Context Tag */
8244 + __u16 l_i_reserved2;
8247 __u8 h_i_frag; /* Fragment number */
8248 @@ -343,6 +348,7 @@ struct ext3_inode {
8249 #define i_gid_low i_gid
8250 #define i_uid_high osd2.linux2.l_i_uid_high
8251 #define i_gid_high osd2.linux2.l_i_gid_high
8252 +#define i_raw_tag osd2.linux2.l_i_tag
8253 #define i_reserved2 osd2.linux2.l_i_reserved2
8255 #elif defined(__GNU__)
8256 @@ -405,6 +411,7 @@ struct ext3_inode {
8257 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8258 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8259 * error in ordered mode */
8260 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8262 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8263 #ifndef _LINUX_EXT2_FS_H
8264 @@ -919,6 +926,7 @@ extern void ext3_get_inode_flags(struct
8265 extern void ext3_set_aops(struct inode *inode);
8266 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8267 u64 start, u64 len);
8268 +extern int ext3_sync_flags(struct inode *, int, int);
8271 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8272 diff -NurpP --minimal linux-3.0.25/include/linux/fs.h linux-3.0.25-vs2.3.2.3/include/linux/fs.h
8273 --- linux-3.0.25/include/linux/fs.h 2012-03-19 21:16:53.000000000 +0100
8274 +++ linux-3.0.25-vs2.3.2.3/include/linux/fs.h 2012-03-01 21:51:50.000000000 +0100
8275 @@ -208,6 +208,9 @@ struct inodes_stat_t {
8276 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8277 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8278 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8279 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8280 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8281 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8282 #define MS_NOSEC (1<<28)
8283 #define MS_BORN (1<<29)
8284 #define MS_ACTIVE (1<<30)
8285 @@ -239,6 +242,14 @@ struct inodes_stat_t {
8286 #define S_IMA 1024 /* Inode has an associated IMA struct */
8287 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
8288 #define S_NOSEC 4096 /* no suid or xattr security attributes */
8289 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
8291 +/* Linux-VServer related Inode flags */
8295 +#define V_BARRIER 4 /* Barrier for chroot() */
8296 +#define V_COW 8 /* Copy on Write */
8299 * Note that nosuid etc flags are inode-specific: setting some file-system
8300 @@ -261,12 +272,15 @@ struct inodes_stat_t {
8301 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8302 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8303 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8304 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8305 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8306 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8307 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8308 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8310 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8311 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8312 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8313 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8314 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8315 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8317 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8318 @@ -277,6 +291,16 @@ struct inodes_stat_t {
8319 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
8320 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
8322 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8324 +#ifdef CONFIG_VSERVER_COWBL
8325 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8326 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8328 +# define IS_COW(inode) (0)
8329 +# define IS_COW_LINK(inode) (0)
8332 /* the read-only stuff doesn't really belong here, but any other place is
8333 probably as bad and I don't want to create yet another include file. */
8335 @@ -362,11 +386,14 @@ struct inodes_stat_t {
8336 #define FS_EXTENT_FL 0x00080000 /* Extents */
8337 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8338 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
8339 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8340 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8342 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8343 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8345 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8346 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8348 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8349 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8351 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8352 #define SYNC_FILE_RANGE_WRITE 2
8353 @@ -447,6 +474,7 @@ typedef void (dio_iodone_t)(struct kiocb
8354 #define ATTR_KILL_PRIV (1 << 14)
8355 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8356 #define ATTR_TIMES_SET (1 << 16)
8357 +#define ATTR_TAG (1 << 17)
8360 * This is the Inode Attributes structure, used for notify_change(). It
8361 @@ -462,6 +490,7 @@ struct iattr {
8367 struct timespec ia_atime;
8368 struct timespec ia_mtime;
8369 @@ -475,6 +504,9 @@ struct iattr {
8370 struct file *ia_file;
8373 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8374 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8377 * Includes for diskquotas.
8379 @@ -740,11 +772,13 @@ struct inode {
8384 const struct inode_operations *i_op;
8385 struct super_block *i_sb;
8387 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
8388 - unsigned int i_flags;
8389 + unsigned short i_flags;
8390 + unsigned short i_vflags;
8391 unsigned long i_state;
8392 #ifdef CONFIG_SECURITY
8394 @@ -766,6 +800,7 @@ struct inode {
8396 unsigned int i_nlink;
8399 unsigned int i_blkbits;
8402 @@ -890,12 +925,12 @@ static inline void i_size_write(struct i
8404 static inline unsigned iminor(const struct inode *inode)
8406 - return MINOR(inode->i_rdev);
8407 + return MINOR(inode->i_mdev);
8410 static inline unsigned imajor(const struct inode *inode)
8412 - return MAJOR(inode->i_rdev);
8413 + return MAJOR(inode->i_mdev);
8416 extern struct block_device *I_BDEV(struct inode *inode);
8417 @@ -957,6 +992,7 @@ struct file {
8419 struct fown_struct f_owner;
8420 const struct cred *f_cred;
8422 struct file_ra_state f_ra;
8425 @@ -1102,6 +1138,7 @@ struct file_lock {
8426 struct file *fl_file;
8431 struct fasync_struct * fl_fasync; /* for lease break notifications */
8432 unsigned long fl_break_time; /* for nonblocking lease breaks */
8433 @@ -1601,6 +1638,7 @@ struct inode_operations {
8434 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8435 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8436 int (*removexattr) (struct dentry *, const char *);
8437 + int (*sync_flags) (struct inode *, int, int);
8438 void (*truncate_range)(struct inode *, loff_t, loff_t);
8439 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8441 @@ -1619,6 +1657,7 @@ extern ssize_t vfs_readv(struct file *,
8442 unsigned long, loff_t *);
8443 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8444 unsigned long, loff_t *);
8445 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8447 struct super_operations {
8448 struct inode *(*alloc_inode)(struct super_block *sb);
8449 @@ -2439,6 +2478,7 @@ extern int dcache_dir_open(struct inode
8450 extern int dcache_dir_close(struct inode *, struct file *);
8451 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8452 extern int dcache_readdir(struct file *, void *, filldir_t);
8453 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8454 extern int simple_setattr(struct dentry *, struct iattr *);
8455 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8456 extern int simple_statfs(struct dentry *, struct kstatfs *);
8457 diff -NurpP --minimal linux-3.0.25/include/linux/gfs2_ondisk.h linux-3.0.25-vs2.3.2.3/include/linux/gfs2_ondisk.h
8458 --- linux-3.0.25/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8459 +++ linux-3.0.25-vs2.3.2.3/include/linux/gfs2_ondisk.h 2011-06-10 22:11:24.000000000 +0200
8460 @@ -211,6 +211,9 @@ enum {
8464 + gfs2fl_IXUnlink = 16,
8465 + gfs2fl_Barrier = 17,
8467 gfs2fl_TruncInProg = 29,
8468 gfs2fl_InheritDirectio = 30,
8469 gfs2fl_InheritJdata = 31,
8470 @@ -227,6 +230,9 @@ enum {
8471 #define GFS2_DIF_NOATIME 0x00000080
8472 #define GFS2_DIF_SYNC 0x00000100
8473 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8474 +#define GFS2_DIF_IXUNLINK 0x00010000
8475 +#define GFS2_DIF_BARRIER 0x00020000
8476 +#define GFS2_DIF_COW 0x00040000
8477 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8478 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8479 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8480 diff -NurpP --minimal linux-3.0.25/include/linux/if_tun.h linux-3.0.25-vs2.3.2.3/include/linux/if_tun.h
8481 --- linux-3.0.25/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8482 +++ linux-3.0.25-vs2.3.2.3/include/linux/if_tun.h 2011-06-10 22:11:24.000000000 +0200
8484 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8485 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8486 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8487 +#define TUNSETNID _IOW('T', 217, int)
8489 /* TUNSETIFF ifr flags */
8490 #define IFF_TUN 0x0001
8491 diff -NurpP --minimal linux-3.0.25/include/linux/init_task.h linux-3.0.25-vs2.3.2.3/include/linux/init_task.h
8492 --- linux-3.0.25/include/linux/init_task.h 2011-07-22 11:18:10.000000000 +0200
8493 +++ linux-3.0.25-vs2.3.2.3/include/linux/init_task.h 2011-06-10 22:11:24.000000000 +0200
8494 @@ -193,6 +193,10 @@ extern struct cred init_cred;
8495 INIT_TRACE_RECURSION \
8496 INIT_TASK_RCU_PREEMPT(tsk) \
8499 + .vx_info = NULL, \
8501 + .nx_info = NULL, \
8505 diff -NurpP --minimal linux-3.0.25/include/linux/ipc.h linux-3.0.25-vs2.3.2.3/include/linux/ipc.h
8506 --- linux-3.0.25/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8507 +++ linux-3.0.25-vs2.3.2.3/include/linux/ipc.h 2011-06-10 22:11:24.000000000 +0200
8508 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8516 diff -NurpP --minimal linux-3.0.25/include/linux/ipc_namespace.h linux-3.0.25-vs2.3.2.3/include/linux/ipc_namespace.h
8517 --- linux-3.0.25/include/linux/ipc_namespace.h 2011-05-22 16:17:55.000000000 +0200
8518 +++ linux-3.0.25-vs2.3.2.3/include/linux/ipc_namespace.h 2011-06-13 14:09:44.000000000 +0200
8519 @@ -94,7 +94,8 @@ static inline int mq_init_ns(struct ipc_
8521 #if defined(CONFIG_IPC_NS)
8522 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
8523 - struct task_struct *tsk);
8524 + struct ipc_namespace *old_ns,
8525 + struct user_namespace *user_ns);
8526 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8529 @@ -105,12 +106,13 @@ static inline struct ipc_namespace *get_
8530 extern void put_ipc_ns(struct ipc_namespace *ns);
8532 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
8533 - struct task_struct *tsk)
8534 + struct ipc_namespace *old_ns,
8535 + struct user_namespace *user_ns)
8537 if (flags & CLONE_NEWIPC)
8538 return ERR_PTR(-EINVAL);
8540 - return tsk->nsproxy->ipc_ns;
8544 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8545 diff -NurpP --minimal linux-3.0.25/include/linux/loop.h linux-3.0.25-vs2.3.2.3/include/linux/loop.h
8546 --- linux-3.0.25/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
8547 +++ linux-3.0.25-vs2.3.2.3/include/linux/loop.h 2011-06-10 22:11:24.000000000 +0200
8548 @@ -45,6 +45,7 @@ struct loop_device {
8549 struct loop_func_table *lo_encryption;
8551 uid_t lo_key_owner; /* Who set the key */
8553 int (*ioctl)(struct loop_device *, int cmd,
8556 diff -NurpP --minimal linux-3.0.25/include/linux/magic.h linux-3.0.25-vs2.3.2.3/include/linux/magic.h
8557 --- linux-3.0.25/include/linux/magic.h 2011-05-22 16:17:55.000000000 +0200
8558 +++ linux-3.0.25-vs2.3.2.3/include/linux/magic.h 2011-06-10 22:11:24.000000000 +0200
8561 #define ADFS_SUPER_MAGIC 0xadf5
8562 #define AFFS_SUPER_MAGIC 0xadff
8563 -#define AFS_SUPER_MAGIC 0x5346414F
8564 +#define AFS_SUPER_MAGIC 0x5346414F
8565 #define AUTOFS_SUPER_MAGIC 0x0187
8566 #define CODA_SUPER_MAGIC 0x73757245
8567 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8569 #define NFS_SUPER_MAGIC 0x6969
8570 #define OPENPROM_SUPER_MAGIC 0x9fa1
8571 #define PROC_SUPER_MAGIC 0x9fa0
8572 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8573 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8575 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8576 diff -NurpP --minimal linux-3.0.25/include/linux/major.h linux-3.0.25-vs2.3.2.3/include/linux/major.h
8577 --- linux-3.0.25/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8578 +++ linux-3.0.25-vs2.3.2.3/include/linux/major.h 2011-06-10 22:11:24.000000000 +0200
8580 #define HD_MAJOR IDE0_MAJOR
8581 #define PTY_SLAVE_MAJOR 3
8583 +#define VROOT_MAJOR 4
8584 #define TTYAUX_MAJOR 5
8587 diff -NurpP --minimal linux-3.0.25/include/linux/memcontrol.h linux-3.0.25-vs2.3.2.3/include/linux/memcontrol.h
8588 --- linux-3.0.25/include/linux/memcontrol.h 2012-03-19 21:16:55.000000000 +0100
8589 +++ linux-3.0.25-vs2.3.2.3/include/linux/memcontrol.h 2012-01-26 08:39:53.000000000 +0100
8590 @@ -86,6 +86,13 @@ extern struct mem_cgroup *try_get_mem_cg
8591 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8592 extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
8594 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8595 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8597 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8598 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8599 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8602 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8604 diff -NurpP --minimal linux-3.0.25/include/linux/mm_types.h linux-3.0.25-vs2.3.2.3/include/linux/mm_types.h
8605 --- linux-3.0.25/include/linux/mm_types.h 2012-03-19 21:16:55.000000000 +0100
8606 +++ linux-3.0.25-vs2.3.2.3/include/linux/mm_types.h 2011-11-15 17:37:07.000000000 +0100
8607 @@ -282,6 +282,7 @@ struct mm_struct {
8609 /* Architecture-specific MM context */
8610 mm_context_t context;
8611 + struct vx_info *mm_vx_info;
8613 /* Swap token stuff */
8615 diff -NurpP --minimal linux-3.0.25/include/linux/mmzone.h linux-3.0.25-vs2.3.2.3/include/linux/mmzone.h
8616 --- linux-3.0.25/include/linux/mmzone.h 2011-07-22 11:18:11.000000000 +0200
8617 +++ linux-3.0.25-vs2.3.2.3/include/linux/mmzone.h 2011-07-01 11:35:35.000000000 +0200
8618 @@ -654,6 +654,13 @@ typedef struct pglist_data {
8619 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8622 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
8624 +#define node_end_pfn(nid) ({\
8625 + pg_data_t *__pgdat = NODE_DATA(nid);\
8626 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8629 #include <linux/memory_hotplug.h>
8631 extern struct mutex zonelists_mutex;
8632 diff -NurpP --minimal linux-3.0.25/include/linux/mount.h linux-3.0.25-vs2.3.2.3/include/linux/mount.h
8633 --- linux-3.0.25/include/linux/mount.h 2011-03-15 18:07:39.000000000 +0100
8634 +++ linux-3.0.25-vs2.3.2.3/include/linux/mount.h 2011-06-10 22:11:24.000000000 +0200
8635 @@ -52,6 +52,9 @@ struct mnt_pcp {
8639 +#define MNT_TAGID 0x10000
8640 +#define MNT_NOTAG 0x20000
8643 struct list_head mnt_hash;
8644 struct vfsmount *mnt_parent; /* fs we are mounted on */
8645 @@ -86,6 +89,7 @@ struct vfsmount {
8646 int mnt_expiry_mark; /* true if marked for expiry */
8649 + tag_t mnt_tag; /* tagging used for vfsmount */
8652 struct file; /* forward dec */
8653 diff -NurpP --minimal linux-3.0.25/include/linux/net.h linux-3.0.25-vs2.3.2.3/include/linux/net.h
8654 --- linux-3.0.25/include/linux/net.h 2011-07-22 11:18:11.000000000 +0200
8655 +++ linux-3.0.25-vs2.3.2.3/include/linux/net.h 2011-06-10 22:11:24.000000000 +0200
8656 @@ -72,6 +72,7 @@ struct net;
8657 #define SOCK_NOSPACE 2
8658 #define SOCK_PASSCRED 3
8659 #define SOCK_PASSSEC 4
8660 +#define SOCK_USER_SOCKET 5
8662 #ifndef ARCH_HAS_SOCKET_TYPES
8664 diff -NurpP --minimal linux-3.0.25/include/linux/netdevice.h linux-3.0.25-vs2.3.2.3/include/linux/netdevice.h
8665 --- linux-3.0.25/include/linux/netdevice.h 2012-03-19 21:16:55.000000000 +0100
8666 +++ linux-3.0.25-vs2.3.2.3/include/linux/netdevice.h 2011-09-17 19:22:49.000000000 +0200
8667 @@ -1650,6 +1650,7 @@ extern void netdev_resync_ops(struct ne
8668 extern int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
8669 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
8670 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
8671 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
8672 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
8673 extern int dev_restart(struct net_device *dev);
8674 #ifdef CONFIG_NETPOLL_TRAP
8675 diff -NurpP --minimal linux-3.0.25/include/linux/nfs_mount.h linux-3.0.25-vs2.3.2.3/include/linux/nfs_mount.h
8676 --- linux-3.0.25/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
8677 +++ linux-3.0.25-vs2.3.2.3/include/linux/nfs_mount.h 2011-06-10 22:11:24.000000000 +0200
8678 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8679 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8680 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8681 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8682 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8683 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8684 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8686 /* The following are for internal use only */
8687 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8688 diff -NurpP --minimal linux-3.0.25/include/linux/nsproxy.h linux-3.0.25-vs2.3.2.3/include/linux/nsproxy.h
8689 --- linux-3.0.25/include/linux/nsproxy.h 2011-07-22 11:18:11.000000000 +0200
8690 +++ linux-3.0.25-vs2.3.2.3/include/linux/nsproxy.h 2011-06-10 22:11:24.000000000 +0200
8693 #include <linux/spinlock.h>
8694 #include <linux/sched.h>
8695 +#include <linux/vserver/debug.h>
8697 struct mnt_namespace;
8698 struct uts_namespace;
8699 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
8702 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8703 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8704 void exit_task_namespaces(struct task_struct *tsk);
8705 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8706 void free_nsproxy(struct nsproxy *ns);
8707 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
8708 struct fs_struct *);
8710 -static inline void put_nsproxy(struct nsproxy *ns)
8711 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8713 +static inline void __get_nsproxy(struct nsproxy *ns,
8714 + const char *_file, int _line)
8716 - if (atomic_dec_and_test(&ns->count)) {
8719 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8720 + ns, atomic_read(&ns->count), _file, _line);
8721 + atomic_inc(&ns->count);
8724 -static inline void get_nsproxy(struct nsproxy *ns)
8725 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8727 +static inline void __put_nsproxy(struct nsproxy *ns,
8728 + const char *_file, int _line)
8730 - atomic_inc(&ns->count);
8731 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8732 + ns, atomic_read(&ns->count), _file, _line);
8733 + if (atomic_dec_and_test(&ns->count)) {
8739 diff -NurpP --minimal linux-3.0.25/include/linux/pid.h linux-3.0.25-vs2.3.2.3/include/linux/pid.h
8740 --- linux-3.0.25/include/linux/pid.h 2011-07-22 11:18:11.000000000 +0200
8741 +++ linux-3.0.25-vs2.3.2.3/include/linux/pid.h 2011-06-10 22:11:24.000000000 +0200
8742 @@ -8,7 +8,8 @@ enum pid_type
8752 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
8755 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8756 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8757 pid_t pid_vnr(struct pid *pid);
8759 #define do_each_pid_task(pid, type, task) \
8760 diff -NurpP --minimal linux-3.0.25/include/linux/proc_fs.h linux-3.0.25-vs2.3.2.3/include/linux/proc_fs.h
8761 --- linux-3.0.25/include/linux/proc_fs.h 2011-07-22 11:18:11.000000000 +0200
8762 +++ linux-3.0.25-vs2.3.2.3/include/linux/proc_fs.h 2011-06-10 22:11:24.000000000 +0200
8763 @@ -56,6 +56,7 @@ struct proc_dir_entry {
8769 const struct inode_operations *proc_iops;
8771 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
8772 extern const struct proc_ns_operations utsns_operations;
8773 extern const struct proc_ns_operations ipcns_operations;
8779 int (*proc_get_link)(struct inode *, struct path *);
8780 int (*proc_read)(struct task_struct *task, char *page);
8781 int (*proc_show)(struct seq_file *m,
8782 struct pid_namespace *ns, struct pid *pid,
8783 struct task_struct *task);
8784 + int (*proc_vs_read)(char *page);
8785 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8786 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8789 struct ctl_table_header;
8790 @@ -265,6 +272,7 @@ struct ctl_table;
8797 struct proc_dir_entry *pde;
8798 diff -NurpP --minimal linux-3.0.25/include/linux/quotaops.h linux-3.0.25-vs2.3.2.3/include/linux/quotaops.h
8799 --- linux-3.0.25/include/linux/quotaops.h 2011-05-22 16:17:57.000000000 +0200
8800 +++ linux-3.0.25-vs2.3.2.3/include/linux/quotaops.h 2011-06-10 22:11:24.000000000 +0200
8802 #define _LINUX_QUOTAOPS_
8804 #include <linux/fs.h>
8805 +#include <linux/vs_dlimit.h>
8807 #define DQUOT_SPACE_WARN 0x1
8808 #define DQUOT_SPACE_RESERVE 0x2
8809 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
8811 static inline int dquot_alloc_inode(const struct inode *inode)
8814 + return dl_alloc_inode(inode);
8817 static inline void dquot_free_inode(const struct inode *inode)
8819 + dl_free_inode(inode);
8822 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
8823 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct
8824 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
8829 + if ((ret = dl_alloc_space(inode, number)))
8831 if (!(flags & DQUOT_SPACE_RESERVE))
8832 inode_add_bytes(inode, number);
8834 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
8836 if (!(flags & DQUOT_SPACE_RESERVE))
8837 inode_sub_bytes(inode, number);
8838 + dl_free_space(inode, number);
8841 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
8842 diff -NurpP --minimal linux-3.0.25/include/linux/reboot.h linux-3.0.25-vs2.3.2.3/include/linux/reboot.h
8843 --- linux-3.0.25/include/linux/reboot.h 2010-07-07 18:31:56.000000000 +0200
8844 +++ linux-3.0.25-vs2.3.2.3/include/linux/reboot.h 2011-06-10 22:11:24.000000000 +0200
8846 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
8847 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
8848 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
8849 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
8853 diff -NurpP --minimal linux-3.0.25/include/linux/reiserfs_fs.h linux-3.0.25-vs2.3.2.3/include/linux/reiserfs_fs.h
8854 --- linux-3.0.25/include/linux/reiserfs_fs.h 2011-05-22 16:17:58.000000000 +0200
8855 +++ linux-3.0.25-vs2.3.2.3/include/linux/reiserfs_fs.h 2011-06-10 22:11:24.000000000 +0200
8856 @@ -976,6 +976,11 @@ struct stat_data_v1 {
8857 #define REISERFS_COMPR_FL FS_COMPR_FL
8858 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
8860 +/* unfortunately reiserfs sdattr is only 16 bit */
8861 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
8862 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
8863 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
8865 /* persistent flags that file inherits from the parent directory */
8866 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
8867 REISERFS_SYNC_FL | \
8868 @@ -985,6 +990,9 @@ struct stat_data_v1 {
8869 REISERFS_COMPR_FL | \
8870 REISERFS_NOTAIL_FL )
8872 +#define REISERFS_FL_USER_VISIBLE 0x80FF
8873 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
8875 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
8878 @@ -2073,6 +2081,7 @@ static inline void reiserfs_update_sd(st
8879 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
8880 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
8881 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
8882 +int reiserfs_sync_flags(struct inode *inode, int, int);
8884 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
8886 diff -NurpP --minimal linux-3.0.25/include/linux/reiserfs_fs_sb.h linux-3.0.25-vs2.3.2.3/include/linux/reiserfs_fs_sb.h
8887 --- linux-3.0.25/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
8888 +++ linux-3.0.25-vs2.3.2.3/include/linux/reiserfs_fs_sb.h 2011-06-10 22:11:24.000000000 +0200
8889 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
8890 REISERFS_EXPOSE_PRIVROOT,
8891 REISERFS_BARRIER_NONE,
8892 REISERFS_BARRIER_FLUSH,
8895 /* Actions on error */
8896 REISERFS_ERROR_PANIC,
8897 diff -NurpP --minimal linux-3.0.25/include/linux/sched.h linux-3.0.25-vs2.3.2.3/include/linux/sched.h
8898 --- linux-3.0.25/include/linux/sched.h 2012-03-19 21:16:55.000000000 +0100
8899 +++ linux-3.0.25-vs2.3.2.3/include/linux/sched.h 2011-10-18 13:51:13.000000000 +0200
8900 @@ -1406,6 +1406,14 @@ struct task_struct {
8904 +/* vserver context data */
8905 + struct vx_info *vx_info;
8906 + struct nx_info *nx_info;
8912 /* Thread group tracking */
8915 @@ -1649,6 +1657,11 @@ struct pid_namespace;
8916 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
8917 struct pid_namespace *ns);
8919 +#include <linux/vserver/base.h>
8920 +#include <linux/vserver/context.h>
8921 +#include <linux/vserver/debug.h>
8922 +#include <linux/vserver/pid.h>
8924 static inline pid_t task_pid_nr(struct task_struct *tsk)
8927 @@ -1662,7 +1675,8 @@ static inline pid_t task_pid_nr_ns(struc
8929 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8931 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8932 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8933 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8937 @@ -1675,7 +1689,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8939 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8941 - return pid_vnr(task_tgid(tsk));
8942 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8946 diff -NurpP --minimal linux-3.0.25/include/linux/shmem_fs.h linux-3.0.25-vs2.3.2.3/include/linux/shmem_fs.h
8947 --- linux-3.0.25/include/linux/shmem_fs.h 2011-07-22 11:18:11.000000000 +0200
8948 +++ linux-3.0.25-vs2.3.2.3/include/linux/shmem_fs.h 2011-07-01 11:35:35.000000000 +0200
8951 #define SHMEM_SYMLINK_INLINE_LEN (SHMEM_NR_DIRECT * sizeof(swp_entry_t))
8953 +#define TMPFS_SUPER_MAGIC 0x01021994
8956 struct shmem_inode_info {
8958 unsigned long flags;
8959 diff -NurpP --minimal linux-3.0.25/include/linux/stat.h linux-3.0.25-vs2.3.2.3/include/linux/stat.h
8960 --- linux-3.0.25/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
8961 +++ linux-3.0.25-vs2.3.2.3/include/linux/stat.h 2011-06-10 22:11:24.000000000 +0200
8962 @@ -66,6 +66,7 @@ struct kstat {
8969 struct timespec atime;
8970 diff -NurpP --minimal linux-3.0.25/include/linux/sunrpc/auth.h linux-3.0.25-vs2.3.2.3/include/linux/sunrpc/auth.h
8971 --- linux-3.0.25/include/linux/sunrpc/auth.h 2011-03-15 18:07:39.000000000 +0100
8972 +++ linux-3.0.25-vs2.3.2.3/include/linux/sunrpc/auth.h 2011-06-10 22:11:24.000000000 +0200
8978 struct group_info *group_info;
8979 unsigned char machine_cred : 1;
8981 diff -NurpP --minimal linux-3.0.25/include/linux/sunrpc/clnt.h linux-3.0.25-vs2.3.2.3/include/linux/sunrpc/clnt.h
8982 --- linux-3.0.25/include/linux/sunrpc/clnt.h 2011-05-22 16:17:58.000000000 +0200
8983 +++ linux-3.0.25-vs2.3.2.3/include/linux/sunrpc/clnt.h 2011-06-10 22:11:24.000000000 +0200
8984 @@ -49,7 +49,8 @@ struct rpc_clnt {
8985 unsigned int cl_softrtry : 1,/* soft timeouts */
8986 cl_discrtry : 1,/* disconnect before retry */
8987 cl_autobind : 1,/* use getport() */
8988 - cl_chatty : 1;/* be verbose */
8989 + cl_chatty : 1,/* be verbose */
8990 + cl_tag : 1;/* context tagging */
8992 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8993 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8994 diff -NurpP --minimal linux-3.0.25/include/linux/syscalls.h linux-3.0.25-vs2.3.2.3/include/linux/syscalls.h
8995 --- linux-3.0.25/include/linux/syscalls.h 2011-07-22 11:18:11.000000000 +0200
8996 +++ linux-3.0.25-vs2.3.2.3/include/linux/syscalls.h 2011-06-10 22:11:24.000000000 +0200
8997 @@ -483,6 +483,8 @@ asmlinkage long sys_symlink(const char _
8998 asmlinkage long sys_unlink(const char __user *pathname);
8999 asmlinkage long sys_rename(const char __user *oldname,
9000 const char __user *newname);
9001 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
9003 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
9004 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
9006 diff -NurpP --minimal linux-3.0.25/include/linux/sysctl.h linux-3.0.25-vs2.3.2.3/include/linux/sysctl.h
9007 --- linux-3.0.25/include/linux/sysctl.h 2011-03-15 18:07:40.000000000 +0100
9008 +++ linux-3.0.25-vs2.3.2.3/include/linux/sysctl.h 2011-06-10 22:11:24.000000000 +0200
9009 @@ -60,6 +60,7 @@ enum
9010 CTL_ABI=9, /* Binary emulation */
9011 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
9012 CTL_ARLAN=254, /* arlan wireless driver */
9013 + CTL_VSERVER=4242, /* Linux-VServer debug */
9014 CTL_S390DBF=5677, /* s390 debug */
9015 CTL_SUNRPC=7249, /* sunrpc debug */
9016 CTL_PM=9899, /* frv power management */
9017 @@ -94,6 +95,7 @@ enum
9019 KERN_PANIC=15, /* int: panic timeout */
9020 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
9021 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9023 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9024 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9025 diff -NurpP --minimal linux-3.0.25/include/linux/sysfs.h linux-3.0.25-vs2.3.2.3/include/linux/sysfs.h
9026 --- linux-3.0.25/include/linux/sysfs.h 2011-07-22 11:18:11.000000000 +0200
9027 +++ linux-3.0.25-vs2.3.2.3/include/linux/sysfs.h 2011-06-22 12:39:15.000000000 +0200
9029 #include <linux/kobject_ns.h>
9030 #include <asm/atomic.h>
9032 +#define SYSFS_SUPER_MAGIC 0x62656572
9037 diff -NurpP --minimal linux-3.0.25/include/linux/time.h linux-3.0.25-vs2.3.2.3/include/linux/time.h
9038 --- linux-3.0.25/include/linux/time.h 2011-07-22 11:18:11.000000000 +0200
9039 +++ linux-3.0.25-vs2.3.2.3/include/linux/time.h 2011-06-10 22:11:24.000000000 +0200
9040 @@ -256,6 +256,9 @@ static __always_inline void timespec_add
9041 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9045 +#include <linux/vs_time.h>
9047 #endif /* __KERNEL__ */
9049 #define NFDBITS __NFDBITS
9050 diff -NurpP --minimal linux-3.0.25/include/linux/types.h linux-3.0.25-vs2.3.2.3/include/linux/types.h
9051 --- linux-3.0.25/include/linux/types.h 2011-05-22 16:17:58.000000000 +0200
9052 +++ linux-3.0.25-vs2.3.2.3/include/linux/types.h 2011-06-10 22:11:24.000000000 +0200
9053 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
9054 typedef __kernel_gid32_t gid_t;
9055 typedef __kernel_uid16_t uid16_t;
9056 typedef __kernel_gid16_t gid16_t;
9057 +typedef unsigned int xid_t;
9058 +typedef unsigned int nid_t;
9059 +typedef unsigned int tag_t;
9061 typedef unsigned long uintptr_t;
9063 diff -NurpP --minimal linux-3.0.25/include/linux/utsname.h linux-3.0.25-vs2.3.2.3/include/linux/utsname.h
9064 --- linux-3.0.25/include/linux/utsname.h 2011-05-22 16:17:58.000000000 +0200
9065 +++ linux-3.0.25-vs2.3.2.3/include/linux/utsname.h 2011-06-13 14:36:48.000000000 +0200
9066 @@ -54,7 +54,8 @@ static inline void get_uts_ns(struct uts
9069 extern struct uts_namespace *copy_utsname(unsigned long flags,
9070 - struct task_struct *tsk);
9071 + struct uts_namespace *old_ns,
9072 + struct user_namespace *user_ns);
9073 extern void free_uts_ns(struct kref *kref);
9075 static inline void put_uts_ns(struct uts_namespace *ns)
9076 @@ -71,12 +72,13 @@ static inline void put_uts_ns(struct uts
9079 static inline struct uts_namespace *copy_utsname(unsigned long flags,
9080 - struct task_struct *tsk)
9081 + struct uts_namespace *old_ns,
9082 + struct user_namespace *user_ns)
9084 if (flags & CLONE_NEWUTS)
9085 return ERR_PTR(-EINVAL);
9087 - return tsk->nsproxy->uts_ns;
9092 diff -NurpP --minimal linux-3.0.25/include/linux/vroot.h linux-3.0.25-vs2.3.2.3/include/linux/vroot.h
9093 --- linux-3.0.25/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9094 +++ linux-3.0.25-vs2.3.2.3/include/linux/vroot.h 2011-06-10 22:11:24.000000000 +0200
9098 + * include/linux/vroot.h
9100 + * written by Herbert Pötzl, 9/11/2002
9101 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9103 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9104 + * Redistribution of this file is permitted under the
9105 + * GNU General Public License.
9108 +#ifndef _LINUX_VROOT_H
9109 +#define _LINUX_VROOT_H
9114 +/* Possible states of device */
9120 +struct vroot_device {
9124 + struct semaphore vr_ctl_mutex;
9125 + struct block_device *vr_device;
9130 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9132 +extern int register_vroot_grb(vroot_grb_func *);
9133 +extern int unregister_vroot_grb(vroot_grb_func *);
9135 +#endif /* __KERNEL__ */
9137 +#define MAX_VROOT_DEFAULT 8
9140 + * IOCTL commands --- we will commandeer 0x56 ('V')
9143 +#define VROOT_SET_DEV 0x5600
9144 +#define VROOT_CLR_DEV 0x5601
9146 +#endif /* _LINUX_VROOT_H */
9147 diff -NurpP --minimal linux-3.0.25/include/linux/vs_base.h linux-3.0.25-vs2.3.2.3/include/linux/vs_base.h
9148 --- linux-3.0.25/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9149 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_base.h 2011-06-10 22:11:24.000000000 +0200
9154 +#include "vserver/base.h"
9155 +#include "vserver/check.h"
9156 +#include "vserver/debug.h"
9159 +#warning duplicate inclusion
9161 diff -NurpP --minimal linux-3.0.25/include/linux/vs_context.h linux-3.0.25-vs2.3.2.3/include/linux/vs_context.h
9162 --- linux-3.0.25/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9163 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_context.h 2011-06-10 22:11:24.000000000 +0200
9165 +#ifndef _VS_CONTEXT_H
9166 +#define _VS_CONTEXT_H
9168 +#include "vserver/base.h"
9169 +#include "vserver/check.h"
9170 +#include "vserver/context.h"
9171 +#include "vserver/history.h"
9172 +#include "vserver/debug.h"
9174 +#include <linux/sched.h>
9177 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9179 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9180 + const char *_file, int _line, void *_here)
9185 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9186 + vxi, vxi ? vxi->vx_id : 0,
9187 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9189 + __vxh_get_vx_info(vxi, _here);
9191 + atomic_inc(&vxi->vx_usecnt);
9196 +extern void free_vx_info(struct vx_info *);
9198 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9200 +static inline void __put_vx_info(struct vx_info *vxi,
9201 + const char *_file, int _line, void *_here)
9206 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9207 + vxi, vxi ? vxi->vx_id : 0,
9208 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9210 + __vxh_put_vx_info(vxi, _here);
9212 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9213 + free_vx_info(vxi);
9217 +#define init_vx_info(p, i) \
9218 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9220 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9221 + const char *_file, int _line, void *_here)
9224 + vxlprintk(VXD_CBIT(xid, 3),
9225 + "init_vx_info(%p[#%d.%d])",
9226 + vxi, vxi ? vxi->vx_id : 0,
9227 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9229 + __vxh_init_vx_info(vxi, vxp, _here);
9231 + atomic_inc(&vxi->vx_usecnt);
9237 +#define set_vx_info(p, i) \
9238 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9240 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9241 + const char *_file, int _line, void *_here)
9243 + struct vx_info *vxo;
9248 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9249 + vxi, vxi ? vxi->vx_id : 0,
9250 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9252 + __vxh_set_vx_info(vxi, vxp, _here);
9254 + atomic_inc(&vxi->vx_usecnt);
9255 + vxo = xchg(vxp, vxi);
9260 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9262 +static inline void __clr_vx_info(struct vx_info **vxp,
9263 + const char *_file, int _line, void *_here)
9265 + struct vx_info *vxo;
9267 + vxo = xchg(vxp, NULL);
9271 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9272 + vxo, vxo ? vxo->vx_id : 0,
9273 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9275 + __vxh_clr_vx_info(vxo, vxp, _here);
9277 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9278 + free_vx_info(vxo);
9282 +#define claim_vx_info(v, p) \
9283 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9285 +static inline void __claim_vx_info(struct vx_info *vxi,
9286 + struct task_struct *task,
9287 + const char *_file, int _line, void *_here)
9289 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9290 + vxi, vxi ? vxi->vx_id : 0,
9291 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9292 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9293 + task, _file, _line);
9294 + __vxh_claim_vx_info(vxi, task, _here);
9296 + atomic_inc(&vxi->vx_tasks);
9300 +extern void unhash_vx_info(struct vx_info *);
9302 +#define release_vx_info(v, p) \
9303 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9305 +static inline void __release_vx_info(struct vx_info *vxi,
9306 + struct task_struct *task,
9307 + const char *_file, int _line, void *_here)
9309 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9310 + vxi, vxi ? vxi->vx_id : 0,
9311 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9312 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9313 + task, _file, _line);
9314 + __vxh_release_vx_info(vxi, task, _here);
9318 + if (atomic_dec_and_test(&vxi->vx_tasks))
9319 + unhash_vx_info(vxi);
9323 +#define task_get_vx_info(p) \
9324 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9326 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9327 + const char *_file, int _line, void *_here)
9329 + struct vx_info *vxi;
9332 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9334 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9340 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9342 + if (waitqueue_active(&vxi->vx_wait))
9343 + wake_up_interruptible(&vxi->vx_wait);
9347 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9349 +static inline void __enter_vx_info(struct vx_info *vxi,
9350 + struct vx_info_save *vxis, const char *_file, int _line)
9352 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9353 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9354 + current->xid, current->vx_info, _file, _line);
9355 + vxis->vxi = xchg(¤t->vx_info, vxi);
9356 + vxis->xid = current->xid;
9357 + current->xid = vxi ? vxi->vx_id : 0;
9360 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9362 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9363 + const char *_file, int _line)
9365 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9366 + vxis, vxis->xid, vxis->vxi, current,
9367 + current->xid, current->vx_info, _file, _line);
9368 + (void)xchg(¤t->vx_info, vxis->vxi);
9369 + current->xid = vxis->xid;
9373 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9375 + vxis->vxi = xchg(¤t->vx_info, NULL);
9376 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9379 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9381 + (void)xchg(¤t->xid, vxis->xid);
9382 + (void)xchg(¤t->vx_info, vxis->vxi);
9385 +#define task_is_init(p) \
9386 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9388 +static inline int __task_is_init(struct task_struct *p,
9389 + const char *_file, int _line, void *_here)
9391 + int is_init = is_global_init(p);
9395 + is_init = p->vx_info->vx_initpid == p->pid;
9400 +extern void exit_vx_info(struct task_struct *, int);
9401 +extern void exit_vx_info_early(struct task_struct *, int);
9405 +#warning duplicate inclusion
9407 diff -NurpP --minimal linux-3.0.25/include/linux/vs_cowbl.h linux-3.0.25-vs2.3.2.3/include/linux/vs_cowbl.h
9408 --- linux-3.0.25/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9409 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_cowbl.h 2011-06-10 22:11:24.000000000 +0200
9411 +#ifndef _VS_COWBL_H
9412 +#define _VS_COWBL_H
9414 +#include <linux/fs.h>
9415 +#include <linux/dcache.h>
9416 +#include <linux/namei.h>
9417 +#include <linux/slab.h>
9419 +extern struct dentry *cow_break_link(const char *pathname);
9421 +static inline int cow_check_and_break(struct path *path)
9423 + struct inode *inode = path->dentry->d_inode;
9426 + /* do we need this check? */
9427 + if (IS_RDONLY(inode))
9430 + if (IS_COW(inode)) {
9431 + if (IS_COW_LINK(inode)) {
9432 + struct dentry *new_dentry, *old_dentry = path->dentry;
9435 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9439 + pp = d_path(path, buf, PATH_MAX);
9440 + new_dentry = cow_break_link(pp);
9442 + if (!IS_ERR(new_dentry)) {
9443 + path->dentry = new_dentry;
9446 + error = PTR_ERR(new_dentry);
9448 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9449 + inode->i_ctime = CURRENT_TIME;
9450 + mark_inode_dirty(inode);
9457 +#warning duplicate inclusion
9459 diff -NurpP --minimal linux-3.0.25/include/linux/vs_cvirt.h linux-3.0.25-vs2.3.2.3/include/linux/vs_cvirt.h
9460 --- linux-3.0.25/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9461 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_cvirt.h 2011-06-10 22:11:24.000000000 +0200
9463 +#ifndef _VS_CVIRT_H
9464 +#define _VS_CVIRT_H
9466 +#include "vserver/cvirt.h"
9467 +#include "vserver/context.h"
9468 +#include "vserver/base.h"
9469 +#include "vserver/check.h"
9470 +#include "vserver/debug.h"
9473 +static inline void vx_activate_task(struct task_struct *p)
9475 + struct vx_info *vxi;
9477 + if ((vxi = p->vx_info)) {
9478 + vx_update_load(vxi);
9479 + atomic_inc(&vxi->cvirt.nr_running);
9483 +static inline void vx_deactivate_task(struct task_struct *p)
9485 + struct vx_info *vxi;
9487 + if ((vxi = p->vx_info)) {
9488 + vx_update_load(vxi);
9489 + atomic_dec(&vxi->cvirt.nr_running);
9493 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9495 + struct vx_info *vxi;
9497 + if ((vxi = p->vx_info))
9498 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9501 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9503 + struct vx_info *vxi;
9505 + if ((vxi = p->vx_info))
9506 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9511 +#warning duplicate inclusion
9513 diff -NurpP --minimal linux-3.0.25/include/linux/vs_device.h linux-3.0.25-vs2.3.2.3/include/linux/vs_device.h
9514 --- linux-3.0.25/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9515 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_device.h 2011-06-10 22:11:24.000000000 +0200
9517 +#ifndef _VS_DEVICE_H
9518 +#define _VS_DEVICE_H
9520 +#include "vserver/base.h"
9521 +#include "vserver/device.h"
9522 +#include "vserver/debug.h"
9525 +#ifdef CONFIG_VSERVER_DEVICE
9527 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9529 +#define vs_device_perm(v, d, m, p) \
9530 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9535 +int vs_map_device(struct vx_info *vxi,
9536 + dev_t device, dev_t *target, umode_t mode)
9543 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9548 +#define vs_map_chrdev(d, t, p) \
9549 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9550 +#define vs_map_blkdev(d, t, p) \
9551 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9553 +#define vs_chrdev_perm(d, p) \
9554 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9555 +#define vs_blkdev_perm(d, p) \
9556 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9560 +#warning duplicate inclusion
9562 diff -NurpP --minimal linux-3.0.25/include/linux/vs_dlimit.h linux-3.0.25-vs2.3.2.3/include/linux/vs_dlimit.h
9563 --- linux-3.0.25/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9564 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_dlimit.h 2011-06-10 22:11:24.000000000 +0200
9566 +#ifndef _VS_DLIMIT_H
9567 +#define _VS_DLIMIT_H
9569 +#include <linux/fs.h>
9571 +#include "vserver/dlimit.h"
9572 +#include "vserver/base.h"
9573 +#include "vserver/debug.h"
9576 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9578 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9579 + const char *_file, int _line)
9583 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9584 + dli, dli ? dli->dl_tag : 0,
9585 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9587 + atomic_inc(&dli->dl_usecnt);
9592 +#define free_dl_info(i) \
9593 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9595 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9597 +static inline void __put_dl_info(struct dl_info *dli,
9598 + const char *_file, int _line)
9602 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9603 + dli, dli ? dli->dl_tag : 0,
9604 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9606 + if (atomic_dec_and_test(&dli->dl_usecnt))
9607 + free_dl_info(dli);
9611 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9613 +static inline int __dl_alloc_space(struct super_block *sb,
9614 + tag_t tag, dlsize_t nr, const char *file, int line)
9616 + struct dl_info *dli = NULL;
9621 + dli = locate_dl_info(sb, tag);
9625 + spin_lock(&dli->dl_lock);
9626 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9628 + dli->dl_space_used += nr;
9629 + spin_unlock(&dli->dl_lock);
9632 + vxlprintk(VXD_CBIT(dlim, 1),
9633 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9634 + sb, tag, __dlimit_char(dli), (long long)nr,
9636 + return ret ? -ENOSPC : 0;
9639 +static inline void __dl_free_space(struct super_block *sb,
9640 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9642 + struct dl_info *dli = NULL;
9646 + dli = locate_dl_info(sb, tag);
9650 + spin_lock(&dli->dl_lock);
9651 + if (dli->dl_space_used > nr)
9652 + dli->dl_space_used -= nr;
9654 + dli->dl_space_used = 0;
9655 + spin_unlock(&dli->dl_lock);
9658 + vxlprintk(VXD_CBIT(dlim, 1),
9659 + "FREE (%p,#%d)%c %lld bytes",
9660 + sb, tag, __dlimit_char(dli), (long long)nr,
9664 +static inline int __dl_alloc_inode(struct super_block *sb,
9665 + tag_t tag, const char *_file, int _line)
9667 + struct dl_info *dli;
9670 + dli = locate_dl_info(sb, tag);
9674 + spin_lock(&dli->dl_lock);
9675 + dli->dl_inodes_used++;
9676 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9677 + spin_unlock(&dli->dl_lock);
9680 + vxlprintk(VXD_CBIT(dlim, 0),
9681 + "ALLOC (%p,#%d)%c inode (%d)",
9682 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9683 + return ret ? -ENOSPC : 0;
9686 +static inline void __dl_free_inode(struct super_block *sb,
9687 + tag_t tag, const char *_file, int _line)
9689 + struct dl_info *dli;
9691 + dli = locate_dl_info(sb, tag);
9695 + spin_lock(&dli->dl_lock);
9696 + if (dli->dl_inodes_used > 1)
9697 + dli->dl_inodes_used--;
9699 + dli->dl_inodes_used = 0;
9700 + spin_unlock(&dli->dl_lock);
9703 + vxlprintk(VXD_CBIT(dlim, 0),
9704 + "FREE (%p,#%d)%c inode",
9705 + sb, tag, __dlimit_char(dli), _file, _line);
9708 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
9709 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9710 + const char *_file, int _line)
9712 + struct dl_info *dli;
9713 + uint64_t broot, bfree;
9715 + dli = locate_dl_info(sb, tag);
9719 + spin_lock(&dli->dl_lock);
9720 + broot = (dli->dl_space_total -
9721 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
9722 + >> sb->s_blocksize_bits;
9723 + bfree = (dli->dl_space_total - dli->dl_space_used)
9724 + >> sb->s_blocksize_bits;
9725 + spin_unlock(&dli->dl_lock);
9727 + vxlprintk(VXD_CBIT(dlim, 2),
9728 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
9729 + (long long)bfree, (long long)broot,
9730 + *free_blocks, *root_blocks, dli->dl_nrlmult,
9732 + if (free_blocks) {
9733 + if (*free_blocks > bfree)
9734 + *free_blocks = bfree;
9736 + if (root_blocks) {
9737 + if (*root_blocks > broot)
9738 + *root_blocks = broot;
9743 +#define dl_prealloc_space(in, bytes) \
9744 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9745 + __FILE__, __LINE__ )
9747 +#define dl_alloc_space(in, bytes) \
9748 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9749 + __FILE__, __LINE__ )
9751 +#define dl_reserve_space(in, bytes) \
9752 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9753 + __FILE__, __LINE__ )
9755 +#define dl_claim_space(in, bytes) (0)
9757 +#define dl_release_space(in, bytes) \
9758 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9759 + __FILE__, __LINE__ )
9761 +#define dl_free_space(in, bytes) \
9762 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9763 + __FILE__, __LINE__ )
9767 +#define dl_alloc_inode(in) \
9768 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9770 +#define dl_free_inode(in) \
9771 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9774 +#define dl_adjust_block(sb, tag, fb, rb) \
9775 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
9779 +#warning duplicate inclusion
9781 diff -NurpP --minimal linux-3.0.25/include/linux/vs_inet.h linux-3.0.25-vs2.3.2.3/include/linux/vs_inet.h
9782 --- linux-3.0.25/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
9783 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_inet.h 2011-08-18 17:01:00.000000000 +0200
9788 +#include "vserver/base.h"
9789 +#include "vserver/network.h"
9790 +#include "vserver/debug.h"
9792 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
9794 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
9795 + NIPQUAD((a)->mask), (a)->type
9796 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
9798 +#define NIPQUAD(addr) \
9799 + ((unsigned char *)&addr)[0], \
9800 + ((unsigned char *)&addr)[1], \
9801 + ((unsigned char *)&addr)[2], \
9802 + ((unsigned char *)&addr)[3]
9804 +#define NIPQUAD_FMT "%u.%u.%u.%u"
9808 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
9810 + __be32 ip = nxa->ip[0].s_addr;
9811 + __be32 mask = nxa->mask.s_addr;
9812 + __be32 bcast = ip | ~mask;
9815 + switch (nxa->type & tmask) {
9816 + case NXA_TYPE_MASK:
9817 + ret = (ip == (addr & mask));
9819 + case NXA_TYPE_ADDR:
9823 + /* fall through to broadcast */
9824 + case NXA_MOD_BCAST:
9825 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
9827 + case NXA_TYPE_RANGE:
9828 + ret = ((nxa->ip[0].s_addr <= addr) &&
9829 + (nxa->ip[1].s_addr > addr));
9831 + case NXA_TYPE_ANY:
9836 + vxdprintk(VXD_CBIT(net, 0),
9837 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
9838 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
9843 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
9845 + struct nx_addr_v4 *nxa;
9852 + /* allow 127.0.0.1 when remapping lback */
9853 + if ((tmask & NXA_LOOPBACK) &&
9854 + (addr == IPI_LOOPBACK) &&
9855 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9858 + /* check for lback address */
9859 + if ((tmask & NXA_MOD_LBACK) &&
9860 + (nxi->v4_lback.s_addr == addr))
9863 + /* check for broadcast address */
9864 + if ((tmask & NXA_MOD_BCAST) &&
9865 + (nxi->v4_bcast.s_addr == addr))
9868 + /* check for v4 addresses */
9869 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9870 + if (v4_addr_match(nxa, addr, tmask))
9874 + vxdprintk(VXD_CBIT(net, 0),
9875 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9876 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9881 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9883 + /* FIXME: needs full range checks */
9884 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9888 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9890 + struct nx_addr_v4 *ptr;
9892 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9893 + if (v4_nx_addr_match(ptr, nxa, mask))
9898 +#include <net/inet_sock.h>
9901 + * Check if a given address matches for a socket
9903 + * nxi: the socket's nx_info if any
9904 + * addr: to be verified address
9907 +int v4_sock_addr_match (
9908 + struct nx_info *nxi,
9909 + struct inet_sock *inet,
9912 + __be32 saddr = inet->inet_rcv_saddr;
9913 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9915 + if (addr && (saddr == addr || bcast == addr))
9918 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9923 +/* inet related checks and helpers */
9932 +#include <linux/netdevice.h>
9933 +#include <linux/inetdevice.h>
9934 +#include <net/inet_sock.h>
9935 +#include <net/inet_timewait_sock.h>
9938 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9939 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9940 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9944 + * check if address is covered by socket
9946 + * sk: the socket to check against
9947 + * addr: the address in question (must be != 0)
9951 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9953 + struct nx_info *nxi = sk->sk_nx_info;
9954 + __be32 saddr = sk_rcv_saddr(sk);
9956 + vxdprintk(VXD_CBIT(net, 5),
9957 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9958 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9959 + (sk->sk_socket?sk->sk_socket->flags:0));
9961 + if (saddr) { /* direct address match */
9962 + return v4_addr_match(nxa, saddr, -1);
9963 + } else if (nxi) { /* match against nx_info */
9964 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9965 + } else { /* unrestricted any socket */
9973 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9975 + vxdprintk(VXD_CBIT(net, 1),
9976 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9977 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9978 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9980 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9982 + if (dev_in_nx_info(dev, nxi))
9989 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9995 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9999 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
10001 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
10002 + nxi, nxi ? nxi->nx_id : 0, ifa,
10003 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
10005 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10007 + if (v4_ifa_in_nx_info(ifa, nxi))
10013 +struct nx_v4_sock_addr {
10014 + __be32 saddr; /* Address used for validation */
10015 + __be32 baddr; /* Address used for socket bind */
10019 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
10020 + struct nx_v4_sock_addr *nsa)
10022 + struct sock *sk = &inet->sk;
10023 + struct nx_info *nxi = sk->sk_nx_info;
10024 + __be32 saddr = addr->sin_addr.s_addr;
10025 + __be32 baddr = saddr;
10027 + vxdprintk(VXD_CBIT(net, 3),
10028 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
10029 + sk, sk->sk_nx_info, sk->sk_socket,
10030 + (sk->sk_socket ? sk->sk_socket->flags : 0),
10034 + if (saddr == INADDR_ANY) {
10035 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
10036 + baddr = nxi->v4.ip[0].s_addr;
10037 + } else if (saddr == IPI_LOOPBACK) {
10038 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10039 + baddr = nxi->v4_lback.s_addr;
10040 + } else if (!ipv4_is_multicast(saddr) ||
10041 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
10042 + /* normal address bind */
10043 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
10044 + return -EADDRNOTAVAIL;
10048 + vxdprintk(VXD_CBIT(net, 3),
10049 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
10050 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
10052 + nsa->saddr = saddr;
10053 + nsa->baddr = baddr;
10058 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
10060 + inet->inet_saddr = nsa->baddr;
10061 + inet->inet_rcv_saddr = nsa->baddr;
10066 + * helper to simplify inet_lookup_listener
10068 + * nxi: the socket's nx_info if any
10069 + * addr: to be verified address
10070 + * saddr: socket address
10072 +static inline int v4_inet_addr_match (
10073 + struct nx_info *nxi,
10077 + if (addr && (saddr == addr))
10080 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
10084 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
10086 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
10087 + (addr == nxi->v4_lback.s_addr))
10088 + return IPI_LOOPBACK;
10093 +int nx_info_has_v4(struct nx_info *nxi)
10097 + if (NX_IPV4(nxi))
10099 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10104 +#else /* CONFIG_INET */
10107 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
10113 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10119 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10125 +int nx_info_has_v4(struct nx_info *nxi)
10130 +#endif /* CONFIG_INET */
10132 +#define current_nx_info_has_v4() \
10133 + nx_info_has_v4(current_nx_info())
10136 +// #warning duplicate inclusion
10138 diff -NurpP --minimal linux-3.0.25/include/linux/vs_inet6.h linux-3.0.25-vs2.3.2.3/include/linux/vs_inet6.h
10139 --- linux-3.0.25/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
10140 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_inet6.h 2011-06-10 22:11:24.000000000 +0200
10142 +#ifndef _VS_INET6_H
10143 +#define _VS_INET6_H
10145 +#include "vserver/base.h"
10146 +#include "vserver/network.h"
10147 +#include "vserver/debug.h"
10149 +#include <net/ipv6.h>
10151 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
10152 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
10155 +#ifdef CONFIG_IPV6
10158 +int v6_addr_match(struct nx_addr_v6 *nxa,
10159 + const struct in6_addr *addr, uint16_t mask)
10163 + switch (nxa->type & mask) {
10164 + case NXA_TYPE_MASK:
10165 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
10167 + case NXA_TYPE_ADDR:
10168 + ret = ipv6_addr_equal(&nxa->ip, addr);
10170 + case NXA_TYPE_ANY:
10174 + vxdprintk(VXD_CBIT(net, 0),
10175 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
10176 + nxa, NXAV6(nxa), addr, mask, ret);
10181 +int v6_addr_in_nx_info(struct nx_info *nxi,
10182 + const struct in6_addr *addr, uint16_t mask)
10184 + struct nx_addr_v6 *nxa;
10189 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
10190 + if (v6_addr_match(nxa, addr, mask))
10194 + vxdprintk(VXD_CBIT(net, 0),
10195 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
10196 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
10201 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
10203 + /* FIXME: needs full range checks */
10204 + return v6_addr_match(nxa, &addr->ip, mask);
10208 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
10210 + struct nx_addr_v6 *ptr;
10212 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
10213 + if (v6_nx_addr_match(ptr, nxa, mask))
10220 + * Check if a given address matches for a socket
10222 + * nxi: the socket's nx_info if any
10223 + * addr: to be verified address
10226 +int v6_sock_addr_match (
10227 + struct nx_info *nxi,
10228 + struct inet_sock *inet,
10229 + struct in6_addr *addr)
10231 + struct sock *sk = &inet->sk;
10232 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10234 + if (!ipv6_addr_any(addr) &&
10235 + ipv6_addr_equal(saddr, addr))
10237 + if (ipv6_addr_any(saddr))
10238 + return v6_addr_in_nx_info(nxi, addr, -1);
10243 + * check if address is covered by socket
10245 + * sk: the socket to check against
10246 + * addr: the address in question (must be != 0)
10250 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
10252 + struct nx_info *nxi = sk->sk_nx_info;
10253 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10255 + vxdprintk(VXD_CBIT(net, 5),
10256 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
10257 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
10258 + (sk->sk_socket?sk->sk_socket->flags:0));
10260 + if (!ipv6_addr_any(saddr)) { /* direct address match */
10261 + return v6_addr_match(nxa, saddr, -1);
10262 + } else if (nxi) { /* match against nx_info */
10263 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
10264 + } else { /* unrestricted any socket */
10270 +/* inet related checks and helpers */
10274 +struct net_device;
10278 +#include <linux/netdevice.h>
10279 +#include <linux/inetdevice.h>
10280 +#include <net/inet_timewait_sock.h>
10283 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10284 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10285 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10290 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10296 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10300 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10302 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10303 + nxi, nxi ? nxi->nx_id : 0, ifa,
10304 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10306 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10308 + if (v6_ifa_in_nx_info(ifa, nxi))
10314 +struct nx_v6_sock_addr {
10315 + struct in6_addr saddr; /* Address used for validation */
10316 + struct in6_addr baddr; /* Address used for socket bind */
10320 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10321 + struct nx_v6_sock_addr *nsa)
10323 + // struct sock *sk = &inet->sk;
10324 + // struct nx_info *nxi = sk->sk_nx_info;
10325 + struct in6_addr saddr = addr->sin6_addr;
10326 + struct in6_addr baddr = saddr;
10328 + nsa->saddr = saddr;
10329 + nsa->baddr = baddr;
10334 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10336 + // struct sock *sk = &inet->sk;
10337 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10339 + // *saddr = nsa->baddr;
10340 + // inet->inet_saddr = nsa->baddr;
10344 +int nx_info_has_v6(struct nx_info *nxi)
10348 + if (NX_IPV6(nxi))
10353 +#else /* CONFIG_IPV6 */
10356 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10363 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10369 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10375 +int nx_info_has_v6(struct nx_info *nxi)
10380 +#endif /* CONFIG_IPV6 */
10382 +#define current_nx_info_has_v6() \
10383 + nx_info_has_v6(current_nx_info())
10386 +#warning duplicate inclusion
10388 diff -NurpP --minimal linux-3.0.25/include/linux/vs_limit.h linux-3.0.25-vs2.3.2.3/include/linux/vs_limit.h
10389 --- linux-3.0.25/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10390 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_limit.h 2011-06-10 22:11:24.000000000 +0200
10392 +#ifndef _VS_LIMIT_H
10393 +#define _VS_LIMIT_H
10395 +#include "vserver/limit.h"
10396 +#include "vserver/base.h"
10397 +#include "vserver/context.h"
10398 +#include "vserver/debug.h"
10399 +#include "vserver/context.h"
10400 +#include "vserver/limit_int.h"
10403 +#define vx_acc_cres(v, d, p, r) \
10404 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10406 +#define vx_acc_cres_cond(x, d, p, r) \
10407 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10408 + r, d, p, __FILE__, __LINE__)
10411 +#define vx_add_cres(v, a, p, r) \
10412 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10413 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10415 +#define vx_add_cres_cond(x, a, p, r) \
10416 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10417 + r, a, p, __FILE__, __LINE__)
10418 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10421 +/* process and file limits */
10423 +#define vx_nproc_inc(p) \
10424 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10426 +#define vx_nproc_dec(p) \
10427 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10429 +#define vx_files_inc(f) \
10430 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10432 +#define vx_files_dec(f) \
10433 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10435 +#define vx_locks_inc(l) \
10436 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10438 +#define vx_locks_dec(l) \
10439 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10441 +#define vx_openfd_inc(f) \
10442 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10444 +#define vx_openfd_dec(f) \
10445 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10448 +#define vx_cres_avail(v, n, r) \
10449 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10452 +#define vx_nproc_avail(n) \
10453 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10455 +#define vx_files_avail(n) \
10456 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10458 +#define vx_locks_avail(n) \
10459 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10461 +#define vx_openfd_avail(n) \
10462 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10465 +/* dentry limits */
10467 +#define vx_dentry_inc(d) do { \
10468 + if ((d)->d_count == 1) \
10469 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10472 +#define vx_dentry_dec(d) do { \
10473 + if ((d)->d_count == 0) \
10474 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10477 +#define vx_dentry_avail(n) \
10478 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10481 +/* socket limits */
10483 +#define vx_sock_inc(s) \
10484 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10486 +#define vx_sock_dec(s) \
10487 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10489 +#define vx_sock_avail(n) \
10490 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10493 +/* ipc resource limits */
10495 +#define vx_ipcmsg_add(v, u, a) \
10496 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10498 +#define vx_ipcmsg_sub(v, u, a) \
10499 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10501 +#define vx_ipcmsg_avail(v, a) \
10502 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10505 +#define vx_ipcshm_add(v, k, a) \
10506 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10508 +#define vx_ipcshm_sub(v, k, a) \
10509 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10511 +#define vx_ipcshm_avail(v, a) \
10512 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10515 +#define vx_semary_inc(a) \
10516 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10518 +#define vx_semary_dec(a) \
10519 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10522 +#define vx_nsems_add(a,n) \
10523 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10525 +#define vx_nsems_sub(a,n) \
10526 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10530 +#warning duplicate inclusion
10532 diff -NurpP --minimal linux-3.0.25/include/linux/vs_memory.h linux-3.0.25-vs2.3.2.3/include/linux/vs_memory.h
10533 --- linux-3.0.25/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
10534 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_memory.h 2011-06-10 22:11:24.000000000 +0200
10536 +#ifndef _VS_MEMORY_H
10537 +#define _VS_MEMORY_H
10539 +#include "vserver/limit.h"
10540 +#include "vserver/base.h"
10541 +#include "vserver/context.h"
10542 +#include "vserver/debug.h"
10543 +#include "vserver/context.h"
10544 +#include "vserver/limit_int.h"
10547 + VXPT_UNKNOWN = 0,
10556 +#define vx_page_fault(mm, vma, type, ret)
10560 +void __vx_page_fault(struct mm_struct *mm,
10561 + struct vm_area_struct *vma, int type, int ret)
10563 + struct vx_info *vxi = mm->mm_vx_info;
10566 + static char *page_type[6] =
10567 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
10568 + static char *page_what[4] =
10569 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
10575 + what = (ret & 0x3);
10577 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
10578 + type, what, ret, page_type[type], page_what[what]);
10580 + if (ret & VM_FAULT_WRITE)
10582 + atomic_inc(&vxi->cacct.page[type][what]);
10585 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
10589 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
10592 +#warning duplicate inclusion
10594 diff -NurpP --minimal linux-3.0.25/include/linux/vs_network.h linux-3.0.25-vs2.3.2.3/include/linux/vs_network.h
10595 --- linux-3.0.25/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
10596 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_network.h 2011-06-10 22:11:24.000000000 +0200
10598 +#ifndef _NX_VS_NETWORK_H
10599 +#define _NX_VS_NETWORK_H
10601 +#include "vserver/context.h"
10602 +#include "vserver/network.h"
10603 +#include "vserver/base.h"
10604 +#include "vserver/check.h"
10605 +#include "vserver/debug.h"
10607 +#include <linux/sched.h>
10610 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
10612 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
10613 + const char *_file, int _line)
10618 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
10619 + nxi, nxi ? nxi->nx_id : 0,
10620 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10623 + atomic_inc(&nxi->nx_usecnt);
10628 +extern void free_nx_info(struct nx_info *);
10630 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
10632 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
10637 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
10638 + nxi, nxi ? nxi->nx_id : 0,
10639 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10642 + if (atomic_dec_and_test(&nxi->nx_usecnt))
10643 + free_nx_info(nxi);
10647 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
10649 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10650 + const char *_file, int _line)
10653 + vxlprintk(VXD_CBIT(nid, 3),
10654 + "init_nx_info(%p[#%d.%d])",
10655 + nxi, nxi ? nxi->nx_id : 0,
10656 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10659 + atomic_inc(&nxi->nx_usecnt);
10665 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
10667 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10668 + const char *_file, int _line)
10670 + struct nx_info *nxo;
10675 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
10676 + nxi, nxi ? nxi->nx_id : 0,
10677 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10680 + atomic_inc(&nxi->nx_usecnt);
10681 + nxo = xchg(nxp, nxi);
10685 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
10687 +static inline void __clr_nx_info(struct nx_info **nxp,
10688 + const char *_file, int _line)
10690 + struct nx_info *nxo;
10692 + nxo = xchg(nxp, NULL);
10696 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
10697 + nxo, nxo ? nxo->nx_id : 0,
10698 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
10701 + if (atomic_dec_and_test(&nxo->nx_usecnt))
10702 + free_nx_info(nxo);
10706 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
10708 +static inline void __claim_nx_info(struct nx_info *nxi,
10709 + struct task_struct *task, const char *_file, int _line)
10711 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
10712 + nxi, nxi ? nxi->nx_id : 0,
10713 + nxi?atomic_read(&nxi->nx_usecnt):0,
10714 + nxi?atomic_read(&nxi->nx_tasks):0,
10715 + task, _file, _line);
10717 + atomic_inc(&nxi->nx_tasks);
10721 +extern void unhash_nx_info(struct nx_info *);
10723 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
10725 +static inline void __release_nx_info(struct nx_info *nxi,
10726 + struct task_struct *task, const char *_file, int _line)
10728 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
10729 + nxi, nxi ? nxi->nx_id : 0,
10730 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10731 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
10732 + task, _file, _line);
10736 + if (atomic_dec_and_test(&nxi->nx_tasks))
10737 + unhash_nx_info(nxi);
10741 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
10743 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
10744 + const char *_file, int _line)
10746 + struct nx_info *nxi;
10749 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
10750 + p, _file, _line);
10751 + nxi = __get_nx_info(p->nx_info, _file, _line);
10757 +static inline void exit_nx_info(struct task_struct *p)
10760 + release_nx_info(p->nx_info, p);
10765 +#warning duplicate inclusion
10767 diff -NurpP --minimal linux-3.0.25/include/linux/vs_pid.h linux-3.0.25-vs2.3.2.3/include/linux/vs_pid.h
10768 --- linux-3.0.25/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
10769 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_pid.h 2011-06-10 22:11:24.000000000 +0200
10774 +#include "vserver/base.h"
10775 +#include "vserver/check.h"
10776 +#include "vserver/context.h"
10777 +#include "vserver/debug.h"
10778 +#include "vserver/pid.h"
10779 +#include <linux/pid_namespace.h>
10782 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
10785 +int vx_proc_task_visible(struct task_struct *task)
10787 + if ((task->pid == 1) &&
10788 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
10789 + /* show a blend through init */
10791 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
10798 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
10802 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
10804 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
10806 + if (task && !vx_proc_task_visible(task)) {
10807 + vxdprintk(VXD_CBIT(misc, 6),
10808 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
10809 + task, task->xid, task->pid,
10810 + current, current->xid, current->pid);
10811 + put_task_struct(task);
10819 +#warning duplicate inclusion
10821 diff -NurpP --minimal linux-3.0.25/include/linux/vs_sched.h linux-3.0.25-vs2.3.2.3/include/linux/vs_sched.h
10822 --- linux-3.0.25/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
10823 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_sched.h 2011-06-10 22:11:24.000000000 +0200
10825 +#ifndef _VS_SCHED_H
10826 +#define _VS_SCHED_H
10828 +#include "vserver/base.h"
10829 +#include "vserver/context.h"
10830 +#include "vserver/sched.h"
10833 +#define MAX_PRIO_BIAS 20
10834 +#define MIN_PRIO_BIAS -20
10837 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
10839 + struct vx_info *vxi = p->vx_info;
10842 + prio += vx_cpu(vxi, sched_pc).prio_bias;
10846 +static inline void vx_account_user(struct vx_info *vxi,
10847 + cputime_t cputime, int nice)
10851 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
10854 +static inline void vx_account_system(struct vx_info *vxi,
10855 + cputime_t cputime, int idle)
10859 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
10863 +#warning duplicate inclusion
10865 diff -NurpP --minimal linux-3.0.25/include/linux/vs_socket.h linux-3.0.25-vs2.3.2.3/include/linux/vs_socket.h
10866 --- linux-3.0.25/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
10867 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_socket.h 2011-06-10 22:11:24.000000000 +0200
10869 +#ifndef _VS_SOCKET_H
10870 +#define _VS_SOCKET_H
10872 +#include "vserver/debug.h"
10873 +#include "vserver/base.h"
10874 +#include "vserver/cacct.h"
10875 +#include "vserver/context.h"
10876 +#include "vserver/tag.h"
10879 +/* socket accounting */
10881 +#include <linux/socket.h>
10883 +static inline int vx_sock_type(int family)
10885 + switch (family) {
10887 + return VXA_SOCK_UNSPEC;
10889 + return VXA_SOCK_UNIX;
10891 + return VXA_SOCK_INET;
10893 + return VXA_SOCK_INET6;
10895 + return VXA_SOCK_PACKET;
10897 + return VXA_SOCK_OTHER;
10901 +#define vx_acc_sock(v, f, p, s) \
10902 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
10904 +static inline void __vx_acc_sock(struct vx_info *vxi,
10905 + int family, int pos, int size, char *file, int line)
10908 + int type = vx_sock_type(family);
10910 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10911 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10915 +#define vx_sock_recv(sk, s) \
10916 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10917 +#define vx_sock_send(sk, s) \
10918 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10919 +#define vx_sock_fail(sk, s) \
10920 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10923 +#define sock_vx_init(s) do { \
10924 + (s)->sk_xid = 0; \
10925 + (s)->sk_vx_info = NULL; \
10928 +#define sock_nx_init(s) do { \
10929 + (s)->sk_nid = 0; \
10930 + (s)->sk_nx_info = NULL; \
10934 +#warning duplicate inclusion
10936 diff -NurpP --minimal linux-3.0.25/include/linux/vs_tag.h linux-3.0.25-vs2.3.2.3/include/linux/vs_tag.h
10937 --- linux-3.0.25/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
10938 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_tag.h 2011-06-10 22:11:24.000000000 +0200
10943 +#include <linux/vserver/tag.h>
10945 +/* check conditions */
10947 +#define DX_ADMIN 0x0001
10948 +#define DX_WATCH 0x0002
10949 +#define DX_HOSTID 0x0008
10951 +#define DX_IDENT 0x0010
10953 +#define DX_ARG_MASK 0x0010
10956 +#define dx_task_tag(t) ((t)->tag)
10958 +#define dx_current_tag() dx_task_tag(current)
10960 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10962 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10966 + * check current context for ADMIN/WATCH and
10967 + * optionally against supplied argument
10969 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
10971 + if (mode & DX_ARG_MASK) {
10972 + if ((mode & DX_IDENT) && (id == cid))
10975 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10976 + ((mode & DX_WATCH) && (cid == 1)) ||
10977 + ((mode & DX_HOSTID) && (id == 0)));
10981 +int dx_permission(const struct inode *inode, int mask);
10985 +#warning duplicate inclusion
10987 diff -NurpP --minimal linux-3.0.25/include/linux/vs_time.h linux-3.0.25-vs2.3.2.3/include/linux/vs_time.h
10988 --- linux-3.0.25/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
10989 +++ linux-3.0.25-vs2.3.2.3/include/linux/vs_time.h 2011-06-13 14:57:45.000000000 +0200
10991 +#ifndef _VS_TIME_H
10992 +#define _VS_TIME_H
10995 +/* time faking stuff */
10997 +#ifdef CONFIG_VSERVER_VTIME
10999 +extern void vx_adjust_timespec(struct timespec *ts);
11000 +extern int vx_settimeofday(const struct timespec *ts);
11003 +#define vx_adjust_timespec(t) do { } while (0)
11004 +#define vx_settimeofday(t) do_settimeofday(t)
11008 +#warning duplicate inclusion
11010 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/Kbuild linux-3.0.25-vs2.3.2.3/include/linux/vserver/Kbuild
11011 --- linux-3.0.25/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
11012 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/Kbuild 2011-08-08 18:02:46.000000000 +0200
11015 +header-y += context_cmd.h network_cmd.h space_cmd.h \
11016 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
11017 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
11018 + debug_cmd.h device_cmd.h
11020 +header-y += switch.h network.h monitor.h inode.h device.h
11022 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/base.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/base.h
11023 --- linux-3.0.25/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
11024 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/base.h 2011-08-01 18:26:07.000000000 +0200
11026 +#ifndef _VX_BASE_H
11027 +#define _VX_BASE_H
11030 +/* context state changes */
11042 +#define vx_task_xid(t) ((t)->xid)
11044 +#define vx_current_xid() vx_task_xid(current)
11046 +#define current_vx_info() (current->vx_info)
11049 +#define nx_task_nid(t) ((t)->nid)
11051 +#define nx_current_nid() nx_task_nid(current)
11053 +#define current_nx_info() (current->nx_info)
11056 +/* generic flag merging */
11058 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
11060 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11062 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
11064 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
11067 +/* context flags */
11069 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
11071 +#define vx_current_flags() __vx_flags(current_vx_info())
11073 +#define vx_info_flags(v, m, f) \
11074 + vs_check_flags(__vx_flags(v), m, f)
11076 +#define task_vx_flags(t, m, f) \
11077 + ((t) && vx_info_flags((t)->vx_info, m, f))
11079 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11082 +/* context caps */
11084 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
11086 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
11088 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
11090 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
11094 +/* network flags */
11096 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
11098 +#define nx_current_flags() __nx_flags(current_nx_info())
11100 +#define nx_info_flags(n, m, f) \
11101 + vs_check_flags(__nx_flags(n), m, f)
11103 +#define task_nx_flags(t, m, f) \
11104 + ((t) && nx_info_flags((t)->nx_info, m, f))
11106 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11109 +/* network caps */
11111 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
11113 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
11115 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
11117 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
11120 +/* context mask capabilities */
11122 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11124 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
11126 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
11129 +/* context bcap mask */
11131 +#define __vx_bcaps(v) ((v)->vx_bcaps)
11133 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
11136 +/* mask given bcaps */
11138 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11140 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
11143 +/* masked cap_bset */
11145 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
11147 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
11150 +#define vx_info_mbcap(v, b) \
11151 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11152 + vx_info_bcaps(v, b) : (b))
11154 +#define task_vx_mbcap(t, b) \
11155 + vx_info_mbcap((t)->vx_info, (t)->b)
11157 +#define vx_mbcap(b) task_vx_mbcap(current, b)
11160 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11162 +#define vx_capable(b, c) (capable(b) || \
11163 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
11165 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
11166 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
11168 +#define nx_capable(b, c) (capable(b) || \
11169 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
11171 +#define vx_task_initpid(t, n) \
11172 + ((t)->vx_info && \
11173 + ((t)->vx_info->vx_initpid == (n)))
11175 +#define vx_current_initpid(n) vx_task_initpid(current, n)
11178 +/* context unshare mask */
11180 +#define __vx_umask(v) ((v)->vx_umask)
11182 +#define vx_current_umask() __vx_umask(current_vx_info())
11184 +#define vx_can_unshare(b, f) (capable(b) || \
11185 + (cap_raised(current_cap(), b) && \
11186 + !((f) & ~vx_current_umask())))
11189 +#define __vx_wmask(v) ((v)->vx_wmask)
11191 +#define vx_current_wmask() __vx_wmask(current_vx_info())
11194 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
11196 +#define vx_info_state(v, m) (__vx_state(v) & (m))
11199 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
11201 +#define nx_info_state(n, m) (__nx_state(n) & (m))
11204 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/cacct.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/cacct.h
11205 --- linux-3.0.25/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
11206 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/cacct.h 2011-06-10 22:11:24.000000000 +0200
11208 +#ifndef _VX_CACCT_H
11209 +#define _VX_CACCT_H
11212 +enum sock_acc_field {
11213 + VXA_SOCK_UNSPEC = 0,
11219 + VXA_SOCK_SIZE /* array size */
11222 +#endif /* _VX_CACCT_H */
11223 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/cacct_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/cacct_cmd.h
11224 --- linux-3.0.25/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
11225 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/cacct_cmd.h 2011-06-10 22:11:24.000000000 +0200
11227 +#ifndef _VX_CACCT_CMD_H
11228 +#define _VX_CACCT_CMD_H
11231 +/* virtual host info name commands */
11233 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
11235 +struct vcmd_sock_stat_v0 {
11237 + uint32_t count[3];
11238 + uint64_t total[3];
11244 +#include <linux/compiler.h>
11246 +extern int vc_sock_stat(struct vx_info *, void __user *);
11248 +#endif /* __KERNEL__ */
11249 +#endif /* _VX_CACCT_CMD_H */
11250 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/cacct_def.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/cacct_def.h
11251 --- linux-3.0.25/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
11252 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/cacct_def.h 2011-06-10 22:11:24.000000000 +0200
11254 +#ifndef _VX_CACCT_DEF_H
11255 +#define _VX_CACCT_DEF_H
11257 +#include <asm/atomic.h>
11258 +#include <linux/vserver/cacct.h>
11261 +struct _vx_sock_acc {
11262 + atomic_long_t count;
11263 + atomic_long_t total;
11266 +/* context sub struct */
11268 +struct _vx_cacct {
11269 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11270 + atomic_t slab[8];
11271 + atomic_t page[6][8];
11274 +#ifdef CONFIG_VSERVER_DEBUG
11276 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11280 + printk("\t_vx_cacct:");
11281 + for (i = 0; i < 6; i++) {
11282 + struct _vx_sock_acc *ptr = cacct->sock[i];
11284 + printk("\t [%d] =", i);
11285 + for (j = 0; j < 3; j++) {
11286 + printk(" [%d] = %8lu, %8lu", j,
11287 + atomic_long_read(&ptr[j].count),
11288 + atomic_long_read(&ptr[j].total));
11296 +#endif /* _VX_CACCT_DEF_H */
11297 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/cacct_int.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/cacct_int.h
11298 --- linux-3.0.25/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
11299 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/cacct_int.h 2011-06-10 22:11:24.000000000 +0200
11301 +#ifndef _VX_CACCT_INT_H
11302 +#define _VX_CACCT_INT_H
11308 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11310 + return atomic_long_read(&cacct->sock[type][pos].count);
11315 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11317 + return atomic_long_read(&cacct->sock[type][pos].total);
11320 +#endif /* __KERNEL__ */
11321 +#endif /* _VX_CACCT_INT_H */
11322 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/check.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/check.h
11323 --- linux-3.0.25/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
11324 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/check.h 2011-06-10 22:11:24.000000000 +0200
11326 +#ifndef _VS_CHECK_H
11327 +#define _VS_CHECK_H
11330 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11332 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11333 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11335 +#define MIN_D_CONTEXT 65536
11338 +/* check conditions */
11340 +#define VS_ADMIN 0x0001
11341 +#define VS_WATCH 0x0002
11342 +#define VS_HIDE 0x0004
11343 +#define VS_HOSTID 0x0008
11345 +#define VS_IDENT 0x0010
11346 +#define VS_EQUIV 0x0020
11347 +#define VS_PARENT 0x0040
11348 +#define VS_CHILD 0x0080
11350 +#define VS_ARG_MASK 0x00F0
11352 +#define VS_DYNAMIC 0x0100
11353 +#define VS_STATIC 0x0200
11355 +#define VS_ATR_MASK 0x0F00
11357 +#ifdef CONFIG_VSERVER_PRIVACY
11358 +#define VS_ADMIN_P (0)
11359 +#define VS_WATCH_P (0)
11361 +#define VS_ADMIN_P VS_ADMIN
11362 +#define VS_WATCH_P VS_WATCH
11365 +#define VS_HARDIRQ 0x1000
11366 +#define VS_SOFTIRQ 0x2000
11367 +#define VS_IRQ 0x4000
11369 +#define VS_IRQ_MASK 0xF000
11371 +#include <linux/hardirq.h>
11374 + * check current context for ADMIN/WATCH and
11375 + * optionally against supplied argument
11377 +static inline int __vs_check(int cid, int id, unsigned int mode)
11379 + if (mode & VS_ARG_MASK) {
11380 + if ((mode & VS_IDENT) && (id == cid))
11383 + if (mode & VS_ATR_MASK) {
11384 + if ((mode & VS_DYNAMIC) &&
11385 + (id >= MIN_D_CONTEXT) &&
11386 + (id <= MAX_S_CONTEXT))
11388 + if ((mode & VS_STATIC) &&
11389 + (id > 1) && (id < MIN_D_CONTEXT))
11392 + if (mode & VS_IRQ_MASK) {
11393 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11395 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11397 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11400 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11401 + ((mode & VS_WATCH) && (cid == 1)) ||
11402 + ((mode & VS_HOSTID) && (id == 0)));
11405 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11407 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11410 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11412 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11415 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/context.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/context.h
11416 --- linux-3.0.25/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11417 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/context.h 2011-10-27 13:59:29.000000000 +0200
11419 +#ifndef _VX_CONTEXT_H
11420 +#define _VX_CONTEXT_H
11422 +#include <linux/types.h>
11423 +#include <linux/capability.h>
11426 +/* context flags */
11428 +#define VXF_INFO_SCHED 0x00000002
11429 +#define VXF_INFO_NPROC 0x00000004
11430 +#define VXF_INFO_PRIVATE 0x00000008
11432 +#define VXF_INFO_INIT 0x00000010
11433 +#define VXF_INFO_HIDE 0x00000020
11434 +#define VXF_INFO_ULIMIT 0x00000040
11435 +#define VXF_INFO_NSPACE 0x00000080
11437 +#define VXF_SCHED_HARD 0x00000100
11438 +#define VXF_SCHED_PRIO 0x00000200
11439 +#define VXF_SCHED_PAUSE 0x00000400
11441 +#define VXF_VIRT_MEM 0x00010000
11442 +#define VXF_VIRT_UPTIME 0x00020000
11443 +#define VXF_VIRT_CPU 0x00040000
11444 +#define VXF_VIRT_LOAD 0x00080000
11445 +#define VXF_VIRT_TIME 0x00100000
11447 +#define VXF_HIDE_MOUNT 0x01000000
11448 +/* was VXF_HIDE_NETIF 0x02000000 */
11449 +#define VXF_HIDE_VINFO 0x04000000
11451 +#define VXF_STATE_SETUP (1ULL << 32)
11452 +#define VXF_STATE_INIT (1ULL << 33)
11453 +#define VXF_STATE_ADMIN (1ULL << 34)
11455 +#define VXF_SC_HELPER (1ULL << 36)
11456 +#define VXF_REBOOT_KILL (1ULL << 37)
11457 +#define VXF_PERSISTENT (1ULL << 38)
11459 +#define VXF_FORK_RSS (1ULL << 48)
11460 +#define VXF_PROLIFIC (1ULL << 49)
11462 +#define VXF_IGNEG_NICE (1ULL << 52)
11464 +#define VXF_ONE_TIME (0x0007ULL << 32)
11466 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11469 +/* context migration */
11471 +#define VXM_SET_INIT 0x00000001
11472 +#define VXM_SET_REAPER 0x00000002
11474 +/* context caps */
11476 +#define VXC_SET_UTSNAME 0x00000001
11477 +#define VXC_SET_RLIMIT 0x00000002
11478 +#define VXC_FS_SECURITY 0x00000004
11479 +#define VXC_FS_TRUSTED 0x00000008
11480 +#define VXC_TIOCSTI 0x00000010
11482 +/* was VXC_RAW_ICMP 0x00000100 */
11483 +#define VXC_SYSLOG 0x00001000
11484 +#define VXC_OOM_ADJUST 0x00002000
11485 +#define VXC_AUDIT_CONTROL 0x00004000
11487 +#define VXC_SECURE_MOUNT 0x00010000
11488 +#define VXC_SECURE_REMOUNT 0x00020000
11489 +#define VXC_BINARY_MOUNT 0x00040000
11491 +#define VXC_QUOTA_CTL 0x00100000
11492 +#define VXC_ADMIN_MAPPER 0x00200000
11493 +#define VXC_ADMIN_CLOOP 0x00400000
11495 +#define VXC_KTHREAD 0x01000000
11496 +#define VXC_NAMESPACE 0x02000000
11501 +#include <linux/list.h>
11502 +#include <linux/spinlock.h>
11503 +#include <linux/rcupdate.h>
11505 +#include "limit_def.h"
11506 +#include "sched_def.h"
11507 +#include "cvirt_def.h"
11508 +#include "cacct_def.h"
11509 +#include "device_def.h"
11511 +#define VX_SPACES 2
11513 +struct _vx_info_pc {
11514 + struct _vx_sched_pc sched_pc;
11515 + struct _vx_cvirt_pc cvirt_pc;
11518 +struct _vx_space {
11519 + unsigned long vx_nsmask; /* assignment mask */
11520 + struct nsproxy *vx_nsproxy; /* private namespaces */
11521 + struct fs_struct *vx_fs; /* private namespace fs */
11522 + const struct cred *vx_cred; /* task credentials */
11526 + struct hlist_node vx_hlist; /* linked list of contexts */
11527 + xid_t vx_id; /* context id */
11528 + atomic_t vx_usecnt; /* usage count */
11529 + atomic_t vx_tasks; /* tasks count */
11530 + struct vx_info *vx_parent; /* parent context */
11531 + int vx_state; /* context state */
11533 + struct _vx_space space[VX_SPACES]; /* namespace store */
11535 + uint64_t vx_flags; /* context flags */
11536 + uint64_t vx_ccaps; /* context caps (vserver) */
11537 + uint64_t vx_umask; /* unshare mask (guest) */
11538 + uint64_t vx_wmask; /* warn mask (guest) */
11539 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11541 + struct task_struct *vx_reaper; /* guest reaper process */
11542 + pid_t vx_initpid; /* PID of guest init */
11543 + int64_t vx_badness_bias; /* OOM points bias */
11545 + struct _vx_limit limit; /* vserver limits */
11546 + struct _vx_sched sched; /* vserver scheduler */
11547 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11548 + struct _vx_cacct cacct; /* context accounting */
11550 + struct _vx_device dmap; /* default device map targets */
11552 +#ifndef CONFIG_SMP
11553 + struct _vx_info_pc info_pc; /* per cpu data */
11555 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11558 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11559 + int reboot_cmd; /* last sys_reboot() cmd */
11560 + int exit_code; /* last process exit code */
11562 + char vx_name[65]; /* vserver name */
11565 +#ifndef CONFIG_SMP
11566 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11567 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11569 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11570 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11573 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11576 +struct vx_info_save {
11577 + struct vx_info *vxi;
11582 +/* status flags */
11584 +#define VXS_HASHED 0x0001
11585 +#define VXS_PAUSED 0x0010
11586 +#define VXS_SHUTDOWN 0x0100
11587 +#define VXS_HELPER 0x1000
11588 +#define VXS_RELEASED 0x8000
11591 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11592 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11594 +extern struct vx_info *lookup_vx_info(int);
11595 +extern struct vx_info *lookup_or_create_vx_info(int);
11597 +extern int get_xid_list(int, unsigned int *, int);
11598 +extern int xid_is_hashed(xid_t);
11600 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11602 +extern long vs_state_change(struct vx_info *, unsigned int);
11605 +#endif /* __KERNEL__ */
11606 +#endif /* _VX_CONTEXT_H */
11607 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/context_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/context_cmd.h
11608 --- linux-3.0.25/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
11609 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/context_cmd.h 2011-08-01 18:25:07.000000000 +0200
11611 +#ifndef _VX_CONTEXT_CMD_H
11612 +#define _VX_CONTEXT_CMD_H
11615 +/* vinfo commands */
11617 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11620 +extern int vc_task_xid(uint32_t);
11622 +#endif /* __KERNEL__ */
11624 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11626 +struct vcmd_vx_info_v0 {
11628 + uint32_t initpid;
11629 + /* more to come */
11633 +extern int vc_vx_info(struct vx_info *, void __user *);
11635 +#endif /* __KERNEL__ */
11637 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11639 +struct vcmd_ctx_stat_v0 {
11642 + /* more to come */
11646 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11648 +#endif /* __KERNEL__ */
11650 +/* context commands */
11652 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11653 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11655 +struct vcmd_ctx_create {
11656 + uint64_t flagword;
11659 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11660 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11662 +struct vcmd_ctx_migrate {
11663 + uint64_t flagword;
11667 +extern int vc_ctx_create(uint32_t, void __user *);
11668 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11670 +#endif /* __KERNEL__ */
11673 +/* flag commands */
11675 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11676 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11678 +struct vcmd_ctx_flags_v0 {
11679 + uint64_t flagword;
11684 +extern int vc_get_cflags(struct vx_info *, void __user *);
11685 +extern int vc_set_cflags(struct vx_info *, void __user *);
11687 +#endif /* __KERNEL__ */
11690 +/* context caps commands */
11692 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
11693 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
11695 +struct vcmd_ctx_caps_v1 {
11701 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11702 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11704 +#endif /* __KERNEL__ */
11707 +/* bcaps commands */
11709 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
11710 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
11712 +struct vcmd_bcaps {
11718 +extern int vc_get_bcaps(struct vx_info *, void __user *);
11719 +extern int vc_set_bcaps(struct vx_info *, void __user *);
11721 +#endif /* __KERNEL__ */
11724 +/* umask commands */
11726 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
11727 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
11729 +struct vcmd_umask {
11735 +extern int vc_get_umask(struct vx_info *, void __user *);
11736 +extern int vc_set_umask(struct vx_info *, void __user *);
11738 +#endif /* __KERNEL__ */
11741 +/* wmask commands */
11743 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
11744 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
11746 +struct vcmd_wmask {
11752 +extern int vc_get_wmask(struct vx_info *, void __user *);
11753 +extern int vc_set_wmask(struct vx_info *, void __user *);
11755 +#endif /* __KERNEL__ */
11760 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
11761 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
11763 +struct vcmd_badness_v0 {
11768 +extern int vc_get_badness(struct vx_info *, void __user *);
11769 +extern int vc_set_badness(struct vx_info *, void __user *);
11771 +#endif /* __KERNEL__ */
11772 +#endif /* _VX_CONTEXT_CMD_H */
11773 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/cvirt.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/cvirt.h
11774 --- linux-3.0.25/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11775 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/cvirt.h 2011-06-10 22:11:24.000000000 +0200
11777 +#ifndef _VX_CVIRT_H
11778 +#define _VX_CVIRT_H
11785 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11790 +void vx_update_load(struct vx_info *);
11793 +int vx_do_syslog(int, char __user *, int);
11795 +#endif /* __KERNEL__ */
11796 +#endif /* _VX_CVIRT_H */
11797 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/cvirt_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/cvirt_cmd.h
11798 --- linux-3.0.25/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11799 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/cvirt_cmd.h 2011-06-10 22:11:24.000000000 +0200
11801 +#ifndef _VX_CVIRT_CMD_H
11802 +#define _VX_CVIRT_CMD_H
11805 +/* virtual host info name commands */
11807 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11808 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11810 +struct vcmd_vhi_name_v0 {
11816 +enum vhi_name_field {
11817 + VHIN_CONTEXT = 0,
11829 +#include <linux/compiler.h>
11831 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11832 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11834 +#endif /* __KERNEL__ */
11836 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11838 +struct vcmd_virt_stat_v0 {
11841 + uint32_t nr_threads;
11842 + uint32_t nr_running;
11843 + uint32_t nr_uninterruptible;
11844 + uint32_t nr_onhold;
11845 + uint32_t nr_forks;
11846 + uint32_t load[3];
11850 +extern int vc_virt_stat(struct vx_info *, void __user *);
11852 +#endif /* __KERNEL__ */
11853 +#endif /* _VX_CVIRT_CMD_H */
11854 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/cvirt_def.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/cvirt_def.h
11855 --- linux-3.0.25/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11856 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/cvirt_def.h 2011-06-10 22:11:24.000000000 +0200
11858 +#ifndef _VX_CVIRT_DEF_H
11859 +#define _VX_CVIRT_DEF_H
11861 +#include <linux/jiffies.h>
11862 +#include <linux/spinlock.h>
11863 +#include <linux/wait.h>
11864 +#include <linux/time.h>
11865 +#include <asm/atomic.h>
11868 +struct _vx_usage_stat {
11872 + uint64_t softirq;
11878 +struct _vx_syslog {
11879 + wait_queue_head_t log_wait;
11880 + spinlock_t logbuf_lock; /* lock for the log buffer */
11882 + unsigned long log_start; /* next char to be read by syslog() */
11883 + unsigned long con_start; /* next char to be sent to consoles */
11884 + unsigned long log_end; /* most-recently-written-char + 1 */
11885 + unsigned long logged_chars; /* #chars since last read+clear operation */
11887 + char log_buf[1024];
11891 +/* context sub struct */
11893 +struct _vx_cvirt {
11894 + atomic_t nr_threads; /* number of current threads */
11895 + atomic_t nr_running; /* number of running threads */
11896 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11898 + atomic_t nr_onhold; /* processes on hold */
11899 + uint32_t onhold_last; /* jiffies when put on hold */
11901 + struct timespec bias_ts; /* time offset to the host */
11902 + struct timespec bias_idle;
11903 + struct timespec bias_uptime; /* context creation point */
11904 + uint64_t bias_clock; /* offset in clock_t */
11906 + spinlock_t load_lock; /* lock for the load averages */
11907 + atomic_t load_updates; /* nr of load updates done so far */
11908 + uint32_t load_last; /* last time load was calculated */
11909 + uint32_t load[3]; /* load averages 1,5,15 */
11911 + atomic_t total_forks; /* number of forks so far */
11913 + struct _vx_syslog syslog;
11916 +struct _vx_cvirt_pc {
11917 + struct _vx_usage_stat cpustat;
11921 +#ifdef CONFIG_VSERVER_DEBUG
11923 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11925 + printk("\t_vx_cvirt:\n");
11926 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11927 + atomic_read(&cvirt->nr_threads),
11928 + atomic_read(&cvirt->nr_running),
11929 + atomic_read(&cvirt->nr_uninterruptible),
11930 + atomic_read(&cvirt->nr_onhold));
11931 + /* add rest here */
11932 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11937 +#endif /* _VX_CVIRT_DEF_H */
11938 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/debug.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/debug.h
11939 --- linux-3.0.25/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11940 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/debug.h 2011-11-17 21:25:04.000000000 +0100
11942 +#ifndef _VX_DEBUG_H
11943 +#define _VX_DEBUG_H
11946 +#define VXD_CBIT(n, m) (vs_debug_ ## n & (1 << (m)))
11947 +#define VXD_CMIN(n, m) (vs_debug_ ## n > (m))
11948 +#define VXD_MASK(n, m) (vs_debug_ ## n & (m))
11950 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11951 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11952 +#define VXF_DEV "%p[%lu,%d:%d]"
11954 +#if defined(CONFIG_QUOTES_UTF8)
11955 +#define VS_Q_LQM "\xc2\xbb"
11956 +#define VS_Q_RQM "\xc2\xab"
11957 +#elif defined(CONFIG_QUOTES_ASCII)
11958 +#define VS_Q_LQM "\x27"
11959 +#define VS_Q_RQM "\x27"
11961 +#define VS_Q_LQM "\xbb"
11962 +#define VS_Q_RQM "\xab"
11965 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
11968 +#define vxd_path(p) \
11969 + ({ static char _buffer[PATH_MAX]; \
11970 + d_path(p, _buffer, sizeof(_buffer)); })
11972 +#define vxd_cond_path(n) \
11973 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11976 +#ifdef CONFIG_VSERVER_DEBUG
11978 +extern unsigned int vs_debug_switch;
11979 +extern unsigned int vs_debug_xid;
11980 +extern unsigned int vs_debug_nid;
11981 +extern unsigned int vs_debug_tag;
11982 +extern unsigned int vs_debug_net;
11983 +extern unsigned int vs_debug_limit;
11984 +extern unsigned int vs_debug_cres;
11985 +extern unsigned int vs_debug_dlim;
11986 +extern unsigned int vs_debug_quota;
11987 +extern unsigned int vs_debug_cvirt;
11988 +extern unsigned int vs_debug_space;
11989 +extern unsigned int vs_debug_perm;
11990 +extern unsigned int vs_debug_misc;
11993 +#define VX_LOGLEVEL "vxD: "
11994 +#define VX_PROC_FMT "%p: "
11995 +#define VX_PROCESS current
11997 +#define vxdprintk(c, f, x...) \
12000 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
12001 + VX_PROCESS , ##x); \
12004 +#define vxlprintk(c, f, x...) \
12007 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
12010 +#define vxfprintk(c, f, x...) \
12013 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
12019 +void dump_vx_info(struct vx_info *, int);
12020 +void dump_vx_info_inactive(int);
12022 +#else /* CONFIG_VSERVER_DEBUG */
12024 +#define vs_debug_switch 0
12025 +#define vs_debug_xid 0
12026 +#define vs_debug_nid 0
12027 +#define vs_debug_tag 0
12028 +#define vs_debug_net 0
12029 +#define vs_debug_limit 0
12030 +#define vs_debug_cres 0
12031 +#define vs_debug_dlim 0
12032 +#define vs_debug_quota 0
12033 +#define vs_debug_cvirt 0
12034 +#define vs_debug_space 0
12035 +#define vs_debug_perm 0
12036 +#define vs_debug_misc 0
12038 +#define vxdprintk(x...) do { } while (0)
12039 +#define vxlprintk(x...) do { } while (0)
12040 +#define vxfprintk(x...) do { } while (0)
12042 +#endif /* CONFIG_VSERVER_DEBUG */
12045 +#ifdef CONFIG_VSERVER_WARN
12047 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
12048 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
12049 +#define VX_WARN_XID "[xid #%u] "
12050 +#define VX_WARN_NID "[nid #%u] "
12051 +#define VX_WARN_TAG "[tag #%u] "
12053 +#define vxwprintk(c, f, x...) \
12056 + printk(VX_WARNLEVEL f "\n", ##x); \
12059 +#else /* CONFIG_VSERVER_WARN */
12061 +#define vxwprintk(x...) do { } while (0)
12063 +#endif /* CONFIG_VSERVER_WARN */
12065 +#define vxwprintk_task(c, f, x...) \
12066 + vxwprintk(c, VX_WARN_TASK f, \
12067 + current->comm, current->pid, \
12068 + current->xid, current->nid, current->tag, ##x)
12069 +#define vxwprintk_xid(c, f, x...) \
12070 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
12071 +#define vxwprintk_nid(c, f, x...) \
12072 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
12073 +#define vxwprintk_tag(c, f, x...) \
12074 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12076 +#ifdef CONFIG_VSERVER_DEBUG
12077 +#define vxd_assert_lock(l) assert_spin_locked(l)
12078 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12079 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12081 +#define vxd_assert_lock(l) do { } while (0)
12082 +#define vxd_assert(c, f, x...) do { } while (0)
12086 +#endif /* _VX_DEBUG_H */
12087 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/debug_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/debug_cmd.h
12088 --- linux-3.0.25/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
12089 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/debug_cmd.h 2011-06-10 22:11:24.000000000 +0200
12091 +#ifndef _VX_DEBUG_CMD_H
12092 +#define _VX_DEBUG_CMD_H
12095 +/* debug commands */
12097 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
12099 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
12100 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
12102 +struct vcmd_read_history_v0 {
12105 + char __user *data;
12108 +struct vcmd_read_monitor_v0 {
12111 + char __user *data;
12117 +#ifdef CONFIG_COMPAT
12119 +#include <asm/compat.h>
12121 +struct vcmd_read_history_v0_x32 {
12124 + compat_uptr_t data_ptr;
12127 +struct vcmd_read_monitor_v0_x32 {
12130 + compat_uptr_t data_ptr;
12133 +#endif /* CONFIG_COMPAT */
12135 +extern int vc_dump_history(uint32_t);
12137 +extern int vc_read_history(uint32_t, void __user *);
12138 +extern int vc_read_monitor(uint32_t, void __user *);
12140 +#ifdef CONFIG_COMPAT
12142 +extern int vc_read_history_x32(uint32_t, void __user *);
12143 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12145 +#endif /* CONFIG_COMPAT */
12147 +#endif /* __KERNEL__ */
12148 +#endif /* _VX_DEBUG_CMD_H */
12149 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/device.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/device.h
12150 --- linux-3.0.25/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
12151 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/device.h 2011-06-10 22:11:24.000000000 +0200
12153 +#ifndef _VX_DEVICE_H
12154 +#define _VX_DEVICE_H
12157 +#define DATTR_CREATE 0x00000001
12158 +#define DATTR_OPEN 0x00000002
12160 +#define DATTR_REMAP 0x00000010
12162 +#define DATTR_MASK 0x00000013
12165 +#else /* _VX_DEVICE_H */
12166 +#warning duplicate inclusion
12167 +#endif /* _VX_DEVICE_H */
12168 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/device_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/device_cmd.h
12169 --- linux-3.0.25/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
12170 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/device_cmd.h 2011-06-10 22:11:24.000000000 +0200
12172 +#ifndef _VX_DEVICE_CMD_H
12173 +#define _VX_DEVICE_CMD_H
12176 +/* device vserver commands */
12178 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
12179 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
12181 +struct vcmd_set_mapping_v0 {
12182 + const char __user *device;
12183 + const char __user *target;
12190 +#ifdef CONFIG_COMPAT
12192 +#include <asm/compat.h>
12194 +struct vcmd_set_mapping_v0_x32 {
12195 + compat_uptr_t device_ptr;
12196 + compat_uptr_t target_ptr;
12200 +#endif /* CONFIG_COMPAT */
12202 +#include <linux/compiler.h>
12204 +extern int vc_set_mapping(struct vx_info *, void __user *);
12205 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12207 +#ifdef CONFIG_COMPAT
12209 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12210 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12212 +#endif /* CONFIG_COMPAT */
12214 +#endif /* __KERNEL__ */
12215 +#endif /* _VX_DEVICE_CMD_H */
12216 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/device_def.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/device_def.h
12217 --- linux-3.0.25/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
12218 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/device_def.h 2011-06-10 22:11:24.000000000 +0200
12220 +#ifndef _VX_DEVICE_DEF_H
12221 +#define _VX_DEVICE_DEF_H
12223 +#include <linux/types.h>
12225 +struct vx_dmap_target {
12230 +struct _vx_device {
12231 +#ifdef CONFIG_VSERVER_DEVICE
12232 + struct vx_dmap_target targets[2];
12236 +#endif /* _VX_DEVICE_DEF_H */
12237 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/dlimit.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/dlimit.h
12238 --- linux-3.0.25/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12239 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/dlimit.h 2011-06-10 22:11:24.000000000 +0200
12241 +#ifndef _VX_DLIMIT_H
12242 +#define _VX_DLIMIT_H
12244 +#include "switch.h"
12249 +/* keep in sync with CDLIM_INFINITY */
12251 +#define DLIM_INFINITY (~0ULL)
12253 +#include <linux/spinlock.h>
12254 +#include <linux/rcupdate.h>
12256 +struct super_block;
12259 + struct hlist_node dl_hlist; /* linked list of contexts */
12260 + struct rcu_head dl_rcu; /* the rcu head */
12261 + tag_t dl_tag; /* context tag */
12262 + atomic_t dl_usecnt; /* usage count */
12263 + atomic_t dl_refcnt; /* reference count */
12265 + struct super_block *dl_sb; /* associated superblock */
12267 + spinlock_t dl_lock; /* protect the values */
12269 + unsigned long long dl_space_used; /* used space in bytes */
12270 + unsigned long long dl_space_total; /* maximum space in bytes */
12271 + unsigned long dl_inodes_used; /* used inodes */
12272 + unsigned long dl_inodes_total; /* maximum inodes */
12274 + unsigned int dl_nrlmult; /* non root limit mult */
12279 +extern void rcu_free_dl_info(struct rcu_head *);
12280 +extern void unhash_dl_info(struct dl_info *);
12282 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12287 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12289 +typedef uint64_t dlsize_t;
12291 +#endif /* __KERNEL__ */
12292 +#else /* _VX_DLIMIT_H */
12293 +#warning duplicate inclusion
12294 +#endif /* _VX_DLIMIT_H */
12295 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/dlimit_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/dlimit_cmd.h
12296 --- linux-3.0.25/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12297 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/dlimit_cmd.h 2011-06-10 22:11:24.000000000 +0200
12299 +#ifndef _VX_DLIMIT_CMD_H
12300 +#define _VX_DLIMIT_CMD_H
12303 +/* dlimit vserver commands */
12305 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12306 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12308 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12309 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12311 +struct vcmd_ctx_dlimit_base_v0 {
12312 + const char __user *name;
12316 +struct vcmd_ctx_dlimit_v0 {
12317 + const char __user *name;
12318 + uint32_t space_used; /* used space in kbytes */
12319 + uint32_t space_total; /* maximum space in kbytes */
12320 + uint32_t inodes_used; /* used inodes */
12321 + uint32_t inodes_total; /* maximum inodes */
12322 + uint32_t reserved; /* reserved for root in % */
12326 +#define CDLIM_UNSET ((uint32_t)0UL)
12327 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12328 +#define CDLIM_KEEP ((uint32_t)~1UL)
12330 +#define DLIME_UNIT 0
12331 +#define DLIME_KILO 1
12332 +#define DLIME_MEGA 2
12333 +#define DLIME_GIGA 3
12335 +#define DLIMF_SHIFT 0x10
12337 +#define DLIMS_USED 0
12338 +#define DLIMS_TOTAL 2
12341 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12343 + int exp = (flags & DLIMF_SHIFT) ?
12344 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12345 + return ((uint64_t)val) << (10 * exp);
12349 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12353 + if (*flags & DLIMF_SHIFT) {
12354 + while (val > (1LL << 32) && (exp < 3)) {
12358 + *flags &= ~(DLIME_GIGA << shift);
12359 + *flags |= exp << shift;
12367 +#ifdef CONFIG_COMPAT
12369 +#include <asm/compat.h>
12371 +struct vcmd_ctx_dlimit_base_v0_x32 {
12372 + compat_uptr_t name_ptr;
12376 +struct vcmd_ctx_dlimit_v0_x32 {
12377 + compat_uptr_t name_ptr;
12378 + uint32_t space_used; /* used space in kbytes */
12379 + uint32_t space_total; /* maximum space in kbytes */
12380 + uint32_t inodes_used; /* used inodes */
12381 + uint32_t inodes_total; /* maximum inodes */
12382 + uint32_t reserved; /* reserved for root in % */
12386 +#endif /* CONFIG_COMPAT */
12388 +#include <linux/compiler.h>
12390 +extern int vc_add_dlimit(uint32_t, void __user *);
12391 +extern int vc_rem_dlimit(uint32_t, void __user *);
12393 +extern int vc_set_dlimit(uint32_t, void __user *);
12394 +extern int vc_get_dlimit(uint32_t, void __user *);
12396 +#ifdef CONFIG_COMPAT
12398 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12399 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12401 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12402 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12404 +#endif /* CONFIG_COMPAT */
12406 +#endif /* __KERNEL__ */
12407 +#endif /* _VX_DLIMIT_CMD_H */
12408 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/global.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/global.h
12409 --- linux-3.0.25/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12410 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/global.h 2011-06-10 22:11:24.000000000 +0200
12412 +#ifndef _VX_GLOBAL_H
12413 +#define _VX_GLOBAL_H
12416 +extern atomic_t vx_global_ctotal;
12417 +extern atomic_t vx_global_cactive;
12419 +extern atomic_t nx_global_ctotal;
12420 +extern atomic_t nx_global_cactive;
12422 +extern atomic_t vs_global_nsproxy;
12423 +extern atomic_t vs_global_fs;
12424 +extern atomic_t vs_global_mnt_ns;
12425 +extern atomic_t vs_global_uts_ns;
12426 +extern atomic_t vs_global_user_ns;
12427 +extern atomic_t vs_global_pid_ns;
12430 +#endif /* _VX_GLOBAL_H */
12431 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/history.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/history.h
12432 --- linux-3.0.25/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12433 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/history.h 2011-06-10 22:11:24.000000000 +0200
12435 +#ifndef _VX_HISTORY_H
12436 +#define _VX_HISTORY_H
12441 + VXH_THROW_OOPS = 1,
12445 + VXH_INIT_VX_INFO,
12448 + VXH_CLAIM_VX_INFO,
12449 + VXH_RELEASE_VX_INFO,
12450 + VXH_ALLOC_VX_INFO,
12451 + VXH_DEALLOC_VX_INFO,
12452 + VXH_HASH_VX_INFO,
12453 + VXH_UNHASH_VX_INFO,
12455 + VXH_LOOKUP_VX_INFO,
12456 + VXH_CREATE_VX_INFO,
12459 +struct _vxhe_vxi {
12460 + struct vx_info *ptr;
12466 +struct _vxhe_set_clr {
12470 +struct _vxhe_loc_lookup {
12474 +struct _vx_hist_entry {
12476 + unsigned short seq;
12477 + unsigned short type;
12478 + struct _vxhe_vxi vxi;
12480 + struct _vxhe_set_clr sc;
12481 + struct _vxhe_loc_lookup ll;
12485 +#ifdef CONFIG_VSERVER_HISTORY
12487 +extern unsigned volatile int vxh_active;
12489 +struct _vx_hist_entry *vxh_advance(void *loc);
12493 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12495 + entry->vxi.ptr = vxi;
12497 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12498 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12499 + entry->vxi.xid = vxi->vx_id;
12504 +#define __HERE__ current_text_addr()
12506 +#define __VXH_BODY(__type, __data, __here) \
12507 + struct _vx_hist_entry *entry; \
12509 + preempt_disable(); \
12510 + entry = vxh_advance(__here); \
12512 + entry->type = __type; \
12513 + preempt_enable();
12516 + /* pass vxi only */
12518 +#define __VXH_SMPL \
12519 + __vxh_copy_vxi(entry, vxi)
12522 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12524 + __VXH_BODY(__type, __VXH_SMPL, __here)
12527 + /* pass vxi and data (void *) */
12529 +#define __VXH_DATA \
12530 + __vxh_copy_vxi(entry, vxi); \
12531 + entry->sc.data = data
12534 +void __vxh_data(struct vx_info *vxi, void *data,
12535 + int __type, void *__here)
12537 + __VXH_BODY(__type, __VXH_DATA, __here)
12540 + /* pass vxi and arg (long) */
12542 +#define __VXH_LONG \
12543 + __vxh_copy_vxi(entry, vxi); \
12544 + entry->ll.arg = arg
12547 +void __vxh_long(struct vx_info *vxi, long arg,
12548 + int __type, void *__here)
12550 + __VXH_BODY(__type, __VXH_LONG, __here)
12555 +void __vxh_throw_oops(void *__here)
12557 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12558 + /* prevent further acquisition */
12563 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12565 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12566 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12568 +#define __vxh_init_vx_info(v, d, h) \
12569 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12570 +#define __vxh_set_vx_info(v, d, h) \
12571 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12572 +#define __vxh_clr_vx_info(v, d, h) \
12573 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12575 +#define __vxh_claim_vx_info(v, d, h) \
12576 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12577 +#define __vxh_release_vx_info(v, d, h) \
12578 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12580 +#define vxh_alloc_vx_info(v) \
12581 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12582 +#define vxh_dealloc_vx_info(v) \
12583 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12585 +#define vxh_hash_vx_info(v) \
12586 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12587 +#define vxh_unhash_vx_info(v) \
12588 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12590 +#define vxh_loc_vx_info(v, l) \
12591 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12592 +#define vxh_lookup_vx_info(v, l) \
12593 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12594 +#define vxh_create_vx_info(v, l) \
12595 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12597 +extern void vxh_dump_history(void);
12600 +#else /* CONFIG_VSERVER_HISTORY */
12602 +#define __HERE__ 0
12604 +#define vxh_throw_oops() do { } while (0)
12606 +#define __vxh_get_vx_info(v, h) do { } while (0)
12607 +#define __vxh_put_vx_info(v, h) do { } while (0)
12609 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12610 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12611 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12613 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12614 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12616 +#define vxh_alloc_vx_info(v) do { } while (0)
12617 +#define vxh_dealloc_vx_info(v) do { } while (0)
12619 +#define vxh_hash_vx_info(v) do { } while (0)
12620 +#define vxh_unhash_vx_info(v) do { } while (0)
12622 +#define vxh_loc_vx_info(v, l) do { } while (0)
12623 +#define vxh_lookup_vx_info(v, l) do { } while (0)
12624 +#define vxh_create_vx_info(v, l) do { } while (0)
12626 +#define vxh_dump_history() do { } while (0)
12629 +#endif /* CONFIG_VSERVER_HISTORY */
12631 +#endif /* _VX_HISTORY_H */
12632 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/inode.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/inode.h
12633 --- linux-3.0.25/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
12634 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/inode.h 2011-06-10 22:11:24.000000000 +0200
12636 +#ifndef _VX_INODE_H
12637 +#define _VX_INODE_H
12640 +#define IATTR_TAG 0x01000000
12642 +#define IATTR_ADMIN 0x00000001
12643 +#define IATTR_WATCH 0x00000002
12644 +#define IATTR_HIDE 0x00000004
12645 +#define IATTR_FLAGS 0x00000007
12647 +#define IATTR_BARRIER 0x00010000
12648 +#define IATTR_IXUNLINK 0x00020000
12649 +#define IATTR_IMMUTABLE 0x00040000
12650 +#define IATTR_COW 0x00080000
12655 +#ifdef CONFIG_VSERVER_PROC_SECURE
12656 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12657 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12659 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12660 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12663 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12665 +#endif /* __KERNEL__ */
12667 +/* inode ioctls */
12669 +#define FIOC_GETXFLG _IOR('x', 5, long)
12670 +#define FIOC_SETXFLG _IOW('x', 6, long)
12672 +#else /* _VX_INODE_H */
12673 +#warning duplicate inclusion
12674 +#endif /* _VX_INODE_H */
12675 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/inode_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/inode_cmd.h
12676 --- linux-3.0.25/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
12677 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/inode_cmd.h 2011-06-10 22:11:24.000000000 +0200
12679 +#ifndef _VX_INODE_CMD_H
12680 +#define _VX_INODE_CMD_H
12683 +/* inode vserver commands */
12685 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12686 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12688 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12689 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12691 +struct vcmd_ctx_iattr_v1 {
12692 + const char __user *name;
12698 +struct vcmd_ctx_fiattr_v0 {
12708 +#ifdef CONFIG_COMPAT
12710 +#include <asm/compat.h>
12712 +struct vcmd_ctx_iattr_v1_x32 {
12713 + compat_uptr_t name_ptr;
12719 +#endif /* CONFIG_COMPAT */
12721 +#include <linux/compiler.h>
12723 +extern int vc_get_iattr(void __user *);
12724 +extern int vc_set_iattr(void __user *);
12726 +extern int vc_fget_iattr(uint32_t, void __user *);
12727 +extern int vc_fset_iattr(uint32_t, void __user *);
12729 +#ifdef CONFIG_COMPAT
12731 +extern int vc_get_iattr_x32(void __user *);
12732 +extern int vc_set_iattr_x32(void __user *);
12734 +#endif /* CONFIG_COMPAT */
12736 +#endif /* __KERNEL__ */
12737 +#endif /* _VX_INODE_CMD_H */
12738 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/limit.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/limit.h
12739 --- linux-3.0.25/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12740 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/limit.h 2011-06-10 22:11:24.000000000 +0200
12742 +#ifndef _VX_LIMIT_H
12743 +#define _VX_LIMIT_H
12745 +#define VLIMIT_NSOCK 16
12746 +#define VLIMIT_OPENFD 17
12747 +#define VLIMIT_ANON 18
12748 +#define VLIMIT_SHMEM 19
12749 +#define VLIMIT_SEMARY 20
12750 +#define VLIMIT_NSEMS 21
12751 +#define VLIMIT_DENTRY 22
12752 +#define VLIMIT_MAPPED 23
12757 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12759 +/* keep in sync with CRLIM_INFINITY */
12761 +#define VLIM_INFINITY (~0ULL)
12763 +#include <asm/atomic.h>
12764 +#include <asm/resource.h>
12766 +#ifndef RLIM_INFINITY
12767 +#warning RLIM_INFINITY is undefined
12770 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12772 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12773 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12775 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12776 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12777 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12779 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12780 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12782 +typedef atomic_long_t rlim_atomic_t;
12783 +typedef unsigned long rlim_t;
12785 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12786 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12787 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12788 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12789 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12790 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12793 +#if (RLIM_INFINITY == VLIM_INFINITY)
12794 +#define VX_VLIM(r) ((long long)(long)(r))
12795 +#define VX_RLIM(v) ((rlim_t)(v))
12797 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12798 + ? VLIM_INFINITY : (long long)(r))
12799 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12800 + ? RLIM_INFINITY : (rlim_t)(v))
12805 +void vx_vsi_meminfo(struct sysinfo *);
12806 +void vx_vsi_swapinfo(struct sysinfo *);
12807 +long vx_vsi_cached(struct sysinfo *);
12809 +#define NUM_LIMITS 24
12811 +#endif /* __KERNEL__ */
12812 +#endif /* _VX_LIMIT_H */
12813 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/limit_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/limit_cmd.h
12814 --- linux-3.0.25/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12815 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/limit_cmd.h 2011-06-10 22:11:24.000000000 +0200
12817 +#ifndef _VX_LIMIT_CMD_H
12818 +#define _VX_LIMIT_CMD_H
12821 +/* rlimit vserver commands */
12823 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12824 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12825 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12826 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
12827 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12829 +struct vcmd_ctx_rlimit_v0 {
12831 + uint64_t minimum;
12832 + uint64_t softlimit;
12833 + uint64_t maximum;
12836 +struct vcmd_ctx_rlimit_mask_v0 {
12837 + uint32_t minimum;
12838 + uint32_t softlimit;
12839 + uint32_t maximum;
12842 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12844 +struct vcmd_rlimit_stat_v0 {
12848 + uint64_t minimum;
12849 + uint64_t maximum;
12852 +#define CRLIM_UNSET (0ULL)
12853 +#define CRLIM_INFINITY (~0ULL)
12854 +#define CRLIM_KEEP (~1ULL)
12858 +#ifdef CONFIG_IA32_EMULATION
12860 +struct vcmd_ctx_rlimit_v0_x32 {
12862 + uint64_t minimum;
12863 + uint64_t softlimit;
12864 + uint64_t maximum;
12865 +} __attribute__ ((packed));
12867 +#endif /* CONFIG_IA32_EMULATION */
12869 +#include <linux/compiler.h>
12871 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12872 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12873 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12874 +extern int vc_reset_hits(struct vx_info *, void __user *);
12875 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12877 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12879 +#ifdef CONFIG_IA32_EMULATION
12881 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12882 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12884 +#endif /* CONFIG_IA32_EMULATION */
12886 +#endif /* __KERNEL__ */
12887 +#endif /* _VX_LIMIT_CMD_H */
12888 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/limit_def.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/limit_def.h
12889 --- linux-3.0.25/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12890 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/limit_def.h 2011-06-10 22:11:24.000000000 +0200
12892 +#ifndef _VX_LIMIT_DEF_H
12893 +#define _VX_LIMIT_DEF_H
12895 +#include <asm/atomic.h>
12896 +#include <asm/resource.h>
12898 +#include "limit.h"
12901 +struct _vx_res_limit {
12902 + rlim_t soft; /* Context soft limit */
12903 + rlim_t hard; /* Context hard limit */
12905 + rlim_atomic_t rcur; /* Current value */
12906 + rlim_t rmin; /* Context minimum */
12907 + rlim_t rmax; /* Context maximum */
12909 + atomic_t lhit; /* Limit hits */
12912 +/* context sub struct */
12914 +struct _vx_limit {
12915 + struct _vx_res_limit res[NUM_LIMITS];
12918 +#ifdef CONFIG_VSERVER_DEBUG
12920 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12924 + printk("\t_vx_limit:");
12925 + for (i = 0; i < NUM_LIMITS; i++) {
12926 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12927 + i, (unsigned long)__rlim_get(limit, i),
12928 + (unsigned long)__rlim_rmin(limit, i),
12929 + (unsigned long)__rlim_rmax(limit, i),
12930 + (long)__rlim_soft(limit, i),
12931 + (long)__rlim_hard(limit, i),
12932 + atomic_read(&__rlim_lhit(limit, i)));
12938 +#endif /* _VX_LIMIT_DEF_H */
12939 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/limit_int.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/limit_int.h
12940 --- linux-3.0.25/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12941 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/limit_int.h 2011-06-10 22:11:24.000000000 +0200
12943 +#ifndef _VX_LIMIT_INT_H
12944 +#define _VX_LIMIT_INT_H
12946 +#include "context.h"
12950 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12951 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12953 +extern const char *vlimit_name[NUM_LIMITS];
12955 +static inline void __vx_acc_cres(struct vx_info *vxi,
12956 + int res, int dir, void *_data, char *_file, int _line)
12958 + if (VXD_RCRES_COND(res))
12959 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12960 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12961 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12962 + (dir > 0) ? "++" : "--", _data, _file, _line);
12967 + __rlim_inc(&vxi->limit, res);
12969 + __rlim_dec(&vxi->limit, res);
12972 +static inline void __vx_add_cres(struct vx_info *vxi,
12973 + int res, int amount, void *_data, char *_file, int _line)
12975 + if (VXD_RCRES_COND(res))
12976 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12977 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12978 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12979 + amount, _data, _file, _line);
12984 + __rlim_add(&vxi->limit, res, amount);
12988 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12990 + int cond = (value > __rlim_rmax(limit, res));
12993 + __rlim_rmax(limit, res) = value;
12998 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
13000 + int cond = (value < __rlim_rmin(limit, res));
13003 + __rlim_rmin(limit, res) = value;
13008 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
13010 + if (!__vx_cres_adjust_max(limit, res, value))
13011 + __vx_cres_adjust_min(limit, res, value);
13016 + +1 ... no limit hit
13017 + -1 ... over soft limit
13018 + 0 ... over hard limit */
13020 +static inline int __vx_cres_avail(struct vx_info *vxi,
13021 + int res, int num, char *_file, int _line)
13023 + struct _vx_limit *limit;
13026 + if (VXD_RLIMIT_COND(res))
13027 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13028 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13029 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13030 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13031 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13032 + num, _file, _line);
13036 + limit = &vxi->limit;
13037 + value = __rlim_get(limit, res);
13039 + if (!__vx_cres_adjust_max(limit, res, value))
13040 + __vx_cres_adjust_min(limit, res, value);
13045 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
13047 + if (value + num <= __rlim_soft(limit, res))
13050 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
13052 + if (value + num <= __rlim_hard(limit, res))
13055 + __rlim_hit(limit, res);
13060 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13063 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13065 + rlim_t value, sum = 0;
13068 + while ((res = *array++)) {
13069 + value = __rlim_get(limit, res);
13070 + __vx_cres_fixup(limit, res, value);
13077 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13079 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
13080 + int res = *array;
13082 + if (value == __rlim_get(limit, res))
13085 + __rlim_set(limit, res, value);
13086 + /* now adjust min/max */
13087 + if (!__vx_cres_adjust_max(limit, res, value))
13088 + __vx_cres_adjust_min(limit, res, value);
13093 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13094 + const int *array, int num, char *_file, int _line)
13096 + struct _vx_limit *limit;
13097 + rlim_t value = 0;
13105 + limit = &vxi->limit;
13107 + value = __vx_cres_array_sum(limit, array + 1);
13109 + __rlim_set(limit, res, value);
13110 + __vx_cres_fixup(limit, res, value);
13112 + return __vx_cres_avail(vxi, res, num, _file, _line);
13116 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13121 + /* complex resources first */
13122 + if ((id < 0) || (id == RLIMIT_RSS))
13123 + __vx_cres_array_fixup(limit, VLA_RSS);
13125 + for (res = 0; res < NUM_LIMITS; res++) {
13126 + if ((id > 0) && (res != id))
13129 + value = __rlim_get(limit, res);
13130 + __vx_cres_fixup(limit, res, value);
13132 + /* not supposed to happen, maybe warn? */
13133 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13134 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13139 +#endif /* __KERNEL__ */
13140 +#endif /* _VX_LIMIT_INT_H */
13141 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/monitor.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/monitor.h
13142 --- linux-3.0.25/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
13143 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/monitor.h 2011-06-10 22:11:24.000000000 +0200
13145 +#ifndef _VX_MONITOR_H
13146 +#define _VX_MONITOR_H
13148 +#include <linux/types.h>
13155 + VXM_UPDATE = 0x20,
13159 + VXM_RQINFO_1 = 0x24,
13162 + VXM_ACTIVATE = 0x40,
13169 + VXM_MIGRATE = 0x48,
13172 + /* all other bits are flags */
13173 + VXM_SCHED = 0x80,
13176 +struct _vxm_update_1 {
13177 + uint32_t tokens_max;
13178 + uint32_t fill_rate;
13179 + uint32_t interval;
13182 +struct _vxm_update_2 {
13183 + uint32_t tokens_min;
13184 + uint32_t fill_rate;
13185 + uint32_t interval;
13188 +struct _vxm_rqinfo_1 {
13189 + uint16_t running;
13193 + uint32_t idle_tokens;
13196 +struct _vxm_rqinfo_2 {
13197 + uint32_t norm_time;
13198 + uint32_t idle_time;
13199 + uint32_t idle_skip;
13202 +struct _vxm_sched {
13204 + uint32_t norm_time;
13205 + uint32_t idle_time;
13208 +struct _vxm_task {
13213 +struct _vxm_event {
13222 + struct _vxm_task tsk;
13226 +struct _vx_mon_entry {
13230 + struct _vxm_event ev;
13231 + struct _vxm_sched sd;
13232 + struct _vxm_update_1 u1;
13233 + struct _vxm_update_2 u2;
13234 + struct _vxm_rqinfo_1 q1;
13235 + struct _vxm_rqinfo_2 q2;
13240 +#endif /* _VX_MONITOR_H */
13241 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/network.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/network.h
13242 --- linux-3.0.25/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
13243 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/network.h 2011-08-18 16:30:48.000000000 +0200
13245 +#ifndef _VX_NETWORK_H
13246 +#define _VX_NETWORK_H
13248 +#include <linux/types.h>
13251 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13254 +/* network flags */
13256 +#define NXF_INFO_PRIVATE 0x00000008
13258 +#define NXF_SINGLE_IP 0x00000100
13259 +#define NXF_LBACK_REMAP 0x00000200
13260 +#define NXF_LBACK_ALLOW 0x00000400
13262 +#define NXF_HIDE_NETIF 0x02000000
13263 +#define NXF_HIDE_LBACK 0x04000000
13265 +#define NXF_STATE_SETUP (1ULL << 32)
13266 +#define NXF_STATE_ADMIN (1ULL << 34)
13268 +#define NXF_SC_HELPER (1ULL << 36)
13269 +#define NXF_PERSISTENT (1ULL << 38)
13271 +#define NXF_ONE_TIME (0x0005ULL << 32)
13274 +#define NXF_INIT_SET (__nxf_init_set())
13276 +static inline uint64_t __nxf_init_set(void) {
13277 + return NXF_STATE_ADMIN
13278 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13279 + | NXF_LBACK_REMAP
13282 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13285 + | NXF_HIDE_NETIF;
13289 +/* network caps */
13291 +#define NXC_TUN_CREATE 0x00000001
13293 +#define NXC_RAW_ICMP 0x00000100
13295 +#define NXC_MULTICAST 0x00001000
13298 +/* address types */
13300 +#define NXA_TYPE_IPV4 0x0001
13301 +#define NXA_TYPE_IPV6 0x0002
13303 +#define NXA_TYPE_NONE 0x0000
13304 +#define NXA_TYPE_ANY 0x00FF
13306 +#define NXA_TYPE_ADDR 0x0010
13307 +#define NXA_TYPE_MASK 0x0020
13308 +#define NXA_TYPE_RANGE 0x0040
13310 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13312 +#define NXA_MOD_BCAST 0x0100
13313 +#define NXA_MOD_LBACK 0x0200
13315 +#define NXA_LOOPBACK 0x1000
13317 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13318 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13322 +#include <linux/list.h>
13323 +#include <linux/spinlock.h>
13324 +#include <linux/rcupdate.h>
13325 +#include <linux/in.h>
13326 +#include <linux/in6.h>
13327 +#include <asm/atomic.h>
13329 +struct nx_addr_v4 {
13330 + struct nx_addr_v4 *next;
13331 + struct in_addr ip[2];
13332 + struct in_addr mask;
13337 +struct nx_addr_v6 {
13338 + struct nx_addr_v6 *next;
13339 + struct in6_addr ip;
13340 + struct in6_addr mask;
13347 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13348 + nid_t nx_id; /* vnet id */
13349 + atomic_t nx_usecnt; /* usage count */
13350 + atomic_t nx_tasks; /* tasks count */
13351 + int nx_state; /* context state */
13353 + uint64_t nx_flags; /* network flag word */
13354 + uint64_t nx_ncaps; /* network capabilities */
13356 + struct in_addr v4_lback; /* Loopback address */
13357 + struct in_addr v4_bcast; /* Broadcast address */
13358 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13359 +#ifdef CONFIG_IPV6
13360 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13362 + char nx_name[65]; /* network context name */
13366 +/* status flags */
13368 +#define NXS_HASHED 0x0001
13369 +#define NXS_SHUTDOWN 0x0100
13370 +#define NXS_RELEASED 0x8000
13372 +extern struct nx_info *lookup_nx_info(int);
13374 +extern int get_nid_list(int, unsigned int *, int);
13375 +extern int nid_is_hashed(nid_t);
13377 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13379 +extern long vs_net_change(struct nx_info *, unsigned int);
13384 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13385 +#ifdef CONFIG_IPV6
13386 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13388 +#define NX_IPV6(n) (0)
13391 +#endif /* __KERNEL__ */
13392 +#endif /* _VX_NETWORK_H */
13393 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/network_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/network_cmd.h
13394 --- linux-3.0.25/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13395 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/network_cmd.h 2011-06-10 22:11:24.000000000 +0200
13397 +#ifndef _VX_NETWORK_CMD_H
13398 +#define _VX_NETWORK_CMD_H
13401 +/* vinfo commands */
13403 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13406 +extern int vc_task_nid(uint32_t);
13408 +#endif /* __KERNEL__ */
13410 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13412 +struct vcmd_nx_info_v0 {
13414 + /* more to come */
13418 +extern int vc_nx_info(struct nx_info *, void __user *);
13420 +#endif /* __KERNEL__ */
13422 +#include <linux/in.h>
13423 +#include <linux/in6.h>
13425 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13426 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13428 +struct vcmd_net_create {
13429 + uint64_t flagword;
13432 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13434 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13435 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13437 +struct vcmd_net_addr_v0 {
13440 + struct in_addr ip[4];
13441 + struct in_addr mask[4];
13444 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13445 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13447 +struct vcmd_net_addr_ipv4_v1 {
13450 + struct in_addr ip;
13451 + struct in_addr mask;
13454 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13455 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13457 +struct vcmd_net_addr_ipv4_v2 {
13460 + struct in_addr ip;
13461 + struct in_addr ip2;
13462 + struct in_addr mask;
13465 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13466 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13468 +struct vcmd_net_addr_ipv6_v1 {
13472 + struct in6_addr ip;
13473 + struct in6_addr mask;
13476 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13477 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13479 +struct vcmd_match_ipv4_v0 {
13484 + struct in_addr ip;
13485 + struct in_addr ip2;
13486 + struct in_addr mask;
13489 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13490 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13492 +struct vcmd_match_ipv6_v0 {
13497 + struct in6_addr ip;
13498 + struct in6_addr ip2;
13499 + struct in6_addr mask;
13504 +extern int vc_net_create(uint32_t, void __user *);
13505 +extern int vc_net_migrate(struct nx_info *, void __user *);
13507 +extern int vc_net_add(struct nx_info *, void __user *);
13508 +extern int vc_net_remove(struct nx_info *, void __user *);
13510 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
13511 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13513 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
13514 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
13516 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13517 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13519 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13520 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13522 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13523 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13525 +#endif /* __KERNEL__ */
13528 +/* flag commands */
13530 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13531 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13533 +struct vcmd_net_flags_v0 {
13534 + uint64_t flagword;
13539 +extern int vc_get_nflags(struct nx_info *, void __user *);
13540 +extern int vc_set_nflags(struct nx_info *, void __user *);
13542 +#endif /* __KERNEL__ */
13545 +/* network caps commands */
13547 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13548 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13550 +struct vcmd_net_caps_v0 {
13556 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13557 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13559 +#endif /* __KERNEL__ */
13560 +#endif /* _VX_CONTEXT_CMD_H */
13561 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/percpu.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/percpu.h
13562 --- linux-3.0.25/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13563 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/percpu.h 2011-06-10 22:11:24.000000000 +0200
13565 +#ifndef _VX_PERCPU_H
13566 +#define _VX_PERCPU_H
13568 +#include "cvirt_def.h"
13569 +#include "sched_def.h"
13571 +struct _vx_percpu {
13572 + struct _vx_cvirt_pc cvirt;
13573 + struct _vx_sched_pc sched;
13576 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13578 +#endif /* _VX_PERCPU_H */
13579 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/pid.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/pid.h
13580 --- linux-3.0.25/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13581 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/pid.h 2011-06-10 22:11:24.000000000 +0200
13583 +#ifndef _VSERVER_PID_H
13584 +#define _VSERVER_PID_H
13586 +/* pid faking stuff */
13588 +#define vx_info_map_pid(v, p) \
13589 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13590 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13591 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13592 +#define vx_map_tgid(p) vx_map_pid(p)
13594 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13595 + const char *func, const char *file, int line)
13597 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13598 + vxfprintk(VXD_CBIT(cvirt, 2),
13599 + "vx_map_tgid: %p/%llx: %d -> %d",
13600 + vxi, (long long)vxi->vx_flags, pid,
13601 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13602 + func, file, line);
13605 + if (pid == vxi->vx_initpid)
13611 +#define vx_info_rmap_pid(v, p) \
13612 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13613 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13614 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13616 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13617 + const char *func, const char *file, int line)
13619 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13620 + vxfprintk(VXD_CBIT(cvirt, 2),
13621 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13622 + vxi, (long long)vxi->vx_flags, pid,
13623 + (pid == 1) ? vxi->vx_initpid : pid,
13624 + func, file, line);
13625 + if ((pid == 1) && vxi->vx_initpid)
13626 + return vxi->vx_initpid;
13627 + if (pid == vxi->vx_initpid)
13634 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/sched.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/sched.h
13635 --- linux-3.0.25/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13636 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/sched.h 2011-06-10 22:11:24.000000000 +0200
13638 +#ifndef _VX_SCHED_H
13639 +#define _VX_SCHED_H
13646 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13651 +void vx_update_load(struct vx_info *);
13654 +void vx_update_sched_param(struct _vx_sched *sched,
13655 + struct _vx_sched_pc *sched_pc);
13657 +#endif /* __KERNEL__ */
13658 +#else /* _VX_SCHED_H */
13659 +#warning duplicate inclusion
13660 +#endif /* _VX_SCHED_H */
13661 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/sched_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/sched_cmd.h
13662 --- linux-3.0.25/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
13663 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/sched_cmd.h 2011-06-10 22:11:24.000000000 +0200
13665 +#ifndef _VX_SCHED_CMD_H
13666 +#define _VX_SCHED_CMD_H
13669 +struct vcmd_prio_bias {
13671 + int32_t prio_bias;
13674 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13675 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13679 +#include <linux/compiler.h>
13681 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
13682 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
13684 +#endif /* __KERNEL__ */
13685 +#endif /* _VX_SCHED_CMD_H */
13686 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/sched_def.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/sched_def.h
13687 --- linux-3.0.25/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13688 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/sched_def.h 2011-06-10 22:11:24.000000000 +0200
13690 +#ifndef _VX_SCHED_DEF_H
13691 +#define _VX_SCHED_DEF_H
13693 +#include <linux/spinlock.h>
13694 +#include <linux/jiffies.h>
13695 +#include <linux/cpumask.h>
13696 +#include <asm/atomic.h>
13697 +#include <asm/param.h>
13700 +/* context sub struct */
13702 +struct _vx_sched {
13703 + int prio_bias; /* bias offset for priority */
13705 + cpumask_t update; /* CPUs which should update */
13708 +struct _vx_sched_pc {
13709 + int prio_bias; /* bias offset for priority */
13711 + uint64_t user_ticks; /* token tick events */
13712 + uint64_t sys_ticks; /* token tick events */
13713 + uint64_t hold_ticks; /* token ticks paused */
13717 +#ifdef CONFIG_VSERVER_DEBUG
13719 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13721 + printk("\t_vx_sched:\n");
13722 + printk("\t priority = %4d\n", sched->prio_bias);
13727 +#endif /* _VX_SCHED_DEF_H */
13728 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/signal.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/signal.h
13729 --- linux-3.0.25/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13730 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/signal.h 2011-06-10 22:11:24.000000000 +0200
13732 +#ifndef _VX_SIGNAL_H
13733 +#define _VX_SIGNAL_H
13740 +int vx_info_kill(struct vx_info *, int, int);
13742 +#endif /* __KERNEL__ */
13743 +#else /* _VX_SIGNAL_H */
13744 +#warning duplicate inclusion
13745 +#endif /* _VX_SIGNAL_H */
13746 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/signal_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/signal_cmd.h
13747 --- linux-3.0.25/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13748 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/signal_cmd.h 2011-06-10 22:11:24.000000000 +0200
13750 +#ifndef _VX_SIGNAL_CMD_H
13751 +#define _VX_SIGNAL_CMD_H
13754 +/* signalling vserver commands */
13756 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13757 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13759 +struct vcmd_ctx_kill_v0 {
13764 +struct vcmd_wait_exit_v0 {
13765 + int32_t reboot_cmd;
13766 + int32_t exit_code;
13771 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13772 +extern int vc_wait_exit(struct vx_info *, void __user *);
13774 +#endif /* __KERNEL__ */
13776 +/* process alteration commands */
13778 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13779 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13781 +struct vcmd_pflags_v0 {
13782 + uint32_t flagword;
13788 +extern int vc_get_pflags(uint32_t pid, void __user *);
13789 +extern int vc_set_pflags(uint32_t pid, void __user *);
13791 +#endif /* __KERNEL__ */
13792 +#endif /* _VX_SIGNAL_CMD_H */
13793 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/space.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/space.h
13794 --- linux-3.0.25/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13795 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/space.h 2011-06-10 22:11:24.000000000 +0200
13797 +#ifndef _VX_SPACE_H
13798 +#define _VX_SPACE_H
13800 +#include <linux/types.h>
13804 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13806 +#else /* _VX_SPACE_H */
13807 +#warning duplicate inclusion
13808 +#endif /* _VX_SPACE_H */
13809 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/space_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/space_cmd.h
13810 --- linux-3.0.25/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13811 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/space_cmd.h 2011-06-10 22:11:24.000000000 +0200
13813 +#ifndef _VX_SPACE_CMD_H
13814 +#define _VX_SPACE_CMD_H
13817 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13818 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13819 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13821 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13822 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13823 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13825 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13827 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13828 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13831 +struct vcmd_space_mask_v1 {
13835 +struct vcmd_space_mask_v2 {
13843 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13844 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13845 +extern int vc_enter_space(struct vx_info *, void __user *);
13846 +extern int vc_set_space(struct vx_info *, void __user *);
13847 +extern int vc_get_space_mask(void __user *, int);
13849 +#endif /* __KERNEL__ */
13850 +#endif /* _VX_SPACE_CMD_H */
13851 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/switch.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/switch.h
13852 --- linux-3.0.25/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13853 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/switch.h 2011-06-10 22:11:24.000000000 +0200
13855 +#ifndef _VX_SWITCH_H
13856 +#define _VX_SWITCH_H
13858 +#include <linux/types.h>
13861 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13862 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13863 +#define VC_VERSION(c) ((c) & 0xFFF)
13865 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13866 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13870 + Syscall Matrix V2.8
13872 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13873 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13874 + |INFO |SETUP | |MOVE | | | | | |
13875 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13876 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13877 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13878 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13879 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13880 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13881 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13882 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13883 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13884 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13885 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13886 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13887 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13888 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13889 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13890 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13891 + OTHER |VSTAT | | | | | | |VINFO | |
13892 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13893 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13894 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13895 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13896 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13897 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13898 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13899 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13903 +#define VC_CAT_VERSION 0
13905 +#define VC_CAT_VSETUP 1
13906 +#define VC_CAT_VHOST 2
13908 +#define VC_CAT_DEVICE 6
13910 +#define VC_CAT_VPROC 9
13911 +#define VC_CAT_PROCALT 10
13912 +#define VC_CAT_PROCMIG 11
13913 +#define VC_CAT_PROCTRL 12
13915 +#define VC_CAT_SCHED 14
13916 +#define VC_CAT_MEMCTRL 20
13918 +#define VC_CAT_VNET 25
13919 +#define VC_CAT_NETALT 26
13920 +#define VC_CAT_NETMIG 27
13921 +#define VC_CAT_NETCTRL 28
13923 +#define VC_CAT_TAGMIG 35
13924 +#define VC_CAT_DLIMIT 36
13925 +#define VC_CAT_INODE 38
13927 +#define VC_CAT_VSTAT 40
13928 +#define VC_CAT_VINFO 46
13929 +#define VC_CAT_EVENT 48
13931 +#define VC_CAT_FLAGS 52
13932 +#define VC_CAT_VSPACE 54
13933 +#define VC_CAT_DEBUG 56
13934 +#define VC_CAT_RLIMIT 60
13936 +#define VC_CAT_SYSTEST 61
13937 +#define VC_CAT_COMPAT 63
13939 +/* query version */
13941 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13942 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13947 +#include <linux/errno.h>
13949 +#endif /* __KERNEL__ */
13951 +#endif /* _VX_SWITCH_H */
13953 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/tag.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/tag.h
13954 --- linux-3.0.25/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13955 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/tag.h 2011-06-10 22:11:24.000000000 +0200
13960 +#include <linux/types.h>
13963 +#define DX_TAG(in) (IS_TAGGED(in))
13966 +#ifdef CONFIG_TAG_NFSD
13967 +#define DX_TAG_NFSD 1
13969 +#define DX_TAG_NFSD 0
13973 +#ifdef CONFIG_TAGGING_NONE
13975 +#define MAX_UID 0xFFFFFFFF
13976 +#define MAX_GID 0xFFFFFFFF
13978 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13980 +#define TAGINO_UID(cond, uid, tag) (uid)
13981 +#define TAGINO_GID(cond, gid, tag) (gid)
13986 +#ifdef CONFIG_TAGGING_GID16
13988 +#define MAX_UID 0xFFFFFFFF
13989 +#define MAX_GID 0x0000FFFF
13991 +#define INOTAG_TAG(cond, uid, gid, tag) \
13992 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13994 +#define TAGINO_UID(cond, uid, tag) (uid)
13995 +#define TAGINO_GID(cond, gid, tag) \
13996 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
14001 +#ifdef CONFIG_TAGGING_ID24
14003 +#define MAX_UID 0x00FFFFFF
14004 +#define MAX_GID 0x00FFFFFF
14006 +#define INOTAG_TAG(cond, uid, gid, tag) \
14007 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
14009 +#define TAGINO_UID(cond, uid, tag) \
14010 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
14011 +#define TAGINO_GID(cond, gid, tag) \
14012 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
14017 +#ifdef CONFIG_TAGGING_UID16
14019 +#define MAX_UID 0x0000FFFF
14020 +#define MAX_GID 0xFFFFFFFF
14022 +#define INOTAG_TAG(cond, uid, gid, tag) \
14023 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14025 +#define TAGINO_UID(cond, uid, tag) \
14026 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14027 +#define TAGINO_GID(cond, gid, tag) (gid)
14032 +#ifdef CONFIG_TAGGING_INTERN
14034 +#define MAX_UID 0xFFFFFFFF
14035 +#define MAX_GID 0xFFFFFFFF
14037 +#define INOTAG_TAG(cond, uid, gid, tag) \
14038 + ((cond) ? (tag) : 0)
14040 +#define TAGINO_UID(cond, uid, tag) (uid)
14041 +#define TAGINO_GID(cond, gid, tag) (gid)
14046 +#ifndef CONFIG_TAGGING_NONE
14047 +#define dx_current_fstag(sb) \
14048 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14050 +#define dx_current_fstag(sb) (0)
14053 +#ifndef CONFIG_TAGGING_INTERN
14054 +#define TAGINO_TAG(cond, tag) (0)
14056 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
14059 +#define INOTAG_UID(cond, uid, gid) \
14060 + ((cond) ? ((uid) & MAX_UID) : (uid))
14061 +#define INOTAG_GID(cond, uid, gid) \
14062 + ((cond) ? ((gid) & MAX_GID) : (gid))
14065 +static inline uid_t dx_map_uid(uid_t uid)
14067 + if ((uid > MAX_UID) && (uid != -1))
14069 + return (uid & MAX_UID);
14072 +static inline gid_t dx_map_gid(gid_t gid)
14074 + if ((gid > MAX_GID) && (gid != -1))
14076 + return (gid & MAX_GID);
14084 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14086 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14087 + unsigned long *flags);
14089 +#ifdef CONFIG_PROPAGATE
14091 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14093 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14096 +#define dx_propagate_tag(n, i) do { } while (0)
14099 +#endif /* _DX_TAG_H */
14100 diff -NurpP --minimal linux-3.0.25/include/linux/vserver/tag_cmd.h linux-3.0.25-vs2.3.2.3/include/linux/vserver/tag_cmd.h
14101 --- linux-3.0.25/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
14102 +++ linux-3.0.25-vs2.3.2.3/include/linux/vserver/tag_cmd.h 2011-06-10 22:11:24.000000000 +0200
14104 +#ifndef _VX_TAG_CMD_H
14105 +#define _VX_TAG_CMD_H
14108 +/* vinfo commands */
14110 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
14113 +extern int vc_task_tag(uint32_t);
14115 +#endif /* __KERNEL__ */
14117 +/* context commands */
14119 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
14122 +extern int vc_tag_migrate(uint32_t);
14124 +#endif /* __KERNEL__ */
14125 +#endif /* _VX_TAG_CMD_H */
14126 diff -NurpP --minimal linux-3.0.25/include/net/addrconf.h linux-3.0.25-vs2.3.2.3/include/net/addrconf.h
14127 --- linux-3.0.25/include/net/addrconf.h 2011-07-22 11:18:11.000000000 +0200
14128 +++ linux-3.0.25-vs2.3.2.3/include/net/addrconf.h 2011-06-10 22:11:24.000000000 +0200
14129 @@ -80,7 +80,8 @@ extern int ipv6_dev_get_saddr(struct n
14130 struct net_device *dev,
14131 const struct in6_addr *daddr,
14132 unsigned int srcprefs,
14133 - struct in6_addr *saddr);
14134 + struct in6_addr *saddr,
14135 + struct nx_info *nxi);
14136 extern int ipv6_get_lladdr(struct net_device *dev,
14137 struct in6_addr *addr,
14138 unsigned char banned_flags);
14139 diff -NurpP --minimal linux-3.0.25/include/net/af_unix.h linux-3.0.25-vs2.3.2.3/include/net/af_unix.h
14140 --- linux-3.0.25/include/net/af_unix.h 2011-07-22 11:18:11.000000000 +0200
14141 +++ linux-3.0.25-vs2.3.2.3/include/net/af_unix.h 2011-06-10 22:11:24.000000000 +0200
14143 #include <linux/socket.h>
14144 #include <linux/un.h>
14145 #include <linux/mutex.h>
14146 +#include <linux/vs_base.h>
14147 #include <net/sock.h>
14149 extern void unix_inflight(struct file *fp);
14150 diff -NurpP --minimal linux-3.0.25/include/net/inet_timewait_sock.h linux-3.0.25-vs2.3.2.3/include/net/inet_timewait_sock.h
14151 --- linux-3.0.25/include/net/inet_timewait_sock.h 2011-03-15 18:07:40.000000000 +0100
14152 +++ linux-3.0.25-vs2.3.2.3/include/net/inet_timewait_sock.h 2011-06-10 22:11:24.000000000 +0200
14153 @@ -113,6 +113,10 @@ struct inet_timewait_sock {
14154 #define tw_net __tw_common.skc_net
14155 #define tw_daddr __tw_common.skc_daddr
14156 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
14157 +#define tw_xid __tw_common.skc_xid
14158 +#define tw_vx_info __tw_common.skc_vx_info
14159 +#define tw_nid __tw_common.skc_nid
14160 +#define tw_nx_info __tw_common.skc_nx_info
14162 volatile unsigned char tw_substate;
14163 unsigned char tw_rcv_wscale;
14164 diff -NurpP --minimal linux-3.0.25/include/net/ip6_route.h linux-3.0.25-vs2.3.2.3/include/net/ip6_route.h
14165 --- linux-3.0.25/include/net/ip6_route.h 2011-07-22 11:18:11.000000000 +0200
14166 +++ linux-3.0.25-vs2.3.2.3/include/net/ip6_route.h 2011-06-16 14:16:51.000000000 +0200
14167 @@ -86,7 +86,8 @@ extern int ip6_route_get_saddr(struct
14168 struct rt6_info *rt,
14169 const struct in6_addr *daddr,
14170 unsigned int prefs,
14171 - struct in6_addr *saddr);
14172 + struct in6_addr *saddr,
14173 + struct nx_info *nxi);
14175 extern struct rt6_info *rt6_lookup(struct net *net,
14176 const struct in6_addr *daddr,
14177 diff -NurpP --minimal linux-3.0.25/include/net/route.h linux-3.0.25-vs2.3.2.3/include/net/route.h
14178 --- linux-3.0.25/include/net/route.h 2012-03-19 21:16:56.000000000 +0100
14179 +++ linux-3.0.25-vs2.3.2.3/include/net/route.h 2012-03-01 21:51:50.000000000 +0100
14180 @@ -202,6 +202,9 @@ static inline void ip_rt_put(struct rtab
14181 dst_release(&rt->dst);
14184 +#include <linux/vs_base.h>
14185 +#include <linux/vs_inet.h>
14187 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14189 extern const __u8 ip_tos2prio[16];
14190 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
14191 protocol, flow_flags, dst, src, dport, sport);
14194 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
14195 + struct flowi4 *);
14197 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
14198 __be32 dst, __be32 src, u32 tos,
14199 int oif, u8 protocol,
14200 @@ -261,11 +267,25 @@ static inline struct rtable *ip_route_co
14202 struct net *net = sock_net(sk);
14204 + struct nx_info *nx_info = current_nx_info();
14206 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
14207 sport, dport, sk, can_sleep);
14209 - if (!dst || !src) {
14211 + nx_info = sk->sk_nx_info;
14213 + vxdprintk(VXD_CBIT(net, 4),
14214 + "ip_route_connect(%p) %p,%p;%lx",
14215 + sk, nx_info, sk->sk_socket,
14216 + (sk->sk_socket?sk->sk_socket->flags:0));
14218 + rt = ip_v4_find_src(net, nx_info, fl4);
14223 + if (!fl4->daddr || !fl4->saddr) {
14224 rt = __ip_route_output_key(net, fl4);
14227 diff -NurpP --minimal linux-3.0.25/include/net/sock.h linux-3.0.25-vs2.3.2.3/include/net/sock.h
14228 --- linux-3.0.25/include/net/sock.h 2011-07-22 11:18:12.000000000 +0200
14229 +++ linux-3.0.25-vs2.3.2.3/include/net/sock.h 2011-07-01 11:35:35.000000000 +0200
14230 @@ -149,6 +149,10 @@ struct sock_common {
14231 #ifdef CONFIG_NET_NS
14232 struct net *skc_net;
14235 + struct vx_info *skc_vx_info;
14237 + struct nx_info *skc_nx_info;
14239 * fields between dontcopy_begin/dontcopy_end
14240 * are not copied in sock_copy()
14241 @@ -256,6 +260,10 @@ struct sock {
14242 #define sk_bind_node __sk_common.skc_bind_node
14243 #define sk_prot __sk_common.skc_prot
14244 #define sk_net __sk_common.skc_net
14245 +#define sk_xid __sk_common.skc_xid
14246 +#define sk_vx_info __sk_common.skc_vx_info
14247 +#define sk_nid __sk_common.skc_nid
14248 +#define sk_nx_info __sk_common.skc_nx_info
14249 socket_lock_t sk_lock;
14250 struct sk_buff_head sk_receive_queue;
14252 diff -NurpP --minimal linux-3.0.25/init/Kconfig linux-3.0.25-vs2.3.2.3/init/Kconfig
14253 --- linux-3.0.25/init/Kconfig 2011-07-22 11:18:12.000000000 +0200
14254 +++ linux-3.0.25-vs2.3.2.3/init/Kconfig 2011-08-08 18:08:57.000000000 +0200
14255 @@ -574,6 +574,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14257 boolean "Control Group support"
14261 This option adds support for grouping sets of processes together, for
14262 use with process control subsystems such as Cpusets, CFS, memory
14263 @@ -790,6 +791,7 @@ config IPC_NS
14265 bool "User namespace (EXPERIMENTAL)"
14266 depends on EXPERIMENTAL
14267 + depends on VSERVER_DISABLED
14270 This allows containers, i.e. vservers, to use user namespaces
14271 diff -NurpP --minimal linux-3.0.25/init/main.c linux-3.0.25-vs2.3.2.3/init/main.c
14272 --- linux-3.0.25/init/main.c 2011-07-22 11:18:12.000000000 +0200
14273 +++ linux-3.0.25-vs2.3.2.3/init/main.c 2011-06-22 12:39:15.000000000 +0200
14275 #include <linux/shmem_fs.h>
14276 #include <linux/slab.h>
14277 #include <linux/perf_event.h>
14278 +#include <linux/vserver/percpu.h>
14280 #include <asm/io.h>
14281 #include <asm/bugs.h>
14282 diff -NurpP --minimal linux-3.0.25/ipc/mqueue.c linux-3.0.25-vs2.3.2.3/ipc/mqueue.c
14283 --- linux-3.0.25/ipc/mqueue.c 2012-03-19 21:16:56.000000000 +0100
14284 +++ linux-3.0.25-vs2.3.2.3/ipc/mqueue.c 2011-10-18 14:03:46.000000000 +0200
14286 #include <linux/pid.h>
14287 #include <linux/ipc_namespace.h>
14288 #include <linux/slab.h>
14289 +#include <linux/vs_context.h>
14290 +#include <linux/vs_limit.h>
14292 #include <net/sock.h>
14294 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14295 struct sigevent notify;
14296 struct pid* notify_owner;
14297 struct user_struct *user; /* user who created, for accounting */
14298 + struct vx_info *vxi;
14299 struct sock *notify_sock;
14300 struct sk_buff *notify_cookie;
14302 @@ -128,6 +131,7 @@ static struct inode *mqueue_get_inode(st
14303 if (S_ISREG(mode)) {
14304 struct mqueue_inode_info *info;
14305 struct task_struct *p = current;
14306 + struct vx_info *vxi = p->vx_info;
14307 unsigned long mq_bytes, mq_msg_tblsz;
14309 inode->i_fop = &mqueue_file_operations;
14310 @@ -141,6 +145,7 @@ static struct inode *mqueue_get_inode(st
14311 info->notify_owner = NULL;
14313 info->user = NULL; /* set when all is ok */
14314 + info->vxi = NULL;
14315 memset(&info->attr, 0, sizeof(info->attr));
14316 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14317 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14318 @@ -158,17 +163,20 @@ static struct inode *mqueue_get_inode(st
14320 spin_lock(&mq_lock);
14321 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14322 - u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) {
14323 + u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE) ||
14324 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14325 spin_unlock(&mq_lock);
14326 /* mqueue_evict_inode() releases info->messages */
14330 u->mq_bytes += mq_bytes;
14331 + vx_ipcmsg_add(vxi, u, mq_bytes);
14332 spin_unlock(&mq_lock);
14335 info->user = get_uid(u);
14336 + info->vxi = get_vx_info(vxi);
14337 } else if (S_ISDIR(mode)) {
14339 /* Some things misbehave if size == 0 on a directory */
14340 @@ -278,8 +286,11 @@ static void mqueue_evict_inode(struct in
14341 + info->attr.mq_msgsize);
14344 + struct vx_info *vxi = info->vxi;
14346 spin_lock(&mq_lock);
14347 user->mq_bytes -= mq_bytes;
14348 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14350 * get_ns_from_inode() ensures that the
14351 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14352 @@ -289,6 +300,7 @@ static void mqueue_evict_inode(struct in
14354 ipc_ns->mq_queues_count--;
14355 spin_unlock(&mq_lock);
14356 + put_vx_info(vxi);
14360 diff -NurpP --minimal linux-3.0.25/ipc/msg.c linux-3.0.25-vs2.3.2.3/ipc/msg.c
14361 --- linux-3.0.25/ipc/msg.c 2011-05-22 16:17:59.000000000 +0200
14362 +++ linux-3.0.25-vs2.3.2.3/ipc/msg.c 2011-06-10 22:11:24.000000000 +0200
14364 #include <linux/rwsem.h>
14365 #include <linux/nsproxy.h>
14366 #include <linux/ipc_namespace.h>
14367 +#include <linux/vs_base.h>
14369 #include <asm/current.h>
14370 #include <asm/uaccess.h>
14371 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14373 msq->q_perm.mode = msgflg & S_IRWXUGO;
14374 msq->q_perm.key = key;
14375 + msq->q_perm.xid = vx_current_xid();
14377 msq->q_perm.security = NULL;
14378 retval = security_msg_queue_alloc(msq);
14379 diff -NurpP --minimal linux-3.0.25/ipc/namespace.c linux-3.0.25-vs2.3.2.3/ipc/namespace.c
14380 --- linux-3.0.25/ipc/namespace.c 2011-07-22 11:18:12.000000000 +0200
14381 +++ linux-3.0.25-vs2.3.2.3/ipc/namespace.c 2011-06-13 14:09:44.000000000 +0200
14382 @@ -13,11 +13,12 @@
14383 #include <linux/mount.h>
14384 #include <linux/user_namespace.h>
14385 #include <linux/proc_fs.h>
14386 +#include <linux/vs_base.h>
14387 +#include <linux/vserver/global.h>
14391 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
14392 - struct ipc_namespace *old_ns)
14393 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
14395 struct ipc_namespace *ns;
14397 @@ -46,19 +47,18 @@ static struct ipc_namespace *create_ipc_
14398 ipcns_notify(IPCNS_CREATED);
14399 register_ipcns_notifier(ns);
14401 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
14402 + ns->user_ns = get_user_ns(user_ns);
14407 struct ipc_namespace *copy_ipcs(unsigned long flags,
14408 - struct task_struct *tsk)
14409 + struct ipc_namespace *old_ns,
14410 + struct user_namespace *user_ns)
14412 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
14414 if (!(flags & CLONE_NEWIPC))
14415 - return get_ipc_ns(ns);
14416 - return create_ipc_ns(tsk, ns);
14417 + return get_ipc_ns(old_ns);
14418 + return create_ipc_ns(user_ns);
14422 diff -NurpP --minimal linux-3.0.25/ipc/sem.c linux-3.0.25-vs2.3.2.3/ipc/sem.c
14423 --- linux-3.0.25/ipc/sem.c 2012-03-19 21:16:56.000000000 +0100
14424 +++ linux-3.0.25-vs2.3.2.3/ipc/sem.c 2011-08-08 23:04:47.000000000 +0200
14426 #include <linux/rwsem.h>
14427 #include <linux/nsproxy.h>
14428 #include <linux/ipc_namespace.h>
14429 +#include <linux/vs_base.h>
14430 +#include <linux/vs_limit.h>
14432 #include <asm/uaccess.h>
14434 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
14436 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14437 sma->sem_perm.key = key;
14438 + sma->sem_perm.xid = vx_current_xid();
14440 sma->sem_perm.security = NULL;
14441 retval = security_sem_alloc(sma);
14442 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
14445 ns->used_sems += nsems;
14446 + /* FIXME: obsoleted? */
14447 + vx_semary_inc(sma);
14448 + vx_nsems_add(sma, nsems);
14450 sma->sem_base = (struct sem *) &sma[1];
14452 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
14454 wake_up_sem_queue_do(&tasks);
14455 ns->used_sems -= sma->sem_nsems;
14456 + /* FIXME: obsoleted? */
14457 + vx_nsems_sub(sma, sma->sem_nsems);
14458 + vx_semary_dec(sma);
14459 security_sem_free(sma);
14460 ipc_rcu_putref(sma);
14462 diff -NurpP --minimal linux-3.0.25/ipc/shm.c linux-3.0.25-vs2.3.2.3/ipc/shm.c
14463 --- linux-3.0.25/ipc/shm.c 2011-07-22 11:18:12.000000000 +0200
14464 +++ linux-3.0.25-vs2.3.2.3/ipc/shm.c 2011-06-10 22:11:24.000000000 +0200
14466 #include <linux/nsproxy.h>
14467 #include <linux/mount.h>
14468 #include <linux/ipc_namespace.h>
14469 +#include <linux/vs_context.h>
14470 +#include <linux/vs_limit.h>
14472 #include <asm/uaccess.h>
14474 @@ -173,7 +175,12 @@ static void shm_open(struct vm_area_stru
14476 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14478 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14479 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14480 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14482 + vx_ipcshm_sub(vxi, shp, numpages);
14483 + ns->shm_tot -= numpages;
14487 if (!is_file_hugepages(shp->shm_file))
14488 @@ -183,6 +190,7 @@ static void shm_destroy(struct ipc_names
14490 fput (shp->shm_file);
14491 security_shm_free(shp);
14492 + put_vx_info(vxi);
14493 ipc_rcu_putref(shp);
14496 @@ -355,11 +363,15 @@ static int newseg(struct ipc_namespace *
14497 if (ns->shm_tot + numpages > ns->shm_ctlall)
14500 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14503 shp = ipc_rcu_alloc(sizeof(*shp));
14507 shp->shm_perm.key = key;
14508 + shp->shm_perm.xid = vx_current_xid();
14509 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14510 shp->mlock_user = NULL;
14512 @@ -413,6 +425,7 @@ static int newseg(struct ipc_namespace *
14513 ns->shm_tot += numpages;
14514 error = shp->shm_perm.id;
14516 + vx_ipcshm_add(current_vx_info(), key, numpages);
14520 diff -NurpP --minimal linux-3.0.25/kernel/Makefile linux-3.0.25-vs2.3.2.3/kernel/Makefile
14521 --- linux-3.0.25/kernel/Makefile 2011-07-22 11:18:12.000000000 +0200
14522 +++ linux-3.0.25-vs2.3.2.3/kernel/Makefile 2011-06-10 22:11:24.000000000 +0200
14523 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
14524 CFLAGS_REMOVE_irq_work.o = -pg
14528 obj-$(CONFIG_FREEZER) += freezer.o
14529 obj-$(CONFIG_PROFILING) += profile.o
14530 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
14531 diff -NurpP --minimal linux-3.0.25/kernel/capability.c linux-3.0.25-vs2.3.2.3/kernel/capability.c
14532 --- linux-3.0.25/kernel/capability.c 2011-07-22 11:18:12.000000000 +0200
14533 +++ linux-3.0.25-vs2.3.2.3/kernel/capability.c 2011-10-27 13:59:20.000000000 +0200
14535 #include <linux/syscalls.h>
14536 #include <linux/pid_namespace.h>
14537 #include <linux/user_namespace.h>
14538 +#include <linux/vs_context.h>
14539 #include <asm/uaccess.h>
14542 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
14548 * The only thing that can change the capabilities of the current
14549 * process is the current process. As such, we can't be in this code
14550 @@ -340,6 +342,8 @@ bool has_capability_noaudit(struct task_
14554 +#include <linux/vserver/base.h>
14557 * capable - Determine if the current task has a superior capability in effect
14558 * @cap: The capability to be tested for
14559 diff -NurpP --minimal linux-3.0.25/kernel/compat.c linux-3.0.25-vs2.3.2.3/kernel/compat.c
14560 --- linux-3.0.25/kernel/compat.c 2011-07-22 11:18:12.000000000 +0200
14561 +++ linux-3.0.25-vs2.3.2.3/kernel/compat.c 2011-06-10 22:11:24.000000000 +0200
14562 @@ -970,7 +970,7 @@ asmlinkage long compat_sys_stime(compat_
14566 - do_settimeofday(&tv);
14567 + vx_settimeofday(&tv);
14571 diff -NurpP --minimal linux-3.0.25/kernel/cred.c linux-3.0.25-vs2.3.2.3/kernel/cred.c
14572 --- linux-3.0.25/kernel/cred.c 2011-07-22 11:18:12.000000000 +0200
14573 +++ linux-3.0.25-vs2.3.2.3/kernel/cred.c 2011-06-10 22:11:24.000000000 +0200
14574 @@ -61,31 +61,6 @@ struct cred init_cred = {
14578 -static inline void set_cred_subscribers(struct cred *cred, int n)
14580 -#ifdef CONFIG_DEBUG_CREDENTIALS
14581 - atomic_set(&cred->subscribers, n);
14585 -static inline int read_cred_subscribers(const struct cred *cred)
14587 -#ifdef CONFIG_DEBUG_CREDENTIALS
14588 - return atomic_read(&cred->subscribers);
14594 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14596 -#ifdef CONFIG_DEBUG_CREDENTIALS
14597 - struct cred *cred = (struct cred *) _cred;
14599 - atomic_add(n, &cred->subscribers);
14604 * Dispose of the shared task group credentials
14606 @@ -281,21 +256,16 @@ error:
14608 * Call commit_creds() or abort_creds() to clean up.
14610 -struct cred *prepare_creds(void)
14611 +struct cred *__prepare_creds(const struct cred *old)
14613 - struct task_struct *task = current;
14614 - const struct cred *old;
14617 - validate_process_creds();
14619 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14623 kdebug("prepare_creds() alloc %p", new);
14625 - old = task->cred;
14626 memcpy(new, old, sizeof(struct cred));
14628 atomic_set(&new->usage, 1);
14629 @@ -322,6 +292,13 @@ error:
14634 +struct cred *prepare_creds(void)
14636 + validate_process_creds();
14638 + return __prepare_creds(current->cred);
14640 EXPORT_SYMBOL(prepare_creds);
14643 diff -NurpP --minimal linux-3.0.25/kernel/exit.c linux-3.0.25-vs2.3.2.3/kernel/exit.c
14644 --- linux-3.0.25/kernel/exit.c 2012-03-19 21:16:56.000000000 +0100
14645 +++ linux-3.0.25-vs2.3.2.3/kernel/exit.c 2012-01-10 09:19:13.000000000 +0100
14647 #include <linux/fs_struct.h>
14648 #include <linux/init_task.h>
14649 #include <linux/perf_event.h>
14650 +#include <linux/vs_limit.h>
14651 +#include <linux/vs_context.h>
14652 +#include <linux/vs_network.h>
14653 +#include <linux/vs_pid.h>
14654 #include <trace/events/sched.h>
14655 #include <linux/hw_breakpoint.h>
14656 #include <linux/oom.h>
14657 @@ -494,9 +498,11 @@ static void close_files(struct files_str
14658 filp_close(file, files);
14661 + vx_openfd_dec(i);
14669 @@ -1047,11 +1053,16 @@ NORET_TYPE void do_exit(long code)
14671 validate_creds_for_do_exit(tsk);
14673 + /* needs to stay after exit_notify() */
14674 + exit_vx_info(tsk, code);
14675 + exit_nx_info(tsk);
14679 /* causes final put_task_struct in finish_task_switch(). */
14680 tsk->state = TASK_DEAD;
14682 + printk("bad task: %p [%lx]\n", current, current->state);
14684 /* Avoid "noreturn function does return". */
14686 diff -NurpP --minimal linux-3.0.25/kernel/fork.c linux-3.0.25-vs2.3.2.3/kernel/fork.c
14687 --- linux-3.0.25/kernel/fork.c 2012-03-19 21:16:56.000000000 +0100
14688 +++ linux-3.0.25-vs2.3.2.3/kernel/fork.c 2012-03-01 21:52:38.000000000 +0100
14690 #include <linux/oom.h>
14691 #include <linux/khugepaged.h>
14692 #include <linux/signalfd.h>
14693 +#include <linux/vs_context.h>
14694 +#include <linux/vs_network.h>
14695 +#include <linux/vs_limit.h>
14696 +#include <linux/vs_memory.h>
14698 #include <asm/pgtable.h>
14699 #include <asm/pgalloc.h>
14700 @@ -168,6 +172,8 @@ void free_task(struct task_struct *tsk)
14701 account_kernel_stack(tsk->stack, -1);
14702 free_thread_info(tsk->stack);
14703 rt_mutex_debug_task_free(tsk);
14704 + clr_vx_info(&tsk->vx_info);
14705 + clr_nx_info(&tsk->nx_info);
14706 ftrace_graph_exit_task(tsk);
14707 free_task_struct(tsk);
14709 @@ -506,6 +512,7 @@ static struct mm_struct * mm_init(struct
14710 if (likely(!mm_alloc_pgd(mm))) {
14712 mmu_notifier_mm_init(mm);
14713 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14717 @@ -543,6 +550,7 @@ void __mmdrop(struct mm_struct *mm)
14718 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14719 VM_BUG_ON(mm->pmd_huge_pte);
14721 + clr_vx_info(&mm->mm_vx_info);
14724 EXPORT_SYMBOL_GPL(__mmdrop);
14725 @@ -730,6 +738,7 @@ struct mm_struct *dup_mm(struct task_str
14728 memcpy(mm, oldmm, sizeof(*mm));
14729 + mm->mm_vx_info = NULL;
14730 mm_init_cpumask(mm);
14732 /* Initializing for Swap token stuff */
14733 @@ -773,6 +782,7 @@ fail_nocontext:
14734 * If init_new_context() failed, we cannot use mmput() to free the mm
14735 * because it calls destroy_context()
14737 + clr_vx_info(&mm->mm_vx_info);
14741 @@ -1060,6 +1070,8 @@ static struct task_struct *copy_process(
14743 struct task_struct *p;
14744 int cgroup_callbacks_done = 0;
14745 + struct vx_info *vxi;
14746 + struct nx_info *nxi;
14748 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14749 return ERR_PTR(-EINVAL);
14750 @@ -1106,7 +1118,12 @@ static struct task_struct *copy_process(
14751 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14752 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14754 + init_vx_info(&p->vx_info, current_vx_info());
14755 + init_nx_info(&p->nx_info, current_nx_info());
14758 + if (!vx_nproc_avail(1))
14759 + goto bad_fork_free;
14760 if (atomic_read(&p->real_cred->user->processes) >=
14761 task_rlimit(p, RLIMIT_NPROC)) {
14762 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14763 @@ -1363,6 +1380,18 @@ static struct task_struct *copy_process(
14766 spin_unlock(¤t->sighand->siglock);
14768 + /* p is copy of current */
14769 + vxi = p->vx_info;
14771 + claim_vx_info(vxi, p);
14772 + atomic_inc(&vxi->cvirt.nr_threads);
14773 + atomic_inc(&vxi->cvirt.total_forks);
14776 + nxi = p->nx_info;
14778 + claim_nx_info(nxi, p);
14779 write_unlock_irq(&tasklist_lock);
14780 proc_fork_connector(p);
14781 cgroup_post_fork(p);
14782 diff -NurpP --minimal linux-3.0.25/kernel/kthread.c linux-3.0.25-vs2.3.2.3/kernel/kthread.c
14783 --- linux-3.0.25/kernel/kthread.c 2011-07-22 11:18:12.000000000 +0200
14784 +++ linux-3.0.25-vs2.3.2.3/kernel/kthread.c 2011-06-10 22:11:24.000000000 +0200
14786 #include <linux/mutex.h>
14787 #include <linux/slab.h>
14788 #include <linux/freezer.h>
14789 +#include <linux/vs_pid.h>
14790 #include <trace/events/sched.h>
14792 static DEFINE_SPINLOCK(kthread_create_lock);
14793 diff -NurpP --minimal linux-3.0.25/kernel/nsproxy.c linux-3.0.25-vs2.3.2.3/kernel/nsproxy.c
14794 --- linux-3.0.25/kernel/nsproxy.c 2011-07-22 11:18:12.000000000 +0200
14795 +++ linux-3.0.25-vs2.3.2.3/kernel/nsproxy.c 2011-06-13 14:09:44.000000000 +0200
14797 #include <linux/mnt_namespace.h>
14798 #include <linux/utsname.h>
14799 #include <linux/pid_namespace.h>
14800 +#include <linux/vserver/global.h>
14801 +#include <linux/vserver/debug.h>
14802 #include <net/net_namespace.h>
14803 #include <linux/ipc_namespace.h>
14804 #include <linux/proc_fs.h>
14805 @@ -46,8 +48,11 @@ static inline struct nsproxy *create_nsp
14806 struct nsproxy *nsproxy;
14808 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14811 atomic_set(&nsproxy->count, 1);
14812 + atomic_inc(&vs_global_nsproxy);
14814 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14818 @@ -56,8 +61,11 @@ static inline struct nsproxy *create_nsp
14819 * Return the newly created nsproxy. Do not attach this to the task,
14820 * leave it to the caller to do proper locking and attach it to task.
14822 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14823 - struct task_struct *tsk, struct fs_struct *new_fs)
14824 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14825 + struct nsproxy *orig,
14826 + struct fs_struct *new_fs,
14827 + struct user_namespace *new_user,
14828 + struct pid_namespace *new_pid)
14830 struct nsproxy *new_nsp;
14832 @@ -66,31 +74,31 @@ static struct nsproxy *create_new_namesp
14834 return ERR_PTR(-ENOMEM);
14836 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
14837 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
14838 if (IS_ERR(new_nsp->mnt_ns)) {
14839 err = PTR_ERR(new_nsp->mnt_ns);
14843 - new_nsp->uts_ns = copy_utsname(flags, tsk);
14844 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
14845 if (IS_ERR(new_nsp->uts_ns)) {
14846 err = PTR_ERR(new_nsp->uts_ns);
14850 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
14851 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
14852 if (IS_ERR(new_nsp->ipc_ns)) {
14853 err = PTR_ERR(new_nsp->ipc_ns);
14857 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
14858 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
14859 if (IS_ERR(new_nsp->pid_ns)) {
14860 err = PTR_ERR(new_nsp->pid_ns);
14864 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
14865 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
14866 if (IS_ERR(new_nsp->net_ns)) {
14867 err = PTR_ERR(new_nsp->net_ns);
14869 @@ -115,6 +123,40 @@ out_ns:
14870 return ERR_PTR(err);
14873 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14874 + struct task_struct *tsk, struct fs_struct *new_fs)
14876 + return unshare_namespaces(flags, tsk->nsproxy,
14877 + new_fs, task_cred_xxx(tsk, user)->user_ns,
14878 + task_active_pid_ns(tsk));
14882 + * copies the nsproxy, setting refcount to 1, and grabbing a
14883 + * reference to all contained namespaces.
14885 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14887 + struct nsproxy *ns = create_nsproxy();
14890 + memcpy(ns, orig, sizeof(struct nsproxy));
14891 + atomic_set(&ns->count, 1);
14894 + get_mnt_ns(ns->mnt_ns);
14896 + get_uts_ns(ns->uts_ns);
14898 + get_ipc_ns(ns->ipc_ns);
14900 + get_pid_ns(ns->pid_ns);
14902 + get_net(ns->net_ns);
14908 * called from clone. This now handles copy for nsproxy and all
14909 * namespaces therein.
14910 @@ -122,9 +164,12 @@ out_ns:
14911 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
14913 struct nsproxy *old_ns = tsk->nsproxy;
14914 - struct nsproxy *new_ns;
14915 + struct nsproxy *new_ns = NULL;
14918 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14919 + flags, tsk, old_ns);
14924 @@ -134,7 +179,7 @@ int copy_namespaces(unsigned long flags,
14925 CLONE_NEWPID | CLONE_NEWNET)))
14928 - if (!capable(CAP_SYS_ADMIN)) {
14929 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
14933 @@ -161,6 +206,9 @@ int copy_namespaces(unsigned long flags,
14936 put_nsproxy(old_ns);
14937 + vxdprintk(VXD_CBIT(space, 3),
14938 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14939 + flags, tsk, old_ns, err, new_ns);
14943 @@ -174,7 +222,9 @@ void free_nsproxy(struct nsproxy *ns)
14944 put_ipc_ns(ns->ipc_ns);
14946 put_pid_ns(ns->pid_ns);
14947 - put_net(ns->net_ns);
14949 + put_net(ns->net_ns);
14950 + atomic_dec(&vs_global_nsproxy);
14951 kmem_cache_free(nsproxy_cachep, ns);
14954 @@ -187,11 +237,15 @@ int unshare_nsproxy_namespaces(unsigned
14958 + vxdprintk(VXD_CBIT(space, 4),
14959 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14960 + unshare_flags, current->nsproxy);
14962 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14966 - if (!capable(CAP_SYS_ADMIN))
14967 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
14970 *new_nsp = create_new_namespaces(unshare_flags, current,
14971 diff -NurpP --minimal linux-3.0.25/kernel/pid.c linux-3.0.25-vs2.3.2.3/kernel/pid.c
14972 --- linux-3.0.25/kernel/pid.c 2011-05-22 16:17:59.000000000 +0200
14973 +++ linux-3.0.25-vs2.3.2.3/kernel/pid.c 2011-06-10 22:11:24.000000000 +0200
14975 #include <linux/pid_namespace.h>
14976 #include <linux/init_task.h>
14977 #include <linux/syscalls.h>
14978 +#include <linux/vs_pid.h>
14980 #define pid_hashfn(nr, ns) \
14981 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14982 @@ -342,7 +343,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14984 struct pid *find_vpid(int nr)
14986 - return find_pid_ns(nr, current->nsproxy->pid_ns);
14987 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
14989 EXPORT_SYMBOL_GPL(find_vpid);
14991 @@ -402,6 +403,9 @@ void transfer_pid(struct task_struct *ol
14992 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14994 struct task_struct *result = NULL;
14996 + if (type == PIDTYPE_REALPID)
14997 + type = PIDTYPE_PID;
14999 struct hlist_node *first;
15000 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
15001 @@ -420,7 +424,7 @@ EXPORT_SYMBOL(pid_task);
15002 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15004 rcu_lockdep_assert(rcu_read_lock_held());
15005 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15006 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15009 struct task_struct *find_task_by_vpid(pid_t vnr)
15010 @@ -464,7 +468,7 @@ struct pid *find_get_pid(pid_t nr)
15012 EXPORT_SYMBOL_GPL(find_get_pid);
15014 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15015 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15019 @@ -477,6 +481,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15023 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15025 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15028 pid_t pid_vnr(struct pid *pid)
15030 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15031 diff -NurpP --minimal linux-3.0.25/kernel/pid_namespace.c linux-3.0.25-vs2.3.2.3/kernel/pid_namespace.c
15032 --- linux-3.0.25/kernel/pid_namespace.c 2011-05-22 16:17:59.000000000 +0200
15033 +++ linux-3.0.25-vs2.3.2.3/kernel/pid_namespace.c 2011-06-10 22:17:45.000000000 +0200
15035 #include <linux/acct.h>
15036 #include <linux/slab.h>
15037 #include <linux/proc_fs.h>
15038 +#include <linux/vserver/global.h>
15040 #define BITS_PER_PAGE (PAGE_SIZE*8)
15042 @@ -88,6 +89,7 @@ static struct pid_namespace *create_pid_
15045 kref_init(&ns->kref);
15046 + atomic_inc(&vs_global_pid_ns);
15048 ns->parent = get_pid_ns(parent_pid_ns);
15050 @@ -119,6 +121,7 @@ static void destroy_pid_namespace(struct
15052 for (i = 0; i < PIDMAP_ENTRIES; i++)
15053 kfree(ns->pidmap[i].page);
15054 + atomic_dec(&vs_global_pid_ns);
15055 kmem_cache_free(pid_ns_cachep, ns);
15058 diff -NurpP --minimal linux-3.0.25/kernel/posix-timers.c linux-3.0.25-vs2.3.2.3/kernel/posix-timers.c
15059 --- linux-3.0.25/kernel/posix-timers.c 2011-07-22 11:18:12.000000000 +0200
15060 +++ linux-3.0.25-vs2.3.2.3/kernel/posix-timers.c 2011-06-10 22:11:24.000000000 +0200
15062 #include <linux/wait.h>
15063 #include <linux/workqueue.h>
15064 #include <linux/module.h>
15065 +#include <linux/vs_context.h>
15068 * Management arrays for POSIX timers. Timers are kept in slab memory
15069 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
15071 struct task_struct *task;
15072 int shared, ret = -1;
15075 * FIXME: if ->sigq is queued we can race with
15076 * dequeue_signal()->do_schedule_next_timer().
15077 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
15079 task = pid_task(timr->it_pid, PIDTYPE_PID);
15081 + struct vx_info_save vxis;
15082 + struct vx_info *vxi;
15084 + vxi = get_vx_info(task->vx_info);
15085 + enter_vx_info(vxi, &vxis);
15086 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15087 ret = send_sigqueue(timr->sigq, task, shared);
15088 + leave_vx_info(&vxis);
15089 + put_vx_info(vxi);
15093 /* If we failed to send the signal the timer stops. */
15096 diff -NurpP --minimal linux-3.0.25/kernel/printk.c linux-3.0.25-vs2.3.2.3/kernel/printk.c
15097 --- linux-3.0.25/kernel/printk.c 2012-03-19 21:16:56.000000000 +0100
15098 +++ linux-3.0.25-vs2.3.2.3/kernel/printk.c 2012-02-07 02:05:58.000000000 +0100
15100 #include <linux/cpu.h>
15101 #include <linux/notifier.h>
15102 #include <linux/rculist.h>
15103 +#include <linux/vs_cvirt.h>
15105 #include <asm/uaccess.h>
15107 @@ -314,7 +315,7 @@ static int check_syslog_permissions(int
15110 if (syslog_action_restricted(type)) {
15111 - if (capable(CAP_SYSLOG))
15112 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
15114 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
15115 if (capable(CAP_SYS_ADMIN)) {
15116 @@ -344,12 +345,9 @@ int do_syslog(int type, char __user *buf
15121 - case SYSLOG_ACTION_CLOSE: /* Close log */
15123 - case SYSLOG_ACTION_OPEN: /* Open log */
15125 - case SYSLOG_ACTION_READ: /* Read from log */
15126 + if ((type == SYSLOG_ACTION_READ) ||
15127 + (type == SYSLOG_ACTION_READ_ALL) ||
15128 + (type == SYSLOG_ACTION_READ_CLEAR)) {
15130 if (!buf || len < 0)
15132 @@ -360,6 +358,16 @@ int do_syslog(int type, char __user *buf
15137 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15138 + return vx_do_syslog(type, buf, len);
15141 + case SYSLOG_ACTION_CLOSE: /* Close log */
15143 + case SYSLOG_ACTION_OPEN: /* Open log */
15145 + case SYSLOG_ACTION_READ: /* Read from log */
15146 error = wait_event_interruptible(log_wait,
15147 (log_start - log_end));
15149 @@ -386,16 +394,6 @@ int do_syslog(int type, char __user *buf
15151 /* Read last kernel messages */
15152 case SYSLOG_ACTION_READ_ALL:
15154 - if (!buf || len < 0)
15159 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15164 if (count > log_buf_len)
15165 count = log_buf_len;
15166 diff -NurpP --minimal linux-3.0.25/kernel/ptrace.c linux-3.0.25-vs2.3.2.3/kernel/ptrace.c
15167 --- linux-3.0.25/kernel/ptrace.c 2011-07-22 11:18:12.000000000 +0200
15168 +++ linux-3.0.25-vs2.3.2.3/kernel/ptrace.c 2011-11-21 16:29:59.000000000 +0100
15170 #include <linux/syscalls.h>
15171 #include <linux/uaccess.h>
15172 #include <linux/regset.h>
15173 +#include <linux/vs_context.h>
15174 #include <linux/hw_breakpoint.h>
15177 @@ -145,9 +146,15 @@ int __ptrace_may_access(struct task_stru
15178 * or halting the specified task is impossible.
15182 /* Don't let security modules deny introspection */
15183 if (task == current)
15186 + vxdprintk(VXD_CBIT(perm, 8),
15187 + "__ptrace_may_access(%p[#%d,%d,%d], %d)",
15188 + task, task->xid, task->pid, task->tgid, mode);
15191 tcred = __task_cred(task);
15192 if (cred->user->user_ns == tcred->user->user_ns &&
15193 @@ -161,6 +168,8 @@ int __ptrace_may_access(struct task_stru
15194 if (ns_capable(tcred->user->user_ns, CAP_SYS_PTRACE))
15197 + vxdprintk(VXD_CBIT(perm, 8),
15198 + "__ptrace_may_access(%p) cred/cap failed", task);
15202 @@ -169,6 +178,19 @@ ok:
15203 dumpable = get_dumpable(task->mm);
15204 if (!dumpable && !task_ns_capable(task, CAP_SYS_PTRACE))
15206 + vxdprintk(VXD_CBIT(perm, 8),
15207 + "__ptrace_may_access(%p) cap/dump ok", task);
15209 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
15211 + vxdprintk(VXD_CBIT(perm, 8),
15212 + "__ptrace_may_access(%p) check ok", task);
15214 + if (!vx_check(task->xid, VS_IDENT) &&
15215 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15217 + vxdprintk(VXD_CBIT(perm, 8),
15218 + "__ptrace_may_access(%p) admin ok", task);
15220 return security_ptrace_access_check(task, mode);
15222 diff -NurpP --minimal linux-3.0.25/kernel/sched.c linux-3.0.25-vs2.3.2.3/kernel/sched.c
15223 --- linux-3.0.25/kernel/sched.c 2012-03-19 21:16:56.000000000 +0100
15224 +++ linux-3.0.25-vs2.3.2.3/kernel/sched.c 2011-10-18 13:51:13.000000000 +0200
15226 #include <linux/ctype.h>
15227 #include <linux/ftrace.h>
15228 #include <linux/slab.h>
15229 +#include <linux/vs_sched.h>
15230 +#include <linux/vs_cvirt.h>
15232 #include <asm/tlb.h>
15233 #include <asm/irq_regs.h>
15234 @@ -3461,9 +3463,17 @@ static void calc_global_nohz(unsigned lo
15236 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
15238 - loads[0] = (avenrun[0] + offset) << shift;
15239 - loads[1] = (avenrun[1] + offset) << shift;
15240 - loads[2] = (avenrun[2] + offset) << shift;
15241 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
15242 + struct vx_info *vxi = current_vx_info();
15244 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15245 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15246 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15248 + loads[0] = (avenrun[0] + offset) << shift;
15249 + loads[1] = (avenrun[1] + offset) << shift;
15250 + loads[2] = (avenrun[2] + offset) << shift;
15255 @@ -3722,16 +3732,19 @@ void account_user_time(struct task_struc
15256 cputime_t cputime_scaled)
15258 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15259 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15261 + int nice = (TASK_NICE(p) > 0);
15263 /* Add user time to process. */
15264 p->utime = cputime_add(p->utime, cputime);
15265 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15266 + vx_account_user(vxi, cputime, nice);
15267 account_group_user_time(p, cputime);
15269 /* Add user time to cpustat. */
15270 tmp = cputime_to_cputime64(cputime);
15271 - if (TASK_NICE(p) > 0)
15273 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15275 cpustat->user = cputime64_add(cpustat->user, tmp);
15276 @@ -3783,10 +3796,12 @@ void __account_system_time(struct task_s
15277 cputime_t cputime_scaled, cputime64_t *target_cputime64)
15279 cputime64_t tmp = cputime_to_cputime64(cputime);
15280 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15282 /* Add system time to process. */
15283 p->stime = cputime_add(p->stime, cputime);
15284 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15285 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15286 account_group_system_time(p, cputime);
15288 /* Add system time to cpustat. */
15289 @@ -4954,7 +4969,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15292 if (increment < 0 && !can_nice(current, nice))
15294 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15296 retval = security_task_setnice(current, nice);
15298 diff -NurpP --minimal linux-3.0.25/kernel/sched_fair.c linux-3.0.25-vs2.3.2.3/kernel/sched_fair.c
15299 --- linux-3.0.25/kernel/sched_fair.c 2011-07-22 11:18:12.000000000 +0200
15300 +++ linux-3.0.25-vs2.3.2.3/kernel/sched_fair.c 2011-07-22 11:20:39.000000000 +0200
15301 @@ -998,6 +998,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15302 __enqueue_entity(cfs_rq, se);
15305 + if (entity_is_task(se))
15306 + vx_activate_task(task_of(se));
15307 if (cfs_rq->nr_running == 1)
15308 list_add_leaf_cfs_rq(cfs_rq);
15310 @@ -1074,6 +1076,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15311 if (se != cfs_rq->curr)
15312 __dequeue_entity(cfs_rq, se);
15314 + if (entity_is_task(se))
15315 + vx_deactivate_task(task_of(se));
15316 update_cfs_load(cfs_rq, 0);
15317 account_entity_dequeue(cfs_rq, se);
15319 diff -NurpP --minimal linux-3.0.25/kernel/signal.c linux-3.0.25-vs2.3.2.3/kernel/signal.c
15320 --- linux-3.0.25/kernel/signal.c 2012-03-19 21:16:56.000000000 +0100
15321 +++ linux-3.0.25-vs2.3.2.3/kernel/signal.c 2011-11-15 17:37:07.000000000 +0100
15323 #include <linux/freezer.h>
15324 #include <linux/pid_namespace.h>
15325 #include <linux/nsproxy.h>
15326 +#include <linux/vs_context.h>
15327 +#include <linux/vs_pid.h>
15328 #define CREATE_TRACE_POINTS
15329 #include <trace/events/signal.h>
15331 @@ -744,9 +746,18 @@ static int check_kill_permission(int sig
15335 + vxdprintk(VXD_CBIT(misc, 7),
15336 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15337 + sig, info, t, vx_task_xid(t), t->pid);
15339 if (!valid_signal(sig))
15342 +/* FIXME: needed? if so, why?
15343 + if ((info != SEND_SIG_NOINFO) &&
15344 + (is_si_special(info) || !si_fromuser(info)))
15347 if (!si_fromuser(info))
15350 @@ -770,6 +781,20 @@ static int check_kill_permission(int sig
15355 + if (t->pid == 1 && current->xid)
15359 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15360 + loops, maybe ENOENT or EACCES? */
15361 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15362 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15363 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15364 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15368 return security_task_kill(t, info, sig, 0);
15371 @@ -1246,7 +1271,7 @@ int kill_pid_info(int sig, struct siginf
15374 p = pid_task(pid, PIDTYPE_PID);
15376 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15377 error = group_send_sig_info(sig, info, p);
15378 if (unlikely(error == -ESRCH))
15380 @@ -1285,7 +1310,7 @@ int kill_pid_info_as_uid(int sig, struct
15383 p = pid_task(pid, PIDTYPE_PID);
15385 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15389 @@ -1340,8 +1365,10 @@ static int kill_something_info(int sig,
15390 struct task_struct * p;
15392 for_each_process(p) {
15393 - if (task_pid_vnr(p) > 1 &&
15394 - !same_thread_group(p, current)) {
15395 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15396 + task_pid_vnr(p) > 1 &&
15397 + !same_thread_group(p, current) &&
15398 + !vx_current_initpid(p->pid)) {
15399 int err = group_send_sig_info(sig, info, p);
15402 @@ -2138,6 +2165,11 @@ relock:
15403 !sig_kernel_only(signr))
15406 + /* virtual init is protected against user signals */
15407 + if ((info->si_code == SI_USER) &&
15408 + vx_current_initpid(current->pid))
15411 if (sig_kernel_stop(signr)) {
15413 * The default action is to stop all threads in
15414 diff -NurpP --minimal linux-3.0.25/kernel/softirq.c linux-3.0.25-vs2.3.2.3/kernel/softirq.c
15415 --- linux-3.0.25/kernel/softirq.c 2011-07-22 11:18:12.000000000 +0200
15416 +++ linux-3.0.25-vs2.3.2.3/kernel/softirq.c 2011-07-22 11:20:39.000000000 +0200
15418 #include <linux/ftrace.h>
15419 #include <linux/smp.h>
15420 #include <linux/tick.h>
15421 +#include <linux/vs_context.h>
15423 #define CREATE_TRACE_POINTS
15424 #include <trace/events/irq.h>
15425 diff -NurpP --minimal linux-3.0.25/kernel/sys.c linux-3.0.25-vs2.3.2.3/kernel/sys.c
15426 --- linux-3.0.25/kernel/sys.c 2012-03-19 21:16:56.000000000 +0100
15427 +++ linux-3.0.25-vs2.3.2.3/kernel/sys.c 2011-11-15 17:37:07.000000000 +0100
15429 #include <linux/syscalls.h>
15430 #include <linux/kprobes.h>
15431 #include <linux/user_namespace.h>
15432 +#include <linux/vs_pid.h>
15434 #include <linux/kmsg_dump.h>
15435 /* Move somewhere else to avoid recompiling? */
15436 @@ -155,7 +156,10 @@ static int set_one_prio(struct task_stru
15439 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15441 + if (vx_flags(VXF_IGNEG_NICE, 0))
15447 no_nice = security_task_setnice(p, niceval);
15448 @@ -205,6 +209,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15450 pgrp = task_pgrp(current);
15451 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15452 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15454 error = set_one_prio(p, niceval, error);
15455 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15457 @@ -268,6 +274,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15459 pgrp = task_pgrp(current);
15460 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15461 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15463 niceval = 20 - task_nice(p);
15464 if (niceval > retval)
15466 @@ -387,6 +395,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15468 static DEFINE_MUTEX(reboot_mutex);
15470 +long vs_reboot(unsigned int, void __user *);
15473 * Reboot system call: for obvious reasons only root may call it,
15474 * and even root needs to set up some magic numbers in the registers
15475 @@ -419,6 +429,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15476 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15477 cmd = LINUX_REBOOT_CMD_HALT;
15479 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15480 + return vs_reboot(cmd, arg);
15482 mutex_lock(&reboot_mutex);
15484 case LINUX_REBOOT_CMD_RESTART:
15485 @@ -1235,7 +1248,8 @@ SYSCALL_DEFINE2(sethostname, char __user
15487 char tmp[__NEW_UTS_LEN];
15489 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15490 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15491 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15494 if (len < 0 || len > __NEW_UTS_LEN)
15495 @@ -1285,7 +1299,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
15497 char tmp[__NEW_UTS_LEN];
15499 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15500 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15501 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15503 if (len < 0 || len > __NEW_UTS_LEN)
15505 @@ -1403,7 +1418,7 @@ int do_prlimit(struct task_struct *tsk,
15506 /* Keep the capable check against init_user_ns until
15507 cgroups can contain all limits */
15508 if (new_rlim->rlim_max > rlim->rlim_max &&
15509 - !capable(CAP_SYS_RESOURCE))
15510 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15513 retval = security_task_setrlimit(tsk->group_leader,
15514 @@ -1457,7 +1472,8 @@ static int check_prlimit_permission(stru
15515 cred->gid == tcred->sgid &&
15516 cred->gid == tcred->gid))
15518 - if (ns_capable(tcred->user->user_ns, CAP_SYS_RESOURCE))
15519 + if (vx_ns_capable(tcred->user->user_ns,
15520 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15524 diff -NurpP --minimal linux-3.0.25/kernel/sysctl.c linux-3.0.25-vs2.3.2.3/kernel/sysctl.c
15525 --- linux-3.0.25/kernel/sysctl.c 2011-07-22 11:18:12.000000000 +0200
15526 +++ linux-3.0.25-vs2.3.2.3/kernel/sysctl.c 2011-06-15 02:40:14.000000000 +0200
15528 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15529 #include <linux/lockdep.h>
15531 +extern char vshelper_path[];
15532 #ifdef CONFIG_CHR_DEV_SG
15533 #include <scsi/sg.h>
15535 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
15536 .proc_handler = proc_dostring,
15540 + .procname = "vshelper",
15541 + .data = &vshelper_path,
15544 + .proc_handler = &proc_dostring,
15546 #ifdef CONFIG_CHR_DEV_SG
15548 .procname = "sg-big-buff",
15549 diff -NurpP --minimal linux-3.0.25/kernel/sysctl_binary.c linux-3.0.25-vs2.3.2.3/kernel/sysctl_binary.c
15550 --- linux-3.0.25/kernel/sysctl_binary.c 2012-03-19 21:16:56.000000000 +0100
15551 +++ linux-3.0.25-vs2.3.2.3/kernel/sysctl_binary.c 2012-01-10 09:19:13.000000000 +0100
15552 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15554 { CTL_INT, KERN_PANIC, "panic" },
15555 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15556 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15558 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15559 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15560 diff -NurpP --minimal linux-3.0.25/kernel/time/timekeeping.c linux-3.0.25-vs2.3.2.3/kernel/time/timekeeping.c
15561 --- linux-3.0.25/kernel/time/timekeeping.c 2012-03-19 21:16:56.000000000 +0100
15562 +++ linux-3.0.25-vs2.3.2.3/kernel/time/timekeeping.c 2011-12-19 15:55:53.000000000 +0100
15563 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
15564 } while (read_seqretry(&xtime_lock, seq));
15566 timespec_add_ns(ts, nsecs);
15567 + vx_adjust_timespec(ts);
15570 EXPORT_SYMBOL(getnstimeofday);
15571 diff -NurpP --minimal linux-3.0.25/kernel/time.c linux-3.0.25-vs2.3.2.3/kernel/time.c
15572 --- linux-3.0.25/kernel/time.c 2012-03-19 21:16:56.000000000 +0100
15573 +++ linux-3.0.25-vs2.3.2.3/kernel/time.c 2011-11-15 17:37:07.000000000 +0100
15574 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15578 - do_settimeofday(&tv);
15579 + vx_settimeofday(&tv);
15583 @@ -177,7 +177,7 @@ int do_sys_settimeofday(const struct tim
15584 /* SMP safe, again the code in arch/foo/time.c should
15585 * globally block out interrupts when it runs.
15587 - return do_settimeofday(tv);
15588 + return vx_settimeofday(tv);
15592 diff -NurpP --minimal linux-3.0.25/kernel/timer.c linux-3.0.25-vs2.3.2.3/kernel/timer.c
15593 --- linux-3.0.25/kernel/timer.c 2011-07-22 11:18:12.000000000 +0200
15594 +++ linux-3.0.25-vs2.3.2.3/kernel/timer.c 2011-06-15 02:40:14.000000000 +0200
15596 #include <linux/irq_work.h>
15597 #include <linux/sched.h>
15598 #include <linux/slab.h>
15599 +#include <linux/vs_base.h>
15600 +#include <linux/vs_cvirt.h>
15601 +#include <linux/vs_pid.h>
15602 +#include <linux/vserver/sched.h>
15604 #include <asm/uaccess.h>
15605 #include <asm/unistd.h>
15606 @@ -1336,12 +1340,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15613 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15614 - * should be moved into arch/i386 instead?
15618 * sys_getpid - return the thread group id of the current process
15619 @@ -1370,10 +1368,23 @@ SYSCALL_DEFINE0(getppid)
15621 pid = task_tgid_vnr(current->real_parent);
15623 + return vx_map_pid(pid);
15630 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15633 +asmlinkage long do_getxpid(long *ppid)
15635 + *ppid = sys_getppid();
15636 + return sys_getpid();
15639 +#else /* _alpha_ */
15641 SYSCALL_DEFINE0(getuid)
15643 /* Only we change this so SMP safe */
15644 diff -NurpP --minimal linux-3.0.25/kernel/user_namespace.c linux-3.0.25-vs2.3.2.3/kernel/user_namespace.c
15645 --- linux-3.0.25/kernel/user_namespace.c 2011-03-15 18:07:42.000000000 +0100
15646 +++ linux-3.0.25-vs2.3.2.3/kernel/user_namespace.c 2011-06-10 22:11:24.000000000 +0200
15648 #include <linux/user_namespace.h>
15649 #include <linux/highuid.h>
15650 #include <linux/cred.h>
15651 +#include <linux/vserver/global.h>
15653 static struct kmem_cache *user_ns_cachep __read_mostly;
15655 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
15658 kref_init(&ns->kref);
15659 + atomic_inc(&vs_global_user_ns);
15661 for (n = 0; n < UIDHASH_SZ; ++n)
15662 INIT_HLIST_HEAD(ns->uidhash_table + n);
15663 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
15664 struct user_namespace *ns =
15665 container_of(kref, struct user_namespace, kref);
15667 + /* FIXME: maybe move into destroyer? */
15668 + atomic_dec(&vs_global_user_ns);
15669 INIT_WORK(&ns->destroyer, free_user_ns_work);
15670 schedule_work(&ns->destroyer);
15672 diff -NurpP --minimal linux-3.0.25/kernel/utsname.c linux-3.0.25-vs2.3.2.3/kernel/utsname.c
15673 --- linux-3.0.25/kernel/utsname.c 2011-07-22 11:18:12.000000000 +0200
15674 +++ linux-3.0.25-vs2.3.2.3/kernel/utsname.c 2011-06-13 14:09:44.000000000 +0200
15675 @@ -16,14 +16,17 @@
15676 #include <linux/slab.h>
15677 #include <linux/user_namespace.h>
15678 #include <linux/proc_fs.h>
15679 +#include <linux/vserver/global.h>
15681 static struct uts_namespace *create_uts_ns(void)
15683 struct uts_namespace *uts_ns;
15685 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15688 kref_init(&uts_ns->kref);
15689 + atomic_inc(&vs_global_uts_ns);
15694 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
15695 * @old_ns: namespace to clone
15696 * Return NULL on error (failure to kmalloc), new ns otherwise
15698 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
15699 - struct uts_namespace *old_ns)
15700 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
15701 + struct user_namespace *old_user)
15703 struct uts_namespace *ns;
15705 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
15707 down_read(&uts_sem);
15708 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
15709 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
15710 + ns->user_ns = get_user_ns(old_user);
15714 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
15717 struct uts_namespace *copy_utsname(unsigned long flags,
15718 - struct task_struct *tsk)
15719 + struct uts_namespace *old_ns,
15720 + struct user_namespace *user_ns)
15722 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
15723 struct uts_namespace *new_ns;
15726 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
15727 if (!(flags & CLONE_NEWUTS))
15730 - new_ns = clone_uts_ns(tsk, old_ns);
15731 + new_ns = clone_uts_ns(old_ns, user_ns);
15733 put_uts_ns(old_ns);
15735 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
15737 ns = container_of(kref, struct uts_namespace, kref);
15738 put_user_ns(ns->user_ns);
15739 + atomic_dec(&vs_global_uts_ns);
15743 diff -NurpP --minimal linux-3.0.25/kernel/vserver/Kconfig linux-3.0.25-vs2.3.2.3/kernel/vserver/Kconfig
15744 --- linux-3.0.25/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
15745 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/Kconfig 2011-08-08 18:06:22.000000000 +0200
15748 +# Linux VServer configuration
15751 +menu "Linux VServer"
15753 +config VSERVER_AUTO_LBACK
15754 + bool "Automatically Assign Loopback IP"
15757 + Automatically assign a guest specific loopback
15758 + IP and add it to the kernel network stack on
15761 +config VSERVER_AUTO_SINGLE
15762 + bool "Automatic Single IP Special Casing"
15763 + depends on EXPERIMENTAL
15766 + This allows network contexts with a single IP to
15767 + automatically remap 0.0.0.0 bindings to that IP,
15768 + avoiding further network checks and improving
15771 + (note: such guests do not allow to change the ip
15772 + on the fly and do not show loopback addresses)
15774 +config VSERVER_COWBL
15775 + bool "Enable COW Immutable Link Breaking"
15778 + This enables the COW (Copy-On-Write) link break code.
15779 + It allows you to treat unified files like normal files
15780 + when writing to them (which will implicitely break the
15781 + link and create a copy of the unified file)
15783 +config VSERVER_VTIME
15784 + bool "Enable Virtualized Guest Time"
15785 + depends on EXPERIMENTAL
15788 + This enables per guest time offsets to allow for
15789 + adjusting the system clock individually per guest.
15790 + this adds some overhead to the time functions and
15791 + therefore should not be enabled without good reason.
15793 +config VSERVER_DEVICE
15794 + bool "Enable Guest Device Mapping"
15795 + depends on EXPERIMENTAL
15798 + This enables generic device remapping.
15800 +config VSERVER_PROC_SECURE
15801 + bool "Enable Proc Security"
15802 + depends on PROC_FS
15805 + This configures ProcFS security to initially hide
15806 + non-process entries for all contexts except the main and
15807 + spectator context (i.e. for all guests), which is a secure
15810 + (note: on 1.2x the entries were visible by default)
15813 + prompt "Persistent Inode Tagging"
15814 + default TAGGING_ID24
15816 + This adds persistent context information to filesystems
15817 + mounted with the tagxid option. Tagging is a requirement
15818 + for per-context disk limits and per-context quota.
15821 +config TAGGING_NONE
15824 + do not store per-context information in inodes.
15826 +config TAGGING_UID16
15827 + bool "UID16/GID32"
15829 + reduces UID to 16 bit, but leaves GID at 32 bit.
15831 +config TAGGING_GID16
15832 + bool "UID32/GID16"
15834 + reduces GID to 16 bit, but leaves UID at 32 bit.
15836 +config TAGGING_ID24
15837 + bool "UID24/GID24"
15839 + uses the upper 8bit from UID and GID for XID tagging
15840 + which leaves 24bit for UID/GID each, which should be
15841 + more than sufficient for normal use.
15843 +config TAGGING_INTERN
15844 + bool "UID32/GID32"
15846 + this uses otherwise reserved inode fields in the on
15847 + disk representation, which limits the use to a few
15848 + filesystems (currently ext2 and ext3)
15853 + bool "Tag NFSD User Auth and Files"
15856 + Enable this if you do want the in-kernel NFS
15857 + Server to use the tagging specified above.
15858 + (will require patched clients too)
15860 +config VSERVER_PRIVACY
15861 + bool "Honor Privacy Aspects of Guests"
15864 + When enabled, most context checks will disallow
15865 + access to structures assigned to a specific context,
15866 + like ptys or loop devices.
15868 +config VSERVER_CONTEXTS
15869 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15871 + default "768" if 64BIT
15874 + This setting will optimize certain data structures
15875 + and memory allocations according to the expected
15878 + note: this is not a strict upper limit.
15880 +config VSERVER_WARN
15881 + bool "VServer Warnings"
15884 + This enables various runtime warnings, which will
15885 + notify about potential manipulation attempts or
15886 + resource shortage. It is generally considered to
15887 + be a good idea to have that enabled.
15889 +config VSERVER_WARN_DEVPTS
15890 + bool "VServer DevPTS Warnings"
15891 + depends on VSERVER_WARN
15894 + This enables DevPTS related warnings, issued when a
15895 + process inside a context tries to lookup or access
15896 + a dynamic pts from the host or a different context.
15898 +config VSERVER_DEBUG
15899 + bool "VServer Debugging Code"
15902 + Set this to yes if you want to be able to activate
15903 + debugging output at runtime. It adds a very small
15904 + overhead to all vserver related functions and
15905 + increases the kernel size by about 20k.
15907 +config VSERVER_HISTORY
15908 + bool "VServer History Tracing"
15909 + depends on VSERVER_DEBUG
15912 + Set this to yes if you want to record the history of
15913 + linux-vserver activities, so they can be replayed in
15914 + the event of a kernel panic or oops.
15916 +config VSERVER_HISTORY_SIZE
15917 + int "Per-CPU History Size (32-65536)"
15918 + depends on VSERVER_HISTORY
15922 + This allows you to specify the number of entries in
15923 + the per-CPU history buffer.
15925 +config VSERVER_LEGACY_MEM
15926 + bool "Legacy Memory Limits"
15929 + This provides fake memory limits to keep
15930 + older tools happy in the face of memory
15934 + prompt "Quotes used in debug and warn messages"
15935 + default QUOTES_ISO8859
15937 +config QUOTES_ISO8859
15938 + bool "Extended ASCII (ISO 8859) angle quotes"
15940 + This uses the extended ASCII characters \xbb
15941 + and \xab for quoting file and process names.
15943 +config QUOTES_UTF8
15944 + bool "UTF-8 angle quotes"
15946 + This uses the the UTF-8 sequences for angle
15947 + quotes to quote file and process names.
15949 +config QUOTES_ASCII
15950 + bool "ASCII single quotes"
15952 + This uses the ASCII single quote character
15953 + (\x27) to quote file and process names.
15963 + select NAMESPACES
15969 +config VSERVER_SECURITY
15971 + depends on SECURITY
15973 + select SECURITY_CAPABILITIES
15975 +config VSERVER_DISABLED
15979 diff -NurpP --minimal linux-3.0.25/kernel/vserver/Makefile linux-3.0.25-vs2.3.2.3/kernel/vserver/Makefile
15980 --- linux-3.0.25/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
15981 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/Makefile 2011-06-10 22:11:24.000000000 +0200
15984 +# Makefile for the Linux vserver routines.
15988 +obj-y += vserver.o
15990 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15991 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15994 +vserver-$(CONFIG_INET) += inet.o
15995 +vserver-$(CONFIG_PROC_FS) += proc.o
15996 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15997 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15998 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15999 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
16001 diff -NurpP --minimal linux-3.0.25/kernel/vserver/cacct.c linux-3.0.25-vs2.3.2.3/kernel/vserver/cacct.c
16002 --- linux-3.0.25/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
16003 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cacct.c 2011-06-10 22:11:24.000000000 +0200
16006 + * linux/kernel/vserver/cacct.c
16008 + * Virtual Server: Context Accounting
16010 + * Copyright (C) 2006-2007 Herbert Pötzl
16012 + * V0.01 added accounting stats
16016 +#include <linux/types.h>
16017 +#include <linux/vs_context.h>
16018 +#include <linux/vserver/cacct_cmd.h>
16019 +#include <linux/vserver/cacct_int.h>
16021 +#include <asm/errno.h>
16022 +#include <asm/uaccess.h>
16025 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16027 + struct vcmd_sock_stat_v0 vc_data;
16030 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16033 + field = vc_data.field;
16034 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16037 + for (j = 0; j < 3; j++) {
16038 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16039 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16042 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16047 diff -NurpP --minimal linux-3.0.25/kernel/vserver/cacct_init.h linux-3.0.25-vs2.3.2.3/kernel/vserver/cacct_init.h
16048 --- linux-3.0.25/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16049 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cacct_init.h 2011-06-10 22:11:24.000000000 +0200
16053 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16058 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16059 + for (j = 0; j < 3; j++) {
16060 + atomic_long_set(&cacct->sock[i][j].count, 0);
16061 + atomic_long_set(&cacct->sock[i][j].total, 0);
16064 + for (i = 0; i < 8; i++)
16065 + atomic_set(&cacct->slab[i], 0);
16066 + for (i = 0; i < 5; i++)
16067 + for (j = 0; j < 4; j++)
16068 + atomic_set(&cacct->page[i][j], 0);
16071 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16076 diff -NurpP --minimal linux-3.0.25/kernel/vserver/cacct_proc.h linux-3.0.25-vs2.3.2.3/kernel/vserver/cacct_proc.h
16077 --- linux-3.0.25/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16078 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cacct_proc.h 2011-06-10 22:11:24.000000000 +0200
16080 +#ifndef _VX_CACCT_PROC_H
16081 +#define _VX_CACCT_PROC_H
16083 +#include <linux/vserver/cacct_int.h>
16086 +#define VX_SOCKA_TOP \
16087 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16089 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16091 + int i, j, length = 0;
16092 + static char *type[VXA_SOCK_SIZE] = {
16093 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16096 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16097 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16098 + length += sprintf(buffer + length, "%s:", type[i]);
16099 + for (j = 0; j < 3; j++) {
16100 + length += sprintf(buffer + length,
16101 + "\t%10lu/%-10lu",
16102 + vx_sock_count(cacct, i, j),
16103 + vx_sock_total(cacct, i, j));
16105 + buffer[length++] = '\n';
16108 + length += sprintf(buffer + length, "\n");
16109 + length += sprintf(buffer + length,
16110 + "slab:\t %8u %8u %8u %8u\n",
16111 + atomic_read(&cacct->slab[1]),
16112 + atomic_read(&cacct->slab[4]),
16113 + atomic_read(&cacct->slab[0]),
16114 + atomic_read(&cacct->slab[2]));
16116 + length += sprintf(buffer + length, "\n");
16117 + for (i = 0; i < 5; i++) {
16118 + length += sprintf(buffer + length,
16119 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16120 + atomic_read(&cacct->page[i][0]),
16121 + atomic_read(&cacct->page[i][1]),
16122 + atomic_read(&cacct->page[i][2]),
16123 + atomic_read(&cacct->page[i][3]),
16124 + atomic_read(&cacct->page[i][4]),
16125 + atomic_read(&cacct->page[i][5]),
16126 + atomic_read(&cacct->page[i][6]),
16127 + atomic_read(&cacct->page[i][7]));
16132 +#endif /* _VX_CACCT_PROC_H */
16133 diff -NurpP --minimal linux-3.0.25/kernel/vserver/context.c linux-3.0.25-vs2.3.2.3/kernel/vserver/context.c
16134 --- linux-3.0.25/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16135 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/context.c 2011-08-01 18:28:12.000000000 +0200
16138 + * linux/kernel/vserver/context.c
16140 + * Virtual Server: Context Support
16142 + * Copyright (C) 2003-2011 Herbert Pötzl
16144 + * V0.01 context helper
16145 + * V0.02 vx_ctx_kill syscall command
16146 + * V0.03 replaced context_info calls
16147 + * V0.04 redesign of struct (de)alloc
16148 + * V0.05 rlimit basic implementation
16149 + * V0.06 task_xid and info commands
16150 + * V0.07 context flags and caps
16151 + * V0.08 switch to RCU based hash
16152 + * V0.09 revert to non RCU for now
16153 + * V0.10 and back to working RCU hash
16154 + * V0.11 and back to locking again
16155 + * V0.12 referenced context store
16156 + * V0.13 separate per cpu data
16157 + * V0.14 changed vcmds to vxi arg
16158 + * V0.15 added context stat
16159 + * V0.16 have __create claim() the vxi
16160 + * V0.17 removed older and legacy stuff
16161 + * V0.18 added user credentials
16162 + * V0.19 added warn mask
16166 +#include <linux/slab.h>
16167 +#include <linux/types.h>
16168 +#include <linux/security.h>
16169 +#include <linux/pid_namespace.h>
16170 +#include <linux/capability.h>
16172 +#include <linux/vserver/context.h>
16173 +#include <linux/vserver/network.h>
16174 +#include <linux/vserver/debug.h>
16175 +#include <linux/vserver/limit.h>
16176 +#include <linux/vserver/limit_int.h>
16177 +#include <linux/vserver/space.h>
16178 +#include <linux/init_task.h>
16179 +#include <linux/fs_struct.h>
16180 +#include <linux/cred.h>
16182 +#include <linux/vs_context.h>
16183 +#include <linux/vs_limit.h>
16184 +#include <linux/vs_pid.h>
16185 +#include <linux/vserver/context_cmd.h>
16187 +#include "cvirt_init.h"
16188 +#include "cacct_init.h"
16189 +#include "limit_init.h"
16190 +#include "sched_init.h"
16193 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16194 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16197 +/* now inactive context structures */
16199 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16201 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
16204 +/* __alloc_vx_info()
16206 + * allocate an initialized vx_info struct
16207 + * doesn't make it visible (hash) */
16209 +static struct vx_info *__alloc_vx_info(xid_t xid)
16211 + struct vx_info *new = NULL;
16214 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16216 + /* would this benefit from a slab cache? */
16217 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16221 + memset(new, 0, sizeof(struct vx_info));
16223 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16224 + if (!new->ptr_pc)
16227 + new->vx_id = xid;
16228 + INIT_HLIST_NODE(&new->vx_hlist);
16229 + atomic_set(&new->vx_usecnt, 0);
16230 + atomic_set(&new->vx_tasks, 0);
16231 + new->vx_parent = NULL;
16232 + new->vx_state = 0;
16233 + init_waitqueue_head(&new->vx_wait);
16235 + /* prepare reaper */
16236 + get_task_struct(init_pid_ns.child_reaper);
16237 + new->vx_reaper = init_pid_ns.child_reaper;
16238 + new->vx_badness_bias = 0;
16240 + /* rest of init goes here */
16241 + vx_info_init_limit(&new->limit);
16242 + vx_info_init_sched(&new->sched);
16243 + vx_info_init_cvirt(&new->cvirt);
16244 + vx_info_init_cacct(&new->cacct);
16246 + /* per cpu data structures */
16247 + for_each_possible_cpu(cpu) {
16248 + vx_info_init_sched_pc(
16249 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16250 + vx_info_init_cvirt_pc(
16251 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16254 + new->vx_flags = VXF_INIT_SET;
16255 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
16256 + new->vx_ccaps = 0;
16257 + new->vx_umask = 0;
16258 + new->vx_wmask = 0;
16260 + new->reboot_cmd = 0;
16261 + new->exit_code = 0;
16263 + // preconfig spaces
16264 + for (index = 0; index < VX_SPACES; index++) {
16265 + struct _vx_space *space = &new->space[index];
16268 + spin_lock(&init_fs.lock);
16270 + spin_unlock(&init_fs.lock);
16271 + space->vx_fs = &init_fs;
16273 + /* FIXME: do we want defaults? */
16274 + // space->vx_real_cred = 0;
16275 + // space->vx_cred = 0;
16279 + vxdprintk(VXD_CBIT(xid, 0),
16280 + "alloc_vx_info(%d) = %p", xid, new);
16281 + vxh_alloc_vx_info(new);
16282 + atomic_inc(&vx_global_ctotal);
16291 +/* __dealloc_vx_info()
16293 + * final disposal of vx_info */
16295 +static void __dealloc_vx_info(struct vx_info *vxi)
16297 +#ifdef CONFIG_VSERVER_WARN
16298 + struct vx_info_save vxis;
16301 + vxdprintk(VXD_CBIT(xid, 0),
16302 + "dealloc_vx_info(%p)", vxi);
16303 + vxh_dealloc_vx_info(vxi);
16305 +#ifdef CONFIG_VSERVER_WARN
16306 + enter_vx_info(vxi, &vxis);
16307 + vx_info_exit_limit(&vxi->limit);
16308 + vx_info_exit_sched(&vxi->sched);
16309 + vx_info_exit_cvirt(&vxi->cvirt);
16310 + vx_info_exit_cacct(&vxi->cacct);
16312 + for_each_possible_cpu(cpu) {
16313 + vx_info_exit_sched_pc(
16314 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16315 + vx_info_exit_cvirt_pc(
16316 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16318 + leave_vx_info(&vxis);
16322 + vxi->vx_state |= VXS_RELEASED;
16325 + free_percpu(vxi->ptr_pc);
16328 + atomic_dec(&vx_global_ctotal);
16331 +static void __shutdown_vx_info(struct vx_info *vxi)
16333 + struct nsproxy *nsproxy;
16334 + struct fs_struct *fs;
16335 + struct cred *cred;
16340 + vxi->vx_state |= VXS_SHUTDOWN;
16341 + vs_state_change(vxi, VSC_SHUTDOWN);
16343 + for (index = 0; index < VX_SPACES; index++) {
16344 + struct _vx_space *space = &vxi->space[index];
16346 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16348 + put_nsproxy(nsproxy);
16350 + fs = xchg(&space->vx_fs, NULL);
16351 + spin_lock(&fs->lock);
16352 + kill = !--fs->users;
16353 + spin_unlock(&fs->lock);
16355 + free_fs_struct(fs);
16357 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16359 + abort_creds(cred);
16363 +/* exported stuff */
16365 +void free_vx_info(struct vx_info *vxi)
16367 + unsigned long flags;
16370 + /* check for reference counts first */
16371 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16372 + BUG_ON(atomic_read(&vxi->vx_tasks));
16374 + /* context must not be hashed */
16375 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16377 + /* context shutdown is mandatory */
16378 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16380 + /* spaces check */
16381 + for (index = 0; index < VX_SPACES; index++) {
16382 + struct _vx_space *space = &vxi->space[index];
16384 + BUG_ON(space->vx_nsproxy);
16385 + BUG_ON(space->vx_fs);
16386 + // BUG_ON(space->vx_real_cred);
16387 + // BUG_ON(space->vx_cred);
16390 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16391 + hlist_del(&vxi->vx_hlist);
16392 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16394 + __dealloc_vx_info(vxi);
16398 +/* hash table for vx_info hash */
16400 +#define VX_HASH_SIZE 13
16402 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16403 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16405 +static DEFINE_SPINLOCK(vx_info_hash_lock);
16408 +static inline unsigned int __hashval(xid_t xid)
16410 + return (xid % VX_HASH_SIZE);
16415 +/* __hash_vx_info()
16417 + * add the vxi to the global hash table
16418 + * requires the hash_lock to be held */
16420 +static inline void __hash_vx_info(struct vx_info *vxi)
16422 + struct hlist_head *head;
16424 + vxd_assert_lock(&vx_info_hash_lock);
16425 + vxdprintk(VXD_CBIT(xid, 4),
16426 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16427 + vxh_hash_vx_info(vxi);
16429 + /* context must not be hashed */
16430 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16432 + vxi->vx_state |= VXS_HASHED;
16433 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16434 + hlist_add_head(&vxi->vx_hlist, head);
16435 + atomic_inc(&vx_global_cactive);
16438 +/* __unhash_vx_info()
16440 + * remove the vxi from the global hash table
16441 + * requires the hash_lock to be held */
16443 +static inline void __unhash_vx_info(struct vx_info *vxi)
16445 + unsigned long flags;
16447 + vxd_assert_lock(&vx_info_hash_lock);
16448 + vxdprintk(VXD_CBIT(xid, 4),
16449 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16450 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16451 + vxh_unhash_vx_info(vxi);
16453 + /* context must be hashed */
16454 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16455 + /* but without tasks */
16456 + BUG_ON(atomic_read(&vxi->vx_tasks));
16458 + vxi->vx_state &= ~VXS_HASHED;
16459 + hlist_del_init(&vxi->vx_hlist);
16460 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16461 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16462 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16463 + atomic_dec(&vx_global_cactive);
16467 +/* __lookup_vx_info()
16469 + * requires the hash_lock to be held
16470 + * doesn't increment the vx_refcnt */
16472 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16474 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16475 + struct hlist_node *pos;
16476 + struct vx_info *vxi;
16478 + vxd_assert_lock(&vx_info_hash_lock);
16479 + hlist_for_each(pos, head) {
16480 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16482 + if (vxi->vx_id == xid)
16487 + vxdprintk(VXD_CBIT(xid, 0),
16488 + "__lookup_vx_info(#%u): %p[#%u]",
16489 + xid, vxi, vxi ? vxi->vx_id : 0);
16490 + vxh_lookup_vx_info(vxi, xid);
16495 +/* __create_vx_info()
16497 + * create the requested context
16498 + * get(), claim() and hash it */
16500 +static struct vx_info *__create_vx_info(int id)
16502 + struct vx_info *new, *vxi = NULL;
16504 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16506 + if (!(new = __alloc_vx_info(id)))
16507 + return ERR_PTR(-ENOMEM);
16509 + /* required to make dynamic xids unique */
16510 + spin_lock(&vx_info_hash_lock);
16512 + /* static context requested */
16513 + if ((vxi = __lookup_vx_info(id))) {
16514 + vxdprintk(VXD_CBIT(xid, 0),
16515 + "create_vx_info(%d) = %p (already there)", id, vxi);
16516 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16517 + vxi = ERR_PTR(-EBUSY);
16519 + vxi = ERR_PTR(-EEXIST);
16522 + /* new context */
16523 + vxdprintk(VXD_CBIT(xid, 0),
16524 + "create_vx_info(%d) = %p (new)", id, new);
16525 + claim_vx_info(new, NULL);
16526 + __hash_vx_info(get_vx_info(new));
16527 + vxi = new, new = NULL;
16530 + spin_unlock(&vx_info_hash_lock);
16531 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16533 + __dealloc_vx_info(new);
16538 +/* exported stuff */
16541 +void unhash_vx_info(struct vx_info *vxi)
16543 + spin_lock(&vx_info_hash_lock);
16544 + __unhash_vx_info(vxi);
16545 + spin_unlock(&vx_info_hash_lock);
16546 + __shutdown_vx_info(vxi);
16547 + __wakeup_vx_info(vxi);
16551 +/* lookup_vx_info()
16553 + * search for a vx_info and get() it
16554 + * negative id means current */
16556 +struct vx_info *lookup_vx_info(int id)
16558 + struct vx_info *vxi = NULL;
16561 + vxi = get_vx_info(current_vx_info());
16562 + } else if (id > 1) {
16563 + spin_lock(&vx_info_hash_lock);
16564 + vxi = get_vx_info(__lookup_vx_info(id));
16565 + spin_unlock(&vx_info_hash_lock);
16570 +/* xid_is_hashed()
16572 + * verify that xid is still hashed */
16574 +int xid_is_hashed(xid_t xid)
16578 + spin_lock(&vx_info_hash_lock);
16579 + hashed = (__lookup_vx_info(xid) != NULL);
16580 + spin_unlock(&vx_info_hash_lock);
16584 +#ifdef CONFIG_PROC_FS
16588 + * get a subset of hashed xids for proc
16589 + * assumes size is at least one */
16591 +int get_xid_list(int index, unsigned int *xids, int size)
16593 + int hindex, nr_xids = 0;
16595 + /* only show current and children */
16596 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16599 + xids[nr_xids] = vx_current_xid();
16603 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16604 + struct hlist_head *head = &vx_info_hash[hindex];
16605 + struct hlist_node *pos;
16607 + spin_lock(&vx_info_hash_lock);
16608 + hlist_for_each(pos, head) {
16609 + struct vx_info *vxi;
16614 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16615 + xids[nr_xids] = vxi->vx_id;
16616 + if (++nr_xids >= size) {
16617 + spin_unlock(&vx_info_hash_lock);
16621 + /* keep the lock time short */
16622 + spin_unlock(&vx_info_hash_lock);
16629 +#ifdef CONFIG_VSERVER_DEBUG
16631 +void dump_vx_info_inactive(int level)
16633 + struct hlist_node *entry, *next;
16635 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16636 + struct vx_info *vxi =
16637 + list_entry(entry, struct vx_info, vx_hlist);
16639 + dump_vx_info(vxi, level);
16646 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16648 + struct user_struct *new_user, *old_user;
16653 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16656 + new_user = alloc_uid(vxi->vx_id, p->uid);
16660 + old_user = p->user;
16661 + if (new_user != old_user) {
16662 + atomic_inc(&new_user->processes);
16663 + atomic_dec(&old_user->processes);
16664 + p->user = new_user;
16666 + free_uid(old_user);
16672 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16674 + // p->cap_effective &= vxi->vx_cap_bset;
16675 + p->cap_effective =
16676 + cap_intersect(p->cap_effective, vxi->cap_bset);
16677 + // p->cap_inheritable &= vxi->vx_cap_bset;
16678 + p->cap_inheritable =
16679 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16680 + // p->cap_permitted &= vxi->vx_cap_bset;
16681 + p->cap_permitted =
16682 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16687 +#include <linux/file.h>
16688 +#include <linux/fdtable.h>
16690 +static int vx_openfd_task(struct task_struct *tsk)
16692 + struct files_struct *files = tsk->files;
16693 + struct fdtable *fdt;
16694 + const unsigned long *bptr;
16695 + int count, total;
16697 + /* no rcu_read_lock() because of spin_lock() */
16698 + spin_lock(&files->file_lock);
16699 + fdt = files_fdtable(files);
16700 + bptr = fdt->open_fds->fds_bits;
16701 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16702 + for (total = 0; count > 0; count--) {
16704 + total += hweight_long(*bptr);
16707 + spin_unlock(&files->file_lock);
16712 +/* for *space compatibility */
16714 +asmlinkage long sys_unshare(unsigned long);
16717 + * migrate task to new context
16718 + * gets vxi, puts old_vxi on change
16719 + * optionally unshares namespaces (hack)
16722 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16724 + struct vx_info *old_vxi;
16730 + vxdprintk(VXD_CBIT(xid, 5),
16731 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16732 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16734 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16735 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16738 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16741 + old_vxi = task_get_vx_info(p);
16742 + if (old_vxi == vxi)
16745 +// if (!(ret = vx_migrate_user(p, vxi))) {
16750 + openfd = vx_openfd_task(p);
16753 + atomic_dec(&old_vxi->cvirt.nr_threads);
16754 + atomic_dec(&old_vxi->cvirt.nr_running);
16755 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16756 + /* FIXME: what about the struct files here? */
16757 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16758 + /* account for the executable */
16759 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16761 + atomic_inc(&vxi->cvirt.nr_threads);
16762 + atomic_inc(&vxi->cvirt.nr_running);
16763 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16764 + /* FIXME: what about the struct files here? */
16765 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16766 + /* account for the executable */
16767 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16770 + release_vx_info(old_vxi, p);
16771 + clr_vx_info(&p->vx_info);
16773 + claim_vx_info(vxi, p);
16774 + set_vx_info(&p->vx_info, vxi);
16775 + p->xid = vxi->vx_id;
16777 + vxdprintk(VXD_CBIT(xid, 5),
16778 + "moved task %p into vxi:%p[#%d]",
16779 + p, vxi, vxi->vx_id);
16781 + // vx_mask_cap_bset(vxi, p);
16784 + /* hack for *spaces to provide compatibility */
16786 + struct nsproxy *old_nsp, *new_nsp;
16788 + ret = unshare_nsproxy_namespaces(
16789 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16794 + old_nsp = xchg(&p->nsproxy, new_nsp);
16795 + vx_set_space(vxi,
16796 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16797 + put_nsproxy(old_nsp);
16801 + put_vx_info(old_vxi);
16805 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16807 + struct task_struct *old_reaper;
16812 + vxdprintk(VXD_CBIT(xid, 6),
16813 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16814 + vxi, vxi->vx_id, p, p->xid, p->pid);
16816 + old_reaper = vxi->vx_reaper;
16817 + if (old_reaper == p)
16820 + /* set new child reaper */
16821 + get_task_struct(p);
16822 + vxi->vx_reaper = p;
16823 + put_task_struct(old_reaper);
16827 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16832 + vxdprintk(VXD_CBIT(xid, 6),
16833 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16834 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16836 + vxi->vx_flags &= ~VXF_STATE_INIT;
16837 + // vxi->vx_initpid = p->tgid;
16838 + vxi->vx_initpid = p->pid;
16842 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16844 + vxdprintk(VXD_CBIT(xid, 6),
16845 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16846 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16848 + vxi->exit_code = code;
16849 + vxi->vx_initpid = 0;
16853 +void vx_set_persistent(struct vx_info *vxi)
16855 + vxdprintk(VXD_CBIT(xid, 6),
16856 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16858 + get_vx_info(vxi);
16859 + claim_vx_info(vxi, NULL);
16862 +void vx_clear_persistent(struct vx_info *vxi)
16864 + vxdprintk(VXD_CBIT(xid, 6),
16865 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16867 + release_vx_info(vxi, NULL);
16868 + put_vx_info(vxi);
16871 +void vx_update_persistent(struct vx_info *vxi)
16873 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16874 + vx_set_persistent(vxi);
16876 + vx_clear_persistent(vxi);
16880 +/* task must be current or locked */
16882 +void exit_vx_info(struct task_struct *p, int code)
16884 + struct vx_info *vxi = p->vx_info;
16887 + atomic_dec(&vxi->cvirt.nr_threads);
16890 + vxi->exit_code = code;
16891 + release_vx_info(vxi, p);
16895 +void exit_vx_info_early(struct task_struct *p, int code)
16897 + struct vx_info *vxi = p->vx_info;
16900 + if (vxi->vx_initpid == p->pid)
16901 + vx_exit_init(vxi, p, code);
16902 + if (vxi->vx_reaper == p)
16903 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16908 +/* vserver syscall commands below here */
16910 +/* taks xid and vx_info functions */
16912 +#include <asm/uaccess.h>
16915 +int vc_task_xid(uint32_t id)
16920 + struct task_struct *tsk;
16923 + tsk = find_task_by_real_pid(id);
16924 + xid = (tsk) ? tsk->xid : -ESRCH;
16925 + rcu_read_unlock();
16927 + xid = vx_current_xid();
16932 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16934 + struct vcmd_vx_info_v0 vc_data;
16936 + vc_data.xid = vxi->vx_id;
16937 + vc_data.initpid = vxi->vx_initpid;
16939 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16945 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16947 + struct vcmd_ctx_stat_v0 vc_data;
16949 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16950 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16952 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16958 +/* context functions */
16960 +int vc_ctx_create(uint32_t xid, void __user *data)
16962 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16963 + struct vx_info *new_vxi;
16966 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16969 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16972 + new_vxi = __create_vx_info(xid);
16973 + if (IS_ERR(new_vxi))
16974 + return PTR_ERR(new_vxi);
16976 + /* initial flags */
16977 + new_vxi->vx_flags = vc_data.flagword;
16980 + if (vs_state_change(new_vxi, VSC_STARTUP))
16983 + ret = vx_migrate_task(current, new_vxi, (!data));
16987 + /* return context id on success */
16988 + ret = new_vxi->vx_id;
16990 + /* get a reference for persistent contexts */
16991 + if ((vc_data.flagword & VXF_PERSISTENT))
16992 + vx_set_persistent(new_vxi);
16994 + release_vx_info(new_vxi, NULL);
16995 + put_vx_info(new_vxi);
17000 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
17002 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
17005 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17008 + ret = vx_migrate_task(current, vxi, 0);
17011 + if (vc_data.flagword & VXM_SET_INIT)
17012 + ret = vx_set_init(vxi, current);
17015 + if (vc_data.flagword & VXM_SET_REAPER)
17016 + ret = vx_set_reaper(vxi, current);
17021 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17023 + struct vcmd_ctx_flags_v0 vc_data;
17025 + vc_data.flagword = vxi->vx_flags;
17027 + /* special STATE flag handling */
17028 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17030 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17035 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17037 + struct vcmd_ctx_flags_v0 vc_data;
17038 + uint64_t mask, trigger;
17040 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17043 + /* special STATE flag handling */
17044 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17045 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17047 + if (vxi == current_vx_info()) {
17048 + /* if (trigger & VXF_STATE_SETUP)
17049 + vx_mask_cap_bset(vxi, current); */
17050 + if (trigger & VXF_STATE_INIT) {
17053 + ret = vx_set_init(vxi, current);
17056 + ret = vx_set_reaper(vxi, current);
17062 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17063 + vc_data.flagword, mask);
17064 + if (trigger & VXF_PERSISTENT)
17065 + vx_update_persistent(vxi);
17071 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17073 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17075 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17079 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17081 + kernel_cap_t c = __cap_empty_set;
17083 + c.cap[0] = v & 0xFFFFFFFF;
17084 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17086 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17091 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17094 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17096 + *ccaps = vxi->vx_ccaps;
17101 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17103 + struct vcmd_ctx_caps_v1 vc_data;
17106 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17109 + vc_data.cmask = ~0ULL;
17111 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17116 +static int do_set_caps(struct vx_info *vxi,
17117 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17119 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17122 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17123 + bcaps, bmask, ccaps, cmask);
17125 + vxi->vx_bcaps = cap_t_from_caps(
17126 + vs_mask_flags(bcold, bcaps, bmask));
17127 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17132 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17134 + struct vcmd_ctx_caps_v1 vc_data;
17136 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17139 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17142 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17144 + struct vcmd_bcaps vc_data;
17147 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17150 + vc_data.bmask = ~0ULL;
17152 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17157 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17159 + struct vcmd_bcaps vc_data;
17161 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17164 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17168 +int vc_get_umask(struct vx_info *vxi, void __user *data)
17170 + struct vcmd_umask vc_data;
17172 + vc_data.umask = vxi->vx_umask;
17173 + vc_data.mask = ~0ULL;
17175 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17180 +int vc_set_umask(struct vx_info *vxi, void __user *data)
17182 + struct vcmd_umask vc_data;
17184 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17187 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
17188 + vc_data.umask, vc_data.mask);
17193 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
17195 + struct vcmd_wmask vc_data;
17197 + vc_data.wmask = vxi->vx_wmask;
17198 + vc_data.mask = ~0ULL;
17200 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17205 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
17207 + struct vcmd_wmask vc_data;
17209 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17212 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
17213 + vc_data.wmask, vc_data.mask);
17218 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17220 + struct vcmd_badness_v0 vc_data;
17222 + vc_data.bias = vxi->vx_badness_bias;
17224 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17229 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17231 + struct vcmd_badness_v0 vc_data;
17233 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17236 + vxi->vx_badness_bias = vc_data.bias;
17240 +#include <linux/module.h>
17242 +EXPORT_SYMBOL_GPL(free_vx_info);
17244 diff -NurpP --minimal linux-3.0.25/kernel/vserver/cvirt.c linux-3.0.25-vs2.3.2.3/kernel/vserver/cvirt.c
17245 --- linux-3.0.25/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17246 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cvirt.c 2011-06-13 14:57:26.000000000 +0200
17249 + * linux/kernel/vserver/cvirt.c
17251 + * Virtual Server: Context Virtualization
17253 + * Copyright (C) 2004-2007 Herbert Pötzl
17255 + * V0.01 broken out from limit.c
17256 + * V0.02 added utsname stuff
17257 + * V0.03 changed vcmds to vxi arg
17261 +#include <linux/types.h>
17262 +#include <linux/utsname.h>
17263 +#include <linux/vs_cvirt.h>
17264 +#include <linux/vserver/switch.h>
17265 +#include <linux/vserver/cvirt_cmd.h>
17267 +#include <asm/uaccess.h>
17270 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17272 + struct vx_info *vxi = current_vx_info();
17274 + set_normalized_timespec(uptime,
17275 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17276 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17279 + set_normalized_timespec(idle,
17280 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17281 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17285 +uint64_t vx_idle_jiffies(void)
17287 + return init_task.utime + init_task.stime;
17292 +static inline uint32_t __update_loadavg(uint32_t load,
17293 + int wsize, int delta, int n)
17295 + unsigned long long calc, prev;
17297 + /* just set it to n */
17298 + if (unlikely(delta >= wsize))
17299 + return (n << FSHIFT);
17301 + calc = delta * n;
17303 + prev = (wsize - delta);
17306 + do_div(calc, wsize);
17311 +void vx_update_load(struct vx_info *vxi)
17313 + uint32_t now, last, delta;
17314 + unsigned int nr_running, nr_uninterruptible;
17315 + unsigned int total;
17316 + unsigned long flags;
17318 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17321 + last = vxi->cvirt.load_last;
17322 + delta = now - last;
17324 + if (delta < 5*HZ)
17327 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17328 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17329 + total = nr_running + nr_uninterruptible;
17331 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17332 + 60*HZ, delta, total);
17333 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17334 + 5*60*HZ, delta, total);
17335 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17336 + 15*60*HZ, delta, total);
17338 + vxi->cvirt.load_last = now;
17340 + atomic_inc(&vxi->cvirt.load_updates);
17341 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17346 + * Commands to do_syslog:
17348 + * 0 -- Close the log. Currently a NOP.
17349 + * 1 -- Open the log. Currently a NOP.
17350 + * 2 -- Read from the log.
17351 + * 3 -- Read all messages remaining in the ring buffer.
17352 + * 4 -- Read and clear all messages remaining in the ring buffer
17353 + * 5 -- Clear ring buffer.
17354 + * 6 -- Disable printk's to console
17355 + * 7 -- Enable printk's to console
17356 + * 8 -- Set level of messages printed to console
17357 + * 9 -- Return number of unread characters in the log buffer
17358 + * 10 -- Return size of the log buffer
17360 +int vx_do_syslog(int type, char __user *buf, int len)
17363 + int do_clear = 0;
17364 + struct vx_info *vxi = current_vx_info();
17365 + struct _vx_syslog *log;
17369 + log = &vxi->cvirt.syslog;
17372 + case 0: /* Close log */
17373 + case 1: /* Open log */
17375 + case 2: /* Read from log */
17376 + error = wait_event_interruptible(log->log_wait,
17377 + (log->log_start - log->log_end));
17380 + spin_lock_irq(&log->logbuf_lock);
17381 + spin_unlock_irq(&log->logbuf_lock);
17383 + case 4: /* Read/clear last kernel messages */
17385 + /* fall through */
17386 + case 3: /* Read last kernel messages */
17389 + case 5: /* Clear ring buffer */
17392 + case 6: /* Disable logging to console */
17393 + case 7: /* Enable logging to console */
17394 + case 8: /* Set level of messages printed to console */
17397 + case 9: /* Number of chars in the log buffer */
17399 + case 10: /* Size of the log buffer */
17409 +/* virtual host info names */
17411 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17413 + struct nsproxy *nsproxy;
17414 + struct uts_namespace *uts;
17416 + if (id == VHIN_CONTEXT)
17417 + return vxi->vx_name;
17419 + nsproxy = vxi->space[0].vx_nsproxy;
17423 + uts = nsproxy->uts_ns;
17428 + case VHIN_SYSNAME:
17429 + return uts->name.sysname;
17430 + case VHIN_NODENAME:
17431 + return uts->name.nodename;
17432 + case VHIN_RELEASE:
17433 + return uts->name.release;
17434 + case VHIN_VERSION:
17435 + return uts->name.version;
17436 + case VHIN_MACHINE:
17437 + return uts->name.machine;
17438 + case VHIN_DOMAINNAME:
17439 + return uts->name.domainname;
17446 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17448 + struct vcmd_vhi_name_v0 vc_data;
17451 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17454 + name = vx_vhi_name(vxi, vc_data.field);
17458 + memcpy(name, vc_data.name, 65);
17462 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17464 + struct vcmd_vhi_name_v0 vc_data;
17467 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17470 + name = vx_vhi_name(vxi, vc_data.field);
17474 + memcpy(vc_data.name, name, 65);
17475 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17481 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17483 + struct vcmd_virt_stat_v0 vc_data;
17484 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17485 + struct timespec uptime;
17487 + do_posix_clock_monotonic_gettime(&uptime);
17488 + set_normalized_timespec(&uptime,
17489 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17490 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17492 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17493 + vc_data.uptime = timespec_to_ns(&uptime);
17494 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17495 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17496 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17497 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17498 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17499 + vc_data.load[0] = cvirt->load[0];
17500 + vc_data.load[1] = cvirt->load[1];
17501 + vc_data.load[2] = cvirt->load[2];
17503 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17509 +#ifdef CONFIG_VSERVER_VTIME
17511 +/* virtualized time base */
17513 +void vx_adjust_timespec(struct timespec *ts)
17515 + struct vx_info *vxi;
17517 + if (!vx_flags(VXF_VIRT_TIME, 0))
17520 + vxi = current_vx_info();
17521 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17522 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17524 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17526 + ts->tv_nsec -= NSEC_PER_SEC;
17527 + } else if (ts->tv_nsec < 0) {
17529 + ts->tv_nsec += NSEC_PER_SEC;
17533 +int vx_settimeofday(const struct timespec *ts)
17535 + struct timespec ats, delta;
17536 + struct vx_info *vxi;
17538 + if (!vx_flags(VXF_VIRT_TIME, 0))
17539 + return do_settimeofday(ts);
17541 + getnstimeofday(&ats);
17542 + delta = timespec_sub(*ts, ats);
17544 + vxi = current_vx_info();
17545 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17551 diff -NurpP --minimal linux-3.0.25/kernel/vserver/cvirt_init.h linux-3.0.25-vs2.3.2.3/kernel/vserver/cvirt_init.h
17552 --- linux-3.0.25/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17553 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cvirt_init.h 2011-06-10 22:11:24.000000000 +0200
17557 +extern uint64_t vx_idle_jiffies(void);
17559 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17561 + uint64_t idle_jiffies = vx_idle_jiffies();
17562 + uint64_t nsuptime;
17564 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17565 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17566 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17567 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17568 + cvirt->bias_ts.tv_sec = 0;
17569 + cvirt->bias_ts.tv_nsec = 0;
17571 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17572 + atomic_set(&cvirt->nr_threads, 0);
17573 + atomic_set(&cvirt->nr_running, 0);
17574 + atomic_set(&cvirt->nr_uninterruptible, 0);
17575 + atomic_set(&cvirt->nr_onhold, 0);
17577 + spin_lock_init(&cvirt->load_lock);
17578 + cvirt->load_last = jiffies;
17579 + atomic_set(&cvirt->load_updates, 0);
17580 + cvirt->load[0] = 0;
17581 + cvirt->load[1] = 0;
17582 + cvirt->load[2] = 0;
17583 + atomic_set(&cvirt->total_forks, 0);
17585 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17586 + init_waitqueue_head(&cvirt->syslog.log_wait);
17587 + cvirt->syslog.log_start = 0;
17588 + cvirt->syslog.log_end = 0;
17589 + cvirt->syslog.con_start = 0;
17590 + cvirt->syslog.logged_chars = 0;
17594 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17596 + // cvirt_pc->cpustat = { 0 };
17599 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17601 +#ifdef CONFIG_VSERVER_WARN
17604 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17605 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17607 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17608 + "!!! cvirt: %p[nr_running] = %d on exit.",
17610 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17611 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17613 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17614 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17620 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17625 diff -NurpP --minimal linux-3.0.25/kernel/vserver/cvirt_proc.h linux-3.0.25-vs2.3.2.3/kernel/vserver/cvirt_proc.h
17626 --- linux-3.0.25/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17627 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cvirt_proc.h 2011-06-10 22:11:24.000000000 +0200
17629 +#ifndef _VX_CVIRT_PROC_H
17630 +#define _VX_CVIRT_PROC_H
17632 +#include <linux/nsproxy.h>
17633 +#include <linux/mnt_namespace.h>
17634 +#include <linux/ipc_namespace.h>
17635 +#include <linux/utsname.h>
17636 +#include <linux/ipc.h>
17640 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17642 + struct mnt_namespace *ns;
17643 + struct uts_namespace *uts;
17644 + struct ipc_namespace *ipc;
17645 + struct path path;
17646 + char *pstr, *root;
17652 + length += sprintf(buffer + length,
17653 + "NSProxy:\t%p [%p,%p,%p]\n",
17654 + nsproxy, nsproxy->mnt_ns,
17655 + nsproxy->uts_ns, nsproxy->ipc_ns);
17657 + ns = nsproxy->mnt_ns;
17661 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17665 + path.mnt = ns->root;
17666 + path.dentry = ns->root->mnt_root;
17667 + root = d_path(&path, pstr, PATH_MAX - 2);
17668 + length += sprintf(buffer + length,
17669 + "Namespace:\t%p [#%u]\n"
17670 + "RootPath:\t%s\n",
17671 + ns, atomic_read(&ns->count),
17676 + uts = nsproxy->uts_ns;
17680 + length += sprintf(buffer + length,
17681 + "SysName:\t%.*s\n"
17682 + "NodeName:\t%.*s\n"
17683 + "Release:\t%.*s\n"
17684 + "Version:\t%.*s\n"
17685 + "Machine:\t%.*s\n"
17686 + "DomainName:\t%.*s\n",
17687 + __NEW_UTS_LEN, uts->name.sysname,
17688 + __NEW_UTS_LEN, uts->name.nodename,
17689 + __NEW_UTS_LEN, uts->name.release,
17690 + __NEW_UTS_LEN, uts->name.version,
17691 + __NEW_UTS_LEN, uts->name.machine,
17692 + __NEW_UTS_LEN, uts->name.domainname);
17695 + ipc = nsproxy->ipc_ns;
17699 + length += sprintf(buffer + length,
17700 + "SEMS:\t\t%d %d %d %d %d\n"
17701 + "MSG:\t\t%d %d %d\n"
17702 + "SHM:\t\t%lu %lu %d %d\n",
17703 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17704 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17706 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17707 + (unsigned long)ipc->shm_ctlmax,
17708 + (unsigned long)ipc->shm_ctlall,
17709 + ipc->shm_ctlmni, ipc->shm_tot);
17716 +#include <linux/sched.h>
17718 +#define LOAD_INT(x) ((x) >> FSHIFT)
17719 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17722 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17727 + length += sprintf(buffer + length,
17728 + "BiasUptime:\t%lu.%02lu\n",
17729 + (unsigned long)cvirt->bias_uptime.tv_sec,
17730 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17732 + a = cvirt->load[0] + (FIXED_1 / 200);
17733 + b = cvirt->load[1] + (FIXED_1 / 200);
17734 + c = cvirt->load[2] + (FIXED_1 / 200);
17735 + length += sprintf(buffer + length,
17736 + "nr_threads:\t%d\n"
17737 + "nr_running:\t%d\n"
17738 + "nr_unintr:\t%d\n"
17739 + "nr_onhold:\t%d\n"
17740 + "load_updates:\t%d\n"
17741 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17742 + "total_forks:\t%d\n",
17743 + atomic_read(&cvirt->nr_threads),
17744 + atomic_read(&cvirt->nr_running),
17745 + atomic_read(&cvirt->nr_uninterruptible),
17746 + atomic_read(&cvirt->nr_onhold),
17747 + atomic_read(&cvirt->load_updates),
17748 + LOAD_INT(a), LOAD_FRAC(a),
17749 + LOAD_INT(b), LOAD_FRAC(b),
17750 + LOAD_INT(c), LOAD_FRAC(c),
17751 + atomic_read(&cvirt->total_forks));
17756 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17757 + char *buffer, int cpu)
17763 +#endif /* _VX_CVIRT_PROC_H */
17764 diff -NurpP --minimal linux-3.0.25/kernel/vserver/debug.c linux-3.0.25-vs2.3.2.3/kernel/vserver/debug.c
17765 --- linux-3.0.25/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17766 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/debug.c 2011-06-10 22:11:24.000000000 +0200
17769 + * kernel/vserver/debug.c
17771 + * Copyright (C) 2005-2007 Herbert Pötzl
17773 + * V0.01 vx_info dump support
17777 +#include <linux/module.h>
17779 +#include <linux/vserver/context.h>
17782 +void dump_vx_info(struct vx_info *vxi, int level)
17784 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17785 + atomic_read(&vxi->vx_usecnt),
17786 + atomic_read(&vxi->vx_tasks),
17789 + __dump_vx_limit(&vxi->limit);
17790 + __dump_vx_sched(&vxi->sched);
17791 + __dump_vx_cvirt(&vxi->cvirt);
17792 + __dump_vx_cacct(&vxi->cacct);
17798 +EXPORT_SYMBOL_GPL(dump_vx_info);
17800 diff -NurpP --minimal linux-3.0.25/kernel/vserver/device.c linux-3.0.25-vs2.3.2.3/kernel/vserver/device.c
17801 --- linux-3.0.25/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17802 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/device.c 2011-06-10 23:20:56.000000000 +0200
17805 + * linux/kernel/vserver/device.c
17807 + * Linux-VServer: Device Support
17809 + * Copyright (C) 2006 Herbert Pötzl
17810 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17812 + * V0.01 device mapping basics
17813 + * V0.02 added defaults
17817 +#include <linux/slab.h>
17818 +#include <linux/rcupdate.h>
17819 +#include <linux/fs.h>
17820 +#include <linux/namei.h>
17821 +#include <linux/hash.h>
17823 +#include <asm/errno.h>
17824 +#include <asm/uaccess.h>
17825 +#include <linux/vserver/base.h>
17826 +#include <linux/vserver/debug.h>
17827 +#include <linux/vserver/context.h>
17828 +#include <linux/vserver/device.h>
17829 +#include <linux/vserver/device_cmd.h>
17832 +#define DMAP_HASH_BITS 4
17835 +struct vs_mapping {
17837 + struct hlist_node hlist;
17838 + struct list_head list;
17840 +#define dm_hlist u.hlist
17841 +#define dm_list u.list
17844 + struct vx_dmap_target target;
17848 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17850 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17852 +static struct vx_dmap_target dmap_defaults[2] = {
17853 + { .flags = DATTR_OPEN },
17854 + { .flags = DATTR_OPEN },
17858 +struct kmem_cache *dmap_cachep __read_mostly;
17860 +int __init dmap_cache_init(void)
17862 + dmap_cachep = kmem_cache_create("dmap_cache",
17863 + sizeof(struct vs_mapping), 0,
17864 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17868 +__initcall(dmap_cache_init);
17871 +static inline unsigned int __hashval(dev_t dev, int bits)
17873 + return hash_long((unsigned long)dev, bits);
17877 +/* __hash_mapping()
17878 + * add the mapping to the hash table
17880 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17882 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17883 + struct hlist_head *head, *hash = dmap_main_hash;
17884 + int device = vdm->device;
17886 + spin_lock(hash_lock);
17887 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17888 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17890 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17891 + hlist_add_head(&vdm->dm_hlist, head);
17892 + spin_unlock(hash_lock);
17896 +static inline int __mode_to_default(umode_t mode)
17909 +/* __set_default()
17912 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17913 + struct vx_dmap_target *vdmt)
17915 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17916 + spin_lock(hash_lock);
17919 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17921 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17924 + spin_unlock(hash_lock);
17926 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17927 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17931 +/* __remove_default()
17932 + * remove a default
17934 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17936 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17937 + spin_lock(hash_lock);
17940 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17941 + else /* remove == reset */
17942 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17944 + spin_unlock(hash_lock);
17949 +/* __find_mapping()
17950 + * find a mapping in the hash table
17952 + * caller must hold hash_lock
17954 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17955 + struct vs_mapping **local, struct vs_mapping **global)
17957 + struct hlist_head *hash = dmap_main_hash;
17958 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17959 + struct hlist_node *pos;
17960 + struct vs_mapping *vdm;
17966 + hlist_for_each(pos, head) {
17967 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17969 + if ((vdm->device == device) &&
17970 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17971 + if (vdm->xid == xid) {
17974 + } else if (global && vdm->xid == 0)
17979 + if (global && *global)
17986 +/* __lookup_mapping()
17987 + * find a mapping and store the result in target and flags
17989 +static inline int __lookup_mapping(struct vx_info *vxi,
17990 + dev_t device, dev_t *target, int *flags, umode_t mode)
17992 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17993 + struct vs_mapping *vdm, *global;
17994 + struct vx_dmap_target *vdmt;
17996 + xid_t xid = vxi->vx_id;
17999 + spin_lock(hash_lock);
18000 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
18002 + vdmt = &vdm->target;
18006 + index = __mode_to_default(mode);
18007 + if (vxi && vxi->dmap.targets[index].flags) {
18009 + vdmt = &vxi->dmap.targets[index];
18010 + } else if (global) {
18012 + vdmt = &global->target;
18016 + vdmt = &dmap_defaults[index];
18020 + if (target && (vdmt->flags & DATTR_REMAP))
18021 + *target = vdmt->target;
18023 + *target = device;
18025 + *flags = vdmt->flags;
18027 + spin_unlock(hash_lock);
18033 +/* __remove_mapping()
18034 + * remove a mapping from the hash table
18036 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
18039 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18040 + struct vs_mapping *vdm = NULL;
18043 + spin_lock(hash_lock);
18045 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
18047 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18048 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18051 + hlist_del(&vdm->dm_hlist);
18054 + spin_unlock(hash_lock);
18056 + kmem_cache_free(dmap_cachep, vdm);
18062 +int vs_map_device(struct vx_info *vxi,
18063 + dev_t device, dev_t *target, umode_t mode)
18065 + int ret, flags = DATTR_MASK;
18069 + *target = device;
18072 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18073 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18074 + device, target ? *target : 0, flags, mode, ret);
18076 + return (flags & DATTR_MASK);
18081 +static int do_set_mapping(struct vx_info *vxi,
18082 + dev_t device, dev_t target, int flags, umode_t mode)
18085 + struct vs_mapping *new;
18087 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18091 + INIT_HLIST_NODE(&new->dm_hlist);
18092 + new->device = device;
18093 + new->target.target = target;
18094 + new->target.flags = flags | mode;
18095 + new->xid = (vxi ? vxi->vx_id : 0);
18097 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18098 + __hash_mapping(vxi, new);
18100 + struct vx_dmap_target new = {
18101 + .target = target,
18102 + .flags = flags | mode,
18104 + __set_default(vxi, mode, &new);
18110 +static int do_unset_mapping(struct vx_info *vxi,
18111 + dev_t device, dev_t target, int flags, umode_t mode)
18113 + int ret = -EINVAL;
18116 + ret = __remove_mapping(vxi, device, mode);
18120 + ret = __remove_default(vxi, mode);
18130 +static inline int __user_device(const char __user *name, dev_t *dev,
18133 + struct nameidata nd;
18140 + ret = user_lpath(name, &nd.path);
18143 + if (nd.path.dentry->d_inode) {
18144 + *dev = nd.path.dentry->d_inode->i_rdev;
18145 + *mode = nd.path.dentry->d_inode->i_mode;
18147 + path_put(&nd.path);
18151 +static inline int __mapping_mode(dev_t device, dev_t target,
18152 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18155 + *mode = device_mode & S_IFMT;
18157 + *mode = target_mode & S_IFMT;
18161 + /* if both given, device and target mode have to match */
18162 + if (device && target &&
18163 + ((device_mode ^ target_mode) & S_IFMT))
18169 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18170 + const char __user *target_path, int flags, int set)
18172 + dev_t device = ~0, target = ~0;
18173 + umode_t device_mode = 0, target_mode = 0, mode;
18176 + ret = __user_device(device_path, &device, &device_mode);
18179 + ret = __user_device(target_path, &target, &target_mode);
18183 + ret = __mapping_mode(device, target,
18184 + device_mode, target_mode, &mode);
18189 + return do_set_mapping(vxi, device, target,
18192 + return do_unset_mapping(vxi, device, target,
18197 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18199 + struct vcmd_set_mapping_v0 vc_data;
18201 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18204 + return do_mapping(vxi, vc_data.device, vc_data.target,
18205 + vc_data.flags, 1);
18208 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18210 + struct vcmd_set_mapping_v0 vc_data;
18212 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18215 + return do_mapping(vxi, vc_data.device, vc_data.target,
18216 + vc_data.flags, 0);
18220 +#ifdef CONFIG_COMPAT
18222 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18224 + struct vcmd_set_mapping_v0_x32 vc_data;
18226 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18229 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18230 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18233 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18235 + struct vcmd_set_mapping_v0_x32 vc_data;
18237 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18240 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18241 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18244 +#endif /* CONFIG_COMPAT */
18247 diff -NurpP --minimal linux-3.0.25/kernel/vserver/dlimit.c linux-3.0.25-vs2.3.2.3/kernel/vserver/dlimit.c
18248 --- linux-3.0.25/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18249 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/dlimit.c 2011-06-10 23:20:56.000000000 +0200
18252 + * linux/kernel/vserver/dlimit.c
18254 + * Virtual Server: Context Disk Limits
18256 + * Copyright (C) 2004-2009 Herbert Pötzl
18258 + * V0.01 initial version
18259 + * V0.02 compat32 splitup
18260 + * V0.03 extended interface
18264 +#include <linux/statfs.h>
18265 +#include <linux/sched.h>
18266 +#include <linux/namei.h>
18267 +#include <linux/vs_tag.h>
18268 +#include <linux/vs_dlimit.h>
18269 +#include <linux/vserver/dlimit_cmd.h>
18270 +#include <linux/slab.h>
18271 +// #include <linux/gfp.h>
18273 +#include <asm/uaccess.h>
18275 +/* __alloc_dl_info()
18277 + * allocate an initialized dl_info struct
18278 + * doesn't make it visible (hash) */
18280 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18282 + struct dl_info *new = NULL;
18284 + vxdprintk(VXD_CBIT(dlim, 5),
18285 + "alloc_dl_info(%p,%d)*", sb, tag);
18287 + /* would this benefit from a slab cache? */
18288 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18292 + memset(new, 0, sizeof(struct dl_info));
18293 + new->dl_tag = tag;
18295 + // INIT_RCU_HEAD(&new->dl_rcu);
18296 + INIT_HLIST_NODE(&new->dl_hlist);
18297 + spin_lock_init(&new->dl_lock);
18298 + atomic_set(&new->dl_refcnt, 0);
18299 + atomic_set(&new->dl_usecnt, 0);
18301 + /* rest of init goes here */
18303 + vxdprintk(VXD_CBIT(dlim, 4),
18304 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18308 +/* __dealloc_dl_info()
18310 + * final disposal of dl_info */
18312 +static void __dealloc_dl_info(struct dl_info *dli)
18314 + vxdprintk(VXD_CBIT(dlim, 4),
18315 + "dealloc_dl_info(%p)", dli);
18317 + dli->dl_hlist.next = LIST_POISON1;
18318 + dli->dl_tag = -1;
18321 + BUG_ON(atomic_read(&dli->dl_usecnt));
18322 + BUG_ON(atomic_read(&dli->dl_refcnt));
18328 +/* hash table for dl_info hash */
18330 +#define DL_HASH_SIZE 13
18332 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18334 +static DEFINE_SPINLOCK(dl_info_hash_lock);
18337 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18339 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18344 +/* __hash_dl_info()
18346 + * add the dli to the global hash table
18347 + * requires the hash_lock to be held */
18349 +static inline void __hash_dl_info(struct dl_info *dli)
18351 + struct hlist_head *head;
18353 + vxdprintk(VXD_CBIT(dlim, 6),
18354 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18355 + get_dl_info(dli);
18356 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18357 + hlist_add_head_rcu(&dli->dl_hlist, head);
18360 +/* __unhash_dl_info()
18362 + * remove the dli from the global hash table
18363 + * requires the hash_lock to be held */
18365 +static inline void __unhash_dl_info(struct dl_info *dli)
18367 + vxdprintk(VXD_CBIT(dlim, 6),
18368 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18369 + hlist_del_rcu(&dli->dl_hlist);
18370 + put_dl_info(dli);
18374 +/* __lookup_dl_info()
18376 + * requires the rcu_read_lock()
18377 + * doesn't increment the dl_refcnt */
18379 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18381 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18382 + struct hlist_node *pos;
18383 + struct dl_info *dli;
18385 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18387 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18395 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18397 + struct dl_info *dli;
18400 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18401 + vxdprintk(VXD_CBIT(dlim, 7),
18402 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18403 + rcu_read_unlock();
18407 +void rcu_free_dl_info(struct rcu_head *head)
18409 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18410 + int usecnt, refcnt;
18412 + BUG_ON(!dli || !head);
18414 + usecnt = atomic_read(&dli->dl_usecnt);
18415 + BUG_ON(usecnt < 0);
18417 + refcnt = atomic_read(&dli->dl_refcnt);
18418 + BUG_ON(refcnt < 0);
18420 + vxdprintk(VXD_CBIT(dlim, 3),
18421 + "rcu_free_dl_info(%p)", dli);
18423 + __dealloc_dl_info(dli);
18425 + printk("!!! rcu didn't free\n");
18431 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18432 + uint32_t flags, int add)
18434 + struct path path;
18437 + ret = user_lpath(name, &path);
18439 + struct super_block *sb;
18440 + struct dl_info *dli;
18443 + if (!path.dentry->d_inode)
18444 + goto out_release;
18445 + if (!(sb = path.dentry->d_inode->i_sb))
18446 + goto out_release;
18449 + dli = __alloc_dl_info(sb, id);
18450 + spin_lock(&dl_info_hash_lock);
18453 + if (__lookup_dl_info(sb, id))
18455 + __hash_dl_info(dli);
18458 + spin_lock(&dl_info_hash_lock);
18459 + dli = __lookup_dl_info(sb, id);
18464 + __unhash_dl_info(dli);
18468 + spin_unlock(&dl_info_hash_lock);
18470 + __dealloc_dl_info(dli);
18477 +int vc_add_dlimit(uint32_t id, void __user *data)
18479 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18481 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18484 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18487 +int vc_rem_dlimit(uint32_t id, void __user *data)
18489 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18491 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18494 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18497 +#ifdef CONFIG_COMPAT
18499 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18501 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18503 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18506 + return do_addrem_dlimit(id,
18507 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18510 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18512 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18514 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18517 + return do_addrem_dlimit(id,
18518 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18521 +#endif /* CONFIG_COMPAT */
18525 +int do_set_dlimit(uint32_t id, const char __user *name,
18526 + uint32_t space_used, uint32_t space_total,
18527 + uint32_t inodes_used, uint32_t inodes_total,
18528 + uint32_t reserved, uint32_t flags)
18530 + struct path path;
18533 + ret = user_lpath(name, &path);
18535 + struct super_block *sb;
18536 + struct dl_info *dli;
18539 + if (!path.dentry->d_inode)
18540 + goto out_release;
18541 + if (!(sb = path.dentry->d_inode->i_sb))
18542 + goto out_release;
18544 + /* sanity checks */
18545 + if ((reserved != CDLIM_KEEP &&
18546 + reserved > 100) ||
18547 + (inodes_used != CDLIM_KEEP &&
18548 + inodes_used > inodes_total) ||
18549 + (space_used != CDLIM_KEEP &&
18550 + space_used > space_total))
18551 + goto out_release;
18554 + dli = locate_dl_info(sb, id);
18556 + goto out_release;
18558 + spin_lock(&dli->dl_lock);
18560 + if (inodes_used != CDLIM_KEEP)
18561 + dli->dl_inodes_used = inodes_used;
18562 + if (inodes_total != CDLIM_KEEP)
18563 + dli->dl_inodes_total = inodes_total;
18564 + if (space_used != CDLIM_KEEP)
18565 + dli->dl_space_used = dlimit_space_32to64(
18566 + space_used, flags, DLIMS_USED);
18568 + if (space_total == CDLIM_INFINITY)
18569 + dli->dl_space_total = DLIM_INFINITY;
18570 + else if (space_total != CDLIM_KEEP)
18571 + dli->dl_space_total = dlimit_space_32to64(
18572 + space_total, flags, DLIMS_TOTAL);
18574 + if (reserved != CDLIM_KEEP)
18575 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18577 + spin_unlock(&dli->dl_lock);
18579 + put_dl_info(dli);
18588 +int vc_set_dlimit(uint32_t id, void __user *data)
18590 + struct vcmd_ctx_dlimit_v0 vc_data;
18592 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18595 + return do_set_dlimit(id, vc_data.name,
18596 + vc_data.space_used, vc_data.space_total,
18597 + vc_data.inodes_used, vc_data.inodes_total,
18598 + vc_data.reserved, vc_data.flags);
18601 +#ifdef CONFIG_COMPAT
18603 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18605 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18607 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18610 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18611 + vc_data.space_used, vc_data.space_total,
18612 + vc_data.inodes_used, vc_data.inodes_total,
18613 + vc_data.reserved, vc_data.flags);
18616 +#endif /* CONFIG_COMPAT */
18620 +int do_get_dlimit(uint32_t id, const char __user *name,
18621 + uint32_t *space_used, uint32_t *space_total,
18622 + uint32_t *inodes_used, uint32_t *inodes_total,
18623 + uint32_t *reserved, uint32_t *flags)
18625 + struct path path;
18628 + ret = user_lpath(name, &path);
18630 + struct super_block *sb;
18631 + struct dl_info *dli;
18634 + if (!path.dentry->d_inode)
18635 + goto out_release;
18636 + if (!(sb = path.dentry->d_inode->i_sb))
18637 + goto out_release;
18640 + dli = locate_dl_info(sb, id);
18642 + goto out_release;
18644 + spin_lock(&dli->dl_lock);
18645 + *inodes_used = dli->dl_inodes_used;
18646 + *inodes_total = dli->dl_inodes_total;
18648 + *space_used = dlimit_space_64to32(
18649 + dli->dl_space_used, flags, DLIMS_USED);
18651 + if (dli->dl_space_total == DLIM_INFINITY)
18652 + *space_total = CDLIM_INFINITY;
18654 + *space_total = dlimit_space_64to32(
18655 + dli->dl_space_total, flags, DLIMS_TOTAL);
18657 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18658 + spin_unlock(&dli->dl_lock);
18660 + put_dl_info(dli);
18671 +int vc_get_dlimit(uint32_t id, void __user *data)
18673 + struct vcmd_ctx_dlimit_v0 vc_data;
18676 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18679 + ret = do_get_dlimit(id, vc_data.name,
18680 + &vc_data.space_used, &vc_data.space_total,
18681 + &vc_data.inodes_used, &vc_data.inodes_total,
18682 + &vc_data.reserved, &vc_data.flags);
18686 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18691 +#ifdef CONFIG_COMPAT
18693 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18695 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18698 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18701 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18702 + &vc_data.space_used, &vc_data.space_total,
18703 + &vc_data.inodes_used, &vc_data.inodes_total,
18704 + &vc_data.reserved, &vc_data.flags);
18708 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18713 +#endif /* CONFIG_COMPAT */
18716 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18718 + struct dl_info *dli;
18719 + __u64 blimit, bfree, bavail;
18722 + dli = locate_dl_info(sb, dx_current_tag());
18726 + spin_lock(&dli->dl_lock);
18727 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18730 + /* reduce max inodes available to limit */
18731 + if (buf->f_files > dli->dl_inodes_total)
18732 + buf->f_files = dli->dl_inodes_total;
18734 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18735 + /* reduce free inodes to min */
18736 + if (ifree < buf->f_ffree)
18737 + buf->f_ffree = ifree;
18740 + if (dli->dl_space_total == DLIM_INFINITY)
18743 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18745 + if (dli->dl_space_total < dli->dl_space_used)
18748 + bfree = (dli->dl_space_total - dli->dl_space_used)
18749 + >> sb->s_blocksize_bits;
18751 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18752 + if (bavail < dli->dl_space_used)
18755 + bavail = (bavail - dli->dl_space_used)
18756 + >> sb->s_blocksize_bits;
18758 + /* reduce max space available to limit */
18759 + if (buf->f_blocks > blimit)
18760 + buf->f_blocks = blimit;
18762 + /* reduce free space to min */
18763 + if (bfree < buf->f_bfree)
18764 + buf->f_bfree = bfree;
18766 + /* reduce avail space to min */
18767 + if (bavail < buf->f_bavail)
18768 + buf->f_bavail = bavail;
18771 + spin_unlock(&dli->dl_lock);
18772 + put_dl_info(dli);
18777 +#include <linux/module.h>
18779 +EXPORT_SYMBOL_GPL(locate_dl_info);
18780 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18782 diff -NurpP --minimal linux-3.0.25/kernel/vserver/helper.c linux-3.0.25-vs2.3.2.3/kernel/vserver/helper.c
18783 --- linux-3.0.25/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18784 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/helper.c 2011-06-10 22:11:24.000000000 +0200
18787 + * linux/kernel/vserver/helper.c
18789 + * Virtual Context Support
18791 + * Copyright (C) 2004-2007 Herbert Pötzl
18793 + * V0.01 basic helper
18797 +#include <linux/kmod.h>
18798 +#include <linux/reboot.h>
18799 +#include <linux/vs_context.h>
18800 +#include <linux/vs_network.h>
18801 +#include <linux/vserver/signal.h>
18804 +char vshelper_path[255] = "/sbin/vshelper";
18807 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18811 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
18812 + printk( KERN_WARNING
18813 + "%s: (%s %s) returned %s with %d\n",
18814 + name, argv[1], argv[2],
18815 + sync ? "sync" : "async", ret);
18817 + vxdprintk(VXD_CBIT(switch, 4),
18818 + "%s: (%s %s) returned %s with %d",
18819 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18824 + * vshelper path is set via /proc/sys
18825 + * invoked by vserver sys_reboot(), with
18826 + * the following arguments
18828 + * argv [0] = vshelper_path;
18829 + * argv [1] = action: "restart", "halt", "poweroff", ...
18830 + * argv [2] = context identifier
18832 + * envp [*] = type-specific parameters
18835 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18837 + char id_buf[8], cmd_buf[16];
18838 + char uid_buf[16], pid_buf[16];
18841 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18842 + char *envp[] = {"HOME=/", "TERM=linux",
18843 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18844 + uid_buf, pid_buf, cmd_buf, 0};
18846 + if (vx_info_state(vxi, VXS_HELPER))
18848 + vxi->vx_state |= VXS_HELPER;
18850 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18852 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18853 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
18854 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
18857 + case LINUX_REBOOT_CMD_RESTART:
18858 + argv[1] = "restart";
18861 + case LINUX_REBOOT_CMD_HALT:
18862 + argv[1] = "halt";
18865 + case LINUX_REBOOT_CMD_POWER_OFF:
18866 + argv[1] = "poweroff";
18869 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18870 + argv[1] = "swsusp";
18873 + case LINUX_REBOOT_CMD_OOM:
18878 + vxi->vx_state &= ~VXS_HELPER;
18882 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18883 + vxi->vx_state &= ~VXS_HELPER;
18884 + __wakeup_vx_info(vxi);
18885 + return (ret) ? -EPERM : 0;
18889 +long vs_reboot(unsigned int cmd, void __user *arg)
18891 + struct vx_info *vxi = current_vx_info();
18894 + vxdprintk(VXD_CBIT(misc, 5),
18895 + "vs_reboot(%p[#%d],%u)",
18896 + vxi, vxi ? vxi->vx_id : 0, cmd);
18898 + ret = vs_reboot_helper(vxi, cmd, arg);
18902 + vxi->reboot_cmd = cmd;
18903 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18905 + case LINUX_REBOOT_CMD_RESTART:
18906 + case LINUX_REBOOT_CMD_HALT:
18907 + case LINUX_REBOOT_CMD_POWER_OFF:
18908 + vx_info_kill(vxi, 0, SIGKILL);
18909 + vx_info_kill(vxi, 1, SIGKILL);
18917 +long vs_oom_action(unsigned int cmd)
18919 + struct vx_info *vxi = current_vx_info();
18922 + vxdprintk(VXD_CBIT(misc, 5),
18923 + "vs_oom_action(%p[#%d],%u)",
18924 + vxi, vxi ? vxi->vx_id : 0, cmd);
18926 + ret = vs_reboot_helper(vxi, cmd, NULL);
18930 + vxi->reboot_cmd = cmd;
18931 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18932 + vx_info_kill(vxi, 0, SIGKILL);
18933 + vx_info_kill(vxi, 1, SIGKILL);
18939 + * argv [0] = vshelper_path;
18940 + * argv [1] = action: "startup", "shutdown"
18941 + * argv [2] = context identifier
18943 + * envp [*] = type-specific parameters
18946 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18948 + char id_buf[8], cmd_buf[16];
18949 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18950 + char *envp[] = {"HOME=/", "TERM=linux",
18951 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18953 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18956 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18957 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18960 + case VSC_STARTUP:
18961 + argv[1] = "startup";
18963 + case VSC_SHUTDOWN:
18964 + argv[1] = "shutdown";
18970 + return do_vshelper(vshelper_path, argv, envp, 1);
18975 + * argv [0] = vshelper_path;
18976 + * argv [1] = action: "netup", "netdown"
18977 + * argv [2] = context identifier
18979 + * envp [*] = type-specific parameters
18982 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18984 + char id_buf[8], cmd_buf[16];
18985 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18986 + char *envp[] = {"HOME=/", "TERM=linux",
18987 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18989 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18992 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
18993 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18997 + argv[1] = "netup";
18999 + case VSC_NETDOWN:
19000 + argv[1] = "netdown";
19006 + return do_vshelper(vshelper_path, argv, envp, 1);
19009 diff -NurpP --minimal linux-3.0.25/kernel/vserver/history.c linux-3.0.25-vs2.3.2.3/kernel/vserver/history.c
19010 --- linux-3.0.25/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
19011 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/history.c 2011-06-10 22:11:24.000000000 +0200
19014 + * kernel/vserver/history.c
19016 + * Virtual Context History Backtrace
19018 + * Copyright (C) 2004-2007 Herbert Pötzl
19020 + * V0.01 basic structure
19021 + * V0.02 hash/unhash and trace
19022 + * V0.03 preemption fixes
19026 +#include <linux/module.h>
19027 +#include <asm/uaccess.h>
19029 +#include <linux/vserver/context.h>
19030 +#include <linux/vserver/debug.h>
19031 +#include <linux/vserver/debug_cmd.h>
19032 +#include <linux/vserver/history.h>
19035 +#ifdef CONFIG_VSERVER_HISTORY
19036 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
19038 +#define VXH_SIZE 64
19041 +struct _vx_history {
19042 + unsigned int counter;
19044 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19048 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19050 +unsigned volatile int vxh_active = 1;
19052 +static atomic_t sequence = ATOMIC_INIT(0);
19057 + * requires disabled preemption */
19059 +struct _vx_hist_entry *vxh_advance(void *loc)
19061 + unsigned int cpu = smp_processor_id();
19062 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19063 + struct _vx_hist_entry *entry;
19064 + unsigned int index;
19066 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19067 + entry = &hist->entry[index];
19069 + entry->seq = atomic_inc_return(&sequence);
19070 + entry->loc = loc;
19074 +EXPORT_SYMBOL_GPL(vxh_advance);
19077 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19079 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19082 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19084 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19085 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19086 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19087 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19089 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19091 + switch (e->type) {
19092 + case VXH_THROW_OOPS:
19093 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19096 + case VXH_GET_VX_INFO:
19097 + case VXH_PUT_VX_INFO:
19098 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19100 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19101 + VXH_VXI_ARGS(e));
19104 + case VXH_INIT_VX_INFO:
19105 + case VXH_SET_VX_INFO:
19106 + case VXH_CLR_VX_INFO:
19107 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19109 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19110 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19111 + VXH_VXI_ARGS(e), e->sc.data);
19114 + case VXH_CLAIM_VX_INFO:
19115 + case VXH_RELEASE_VX_INFO:
19116 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19118 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19119 + VXH_VXI_ARGS(e), e->sc.data);
19122 + case VXH_ALLOC_VX_INFO:
19123 + case VXH_DEALLOC_VX_INFO:
19124 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19126 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19127 + VXH_VXI_ARGS(e));
19130 + case VXH_HASH_VX_INFO:
19131 + case VXH_UNHASH_VX_INFO:
19132 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19134 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19135 + VXH_VXI_ARGS(e));
19138 + case VXH_LOC_VX_INFO:
19139 + case VXH_LOOKUP_VX_INFO:
19140 + case VXH_CREATE_VX_INFO:
19141 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19143 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19144 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19145 + e->ll.arg, VXH_VXI_ARGS(e));
19150 +static void __vxh_dump_history(void)
19152 + unsigned int i, cpu;
19154 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19155 + atomic_read(&sequence), NR_CPUS);
19157 + for (i = 0; i < VXH_SIZE; i++) {
19158 + for_each_online_cpu(cpu) {
19159 + struct _vx_history *hist =
19160 + &per_cpu(vx_history_buffer, cpu);
19161 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19162 + struct _vx_hist_entry *entry = &hist->entry[index];
19164 + vxh_dump_entry(entry, cpu);
19169 +void vxh_dump_history(void)
19173 + local_irq_enable();
19175 + local_irq_disable();
19177 + __vxh_dump_history();
19181 +/* vserver syscall commands below here */
19184 +int vc_dump_history(uint32_t id)
19187 + __vxh_dump_history();
19194 +int do_read_history(struct __user _vx_hist_entry *data,
19195 + int cpu, uint32_t *index, uint32_t *count)
19197 + int pos, ret = 0;
19198 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19199 + int end = hist->counter;
19200 + int start = end - VXH_SIZE + 2;
19201 + int idx = *index;
19203 + /* special case: get current pos */
19209 + /* have we lost some data? */
19213 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19214 + struct _vx_hist_entry *entry =
19215 + &hist->entry[idx % VXH_SIZE];
19217 + /* send entry to userspace */
19218 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19222 + /* save new index and count */
19225 + return ret ? ret : (*index < end);
19228 +int vc_read_history(uint32_t id, void __user *data)
19230 + struct vcmd_read_history_v0 vc_data;
19233 + if (id >= NR_CPUS)
19236 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19239 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19240 + id, &vc_data.index, &vc_data.count);
19242 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19247 +#ifdef CONFIG_COMPAT
19249 +int vc_read_history_x32(uint32_t id, void __user *data)
19251 + struct vcmd_read_history_v0_x32 vc_data;
19254 + if (id >= NR_CPUS)
19257 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19260 + ret = do_read_history((struct __user _vx_hist_entry *)
19261 + compat_ptr(vc_data.data_ptr),
19262 + id, &vc_data.index, &vc_data.count);
19264 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19269 +#endif /* CONFIG_COMPAT */
19271 diff -NurpP --minimal linux-3.0.25/kernel/vserver/inet.c linux-3.0.25-vs2.3.2.3/kernel/vserver/inet.c
19272 --- linux-3.0.25/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19273 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/inet.c 2011-08-30 20:14:33.000000000 +0200
19276 +#include <linux/in.h>
19277 +#include <linux/inetdevice.h>
19278 +#include <linux/vs_inet.h>
19279 +#include <linux/vs_inet6.h>
19280 +#include <linux/vserver/debug.h>
19281 +#include <net/route.h>
19282 +#include <net/addrconf.h>
19285 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19289 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19292 + struct nx_addr_v4 *ptr;
19294 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19295 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19302 + vxdprintk(VXD_CBIT(net, 2),
19303 + "nx_v4_addr_conflict(%p,%p): %d",
19304 + nxi1, nxi2, ret);
19310 +#ifdef CONFIG_IPV6
19312 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19316 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19319 + struct nx_addr_v6 *ptr;
19321 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19322 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19329 + vxdprintk(VXD_CBIT(net, 2),
19330 + "nx_v6_addr_conflict(%p,%p): %d",
19331 + nxi1, nxi2, ret);
19338 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19340 + struct in_device *in_dev;
19341 + struct in_ifaddr **ifap;
19342 + struct in_ifaddr *ifa;
19347 + in_dev = in_dev_get(dev);
19351 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19352 + ifap = &ifa->ifa_next) {
19353 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19358 + in_dev_put(in_dev);
19364 +#ifdef CONFIG_IPV6
19366 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19368 + struct inet6_dev *in_dev;
19369 + struct inet6_ifaddr *ifa;
19374 + in_dev = in6_dev_get(dev);
19378 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19379 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19380 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19385 + in6_dev_put(in_dev);
19392 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19398 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19400 +#ifdef CONFIG_IPV6
19402 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19407 + vxdprintk(VXD_CBIT(net, 3),
19408 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19409 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19413 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
19414 + struct flowi4 *fl4)
19416 + struct rtable *rt;
19421 + /* FIXME: handle lback only case */
19422 + if (!NX_IPV4(nxi))
19423 + return ERR_PTR(-EPERM);
19425 + vxdprintk(VXD_CBIT(net, 4),
19426 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19427 + nxi, nxi ? nxi->nx_id : 0,
19428 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
19430 + /* single IP is unconditional */
19431 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19432 + (fl4->saddr == INADDR_ANY))
19433 + fl4->saddr = nxi->v4.ip[0].s_addr;
19435 + if (fl4->saddr == INADDR_ANY) {
19436 + struct nx_addr_v4 *ptr;
19437 + __be32 found = 0;
19439 + rt = __ip_route_output_key(net, fl4);
19440 + if (!IS_ERR(rt)) {
19441 + found = fl4->saddr;
19443 + vxdprintk(VXD_CBIT(net, 4),
19444 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19445 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
19446 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19450 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19451 + __be32 primary = ptr->ip[0].s_addr;
19452 + __be32 mask = ptr->mask.s_addr;
19453 + __be32 neta = primary & mask;
19455 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19456 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19457 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19458 + NIPQUAD(mask), NIPQUAD(neta));
19459 + if ((found & mask) != neta)
19462 + fl4->saddr = primary;
19463 + rt = __ip_route_output_key(net, fl4);
19464 + vxdprintk(VXD_CBIT(net, 4),
19465 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19466 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
19467 + if (!IS_ERR(rt)) {
19468 + found = fl4->saddr;
19470 + if (found == primary)
19474 + /* still no source ip? */
19475 + found = ipv4_is_loopback(fl4->daddr)
19476 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19478 + /* assign src ip to flow */
19479 + fl4->saddr = found;
19482 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
19483 + return ERR_PTR(-EPERM);
19486 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19487 + if (ipv4_is_loopback(fl4->daddr))
19488 + fl4->daddr = nxi->v4_lback.s_addr;
19489 + if (ipv4_is_loopback(fl4->saddr))
19490 + fl4->saddr = nxi->v4_lback.s_addr;
19491 + } else if (ipv4_is_loopback(fl4->daddr) &&
19492 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19493 + return ERR_PTR(-EPERM);
19498 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19500 diff -NurpP --minimal linux-3.0.25/kernel/vserver/init.c linux-3.0.25-vs2.3.2.3/kernel/vserver/init.c
19501 --- linux-3.0.25/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19502 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/init.c 2011-06-10 22:11:24.000000000 +0200
19505 + * linux/kernel/init.c
19507 + * Virtual Server Init
19509 + * Copyright (C) 2004-2007 Herbert Pötzl
19511 + * V0.01 basic structure
19515 +#include <linux/init.h>
19517 +int vserver_register_sysctl(void);
19518 +void vserver_unregister_sysctl(void);
19521 +static int __init init_vserver(void)
19525 +#ifdef CONFIG_VSERVER_DEBUG
19526 + vserver_register_sysctl();
19532 +static void __exit exit_vserver(void)
19535 +#ifdef CONFIG_VSERVER_DEBUG
19536 + vserver_unregister_sysctl();
19541 +/* FIXME: GFP_ZONETYPES gone
19542 +long vx_slab[GFP_ZONETYPES]; */
19546 +module_init(init_vserver);
19547 +module_exit(exit_vserver);
19549 diff -NurpP --minimal linux-3.0.25/kernel/vserver/inode.c linux-3.0.25-vs2.3.2.3/kernel/vserver/inode.c
19550 --- linux-3.0.25/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19551 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/inode.c 2012-01-24 01:46:36.000000000 +0100
19554 + * linux/kernel/vserver/inode.c
19556 + * Virtual Server: File System Support
19558 + * Copyright (C) 2004-2007 Herbert Pötzl
19560 + * V0.01 separated from vcontext V0.05
19561 + * V0.02 moved to tag (instead of xid)
19565 +#include <linux/tty.h>
19566 +#include <linux/proc_fs.h>
19567 +#include <linux/devpts_fs.h>
19568 +#include <linux/fs.h>
19569 +#include <linux/file.h>
19570 +#include <linux/mount.h>
19571 +#include <linux/parser.h>
19572 +#include <linux/namei.h>
19573 +#include <linux/vserver/inode.h>
19574 +#include <linux/vserver/inode_cmd.h>
19575 +#include <linux/vs_base.h>
19576 +#include <linux/vs_tag.h>
19578 +#include <asm/uaccess.h>
19581 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19583 + struct proc_dir_entry *entry;
19585 + if (!in || !in->i_sb)
19588 + *flags = IATTR_TAG
19589 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19590 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19591 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19592 + | (IS_COW(in) ? IATTR_COW : 0);
19593 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19595 + if (S_ISDIR(in->i_mode))
19596 + *mask |= IATTR_BARRIER;
19598 + if (IS_TAGGED(in)) {
19599 + *tag = in->i_tag;
19600 + *mask |= IATTR_TAG;
19603 + switch (in->i_sb->s_magic) {
19604 + case PROC_SUPER_MAGIC:
19605 + entry = PROC_I(in)->pde;
19607 + /* check for specific inodes? */
19609 + *mask |= IATTR_FLAGS;
19611 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19613 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19616 + case DEVPTS_SUPER_MAGIC:
19617 + *tag = in->i_tag;
19618 + *mask |= IATTR_TAG;
19627 +int vc_get_iattr(void __user *data)
19629 + struct path path;
19630 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19633 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19636 + ret = user_lpath(vc_data.name, &path);
19638 + ret = __vc_get_iattr(path.dentry->d_inode,
19639 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19645 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19650 +#ifdef CONFIG_COMPAT
19652 +int vc_get_iattr_x32(void __user *data)
19654 + struct path path;
19655 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19658 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19661 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19663 + ret = __vc_get_iattr(path.dentry->d_inode,
19664 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19670 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19675 +#endif /* CONFIG_COMPAT */
19678 +int vc_fget_iattr(uint32_t fd, void __user *data)
19680 + struct file *filp;
19681 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19684 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19688 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19691 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19692 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19696 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19702 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19704 + struct inode *in = de->d_inode;
19705 + int error = 0, is_proc = 0, has_tag = 0;
19706 + struct iattr attr = { 0 };
19708 + if (!in || !in->i_sb)
19711 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19712 + if ((*mask & IATTR_FLAGS) && !is_proc)
19715 + has_tag = IS_TAGGED(in) ||
19716 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19717 + if ((*mask & IATTR_TAG) && !has_tag)
19720 + mutex_lock(&in->i_mutex);
19721 + if (*mask & IATTR_TAG) {
19722 + attr.ia_tag = *tag;
19723 + attr.ia_valid |= ATTR_TAG;
19726 + if (*mask & IATTR_FLAGS) {
19727 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19728 + unsigned int iflags = PROC_I(in)->vx_flags;
19730 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19731 + | (*flags & IATTR_FLAGS);
19732 + PROC_I(in)->vx_flags = iflags;
19734 + entry->vx_flags = iflags;
19737 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19738 + IATTR_BARRIER | IATTR_COW)) {
19739 + int iflags = in->i_flags;
19740 + int vflags = in->i_vflags;
19742 + if (*mask & IATTR_IMMUTABLE) {
19743 + if (*flags & IATTR_IMMUTABLE)
19744 + iflags |= S_IMMUTABLE;
19746 + iflags &= ~S_IMMUTABLE;
19748 + if (*mask & IATTR_IXUNLINK) {
19749 + if (*flags & IATTR_IXUNLINK)
19750 + iflags |= S_IXUNLINK;
19752 + iflags &= ~S_IXUNLINK;
19754 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19755 + if (*flags & IATTR_BARRIER)
19756 + vflags |= V_BARRIER;
19758 + vflags &= ~V_BARRIER;
19760 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19761 + if (*flags & IATTR_COW)
19764 + vflags &= ~V_COW;
19766 + if (in->i_op && in->i_op->sync_flags) {
19767 + error = in->i_op->sync_flags(in, iflags, vflags);
19773 + if (attr.ia_valid) {
19774 + if (in->i_op && in->i_op->setattr)
19775 + error = in->i_op->setattr(de, &attr);
19777 + error = inode_change_ok(in, &attr);
19779 + setattr_copy(in, &attr);
19780 + mark_inode_dirty(in);
19786 + mutex_unlock(&in->i_mutex);
19790 +int vc_set_iattr(void __user *data)
19792 + struct path path;
19793 + struct vcmd_ctx_iattr_v1 vc_data;
19796 + if (!capable(CAP_LINUX_IMMUTABLE))
19798 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19801 + ret = user_lpath(vc_data.name, &path);
19803 + ret = __vc_set_iattr(path.dentry,
19804 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19808 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19813 +#ifdef CONFIG_COMPAT
19815 +int vc_set_iattr_x32(void __user *data)
19817 + struct path path;
19818 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19821 + if (!capable(CAP_LINUX_IMMUTABLE))
19823 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19826 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19828 + ret = __vc_set_iattr(path.dentry,
19829 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19833 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19838 +#endif /* CONFIG_COMPAT */
19840 +int vc_fset_iattr(uint32_t fd, void __user *data)
19842 + struct file *filp;
19843 + struct vcmd_ctx_fiattr_v0 vc_data;
19846 + if (!capable(CAP_LINUX_IMMUTABLE))
19848 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19852 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19855 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19856 + &vc_data.flags, &vc_data.mask);
19860 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19866 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19868 +static match_table_t tokens = {
19869 + {Opt_notagcheck, "notagcheck"},
19870 +#ifdef CONFIG_PROPAGATE
19871 + {Opt_notag, "notag"},
19872 + {Opt_tag, "tag"},
19873 + {Opt_tagid, "tagid=%u"},
19879 +static void __dx_parse_remove(char *string, char *opt)
19881 + char *p = strstr(string, opt);
19885 + while (*q != '\0' && *q != ',')
19894 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19895 + unsigned long *flags)
19898 + substring_t args[MAX_OPT_ARGS];
19900 + char *s, *p, *opts;
19901 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19907 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19912 + while ((p = strsep(&opts, ",")) != NULL) {
19913 + token = match_token(p, tokens, args);
19916 +#ifdef CONFIG_PROPAGATE
19921 + __dx_parse_remove(s, "tag");
19922 + *mnt_flags |= MNT_TAGID;
19923 + set |= MNT_TAGID;
19927 + __dx_parse_remove(s, "notag");
19928 + *mnt_flags |= MNT_NOTAG;
19929 + set |= MNT_NOTAG;
19932 + if (tag && !match_int(args, &option))
19935 + __dx_parse_remove(s, "tagid");
19936 + *mnt_flags |= MNT_TAGID;
19937 + set |= MNT_TAGID;
19940 + case Opt_notagcheck:
19942 + __dx_parse_remove(s, "notagcheck");
19943 + *flags |= MS_NOTAGCHECK;
19944 + set |= MS_NOTAGCHECK;
19947 + vxdprintk(VXD_CBIT(tag, 7),
19948 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19949 + p, token, option);
19952 + strcpy(string, s);
19957 +#ifdef CONFIG_PROPAGATE
19959 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19961 + tag_t new_tag = 0;
19962 + struct vfsmount *mnt;
19967 + mnt = nd->path.mnt;
19971 + propagate = (mnt->mnt_flags & MNT_TAGID);
19973 + new_tag = mnt->mnt_tag;
19975 + vxdprintk(VXD_CBIT(tag, 7),
19976 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19977 + inode, inode->i_ino, inode->i_tag,
19978 + new_tag, (propagate) ? 1 : 0);
19981 + inode->i_tag = new_tag;
19984 +#include <linux/module.h>
19986 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19988 +#endif /* CONFIG_PROPAGATE */
19990 diff -NurpP --minimal linux-3.0.25/kernel/vserver/limit.c linux-3.0.25-vs2.3.2.3/kernel/vserver/limit.c
19991 --- linux-3.0.25/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
19992 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/limit.c 2011-10-11 20:48:08.000000000 +0200
19995 + * linux/kernel/vserver/limit.c
19997 + * Virtual Server: Context Limits
19999 + * Copyright (C) 2004-2010 Herbert Pötzl
20001 + * V0.01 broken out from vcontext V0.05
20002 + * V0.02 changed vcmds to vxi arg
20003 + * V0.03 added memory cgroup support
20007 +#include <linux/sched.h>
20008 +#include <linux/module.h>
20009 +#include <linux/memcontrol.h>
20010 +#include <linux/res_counter.h>
20011 +#include <linux/vs_limit.h>
20012 +#include <linux/vserver/limit.h>
20013 +#include <linux/vserver/limit_cmd.h>
20015 +#include <asm/uaccess.h>
20018 +const char *vlimit_name[NUM_LIMITS] = {
20019 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20020 + [RLIMIT_RSS] = "RSS",
20021 + [RLIMIT_AS] = "VM",
20022 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20023 + [RLIMIT_CPU] = "CPU",
20024 + [RLIMIT_NPROC] = "NPROC",
20025 + [RLIMIT_NOFILE] = "NOFILE",
20026 + [RLIMIT_LOCKS] = "LOCKS",
20027 + [RLIMIT_SIGPENDING] = "SIGP",
20028 + [RLIMIT_MSGQUEUE] = "MSGQ",
20030 + [VLIMIT_NSOCK] = "NSOCK",
20031 + [VLIMIT_OPENFD] = "OPENFD",
20032 + [VLIMIT_SHMEM] = "SHMEM",
20033 + [VLIMIT_DENTRY] = "DENTRY",
20036 +EXPORT_SYMBOL_GPL(vlimit_name);
20038 +#define MASK_ENTRY(x) (1 << (x))
20040 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
20043 + , /* softlimit */
20044 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20045 + MASK_ENTRY( RLIMIT_RSS ) |
20046 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20049 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20050 + MASK_ENTRY( RLIMIT_RSS ) |
20051 + MASK_ENTRY( RLIMIT_AS ) |
20052 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20053 + MASK_ENTRY( RLIMIT_NPROC ) |
20054 + MASK_ENTRY( RLIMIT_NOFILE ) |
20055 + MASK_ENTRY( RLIMIT_LOCKS ) |
20056 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20058 + MASK_ENTRY( VLIMIT_NSOCK ) |
20059 + MASK_ENTRY( VLIMIT_OPENFD ) |
20060 + MASK_ENTRY( VLIMIT_SHMEM ) |
20061 + MASK_ENTRY( VLIMIT_DENTRY ) |
20064 + /* accounting only */
20065 +uint32_t account_mask =
20066 + MASK_ENTRY( VLIMIT_SEMARY ) |
20067 + MASK_ENTRY( VLIMIT_NSEMS ) |
20068 + MASK_ENTRY( VLIMIT_MAPPED ) |
20072 +static int is_valid_vlimit(int id)
20074 + uint32_t mask = vlimit_mask.minimum |
20075 + vlimit_mask.softlimit | vlimit_mask.maximum;
20076 + return mask & (1 << id);
20079 +static int is_accounted_vlimit(int id)
20081 + if (is_valid_vlimit(id))
20083 + return account_mask & (1 << id);
20087 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20089 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20090 + return VX_VLIM(limit);
20093 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20095 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20096 + return VX_VLIM(limit);
20099 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20100 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20102 + if (!is_valid_vlimit(id))
20106 + *minimum = CRLIM_UNSET;
20108 + *softlimit = vc_get_soft(vxi, id);
20110 + *maximum = vc_get_hard(vxi, id);
20114 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20116 + struct vcmd_ctx_rlimit_v0 vc_data;
20119 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20122 + ret = do_get_rlimit(vxi, vc_data.id,
20123 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20127 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20132 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20133 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20135 + if (!is_valid_vlimit(id))
20138 + if (maximum != CRLIM_KEEP)
20139 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20140 + if (softlimit != CRLIM_KEEP)
20141 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20143 + /* clamp soft limit */
20144 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20145 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20150 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20152 + struct vcmd_ctx_rlimit_v0 vc_data;
20154 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20157 + return do_set_rlimit(vxi, vc_data.id,
20158 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20161 +#ifdef CONFIG_IA32_EMULATION
20163 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20165 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20167 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20170 + return do_set_rlimit(vxi, vc_data.id,
20171 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20174 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20176 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20179 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20182 + ret = do_get_rlimit(vxi, vc_data.id,
20183 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20187 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20192 +#endif /* CONFIG_IA32_EMULATION */
20195 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20197 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20203 +static inline void vx_reset_hits(struct _vx_limit *limit)
20207 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20208 + atomic_set(&__rlim_lhit(limit, lim), 0);
20212 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
20214 + vx_reset_hits(&vxi->limit);
20218 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20223 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20224 + value = __rlim_get(limit, lim);
20225 + __rlim_rmax(limit, lim) = value;
20226 + __rlim_rmin(limit, lim) = value;
20230 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20232 + vx_reset_minmax(&vxi->limit);
20237 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20239 + struct vcmd_rlimit_stat_v0 vc_data;
20240 + struct _vx_limit *limit = &vxi->limit;
20243 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20247 + if (!is_accounted_vlimit(id))
20250 + vx_limit_fixup(limit, id);
20251 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20252 + vc_data.value = __rlim_get(limit, id);
20253 + vc_data.minimum = __rlim_rmin(limit, id);
20254 + vc_data.maximum = __rlim_rmax(limit, id);
20256 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20262 +void vx_vsi_meminfo(struct sysinfo *val)
20264 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20265 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20266 + u64 res_limit, res_usage;
20271 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20272 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20274 + if (res_limit != RESOURCE_MAX)
20275 + val->totalram = (res_limit >> PAGE_SHIFT);
20276 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20277 + val->bufferram = 0;
20278 + val->totalhigh = 0;
20279 + val->freehigh = 0;
20280 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20284 +void vx_vsi_swapinfo(struct sysinfo *val)
20286 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20287 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20288 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20289 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20290 + s64 swap_limit, swap_usage;
20295 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20296 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20297 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20298 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20300 + /* memory unlimited */
20301 + if (res_limit == RESOURCE_MAX)
20304 + swap_limit = memsw_limit - res_limit;
20305 + /* we have a swap limit? */
20306 + if (memsw_limit != RESOURCE_MAX)
20307 + val->totalswap = swap_limit >> PAGE_SHIFT;
20309 + /* calculate swap part */
20310 + swap_usage = (memsw_usage > res_usage) ?
20311 + memsw_usage - res_usage : 0;
20313 + /* total shown minus usage gives free swap */
20314 + val->freeswap = (swap_usage < swap_limit) ?
20315 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20316 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20317 + val->totalswap = 0;
20318 + val->freeswap = 0;
20319 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20320 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20324 +long vx_vsi_cached(struct sysinfo *val)
20326 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20327 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20329 + return mem_cgroup_stat_read_cache(mcg);
20336 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20338 + struct vx_info *vxi = mm->mm_vx_info;
20339 + unsigned long points;
20345 + points = vxi->vx_badness_bias;
20347 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20348 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20349 + points += (v > w) ? (v - w) : 0;
20354 diff -NurpP --minimal linux-3.0.25/kernel/vserver/limit_init.h linux-3.0.25-vs2.3.2.3/kernel/vserver/limit_init.h
20355 --- linux-3.0.25/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20356 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/limit_init.h 2011-06-10 22:11:24.000000000 +0200
20360 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20364 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20365 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20366 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20367 + __rlim_set(limit, lim, 0);
20368 + atomic_set(&__rlim_lhit(limit, lim), 0);
20369 + __rlim_rmin(limit, lim) = 0;
20370 + __rlim_rmax(limit, lim) = 0;
20374 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20379 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20380 + if ((1 << lim) & VLIM_NOCHECK)
20382 + value = __rlim_get(limit, lim);
20383 + vxwprintk_xid(value,
20384 + "!!! limit: %p[%s,%d] = %ld on exit.",
20385 + limit, vlimit_name[lim], lim, (long)value);
20389 diff -NurpP --minimal linux-3.0.25/kernel/vserver/limit_proc.h linux-3.0.25-vs2.3.2.3/kernel/vserver/limit_proc.h
20390 --- linux-3.0.25/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20391 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/limit_proc.h 2011-06-10 22:11:24.000000000 +0200
20393 +#ifndef _VX_LIMIT_PROC_H
20394 +#define _VX_LIMIT_PROC_H
20396 +#include <linux/vserver/limit_int.h>
20399 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20400 +#define VX_LIMIT_TOP \
20401 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20403 +#define VX_LIMIT_ARG(r) \
20404 + (unsigned long)__rlim_get(limit, r), \
20405 + (unsigned long)__rlim_rmin(limit, r), \
20406 + (unsigned long)__rlim_rmax(limit, r), \
20407 + VX_VLIM(__rlim_soft(limit, r)), \
20408 + VX_VLIM(__rlim_hard(limit, r)), \
20409 + atomic_read(&__rlim_lhit(limit, r))
20411 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20413 + vx_limit_fixup(limit, -1);
20414 + return sprintf(buffer, VX_LIMIT_TOP
20415 + "PROC" VX_LIMIT_FMT
20416 + "VM" VX_LIMIT_FMT
20417 + "VML" VX_LIMIT_FMT
20418 + "RSS" VX_LIMIT_FMT
20419 + "ANON" VX_LIMIT_FMT
20420 + "RMAP" VX_LIMIT_FMT
20421 + "FILES" VX_LIMIT_FMT
20422 + "OFD" VX_LIMIT_FMT
20423 + "LOCKS" VX_LIMIT_FMT
20424 + "SOCK" VX_LIMIT_FMT
20425 + "MSGQ" VX_LIMIT_FMT
20426 + "SHM" VX_LIMIT_FMT
20427 + "SEMA" VX_LIMIT_FMT
20428 + "SEMS" VX_LIMIT_FMT
20429 + "DENT" VX_LIMIT_FMT,
20430 + VX_LIMIT_ARG(RLIMIT_NPROC),
20431 + VX_LIMIT_ARG(RLIMIT_AS),
20432 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20433 + VX_LIMIT_ARG(RLIMIT_RSS),
20434 + VX_LIMIT_ARG(VLIMIT_ANON),
20435 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20436 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20437 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20438 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20439 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20440 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20441 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20442 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20443 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20444 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20447 +#endif /* _VX_LIMIT_PROC_H */
20450 diff -NurpP --minimal linux-3.0.25/kernel/vserver/network.c linux-3.0.25-vs2.3.2.3/kernel/vserver/network.c
20451 --- linux-3.0.25/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20452 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/network.c 2011-06-10 23:20:56.000000000 +0200
20455 + * linux/kernel/vserver/network.c
20457 + * Virtual Server: Network Support
20459 + * Copyright (C) 2003-2007 Herbert Pötzl
20461 + * V0.01 broken out from vcontext V0.05
20462 + * V0.02 cleaned up implementation
20463 + * V0.03 added equiv nx commands
20464 + * V0.04 switch to RCU based hash
20465 + * V0.05 and back to locking again
20466 + * V0.06 changed vcmds to nxi arg
20467 + * V0.07 have __create claim() the nxi
20471 +#include <linux/err.h>
20472 +#include <linux/slab.h>
20473 +#include <linux/rcupdate.h>
20475 +#include <linux/vs_network.h>
20476 +#include <linux/vs_pid.h>
20477 +#include <linux/vserver/network_cmd.h>
20480 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20481 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20483 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20484 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20487 +static int __init init_network(void)
20489 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20490 + sizeof(struct nx_addr_v4), 0,
20491 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20492 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20493 + sizeof(struct nx_addr_v6), 0,
20494 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20499 +/* __alloc_nx_addr_v4() */
20501 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20503 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20504 + nx_addr_v4_cachep, GFP_KERNEL);
20506 + if (!IS_ERR(nxa))
20507 + memset(nxa, 0, sizeof(*nxa));
20511 +/* __dealloc_nx_addr_v4() */
20513 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20515 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20518 +/* __dealloc_nx_addr_v4_all() */
20520 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20523 + struct nx_addr_v4 *next = nxa->next;
20525 + __dealloc_nx_addr_v4(nxa);
20531 +#ifdef CONFIG_IPV6
20533 +/* __alloc_nx_addr_v6() */
20535 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20537 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20538 + nx_addr_v6_cachep, GFP_KERNEL);
20540 + if (!IS_ERR(nxa))
20541 + memset(nxa, 0, sizeof(*nxa));
20545 +/* __dealloc_nx_addr_v6() */
20547 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20549 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20552 +/* __dealloc_nx_addr_v6_all() */
20554 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20557 + struct nx_addr_v6 *next = nxa->next;
20559 + __dealloc_nx_addr_v6(nxa);
20564 +#endif /* CONFIG_IPV6 */
20566 +/* __alloc_nx_info()
20568 + * allocate an initialized nx_info struct
20569 + * doesn't make it visible (hash) */
20571 +static struct nx_info *__alloc_nx_info(nid_t nid)
20573 + struct nx_info *new = NULL;
20575 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20577 + /* would this benefit from a slab cache? */
20578 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20582 + memset(new, 0, sizeof(struct nx_info));
20583 + new->nx_id = nid;
20584 + INIT_HLIST_NODE(&new->nx_hlist);
20585 + atomic_set(&new->nx_usecnt, 0);
20586 + atomic_set(&new->nx_tasks, 0);
20587 + new->nx_state = 0;
20589 + new->nx_flags = NXF_INIT_SET;
20591 + /* rest of init goes here */
20593 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20594 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20596 + vxdprintk(VXD_CBIT(nid, 0),
20597 + "alloc_nx_info(%d) = %p", nid, new);
20598 + atomic_inc(&nx_global_ctotal);
20602 +/* __dealloc_nx_info()
20604 + * final disposal of nx_info */
20606 +static void __dealloc_nx_info(struct nx_info *nxi)
20608 + vxdprintk(VXD_CBIT(nid, 0),
20609 + "dealloc_nx_info(%p)", nxi);
20611 + nxi->nx_hlist.next = LIST_POISON1;
20614 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20615 + BUG_ON(atomic_read(&nxi->nx_tasks));
20617 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20619 + nxi->nx_state |= NXS_RELEASED;
20621 + atomic_dec(&nx_global_ctotal);
20624 +static void __shutdown_nx_info(struct nx_info *nxi)
20626 + nxi->nx_state |= NXS_SHUTDOWN;
20627 + vs_net_change(nxi, VSC_NETDOWN);
20630 +/* exported stuff */
20632 +void free_nx_info(struct nx_info *nxi)
20634 + /* context shutdown is mandatory */
20635 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20637 + /* context must not be hashed */
20638 + BUG_ON(nxi->nx_state & NXS_HASHED);
20640 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20641 + BUG_ON(atomic_read(&nxi->nx_tasks));
20643 + __dealloc_nx_info(nxi);
20647 +void __nx_set_lback(struct nx_info *nxi)
20649 + int nid = nxi->nx_id;
20650 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20652 + nxi->v4_lback.s_addr = lback;
20655 +extern int __nx_inet_add_lback(__be32 addr);
20656 +extern int __nx_inet_del_lback(__be32 addr);
20659 +/* hash table for nx_info hash */
20661 +#define NX_HASH_SIZE 13
20663 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20665 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20668 +static inline unsigned int __hashval(nid_t nid)
20670 + return (nid % NX_HASH_SIZE);
20675 +/* __hash_nx_info()
20677 + * add the nxi to the global hash table
20678 + * requires the hash_lock to be held */
20680 +static inline void __hash_nx_info(struct nx_info *nxi)
20682 + struct hlist_head *head;
20684 + vxd_assert_lock(&nx_info_hash_lock);
20685 + vxdprintk(VXD_CBIT(nid, 4),
20686 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20688 + /* context must not be hashed */
20689 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20691 + nxi->nx_state |= NXS_HASHED;
20692 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20693 + hlist_add_head(&nxi->nx_hlist, head);
20694 + atomic_inc(&nx_global_cactive);
20697 +/* __unhash_nx_info()
20699 + * remove the nxi from the global hash table
20700 + * requires the hash_lock to be held */
20702 +static inline void __unhash_nx_info(struct nx_info *nxi)
20704 + vxd_assert_lock(&nx_info_hash_lock);
20705 + vxdprintk(VXD_CBIT(nid, 4),
20706 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20707 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20709 + /* context must be hashed */
20710 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20711 + /* but without tasks */
20712 + BUG_ON(atomic_read(&nxi->nx_tasks));
20714 + nxi->nx_state &= ~NXS_HASHED;
20715 + hlist_del(&nxi->nx_hlist);
20716 + atomic_dec(&nx_global_cactive);
20720 +/* __lookup_nx_info()
20722 + * requires the hash_lock to be held
20723 + * doesn't increment the nx_refcnt */
20725 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20727 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20728 + struct hlist_node *pos;
20729 + struct nx_info *nxi;
20731 + vxd_assert_lock(&nx_info_hash_lock);
20732 + hlist_for_each(pos, head) {
20733 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20735 + if (nxi->nx_id == nid)
20740 + vxdprintk(VXD_CBIT(nid, 0),
20741 + "__lookup_nx_info(#%u): %p[#%u]",
20742 + nid, nxi, nxi ? nxi->nx_id : 0);
20747 +/* __create_nx_info()
20749 + * create the requested context
20750 + * get(), claim() and hash it */
20752 +static struct nx_info *__create_nx_info(int id)
20754 + struct nx_info *new, *nxi = NULL;
20756 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20758 + if (!(new = __alloc_nx_info(id)))
20759 + return ERR_PTR(-ENOMEM);
20761 + /* required to make dynamic xids unique */
20762 + spin_lock(&nx_info_hash_lock);
20764 + /* static context requested */
20765 + if ((nxi = __lookup_nx_info(id))) {
20766 + vxdprintk(VXD_CBIT(nid, 0),
20767 + "create_nx_info(%d) = %p (already there)", id, nxi);
20768 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20769 + nxi = ERR_PTR(-EBUSY);
20771 + nxi = ERR_PTR(-EEXIST);
20774 + /* new context */
20775 + vxdprintk(VXD_CBIT(nid, 0),
20776 + "create_nx_info(%d) = %p (new)", id, new);
20777 + claim_nx_info(new, NULL);
20778 + __nx_set_lback(new);
20779 + __hash_nx_info(get_nx_info(new));
20780 + nxi = new, new = NULL;
20783 + spin_unlock(&nx_info_hash_lock);
20785 + __dealloc_nx_info(new);
20791 +/* exported stuff */
20794 +void unhash_nx_info(struct nx_info *nxi)
20796 + __shutdown_nx_info(nxi);
20797 + spin_lock(&nx_info_hash_lock);
20798 + __unhash_nx_info(nxi);
20799 + spin_unlock(&nx_info_hash_lock);
20802 +/* lookup_nx_info()
20804 + * search for a nx_info and get() it
20805 + * negative id means current */
20807 +struct nx_info *lookup_nx_info(int id)
20809 + struct nx_info *nxi = NULL;
20812 + nxi = get_nx_info(current_nx_info());
20813 + } else if (id > 1) {
20814 + spin_lock(&nx_info_hash_lock);
20815 + nxi = get_nx_info(__lookup_nx_info(id));
20816 + spin_unlock(&nx_info_hash_lock);
20821 +/* nid_is_hashed()
20823 + * verify that nid is still hashed */
20825 +int nid_is_hashed(nid_t nid)
20829 + spin_lock(&nx_info_hash_lock);
20830 + hashed = (__lookup_nx_info(nid) != NULL);
20831 + spin_unlock(&nx_info_hash_lock);
20836 +#ifdef CONFIG_PROC_FS
20840 + * get a subset of hashed nids for proc
20841 + * assumes size is at least one */
20843 +int get_nid_list(int index, unsigned int *nids, int size)
20845 + int hindex, nr_nids = 0;
20847 + /* only show current and children */
20848 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20851 + nids[nr_nids] = nx_current_nid();
20855 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20856 + struct hlist_head *head = &nx_info_hash[hindex];
20857 + struct hlist_node *pos;
20859 + spin_lock(&nx_info_hash_lock);
20860 + hlist_for_each(pos, head) {
20861 + struct nx_info *nxi;
20866 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20867 + nids[nr_nids] = nxi->nx_id;
20868 + if (++nr_nids >= size) {
20869 + spin_unlock(&nx_info_hash_lock);
20873 + /* keep the lock time short */
20874 + spin_unlock(&nx_info_hash_lock);
20883 + * migrate task to new network
20884 + * gets nxi, puts old_nxi on change
20887 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20889 + struct nx_info *old_nxi;
20895 + vxdprintk(VXD_CBIT(nid, 5),
20896 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20897 + p, nxi, nxi->nx_id,
20898 + atomic_read(&nxi->nx_usecnt),
20899 + atomic_read(&nxi->nx_tasks));
20901 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20902 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20905 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20908 + /* maybe disallow this completely? */
20909 + old_nxi = task_get_nx_info(p);
20910 + if (old_nxi == nxi)
20915 + clr_nx_info(&p->nx_info);
20916 + claim_nx_info(nxi, p);
20917 + set_nx_info(&p->nx_info, nxi);
20918 + p->nid = nxi->nx_id;
20921 + vxdprintk(VXD_CBIT(nid, 5),
20922 + "moved task %p into nxi:%p[#%d]",
20923 + p, nxi, nxi->nx_id);
20926 + release_nx_info(old_nxi, p);
20929 + put_nx_info(old_nxi);
20934 +void nx_set_persistent(struct nx_info *nxi)
20936 + vxdprintk(VXD_CBIT(nid, 6),
20937 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20939 + get_nx_info(nxi);
20940 + claim_nx_info(nxi, NULL);
20943 +void nx_clear_persistent(struct nx_info *nxi)
20945 + vxdprintk(VXD_CBIT(nid, 6),
20946 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20948 + release_nx_info(nxi, NULL);
20949 + put_nx_info(nxi);
20952 +void nx_update_persistent(struct nx_info *nxi)
20954 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20955 + nx_set_persistent(nxi);
20957 + nx_clear_persistent(nxi);
20960 +/* vserver syscall commands below here */
20962 +/* taks nid and nx_info functions */
20964 +#include <asm/uaccess.h>
20967 +int vc_task_nid(uint32_t id)
20972 + struct task_struct *tsk;
20975 + tsk = find_task_by_real_pid(id);
20976 + nid = (tsk) ? tsk->nid : -ESRCH;
20977 + rcu_read_unlock();
20979 + nid = nx_current_nid();
20984 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20986 + struct vcmd_nx_info_v0 vc_data;
20988 + vc_data.nid = nxi->nx_id;
20990 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20996 +/* network functions */
20998 +int vc_net_create(uint32_t nid, void __user *data)
21000 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
21001 + struct nx_info *new_nxi;
21004 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21007 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
21010 + new_nxi = __create_nx_info(nid);
21011 + if (IS_ERR(new_nxi))
21012 + return PTR_ERR(new_nxi);
21014 + /* initial flags */
21015 + new_nxi->nx_flags = vc_data.flagword;
21018 + if (vs_net_change(new_nxi, VSC_NETUP))
21021 + ret = nx_migrate_task(current, new_nxi);
21025 + /* return context id on success */
21026 + ret = new_nxi->nx_id;
21028 + /* get a reference for persistent contexts */
21029 + if ((vc_data.flagword & NXF_PERSISTENT))
21030 + nx_set_persistent(new_nxi);
21032 + release_nx_info(new_nxi, NULL);
21033 + put_nx_info(new_nxi);
21038 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
21040 + return nx_migrate_task(current, nxi);
21045 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21046 + uint16_t type, uint16_t flags)
21048 + struct nx_addr_v4 *nxa = &nxi->v4;
21050 + if (NX_IPV4(nxi)) {
21051 + /* locate last entry */
21052 + for (; nxa->next; nxa = nxa->next);
21053 + nxa->next = __alloc_nx_addr_v4();
21057 + return PTR_ERR(nxa);
21060 + if (nxi->v4.next)
21061 + /* remove single ip for ip list */
21062 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21064 + nxa->ip[0].s_addr = ip;
21065 + nxa->ip[1].s_addr = ip2;
21066 + nxa->mask.s_addr = mask;
21067 + nxa->type = type;
21068 + nxa->flags = flags;
21072 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21073 + uint16_t type, uint16_t flags)
21075 + struct nx_addr_v4 *nxa = &nxi->v4;
21078 +/* case NXA_TYPE_ADDR:
21081 + case NXA_TYPE_ANY:
21082 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
21083 + memset(nxa, 0, sizeof(*nxa));
21093 +int vc_net_add(struct nx_info *nxi, void __user *data)
21095 + struct vcmd_net_addr_v0 vc_data;
21096 + int index, ret = 0;
21098 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21101 + switch (vc_data.type) {
21102 + case NXA_TYPE_IPV4:
21103 + if ((vc_data.count < 1) || (vc_data.count > 4))
21107 + while (index < vc_data.count) {
21108 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21109 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21117 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21118 + nxi->v4_bcast = vc_data.ip[0];
21122 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21123 + nxi->v4_lback = vc_data.ip[0];
21134 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21136 + struct vcmd_net_addr_v0 vc_data;
21138 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21141 + switch (vc_data.type) {
21142 + case NXA_TYPE_ANY:
21143 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21144 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21154 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
21156 + struct vcmd_net_addr_ipv4_v1 vc_data;
21158 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21161 + switch (vc_data.type) {
21162 + case NXA_TYPE_ADDR:
21163 + case NXA_TYPE_MASK:
21164 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21165 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21167 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21168 + nxi->v4_bcast = vc_data.ip;
21171 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21172 + nxi->v4_lback = vc_data.ip;
21181 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21183 + struct vcmd_net_addr_ipv4_v2 vc_data;
21185 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21188 + switch (vc_data.type) {
21189 + case NXA_TYPE_ADDR:
21190 + case NXA_TYPE_MASK:
21191 + case NXA_TYPE_RANGE:
21192 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
21193 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21195 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21196 + nxi->v4_bcast = vc_data.ip;
21199 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21200 + nxi->v4_lback = vc_data.ip;
21209 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
21211 + struct vcmd_net_addr_ipv4_v1 vc_data;
21213 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21216 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
21217 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21220 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
21222 + struct vcmd_net_addr_ipv4_v2 vc_data;
21224 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21227 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
21228 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21231 +#ifdef CONFIG_IPV6
21233 +int do_add_v6_addr(struct nx_info *nxi,
21234 + struct in6_addr *ip, struct in6_addr *mask,
21235 + uint32_t prefix, uint16_t type, uint16_t flags)
21237 + struct nx_addr_v6 *nxa = &nxi->v6;
21239 + if (NX_IPV6(nxi)) {
21240 + /* locate last entry */
21241 + for (; nxa->next; nxa = nxa->next);
21242 + nxa->next = __alloc_nx_addr_v6();
21246 + return PTR_ERR(nxa);
21250 + nxa->mask = *mask;
21251 + nxa->prefix = prefix;
21252 + nxa->type = type;
21253 + nxa->flags = flags;
21258 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21260 + struct vcmd_net_addr_ipv6_v1 vc_data;
21262 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21265 + switch (vc_data.type) {
21266 + case NXA_TYPE_ADDR:
21267 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
21268 + /* fallthrough */
21269 + case NXA_TYPE_MASK:
21270 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21271 + vc_data.prefix, vc_data.type, vc_data.flags);
21278 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21280 + struct vcmd_net_addr_ipv6_v1 vc_data;
21282 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21285 + switch (vc_data.type) {
21286 + case NXA_TYPE_ANY:
21287 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21288 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21297 +#endif /* CONFIG_IPV6 */
21300 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21302 + struct vcmd_net_flags_v0 vc_data;
21304 + vc_data.flagword = nxi->nx_flags;
21306 + /* special STATE flag handling */
21307 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21309 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21314 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21316 + struct vcmd_net_flags_v0 vc_data;
21317 + uint64_t mask, trigger;
21319 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21322 + /* special STATE flag handling */
21323 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21324 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21326 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21327 + vc_data.flagword, mask);
21328 + if (trigger & NXF_PERSISTENT)
21329 + nx_update_persistent(nxi);
21334 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21336 + struct vcmd_net_caps_v0 vc_data;
21338 + vc_data.ncaps = nxi->nx_ncaps;
21339 + vc_data.cmask = ~0ULL;
21341 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21346 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21348 + struct vcmd_net_caps_v0 vc_data;
21350 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21353 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21354 + vc_data.ncaps, vc_data.cmask);
21359 +#include <linux/module.h>
21361 +module_init(init_network);
21363 +EXPORT_SYMBOL_GPL(free_nx_info);
21364 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21366 diff -NurpP --minimal linux-3.0.25/kernel/vserver/proc.c linux-3.0.25-vs2.3.2.3/kernel/vserver/proc.c
21367 --- linux-3.0.25/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21368 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/proc.c 2011-08-01 19:57:21.000000000 +0200
21371 + * linux/kernel/vserver/proc.c
21373 + * Virtual Context Support
21375 + * Copyright (C) 2003-2011 Herbert Pötzl
21377 + * V0.01 basic structure
21378 + * V0.02 adaptation vs1.3.0
21379 + * V0.03 proc permissions
21380 + * V0.04 locking/generic
21381 + * V0.05 next generation procfs
21382 + * V0.06 inode validation
21383 + * V0.07 generic rewrite vid
21384 + * V0.08 remove inode type
21385 + * V0.09 added u/wmask info
21389 +#include <linux/proc_fs.h>
21390 +#include <linux/fs_struct.h>
21391 +#include <linux/mount.h>
21392 +#include <asm/unistd.h>
21394 +#include <linux/vs_context.h>
21395 +#include <linux/vs_network.h>
21396 +#include <linux/vs_cvirt.h>
21398 +#include <linux/in.h>
21399 +#include <linux/inetdevice.h>
21400 +#include <linux/vs_inet.h>
21401 +#include <linux/vs_inet6.h>
21403 +#include <linux/vserver/global.h>
21405 +#include "cvirt_proc.h"
21406 +#include "cacct_proc.h"
21407 +#include "limit_proc.h"
21408 +#include "sched_proc.h"
21409 +#include "vci_config.h"
21412 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21416 + CAP_FOR_EACH_U32(__capi) {
21417 + buffer += sprintf(buffer, "%08x",
21418 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21424 +static struct proc_dir_entry *proc_virtual;
21426 +static struct proc_dir_entry *proc_virtnet;
21429 +/* first the actual feeds */
21432 +static int proc_vci(char *buffer)
21434 + return sprintf(buffer,
21435 + "VCIVersion:\t%04x:%04x\n"
21436 + "VCISyscall:\t%d\n"
21437 + "VCIKernel:\t%08x\n",
21438 + VCI_VERSION >> 16,
21439 + VCI_VERSION & 0xFFFF,
21441 + vci_kernel_config());
21444 +static int proc_virtual_info(char *buffer)
21446 + return proc_vci(buffer);
21449 +static int proc_virtual_status(char *buffer)
21451 + return sprintf(buffer,
21453 + "#CActive:\t%d\n"
21454 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21455 + "#InitTask:\t%d\t%d %d\n",
21456 + atomic_read(&vx_global_ctotal),
21457 + atomic_read(&vx_global_cactive),
21458 + atomic_read(&vs_global_nsproxy),
21459 + atomic_read(&vs_global_fs),
21460 + atomic_read(&vs_global_mnt_ns),
21461 + atomic_read(&vs_global_uts_ns),
21462 + atomic_read(&nr_ipc_ns),
21463 + atomic_read(&vs_global_user_ns),
21464 + atomic_read(&vs_global_pid_ns),
21465 + atomic_read(&init_task.usage),
21466 + atomic_read(&init_task.nsproxy->count),
21467 + init_task.fs->users);
21471 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21475 + length = sprintf(buffer,
21483 + vxi->vx_badness_bias);
21487 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21489 + char *orig = buffer;
21491 + buffer += sprintf(buffer,
21494 + "Flags:\t%016llx\n",
21495 + atomic_read(&vxi->vx_usecnt),
21496 + atomic_read(&vxi->vx_tasks),
21497 + (unsigned long long)vxi->vx_flags);
21499 + buffer += sprintf(buffer, "BCaps:\t");
21500 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21501 + buffer += sprintf(buffer, "\n");
21503 + buffer += sprintf(buffer,
21504 + "CCaps:\t%016llx\n"
21505 + "Umask:\t%16llx\n"
21506 + "Wmask:\t%16llx\n"
21507 + "Spaces:\t%08lx %08lx\n",
21508 + (unsigned long long)vxi->vx_ccaps,
21509 + (unsigned long long)vxi->vx_umask,
21510 + (unsigned long long)vxi->vx_wmask,
21511 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21512 + return buffer - orig;
21515 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21517 + return vx_info_proc_limit(&vxi->limit, buffer);
21520 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21524 + length = vx_info_proc_sched(&vxi->sched, buffer);
21525 + for_each_online_cpu(cpu) {
21526 + length += vx_info_proc_sched_pc(
21527 + &vx_per_cpu(vxi, sched_pc, cpu),
21528 + buffer + length, cpu);
21533 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21535 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21538 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21540 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21543 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21547 + vx_update_load(vxi);
21548 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21549 + for_each_online_cpu(cpu) {
21550 + length += vx_info_proc_cvirt_pc(
21551 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21552 + buffer + length, cpu);
21557 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21559 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21563 +static int proc_virtnet_info(char *buffer)
21565 + return proc_vci(buffer);
21568 +static int proc_virtnet_status(char *buffer)
21570 + return sprintf(buffer,
21572 + "#CActive:\t%d\n",
21573 + atomic_read(&nx_global_ctotal),
21574 + atomic_read(&nx_global_cactive));
21577 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21579 + struct nx_addr_v4 *v4a;
21580 +#ifdef CONFIG_IPV6
21581 + struct nx_addr_v6 *v6a;
21585 + length = sprintf(buffer,
21588 + "Bcast:\t" NIPQUAD_FMT "\n"
21589 + "Lback:\t" NIPQUAD_FMT "\n",
21592 + NIPQUAD(nxi->v4_bcast.s_addr),
21593 + NIPQUAD(nxi->v4_lback.s_addr));
21595 + if (!NX_IPV4(nxi))
21597 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21598 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21601 +#ifdef CONFIG_IPV6
21602 + if (!NX_IPV6(nxi))
21604 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21605 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21612 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21616 + length = sprintf(buffer,
21619 + "Flags:\t%016llx\n"
21620 + "NCaps:\t%016llx\n",
21621 + atomic_read(&nxi->nx_usecnt),
21622 + atomic_read(&nxi->nx_tasks),
21623 + (unsigned long long)nxi->nx_flags,
21624 + (unsigned long long)nxi->nx_ncaps);
21630 +/* here the inode helpers */
21636 + struct inode_operations *iop;
21637 + struct file_operations *fop;
21638 + union proc_op op;
21641 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21643 + struct inode *inode = new_inode(sb);
21648 + inode->i_mode = p->mode;
21650 + inode->i_op = p->iop;
21652 + inode->i_fop = p->fop;
21654 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
21655 + inode->i_flags |= S_IMMUTABLE;
21657 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21659 + inode->i_uid = 0;
21660 + inode->i_gid = 0;
21661 + inode->i_tag = 0;
21666 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21667 + struct dentry *dentry, int id, void *ptr)
21669 + struct vs_entry *p = ptr;
21670 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21671 + struct dentry *error = ERR_PTR(-EINVAL);
21676 + PROC_I(inode)->op = p->op;
21677 + PROC_I(inode)->fd = id;
21678 + d_add(dentry, inode);
21686 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21689 + * Fill a directory entry.
21691 + * If possible create the dcache entry and derive our inode number and
21692 + * file type from dcache entry.
21694 + * Since all of the proc inode numbers are dynamically generated, the inode
21695 + * numbers do not exist until the inode is cache. This means creating the
21696 + * the dcache entry in readdir is necessary to keep the inode numbers
21697 + * reported by readdir in sync with the inode numbers reported
21700 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21701 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21703 + struct dentry *child, *dir = filp->f_dentry;
21704 + struct inode *inode;
21705 + struct qstr qname;
21707 + unsigned type = DT_UNKNOWN;
21709 + qname.name = name;
21711 + qname.hash = full_name_hash(name, len);
21713 + child = d_lookup(dir, &qname);
21715 + struct dentry *new;
21716 + new = d_alloc(dir, &qname);
21718 + child = instantiate(dir->d_inode, new, id, ptr);
21725 + if (!child || IS_ERR(child) || !child->d_inode)
21726 + goto end_instantiate;
21727 + inode = child->d_inode;
21729 + ino = inode->i_ino;
21730 + type = inode->i_mode >> 12;
21735 + ino = find_inode_number(dir, &qname);
21738 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21743 +/* get and revalidate vx_info/xid */
21746 +struct vx_info *get_proc_vx_info(struct inode *inode)
21748 + return lookup_vx_info(PROC_I(inode)->fd);
21751 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21753 + struct inode *inode = dentry->d_inode;
21754 + xid_t xid = PROC_I(inode)->fd;
21756 + if (!xid || xid_is_hashed(xid))
21763 +/* get and revalidate nx_info/nid */
21765 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21767 + struct inode *inode = dentry->d_inode;
21768 + nid_t nid = PROC_I(inode)->fd;
21770 + if (!nid || nid_is_hashed(nid))
21778 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21780 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21781 + size_t count, loff_t *ppos)
21783 + struct inode *inode = file->f_dentry->d_inode;
21784 + unsigned long page;
21785 + ssize_t length = 0;
21787 + if (count > PROC_BLOCK_SIZE)
21788 + count = PROC_BLOCK_SIZE;
21790 + /* fade that out as soon as stable */
21791 + WARN_ON(PROC_I(inode)->fd);
21793 + if (!(page = __get_free_page(GFP_KERNEL)))
21796 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21797 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21800 + length = simple_read_from_buffer(buf, count, ppos,
21801 + (char *)page, length);
21807 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21808 + size_t count, loff_t *ppos)
21810 + struct inode *inode = file->f_dentry->d_inode;
21811 + struct vx_info *vxi = NULL;
21812 + xid_t xid = PROC_I(inode)->fd;
21813 + unsigned long page;
21814 + ssize_t length = 0;
21816 + if (count > PROC_BLOCK_SIZE)
21817 + count = PROC_BLOCK_SIZE;
21819 + /* fade that out as soon as stable */
21821 + vxi = lookup_vx_info(xid);
21825 + length = -ENOMEM;
21826 + if (!(page = __get_free_page(GFP_KERNEL)))
21829 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21830 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21833 + length = simple_read_from_buffer(buf, count, ppos,
21834 + (char *)page, length);
21838 + put_vx_info(vxi);
21843 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21844 + size_t count, loff_t *ppos)
21846 + struct inode *inode = file->f_dentry->d_inode;
21847 + struct nx_info *nxi = NULL;
21848 + nid_t nid = PROC_I(inode)->fd;
21849 + unsigned long page;
21850 + ssize_t length = 0;
21852 + if (count > PROC_BLOCK_SIZE)
21853 + count = PROC_BLOCK_SIZE;
21855 + /* fade that out as soon as stable */
21857 + nxi = lookup_nx_info(nid);
21861 + length = -ENOMEM;
21862 + if (!(page = __get_free_page(GFP_KERNEL)))
21865 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21866 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21869 + length = simple_read_from_buffer(buf, count, ppos,
21870 + (char *)page, length);
21874 + put_nx_info(nxi);
21881 +/* here comes the lower level */
21884 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21885 + .len = sizeof(NAME) - 1, \
21886 + .name = (NAME), \
21894 +#define DIR(NAME, MODE, OTYPE) \
21895 + NOD(NAME, (S_IFDIR | (MODE)), \
21896 + &proc_ ## OTYPE ## _inode_operations, \
21897 + &proc_ ## OTYPE ## _file_operations, { } )
21899 +#define INF(NAME, MODE, OTYPE) \
21900 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21901 + &proc_vs_info_file_operations, \
21902 + { .proc_vs_read = &proc_##OTYPE } )
21904 +#define VINF(NAME, MODE, OTYPE) \
21905 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21906 + &proc_vx_info_file_operations, \
21907 + { .proc_vxi_read = &proc_##OTYPE } )
21909 +#define NINF(NAME, MODE, OTYPE) \
21910 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21911 + &proc_nx_info_file_operations, \
21912 + { .proc_nxi_read = &proc_##OTYPE } )
21915 +static struct file_operations proc_vs_info_file_operations = {
21916 + .read = proc_vs_info_read,
21919 +static struct file_operations proc_vx_info_file_operations = {
21920 + .read = proc_vx_info_read,
21923 +static struct dentry_operations proc_xid_dentry_operations = {
21924 + .d_revalidate = proc_xid_revalidate,
21927 +static struct vs_entry vx_base_stuff[] = {
21928 + VINF("info", S_IRUGO, vxi_info),
21929 + VINF("status", S_IRUGO, vxi_status),
21930 + VINF("limit", S_IRUGO, vxi_limit),
21931 + VINF("sched", S_IRUGO, vxi_sched),
21932 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21933 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21934 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21935 + VINF("cacct", S_IRUGO, vxi_cacct),
21942 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21943 + struct dentry *dentry, int id, void *ptr)
21945 + dentry->d_op = &proc_xid_dentry_operations;
21946 + return vs_proc_instantiate(dir, dentry, id, ptr);
21949 +static struct dentry *proc_xid_lookup(struct inode *dir,
21950 + struct dentry *dentry, struct nameidata *nd)
21952 + struct vs_entry *p = vx_base_stuff;
21953 + struct dentry *error = ERR_PTR(-ENOENT);
21955 + for (; p->name; p++) {
21956 + if (p->len != dentry->d_name.len)
21958 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21964 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21969 +static int proc_xid_readdir(struct file *filp,
21970 + void *dirent, filldir_t filldir)
21972 + struct dentry *dentry = filp->f_dentry;
21973 + struct inode *inode = dentry->d_inode;
21974 + struct vs_entry *p = vx_base_stuff;
21975 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21979 + pos = filp->f_pos;
21982 + ino = inode->i_ino;
21983 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21986 + /* fall through */
21988 + ino = parent_ino(dentry);
21989 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21992 + /* fall through */
21995 + if (index >= size)
21997 + for (p += index; p->name; p++) {
21998 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21999 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22005 + filp->f_pos = pos;
22011 +static struct file_operations proc_nx_info_file_operations = {
22012 + .read = proc_nx_info_read,
22015 +static struct dentry_operations proc_nid_dentry_operations = {
22016 + .d_revalidate = proc_nid_revalidate,
22019 +static struct vs_entry nx_base_stuff[] = {
22020 + NINF("info", S_IRUGO, nxi_info),
22021 + NINF("status", S_IRUGO, nxi_status),
22026 +static struct dentry *proc_nid_instantiate(struct inode *dir,
22027 + struct dentry *dentry, int id, void *ptr)
22029 + dentry->d_op = &proc_nid_dentry_operations;
22030 + return vs_proc_instantiate(dir, dentry, id, ptr);
22033 +static struct dentry *proc_nid_lookup(struct inode *dir,
22034 + struct dentry *dentry, struct nameidata *nd)
22036 + struct vs_entry *p = nx_base_stuff;
22037 + struct dentry *error = ERR_PTR(-ENOENT);
22039 + for (; p->name; p++) {
22040 + if (p->len != dentry->d_name.len)
22042 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22048 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22053 +static int proc_nid_readdir(struct file *filp,
22054 + void *dirent, filldir_t filldir)
22056 + struct dentry *dentry = filp->f_dentry;
22057 + struct inode *inode = dentry->d_inode;
22058 + struct vs_entry *p = nx_base_stuff;
22059 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22063 + pos = filp->f_pos;
22066 + ino = inode->i_ino;
22067 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22070 + /* fall through */
22072 + ino = parent_ino(dentry);
22073 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22076 + /* fall through */
22079 + if (index >= size)
22081 + for (p += index; p->name; p++) {
22082 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22083 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22089 + filp->f_pos = pos;
22094 +#define MAX_MULBY10 ((~0U - 9) / 10)
22096 +static inline int atovid(const char *str, int len)
22101 + while (len-- > 0) {
22106 + if (vid >= MAX_MULBY10)
22116 +/* now the upper level (virtual) */
22119 +static struct file_operations proc_xid_file_operations = {
22120 + .read = generic_read_dir,
22121 + .readdir = proc_xid_readdir,
22124 +static struct inode_operations proc_xid_inode_operations = {
22125 + .lookup = proc_xid_lookup,
22128 +static struct vs_entry vx_virtual_stuff[] = {
22129 + INF("info", S_IRUGO, virtual_info),
22130 + INF("status", S_IRUGO, virtual_status),
22131 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22135 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22136 + struct dentry *dentry, struct nameidata *nd)
22138 + struct vs_entry *p = vx_virtual_stuff;
22139 + struct dentry *error = ERR_PTR(-ENOENT);
22142 + for (; p->name; p++) {
22143 + if (p->len != dentry->d_name.len)
22145 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22149 + goto instantiate;
22151 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22152 + if ((id < 0) || !xid_is_hashed(id))
22156 + error = proc_xid_instantiate(dir, dentry, id, p);
22161 +static struct file_operations proc_nid_file_operations = {
22162 + .read = generic_read_dir,
22163 + .readdir = proc_nid_readdir,
22166 +static struct inode_operations proc_nid_inode_operations = {
22167 + .lookup = proc_nid_lookup,
22170 +static struct vs_entry nx_virtnet_stuff[] = {
22171 + INF("info", S_IRUGO, virtnet_info),
22172 + INF("status", S_IRUGO, virtnet_status),
22173 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22177 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22178 + struct dentry *dentry, struct nameidata *nd)
22180 + struct vs_entry *p = nx_virtnet_stuff;
22181 + struct dentry *error = ERR_PTR(-ENOENT);
22184 + for (; p->name; p++) {
22185 + if (p->len != dentry->d_name.len)
22187 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22191 + goto instantiate;
22193 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22194 + if ((id < 0) || !nid_is_hashed(id))
22198 + error = proc_nid_instantiate(dir, dentry, id, p);
22204 +#define PROC_MAXVIDS 32
22206 +int proc_virtual_readdir(struct file *filp,
22207 + void *dirent, filldir_t filldir)
22209 + struct dentry *dentry = filp->f_dentry;
22210 + struct inode *inode = dentry->d_inode;
22211 + struct vs_entry *p = vx_virtual_stuff;
22212 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22214 + unsigned int xid_array[PROC_MAXVIDS];
22215 + char buf[PROC_NUMBUF];
22216 + unsigned int nr_xids, i;
22219 + pos = filp->f_pos;
22222 + ino = inode->i_ino;
22223 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22226 + /* fall through */
22228 + ino = parent_ino(dentry);
22229 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22232 + /* fall through */
22235 + if (index >= size)
22237 + for (p += index; p->name; p++) {
22238 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22239 + vs_proc_instantiate, 0, p))
22244 + index = pos - size;
22245 + p = &vx_virtual_stuff[size - 1];
22246 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22247 + for (i = 0; i < nr_xids; i++) {
22248 + int n, xid = xid_array[i];
22249 + unsigned int j = PROC_NUMBUF;
22253 + buf[--j] = '0' + (n % 10);
22256 + if (proc_fill_cache(filp, dirent, filldir,
22257 + buf + j, PROC_NUMBUF - j,
22258 + vs_proc_instantiate, xid, p))
22264 + filp->f_pos = pos;
22268 +static int proc_virtual_getattr(struct vfsmount *mnt,
22269 + struct dentry *dentry, struct kstat *stat)
22271 + struct inode *inode = dentry->d_inode;
22273 + generic_fillattr(inode, stat);
22274 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22278 +static struct file_operations proc_virtual_dir_operations = {
22279 + .read = generic_read_dir,
22280 + .readdir = proc_virtual_readdir,
22283 +static struct inode_operations proc_virtual_dir_inode_operations = {
22284 + .getattr = proc_virtual_getattr,
22285 + .lookup = proc_virtual_lookup,
22292 +int proc_virtnet_readdir(struct file *filp,
22293 + void *dirent, filldir_t filldir)
22295 + struct dentry *dentry = filp->f_dentry;
22296 + struct inode *inode = dentry->d_inode;
22297 + struct vs_entry *p = nx_virtnet_stuff;
22298 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22300 + unsigned int nid_array[PROC_MAXVIDS];
22301 + char buf[PROC_NUMBUF];
22302 + unsigned int nr_nids, i;
22305 + pos = filp->f_pos;
22308 + ino = inode->i_ino;
22309 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22312 + /* fall through */
22314 + ino = parent_ino(dentry);
22315 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22318 + /* fall through */
22321 + if (index >= size)
22323 + for (p += index; p->name; p++) {
22324 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22325 + vs_proc_instantiate, 0, p))
22330 + index = pos - size;
22331 + p = &nx_virtnet_stuff[size - 1];
22332 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22333 + for (i = 0; i < nr_nids; i++) {
22334 + int n, nid = nid_array[i];
22335 + unsigned int j = PROC_NUMBUF;
22339 + buf[--j] = '0' + (n % 10);
22342 + if (proc_fill_cache(filp, dirent, filldir,
22343 + buf + j, PROC_NUMBUF - j,
22344 + vs_proc_instantiate, nid, p))
22350 + filp->f_pos = pos;
22354 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22355 + struct dentry *dentry, struct kstat *stat)
22357 + struct inode *inode = dentry->d_inode;
22359 + generic_fillattr(inode, stat);
22360 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22364 +static struct file_operations proc_virtnet_dir_operations = {
22365 + .read = generic_read_dir,
22366 + .readdir = proc_virtnet_readdir,
22369 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22370 + .getattr = proc_virtnet_getattr,
22371 + .lookup = proc_virtnet_lookup,
22376 +void proc_vx_init(void)
22378 + struct proc_dir_entry *ent;
22380 + ent = proc_mkdir("virtual", 0);
22382 + ent->proc_fops = &proc_virtual_dir_operations;
22383 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22385 + proc_virtual = ent;
22387 + ent = proc_mkdir("virtnet", 0);
22389 + ent->proc_fops = &proc_virtnet_dir_operations;
22390 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22392 + proc_virtnet = ent;
22398 +/* per pid info */
22401 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22403 + struct vx_info *vxi;
22404 + char *orig = buffer;
22406 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22408 + vxi = task_get_vx_info(p);
22412 + buffer += sprintf(buffer, "BCaps:\t");
22413 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22414 + buffer += sprintf(buffer, "\n");
22415 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22416 + (unsigned long long)vxi->vx_ccaps);
22417 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22418 + (unsigned long long)vxi->vx_flags);
22419 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22421 + put_vx_info(vxi);
22423 + return buffer - orig;
22427 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22429 + struct nx_info *nxi;
22430 + struct nx_addr_v4 *v4a;
22431 +#ifdef CONFIG_IPV6
22432 + struct nx_addr_v6 *v6a;
22434 + char *orig = buffer;
22437 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22439 + nxi = task_get_nx_info(p);
22443 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22444 + (unsigned long long)nxi->nx_ncaps);
22445 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22446 + (unsigned long long)nxi->nx_flags);
22448 + buffer += sprintf(buffer,
22449 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22450 + NIPQUAD(nxi->v4_bcast.s_addr));
22451 + buffer += sprintf (buffer,
22452 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22453 + NIPQUAD(nxi->v4_lback.s_addr));
22454 + if (!NX_IPV4(nxi))
22456 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22457 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22460 +#ifdef CONFIG_IPV6
22461 + if (!NX_IPV6(nxi))
22463 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22464 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22468 + put_nx_info(nxi);
22470 + return buffer - orig;
22473 diff -NurpP --minimal linux-3.0.25/kernel/vserver/sched.c linux-3.0.25-vs2.3.2.3/kernel/vserver/sched.c
22474 --- linux-3.0.25/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22475 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/sched.c 2011-06-10 22:11:24.000000000 +0200
22478 + * linux/kernel/vserver/sched.c
22480 + * Virtual Server: Scheduler Support
22482 + * Copyright (C) 2004-2010 Herbert Pötzl
22484 + * V0.01 adapted Sam Vilains version to 2.6.3
22485 + * V0.02 removed legacy interface
22486 + * V0.03 changed vcmds to vxi arg
22487 + * V0.04 removed older and legacy interfaces
22488 + * V0.05 removed scheduler code/commands
22492 +#include <linux/vs_context.h>
22493 +#include <linux/vs_sched.h>
22494 +#include <linux/vserver/sched_cmd.h>
22496 +#include <asm/uaccess.h>
22499 +void vx_update_sched_param(struct _vx_sched *sched,
22500 + struct _vx_sched_pc *sched_pc)
22502 + sched_pc->prio_bias = sched->prio_bias;
22505 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22509 + if (data->prio_bias > MAX_PRIO_BIAS)
22510 + data->prio_bias = MAX_PRIO_BIAS;
22511 + if (data->prio_bias < MIN_PRIO_BIAS)
22512 + data->prio_bias = MIN_PRIO_BIAS;
22514 + if (data->cpu_id != ~0) {
22515 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22516 + cpus_and(vxi->sched.update, cpu_online_map,
22517 + vxi->sched.update);
22519 + vxi->sched.update = cpu_online_map;
22521 + for_each_cpu_mask(cpu, vxi->sched.update)
22522 + vx_update_sched_param(&vxi->sched,
22523 + &vx_per_cpu(vxi, sched_pc, cpu));
22527 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22529 + struct vcmd_prio_bias vc_data;
22531 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22534 + return do_set_prio_bias(vxi, &vc_data);
22537 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22539 + struct vcmd_prio_bias vc_data;
22540 + struct _vx_sched_pc *pcd;
22543 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22546 + cpu = vc_data.cpu_id;
22548 + if (!cpu_possible(cpu))
22551 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22552 + vc_data.prio_bias = pcd->prio_bias;
22554 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22559 diff -NurpP --minimal linux-3.0.25/kernel/vserver/sched_init.h linux-3.0.25-vs2.3.2.3/kernel/vserver/sched_init.h
22560 --- linux-3.0.25/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22561 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/sched_init.h 2011-06-10 22:11:24.000000000 +0200
22564 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22566 + /* scheduling; hard code starting values as constants */
22567 + sched->prio_bias = 0;
22571 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22573 + sched_pc->prio_bias = 0;
22575 + sched_pc->user_ticks = 0;
22576 + sched_pc->sys_ticks = 0;
22577 + sched_pc->hold_ticks = 0;
22580 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22586 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22590 diff -NurpP --minimal linux-3.0.25/kernel/vserver/sched_proc.h linux-3.0.25-vs2.3.2.3/kernel/vserver/sched_proc.h
22591 --- linux-3.0.25/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22592 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/sched_proc.h 2011-06-10 22:11:24.000000000 +0200
22594 +#ifndef _VX_SCHED_PROC_H
22595 +#define _VX_SCHED_PROC_H
22599 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22603 + length += sprintf(buffer,
22604 + "PrioBias:\t%8d\n",
22605 + sched->prio_bias);
22610 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22611 + char *buffer, int cpu)
22615 + length += sprintf(buffer + length,
22616 + "cpu %d: %lld %lld %lld", cpu,
22617 + (unsigned long long)sched_pc->user_ticks,
22618 + (unsigned long long)sched_pc->sys_ticks,
22619 + (unsigned long long)sched_pc->hold_ticks);
22620 + length += sprintf(buffer + length,
22621 + " %d\n", sched_pc->prio_bias);
22625 +#endif /* _VX_SCHED_PROC_H */
22626 diff -NurpP --minimal linux-3.0.25/kernel/vserver/signal.c linux-3.0.25-vs2.3.2.3/kernel/vserver/signal.c
22627 --- linux-3.0.25/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22628 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/signal.c 2011-06-10 22:11:24.000000000 +0200
22631 + * linux/kernel/vserver/signal.c
22633 + * Virtual Server: Signal Support
22635 + * Copyright (C) 2003-2007 Herbert Pötzl
22637 + * V0.01 broken out from vcontext V0.05
22638 + * V0.02 changed vcmds to vxi arg
22639 + * V0.03 adjusted siginfo for kill
22643 +#include <asm/uaccess.h>
22645 +#include <linux/vs_context.h>
22646 +#include <linux/vs_pid.h>
22647 +#include <linux/vserver/signal_cmd.h>
22650 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22652 + int retval, count = 0;
22653 + struct task_struct *p;
22654 + struct siginfo *sip = SEND_SIG_PRIV;
22657 + vxdprintk(VXD_CBIT(misc, 4),
22658 + "vx_info_kill(%p[#%d],%d,%d)*",
22659 + vxi, vxi->vx_id, pid, sig);
22660 + read_lock(&tasklist_lock);
22664 + for_each_process(p) {
22667 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22668 + (pid && vxi->vx_initpid == p->pid))
22671 + err = group_send_sig_info(sig, sip, p);
22673 + if (err != -EPERM)
22679 + if (vxi->vx_initpid) {
22680 + pid = vxi->vx_initpid;
22681 + /* for now, only SIGINT to private init ... */
22682 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22683 + /* ... as long as there are tasks left */
22684 + (atomic_read(&vxi->vx_tasks) > 1))
22687 + /* fallthrough */
22690 + p = find_task_by_real_pid(pid);
22691 + rcu_read_unlock();
22693 + if (vx_task_xid(p) == vxi->vx_id)
22694 + retval = group_send_sig_info(sig, sip, p);
22698 + read_unlock(&tasklist_lock);
22699 + vxdprintk(VXD_CBIT(misc, 4),
22700 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22701 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22705 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22707 + struct vcmd_ctx_kill_v0 vc_data;
22709 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22712 + /* special check to allow guest shutdown */
22713 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22714 + /* forbid killall pid=0 when init is present */
22715 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22716 + (vc_data.pid > 1)))
22719 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22723 +static int __wait_exit(struct vx_info *vxi)
22725 + DECLARE_WAITQUEUE(wait, current);
22728 + add_wait_queue(&vxi->vx_wait, &wait);
22729 + set_current_state(TASK_INTERRUPTIBLE);
22732 + if (vx_info_state(vxi,
22733 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22735 + if (signal_pending(current)) {
22736 + ret = -ERESTARTSYS;
22743 + set_current_state(TASK_RUNNING);
22744 + remove_wait_queue(&vxi->vx_wait, &wait);
22750 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22752 + struct vcmd_wait_exit_v0 vc_data;
22755 + ret = __wait_exit(vxi);
22756 + vc_data.reboot_cmd = vxi->reboot_cmd;
22757 + vc_data.exit_code = vxi->exit_code;
22759 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22764 diff -NurpP --minimal linux-3.0.25/kernel/vserver/space.c linux-3.0.25-vs2.3.2.3/kernel/vserver/space.c
22765 --- linux-3.0.25/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22766 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/space.c 2011-07-20 02:11:49.000000000 +0200
22769 + * linux/kernel/vserver/space.c
22771 + * Virtual Server: Context Space Support
22773 + * Copyright (C) 2003-2010 Herbert Pötzl
22775 + * V0.01 broken out from context.c 0.07
22776 + * V0.02 added task locking for namespace
22777 + * V0.03 broken out vx_enter_namespace
22778 + * V0.04 added *space support and commands
22779 + * V0.05 added credential support
22783 +#include <linux/utsname.h>
22784 +#include <linux/nsproxy.h>
22785 +#include <linux/err.h>
22786 +#include <linux/fs_struct.h>
22787 +#include <linux/cred.h>
22788 +#include <asm/uaccess.h>
22790 +#include <linux/vs_context.h>
22791 +#include <linux/vserver/space.h>
22792 +#include <linux/vserver/space_cmd.h>
22794 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22795 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22796 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22797 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22798 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22799 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22802 +/* namespace functions */
22804 +#include <linux/mnt_namespace.h>
22805 +#include <linux/user_namespace.h>
22806 +#include <linux/pid_namespace.h>
22807 +#include <linux/ipc_namespace.h>
22808 +#include <net/net_namespace.h>
22811 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22812 + .mask = CLONE_FS |
22814 +#ifdef CONFIG_UTS_NS
22817 +#ifdef CONFIG_IPC_NS
22820 +#ifdef CONFIG_USER_NS
22826 +static const struct vcmd_space_mask_v1 space_mask = {
22827 + .mask = CLONE_FS |
22829 +#ifdef CONFIG_UTS_NS
22832 +#ifdef CONFIG_IPC_NS
22835 +#ifdef CONFIG_USER_NS
22838 +#ifdef CONFIG_PID_NS
22841 +#ifdef CONFIG_NET_NS
22847 +static const struct vcmd_space_mask_v1 default_space_mask = {
22848 + .mask = CLONE_FS |
22850 +#ifdef CONFIG_UTS_NS
22853 +#ifdef CONFIG_IPC_NS
22856 +#ifdef CONFIG_USER_NS
22859 +#ifdef CONFIG_PID_NS
22866 + * build a new nsproxy mix
22867 + * assumes that both proxies are 'const'
22868 + * does not touch nsproxy refcounts
22869 + * will hold a reference on the result.
22872 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22873 + struct nsproxy *new_nsproxy, unsigned long mask)
22875 + struct mnt_namespace *old_ns;
22876 + struct uts_namespace *old_uts;
22877 + struct ipc_namespace *old_ipc;
22878 +#ifdef CONFIG_PID_NS
22879 + struct pid_namespace *old_pid;
22881 +#ifdef CONFIG_NET_NS
22882 + struct net *old_net;
22884 + struct nsproxy *nsproxy;
22886 + nsproxy = copy_nsproxy(old_nsproxy);
22890 + if (mask & CLONE_NEWNS) {
22891 + old_ns = nsproxy->mnt_ns;
22892 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22893 + if (nsproxy->mnt_ns)
22894 + get_mnt_ns(nsproxy->mnt_ns);
22898 + if (mask & CLONE_NEWUTS) {
22899 + old_uts = nsproxy->uts_ns;
22900 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22901 + if (nsproxy->uts_ns)
22902 + get_uts_ns(nsproxy->uts_ns);
22906 + if (mask & CLONE_NEWIPC) {
22907 + old_ipc = nsproxy->ipc_ns;
22908 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22909 + if (nsproxy->ipc_ns)
22910 + get_ipc_ns(nsproxy->ipc_ns);
22914 +#ifdef CONFIG_PID_NS
22915 + if (mask & CLONE_NEWPID) {
22916 + old_pid = nsproxy->pid_ns;
22917 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22918 + if (nsproxy->pid_ns)
22919 + get_pid_ns(nsproxy->pid_ns);
22923 +#ifdef CONFIG_NET_NS
22924 + if (mask & CLONE_NEWNET) {
22925 + old_net = nsproxy->net_ns;
22926 + nsproxy->net_ns = new_nsproxy->net_ns;
22927 + if (nsproxy->net_ns)
22928 + get_net(nsproxy->net_ns);
22933 + put_mnt_ns(old_ns);
22935 + put_uts_ns(old_uts);
22937 + put_ipc_ns(old_ipc);
22938 +#ifdef CONFIG_PID_NS
22940 + put_pid_ns(old_pid);
22942 +#ifdef CONFIG_NET_NS
22944 + put_net(old_net);
22952 + * merge two nsproxy structs into a new one.
22953 + * will hold a reference on the result.
22957 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22958 + struct nsproxy *proxy, unsigned long mask)
22960 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22966 + /* vs_mix_nsproxy returns with reference */
22967 + return vs_mix_nsproxy(old ? old : &null_proxy,
22970 + get_nsproxy(proxy);
22975 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22977 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22978 + struct fs_struct *fs_cur, *fs = NULL;
22979 + struct _vx_space *space;
22980 + int ret, kill = 0;
22982 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22983 + vxi, vxi->vx_id, mask, index);
22985 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22988 + if (index >= VX_SPACES)
22991 + space = &vxi->space[index];
22994 + mask = space->vx_nsmask;
22996 + if ((mask & space->vx_nsmask) != mask)
22999 + if (mask & CLONE_FS) {
23000 + fs = copy_fs_struct(space->vx_fs);
23004 + proxy = space->vx_nsproxy;
23006 + vxdprintk(VXD_CBIT(space, 9),
23007 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
23008 + vxi, vxi->vx_id, mask, index, proxy, fs);
23010 + task_lock(current);
23011 + fs_cur = current->fs;
23013 + if (mask & CLONE_FS) {
23014 + spin_lock(&fs_cur->lock);
23015 + current->fs = fs;
23016 + kill = !--fs_cur->users;
23017 + spin_unlock(&fs_cur->lock);
23020 + proxy_cur = current->nsproxy;
23021 + get_nsproxy(proxy_cur);
23022 + task_unlock(current);
23025 + free_fs_struct(fs_cur);
23027 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
23028 + if (IS_ERR(proxy_new)) {
23029 + ret = PTR_ERR(proxy_new);
23033 + proxy_new = xchg(¤t->nsproxy, proxy_new);
23035 + if (mask & CLONE_NEWUSER) {
23036 + struct cred *cred;
23038 + vxdprintk(VXD_CBIT(space, 10),
23039 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
23040 + vxi, vxi->vx_id, space->vx_cred,
23041 + current->real_cred, current->cred);
23043 + if (space->vx_cred) {
23044 + cred = __prepare_creds(space->vx_cred);
23046 + commit_creds(cred);
23053 + put_nsproxy(proxy_new);
23056 + put_nsproxy(proxy_cur);
23061 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23063 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
23064 + struct fs_struct *fs_vxi, *fs;
23065 + struct _vx_space *space;
23066 + int ret, kill = 0;
23068 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
23069 + vxi, vxi->vx_id, mask, index);
23071 + if ((mask & space_mask.mask) != mask)
23074 + if (index >= VX_SPACES)
23077 + space = &vxi->space[index];
23079 + proxy_vxi = space->vx_nsproxy;
23080 + fs_vxi = space->vx_fs;
23082 + if (mask & CLONE_FS) {
23083 + fs = copy_fs_struct(current->fs);
23088 + task_lock(current);
23090 + if (mask & CLONE_FS) {
23091 + spin_lock(&fs_vxi->lock);
23092 + space->vx_fs = fs;
23093 + kill = !--fs_vxi->users;
23094 + spin_unlock(&fs_vxi->lock);
23097 + proxy_cur = current->nsproxy;
23098 + get_nsproxy(proxy_cur);
23099 + task_unlock(current);
23102 + free_fs_struct(fs_vxi);
23104 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
23105 + if (IS_ERR(proxy_new)) {
23106 + ret = PTR_ERR(proxy_new);
23110 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
23111 + space->vx_nsmask |= mask;
23113 + if (mask & CLONE_NEWUSER) {
23114 + struct cred *cred;
23116 + vxdprintk(VXD_CBIT(space, 10),
23117 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
23118 + vxi, vxi->vx_id, space->vx_cred,
23119 + current->real_cred, current->cred);
23121 + cred = prepare_creds();
23122 + cred = (struct cred *)xchg(&space->vx_cred, cred);
23124 + abort_creds(cred);
23130 + put_nsproxy(proxy_new);
23133 + put_nsproxy(proxy_cur);
23138 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
23140 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23142 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23145 + return vx_enter_space(vxi, vc_data.mask, 0);
23148 +int vc_enter_space(struct vx_info *vxi, void __user *data)
23150 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23152 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23155 + if (vc_data.index >= VX_SPACES)
23158 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
23161 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
23163 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23165 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23168 + return vx_set_space(vxi, vc_data.mask, 0);
23171 +int vc_set_space(struct vx_info *vxi, void __user *data)
23173 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23175 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23178 + if (vc_data.index >= VX_SPACES)
23181 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
23184 +int vc_get_space_mask(void __user *data, int type)
23186 + const struct vcmd_space_mask_v1 *mask;
23189 + mask = &space_mask_v0;
23190 + else if (type == 1)
23191 + mask = &space_mask;
23193 + mask = &default_space_mask;
23195 + vxdprintk(VXD_CBIT(space, 10),
23196 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
23198 + if (copy_to_user(data, mask, sizeof(*mask)))
23203 diff -NurpP --minimal linux-3.0.25/kernel/vserver/switch.c linux-3.0.25-vs2.3.2.3/kernel/vserver/switch.c
23204 --- linux-3.0.25/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
23205 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/switch.c 2011-08-01 18:28:26.000000000 +0200
23208 + * linux/kernel/vserver/switch.c
23210 + * Virtual Server: Syscall Switch
23212 + * Copyright (C) 2003-2011 Herbert Pötzl
23214 + * V0.01 syscall switch
23215 + * V0.02 added signal to context
23216 + * V0.03 added rlimit functions
23217 + * V0.04 added iattr, task/xid functions
23218 + * V0.05 added debug/history stuff
23219 + * V0.06 added compat32 layer
23220 + * V0.07 vcmd args and perms
23221 + * V0.08 added status commands
23222 + * V0.09 added tag commands
23223 + * V0.10 added oom bias
23224 + * V0.11 added device commands
23225 + * V0.12 added warn mask
23229 +#include <linux/vs_context.h>
23230 +#include <linux/vs_network.h>
23231 +#include <linux/vserver/switch.h>
23233 +#include "vci_config.h"
23237 +int vc_get_version(uint32_t id)
23239 + return VCI_VERSION;
23243 +int vc_get_vci(uint32_t id)
23245 + return vci_kernel_config();
23248 +#include <linux/vserver/context_cmd.h>
23249 +#include <linux/vserver/cvirt_cmd.h>
23250 +#include <linux/vserver/cacct_cmd.h>
23251 +#include <linux/vserver/limit_cmd.h>
23252 +#include <linux/vserver/network_cmd.h>
23253 +#include <linux/vserver/sched_cmd.h>
23254 +#include <linux/vserver/debug_cmd.h>
23255 +#include <linux/vserver/inode_cmd.h>
23256 +#include <linux/vserver/dlimit_cmd.h>
23257 +#include <linux/vserver/signal_cmd.h>
23258 +#include <linux/vserver/space_cmd.h>
23259 +#include <linux/vserver/tag_cmd.h>
23260 +#include <linux/vserver/device_cmd.h>
23262 +#include <linux/vserver/inode.h>
23263 +#include <linux/vserver/dlimit.h>
23266 +#ifdef CONFIG_COMPAT
23267 +#define __COMPAT(name, id, data, compat) \
23268 + (compat) ? name ## _x32(id, data) : name(id, data)
23269 +#define __COMPAT_NO_ID(name, data, compat) \
23270 + (compat) ? name ## _x32(data) : name(data)
23272 +#define __COMPAT(name, id, data, compat) \
23274 +#define __COMPAT_NO_ID(name, data, compat) \
23280 +long do_vcmd(uint32_t cmd, uint32_t id,
23281 + struct vx_info *vxi, struct nx_info *nxi,
23282 + void __user *data, int compat)
23286 + case VCMD_get_version:
23287 + return vc_get_version(id);
23288 + case VCMD_get_vci:
23289 + return vc_get_vci(id);
23291 + case VCMD_task_xid:
23292 + return vc_task_xid(id);
23293 + case VCMD_vx_info:
23294 + return vc_vx_info(vxi, data);
23296 + case VCMD_task_nid:
23297 + return vc_task_nid(id);
23298 + case VCMD_nx_info:
23299 + return vc_nx_info(nxi, data);
23301 + case VCMD_task_tag:
23302 + return vc_task_tag(id);
23304 + case VCMD_set_space_v1:
23305 + return vc_set_space_v1(vxi, data);
23306 + /* this is version 2 */
23307 + case VCMD_set_space:
23308 + return vc_set_space(vxi, data);
23310 + case VCMD_get_space_mask_v0:
23311 + return vc_get_space_mask(data, 0);
23312 + /* this is version 1 */
23313 + case VCMD_get_space_mask:
23314 + return vc_get_space_mask(data, 1);
23316 + case VCMD_get_space_default:
23317 + return vc_get_space_mask(data, -1);
23319 + case VCMD_set_umask:
23320 + return vc_set_umask(vxi, data);
23322 + case VCMD_get_umask:
23323 + return vc_get_umask(vxi, data);
23325 + case VCMD_set_wmask:
23326 + return vc_set_wmask(vxi, data);
23328 + case VCMD_get_wmask:
23329 + return vc_get_wmask(vxi, data);
23330 +#ifdef CONFIG_IA32_EMULATION
23331 + case VCMD_get_rlimit:
23332 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23333 + case VCMD_set_rlimit:
23334 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23336 + case VCMD_get_rlimit:
23337 + return vc_get_rlimit(vxi, data);
23338 + case VCMD_set_rlimit:
23339 + return vc_set_rlimit(vxi, data);
23341 + case VCMD_get_rlimit_mask:
23342 + return vc_get_rlimit_mask(id, data);
23343 + case VCMD_reset_hits:
23344 + return vc_reset_hits(vxi, data);
23345 + case VCMD_reset_minmax:
23346 + return vc_reset_minmax(vxi, data);
23348 + case VCMD_get_vhi_name:
23349 + return vc_get_vhi_name(vxi, data);
23350 + case VCMD_set_vhi_name:
23351 + return vc_set_vhi_name(vxi, data);
23353 + case VCMD_ctx_stat:
23354 + return vc_ctx_stat(vxi, data);
23355 + case VCMD_virt_stat:
23356 + return vc_virt_stat(vxi, data);
23357 + case VCMD_sock_stat:
23358 + return vc_sock_stat(vxi, data);
23359 + case VCMD_rlimit_stat:
23360 + return vc_rlimit_stat(vxi, data);
23362 + case VCMD_set_cflags:
23363 + return vc_set_cflags(vxi, data);
23364 + case VCMD_get_cflags:
23365 + return vc_get_cflags(vxi, data);
23367 + /* this is version 1 */
23368 + case VCMD_set_ccaps:
23369 + return vc_set_ccaps(vxi, data);
23370 + /* this is version 1 */
23371 + case VCMD_get_ccaps:
23372 + return vc_get_ccaps(vxi, data);
23373 + case VCMD_set_bcaps:
23374 + return vc_set_bcaps(vxi, data);
23375 + case VCMD_get_bcaps:
23376 + return vc_get_bcaps(vxi, data);
23378 + case VCMD_set_badness:
23379 + return vc_set_badness(vxi, data);
23380 + case VCMD_get_badness:
23381 + return vc_get_badness(vxi, data);
23383 + case VCMD_set_nflags:
23384 + return vc_set_nflags(nxi, data);
23385 + case VCMD_get_nflags:
23386 + return vc_get_nflags(nxi, data);
23388 + case VCMD_set_ncaps:
23389 + return vc_set_ncaps(nxi, data);
23390 + case VCMD_get_ncaps:
23391 + return vc_get_ncaps(nxi, data);
23393 + case VCMD_set_prio_bias:
23394 + return vc_set_prio_bias(vxi, data);
23395 + case VCMD_get_prio_bias:
23396 + return vc_get_prio_bias(vxi, data);
23397 + case VCMD_add_dlimit:
23398 + return __COMPAT(vc_add_dlimit, id, data, compat);
23399 + case VCMD_rem_dlimit:
23400 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23401 + case VCMD_set_dlimit:
23402 + return __COMPAT(vc_set_dlimit, id, data, compat);
23403 + case VCMD_get_dlimit:
23404 + return __COMPAT(vc_get_dlimit, id, data, compat);
23406 + case VCMD_ctx_kill:
23407 + return vc_ctx_kill(vxi, data);
23409 + case VCMD_wait_exit:
23410 + return vc_wait_exit(vxi, data);
23412 + case VCMD_get_iattr:
23413 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23414 + case VCMD_set_iattr:
23415 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23417 + case VCMD_fget_iattr:
23418 + return vc_fget_iattr(id, data);
23419 + case VCMD_fset_iattr:
23420 + return vc_fset_iattr(id, data);
23422 + case VCMD_enter_space_v0:
23423 + return vc_enter_space_v1(vxi, NULL);
23424 + case VCMD_enter_space_v1:
23425 + return vc_enter_space_v1(vxi, data);
23426 + /* this is version 2 */
23427 + case VCMD_enter_space:
23428 + return vc_enter_space(vxi, data);
23430 + case VCMD_ctx_create_v0:
23431 + return vc_ctx_create(id, NULL);
23432 + case VCMD_ctx_create:
23433 + return vc_ctx_create(id, data);
23434 + case VCMD_ctx_migrate_v0:
23435 + return vc_ctx_migrate(vxi, NULL);
23436 + case VCMD_ctx_migrate:
23437 + return vc_ctx_migrate(vxi, data);
23439 + case VCMD_net_create_v0:
23440 + return vc_net_create(id, NULL);
23441 + case VCMD_net_create:
23442 + return vc_net_create(id, data);
23443 + case VCMD_net_migrate:
23444 + return vc_net_migrate(nxi, data);
23446 + case VCMD_tag_migrate:
23447 + return vc_tag_migrate(id);
23449 + case VCMD_net_add:
23450 + return vc_net_add(nxi, data);
23451 + case VCMD_net_remove:
23452 + return vc_net_remove(nxi, data);
23454 + case VCMD_net_add_ipv4_v1:
23455 + return vc_net_add_ipv4_v1(nxi, data);
23456 + /* this is version 2 */
23457 + case VCMD_net_add_ipv4:
23458 + return vc_net_add_ipv4(nxi, data);
23460 + case VCMD_net_rem_ipv4_v1:
23461 + return vc_net_rem_ipv4_v1(nxi, data);
23462 + /* this is version 2 */
23463 + case VCMD_net_rem_ipv4:
23464 + return vc_net_rem_ipv4(nxi, data);
23465 +#ifdef CONFIG_IPV6
23466 + case VCMD_net_add_ipv6:
23467 + return vc_net_add_ipv6(nxi, data);
23468 + case VCMD_net_remove_ipv6:
23469 + return vc_net_remove_ipv6(nxi, data);
23471 +/* case VCMD_add_match_ipv4:
23472 + return vc_add_match_ipv4(nxi, data);
23473 + case VCMD_get_match_ipv4:
23474 + return vc_get_match_ipv4(nxi, data);
23475 +#ifdef CONFIG_IPV6
23476 + case VCMD_add_match_ipv6:
23477 + return vc_add_match_ipv6(nxi, data);
23478 + case VCMD_get_match_ipv6:
23479 + return vc_get_match_ipv6(nxi, data);
23482 +#ifdef CONFIG_VSERVER_DEVICE
23483 + case VCMD_set_mapping:
23484 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23485 + case VCMD_unset_mapping:
23486 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23488 +#ifdef CONFIG_VSERVER_HISTORY
23489 + case VCMD_dump_history:
23490 + return vc_dump_history(id);
23491 + case VCMD_read_history:
23492 + return __COMPAT(vc_read_history, id, data, compat);
23495 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23496 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23502 +#define __VCMD(vcmd, _perm, _args, _flags) \
23503 + case VCMD_ ## vcmd: perm = _perm; \
23504 + args = _args; flags = _flags; break
23507 +#define VCA_NONE 0x00
23508 +#define VCA_VXI 0x01
23509 +#define VCA_NXI 0x02
23511 +#define VCF_NONE 0x00
23512 +#define VCF_INFO 0x01
23513 +#define VCF_ADMIN 0x02
23514 +#define VCF_ARES 0x06 /* includes admin */
23515 +#define VCF_SETUP 0x08
23517 +#define VCF_ZIDOK 0x10 /* zero id okay */
23521 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23524 + int permit = -1, state = 0;
23525 + int perm = -1, args = 0, flags = 0;
23526 + struct vx_info *vxi = NULL;
23527 + struct nx_info *nxi = NULL;
23530 + /* unpriviledged commands */
23531 + __VCMD(get_version, 0, VCA_NONE, 0);
23532 + __VCMD(get_vci, 0, VCA_NONE, 0);
23533 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23534 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23535 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23536 + __VCMD(get_space_default,0, VCA_NONE, 0);
23538 + /* info commands */
23539 + __VCMD(task_xid, 2, VCA_NONE, 0);
23540 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23541 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23542 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23543 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23544 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23545 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23546 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23547 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23548 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23549 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23550 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23552 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23553 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23554 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23555 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23557 + __VCMD(task_nid, 2, VCA_NONE, 0);
23558 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23559 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23560 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23562 + __VCMD(task_tag, 2, VCA_NONE, 0);
23564 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23565 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23566 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23567 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23569 + /* lower admin commands */
23570 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23571 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23572 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23573 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23574 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23575 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23576 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23577 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23579 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23580 + __VCMD(net_create, 5, VCA_NONE, 0);
23581 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23583 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23585 + /* higher admin commands */
23586 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23587 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23588 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23590 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23591 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23592 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23593 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23594 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23595 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23597 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23598 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23599 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23601 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23602 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23603 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23604 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23605 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23606 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23607 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23608 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23609 +#ifdef CONFIG_IPV6
23610 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23611 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23613 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23614 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23615 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23616 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23617 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23619 +#ifdef CONFIG_VSERVER_DEVICE
23620 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23621 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23623 + /* debug level admin commands */
23624 +#ifdef CONFIG_VSERVER_HISTORY
23625 + __VCMD(dump_history, 9, VCA_NONE, 0);
23626 + __VCMD(read_history, 9, VCA_NONE, 0);
23633 + vxdprintk(VXD_CBIT(switch, 0),
23634 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23635 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23636 + VC_VERSION(cmd), id, data, compat,
23637 + perm, args, flags);
23644 + if (!capable(CAP_CONTEXT))
23648 + /* moved here from the individual commands */
23650 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23654 + /* vcmd involves resource management */
23656 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23660 + /* various legacy exceptions */
23662 + /* will go away when spectator is a cap */
23663 + case VCMD_ctx_migrate_v0:
23664 + case VCMD_ctx_migrate:
23666 + current->xid = 1;
23672 + /* will go away when spectator is a cap */
23673 + case VCMD_net_migrate:
23675 + current->nid = 1;
23682 + /* vcmds are fine by default */
23685 + /* admin type vcmds require admin ... */
23686 + if (flags & VCF_ADMIN)
23687 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23689 + /* ... but setup type vcmds override that */
23690 + if (!permit && (flags & VCF_SETUP))
23691 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23699 + if (!id && (flags & VCF_ZIDOK))
23703 + if (args & VCA_VXI) {
23704 + vxi = lookup_vx_info(id);
23708 + if ((flags & VCF_ADMIN) &&
23709 + /* special case kill for shutdown */
23710 + (cmd != VCMD_ctx_kill) &&
23711 + /* can context be administrated? */
23712 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23718 + if (args & VCA_NXI) {
23719 + nxi = lookup_nx_info(id);
23723 + if ((flags & VCF_ADMIN) &&
23724 + /* can context be administrated? */
23725 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23732 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23735 + if ((args & VCA_NXI) && nxi)
23736 + put_nx_info(nxi);
23738 + if ((args & VCA_VXI) && vxi)
23739 + put_vx_info(vxi);
23741 + vxdprintk(VXD_CBIT(switch, 1),
23742 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23743 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23744 + VC_VERSION(cmd), ret, ret, state, permit);
23749 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23751 + return do_vserver(cmd, id, data, 0);
23754 +#ifdef CONFIG_COMPAT
23757 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23759 + return do_vserver(cmd, id, data, 1);
23762 +#endif /* CONFIG_COMPAT */
23763 diff -NurpP --minimal linux-3.0.25/kernel/vserver/sysctl.c linux-3.0.25-vs2.3.2.3/kernel/vserver/sysctl.c
23764 --- linux-3.0.25/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23765 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/sysctl.c 2011-10-27 15:18:40.000000000 +0200
23768 + * kernel/vserver/sysctl.c
23770 + * Virtual Context Support
23772 + * Copyright (C) 2004-2007 Herbert Pötzl
23774 + * V0.01 basic structure
23778 +#include <linux/module.h>
23779 +#include <linux/ctype.h>
23780 +#include <linux/sysctl.h>
23781 +#include <linux/parser.h>
23782 +#include <asm/uaccess.h>
23785 + CTL_DEBUG_ERROR = 0,
23786 + CTL_DEBUG_SWITCH = 1,
23802 +unsigned int vs_debug_switch = 0;
23803 +unsigned int vs_debug_xid = 0;
23804 +unsigned int vs_debug_nid = 0;
23805 +unsigned int vs_debug_tag = 0;
23806 +unsigned int vs_debug_net = 0;
23807 +unsigned int vs_debug_limit = 0;
23808 +unsigned int vs_debug_cres = 0;
23809 +unsigned int vs_debug_dlim = 0;
23810 +unsigned int vs_debug_quota = 0;
23811 +unsigned int vs_debug_cvirt = 0;
23812 +unsigned int vs_debug_space = 0;
23813 +unsigned int vs_debug_perm = 0;
23814 +unsigned int vs_debug_misc = 0;
23817 +static struct ctl_table_header *vserver_table_header;
23818 +static ctl_table vserver_root_table[];
23821 +void vserver_register_sysctl(void)
23823 + if (!vserver_table_header) {
23824 + vserver_table_header = register_sysctl_table(vserver_root_table);
23829 +void vserver_unregister_sysctl(void)
23831 + if (vserver_table_header) {
23832 + unregister_sysctl_table(vserver_table_header);
23833 + vserver_table_header = NULL;
23838 +static int proc_dodebug(ctl_table *table, int write,
23839 + void __user *buffer, size_t *lenp, loff_t *ppos)
23841 + char tmpbuf[20], *p, c;
23842 + unsigned int value;
23843 + size_t left, len;
23845 + if ((*ppos && !write) || !*lenp) {
23853 + if (!access_ok(VERIFY_READ, buffer, left))
23855 + p = (char *)buffer;
23856 + while (left && __get_user(c, p) >= 0 && isspace(c))
23861 + if (left > sizeof(tmpbuf) - 1)
23863 + if (copy_from_user(tmpbuf, p, left))
23865 + tmpbuf[left] = '\0';
23867 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23868 + value = 10 * value + (*p - '0');
23869 + if (*p && !isspace(*p))
23871 + while (left && isspace(*p))
23873 + *(unsigned int *)table->data = value;
23875 + if (!access_ok(VERIFY_WRITE, buffer, left))
23877 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23880 + if (__copy_to_user(buffer, tmpbuf, len))
23882 + if ((left -= len) > 0) {
23883 + if (put_user('\n', (char *)buffer + len))
23897 +#define CTL_ENTRY(ctl, name) \
23899 + .procname = #name, \
23900 + .data = &vs_ ## name, \
23901 + .maxlen = sizeof(int), \
23903 + .proc_handler = &proc_dodebug, \
23904 + .extra1 = &zero, \
23905 + .extra2 = &zero, \
23908 +static ctl_table vserver_debug_table[] = {
23909 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23910 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23911 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23912 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23913 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23914 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23915 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23916 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23917 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23918 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23919 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23920 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23921 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23925 +static ctl_table vserver_root_table[] = {
23927 + .procname = "vserver",
23929 + .child = vserver_debug_table
23935 +static match_table_t tokens = {
23936 + { CTL_DEBUG_SWITCH, "switch=%x" },
23937 + { CTL_DEBUG_XID, "xid=%x" },
23938 + { CTL_DEBUG_NID, "nid=%x" },
23939 + { CTL_DEBUG_TAG, "tag=%x" },
23940 + { CTL_DEBUG_NET, "net=%x" },
23941 + { CTL_DEBUG_LIMIT, "limit=%x" },
23942 + { CTL_DEBUG_CRES, "cres=%x" },
23943 + { CTL_DEBUG_DLIM, "dlim=%x" },
23944 + { CTL_DEBUG_QUOTA, "quota=%x" },
23945 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23946 + { CTL_DEBUG_SPACE, "space=%x" },
23947 + { CTL_DEBUG_PERM, "perm=%x" },
23948 + { CTL_DEBUG_MISC, "misc=%x" },
23949 + { CTL_DEBUG_ERROR, NULL }
23952 +#define HANDLE_CASE(id, name, val) \
23953 + case CTL_DEBUG_ ## id: \
23954 + vs_debug_ ## name = val; \
23955 + printk("vs_debug_" #name "=0x%x\n", val); \
23959 +static int __init vs_debug_setup(char *str)
23964 + printk("vs_debug_setup(%s)\n", str);
23965 + while ((p = strsep(&str, ",")) != NULL) {
23966 + substring_t args[MAX_OPT_ARGS];
23967 + unsigned int value;
23972 + token = match_token(p, tokens, args);
23973 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23976 + HANDLE_CASE(SWITCH, switch, value);
23977 + HANDLE_CASE(XID, xid, value);
23978 + HANDLE_CASE(NID, nid, value);
23979 + HANDLE_CASE(TAG, tag, value);
23980 + HANDLE_CASE(NET, net, value);
23981 + HANDLE_CASE(LIMIT, limit, value);
23982 + HANDLE_CASE(CRES, cres, value);
23983 + HANDLE_CASE(DLIM, dlim, value);
23984 + HANDLE_CASE(QUOTA, quota, value);
23985 + HANDLE_CASE(CVIRT, cvirt, value);
23986 + HANDLE_CASE(SPACE, space, value);
23987 + HANDLE_CASE(PERM, perm, value);
23988 + HANDLE_CASE(MISC, misc, value);
23997 +__setup("vsdebug=", vs_debug_setup);
24001 +EXPORT_SYMBOL_GPL(vs_debug_switch);
24002 +EXPORT_SYMBOL_GPL(vs_debug_xid);
24003 +EXPORT_SYMBOL_GPL(vs_debug_nid);
24004 +EXPORT_SYMBOL_GPL(vs_debug_net);
24005 +EXPORT_SYMBOL_GPL(vs_debug_limit);
24006 +EXPORT_SYMBOL_GPL(vs_debug_cres);
24007 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
24008 +EXPORT_SYMBOL_GPL(vs_debug_quota);
24009 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
24010 +EXPORT_SYMBOL_GPL(vs_debug_space);
24011 +EXPORT_SYMBOL_GPL(vs_debug_perm);
24012 +EXPORT_SYMBOL_GPL(vs_debug_misc);
24014 diff -NurpP --minimal linux-3.0.25/kernel/vserver/tag.c linux-3.0.25-vs2.3.2.3/kernel/vserver/tag.c
24015 --- linux-3.0.25/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
24016 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/tag.c 2011-06-10 22:11:24.000000000 +0200
24019 + * linux/kernel/vserver/tag.c
24021 + * Virtual Server: Shallow Tag Space
24023 + * Copyright (C) 2007 Herbert Pötzl
24025 + * V0.01 basic implementation
24029 +#include <linux/sched.h>
24030 +#include <linux/vserver/debug.h>
24031 +#include <linux/vs_pid.h>
24032 +#include <linux/vs_tag.h>
24034 +#include <linux/vserver/tag_cmd.h>
24037 +int dx_migrate_task(struct task_struct *p, tag_t tag)
24042 + vxdprintk(VXD_CBIT(tag, 5),
24043 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
24049 + vxdprintk(VXD_CBIT(tag, 5),
24050 + "moved task %p into [#%d]", p, tag);
24054 +/* vserver syscall commands below here */
24056 +/* taks xid and vx_info functions */
24059 +int vc_task_tag(uint32_t id)
24064 + struct task_struct *tsk;
24066 + tsk = find_task_by_real_pid(id);
24067 + tag = (tsk) ? tsk->tag : -ESRCH;
24068 + rcu_read_unlock();
24070 + tag = dx_current_tag();
24075 +int vc_tag_migrate(uint32_t tag)
24077 + return dx_migrate_task(current, tag & 0xFFFF);
24081 diff -NurpP --minimal linux-3.0.25/kernel/vserver/vci_config.h linux-3.0.25-vs2.3.2.3/kernel/vserver/vci_config.h
24082 --- linux-3.0.25/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
24083 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/vci_config.h 2011-06-10 22:11:24.000000000 +0200
24086 +/* interface version */
24088 +#define VCI_VERSION 0x00020308
24092 + VCI_KCBIT_NO_DYNAMIC = 0,
24094 + VCI_KCBIT_PROC_SECURE = 4,
24095 + /* VCI_KCBIT_HARDCPU = 5, */
24096 + /* VCI_KCBIT_IDLELIMIT = 6, */
24097 + /* VCI_KCBIT_IDLETIME = 7, */
24099 + VCI_KCBIT_COWBL = 8,
24100 + VCI_KCBIT_FULLCOWBL = 9,
24101 + VCI_KCBIT_SPACES = 10,
24102 + VCI_KCBIT_NETV2 = 11,
24103 + VCI_KCBIT_MEMCG = 12,
24105 + VCI_KCBIT_DEBUG = 16,
24106 + VCI_KCBIT_HISTORY = 20,
24107 + VCI_KCBIT_TAGGED = 24,
24108 + VCI_KCBIT_PPTAG = 28,
24110 + VCI_KCBIT_MORE = 31,
24114 +static inline uint32_t vci_kernel_config(void)
24117 + (1 << VCI_KCBIT_NO_DYNAMIC) |
24119 + /* configured features */
24120 +#ifdef CONFIG_VSERVER_PROC_SECURE
24121 + (1 << VCI_KCBIT_PROC_SECURE) |
24123 +#ifdef CONFIG_VSERVER_COWBL
24124 + (1 << VCI_KCBIT_COWBL) |
24125 + (1 << VCI_KCBIT_FULLCOWBL) |
24127 + (1 << VCI_KCBIT_SPACES) |
24128 + (1 << VCI_KCBIT_NETV2) |
24129 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
24130 + (1 << VCI_KCBIT_MEMCG) |
24133 + /* debug options */
24134 +#ifdef CONFIG_VSERVER_DEBUG
24135 + (1 << VCI_KCBIT_DEBUG) |
24137 +#ifdef CONFIG_VSERVER_HISTORY
24138 + (1 << VCI_KCBIT_HISTORY) |
24141 + /* inode context tagging */
24142 +#if defined(CONFIG_TAGGING_NONE)
24143 + (0 << VCI_KCBIT_TAGGED) |
24144 +#elif defined(CONFIG_TAGGING_UID16)
24145 + (1 << VCI_KCBIT_TAGGED) |
24146 +#elif defined(CONFIG_TAGGING_GID16)
24147 + (2 << VCI_KCBIT_TAGGED) |
24148 +#elif defined(CONFIG_TAGGING_ID24)
24149 + (3 << VCI_KCBIT_TAGGED) |
24150 +#elif defined(CONFIG_TAGGING_INTERN)
24151 + (4 << VCI_KCBIT_TAGGED) |
24152 +#elif defined(CONFIG_TAGGING_RUNTIME)
24153 + (5 << VCI_KCBIT_TAGGED) |
24155 + (7 << VCI_KCBIT_TAGGED) |
24157 + (1 << VCI_KCBIT_PPTAG) |
24161 diff -NurpP --minimal linux-3.0.25/mm/filemap_xip.c linux-3.0.25-vs2.3.2.3/mm/filemap_xip.c
24162 --- linux-3.0.25/mm/filemap_xip.c 2012-03-19 21:16:56.000000000 +0100
24163 +++ linux-3.0.25-vs2.3.2.3/mm/filemap_xip.c 2012-02-15 05:20:43.000000000 +0100
24165 #include <linux/seqlock.h>
24166 #include <linux/mutex.h>
24167 #include <linux/gfp.h>
24168 +#include <linux/vs_memory.h>
24169 #include <asm/tlbflush.h>
24170 #include <asm/io.h>
24172 diff -NurpP --minimal linux-3.0.25/mm/fremap.c linux-3.0.25-vs2.3.2.3/mm/fremap.c
24173 --- linux-3.0.25/mm/fremap.c 2011-07-22 11:18:12.000000000 +0200
24174 +++ linux-3.0.25-vs2.3.2.3/mm/fremap.c 2011-06-10 22:11:24.000000000 +0200
24176 #include <linux/module.h>
24177 #include <linux/syscalls.h>
24178 #include <linux/mmu_notifier.h>
24179 +#include <linux/vs_memory.h>
24181 #include <asm/mmu_context.h>
24182 #include <asm/cacheflush.h>
24183 diff -NurpP --minimal linux-3.0.25/mm/hugetlb.c linux-3.0.25-vs2.3.2.3/mm/hugetlb.c
24184 --- linux-3.0.25/mm/hugetlb.c 2012-03-19 21:16:56.000000000 +0100
24185 +++ linux-3.0.25-vs2.3.2.3/mm/hugetlb.c 2012-01-10 09:19:13.000000000 +0100
24188 #include <linux/hugetlb.h>
24189 #include <linux/node.h>
24190 +#include <linux/vs_memory.h>
24191 #include "internal.h"
24193 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
24194 diff -NurpP --minimal linux-3.0.25/mm/memcontrol.c linux-3.0.25-vs2.3.2.3/mm/memcontrol.c
24195 --- linux-3.0.25/mm/memcontrol.c 2012-03-19 21:16:56.000000000 +0100
24196 +++ linux-3.0.25-vs2.3.2.3/mm/memcontrol.c 2012-03-15 13:32:35.000000000 +0100
24197 @@ -741,6 +741,31 @@ struct mem_cgroup *mem_cgroup_from_task(
24198 struct mem_cgroup, css);
24201 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
24203 + return res_counter_read_u64(&mem->res, member);
24206 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
24208 + return res_counter_read_u64(&mem->memsw, member);
24211 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
24213 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
24216 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
24218 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
24221 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
24223 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
24226 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
24228 struct mem_cgroup *mem = NULL;
24229 diff -NurpP --minimal linux-3.0.25/mm/memory.c linux-3.0.25-vs2.3.2.3/mm/memory.c
24230 --- linux-3.0.25/mm/memory.c 2012-03-19 21:16:56.000000000 +0100
24231 +++ linux-3.0.25-vs2.3.2.3/mm/memory.c 2011-11-15 17:37:07.000000000 +0100
24232 @@ -3388,6 +3388,7 @@ int handle_pte_fault(struct mm_struct *m
24236 + int ret = 0, type = VXPT_UNKNOWN;
24239 if (!pte_present(entry)) {
24240 @@ -3412,9 +3413,12 @@ int handle_pte_fault(struct mm_struct *m
24241 if (unlikely(!pte_same(*pte, entry)))
24243 if (flags & FAULT_FLAG_WRITE) {
24244 - if (!pte_write(entry))
24245 - return do_wp_page(mm, vma, address,
24246 + if (!pte_write(entry)) {
24247 + ret = do_wp_page(mm, vma, address,
24248 pte, pmd, ptl, entry);
24249 + type = VXPT_WRITE;
24252 entry = pte_mkdirty(entry);
24254 entry = pte_mkyoung(entry);
24255 @@ -3432,7 +3436,10 @@ int handle_pte_fault(struct mm_struct *m
24258 pte_unmap_unlock(pte, ptl);
24262 + vx_page_fault(mm, vma, type, ret);
24267 diff -NurpP --minimal linux-3.0.25/mm/mremap.c linux-3.0.25-vs2.3.2.3/mm/mremap.c
24268 --- linux-3.0.25/mm/mremap.c 2011-07-22 11:18:12.000000000 +0200
24269 +++ linux-3.0.25-vs2.3.2.3/mm/mremap.c 2011-06-10 22:11:24.000000000 +0200
24271 #include <linux/security.h>
24272 #include <linux/syscalls.h>
24273 #include <linux/mmu_notifier.h>
24274 +#include <linux/vs_memory.h>
24276 #include <asm/uaccess.h>
24277 #include <asm/cacheflush.h>
24278 diff -NurpP --minimal linux-3.0.25/mm/oom_kill.c linux-3.0.25-vs2.3.2.3/mm/oom_kill.c
24279 --- linux-3.0.25/mm/oom_kill.c 2012-03-19 21:16:56.000000000 +0100
24280 +++ linux-3.0.25-vs2.3.2.3/mm/oom_kill.c 2012-01-10 09:19:13.000000000 +0100
24282 #include <linux/mempolicy.h>
24283 #include <linux/security.h>
24284 #include <linux/ptrace.h>
24285 +#include <linux/reboot.h>
24286 +#include <linux/vs_memory.h>
24287 +#include <linux/vs_context.h>
24289 int sysctl_panic_on_oom;
24290 int sysctl_oom_kill_allocating_task;
24291 @@ -134,11 +137,18 @@ struct task_struct *find_lock_task_mm(st
24292 static bool oom_unkillable_task(struct task_struct *p,
24293 const struct mem_cgroup *mem, const nodemask_t *nodemask)
24295 - if (is_global_init(p))
24296 + unsigned xid = vx_current_xid();
24298 + /* skip the init task, global and per guest */
24299 + if (task_is_init(p))
24301 if (p->flags & PF_KTHREAD)
24304 + /* skip other guest and host processes if oom in guest */
24305 + if (xid && vx_task_xid(p) != xid)
24308 /* When mem_cgroup_out_of_memory() and p is not member of the group */
24309 if (mem && !task_in_mem_cgroup(p, mem))
24311 @@ -214,6 +224,18 @@ unsigned int oom_badness(struct task_str
24312 points += p->signal->oom_score_adj;
24315 + * add points for context badness and
24316 + * reduce badness for processes belonging to
24317 + * a different context
24320 + points += vx_badness(p, p->mm);
24322 + if ((vx_current_xid() > 1) &&
24323 + vx_current_xid() != vx_task_xid(p))
24327 * Never return 0 for an eligible task that may be killed since it's
24328 * possible that no single user task uses more than 0.1% of memory and
24329 * no single admin tasks uses more than 3.0%.
24330 @@ -429,8 +451,8 @@ static int oom_kill_task(struct task_str
24331 /* mm cannot be safely dereferenced after task_unlock(p) */
24334 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24335 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
24336 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24337 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
24338 K(get_mm_counter(p->mm, MM_ANONPAGES)),
24339 K(get_mm_counter(p->mm, MM_FILEPAGES)));
24341 @@ -484,8 +506,8 @@ static int oom_kill_process(struct task_
24345 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
24346 - message, task_pid_nr(p), p->comm, points);
24347 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
24348 + message, task_pid_nr(p), p->xid, p->comm, points);
24352 @@ -586,6 +608,8 @@ int unregister_oom_notifier(struct notif
24354 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
24356 +long vs_oom_action(unsigned int);
24359 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
24360 * if a parallel OOM killing is already taking place that includes a zone in
24361 @@ -744,7 +768,12 @@ retry:
24363 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
24364 read_unlock(&tasklist_lock);
24365 - panic("Out of memory and no killable processes...\n");
24367 + /* avoid panic for guest OOM */
24368 + if (current->xid)
24369 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
24371 + panic("Out of memory and no killable processes...\n");
24374 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
24375 diff -NurpP --minimal linux-3.0.25/mm/page_alloc.c linux-3.0.25-vs2.3.2.3/mm/page_alloc.c
24376 --- linux-3.0.25/mm/page_alloc.c 2012-03-19 21:16:56.000000000 +0100
24377 +++ linux-3.0.25-vs2.3.2.3/mm/page_alloc.c 2012-01-26 08:39:53.000000000 +0100
24379 #include <linux/ftrace_event.h>
24380 #include <linux/memcontrol.h>
24381 #include <linux/prefetch.h>
24382 +#include <linux/vs_base.h>
24383 +#include <linux/vs_limit.h>
24385 #include <asm/tlbflush.h>
24386 #include <asm/div64.h>
24387 @@ -2502,6 +2504,9 @@ void si_meminfo(struct sysinfo *val)
24388 val->totalhigh = totalhigh_pages;
24389 val->freehigh = nr_free_highpages();
24390 val->mem_unit = PAGE_SIZE;
24392 + if (vx_flags(VXF_VIRT_MEM, 0))
24393 + vx_vsi_meminfo(val);
24396 EXPORT_SYMBOL(si_meminfo);
24397 @@ -2522,6 +2527,9 @@ void si_meminfo_node(struct sysinfo *val
24400 val->mem_unit = PAGE_SIZE;
24402 + if (vx_flags(VXF_VIRT_MEM, 0))
24403 + vx_vsi_meminfo(val);
24407 diff -NurpP --minimal linux-3.0.25/mm/pgtable-generic.c linux-3.0.25-vs2.3.2.3/mm/pgtable-generic.c
24408 --- linux-3.0.25/mm/pgtable-generic.c 2011-03-15 18:07:42.000000000 +0100
24409 +++ linux-3.0.25-vs2.3.2.3/mm/pgtable-generic.c 2011-06-10 22:11:24.000000000 +0200
24411 * Copyright (C) 2010 Linus Torvalds
24414 +#include <linux/mm.h>
24416 #include <linux/pagemap.h>
24417 #include <asm/tlb.h>
24418 #include <asm-generic/pgtable.h>
24419 diff -NurpP --minimal linux-3.0.25/mm/rmap.c linux-3.0.25-vs2.3.2.3/mm/rmap.c
24420 --- linux-3.0.25/mm/rmap.c 2011-07-22 11:18:12.000000000 +0200
24421 +++ linux-3.0.25-vs2.3.2.3/mm/rmap.c 2011-07-01 11:35:35.000000000 +0200
24423 #include <linux/mmu_notifier.h>
24424 #include <linux/migrate.h>
24425 #include <linux/hugetlb.h>
24426 +#include <linux/vs_memory.h>
24428 #include <asm/tlbflush.h>
24430 diff -NurpP --minimal linux-3.0.25/mm/shmem.c linux-3.0.25-vs2.3.2.3/mm/shmem.c
24431 --- linux-3.0.25/mm/shmem.c 2011-07-22 11:18:12.000000000 +0200
24432 +++ linux-3.0.25-vs2.3.2.3/mm/shmem.c 2011-07-01 11:35:35.000000000 +0200
24433 @@ -1850,7 +1850,7 @@ static int shmem_statfs(struct dentry *d
24435 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24437 - buf->f_type = TMPFS_MAGIC;
24438 + buf->f_type = TMPFS_SUPER_MAGIC;
24439 buf->f_bsize = PAGE_CACHE_SIZE;
24440 buf->f_namelen = NAME_MAX;
24441 if (sbinfo->max_blocks) {
24442 @@ -2605,7 +2605,7 @@ int shmem_fill_super(struct super_block
24443 sb->s_maxbytes = SHMEM_MAX_BYTES;
24444 sb->s_blocksize = PAGE_CACHE_SIZE;
24445 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24446 - sb->s_magic = TMPFS_MAGIC;
24447 + sb->s_magic = TMPFS_SUPER_MAGIC;
24448 sb->s_op = &shmem_ops;
24449 sb->s_time_gran = 1;
24450 #ifdef CONFIG_TMPFS_XATTR
24451 diff -NurpP --minimal linux-3.0.25/mm/slab.c linux-3.0.25-vs2.3.2.3/mm/slab.c
24452 --- linux-3.0.25/mm/slab.c 2011-07-22 11:18:12.000000000 +0200
24453 +++ linux-3.0.25-vs2.3.2.3/mm/slab.c 2011-06-15 02:41:23.000000000 +0200
24454 @@ -411,6 +411,8 @@ static void kmem_list3_init(struct kmem_
24455 #define STATS_INC_FREEMISS(x) do { } while (0)
24458 +#include "slab_vs.h"
24463 @@ -3348,6 +3350,7 @@ retry:
24465 obj = slab_get_obj(cachep, slabp, nodeid);
24466 check_slabp(cachep, slabp);
24467 + vx_slab_alloc(cachep, flags);
24468 l3->free_objects--;
24469 /* move slabp to correct slabp list: */
24470 list_del(&slabp->list);
24471 @@ -3425,6 +3428,7 @@ __cache_alloc_node(struct kmem_cache *ca
24472 /* ___cache_alloc_node can fall back to other nodes */
24473 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24475 + vx_slab_alloc(cachep, flags);
24476 local_irq_restore(save_flags);
24477 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24478 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24479 @@ -3612,6 +3616,7 @@ static inline void __cache_free(struct k
24481 kmemleak_free_recursive(objp, cachep->flags);
24482 objp = cache_free_debugcheck(cachep, objp, caller);
24483 + vx_slab_free(cachep);
24485 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24487 diff -NurpP --minimal linux-3.0.25/mm/slab_vs.h linux-3.0.25-vs2.3.2.3/mm/slab_vs.h
24488 --- linux-3.0.25/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24489 +++ linux-3.0.25-vs2.3.2.3/mm/slab_vs.h 2011-06-10 22:11:24.000000000 +0200
24492 +#include <linux/vserver/context.h>
24494 +#include <linux/vs_context.h>
24497 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24499 + int what = gfp_zone(cachep->gfpflags);
24500 + struct vx_info *vxi = current_vx_info();
24505 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24509 +void vx_slab_free(struct kmem_cache *cachep)
24511 + int what = gfp_zone(cachep->gfpflags);
24512 + struct vx_info *vxi = current_vx_info();
24517 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24520 diff -NurpP --minimal linux-3.0.25/mm/swapfile.c linux-3.0.25-vs2.3.2.3/mm/swapfile.c
24521 --- linux-3.0.25/mm/swapfile.c 2011-07-22 11:18:12.000000000 +0200
24522 +++ linux-3.0.25-vs2.3.2.3/mm/swapfile.c 2011-07-01 11:35:35.000000000 +0200
24524 #include <asm/tlbflush.h>
24525 #include <linux/swapops.h>
24526 #include <linux/page_cgroup.h>
24527 +#include <linux/vs_base.h>
24528 +#include <linux/vs_memory.h>
24530 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24532 @@ -1759,6 +1761,16 @@ static int swap_show(struct seq_file *sw
24534 if (si == SEQ_START_TOKEN) {
24535 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24536 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24537 + struct sysinfo si;
24539 + vx_vsi_swapinfo(&si);
24540 + if (si.totalswap < (1 << 10))
24542 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24543 + "hdv0", "partition", si.totalswap >> 10,
24544 + (si.totalswap - si.freeswap) >> 10, -1);
24549 @@ -2186,6 +2198,8 @@ void si_swapinfo(struct sysinfo *val)
24550 val->freeswap = nr_swap_pages + nr_to_be_unused;
24551 val->totalswap = total_swap_pages + nr_to_be_unused;
24552 spin_unlock(&swap_lock);
24553 + if (vx_flags(VXF_VIRT_MEM, 0))
24554 + vx_vsi_swapinfo(val);
24558 diff -NurpP --minimal linux-3.0.25/net/bridge/br_multicast.c linux-3.0.25-vs2.3.2.3/net/bridge/br_multicast.c
24559 --- linux-3.0.25/net/bridge/br_multicast.c 2012-03-19 21:16:57.000000000 +0100
24560 +++ linux-3.0.25-vs2.3.2.3/net/bridge/br_multicast.c 2012-03-23 14:55:24.000000000 +0100
24561 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
24562 ip6h->hop_limit = 1;
24563 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24564 if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24566 + &ip6h->saddr, NULL)) {
24570 diff -NurpP --minimal linux-3.0.25/net/core/dev.c linux-3.0.25-vs2.3.2.3/net/core/dev.c
24571 --- linux-3.0.25/net/core/dev.c 2012-03-19 21:16:57.000000000 +0100
24572 +++ linux-3.0.25-vs2.3.2.3/net/core/dev.c 2012-03-01 21:51:50.000000000 +0100
24573 @@ -127,6 +127,7 @@
24574 #include <linux/in.h>
24575 #include <linux/jhash.h>
24576 #include <linux/random.h>
24577 +#include <linux/vs_inet.h>
24578 #include <trace/events/napi.h>
24579 #include <trace/events/net.h>
24580 #include <trace/events/skb.h>
24581 @@ -609,7 +610,8 @@ struct net_device *__dev_get_by_name(str
24582 struct hlist_head *head = dev_name_hash(net, name);
24584 hlist_for_each_entry(dev, p, head, name_hlist)
24585 - if (!strncmp(dev->name, name, IFNAMSIZ))
24586 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24587 + nx_dev_visible(current_nx_info(), dev))
24591 @@ -635,7 +637,8 @@ struct net_device *dev_get_by_name_rcu(s
24592 struct hlist_head *head = dev_name_hash(net, name);
24594 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24595 - if (!strncmp(dev->name, name, IFNAMSIZ))
24596 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24597 + nx_dev_visible(current_nx_info(), dev))
24601 @@ -686,7 +689,8 @@ struct net_device *__dev_get_by_index(st
24602 struct hlist_head *head = dev_index_hash(net, ifindex);
24604 hlist_for_each_entry(dev, p, head, index_hlist)
24605 - if (dev->ifindex == ifindex)
24606 + if ((dev->ifindex == ifindex) &&
24607 + nx_dev_visible(current_nx_info(), dev))
24611 @@ -704,7 +708,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24612 * about locking. The caller must hold RCU lock.
24615 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24616 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24618 struct hlist_node *p;
24619 struct net_device *dev;
24620 @@ -716,6 +720,16 @@ struct net_device *dev_get_by_index_rcu(
24624 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24626 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24628 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24630 + if (nx_dev_visible(current_nx_info(), dev))
24634 EXPORT_SYMBOL(dev_get_by_index_rcu);
24637 @@ -764,7 +778,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24639 for_each_netdev_rcu(net, dev)
24640 if (dev->type == type &&
24641 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24642 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24643 + nx_dev_visible(current_nx_info(), dev))
24647 @@ -776,9 +791,11 @@ struct net_device *__dev_getfirstbyhwtyp
24648 struct net_device *dev;
24651 - for_each_netdev(net, dev)
24652 - if (dev->type == type)
24653 + for_each_netdev(net, dev) {
24654 + if ((dev->type == type) &&
24655 + nx_dev_visible(current_nx_info(), dev))
24661 @@ -896,6 +913,8 @@ static int __dev_alloc_name(struct net *
24663 if (i < 0 || i >= max_netdevices)
24665 + if (!nx_dev_visible(current_nx_info(), d))
24668 /* avoid cases where sscanf is not exact inverse of printf */
24669 snprintf(buf, IFNAMSIZ, name, i);
24670 @@ -3943,6 +3962,8 @@ static int dev_ifconf(struct net *net, c
24673 for_each_netdev(net, dev) {
24674 + if (!nx_dev_visible(current_nx_info(), dev))
24676 for (i = 0; i < NPROTO; i++) {
24677 if (gifconf_list[i]) {
24679 @@ -4017,6 +4038,10 @@ static void dev_seq_printf_stats(struct
24680 struct rtnl_link_stats64 temp;
24681 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24683 + /* device visible inside network context? */
24684 + if (!nx_dev_visible(current_nx_info(), dev))
24687 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24688 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24689 dev->name, stats->rx_bytes, stats->rx_packets,
24690 diff -NurpP --minimal linux-3.0.25/net/core/rtnetlink.c linux-3.0.25-vs2.3.2.3/net/core/rtnetlink.c
24691 --- linux-3.0.25/net/core/rtnetlink.c 2011-07-22 11:18:13.000000000 +0200
24692 +++ linux-3.0.25-vs2.3.2.3/net/core/rtnetlink.c 2011-06-10 22:11:24.000000000 +0200
24693 @@ -1015,6 +1015,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24694 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
24697 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24699 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24700 NETLINK_CB(cb->skb).pid,
24701 cb->nlh->nlmsg_seq, 0,
24702 @@ -1848,6 +1850,9 @@ void rtmsg_ifinfo(int type, struct net_d
24703 struct sk_buff *skb;
24704 int err = -ENOBUFS;
24706 + if (!nx_dev_visible(current_nx_info(), dev))
24709 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
24712 diff -NurpP --minimal linux-3.0.25/net/core/sock.c linux-3.0.25-vs2.3.2.3/net/core/sock.c
24713 --- linux-3.0.25/net/core/sock.c 2012-03-19 21:16:57.000000000 +0100
24714 +++ linux-3.0.25-vs2.3.2.3/net/core/sock.c 2011-11-15 17:37:07.000000000 +0100
24715 @@ -127,6 +127,10 @@
24716 #include <net/cls_cgroup.h>
24718 #include <linux/filter.h>
24719 +#include <linux/vs_socket.h>
24720 +#include <linux/vs_limit.h>
24721 +#include <linux/vs_context.h>
24722 +#include <linux/vs_network.h>
24725 #include <net/tcp.h>
24726 @@ -1070,6 +1074,8 @@ static struct sock *sk_prot_alloc(struct
24728 sk_tx_queue_clear(sk);
24730 + sock_vx_init(sk);
24731 + sock_nx_init(sk);
24735 @@ -1169,6 +1175,11 @@ static void __sk_free(struct sock *sk)
24736 put_cred(sk->sk_peer_cred);
24737 put_pid(sk->sk_peer_pid);
24738 put_net(sock_net(sk));
24740 + clr_vx_info(&sk->sk_vx_info);
24742 + clr_nx_info(&sk->sk_nx_info);
24744 sk_prot_free(sk->sk_prot_creator, sk);
24747 @@ -1216,6 +1227,8 @@ struct sock *sk_clone(const struct sock
24750 get_net(sock_net(newsk));
24751 + sock_vx_init(newsk);
24752 + sock_nx_init(newsk);
24753 sk_node_init(&newsk->sk_node);
24754 sock_lock_init(newsk);
24755 bh_lock_sock(newsk);
24756 @@ -1272,6 +1285,12 @@ struct sock *sk_clone(const struct sock
24758 atomic_set(&newsk->sk_refcnt, 2);
24760 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24761 + newsk->sk_xid = sk->sk_xid;
24762 + vx_sock_inc(newsk);
24763 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24764 + newsk->sk_nid = sk->sk_nid;
24767 * Increment the counter in the same struct proto as the master
24768 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24769 @@ -2018,6 +2037,12 @@ void sock_init_data(struct socket *sock,
24771 sk->sk_stamp = ktime_set(-1L, 0);
24773 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24774 + sk->sk_xid = vx_current_xid();
24776 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24777 + sk->sk_nid = nx_current_nid();
24780 * Before updating sk_refcnt, we must commit prior changes to memory
24781 * (Documentation/RCU/rculist_nulls.txt for details)
24782 diff -NurpP --minimal linux-3.0.25/net/ipv4/af_inet.c linux-3.0.25-vs2.3.2.3/net/ipv4/af_inet.c
24783 --- linux-3.0.25/net/ipv4/af_inet.c 2011-07-22 11:18:13.000000000 +0200
24784 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/af_inet.c 2011-07-19 00:44:39.000000000 +0200
24785 @@ -117,6 +117,7 @@
24786 #ifdef CONFIG_IP_MROUTE
24787 #include <linux/mroute.h>
24789 +#include <linux/vs_limit.h>
24792 /* The inetsw table contains everything that inet_create needs to
24793 @@ -326,9 +327,13 @@ lookup_protocol:
24797 + if ((protocol == IPPROTO_ICMP) &&
24798 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24801 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24802 goto out_rcu_unlock;
24805 err = -EAFNOSUPPORT;
24806 if (!inet_netns_ok(net, protocol))
24807 goto out_rcu_unlock;
24808 @@ -452,6 +457,7 @@ int inet_bind(struct socket *sock, struc
24809 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24810 struct sock *sk = sock->sk;
24811 struct inet_sock *inet = inet_sk(sk);
24812 + struct nx_v4_sock_addr nsa;
24813 unsigned short snum;
24816 @@ -470,7 +476,11 @@ int inet_bind(struct socket *sock, struc
24820 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24821 + err = v4_map_sock_addr(inet, addr, &nsa);
24825 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24827 /* Not specified by any standard per-se, however it breaks too
24828 * many applications when removed. It is unfortunate since
24829 @@ -482,7 +492,7 @@ int inet_bind(struct socket *sock, struc
24830 err = -EADDRNOTAVAIL;
24831 if (!sysctl_ip_nonlocal_bind &&
24832 !(inet->freebind || inet->transparent) &&
24833 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24834 + nsa.saddr != htonl(INADDR_ANY) &&
24835 chk_addr_ret != RTN_LOCAL &&
24836 chk_addr_ret != RTN_MULTICAST &&
24837 chk_addr_ret != RTN_BROADCAST)
24838 @@ -507,7 +517,7 @@ int inet_bind(struct socket *sock, struc
24839 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24840 goto out_release_sock;
24842 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24843 + v4_set_sock_addr(inet, &nsa);
24844 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24845 inet->inet_saddr = 0; /* Use device */
24847 @@ -710,11 +720,13 @@ int inet_getname(struct socket *sock, st
24850 sin->sin_port = inet->inet_dport;
24851 - sin->sin_addr.s_addr = inet->inet_daddr;
24852 + sin->sin_addr.s_addr =
24853 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24855 __be32 addr = inet->inet_rcv_saddr;
24857 addr = inet->inet_saddr;
24858 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24859 sin->sin_port = inet->inet_sport;
24860 sin->sin_addr.s_addr = addr;
24862 diff -NurpP --minimal linux-3.0.25/net/ipv4/arp.c linux-3.0.25-vs2.3.2.3/net/ipv4/arp.c
24863 --- linux-3.0.25/net/ipv4/arp.c 2012-03-19 21:16:57.000000000 +0100
24864 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/arp.c 2012-03-01 21:51:50.000000000 +0100
24865 @@ -1372,6 +1372,7 @@ static void arp_format_neigh_entry(struc
24866 struct net_device *dev = n->dev;
24867 int hatype = dev->type;
24869 + /* FIXME: check for network context */
24870 read_lock(&n->lock);
24871 /* Convert hardware address to XX:XX:XX:XX ... form. */
24872 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
24873 @@ -1403,6 +1404,7 @@ static void arp_format_pneigh_entry(stru
24874 int hatype = dev ? dev->type : 0;
24877 + /* FIXME: check for network context */
24878 sprintf(tbuf, "%pI4", n->key);
24879 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24880 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24881 diff -NurpP --minimal linux-3.0.25/net/ipv4/devinet.c linux-3.0.25-vs2.3.2.3/net/ipv4/devinet.c
24882 --- linux-3.0.25/net/ipv4/devinet.c 2012-03-19 21:16:57.000000000 +0100
24883 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/devinet.c 2012-01-10 09:19:13.000000000 +0100
24884 @@ -518,6 +518,7 @@ struct in_device *inetdev_by_index(struc
24886 EXPORT_SYMBOL(inetdev_by_index);
24889 /* Called only from RTNL semaphored context. No locks. */
24891 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24892 @@ -759,6 +760,8 @@ int devinet_ioctl(struct net *net, unsig
24894 in_dev = __in_dev_get_rtnl(dev);
24896 + struct nx_info *nxi = current_nx_info();
24898 if (tryaddrmatch) {
24899 /* Matthias Andree */
24900 /* compare label and address (4.4BSD style) */
24901 @@ -767,6 +770,8 @@ int devinet_ioctl(struct net *net, unsig
24902 This is checked above. */
24903 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24904 ifap = &ifa->ifa_next) {
24905 + if (!nx_v4_ifa_visible(nxi, ifa))
24907 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24908 sin_orig.sin_addr.s_addr ==
24910 @@ -779,9 +784,12 @@ int devinet_ioctl(struct net *net, unsig
24911 comparing just the label */
24913 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24914 - ifap = &ifa->ifa_next)
24915 + ifap = &ifa->ifa_next) {
24916 + if (!nx_v4_ifa_visible(nxi, ifa))
24918 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24924 @@ -934,6 +942,8 @@ static int inet_gifconf(struct net_devic
24927 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24928 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24931 done += sizeof(ifr);
24933 @@ -1294,6 +1304,7 @@ static int inet_dump_ifaddr(struct sk_bu
24934 struct net_device *dev;
24935 struct in_device *in_dev;
24936 struct in_ifaddr *ifa;
24937 + struct sock *sk = skb->sk;
24938 struct hlist_head *head;
24939 struct hlist_node *node;
24941 @@ -1316,6 +1327,8 @@ static int inet_dump_ifaddr(struct sk_bu
24943 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24944 ifa = ifa->ifa_next, ip_idx++) {
24945 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24947 if (ip_idx < s_ip_idx)
24949 if (inet_fill_ifaddr(skb, ifa,
24950 diff -NurpP --minimal linux-3.0.25/net/ipv4/fib_trie.c linux-3.0.25-vs2.3.2.3/net/ipv4/fib_trie.c
24951 --- linux-3.0.25/net/ipv4/fib_trie.c 2011-07-22 11:18:13.000000000 +0200
24952 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/fib_trie.c 2011-08-29 04:56:47.000000000 +0200
24953 @@ -2554,6 +2554,7 @@ static int fib_route_seq_show(struct seq
24954 || fa->fa_type == RTN_MULTICAST)
24957 + /* FIXME: check for network context? */
24960 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24961 diff -NurpP --minimal linux-3.0.25/net/ipv4/inet_connection_sock.c linux-3.0.25-vs2.3.2.3/net/ipv4/inet_connection_sock.c
24962 --- linux-3.0.25/net/ipv4/inet_connection_sock.c 2011-07-22 11:18:13.000000000 +0200
24963 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/inet_connection_sock.c 2011-06-10 22:11:24.000000000 +0200
24964 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
24966 EXPORT_SYMBOL(inet_get_local_port_range);
24968 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24970 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24971 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24973 + if (inet_v6_ipv6only(sk2))
24976 + if (sk1_rcv_saddr &&
24978 + sk1_rcv_saddr == sk2_rcv_saddr)
24981 + if (sk1_rcv_saddr &&
24982 + !sk2_rcv_saddr &&
24983 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24986 + if (sk2_rcv_saddr &&
24987 + !sk1_rcv_saddr &&
24988 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24991 + if (!sk1_rcv_saddr &&
24992 + !sk2_rcv_saddr &&
24993 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24999 int inet_csk_bind_conflict(const struct sock *sk,
25000 const struct inet_bind_bucket *tb)
25002 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
25003 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
25004 if (!reuse || !sk2->sk_reuse ||
25005 sk2->sk_state == TCP_LISTEN) {
25006 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25007 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
25008 - sk2_rcv_saddr == sk_rcv_saddr(sk))
25009 + if (ipv4_rcv_saddr_equal(sk, sk2))
25013 diff -NurpP --minimal linux-3.0.25/net/ipv4/inet_diag.c linux-3.0.25-vs2.3.2.3/net/ipv4/inet_diag.c
25014 --- linux-3.0.25/net/ipv4/inet_diag.c 2011-07-22 11:18:13.000000000 +0200
25015 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/inet_diag.c 2011-06-22 12:39:16.000000000 +0200
25017 #include <linux/stddef.h>
25019 #include <linux/inet_diag.h>
25020 +#include <linux/vs_network.h>
25021 +#include <linux/vs_inet.h>
25023 static const struct inet_diag_handler **inet_diag_table;
25025 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
25027 r->id.idiag_sport = inet->inet_sport;
25028 r->id.idiag_dport = inet->inet_dport;
25029 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
25030 - r->id.idiag_dst[0] = inet->inet_daddr;
25031 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
25032 + inet->inet_rcv_saddr);
25033 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
25034 + inet->inet_daddr);
25036 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25037 if (r->idiag_family == AF_INET6) {
25038 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
25039 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
25040 r->id.idiag_sport = tw->tw_sport;
25041 r->id.idiag_dport = tw->tw_dport;
25042 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
25043 - r->id.idiag_dst[0] = tw->tw_daddr;
25044 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
25045 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
25046 r->idiag_state = tw->tw_substate;
25047 r->idiag_timer = 3;
25048 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
25049 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
25052 if (req->idiag_family == AF_INET) {
25053 + /* TODO: lback */
25054 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
25055 req->id.idiag_dport, req->id.idiag_src[0],
25056 req->id.idiag_sport, req->id.idiag_if);
25057 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
25061 + /* TODO: lback */
25062 entry.saddr = &inet->inet_rcv_saddr;
25063 entry.daddr = &inet->inet_daddr;
25065 @@ -543,6 +549,7 @@ static int inet_twsk_diag_dump(struct in
25069 + /* TODO: lback */
25070 entry.saddr = &tw->tw_rcv_saddr;
25071 entry.daddr = &tw->tw_daddr;
25073 @@ -589,8 +596,8 @@ static int inet_diag_fill_req(struct sk_
25075 r->id.idiag_sport = inet->inet_sport;
25076 r->id.idiag_dport = ireq->rmt_port;
25077 - r->id.idiag_src[0] = ireq->loc_addr;
25078 - r->id.idiag_dst[0] = ireq->rmt_addr;
25079 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
25080 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
25081 r->idiag_expires = jiffies_to_msecs(tmo);
25082 r->idiag_rqueue = 0;
25083 r->idiag_wqueue = 0;
25084 @@ -661,6 +668,7 @@ static int inet_diag_dump_reqs(struct sk
25088 + /* TODO: lback */
25090 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25091 (entry.family == AF_INET6) ?
25092 @@ -731,6 +739,8 @@ static int inet_diag_dump(struct sk_buff
25093 sk_nulls_for_each(sk, node, &ilb->head) {
25094 struct inet_sock *inet = inet_sk(sk);
25096 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25101 @@ -797,6 +807,8 @@ skip_listen_ht:
25102 sk_nulls_for_each(sk, node, &head->chain) {
25103 struct inet_sock *inet = inet_sk(sk);
25105 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25109 if (!(r->idiag_states & (1 << sk->sk_state)))
25110 @@ -821,6 +833,8 @@ next_normal:
25111 inet_twsk_for_each(tw, node,
25114 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25118 if (r->id.idiag_sport != tw->tw_sport &&
25119 diff -NurpP --minimal linux-3.0.25/net/ipv4/inet_hashtables.c linux-3.0.25-vs2.3.2.3/net/ipv4/inet_hashtables.c
25120 --- linux-3.0.25/net/ipv4/inet_hashtables.c 2012-03-19 21:16:57.000000000 +0100
25121 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/inet_hashtables.c 2011-08-29 03:45:56.000000000 +0200
25123 #include <net/inet_connection_sock.h>
25124 #include <net/inet_hashtables.h>
25125 #include <net/secure_seq.h>
25126 +#include <net/route.h>
25127 #include <net/ip.h>
25130 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
25131 if (rcv_saddr != daddr)
25135 + /* block non nx_info ips */
25136 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25137 + daddr, NXA_MASK_BIND))
25140 if (sk->sk_bound_dev_if) {
25141 if (sk->sk_bound_dev_if != dif)
25142 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
25143 * wildcarded during the search since they can never be otherwise.
25147 struct sock *__inet_lookup_listener(struct net *net,
25148 struct inet_hashinfo *hashinfo,
25149 const __be32 daddr, const unsigned short hnum,
25150 @@ -196,6 +201,7 @@ begin:
25156 * if the nulls value we got at the end of this lookup is
25157 * not the expected one, we must restart lookup.
25158 diff -NurpP --minimal linux-3.0.25/net/ipv4/netfilter/nf_nat_helper.c linux-3.0.25-vs2.3.2.3/net/ipv4/netfilter/nf_nat_helper.c
25159 --- linux-3.0.25/net/ipv4/netfilter/nf_nat_helper.c 2011-07-22 11:18:13.000000000 +0200
25160 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/netfilter/nf_nat_helper.c 2011-06-15 02:40:14.000000000 +0200
25162 #include <net/route.h>
25164 #include <linux/netfilter_ipv4.h>
25165 +#include <net/route.h>
25166 #include <net/netfilter/nf_conntrack.h>
25167 #include <net/netfilter/nf_conntrack_helper.h>
25168 #include <net/netfilter/nf_conntrack_ecache.h>
25169 diff -NurpP --minimal linux-3.0.25/net/ipv4/netfilter.c linux-3.0.25-vs2.3.2.3/net/ipv4/netfilter.c
25170 --- linux-3.0.25/net/ipv4/netfilter.c 2012-03-19 21:16:57.000000000 +0100
25171 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/netfilter.c 2011-10-18 13:51:13.000000000 +0200
25173 #include <linux/ip.h>
25174 #include <linux/skbuff.h>
25175 #include <linux/gfp.h>
25176 -#include <net/route.h>
25177 +// #include <net/route.h>
25178 #include <net/xfrm.h>
25179 #include <net/ip.h>
25180 #include <net/netfilter/nf_queue.h>
25181 diff -NurpP --minimal linux-3.0.25/net/ipv4/raw.c linux-3.0.25-vs2.3.2.3/net/ipv4/raw.c
25182 --- linux-3.0.25/net/ipv4/raw.c 2011-07-22 11:18:13.000000000 +0200
25183 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/raw.c 2011-07-27 20:26:04.000000000 +0200
25184 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
25186 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
25187 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
25188 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
25189 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
25190 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
25191 goto found; /* gotcha */
25193 @@ -385,6 +385,12 @@ static int raw_send_hdrinc(struct sock *
25194 icmp_out_count(net, ((struct icmphdr *)
25195 skb_transport_header(skb))->type);
25198 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
25199 + sk->sk_nx_info &&
25200 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
25203 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
25204 rt->dst.dev, dst_output);
25206 @@ -571,6 +577,16 @@ static int raw_sendmsg(struct kiocb *ioc
25210 + if (sk->sk_nx_info) {
25211 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
25212 + if (IS_ERR(rt)) {
25213 + err = PTR_ERR(rt);
25220 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
25221 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
25223 @@ -647,17 +663,19 @@ static int raw_bind(struct sock *sk, str
25225 struct inet_sock *inet = inet_sk(sk);
25226 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
25227 + struct nx_v4_sock_addr nsa = { 0 };
25231 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
25233 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25234 + v4_map_sock_addr(inet, addr, &nsa);
25235 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25236 ret = -EADDRNOTAVAIL;
25237 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
25238 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
25239 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
25241 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25242 + v4_set_sock_addr(inet, &nsa);
25243 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25244 inet->inet_saddr = 0; /* Use device */
25246 @@ -709,7 +727,8 @@ static int raw_recvmsg(struct kiocb *ioc
25247 /* Copy the address. */
25249 sin->sin_family = AF_INET;
25250 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25251 + sin->sin_addr.s_addr =
25252 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
25254 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
25256 @@ -905,7 +924,8 @@ static struct sock *raw_get_first(struct
25257 struct hlist_node *node;
25259 sk_for_each(sk, node, &state->h->ht[state->bucket])
25260 - if (sock_net(sk) == seq_file_net(seq))
25261 + if ((sock_net(sk) == seq_file_net(seq)) &&
25262 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25266 @@ -921,7 +941,8 @@ static struct sock *raw_get_next(struct
25270 - } while (sk && sock_net(sk) != seq_file_net(seq));
25271 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
25272 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25274 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
25275 sk = sk_head(&state->h->ht[state->bucket]);
25276 diff -NurpP --minimal linux-3.0.25/net/ipv4/route.c linux-3.0.25-vs2.3.2.3/net/ipv4/route.c
25277 --- linux-3.0.25/net/ipv4/route.c 2012-03-19 21:16:57.000000000 +0100
25278 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/route.c 2012-03-01 21:51:50.000000000 +0100
25279 @@ -2658,7 +2658,7 @@ static struct rtable *ip_route_output_sl
25282 if (fl4->flowi4_oif) {
25283 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
25284 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
25285 rth = ERR_PTR(-ENODEV);
25286 if (dev_out == NULL)
25288 diff -NurpP --minimal linux-3.0.25/net/ipv4/tcp.c linux-3.0.25-vs2.3.2.3/net/ipv4/tcp.c
25289 --- linux-3.0.25/net/ipv4/tcp.c 2011-07-22 11:18:13.000000000 +0200
25290 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/tcp.c 2011-07-19 00:44:39.000000000 +0200
25291 @@ -266,6 +266,7 @@
25292 #include <linux/crypto.h>
25293 #include <linux/time.h>
25294 #include <linux/slab.h>
25295 +#include <linux/in.h>
25297 #include <net/icmp.h>
25298 #include <net/tcp.h>
25299 diff -NurpP --minimal linux-3.0.25/net/ipv4/tcp_ipv4.c linux-3.0.25-vs2.3.2.3/net/ipv4/tcp_ipv4.c
25300 --- linux-3.0.25/net/ipv4/tcp_ipv4.c 2012-03-19 21:16:57.000000000 +0100
25301 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/tcp_ipv4.c 2012-03-01 21:51:50.000000000 +0100
25302 @@ -2011,6 +2011,12 @@ static void *listening_get_next(struct s
25303 req = req->dl_next;
25306 + vxdprintk(VXD_CBIT(net, 6),
25307 + "sk,req: %p [#%d] (from %d)", req->sk,
25308 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
25310 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
25312 if (req->rsk_ops->family == st->family) {
25315 @@ -2035,6 +2041,10 @@ get_req:
25318 sk_nulls_for_each_from(sk, node) {
25319 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
25320 + sk, sk->sk_nid, nx_current_nid());
25321 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25323 if (!net_eq(sock_net(sk), net))
25325 if (sk->sk_family == st->family) {
25326 @@ -2111,6 +2121,11 @@ static void *established_get_first(struc
25328 spin_lock_bh(lock);
25329 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
25330 + vxdprintk(VXD_CBIT(net, 6),
25331 + "sk,egf: %p [#%d] (from %d)",
25332 + sk, sk->sk_nid, nx_current_nid());
25333 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25335 if (sk->sk_family != st->family ||
25336 !net_eq(sock_net(sk), net)) {
25338 @@ -2121,6 +2136,11 @@ static void *established_get_first(struc
25339 st->state = TCP_SEQ_STATE_TIME_WAIT;
25340 inet_twsk_for_each(tw, node,
25341 &tcp_hashinfo.ehash[st->bucket].twchain) {
25342 + vxdprintk(VXD_CBIT(net, 6),
25343 + "tw: %p [#%d] (from %d)",
25344 + tw, tw->tw_nid, nx_current_nid());
25345 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25347 if (tw->tw_family != st->family ||
25348 !net_eq(twsk_net(tw), net)) {
25350 @@ -2150,7 +2170,9 @@ static void *established_get_next(struct
25354 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
25355 + while (tw && (tw->tw_family != st->family ||
25356 + !net_eq(twsk_net(tw), net) ||
25357 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
25361 @@ -2174,6 +2196,11 @@ get_tw:
25362 sk = sk_nulls_next(sk);
25364 sk_nulls_for_each_from(sk, node) {
25365 + vxdprintk(VXD_CBIT(net, 6),
25366 + "sk,egn: %p [#%d] (from %d)",
25367 + sk, sk->sk_nid, nx_current_nid());
25368 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25370 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
25373 @@ -2383,9 +2410,9 @@ static void get_openreq4(struct sock *sk
25374 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25375 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
25378 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
25379 ntohs(inet_sk(sk)->inet_sport),
25381 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
25382 ntohs(ireq->rmt_port),
25384 0, 0, /* could print option size, but that is af dependent. */
25385 @@ -2407,8 +2434,8 @@ static void get_tcp4_sock(struct sock *s
25386 struct tcp_sock *tp = tcp_sk(sk);
25387 const struct inet_connection_sock *icsk = inet_csk(sk);
25388 struct inet_sock *inet = inet_sk(sk);
25389 - __be32 dest = inet->inet_daddr;
25390 - __be32 src = inet->inet_rcv_saddr;
25391 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
25392 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
25393 __u16 destp = ntohs(inet->inet_dport);
25394 __u16 srcp = ntohs(inet->inet_sport);
25396 @@ -2465,8 +2492,8 @@ static void get_timewait4_sock(struct in
25400 - dest = tw->tw_daddr;
25401 - src = tw->tw_rcv_saddr;
25402 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
25403 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
25404 destp = ntohs(tw->tw_dport);
25405 srcp = ntohs(tw->tw_sport);
25407 diff -NurpP --minimal linux-3.0.25/net/ipv4/tcp_minisocks.c linux-3.0.25-vs2.3.2.3/net/ipv4/tcp_minisocks.c
25408 --- linux-3.0.25/net/ipv4/tcp_minisocks.c 2011-03-15 18:07:45.000000000 +0100
25409 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/tcp_minisocks.c 2011-06-10 22:11:24.000000000 +0200
25411 #include <linux/slab.h>
25412 #include <linux/sysctl.h>
25413 #include <linux/workqueue.h>
25414 +#include <linux/vs_limit.h>
25415 +#include <linux/vs_socket.h>
25416 +#include <linux/vs_context.h>
25417 #include <net/tcp.h>
25418 #include <net/inet_common.h>
25419 #include <net/xfrm.h>
25420 @@ -335,6 +338,11 @@ void tcp_time_wait(struct sock *sk, int
25421 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25422 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25424 + tw->tw_xid = sk->sk_xid;
25425 + tw->tw_vx_info = NULL;
25426 + tw->tw_nid = sk->sk_nid;
25427 + tw->tw_nx_info = NULL;
25429 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25430 if (tw->tw_family == PF_INET6) {
25431 struct ipv6_pinfo *np = inet6_sk(sk);
25432 diff -NurpP --minimal linux-3.0.25/net/ipv4/udp.c linux-3.0.25-vs2.3.2.3/net/ipv4/udp.c
25433 --- linux-3.0.25/net/ipv4/udp.c 2011-07-22 11:18:13.000000000 +0200
25434 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/udp.c 2011-07-27 20:26:14.000000000 +0200
25435 @@ -296,14 +296,7 @@ fail:
25437 EXPORT_SYMBOL(udp_lib_get_port);
25439 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25441 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25443 - return (!ipv6_only_sock(sk2) &&
25444 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25445 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25447 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25449 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25451 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
25452 if (inet->inet_rcv_saddr != daddr)
25456 + /* block non nx_info ips */
25457 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25458 + daddr, NXA_MASK_BIND))
25461 if (inet->inet_daddr) {
25462 if (inet->inet_daddr != saddr)
25463 @@ -441,6 +439,7 @@ exact_match:
25468 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25469 * harder than this. -DaveM
25471 @@ -486,6 +485,11 @@ begin:
25472 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25473 score = compute_score(sk, net, saddr, hnum, sport,
25474 daddr, dport, dif);
25475 + /* FIXME: disabled?
25476 + if (score == 9) {
25480 if (score > badness) {
25483 @@ -499,6 +503,7 @@ begin:
25484 if (get_nulls_value(node) != slot)
25489 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25491 @@ -508,6 +513,7 @@ begin:
25499 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
25500 udp_sk(s)->udp_port_hash != hnum ||
25501 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25502 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25503 - (inet->inet_rcv_saddr &&
25504 - inet->inet_rcv_saddr != loc_addr) ||
25505 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25506 ipv6_only_sock(s) ||
25507 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25509 @@ -929,6 +934,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
25510 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
25511 faddr, saddr, dport, inet->inet_sport);
25513 + if (sk->sk_nx_info) {
25514 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
25515 + if (IS_ERR(rt)) {
25516 + err = PTR_ERR(rt);
25523 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
25524 rt = ip_route_output_flow(net, fl4, sk);
25526 @@ -1226,7 +1241,8 @@ try_again:
25528 sin->sin_family = AF_INET;
25529 sin->sin_port = udp_hdr(skb)->source;
25530 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25531 + sin->sin_addr.s_addr = nx_map_sock_lback(
25532 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25533 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25535 if (inet->cmsg_flags)
25536 @@ -1970,6 +1986,8 @@ static struct sock *udp_get_first(struct
25537 sk_nulls_for_each(sk, node, &hslot->head) {
25538 if (!net_eq(sock_net(sk), net))
25540 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25542 if (sk->sk_family == state->family)
25545 @@ -1987,7 +2005,9 @@ static struct sock *udp_get_next(struct
25548 sk = sk_nulls_next(sk);
25549 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25550 + } while (sk && (!net_eq(sock_net(sk), net) ||
25551 + sk->sk_family != state->family ||
25552 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25555 if (state->bucket <= state->udp_table->mask)
25556 diff -NurpP --minimal linux-3.0.25/net/ipv6/Kconfig linux-3.0.25-vs2.3.2.3/net/ipv6/Kconfig
25557 --- linux-3.0.25/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25558 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/Kconfig 2011-06-10 22:11:24.000000000 +0200
25561 # IPv6 as module will cause a CRASH if you try to unload it
25563 - tristate "The IPv6 protocol"
25565 + bool "The IPv6 protocol"
25568 This is complemental support for the IP version 6.
25569 You will still be able to do traditional IPv4 networking as well.
25570 diff -NurpP --minimal linux-3.0.25/net/ipv6/addrconf.c linux-3.0.25-vs2.3.2.3/net/ipv6/addrconf.c
25571 --- linux-3.0.25/net/ipv6/addrconf.c 2012-03-19 21:16:57.000000000 +0100
25572 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/addrconf.c 2012-03-23 14:54:00.000000000 +0100
25575 #include <linux/proc_fs.h>
25576 #include <linux/seq_file.h>
25577 +#include <linux/vs_network.h>
25578 +#include <linux/vs_inet6.h>
25580 /* Set to 3 to get tracing... */
25581 #define ACONF_DEBUG 2
25582 @@ -1112,7 +1114,7 @@ out:
25584 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25585 const struct in6_addr *daddr, unsigned int prefs,
25586 - struct in6_addr *saddr)
25587 + struct in6_addr *saddr, struct nx_info *nxi)
25589 struct ipv6_saddr_score scores[2],
25590 *score = &scores[0], *hiscore = &scores[1];
25591 @@ -1184,6 +1186,8 @@ int ipv6_dev_get_saddr(struct net *net,
25595 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25599 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25600 @@ -3052,7 +3056,10 @@ static void if6_seq_stop(struct seq_file
25601 static int if6_seq_show(struct seq_file *seq, void *v)
25603 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25604 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25606 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25607 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25608 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25610 ifp->idev->dev->ifindex,
25612 @@ -3558,6 +3565,11 @@ static int in6_dump_addrs(struct inet6_d
25613 struct ifacaddr6 *ifaca;
25615 int ip_idx = *p_ip_idx;
25616 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25618 + /* disable ipv6 on non v6 guests */
25619 + if (nxi && !nx_info_has_v6(nxi))
25622 read_lock_bh(&idev->lock);
25624 @@ -3568,6 +3580,8 @@ static int in6_dump_addrs(struct inet6_d
25625 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25626 if (++ip_idx < s_ip_idx)
25628 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25630 err = inet6_fill_ifaddr(skb, ifa,
25631 NETLINK_CB(cb->skb).pid,
25632 cb->nlh->nlmsg_seq,
25633 @@ -3584,6 +3598,8 @@ static int in6_dump_addrs(struct inet6_d
25634 ifmca = ifmca->next, ip_idx++) {
25635 if (ip_idx < s_ip_idx)
25637 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25639 err = inet6_fill_ifmcaddr(skb, ifmca,
25640 NETLINK_CB(cb->skb).pid,
25641 cb->nlh->nlmsg_seq,
25642 @@ -3599,6 +3615,8 @@ static int in6_dump_addrs(struct inet6_d
25643 ifaca = ifaca->aca_next, ip_idx++) {
25644 if (ip_idx < s_ip_idx)
25646 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25648 err = inet6_fill_ifacaddr(skb, ifaca,
25649 NETLINK_CB(cb->skb).pid,
25650 cb->nlh->nlmsg_seq,
25651 @@ -3984,6 +4002,11 @@ static int inet6_dump_ifinfo(struct sk_b
25652 struct inet6_dev *idev;
25653 struct hlist_head *head;
25654 struct hlist_node *node;
25655 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25657 + /* FIXME: maybe disable ipv6 on non v6 guests?
25658 + if (skb->sk && skb->sk->sk_vx_info)
25659 + return skb->len; */
25662 s_idx = cb->args[1];
25663 @@ -3995,6 +4018,8 @@ static int inet6_dump_ifinfo(struct sk_b
25664 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25667 + if (!v6_dev_in_nx_info(dev, nxi))
25669 idev = __in6_dev_get(dev);
25672 diff -NurpP --minimal linux-3.0.25/net/ipv6/af_inet6.c linux-3.0.25-vs2.3.2.3/net/ipv6/af_inet6.c
25673 --- linux-3.0.25/net/ipv6/af_inet6.c 2012-03-19 21:16:57.000000000 +0100
25674 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/af_inet6.c 2011-08-29 03:45:10.000000000 +0200
25676 #include <linux/netdevice.h>
25677 #include <linux/icmpv6.h>
25678 #include <linux/netfilter_ipv6.h>
25679 +#include <linux/vs_inet.h>
25680 +#include <linux/vs_inet6.h>
25682 #include <net/ip.h>
25683 #include <net/ipv6.h>
25684 @@ -160,9 +162,12 @@ lookup_protocol:
25688 + if ((protocol == IPPROTO_ICMPV6) &&
25689 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25691 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25692 goto out_rcu_unlock;
25695 sock->ops = answer->ops;
25696 answer_prot = answer->prot;
25697 answer_no_check = answer->no_check;
25698 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25699 struct inet_sock *inet = inet_sk(sk);
25700 struct ipv6_pinfo *np = inet6_sk(sk);
25701 struct net *net = sock_net(sk);
25702 + struct nx_v6_sock_addr nsa;
25704 unsigned short snum;
25706 @@ -276,6 +282,10 @@ int inet6_bind(struct socket *sock, stru
25707 if (addr->sin6_family != AF_INET6)
25708 return -EAFNOSUPPORT;
25710 + err = v6_map_sock_addr(inet, addr, &nsa);
25714 addr_type = ipv6_addr_type(&addr->sin6_addr);
25715 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25717 @@ -307,6 +317,7 @@ int inet6_bind(struct socket *sock, stru
25718 /* Reproduce AF_INET checks to make the bindings consistent */
25719 v4addr = addr->sin6_addr.s6_addr32[3];
25720 chk_addr_ret = inet_addr_type(net, v4addr);
25722 if (!sysctl_ip_nonlocal_bind &&
25723 !(inet->freebind || inet->transparent) &&
25724 v4addr != htonl(INADDR_ANY) &&
25725 @@ -316,6 +327,10 @@ int inet6_bind(struct socket *sock, stru
25726 err = -EADDRNOTAVAIL;
25729 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25730 + err = -EADDRNOTAVAIL;
25734 if (addr_type != IPV6_ADDR_ANY) {
25735 struct net_device *dev = NULL;
25736 @@ -342,6 +357,11 @@ int inet6_bind(struct socket *sock, stru
25740 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25741 + err = -EADDRNOTAVAIL;
25745 /* ipv4 addr of the socket is invalid. Only the
25746 * unspecified and mapped address have a v4 equivalent.
25748 @@ -358,6 +378,9 @@ int inet6_bind(struct socket *sock, stru
25752 + /* what's that for? */
25753 + v6_set_sock_addr(inet, &nsa);
25755 inet->inet_rcv_saddr = v4addr;
25756 inet->inet_saddr = v4addr;
25758 @@ -459,9 +482,11 @@ int inet6_getname(struct socket *sock, s
25760 sin->sin6_port = inet->inet_dport;
25761 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25762 + /* FIXME: remap lback? */
25764 sin->sin6_flowinfo = np->flow_label;
25766 + /* FIXME: remap lback? */
25767 if (ipv6_addr_any(&np->rcv_saddr))
25768 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25770 diff -NurpP --minimal linux-3.0.25/net/ipv6/datagram.c linux-3.0.25-vs2.3.2.3/net/ipv6/datagram.c
25771 --- linux-3.0.25/net/ipv6/datagram.c 2011-05-22 16:18:00.000000000 +0200
25772 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/datagram.c 2011-09-17 19:24:15.000000000 +0200
25773 @@ -639,7 +639,7 @@ int datagram_send_ctl(struct net *net,
25776 if (fl6->flowi6_oif) {
25777 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25778 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25782 diff -NurpP --minimal linux-3.0.25/net/ipv6/fib6_rules.c linux-3.0.25-vs2.3.2.3/net/ipv6/fib6_rules.c
25783 --- linux-3.0.25/net/ipv6/fib6_rules.c 2011-05-22 16:18:00.000000000 +0200
25784 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/fib6_rules.c 2011-06-10 22:11:24.000000000 +0200
25785 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
25786 ip6_dst_idev(&rt->dst)->dev,
25788 rt6_flags2srcprefs(flags),
25792 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25794 diff -NurpP --minimal linux-3.0.25/net/ipv6/inet6_hashtables.c linux-3.0.25-vs2.3.2.3/net/ipv6/inet6_hashtables.c
25795 --- linux-3.0.25/net/ipv6/inet6_hashtables.c 2012-03-19 21:16:57.000000000 +0100
25796 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/inet6_hashtables.c 2011-08-29 03:45:10.000000000 +0200
25799 #include <linux/module.h>
25800 #include <linux/random.h>
25801 +#include <linux/vs_inet6.h>
25803 #include <net/inet_connection_sock.h>
25804 #include <net/inet_hashtables.h>
25805 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25806 unsigned int slot = hash & hashinfo->ehash_mask;
25807 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25812 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25813 @@ -95,7 +95,7 @@ begin:
25821 if (get_nulls_value(node) != slot)
25822 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
25823 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25827 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25830 if (sk->sk_bound_dev_if) {
25831 if (sk->sk_bound_dev_if != dif)
25832 diff -NurpP --minimal linux-3.0.25/net/ipv6/ip6_output.c linux-3.0.25-vs2.3.2.3/net/ipv6/ip6_output.c
25833 --- linux-3.0.25/net/ipv6/ip6_output.c 2012-03-19 21:16:57.000000000 +0100
25834 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/ip6_output.c 2012-02-15 05:20:43.000000000 +0100
25835 @@ -979,7 +979,8 @@ static int ip6_dst_lookup_tail(struct so
25836 struct rt6_info *rt = (struct rt6_info *) *dst;
25837 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25838 sk ? inet6_sk(sk)->srcprefs : 0,
25841 + sk ? sk->sk_nx_info : NULL);
25843 goto out_err_release;
25845 diff -NurpP --minimal linux-3.0.25/net/ipv6/ndisc.c linux-3.0.25-vs2.3.2.3/net/ipv6/ndisc.c
25846 --- linux-3.0.25/net/ipv6/ndisc.c 2012-03-19 21:16:57.000000000 +0100
25847 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/ndisc.c 2012-02-15 05:20:43.000000000 +0100
25848 @@ -597,7 +597,7 @@ static void ndisc_send_na(struct net_dev
25850 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25851 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25855 src_addr = &tmpaddr;
25857 diff -NurpP --minimal linux-3.0.25/net/ipv6/raw.c linux-3.0.25-vs2.3.2.3/net/ipv6/raw.c
25858 --- linux-3.0.25/net/ipv6/raw.c 2011-07-22 11:18:13.000000000 +0200
25859 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/raw.c 2011-06-10 22:11:24.000000000 +0200
25861 #include <linux/icmpv6.h>
25862 #include <linux/netfilter.h>
25863 #include <linux/netfilter_ipv6.h>
25864 +#include <linux/vs_inet6.h>
25865 #include <linux/skbuff.h>
25866 #include <linux/compat.h>
25867 #include <asm/uaccess.h>
25868 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
25872 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25873 + err = -EADDRNOTAVAIL;
25879 /* ipv4 addr of the socket is invalid. Only the
25880 * unspecified and mapped address have a v4 equivalent.
25882 diff -NurpP --minimal linux-3.0.25/net/ipv6/route.c linux-3.0.25-vs2.3.2.3/net/ipv6/route.c
25883 --- linux-3.0.25/net/ipv6/route.c 2012-03-19 21:16:57.000000000 +0100
25884 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/route.c 2012-02-15 05:20:43.000000000 +0100
25886 #include <net/xfrm.h>
25887 #include <net/netevent.h>
25888 #include <net/netlink.h>
25889 +#include <linux/vs_inet6.h>
25891 #include <asm/uaccess.h>
25893 @@ -2058,15 +2059,17 @@ int ip6_route_get_saddr(struct net *net,
25894 struct rt6_info *rt,
25895 const struct in6_addr *daddr,
25896 unsigned int prefs,
25897 - struct in6_addr *saddr)
25898 + struct in6_addr *saddr,
25899 + struct nx_info *nxi)
25901 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25903 - if (rt->rt6i_prefsrc.plen)
25904 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25905 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25906 ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr);
25908 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25909 - daddr, prefs, saddr);
25910 + daddr, prefs, saddr, nxi);
25914 @@ -2396,7 +2399,8 @@ static int rt6_fill_node(struct net *net
25915 NLA_PUT_U32(skb, RTA_IIF, iif);
25917 struct in6_addr saddr_buf;
25918 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0)
25919 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25920 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25921 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25924 @@ -2599,6 +2603,7 @@ static int rt6_info_route(struct rt6_inf
25925 struct seq_file *m = p_arg;
25926 struct neighbour *n;
25928 + /* FIXME: check for network context? */
25929 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25931 #ifdef CONFIG_IPV6_SUBTREES
25932 diff -NurpP --minimal linux-3.0.25/net/ipv6/tcp_ipv6.c linux-3.0.25-vs2.3.2.3/net/ipv6/tcp_ipv6.c
25933 --- linux-3.0.25/net/ipv6/tcp_ipv6.c 2012-03-19 21:16:57.000000000 +0100
25934 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/tcp_ipv6.c 2012-02-07 02:05:58.000000000 +0100
25937 #include <linux/crypto.h>
25938 #include <linux/scatterlist.h>
25939 +#include <linux/vs_inet6.h>
25941 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25942 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25943 @@ -162,8 +163,15 @@ static int tcp_v6_connect(struct sock *s
25944 * connect() to INADDR_ANY means loopback (BSD'ism).
25947 - if(ipv6_addr_any(&usin->sin6_addr))
25948 - usin->sin6_addr.s6_addr[15] = 0x1;
25949 + if(ipv6_addr_any(&usin->sin6_addr)) {
25950 + struct nx_info *nxi = sk->sk_nx_info;
25952 + if (nxi && nx_info_has_v6(nxi))
25953 + /* FIXME: remap lback? */
25954 + usin->sin6_addr = nxi->v6.ip;
25956 + usin->sin6_addr.s6_addr[15] = 0x1;
25959 addr_type = ipv6_addr_type(&usin->sin6_addr);
25961 diff -NurpP --minimal linux-3.0.25/net/ipv6/udp.c linux-3.0.25-vs2.3.2.3/net/ipv6/udp.c
25962 --- linux-3.0.25/net/ipv6/udp.c 2012-03-19 21:16:57.000000000 +0100
25963 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/udp.c 2011-10-18 13:51:13.000000000 +0200
25964 @@ -45,41 +45,67 @@
25965 #include <net/tcp_states.h>
25966 #include <net/ip6_checksum.h>
25967 #include <net/xfrm.h>
25968 +#include <linux/vs_inet6.h>
25970 #include <linux/proc_fs.h>
25971 #include <linux/seq_file.h>
25972 #include "udp_impl.h"
25974 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25975 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25977 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25978 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25979 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25980 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25981 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25982 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25983 - int sk_ipv6only = ipv6_only_sock(sk);
25984 + int sk1_ipv6only = ipv6_only_sock(sk1);
25985 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25986 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25987 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25988 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25990 /* if both are mapped, treat as IPv4 */
25991 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25992 - return (!sk2_ipv6only &&
25993 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25994 + if (!sk2_ipv6only &&
25995 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25996 - sk1_rcv_saddr == sk2_rcv_saddr));
25997 + sk1_rcv_saddr == sk2_rcv_saddr))
26003 if (addr_type2 == IPV6_ADDR_ANY &&
26004 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
26008 if (addr_type == IPV6_ADDR_ANY &&
26009 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26011 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26014 if (sk2_rcv_saddr6 &&
26015 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
26017 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
26023 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
26024 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26025 + if (!sk2_rcv_saddr)
26026 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
26027 + if (!sk1_rcv_saddr)
26028 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
26031 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
26032 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26033 + else if (addr_type2 == IPV6_ADDR_ANY)
26034 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
26035 + else if (addr_type == IPV6_ADDR_ANY) {
26036 + if (addr_type2 == IPV6_ADDR_MAPPED)
26037 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26039 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
26044 static unsigned int udp6_portaddr_hash(struct net *net,
26045 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
26046 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
26050 + /* block non nx_info ips */
26051 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26054 if (!ipv6_addr_any(&np->daddr)) {
26055 if (!ipv6_addr_equal(&np->daddr, saddr))
26056 diff -NurpP --minimal linux-3.0.25/net/ipv6/xfrm6_policy.c linux-3.0.25-vs2.3.2.3/net/ipv6/xfrm6_policy.c
26057 --- linux-3.0.25/net/ipv6/xfrm6_policy.c 2011-07-22 11:18:13.000000000 +0200
26058 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/xfrm6_policy.c 2011-06-10 22:11:24.000000000 +0200
26059 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
26060 dev = ip6_dst_idev(dst)->dev;
26061 ipv6_dev_get_saddr(dev_net(dev), dev,
26062 (struct in6_addr *)&daddr->a6, 0,
26063 - (struct in6_addr *)&saddr->a6);
26064 + (struct in6_addr *)&saddr->a6, NULL);
26068 diff -NurpP --minimal linux-3.0.25/net/netfilter/ipvs/ip_vs_xmit.c linux-3.0.25-vs2.3.2.3/net/netfilter/ipvs/ip_vs_xmit.c
26069 --- linux-3.0.25/net/netfilter/ipvs/ip_vs_xmit.c 2011-07-22 11:18:13.000000000 +0200
26070 +++ linux-3.0.25-vs2.3.2.3/net/netfilter/ipvs/ip_vs_xmit.c 2011-07-22 15:27:52.000000000 +0200
26071 @@ -226,7 +226,7 @@ __ip_vs_route_output_v6(struct net *net,
26073 if (ipv6_addr_any(&fl6.saddr) &&
26074 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
26075 - &fl6.daddr, 0, &fl6.saddr) < 0)
26076 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
26079 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
26080 diff -NurpP --minimal linux-3.0.25/net/netlink/af_netlink.c linux-3.0.25-vs2.3.2.3/net/netlink/af_netlink.c
26081 --- linux-3.0.25/net/netlink/af_netlink.c 2011-07-22 11:18:13.000000000 +0200
26082 +++ linux-3.0.25-vs2.3.2.3/net/netlink/af_netlink.c 2011-06-10 22:11:24.000000000 +0200
26084 #include <linux/types.h>
26085 #include <linux/audit.h>
26086 #include <linux/mutex.h>
26087 +#include <linux/vs_context.h>
26088 +#include <linux/vs_network.h>
26089 +#include <linux/vs_limit.h>
26091 #include <net/net_namespace.h>
26092 #include <net/sock.h>
26093 @@ -1907,6 +1910,8 @@ static struct sock *netlink_seq_socket_i
26094 sk_for_each(s, node, &hash->table[j]) {
26095 if (sock_net(s) != seq_file_net(seq))
26097 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26101 iter->hash_idx = j;
26102 @@ -1941,7 +1946,8 @@ static void *netlink_seq_next(struct seq
26106 - } while (s && sock_net(s) != seq_file_net(seq));
26107 + } while (s && (sock_net(s) != seq_file_net(seq) ||
26108 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
26112 @@ -1953,7 +1959,8 @@ static void *netlink_seq_next(struct seq
26114 for (; j <= hash->mask; j++) {
26115 s = sk_head(&hash->table[j]);
26116 - while (s && sock_net(s) != seq_file_net(seq))
26117 + while (s && (sock_net(s) != seq_file_net(seq) ||
26118 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
26122 diff -NurpP --minimal linux-3.0.25/net/socket.c linux-3.0.25-vs2.3.2.3/net/socket.c
26123 --- linux-3.0.25/net/socket.c 2012-03-19 21:16:58.000000000 +0100
26124 +++ linux-3.0.25-vs2.3.2.3/net/socket.c 2011-10-18 13:51:13.000000000 +0200
26127 #include <net/sock.h>
26128 #include <linux/netfilter.h>
26129 +#include <linux/vs_base.h>
26130 +#include <linux/vs_socket.h>
26131 +#include <linux/vs_inet.h>
26132 +#include <linux/vs_inet6.h>
26134 #include <linux/if_tun.h>
26135 #include <linux/ipv6_route.h>
26136 @@ -546,6 +550,7 @@ static inline int __sock_sendmsg_nosec(s
26137 struct msghdr *msg, size_t size)
26139 struct sock_iocb *si = kiocb_to_siocb(iocb);
26142 sock_update_classid(sock->sk);
26144 @@ -554,7 +559,22 @@ static inline int __sock_sendmsg_nosec(s
26148 - return sock->ops->sendmsg(iocb, sock, msg, size);
26149 + len = sock->ops->sendmsg(iocb, sock, msg, size);
26152 + vx_sock_send(sock->sk, size);
26154 + vx_sock_fail(sock->sk, size);
26156 + vxdprintk(VXD_CBIT(net, 7),
26157 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
26159 + (sock->sk)?sock->sk->sk_nx_info:0,
26160 + (sock->sk)?sock->sk->sk_vx_info:0,
26161 + (sock->sk)?sock->sk->sk_xid:0,
26162 + (sock->sk)?sock->sk->sk_nid:0,
26163 + (unsigned int)size, len);
26167 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
26168 @@ -694,6 +714,7 @@ static inline int __sock_recvmsg_nosec(s
26169 struct msghdr *msg, size_t size, int flags)
26171 struct sock_iocb *si = kiocb_to_siocb(iocb);
26174 sock_update_classid(sock->sk);
26176 @@ -703,7 +724,18 @@ static inline int __sock_recvmsg_nosec(s
26180 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
26181 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
26182 + if ((len >= 0) && sock->sk)
26183 + vx_sock_recv(sock->sk, len);
26184 + vxdprintk(VXD_CBIT(net, 7),
26185 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26187 + (sock->sk)?sock->sk->sk_nx_info:0,
26188 + (sock->sk)?sock->sk->sk_vx_info:0,
26189 + (sock->sk)?sock->sk->sk_xid:0,
26190 + (sock->sk)?sock->sk->sk_nid:0,
26191 + (unsigned int)size, len);
26195 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
26196 @@ -1188,6 +1220,13 @@ int __sock_create(struct net *net, int f
26197 if (type < 0 || type >= SOCK_MAX)
26200 + if (!nx_check(0, VS_ADMIN)) {
26201 + if (family == PF_INET && !current_nx_info_has_v4())
26202 + return -EAFNOSUPPORT;
26203 + if (family == PF_INET6 && !current_nx_info_has_v6())
26204 + return -EAFNOSUPPORT;
26209 This uglymoron is moved from INET layer to here to avoid
26210 @@ -1323,6 +1362,7 @@ SYSCALL_DEFINE3(socket, int, family, int
26214 + set_bit(SOCK_USER_SOCKET, &sock->flags);
26215 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
26218 @@ -1364,10 +1404,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
26219 err = sock_create(family, type, protocol, &sock1);
26222 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
26224 err = sock_create(family, type, protocol, &sock2);
26226 goto out_release_1;
26227 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
26229 err = sock1->ops->socketpair(sock1, sock2);
26231 diff -NurpP --minimal linux-3.0.25/net/sunrpc/auth.c linux-3.0.25-vs2.3.2.3/net/sunrpc/auth.c
26232 --- linux-3.0.25/net/sunrpc/auth.c 2011-07-22 11:18:13.000000000 +0200
26233 +++ linux-3.0.25-vs2.3.2.3/net/sunrpc/auth.c 2011-06-10 22:11:24.000000000 +0200
26235 #include <linux/hash.h>
26236 #include <linux/sunrpc/clnt.h>
26237 #include <linux/spinlock.h>
26238 +#include <linux/vs_tag.h>
26241 # define RPCDBG_FACILITY RPCDBG_AUTH
26242 @@ -427,6 +428,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
26243 memset(&acred, 0, sizeof(acred));
26244 acred.uid = cred->fsuid;
26245 acred.gid = cred->fsgid;
26246 + acred.tag = dx_current_tag();
26247 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
26249 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
26250 @@ -467,6 +469,7 @@ rpcauth_bind_root_cred(struct rpc_task *
26251 struct auth_cred acred = {
26254 + .tag = dx_current_tag(),
26257 dprintk("RPC: %5u looking up %s cred\n",
26258 diff -NurpP --minimal linux-3.0.25/net/sunrpc/auth_unix.c linux-3.0.25-vs2.3.2.3/net/sunrpc/auth_unix.c
26259 --- linux-3.0.25/net/sunrpc/auth_unix.c 2012-03-19 21:16:58.000000000 +0100
26260 +++ linux-3.0.25-vs2.3.2.3/net/sunrpc/auth_unix.c 2011-11-15 17:37:07.000000000 +0100
26261 @@ -12,12 +12,14 @@
26262 #include <linux/module.h>
26263 #include <linux/sunrpc/clnt.h>
26264 #include <linux/sunrpc/auth.h>
26265 +#include <linux/vs_tag.h>
26267 #define NFS_NGROUPS 16
26270 struct rpc_cred uc_base;
26273 gid_t uc_gids[NFS_NGROUPS];
26275 #define uc_uid uc_base.cr_uid
26276 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
26277 groups = NFS_NGROUPS;
26279 cred->uc_gid = acred->gid;
26280 + cred->uc_tag = acred->tag;
26281 for (i = 0; i < groups; i++)
26282 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
26283 if (i < NFS_NGROUPS)
26284 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
26288 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
26289 + if (cred->uc_uid != acred->uid ||
26290 + cred->uc_gid != acred->gid ||
26291 + cred->uc_tag != acred->tag)
26294 if (acred->group_info != NULL)
26295 @@ -145,7 +150,7 @@ unx_marshal(struct rpc_task *task, __be3
26296 struct rpc_clnt *clnt = task->tk_client;
26297 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
26298 __be32 *base, *hold;
26302 *p++ = htonl(RPC_AUTH_UNIX);
26304 @@ -155,9 +160,12 @@ unx_marshal(struct rpc_task *task, __be3
26305 * Copy the UTS nodename captured when the client was created.
26307 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
26308 + tag = task->tk_client->cl_tag;
26310 - *p++ = htonl((u32) cred->uc_uid);
26311 - *p++ = htonl((u32) cred->uc_gid);
26312 + *p++ = htonl((u32) TAGINO_UID(tag,
26313 + cred->uc_uid, cred->uc_tag));
26314 + *p++ = htonl((u32) TAGINO_GID(tag,
26315 + cred->uc_gid, cred->uc_tag));
26317 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
26318 *p++ = htonl((u32) cred->uc_gids[i]);
26319 diff -NurpP --minimal linux-3.0.25/net/sunrpc/clnt.c linux-3.0.25-vs2.3.2.3/net/sunrpc/clnt.c
26320 --- linux-3.0.25/net/sunrpc/clnt.c 2011-07-22 11:18:13.000000000 +0200
26321 +++ linux-3.0.25-vs2.3.2.3/net/sunrpc/clnt.c 2011-07-01 11:35:35.000000000 +0200
26323 #include <linux/in.h>
26324 #include <linux/in6.h>
26325 #include <linux/un.h>
26326 +#include <linux/vs_cvirt.h>
26328 #include <linux/sunrpc/clnt.h>
26329 #include <linux/sunrpc/rpc_pipe_fs.h>
26330 @@ -362,6 +363,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
26331 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
26332 clnt->cl_chatty = 1;
26334 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
26335 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
26336 + clnt->cl_tag = 1; */
26339 EXPORT_SYMBOL_GPL(rpc_create);
26340 diff -NurpP --minimal linux-3.0.25/net/unix/af_unix.c linux-3.0.25-vs2.3.2.3/net/unix/af_unix.c
26341 --- linux-3.0.25/net/unix/af_unix.c 2011-07-22 11:18:13.000000000 +0200
26342 +++ linux-3.0.25-vs2.3.2.3/net/unix/af_unix.c 2011-06-10 22:11:24.000000000 +0200
26343 @@ -114,6 +114,8 @@
26344 #include <linux/mount.h>
26345 #include <net/checksum.h>
26346 #include <linux/security.h>
26347 +#include <linux/vs_context.h>
26348 +#include <linux/vs_limit.h>
26350 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
26351 static DEFINE_SPINLOCK(unix_table_lock);
26352 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
26353 if (!net_eq(sock_net(s), net))
26356 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26358 if (u->addr->len == len &&
26359 !memcmp(u->addr->name, sunname, len))
26361 @@ -2208,6 +2212,8 @@ static struct sock *unix_seq_idx(struct
26362 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
26363 if (sock_net(s) != seq_file_net(seq))
26365 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26370 @@ -2232,7 +2238,8 @@ static void *unix_seq_next(struct seq_fi
26371 sk = first_unix_socket(&iter->i);
26373 sk = next_unix_socket(&iter->i, sk);
26374 - while (sk && (sock_net(sk) != seq_file_net(seq)))
26375 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
26376 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
26377 sk = next_unix_socket(&iter->i, sk);
26380 diff -NurpP --minimal linux-3.0.25/scripts/checksyscalls.sh linux-3.0.25-vs2.3.2.3/scripts/checksyscalls.sh
26381 --- linux-3.0.25/scripts/checksyscalls.sh 2011-03-15 18:07:46.000000000 +0100
26382 +++ linux-3.0.25-vs2.3.2.3/scripts/checksyscalls.sh 2011-06-10 22:11:24.000000000 +0200
26383 @@ -193,7 +193,6 @@ cat << EOF
26384 #define __IGNORE_afs_syscall
26385 #define __IGNORE_getpmsg
26386 #define __IGNORE_putpmsg
26387 -#define __IGNORE_vserver
26391 diff -NurpP --minimal linux-3.0.25/security/commoncap.c linux-3.0.25-vs2.3.2.3/security/commoncap.c
26392 --- linux-3.0.25/security/commoncap.c 2011-07-22 11:18:14.000000000 +0200
26393 +++ linux-3.0.25-vs2.3.2.3/security/commoncap.c 2011-08-30 15:42:43.000000000 +0200
26394 @@ -62,6 +62,7 @@ int cap_netlink_recv(struct sk_buff *skb
26399 EXPORT_SYMBOL(cap_netlink_recv);
26402 @@ -83,14 +84,20 @@ EXPORT_SYMBOL(cap_netlink_recv);
26403 int cap_capable(struct task_struct *tsk, const struct cred *cred,
26404 struct user_namespace *targ_ns, int cap, int audit)
26406 + struct vx_info *vxi = tsk->vx_info;
26409 /* The creator of the user namespace has all caps. */
26410 if (targ_ns != &init_user_ns && targ_ns->creator == cred->user)
26413 /* Do we have the necessary capabilities? */
26414 - if (targ_ns == cred->user->user_ns)
26415 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26416 + if (targ_ns == cred->user->user_ns) {
26417 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26418 + cap_raised(cred->cap_effective, cap))
26420 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26423 /* Have we tried all of the parent namespaces? */
26424 if (targ_ns == &init_user_ns)
26425 @@ -611,7 +618,7 @@ int cap_inode_setxattr(struct dentry *de
26427 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26428 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26429 - !capable(CAP_SYS_ADMIN))
26430 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26434 @@ -637,7 +644,7 @@ int cap_inode_removexattr(struct dentry
26436 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26437 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26438 - !capable(CAP_SYS_ADMIN))
26439 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26443 diff -NurpP --minimal linux-3.0.25/security/selinux/hooks.c linux-3.0.25-vs2.3.2.3/security/selinux/hooks.c
26444 --- linux-3.0.25/security/selinux/hooks.c 2011-07-22 11:18:14.000000000 +0200
26445 +++ linux-3.0.25-vs2.3.2.3/security/selinux/hooks.c 2011-06-15 02:40:14.000000000 +0200
26447 #include <linux/dccp.h>
26448 #include <linux/quota.h>
26449 #include <linux/un.h> /* for Unix socket types */
26450 -#include <net/af_unix.h> /* for Unix socket types */
26451 #include <linux/parser.h>
26452 #include <linux/nfs_mount.h>
26453 #include <net/ipv6.h>