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 --- linux-3.0.50/kernel/exit.c~ 2012-11-03 12:37:12.001220335 +0200
14644 +++ linux-3.0.50/kernel/exit.c 2012-11-03 12:44:28.779379101 +0200
14646 #include <linux/fs_struct.h>
14647 #include <linux/init_task.h>
14648 #include <linux/perf_event.h>
14649 +#include <linux/vs_limit.h>
14650 +#include <linux/vs_context.h>
14651 +#include <linux/vs_network.h>
14652 +#include <linux/vs_pid.h>
14653 #include <trace/events/sched.h>
14654 #include <linux/hw_breakpoint.h>
14655 #include <linux/oom.h>
14656 @@ -494,9 +498,11 @@ static void close_files(struct files_str
14657 filp_close(file, files);
14660 + vx_openfd_dec(i);
14668 @@ -1053,6 +1053,10 @@
14670 validate_creds_for_do_exit(tsk);
14672 + /* needs to stay after exit_notify() */
14673 + exit_vx_info(tsk, code);
14674 + exit_nx_info(tsk);
14679 @@ -1074,6 +1078,7 @@
14680 /* causes final put_task_struct in finish_task_switch(). */
14681 tsk->state = TASK_DEAD;
14683 + printk("bad task: %p [%lx]\n", current, current->state);
14685 /* Avoid "noreturn function does return". */
14687 diff -NurpP --minimal linux-3.0.25/kernel/fork.c linux-3.0.25-vs2.3.2.3/kernel/fork.c
14688 --- linux-3.0.25/kernel/fork.c 2012-03-19 21:16:56.000000000 +0100
14689 +++ linux-3.0.25-vs2.3.2.3/kernel/fork.c 2012-03-01 21:52:38.000000000 +0100
14691 #include <linux/oom.h>
14692 #include <linux/khugepaged.h>
14693 #include <linux/signalfd.h>
14694 +#include <linux/vs_context.h>
14695 +#include <linux/vs_network.h>
14696 +#include <linux/vs_limit.h>
14697 +#include <linux/vs_memory.h>
14699 #include <asm/pgtable.h>
14700 #include <asm/pgalloc.h>
14701 @@ -168,6 +172,8 @@ void free_task(struct task_struct *tsk)
14702 account_kernel_stack(tsk->stack, -1);
14703 free_thread_info(tsk->stack);
14704 rt_mutex_debug_task_free(tsk);
14705 + clr_vx_info(&tsk->vx_info);
14706 + clr_nx_info(&tsk->nx_info);
14707 ftrace_graph_exit_task(tsk);
14708 free_task_struct(tsk);
14710 @@ -506,6 +512,7 @@ static struct mm_struct * mm_init(struct
14711 if (likely(!mm_alloc_pgd(mm))) {
14713 mmu_notifier_mm_init(mm);
14714 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14718 @@ -543,6 +550,7 @@ void __mmdrop(struct mm_struct *mm)
14719 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14720 VM_BUG_ON(mm->pmd_huge_pte);
14722 + clr_vx_info(&mm->mm_vx_info);
14725 EXPORT_SYMBOL_GPL(__mmdrop);
14726 @@ -730,6 +738,7 @@ struct mm_struct *dup_mm(struct task_str
14729 memcpy(mm, oldmm, sizeof(*mm));
14730 + mm->mm_vx_info = NULL;
14731 mm_init_cpumask(mm);
14733 /* Initializing for Swap token stuff */
14734 @@ -773,6 +782,7 @@ fail_nocontext:
14735 * If init_new_context() failed, we cannot use mmput() to free the mm
14736 * because it calls destroy_context()
14738 + clr_vx_info(&mm->mm_vx_info);
14742 @@ -1060,6 +1070,8 @@ static struct task_struct *copy_process(
14744 struct task_struct *p;
14745 int cgroup_callbacks_done = 0;
14746 + struct vx_info *vxi;
14747 + struct nx_info *nxi;
14749 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14750 return ERR_PTR(-EINVAL);
14751 @@ -1106,7 +1118,12 @@ static struct task_struct *copy_process(
14752 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14753 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14755 + init_vx_info(&p->vx_info, current_vx_info());
14756 + init_nx_info(&p->nx_info, current_nx_info());
14759 + if (!vx_nproc_avail(1))
14760 + goto bad_fork_free;
14761 if (atomic_read(&p->real_cred->user->processes) >=
14762 task_rlimit(p, RLIMIT_NPROC)) {
14763 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14764 @@ -1363,6 +1380,18 @@ static struct task_struct *copy_process(
14767 spin_unlock(¤t->sighand->siglock);
14769 + /* p is copy of current */
14770 + vxi = p->vx_info;
14772 + claim_vx_info(vxi, p);
14773 + atomic_inc(&vxi->cvirt.nr_threads);
14774 + atomic_inc(&vxi->cvirt.total_forks);
14777 + nxi = p->nx_info;
14779 + claim_nx_info(nxi, p);
14780 write_unlock_irq(&tasklist_lock);
14781 proc_fork_connector(p);
14782 cgroup_post_fork(p);
14783 diff -NurpP --minimal linux-3.0.25/kernel/kthread.c linux-3.0.25-vs2.3.2.3/kernel/kthread.c
14784 --- linux-3.0.25/kernel/kthread.c 2011-07-22 11:18:12.000000000 +0200
14785 +++ linux-3.0.25-vs2.3.2.3/kernel/kthread.c 2011-06-10 22:11:24.000000000 +0200
14787 #include <linux/mutex.h>
14788 #include <linux/slab.h>
14789 #include <linux/freezer.h>
14790 +#include <linux/vs_pid.h>
14791 #include <trace/events/sched.h>
14793 static DEFINE_SPINLOCK(kthread_create_lock);
14794 diff -NurpP --minimal linux-3.0.25/kernel/nsproxy.c linux-3.0.25-vs2.3.2.3/kernel/nsproxy.c
14795 --- linux-3.0.25/kernel/nsproxy.c 2011-07-22 11:18:12.000000000 +0200
14796 +++ linux-3.0.25-vs2.3.2.3/kernel/nsproxy.c 2011-06-13 14:09:44.000000000 +0200
14798 #include <linux/mnt_namespace.h>
14799 #include <linux/utsname.h>
14800 #include <linux/pid_namespace.h>
14801 +#include <linux/vserver/global.h>
14802 +#include <linux/vserver/debug.h>
14803 #include <net/net_namespace.h>
14804 #include <linux/ipc_namespace.h>
14805 #include <linux/proc_fs.h>
14806 @@ -46,8 +48,11 @@ static inline struct nsproxy *create_nsp
14807 struct nsproxy *nsproxy;
14809 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14812 atomic_set(&nsproxy->count, 1);
14813 + atomic_inc(&vs_global_nsproxy);
14815 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14819 @@ -56,8 +61,11 @@ static inline struct nsproxy *create_nsp
14820 * Return the newly created nsproxy. Do not attach this to the task,
14821 * leave it to the caller to do proper locking and attach it to task.
14823 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14824 - struct task_struct *tsk, struct fs_struct *new_fs)
14825 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14826 + struct nsproxy *orig,
14827 + struct fs_struct *new_fs,
14828 + struct user_namespace *new_user,
14829 + struct pid_namespace *new_pid)
14831 struct nsproxy *new_nsp;
14833 @@ -66,31 +74,31 @@ static struct nsproxy *create_new_namesp
14835 return ERR_PTR(-ENOMEM);
14837 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
14838 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
14839 if (IS_ERR(new_nsp->mnt_ns)) {
14840 err = PTR_ERR(new_nsp->mnt_ns);
14844 - new_nsp->uts_ns = copy_utsname(flags, tsk);
14845 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
14846 if (IS_ERR(new_nsp->uts_ns)) {
14847 err = PTR_ERR(new_nsp->uts_ns);
14851 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
14852 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
14853 if (IS_ERR(new_nsp->ipc_ns)) {
14854 err = PTR_ERR(new_nsp->ipc_ns);
14858 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
14859 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
14860 if (IS_ERR(new_nsp->pid_ns)) {
14861 err = PTR_ERR(new_nsp->pid_ns);
14865 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
14866 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
14867 if (IS_ERR(new_nsp->net_ns)) {
14868 err = PTR_ERR(new_nsp->net_ns);
14870 @@ -115,6 +123,40 @@ out_ns:
14871 return ERR_PTR(err);
14874 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14875 + struct task_struct *tsk, struct fs_struct *new_fs)
14877 + return unshare_namespaces(flags, tsk->nsproxy,
14878 + new_fs, task_cred_xxx(tsk, user)->user_ns,
14879 + task_active_pid_ns(tsk));
14883 + * copies the nsproxy, setting refcount to 1, and grabbing a
14884 + * reference to all contained namespaces.
14886 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14888 + struct nsproxy *ns = create_nsproxy();
14891 + memcpy(ns, orig, sizeof(struct nsproxy));
14892 + atomic_set(&ns->count, 1);
14895 + get_mnt_ns(ns->mnt_ns);
14897 + get_uts_ns(ns->uts_ns);
14899 + get_ipc_ns(ns->ipc_ns);
14901 + get_pid_ns(ns->pid_ns);
14903 + get_net(ns->net_ns);
14909 * called from clone. This now handles copy for nsproxy and all
14910 * namespaces therein.
14911 @@ -122,9 +164,12 @@ out_ns:
14912 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
14914 struct nsproxy *old_ns = tsk->nsproxy;
14915 - struct nsproxy *new_ns;
14916 + struct nsproxy *new_ns = NULL;
14919 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14920 + flags, tsk, old_ns);
14925 @@ -134,7 +179,7 @@ int copy_namespaces(unsigned long flags,
14926 CLONE_NEWPID | CLONE_NEWNET)))
14929 - if (!capable(CAP_SYS_ADMIN)) {
14930 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
14934 @@ -161,6 +206,9 @@ int copy_namespaces(unsigned long flags,
14937 put_nsproxy(old_ns);
14938 + vxdprintk(VXD_CBIT(space, 3),
14939 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14940 + flags, tsk, old_ns, err, new_ns);
14944 @@ -174,7 +222,9 @@ void free_nsproxy(struct nsproxy *ns)
14945 put_ipc_ns(ns->ipc_ns);
14947 put_pid_ns(ns->pid_ns);
14948 - put_net(ns->net_ns);
14950 + put_net(ns->net_ns);
14951 + atomic_dec(&vs_global_nsproxy);
14952 kmem_cache_free(nsproxy_cachep, ns);
14955 @@ -187,11 +237,15 @@ int unshare_nsproxy_namespaces(unsigned
14959 + vxdprintk(VXD_CBIT(space, 4),
14960 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14961 + unshare_flags, current->nsproxy);
14963 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14967 - if (!capable(CAP_SYS_ADMIN))
14968 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
14971 *new_nsp = create_new_namespaces(unshare_flags, current,
14972 diff -NurpP --minimal linux-3.0.25/kernel/pid.c linux-3.0.25-vs2.3.2.3/kernel/pid.c
14973 --- linux-3.0.25/kernel/pid.c 2011-05-22 16:17:59.000000000 +0200
14974 +++ linux-3.0.25-vs2.3.2.3/kernel/pid.c 2011-06-10 22:11:24.000000000 +0200
14976 #include <linux/pid_namespace.h>
14977 #include <linux/init_task.h>
14978 #include <linux/syscalls.h>
14979 +#include <linux/vs_pid.h>
14981 #define pid_hashfn(nr, ns) \
14982 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14983 @@ -342,7 +343,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14985 struct pid *find_vpid(int nr)
14987 - return find_pid_ns(nr, current->nsproxy->pid_ns);
14988 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
14990 EXPORT_SYMBOL_GPL(find_vpid);
14992 @@ -402,6 +403,9 @@ void transfer_pid(struct task_struct *ol
14993 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14995 struct task_struct *result = NULL;
14997 + if (type == PIDTYPE_REALPID)
14998 + type = PIDTYPE_PID;
15000 struct hlist_node *first;
15001 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
15002 @@ -420,7 +424,7 @@ EXPORT_SYMBOL(pid_task);
15003 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
15005 rcu_lockdep_assert(rcu_read_lock_held());
15006 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
15007 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
15010 struct task_struct *find_task_by_vpid(pid_t vnr)
15011 @@ -464,7 +468,7 @@ struct pid *find_get_pid(pid_t nr)
15013 EXPORT_SYMBOL_GPL(find_get_pid);
15015 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15016 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15020 @@ -477,6 +481,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15024 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15026 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15029 pid_t pid_vnr(struct pid *pid)
15031 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15032 diff -NurpP --minimal linux-3.0.25/kernel/pid_namespace.c linux-3.0.25-vs2.3.2.3/kernel/pid_namespace.c
15033 --- linux-3.0.25/kernel/pid_namespace.c 2011-05-22 16:17:59.000000000 +0200
15034 +++ linux-3.0.25-vs2.3.2.3/kernel/pid_namespace.c 2011-06-10 22:17:45.000000000 +0200
15036 #include <linux/acct.h>
15037 #include <linux/slab.h>
15038 #include <linux/proc_fs.h>
15039 +#include <linux/vserver/global.h>
15041 #define BITS_PER_PAGE (PAGE_SIZE*8)
15043 @@ -88,6 +89,7 @@ static struct pid_namespace *create_pid_
15046 kref_init(&ns->kref);
15047 + atomic_inc(&vs_global_pid_ns);
15049 ns->parent = get_pid_ns(parent_pid_ns);
15051 @@ -119,6 +121,7 @@ static void destroy_pid_namespace(struct
15053 for (i = 0; i < PIDMAP_ENTRIES; i++)
15054 kfree(ns->pidmap[i].page);
15055 + atomic_dec(&vs_global_pid_ns);
15056 kmem_cache_free(pid_ns_cachep, ns);
15059 diff -NurpP --minimal linux-3.0.25/kernel/posix-timers.c linux-3.0.25-vs2.3.2.3/kernel/posix-timers.c
15060 --- linux-3.0.25/kernel/posix-timers.c 2011-07-22 11:18:12.000000000 +0200
15061 +++ linux-3.0.25-vs2.3.2.3/kernel/posix-timers.c 2011-06-10 22:11:24.000000000 +0200
15063 #include <linux/wait.h>
15064 #include <linux/workqueue.h>
15065 #include <linux/module.h>
15066 +#include <linux/vs_context.h>
15069 * Management arrays for POSIX timers. Timers are kept in slab memory
15070 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
15072 struct task_struct *task;
15073 int shared, ret = -1;
15076 * FIXME: if ->sigq is queued we can race with
15077 * dequeue_signal()->do_schedule_next_timer().
15078 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
15080 task = pid_task(timr->it_pid, PIDTYPE_PID);
15082 + struct vx_info_save vxis;
15083 + struct vx_info *vxi;
15085 + vxi = get_vx_info(task->vx_info);
15086 + enter_vx_info(vxi, &vxis);
15087 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15088 ret = send_sigqueue(timr->sigq, task, shared);
15089 + leave_vx_info(&vxis);
15090 + put_vx_info(vxi);
15094 /* If we failed to send the signal the timer stops. */
15097 diff -NurpP --minimal linux-3.0.25/kernel/printk.c linux-3.0.25-vs2.3.2.3/kernel/printk.c
15098 --- linux-3.0.25/kernel/printk.c 2012-03-19 21:16:56.000000000 +0100
15099 +++ linux-3.0.25-vs2.3.2.3/kernel/printk.c 2012-02-07 02:05:58.000000000 +0100
15101 #include <linux/cpu.h>
15102 #include <linux/notifier.h>
15103 #include <linux/rculist.h>
15104 +#include <linux/vs_cvirt.h>
15106 #include <asm/uaccess.h>
15108 @@ -314,7 +315,7 @@ static int check_syslog_permissions(int
15111 if (syslog_action_restricted(type)) {
15112 - if (capable(CAP_SYSLOG))
15113 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
15115 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
15116 if (capable(CAP_SYS_ADMIN)) {
15117 @@ -344,12 +345,9 @@ int do_syslog(int type, char __user *buf
15122 - case SYSLOG_ACTION_CLOSE: /* Close log */
15124 - case SYSLOG_ACTION_OPEN: /* Open log */
15126 - case SYSLOG_ACTION_READ: /* Read from log */
15127 + if ((type == SYSLOG_ACTION_READ) ||
15128 + (type == SYSLOG_ACTION_READ_ALL) ||
15129 + (type == SYSLOG_ACTION_READ_CLEAR)) {
15131 if (!buf || len < 0)
15133 @@ -360,6 +358,16 @@ int do_syslog(int type, char __user *buf
15138 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15139 + return vx_do_syslog(type, buf, len);
15142 + case SYSLOG_ACTION_CLOSE: /* Close log */
15144 + case SYSLOG_ACTION_OPEN: /* Open log */
15146 + case SYSLOG_ACTION_READ: /* Read from log */
15147 error = wait_event_interruptible(log_wait,
15148 (log_start - log_end));
15150 @@ -386,16 +394,6 @@ int do_syslog(int type, char __user *buf
15152 /* Read last kernel messages */
15153 case SYSLOG_ACTION_READ_ALL:
15155 - if (!buf || len < 0)
15160 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15165 if (count > log_buf_len)
15166 count = log_buf_len;
15167 diff -NurpP --minimal linux-3.0.25/kernel/ptrace.c linux-3.0.25-vs2.3.2.3/kernel/ptrace.c
15168 --- linux-3.0.25/kernel/ptrace.c 2011-07-22 11:18:12.000000000 +0200
15169 +++ linux-3.0.25-vs2.3.2.3/kernel/ptrace.c 2011-11-21 16:29:59.000000000 +0100
15171 #include <linux/syscalls.h>
15172 #include <linux/uaccess.h>
15173 #include <linux/regset.h>
15174 +#include <linux/vs_context.h>
15175 #include <linux/hw_breakpoint.h>
15178 @@ -145,9 +146,15 @@ int __ptrace_may_access(struct task_stru
15179 * or halting the specified task is impossible.
15183 /* Don't let security modules deny introspection */
15184 if (task == current)
15187 + vxdprintk(VXD_CBIT(perm, 8),
15188 + "__ptrace_may_access(%p[#%d,%d,%d], %d)",
15189 + task, task->xid, task->pid, task->tgid, mode);
15192 tcred = __task_cred(task);
15193 if (cred->user->user_ns == tcred->user->user_ns &&
15194 @@ -161,6 +168,8 @@ int __ptrace_may_access(struct task_stru
15195 if (ns_capable(tcred->user->user_ns, CAP_SYS_PTRACE))
15198 + vxdprintk(VXD_CBIT(perm, 8),
15199 + "__ptrace_may_access(%p) cred/cap failed", task);
15203 @@ -169,6 +178,19 @@ ok:
15204 dumpable = get_dumpable(task->mm);
15205 if (!dumpable && !task_ns_capable(task, CAP_SYS_PTRACE))
15207 + vxdprintk(VXD_CBIT(perm, 8),
15208 + "__ptrace_may_access(%p) cap/dump ok", task);
15210 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
15212 + vxdprintk(VXD_CBIT(perm, 8),
15213 + "__ptrace_may_access(%p) check ok", task);
15215 + if (!vx_check(task->xid, VS_IDENT) &&
15216 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15218 + vxdprintk(VXD_CBIT(perm, 8),
15219 + "__ptrace_may_access(%p) admin ok", task);
15221 return security_ptrace_access_check(task, mode);
15223 diff -NurpP --minimal linux-3.0.25/kernel/sched.c linux-3.0.25-vs2.3.2.3/kernel/sched.c
15224 --- linux-3.0.25/kernel/sched.c 2012-03-19 21:16:56.000000000 +0100
15225 +++ linux-3.0.25-vs2.3.2.3/kernel/sched.c 2011-10-18 13:51:13.000000000 +0200
15227 #include <linux/ctype.h>
15228 #include <linux/ftrace.h>
15229 #include <linux/slab.h>
15230 +#include <linux/vs_sched.h>
15231 +#include <linux/vs_cvirt.h>
15233 #include <asm/tlb.h>
15234 #include <asm/irq_regs.h>
15235 @@ -3461,9 +3463,17 @@ static void calc_global_nohz(unsigned lo
15237 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
15239 - loads[0] = (avenrun[0] + offset) << shift;
15240 - loads[1] = (avenrun[1] + offset) << shift;
15241 - loads[2] = (avenrun[2] + offset) << shift;
15242 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
15243 + struct vx_info *vxi = current_vx_info();
15245 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15246 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15247 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15249 + loads[0] = (avenrun[0] + offset) << shift;
15250 + loads[1] = (avenrun[1] + offset) << shift;
15251 + loads[2] = (avenrun[2] + offset) << shift;
15256 @@ -3722,16 +3732,19 @@ void account_user_time(struct task_struc
15257 cputime_t cputime_scaled)
15259 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15260 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15262 + int nice = (TASK_NICE(p) > 0);
15264 /* Add user time to process. */
15265 p->utime = cputime_add(p->utime, cputime);
15266 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15267 + vx_account_user(vxi, cputime, nice);
15268 account_group_user_time(p, cputime);
15270 /* Add user time to cpustat. */
15271 tmp = cputime_to_cputime64(cputime);
15272 - if (TASK_NICE(p) > 0)
15274 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15276 cpustat->user = cputime64_add(cpustat->user, tmp);
15277 @@ -3783,10 +3796,12 @@ void __account_system_time(struct task_s
15278 cputime_t cputime_scaled, cputime64_t *target_cputime64)
15280 cputime64_t tmp = cputime_to_cputime64(cputime);
15281 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15283 /* Add system time to process. */
15284 p->stime = cputime_add(p->stime, cputime);
15285 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15286 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15287 account_group_system_time(p, cputime);
15289 /* Add system time to cpustat. */
15290 @@ -4954,7 +4969,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15293 if (increment < 0 && !can_nice(current, nice))
15295 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15297 retval = security_task_setnice(current, nice);
15299 diff -NurpP --minimal linux-3.0.25/kernel/sched_fair.c linux-3.0.25-vs2.3.2.3/kernel/sched_fair.c
15300 --- linux-3.0.25/kernel/sched_fair.c 2011-07-22 11:18:12.000000000 +0200
15301 +++ linux-3.0.25-vs2.3.2.3/kernel/sched_fair.c 2011-07-22 11:20:39.000000000 +0200
15302 @@ -998,6 +998,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15303 __enqueue_entity(cfs_rq, se);
15306 + if (entity_is_task(se))
15307 + vx_activate_task(task_of(se));
15308 if (cfs_rq->nr_running == 1)
15309 list_add_leaf_cfs_rq(cfs_rq);
15311 @@ -1074,6 +1076,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15312 if (se != cfs_rq->curr)
15313 __dequeue_entity(cfs_rq, se);
15315 + if (entity_is_task(se))
15316 + vx_deactivate_task(task_of(se));
15317 update_cfs_load(cfs_rq, 0);
15318 account_entity_dequeue(cfs_rq, se);
15320 diff -NurpP --minimal linux-3.0.25/kernel/signal.c linux-3.0.25-vs2.3.2.3/kernel/signal.c
15321 --- linux-3.0.25/kernel/signal.c 2012-03-19 21:16:56.000000000 +0100
15322 +++ linux-3.0.25-vs2.3.2.3/kernel/signal.c 2011-11-15 17:37:07.000000000 +0100
15324 #include <linux/freezer.h>
15325 #include <linux/pid_namespace.h>
15326 #include <linux/nsproxy.h>
15327 +#include <linux/vs_context.h>
15328 +#include <linux/vs_pid.h>
15329 #define CREATE_TRACE_POINTS
15330 #include <trace/events/signal.h>
15332 @@ -744,9 +746,18 @@ static int check_kill_permission(int sig
15336 + vxdprintk(VXD_CBIT(misc, 7),
15337 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15338 + sig, info, t, vx_task_xid(t), t->pid);
15340 if (!valid_signal(sig))
15343 +/* FIXME: needed? if so, why?
15344 + if ((info != SEND_SIG_NOINFO) &&
15345 + (is_si_special(info) || !si_fromuser(info)))
15348 if (!si_fromuser(info))
15351 @@ -770,6 +781,20 @@ static int check_kill_permission(int sig
15356 + if (t->pid == 1 && current->xid)
15360 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15361 + loops, maybe ENOENT or EACCES? */
15362 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15363 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15364 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15365 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15369 return security_task_kill(t, info, sig, 0);
15372 @@ -1246,7 +1271,7 @@ int kill_pid_info(int sig, struct siginf
15375 p = pid_task(pid, PIDTYPE_PID);
15377 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15378 error = group_send_sig_info(sig, info, p);
15379 if (unlikely(error == -ESRCH))
15381 @@ -1285,7 +1310,7 @@ int kill_pid_info_as_uid(int sig, struct
15384 p = pid_task(pid, PIDTYPE_PID);
15386 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15390 @@ -1340,8 +1365,10 @@ static int kill_something_info(int sig,
15391 struct task_struct * p;
15393 for_each_process(p) {
15394 - if (task_pid_vnr(p) > 1 &&
15395 - !same_thread_group(p, current)) {
15396 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15397 + task_pid_vnr(p) > 1 &&
15398 + !same_thread_group(p, current) &&
15399 + !vx_current_initpid(p->pid)) {
15400 int err = group_send_sig_info(sig, info, p);
15403 @@ -2138,6 +2165,11 @@ relock:
15404 !sig_kernel_only(signr))
15407 + /* virtual init is protected against user signals */
15408 + if ((info->si_code == SI_USER) &&
15409 + vx_current_initpid(current->pid))
15412 if (sig_kernel_stop(signr)) {
15414 * The default action is to stop all threads in
15415 diff -NurpP --minimal linux-3.0.25/kernel/softirq.c linux-3.0.25-vs2.3.2.3/kernel/softirq.c
15416 --- linux-3.0.25/kernel/softirq.c 2011-07-22 11:18:12.000000000 +0200
15417 +++ linux-3.0.25-vs2.3.2.3/kernel/softirq.c 2011-07-22 11:20:39.000000000 +0200
15419 #include <linux/ftrace.h>
15420 #include <linux/smp.h>
15421 #include <linux/tick.h>
15422 +#include <linux/vs_context.h>
15424 #define CREATE_TRACE_POINTS
15425 #include <trace/events/irq.h>
15426 diff -NurpP --minimal linux-3.0.25/kernel/sys.c linux-3.0.25-vs2.3.2.3/kernel/sys.c
15427 --- linux-3.0.25/kernel/sys.c 2012-03-19 21:16:56.000000000 +0100
15428 +++ linux-3.0.25-vs2.3.2.3/kernel/sys.c 2011-11-15 17:37:07.000000000 +0100
15430 #include <linux/syscalls.h>
15431 #include <linux/kprobes.h>
15432 #include <linux/user_namespace.h>
15433 +#include <linux/vs_pid.h>
15435 #include <linux/kmsg_dump.h>
15436 /* Move somewhere else to avoid recompiling? */
15437 @@ -155,7 +156,10 @@ static int set_one_prio(struct task_stru
15440 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15442 + if (vx_flags(VXF_IGNEG_NICE, 0))
15448 no_nice = security_task_setnice(p, niceval);
15449 @@ -205,6 +209,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15451 pgrp = task_pgrp(current);
15452 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15453 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15455 error = set_one_prio(p, niceval, error);
15456 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15458 @@ -268,6 +274,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15460 pgrp = task_pgrp(current);
15461 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15462 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15464 niceval = 20 - task_nice(p);
15465 if (niceval > retval)
15467 @@ -387,6 +395,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15469 static DEFINE_MUTEX(reboot_mutex);
15471 +long vs_reboot(unsigned int, void __user *);
15474 * Reboot system call: for obvious reasons only root may call it,
15475 * and even root needs to set up some magic numbers in the registers
15476 @@ -419,6 +429,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15477 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15478 cmd = LINUX_REBOOT_CMD_HALT;
15480 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15481 + return vs_reboot(cmd, arg);
15483 mutex_lock(&reboot_mutex);
15485 case LINUX_REBOOT_CMD_RESTART:
15486 @@ -1235,7 +1248,8 @@ SYSCALL_DEFINE2(sethostname, char __user
15488 char tmp[__NEW_UTS_LEN];
15490 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15491 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15492 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15495 if (len < 0 || len > __NEW_UTS_LEN)
15496 @@ -1285,7 +1299,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
15498 char tmp[__NEW_UTS_LEN];
15500 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15501 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15502 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15504 if (len < 0 || len > __NEW_UTS_LEN)
15506 @@ -1403,7 +1418,7 @@ int do_prlimit(struct task_struct *tsk,
15507 /* Keep the capable check against init_user_ns until
15508 cgroups can contain all limits */
15509 if (new_rlim->rlim_max > rlim->rlim_max &&
15510 - !capable(CAP_SYS_RESOURCE))
15511 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15514 retval = security_task_setrlimit(tsk->group_leader,
15515 @@ -1457,7 +1472,8 @@ static int check_prlimit_permission(stru
15516 cred->gid == tcred->sgid &&
15517 cred->gid == tcred->gid))
15519 - if (ns_capable(tcred->user->user_ns, CAP_SYS_RESOURCE))
15520 + if (vx_ns_capable(tcred->user->user_ns,
15521 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15525 diff -NurpP --minimal linux-3.0.25/kernel/sysctl.c linux-3.0.25-vs2.3.2.3/kernel/sysctl.c
15526 --- linux-3.0.25/kernel/sysctl.c 2011-07-22 11:18:12.000000000 +0200
15527 +++ linux-3.0.25-vs2.3.2.3/kernel/sysctl.c 2011-06-15 02:40:14.000000000 +0200
15529 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15530 #include <linux/lockdep.h>
15532 +extern char vshelper_path[];
15533 #ifdef CONFIG_CHR_DEV_SG
15534 #include <scsi/sg.h>
15536 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
15537 .proc_handler = proc_dostring,
15541 + .procname = "vshelper",
15542 + .data = &vshelper_path,
15545 + .proc_handler = &proc_dostring,
15547 #ifdef CONFIG_CHR_DEV_SG
15549 .procname = "sg-big-buff",
15550 diff -NurpP --minimal linux-3.0.25/kernel/sysctl_binary.c linux-3.0.25-vs2.3.2.3/kernel/sysctl_binary.c
15551 --- linux-3.0.25/kernel/sysctl_binary.c 2012-03-19 21:16:56.000000000 +0100
15552 +++ linux-3.0.25-vs2.3.2.3/kernel/sysctl_binary.c 2012-01-10 09:19:13.000000000 +0100
15553 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15555 { CTL_INT, KERN_PANIC, "panic" },
15556 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15557 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15559 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15560 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15561 diff -NurpP --minimal linux-3.0.25/kernel/time/timekeeping.c linux-3.0.25-vs2.3.2.3/kernel/time/timekeeping.c
15562 --- linux-3.0.25/kernel/time/timekeeping.c 2012-03-19 21:16:56.000000000 +0100
15563 +++ linux-3.0.25-vs2.3.2.3/kernel/time/timekeeping.c 2011-12-19 15:55:53.000000000 +0100
15564 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
15565 } while (read_seqretry(&xtime_lock, seq));
15567 timespec_add_ns(ts, nsecs);
15568 + vx_adjust_timespec(ts);
15571 EXPORT_SYMBOL(getnstimeofday);
15572 diff -NurpP --minimal linux-3.0.25/kernel/time.c linux-3.0.25-vs2.3.2.3/kernel/time.c
15573 --- linux-3.0.25/kernel/time.c 2012-03-19 21:16:56.000000000 +0100
15574 +++ linux-3.0.25-vs2.3.2.3/kernel/time.c 2011-11-15 17:37:07.000000000 +0100
15575 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15579 - do_settimeofday(&tv);
15580 + vx_settimeofday(&tv);
15584 @@ -177,7 +177,7 @@ int do_sys_settimeofday(const struct tim
15585 /* SMP safe, again the code in arch/foo/time.c should
15586 * globally block out interrupts when it runs.
15588 - return do_settimeofday(tv);
15589 + return vx_settimeofday(tv);
15593 diff -NurpP --minimal linux-3.0.25/kernel/timer.c linux-3.0.25-vs2.3.2.3/kernel/timer.c
15594 --- linux-3.0.25/kernel/timer.c 2011-07-22 11:18:12.000000000 +0200
15595 +++ linux-3.0.25-vs2.3.2.3/kernel/timer.c 2011-06-15 02:40:14.000000000 +0200
15597 #include <linux/irq_work.h>
15598 #include <linux/sched.h>
15599 #include <linux/slab.h>
15600 +#include <linux/vs_base.h>
15601 +#include <linux/vs_cvirt.h>
15602 +#include <linux/vs_pid.h>
15603 +#include <linux/vserver/sched.h>
15605 #include <asm/uaccess.h>
15606 #include <asm/unistd.h>
15607 @@ -1336,12 +1340,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15614 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15615 - * should be moved into arch/i386 instead?
15619 * sys_getpid - return the thread group id of the current process
15620 @@ -1370,10 +1368,23 @@ SYSCALL_DEFINE0(getppid)
15622 pid = task_tgid_vnr(current->real_parent);
15624 + return vx_map_pid(pid);
15631 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15634 +asmlinkage long do_getxpid(long *ppid)
15636 + *ppid = sys_getppid();
15637 + return sys_getpid();
15640 +#else /* _alpha_ */
15642 SYSCALL_DEFINE0(getuid)
15644 /* Only we change this so SMP safe */
15645 diff -NurpP --minimal linux-3.0.25/kernel/user_namespace.c linux-3.0.25-vs2.3.2.3/kernel/user_namespace.c
15646 --- linux-3.0.25/kernel/user_namespace.c 2011-03-15 18:07:42.000000000 +0100
15647 +++ linux-3.0.25-vs2.3.2.3/kernel/user_namespace.c 2011-06-10 22:11:24.000000000 +0200
15649 #include <linux/user_namespace.h>
15650 #include <linux/highuid.h>
15651 #include <linux/cred.h>
15652 +#include <linux/vserver/global.h>
15654 static struct kmem_cache *user_ns_cachep __read_mostly;
15656 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
15659 kref_init(&ns->kref);
15660 + atomic_inc(&vs_global_user_ns);
15662 for (n = 0; n < UIDHASH_SZ; ++n)
15663 INIT_HLIST_HEAD(ns->uidhash_table + n);
15664 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
15665 struct user_namespace *ns =
15666 container_of(kref, struct user_namespace, kref);
15668 + /* FIXME: maybe move into destroyer? */
15669 + atomic_dec(&vs_global_user_ns);
15670 INIT_WORK(&ns->destroyer, free_user_ns_work);
15671 schedule_work(&ns->destroyer);
15673 diff -NurpP --minimal linux-3.0.25/kernel/utsname.c linux-3.0.25-vs2.3.2.3/kernel/utsname.c
15674 --- linux-3.0.25/kernel/utsname.c 2011-07-22 11:18:12.000000000 +0200
15675 +++ linux-3.0.25-vs2.3.2.3/kernel/utsname.c 2011-06-13 14:09:44.000000000 +0200
15676 @@ -16,14 +16,17 @@
15677 #include <linux/slab.h>
15678 #include <linux/user_namespace.h>
15679 #include <linux/proc_fs.h>
15680 +#include <linux/vserver/global.h>
15682 static struct uts_namespace *create_uts_ns(void)
15684 struct uts_namespace *uts_ns;
15686 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15689 kref_init(&uts_ns->kref);
15690 + atomic_inc(&vs_global_uts_ns);
15695 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
15696 * @old_ns: namespace to clone
15697 * Return NULL on error (failure to kmalloc), new ns otherwise
15699 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
15700 - struct uts_namespace *old_ns)
15701 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
15702 + struct user_namespace *old_user)
15704 struct uts_namespace *ns;
15706 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
15708 down_read(&uts_sem);
15709 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
15710 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
15711 + ns->user_ns = get_user_ns(old_user);
15715 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
15718 struct uts_namespace *copy_utsname(unsigned long flags,
15719 - struct task_struct *tsk)
15720 + struct uts_namespace *old_ns,
15721 + struct user_namespace *user_ns)
15723 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
15724 struct uts_namespace *new_ns;
15727 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
15728 if (!(flags & CLONE_NEWUTS))
15731 - new_ns = clone_uts_ns(tsk, old_ns);
15732 + new_ns = clone_uts_ns(old_ns, user_ns);
15734 put_uts_ns(old_ns);
15736 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
15738 ns = container_of(kref, struct uts_namespace, kref);
15739 put_user_ns(ns->user_ns);
15740 + atomic_dec(&vs_global_uts_ns);
15744 diff -NurpP --minimal linux-3.0.25/kernel/vserver/Kconfig linux-3.0.25-vs2.3.2.3/kernel/vserver/Kconfig
15745 --- linux-3.0.25/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
15746 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/Kconfig 2011-08-08 18:06:22.000000000 +0200
15749 +# Linux VServer configuration
15752 +menu "Linux VServer"
15754 +config VSERVER_AUTO_LBACK
15755 + bool "Automatically Assign Loopback IP"
15758 + Automatically assign a guest specific loopback
15759 + IP and add it to the kernel network stack on
15762 +config VSERVER_AUTO_SINGLE
15763 + bool "Automatic Single IP Special Casing"
15764 + depends on EXPERIMENTAL
15767 + This allows network contexts with a single IP to
15768 + automatically remap 0.0.0.0 bindings to that IP,
15769 + avoiding further network checks and improving
15772 + (note: such guests do not allow to change the ip
15773 + on the fly and do not show loopback addresses)
15775 +config VSERVER_COWBL
15776 + bool "Enable COW Immutable Link Breaking"
15779 + This enables the COW (Copy-On-Write) link break code.
15780 + It allows you to treat unified files like normal files
15781 + when writing to them (which will implicitely break the
15782 + link and create a copy of the unified file)
15784 +config VSERVER_VTIME
15785 + bool "Enable Virtualized Guest Time"
15786 + depends on EXPERIMENTAL
15789 + This enables per guest time offsets to allow for
15790 + adjusting the system clock individually per guest.
15791 + this adds some overhead to the time functions and
15792 + therefore should not be enabled without good reason.
15794 +config VSERVER_DEVICE
15795 + bool "Enable Guest Device Mapping"
15796 + depends on EXPERIMENTAL
15799 + This enables generic device remapping.
15801 +config VSERVER_PROC_SECURE
15802 + bool "Enable Proc Security"
15803 + depends on PROC_FS
15806 + This configures ProcFS security to initially hide
15807 + non-process entries for all contexts except the main and
15808 + spectator context (i.e. for all guests), which is a secure
15811 + (note: on 1.2x the entries were visible by default)
15814 + prompt "Persistent Inode Tagging"
15815 + default TAGGING_ID24
15817 + This adds persistent context information to filesystems
15818 + mounted with the tagxid option. Tagging is a requirement
15819 + for per-context disk limits and per-context quota.
15822 +config TAGGING_NONE
15825 + do not store per-context information in inodes.
15827 +config TAGGING_UID16
15828 + bool "UID16/GID32"
15830 + reduces UID to 16 bit, but leaves GID at 32 bit.
15832 +config TAGGING_GID16
15833 + bool "UID32/GID16"
15835 + reduces GID to 16 bit, but leaves UID at 32 bit.
15837 +config TAGGING_ID24
15838 + bool "UID24/GID24"
15840 + uses the upper 8bit from UID and GID for XID tagging
15841 + which leaves 24bit for UID/GID each, which should be
15842 + more than sufficient for normal use.
15844 +config TAGGING_INTERN
15845 + bool "UID32/GID32"
15847 + this uses otherwise reserved inode fields in the on
15848 + disk representation, which limits the use to a few
15849 + filesystems (currently ext2 and ext3)
15854 + bool "Tag NFSD User Auth and Files"
15857 + Enable this if you do want the in-kernel NFS
15858 + Server to use the tagging specified above.
15859 + (will require patched clients too)
15861 +config VSERVER_PRIVACY
15862 + bool "Honor Privacy Aspects of Guests"
15865 + When enabled, most context checks will disallow
15866 + access to structures assigned to a specific context,
15867 + like ptys or loop devices.
15869 +config VSERVER_CONTEXTS
15870 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15872 + default "768" if 64BIT
15875 + This setting will optimize certain data structures
15876 + and memory allocations according to the expected
15879 + note: this is not a strict upper limit.
15881 +config VSERVER_WARN
15882 + bool "VServer Warnings"
15885 + This enables various runtime warnings, which will
15886 + notify about potential manipulation attempts or
15887 + resource shortage. It is generally considered to
15888 + be a good idea to have that enabled.
15890 +config VSERVER_WARN_DEVPTS
15891 + bool "VServer DevPTS Warnings"
15892 + depends on VSERVER_WARN
15895 + This enables DevPTS related warnings, issued when a
15896 + process inside a context tries to lookup or access
15897 + a dynamic pts from the host or a different context.
15899 +config VSERVER_DEBUG
15900 + bool "VServer Debugging Code"
15903 + Set this to yes if you want to be able to activate
15904 + debugging output at runtime. It adds a very small
15905 + overhead to all vserver related functions and
15906 + increases the kernel size by about 20k.
15908 +config VSERVER_HISTORY
15909 + bool "VServer History Tracing"
15910 + depends on VSERVER_DEBUG
15913 + Set this to yes if you want to record the history of
15914 + linux-vserver activities, so they can be replayed in
15915 + the event of a kernel panic or oops.
15917 +config VSERVER_HISTORY_SIZE
15918 + int "Per-CPU History Size (32-65536)"
15919 + depends on VSERVER_HISTORY
15923 + This allows you to specify the number of entries in
15924 + the per-CPU history buffer.
15926 +config VSERVER_LEGACY_MEM
15927 + bool "Legacy Memory Limits"
15930 + This provides fake memory limits to keep
15931 + older tools happy in the face of memory
15935 + prompt "Quotes used in debug and warn messages"
15936 + default QUOTES_ISO8859
15938 +config QUOTES_ISO8859
15939 + bool "Extended ASCII (ISO 8859) angle quotes"
15941 + This uses the extended ASCII characters \xbb
15942 + and \xab for quoting file and process names.
15944 +config QUOTES_UTF8
15945 + bool "UTF-8 angle quotes"
15947 + This uses the the UTF-8 sequences for angle
15948 + quotes to quote file and process names.
15950 +config QUOTES_ASCII
15951 + bool "ASCII single quotes"
15953 + This uses the ASCII single quote character
15954 + (\x27) to quote file and process names.
15964 + select NAMESPACES
15970 +config VSERVER_SECURITY
15972 + depends on SECURITY
15974 + select SECURITY_CAPABILITIES
15976 +config VSERVER_DISABLED
15980 diff -NurpP --minimal linux-3.0.25/kernel/vserver/Makefile linux-3.0.25-vs2.3.2.3/kernel/vserver/Makefile
15981 --- linux-3.0.25/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
15982 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/Makefile 2011-06-10 22:11:24.000000000 +0200
15985 +# Makefile for the Linux vserver routines.
15989 +obj-y += vserver.o
15991 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15992 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15995 +vserver-$(CONFIG_INET) += inet.o
15996 +vserver-$(CONFIG_PROC_FS) += proc.o
15997 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15998 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15999 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
16000 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
16002 diff -NurpP --minimal linux-3.0.25/kernel/vserver/cacct.c linux-3.0.25-vs2.3.2.3/kernel/vserver/cacct.c
16003 --- linux-3.0.25/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
16004 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cacct.c 2011-06-10 22:11:24.000000000 +0200
16007 + * linux/kernel/vserver/cacct.c
16009 + * Virtual Server: Context Accounting
16011 + * Copyright (C) 2006-2007 Herbert Pötzl
16013 + * V0.01 added accounting stats
16017 +#include <linux/types.h>
16018 +#include <linux/vs_context.h>
16019 +#include <linux/vserver/cacct_cmd.h>
16020 +#include <linux/vserver/cacct_int.h>
16022 +#include <asm/errno.h>
16023 +#include <asm/uaccess.h>
16026 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
16028 + struct vcmd_sock_stat_v0 vc_data;
16031 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16034 + field = vc_data.field;
16035 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
16038 + for (j = 0; j < 3; j++) {
16039 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
16040 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
16043 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16048 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
16049 --- linux-3.0.25/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16050 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cacct_init.h 2011-06-10 22:11:24.000000000 +0200
16054 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16059 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16060 + for (j = 0; j < 3; j++) {
16061 + atomic_long_set(&cacct->sock[i][j].count, 0);
16062 + atomic_long_set(&cacct->sock[i][j].total, 0);
16065 + for (i = 0; i < 8; i++)
16066 + atomic_set(&cacct->slab[i], 0);
16067 + for (i = 0; i < 5; i++)
16068 + for (j = 0; j < 4; j++)
16069 + atomic_set(&cacct->page[i][j], 0);
16072 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16077 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
16078 --- linux-3.0.25/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16079 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cacct_proc.h 2011-06-10 22:11:24.000000000 +0200
16081 +#ifndef _VX_CACCT_PROC_H
16082 +#define _VX_CACCT_PROC_H
16084 +#include <linux/vserver/cacct_int.h>
16087 +#define VX_SOCKA_TOP \
16088 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16090 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16092 + int i, j, length = 0;
16093 + static char *type[VXA_SOCK_SIZE] = {
16094 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16097 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16098 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16099 + length += sprintf(buffer + length, "%s:", type[i]);
16100 + for (j = 0; j < 3; j++) {
16101 + length += sprintf(buffer + length,
16102 + "\t%10lu/%-10lu",
16103 + vx_sock_count(cacct, i, j),
16104 + vx_sock_total(cacct, i, j));
16106 + buffer[length++] = '\n';
16109 + length += sprintf(buffer + length, "\n");
16110 + length += sprintf(buffer + length,
16111 + "slab:\t %8u %8u %8u %8u\n",
16112 + atomic_read(&cacct->slab[1]),
16113 + atomic_read(&cacct->slab[4]),
16114 + atomic_read(&cacct->slab[0]),
16115 + atomic_read(&cacct->slab[2]));
16117 + length += sprintf(buffer + length, "\n");
16118 + for (i = 0; i < 5; i++) {
16119 + length += sprintf(buffer + length,
16120 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16121 + atomic_read(&cacct->page[i][0]),
16122 + atomic_read(&cacct->page[i][1]),
16123 + atomic_read(&cacct->page[i][2]),
16124 + atomic_read(&cacct->page[i][3]),
16125 + atomic_read(&cacct->page[i][4]),
16126 + atomic_read(&cacct->page[i][5]),
16127 + atomic_read(&cacct->page[i][6]),
16128 + atomic_read(&cacct->page[i][7]));
16133 +#endif /* _VX_CACCT_PROC_H */
16134 diff -NurpP --minimal linux-3.0.25/kernel/vserver/context.c linux-3.0.25-vs2.3.2.3/kernel/vserver/context.c
16135 --- linux-3.0.25/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16136 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/context.c 2011-08-01 18:28:12.000000000 +0200
16139 + * linux/kernel/vserver/context.c
16141 + * Virtual Server: Context Support
16143 + * Copyright (C) 2003-2011 Herbert Pötzl
16145 + * V0.01 context helper
16146 + * V0.02 vx_ctx_kill syscall command
16147 + * V0.03 replaced context_info calls
16148 + * V0.04 redesign of struct (de)alloc
16149 + * V0.05 rlimit basic implementation
16150 + * V0.06 task_xid and info commands
16151 + * V0.07 context flags and caps
16152 + * V0.08 switch to RCU based hash
16153 + * V0.09 revert to non RCU for now
16154 + * V0.10 and back to working RCU hash
16155 + * V0.11 and back to locking again
16156 + * V0.12 referenced context store
16157 + * V0.13 separate per cpu data
16158 + * V0.14 changed vcmds to vxi arg
16159 + * V0.15 added context stat
16160 + * V0.16 have __create claim() the vxi
16161 + * V0.17 removed older and legacy stuff
16162 + * V0.18 added user credentials
16163 + * V0.19 added warn mask
16167 +#include <linux/slab.h>
16168 +#include <linux/types.h>
16169 +#include <linux/security.h>
16170 +#include <linux/pid_namespace.h>
16171 +#include <linux/capability.h>
16173 +#include <linux/vserver/context.h>
16174 +#include <linux/vserver/network.h>
16175 +#include <linux/vserver/debug.h>
16176 +#include <linux/vserver/limit.h>
16177 +#include <linux/vserver/limit_int.h>
16178 +#include <linux/vserver/space.h>
16179 +#include <linux/init_task.h>
16180 +#include <linux/fs_struct.h>
16181 +#include <linux/cred.h>
16183 +#include <linux/vs_context.h>
16184 +#include <linux/vs_limit.h>
16185 +#include <linux/vs_pid.h>
16186 +#include <linux/vserver/context_cmd.h>
16188 +#include "cvirt_init.h"
16189 +#include "cacct_init.h"
16190 +#include "limit_init.h"
16191 +#include "sched_init.h"
16194 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16195 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16198 +/* now inactive context structures */
16200 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16202 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
16205 +/* __alloc_vx_info()
16207 + * allocate an initialized vx_info struct
16208 + * doesn't make it visible (hash) */
16210 +static struct vx_info *__alloc_vx_info(xid_t xid)
16212 + struct vx_info *new = NULL;
16215 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16217 + /* would this benefit from a slab cache? */
16218 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16222 + memset(new, 0, sizeof(struct vx_info));
16224 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16225 + if (!new->ptr_pc)
16228 + new->vx_id = xid;
16229 + INIT_HLIST_NODE(&new->vx_hlist);
16230 + atomic_set(&new->vx_usecnt, 0);
16231 + atomic_set(&new->vx_tasks, 0);
16232 + new->vx_parent = NULL;
16233 + new->vx_state = 0;
16234 + init_waitqueue_head(&new->vx_wait);
16236 + /* prepare reaper */
16237 + get_task_struct(init_pid_ns.child_reaper);
16238 + new->vx_reaper = init_pid_ns.child_reaper;
16239 + new->vx_badness_bias = 0;
16241 + /* rest of init goes here */
16242 + vx_info_init_limit(&new->limit);
16243 + vx_info_init_sched(&new->sched);
16244 + vx_info_init_cvirt(&new->cvirt);
16245 + vx_info_init_cacct(&new->cacct);
16247 + /* per cpu data structures */
16248 + for_each_possible_cpu(cpu) {
16249 + vx_info_init_sched_pc(
16250 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16251 + vx_info_init_cvirt_pc(
16252 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16255 + new->vx_flags = VXF_INIT_SET;
16256 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
16257 + new->vx_ccaps = 0;
16258 + new->vx_umask = 0;
16259 + new->vx_wmask = 0;
16261 + new->reboot_cmd = 0;
16262 + new->exit_code = 0;
16264 + // preconfig spaces
16265 + for (index = 0; index < VX_SPACES; index++) {
16266 + struct _vx_space *space = &new->space[index];
16269 + spin_lock(&init_fs.lock);
16271 + spin_unlock(&init_fs.lock);
16272 + space->vx_fs = &init_fs;
16274 + /* FIXME: do we want defaults? */
16275 + // space->vx_real_cred = 0;
16276 + // space->vx_cred = 0;
16280 + vxdprintk(VXD_CBIT(xid, 0),
16281 + "alloc_vx_info(%d) = %p", xid, new);
16282 + vxh_alloc_vx_info(new);
16283 + atomic_inc(&vx_global_ctotal);
16292 +/* __dealloc_vx_info()
16294 + * final disposal of vx_info */
16296 +static void __dealloc_vx_info(struct vx_info *vxi)
16298 +#ifdef CONFIG_VSERVER_WARN
16299 + struct vx_info_save vxis;
16302 + vxdprintk(VXD_CBIT(xid, 0),
16303 + "dealloc_vx_info(%p)", vxi);
16304 + vxh_dealloc_vx_info(vxi);
16306 +#ifdef CONFIG_VSERVER_WARN
16307 + enter_vx_info(vxi, &vxis);
16308 + vx_info_exit_limit(&vxi->limit);
16309 + vx_info_exit_sched(&vxi->sched);
16310 + vx_info_exit_cvirt(&vxi->cvirt);
16311 + vx_info_exit_cacct(&vxi->cacct);
16313 + for_each_possible_cpu(cpu) {
16314 + vx_info_exit_sched_pc(
16315 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16316 + vx_info_exit_cvirt_pc(
16317 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16319 + leave_vx_info(&vxis);
16323 + vxi->vx_state |= VXS_RELEASED;
16326 + free_percpu(vxi->ptr_pc);
16329 + atomic_dec(&vx_global_ctotal);
16332 +static void __shutdown_vx_info(struct vx_info *vxi)
16334 + struct nsproxy *nsproxy;
16335 + struct fs_struct *fs;
16336 + struct cred *cred;
16341 + vxi->vx_state |= VXS_SHUTDOWN;
16342 + vs_state_change(vxi, VSC_SHUTDOWN);
16344 + for (index = 0; index < VX_SPACES; index++) {
16345 + struct _vx_space *space = &vxi->space[index];
16347 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16349 + put_nsproxy(nsproxy);
16351 + fs = xchg(&space->vx_fs, NULL);
16352 + spin_lock(&fs->lock);
16353 + kill = !--fs->users;
16354 + spin_unlock(&fs->lock);
16356 + free_fs_struct(fs);
16358 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16360 + abort_creds(cred);
16364 +/* exported stuff */
16366 +void free_vx_info(struct vx_info *vxi)
16368 + unsigned long flags;
16371 + /* check for reference counts first */
16372 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16373 + BUG_ON(atomic_read(&vxi->vx_tasks));
16375 + /* context must not be hashed */
16376 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16378 + /* context shutdown is mandatory */
16379 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16381 + /* spaces check */
16382 + for (index = 0; index < VX_SPACES; index++) {
16383 + struct _vx_space *space = &vxi->space[index];
16385 + BUG_ON(space->vx_nsproxy);
16386 + BUG_ON(space->vx_fs);
16387 + // BUG_ON(space->vx_real_cred);
16388 + // BUG_ON(space->vx_cred);
16391 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16392 + hlist_del(&vxi->vx_hlist);
16393 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16395 + __dealloc_vx_info(vxi);
16399 +/* hash table for vx_info hash */
16401 +#define VX_HASH_SIZE 13
16403 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16404 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16406 +static DEFINE_SPINLOCK(vx_info_hash_lock);
16409 +static inline unsigned int __hashval(xid_t xid)
16411 + return (xid % VX_HASH_SIZE);
16416 +/* __hash_vx_info()
16418 + * add the vxi to the global hash table
16419 + * requires the hash_lock to be held */
16421 +static inline void __hash_vx_info(struct vx_info *vxi)
16423 + struct hlist_head *head;
16425 + vxd_assert_lock(&vx_info_hash_lock);
16426 + vxdprintk(VXD_CBIT(xid, 4),
16427 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16428 + vxh_hash_vx_info(vxi);
16430 + /* context must not be hashed */
16431 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16433 + vxi->vx_state |= VXS_HASHED;
16434 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16435 + hlist_add_head(&vxi->vx_hlist, head);
16436 + atomic_inc(&vx_global_cactive);
16439 +/* __unhash_vx_info()
16441 + * remove the vxi from the global hash table
16442 + * requires the hash_lock to be held */
16444 +static inline void __unhash_vx_info(struct vx_info *vxi)
16446 + unsigned long flags;
16448 + vxd_assert_lock(&vx_info_hash_lock);
16449 + vxdprintk(VXD_CBIT(xid, 4),
16450 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16451 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16452 + vxh_unhash_vx_info(vxi);
16454 + /* context must be hashed */
16455 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16456 + /* but without tasks */
16457 + BUG_ON(atomic_read(&vxi->vx_tasks));
16459 + vxi->vx_state &= ~VXS_HASHED;
16460 + hlist_del_init(&vxi->vx_hlist);
16461 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16462 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16463 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16464 + atomic_dec(&vx_global_cactive);
16468 +/* __lookup_vx_info()
16470 + * requires the hash_lock to be held
16471 + * doesn't increment the vx_refcnt */
16473 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16475 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16476 + struct hlist_node *pos;
16477 + struct vx_info *vxi;
16479 + vxd_assert_lock(&vx_info_hash_lock);
16480 + hlist_for_each(pos, head) {
16481 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16483 + if (vxi->vx_id == xid)
16488 + vxdprintk(VXD_CBIT(xid, 0),
16489 + "__lookup_vx_info(#%u): %p[#%u]",
16490 + xid, vxi, vxi ? vxi->vx_id : 0);
16491 + vxh_lookup_vx_info(vxi, xid);
16496 +/* __create_vx_info()
16498 + * create the requested context
16499 + * get(), claim() and hash it */
16501 +static struct vx_info *__create_vx_info(int id)
16503 + struct vx_info *new, *vxi = NULL;
16505 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16507 + if (!(new = __alloc_vx_info(id)))
16508 + return ERR_PTR(-ENOMEM);
16510 + /* required to make dynamic xids unique */
16511 + spin_lock(&vx_info_hash_lock);
16513 + /* static context requested */
16514 + if ((vxi = __lookup_vx_info(id))) {
16515 + vxdprintk(VXD_CBIT(xid, 0),
16516 + "create_vx_info(%d) = %p (already there)", id, vxi);
16517 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16518 + vxi = ERR_PTR(-EBUSY);
16520 + vxi = ERR_PTR(-EEXIST);
16523 + /* new context */
16524 + vxdprintk(VXD_CBIT(xid, 0),
16525 + "create_vx_info(%d) = %p (new)", id, new);
16526 + claim_vx_info(new, NULL);
16527 + __hash_vx_info(get_vx_info(new));
16528 + vxi = new, new = NULL;
16531 + spin_unlock(&vx_info_hash_lock);
16532 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16534 + __dealloc_vx_info(new);
16539 +/* exported stuff */
16542 +void unhash_vx_info(struct vx_info *vxi)
16544 + spin_lock(&vx_info_hash_lock);
16545 + __unhash_vx_info(vxi);
16546 + spin_unlock(&vx_info_hash_lock);
16547 + __shutdown_vx_info(vxi);
16548 + __wakeup_vx_info(vxi);
16552 +/* lookup_vx_info()
16554 + * search for a vx_info and get() it
16555 + * negative id means current */
16557 +struct vx_info *lookup_vx_info(int id)
16559 + struct vx_info *vxi = NULL;
16562 + vxi = get_vx_info(current_vx_info());
16563 + } else if (id > 1) {
16564 + spin_lock(&vx_info_hash_lock);
16565 + vxi = get_vx_info(__lookup_vx_info(id));
16566 + spin_unlock(&vx_info_hash_lock);
16571 +/* xid_is_hashed()
16573 + * verify that xid is still hashed */
16575 +int xid_is_hashed(xid_t xid)
16579 + spin_lock(&vx_info_hash_lock);
16580 + hashed = (__lookup_vx_info(xid) != NULL);
16581 + spin_unlock(&vx_info_hash_lock);
16585 +#ifdef CONFIG_PROC_FS
16589 + * get a subset of hashed xids for proc
16590 + * assumes size is at least one */
16592 +int get_xid_list(int index, unsigned int *xids, int size)
16594 + int hindex, nr_xids = 0;
16596 + /* only show current and children */
16597 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16600 + xids[nr_xids] = vx_current_xid();
16604 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16605 + struct hlist_head *head = &vx_info_hash[hindex];
16606 + struct hlist_node *pos;
16608 + spin_lock(&vx_info_hash_lock);
16609 + hlist_for_each(pos, head) {
16610 + struct vx_info *vxi;
16615 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16616 + xids[nr_xids] = vxi->vx_id;
16617 + if (++nr_xids >= size) {
16618 + spin_unlock(&vx_info_hash_lock);
16622 + /* keep the lock time short */
16623 + spin_unlock(&vx_info_hash_lock);
16630 +#ifdef CONFIG_VSERVER_DEBUG
16632 +void dump_vx_info_inactive(int level)
16634 + struct hlist_node *entry, *next;
16636 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16637 + struct vx_info *vxi =
16638 + list_entry(entry, struct vx_info, vx_hlist);
16640 + dump_vx_info(vxi, level);
16647 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16649 + struct user_struct *new_user, *old_user;
16654 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16657 + new_user = alloc_uid(vxi->vx_id, p->uid);
16661 + old_user = p->user;
16662 + if (new_user != old_user) {
16663 + atomic_inc(&new_user->processes);
16664 + atomic_dec(&old_user->processes);
16665 + p->user = new_user;
16667 + free_uid(old_user);
16673 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16675 + // p->cap_effective &= vxi->vx_cap_bset;
16676 + p->cap_effective =
16677 + cap_intersect(p->cap_effective, vxi->cap_bset);
16678 + // p->cap_inheritable &= vxi->vx_cap_bset;
16679 + p->cap_inheritable =
16680 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16681 + // p->cap_permitted &= vxi->vx_cap_bset;
16682 + p->cap_permitted =
16683 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16688 +#include <linux/file.h>
16689 +#include <linux/fdtable.h>
16691 +static int vx_openfd_task(struct task_struct *tsk)
16693 + struct files_struct *files = tsk->files;
16694 + struct fdtable *fdt;
16695 + const unsigned long *bptr;
16696 + int count, total;
16698 + /* no rcu_read_lock() because of spin_lock() */
16699 + spin_lock(&files->file_lock);
16700 + fdt = files_fdtable(files);
16701 + bptr = fdt->open_fds->fds_bits;
16702 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16703 + for (total = 0; count > 0; count--) {
16705 + total += hweight_long(*bptr);
16708 + spin_unlock(&files->file_lock);
16713 +/* for *space compatibility */
16715 +asmlinkage long sys_unshare(unsigned long);
16718 + * migrate task to new context
16719 + * gets vxi, puts old_vxi on change
16720 + * optionally unshares namespaces (hack)
16723 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16725 + struct vx_info *old_vxi;
16731 + vxdprintk(VXD_CBIT(xid, 5),
16732 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16733 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16735 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16736 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16739 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16742 + old_vxi = task_get_vx_info(p);
16743 + if (old_vxi == vxi)
16746 +// if (!(ret = vx_migrate_user(p, vxi))) {
16751 + openfd = vx_openfd_task(p);
16754 + atomic_dec(&old_vxi->cvirt.nr_threads);
16755 + atomic_dec(&old_vxi->cvirt.nr_running);
16756 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16757 + /* FIXME: what about the struct files here? */
16758 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16759 + /* account for the executable */
16760 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16762 + atomic_inc(&vxi->cvirt.nr_threads);
16763 + atomic_inc(&vxi->cvirt.nr_running);
16764 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16765 + /* FIXME: what about the struct files here? */
16766 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16767 + /* account for the executable */
16768 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16771 + release_vx_info(old_vxi, p);
16772 + clr_vx_info(&p->vx_info);
16774 + claim_vx_info(vxi, p);
16775 + set_vx_info(&p->vx_info, vxi);
16776 + p->xid = vxi->vx_id;
16778 + vxdprintk(VXD_CBIT(xid, 5),
16779 + "moved task %p into vxi:%p[#%d]",
16780 + p, vxi, vxi->vx_id);
16782 + // vx_mask_cap_bset(vxi, p);
16785 + /* hack for *spaces to provide compatibility */
16787 + struct nsproxy *old_nsp, *new_nsp;
16789 + ret = unshare_nsproxy_namespaces(
16790 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16795 + old_nsp = xchg(&p->nsproxy, new_nsp);
16796 + vx_set_space(vxi,
16797 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16798 + put_nsproxy(old_nsp);
16802 + put_vx_info(old_vxi);
16806 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16808 + struct task_struct *old_reaper;
16813 + vxdprintk(VXD_CBIT(xid, 6),
16814 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16815 + vxi, vxi->vx_id, p, p->xid, p->pid);
16817 + old_reaper = vxi->vx_reaper;
16818 + if (old_reaper == p)
16821 + /* set new child reaper */
16822 + get_task_struct(p);
16823 + vxi->vx_reaper = p;
16824 + put_task_struct(old_reaper);
16828 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16833 + vxdprintk(VXD_CBIT(xid, 6),
16834 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16835 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16837 + vxi->vx_flags &= ~VXF_STATE_INIT;
16838 + // vxi->vx_initpid = p->tgid;
16839 + vxi->vx_initpid = p->pid;
16843 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16845 + vxdprintk(VXD_CBIT(xid, 6),
16846 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16847 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16849 + vxi->exit_code = code;
16850 + vxi->vx_initpid = 0;
16854 +void vx_set_persistent(struct vx_info *vxi)
16856 + vxdprintk(VXD_CBIT(xid, 6),
16857 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16859 + get_vx_info(vxi);
16860 + claim_vx_info(vxi, NULL);
16863 +void vx_clear_persistent(struct vx_info *vxi)
16865 + vxdprintk(VXD_CBIT(xid, 6),
16866 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16868 + release_vx_info(vxi, NULL);
16869 + put_vx_info(vxi);
16872 +void vx_update_persistent(struct vx_info *vxi)
16874 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16875 + vx_set_persistent(vxi);
16877 + vx_clear_persistent(vxi);
16881 +/* task must be current or locked */
16883 +void exit_vx_info(struct task_struct *p, int code)
16885 + struct vx_info *vxi = p->vx_info;
16888 + atomic_dec(&vxi->cvirt.nr_threads);
16891 + vxi->exit_code = code;
16892 + release_vx_info(vxi, p);
16896 +void exit_vx_info_early(struct task_struct *p, int code)
16898 + struct vx_info *vxi = p->vx_info;
16901 + if (vxi->vx_initpid == p->pid)
16902 + vx_exit_init(vxi, p, code);
16903 + if (vxi->vx_reaper == p)
16904 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16909 +/* vserver syscall commands below here */
16911 +/* taks xid and vx_info functions */
16913 +#include <asm/uaccess.h>
16916 +int vc_task_xid(uint32_t id)
16921 + struct task_struct *tsk;
16924 + tsk = find_task_by_real_pid(id);
16925 + xid = (tsk) ? tsk->xid : -ESRCH;
16926 + rcu_read_unlock();
16928 + xid = vx_current_xid();
16933 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16935 + struct vcmd_vx_info_v0 vc_data;
16937 + vc_data.xid = vxi->vx_id;
16938 + vc_data.initpid = vxi->vx_initpid;
16940 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16946 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16948 + struct vcmd_ctx_stat_v0 vc_data;
16950 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16951 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16953 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16959 +/* context functions */
16961 +int vc_ctx_create(uint32_t xid, void __user *data)
16963 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16964 + struct vx_info *new_vxi;
16967 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16970 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16973 + new_vxi = __create_vx_info(xid);
16974 + if (IS_ERR(new_vxi))
16975 + return PTR_ERR(new_vxi);
16977 + /* initial flags */
16978 + new_vxi->vx_flags = vc_data.flagword;
16981 + if (vs_state_change(new_vxi, VSC_STARTUP))
16984 + ret = vx_migrate_task(current, new_vxi, (!data));
16988 + /* return context id on success */
16989 + ret = new_vxi->vx_id;
16991 + /* get a reference for persistent contexts */
16992 + if ((vc_data.flagword & VXF_PERSISTENT))
16993 + vx_set_persistent(new_vxi);
16995 + release_vx_info(new_vxi, NULL);
16996 + put_vx_info(new_vxi);
17001 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
17003 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
17006 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
17009 + ret = vx_migrate_task(current, vxi, 0);
17012 + if (vc_data.flagword & VXM_SET_INIT)
17013 + ret = vx_set_init(vxi, current);
17016 + if (vc_data.flagword & VXM_SET_REAPER)
17017 + ret = vx_set_reaper(vxi, current);
17022 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
17024 + struct vcmd_ctx_flags_v0 vc_data;
17026 + vc_data.flagword = vxi->vx_flags;
17028 + /* special STATE flag handling */
17029 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
17031 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17036 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
17038 + struct vcmd_ctx_flags_v0 vc_data;
17039 + uint64_t mask, trigger;
17041 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17044 + /* special STATE flag handling */
17045 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
17046 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
17048 + if (vxi == current_vx_info()) {
17049 + /* if (trigger & VXF_STATE_SETUP)
17050 + vx_mask_cap_bset(vxi, current); */
17051 + if (trigger & VXF_STATE_INIT) {
17054 + ret = vx_set_init(vxi, current);
17057 + ret = vx_set_reaper(vxi, current);
17063 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17064 + vc_data.flagword, mask);
17065 + if (trigger & VXF_PERSISTENT)
17066 + vx_update_persistent(vxi);
17072 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17074 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17076 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17080 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17082 + kernel_cap_t c = __cap_empty_set;
17084 + c.cap[0] = v & 0xFFFFFFFF;
17085 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17087 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17092 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17095 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17097 + *ccaps = vxi->vx_ccaps;
17102 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17104 + struct vcmd_ctx_caps_v1 vc_data;
17107 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17110 + vc_data.cmask = ~0ULL;
17112 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17117 +static int do_set_caps(struct vx_info *vxi,
17118 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17120 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17123 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17124 + bcaps, bmask, ccaps, cmask);
17126 + vxi->vx_bcaps = cap_t_from_caps(
17127 + vs_mask_flags(bcold, bcaps, bmask));
17128 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17133 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17135 + struct vcmd_ctx_caps_v1 vc_data;
17137 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17140 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17143 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17145 + struct vcmd_bcaps vc_data;
17148 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17151 + vc_data.bmask = ~0ULL;
17153 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17158 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17160 + struct vcmd_bcaps vc_data;
17162 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17165 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17169 +int vc_get_umask(struct vx_info *vxi, void __user *data)
17171 + struct vcmd_umask vc_data;
17173 + vc_data.umask = vxi->vx_umask;
17174 + vc_data.mask = ~0ULL;
17176 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17181 +int vc_set_umask(struct vx_info *vxi, void __user *data)
17183 + struct vcmd_umask vc_data;
17185 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17188 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
17189 + vc_data.umask, vc_data.mask);
17194 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
17196 + struct vcmd_wmask vc_data;
17198 + vc_data.wmask = vxi->vx_wmask;
17199 + vc_data.mask = ~0ULL;
17201 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17206 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
17208 + struct vcmd_wmask vc_data;
17210 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17213 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
17214 + vc_data.wmask, vc_data.mask);
17219 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17221 + struct vcmd_badness_v0 vc_data;
17223 + vc_data.bias = vxi->vx_badness_bias;
17225 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17230 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17232 + struct vcmd_badness_v0 vc_data;
17234 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17237 + vxi->vx_badness_bias = vc_data.bias;
17241 +#include <linux/module.h>
17243 +EXPORT_SYMBOL_GPL(free_vx_info);
17245 diff -NurpP --minimal linux-3.0.25/kernel/vserver/cvirt.c linux-3.0.25-vs2.3.2.3/kernel/vserver/cvirt.c
17246 --- linux-3.0.25/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17247 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cvirt.c 2011-06-13 14:57:26.000000000 +0200
17250 + * linux/kernel/vserver/cvirt.c
17252 + * Virtual Server: Context Virtualization
17254 + * Copyright (C) 2004-2007 Herbert Pötzl
17256 + * V0.01 broken out from limit.c
17257 + * V0.02 added utsname stuff
17258 + * V0.03 changed vcmds to vxi arg
17262 +#include <linux/types.h>
17263 +#include <linux/utsname.h>
17264 +#include <linux/vs_cvirt.h>
17265 +#include <linux/vserver/switch.h>
17266 +#include <linux/vserver/cvirt_cmd.h>
17268 +#include <asm/uaccess.h>
17271 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17273 + struct vx_info *vxi = current_vx_info();
17275 + set_normalized_timespec(uptime,
17276 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17277 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17280 + set_normalized_timespec(idle,
17281 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17282 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17286 +uint64_t vx_idle_jiffies(void)
17288 + return init_task.utime + init_task.stime;
17293 +static inline uint32_t __update_loadavg(uint32_t load,
17294 + int wsize, int delta, int n)
17296 + unsigned long long calc, prev;
17298 + /* just set it to n */
17299 + if (unlikely(delta >= wsize))
17300 + return (n << FSHIFT);
17302 + calc = delta * n;
17304 + prev = (wsize - delta);
17307 + do_div(calc, wsize);
17312 +void vx_update_load(struct vx_info *vxi)
17314 + uint32_t now, last, delta;
17315 + unsigned int nr_running, nr_uninterruptible;
17316 + unsigned int total;
17317 + unsigned long flags;
17319 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17322 + last = vxi->cvirt.load_last;
17323 + delta = now - last;
17325 + if (delta < 5*HZ)
17328 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17329 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17330 + total = nr_running + nr_uninterruptible;
17332 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17333 + 60*HZ, delta, total);
17334 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17335 + 5*60*HZ, delta, total);
17336 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17337 + 15*60*HZ, delta, total);
17339 + vxi->cvirt.load_last = now;
17341 + atomic_inc(&vxi->cvirt.load_updates);
17342 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17347 + * Commands to do_syslog:
17349 + * 0 -- Close the log. Currently a NOP.
17350 + * 1 -- Open the log. Currently a NOP.
17351 + * 2 -- Read from the log.
17352 + * 3 -- Read all messages remaining in the ring buffer.
17353 + * 4 -- Read and clear all messages remaining in the ring buffer
17354 + * 5 -- Clear ring buffer.
17355 + * 6 -- Disable printk's to console
17356 + * 7 -- Enable printk's to console
17357 + * 8 -- Set level of messages printed to console
17358 + * 9 -- Return number of unread characters in the log buffer
17359 + * 10 -- Return size of the log buffer
17361 +int vx_do_syslog(int type, char __user *buf, int len)
17364 + int do_clear = 0;
17365 + struct vx_info *vxi = current_vx_info();
17366 + struct _vx_syslog *log;
17370 + log = &vxi->cvirt.syslog;
17373 + case 0: /* Close log */
17374 + case 1: /* Open log */
17376 + case 2: /* Read from log */
17377 + error = wait_event_interruptible(log->log_wait,
17378 + (log->log_start - log->log_end));
17381 + spin_lock_irq(&log->logbuf_lock);
17382 + spin_unlock_irq(&log->logbuf_lock);
17384 + case 4: /* Read/clear last kernel messages */
17386 + /* fall through */
17387 + case 3: /* Read last kernel messages */
17390 + case 5: /* Clear ring buffer */
17393 + case 6: /* Disable logging to console */
17394 + case 7: /* Enable logging to console */
17395 + case 8: /* Set level of messages printed to console */
17398 + case 9: /* Number of chars in the log buffer */
17400 + case 10: /* Size of the log buffer */
17410 +/* virtual host info names */
17412 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17414 + struct nsproxy *nsproxy;
17415 + struct uts_namespace *uts;
17417 + if (id == VHIN_CONTEXT)
17418 + return vxi->vx_name;
17420 + nsproxy = vxi->space[0].vx_nsproxy;
17424 + uts = nsproxy->uts_ns;
17429 + case VHIN_SYSNAME:
17430 + return uts->name.sysname;
17431 + case VHIN_NODENAME:
17432 + return uts->name.nodename;
17433 + case VHIN_RELEASE:
17434 + return uts->name.release;
17435 + case VHIN_VERSION:
17436 + return uts->name.version;
17437 + case VHIN_MACHINE:
17438 + return uts->name.machine;
17439 + case VHIN_DOMAINNAME:
17440 + return uts->name.domainname;
17447 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17449 + struct vcmd_vhi_name_v0 vc_data;
17452 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17455 + name = vx_vhi_name(vxi, vc_data.field);
17459 + memcpy(name, vc_data.name, 65);
17463 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17465 + struct vcmd_vhi_name_v0 vc_data;
17468 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17471 + name = vx_vhi_name(vxi, vc_data.field);
17475 + memcpy(vc_data.name, name, 65);
17476 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17482 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17484 + struct vcmd_virt_stat_v0 vc_data;
17485 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17486 + struct timespec uptime;
17488 + do_posix_clock_monotonic_gettime(&uptime);
17489 + set_normalized_timespec(&uptime,
17490 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17491 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17493 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17494 + vc_data.uptime = timespec_to_ns(&uptime);
17495 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17496 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17497 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17498 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17499 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17500 + vc_data.load[0] = cvirt->load[0];
17501 + vc_data.load[1] = cvirt->load[1];
17502 + vc_data.load[2] = cvirt->load[2];
17504 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17510 +#ifdef CONFIG_VSERVER_VTIME
17512 +/* virtualized time base */
17514 +void vx_adjust_timespec(struct timespec *ts)
17516 + struct vx_info *vxi;
17518 + if (!vx_flags(VXF_VIRT_TIME, 0))
17521 + vxi = current_vx_info();
17522 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17523 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17525 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17527 + ts->tv_nsec -= NSEC_PER_SEC;
17528 + } else if (ts->tv_nsec < 0) {
17530 + ts->tv_nsec += NSEC_PER_SEC;
17534 +int vx_settimeofday(const struct timespec *ts)
17536 + struct timespec ats, delta;
17537 + struct vx_info *vxi;
17539 + if (!vx_flags(VXF_VIRT_TIME, 0))
17540 + return do_settimeofday(ts);
17542 + getnstimeofday(&ats);
17543 + delta = timespec_sub(*ts, ats);
17545 + vxi = current_vx_info();
17546 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17552 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
17553 --- linux-3.0.25/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17554 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cvirt_init.h 2011-06-10 22:11:24.000000000 +0200
17558 +extern uint64_t vx_idle_jiffies(void);
17560 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17562 + uint64_t idle_jiffies = vx_idle_jiffies();
17563 + uint64_t nsuptime;
17565 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17566 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17567 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17568 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17569 + cvirt->bias_ts.tv_sec = 0;
17570 + cvirt->bias_ts.tv_nsec = 0;
17572 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17573 + atomic_set(&cvirt->nr_threads, 0);
17574 + atomic_set(&cvirt->nr_running, 0);
17575 + atomic_set(&cvirt->nr_uninterruptible, 0);
17576 + atomic_set(&cvirt->nr_onhold, 0);
17578 + spin_lock_init(&cvirt->load_lock);
17579 + cvirt->load_last = jiffies;
17580 + atomic_set(&cvirt->load_updates, 0);
17581 + cvirt->load[0] = 0;
17582 + cvirt->load[1] = 0;
17583 + cvirt->load[2] = 0;
17584 + atomic_set(&cvirt->total_forks, 0);
17586 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17587 + init_waitqueue_head(&cvirt->syslog.log_wait);
17588 + cvirt->syslog.log_start = 0;
17589 + cvirt->syslog.log_end = 0;
17590 + cvirt->syslog.con_start = 0;
17591 + cvirt->syslog.logged_chars = 0;
17595 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17597 + // cvirt_pc->cpustat = { 0 };
17600 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17602 +#ifdef CONFIG_VSERVER_WARN
17605 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17606 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17608 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17609 + "!!! cvirt: %p[nr_running] = %d on exit.",
17611 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17612 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17614 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17615 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17621 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17626 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
17627 --- linux-3.0.25/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17628 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/cvirt_proc.h 2011-06-10 22:11:24.000000000 +0200
17630 +#ifndef _VX_CVIRT_PROC_H
17631 +#define _VX_CVIRT_PROC_H
17633 +#include <linux/nsproxy.h>
17634 +#include <linux/mnt_namespace.h>
17635 +#include <linux/ipc_namespace.h>
17636 +#include <linux/utsname.h>
17637 +#include <linux/ipc.h>
17641 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17643 + struct mnt_namespace *ns;
17644 + struct uts_namespace *uts;
17645 + struct ipc_namespace *ipc;
17646 + struct path path;
17647 + char *pstr, *root;
17653 + length += sprintf(buffer + length,
17654 + "NSProxy:\t%p [%p,%p,%p]\n",
17655 + nsproxy, nsproxy->mnt_ns,
17656 + nsproxy->uts_ns, nsproxy->ipc_ns);
17658 + ns = nsproxy->mnt_ns;
17662 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17666 + path.mnt = ns->root;
17667 + path.dentry = ns->root->mnt_root;
17668 + root = d_path(&path, pstr, PATH_MAX - 2);
17669 + length += sprintf(buffer + length,
17670 + "Namespace:\t%p [#%u]\n"
17671 + "RootPath:\t%s\n",
17672 + ns, atomic_read(&ns->count),
17677 + uts = nsproxy->uts_ns;
17681 + length += sprintf(buffer + length,
17682 + "SysName:\t%.*s\n"
17683 + "NodeName:\t%.*s\n"
17684 + "Release:\t%.*s\n"
17685 + "Version:\t%.*s\n"
17686 + "Machine:\t%.*s\n"
17687 + "DomainName:\t%.*s\n",
17688 + __NEW_UTS_LEN, uts->name.sysname,
17689 + __NEW_UTS_LEN, uts->name.nodename,
17690 + __NEW_UTS_LEN, uts->name.release,
17691 + __NEW_UTS_LEN, uts->name.version,
17692 + __NEW_UTS_LEN, uts->name.machine,
17693 + __NEW_UTS_LEN, uts->name.domainname);
17696 + ipc = nsproxy->ipc_ns;
17700 + length += sprintf(buffer + length,
17701 + "SEMS:\t\t%d %d %d %d %d\n"
17702 + "MSG:\t\t%d %d %d\n"
17703 + "SHM:\t\t%lu %lu %d %d\n",
17704 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17705 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17707 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17708 + (unsigned long)ipc->shm_ctlmax,
17709 + (unsigned long)ipc->shm_ctlall,
17710 + ipc->shm_ctlmni, ipc->shm_tot);
17717 +#include <linux/sched.h>
17719 +#define LOAD_INT(x) ((x) >> FSHIFT)
17720 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17723 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17728 + length += sprintf(buffer + length,
17729 + "BiasUptime:\t%lu.%02lu\n",
17730 + (unsigned long)cvirt->bias_uptime.tv_sec,
17731 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17733 + a = cvirt->load[0] + (FIXED_1 / 200);
17734 + b = cvirt->load[1] + (FIXED_1 / 200);
17735 + c = cvirt->load[2] + (FIXED_1 / 200);
17736 + length += sprintf(buffer + length,
17737 + "nr_threads:\t%d\n"
17738 + "nr_running:\t%d\n"
17739 + "nr_unintr:\t%d\n"
17740 + "nr_onhold:\t%d\n"
17741 + "load_updates:\t%d\n"
17742 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17743 + "total_forks:\t%d\n",
17744 + atomic_read(&cvirt->nr_threads),
17745 + atomic_read(&cvirt->nr_running),
17746 + atomic_read(&cvirt->nr_uninterruptible),
17747 + atomic_read(&cvirt->nr_onhold),
17748 + atomic_read(&cvirt->load_updates),
17749 + LOAD_INT(a), LOAD_FRAC(a),
17750 + LOAD_INT(b), LOAD_FRAC(b),
17751 + LOAD_INT(c), LOAD_FRAC(c),
17752 + atomic_read(&cvirt->total_forks));
17757 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17758 + char *buffer, int cpu)
17764 +#endif /* _VX_CVIRT_PROC_H */
17765 diff -NurpP --minimal linux-3.0.25/kernel/vserver/debug.c linux-3.0.25-vs2.3.2.3/kernel/vserver/debug.c
17766 --- linux-3.0.25/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17767 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/debug.c 2011-06-10 22:11:24.000000000 +0200
17770 + * kernel/vserver/debug.c
17772 + * Copyright (C) 2005-2007 Herbert Pötzl
17774 + * V0.01 vx_info dump support
17778 +#include <linux/module.h>
17780 +#include <linux/vserver/context.h>
17783 +void dump_vx_info(struct vx_info *vxi, int level)
17785 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17786 + atomic_read(&vxi->vx_usecnt),
17787 + atomic_read(&vxi->vx_tasks),
17790 + __dump_vx_limit(&vxi->limit);
17791 + __dump_vx_sched(&vxi->sched);
17792 + __dump_vx_cvirt(&vxi->cvirt);
17793 + __dump_vx_cacct(&vxi->cacct);
17799 +EXPORT_SYMBOL_GPL(dump_vx_info);
17801 diff -NurpP --minimal linux-3.0.25/kernel/vserver/device.c linux-3.0.25-vs2.3.2.3/kernel/vserver/device.c
17802 --- linux-3.0.25/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17803 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/device.c 2011-06-10 23:20:56.000000000 +0200
17806 + * linux/kernel/vserver/device.c
17808 + * Linux-VServer: Device Support
17810 + * Copyright (C) 2006 Herbert Pötzl
17811 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17813 + * V0.01 device mapping basics
17814 + * V0.02 added defaults
17818 +#include <linux/slab.h>
17819 +#include <linux/rcupdate.h>
17820 +#include <linux/fs.h>
17821 +#include <linux/namei.h>
17822 +#include <linux/hash.h>
17824 +#include <asm/errno.h>
17825 +#include <asm/uaccess.h>
17826 +#include <linux/vserver/base.h>
17827 +#include <linux/vserver/debug.h>
17828 +#include <linux/vserver/context.h>
17829 +#include <linux/vserver/device.h>
17830 +#include <linux/vserver/device_cmd.h>
17833 +#define DMAP_HASH_BITS 4
17836 +struct vs_mapping {
17838 + struct hlist_node hlist;
17839 + struct list_head list;
17841 +#define dm_hlist u.hlist
17842 +#define dm_list u.list
17845 + struct vx_dmap_target target;
17849 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17851 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17853 +static struct vx_dmap_target dmap_defaults[2] = {
17854 + { .flags = DATTR_OPEN },
17855 + { .flags = DATTR_OPEN },
17859 +struct kmem_cache *dmap_cachep __read_mostly;
17861 +int __init dmap_cache_init(void)
17863 + dmap_cachep = kmem_cache_create("dmap_cache",
17864 + sizeof(struct vs_mapping), 0,
17865 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17869 +__initcall(dmap_cache_init);
17872 +static inline unsigned int __hashval(dev_t dev, int bits)
17874 + return hash_long((unsigned long)dev, bits);
17878 +/* __hash_mapping()
17879 + * add the mapping to the hash table
17881 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17883 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17884 + struct hlist_head *head, *hash = dmap_main_hash;
17885 + int device = vdm->device;
17887 + spin_lock(hash_lock);
17888 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17889 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17891 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17892 + hlist_add_head(&vdm->dm_hlist, head);
17893 + spin_unlock(hash_lock);
17897 +static inline int __mode_to_default(umode_t mode)
17910 +/* __set_default()
17913 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17914 + struct vx_dmap_target *vdmt)
17916 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17917 + spin_lock(hash_lock);
17920 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17922 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17925 + spin_unlock(hash_lock);
17927 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17928 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17932 +/* __remove_default()
17933 + * remove a default
17935 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17937 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17938 + spin_lock(hash_lock);
17941 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17942 + else /* remove == reset */
17943 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17945 + spin_unlock(hash_lock);
17950 +/* __find_mapping()
17951 + * find a mapping in the hash table
17953 + * caller must hold hash_lock
17955 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17956 + struct vs_mapping **local, struct vs_mapping **global)
17958 + struct hlist_head *hash = dmap_main_hash;
17959 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17960 + struct hlist_node *pos;
17961 + struct vs_mapping *vdm;
17967 + hlist_for_each(pos, head) {
17968 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17970 + if ((vdm->device == device) &&
17971 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17972 + if (vdm->xid == xid) {
17975 + } else if (global && vdm->xid == 0)
17980 + if (global && *global)
17987 +/* __lookup_mapping()
17988 + * find a mapping and store the result in target and flags
17990 +static inline int __lookup_mapping(struct vx_info *vxi,
17991 + dev_t device, dev_t *target, int *flags, umode_t mode)
17993 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17994 + struct vs_mapping *vdm, *global;
17995 + struct vx_dmap_target *vdmt;
17997 + xid_t xid = vxi->vx_id;
18000 + spin_lock(hash_lock);
18001 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
18003 + vdmt = &vdm->target;
18007 + index = __mode_to_default(mode);
18008 + if (vxi && vxi->dmap.targets[index].flags) {
18010 + vdmt = &vxi->dmap.targets[index];
18011 + } else if (global) {
18013 + vdmt = &global->target;
18017 + vdmt = &dmap_defaults[index];
18021 + if (target && (vdmt->flags & DATTR_REMAP))
18022 + *target = vdmt->target;
18024 + *target = device;
18026 + *flags = vdmt->flags;
18028 + spin_unlock(hash_lock);
18034 +/* __remove_mapping()
18035 + * remove a mapping from the hash table
18037 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
18040 + spinlock_t *hash_lock = &dmap_main_hash_lock;
18041 + struct vs_mapping *vdm = NULL;
18044 + spin_lock(hash_lock);
18046 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
18048 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18049 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18052 + hlist_del(&vdm->dm_hlist);
18055 + spin_unlock(hash_lock);
18057 + kmem_cache_free(dmap_cachep, vdm);
18063 +int vs_map_device(struct vx_info *vxi,
18064 + dev_t device, dev_t *target, umode_t mode)
18066 + int ret, flags = DATTR_MASK;
18070 + *target = device;
18073 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18074 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18075 + device, target ? *target : 0, flags, mode, ret);
18077 + return (flags & DATTR_MASK);
18082 +static int do_set_mapping(struct vx_info *vxi,
18083 + dev_t device, dev_t target, int flags, umode_t mode)
18086 + struct vs_mapping *new;
18088 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18092 + INIT_HLIST_NODE(&new->dm_hlist);
18093 + new->device = device;
18094 + new->target.target = target;
18095 + new->target.flags = flags | mode;
18096 + new->xid = (vxi ? vxi->vx_id : 0);
18098 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18099 + __hash_mapping(vxi, new);
18101 + struct vx_dmap_target new = {
18102 + .target = target,
18103 + .flags = flags | mode,
18105 + __set_default(vxi, mode, &new);
18111 +static int do_unset_mapping(struct vx_info *vxi,
18112 + dev_t device, dev_t target, int flags, umode_t mode)
18114 + int ret = -EINVAL;
18117 + ret = __remove_mapping(vxi, device, mode);
18121 + ret = __remove_default(vxi, mode);
18131 +static inline int __user_device(const char __user *name, dev_t *dev,
18134 + struct nameidata nd;
18141 + ret = user_lpath(name, &nd.path);
18144 + if (nd.path.dentry->d_inode) {
18145 + *dev = nd.path.dentry->d_inode->i_rdev;
18146 + *mode = nd.path.dentry->d_inode->i_mode;
18148 + path_put(&nd.path);
18152 +static inline int __mapping_mode(dev_t device, dev_t target,
18153 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18156 + *mode = device_mode & S_IFMT;
18158 + *mode = target_mode & S_IFMT;
18162 + /* if both given, device and target mode have to match */
18163 + if (device && target &&
18164 + ((device_mode ^ target_mode) & S_IFMT))
18170 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18171 + const char __user *target_path, int flags, int set)
18173 + dev_t device = ~0, target = ~0;
18174 + umode_t device_mode = 0, target_mode = 0, mode;
18177 + ret = __user_device(device_path, &device, &device_mode);
18180 + ret = __user_device(target_path, &target, &target_mode);
18184 + ret = __mapping_mode(device, target,
18185 + device_mode, target_mode, &mode);
18190 + return do_set_mapping(vxi, device, target,
18193 + return do_unset_mapping(vxi, device, target,
18198 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18200 + struct vcmd_set_mapping_v0 vc_data;
18202 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18205 + return do_mapping(vxi, vc_data.device, vc_data.target,
18206 + vc_data.flags, 1);
18209 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18211 + struct vcmd_set_mapping_v0 vc_data;
18213 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18216 + return do_mapping(vxi, vc_data.device, vc_data.target,
18217 + vc_data.flags, 0);
18221 +#ifdef CONFIG_COMPAT
18223 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18225 + struct vcmd_set_mapping_v0_x32 vc_data;
18227 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18230 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18231 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18234 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18236 + struct vcmd_set_mapping_v0_x32 vc_data;
18238 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18241 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18242 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18245 +#endif /* CONFIG_COMPAT */
18248 diff -NurpP --minimal linux-3.0.25/kernel/vserver/dlimit.c linux-3.0.25-vs2.3.2.3/kernel/vserver/dlimit.c
18249 --- linux-3.0.25/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18250 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/dlimit.c 2011-06-10 23:20:56.000000000 +0200
18253 + * linux/kernel/vserver/dlimit.c
18255 + * Virtual Server: Context Disk Limits
18257 + * Copyright (C) 2004-2009 Herbert Pötzl
18259 + * V0.01 initial version
18260 + * V0.02 compat32 splitup
18261 + * V0.03 extended interface
18265 +#include <linux/statfs.h>
18266 +#include <linux/sched.h>
18267 +#include <linux/namei.h>
18268 +#include <linux/vs_tag.h>
18269 +#include <linux/vs_dlimit.h>
18270 +#include <linux/vserver/dlimit_cmd.h>
18271 +#include <linux/slab.h>
18272 +// #include <linux/gfp.h>
18274 +#include <asm/uaccess.h>
18276 +/* __alloc_dl_info()
18278 + * allocate an initialized dl_info struct
18279 + * doesn't make it visible (hash) */
18281 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18283 + struct dl_info *new = NULL;
18285 + vxdprintk(VXD_CBIT(dlim, 5),
18286 + "alloc_dl_info(%p,%d)*", sb, tag);
18288 + /* would this benefit from a slab cache? */
18289 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18293 + memset(new, 0, sizeof(struct dl_info));
18294 + new->dl_tag = tag;
18296 + // INIT_RCU_HEAD(&new->dl_rcu);
18297 + INIT_HLIST_NODE(&new->dl_hlist);
18298 + spin_lock_init(&new->dl_lock);
18299 + atomic_set(&new->dl_refcnt, 0);
18300 + atomic_set(&new->dl_usecnt, 0);
18302 + /* rest of init goes here */
18304 + vxdprintk(VXD_CBIT(dlim, 4),
18305 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18309 +/* __dealloc_dl_info()
18311 + * final disposal of dl_info */
18313 +static void __dealloc_dl_info(struct dl_info *dli)
18315 + vxdprintk(VXD_CBIT(dlim, 4),
18316 + "dealloc_dl_info(%p)", dli);
18318 + dli->dl_hlist.next = LIST_POISON1;
18319 + dli->dl_tag = -1;
18322 + BUG_ON(atomic_read(&dli->dl_usecnt));
18323 + BUG_ON(atomic_read(&dli->dl_refcnt));
18329 +/* hash table for dl_info hash */
18331 +#define DL_HASH_SIZE 13
18333 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18335 +static DEFINE_SPINLOCK(dl_info_hash_lock);
18338 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18340 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18345 +/* __hash_dl_info()
18347 + * add the dli to the global hash table
18348 + * requires the hash_lock to be held */
18350 +static inline void __hash_dl_info(struct dl_info *dli)
18352 + struct hlist_head *head;
18354 + vxdprintk(VXD_CBIT(dlim, 6),
18355 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18356 + get_dl_info(dli);
18357 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18358 + hlist_add_head_rcu(&dli->dl_hlist, head);
18361 +/* __unhash_dl_info()
18363 + * remove the dli from the global hash table
18364 + * requires the hash_lock to be held */
18366 +static inline void __unhash_dl_info(struct dl_info *dli)
18368 + vxdprintk(VXD_CBIT(dlim, 6),
18369 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18370 + hlist_del_rcu(&dli->dl_hlist);
18371 + put_dl_info(dli);
18375 +/* __lookup_dl_info()
18377 + * requires the rcu_read_lock()
18378 + * doesn't increment the dl_refcnt */
18380 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18382 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18383 + struct hlist_node *pos;
18384 + struct dl_info *dli;
18386 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18388 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18396 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18398 + struct dl_info *dli;
18401 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18402 + vxdprintk(VXD_CBIT(dlim, 7),
18403 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18404 + rcu_read_unlock();
18408 +void rcu_free_dl_info(struct rcu_head *head)
18410 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18411 + int usecnt, refcnt;
18413 + BUG_ON(!dli || !head);
18415 + usecnt = atomic_read(&dli->dl_usecnt);
18416 + BUG_ON(usecnt < 0);
18418 + refcnt = atomic_read(&dli->dl_refcnt);
18419 + BUG_ON(refcnt < 0);
18421 + vxdprintk(VXD_CBIT(dlim, 3),
18422 + "rcu_free_dl_info(%p)", dli);
18424 + __dealloc_dl_info(dli);
18426 + printk("!!! rcu didn't free\n");
18432 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18433 + uint32_t flags, int add)
18435 + struct path path;
18438 + ret = user_lpath(name, &path);
18440 + struct super_block *sb;
18441 + struct dl_info *dli;
18444 + if (!path.dentry->d_inode)
18445 + goto out_release;
18446 + if (!(sb = path.dentry->d_inode->i_sb))
18447 + goto out_release;
18450 + dli = __alloc_dl_info(sb, id);
18451 + spin_lock(&dl_info_hash_lock);
18454 + if (__lookup_dl_info(sb, id))
18456 + __hash_dl_info(dli);
18459 + spin_lock(&dl_info_hash_lock);
18460 + dli = __lookup_dl_info(sb, id);
18465 + __unhash_dl_info(dli);
18469 + spin_unlock(&dl_info_hash_lock);
18471 + __dealloc_dl_info(dli);
18478 +int vc_add_dlimit(uint32_t id, void __user *data)
18480 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18482 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18485 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18488 +int vc_rem_dlimit(uint32_t id, void __user *data)
18490 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18492 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18495 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18498 +#ifdef CONFIG_COMPAT
18500 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18502 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18504 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18507 + return do_addrem_dlimit(id,
18508 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18511 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18513 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18515 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18518 + return do_addrem_dlimit(id,
18519 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18522 +#endif /* CONFIG_COMPAT */
18526 +int do_set_dlimit(uint32_t id, const char __user *name,
18527 + uint32_t space_used, uint32_t space_total,
18528 + uint32_t inodes_used, uint32_t inodes_total,
18529 + uint32_t reserved, uint32_t flags)
18531 + struct path path;
18534 + ret = user_lpath(name, &path);
18536 + struct super_block *sb;
18537 + struct dl_info *dli;
18540 + if (!path.dentry->d_inode)
18541 + goto out_release;
18542 + if (!(sb = path.dentry->d_inode->i_sb))
18543 + goto out_release;
18545 + /* sanity checks */
18546 + if ((reserved != CDLIM_KEEP &&
18547 + reserved > 100) ||
18548 + (inodes_used != CDLIM_KEEP &&
18549 + inodes_used > inodes_total) ||
18550 + (space_used != CDLIM_KEEP &&
18551 + space_used > space_total))
18552 + goto out_release;
18555 + dli = locate_dl_info(sb, id);
18557 + goto out_release;
18559 + spin_lock(&dli->dl_lock);
18561 + if (inodes_used != CDLIM_KEEP)
18562 + dli->dl_inodes_used = inodes_used;
18563 + if (inodes_total != CDLIM_KEEP)
18564 + dli->dl_inodes_total = inodes_total;
18565 + if (space_used != CDLIM_KEEP)
18566 + dli->dl_space_used = dlimit_space_32to64(
18567 + space_used, flags, DLIMS_USED);
18569 + if (space_total == CDLIM_INFINITY)
18570 + dli->dl_space_total = DLIM_INFINITY;
18571 + else if (space_total != CDLIM_KEEP)
18572 + dli->dl_space_total = dlimit_space_32to64(
18573 + space_total, flags, DLIMS_TOTAL);
18575 + if (reserved != CDLIM_KEEP)
18576 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18578 + spin_unlock(&dli->dl_lock);
18580 + put_dl_info(dli);
18589 +int vc_set_dlimit(uint32_t id, void __user *data)
18591 + struct vcmd_ctx_dlimit_v0 vc_data;
18593 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18596 + return do_set_dlimit(id, vc_data.name,
18597 + vc_data.space_used, vc_data.space_total,
18598 + vc_data.inodes_used, vc_data.inodes_total,
18599 + vc_data.reserved, vc_data.flags);
18602 +#ifdef CONFIG_COMPAT
18604 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18606 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18608 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18611 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18612 + vc_data.space_used, vc_data.space_total,
18613 + vc_data.inodes_used, vc_data.inodes_total,
18614 + vc_data.reserved, vc_data.flags);
18617 +#endif /* CONFIG_COMPAT */
18621 +int do_get_dlimit(uint32_t id, const char __user *name,
18622 + uint32_t *space_used, uint32_t *space_total,
18623 + uint32_t *inodes_used, uint32_t *inodes_total,
18624 + uint32_t *reserved, uint32_t *flags)
18626 + struct path path;
18629 + ret = user_lpath(name, &path);
18631 + struct super_block *sb;
18632 + struct dl_info *dli;
18635 + if (!path.dentry->d_inode)
18636 + goto out_release;
18637 + if (!(sb = path.dentry->d_inode->i_sb))
18638 + goto out_release;
18641 + dli = locate_dl_info(sb, id);
18643 + goto out_release;
18645 + spin_lock(&dli->dl_lock);
18646 + *inodes_used = dli->dl_inodes_used;
18647 + *inodes_total = dli->dl_inodes_total;
18649 + *space_used = dlimit_space_64to32(
18650 + dli->dl_space_used, flags, DLIMS_USED);
18652 + if (dli->dl_space_total == DLIM_INFINITY)
18653 + *space_total = CDLIM_INFINITY;
18655 + *space_total = dlimit_space_64to32(
18656 + dli->dl_space_total, flags, DLIMS_TOTAL);
18658 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18659 + spin_unlock(&dli->dl_lock);
18661 + put_dl_info(dli);
18672 +int vc_get_dlimit(uint32_t id, void __user *data)
18674 + struct vcmd_ctx_dlimit_v0 vc_data;
18677 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18680 + ret = do_get_dlimit(id, vc_data.name,
18681 + &vc_data.space_used, &vc_data.space_total,
18682 + &vc_data.inodes_used, &vc_data.inodes_total,
18683 + &vc_data.reserved, &vc_data.flags);
18687 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18692 +#ifdef CONFIG_COMPAT
18694 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18696 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18699 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18702 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18703 + &vc_data.space_used, &vc_data.space_total,
18704 + &vc_data.inodes_used, &vc_data.inodes_total,
18705 + &vc_data.reserved, &vc_data.flags);
18709 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18714 +#endif /* CONFIG_COMPAT */
18717 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18719 + struct dl_info *dli;
18720 + __u64 blimit, bfree, bavail;
18723 + dli = locate_dl_info(sb, dx_current_tag());
18727 + spin_lock(&dli->dl_lock);
18728 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18731 + /* reduce max inodes available to limit */
18732 + if (buf->f_files > dli->dl_inodes_total)
18733 + buf->f_files = dli->dl_inodes_total;
18735 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18736 + /* reduce free inodes to min */
18737 + if (ifree < buf->f_ffree)
18738 + buf->f_ffree = ifree;
18741 + if (dli->dl_space_total == DLIM_INFINITY)
18744 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18746 + if (dli->dl_space_total < dli->dl_space_used)
18749 + bfree = (dli->dl_space_total - dli->dl_space_used)
18750 + >> sb->s_blocksize_bits;
18752 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18753 + if (bavail < dli->dl_space_used)
18756 + bavail = (bavail - dli->dl_space_used)
18757 + >> sb->s_blocksize_bits;
18759 + /* reduce max space available to limit */
18760 + if (buf->f_blocks > blimit)
18761 + buf->f_blocks = blimit;
18763 + /* reduce free space to min */
18764 + if (bfree < buf->f_bfree)
18765 + buf->f_bfree = bfree;
18767 + /* reduce avail space to min */
18768 + if (bavail < buf->f_bavail)
18769 + buf->f_bavail = bavail;
18772 + spin_unlock(&dli->dl_lock);
18773 + put_dl_info(dli);
18778 +#include <linux/module.h>
18780 +EXPORT_SYMBOL_GPL(locate_dl_info);
18781 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18783 diff -NurpP --minimal linux-3.0.25/kernel/vserver/helper.c linux-3.0.25-vs2.3.2.3/kernel/vserver/helper.c
18784 --- linux-3.0.25/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18785 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/helper.c 2011-06-10 22:11:24.000000000 +0200
18788 + * linux/kernel/vserver/helper.c
18790 + * Virtual Context Support
18792 + * Copyright (C) 2004-2007 Herbert Pötzl
18794 + * V0.01 basic helper
18798 +#include <linux/kmod.h>
18799 +#include <linux/reboot.h>
18800 +#include <linux/vs_context.h>
18801 +#include <linux/vs_network.h>
18802 +#include <linux/vserver/signal.h>
18805 +char vshelper_path[255] = "/sbin/vshelper";
18808 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18812 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
18813 + printk( KERN_WARNING
18814 + "%s: (%s %s) returned %s with %d\n",
18815 + name, argv[1], argv[2],
18816 + sync ? "sync" : "async", ret);
18818 + vxdprintk(VXD_CBIT(switch, 4),
18819 + "%s: (%s %s) returned %s with %d",
18820 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18825 + * vshelper path is set via /proc/sys
18826 + * invoked by vserver sys_reboot(), with
18827 + * the following arguments
18829 + * argv [0] = vshelper_path;
18830 + * argv [1] = action: "restart", "halt", "poweroff", ...
18831 + * argv [2] = context identifier
18833 + * envp [*] = type-specific parameters
18836 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18838 + char id_buf[8], cmd_buf[16];
18839 + char uid_buf[16], pid_buf[16];
18842 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18843 + char *envp[] = {"HOME=/", "TERM=linux",
18844 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18845 + uid_buf, pid_buf, cmd_buf, 0};
18847 + if (vx_info_state(vxi, VXS_HELPER))
18849 + vxi->vx_state |= VXS_HELPER;
18851 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18853 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18854 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
18855 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
18858 + case LINUX_REBOOT_CMD_RESTART:
18859 + argv[1] = "restart";
18862 + case LINUX_REBOOT_CMD_HALT:
18863 + argv[1] = "halt";
18866 + case LINUX_REBOOT_CMD_POWER_OFF:
18867 + argv[1] = "poweroff";
18870 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18871 + argv[1] = "swsusp";
18874 + case LINUX_REBOOT_CMD_OOM:
18879 + vxi->vx_state &= ~VXS_HELPER;
18883 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18884 + vxi->vx_state &= ~VXS_HELPER;
18885 + __wakeup_vx_info(vxi);
18886 + return (ret) ? -EPERM : 0;
18890 +long vs_reboot(unsigned int cmd, void __user *arg)
18892 + struct vx_info *vxi = current_vx_info();
18895 + vxdprintk(VXD_CBIT(misc, 5),
18896 + "vs_reboot(%p[#%d],%u)",
18897 + vxi, vxi ? vxi->vx_id : 0, cmd);
18899 + ret = vs_reboot_helper(vxi, cmd, arg);
18903 + vxi->reboot_cmd = cmd;
18904 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18906 + case LINUX_REBOOT_CMD_RESTART:
18907 + case LINUX_REBOOT_CMD_HALT:
18908 + case LINUX_REBOOT_CMD_POWER_OFF:
18909 + vx_info_kill(vxi, 0, SIGKILL);
18910 + vx_info_kill(vxi, 1, SIGKILL);
18918 +long vs_oom_action(unsigned int cmd)
18920 + struct vx_info *vxi = current_vx_info();
18923 + vxdprintk(VXD_CBIT(misc, 5),
18924 + "vs_oom_action(%p[#%d],%u)",
18925 + vxi, vxi ? vxi->vx_id : 0, cmd);
18927 + ret = vs_reboot_helper(vxi, cmd, NULL);
18931 + vxi->reboot_cmd = cmd;
18932 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18933 + vx_info_kill(vxi, 0, SIGKILL);
18934 + vx_info_kill(vxi, 1, SIGKILL);
18940 + * argv [0] = vshelper_path;
18941 + * argv [1] = action: "startup", "shutdown"
18942 + * argv [2] = context identifier
18944 + * envp [*] = type-specific parameters
18947 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18949 + char id_buf[8], cmd_buf[16];
18950 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18951 + char *envp[] = {"HOME=/", "TERM=linux",
18952 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18954 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18957 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18958 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18961 + case VSC_STARTUP:
18962 + argv[1] = "startup";
18964 + case VSC_SHUTDOWN:
18965 + argv[1] = "shutdown";
18971 + return do_vshelper(vshelper_path, argv, envp, 1);
18976 + * argv [0] = vshelper_path;
18977 + * argv [1] = action: "netup", "netdown"
18978 + * argv [2] = context identifier
18980 + * envp [*] = type-specific parameters
18983 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18985 + char id_buf[8], cmd_buf[16];
18986 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18987 + char *envp[] = {"HOME=/", "TERM=linux",
18988 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18990 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18993 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
18994 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18998 + argv[1] = "netup";
19000 + case VSC_NETDOWN:
19001 + argv[1] = "netdown";
19007 + return do_vshelper(vshelper_path, argv, envp, 1);
19010 diff -NurpP --minimal linux-3.0.25/kernel/vserver/history.c linux-3.0.25-vs2.3.2.3/kernel/vserver/history.c
19011 --- linux-3.0.25/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
19012 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/history.c 2011-06-10 22:11:24.000000000 +0200
19015 + * kernel/vserver/history.c
19017 + * Virtual Context History Backtrace
19019 + * Copyright (C) 2004-2007 Herbert Pötzl
19021 + * V0.01 basic structure
19022 + * V0.02 hash/unhash and trace
19023 + * V0.03 preemption fixes
19027 +#include <linux/module.h>
19028 +#include <asm/uaccess.h>
19030 +#include <linux/vserver/context.h>
19031 +#include <linux/vserver/debug.h>
19032 +#include <linux/vserver/debug_cmd.h>
19033 +#include <linux/vserver/history.h>
19036 +#ifdef CONFIG_VSERVER_HISTORY
19037 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
19039 +#define VXH_SIZE 64
19042 +struct _vx_history {
19043 + unsigned int counter;
19045 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19049 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19051 +unsigned volatile int vxh_active = 1;
19053 +static atomic_t sequence = ATOMIC_INIT(0);
19058 + * requires disabled preemption */
19060 +struct _vx_hist_entry *vxh_advance(void *loc)
19062 + unsigned int cpu = smp_processor_id();
19063 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19064 + struct _vx_hist_entry *entry;
19065 + unsigned int index;
19067 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19068 + entry = &hist->entry[index];
19070 + entry->seq = atomic_inc_return(&sequence);
19071 + entry->loc = loc;
19075 +EXPORT_SYMBOL_GPL(vxh_advance);
19078 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19080 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19083 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19085 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19086 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19087 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19088 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19090 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19092 + switch (e->type) {
19093 + case VXH_THROW_OOPS:
19094 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19097 + case VXH_GET_VX_INFO:
19098 + case VXH_PUT_VX_INFO:
19099 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19101 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19102 + VXH_VXI_ARGS(e));
19105 + case VXH_INIT_VX_INFO:
19106 + case VXH_SET_VX_INFO:
19107 + case VXH_CLR_VX_INFO:
19108 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19110 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19111 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19112 + VXH_VXI_ARGS(e), e->sc.data);
19115 + case VXH_CLAIM_VX_INFO:
19116 + case VXH_RELEASE_VX_INFO:
19117 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19119 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19120 + VXH_VXI_ARGS(e), e->sc.data);
19123 + case VXH_ALLOC_VX_INFO:
19124 + case VXH_DEALLOC_VX_INFO:
19125 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19127 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19128 + VXH_VXI_ARGS(e));
19131 + case VXH_HASH_VX_INFO:
19132 + case VXH_UNHASH_VX_INFO:
19133 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19135 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19136 + VXH_VXI_ARGS(e));
19139 + case VXH_LOC_VX_INFO:
19140 + case VXH_LOOKUP_VX_INFO:
19141 + case VXH_CREATE_VX_INFO:
19142 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19144 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19145 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19146 + e->ll.arg, VXH_VXI_ARGS(e));
19151 +static void __vxh_dump_history(void)
19153 + unsigned int i, cpu;
19155 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19156 + atomic_read(&sequence), NR_CPUS);
19158 + for (i = 0; i < VXH_SIZE; i++) {
19159 + for_each_online_cpu(cpu) {
19160 + struct _vx_history *hist =
19161 + &per_cpu(vx_history_buffer, cpu);
19162 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19163 + struct _vx_hist_entry *entry = &hist->entry[index];
19165 + vxh_dump_entry(entry, cpu);
19170 +void vxh_dump_history(void)
19174 + local_irq_enable();
19176 + local_irq_disable();
19178 + __vxh_dump_history();
19182 +/* vserver syscall commands below here */
19185 +int vc_dump_history(uint32_t id)
19188 + __vxh_dump_history();
19195 +int do_read_history(struct __user _vx_hist_entry *data,
19196 + int cpu, uint32_t *index, uint32_t *count)
19198 + int pos, ret = 0;
19199 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19200 + int end = hist->counter;
19201 + int start = end - VXH_SIZE + 2;
19202 + int idx = *index;
19204 + /* special case: get current pos */
19210 + /* have we lost some data? */
19214 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19215 + struct _vx_hist_entry *entry =
19216 + &hist->entry[idx % VXH_SIZE];
19218 + /* send entry to userspace */
19219 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19223 + /* save new index and count */
19226 + return ret ? ret : (*index < end);
19229 +int vc_read_history(uint32_t id, void __user *data)
19231 + struct vcmd_read_history_v0 vc_data;
19234 + if (id >= NR_CPUS)
19237 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19240 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19241 + id, &vc_data.index, &vc_data.count);
19243 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19248 +#ifdef CONFIG_COMPAT
19250 +int vc_read_history_x32(uint32_t id, void __user *data)
19252 + struct vcmd_read_history_v0_x32 vc_data;
19255 + if (id >= NR_CPUS)
19258 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19261 + ret = do_read_history((struct __user _vx_hist_entry *)
19262 + compat_ptr(vc_data.data_ptr),
19263 + id, &vc_data.index, &vc_data.count);
19265 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19270 +#endif /* CONFIG_COMPAT */
19272 diff -NurpP --minimal linux-3.0.25/kernel/vserver/inet.c linux-3.0.25-vs2.3.2.3/kernel/vserver/inet.c
19273 --- linux-3.0.25/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19274 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/inet.c 2011-08-30 20:14:33.000000000 +0200
19277 +#include <linux/in.h>
19278 +#include <linux/inetdevice.h>
19279 +#include <linux/vs_inet.h>
19280 +#include <linux/vs_inet6.h>
19281 +#include <linux/vserver/debug.h>
19282 +#include <net/route.h>
19283 +#include <net/addrconf.h>
19286 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19290 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19293 + struct nx_addr_v4 *ptr;
19295 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19296 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19303 + vxdprintk(VXD_CBIT(net, 2),
19304 + "nx_v4_addr_conflict(%p,%p): %d",
19305 + nxi1, nxi2, ret);
19311 +#ifdef CONFIG_IPV6
19313 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19317 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19320 + struct nx_addr_v6 *ptr;
19322 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19323 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19330 + vxdprintk(VXD_CBIT(net, 2),
19331 + "nx_v6_addr_conflict(%p,%p): %d",
19332 + nxi1, nxi2, ret);
19339 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19341 + struct in_device *in_dev;
19342 + struct in_ifaddr **ifap;
19343 + struct in_ifaddr *ifa;
19348 + in_dev = in_dev_get(dev);
19352 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19353 + ifap = &ifa->ifa_next) {
19354 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19359 + in_dev_put(in_dev);
19365 +#ifdef CONFIG_IPV6
19367 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19369 + struct inet6_dev *in_dev;
19370 + struct inet6_ifaddr *ifa;
19375 + in_dev = in6_dev_get(dev);
19379 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19380 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19381 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19386 + in6_dev_put(in_dev);
19393 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19399 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19401 +#ifdef CONFIG_IPV6
19403 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19408 + vxdprintk(VXD_CBIT(net, 3),
19409 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19410 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19414 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
19415 + struct flowi4 *fl4)
19417 + struct rtable *rt;
19422 + /* FIXME: handle lback only case */
19423 + if (!NX_IPV4(nxi))
19424 + return ERR_PTR(-EPERM);
19426 + vxdprintk(VXD_CBIT(net, 4),
19427 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19428 + nxi, nxi ? nxi->nx_id : 0,
19429 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
19431 + /* single IP is unconditional */
19432 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19433 + (fl4->saddr == INADDR_ANY))
19434 + fl4->saddr = nxi->v4.ip[0].s_addr;
19436 + if (fl4->saddr == INADDR_ANY) {
19437 + struct nx_addr_v4 *ptr;
19438 + __be32 found = 0;
19440 + rt = __ip_route_output_key(net, fl4);
19441 + if (!IS_ERR(rt)) {
19442 + found = fl4->saddr;
19444 + vxdprintk(VXD_CBIT(net, 4),
19445 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19446 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
19447 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19451 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19452 + __be32 primary = ptr->ip[0].s_addr;
19453 + __be32 mask = ptr->mask.s_addr;
19454 + __be32 neta = primary & mask;
19456 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19457 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19458 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19459 + NIPQUAD(mask), NIPQUAD(neta));
19460 + if ((found & mask) != neta)
19463 + fl4->saddr = primary;
19464 + rt = __ip_route_output_key(net, fl4);
19465 + vxdprintk(VXD_CBIT(net, 4),
19466 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19467 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
19468 + if (!IS_ERR(rt)) {
19469 + found = fl4->saddr;
19471 + if (found == primary)
19475 + /* still no source ip? */
19476 + found = ipv4_is_loopback(fl4->daddr)
19477 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19479 + /* assign src ip to flow */
19480 + fl4->saddr = found;
19483 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
19484 + return ERR_PTR(-EPERM);
19487 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19488 + if (ipv4_is_loopback(fl4->daddr))
19489 + fl4->daddr = nxi->v4_lback.s_addr;
19490 + if (ipv4_is_loopback(fl4->saddr))
19491 + fl4->saddr = nxi->v4_lback.s_addr;
19492 + } else if (ipv4_is_loopback(fl4->daddr) &&
19493 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19494 + return ERR_PTR(-EPERM);
19499 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19501 diff -NurpP --minimal linux-3.0.25/kernel/vserver/init.c linux-3.0.25-vs2.3.2.3/kernel/vserver/init.c
19502 --- linux-3.0.25/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19503 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/init.c 2011-06-10 22:11:24.000000000 +0200
19506 + * linux/kernel/init.c
19508 + * Virtual Server Init
19510 + * Copyright (C) 2004-2007 Herbert Pötzl
19512 + * V0.01 basic structure
19516 +#include <linux/init.h>
19518 +int vserver_register_sysctl(void);
19519 +void vserver_unregister_sysctl(void);
19522 +static int __init init_vserver(void)
19526 +#ifdef CONFIG_VSERVER_DEBUG
19527 + vserver_register_sysctl();
19533 +static void __exit exit_vserver(void)
19536 +#ifdef CONFIG_VSERVER_DEBUG
19537 + vserver_unregister_sysctl();
19542 +/* FIXME: GFP_ZONETYPES gone
19543 +long vx_slab[GFP_ZONETYPES]; */
19547 +module_init(init_vserver);
19548 +module_exit(exit_vserver);
19550 diff -NurpP --minimal linux-3.0.25/kernel/vserver/inode.c linux-3.0.25-vs2.3.2.3/kernel/vserver/inode.c
19551 --- linux-3.0.25/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19552 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/inode.c 2012-01-24 01:46:36.000000000 +0100
19555 + * linux/kernel/vserver/inode.c
19557 + * Virtual Server: File System Support
19559 + * Copyright (C) 2004-2007 Herbert Pötzl
19561 + * V0.01 separated from vcontext V0.05
19562 + * V0.02 moved to tag (instead of xid)
19566 +#include <linux/tty.h>
19567 +#include <linux/proc_fs.h>
19568 +#include <linux/devpts_fs.h>
19569 +#include <linux/fs.h>
19570 +#include <linux/file.h>
19571 +#include <linux/mount.h>
19572 +#include <linux/parser.h>
19573 +#include <linux/namei.h>
19574 +#include <linux/vserver/inode.h>
19575 +#include <linux/vserver/inode_cmd.h>
19576 +#include <linux/vs_base.h>
19577 +#include <linux/vs_tag.h>
19579 +#include <asm/uaccess.h>
19582 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19584 + struct proc_dir_entry *entry;
19586 + if (!in || !in->i_sb)
19589 + *flags = IATTR_TAG
19590 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19591 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19592 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19593 + | (IS_COW(in) ? IATTR_COW : 0);
19594 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19596 + if (S_ISDIR(in->i_mode))
19597 + *mask |= IATTR_BARRIER;
19599 + if (IS_TAGGED(in)) {
19600 + *tag = in->i_tag;
19601 + *mask |= IATTR_TAG;
19604 + switch (in->i_sb->s_magic) {
19605 + case PROC_SUPER_MAGIC:
19606 + entry = PROC_I(in)->pde;
19608 + /* check for specific inodes? */
19610 + *mask |= IATTR_FLAGS;
19612 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19614 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19617 + case DEVPTS_SUPER_MAGIC:
19618 + *tag = in->i_tag;
19619 + *mask |= IATTR_TAG;
19628 +int vc_get_iattr(void __user *data)
19630 + struct path path;
19631 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19634 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19637 + ret = user_lpath(vc_data.name, &path);
19639 + ret = __vc_get_iattr(path.dentry->d_inode,
19640 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19646 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19651 +#ifdef CONFIG_COMPAT
19653 +int vc_get_iattr_x32(void __user *data)
19655 + struct path path;
19656 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19659 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19662 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19664 + ret = __vc_get_iattr(path.dentry->d_inode,
19665 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19671 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19676 +#endif /* CONFIG_COMPAT */
19679 +int vc_fget_iattr(uint32_t fd, void __user *data)
19681 + struct file *filp;
19682 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19685 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19689 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19692 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19693 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19697 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19703 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19705 + struct inode *in = de->d_inode;
19706 + int error = 0, is_proc = 0, has_tag = 0;
19707 + struct iattr attr = { 0 };
19709 + if (!in || !in->i_sb)
19712 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19713 + if ((*mask & IATTR_FLAGS) && !is_proc)
19716 + has_tag = IS_TAGGED(in) ||
19717 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19718 + if ((*mask & IATTR_TAG) && !has_tag)
19721 + mutex_lock(&in->i_mutex);
19722 + if (*mask & IATTR_TAG) {
19723 + attr.ia_tag = *tag;
19724 + attr.ia_valid |= ATTR_TAG;
19727 + if (*mask & IATTR_FLAGS) {
19728 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19729 + unsigned int iflags = PROC_I(in)->vx_flags;
19731 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19732 + | (*flags & IATTR_FLAGS);
19733 + PROC_I(in)->vx_flags = iflags;
19735 + entry->vx_flags = iflags;
19738 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19739 + IATTR_BARRIER | IATTR_COW)) {
19740 + int iflags = in->i_flags;
19741 + int vflags = in->i_vflags;
19743 + if (*mask & IATTR_IMMUTABLE) {
19744 + if (*flags & IATTR_IMMUTABLE)
19745 + iflags |= S_IMMUTABLE;
19747 + iflags &= ~S_IMMUTABLE;
19749 + if (*mask & IATTR_IXUNLINK) {
19750 + if (*flags & IATTR_IXUNLINK)
19751 + iflags |= S_IXUNLINK;
19753 + iflags &= ~S_IXUNLINK;
19755 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19756 + if (*flags & IATTR_BARRIER)
19757 + vflags |= V_BARRIER;
19759 + vflags &= ~V_BARRIER;
19761 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19762 + if (*flags & IATTR_COW)
19765 + vflags &= ~V_COW;
19767 + if (in->i_op && in->i_op->sync_flags) {
19768 + error = in->i_op->sync_flags(in, iflags, vflags);
19774 + if (attr.ia_valid) {
19775 + if (in->i_op && in->i_op->setattr)
19776 + error = in->i_op->setattr(de, &attr);
19778 + error = inode_change_ok(in, &attr);
19780 + setattr_copy(in, &attr);
19781 + mark_inode_dirty(in);
19787 + mutex_unlock(&in->i_mutex);
19791 +int vc_set_iattr(void __user *data)
19793 + struct path path;
19794 + struct vcmd_ctx_iattr_v1 vc_data;
19797 + if (!capable(CAP_LINUX_IMMUTABLE))
19799 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19802 + ret = user_lpath(vc_data.name, &path);
19804 + ret = __vc_set_iattr(path.dentry,
19805 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19809 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19814 +#ifdef CONFIG_COMPAT
19816 +int vc_set_iattr_x32(void __user *data)
19818 + struct path path;
19819 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19822 + if (!capable(CAP_LINUX_IMMUTABLE))
19824 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19827 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19829 + ret = __vc_set_iattr(path.dentry,
19830 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19834 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19839 +#endif /* CONFIG_COMPAT */
19841 +int vc_fset_iattr(uint32_t fd, void __user *data)
19843 + struct file *filp;
19844 + struct vcmd_ctx_fiattr_v0 vc_data;
19847 + if (!capable(CAP_LINUX_IMMUTABLE))
19849 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19853 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19856 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19857 + &vc_data.flags, &vc_data.mask);
19861 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19867 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19869 +static match_table_t tokens = {
19870 + {Opt_notagcheck, "notagcheck"},
19871 +#ifdef CONFIG_PROPAGATE
19872 + {Opt_notag, "notag"},
19873 + {Opt_tag, "tag"},
19874 + {Opt_tagid, "tagid=%u"},
19880 +static void __dx_parse_remove(char *string, char *opt)
19882 + char *p = strstr(string, opt);
19886 + while (*q != '\0' && *q != ',')
19895 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19896 + unsigned long *flags)
19899 + substring_t args[MAX_OPT_ARGS];
19901 + char *s, *p, *opts;
19902 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19908 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19913 + while ((p = strsep(&opts, ",")) != NULL) {
19914 + token = match_token(p, tokens, args);
19917 +#ifdef CONFIG_PROPAGATE
19922 + __dx_parse_remove(s, "tag");
19923 + *mnt_flags |= MNT_TAGID;
19924 + set |= MNT_TAGID;
19928 + __dx_parse_remove(s, "notag");
19929 + *mnt_flags |= MNT_NOTAG;
19930 + set |= MNT_NOTAG;
19933 + if (tag && !match_int(args, &option))
19936 + __dx_parse_remove(s, "tagid");
19937 + *mnt_flags |= MNT_TAGID;
19938 + set |= MNT_TAGID;
19941 + case Opt_notagcheck:
19943 + __dx_parse_remove(s, "notagcheck");
19944 + *flags |= MS_NOTAGCHECK;
19945 + set |= MS_NOTAGCHECK;
19948 + vxdprintk(VXD_CBIT(tag, 7),
19949 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19950 + p, token, option);
19953 + strcpy(string, s);
19958 +#ifdef CONFIG_PROPAGATE
19960 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19962 + tag_t new_tag = 0;
19963 + struct vfsmount *mnt;
19968 + mnt = nd->path.mnt;
19972 + propagate = (mnt->mnt_flags & MNT_TAGID);
19974 + new_tag = mnt->mnt_tag;
19976 + vxdprintk(VXD_CBIT(tag, 7),
19977 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19978 + inode, inode->i_ino, inode->i_tag,
19979 + new_tag, (propagate) ? 1 : 0);
19982 + inode->i_tag = new_tag;
19985 +#include <linux/module.h>
19987 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19989 +#endif /* CONFIG_PROPAGATE */
19991 diff -NurpP --minimal linux-3.0.25/kernel/vserver/limit.c linux-3.0.25-vs2.3.2.3/kernel/vserver/limit.c
19992 --- linux-3.0.25/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
19993 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/limit.c 2011-10-11 20:48:08.000000000 +0200
19996 + * linux/kernel/vserver/limit.c
19998 + * Virtual Server: Context Limits
20000 + * Copyright (C) 2004-2010 Herbert Pötzl
20002 + * V0.01 broken out from vcontext V0.05
20003 + * V0.02 changed vcmds to vxi arg
20004 + * V0.03 added memory cgroup support
20008 +#include <linux/sched.h>
20009 +#include <linux/module.h>
20010 +#include <linux/memcontrol.h>
20011 +#include <linux/res_counter.h>
20012 +#include <linux/vs_limit.h>
20013 +#include <linux/vserver/limit.h>
20014 +#include <linux/vserver/limit_cmd.h>
20016 +#include <asm/uaccess.h>
20019 +const char *vlimit_name[NUM_LIMITS] = {
20020 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20021 + [RLIMIT_RSS] = "RSS",
20022 + [RLIMIT_AS] = "VM",
20023 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20024 + [RLIMIT_CPU] = "CPU",
20025 + [RLIMIT_NPROC] = "NPROC",
20026 + [RLIMIT_NOFILE] = "NOFILE",
20027 + [RLIMIT_LOCKS] = "LOCKS",
20028 + [RLIMIT_SIGPENDING] = "SIGP",
20029 + [RLIMIT_MSGQUEUE] = "MSGQ",
20031 + [VLIMIT_NSOCK] = "NSOCK",
20032 + [VLIMIT_OPENFD] = "OPENFD",
20033 + [VLIMIT_SHMEM] = "SHMEM",
20034 + [VLIMIT_DENTRY] = "DENTRY",
20037 +EXPORT_SYMBOL_GPL(vlimit_name);
20039 +#define MASK_ENTRY(x) (1 << (x))
20041 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
20044 + , /* softlimit */
20045 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20046 + MASK_ENTRY( RLIMIT_RSS ) |
20047 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20050 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20051 + MASK_ENTRY( RLIMIT_RSS ) |
20052 + MASK_ENTRY( RLIMIT_AS ) |
20053 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20054 + MASK_ENTRY( RLIMIT_NPROC ) |
20055 + MASK_ENTRY( RLIMIT_NOFILE ) |
20056 + MASK_ENTRY( RLIMIT_LOCKS ) |
20057 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20059 + MASK_ENTRY( VLIMIT_NSOCK ) |
20060 + MASK_ENTRY( VLIMIT_OPENFD ) |
20061 + MASK_ENTRY( VLIMIT_SHMEM ) |
20062 + MASK_ENTRY( VLIMIT_DENTRY ) |
20065 + /* accounting only */
20066 +uint32_t account_mask =
20067 + MASK_ENTRY( VLIMIT_SEMARY ) |
20068 + MASK_ENTRY( VLIMIT_NSEMS ) |
20069 + MASK_ENTRY( VLIMIT_MAPPED ) |
20073 +static int is_valid_vlimit(int id)
20075 + uint32_t mask = vlimit_mask.minimum |
20076 + vlimit_mask.softlimit | vlimit_mask.maximum;
20077 + return mask & (1 << id);
20080 +static int is_accounted_vlimit(int id)
20082 + if (is_valid_vlimit(id))
20084 + return account_mask & (1 << id);
20088 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20090 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20091 + return VX_VLIM(limit);
20094 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20096 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20097 + return VX_VLIM(limit);
20100 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20101 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20103 + if (!is_valid_vlimit(id))
20107 + *minimum = CRLIM_UNSET;
20109 + *softlimit = vc_get_soft(vxi, id);
20111 + *maximum = vc_get_hard(vxi, id);
20115 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20117 + struct vcmd_ctx_rlimit_v0 vc_data;
20120 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20123 + ret = do_get_rlimit(vxi, vc_data.id,
20124 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20128 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20133 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20134 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20136 + if (!is_valid_vlimit(id))
20139 + if (maximum != CRLIM_KEEP)
20140 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20141 + if (softlimit != CRLIM_KEEP)
20142 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20144 + /* clamp soft limit */
20145 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20146 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20151 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20153 + struct vcmd_ctx_rlimit_v0 vc_data;
20155 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20158 + return do_set_rlimit(vxi, vc_data.id,
20159 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20162 +#ifdef CONFIG_IA32_EMULATION
20164 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20166 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20168 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20171 + return do_set_rlimit(vxi, vc_data.id,
20172 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20175 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20177 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20180 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20183 + ret = do_get_rlimit(vxi, vc_data.id,
20184 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20188 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20193 +#endif /* CONFIG_IA32_EMULATION */
20196 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20198 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20204 +static inline void vx_reset_hits(struct _vx_limit *limit)
20208 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20209 + atomic_set(&__rlim_lhit(limit, lim), 0);
20213 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
20215 + vx_reset_hits(&vxi->limit);
20219 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20224 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20225 + value = __rlim_get(limit, lim);
20226 + __rlim_rmax(limit, lim) = value;
20227 + __rlim_rmin(limit, lim) = value;
20231 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20233 + vx_reset_minmax(&vxi->limit);
20238 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20240 + struct vcmd_rlimit_stat_v0 vc_data;
20241 + struct _vx_limit *limit = &vxi->limit;
20244 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20248 + if (!is_accounted_vlimit(id))
20251 + vx_limit_fixup(limit, id);
20252 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20253 + vc_data.value = __rlim_get(limit, id);
20254 + vc_data.minimum = __rlim_rmin(limit, id);
20255 + vc_data.maximum = __rlim_rmax(limit, id);
20257 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20263 +void vx_vsi_meminfo(struct sysinfo *val)
20265 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20266 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20267 + u64 res_limit, res_usage;
20272 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20273 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20275 + if (res_limit != RESOURCE_MAX)
20276 + val->totalram = (res_limit >> PAGE_SHIFT);
20277 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20278 + val->bufferram = 0;
20279 + val->totalhigh = 0;
20280 + val->freehigh = 0;
20281 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20285 +void vx_vsi_swapinfo(struct sysinfo *val)
20287 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20288 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20289 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20290 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20291 + s64 swap_limit, swap_usage;
20296 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20297 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20298 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20299 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20301 + /* memory unlimited */
20302 + if (res_limit == RESOURCE_MAX)
20305 + swap_limit = memsw_limit - res_limit;
20306 + /* we have a swap limit? */
20307 + if (memsw_limit != RESOURCE_MAX)
20308 + val->totalswap = swap_limit >> PAGE_SHIFT;
20310 + /* calculate swap part */
20311 + swap_usage = (memsw_usage > res_usage) ?
20312 + memsw_usage - res_usage : 0;
20314 + /* total shown minus usage gives free swap */
20315 + val->freeswap = (swap_usage < swap_limit) ?
20316 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20317 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20318 + val->totalswap = 0;
20319 + val->freeswap = 0;
20320 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20321 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20325 +long vx_vsi_cached(struct sysinfo *val)
20327 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20328 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20330 + return mem_cgroup_stat_read_cache(mcg);
20337 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20339 + struct vx_info *vxi = mm->mm_vx_info;
20340 + unsigned long points;
20346 + points = vxi->vx_badness_bias;
20348 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20349 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20350 + points += (v > w) ? (v - w) : 0;
20355 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
20356 --- linux-3.0.25/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20357 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/limit_init.h 2011-06-10 22:11:24.000000000 +0200
20361 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20365 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20366 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20367 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20368 + __rlim_set(limit, lim, 0);
20369 + atomic_set(&__rlim_lhit(limit, lim), 0);
20370 + __rlim_rmin(limit, lim) = 0;
20371 + __rlim_rmax(limit, lim) = 0;
20375 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20380 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20381 + if ((1 << lim) & VLIM_NOCHECK)
20383 + value = __rlim_get(limit, lim);
20384 + vxwprintk_xid(value,
20385 + "!!! limit: %p[%s,%d] = %ld on exit.",
20386 + limit, vlimit_name[lim], lim, (long)value);
20390 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
20391 --- linux-3.0.25/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20392 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/limit_proc.h 2011-06-10 22:11:24.000000000 +0200
20394 +#ifndef _VX_LIMIT_PROC_H
20395 +#define _VX_LIMIT_PROC_H
20397 +#include <linux/vserver/limit_int.h>
20400 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20401 +#define VX_LIMIT_TOP \
20402 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20404 +#define VX_LIMIT_ARG(r) \
20405 + (unsigned long)__rlim_get(limit, r), \
20406 + (unsigned long)__rlim_rmin(limit, r), \
20407 + (unsigned long)__rlim_rmax(limit, r), \
20408 + VX_VLIM(__rlim_soft(limit, r)), \
20409 + VX_VLIM(__rlim_hard(limit, r)), \
20410 + atomic_read(&__rlim_lhit(limit, r))
20412 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20414 + vx_limit_fixup(limit, -1);
20415 + return sprintf(buffer, VX_LIMIT_TOP
20416 + "PROC" VX_LIMIT_FMT
20417 + "VM" VX_LIMIT_FMT
20418 + "VML" VX_LIMIT_FMT
20419 + "RSS" VX_LIMIT_FMT
20420 + "ANON" VX_LIMIT_FMT
20421 + "RMAP" VX_LIMIT_FMT
20422 + "FILES" VX_LIMIT_FMT
20423 + "OFD" VX_LIMIT_FMT
20424 + "LOCKS" VX_LIMIT_FMT
20425 + "SOCK" VX_LIMIT_FMT
20426 + "MSGQ" VX_LIMIT_FMT
20427 + "SHM" VX_LIMIT_FMT
20428 + "SEMA" VX_LIMIT_FMT
20429 + "SEMS" VX_LIMIT_FMT
20430 + "DENT" VX_LIMIT_FMT,
20431 + VX_LIMIT_ARG(RLIMIT_NPROC),
20432 + VX_LIMIT_ARG(RLIMIT_AS),
20433 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20434 + VX_LIMIT_ARG(RLIMIT_RSS),
20435 + VX_LIMIT_ARG(VLIMIT_ANON),
20436 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20437 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20438 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20439 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20440 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20441 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20442 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20443 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20444 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20445 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20448 +#endif /* _VX_LIMIT_PROC_H */
20451 diff -NurpP --minimal linux-3.0.25/kernel/vserver/network.c linux-3.0.25-vs2.3.2.3/kernel/vserver/network.c
20452 --- linux-3.0.25/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20453 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/network.c 2011-06-10 23:20:56.000000000 +0200
20456 + * linux/kernel/vserver/network.c
20458 + * Virtual Server: Network Support
20460 + * Copyright (C) 2003-2007 Herbert Pötzl
20462 + * V0.01 broken out from vcontext V0.05
20463 + * V0.02 cleaned up implementation
20464 + * V0.03 added equiv nx commands
20465 + * V0.04 switch to RCU based hash
20466 + * V0.05 and back to locking again
20467 + * V0.06 changed vcmds to nxi arg
20468 + * V0.07 have __create claim() the nxi
20472 +#include <linux/err.h>
20473 +#include <linux/slab.h>
20474 +#include <linux/rcupdate.h>
20476 +#include <linux/vs_network.h>
20477 +#include <linux/vs_pid.h>
20478 +#include <linux/vserver/network_cmd.h>
20481 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20482 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20484 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20485 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20488 +static int __init init_network(void)
20490 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20491 + sizeof(struct nx_addr_v4), 0,
20492 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20493 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20494 + sizeof(struct nx_addr_v6), 0,
20495 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20500 +/* __alloc_nx_addr_v4() */
20502 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20504 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20505 + nx_addr_v4_cachep, GFP_KERNEL);
20507 + if (!IS_ERR(nxa))
20508 + memset(nxa, 0, sizeof(*nxa));
20512 +/* __dealloc_nx_addr_v4() */
20514 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20516 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20519 +/* __dealloc_nx_addr_v4_all() */
20521 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20524 + struct nx_addr_v4 *next = nxa->next;
20526 + __dealloc_nx_addr_v4(nxa);
20532 +#ifdef CONFIG_IPV6
20534 +/* __alloc_nx_addr_v6() */
20536 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20538 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20539 + nx_addr_v6_cachep, GFP_KERNEL);
20541 + if (!IS_ERR(nxa))
20542 + memset(nxa, 0, sizeof(*nxa));
20546 +/* __dealloc_nx_addr_v6() */
20548 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20550 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20553 +/* __dealloc_nx_addr_v6_all() */
20555 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20558 + struct nx_addr_v6 *next = nxa->next;
20560 + __dealloc_nx_addr_v6(nxa);
20565 +#endif /* CONFIG_IPV6 */
20567 +/* __alloc_nx_info()
20569 + * allocate an initialized nx_info struct
20570 + * doesn't make it visible (hash) */
20572 +static struct nx_info *__alloc_nx_info(nid_t nid)
20574 + struct nx_info *new = NULL;
20576 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20578 + /* would this benefit from a slab cache? */
20579 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20583 + memset(new, 0, sizeof(struct nx_info));
20584 + new->nx_id = nid;
20585 + INIT_HLIST_NODE(&new->nx_hlist);
20586 + atomic_set(&new->nx_usecnt, 0);
20587 + atomic_set(&new->nx_tasks, 0);
20588 + new->nx_state = 0;
20590 + new->nx_flags = NXF_INIT_SET;
20592 + /* rest of init goes here */
20594 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20595 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20597 + vxdprintk(VXD_CBIT(nid, 0),
20598 + "alloc_nx_info(%d) = %p", nid, new);
20599 + atomic_inc(&nx_global_ctotal);
20603 +/* __dealloc_nx_info()
20605 + * final disposal of nx_info */
20607 +static void __dealloc_nx_info(struct nx_info *nxi)
20609 + vxdprintk(VXD_CBIT(nid, 0),
20610 + "dealloc_nx_info(%p)", nxi);
20612 + nxi->nx_hlist.next = LIST_POISON1;
20615 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20616 + BUG_ON(atomic_read(&nxi->nx_tasks));
20618 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20620 + nxi->nx_state |= NXS_RELEASED;
20622 + atomic_dec(&nx_global_ctotal);
20625 +static void __shutdown_nx_info(struct nx_info *nxi)
20627 + nxi->nx_state |= NXS_SHUTDOWN;
20628 + vs_net_change(nxi, VSC_NETDOWN);
20631 +/* exported stuff */
20633 +void free_nx_info(struct nx_info *nxi)
20635 + /* context shutdown is mandatory */
20636 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20638 + /* context must not be hashed */
20639 + BUG_ON(nxi->nx_state & NXS_HASHED);
20641 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20642 + BUG_ON(atomic_read(&nxi->nx_tasks));
20644 + __dealloc_nx_info(nxi);
20648 +void __nx_set_lback(struct nx_info *nxi)
20650 + int nid = nxi->nx_id;
20651 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20653 + nxi->v4_lback.s_addr = lback;
20656 +extern int __nx_inet_add_lback(__be32 addr);
20657 +extern int __nx_inet_del_lback(__be32 addr);
20660 +/* hash table for nx_info hash */
20662 +#define NX_HASH_SIZE 13
20664 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20666 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20669 +static inline unsigned int __hashval(nid_t nid)
20671 + return (nid % NX_HASH_SIZE);
20676 +/* __hash_nx_info()
20678 + * add the nxi to the global hash table
20679 + * requires the hash_lock to be held */
20681 +static inline void __hash_nx_info(struct nx_info *nxi)
20683 + struct hlist_head *head;
20685 + vxd_assert_lock(&nx_info_hash_lock);
20686 + vxdprintk(VXD_CBIT(nid, 4),
20687 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20689 + /* context must not be hashed */
20690 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20692 + nxi->nx_state |= NXS_HASHED;
20693 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20694 + hlist_add_head(&nxi->nx_hlist, head);
20695 + atomic_inc(&nx_global_cactive);
20698 +/* __unhash_nx_info()
20700 + * remove the nxi from the global hash table
20701 + * requires the hash_lock to be held */
20703 +static inline void __unhash_nx_info(struct nx_info *nxi)
20705 + vxd_assert_lock(&nx_info_hash_lock);
20706 + vxdprintk(VXD_CBIT(nid, 4),
20707 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20708 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20710 + /* context must be hashed */
20711 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20712 + /* but without tasks */
20713 + BUG_ON(atomic_read(&nxi->nx_tasks));
20715 + nxi->nx_state &= ~NXS_HASHED;
20716 + hlist_del(&nxi->nx_hlist);
20717 + atomic_dec(&nx_global_cactive);
20721 +/* __lookup_nx_info()
20723 + * requires the hash_lock to be held
20724 + * doesn't increment the nx_refcnt */
20726 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20728 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20729 + struct hlist_node *pos;
20730 + struct nx_info *nxi;
20732 + vxd_assert_lock(&nx_info_hash_lock);
20733 + hlist_for_each(pos, head) {
20734 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20736 + if (nxi->nx_id == nid)
20741 + vxdprintk(VXD_CBIT(nid, 0),
20742 + "__lookup_nx_info(#%u): %p[#%u]",
20743 + nid, nxi, nxi ? nxi->nx_id : 0);
20748 +/* __create_nx_info()
20750 + * create the requested context
20751 + * get(), claim() and hash it */
20753 +static struct nx_info *__create_nx_info(int id)
20755 + struct nx_info *new, *nxi = NULL;
20757 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20759 + if (!(new = __alloc_nx_info(id)))
20760 + return ERR_PTR(-ENOMEM);
20762 + /* required to make dynamic xids unique */
20763 + spin_lock(&nx_info_hash_lock);
20765 + /* static context requested */
20766 + if ((nxi = __lookup_nx_info(id))) {
20767 + vxdprintk(VXD_CBIT(nid, 0),
20768 + "create_nx_info(%d) = %p (already there)", id, nxi);
20769 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20770 + nxi = ERR_PTR(-EBUSY);
20772 + nxi = ERR_PTR(-EEXIST);
20775 + /* new context */
20776 + vxdprintk(VXD_CBIT(nid, 0),
20777 + "create_nx_info(%d) = %p (new)", id, new);
20778 + claim_nx_info(new, NULL);
20779 + __nx_set_lback(new);
20780 + __hash_nx_info(get_nx_info(new));
20781 + nxi = new, new = NULL;
20784 + spin_unlock(&nx_info_hash_lock);
20786 + __dealloc_nx_info(new);
20792 +/* exported stuff */
20795 +void unhash_nx_info(struct nx_info *nxi)
20797 + __shutdown_nx_info(nxi);
20798 + spin_lock(&nx_info_hash_lock);
20799 + __unhash_nx_info(nxi);
20800 + spin_unlock(&nx_info_hash_lock);
20803 +/* lookup_nx_info()
20805 + * search for a nx_info and get() it
20806 + * negative id means current */
20808 +struct nx_info *lookup_nx_info(int id)
20810 + struct nx_info *nxi = NULL;
20813 + nxi = get_nx_info(current_nx_info());
20814 + } else if (id > 1) {
20815 + spin_lock(&nx_info_hash_lock);
20816 + nxi = get_nx_info(__lookup_nx_info(id));
20817 + spin_unlock(&nx_info_hash_lock);
20822 +/* nid_is_hashed()
20824 + * verify that nid is still hashed */
20826 +int nid_is_hashed(nid_t nid)
20830 + spin_lock(&nx_info_hash_lock);
20831 + hashed = (__lookup_nx_info(nid) != NULL);
20832 + spin_unlock(&nx_info_hash_lock);
20837 +#ifdef CONFIG_PROC_FS
20841 + * get a subset of hashed nids for proc
20842 + * assumes size is at least one */
20844 +int get_nid_list(int index, unsigned int *nids, int size)
20846 + int hindex, nr_nids = 0;
20848 + /* only show current and children */
20849 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20852 + nids[nr_nids] = nx_current_nid();
20856 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20857 + struct hlist_head *head = &nx_info_hash[hindex];
20858 + struct hlist_node *pos;
20860 + spin_lock(&nx_info_hash_lock);
20861 + hlist_for_each(pos, head) {
20862 + struct nx_info *nxi;
20867 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20868 + nids[nr_nids] = nxi->nx_id;
20869 + if (++nr_nids >= size) {
20870 + spin_unlock(&nx_info_hash_lock);
20874 + /* keep the lock time short */
20875 + spin_unlock(&nx_info_hash_lock);
20884 + * migrate task to new network
20885 + * gets nxi, puts old_nxi on change
20888 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20890 + struct nx_info *old_nxi;
20896 + vxdprintk(VXD_CBIT(nid, 5),
20897 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20898 + p, nxi, nxi->nx_id,
20899 + atomic_read(&nxi->nx_usecnt),
20900 + atomic_read(&nxi->nx_tasks));
20902 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20903 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20906 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20909 + /* maybe disallow this completely? */
20910 + old_nxi = task_get_nx_info(p);
20911 + if (old_nxi == nxi)
20916 + clr_nx_info(&p->nx_info);
20917 + claim_nx_info(nxi, p);
20918 + set_nx_info(&p->nx_info, nxi);
20919 + p->nid = nxi->nx_id;
20922 + vxdprintk(VXD_CBIT(nid, 5),
20923 + "moved task %p into nxi:%p[#%d]",
20924 + p, nxi, nxi->nx_id);
20927 + release_nx_info(old_nxi, p);
20930 + put_nx_info(old_nxi);
20935 +void nx_set_persistent(struct nx_info *nxi)
20937 + vxdprintk(VXD_CBIT(nid, 6),
20938 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20940 + get_nx_info(nxi);
20941 + claim_nx_info(nxi, NULL);
20944 +void nx_clear_persistent(struct nx_info *nxi)
20946 + vxdprintk(VXD_CBIT(nid, 6),
20947 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20949 + release_nx_info(nxi, NULL);
20950 + put_nx_info(nxi);
20953 +void nx_update_persistent(struct nx_info *nxi)
20955 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20956 + nx_set_persistent(nxi);
20958 + nx_clear_persistent(nxi);
20961 +/* vserver syscall commands below here */
20963 +/* taks nid and nx_info functions */
20965 +#include <asm/uaccess.h>
20968 +int vc_task_nid(uint32_t id)
20973 + struct task_struct *tsk;
20976 + tsk = find_task_by_real_pid(id);
20977 + nid = (tsk) ? tsk->nid : -ESRCH;
20978 + rcu_read_unlock();
20980 + nid = nx_current_nid();
20985 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20987 + struct vcmd_nx_info_v0 vc_data;
20989 + vc_data.nid = nxi->nx_id;
20991 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20997 +/* network functions */
20999 +int vc_net_create(uint32_t nid, void __user *data)
21001 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
21002 + struct nx_info *new_nxi;
21005 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21008 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
21011 + new_nxi = __create_nx_info(nid);
21012 + if (IS_ERR(new_nxi))
21013 + return PTR_ERR(new_nxi);
21015 + /* initial flags */
21016 + new_nxi->nx_flags = vc_data.flagword;
21019 + if (vs_net_change(new_nxi, VSC_NETUP))
21022 + ret = nx_migrate_task(current, new_nxi);
21026 + /* return context id on success */
21027 + ret = new_nxi->nx_id;
21029 + /* get a reference for persistent contexts */
21030 + if ((vc_data.flagword & NXF_PERSISTENT))
21031 + nx_set_persistent(new_nxi);
21033 + release_nx_info(new_nxi, NULL);
21034 + put_nx_info(new_nxi);
21039 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
21041 + return nx_migrate_task(current, nxi);
21046 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21047 + uint16_t type, uint16_t flags)
21049 + struct nx_addr_v4 *nxa = &nxi->v4;
21051 + if (NX_IPV4(nxi)) {
21052 + /* locate last entry */
21053 + for (; nxa->next; nxa = nxa->next);
21054 + nxa->next = __alloc_nx_addr_v4();
21058 + return PTR_ERR(nxa);
21061 + if (nxi->v4.next)
21062 + /* remove single ip for ip list */
21063 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21065 + nxa->ip[0].s_addr = ip;
21066 + nxa->ip[1].s_addr = ip2;
21067 + nxa->mask.s_addr = mask;
21068 + nxa->type = type;
21069 + nxa->flags = flags;
21073 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21074 + uint16_t type, uint16_t flags)
21076 + struct nx_addr_v4 *nxa = &nxi->v4;
21079 +/* case NXA_TYPE_ADDR:
21082 + case NXA_TYPE_ANY:
21083 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
21084 + memset(nxa, 0, sizeof(*nxa));
21094 +int vc_net_add(struct nx_info *nxi, void __user *data)
21096 + struct vcmd_net_addr_v0 vc_data;
21097 + int index, ret = 0;
21099 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21102 + switch (vc_data.type) {
21103 + case NXA_TYPE_IPV4:
21104 + if ((vc_data.count < 1) || (vc_data.count > 4))
21108 + while (index < vc_data.count) {
21109 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21110 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21118 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21119 + nxi->v4_bcast = vc_data.ip[0];
21123 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21124 + nxi->v4_lback = vc_data.ip[0];
21135 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21137 + struct vcmd_net_addr_v0 vc_data;
21139 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21142 + switch (vc_data.type) {
21143 + case NXA_TYPE_ANY:
21144 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21145 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21155 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
21157 + struct vcmd_net_addr_ipv4_v1 vc_data;
21159 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21162 + switch (vc_data.type) {
21163 + case NXA_TYPE_ADDR:
21164 + case NXA_TYPE_MASK:
21165 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21166 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21168 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21169 + nxi->v4_bcast = vc_data.ip;
21172 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21173 + nxi->v4_lback = vc_data.ip;
21182 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21184 + struct vcmd_net_addr_ipv4_v2 vc_data;
21186 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21189 + switch (vc_data.type) {
21190 + case NXA_TYPE_ADDR:
21191 + case NXA_TYPE_MASK:
21192 + case NXA_TYPE_RANGE:
21193 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
21194 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21196 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21197 + nxi->v4_bcast = vc_data.ip;
21200 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21201 + nxi->v4_lback = vc_data.ip;
21210 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
21212 + struct vcmd_net_addr_ipv4_v1 vc_data;
21214 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21217 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
21218 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21221 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
21223 + struct vcmd_net_addr_ipv4_v2 vc_data;
21225 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21228 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
21229 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21232 +#ifdef CONFIG_IPV6
21234 +int do_add_v6_addr(struct nx_info *nxi,
21235 + struct in6_addr *ip, struct in6_addr *mask,
21236 + uint32_t prefix, uint16_t type, uint16_t flags)
21238 + struct nx_addr_v6 *nxa = &nxi->v6;
21240 + if (NX_IPV6(nxi)) {
21241 + /* locate last entry */
21242 + for (; nxa->next; nxa = nxa->next);
21243 + nxa->next = __alloc_nx_addr_v6();
21247 + return PTR_ERR(nxa);
21251 + nxa->mask = *mask;
21252 + nxa->prefix = prefix;
21253 + nxa->type = type;
21254 + nxa->flags = flags;
21259 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21261 + struct vcmd_net_addr_ipv6_v1 vc_data;
21263 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21266 + switch (vc_data.type) {
21267 + case NXA_TYPE_ADDR:
21268 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
21269 + /* fallthrough */
21270 + case NXA_TYPE_MASK:
21271 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21272 + vc_data.prefix, vc_data.type, vc_data.flags);
21279 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21281 + struct vcmd_net_addr_ipv6_v1 vc_data;
21283 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21286 + switch (vc_data.type) {
21287 + case NXA_TYPE_ANY:
21288 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21289 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21298 +#endif /* CONFIG_IPV6 */
21301 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21303 + struct vcmd_net_flags_v0 vc_data;
21305 + vc_data.flagword = nxi->nx_flags;
21307 + /* special STATE flag handling */
21308 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21310 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21315 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21317 + struct vcmd_net_flags_v0 vc_data;
21318 + uint64_t mask, trigger;
21320 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21323 + /* special STATE flag handling */
21324 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21325 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21327 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21328 + vc_data.flagword, mask);
21329 + if (trigger & NXF_PERSISTENT)
21330 + nx_update_persistent(nxi);
21335 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21337 + struct vcmd_net_caps_v0 vc_data;
21339 + vc_data.ncaps = nxi->nx_ncaps;
21340 + vc_data.cmask = ~0ULL;
21342 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21347 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21349 + struct vcmd_net_caps_v0 vc_data;
21351 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21354 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21355 + vc_data.ncaps, vc_data.cmask);
21360 +#include <linux/module.h>
21362 +module_init(init_network);
21364 +EXPORT_SYMBOL_GPL(free_nx_info);
21365 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21367 diff -NurpP --minimal linux-3.0.25/kernel/vserver/proc.c linux-3.0.25-vs2.3.2.3/kernel/vserver/proc.c
21368 --- linux-3.0.25/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21369 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/proc.c 2011-08-01 19:57:21.000000000 +0200
21372 + * linux/kernel/vserver/proc.c
21374 + * Virtual Context Support
21376 + * Copyright (C) 2003-2011 Herbert Pötzl
21378 + * V0.01 basic structure
21379 + * V0.02 adaptation vs1.3.0
21380 + * V0.03 proc permissions
21381 + * V0.04 locking/generic
21382 + * V0.05 next generation procfs
21383 + * V0.06 inode validation
21384 + * V0.07 generic rewrite vid
21385 + * V0.08 remove inode type
21386 + * V0.09 added u/wmask info
21390 +#include <linux/proc_fs.h>
21391 +#include <linux/fs_struct.h>
21392 +#include <linux/mount.h>
21393 +#include <asm/unistd.h>
21395 +#include <linux/vs_context.h>
21396 +#include <linux/vs_network.h>
21397 +#include <linux/vs_cvirt.h>
21399 +#include <linux/in.h>
21400 +#include <linux/inetdevice.h>
21401 +#include <linux/vs_inet.h>
21402 +#include <linux/vs_inet6.h>
21404 +#include <linux/vserver/global.h>
21406 +#include "cvirt_proc.h"
21407 +#include "cacct_proc.h"
21408 +#include "limit_proc.h"
21409 +#include "sched_proc.h"
21410 +#include "vci_config.h"
21413 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21417 + CAP_FOR_EACH_U32(__capi) {
21418 + buffer += sprintf(buffer, "%08x",
21419 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21425 +static struct proc_dir_entry *proc_virtual;
21427 +static struct proc_dir_entry *proc_virtnet;
21430 +/* first the actual feeds */
21433 +static int proc_vci(char *buffer)
21435 + return sprintf(buffer,
21436 + "VCIVersion:\t%04x:%04x\n"
21437 + "VCISyscall:\t%d\n"
21438 + "VCIKernel:\t%08x\n",
21439 + VCI_VERSION >> 16,
21440 + VCI_VERSION & 0xFFFF,
21442 + vci_kernel_config());
21445 +static int proc_virtual_info(char *buffer)
21447 + return proc_vci(buffer);
21450 +static int proc_virtual_status(char *buffer)
21452 + return sprintf(buffer,
21454 + "#CActive:\t%d\n"
21455 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21456 + "#InitTask:\t%d\t%d %d\n",
21457 + atomic_read(&vx_global_ctotal),
21458 + atomic_read(&vx_global_cactive),
21459 + atomic_read(&vs_global_nsproxy),
21460 + atomic_read(&vs_global_fs),
21461 + atomic_read(&vs_global_mnt_ns),
21462 + atomic_read(&vs_global_uts_ns),
21463 + atomic_read(&nr_ipc_ns),
21464 + atomic_read(&vs_global_user_ns),
21465 + atomic_read(&vs_global_pid_ns),
21466 + atomic_read(&init_task.usage),
21467 + atomic_read(&init_task.nsproxy->count),
21468 + init_task.fs->users);
21472 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21476 + length = sprintf(buffer,
21484 + vxi->vx_badness_bias);
21488 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21490 + char *orig = buffer;
21492 + buffer += sprintf(buffer,
21495 + "Flags:\t%016llx\n",
21496 + atomic_read(&vxi->vx_usecnt),
21497 + atomic_read(&vxi->vx_tasks),
21498 + (unsigned long long)vxi->vx_flags);
21500 + buffer += sprintf(buffer, "BCaps:\t");
21501 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21502 + buffer += sprintf(buffer, "\n");
21504 + buffer += sprintf(buffer,
21505 + "CCaps:\t%016llx\n"
21506 + "Umask:\t%16llx\n"
21507 + "Wmask:\t%16llx\n"
21508 + "Spaces:\t%08lx %08lx\n",
21509 + (unsigned long long)vxi->vx_ccaps,
21510 + (unsigned long long)vxi->vx_umask,
21511 + (unsigned long long)vxi->vx_wmask,
21512 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21513 + return buffer - orig;
21516 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21518 + return vx_info_proc_limit(&vxi->limit, buffer);
21521 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21525 + length = vx_info_proc_sched(&vxi->sched, buffer);
21526 + for_each_online_cpu(cpu) {
21527 + length += vx_info_proc_sched_pc(
21528 + &vx_per_cpu(vxi, sched_pc, cpu),
21529 + buffer + length, cpu);
21534 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21536 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21539 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21541 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21544 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21548 + vx_update_load(vxi);
21549 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21550 + for_each_online_cpu(cpu) {
21551 + length += vx_info_proc_cvirt_pc(
21552 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21553 + buffer + length, cpu);
21558 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21560 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21564 +static int proc_virtnet_info(char *buffer)
21566 + return proc_vci(buffer);
21569 +static int proc_virtnet_status(char *buffer)
21571 + return sprintf(buffer,
21573 + "#CActive:\t%d\n",
21574 + atomic_read(&nx_global_ctotal),
21575 + atomic_read(&nx_global_cactive));
21578 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21580 + struct nx_addr_v4 *v4a;
21581 +#ifdef CONFIG_IPV6
21582 + struct nx_addr_v6 *v6a;
21586 + length = sprintf(buffer,
21589 + "Bcast:\t" NIPQUAD_FMT "\n"
21590 + "Lback:\t" NIPQUAD_FMT "\n",
21593 + NIPQUAD(nxi->v4_bcast.s_addr),
21594 + NIPQUAD(nxi->v4_lback.s_addr));
21596 + if (!NX_IPV4(nxi))
21598 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21599 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21602 +#ifdef CONFIG_IPV6
21603 + if (!NX_IPV6(nxi))
21605 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21606 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21613 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21617 + length = sprintf(buffer,
21620 + "Flags:\t%016llx\n"
21621 + "NCaps:\t%016llx\n",
21622 + atomic_read(&nxi->nx_usecnt),
21623 + atomic_read(&nxi->nx_tasks),
21624 + (unsigned long long)nxi->nx_flags,
21625 + (unsigned long long)nxi->nx_ncaps);
21631 +/* here the inode helpers */
21637 + struct inode_operations *iop;
21638 + struct file_operations *fop;
21639 + union proc_op op;
21642 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21644 + struct inode *inode = new_inode(sb);
21649 + inode->i_mode = p->mode;
21651 + inode->i_op = p->iop;
21653 + inode->i_fop = p->fop;
21655 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
21656 + inode->i_flags |= S_IMMUTABLE;
21658 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21660 + inode->i_uid = 0;
21661 + inode->i_gid = 0;
21662 + inode->i_tag = 0;
21667 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21668 + struct dentry *dentry, int id, void *ptr)
21670 + struct vs_entry *p = ptr;
21671 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21672 + struct dentry *error = ERR_PTR(-EINVAL);
21677 + PROC_I(inode)->op = p->op;
21678 + PROC_I(inode)->fd = id;
21679 + d_add(dentry, inode);
21687 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21690 + * Fill a directory entry.
21692 + * If possible create the dcache entry and derive our inode number and
21693 + * file type from dcache entry.
21695 + * Since all of the proc inode numbers are dynamically generated, the inode
21696 + * numbers do not exist until the inode is cache. This means creating the
21697 + * the dcache entry in readdir is necessary to keep the inode numbers
21698 + * reported by readdir in sync with the inode numbers reported
21701 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21702 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21704 + struct dentry *child, *dir = filp->f_dentry;
21705 + struct inode *inode;
21706 + struct qstr qname;
21708 + unsigned type = DT_UNKNOWN;
21710 + qname.name = name;
21712 + qname.hash = full_name_hash(name, len);
21714 + child = d_lookup(dir, &qname);
21716 + struct dentry *new;
21717 + new = d_alloc(dir, &qname);
21719 + child = instantiate(dir->d_inode, new, id, ptr);
21726 + if (!child || IS_ERR(child) || !child->d_inode)
21727 + goto end_instantiate;
21728 + inode = child->d_inode;
21730 + ino = inode->i_ino;
21731 + type = inode->i_mode >> 12;
21736 + ino = find_inode_number(dir, &qname);
21739 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21744 +/* get and revalidate vx_info/xid */
21747 +struct vx_info *get_proc_vx_info(struct inode *inode)
21749 + return lookup_vx_info(PROC_I(inode)->fd);
21752 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21754 + struct inode *inode = dentry->d_inode;
21755 + xid_t xid = PROC_I(inode)->fd;
21757 + if (!xid || xid_is_hashed(xid))
21764 +/* get and revalidate nx_info/nid */
21766 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21768 + struct inode *inode = dentry->d_inode;
21769 + nid_t nid = PROC_I(inode)->fd;
21771 + if (!nid || nid_is_hashed(nid))
21779 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21781 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21782 + size_t count, loff_t *ppos)
21784 + struct inode *inode = file->f_dentry->d_inode;
21785 + unsigned long page;
21786 + ssize_t length = 0;
21788 + if (count > PROC_BLOCK_SIZE)
21789 + count = PROC_BLOCK_SIZE;
21791 + /* fade that out as soon as stable */
21792 + WARN_ON(PROC_I(inode)->fd);
21794 + if (!(page = __get_free_page(GFP_KERNEL)))
21797 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21798 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21801 + length = simple_read_from_buffer(buf, count, ppos,
21802 + (char *)page, length);
21808 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21809 + size_t count, loff_t *ppos)
21811 + struct inode *inode = file->f_dentry->d_inode;
21812 + struct vx_info *vxi = NULL;
21813 + xid_t xid = PROC_I(inode)->fd;
21814 + unsigned long page;
21815 + ssize_t length = 0;
21817 + if (count > PROC_BLOCK_SIZE)
21818 + count = PROC_BLOCK_SIZE;
21820 + /* fade that out as soon as stable */
21822 + vxi = lookup_vx_info(xid);
21826 + length = -ENOMEM;
21827 + if (!(page = __get_free_page(GFP_KERNEL)))
21830 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21831 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21834 + length = simple_read_from_buffer(buf, count, ppos,
21835 + (char *)page, length);
21839 + put_vx_info(vxi);
21844 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21845 + size_t count, loff_t *ppos)
21847 + struct inode *inode = file->f_dentry->d_inode;
21848 + struct nx_info *nxi = NULL;
21849 + nid_t nid = PROC_I(inode)->fd;
21850 + unsigned long page;
21851 + ssize_t length = 0;
21853 + if (count > PROC_BLOCK_SIZE)
21854 + count = PROC_BLOCK_SIZE;
21856 + /* fade that out as soon as stable */
21858 + nxi = lookup_nx_info(nid);
21862 + length = -ENOMEM;
21863 + if (!(page = __get_free_page(GFP_KERNEL)))
21866 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21867 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21870 + length = simple_read_from_buffer(buf, count, ppos,
21871 + (char *)page, length);
21875 + put_nx_info(nxi);
21882 +/* here comes the lower level */
21885 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21886 + .len = sizeof(NAME) - 1, \
21887 + .name = (NAME), \
21895 +#define DIR(NAME, MODE, OTYPE) \
21896 + NOD(NAME, (S_IFDIR | (MODE)), \
21897 + &proc_ ## OTYPE ## _inode_operations, \
21898 + &proc_ ## OTYPE ## _file_operations, { } )
21900 +#define INF(NAME, MODE, OTYPE) \
21901 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21902 + &proc_vs_info_file_operations, \
21903 + { .proc_vs_read = &proc_##OTYPE } )
21905 +#define VINF(NAME, MODE, OTYPE) \
21906 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21907 + &proc_vx_info_file_operations, \
21908 + { .proc_vxi_read = &proc_##OTYPE } )
21910 +#define NINF(NAME, MODE, OTYPE) \
21911 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21912 + &proc_nx_info_file_operations, \
21913 + { .proc_nxi_read = &proc_##OTYPE } )
21916 +static struct file_operations proc_vs_info_file_operations = {
21917 + .read = proc_vs_info_read,
21920 +static struct file_operations proc_vx_info_file_operations = {
21921 + .read = proc_vx_info_read,
21924 +static struct dentry_operations proc_xid_dentry_operations = {
21925 + .d_revalidate = proc_xid_revalidate,
21928 +static struct vs_entry vx_base_stuff[] = {
21929 + VINF("info", S_IRUGO, vxi_info),
21930 + VINF("status", S_IRUGO, vxi_status),
21931 + VINF("limit", S_IRUGO, vxi_limit),
21932 + VINF("sched", S_IRUGO, vxi_sched),
21933 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21934 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21935 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21936 + VINF("cacct", S_IRUGO, vxi_cacct),
21943 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21944 + struct dentry *dentry, int id, void *ptr)
21946 + dentry->d_op = &proc_xid_dentry_operations;
21947 + return vs_proc_instantiate(dir, dentry, id, ptr);
21950 +static struct dentry *proc_xid_lookup(struct inode *dir,
21951 + struct dentry *dentry, struct nameidata *nd)
21953 + struct vs_entry *p = vx_base_stuff;
21954 + struct dentry *error = ERR_PTR(-ENOENT);
21956 + for (; p->name; p++) {
21957 + if (p->len != dentry->d_name.len)
21959 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21965 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21970 +static int proc_xid_readdir(struct file *filp,
21971 + void *dirent, filldir_t filldir)
21973 + struct dentry *dentry = filp->f_dentry;
21974 + struct inode *inode = dentry->d_inode;
21975 + struct vs_entry *p = vx_base_stuff;
21976 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21980 + pos = filp->f_pos;
21983 + ino = inode->i_ino;
21984 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21987 + /* fall through */
21989 + ino = parent_ino(dentry);
21990 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21993 + /* fall through */
21996 + if (index >= size)
21998 + for (p += index; p->name; p++) {
21999 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22000 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22006 + filp->f_pos = pos;
22012 +static struct file_operations proc_nx_info_file_operations = {
22013 + .read = proc_nx_info_read,
22016 +static struct dentry_operations proc_nid_dentry_operations = {
22017 + .d_revalidate = proc_nid_revalidate,
22020 +static struct vs_entry nx_base_stuff[] = {
22021 + NINF("info", S_IRUGO, nxi_info),
22022 + NINF("status", S_IRUGO, nxi_status),
22027 +static struct dentry *proc_nid_instantiate(struct inode *dir,
22028 + struct dentry *dentry, int id, void *ptr)
22030 + dentry->d_op = &proc_nid_dentry_operations;
22031 + return vs_proc_instantiate(dir, dentry, id, ptr);
22034 +static struct dentry *proc_nid_lookup(struct inode *dir,
22035 + struct dentry *dentry, struct nameidata *nd)
22037 + struct vs_entry *p = nx_base_stuff;
22038 + struct dentry *error = ERR_PTR(-ENOENT);
22040 + for (; p->name; p++) {
22041 + if (p->len != dentry->d_name.len)
22043 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22049 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22054 +static int proc_nid_readdir(struct file *filp,
22055 + void *dirent, filldir_t filldir)
22057 + struct dentry *dentry = filp->f_dentry;
22058 + struct inode *inode = dentry->d_inode;
22059 + struct vs_entry *p = nx_base_stuff;
22060 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22064 + pos = filp->f_pos;
22067 + ino = inode->i_ino;
22068 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22071 + /* fall through */
22073 + ino = parent_ino(dentry);
22074 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22077 + /* fall through */
22080 + if (index >= size)
22082 + for (p += index; p->name; p++) {
22083 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22084 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22090 + filp->f_pos = pos;
22095 +#define MAX_MULBY10 ((~0U - 9) / 10)
22097 +static inline int atovid(const char *str, int len)
22102 + while (len-- > 0) {
22107 + if (vid >= MAX_MULBY10)
22117 +/* now the upper level (virtual) */
22120 +static struct file_operations proc_xid_file_operations = {
22121 + .read = generic_read_dir,
22122 + .readdir = proc_xid_readdir,
22125 +static struct inode_operations proc_xid_inode_operations = {
22126 + .lookup = proc_xid_lookup,
22129 +static struct vs_entry vx_virtual_stuff[] = {
22130 + INF("info", S_IRUGO, virtual_info),
22131 + INF("status", S_IRUGO, virtual_status),
22132 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22136 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22137 + struct dentry *dentry, struct nameidata *nd)
22139 + struct vs_entry *p = vx_virtual_stuff;
22140 + struct dentry *error = ERR_PTR(-ENOENT);
22143 + for (; p->name; p++) {
22144 + if (p->len != dentry->d_name.len)
22146 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22150 + goto instantiate;
22152 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22153 + if ((id < 0) || !xid_is_hashed(id))
22157 + error = proc_xid_instantiate(dir, dentry, id, p);
22162 +static struct file_operations proc_nid_file_operations = {
22163 + .read = generic_read_dir,
22164 + .readdir = proc_nid_readdir,
22167 +static struct inode_operations proc_nid_inode_operations = {
22168 + .lookup = proc_nid_lookup,
22171 +static struct vs_entry nx_virtnet_stuff[] = {
22172 + INF("info", S_IRUGO, virtnet_info),
22173 + INF("status", S_IRUGO, virtnet_status),
22174 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22178 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22179 + struct dentry *dentry, struct nameidata *nd)
22181 + struct vs_entry *p = nx_virtnet_stuff;
22182 + struct dentry *error = ERR_PTR(-ENOENT);
22185 + for (; p->name; p++) {
22186 + if (p->len != dentry->d_name.len)
22188 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22192 + goto instantiate;
22194 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22195 + if ((id < 0) || !nid_is_hashed(id))
22199 + error = proc_nid_instantiate(dir, dentry, id, p);
22205 +#define PROC_MAXVIDS 32
22207 +int proc_virtual_readdir(struct file *filp,
22208 + void *dirent, filldir_t filldir)
22210 + struct dentry *dentry = filp->f_dentry;
22211 + struct inode *inode = dentry->d_inode;
22212 + struct vs_entry *p = vx_virtual_stuff;
22213 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22215 + unsigned int xid_array[PROC_MAXVIDS];
22216 + char buf[PROC_NUMBUF];
22217 + unsigned int nr_xids, i;
22220 + pos = filp->f_pos;
22223 + ino = inode->i_ino;
22224 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22227 + /* fall through */
22229 + ino = parent_ino(dentry);
22230 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22233 + /* fall through */
22236 + if (index >= size)
22238 + for (p += index; p->name; p++) {
22239 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22240 + vs_proc_instantiate, 0, p))
22245 + index = pos - size;
22246 + p = &vx_virtual_stuff[size - 1];
22247 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22248 + for (i = 0; i < nr_xids; i++) {
22249 + int n, xid = xid_array[i];
22250 + unsigned int j = PROC_NUMBUF;
22254 + buf[--j] = '0' + (n % 10);
22257 + if (proc_fill_cache(filp, dirent, filldir,
22258 + buf + j, PROC_NUMBUF - j,
22259 + vs_proc_instantiate, xid, p))
22265 + filp->f_pos = pos;
22269 +static int proc_virtual_getattr(struct vfsmount *mnt,
22270 + struct dentry *dentry, struct kstat *stat)
22272 + struct inode *inode = dentry->d_inode;
22274 + generic_fillattr(inode, stat);
22275 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22279 +static struct file_operations proc_virtual_dir_operations = {
22280 + .read = generic_read_dir,
22281 + .readdir = proc_virtual_readdir,
22284 +static struct inode_operations proc_virtual_dir_inode_operations = {
22285 + .getattr = proc_virtual_getattr,
22286 + .lookup = proc_virtual_lookup,
22293 +int proc_virtnet_readdir(struct file *filp,
22294 + void *dirent, filldir_t filldir)
22296 + struct dentry *dentry = filp->f_dentry;
22297 + struct inode *inode = dentry->d_inode;
22298 + struct vs_entry *p = nx_virtnet_stuff;
22299 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22301 + unsigned int nid_array[PROC_MAXVIDS];
22302 + char buf[PROC_NUMBUF];
22303 + unsigned int nr_nids, i;
22306 + pos = filp->f_pos;
22309 + ino = inode->i_ino;
22310 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22313 + /* fall through */
22315 + ino = parent_ino(dentry);
22316 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22319 + /* fall through */
22322 + if (index >= size)
22324 + for (p += index; p->name; p++) {
22325 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22326 + vs_proc_instantiate, 0, p))
22331 + index = pos - size;
22332 + p = &nx_virtnet_stuff[size - 1];
22333 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22334 + for (i = 0; i < nr_nids; i++) {
22335 + int n, nid = nid_array[i];
22336 + unsigned int j = PROC_NUMBUF;
22340 + buf[--j] = '0' + (n % 10);
22343 + if (proc_fill_cache(filp, dirent, filldir,
22344 + buf + j, PROC_NUMBUF - j,
22345 + vs_proc_instantiate, nid, p))
22351 + filp->f_pos = pos;
22355 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22356 + struct dentry *dentry, struct kstat *stat)
22358 + struct inode *inode = dentry->d_inode;
22360 + generic_fillattr(inode, stat);
22361 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22365 +static struct file_operations proc_virtnet_dir_operations = {
22366 + .read = generic_read_dir,
22367 + .readdir = proc_virtnet_readdir,
22370 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22371 + .getattr = proc_virtnet_getattr,
22372 + .lookup = proc_virtnet_lookup,
22377 +void proc_vx_init(void)
22379 + struct proc_dir_entry *ent;
22381 + ent = proc_mkdir("virtual", 0);
22383 + ent->proc_fops = &proc_virtual_dir_operations;
22384 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22386 + proc_virtual = ent;
22388 + ent = proc_mkdir("virtnet", 0);
22390 + ent->proc_fops = &proc_virtnet_dir_operations;
22391 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22393 + proc_virtnet = ent;
22399 +/* per pid info */
22402 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22404 + struct vx_info *vxi;
22405 + char *orig = buffer;
22407 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22409 + vxi = task_get_vx_info(p);
22413 + buffer += sprintf(buffer, "BCaps:\t");
22414 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22415 + buffer += sprintf(buffer, "\n");
22416 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22417 + (unsigned long long)vxi->vx_ccaps);
22418 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22419 + (unsigned long long)vxi->vx_flags);
22420 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22422 + put_vx_info(vxi);
22424 + return buffer - orig;
22428 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22430 + struct nx_info *nxi;
22431 + struct nx_addr_v4 *v4a;
22432 +#ifdef CONFIG_IPV6
22433 + struct nx_addr_v6 *v6a;
22435 + char *orig = buffer;
22438 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22440 + nxi = task_get_nx_info(p);
22444 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22445 + (unsigned long long)nxi->nx_ncaps);
22446 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22447 + (unsigned long long)nxi->nx_flags);
22449 + buffer += sprintf(buffer,
22450 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22451 + NIPQUAD(nxi->v4_bcast.s_addr));
22452 + buffer += sprintf (buffer,
22453 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22454 + NIPQUAD(nxi->v4_lback.s_addr));
22455 + if (!NX_IPV4(nxi))
22457 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22458 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22461 +#ifdef CONFIG_IPV6
22462 + if (!NX_IPV6(nxi))
22464 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22465 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22469 + put_nx_info(nxi);
22471 + return buffer - orig;
22474 diff -NurpP --minimal linux-3.0.25/kernel/vserver/sched.c linux-3.0.25-vs2.3.2.3/kernel/vserver/sched.c
22475 --- linux-3.0.25/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22476 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/sched.c 2011-06-10 22:11:24.000000000 +0200
22479 + * linux/kernel/vserver/sched.c
22481 + * Virtual Server: Scheduler Support
22483 + * Copyright (C) 2004-2010 Herbert Pötzl
22485 + * V0.01 adapted Sam Vilains version to 2.6.3
22486 + * V0.02 removed legacy interface
22487 + * V0.03 changed vcmds to vxi arg
22488 + * V0.04 removed older and legacy interfaces
22489 + * V0.05 removed scheduler code/commands
22493 +#include <linux/vs_context.h>
22494 +#include <linux/vs_sched.h>
22495 +#include <linux/vserver/sched_cmd.h>
22497 +#include <asm/uaccess.h>
22500 +void vx_update_sched_param(struct _vx_sched *sched,
22501 + struct _vx_sched_pc *sched_pc)
22503 + sched_pc->prio_bias = sched->prio_bias;
22506 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22510 + if (data->prio_bias > MAX_PRIO_BIAS)
22511 + data->prio_bias = MAX_PRIO_BIAS;
22512 + if (data->prio_bias < MIN_PRIO_BIAS)
22513 + data->prio_bias = MIN_PRIO_BIAS;
22515 + if (data->cpu_id != ~0) {
22516 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22517 + cpus_and(vxi->sched.update, cpu_online_map,
22518 + vxi->sched.update);
22520 + vxi->sched.update = cpu_online_map;
22522 + for_each_cpu_mask(cpu, vxi->sched.update)
22523 + vx_update_sched_param(&vxi->sched,
22524 + &vx_per_cpu(vxi, sched_pc, cpu));
22528 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22530 + struct vcmd_prio_bias vc_data;
22532 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22535 + return do_set_prio_bias(vxi, &vc_data);
22538 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22540 + struct vcmd_prio_bias vc_data;
22541 + struct _vx_sched_pc *pcd;
22544 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22547 + cpu = vc_data.cpu_id;
22549 + if (!cpu_possible(cpu))
22552 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22553 + vc_data.prio_bias = pcd->prio_bias;
22555 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22560 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
22561 --- linux-3.0.25/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22562 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/sched_init.h 2011-06-10 22:11:24.000000000 +0200
22565 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22567 + /* scheduling; hard code starting values as constants */
22568 + sched->prio_bias = 0;
22572 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22574 + sched_pc->prio_bias = 0;
22576 + sched_pc->user_ticks = 0;
22577 + sched_pc->sys_ticks = 0;
22578 + sched_pc->hold_ticks = 0;
22581 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22587 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22591 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
22592 --- linux-3.0.25/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22593 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/sched_proc.h 2011-06-10 22:11:24.000000000 +0200
22595 +#ifndef _VX_SCHED_PROC_H
22596 +#define _VX_SCHED_PROC_H
22600 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22604 + length += sprintf(buffer,
22605 + "PrioBias:\t%8d\n",
22606 + sched->prio_bias);
22611 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22612 + char *buffer, int cpu)
22616 + length += sprintf(buffer + length,
22617 + "cpu %d: %lld %lld %lld", cpu,
22618 + (unsigned long long)sched_pc->user_ticks,
22619 + (unsigned long long)sched_pc->sys_ticks,
22620 + (unsigned long long)sched_pc->hold_ticks);
22621 + length += sprintf(buffer + length,
22622 + " %d\n", sched_pc->prio_bias);
22626 +#endif /* _VX_SCHED_PROC_H */
22627 diff -NurpP --minimal linux-3.0.25/kernel/vserver/signal.c linux-3.0.25-vs2.3.2.3/kernel/vserver/signal.c
22628 --- linux-3.0.25/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22629 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/signal.c 2011-06-10 22:11:24.000000000 +0200
22632 + * linux/kernel/vserver/signal.c
22634 + * Virtual Server: Signal Support
22636 + * Copyright (C) 2003-2007 Herbert Pötzl
22638 + * V0.01 broken out from vcontext V0.05
22639 + * V0.02 changed vcmds to vxi arg
22640 + * V0.03 adjusted siginfo for kill
22644 +#include <asm/uaccess.h>
22646 +#include <linux/vs_context.h>
22647 +#include <linux/vs_pid.h>
22648 +#include <linux/vserver/signal_cmd.h>
22651 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22653 + int retval, count = 0;
22654 + struct task_struct *p;
22655 + struct siginfo *sip = SEND_SIG_PRIV;
22658 + vxdprintk(VXD_CBIT(misc, 4),
22659 + "vx_info_kill(%p[#%d],%d,%d)*",
22660 + vxi, vxi->vx_id, pid, sig);
22661 + read_lock(&tasklist_lock);
22665 + for_each_process(p) {
22668 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22669 + (pid && vxi->vx_initpid == p->pid))
22672 + err = group_send_sig_info(sig, sip, p);
22674 + if (err != -EPERM)
22680 + if (vxi->vx_initpid) {
22681 + pid = vxi->vx_initpid;
22682 + /* for now, only SIGINT to private init ... */
22683 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22684 + /* ... as long as there are tasks left */
22685 + (atomic_read(&vxi->vx_tasks) > 1))
22688 + /* fallthrough */
22691 + p = find_task_by_real_pid(pid);
22692 + rcu_read_unlock();
22694 + if (vx_task_xid(p) == vxi->vx_id)
22695 + retval = group_send_sig_info(sig, sip, p);
22699 + read_unlock(&tasklist_lock);
22700 + vxdprintk(VXD_CBIT(misc, 4),
22701 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22702 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22706 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22708 + struct vcmd_ctx_kill_v0 vc_data;
22710 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22713 + /* special check to allow guest shutdown */
22714 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22715 + /* forbid killall pid=0 when init is present */
22716 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22717 + (vc_data.pid > 1)))
22720 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22724 +static int __wait_exit(struct vx_info *vxi)
22726 + DECLARE_WAITQUEUE(wait, current);
22729 + add_wait_queue(&vxi->vx_wait, &wait);
22730 + set_current_state(TASK_INTERRUPTIBLE);
22733 + if (vx_info_state(vxi,
22734 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22736 + if (signal_pending(current)) {
22737 + ret = -ERESTARTSYS;
22744 + set_current_state(TASK_RUNNING);
22745 + remove_wait_queue(&vxi->vx_wait, &wait);
22751 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22753 + struct vcmd_wait_exit_v0 vc_data;
22756 + ret = __wait_exit(vxi);
22757 + vc_data.reboot_cmd = vxi->reboot_cmd;
22758 + vc_data.exit_code = vxi->exit_code;
22760 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22765 diff -NurpP --minimal linux-3.0.25/kernel/vserver/space.c linux-3.0.25-vs2.3.2.3/kernel/vserver/space.c
22766 --- linux-3.0.25/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22767 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/space.c 2011-07-20 02:11:49.000000000 +0200
22770 + * linux/kernel/vserver/space.c
22772 + * Virtual Server: Context Space Support
22774 + * Copyright (C) 2003-2010 Herbert Pötzl
22776 + * V0.01 broken out from context.c 0.07
22777 + * V0.02 added task locking for namespace
22778 + * V0.03 broken out vx_enter_namespace
22779 + * V0.04 added *space support and commands
22780 + * V0.05 added credential support
22784 +#include <linux/utsname.h>
22785 +#include <linux/nsproxy.h>
22786 +#include <linux/err.h>
22787 +#include <linux/fs_struct.h>
22788 +#include <linux/cred.h>
22789 +#include <asm/uaccess.h>
22791 +#include <linux/vs_context.h>
22792 +#include <linux/vserver/space.h>
22793 +#include <linux/vserver/space_cmd.h>
22795 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22796 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22797 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22798 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22799 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22800 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22803 +/* namespace functions */
22805 +#include <linux/mnt_namespace.h>
22806 +#include <linux/user_namespace.h>
22807 +#include <linux/pid_namespace.h>
22808 +#include <linux/ipc_namespace.h>
22809 +#include <net/net_namespace.h>
22812 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22813 + .mask = CLONE_FS |
22815 +#ifdef CONFIG_UTS_NS
22818 +#ifdef CONFIG_IPC_NS
22821 +#ifdef CONFIG_USER_NS
22827 +static const struct vcmd_space_mask_v1 space_mask = {
22828 + .mask = CLONE_FS |
22830 +#ifdef CONFIG_UTS_NS
22833 +#ifdef CONFIG_IPC_NS
22836 +#ifdef CONFIG_USER_NS
22839 +#ifdef CONFIG_PID_NS
22842 +#ifdef CONFIG_NET_NS
22848 +static const struct vcmd_space_mask_v1 default_space_mask = {
22849 + .mask = CLONE_FS |
22851 +#ifdef CONFIG_UTS_NS
22854 +#ifdef CONFIG_IPC_NS
22857 +#ifdef CONFIG_USER_NS
22860 +#ifdef CONFIG_PID_NS
22867 + * build a new nsproxy mix
22868 + * assumes that both proxies are 'const'
22869 + * does not touch nsproxy refcounts
22870 + * will hold a reference on the result.
22873 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22874 + struct nsproxy *new_nsproxy, unsigned long mask)
22876 + struct mnt_namespace *old_ns;
22877 + struct uts_namespace *old_uts;
22878 + struct ipc_namespace *old_ipc;
22879 +#ifdef CONFIG_PID_NS
22880 + struct pid_namespace *old_pid;
22882 +#ifdef CONFIG_NET_NS
22883 + struct net *old_net;
22885 + struct nsproxy *nsproxy;
22887 + nsproxy = copy_nsproxy(old_nsproxy);
22891 + if (mask & CLONE_NEWNS) {
22892 + old_ns = nsproxy->mnt_ns;
22893 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22894 + if (nsproxy->mnt_ns)
22895 + get_mnt_ns(nsproxy->mnt_ns);
22899 + if (mask & CLONE_NEWUTS) {
22900 + old_uts = nsproxy->uts_ns;
22901 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22902 + if (nsproxy->uts_ns)
22903 + get_uts_ns(nsproxy->uts_ns);
22907 + if (mask & CLONE_NEWIPC) {
22908 + old_ipc = nsproxy->ipc_ns;
22909 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22910 + if (nsproxy->ipc_ns)
22911 + get_ipc_ns(nsproxy->ipc_ns);
22915 +#ifdef CONFIG_PID_NS
22916 + if (mask & CLONE_NEWPID) {
22917 + old_pid = nsproxy->pid_ns;
22918 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22919 + if (nsproxy->pid_ns)
22920 + get_pid_ns(nsproxy->pid_ns);
22924 +#ifdef CONFIG_NET_NS
22925 + if (mask & CLONE_NEWNET) {
22926 + old_net = nsproxy->net_ns;
22927 + nsproxy->net_ns = new_nsproxy->net_ns;
22928 + if (nsproxy->net_ns)
22929 + get_net(nsproxy->net_ns);
22934 + put_mnt_ns(old_ns);
22936 + put_uts_ns(old_uts);
22938 + put_ipc_ns(old_ipc);
22939 +#ifdef CONFIG_PID_NS
22941 + put_pid_ns(old_pid);
22943 +#ifdef CONFIG_NET_NS
22945 + put_net(old_net);
22953 + * merge two nsproxy structs into a new one.
22954 + * will hold a reference on the result.
22958 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22959 + struct nsproxy *proxy, unsigned long mask)
22961 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22967 + /* vs_mix_nsproxy returns with reference */
22968 + return vs_mix_nsproxy(old ? old : &null_proxy,
22971 + get_nsproxy(proxy);
22976 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22978 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22979 + struct fs_struct *fs_cur, *fs = NULL;
22980 + struct _vx_space *space;
22981 + int ret, kill = 0;
22983 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22984 + vxi, vxi->vx_id, mask, index);
22986 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22989 + if (index >= VX_SPACES)
22992 + space = &vxi->space[index];
22995 + mask = space->vx_nsmask;
22997 + if ((mask & space->vx_nsmask) != mask)
23000 + if (mask & CLONE_FS) {
23001 + fs = copy_fs_struct(space->vx_fs);
23005 + proxy = space->vx_nsproxy;
23007 + vxdprintk(VXD_CBIT(space, 9),
23008 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
23009 + vxi, vxi->vx_id, mask, index, proxy, fs);
23011 + task_lock(current);
23012 + fs_cur = current->fs;
23014 + if (mask & CLONE_FS) {
23015 + spin_lock(&fs_cur->lock);
23016 + current->fs = fs;
23017 + kill = !--fs_cur->users;
23018 + spin_unlock(&fs_cur->lock);
23021 + proxy_cur = current->nsproxy;
23022 + get_nsproxy(proxy_cur);
23023 + task_unlock(current);
23026 + free_fs_struct(fs_cur);
23028 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
23029 + if (IS_ERR(proxy_new)) {
23030 + ret = PTR_ERR(proxy_new);
23034 + proxy_new = xchg(¤t->nsproxy, proxy_new);
23036 + if (mask & CLONE_NEWUSER) {
23037 + struct cred *cred;
23039 + vxdprintk(VXD_CBIT(space, 10),
23040 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
23041 + vxi, vxi->vx_id, space->vx_cred,
23042 + current->real_cred, current->cred);
23044 + if (space->vx_cred) {
23045 + cred = __prepare_creds(space->vx_cred);
23047 + commit_creds(cred);
23054 + put_nsproxy(proxy_new);
23057 + put_nsproxy(proxy_cur);
23062 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23064 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
23065 + struct fs_struct *fs_vxi, *fs;
23066 + struct _vx_space *space;
23067 + int ret, kill = 0;
23069 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
23070 + vxi, vxi->vx_id, mask, index);
23072 + if ((mask & space_mask.mask) != mask)
23075 + if (index >= VX_SPACES)
23078 + space = &vxi->space[index];
23080 + proxy_vxi = space->vx_nsproxy;
23081 + fs_vxi = space->vx_fs;
23083 + if (mask & CLONE_FS) {
23084 + fs = copy_fs_struct(current->fs);
23089 + task_lock(current);
23091 + if (mask & CLONE_FS) {
23092 + spin_lock(&fs_vxi->lock);
23093 + space->vx_fs = fs;
23094 + kill = !--fs_vxi->users;
23095 + spin_unlock(&fs_vxi->lock);
23098 + proxy_cur = current->nsproxy;
23099 + get_nsproxy(proxy_cur);
23100 + task_unlock(current);
23103 + free_fs_struct(fs_vxi);
23105 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
23106 + if (IS_ERR(proxy_new)) {
23107 + ret = PTR_ERR(proxy_new);
23111 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
23112 + space->vx_nsmask |= mask;
23114 + if (mask & CLONE_NEWUSER) {
23115 + struct cred *cred;
23117 + vxdprintk(VXD_CBIT(space, 10),
23118 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
23119 + vxi, vxi->vx_id, space->vx_cred,
23120 + current->real_cred, current->cred);
23122 + cred = prepare_creds();
23123 + cred = (struct cred *)xchg(&space->vx_cred, cred);
23125 + abort_creds(cred);
23131 + put_nsproxy(proxy_new);
23134 + put_nsproxy(proxy_cur);
23139 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
23141 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23143 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23146 + return vx_enter_space(vxi, vc_data.mask, 0);
23149 +int vc_enter_space(struct vx_info *vxi, void __user *data)
23151 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23153 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23156 + if (vc_data.index >= VX_SPACES)
23159 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
23162 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
23164 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23166 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23169 + return vx_set_space(vxi, vc_data.mask, 0);
23172 +int vc_set_space(struct vx_info *vxi, void __user *data)
23174 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23176 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23179 + if (vc_data.index >= VX_SPACES)
23182 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
23185 +int vc_get_space_mask(void __user *data, int type)
23187 + const struct vcmd_space_mask_v1 *mask;
23190 + mask = &space_mask_v0;
23191 + else if (type == 1)
23192 + mask = &space_mask;
23194 + mask = &default_space_mask;
23196 + vxdprintk(VXD_CBIT(space, 10),
23197 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
23199 + if (copy_to_user(data, mask, sizeof(*mask)))
23204 diff -NurpP --minimal linux-3.0.25/kernel/vserver/switch.c linux-3.0.25-vs2.3.2.3/kernel/vserver/switch.c
23205 --- linux-3.0.25/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
23206 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/switch.c 2011-08-01 18:28:26.000000000 +0200
23209 + * linux/kernel/vserver/switch.c
23211 + * Virtual Server: Syscall Switch
23213 + * Copyright (C) 2003-2011 Herbert Pötzl
23215 + * V0.01 syscall switch
23216 + * V0.02 added signal to context
23217 + * V0.03 added rlimit functions
23218 + * V0.04 added iattr, task/xid functions
23219 + * V0.05 added debug/history stuff
23220 + * V0.06 added compat32 layer
23221 + * V0.07 vcmd args and perms
23222 + * V0.08 added status commands
23223 + * V0.09 added tag commands
23224 + * V0.10 added oom bias
23225 + * V0.11 added device commands
23226 + * V0.12 added warn mask
23230 +#include <linux/vs_context.h>
23231 +#include <linux/vs_network.h>
23232 +#include <linux/vserver/switch.h>
23234 +#include "vci_config.h"
23238 +int vc_get_version(uint32_t id)
23240 + return VCI_VERSION;
23244 +int vc_get_vci(uint32_t id)
23246 + return vci_kernel_config();
23249 +#include <linux/vserver/context_cmd.h>
23250 +#include <linux/vserver/cvirt_cmd.h>
23251 +#include <linux/vserver/cacct_cmd.h>
23252 +#include <linux/vserver/limit_cmd.h>
23253 +#include <linux/vserver/network_cmd.h>
23254 +#include <linux/vserver/sched_cmd.h>
23255 +#include <linux/vserver/debug_cmd.h>
23256 +#include <linux/vserver/inode_cmd.h>
23257 +#include <linux/vserver/dlimit_cmd.h>
23258 +#include <linux/vserver/signal_cmd.h>
23259 +#include <linux/vserver/space_cmd.h>
23260 +#include <linux/vserver/tag_cmd.h>
23261 +#include <linux/vserver/device_cmd.h>
23263 +#include <linux/vserver/inode.h>
23264 +#include <linux/vserver/dlimit.h>
23267 +#ifdef CONFIG_COMPAT
23268 +#define __COMPAT(name, id, data, compat) \
23269 + (compat) ? name ## _x32(id, data) : name(id, data)
23270 +#define __COMPAT_NO_ID(name, data, compat) \
23271 + (compat) ? name ## _x32(data) : name(data)
23273 +#define __COMPAT(name, id, data, compat) \
23275 +#define __COMPAT_NO_ID(name, data, compat) \
23281 +long do_vcmd(uint32_t cmd, uint32_t id,
23282 + struct vx_info *vxi, struct nx_info *nxi,
23283 + void __user *data, int compat)
23287 + case VCMD_get_version:
23288 + return vc_get_version(id);
23289 + case VCMD_get_vci:
23290 + return vc_get_vci(id);
23292 + case VCMD_task_xid:
23293 + return vc_task_xid(id);
23294 + case VCMD_vx_info:
23295 + return vc_vx_info(vxi, data);
23297 + case VCMD_task_nid:
23298 + return vc_task_nid(id);
23299 + case VCMD_nx_info:
23300 + return vc_nx_info(nxi, data);
23302 + case VCMD_task_tag:
23303 + return vc_task_tag(id);
23305 + case VCMD_set_space_v1:
23306 + return vc_set_space_v1(vxi, data);
23307 + /* this is version 2 */
23308 + case VCMD_set_space:
23309 + return vc_set_space(vxi, data);
23311 + case VCMD_get_space_mask_v0:
23312 + return vc_get_space_mask(data, 0);
23313 + /* this is version 1 */
23314 + case VCMD_get_space_mask:
23315 + return vc_get_space_mask(data, 1);
23317 + case VCMD_get_space_default:
23318 + return vc_get_space_mask(data, -1);
23320 + case VCMD_set_umask:
23321 + return vc_set_umask(vxi, data);
23323 + case VCMD_get_umask:
23324 + return vc_get_umask(vxi, data);
23326 + case VCMD_set_wmask:
23327 + return vc_set_wmask(vxi, data);
23329 + case VCMD_get_wmask:
23330 + return vc_get_wmask(vxi, data);
23331 +#ifdef CONFIG_IA32_EMULATION
23332 + case VCMD_get_rlimit:
23333 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23334 + case VCMD_set_rlimit:
23335 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23337 + case VCMD_get_rlimit:
23338 + return vc_get_rlimit(vxi, data);
23339 + case VCMD_set_rlimit:
23340 + return vc_set_rlimit(vxi, data);
23342 + case VCMD_get_rlimit_mask:
23343 + return vc_get_rlimit_mask(id, data);
23344 + case VCMD_reset_hits:
23345 + return vc_reset_hits(vxi, data);
23346 + case VCMD_reset_minmax:
23347 + return vc_reset_minmax(vxi, data);
23349 + case VCMD_get_vhi_name:
23350 + return vc_get_vhi_name(vxi, data);
23351 + case VCMD_set_vhi_name:
23352 + return vc_set_vhi_name(vxi, data);
23354 + case VCMD_ctx_stat:
23355 + return vc_ctx_stat(vxi, data);
23356 + case VCMD_virt_stat:
23357 + return vc_virt_stat(vxi, data);
23358 + case VCMD_sock_stat:
23359 + return vc_sock_stat(vxi, data);
23360 + case VCMD_rlimit_stat:
23361 + return vc_rlimit_stat(vxi, data);
23363 + case VCMD_set_cflags:
23364 + return vc_set_cflags(vxi, data);
23365 + case VCMD_get_cflags:
23366 + return vc_get_cflags(vxi, data);
23368 + /* this is version 1 */
23369 + case VCMD_set_ccaps:
23370 + return vc_set_ccaps(vxi, data);
23371 + /* this is version 1 */
23372 + case VCMD_get_ccaps:
23373 + return vc_get_ccaps(vxi, data);
23374 + case VCMD_set_bcaps:
23375 + return vc_set_bcaps(vxi, data);
23376 + case VCMD_get_bcaps:
23377 + return vc_get_bcaps(vxi, data);
23379 + case VCMD_set_badness:
23380 + return vc_set_badness(vxi, data);
23381 + case VCMD_get_badness:
23382 + return vc_get_badness(vxi, data);
23384 + case VCMD_set_nflags:
23385 + return vc_set_nflags(nxi, data);
23386 + case VCMD_get_nflags:
23387 + return vc_get_nflags(nxi, data);
23389 + case VCMD_set_ncaps:
23390 + return vc_set_ncaps(nxi, data);
23391 + case VCMD_get_ncaps:
23392 + return vc_get_ncaps(nxi, data);
23394 + case VCMD_set_prio_bias:
23395 + return vc_set_prio_bias(vxi, data);
23396 + case VCMD_get_prio_bias:
23397 + return vc_get_prio_bias(vxi, data);
23398 + case VCMD_add_dlimit:
23399 + return __COMPAT(vc_add_dlimit, id, data, compat);
23400 + case VCMD_rem_dlimit:
23401 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23402 + case VCMD_set_dlimit:
23403 + return __COMPAT(vc_set_dlimit, id, data, compat);
23404 + case VCMD_get_dlimit:
23405 + return __COMPAT(vc_get_dlimit, id, data, compat);
23407 + case VCMD_ctx_kill:
23408 + return vc_ctx_kill(vxi, data);
23410 + case VCMD_wait_exit:
23411 + return vc_wait_exit(vxi, data);
23413 + case VCMD_get_iattr:
23414 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23415 + case VCMD_set_iattr:
23416 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23418 + case VCMD_fget_iattr:
23419 + return vc_fget_iattr(id, data);
23420 + case VCMD_fset_iattr:
23421 + return vc_fset_iattr(id, data);
23423 + case VCMD_enter_space_v0:
23424 + return vc_enter_space_v1(vxi, NULL);
23425 + case VCMD_enter_space_v1:
23426 + return vc_enter_space_v1(vxi, data);
23427 + /* this is version 2 */
23428 + case VCMD_enter_space:
23429 + return vc_enter_space(vxi, data);
23431 + case VCMD_ctx_create_v0:
23432 + return vc_ctx_create(id, NULL);
23433 + case VCMD_ctx_create:
23434 + return vc_ctx_create(id, data);
23435 + case VCMD_ctx_migrate_v0:
23436 + return vc_ctx_migrate(vxi, NULL);
23437 + case VCMD_ctx_migrate:
23438 + return vc_ctx_migrate(vxi, data);
23440 + case VCMD_net_create_v0:
23441 + return vc_net_create(id, NULL);
23442 + case VCMD_net_create:
23443 + return vc_net_create(id, data);
23444 + case VCMD_net_migrate:
23445 + return vc_net_migrate(nxi, data);
23447 + case VCMD_tag_migrate:
23448 + return vc_tag_migrate(id);
23450 + case VCMD_net_add:
23451 + return vc_net_add(nxi, data);
23452 + case VCMD_net_remove:
23453 + return vc_net_remove(nxi, data);
23455 + case VCMD_net_add_ipv4_v1:
23456 + return vc_net_add_ipv4_v1(nxi, data);
23457 + /* this is version 2 */
23458 + case VCMD_net_add_ipv4:
23459 + return vc_net_add_ipv4(nxi, data);
23461 + case VCMD_net_rem_ipv4_v1:
23462 + return vc_net_rem_ipv4_v1(nxi, data);
23463 + /* this is version 2 */
23464 + case VCMD_net_rem_ipv4:
23465 + return vc_net_rem_ipv4(nxi, data);
23466 +#ifdef CONFIG_IPV6
23467 + case VCMD_net_add_ipv6:
23468 + return vc_net_add_ipv6(nxi, data);
23469 + case VCMD_net_remove_ipv6:
23470 + return vc_net_remove_ipv6(nxi, data);
23472 +/* case VCMD_add_match_ipv4:
23473 + return vc_add_match_ipv4(nxi, data);
23474 + case VCMD_get_match_ipv4:
23475 + return vc_get_match_ipv4(nxi, data);
23476 +#ifdef CONFIG_IPV6
23477 + case VCMD_add_match_ipv6:
23478 + return vc_add_match_ipv6(nxi, data);
23479 + case VCMD_get_match_ipv6:
23480 + return vc_get_match_ipv6(nxi, data);
23483 +#ifdef CONFIG_VSERVER_DEVICE
23484 + case VCMD_set_mapping:
23485 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23486 + case VCMD_unset_mapping:
23487 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23489 +#ifdef CONFIG_VSERVER_HISTORY
23490 + case VCMD_dump_history:
23491 + return vc_dump_history(id);
23492 + case VCMD_read_history:
23493 + return __COMPAT(vc_read_history, id, data, compat);
23496 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23497 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23503 +#define __VCMD(vcmd, _perm, _args, _flags) \
23504 + case VCMD_ ## vcmd: perm = _perm; \
23505 + args = _args; flags = _flags; break
23508 +#define VCA_NONE 0x00
23509 +#define VCA_VXI 0x01
23510 +#define VCA_NXI 0x02
23512 +#define VCF_NONE 0x00
23513 +#define VCF_INFO 0x01
23514 +#define VCF_ADMIN 0x02
23515 +#define VCF_ARES 0x06 /* includes admin */
23516 +#define VCF_SETUP 0x08
23518 +#define VCF_ZIDOK 0x10 /* zero id okay */
23522 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23525 + int permit = -1, state = 0;
23526 + int perm = -1, args = 0, flags = 0;
23527 + struct vx_info *vxi = NULL;
23528 + struct nx_info *nxi = NULL;
23531 + /* unpriviledged commands */
23532 + __VCMD(get_version, 0, VCA_NONE, 0);
23533 + __VCMD(get_vci, 0, VCA_NONE, 0);
23534 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23535 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23536 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23537 + __VCMD(get_space_default,0, VCA_NONE, 0);
23539 + /* info commands */
23540 + __VCMD(task_xid, 2, VCA_NONE, 0);
23541 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23542 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23543 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23544 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23545 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23546 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23547 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23548 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23549 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23550 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23551 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23553 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23554 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23555 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23556 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23558 + __VCMD(task_nid, 2, VCA_NONE, 0);
23559 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23560 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23561 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23563 + __VCMD(task_tag, 2, VCA_NONE, 0);
23565 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23566 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23567 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23568 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23570 + /* lower admin commands */
23571 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23572 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23573 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23574 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23575 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23576 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23577 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23578 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23580 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23581 + __VCMD(net_create, 5, VCA_NONE, 0);
23582 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23584 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23586 + /* higher admin commands */
23587 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23588 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23589 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23591 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23592 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23593 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23594 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23595 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23596 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23598 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23599 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23600 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23602 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23603 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23604 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23605 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23606 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23607 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23608 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23609 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23610 +#ifdef CONFIG_IPV6
23611 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23612 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23614 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23615 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23616 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23617 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23618 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23620 +#ifdef CONFIG_VSERVER_DEVICE
23621 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23622 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23624 + /* debug level admin commands */
23625 +#ifdef CONFIG_VSERVER_HISTORY
23626 + __VCMD(dump_history, 9, VCA_NONE, 0);
23627 + __VCMD(read_history, 9, VCA_NONE, 0);
23634 + vxdprintk(VXD_CBIT(switch, 0),
23635 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23636 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23637 + VC_VERSION(cmd), id, data, compat,
23638 + perm, args, flags);
23645 + if (!capable(CAP_CONTEXT))
23649 + /* moved here from the individual commands */
23651 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23655 + /* vcmd involves resource management */
23657 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23661 + /* various legacy exceptions */
23663 + /* will go away when spectator is a cap */
23664 + case VCMD_ctx_migrate_v0:
23665 + case VCMD_ctx_migrate:
23667 + current->xid = 1;
23673 + /* will go away when spectator is a cap */
23674 + case VCMD_net_migrate:
23676 + current->nid = 1;
23683 + /* vcmds are fine by default */
23686 + /* admin type vcmds require admin ... */
23687 + if (flags & VCF_ADMIN)
23688 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23690 + /* ... but setup type vcmds override that */
23691 + if (!permit && (flags & VCF_SETUP))
23692 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23700 + if (!id && (flags & VCF_ZIDOK))
23704 + if (args & VCA_VXI) {
23705 + vxi = lookup_vx_info(id);
23709 + if ((flags & VCF_ADMIN) &&
23710 + /* special case kill for shutdown */
23711 + (cmd != VCMD_ctx_kill) &&
23712 + /* can context be administrated? */
23713 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23719 + if (args & VCA_NXI) {
23720 + nxi = lookup_nx_info(id);
23724 + if ((flags & VCF_ADMIN) &&
23725 + /* can context be administrated? */
23726 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23733 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23736 + if ((args & VCA_NXI) && nxi)
23737 + put_nx_info(nxi);
23739 + if ((args & VCA_VXI) && vxi)
23740 + put_vx_info(vxi);
23742 + vxdprintk(VXD_CBIT(switch, 1),
23743 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23744 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23745 + VC_VERSION(cmd), ret, ret, state, permit);
23750 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23752 + return do_vserver(cmd, id, data, 0);
23755 +#ifdef CONFIG_COMPAT
23758 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23760 + return do_vserver(cmd, id, data, 1);
23763 +#endif /* CONFIG_COMPAT */
23764 diff -NurpP --minimal linux-3.0.25/kernel/vserver/sysctl.c linux-3.0.25-vs2.3.2.3/kernel/vserver/sysctl.c
23765 --- linux-3.0.25/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23766 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/sysctl.c 2011-10-27 15:18:40.000000000 +0200
23769 + * kernel/vserver/sysctl.c
23771 + * Virtual Context Support
23773 + * Copyright (C) 2004-2007 Herbert Pötzl
23775 + * V0.01 basic structure
23779 +#include <linux/module.h>
23780 +#include <linux/ctype.h>
23781 +#include <linux/sysctl.h>
23782 +#include <linux/parser.h>
23783 +#include <asm/uaccess.h>
23786 + CTL_DEBUG_ERROR = 0,
23787 + CTL_DEBUG_SWITCH = 1,
23803 +unsigned int vs_debug_switch = 0;
23804 +unsigned int vs_debug_xid = 0;
23805 +unsigned int vs_debug_nid = 0;
23806 +unsigned int vs_debug_tag = 0;
23807 +unsigned int vs_debug_net = 0;
23808 +unsigned int vs_debug_limit = 0;
23809 +unsigned int vs_debug_cres = 0;
23810 +unsigned int vs_debug_dlim = 0;
23811 +unsigned int vs_debug_quota = 0;
23812 +unsigned int vs_debug_cvirt = 0;
23813 +unsigned int vs_debug_space = 0;
23814 +unsigned int vs_debug_perm = 0;
23815 +unsigned int vs_debug_misc = 0;
23818 +static struct ctl_table_header *vserver_table_header;
23819 +static ctl_table vserver_root_table[];
23822 +void vserver_register_sysctl(void)
23824 + if (!vserver_table_header) {
23825 + vserver_table_header = register_sysctl_table(vserver_root_table);
23830 +void vserver_unregister_sysctl(void)
23832 + if (vserver_table_header) {
23833 + unregister_sysctl_table(vserver_table_header);
23834 + vserver_table_header = NULL;
23839 +static int proc_dodebug(ctl_table *table, int write,
23840 + void __user *buffer, size_t *lenp, loff_t *ppos)
23842 + char tmpbuf[20], *p, c;
23843 + unsigned int value;
23844 + size_t left, len;
23846 + if ((*ppos && !write) || !*lenp) {
23854 + if (!access_ok(VERIFY_READ, buffer, left))
23856 + p = (char *)buffer;
23857 + while (left && __get_user(c, p) >= 0 && isspace(c))
23862 + if (left > sizeof(tmpbuf) - 1)
23864 + if (copy_from_user(tmpbuf, p, left))
23866 + tmpbuf[left] = '\0';
23868 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23869 + value = 10 * value + (*p - '0');
23870 + if (*p && !isspace(*p))
23872 + while (left && isspace(*p))
23874 + *(unsigned int *)table->data = value;
23876 + if (!access_ok(VERIFY_WRITE, buffer, left))
23878 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23881 + if (__copy_to_user(buffer, tmpbuf, len))
23883 + if ((left -= len) > 0) {
23884 + if (put_user('\n', (char *)buffer + len))
23898 +#define CTL_ENTRY(ctl, name) \
23900 + .procname = #name, \
23901 + .data = &vs_ ## name, \
23902 + .maxlen = sizeof(int), \
23904 + .proc_handler = &proc_dodebug, \
23905 + .extra1 = &zero, \
23906 + .extra2 = &zero, \
23909 +static ctl_table vserver_debug_table[] = {
23910 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23911 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23912 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23913 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23914 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23915 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23916 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23917 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23918 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23919 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23920 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23921 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23922 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23926 +static ctl_table vserver_root_table[] = {
23928 + .procname = "vserver",
23930 + .child = vserver_debug_table
23936 +static match_table_t tokens = {
23937 + { CTL_DEBUG_SWITCH, "switch=%x" },
23938 + { CTL_DEBUG_XID, "xid=%x" },
23939 + { CTL_DEBUG_NID, "nid=%x" },
23940 + { CTL_DEBUG_TAG, "tag=%x" },
23941 + { CTL_DEBUG_NET, "net=%x" },
23942 + { CTL_DEBUG_LIMIT, "limit=%x" },
23943 + { CTL_DEBUG_CRES, "cres=%x" },
23944 + { CTL_DEBUG_DLIM, "dlim=%x" },
23945 + { CTL_DEBUG_QUOTA, "quota=%x" },
23946 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23947 + { CTL_DEBUG_SPACE, "space=%x" },
23948 + { CTL_DEBUG_PERM, "perm=%x" },
23949 + { CTL_DEBUG_MISC, "misc=%x" },
23950 + { CTL_DEBUG_ERROR, NULL }
23953 +#define HANDLE_CASE(id, name, val) \
23954 + case CTL_DEBUG_ ## id: \
23955 + vs_debug_ ## name = val; \
23956 + printk("vs_debug_" #name "=0x%x\n", val); \
23960 +static int __init vs_debug_setup(char *str)
23965 + printk("vs_debug_setup(%s)\n", str);
23966 + while ((p = strsep(&str, ",")) != NULL) {
23967 + substring_t args[MAX_OPT_ARGS];
23968 + unsigned int value;
23973 + token = match_token(p, tokens, args);
23974 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23977 + HANDLE_CASE(SWITCH, switch, value);
23978 + HANDLE_CASE(XID, xid, value);
23979 + HANDLE_CASE(NID, nid, value);
23980 + HANDLE_CASE(TAG, tag, value);
23981 + HANDLE_CASE(NET, net, value);
23982 + HANDLE_CASE(LIMIT, limit, value);
23983 + HANDLE_CASE(CRES, cres, value);
23984 + HANDLE_CASE(DLIM, dlim, value);
23985 + HANDLE_CASE(QUOTA, quota, value);
23986 + HANDLE_CASE(CVIRT, cvirt, value);
23987 + HANDLE_CASE(SPACE, space, value);
23988 + HANDLE_CASE(PERM, perm, value);
23989 + HANDLE_CASE(MISC, misc, value);
23998 +__setup("vsdebug=", vs_debug_setup);
24002 +EXPORT_SYMBOL_GPL(vs_debug_switch);
24003 +EXPORT_SYMBOL_GPL(vs_debug_xid);
24004 +EXPORT_SYMBOL_GPL(vs_debug_nid);
24005 +EXPORT_SYMBOL_GPL(vs_debug_net);
24006 +EXPORT_SYMBOL_GPL(vs_debug_limit);
24007 +EXPORT_SYMBOL_GPL(vs_debug_cres);
24008 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
24009 +EXPORT_SYMBOL_GPL(vs_debug_quota);
24010 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
24011 +EXPORT_SYMBOL_GPL(vs_debug_space);
24012 +EXPORT_SYMBOL_GPL(vs_debug_perm);
24013 +EXPORT_SYMBOL_GPL(vs_debug_misc);
24015 diff -NurpP --minimal linux-3.0.25/kernel/vserver/tag.c linux-3.0.25-vs2.3.2.3/kernel/vserver/tag.c
24016 --- linux-3.0.25/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
24017 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/tag.c 2011-06-10 22:11:24.000000000 +0200
24020 + * linux/kernel/vserver/tag.c
24022 + * Virtual Server: Shallow Tag Space
24024 + * Copyright (C) 2007 Herbert Pötzl
24026 + * V0.01 basic implementation
24030 +#include <linux/sched.h>
24031 +#include <linux/vserver/debug.h>
24032 +#include <linux/vs_pid.h>
24033 +#include <linux/vs_tag.h>
24035 +#include <linux/vserver/tag_cmd.h>
24038 +int dx_migrate_task(struct task_struct *p, tag_t tag)
24043 + vxdprintk(VXD_CBIT(tag, 5),
24044 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
24050 + vxdprintk(VXD_CBIT(tag, 5),
24051 + "moved task %p into [#%d]", p, tag);
24055 +/* vserver syscall commands below here */
24057 +/* taks xid and vx_info functions */
24060 +int vc_task_tag(uint32_t id)
24065 + struct task_struct *tsk;
24067 + tsk = find_task_by_real_pid(id);
24068 + tag = (tsk) ? tsk->tag : -ESRCH;
24069 + rcu_read_unlock();
24071 + tag = dx_current_tag();
24076 +int vc_tag_migrate(uint32_t tag)
24078 + return dx_migrate_task(current, tag & 0xFFFF);
24082 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
24083 --- linux-3.0.25/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
24084 +++ linux-3.0.25-vs2.3.2.3/kernel/vserver/vci_config.h 2011-06-10 22:11:24.000000000 +0200
24087 +/* interface version */
24089 +#define VCI_VERSION 0x00020308
24093 + VCI_KCBIT_NO_DYNAMIC = 0,
24095 + VCI_KCBIT_PROC_SECURE = 4,
24096 + /* VCI_KCBIT_HARDCPU = 5, */
24097 + /* VCI_KCBIT_IDLELIMIT = 6, */
24098 + /* VCI_KCBIT_IDLETIME = 7, */
24100 + VCI_KCBIT_COWBL = 8,
24101 + VCI_KCBIT_FULLCOWBL = 9,
24102 + VCI_KCBIT_SPACES = 10,
24103 + VCI_KCBIT_NETV2 = 11,
24104 + VCI_KCBIT_MEMCG = 12,
24106 + VCI_KCBIT_DEBUG = 16,
24107 + VCI_KCBIT_HISTORY = 20,
24108 + VCI_KCBIT_TAGGED = 24,
24109 + VCI_KCBIT_PPTAG = 28,
24111 + VCI_KCBIT_MORE = 31,
24115 +static inline uint32_t vci_kernel_config(void)
24118 + (1 << VCI_KCBIT_NO_DYNAMIC) |
24120 + /* configured features */
24121 +#ifdef CONFIG_VSERVER_PROC_SECURE
24122 + (1 << VCI_KCBIT_PROC_SECURE) |
24124 +#ifdef CONFIG_VSERVER_COWBL
24125 + (1 << VCI_KCBIT_COWBL) |
24126 + (1 << VCI_KCBIT_FULLCOWBL) |
24128 + (1 << VCI_KCBIT_SPACES) |
24129 + (1 << VCI_KCBIT_NETV2) |
24130 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
24131 + (1 << VCI_KCBIT_MEMCG) |
24134 + /* debug options */
24135 +#ifdef CONFIG_VSERVER_DEBUG
24136 + (1 << VCI_KCBIT_DEBUG) |
24138 +#ifdef CONFIG_VSERVER_HISTORY
24139 + (1 << VCI_KCBIT_HISTORY) |
24142 + /* inode context tagging */
24143 +#if defined(CONFIG_TAGGING_NONE)
24144 + (0 << VCI_KCBIT_TAGGED) |
24145 +#elif defined(CONFIG_TAGGING_UID16)
24146 + (1 << VCI_KCBIT_TAGGED) |
24147 +#elif defined(CONFIG_TAGGING_GID16)
24148 + (2 << VCI_KCBIT_TAGGED) |
24149 +#elif defined(CONFIG_TAGGING_ID24)
24150 + (3 << VCI_KCBIT_TAGGED) |
24151 +#elif defined(CONFIG_TAGGING_INTERN)
24152 + (4 << VCI_KCBIT_TAGGED) |
24153 +#elif defined(CONFIG_TAGGING_RUNTIME)
24154 + (5 << VCI_KCBIT_TAGGED) |
24156 + (7 << VCI_KCBIT_TAGGED) |
24158 + (1 << VCI_KCBIT_PPTAG) |
24162 diff -NurpP --minimal linux-3.0.25/mm/filemap_xip.c linux-3.0.25-vs2.3.2.3/mm/filemap_xip.c
24163 --- linux-3.0.25/mm/filemap_xip.c 2012-03-19 21:16:56.000000000 +0100
24164 +++ linux-3.0.25-vs2.3.2.3/mm/filemap_xip.c 2012-02-15 05:20:43.000000000 +0100
24166 #include <linux/seqlock.h>
24167 #include <linux/mutex.h>
24168 #include <linux/gfp.h>
24169 +#include <linux/vs_memory.h>
24170 #include <asm/tlbflush.h>
24171 #include <asm/io.h>
24173 diff -NurpP --minimal linux-3.0.25/mm/fremap.c linux-3.0.25-vs2.3.2.3/mm/fremap.c
24174 --- linux-3.0.25/mm/fremap.c 2011-07-22 11:18:12.000000000 +0200
24175 +++ linux-3.0.25-vs2.3.2.3/mm/fremap.c 2011-06-10 22:11:24.000000000 +0200
24177 #include <linux/module.h>
24178 #include <linux/syscalls.h>
24179 #include <linux/mmu_notifier.h>
24180 +#include <linux/vs_memory.h>
24182 #include <asm/mmu_context.h>
24183 #include <asm/cacheflush.h>
24184 diff -NurpP --minimal linux-3.0.25/mm/hugetlb.c linux-3.0.25-vs2.3.2.3/mm/hugetlb.c
24185 --- linux-3.0.25/mm/hugetlb.c 2012-03-19 21:16:56.000000000 +0100
24186 +++ linux-3.0.25-vs2.3.2.3/mm/hugetlb.c 2012-01-10 09:19:13.000000000 +0100
24189 #include <linux/hugetlb.h>
24190 #include <linux/node.h>
24191 +#include <linux/vs_memory.h>
24192 #include "internal.h"
24194 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
24195 diff -NurpP --minimal linux-3.0.25/mm/memcontrol.c linux-3.0.25-vs2.3.2.3/mm/memcontrol.c
24196 --- linux-3.0.25/mm/memcontrol.c 2012-03-19 21:16:56.000000000 +0100
24197 +++ linux-3.0.25-vs2.3.2.3/mm/memcontrol.c 2012-03-15 13:32:35.000000000 +0100
24198 @@ -741,6 +741,31 @@ struct mem_cgroup *mem_cgroup_from_task(
24199 struct mem_cgroup, css);
24202 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
24204 + return res_counter_read_u64(&mem->res, member);
24207 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
24209 + return res_counter_read_u64(&mem->memsw, member);
24212 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
24214 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
24217 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
24219 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
24222 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
24224 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
24227 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
24229 struct mem_cgroup *mem = NULL;
24230 diff -NurpP --minimal linux-3.0.25/mm/memory.c linux-3.0.25-vs2.3.2.3/mm/memory.c
24231 --- linux-3.0.25/mm/memory.c 2012-03-19 21:16:56.000000000 +0100
24232 +++ linux-3.0.25-vs2.3.2.3/mm/memory.c 2011-11-15 17:37:07.000000000 +0100
24233 @@ -3388,6 +3388,7 @@ int handle_pte_fault(struct mm_struct *m
24237 + int ret = 0, type = VXPT_UNKNOWN;
24240 if (!pte_present(entry)) {
24241 @@ -3412,9 +3413,12 @@ int handle_pte_fault(struct mm_struct *m
24242 if (unlikely(!pte_same(*pte, entry)))
24244 if (flags & FAULT_FLAG_WRITE) {
24245 - if (!pte_write(entry))
24246 - return do_wp_page(mm, vma, address,
24247 + if (!pte_write(entry)) {
24248 + ret = do_wp_page(mm, vma, address,
24249 pte, pmd, ptl, entry);
24250 + type = VXPT_WRITE;
24253 entry = pte_mkdirty(entry);
24255 entry = pte_mkyoung(entry);
24256 @@ -3432,7 +3436,10 @@ int handle_pte_fault(struct mm_struct *m
24259 pte_unmap_unlock(pte, ptl);
24263 + vx_page_fault(mm, vma, type, ret);
24268 diff -NurpP --minimal linux-3.0.25/mm/mremap.c linux-3.0.25-vs2.3.2.3/mm/mremap.c
24269 --- linux-3.0.25/mm/mremap.c 2011-07-22 11:18:12.000000000 +0200
24270 +++ linux-3.0.25-vs2.3.2.3/mm/mremap.c 2011-06-10 22:11:24.000000000 +0200
24272 #include <linux/security.h>
24273 #include <linux/syscalls.h>
24274 #include <linux/mmu_notifier.h>
24275 +#include <linux/vs_memory.h>
24277 #include <asm/uaccess.h>
24278 #include <asm/cacheflush.h>
24279 diff -NurpP --minimal linux-3.0.25/mm/oom_kill.c linux-3.0.25-vs2.3.2.3/mm/oom_kill.c
24280 --- linux-3.0.25/mm/oom_kill.c 2012-03-19 21:16:56.000000000 +0100
24281 +++ linux-3.0.25-vs2.3.2.3/mm/oom_kill.c 2012-01-10 09:19:13.000000000 +0100
24283 #include <linux/mempolicy.h>
24284 #include <linux/security.h>
24285 #include <linux/ptrace.h>
24286 +#include <linux/reboot.h>
24287 +#include <linux/vs_memory.h>
24288 +#include <linux/vs_context.h>
24290 int sysctl_panic_on_oom;
24291 int sysctl_oom_kill_allocating_task;
24292 @@ -134,11 +137,18 @@ struct task_struct *find_lock_task_mm(st
24293 static bool oom_unkillable_task(struct task_struct *p,
24294 const struct mem_cgroup *mem, const nodemask_t *nodemask)
24296 - if (is_global_init(p))
24297 + unsigned xid = vx_current_xid();
24299 + /* skip the init task, global and per guest */
24300 + if (task_is_init(p))
24302 if (p->flags & PF_KTHREAD)
24305 + /* skip other guest and host processes if oom in guest */
24306 + if (xid && vx_task_xid(p) != xid)
24309 /* When mem_cgroup_out_of_memory() and p is not member of the group */
24310 if (mem && !task_in_mem_cgroup(p, mem))
24312 @@ -214,6 +224,18 @@ unsigned int oom_badness(struct task_str
24313 points += p->signal->oom_score_adj;
24316 + * add points for context badness and
24317 + * reduce badness for processes belonging to
24318 + * a different context
24321 + points += vx_badness(p, p->mm);
24323 + if ((vx_current_xid() > 1) &&
24324 + vx_current_xid() != vx_task_xid(p))
24328 * Never return 0 for an eligible task that may be killed since it's
24329 * possible that no single user task uses more than 0.1% of memory and
24330 * no single admin tasks uses more than 3.0%.
24331 @@ -429,8 +451,8 @@ static int oom_kill_task(struct task_str
24332 /* mm cannot be safely dereferenced after task_unlock(p) */
24335 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24336 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
24337 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24338 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
24339 K(get_mm_counter(p->mm, MM_ANONPAGES)),
24340 K(get_mm_counter(p->mm, MM_FILEPAGES)));
24342 @@ -484,8 +506,8 @@ static int oom_kill_process(struct task_
24346 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
24347 - message, task_pid_nr(p), p->comm, points);
24348 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
24349 + message, task_pid_nr(p), p->xid, p->comm, points);
24353 @@ -586,6 +608,8 @@ int unregister_oom_notifier(struct notif
24355 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
24357 +long vs_oom_action(unsigned int);
24360 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
24361 * if a parallel OOM killing is already taking place that includes a zone in
24362 @@ -744,7 +768,12 @@ retry:
24364 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
24365 read_unlock(&tasklist_lock);
24366 - panic("Out of memory and no killable processes...\n");
24368 + /* avoid panic for guest OOM */
24369 + if (current->xid)
24370 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
24372 + panic("Out of memory and no killable processes...\n");
24375 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
24376 diff -NurpP --minimal linux-3.0.25/mm/page_alloc.c linux-3.0.25-vs2.3.2.3/mm/page_alloc.c
24377 --- linux-3.0.25/mm/page_alloc.c 2012-03-19 21:16:56.000000000 +0100
24378 +++ linux-3.0.25-vs2.3.2.3/mm/page_alloc.c 2012-01-26 08:39:53.000000000 +0100
24380 #include <linux/ftrace_event.h>
24381 #include <linux/memcontrol.h>
24382 #include <linux/prefetch.h>
24383 +#include <linux/vs_base.h>
24384 +#include <linux/vs_limit.h>
24386 #include <asm/tlbflush.h>
24387 #include <asm/div64.h>
24388 @@ -2502,6 +2504,9 @@ void si_meminfo(struct sysinfo *val)
24389 val->totalhigh = totalhigh_pages;
24390 val->freehigh = nr_free_highpages();
24391 val->mem_unit = PAGE_SIZE;
24393 + if (vx_flags(VXF_VIRT_MEM, 0))
24394 + vx_vsi_meminfo(val);
24397 EXPORT_SYMBOL(si_meminfo);
24398 @@ -2522,6 +2527,9 @@ void si_meminfo_node(struct sysinfo *val
24401 val->mem_unit = PAGE_SIZE;
24403 + if (vx_flags(VXF_VIRT_MEM, 0))
24404 + vx_vsi_meminfo(val);
24408 diff -NurpP --minimal linux-3.0.25/mm/pgtable-generic.c linux-3.0.25-vs2.3.2.3/mm/pgtable-generic.c
24409 --- linux-3.0.25/mm/pgtable-generic.c 2011-03-15 18:07:42.000000000 +0100
24410 +++ linux-3.0.25-vs2.3.2.3/mm/pgtable-generic.c 2011-06-10 22:11:24.000000000 +0200
24412 * Copyright (C) 2010 Linus Torvalds
24415 +#include <linux/mm.h>
24417 #include <linux/pagemap.h>
24418 #include <asm/tlb.h>
24419 #include <asm-generic/pgtable.h>
24420 diff -NurpP --minimal linux-3.0.25/mm/rmap.c linux-3.0.25-vs2.3.2.3/mm/rmap.c
24421 --- linux-3.0.25/mm/rmap.c 2011-07-22 11:18:12.000000000 +0200
24422 +++ linux-3.0.25-vs2.3.2.3/mm/rmap.c 2011-07-01 11:35:35.000000000 +0200
24424 #include <linux/mmu_notifier.h>
24425 #include <linux/migrate.h>
24426 #include <linux/hugetlb.h>
24427 +#include <linux/vs_memory.h>
24429 #include <asm/tlbflush.h>
24431 diff -NurpP --minimal linux-3.0.25/mm/shmem.c linux-3.0.25-vs2.3.2.3/mm/shmem.c
24432 --- linux-3.0.25/mm/shmem.c 2011-07-22 11:18:12.000000000 +0200
24433 +++ linux-3.0.25-vs2.3.2.3/mm/shmem.c 2011-07-01 11:35:35.000000000 +0200
24434 @@ -1850,7 +1850,7 @@ static int shmem_statfs(struct dentry *d
24436 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24438 - buf->f_type = TMPFS_MAGIC;
24439 + buf->f_type = TMPFS_SUPER_MAGIC;
24440 buf->f_bsize = PAGE_CACHE_SIZE;
24441 buf->f_namelen = NAME_MAX;
24442 if (sbinfo->max_blocks) {
24443 @@ -2605,7 +2605,7 @@ int shmem_fill_super(struct super_block
24444 sb->s_maxbytes = SHMEM_MAX_BYTES;
24445 sb->s_blocksize = PAGE_CACHE_SIZE;
24446 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24447 - sb->s_magic = TMPFS_MAGIC;
24448 + sb->s_magic = TMPFS_SUPER_MAGIC;
24449 sb->s_op = &shmem_ops;
24450 sb->s_time_gran = 1;
24451 #ifdef CONFIG_TMPFS_XATTR
24452 diff -NurpP --minimal linux-3.0.25/mm/slab.c linux-3.0.25-vs2.3.2.3/mm/slab.c
24453 --- linux-3.0.25/mm/slab.c 2011-07-22 11:18:12.000000000 +0200
24454 +++ linux-3.0.25-vs2.3.2.3/mm/slab.c 2011-06-15 02:41:23.000000000 +0200
24455 @@ -411,6 +411,8 @@ static void kmem_list3_init(struct kmem_
24456 #define STATS_INC_FREEMISS(x) do { } while (0)
24459 +#include "slab_vs.h"
24464 @@ -3348,6 +3350,7 @@ retry:
24466 obj = slab_get_obj(cachep, slabp, nodeid);
24467 check_slabp(cachep, slabp);
24468 + vx_slab_alloc(cachep, flags);
24469 l3->free_objects--;
24470 /* move slabp to correct slabp list: */
24471 list_del(&slabp->list);
24472 @@ -3425,6 +3428,7 @@ __cache_alloc_node(struct kmem_cache *ca
24473 /* ___cache_alloc_node can fall back to other nodes */
24474 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24476 + vx_slab_alloc(cachep, flags);
24477 local_irq_restore(save_flags);
24478 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24479 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24480 @@ -3612,6 +3616,7 @@ static inline void __cache_free(struct k
24482 kmemleak_free_recursive(objp, cachep->flags);
24483 objp = cache_free_debugcheck(cachep, objp, caller);
24484 + vx_slab_free(cachep);
24486 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24488 diff -NurpP --minimal linux-3.0.25/mm/slab_vs.h linux-3.0.25-vs2.3.2.3/mm/slab_vs.h
24489 --- linux-3.0.25/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24490 +++ linux-3.0.25-vs2.3.2.3/mm/slab_vs.h 2011-06-10 22:11:24.000000000 +0200
24493 +#include <linux/vserver/context.h>
24495 +#include <linux/vs_context.h>
24498 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24500 + int what = gfp_zone(cachep->gfpflags);
24501 + struct vx_info *vxi = current_vx_info();
24506 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24510 +void vx_slab_free(struct kmem_cache *cachep)
24512 + int what = gfp_zone(cachep->gfpflags);
24513 + struct vx_info *vxi = current_vx_info();
24518 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24521 diff -NurpP --minimal linux-3.0.25/mm/swapfile.c linux-3.0.25-vs2.3.2.3/mm/swapfile.c
24522 --- linux-3.0.25/mm/swapfile.c 2011-07-22 11:18:12.000000000 +0200
24523 +++ linux-3.0.25-vs2.3.2.3/mm/swapfile.c 2011-07-01 11:35:35.000000000 +0200
24525 #include <asm/tlbflush.h>
24526 #include <linux/swapops.h>
24527 #include <linux/page_cgroup.h>
24528 +#include <linux/vs_base.h>
24529 +#include <linux/vs_memory.h>
24531 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24533 @@ -1759,6 +1761,16 @@ static int swap_show(struct seq_file *sw
24535 if (si == SEQ_START_TOKEN) {
24536 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24537 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24538 + struct sysinfo si;
24540 + vx_vsi_swapinfo(&si);
24541 + if (si.totalswap < (1 << 10))
24543 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24544 + "hdv0", "partition", si.totalswap >> 10,
24545 + (si.totalswap - si.freeswap) >> 10, -1);
24550 @@ -2186,6 +2198,8 @@ void si_swapinfo(struct sysinfo *val)
24551 val->freeswap = nr_swap_pages + nr_to_be_unused;
24552 val->totalswap = total_swap_pages + nr_to_be_unused;
24553 spin_unlock(&swap_lock);
24554 + if (vx_flags(VXF_VIRT_MEM, 0))
24555 + vx_vsi_swapinfo(val);
24559 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
24560 --- linux-3.0.25/net/bridge/br_multicast.c 2012-03-19 21:16:57.000000000 +0100
24561 +++ linux-3.0.25-vs2.3.2.3/net/bridge/br_multicast.c 2012-03-23 14:55:24.000000000 +0100
24562 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
24563 ip6h->hop_limit = 1;
24564 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24565 if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24567 + &ip6h->saddr, NULL)) {
24571 diff -NurpP --minimal linux-3.0.25/net/core/dev.c linux-3.0.25-vs2.3.2.3/net/core/dev.c
24572 --- linux-3.0.25/net/core/dev.c 2012-03-19 21:16:57.000000000 +0100
24573 +++ linux-3.0.25-vs2.3.2.3/net/core/dev.c 2012-03-01 21:51:50.000000000 +0100
24574 @@ -127,6 +127,7 @@
24575 #include <linux/in.h>
24576 #include <linux/jhash.h>
24577 #include <linux/random.h>
24578 +#include <linux/vs_inet.h>
24579 #include <trace/events/napi.h>
24580 #include <trace/events/net.h>
24581 #include <trace/events/skb.h>
24582 @@ -609,7 +610,8 @@ struct net_device *__dev_get_by_name(str
24583 struct hlist_head *head = dev_name_hash(net, name);
24585 hlist_for_each_entry(dev, p, head, name_hlist)
24586 - if (!strncmp(dev->name, name, IFNAMSIZ))
24587 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24588 + nx_dev_visible(current_nx_info(), dev))
24592 @@ -635,7 +637,8 @@ struct net_device *dev_get_by_name_rcu(s
24593 struct hlist_head *head = dev_name_hash(net, name);
24595 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24596 - if (!strncmp(dev->name, name, IFNAMSIZ))
24597 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24598 + nx_dev_visible(current_nx_info(), dev))
24602 @@ -686,7 +689,8 @@ struct net_device *__dev_get_by_index(st
24603 struct hlist_head *head = dev_index_hash(net, ifindex);
24605 hlist_for_each_entry(dev, p, head, index_hlist)
24606 - if (dev->ifindex == ifindex)
24607 + if ((dev->ifindex == ifindex) &&
24608 + nx_dev_visible(current_nx_info(), dev))
24612 @@ -704,7 +708,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24613 * about locking. The caller must hold RCU lock.
24616 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24617 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24619 struct hlist_node *p;
24620 struct net_device *dev;
24621 @@ -716,6 +720,16 @@ struct net_device *dev_get_by_index_rcu(
24625 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24627 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24629 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24631 + if (nx_dev_visible(current_nx_info(), dev))
24635 EXPORT_SYMBOL(dev_get_by_index_rcu);
24638 @@ -764,7 +778,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24640 for_each_netdev_rcu(net, dev)
24641 if (dev->type == type &&
24642 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24643 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24644 + nx_dev_visible(current_nx_info(), dev))
24648 @@ -776,9 +791,11 @@ struct net_device *__dev_getfirstbyhwtyp
24649 struct net_device *dev;
24652 - for_each_netdev(net, dev)
24653 - if (dev->type == type)
24654 + for_each_netdev(net, dev) {
24655 + if ((dev->type == type) &&
24656 + nx_dev_visible(current_nx_info(), dev))
24662 @@ -896,6 +913,8 @@ static int __dev_alloc_name(struct net *
24664 if (i < 0 || i >= max_netdevices)
24666 + if (!nx_dev_visible(current_nx_info(), d))
24669 /* avoid cases where sscanf is not exact inverse of printf */
24670 snprintf(buf, IFNAMSIZ, name, i);
24671 @@ -3943,6 +3962,8 @@ static int dev_ifconf(struct net *net, c
24674 for_each_netdev(net, dev) {
24675 + if (!nx_dev_visible(current_nx_info(), dev))
24677 for (i = 0; i < NPROTO; i++) {
24678 if (gifconf_list[i]) {
24680 @@ -4017,6 +4038,10 @@ static void dev_seq_printf_stats(struct
24681 struct rtnl_link_stats64 temp;
24682 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24684 + /* device visible inside network context? */
24685 + if (!nx_dev_visible(current_nx_info(), dev))
24688 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24689 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24690 dev->name, stats->rx_bytes, stats->rx_packets,
24691 diff -NurpP --minimal linux-3.0.25/net/core/rtnetlink.c linux-3.0.25-vs2.3.2.3/net/core/rtnetlink.c
24692 --- linux-3.0.25/net/core/rtnetlink.c 2011-07-22 11:18:13.000000000 +0200
24693 +++ linux-3.0.25-vs2.3.2.3/net/core/rtnetlink.c 2011-06-10 22:11:24.000000000 +0200
24694 @@ -1015,6 +1015,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24695 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
24698 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24700 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24701 NETLINK_CB(cb->skb).pid,
24702 cb->nlh->nlmsg_seq, 0,
24703 @@ -1848,6 +1850,9 @@ void rtmsg_ifinfo(int type, struct net_d
24704 struct sk_buff *skb;
24705 int err = -ENOBUFS;
24707 + if (!nx_dev_visible(current_nx_info(), dev))
24710 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
24713 diff -NurpP --minimal linux-3.0.25/net/core/sock.c linux-3.0.25-vs2.3.2.3/net/core/sock.c
24714 --- linux-3.0.25/net/core/sock.c 2012-03-19 21:16:57.000000000 +0100
24715 +++ linux-3.0.25-vs2.3.2.3/net/core/sock.c 2011-11-15 17:37:07.000000000 +0100
24716 @@ -127,6 +127,10 @@
24717 #include <net/cls_cgroup.h>
24719 #include <linux/filter.h>
24720 +#include <linux/vs_socket.h>
24721 +#include <linux/vs_limit.h>
24722 +#include <linux/vs_context.h>
24723 +#include <linux/vs_network.h>
24726 #include <net/tcp.h>
24727 @@ -1070,6 +1074,8 @@ static struct sock *sk_prot_alloc(struct
24729 sk_tx_queue_clear(sk);
24731 + sock_vx_init(sk);
24732 + sock_nx_init(sk);
24736 @@ -1169,6 +1175,11 @@ static void __sk_free(struct sock *sk)
24737 put_cred(sk->sk_peer_cred);
24738 put_pid(sk->sk_peer_pid);
24739 put_net(sock_net(sk));
24741 + clr_vx_info(&sk->sk_vx_info);
24743 + clr_nx_info(&sk->sk_nx_info);
24745 sk_prot_free(sk->sk_prot_creator, sk);
24748 @@ -1216,6 +1227,8 @@ struct sock *sk_clone(const struct sock
24751 get_net(sock_net(newsk));
24752 + sock_vx_init(newsk);
24753 + sock_nx_init(newsk);
24754 sk_node_init(&newsk->sk_node);
24755 sock_lock_init(newsk);
24756 bh_lock_sock(newsk);
24757 @@ -1272,6 +1285,12 @@ struct sock *sk_clone(const struct sock
24759 atomic_set(&newsk->sk_refcnt, 2);
24761 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24762 + newsk->sk_xid = sk->sk_xid;
24763 + vx_sock_inc(newsk);
24764 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24765 + newsk->sk_nid = sk->sk_nid;
24768 * Increment the counter in the same struct proto as the master
24769 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24770 @@ -2018,6 +2037,12 @@ void sock_init_data(struct socket *sock,
24772 sk->sk_stamp = ktime_set(-1L, 0);
24774 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24775 + sk->sk_xid = vx_current_xid();
24777 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24778 + sk->sk_nid = nx_current_nid();
24781 * Before updating sk_refcnt, we must commit prior changes to memory
24782 * (Documentation/RCU/rculist_nulls.txt for details)
24783 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
24784 --- linux-3.0.25/net/ipv4/af_inet.c 2011-07-22 11:18:13.000000000 +0200
24785 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/af_inet.c 2011-07-19 00:44:39.000000000 +0200
24786 @@ -117,6 +117,7 @@
24787 #ifdef CONFIG_IP_MROUTE
24788 #include <linux/mroute.h>
24790 +#include <linux/vs_limit.h>
24793 /* The inetsw table contains everything that inet_create needs to
24794 @@ -326,9 +327,13 @@ lookup_protocol:
24798 + if ((protocol == IPPROTO_ICMP) &&
24799 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24802 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24803 goto out_rcu_unlock;
24806 err = -EAFNOSUPPORT;
24807 if (!inet_netns_ok(net, protocol))
24808 goto out_rcu_unlock;
24809 @@ -452,6 +457,7 @@ int inet_bind(struct socket *sock, struc
24810 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24811 struct sock *sk = sock->sk;
24812 struct inet_sock *inet = inet_sk(sk);
24813 + struct nx_v4_sock_addr nsa;
24814 unsigned short snum;
24817 @@ -470,7 +476,11 @@ int inet_bind(struct socket *sock, struc
24821 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24822 + err = v4_map_sock_addr(inet, addr, &nsa);
24826 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24828 /* Not specified by any standard per-se, however it breaks too
24829 * many applications when removed. It is unfortunate since
24830 @@ -482,7 +492,7 @@ int inet_bind(struct socket *sock, struc
24831 err = -EADDRNOTAVAIL;
24832 if (!sysctl_ip_nonlocal_bind &&
24833 !(inet->freebind || inet->transparent) &&
24834 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24835 + nsa.saddr != htonl(INADDR_ANY) &&
24836 chk_addr_ret != RTN_LOCAL &&
24837 chk_addr_ret != RTN_MULTICAST &&
24838 chk_addr_ret != RTN_BROADCAST)
24839 @@ -507,7 +517,7 @@ int inet_bind(struct socket *sock, struc
24840 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24841 goto out_release_sock;
24843 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24844 + v4_set_sock_addr(inet, &nsa);
24845 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24846 inet->inet_saddr = 0; /* Use device */
24848 @@ -710,11 +720,13 @@ int inet_getname(struct socket *sock, st
24851 sin->sin_port = inet->inet_dport;
24852 - sin->sin_addr.s_addr = inet->inet_daddr;
24853 + sin->sin_addr.s_addr =
24854 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24856 __be32 addr = inet->inet_rcv_saddr;
24858 addr = inet->inet_saddr;
24859 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24860 sin->sin_port = inet->inet_sport;
24861 sin->sin_addr.s_addr = addr;
24863 diff -NurpP --minimal linux-3.0.25/net/ipv4/arp.c linux-3.0.25-vs2.3.2.3/net/ipv4/arp.c
24864 --- linux-3.0.25/net/ipv4/arp.c 2012-03-19 21:16:57.000000000 +0100
24865 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/arp.c 2012-03-01 21:51:50.000000000 +0100
24866 @@ -1372,6 +1372,7 @@ static void arp_format_neigh_entry(struc
24867 struct net_device *dev = n->dev;
24868 int hatype = dev->type;
24870 + /* FIXME: check for network context */
24871 read_lock(&n->lock);
24872 /* Convert hardware address to XX:XX:XX:XX ... form. */
24873 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
24874 @@ -1403,6 +1404,7 @@ static void arp_format_pneigh_entry(stru
24875 int hatype = dev ? dev->type : 0;
24878 + /* FIXME: check for network context */
24879 sprintf(tbuf, "%pI4", n->key);
24880 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24881 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24882 diff -NurpP --minimal linux-3.0.25/net/ipv4/devinet.c linux-3.0.25-vs2.3.2.3/net/ipv4/devinet.c
24883 --- linux-3.0.25/net/ipv4/devinet.c 2012-03-19 21:16:57.000000000 +0100
24884 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/devinet.c 2012-01-10 09:19:13.000000000 +0100
24885 @@ -518,6 +518,7 @@ struct in_device *inetdev_by_index(struc
24887 EXPORT_SYMBOL(inetdev_by_index);
24890 /* Called only from RTNL semaphored context. No locks. */
24892 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24893 @@ -759,6 +760,8 @@ int devinet_ioctl(struct net *net, unsig
24895 in_dev = __in_dev_get_rtnl(dev);
24897 + struct nx_info *nxi = current_nx_info();
24899 if (tryaddrmatch) {
24900 /* Matthias Andree */
24901 /* compare label and address (4.4BSD style) */
24902 @@ -767,6 +770,8 @@ int devinet_ioctl(struct net *net, unsig
24903 This is checked above. */
24904 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24905 ifap = &ifa->ifa_next) {
24906 + if (!nx_v4_ifa_visible(nxi, ifa))
24908 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24909 sin_orig.sin_addr.s_addr ==
24911 @@ -779,9 +784,12 @@ int devinet_ioctl(struct net *net, unsig
24912 comparing just the label */
24914 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24915 - ifap = &ifa->ifa_next)
24916 + ifap = &ifa->ifa_next) {
24917 + if (!nx_v4_ifa_visible(nxi, ifa))
24919 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24925 @@ -934,6 +942,8 @@ static int inet_gifconf(struct net_devic
24928 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24929 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24932 done += sizeof(ifr);
24934 @@ -1294,6 +1304,7 @@ static int inet_dump_ifaddr(struct sk_bu
24935 struct net_device *dev;
24936 struct in_device *in_dev;
24937 struct in_ifaddr *ifa;
24938 + struct sock *sk = skb->sk;
24939 struct hlist_head *head;
24940 struct hlist_node *node;
24942 @@ -1316,6 +1327,8 @@ static int inet_dump_ifaddr(struct sk_bu
24944 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24945 ifa = ifa->ifa_next, ip_idx++) {
24946 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24948 if (ip_idx < s_ip_idx)
24950 if (inet_fill_ifaddr(skb, ifa,
24951 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
24952 --- linux-3.0.25/net/ipv4/fib_trie.c 2011-07-22 11:18:13.000000000 +0200
24953 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/fib_trie.c 2011-08-29 04:56:47.000000000 +0200
24954 @@ -2554,6 +2554,7 @@ static int fib_route_seq_show(struct seq
24955 || fa->fa_type == RTN_MULTICAST)
24958 + /* FIXME: check for network context? */
24961 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24962 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
24963 --- linux-3.0.25/net/ipv4/inet_connection_sock.c 2011-07-22 11:18:13.000000000 +0200
24964 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/inet_connection_sock.c 2011-06-10 22:11:24.000000000 +0200
24965 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
24967 EXPORT_SYMBOL(inet_get_local_port_range);
24969 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24971 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24972 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24974 + if (inet_v6_ipv6only(sk2))
24977 + if (sk1_rcv_saddr &&
24979 + sk1_rcv_saddr == sk2_rcv_saddr)
24982 + if (sk1_rcv_saddr &&
24983 + !sk2_rcv_saddr &&
24984 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24987 + if (sk2_rcv_saddr &&
24988 + !sk1_rcv_saddr &&
24989 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24992 + if (!sk1_rcv_saddr &&
24993 + !sk2_rcv_saddr &&
24994 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
25000 int inet_csk_bind_conflict(const struct sock *sk,
25001 const struct inet_bind_bucket *tb)
25003 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
25004 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
25005 if (!reuse || !sk2->sk_reuse ||
25006 sk2->sk_state == TCP_LISTEN) {
25007 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25008 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
25009 - sk2_rcv_saddr == sk_rcv_saddr(sk))
25010 + if (ipv4_rcv_saddr_equal(sk, sk2))
25014 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
25015 --- linux-3.0.25/net/ipv4/inet_diag.c 2011-07-22 11:18:13.000000000 +0200
25016 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/inet_diag.c 2011-06-22 12:39:16.000000000 +0200
25018 #include <linux/stddef.h>
25020 #include <linux/inet_diag.h>
25021 +#include <linux/vs_network.h>
25022 +#include <linux/vs_inet.h>
25024 static const struct inet_diag_handler **inet_diag_table;
25026 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
25028 r->id.idiag_sport = inet->inet_sport;
25029 r->id.idiag_dport = inet->inet_dport;
25030 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
25031 - r->id.idiag_dst[0] = inet->inet_daddr;
25032 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
25033 + inet->inet_rcv_saddr);
25034 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
25035 + inet->inet_daddr);
25037 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25038 if (r->idiag_family == AF_INET6) {
25039 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
25040 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
25041 r->id.idiag_sport = tw->tw_sport;
25042 r->id.idiag_dport = tw->tw_dport;
25043 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
25044 - r->id.idiag_dst[0] = tw->tw_daddr;
25045 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
25046 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
25047 r->idiag_state = tw->tw_substate;
25048 r->idiag_timer = 3;
25049 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
25050 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
25053 if (req->idiag_family == AF_INET) {
25054 + /* TODO: lback */
25055 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
25056 req->id.idiag_dport, req->id.idiag_src[0],
25057 req->id.idiag_sport, req->id.idiag_if);
25058 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
25062 + /* TODO: lback */
25063 entry.saddr = &inet->inet_rcv_saddr;
25064 entry.daddr = &inet->inet_daddr;
25066 @@ -543,6 +549,7 @@ static int inet_twsk_diag_dump(struct in
25070 + /* TODO: lback */
25071 entry.saddr = &tw->tw_rcv_saddr;
25072 entry.daddr = &tw->tw_daddr;
25074 @@ -589,8 +596,8 @@ static int inet_diag_fill_req(struct sk_
25076 r->id.idiag_sport = inet->inet_sport;
25077 r->id.idiag_dport = ireq->rmt_port;
25078 - r->id.idiag_src[0] = ireq->loc_addr;
25079 - r->id.idiag_dst[0] = ireq->rmt_addr;
25080 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
25081 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
25082 r->idiag_expires = jiffies_to_msecs(tmo);
25083 r->idiag_rqueue = 0;
25084 r->idiag_wqueue = 0;
25085 @@ -661,6 +668,7 @@ static int inet_diag_dump_reqs(struct sk
25089 + /* TODO: lback */
25091 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25092 (entry.family == AF_INET6) ?
25093 @@ -731,6 +739,8 @@ static int inet_diag_dump(struct sk_buff
25094 sk_nulls_for_each(sk, node, &ilb->head) {
25095 struct inet_sock *inet = inet_sk(sk);
25097 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25102 @@ -797,6 +807,8 @@ skip_listen_ht:
25103 sk_nulls_for_each(sk, node, &head->chain) {
25104 struct inet_sock *inet = inet_sk(sk);
25106 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25110 if (!(r->idiag_states & (1 << sk->sk_state)))
25111 @@ -821,6 +833,8 @@ next_normal:
25112 inet_twsk_for_each(tw, node,
25115 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25119 if (r->id.idiag_sport != tw->tw_sport &&
25120 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
25121 --- linux-3.0.25/net/ipv4/inet_hashtables.c 2012-03-19 21:16:57.000000000 +0100
25122 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/inet_hashtables.c 2011-08-29 03:45:56.000000000 +0200
25124 #include <net/inet_connection_sock.h>
25125 #include <net/inet_hashtables.h>
25126 #include <net/secure_seq.h>
25127 +#include <net/route.h>
25128 #include <net/ip.h>
25131 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
25132 if (rcv_saddr != daddr)
25136 + /* block non nx_info ips */
25137 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25138 + daddr, NXA_MASK_BIND))
25141 if (sk->sk_bound_dev_if) {
25142 if (sk->sk_bound_dev_if != dif)
25143 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
25144 * wildcarded during the search since they can never be otherwise.
25148 struct sock *__inet_lookup_listener(struct net *net,
25149 struct inet_hashinfo *hashinfo,
25150 const __be32 daddr, const unsigned short hnum,
25151 @@ -196,6 +201,7 @@ begin:
25157 * if the nulls value we got at the end of this lookup is
25158 * not the expected one, we must restart lookup.
25159 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
25160 --- linux-3.0.25/net/ipv4/netfilter/nf_nat_helper.c 2011-07-22 11:18:13.000000000 +0200
25161 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/netfilter/nf_nat_helper.c 2011-06-15 02:40:14.000000000 +0200
25163 #include <net/route.h>
25165 #include <linux/netfilter_ipv4.h>
25166 +#include <net/route.h>
25167 #include <net/netfilter/nf_conntrack.h>
25168 #include <net/netfilter/nf_conntrack_helper.h>
25169 #include <net/netfilter/nf_conntrack_ecache.h>
25170 diff -NurpP --minimal linux-3.0.25/net/ipv4/netfilter.c linux-3.0.25-vs2.3.2.3/net/ipv4/netfilter.c
25171 --- linux-3.0.25/net/ipv4/netfilter.c 2012-03-19 21:16:57.000000000 +0100
25172 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/netfilter.c 2011-10-18 13:51:13.000000000 +0200
25174 #include <linux/ip.h>
25175 #include <linux/skbuff.h>
25176 #include <linux/gfp.h>
25177 -#include <net/route.h>
25178 +// #include <net/route.h>
25179 #include <net/xfrm.h>
25180 #include <net/ip.h>
25181 #include <net/netfilter/nf_queue.h>
25182 diff -NurpP --minimal linux-3.0.25/net/ipv4/raw.c linux-3.0.25-vs2.3.2.3/net/ipv4/raw.c
25183 --- linux-3.0.25/net/ipv4/raw.c 2011-07-22 11:18:13.000000000 +0200
25184 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/raw.c 2011-07-27 20:26:04.000000000 +0200
25185 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
25187 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
25188 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
25189 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
25190 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
25191 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
25192 goto found; /* gotcha */
25194 @@ -385,6 +385,12 @@ static int raw_send_hdrinc(struct sock *
25195 icmp_out_count(net, ((struct icmphdr *)
25196 skb_transport_header(skb))->type);
25199 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
25200 + sk->sk_nx_info &&
25201 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
25204 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
25205 rt->dst.dev, dst_output);
25207 @@ -571,6 +577,16 @@ static int raw_sendmsg(struct kiocb *ioc
25211 + if (sk->sk_nx_info) {
25212 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
25213 + if (IS_ERR(rt)) {
25214 + err = PTR_ERR(rt);
25221 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
25222 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
25224 @@ -647,17 +663,19 @@ static int raw_bind(struct sock *sk, str
25226 struct inet_sock *inet = inet_sk(sk);
25227 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
25228 + struct nx_v4_sock_addr nsa = { 0 };
25232 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
25234 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25235 + v4_map_sock_addr(inet, addr, &nsa);
25236 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25237 ret = -EADDRNOTAVAIL;
25238 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
25239 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
25240 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
25242 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25243 + v4_set_sock_addr(inet, &nsa);
25244 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25245 inet->inet_saddr = 0; /* Use device */
25247 @@ -709,7 +727,8 @@ static int raw_recvmsg(struct kiocb *ioc
25248 /* Copy the address. */
25250 sin->sin_family = AF_INET;
25251 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25252 + sin->sin_addr.s_addr =
25253 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
25255 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
25257 @@ -905,7 +924,8 @@ static struct sock *raw_get_first(struct
25258 struct hlist_node *node;
25260 sk_for_each(sk, node, &state->h->ht[state->bucket])
25261 - if (sock_net(sk) == seq_file_net(seq))
25262 + if ((sock_net(sk) == seq_file_net(seq)) &&
25263 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25267 @@ -921,7 +941,8 @@ static struct sock *raw_get_next(struct
25271 - } while (sk && sock_net(sk) != seq_file_net(seq));
25272 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
25273 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25275 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
25276 sk = sk_head(&state->h->ht[state->bucket]);
25277 diff -NurpP --minimal linux-3.0.25/net/ipv4/route.c linux-3.0.25-vs2.3.2.3/net/ipv4/route.c
25278 --- linux-3.0.25/net/ipv4/route.c 2012-03-19 21:16:57.000000000 +0100
25279 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/route.c 2012-03-01 21:51:50.000000000 +0100
25280 @@ -2658,7 +2658,7 @@ static struct rtable *ip_route_output_sl
25283 if (fl4->flowi4_oif) {
25284 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
25285 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
25286 rth = ERR_PTR(-ENODEV);
25287 if (dev_out == NULL)
25289 diff -NurpP --minimal linux-3.0.25/net/ipv4/tcp.c linux-3.0.25-vs2.3.2.3/net/ipv4/tcp.c
25290 --- linux-3.0.25/net/ipv4/tcp.c 2011-07-22 11:18:13.000000000 +0200
25291 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/tcp.c 2011-07-19 00:44:39.000000000 +0200
25292 @@ -266,6 +266,7 @@
25293 #include <linux/crypto.h>
25294 #include <linux/time.h>
25295 #include <linux/slab.h>
25296 +#include <linux/in.h>
25298 #include <net/icmp.h>
25299 #include <net/tcp.h>
25300 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
25301 --- linux-3.0.25/net/ipv4/tcp_ipv4.c 2012-03-19 21:16:57.000000000 +0100
25302 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/tcp_ipv4.c 2012-03-01 21:51:50.000000000 +0100
25303 @@ -2011,6 +2011,12 @@ static void *listening_get_next(struct s
25304 req = req->dl_next;
25307 + vxdprintk(VXD_CBIT(net, 6),
25308 + "sk,req: %p [#%d] (from %d)", req->sk,
25309 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
25311 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
25313 if (req->rsk_ops->family == st->family) {
25316 @@ -2035,6 +2041,10 @@ get_req:
25319 sk_nulls_for_each_from(sk, node) {
25320 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
25321 + sk, sk->sk_nid, nx_current_nid());
25322 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25324 if (!net_eq(sock_net(sk), net))
25326 if (sk->sk_family == st->family) {
25327 @@ -2111,6 +2121,11 @@ static void *established_get_first(struc
25329 spin_lock_bh(lock);
25330 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
25331 + vxdprintk(VXD_CBIT(net, 6),
25332 + "sk,egf: %p [#%d] (from %d)",
25333 + sk, sk->sk_nid, nx_current_nid());
25334 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25336 if (sk->sk_family != st->family ||
25337 !net_eq(sock_net(sk), net)) {
25339 @@ -2121,6 +2136,11 @@ static void *established_get_first(struc
25340 st->state = TCP_SEQ_STATE_TIME_WAIT;
25341 inet_twsk_for_each(tw, node,
25342 &tcp_hashinfo.ehash[st->bucket].twchain) {
25343 + vxdprintk(VXD_CBIT(net, 6),
25344 + "tw: %p [#%d] (from %d)",
25345 + tw, tw->tw_nid, nx_current_nid());
25346 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25348 if (tw->tw_family != st->family ||
25349 !net_eq(twsk_net(tw), net)) {
25351 @@ -2150,7 +2170,9 @@ static void *established_get_next(struct
25355 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
25356 + while (tw && (tw->tw_family != st->family ||
25357 + !net_eq(twsk_net(tw), net) ||
25358 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
25362 @@ -2174,6 +2196,11 @@ get_tw:
25363 sk = sk_nulls_next(sk);
25365 sk_nulls_for_each_from(sk, node) {
25366 + vxdprintk(VXD_CBIT(net, 6),
25367 + "sk,egn: %p [#%d] (from %d)",
25368 + sk, sk->sk_nid, nx_current_nid());
25369 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25371 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
25374 @@ -2383,9 +2410,9 @@ static void get_openreq4(struct sock *sk
25375 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25376 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
25379 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
25380 ntohs(inet_sk(sk)->inet_sport),
25382 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
25383 ntohs(ireq->rmt_port),
25385 0, 0, /* could print option size, but that is af dependent. */
25386 @@ -2407,8 +2434,8 @@ static void get_tcp4_sock(struct sock *s
25387 struct tcp_sock *tp = tcp_sk(sk);
25388 const struct inet_connection_sock *icsk = inet_csk(sk);
25389 struct inet_sock *inet = inet_sk(sk);
25390 - __be32 dest = inet->inet_daddr;
25391 - __be32 src = inet->inet_rcv_saddr;
25392 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
25393 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
25394 __u16 destp = ntohs(inet->inet_dport);
25395 __u16 srcp = ntohs(inet->inet_sport);
25397 @@ -2465,8 +2492,8 @@ static void get_timewait4_sock(struct in
25401 - dest = tw->tw_daddr;
25402 - src = tw->tw_rcv_saddr;
25403 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
25404 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
25405 destp = ntohs(tw->tw_dport);
25406 srcp = ntohs(tw->tw_sport);
25408 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
25409 --- linux-3.0.25/net/ipv4/tcp_minisocks.c 2011-03-15 18:07:45.000000000 +0100
25410 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/tcp_minisocks.c 2011-06-10 22:11:24.000000000 +0200
25412 #include <linux/slab.h>
25413 #include <linux/sysctl.h>
25414 #include <linux/workqueue.h>
25415 +#include <linux/vs_limit.h>
25416 +#include <linux/vs_socket.h>
25417 +#include <linux/vs_context.h>
25418 #include <net/tcp.h>
25419 #include <net/inet_common.h>
25420 #include <net/xfrm.h>
25421 @@ -335,6 +338,11 @@ void tcp_time_wait(struct sock *sk, int
25422 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25423 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25425 + tw->tw_xid = sk->sk_xid;
25426 + tw->tw_vx_info = NULL;
25427 + tw->tw_nid = sk->sk_nid;
25428 + tw->tw_nx_info = NULL;
25430 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25431 if (tw->tw_family == PF_INET6) {
25432 struct ipv6_pinfo *np = inet6_sk(sk);
25433 diff -NurpP --minimal linux-3.0.25/net/ipv4/udp.c linux-3.0.25-vs2.3.2.3/net/ipv4/udp.c
25434 --- linux-3.0.25/net/ipv4/udp.c 2011-07-22 11:18:13.000000000 +0200
25435 +++ linux-3.0.25-vs2.3.2.3/net/ipv4/udp.c 2011-07-27 20:26:14.000000000 +0200
25436 @@ -296,14 +296,7 @@ fail:
25438 EXPORT_SYMBOL(udp_lib_get_port);
25440 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25442 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25444 - return (!ipv6_only_sock(sk2) &&
25445 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25446 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25448 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25450 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25452 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
25453 if (inet->inet_rcv_saddr != daddr)
25457 + /* block non nx_info ips */
25458 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25459 + daddr, NXA_MASK_BIND))
25462 if (inet->inet_daddr) {
25463 if (inet->inet_daddr != saddr)
25464 @@ -441,6 +439,7 @@ exact_match:
25469 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25470 * harder than this. -DaveM
25472 @@ -486,6 +485,11 @@ begin:
25473 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25474 score = compute_score(sk, net, saddr, hnum, sport,
25475 daddr, dport, dif);
25476 + /* FIXME: disabled?
25477 + if (score == 9) {
25481 if (score > badness) {
25484 @@ -499,6 +503,7 @@ begin:
25485 if (get_nulls_value(node) != slot)
25490 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25492 @@ -508,6 +513,7 @@ begin:
25500 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
25501 udp_sk(s)->udp_port_hash != hnum ||
25502 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25503 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25504 - (inet->inet_rcv_saddr &&
25505 - inet->inet_rcv_saddr != loc_addr) ||
25506 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25507 ipv6_only_sock(s) ||
25508 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25510 @@ -929,6 +934,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
25511 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
25512 faddr, saddr, dport, inet->inet_sport);
25514 + if (sk->sk_nx_info) {
25515 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
25516 + if (IS_ERR(rt)) {
25517 + err = PTR_ERR(rt);
25524 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
25525 rt = ip_route_output_flow(net, fl4, sk);
25527 @@ -1226,7 +1241,8 @@ try_again:
25529 sin->sin_family = AF_INET;
25530 sin->sin_port = udp_hdr(skb)->source;
25531 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25532 + sin->sin_addr.s_addr = nx_map_sock_lback(
25533 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25534 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25536 if (inet->cmsg_flags)
25537 @@ -1970,6 +1986,8 @@ static struct sock *udp_get_first(struct
25538 sk_nulls_for_each(sk, node, &hslot->head) {
25539 if (!net_eq(sock_net(sk), net))
25541 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25543 if (sk->sk_family == state->family)
25546 @@ -1987,7 +2005,9 @@ static struct sock *udp_get_next(struct
25549 sk = sk_nulls_next(sk);
25550 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25551 + } while (sk && (!net_eq(sock_net(sk), net) ||
25552 + sk->sk_family != state->family ||
25553 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25556 if (state->bucket <= state->udp_table->mask)
25557 diff -NurpP --minimal linux-3.0.25/net/ipv6/Kconfig linux-3.0.25-vs2.3.2.3/net/ipv6/Kconfig
25558 --- linux-3.0.25/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25559 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/Kconfig 2011-06-10 22:11:24.000000000 +0200
25562 # IPv6 as module will cause a CRASH if you try to unload it
25564 - tristate "The IPv6 protocol"
25566 + bool "The IPv6 protocol"
25569 This is complemental support for the IP version 6.
25570 You will still be able to do traditional IPv4 networking as well.
25571 diff -NurpP --minimal linux-3.0.25/net/ipv6/addrconf.c linux-3.0.25-vs2.3.2.3/net/ipv6/addrconf.c
25572 --- linux-3.0.25/net/ipv6/addrconf.c 2012-03-19 21:16:57.000000000 +0100
25573 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/addrconf.c 2012-03-23 14:54:00.000000000 +0100
25576 #include <linux/proc_fs.h>
25577 #include <linux/seq_file.h>
25578 +#include <linux/vs_network.h>
25579 +#include <linux/vs_inet6.h>
25581 /* Set to 3 to get tracing... */
25582 #define ACONF_DEBUG 2
25583 @@ -1112,7 +1114,7 @@ out:
25585 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25586 const struct in6_addr *daddr, unsigned int prefs,
25587 - struct in6_addr *saddr)
25588 + struct in6_addr *saddr, struct nx_info *nxi)
25590 struct ipv6_saddr_score scores[2],
25591 *score = &scores[0], *hiscore = &scores[1];
25592 @@ -1184,6 +1186,8 @@ int ipv6_dev_get_saddr(struct net *net,
25596 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25600 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25601 @@ -3052,7 +3056,10 @@ static void if6_seq_stop(struct seq_file
25602 static int if6_seq_show(struct seq_file *seq, void *v)
25604 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25605 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25607 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25608 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25609 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25611 ifp->idev->dev->ifindex,
25613 @@ -3558,6 +3565,11 @@ static int in6_dump_addrs(struct inet6_d
25614 struct ifacaddr6 *ifaca;
25616 int ip_idx = *p_ip_idx;
25617 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25619 + /* disable ipv6 on non v6 guests */
25620 + if (nxi && !nx_info_has_v6(nxi))
25623 read_lock_bh(&idev->lock);
25625 @@ -3568,6 +3580,8 @@ static int in6_dump_addrs(struct inet6_d
25626 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25627 if (++ip_idx < s_ip_idx)
25629 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25631 err = inet6_fill_ifaddr(skb, ifa,
25632 NETLINK_CB(cb->skb).pid,
25633 cb->nlh->nlmsg_seq,
25634 @@ -3584,6 +3598,8 @@ static int in6_dump_addrs(struct inet6_d
25635 ifmca = ifmca->next, ip_idx++) {
25636 if (ip_idx < s_ip_idx)
25638 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25640 err = inet6_fill_ifmcaddr(skb, ifmca,
25641 NETLINK_CB(cb->skb).pid,
25642 cb->nlh->nlmsg_seq,
25643 @@ -3599,6 +3615,8 @@ static int in6_dump_addrs(struct inet6_d
25644 ifaca = ifaca->aca_next, ip_idx++) {
25645 if (ip_idx < s_ip_idx)
25647 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25649 err = inet6_fill_ifacaddr(skb, ifaca,
25650 NETLINK_CB(cb->skb).pid,
25651 cb->nlh->nlmsg_seq,
25652 @@ -3984,6 +4002,11 @@ static int inet6_dump_ifinfo(struct sk_b
25653 struct inet6_dev *idev;
25654 struct hlist_head *head;
25655 struct hlist_node *node;
25656 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25658 + /* FIXME: maybe disable ipv6 on non v6 guests?
25659 + if (skb->sk && skb->sk->sk_vx_info)
25660 + return skb->len; */
25663 s_idx = cb->args[1];
25664 @@ -3995,6 +4018,8 @@ static int inet6_dump_ifinfo(struct sk_b
25665 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25668 + if (!v6_dev_in_nx_info(dev, nxi))
25670 idev = __in6_dev_get(dev);
25673 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
25674 --- linux-3.0.25/net/ipv6/af_inet6.c 2012-03-19 21:16:57.000000000 +0100
25675 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/af_inet6.c 2011-08-29 03:45:10.000000000 +0200
25677 #include <linux/netdevice.h>
25678 #include <linux/icmpv6.h>
25679 #include <linux/netfilter_ipv6.h>
25680 +#include <linux/vs_inet.h>
25681 +#include <linux/vs_inet6.h>
25683 #include <net/ip.h>
25684 #include <net/ipv6.h>
25685 @@ -160,9 +162,12 @@ lookup_protocol:
25689 + if ((protocol == IPPROTO_ICMPV6) &&
25690 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25692 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25693 goto out_rcu_unlock;
25696 sock->ops = answer->ops;
25697 answer_prot = answer->prot;
25698 answer_no_check = answer->no_check;
25699 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25700 struct inet_sock *inet = inet_sk(sk);
25701 struct ipv6_pinfo *np = inet6_sk(sk);
25702 struct net *net = sock_net(sk);
25703 + struct nx_v6_sock_addr nsa;
25705 unsigned short snum;
25707 @@ -276,6 +282,10 @@ int inet6_bind(struct socket *sock, stru
25708 if (addr->sin6_family != AF_INET6)
25709 return -EAFNOSUPPORT;
25711 + err = v6_map_sock_addr(inet, addr, &nsa);
25715 addr_type = ipv6_addr_type(&addr->sin6_addr);
25716 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25718 @@ -307,6 +317,7 @@ int inet6_bind(struct socket *sock, stru
25719 /* Reproduce AF_INET checks to make the bindings consistent */
25720 v4addr = addr->sin6_addr.s6_addr32[3];
25721 chk_addr_ret = inet_addr_type(net, v4addr);
25723 if (!sysctl_ip_nonlocal_bind &&
25724 !(inet->freebind || inet->transparent) &&
25725 v4addr != htonl(INADDR_ANY) &&
25726 @@ -316,6 +327,10 @@ int inet6_bind(struct socket *sock, stru
25727 err = -EADDRNOTAVAIL;
25730 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25731 + err = -EADDRNOTAVAIL;
25735 if (addr_type != IPV6_ADDR_ANY) {
25736 struct net_device *dev = NULL;
25737 @@ -342,6 +357,11 @@ int inet6_bind(struct socket *sock, stru
25741 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25742 + err = -EADDRNOTAVAIL;
25746 /* ipv4 addr of the socket is invalid. Only the
25747 * unspecified and mapped address have a v4 equivalent.
25749 @@ -358,6 +378,9 @@ int inet6_bind(struct socket *sock, stru
25753 + /* what's that for? */
25754 + v6_set_sock_addr(inet, &nsa);
25756 inet->inet_rcv_saddr = v4addr;
25757 inet->inet_saddr = v4addr;
25759 @@ -459,9 +482,11 @@ int inet6_getname(struct socket *sock, s
25761 sin->sin6_port = inet->inet_dport;
25762 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25763 + /* FIXME: remap lback? */
25765 sin->sin6_flowinfo = np->flow_label;
25767 + /* FIXME: remap lback? */
25768 if (ipv6_addr_any(&np->rcv_saddr))
25769 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25771 diff -NurpP --minimal linux-3.0.25/net/ipv6/datagram.c linux-3.0.25-vs2.3.2.3/net/ipv6/datagram.c
25772 --- linux-3.0.25/net/ipv6/datagram.c 2011-05-22 16:18:00.000000000 +0200
25773 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/datagram.c 2011-09-17 19:24:15.000000000 +0200
25774 @@ -639,7 +639,7 @@ int datagram_send_ctl(struct net *net,
25777 if (fl6->flowi6_oif) {
25778 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25779 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25783 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
25784 --- linux-3.0.25/net/ipv6/fib6_rules.c 2011-05-22 16:18:00.000000000 +0200
25785 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/fib6_rules.c 2011-06-10 22:11:24.000000000 +0200
25786 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
25787 ip6_dst_idev(&rt->dst)->dev,
25789 rt6_flags2srcprefs(flags),
25793 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25795 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
25796 --- linux-3.0.25/net/ipv6/inet6_hashtables.c 2012-03-19 21:16:57.000000000 +0100
25797 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/inet6_hashtables.c 2011-08-29 03:45:10.000000000 +0200
25800 #include <linux/module.h>
25801 #include <linux/random.h>
25802 +#include <linux/vs_inet6.h>
25804 #include <net/inet_connection_sock.h>
25805 #include <net/inet_hashtables.h>
25806 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25807 unsigned int slot = hash & hashinfo->ehash_mask;
25808 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25813 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25814 @@ -95,7 +95,7 @@ begin:
25822 if (get_nulls_value(node) != slot)
25823 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
25824 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25828 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25831 if (sk->sk_bound_dev_if) {
25832 if (sk->sk_bound_dev_if != dif)
25833 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
25834 --- linux-3.0.25/net/ipv6/ip6_output.c 2012-03-19 21:16:57.000000000 +0100
25835 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/ip6_output.c 2012-02-15 05:20:43.000000000 +0100
25836 @@ -979,7 +979,8 @@ static int ip6_dst_lookup_tail(struct so
25837 struct rt6_info *rt = (struct rt6_info *) *dst;
25838 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25839 sk ? inet6_sk(sk)->srcprefs : 0,
25842 + sk ? sk->sk_nx_info : NULL);
25844 goto out_err_release;
25846 diff -NurpP --minimal linux-3.0.25/net/ipv6/ndisc.c linux-3.0.25-vs2.3.2.3/net/ipv6/ndisc.c
25847 --- linux-3.0.25/net/ipv6/ndisc.c 2012-03-19 21:16:57.000000000 +0100
25848 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/ndisc.c 2012-02-15 05:20:43.000000000 +0100
25849 @@ -597,7 +597,7 @@ static void ndisc_send_na(struct net_dev
25851 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25852 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25856 src_addr = &tmpaddr;
25858 diff -NurpP --minimal linux-3.0.25/net/ipv6/raw.c linux-3.0.25-vs2.3.2.3/net/ipv6/raw.c
25859 --- linux-3.0.25/net/ipv6/raw.c 2011-07-22 11:18:13.000000000 +0200
25860 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/raw.c 2011-06-10 22:11:24.000000000 +0200
25862 #include <linux/icmpv6.h>
25863 #include <linux/netfilter.h>
25864 #include <linux/netfilter_ipv6.h>
25865 +#include <linux/vs_inet6.h>
25866 #include <linux/skbuff.h>
25867 #include <linux/compat.h>
25868 #include <asm/uaccess.h>
25869 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
25873 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25874 + err = -EADDRNOTAVAIL;
25880 /* ipv4 addr of the socket is invalid. Only the
25881 * unspecified and mapped address have a v4 equivalent.
25883 diff -NurpP --minimal linux-3.0.25/net/ipv6/route.c linux-3.0.25-vs2.3.2.3/net/ipv6/route.c
25884 --- linux-3.0.25/net/ipv6/route.c 2012-03-19 21:16:57.000000000 +0100
25885 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/route.c 2012-02-15 05:20:43.000000000 +0100
25887 #include <net/xfrm.h>
25888 #include <net/netevent.h>
25889 #include <net/netlink.h>
25890 +#include <linux/vs_inet6.h>
25892 #include <asm/uaccess.h>
25894 @@ -2058,15 +2059,17 @@ int ip6_route_get_saddr(struct net *net,
25895 struct rt6_info *rt,
25896 const struct in6_addr *daddr,
25897 unsigned int prefs,
25898 - struct in6_addr *saddr)
25899 + struct in6_addr *saddr,
25900 + struct nx_info *nxi)
25902 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25904 - if (rt->rt6i_prefsrc.plen)
25905 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25906 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25907 ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr);
25909 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25910 - daddr, prefs, saddr);
25911 + daddr, prefs, saddr, nxi);
25915 @@ -2396,7 +2399,8 @@ static int rt6_fill_node(struct net *net
25916 NLA_PUT_U32(skb, RTA_IIF, iif);
25918 struct in6_addr saddr_buf;
25919 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0)
25920 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25921 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25922 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25925 @@ -2599,6 +2603,7 @@ static int rt6_info_route(struct rt6_inf
25926 struct seq_file *m = p_arg;
25927 struct neighbour *n;
25929 + /* FIXME: check for network context? */
25930 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25932 #ifdef CONFIG_IPV6_SUBTREES
25933 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
25934 --- linux-3.0.25/net/ipv6/tcp_ipv6.c 2012-03-19 21:16:57.000000000 +0100
25935 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/tcp_ipv6.c 2012-02-07 02:05:58.000000000 +0100
25938 #include <linux/crypto.h>
25939 #include <linux/scatterlist.h>
25940 +#include <linux/vs_inet6.h>
25942 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25943 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25944 @@ -162,8 +163,15 @@ static int tcp_v6_connect(struct sock *s
25945 * connect() to INADDR_ANY means loopback (BSD'ism).
25948 - if(ipv6_addr_any(&usin->sin6_addr))
25949 - usin->sin6_addr.s6_addr[15] = 0x1;
25950 + if(ipv6_addr_any(&usin->sin6_addr)) {
25951 + struct nx_info *nxi = sk->sk_nx_info;
25953 + if (nxi && nx_info_has_v6(nxi))
25954 + /* FIXME: remap lback? */
25955 + usin->sin6_addr = nxi->v6.ip;
25957 + usin->sin6_addr.s6_addr[15] = 0x1;
25960 addr_type = ipv6_addr_type(&usin->sin6_addr);
25962 diff -NurpP --minimal linux-3.0.25/net/ipv6/udp.c linux-3.0.25-vs2.3.2.3/net/ipv6/udp.c
25963 --- linux-3.0.25/net/ipv6/udp.c 2012-03-19 21:16:57.000000000 +0100
25964 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/udp.c 2011-10-18 13:51:13.000000000 +0200
25965 @@ -45,41 +45,67 @@
25966 #include <net/tcp_states.h>
25967 #include <net/ip6_checksum.h>
25968 #include <net/xfrm.h>
25969 +#include <linux/vs_inet6.h>
25971 #include <linux/proc_fs.h>
25972 #include <linux/seq_file.h>
25973 #include "udp_impl.h"
25975 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25976 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25978 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25979 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25980 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25981 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25982 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25983 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25984 - int sk_ipv6only = ipv6_only_sock(sk);
25985 + int sk1_ipv6only = ipv6_only_sock(sk1);
25986 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25987 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25988 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25989 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25991 /* if both are mapped, treat as IPv4 */
25992 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25993 - return (!sk2_ipv6only &&
25994 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25995 + if (!sk2_ipv6only &&
25996 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25997 - sk1_rcv_saddr == sk2_rcv_saddr));
25998 + sk1_rcv_saddr == sk2_rcv_saddr))
26004 if (addr_type2 == IPV6_ADDR_ANY &&
26005 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
26009 if (addr_type == IPV6_ADDR_ANY &&
26010 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26012 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
26015 if (sk2_rcv_saddr6 &&
26016 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
26018 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
26024 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
26025 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26026 + if (!sk2_rcv_saddr)
26027 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
26028 + if (!sk1_rcv_saddr)
26029 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
26032 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
26033 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26034 + else if (addr_type2 == IPV6_ADDR_ANY)
26035 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
26036 + else if (addr_type == IPV6_ADDR_ANY) {
26037 + if (addr_type2 == IPV6_ADDR_MAPPED)
26038 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
26040 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
26045 static unsigned int udp6_portaddr_hash(struct net *net,
26046 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
26047 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
26051 + /* block non nx_info ips */
26052 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26055 if (!ipv6_addr_any(&np->daddr)) {
26056 if (!ipv6_addr_equal(&np->daddr, saddr))
26057 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
26058 --- linux-3.0.25/net/ipv6/xfrm6_policy.c 2011-07-22 11:18:13.000000000 +0200
26059 +++ linux-3.0.25-vs2.3.2.3/net/ipv6/xfrm6_policy.c 2011-06-10 22:11:24.000000000 +0200
26060 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
26061 dev = ip6_dst_idev(dst)->dev;
26062 ipv6_dev_get_saddr(dev_net(dev), dev,
26063 (struct in6_addr *)&daddr->a6, 0,
26064 - (struct in6_addr *)&saddr->a6);
26065 + (struct in6_addr *)&saddr->a6, NULL);
26069 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
26070 --- linux-3.0.25/net/netfilter/ipvs/ip_vs_xmit.c 2011-07-22 11:18:13.000000000 +0200
26071 +++ linux-3.0.25-vs2.3.2.3/net/netfilter/ipvs/ip_vs_xmit.c 2011-07-22 15:27:52.000000000 +0200
26072 @@ -226,7 +226,7 @@ __ip_vs_route_output_v6(struct net *net,
26074 if (ipv6_addr_any(&fl6.saddr) &&
26075 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
26076 - &fl6.daddr, 0, &fl6.saddr) < 0)
26077 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
26080 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
26081 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
26082 --- linux-3.0.25/net/netlink/af_netlink.c 2011-07-22 11:18:13.000000000 +0200
26083 +++ linux-3.0.25-vs2.3.2.3/net/netlink/af_netlink.c 2011-06-10 22:11:24.000000000 +0200
26085 #include <linux/types.h>
26086 #include <linux/audit.h>
26087 #include <linux/mutex.h>
26088 +#include <linux/vs_context.h>
26089 +#include <linux/vs_network.h>
26090 +#include <linux/vs_limit.h>
26092 #include <net/net_namespace.h>
26093 #include <net/sock.h>
26094 @@ -1907,6 +1910,8 @@ static struct sock *netlink_seq_socket_i
26095 sk_for_each(s, node, &hash->table[j]) {
26096 if (sock_net(s) != seq_file_net(seq))
26098 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26102 iter->hash_idx = j;
26103 @@ -1941,7 +1946,8 @@ static void *netlink_seq_next(struct seq
26107 - } while (s && sock_net(s) != seq_file_net(seq));
26108 + } while (s && (sock_net(s) != seq_file_net(seq) ||
26109 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
26113 @@ -1953,7 +1959,8 @@ static void *netlink_seq_next(struct seq
26115 for (; j <= hash->mask; j++) {
26116 s = sk_head(&hash->table[j]);
26117 - while (s && sock_net(s) != seq_file_net(seq))
26118 + while (s && (sock_net(s) != seq_file_net(seq) ||
26119 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
26123 diff -NurpP --minimal linux-3.0.25/net/socket.c linux-3.0.25-vs2.3.2.3/net/socket.c
26124 --- linux-3.0.25/net/socket.c 2012-03-19 21:16:58.000000000 +0100
26125 +++ linux-3.0.25-vs2.3.2.3/net/socket.c 2011-10-18 13:51:13.000000000 +0200
26128 #include <net/sock.h>
26129 #include <linux/netfilter.h>
26130 +#include <linux/vs_base.h>
26131 +#include <linux/vs_socket.h>
26132 +#include <linux/vs_inet.h>
26133 +#include <linux/vs_inet6.h>
26135 #include <linux/if_tun.h>
26136 #include <linux/ipv6_route.h>
26137 @@ -546,6 +550,7 @@ static inline int __sock_sendmsg_nosec(s
26138 struct msghdr *msg, size_t size)
26140 struct sock_iocb *si = kiocb_to_siocb(iocb);
26143 sock_update_classid(sock->sk);
26145 @@ -554,7 +559,22 @@ static inline int __sock_sendmsg_nosec(s
26149 - return sock->ops->sendmsg(iocb, sock, msg, size);
26150 + len = sock->ops->sendmsg(iocb, sock, msg, size);
26153 + vx_sock_send(sock->sk, size);
26155 + vx_sock_fail(sock->sk, size);
26157 + vxdprintk(VXD_CBIT(net, 7),
26158 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
26160 + (sock->sk)?sock->sk->sk_nx_info:0,
26161 + (sock->sk)?sock->sk->sk_vx_info:0,
26162 + (sock->sk)?sock->sk->sk_xid:0,
26163 + (sock->sk)?sock->sk->sk_nid:0,
26164 + (unsigned int)size, len);
26168 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
26169 @@ -694,6 +714,7 @@ static inline int __sock_recvmsg_nosec(s
26170 struct msghdr *msg, size_t size, int flags)
26172 struct sock_iocb *si = kiocb_to_siocb(iocb);
26175 sock_update_classid(sock->sk);
26177 @@ -703,7 +724,18 @@ static inline int __sock_recvmsg_nosec(s
26181 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
26182 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
26183 + if ((len >= 0) && sock->sk)
26184 + vx_sock_recv(sock->sk, len);
26185 + vxdprintk(VXD_CBIT(net, 7),
26186 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26188 + (sock->sk)?sock->sk->sk_nx_info:0,
26189 + (sock->sk)?sock->sk->sk_vx_info:0,
26190 + (sock->sk)?sock->sk->sk_xid:0,
26191 + (sock->sk)?sock->sk->sk_nid:0,
26192 + (unsigned int)size, len);
26196 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
26197 @@ -1188,6 +1220,13 @@ int __sock_create(struct net *net, int f
26198 if (type < 0 || type >= SOCK_MAX)
26201 + if (!nx_check(0, VS_ADMIN)) {
26202 + if (family == PF_INET && !current_nx_info_has_v4())
26203 + return -EAFNOSUPPORT;
26204 + if (family == PF_INET6 && !current_nx_info_has_v6())
26205 + return -EAFNOSUPPORT;
26210 This uglymoron is moved from INET layer to here to avoid
26211 @@ -1323,6 +1362,7 @@ SYSCALL_DEFINE3(socket, int, family, int
26215 + set_bit(SOCK_USER_SOCKET, &sock->flags);
26216 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
26219 @@ -1364,10 +1404,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
26220 err = sock_create(family, type, protocol, &sock1);
26223 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
26225 err = sock_create(family, type, protocol, &sock2);
26227 goto out_release_1;
26228 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
26230 err = sock1->ops->socketpair(sock1, sock2);
26232 diff -NurpP --minimal linux-3.0.25/net/sunrpc/auth.c linux-3.0.25-vs2.3.2.3/net/sunrpc/auth.c
26233 --- linux-3.0.25/net/sunrpc/auth.c 2011-07-22 11:18:13.000000000 +0200
26234 +++ linux-3.0.25-vs2.3.2.3/net/sunrpc/auth.c 2011-06-10 22:11:24.000000000 +0200
26236 #include <linux/hash.h>
26237 #include <linux/sunrpc/clnt.h>
26238 #include <linux/spinlock.h>
26239 +#include <linux/vs_tag.h>
26242 # define RPCDBG_FACILITY RPCDBG_AUTH
26243 @@ -427,6 +428,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
26244 memset(&acred, 0, sizeof(acred));
26245 acred.uid = cred->fsuid;
26246 acred.gid = cred->fsgid;
26247 + acred.tag = dx_current_tag();
26248 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
26250 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
26251 @@ -467,6 +469,7 @@ rpcauth_bind_root_cred(struct rpc_task *
26252 struct auth_cred acred = {
26255 + .tag = dx_current_tag(),
26258 dprintk("RPC: %5u looking up %s cred\n",
26259 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
26260 --- linux-3.0.25/net/sunrpc/auth_unix.c 2012-03-19 21:16:58.000000000 +0100
26261 +++ linux-3.0.25-vs2.3.2.3/net/sunrpc/auth_unix.c 2011-11-15 17:37:07.000000000 +0100
26262 @@ -12,12 +12,14 @@
26263 #include <linux/module.h>
26264 #include <linux/sunrpc/clnt.h>
26265 #include <linux/sunrpc/auth.h>
26266 +#include <linux/vs_tag.h>
26268 #define NFS_NGROUPS 16
26271 struct rpc_cred uc_base;
26274 gid_t uc_gids[NFS_NGROUPS];
26276 #define uc_uid uc_base.cr_uid
26277 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
26278 groups = NFS_NGROUPS;
26280 cred->uc_gid = acred->gid;
26281 + cred->uc_tag = acred->tag;
26282 for (i = 0; i < groups; i++)
26283 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
26284 if (i < NFS_NGROUPS)
26285 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
26289 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
26290 + if (cred->uc_uid != acred->uid ||
26291 + cred->uc_gid != acred->gid ||
26292 + cred->uc_tag != acred->tag)
26295 if (acred->group_info != NULL)
26296 @@ -145,7 +150,7 @@ unx_marshal(struct rpc_task *task, __be3
26297 struct rpc_clnt *clnt = task->tk_client;
26298 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
26299 __be32 *base, *hold;
26303 *p++ = htonl(RPC_AUTH_UNIX);
26305 @@ -155,9 +160,12 @@ unx_marshal(struct rpc_task *task, __be3
26306 * Copy the UTS nodename captured when the client was created.
26308 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
26309 + tag = task->tk_client->cl_tag;
26311 - *p++ = htonl((u32) cred->uc_uid);
26312 - *p++ = htonl((u32) cred->uc_gid);
26313 + *p++ = htonl((u32) TAGINO_UID(tag,
26314 + cred->uc_uid, cred->uc_tag));
26315 + *p++ = htonl((u32) TAGINO_GID(tag,
26316 + cred->uc_gid, cred->uc_tag));
26318 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
26319 *p++ = htonl((u32) cred->uc_gids[i]);
26320 diff -NurpP --minimal linux-3.0.25/net/sunrpc/clnt.c linux-3.0.25-vs2.3.2.3/net/sunrpc/clnt.c
26321 --- linux-3.0.25/net/sunrpc/clnt.c 2011-07-22 11:18:13.000000000 +0200
26322 +++ linux-3.0.25-vs2.3.2.3/net/sunrpc/clnt.c 2011-07-01 11:35:35.000000000 +0200
26324 #include <linux/in.h>
26325 #include <linux/in6.h>
26326 #include <linux/un.h>
26327 +#include <linux/vs_cvirt.h>
26329 #include <linux/sunrpc/clnt.h>
26330 #include <linux/sunrpc/rpc_pipe_fs.h>
26331 @@ -362,6 +363,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
26332 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
26333 clnt->cl_chatty = 1;
26335 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
26336 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
26337 + clnt->cl_tag = 1; */
26340 EXPORT_SYMBOL_GPL(rpc_create);
26341 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
26342 --- linux-3.0.25/net/unix/af_unix.c 2011-07-22 11:18:13.000000000 +0200
26343 +++ linux-3.0.25-vs2.3.2.3/net/unix/af_unix.c 2011-06-10 22:11:24.000000000 +0200
26344 @@ -114,6 +114,8 @@
26345 #include <linux/mount.h>
26346 #include <net/checksum.h>
26347 #include <linux/security.h>
26348 +#include <linux/vs_context.h>
26349 +#include <linux/vs_limit.h>
26351 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
26352 static DEFINE_SPINLOCK(unix_table_lock);
26353 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
26354 if (!net_eq(sock_net(s), net))
26357 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26359 if (u->addr->len == len &&
26360 !memcmp(u->addr->name, sunname, len))
26362 @@ -2208,6 +2212,8 @@ static struct sock *unix_seq_idx(struct
26363 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
26364 if (sock_net(s) != seq_file_net(seq))
26366 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26371 @@ -2232,7 +2238,8 @@ static void *unix_seq_next(struct seq_fi
26372 sk = first_unix_socket(&iter->i);
26374 sk = next_unix_socket(&iter->i, sk);
26375 - while (sk && (sock_net(sk) != seq_file_net(seq)))
26376 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
26377 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
26378 sk = next_unix_socket(&iter->i, sk);
26381 diff -NurpP --minimal linux-3.0.25/scripts/checksyscalls.sh linux-3.0.25-vs2.3.2.3/scripts/checksyscalls.sh
26382 --- linux-3.0.25/scripts/checksyscalls.sh 2011-03-15 18:07:46.000000000 +0100
26383 +++ linux-3.0.25-vs2.3.2.3/scripts/checksyscalls.sh 2011-06-10 22:11:24.000000000 +0200
26384 @@ -193,7 +193,6 @@ cat << EOF
26385 #define __IGNORE_afs_syscall
26386 #define __IGNORE_getpmsg
26387 #define __IGNORE_putpmsg
26388 -#define __IGNORE_vserver
26392 diff -NurpP --minimal linux-3.0.25/security/commoncap.c linux-3.0.25-vs2.3.2.3/security/commoncap.c
26393 --- linux-3.0.25/security/commoncap.c 2011-07-22 11:18:14.000000000 +0200
26394 +++ linux-3.0.25-vs2.3.2.3/security/commoncap.c 2011-08-30 15:42:43.000000000 +0200
26395 @@ -62,6 +62,7 @@ int cap_netlink_recv(struct sk_buff *skb
26400 EXPORT_SYMBOL(cap_netlink_recv);
26403 @@ -83,14 +84,20 @@ EXPORT_SYMBOL(cap_netlink_recv);
26404 int cap_capable(struct task_struct *tsk, const struct cred *cred,
26405 struct user_namespace *targ_ns, int cap, int audit)
26407 + struct vx_info *vxi = tsk->vx_info;
26410 /* The creator of the user namespace has all caps. */
26411 if (targ_ns != &init_user_ns && targ_ns->creator == cred->user)
26414 /* Do we have the necessary capabilities? */
26415 - if (targ_ns == cred->user->user_ns)
26416 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26417 + if (targ_ns == cred->user->user_ns) {
26418 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26419 + cap_raised(cred->cap_effective, cap))
26421 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26424 /* Have we tried all of the parent namespaces? */
26425 if (targ_ns == &init_user_ns)
26426 @@ -611,7 +618,7 @@ int cap_inode_setxattr(struct dentry *de
26428 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26429 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26430 - !capable(CAP_SYS_ADMIN))
26431 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26435 @@ -637,7 +644,7 @@ int cap_inode_removexattr(struct dentry
26437 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26438 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26439 - !capable(CAP_SYS_ADMIN))
26440 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26444 diff -NurpP --minimal linux-3.0.25/security/selinux/hooks.c linux-3.0.25-vs2.3.2.3/security/selinux/hooks.c
26445 --- linux-3.0.25/security/selinux/hooks.c 2011-07-22 11:18:14.000000000 +0200
26446 +++ linux-3.0.25-vs2.3.2.3/security/selinux/hooks.c 2011-06-15 02:40:14.000000000 +0200
26448 #include <linux/dccp.h>
26449 #include <linux/quota.h>
26450 #include <linux/un.h> /* for Unix socket types */
26451 -#include <net/af_unix.h> /* for Unix socket types */
26452 #include <linux/parser.h>
26453 #include <linux/nfs_mount.h>
26454 #include <net/ipv6.h>