1 diff -NurpP --minimal linux-3.2.5/Documentation/vserver/debug.txt linux-3.2.5-vs2.3.2.6/Documentation/vserver/debug.txt
2 --- linux-3.2.5/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.2.5-vs2.3.2.6/Documentation/vserver/debug.txt 2011-12-05 19:33:02.000000000 +0100
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.2.5/arch/alpha/Kconfig linux-3.2.5-vs2.3.2.6/arch/alpha/Kconfig
160 --- linux-3.2.5/arch/alpha/Kconfig 2012-01-09 16:13:54.000000000 +0100
161 +++ linux-3.2.5-vs2.3.2.6/arch/alpha/Kconfig 2011-12-05 19:33:02.000000000 +0100
162 @@ -665,6 +665,8 @@ config DUMMY_CONSOLE
166 +source "kernel/vserver/Kconfig"
168 source "security/Kconfig"
170 source "crypto/Kconfig"
171 diff -NurpP --minimal linux-3.2.5/arch/alpha/kernel/entry.S linux-3.2.5-vs2.3.2.6/arch/alpha/kernel/entry.S
172 --- linux-3.2.5/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
173 +++ linux-3.2.5-vs2.3.2.6/arch/alpha/kernel/entry.S 2011-12-05 19:33:02.000000000 +0100
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.2.5/arch/alpha/kernel/ptrace.c linux-3.2.5-vs2.3.2.6/arch/alpha/kernel/ptrace.c
207 --- linux-3.2.5/arch/alpha/kernel/ptrace.c 2011-01-05 21:48:40.000000000 +0100
208 +++ linux-3.2.5-vs2.3.2.6/arch/alpha/kernel/ptrace.c 2011-12-05 19:33:02.000000000 +0100
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.2.5/arch/alpha/kernel/systbls.S linux-3.2.5-vs2.3.2.6/arch/alpha/kernel/systbls.S
218 --- linux-3.2.5/arch/alpha/kernel/systbls.S 2012-01-09 16:13:54.000000000 +0100
219 +++ linux-3.2.5-vs2.3.2.6/arch/alpha/kernel/systbls.S 2011-12-05 19:33:02.000000000 +0100
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.2.5/arch/alpha/kernel/traps.c linux-3.2.5-vs2.3.2.6/arch/alpha/kernel/traps.c
230 --- linux-3.2.5/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
231 +++ linux-3.2.5-vs2.3.2.6/arch/alpha/kernel/traps.c 2011-12-05 19:33:02.000000000 +0100
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.2.5/arch/arm/Kconfig linux-3.2.5-vs2.3.2.6/arch/arm/Kconfig
243 --- linux-3.2.5/arch/arm/Kconfig 2012-01-09 16:13:54.000000000 +0100
244 +++ linux-3.2.5-vs2.3.2.6/arch/arm/Kconfig 2012-01-09 16:19:31.000000000 +0100
245 @@ -2242,6 +2242,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.2.5/arch/arm/kernel/calls.S linux-3.2.5-vs2.3.2.6/arch/arm/kernel/calls.S
255 --- linux-3.2.5/arch/arm/kernel/calls.S 2012-01-09 16:13:54.000000000 +0100
256 +++ linux-3.2.5-vs2.3.2.6/arch/arm/kernel/calls.S 2011-12-05 19:33:02.000000000 +0100
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.2.5/arch/arm/kernel/process.c linux-3.2.5-vs2.3.2.6/arch/arm/kernel/process.c
267 --- linux-3.2.5/arch/arm/kernel/process.c 2012-01-09 16:13:54.000000000 +0100
268 +++ linux-3.2.5-vs2.3.2.6/arch/arm/kernel/process.c 2011-12-05 19:33:02.000000000 +0100
269 @@ -320,7 +320,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.2.5/arch/arm/kernel/traps.c linux-3.2.5-vs2.3.2.6/arch/arm/kernel/traps.c
280 --- linux-3.2.5/arch/arm/kernel/traps.c 2012-01-09 16:13:54.000000000 +0100
281 +++ linux-3.2.5-vs2.3.2.6/arch/arm/kernel/traps.c 2011-12-05 19:33:02.000000000 +0100
282 @@ -244,8 +244,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.2.5/arch/cris/Kconfig linux-3.2.5-vs2.3.2.6/arch/cris/Kconfig
294 --- linux-3.2.5/arch/cris/Kconfig 2012-01-09 16:14:01.000000000 +0100
295 +++ linux-3.2.5-vs2.3.2.6/arch/cris/Kconfig 2011-12-05 19:33:02.000000000 +0100
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.2.5/arch/frv/kernel/kernel_thread.S linux-3.2.5-vs2.3.2.6/arch/frv/kernel/kernel_thread.S
306 --- linux-3.2.5/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
307 +++ linux-3.2.5-vs2.3.2.6/arch/frv/kernel/kernel_thread.S 2011-12-05 19:33:02.000000000 +0100
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.2.5/arch/h8300/Kconfig linux-3.2.5-vs2.3.2.6/arch/h8300/Kconfig
318 --- linux-3.2.5/arch/h8300/Kconfig 2012-01-09 16:14:01.000000000 +0100
319 +++ linux-3.2.5-vs2.3.2.6/arch/h8300/Kconfig 2011-12-05 19:33:02.000000000 +0100
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.2.5/arch/ia64/Kconfig linux-3.2.5-vs2.3.2.6/arch/ia64/Kconfig
330 --- linux-3.2.5/arch/ia64/Kconfig 2012-01-09 16:14:01.000000000 +0100
331 +++ linux-3.2.5-vs2.3.2.6/arch/ia64/Kconfig 2011-12-05 19:33:02.000000000 +0100
332 @@ -657,6 +657,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.2.5/arch/ia64/kernel/entry.S linux-3.2.5-vs2.3.2.6/arch/ia64/kernel/entry.S
342 --- linux-3.2.5/arch/ia64/kernel/entry.S 2012-01-09 16:14:02.000000000 +0100
343 +++ linux-3.2.5-vs2.3.2.6/arch/ia64/kernel/entry.S 2011-12-05 19:33:02.000000000 +0100
344 @@ -1714,7 +1714,7 @@ sys_call_table:
346 data8 sys_mq_getsetattr
348 - data8 sys_ni_syscall // reserved for vserver
350 data8 sys_waitid // 1270
352 data8 sys_request_key
353 diff -NurpP --minimal linux-3.2.5/arch/ia64/kernel/process.c linux-3.2.5-vs2.3.2.6/arch/ia64/kernel/process.c
354 --- linux-3.2.5/arch/ia64/kernel/process.c 2011-03-15 18:06:39.000000000 +0100
355 +++ linux-3.2.5-vs2.3.2.6/arch/ia64/kernel/process.c 2011-12-05 19:33:02.000000000 +0100
356 @@ -109,8 +109,8 @@ show_regs (struct pt_regs *regs)
357 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
360 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
361 - smp_processor_id(), current->comm);
362 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
363 + current->xid, smp_processor_id(), current->comm);
364 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
365 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
366 init_utsname()->release);
367 diff -NurpP --minimal linux-3.2.5/arch/ia64/kernel/ptrace.c linux-3.2.5-vs2.3.2.6/arch/ia64/kernel/ptrace.c
368 --- linux-3.2.5/arch/ia64/kernel/ptrace.c 2011-01-05 21:48:59.000000000 +0100
369 +++ linux-3.2.5-vs2.3.2.6/arch/ia64/kernel/ptrace.c 2011-12-05 19:33:02.000000000 +0100
371 #include <linux/regset.h>
372 #include <linux/elf.h>
373 #include <linux/tracehook.h>
374 +#include <linux/vs_base.h>
376 #include <asm/pgtable.h>
377 #include <asm/processor.h>
378 diff -NurpP --minimal linux-3.2.5/arch/ia64/kernel/traps.c linux-3.2.5-vs2.3.2.6/arch/ia64/kernel/traps.c
379 --- linux-3.2.5/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
380 +++ linux-3.2.5-vs2.3.2.6/arch/ia64/kernel/traps.c 2011-12-05 19:33:02.000000000 +0100
381 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
384 if (++die.lock_owner_depth < 3) {
385 - printk("%s[%d]: %s %ld [%d]\n",
386 - current->comm, task_pid_nr(current), str, err, ++die_counter);
387 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
388 + current->comm, task_pid_nr(current), current->xid,
389 + str, err, ++die_counter);
390 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
393 @@ -323,8 +324,9 @@ handle_fpu_swa (int fp_fault, struct pt_
394 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
395 last.time = current_jiffies + 5 * HZ;
397 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
398 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
399 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
400 + current->comm, task_pid_nr(current), current->xid,
401 + regs->cr_iip + ia64_psr(regs)->ri, isr);
405 diff -NurpP --minimal linux-3.2.5/arch/m32r/kernel/traps.c linux-3.2.5-vs2.3.2.6/arch/m32r/kernel/traps.c
406 --- linux-3.2.5/arch/m32r/kernel/traps.c 2011-10-24 18:44:58.000000000 +0200
407 +++ linux-3.2.5-vs2.3.2.6/arch/m32r/kernel/traps.c 2011-12-05 19:33:02.000000000 +0100
408 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
410 printk("SPI: %08lx\n", sp);
412 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
413 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
414 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
415 + current->comm, task_pid_nr(current), current->xid,
416 + 0xffff & i, 4096+(unsigned long)current);
419 * When in-kernel, we also print out the stack and code at the
420 diff -NurpP --minimal linux-3.2.5/arch/m68k/Kconfig linux-3.2.5-vs2.3.2.6/arch/m68k/Kconfig
421 --- linux-3.2.5/arch/m68k/Kconfig 2012-01-09 16:14:03.000000000 +0100
422 +++ linux-3.2.5-vs2.3.2.6/arch/m68k/Kconfig 2011-12-05 19:33:02.000000000 +0100
423 @@ -135,6 +135,8 @@ source "fs/Kconfig"
425 source "arch/m68k/Kconfig.debug"
427 +source "kernel/vserver/Kconfig"
429 source "security/Kconfig"
431 source "crypto/Kconfig"
432 diff -NurpP --minimal linux-3.2.5/arch/mips/Kconfig linux-3.2.5-vs2.3.2.6/arch/mips/Kconfig
433 --- linux-3.2.5/arch/mips/Kconfig 2012-01-09 16:14:04.000000000 +0100
434 +++ linux-3.2.5-vs2.3.2.6/arch/mips/Kconfig 2011-12-05 19:33:02.000000000 +0100
435 @@ -2478,6 +2478,8 @@ source "fs/Kconfig"
437 source "arch/mips/Kconfig.debug"
439 +source "kernel/vserver/Kconfig"
441 source "security/Kconfig"
443 source "crypto/Kconfig"
444 diff -NurpP --minimal linux-3.2.5/arch/mips/kernel/ptrace.c linux-3.2.5-vs2.3.2.6/arch/mips/kernel/ptrace.c
445 --- linux-3.2.5/arch/mips/kernel/ptrace.c 2011-07-22 11:17:36.000000000 +0200
446 +++ linux-3.2.5-vs2.3.2.6/arch/mips/kernel/ptrace.c 2011-12-05 19:33:02.000000000 +0100
448 #include <linux/security.h>
449 #include <linux/audit.h>
450 #include <linux/seccomp.h>
451 +#include <linux/vs_base.h>
453 #include <asm/byteorder.h>
455 @@ -263,6 +264,9 @@ long arch_ptrace(struct task_struct *chi
456 void __user *datavp = (void __user *) data;
457 unsigned long __user *datalp = (void __user *) data;
459 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
463 /* when I and D space are separate, these will need to be fixed. */
464 case PTRACE_PEEKTEXT: /* read word at location addr. */
465 diff -NurpP --minimal linux-3.2.5/arch/mips/kernel/scall32-o32.S linux-3.2.5-vs2.3.2.6/arch/mips/kernel/scall32-o32.S
466 --- linux-3.2.5/arch/mips/kernel/scall32-o32.S 2012-01-09 16:14:05.000000000 +0100
467 +++ linux-3.2.5-vs2.3.2.6/arch/mips/kernel/scall32-o32.S 2011-12-05 19:33:02.000000000 +0100
468 @@ -523,7 +523,7 @@ einval: li v0, -ENOSYS
469 sys sys_mq_timedreceive 5
470 sys sys_mq_notify 2 /* 4275 */
471 sys sys_mq_getsetattr 3
472 - sys sys_ni_syscall 0 /* sys_vserver */
475 sys sys_ni_syscall 0 /* available, was setaltroot */
476 sys sys_add_key 5 /* 4280 */
477 diff -NurpP --minimal linux-3.2.5/arch/mips/kernel/scall64-64.S linux-3.2.5-vs2.3.2.6/arch/mips/kernel/scall64-64.S
478 --- linux-3.2.5/arch/mips/kernel/scall64-64.S 2012-01-09 16:14:05.000000000 +0100
479 +++ linux-3.2.5-vs2.3.2.6/arch/mips/kernel/scall64-64.S 2011-12-05 19:33:02.000000000 +0100
480 @@ -362,7 +362,7 @@ sys_call_table:
481 PTR sys_mq_timedreceive
483 PTR sys_mq_getsetattr /* 5235 */
484 - PTR sys_ni_syscall /* sys_vserver */
487 PTR sys_ni_syscall /* available, was setaltroot */
489 diff -NurpP --minimal linux-3.2.5/arch/mips/kernel/scall64-n32.S linux-3.2.5-vs2.3.2.6/arch/mips/kernel/scall64-n32.S
490 --- linux-3.2.5/arch/mips/kernel/scall64-n32.S 2012-01-09 16:14:05.000000000 +0100
491 +++ linux-3.2.5-vs2.3.2.6/arch/mips/kernel/scall64-n32.S 2011-12-05 19:33:02.000000000 +0100
492 @@ -361,7 +361,7 @@ EXPORT(sysn32_call_table)
493 PTR compat_sys_mq_timedreceive
494 PTR compat_sys_mq_notify
495 PTR compat_sys_mq_getsetattr
496 - PTR sys_ni_syscall /* 6240, sys_vserver */
497 + PTR sys32_vserver /* 6240 */
498 PTR compat_sys_waitid
499 PTR sys_ni_syscall /* available, was setaltroot */
501 diff -NurpP --minimal linux-3.2.5/arch/mips/kernel/scall64-o32.S linux-3.2.5-vs2.3.2.6/arch/mips/kernel/scall64-o32.S
502 --- linux-3.2.5/arch/mips/kernel/scall64-o32.S 2012-01-09 16:14:05.000000000 +0100
503 +++ linux-3.2.5-vs2.3.2.6/arch/mips/kernel/scall64-o32.S 2011-12-05 19:33:02.000000000 +0100
504 @@ -480,7 +480,7 @@ sys_call_table:
505 PTR compat_sys_mq_timedreceive
506 PTR compat_sys_mq_notify /* 4275 */
507 PTR compat_sys_mq_getsetattr
508 - PTR sys_ni_syscall /* sys_vserver */
511 PTR sys_ni_syscall /* available, was setaltroot */
512 PTR sys_add_key /* 4280 */
513 diff -NurpP --minimal linux-3.2.5/arch/mips/kernel/traps.c linux-3.2.5-vs2.3.2.6/arch/mips/kernel/traps.c
514 --- linux-3.2.5/arch/mips/kernel/traps.c 2012-01-09 16:14:05.000000000 +0100
515 +++ linux-3.2.5-vs2.3.2.6/arch/mips/kernel/traps.c 2011-12-05 19:33:02.000000000 +0100
516 @@ -343,9 +343,10 @@ void show_registers(struct pt_regs *regs
520 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
521 - current->comm, current->pid, current_thread_info(), current,
522 - field, current_thread_info()->tp_value);
523 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
524 + current->comm, task_pid_nr(current), current->xid,
525 + current_thread_info(), current,
526 + field, current_thread_info()->tp_value);
527 if (cpu_has_userlocal) {
530 diff -NurpP --minimal linux-3.2.5/arch/parisc/Kconfig linux-3.2.5-vs2.3.2.6/arch/parisc/Kconfig
531 --- linux-3.2.5/arch/parisc/Kconfig 2012-01-09 16:14:05.000000000 +0100
532 +++ linux-3.2.5-vs2.3.2.6/arch/parisc/Kconfig 2011-12-05 19:33:02.000000000 +0100
533 @@ -278,6 +278,8 @@ source "fs/Kconfig"
535 source "arch/parisc/Kconfig.debug"
537 +source "kernel/vserver/Kconfig"
539 source "security/Kconfig"
541 source "crypto/Kconfig"
542 diff -NurpP --minimal linux-3.2.5/arch/parisc/kernel/syscall_table.S linux-3.2.5-vs2.3.2.6/arch/parisc/kernel/syscall_table.S
543 --- linux-3.2.5/arch/parisc/kernel/syscall_table.S 2011-10-24 18:45:00.000000000 +0200
544 +++ linux-3.2.5-vs2.3.2.6/arch/parisc/kernel/syscall_table.S 2011-12-05 19:33:02.000000000 +0100
546 ENTRY_COMP(mbind) /* 260 */
547 ENTRY_COMP(get_mempolicy)
548 ENTRY_COMP(set_mempolicy)
549 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
550 + ENTRY_DIFF(vserver)
552 ENTRY_SAME(request_key) /* 265 */
554 diff -NurpP --minimal linux-3.2.5/arch/parisc/kernel/traps.c linux-3.2.5-vs2.3.2.6/arch/parisc/kernel/traps.c
555 --- linux-3.2.5/arch/parisc/kernel/traps.c 2011-10-24 18:45:00.000000000 +0200
556 +++ linux-3.2.5-vs2.3.2.6/arch/parisc/kernel/traps.c 2011-12-05 19:33:02.000000000 +0100
557 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
561 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
562 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
563 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
564 + current->comm, task_pid_nr(current), current->xid,
565 + str, err, regs->iaoq[0]);
566 #ifdef PRINT_USER_FAULTS
567 /* XXX for debugging only */
569 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
570 pdc_console_restart();
573 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
574 - current->comm, task_pid_nr(current), str, err);
575 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
576 + current->comm, task_pid_nr(current), current->xid, str, err);
578 /* Wot's wrong wif bein' racy? */
579 if (current->thread.flags & PARISC_KERNEL_DEATH) {
580 diff -NurpP --minimal linux-3.2.5/arch/parisc/mm/fault.c linux-3.2.5-vs2.3.2.6/arch/parisc/mm/fault.c
581 --- linux-3.2.5/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
582 +++ linux-3.2.5-vs2.3.2.6/arch/parisc/mm/fault.c 2011-12-05 19:33:02.000000000 +0100
583 @@ -237,8 +237,9 @@ bad_area:
585 #ifdef PRINT_USER_FAULTS
586 printk(KERN_DEBUG "\n");
587 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
588 - task_pid_nr(tsk), tsk->comm, code, address);
589 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
590 + "command='%s' type=%lu address=0x%08lx\n",
591 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
593 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
594 vma->vm_start, vma->vm_end);
595 diff -NurpP --minimal linux-3.2.5/arch/powerpc/Kconfig linux-3.2.5-vs2.3.2.6/arch/powerpc/Kconfig
596 --- linux-3.2.5/arch/powerpc/Kconfig 2012-01-09 16:14:05.000000000 +0100
597 +++ linux-3.2.5-vs2.3.2.6/arch/powerpc/Kconfig 2011-12-05 19:33:02.000000000 +0100
598 @@ -960,6 +960,8 @@ source "lib/Kconfig"
600 source "arch/powerpc/Kconfig.debug"
602 +source "kernel/vserver/Kconfig"
604 source "security/Kconfig"
607 diff -NurpP --minimal linux-3.2.5/arch/powerpc/include/asm/unistd.h linux-3.2.5-vs2.3.2.6/arch/powerpc/include/asm/unistd.h
608 --- linux-3.2.5/arch/powerpc/include/asm/unistd.h 2012-01-09 16:14:05.000000000 +0100
609 +++ linux-3.2.5-vs2.3.2.6/arch/powerpc/include/asm/unistd.h 2011-12-05 19:33:02.000000000 +0100
612 #define __NR_rtas 255
613 #define __NR_sys_debug_setcontext 256
614 -/* Number 257 is reserved for vserver */
615 +#define __NR_vserver 257
616 #define __NR_migrate_pages 258
617 #define __NR_mbind 259
618 #define __NR_get_mempolicy 260
619 diff -NurpP --minimal linux-3.2.5/arch/powerpc/kernel/process.c linux-3.2.5-vs2.3.2.6/arch/powerpc/kernel/process.c
620 --- linux-3.2.5/arch/powerpc/kernel/process.c 2012-01-09 16:14:05.000000000 +0100
621 +++ linux-3.2.5-vs2.3.2.6/arch/powerpc/kernel/process.c 2011-12-05 19:33:02.000000000 +0100
622 @@ -640,8 +640,9 @@ void show_regs(struct pt_regs * regs)
624 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
626 - printk("TASK = %p[%d] '%s' THREAD: %p",
627 - current, task_pid_nr(current), current->comm, task_thread_info(current));
628 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
629 + current, task_pid_nr(current), current->xid,
630 + current->comm, task_thread_info(current));
633 printk(" CPU: %d", raw_smp_processor_id());
634 diff -NurpP --minimal linux-3.2.5/arch/powerpc/kernel/traps.c linux-3.2.5-vs2.3.2.6/arch/powerpc/kernel/traps.c
635 --- linux-3.2.5/arch/powerpc/kernel/traps.c 2012-01-09 16:14:05.000000000 +0100
636 +++ linux-3.2.5-vs2.3.2.6/arch/powerpc/kernel/traps.c 2011-12-05 19:33:02.000000000 +0100
637 @@ -1082,8 +1082,9 @@ void nonrecoverable_exception(struct pt_
639 void trace_syscall(struct pt_regs *regs)
641 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
642 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
643 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
644 + current, task_pid_nr(current), current->xid,
645 + regs->nip, regs->link, regs->gpr[0],
646 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
649 diff -NurpP --minimal linux-3.2.5/arch/s390/Kconfig linux-3.2.5-vs2.3.2.6/arch/s390/Kconfig
650 --- linux-3.2.5/arch/s390/Kconfig 2012-01-09 16:14:06.000000000 +0100
651 +++ linux-3.2.5-vs2.3.2.6/arch/s390/Kconfig 2011-12-05 19:33:02.000000000 +0100
652 @@ -641,6 +641,8 @@ source "fs/Kconfig"
654 source "arch/s390/Kconfig.debug"
656 +source "kernel/vserver/Kconfig"
658 source "security/Kconfig"
660 source "crypto/Kconfig"
661 diff -NurpP --minimal linux-3.2.5/arch/s390/include/asm/tlb.h linux-3.2.5-vs2.3.2.6/arch/s390/include/asm/tlb.h
662 --- linux-3.2.5/arch/s390/include/asm/tlb.h 2011-07-22 11:17:41.000000000 +0200
663 +++ linux-3.2.5-vs2.3.2.6/arch/s390/include/asm/tlb.h 2011-12-15 01:52:28.000000000 +0100
665 #include <linux/mm.h>
666 #include <linux/pagemap.h>
667 #include <linux/swap.h>
669 #include <asm/processor.h>
670 #include <asm/pgalloc.h>
671 #include <asm/tlbflush.h>
672 diff -NurpP --minimal linux-3.2.5/arch/s390/include/asm/unistd.h linux-3.2.5-vs2.3.2.6/arch/s390/include/asm/unistd.h
673 --- linux-3.2.5/arch/s390/include/asm/unistd.h 2012-01-09 16:14:06.000000000 +0100
674 +++ linux-3.2.5-vs2.3.2.6/arch/s390/include/asm/unistd.h 2011-12-05 19:33:02.000000000 +0100
676 #define __NR_clock_gettime (__NR_timer_create+6)
677 #define __NR_clock_getres (__NR_timer_create+7)
678 #define __NR_clock_nanosleep (__NR_timer_create+8)
679 -/* Number 263 is reserved for vserver */
680 +#define __NR_vserver 263
681 #define __NR_statfs64 265
682 #define __NR_fstatfs64 266
683 #define __NR_remap_file_pages 267
684 diff -NurpP --minimal linux-3.2.5/arch/s390/kernel/ptrace.c linux-3.2.5-vs2.3.2.6/arch/s390/kernel/ptrace.c
685 --- linux-3.2.5/arch/s390/kernel/ptrace.c 2012-01-09 16:14:06.000000000 +0100
686 +++ linux-3.2.5-vs2.3.2.6/arch/s390/kernel/ptrace.c 2011-12-15 01:11:29.000000000 +0100
688 #include <linux/regset.h>
689 #include <linux/tracehook.h>
690 #include <linux/seccomp.h>
691 +#include <linux/vs_base.h>
692 #include <trace/syscall.h>
693 #include <asm/compat.h>
694 #include <asm/segment.h>
695 diff -NurpP --minimal linux-3.2.5/arch/s390/kernel/syscalls.S linux-3.2.5-vs2.3.2.6/arch/s390/kernel/syscalls.S
696 --- linux-3.2.5/arch/s390/kernel/syscalls.S 2012-01-09 16:14:06.000000000 +0100
697 +++ linux-3.2.5-vs2.3.2.6/arch/s390/kernel/syscalls.S 2011-12-05 19:33:02.000000000 +0100
698 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
699 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
700 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
701 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
702 -NI_SYSCALL /* reserved for vserver */
703 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
704 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
705 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
706 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
707 diff -NurpP --minimal linux-3.2.5/arch/sh/Kconfig linux-3.2.5-vs2.3.2.6/arch/sh/Kconfig
708 --- linux-3.2.5/arch/sh/Kconfig 2012-01-09 16:14:07.000000000 +0100
709 +++ linux-3.2.5-vs2.3.2.6/arch/sh/Kconfig 2011-12-05 19:33:02.000000000 +0100
710 @@ -901,6 +901,8 @@ source "fs/Kconfig"
712 source "arch/sh/Kconfig.debug"
714 +source "kernel/vserver/Kconfig"
716 source "security/Kconfig"
718 source "crypto/Kconfig"
719 diff -NurpP --minimal linux-3.2.5/arch/sh/kernel/irq.c linux-3.2.5-vs2.3.2.6/arch/sh/kernel/irq.c
720 --- linux-3.2.5/arch/sh/kernel/irq.c 2011-07-22 11:17:41.000000000 +0200
721 +++ linux-3.2.5-vs2.3.2.6/arch/sh/kernel/irq.c 2011-12-05 19:33:02.000000000 +0100
723 #include <linux/ftrace.h>
724 #include <linux/delay.h>
725 #include <linux/ratelimit.h>
726 +// #include <linux/vs_context.h>
727 #include <asm/processor.h>
728 #include <asm/machvec.h>
729 #include <asm/uaccess.h>
730 diff -NurpP --minimal linux-3.2.5/arch/sparc/Kconfig linux-3.2.5-vs2.3.2.6/arch/sparc/Kconfig
731 --- linux-3.2.5/arch/sparc/Kconfig 2012-01-09 16:14:07.000000000 +0100
732 +++ linux-3.2.5-vs2.3.2.6/arch/sparc/Kconfig 2011-12-05 19:33:02.000000000 +0100
733 @@ -595,6 +595,8 @@ source "fs/Kconfig"
735 source "arch/sparc/Kconfig.debug"
737 +source "kernel/vserver/Kconfig"
739 source "security/Kconfig"
741 source "crypto/Kconfig"
742 diff -NurpP --minimal linux-3.2.5/arch/sparc/include/asm/unistd.h linux-3.2.5-vs2.3.2.6/arch/sparc/include/asm/unistd.h
743 --- linux-3.2.5/arch/sparc/include/asm/unistd.h 2012-01-09 16:14:07.000000000 +0100
744 +++ linux-3.2.5-vs2.3.2.6/arch/sparc/include/asm/unistd.h 2011-12-05 19:33:02.000000000 +0100
746 #define __NR_timer_getoverrun 264
747 #define __NR_timer_delete 265
748 #define __NR_timer_create 266
749 -/* #define __NR_vserver 267 Reserved for VSERVER */
750 +#define __NR_vserver 267
751 #define __NR_io_setup 268
752 #define __NR_io_destroy 269
753 #define __NR_io_submit 270
754 diff -NurpP --minimal linux-3.2.5/arch/sparc/kernel/systbls_32.S linux-3.2.5-vs2.3.2.6/arch/sparc/kernel/systbls_32.S
755 --- linux-3.2.5/arch/sparc/kernel/systbls_32.S 2012-01-09 16:14:09.000000000 +0100
756 +++ linux-3.2.5-vs2.3.2.6/arch/sparc/kernel/systbls_32.S 2011-12-05 19:33:02.000000000 +0100
757 @@ -70,7 +70,7 @@ sys_call_table:
758 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_ni_syscall
759 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
760 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
761 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
762 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
763 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
764 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
765 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
766 diff -NurpP --minimal linux-3.2.5/arch/sparc/kernel/systbls_64.S linux-3.2.5-vs2.3.2.6/arch/sparc/kernel/systbls_64.S
767 --- linux-3.2.5/arch/sparc/kernel/systbls_64.S 2012-01-09 16:14:09.000000000 +0100
768 +++ linux-3.2.5-vs2.3.2.6/arch/sparc/kernel/systbls_64.S 2011-12-05 19:33:02.000000000 +0100
769 @@ -71,7 +71,7 @@ sys_call_table32:
770 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys_nis_syscall
771 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
772 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
773 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
774 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
775 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
776 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
777 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
778 @@ -148,7 +148,7 @@ sys_call_table:
779 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nis_syscall
780 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
781 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
782 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
783 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
784 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
785 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
786 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
787 diff -NurpP --minimal linux-3.2.5/arch/um/Kconfig.rest linux-3.2.5-vs2.3.2.6/arch/um/Kconfig.rest
788 --- linux-3.2.5/arch/um/Kconfig.rest 2012-01-09 16:14:09.000000000 +0100
789 +++ linux-3.2.5-vs2.3.2.6/arch/um/Kconfig.rest 2011-12-05 19:33:02.000000000 +0100
790 @@ -12,6 +12,8 @@ source "arch/um/Kconfig.net"
794 +source "kernel/vserver/Kconfig"
796 source "security/Kconfig"
798 source "crypto/Kconfig"
799 diff -NurpP --minimal linux-3.2.5/arch/um/include/shared/kern_constants.h linux-3.2.5-vs2.3.2.6/arch/um/include/shared/kern_constants.h
800 --- linux-3.2.5/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
801 +++ linux-3.2.5-vs2.3.2.6/arch/um/include/shared/kern_constants.h 2011-12-05 19:33:02.000000000 +0100
803 +#include "../../../../include/generated/asm-offsets.h"
804 diff -NurpP --minimal linux-3.2.5/arch/um/include/shared/user_constants.h linux-3.2.5-vs2.3.2.6/arch/um/include/shared/user_constants.h
805 --- linux-3.2.5/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
806 +++ linux-3.2.5-vs2.3.2.6/arch/um/include/shared/user_constants.h 2011-12-05 19:33:02.000000000 +0100
811 + * This file was generated by arch/um/Makefile
815 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2) # */
816 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err) # */
817 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno) # */
818 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long) # */
819 +#define HOST_RBX 5 /* RBX # */
820 +#define HOST_RCX 11 /* RCX # */
821 +#define HOST_RDI 14 /* RDI # */
822 +#define HOST_RSI 13 /* RSI # */
823 +#define HOST_RDX 12 /* RDX # */
824 +#define HOST_RBP 4 /* RBP # */
825 +#define HOST_RAX 10 /* RAX # */
826 +#define HOST_R8 9 /* R8 # */
827 +#define HOST_R9 8 /* R9 # */
828 +#define HOST_R10 7 /* R10 # */
829 +#define HOST_R11 6 /* R11 # */
830 +#define HOST_R12 3 /* R12 # */
831 +#define HOST_R13 2 /* R13 # */
832 +#define HOST_R14 1 /* R14 # */
833 +#define HOST_R15 0 /* R15 # */
834 +#define HOST_ORIG_RAX 15 /* ORIG_RAX # */
835 +#define HOST_CS 17 /* CS # */
836 +#define HOST_SS 20 /* SS # */
837 +#define HOST_EFLAGS 18 /* EFLAGS # */
838 +#define HOST_IP 16 /* RIP # */
839 +#define HOST_SP 19 /* RSP # */
840 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct) # */
841 +#define UM_POLLIN 1 /* POLLIN # */
842 +#define UM_POLLPRI 2 /* POLLPRI # */
843 +#define UM_POLLOUT 4 /* POLLOUT # */
844 +#define UM_PROT_READ 1 /* PROT_READ # */
845 +#define UM_PROT_WRITE 2 /* PROT_WRITE # */
846 +#define UM_PROT_EXEC 4 /* PROT_EXEC # */
848 diff -NurpP --minimal linux-3.2.5/arch/x86/Kconfig linux-3.2.5-vs2.3.2.6/arch/x86/Kconfig
849 --- linux-3.2.5/arch/x86/Kconfig 2012-01-09 16:14:10.000000000 +0100
850 +++ linux-3.2.5-vs2.3.2.6/arch/x86/Kconfig 2011-12-15 01:11:29.000000000 +0100
851 @@ -2170,6 +2170,8 @@ source "fs/Kconfig"
853 source "arch/x86/Kconfig.debug"
855 +source "kernel/vserver/Kconfig"
857 source "security/Kconfig"
859 source "crypto/Kconfig"
860 diff -NurpP --minimal linux-3.2.5/arch/x86/ia32/ia32entry.S linux-3.2.5-vs2.3.2.6/arch/x86/ia32/ia32entry.S
861 --- linux-3.2.5/arch/x86/ia32/ia32entry.S 2012-01-09 16:14:10.000000000 +0100
862 +++ linux-3.2.5-vs2.3.2.6/arch/x86/ia32/ia32entry.S 2011-12-05 19:33:02.000000000 +0100
863 @@ -776,7 +776,7 @@ ia32_sys_call_table:
864 .quad sys_tgkill /* 270 */
865 .quad compat_sys_utimes
866 .quad sys32_fadvise64_64
867 - .quad quiet_ni_syscall /* sys_vserver */
868 + .quad sys32_vserver
870 .quad compat_sys_get_mempolicy /* 275 */
871 .quad sys_set_mempolicy
872 diff -NurpP --minimal linux-3.2.5/arch/x86/include/asm/unistd_64.h linux-3.2.5-vs2.3.2.6/arch/x86/include/asm/unistd_64.h
873 --- linux-3.2.5/arch/x86/include/asm/unistd_64.h 2012-01-09 16:14:11.000000000 +0100
874 +++ linux-3.2.5-vs2.3.2.6/arch/x86/include/asm/unistd_64.h 2011-12-05 19:33:02.000000000 +0100
875 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
876 #define __NR_utimes 235
877 __SYSCALL(__NR_utimes, sys_utimes)
878 #define __NR_vserver 236
879 -__SYSCALL(__NR_vserver, sys_ni_syscall)
880 +__SYSCALL(__NR_vserver, sys_vserver)
881 #define __NR_mbind 237
882 __SYSCALL(__NR_mbind, sys_mbind)
883 #define __NR_set_mempolicy 238
884 diff -NurpP --minimal linux-3.2.5/arch/x86/kernel/syscall_table_32.S linux-3.2.5-vs2.3.2.6/arch/x86/kernel/syscall_table_32.S
885 --- linux-3.2.5/arch/x86/kernel/syscall_table_32.S 2012-01-09 16:14:11.000000000 +0100
886 +++ linux-3.2.5-vs2.3.2.6/arch/x86/kernel/syscall_table_32.S 2011-12-05 19:33:02.000000000 +0100
887 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
888 .long sys_tgkill /* 270 */
890 .long sys_fadvise64_64
891 - .long sys_ni_syscall /* sys_vserver */
894 .long sys_get_mempolicy
895 .long sys_set_mempolicy
896 diff -NurpP --minimal linux-3.2.5/drivers/block/Kconfig linux-3.2.5-vs2.3.2.6/drivers/block/Kconfig
897 --- linux-3.2.5/drivers/block/Kconfig 2011-10-24 18:45:08.000000000 +0200
898 +++ linux-3.2.5-vs2.3.2.6/drivers/block/Kconfig 2011-12-05 19:33:02.000000000 +0100
899 @@ -288,6 +288,13 @@ config BLK_DEV_CRYPTOLOOP
901 source "drivers/block/drbd/Kconfig"
903 +config BLK_DEV_VROOT
904 + tristate "Virtual Root device support"
905 + depends on QUOTACTL
907 + Saying Y here will allow you to use quota/fs ioctls on a shared
908 + partition within a virtual server without compromising security.
911 tristate "Network block device support"
913 diff -NurpP --minimal linux-3.2.5/drivers/block/Makefile linux-3.2.5-vs2.3.2.6/drivers/block/Makefile
914 --- linux-3.2.5/drivers/block/Makefile 2011-07-22 11:17:44.000000000 +0200
915 +++ linux-3.2.5-vs2.3.2.6/drivers/block/Makefile 2011-12-05 19:33:02.000000000 +0100
916 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
917 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
918 obj-$(CONFIG_BLK_DEV_UB) += ub.o
919 obj-$(CONFIG_BLK_DEV_HD) += hd.o
920 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
922 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
923 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
924 diff -NurpP --minimal linux-3.2.5/drivers/block/loop.c linux-3.2.5-vs2.3.2.6/drivers/block/loop.c
925 --- linux-3.2.5/drivers/block/loop.c 2012-01-09 16:14:15.000000000 +0100
926 +++ linux-3.2.5-vs2.3.2.6/drivers/block/loop.c 2012-01-09 16:19:31.000000000 +0100
928 #include <linux/sysfs.h>
929 #include <linux/miscdevice.h>
930 #include <linux/falloc.h>
931 +#include <linux/vs_context.h>
933 #include <asm/uaccess.h>
935 @@ -868,6 +869,7 @@ static int loop_set_fd(struct loop_devic
936 lo->lo_blocksize = lo_blocksize;
937 lo->lo_device = bdev;
938 lo->lo_flags = lo_flags;
939 + lo->lo_xid = vx_current_xid();
940 lo->lo_backing_file = file;
941 lo->transfer = transfer_none;
943 @@ -1000,6 +1002,7 @@ static int loop_clr_fd(struct loop_devic
944 lo->lo_sizelimit = 0;
945 lo->lo_encrypt_key_size = 0;
946 lo->lo_thread = NULL;
948 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
949 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
950 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
951 @@ -1041,7 +1044,7 @@ loop_set_status(struct loop_device *lo,
953 if (lo->lo_encrypt_key_size &&
954 lo->lo_key_owner != uid &&
955 - !capable(CAP_SYS_ADMIN))
956 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
958 if (lo->lo_state != Lo_bound)
960 @@ -1131,7 +1134,8 @@ loop_get_status(struct loop_device *lo,
961 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
962 info->lo_encrypt_type =
963 lo->lo_encryption ? lo->lo_encryption->number : 0;
964 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
965 + if (lo->lo_encrypt_key_size &&
966 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
967 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
968 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
969 lo->lo_encrypt_key_size);
970 @@ -1491,6 +1495,11 @@ static int lo_open(struct block_device *
974 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P)) {
979 mutex_lock(&lo->lo_ctl_mutex);
981 mutex_unlock(&lo->lo_ctl_mutex);
982 diff -NurpP --minimal linux-3.2.5/drivers/block/vroot.c linux-3.2.5-vs2.3.2.6/drivers/block/vroot.c
983 --- linux-3.2.5/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
984 +++ linux-3.2.5-vs2.3.2.6/drivers/block/vroot.c 2011-12-07 00:05:16.000000000 +0100
987 + * linux/drivers/block/vroot.c
989 + * written by Herbert Pötzl, 9/11/2002
990 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
992 + * based on the loop.c code by Theodore Ts'o.
994 + * Copyright (C) 2002-2007 by Herbert Pötzl.
995 + * Redistribution of this file is permitted under the
996 + * GNU General Public License.
1000 +#include <linux/module.h>
1001 +#include <linux/moduleparam.h>
1002 +#include <linux/file.h>
1003 +#include <linux/major.h>
1004 +#include <linux/blkdev.h>
1005 +#include <linux/slab.h>
1007 +#include <linux/vroot.h>
1008 +#include <linux/vs_context.h>
1011 +static int max_vroot = 8;
1013 +static struct vroot_device *vroot_dev;
1014 +static struct gendisk **disks;
1017 +static int vroot_set_dev(
1018 + struct vroot_device *vr,
1019 + struct block_device *bdev,
1022 + struct block_device *real_bdev;
1023 + struct file *file;
1024 + struct inode *inode;
1028 + if (vr->vr_state != Vr_unbound)
1037 + inode = file->f_dentry->d_inode;
1040 + if (S_ISBLK(inode->i_mode)) {
1041 + real_bdev = inode->i_bdev;
1042 + vr->vr_device = real_bdev;
1043 + __iget(real_bdev->bd_inode);
1047 + vxdprintk(VXD_CBIT(misc, 0),
1048 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1049 + vr->vr_number, VXD_DEV(real_bdev));
1051 + vr->vr_state = Vr_bound;
1060 +static int vroot_clr_dev(
1061 + struct vroot_device *vr,
1062 + struct block_device *bdev)
1064 + struct block_device *real_bdev;
1066 + if (vr->vr_state != Vr_bound)
1068 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1071 + real_bdev = vr->vr_device;
1073 + vxdprintk(VXD_CBIT(misc, 0),
1074 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1075 + vr->vr_number, VXD_DEV(real_bdev));
1078 + vr->vr_state = Vr_unbound;
1079 + vr->vr_device = NULL;
1084 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1085 + unsigned int cmd, unsigned long arg)
1087 + struct vroot_device *vr = bdev->bd_disk->private_data;
1090 + down(&vr->vr_ctl_mutex);
1092 + case VROOT_SET_DEV:
1093 + err = vroot_set_dev(vr, bdev, arg);
1095 + case VROOT_CLR_DEV:
1096 + err = vroot_clr_dev(vr, bdev);
1102 + up(&vr->vr_ctl_mutex);
1106 +static int vr_open(struct block_device *bdev, fmode_t mode)
1108 + struct vroot_device *vr = bdev->bd_disk->private_data;
1110 + down(&vr->vr_ctl_mutex);
1112 + up(&vr->vr_ctl_mutex);
1116 +static int vr_release(struct gendisk *disk, fmode_t mode)
1118 + struct vroot_device *vr = disk->private_data;
1120 + down(&vr->vr_ctl_mutex);
1122 + up(&vr->vr_ctl_mutex);
1126 +static struct block_device_operations vr_fops = {
1127 + .owner = THIS_MODULE,
1129 + .release = vr_release,
1130 + .ioctl = vr_ioctl,
1133 +static void vroot_make_request(struct request_queue *q, struct bio *bio)
1135 + printk("vroot_make_request %p, %p\n", q, bio);
1136 + bio_io_error(bio);
1139 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1141 + struct inode *inode = bdev->bd_inode;
1142 + struct vroot_device *vr;
1143 + struct block_device *real_bdev;
1144 + int minor = iminor(inode);
1146 + vr = &vroot_dev[minor];
1147 + real_bdev = vr->vr_device;
1149 + vxdprintk(VXD_CBIT(misc, 0),
1150 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1151 + vr->vr_number, VXD_DEV(real_bdev));
1153 + if (vr->vr_state != Vr_bound)
1154 + return ERR_PTR(-ENXIO);
1156 + __iget(real_bdev->bd_inode);
1163 + * And now the modules code and kernel interface.
1166 +module_param(max_vroot, int, 0);
1168 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1169 +MODULE_LICENSE("GPL");
1170 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1172 +MODULE_AUTHOR ("Herbert Pötzl");
1173 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1176 +int __init vroot_init(void)
1180 + if (max_vroot < 1 || max_vroot > 256) {
1181 + max_vroot = MAX_VROOT_DEFAULT;
1182 + printk(KERN_WARNING "vroot: invalid max_vroot "
1183 + "(must be between 1 and 256), "
1184 + "using default (%d)\n", max_vroot);
1187 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1191 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1194 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1196 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1200 + for (i = 0; i < max_vroot; i++) {
1201 + disks[i] = alloc_disk(1);
1204 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1205 + if (!disks[i]->queue)
1207 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1210 + for (i = 0; i < max_vroot; i++) {
1211 + struct vroot_device *vr = &vroot_dev[i];
1212 + struct gendisk *disk = disks[i];
1214 + memset(vr, 0, sizeof(*vr));
1215 + sema_init(&vr->vr_ctl_mutex, 1);
1216 + vr->vr_number = i;
1217 + disk->major = VROOT_MAJOR;
1218 + disk->first_minor = i;
1219 + disk->fops = &vr_fops;
1220 + sprintf(disk->disk_name, "vroot%d", i);
1221 + disk->private_data = vr;
1224 + err = register_vroot_grb(&__vroot_get_real_bdev);
1228 + for (i = 0; i < max_vroot; i++)
1229 + add_disk(disks[i]);
1230 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1235 + put_disk(disks[i]);
1240 + unregister_blkdev(VROOT_MAJOR, "vroot");
1241 + printk(KERN_ERR "vroot: ran out of memory\n");
1245 +void vroot_exit(void)
1249 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1250 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1252 + for (i = 0; i < max_vroot; i++) {
1253 + del_gendisk(disks[i]);
1254 + put_disk(disks[i]);
1256 + unregister_blkdev(VROOT_MAJOR, "vroot");
1262 +module_init(vroot_init);
1263 +module_exit(vroot_exit);
1267 +static int __init max_vroot_setup(char *str)
1269 + max_vroot = simple_strtol(str, NULL, 0);
1273 +__setup("max_vroot=", max_vroot_setup);
1277 diff -NurpP --minimal linux-3.2.5/drivers/infiniband/core/addr.c linux-3.2.5-vs2.3.2.6/drivers/infiniband/core/addr.c
1278 --- linux-3.2.5/drivers/infiniband/core/addr.c 2012-01-09 16:14:19.000000000 +0100
1279 +++ linux-3.2.5-vs2.3.2.6/drivers/infiniband/core/addr.c 2011-12-05 19:33:02.000000000 +0100
1280 @@ -255,7 +255,7 @@ static int addr6_resolve(struct sockaddr
1282 if (ipv6_addr_any(&fl6.saddr)) {
1283 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1284 - &fl6.daddr, 0, &fl6.saddr);
1285 + &fl6.daddr, 0, &fl6.saddr, NULL);
1289 diff -NurpP --minimal linux-3.2.5/drivers/md/dm-ioctl.c linux-3.2.5-vs2.3.2.6/drivers/md/dm-ioctl.c
1290 --- linux-3.2.5/drivers/md/dm-ioctl.c 2012-01-09 16:14:20.000000000 +0100
1291 +++ linux-3.2.5-vs2.3.2.6/drivers/md/dm-ioctl.c 2011-12-05 19:33:02.000000000 +0100
1293 #include <linux/dm-ioctl.h>
1294 #include <linux/hdreg.h>
1295 #include <linux/compat.h>
1296 +#include <linux/vs_context.h>
1298 #include <asm/uaccess.h>
1300 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1301 unsigned int h = hash_str(str);
1303 list_for_each_entry (hc, _name_buckets + h, name_list)
1304 - if (!strcmp(hc->name, str)) {
1305 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1306 + !strcmp(hc->name, str)) {
1310 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1311 unsigned int h = hash_str(str);
1313 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1314 - if (!strcmp(hc->uuid, str)) {
1315 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1316 + !strcmp(hc->uuid, str)) {
1320 @@ -131,13 +134,15 @@ static struct hash_cell *__get_uuid_cell
1321 static struct hash_cell *__get_dev_cell(uint64_t dev)
1323 struct mapped_device *md;
1324 - struct hash_cell *hc;
1325 + struct hash_cell *hc = NULL;
1327 md = dm_get_md(huge_decode_dev(dev));
1331 - hc = dm_get_mdptr(md);
1332 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1333 + hc = dm_get_mdptr(md);
1338 @@ -445,6 +450,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1340 static int remove_all(struct dm_ioctl *param, size_t param_size)
1342 + if (!vx_check(0, VS_ADMIN))
1345 dm_hash_remove_all(1);
1346 param->data_size = 0;
1348 @@ -492,6 +500,8 @@ static int list_devices(struct dm_ioctl
1350 for (i = 0; i < NUM_BUCKETS; i++) {
1351 list_for_each_entry (hc, _name_buckets + i, name_list) {
1352 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1354 needed += sizeof(struct dm_name_list);
1355 needed += strlen(hc->name) + 1;
1356 needed += ALIGN_MASK;
1357 @@ -515,6 +525,8 @@ static int list_devices(struct dm_ioctl
1359 for (i = 0; i < NUM_BUCKETS; i++) {
1360 list_for_each_entry (hc, _name_buckets + i, name_list) {
1361 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1364 old_nl->next = (uint32_t) ((void *) nl -
1366 @@ -1615,8 +1627,8 @@ static int ctl_ioctl(uint command, struc
1368 size_t input_param_size;
1370 - /* only root can play with this */
1371 - if (!capable(CAP_SYS_ADMIN))
1372 + /* only root and certain contexts can play with this */
1373 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1376 if (_IOC_TYPE(command) != DM_IOCTL)
1377 diff -NurpP --minimal linux-3.2.5/drivers/md/dm.c linux-3.2.5-vs2.3.2.6/drivers/md/dm.c
1378 --- linux-3.2.5/drivers/md/dm.c 2012-01-09 16:14:21.000000000 +0100
1379 +++ linux-3.2.5-vs2.3.2.6/drivers/md/dm.c 2011-12-05 19:33:02.000000000 +0100
1381 #include <linux/idr.h>
1382 #include <linux/hdreg.h>
1383 #include <linux/delay.h>
1384 +#include <linux/vs_base.h>
1386 #include <trace/events/block.h>
1388 @@ -132,6 +133,7 @@ struct mapped_device {
1391 atomic_t open_count;
1394 unsigned long flags;
1396 @@ -344,6 +346,7 @@ int dm_deleting_md(struct mapped_device
1397 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1399 struct mapped_device *md;
1402 spin_lock(&_minor_lock);
1404 @@ -352,18 +355,19 @@ static int dm_blk_open(struct block_devi
1407 if (test_bit(DMF_FREEING, &md->flags) ||
1408 - dm_deleting_md(md)) {
1410 + dm_deleting_md(md))
1414 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1419 atomic_inc(&md->open_count);
1423 spin_unlock(&_minor_lock);
1425 - return md ? 0 : -ENXIO;
1429 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1430 @@ -584,6 +588,14 @@ int dm_set_geometry(struct mapped_device
1435 + * Get the xid associated with a dm device
1437 +xid_t dm_get_xid(struct mapped_device *md)
1442 /*-----------------------------------------------------------------
1444 * A more elegant soln is in the works that uses the queue
1445 @@ -1850,6 +1862,7 @@ static struct mapped_device *alloc_dev(i
1446 INIT_LIST_HEAD(&md->uevent_list);
1447 spin_lock_init(&md->uevent_lock);
1449 + md->xid = vx_current_xid();
1450 md->queue = blk_alloc_queue(GFP_KERNEL);
1453 diff -NurpP --minimal linux-3.2.5/drivers/md/dm.h linux-3.2.5-vs2.3.2.6/drivers/md/dm.h
1454 --- linux-3.2.5/drivers/md/dm.h 2012-01-09 16:14:21.000000000 +0100
1455 +++ linux-3.2.5-vs2.3.2.6/drivers/md/dm.h 2011-12-05 19:33:02.000000000 +0100
1456 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1458 struct dm_md_mempools;
1460 +xid_t dm_get_xid(struct mapped_device *md);
1462 /*-----------------------------------------------------------------
1463 * Internal table functions.
1464 *---------------------------------------------------------------*/
1465 diff -NurpP --minimal linux-3.2.5/drivers/net/tun.c linux-3.2.5-vs2.3.2.6/drivers/net/tun.c
1466 --- linux-3.2.5/drivers/net/tun.c 2012-01-09 16:14:35.000000000 +0100
1467 +++ linux-3.2.5-vs2.3.2.6/drivers/net/tun.c 2011-12-05 19:33:02.000000000 +0100
1469 #include <linux/nsproxy.h>
1470 #include <linux/virtio_net.h>
1471 #include <linux/rcupdate.h>
1472 +#include <linux/vs_network.h>
1473 #include <net/net_namespace.h>
1474 #include <net/netns/generic.h>
1475 #include <net/rtnetlink.h>
1476 @@ -121,6 +122,7 @@ struct tun_struct {
1482 struct net_device *dev;
1484 @@ -909,6 +911,7 @@ static void tun_setup(struct net_device
1488 + tun->nid = current->nid;
1490 dev->ethtool_ops = &tun_ethtool_ops;
1491 dev->destructor = tun_free_netdev;
1492 @@ -1059,7 +1062,7 @@ static int tun_set_iff(struct net *net,
1494 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1495 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1496 - !capable(CAP_NET_ADMIN))
1497 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1499 err = security_tun_dev_attach(tun->socket.sk);
1501 @@ -1073,7 +1076,7 @@ static int tun_set_iff(struct net *net,
1503 unsigned long flags = 0;
1505 - if (!capable(CAP_NET_ADMIN))
1506 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1508 err = security_tun_dev_create();
1510 @@ -1141,6 +1144,9 @@ static int tun_set_iff(struct net *net,
1512 sk->sk_destruct = tun_sock_destruct;
1514 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1517 err = tun_attach(tun, file);
1520 @@ -1322,6 +1328,16 @@ static long __tun_chr_ioctl(struct file
1521 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
1525 + if (!capable(CAP_CONTEXT))
1528 + /* Set nid owner of the device */
1529 + tun->nid = (nid_t) arg;
1531 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1535 /* Only allow setting the type when the interface is down */
1536 if (tun->dev->flags & IFF_UP) {
1537 diff -NurpP --minimal linux-3.2.5/drivers/tty/sysrq.c linux-3.2.5-vs2.3.2.6/drivers/tty/sysrq.c
1538 --- linux-3.2.5/drivers/tty/sysrq.c 2011-05-22 16:17:44.000000000 +0200
1539 +++ linux-3.2.5-vs2.3.2.6/drivers/tty/sysrq.c 2011-12-05 19:33:02.000000000 +0100
1541 #include <linux/oom.h>
1542 #include <linux/slab.h>
1543 #include <linux/input.h>
1544 +#include <linux/vserver/debug.h>
1546 #include <asm/ptrace.h>
1547 #include <asm/irq_regs.h>
1548 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
1549 .enable_mask = SYSRQ_ENABLE_RTNICE,
1553 +#ifdef CONFIG_VSERVER_DEBUG
1554 +static void sysrq_handle_vxinfo(int key)
1556 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1559 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1560 + .handler = sysrq_handle_vxinfo,
1561 + .help_msg = "conteXt",
1562 + .action_msg = "Show Context Info",
1563 + .enable_mask = SYSRQ_ENABLE_DUMP,
1567 /* Key Operations table and lock */
1568 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1570 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
1572 &sysrq_showstate_blocked_op, /* w */
1573 /* x: May be registered on ppc/powerpc for xmon */
1574 +#ifdef CONFIG_VSERVER_DEBUG
1575 + &sysrq_showvxinfo_op, /* x */
1579 /* y: May be registered on sparc64 for global register dump */
1581 &sysrq_ftrace_dump_op, /* z */
1582 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
1584 else if ((key >= 'a') && (key <= 'z'))
1585 retval = key + 10 - 'a';
1586 + else if ((key >= 'A') && (key <= 'Z'))
1587 + retval = key + 10 - 'A';
1591 diff -NurpP --minimal linux-3.2.5/drivers/tty/tty_io.c linux-3.2.5-vs2.3.2.6/drivers/tty/tty_io.c
1592 --- linux-3.2.5/drivers/tty/tty_io.c 2012-01-09 16:14:48.000000000 +0100
1593 +++ linux-3.2.5-vs2.3.2.6/drivers/tty/tty_io.c 2011-12-05 19:33:02.000000000 +0100
1596 #include <linux/kmod.h>
1597 #include <linux/nsproxy.h>
1598 +#include <linux/vs_pid.h>
1600 #undef TTY_DEBUG_HANGUP
1602 @@ -2080,7 +2081,8 @@ static int tiocsti(struct tty_struct *tt
1604 struct tty_ldisc *ld;
1606 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1607 + if (((current->signal->tty != tty) &&
1608 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1610 if (get_user(ch, p))
1612 @@ -2368,6 +2370,7 @@ static int tiocspgrp(struct tty_struct *
1614 if (get_user(pgrp_nr, p))
1616 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1620 diff -NurpP --minimal linux-3.2.5/fs/attr.c linux-3.2.5-vs2.3.2.6/fs/attr.c
1621 --- linux-3.2.5/fs/attr.c 2012-01-09 16:14:53.000000000 +0100
1622 +++ linux-3.2.5-vs2.3.2.6/fs/attr.c 2011-12-05 21:16:01.000000000 +0100
1624 #include <linux/fcntl.h>
1625 #include <linux/security.h>
1626 #include <linux/evm.h>
1627 +#include <linux/proc_fs.h>
1628 +#include <linux/devpts_fs.h>
1629 +#include <linux/vs_tag.h>
1632 * inode_change_ok - check if attribute changes to an inode are allowed
1633 @@ -74,6 +77,10 @@ int inode_change_ok(const struct inode *
1637 + /* check for inode tag permission */
1638 + if (dx_permission(inode, MAY_WRITE))
1643 EXPORT_SYMBOL(inode_change_ok);
1644 @@ -144,6 +151,8 @@ void setattr_copy(struct inode *inode, c
1645 inode->i_uid = attr->ia_uid;
1646 if (ia_valid & ATTR_GID)
1647 inode->i_gid = attr->ia_gid;
1648 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1649 + inode->i_tag = attr->ia_tag;
1650 if (ia_valid & ATTR_ATIME)
1651 inode->i_atime = timespec_trunc(attr->ia_atime,
1652 inode->i_sb->s_time_gran);
1653 @@ -171,7 +180,8 @@ int notify_change(struct dentry * dentry
1654 struct timespec now;
1655 unsigned int ia_valid = attr->ia_valid;
1657 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1658 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1659 + ATTR_TAG | ATTR_TIMES_SET)) {
1660 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1663 diff -NurpP --minimal linux-3.2.5/fs/block_dev.c linux-3.2.5-vs2.3.2.6/fs/block_dev.c
1664 --- linux-3.2.5/fs/block_dev.c 2012-01-09 16:14:53.000000000 +0100
1665 +++ linux-3.2.5-vs2.3.2.6/fs/block_dev.c 2011-12-05 19:33:02.000000000 +0100
1667 #include <linux/namei.h>
1668 #include <linux/log2.h>
1669 #include <linux/kmemleak.h>
1670 +#include <linux/vs_device.h>
1671 #include <asm/uaccess.h>
1672 #include "internal.h"
1674 @@ -563,6 +564,7 @@ struct block_device *bdget(dev_t dev)
1675 bdev->bd_invalidated = 0;
1676 inode->i_mode = S_IFBLK;
1677 inode->i_rdev = dev;
1678 + inode->i_mdev = dev;
1679 inode->i_bdev = bdev;
1680 inode->i_data.a_ops = &def_blk_aops;
1681 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1682 @@ -609,6 +611,11 @@ EXPORT_SYMBOL(bdput);
1683 static struct block_device *bd_acquire(struct inode *inode)
1685 struct block_device *bdev;
1688 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1690 + inode->i_mdev = mdev;
1692 spin_lock(&bdev_lock);
1693 bdev = inode->i_bdev;
1694 @@ -619,7 +626,7 @@ static struct block_device *bd_acquire(s
1696 spin_unlock(&bdev_lock);
1698 - bdev = bdget(inode->i_rdev);
1699 + bdev = bdget(mdev);
1701 spin_lock(&bdev_lock);
1702 if (!inode->i_bdev) {
1703 diff -NurpP --minimal linux-3.2.5/fs/btrfs/ctree.h linux-3.2.5-vs2.3.2.6/fs/btrfs/ctree.h
1704 --- linux-3.2.5/fs/btrfs/ctree.h 2012-01-09 16:14:53.000000000 +0100
1705 +++ linux-3.2.5-vs2.3.2.6/fs/btrfs/ctree.h 2012-01-09 16:19:31.000000000 +0100
1706 @@ -643,11 +643,14 @@ struct btrfs_inode_item {
1707 /* modification sequence number for NFS */
1712 * a little future expansion, for more than this we can
1713 * just grow the inode item and version it
1715 - __le64 reserved[4];
1716 + __le16 reserved16;
1717 + __le32 reserved32;
1718 + __le64 reserved[3];
1719 struct btrfs_timespec atime;
1720 struct btrfs_timespec ctime;
1721 struct btrfs_timespec mtime;
1722 @@ -1414,6 +1417,8 @@ struct btrfs_ioctl_defrag_range_args {
1723 #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17)
1724 #define BTRFS_MOUNT_RECOVERY (1 << 18)
1726 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1728 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1729 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1730 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
1731 @@ -1621,6 +1626,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1732 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1733 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1734 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1735 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1736 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1737 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1738 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1739 @@ -1674,6 +1680,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1741 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1743 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1744 +#define BTRFS_INODE_BARRIER (1 << 25)
1745 +#define BTRFS_INODE_COW (1 << 26)
1748 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1750 @@ -2730,6 +2740,7 @@ extern const struct dentry_operations bt
1751 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1752 void btrfs_update_iflags(struct inode *inode);
1753 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1754 +int btrfs_sync_flags(struct inode *inode, int, int);
1755 int btrfs_defrag_file(struct inode *inode, struct file *file,
1756 struct btrfs_ioctl_defrag_range_args *range,
1757 u64 newer_than, unsigned long max_pages);
1758 diff -NurpP --minimal linux-3.2.5/fs/btrfs/disk-io.c linux-3.2.5-vs2.3.2.6/fs/btrfs/disk-io.c
1759 --- linux-3.2.5/fs/btrfs/disk-io.c 2012-01-09 16:14:53.000000000 +0100
1760 +++ linux-3.2.5-vs2.3.2.6/fs/btrfs/disk-io.c 2012-01-09 16:19:31.000000000 +0100
1761 @@ -2103,6 +2103,9 @@ struct btrfs_root *open_ctree(struct sup
1765 + if (btrfs_test_opt(tree_root, TAGGED))
1766 + sb->s_flags |= MS_TAGGED;
1768 features = btrfs_super_incompat_flags(disk_super) &
1769 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1771 diff -NurpP --minimal linux-3.2.5/fs/btrfs/inode.c linux-3.2.5-vs2.3.2.6/fs/btrfs/inode.c
1772 --- linux-3.2.5/fs/btrfs/inode.c 2012-01-09 16:14:53.000000000 +0100
1773 +++ linux-3.2.5-vs2.3.2.6/fs/btrfs/inode.c 2012-01-09 16:19:51.000000000 +0100
1775 #include <linux/slab.h>
1776 #include <linux/ratelimit.h>
1777 #include <linux/mount.h>
1778 +#include <linux/vs_tag.h>
1781 #include "disk-io.h"
1782 @@ -2332,6 +2333,8 @@ static void btrfs_read_locked_inode(stru
1783 struct btrfs_key location;
1789 bool filled = false;
1791 @@ -2359,8 +2362,13 @@ static void btrfs_read_locked_inode(stru
1792 struct btrfs_inode_item);
1793 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1794 set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
1795 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
1796 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
1798 + uid = btrfs_inode_uid(leaf, inode_item);
1799 + gid = btrfs_inode_gid(leaf, inode_item);
1800 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
1801 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
1802 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
1803 + btrfs_inode_tag(leaf, inode_item));
1804 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1806 tspec = btrfs_inode_atime(inode_item);
1807 @@ -2438,8 +2446,14 @@ static void fill_inode_item(struct btrfs
1808 struct btrfs_inode_item *item,
1809 struct inode *inode)
1811 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
1812 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
1813 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
1814 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
1816 + btrfs_set_inode_uid(leaf, item, uid);
1817 + btrfs_set_inode_gid(leaf, item, gid);
1818 +#ifdef CONFIG_TAGGING_INTERN
1819 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
1821 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
1822 btrfs_set_inode_mode(leaf, item, inode->i_mode);
1823 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
1824 @@ -7377,11 +7391,13 @@ static const struct inode_operations btr
1825 .listxattr = btrfs_listxattr,
1826 .removexattr = btrfs_removexattr,
1827 .permission = btrfs_permission,
1828 + .sync_flags = btrfs_sync_flags,
1829 .get_acl = btrfs_get_acl,
1831 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1832 .lookup = btrfs_lookup,
1833 .permission = btrfs_permission,
1834 + .sync_flags = btrfs_sync_flags,
1835 .get_acl = btrfs_get_acl,
1838 diff -NurpP --minimal linux-3.2.5/fs/btrfs/ioctl.c linux-3.2.5-vs2.3.2.6/fs/btrfs/ioctl.c
1839 --- linux-3.2.5/fs/btrfs/ioctl.c 2012-01-09 16:14:53.000000000 +0100
1840 +++ linux-3.2.5-vs2.3.2.6/fs/btrfs/ioctl.c 2012-01-09 16:19:31.000000000 +0100
1841 @@ -71,10 +71,13 @@ static unsigned int btrfs_flags_to_ioctl
1843 unsigned int iflags = 0;
1845 - if (flags & BTRFS_INODE_SYNC)
1846 - iflags |= FS_SYNC_FL;
1847 if (flags & BTRFS_INODE_IMMUTABLE)
1848 iflags |= FS_IMMUTABLE_FL;
1849 + if (flags & BTRFS_INODE_IXUNLINK)
1850 + iflags |= FS_IXUNLINK_FL;
1852 + if (flags & BTRFS_INODE_SYNC)
1853 + iflags |= FS_SYNC_FL;
1854 if (flags & BTRFS_INODE_APPEND)
1855 iflags |= FS_APPEND_FL;
1856 if (flags & BTRFS_INODE_NODUMP)
1857 @@ -91,28 +94,78 @@ static unsigned int btrfs_flags_to_ioctl
1858 else if (flags & BTRFS_INODE_NOCOMPRESS)
1859 iflags |= FS_NOCOMP_FL;
1861 + if (flags & BTRFS_INODE_BARRIER)
1862 + iflags |= FS_BARRIER_FL;
1863 + if (flags & BTRFS_INODE_COW)
1864 + iflags |= FS_COW_FL;
1869 - * Update inode->i_flags based on the btrfs internal flags.
1870 + * Update inode->i_(v)flags based on the btrfs internal flags.
1872 void btrfs_update_iflags(struct inode *inode)
1874 struct btrfs_inode *ip = BTRFS_I(inode);
1876 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
1877 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
1878 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
1880 - if (ip->flags & BTRFS_INODE_SYNC)
1881 - inode->i_flags |= S_SYNC;
1882 if (ip->flags & BTRFS_INODE_IMMUTABLE)
1883 inode->i_flags |= S_IMMUTABLE;
1884 + if (ip->flags & BTRFS_INODE_IXUNLINK)
1885 + inode->i_flags |= S_IXUNLINK;
1887 + if (ip->flags & BTRFS_INODE_SYNC)
1888 + inode->i_flags |= S_SYNC;
1889 if (ip->flags & BTRFS_INODE_APPEND)
1890 inode->i_flags |= S_APPEND;
1891 if (ip->flags & BTRFS_INODE_NOATIME)
1892 inode->i_flags |= S_NOATIME;
1893 if (ip->flags & BTRFS_INODE_DIRSYNC)
1894 inode->i_flags |= S_DIRSYNC;
1896 + inode->i_vflags &= ~(V_BARRIER | V_COW);
1898 + if (ip->flags & BTRFS_INODE_BARRIER)
1899 + inode->i_vflags |= V_BARRIER;
1900 + if (ip->flags & BTRFS_INODE_COW)
1901 + inode->i_vflags |= V_COW;
1905 + * Update btrfs internal flags from inode->i_(v)flags.
1907 +void btrfs_update_flags(struct inode *inode)
1909 + struct btrfs_inode *ip = BTRFS_I(inode);
1911 + unsigned int flags = inode->i_flags;
1912 + unsigned int vflags = inode->i_vflags;
1914 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
1915 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
1916 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
1917 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
1919 + if (flags & S_IMMUTABLE)
1920 + ip->flags |= BTRFS_INODE_IMMUTABLE;
1921 + if (flags & S_IXUNLINK)
1922 + ip->flags |= BTRFS_INODE_IXUNLINK;
1924 + if (flags & S_SYNC)
1925 + ip->flags |= BTRFS_INODE_SYNC;
1926 + if (flags & S_APPEND)
1927 + ip->flags |= BTRFS_INODE_APPEND;
1928 + if (flags & S_NOATIME)
1929 + ip->flags |= BTRFS_INODE_NOATIME;
1930 + if (flags & S_DIRSYNC)
1931 + ip->flags |= BTRFS_INODE_DIRSYNC;
1933 + if (vflags & V_BARRIER)
1934 + ip->flags |= BTRFS_INODE_BARRIER;
1935 + if (vflags & V_COW)
1936 + ip->flags |= BTRFS_INODE_COW;
1940 @@ -128,6 +181,7 @@ void btrfs_inherit_iflags(struct inode *
1943 flags = BTRFS_I(dir)->flags;
1944 + flags &= ~BTRFS_INODE_BARRIER;
1946 if (flags & BTRFS_INODE_NOCOMPRESS) {
1947 BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
1948 @@ -143,6 +197,30 @@ void btrfs_inherit_iflags(struct inode *
1949 btrfs_update_iflags(inode);
1952 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
1954 + struct btrfs_inode *ip = BTRFS_I(inode);
1955 + struct btrfs_root *root = ip->root;
1956 + struct btrfs_trans_handle *trans;
1959 + trans = btrfs_join_transaction(root);
1962 + inode->i_flags = flags;
1963 + inode->i_vflags = vflags;
1964 + btrfs_update_flags(inode);
1966 + ret = btrfs_update_inode(trans, root, inode);
1969 + btrfs_update_iflags(inode);
1970 + inode->i_ctime = CURRENT_TIME;
1971 + btrfs_end_transaction(trans, root);
1976 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
1978 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
1979 @@ -194,7 +272,8 @@ static int btrfs_ioctl_setflags(struct f
1981 flags = btrfs_mask_flags(inode->i_mode, flags);
1982 oldflags = btrfs_flags_to_ioctl(ip->flags);
1983 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
1984 + if ((flags ^ oldflags) & (FS_APPEND_FL |
1985 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
1986 if (!capable(CAP_LINUX_IMMUTABLE)) {
1989 @@ -205,14 +284,19 @@ static int btrfs_ioctl_setflags(struct f
1993 - if (flags & FS_SYNC_FL)
1994 - ip->flags |= BTRFS_INODE_SYNC;
1996 - ip->flags &= ~BTRFS_INODE_SYNC;
1997 if (flags & FS_IMMUTABLE_FL)
1998 ip->flags |= BTRFS_INODE_IMMUTABLE;
2000 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2001 + if (flags & FS_IXUNLINK_FL)
2002 + ip->flags |= BTRFS_INODE_IXUNLINK;
2004 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2006 + if (flags & FS_SYNC_FL)
2007 + ip->flags |= BTRFS_INODE_SYNC;
2009 + ip->flags &= ~BTRFS_INODE_SYNC;
2010 if (flags & FS_APPEND_FL)
2011 ip->flags |= BTRFS_INODE_APPEND;
2013 diff -NurpP --minimal linux-3.2.5/fs/btrfs/super.c linux-3.2.5-vs2.3.2.6/fs/btrfs/super.c
2014 --- linux-3.2.5/fs/btrfs/super.c 2012-01-09 16:14:53.000000000 +0100
2015 +++ linux-3.2.5-vs2.3.2.6/fs/btrfs/super.c 2012-01-09 16:19:31.000000000 +0100
2016 @@ -165,7 +165,8 @@ enum {
2017 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
2018 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
2019 Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,
2020 - Opt_inode_cache, Opt_no_space_cache, Opt_recovery, Opt_err,
2021 + Opt_inode_cache, Opt_no_space_cache, Opt_recovery,
2022 + Opt_tag, Opt_notag, Opt_tagid, Opt_err,
2025 static match_table_t tokens = {
2026 @@ -200,6 +201,9 @@ static match_table_t tokens = {
2027 {Opt_inode_cache, "inode_cache"},
2028 {Opt_no_space_cache, "nospace_cache"},
2029 {Opt_recovery, "recovery"},
2031 + {Opt_notag, "notag"},
2032 + {Opt_tagid, "tagid=%u"},
2036 @@ -398,6 +402,22 @@ int btrfs_parse_options(struct btrfs_roo
2037 printk(KERN_INFO "btrfs: enabling auto recovery");
2038 btrfs_set_opt(info->mount_opt, RECOVERY);
2040 +#ifndef CONFIG_TAGGING_NONE
2042 + printk(KERN_INFO "btrfs: use tagging\n");
2043 + btrfs_set_opt(info->mount_opt, TAGGED);
2046 + printk(KERN_INFO "btrfs: disabled tagging\n");
2047 + btrfs_clear_opt(info->mount_opt, TAGGED);
2050 +#ifdef CONFIG_PROPAGATE
2053 + btrfs_set_opt(info->mount_opt, TAGGED);
2057 printk(KERN_INFO "btrfs: unrecognized mount option "
2059 @@ -985,6 +1005,12 @@ static int btrfs_remount(struct super_bl
2063 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2064 + printk("btrfs: %s: tagging not permitted on remount.\n",
2069 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2072 diff -NurpP --minimal linux-3.2.5/fs/char_dev.c linux-3.2.5-vs2.3.2.6/fs/char_dev.c
2073 --- linux-3.2.5/fs/char_dev.c 2011-03-15 18:07:31.000000000 +0100
2074 +++ linux-3.2.5-vs2.3.2.6/fs/char_dev.c 2011-12-05 19:33:02.000000000 +0100
2076 #include <linux/mutex.h>
2077 #include <linux/backing-dev.h>
2078 #include <linux/tty.h>
2079 +#include <linux/vs_context.h>
2080 +#include <linux/vs_device.h>
2082 #include "internal.h"
2084 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2086 struct cdev *new = NULL;
2090 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2092 + inode->i_mdev = mdev;
2094 spin_lock(&cdev_lock);
2097 struct kobject *kobj;
2100 spin_unlock(&cdev_lock);
2101 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2103 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2106 new = container_of(kobj, struct cdev, kobj);
2107 diff -NurpP --minimal linux-3.2.5/fs/dcache.c linux-3.2.5-vs2.3.2.6/fs/dcache.c
2108 --- linux-3.2.5/fs/dcache.c 2012-02-07 01:57:54.000000000 +0100
2109 +++ linux-3.2.5-vs2.3.2.6/fs/dcache.c 2012-01-26 08:52:10.000000000 +0100
2111 #include <linux/rculist_bl.h>
2112 #include <linux/prefetch.h>
2113 #include <linux/ratelimit.h>
2114 +#include <linux/vs_limit.h>
2115 #include "internal.h"
2118 @@ -539,6 +540,8 @@ int d_invalidate(struct dentry * dentry)
2119 spin_lock(&dentry->d_lock);
2122 + vx_dentry_dec(dentry);
2125 * Somebody else still using it?
2127 @@ -568,6 +571,7 @@ EXPORT_SYMBOL(d_invalidate);
2128 static inline void __dget_dlock(struct dentry *dentry)
2131 + vx_dentry_inc(dentry);
2134 static inline void __dget(struct dentry *dentry)
2135 @@ -1192,6 +1196,9 @@ struct dentry *__d_alloc(struct super_bl
2136 struct dentry *dentry;
2139 + if (!vx_dentry_avail(1))
2142 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2145 @@ -1214,6 +1221,7 @@ struct dentry *__d_alloc(struct super_bl
2147 dentry->d_count = 1;
2148 dentry->d_flags = 0;
2149 + vx_dentry_inc(dentry);
2150 spin_lock_init(&dentry->d_lock);
2151 seqcount_init(&dentry->d_seq);
2152 dentry->d_inode = NULL;
2153 @@ -1872,6 +1880,7 @@ struct dentry *__d_lookup(struct dentry
2157 + vx_dentry_inc(dentry);
2159 spin_unlock(&dentry->d_lock);
2161 diff -NurpP --minimal linux-3.2.5/fs/devpts/inode.c linux-3.2.5-vs2.3.2.6/fs/devpts/inode.c
2162 --- linux-3.2.5/fs/devpts/inode.c 2012-01-09 16:14:54.000000000 +0100
2163 +++ linux-3.2.5-vs2.3.2.6/fs/devpts/inode.c 2011-12-05 21:23:19.000000000 +0100
2165 #include <linux/parser.h>
2166 #include <linux/fsnotify.h>
2167 #include <linux/seq_file.h>
2168 +#include <linux/vs_base.h>
2170 #define DEVPTS_DEFAULT_MODE 0600
2173 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2174 #define PTMX_MINOR 2
2176 +static int devpts_permission(struct inode *inode, int mask)
2178 + int ret = -EACCES;
2180 + /* devpts is xid tagged */
2181 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2182 + ret = generic_permission(inode, mask);
2186 +static struct inode_operations devpts_file_inode_operations = {
2187 + .permission = devpts_permission,
2190 extern int pty_limit; /* Config limit on Unix98 ptys */
2191 static DEFINE_MUTEX(allocated_ptys_lock);
2193 @@ -263,6 +278,34 @@ static int devpts_show_options(struct se
2197 +static int devpts_filter(struct dentry *de)
2201 + /* devpts is xid tagged */
2202 + if (de && de->d_inode)
2203 + xid = (xid_t)de->d_inode->i_tag;
2204 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2206 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2207 + de->d_name.len, de->d_name.name);
2209 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2212 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2214 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2217 +static struct file_operations devpts_dir_operations = {
2218 + .open = dcache_dir_open,
2219 + .release = dcache_dir_close,
2220 + .llseek = dcache_dir_lseek,
2221 + .read = generic_read_dir,
2222 + .readdir = devpts_readdir,
2225 static const struct super_operations devpts_sops = {
2226 .statfs = simple_statfs,
2227 .remount_fs = devpts_remount,
2228 @@ -306,8 +349,10 @@ devpts_fill_super(struct super_block *s,
2229 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2230 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2231 inode->i_op = &simple_dir_inode_operations;
2232 - inode->i_fop = &simple_dir_operations;
2233 + inode->i_fop = &devpts_dir_operations;
2234 set_nlink(inode, 2);
2235 + /* devpts is xid tagged */
2236 + inode->i_tag = (tag_t)vx_current_xid();
2238 s->s_root = d_alloc_root(inode);
2240 @@ -494,6 +539,9 @@ int devpts_pty_new(struct inode *ptmx_in
2241 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2242 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2243 init_special_inode(inode, S_IFCHR|opts->mode, device);
2244 + /* devpts is xid tagged */
2245 + inode->i_tag = (tag_t)vx_current_xid();
2246 + inode->i_op = &devpts_file_inode_operations;
2247 inode->i_private = tty;
2248 tty->driver_data = inode;
2250 diff -NurpP --minimal linux-3.2.5/fs/ext2/balloc.c linux-3.2.5-vs2.3.2.6/fs/ext2/balloc.c
2251 --- linux-3.2.5/fs/ext2/balloc.c 2012-01-09 16:14:54.000000000 +0100
2252 +++ linux-3.2.5-vs2.3.2.6/fs/ext2/balloc.c 2011-12-05 19:33:02.000000000 +0100
2253 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2255 end = EXT2_BLOCKS_PER_GROUP(sb);
2258 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2261 diff -NurpP --minimal linux-3.2.5/fs/ext2/ext2.h linux-3.2.5-vs2.3.2.6/fs/ext2/ext2.h
2262 --- linux-3.2.5/fs/ext2/ext2.h 2012-01-09 16:14:54.000000000 +0100
2263 +++ linux-3.2.5-vs2.3.2.6/fs/ext2/ext2.h 2011-12-05 19:33:02.000000000 +0100
2264 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct
2265 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2266 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2267 u64 start, u64 len);
2268 +extern int ext2_sync_flags(struct inode *, int, int);
2271 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2272 diff -NurpP --minimal linux-3.2.5/fs/ext2/file.c linux-3.2.5-vs2.3.2.6/fs/ext2/file.c
2273 --- linux-3.2.5/fs/ext2/file.c 2011-10-24 18:45:27.000000000 +0200
2274 +++ linux-3.2.5-vs2.3.2.6/fs/ext2/file.c 2011-12-05 19:33:02.000000000 +0100
2275 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2276 .setattr = ext2_setattr,
2277 .get_acl = ext2_get_acl,
2278 .fiemap = ext2_fiemap,
2279 + .sync_flags = ext2_sync_flags,
2281 diff -NurpP --minimal linux-3.2.5/fs/ext2/ialloc.c linux-3.2.5-vs2.3.2.6/fs/ext2/ialloc.c
2282 --- linux-3.2.5/fs/ext2/ialloc.c 2012-01-09 16:14:54.000000000 +0100
2283 +++ linux-3.2.5-vs2.3.2.6/fs/ext2/ialloc.c 2011-12-05 19:33:02.000000000 +0100
2285 #include <linux/backing-dev.h>
2286 #include <linux/buffer_head.h>
2287 #include <linux/random.h>
2288 +#include <linux/vs_tag.h>
2292 @@ -549,6 +550,7 @@ got:
2293 inode->i_mode = mode;
2294 inode->i_uid = current_fsuid();
2295 inode->i_gid = dir->i_gid;
2296 + inode->i_tag = dx_current_fstag(sb);
2298 inode_init_owner(inode, dir, mode);
2300 diff -NurpP --minimal linux-3.2.5/fs/ext2/inode.c linux-3.2.5-vs2.3.2.6/fs/ext2/inode.c
2301 --- linux-3.2.5/fs/ext2/inode.c 2012-01-09 16:14:54.000000000 +0100
2302 +++ linux-3.2.5-vs2.3.2.6/fs/ext2/inode.c 2011-12-05 21:24:12.000000000 +0100
2304 #include <linux/mpage.h>
2305 #include <linux/fiemap.h>
2306 #include <linux/namei.h>
2307 +#include <linux/vs_tag.h>
2311 @@ -1167,7 +1168,7 @@ static void ext2_truncate_blocks(struct
2313 if (ext2_inode_is_fast_symlink(inode))
2315 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2316 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2318 __ext2_truncate_blocks(inode, offset);
2320 @@ -1258,36 +1259,61 @@ void ext2_set_inode_flags(struct inode *
2322 unsigned int flags = EXT2_I(inode)->i_flags;
2324 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2325 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2326 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2329 + if (flags & EXT2_IMMUTABLE_FL)
2330 + inode->i_flags |= S_IMMUTABLE;
2331 + if (flags & EXT2_IXUNLINK_FL)
2332 + inode->i_flags |= S_IXUNLINK;
2334 if (flags & EXT2_SYNC_FL)
2335 inode->i_flags |= S_SYNC;
2336 if (flags & EXT2_APPEND_FL)
2337 inode->i_flags |= S_APPEND;
2338 - if (flags & EXT2_IMMUTABLE_FL)
2339 - inode->i_flags |= S_IMMUTABLE;
2340 if (flags & EXT2_NOATIME_FL)
2341 inode->i_flags |= S_NOATIME;
2342 if (flags & EXT2_DIRSYNC_FL)
2343 inode->i_flags |= S_DIRSYNC;
2345 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2347 + if (flags & EXT2_BARRIER_FL)
2348 + inode->i_vflags |= V_BARRIER;
2349 + if (flags & EXT2_COW_FL)
2350 + inode->i_vflags |= V_COW;
2353 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2354 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2356 unsigned int flags = ei->vfs_inode.i_flags;
2357 + unsigned int vflags = ei->vfs_inode.i_vflags;
2359 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2360 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2361 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2362 + EXT2_BARRIER_FL | EXT2_COW_FL);
2364 + if (flags & S_IMMUTABLE)
2365 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2366 + if (flags & S_IXUNLINK)
2367 + ei->i_flags |= EXT2_IXUNLINK_FL;
2369 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2370 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2372 ei->i_flags |= EXT2_SYNC_FL;
2373 if (flags & S_APPEND)
2374 ei->i_flags |= EXT2_APPEND_FL;
2375 - if (flags & S_IMMUTABLE)
2376 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2377 if (flags & S_NOATIME)
2378 ei->i_flags |= EXT2_NOATIME_FL;
2379 if (flags & S_DIRSYNC)
2380 ei->i_flags |= EXT2_DIRSYNC_FL;
2382 + if (vflags & V_BARRIER)
2383 + ei->i_flags |= EXT2_BARRIER_FL;
2384 + if (vflags & V_COW)
2385 + ei->i_flags |= EXT2_COW_FL;
2388 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2389 @@ -1297,6 +1323,8 @@ struct inode *ext2_iget (struct super_bl
2390 struct ext2_inode *raw_inode;
2391 struct inode *inode;
2397 inode = iget_locked(sb, ino);
2398 @@ -1315,12 +1343,16 @@ struct inode *ext2_iget (struct super_bl
2401 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2402 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2403 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2404 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2405 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2406 if (!(test_opt (inode->i_sb, NO_UID32))) {
2407 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2408 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2409 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2410 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2412 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2413 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2414 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2415 + le16_to_cpu(raw_inode->i_raw_tag));
2416 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2417 inode->i_size = le32_to_cpu(raw_inode->i_size);
2418 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2419 @@ -1418,8 +1450,8 @@ static int __ext2_write_inode(struct ino
2420 struct ext2_inode_info *ei = EXT2_I(inode);
2421 struct super_block *sb = inode->i_sb;
2422 ino_t ino = inode->i_ino;
2423 - uid_t uid = inode->i_uid;
2424 - gid_t gid = inode->i_gid;
2425 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2426 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2427 struct buffer_head * bh;
2428 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2430 @@ -1455,6 +1487,9 @@ static int __ext2_write_inode(struct ino
2431 raw_inode->i_uid_high = 0;
2432 raw_inode->i_gid_high = 0;
2434 +#ifdef CONFIG_TAGGING_INTERN
2435 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2437 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2438 raw_inode->i_size = cpu_to_le32(inode->i_size);
2439 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2440 @@ -1535,7 +1570,8 @@ int ext2_setattr(struct dentry *dentry,
2441 if (is_quota_modification(inode, iattr))
2442 dquot_initialize(inode);
2443 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2444 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2445 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2446 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2447 error = dquot_transfer(inode, iattr);
2450 diff -NurpP --minimal linux-3.2.5/fs/ext2/ioctl.c linux-3.2.5-vs2.3.2.6/fs/ext2/ioctl.c
2451 --- linux-3.2.5/fs/ext2/ioctl.c 2011-05-22 16:17:51.000000000 +0200
2452 +++ linux-3.2.5-vs2.3.2.6/fs/ext2/ioctl.c 2011-12-05 19:33:02.000000000 +0100
2454 #include <asm/uaccess.h>
2457 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2459 + inode->i_flags = flags;
2460 + inode->i_vflags = vflags;
2461 + ext2_get_inode_flags(EXT2_I(inode));
2462 + inode->i_ctime = CURRENT_TIME_SEC;
2463 + mark_inode_dirty(inode);
2467 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2469 struct inode *inode = filp->f_dentry->d_inode;
2470 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2472 flags = ext2_mask_flags(inode->i_mode, flags);
2474 + if (IS_BARRIER(inode)) {
2475 + vxwprintk_task(1, "messing with the barrier.");
2479 mutex_lock(&inode->i_mutex);
2480 /* Is it quota file? Do not allow user to mess with it */
2481 if (IS_NOQUOTA(inode)) {
2482 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2484 * This test looks nicer. Thanks to Pauline Middelink
2486 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2487 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2488 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2489 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2490 if (!capable(CAP_LINUX_IMMUTABLE)) {
2491 mutex_unlock(&inode->i_mutex);
2493 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2497 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2498 + flags &= EXT2_FL_USER_MODIFIABLE;
2499 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2500 ei->i_flags = flags;
2501 mutex_unlock(&inode->i_mutex);
2502 diff -NurpP --minimal linux-3.2.5/fs/ext2/namei.c linux-3.2.5-vs2.3.2.6/fs/ext2/namei.c
2503 --- linux-3.2.5/fs/ext2/namei.c 2011-10-24 18:45:27.000000000 +0200
2504 +++ linux-3.2.5-vs2.3.2.6/fs/ext2/namei.c 2011-12-05 19:33:02.000000000 +0100
2507 #include <linux/pagemap.h>
2508 #include <linux/quotaops.h>
2509 +#include <linux/vs_tag.h>
2513 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
2514 (unsigned long) ino);
2515 return ERR_PTR(-EIO);
2517 + dx_propagate_tag(nd, inode);
2519 return d_splice_alias(inode, dentry);
2521 @@ -408,6 +410,7 @@ const struct inode_operations ext2_dir_i
2522 .removexattr = generic_removexattr,
2524 .setattr = ext2_setattr,
2525 + .sync_flags = ext2_sync_flags,
2526 .get_acl = ext2_get_acl,
2529 diff -NurpP --minimal linux-3.2.5/fs/ext2/super.c linux-3.2.5-vs2.3.2.6/fs/ext2/super.c
2530 --- linux-3.2.5/fs/ext2/super.c 2012-01-09 16:14:54.000000000 +0100
2531 +++ linux-3.2.5-vs2.3.2.6/fs/ext2/super.c 2011-12-05 19:33:02.000000000 +0100
2532 @@ -394,7 +394,8 @@ enum {
2533 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2534 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2535 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2536 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2537 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2538 + Opt_tag, Opt_notag, Opt_tagid
2541 static const match_table_t tokens = {
2542 @@ -422,6 +423,9 @@ static const match_table_t tokens = {
2544 {Opt_noacl, "noacl"},
2547 + {Opt_notag, "notag"},
2548 + {Opt_tagid, "tagid=%u"},
2549 {Opt_grpquota, "grpquota"},
2550 {Opt_ignore, "noquota"},
2551 {Opt_quota, "quota"},
2552 @@ -492,6 +496,20 @@ static int parse_options(char *options,
2554 set_opt (sbi->s_mount_opt, NO_UID32);
2556 +#ifndef CONFIG_TAGGING_NONE
2558 + set_opt (sbi->s_mount_opt, TAGGED);
2561 + clear_opt (sbi->s_mount_opt, TAGGED);
2564 +#ifdef CONFIG_PROPAGATE
2567 + set_opt (sbi->s_mount_opt, TAGGED);
2571 clear_opt (sbi->s_mount_opt, CHECK);
2573 @@ -850,6 +868,8 @@ static int ext2_fill_super(struct super_
2574 if (!parse_options((char *) data, sb))
2577 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2578 + sb->s_flags |= MS_TAGGED;
2579 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2580 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2582 @@ -1224,6 +1244,14 @@ static int ext2_remount (struct super_bl
2586 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2587 + !(sb->s_flags & MS_TAGGED)) {
2588 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2591 + goto restore_opts;
2594 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2595 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2597 diff -NurpP --minimal linux-3.2.5/fs/ext3/file.c linux-3.2.5-vs2.3.2.6/fs/ext3/file.c
2598 --- linux-3.2.5/fs/ext3/file.c 2011-10-24 18:45:27.000000000 +0200
2599 +++ linux-3.2.5-vs2.3.2.6/fs/ext3/file.c 2011-12-05 19:33:02.000000000 +0100
2600 @@ -80,5 +80,6 @@ const struct inode_operations ext3_file_
2602 .get_acl = ext3_get_acl,
2603 .fiemap = ext3_fiemap,
2604 + .sync_flags = ext3_sync_flags,
2607 diff -NurpP --minimal linux-3.2.5/fs/ext3/ialloc.c linux-3.2.5-vs2.3.2.6/fs/ext3/ialloc.c
2608 --- linux-3.2.5/fs/ext3/ialloc.c 2012-01-09 16:14:54.000000000 +0100
2609 +++ linux-3.2.5-vs2.3.2.6/fs/ext3/ialloc.c 2011-12-05 19:33:02.000000000 +0100
2611 #include <linux/buffer_head.h>
2612 #include <linux/random.h>
2613 #include <linux/bitops.h>
2614 +#include <linux/vs_tag.h>
2615 #include <trace/events/ext3.h>
2617 #include <asm/byteorder.h>
2618 @@ -496,6 +497,7 @@ got:
2619 inode->i_mode = mode;
2620 inode->i_uid = current_fsuid();
2621 inode->i_gid = dir->i_gid;
2622 + inode->i_tag = dx_current_fstag(sb);
2624 inode_init_owner(inode, dir, mode);
2626 diff -NurpP --minimal linux-3.2.5/fs/ext3/inode.c linux-3.2.5-vs2.3.2.6/fs/ext3/inode.c
2627 --- linux-3.2.5/fs/ext3/inode.c 2012-02-07 01:57:54.000000000 +0100
2628 +++ linux-3.2.5-vs2.3.2.6/fs/ext3/inode.c 2012-01-18 02:58:07.000000000 +0100
2630 #include <linux/bio.h>
2631 #include <linux/fiemap.h>
2632 #include <linux/namei.h>
2633 +#include <linux/vs_tag.h>
2634 #include <trace/events/ext3.h>
2637 @@ -2852,36 +2853,60 @@ void ext3_set_inode_flags(struct inode *
2639 unsigned int flags = EXT3_I(inode)->i_flags;
2641 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2642 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2643 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2645 + if (flags & EXT3_IMMUTABLE_FL)
2646 + inode->i_flags |= S_IMMUTABLE;
2647 + if (flags & EXT3_IXUNLINK_FL)
2648 + inode->i_flags |= S_IXUNLINK;
2650 if (flags & EXT3_SYNC_FL)
2651 inode->i_flags |= S_SYNC;
2652 if (flags & EXT3_APPEND_FL)
2653 inode->i_flags |= S_APPEND;
2654 - if (flags & EXT3_IMMUTABLE_FL)
2655 - inode->i_flags |= S_IMMUTABLE;
2656 if (flags & EXT3_NOATIME_FL)
2657 inode->i_flags |= S_NOATIME;
2658 if (flags & EXT3_DIRSYNC_FL)
2659 inode->i_flags |= S_DIRSYNC;
2661 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2663 + if (flags & EXT3_BARRIER_FL)
2664 + inode->i_vflags |= V_BARRIER;
2665 + if (flags & EXT3_COW_FL)
2666 + inode->i_vflags |= V_COW;
2669 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2670 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2672 unsigned int flags = ei->vfs_inode.i_flags;
2673 + unsigned int vflags = ei->vfs_inode.i_vflags;
2675 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2676 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2677 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2678 + EXT3_BARRIER_FL | EXT3_COW_FL);
2680 + if (flags & S_IMMUTABLE)
2681 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2682 + if (flags & S_IXUNLINK)
2683 + ei->i_flags |= EXT3_IXUNLINK_FL;
2685 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2686 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2688 ei->i_flags |= EXT3_SYNC_FL;
2689 if (flags & S_APPEND)
2690 ei->i_flags |= EXT3_APPEND_FL;
2691 - if (flags & S_IMMUTABLE)
2692 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2693 if (flags & S_NOATIME)
2694 ei->i_flags |= EXT3_NOATIME_FL;
2695 if (flags & S_DIRSYNC)
2696 ei->i_flags |= EXT3_DIRSYNC_FL;
2698 + if (vflags & V_BARRIER)
2699 + ei->i_flags |= EXT3_BARRIER_FL;
2700 + if (vflags & V_COW)
2701 + ei->i_flags |= EXT3_COW_FL;
2704 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2705 @@ -2895,6 +2920,8 @@ struct inode *ext3_iget(struct super_blo
2706 transaction_t *transaction;
2712 inode = iget_locked(sb, ino);
2714 @@ -2911,12 +2938,16 @@ struct inode *ext3_iget(struct super_blo
2716 raw_inode = ext3_raw_inode(&iloc);
2717 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2718 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2719 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2720 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2721 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2722 if(!(test_opt (inode->i_sb, NO_UID32))) {
2723 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2724 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2725 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2726 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2728 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2729 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2730 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2731 + le16_to_cpu(raw_inode->i_raw_tag));
2732 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2733 inode->i_size = le32_to_cpu(raw_inode->i_size);
2734 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2735 @@ -3071,6 +3102,8 @@ static int ext3_do_update_inode(handle_t
2736 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
2737 struct ext3_inode_info *ei = EXT3_I(inode);
2738 struct buffer_head *bh = iloc->bh;
2739 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2740 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2741 int err = 0, rc, block;
2744 @@ -3085,29 +3118,32 @@ again:
2745 ext3_get_inode_flags(ei);
2746 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2747 if(!(test_opt(inode->i_sb, NO_UID32))) {
2748 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
2749 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
2750 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
2751 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
2753 * Fix up interoperability with old kernels. Otherwise, old inodes get
2754 * re-used with the upper 16 bits of the uid/gid intact
2757 raw_inode->i_uid_high =
2758 - cpu_to_le16(high_16_bits(inode->i_uid));
2759 + cpu_to_le16(high_16_bits(uid));
2760 raw_inode->i_gid_high =
2761 - cpu_to_le16(high_16_bits(inode->i_gid));
2762 + cpu_to_le16(high_16_bits(gid));
2764 raw_inode->i_uid_high = 0;
2765 raw_inode->i_gid_high = 0;
2768 raw_inode->i_uid_low =
2769 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
2770 + cpu_to_le16(fs_high2lowuid(uid));
2771 raw_inode->i_gid_low =
2772 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
2773 + cpu_to_le16(fs_high2lowgid(gid));
2774 raw_inode->i_uid_high = 0;
2775 raw_inode->i_gid_high = 0;
2777 +#ifdef CONFIG_TAGGING_INTERN
2778 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2780 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2781 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
2782 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2783 @@ -3267,7 +3303,8 @@ int ext3_setattr(struct dentry *dentry,
2784 if (is_quota_modification(inode, attr))
2785 dquot_initialize(inode);
2786 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2787 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
2788 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2789 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
2792 /* (user+group)*(old+new) structure, inode write (sb,
2793 @@ -3289,6 +3326,8 @@ int ext3_setattr(struct dentry *dentry,
2794 inode->i_uid = attr->ia_uid;
2795 if (attr->ia_valid & ATTR_GID)
2796 inode->i_gid = attr->ia_gid;
2797 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2798 + inode->i_tag = attr->ia_tag;
2799 error = ext3_mark_inode_dirty(handle, inode);
2800 ext3_journal_stop(handle);
2802 diff -NurpP --minimal linux-3.2.5/fs/ext3/ioctl.c linux-3.2.5-vs2.3.2.6/fs/ext3/ioctl.c
2803 --- linux-3.2.5/fs/ext3/ioctl.c 2012-01-09 16:14:54.000000000 +0100
2804 +++ linux-3.2.5-vs2.3.2.6/fs/ext3/ioctl.c 2011-12-05 19:33:02.000000000 +0100
2808 #include <linux/fs.h>
2809 +#include <linux/mount.h>
2810 #include <linux/jbd.h>
2811 #include <linux/capability.h>
2812 #include <linux/ext3_fs.h>
2814 #include <linux/compat.h>
2815 #include <asm/uaccess.h>
2818 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2820 + handle_t *handle = NULL;
2821 + struct ext3_iloc iloc;
2824 + handle = ext3_journal_start(inode, 1);
2825 + if (IS_ERR(handle))
2826 + return PTR_ERR(handle);
2828 + if (IS_SYNC(inode))
2829 + handle->h_sync = 1;
2830 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2834 + inode->i_flags = flags;
2835 + inode->i_vflags = vflags;
2836 + ext3_get_inode_flags(EXT3_I(inode));
2837 + inode->i_ctime = CURRENT_TIME_SEC;
2839 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2841 + ext3_journal_stop(handle);
2845 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2847 struct inode *inode = filp->f_dentry->d_inode;
2848 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
2850 flags = ext3_mask_flags(inode->i_mode, flags);
2852 + if (IS_BARRIER(inode)) {
2853 + vxwprintk_task(1, "messing with the barrier.");
2857 mutex_lock(&inode->i_mutex);
2859 /* Is it quota file? Do not allow user to mess with it */
2860 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
2862 * This test looks nicer. Thanks to Pauline Middelink
2864 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2865 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2866 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2867 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2868 if (!capable(CAP_LINUX_IMMUTABLE))
2871 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
2875 - flags = flags & EXT3_FL_USER_MODIFIABLE;
2876 + flags &= EXT3_FL_USER_MODIFIABLE;
2877 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
2878 ei->i_flags = flags;
2880 diff -NurpP --minimal linux-3.2.5/fs/ext3/namei.c linux-3.2.5-vs2.3.2.6/fs/ext3/namei.c
2881 --- linux-3.2.5/fs/ext3/namei.c 2012-01-09 16:14:54.000000000 +0100
2882 +++ linux-3.2.5-vs2.3.2.6/fs/ext3/namei.c 2011-12-05 19:33:02.000000000 +0100
2884 #include <linux/quotaops.h>
2885 #include <linux/buffer_head.h>
2886 #include <linux/bio.h>
2887 +#include <linux/vs_tag.h>
2888 #include <trace/events/ext3.h>
2891 @@ -925,6 +926,7 @@ restart:
2892 ll_rw_block(READ | REQ_META | REQ_PRIO,
2895 + dx_propagate_tag(nd, inode);
2897 if ((bh = bh_use[ra_ptr++]) == NULL)
2899 @@ -2535,6 +2537,7 @@ const struct inode_operations ext3_dir_i
2900 .listxattr = ext3_listxattr,
2901 .removexattr = generic_removexattr,
2903 + .sync_flags = ext3_sync_flags,
2904 .get_acl = ext3_get_acl,
2907 diff -NurpP --minimal linux-3.2.5/fs/ext3/super.c linux-3.2.5-vs2.3.2.6/fs/ext3/super.c
2908 --- linux-3.2.5/fs/ext3/super.c 2012-01-09 16:14:54.000000000 +0100
2909 +++ linux-3.2.5-vs2.3.2.6/fs/ext3/super.c 2011-12-05 19:33:02.000000000 +0100
2910 @@ -831,7 +831,8 @@ enum {
2911 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2912 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
2913 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
2914 - Opt_resize, Opt_usrquota, Opt_grpquota
2915 + Opt_resize, Opt_usrquota, Opt_grpquota,
2916 + Opt_tag, Opt_notag, Opt_tagid
2919 static const match_table_t tokens = {
2920 @@ -888,6 +889,9 @@ static const match_table_t tokens = {
2921 {Opt_barrier, "barrier"},
2922 {Opt_nobarrier, "nobarrier"},
2923 {Opt_resize, "resize"},
2925 + {Opt_notag, "notag"},
2926 + {Opt_tagid, "tagid=%u"},
2930 @@ -1040,6 +1044,20 @@ static int parse_options (char *options,
2932 set_opt (sbi->s_mount_opt, NO_UID32);
2934 +#ifndef CONFIG_TAGGING_NONE
2936 + set_opt (sbi->s_mount_opt, TAGGED);
2939 + clear_opt (sbi->s_mount_opt, TAGGED);
2942 +#ifdef CONFIG_PROPAGATE
2945 + set_opt (sbi->s_mount_opt, TAGGED);
2949 clear_opt (sbi->s_mount_opt, CHECK);
2951 @@ -1738,6 +1756,9 @@ static int ext3_fill_super (struct super
2955 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
2956 + sb->s_flags |= MS_TAGGED;
2958 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2959 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2961 @@ -2619,6 +2640,14 @@ static int ext3_remount (struct super_bl
2962 if (test_opt(sb, ABORT))
2963 ext3_abort(sb, __func__, "Abort forced by user");
2965 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
2966 + !(sb->s_flags & MS_TAGGED)) {
2967 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
2970 + goto restore_opts;
2973 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2974 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2976 diff -NurpP --minimal linux-3.2.5/fs/ext4/ext4.h linux-3.2.5-vs2.3.2.6/fs/ext4/ext4.h
2977 --- linux-3.2.5/fs/ext4/ext4.h 2012-01-09 16:14:54.000000000 +0100
2978 +++ linux-3.2.5-vs2.3.2.6/fs/ext4/ext4.h 2011-12-05 19:33:02.000000000 +0100
2979 @@ -371,8 +371,12 @@ struct flex_groups {
2980 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
2981 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
2982 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
2983 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2984 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
2986 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2987 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
2989 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
2990 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
2992 @@ -632,7 +636,8 @@ struct ext4_inode {
2993 __le16 l_i_file_acl_high;
2994 __le16 l_i_uid_high; /* these 2 fields */
2995 __le16 l_i_gid_high; /* were reserved2[0] */
2996 - __u32 l_i_reserved2;
2997 + __le16 l_i_tag; /* Context Tag */
2998 + __u16 l_i_reserved2;
3001 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3002 @@ -750,6 +755,7 @@ do { \
3003 #define i_gid_low i_gid
3004 #define i_uid_high osd2.linux2.l_i_uid_high
3005 #define i_gid_high osd2.linux2.l_i_gid_high
3006 +#define i_raw_tag osd2.linux2.l_i_tag
3007 #define i_reserved2 osd2.linux2.l_i_reserved2
3009 #elif defined(__GNU__)
3010 @@ -926,6 +932,7 @@ struct ext4_inode_info {
3011 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3012 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3013 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3014 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3015 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3016 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3017 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3018 @@ -2270,6 +2277,7 @@ extern int ext4_map_blocks(handle_t *han
3019 struct ext4_map_blocks *map, int flags);
3020 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3021 __u64 start, __u64 len);
3022 +extern int ext4_sync_flags(struct inode *, int, int);
3024 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3025 __u64 start_orig, __u64 start_donor,
3026 diff -NurpP --minimal linux-3.2.5/fs/ext4/file.c linux-3.2.5-vs2.3.2.6/fs/ext4/file.c
3027 --- linux-3.2.5/fs/ext4/file.c 2012-01-09 16:14:54.000000000 +0100
3028 +++ linux-3.2.5-vs2.3.2.6/fs/ext4/file.c 2011-12-05 19:33:02.000000000 +0100
3029 @@ -258,5 +258,6 @@ const struct inode_operations ext4_file_
3031 .get_acl = ext4_get_acl,
3032 .fiemap = ext4_fiemap,
3033 + .sync_flags = ext4_sync_flags,
3036 diff -NurpP --minimal linux-3.2.5/fs/ext4/ialloc.c linux-3.2.5-vs2.3.2.6/fs/ext4/ialloc.c
3037 --- linux-3.2.5/fs/ext4/ialloc.c 2012-01-09 16:14:54.000000000 +0100
3038 +++ linux-3.2.5-vs2.3.2.6/fs/ext4/ialloc.c 2011-12-05 19:33:02.000000000 +0100
3040 #include <linux/random.h>
3041 #include <linux/bitops.h>
3042 #include <linux/blkdev.h>
3043 +#include <linux/vs_tag.h>
3044 #include <asm/byteorder.h>
3047 @@ -860,6 +861,7 @@ got:
3048 inode->i_mode = mode;
3049 inode->i_uid = current_fsuid();
3050 inode->i_gid = dir->i_gid;
3051 + inode->i_tag = dx_current_fstag(sb);
3053 inode_init_owner(inode, dir, mode);
3055 diff -NurpP --minimal linux-3.2.5/fs/ext4/inode.c linux-3.2.5-vs2.3.2.6/fs/ext4/inode.c
3056 --- linux-3.2.5/fs/ext4/inode.c 2012-01-09 16:14:54.000000000 +0100
3057 +++ linux-3.2.5-vs2.3.2.6/fs/ext4/inode.c 2012-01-09 16:19:31.000000000 +0100
3059 #include <linux/printk.h>
3060 #include <linux/slab.h>
3061 #include <linux/ratelimit.h>
3062 +#include <linux/vs_tag.h>
3064 #include "ext4_jbd2.h"
3066 @@ -3667,41 +3668,64 @@ void ext4_set_inode_flags(struct inode *
3068 unsigned int flags = EXT4_I(inode)->i_flags;
3070 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3071 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3072 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3074 + if (flags & EXT4_IMMUTABLE_FL)
3075 + inode->i_flags |= S_IMMUTABLE;
3076 + if (flags & EXT4_IXUNLINK_FL)
3077 + inode->i_flags |= S_IXUNLINK;
3079 if (flags & EXT4_SYNC_FL)
3080 inode->i_flags |= S_SYNC;
3081 if (flags & EXT4_APPEND_FL)
3082 inode->i_flags |= S_APPEND;
3083 - if (flags & EXT4_IMMUTABLE_FL)
3084 - inode->i_flags |= S_IMMUTABLE;
3085 if (flags & EXT4_NOATIME_FL)
3086 inode->i_flags |= S_NOATIME;
3087 if (flags & EXT4_DIRSYNC_FL)
3088 inode->i_flags |= S_DIRSYNC;
3090 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3092 + if (flags & EXT4_BARRIER_FL)
3093 + inode->i_vflags |= V_BARRIER;
3094 + if (flags & EXT4_COW_FL)
3095 + inode->i_vflags |= V_COW;
3098 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3099 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3101 - unsigned int vfs_fl;
3102 + unsigned int vfs_fl, vfs_vf;
3103 unsigned long old_fl, new_fl;
3106 vfs_fl = ei->vfs_inode.i_flags;
3107 + vfs_vf = ei->vfs_inode.i_vflags;
3108 old_fl = ei->i_flags;
3109 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3110 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3112 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3115 + if (vfs_fl & S_IMMUTABLE)
3116 + new_fl |= EXT4_IMMUTABLE_FL;
3117 + if (vfs_fl & S_IXUNLINK)
3118 + new_fl |= EXT4_IXUNLINK_FL;
3120 if (vfs_fl & S_SYNC)
3121 new_fl |= EXT4_SYNC_FL;
3122 if (vfs_fl & S_APPEND)
3123 new_fl |= EXT4_APPEND_FL;
3124 - if (vfs_fl & S_IMMUTABLE)
3125 - new_fl |= EXT4_IMMUTABLE_FL;
3126 if (vfs_fl & S_NOATIME)
3127 new_fl |= EXT4_NOATIME_FL;
3128 if (vfs_fl & S_DIRSYNC)
3129 new_fl |= EXT4_DIRSYNC_FL;
3131 + if (vfs_vf & V_BARRIER)
3132 + new_fl |= EXT4_BARRIER_FL;
3133 + if (vfs_vf & V_COW)
3134 + new_fl |= EXT4_COW_FL;
3135 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3138 @@ -3737,6 +3761,8 @@ struct inode *ext4_iget(struct super_blo
3139 journal_t *journal = EXT4_SB(sb)->s_journal;
3145 inode = iget_locked(sb, ino);
3147 @@ -3752,12 +3778,16 @@ struct inode *ext4_iget(struct super_blo
3149 raw_inode = ext4_raw_inode(&iloc);
3150 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3151 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3152 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3153 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3154 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3155 if (!(test_opt(inode->i_sb, NO_UID32))) {
3156 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3157 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3158 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3159 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3161 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3162 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3163 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3164 + le16_to_cpu(raw_inode->i_raw_tag));
3165 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
3167 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3168 @@ -3976,6 +4006,8 @@ static int ext4_do_update_inode(handle_t
3169 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3170 struct ext4_inode_info *ei = EXT4_I(inode);
3171 struct buffer_head *bh = iloc->bh;
3172 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3173 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3174 int err = 0, rc, block;
3176 /* For fields not not tracking in the in-memory inode,
3177 @@ -3986,29 +4018,32 @@ static int ext4_do_update_inode(handle_t
3178 ext4_get_inode_flags(ei);
3179 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3180 if (!(test_opt(inode->i_sb, NO_UID32))) {
3181 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3182 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3183 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3184 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3186 * Fix up interoperability with old kernels. Otherwise, old inodes get
3187 * re-used with the upper 16 bits of the uid/gid intact
3190 raw_inode->i_uid_high =
3191 - cpu_to_le16(high_16_bits(inode->i_uid));
3192 + cpu_to_le16(high_16_bits(uid));
3193 raw_inode->i_gid_high =
3194 - cpu_to_le16(high_16_bits(inode->i_gid));
3195 + cpu_to_le16(high_16_bits(gid));
3197 raw_inode->i_uid_high = 0;
3198 raw_inode->i_gid_high = 0;
3201 raw_inode->i_uid_low =
3202 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3203 + cpu_to_le16(fs_high2lowuid(uid));
3204 raw_inode->i_gid_low =
3205 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3206 + cpu_to_le16(fs_high2lowgid(gid));
3207 raw_inode->i_uid_high = 0;
3208 raw_inode->i_gid_high = 0;
3210 +#ifdef CONFIG_TAGGING_INTERN
3211 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3213 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3215 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3216 @@ -4194,7 +4229,8 @@ int ext4_setattr(struct dentry *dentry,
3217 if (is_quota_modification(inode, attr))
3218 dquot_initialize(inode);
3219 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3220 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3221 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3222 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3225 /* (user+group)*(old+new) structure, inode write (sb,
3226 @@ -4216,6 +4252,8 @@ int ext4_setattr(struct dentry *dentry,
3227 inode->i_uid = attr->ia_uid;
3228 if (attr->ia_valid & ATTR_GID)
3229 inode->i_gid = attr->ia_gid;
3230 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3231 + inode->i_tag = attr->ia_tag;
3232 error = ext4_mark_inode_dirty(handle, inode);
3233 ext4_journal_stop(handle);
3235 diff -NurpP --minimal linux-3.2.5/fs/ext4/ioctl.c linux-3.2.5-vs2.3.2.6/fs/ext4/ioctl.c
3236 --- linux-3.2.5/fs/ext4/ioctl.c 2012-02-07 01:57:54.000000000 +0100
3237 +++ linux-3.2.5-vs2.3.2.6/fs/ext4/ioctl.c 2012-01-26 08:52:10.000000000 +0100
3239 #include <linux/compat.h>
3240 #include <linux/mount.h>
3241 #include <linux/file.h>
3242 +#include <linux/vs_tag.h>
3243 #include <asm/uaccess.h>
3244 #include "ext4_jbd2.h"
3248 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3250 + handle_t *handle = NULL;
3251 + struct ext4_iloc iloc;
3254 + handle = ext4_journal_start(inode, 1);
3255 + if (IS_ERR(handle))
3256 + return PTR_ERR(handle);
3258 + if (IS_SYNC(inode))
3259 + ext4_handle_sync(handle);
3260 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3264 + inode->i_flags = flags;
3265 + inode->i_vflags = vflags;
3266 + ext4_get_inode_flags(EXT4_I(inode));
3267 + inode->i_ctime = ext4_current_time(inode);
3269 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3271 + ext4_journal_stop(handle);
3275 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3277 struct inode *inode = filp->f_dentry->d_inode;
3278 @@ -51,6 +80,11 @@ long ext4_ioctl(struct file *filp, unsig
3280 flags = ext4_mask_flags(inode->i_mode, flags);
3282 + if (IS_BARRIER(inode)) {
3283 + vxwprintk_task(1, "messing with the barrier.");
3288 mutex_lock(&inode->i_mutex);
3289 /* Is it quota file? Do not allow user to mess with it */
3290 @@ -68,7 +102,9 @@ long ext4_ioctl(struct file *filp, unsig
3292 * This test looks nicer. Thanks to Pauline Middelink
3294 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3295 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3296 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3297 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3298 if (!capable(CAP_LINUX_IMMUTABLE))
3301 diff -NurpP --minimal linux-3.2.5/fs/ext4/namei.c linux-3.2.5-vs2.3.2.6/fs/ext4/namei.c
3302 --- linux-3.2.5/fs/ext4/namei.c 2012-01-09 16:14:54.000000000 +0100
3303 +++ linux-3.2.5-vs2.3.2.6/fs/ext4/namei.c 2011-12-05 19:33:02.000000000 +0100
3305 #include <linux/quotaops.h>
3306 #include <linux/buffer_head.h>
3307 #include <linux/bio.h>
3308 +#include <linux/vs_tag.h>
3310 #include "ext4_jbd2.h"
3312 @@ -925,6 +926,7 @@ restart:
3313 ll_rw_block(READ | REQ_META | REQ_PRIO,
3316 + dx_propagate_tag(nd, inode);
3318 if ((bh = bh_use[ra_ptr++]) == NULL)
3320 @@ -2587,6 +2589,7 @@ const struct inode_operations ext4_dir_i
3322 .get_acl = ext4_get_acl,
3323 .fiemap = ext4_fiemap,
3324 + .sync_flags = ext4_sync_flags,
3327 const struct inode_operations ext4_special_inode_operations = {
3328 diff -NurpP --minimal linux-3.2.5/fs/ext4/super.c linux-3.2.5-vs2.3.2.6/fs/ext4/super.c
3329 --- linux-3.2.5/fs/ext4/super.c 2012-02-07 01:57:54.000000000 +0100
3330 +++ linux-3.2.5-vs2.3.2.6/fs/ext4/super.c 2012-01-26 08:52:10.000000000 +0100
3331 @@ -1334,6 +1334,7 @@ enum {
3332 Opt_inode_readahead_blks, Opt_journal_ioprio,
3333 Opt_dioread_nolock, Opt_dioread_lock,
3334 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
3335 + Opt_tag, Opt_notag, Opt_tagid
3338 static const match_table_t tokens = {
3339 @@ -1409,6 +1410,9 @@ static const match_table_t tokens = {
3340 {Opt_init_itable, "init_itable=%u"},
3341 {Opt_init_itable, "init_itable"},
3342 {Opt_noinit_itable, "noinit_itable"},
3344 + {Opt_notag, "notag"},
3345 + {Opt_tagid, "tagid=%u"},
3349 @@ -1577,6 +1581,20 @@ static int parse_options(char *options,
3351 set_opt(sb, NO_UID32);
3353 +#ifndef CONFIG_TAGGING_NONE
3355 + set_opt(sb, TAGGED);
3358 + clear_opt(sb, TAGGED);
3361 +#ifdef CONFIG_PROPAGATE
3364 + set_opt(sb, TAGGED);
3370 @@ -3278,6 +3296,9 @@ static int ext4_fill_super(struct super_
3374 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3375 + sb->s_flags |= MS_TAGGED;
3377 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3378 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3380 @@ -4427,6 +4448,14 @@ static int ext4_remount(struct super_blo
3381 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3382 ext4_abort(sb, "Abort forced by user");
3384 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3385 + !(sb->s_flags & MS_TAGGED)) {
3386 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3389 + goto restore_opts;
3392 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3393 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3395 diff -NurpP --minimal linux-3.2.5/fs/fcntl.c linux-3.2.5-vs2.3.2.6/fs/fcntl.c
3396 --- linux-3.2.5/fs/fcntl.c 2011-05-22 16:17:52.000000000 +0200
3397 +++ linux-3.2.5-vs2.3.2.6/fs/fcntl.c 2011-12-05 19:33:02.000000000 +0100
3399 #include <linux/signal.h>
3400 #include <linux/rcupdate.h>
3401 #include <linux/pid_namespace.h>
3402 +#include <linux/vs_limit.h>
3404 #include <asm/poll.h>
3405 #include <asm/siginfo.h>
3406 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3409 filp_close(tofree, files);
3411 + vx_openfd_inc(newfd); /* fd was unused */
3415 @@ -447,6 +450,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3416 filp = fget_raw(fd);
3419 + if (!vx_files_avail(1))
3422 if (unlikely(filp->f_mode & FMODE_PATH)) {
3423 if (!check_fcntl_cmd(cmd)) {
3424 diff -NurpP --minimal linux-3.2.5/fs/file.c linux-3.2.5-vs2.3.2.6/fs/file.c
3425 --- linux-3.2.5/fs/file.c 2011-05-22 16:17:52.000000000 +0200
3426 +++ linux-3.2.5-vs2.3.2.6/fs/file.c 2011-12-05 19:33:02.000000000 +0100
3428 #include <linux/spinlock.h>
3429 #include <linux/rcupdate.h>
3430 #include <linux/workqueue.h>
3431 +#include <linux/vs_limit.h>
3433 struct fdtable_defer {
3435 @@ -359,6 +360,8 @@ struct files_struct *dup_fd(struct files
3436 struct file *f = *old_fds++;
3439 + /* TODO: sum it first for check and performance */
3440 + vx_openfd_inc(open_files - i);
3443 * The fd may be claimed in the fd bitmap but not yet
3444 @@ -466,6 +469,7 @@ repeat:
3446 FD_CLR(fd, fdt->close_on_exec);
3448 + vx_openfd_inc(fd);
3451 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3452 diff -NurpP --minimal linux-3.2.5/fs/file_table.c linux-3.2.5-vs2.3.2.6/fs/file_table.c
3453 --- linux-3.2.5/fs/file_table.c 2011-10-24 18:45:27.000000000 +0200
3454 +++ linux-3.2.5-vs2.3.2.6/fs/file_table.c 2011-12-05 19:33:02.000000000 +0100
3456 #include <linux/percpu_counter.h>
3457 #include <linux/percpu.h>
3458 #include <linux/ima.h>
3459 +#include <linux/vs_limit.h>
3460 +#include <linux/vs_context.h>
3462 #include <linux/atomic.h>
3464 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
3465 spin_lock_init(&f->f_lock);
3466 eventpoll_init_file(f);
3467 /* f->f_version: 0 */
3468 + f->f_xid = vx_current_xid();
3473 @@ -253,6 +257,8 @@ static void __fput(struct file *file)
3475 fops_put(file->f_op);
3476 put_pid(file->f_owner.pid);
3477 + vx_files_dec(file);
3479 file_sb_list_del(file);
3480 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
3481 i_readcount_dec(inode);
3482 @@ -383,6 +389,8 @@ void put_filp(struct file *file)
3484 if (atomic_long_dec_and_test(&file->f_count)) {
3485 security_file_free(file);
3486 + vx_files_dec(file);
3488 file_sb_list_del(file);
3491 diff -NurpP --minimal linux-3.2.5/fs/fs_struct.c linux-3.2.5-vs2.3.2.6/fs/fs_struct.c
3492 --- linux-3.2.5/fs/fs_struct.c 2011-03-15 18:07:31.000000000 +0100
3493 +++ linux-3.2.5-vs2.3.2.6/fs/fs_struct.c 2011-12-05 19:33:02.000000000 +0100
3495 #include <linux/path.h>
3496 #include <linux/slab.h>
3497 #include <linux/fs_struct.h>
3498 +#include <linux/vserver/global.h>
3499 #include "internal.h"
3501 static inline void path_get_longterm(struct path *path)
3502 @@ -96,6 +97,7 @@ void free_fs_struct(struct fs_struct *fs
3504 path_put_longterm(&fs->root);
3505 path_put_longterm(&fs->pwd);
3506 + atomic_dec(&vs_global_fs);
3507 kmem_cache_free(fs_cachep, fs);
3510 @@ -135,6 +137,7 @@ struct fs_struct *copy_fs_struct(struct
3512 path_get_longterm(&fs->pwd);
3513 spin_unlock(&old->lock);
3514 + atomic_inc(&vs_global_fs);
3518 diff -NurpP --minimal linux-3.2.5/fs/gfs2/file.c linux-3.2.5-vs2.3.2.6/fs/gfs2/file.c
3519 --- linux-3.2.5/fs/gfs2/file.c 2012-01-09 16:14:54.000000000 +0100
3520 +++ linux-3.2.5-vs2.3.2.6/fs/gfs2/file.c 2011-12-05 19:33:02.000000000 +0100
3521 @@ -143,6 +143,9 @@ static const u32 fsflags_to_gfs2[32] = {
3522 [7] = GFS2_DIF_NOATIME,
3523 [12] = GFS2_DIF_EXHASH,
3524 [14] = GFS2_DIF_INHERIT_JDATA,
3525 + [27] = GFS2_DIF_IXUNLINK,
3526 + [26] = GFS2_DIF_BARRIER,
3527 + [29] = GFS2_DIF_COW,
3530 static const u32 gfs2_to_fsflags[32] = {
3531 @@ -152,6 +155,9 @@ static const u32 gfs2_to_fsflags[32] = {
3532 [gfs2fl_NoAtime] = FS_NOATIME_FL,
3533 [gfs2fl_ExHash] = FS_INDEX_FL,
3534 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3535 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3536 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3537 + [gfs2fl_Cow] = FS_COW_FL,
3540 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3541 @@ -182,12 +188,18 @@ void gfs2_set_inode_flags(struct inode *
3543 struct gfs2_inode *ip = GFS2_I(inode);
3544 unsigned int flags = inode->i_flags;
3545 + unsigned int vflags = inode->i_vflags;
3547 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3548 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
3550 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
3551 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
3552 inode->i_flags |= S_NOSEC;
3553 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3554 flags |= S_IMMUTABLE;
3555 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3556 + flags |= S_IXUNLINK;
3558 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3560 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3561 @@ -195,6 +207,43 @@ void gfs2_set_inode_flags(struct inode *
3562 if (ip->i_diskflags & GFS2_DIF_SYNC)
3564 inode->i_flags = flags;
3566 + vflags &= ~(V_BARRIER | V_COW);
3568 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3569 + vflags |= V_BARRIER;
3570 + if (ip->i_diskflags & GFS2_DIF_COW)
3572 + inode->i_vflags = vflags;
3575 +void gfs2_get_inode_flags(struct inode *inode)
3577 + struct gfs2_inode *ip = GFS2_I(inode);
3578 + unsigned int flags = inode->i_flags;
3579 + unsigned int vflags = inode->i_vflags;
3581 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3582 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3583 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3584 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3586 + if (flags & S_IMMUTABLE)
3587 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3588 + if (flags & S_IXUNLINK)
3589 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3591 + if (flags & S_APPEND)
3592 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3593 + if (flags & S_NOATIME)
3594 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3595 + if (flags & S_SYNC)
3596 + ip->i_diskflags |= GFS2_DIF_SYNC;
3598 + if (vflags & V_BARRIER)
3599 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3600 + if (vflags & V_COW)
3601 + ip->i_diskflags |= GFS2_DIF_COW;
3604 /* Flags that can be set by user space */
3605 @@ -306,6 +355,37 @@ static int gfs2_set_flags(struct file *f
3606 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3609 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3611 + struct gfs2_inode *ip = GFS2_I(inode);
3612 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3613 + struct buffer_head *bh;
3614 + struct gfs2_holder gh;
3617 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3620 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3623 + error = gfs2_meta_inode_buffer(ip, &bh);
3625 + goto out_trans_end;
3626 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
3627 + inode->i_flags = flags;
3628 + inode->i_vflags = vflags;
3629 + gfs2_get_inode_flags(inode);
3630 + gfs2_dinode_out(ip, bh->b_data);
3632 + gfs2_set_aops(inode);
3634 + gfs2_trans_end(sdp);
3636 + gfs2_glock_dq_uninit(&gh);
3640 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3643 diff -NurpP --minimal linux-3.2.5/fs/gfs2/inode.h linux-3.2.5-vs2.3.2.6/fs/gfs2/inode.h
3644 --- linux-3.2.5/fs/gfs2/inode.h 2012-01-09 16:14:54.000000000 +0100
3645 +++ linux-3.2.5-vs2.3.2.6/fs/gfs2/inode.h 2011-12-05 19:33:02.000000000 +0100
3646 @@ -120,6 +120,7 @@ extern const struct file_operations gfs2
3647 extern const struct file_operations gfs2_dir_fops_nolock;
3649 extern void gfs2_set_inode_flags(struct inode *inode);
3650 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3652 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3653 extern const struct file_operations gfs2_file_fops;
3654 diff -NurpP --minimal linux-3.2.5/fs/inode.c linux-3.2.5-vs2.3.2.6/fs/inode.c
3655 --- linux-3.2.5/fs/inode.c 2012-01-09 16:14:54.000000000 +0100
3656 +++ linux-3.2.5-vs2.3.2.6/fs/inode.c 2011-12-05 19:33:02.000000000 +0100
3658 #include <linux/ima.h>
3659 #include <linux/cred.h>
3660 #include <linux/buffer_head.h> /* for inode_has_buffers */
3661 +#include <linux/vs_tag.h>
3662 #include "internal.h"
3665 @@ -137,6 +138,9 @@ int inode_init_always(struct super_block
3666 struct address_space *const mapping = &inode->i_data;
3670 + /* essential because of inode slab reuse */
3672 inode->i_blkbits = sb->s_blocksize_bits;
3674 atomic_set(&inode->i_count, 1);
3675 @@ -158,6 +162,7 @@ int inode_init_always(struct super_block
3676 inode->i_bdev = NULL;
3677 inode->i_cdev = NULL;
3679 + inode->i_mdev = 0;
3680 inode->dirtied_when = 0;
3682 if (security_inode_alloc(inode))
3683 @@ -399,6 +404,8 @@ void __insert_inode_hash(struct inode *i
3685 EXPORT_SYMBOL(__insert_inode_hash);
3687 +EXPORT_SYMBOL_GPL(__iget);
3690 * __remove_inode_hash - remove an inode from the hash
3691 * @inode: inode to unhash
3692 @@ -1626,9 +1633,11 @@ void init_special_inode(struct inode *in
3693 if (S_ISCHR(mode)) {
3694 inode->i_fop = &def_chr_fops;
3695 inode->i_rdev = rdev;
3696 + inode->i_mdev = rdev;
3697 } else if (S_ISBLK(mode)) {
3698 inode->i_fop = &def_blk_fops;
3699 inode->i_rdev = rdev;
3700 + inode->i_mdev = rdev;
3701 } else if (S_ISFIFO(mode))
3702 inode->i_fop = &def_fifo_fops;
3703 else if (S_ISSOCK(mode))
3704 @@ -1657,6 +1666,7 @@ void inode_init_owner(struct inode *inod
3706 inode->i_gid = current_fsgid();
3707 inode->i_mode = mode;
3708 + inode->i_tag = dx_current_fstag(inode->i_sb);
3710 EXPORT_SYMBOL(inode_init_owner);
3712 diff -NurpP --minimal linux-3.2.5/fs/ioctl.c linux-3.2.5-vs2.3.2.6/fs/ioctl.c
3713 --- linux-3.2.5/fs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3714 +++ linux-3.2.5-vs2.3.2.6/fs/ioctl.c 2011-12-05 19:33:02.000000000 +0100
3716 #include <linux/writeback.h>
3717 #include <linux/buffer_head.h>
3718 #include <linux/falloc.h>
3719 +#include <linux/proc_fs.h>
3720 +#include <linux/vserver/inode.h>
3721 +#include <linux/vs_tag.h>
3723 #include <asm/ioctls.h>
3725 diff -NurpP --minimal linux-3.2.5/fs/ioprio.c linux-3.2.5-vs2.3.2.6/fs/ioprio.c
3726 --- linux-3.2.5/fs/ioprio.c 2012-01-09 16:14:54.000000000 +0100
3727 +++ linux-3.2.5-vs2.3.2.6/fs/ioprio.c 2011-12-05 19:33:02.000000000 +0100
3729 #include <linux/syscalls.h>
3730 #include <linux/security.h>
3731 #include <linux/pid_namespace.h>
3732 +#include <linux/vs_base.h>
3734 int set_task_ioprio(struct task_struct *task, int ioprio)
3736 @@ -120,6 +121,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3738 pgrp = find_vpid(who);
3739 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3740 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3742 ret = set_task_ioprio(p, ioprio);
3745 @@ -209,6 +212,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3747 pgrp = find_vpid(who);
3748 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3749 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3751 tmpio = get_task_ioprio(p);
3754 diff -NurpP --minimal linux-3.2.5/fs/jfs/file.c linux-3.2.5-vs2.3.2.6/fs/jfs/file.c
3755 --- linux-3.2.5/fs/jfs/file.c 2011-10-24 18:45:27.000000000 +0200
3756 +++ linux-3.2.5-vs2.3.2.6/fs/jfs/file.c 2011-12-05 19:33:02.000000000 +0100
3757 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
3758 if (is_quota_modification(inode, iattr))
3759 dquot_initialize(inode);
3760 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3761 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3762 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3763 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3764 rc = dquot_transfer(inode, iattr);
3767 @@ -142,6 +143,7 @@ const struct inode_operations jfs_file_i
3768 #ifdef CONFIG_JFS_POSIX_ACL
3769 .get_acl = jfs_get_acl,
3771 + .sync_flags = jfs_sync_flags,
3774 const struct file_operations jfs_file_operations = {
3775 diff -NurpP --minimal linux-3.2.5/fs/jfs/ioctl.c linux-3.2.5-vs2.3.2.6/fs/jfs/ioctl.c
3776 --- linux-3.2.5/fs/jfs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3777 +++ linux-3.2.5-vs2.3.2.6/fs/jfs/ioctl.c 2011-12-05 19:33:02.000000000 +0100
3779 #include <linux/mount.h>
3780 #include <linux/time.h>
3781 #include <linux/sched.h>
3782 +#include <linux/mount.h>
3783 #include <asm/current.h>
3784 #include <asm/uaccess.h>
3786 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
3790 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3792 + inode->i_flags = flags;
3793 + inode->i_vflags = vflags;
3794 + jfs_get_inode_flags(JFS_IP(inode));
3795 + inode->i_ctime = CURRENT_TIME_SEC;
3796 + mark_inode_dirty(inode);
3800 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3802 struct inode *inode = filp->f_dentry->d_inode;
3803 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
3804 if (!S_ISDIR(inode->i_mode))
3805 flags &= ~JFS_DIRSYNC_FL;
3807 + if (IS_BARRIER(inode)) {
3808 + vxwprintk_task(1, "messing with the barrier.");
3812 /* Is it quota file? Do not allow user to mess with it */
3813 if (IS_NOQUOTA(inode)) {
3815 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
3816 * the relevant capability.
3818 if ((oldflags & JFS_IMMUTABLE_FL) ||
3819 - ((flags ^ oldflags) &
3820 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3821 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3822 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3823 if (!capable(CAP_LINUX_IMMUTABLE)) {
3824 mutex_unlock(&inode->i_mutex);
3826 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
3830 - flags = flags & JFS_FL_USER_MODIFIABLE;
3831 + flags &= JFS_FL_USER_MODIFIABLE;
3832 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3833 jfs_inode->mode2 = flags;
3835 diff -NurpP --minimal linux-3.2.5/fs/jfs/jfs_dinode.h linux-3.2.5-vs2.3.2.6/fs/jfs/jfs_dinode.h
3836 --- linux-3.2.5/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
3837 +++ linux-3.2.5-vs2.3.2.6/fs/jfs/jfs_dinode.h 2011-12-05 19:33:02.000000000 +0100
3838 @@ -161,9 +161,13 @@ struct dinode {
3840 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3841 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3842 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3844 -#define JFS_FL_USER_VISIBLE 0x03F80000
3845 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3846 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3847 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3849 +#define JFS_FL_USER_VISIBLE 0x07F80000
3850 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3851 #define JFS_FL_INHERIT 0x03C80000
3853 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3854 diff -NurpP --minimal linux-3.2.5/fs/jfs/jfs_filsys.h linux-3.2.5-vs2.3.2.6/fs/jfs/jfs_filsys.h
3855 --- linux-3.2.5/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
3856 +++ linux-3.2.5-vs2.3.2.6/fs/jfs/jfs_filsys.h 2011-12-05 19:33:02.000000000 +0100
3858 #define JFS_NAME_MAX 255
3859 #define JFS_PATH_MAX BPSIZE
3861 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
3864 * file system state (superblock state)
3865 diff -NurpP --minimal linux-3.2.5/fs/jfs/jfs_imap.c linux-3.2.5-vs2.3.2.6/fs/jfs/jfs_imap.c
3866 --- linux-3.2.5/fs/jfs/jfs_imap.c 2012-01-09 16:14:54.000000000 +0100
3867 +++ linux-3.2.5-vs2.3.2.6/fs/jfs/jfs_imap.c 2011-12-05 19:33:02.000000000 +0100
3869 #include <linux/pagemap.h>
3870 #include <linux/quotaops.h>
3871 #include <linux/slab.h>
3872 +#include <linux/vs_tag.h>
3874 #include "jfs_incore.h"
3875 #include "jfs_inode.h"
3876 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
3878 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3879 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
3883 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3884 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3885 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
3887 set_nlink(ip, le32_to_cpu(dip->di_nlink));
3889 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
3890 + uid = le32_to_cpu(dip->di_uid);
3891 + gid = le32_to_cpu(dip->di_gid);
3892 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
3894 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
3896 ip->i_uid = jfs_ip->saved_uid;
3898 ip->i_uid = sbi->uid;
3901 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
3902 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
3904 ip->i_gid = jfs_ip->saved_gid;
3906 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
3907 dip->di_size = cpu_to_le64(ip->i_size);
3908 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
3909 dip->di_nlink = cpu_to_le32(ip->i_nlink);
3910 - if (sbi->uid == -1)
3911 - dip->di_uid = cpu_to_le32(ip->i_uid);
3913 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
3914 - if (sbi->gid == -1)
3915 - dip->di_gid = cpu_to_le32(ip->i_gid);
3917 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
3919 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
3920 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
3921 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
3922 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
3924 jfs_get_inode_flags(jfs_ip);
3926 * mode2 is only needed for storing the higher order bits.
3927 diff -NurpP --minimal linux-3.2.5/fs/jfs/jfs_inode.c linux-3.2.5-vs2.3.2.6/fs/jfs/jfs_inode.c
3928 --- linux-3.2.5/fs/jfs/jfs_inode.c 2012-01-09 16:14:54.000000000 +0100
3929 +++ linux-3.2.5-vs2.3.2.6/fs/jfs/jfs_inode.c 2011-12-05 19:33:02.000000000 +0100
3932 #include <linux/fs.h>
3933 #include <linux/quotaops.h>
3934 +#include <linux/vs_tag.h>
3935 #include "jfs_incore.h"
3936 #include "jfs_inode.h"
3937 #include "jfs_filsys.h"
3938 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
3940 unsigned int flags = JFS_IP(inode)->mode2;
3942 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
3943 - S_NOATIME | S_DIRSYNC | S_SYNC);
3944 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3945 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3947 if (flags & JFS_IMMUTABLE_FL)
3948 inode->i_flags |= S_IMMUTABLE;
3949 + if (flags & JFS_IXUNLINK_FL)
3950 + inode->i_flags |= S_IXUNLINK;
3952 + if (flags & JFS_SYNC_FL)
3953 + inode->i_flags |= S_SYNC;
3954 if (flags & JFS_APPEND_FL)
3955 inode->i_flags |= S_APPEND;
3956 if (flags & JFS_NOATIME_FL)
3957 inode->i_flags |= S_NOATIME;
3958 if (flags & JFS_DIRSYNC_FL)
3959 inode->i_flags |= S_DIRSYNC;
3960 - if (flags & JFS_SYNC_FL)
3961 - inode->i_flags |= S_SYNC;
3963 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3965 + if (flags & JFS_BARRIER_FL)
3966 + inode->i_vflags |= V_BARRIER;
3967 + if (flags & JFS_COW_FL)
3968 + inode->i_vflags |= V_COW;
3971 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
3973 unsigned int flags = jfs_ip->vfs_inode.i_flags;
3974 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
3976 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
3977 + JFS_APPEND_FL | JFS_NOATIME_FL |
3978 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
3979 + JFS_BARRIER_FL | JFS_COW_FL);
3981 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
3982 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
3983 if (flags & S_IMMUTABLE)
3984 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
3985 + if (flags & S_IXUNLINK)
3986 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
3988 if (flags & S_APPEND)
3989 jfs_ip->mode2 |= JFS_APPEND_FL;
3990 if (flags & S_NOATIME)
3991 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
3992 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
3994 jfs_ip->mode2 |= JFS_SYNC_FL;
3996 + if (vflags & V_BARRIER)
3997 + jfs_ip->mode2 |= JFS_BARRIER_FL;
3998 + if (vflags & V_COW)
3999 + jfs_ip->mode2 |= JFS_COW_FL;
4003 diff -NurpP --minimal linux-3.2.5/fs/jfs/jfs_inode.h linux-3.2.5-vs2.3.2.6/fs/jfs/jfs_inode.h
4004 --- linux-3.2.5/fs/jfs/jfs_inode.h 2011-10-24 18:45:27.000000000 +0200
4005 +++ linux-3.2.5-vs2.3.2.6/fs/jfs/jfs_inode.h 2011-12-05 19:33:02.000000000 +0100
4006 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4007 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4008 int fh_len, int fh_type);
4009 extern void jfs_set_inode_flags(struct inode *);
4010 +extern int jfs_sync_flags(struct inode *, int, int);
4011 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4012 extern int jfs_setattr(struct dentry *, struct iattr *);
4014 diff -NurpP --minimal linux-3.2.5/fs/jfs/namei.c linux-3.2.5-vs2.3.2.6/fs/jfs/namei.c
4015 --- linux-3.2.5/fs/jfs/namei.c 2012-01-09 16:14:54.000000000 +0100
4016 +++ linux-3.2.5-vs2.3.2.6/fs/jfs/namei.c 2011-12-05 19:33:02.000000000 +0100
4018 #include <linux/ctype.h>
4019 #include <linux/quotaops.h>
4020 #include <linux/exportfs.h>
4021 +#include <linux/vs_tag.h>
4022 #include "jfs_incore.h"
4023 #include "jfs_superblock.h"
4024 #include "jfs_inode.h"
4025 @@ -1474,6 +1475,7 @@ static struct dentry *jfs_lookup(struct
4026 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
4029 + dx_propagate_tag(nd, ip);
4030 return d_splice_alias(ip, dentry);
4033 @@ -1538,6 +1540,7 @@ const struct inode_operations jfs_dir_in
4034 #ifdef CONFIG_JFS_POSIX_ACL
4035 .get_acl = jfs_get_acl,
4037 + .sync_flags = jfs_sync_flags,
4040 const struct file_operations jfs_dir_operations = {
4041 diff -NurpP --minimal linux-3.2.5/fs/jfs/super.c linux-3.2.5-vs2.3.2.6/fs/jfs/super.c
4042 --- linux-3.2.5/fs/jfs/super.c 2012-01-09 16:14:54.000000000 +0100
4043 +++ linux-3.2.5-vs2.3.2.6/fs/jfs/super.c 2011-12-05 19:33:02.000000000 +0100
4044 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
4046 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4047 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4048 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4049 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4050 + Opt_tag, Opt_notag, Opt_tagid
4053 static const match_table_t tokens = {
4054 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
4055 {Opt_resize, "resize=%u"},
4056 {Opt_resize_nosize, "resize"},
4057 {Opt_errors, "errors=%s"},
4059 + {Opt_notag, "notag"},
4060 + {Opt_tagid, "tagid=%u"},
4061 + {Opt_tag, "tagxid"},
4062 {Opt_ignore, "noquota"},
4063 {Opt_ignore, "quota"},
4064 {Opt_usrquota, "usrquota"},
4065 @@ -342,6 +347,20 @@ static int parse_options(char *options,
4069 +#ifndef CONFIG_TAGGING_NONE
4071 + *flag |= JFS_TAGGED;
4074 + *flag &= JFS_TAGGED;
4077 +#ifdef CONFIG_PROPAGATE
4080 + *flag |= JFS_TAGGED;
4084 printk("jfs: Unrecognized mount option \"%s\" "
4085 " or missing value\n", p);
4086 @@ -373,6 +392,12 @@ static int jfs_remount(struct super_bloc
4090 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4091 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4097 if (sb->s_flags & MS_RDONLY) {
4099 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4100 #ifdef CONFIG_JFS_POSIX_ACL
4101 sb->s_flags |= MS_POSIXACL;
4103 + /* map mount option tagxid */
4104 + if (sbi->flag & JFS_TAGGED)
4105 + sb->s_flags |= MS_TAGGED;
4108 printk(KERN_ERR "resize option for remount only\n");
4109 diff -NurpP --minimal linux-3.2.5/fs/libfs.c linux-3.2.5-vs2.3.2.6/fs/libfs.c
4110 --- linux-3.2.5/fs/libfs.c 2012-01-09 16:14:54.000000000 +0100
4111 +++ linux-3.2.5-vs2.3.2.6/fs/libfs.c 2011-12-05 19:33:02.000000000 +0100
4112 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
4113 * both impossible due to the lock on directory.
4116 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4117 +static inline int do_dcache_readdir_filter(struct file *filp,
4118 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4120 struct dentry *dentry = filp->f_path.dentry;
4121 struct dentry *cursor = filp->private_data;
4122 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
4123 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4124 struct dentry *next;
4125 next = list_entry(p, struct dentry, d_u.d_child);
4126 + if (filter && !filter(next))
4128 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4129 if (!simple_positive(next)) {
4130 spin_unlock(&next->d_lock);
4131 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
4135 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4137 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4140 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4141 + int (*filter)(struct dentry *))
4143 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4146 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4149 @@ -977,6 +991,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4150 EXPORT_SYMBOL(dcache_dir_lseek);
4151 EXPORT_SYMBOL(dcache_dir_open);
4152 EXPORT_SYMBOL(dcache_readdir);
4153 +EXPORT_SYMBOL(dcache_readdir_filter);
4154 EXPORT_SYMBOL(generic_read_dir);
4155 EXPORT_SYMBOL(mount_pseudo);
4156 EXPORT_SYMBOL(simple_write_begin);
4157 diff -NurpP --minimal linux-3.2.5/fs/locks.c linux-3.2.5-vs2.3.2.6/fs/locks.c
4158 --- linux-3.2.5/fs/locks.c 2012-01-09 16:14:54.000000000 +0100
4159 +++ linux-3.2.5-vs2.3.2.6/fs/locks.c 2012-01-09 16:19:31.000000000 +0100
4161 #include <linux/time.h>
4162 #include <linux/rcupdate.h>
4163 #include <linux/pid_namespace.h>
4164 +#include <linux/vs_base.h>
4165 +#include <linux/vs_limit.h>
4167 #include <asm/uaccess.h>
4169 @@ -184,11 +186,17 @@ static void locks_init_lock_heads(struct
4170 /* Allocate an empty lock structure. */
4171 struct file_lock *locks_alloc_lock(void)
4173 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4174 + struct file_lock *fl;
4177 - locks_init_lock_heads(fl);
4178 + if (!vx_locks_avail(1))
4181 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4184 + locks_init_lock_heads(fl);
4189 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4190 @@ -216,6 +224,7 @@ void locks_free_lock(struct file_lock *f
4191 BUG_ON(!list_empty(&fl->fl_block));
4192 BUG_ON(!list_empty(&fl->fl_link));
4195 locks_release_private(fl);
4196 kmem_cache_free(filelock_cache, fl);
4198 @@ -225,6 +234,7 @@ void locks_init_lock(struct file_lock *f
4200 memset(fl, 0, sizeof(struct file_lock));
4201 locks_init_lock_heads(fl);
4205 EXPORT_SYMBOL(locks_init_lock);
4206 @@ -265,6 +275,7 @@ void locks_copy_lock(struct file_lock *n
4207 new->fl_file = fl->fl_file;
4208 new->fl_ops = fl->fl_ops;
4209 new->fl_lmops = fl->fl_lmops;
4210 + new->fl_xid = fl->fl_xid;
4212 locks_copy_private(new, fl);
4214 @@ -303,6 +314,11 @@ static int flock_make_lock(struct file *
4215 fl->fl_flags = FL_FLOCK;
4217 fl->fl_end = OFFSET_MAX;
4219 + vxd_assert(filp->f_xid == vx_current_xid(),
4220 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4221 + fl->fl_xid = filp->f_xid;
4226 @@ -452,6 +468,7 @@ static int lease_init(struct file *filp,
4228 fl->fl_owner = current->files;
4229 fl->fl_pid = current->tgid;
4230 + fl->fl_xid = vx_current_xid();
4233 fl->fl_flags = FL_LEASE;
4234 @@ -471,6 +488,11 @@ static struct file_lock *lease_alloc(str
4236 return ERR_PTR(error);
4238 + fl->fl_xid = vx_current_xid();
4240 + vxd_assert(filp->f_xid == fl->fl_xid,
4241 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4243 error = lease_init(filp, type, fl);
4245 locks_free_lock(fl);
4246 @@ -772,6 +794,7 @@ static int flock_lock_file(struct file *
4250 + new_fl->fl_xid = -1;
4252 for_each_lock(inode, before) {
4253 struct file_lock *fl = *before;
4254 @@ -792,6 +815,7 @@ find_conflict:
4256 locks_copy_lock(new_fl, request);
4257 locks_insert_lock(before, new_fl);
4258 + vx_locks_inc(new_fl);
4262 @@ -802,7 +826,8 @@ out:
4266 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4267 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4268 + struct file_lock *conflock, xid_t xid)
4270 struct file_lock *fl;
4271 struct file_lock *new_fl = NULL;
4272 @@ -812,6 +837,8 @@ static int __posix_lock_file(struct inod
4273 struct file_lock **before;
4274 int error, added = 0;
4276 + vxd_assert(xid == vx_current_xid(),
4277 + "xid(%d) == current(%d)", xid, vx_current_xid());
4279 * We may need two file_lock structures for this operation,
4280 * so we get them in advance to avoid races.
4281 @@ -822,7 +849,11 @@ static int __posix_lock_file(struct inod
4282 (request->fl_type != F_UNLCK ||
4283 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4284 new_fl = locks_alloc_lock();
4285 + new_fl->fl_xid = xid;
4286 + vx_locks_inc(new_fl);
4287 new_fl2 = locks_alloc_lock();
4288 + new_fl2->fl_xid = xid;
4289 + vx_locks_inc(new_fl2);
4293 @@ -1021,7 +1052,8 @@ static int __posix_lock_file(struct inod
4294 int posix_lock_file(struct file *filp, struct file_lock *fl,
4295 struct file_lock *conflock)
4297 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4298 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4299 + fl, conflock, filp->f_xid);
4301 EXPORT_SYMBOL(posix_lock_file);
4303 @@ -1111,7 +1143,7 @@ int locks_mandatory_area(int read_write,
4304 fl.fl_end = offset + count - 1;
4307 - error = __posix_lock_file(inode, &fl, NULL);
4308 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4309 if (error != FILE_LOCK_DEFERRED)
4311 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4312 @@ -1406,6 +1438,7 @@ int generic_add_lease(struct file *filp,
4315 locks_insert_lock(before, lease);
4316 + vx_locks_inc(lease);
4320 @@ -1846,6 +1879,11 @@ int fcntl_setlk(unsigned int fd, struct
4321 if (file_lock == NULL)
4324 + vxd_assert(filp->f_xid == vx_current_xid(),
4325 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4326 + file_lock->fl_xid = filp->f_xid;
4327 + vx_locks_inc(file_lock);
4330 * This might block, so we do it before checking the inode.
4332 @@ -1964,6 +2002,11 @@ int fcntl_setlk64(unsigned int fd, struc
4333 if (file_lock == NULL)
4336 + vxd_assert(filp->f_xid == vx_current_xid(),
4337 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4338 + file_lock->fl_xid = filp->f_xid;
4339 + vx_locks_inc(file_lock);
4342 * This might block, so we do it before checking the inode.
4344 @@ -2229,8 +2272,11 @@ static int locks_show(struct seq_file *f
4346 lock_get_status(f, fl, *((loff_t *)f->private), "");
4348 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4349 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4350 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4352 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4357 diff -NurpP --minimal linux-3.2.5/fs/namei.c linux-3.2.5-vs2.3.2.6/fs/namei.c
4358 --- linux-3.2.5/fs/namei.c 2012-01-09 16:14:54.000000000 +0100
4359 +++ linux-3.2.5-vs2.3.2.6/fs/namei.c 2011-12-05 19:33:02.000000000 +0100
4361 #include <linux/device_cgroup.h>
4362 #include <linux/fs_struct.h>
4363 #include <linux/posix_acl.h>
4364 +#include <linux/proc_fs.h>
4365 +#include <linux/vserver/inode.h>
4366 +#include <linux/vs_base.h>
4367 +#include <linux/vs_tag.h>
4368 +#include <linux/vs_cowbl.h>
4369 +#include <linux/vs_device.h>
4370 +#include <linux/vs_context.h>
4371 +#include <linux/pid_namespace.h>
4372 #include <asm/uaccess.h>
4374 #include "internal.h"
4375 @@ -222,6 +230,89 @@ static int check_acl(struct inode *inode
4379 +static inline int dx_barrier(const struct inode *inode)
4381 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4382 + vxwprintk_task(1, "did hit the barrier.");
4388 +static int __dx_permission(const struct inode *inode, int mask)
4390 + if (dx_barrier(inode))
4393 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4394 + /* devpts is xid tagged */
4395 + if (S_ISDIR(inode->i_mode) ||
4396 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4399 + /* just pretend we didn't find anything */
4402 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4403 + struct proc_dir_entry *de = PDE(inode);
4405 + if (de && !vx_hide_check(0, de->vx_flags))
4408 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4410 + struct task_struct *tsk;
4412 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4413 + vx_flags(VXF_STATE_SETUP, 0))
4416 + pid = PROC_I(inode)->pid;
4421 + tsk = pid_task(pid, PIDTYPE_PID);
4422 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4423 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4425 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4426 + rcu_read_unlock();
4429 + rcu_read_unlock();
4432 + /* FIXME: Should we block some entries here? */
4437 + if (dx_notagcheck(inode->i_sb) ||
4438 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4447 +int dx_permission(const struct inode *inode, int mask)
4449 + int ret = __dx_permission(inode, mask);
4450 + if (unlikely(ret)) {
4451 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4452 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4455 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4456 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4463 * This does the basic permission checking
4465 @@ -357,10 +448,14 @@ int inode_permission(struct inode *inode
4467 * Nobody gets write access to an immutable file.
4469 - if (IS_IMMUTABLE(inode))
4470 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4474 + retval = dx_permission(inode, mask);
4478 retval = do_inode_permission(inode, mask);
4481 @@ -1037,7 +1132,8 @@ static void follow_dotdot(struct nameida
4483 if (nd->path.dentry == nd->root.dentry &&
4484 nd->path.mnt == nd->root.mnt) {
4486 + /* for sane '/' avoid follow_mount() */
4489 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4490 /* rare case of legitimate dget_parent()... */
4491 @@ -1146,6 +1242,9 @@ static int do_lookup(struct nameidata *n
4493 if (unlikely(d_need_lookup(dentry)))
4496 + /* FIXME: check dx permission */
4499 path->dentry = dentry;
4500 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4501 @@ -1207,6 +1306,8 @@ retry:
4505 + /* FIXME: check dx permission */
4508 path->dentry = dentry;
4509 err = follow_managed(path, nd->flags);
4510 @@ -1901,7 +2002,7 @@ static int may_delete(struct inode *dir,
4513 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4514 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4515 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4518 if (!S_ISDIR(victim->d_inode->i_mode))
4519 @@ -1981,19 +2082,25 @@ int vfs_create(struct inode *dir, struct
4521 int error = may_create(dir, dentry);
4525 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
4529 if (!dir->i_op->create)
4530 return -EACCES; /* shouldn't it be ENOSYS? */
4533 error = security_inode_create(dir, dentry, mode);
4536 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
4539 error = dir->i_op->create(dir, dentry, mode, nd);
4541 fsnotify_create(dir, dentry);
4543 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
4547 @@ -2028,6 +2135,15 @@ static int may_open(struct path *path, i
4551 +#ifdef CONFIG_VSERVER_COWBL
4552 + if (IS_COW(inode) &&
4553 + ((flag & O_ACCMODE) != O_RDONLY)) {
4554 + if (IS_COW_LINK(inode))
4556 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4557 + mark_inode_dirty(inode);
4560 error = inode_permission(inode, acc_mode);
4563 @@ -2252,6 +2368,16 @@ ok:
4566 error = may_open(&nd->path, acc_mode, open_flag);
4567 +#ifdef CONFIG_VSERVER_COWBL
4568 + if (error == -EMLINK) {
4569 + struct dentry *dentry;
4570 + dentry = cow_break_link(pathname);
4571 + if (IS_ERR(dentry))
4572 + error = PTR_ERR(dentry);
4579 filp = nameidata_to_filp(nd);
4580 @@ -2294,6 +2420,7 @@ static struct file *path_openat(int dfd,
4585 filp = get_empty_filp();
4587 return ERR_PTR(-ENFILE);
4588 @@ -2331,6 +2458,17 @@ static struct file *path_openat(int dfd,
4589 filp = do_last(nd, &path, op, pathname);
4590 put_link(nd, &link, cookie);
4593 +#ifdef CONFIG_VSERVER_COWBL
4594 + if (filp == ERR_PTR(-EMLINK)) {
4595 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4596 + path_put(&nd->root);
4599 + release_open_intent(nd);
4604 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4605 path_put(&nd->root);
4606 @@ -2420,6 +2558,11 @@ struct dentry *kern_path_create(int dfd,
4610 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
4611 + path->dentry, path->dentry->d_name.len,
4612 + path->dentry->d_name.name, dentry,
4613 + dentry->d_name.len, dentry->d_name.name,
4614 + path->dentry->d_inode);
4618 @@ -2901,7 +3044,7 @@ int vfs_link(struct dentry *old_dentry,
4620 * A link to an append-only or immutable file cannot be created.
4622 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4623 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4625 if (!dir->i_op->link)
4627 @@ -3282,6 +3425,227 @@ int vfs_follow_link(struct nameidata *nd
4628 return __vfs_follow_link(nd, link);
4632 +#ifdef CONFIG_VSERVER_COWBL
4635 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4639 + return do_splice_direct(in, &ppos, out, len, 0);
4642 +struct dentry *cow_break_link(const char *pathname)
4644 + int ret, mode, pathlen, redo = 0;
4645 + struct nameidata old_nd, dir_nd;
4646 + struct path old_path, dir_path;
4647 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4648 + struct file *old_file;
4649 + struct file *new_file;
4650 + char *to, *path, pad='\251';
4653 + vxdprintk(VXD_CBIT(misc, 1),
4654 + "cow_break_link(" VS_Q("%s") ")", pathname);
4655 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4660 + /* old_nd will have refs to dentry and mnt */
4661 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4662 + vxdprintk(VXD_CBIT(misc, 2),
4663 + "do_path_lookup(old): %d [r=%d]",
4664 + ret, mnt_get_count(old_nd.path.mnt));
4666 + goto out_free_path;
4668 + old_path = old_nd.path;
4669 + old_dentry = old_path.dentry;
4670 + mode = old_dentry->d_inode->i_mode;
4672 + to = d_path(&old_path, path, PATH_MAX-2);
4673 + pathlen = strlen(to);
4674 + vxdprintk(VXD_CBIT(misc, 2),
4675 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4677 + old_dentry->d_name.len, old_dentry->d_name.name,
4678 + old_dentry->d_name.len);
4680 + to[pathlen + 1] = 0;
4682 + new_dentry = NULL;
4683 + to[pathlen] = pad--;
4685 + if (pad <= '\240')
4688 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4689 + /* dir_nd will have refs to dentry and mnt */
4690 + ret = do_path_lookup(AT_FDCWD, to,
4691 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4692 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4696 + /* this puppy downs the dir inode mutex if successful */
4697 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
4698 + if (!new_dentry || IS_ERR(new_dentry)) {
4699 + path_put(&dir_nd.path);
4700 + vxdprintk(VXD_CBIT(misc, 2),
4701 + "kern_path_create(new) failed with %ld",
4702 + PTR_ERR(new_dentry));
4705 + path_put(&dir_path);
4706 + vxdprintk(VXD_CBIT(misc, 2),
4707 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
4709 + new_dentry->d_name.len, new_dentry->d_name.name,
4710 + new_dentry->d_name.len);
4712 + dir = dir_nd.path.dentry;
4714 + ret = vfs_create(dir->d_inode, new_dentry, mode, &dir_nd);
4715 + vxdprintk(VXD_CBIT(misc, 2),
4716 + "vfs_create(new): %d", ret);
4717 + if (ret == -EEXIST) {
4718 + mutex_unlock(&dir->d_inode->i_mutex);
4719 + path_put(&dir_nd.path);
4724 + goto out_unlock_new;
4726 + /* drop out early, ret passes ENOENT */
4728 + if ((redo = d_unhashed(old_dentry)))
4729 + goto out_unlock_new;
4731 + path_get(&old_path);
4732 + /* this one cleans up the dentry/mnt in case of failure */
4733 + old_file = dentry_open(old_dentry, old_path.mnt,
4734 + O_RDONLY, current_cred());
4735 + vxdprintk(VXD_CBIT(misc, 2),
4736 + "dentry_open(old): %p", old_file);
4737 + if (IS_ERR(old_file)) {
4738 + ret = PTR_ERR(old_file);
4739 + goto out_unlock_new;
4743 + mntget(old_path.mnt);
4744 + /* this one cleans up the dentry/mnt in case of failure */
4745 + new_file = dentry_open(new_dentry, old_path.mnt,
4746 + O_WRONLY, current_cred());
4747 + vxdprintk(VXD_CBIT(misc, 2),
4748 + "dentry_open(new): %p", new_file);
4749 + if (IS_ERR(new_file)) {
4750 + ret = PTR_ERR(new_file);
4751 + goto out_fput_old;
4754 + size = i_size_read(old_file->f_dentry->d_inode);
4755 + ret = do_cow_splice(old_file, new_file, size);
4756 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4758 + goto out_fput_both;
4759 + } else if (ret < size) {
4761 + goto out_fput_both;
4763 + struct inode *old_inode = old_dentry->d_inode;
4764 + struct inode *new_inode = new_dentry->d_inode;
4765 + struct iattr attr = {
4766 + .ia_uid = old_inode->i_uid,
4767 + .ia_gid = old_inode->i_gid,
4768 + .ia_valid = ATTR_UID | ATTR_GID
4771 + setattr_copy(new_inode, &attr);
4772 + mark_inode_dirty(new_inode);
4775 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4777 + /* drop out late */
4779 + if ((redo = d_unhashed(old_dentry)))
4782 + vxdprintk(VXD_CBIT(misc, 2),
4783 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4784 + new_dentry->d_name.len, new_dentry->d_name.name,
4785 + new_dentry->d_name.len,
4786 + old_dentry->d_name.len, old_dentry->d_name.name,
4787 + old_dentry->d_name.len);
4788 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4789 + old_dentry->d_parent->d_inode, old_dentry);
4790 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4793 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4796 + vxdprintk(VXD_CBIT(misc, 3),
4797 + "fput(new_file=%p[#%ld])", new_file,
4798 + atomic_long_read(&new_file->f_count));
4802 + vxdprintk(VXD_CBIT(misc, 3),
4803 + "fput(old_file=%p[#%ld])", old_file,
4804 + atomic_long_read(&old_file->f_count));
4808 + mutex_unlock(&dir->d_inode->i_mutex);
4812 + /* error path cleanup */
4813 + vfs_unlink(dir->d_inode, new_dentry);
4817 + goto out_rel_both;
4818 + /* lookup dentry once again */
4819 + /* old_nd.path is freed as old_path in out_rel_old */
4820 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4822 + goto out_rel_both;
4825 + new_dentry = old_nd.path.dentry;
4826 + vxdprintk(VXD_CBIT(misc, 2),
4827 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4829 + new_dentry->d_name.len, new_dentry->d_name.name,
4830 + new_dentry->d_name.len);
4834 + path_put(&dir_nd.path);
4836 + path_put(&old_path);
4842 + new_dentry = ERR_PTR(ret);
4844 + vxdprintk(VXD_CBIT(misc, 3),
4845 + "cow_break_link returning with %p [r=%d]",
4846 + new_dentry, mnt_get_count(old_nd.path.mnt));
4847 + return new_dentry;
4852 /* get the link contents into pagecache */
4853 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4855 diff -NurpP --minimal linux-3.2.5/fs/namespace.c linux-3.2.5-vs2.3.2.6/fs/namespace.c
4856 --- linux-3.2.5/fs/namespace.c 2012-01-09 16:14:54.000000000 +0100
4857 +++ linux-3.2.5-vs2.3.2.6/fs/namespace.c 2011-12-15 01:11:32.000000000 +0100
4859 #include <linux/idr.h>
4860 #include <linux/fs_struct.h>
4861 #include <linux/fsnotify.h>
4862 +#include <linux/vs_base.h>
4863 +#include <linux/vs_context.h>
4864 +#include <linux/vs_tag.h>
4865 +#include <linux/vserver/space.h>
4866 +#include <linux/vserver/global.h>
4867 #include <asm/uaccess.h>
4868 #include <asm/unistd.h>
4870 @@ -679,6 +684,10 @@ vfs_kern_mount(struct file_system_type *
4872 return ERR_PTR(-ENODEV);
4874 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
4875 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
4876 + return ERR_PTR(-EPERM);
4878 mnt = alloc_vfsmnt(name);
4880 return ERR_PTR(-ENOMEM);
4881 @@ -724,6 +733,7 @@ static struct vfsmount *clone_mnt(struct
4882 mnt->mnt_root = dget(root);
4883 mnt->mnt_mountpoint = mnt->mnt_root;
4884 mnt->mnt_parent = mnt;
4885 + mnt->mnt_tag = old->mnt_tag;
4887 if (flag & CL_SLAVE) {
4888 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
4889 @@ -852,6 +862,31 @@ static inline void mangle(struct seq_fil
4890 seq_escape(m, s, " \t\n\\");
4893 +static int mnt_is_reachable(struct vfsmount *mnt)
4896 + struct dentry *point;
4899 + if (mnt == mnt->mnt_ns->root)
4902 + br_read_lock(vfsmount_lock);
4903 + root = current->fs->root;
4904 + point = root.dentry;
4906 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
4907 + point = mnt->mnt_mountpoint;
4908 + mnt = mnt->mnt_parent;
4911 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
4913 + br_read_unlock(vfsmount_lock);
4919 * Simple .show_options callback for filesystems which don't want to
4920 * implement more complex mount option showing.
4921 @@ -954,6 +989,8 @@ static int show_sb_opts(struct seq_file
4922 { MS_SYNCHRONOUS, ",sync" },
4923 { MS_DIRSYNC, ",dirsync" },
4924 { MS_MANDLOCK, ",mand" },
4925 + { MS_TAGGED, ",tag" },
4926 + { MS_NOTAGCHECK, ",notagcheck" },
4929 const struct proc_fs_info *fs_infop;
4930 @@ -1000,16 +1037,26 @@ static int show_vfsmnt(struct seq_file *
4932 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
4934 - if (mnt->mnt_sb->s_op->show_devname) {
4935 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
4938 + if (vx_flags(VXF_HIDE_MOUNT, 0))
4940 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
4943 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
4944 + mnt == current->fs->root.mnt) {
4945 + seq_puts(m, "/dev/root / ");
4947 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
4948 + if (mnt->mnt_sb->s_op->show_devname) {
4949 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
4953 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
4956 + seq_path(m, &mnt_path, " \t\n\\");
4960 - seq_path(m, &mnt_path, " \t\n\\");
4962 show_type(m, mnt->mnt_sb);
4963 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
4964 err = show_sb_opts(m, mnt->mnt_sb);
4965 @@ -1039,6 +1086,11 @@ static int show_mountinfo(struct seq_fil
4966 struct path root = p->root;
4969 + if (vx_flags(VXF_HIDE_MOUNT, 0))
4971 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
4974 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
4975 MAJOR(sb->s_dev), MINOR(sb->s_dev));
4976 if (sb->s_op->show_path)
4977 @@ -1104,22 +1156,32 @@ static int show_vfsstat(struct seq_file
4978 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
4982 - if (mnt->mnt_sb->s_op->show_devname) {
4983 - seq_puts(m, "device ");
4984 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
4985 + if (vx_flags(VXF_HIDE_MOUNT, 0))
4987 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
4990 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
4991 + mnt == current->fs->root.mnt) {
4992 + seq_puts(m, "device /dev/root mounted on / ");
4994 - if (mnt->mnt_devname) {
4996 + if (mnt->mnt_sb->s_op->show_devname) {
4997 seq_puts(m, "device ");
4998 - mangle(m, mnt->mnt_devname);
5000 - seq_puts(m, "no device");
5002 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5004 + if (mnt->mnt_devname) {
5005 + seq_puts(m, "device ");
5006 + mangle(m, mnt->mnt_devname);
5008 + seq_puts(m, "no device");
5012 - seq_puts(m, " mounted on ");
5013 - seq_path(m, &mnt_path, " \t\n\\");
5016 + seq_puts(m, " mounted on ");
5017 + seq_path(m, &mnt_path, " \t\n\\");
5021 /* file system type */
5022 seq_puts(m, "with fstype ");
5023 @@ -1378,7 +1440,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5027 - if (!capable(CAP_SYS_ADMIN))
5028 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5031 retval = do_umount(path.mnt, flags);
5032 @@ -1404,7 +1466,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5034 static int mount_is_safe(struct path *path)
5036 - if (capable(CAP_SYS_ADMIN))
5037 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5041 @@ -1714,7 +1776,7 @@ static int do_change_type(struct path *p
5045 - if (!capable(CAP_SYS_ADMIN))
5046 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5049 if (path->dentry != path->mnt->mnt_root)
5050 @@ -1730,6 +1792,7 @@ static int do_change_type(struct path *p
5054 + // mnt->mnt_flags = mnt_flags;
5056 br_write_lock(vfsmount_lock);
5057 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
5058 @@ -1745,12 +1808,14 @@ static int do_change_type(struct path *p
5059 * do loopback mount.
5061 static int do_loopback(struct path *path, char *old_name,
5063 + tag_t tag, unsigned long flags, int mnt_flags)
5065 LIST_HEAD(umount_list);
5066 struct path old_path;
5067 struct vfsmount *mnt = NULL;
5068 int err = mount_is_safe(path);
5069 + int recurse = flags & MS_REC;
5073 if (!old_name || !*old_name)
5074 @@ -1816,12 +1881,12 @@ static int change_mount_flags(struct vfs
5075 * on it - tough luck.
5077 static int do_remount(struct path *path, int flags, int mnt_flags,
5079 + void *data, xid_t xid)
5082 struct super_block *sb = path->mnt->mnt_sb;
5084 - if (!capable(CAP_SYS_ADMIN))
5085 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5088 if (!check_mnt(path->mnt))
5089 @@ -1869,7 +1934,7 @@ static int do_move_mount(struct path *pa
5090 struct path old_path, parent_path;
5093 - if (!capable(CAP_SYS_ADMIN))
5094 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5096 if (!old_name || !*old_name)
5098 @@ -2020,7 +2085,7 @@ static int do_new_mount(struct path *pat
5101 /* we need capabilities... */
5102 - if (!capable(CAP_SYS_ADMIN))
5103 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5106 mnt = do_kern_mount(type, flags, name, data);
5107 @@ -2289,6 +2354,7 @@ long do_mount(char *dev_name, char *dir_
5114 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5115 @@ -2316,6 +2382,12 @@ long do_mount(char *dev_name, char *dir_
5116 if (!(flags & MS_NOATIME))
5117 mnt_flags |= MNT_RELATIME;
5119 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5120 + /* FIXME: bind and re-mounts get the tag flag? */
5121 + if (flags & (MS_BIND|MS_REMOUNT))
5122 + flags |= MS_TAGID;
5125 /* Separate the per-mountpoint flags */
5126 if (flags & MS_NOSUID)
5127 mnt_flags |= MNT_NOSUID;
5128 @@ -2332,15 +2404,17 @@ long do_mount(char *dev_name, char *dir_
5129 if (flags & MS_RDONLY)
5130 mnt_flags |= MNT_READONLY;
5132 + if (!capable(CAP_SYS_ADMIN))
5133 + mnt_flags |= MNT_NODEV;
5134 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5135 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5138 if (flags & MS_REMOUNT)
5139 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5142 else if (flags & MS_BIND)
5143 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5144 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5145 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5146 retval = do_change_type(&path, flags);
5147 else if (flags & MS_MOVE)
5148 @@ -2440,6 +2514,7 @@ static struct mnt_namespace *dup_mnt_ns(
5149 q = next_mnt(q, new_ns->root);
5151 up_write(&namespace_sem);
5152 + atomic_inc(&vs_global_mnt_ns);
5156 @@ -2611,9 +2686,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5160 - if (IS_MNT_SHARED(old.mnt) ||
5161 + if ((IS_MNT_SHARED(old.mnt) ||
5162 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5163 - IS_MNT_SHARED(root.mnt->mnt_parent))
5164 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5165 + !vx_flags(VXF_STATE_SETUP, 0))
5167 if (!check_mnt(root.mnt) || !check_mnt(new.mnt))
5169 @@ -2745,6 +2821,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5170 br_write_unlock(vfsmount_lock);
5171 up_write(&namespace_sem);
5172 release_mounts(&umount_list);
5173 + atomic_dec(&vs_global_mnt_ns);
5176 EXPORT_SYMBOL(put_mnt_ns);
5177 diff -NurpP --minimal linux-3.2.5/fs/nfs/client.c linux-3.2.5-vs2.3.2.6/fs/nfs/client.c
5178 --- linux-3.2.5/fs/nfs/client.c 2012-01-09 16:14:54.000000000 +0100
5179 +++ linux-3.2.5-vs2.3.2.6/fs/nfs/client.c 2011-12-05 19:33:02.000000000 +0100
5180 @@ -779,6 +779,9 @@ static int nfs_init_server_rpcclient(str
5181 if (server->flags & NFS_MOUNT_SOFT)
5182 server->client->cl_softrtry = 1;
5184 + server->client->cl_tag = 0;
5185 + if (server->flags & NFS_MOUNT_TAGGED)
5186 + server->client->cl_tag = 1;
5190 @@ -953,6 +956,10 @@ static void nfs_server_set_fsinfo(struct
5191 server->acdirmin = server->acdirmax = 0;
5194 + /* FIXME: needs fsinfo
5195 + if (server->flags & NFS_MOUNT_TAGGED)
5196 + sb->s_flags |= MS_TAGGED; */
5198 server->maxfilesize = fsinfo->maxfilesize;
5200 server->time_delta = fsinfo->time_delta;
5201 diff -NurpP --minimal linux-3.2.5/fs/nfs/dir.c linux-3.2.5-vs2.3.2.6/fs/nfs/dir.c
5202 --- linux-3.2.5/fs/nfs/dir.c 2012-01-09 16:14:54.000000000 +0100
5203 +++ linux-3.2.5-vs2.3.2.6/fs/nfs/dir.c 2011-12-05 19:33:02.000000000 +0100
5205 #include <linux/sched.h>
5206 #include <linux/kmemleak.h>
5207 #include <linux/xattr.h>
5208 +#include <linux/vs_tag.h>
5210 #include "delegation.h"
5212 @@ -1311,6 +1312,7 @@ static struct dentry *nfs_lookup(struct
5214 goto out_unblock_sillyrename;
5216 + dx_propagate_tag(nd, inode);
5218 res = d_materialise_unique(dentry, inode);
5220 diff -NurpP --minimal linux-3.2.5/fs/nfs/inode.c linux-3.2.5-vs2.3.2.6/fs/nfs/inode.c
5221 --- linux-3.2.5/fs/nfs/inode.c 2012-01-09 16:14:54.000000000 +0100
5222 +++ linux-3.2.5-vs2.3.2.6/fs/nfs/inode.c 2011-12-05 21:16:35.000000000 +0100
5224 #include <linux/nfs_xdr.h>
5225 #include <linux/slab.h>
5226 #include <linux/compat.h>
5227 +#include <linux/vs_tag.h>
5229 #include <asm/system.h>
5230 #include <asm/uaccess.h>
5231 @@ -273,6 +274,8 @@ nfs_fhget(struct super_block *sb, struct
5232 if (inode->i_state & I_NEW) {
5233 struct nfs_inode *nfsi = NFS_I(inode);
5234 unsigned long now = jiffies;
5238 /* We set i_ino for the few things that still rely on it,
5239 * such as stat(2) */
5240 @@ -321,8 +324,8 @@ nfs_fhget(struct super_block *sb, struct
5241 inode->i_version = 0;
5244 - inode->i_uid = -2;
5245 - inode->i_gid = -2;
5248 inode->i_blocks = 0;
5249 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5251 @@ -359,13 +362,13 @@ nfs_fhget(struct super_block *sb, struct
5252 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5253 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5254 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5255 - inode->i_uid = fattr->uid;
5257 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5258 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5259 | NFS_INO_INVALID_ACCESS
5260 | NFS_INO_INVALID_ACL;
5261 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5262 - inode->i_gid = fattr->gid;
5264 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5265 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5266 | NFS_INO_INVALID_ACCESS
5267 @@ -378,6 +381,11 @@ nfs_fhget(struct super_block *sb, struct
5269 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5271 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5272 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5273 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5274 + /* maybe fattr->xid someday */
5276 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5277 nfsi->attrtimeo_timestamp = now;
5278 nfsi->access_cache = RB_ROOT;
5279 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
5280 inode->i_uid = attr->ia_uid;
5281 if ((attr->ia_valid & ATTR_GID) != 0)
5282 inode->i_gid = attr->ia_gid;
5283 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5284 + inode->i_tag = attr->ia_tag;
5285 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5286 spin_unlock(&inode->i_lock);
5288 @@ -943,6 +953,9 @@ static int nfs_check_inode_attributes(st
5289 struct nfs_inode *nfsi = NFS_I(inode);
5290 loff_t cur_size, new_isize;
5291 unsigned long invalid = 0;
5297 /* Has the inode gone and changed behind our back? */
5298 @@ -966,13 +979,18 @@ static int nfs_check_inode_attributes(st
5299 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5302 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5303 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5304 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5306 /* Have any file permissions changed? */
5307 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5308 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5309 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5310 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5311 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5312 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5313 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5314 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5315 + /* maybe check for tag too? */
5317 /* Has the link count changed? */
5318 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5319 @@ -1207,6 +1225,9 @@ static int nfs_update_inode(struct inode
5320 unsigned long invalid = 0;
5321 unsigned long now = jiffies;
5322 unsigned long save_cache_validity;
5327 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5328 __func__, inode->i_sb->s_id, inode->i_ino,
5329 @@ -1314,6 +1335,9 @@ static int nfs_update_inode(struct inode
5330 | NFS_INO_REVAL_PAGECACHE
5331 | NFS_INO_REVAL_FORCED);
5333 + uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5334 + gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5335 + tag = inode->i_tag;
5337 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5338 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5339 @@ -1335,9 +1359,9 @@ static int nfs_update_inode(struct inode
5340 | NFS_INO_REVAL_FORCED);
5342 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5343 - if (inode->i_uid != fattr->uid) {
5344 + if (uid != fattr->uid) {
5345 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5346 - inode->i_uid = fattr->uid;
5349 } else if (server->caps & NFS_CAP_OWNER)
5350 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5351 @@ -1346,9 +1370,9 @@ static int nfs_update_inode(struct inode
5352 | NFS_INO_REVAL_FORCED);
5354 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5355 - if (inode->i_gid != fattr->gid) {
5356 + if (gid != fattr->gid) {
5357 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5358 - inode->i_gid = fattr->gid;
5361 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5362 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5363 @@ -1356,6 +1380,10 @@ static int nfs_update_inode(struct inode
5364 | NFS_INO_INVALID_ACL
5365 | NFS_INO_REVAL_FORCED);
5367 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5368 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5369 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
5371 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5372 if (inode->i_nlink != fattr->nlink) {
5373 invalid |= NFS_INO_INVALID_ATTR;
5374 diff -NurpP --minimal linux-3.2.5/fs/nfs/nfs3xdr.c linux-3.2.5-vs2.3.2.6/fs/nfs/nfs3xdr.c
5375 --- linux-3.2.5/fs/nfs/nfs3xdr.c 2011-03-15 18:07:32.000000000 +0100
5376 +++ linux-3.2.5-vs2.3.2.6/fs/nfs/nfs3xdr.c 2011-12-05 19:33:02.000000000 +0100
5378 #include <linux/nfs3.h>
5379 #include <linux/nfs_fs.h>
5380 #include <linux/nfsacl.h>
5381 +#include <linux/vs_tag.h>
5382 #include "internal.h"
5384 #define NFSDBG_FACILITY NFSDBG_XDR
5385 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5389 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5390 +static void encode_sattr3(struct xdr_stream *xdr,
5391 + const struct iattr *attr, int tag)
5395 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
5399 - if (attr->ia_valid & ATTR_UID) {
5400 + if (attr->ia_valid & ATTR_UID ||
5401 + (tag && (attr->ia_valid & ATTR_TAG))) {
5403 - *p++ = cpu_to_be32(attr->ia_uid);
5404 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5405 + attr->ia_uid, attr->ia_tag));
5409 - if (attr->ia_valid & ATTR_GID) {
5410 + if (attr->ia_valid & ATTR_GID ||
5411 + (tag && (attr->ia_valid & ATTR_TAG))) {
5413 - *p++ = cpu_to_be32(attr->ia_gid);
5414 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5415 + attr->ia_gid, attr->ia_tag));
5419 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
5420 const struct nfs3_sattrargs *args)
5422 encode_nfs_fh3(xdr, args->fh);
5423 - encode_sattr3(xdr, args->sattr);
5424 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5425 encode_sattrguard3(xdr, args);
5428 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
5431 static void encode_createhow3(struct xdr_stream *xdr,
5432 - const struct nfs3_createargs *args)
5433 + const struct nfs3_createargs *args, int tag)
5435 encode_uint32(xdr, args->createmode);
5436 switch (args->createmode) {
5437 case NFS3_CREATE_UNCHECKED:
5438 case NFS3_CREATE_GUARDED:
5439 - encode_sattr3(xdr, args->sattr);
5440 + encode_sattr3(xdr, args->sattr, tag);
5442 case NFS3_CREATE_EXCLUSIVE:
5443 encode_createverf3(xdr, args->verifier);
5444 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
5445 const struct nfs3_createargs *args)
5447 encode_diropargs3(xdr, args->fh, args->name, args->len);
5448 - encode_createhow3(xdr, args);
5449 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5453 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5454 const struct nfs3_mkdirargs *args)
5456 encode_diropargs3(xdr, args->fh, args->name, args->len);
5457 - encode_sattr3(xdr, args->sattr);
5458 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5462 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5465 static void encode_symlinkdata3(struct xdr_stream *xdr,
5466 - const struct nfs3_symlinkargs *args)
5467 + const struct nfs3_symlinkargs *args, int tag)
5469 - encode_sattr3(xdr, args->sattr);
5470 + encode_sattr3(xdr, args->sattr, tag);
5471 encode_nfspath3(xdr, args->pages, args->pathlen);
5474 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
5475 const struct nfs3_symlinkargs *args)
5477 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5478 - encode_symlinkdata3(xdr, args);
5479 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5483 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
5486 static void encode_devicedata3(struct xdr_stream *xdr,
5487 - const struct nfs3_mknodargs *args)
5488 + const struct nfs3_mknodargs *args, int tag)
5490 - encode_sattr3(xdr, args->sattr);
5491 + encode_sattr3(xdr, args->sattr, tag);
5492 encode_specdata3(xdr, args->rdev);
5495 static void encode_mknoddata3(struct xdr_stream *xdr,
5496 - const struct nfs3_mknodargs *args)
5497 + const struct nfs3_mknodargs *args, int tag)
5499 encode_ftype3(xdr, args->type);
5500 switch (args->type) {
5503 - encode_devicedata3(xdr, args);
5504 + encode_devicedata3(xdr, args, tag);
5508 - encode_sattr3(xdr, args->sattr);
5509 + encode_sattr3(xdr, args->sattr, tag);
5513 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5514 const struct nfs3_mknodargs *args)
5516 encode_diropargs3(xdr, args->fh, args->name, args->len);
5517 - encode_mknoddata3(xdr, args);
5518 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5522 diff -NurpP --minimal linux-3.2.5/fs/nfs/super.c linux-3.2.5-vs2.3.2.6/fs/nfs/super.c
5523 --- linux-3.2.5/fs/nfs/super.c 2012-02-07 01:57:54.000000000 +0100
5524 +++ linux-3.2.5-vs2.3.2.6/fs/nfs/super.c 2012-01-26 08:52:10.000000000 +0100
5526 #include <linux/nfs_xdr.h>
5527 #include <linux/magic.h>
5528 #include <linux/parser.h>
5529 +#include <linux/vs_tag.h>
5531 #include <asm/system.h>
5532 #include <asm/uaccess.h>
5533 @@ -87,6 +88,7 @@ enum {
5534 Opt_sharecache, Opt_nosharecache,
5535 Opt_resvport, Opt_noresvport,
5536 Opt_fscache, Opt_nofscache,
5537 + Opt_tag, Opt_notag,
5539 /* Mount options that take integer arguments */
5541 @@ -100,6 +102,7 @@ enum {
5547 /* Mount options that take string arguments */
5548 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
5549 @@ -180,6 +183,10 @@ static const match_table_t nfs_mount_opt
5550 { Opt_fscache_uniq, "fsc=%s" },
5551 { Opt_local_lock, "local_lock=%s" },
5553 + { Opt_tag, "tag" },
5554 + { Opt_notag, "notag" },
5555 + { Opt_tagid, "tagid=%u" },
5560 @@ -650,6 +657,7 @@ static void nfs_show_mount_options(struc
5561 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5562 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5563 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5564 + { NFS_MOUNT_TAGGED, ",tag", "" },
5567 const struct proc_nfs_info *nfs_infop;
5568 @@ -1217,6 +1225,14 @@ static int nfs_parse_mount_options(char
5569 kfree(mnt->fscache_uniq);
5570 mnt->fscache_uniq = NULL;
5572 +#ifndef CONFIG_TAGGING_NONE
5574 + mnt->flags |= NFS_MOUNT_TAGGED;
5577 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5582 * options that take numeric values
5583 @@ -1323,6 +1339,12 @@ static int nfs_parse_mount_options(char
5584 goto out_invalid_value;
5585 mnt->minorversion = option;
5587 +#ifdef CONFIG_PROPAGATE
5590 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5595 * options that take text values
5596 diff -NurpP --minimal linux-3.2.5/fs/nfsd/auth.c linux-3.2.5-vs2.3.2.6/fs/nfsd/auth.c
5597 --- linux-3.2.5/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
5598 +++ linux-3.2.5-vs2.3.2.6/fs/nfsd/auth.c 2011-12-05 19:33:02.000000000 +0100
5600 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
5602 #include <linux/sched.h>
5603 +#include <linux/vs_tag.h>
5607 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5609 new->fsuid = rqstp->rq_cred.cr_uid;
5610 new->fsgid = rqstp->rq_cred.cr_gid;
5611 + /* FIXME: this desperately needs a tag :)
5612 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5615 rqgi = rqstp->rq_cred.cr_group_info;
5617 diff -NurpP --minimal linux-3.2.5/fs/nfsd/nfs3xdr.c linux-3.2.5-vs2.3.2.6/fs/nfsd/nfs3xdr.c
5618 --- linux-3.2.5/fs/nfsd/nfs3xdr.c 2011-07-22 11:18:05.000000000 +0200
5619 +++ linux-3.2.5-vs2.3.2.6/fs/nfsd/nfs3xdr.c 2011-12-05 19:33:02.000000000 +0100
5623 #include <linux/namei.h>
5624 +#include <linux/vs_tag.h>
5628 @@ -95,6 +96,8 @@ static __be32 *
5629 decode_sattr3(__be32 *p, struct iattr *iap)
5637 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
5640 iap->ia_valid |= ATTR_UID;
5641 - iap->ia_uid = ntohl(*p++);
5642 + uid = ntohl(*p++);
5645 iap->ia_valid |= ATTR_GID;
5646 - iap->ia_gid = ntohl(*p++);
5647 + gid = ntohl(*p++);
5649 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5650 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5651 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5655 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5656 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5657 *p++ = htonl((u32) stat->mode);
5658 *p++ = htonl((u32) stat->nlink);
5659 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5660 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5661 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5662 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5663 + stat->uid, stat->tag)));
5664 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5665 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5666 + stat->gid, stat->tag)));
5667 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5668 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5670 diff -NurpP --minimal linux-3.2.5/fs/nfsd/nfs4xdr.c linux-3.2.5-vs2.3.2.6/fs/nfsd/nfs4xdr.c
5671 --- linux-3.2.5/fs/nfsd/nfs4xdr.c 2012-01-09 16:14:54.000000000 +0100
5672 +++ linux-3.2.5-vs2.3.2.6/fs/nfsd/nfs4xdr.c 2011-12-05 19:33:02.000000000 +0100
5674 #include <linux/utsname.h>
5675 #include <linux/pagemap.h>
5676 #include <linux/sunrpc/svcauth_gss.h>
5677 +#include <linux/vs_tag.h>
5681 @@ -2328,14 +2329,18 @@ out_acl:
5682 WRITE32(stat.nlink);
5684 if (bmval1 & FATTR4_WORD1_OWNER) {
5685 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5686 + status = nfsd4_encode_user(rqstp,
5687 + TAGINO_UID(DX_TAG(dentry->d_inode),
5688 + stat.uid, stat.tag), &p, &buflen);
5689 if (status == nfserr_resource)
5694 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5695 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5696 + status = nfsd4_encode_group(rqstp,
5697 + TAGINO_GID(DX_TAG(dentry->d_inode),
5698 + stat.gid, stat.tag), &p, &buflen);
5699 if (status == nfserr_resource)
5702 diff -NurpP --minimal linux-3.2.5/fs/nfsd/nfsxdr.c linux-3.2.5-vs2.3.2.6/fs/nfsd/nfsxdr.c
5703 --- linux-3.2.5/fs/nfsd/nfsxdr.c 2011-05-22 16:17:53.000000000 +0200
5704 +++ linux-3.2.5-vs2.3.2.6/fs/nfsd/nfsxdr.c 2011-12-05 19:33:02.000000000 +0100
5709 +#include <linux/vs_tag.h>
5711 #define NFSDDBG_FACILITY NFSDDBG_XDR
5713 @@ -88,6 +89,8 @@ static __be32 *
5714 decode_sattr(__be32 *p, struct iattr *iap)
5722 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
5724 if ((tmp = ntohl(*p++)) != (u32)-1) {
5725 iap->ia_valid |= ATTR_UID;
5726 - iap->ia_uid = tmp;
5729 if ((tmp = ntohl(*p++)) != (u32)-1) {
5730 iap->ia_valid |= ATTR_GID;
5731 - iap->ia_gid = tmp;
5734 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5735 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5736 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5737 if ((tmp = ntohl(*p++)) != (u32)-1) {
5738 iap->ia_valid |= ATTR_SIZE;
5740 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5741 *p++ = htonl(nfs_ftypes[type >> 12]);
5742 *p++ = htonl((u32) stat->mode);
5743 *p++ = htonl((u32) stat->nlink);
5744 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5745 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5746 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5747 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5748 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5749 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5751 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5752 *p++ = htonl(NFS_MAXPATHLEN);
5753 diff -NurpP --minimal linux-3.2.5/fs/ocfs2/dlmglue.c linux-3.2.5-vs2.3.2.6/fs/ocfs2/dlmglue.c
5754 --- linux-3.2.5/fs/ocfs2/dlmglue.c 2012-01-09 16:14:55.000000000 +0100
5755 +++ linux-3.2.5-vs2.3.2.6/fs/ocfs2/dlmglue.c 2011-12-05 19:33:02.000000000 +0100
5756 @@ -2047,6 +2047,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5757 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5758 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
5759 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
5760 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
5761 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5762 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5763 lvb->lvb_iatime_packed =
5764 @@ -2097,6 +2098,7 @@ static void ocfs2_refresh_inode_from_lvb
5766 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
5767 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
5768 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
5769 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5770 set_nlink(inode, be16_to_cpu(lvb->lvb_inlink));
5771 ocfs2_unpack_timespec(&inode->i_atime,
5772 diff -NurpP --minimal linux-3.2.5/fs/ocfs2/dlmglue.h linux-3.2.5-vs2.3.2.6/fs/ocfs2/dlmglue.h
5773 --- linux-3.2.5/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
5774 +++ linux-3.2.5-vs2.3.2.6/fs/ocfs2/dlmglue.h 2011-12-05 19:33:02.000000000 +0100
5775 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5778 __be32 lvb_igeneration;
5779 - __be32 lvb_reserved2;
5781 + __be16 lvb_reserved2;
5784 #define OCFS2_QINFO_LVB_VERSION 1
5785 diff -NurpP --minimal linux-3.2.5/fs/ocfs2/file.c linux-3.2.5-vs2.3.2.6/fs/ocfs2/file.c
5786 --- linux-3.2.5/fs/ocfs2/file.c 2012-01-09 16:14:55.000000000 +0100
5787 +++ linux-3.2.5-vs2.3.2.6/fs/ocfs2/file.c 2011-12-05 19:33:02.000000000 +0100
5788 @@ -1123,7 +1123,7 @@ int ocfs2_setattr(struct dentry *dentry,
5789 attr->ia_valid &= ~ATTR_SIZE;
5791 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5792 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5793 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5794 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5797 diff -NurpP --minimal linux-3.2.5/fs/ocfs2/inode.c linux-3.2.5-vs2.3.2.6/fs/ocfs2/inode.c
5798 --- linux-3.2.5/fs/ocfs2/inode.c 2012-01-09 16:14:55.000000000 +0100
5799 +++ linux-3.2.5-vs2.3.2.6/fs/ocfs2/inode.c 2011-12-05 19:33:02.000000000 +0100
5801 #include <linux/highmem.h>
5802 #include <linux/pagemap.h>
5803 #include <linux/quotaops.h>
5804 +#include <linux/vs_tag.h>
5806 #include <asm/byteorder.h>
5808 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5810 unsigned int flags = OCFS2_I(inode)->ip_attr;
5812 - inode->i_flags &= ~(S_IMMUTABLE |
5813 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5814 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5816 if (flags & OCFS2_IMMUTABLE_FL)
5817 inode->i_flags |= S_IMMUTABLE;
5818 + if (flags & OCFS2_IXUNLINK_FL)
5819 + inode->i_flags |= S_IXUNLINK;
5821 if (flags & OCFS2_SYNC_FL)
5822 inode->i_flags |= S_SYNC;
5823 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5824 inode->i_flags |= S_NOATIME;
5825 if (flags & OCFS2_DIRSYNC_FL)
5826 inode->i_flags |= S_DIRSYNC;
5828 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5830 + if (flags & OCFS2_BARRIER_FL)
5831 + inode->i_vflags |= V_BARRIER;
5832 + if (flags & OCFS2_COW_FL)
5833 + inode->i_vflags |= V_COW;
5836 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5837 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5839 unsigned int flags = oi->vfs_inode.i_flags;
5840 + unsigned int vflags = oi->vfs_inode.i_vflags;
5842 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5843 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5844 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5845 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5847 + if (flags & S_IMMUTABLE)
5848 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5849 + if (flags & S_IXUNLINK)
5850 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5852 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5853 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5855 oi->ip_attr |= OCFS2_SYNC_FL;
5856 if (flags & S_APPEND)
5857 oi->ip_attr |= OCFS2_APPEND_FL;
5858 - if (flags & S_IMMUTABLE)
5859 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5860 if (flags & S_NOATIME)
5861 oi->ip_attr |= OCFS2_NOATIME_FL;
5862 if (flags & S_DIRSYNC)
5863 oi->ip_attr |= OCFS2_DIRSYNC_FL;
5865 + if (vflags & V_BARRIER)
5866 + oi->ip_attr |= OCFS2_BARRIER_FL;
5867 + if (vflags & V_COW)
5868 + oi->ip_attr |= OCFS2_COW_FL;
5871 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
5872 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
5873 struct super_block *sb;
5874 struct ocfs2_super *osb;
5881 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
5882 inode->i_generation = le32_to_cpu(fe->i_generation);
5883 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
5884 inode->i_mode = le16_to_cpu(fe->i_mode);
5885 - inode->i_uid = le32_to_cpu(fe->i_uid);
5886 - inode->i_gid = le32_to_cpu(fe->i_gid);
5887 + uid = le32_to_cpu(fe->i_uid);
5888 + gid = le32_to_cpu(fe->i_gid);
5889 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5890 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5891 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5892 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
5894 /* Fast symlinks will have i_size but no allocated clusters. */
5895 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
5896 diff -NurpP --minimal linux-3.2.5/fs/ocfs2/inode.h linux-3.2.5-vs2.3.2.6/fs/ocfs2/inode.h
5897 --- linux-3.2.5/fs/ocfs2/inode.h 2012-01-09 16:14:55.000000000 +0100
5898 +++ linux-3.2.5-vs2.3.2.6/fs/ocfs2/inode.h 2011-12-05 19:33:02.000000000 +0100
5899 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
5901 void ocfs2_set_inode_flags(struct inode *inode);
5902 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
5903 +int ocfs2_sync_flags(struct inode *inode, int, int);
5905 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
5907 diff -NurpP --minimal linux-3.2.5/fs/ocfs2/ioctl.c linux-3.2.5-vs2.3.2.6/fs/ocfs2/ioctl.c
5908 --- linux-3.2.5/fs/ocfs2/ioctl.c 2012-01-09 16:14:55.000000000 +0100
5909 +++ linux-3.2.5-vs2.3.2.6/fs/ocfs2/ioctl.c 2011-12-05 19:33:02.000000000 +0100
5910 @@ -78,7 +78,41 @@ static int ocfs2_get_inode_attr(struct i
5914 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5915 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
5917 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5918 + struct buffer_head *bh = NULL;
5919 + handle_t *handle = NULL;
5922 + status = ocfs2_inode_lock(inode, &bh, 1);
5924 + mlog_errno(status);
5927 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5928 + if (IS_ERR(handle)) {
5929 + status = PTR_ERR(handle);
5930 + mlog_errno(status);
5934 + inode->i_flags = flags;
5935 + inode->i_vflags = vflags;
5936 + ocfs2_get_inode_flags(OCFS2_I(inode));
5938 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
5940 + mlog_errno(status);
5942 + ocfs2_commit_trans(osb, handle);
5944 + ocfs2_inode_unlock(inode, 1);
5949 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5952 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
5953 @@ -103,6 +137,11 @@ static int ocfs2_set_inode_attr(struct i
5954 if (!S_ISDIR(inode->i_mode))
5955 flags &= ~OCFS2_DIRSYNC_FL;
5957 + if (IS_BARRIER(inode)) {
5958 + vxwprintk_task(1, "messing with the barrier.");
5962 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5963 if (IS_ERR(handle)) {
5964 status = PTR_ERR(handle);
5965 @@ -881,6 +920,7 @@ bail:
5970 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5972 struct inode *inode = filp->f_path.dentry->d_inode;
5973 diff -NurpP --minimal linux-3.2.5/fs/ocfs2/namei.c linux-3.2.5-vs2.3.2.6/fs/ocfs2/namei.c
5974 --- linux-3.2.5/fs/ocfs2/namei.c 2012-01-09 16:14:55.000000000 +0100
5975 +++ linux-3.2.5-vs2.3.2.6/fs/ocfs2/namei.c 2011-12-05 19:33:02.000000000 +0100
5977 #include <linux/slab.h>
5978 #include <linux/highmem.h>
5979 #include <linux/quotaops.h>
5980 +#include <linux/vs_tag.h>
5982 #include <cluster/masklog.h>
5984 @@ -475,6 +476,7 @@ static int __ocfs2_mknod_locked(struct i
5985 struct ocfs2_dinode *fe = NULL;
5986 struct ocfs2_extent_list *fel;
5992 @@ -512,8 +514,11 @@ static int __ocfs2_mknod_locked(struct i
5993 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
5994 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
5995 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
5996 - fe->i_uid = cpu_to_le32(inode->i_uid);
5997 - fe->i_gid = cpu_to_le32(inode->i_gid);
5999 + tag = dx_current_fstag(osb->sb);
6000 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6001 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6002 + inode->i_tag = tag;
6003 fe->i_mode = cpu_to_le16(inode->i_mode);
6004 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6005 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6006 diff -NurpP --minimal linux-3.2.5/fs/ocfs2/ocfs2.h linux-3.2.5-vs2.3.2.6/fs/ocfs2/ocfs2.h
6007 --- linux-3.2.5/fs/ocfs2/ocfs2.h 2012-01-09 16:14:55.000000000 +0100
6008 +++ linux-3.2.5-vs2.3.2.6/fs/ocfs2/ocfs2.h 2011-12-05 19:33:02.000000000 +0100
6009 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
6011 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
6012 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
6013 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
6016 #define OCFS2_OSB_SOFT_RO 0x0001
6017 diff -NurpP --minimal linux-3.2.5/fs/ocfs2/ocfs2_fs.h linux-3.2.5-vs2.3.2.6/fs/ocfs2/ocfs2_fs.h
6018 --- linux-3.2.5/fs/ocfs2/ocfs2_fs.h 2011-05-22 16:17:53.000000000 +0200
6019 +++ linux-3.2.5-vs2.3.2.6/fs/ocfs2/ocfs2_fs.h 2011-12-05 19:33:02.000000000 +0100
6020 @@ -266,6 +266,11 @@
6021 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
6022 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
6024 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6026 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6027 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6029 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
6030 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
6032 diff -NurpP --minimal linux-3.2.5/fs/ocfs2/super.c linux-3.2.5-vs2.3.2.6/fs/ocfs2/super.c
6033 --- linux-3.2.5/fs/ocfs2/super.c 2012-01-09 16:14:55.000000000 +0100
6034 +++ linux-3.2.5-vs2.3.2.6/fs/ocfs2/super.c 2011-12-05 19:33:02.000000000 +0100
6035 @@ -185,6 +185,7 @@ enum {
6039 + Opt_tag, Opt_notag, Opt_tagid,
6043 @@ -216,6 +217,9 @@ static const match_table_t tokens = {
6044 {Opt_coherency_full, "coherency=full"},
6045 {Opt_resv_level, "resv_level=%u"},
6046 {Opt_dir_resv_level, "dir_resv_level=%u"},
6048 + {Opt_notag, "notag"},
6049 + {Opt_tagid, "tagid=%u"},
6053 @@ -663,6 +667,13 @@ static int ocfs2_remount(struct super_bl
6057 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6058 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6060 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6064 /* We're going to/from readonly mode. */
6065 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
6066 /* Disable quota accounting before remounting RO */
6067 @@ -1178,6 +1189,9 @@ static int ocfs2_fill_super(struct super
6069 ocfs2_complete_mount_recovery(osb);
6071 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6072 + sb->s_flags |= MS_TAGGED;
6074 if (ocfs2_mount_local(osb))
6075 snprintf(nodestr, sizeof(nodestr), "local");
6077 @@ -1507,6 +1521,20 @@ static int ocfs2_parse_options(struct su
6078 option < OCFS2_MAX_RESV_LEVEL)
6079 mopt->dir_resv_level = option;
6081 +#ifndef CONFIG_TAGGING_NONE
6083 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6086 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6089 +#ifdef CONFIG_PROPAGATE
6092 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6097 "Unrecognized mount option \"%s\" "
6098 diff -NurpP --minimal linux-3.2.5/fs/open.c linux-3.2.5-vs2.3.2.6/fs/open.c
6099 --- linux-3.2.5/fs/open.c 2012-01-09 16:14:55.000000000 +0100
6100 +++ linux-3.2.5-vs2.3.2.6/fs/open.c 2011-12-05 19:33:02.000000000 +0100
6102 #include <linux/fs_struct.h>
6103 #include <linux/ima.h>
6104 #include <linux/dnotify.h>
6105 +#include <linux/vs_base.h>
6106 +#include <linux/vs_limit.h>
6107 +#include <linux/vs_tag.h>
6108 +#include <linux/vs_cowbl.h>
6109 +#include <linux/vserver/dlimit.h>
6111 #include "internal.h"
6113 @@ -74,6 +79,12 @@ static long do_sys_truncate(const char _
6114 error = user_path(pathname, &path);
6118 +#ifdef CONFIG_VSERVER_COWBL
6119 + error = cow_check_and_break(&path);
6121 + goto dput_and_out;
6123 inode = path.dentry->d_inode;
6125 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
6126 @@ -489,6 +500,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6128 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6130 +#ifdef CONFIG_VSERVER_COWBL
6131 + error = cow_check_and_break(&path);
6134 error = chmod_common(&path, mode);
6137 @@ -509,11 +524,11 @@ static int chown_common(struct path *pat
6138 newattrs.ia_valid = ATTR_CTIME;
6139 if (user != (uid_t) -1) {
6140 newattrs.ia_valid |= ATTR_UID;
6141 - newattrs.ia_uid = user;
6142 + newattrs.ia_uid = dx_map_uid(user);
6144 if (group != (gid_t) -1) {
6145 newattrs.ia_valid |= ATTR_GID;
6146 - newattrs.ia_gid = group;
6147 + newattrs.ia_gid = dx_map_gid(group);
6149 if (!S_ISDIR(inode->i_mode))
6150 newattrs.ia_valid |=
6151 @@ -538,6 +553,10 @@ SYSCALL_DEFINE3(chown, const char __user
6152 error = mnt_want_write(path.mnt);
6155 +#ifdef CONFIG_VSERVER_COWBL
6156 + error = cow_check_and_break(&path);
6159 error = chown_common(&path, user, group);
6160 mnt_drop_write(path.mnt);
6162 @@ -565,6 +584,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6163 error = mnt_want_write(path.mnt);
6166 +#ifdef CONFIG_VSERVER_COWBL
6167 + error = cow_check_and_break(&path);
6170 error = chown_common(&path, user, group);
6171 mnt_drop_write(path.mnt);
6173 @@ -584,6 +607,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6174 error = mnt_want_write(path.mnt);
6177 +#ifdef CONFIG_VSERVER_COWBL
6178 + error = cow_check_and_break(&path);
6181 error = chown_common(&path, user, group);
6182 mnt_drop_write(path.mnt);
6184 @@ -839,6 +866,7 @@ static void __put_unused_fd(struct files
6185 __FD_CLR(fd, fdt->open_fds);
6186 if (fd < files->next_fd)
6187 files->next_fd = fd;
6188 + vx_openfd_dec(fd);
6191 void put_unused_fd(unsigned int fd)
6192 diff -NurpP --minimal linux-3.2.5/fs/proc/array.c linux-3.2.5-vs2.3.2.6/fs/proc/array.c
6193 --- linux-3.2.5/fs/proc/array.c 2011-10-24 18:45:27.000000000 +0200
6194 +++ linux-3.2.5-vs2.3.2.6/fs/proc/array.c 2011-12-05 19:33:02.000000000 +0100
6196 #include <linux/pid_namespace.h>
6197 #include <linux/ptrace.h>
6198 #include <linux/tracehook.h>
6199 +#include <linux/vs_context.h>
6200 +#include <linux/vs_network.h>
6202 #include <asm/pgtable.h>
6203 #include <asm/processor.h>
6204 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6206 ppid = pid_alive(p) ?
6207 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6208 + if (unlikely(vx_current_initpid(p->pid)))
6213 struct task_struct *tracer = ptrace_parent(p);
6214 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6217 static void render_cap_t(struct seq_file *m, const char *header,
6219 + struct vx_info *vxi, kernel_cap_t *a)
6223 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6224 cap_bset = cred->cap_bset;
6227 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6228 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6229 - render_cap_t(m, "CapEff:\t", &cap_effective);
6230 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6231 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6232 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6233 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6234 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6235 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6238 static inline void task_context_switch_counts(struct seq_file *m,
6239 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6243 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6244 + struct pid *pid, struct task_struct *task)
6246 + seq_printf(m, "Proxy:\t%p(%c)\n"
6254 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6255 + atomic_read(&task->nsproxy->count),
6256 + task->nsproxy->uts_ns,
6257 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6258 + task->nsproxy->ipc_ns,
6259 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6260 + task->nsproxy->mnt_ns,
6261 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6262 + task->nsproxy->pid_ns,
6263 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6264 + task->nsproxy->net_ns,
6265 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6269 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6271 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6274 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6275 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6279 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6280 struct pid *pid, struct task_struct *task)
6282 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6284 task_cpus_allowed(m, task);
6285 cpuset_task_status_allowed(m, task);
6286 + task_vs_id(m, task);
6287 task_context_switch_counts(m, task);
6290 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file
6291 /* convert nsec -> ticks */
6292 start_time = nsec_to_clock_t(start_time);
6294 + /* fixup start time for virt uptime */
6295 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6296 + unsigned long long bias =
6297 + current->vx_info->cvirt.bias_clock;
6299 + if (start_time > bias)
6300 + start_time -= bias;
6305 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6306 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6307 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6308 diff -NurpP --minimal linux-3.2.5/fs/proc/base.c linux-3.2.5-vs2.3.2.6/fs/proc/base.c
6309 --- linux-3.2.5/fs/proc/base.c 2012-02-07 01:57:54.000000000 +0100
6310 +++ linux-3.2.5-vs2.3.2.6/fs/proc/base.c 2012-01-26 08:52:10.000000000 +0100
6312 #include <linux/pid_namespace.h>
6313 #include <linux/fs_struct.h>
6314 #include <linux/slab.h>
6315 +#include <linux/vs_context.h>
6316 +#include <linux/vs_network.h>
6317 #ifdef CONFIG_HARDWALL
6318 #include <asm/hardwall.h>
6320 @@ -1035,11 +1037,16 @@ static ssize_t oom_adjust_write(struct f
6324 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6325 + if (oom_adjust < task->signal->oom_adj &&
6326 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6331 + /* prevent guest processes from circumventing the oom killer */
6332 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6333 + oom_adjust = OOM_ADJUST_MIN;
6336 * Warn that /proc/pid/oom_adj is deprecated, see
6337 * Documentation/feature-removal-schedule.txt.
6338 @@ -1194,7 +1201,7 @@ static ssize_t proc_loginuid_write(struc
6342 - if (!capable(CAP_AUDIT_CONTROL))
6343 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6347 @@ -1641,6 +1648,8 @@ struct inode *proc_pid_make_inode(struct
6348 inode->i_gid = cred->egid;
6351 + /* procfs is xid tagged */
6352 + inode->i_tag = (tag_t)vx_task_xid(task);
6353 security_task_to_inode(task, inode);
6356 @@ -1677,6 +1686,8 @@ int pid_getattr(struct vfsmount *mnt, st
6360 +static unsigned name_to_int(struct dentry *dentry);
6363 * Exceptional case: normally we are not allowed to unhash a busy
6364 * directory. In this case, however, we can do it - no aliasing problems
6365 @@ -1705,6 +1716,12 @@ int pid_revalidate(struct dentry *dentry
6366 task = get_proc_task(inode);
6369 + unsigned pid = name_to_int(dentry);
6371 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6372 + put_task_struct(task);
6375 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6376 task_dumpable(task)) {
6378 @@ -1721,6 +1738,7 @@ int pid_revalidate(struct dentry *dentry
6379 put_task_struct(task);
6386 @@ -2210,6 +2228,13 @@ static struct dentry *proc_pident_lookup
6390 + /* TODO: maybe we can come up with a generic approach? */
6391 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6392 + (dentry->d_name.len == 5) &&
6393 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6394 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6398 * Yes, it does not scale. And it should not. Don't add
6399 * new entries into /proc/<tgid>/ without very good reasons.
6400 @@ -2595,7 +2620,7 @@ out_iput:
6401 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6403 struct dentry *error;
6404 - struct task_struct *task = get_proc_task(dir);
6405 + struct task_struct *task = get_proc_task_real(dir);
6406 const struct pid_entry *p, *last;
6408 error = ERR_PTR(-ENOENT);
6409 @@ -2702,6 +2727,9 @@ static int proc_pid_personality(struct s
6410 static const struct file_operations proc_task_operations;
6411 static const struct inode_operations proc_task_inode_operations;
6413 +extern int proc_pid_vx_info(struct task_struct *, char *);
6414 +extern int proc_pid_nx_info(struct task_struct *, char *);
6416 static const struct pid_entry tgid_base_stuff[] = {
6417 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6418 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6419 @@ -2765,6 +2793,8 @@ static const struct pid_entry tgid_base_
6420 #ifdef CONFIG_CGROUPS
6421 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6423 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6424 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6425 INF("oom_score", S_IRUGO, proc_oom_score),
6426 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6427 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6428 @@ -2784,6 +2814,7 @@ static const struct pid_entry tgid_base_
6429 #ifdef CONFIG_HARDWALL
6430 INF("hardwall", S_IRUGO, proc_pid_hardwall),
6432 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6435 static int proc_tgid_base_readdir(struct file * filp,
6436 @@ -2976,7 +3007,7 @@ retry:
6438 pid = find_ge_pid(iter.tgid, ns);
6440 - iter.tgid = pid_nr_ns(pid, ns);
6441 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6442 iter.task = pid_task(pid, PIDTYPE_PID);
6443 /* What we to know is if the pid we have find is the
6444 * pid of a thread_group_leader. Testing for task
6445 @@ -3006,7 +3037,7 @@ static int proc_pid_fill_cache(struct fi
6446 struct tgid_iter iter)
6448 char name[PROC_NUMBUF];
6449 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6450 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6451 return proc_fill_cache(filp, dirent, filldir, name, len,
6452 proc_pid_instantiate, iter.task, NULL);
6454 @@ -3023,7 +3054,7 @@ int proc_pid_readdir(struct file * filp,
6456 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6458 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
6459 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6463 @@ -3040,6 +3071,8 @@ int proc_pid_readdir(struct file * filp,
6465 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6466 filp->f_pos = iter.tgid + TGID_OFFSET;
6467 + if (!vx_proc_task_visible(iter.task))
6469 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6470 put_task_struct(iter.task);
6472 @@ -3193,6 +3226,8 @@ static struct dentry *proc_task_lookup(s
6473 tid = name_to_int(dentry);
6476 + if (vx_current_initpid(tid))
6479 ns = dentry->d_sb->s_fs_info;
6481 diff -NurpP --minimal linux-3.2.5/fs/proc/generic.c linux-3.2.5-vs2.3.2.6/fs/proc/generic.c
6482 --- linux-3.2.5/fs/proc/generic.c 2012-01-09 16:14:55.000000000 +0100
6483 +++ linux-3.2.5-vs2.3.2.6/fs/proc/generic.c 2011-12-05 19:33:02.000000000 +0100
6485 #include <linux/bitops.h>
6486 #include <linux/spinlock.h>
6487 #include <linux/completion.h>
6488 +#include <linux/vserver/inode.h>
6489 #include <asm/uaccess.h>
6491 #include "internal.h"
6492 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
6493 for (de = de->subdir; de ; de = de->next) {
6494 if (de->namelen != dentry->d_name.len)
6496 + if (!vx_hide_check(0, de->vx_flags))
6498 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6500 spin_unlock(&proc_subdir_lock);
6502 inode = proc_get_inode(dir->i_sb, de);
6503 + /* generic proc entries belong to the host */
6508 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
6510 /* filldir passes info to user space */
6512 + if (!vx_hide_check(0, de->vx_flags))
6514 spin_unlock(&proc_subdir_lock);
6515 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6516 de->low_ino, de->mode >> 12) < 0) {
6517 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
6520 spin_lock(&proc_subdir_lock);
6525 @@ -626,6 +634,7 @@ static struct proc_dir_entry *__proc_cre
6527 atomic_set(&ent->count, 1);
6529 + ent->vx_flags = IATTR_PROC_DEFAULT;
6530 spin_lock_init(&ent->pde_unload_lock);
6531 ent->pde_unload_completion = NULL;
6532 INIT_LIST_HEAD(&ent->pde_openers);
6533 @@ -649,7 +658,8 @@ struct proc_dir_entry *proc_symlink(cons
6539 + ent->vx_flags = IATTR_PROC_SYMLINK;
6543 diff -NurpP --minimal linux-3.2.5/fs/proc/inode.c linux-3.2.5-vs2.3.2.6/fs/proc/inode.c
6544 --- linux-3.2.5/fs/proc/inode.c 2012-01-09 16:14:55.000000000 +0100
6545 +++ linux-3.2.5-vs2.3.2.6/fs/proc/inode.c 2011-12-05 19:33:02.000000000 +0100
6546 @@ -442,6 +442,8 @@ struct inode *proc_get_inode(struct supe
6547 inode->i_uid = de->uid;
6548 inode->i_gid = de->gid;
6551 + PROC_I(inode)->vx_flags = de->vx_flags;
6553 inode->i_size = de->size;
6555 diff -NurpP --minimal linux-3.2.5/fs/proc/internal.h linux-3.2.5-vs2.3.2.6/fs/proc/internal.h
6556 --- linux-3.2.5/fs/proc/internal.h 2011-07-22 11:18:06.000000000 +0200
6557 +++ linux-3.2.5-vs2.3.2.6/fs/proc/internal.h 2011-12-05 19:33:02.000000000 +0100
6561 #include <linux/proc_fs.h>
6562 +#include <linux/vs_pid.h>
6564 extern struct proc_dir_entry proc_root;
6565 #ifdef CONFIG_PROC_SYSCTL
6566 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
6567 struct pid *pid, struct task_struct *task);
6568 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6569 struct pid *pid, struct task_struct *task);
6570 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6571 + struct pid *pid, struct task_struct *task);
6573 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6575 extern const struct file_operations proc_maps_operations;
6576 @@ -76,11 +80,16 @@ static inline struct pid *proc_pid(struc
6577 return PROC_I(inode)->pid;
6580 -static inline struct task_struct *get_proc_task(struct inode *inode)
6581 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6583 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6586 +static inline struct task_struct *get_proc_task(struct inode *inode)
6588 + return vx_get_proc_task(inode, proc_pid(inode));
6591 static inline int proc_fd(struct inode *inode)
6593 return PROC_I(inode)->fd;
6594 diff -NurpP --minimal linux-3.2.5/fs/proc/loadavg.c linux-3.2.5-vs2.3.2.6/fs/proc/loadavg.c
6595 --- linux-3.2.5/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
6596 +++ linux-3.2.5-vs2.3.2.6/fs/proc/loadavg.c 2011-12-05 19:33:02.000000000 +0100
6599 static int loadavg_proc_show(struct seq_file *m, void *v)
6601 + unsigned long running;
6602 + unsigned int threads;
6603 unsigned long avnrun[3];
6605 get_avenrun(avnrun, FIXED_1/200, 0);
6607 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6608 + struct vx_info *vxi = current_vx_info();
6610 + running = atomic_read(&vxi->cvirt.nr_running);
6611 + threads = atomic_read(&vxi->cvirt.nr_threads);
6613 + running = nr_running();
6614 + threads = nr_threads;
6617 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6618 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6619 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6620 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6621 - nr_running(), nr_threads,
6623 task_active_pid_ns(current)->last_pid);
6626 diff -NurpP --minimal linux-3.2.5/fs/proc/meminfo.c linux-3.2.5-vs2.3.2.6/fs/proc/meminfo.c
6627 --- linux-3.2.5/fs/proc/meminfo.c 2012-01-09 16:14:55.000000000 +0100
6628 +++ linux-3.2.5-vs2.3.2.6/fs/proc/meminfo.c 2011-12-15 01:11:32.000000000 +0100
6629 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6630 allowed = ((totalram_pages - hugetlb_total_pages())
6631 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6633 - cached = global_page_state(NR_FILE_PAGES) -
6634 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6635 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6636 total_swapcache_pages - i.bufferram;
6639 diff -NurpP --minimal linux-3.2.5/fs/proc/root.c linux-3.2.5-vs2.3.2.6/fs/proc/root.c
6640 --- linux-3.2.5/fs/proc/root.c 2012-01-09 16:14:55.000000000 +0100
6641 +++ linux-3.2.5-vs2.3.2.6/fs/proc/root.c 2012-01-09 16:19:31.000000000 +0100
6643 #include <linux/bitops.h>
6644 #include <linux/mount.h>
6645 #include <linux/pid_namespace.h>
6646 +#include <linux/vserver/inode.h>
6648 #include "internal.h"
6650 +struct proc_dir_entry *proc_virtual;
6652 +extern void proc_vx_init(void);
6654 static int proc_test_super(struct super_block *sb, void *data)
6656 return sb->s_fs_info == data;
6657 @@ -123,6 +128,7 @@ void __init proc_root_init(void)
6659 proc_mkdir("bus", NULL);
6664 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6665 @@ -190,6 +196,7 @@ struct proc_dir_entry proc_root = {
6666 .proc_iops = &proc_root_inode_operations,
6667 .proc_fops = &proc_root_operations,
6668 .parent = &proc_root,
6669 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6673 diff -NurpP --minimal linux-3.2.5/fs/proc/uptime.c linux-3.2.5-vs2.3.2.6/fs/proc/uptime.c
6674 --- linux-3.2.5/fs/proc/uptime.c 2012-02-07 01:57:54.000000000 +0100
6675 +++ linux-3.2.5-vs2.3.2.6/fs/proc/uptime.c 2012-01-26 09:03:19.000000000 +0100
6677 #include <linux/seq_file.h>
6678 #include <linux/time.h>
6679 #include <linux/kernel_stat.h>
6680 +#include <linux/vserver/cvirt.h>
6681 #include <asm/cputime.h>
6683 static int uptime_proc_show(struct seq_file *m, void *v)
6684 @@ -25,6 +26,10 @@ static int uptime_proc_show(struct seq_f
6685 nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
6686 idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
6689 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6690 + vx_vsi_uptime(&uptime, &idle);
6692 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6693 (unsigned long) uptime.tv_sec,
6694 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6695 diff -NurpP --minimal linux-3.2.5/fs/quota/dquot.c linux-3.2.5-vs2.3.2.6/fs/quota/dquot.c
6696 --- linux-3.2.5/fs/quota/dquot.c 2011-07-22 11:18:06.000000000 +0200
6697 +++ linux-3.2.5-vs2.3.2.6/fs/quota/dquot.c 2011-12-05 19:33:02.000000000 +0100
6698 @@ -1548,6 +1548,9 @@ int __dquot_alloc_space(struct inode *in
6699 int reserve = flags & DQUOT_SPACE_RESERVE;
6700 int nofail = flags & DQUOT_SPACE_NOFAIL;
6702 + if ((ret = dl_alloc_space(inode, number)))
6706 * First test before acquiring mutex - solves deadlocks when we
6707 * re-enter the quota code and are already holding the mutex
6708 @@ -1602,6 +1605,9 @@ int dquot_alloc_inode(const struct inode
6710 char warntype[MAXQUOTAS];
6712 + if ((ret = dl_alloc_inode(inode)))
6715 /* First test before acquiring mutex - solves deadlocks when we
6716 * re-enter the quota code and are already holding the mutex */
6717 if (!dquot_active(inode))
6718 @@ -1672,6 +1678,8 @@ void __dquot_free_space(struct inode *in
6719 char warntype[MAXQUOTAS];
6720 int reserve = flags & DQUOT_SPACE_RESERVE;
6722 + dl_free_space(inode, number);
6724 /* First test before acquiring mutex - solves deadlocks when we
6725 * re-enter the quota code and are already holding the mutex */
6726 if (!dquot_active(inode)) {
6727 @@ -1710,6 +1718,8 @@ void dquot_free_inode(const struct inode
6729 char warntype[MAXQUOTAS];
6731 + dl_free_inode(inode);
6733 /* First test before acquiring mutex - solves deadlocks when we
6734 * re-enter the quota code and are already holding the mutex */
6735 if (!dquot_active(inode))
6736 diff -NurpP --minimal linux-3.2.5/fs/quota/quota.c linux-3.2.5-vs2.3.2.6/fs/quota/quota.c
6737 --- linux-3.2.5/fs/quota/quota.c 2012-01-09 16:14:55.000000000 +0100
6738 +++ linux-3.2.5-vs2.3.2.6/fs/quota/quota.c 2011-12-05 19:33:02.000000000 +0100
6740 #include <linux/fs.h>
6741 #include <linux/namei.h>
6742 #include <linux/slab.h>
6743 +#include <linux/vs_context.h>
6744 #include <asm/current.h>
6745 #include <asm/uaccess.h>
6746 #include <linux/kernel.h>
6747 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
6751 - if (!capable(CAP_SYS_ADMIN))
6752 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6756 @@ -293,6 +294,46 @@ static int do_quotactl(struct super_bloc
6760 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6762 +#include <linux/vroot.h>
6763 +#include <linux/major.h>
6764 +#include <linux/module.h>
6765 +#include <linux/kallsyms.h>
6766 +#include <linux/vserver/debug.h>
6768 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6770 +static DEFINE_SPINLOCK(vroot_grb_lock);
6772 +int register_vroot_grb(vroot_grb_func *func) {
6775 + spin_lock(&vroot_grb_lock);
6776 + if (!vroot_get_real_bdev) {
6777 + vroot_get_real_bdev = func;
6780 + spin_unlock(&vroot_grb_lock);
6783 +EXPORT_SYMBOL(register_vroot_grb);
6785 +int unregister_vroot_grb(vroot_grb_func *func) {
6786 + int ret = -EINVAL;
6788 + spin_lock(&vroot_grb_lock);
6789 + if (vroot_get_real_bdev) {
6790 + vroot_get_real_bdev = NULL;
6793 + spin_unlock(&vroot_grb_lock);
6796 +EXPORT_SYMBOL(unregister_vroot_grb);
6801 * look up a superblock on which quota ops will be performed
6802 * - use the name of a block device to find the superblock thereon
6803 @@ -310,6 +351,22 @@ static struct super_block *quotactl_bloc
6806 return ERR_CAST(bdev);
6807 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6808 + if (bdev && bdev->bd_inode &&
6809 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6810 + struct block_device *bdnew = (void *)-EINVAL;
6812 + if (vroot_get_real_bdev)
6813 + bdnew = vroot_get_real_bdev(bdev);
6815 + vxdprintk(VXD_CBIT(misc, 0),
6816 + "vroot_get_real_bdev not set");
6818 + if (IS_ERR(bdnew))
6819 + return ERR_PTR(PTR_ERR(bdnew));
6823 sb = get_super(bdev);
6826 diff -NurpP --minimal linux-3.2.5/fs/reiserfs/file.c linux-3.2.5-vs2.3.2.6/fs/reiserfs/file.c
6827 --- linux-3.2.5/fs/reiserfs/file.c 2011-10-24 18:45:27.000000000 +0200
6828 +++ linux-3.2.5-vs2.3.2.6/fs/reiserfs/file.c 2011-12-05 19:33:02.000000000 +0100
6829 @@ -319,5 +319,6 @@ const struct inode_operations reiserfs_f
6830 .listxattr = reiserfs_listxattr,
6831 .removexattr = reiserfs_removexattr,
6832 .permission = reiserfs_permission,
6833 + .sync_flags = reiserfs_sync_flags,
6834 .get_acl = reiserfs_get_acl,
6836 diff -NurpP --minimal linux-3.2.5/fs/reiserfs/inode.c linux-3.2.5-vs2.3.2.6/fs/reiserfs/inode.c
6837 --- linux-3.2.5/fs/reiserfs/inode.c 2012-01-09 16:14:55.000000000 +0100
6838 +++ linux-3.2.5-vs2.3.2.6/fs/reiserfs/inode.c 2011-12-05 21:18:16.000000000 +0100
6840 #include <linux/writeback.h>
6841 #include <linux/quotaops.h>
6842 #include <linux/swap.h>
6843 +#include <linux/vs_tag.h>
6845 int reiserfs_commit_write(struct file *f, struct page *page,
6846 unsigned from, unsigned to);
6847 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
6848 struct buffer_head *bh;
6849 struct item_head *ih;
6853 //int version = ITEM_VERSION_1;
6855 bh = PATH_PLAST_BUFFER(path);
6856 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
6857 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
6858 unsigned long blocks;
6860 + uid = sd_v1_uid(sd);
6861 + gid = sd_v1_gid(sd);
6863 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
6864 set_inode_sd_version(inode, STAT_DATA_V1);
6865 inode->i_mode = sd_v1_mode(sd);
6866 set_nlink(inode, sd_v1_nlink(sd));
6867 - inode->i_uid = sd_v1_uid(sd);
6868 - inode->i_gid = sd_v1_gid(sd);
6869 inode->i_size = sd_v1_size(sd);
6870 inode->i_atime.tv_sec = sd_v1_atime(sd);
6871 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
6872 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
6873 // (directories and symlinks)
6874 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
6876 + uid = sd_v2_uid(sd);
6877 + gid = sd_v2_gid(sd);
6879 inode->i_mode = sd_v2_mode(sd);
6880 set_nlink(inode, sd_v2_nlink(sd));
6881 - inode->i_uid = sd_v2_uid(sd);
6882 inode->i_size = sd_v2_size(sd);
6883 - inode->i_gid = sd_v2_gid(sd);
6884 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
6885 inode->i_atime.tv_sec = sd_v2_atime(sd);
6886 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
6887 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
6888 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
6891 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6892 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6893 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
6896 if (S_ISREG(inode->i_mode)) {
6897 inode->i_op = &reiserfs_file_inode_operations;
6898 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
6899 static void inode2sd(void *sd, struct inode *inode, loff_t size)
6901 struct stat_data *sd_v2 = (struct stat_data *)sd;
6902 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
6903 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
6906 + set_sd_v2_uid(sd_v2, uid);
6907 + set_sd_v2_gid(sd_v2, gid);
6908 set_sd_v2_mode(sd_v2, inode->i_mode);
6909 set_sd_v2_nlink(sd_v2, inode->i_nlink);
6910 - set_sd_v2_uid(sd_v2, inode->i_uid);
6911 set_sd_v2_size(sd_v2, size);
6912 - set_sd_v2_gid(sd_v2, inode->i_gid);
6913 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
6914 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
6915 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
6916 @@ -2868,14 +2879,19 @@ int reiserfs_commit_write(struct file *f
6917 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
6919 if (reiserfs_attrs(inode->i_sb)) {
6920 - if (sd_attrs & REISERFS_SYNC_FL)
6921 - inode->i_flags |= S_SYNC;
6923 - inode->i_flags &= ~S_SYNC;
6924 if (sd_attrs & REISERFS_IMMUTABLE_FL)
6925 inode->i_flags |= S_IMMUTABLE;
6927 inode->i_flags &= ~S_IMMUTABLE;
6928 + if (sd_attrs & REISERFS_IXUNLINK_FL)
6929 + inode->i_flags |= S_IXUNLINK;
6931 + inode->i_flags &= ~S_IXUNLINK;
6933 + if (sd_attrs & REISERFS_SYNC_FL)
6934 + inode->i_flags |= S_SYNC;
6936 + inode->i_flags &= ~S_SYNC;
6937 if (sd_attrs & REISERFS_APPEND_FL)
6938 inode->i_flags |= S_APPEND;
6940 @@ -2888,6 +2904,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
6941 REISERFS_I(inode)->i_flags |= i_nopack_mask;
6943 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
6945 + if (sd_attrs & REISERFS_BARRIER_FL)
6946 + inode->i_vflags |= V_BARRIER;
6948 + inode->i_vflags &= ~V_BARRIER;
6949 + if (sd_attrs & REISERFS_COW_FL)
6950 + inode->i_vflags |= V_COW;
6952 + inode->i_vflags &= ~V_COW;
6956 @@ -2898,6 +2923,11 @@ void i_attrs_to_sd_attrs(struct inode *i
6957 *sd_attrs |= REISERFS_IMMUTABLE_FL;
6959 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
6960 + if (inode->i_flags & S_IXUNLINK)
6961 + *sd_attrs |= REISERFS_IXUNLINK_FL;
6963 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
6965 if (inode->i_flags & S_SYNC)
6966 *sd_attrs |= REISERFS_SYNC_FL;
6968 @@ -2910,6 +2940,15 @@ void i_attrs_to_sd_attrs(struct inode *i
6969 *sd_attrs |= REISERFS_NOTAIL_FL;
6971 *sd_attrs &= ~REISERFS_NOTAIL_FL;
6973 + if (inode->i_vflags & V_BARRIER)
6974 + *sd_attrs |= REISERFS_BARRIER_FL;
6976 + *sd_attrs &= ~REISERFS_BARRIER_FL;
6977 + if (inode->i_vflags & V_COW)
6978 + *sd_attrs |= REISERFS_COW_FL;
6980 + *sd_attrs &= ~REISERFS_COW_FL;
6984 @@ -3155,7 +3194,8 @@ int reiserfs_setattr(struct dentry *dent
6987 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
6988 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
6989 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
6990 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
6991 struct reiserfs_transaction_handle th;
6994 @@ -3184,6 +3224,9 @@ int reiserfs_setattr(struct dentry *dent
6995 inode->i_uid = attr->ia_uid;
6996 if (attr->ia_valid & ATTR_GID)
6997 inode->i_gid = attr->ia_gid;
6998 + if ((attr->ia_valid & ATTR_TAG) &&
7000 + inode->i_tag = attr->ia_tag;
7001 mark_inode_dirty(inode);
7002 error = journal_end(&th, inode->i_sb, jbegin_count);
7004 diff -NurpP --minimal linux-3.2.5/fs/reiserfs/ioctl.c linux-3.2.5-vs2.3.2.6/fs/reiserfs/ioctl.c
7005 --- linux-3.2.5/fs/reiserfs/ioctl.c 2011-05-22 16:17:53.000000000 +0200
7006 +++ linux-3.2.5-vs2.3.2.6/fs/reiserfs/ioctl.c 2011-12-05 19:33:02.000000000 +0100
7008 #include <linux/pagemap.h>
7009 #include <linux/compat.h>
7012 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7014 + __u16 sd_attrs = 0;
7016 + inode->i_flags = flags;
7017 + inode->i_vflags = vflags;
7019 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7020 + REISERFS_I(inode)->i_attrs = sd_attrs;
7021 + inode->i_ctime = CURRENT_TIME_SEC;
7022 + mark_inode_dirty(inode);
7027 * reiserfs_ioctl - handler for ioctl for inode
7028 * supported commands:
7030 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7032 struct inode *inode = filp->f_path.dentry->d_inode;
7033 - unsigned int flags;
7034 + unsigned int flags, oldflags;
7037 reiserfs_write_lock(inode->i_sb);
7038 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7040 flags = REISERFS_I(inode)->i_attrs;
7041 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7042 + flags &= REISERFS_FL_USER_VISIBLE;
7043 err = put_user(flags, (int __user *)arg);
7045 case REISERFS_IOC_SETFLAGS:{
7046 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7050 + if (IS_BARRIER(inode)) {
7051 + vxwprintk_task(1, "messing with the barrier.");
7055 * Is it quota file? Do not allow user to mess with it
7057 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7062 + oldflags = REISERFS_I(inode)->i_attrs;
7063 + flags &= REISERFS_FL_USER_MODIFIABLE;
7064 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7065 sd_attrs_to_i_attrs(flags, inode);
7066 REISERFS_I(inode)->i_attrs = flags;
7067 inode->i_ctime = CURRENT_TIME_SEC;
7068 diff -NurpP --minimal linux-3.2.5/fs/reiserfs/namei.c linux-3.2.5-vs2.3.2.6/fs/reiserfs/namei.c
7069 --- linux-3.2.5/fs/reiserfs/namei.c 2012-01-09 16:14:55.000000000 +0100
7070 +++ linux-3.2.5-vs2.3.2.6/fs/reiserfs/namei.c 2011-12-05 19:33:02.000000000 +0100
7072 #include <linux/reiserfs_acl.h>
7073 #include <linux/reiserfs_xattr.h>
7074 #include <linux/quotaops.h>
7075 +#include <linux/vs_tag.h>
7077 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) set_nlink(i, 1); }
7078 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7079 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7080 if (retval == IO_ERROR) {
7081 return ERR_PTR(-EIO);
7083 + dx_propagate_tag(nd, inode);
7085 return d_splice_alias(inode, dentry);
7087 diff -NurpP --minimal linux-3.2.5/fs/reiserfs/super.c linux-3.2.5-vs2.3.2.6/fs/reiserfs/super.c
7088 --- linux-3.2.5/fs/reiserfs/super.c 2012-02-07 01:57:54.000000000 +0100
7089 +++ linux-3.2.5-vs2.3.2.6/fs/reiserfs/super.c 2012-01-18 02:58:07.000000000 +0100
7090 @@ -903,6 +903,14 @@ static int reiserfs_parse_options(struct
7091 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7092 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7094 +#ifndef CONFIG_TAGGING_NONE
7095 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7096 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7097 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7099 +#ifdef CONFIG_PROPAGATE
7100 + {"tag",.arg_required = 'T',.values = NULL},
7102 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7103 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7104 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7105 @@ -1213,6 +1221,14 @@ static int reiserfs_remount(struct super
7106 handle_quota_files(s, qf_names, &qfmt);
7109 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7110 + !(s->s_flags & MS_TAGGED)) {
7111 + reiserfs_warning(s, "super-vs01",
7112 + "reiserfs: tagging not permitted on remount.");
7119 /* Add options that are safe here */
7120 @@ -1696,6 +1712,10 @@ static int reiserfs_fill_super(struct su
7124 + /* map mount option tagxid */
7125 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7126 + s->s_flags |= MS_TAGGED;
7128 rs = SB_DISK_SUPER_BLOCK(s);
7129 /* Let's do basic sanity check to verify that underlying device is not
7130 smaller than the filesystem. If the check fails then abort and scream,
7131 diff -NurpP --minimal linux-3.2.5/fs/reiserfs/xattr.c linux-3.2.5-vs2.3.2.6/fs/reiserfs/xattr.c
7132 --- linux-3.2.5/fs/reiserfs/xattr.c 2011-10-24 18:45:27.000000000 +0200
7133 +++ linux-3.2.5-vs2.3.2.6/fs/reiserfs/xattr.c 2011-12-05 19:33:02.000000000 +0100
7135 #include <linux/errno.h>
7136 #include <linux/gfp.h>
7137 #include <linux/fs.h>
7138 +#include <linux/mount.h>
7139 #include <linux/file.h>
7140 #include <linux/pagemap.h>
7141 #include <linux/xattr.h>
7142 diff -NurpP --minimal linux-3.2.5/fs/stat.c linux-3.2.5-vs2.3.2.6/fs/stat.c
7143 --- linux-3.2.5/fs/stat.c 2012-01-09 16:14:55.000000000 +0100
7144 +++ linux-3.2.5-vs2.3.2.6/fs/stat.c 2011-12-05 19:33:02.000000000 +0100
7145 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7146 stat->nlink = inode->i_nlink;
7147 stat->uid = inode->i_uid;
7148 stat->gid = inode->i_gid;
7149 + stat->tag = inode->i_tag;
7150 stat->rdev = inode->i_rdev;
7151 stat->size = i_size_read(inode);
7152 stat->atime = inode->i_atime;
7153 diff -NurpP --minimal linux-3.2.5/fs/statfs.c linux-3.2.5-vs2.3.2.6/fs/statfs.c
7154 --- linux-3.2.5/fs/statfs.c 2012-01-09 16:14:55.000000000 +0100
7155 +++ linux-3.2.5-vs2.3.2.6/fs/statfs.c 2011-12-05 19:33:02.000000000 +0100
7157 #include <linux/statfs.h>
7158 #include <linux/security.h>
7159 #include <linux/uaccess.h>
7160 +#include <linux/vs_base.h>
7161 +#include <linux/vs_dlimit.h>
7163 static int flags_by_mnt(int mnt_flags)
7165 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
7166 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7167 if (retval == 0 && buf->f_frsize == 0)
7168 buf->f_frsize = buf->f_bsize;
7169 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7170 + vx_vsi_statfs(dentry->d_sb, buf);
7174 diff -NurpP --minimal linux-3.2.5/fs/super.c linux-3.2.5-vs2.3.2.6/fs/super.c
7175 --- linux-3.2.5/fs/super.c 2012-01-09 16:14:55.000000000 +0100
7176 +++ linux-3.2.5-vs2.3.2.6/fs/super.c 2011-12-05 19:33:02.000000000 +0100
7178 #include <linux/backing-dev.h>
7179 #include <linux/rculist_bl.h>
7180 #include <linux/cleancache.h>
7181 +#include <linux/devpts_fs.h>
7182 +#include <linux/proc_fs.h>
7183 +#include <linux/vs_context.h>
7184 #include "internal.h"
7187 @@ -1100,6 +1103,13 @@ mount_fs(struct file_system_type *type,
7188 WARN_ON(sb->s_bdi == &default_backing_dev_info);
7189 sb->s_flags |= MS_BORN;
7192 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
7194 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7195 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7198 error = security_sb_kern_mount(sb, flags, secdata);
7201 diff -NurpP --minimal linux-3.2.5/fs/sysfs/mount.c linux-3.2.5-vs2.3.2.6/fs/sysfs/mount.c
7202 --- linux-3.2.5/fs/sysfs/mount.c 2011-07-22 11:18:06.000000000 +0200
7203 +++ linux-3.2.5-vs2.3.2.6/fs/sysfs/mount.c 2011-12-05 19:33:02.000000000 +0100
7204 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7206 sb->s_blocksize = PAGE_CACHE_SIZE;
7207 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7208 - sb->s_magic = SYSFS_MAGIC;
7209 + sb->s_magic = SYSFS_SUPER_MAGIC;
7210 sb->s_op = &sysfs_ops;
7211 sb->s_time_gran = 1;
7213 diff -NurpP --minimal linux-3.2.5/fs/utimes.c linux-3.2.5-vs2.3.2.6/fs/utimes.c
7214 --- linux-3.2.5/fs/utimes.c 2011-05-22 16:17:54.000000000 +0200
7215 +++ linux-3.2.5-vs2.3.2.6/fs/utimes.c 2011-12-05 19:33:02.000000000 +0100
7217 #include <linux/stat.h>
7218 #include <linux/utime.h>
7219 #include <linux/syscalls.h>
7220 +#include <linux/mount.h>
7221 +#include <linux/vs_cowbl.h>
7222 #include <asm/uaccess.h>
7223 #include <asm/unistd.h>
7225 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7228 struct iattr newattrs;
7229 - struct inode *inode = path->dentry->d_inode;
7230 + struct inode *inode;
7232 error = mnt_want_write(path->mnt);
7236 + error = cow_check_and_break(path);
7238 + goto mnt_drop_write_and_out;
7240 + inode = path->dentry->d_inode;
7242 if (times && times[0].tv_nsec == UTIME_NOW &&
7243 times[1].tv_nsec == UTIME_NOW)
7245 diff -NurpP --minimal linux-3.2.5/fs/xattr.c linux-3.2.5-vs2.3.2.6/fs/xattr.c
7246 --- linux-3.2.5/fs/xattr.c 2012-01-09 16:14:55.000000000 +0100
7247 +++ linux-3.2.5-vs2.3.2.6/fs/xattr.c 2011-12-05 19:33:02.000000000 +0100
7249 #include <linux/module.h>
7250 #include <linux/fsnotify.h>
7251 #include <linux/audit.h>
7252 +#include <linux/mount.h>
7253 #include <asm/uaccess.h>
7256 @@ -50,7 +51,7 @@ xattr_permission(struct inode *inode, co
7257 * The trusted.* namespace can only be accessed by privileged users.
7259 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
7260 - if (!capable(CAP_SYS_ADMIN))
7261 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
7262 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
7265 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_dinode.h linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_dinode.h
7266 --- linux-3.2.5/fs/xfs/xfs_dinode.h 2011-10-24 18:45:31.000000000 +0200
7267 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_dinode.h 2011-12-05 19:33:02.000000000 +0100
7268 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
7269 __be32 di_nlink; /* number of links to file */
7270 __be16 di_projid_lo; /* lower part of owner's project id */
7271 __be16 di_projid_hi; /* higher part owner's project id */
7272 - __u8 di_pad[6]; /* unused, zeroed space */
7273 + __u8 di_pad[2]; /* unused, zeroed space */
7274 + __be16 di_tag; /* context tagging */
7275 + __be16 di_vflags; /* vserver specific flags */
7276 __be16 di_flushiter; /* incremented on flush */
7277 xfs_timestamp_t di_atime; /* time last accessed */
7278 xfs_timestamp_t di_mtime; /* time last modified */
7279 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
7280 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7281 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7282 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7283 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7285 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7286 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7287 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7288 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
7289 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7290 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7291 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7292 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7294 #ifdef CONFIG_XFS_RT
7295 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7296 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
7297 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7298 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7299 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7300 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7301 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7302 + XFS_DIFLAG_IXUNLINK)
7304 +#define XFS_DIVFLAG_BARRIER 0x01
7305 +#define XFS_DIVFLAG_COW 0x02
7307 #endif /* __XFS_DINODE_H__ */
7308 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_fs.h linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_fs.h
7309 --- linux-3.2.5/fs/xfs/xfs_fs.h 2011-10-24 18:45:31.000000000 +0200
7310 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_fs.h 2011-12-05 19:33:02.000000000 +0100
7311 @@ -67,6 +67,9 @@ struct fsxattr {
7312 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
7313 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
7314 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
7315 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
7316 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
7317 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
7318 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
7321 @@ -302,7 +305,8 @@ typedef struct xfs_bstat {
7322 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
7323 __u16 bs_forkoff; /* inode fork offset in bytes */
7324 __u16 bs_projid_hi; /* higher part of project id */
7325 - unsigned char bs_pad[10]; /* pad space, unused */
7326 + unsigned char bs_pad[8]; /* pad space, unused */
7327 + __u16 bs_tag; /* context tagging */
7328 __u32 bs_dmevmask; /* DMIG event mask */
7329 __u16 bs_dmstate; /* DMIG state info */
7330 __u16 bs_aextents; /* attribute number of extents */
7331 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_ialloc.c linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_ialloc.c
7332 --- linux-3.2.5/fs/xfs/xfs_ialloc.c 2012-01-09 16:14:55.000000000 +0100
7333 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_ialloc.c 2011-12-05 19:33:02.000000000 +0100
7335 #include "xfs_error.h"
7336 #include "xfs_bmap.h"
7340 * Allocation group level functions.
7342 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_inode.c linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_inode.c
7343 --- linux-3.2.5/fs/xfs/xfs_inode.c 2012-01-09 16:14:55.000000000 +0100
7344 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_inode.c 2011-12-15 01:11:32.000000000 +0100
7345 @@ -236,6 +236,7 @@ xfs_inotobp(
7349 +#include <linux/vs_tag.h>
7352 * This routine is called to map an inode to the buffer containing
7353 @@ -634,15 +635,25 @@ xfs_iformat_btree(
7355 xfs_dinode_from_disk(
7357 - xfs_dinode_t *from)
7358 + xfs_dinode_t *from,
7361 + uint32_t uid, gid, tag;
7363 to->di_magic = be16_to_cpu(from->di_magic);
7364 to->di_mode = be16_to_cpu(from->di_mode);
7365 to->di_version = from ->di_version;
7366 to->di_format = from->di_format;
7367 to->di_onlink = be16_to_cpu(from->di_onlink);
7368 - to->di_uid = be32_to_cpu(from->di_uid);
7369 - to->di_gid = be32_to_cpu(from->di_gid);
7371 + uid = be32_to_cpu(from->di_uid);
7372 + gid = be32_to_cpu(from->di_gid);
7373 + tag = be16_to_cpu(from->di_tag);
7375 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7376 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7377 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7379 to->di_nlink = be32_to_cpu(from->di_nlink);
7380 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7381 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7382 @@ -664,21 +675,26 @@ xfs_dinode_from_disk(
7383 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7384 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7385 to->di_flags = be16_to_cpu(from->di_flags);
7386 + to->di_vflags = be16_to_cpu(from->di_vflags);
7387 to->di_gen = be32_to_cpu(from->di_gen);
7393 - xfs_icdinode_t *from)
7394 + xfs_icdinode_t *from,
7397 to->di_magic = cpu_to_be16(from->di_magic);
7398 to->di_mode = cpu_to_be16(from->di_mode);
7399 to->di_version = from ->di_version;
7400 to->di_format = from->di_format;
7401 to->di_onlink = cpu_to_be16(from->di_onlink);
7402 - to->di_uid = cpu_to_be32(from->di_uid);
7403 - to->di_gid = cpu_to_be32(from->di_gid);
7405 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
7406 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
7407 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
7409 to->di_nlink = cpu_to_be32(from->di_nlink);
7410 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
7411 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
7412 @@ -700,12 +716,14 @@ xfs_dinode_to_disk(
7413 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
7414 to->di_dmstate = cpu_to_be16(from->di_dmstate);
7415 to->di_flags = cpu_to_be16(from->di_flags);
7416 + to->di_vflags = cpu_to_be16(from->di_vflags);
7417 to->di_gen = cpu_to_be32(from->di_gen);
7422 - __uint16_t di_flags)
7423 + __uint16_t di_flags,
7424 + __uint16_t di_vflags)
7428 @@ -716,6 +734,8 @@ _xfs_dic2xflags(
7429 flags |= XFS_XFLAG_PREALLOC;
7430 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7431 flags |= XFS_XFLAG_IMMUTABLE;
7432 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7433 + flags |= XFS_XFLAG_IXUNLINK;
7434 if (di_flags & XFS_DIFLAG_APPEND)
7435 flags |= XFS_XFLAG_APPEND;
7436 if (di_flags & XFS_DIFLAG_SYNC)
7437 @@ -740,6 +760,10 @@ _xfs_dic2xflags(
7438 flags |= XFS_XFLAG_FILESTREAM;
7441 + if (di_vflags & XFS_DIVFLAG_BARRIER)
7442 + flags |= FS_BARRIER_FL;
7443 + if (di_vflags & XFS_DIVFLAG_COW)
7444 + flags |= FS_COW_FL;
7448 @@ -749,7 +773,7 @@ xfs_ip2xflags(
7450 xfs_icdinode_t *dic = &ip->i_d;
7452 - return _xfs_dic2xflags(dic->di_flags) |
7453 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
7454 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
7457 @@ -757,7 +781,8 @@ uint
7461 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
7462 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
7463 + be16_to_cpu(dip->di_vflags)) |
7464 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
7467 @@ -790,7 +815,6 @@ xfs_iread(
7470 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
7473 * If we got something that isn't an inode it means someone
7474 * (nfs or dmi) has a stale handle.
7475 @@ -813,7 +837,8 @@ xfs_iread(
7476 * Otherwise, just get the truly permanent information.
7479 - xfs_dinode_from_disk(&ip->i_d, dip);
7480 + xfs_dinode_from_disk(&ip->i_d, dip,
7481 + mp->m_flags & XFS_MOUNT_TAGGED);
7482 error = xfs_iformat(ip, dip);
7485 @@ -1008,6 +1033,7 @@ xfs_ialloc(
7486 ASSERT(ip->i_d.di_nlink == nlink);
7487 ip->i_d.di_uid = current_fsuid();
7488 ip->i_d.di_gid = current_fsgid();
7489 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
7490 xfs_set_projid(ip, prid);
7491 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
7493 @@ -1068,6 +1094,7 @@ xfs_ialloc(
7494 ip->i_d.di_dmevmask = 0;
7495 ip->i_d.di_dmstate = 0;
7496 ip->i_d.di_flags = 0;
7497 + ip->i_d.di_vflags = 0;
7498 flags = XFS_ILOG_CORE;
7499 switch (mode & S_IFMT) {
7501 @@ -1842,6 +1869,7 @@ xfs_ifree(
7503 ip->i_d.di_mode = 0; /* mark incore inode as free */
7504 ip->i_d.di_flags = 0;
7505 + ip->i_d.di_vflags = 0;
7506 ip->i_d.di_dmevmask = 0;
7507 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
7508 ip->i_df.if_ext_max =
7509 @@ -2723,7 +2751,8 @@ xfs_iflush_int(
7510 * because if the inode is dirty at all the core must
7513 - xfs_dinode_to_disk(dip, &ip->i_d);
7514 + xfs_dinode_to_disk(dip, &ip->i_d,
7515 + mp->m_flags & XFS_MOUNT_TAGGED);
7517 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7518 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7519 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_inode.h linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_inode.h
7520 --- linux-3.2.5/fs/xfs/xfs_inode.h 2012-01-09 16:14:55.000000000 +0100
7521 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_inode.h 2011-12-15 01:11:32.000000000 +0100
7522 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
7523 __uint32_t di_nlink; /* number of links to file */
7524 __uint16_t di_projid_lo; /* lower part of owner's project id */
7525 __uint16_t di_projid_hi; /* higher part of owner's project id */
7526 - __uint8_t di_pad[6]; /* unused, zeroed space */
7527 + __uint8_t di_pad[2]; /* unused, zeroed space */
7528 + __uint16_t di_tag; /* context tagging */
7529 + __uint16_t di_vflags; /* vserver specific flags */
7530 __uint16_t di_flushiter; /* incremented on flush */
7531 xfs_ictimestamp_t di_atime; /* time last accessed */
7532 xfs_ictimestamp_t di_mtime; /* time last modified */
7533 @@ -536,7 +538,7 @@ int xfs_itobp(struct xfs_mount *, struc
7534 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
7535 struct xfs_inode *, uint);
7536 void xfs_dinode_to_disk(struct xfs_dinode *,
7537 - struct xfs_icdinode *);
7538 + struct xfs_icdinode *, int);
7539 void xfs_idestroy_fork(struct xfs_inode *, int);
7540 void xfs_idata_realloc(struct xfs_inode *, int, int);
7541 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7542 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_ioctl.c linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_ioctl.c
7543 --- linux-3.2.5/fs/xfs/xfs_ioctl.c 2012-01-09 16:14:55.000000000 +0100
7544 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_ioctl.c 2011-12-05 19:33:02.000000000 +0100
7546 #include "xfs_bmap_btree.h"
7547 #include "xfs_dinode.h"
7548 #include "xfs_inode.h"
7549 -#include "xfs_ioctl.h"
7550 +// #include "xfs_ioctl.h"
7551 #include "xfs_rtalloc.h"
7552 #include "xfs_itable.h"
7553 #include "xfs_error.h"
7554 @@ -748,6 +748,10 @@ xfs_merge_ioc_xflags(
7555 xflags |= XFS_XFLAG_IMMUTABLE;
7557 xflags &= ~XFS_XFLAG_IMMUTABLE;
7558 + if (flags & FS_IXUNLINK_FL)
7559 + xflags |= XFS_XFLAG_IXUNLINK;
7561 + xflags &= ~XFS_XFLAG_IXUNLINK;
7562 if (flags & FS_APPEND_FL)
7563 xflags |= XFS_XFLAG_APPEND;
7565 @@ -776,6 +780,8 @@ xfs_di2lxflags(
7567 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7568 flags |= FS_IMMUTABLE_FL;
7569 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7570 + flags |= FS_IXUNLINK_FL;
7571 if (di_flags & XFS_DIFLAG_APPEND)
7572 flags |= FS_APPEND_FL;
7573 if (di_flags & XFS_DIFLAG_SYNC)
7574 @@ -836,6 +842,8 @@ xfs_set_diflags(
7575 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7576 if (xflags & XFS_XFLAG_IMMUTABLE)
7577 di_flags |= XFS_DIFLAG_IMMUTABLE;
7578 + if (xflags & XFS_XFLAG_IXUNLINK)
7579 + di_flags |= XFS_DIFLAG_IXUNLINK;
7580 if (xflags & XFS_XFLAG_APPEND)
7581 di_flags |= XFS_DIFLAG_APPEND;
7582 if (xflags & XFS_XFLAG_SYNC)
7583 @@ -878,6 +886,10 @@ xfs_diflags_to_linux(
7584 inode->i_flags |= S_IMMUTABLE;
7586 inode->i_flags &= ~S_IMMUTABLE;
7587 + if (xflags & XFS_XFLAG_IXUNLINK)
7588 + inode->i_flags |= S_IXUNLINK;
7590 + inode->i_flags &= ~S_IXUNLINK;
7591 if (xflags & XFS_XFLAG_APPEND)
7592 inode->i_flags |= S_APPEND;
7594 @@ -1370,10 +1382,18 @@ xfs_file_ioctl(
7595 case XFS_IOC_FSGETXATTRA:
7596 return xfs_ioc_fsgetxattr(ip, 1, arg);
7597 case XFS_IOC_FSSETXATTR:
7598 + if (IS_BARRIER(inode)) {
7599 + vxwprintk_task(1, "messing with the barrier.");
7600 + return -XFS_ERROR(EACCES);
7602 return xfs_ioc_fssetxattr(ip, filp, arg);
7603 case XFS_IOC_GETXFLAGS:
7604 return xfs_ioc_getxflags(ip, arg);
7605 case XFS_IOC_SETXFLAGS:
7606 + if (IS_BARRIER(inode)) {
7607 + vxwprintk_task(1, "messing with the barrier.");
7608 + return -XFS_ERROR(EACCES);
7610 return xfs_ioc_setxflags(ip, filp, arg);
7612 case XFS_IOC_FSSETDM: {
7613 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_ioctl.h linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_ioctl.h
7614 --- linux-3.2.5/fs/xfs/xfs_ioctl.h 2011-10-24 18:45:31.000000000 +0200
7615 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_ioctl.h 2011-12-05 19:33:02.000000000 +0100
7616 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7617 void __user *uhandle,
7622 + struct inode *inode,
7629 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_iops.c linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_iops.c
7630 --- linux-3.2.5/fs/xfs/xfs_iops.c 2012-01-09 16:14:55.000000000 +0100
7631 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_iops.c 2011-12-05 19:33:02.000000000 +0100
7633 #include "xfs_bmap_btree.h"
7634 #include "xfs_dinode.h"
7635 #include "xfs_inode.h"
7636 +#include "xfs_ioctl.h"
7637 #include "xfs_bmap.h"
7638 #include "xfs_rtalloc.h"
7639 #include "xfs_error.h"
7641 #include <linux/security.h>
7642 #include <linux/fiemap.h>
7643 #include <linux/slab.h>
7644 +#include <linux/vs_tag.h>
7647 * Bring the timestamps in the XFS inode uptodate.
7648 @@ -474,6 +476,7 @@ xfs_vn_getattr(
7649 stat->nlink = ip->i_d.di_nlink;
7650 stat->uid = ip->i_d.di_uid;
7651 stat->gid = ip->i_d.di_gid;
7652 + stat->tag = ip->i_d.di_tag;
7653 stat->ino = ip->i_ino;
7654 stat->atime = inode->i_atime;
7655 stat->mtime = inode->i_mtime;
7656 @@ -1039,6 +1042,7 @@ static const struct inode_operations xfs
7657 .removexattr = generic_removexattr,
7658 .listxattr = xfs_vn_listxattr,
7659 .fiemap = xfs_vn_fiemap,
7660 + .sync_flags = xfs_sync_flags,
7663 static const struct inode_operations xfs_dir_inode_operations = {
7664 @@ -1064,6 +1068,7 @@ static const struct inode_operations xfs
7665 .getxattr = generic_getxattr,
7666 .removexattr = generic_removexattr,
7667 .listxattr = xfs_vn_listxattr,
7668 + .sync_flags = xfs_sync_flags,
7671 static const struct inode_operations xfs_dir_ci_inode_operations = {
7672 @@ -1113,6 +1118,10 @@ xfs_diflags_to_iflags(
7673 inode->i_flags |= S_IMMUTABLE;
7675 inode->i_flags &= ~S_IMMUTABLE;
7676 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7677 + inode->i_flags |= S_IXUNLINK;
7679 + inode->i_flags &= ~S_IXUNLINK;
7680 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7681 inode->i_flags |= S_APPEND;
7683 @@ -1125,6 +1134,15 @@ xfs_diflags_to_iflags(
7684 inode->i_flags |= S_NOATIME;
7686 inode->i_flags &= ~S_NOATIME;
7688 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7689 + inode->i_vflags |= V_BARRIER;
7691 + inode->i_vflags &= ~V_BARRIER;
7692 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7693 + inode->i_vflags |= V_COW;
7695 + inode->i_vflags &= ~V_COW;
7699 @@ -1156,6 +1174,7 @@ xfs_setup_inode(
7700 set_nlink(inode, ip->i_d.di_nlink);
7701 inode->i_uid = ip->i_d.di_uid;
7702 inode->i_gid = ip->i_d.di_gid;
7703 + inode->i_tag = ip->i_d.di_tag;
7705 switch (inode->i_mode & S_IFMT) {
7707 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_itable.c linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_itable.c
7708 --- linux-3.2.5/fs/xfs/xfs_itable.c 2011-05-22 16:17:54.000000000 +0200
7709 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_itable.c 2011-12-05 19:33:02.000000000 +0100
7710 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
7711 buf->bs_mode = dic->di_mode;
7712 buf->bs_uid = dic->di_uid;
7713 buf->bs_gid = dic->di_gid;
7714 + buf->bs_tag = dic->di_tag;
7715 buf->bs_size = dic->di_size;
7718 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_linux.h linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_linux.h
7719 --- linux-3.2.5/fs/xfs/xfs_linux.h 2011-10-24 18:45:31.000000000 +0200
7720 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_linux.h 2011-12-05 19:33:02.000000000 +0100
7723 #define current_cpu() (raw_smp_processor_id())
7724 #define current_pid() (current->pid)
7725 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7726 #define current_test_flags(f) (current->flags & (f))
7727 #define current_set_flags_nested(sp, f) \
7728 (*(sp) = current->flags, current->flags |= (f))
7729 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_log_recover.c linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_log_recover.c
7730 --- linux-3.2.5/fs/xfs/xfs_log_recover.c 2012-01-09 16:14:55.000000000 +0100
7731 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_log_recover.c 2011-12-05 19:33:02.000000000 +0100
7732 @@ -2344,7 +2344,8 @@ xlog_recover_inode_pass2(
7735 /* The core is in in-core format */
7736 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
7737 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
7738 + mp->m_flags & XFS_MOUNT_TAGGED);
7740 /* the rest is in on-disk format */
7741 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
7742 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_mount.h linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_mount.h
7743 --- linux-3.2.5/fs/xfs/xfs_mount.h 2011-10-24 18:45:31.000000000 +0200
7744 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_mount.h 2011-12-05 19:33:02.000000000 +0100
7745 @@ -249,6 +249,7 @@ typedef struct xfs_mount {
7747 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7749 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7752 * Default minimum read and write sizes.
7753 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_super.c linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_super.c
7754 --- linux-3.2.5/fs/xfs/xfs_super.c 2012-01-09 16:14:55.000000000 +0100
7755 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_super.c 2012-01-09 16:19:31.000000000 +0100
7756 @@ -113,6 +113,9 @@ mempool_t *xfs_ioend_pool;
7757 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7758 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7759 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7760 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7761 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7762 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7765 * Table driven mount option parser.
7766 @@ -121,10 +124,14 @@ mempool_t *xfs_ioend_pool;
7767 * in the future, too.
7770 + Opt_tag, Opt_notag,
7771 Opt_barrier, Opt_nobarrier, Opt_err
7774 static const match_table_t tokens = {
7775 + {Opt_tag, "tagxid"},
7777 + {Opt_notag, "notag"},
7778 {Opt_barrier, "barrier"},
7779 {Opt_nobarrier, "nobarrier"},
7781 @@ -374,6 +381,19 @@ xfs_parseargs(
7782 } else if (!strcmp(this_char, "irixsgid")) {
7784 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7785 +#ifndef CONFIG_TAGGING_NONE
7786 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7787 + mp->m_flags |= XFS_MOUNT_TAGGED;
7788 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7789 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7790 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7791 + mp->m_flags |= XFS_MOUNT_TAGGED;
7793 +#ifdef CONFIG_PROPAGATE
7794 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7796 + mp->m_flags |= XFS_MOUNT_TAGGED;
7799 xfs_warn(mp, "unknown mount option [%s].", this_char);
7801 @@ -1138,6 +1158,16 @@ xfs_fs_remount(
7803 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7806 + if (!(sb->s_flags & MS_TAGGED)) {
7808 + "XFS: %s: tagging not permitted on remount.\n",
7817 * Logically we would return an error here to prevent
7818 @@ -1353,6 +1383,9 @@ xfs_fs_fill_super(
7822 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7823 + sb->s_flags |= MS_TAGGED;
7826 * we must configure the block size in the superblock before we run the
7827 * full mount process as the mount process can lookup and cache inodes.
7828 diff -NurpP --minimal linux-3.2.5/fs/xfs/xfs_vnodeops.c linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_vnodeops.c
7829 --- linux-3.2.5/fs/xfs/xfs_vnodeops.c 2012-02-07 01:57:54.000000000 +0100
7830 +++ linux-3.2.5-vs2.3.2.6/fs/xfs/xfs_vnodeops.c 2012-02-07 03:14:01.000000000 +0100
7831 @@ -106,6 +106,77 @@ xfs_readlink_bmap(
7837 +xfs_get_inode_flags(
7840 + struct inode *inode = VFS_I(ip);
7841 + unsigned int flags = inode->i_flags;
7842 + unsigned int vflags = inode->i_vflags;
7844 + if (flags & S_IMMUTABLE)
7845 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7847 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7848 + if (flags & S_IXUNLINK)
7849 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
7851 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
7853 + if (vflags & V_BARRIER)
7854 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
7856 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
7857 + if (vflags & V_COW)
7858 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
7860 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
7865 + struct inode *inode,
7869 + struct xfs_inode *ip = XFS_I(inode);
7870 + struct xfs_mount *mp = ip->i_mount;
7871 + struct xfs_trans *tp;
7872 + unsigned int lock_flags = 0;
7875 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
7876 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
7880 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7881 + xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
7883 + inode->i_flags = flags;
7884 + inode->i_vflags = vflags;
7885 + xfs_get_inode_flags(ip);
7887 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
7888 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
7890 + XFS_STATS_INC(xs_ig_attrchg);
7892 + if (mp->m_flags & XFS_MOUNT_WSYNC)
7893 + xfs_trans_set_sync(tp);
7894 + code = xfs_trans_commit(tp, 0);
7895 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7899 + xfs_trans_cancel(tp, 0);
7901 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7909 diff -NurpP --minimal linux-3.2.5/include/linux/Kbuild linux-3.2.5-vs2.3.2.6/include/linux/Kbuild
7910 --- linux-3.2.5/include/linux/Kbuild 2011-10-24 18:45:31.000000000 +0200
7911 +++ linux-3.2.5-vs2.3.2.6/include/linux/Kbuild 2011-12-05 19:33:02.000000000 +0100
7912 @@ -17,6 +17,7 @@ header-y += netfilter_bridge/
7913 header-y += netfilter_ipv4/
7914 header-y += netfilter_ipv6/
7916 +header-y += vserver/
7919 objhdr-y += version.h
7920 diff -NurpP --minimal linux-3.2.5/include/linux/capability.h linux-3.2.5-vs2.3.2.6/include/linux/capability.h
7921 --- linux-3.2.5/include/linux/capability.h 2012-01-09 16:14:56.000000000 +0100
7922 +++ linux-3.2.5-vs2.3.2.6/include/linux/capability.h 2011-12-05 19:33:02.000000000 +0100
7923 @@ -280,6 +280,7 @@ struct cpu_vfs_cap_data {
7924 arbitrary SCSI commands */
7925 /* Allow setting encryption key on loopback filesystem */
7926 /* Allow setting zone reclaim policy */
7927 +/* Allow the selection of a security context */
7929 #define CAP_SYS_ADMIN 21
7931 @@ -363,7 +364,12 @@ struct cpu_vfs_cap_data {
7933 #define CAP_LAST_CAP CAP_WAKE_ALARM
7935 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
7936 +/* Allow context manipulations */
7937 +/* Allow changing context info on files */
7939 +#define CAP_CONTEXT 63
7941 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
7944 * Bit location of each capability (used by user-space library and kernel)
7945 diff -NurpP --minimal linux-3.2.5/include/linux/cred.h linux-3.2.5-vs2.3.2.6/include/linux/cred.h
7946 --- linux-3.2.5/include/linux/cred.h 2011-10-24 18:45:31.000000000 +0200
7947 +++ linux-3.2.5-vs2.3.2.6/include/linux/cred.h 2011-12-05 19:33:02.000000000 +0100
7948 @@ -156,6 +156,7 @@ extern void exit_creds(struct task_struc
7949 extern int copy_creds(struct task_struct *, unsigned long);
7950 extern const struct cred *get_task_cred(struct task_struct *);
7951 extern struct cred *cred_alloc_blank(void);
7952 +extern struct cred *__prepare_creds(const struct cred *);
7953 extern struct cred *prepare_creds(void);
7954 extern struct cred *prepare_exec_creds(void);
7955 extern int commit_creds(struct cred *);
7956 @@ -209,6 +210,31 @@ static inline void validate_process_cred
7960 +static inline void set_cred_subscribers(struct cred *cred, int n)
7962 +#ifdef CONFIG_DEBUG_CREDENTIALS
7963 + atomic_set(&cred->subscribers, n);
7967 +static inline int read_cred_subscribers(const struct cred *cred)
7969 +#ifdef CONFIG_DEBUG_CREDENTIALS
7970 + return atomic_read(&cred->subscribers);
7976 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
7978 +#ifdef CONFIG_DEBUG_CREDENTIALS
7979 + struct cred *cred = (struct cred *) _cred;
7981 + atomic_add(n, &cred->subscribers);
7986 * get_new_cred - Get a reference on a new set of credentials
7987 * @cred: The new credentials to reference
7988 diff -NurpP --minimal linux-3.2.5/include/linux/devpts_fs.h linux-3.2.5-vs2.3.2.6/include/linux/devpts_fs.h
7989 --- linux-3.2.5/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
7990 +++ linux-3.2.5-vs2.3.2.6/include/linux/devpts_fs.h 2011-12-05 19:33:02.000000000 +0100
7991 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
7996 #endif /* _LINUX_DEVPTS_FS_H */
7997 diff -NurpP --minimal linux-3.2.5/include/linux/ext2_fs.h linux-3.2.5-vs2.3.2.6/include/linux/ext2_fs.h
7998 --- linux-3.2.5/include/linux/ext2_fs.h 2012-01-09 16:14:56.000000000 +0100
7999 +++ linux-3.2.5-vs2.3.2.6/include/linux/ext2_fs.h 2011-12-05 19:33:02.000000000 +0100
8000 @@ -190,8 +190,12 @@ struct ext2_group_desc
8001 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8002 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8003 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8004 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8005 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8007 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8008 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8010 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8011 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8013 @@ -275,7 +279,8 @@ struct ext2_inode {
8015 __le16 l_i_uid_high; /* these 2 fields */
8016 __le16 l_i_gid_high; /* were reserved2[0] */
8017 - __u32 l_i_reserved2;
8018 + __le16 l_i_tag; /* Context Tag */
8019 + __u16 l_i_reserved2;
8022 __u8 h_i_frag; /* Fragment number */
8023 @@ -304,6 +309,7 @@ struct ext2_inode {
8024 #define i_gid_low i_gid
8025 #define i_uid_high osd2.linux2.l_i_uid_high
8026 #define i_gid_high osd2.linux2.l_i_gid_high
8027 +#define i_raw_tag osd2.linux2.l_i_tag
8028 #define i_reserved2 osd2.linux2.l_i_reserved2
8031 @@ -348,6 +354,7 @@ struct ext2_inode {
8032 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8033 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8034 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8035 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8038 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8039 diff -NurpP --minimal linux-3.2.5/include/linux/ext3_fs.h linux-3.2.5-vs2.3.2.6/include/linux/ext3_fs.h
8040 --- linux-3.2.5/include/linux/ext3_fs.h 2012-01-09 16:14:56.000000000 +0100
8041 +++ linux-3.2.5-vs2.3.2.6/include/linux/ext3_fs.h 2011-12-05 19:33:02.000000000 +0100
8042 @@ -173,10 +173,14 @@ struct ext3_group_desc
8043 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8044 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8045 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8046 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8047 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8049 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8050 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8051 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8052 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8054 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8055 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8057 /* Flags that should be inherited by new inodes from their parent. */
8058 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8059 @@ -312,7 +316,8 @@ struct ext3_inode {
8061 __le16 l_i_uid_high; /* these 2 fields */
8062 __le16 l_i_gid_high; /* were reserved2[0] */
8063 - __u32 l_i_reserved2;
8064 + __le16 l_i_tag; /* Context Tag */
8065 + __u16 l_i_reserved2;
8068 __u8 h_i_frag; /* Fragment number */
8069 @@ -343,6 +348,7 @@ struct ext3_inode {
8070 #define i_gid_low i_gid
8071 #define i_uid_high osd2.linux2.l_i_uid_high
8072 #define i_gid_high osd2.linux2.l_i_gid_high
8073 +#define i_raw_tag osd2.linux2.l_i_tag
8074 #define i_reserved2 osd2.linux2.l_i_reserved2
8076 #elif defined(__GNU__)
8077 @@ -405,6 +411,7 @@ struct ext3_inode {
8078 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8079 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8080 * error in ordered mode */
8081 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8083 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8084 #ifndef _LINUX_EXT2_FS_H
8085 @@ -918,6 +925,7 @@ extern void ext3_get_inode_flags(struct
8086 extern void ext3_set_aops(struct inode *inode);
8087 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8088 u64 start, u64 len);
8089 +extern int ext3_sync_flags(struct inode *, int, int);
8092 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8093 diff -NurpP --minimal linux-3.2.5/include/linux/fs.h linux-3.2.5-vs2.3.2.6/include/linux/fs.h
8094 --- linux-3.2.5/include/linux/fs.h 2012-01-09 16:14:57.000000000 +0100
8095 +++ linux-3.2.5-vs2.3.2.6/include/linux/fs.h 2011-12-15 01:11:32.000000000 +0100
8096 @@ -210,6 +210,9 @@ struct inodes_stat_t {
8097 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8098 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8099 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8100 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8101 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8102 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8103 #define MS_NOSEC (1<<28)
8104 #define MS_BORN (1<<29)
8105 #define MS_ACTIVE (1<<30)
8106 @@ -241,6 +244,14 @@ struct inodes_stat_t {
8107 #define S_IMA 1024 /* Inode has an associated IMA struct */
8108 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
8109 #define S_NOSEC 4096 /* no suid or xattr security attributes */
8110 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
8112 +/* Linux-VServer related Inode flags */
8116 +#define V_BARRIER 4 /* Barrier for chroot() */
8117 +#define V_COW 8 /* Copy on Write */
8120 * Note that nosuid etc flags are inode-specific: setting some file-system
8121 @@ -263,12 +274,15 @@ struct inodes_stat_t {
8122 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8123 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8124 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8125 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8126 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8127 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8128 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8129 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8131 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8132 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8133 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8134 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8135 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8136 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8138 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8139 @@ -279,6 +293,16 @@ struct inodes_stat_t {
8140 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
8141 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
8143 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8145 +#ifdef CONFIG_VSERVER_COWBL
8146 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8147 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8149 +# define IS_COW(inode) (0)
8150 +# define IS_COW_LINK(inode) (0)
8153 /* the read-only stuff doesn't really belong here, but any other place is
8154 probably as bad and I don't want to create yet another include file. */
8156 @@ -364,11 +388,14 @@ struct inodes_stat_t {
8157 #define FS_EXTENT_FL 0x00080000 /* Extents */
8158 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8159 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
8160 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8161 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8163 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8164 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8165 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8166 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8168 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8169 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8171 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8172 #define SYNC_FILE_RANGE_WRITE 2
8173 @@ -449,6 +476,7 @@ typedef void (dio_iodone_t)(struct kiocb
8174 #define ATTR_KILL_PRIV (1 << 14)
8175 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8176 #define ATTR_TIMES_SET (1 << 16)
8177 +#define ATTR_TAG (1 << 17)
8180 * This is the Inode Attributes structure, used for notify_change(). It
8181 @@ -464,6 +492,7 @@ struct iattr {
8187 struct timespec ia_atime;
8188 struct timespec ia_mtime;
8189 @@ -477,6 +506,9 @@ struct iattr {
8190 struct file *ia_file;
8193 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8194 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8197 * Includes for diskquotas.
8199 @@ -751,7 +783,9 @@ struct inode {
8200 unsigned short i_opflags;
8203 - unsigned int i_flags;
8205 + unsigned short i_flags;
8206 + unsigned short i_vflags;
8208 #ifdef CONFIG_FS_POSIX_ACL
8209 struct posix_acl *i_acl;
8210 @@ -780,6 +814,7 @@ struct inode {
8211 unsigned int __i_nlink;
8215 struct timespec i_atime;
8216 struct timespec i_mtime;
8217 struct timespec i_ctime;
8218 @@ -917,12 +952,12 @@ static inline void i_size_write(struct i
8220 static inline unsigned iminor(const struct inode *inode)
8222 - return MINOR(inode->i_rdev);
8223 + return MINOR(inode->i_mdev);
8226 static inline unsigned imajor(const struct inode *inode)
8228 - return MAJOR(inode->i_rdev);
8229 + return MAJOR(inode->i_mdev);
8232 extern struct block_device *I_BDEV(struct inode *inode);
8233 @@ -989,6 +1024,7 @@ struct file {
8235 struct fown_struct f_owner;
8236 const struct cred *f_cred;
8238 struct file_ra_state f_ra;
8241 @@ -1135,6 +1171,7 @@ struct file_lock {
8242 struct file *fl_file;
8247 struct fasync_struct * fl_fasync; /* for lease break notifications */
8248 /* for lease breaks: */
8249 @@ -1635,6 +1672,7 @@ struct inode_operations {
8250 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8251 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8252 int (*removexattr) (struct dentry *, const char *);
8253 + int (*sync_flags) (struct inode *, int, int);
8254 void (*truncate_range)(struct inode *, loff_t, loff_t);
8255 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8257 @@ -1654,6 +1692,7 @@ extern ssize_t vfs_readv(struct file *,
8258 unsigned long, loff_t *);
8259 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8260 unsigned long, loff_t *);
8261 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8263 struct super_operations {
8264 struct inode *(*alloc_inode)(struct super_block *sb);
8265 @@ -2541,6 +2580,7 @@ extern int dcache_dir_open(struct inode
8266 extern int dcache_dir_close(struct inode *, struct file *);
8267 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8268 extern int dcache_readdir(struct file *, void *, filldir_t);
8269 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8270 extern int simple_setattr(struct dentry *, struct iattr *);
8271 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8272 extern int simple_statfs(struct dentry *, struct kstatfs *);
8273 diff -NurpP --minimal linux-3.2.5/include/linux/gfs2_ondisk.h linux-3.2.5-vs2.3.2.6/include/linux/gfs2_ondisk.h
8274 --- linux-3.2.5/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8275 +++ linux-3.2.5-vs2.3.2.6/include/linux/gfs2_ondisk.h 2011-12-05 19:33:02.000000000 +0100
8276 @@ -211,6 +211,9 @@ enum {
8280 + gfs2fl_IXUnlink = 16,
8281 + gfs2fl_Barrier = 17,
8283 gfs2fl_TruncInProg = 29,
8284 gfs2fl_InheritDirectio = 30,
8285 gfs2fl_InheritJdata = 31,
8286 @@ -227,6 +230,9 @@ enum {
8287 #define GFS2_DIF_NOATIME 0x00000080
8288 #define GFS2_DIF_SYNC 0x00000100
8289 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8290 +#define GFS2_DIF_IXUNLINK 0x00010000
8291 +#define GFS2_DIF_BARRIER 0x00020000
8292 +#define GFS2_DIF_COW 0x00040000
8293 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8294 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8295 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8296 diff -NurpP --minimal linux-3.2.5/include/linux/if_tun.h linux-3.2.5-vs2.3.2.6/include/linux/if_tun.h
8297 --- linux-3.2.5/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8298 +++ linux-3.2.5-vs2.3.2.6/include/linux/if_tun.h 2011-12-05 19:33:02.000000000 +0100
8300 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8301 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8302 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8303 +#define TUNSETNID _IOW('T', 217, int)
8305 /* TUNSETIFF ifr flags */
8306 #define IFF_TUN 0x0001
8307 diff -NurpP --minimal linux-3.2.5/include/linux/init_task.h linux-3.2.5-vs2.3.2.6/include/linux/init_task.h
8308 --- linux-3.2.5/include/linux/init_task.h 2012-01-09 16:14:58.000000000 +0100
8309 +++ linux-3.2.5-vs2.3.2.6/include/linux/init_task.h 2011-12-15 01:11:32.000000000 +0100
8310 @@ -193,6 +193,10 @@ extern struct cred init_cred;
8312 INIT_TRACE_RECURSION \
8313 INIT_TASK_RCU_PREEMPT(tsk) \
8315 + .vx_info = NULL, \
8317 + .nx_info = NULL, \
8321 diff -NurpP --minimal linux-3.2.5/include/linux/ipc.h linux-3.2.5-vs2.3.2.6/include/linux/ipc.h
8322 --- linux-3.2.5/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8323 +++ linux-3.2.5-vs2.3.2.6/include/linux/ipc.h 2011-12-05 19:33:02.000000000 +0100
8324 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8332 diff -NurpP --minimal linux-3.2.5/include/linux/ipc_namespace.h linux-3.2.5-vs2.3.2.6/include/linux/ipc_namespace.h
8333 --- linux-3.2.5/include/linux/ipc_namespace.h 2011-10-24 18:45:32.000000000 +0200
8334 +++ linux-3.2.5-vs2.3.2.6/include/linux/ipc_namespace.h 2011-12-05 19:33:02.000000000 +0100
8335 @@ -101,7 +101,8 @@ static inline int mq_init_ns(struct ipc_
8337 #if defined(CONFIG_IPC_NS)
8338 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
8339 - struct task_struct *tsk);
8340 + struct ipc_namespace *old_ns,
8341 + struct user_namespace *user_ns);
8342 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8345 @@ -112,12 +113,13 @@ static inline struct ipc_namespace *get_
8346 extern void put_ipc_ns(struct ipc_namespace *ns);
8348 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
8349 - struct task_struct *tsk)
8350 + struct ipc_namespace *old_ns,
8351 + struct user_namespace *user_ns)
8353 if (flags & CLONE_NEWIPC)
8354 return ERR_PTR(-EINVAL);
8356 - return tsk->nsproxy->ipc_ns;
8360 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8361 diff -NurpP --minimal linux-3.2.5/include/linux/loop.h linux-3.2.5-vs2.3.2.6/include/linux/loop.h
8362 --- linux-3.2.5/include/linux/loop.h 2012-01-09 16:14:58.000000000 +0100
8363 +++ linux-3.2.5-vs2.3.2.6/include/linux/loop.h 2011-12-05 19:33:02.000000000 +0100
8364 @@ -45,6 +45,7 @@ struct loop_device {
8365 struct loop_func_table *lo_encryption;
8367 uid_t lo_key_owner; /* Who set the key */
8369 int (*ioctl)(struct loop_device *, int cmd,
8372 diff -NurpP --minimal linux-3.2.5/include/linux/magic.h linux-3.2.5-vs2.3.2.6/include/linux/magic.h
8373 --- linux-3.2.5/include/linux/magic.h 2012-01-09 16:14:58.000000000 +0100
8374 +++ linux-3.2.5-vs2.3.2.6/include/linux/magic.h 2011-12-05 19:33:02.000000000 +0100
8377 #define ADFS_SUPER_MAGIC 0xadf5
8378 #define AFFS_SUPER_MAGIC 0xadff
8379 -#define AFS_SUPER_MAGIC 0x5346414F
8380 +#define AFS_SUPER_MAGIC 0x5346414F
8381 #define AUTOFS_SUPER_MAGIC 0x0187
8382 #define CODA_SUPER_MAGIC 0x73757245
8383 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8385 #define NFS_SUPER_MAGIC 0x6969
8386 #define OPENPROM_SUPER_MAGIC 0x9fa1
8387 #define PROC_SUPER_MAGIC 0x9fa0
8388 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8389 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8391 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8392 diff -NurpP --minimal linux-3.2.5/include/linux/major.h linux-3.2.5-vs2.3.2.6/include/linux/major.h
8393 --- linux-3.2.5/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8394 +++ linux-3.2.5-vs2.3.2.6/include/linux/major.h 2011-12-05 19:33:02.000000000 +0100
8396 #define HD_MAJOR IDE0_MAJOR
8397 #define PTY_SLAVE_MAJOR 3
8399 +#define VROOT_MAJOR 4
8400 #define TTYAUX_MAJOR 5
8403 diff -NurpP --minimal linux-3.2.5/include/linux/memcontrol.h linux-3.2.5-vs2.3.2.6/include/linux/memcontrol.h
8404 --- linux-3.2.5/include/linux/memcontrol.h 2012-02-07 01:57:55.000000000 +0100
8405 +++ linux-3.2.5-vs2.3.2.6/include/linux/memcontrol.h 2012-01-26 08:52:10.000000000 +0100
8406 @@ -85,6 +85,13 @@ extern struct mem_cgroup *try_get_mem_cg
8407 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8408 extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
8410 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8411 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8413 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8414 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8415 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8418 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8420 diff -NurpP --minimal linux-3.2.5/include/linux/mm_types.h linux-3.2.5-vs2.3.2.6/include/linux/mm_types.h
8421 --- linux-3.2.5/include/linux/mm_types.h 2012-01-09 16:14:58.000000000 +0100
8422 +++ linux-3.2.5-vs2.3.2.6/include/linux/mm_types.h 2011-12-05 19:33:02.000000000 +0100
8423 @@ -344,6 +344,7 @@ struct mm_struct {
8425 /* Architecture-specific MM context */
8426 mm_context_t context;
8427 + struct vx_info *mm_vx_info;
8429 /* Swap token stuff */
8431 diff -NurpP --minimal linux-3.2.5/include/linux/mmzone.h linux-3.2.5-vs2.3.2.6/include/linux/mmzone.h
8432 --- linux-3.2.5/include/linux/mmzone.h 2012-01-09 16:14:58.000000000 +0100
8433 +++ linux-3.2.5-vs2.3.2.6/include/linux/mmzone.h 2011-12-05 19:33:02.000000000 +0100
8434 @@ -673,6 +673,13 @@ typedef struct pglist_data {
8435 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8438 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
8440 +#define node_end_pfn(nid) ({\
8441 + pg_data_t *__pgdat = NODE_DATA(nid);\
8442 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8445 #include <linux/memory_hotplug.h>
8447 extern struct mutex zonelists_mutex;
8448 diff -NurpP --minimal linux-3.2.5/include/linux/mount.h linux-3.2.5-vs2.3.2.6/include/linux/mount.h
8449 --- linux-3.2.5/include/linux/mount.h 2011-10-24 18:45:32.000000000 +0200
8450 +++ linux-3.2.5-vs2.3.2.6/include/linux/mount.h 2011-12-05 19:33:02.000000000 +0100
8451 @@ -52,6 +52,9 @@ struct mnt_pcp {
8455 +#define MNT_TAGID 0x10000
8456 +#define MNT_NOTAG 0x20000
8459 struct list_head mnt_hash;
8460 struct vfsmount *mnt_parent; /* fs we are mounted on */
8461 @@ -86,6 +89,7 @@ struct vfsmount {
8462 int mnt_expiry_mark; /* true if marked for expiry */
8465 + tag_t mnt_tag; /* tagging used for vfsmount */
8468 struct file; /* forward dec */
8469 diff -NurpP --minimal linux-3.2.5/include/linux/net.h linux-3.2.5-vs2.3.2.6/include/linux/net.h
8470 --- linux-3.2.5/include/linux/net.h 2011-07-22 11:18:11.000000000 +0200
8471 +++ linux-3.2.5-vs2.3.2.6/include/linux/net.h 2011-12-05 19:33:02.000000000 +0100
8472 @@ -72,6 +72,7 @@ struct net;
8473 #define SOCK_NOSPACE 2
8474 #define SOCK_PASSCRED 3
8475 #define SOCK_PASSSEC 4
8476 +#define SOCK_USER_SOCKET 5
8478 #ifndef ARCH_HAS_SOCKET_TYPES
8480 diff -NurpP --minimal linux-3.2.5/include/linux/netdevice.h linux-3.2.5-vs2.3.2.6/include/linux/netdevice.h
8481 --- linux-3.2.5/include/linux/netdevice.h 2012-01-09 16:14:58.000000000 +0100
8482 +++ linux-3.2.5-vs2.3.2.6/include/linux/netdevice.h 2011-12-15 01:11:33.000000000 +0100
8483 @@ -1646,6 +1646,7 @@ extern void netdev_resync_ops(struct ne
8485 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
8486 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
8487 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
8488 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
8489 extern int dev_restart(struct net_device *dev);
8490 #ifdef CONFIG_NETPOLL_TRAP
8491 diff -NurpP --minimal linux-3.2.5/include/linux/nfs_mount.h linux-3.2.5-vs2.3.2.6/include/linux/nfs_mount.h
8492 --- linux-3.2.5/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
8493 +++ linux-3.2.5-vs2.3.2.6/include/linux/nfs_mount.h 2011-12-05 19:33:02.000000000 +0100
8494 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8495 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8496 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8497 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8498 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8499 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8500 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8502 /* The following are for internal use only */
8503 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8504 diff -NurpP --minimal linux-3.2.5/include/linux/nsproxy.h linux-3.2.5-vs2.3.2.6/include/linux/nsproxy.h
8505 --- linux-3.2.5/include/linux/nsproxy.h 2011-10-24 18:45:32.000000000 +0200
8506 +++ linux-3.2.5-vs2.3.2.6/include/linux/nsproxy.h 2011-12-05 19:33:02.000000000 +0100
8509 #include <linux/spinlock.h>
8510 #include <linux/sched.h>
8511 +#include <linux/vserver/debug.h>
8513 struct mnt_namespace;
8514 struct uts_namespace;
8515 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
8518 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8519 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8520 void exit_task_namespaces(struct task_struct *tsk);
8521 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8522 void free_nsproxy(struct nsproxy *ns);
8523 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
8524 struct fs_struct *);
8525 int __init nsproxy_cache_init(void);
8527 -static inline void put_nsproxy(struct nsproxy *ns)
8528 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8530 +static inline void __get_nsproxy(struct nsproxy *ns,
8531 + const char *_file, int _line)
8533 - if (atomic_dec_and_test(&ns->count)) {
8536 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8537 + ns, atomic_read(&ns->count), _file, _line);
8538 + atomic_inc(&ns->count);
8541 -static inline void get_nsproxy(struct nsproxy *ns)
8542 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8544 +static inline void __put_nsproxy(struct nsproxy *ns,
8545 + const char *_file, int _line)
8547 - atomic_inc(&ns->count);
8548 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8549 + ns, atomic_read(&ns->count), _file, _line);
8550 + if (atomic_dec_and_test(&ns->count)) {
8556 diff -NurpP --minimal linux-3.2.5/include/linux/pid.h linux-3.2.5-vs2.3.2.6/include/linux/pid.h
8557 --- linux-3.2.5/include/linux/pid.h 2011-07-22 11:18:11.000000000 +0200
8558 +++ linux-3.2.5-vs2.3.2.6/include/linux/pid.h 2011-12-05 19:33:02.000000000 +0100
8559 @@ -8,7 +8,8 @@ enum pid_type
8569 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
8572 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8573 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8574 pid_t pid_vnr(struct pid *pid);
8576 #define do_each_pid_task(pid, type, task) \
8577 diff -NurpP --minimal linux-3.2.5/include/linux/proc_fs.h linux-3.2.5-vs2.3.2.6/include/linux/proc_fs.h
8578 --- linux-3.2.5/include/linux/proc_fs.h 2011-10-24 18:45:32.000000000 +0200
8579 +++ linux-3.2.5-vs2.3.2.6/include/linux/proc_fs.h 2011-12-05 19:33:02.000000000 +0100
8580 @@ -54,6 +54,7 @@ struct proc_dir_entry {
8586 const struct inode_operations *proc_iops;
8588 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
8589 extern const struct proc_ns_operations utsns_operations;
8590 extern const struct proc_ns_operations ipcns_operations;
8596 int (*proc_get_link)(struct inode *, struct path *);
8597 int (*proc_read)(struct task_struct *task, char *page);
8598 int (*proc_show)(struct seq_file *m,
8599 struct pid_namespace *ns, struct pid *pid,
8600 struct task_struct *task);
8601 + int (*proc_vs_read)(char *page);
8602 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8603 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8606 struct ctl_table_header;
8607 @@ -265,6 +272,7 @@ struct ctl_table;
8614 struct proc_dir_entry *pde;
8615 diff -NurpP --minimal linux-3.2.5/include/linux/quotaops.h linux-3.2.5-vs2.3.2.6/include/linux/quotaops.h
8616 --- linux-3.2.5/include/linux/quotaops.h 2012-01-09 16:14:58.000000000 +0100
8617 +++ linux-3.2.5-vs2.3.2.6/include/linux/quotaops.h 2011-12-05 19:33:02.000000000 +0100
8619 #define _LINUX_QUOTAOPS_
8621 #include <linux/fs.h>
8622 +#include <linux/vs_dlimit.h>
8624 #define DQUOT_SPACE_WARN 0x1
8625 #define DQUOT_SPACE_RESERVE 0x2
8626 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
8628 static inline int dquot_alloc_inode(const struct inode *inode)
8631 + return dl_alloc_inode(inode);
8634 static inline void dquot_free_inode(const struct inode *inode)
8636 + dl_free_inode(inode);
8639 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
8640 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct
8641 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
8646 + if ((ret = dl_alloc_space(inode, number)))
8648 if (!(flags & DQUOT_SPACE_RESERVE))
8649 inode_add_bytes(inode, number);
8651 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
8653 if (!(flags & DQUOT_SPACE_RESERVE))
8654 inode_sub_bytes(inode, number);
8655 + dl_free_space(inode, number);
8658 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
8659 diff -NurpP --minimal linux-3.2.5/include/linux/reboot.h linux-3.2.5-vs2.3.2.6/include/linux/reboot.h
8660 --- linux-3.2.5/include/linux/reboot.h 2011-10-24 18:45:32.000000000 +0200
8661 +++ linux-3.2.5-vs2.3.2.6/include/linux/reboot.h 2011-12-05 19:33:02.000000000 +0100
8663 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
8664 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
8665 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
8666 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
8670 diff -NurpP --minimal linux-3.2.5/include/linux/reiserfs_fs.h linux-3.2.5-vs2.3.2.6/include/linux/reiserfs_fs.h
8671 --- linux-3.2.5/include/linux/reiserfs_fs.h 2011-10-24 18:45:32.000000000 +0200
8672 +++ linux-3.2.5-vs2.3.2.6/include/linux/reiserfs_fs.h 2011-12-05 19:33:02.000000000 +0100
8673 @@ -976,6 +976,11 @@ struct stat_data_v1 {
8674 #define REISERFS_COMPR_FL FS_COMPR_FL
8675 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
8677 +/* unfortunately reiserfs sdattr is only 16 bit */
8678 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
8679 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
8680 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
8682 /* persistent flags that file inherits from the parent directory */
8683 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
8684 REISERFS_SYNC_FL | \
8685 @@ -985,6 +990,9 @@ struct stat_data_v1 {
8686 REISERFS_COMPR_FL | \
8687 REISERFS_NOTAIL_FL )
8689 +#define REISERFS_FL_USER_VISIBLE 0x80FF
8690 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
8692 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
8695 @@ -2073,6 +2081,7 @@ static inline void reiserfs_update_sd(st
8696 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
8697 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
8698 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
8699 +int reiserfs_sync_flags(struct inode *inode, int, int);
8701 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
8703 diff -NurpP --minimal linux-3.2.5/include/linux/reiserfs_fs_sb.h linux-3.2.5-vs2.3.2.6/include/linux/reiserfs_fs_sb.h
8704 --- linux-3.2.5/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
8705 +++ linux-3.2.5-vs2.3.2.6/include/linux/reiserfs_fs_sb.h 2011-12-05 19:33:02.000000000 +0100
8706 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
8707 REISERFS_EXPOSE_PRIVROOT,
8708 REISERFS_BARRIER_NONE,
8709 REISERFS_BARRIER_FLUSH,
8712 /* Actions on error */
8713 REISERFS_ERROR_PANIC,
8714 diff -NurpP --minimal linux-3.2.5/include/linux/sched.h linux-3.2.5-vs2.3.2.6/include/linux/sched.h
8715 --- linux-3.2.5/include/linux/sched.h 2012-01-09 16:14:58.000000000 +0100
8716 +++ linux-3.2.5-vs2.3.2.6/include/linux/sched.h 2011-12-05 19:33:02.000000000 +0100
8717 @@ -1403,6 +1403,14 @@ struct task_struct {
8721 +/* vserver context data */
8722 + struct vx_info *vx_info;
8723 + struct nx_info *nx_info;
8729 /* Thread group tracking */
8732 @@ -1651,6 +1659,11 @@ struct pid_namespace;
8733 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
8734 struct pid_namespace *ns);
8736 +#include <linux/vserver/base.h>
8737 +#include <linux/vserver/context.h>
8738 +#include <linux/vserver/debug.h>
8739 +#include <linux/vserver/pid.h>
8741 static inline pid_t task_pid_nr(struct task_struct *tsk)
8744 @@ -1664,7 +1677,8 @@ static inline pid_t task_pid_nr_ns(struc
8746 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8748 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8749 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8750 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8754 @@ -1677,7 +1691,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8756 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8758 - return pid_vnr(task_tgid(tsk));
8759 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8763 diff -NurpP --minimal linux-3.2.5/include/linux/shmem_fs.h linux-3.2.5-vs2.3.2.6/include/linux/shmem_fs.h
8764 --- linux-3.2.5/include/linux/shmem_fs.h 2012-02-07 01:57:55.000000000 +0100
8765 +++ linux-3.2.5-vs2.3.2.6/include/linux/shmem_fs.h 2012-01-26 08:52:10.000000000 +0100
8768 /* inode in-kernel data */
8770 +#define TMPFS_SUPER_MAGIC 0x01021994
8773 struct shmem_inode_info {
8775 unsigned long flags;
8776 diff -NurpP --minimal linux-3.2.5/include/linux/stat.h linux-3.2.5-vs2.3.2.6/include/linux/stat.h
8777 --- linux-3.2.5/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
8778 +++ linux-3.2.5-vs2.3.2.6/include/linux/stat.h 2011-12-05 19:33:02.000000000 +0100
8779 @@ -66,6 +66,7 @@ struct kstat {
8786 struct timespec atime;
8787 diff -NurpP --minimal linux-3.2.5/include/linux/sunrpc/auth.h linux-3.2.5-vs2.3.2.6/include/linux/sunrpc/auth.h
8788 --- linux-3.2.5/include/linux/sunrpc/auth.h 2011-10-24 18:45:32.000000000 +0200
8789 +++ linux-3.2.5-vs2.3.2.6/include/linux/sunrpc/auth.h 2011-12-05 19:33:02.000000000 +0100
8795 struct group_info *group_info;
8796 unsigned char machine_cred : 1;
8798 diff -NurpP --minimal linux-3.2.5/include/linux/sunrpc/clnt.h linux-3.2.5-vs2.3.2.6/include/linux/sunrpc/clnt.h
8799 --- linux-3.2.5/include/linux/sunrpc/clnt.h 2012-01-09 16:14:58.000000000 +0100
8800 +++ linux-3.2.5-vs2.3.2.6/include/linux/sunrpc/clnt.h 2011-12-05 19:33:02.000000000 +0100
8801 @@ -50,7 +50,8 @@ struct rpc_clnt {
8802 unsigned int cl_softrtry : 1,/* soft timeouts */
8803 cl_discrtry : 1,/* disconnect before retry */
8804 cl_autobind : 1,/* use getport() */
8805 - cl_chatty : 1;/* be verbose */
8806 + cl_chatty : 1,/* be verbose */
8807 + cl_tag : 1;/* context tagging */
8809 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8810 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8811 diff -NurpP --minimal linux-3.2.5/include/linux/syscalls.h linux-3.2.5-vs2.3.2.6/include/linux/syscalls.h
8812 --- linux-3.2.5/include/linux/syscalls.h 2012-01-09 16:14:58.000000000 +0100
8813 +++ linux-3.2.5-vs2.3.2.6/include/linux/syscalls.h 2011-12-05 19:33:02.000000000 +0100
8814 @@ -483,6 +483,8 @@ asmlinkage long sys_symlink(const char _
8815 asmlinkage long sys_unlink(const char __user *pathname);
8816 asmlinkage long sys_rename(const char __user *oldname,
8817 const char __user *newname);
8818 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
8820 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
8821 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
8823 diff -NurpP --minimal linux-3.2.5/include/linux/sysctl.h linux-3.2.5-vs2.3.2.6/include/linux/sysctl.h
8824 --- linux-3.2.5/include/linux/sysctl.h 2012-01-09 16:14:58.000000000 +0100
8825 +++ linux-3.2.5-vs2.3.2.6/include/linux/sysctl.h 2011-12-05 19:33:02.000000000 +0100
8826 @@ -60,6 +60,7 @@ enum
8827 CTL_ABI=9, /* Binary emulation */
8828 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
8829 CTL_ARLAN=254, /* arlan wireless driver */
8830 + CTL_VSERVER=4242, /* Linux-VServer debug */
8831 CTL_S390DBF=5677, /* s390 debug */
8832 CTL_SUNRPC=7249, /* sunrpc debug */
8833 CTL_PM=9899, /* frv power management */
8834 @@ -94,6 +95,7 @@ enum
8836 KERN_PANIC=15, /* int: panic timeout */
8837 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
8838 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
8840 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
8841 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
8842 diff -NurpP --minimal linux-3.2.5/include/linux/sysfs.h linux-3.2.5-vs2.3.2.6/include/linux/sysfs.h
8843 --- linux-3.2.5/include/linux/sysfs.h 2012-01-09 16:14:58.000000000 +0100
8844 +++ linux-3.2.5-vs2.3.2.6/include/linux/sysfs.h 2011-12-05 19:33:02.000000000 +0100
8846 #include <linux/kobject_ns.h>
8847 #include <linux/atomic.h>
8849 +#define SYSFS_SUPER_MAGIC 0x62656572
8854 diff -NurpP --minimal linux-3.2.5/include/linux/time.h linux-3.2.5-vs2.3.2.6/include/linux/time.h
8855 --- linux-3.2.5/include/linux/time.h 2011-07-22 11:18:11.000000000 +0200
8856 +++ linux-3.2.5-vs2.3.2.6/include/linux/time.h 2011-12-05 19:33:02.000000000 +0100
8857 @@ -256,6 +256,9 @@ static __always_inline void timespec_add
8858 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
8862 +#include <linux/vs_time.h>
8864 #endif /* __KERNEL__ */
8866 #define NFDBITS __NFDBITS
8867 diff -NurpP --minimal linux-3.2.5/include/linux/types.h linux-3.2.5-vs2.3.2.6/include/linux/types.h
8868 --- linux-3.2.5/include/linux/types.h 2012-01-09 16:14:59.000000000 +0100
8869 +++ linux-3.2.5-vs2.3.2.6/include/linux/types.h 2011-12-05 19:33:02.000000000 +0100
8870 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
8871 typedef __kernel_gid32_t gid_t;
8872 typedef __kernel_uid16_t uid16_t;
8873 typedef __kernel_gid16_t gid16_t;
8874 +typedef unsigned int xid_t;
8875 +typedef unsigned int nid_t;
8876 +typedef unsigned int tag_t;
8878 typedef unsigned long uintptr_t;
8880 diff -NurpP --minimal linux-3.2.5/include/linux/utsname.h linux-3.2.5-vs2.3.2.6/include/linux/utsname.h
8881 --- linux-3.2.5/include/linux/utsname.h 2012-01-09 16:14:59.000000000 +0100
8882 +++ linux-3.2.5-vs2.3.2.6/include/linux/utsname.h 2011-12-05 19:33:02.000000000 +0100
8883 @@ -62,7 +62,8 @@ static inline void get_uts_ns(struct uts
8886 extern struct uts_namespace *copy_utsname(unsigned long flags,
8887 - struct task_struct *tsk);
8888 + struct uts_namespace *old_ns,
8889 + struct user_namespace *user_ns);
8890 extern void free_uts_ns(struct kref *kref);
8892 static inline void put_uts_ns(struct uts_namespace *ns)
8893 @@ -79,12 +80,13 @@ static inline void put_uts_ns(struct uts
8896 static inline struct uts_namespace *copy_utsname(unsigned long flags,
8897 - struct task_struct *tsk)
8898 + struct uts_namespace *old_ns,
8899 + struct user_namespace *user_ns)
8901 if (flags & CLONE_NEWUTS)
8902 return ERR_PTR(-EINVAL);
8904 - return tsk->nsproxy->uts_ns;
8909 diff -NurpP --minimal linux-3.2.5/include/linux/vroot.h linux-3.2.5-vs2.3.2.6/include/linux/vroot.h
8910 --- linux-3.2.5/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
8911 +++ linux-3.2.5-vs2.3.2.6/include/linux/vroot.h 2011-12-05 19:33:02.000000000 +0100
8915 + * include/linux/vroot.h
8917 + * written by Herbert Pötzl, 9/11/2002
8918 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
8920 + * Copyright (C) 2002-2007 by Herbert Pötzl.
8921 + * Redistribution of this file is permitted under the
8922 + * GNU General Public License.
8925 +#ifndef _LINUX_VROOT_H
8926 +#define _LINUX_VROOT_H
8931 +/* Possible states of device */
8937 +struct vroot_device {
8941 + struct semaphore vr_ctl_mutex;
8942 + struct block_device *vr_device;
8947 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
8949 +extern int register_vroot_grb(vroot_grb_func *);
8950 +extern int unregister_vroot_grb(vroot_grb_func *);
8952 +#endif /* __KERNEL__ */
8954 +#define MAX_VROOT_DEFAULT 8
8957 + * IOCTL commands --- we will commandeer 0x56 ('V')
8960 +#define VROOT_SET_DEV 0x5600
8961 +#define VROOT_CLR_DEV 0x5601
8963 +#endif /* _LINUX_VROOT_H */
8964 diff -NurpP --minimal linux-3.2.5/include/linux/vs_base.h linux-3.2.5-vs2.3.2.6/include/linux/vs_base.h
8965 --- linux-3.2.5/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
8966 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_base.h 2011-12-05 19:33:02.000000000 +0100
8971 +#include "vserver/base.h"
8972 +#include "vserver/check.h"
8973 +#include "vserver/debug.h"
8976 +#warning duplicate inclusion
8978 diff -NurpP --minimal linux-3.2.5/include/linux/vs_context.h linux-3.2.5-vs2.3.2.6/include/linux/vs_context.h
8979 --- linux-3.2.5/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
8980 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_context.h 2011-12-05 19:33:02.000000000 +0100
8982 +#ifndef _VS_CONTEXT_H
8983 +#define _VS_CONTEXT_H
8985 +#include "vserver/base.h"
8986 +#include "vserver/check.h"
8987 +#include "vserver/context.h"
8988 +#include "vserver/history.h"
8989 +#include "vserver/debug.h"
8991 +#include <linux/sched.h>
8994 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
8996 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
8997 + const char *_file, int _line, void *_here)
9002 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9003 + vxi, vxi ? vxi->vx_id : 0,
9004 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9006 + __vxh_get_vx_info(vxi, _here);
9008 + atomic_inc(&vxi->vx_usecnt);
9013 +extern void free_vx_info(struct vx_info *);
9015 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9017 +static inline void __put_vx_info(struct vx_info *vxi,
9018 + const char *_file, int _line, void *_here)
9023 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9024 + vxi, vxi ? vxi->vx_id : 0,
9025 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9027 + __vxh_put_vx_info(vxi, _here);
9029 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9030 + free_vx_info(vxi);
9034 +#define init_vx_info(p, i) \
9035 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9037 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9038 + const char *_file, int _line, void *_here)
9041 + vxlprintk(VXD_CBIT(xid, 3),
9042 + "init_vx_info(%p[#%d.%d])",
9043 + vxi, vxi ? vxi->vx_id : 0,
9044 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9046 + __vxh_init_vx_info(vxi, vxp, _here);
9048 + atomic_inc(&vxi->vx_usecnt);
9054 +#define set_vx_info(p, i) \
9055 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9057 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9058 + const char *_file, int _line, void *_here)
9060 + struct vx_info *vxo;
9065 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9066 + vxi, vxi ? vxi->vx_id : 0,
9067 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9069 + __vxh_set_vx_info(vxi, vxp, _here);
9071 + atomic_inc(&vxi->vx_usecnt);
9072 + vxo = xchg(vxp, vxi);
9077 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9079 +static inline void __clr_vx_info(struct vx_info **vxp,
9080 + const char *_file, int _line, void *_here)
9082 + struct vx_info *vxo;
9084 + vxo = xchg(vxp, NULL);
9088 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9089 + vxo, vxo ? vxo->vx_id : 0,
9090 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9092 + __vxh_clr_vx_info(vxo, vxp, _here);
9094 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9095 + free_vx_info(vxo);
9099 +#define claim_vx_info(v, p) \
9100 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9102 +static inline void __claim_vx_info(struct vx_info *vxi,
9103 + struct task_struct *task,
9104 + const char *_file, int _line, void *_here)
9106 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9107 + vxi, vxi ? vxi->vx_id : 0,
9108 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9109 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9110 + task, _file, _line);
9111 + __vxh_claim_vx_info(vxi, task, _here);
9113 + atomic_inc(&vxi->vx_tasks);
9117 +extern void unhash_vx_info(struct vx_info *);
9119 +#define release_vx_info(v, p) \
9120 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9122 +static inline void __release_vx_info(struct vx_info *vxi,
9123 + struct task_struct *task,
9124 + const char *_file, int _line, void *_here)
9126 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9127 + vxi, vxi ? vxi->vx_id : 0,
9128 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9129 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9130 + task, _file, _line);
9131 + __vxh_release_vx_info(vxi, task, _here);
9135 + if (atomic_dec_and_test(&vxi->vx_tasks))
9136 + unhash_vx_info(vxi);
9140 +#define task_get_vx_info(p) \
9141 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9143 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9144 + const char *_file, int _line, void *_here)
9146 + struct vx_info *vxi;
9149 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9151 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9157 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9159 + if (waitqueue_active(&vxi->vx_wait))
9160 + wake_up_interruptible(&vxi->vx_wait);
9164 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9166 +static inline void __enter_vx_info(struct vx_info *vxi,
9167 + struct vx_info_save *vxis, const char *_file, int _line)
9169 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9170 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9171 + current->xid, current->vx_info, _file, _line);
9172 + vxis->vxi = xchg(¤t->vx_info, vxi);
9173 + vxis->xid = current->xid;
9174 + current->xid = vxi ? vxi->vx_id : 0;
9177 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9179 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9180 + const char *_file, int _line)
9182 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9183 + vxis, vxis->xid, vxis->vxi, current,
9184 + current->xid, current->vx_info, _file, _line);
9185 + (void)xchg(¤t->vx_info, vxis->vxi);
9186 + current->xid = vxis->xid;
9190 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9192 + vxis->vxi = xchg(¤t->vx_info, NULL);
9193 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9196 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9198 + (void)xchg(¤t->xid, vxis->xid);
9199 + (void)xchg(¤t->vx_info, vxis->vxi);
9202 +#define task_is_init(p) \
9203 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9205 +static inline int __task_is_init(struct task_struct *p,
9206 + const char *_file, int _line, void *_here)
9208 + int is_init = is_global_init(p);
9212 + is_init = p->vx_info->vx_initpid == p->pid;
9217 +extern void exit_vx_info(struct task_struct *, int);
9218 +extern void exit_vx_info_early(struct task_struct *, int);
9222 +#warning duplicate inclusion
9224 diff -NurpP --minimal linux-3.2.5/include/linux/vs_cowbl.h linux-3.2.5-vs2.3.2.6/include/linux/vs_cowbl.h
9225 --- linux-3.2.5/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9226 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_cowbl.h 2011-12-05 19:33:02.000000000 +0100
9228 +#ifndef _VS_COWBL_H
9229 +#define _VS_COWBL_H
9231 +#include <linux/fs.h>
9232 +#include <linux/dcache.h>
9233 +#include <linux/namei.h>
9234 +#include <linux/slab.h>
9236 +extern struct dentry *cow_break_link(const char *pathname);
9238 +static inline int cow_check_and_break(struct path *path)
9240 + struct inode *inode = path->dentry->d_inode;
9243 + /* do we need this check? */
9244 + if (IS_RDONLY(inode))
9247 + if (IS_COW(inode)) {
9248 + if (IS_COW_LINK(inode)) {
9249 + struct dentry *new_dentry, *old_dentry = path->dentry;
9252 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9256 + pp = d_path(path, buf, PATH_MAX);
9257 + new_dentry = cow_break_link(pp);
9259 + if (!IS_ERR(new_dentry)) {
9260 + path->dentry = new_dentry;
9263 + error = PTR_ERR(new_dentry);
9265 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9266 + inode->i_ctime = CURRENT_TIME;
9267 + mark_inode_dirty(inode);
9274 +#warning duplicate inclusion
9276 diff -NurpP --minimal linux-3.2.5/include/linux/vs_cvirt.h linux-3.2.5-vs2.3.2.6/include/linux/vs_cvirt.h
9277 --- linux-3.2.5/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9278 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_cvirt.h 2011-12-05 19:33:02.000000000 +0100
9280 +#ifndef _VS_CVIRT_H
9281 +#define _VS_CVIRT_H
9283 +#include "vserver/cvirt.h"
9284 +#include "vserver/context.h"
9285 +#include "vserver/base.h"
9286 +#include "vserver/check.h"
9287 +#include "vserver/debug.h"
9290 +static inline void vx_activate_task(struct task_struct *p)
9292 + struct vx_info *vxi;
9294 + if ((vxi = p->vx_info)) {
9295 + vx_update_load(vxi);
9296 + atomic_inc(&vxi->cvirt.nr_running);
9300 +static inline void vx_deactivate_task(struct task_struct *p)
9302 + struct vx_info *vxi;
9304 + if ((vxi = p->vx_info)) {
9305 + vx_update_load(vxi);
9306 + atomic_dec(&vxi->cvirt.nr_running);
9310 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9312 + struct vx_info *vxi;
9314 + if ((vxi = p->vx_info))
9315 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9318 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9320 + struct vx_info *vxi;
9322 + if ((vxi = p->vx_info))
9323 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9328 +#warning duplicate inclusion
9330 diff -NurpP --minimal linux-3.2.5/include/linux/vs_device.h linux-3.2.5-vs2.3.2.6/include/linux/vs_device.h
9331 --- linux-3.2.5/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9332 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_device.h 2011-12-05 19:33:02.000000000 +0100
9334 +#ifndef _VS_DEVICE_H
9335 +#define _VS_DEVICE_H
9337 +#include "vserver/base.h"
9338 +#include "vserver/device.h"
9339 +#include "vserver/debug.h"
9342 +#ifdef CONFIG_VSERVER_DEVICE
9344 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9346 +#define vs_device_perm(v, d, m, p) \
9347 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9352 +int vs_map_device(struct vx_info *vxi,
9353 + dev_t device, dev_t *target, umode_t mode)
9360 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9365 +#define vs_map_chrdev(d, t, p) \
9366 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9367 +#define vs_map_blkdev(d, t, p) \
9368 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9370 +#define vs_chrdev_perm(d, p) \
9371 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9372 +#define vs_blkdev_perm(d, p) \
9373 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9377 +#warning duplicate inclusion
9379 diff -NurpP --minimal linux-3.2.5/include/linux/vs_dlimit.h linux-3.2.5-vs2.3.2.6/include/linux/vs_dlimit.h
9380 --- linux-3.2.5/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9381 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_dlimit.h 2011-12-05 19:33:02.000000000 +0100
9383 +#ifndef _VS_DLIMIT_H
9384 +#define _VS_DLIMIT_H
9386 +#include <linux/fs.h>
9388 +#include "vserver/dlimit.h"
9389 +#include "vserver/base.h"
9390 +#include "vserver/debug.h"
9393 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9395 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9396 + const char *_file, int _line)
9400 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9401 + dli, dli ? dli->dl_tag : 0,
9402 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9404 + atomic_inc(&dli->dl_usecnt);
9409 +#define free_dl_info(i) \
9410 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9412 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9414 +static inline void __put_dl_info(struct dl_info *dli,
9415 + const char *_file, int _line)
9419 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9420 + dli, dli ? dli->dl_tag : 0,
9421 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9423 + if (atomic_dec_and_test(&dli->dl_usecnt))
9424 + free_dl_info(dli);
9428 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9430 +static inline int __dl_alloc_space(struct super_block *sb,
9431 + tag_t tag, dlsize_t nr, const char *file, int line)
9433 + struct dl_info *dli = NULL;
9438 + dli = locate_dl_info(sb, tag);
9442 + spin_lock(&dli->dl_lock);
9443 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9445 + dli->dl_space_used += nr;
9446 + spin_unlock(&dli->dl_lock);
9449 + vxlprintk(VXD_CBIT(dlim, 1),
9450 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9451 + sb, tag, __dlimit_char(dli), (long long)nr,
9453 + return ret ? -ENOSPC : 0;
9456 +static inline void __dl_free_space(struct super_block *sb,
9457 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9459 + struct dl_info *dli = NULL;
9463 + dli = locate_dl_info(sb, tag);
9467 + spin_lock(&dli->dl_lock);
9468 + if (dli->dl_space_used > nr)
9469 + dli->dl_space_used -= nr;
9471 + dli->dl_space_used = 0;
9472 + spin_unlock(&dli->dl_lock);
9475 + vxlprintk(VXD_CBIT(dlim, 1),
9476 + "FREE (%p,#%d)%c %lld bytes",
9477 + sb, tag, __dlimit_char(dli), (long long)nr,
9481 +static inline int __dl_alloc_inode(struct super_block *sb,
9482 + tag_t tag, const char *_file, int _line)
9484 + struct dl_info *dli;
9487 + dli = locate_dl_info(sb, tag);
9491 + spin_lock(&dli->dl_lock);
9492 + dli->dl_inodes_used++;
9493 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9494 + spin_unlock(&dli->dl_lock);
9497 + vxlprintk(VXD_CBIT(dlim, 0),
9498 + "ALLOC (%p,#%d)%c inode (%d)",
9499 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9500 + return ret ? -ENOSPC : 0;
9503 +static inline void __dl_free_inode(struct super_block *sb,
9504 + tag_t tag, const char *_file, int _line)
9506 + struct dl_info *dli;
9508 + dli = locate_dl_info(sb, tag);
9512 + spin_lock(&dli->dl_lock);
9513 + if (dli->dl_inodes_used > 1)
9514 + dli->dl_inodes_used--;
9516 + dli->dl_inodes_used = 0;
9517 + spin_unlock(&dli->dl_lock);
9520 + vxlprintk(VXD_CBIT(dlim, 0),
9521 + "FREE (%p,#%d)%c inode",
9522 + sb, tag, __dlimit_char(dli), _file, _line);
9525 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
9526 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9527 + const char *_file, int _line)
9529 + struct dl_info *dli;
9530 + uint64_t broot, bfree;
9532 + dli = locate_dl_info(sb, tag);
9536 + spin_lock(&dli->dl_lock);
9537 + broot = (dli->dl_space_total -
9538 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
9539 + >> sb->s_blocksize_bits;
9540 + bfree = (dli->dl_space_total - dli->dl_space_used)
9541 + >> sb->s_blocksize_bits;
9542 + spin_unlock(&dli->dl_lock);
9544 + vxlprintk(VXD_CBIT(dlim, 2),
9545 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
9546 + (long long)bfree, (long long)broot,
9547 + *free_blocks, *root_blocks, dli->dl_nrlmult,
9549 + if (free_blocks) {
9550 + if (*free_blocks > bfree)
9551 + *free_blocks = bfree;
9553 + if (root_blocks) {
9554 + if (*root_blocks > broot)
9555 + *root_blocks = broot;
9560 +#define dl_prealloc_space(in, bytes) \
9561 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9562 + __FILE__, __LINE__ )
9564 +#define dl_alloc_space(in, bytes) \
9565 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9566 + __FILE__, __LINE__ )
9568 +#define dl_reserve_space(in, bytes) \
9569 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9570 + __FILE__, __LINE__ )
9572 +#define dl_claim_space(in, bytes) (0)
9574 +#define dl_release_space(in, bytes) \
9575 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9576 + __FILE__, __LINE__ )
9578 +#define dl_free_space(in, bytes) \
9579 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9580 + __FILE__, __LINE__ )
9584 +#define dl_alloc_inode(in) \
9585 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9587 +#define dl_free_inode(in) \
9588 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9591 +#define dl_adjust_block(sb, tag, fb, rb) \
9592 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
9596 +#warning duplicate inclusion
9598 diff -NurpP --minimal linux-3.2.5/include/linux/vs_inet.h linux-3.2.5-vs2.3.2.6/include/linux/vs_inet.h
9599 --- linux-3.2.5/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
9600 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_inet.h 2011-12-05 19:33:02.000000000 +0100
9605 +#include "vserver/base.h"
9606 +#include "vserver/network.h"
9607 +#include "vserver/debug.h"
9609 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
9611 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
9612 + NIPQUAD((a)->mask), (a)->type
9613 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
9615 +#define NIPQUAD(addr) \
9616 + ((unsigned char *)&addr)[0], \
9617 + ((unsigned char *)&addr)[1], \
9618 + ((unsigned char *)&addr)[2], \
9619 + ((unsigned char *)&addr)[3]
9621 +#define NIPQUAD_FMT "%u.%u.%u.%u"
9625 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
9627 + __be32 ip = nxa->ip[0].s_addr;
9628 + __be32 mask = nxa->mask.s_addr;
9629 + __be32 bcast = ip | ~mask;
9632 + switch (nxa->type & tmask) {
9633 + case NXA_TYPE_MASK:
9634 + ret = (ip == (addr & mask));
9636 + case NXA_TYPE_ADDR:
9640 + /* fall through to broadcast */
9641 + case NXA_MOD_BCAST:
9642 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
9644 + case NXA_TYPE_RANGE:
9645 + ret = ((nxa->ip[0].s_addr <= addr) &&
9646 + (nxa->ip[1].s_addr > addr));
9648 + case NXA_TYPE_ANY:
9653 + vxdprintk(VXD_CBIT(net, 0),
9654 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
9655 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
9660 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
9662 + struct nx_addr_v4 *nxa;
9669 + /* allow 127.0.0.1 when remapping lback */
9670 + if ((tmask & NXA_LOOPBACK) &&
9671 + (addr == IPI_LOOPBACK) &&
9672 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9675 + /* check for lback address */
9676 + if ((tmask & NXA_MOD_LBACK) &&
9677 + (nxi->v4_lback.s_addr == addr))
9680 + /* check for broadcast address */
9681 + if ((tmask & NXA_MOD_BCAST) &&
9682 + (nxi->v4_bcast.s_addr == addr))
9685 + /* check for v4 addresses */
9686 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9687 + if (v4_addr_match(nxa, addr, tmask))
9691 + vxdprintk(VXD_CBIT(net, 0),
9692 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9693 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9698 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9700 + /* FIXME: needs full range checks */
9701 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9705 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9707 + struct nx_addr_v4 *ptr;
9709 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9710 + if (v4_nx_addr_match(ptr, nxa, mask))
9715 +#include <net/inet_sock.h>
9718 + * Check if a given address matches for a socket
9720 + * nxi: the socket's nx_info if any
9721 + * addr: to be verified address
9724 +int v4_sock_addr_match (
9725 + struct nx_info *nxi,
9726 + struct inet_sock *inet,
9729 + __be32 saddr = inet->inet_rcv_saddr;
9730 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9732 + if (addr && (saddr == addr || bcast == addr))
9735 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9740 +/* inet related checks and helpers */
9749 +#include <linux/netdevice.h>
9750 +#include <linux/inetdevice.h>
9751 +#include <net/inet_sock.h>
9752 +#include <net/inet_timewait_sock.h>
9755 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9756 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9757 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9761 + * check if address is covered by socket
9763 + * sk: the socket to check against
9764 + * addr: the address in question (must be != 0)
9768 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9770 + struct nx_info *nxi = sk->sk_nx_info;
9771 + __be32 saddr = sk_rcv_saddr(sk);
9773 + vxdprintk(VXD_CBIT(net, 5),
9774 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9775 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9776 + (sk->sk_socket?sk->sk_socket->flags:0));
9778 + if (saddr) { /* direct address match */
9779 + return v4_addr_match(nxa, saddr, -1);
9780 + } else if (nxi) { /* match against nx_info */
9781 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9782 + } else { /* unrestricted any socket */
9790 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9792 + vxdprintk(VXD_CBIT(net, 1),
9793 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9794 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9795 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9797 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9799 + if (dev_in_nx_info(dev, nxi))
9806 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9812 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9816 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
9818 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
9819 + nxi, nxi ? nxi->nx_id : 0, ifa,
9820 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
9822 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9824 + if (v4_ifa_in_nx_info(ifa, nxi))
9830 +struct nx_v4_sock_addr {
9831 + __be32 saddr; /* Address used for validation */
9832 + __be32 baddr; /* Address used for socket bind */
9836 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
9837 + struct nx_v4_sock_addr *nsa)
9839 + struct sock *sk = &inet->sk;
9840 + struct nx_info *nxi = sk->sk_nx_info;
9841 + __be32 saddr = addr->sin_addr.s_addr;
9842 + __be32 baddr = saddr;
9844 + vxdprintk(VXD_CBIT(net, 3),
9845 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
9846 + sk, sk->sk_nx_info, sk->sk_socket,
9847 + (sk->sk_socket ? sk->sk_socket->flags : 0),
9851 + if (saddr == INADDR_ANY) {
9852 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
9853 + baddr = nxi->v4.ip[0].s_addr;
9854 + } else if (saddr == IPI_LOOPBACK) {
9855 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9856 + baddr = nxi->v4_lback.s_addr;
9857 + } else if (!ipv4_is_multicast(saddr) ||
9858 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
9859 + /* normal address bind */
9860 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
9861 + return -EADDRNOTAVAIL;
9865 + vxdprintk(VXD_CBIT(net, 3),
9866 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
9867 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
9869 + nsa->saddr = saddr;
9870 + nsa->baddr = baddr;
9875 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
9877 + inet->inet_saddr = nsa->baddr;
9878 + inet->inet_rcv_saddr = nsa->baddr;
9883 + * helper to simplify inet_lookup_listener
9885 + * nxi: the socket's nx_info if any
9886 + * addr: to be verified address
9887 + * saddr: socket address
9889 +static inline int v4_inet_addr_match (
9890 + struct nx_info *nxi,
9894 + if (addr && (saddr == addr))
9897 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
9901 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
9903 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
9904 + (addr == nxi->v4_lback.s_addr))
9905 + return IPI_LOOPBACK;
9910 +int nx_info_has_v4(struct nx_info *nxi)
9916 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9921 +#else /* CONFIG_INET */
9924 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
9930 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9936 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9942 +int nx_info_has_v4(struct nx_info *nxi)
9947 +#endif /* CONFIG_INET */
9949 +#define current_nx_info_has_v4() \
9950 + nx_info_has_v4(current_nx_info())
9953 +// #warning duplicate inclusion
9955 diff -NurpP --minimal linux-3.2.5/include/linux/vs_inet6.h linux-3.2.5-vs2.3.2.6/include/linux/vs_inet6.h
9956 --- linux-3.2.5/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
9957 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_inet6.h 2011-12-05 19:33:02.000000000 +0100
9959 +#ifndef _VS_INET6_H
9960 +#define _VS_INET6_H
9962 +#include "vserver/base.h"
9963 +#include "vserver/network.h"
9964 +#include "vserver/debug.h"
9966 +#include <net/ipv6.h>
9968 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
9969 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
9975 +int v6_addr_match(struct nx_addr_v6 *nxa,
9976 + const struct in6_addr *addr, uint16_t mask)
9980 + switch (nxa->type & mask) {
9981 + case NXA_TYPE_MASK:
9982 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
9984 + case NXA_TYPE_ADDR:
9985 + ret = ipv6_addr_equal(&nxa->ip, addr);
9987 + case NXA_TYPE_ANY:
9991 + vxdprintk(VXD_CBIT(net, 0),
9992 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
9993 + nxa, NXAV6(nxa), addr, mask, ret);
9998 +int v6_addr_in_nx_info(struct nx_info *nxi,
9999 + const struct in6_addr *addr, uint16_t mask)
10001 + struct nx_addr_v6 *nxa;
10006 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
10007 + if (v6_addr_match(nxa, addr, mask))
10011 + vxdprintk(VXD_CBIT(net, 0),
10012 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
10013 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
10018 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
10020 + /* FIXME: needs full range checks */
10021 + return v6_addr_match(nxa, &addr->ip, mask);
10025 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
10027 + struct nx_addr_v6 *ptr;
10029 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
10030 + if (v6_nx_addr_match(ptr, nxa, mask))
10037 + * Check if a given address matches for a socket
10039 + * nxi: the socket's nx_info if any
10040 + * addr: to be verified address
10043 +int v6_sock_addr_match (
10044 + struct nx_info *nxi,
10045 + struct inet_sock *inet,
10046 + struct in6_addr *addr)
10048 + struct sock *sk = &inet->sk;
10049 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10051 + if (!ipv6_addr_any(addr) &&
10052 + ipv6_addr_equal(saddr, addr))
10054 + if (ipv6_addr_any(saddr))
10055 + return v6_addr_in_nx_info(nxi, addr, -1);
10060 + * check if address is covered by socket
10062 + * sk: the socket to check against
10063 + * addr: the address in question (must be != 0)
10067 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
10069 + struct nx_info *nxi = sk->sk_nx_info;
10070 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10072 + vxdprintk(VXD_CBIT(net, 5),
10073 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
10074 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
10075 + (sk->sk_socket?sk->sk_socket->flags:0));
10077 + if (!ipv6_addr_any(saddr)) { /* direct address match */
10078 + return v6_addr_match(nxa, saddr, -1);
10079 + } else if (nxi) { /* match against nx_info */
10080 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
10081 + } else { /* unrestricted any socket */
10087 +/* inet related checks and helpers */
10091 +struct net_device;
10095 +#include <linux/netdevice.h>
10096 +#include <linux/inetdevice.h>
10097 +#include <net/inet_timewait_sock.h>
10100 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10101 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10102 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10107 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10113 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10117 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10119 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10120 + nxi, nxi ? nxi->nx_id : 0, ifa,
10121 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10123 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10125 + if (v6_ifa_in_nx_info(ifa, nxi))
10131 +struct nx_v6_sock_addr {
10132 + struct in6_addr saddr; /* Address used for validation */
10133 + struct in6_addr baddr; /* Address used for socket bind */
10137 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10138 + struct nx_v6_sock_addr *nsa)
10140 + // struct sock *sk = &inet->sk;
10141 + // struct nx_info *nxi = sk->sk_nx_info;
10142 + struct in6_addr saddr = addr->sin6_addr;
10143 + struct in6_addr baddr = saddr;
10145 + nsa->saddr = saddr;
10146 + nsa->baddr = baddr;
10151 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10153 + // struct sock *sk = &inet->sk;
10154 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10156 + // *saddr = nsa->baddr;
10157 + // inet->inet_saddr = nsa->baddr;
10161 +int nx_info_has_v6(struct nx_info *nxi)
10165 + if (NX_IPV6(nxi))
10170 +#else /* CONFIG_IPV6 */
10173 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10180 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10186 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10192 +int nx_info_has_v6(struct nx_info *nxi)
10197 +#endif /* CONFIG_IPV6 */
10199 +#define current_nx_info_has_v6() \
10200 + nx_info_has_v6(current_nx_info())
10203 +#warning duplicate inclusion
10205 diff -NurpP --minimal linux-3.2.5/include/linux/vs_limit.h linux-3.2.5-vs2.3.2.6/include/linux/vs_limit.h
10206 --- linux-3.2.5/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10207 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_limit.h 2011-12-05 19:33:02.000000000 +0100
10209 +#ifndef _VS_LIMIT_H
10210 +#define _VS_LIMIT_H
10212 +#include "vserver/limit.h"
10213 +#include "vserver/base.h"
10214 +#include "vserver/context.h"
10215 +#include "vserver/debug.h"
10216 +#include "vserver/context.h"
10217 +#include "vserver/limit_int.h"
10220 +#define vx_acc_cres(v, d, p, r) \
10221 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10223 +#define vx_acc_cres_cond(x, d, p, r) \
10224 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10225 + r, d, p, __FILE__, __LINE__)
10228 +#define vx_add_cres(v, a, p, r) \
10229 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10230 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10232 +#define vx_add_cres_cond(x, a, p, r) \
10233 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10234 + r, a, p, __FILE__, __LINE__)
10235 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10238 +/* process and file limits */
10240 +#define vx_nproc_inc(p) \
10241 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10243 +#define vx_nproc_dec(p) \
10244 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10246 +#define vx_files_inc(f) \
10247 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10249 +#define vx_files_dec(f) \
10250 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10252 +#define vx_locks_inc(l) \
10253 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10255 +#define vx_locks_dec(l) \
10256 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10258 +#define vx_openfd_inc(f) \
10259 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10261 +#define vx_openfd_dec(f) \
10262 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10265 +#define vx_cres_avail(v, n, r) \
10266 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10269 +#define vx_nproc_avail(n) \
10270 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10272 +#define vx_files_avail(n) \
10273 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10275 +#define vx_locks_avail(n) \
10276 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10278 +#define vx_openfd_avail(n) \
10279 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10282 +/* dentry limits */
10284 +#define vx_dentry_inc(d) do { \
10285 + if ((d)->d_count == 1) \
10286 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10289 +#define vx_dentry_dec(d) do { \
10290 + if ((d)->d_count == 0) \
10291 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10294 +#define vx_dentry_avail(n) \
10295 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10298 +/* socket limits */
10300 +#define vx_sock_inc(s) \
10301 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10303 +#define vx_sock_dec(s) \
10304 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10306 +#define vx_sock_avail(n) \
10307 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10310 +/* ipc resource limits */
10312 +#define vx_ipcmsg_add(v, u, a) \
10313 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10315 +#define vx_ipcmsg_sub(v, u, a) \
10316 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10318 +#define vx_ipcmsg_avail(v, a) \
10319 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10322 +#define vx_ipcshm_add(v, k, a) \
10323 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10325 +#define vx_ipcshm_sub(v, k, a) \
10326 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10328 +#define vx_ipcshm_avail(v, a) \
10329 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10332 +#define vx_semary_inc(a) \
10333 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10335 +#define vx_semary_dec(a) \
10336 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10339 +#define vx_nsems_add(a,n) \
10340 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10342 +#define vx_nsems_sub(a,n) \
10343 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10347 +#warning duplicate inclusion
10349 diff -NurpP --minimal linux-3.2.5/include/linux/vs_network.h linux-3.2.5-vs2.3.2.6/include/linux/vs_network.h
10350 --- linux-3.2.5/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
10351 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_network.h 2011-12-05 19:33:02.000000000 +0100
10353 +#ifndef _NX_VS_NETWORK_H
10354 +#define _NX_VS_NETWORK_H
10356 +#include "vserver/context.h"
10357 +#include "vserver/network.h"
10358 +#include "vserver/base.h"
10359 +#include "vserver/check.h"
10360 +#include "vserver/debug.h"
10362 +#include <linux/sched.h>
10365 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
10367 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
10368 + const char *_file, int _line)
10373 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
10374 + nxi, nxi ? nxi->nx_id : 0,
10375 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10378 + atomic_inc(&nxi->nx_usecnt);
10383 +extern void free_nx_info(struct nx_info *);
10385 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
10387 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
10392 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
10393 + nxi, nxi ? nxi->nx_id : 0,
10394 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10397 + if (atomic_dec_and_test(&nxi->nx_usecnt))
10398 + free_nx_info(nxi);
10402 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
10404 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10405 + const char *_file, int _line)
10408 + vxlprintk(VXD_CBIT(nid, 3),
10409 + "init_nx_info(%p[#%d.%d])",
10410 + nxi, nxi ? nxi->nx_id : 0,
10411 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10414 + atomic_inc(&nxi->nx_usecnt);
10420 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
10422 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10423 + const char *_file, int _line)
10425 + struct nx_info *nxo;
10430 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
10431 + nxi, nxi ? nxi->nx_id : 0,
10432 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10435 + atomic_inc(&nxi->nx_usecnt);
10436 + nxo = xchg(nxp, nxi);
10440 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
10442 +static inline void __clr_nx_info(struct nx_info **nxp,
10443 + const char *_file, int _line)
10445 + struct nx_info *nxo;
10447 + nxo = xchg(nxp, NULL);
10451 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
10452 + nxo, nxo ? nxo->nx_id : 0,
10453 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
10456 + if (atomic_dec_and_test(&nxo->nx_usecnt))
10457 + free_nx_info(nxo);
10461 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
10463 +static inline void __claim_nx_info(struct nx_info *nxi,
10464 + struct task_struct *task, const char *_file, int _line)
10466 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
10467 + nxi, nxi ? nxi->nx_id : 0,
10468 + nxi?atomic_read(&nxi->nx_usecnt):0,
10469 + nxi?atomic_read(&nxi->nx_tasks):0,
10470 + task, _file, _line);
10472 + atomic_inc(&nxi->nx_tasks);
10476 +extern void unhash_nx_info(struct nx_info *);
10478 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
10480 +static inline void __release_nx_info(struct nx_info *nxi,
10481 + struct task_struct *task, const char *_file, int _line)
10483 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
10484 + nxi, nxi ? nxi->nx_id : 0,
10485 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10486 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
10487 + task, _file, _line);
10491 + if (atomic_dec_and_test(&nxi->nx_tasks))
10492 + unhash_nx_info(nxi);
10496 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
10498 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
10499 + const char *_file, int _line)
10501 + struct nx_info *nxi;
10504 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
10505 + p, _file, _line);
10506 + nxi = __get_nx_info(p->nx_info, _file, _line);
10512 +static inline void exit_nx_info(struct task_struct *p)
10515 + release_nx_info(p->nx_info, p);
10520 +#warning duplicate inclusion
10522 diff -NurpP --minimal linux-3.2.5/include/linux/vs_pid.h linux-3.2.5-vs2.3.2.6/include/linux/vs_pid.h
10523 --- linux-3.2.5/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
10524 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_pid.h 2011-12-05 19:33:02.000000000 +0100
10529 +#include "vserver/base.h"
10530 +#include "vserver/check.h"
10531 +#include "vserver/context.h"
10532 +#include "vserver/debug.h"
10533 +#include "vserver/pid.h"
10534 +#include <linux/pid_namespace.h>
10537 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
10540 +int vx_proc_task_visible(struct task_struct *task)
10542 + if ((task->pid == 1) &&
10543 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
10544 + /* show a blend through init */
10546 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
10553 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
10557 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
10559 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
10561 + if (task && !vx_proc_task_visible(task)) {
10562 + vxdprintk(VXD_CBIT(misc, 6),
10563 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
10564 + task, task->xid, task->pid,
10565 + current, current->xid, current->pid);
10566 + put_task_struct(task);
10574 +#warning duplicate inclusion
10576 diff -NurpP --minimal linux-3.2.5/include/linux/vs_sched.h linux-3.2.5-vs2.3.2.6/include/linux/vs_sched.h
10577 --- linux-3.2.5/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
10578 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_sched.h 2011-12-05 19:33:02.000000000 +0100
10580 +#ifndef _VS_SCHED_H
10581 +#define _VS_SCHED_H
10583 +#include "vserver/base.h"
10584 +#include "vserver/context.h"
10585 +#include "vserver/sched.h"
10588 +#define MAX_PRIO_BIAS 20
10589 +#define MIN_PRIO_BIAS -20
10592 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
10594 + struct vx_info *vxi = p->vx_info;
10597 + prio += vx_cpu(vxi, sched_pc).prio_bias;
10601 +static inline void vx_account_user(struct vx_info *vxi,
10602 + cputime_t cputime, int nice)
10606 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
10609 +static inline void vx_account_system(struct vx_info *vxi,
10610 + cputime_t cputime, int idle)
10614 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
10618 +#warning duplicate inclusion
10620 diff -NurpP --minimal linux-3.2.5/include/linux/vs_socket.h linux-3.2.5-vs2.3.2.6/include/linux/vs_socket.h
10621 --- linux-3.2.5/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
10622 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_socket.h 2011-12-05 19:33:02.000000000 +0100
10624 +#ifndef _VS_SOCKET_H
10625 +#define _VS_SOCKET_H
10627 +#include "vserver/debug.h"
10628 +#include "vserver/base.h"
10629 +#include "vserver/cacct.h"
10630 +#include "vserver/context.h"
10631 +#include "vserver/tag.h"
10634 +/* socket accounting */
10636 +#include <linux/socket.h>
10638 +static inline int vx_sock_type(int family)
10640 + switch (family) {
10642 + return VXA_SOCK_UNSPEC;
10644 + return VXA_SOCK_UNIX;
10646 + return VXA_SOCK_INET;
10648 + return VXA_SOCK_INET6;
10650 + return VXA_SOCK_PACKET;
10652 + return VXA_SOCK_OTHER;
10656 +#define vx_acc_sock(v, f, p, s) \
10657 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
10659 +static inline void __vx_acc_sock(struct vx_info *vxi,
10660 + int family, int pos, int size, char *file, int line)
10663 + int type = vx_sock_type(family);
10665 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10666 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10670 +#define vx_sock_recv(sk, s) \
10671 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10672 +#define vx_sock_send(sk, s) \
10673 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10674 +#define vx_sock_fail(sk, s) \
10675 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10678 +#define sock_vx_init(s) do { \
10679 + (s)->sk_xid = 0; \
10680 + (s)->sk_vx_info = NULL; \
10683 +#define sock_nx_init(s) do { \
10684 + (s)->sk_nid = 0; \
10685 + (s)->sk_nx_info = NULL; \
10689 +#warning duplicate inclusion
10691 diff -NurpP --minimal linux-3.2.5/include/linux/vs_tag.h linux-3.2.5-vs2.3.2.6/include/linux/vs_tag.h
10692 --- linux-3.2.5/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
10693 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_tag.h 2011-12-05 19:33:02.000000000 +0100
10698 +#include <linux/vserver/tag.h>
10700 +/* check conditions */
10702 +#define DX_ADMIN 0x0001
10703 +#define DX_WATCH 0x0002
10704 +#define DX_HOSTID 0x0008
10706 +#define DX_IDENT 0x0010
10708 +#define DX_ARG_MASK 0x0010
10711 +#define dx_task_tag(t) ((t)->tag)
10713 +#define dx_current_tag() dx_task_tag(current)
10715 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10717 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10721 + * check current context for ADMIN/WATCH and
10722 + * optionally against supplied argument
10724 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
10726 + if (mode & DX_ARG_MASK) {
10727 + if ((mode & DX_IDENT) && (id == cid))
10730 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10731 + ((mode & DX_WATCH) && (cid == 1)) ||
10732 + ((mode & DX_HOSTID) && (id == 0)));
10736 +int dx_permission(const struct inode *inode, int mask);
10740 +#warning duplicate inclusion
10742 diff -NurpP --minimal linux-3.2.5/include/linux/vs_time.h linux-3.2.5-vs2.3.2.6/include/linux/vs_time.h
10743 --- linux-3.2.5/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
10744 +++ linux-3.2.5-vs2.3.2.6/include/linux/vs_time.h 2011-12-05 19:33:02.000000000 +0100
10746 +#ifndef _VS_TIME_H
10747 +#define _VS_TIME_H
10750 +/* time faking stuff */
10752 +#ifdef CONFIG_VSERVER_VTIME
10754 +extern void vx_adjust_timespec(struct timespec *ts);
10755 +extern int vx_settimeofday(const struct timespec *ts);
10758 +#define vx_adjust_timespec(t) do { } while (0)
10759 +#define vx_settimeofday(t) do_settimeofday(t)
10763 +#warning duplicate inclusion
10765 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/Kbuild linux-3.2.5-vs2.3.2.6/include/linux/vserver/Kbuild
10766 --- linux-3.2.5/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
10767 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/Kbuild 2011-12-05 19:33:02.000000000 +0100
10770 +header-y += context_cmd.h network_cmd.h space_cmd.h \
10771 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
10772 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
10773 + debug_cmd.h device_cmd.h
10775 +header-y += switch.h network.h monitor.h inode.h device.h
10777 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/base.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/base.h
10778 --- linux-3.2.5/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10779 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/base.h 2011-12-05 19:33:02.000000000 +0100
10781 +#ifndef _VX_BASE_H
10782 +#define _VX_BASE_H
10785 +/* context state changes */
10797 +#define vx_task_xid(t) ((t)->xid)
10799 +#define vx_current_xid() vx_task_xid(current)
10801 +#define current_vx_info() (current->vx_info)
10804 +#define nx_task_nid(t) ((t)->nid)
10806 +#define nx_current_nid() nx_task_nid(current)
10808 +#define current_nx_info() (current->nx_info)
10811 +/* generic flag merging */
10813 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10815 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10817 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10819 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10822 +/* context flags */
10824 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10826 +#define vx_current_flags() __vx_flags(current_vx_info())
10828 +#define vx_info_flags(v, m, f) \
10829 + vs_check_flags(__vx_flags(v), m, f)
10831 +#define task_vx_flags(t, m, f) \
10832 + ((t) && vx_info_flags((t)->vx_info, m, f))
10834 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10837 +/* context caps */
10839 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10841 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10843 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10845 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10849 +/* network flags */
10851 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10853 +#define nx_current_flags() __nx_flags(current_nx_info())
10855 +#define nx_info_flags(n, m, f) \
10856 + vs_check_flags(__nx_flags(n), m, f)
10858 +#define task_nx_flags(t, m, f) \
10859 + ((t) && nx_info_flags((t)->nx_info, m, f))
10861 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10864 +/* network caps */
10866 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10868 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10870 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10872 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10875 +/* context mask capabilities */
10877 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10879 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10881 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10884 +/* context bcap mask */
10886 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10888 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10891 +/* mask given bcaps */
10893 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10895 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10898 +/* masked cap_bset */
10900 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10902 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10905 +#define vx_info_mbcap(v, b) \
10906 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10907 + vx_info_bcaps(v, b) : (b))
10909 +#define task_vx_mbcap(t, b) \
10910 + vx_info_mbcap((t)->vx_info, (t)->b)
10912 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10915 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10917 +#define vx_capable(b, c) (capable(b) || \
10918 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10920 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
10921 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10923 +#define nx_capable(b, c) (capable(b) || \
10924 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10926 +#define vx_task_initpid(t, n) \
10927 + ((t)->vx_info && \
10928 + ((t)->vx_info->vx_initpid == (n)))
10930 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10933 +/* context unshare mask */
10935 +#define __vx_umask(v) ((v)->vx_umask)
10937 +#define vx_current_umask() __vx_umask(current_vx_info())
10939 +#define vx_can_unshare(b, f) (capable(b) || \
10940 + (cap_raised(current_cap(), b) && \
10941 + !((f) & ~vx_current_umask())))
10944 +#define __vx_wmask(v) ((v)->vx_wmask)
10946 +#define vx_current_wmask() __vx_wmask(current_vx_info())
10949 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10951 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10954 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10956 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10959 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/cacct.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/cacct.h
10960 --- linux-3.2.5/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10961 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/cacct.h 2011-12-05 19:33:02.000000000 +0100
10963 +#ifndef _VX_CACCT_H
10964 +#define _VX_CACCT_H
10967 +enum sock_acc_field {
10968 + VXA_SOCK_UNSPEC = 0,
10974 + VXA_SOCK_SIZE /* array size */
10977 +#endif /* _VX_CACCT_H */
10978 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/cacct_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/cacct_cmd.h
10979 --- linux-3.2.5/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10980 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/cacct_cmd.h 2011-12-05 19:33:02.000000000 +0100
10982 +#ifndef _VX_CACCT_CMD_H
10983 +#define _VX_CACCT_CMD_H
10986 +/* virtual host info name commands */
10988 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10990 +struct vcmd_sock_stat_v0 {
10992 + uint32_t count[3];
10993 + uint64_t total[3];
10999 +#include <linux/compiler.h>
11001 +extern int vc_sock_stat(struct vx_info *, void __user *);
11003 +#endif /* __KERNEL__ */
11004 +#endif /* _VX_CACCT_CMD_H */
11005 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/cacct_def.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/cacct_def.h
11006 --- linux-3.2.5/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
11007 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/cacct_def.h 2011-12-05 19:33:02.000000000 +0100
11009 +#ifndef _VX_CACCT_DEF_H
11010 +#define _VX_CACCT_DEF_H
11012 +#include <asm/atomic.h>
11013 +#include <linux/vserver/cacct.h>
11016 +struct _vx_sock_acc {
11017 + atomic_long_t count;
11018 + atomic_long_t total;
11021 +/* context sub struct */
11023 +struct _vx_cacct {
11024 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11025 + atomic_t slab[8];
11026 + atomic_t page[6][8];
11029 +#ifdef CONFIG_VSERVER_DEBUG
11031 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11035 + printk("\t_vx_cacct:");
11036 + for (i = 0; i < 6; i++) {
11037 + struct _vx_sock_acc *ptr = cacct->sock[i];
11039 + printk("\t [%d] =", i);
11040 + for (j = 0; j < 3; j++) {
11041 + printk(" [%d] = %8lu, %8lu", j,
11042 + atomic_long_read(&ptr[j].count),
11043 + atomic_long_read(&ptr[j].total));
11051 +#endif /* _VX_CACCT_DEF_H */
11052 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/cacct_int.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/cacct_int.h
11053 --- linux-3.2.5/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
11054 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/cacct_int.h 2011-12-05 19:33:02.000000000 +0100
11056 +#ifndef _VX_CACCT_INT_H
11057 +#define _VX_CACCT_INT_H
11063 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11065 + return atomic_long_read(&cacct->sock[type][pos].count);
11070 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11072 + return atomic_long_read(&cacct->sock[type][pos].total);
11075 +#endif /* __KERNEL__ */
11076 +#endif /* _VX_CACCT_INT_H */
11077 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/check.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/check.h
11078 --- linux-3.2.5/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
11079 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/check.h 2011-12-05 19:33:02.000000000 +0100
11081 +#ifndef _VS_CHECK_H
11082 +#define _VS_CHECK_H
11085 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11087 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11088 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11090 +#define MIN_D_CONTEXT 65536
11093 +/* check conditions */
11095 +#define VS_ADMIN 0x0001
11096 +#define VS_WATCH 0x0002
11097 +#define VS_HIDE 0x0004
11098 +#define VS_HOSTID 0x0008
11100 +#define VS_IDENT 0x0010
11101 +#define VS_EQUIV 0x0020
11102 +#define VS_PARENT 0x0040
11103 +#define VS_CHILD 0x0080
11105 +#define VS_ARG_MASK 0x00F0
11107 +#define VS_DYNAMIC 0x0100
11108 +#define VS_STATIC 0x0200
11110 +#define VS_ATR_MASK 0x0F00
11112 +#ifdef CONFIG_VSERVER_PRIVACY
11113 +#define VS_ADMIN_P (0)
11114 +#define VS_WATCH_P (0)
11116 +#define VS_ADMIN_P VS_ADMIN
11117 +#define VS_WATCH_P VS_WATCH
11120 +#define VS_HARDIRQ 0x1000
11121 +#define VS_SOFTIRQ 0x2000
11122 +#define VS_IRQ 0x4000
11124 +#define VS_IRQ_MASK 0xF000
11126 +#include <linux/hardirq.h>
11129 + * check current context for ADMIN/WATCH and
11130 + * optionally against supplied argument
11132 +static inline int __vs_check(int cid, int id, unsigned int mode)
11134 + if (mode & VS_ARG_MASK) {
11135 + if ((mode & VS_IDENT) && (id == cid))
11138 + if (mode & VS_ATR_MASK) {
11139 + if ((mode & VS_DYNAMIC) &&
11140 + (id >= MIN_D_CONTEXT) &&
11141 + (id <= MAX_S_CONTEXT))
11143 + if ((mode & VS_STATIC) &&
11144 + (id > 1) && (id < MIN_D_CONTEXT))
11147 + if (mode & VS_IRQ_MASK) {
11148 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11150 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11152 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11155 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11156 + ((mode & VS_WATCH) && (cid == 1)) ||
11157 + ((mode & VS_HOSTID) && (id == 0)));
11160 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11162 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11165 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11167 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11170 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/context.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/context.h
11171 --- linux-3.2.5/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11172 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/context.h 2011-12-05 19:33:02.000000000 +0100
11174 +#ifndef _VX_CONTEXT_H
11175 +#define _VX_CONTEXT_H
11177 +#include <linux/types.h>
11178 +#include <linux/capability.h>
11181 +/* context flags */
11183 +#define VXF_INFO_SCHED 0x00000002
11184 +#define VXF_INFO_NPROC 0x00000004
11185 +#define VXF_INFO_PRIVATE 0x00000008
11187 +#define VXF_INFO_INIT 0x00000010
11188 +#define VXF_INFO_HIDE 0x00000020
11189 +#define VXF_INFO_ULIMIT 0x00000040
11190 +#define VXF_INFO_NSPACE 0x00000080
11192 +#define VXF_SCHED_HARD 0x00000100
11193 +#define VXF_SCHED_PRIO 0x00000200
11194 +#define VXF_SCHED_PAUSE 0x00000400
11196 +#define VXF_VIRT_MEM 0x00010000
11197 +#define VXF_VIRT_UPTIME 0x00020000
11198 +#define VXF_VIRT_CPU 0x00040000
11199 +#define VXF_VIRT_LOAD 0x00080000
11200 +#define VXF_VIRT_TIME 0x00100000
11202 +#define VXF_HIDE_MOUNT 0x01000000
11203 +/* was VXF_HIDE_NETIF 0x02000000 */
11204 +#define VXF_HIDE_VINFO 0x04000000
11206 +#define VXF_STATE_SETUP (1ULL << 32)
11207 +#define VXF_STATE_INIT (1ULL << 33)
11208 +#define VXF_STATE_ADMIN (1ULL << 34)
11210 +#define VXF_SC_HELPER (1ULL << 36)
11211 +#define VXF_REBOOT_KILL (1ULL << 37)
11212 +#define VXF_PERSISTENT (1ULL << 38)
11214 +#define VXF_FORK_RSS (1ULL << 48)
11215 +#define VXF_PROLIFIC (1ULL << 49)
11217 +#define VXF_IGNEG_NICE (1ULL << 52)
11219 +#define VXF_ONE_TIME (0x0007ULL << 32)
11221 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11224 +/* context migration */
11226 +#define VXM_SET_INIT 0x00000001
11227 +#define VXM_SET_REAPER 0x00000002
11229 +/* context caps */
11231 +#define VXC_SET_UTSNAME 0x00000001
11232 +#define VXC_SET_RLIMIT 0x00000002
11233 +#define VXC_FS_SECURITY 0x00000004
11234 +#define VXC_FS_TRUSTED 0x00000008
11235 +#define VXC_TIOCSTI 0x00000010
11237 +/* was VXC_RAW_ICMP 0x00000100 */
11238 +#define VXC_SYSLOG 0x00001000
11239 +#define VXC_OOM_ADJUST 0x00002000
11240 +#define VXC_AUDIT_CONTROL 0x00004000
11242 +#define VXC_SECURE_MOUNT 0x00010000
11243 +#define VXC_SECURE_REMOUNT 0x00020000
11244 +#define VXC_BINARY_MOUNT 0x00040000
11246 +#define VXC_QUOTA_CTL 0x00100000
11247 +#define VXC_ADMIN_MAPPER 0x00200000
11248 +#define VXC_ADMIN_CLOOP 0x00400000
11250 +#define VXC_KTHREAD 0x01000000
11251 +#define VXC_NAMESPACE 0x02000000
11256 +#include <linux/list.h>
11257 +#include <linux/spinlock.h>
11258 +#include <linux/rcupdate.h>
11260 +#include "limit_def.h"
11261 +#include "sched_def.h"
11262 +#include "cvirt_def.h"
11263 +#include "cacct_def.h"
11264 +#include "device_def.h"
11266 +#define VX_SPACES 2
11268 +struct _vx_info_pc {
11269 + struct _vx_sched_pc sched_pc;
11270 + struct _vx_cvirt_pc cvirt_pc;
11273 +struct _vx_space {
11274 + unsigned long vx_nsmask; /* assignment mask */
11275 + struct nsproxy *vx_nsproxy; /* private namespaces */
11276 + struct fs_struct *vx_fs; /* private namespace fs */
11277 + const struct cred *vx_cred; /* task credentials */
11281 + struct hlist_node vx_hlist; /* linked list of contexts */
11282 + xid_t vx_id; /* context id */
11283 + atomic_t vx_usecnt; /* usage count */
11284 + atomic_t vx_tasks; /* tasks count */
11285 + struct vx_info *vx_parent; /* parent context */
11286 + int vx_state; /* context state */
11288 + struct _vx_space space[VX_SPACES]; /* namespace store */
11290 + uint64_t vx_flags; /* context flags */
11291 + uint64_t vx_ccaps; /* context caps (vserver) */
11292 + uint64_t vx_umask; /* unshare mask (guest) */
11293 + uint64_t vx_wmask; /* warn mask (guest) */
11294 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11296 + struct task_struct *vx_reaper; /* guest reaper process */
11297 + pid_t vx_initpid; /* PID of guest init */
11298 + int64_t vx_badness_bias; /* OOM points bias */
11300 + struct _vx_limit limit; /* vserver limits */
11301 + struct _vx_sched sched; /* vserver scheduler */
11302 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11303 + struct _vx_cacct cacct; /* context accounting */
11305 + struct _vx_device dmap; /* default device map targets */
11307 +#ifndef CONFIG_SMP
11308 + struct _vx_info_pc info_pc; /* per cpu data */
11310 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11313 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11314 + int reboot_cmd; /* last sys_reboot() cmd */
11315 + int exit_code; /* last process exit code */
11317 + char vx_name[65]; /* vserver name */
11320 +#ifndef CONFIG_SMP
11321 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11322 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11324 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11325 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11328 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11331 +struct vx_info_save {
11332 + struct vx_info *vxi;
11337 +/* status flags */
11339 +#define VXS_HASHED 0x0001
11340 +#define VXS_PAUSED 0x0010
11341 +#define VXS_SHUTDOWN 0x0100
11342 +#define VXS_HELPER 0x1000
11343 +#define VXS_RELEASED 0x8000
11346 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11347 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11349 +extern struct vx_info *lookup_vx_info(int);
11350 +extern struct vx_info *lookup_or_create_vx_info(int);
11352 +extern int get_xid_list(int, unsigned int *, int);
11353 +extern int xid_is_hashed(xid_t);
11355 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11357 +extern long vs_state_change(struct vx_info *, unsigned int);
11360 +#endif /* __KERNEL__ */
11361 +#endif /* _VX_CONTEXT_H */
11362 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/context_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/context_cmd.h
11363 --- linux-3.2.5/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
11364 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/context_cmd.h 2011-12-05 19:33:02.000000000 +0100
11366 +#ifndef _VX_CONTEXT_CMD_H
11367 +#define _VX_CONTEXT_CMD_H
11370 +/* vinfo commands */
11372 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11375 +extern int vc_task_xid(uint32_t);
11377 +#endif /* __KERNEL__ */
11379 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11381 +struct vcmd_vx_info_v0 {
11383 + uint32_t initpid;
11384 + /* more to come */
11388 +extern int vc_vx_info(struct vx_info *, void __user *);
11390 +#endif /* __KERNEL__ */
11392 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11394 +struct vcmd_ctx_stat_v0 {
11397 + /* more to come */
11401 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11403 +#endif /* __KERNEL__ */
11405 +/* context commands */
11407 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11408 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11410 +struct vcmd_ctx_create {
11411 + uint64_t flagword;
11414 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11415 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11417 +struct vcmd_ctx_migrate {
11418 + uint64_t flagword;
11422 +extern int vc_ctx_create(uint32_t, void __user *);
11423 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11425 +#endif /* __KERNEL__ */
11428 +/* flag commands */
11430 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11431 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11433 +struct vcmd_ctx_flags_v0 {
11434 + uint64_t flagword;
11439 +extern int vc_get_cflags(struct vx_info *, void __user *);
11440 +extern int vc_set_cflags(struct vx_info *, void __user *);
11442 +#endif /* __KERNEL__ */
11445 +/* context caps commands */
11447 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
11448 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
11450 +struct vcmd_ctx_caps_v1 {
11456 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11457 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11459 +#endif /* __KERNEL__ */
11462 +/* bcaps commands */
11464 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
11465 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
11467 +struct vcmd_bcaps {
11473 +extern int vc_get_bcaps(struct vx_info *, void __user *);
11474 +extern int vc_set_bcaps(struct vx_info *, void __user *);
11476 +#endif /* __KERNEL__ */
11479 +/* umask commands */
11481 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
11482 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
11484 +struct vcmd_umask {
11490 +extern int vc_get_umask(struct vx_info *, void __user *);
11491 +extern int vc_set_umask(struct vx_info *, void __user *);
11493 +#endif /* __KERNEL__ */
11496 +/* wmask commands */
11498 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
11499 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
11501 +struct vcmd_wmask {
11507 +extern int vc_get_wmask(struct vx_info *, void __user *);
11508 +extern int vc_set_wmask(struct vx_info *, void __user *);
11510 +#endif /* __KERNEL__ */
11515 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
11516 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
11518 +struct vcmd_badness_v0 {
11523 +extern int vc_get_badness(struct vx_info *, void __user *);
11524 +extern int vc_set_badness(struct vx_info *, void __user *);
11526 +#endif /* __KERNEL__ */
11527 +#endif /* _VX_CONTEXT_CMD_H */
11528 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/cvirt.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/cvirt.h
11529 --- linux-3.2.5/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11530 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/cvirt.h 2011-12-05 19:33:02.000000000 +0100
11532 +#ifndef _VX_CVIRT_H
11533 +#define _VX_CVIRT_H
11540 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11545 +void vx_update_load(struct vx_info *);
11548 +int vx_do_syslog(int, char __user *, int);
11550 +#endif /* __KERNEL__ */
11551 +#endif /* _VX_CVIRT_H */
11552 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/cvirt_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/cvirt_cmd.h
11553 --- linux-3.2.5/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11554 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/cvirt_cmd.h 2011-12-05 19:33:02.000000000 +0100
11556 +#ifndef _VX_CVIRT_CMD_H
11557 +#define _VX_CVIRT_CMD_H
11560 +/* virtual host info name commands */
11562 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11563 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11565 +struct vcmd_vhi_name_v0 {
11571 +enum vhi_name_field {
11572 + VHIN_CONTEXT = 0,
11584 +#include <linux/compiler.h>
11586 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11587 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11589 +#endif /* __KERNEL__ */
11591 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11593 +struct vcmd_virt_stat_v0 {
11596 + uint32_t nr_threads;
11597 + uint32_t nr_running;
11598 + uint32_t nr_uninterruptible;
11599 + uint32_t nr_onhold;
11600 + uint32_t nr_forks;
11601 + uint32_t load[3];
11605 +extern int vc_virt_stat(struct vx_info *, void __user *);
11607 +#endif /* __KERNEL__ */
11608 +#endif /* _VX_CVIRT_CMD_H */
11609 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/cvirt_def.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/cvirt_def.h
11610 --- linux-3.2.5/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11611 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/cvirt_def.h 2011-12-05 19:33:02.000000000 +0100
11613 +#ifndef _VX_CVIRT_DEF_H
11614 +#define _VX_CVIRT_DEF_H
11616 +#include <linux/jiffies.h>
11617 +#include <linux/spinlock.h>
11618 +#include <linux/wait.h>
11619 +#include <linux/time.h>
11620 +#include <asm/atomic.h>
11623 +struct _vx_usage_stat {
11627 + uint64_t softirq;
11633 +struct _vx_syslog {
11634 + wait_queue_head_t log_wait;
11635 + spinlock_t logbuf_lock; /* lock for the log buffer */
11637 + unsigned long log_start; /* next char to be read by syslog() */
11638 + unsigned long con_start; /* next char to be sent to consoles */
11639 + unsigned long log_end; /* most-recently-written-char + 1 */
11640 + unsigned long logged_chars; /* #chars since last read+clear operation */
11642 + char log_buf[1024];
11646 +/* context sub struct */
11648 +struct _vx_cvirt {
11649 + atomic_t nr_threads; /* number of current threads */
11650 + atomic_t nr_running; /* number of running threads */
11651 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11653 + atomic_t nr_onhold; /* processes on hold */
11654 + uint32_t onhold_last; /* jiffies when put on hold */
11656 + struct timespec bias_ts; /* time offset to the host */
11657 + struct timespec bias_idle;
11658 + struct timespec bias_uptime; /* context creation point */
11659 + uint64_t bias_clock; /* offset in clock_t */
11661 + spinlock_t load_lock; /* lock for the load averages */
11662 + atomic_t load_updates; /* nr of load updates done so far */
11663 + uint32_t load_last; /* last time load was calculated */
11664 + uint32_t load[3]; /* load averages 1,5,15 */
11666 + atomic_t total_forks; /* number of forks so far */
11668 + struct _vx_syslog syslog;
11671 +struct _vx_cvirt_pc {
11672 + struct _vx_usage_stat cpustat;
11676 +#ifdef CONFIG_VSERVER_DEBUG
11678 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11680 + printk("\t_vx_cvirt:\n");
11681 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11682 + atomic_read(&cvirt->nr_threads),
11683 + atomic_read(&cvirt->nr_running),
11684 + atomic_read(&cvirt->nr_uninterruptible),
11685 + atomic_read(&cvirt->nr_onhold));
11686 + /* add rest here */
11687 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11692 +#endif /* _VX_CVIRT_DEF_H */
11693 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/debug.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/debug.h
11694 --- linux-3.2.5/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11695 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/debug.h 2011-12-05 19:33:02.000000000 +0100
11697 +#ifndef _VX_DEBUG_H
11698 +#define _VX_DEBUG_H
11701 +#define VXD_CBIT(n, m) (vs_debug_ ## n & (1 << (m)))
11702 +#define VXD_CMIN(n, m) (vs_debug_ ## n > (m))
11703 +#define VXD_MASK(n, m) (vs_debug_ ## n & (m))
11705 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11706 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11707 +#define VXF_DEV "%p[%lu,%d:%d]"
11709 +#if defined(CONFIG_QUOTES_UTF8)
11710 +#define VS_Q_LQM "\xc2\xbb"
11711 +#define VS_Q_RQM "\xc2\xab"
11712 +#elif defined(CONFIG_QUOTES_ASCII)
11713 +#define VS_Q_LQM "\x27"
11714 +#define VS_Q_RQM "\x27"
11716 +#define VS_Q_LQM "\xbb"
11717 +#define VS_Q_RQM "\xab"
11720 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
11723 +#define vxd_path(p) \
11724 + ({ static char _buffer[PATH_MAX]; \
11725 + d_path(p, _buffer, sizeof(_buffer)); })
11727 +#define vxd_cond_path(n) \
11728 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11731 +#ifdef CONFIG_VSERVER_DEBUG
11733 +extern unsigned int vs_debug_switch;
11734 +extern unsigned int vs_debug_xid;
11735 +extern unsigned int vs_debug_nid;
11736 +extern unsigned int vs_debug_tag;
11737 +extern unsigned int vs_debug_net;
11738 +extern unsigned int vs_debug_limit;
11739 +extern unsigned int vs_debug_cres;
11740 +extern unsigned int vs_debug_dlim;
11741 +extern unsigned int vs_debug_quota;
11742 +extern unsigned int vs_debug_cvirt;
11743 +extern unsigned int vs_debug_space;
11744 +extern unsigned int vs_debug_perm;
11745 +extern unsigned int vs_debug_misc;
11748 +#define VX_LOGLEVEL "vxD: "
11749 +#define VX_PROC_FMT "%p: "
11750 +#define VX_PROCESS current
11752 +#define vxdprintk(c, f, x...) \
11755 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11756 + VX_PROCESS , ##x); \
11759 +#define vxlprintk(c, f, x...) \
11762 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11765 +#define vxfprintk(c, f, x...) \
11768 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11774 +void dump_vx_info(struct vx_info *, int);
11775 +void dump_vx_info_inactive(int);
11777 +#else /* CONFIG_VSERVER_DEBUG */
11779 +#define vs_debug_switch 0
11780 +#define vs_debug_xid 0
11781 +#define vs_debug_nid 0
11782 +#define vs_debug_tag 0
11783 +#define vs_debug_net 0
11784 +#define vs_debug_limit 0
11785 +#define vs_debug_cres 0
11786 +#define vs_debug_dlim 0
11787 +#define vs_debug_quota 0
11788 +#define vs_debug_cvirt 0
11789 +#define vs_debug_space 0
11790 +#define vs_debug_perm 0
11791 +#define vs_debug_misc 0
11793 +#define vxdprintk(x...) do { } while (0)
11794 +#define vxlprintk(x...) do { } while (0)
11795 +#define vxfprintk(x...) do { } while (0)
11797 +#endif /* CONFIG_VSERVER_DEBUG */
11800 +#ifdef CONFIG_VSERVER_WARN
11802 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11803 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
11804 +#define VX_WARN_XID "[xid #%u] "
11805 +#define VX_WARN_NID "[nid #%u] "
11806 +#define VX_WARN_TAG "[tag #%u] "
11808 +#define vxwprintk(c, f, x...) \
11811 + printk(VX_WARNLEVEL f "\n", ##x); \
11814 +#else /* CONFIG_VSERVER_WARN */
11816 +#define vxwprintk(x...) do { } while (0)
11818 +#endif /* CONFIG_VSERVER_WARN */
11820 +#define vxwprintk_task(c, f, x...) \
11821 + vxwprintk(c, VX_WARN_TASK f, \
11822 + current->comm, current->pid, \
11823 + current->xid, current->nid, current->tag, ##x)
11824 +#define vxwprintk_xid(c, f, x...) \
11825 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11826 +#define vxwprintk_nid(c, f, x...) \
11827 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11828 +#define vxwprintk_tag(c, f, x...) \
11829 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11831 +#ifdef CONFIG_VSERVER_DEBUG
11832 +#define vxd_assert_lock(l) assert_spin_locked(l)
11833 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11834 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11836 +#define vxd_assert_lock(l) do { } while (0)
11837 +#define vxd_assert(c, f, x...) do { } while (0)
11841 +#endif /* _VX_DEBUG_H */
11842 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/debug_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/debug_cmd.h
11843 --- linux-3.2.5/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11844 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/debug_cmd.h 2011-12-05 19:33:02.000000000 +0100
11846 +#ifndef _VX_DEBUG_CMD_H
11847 +#define _VX_DEBUG_CMD_H
11850 +/* debug commands */
11852 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11854 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11855 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11857 +struct vcmd_read_history_v0 {
11860 + char __user *data;
11863 +struct vcmd_read_monitor_v0 {
11866 + char __user *data;
11872 +#ifdef CONFIG_COMPAT
11874 +#include <asm/compat.h>
11876 +struct vcmd_read_history_v0_x32 {
11879 + compat_uptr_t data_ptr;
11882 +struct vcmd_read_monitor_v0_x32 {
11885 + compat_uptr_t data_ptr;
11888 +#endif /* CONFIG_COMPAT */
11890 +extern int vc_dump_history(uint32_t);
11892 +extern int vc_read_history(uint32_t, void __user *);
11893 +extern int vc_read_monitor(uint32_t, void __user *);
11895 +#ifdef CONFIG_COMPAT
11897 +extern int vc_read_history_x32(uint32_t, void __user *);
11898 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11900 +#endif /* CONFIG_COMPAT */
11902 +#endif /* __KERNEL__ */
11903 +#endif /* _VX_DEBUG_CMD_H */
11904 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/device.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/device.h
11905 --- linux-3.2.5/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11906 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/device.h 2011-12-05 19:33:02.000000000 +0100
11908 +#ifndef _VX_DEVICE_H
11909 +#define _VX_DEVICE_H
11912 +#define DATTR_CREATE 0x00000001
11913 +#define DATTR_OPEN 0x00000002
11915 +#define DATTR_REMAP 0x00000010
11917 +#define DATTR_MASK 0x00000013
11920 +#else /* _VX_DEVICE_H */
11921 +#warning duplicate inclusion
11922 +#endif /* _VX_DEVICE_H */
11923 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/device_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/device_cmd.h
11924 --- linux-3.2.5/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11925 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/device_cmd.h 2011-12-05 19:33:02.000000000 +0100
11927 +#ifndef _VX_DEVICE_CMD_H
11928 +#define _VX_DEVICE_CMD_H
11931 +/* device vserver commands */
11933 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11934 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11936 +struct vcmd_set_mapping_v0 {
11937 + const char __user *device;
11938 + const char __user *target;
11945 +#ifdef CONFIG_COMPAT
11947 +#include <asm/compat.h>
11949 +struct vcmd_set_mapping_v0_x32 {
11950 + compat_uptr_t device_ptr;
11951 + compat_uptr_t target_ptr;
11955 +#endif /* CONFIG_COMPAT */
11957 +#include <linux/compiler.h>
11959 +extern int vc_set_mapping(struct vx_info *, void __user *);
11960 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11962 +#ifdef CONFIG_COMPAT
11964 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11965 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11967 +#endif /* CONFIG_COMPAT */
11969 +#endif /* __KERNEL__ */
11970 +#endif /* _VX_DEVICE_CMD_H */
11971 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/device_def.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/device_def.h
11972 --- linux-3.2.5/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11973 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/device_def.h 2011-12-05 19:33:02.000000000 +0100
11975 +#ifndef _VX_DEVICE_DEF_H
11976 +#define _VX_DEVICE_DEF_H
11978 +#include <linux/types.h>
11980 +struct vx_dmap_target {
11985 +struct _vx_device {
11986 +#ifdef CONFIG_VSERVER_DEVICE
11987 + struct vx_dmap_target targets[2];
11991 +#endif /* _VX_DEVICE_DEF_H */
11992 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/dlimit.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/dlimit.h
11993 --- linux-3.2.5/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11994 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/dlimit.h 2011-12-05 19:33:02.000000000 +0100
11996 +#ifndef _VX_DLIMIT_H
11997 +#define _VX_DLIMIT_H
11999 +#include "switch.h"
12004 +/* keep in sync with CDLIM_INFINITY */
12006 +#define DLIM_INFINITY (~0ULL)
12008 +#include <linux/spinlock.h>
12009 +#include <linux/rcupdate.h>
12011 +struct super_block;
12014 + struct hlist_node dl_hlist; /* linked list of contexts */
12015 + struct rcu_head dl_rcu; /* the rcu head */
12016 + tag_t dl_tag; /* context tag */
12017 + atomic_t dl_usecnt; /* usage count */
12018 + atomic_t dl_refcnt; /* reference count */
12020 + struct super_block *dl_sb; /* associated superblock */
12022 + spinlock_t dl_lock; /* protect the values */
12024 + unsigned long long dl_space_used; /* used space in bytes */
12025 + unsigned long long dl_space_total; /* maximum space in bytes */
12026 + unsigned long dl_inodes_used; /* used inodes */
12027 + unsigned long dl_inodes_total; /* maximum inodes */
12029 + unsigned int dl_nrlmult; /* non root limit mult */
12034 +extern void rcu_free_dl_info(struct rcu_head *);
12035 +extern void unhash_dl_info(struct dl_info *);
12037 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12042 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12044 +typedef uint64_t dlsize_t;
12046 +#endif /* __KERNEL__ */
12047 +#else /* _VX_DLIMIT_H */
12048 +#warning duplicate inclusion
12049 +#endif /* _VX_DLIMIT_H */
12050 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/dlimit_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/dlimit_cmd.h
12051 --- linux-3.2.5/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12052 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/dlimit_cmd.h 2011-12-05 19:33:02.000000000 +0100
12054 +#ifndef _VX_DLIMIT_CMD_H
12055 +#define _VX_DLIMIT_CMD_H
12058 +/* dlimit vserver commands */
12060 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12061 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12063 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12064 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12066 +struct vcmd_ctx_dlimit_base_v0 {
12067 + const char __user *name;
12071 +struct vcmd_ctx_dlimit_v0 {
12072 + const char __user *name;
12073 + uint32_t space_used; /* used space in kbytes */
12074 + uint32_t space_total; /* maximum space in kbytes */
12075 + uint32_t inodes_used; /* used inodes */
12076 + uint32_t inodes_total; /* maximum inodes */
12077 + uint32_t reserved; /* reserved for root in % */
12081 +#define CDLIM_UNSET ((uint32_t)0UL)
12082 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12083 +#define CDLIM_KEEP ((uint32_t)~1UL)
12085 +#define DLIME_UNIT 0
12086 +#define DLIME_KILO 1
12087 +#define DLIME_MEGA 2
12088 +#define DLIME_GIGA 3
12090 +#define DLIMF_SHIFT 0x10
12092 +#define DLIMS_USED 0
12093 +#define DLIMS_TOTAL 2
12096 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12098 + int exp = (flags & DLIMF_SHIFT) ?
12099 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12100 + return ((uint64_t)val) << (10 * exp);
12104 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12108 + if (*flags & DLIMF_SHIFT) {
12109 + while (val > (1LL << 32) && (exp < 3)) {
12113 + *flags &= ~(DLIME_GIGA << shift);
12114 + *flags |= exp << shift;
12122 +#ifdef CONFIG_COMPAT
12124 +#include <asm/compat.h>
12126 +struct vcmd_ctx_dlimit_base_v0_x32 {
12127 + compat_uptr_t name_ptr;
12131 +struct vcmd_ctx_dlimit_v0_x32 {
12132 + compat_uptr_t name_ptr;
12133 + uint32_t space_used; /* used space in kbytes */
12134 + uint32_t space_total; /* maximum space in kbytes */
12135 + uint32_t inodes_used; /* used inodes */
12136 + uint32_t inodes_total; /* maximum inodes */
12137 + uint32_t reserved; /* reserved for root in % */
12141 +#endif /* CONFIG_COMPAT */
12143 +#include <linux/compiler.h>
12145 +extern int vc_add_dlimit(uint32_t, void __user *);
12146 +extern int vc_rem_dlimit(uint32_t, void __user *);
12148 +extern int vc_set_dlimit(uint32_t, void __user *);
12149 +extern int vc_get_dlimit(uint32_t, void __user *);
12151 +#ifdef CONFIG_COMPAT
12153 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12154 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12156 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12157 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12159 +#endif /* CONFIG_COMPAT */
12161 +#endif /* __KERNEL__ */
12162 +#endif /* _VX_DLIMIT_CMD_H */
12163 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/global.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/global.h
12164 --- linux-3.2.5/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12165 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/global.h 2011-12-05 19:33:02.000000000 +0100
12167 +#ifndef _VX_GLOBAL_H
12168 +#define _VX_GLOBAL_H
12171 +extern atomic_t vx_global_ctotal;
12172 +extern atomic_t vx_global_cactive;
12174 +extern atomic_t nx_global_ctotal;
12175 +extern atomic_t nx_global_cactive;
12177 +extern atomic_t vs_global_nsproxy;
12178 +extern atomic_t vs_global_fs;
12179 +extern atomic_t vs_global_mnt_ns;
12180 +extern atomic_t vs_global_uts_ns;
12181 +extern atomic_t vs_global_user_ns;
12182 +extern atomic_t vs_global_pid_ns;
12185 +#endif /* _VX_GLOBAL_H */
12186 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/history.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/history.h
12187 --- linux-3.2.5/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12188 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/history.h 2011-12-05 19:33:02.000000000 +0100
12190 +#ifndef _VX_HISTORY_H
12191 +#define _VX_HISTORY_H
12196 + VXH_THROW_OOPS = 1,
12200 + VXH_INIT_VX_INFO,
12203 + VXH_CLAIM_VX_INFO,
12204 + VXH_RELEASE_VX_INFO,
12205 + VXH_ALLOC_VX_INFO,
12206 + VXH_DEALLOC_VX_INFO,
12207 + VXH_HASH_VX_INFO,
12208 + VXH_UNHASH_VX_INFO,
12210 + VXH_LOOKUP_VX_INFO,
12211 + VXH_CREATE_VX_INFO,
12214 +struct _vxhe_vxi {
12215 + struct vx_info *ptr;
12221 +struct _vxhe_set_clr {
12225 +struct _vxhe_loc_lookup {
12229 +struct _vx_hist_entry {
12231 + unsigned short seq;
12232 + unsigned short type;
12233 + struct _vxhe_vxi vxi;
12235 + struct _vxhe_set_clr sc;
12236 + struct _vxhe_loc_lookup ll;
12240 +#ifdef CONFIG_VSERVER_HISTORY
12242 +extern unsigned volatile int vxh_active;
12244 +struct _vx_hist_entry *vxh_advance(void *loc);
12248 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12250 + entry->vxi.ptr = vxi;
12252 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12253 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12254 + entry->vxi.xid = vxi->vx_id;
12259 +#define __HERE__ current_text_addr()
12261 +#define __VXH_BODY(__type, __data, __here) \
12262 + struct _vx_hist_entry *entry; \
12264 + preempt_disable(); \
12265 + entry = vxh_advance(__here); \
12267 + entry->type = __type; \
12268 + preempt_enable();
12271 + /* pass vxi only */
12273 +#define __VXH_SMPL \
12274 + __vxh_copy_vxi(entry, vxi)
12277 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12279 + __VXH_BODY(__type, __VXH_SMPL, __here)
12282 + /* pass vxi and data (void *) */
12284 +#define __VXH_DATA \
12285 + __vxh_copy_vxi(entry, vxi); \
12286 + entry->sc.data = data
12289 +void __vxh_data(struct vx_info *vxi, void *data,
12290 + int __type, void *__here)
12292 + __VXH_BODY(__type, __VXH_DATA, __here)
12295 + /* pass vxi and arg (long) */
12297 +#define __VXH_LONG \
12298 + __vxh_copy_vxi(entry, vxi); \
12299 + entry->ll.arg = arg
12302 +void __vxh_long(struct vx_info *vxi, long arg,
12303 + int __type, void *__here)
12305 + __VXH_BODY(__type, __VXH_LONG, __here)
12310 +void __vxh_throw_oops(void *__here)
12312 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12313 + /* prevent further acquisition */
12318 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12320 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12321 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12323 +#define __vxh_init_vx_info(v, d, h) \
12324 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12325 +#define __vxh_set_vx_info(v, d, h) \
12326 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12327 +#define __vxh_clr_vx_info(v, d, h) \
12328 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12330 +#define __vxh_claim_vx_info(v, d, h) \
12331 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12332 +#define __vxh_release_vx_info(v, d, h) \
12333 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12335 +#define vxh_alloc_vx_info(v) \
12336 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12337 +#define vxh_dealloc_vx_info(v) \
12338 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12340 +#define vxh_hash_vx_info(v) \
12341 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12342 +#define vxh_unhash_vx_info(v) \
12343 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12345 +#define vxh_loc_vx_info(v, l) \
12346 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12347 +#define vxh_lookup_vx_info(v, l) \
12348 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12349 +#define vxh_create_vx_info(v, l) \
12350 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12352 +extern void vxh_dump_history(void);
12355 +#else /* CONFIG_VSERVER_HISTORY */
12357 +#define __HERE__ 0
12359 +#define vxh_throw_oops() do { } while (0)
12361 +#define __vxh_get_vx_info(v, h) do { } while (0)
12362 +#define __vxh_put_vx_info(v, h) do { } while (0)
12364 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12365 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12366 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12368 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12369 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12371 +#define vxh_alloc_vx_info(v) do { } while (0)
12372 +#define vxh_dealloc_vx_info(v) do { } while (0)
12374 +#define vxh_hash_vx_info(v) do { } while (0)
12375 +#define vxh_unhash_vx_info(v) do { } while (0)
12377 +#define vxh_loc_vx_info(v, l) do { } while (0)
12378 +#define vxh_lookup_vx_info(v, l) do { } while (0)
12379 +#define vxh_create_vx_info(v, l) do { } while (0)
12381 +#define vxh_dump_history() do { } while (0)
12384 +#endif /* CONFIG_VSERVER_HISTORY */
12386 +#endif /* _VX_HISTORY_H */
12387 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/inode.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/inode.h
12388 --- linux-3.2.5/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
12389 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/inode.h 2011-12-05 19:33:02.000000000 +0100
12391 +#ifndef _VX_INODE_H
12392 +#define _VX_INODE_H
12395 +#define IATTR_TAG 0x01000000
12397 +#define IATTR_ADMIN 0x00000001
12398 +#define IATTR_WATCH 0x00000002
12399 +#define IATTR_HIDE 0x00000004
12400 +#define IATTR_FLAGS 0x00000007
12402 +#define IATTR_BARRIER 0x00010000
12403 +#define IATTR_IXUNLINK 0x00020000
12404 +#define IATTR_IMMUTABLE 0x00040000
12405 +#define IATTR_COW 0x00080000
12410 +#ifdef CONFIG_VSERVER_PROC_SECURE
12411 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12412 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12414 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12415 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12418 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12420 +#endif /* __KERNEL__ */
12422 +/* inode ioctls */
12424 +#define FIOC_GETXFLG _IOR('x', 5, long)
12425 +#define FIOC_SETXFLG _IOW('x', 6, long)
12427 +#else /* _VX_INODE_H */
12428 +#warning duplicate inclusion
12429 +#endif /* _VX_INODE_H */
12430 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/inode_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/inode_cmd.h
12431 --- linux-3.2.5/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
12432 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/inode_cmd.h 2011-12-05 19:33:02.000000000 +0100
12434 +#ifndef _VX_INODE_CMD_H
12435 +#define _VX_INODE_CMD_H
12438 +/* inode vserver commands */
12440 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12441 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12443 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12444 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12446 +struct vcmd_ctx_iattr_v1 {
12447 + const char __user *name;
12453 +struct vcmd_ctx_fiattr_v0 {
12463 +#ifdef CONFIG_COMPAT
12465 +#include <asm/compat.h>
12467 +struct vcmd_ctx_iattr_v1_x32 {
12468 + compat_uptr_t name_ptr;
12474 +#endif /* CONFIG_COMPAT */
12476 +#include <linux/compiler.h>
12478 +extern int vc_get_iattr(void __user *);
12479 +extern int vc_set_iattr(void __user *);
12481 +extern int vc_fget_iattr(uint32_t, void __user *);
12482 +extern int vc_fset_iattr(uint32_t, void __user *);
12484 +#ifdef CONFIG_COMPAT
12486 +extern int vc_get_iattr_x32(void __user *);
12487 +extern int vc_set_iattr_x32(void __user *);
12489 +#endif /* CONFIG_COMPAT */
12491 +#endif /* __KERNEL__ */
12492 +#endif /* _VX_INODE_CMD_H */
12493 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/limit.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/limit.h
12494 --- linux-3.2.5/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12495 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/limit.h 2011-12-05 19:33:02.000000000 +0100
12497 +#ifndef _VX_LIMIT_H
12498 +#define _VX_LIMIT_H
12500 +#define VLIMIT_NSOCK 16
12501 +#define VLIMIT_OPENFD 17
12502 +#define VLIMIT_ANON 18
12503 +#define VLIMIT_SHMEM 19
12504 +#define VLIMIT_SEMARY 20
12505 +#define VLIMIT_NSEMS 21
12506 +#define VLIMIT_DENTRY 22
12507 +#define VLIMIT_MAPPED 23
12512 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12514 +/* keep in sync with CRLIM_INFINITY */
12516 +#define VLIM_INFINITY (~0ULL)
12518 +#include <asm/atomic.h>
12519 +#include <asm/resource.h>
12521 +#ifndef RLIM_INFINITY
12522 +#warning RLIM_INFINITY is undefined
12525 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12527 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12528 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12530 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12531 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12532 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12534 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12535 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12537 +typedef atomic_long_t rlim_atomic_t;
12538 +typedef unsigned long rlim_t;
12540 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12541 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12542 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12543 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12544 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12545 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12548 +#if (RLIM_INFINITY == VLIM_INFINITY)
12549 +#define VX_VLIM(r) ((long long)(long)(r))
12550 +#define VX_RLIM(v) ((rlim_t)(v))
12552 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12553 + ? VLIM_INFINITY : (long long)(r))
12554 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12555 + ? RLIM_INFINITY : (rlim_t)(v))
12560 +void vx_vsi_meminfo(struct sysinfo *);
12561 +void vx_vsi_swapinfo(struct sysinfo *);
12562 +long vx_vsi_cached(struct sysinfo *);
12564 +#define NUM_LIMITS 24
12566 +#endif /* __KERNEL__ */
12567 +#endif /* _VX_LIMIT_H */
12568 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/limit_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/limit_cmd.h
12569 --- linux-3.2.5/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12570 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/limit_cmd.h 2011-12-05 19:33:02.000000000 +0100
12572 +#ifndef _VX_LIMIT_CMD_H
12573 +#define _VX_LIMIT_CMD_H
12576 +/* rlimit vserver commands */
12578 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12579 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12580 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12581 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
12582 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12584 +struct vcmd_ctx_rlimit_v0 {
12586 + uint64_t minimum;
12587 + uint64_t softlimit;
12588 + uint64_t maximum;
12591 +struct vcmd_ctx_rlimit_mask_v0 {
12592 + uint32_t minimum;
12593 + uint32_t softlimit;
12594 + uint32_t maximum;
12597 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12599 +struct vcmd_rlimit_stat_v0 {
12603 + uint64_t minimum;
12604 + uint64_t maximum;
12607 +#define CRLIM_UNSET (0ULL)
12608 +#define CRLIM_INFINITY (~0ULL)
12609 +#define CRLIM_KEEP (~1ULL)
12613 +#ifdef CONFIG_IA32_EMULATION
12615 +struct vcmd_ctx_rlimit_v0_x32 {
12617 + uint64_t minimum;
12618 + uint64_t softlimit;
12619 + uint64_t maximum;
12620 +} __attribute__ ((packed));
12622 +#endif /* CONFIG_IA32_EMULATION */
12624 +#include <linux/compiler.h>
12626 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12627 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12628 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12629 +extern int vc_reset_hits(struct vx_info *, void __user *);
12630 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12632 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12634 +#ifdef CONFIG_IA32_EMULATION
12636 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12637 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12639 +#endif /* CONFIG_IA32_EMULATION */
12641 +#endif /* __KERNEL__ */
12642 +#endif /* _VX_LIMIT_CMD_H */
12643 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/limit_def.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/limit_def.h
12644 --- linux-3.2.5/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12645 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/limit_def.h 2011-12-05 19:33:02.000000000 +0100
12647 +#ifndef _VX_LIMIT_DEF_H
12648 +#define _VX_LIMIT_DEF_H
12650 +#include <asm/atomic.h>
12651 +#include <asm/resource.h>
12653 +#include "limit.h"
12656 +struct _vx_res_limit {
12657 + rlim_t soft; /* Context soft limit */
12658 + rlim_t hard; /* Context hard limit */
12660 + rlim_atomic_t rcur; /* Current value */
12661 + rlim_t rmin; /* Context minimum */
12662 + rlim_t rmax; /* Context maximum */
12664 + atomic_t lhit; /* Limit hits */
12667 +/* context sub struct */
12669 +struct _vx_limit {
12670 + struct _vx_res_limit res[NUM_LIMITS];
12673 +#ifdef CONFIG_VSERVER_DEBUG
12675 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12679 + printk("\t_vx_limit:");
12680 + for (i = 0; i < NUM_LIMITS; i++) {
12681 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12682 + i, (unsigned long)__rlim_get(limit, i),
12683 + (unsigned long)__rlim_rmin(limit, i),
12684 + (unsigned long)__rlim_rmax(limit, i),
12685 + (long)__rlim_soft(limit, i),
12686 + (long)__rlim_hard(limit, i),
12687 + atomic_read(&__rlim_lhit(limit, i)));
12693 +#endif /* _VX_LIMIT_DEF_H */
12694 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/limit_int.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/limit_int.h
12695 --- linux-3.2.5/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12696 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/limit_int.h 2011-12-05 19:33:02.000000000 +0100
12698 +#ifndef _VX_LIMIT_INT_H
12699 +#define _VX_LIMIT_INT_H
12701 +#include "context.h"
12705 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12706 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12708 +extern const char *vlimit_name[NUM_LIMITS];
12710 +static inline void __vx_acc_cres(struct vx_info *vxi,
12711 + int res, int dir, void *_data, char *_file, int _line)
12713 + if (VXD_RCRES_COND(res))
12714 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12715 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12716 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12717 + (dir > 0) ? "++" : "--", _data, _file, _line);
12722 + __rlim_inc(&vxi->limit, res);
12724 + __rlim_dec(&vxi->limit, res);
12727 +static inline void __vx_add_cres(struct vx_info *vxi,
12728 + int res, int amount, void *_data, char *_file, int _line)
12730 + if (VXD_RCRES_COND(res))
12731 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12732 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12733 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12734 + amount, _data, _file, _line);
12739 + __rlim_add(&vxi->limit, res, amount);
12743 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12745 + int cond = (value > __rlim_rmax(limit, res));
12748 + __rlim_rmax(limit, res) = value;
12753 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12755 + int cond = (value < __rlim_rmin(limit, res));
12758 + __rlim_rmin(limit, res) = value;
12763 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12765 + if (!__vx_cres_adjust_max(limit, res, value))
12766 + __vx_cres_adjust_min(limit, res, value);
12771 + +1 ... no limit hit
12772 + -1 ... over soft limit
12773 + 0 ... over hard limit */
12775 +static inline int __vx_cres_avail(struct vx_info *vxi,
12776 + int res, int num, char *_file, int _line)
12778 + struct _vx_limit *limit;
12781 + if (VXD_RLIMIT_COND(res))
12782 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12783 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12784 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12785 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12786 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12787 + num, _file, _line);
12791 + limit = &vxi->limit;
12792 + value = __rlim_get(limit, res);
12794 + if (!__vx_cres_adjust_max(limit, res, value))
12795 + __vx_cres_adjust_min(limit, res, value);
12800 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12802 + if (value + num <= __rlim_soft(limit, res))
12805 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12807 + if (value + num <= __rlim_hard(limit, res))
12810 + __rlim_hit(limit, res);
12815 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12818 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12820 + rlim_t value, sum = 0;
12823 + while ((res = *array++)) {
12824 + value = __rlim_get(limit, res);
12825 + __vx_cres_fixup(limit, res, value);
12832 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12834 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12835 + int res = *array;
12837 + if (value == __rlim_get(limit, res))
12840 + __rlim_set(limit, res, value);
12841 + /* now adjust min/max */
12842 + if (!__vx_cres_adjust_max(limit, res, value))
12843 + __vx_cres_adjust_min(limit, res, value);
12848 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12849 + const int *array, int num, char *_file, int _line)
12851 + struct _vx_limit *limit;
12852 + rlim_t value = 0;
12860 + limit = &vxi->limit;
12862 + value = __vx_cres_array_sum(limit, array + 1);
12864 + __rlim_set(limit, res, value);
12865 + __vx_cres_fixup(limit, res, value);
12867 + return __vx_cres_avail(vxi, res, num, _file, _line);
12871 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12876 + /* complex resources first */
12877 + if ((id < 0) || (id == RLIMIT_RSS))
12878 + __vx_cres_array_fixup(limit, VLA_RSS);
12880 + for (res = 0; res < NUM_LIMITS; res++) {
12881 + if ((id > 0) && (res != id))
12884 + value = __rlim_get(limit, res);
12885 + __vx_cres_fixup(limit, res, value);
12887 + /* not supposed to happen, maybe warn? */
12888 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12889 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12894 +#endif /* __KERNEL__ */
12895 +#endif /* _VX_LIMIT_INT_H */
12896 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/monitor.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/monitor.h
12897 --- linux-3.2.5/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12898 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/monitor.h 2011-12-05 19:33:02.000000000 +0100
12900 +#ifndef _VX_MONITOR_H
12901 +#define _VX_MONITOR_H
12903 +#include <linux/types.h>
12910 + VXM_UPDATE = 0x20,
12914 + VXM_RQINFO_1 = 0x24,
12917 + VXM_ACTIVATE = 0x40,
12924 + VXM_MIGRATE = 0x48,
12927 + /* all other bits are flags */
12928 + VXM_SCHED = 0x80,
12931 +struct _vxm_update_1 {
12932 + uint32_t tokens_max;
12933 + uint32_t fill_rate;
12934 + uint32_t interval;
12937 +struct _vxm_update_2 {
12938 + uint32_t tokens_min;
12939 + uint32_t fill_rate;
12940 + uint32_t interval;
12943 +struct _vxm_rqinfo_1 {
12944 + uint16_t running;
12948 + uint32_t idle_tokens;
12951 +struct _vxm_rqinfo_2 {
12952 + uint32_t norm_time;
12953 + uint32_t idle_time;
12954 + uint32_t idle_skip;
12957 +struct _vxm_sched {
12959 + uint32_t norm_time;
12960 + uint32_t idle_time;
12963 +struct _vxm_task {
12968 +struct _vxm_event {
12977 + struct _vxm_task tsk;
12981 +struct _vx_mon_entry {
12985 + struct _vxm_event ev;
12986 + struct _vxm_sched sd;
12987 + struct _vxm_update_1 u1;
12988 + struct _vxm_update_2 u2;
12989 + struct _vxm_rqinfo_1 q1;
12990 + struct _vxm_rqinfo_2 q2;
12995 +#endif /* _VX_MONITOR_H */
12996 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/network.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/network.h
12997 --- linux-3.2.5/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12998 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/network.h 2011-12-05 19:33:02.000000000 +0100
13000 +#ifndef _VX_NETWORK_H
13001 +#define _VX_NETWORK_H
13003 +#include <linux/types.h>
13006 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13009 +/* network flags */
13011 +#define NXF_INFO_PRIVATE 0x00000008
13013 +#define NXF_SINGLE_IP 0x00000100
13014 +#define NXF_LBACK_REMAP 0x00000200
13015 +#define NXF_LBACK_ALLOW 0x00000400
13017 +#define NXF_HIDE_NETIF 0x02000000
13018 +#define NXF_HIDE_LBACK 0x04000000
13020 +#define NXF_STATE_SETUP (1ULL << 32)
13021 +#define NXF_STATE_ADMIN (1ULL << 34)
13023 +#define NXF_SC_HELPER (1ULL << 36)
13024 +#define NXF_PERSISTENT (1ULL << 38)
13026 +#define NXF_ONE_TIME (0x0005ULL << 32)
13029 +#define NXF_INIT_SET (__nxf_init_set())
13031 +static inline uint64_t __nxf_init_set(void) {
13032 + return NXF_STATE_ADMIN
13033 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13034 + | NXF_LBACK_REMAP
13037 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13040 + | NXF_HIDE_NETIF;
13044 +/* network caps */
13046 +#define NXC_TUN_CREATE 0x00000001
13048 +#define NXC_RAW_ICMP 0x00000100
13050 +#define NXC_MULTICAST 0x00001000
13053 +/* address types */
13055 +#define NXA_TYPE_IPV4 0x0001
13056 +#define NXA_TYPE_IPV6 0x0002
13058 +#define NXA_TYPE_NONE 0x0000
13059 +#define NXA_TYPE_ANY 0x00FF
13061 +#define NXA_TYPE_ADDR 0x0010
13062 +#define NXA_TYPE_MASK 0x0020
13063 +#define NXA_TYPE_RANGE 0x0040
13065 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13067 +#define NXA_MOD_BCAST 0x0100
13068 +#define NXA_MOD_LBACK 0x0200
13070 +#define NXA_LOOPBACK 0x1000
13072 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13073 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13077 +#include <linux/list.h>
13078 +#include <linux/spinlock.h>
13079 +#include <linux/rcupdate.h>
13080 +#include <linux/in.h>
13081 +#include <linux/in6.h>
13082 +#include <asm/atomic.h>
13084 +struct nx_addr_v4 {
13085 + struct nx_addr_v4 *next;
13086 + struct in_addr ip[2];
13087 + struct in_addr mask;
13092 +struct nx_addr_v6 {
13093 + struct nx_addr_v6 *next;
13094 + struct in6_addr ip;
13095 + struct in6_addr mask;
13102 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13103 + nid_t nx_id; /* vnet id */
13104 + atomic_t nx_usecnt; /* usage count */
13105 + atomic_t nx_tasks; /* tasks count */
13106 + int nx_state; /* context state */
13108 + uint64_t nx_flags; /* network flag word */
13109 + uint64_t nx_ncaps; /* network capabilities */
13111 + struct in_addr v4_lback; /* Loopback address */
13112 + struct in_addr v4_bcast; /* Broadcast address */
13113 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13114 +#ifdef CONFIG_IPV6
13115 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13117 + char nx_name[65]; /* network context name */
13121 +/* status flags */
13123 +#define NXS_HASHED 0x0001
13124 +#define NXS_SHUTDOWN 0x0100
13125 +#define NXS_RELEASED 0x8000
13127 +extern struct nx_info *lookup_nx_info(int);
13129 +extern int get_nid_list(int, unsigned int *, int);
13130 +extern int nid_is_hashed(nid_t);
13132 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13134 +extern long vs_net_change(struct nx_info *, unsigned int);
13139 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13140 +#ifdef CONFIG_IPV6
13141 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13143 +#define NX_IPV6(n) (0)
13146 +#endif /* __KERNEL__ */
13147 +#endif /* _VX_NETWORK_H */
13148 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/network_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/network_cmd.h
13149 --- linux-3.2.5/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13150 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/network_cmd.h 2011-12-05 19:33:02.000000000 +0100
13152 +#ifndef _VX_NETWORK_CMD_H
13153 +#define _VX_NETWORK_CMD_H
13156 +/* vinfo commands */
13158 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13161 +extern int vc_task_nid(uint32_t);
13163 +#endif /* __KERNEL__ */
13165 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13167 +struct vcmd_nx_info_v0 {
13169 + /* more to come */
13173 +extern int vc_nx_info(struct nx_info *, void __user *);
13175 +#endif /* __KERNEL__ */
13177 +#include <linux/in.h>
13178 +#include <linux/in6.h>
13180 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13181 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13183 +struct vcmd_net_create {
13184 + uint64_t flagword;
13187 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13189 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13190 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13192 +struct vcmd_net_addr_v0 {
13195 + struct in_addr ip[4];
13196 + struct in_addr mask[4];
13199 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13200 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13202 +struct vcmd_net_addr_ipv4_v1 {
13205 + struct in_addr ip;
13206 + struct in_addr mask;
13209 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13210 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13212 +struct vcmd_net_addr_ipv4_v2 {
13215 + struct in_addr ip;
13216 + struct in_addr ip2;
13217 + struct in_addr mask;
13220 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13221 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13223 +struct vcmd_net_addr_ipv6_v1 {
13227 + struct in6_addr ip;
13228 + struct in6_addr mask;
13231 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13232 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13234 +struct vcmd_match_ipv4_v0 {
13239 + struct in_addr ip;
13240 + struct in_addr ip2;
13241 + struct in_addr mask;
13244 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13245 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13247 +struct vcmd_match_ipv6_v0 {
13252 + struct in6_addr ip;
13253 + struct in6_addr ip2;
13254 + struct in6_addr mask;
13259 +extern int vc_net_create(uint32_t, void __user *);
13260 +extern int vc_net_migrate(struct nx_info *, void __user *);
13262 +extern int vc_net_add(struct nx_info *, void __user *);
13263 +extern int vc_net_remove(struct nx_info *, void __user *);
13265 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
13266 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13268 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
13269 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
13271 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13272 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13274 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13275 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13277 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13278 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13280 +#endif /* __KERNEL__ */
13283 +/* flag commands */
13285 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13286 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13288 +struct vcmd_net_flags_v0 {
13289 + uint64_t flagword;
13294 +extern int vc_get_nflags(struct nx_info *, void __user *);
13295 +extern int vc_set_nflags(struct nx_info *, void __user *);
13297 +#endif /* __KERNEL__ */
13300 +/* network caps commands */
13302 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13303 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13305 +struct vcmd_net_caps_v0 {
13311 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13312 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13314 +#endif /* __KERNEL__ */
13315 +#endif /* _VX_CONTEXT_CMD_H */
13316 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/percpu.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/percpu.h
13317 --- linux-3.2.5/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13318 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/percpu.h 2011-12-05 19:33:02.000000000 +0100
13320 +#ifndef _VX_PERCPU_H
13321 +#define _VX_PERCPU_H
13323 +#include "cvirt_def.h"
13324 +#include "sched_def.h"
13326 +struct _vx_percpu {
13327 + struct _vx_cvirt_pc cvirt;
13328 + struct _vx_sched_pc sched;
13331 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13333 +#endif /* _VX_PERCPU_H */
13334 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/pid.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/pid.h
13335 --- linux-3.2.5/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13336 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/pid.h 2011-12-05 19:33:02.000000000 +0100
13338 +#ifndef _VSERVER_PID_H
13339 +#define _VSERVER_PID_H
13341 +/* pid faking stuff */
13343 +#define vx_info_map_pid(v, p) \
13344 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13345 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13346 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13347 +#define vx_map_tgid(p) vx_map_pid(p)
13349 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13350 + const char *func, const char *file, int line)
13352 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13353 + vxfprintk(VXD_CBIT(cvirt, 2),
13354 + "vx_map_tgid: %p/%llx: %d -> %d",
13355 + vxi, (long long)vxi->vx_flags, pid,
13356 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13357 + func, file, line);
13360 + if (pid == vxi->vx_initpid)
13366 +#define vx_info_rmap_pid(v, p) \
13367 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13368 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13369 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13371 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13372 + const char *func, const char *file, int line)
13374 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13375 + vxfprintk(VXD_CBIT(cvirt, 2),
13376 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13377 + vxi, (long long)vxi->vx_flags, pid,
13378 + (pid == 1) ? vxi->vx_initpid : pid,
13379 + func, file, line);
13380 + if ((pid == 1) && vxi->vx_initpid)
13381 + return vxi->vx_initpid;
13382 + if (pid == vxi->vx_initpid)
13389 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/sched.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/sched.h
13390 --- linux-3.2.5/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13391 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/sched.h 2011-12-05 19:33:02.000000000 +0100
13393 +#ifndef _VX_SCHED_H
13394 +#define _VX_SCHED_H
13401 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13406 +void vx_update_load(struct vx_info *);
13409 +void vx_update_sched_param(struct _vx_sched *sched,
13410 + struct _vx_sched_pc *sched_pc);
13412 +#endif /* __KERNEL__ */
13413 +#else /* _VX_SCHED_H */
13414 +#warning duplicate inclusion
13415 +#endif /* _VX_SCHED_H */
13416 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/sched_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/sched_cmd.h
13417 --- linux-3.2.5/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
13418 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/sched_cmd.h 2011-12-05 19:33:02.000000000 +0100
13420 +#ifndef _VX_SCHED_CMD_H
13421 +#define _VX_SCHED_CMD_H
13424 +struct vcmd_prio_bias {
13426 + int32_t prio_bias;
13429 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13430 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13434 +#include <linux/compiler.h>
13436 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
13437 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
13439 +#endif /* __KERNEL__ */
13440 +#endif /* _VX_SCHED_CMD_H */
13441 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/sched_def.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/sched_def.h
13442 --- linux-3.2.5/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13443 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/sched_def.h 2011-12-05 19:33:02.000000000 +0100
13445 +#ifndef _VX_SCHED_DEF_H
13446 +#define _VX_SCHED_DEF_H
13448 +#include <linux/spinlock.h>
13449 +#include <linux/jiffies.h>
13450 +#include <linux/cpumask.h>
13451 +#include <asm/atomic.h>
13452 +#include <asm/param.h>
13455 +/* context sub struct */
13457 +struct _vx_sched {
13458 + int prio_bias; /* bias offset for priority */
13460 + cpumask_t update; /* CPUs which should update */
13463 +struct _vx_sched_pc {
13464 + int prio_bias; /* bias offset for priority */
13466 + uint64_t user_ticks; /* token tick events */
13467 + uint64_t sys_ticks; /* token tick events */
13468 + uint64_t hold_ticks; /* token ticks paused */
13472 +#ifdef CONFIG_VSERVER_DEBUG
13474 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13476 + printk("\t_vx_sched:\n");
13477 + printk("\t priority = %4d\n", sched->prio_bias);
13482 +#endif /* _VX_SCHED_DEF_H */
13483 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/signal.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/signal.h
13484 --- linux-3.2.5/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13485 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/signal.h 2011-12-05 19:33:02.000000000 +0100
13487 +#ifndef _VX_SIGNAL_H
13488 +#define _VX_SIGNAL_H
13495 +int vx_info_kill(struct vx_info *, int, int);
13497 +#endif /* __KERNEL__ */
13498 +#else /* _VX_SIGNAL_H */
13499 +#warning duplicate inclusion
13500 +#endif /* _VX_SIGNAL_H */
13501 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/signal_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/signal_cmd.h
13502 --- linux-3.2.5/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13503 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/signal_cmd.h 2011-12-05 19:33:02.000000000 +0100
13505 +#ifndef _VX_SIGNAL_CMD_H
13506 +#define _VX_SIGNAL_CMD_H
13509 +/* signalling vserver commands */
13511 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13512 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13514 +struct vcmd_ctx_kill_v0 {
13519 +struct vcmd_wait_exit_v0 {
13520 + int32_t reboot_cmd;
13521 + int32_t exit_code;
13526 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13527 +extern int vc_wait_exit(struct vx_info *, void __user *);
13529 +#endif /* __KERNEL__ */
13531 +/* process alteration commands */
13533 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13534 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13536 +struct vcmd_pflags_v0 {
13537 + uint32_t flagword;
13543 +extern int vc_get_pflags(uint32_t pid, void __user *);
13544 +extern int vc_set_pflags(uint32_t pid, void __user *);
13546 +#endif /* __KERNEL__ */
13547 +#endif /* _VX_SIGNAL_CMD_H */
13548 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/space.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/space.h
13549 --- linux-3.2.5/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13550 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/space.h 2011-12-05 19:33:02.000000000 +0100
13552 +#ifndef _VX_SPACE_H
13553 +#define _VX_SPACE_H
13555 +#include <linux/types.h>
13559 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13561 +#else /* _VX_SPACE_H */
13562 +#warning duplicate inclusion
13563 +#endif /* _VX_SPACE_H */
13564 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/space_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/space_cmd.h
13565 --- linux-3.2.5/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13566 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/space_cmd.h 2011-12-05 19:33:02.000000000 +0100
13568 +#ifndef _VX_SPACE_CMD_H
13569 +#define _VX_SPACE_CMD_H
13572 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13573 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13574 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13576 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13577 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13578 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13580 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13582 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13583 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13586 +struct vcmd_space_mask_v1 {
13590 +struct vcmd_space_mask_v2 {
13598 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13599 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13600 +extern int vc_enter_space(struct vx_info *, void __user *);
13601 +extern int vc_set_space(struct vx_info *, void __user *);
13602 +extern int vc_get_space_mask(void __user *, int);
13604 +#endif /* __KERNEL__ */
13605 +#endif /* _VX_SPACE_CMD_H */
13606 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/switch.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/switch.h
13607 --- linux-3.2.5/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13608 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/switch.h 2011-12-05 19:33:02.000000000 +0100
13610 +#ifndef _VX_SWITCH_H
13611 +#define _VX_SWITCH_H
13613 +#include <linux/types.h>
13616 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13617 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13618 +#define VC_VERSION(c) ((c) & 0xFFF)
13620 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13621 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13625 + Syscall Matrix V2.8
13627 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13628 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13629 + |INFO |SETUP | |MOVE | | | | | |
13630 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13631 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13632 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13633 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13634 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13635 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13636 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13637 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13638 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13639 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13640 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13641 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13642 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13643 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13644 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13645 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13646 + OTHER |VSTAT | | | | | | |VINFO | |
13647 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13648 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13649 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13650 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13651 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13652 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13653 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13654 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13658 +#define VC_CAT_VERSION 0
13660 +#define VC_CAT_VSETUP 1
13661 +#define VC_CAT_VHOST 2
13663 +#define VC_CAT_DEVICE 6
13665 +#define VC_CAT_VPROC 9
13666 +#define VC_CAT_PROCALT 10
13667 +#define VC_CAT_PROCMIG 11
13668 +#define VC_CAT_PROCTRL 12
13670 +#define VC_CAT_SCHED 14
13671 +#define VC_CAT_MEMCTRL 20
13673 +#define VC_CAT_VNET 25
13674 +#define VC_CAT_NETALT 26
13675 +#define VC_CAT_NETMIG 27
13676 +#define VC_CAT_NETCTRL 28
13678 +#define VC_CAT_TAGMIG 35
13679 +#define VC_CAT_DLIMIT 36
13680 +#define VC_CAT_INODE 38
13682 +#define VC_CAT_VSTAT 40
13683 +#define VC_CAT_VINFO 46
13684 +#define VC_CAT_EVENT 48
13686 +#define VC_CAT_FLAGS 52
13687 +#define VC_CAT_VSPACE 54
13688 +#define VC_CAT_DEBUG 56
13689 +#define VC_CAT_RLIMIT 60
13691 +#define VC_CAT_SYSTEST 61
13692 +#define VC_CAT_COMPAT 63
13694 +/* query version */
13696 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13697 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13702 +#include <linux/errno.h>
13704 +#endif /* __KERNEL__ */
13706 +#endif /* _VX_SWITCH_H */
13708 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/tag.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/tag.h
13709 --- linux-3.2.5/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13710 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/tag.h 2011-12-05 19:33:02.000000000 +0100
13715 +#include <linux/types.h>
13718 +#define DX_TAG(in) (IS_TAGGED(in))
13721 +#ifdef CONFIG_TAG_NFSD
13722 +#define DX_TAG_NFSD 1
13724 +#define DX_TAG_NFSD 0
13728 +#ifdef CONFIG_TAGGING_NONE
13730 +#define MAX_UID 0xFFFFFFFF
13731 +#define MAX_GID 0xFFFFFFFF
13733 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13735 +#define TAGINO_UID(cond, uid, tag) (uid)
13736 +#define TAGINO_GID(cond, gid, tag) (gid)
13741 +#ifdef CONFIG_TAGGING_GID16
13743 +#define MAX_UID 0xFFFFFFFF
13744 +#define MAX_GID 0x0000FFFF
13746 +#define INOTAG_TAG(cond, uid, gid, tag) \
13747 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13749 +#define TAGINO_UID(cond, uid, tag) (uid)
13750 +#define TAGINO_GID(cond, gid, tag) \
13751 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13756 +#ifdef CONFIG_TAGGING_ID24
13758 +#define MAX_UID 0x00FFFFFF
13759 +#define MAX_GID 0x00FFFFFF
13761 +#define INOTAG_TAG(cond, uid, gid, tag) \
13762 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13764 +#define TAGINO_UID(cond, uid, tag) \
13765 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13766 +#define TAGINO_GID(cond, gid, tag) \
13767 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13772 +#ifdef CONFIG_TAGGING_UID16
13774 +#define MAX_UID 0x0000FFFF
13775 +#define MAX_GID 0xFFFFFFFF
13777 +#define INOTAG_TAG(cond, uid, gid, tag) \
13778 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13780 +#define TAGINO_UID(cond, uid, tag) \
13781 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13782 +#define TAGINO_GID(cond, gid, tag) (gid)
13787 +#ifdef CONFIG_TAGGING_INTERN
13789 +#define MAX_UID 0xFFFFFFFF
13790 +#define MAX_GID 0xFFFFFFFF
13792 +#define INOTAG_TAG(cond, uid, gid, tag) \
13793 + ((cond) ? (tag) : 0)
13795 +#define TAGINO_UID(cond, uid, tag) (uid)
13796 +#define TAGINO_GID(cond, gid, tag) (gid)
13801 +#ifndef CONFIG_TAGGING_NONE
13802 +#define dx_current_fstag(sb) \
13803 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13805 +#define dx_current_fstag(sb) (0)
13808 +#ifndef CONFIG_TAGGING_INTERN
13809 +#define TAGINO_TAG(cond, tag) (0)
13811 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13814 +#define INOTAG_UID(cond, uid, gid) \
13815 + ((cond) ? ((uid) & MAX_UID) : (uid))
13816 +#define INOTAG_GID(cond, uid, gid) \
13817 + ((cond) ? ((gid) & MAX_GID) : (gid))
13820 +static inline uid_t dx_map_uid(uid_t uid)
13822 + if ((uid > MAX_UID) && (uid != -1))
13824 + return (uid & MAX_UID);
13827 +static inline gid_t dx_map_gid(gid_t gid)
13829 + if ((gid > MAX_GID) && (gid != -1))
13831 + return (gid & MAX_GID);
13839 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13841 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13842 + unsigned long *flags);
13844 +#ifdef CONFIG_PROPAGATE
13846 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13848 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13851 +#define dx_propagate_tag(n, i) do { } while (0)
13854 +#endif /* _DX_TAG_H */
13855 diff -NurpP --minimal linux-3.2.5/include/linux/vserver/tag_cmd.h linux-3.2.5-vs2.3.2.6/include/linux/vserver/tag_cmd.h
13856 --- linux-3.2.5/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13857 +++ linux-3.2.5-vs2.3.2.6/include/linux/vserver/tag_cmd.h 2011-12-05 19:33:02.000000000 +0100
13859 +#ifndef _VX_TAG_CMD_H
13860 +#define _VX_TAG_CMD_H
13863 +/* vinfo commands */
13865 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13868 +extern int vc_task_tag(uint32_t);
13870 +#endif /* __KERNEL__ */
13872 +/* context commands */
13874 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13877 +extern int vc_tag_migrate(uint32_t);
13879 +#endif /* __KERNEL__ */
13880 +#endif /* _VX_TAG_CMD_H */
13881 diff -NurpP --minimal linux-3.2.5/include/net/addrconf.h linux-3.2.5-vs2.3.2.6/include/net/addrconf.h
13882 --- linux-3.2.5/include/net/addrconf.h 2012-01-09 16:14:59.000000000 +0100
13883 +++ linux-3.2.5-vs2.3.2.6/include/net/addrconf.h 2011-12-05 19:33:02.000000000 +0100
13884 @@ -80,7 +80,8 @@ extern int ipv6_dev_get_saddr(struct n
13885 struct net_device *dev,
13886 const struct in6_addr *daddr,
13887 unsigned int srcprefs,
13888 - struct in6_addr *saddr);
13889 + struct in6_addr *saddr,
13890 + struct nx_info *nxi);
13891 extern int ipv6_get_lladdr(struct net_device *dev,
13892 struct in6_addr *addr,
13893 unsigned char banned_flags);
13894 diff -NurpP --minimal linux-3.2.5/include/net/af_unix.h linux-3.2.5-vs2.3.2.6/include/net/af_unix.h
13895 --- linux-3.2.5/include/net/af_unix.h 2011-07-22 11:18:11.000000000 +0200
13896 +++ linux-3.2.5-vs2.3.2.6/include/net/af_unix.h 2011-12-05 19:33:02.000000000 +0100
13898 #include <linux/socket.h>
13899 #include <linux/un.h>
13900 #include <linux/mutex.h>
13901 +#include <linux/vs_base.h>
13902 #include <net/sock.h>
13904 extern void unix_inflight(struct file *fp);
13905 diff -NurpP --minimal linux-3.2.5/include/net/inet_timewait_sock.h linux-3.2.5-vs2.3.2.6/include/net/inet_timewait_sock.h
13906 --- linux-3.2.5/include/net/inet_timewait_sock.h 2012-01-09 16:14:59.000000000 +0100
13907 +++ linux-3.2.5-vs2.3.2.6/include/net/inet_timewait_sock.h 2011-12-05 19:33:02.000000000 +0100
13908 @@ -112,6 +112,10 @@ struct inet_timewait_sock {
13909 #define tw_net __tw_common.skc_net
13910 #define tw_daddr __tw_common.skc_daddr
13911 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
13912 +#define tw_xid __tw_common.skc_xid
13913 +#define tw_vx_info __tw_common.skc_vx_info
13914 +#define tw_nid __tw_common.skc_nid
13915 +#define tw_nx_info __tw_common.skc_nx_info
13917 volatile unsigned char tw_substate;
13918 unsigned char tw_rcv_wscale;
13919 diff -NurpP --minimal linux-3.2.5/include/net/ip6_route.h linux-3.2.5-vs2.3.2.6/include/net/ip6_route.h
13920 --- linux-3.2.5/include/net/ip6_route.h 2011-07-22 11:18:11.000000000 +0200
13921 +++ linux-3.2.5-vs2.3.2.6/include/net/ip6_route.h 2011-12-05 19:33:02.000000000 +0100
13922 @@ -86,7 +86,8 @@ extern int ip6_route_get_saddr(struct
13923 struct rt6_info *rt,
13924 const struct in6_addr *daddr,
13925 unsigned int prefs,
13926 - struct in6_addr *saddr);
13927 + struct in6_addr *saddr,
13928 + struct nx_info *nxi);
13930 extern struct rt6_info *rt6_lookup(struct net *net,
13931 const struct in6_addr *daddr,
13932 diff -NurpP --minimal linux-3.2.5/include/net/route.h linux-3.2.5-vs2.3.2.6/include/net/route.h
13933 --- linux-3.2.5/include/net/route.h 2012-01-09 16:14:59.000000000 +0100
13934 +++ linux-3.2.5-vs2.3.2.6/include/net/route.h 2012-02-07 03:13:38.000000000 +0100
13935 @@ -202,6 +202,9 @@ static inline void ip_rt_put(struct rtab
13936 dst_release(&rt->dst);
13939 +#include <linux/vs_base.h>
13940 +#include <linux/vs_inet.h>
13942 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
13944 extern const __u8 ip_tos2prio[16];
13945 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
13946 protocol, flow_flags, dst, src, dport, sport);
13949 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
13950 + struct flowi4 *);
13952 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
13953 __be32 dst, __be32 src, u32 tos,
13954 int oif, u8 protocol,
13955 @@ -261,11 +267,25 @@ static inline struct rtable *ip_route_co
13957 struct net *net = sock_net(sk);
13959 + struct nx_info *nx_info = current_nx_info();
13961 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
13962 sport, dport, sk, can_sleep);
13964 - if (!dst || !src) {
13966 + nx_info = sk->sk_nx_info;
13968 + vxdprintk(VXD_CBIT(net, 4),
13969 + "ip_route_connect(%p) %p,%p;%lx",
13970 + sk, nx_info, sk->sk_socket,
13971 + (sk->sk_socket?sk->sk_socket->flags:0));
13973 + rt = ip_v4_find_src(net, nx_info, fl4);
13978 + if (!fl4->daddr || !fl4->saddr) {
13979 rt = __ip_route_output_key(net, fl4);
13982 diff -NurpP --minimal linux-3.2.5/include/net/sock.h linux-3.2.5-vs2.3.2.6/include/net/sock.h
13983 --- linux-3.2.5/include/net/sock.h 2012-01-09 16:14:59.000000000 +0100
13984 +++ linux-3.2.5-vs2.3.2.6/include/net/sock.h 2012-01-09 16:19:31.000000000 +0100
13985 @@ -149,6 +149,10 @@ struct sock_common {
13986 #ifdef CONFIG_NET_NS
13987 struct net *skc_net;
13990 + struct vx_info *skc_vx_info;
13992 + struct nx_info *skc_nx_info;
13994 * fields between dontcopy_begin/dontcopy_end
13995 * are not copied in sock_copy()
13996 @@ -256,6 +260,10 @@ struct sock {
13997 #define sk_bind_node __sk_common.skc_bind_node
13998 #define sk_prot __sk_common.skc_prot
13999 #define sk_net __sk_common.skc_net
14000 +#define sk_xid __sk_common.skc_xid
14001 +#define sk_vx_info __sk_common.skc_vx_info
14002 +#define sk_nid __sk_common.skc_nid
14003 +#define sk_nx_info __sk_common.skc_nx_info
14004 socket_lock_t sk_lock;
14005 struct sk_buff_head sk_receive_queue;
14007 diff -NurpP --minimal linux-3.2.5/init/Kconfig linux-3.2.5-vs2.3.2.6/init/Kconfig
14008 --- linux-3.2.5/init/Kconfig 2012-01-09 16:14:59.000000000 +0100
14009 +++ linux-3.2.5-vs2.3.2.6/init/Kconfig 2011-12-05 19:33:02.000000000 +0100
14010 @@ -574,6 +574,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14012 boolean "Control Group support"
14016 This option adds support for grouping sets of processes together, for
14017 use with process control subsystems such as Cpusets, CFS, memory
14018 @@ -802,6 +803,7 @@ config IPC_NS
14020 bool "User namespace (EXPERIMENTAL)"
14021 depends on EXPERIMENTAL
14022 + depends on VSERVER_DISABLED
14025 This allows containers, i.e. vservers, to use user namespaces
14026 diff -NurpP --minimal linux-3.2.5/init/main.c linux-3.2.5-vs2.3.2.6/init/main.c
14027 --- linux-3.2.5/init/main.c 2012-01-09 16:14:59.000000000 +0100
14028 +++ linux-3.2.5-vs2.3.2.6/init/main.c 2011-12-05 19:33:02.000000000 +0100
14030 #include <linux/shmem_fs.h>
14031 #include <linux/slab.h>
14032 #include <linux/perf_event.h>
14033 +#include <linux/vserver/percpu.h>
14035 #include <asm/io.h>
14036 #include <asm/bugs.h>
14037 diff -NurpP --minimal linux-3.2.5/ipc/mqueue.c linux-3.2.5-vs2.3.2.6/ipc/mqueue.c
14038 --- linux-3.2.5/ipc/mqueue.c 2012-01-09 16:14:59.000000000 +0100
14039 +++ linux-3.2.5-vs2.3.2.6/ipc/mqueue.c 2012-01-09 16:19:31.000000000 +0100
14041 #include <linux/pid.h>
14042 #include <linux/ipc_namespace.h>
14043 #include <linux/slab.h>
14044 +#include <linux/vs_context.h>
14045 +#include <linux/vs_limit.h>
14047 #include <net/sock.h>
14049 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14050 struct sigevent notify;
14051 struct pid* notify_owner;
14052 struct user_struct *user; /* user who created, for accounting */
14053 + struct vx_info *vxi;
14054 struct sock *notify_sock;
14055 struct sk_buff *notify_cookie;
14057 @@ -128,6 +131,7 @@ static struct inode *mqueue_get_inode(st
14058 if (S_ISREG(mode)) {
14059 struct mqueue_inode_info *info;
14060 struct task_struct *p = current;
14061 + struct vx_info *vxi = p->vx_info;
14062 unsigned long mq_bytes, mq_msg_tblsz;
14064 inode->i_fop = &mqueue_file_operations;
14065 @@ -141,6 +145,7 @@ static struct inode *mqueue_get_inode(st
14066 info->notify_owner = NULL;
14068 info->user = NULL; /* set when all is ok */
14069 + info->vxi = NULL;
14070 memset(&info->attr, 0, sizeof(info->attr));
14071 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14072 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14073 @@ -158,17 +163,20 @@ static struct inode *mqueue_get_inode(st
14075 spin_lock(&mq_lock);
14076 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14077 - u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) {
14078 + u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE) ||
14079 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14080 spin_unlock(&mq_lock);
14081 /* mqueue_evict_inode() releases info->messages */
14085 u->mq_bytes += mq_bytes;
14086 + vx_ipcmsg_add(vxi, u, mq_bytes);
14087 spin_unlock(&mq_lock);
14090 info->user = get_uid(u);
14091 + info->vxi = get_vx_info(vxi);
14092 } else if (S_ISDIR(mode)) {
14094 /* Some things misbehave if size == 0 on a directory */
14095 @@ -278,8 +286,11 @@ static void mqueue_evict_inode(struct in
14096 + info->attr.mq_msgsize);
14099 + struct vx_info *vxi = info->vxi;
14101 spin_lock(&mq_lock);
14102 user->mq_bytes -= mq_bytes;
14103 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14105 * get_ns_from_inode() ensures that the
14106 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14107 @@ -289,6 +300,7 @@ static void mqueue_evict_inode(struct in
14109 ipc_ns->mq_queues_count--;
14110 spin_unlock(&mq_lock);
14111 + put_vx_info(vxi);
14115 diff -NurpP --minimal linux-3.2.5/ipc/msg.c linux-3.2.5-vs2.3.2.6/ipc/msg.c
14116 --- linux-3.2.5/ipc/msg.c 2011-05-22 16:17:59.000000000 +0200
14117 +++ linux-3.2.5-vs2.3.2.6/ipc/msg.c 2011-12-05 19:33:02.000000000 +0100
14119 #include <linux/rwsem.h>
14120 #include <linux/nsproxy.h>
14121 #include <linux/ipc_namespace.h>
14122 +#include <linux/vs_base.h>
14124 #include <asm/current.h>
14125 #include <asm/uaccess.h>
14126 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14128 msq->q_perm.mode = msgflg & S_IRWXUGO;
14129 msq->q_perm.key = key;
14130 + msq->q_perm.xid = vx_current_xid();
14132 msq->q_perm.security = NULL;
14133 retval = security_msg_queue_alloc(msq);
14134 diff -NurpP --minimal linux-3.2.5/ipc/namespace.c linux-3.2.5-vs2.3.2.6/ipc/namespace.c
14135 --- linux-3.2.5/ipc/namespace.c 2011-07-22 11:18:12.000000000 +0200
14136 +++ linux-3.2.5-vs2.3.2.6/ipc/namespace.c 2011-12-05 19:33:02.000000000 +0100
14137 @@ -13,11 +13,12 @@
14138 #include <linux/mount.h>
14139 #include <linux/user_namespace.h>
14140 #include <linux/proc_fs.h>
14141 +#include <linux/vs_base.h>
14142 +#include <linux/vserver/global.h>
14146 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
14147 - struct ipc_namespace *old_ns)
14148 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
14150 struct ipc_namespace *ns;
14152 @@ -46,19 +47,18 @@ static struct ipc_namespace *create_ipc_
14153 ipcns_notify(IPCNS_CREATED);
14154 register_ipcns_notifier(ns);
14156 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
14157 + ns->user_ns = get_user_ns(user_ns);
14162 struct ipc_namespace *copy_ipcs(unsigned long flags,
14163 - struct task_struct *tsk)
14164 + struct ipc_namespace *old_ns,
14165 + struct user_namespace *user_ns)
14167 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
14169 if (!(flags & CLONE_NEWIPC))
14170 - return get_ipc_ns(ns);
14171 - return create_ipc_ns(tsk, ns);
14172 + return get_ipc_ns(old_ns);
14173 + return create_ipc_ns(user_ns);
14177 diff -NurpP --minimal linux-3.2.5/ipc/sem.c linux-3.2.5-vs2.3.2.6/ipc/sem.c
14178 --- linux-3.2.5/ipc/sem.c 2012-01-09 16:14:59.000000000 +0100
14179 +++ linux-3.2.5-vs2.3.2.6/ipc/sem.c 2011-12-05 19:33:02.000000000 +0100
14181 #include <linux/rwsem.h>
14182 #include <linux/nsproxy.h>
14183 #include <linux/ipc_namespace.h>
14184 +#include <linux/vs_base.h>
14185 +#include <linux/vs_limit.h>
14187 #include <asm/uaccess.h>
14189 @@ -306,6 +308,7 @@ static int newary(struct ipc_namespace *
14191 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14192 sma->sem_perm.key = key;
14193 + sma->sem_perm.xid = vx_current_xid();
14195 sma->sem_perm.security = NULL;
14196 retval = security_sem_alloc(sma);
14197 @@ -321,6 +324,9 @@ static int newary(struct ipc_namespace *
14200 ns->used_sems += nsems;
14201 + /* FIXME: obsoleted? */
14202 + vx_semary_inc(sma);
14203 + vx_nsems_add(sma, nsems);
14205 sma->sem_base = (struct sem *) &sma[1];
14207 @@ -770,6 +776,9 @@ static void freeary(struct ipc_namespace
14209 wake_up_sem_queue_do(&tasks);
14210 ns->used_sems -= sma->sem_nsems;
14211 + /* FIXME: obsoleted? */
14212 + vx_nsems_sub(sma, sma->sem_nsems);
14213 + vx_semary_dec(sma);
14214 security_sem_free(sma);
14215 ipc_rcu_putref(sma);
14217 diff -NurpP --minimal linux-3.2.5/ipc/shm.c linux-3.2.5-vs2.3.2.6/ipc/shm.c
14218 --- linux-3.2.5/ipc/shm.c 2012-02-07 01:57:55.000000000 +0100
14219 +++ linux-3.2.5-vs2.3.2.6/ipc/shm.c 2012-01-26 08:52:10.000000000 +0100
14221 #include <linux/nsproxy.h>
14222 #include <linux/mount.h>
14223 #include <linux/ipc_namespace.h>
14224 +#include <linux/vs_context.h>
14225 +#include <linux/vs_limit.h>
14227 #include <asm/uaccess.h>
14229 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
14231 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14233 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14234 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14235 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14237 + vx_ipcshm_sub(vxi, shp, numpages);
14238 + ns->shm_tot -= numpages;
14242 if (!is_file_hugepages(shp->shm_file))
14243 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
14245 fput (shp->shm_file);
14246 security_shm_free(shp);
14247 + put_vx_info(vxi);
14248 ipc_rcu_putref(shp);
14251 @@ -462,11 +470,15 @@ static int newseg(struct ipc_namespace *
14252 if (ns->shm_tot + numpages > ns->shm_ctlall)
14255 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14258 shp = ipc_rcu_alloc(sizeof(*shp));
14262 shp->shm_perm.key = key;
14263 + shp->shm_perm.xid = vx_current_xid();
14264 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14265 shp->mlock_user = NULL;
14267 @@ -521,6 +533,7 @@ static int newseg(struct ipc_namespace *
14268 ns->shm_tot += numpages;
14269 error = shp->shm_perm.id;
14271 + vx_ipcshm_add(current_vx_info(), key, numpages);
14275 diff -NurpP --minimal linux-3.2.5/kernel/Makefile linux-3.2.5-vs2.3.2.6/kernel/Makefile
14276 --- linux-3.2.5/kernel/Makefile 2012-01-09 16:14:59.000000000 +0100
14277 +++ linux-3.2.5-vs2.3.2.6/kernel/Makefile 2011-12-05 19:33:02.000000000 +0100
14278 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
14279 CFLAGS_REMOVE_irq_work.o = -pg
14283 obj-$(CONFIG_FREEZER) += freezer.o
14284 obj-$(CONFIG_PROFILING) += profile.o
14285 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
14286 diff -NurpP --minimal linux-3.2.5/kernel/capability.c linux-3.2.5-vs2.3.2.6/kernel/capability.c
14287 --- linux-3.2.5/kernel/capability.c 2012-01-09 16:14:59.000000000 +0100
14288 +++ linux-3.2.5-vs2.3.2.6/kernel/capability.c 2011-12-05 19:33:02.000000000 +0100
14290 #include <linux/syscalls.h>
14291 #include <linux/pid_namespace.h>
14292 #include <linux/user_namespace.h>
14293 +#include <linux/vs_context.h>
14294 #include <asm/uaccess.h>
14297 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
14303 * The only thing that can change the capabilities of the current
14304 * process is the current process. As such, we can't be in this code
14305 @@ -340,6 +342,8 @@ bool has_capability_noaudit(struct task_
14309 +#include <linux/vserver/base.h>
14312 * capable - Determine if the current task has a superior capability in effect
14313 * @cap: The capability to be tested for
14314 diff -NurpP --minimal linux-3.2.5/kernel/compat.c linux-3.2.5-vs2.3.2.6/kernel/compat.c
14315 --- linux-3.2.5/kernel/compat.c 2012-01-09 16:14:59.000000000 +0100
14316 +++ linux-3.2.5-vs2.3.2.6/kernel/compat.c 2011-12-05 19:33:02.000000000 +0100
14317 @@ -973,7 +973,7 @@ asmlinkage long compat_sys_stime(compat_
14321 - do_settimeofday(&tv);
14322 + vx_settimeofday(&tv);
14326 diff -NurpP --minimal linux-3.2.5/kernel/cred.c linux-3.2.5-vs2.3.2.6/kernel/cred.c
14327 --- linux-3.2.5/kernel/cred.c 2012-01-09 16:15:00.000000000 +0100
14328 +++ linux-3.2.5-vs2.3.2.6/kernel/cred.c 2011-12-05 19:33:02.000000000 +0100
14329 @@ -61,31 +61,6 @@ struct cred init_cred = {
14333 -static inline void set_cred_subscribers(struct cred *cred, int n)
14335 -#ifdef CONFIG_DEBUG_CREDENTIALS
14336 - atomic_set(&cred->subscribers, n);
14340 -static inline int read_cred_subscribers(const struct cred *cred)
14342 -#ifdef CONFIG_DEBUG_CREDENTIALS
14343 - return atomic_read(&cred->subscribers);
14349 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14351 -#ifdef CONFIG_DEBUG_CREDENTIALS
14352 - struct cred *cred = (struct cred *) _cred;
14354 - atomic_add(n, &cred->subscribers);
14359 * Dispose of the shared task group credentials
14361 @@ -281,21 +256,16 @@ error:
14363 * Call commit_creds() or abort_creds() to clean up.
14365 -struct cred *prepare_creds(void)
14366 +struct cred *__prepare_creds(const struct cred *old)
14368 - struct task_struct *task = current;
14369 - const struct cred *old;
14372 - validate_process_creds();
14374 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14378 kdebug("prepare_creds() alloc %p", new);
14380 - old = task->cred;
14381 memcpy(new, old, sizeof(struct cred));
14383 atomic_set(&new->usage, 1);
14384 @@ -322,6 +292,13 @@ error:
14389 +struct cred *prepare_creds(void)
14391 + validate_process_creds();
14393 + return __prepare_creds(current->cred);
14395 EXPORT_SYMBOL(prepare_creds);
14398 diff -NurpP --minimal linux-3.2.5/kernel/exit.c linux-3.2.5-vs2.3.2.6/kernel/exit.c
14399 --- linux-3.2.5/kernel/exit.c 2012-01-09 16:15:00.000000000 +0100
14400 +++ linux-3.2.5-vs2.3.2.6/kernel/exit.c 2012-01-09 16:19:31.000000000 +0100
14402 #include <linux/fs_struct.h>
14403 #include <linux/init_task.h>
14404 #include <linux/perf_event.h>
14405 +#include <linux/vs_limit.h>
14406 +#include <linux/vs_context.h>
14407 +#include <linux/vs_network.h>
14408 +#include <linux/vs_pid.h>
14409 #include <trace/events/sched.h>
14410 #include <linux/hw_breakpoint.h>
14411 #include <linux/oom.h>
14412 @@ -480,9 +484,11 @@ static void close_files(struct files_str
14413 filp_close(file, files);
14416 + vx_openfd_dec(i);
14424 @@ -1036,11 +1042,16 @@ NORET_TYPE void do_exit(long code)
14426 validate_creds_for_do_exit(tsk);
14428 + /* needs to stay after exit_notify() */
14429 + exit_vx_info(tsk, code);
14430 + exit_nx_info(tsk);
14434 /* causes final put_task_struct in finish_task_switch(). */
14435 tsk->state = TASK_DEAD;
14437 + printk("bad task: %p [%lx]\n", current, current->state);
14439 /* Avoid "noreturn function does return". */
14441 diff -NurpP --minimal linux-3.2.5/kernel/fork.c linux-3.2.5-vs2.3.2.6/kernel/fork.c
14442 --- linux-3.2.5/kernel/fork.c 2012-01-09 16:15:00.000000000 +0100
14443 +++ linux-3.2.5-vs2.3.2.6/kernel/fork.c 2011-12-15 01:52:28.000000000 +0100
14445 #include <linux/user-return-notifier.h>
14446 #include <linux/oom.h>
14447 #include <linux/khugepaged.h>
14448 +#include <linux/vs_context.h>
14449 +#include <linux/vs_network.h>
14450 +#include <linux/vs_limit.h>
14452 #include <asm/pgtable.h>
14453 #include <asm/pgalloc.h>
14454 @@ -165,6 +168,8 @@ void free_task(struct task_struct *tsk)
14455 account_kernel_stack(tsk->stack, -1);
14456 free_thread_info(tsk->stack);
14457 rt_mutex_debug_task_free(tsk);
14458 + clr_vx_info(&tsk->vx_info);
14459 + clr_nx_info(&tsk->nx_info);
14460 ftrace_graph_exit_task(tsk);
14461 free_task_struct(tsk);
14463 @@ -500,6 +505,7 @@ static struct mm_struct *mm_init(struct
14464 if (likely(!mm_alloc_pgd(mm))) {
14466 mmu_notifier_mm_init(mm);
14467 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14471 @@ -537,6 +543,7 @@ void __mmdrop(struct mm_struct *mm)
14472 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14473 VM_BUG_ON(mm->pmd_huge_pte);
14475 + clr_vx_info(&mm->mm_vx_info);
14478 EXPORT_SYMBOL_GPL(__mmdrop);
14479 @@ -724,6 +731,7 @@ struct mm_struct *dup_mm(struct task_str
14482 memcpy(mm, oldmm, sizeof(*mm));
14483 + mm->mm_vx_info = NULL;
14484 mm_init_cpumask(mm);
14486 /* Initializing for Swap token stuff */
14487 @@ -767,6 +775,7 @@ fail_nocontext:
14488 * If init_new_context() failed, we cannot use mmput() to free the mm
14489 * because it calls destroy_context()
14491 + clr_vx_info(&mm->mm_vx_info);
14495 @@ -1050,6 +1059,8 @@ static struct task_struct *copy_process(
14497 struct task_struct *p;
14498 int cgroup_callbacks_done = 0;
14499 + struct vx_info *vxi;
14500 + struct nx_info *nxi;
14502 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14503 return ERR_PTR(-EINVAL);
14504 @@ -1096,7 +1107,12 @@ static struct task_struct *copy_process(
14505 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14506 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14508 + init_vx_info(&p->vx_info, current_vx_info());
14509 + init_nx_info(&p->nx_info, current_nx_info());
14512 + if (!vx_nproc_avail(1))
14513 + goto bad_fork_free;
14514 if (atomic_read(&p->real_cred->user->processes) >=
14515 task_rlimit(p, RLIMIT_NPROC)) {
14516 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14517 @@ -1369,6 +1385,18 @@ static struct task_struct *copy_process(
14520 spin_unlock(¤t->sighand->siglock);
14522 + /* p is copy of current */
14523 + vxi = p->vx_info;
14525 + claim_vx_info(vxi, p);
14526 + atomic_inc(&vxi->cvirt.nr_threads);
14527 + atomic_inc(&vxi->cvirt.total_forks);
14530 + nxi = p->nx_info;
14532 + claim_nx_info(nxi, p);
14533 write_unlock_irq(&tasklist_lock);
14534 proc_fork_connector(p);
14535 cgroup_post_fork(p);
14536 diff -NurpP --minimal linux-3.2.5/kernel/kthread.c linux-3.2.5-vs2.3.2.6/kernel/kthread.c
14537 --- linux-3.2.5/kernel/kthread.c 2012-01-09 16:15:00.000000000 +0100
14538 +++ linux-3.2.5-vs2.3.2.6/kernel/kthread.c 2011-12-05 19:33:02.000000000 +0100
14540 #include <linux/mutex.h>
14541 #include <linux/slab.h>
14542 #include <linux/freezer.h>
14543 +#include <linux/vs_pid.h>
14544 #include <trace/events/sched.h>
14546 static DEFINE_SPINLOCK(kthread_create_lock);
14547 diff -NurpP --minimal linux-3.2.5/kernel/nsproxy.c linux-3.2.5-vs2.3.2.6/kernel/nsproxy.c
14548 --- linux-3.2.5/kernel/nsproxy.c 2012-01-09 16:15:00.000000000 +0100
14549 +++ linux-3.2.5-vs2.3.2.6/kernel/nsproxy.c 2011-12-05 19:33:02.000000000 +0100
14551 #include <linux/mnt_namespace.h>
14552 #include <linux/utsname.h>
14553 #include <linux/pid_namespace.h>
14554 +#include <linux/vserver/global.h>
14555 +#include <linux/vserver/debug.h>
14556 #include <net/net_namespace.h>
14557 #include <linux/ipc_namespace.h>
14558 #include <linux/proc_fs.h>
14559 @@ -46,8 +48,11 @@ static inline struct nsproxy *create_nsp
14560 struct nsproxy *nsproxy;
14562 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14565 atomic_set(&nsproxy->count, 1);
14566 + atomic_inc(&vs_global_nsproxy);
14568 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14572 @@ -56,8 +61,11 @@ static inline struct nsproxy *create_nsp
14573 * Return the newly created nsproxy. Do not attach this to the task,
14574 * leave it to the caller to do proper locking and attach it to task.
14576 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14577 - struct task_struct *tsk, struct fs_struct *new_fs)
14578 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14579 + struct nsproxy *orig,
14580 + struct fs_struct *new_fs,
14581 + struct user_namespace *new_user,
14582 + struct pid_namespace *new_pid)
14584 struct nsproxy *new_nsp;
14586 @@ -66,31 +74,31 @@ static struct nsproxy *create_new_namesp
14588 return ERR_PTR(-ENOMEM);
14590 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
14591 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
14592 if (IS_ERR(new_nsp->mnt_ns)) {
14593 err = PTR_ERR(new_nsp->mnt_ns);
14597 - new_nsp->uts_ns = copy_utsname(flags, tsk);
14598 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
14599 if (IS_ERR(new_nsp->uts_ns)) {
14600 err = PTR_ERR(new_nsp->uts_ns);
14604 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
14605 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
14606 if (IS_ERR(new_nsp->ipc_ns)) {
14607 err = PTR_ERR(new_nsp->ipc_ns);
14611 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
14612 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
14613 if (IS_ERR(new_nsp->pid_ns)) {
14614 err = PTR_ERR(new_nsp->pid_ns);
14618 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
14619 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
14620 if (IS_ERR(new_nsp->net_ns)) {
14621 err = PTR_ERR(new_nsp->net_ns);
14623 @@ -115,6 +123,40 @@ out_ns:
14624 return ERR_PTR(err);
14627 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14628 + struct task_struct *tsk, struct fs_struct *new_fs)
14630 + return unshare_namespaces(flags, tsk->nsproxy,
14631 + new_fs, task_cred_xxx(tsk, user)->user_ns,
14632 + task_active_pid_ns(tsk));
14636 + * copies the nsproxy, setting refcount to 1, and grabbing a
14637 + * reference to all contained namespaces.
14639 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14641 + struct nsproxy *ns = create_nsproxy();
14644 + memcpy(ns, orig, sizeof(struct nsproxy));
14645 + atomic_set(&ns->count, 1);
14648 + get_mnt_ns(ns->mnt_ns);
14650 + get_uts_ns(ns->uts_ns);
14652 + get_ipc_ns(ns->ipc_ns);
14654 + get_pid_ns(ns->pid_ns);
14656 + get_net(ns->net_ns);
14662 * called from clone. This now handles copy for nsproxy and all
14663 * namespaces therein.
14664 @@ -122,9 +164,12 @@ out_ns:
14665 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
14667 struct nsproxy *old_ns = tsk->nsproxy;
14668 - struct nsproxy *new_ns;
14669 + struct nsproxy *new_ns = NULL;
14672 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14673 + flags, tsk, old_ns);
14678 @@ -134,7 +179,7 @@ int copy_namespaces(unsigned long flags,
14679 CLONE_NEWPID | CLONE_NEWNET)))
14682 - if (!capable(CAP_SYS_ADMIN)) {
14683 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
14687 @@ -161,6 +206,9 @@ int copy_namespaces(unsigned long flags,
14690 put_nsproxy(old_ns);
14691 + vxdprintk(VXD_CBIT(space, 3),
14692 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14693 + flags, tsk, old_ns, err, new_ns);
14697 @@ -174,7 +222,9 @@ void free_nsproxy(struct nsproxy *ns)
14698 put_ipc_ns(ns->ipc_ns);
14700 put_pid_ns(ns->pid_ns);
14701 - put_net(ns->net_ns);
14703 + put_net(ns->net_ns);
14704 + atomic_dec(&vs_global_nsproxy);
14705 kmem_cache_free(nsproxy_cachep, ns);
14708 @@ -187,11 +237,15 @@ int unshare_nsproxy_namespaces(unsigned
14712 + vxdprintk(VXD_CBIT(space, 4),
14713 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14714 + unshare_flags, current->nsproxy);
14716 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14720 - if (!capable(CAP_SYS_ADMIN))
14721 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
14724 *new_nsp = create_new_namespaces(unshare_flags, current,
14725 diff -NurpP --minimal linux-3.2.5/kernel/pid.c linux-3.2.5-vs2.3.2.6/kernel/pid.c
14726 --- linux-3.2.5/kernel/pid.c 2012-01-09 16:15:00.000000000 +0100
14727 +++ linux-3.2.5-vs2.3.2.6/kernel/pid.c 2011-12-05 19:43:14.000000000 +0100
14729 #include <linux/pid_namespace.h>
14730 #include <linux/init_task.h>
14731 #include <linux/syscalls.h>
14732 +#include <linux/vs_pid.h>
14734 #define pid_hashfn(nr, ns) \
14735 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14736 @@ -342,7 +343,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14738 struct pid *find_vpid(int nr)
14740 - return find_pid_ns(nr, current->nsproxy->pid_ns);
14741 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
14743 EXPORT_SYMBOL_GPL(find_vpid);
14745 @@ -402,6 +403,9 @@ void transfer_pid(struct task_struct *ol
14746 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14748 struct task_struct *result = NULL;
14750 + if (type == PIDTYPE_REALPID)
14751 + type = PIDTYPE_PID;
14753 struct hlist_node *first;
14754 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
14755 @@ -421,7 +425,7 @@ struct task_struct *find_task_by_pid_ns(
14756 rcu_lockdep_assert(rcu_read_lock_held(),
14757 "find_task_by_pid_ns() needs rcu_read_lock()"
14759 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
14760 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
14763 struct task_struct *find_task_by_vpid(pid_t vnr)
14764 @@ -465,7 +469,7 @@ struct pid *find_get_pid(pid_t nr)
14766 EXPORT_SYMBOL_GPL(find_get_pid);
14768 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14769 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
14773 @@ -478,6 +482,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
14777 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14779 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
14782 pid_t pid_vnr(struct pid *pid)
14784 return pid_nr_ns(pid, current->nsproxy->pid_ns);
14785 diff -NurpP --minimal linux-3.2.5/kernel/pid_namespace.c linux-3.2.5-vs2.3.2.6/kernel/pid_namespace.c
14786 --- linux-3.2.5/kernel/pid_namespace.c 2011-05-22 16:17:59.000000000 +0200
14787 +++ linux-3.2.5-vs2.3.2.6/kernel/pid_namespace.c 2011-12-05 19:33:02.000000000 +0100
14789 #include <linux/acct.h>
14790 #include <linux/slab.h>
14791 #include <linux/proc_fs.h>
14792 +#include <linux/vserver/global.h>
14794 #define BITS_PER_PAGE (PAGE_SIZE*8)
14796 @@ -88,6 +89,7 @@ static struct pid_namespace *create_pid_
14799 kref_init(&ns->kref);
14800 + atomic_inc(&vs_global_pid_ns);
14802 ns->parent = get_pid_ns(parent_pid_ns);
14804 @@ -119,6 +121,7 @@ static void destroy_pid_namespace(struct
14806 for (i = 0; i < PIDMAP_ENTRIES; i++)
14807 kfree(ns->pidmap[i].page);
14808 + atomic_dec(&vs_global_pid_ns);
14809 kmem_cache_free(pid_ns_cachep, ns);
14812 diff -NurpP --minimal linux-3.2.5/kernel/posix-timers.c linux-3.2.5-vs2.3.2.6/kernel/posix-timers.c
14813 --- linux-3.2.5/kernel/posix-timers.c 2012-01-09 16:15:00.000000000 +0100
14814 +++ linux-3.2.5-vs2.3.2.6/kernel/posix-timers.c 2011-12-05 19:44:00.000000000 +0100
14816 #include <linux/wait.h>
14817 #include <linux/workqueue.h>
14818 #include <linux/export.h>
14819 +#include <linux/vs_context.h>
14822 * Management arrays for POSIX timers. Timers are kept in slab memory
14823 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
14825 struct task_struct *task;
14826 int shared, ret = -1;
14829 * FIXME: if ->sigq is queued we can race with
14830 * dequeue_signal()->do_schedule_next_timer().
14831 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
14833 task = pid_task(timr->it_pid, PIDTYPE_PID);
14835 + struct vx_info_save vxis;
14836 + struct vx_info *vxi;
14838 + vxi = get_vx_info(task->vx_info);
14839 + enter_vx_info(vxi, &vxis);
14840 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
14841 ret = send_sigqueue(timr->sigq, task, shared);
14842 + leave_vx_info(&vxis);
14843 + put_vx_info(vxi);
14847 /* If we failed to send the signal the timer stops. */
14850 diff -NurpP --minimal linux-3.2.5/kernel/printk.c linux-3.2.5-vs2.3.2.6/kernel/printk.c
14851 --- linux-3.2.5/kernel/printk.c 2012-01-09 16:15:00.000000000 +0100
14852 +++ linux-3.2.5-vs2.3.2.6/kernel/printk.c 2011-12-15 01:11:33.000000000 +0100
14854 #include <linux/cpu.h>
14855 #include <linux/notifier.h>
14856 #include <linux/rculist.h>
14857 +#include <linux/vs_cvirt.h>
14859 #include <asm/uaccess.h>
14861 @@ -314,7 +315,7 @@ static int check_syslog_permissions(int
14864 if (syslog_action_restricted(type)) {
14865 - if (capable(CAP_SYSLOG))
14866 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
14868 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
14869 if (capable(CAP_SYS_ADMIN)) {
14870 @@ -344,12 +345,9 @@ int do_syslog(int type, char __user *buf
14875 - case SYSLOG_ACTION_CLOSE: /* Close log */
14877 - case SYSLOG_ACTION_OPEN: /* Open log */
14879 - case SYSLOG_ACTION_READ: /* Read from log */
14880 + if ((type == SYSLOG_ACTION_READ) ||
14881 + (type == SYSLOG_ACTION_READ_ALL) ||
14882 + (type == SYSLOG_ACTION_READ_CLEAR)) {
14884 if (!buf || len < 0)
14886 @@ -360,6 +358,16 @@ int do_syslog(int type, char __user *buf
14891 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14892 + return vx_do_syslog(type, buf, len);
14895 + case SYSLOG_ACTION_CLOSE: /* Close log */
14897 + case SYSLOG_ACTION_OPEN: /* Open log */
14899 + case SYSLOG_ACTION_READ: /* Read from log */
14900 error = wait_event_interruptible(log_wait,
14901 (log_start - log_end));
14903 @@ -386,16 +394,6 @@ int do_syslog(int type, char __user *buf
14905 /* Read last kernel messages */
14906 case SYSLOG_ACTION_READ_ALL:
14908 - if (!buf || len < 0)
14913 - if (!access_ok(VERIFY_WRITE, buf, len)) {
14918 if (count > log_buf_len)
14919 count = log_buf_len;
14920 diff -NurpP --minimal linux-3.2.5/kernel/ptrace.c linux-3.2.5-vs2.3.2.6/kernel/ptrace.c
14921 --- linux-3.2.5/kernel/ptrace.c 2012-01-09 16:15:00.000000000 +0100
14922 +++ linux-3.2.5-vs2.3.2.6/kernel/ptrace.c 2012-01-09 16:19:31.000000000 +0100
14924 #include <linux/syscalls.h>
14925 #include <linux/uaccess.h>
14926 #include <linux/regset.h>
14927 +#include <linux/vs_context.h>
14928 #include <linux/hw_breakpoint.h>
14929 #include <linux/cn_proc.h>
14931 @@ -209,6 +210,11 @@ ok:
14932 dumpable = get_dumpable(task->mm);
14933 if (!dumpable && !task_ns_capable(task, CAP_SYS_PTRACE))
14935 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
14937 + if (!vx_check(task->xid, VS_IDENT) &&
14938 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
14941 return security_ptrace_access_check(task, mode);
14943 diff -NurpP --minimal linux-3.2.5/kernel/sched.c linux-3.2.5-vs2.3.2.6/kernel/sched.c
14944 --- linux-3.2.5/kernel/sched.c 2012-01-09 16:15:00.000000000 +0100
14945 +++ linux-3.2.5-vs2.3.2.6/kernel/sched.c 2011-12-15 01:14:00.000000000 +0100
14947 #include <linux/ftrace.h>
14948 #include <linux/slab.h>
14949 #include <linux/init_task.h>
14950 +#include <linux/vs_sched.h>
14951 +#include <linux/vs_cvirt.h>
14953 #include <asm/tlb.h>
14954 #include <asm/irq_regs.h>
14955 @@ -3607,9 +3609,17 @@ static void calc_global_nohz(unsigned lo
14957 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
14959 - loads[0] = (avenrun[0] + offset) << shift;
14960 - loads[1] = (avenrun[1] + offset) << shift;
14961 - loads[2] = (avenrun[2] + offset) << shift;
14962 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
14963 + struct vx_info *vxi = current_vx_info();
14965 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
14966 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
14967 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
14969 + loads[0] = (avenrun[0] + offset) << shift;
14970 + loads[1] = (avenrun[1] + offset) << shift;
14971 + loads[2] = (avenrun[2] + offset) << shift;
14976 @@ -3868,16 +3878,19 @@ void account_user_time(struct task_struc
14977 cputime_t cputime_scaled)
14979 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
14980 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14982 + int nice = (TASK_NICE(p) > 0);
14984 /* Add user time to process. */
14985 p->utime = cputime_add(p->utime, cputime);
14986 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
14987 + vx_account_user(vxi, cputime, nice);
14988 account_group_user_time(p, cputime);
14990 /* Add user time to cpustat. */
14991 tmp = cputime_to_cputime64(cputime);
14992 - if (TASK_NICE(p) > 0)
14994 cpustat->nice = cputime64_add(cpustat->nice, tmp);
14996 cpustat->user = cputime64_add(cpustat->user, tmp);
14997 @@ -3929,10 +3942,12 @@ void __account_system_time(struct task_s
14998 cputime_t cputime_scaled, cputime64_t *target_cputime64)
15000 cputime64_t tmp = cputime_to_cputime64(cputime);
15001 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15003 /* Add system time to process. */
15004 p->stime = cputime_add(p->stime, cputime);
15005 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15006 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15007 account_group_system_time(p, cputime);
15009 /* Add system time to cpustat. */
15010 @@ -5132,7 +5147,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15013 if (increment < 0 && !can_nice(current, nice))
15015 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15017 retval = security_task_setnice(current, nice);
15019 diff -NurpP --minimal linux-3.2.5/kernel/sched_fair.c linux-3.2.5-vs2.3.2.6/kernel/sched_fair.c
15020 --- linux-3.2.5/kernel/sched_fair.c 2012-01-09 16:15:00.000000000 +0100
15021 +++ linux-3.2.5-vs2.3.2.6/kernel/sched_fair.c 2012-01-09 16:19:31.000000000 +0100
15022 @@ -1014,6 +1014,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15023 __enqueue_entity(cfs_rq, se);
15026 + if (entity_is_task(se))
15027 + vx_activate_task(task_of(se));
15028 if (cfs_rq->nr_running == 1) {
15029 list_add_leaf_cfs_rq(cfs_rq);
15030 check_enqueue_throttle(cfs_rq);
15031 @@ -1094,6 +1096,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15032 if (se != cfs_rq->curr)
15033 __dequeue_entity(cfs_rq, se);
15035 + if (entity_is_task(se))
15036 + vx_deactivate_task(task_of(se));
15037 update_cfs_load(cfs_rq, 0);
15038 account_entity_dequeue(cfs_rq, se);
15040 diff -NurpP --minimal linux-3.2.5/kernel/signal.c linux-3.2.5-vs2.3.2.6/kernel/signal.c
15041 --- linux-3.2.5/kernel/signal.c 2012-01-09 16:15:00.000000000 +0100
15042 +++ linux-3.2.5-vs2.3.2.6/kernel/signal.c 2012-01-09 16:19:31.000000000 +0100
15044 #include <linux/freezer.h>
15045 #include <linux/pid_namespace.h>
15046 #include <linux/nsproxy.h>
15047 +#include <linux/vs_context.h>
15048 +#include <linux/vs_pid.h>
15049 #define CREATE_TRACE_POINTS
15050 #include <trace/events/signal.h>
15052 @@ -789,9 +791,18 @@ static int check_kill_permission(int sig
15056 + vxdprintk(VXD_CBIT(misc, 7),
15057 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15058 + sig, info, t, vx_task_xid(t), t->pid);
15060 if (!valid_signal(sig))
15063 +/* FIXME: needed? if so, why?
15064 + if ((info != SEND_SIG_NOINFO) &&
15065 + (is_si_special(info) || !si_fromuser(info)))
15068 if (!si_fromuser(info))
15071 @@ -815,6 +826,20 @@ static int check_kill_permission(int sig
15076 + if (t->pid == 1 && current->xid)
15080 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15081 + loops, maybe ENOENT or EACCES? */
15082 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15083 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15084 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15085 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15089 return security_task_kill(t, info, sig, 0);
15092 @@ -1319,7 +1344,7 @@ int kill_pid_info(int sig, struct siginf
15095 p = pid_task(pid, PIDTYPE_PID);
15097 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15098 error = group_send_sig_info(sig, info, p);
15099 if (unlikely(error == -ESRCH))
15101 @@ -1369,7 +1394,7 @@ int kill_pid_info_as_cred(int sig, struc
15104 p = pid_task(pid, PIDTYPE_PID);
15106 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15110 @@ -1421,8 +1446,10 @@ static int kill_something_info(int sig,
15111 struct task_struct * p;
15113 for_each_process(p) {
15114 - if (task_pid_vnr(p) > 1 &&
15115 - !same_thread_group(p, current)) {
15116 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15117 + task_pid_vnr(p) > 1 &&
15118 + !same_thread_group(p, current) &&
15119 + !vx_current_initpid(p->pid)) {
15120 int err = group_send_sig_info(sig, info, p);
15123 @@ -2255,6 +2282,11 @@ relock:
15124 !sig_kernel_only(signr))
15127 + /* virtual init is protected against user signals */
15128 + if ((info->si_code == SI_USER) &&
15129 + vx_current_initpid(current->pid))
15132 if (sig_kernel_stop(signr)) {
15134 * The default action is to stop all threads in
15135 diff -NurpP --minimal linux-3.2.5/kernel/softirq.c linux-3.2.5-vs2.3.2.6/kernel/softirq.c
15136 --- linux-3.2.5/kernel/softirq.c 2012-01-09 16:15:00.000000000 +0100
15137 +++ linux-3.2.5-vs2.3.2.6/kernel/softirq.c 2011-12-05 19:33:02.000000000 +0100
15139 #include <linux/ftrace.h>
15140 #include <linux/smp.h>
15141 #include <linux/tick.h>
15142 +#include <linux/vs_context.h>
15144 #define CREATE_TRACE_POINTS
15145 #include <trace/events/irq.h>
15146 diff -NurpP --minimal linux-3.2.5/kernel/sys.c linux-3.2.5-vs2.3.2.6/kernel/sys.c
15147 --- linux-3.2.5/kernel/sys.c 2012-01-09 16:15:00.000000000 +0100
15148 +++ linux-3.2.5-vs2.3.2.6/kernel/sys.c 2011-12-05 19:33:02.000000000 +0100
15150 #include <linux/syscalls.h>
15151 #include <linux/kprobes.h>
15152 #include <linux/user_namespace.h>
15153 +#include <linux/vs_pid.h>
15155 #include <linux/kmsg_dump.h>
15156 /* Move somewhere else to avoid recompiling? */
15157 @@ -155,7 +156,10 @@ static int set_one_prio(struct task_stru
15160 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15162 + if (vx_flags(VXF_IGNEG_NICE, 0))
15168 no_nice = security_task_setnice(p, niceval);
15169 @@ -205,6 +209,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15171 pgrp = task_pgrp(current);
15172 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15173 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15175 error = set_one_prio(p, niceval, error);
15176 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15178 @@ -268,6 +274,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15180 pgrp = task_pgrp(current);
15181 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15182 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15184 niceval = 20 - task_nice(p);
15185 if (niceval > retval)
15187 @@ -418,6 +426,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15189 static DEFINE_MUTEX(reboot_mutex);
15191 +long vs_reboot(unsigned int, void __user *);
15194 * Reboot system call: for obvious reasons only root may call it,
15195 * and even root needs to set up some magic numbers in the registers
15196 @@ -450,6 +460,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15197 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15198 cmd = LINUX_REBOOT_CMD_HALT;
15200 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15201 + return vs_reboot(cmd, arg);
15203 mutex_lock(&reboot_mutex);
15205 case LINUX_REBOOT_CMD_RESTART:
15206 @@ -1273,7 +1286,8 @@ SYSCALL_DEFINE2(sethostname, char __user
15208 char tmp[__NEW_UTS_LEN];
15210 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15211 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15212 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15215 if (len < 0 || len > __NEW_UTS_LEN)
15216 @@ -1324,7 +1338,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
15218 char tmp[__NEW_UTS_LEN];
15220 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15221 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15222 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15224 if (len < 0 || len > __NEW_UTS_LEN)
15226 @@ -1443,7 +1458,7 @@ int do_prlimit(struct task_struct *tsk,
15227 /* Keep the capable check against init_user_ns until
15228 cgroups can contain all limits */
15229 if (new_rlim->rlim_max > rlim->rlim_max &&
15230 - !capable(CAP_SYS_RESOURCE))
15231 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15234 retval = security_task_setrlimit(tsk->group_leader,
15235 @@ -1497,7 +1512,8 @@ static int check_prlimit_permission(stru
15236 cred->gid == tcred->sgid &&
15237 cred->gid == tcred->gid))
15239 - if (ns_capable(tcred->user->user_ns, CAP_SYS_RESOURCE))
15240 + if (vx_ns_capable(tcred->user->user_ns,
15241 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15245 diff -NurpP --minimal linux-3.2.5/kernel/sysctl.c linux-3.2.5-vs2.3.2.6/kernel/sysctl.c
15246 --- linux-3.2.5/kernel/sysctl.c 2012-01-09 16:15:00.000000000 +0100
15247 +++ linux-3.2.5-vs2.3.2.6/kernel/sysctl.c 2011-12-05 19:33:02.000000000 +0100
15249 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15250 #include <linux/lockdep.h>
15252 +extern char vshelper_path[];
15253 #ifdef CONFIG_CHR_DEV_SG
15254 #include <scsi/sg.h>
15256 @@ -572,6 +573,13 @@ static struct ctl_table kern_table[] = {
15257 .proc_handler = proc_dostring,
15261 + .procname = "vshelper",
15262 + .data = &vshelper_path,
15265 + .proc_handler = &proc_dostring,
15267 #ifdef CONFIG_CHR_DEV_SG
15269 .procname = "sg-big-buff",
15270 diff -NurpP --minimal linux-3.2.5/kernel/sysctl_binary.c linux-3.2.5-vs2.3.2.6/kernel/sysctl_binary.c
15271 --- linux-3.2.5/kernel/sysctl_binary.c 2012-01-09 16:15:00.000000000 +0100
15272 +++ linux-3.2.5-vs2.3.2.6/kernel/sysctl_binary.c 2012-01-09 16:19:31.000000000 +0100
15273 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15275 { CTL_INT, KERN_PANIC, "panic" },
15276 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15277 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15279 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15280 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15281 diff -NurpP --minimal linux-3.2.5/kernel/time/timekeeping.c linux-3.2.5-vs2.3.2.6/kernel/time/timekeeping.c
15282 --- linux-3.2.5/kernel/time/timekeeping.c 2012-01-09 16:15:00.000000000 +0100
15283 +++ linux-3.2.5-vs2.3.2.6/kernel/time/timekeeping.c 2011-12-05 19:33:02.000000000 +0100
15284 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
15285 } while (read_seqretry(&xtime_lock, seq));
15287 timespec_add_ns(ts, nsecs);
15288 + vx_adjust_timespec(ts);
15291 EXPORT_SYMBOL(getnstimeofday);
15292 diff -NurpP --minimal linux-3.2.5/kernel/time.c linux-3.2.5-vs2.3.2.6/kernel/time.c
15293 --- linux-3.2.5/kernel/time.c 2012-01-09 16:15:00.000000000 +0100
15294 +++ linux-3.2.5-vs2.3.2.6/kernel/time.c 2011-12-05 19:33:02.000000000 +0100
15295 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15299 - do_settimeofday(&tv);
15300 + vx_settimeofday(&tv);
15304 @@ -177,7 +177,7 @@ int do_sys_settimeofday(const struct tim
15305 /* SMP safe, again the code in arch/foo/time.c should
15306 * globally block out interrupts when it runs.
15308 - return do_settimeofday(tv);
15309 + return vx_settimeofday(tv);
15313 diff -NurpP --minimal linux-3.2.5/kernel/timer.c linux-3.2.5-vs2.3.2.6/kernel/timer.c
15314 --- linux-3.2.5/kernel/timer.c 2012-01-09 16:15:00.000000000 +0100
15315 +++ linux-3.2.5-vs2.3.2.6/kernel/timer.c 2011-12-15 01:11:33.000000000 +0100
15317 #include <linux/irq_work.h>
15318 #include <linux/sched.h>
15319 #include <linux/slab.h>
15320 +#include <linux/vs_base.h>
15321 +#include <linux/vs_cvirt.h>
15322 +#include <linux/vs_pid.h>
15323 +#include <linux/vserver/sched.h>
15325 #include <asm/uaccess.h>
15326 #include <asm/unistd.h>
15327 @@ -1336,12 +1340,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15334 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15335 - * should be moved into arch/i386 instead?
15339 * sys_getpid - return the thread group id of the current process
15340 @@ -1370,10 +1368,23 @@ SYSCALL_DEFINE0(getppid)
15342 pid = task_tgid_vnr(rcu_dereference(current->real_parent));
15344 + return vx_map_pid(pid);
15351 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15354 +asmlinkage long do_getxpid(long *ppid)
15356 + *ppid = sys_getppid();
15357 + return sys_getpid();
15360 +#else /* _alpha_ */
15362 SYSCALL_DEFINE0(getuid)
15364 /* Only we change this so SMP safe */
15365 diff -NurpP --minimal linux-3.2.5/kernel/user_namespace.c linux-3.2.5-vs2.3.2.6/kernel/user_namespace.c
15366 --- linux-3.2.5/kernel/user_namespace.c 2012-01-09 16:15:00.000000000 +0100
15367 +++ linux-3.2.5-vs2.3.2.6/kernel/user_namespace.c 2011-12-05 19:33:02.000000000 +0100
15369 #include <linux/user_namespace.h>
15370 #include <linux/highuid.h>
15371 #include <linux/cred.h>
15372 +#include <linux/vserver/global.h>
15374 static struct kmem_cache *user_ns_cachep __read_mostly;
15376 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
15379 kref_init(&ns->kref);
15380 + atomic_inc(&vs_global_user_ns);
15382 for (n = 0; n < UIDHASH_SZ; ++n)
15383 INIT_HLIST_HEAD(ns->uidhash_table + n);
15384 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
15385 struct user_namespace *ns =
15386 container_of(kref, struct user_namespace, kref);
15388 + /* FIXME: maybe move into destroyer? */
15389 + atomic_dec(&vs_global_user_ns);
15390 INIT_WORK(&ns->destroyer, free_user_ns_work);
15391 schedule_work(&ns->destroyer);
15393 diff -NurpP --minimal linux-3.2.5/kernel/utsname.c linux-3.2.5-vs2.3.2.6/kernel/utsname.c
15394 --- linux-3.2.5/kernel/utsname.c 2012-01-09 16:15:00.000000000 +0100
15395 +++ linux-3.2.5-vs2.3.2.6/kernel/utsname.c 2011-12-05 19:33:02.000000000 +0100
15396 @@ -16,14 +16,17 @@
15397 #include <linux/slab.h>
15398 #include <linux/user_namespace.h>
15399 #include <linux/proc_fs.h>
15400 +#include <linux/vserver/global.h>
15402 static struct uts_namespace *create_uts_ns(void)
15404 struct uts_namespace *uts_ns;
15406 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15409 kref_init(&uts_ns->kref);
15410 + atomic_inc(&vs_global_uts_ns);
15415 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
15416 * @old_ns: namespace to clone
15417 * Return NULL on error (failure to kmalloc), new ns otherwise
15419 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
15420 - struct uts_namespace *old_ns)
15421 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
15422 + struct user_namespace *old_user)
15424 struct uts_namespace *ns;
15426 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
15428 down_read(&uts_sem);
15429 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
15430 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
15431 + ns->user_ns = get_user_ns(old_user);
15435 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
15438 struct uts_namespace *copy_utsname(unsigned long flags,
15439 - struct task_struct *tsk)
15440 + struct uts_namespace *old_ns,
15441 + struct user_namespace *user_ns)
15443 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
15444 struct uts_namespace *new_ns;
15447 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
15448 if (!(flags & CLONE_NEWUTS))
15451 - new_ns = clone_uts_ns(tsk, old_ns);
15452 + new_ns = clone_uts_ns(old_ns, user_ns);
15454 put_uts_ns(old_ns);
15456 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
15458 ns = container_of(kref, struct uts_namespace, kref);
15459 put_user_ns(ns->user_ns);
15460 + atomic_dec(&vs_global_uts_ns);
15464 diff -NurpP --minimal linux-3.2.5/kernel/vserver/Kconfig linux-3.2.5-vs2.3.2.6/kernel/vserver/Kconfig
15465 --- linux-3.2.5/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
15466 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/Kconfig 2011-12-15 01:52:48.000000000 +0100
15469 +# Linux VServer configuration
15472 +menu "Linux VServer"
15474 +config VSERVER_AUTO_LBACK
15475 + bool "Automatically Assign Loopback IP"
15478 + Automatically assign a guest specific loopback
15479 + IP and add it to the kernel network stack on
15482 +config VSERVER_AUTO_SINGLE
15483 + bool "Automatic Single IP Special Casing"
15484 + depends on EXPERIMENTAL
15487 + This allows network contexts with a single IP to
15488 + automatically remap 0.0.0.0 bindings to that IP,
15489 + avoiding further network checks and improving
15492 + (note: such guests do not allow to change the ip
15493 + on the fly and do not show loopback addresses)
15495 +config VSERVER_COWBL
15496 + bool "Enable COW Immutable Link Breaking"
15499 + This enables the COW (Copy-On-Write) link break code.
15500 + It allows you to treat unified files like normal files
15501 + when writing to them (which will implicitely break the
15502 + link and create a copy of the unified file)
15504 +config VSERVER_VTIME
15505 + bool "Enable Virtualized Guest Time"
15506 + depends on EXPERIMENTAL
15509 + This enables per guest time offsets to allow for
15510 + adjusting the system clock individually per guest.
15511 + this adds some overhead to the time functions and
15512 + therefore should not be enabled without good reason.
15514 +config VSERVER_DEVICE
15515 + bool "Enable Guest Device Mapping"
15516 + depends on EXPERIMENTAL
15519 + This enables generic device remapping.
15521 +config VSERVER_PROC_SECURE
15522 + bool "Enable Proc Security"
15523 + depends on PROC_FS
15526 + This configures ProcFS security to initially hide
15527 + non-process entries for all contexts except the main and
15528 + spectator context (i.e. for all guests), which is a secure
15531 + (note: on 1.2x the entries were visible by default)
15534 + prompt "Persistent Inode Tagging"
15535 + default TAGGING_ID24
15537 + This adds persistent context information to filesystems
15538 + mounted with the tagxid option. Tagging is a requirement
15539 + for per-context disk limits and per-context quota.
15542 +config TAGGING_NONE
15545 + do not store per-context information in inodes.
15547 +config TAGGING_UID16
15548 + bool "UID16/GID32"
15550 + reduces UID to 16 bit, but leaves GID at 32 bit.
15552 +config TAGGING_GID16
15553 + bool "UID32/GID16"
15555 + reduces GID to 16 bit, but leaves UID at 32 bit.
15557 +config TAGGING_ID24
15558 + bool "UID24/GID24"
15560 + uses the upper 8bit from UID and GID for XID tagging
15561 + which leaves 24bit for UID/GID each, which should be
15562 + more than sufficient for normal use.
15564 +config TAGGING_INTERN
15565 + bool "UID32/GID32"
15567 + this uses otherwise reserved inode fields in the on
15568 + disk representation, which limits the use to a few
15569 + filesystems (currently ext2 and ext3)
15574 + bool "Tag NFSD User Auth and Files"
15577 + Enable this if you do want the in-kernel NFS
15578 + Server to use the tagging specified above.
15579 + (will require patched clients too)
15581 +config VSERVER_PRIVACY
15582 + bool "Honor Privacy Aspects of Guests"
15585 + When enabled, most context checks will disallow
15586 + access to structures assigned to a specific context,
15587 + like ptys or loop devices.
15589 +config VSERVER_CONTEXTS
15590 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15592 + default "768" if 64BIT
15595 + This setting will optimize certain data structures
15596 + and memory allocations according to the expected
15599 + note: this is not a strict upper limit.
15601 +config VSERVER_WARN
15602 + bool "VServer Warnings"
15605 + This enables various runtime warnings, which will
15606 + notify about potential manipulation attempts or
15607 + resource shortage. It is generally considered to
15608 + be a good idea to have that enabled.
15610 +config VSERVER_WARN_DEVPTS
15611 + bool "VServer DevPTS Warnings"
15612 + depends on VSERVER_WARN
15615 + This enables DevPTS related warnings, issued when a
15616 + process inside a context tries to lookup or access
15617 + a dynamic pts from the host or a different context.
15619 +config VSERVER_DEBUG
15620 + bool "VServer Debugging Code"
15623 + Set this to yes if you want to be able to activate
15624 + debugging output at runtime. It adds a very small
15625 + overhead to all vserver related functions and
15626 + increases the kernel size by about 20k.
15628 +config VSERVER_HISTORY
15629 + bool "VServer History Tracing"
15630 + depends on VSERVER_DEBUG
15633 + Set this to yes if you want to record the history of
15634 + linux-vserver activities, so they can be replayed in
15635 + the event of a kernel panic or oops.
15637 +config VSERVER_HISTORY_SIZE
15638 + int "Per-CPU History Size (32-65536)"
15639 + depends on VSERVER_HISTORY
15643 + This allows you to specify the number of entries in
15644 + the per-CPU history buffer.
15647 + prompt "Quotes used in debug and warn messages"
15648 + default QUOTES_ISO8859
15650 +config QUOTES_ISO8859
15651 + bool "Extended ASCII (ISO 8859) angle quotes"
15653 + This uses the extended ASCII characters \xbb
15654 + and \xab for quoting file and process names.
15656 +config QUOTES_UTF8
15657 + bool "UTF-8 angle quotes"
15659 + This uses the the UTF-8 sequences for angle
15660 + quotes to quote file and process names.
15662 +config QUOTES_ASCII
15663 + bool "ASCII single quotes"
15665 + This uses the ASCII single quote character
15666 + (\x27) to quote file and process names.
15676 + select NAMESPACES
15682 +config VSERVER_SECURITY
15684 + depends on SECURITY
15686 + select SECURITY_CAPABILITIES
15688 +config VSERVER_DISABLED
15692 diff -NurpP --minimal linux-3.2.5/kernel/vserver/Makefile linux-3.2.5-vs2.3.2.6/kernel/vserver/Makefile
15693 --- linux-3.2.5/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
15694 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/Makefile 2011-12-05 19:33:02.000000000 +0100
15697 +# Makefile for the Linux vserver routines.
15701 +obj-y += vserver.o
15703 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15704 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15707 +vserver-$(CONFIG_INET) += inet.o
15708 +vserver-$(CONFIG_PROC_FS) += proc.o
15709 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15710 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15711 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15712 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
15714 diff -NurpP --minimal linux-3.2.5/kernel/vserver/cacct.c linux-3.2.5-vs2.3.2.6/kernel/vserver/cacct.c
15715 --- linux-3.2.5/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
15716 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/cacct.c 2011-12-05 19:33:02.000000000 +0100
15719 + * linux/kernel/vserver/cacct.c
15721 + * Virtual Server: Context Accounting
15723 + * Copyright (C) 2006-2007 Herbert Pötzl
15725 + * V0.01 added accounting stats
15729 +#include <linux/types.h>
15730 +#include <linux/vs_context.h>
15731 +#include <linux/vserver/cacct_cmd.h>
15732 +#include <linux/vserver/cacct_int.h>
15734 +#include <asm/errno.h>
15735 +#include <asm/uaccess.h>
15738 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15740 + struct vcmd_sock_stat_v0 vc_data;
15743 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15746 + field = vc_data.field;
15747 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15750 + for (j = 0; j < 3; j++) {
15751 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15752 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15755 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15760 diff -NurpP --minimal linux-3.2.5/kernel/vserver/cacct_init.h linux-3.2.5-vs2.3.2.6/kernel/vserver/cacct_init.h
15761 --- linux-3.2.5/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
15762 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/cacct_init.h 2011-12-05 19:33:02.000000000 +0100
15766 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
15771 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15772 + for (j = 0; j < 3; j++) {
15773 + atomic_long_set(&cacct->sock[i][j].count, 0);
15774 + atomic_long_set(&cacct->sock[i][j].total, 0);
15777 + for (i = 0; i < 8; i++)
15778 + atomic_set(&cacct->slab[i], 0);
15779 + for (i = 0; i < 5; i++)
15780 + for (j = 0; j < 4; j++)
15781 + atomic_set(&cacct->page[i][j], 0);
15784 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
15789 diff -NurpP --minimal linux-3.2.5/kernel/vserver/cacct_proc.h linux-3.2.5-vs2.3.2.6/kernel/vserver/cacct_proc.h
15790 --- linux-3.2.5/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
15791 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/cacct_proc.h 2011-12-05 19:33:02.000000000 +0100
15793 +#ifndef _VX_CACCT_PROC_H
15794 +#define _VX_CACCT_PROC_H
15796 +#include <linux/vserver/cacct_int.h>
15799 +#define VX_SOCKA_TOP \
15800 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
15802 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
15804 + int i, j, length = 0;
15805 + static char *type[VXA_SOCK_SIZE] = {
15806 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
15809 + length += sprintf(buffer + length, VX_SOCKA_TOP);
15810 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15811 + length += sprintf(buffer + length, "%s:", type[i]);
15812 + for (j = 0; j < 3; j++) {
15813 + length += sprintf(buffer + length,
15814 + "\t%10lu/%-10lu",
15815 + vx_sock_count(cacct, i, j),
15816 + vx_sock_total(cacct, i, j));
15818 + buffer[length++] = '\n';
15821 + length += sprintf(buffer + length, "\n");
15822 + length += sprintf(buffer + length,
15823 + "slab:\t %8u %8u %8u %8u\n",
15824 + atomic_read(&cacct->slab[1]),
15825 + atomic_read(&cacct->slab[4]),
15826 + atomic_read(&cacct->slab[0]),
15827 + atomic_read(&cacct->slab[2]));
15829 + length += sprintf(buffer + length, "\n");
15830 + for (i = 0; i < 5; i++) {
15831 + length += sprintf(buffer + length,
15832 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
15833 + atomic_read(&cacct->page[i][0]),
15834 + atomic_read(&cacct->page[i][1]),
15835 + atomic_read(&cacct->page[i][2]),
15836 + atomic_read(&cacct->page[i][3]),
15837 + atomic_read(&cacct->page[i][4]),
15838 + atomic_read(&cacct->page[i][5]),
15839 + atomic_read(&cacct->page[i][6]),
15840 + atomic_read(&cacct->page[i][7]));
15845 +#endif /* _VX_CACCT_PROC_H */
15846 diff -NurpP --minimal linux-3.2.5/kernel/vserver/context.c linux-3.2.5-vs2.3.2.6/kernel/vserver/context.c
15847 --- linux-3.2.5/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
15848 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/context.c 2011-12-05 19:33:02.000000000 +0100
15851 + * linux/kernel/vserver/context.c
15853 + * Virtual Server: Context Support
15855 + * Copyright (C) 2003-2011 Herbert Pötzl
15857 + * V0.01 context helper
15858 + * V0.02 vx_ctx_kill syscall command
15859 + * V0.03 replaced context_info calls
15860 + * V0.04 redesign of struct (de)alloc
15861 + * V0.05 rlimit basic implementation
15862 + * V0.06 task_xid and info commands
15863 + * V0.07 context flags and caps
15864 + * V0.08 switch to RCU based hash
15865 + * V0.09 revert to non RCU for now
15866 + * V0.10 and back to working RCU hash
15867 + * V0.11 and back to locking again
15868 + * V0.12 referenced context store
15869 + * V0.13 separate per cpu data
15870 + * V0.14 changed vcmds to vxi arg
15871 + * V0.15 added context stat
15872 + * V0.16 have __create claim() the vxi
15873 + * V0.17 removed older and legacy stuff
15874 + * V0.18 added user credentials
15875 + * V0.19 added warn mask
15879 +#include <linux/slab.h>
15880 +#include <linux/types.h>
15881 +#include <linux/security.h>
15882 +#include <linux/pid_namespace.h>
15883 +#include <linux/capability.h>
15885 +#include <linux/vserver/context.h>
15886 +#include <linux/vserver/network.h>
15887 +#include <linux/vserver/debug.h>
15888 +#include <linux/vserver/limit.h>
15889 +#include <linux/vserver/limit_int.h>
15890 +#include <linux/vserver/space.h>
15891 +#include <linux/init_task.h>
15892 +#include <linux/fs_struct.h>
15893 +#include <linux/cred.h>
15895 +#include <linux/vs_context.h>
15896 +#include <linux/vs_limit.h>
15897 +#include <linux/vs_pid.h>
15898 +#include <linux/vserver/context_cmd.h>
15900 +#include "cvirt_init.h"
15901 +#include "cacct_init.h"
15902 +#include "limit_init.h"
15903 +#include "sched_init.h"
15906 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
15907 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
15910 +/* now inactive context structures */
15912 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
15914 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
15917 +/* __alloc_vx_info()
15919 + * allocate an initialized vx_info struct
15920 + * doesn't make it visible (hash) */
15922 +static struct vx_info *__alloc_vx_info(xid_t xid)
15924 + struct vx_info *new = NULL;
15927 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
15929 + /* would this benefit from a slab cache? */
15930 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
15934 + memset(new, 0, sizeof(struct vx_info));
15936 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
15937 + if (!new->ptr_pc)
15940 + new->vx_id = xid;
15941 + INIT_HLIST_NODE(&new->vx_hlist);
15942 + atomic_set(&new->vx_usecnt, 0);
15943 + atomic_set(&new->vx_tasks, 0);
15944 + new->vx_parent = NULL;
15945 + new->vx_state = 0;
15946 + init_waitqueue_head(&new->vx_wait);
15948 + /* prepare reaper */
15949 + get_task_struct(init_pid_ns.child_reaper);
15950 + new->vx_reaper = init_pid_ns.child_reaper;
15951 + new->vx_badness_bias = 0;
15953 + /* rest of init goes here */
15954 + vx_info_init_limit(&new->limit);
15955 + vx_info_init_sched(&new->sched);
15956 + vx_info_init_cvirt(&new->cvirt);
15957 + vx_info_init_cacct(&new->cacct);
15959 + /* per cpu data structures */
15960 + for_each_possible_cpu(cpu) {
15961 + vx_info_init_sched_pc(
15962 + &vx_per_cpu(new, sched_pc, cpu), cpu);
15963 + vx_info_init_cvirt_pc(
15964 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
15967 + new->vx_flags = VXF_INIT_SET;
15968 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
15969 + new->vx_ccaps = 0;
15970 + new->vx_umask = 0;
15971 + new->vx_wmask = 0;
15973 + new->reboot_cmd = 0;
15974 + new->exit_code = 0;
15976 + // preconfig spaces
15977 + for (index = 0; index < VX_SPACES; index++) {
15978 + struct _vx_space *space = &new->space[index];
15981 + spin_lock(&init_fs.lock);
15983 + spin_unlock(&init_fs.lock);
15984 + space->vx_fs = &init_fs;
15986 + /* FIXME: do we want defaults? */
15987 + // space->vx_real_cred = 0;
15988 + // space->vx_cred = 0;
15992 + vxdprintk(VXD_CBIT(xid, 0),
15993 + "alloc_vx_info(%d) = %p", xid, new);
15994 + vxh_alloc_vx_info(new);
15995 + atomic_inc(&vx_global_ctotal);
16004 +/* __dealloc_vx_info()
16006 + * final disposal of vx_info */
16008 +static void __dealloc_vx_info(struct vx_info *vxi)
16010 +#ifdef CONFIG_VSERVER_WARN
16011 + struct vx_info_save vxis;
16014 + vxdprintk(VXD_CBIT(xid, 0),
16015 + "dealloc_vx_info(%p)", vxi);
16016 + vxh_dealloc_vx_info(vxi);
16018 +#ifdef CONFIG_VSERVER_WARN
16019 + enter_vx_info(vxi, &vxis);
16020 + vx_info_exit_limit(&vxi->limit);
16021 + vx_info_exit_sched(&vxi->sched);
16022 + vx_info_exit_cvirt(&vxi->cvirt);
16023 + vx_info_exit_cacct(&vxi->cacct);
16025 + for_each_possible_cpu(cpu) {
16026 + vx_info_exit_sched_pc(
16027 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16028 + vx_info_exit_cvirt_pc(
16029 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16031 + leave_vx_info(&vxis);
16035 + vxi->vx_state |= VXS_RELEASED;
16038 + free_percpu(vxi->ptr_pc);
16041 + atomic_dec(&vx_global_ctotal);
16044 +static void __shutdown_vx_info(struct vx_info *vxi)
16046 + struct nsproxy *nsproxy;
16047 + struct fs_struct *fs;
16048 + struct cred *cred;
16053 + vxi->vx_state |= VXS_SHUTDOWN;
16054 + vs_state_change(vxi, VSC_SHUTDOWN);
16056 + for (index = 0; index < VX_SPACES; index++) {
16057 + struct _vx_space *space = &vxi->space[index];
16059 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16061 + put_nsproxy(nsproxy);
16063 + fs = xchg(&space->vx_fs, NULL);
16064 + spin_lock(&fs->lock);
16065 + kill = !--fs->users;
16066 + spin_unlock(&fs->lock);
16068 + free_fs_struct(fs);
16070 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16072 + abort_creds(cred);
16076 +/* exported stuff */
16078 +void free_vx_info(struct vx_info *vxi)
16080 + unsigned long flags;
16083 + /* check for reference counts first */
16084 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16085 + BUG_ON(atomic_read(&vxi->vx_tasks));
16087 + /* context must not be hashed */
16088 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16090 + /* context shutdown is mandatory */
16091 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16093 + /* spaces check */
16094 + for (index = 0; index < VX_SPACES; index++) {
16095 + struct _vx_space *space = &vxi->space[index];
16097 + BUG_ON(space->vx_nsproxy);
16098 + BUG_ON(space->vx_fs);
16099 + // BUG_ON(space->vx_real_cred);
16100 + // BUG_ON(space->vx_cred);
16103 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16104 + hlist_del(&vxi->vx_hlist);
16105 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16107 + __dealloc_vx_info(vxi);
16111 +/* hash table for vx_info hash */
16113 +#define VX_HASH_SIZE 13
16115 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16116 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16118 +static DEFINE_SPINLOCK(vx_info_hash_lock);
16121 +static inline unsigned int __hashval(xid_t xid)
16123 + return (xid % VX_HASH_SIZE);
16128 +/* __hash_vx_info()
16130 + * add the vxi to the global hash table
16131 + * requires the hash_lock to be held */
16133 +static inline void __hash_vx_info(struct vx_info *vxi)
16135 + struct hlist_head *head;
16137 + vxd_assert_lock(&vx_info_hash_lock);
16138 + vxdprintk(VXD_CBIT(xid, 4),
16139 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16140 + vxh_hash_vx_info(vxi);
16142 + /* context must not be hashed */
16143 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16145 + vxi->vx_state |= VXS_HASHED;
16146 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16147 + hlist_add_head(&vxi->vx_hlist, head);
16148 + atomic_inc(&vx_global_cactive);
16151 +/* __unhash_vx_info()
16153 + * remove the vxi from the global hash table
16154 + * requires the hash_lock to be held */
16156 +static inline void __unhash_vx_info(struct vx_info *vxi)
16158 + unsigned long flags;
16160 + vxd_assert_lock(&vx_info_hash_lock);
16161 + vxdprintk(VXD_CBIT(xid, 4),
16162 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16163 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16164 + vxh_unhash_vx_info(vxi);
16166 + /* context must be hashed */
16167 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16168 + /* but without tasks */
16169 + BUG_ON(atomic_read(&vxi->vx_tasks));
16171 + vxi->vx_state &= ~VXS_HASHED;
16172 + hlist_del_init(&vxi->vx_hlist);
16173 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16174 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16175 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16176 + atomic_dec(&vx_global_cactive);
16180 +/* __lookup_vx_info()
16182 + * requires the hash_lock to be held
16183 + * doesn't increment the vx_refcnt */
16185 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16187 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16188 + struct hlist_node *pos;
16189 + struct vx_info *vxi;
16191 + vxd_assert_lock(&vx_info_hash_lock);
16192 + hlist_for_each(pos, head) {
16193 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16195 + if (vxi->vx_id == xid)
16200 + vxdprintk(VXD_CBIT(xid, 0),
16201 + "__lookup_vx_info(#%u): %p[#%u]",
16202 + xid, vxi, vxi ? vxi->vx_id : 0);
16203 + vxh_lookup_vx_info(vxi, xid);
16208 +/* __create_vx_info()
16210 + * create the requested context
16211 + * get(), claim() and hash it */
16213 +static struct vx_info *__create_vx_info(int id)
16215 + struct vx_info *new, *vxi = NULL;
16217 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16219 + if (!(new = __alloc_vx_info(id)))
16220 + return ERR_PTR(-ENOMEM);
16222 + /* required to make dynamic xids unique */
16223 + spin_lock(&vx_info_hash_lock);
16225 + /* static context requested */
16226 + if ((vxi = __lookup_vx_info(id))) {
16227 + vxdprintk(VXD_CBIT(xid, 0),
16228 + "create_vx_info(%d) = %p (already there)", id, vxi);
16229 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16230 + vxi = ERR_PTR(-EBUSY);
16232 + vxi = ERR_PTR(-EEXIST);
16235 + /* new context */
16236 + vxdprintk(VXD_CBIT(xid, 0),
16237 + "create_vx_info(%d) = %p (new)", id, new);
16238 + claim_vx_info(new, NULL);
16239 + __hash_vx_info(get_vx_info(new));
16240 + vxi = new, new = NULL;
16243 + spin_unlock(&vx_info_hash_lock);
16244 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16246 + __dealloc_vx_info(new);
16251 +/* exported stuff */
16254 +void unhash_vx_info(struct vx_info *vxi)
16256 + spin_lock(&vx_info_hash_lock);
16257 + __unhash_vx_info(vxi);
16258 + spin_unlock(&vx_info_hash_lock);
16259 + __shutdown_vx_info(vxi);
16260 + __wakeup_vx_info(vxi);
16264 +/* lookup_vx_info()
16266 + * search for a vx_info and get() it
16267 + * negative id means current */
16269 +struct vx_info *lookup_vx_info(int id)
16271 + struct vx_info *vxi = NULL;
16274 + vxi = get_vx_info(current_vx_info());
16275 + } else if (id > 1) {
16276 + spin_lock(&vx_info_hash_lock);
16277 + vxi = get_vx_info(__lookup_vx_info(id));
16278 + spin_unlock(&vx_info_hash_lock);
16283 +/* xid_is_hashed()
16285 + * verify that xid is still hashed */
16287 +int xid_is_hashed(xid_t xid)
16291 + spin_lock(&vx_info_hash_lock);
16292 + hashed = (__lookup_vx_info(xid) != NULL);
16293 + spin_unlock(&vx_info_hash_lock);
16297 +#ifdef CONFIG_PROC_FS
16301 + * get a subset of hashed xids for proc
16302 + * assumes size is at least one */
16304 +int get_xid_list(int index, unsigned int *xids, int size)
16306 + int hindex, nr_xids = 0;
16308 + /* only show current and children */
16309 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16312 + xids[nr_xids] = vx_current_xid();
16316 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16317 + struct hlist_head *head = &vx_info_hash[hindex];
16318 + struct hlist_node *pos;
16320 + spin_lock(&vx_info_hash_lock);
16321 + hlist_for_each(pos, head) {
16322 + struct vx_info *vxi;
16327 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16328 + xids[nr_xids] = vxi->vx_id;
16329 + if (++nr_xids >= size) {
16330 + spin_unlock(&vx_info_hash_lock);
16334 + /* keep the lock time short */
16335 + spin_unlock(&vx_info_hash_lock);
16342 +#ifdef CONFIG_VSERVER_DEBUG
16344 +void dump_vx_info_inactive(int level)
16346 + struct hlist_node *entry, *next;
16348 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16349 + struct vx_info *vxi =
16350 + list_entry(entry, struct vx_info, vx_hlist);
16352 + dump_vx_info(vxi, level);
16359 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16361 + struct user_struct *new_user, *old_user;
16366 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16369 + new_user = alloc_uid(vxi->vx_id, p->uid);
16373 + old_user = p->user;
16374 + if (new_user != old_user) {
16375 + atomic_inc(&new_user->processes);
16376 + atomic_dec(&old_user->processes);
16377 + p->user = new_user;
16379 + free_uid(old_user);
16385 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16387 + // p->cap_effective &= vxi->vx_cap_bset;
16388 + p->cap_effective =
16389 + cap_intersect(p->cap_effective, vxi->cap_bset);
16390 + // p->cap_inheritable &= vxi->vx_cap_bset;
16391 + p->cap_inheritable =
16392 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16393 + // p->cap_permitted &= vxi->vx_cap_bset;
16394 + p->cap_permitted =
16395 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16400 +#include <linux/file.h>
16401 +#include <linux/fdtable.h>
16403 +static int vx_openfd_task(struct task_struct *tsk)
16405 + struct files_struct *files = tsk->files;
16406 + struct fdtable *fdt;
16407 + const unsigned long *bptr;
16408 + int count, total;
16410 + /* no rcu_read_lock() because of spin_lock() */
16411 + spin_lock(&files->file_lock);
16412 + fdt = files_fdtable(files);
16413 + bptr = fdt->open_fds->fds_bits;
16414 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16415 + for (total = 0; count > 0; count--) {
16417 + total += hweight_long(*bptr);
16420 + spin_unlock(&files->file_lock);
16425 +/* for *space compatibility */
16427 +asmlinkage long sys_unshare(unsigned long);
16430 + * migrate task to new context
16431 + * gets vxi, puts old_vxi on change
16432 + * optionally unshares namespaces (hack)
16435 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16437 + struct vx_info *old_vxi;
16443 + vxdprintk(VXD_CBIT(xid, 5),
16444 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16445 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16447 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16448 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16451 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16454 + old_vxi = task_get_vx_info(p);
16455 + if (old_vxi == vxi)
16458 +// if (!(ret = vx_migrate_user(p, vxi))) {
16463 + openfd = vx_openfd_task(p);
16466 + atomic_dec(&old_vxi->cvirt.nr_threads);
16467 + atomic_dec(&old_vxi->cvirt.nr_running);
16468 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16469 + /* FIXME: what about the struct files here? */
16470 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16471 + /* account for the executable */
16472 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16474 + atomic_inc(&vxi->cvirt.nr_threads);
16475 + atomic_inc(&vxi->cvirt.nr_running);
16476 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16477 + /* FIXME: what about the struct files here? */
16478 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16479 + /* account for the executable */
16480 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16483 + release_vx_info(old_vxi, p);
16484 + clr_vx_info(&p->vx_info);
16486 + claim_vx_info(vxi, p);
16487 + set_vx_info(&p->vx_info, vxi);
16488 + p->xid = vxi->vx_id;
16490 + vxdprintk(VXD_CBIT(xid, 5),
16491 + "moved task %p into vxi:%p[#%d]",
16492 + p, vxi, vxi->vx_id);
16494 + // vx_mask_cap_bset(vxi, p);
16497 + /* hack for *spaces to provide compatibility */
16499 + struct nsproxy *old_nsp, *new_nsp;
16501 + ret = unshare_nsproxy_namespaces(
16502 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16507 + old_nsp = xchg(&p->nsproxy, new_nsp);
16508 + vx_set_space(vxi,
16509 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16510 + put_nsproxy(old_nsp);
16514 + put_vx_info(old_vxi);
16518 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16520 + struct task_struct *old_reaper;
16525 + vxdprintk(VXD_CBIT(xid, 6),
16526 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16527 + vxi, vxi->vx_id, p, p->xid, p->pid);
16529 + old_reaper = vxi->vx_reaper;
16530 + if (old_reaper == p)
16533 + /* set new child reaper */
16534 + get_task_struct(p);
16535 + vxi->vx_reaper = p;
16536 + put_task_struct(old_reaper);
16540 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16545 + vxdprintk(VXD_CBIT(xid, 6),
16546 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16547 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16549 + vxi->vx_flags &= ~VXF_STATE_INIT;
16550 + // vxi->vx_initpid = p->tgid;
16551 + vxi->vx_initpid = p->pid;
16555 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16557 + vxdprintk(VXD_CBIT(xid, 6),
16558 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16559 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16561 + vxi->exit_code = code;
16562 + vxi->vx_initpid = 0;
16566 +void vx_set_persistent(struct vx_info *vxi)
16568 + vxdprintk(VXD_CBIT(xid, 6),
16569 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16571 + get_vx_info(vxi);
16572 + claim_vx_info(vxi, NULL);
16575 +void vx_clear_persistent(struct vx_info *vxi)
16577 + vxdprintk(VXD_CBIT(xid, 6),
16578 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16580 + release_vx_info(vxi, NULL);
16581 + put_vx_info(vxi);
16584 +void vx_update_persistent(struct vx_info *vxi)
16586 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16587 + vx_set_persistent(vxi);
16589 + vx_clear_persistent(vxi);
16593 +/* task must be current or locked */
16595 +void exit_vx_info(struct task_struct *p, int code)
16597 + struct vx_info *vxi = p->vx_info;
16600 + atomic_dec(&vxi->cvirt.nr_threads);
16603 + vxi->exit_code = code;
16604 + release_vx_info(vxi, p);
16608 +void exit_vx_info_early(struct task_struct *p, int code)
16610 + struct vx_info *vxi = p->vx_info;
16613 + if (vxi->vx_initpid == p->pid)
16614 + vx_exit_init(vxi, p, code);
16615 + if (vxi->vx_reaper == p)
16616 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16621 +/* vserver syscall commands below here */
16623 +/* taks xid and vx_info functions */
16625 +#include <asm/uaccess.h>
16628 +int vc_task_xid(uint32_t id)
16633 + struct task_struct *tsk;
16636 + tsk = find_task_by_real_pid(id);
16637 + xid = (tsk) ? tsk->xid : -ESRCH;
16638 + rcu_read_unlock();
16640 + xid = vx_current_xid();
16645 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16647 + struct vcmd_vx_info_v0 vc_data;
16649 + vc_data.xid = vxi->vx_id;
16650 + vc_data.initpid = vxi->vx_initpid;
16652 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16658 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16660 + struct vcmd_ctx_stat_v0 vc_data;
16662 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16663 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16665 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16671 +/* context functions */
16673 +int vc_ctx_create(uint32_t xid, void __user *data)
16675 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16676 + struct vx_info *new_vxi;
16679 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16682 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16685 + new_vxi = __create_vx_info(xid);
16686 + if (IS_ERR(new_vxi))
16687 + return PTR_ERR(new_vxi);
16689 + /* initial flags */
16690 + new_vxi->vx_flags = vc_data.flagword;
16693 + if (vs_state_change(new_vxi, VSC_STARTUP))
16696 + ret = vx_migrate_task(current, new_vxi, (!data));
16700 + /* return context id on success */
16701 + ret = new_vxi->vx_id;
16703 + /* get a reference for persistent contexts */
16704 + if ((vc_data.flagword & VXF_PERSISTENT))
16705 + vx_set_persistent(new_vxi);
16707 + release_vx_info(new_vxi, NULL);
16708 + put_vx_info(new_vxi);
16713 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16715 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16718 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16721 + ret = vx_migrate_task(current, vxi, 0);
16724 + if (vc_data.flagword & VXM_SET_INIT)
16725 + ret = vx_set_init(vxi, current);
16728 + if (vc_data.flagword & VXM_SET_REAPER)
16729 + ret = vx_set_reaper(vxi, current);
16734 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16736 + struct vcmd_ctx_flags_v0 vc_data;
16738 + vc_data.flagword = vxi->vx_flags;
16740 + /* special STATE flag handling */
16741 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16743 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16748 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16750 + struct vcmd_ctx_flags_v0 vc_data;
16751 + uint64_t mask, trigger;
16753 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16756 + /* special STATE flag handling */
16757 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16758 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16760 + if (vxi == current_vx_info()) {
16761 + /* if (trigger & VXF_STATE_SETUP)
16762 + vx_mask_cap_bset(vxi, current); */
16763 + if (trigger & VXF_STATE_INIT) {
16766 + ret = vx_set_init(vxi, current);
16769 + ret = vx_set_reaper(vxi, current);
16775 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
16776 + vc_data.flagword, mask);
16777 + if (trigger & VXF_PERSISTENT)
16778 + vx_update_persistent(vxi);
16784 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
16786 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
16788 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
16792 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
16794 + kernel_cap_t c = __cap_empty_set;
16796 + c.cap[0] = v & 0xFFFFFFFF;
16797 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
16799 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
16804 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
16807 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
16809 + *ccaps = vxi->vx_ccaps;
16814 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
16816 + struct vcmd_ctx_caps_v1 vc_data;
16819 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
16822 + vc_data.cmask = ~0ULL;
16824 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16829 +static int do_set_caps(struct vx_info *vxi,
16830 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
16832 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
16835 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
16836 + bcaps, bmask, ccaps, cmask);
16838 + vxi->vx_bcaps = cap_t_from_caps(
16839 + vs_mask_flags(bcold, bcaps, bmask));
16840 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
16845 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
16847 + struct vcmd_ctx_caps_v1 vc_data;
16849 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16852 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
16855 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
16857 + struct vcmd_bcaps vc_data;
16860 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
16863 + vc_data.bmask = ~0ULL;
16865 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16870 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
16872 + struct vcmd_bcaps vc_data;
16874 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16877 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
16881 +int vc_get_umask(struct vx_info *vxi, void __user *data)
16883 + struct vcmd_umask vc_data;
16885 + vc_data.umask = vxi->vx_umask;
16886 + vc_data.mask = ~0ULL;
16888 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16893 +int vc_set_umask(struct vx_info *vxi, void __user *data)
16895 + struct vcmd_umask vc_data;
16897 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16900 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
16901 + vc_data.umask, vc_data.mask);
16906 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
16908 + struct vcmd_wmask vc_data;
16910 + vc_data.wmask = vxi->vx_wmask;
16911 + vc_data.mask = ~0ULL;
16913 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16918 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
16920 + struct vcmd_wmask vc_data;
16922 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16925 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
16926 + vc_data.wmask, vc_data.mask);
16931 +int vc_get_badness(struct vx_info *vxi, void __user *data)
16933 + struct vcmd_badness_v0 vc_data;
16935 + vc_data.bias = vxi->vx_badness_bias;
16937 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16942 +int vc_set_badness(struct vx_info *vxi, void __user *data)
16944 + struct vcmd_badness_v0 vc_data;
16946 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16949 + vxi->vx_badness_bias = vc_data.bias;
16953 +#include <linux/module.h>
16955 +EXPORT_SYMBOL_GPL(free_vx_info);
16957 diff -NurpP --minimal linux-3.2.5/kernel/vserver/cvirt.c linux-3.2.5-vs2.3.2.6/kernel/vserver/cvirt.c
16958 --- linux-3.2.5/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
16959 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/cvirt.c 2011-12-05 19:33:02.000000000 +0100
16962 + * linux/kernel/vserver/cvirt.c
16964 + * Virtual Server: Context Virtualization
16966 + * Copyright (C) 2004-2007 Herbert Pötzl
16968 + * V0.01 broken out from limit.c
16969 + * V0.02 added utsname stuff
16970 + * V0.03 changed vcmds to vxi arg
16974 +#include <linux/types.h>
16975 +#include <linux/utsname.h>
16976 +#include <linux/vs_cvirt.h>
16977 +#include <linux/vserver/switch.h>
16978 +#include <linux/vserver/cvirt_cmd.h>
16980 +#include <asm/uaccess.h>
16983 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
16985 + struct vx_info *vxi = current_vx_info();
16987 + set_normalized_timespec(uptime,
16988 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
16989 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
16992 + set_normalized_timespec(idle,
16993 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
16994 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
16998 +uint64_t vx_idle_jiffies(void)
17000 + return init_task.utime + init_task.stime;
17005 +static inline uint32_t __update_loadavg(uint32_t load,
17006 + int wsize, int delta, int n)
17008 + unsigned long long calc, prev;
17010 + /* just set it to n */
17011 + if (unlikely(delta >= wsize))
17012 + return (n << FSHIFT);
17014 + calc = delta * n;
17016 + prev = (wsize - delta);
17019 + do_div(calc, wsize);
17024 +void vx_update_load(struct vx_info *vxi)
17026 + uint32_t now, last, delta;
17027 + unsigned int nr_running, nr_uninterruptible;
17028 + unsigned int total;
17029 + unsigned long flags;
17031 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17034 + last = vxi->cvirt.load_last;
17035 + delta = now - last;
17037 + if (delta < 5*HZ)
17040 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17041 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17042 + total = nr_running + nr_uninterruptible;
17044 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17045 + 60*HZ, delta, total);
17046 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17047 + 5*60*HZ, delta, total);
17048 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17049 + 15*60*HZ, delta, total);
17051 + vxi->cvirt.load_last = now;
17053 + atomic_inc(&vxi->cvirt.load_updates);
17054 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17059 + * Commands to do_syslog:
17061 + * 0 -- Close the log. Currently a NOP.
17062 + * 1 -- Open the log. Currently a NOP.
17063 + * 2 -- Read from the log.
17064 + * 3 -- Read all messages remaining in the ring buffer.
17065 + * 4 -- Read and clear all messages remaining in the ring buffer
17066 + * 5 -- Clear ring buffer.
17067 + * 6 -- Disable printk's to console
17068 + * 7 -- Enable printk's to console
17069 + * 8 -- Set level of messages printed to console
17070 + * 9 -- Return number of unread characters in the log buffer
17071 + * 10 -- Return size of the log buffer
17073 +int vx_do_syslog(int type, char __user *buf, int len)
17076 + int do_clear = 0;
17077 + struct vx_info *vxi = current_vx_info();
17078 + struct _vx_syslog *log;
17082 + log = &vxi->cvirt.syslog;
17085 + case 0: /* Close log */
17086 + case 1: /* Open log */
17088 + case 2: /* Read from log */
17089 + error = wait_event_interruptible(log->log_wait,
17090 + (log->log_start - log->log_end));
17093 + spin_lock_irq(&log->logbuf_lock);
17094 + spin_unlock_irq(&log->logbuf_lock);
17096 + case 4: /* Read/clear last kernel messages */
17098 + /* fall through */
17099 + case 3: /* Read last kernel messages */
17102 + case 5: /* Clear ring buffer */
17105 + case 6: /* Disable logging to console */
17106 + case 7: /* Enable logging to console */
17107 + case 8: /* Set level of messages printed to console */
17110 + case 9: /* Number of chars in the log buffer */
17112 + case 10: /* Size of the log buffer */
17122 +/* virtual host info names */
17124 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17126 + struct nsproxy *nsproxy;
17127 + struct uts_namespace *uts;
17129 + if (id == VHIN_CONTEXT)
17130 + return vxi->vx_name;
17132 + nsproxy = vxi->space[0].vx_nsproxy;
17136 + uts = nsproxy->uts_ns;
17141 + case VHIN_SYSNAME:
17142 + return uts->name.sysname;
17143 + case VHIN_NODENAME:
17144 + return uts->name.nodename;
17145 + case VHIN_RELEASE:
17146 + return uts->name.release;
17147 + case VHIN_VERSION:
17148 + return uts->name.version;
17149 + case VHIN_MACHINE:
17150 + return uts->name.machine;
17151 + case VHIN_DOMAINNAME:
17152 + return uts->name.domainname;
17159 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17161 + struct vcmd_vhi_name_v0 vc_data;
17164 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17167 + name = vx_vhi_name(vxi, vc_data.field);
17171 + memcpy(name, vc_data.name, 65);
17175 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17177 + struct vcmd_vhi_name_v0 vc_data;
17180 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17183 + name = vx_vhi_name(vxi, vc_data.field);
17187 + memcpy(vc_data.name, name, 65);
17188 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17194 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17196 + struct vcmd_virt_stat_v0 vc_data;
17197 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17198 + struct timespec uptime;
17200 + do_posix_clock_monotonic_gettime(&uptime);
17201 + set_normalized_timespec(&uptime,
17202 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17203 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17205 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17206 + vc_data.uptime = timespec_to_ns(&uptime);
17207 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17208 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17209 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17210 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17211 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17212 + vc_data.load[0] = cvirt->load[0];
17213 + vc_data.load[1] = cvirt->load[1];
17214 + vc_data.load[2] = cvirt->load[2];
17216 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17222 +#ifdef CONFIG_VSERVER_VTIME
17224 +/* virtualized time base */
17226 +void vx_adjust_timespec(struct timespec *ts)
17228 + struct vx_info *vxi;
17230 + if (!vx_flags(VXF_VIRT_TIME, 0))
17233 + vxi = current_vx_info();
17234 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17235 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17237 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17239 + ts->tv_nsec -= NSEC_PER_SEC;
17240 + } else if (ts->tv_nsec < 0) {
17242 + ts->tv_nsec += NSEC_PER_SEC;
17246 +int vx_settimeofday(const struct timespec *ts)
17248 + struct timespec ats, delta;
17249 + struct vx_info *vxi;
17251 + if (!vx_flags(VXF_VIRT_TIME, 0))
17252 + return do_settimeofday(ts);
17254 + getnstimeofday(&ats);
17255 + delta = timespec_sub(*ts, ats);
17257 + vxi = current_vx_info();
17258 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17264 diff -NurpP --minimal linux-3.2.5/kernel/vserver/cvirt_init.h linux-3.2.5-vs2.3.2.6/kernel/vserver/cvirt_init.h
17265 --- linux-3.2.5/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17266 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/cvirt_init.h 2011-12-05 19:33:02.000000000 +0100
17270 +extern uint64_t vx_idle_jiffies(void);
17272 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17274 + uint64_t idle_jiffies = vx_idle_jiffies();
17275 + uint64_t nsuptime;
17277 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17278 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17279 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17280 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17281 + cvirt->bias_ts.tv_sec = 0;
17282 + cvirt->bias_ts.tv_nsec = 0;
17284 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17285 + atomic_set(&cvirt->nr_threads, 0);
17286 + atomic_set(&cvirt->nr_running, 0);
17287 + atomic_set(&cvirt->nr_uninterruptible, 0);
17288 + atomic_set(&cvirt->nr_onhold, 0);
17290 + spin_lock_init(&cvirt->load_lock);
17291 + cvirt->load_last = jiffies;
17292 + atomic_set(&cvirt->load_updates, 0);
17293 + cvirt->load[0] = 0;
17294 + cvirt->load[1] = 0;
17295 + cvirt->load[2] = 0;
17296 + atomic_set(&cvirt->total_forks, 0);
17298 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17299 + init_waitqueue_head(&cvirt->syslog.log_wait);
17300 + cvirt->syslog.log_start = 0;
17301 + cvirt->syslog.log_end = 0;
17302 + cvirt->syslog.con_start = 0;
17303 + cvirt->syslog.logged_chars = 0;
17307 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17309 + // cvirt_pc->cpustat = { 0 };
17312 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17314 +#ifdef CONFIG_VSERVER_WARN
17317 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17318 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17320 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17321 + "!!! cvirt: %p[nr_running] = %d on exit.",
17323 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17324 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17326 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17327 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17333 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17338 diff -NurpP --minimal linux-3.2.5/kernel/vserver/cvirt_proc.h linux-3.2.5-vs2.3.2.6/kernel/vserver/cvirt_proc.h
17339 --- linux-3.2.5/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17340 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/cvirt_proc.h 2011-12-05 19:33:02.000000000 +0100
17342 +#ifndef _VX_CVIRT_PROC_H
17343 +#define _VX_CVIRT_PROC_H
17345 +#include <linux/nsproxy.h>
17346 +#include <linux/mnt_namespace.h>
17347 +#include <linux/ipc_namespace.h>
17348 +#include <linux/utsname.h>
17349 +#include <linux/ipc.h>
17353 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17355 + struct mnt_namespace *ns;
17356 + struct uts_namespace *uts;
17357 + struct ipc_namespace *ipc;
17358 + struct path path;
17359 + char *pstr, *root;
17365 + length += sprintf(buffer + length,
17366 + "NSProxy:\t%p [%p,%p,%p]\n",
17367 + nsproxy, nsproxy->mnt_ns,
17368 + nsproxy->uts_ns, nsproxy->ipc_ns);
17370 + ns = nsproxy->mnt_ns;
17374 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17378 + path.mnt = ns->root;
17379 + path.dentry = ns->root->mnt_root;
17380 + root = d_path(&path, pstr, PATH_MAX - 2);
17381 + length += sprintf(buffer + length,
17382 + "Namespace:\t%p [#%u]\n"
17383 + "RootPath:\t%s\n",
17384 + ns, atomic_read(&ns->count),
17389 + uts = nsproxy->uts_ns;
17393 + length += sprintf(buffer + length,
17394 + "SysName:\t%.*s\n"
17395 + "NodeName:\t%.*s\n"
17396 + "Release:\t%.*s\n"
17397 + "Version:\t%.*s\n"
17398 + "Machine:\t%.*s\n"
17399 + "DomainName:\t%.*s\n",
17400 + __NEW_UTS_LEN, uts->name.sysname,
17401 + __NEW_UTS_LEN, uts->name.nodename,
17402 + __NEW_UTS_LEN, uts->name.release,
17403 + __NEW_UTS_LEN, uts->name.version,
17404 + __NEW_UTS_LEN, uts->name.machine,
17405 + __NEW_UTS_LEN, uts->name.domainname);
17408 + ipc = nsproxy->ipc_ns;
17412 + length += sprintf(buffer + length,
17413 + "SEMS:\t\t%d %d %d %d %d\n"
17414 + "MSG:\t\t%d %d %d\n"
17415 + "SHM:\t\t%lu %lu %d %d\n",
17416 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17417 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17419 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17420 + (unsigned long)ipc->shm_ctlmax,
17421 + (unsigned long)ipc->shm_ctlall,
17422 + ipc->shm_ctlmni, ipc->shm_tot);
17429 +#include <linux/sched.h>
17431 +#define LOAD_INT(x) ((x) >> FSHIFT)
17432 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17435 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17440 + length += sprintf(buffer + length,
17441 + "BiasUptime:\t%lu.%02lu\n",
17442 + (unsigned long)cvirt->bias_uptime.tv_sec,
17443 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17445 + a = cvirt->load[0] + (FIXED_1 / 200);
17446 + b = cvirt->load[1] + (FIXED_1 / 200);
17447 + c = cvirt->load[2] + (FIXED_1 / 200);
17448 + length += sprintf(buffer + length,
17449 + "nr_threads:\t%d\n"
17450 + "nr_running:\t%d\n"
17451 + "nr_unintr:\t%d\n"
17452 + "nr_onhold:\t%d\n"
17453 + "load_updates:\t%d\n"
17454 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17455 + "total_forks:\t%d\n",
17456 + atomic_read(&cvirt->nr_threads),
17457 + atomic_read(&cvirt->nr_running),
17458 + atomic_read(&cvirt->nr_uninterruptible),
17459 + atomic_read(&cvirt->nr_onhold),
17460 + atomic_read(&cvirt->load_updates),
17461 + LOAD_INT(a), LOAD_FRAC(a),
17462 + LOAD_INT(b), LOAD_FRAC(b),
17463 + LOAD_INT(c), LOAD_FRAC(c),
17464 + atomic_read(&cvirt->total_forks));
17469 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17470 + char *buffer, int cpu)
17476 +#endif /* _VX_CVIRT_PROC_H */
17477 diff -NurpP --minimal linux-3.2.5/kernel/vserver/debug.c linux-3.2.5-vs2.3.2.6/kernel/vserver/debug.c
17478 --- linux-3.2.5/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17479 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/debug.c 2011-12-05 19:33:02.000000000 +0100
17482 + * kernel/vserver/debug.c
17484 + * Copyright (C) 2005-2007 Herbert Pötzl
17486 + * V0.01 vx_info dump support
17490 +#include <linux/module.h>
17492 +#include <linux/vserver/context.h>
17495 +void dump_vx_info(struct vx_info *vxi, int level)
17497 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17498 + atomic_read(&vxi->vx_usecnt),
17499 + atomic_read(&vxi->vx_tasks),
17502 + __dump_vx_limit(&vxi->limit);
17503 + __dump_vx_sched(&vxi->sched);
17504 + __dump_vx_cvirt(&vxi->cvirt);
17505 + __dump_vx_cacct(&vxi->cacct);
17511 +EXPORT_SYMBOL_GPL(dump_vx_info);
17513 diff -NurpP --minimal linux-3.2.5/kernel/vserver/device.c linux-3.2.5-vs2.3.2.6/kernel/vserver/device.c
17514 --- linux-3.2.5/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17515 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/device.c 2011-12-05 19:33:02.000000000 +0100
17518 + * linux/kernel/vserver/device.c
17520 + * Linux-VServer: Device Support
17522 + * Copyright (C) 2006 Herbert Pötzl
17523 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17525 + * V0.01 device mapping basics
17526 + * V0.02 added defaults
17530 +#include <linux/slab.h>
17531 +#include <linux/rcupdate.h>
17532 +#include <linux/fs.h>
17533 +#include <linux/namei.h>
17534 +#include <linux/hash.h>
17536 +#include <asm/errno.h>
17537 +#include <asm/uaccess.h>
17538 +#include <linux/vserver/base.h>
17539 +#include <linux/vserver/debug.h>
17540 +#include <linux/vserver/context.h>
17541 +#include <linux/vserver/device.h>
17542 +#include <linux/vserver/device_cmd.h>
17545 +#define DMAP_HASH_BITS 4
17548 +struct vs_mapping {
17550 + struct hlist_node hlist;
17551 + struct list_head list;
17553 +#define dm_hlist u.hlist
17554 +#define dm_list u.list
17557 + struct vx_dmap_target target;
17561 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17563 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17565 +static struct vx_dmap_target dmap_defaults[2] = {
17566 + { .flags = DATTR_OPEN },
17567 + { .flags = DATTR_OPEN },
17571 +struct kmem_cache *dmap_cachep __read_mostly;
17573 +int __init dmap_cache_init(void)
17575 + dmap_cachep = kmem_cache_create("dmap_cache",
17576 + sizeof(struct vs_mapping), 0,
17577 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17581 +__initcall(dmap_cache_init);
17584 +static inline unsigned int __hashval(dev_t dev, int bits)
17586 + return hash_long((unsigned long)dev, bits);
17590 +/* __hash_mapping()
17591 + * add the mapping to the hash table
17593 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17595 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17596 + struct hlist_head *head, *hash = dmap_main_hash;
17597 + int device = vdm->device;
17599 + spin_lock(hash_lock);
17600 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17601 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17603 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17604 + hlist_add_head(&vdm->dm_hlist, head);
17605 + spin_unlock(hash_lock);
17609 +static inline int __mode_to_default(umode_t mode)
17622 +/* __set_default()
17625 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17626 + struct vx_dmap_target *vdmt)
17628 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17629 + spin_lock(hash_lock);
17632 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17634 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17637 + spin_unlock(hash_lock);
17639 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17640 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17644 +/* __remove_default()
17645 + * remove a default
17647 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17649 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17650 + spin_lock(hash_lock);
17653 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17654 + else /* remove == reset */
17655 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17657 + spin_unlock(hash_lock);
17662 +/* __find_mapping()
17663 + * find a mapping in the hash table
17665 + * caller must hold hash_lock
17667 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17668 + struct vs_mapping **local, struct vs_mapping **global)
17670 + struct hlist_head *hash = dmap_main_hash;
17671 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17672 + struct hlist_node *pos;
17673 + struct vs_mapping *vdm;
17679 + hlist_for_each(pos, head) {
17680 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17682 + if ((vdm->device == device) &&
17683 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17684 + if (vdm->xid == xid) {
17687 + } else if (global && vdm->xid == 0)
17692 + if (global && *global)
17699 +/* __lookup_mapping()
17700 + * find a mapping and store the result in target and flags
17702 +static inline int __lookup_mapping(struct vx_info *vxi,
17703 + dev_t device, dev_t *target, int *flags, umode_t mode)
17705 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17706 + struct vs_mapping *vdm, *global;
17707 + struct vx_dmap_target *vdmt;
17709 + xid_t xid = vxi->vx_id;
17712 + spin_lock(hash_lock);
17713 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17715 + vdmt = &vdm->target;
17719 + index = __mode_to_default(mode);
17720 + if (vxi && vxi->dmap.targets[index].flags) {
17722 + vdmt = &vxi->dmap.targets[index];
17723 + } else if (global) {
17725 + vdmt = &global->target;
17729 + vdmt = &dmap_defaults[index];
17733 + if (target && (vdmt->flags & DATTR_REMAP))
17734 + *target = vdmt->target;
17736 + *target = device;
17738 + *flags = vdmt->flags;
17740 + spin_unlock(hash_lock);
17746 +/* __remove_mapping()
17747 + * remove a mapping from the hash table
17749 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17752 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17753 + struct vs_mapping *vdm = NULL;
17756 + spin_lock(hash_lock);
17758 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17760 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
17761 + vxi, vxi ? vxi->vx_id : 0, device, mode);
17764 + hlist_del(&vdm->dm_hlist);
17767 + spin_unlock(hash_lock);
17769 + kmem_cache_free(dmap_cachep, vdm);
17775 +int vs_map_device(struct vx_info *vxi,
17776 + dev_t device, dev_t *target, umode_t mode)
17778 + int ret, flags = DATTR_MASK;
17782 + *target = device;
17785 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
17786 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
17787 + device, target ? *target : 0, flags, mode, ret);
17789 + return (flags & DATTR_MASK);
17794 +static int do_set_mapping(struct vx_info *vxi,
17795 + dev_t device, dev_t target, int flags, umode_t mode)
17798 + struct vs_mapping *new;
17800 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
17804 + INIT_HLIST_NODE(&new->dm_hlist);
17805 + new->device = device;
17806 + new->target.target = target;
17807 + new->target.flags = flags | mode;
17808 + new->xid = (vxi ? vxi->vx_id : 0);
17810 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
17811 + __hash_mapping(vxi, new);
17813 + struct vx_dmap_target new = {
17814 + .target = target,
17815 + .flags = flags | mode,
17817 + __set_default(vxi, mode, &new);
17823 +static int do_unset_mapping(struct vx_info *vxi,
17824 + dev_t device, dev_t target, int flags, umode_t mode)
17826 + int ret = -EINVAL;
17829 + ret = __remove_mapping(vxi, device, mode);
17833 + ret = __remove_default(vxi, mode);
17843 +static inline int __user_device(const char __user *name, dev_t *dev,
17846 + struct nameidata nd;
17853 + ret = user_lpath(name, &nd.path);
17856 + if (nd.path.dentry->d_inode) {
17857 + *dev = nd.path.dentry->d_inode->i_rdev;
17858 + *mode = nd.path.dentry->d_inode->i_mode;
17860 + path_put(&nd.path);
17864 +static inline int __mapping_mode(dev_t device, dev_t target,
17865 + umode_t device_mode, umode_t target_mode, umode_t *mode)
17868 + *mode = device_mode & S_IFMT;
17870 + *mode = target_mode & S_IFMT;
17874 + /* if both given, device and target mode have to match */
17875 + if (device && target &&
17876 + ((device_mode ^ target_mode) & S_IFMT))
17882 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
17883 + const char __user *target_path, int flags, int set)
17885 + dev_t device = ~0, target = ~0;
17886 + umode_t device_mode = 0, target_mode = 0, mode;
17889 + ret = __user_device(device_path, &device, &device_mode);
17892 + ret = __user_device(target_path, &target, &target_mode);
17896 + ret = __mapping_mode(device, target,
17897 + device_mode, target_mode, &mode);
17902 + return do_set_mapping(vxi, device, target,
17905 + return do_unset_mapping(vxi, device, target,
17910 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
17912 + struct vcmd_set_mapping_v0 vc_data;
17914 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17917 + return do_mapping(vxi, vc_data.device, vc_data.target,
17918 + vc_data.flags, 1);
17921 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
17923 + struct vcmd_set_mapping_v0 vc_data;
17925 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17928 + return do_mapping(vxi, vc_data.device, vc_data.target,
17929 + vc_data.flags, 0);
17933 +#ifdef CONFIG_COMPAT
17935 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
17937 + struct vcmd_set_mapping_v0_x32 vc_data;
17939 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17942 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17943 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
17946 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
17948 + struct vcmd_set_mapping_v0_x32 vc_data;
17950 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17953 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17954 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
17957 +#endif /* CONFIG_COMPAT */
17960 diff -NurpP --minimal linux-3.2.5/kernel/vserver/dlimit.c linux-3.2.5-vs2.3.2.6/kernel/vserver/dlimit.c
17961 --- linux-3.2.5/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
17962 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/dlimit.c 2011-12-05 19:33:02.000000000 +0100
17965 + * linux/kernel/vserver/dlimit.c
17967 + * Virtual Server: Context Disk Limits
17969 + * Copyright (C) 2004-2009 Herbert Pötzl
17971 + * V0.01 initial version
17972 + * V0.02 compat32 splitup
17973 + * V0.03 extended interface
17977 +#include <linux/statfs.h>
17978 +#include <linux/sched.h>
17979 +#include <linux/namei.h>
17980 +#include <linux/vs_tag.h>
17981 +#include <linux/vs_dlimit.h>
17982 +#include <linux/vserver/dlimit_cmd.h>
17983 +#include <linux/slab.h>
17984 +// #include <linux/gfp.h>
17986 +#include <asm/uaccess.h>
17988 +/* __alloc_dl_info()
17990 + * allocate an initialized dl_info struct
17991 + * doesn't make it visible (hash) */
17993 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
17995 + struct dl_info *new = NULL;
17997 + vxdprintk(VXD_CBIT(dlim, 5),
17998 + "alloc_dl_info(%p,%d)*", sb, tag);
18000 + /* would this benefit from a slab cache? */
18001 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18005 + memset(new, 0, sizeof(struct dl_info));
18006 + new->dl_tag = tag;
18008 + // INIT_RCU_HEAD(&new->dl_rcu);
18009 + INIT_HLIST_NODE(&new->dl_hlist);
18010 + spin_lock_init(&new->dl_lock);
18011 + atomic_set(&new->dl_refcnt, 0);
18012 + atomic_set(&new->dl_usecnt, 0);
18014 + /* rest of init goes here */
18016 + vxdprintk(VXD_CBIT(dlim, 4),
18017 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18021 +/* __dealloc_dl_info()
18023 + * final disposal of dl_info */
18025 +static void __dealloc_dl_info(struct dl_info *dli)
18027 + vxdprintk(VXD_CBIT(dlim, 4),
18028 + "dealloc_dl_info(%p)", dli);
18030 + dli->dl_hlist.next = LIST_POISON1;
18031 + dli->dl_tag = -1;
18034 + BUG_ON(atomic_read(&dli->dl_usecnt));
18035 + BUG_ON(atomic_read(&dli->dl_refcnt));
18041 +/* hash table for dl_info hash */
18043 +#define DL_HASH_SIZE 13
18045 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18047 +static DEFINE_SPINLOCK(dl_info_hash_lock);
18050 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18052 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18057 +/* __hash_dl_info()
18059 + * add the dli to the global hash table
18060 + * requires the hash_lock to be held */
18062 +static inline void __hash_dl_info(struct dl_info *dli)
18064 + struct hlist_head *head;
18066 + vxdprintk(VXD_CBIT(dlim, 6),
18067 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18068 + get_dl_info(dli);
18069 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18070 + hlist_add_head_rcu(&dli->dl_hlist, head);
18073 +/* __unhash_dl_info()
18075 + * remove the dli from the global hash table
18076 + * requires the hash_lock to be held */
18078 +static inline void __unhash_dl_info(struct dl_info *dli)
18080 + vxdprintk(VXD_CBIT(dlim, 6),
18081 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18082 + hlist_del_rcu(&dli->dl_hlist);
18083 + put_dl_info(dli);
18087 +/* __lookup_dl_info()
18089 + * requires the rcu_read_lock()
18090 + * doesn't increment the dl_refcnt */
18092 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18094 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18095 + struct hlist_node *pos;
18096 + struct dl_info *dli;
18098 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18100 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18108 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18110 + struct dl_info *dli;
18113 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18114 + vxdprintk(VXD_CBIT(dlim, 7),
18115 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18116 + rcu_read_unlock();
18120 +void rcu_free_dl_info(struct rcu_head *head)
18122 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18123 + int usecnt, refcnt;
18125 + BUG_ON(!dli || !head);
18127 + usecnt = atomic_read(&dli->dl_usecnt);
18128 + BUG_ON(usecnt < 0);
18130 + refcnt = atomic_read(&dli->dl_refcnt);
18131 + BUG_ON(refcnt < 0);
18133 + vxdprintk(VXD_CBIT(dlim, 3),
18134 + "rcu_free_dl_info(%p)", dli);
18136 + __dealloc_dl_info(dli);
18138 + printk("!!! rcu didn't free\n");
18144 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18145 + uint32_t flags, int add)
18147 + struct path path;
18150 + ret = user_lpath(name, &path);
18152 + struct super_block *sb;
18153 + struct dl_info *dli;
18156 + if (!path.dentry->d_inode)
18157 + goto out_release;
18158 + if (!(sb = path.dentry->d_inode->i_sb))
18159 + goto out_release;
18162 + dli = __alloc_dl_info(sb, id);
18163 + spin_lock(&dl_info_hash_lock);
18166 + if (__lookup_dl_info(sb, id))
18168 + __hash_dl_info(dli);
18171 + spin_lock(&dl_info_hash_lock);
18172 + dli = __lookup_dl_info(sb, id);
18177 + __unhash_dl_info(dli);
18181 + spin_unlock(&dl_info_hash_lock);
18183 + __dealloc_dl_info(dli);
18190 +int vc_add_dlimit(uint32_t id, void __user *data)
18192 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18194 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18197 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18200 +int vc_rem_dlimit(uint32_t id, void __user *data)
18202 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18204 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18207 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18210 +#ifdef CONFIG_COMPAT
18212 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18214 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18216 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18219 + return do_addrem_dlimit(id,
18220 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18223 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18225 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18227 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18230 + return do_addrem_dlimit(id,
18231 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18234 +#endif /* CONFIG_COMPAT */
18238 +int do_set_dlimit(uint32_t id, const char __user *name,
18239 + uint32_t space_used, uint32_t space_total,
18240 + uint32_t inodes_used, uint32_t inodes_total,
18241 + uint32_t reserved, uint32_t flags)
18243 + struct path path;
18246 + ret = user_lpath(name, &path);
18248 + struct super_block *sb;
18249 + struct dl_info *dli;
18252 + if (!path.dentry->d_inode)
18253 + goto out_release;
18254 + if (!(sb = path.dentry->d_inode->i_sb))
18255 + goto out_release;
18257 + /* sanity checks */
18258 + if ((reserved != CDLIM_KEEP &&
18259 + reserved > 100) ||
18260 + (inodes_used != CDLIM_KEEP &&
18261 + inodes_used > inodes_total) ||
18262 + (space_used != CDLIM_KEEP &&
18263 + space_used > space_total))
18264 + goto out_release;
18267 + dli = locate_dl_info(sb, id);
18269 + goto out_release;
18271 + spin_lock(&dli->dl_lock);
18273 + if (inodes_used != CDLIM_KEEP)
18274 + dli->dl_inodes_used = inodes_used;
18275 + if (inodes_total != CDLIM_KEEP)
18276 + dli->dl_inodes_total = inodes_total;
18277 + if (space_used != CDLIM_KEEP)
18278 + dli->dl_space_used = dlimit_space_32to64(
18279 + space_used, flags, DLIMS_USED);
18281 + if (space_total == CDLIM_INFINITY)
18282 + dli->dl_space_total = DLIM_INFINITY;
18283 + else if (space_total != CDLIM_KEEP)
18284 + dli->dl_space_total = dlimit_space_32to64(
18285 + space_total, flags, DLIMS_TOTAL);
18287 + if (reserved != CDLIM_KEEP)
18288 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18290 + spin_unlock(&dli->dl_lock);
18292 + put_dl_info(dli);
18301 +int vc_set_dlimit(uint32_t id, void __user *data)
18303 + struct vcmd_ctx_dlimit_v0 vc_data;
18305 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18308 + return do_set_dlimit(id, vc_data.name,
18309 + vc_data.space_used, vc_data.space_total,
18310 + vc_data.inodes_used, vc_data.inodes_total,
18311 + vc_data.reserved, vc_data.flags);
18314 +#ifdef CONFIG_COMPAT
18316 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18318 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18320 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18323 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18324 + vc_data.space_used, vc_data.space_total,
18325 + vc_data.inodes_used, vc_data.inodes_total,
18326 + vc_data.reserved, vc_data.flags);
18329 +#endif /* CONFIG_COMPAT */
18333 +int do_get_dlimit(uint32_t id, const char __user *name,
18334 + uint32_t *space_used, uint32_t *space_total,
18335 + uint32_t *inodes_used, uint32_t *inodes_total,
18336 + uint32_t *reserved, uint32_t *flags)
18338 + struct path path;
18341 + ret = user_lpath(name, &path);
18343 + struct super_block *sb;
18344 + struct dl_info *dli;
18347 + if (!path.dentry->d_inode)
18348 + goto out_release;
18349 + if (!(sb = path.dentry->d_inode->i_sb))
18350 + goto out_release;
18353 + dli = locate_dl_info(sb, id);
18355 + goto out_release;
18357 + spin_lock(&dli->dl_lock);
18358 + *inodes_used = dli->dl_inodes_used;
18359 + *inodes_total = dli->dl_inodes_total;
18361 + *space_used = dlimit_space_64to32(
18362 + dli->dl_space_used, flags, DLIMS_USED);
18364 + if (dli->dl_space_total == DLIM_INFINITY)
18365 + *space_total = CDLIM_INFINITY;
18367 + *space_total = dlimit_space_64to32(
18368 + dli->dl_space_total, flags, DLIMS_TOTAL);
18370 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18371 + spin_unlock(&dli->dl_lock);
18373 + put_dl_info(dli);
18384 +int vc_get_dlimit(uint32_t id, void __user *data)
18386 + struct vcmd_ctx_dlimit_v0 vc_data;
18389 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18392 + ret = do_get_dlimit(id, vc_data.name,
18393 + &vc_data.space_used, &vc_data.space_total,
18394 + &vc_data.inodes_used, &vc_data.inodes_total,
18395 + &vc_data.reserved, &vc_data.flags);
18399 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18404 +#ifdef CONFIG_COMPAT
18406 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18408 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18411 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18414 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18415 + &vc_data.space_used, &vc_data.space_total,
18416 + &vc_data.inodes_used, &vc_data.inodes_total,
18417 + &vc_data.reserved, &vc_data.flags);
18421 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18426 +#endif /* CONFIG_COMPAT */
18429 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18431 + struct dl_info *dli;
18432 + __u64 blimit, bfree, bavail;
18435 + dli = locate_dl_info(sb, dx_current_tag());
18439 + spin_lock(&dli->dl_lock);
18440 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18443 + /* reduce max inodes available to limit */
18444 + if (buf->f_files > dli->dl_inodes_total)
18445 + buf->f_files = dli->dl_inodes_total;
18447 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18448 + /* reduce free inodes to min */
18449 + if (ifree < buf->f_ffree)
18450 + buf->f_ffree = ifree;
18453 + if (dli->dl_space_total == DLIM_INFINITY)
18456 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18458 + if (dli->dl_space_total < dli->dl_space_used)
18461 + bfree = (dli->dl_space_total - dli->dl_space_used)
18462 + >> sb->s_blocksize_bits;
18464 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18465 + if (bavail < dli->dl_space_used)
18468 + bavail = (bavail - dli->dl_space_used)
18469 + >> sb->s_blocksize_bits;
18471 + /* reduce max space available to limit */
18472 + if (buf->f_blocks > blimit)
18473 + buf->f_blocks = blimit;
18475 + /* reduce free space to min */
18476 + if (bfree < buf->f_bfree)
18477 + buf->f_bfree = bfree;
18479 + /* reduce avail space to min */
18480 + if (bavail < buf->f_bavail)
18481 + buf->f_bavail = bavail;
18484 + spin_unlock(&dli->dl_lock);
18485 + put_dl_info(dli);
18490 +#include <linux/module.h>
18492 +EXPORT_SYMBOL_GPL(locate_dl_info);
18493 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18495 diff -NurpP --minimal linux-3.2.5/kernel/vserver/helper.c linux-3.2.5-vs2.3.2.6/kernel/vserver/helper.c
18496 --- linux-3.2.5/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18497 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/helper.c 2011-12-05 19:33:02.000000000 +0100
18500 + * linux/kernel/vserver/helper.c
18502 + * Virtual Context Support
18504 + * Copyright (C) 2004-2007 Herbert Pötzl
18506 + * V0.01 basic helper
18510 +#include <linux/kmod.h>
18511 +#include <linux/reboot.h>
18512 +#include <linux/vs_context.h>
18513 +#include <linux/vs_network.h>
18514 +#include <linux/vserver/signal.h>
18517 +char vshelper_path[255] = "/sbin/vshelper";
18520 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18524 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
18525 + printk( KERN_WARNING
18526 + "%s: (%s %s) returned %s with %d\n",
18527 + name, argv[1], argv[2],
18528 + sync ? "sync" : "async", ret);
18530 + vxdprintk(VXD_CBIT(switch, 4),
18531 + "%s: (%s %s) returned %s with %d",
18532 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18537 + * vshelper path is set via /proc/sys
18538 + * invoked by vserver sys_reboot(), with
18539 + * the following arguments
18541 + * argv [0] = vshelper_path;
18542 + * argv [1] = action: "restart", "halt", "poweroff", ...
18543 + * argv [2] = context identifier
18545 + * envp [*] = type-specific parameters
18548 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18550 + char id_buf[8], cmd_buf[16];
18551 + char uid_buf[16], pid_buf[16];
18554 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18555 + char *envp[] = {"HOME=/", "TERM=linux",
18556 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18557 + uid_buf, pid_buf, cmd_buf, 0};
18559 + if (vx_info_state(vxi, VXS_HELPER))
18561 + vxi->vx_state |= VXS_HELPER;
18563 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18565 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18566 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
18567 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
18570 + case LINUX_REBOOT_CMD_RESTART:
18571 + argv[1] = "restart";
18574 + case LINUX_REBOOT_CMD_HALT:
18575 + argv[1] = "halt";
18578 + case LINUX_REBOOT_CMD_POWER_OFF:
18579 + argv[1] = "poweroff";
18582 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18583 + argv[1] = "swsusp";
18586 + case LINUX_REBOOT_CMD_OOM:
18591 + vxi->vx_state &= ~VXS_HELPER;
18595 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18596 + vxi->vx_state &= ~VXS_HELPER;
18597 + __wakeup_vx_info(vxi);
18598 + return (ret) ? -EPERM : 0;
18602 +long vs_reboot(unsigned int cmd, void __user *arg)
18604 + struct vx_info *vxi = current_vx_info();
18607 + vxdprintk(VXD_CBIT(misc, 5),
18608 + "vs_reboot(%p[#%d],%u)",
18609 + vxi, vxi ? vxi->vx_id : 0, cmd);
18611 + ret = vs_reboot_helper(vxi, cmd, arg);
18615 + vxi->reboot_cmd = cmd;
18616 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18618 + case LINUX_REBOOT_CMD_RESTART:
18619 + case LINUX_REBOOT_CMD_HALT:
18620 + case LINUX_REBOOT_CMD_POWER_OFF:
18621 + vx_info_kill(vxi, 0, SIGKILL);
18622 + vx_info_kill(vxi, 1, SIGKILL);
18630 +long vs_oom_action(unsigned int cmd)
18632 + struct vx_info *vxi = current_vx_info();
18635 + vxdprintk(VXD_CBIT(misc, 5),
18636 + "vs_oom_action(%p[#%d],%u)",
18637 + vxi, vxi ? vxi->vx_id : 0, cmd);
18639 + ret = vs_reboot_helper(vxi, cmd, NULL);
18643 + vxi->reboot_cmd = cmd;
18644 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18645 + vx_info_kill(vxi, 0, SIGKILL);
18646 + vx_info_kill(vxi, 1, SIGKILL);
18652 + * argv [0] = vshelper_path;
18653 + * argv [1] = action: "startup", "shutdown"
18654 + * argv [2] = context identifier
18656 + * envp [*] = type-specific parameters
18659 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18661 + char id_buf[8], cmd_buf[16];
18662 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18663 + char *envp[] = {"HOME=/", "TERM=linux",
18664 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18666 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18669 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18670 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18673 + case VSC_STARTUP:
18674 + argv[1] = "startup";
18676 + case VSC_SHUTDOWN:
18677 + argv[1] = "shutdown";
18683 + return do_vshelper(vshelper_path, argv, envp, 1);
18688 + * argv [0] = vshelper_path;
18689 + * argv [1] = action: "netup", "netdown"
18690 + * argv [2] = context identifier
18692 + * envp [*] = type-specific parameters
18695 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18697 + char id_buf[8], cmd_buf[16];
18698 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18699 + char *envp[] = {"HOME=/", "TERM=linux",
18700 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18702 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18705 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
18706 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18710 + argv[1] = "netup";
18712 + case VSC_NETDOWN:
18713 + argv[1] = "netdown";
18719 + return do_vshelper(vshelper_path, argv, envp, 1);
18722 diff -NurpP --minimal linux-3.2.5/kernel/vserver/history.c linux-3.2.5-vs2.3.2.6/kernel/vserver/history.c
18723 --- linux-3.2.5/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
18724 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/history.c 2011-12-05 19:33:02.000000000 +0100
18727 + * kernel/vserver/history.c
18729 + * Virtual Context History Backtrace
18731 + * Copyright (C) 2004-2007 Herbert Pötzl
18733 + * V0.01 basic structure
18734 + * V0.02 hash/unhash and trace
18735 + * V0.03 preemption fixes
18739 +#include <linux/module.h>
18740 +#include <asm/uaccess.h>
18742 +#include <linux/vserver/context.h>
18743 +#include <linux/vserver/debug.h>
18744 +#include <linux/vserver/debug_cmd.h>
18745 +#include <linux/vserver/history.h>
18748 +#ifdef CONFIG_VSERVER_HISTORY
18749 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18751 +#define VXH_SIZE 64
18754 +struct _vx_history {
18755 + unsigned int counter;
18757 + struct _vx_hist_entry entry[VXH_SIZE + 1];
18761 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
18763 +unsigned volatile int vxh_active = 1;
18765 +static atomic_t sequence = ATOMIC_INIT(0);
18770 + * requires disabled preemption */
18772 +struct _vx_hist_entry *vxh_advance(void *loc)
18774 + unsigned int cpu = smp_processor_id();
18775 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18776 + struct _vx_hist_entry *entry;
18777 + unsigned int index;
18779 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
18780 + entry = &hist->entry[index];
18782 + entry->seq = atomic_inc_return(&sequence);
18783 + entry->loc = loc;
18787 +EXPORT_SYMBOL_GPL(vxh_advance);
18790 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
18792 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
18795 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
18797 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
18798 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
18799 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
18800 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
18802 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
18804 + switch (e->type) {
18805 + case VXH_THROW_OOPS:
18806 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
18809 + case VXH_GET_VX_INFO:
18810 + case VXH_PUT_VX_INFO:
18811 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18813 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
18814 + VXH_VXI_ARGS(e));
18817 + case VXH_INIT_VX_INFO:
18818 + case VXH_SET_VX_INFO:
18819 + case VXH_CLR_VX_INFO:
18820 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18822 + (e->type == VXH_INIT_VX_INFO) ? "init" :
18823 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
18824 + VXH_VXI_ARGS(e), e->sc.data);
18827 + case VXH_CLAIM_VX_INFO:
18828 + case VXH_RELEASE_VX_INFO:
18829 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18831 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
18832 + VXH_VXI_ARGS(e), e->sc.data);
18835 + case VXH_ALLOC_VX_INFO:
18836 + case VXH_DEALLOC_VX_INFO:
18837 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18839 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
18840 + VXH_VXI_ARGS(e));
18843 + case VXH_HASH_VX_INFO:
18844 + case VXH_UNHASH_VX_INFO:
18845 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
18847 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
18848 + VXH_VXI_ARGS(e));
18851 + case VXH_LOC_VX_INFO:
18852 + case VXH_LOOKUP_VX_INFO:
18853 + case VXH_CREATE_VX_INFO:
18854 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
18856 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
18857 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
18858 + e->ll.arg, VXH_VXI_ARGS(e));
18863 +static void __vxh_dump_history(void)
18865 + unsigned int i, cpu;
18867 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
18868 + atomic_read(&sequence), NR_CPUS);
18870 + for (i = 0; i < VXH_SIZE; i++) {
18871 + for_each_online_cpu(cpu) {
18872 + struct _vx_history *hist =
18873 + &per_cpu(vx_history_buffer, cpu);
18874 + unsigned int index = (hist->counter - i) % VXH_SIZE;
18875 + struct _vx_hist_entry *entry = &hist->entry[index];
18877 + vxh_dump_entry(entry, cpu);
18882 +void vxh_dump_history(void)
18886 + local_irq_enable();
18888 + local_irq_disable();
18890 + __vxh_dump_history();
18894 +/* vserver syscall commands below here */
18897 +int vc_dump_history(uint32_t id)
18900 + __vxh_dump_history();
18907 +int do_read_history(struct __user _vx_hist_entry *data,
18908 + int cpu, uint32_t *index, uint32_t *count)
18910 + int pos, ret = 0;
18911 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18912 + int end = hist->counter;
18913 + int start = end - VXH_SIZE + 2;
18914 + int idx = *index;
18916 + /* special case: get current pos */
18922 + /* have we lost some data? */
18926 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
18927 + struct _vx_hist_entry *entry =
18928 + &hist->entry[idx % VXH_SIZE];
18930 + /* send entry to userspace */
18931 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
18935 + /* save new index and count */
18938 + return ret ? ret : (*index < end);
18941 +int vc_read_history(uint32_t id, void __user *data)
18943 + struct vcmd_read_history_v0 vc_data;
18946 + if (id >= NR_CPUS)
18949 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18952 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
18953 + id, &vc_data.index, &vc_data.count);
18955 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18960 +#ifdef CONFIG_COMPAT
18962 +int vc_read_history_x32(uint32_t id, void __user *data)
18964 + struct vcmd_read_history_v0_x32 vc_data;
18967 + if (id >= NR_CPUS)
18970 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18973 + ret = do_read_history((struct __user _vx_hist_entry *)
18974 + compat_ptr(vc_data.data_ptr),
18975 + id, &vc_data.index, &vc_data.count);
18977 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18982 +#endif /* CONFIG_COMPAT */
18984 diff -NurpP --minimal linux-3.2.5/kernel/vserver/inet.c linux-3.2.5-vs2.3.2.6/kernel/vserver/inet.c
18985 --- linux-3.2.5/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
18986 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/inet.c 2011-12-15 01:33:09.000000000 +0100
18989 +#include <linux/in.h>
18990 +#include <linux/inetdevice.h>
18991 +#include <linux/export.h>
18992 +#include <linux/vs_inet.h>
18993 +#include <linux/vs_inet6.h>
18994 +#include <linux/vserver/debug.h>
18995 +#include <net/route.h>
18996 +#include <net/addrconf.h>
18999 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19003 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19006 + struct nx_addr_v4 *ptr;
19008 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19009 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19016 + vxdprintk(VXD_CBIT(net, 2),
19017 + "nx_v4_addr_conflict(%p,%p): %d",
19018 + nxi1, nxi2, ret);
19024 +#ifdef CONFIG_IPV6
19026 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19030 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19033 + struct nx_addr_v6 *ptr;
19035 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19036 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19043 + vxdprintk(VXD_CBIT(net, 2),
19044 + "nx_v6_addr_conflict(%p,%p): %d",
19045 + nxi1, nxi2, ret);
19052 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19054 + struct in_device *in_dev;
19055 + struct in_ifaddr **ifap;
19056 + struct in_ifaddr *ifa;
19061 + in_dev = in_dev_get(dev);
19065 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19066 + ifap = &ifa->ifa_next) {
19067 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19072 + in_dev_put(in_dev);
19078 +#ifdef CONFIG_IPV6
19080 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19082 + struct inet6_dev *in_dev;
19083 + struct inet6_ifaddr *ifa;
19088 + in_dev = in6_dev_get(dev);
19092 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19093 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19094 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19099 + in6_dev_put(in_dev);
19106 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19112 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19114 +#ifdef CONFIG_IPV6
19116 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19121 + vxdprintk(VXD_CBIT(net, 3),
19122 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19123 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19127 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
19128 + struct flowi4 *fl4)
19130 + struct rtable *rt;
19135 + /* FIXME: handle lback only case */
19136 + if (!NX_IPV4(nxi))
19137 + return ERR_PTR(-EPERM);
19139 + vxdprintk(VXD_CBIT(net, 4),
19140 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19141 + nxi, nxi ? nxi->nx_id : 0,
19142 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
19144 + /* single IP is unconditional */
19145 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19146 + (fl4->saddr == INADDR_ANY))
19147 + fl4->saddr = nxi->v4.ip[0].s_addr;
19149 + if (fl4->saddr == INADDR_ANY) {
19150 + struct nx_addr_v4 *ptr;
19151 + __be32 found = 0;
19153 + rt = __ip_route_output_key(net, fl4);
19154 + if (!IS_ERR(rt)) {
19155 + found = fl4->saddr;
19157 + vxdprintk(VXD_CBIT(net, 4),
19158 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19159 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
19160 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19164 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19165 + __be32 primary = ptr->ip[0].s_addr;
19166 + __be32 mask = ptr->mask.s_addr;
19167 + __be32 neta = primary & mask;
19169 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19170 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19171 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19172 + NIPQUAD(mask), NIPQUAD(neta));
19173 + if ((found & mask) != neta)
19176 + fl4->saddr = primary;
19177 + rt = __ip_route_output_key(net, fl4);
19178 + vxdprintk(VXD_CBIT(net, 4),
19179 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19180 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
19181 + if (!IS_ERR(rt)) {
19182 + found = fl4->saddr;
19184 + if (found == primary)
19188 + /* still no source ip? */
19189 + found = ipv4_is_loopback(fl4->daddr)
19190 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19192 + /* assign src ip to flow */
19193 + fl4->saddr = found;
19196 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
19197 + return ERR_PTR(-EPERM);
19200 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19201 + if (ipv4_is_loopback(fl4->daddr))
19202 + fl4->daddr = nxi->v4_lback.s_addr;
19203 + if (ipv4_is_loopback(fl4->saddr))
19204 + fl4->saddr = nxi->v4_lback.s_addr;
19205 + } else if (ipv4_is_loopback(fl4->daddr) &&
19206 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19207 + return ERR_PTR(-EPERM);
19212 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19214 diff -NurpP --minimal linux-3.2.5/kernel/vserver/init.c linux-3.2.5-vs2.3.2.6/kernel/vserver/init.c
19215 --- linux-3.2.5/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19216 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/init.c 2011-12-05 19:33:02.000000000 +0100
19219 + * linux/kernel/init.c
19221 + * Virtual Server Init
19223 + * Copyright (C) 2004-2007 Herbert Pötzl
19225 + * V0.01 basic structure
19229 +#include <linux/init.h>
19231 +int vserver_register_sysctl(void);
19232 +void vserver_unregister_sysctl(void);
19235 +static int __init init_vserver(void)
19239 +#ifdef CONFIG_VSERVER_DEBUG
19240 + vserver_register_sysctl();
19246 +static void __exit exit_vserver(void)
19249 +#ifdef CONFIG_VSERVER_DEBUG
19250 + vserver_unregister_sysctl();
19255 +/* FIXME: GFP_ZONETYPES gone
19256 +long vx_slab[GFP_ZONETYPES]; */
19260 +module_init(init_vserver);
19261 +module_exit(exit_vserver);
19263 diff -NurpP --minimal linux-3.2.5/kernel/vserver/inode.c linux-3.2.5-vs2.3.2.6/kernel/vserver/inode.c
19264 --- linux-3.2.5/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19265 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/inode.c 2011-12-06 23:56:11.000000000 +0100
19268 + * linux/kernel/vserver/inode.c
19270 + * Virtual Server: File System Support
19272 + * Copyright (C) 2004-2007 Herbert Pötzl
19274 + * V0.01 separated from vcontext V0.05
19275 + * V0.02 moved to tag (instead of xid)
19279 +#include <linux/tty.h>
19280 +#include <linux/proc_fs.h>
19281 +#include <linux/devpts_fs.h>
19282 +#include <linux/fs.h>
19283 +#include <linux/file.h>
19284 +#include <linux/mount.h>
19285 +#include <linux/parser.h>
19286 +#include <linux/namei.h>
19287 +#include <linux/vserver/inode.h>
19288 +#include <linux/vserver/inode_cmd.h>
19289 +#include <linux/vs_base.h>
19290 +#include <linux/vs_tag.h>
19292 +#include <asm/uaccess.h>
19295 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19297 + struct proc_dir_entry *entry;
19299 + if (!in || !in->i_sb)
19302 + *flags = IATTR_TAG
19303 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19304 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19305 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19306 + | (IS_COW(in) ? IATTR_COW : 0);
19307 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19309 + if (S_ISDIR(in->i_mode))
19310 + *mask |= IATTR_BARRIER;
19312 + if (IS_TAGGED(in)) {
19313 + *tag = in->i_tag;
19314 + *mask |= IATTR_TAG;
19317 + switch (in->i_sb->s_magic) {
19318 + case PROC_SUPER_MAGIC:
19319 + entry = PROC_I(in)->pde;
19321 + /* check for specific inodes? */
19323 + *mask |= IATTR_FLAGS;
19325 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19327 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19330 + case DEVPTS_SUPER_MAGIC:
19331 + *tag = in->i_tag;
19332 + *mask |= IATTR_TAG;
19341 +int vc_get_iattr(void __user *data)
19343 + struct path path;
19344 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19347 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19350 + ret = user_lpath(vc_data.name, &path);
19352 + ret = __vc_get_iattr(path.dentry->d_inode,
19353 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19359 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19364 +#ifdef CONFIG_COMPAT
19366 +int vc_get_iattr_x32(void __user *data)
19368 + struct path path;
19369 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19372 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19375 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19377 + ret = __vc_get_iattr(path.dentry->d_inode,
19378 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19384 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19389 +#endif /* CONFIG_COMPAT */
19392 +int vc_fget_iattr(uint32_t fd, void __user *data)
19394 + struct file *filp;
19395 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19398 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19402 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19405 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19406 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19410 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19416 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19418 + struct inode *in = de->d_inode;
19419 + int error = 0, is_proc = 0, has_tag = 0;
19420 + struct iattr attr = { 0 };
19422 + if (!in || !in->i_sb)
19425 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19426 + if ((*mask & IATTR_FLAGS) && !is_proc)
19429 + has_tag = IS_TAGGED(in) ||
19430 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19431 + if ((*mask & IATTR_TAG) && !has_tag)
19434 + mutex_lock(&in->i_mutex);
19435 + if (*mask & IATTR_TAG) {
19436 + attr.ia_tag = *tag;
19437 + attr.ia_valid |= ATTR_TAG;
19440 + if (*mask & IATTR_FLAGS) {
19441 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19442 + unsigned int iflags = PROC_I(in)->vx_flags;
19444 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19445 + | (*flags & IATTR_FLAGS);
19446 + PROC_I(in)->vx_flags = iflags;
19448 + entry->vx_flags = iflags;
19451 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19452 + IATTR_BARRIER | IATTR_COW)) {
19453 + int iflags = in->i_flags;
19454 + int vflags = in->i_vflags;
19456 + if (*mask & IATTR_IMMUTABLE) {
19457 + if (*flags & IATTR_IMMUTABLE)
19458 + iflags |= S_IMMUTABLE;
19460 + iflags &= ~S_IMMUTABLE;
19462 + if (*mask & IATTR_IXUNLINK) {
19463 + if (*flags & IATTR_IXUNLINK)
19464 + iflags |= S_IXUNLINK;
19466 + iflags &= ~S_IXUNLINK;
19468 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19469 + if (*flags & IATTR_BARRIER)
19470 + vflags |= V_BARRIER;
19472 + vflags &= ~V_BARRIER;
19474 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19475 + if (*flags & IATTR_COW)
19478 + vflags &= ~V_COW;
19480 + if (in->i_op && in->i_op->sync_flags) {
19481 + error = in->i_op->sync_flags(in, iflags, vflags);
19487 + if (attr.ia_valid) {
19488 + if (in->i_op && in->i_op->setattr)
19489 + error = in->i_op->setattr(de, &attr);
19491 + error = inode_change_ok(in, &attr);
19493 + setattr_copy(in, &attr);
19494 + mark_inode_dirty(in);
19500 + mutex_unlock(&in->i_mutex);
19504 +int vc_set_iattr(void __user *data)
19506 + struct path path;
19507 + struct vcmd_ctx_iattr_v1 vc_data;
19510 + if (!capable(CAP_LINUX_IMMUTABLE))
19512 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19515 + ret = user_lpath(vc_data.name, &path);
19517 + ret = __vc_set_iattr(path.dentry,
19518 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19522 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19527 +#ifdef CONFIG_COMPAT
19529 +int vc_set_iattr_x32(void __user *data)
19531 + struct path path;
19532 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19535 + if (!capable(CAP_LINUX_IMMUTABLE))
19537 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19540 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19542 + ret = __vc_set_iattr(path.dentry,
19543 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19547 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19552 +#endif /* CONFIG_COMPAT */
19554 +int vc_fset_iattr(uint32_t fd, void __user *data)
19556 + struct file *filp;
19557 + struct vcmd_ctx_fiattr_v0 vc_data;
19560 + if (!capable(CAP_LINUX_IMMUTABLE))
19562 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19566 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19569 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19570 + &vc_data.flags, &vc_data.mask);
19574 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19580 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19582 +static match_table_t tokens = {
19583 + {Opt_notagcheck, "notagcheck"},
19584 +#ifdef CONFIG_PROPAGATE
19585 + {Opt_notag, "notag"},
19586 + {Opt_tag, "tag"},
19587 + {Opt_tagid, "tagid=%u"},
19593 +static void __dx_parse_remove(char *string, char *opt)
19595 + char *p = strstr(string, opt);
19599 + while (*q != '\0' && *q != ',')
19608 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19609 + unsigned long *flags)
19612 + substring_t args[MAX_OPT_ARGS];
19614 + char *s, *p, *opts;
19615 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19621 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19626 + while ((p = strsep(&opts, ",")) != NULL) {
19627 + token = match_token(p, tokens, args);
19630 +#ifdef CONFIG_PROPAGATE
19635 + __dx_parse_remove(s, "tag");
19636 + *mnt_flags |= MNT_TAGID;
19637 + set |= MNT_TAGID;
19641 + __dx_parse_remove(s, "notag");
19642 + *mnt_flags |= MNT_NOTAG;
19643 + set |= MNT_NOTAG;
19646 + if (tag && !match_int(args, &option))
19649 + __dx_parse_remove(s, "tagid");
19650 + *mnt_flags |= MNT_TAGID;
19651 + set |= MNT_TAGID;
19653 +#endif /* CONFIG_PROPAGATE */
19654 + case Opt_notagcheck:
19656 + __dx_parse_remove(s, "notagcheck");
19657 + *flags |= MS_NOTAGCHECK;
19658 + set |= MS_NOTAGCHECK;
19661 + vxdprintk(VXD_CBIT(tag, 7),
19662 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19663 + p, token, option);
19666 + strcpy(string, s);
19671 +#ifdef CONFIG_PROPAGATE
19673 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19675 + tag_t new_tag = 0;
19676 + struct vfsmount *mnt;
19681 + mnt = nd->path.mnt;
19685 + propagate = (mnt->mnt_flags & MNT_TAGID);
19687 + new_tag = mnt->mnt_tag;
19689 + vxdprintk(VXD_CBIT(tag, 7),
19690 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19691 + inode, inode->i_ino, inode->i_tag,
19692 + new_tag, (propagate) ? 1 : 0);
19695 + inode->i_tag = new_tag;
19698 +#include <linux/module.h>
19700 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19702 +#endif /* CONFIG_PROPAGATE */
19704 diff -NurpP --minimal linux-3.2.5/kernel/vserver/limit.c linux-3.2.5-vs2.3.2.6/kernel/vserver/limit.c
19705 --- linux-3.2.5/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
19706 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/limit.c 2011-12-15 01:52:48.000000000 +0100
19709 + * linux/kernel/vserver/limit.c
19711 + * Virtual Server: Context Limits
19713 + * Copyright (C) 2004-2010 Herbert Pötzl
19715 + * V0.01 broken out from vcontext V0.05
19716 + * V0.02 changed vcmds to vxi arg
19717 + * V0.03 added memory cgroup support
19721 +#include <linux/sched.h>
19722 +#include <linux/module.h>
19723 +#include <linux/memcontrol.h>
19724 +#include <linux/res_counter.h>
19725 +#include <linux/vs_limit.h>
19726 +#include <linux/vserver/limit.h>
19727 +#include <linux/vserver/limit_cmd.h>
19729 +#include <asm/uaccess.h>
19732 +const char *vlimit_name[NUM_LIMITS] = {
19733 + [RLIMIT_CPU] = "CPU",
19734 + [RLIMIT_NPROC] = "NPROC",
19735 + [RLIMIT_NOFILE] = "NOFILE",
19736 + [RLIMIT_LOCKS] = "LOCKS",
19737 + [RLIMIT_SIGPENDING] = "SIGP",
19738 + [RLIMIT_MSGQUEUE] = "MSGQ",
19740 + [VLIMIT_NSOCK] = "NSOCK",
19741 + [VLIMIT_OPENFD] = "OPENFD",
19742 + [VLIMIT_SHMEM] = "SHMEM",
19743 + [VLIMIT_DENTRY] = "DENTRY",
19746 +EXPORT_SYMBOL_GPL(vlimit_name);
19748 +#define MASK_ENTRY(x) (1 << (x))
19750 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
19753 + , /* softlimit */
19756 + MASK_ENTRY( RLIMIT_NPROC ) |
19757 + MASK_ENTRY( RLIMIT_NOFILE ) |
19758 + MASK_ENTRY( RLIMIT_LOCKS ) |
19759 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
19761 + MASK_ENTRY( VLIMIT_NSOCK ) |
19762 + MASK_ENTRY( VLIMIT_OPENFD ) |
19763 + MASK_ENTRY( VLIMIT_SHMEM ) |
19764 + MASK_ENTRY( VLIMIT_DENTRY ) |
19767 + /* accounting only */
19768 +uint32_t account_mask =
19769 + MASK_ENTRY( VLIMIT_SEMARY ) |
19770 + MASK_ENTRY( VLIMIT_NSEMS ) |
19771 + MASK_ENTRY( VLIMIT_MAPPED ) |
19775 +static int is_valid_vlimit(int id)
19777 + uint32_t mask = vlimit_mask.minimum |
19778 + vlimit_mask.softlimit | vlimit_mask.maximum;
19779 + return mask & (1 << id);
19782 +static int is_accounted_vlimit(int id)
19784 + if (is_valid_vlimit(id))
19786 + return account_mask & (1 << id);
19790 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
19792 + rlim_t limit = __rlim_soft(&vxi->limit, id);
19793 + return VX_VLIM(limit);
19796 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
19798 + rlim_t limit = __rlim_hard(&vxi->limit, id);
19799 + return VX_VLIM(limit);
19802 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
19803 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
19805 + if (!is_valid_vlimit(id))
19809 + *minimum = CRLIM_UNSET;
19811 + *softlimit = vc_get_soft(vxi, id);
19813 + *maximum = vc_get_hard(vxi, id);
19817 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
19819 + struct vcmd_ctx_rlimit_v0 vc_data;
19822 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19825 + ret = do_get_rlimit(vxi, vc_data.id,
19826 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19830 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19835 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
19836 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
19838 + if (!is_valid_vlimit(id))
19841 + if (maximum != CRLIM_KEEP)
19842 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
19843 + if (softlimit != CRLIM_KEEP)
19844 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
19846 + /* clamp soft limit */
19847 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
19848 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
19853 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
19855 + struct vcmd_ctx_rlimit_v0 vc_data;
19857 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19860 + return do_set_rlimit(vxi, vc_data.id,
19861 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19864 +#ifdef CONFIG_IA32_EMULATION
19866 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
19868 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19870 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19873 + return do_set_rlimit(vxi, vc_data.id,
19874 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19877 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
19879 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19882 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19885 + ret = do_get_rlimit(vxi, vc_data.id,
19886 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19890 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19895 +#endif /* CONFIG_IA32_EMULATION */
19898 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
19900 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
19906 +static inline void vx_reset_hits(struct _vx_limit *limit)
19910 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19911 + atomic_set(&__rlim_lhit(limit, lim), 0);
19915 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
19917 + vx_reset_hits(&vxi->limit);
19921 +static inline void vx_reset_minmax(struct _vx_limit *limit)
19926 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19927 + value = __rlim_get(limit, lim);
19928 + __rlim_rmax(limit, lim) = value;
19929 + __rlim_rmin(limit, lim) = value;
19933 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
19935 + vx_reset_minmax(&vxi->limit);
19940 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
19942 + struct vcmd_rlimit_stat_v0 vc_data;
19943 + struct _vx_limit *limit = &vxi->limit;
19946 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19950 + if (!is_accounted_vlimit(id))
19953 + vx_limit_fixup(limit, id);
19954 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
19955 + vc_data.value = __rlim_get(limit, id);
19956 + vc_data.minimum = __rlim_rmin(limit, id);
19957 + vc_data.maximum = __rlim_rmax(limit, id);
19959 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19965 +void vx_vsi_meminfo(struct sysinfo *val)
19967 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19968 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
19969 + u64 res_limit, res_usage;
19974 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19975 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19977 + if (res_limit != RESOURCE_MAX)
19978 + val->totalram = (res_limit >> PAGE_SHIFT);
19979 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
19980 + val->bufferram = 0;
19981 + val->totalhigh = 0;
19982 + val->freehigh = 0;
19983 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
19987 +void vx_vsi_swapinfo(struct sysinfo *val)
19989 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19990 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
19991 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
19992 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
19993 + s64 swap_limit, swap_usage;
19998 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19999 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20000 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20001 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20003 + /* memory unlimited */
20004 + if (res_limit == RESOURCE_MAX)
20007 + swap_limit = memsw_limit - res_limit;
20008 + /* we have a swap limit? */
20009 + if (memsw_limit != RESOURCE_MAX)
20010 + val->totalswap = swap_limit >> PAGE_SHIFT;
20012 + /* calculate swap part */
20013 + swap_usage = (memsw_usage > res_usage) ?
20014 + memsw_usage - res_usage : 0;
20016 + /* total shown minus usage gives free swap */
20017 + val->freeswap = (swap_usage < swap_limit) ?
20018 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20019 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20020 + val->totalswap = 0;
20021 + val->freeswap = 0;
20022 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20023 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20027 +long vx_vsi_cached(struct sysinfo *val)
20029 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20030 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20032 + return mem_cgroup_stat_read_cache(mcg);
20038 diff -NurpP --minimal linux-3.2.5/kernel/vserver/limit_init.h linux-3.2.5-vs2.3.2.6/kernel/vserver/limit_init.h
20039 --- linux-3.2.5/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20040 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/limit_init.h 2011-12-05 19:33:02.000000000 +0100
20044 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20048 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20049 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20050 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20051 + __rlim_set(limit, lim, 0);
20052 + atomic_set(&__rlim_lhit(limit, lim), 0);
20053 + __rlim_rmin(limit, lim) = 0;
20054 + __rlim_rmax(limit, lim) = 0;
20058 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20063 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20064 + if ((1 << lim) & VLIM_NOCHECK)
20066 + value = __rlim_get(limit, lim);
20067 + vxwprintk_xid(value,
20068 + "!!! limit: %p[%s,%d] = %ld on exit.",
20069 + limit, vlimit_name[lim], lim, (long)value);
20073 diff -NurpP --minimal linux-3.2.5/kernel/vserver/limit_proc.h linux-3.2.5-vs2.3.2.6/kernel/vserver/limit_proc.h
20074 --- linux-3.2.5/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20075 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/limit_proc.h 2011-12-05 19:33:02.000000000 +0100
20077 +#ifndef _VX_LIMIT_PROC_H
20078 +#define _VX_LIMIT_PROC_H
20080 +#include <linux/vserver/limit_int.h>
20083 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20084 +#define VX_LIMIT_TOP \
20085 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20087 +#define VX_LIMIT_ARG(r) \
20088 + (unsigned long)__rlim_get(limit, r), \
20089 + (unsigned long)__rlim_rmin(limit, r), \
20090 + (unsigned long)__rlim_rmax(limit, r), \
20091 + VX_VLIM(__rlim_soft(limit, r)), \
20092 + VX_VLIM(__rlim_hard(limit, r)), \
20093 + atomic_read(&__rlim_lhit(limit, r))
20095 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20097 + vx_limit_fixup(limit, -1);
20098 + return sprintf(buffer, VX_LIMIT_TOP
20099 + "PROC" VX_LIMIT_FMT
20100 + "VM" VX_LIMIT_FMT
20101 + "VML" VX_LIMIT_FMT
20102 + "RSS" VX_LIMIT_FMT
20103 + "ANON" VX_LIMIT_FMT
20104 + "RMAP" VX_LIMIT_FMT
20105 + "FILES" VX_LIMIT_FMT
20106 + "OFD" VX_LIMIT_FMT
20107 + "LOCKS" VX_LIMIT_FMT
20108 + "SOCK" VX_LIMIT_FMT
20109 + "MSGQ" VX_LIMIT_FMT
20110 + "SHM" VX_LIMIT_FMT
20111 + "SEMA" VX_LIMIT_FMT
20112 + "SEMS" VX_LIMIT_FMT
20113 + "DENT" VX_LIMIT_FMT,
20114 + VX_LIMIT_ARG(RLIMIT_NPROC),
20115 + VX_LIMIT_ARG(RLIMIT_AS),
20116 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20117 + VX_LIMIT_ARG(RLIMIT_RSS),
20118 + VX_LIMIT_ARG(VLIMIT_ANON),
20119 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20120 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20121 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20122 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20123 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20124 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20125 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20126 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20127 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20128 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20131 +#endif /* _VX_LIMIT_PROC_H */
20134 diff -NurpP --minimal linux-3.2.5/kernel/vserver/network.c linux-3.2.5-vs2.3.2.6/kernel/vserver/network.c
20135 --- linux-3.2.5/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20136 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/network.c 2011-12-05 19:33:02.000000000 +0100
20139 + * linux/kernel/vserver/network.c
20141 + * Virtual Server: Network Support
20143 + * Copyright (C) 2003-2007 Herbert Pötzl
20145 + * V0.01 broken out from vcontext V0.05
20146 + * V0.02 cleaned up implementation
20147 + * V0.03 added equiv nx commands
20148 + * V0.04 switch to RCU based hash
20149 + * V0.05 and back to locking again
20150 + * V0.06 changed vcmds to nxi arg
20151 + * V0.07 have __create claim() the nxi
20155 +#include <linux/err.h>
20156 +#include <linux/slab.h>
20157 +#include <linux/rcupdate.h>
20159 +#include <linux/vs_network.h>
20160 +#include <linux/vs_pid.h>
20161 +#include <linux/vserver/network_cmd.h>
20164 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20165 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20167 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20168 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20171 +static int __init init_network(void)
20173 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20174 + sizeof(struct nx_addr_v4), 0,
20175 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20176 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20177 + sizeof(struct nx_addr_v6), 0,
20178 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20183 +/* __alloc_nx_addr_v4() */
20185 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20187 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20188 + nx_addr_v4_cachep, GFP_KERNEL);
20190 + if (!IS_ERR(nxa))
20191 + memset(nxa, 0, sizeof(*nxa));
20195 +/* __dealloc_nx_addr_v4() */
20197 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20199 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20202 +/* __dealloc_nx_addr_v4_all() */
20204 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20207 + struct nx_addr_v4 *next = nxa->next;
20209 + __dealloc_nx_addr_v4(nxa);
20215 +#ifdef CONFIG_IPV6
20217 +/* __alloc_nx_addr_v6() */
20219 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20221 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20222 + nx_addr_v6_cachep, GFP_KERNEL);
20224 + if (!IS_ERR(nxa))
20225 + memset(nxa, 0, sizeof(*nxa));
20229 +/* __dealloc_nx_addr_v6() */
20231 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20233 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20236 +/* __dealloc_nx_addr_v6_all() */
20238 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20241 + struct nx_addr_v6 *next = nxa->next;
20243 + __dealloc_nx_addr_v6(nxa);
20248 +#endif /* CONFIG_IPV6 */
20250 +/* __alloc_nx_info()
20252 + * allocate an initialized nx_info struct
20253 + * doesn't make it visible (hash) */
20255 +static struct nx_info *__alloc_nx_info(nid_t nid)
20257 + struct nx_info *new = NULL;
20259 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20261 + /* would this benefit from a slab cache? */
20262 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20266 + memset(new, 0, sizeof(struct nx_info));
20267 + new->nx_id = nid;
20268 + INIT_HLIST_NODE(&new->nx_hlist);
20269 + atomic_set(&new->nx_usecnt, 0);
20270 + atomic_set(&new->nx_tasks, 0);
20271 + new->nx_state = 0;
20273 + new->nx_flags = NXF_INIT_SET;
20275 + /* rest of init goes here */
20277 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20278 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20280 + vxdprintk(VXD_CBIT(nid, 0),
20281 + "alloc_nx_info(%d) = %p", nid, new);
20282 + atomic_inc(&nx_global_ctotal);
20286 +/* __dealloc_nx_info()
20288 + * final disposal of nx_info */
20290 +static void __dealloc_nx_info(struct nx_info *nxi)
20292 + vxdprintk(VXD_CBIT(nid, 0),
20293 + "dealloc_nx_info(%p)", nxi);
20295 + nxi->nx_hlist.next = LIST_POISON1;
20298 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20299 + BUG_ON(atomic_read(&nxi->nx_tasks));
20301 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20303 + nxi->nx_state |= NXS_RELEASED;
20305 + atomic_dec(&nx_global_ctotal);
20308 +static void __shutdown_nx_info(struct nx_info *nxi)
20310 + nxi->nx_state |= NXS_SHUTDOWN;
20311 + vs_net_change(nxi, VSC_NETDOWN);
20314 +/* exported stuff */
20316 +void free_nx_info(struct nx_info *nxi)
20318 + /* context shutdown is mandatory */
20319 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20321 + /* context must not be hashed */
20322 + BUG_ON(nxi->nx_state & NXS_HASHED);
20324 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20325 + BUG_ON(atomic_read(&nxi->nx_tasks));
20327 + __dealloc_nx_info(nxi);
20331 +void __nx_set_lback(struct nx_info *nxi)
20333 + int nid = nxi->nx_id;
20334 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20336 + nxi->v4_lback.s_addr = lback;
20339 +extern int __nx_inet_add_lback(__be32 addr);
20340 +extern int __nx_inet_del_lback(__be32 addr);
20343 +/* hash table for nx_info hash */
20345 +#define NX_HASH_SIZE 13
20347 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20349 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20352 +static inline unsigned int __hashval(nid_t nid)
20354 + return (nid % NX_HASH_SIZE);
20359 +/* __hash_nx_info()
20361 + * add the nxi to the global hash table
20362 + * requires the hash_lock to be held */
20364 +static inline void __hash_nx_info(struct nx_info *nxi)
20366 + struct hlist_head *head;
20368 + vxd_assert_lock(&nx_info_hash_lock);
20369 + vxdprintk(VXD_CBIT(nid, 4),
20370 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20372 + /* context must not be hashed */
20373 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20375 + nxi->nx_state |= NXS_HASHED;
20376 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20377 + hlist_add_head(&nxi->nx_hlist, head);
20378 + atomic_inc(&nx_global_cactive);
20381 +/* __unhash_nx_info()
20383 + * remove the nxi from the global hash table
20384 + * requires the hash_lock to be held */
20386 +static inline void __unhash_nx_info(struct nx_info *nxi)
20388 + vxd_assert_lock(&nx_info_hash_lock);
20389 + vxdprintk(VXD_CBIT(nid, 4),
20390 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20391 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20393 + /* context must be hashed */
20394 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20395 + /* but without tasks */
20396 + BUG_ON(atomic_read(&nxi->nx_tasks));
20398 + nxi->nx_state &= ~NXS_HASHED;
20399 + hlist_del(&nxi->nx_hlist);
20400 + atomic_dec(&nx_global_cactive);
20404 +/* __lookup_nx_info()
20406 + * requires the hash_lock to be held
20407 + * doesn't increment the nx_refcnt */
20409 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20411 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20412 + struct hlist_node *pos;
20413 + struct nx_info *nxi;
20415 + vxd_assert_lock(&nx_info_hash_lock);
20416 + hlist_for_each(pos, head) {
20417 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20419 + if (nxi->nx_id == nid)
20424 + vxdprintk(VXD_CBIT(nid, 0),
20425 + "__lookup_nx_info(#%u): %p[#%u]",
20426 + nid, nxi, nxi ? nxi->nx_id : 0);
20431 +/* __create_nx_info()
20433 + * create the requested context
20434 + * get(), claim() and hash it */
20436 +static struct nx_info *__create_nx_info(int id)
20438 + struct nx_info *new, *nxi = NULL;
20440 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20442 + if (!(new = __alloc_nx_info(id)))
20443 + return ERR_PTR(-ENOMEM);
20445 + /* required to make dynamic xids unique */
20446 + spin_lock(&nx_info_hash_lock);
20448 + /* static context requested */
20449 + if ((nxi = __lookup_nx_info(id))) {
20450 + vxdprintk(VXD_CBIT(nid, 0),
20451 + "create_nx_info(%d) = %p (already there)", id, nxi);
20452 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20453 + nxi = ERR_PTR(-EBUSY);
20455 + nxi = ERR_PTR(-EEXIST);
20458 + /* new context */
20459 + vxdprintk(VXD_CBIT(nid, 0),
20460 + "create_nx_info(%d) = %p (new)", id, new);
20461 + claim_nx_info(new, NULL);
20462 + __nx_set_lback(new);
20463 + __hash_nx_info(get_nx_info(new));
20464 + nxi = new, new = NULL;
20467 + spin_unlock(&nx_info_hash_lock);
20469 + __dealloc_nx_info(new);
20475 +/* exported stuff */
20478 +void unhash_nx_info(struct nx_info *nxi)
20480 + __shutdown_nx_info(nxi);
20481 + spin_lock(&nx_info_hash_lock);
20482 + __unhash_nx_info(nxi);
20483 + spin_unlock(&nx_info_hash_lock);
20486 +/* lookup_nx_info()
20488 + * search for a nx_info and get() it
20489 + * negative id means current */
20491 +struct nx_info *lookup_nx_info(int id)
20493 + struct nx_info *nxi = NULL;
20496 + nxi = get_nx_info(current_nx_info());
20497 + } else if (id > 1) {
20498 + spin_lock(&nx_info_hash_lock);
20499 + nxi = get_nx_info(__lookup_nx_info(id));
20500 + spin_unlock(&nx_info_hash_lock);
20505 +/* nid_is_hashed()
20507 + * verify that nid is still hashed */
20509 +int nid_is_hashed(nid_t nid)
20513 + spin_lock(&nx_info_hash_lock);
20514 + hashed = (__lookup_nx_info(nid) != NULL);
20515 + spin_unlock(&nx_info_hash_lock);
20520 +#ifdef CONFIG_PROC_FS
20524 + * get a subset of hashed nids for proc
20525 + * assumes size is at least one */
20527 +int get_nid_list(int index, unsigned int *nids, int size)
20529 + int hindex, nr_nids = 0;
20531 + /* only show current and children */
20532 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20535 + nids[nr_nids] = nx_current_nid();
20539 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20540 + struct hlist_head *head = &nx_info_hash[hindex];
20541 + struct hlist_node *pos;
20543 + spin_lock(&nx_info_hash_lock);
20544 + hlist_for_each(pos, head) {
20545 + struct nx_info *nxi;
20550 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20551 + nids[nr_nids] = nxi->nx_id;
20552 + if (++nr_nids >= size) {
20553 + spin_unlock(&nx_info_hash_lock);
20557 + /* keep the lock time short */
20558 + spin_unlock(&nx_info_hash_lock);
20567 + * migrate task to new network
20568 + * gets nxi, puts old_nxi on change
20571 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20573 + struct nx_info *old_nxi;
20579 + vxdprintk(VXD_CBIT(nid, 5),
20580 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20581 + p, nxi, nxi->nx_id,
20582 + atomic_read(&nxi->nx_usecnt),
20583 + atomic_read(&nxi->nx_tasks));
20585 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20586 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20589 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20592 + /* maybe disallow this completely? */
20593 + old_nxi = task_get_nx_info(p);
20594 + if (old_nxi == nxi)
20599 + clr_nx_info(&p->nx_info);
20600 + claim_nx_info(nxi, p);
20601 + set_nx_info(&p->nx_info, nxi);
20602 + p->nid = nxi->nx_id;
20605 + vxdprintk(VXD_CBIT(nid, 5),
20606 + "moved task %p into nxi:%p[#%d]",
20607 + p, nxi, nxi->nx_id);
20610 + release_nx_info(old_nxi, p);
20613 + put_nx_info(old_nxi);
20618 +void nx_set_persistent(struct nx_info *nxi)
20620 + vxdprintk(VXD_CBIT(nid, 6),
20621 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20623 + get_nx_info(nxi);
20624 + claim_nx_info(nxi, NULL);
20627 +void nx_clear_persistent(struct nx_info *nxi)
20629 + vxdprintk(VXD_CBIT(nid, 6),
20630 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20632 + release_nx_info(nxi, NULL);
20633 + put_nx_info(nxi);
20636 +void nx_update_persistent(struct nx_info *nxi)
20638 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20639 + nx_set_persistent(nxi);
20641 + nx_clear_persistent(nxi);
20644 +/* vserver syscall commands below here */
20646 +/* taks nid and nx_info functions */
20648 +#include <asm/uaccess.h>
20651 +int vc_task_nid(uint32_t id)
20656 + struct task_struct *tsk;
20659 + tsk = find_task_by_real_pid(id);
20660 + nid = (tsk) ? tsk->nid : -ESRCH;
20661 + rcu_read_unlock();
20663 + nid = nx_current_nid();
20668 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20670 + struct vcmd_nx_info_v0 vc_data;
20672 + vc_data.nid = nxi->nx_id;
20674 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20680 +/* network functions */
20682 +int vc_net_create(uint32_t nid, void __user *data)
20684 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
20685 + struct nx_info *new_nxi;
20688 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20691 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
20694 + new_nxi = __create_nx_info(nid);
20695 + if (IS_ERR(new_nxi))
20696 + return PTR_ERR(new_nxi);
20698 + /* initial flags */
20699 + new_nxi->nx_flags = vc_data.flagword;
20702 + if (vs_net_change(new_nxi, VSC_NETUP))
20705 + ret = nx_migrate_task(current, new_nxi);
20709 + /* return context id on success */
20710 + ret = new_nxi->nx_id;
20712 + /* get a reference for persistent contexts */
20713 + if ((vc_data.flagword & NXF_PERSISTENT))
20714 + nx_set_persistent(new_nxi);
20716 + release_nx_info(new_nxi, NULL);
20717 + put_nx_info(new_nxi);
20722 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
20724 + return nx_migrate_task(current, nxi);
20729 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20730 + uint16_t type, uint16_t flags)
20732 + struct nx_addr_v4 *nxa = &nxi->v4;
20734 + if (NX_IPV4(nxi)) {
20735 + /* locate last entry */
20736 + for (; nxa->next; nxa = nxa->next);
20737 + nxa->next = __alloc_nx_addr_v4();
20741 + return PTR_ERR(nxa);
20744 + if (nxi->v4.next)
20745 + /* remove single ip for ip list */
20746 + nxi->nx_flags &= ~NXF_SINGLE_IP;
20748 + nxa->ip[0].s_addr = ip;
20749 + nxa->ip[1].s_addr = ip2;
20750 + nxa->mask.s_addr = mask;
20751 + nxa->type = type;
20752 + nxa->flags = flags;
20756 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20757 + uint16_t type, uint16_t flags)
20759 + struct nx_addr_v4 *nxa = &nxi->v4;
20762 +/* case NXA_TYPE_ADDR:
20765 + case NXA_TYPE_ANY:
20766 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
20767 + memset(nxa, 0, sizeof(*nxa));
20777 +int vc_net_add(struct nx_info *nxi, void __user *data)
20779 + struct vcmd_net_addr_v0 vc_data;
20780 + int index, ret = 0;
20782 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20785 + switch (vc_data.type) {
20786 + case NXA_TYPE_IPV4:
20787 + if ((vc_data.count < 1) || (vc_data.count > 4))
20791 + while (index < vc_data.count) {
20792 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
20793 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
20801 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
20802 + nxi->v4_bcast = vc_data.ip[0];
20806 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
20807 + nxi->v4_lback = vc_data.ip[0];
20818 +int vc_net_remove(struct nx_info *nxi, void __user *data)
20820 + struct vcmd_net_addr_v0 vc_data;
20822 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20825 + switch (vc_data.type) {
20826 + case NXA_TYPE_ANY:
20827 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
20828 + memset(&nxi->v4, 0, sizeof(nxi->v4));
20838 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
20840 + struct vcmd_net_addr_ipv4_v1 vc_data;
20842 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20845 + switch (vc_data.type) {
20846 + case NXA_TYPE_ADDR:
20847 + case NXA_TYPE_MASK:
20848 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
20849 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20851 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20852 + nxi->v4_bcast = vc_data.ip;
20855 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20856 + nxi->v4_lback = vc_data.ip;
20865 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
20867 + struct vcmd_net_addr_ipv4_v2 vc_data;
20869 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20872 + switch (vc_data.type) {
20873 + case NXA_TYPE_ADDR:
20874 + case NXA_TYPE_MASK:
20875 + case NXA_TYPE_RANGE:
20876 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20877 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20879 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20880 + nxi->v4_bcast = vc_data.ip;
20883 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20884 + nxi->v4_lback = vc_data.ip;
20893 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
20895 + struct vcmd_net_addr_ipv4_v1 vc_data;
20897 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20900 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
20901 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20904 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
20906 + struct vcmd_net_addr_ipv4_v2 vc_data;
20908 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20911 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20912 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20915 +#ifdef CONFIG_IPV6
20917 +int do_add_v6_addr(struct nx_info *nxi,
20918 + struct in6_addr *ip, struct in6_addr *mask,
20919 + uint32_t prefix, uint16_t type, uint16_t flags)
20921 + struct nx_addr_v6 *nxa = &nxi->v6;
20923 + if (NX_IPV6(nxi)) {
20924 + /* locate last entry */
20925 + for (; nxa->next; nxa = nxa->next);
20926 + nxa->next = __alloc_nx_addr_v6();
20930 + return PTR_ERR(nxa);
20934 + nxa->mask = *mask;
20935 + nxa->prefix = prefix;
20936 + nxa->type = type;
20937 + nxa->flags = flags;
20942 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
20944 + struct vcmd_net_addr_ipv6_v1 vc_data;
20946 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20949 + switch (vc_data.type) {
20950 + case NXA_TYPE_ADDR:
20951 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20952 + /* fallthrough */
20953 + case NXA_TYPE_MASK:
20954 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20955 + vc_data.prefix, vc_data.type, vc_data.flags);
20962 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
20964 + struct vcmd_net_addr_ipv6_v1 vc_data;
20966 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20969 + switch (vc_data.type) {
20970 + case NXA_TYPE_ANY:
20971 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
20972 + memset(&nxi->v6, 0, sizeof(nxi->v6));
20981 +#endif /* CONFIG_IPV6 */
20984 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
20986 + struct vcmd_net_flags_v0 vc_data;
20988 + vc_data.flagword = nxi->nx_flags;
20990 + /* special STATE flag handling */
20991 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
20993 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20998 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21000 + struct vcmd_net_flags_v0 vc_data;
21001 + uint64_t mask, trigger;
21003 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21006 + /* special STATE flag handling */
21007 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21008 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21010 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21011 + vc_data.flagword, mask);
21012 + if (trigger & NXF_PERSISTENT)
21013 + nx_update_persistent(nxi);
21018 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21020 + struct vcmd_net_caps_v0 vc_data;
21022 + vc_data.ncaps = nxi->nx_ncaps;
21023 + vc_data.cmask = ~0ULL;
21025 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21030 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21032 + struct vcmd_net_caps_v0 vc_data;
21034 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21037 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21038 + vc_data.ncaps, vc_data.cmask);
21043 +#include <linux/module.h>
21045 +module_init(init_network);
21047 +EXPORT_SYMBOL_GPL(free_nx_info);
21048 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21050 diff -NurpP --minimal linux-3.2.5/kernel/vserver/proc.c linux-3.2.5-vs2.3.2.6/kernel/vserver/proc.c
21051 --- linux-3.2.5/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21052 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/proc.c 2011-12-06 23:19:52.000000000 +0100
21055 + * linux/kernel/vserver/proc.c
21057 + * Virtual Context Support
21059 + * Copyright (C) 2003-2011 Herbert Pötzl
21061 + * V0.01 basic structure
21062 + * V0.02 adaptation vs1.3.0
21063 + * V0.03 proc permissions
21064 + * V0.04 locking/generic
21065 + * V0.05 next generation procfs
21066 + * V0.06 inode validation
21067 + * V0.07 generic rewrite vid
21068 + * V0.08 remove inode type
21069 + * V0.09 added u/wmask info
21073 +#include <linux/proc_fs.h>
21074 +#include <linux/fs_struct.h>
21075 +#include <linux/mount.h>
21076 +#include <asm/unistd.h>
21078 +#include <linux/vs_context.h>
21079 +#include <linux/vs_network.h>
21080 +#include <linux/vs_cvirt.h>
21082 +#include <linux/in.h>
21083 +#include <linux/inetdevice.h>
21084 +#include <linux/vs_inet.h>
21085 +#include <linux/vs_inet6.h>
21087 +#include <linux/vserver/global.h>
21089 +#include "cvirt_proc.h"
21090 +#include "cacct_proc.h"
21091 +#include "limit_proc.h"
21092 +#include "sched_proc.h"
21093 +#include "vci_config.h"
21096 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21100 + CAP_FOR_EACH_U32(__capi) {
21101 + buffer += sprintf(buffer, "%08x",
21102 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21108 +static struct proc_dir_entry *proc_virtual;
21110 +static struct proc_dir_entry *proc_virtnet;
21113 +/* first the actual feeds */
21116 +static int proc_vci(char *buffer)
21118 + return sprintf(buffer,
21119 + "VCIVersion:\t%04x:%04x\n"
21120 + "VCISyscall:\t%d\n"
21121 + "VCIKernel:\t%08x\n",
21122 + VCI_VERSION >> 16,
21123 + VCI_VERSION & 0xFFFF,
21125 + vci_kernel_config());
21128 +static int proc_virtual_info(char *buffer)
21130 + return proc_vci(buffer);
21133 +static int proc_virtual_status(char *buffer)
21135 + return sprintf(buffer,
21137 + "#CActive:\t%d\n"
21138 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21139 + "#InitTask:\t%d\t%d %d\n",
21140 + atomic_read(&vx_global_ctotal),
21141 + atomic_read(&vx_global_cactive),
21142 + atomic_read(&vs_global_nsproxy),
21143 + atomic_read(&vs_global_fs),
21144 + atomic_read(&vs_global_mnt_ns),
21145 + atomic_read(&vs_global_uts_ns),
21146 + atomic_read(&nr_ipc_ns),
21147 + atomic_read(&vs_global_user_ns),
21148 + atomic_read(&vs_global_pid_ns),
21149 + atomic_read(&init_task.usage),
21150 + atomic_read(&init_task.nsproxy->count),
21151 + init_task.fs->users);
21155 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21159 + length = sprintf(buffer,
21167 + vxi->vx_badness_bias);
21171 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21173 + char *orig = buffer;
21175 + buffer += sprintf(buffer,
21178 + "Flags:\t%016llx\n",
21179 + atomic_read(&vxi->vx_usecnt),
21180 + atomic_read(&vxi->vx_tasks),
21181 + (unsigned long long)vxi->vx_flags);
21183 + buffer += sprintf(buffer, "BCaps:\t");
21184 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21185 + buffer += sprintf(buffer, "\n");
21187 + buffer += sprintf(buffer,
21188 + "CCaps:\t%016llx\n"
21189 + "Umask:\t%16llx\n"
21190 + "Wmask:\t%16llx\n"
21191 + "Spaces:\t%08lx %08lx\n",
21192 + (unsigned long long)vxi->vx_ccaps,
21193 + (unsigned long long)vxi->vx_umask,
21194 + (unsigned long long)vxi->vx_wmask,
21195 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21196 + return buffer - orig;
21199 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21201 + return vx_info_proc_limit(&vxi->limit, buffer);
21204 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21208 + length = vx_info_proc_sched(&vxi->sched, buffer);
21209 + for_each_online_cpu(cpu) {
21210 + length += vx_info_proc_sched_pc(
21211 + &vx_per_cpu(vxi, sched_pc, cpu),
21212 + buffer + length, cpu);
21217 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21219 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21222 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21224 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21227 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21231 + vx_update_load(vxi);
21232 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21233 + for_each_online_cpu(cpu) {
21234 + length += vx_info_proc_cvirt_pc(
21235 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21236 + buffer + length, cpu);
21241 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21243 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21247 +static int proc_virtnet_info(char *buffer)
21249 + return proc_vci(buffer);
21252 +static int proc_virtnet_status(char *buffer)
21254 + return sprintf(buffer,
21256 + "#CActive:\t%d\n",
21257 + atomic_read(&nx_global_ctotal),
21258 + atomic_read(&nx_global_cactive));
21261 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21263 + struct nx_addr_v4 *v4a;
21264 +#ifdef CONFIG_IPV6
21265 + struct nx_addr_v6 *v6a;
21269 + length = sprintf(buffer,
21272 + "Bcast:\t" NIPQUAD_FMT "\n"
21273 + "Lback:\t" NIPQUAD_FMT "\n",
21276 + NIPQUAD(nxi->v4_bcast.s_addr),
21277 + NIPQUAD(nxi->v4_lback.s_addr));
21279 + if (!NX_IPV4(nxi))
21281 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21282 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21285 +#ifdef CONFIG_IPV6
21286 + if (!NX_IPV6(nxi))
21288 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21289 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21296 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21300 + length = sprintf(buffer,
21303 + "Flags:\t%016llx\n"
21304 + "NCaps:\t%016llx\n",
21305 + atomic_read(&nxi->nx_usecnt),
21306 + atomic_read(&nxi->nx_tasks),
21307 + (unsigned long long)nxi->nx_flags,
21308 + (unsigned long long)nxi->nx_ncaps);
21314 +/* here the inode helpers */
21320 + struct inode_operations *iop;
21321 + struct file_operations *fop;
21322 + union proc_op op;
21325 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21327 + struct inode *inode = new_inode(sb);
21332 + inode->i_mode = p->mode;
21334 + inode->i_op = p->iop;
21336 + inode->i_fop = p->fop;
21338 + set_nlink(inode, (p->mode & S_IFDIR) ? 2 : 1);
21339 + inode->i_flags |= S_IMMUTABLE;
21341 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21343 + inode->i_uid = 0;
21344 + inode->i_gid = 0;
21345 + inode->i_tag = 0;
21350 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21351 + struct dentry *dentry, int id, void *ptr)
21353 + struct vs_entry *p = ptr;
21354 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21355 + struct dentry *error = ERR_PTR(-EINVAL);
21360 + PROC_I(inode)->op = p->op;
21361 + PROC_I(inode)->fd = id;
21362 + d_add(dentry, inode);
21370 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21373 + * Fill a directory entry.
21375 + * If possible create the dcache entry and derive our inode number and
21376 + * file type from dcache entry.
21378 + * Since all of the proc inode numbers are dynamically generated, the inode
21379 + * numbers do not exist until the inode is cache. This means creating the
21380 + * the dcache entry in readdir is necessary to keep the inode numbers
21381 + * reported by readdir in sync with the inode numbers reported
21384 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21385 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21387 + struct dentry *child, *dir = filp->f_dentry;
21388 + struct inode *inode;
21389 + struct qstr qname;
21391 + unsigned type = DT_UNKNOWN;
21393 + qname.name = name;
21395 + qname.hash = full_name_hash(name, len);
21397 + child = d_lookup(dir, &qname);
21399 + struct dentry *new;
21400 + new = d_alloc(dir, &qname);
21402 + child = instantiate(dir->d_inode, new, id, ptr);
21409 + if (!child || IS_ERR(child) || !child->d_inode)
21410 + goto end_instantiate;
21411 + inode = child->d_inode;
21413 + ino = inode->i_ino;
21414 + type = inode->i_mode >> 12;
21419 + ino = find_inode_number(dir, &qname);
21422 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21427 +/* get and revalidate vx_info/xid */
21430 +struct vx_info *get_proc_vx_info(struct inode *inode)
21432 + return lookup_vx_info(PROC_I(inode)->fd);
21435 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21437 + struct inode *inode = dentry->d_inode;
21438 + xid_t xid = PROC_I(inode)->fd;
21440 + if (!xid || xid_is_hashed(xid))
21447 +/* get and revalidate nx_info/nid */
21449 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21451 + struct inode *inode = dentry->d_inode;
21452 + nid_t nid = PROC_I(inode)->fd;
21454 + if (!nid || nid_is_hashed(nid))
21462 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21464 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21465 + size_t count, loff_t *ppos)
21467 + struct inode *inode = file->f_dentry->d_inode;
21468 + unsigned long page;
21469 + ssize_t length = 0;
21471 + if (count > PROC_BLOCK_SIZE)
21472 + count = PROC_BLOCK_SIZE;
21474 + /* fade that out as soon as stable */
21475 + WARN_ON(PROC_I(inode)->fd);
21477 + if (!(page = __get_free_page(GFP_KERNEL)))
21480 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21481 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21484 + length = simple_read_from_buffer(buf, count, ppos,
21485 + (char *)page, length);
21491 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21492 + size_t count, loff_t *ppos)
21494 + struct inode *inode = file->f_dentry->d_inode;
21495 + struct vx_info *vxi = NULL;
21496 + xid_t xid = PROC_I(inode)->fd;
21497 + unsigned long page;
21498 + ssize_t length = 0;
21500 + if (count > PROC_BLOCK_SIZE)
21501 + count = PROC_BLOCK_SIZE;
21503 + /* fade that out as soon as stable */
21505 + vxi = lookup_vx_info(xid);
21509 + length = -ENOMEM;
21510 + if (!(page = __get_free_page(GFP_KERNEL)))
21513 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21514 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21517 + length = simple_read_from_buffer(buf, count, ppos,
21518 + (char *)page, length);
21522 + put_vx_info(vxi);
21527 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21528 + size_t count, loff_t *ppos)
21530 + struct inode *inode = file->f_dentry->d_inode;
21531 + struct nx_info *nxi = NULL;
21532 + nid_t nid = PROC_I(inode)->fd;
21533 + unsigned long page;
21534 + ssize_t length = 0;
21536 + if (count > PROC_BLOCK_SIZE)
21537 + count = PROC_BLOCK_SIZE;
21539 + /* fade that out as soon as stable */
21541 + nxi = lookup_nx_info(nid);
21545 + length = -ENOMEM;
21546 + if (!(page = __get_free_page(GFP_KERNEL)))
21549 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21550 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21553 + length = simple_read_from_buffer(buf, count, ppos,
21554 + (char *)page, length);
21558 + put_nx_info(nxi);
21565 +/* here comes the lower level */
21568 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21569 + .len = sizeof(NAME) - 1, \
21570 + .name = (NAME), \
21578 +#define DIR(NAME, MODE, OTYPE) \
21579 + NOD(NAME, (S_IFDIR | (MODE)), \
21580 + &proc_ ## OTYPE ## _inode_operations, \
21581 + &proc_ ## OTYPE ## _file_operations, { } )
21583 +#define INF(NAME, MODE, OTYPE) \
21584 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21585 + &proc_vs_info_file_operations, \
21586 + { .proc_vs_read = &proc_##OTYPE } )
21588 +#define VINF(NAME, MODE, OTYPE) \
21589 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21590 + &proc_vx_info_file_operations, \
21591 + { .proc_vxi_read = &proc_##OTYPE } )
21593 +#define NINF(NAME, MODE, OTYPE) \
21594 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21595 + &proc_nx_info_file_operations, \
21596 + { .proc_nxi_read = &proc_##OTYPE } )
21599 +static struct file_operations proc_vs_info_file_operations = {
21600 + .read = proc_vs_info_read,
21603 +static struct file_operations proc_vx_info_file_operations = {
21604 + .read = proc_vx_info_read,
21607 +static struct dentry_operations proc_xid_dentry_operations = {
21608 + .d_revalidate = proc_xid_revalidate,
21611 +static struct vs_entry vx_base_stuff[] = {
21612 + VINF("info", S_IRUGO, vxi_info),
21613 + VINF("status", S_IRUGO, vxi_status),
21614 + VINF("limit", S_IRUGO, vxi_limit),
21615 + VINF("sched", S_IRUGO, vxi_sched),
21616 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21617 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21618 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21619 + VINF("cacct", S_IRUGO, vxi_cacct),
21626 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21627 + struct dentry *dentry, int id, void *ptr)
21629 + dentry->d_op = &proc_xid_dentry_operations;
21630 + return vs_proc_instantiate(dir, dentry, id, ptr);
21633 +static struct dentry *proc_xid_lookup(struct inode *dir,
21634 + struct dentry *dentry, struct nameidata *nd)
21636 + struct vs_entry *p = vx_base_stuff;
21637 + struct dentry *error = ERR_PTR(-ENOENT);
21639 + for (; p->name; p++) {
21640 + if (p->len != dentry->d_name.len)
21642 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21648 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21653 +static int proc_xid_readdir(struct file *filp,
21654 + void *dirent, filldir_t filldir)
21656 + struct dentry *dentry = filp->f_dentry;
21657 + struct inode *inode = dentry->d_inode;
21658 + struct vs_entry *p = vx_base_stuff;
21659 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21663 + pos = filp->f_pos;
21666 + ino = inode->i_ino;
21667 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21670 + /* fall through */
21672 + ino = parent_ino(dentry);
21673 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21676 + /* fall through */
21679 + if (index >= size)
21681 + for (p += index; p->name; p++) {
21682 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21683 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21689 + filp->f_pos = pos;
21695 +static struct file_operations proc_nx_info_file_operations = {
21696 + .read = proc_nx_info_read,
21699 +static struct dentry_operations proc_nid_dentry_operations = {
21700 + .d_revalidate = proc_nid_revalidate,
21703 +static struct vs_entry nx_base_stuff[] = {
21704 + NINF("info", S_IRUGO, nxi_info),
21705 + NINF("status", S_IRUGO, nxi_status),
21710 +static struct dentry *proc_nid_instantiate(struct inode *dir,
21711 + struct dentry *dentry, int id, void *ptr)
21713 + dentry->d_op = &proc_nid_dentry_operations;
21714 + return vs_proc_instantiate(dir, dentry, id, ptr);
21717 +static struct dentry *proc_nid_lookup(struct inode *dir,
21718 + struct dentry *dentry, struct nameidata *nd)
21720 + struct vs_entry *p = nx_base_stuff;
21721 + struct dentry *error = ERR_PTR(-ENOENT);
21723 + for (; p->name; p++) {
21724 + if (p->len != dentry->d_name.len)
21726 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21732 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21737 +static int proc_nid_readdir(struct file *filp,
21738 + void *dirent, filldir_t filldir)
21740 + struct dentry *dentry = filp->f_dentry;
21741 + struct inode *inode = dentry->d_inode;
21742 + struct vs_entry *p = nx_base_stuff;
21743 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
21747 + pos = filp->f_pos;
21750 + ino = inode->i_ino;
21751 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21754 + /* fall through */
21756 + ino = parent_ino(dentry);
21757 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21760 + /* fall through */
21763 + if (index >= size)
21765 + for (p += index; p->name; p++) {
21766 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21767 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21773 + filp->f_pos = pos;
21778 +#define MAX_MULBY10 ((~0U - 9) / 10)
21780 +static inline int atovid(const char *str, int len)
21785 + while (len-- > 0) {
21790 + if (vid >= MAX_MULBY10)
21800 +/* now the upper level (virtual) */
21803 +static struct file_operations proc_xid_file_operations = {
21804 + .read = generic_read_dir,
21805 + .readdir = proc_xid_readdir,
21808 +static struct inode_operations proc_xid_inode_operations = {
21809 + .lookup = proc_xid_lookup,
21812 +static struct vs_entry vx_virtual_stuff[] = {
21813 + INF("info", S_IRUGO, virtual_info),
21814 + INF("status", S_IRUGO, virtual_status),
21815 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
21819 +static struct dentry *proc_virtual_lookup(struct inode *dir,
21820 + struct dentry *dentry, struct nameidata *nd)
21822 + struct vs_entry *p = vx_virtual_stuff;
21823 + struct dentry *error = ERR_PTR(-ENOENT);
21826 + for (; p->name; p++) {
21827 + if (p->len != dentry->d_name.len)
21829 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21833 + goto instantiate;
21835 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21836 + if ((id < 0) || !xid_is_hashed(id))
21840 + error = proc_xid_instantiate(dir, dentry, id, p);
21845 +static struct file_operations proc_nid_file_operations = {
21846 + .read = generic_read_dir,
21847 + .readdir = proc_nid_readdir,
21850 +static struct inode_operations proc_nid_inode_operations = {
21851 + .lookup = proc_nid_lookup,
21854 +static struct vs_entry nx_virtnet_stuff[] = {
21855 + INF("info", S_IRUGO, virtnet_info),
21856 + INF("status", S_IRUGO, virtnet_status),
21857 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
21861 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
21862 + struct dentry *dentry, struct nameidata *nd)
21864 + struct vs_entry *p = nx_virtnet_stuff;
21865 + struct dentry *error = ERR_PTR(-ENOENT);
21868 + for (; p->name; p++) {
21869 + if (p->len != dentry->d_name.len)
21871 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21875 + goto instantiate;
21877 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21878 + if ((id < 0) || !nid_is_hashed(id))
21882 + error = proc_nid_instantiate(dir, dentry, id, p);
21888 +#define PROC_MAXVIDS 32
21890 +int proc_virtual_readdir(struct file *filp,
21891 + void *dirent, filldir_t filldir)
21893 + struct dentry *dentry = filp->f_dentry;
21894 + struct inode *inode = dentry->d_inode;
21895 + struct vs_entry *p = vx_virtual_stuff;
21896 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
21898 + unsigned int xid_array[PROC_MAXVIDS];
21899 + char buf[PROC_NUMBUF];
21900 + unsigned int nr_xids, i;
21903 + pos = filp->f_pos;
21906 + ino = inode->i_ino;
21907 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21910 + /* fall through */
21912 + ino = parent_ino(dentry);
21913 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21916 + /* fall through */
21919 + if (index >= size)
21921 + for (p += index; p->name; p++) {
21922 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21923 + vs_proc_instantiate, 0, p))
21928 + index = pos - size;
21929 + p = &vx_virtual_stuff[size - 1];
21930 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
21931 + for (i = 0; i < nr_xids; i++) {
21932 + int n, xid = xid_array[i];
21933 + unsigned int j = PROC_NUMBUF;
21937 + buf[--j] = '0' + (n % 10);
21940 + if (proc_fill_cache(filp, dirent, filldir,
21941 + buf + j, PROC_NUMBUF - j,
21942 + vs_proc_instantiate, xid, p))
21948 + filp->f_pos = pos;
21952 +static int proc_virtual_getattr(struct vfsmount *mnt,
21953 + struct dentry *dentry, struct kstat *stat)
21955 + struct inode *inode = dentry->d_inode;
21957 + generic_fillattr(inode, stat);
21958 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
21962 +static struct file_operations proc_virtual_dir_operations = {
21963 + .read = generic_read_dir,
21964 + .readdir = proc_virtual_readdir,
21967 +static struct inode_operations proc_virtual_dir_inode_operations = {
21968 + .getattr = proc_virtual_getattr,
21969 + .lookup = proc_virtual_lookup,
21976 +int proc_virtnet_readdir(struct file *filp,
21977 + void *dirent, filldir_t filldir)
21979 + struct dentry *dentry = filp->f_dentry;
21980 + struct inode *inode = dentry->d_inode;
21981 + struct vs_entry *p = nx_virtnet_stuff;
21982 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
21984 + unsigned int nid_array[PROC_MAXVIDS];
21985 + char buf[PROC_NUMBUF];
21986 + unsigned int nr_nids, i;
21989 + pos = filp->f_pos;
21992 + ino = inode->i_ino;
21993 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21996 + /* fall through */
21998 + ino = parent_ino(dentry);
21999 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22002 + /* fall through */
22005 + if (index >= size)
22007 + for (p += index; p->name; p++) {
22008 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22009 + vs_proc_instantiate, 0, p))
22014 + index = pos - size;
22015 + p = &nx_virtnet_stuff[size - 1];
22016 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22017 + for (i = 0; i < nr_nids; i++) {
22018 + int n, nid = nid_array[i];
22019 + unsigned int j = PROC_NUMBUF;
22023 + buf[--j] = '0' + (n % 10);
22026 + if (proc_fill_cache(filp, dirent, filldir,
22027 + buf + j, PROC_NUMBUF - j,
22028 + vs_proc_instantiate, nid, p))
22034 + filp->f_pos = pos;
22038 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22039 + struct dentry *dentry, struct kstat *stat)
22041 + struct inode *inode = dentry->d_inode;
22043 + generic_fillattr(inode, stat);
22044 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22048 +static struct file_operations proc_virtnet_dir_operations = {
22049 + .read = generic_read_dir,
22050 + .readdir = proc_virtnet_readdir,
22053 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22054 + .getattr = proc_virtnet_getattr,
22055 + .lookup = proc_virtnet_lookup,
22060 +void proc_vx_init(void)
22062 + struct proc_dir_entry *ent;
22064 + ent = proc_mkdir("virtual", 0);
22066 + ent->proc_fops = &proc_virtual_dir_operations;
22067 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22069 + proc_virtual = ent;
22071 + ent = proc_mkdir("virtnet", 0);
22073 + ent->proc_fops = &proc_virtnet_dir_operations;
22074 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22076 + proc_virtnet = ent;
22082 +/* per pid info */
22085 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22087 + struct vx_info *vxi;
22088 + char *orig = buffer;
22090 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22092 + vxi = task_get_vx_info(p);
22096 + buffer += sprintf(buffer, "BCaps:\t");
22097 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22098 + buffer += sprintf(buffer, "\n");
22099 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22100 + (unsigned long long)vxi->vx_ccaps);
22101 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22102 + (unsigned long long)vxi->vx_flags);
22103 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22105 + put_vx_info(vxi);
22107 + return buffer - orig;
22111 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22113 + struct nx_info *nxi;
22114 + struct nx_addr_v4 *v4a;
22115 +#ifdef CONFIG_IPV6
22116 + struct nx_addr_v6 *v6a;
22118 + char *orig = buffer;
22121 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22123 + nxi = task_get_nx_info(p);
22127 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22128 + (unsigned long long)nxi->nx_ncaps);
22129 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22130 + (unsigned long long)nxi->nx_flags);
22132 + buffer += sprintf(buffer,
22133 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22134 + NIPQUAD(nxi->v4_bcast.s_addr));
22135 + buffer += sprintf (buffer,
22136 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22137 + NIPQUAD(nxi->v4_lback.s_addr));
22138 + if (!NX_IPV4(nxi))
22140 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22141 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22144 +#ifdef CONFIG_IPV6
22145 + if (!NX_IPV6(nxi))
22147 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22148 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22152 + put_nx_info(nxi);
22154 + return buffer - orig;
22157 diff -NurpP --minimal linux-3.2.5/kernel/vserver/sched.c linux-3.2.5-vs2.3.2.6/kernel/vserver/sched.c
22158 --- linux-3.2.5/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22159 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/sched.c 2011-12-05 19:33:02.000000000 +0100
22162 + * linux/kernel/vserver/sched.c
22164 + * Virtual Server: Scheduler Support
22166 + * Copyright (C) 2004-2010 Herbert Pötzl
22168 + * V0.01 adapted Sam Vilains version to 2.6.3
22169 + * V0.02 removed legacy interface
22170 + * V0.03 changed vcmds to vxi arg
22171 + * V0.04 removed older and legacy interfaces
22172 + * V0.05 removed scheduler code/commands
22176 +#include <linux/vs_context.h>
22177 +#include <linux/vs_sched.h>
22178 +#include <linux/vserver/sched_cmd.h>
22180 +#include <asm/uaccess.h>
22183 +void vx_update_sched_param(struct _vx_sched *sched,
22184 + struct _vx_sched_pc *sched_pc)
22186 + sched_pc->prio_bias = sched->prio_bias;
22189 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22193 + if (data->prio_bias > MAX_PRIO_BIAS)
22194 + data->prio_bias = MAX_PRIO_BIAS;
22195 + if (data->prio_bias < MIN_PRIO_BIAS)
22196 + data->prio_bias = MIN_PRIO_BIAS;
22198 + if (data->cpu_id != ~0) {
22199 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22200 + cpus_and(vxi->sched.update, cpu_online_map,
22201 + vxi->sched.update);
22203 + vxi->sched.update = cpu_online_map;
22205 + for_each_cpu_mask(cpu, vxi->sched.update)
22206 + vx_update_sched_param(&vxi->sched,
22207 + &vx_per_cpu(vxi, sched_pc, cpu));
22211 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22213 + struct vcmd_prio_bias vc_data;
22215 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22218 + return do_set_prio_bias(vxi, &vc_data);
22221 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22223 + struct vcmd_prio_bias vc_data;
22224 + struct _vx_sched_pc *pcd;
22227 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22230 + cpu = vc_data.cpu_id;
22232 + if (!cpu_possible(cpu))
22235 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22236 + vc_data.prio_bias = pcd->prio_bias;
22238 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22243 diff -NurpP --minimal linux-3.2.5/kernel/vserver/sched_init.h linux-3.2.5-vs2.3.2.6/kernel/vserver/sched_init.h
22244 --- linux-3.2.5/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22245 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/sched_init.h 2011-12-05 19:33:02.000000000 +0100
22248 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22250 + /* scheduling; hard code starting values as constants */
22251 + sched->prio_bias = 0;
22255 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22257 + sched_pc->prio_bias = 0;
22259 + sched_pc->user_ticks = 0;
22260 + sched_pc->sys_ticks = 0;
22261 + sched_pc->hold_ticks = 0;
22264 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22270 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22274 diff -NurpP --minimal linux-3.2.5/kernel/vserver/sched_proc.h linux-3.2.5-vs2.3.2.6/kernel/vserver/sched_proc.h
22275 --- linux-3.2.5/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22276 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/sched_proc.h 2011-12-05 19:33:02.000000000 +0100
22278 +#ifndef _VX_SCHED_PROC_H
22279 +#define _VX_SCHED_PROC_H
22283 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22287 + length += sprintf(buffer,
22288 + "PrioBias:\t%8d\n",
22289 + sched->prio_bias);
22294 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22295 + char *buffer, int cpu)
22299 + length += sprintf(buffer + length,
22300 + "cpu %d: %lld %lld %lld", cpu,
22301 + (unsigned long long)sched_pc->user_ticks,
22302 + (unsigned long long)sched_pc->sys_ticks,
22303 + (unsigned long long)sched_pc->hold_ticks);
22304 + length += sprintf(buffer + length,
22305 + " %d\n", sched_pc->prio_bias);
22309 +#endif /* _VX_SCHED_PROC_H */
22310 diff -NurpP --minimal linux-3.2.5/kernel/vserver/signal.c linux-3.2.5-vs2.3.2.6/kernel/vserver/signal.c
22311 --- linux-3.2.5/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22312 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/signal.c 2011-12-05 19:33:02.000000000 +0100
22315 + * linux/kernel/vserver/signal.c
22317 + * Virtual Server: Signal Support
22319 + * Copyright (C) 2003-2007 Herbert Pötzl
22321 + * V0.01 broken out from vcontext V0.05
22322 + * V0.02 changed vcmds to vxi arg
22323 + * V0.03 adjusted siginfo for kill
22327 +#include <asm/uaccess.h>
22329 +#include <linux/vs_context.h>
22330 +#include <linux/vs_pid.h>
22331 +#include <linux/vserver/signal_cmd.h>
22334 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22336 + int retval, count = 0;
22337 + struct task_struct *p;
22338 + struct siginfo *sip = SEND_SIG_PRIV;
22341 + vxdprintk(VXD_CBIT(misc, 4),
22342 + "vx_info_kill(%p[#%d],%d,%d)*",
22343 + vxi, vxi->vx_id, pid, sig);
22344 + read_lock(&tasklist_lock);
22348 + for_each_process(p) {
22351 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22352 + (pid && vxi->vx_initpid == p->pid))
22355 + err = group_send_sig_info(sig, sip, p);
22357 + if (err != -EPERM)
22363 + if (vxi->vx_initpid) {
22364 + pid = vxi->vx_initpid;
22365 + /* for now, only SIGINT to private init ... */
22366 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22367 + /* ... as long as there are tasks left */
22368 + (atomic_read(&vxi->vx_tasks) > 1))
22371 + /* fallthrough */
22374 + p = find_task_by_real_pid(pid);
22375 + rcu_read_unlock();
22377 + if (vx_task_xid(p) == vxi->vx_id)
22378 + retval = group_send_sig_info(sig, sip, p);
22382 + read_unlock(&tasklist_lock);
22383 + vxdprintk(VXD_CBIT(misc, 4),
22384 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22385 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22389 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22391 + struct vcmd_ctx_kill_v0 vc_data;
22393 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22396 + /* special check to allow guest shutdown */
22397 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22398 + /* forbid killall pid=0 when init is present */
22399 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22400 + (vc_data.pid > 1)))
22403 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22407 +static int __wait_exit(struct vx_info *vxi)
22409 + DECLARE_WAITQUEUE(wait, current);
22412 + add_wait_queue(&vxi->vx_wait, &wait);
22413 + set_current_state(TASK_INTERRUPTIBLE);
22416 + if (vx_info_state(vxi,
22417 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22419 + if (signal_pending(current)) {
22420 + ret = -ERESTARTSYS;
22427 + set_current_state(TASK_RUNNING);
22428 + remove_wait_queue(&vxi->vx_wait, &wait);
22434 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22436 + struct vcmd_wait_exit_v0 vc_data;
22439 + ret = __wait_exit(vxi);
22440 + vc_data.reboot_cmd = vxi->reboot_cmd;
22441 + vc_data.exit_code = vxi->exit_code;
22443 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22448 diff -NurpP --minimal linux-3.2.5/kernel/vserver/space.c linux-3.2.5-vs2.3.2.6/kernel/vserver/space.c
22449 --- linux-3.2.5/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22450 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/space.c 2011-12-05 19:33:02.000000000 +0100
22453 + * linux/kernel/vserver/space.c
22455 + * Virtual Server: Context Space Support
22457 + * Copyright (C) 2003-2010 Herbert Pötzl
22459 + * V0.01 broken out from context.c 0.07
22460 + * V0.02 added task locking for namespace
22461 + * V0.03 broken out vx_enter_namespace
22462 + * V0.04 added *space support and commands
22463 + * V0.05 added credential support
22467 +#include <linux/utsname.h>
22468 +#include <linux/nsproxy.h>
22469 +#include <linux/err.h>
22470 +#include <linux/fs_struct.h>
22471 +#include <linux/cred.h>
22472 +#include <asm/uaccess.h>
22474 +#include <linux/vs_context.h>
22475 +#include <linux/vserver/space.h>
22476 +#include <linux/vserver/space_cmd.h>
22478 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22479 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22480 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22481 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22482 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22483 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22486 +/* namespace functions */
22488 +#include <linux/mnt_namespace.h>
22489 +#include <linux/user_namespace.h>
22490 +#include <linux/pid_namespace.h>
22491 +#include <linux/ipc_namespace.h>
22492 +#include <net/net_namespace.h>
22495 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22496 + .mask = CLONE_FS |
22498 +#ifdef CONFIG_UTS_NS
22501 +#ifdef CONFIG_IPC_NS
22504 +#ifdef CONFIG_USER_NS
22510 +static const struct vcmd_space_mask_v1 space_mask = {
22511 + .mask = CLONE_FS |
22513 +#ifdef CONFIG_UTS_NS
22516 +#ifdef CONFIG_IPC_NS
22519 +#ifdef CONFIG_USER_NS
22522 +#ifdef CONFIG_PID_NS
22525 +#ifdef CONFIG_NET_NS
22531 +static const struct vcmd_space_mask_v1 default_space_mask = {
22532 + .mask = CLONE_FS |
22534 +#ifdef CONFIG_UTS_NS
22537 +#ifdef CONFIG_IPC_NS
22540 +#ifdef CONFIG_USER_NS
22543 +#ifdef CONFIG_PID_NS
22550 + * build a new nsproxy mix
22551 + * assumes that both proxies are 'const'
22552 + * does not touch nsproxy refcounts
22553 + * will hold a reference on the result.
22556 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22557 + struct nsproxy *new_nsproxy, unsigned long mask)
22559 + struct mnt_namespace *old_ns;
22560 + struct uts_namespace *old_uts;
22561 + struct ipc_namespace *old_ipc;
22562 +#ifdef CONFIG_PID_NS
22563 + struct pid_namespace *old_pid;
22565 +#ifdef CONFIG_NET_NS
22566 + struct net *old_net;
22568 + struct nsproxy *nsproxy;
22570 + nsproxy = copy_nsproxy(old_nsproxy);
22574 + if (mask & CLONE_NEWNS) {
22575 + old_ns = nsproxy->mnt_ns;
22576 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22577 + if (nsproxy->mnt_ns)
22578 + get_mnt_ns(nsproxy->mnt_ns);
22582 + if (mask & CLONE_NEWUTS) {
22583 + old_uts = nsproxy->uts_ns;
22584 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22585 + if (nsproxy->uts_ns)
22586 + get_uts_ns(nsproxy->uts_ns);
22590 + if (mask & CLONE_NEWIPC) {
22591 + old_ipc = nsproxy->ipc_ns;
22592 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22593 + if (nsproxy->ipc_ns)
22594 + get_ipc_ns(nsproxy->ipc_ns);
22598 +#ifdef CONFIG_PID_NS
22599 + if (mask & CLONE_NEWPID) {
22600 + old_pid = nsproxy->pid_ns;
22601 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22602 + if (nsproxy->pid_ns)
22603 + get_pid_ns(nsproxy->pid_ns);
22607 +#ifdef CONFIG_NET_NS
22608 + if (mask & CLONE_NEWNET) {
22609 + old_net = nsproxy->net_ns;
22610 + nsproxy->net_ns = new_nsproxy->net_ns;
22611 + if (nsproxy->net_ns)
22612 + get_net(nsproxy->net_ns);
22617 + put_mnt_ns(old_ns);
22619 + put_uts_ns(old_uts);
22621 + put_ipc_ns(old_ipc);
22622 +#ifdef CONFIG_PID_NS
22624 + put_pid_ns(old_pid);
22626 +#ifdef CONFIG_NET_NS
22628 + put_net(old_net);
22636 + * merge two nsproxy structs into a new one.
22637 + * will hold a reference on the result.
22641 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22642 + struct nsproxy *proxy, unsigned long mask)
22644 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22650 + /* vs_mix_nsproxy returns with reference */
22651 + return vs_mix_nsproxy(old ? old : &null_proxy,
22654 + get_nsproxy(proxy);
22659 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22661 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22662 + struct fs_struct *fs_cur, *fs = NULL;
22663 + struct _vx_space *space;
22664 + int ret, kill = 0;
22666 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22667 + vxi, vxi->vx_id, mask, index);
22669 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22672 + if (index >= VX_SPACES)
22675 + space = &vxi->space[index];
22678 + mask = space->vx_nsmask;
22680 + if ((mask & space->vx_nsmask) != mask)
22683 + if (mask & CLONE_FS) {
22684 + fs = copy_fs_struct(space->vx_fs);
22688 + proxy = space->vx_nsproxy;
22690 + vxdprintk(VXD_CBIT(space, 9),
22691 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
22692 + vxi, vxi->vx_id, mask, index, proxy, fs);
22694 + task_lock(current);
22695 + fs_cur = current->fs;
22697 + if (mask & CLONE_FS) {
22698 + spin_lock(&fs_cur->lock);
22699 + current->fs = fs;
22700 + kill = !--fs_cur->users;
22701 + spin_unlock(&fs_cur->lock);
22704 + proxy_cur = current->nsproxy;
22705 + get_nsproxy(proxy_cur);
22706 + task_unlock(current);
22709 + free_fs_struct(fs_cur);
22711 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
22712 + if (IS_ERR(proxy_new)) {
22713 + ret = PTR_ERR(proxy_new);
22717 + proxy_new = xchg(¤t->nsproxy, proxy_new);
22719 + if (mask & CLONE_NEWUSER) {
22720 + struct cred *cred;
22722 + vxdprintk(VXD_CBIT(space, 10),
22723 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
22724 + vxi, vxi->vx_id, space->vx_cred,
22725 + current->real_cred, current->cred);
22727 + if (space->vx_cred) {
22728 + cred = __prepare_creds(space->vx_cred);
22730 + commit_creds(cred);
22737 + put_nsproxy(proxy_new);
22740 + put_nsproxy(proxy_cur);
22745 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22747 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
22748 + struct fs_struct *fs_vxi, *fs;
22749 + struct _vx_space *space;
22750 + int ret, kill = 0;
22752 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
22753 + vxi, vxi->vx_id, mask, index);
22755 + if ((mask & space_mask.mask) != mask)
22758 + if (index >= VX_SPACES)
22761 + space = &vxi->space[index];
22763 + proxy_vxi = space->vx_nsproxy;
22764 + fs_vxi = space->vx_fs;
22766 + if (mask & CLONE_FS) {
22767 + fs = copy_fs_struct(current->fs);
22772 + task_lock(current);
22774 + if (mask & CLONE_FS) {
22775 + spin_lock(&fs_vxi->lock);
22776 + space->vx_fs = fs;
22777 + kill = !--fs_vxi->users;
22778 + spin_unlock(&fs_vxi->lock);
22781 + proxy_cur = current->nsproxy;
22782 + get_nsproxy(proxy_cur);
22783 + task_unlock(current);
22786 + free_fs_struct(fs_vxi);
22788 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
22789 + if (IS_ERR(proxy_new)) {
22790 + ret = PTR_ERR(proxy_new);
22794 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
22795 + space->vx_nsmask |= mask;
22797 + if (mask & CLONE_NEWUSER) {
22798 + struct cred *cred;
22800 + vxdprintk(VXD_CBIT(space, 10),
22801 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
22802 + vxi, vxi->vx_id, space->vx_cred,
22803 + current->real_cred, current->cred);
22805 + cred = prepare_creds();
22806 + cred = (struct cred *)xchg(&space->vx_cred, cred);
22808 + abort_creds(cred);
22814 + put_nsproxy(proxy_new);
22817 + put_nsproxy(proxy_cur);
22822 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
22824 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22826 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22829 + return vx_enter_space(vxi, vc_data.mask, 0);
22832 +int vc_enter_space(struct vx_info *vxi, void __user *data)
22834 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22836 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22839 + if (vc_data.index >= VX_SPACES)
22842 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
22845 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
22847 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22849 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22852 + return vx_set_space(vxi, vc_data.mask, 0);
22855 +int vc_set_space(struct vx_info *vxi, void __user *data)
22857 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22859 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22862 + if (vc_data.index >= VX_SPACES)
22865 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
22868 +int vc_get_space_mask(void __user *data, int type)
22870 + const struct vcmd_space_mask_v1 *mask;
22873 + mask = &space_mask_v0;
22874 + else if (type == 1)
22875 + mask = &space_mask;
22877 + mask = &default_space_mask;
22879 + vxdprintk(VXD_CBIT(space, 10),
22880 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
22882 + if (copy_to_user(data, mask, sizeof(*mask)))
22887 diff -NurpP --minimal linux-3.2.5/kernel/vserver/switch.c linux-3.2.5-vs2.3.2.6/kernel/vserver/switch.c
22888 --- linux-3.2.5/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
22889 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/switch.c 2011-12-05 19:33:02.000000000 +0100
22892 + * linux/kernel/vserver/switch.c
22894 + * Virtual Server: Syscall Switch
22896 + * Copyright (C) 2003-2011 Herbert Pötzl
22898 + * V0.01 syscall switch
22899 + * V0.02 added signal to context
22900 + * V0.03 added rlimit functions
22901 + * V0.04 added iattr, task/xid functions
22902 + * V0.05 added debug/history stuff
22903 + * V0.06 added compat32 layer
22904 + * V0.07 vcmd args and perms
22905 + * V0.08 added status commands
22906 + * V0.09 added tag commands
22907 + * V0.10 added oom bias
22908 + * V0.11 added device commands
22909 + * V0.12 added warn mask
22913 +#include <linux/vs_context.h>
22914 +#include <linux/vs_network.h>
22915 +#include <linux/vserver/switch.h>
22917 +#include "vci_config.h"
22921 +int vc_get_version(uint32_t id)
22923 + return VCI_VERSION;
22927 +int vc_get_vci(uint32_t id)
22929 + return vci_kernel_config();
22932 +#include <linux/vserver/context_cmd.h>
22933 +#include <linux/vserver/cvirt_cmd.h>
22934 +#include <linux/vserver/cacct_cmd.h>
22935 +#include <linux/vserver/limit_cmd.h>
22936 +#include <linux/vserver/network_cmd.h>
22937 +#include <linux/vserver/sched_cmd.h>
22938 +#include <linux/vserver/debug_cmd.h>
22939 +#include <linux/vserver/inode_cmd.h>
22940 +#include <linux/vserver/dlimit_cmd.h>
22941 +#include <linux/vserver/signal_cmd.h>
22942 +#include <linux/vserver/space_cmd.h>
22943 +#include <linux/vserver/tag_cmd.h>
22944 +#include <linux/vserver/device_cmd.h>
22946 +#include <linux/vserver/inode.h>
22947 +#include <linux/vserver/dlimit.h>
22950 +#ifdef CONFIG_COMPAT
22951 +#define __COMPAT(name, id, data, compat) \
22952 + (compat) ? name ## _x32(id, data) : name(id, data)
22953 +#define __COMPAT_NO_ID(name, data, compat) \
22954 + (compat) ? name ## _x32(data) : name(data)
22956 +#define __COMPAT(name, id, data, compat) \
22958 +#define __COMPAT_NO_ID(name, data, compat) \
22964 +long do_vcmd(uint32_t cmd, uint32_t id,
22965 + struct vx_info *vxi, struct nx_info *nxi,
22966 + void __user *data, int compat)
22970 + case VCMD_get_version:
22971 + return vc_get_version(id);
22972 + case VCMD_get_vci:
22973 + return vc_get_vci(id);
22975 + case VCMD_task_xid:
22976 + return vc_task_xid(id);
22977 + case VCMD_vx_info:
22978 + return vc_vx_info(vxi, data);
22980 + case VCMD_task_nid:
22981 + return vc_task_nid(id);
22982 + case VCMD_nx_info:
22983 + return vc_nx_info(nxi, data);
22985 + case VCMD_task_tag:
22986 + return vc_task_tag(id);
22988 + case VCMD_set_space_v1:
22989 + return vc_set_space_v1(vxi, data);
22990 + /* this is version 2 */
22991 + case VCMD_set_space:
22992 + return vc_set_space(vxi, data);
22994 + case VCMD_get_space_mask_v0:
22995 + return vc_get_space_mask(data, 0);
22996 + /* this is version 1 */
22997 + case VCMD_get_space_mask:
22998 + return vc_get_space_mask(data, 1);
23000 + case VCMD_get_space_default:
23001 + return vc_get_space_mask(data, -1);
23003 + case VCMD_set_umask:
23004 + return vc_set_umask(vxi, data);
23006 + case VCMD_get_umask:
23007 + return vc_get_umask(vxi, data);
23009 + case VCMD_set_wmask:
23010 + return vc_set_wmask(vxi, data);
23012 + case VCMD_get_wmask:
23013 + return vc_get_wmask(vxi, data);
23014 +#ifdef CONFIG_IA32_EMULATION
23015 + case VCMD_get_rlimit:
23016 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23017 + case VCMD_set_rlimit:
23018 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23020 + case VCMD_get_rlimit:
23021 + return vc_get_rlimit(vxi, data);
23022 + case VCMD_set_rlimit:
23023 + return vc_set_rlimit(vxi, data);
23025 + case VCMD_get_rlimit_mask:
23026 + return vc_get_rlimit_mask(id, data);
23027 + case VCMD_reset_hits:
23028 + return vc_reset_hits(vxi, data);
23029 + case VCMD_reset_minmax:
23030 + return vc_reset_minmax(vxi, data);
23032 + case VCMD_get_vhi_name:
23033 + return vc_get_vhi_name(vxi, data);
23034 + case VCMD_set_vhi_name:
23035 + return vc_set_vhi_name(vxi, data);
23037 + case VCMD_ctx_stat:
23038 + return vc_ctx_stat(vxi, data);
23039 + case VCMD_virt_stat:
23040 + return vc_virt_stat(vxi, data);
23041 + case VCMD_sock_stat:
23042 + return vc_sock_stat(vxi, data);
23043 + case VCMD_rlimit_stat:
23044 + return vc_rlimit_stat(vxi, data);
23046 + case VCMD_set_cflags:
23047 + return vc_set_cflags(vxi, data);
23048 + case VCMD_get_cflags:
23049 + return vc_get_cflags(vxi, data);
23051 + /* this is version 1 */
23052 + case VCMD_set_ccaps:
23053 + return vc_set_ccaps(vxi, data);
23054 + /* this is version 1 */
23055 + case VCMD_get_ccaps:
23056 + return vc_get_ccaps(vxi, data);
23057 + case VCMD_set_bcaps:
23058 + return vc_set_bcaps(vxi, data);
23059 + case VCMD_get_bcaps:
23060 + return vc_get_bcaps(vxi, data);
23062 + case VCMD_set_badness:
23063 + return vc_set_badness(vxi, data);
23064 + case VCMD_get_badness:
23065 + return vc_get_badness(vxi, data);
23067 + case VCMD_set_nflags:
23068 + return vc_set_nflags(nxi, data);
23069 + case VCMD_get_nflags:
23070 + return vc_get_nflags(nxi, data);
23072 + case VCMD_set_ncaps:
23073 + return vc_set_ncaps(nxi, data);
23074 + case VCMD_get_ncaps:
23075 + return vc_get_ncaps(nxi, data);
23077 + case VCMD_set_prio_bias:
23078 + return vc_set_prio_bias(vxi, data);
23079 + case VCMD_get_prio_bias:
23080 + return vc_get_prio_bias(vxi, data);
23081 + case VCMD_add_dlimit:
23082 + return __COMPAT(vc_add_dlimit, id, data, compat);
23083 + case VCMD_rem_dlimit:
23084 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23085 + case VCMD_set_dlimit:
23086 + return __COMPAT(vc_set_dlimit, id, data, compat);
23087 + case VCMD_get_dlimit:
23088 + return __COMPAT(vc_get_dlimit, id, data, compat);
23090 + case VCMD_ctx_kill:
23091 + return vc_ctx_kill(vxi, data);
23093 + case VCMD_wait_exit:
23094 + return vc_wait_exit(vxi, data);
23096 + case VCMD_get_iattr:
23097 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23098 + case VCMD_set_iattr:
23099 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23101 + case VCMD_fget_iattr:
23102 + return vc_fget_iattr(id, data);
23103 + case VCMD_fset_iattr:
23104 + return vc_fset_iattr(id, data);
23106 + case VCMD_enter_space_v0:
23107 + return vc_enter_space_v1(vxi, NULL);
23108 + case VCMD_enter_space_v1:
23109 + return vc_enter_space_v1(vxi, data);
23110 + /* this is version 2 */
23111 + case VCMD_enter_space:
23112 + return vc_enter_space(vxi, data);
23114 + case VCMD_ctx_create_v0:
23115 + return vc_ctx_create(id, NULL);
23116 + case VCMD_ctx_create:
23117 + return vc_ctx_create(id, data);
23118 + case VCMD_ctx_migrate_v0:
23119 + return vc_ctx_migrate(vxi, NULL);
23120 + case VCMD_ctx_migrate:
23121 + return vc_ctx_migrate(vxi, data);
23123 + case VCMD_net_create_v0:
23124 + return vc_net_create(id, NULL);
23125 + case VCMD_net_create:
23126 + return vc_net_create(id, data);
23127 + case VCMD_net_migrate:
23128 + return vc_net_migrate(nxi, data);
23130 + case VCMD_tag_migrate:
23131 + return vc_tag_migrate(id);
23133 + case VCMD_net_add:
23134 + return vc_net_add(nxi, data);
23135 + case VCMD_net_remove:
23136 + return vc_net_remove(nxi, data);
23138 + case VCMD_net_add_ipv4_v1:
23139 + return vc_net_add_ipv4_v1(nxi, data);
23140 + /* this is version 2 */
23141 + case VCMD_net_add_ipv4:
23142 + return vc_net_add_ipv4(nxi, data);
23144 + case VCMD_net_rem_ipv4_v1:
23145 + return vc_net_rem_ipv4_v1(nxi, data);
23146 + /* this is version 2 */
23147 + case VCMD_net_rem_ipv4:
23148 + return vc_net_rem_ipv4(nxi, data);
23149 +#ifdef CONFIG_IPV6
23150 + case VCMD_net_add_ipv6:
23151 + return vc_net_add_ipv6(nxi, data);
23152 + case VCMD_net_remove_ipv6:
23153 + return vc_net_remove_ipv6(nxi, data);
23155 +/* case VCMD_add_match_ipv4:
23156 + return vc_add_match_ipv4(nxi, data);
23157 + case VCMD_get_match_ipv4:
23158 + return vc_get_match_ipv4(nxi, data);
23159 +#ifdef CONFIG_IPV6
23160 + case VCMD_add_match_ipv6:
23161 + return vc_add_match_ipv6(nxi, data);
23162 + case VCMD_get_match_ipv6:
23163 + return vc_get_match_ipv6(nxi, data);
23166 +#ifdef CONFIG_VSERVER_DEVICE
23167 + case VCMD_set_mapping:
23168 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23169 + case VCMD_unset_mapping:
23170 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23172 +#ifdef CONFIG_VSERVER_HISTORY
23173 + case VCMD_dump_history:
23174 + return vc_dump_history(id);
23175 + case VCMD_read_history:
23176 + return __COMPAT(vc_read_history, id, data, compat);
23179 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23180 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23186 +#define __VCMD(vcmd, _perm, _args, _flags) \
23187 + case VCMD_ ## vcmd: perm = _perm; \
23188 + args = _args; flags = _flags; break
23191 +#define VCA_NONE 0x00
23192 +#define VCA_VXI 0x01
23193 +#define VCA_NXI 0x02
23195 +#define VCF_NONE 0x00
23196 +#define VCF_INFO 0x01
23197 +#define VCF_ADMIN 0x02
23198 +#define VCF_ARES 0x06 /* includes admin */
23199 +#define VCF_SETUP 0x08
23201 +#define VCF_ZIDOK 0x10 /* zero id okay */
23205 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23208 + int permit = -1, state = 0;
23209 + int perm = -1, args = 0, flags = 0;
23210 + struct vx_info *vxi = NULL;
23211 + struct nx_info *nxi = NULL;
23214 + /* unpriviledged commands */
23215 + __VCMD(get_version, 0, VCA_NONE, 0);
23216 + __VCMD(get_vci, 0, VCA_NONE, 0);
23217 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23218 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23219 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23220 + __VCMD(get_space_default,0, VCA_NONE, 0);
23222 + /* info commands */
23223 + __VCMD(task_xid, 2, VCA_NONE, 0);
23224 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23225 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23226 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23227 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23228 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23229 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23230 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23231 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23232 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23233 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23234 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23236 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23237 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23238 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23239 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23241 + __VCMD(task_nid, 2, VCA_NONE, 0);
23242 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23243 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23244 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23246 + __VCMD(task_tag, 2, VCA_NONE, 0);
23248 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23249 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23250 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23251 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23253 + /* lower admin commands */
23254 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23255 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23256 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23257 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23258 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23259 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23260 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23261 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23263 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23264 + __VCMD(net_create, 5, VCA_NONE, 0);
23265 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23267 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23269 + /* higher admin commands */
23270 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23271 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23272 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23274 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23275 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23276 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23277 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23278 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23279 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23281 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23282 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23283 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23285 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23286 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23287 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23288 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23289 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23290 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23291 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23292 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23293 +#ifdef CONFIG_IPV6
23294 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23295 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23297 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23298 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23299 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23300 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23301 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23303 +#ifdef CONFIG_VSERVER_DEVICE
23304 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23305 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23307 + /* debug level admin commands */
23308 +#ifdef CONFIG_VSERVER_HISTORY
23309 + __VCMD(dump_history, 9, VCA_NONE, 0);
23310 + __VCMD(read_history, 9, VCA_NONE, 0);
23317 + vxdprintk(VXD_CBIT(switch, 0),
23318 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23319 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23320 + VC_VERSION(cmd), id, data, compat,
23321 + perm, args, flags);
23328 + if (!capable(CAP_CONTEXT))
23332 + /* moved here from the individual commands */
23334 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23338 + /* vcmd involves resource management */
23340 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23344 + /* various legacy exceptions */
23346 + /* will go away when spectator is a cap */
23347 + case VCMD_ctx_migrate_v0:
23348 + case VCMD_ctx_migrate:
23350 + current->xid = 1;
23356 + /* will go away when spectator is a cap */
23357 + case VCMD_net_migrate:
23359 + current->nid = 1;
23366 + /* vcmds are fine by default */
23369 + /* admin type vcmds require admin ... */
23370 + if (flags & VCF_ADMIN)
23371 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23373 + /* ... but setup type vcmds override that */
23374 + if (!permit && (flags & VCF_SETUP))
23375 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23383 + if (!id && (flags & VCF_ZIDOK))
23387 + if (args & VCA_VXI) {
23388 + vxi = lookup_vx_info(id);
23392 + if ((flags & VCF_ADMIN) &&
23393 + /* special case kill for shutdown */
23394 + (cmd != VCMD_ctx_kill) &&
23395 + /* can context be administrated? */
23396 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23402 + if (args & VCA_NXI) {
23403 + nxi = lookup_nx_info(id);
23407 + if ((flags & VCF_ADMIN) &&
23408 + /* can context be administrated? */
23409 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23416 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23419 + if ((args & VCA_NXI) && nxi)
23420 + put_nx_info(nxi);
23422 + if ((args & VCA_VXI) && vxi)
23423 + put_vx_info(vxi);
23425 + vxdprintk(VXD_CBIT(switch, 1),
23426 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23427 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23428 + VC_VERSION(cmd), ret, ret, state, permit);
23433 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23435 + return do_vserver(cmd, id, data, 0);
23438 +#ifdef CONFIG_COMPAT
23441 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23443 + return do_vserver(cmd, id, data, 1);
23446 +#endif /* CONFIG_COMPAT */
23447 diff -NurpP --minimal linux-3.2.5/kernel/vserver/sysctl.c linux-3.2.5-vs2.3.2.6/kernel/vserver/sysctl.c
23448 --- linux-3.2.5/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23449 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/sysctl.c 2011-12-05 19:33:02.000000000 +0100
23452 + * kernel/vserver/sysctl.c
23454 + * Virtual Context Support
23456 + * Copyright (C) 2004-2007 Herbert Pötzl
23458 + * V0.01 basic structure
23462 +#include <linux/module.h>
23463 +#include <linux/ctype.h>
23464 +#include <linux/sysctl.h>
23465 +#include <linux/parser.h>
23466 +#include <asm/uaccess.h>
23469 + CTL_DEBUG_ERROR = 0,
23470 + CTL_DEBUG_SWITCH = 1,
23486 +unsigned int vs_debug_switch = 0;
23487 +unsigned int vs_debug_xid = 0;
23488 +unsigned int vs_debug_nid = 0;
23489 +unsigned int vs_debug_tag = 0;
23490 +unsigned int vs_debug_net = 0;
23491 +unsigned int vs_debug_limit = 0;
23492 +unsigned int vs_debug_cres = 0;
23493 +unsigned int vs_debug_dlim = 0;
23494 +unsigned int vs_debug_quota = 0;
23495 +unsigned int vs_debug_cvirt = 0;
23496 +unsigned int vs_debug_space = 0;
23497 +unsigned int vs_debug_perm = 0;
23498 +unsigned int vs_debug_misc = 0;
23501 +static struct ctl_table_header *vserver_table_header;
23502 +static ctl_table vserver_root_table[];
23505 +void vserver_register_sysctl(void)
23507 + if (!vserver_table_header) {
23508 + vserver_table_header = register_sysctl_table(vserver_root_table);
23513 +void vserver_unregister_sysctl(void)
23515 + if (vserver_table_header) {
23516 + unregister_sysctl_table(vserver_table_header);
23517 + vserver_table_header = NULL;
23522 +static int proc_dodebug(ctl_table *table, int write,
23523 + void __user *buffer, size_t *lenp, loff_t *ppos)
23525 + char tmpbuf[20], *p, c;
23526 + unsigned int value;
23527 + size_t left, len;
23529 + if ((*ppos && !write) || !*lenp) {
23537 + if (!access_ok(VERIFY_READ, buffer, left))
23539 + p = (char *)buffer;
23540 + while (left && __get_user(c, p) >= 0 && isspace(c))
23545 + if (left > sizeof(tmpbuf) - 1)
23547 + if (copy_from_user(tmpbuf, p, left))
23549 + tmpbuf[left] = '\0';
23551 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23552 + value = 10 * value + (*p - '0');
23553 + if (*p && !isspace(*p))
23555 + while (left && isspace(*p))
23557 + *(unsigned int *)table->data = value;
23559 + if (!access_ok(VERIFY_WRITE, buffer, left))
23561 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23564 + if (__copy_to_user(buffer, tmpbuf, len))
23566 + if ((left -= len) > 0) {
23567 + if (put_user('\n', (char *)buffer + len))
23581 +#define CTL_ENTRY(ctl, name) \
23583 + .procname = #name, \
23584 + .data = &vs_ ## name, \
23585 + .maxlen = sizeof(int), \
23587 + .proc_handler = &proc_dodebug, \
23588 + .extra1 = &zero, \
23589 + .extra2 = &zero, \
23592 +static ctl_table vserver_debug_table[] = {
23593 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23594 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23595 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23596 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23597 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23598 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23599 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23600 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23601 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23602 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23603 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23604 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23605 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23609 +static ctl_table vserver_root_table[] = {
23611 + .procname = "vserver",
23613 + .child = vserver_debug_table
23619 +static match_table_t tokens = {
23620 + { CTL_DEBUG_SWITCH, "switch=%x" },
23621 + { CTL_DEBUG_XID, "xid=%x" },
23622 + { CTL_DEBUG_NID, "nid=%x" },
23623 + { CTL_DEBUG_TAG, "tag=%x" },
23624 + { CTL_DEBUG_NET, "net=%x" },
23625 + { CTL_DEBUG_LIMIT, "limit=%x" },
23626 + { CTL_DEBUG_CRES, "cres=%x" },
23627 + { CTL_DEBUG_DLIM, "dlim=%x" },
23628 + { CTL_DEBUG_QUOTA, "quota=%x" },
23629 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23630 + { CTL_DEBUG_SPACE, "space=%x" },
23631 + { CTL_DEBUG_PERM, "perm=%x" },
23632 + { CTL_DEBUG_MISC, "misc=%x" },
23633 + { CTL_DEBUG_ERROR, NULL }
23636 +#define HANDLE_CASE(id, name, val) \
23637 + case CTL_DEBUG_ ## id: \
23638 + vs_debug_ ## name = val; \
23639 + printk("vs_debug_" #name "=0x%x\n", val); \
23643 +static int __init vs_debug_setup(char *str)
23648 + printk("vs_debug_setup(%s)\n", str);
23649 + while ((p = strsep(&str, ",")) != NULL) {
23650 + substring_t args[MAX_OPT_ARGS];
23651 + unsigned int value;
23656 + token = match_token(p, tokens, args);
23657 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23660 + HANDLE_CASE(SWITCH, switch, value);
23661 + HANDLE_CASE(XID, xid, value);
23662 + HANDLE_CASE(NID, nid, value);
23663 + HANDLE_CASE(TAG, tag, value);
23664 + HANDLE_CASE(NET, net, value);
23665 + HANDLE_CASE(LIMIT, limit, value);
23666 + HANDLE_CASE(CRES, cres, value);
23667 + HANDLE_CASE(DLIM, dlim, value);
23668 + HANDLE_CASE(QUOTA, quota, value);
23669 + HANDLE_CASE(CVIRT, cvirt, value);
23670 + HANDLE_CASE(SPACE, space, value);
23671 + HANDLE_CASE(PERM, perm, value);
23672 + HANDLE_CASE(MISC, misc, value);
23681 +__setup("vsdebug=", vs_debug_setup);
23685 +EXPORT_SYMBOL_GPL(vs_debug_switch);
23686 +EXPORT_SYMBOL_GPL(vs_debug_xid);
23687 +EXPORT_SYMBOL_GPL(vs_debug_nid);
23688 +EXPORT_SYMBOL_GPL(vs_debug_net);
23689 +EXPORT_SYMBOL_GPL(vs_debug_limit);
23690 +EXPORT_SYMBOL_GPL(vs_debug_cres);
23691 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
23692 +EXPORT_SYMBOL_GPL(vs_debug_quota);
23693 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
23694 +EXPORT_SYMBOL_GPL(vs_debug_space);
23695 +EXPORT_SYMBOL_GPL(vs_debug_perm);
23696 +EXPORT_SYMBOL_GPL(vs_debug_misc);
23698 diff -NurpP --minimal linux-3.2.5/kernel/vserver/tag.c linux-3.2.5-vs2.3.2.6/kernel/vserver/tag.c
23699 --- linux-3.2.5/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
23700 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/tag.c 2011-12-05 19:33:02.000000000 +0100
23703 + * linux/kernel/vserver/tag.c
23705 + * Virtual Server: Shallow Tag Space
23707 + * Copyright (C) 2007 Herbert Pötzl
23709 + * V0.01 basic implementation
23713 +#include <linux/sched.h>
23714 +#include <linux/vserver/debug.h>
23715 +#include <linux/vs_pid.h>
23716 +#include <linux/vs_tag.h>
23718 +#include <linux/vserver/tag_cmd.h>
23721 +int dx_migrate_task(struct task_struct *p, tag_t tag)
23726 + vxdprintk(VXD_CBIT(tag, 5),
23727 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23733 + vxdprintk(VXD_CBIT(tag, 5),
23734 + "moved task %p into [#%d]", p, tag);
23738 +/* vserver syscall commands below here */
23740 +/* taks xid and vx_info functions */
23743 +int vc_task_tag(uint32_t id)
23748 + struct task_struct *tsk;
23750 + tsk = find_task_by_real_pid(id);
23751 + tag = (tsk) ? tsk->tag : -ESRCH;
23752 + rcu_read_unlock();
23754 + tag = dx_current_tag();
23759 +int vc_tag_migrate(uint32_t tag)
23761 + return dx_migrate_task(current, tag & 0xFFFF);
23765 diff -NurpP --minimal linux-3.2.5/kernel/vserver/vci_config.h linux-3.2.5-vs2.3.2.6/kernel/vserver/vci_config.h
23766 --- linux-3.2.5/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
23767 +++ linux-3.2.5-vs2.3.2.6/kernel/vserver/vci_config.h 2011-12-05 19:33:02.000000000 +0100
23770 +/* interface version */
23772 +#define VCI_VERSION 0x00020308
23776 + VCI_KCBIT_NO_DYNAMIC = 0,
23778 + VCI_KCBIT_PROC_SECURE = 4,
23779 + /* VCI_KCBIT_HARDCPU = 5, */
23780 + /* VCI_KCBIT_IDLELIMIT = 6, */
23781 + /* VCI_KCBIT_IDLETIME = 7, */
23783 + VCI_KCBIT_COWBL = 8,
23784 + VCI_KCBIT_FULLCOWBL = 9,
23785 + VCI_KCBIT_SPACES = 10,
23786 + VCI_KCBIT_NETV2 = 11,
23787 + VCI_KCBIT_MEMCG = 12,
23789 + VCI_KCBIT_DEBUG = 16,
23790 + VCI_KCBIT_HISTORY = 20,
23791 + VCI_KCBIT_TAGGED = 24,
23792 + VCI_KCBIT_PPTAG = 28,
23794 + VCI_KCBIT_MORE = 31,
23798 +static inline uint32_t vci_kernel_config(void)
23801 + (1 << VCI_KCBIT_NO_DYNAMIC) |
23803 + /* configured features */
23804 +#ifdef CONFIG_VSERVER_PROC_SECURE
23805 + (1 << VCI_KCBIT_PROC_SECURE) |
23807 +#ifdef CONFIG_VSERVER_COWBL
23808 + (1 << VCI_KCBIT_COWBL) |
23809 + (1 << VCI_KCBIT_FULLCOWBL) |
23811 + (1 << VCI_KCBIT_SPACES) |
23812 + (1 << VCI_KCBIT_NETV2) |
23813 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
23814 + (1 << VCI_KCBIT_MEMCG) |
23817 + /* debug options */
23818 +#ifdef CONFIG_VSERVER_DEBUG
23819 + (1 << VCI_KCBIT_DEBUG) |
23821 +#ifdef CONFIG_VSERVER_HISTORY
23822 + (1 << VCI_KCBIT_HISTORY) |
23825 + /* inode context tagging */
23826 +#if defined(CONFIG_TAGGING_NONE)
23827 + (0 << VCI_KCBIT_TAGGED) |
23828 +#elif defined(CONFIG_TAGGING_UID16)
23829 + (1 << VCI_KCBIT_TAGGED) |
23830 +#elif defined(CONFIG_TAGGING_GID16)
23831 + (2 << VCI_KCBIT_TAGGED) |
23832 +#elif defined(CONFIG_TAGGING_ID24)
23833 + (3 << VCI_KCBIT_TAGGED) |
23834 +#elif defined(CONFIG_TAGGING_INTERN)
23835 + (4 << VCI_KCBIT_TAGGED) |
23836 +#elif defined(CONFIG_TAGGING_RUNTIME)
23837 + (5 << VCI_KCBIT_TAGGED) |
23839 + (7 << VCI_KCBIT_TAGGED) |
23841 + (1 << VCI_KCBIT_PPTAG) |
23845 diff -NurpP --minimal linux-3.2.5/mm/memcontrol.c linux-3.2.5-vs2.3.2.6/mm/memcontrol.c
23846 --- linux-3.2.5/mm/memcontrol.c 2012-02-07 01:57:55.000000000 +0100
23847 +++ linux-3.2.5-vs2.3.2.6/mm/memcontrol.c 2012-01-26 08:52:10.000000000 +0100
23848 @@ -766,6 +766,31 @@ struct mem_cgroup *mem_cgroup_from_task(
23849 struct mem_cgroup, css);
23852 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
23854 + return res_counter_read_u64(&mem->res, member);
23857 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
23859 + return res_counter_read_u64(&mem->memsw, member);
23862 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
23864 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
23867 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
23869 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
23872 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
23874 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
23877 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
23879 struct mem_cgroup *memcg = NULL;
23880 diff -NurpP --minimal linux-3.2.5/mm/oom_kill.c linux-3.2.5-vs2.3.2.6/mm/oom_kill.c
23881 --- linux-3.2.5/mm/oom_kill.c 2012-01-09 16:15:00.000000000 +0100
23882 +++ linux-3.2.5-vs2.3.2.6/mm/oom_kill.c 2012-01-09 16:19:31.000000000 +0100
23884 #include <linux/security.h>
23885 #include <linux/ptrace.h>
23886 #include <linux/freezer.h>
23887 +#include <linux/reboot.h>
23888 +#include <linux/vs_context.h>
23890 int sysctl_panic_on_oom;
23891 int sysctl_oom_kill_allocating_task;
23892 @@ -148,11 +150,18 @@ struct task_struct *find_lock_task_mm(st
23893 static bool oom_unkillable_task(struct task_struct *p,
23894 const struct mem_cgroup *mem, const nodemask_t *nodemask)
23896 - if (is_global_init(p))
23897 + unsigned xid = vx_current_xid();
23899 + /* skip the init task, global and per guest */
23900 + if (task_is_init(p))
23902 if (p->flags & PF_KTHREAD)
23905 + /* skip other guest and host processes if oom in guest */
23906 + if (xid && vx_task_xid(p) != xid)
23909 /* When mem_cgroup_out_of_memory() and p is not member of the group */
23910 if (mem && !task_in_mem_cgroup(p, mem))
23912 @@ -440,8 +449,8 @@ static int oom_kill_task(struct task_str
23913 /* mm cannot be safely dereferenced after task_unlock(p) */
23916 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23917 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
23918 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23919 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
23920 K(get_mm_counter(p->mm, MM_ANONPAGES)),
23921 K(get_mm_counter(p->mm, MM_FILEPAGES)));
23923 @@ -499,8 +508,8 @@ static int oom_kill_process(struct task_
23927 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
23928 - message, task_pid_nr(p), p->comm, points);
23929 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
23930 + message, task_pid_nr(p), p->xid, p->comm, points);
23934 @@ -601,6 +610,8 @@ int unregister_oom_notifier(struct notif
23936 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
23938 +long vs_oom_action(unsigned int);
23941 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
23942 * if a parallel OOM killing is already taking place that includes a zone in
23943 @@ -759,7 +770,12 @@ retry:
23945 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
23946 read_unlock(&tasklist_lock);
23947 - panic("Out of memory and no killable processes...\n");
23949 + /* avoid panic for guest OOM */
23950 + if (current->xid)
23951 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
23953 + panic("Out of memory and no killable processes...\n");
23956 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
23957 diff -NurpP --minimal linux-3.2.5/mm/page_alloc.c linux-3.2.5-vs2.3.2.6/mm/page_alloc.c
23958 --- linux-3.2.5/mm/page_alloc.c 2012-02-07 01:57:55.000000000 +0100
23959 +++ linux-3.2.5-vs2.3.2.6/mm/page_alloc.c 2012-01-26 08:52:10.000000000 +0100
23961 #include <linux/ftrace_event.h>
23962 #include <linux/memcontrol.h>
23963 #include <linux/prefetch.h>
23964 +#include <linux/vs_base.h>
23965 +#include <linux/vs_limit.h>
23967 #include <asm/tlbflush.h>
23968 #include <asm/div64.h>
23969 @@ -2491,6 +2493,9 @@ void si_meminfo(struct sysinfo *val)
23970 val->totalhigh = totalhigh_pages;
23971 val->freehigh = nr_free_highpages();
23972 val->mem_unit = PAGE_SIZE;
23974 + if (vx_flags(VXF_VIRT_MEM, 0))
23975 + vx_vsi_meminfo(val);
23978 EXPORT_SYMBOL(si_meminfo);
23979 @@ -2511,6 +2516,9 @@ void si_meminfo_node(struct sysinfo *val
23982 val->mem_unit = PAGE_SIZE;
23984 + if (vx_flags(VXF_VIRT_MEM, 0))
23985 + vx_vsi_meminfo(val);
23989 diff -NurpP --minimal linux-3.2.5/mm/pgtable-generic.c linux-3.2.5-vs2.3.2.6/mm/pgtable-generic.c
23990 --- linux-3.2.5/mm/pgtable-generic.c 2011-03-15 18:07:42.000000000 +0100
23991 +++ linux-3.2.5-vs2.3.2.6/mm/pgtable-generic.c 2011-12-05 19:33:02.000000000 +0100
23993 * Copyright (C) 2010 Linus Torvalds
23996 +#include <linux/mm.h>
23998 #include <linux/pagemap.h>
23999 #include <asm/tlb.h>
24000 #include <asm-generic/pgtable.h>
24001 diff -NurpP --minimal linux-3.2.5/mm/shmem.c linux-3.2.5-vs2.3.2.6/mm/shmem.c
24002 --- linux-3.2.5/mm/shmem.c 2012-02-07 01:57:55.000000000 +0100
24003 +++ linux-3.2.5-vs2.3.2.6/mm/shmem.c 2012-01-26 08:52:10.000000000 +0100
24004 @@ -1460,7 +1460,7 @@ static int shmem_statfs(struct dentry *d
24006 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24008 - buf->f_type = TMPFS_MAGIC;
24009 + buf->f_type = TMPFS_SUPER_MAGIC;
24010 buf->f_bsize = PAGE_CACHE_SIZE;
24011 buf->f_namelen = NAME_MAX;
24012 if (sbinfo->max_blocks) {
24013 @@ -2217,7 +2217,7 @@ int shmem_fill_super(struct super_block
24014 sb->s_maxbytes = MAX_LFS_FILESIZE;
24015 sb->s_blocksize = PAGE_CACHE_SIZE;
24016 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24017 - sb->s_magic = TMPFS_MAGIC;
24018 + sb->s_magic = TMPFS_SUPER_MAGIC;
24019 sb->s_op = &shmem_ops;
24020 sb->s_time_gran = 1;
24021 #ifdef CONFIG_TMPFS_XATTR
24022 diff -NurpP --minimal linux-3.2.5/mm/slab.c linux-3.2.5-vs2.3.2.6/mm/slab.c
24023 --- linux-3.2.5/mm/slab.c 2012-01-09 16:15:00.000000000 +0100
24024 +++ linux-3.2.5-vs2.3.2.6/mm/slab.c 2011-12-15 01:11:34.000000000 +0100
24025 @@ -411,6 +411,8 @@ static void kmem_list3_init(struct kmem_
24026 #define STATS_INC_FREEMISS(x) do { } while (0)
24029 +#include "slab_vs.h"
24034 @@ -3397,6 +3399,7 @@ retry:
24036 obj = slab_get_obj(cachep, slabp, nodeid);
24037 check_slabp(cachep, slabp);
24038 + vx_slab_alloc(cachep, flags);
24039 l3->free_objects--;
24040 /* move slabp to correct slabp list: */
24041 list_del(&slabp->list);
24042 @@ -3474,6 +3477,7 @@ __cache_alloc_node(struct kmem_cache *ca
24043 /* ___cache_alloc_node can fall back to other nodes */
24044 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24046 + vx_slab_alloc(cachep, flags);
24047 local_irq_restore(save_flags);
24048 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24049 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24050 @@ -3661,6 +3665,7 @@ static inline void __cache_free(struct k
24052 kmemleak_free_recursive(objp, cachep->flags);
24053 objp = cache_free_debugcheck(cachep, objp, caller);
24054 + vx_slab_free(cachep);
24056 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24058 diff -NurpP --minimal linux-3.2.5/mm/slab_vs.h linux-3.2.5-vs2.3.2.6/mm/slab_vs.h
24059 --- linux-3.2.5/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24060 +++ linux-3.2.5-vs2.3.2.6/mm/slab_vs.h 2011-12-05 19:33:02.000000000 +0100
24063 +#include <linux/vserver/context.h>
24065 +#include <linux/vs_context.h>
24068 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24070 + int what = gfp_zone(cachep->gfpflags);
24071 + struct vx_info *vxi = current_vx_info();
24076 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24080 +void vx_slab_free(struct kmem_cache *cachep)
24082 + int what = gfp_zone(cachep->gfpflags);
24083 + struct vx_info *vxi = current_vx_info();
24088 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24091 diff -NurpP --minimal linux-3.2.5/mm/swapfile.c linux-3.2.5-vs2.3.2.6/mm/swapfile.c
24092 --- linux-3.2.5/mm/swapfile.c 2012-01-09 16:15:00.000000000 +0100
24093 +++ linux-3.2.5-vs2.3.2.6/mm/swapfile.c 2011-12-15 01:52:28.000000000 +0100
24095 #include <asm/tlbflush.h>
24096 #include <linux/swapops.h>
24097 #include <linux/page_cgroup.h>
24098 +#include <linux/vs_base.h>
24100 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24102 @@ -1753,6 +1754,16 @@ static int swap_show(struct seq_file *sw
24104 if (si == SEQ_START_TOKEN) {
24105 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24106 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24107 + struct sysinfo si;
24109 + vx_vsi_swapinfo(&si);
24110 + if (si.totalswap < (1 << 10))
24112 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24113 + "hdv0", "partition", si.totalswap >> 10,
24114 + (si.totalswap - si.freeswap) >> 10, -1);
24119 @@ -2176,6 +2187,8 @@ void si_swapinfo(struct sysinfo *val)
24120 val->freeswap = nr_swap_pages + nr_to_be_unused;
24121 val->totalswap = total_swap_pages + nr_to_be_unused;
24122 spin_unlock(&swap_lock);
24123 + if (vx_flags(VXF_VIRT_MEM, 0))
24124 + vx_vsi_swapinfo(val);
24128 diff -NurpP --minimal linux-3.2.5/net/bridge/br_multicast.c linux-3.2.5-vs2.3.2.6/net/bridge/br_multicast.c
24129 --- linux-3.2.5/net/bridge/br_multicast.c 2012-01-09 16:15:03.000000000 +0100
24130 +++ linux-3.2.5-vs2.3.2.6/net/bridge/br_multicast.c 2011-12-05 19:33:02.000000000 +0100
24131 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
24132 ip6h->hop_limit = 1;
24133 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24134 ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24136 + &ip6h->saddr, NULL);
24137 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
24139 hopopt = (u8 *)(ip6h + 1);
24140 diff -NurpP --minimal linux-3.2.5/net/core/dev.c linux-3.2.5-vs2.3.2.6/net/core/dev.c
24141 --- linux-3.2.5/net/core/dev.c 2012-01-09 16:15:03.000000000 +0100
24142 +++ linux-3.2.5-vs2.3.2.6/net/core/dev.c 2011-12-15 01:11:36.000000000 +0100
24143 @@ -127,6 +127,7 @@
24144 #include <linux/in.h>
24145 #include <linux/jhash.h>
24146 #include <linux/random.h>
24147 +#include <linux/vs_inet.h>
24148 #include <trace/events/napi.h>
24149 #include <trace/events/net.h>
24150 #include <trace/events/skb.h>
24151 @@ -623,7 +624,8 @@ struct net_device *__dev_get_by_name(str
24152 struct hlist_head *head = dev_name_hash(net, name);
24154 hlist_for_each_entry(dev, p, head, name_hlist)
24155 - if (!strncmp(dev->name, name, IFNAMSIZ))
24156 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24157 + nx_dev_visible(current_nx_info(), dev))
24161 @@ -649,7 +651,8 @@ struct net_device *dev_get_by_name_rcu(s
24162 struct hlist_head *head = dev_name_hash(net, name);
24164 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24165 - if (!strncmp(dev->name, name, IFNAMSIZ))
24166 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24167 + nx_dev_visible(current_nx_info(), dev))
24171 @@ -700,7 +703,8 @@ struct net_device *__dev_get_by_index(st
24172 struct hlist_head *head = dev_index_hash(net, ifindex);
24174 hlist_for_each_entry(dev, p, head, index_hlist)
24175 - if (dev->ifindex == ifindex)
24176 + if ((dev->ifindex == ifindex) &&
24177 + nx_dev_visible(current_nx_info(), dev))
24181 @@ -718,7 +722,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24182 * about locking. The caller must hold RCU lock.
24185 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24186 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24188 struct hlist_node *p;
24189 struct net_device *dev;
24190 @@ -730,6 +734,16 @@ struct net_device *dev_get_by_index_rcu(
24194 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24196 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24198 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24200 + if (nx_dev_visible(current_nx_info(), dev))
24204 EXPORT_SYMBOL(dev_get_by_index_rcu);
24207 @@ -778,7 +792,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24209 for_each_netdev_rcu(net, dev)
24210 if (dev->type == type &&
24211 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24212 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24213 + nx_dev_visible(current_nx_info(), dev))
24217 @@ -790,9 +805,11 @@ struct net_device *__dev_getfirstbyhwtyp
24218 struct net_device *dev;
24221 - for_each_netdev(net, dev)
24222 - if (dev->type == type)
24223 + for_each_netdev(net, dev) {
24224 + if ((dev->type == type) &&
24225 + nx_dev_visible(current_nx_info(), dev))
24231 @@ -910,6 +927,8 @@ static int __dev_alloc_name(struct net *
24233 if (i < 0 || i >= max_netdevices)
24235 + if (!nx_dev_visible(current_nx_info(), d))
24238 /* avoid cases where sscanf is not exact inverse of printf */
24239 snprintf(buf, IFNAMSIZ, name, i);
24240 @@ -4067,6 +4086,8 @@ static int dev_ifconf(struct net *net, c
24243 for_each_netdev(net, dev) {
24244 + if (!nx_dev_visible(current_nx_info(), dev))
24246 for (i = 0; i < NPROTO; i++) {
24247 if (gifconf_list[i]) {
24249 @@ -4195,6 +4216,10 @@ static void dev_seq_printf_stats(struct
24250 struct rtnl_link_stats64 temp;
24251 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24253 + /* device visible inside network context? */
24254 + if (!nx_dev_visible(current_nx_info(), dev))
24257 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24258 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24259 dev->name, stats->rx_bytes, stats->rx_packets,
24260 diff -NurpP --minimal linux-3.2.5/net/core/rtnetlink.c linux-3.2.5-vs2.3.2.6/net/core/rtnetlink.c
24261 --- linux-3.2.5/net/core/rtnetlink.c 2012-01-09 16:15:03.000000000 +0100
24262 +++ linux-3.2.5-vs2.3.2.6/net/core/rtnetlink.c 2011-12-05 19:33:02.000000000 +0100
24263 @@ -1058,6 +1058,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24264 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
24267 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24269 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24270 NETLINK_CB(cb->skb).pid,
24271 cb->nlh->nlmsg_seq, 0,
24272 @@ -1907,6 +1909,9 @@ void rtmsg_ifinfo(int type, struct net_d
24273 int err = -ENOBUFS;
24274 size_t if_info_size;
24276 + if (!nx_dev_visible(current_nx_info(), dev))
24279 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev)), GFP_KERNEL);
24282 diff -NurpP --minimal linux-3.2.5/net/core/sock.c linux-3.2.5-vs2.3.2.6/net/core/sock.c
24283 --- linux-3.2.5/net/core/sock.c 2012-01-09 16:15:03.000000000 +0100
24284 +++ linux-3.2.5-vs2.3.2.6/net/core/sock.c 2012-01-09 16:19:31.000000000 +0100
24285 @@ -127,6 +127,10 @@
24286 #include <net/cls_cgroup.h>
24288 #include <linux/filter.h>
24289 +#include <linux/vs_socket.h>
24290 +#include <linux/vs_limit.h>
24291 +#include <linux/vs_context.h>
24292 +#include <linux/vs_network.h>
24294 #include <trace/events/sock.h>
24296 @@ -1066,6 +1070,8 @@ static struct sock *sk_prot_alloc(struct
24298 sk_tx_queue_clear(sk);
24300 + sock_vx_init(sk);
24301 + sock_nx_init(sk);
24305 @@ -1165,6 +1171,11 @@ static void __sk_free(struct sock *sk)
24306 put_cred(sk->sk_peer_cred);
24307 put_pid(sk->sk_peer_pid);
24308 put_net(sock_net(sk));
24310 + clr_vx_info(&sk->sk_vx_info);
24312 + clr_nx_info(&sk->sk_nx_info);
24314 sk_prot_free(sk->sk_prot_creator, sk);
24317 @@ -1212,6 +1223,8 @@ struct sock *sk_clone(const struct sock
24320 get_net(sock_net(newsk));
24321 + sock_vx_init(newsk);
24322 + sock_nx_init(newsk);
24323 sk_node_init(&newsk->sk_node);
24324 sock_lock_init(newsk);
24325 bh_lock_sock(newsk);
24326 @@ -1268,6 +1281,12 @@ struct sock *sk_clone(const struct sock
24328 atomic_set(&newsk->sk_refcnt, 2);
24330 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24331 + newsk->sk_xid = sk->sk_xid;
24332 + vx_sock_inc(newsk);
24333 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24334 + newsk->sk_nid = sk->sk_nid;
24337 * Increment the counter in the same struct proto as the master
24338 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24339 @@ -2014,6 +2033,12 @@ void sock_init_data(struct socket *sock,
24341 sk->sk_stamp = ktime_set(-1L, 0);
24343 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24344 + sk->sk_xid = vx_current_xid();
24346 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24347 + sk->sk_nid = nx_current_nid();
24350 * Before updating sk_refcnt, we must commit prior changes to memory
24351 * (Documentation/RCU/rculist_nulls.txt for details)
24352 diff -NurpP --minimal linux-3.2.5/net/ipv4/af_inet.c linux-3.2.5-vs2.3.2.6/net/ipv4/af_inet.c
24353 --- linux-3.2.5/net/ipv4/af_inet.c 2012-01-09 16:15:03.000000000 +0100
24354 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/af_inet.c 2011-12-05 19:33:02.000000000 +0100
24355 @@ -117,6 +117,7 @@
24356 #ifdef CONFIG_IP_MROUTE
24357 #include <linux/mroute.h>
24359 +#include <linux/vs_limit.h>
24362 /* The inetsw table contains everything that inet_create needs to
24363 @@ -326,9 +327,13 @@ lookup_protocol:
24367 + if ((protocol == IPPROTO_ICMP) &&
24368 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24371 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24372 goto out_rcu_unlock;
24375 err = -EAFNOSUPPORT;
24376 if (!inet_netns_ok(net, protocol))
24377 goto out_rcu_unlock;
24378 @@ -452,6 +457,7 @@ int inet_bind(struct socket *sock, struc
24379 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24380 struct sock *sk = sock->sk;
24381 struct inet_sock *inet = inet_sk(sk);
24382 + struct nx_v4_sock_addr nsa;
24383 unsigned short snum;
24386 @@ -475,7 +481,11 @@ int inet_bind(struct socket *sock, struc
24390 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24391 + err = v4_map_sock_addr(inet, addr, &nsa);
24395 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24397 /* Not specified by any standard per-se, however it breaks too
24398 * many applications when removed. It is unfortunate since
24399 @@ -487,7 +497,7 @@ int inet_bind(struct socket *sock, struc
24400 err = -EADDRNOTAVAIL;
24401 if (!sysctl_ip_nonlocal_bind &&
24402 !(inet->freebind || inet->transparent) &&
24403 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24404 + nsa.saddr != htonl(INADDR_ANY) &&
24405 chk_addr_ret != RTN_LOCAL &&
24406 chk_addr_ret != RTN_MULTICAST &&
24407 chk_addr_ret != RTN_BROADCAST)
24408 @@ -512,7 +522,7 @@ int inet_bind(struct socket *sock, struc
24409 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24410 goto out_release_sock;
24412 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24413 + v4_set_sock_addr(inet, &nsa);
24414 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24415 inet->inet_saddr = 0; /* Use device */
24417 @@ -715,11 +725,13 @@ int inet_getname(struct socket *sock, st
24420 sin->sin_port = inet->inet_dport;
24421 - sin->sin_addr.s_addr = inet->inet_daddr;
24422 + sin->sin_addr.s_addr =
24423 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24425 __be32 addr = inet->inet_rcv_saddr;
24427 addr = inet->inet_saddr;
24428 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24429 sin->sin_port = inet->inet_sport;
24430 sin->sin_addr.s_addr = addr;
24432 diff -NurpP --minimal linux-3.2.5/net/ipv4/arp.c linux-3.2.5-vs2.3.2.6/net/ipv4/arp.c
24433 --- linux-3.2.5/net/ipv4/arp.c 2011-10-24 18:45:34.000000000 +0200
24434 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/arp.c 2012-02-07 03:13:38.000000000 +0100
24435 @@ -1332,6 +1332,7 @@ static void arp_format_neigh_entry(struc
24436 struct net_device *dev = n->dev;
24437 int hatype = dev->type;
24439 + /* FIXME: check for network context */
24440 read_lock(&n->lock);
24441 /* Convert hardware address to XX:XX:XX:XX ... form. */
24442 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
24443 @@ -1363,6 +1364,7 @@ static void arp_format_pneigh_entry(stru
24444 int hatype = dev ? dev->type : 0;
24447 + /* FIXME: check for network context */
24448 sprintf(tbuf, "%pI4", n->key);
24449 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24450 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24451 diff -NurpP --minimal linux-3.2.5/net/ipv4/devinet.c linux-3.2.5-vs2.3.2.6/net/ipv4/devinet.c
24452 --- linux-3.2.5/net/ipv4/devinet.c 2012-02-07 01:57:55.000000000 +0100
24453 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/devinet.c 2012-02-07 03:14:01.000000000 +0100
24454 @@ -518,6 +518,7 @@ struct in_device *inetdev_by_index(struc
24456 EXPORT_SYMBOL(inetdev_by_index);
24459 /* Called only from RTNL semaphored context. No locks. */
24461 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24462 @@ -759,6 +760,8 @@ int devinet_ioctl(struct net *net, unsig
24464 in_dev = __in_dev_get_rtnl(dev);
24466 + struct nx_info *nxi = current_nx_info();
24468 if (tryaddrmatch) {
24469 /* Matthias Andree */
24470 /* compare label and address (4.4BSD style) */
24471 @@ -767,6 +770,8 @@ int devinet_ioctl(struct net *net, unsig
24472 This is checked above. */
24473 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24474 ifap = &ifa->ifa_next) {
24475 + if (!nx_v4_ifa_visible(nxi, ifa))
24477 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24478 sin_orig.sin_addr.s_addr ==
24480 @@ -779,9 +784,12 @@ int devinet_ioctl(struct net *net, unsig
24481 comparing just the label */
24483 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24484 - ifap = &ifa->ifa_next)
24485 + ifap = &ifa->ifa_next) {
24486 + if (!nx_v4_ifa_visible(nxi, ifa))
24488 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24494 @@ -934,6 +942,8 @@ static int inet_gifconf(struct net_devic
24497 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24498 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24501 done += sizeof(ifr);
24503 @@ -1294,6 +1304,7 @@ static int inet_dump_ifaddr(struct sk_bu
24504 struct net_device *dev;
24505 struct in_device *in_dev;
24506 struct in_ifaddr *ifa;
24507 + struct sock *sk = skb->sk;
24508 struct hlist_head *head;
24509 struct hlist_node *node;
24511 @@ -1316,6 +1327,8 @@ static int inet_dump_ifaddr(struct sk_bu
24513 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24514 ifa = ifa->ifa_next, ip_idx++) {
24515 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24517 if (ip_idx < s_ip_idx)
24519 if (inet_fill_ifaddr(skb, ifa,
24520 diff -NurpP --minimal linux-3.2.5/net/ipv4/fib_trie.c linux-3.2.5-vs2.3.2.6/net/ipv4/fib_trie.c
24521 --- linux-3.2.5/net/ipv4/fib_trie.c 2012-02-07 01:57:55.000000000 +0100
24522 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/fib_trie.c 2012-02-07 03:14:01.000000000 +0100
24523 @@ -2555,6 +2555,7 @@ static int fib_route_seq_show(struct seq
24524 || fa->fa_type == RTN_MULTICAST)
24527 + /* FIXME: check for network context? */
24530 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24531 diff -NurpP --minimal linux-3.2.5/net/ipv4/inet_connection_sock.c linux-3.2.5-vs2.3.2.6/net/ipv4/inet_connection_sock.c
24532 --- linux-3.2.5/net/ipv4/inet_connection_sock.c 2011-07-22 11:18:13.000000000 +0200
24533 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/inet_connection_sock.c 2012-02-07 03:13:38.000000000 +0100
24534 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
24536 EXPORT_SYMBOL(inet_get_local_port_range);
24538 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24540 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24541 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24543 + if (inet_v6_ipv6only(sk2))
24546 + if (sk1_rcv_saddr &&
24548 + sk1_rcv_saddr == sk2_rcv_saddr)
24551 + if (sk1_rcv_saddr &&
24552 + !sk2_rcv_saddr &&
24553 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24556 + if (sk2_rcv_saddr &&
24557 + !sk1_rcv_saddr &&
24558 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24561 + if (!sk1_rcv_saddr &&
24562 + !sk2_rcv_saddr &&
24563 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24569 int inet_csk_bind_conflict(const struct sock *sk,
24570 const struct inet_bind_bucket *tb)
24572 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
24573 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
24574 if (!reuse || !sk2->sk_reuse ||
24575 sk2->sk_state == TCP_LISTEN) {
24576 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24577 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24578 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24579 + if (ipv4_rcv_saddr_equal(sk, sk2))
24583 diff -NurpP --minimal linux-3.2.5/net/ipv4/inet_diag.c linux-3.2.5-vs2.3.2.6/net/ipv4/inet_diag.c
24584 --- linux-3.2.5/net/ipv4/inet_diag.c 2012-01-09 16:15:03.000000000 +0100
24585 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/inet_diag.c 2011-12-15 01:11:37.000000000 +0100
24587 #include <linux/stddef.h>
24589 #include <linux/inet_diag.h>
24590 +#include <linux/vs_network.h>
24591 +#include <linux/vs_inet.h>
24593 static const struct inet_diag_handler **inet_diag_table;
24595 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
24597 r->id.idiag_sport = inet->inet_sport;
24598 r->id.idiag_dport = inet->inet_dport;
24599 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24600 - r->id.idiag_dst[0] = inet->inet_daddr;
24601 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24602 + inet->inet_rcv_saddr);
24603 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24604 + inet->inet_daddr);
24606 /* IPv6 dual-stack sockets use inet->tos for IPv4 connections,
24607 * hence this needs to be included regardless of socket family.
24608 @@ -214,8 +218,8 @@ static int inet_twsk_diag_fill(struct in
24609 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
24610 r->id.idiag_sport = tw->tw_sport;
24611 r->id.idiag_dport = tw->tw_dport;
24612 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24613 - r->id.idiag_dst[0] = tw->tw_daddr;
24614 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24615 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24616 r->idiag_state = tw->tw_substate;
24617 r->idiag_timer = 3;
24618 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
24619 @@ -272,6 +276,7 @@ static int inet_diag_get_exact(struct sk
24622 if (req->idiag_family == AF_INET) {
24623 + /* TODO: lback */
24624 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
24625 req->id.idiag_dport, req->id.idiag_src[0],
24626 req->id.idiag_sport, req->id.idiag_if);
24627 @@ -514,6 +519,7 @@ static int inet_csk_diag_dump(struct soc
24631 + /* TODO: lback */
24632 entry.saddr = &inet->inet_rcv_saddr;
24633 entry.daddr = &inet->inet_daddr;
24635 @@ -552,6 +558,7 @@ static int inet_twsk_diag_dump(struct in
24639 + /* TODO: lback */
24640 entry.saddr = &tw->tw_rcv_saddr;
24641 entry.daddr = &tw->tw_daddr;
24643 @@ -598,8 +605,8 @@ static int inet_diag_fill_req(struct sk_
24645 r->id.idiag_sport = inet->inet_sport;
24646 r->id.idiag_dport = ireq->rmt_port;
24647 - r->id.idiag_src[0] = ireq->loc_addr;
24648 - r->id.idiag_dst[0] = ireq->rmt_addr;
24649 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
24650 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
24651 r->idiag_expires = jiffies_to_msecs(tmo);
24652 r->idiag_rqueue = 0;
24653 r->idiag_wqueue = 0;
24654 @@ -670,6 +677,7 @@ static int inet_diag_dump_reqs(struct sk
24658 + /* TODO: lback */
24660 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
24661 (entry.family == AF_INET6) ?
24662 @@ -740,6 +748,8 @@ static int inet_diag_dump(struct sk_buff
24663 sk_nulls_for_each(sk, node, &ilb->head) {
24664 struct inet_sock *inet = inet_sk(sk);
24666 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24671 @@ -806,6 +816,8 @@ skip_listen_ht:
24672 sk_nulls_for_each(sk, node, &head->chain) {
24673 struct inet_sock *inet = inet_sk(sk);
24675 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24679 if (!(r->idiag_states & (1 << sk->sk_state)))
24680 @@ -830,6 +842,8 @@ next_normal:
24681 inet_twsk_for_each(tw, node,
24684 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24688 if (r->id.idiag_sport != tw->tw_sport &&
24689 diff -NurpP --minimal linux-3.2.5/net/ipv4/inet_hashtables.c linux-3.2.5-vs2.3.2.6/net/ipv4/inet_hashtables.c
24690 --- linux-3.2.5/net/ipv4/inet_hashtables.c 2011-10-24 18:45:34.000000000 +0200
24691 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/inet_hashtables.c 2011-12-05 19:33:02.000000000 +0100
24693 #include <net/inet_connection_sock.h>
24694 #include <net/inet_hashtables.h>
24695 #include <net/secure_seq.h>
24696 +#include <net/route.h>
24697 #include <net/ip.h>
24700 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
24701 if (rcv_saddr != daddr)
24705 + /* block non nx_info ips */
24706 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24707 + daddr, NXA_MASK_BIND))
24710 if (sk->sk_bound_dev_if) {
24711 if (sk->sk_bound_dev_if != dif)
24712 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
24713 * wildcarded during the search since they can never be otherwise.
24717 struct sock *__inet_lookup_listener(struct net *net,
24718 struct inet_hashinfo *hashinfo,
24719 const __be32 daddr, const unsigned short hnum,
24720 @@ -196,6 +201,7 @@ begin:
24726 * if the nulls value we got at the end of this lookup is
24727 * not the expected one, we must restart lookup.
24728 diff -NurpP --minimal linux-3.2.5/net/ipv4/netfilter/nf_nat_helper.c linux-3.2.5-vs2.3.2.6/net/ipv4/netfilter/nf_nat_helper.c
24729 --- linux-3.2.5/net/ipv4/netfilter/nf_nat_helper.c 2011-07-22 11:18:13.000000000 +0200
24730 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/netfilter/nf_nat_helper.c 2011-12-05 19:33:02.000000000 +0100
24732 #include <net/route.h>
24734 #include <linux/netfilter_ipv4.h>
24735 +#include <net/route.h>
24736 #include <net/netfilter/nf_conntrack.h>
24737 #include <net/netfilter/nf_conntrack_helper.h>
24738 #include <net/netfilter/nf_conntrack_ecache.h>
24739 diff -NurpP --minimal linux-3.2.5/net/ipv4/netfilter.c linux-3.2.5-vs2.3.2.6/net/ipv4/netfilter.c
24740 --- linux-3.2.5/net/ipv4/netfilter.c 2012-01-09 16:15:03.000000000 +0100
24741 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/netfilter.c 2012-02-07 03:13:38.000000000 +0100
24743 #include <linux/skbuff.h>
24744 #include <linux/gfp.h>
24745 #include <linux/export.h>
24746 -#include <net/route.h>
24747 +// #include <net/route.h>
24748 #include <net/xfrm.h>
24749 #include <net/ip.h>
24750 #include <net/netfilter/nf_queue.h>
24751 diff -NurpP --minimal linux-3.2.5/net/ipv4/raw.c linux-3.2.5-vs2.3.2.6/net/ipv4/raw.c
24752 --- linux-3.2.5/net/ipv4/raw.c 2012-01-09 16:15:04.000000000 +0100
24753 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/raw.c 2012-02-07 03:13:38.000000000 +0100
24754 @@ -118,7 +118,7 @@ static struct sock *__raw_v4_lookup(stru
24756 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
24757 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
24758 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
24759 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
24760 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
24761 goto found; /* gotcha */
24763 @@ -386,6 +386,12 @@ static int raw_send_hdrinc(struct sock *
24764 icmp_out_count(net, ((struct icmphdr *)
24765 skb_transport_header(skb))->type);
24768 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
24769 + sk->sk_nx_info &&
24770 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
24773 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
24774 rt->dst.dev, dst_output);
24776 @@ -573,6 +579,16 @@ static int raw_sendmsg(struct kiocb *ioc
24780 + if (sk->sk_nx_info) {
24781 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
24782 + if (IS_ERR(rt)) {
24783 + err = PTR_ERR(rt);
24790 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
24791 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
24793 @@ -649,17 +665,19 @@ static int raw_bind(struct sock *sk, str
24795 struct inet_sock *inet = inet_sk(sk);
24796 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
24797 + struct nx_v4_sock_addr nsa = { 0 };
24801 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
24803 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24804 + v4_map_sock_addr(inet, addr, &nsa);
24805 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24806 ret = -EADDRNOTAVAIL;
24807 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
24808 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
24809 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
24811 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24812 + v4_set_sock_addr(inet, &nsa);
24813 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24814 inet->inet_saddr = 0; /* Use device */
24816 @@ -711,7 +729,8 @@ static int raw_recvmsg(struct kiocb *ioc
24817 /* Copy the address. */
24819 sin->sin_family = AF_INET;
24820 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24821 + sin->sin_addr.s_addr =
24822 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
24824 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
24826 @@ -907,7 +926,8 @@ static struct sock *raw_get_first(struct
24827 struct hlist_node *node;
24829 sk_for_each(sk, node, &state->h->ht[state->bucket])
24830 - if (sock_net(sk) == seq_file_net(seq))
24831 + if ((sock_net(sk) == seq_file_net(seq)) &&
24832 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24836 @@ -923,7 +943,8 @@ static struct sock *raw_get_next(struct
24840 - } while (sk && sock_net(sk) != seq_file_net(seq));
24841 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
24842 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24844 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
24845 sk = sk_head(&state->h->ht[state->bucket]);
24846 diff -NurpP --minimal linux-3.2.5/net/ipv4/route.c linux-3.2.5-vs2.3.2.6/net/ipv4/route.c
24847 --- linux-3.2.5/net/ipv4/route.c 2012-01-09 16:15:04.000000000 +0100
24848 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/route.c 2012-02-07 03:13:38.000000000 +0100
24849 @@ -2709,7 +2709,7 @@ static struct rtable *ip_route_output_sl
24852 if (fl4->flowi4_oif) {
24853 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
24854 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
24855 rth = ERR_PTR(-ENODEV);
24856 if (dev_out == NULL)
24858 diff -NurpP --minimal linux-3.2.5/net/ipv4/tcp.c linux-3.2.5-vs2.3.2.6/net/ipv4/tcp.c
24859 --- linux-3.2.5/net/ipv4/tcp.c 2012-01-09 16:15:04.000000000 +0100
24860 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/tcp.c 2011-12-05 19:33:02.000000000 +0100
24861 @@ -266,6 +266,7 @@
24862 #include <linux/crypto.h>
24863 #include <linux/time.h>
24864 #include <linux/slab.h>
24865 +#include <linux/in.h>
24867 #include <net/icmp.h>
24868 #include <net/tcp.h>
24869 diff -NurpP --minimal linux-3.2.5/net/ipv4/tcp_ipv4.c linux-3.2.5-vs2.3.2.6/net/ipv4/tcp_ipv4.c
24870 --- linux-3.2.5/net/ipv4/tcp_ipv4.c 2012-02-07 01:57:55.000000000 +0100
24871 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/tcp_ipv4.c 2012-02-07 03:14:01.000000000 +0100
24872 @@ -2023,6 +2023,12 @@ static void *listening_get_next(struct s
24873 req = req->dl_next;
24876 + vxdprintk(VXD_CBIT(net, 6),
24877 + "sk,req: %p [#%d] (from %d)", req->sk,
24878 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
24880 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
24882 if (req->rsk_ops->family == st->family) {
24885 @@ -2047,6 +2053,10 @@ get_req:
24888 sk_nulls_for_each_from(sk, node) {
24889 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
24890 + sk, sk->sk_nid, nx_current_nid());
24891 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24893 if (!net_eq(sock_net(sk), net))
24895 if (sk->sk_family == st->family) {
24896 @@ -2123,6 +2133,11 @@ static void *established_get_first(struc
24898 spin_lock_bh(lock);
24899 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
24900 + vxdprintk(VXD_CBIT(net, 6),
24901 + "sk,egf: %p [#%d] (from %d)",
24902 + sk, sk->sk_nid, nx_current_nid());
24903 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24905 if (sk->sk_family != st->family ||
24906 !net_eq(sock_net(sk), net)) {
24908 @@ -2133,6 +2148,11 @@ static void *established_get_first(struc
24909 st->state = TCP_SEQ_STATE_TIME_WAIT;
24910 inet_twsk_for_each(tw, node,
24911 &tcp_hashinfo.ehash[st->bucket].twchain) {
24912 + vxdprintk(VXD_CBIT(net, 6),
24913 + "tw: %p [#%d] (from %d)",
24914 + tw, tw->tw_nid, nx_current_nid());
24915 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24917 if (tw->tw_family != st->family ||
24918 !net_eq(twsk_net(tw), net)) {
24920 @@ -2162,7 +2182,9 @@ static void *established_get_next(struct
24924 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
24925 + while (tw && (tw->tw_family != st->family ||
24926 + !net_eq(twsk_net(tw), net) ||
24927 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
24931 @@ -2186,6 +2208,11 @@ get_tw:
24932 sk = sk_nulls_next(sk);
24934 sk_nulls_for_each_from(sk, node) {
24935 + vxdprintk(VXD_CBIT(net, 6),
24936 + "sk,egn: %p [#%d] (from %d)",
24937 + sk, sk->sk_nid, nx_current_nid());
24938 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24940 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
24943 @@ -2391,9 +2418,9 @@ static void get_openreq4(const struct so
24944 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
24945 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
24948 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
24949 ntohs(inet_sk(sk)->inet_sport),
24951 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
24952 ntohs(ireq->rmt_port),
24954 0, 0, /* could print option size, but that is af dependent. */
24955 @@ -2415,8 +2442,8 @@ static void get_tcp4_sock(struct sock *s
24956 const struct tcp_sock *tp = tcp_sk(sk);
24957 const struct inet_connection_sock *icsk = inet_csk(sk);
24958 const struct inet_sock *inet = inet_sk(sk);
24959 - __be32 dest = inet->inet_daddr;
24960 - __be32 src = inet->inet_rcv_saddr;
24961 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
24962 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
24963 __u16 destp = ntohs(inet->inet_dport);
24964 __u16 srcp = ntohs(inet->inet_sport);
24966 @@ -2473,8 +2500,8 @@ static void get_timewait4_sock(const str
24970 - dest = tw->tw_daddr;
24971 - src = tw->tw_rcv_saddr;
24972 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
24973 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
24974 destp = ntohs(tw->tw_dport);
24975 srcp = ntohs(tw->tw_sport);
24977 diff -NurpP --minimal linux-3.2.5/net/ipv4/tcp_minisocks.c linux-3.2.5-vs2.3.2.6/net/ipv4/tcp_minisocks.c
24978 --- linux-3.2.5/net/ipv4/tcp_minisocks.c 2012-01-09 16:15:04.000000000 +0100
24979 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/tcp_minisocks.c 2011-12-05 19:33:02.000000000 +0100
24981 #include <linux/slab.h>
24982 #include <linux/sysctl.h>
24983 #include <linux/workqueue.h>
24984 +#include <linux/vs_limit.h>
24985 +#include <linux/vs_socket.h>
24986 +#include <linux/vs_context.h>
24987 #include <net/tcp.h>
24988 #include <net/inet_common.h>
24989 #include <net/xfrm.h>
24990 @@ -336,6 +339,11 @@ void tcp_time_wait(struct sock *sk, int
24991 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
24992 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
24994 + tw->tw_xid = sk->sk_xid;
24995 + tw->tw_vx_info = NULL;
24996 + tw->tw_nid = sk->sk_nid;
24997 + tw->tw_nx_info = NULL;
24999 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25000 if (tw->tw_family == PF_INET6) {
25001 struct ipv6_pinfo *np = inet6_sk(sk);
25002 diff -NurpP --minimal linux-3.2.5/net/ipv4/udp.c linux-3.2.5-vs2.3.2.6/net/ipv4/udp.c
25003 --- linux-3.2.5/net/ipv4/udp.c 2012-01-09 16:15:04.000000000 +0100
25004 +++ linux-3.2.5-vs2.3.2.6/net/ipv4/udp.c 2012-02-07 03:13:38.000000000 +0100
25005 @@ -297,14 +297,7 @@ fail:
25007 EXPORT_SYMBOL(udp_lib_get_port);
25009 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25011 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25013 - return (!ipv6_only_sock(sk2) &&
25014 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25015 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25017 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25019 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25021 @@ -339,6 +332,11 @@ static inline int compute_score(struct s
25022 if (inet->inet_rcv_saddr != daddr)
25026 + /* block non nx_info ips */
25027 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25028 + daddr, NXA_MASK_BIND))
25031 if (inet->inet_daddr) {
25032 if (inet->inet_daddr != saddr)
25033 @@ -442,6 +440,7 @@ exact_match:
25038 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25039 * harder than this. -DaveM
25041 @@ -487,6 +486,11 @@ begin:
25042 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25043 score = compute_score(sk, net, saddr, hnum, sport,
25044 daddr, dport, dif);
25045 + /* FIXME: disabled?
25046 + if (score == 9) {
25050 if (score > badness) {
25053 @@ -500,6 +504,7 @@ begin:
25054 if (get_nulls_value(node) != slot)
25059 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25061 @@ -509,6 +514,7 @@ begin:
25069 @@ -551,8 +557,7 @@ static inline struct sock *udp_v4_mcast_
25070 udp_sk(s)->udp_port_hash != hnum ||
25071 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25072 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25073 - (inet->inet_rcv_saddr &&
25074 - inet->inet_rcv_saddr != loc_addr) ||
25075 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25076 ipv6_only_sock(s) ||
25077 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25079 @@ -930,6 +935,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
25080 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
25081 faddr, saddr, dport, inet->inet_sport);
25083 + if (sk->sk_nx_info) {
25084 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
25085 + if (IS_ERR(rt)) {
25086 + err = PTR_ERR(rt);
25093 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
25094 rt = ip_route_output_flow(net, fl4, sk);
25096 @@ -1228,7 +1243,8 @@ try_again:
25098 sin->sin_family = AF_INET;
25099 sin->sin_port = udp_hdr(skb)->source;
25100 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25101 + sin->sin_addr.s_addr = nx_map_sock_lback(
25102 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25103 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25105 if (inet->cmsg_flags)
25106 @@ -1974,6 +1990,8 @@ static struct sock *udp_get_first(struct
25107 sk_nulls_for_each(sk, node, &hslot->head) {
25108 if (!net_eq(sock_net(sk), net))
25110 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25112 if (sk->sk_family == state->family)
25115 @@ -1991,7 +2009,9 @@ static struct sock *udp_get_next(struct
25118 sk = sk_nulls_next(sk);
25119 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25120 + } while (sk && (!net_eq(sock_net(sk), net) ||
25121 + sk->sk_family != state->family ||
25122 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25125 if (state->bucket <= state->udp_table->mask)
25126 diff -NurpP --minimal linux-3.2.5/net/ipv6/Kconfig linux-3.2.5-vs2.3.2.6/net/ipv6/Kconfig
25127 --- linux-3.2.5/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25128 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/Kconfig 2011-12-05 19:33:02.000000000 +0100
25131 # IPv6 as module will cause a CRASH if you try to unload it
25133 - tristate "The IPv6 protocol"
25135 + bool "The IPv6 protocol"
25138 This is complemental support for the IP version 6.
25139 You will still be able to do traditional IPv4 networking as well.
25140 diff -NurpP --minimal linux-3.2.5/net/ipv6/addrconf.c linux-3.2.5-vs2.3.2.6/net/ipv6/addrconf.c
25141 --- linux-3.2.5/net/ipv6/addrconf.c 2012-02-07 01:57:55.000000000 +0100
25142 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/addrconf.c 2012-02-07 03:14:01.000000000 +0100
25144 #include <linux/proc_fs.h>
25145 #include <linux/seq_file.h>
25146 #include <linux/export.h>
25147 +#include <linux/vs_network.h>
25148 +#include <linux/vs_inet6.h>
25150 /* Set to 3 to get tracing... */
25151 #define ACONF_DEBUG 2
25152 @@ -1109,7 +1111,7 @@ out:
25154 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25155 const struct in6_addr *daddr, unsigned int prefs,
25156 - struct in6_addr *saddr)
25157 + struct in6_addr *saddr, struct nx_info *nxi)
25159 struct ipv6_saddr_score scores[2],
25160 *score = &scores[0], *hiscore = &scores[1];
25161 @@ -1181,6 +1183,8 @@ int ipv6_dev_get_saddr(struct net *net,
25165 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25169 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25170 @@ -3153,7 +3157,10 @@ static void if6_seq_stop(struct seq_file
25171 static int if6_seq_show(struct seq_file *seq, void *v)
25173 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25174 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25176 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25177 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25178 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25180 ifp->idev->dev->ifindex,
25182 @@ -3659,6 +3666,11 @@ static int in6_dump_addrs(struct inet6_d
25183 struct ifacaddr6 *ifaca;
25185 int ip_idx = *p_ip_idx;
25186 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25188 + /* disable ipv6 on non v6 guests */
25189 + if (nxi && !nx_info_has_v6(nxi))
25192 read_lock_bh(&idev->lock);
25194 @@ -3669,6 +3681,8 @@ static int in6_dump_addrs(struct inet6_d
25195 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25196 if (++ip_idx < s_ip_idx)
25198 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25200 err = inet6_fill_ifaddr(skb, ifa,
25201 NETLINK_CB(cb->skb).pid,
25202 cb->nlh->nlmsg_seq,
25203 @@ -3685,6 +3699,8 @@ static int in6_dump_addrs(struct inet6_d
25204 ifmca = ifmca->next, ip_idx++) {
25205 if (ip_idx < s_ip_idx)
25207 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25209 err = inet6_fill_ifmcaddr(skb, ifmca,
25210 NETLINK_CB(cb->skb).pid,
25211 cb->nlh->nlmsg_seq,
25212 @@ -3700,6 +3716,8 @@ static int in6_dump_addrs(struct inet6_d
25213 ifaca = ifaca->aca_next, ip_idx++) {
25214 if (ip_idx < s_ip_idx)
25216 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25218 err = inet6_fill_ifacaddr(skb, ifaca,
25219 NETLINK_CB(cb->skb).pid,
25220 cb->nlh->nlmsg_seq,
25221 @@ -4085,6 +4103,11 @@ static int inet6_dump_ifinfo(struct sk_b
25222 struct inet6_dev *idev;
25223 struct hlist_head *head;
25224 struct hlist_node *node;
25225 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25227 + /* FIXME: maybe disable ipv6 on non v6 guests?
25228 + if (skb->sk && skb->sk->sk_vx_info)
25229 + return skb->len; */
25232 s_idx = cb->args[1];
25233 @@ -4096,6 +4119,8 @@ static int inet6_dump_ifinfo(struct sk_b
25234 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25237 + if (!v6_dev_in_nx_info(dev, nxi))
25239 idev = __in6_dev_get(dev);
25242 diff -NurpP --minimal linux-3.2.5/net/ipv6/af_inet6.c linux-3.2.5-vs2.3.2.6/net/ipv6/af_inet6.c
25243 --- linux-3.2.5/net/ipv6/af_inet6.c 2011-10-24 18:45:34.000000000 +0200
25244 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/af_inet6.c 2011-12-05 19:33:02.000000000 +0100
25246 #include <linux/netdevice.h>
25247 #include <linux/icmpv6.h>
25248 #include <linux/netfilter_ipv6.h>
25249 +#include <linux/vs_inet.h>
25250 +#include <linux/vs_inet6.h>
25252 #include <net/ip.h>
25253 #include <net/ipv6.h>
25254 @@ -160,9 +162,12 @@ lookup_protocol:
25258 + if ((protocol == IPPROTO_ICMPV6) &&
25259 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25261 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25262 goto out_rcu_unlock;
25265 sock->ops = answer->ops;
25266 answer_prot = answer->prot;
25267 answer_no_check = answer->no_check;
25268 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25269 struct inet_sock *inet = inet_sk(sk);
25270 struct ipv6_pinfo *np = inet6_sk(sk);
25271 struct net *net = sock_net(sk);
25272 + struct nx_v6_sock_addr nsa;
25274 unsigned short snum;
25276 @@ -276,6 +282,10 @@ int inet6_bind(struct socket *sock, stru
25277 if (addr->sin6_family != AF_INET6)
25278 return -EAFNOSUPPORT;
25280 + err = v6_map_sock_addr(inet, addr, &nsa);
25284 addr_type = ipv6_addr_type(&addr->sin6_addr);
25285 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25287 @@ -307,6 +317,7 @@ int inet6_bind(struct socket *sock, stru
25288 /* Reproduce AF_INET checks to make the bindings consistent */
25289 v4addr = addr->sin6_addr.s6_addr32[3];
25290 chk_addr_ret = inet_addr_type(net, v4addr);
25292 if (!sysctl_ip_nonlocal_bind &&
25293 !(inet->freebind || inet->transparent) &&
25294 v4addr != htonl(INADDR_ANY) &&
25295 @@ -316,6 +327,10 @@ int inet6_bind(struct socket *sock, stru
25296 err = -EADDRNOTAVAIL;
25299 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25300 + err = -EADDRNOTAVAIL;
25304 if (addr_type != IPV6_ADDR_ANY) {
25305 struct net_device *dev = NULL;
25306 @@ -342,6 +357,11 @@ int inet6_bind(struct socket *sock, stru
25310 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25311 + err = -EADDRNOTAVAIL;
25315 /* ipv4 addr of the socket is invalid. Only the
25316 * unspecified and mapped address have a v4 equivalent.
25318 @@ -358,6 +378,9 @@ int inet6_bind(struct socket *sock, stru
25322 + /* what's that for? */
25323 + v6_set_sock_addr(inet, &nsa);
25325 inet->inet_rcv_saddr = v4addr;
25326 inet->inet_saddr = v4addr;
25328 @@ -459,9 +482,11 @@ int inet6_getname(struct socket *sock, s
25330 sin->sin6_port = inet->inet_dport;
25331 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25332 + /* FIXME: remap lback? */
25334 sin->sin6_flowinfo = np->flow_label;
25336 + /* FIXME: remap lback? */
25337 if (ipv6_addr_any(&np->rcv_saddr))
25338 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25340 diff -NurpP --minimal linux-3.2.5/net/ipv6/datagram.c linux-3.2.5-vs2.3.2.6/net/ipv6/datagram.c
25341 --- linux-3.2.5/net/ipv6/datagram.c 2012-01-09 16:15:04.000000000 +0100
25342 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/datagram.c 2011-12-05 19:33:02.000000000 +0100
25343 @@ -642,7 +642,7 @@ int datagram_send_ctl(struct net *net, s
25346 if (fl6->flowi6_oif) {
25347 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25348 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25352 diff -NurpP --minimal linux-3.2.5/net/ipv6/fib6_rules.c linux-3.2.5-vs2.3.2.6/net/ipv6/fib6_rules.c
25353 --- linux-3.2.5/net/ipv6/fib6_rules.c 2012-01-09 16:15:04.000000000 +0100
25354 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/fib6_rules.c 2011-12-05 19:33:02.000000000 +0100
25355 @@ -91,7 +91,7 @@ static int fib6_rule_action(struct fib_r
25356 ip6_dst_idev(&rt->dst)->dev,
25358 rt6_flags2srcprefs(flags),
25362 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25364 diff -NurpP --minimal linux-3.2.5/net/ipv6/inet6_hashtables.c linux-3.2.5-vs2.3.2.6/net/ipv6/inet6_hashtables.c
25365 --- linux-3.2.5/net/ipv6/inet6_hashtables.c 2011-10-24 18:45:34.000000000 +0200
25366 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/inet6_hashtables.c 2011-12-05 19:33:02.000000000 +0100
25369 #include <linux/module.h>
25370 #include <linux/random.h>
25371 +#include <linux/vs_inet6.h>
25373 #include <net/inet_connection_sock.h>
25374 #include <net/inet_hashtables.h>
25375 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25376 unsigned int slot = hash & hashinfo->ehash_mask;
25377 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25382 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25383 @@ -95,7 +95,7 @@ begin:
25391 if (get_nulls_value(node) != slot)
25392 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
25393 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25397 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25400 if (sk->sk_bound_dev_if) {
25401 if (sk->sk_bound_dev_if != dif)
25402 diff -NurpP --minimal linux-3.2.5/net/ipv6/ip6_output.c linux-3.2.5-vs2.3.2.6/net/ipv6/ip6_output.c
25403 --- linux-3.2.5/net/ipv6/ip6_output.c 2012-01-09 16:15:04.000000000 +0100
25404 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/ip6_output.c 2012-01-09 16:19:31.000000000 +0100
25405 @@ -963,7 +963,8 @@ static int ip6_dst_lookup_tail(struct so
25406 struct rt6_info *rt = (struct rt6_info *) *dst;
25407 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25408 sk ? inet6_sk(sk)->srcprefs : 0,
25411 + sk ? sk->sk_nx_info : NULL);
25413 goto out_err_release;
25415 diff -NurpP --minimal linux-3.2.5/net/ipv6/ndisc.c linux-3.2.5-vs2.3.2.6/net/ipv6/ndisc.c
25416 --- linux-3.2.5/net/ipv6/ndisc.c 2012-01-09 16:15:04.000000000 +0100
25417 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/ndisc.c 2011-12-15 01:11:37.000000000 +0100
25418 @@ -588,7 +588,7 @@ static void ndisc_send_na(struct net_dev
25420 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25421 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25425 src_addr = &tmpaddr;
25427 diff -NurpP --minimal linux-3.2.5/net/ipv6/raw.c linux-3.2.5-vs2.3.2.6/net/ipv6/raw.c
25428 --- linux-3.2.5/net/ipv6/raw.c 2012-02-07 01:57:55.000000000 +0100
25429 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/raw.c 2012-02-07 03:14:01.000000000 +0100
25431 #include <linux/icmpv6.h>
25432 #include <linux/netfilter.h>
25433 #include <linux/netfilter_ipv6.h>
25434 +#include <linux/vs_inet6.h>
25435 #include <linux/skbuff.h>
25436 #include <linux/compat.h>
25437 #include <asm/uaccess.h>
25438 @@ -285,6 +286,13 @@ static int rawv6_bind(struct sock *sk, s
25442 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25443 + err = -EADDRNOTAVAIL;
25449 /* ipv4 addr of the socket is invalid. Only the
25450 * unspecified and mapped address have a v4 equivalent.
25452 diff -NurpP --minimal linux-3.2.5/net/ipv6/route.c linux-3.2.5-vs2.3.2.6/net/ipv6/route.c
25453 --- linux-3.2.5/net/ipv6/route.c 2012-01-09 16:15:04.000000000 +0100
25454 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/route.c 2012-01-09 16:19:31.000000000 +0100
25456 #include <net/xfrm.h>
25457 #include <net/netevent.h>
25458 #include <net/netlink.h>
25459 +#include <linux/vs_inet6.h>
25461 #include <asm/uaccess.h>
25463 @@ -2093,15 +2094,17 @@ int ip6_route_get_saddr(struct net *net,
25464 struct rt6_info *rt,
25465 const struct in6_addr *daddr,
25466 unsigned int prefs,
25467 - struct in6_addr *saddr)
25468 + struct in6_addr *saddr,
25469 + struct nx_info *nxi)
25471 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25473 - if (rt->rt6i_prefsrc.plen)
25474 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25475 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25476 ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr);
25478 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25479 - daddr, prefs, saddr);
25480 + daddr, prefs, saddr, nxi);
25484 @@ -2431,7 +2434,8 @@ static int rt6_fill_node(struct net *net
25485 NLA_PUT_U32(skb, RTA_IIF, iif);
25487 struct in6_addr saddr_buf;
25488 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0)
25489 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25490 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25491 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25494 @@ -2634,6 +2638,7 @@ static int rt6_info_route(struct rt6_inf
25495 struct seq_file *m = p_arg;
25496 struct neighbour *n;
25498 + /* FIXME: check for network context? */
25499 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25501 #ifdef CONFIG_IPV6_SUBTREES
25502 diff -NurpP --minimal linux-3.2.5/net/ipv6/tcp_ipv6.c linux-3.2.5-vs2.3.2.6/net/ipv6/tcp_ipv6.c
25503 --- linux-3.2.5/net/ipv6/tcp_ipv6.c 2012-02-07 01:57:55.000000000 +0100
25504 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/tcp_ipv6.c 2012-02-07 03:14:01.000000000 +0100
25507 #include <linux/crypto.h>
25508 #include <linux/scatterlist.h>
25509 +#include <linux/vs_inet6.h>
25511 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25512 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25513 @@ -162,8 +163,15 @@ static int tcp_v6_connect(struct sock *s
25514 * connect() to INADDR_ANY means loopback (BSD'ism).
25517 - if(ipv6_addr_any(&usin->sin6_addr))
25518 - usin->sin6_addr.s6_addr[15] = 0x1;
25519 + if(ipv6_addr_any(&usin->sin6_addr)) {
25520 + struct nx_info *nxi = sk->sk_nx_info;
25522 + if (nxi && nx_info_has_v6(nxi))
25523 + /* FIXME: remap lback? */
25524 + usin->sin6_addr = nxi->v6.ip;
25526 + usin->sin6_addr.s6_addr[15] = 0x1;
25529 addr_type = ipv6_addr_type(&usin->sin6_addr);
25531 diff -NurpP --minimal linux-3.2.5/net/ipv6/udp.c linux-3.2.5-vs2.3.2.6/net/ipv6/udp.c
25532 --- linux-3.2.5/net/ipv6/udp.c 2012-01-09 16:15:04.000000000 +0100
25533 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/udp.c 2011-12-15 01:11:37.000000000 +0100
25534 @@ -45,41 +45,67 @@
25535 #include <net/tcp_states.h>
25536 #include <net/ip6_checksum.h>
25537 #include <net/xfrm.h>
25538 +#include <linux/vs_inet6.h>
25540 #include <linux/proc_fs.h>
25541 #include <linux/seq_file.h>
25542 #include "udp_impl.h"
25544 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25545 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25547 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25548 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25549 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25550 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25551 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25552 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25553 - int sk_ipv6only = ipv6_only_sock(sk);
25554 + int sk1_ipv6only = ipv6_only_sock(sk1);
25555 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25556 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25557 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25558 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25560 /* if both are mapped, treat as IPv4 */
25561 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25562 - return (!sk2_ipv6only &&
25563 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25564 + if (!sk2_ipv6only &&
25565 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25566 - sk1_rcv_saddr == sk2_rcv_saddr));
25567 + sk1_rcv_saddr == sk2_rcv_saddr))
25573 if (addr_type2 == IPV6_ADDR_ANY &&
25574 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25578 if (addr_type == IPV6_ADDR_ANY &&
25579 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25581 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25584 if (sk2_rcv_saddr6 &&
25585 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25587 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25593 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25594 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25595 + if (!sk2_rcv_saddr)
25596 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25597 + if (!sk1_rcv_saddr)
25598 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25601 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25602 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25603 + else if (addr_type2 == IPV6_ADDR_ANY)
25604 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25605 + else if (addr_type == IPV6_ADDR_ANY) {
25606 + if (addr_type2 == IPV6_ADDR_MAPPED)
25607 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25609 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25614 static unsigned int udp6_portaddr_hash(struct net *net,
25615 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
25616 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25620 + /* block non nx_info ips */
25621 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25624 if (!ipv6_addr_any(&np->daddr)) {
25625 if (!ipv6_addr_equal(&np->daddr, saddr))
25626 diff -NurpP --minimal linux-3.2.5/net/ipv6/xfrm6_policy.c linux-3.2.5-vs2.3.2.6/net/ipv6/xfrm6_policy.c
25627 --- linux-3.2.5/net/ipv6/xfrm6_policy.c 2011-07-22 11:18:13.000000000 +0200
25628 +++ linux-3.2.5-vs2.3.2.6/net/ipv6/xfrm6_policy.c 2011-12-05 19:33:02.000000000 +0100
25629 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
25630 dev = ip6_dst_idev(dst)->dev;
25631 ipv6_dev_get_saddr(dev_net(dev), dev,
25632 (struct in6_addr *)&daddr->a6, 0,
25633 - (struct in6_addr *)&saddr->a6);
25634 + (struct in6_addr *)&saddr->a6, NULL);
25638 diff -NurpP --minimal linux-3.2.5/net/netfilter/ipvs/ip_vs_xmit.c linux-3.2.5-vs2.3.2.6/net/netfilter/ipvs/ip_vs_xmit.c
25639 --- linux-3.2.5/net/netfilter/ipvs/ip_vs_xmit.c 2012-01-09 16:15:04.000000000 +0100
25640 +++ linux-3.2.5-vs2.3.2.6/net/netfilter/ipvs/ip_vs_xmit.c 2012-02-07 03:13:38.000000000 +0100
25641 @@ -226,7 +226,7 @@ __ip_vs_route_output_v6(struct net *net,
25643 if (ipv6_addr_any(&fl6.saddr) &&
25644 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
25645 - &fl6.daddr, 0, &fl6.saddr) < 0)
25646 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
25649 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
25650 diff -NurpP --minimal linux-3.2.5/net/netlink/af_netlink.c linux-3.2.5-vs2.3.2.6/net/netlink/af_netlink.c
25651 --- linux-3.2.5/net/netlink/af_netlink.c 2012-01-09 16:15:04.000000000 +0100
25652 +++ linux-3.2.5-vs2.3.2.6/net/netlink/af_netlink.c 2011-12-05 19:33:02.000000000 +0100
25654 #include <linux/types.h>
25655 #include <linux/audit.h>
25656 #include <linux/mutex.h>
25657 +#include <linux/vs_context.h>
25658 +#include <linux/vs_network.h>
25659 +#include <linux/vs_limit.h>
25661 #include <net/net_namespace.h>
25662 #include <net/sock.h>
25663 @@ -1912,6 +1915,8 @@ static struct sock *netlink_seq_socket_i
25664 sk_for_each(s, node, &hash->table[j]) {
25665 if (sock_net(s) != seq_file_net(seq))
25667 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25671 iter->hash_idx = j;
25672 @@ -1946,7 +1951,8 @@ static void *netlink_seq_next(struct seq
25676 - } while (s && sock_net(s) != seq_file_net(seq));
25677 + } while (s && (sock_net(s) != seq_file_net(seq) ||
25678 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
25682 @@ -1958,7 +1964,8 @@ static void *netlink_seq_next(struct seq
25684 for (; j <= hash->mask; j++) {
25685 s = sk_head(&hash->table[j]);
25686 - while (s && sock_net(s) != seq_file_net(seq))
25687 + while (s && (sock_net(s) != seq_file_net(seq) ||
25688 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
25692 diff -NurpP --minimal linux-3.2.5/net/socket.c linux-3.2.5-vs2.3.2.6/net/socket.c
25693 --- linux-3.2.5/net/socket.c 2012-02-07 01:57:55.000000000 +0100
25694 +++ linux-3.2.5-vs2.3.2.6/net/socket.c 2012-02-07 03:14:01.000000000 +0100
25697 #include <net/sock.h>
25698 #include <linux/netfilter.h>
25699 +#include <linux/vs_base.h>
25700 +#include <linux/vs_socket.h>
25701 +#include <linux/vs_inet.h>
25702 +#include <linux/vs_inet6.h>
25704 #include <linux/if_tun.h>
25705 #include <linux/ipv6_route.h>
25706 @@ -546,6 +550,7 @@ static inline int __sock_sendmsg_nosec(s
25707 struct msghdr *msg, size_t size)
25709 struct sock_iocb *si = kiocb_to_siocb(iocb);
25712 sock_update_classid(sock->sk);
25714 @@ -554,7 +559,22 @@ static inline int __sock_sendmsg_nosec(s
25718 - return sock->ops->sendmsg(iocb, sock, msg, size);
25719 + len = sock->ops->sendmsg(iocb, sock, msg, size);
25722 + vx_sock_send(sock->sk, size);
25724 + vx_sock_fail(sock->sk, size);
25726 + vxdprintk(VXD_CBIT(net, 7),
25727 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
25729 + (sock->sk)?sock->sk->sk_nx_info:0,
25730 + (sock->sk)?sock->sk->sk_vx_info:0,
25731 + (sock->sk)?sock->sk->sk_xid:0,
25732 + (sock->sk)?sock->sk->sk_nid:0,
25733 + (unsigned int)size, len);
25737 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
25738 @@ -694,6 +714,7 @@ static inline int __sock_recvmsg_nosec(s
25739 struct msghdr *msg, size_t size, int flags)
25741 struct sock_iocb *si = kiocb_to_siocb(iocb);
25744 sock_update_classid(sock->sk);
25746 @@ -703,7 +724,18 @@ static inline int __sock_recvmsg_nosec(s
25750 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
25751 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
25752 + if ((len >= 0) && sock->sk)
25753 + vx_sock_recv(sock->sk, len);
25754 + vxdprintk(VXD_CBIT(net, 7),
25755 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
25757 + (sock->sk)?sock->sk->sk_nx_info:0,
25758 + (sock->sk)?sock->sk->sk_vx_info:0,
25759 + (sock->sk)?sock->sk->sk_xid:0,
25760 + (sock->sk)?sock->sk->sk_nid:0,
25761 + (unsigned int)size, len);
25765 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
25766 @@ -1188,6 +1220,13 @@ int __sock_create(struct net *net, int f
25767 if (type < 0 || type >= SOCK_MAX)
25770 + if (!nx_check(0, VS_ADMIN)) {
25771 + if (family == PF_INET && !current_nx_info_has_v4())
25772 + return -EAFNOSUPPORT;
25773 + if (family == PF_INET6 && !current_nx_info_has_v6())
25774 + return -EAFNOSUPPORT;
25779 This uglymoron is moved from INET layer to here to avoid
25780 @@ -1323,6 +1362,7 @@ SYSCALL_DEFINE3(socket, int, family, int
25784 + set_bit(SOCK_USER_SOCKET, &sock->flags);
25785 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
25788 @@ -1364,10 +1404,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
25789 err = sock_create(family, type, protocol, &sock1);
25792 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
25794 err = sock_create(family, type, protocol, &sock2);
25796 goto out_release_1;
25797 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
25799 err = sock1->ops->socketpair(sock1, sock2);
25801 diff -NurpP --minimal linux-3.2.5/net/sunrpc/auth.c linux-3.2.5-vs2.3.2.6/net/sunrpc/auth.c
25802 --- linux-3.2.5/net/sunrpc/auth.c 2011-10-24 18:45:34.000000000 +0200
25803 +++ linux-3.2.5-vs2.3.2.6/net/sunrpc/auth.c 2011-12-05 19:33:02.000000000 +0100
25805 #include <linux/hash.h>
25806 #include <linux/sunrpc/clnt.h>
25807 #include <linux/spinlock.h>
25808 +#include <linux/vs_tag.h>
25811 # define RPCDBG_FACILITY RPCDBG_AUTH
25812 @@ -427,6 +428,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
25813 memset(&acred, 0, sizeof(acred));
25814 acred.uid = cred->fsuid;
25815 acred.gid = cred->fsgid;
25816 + acred.tag = dx_current_tag();
25817 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
25819 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
25820 @@ -467,6 +469,7 @@ rpcauth_bind_root_cred(struct rpc_task *
25821 struct auth_cred acred = {
25824 + .tag = dx_current_tag(),
25827 dprintk("RPC: %5u looking up %s cred\n",
25828 diff -NurpP --minimal linux-3.2.5/net/sunrpc/auth_unix.c linux-3.2.5-vs2.3.2.6/net/sunrpc/auth_unix.c
25829 --- linux-3.2.5/net/sunrpc/auth_unix.c 2012-01-09 16:15:04.000000000 +0100
25830 +++ linux-3.2.5-vs2.3.2.6/net/sunrpc/auth_unix.c 2011-12-05 19:33:02.000000000 +0100
25831 @@ -12,12 +12,14 @@
25832 #include <linux/module.h>
25833 #include <linux/sunrpc/clnt.h>
25834 #include <linux/sunrpc/auth.h>
25835 +#include <linux/vs_tag.h>
25837 #define NFS_NGROUPS 16
25840 struct rpc_cred uc_base;
25843 gid_t uc_gids[NFS_NGROUPS];
25845 #define uc_uid uc_base.cr_uid
25846 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
25847 groups = NFS_NGROUPS;
25849 cred->uc_gid = acred->gid;
25850 + cred->uc_tag = acred->tag;
25851 for (i = 0; i < groups; i++)
25852 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
25853 if (i < NFS_NGROUPS)
25854 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
25858 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
25859 + if (cred->uc_uid != acred->uid ||
25860 + cred->uc_gid != acred->gid ||
25861 + cred->uc_tag != acred->tag)
25864 if (acred->group_info != NULL)
25865 @@ -145,7 +150,7 @@ unx_marshal(struct rpc_task *task, __be3
25866 struct rpc_clnt *clnt = task->tk_client;
25867 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
25868 __be32 *base, *hold;
25872 *p++ = htonl(RPC_AUTH_UNIX);
25874 @@ -155,9 +160,12 @@ unx_marshal(struct rpc_task *task, __be3
25875 * Copy the UTS nodename captured when the client was created.
25877 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
25878 + tag = task->tk_client->cl_tag;
25880 - *p++ = htonl((u32) cred->uc_uid);
25881 - *p++ = htonl((u32) cred->uc_gid);
25882 + *p++ = htonl((u32) TAGINO_UID(tag,
25883 + cred->uc_uid, cred->uc_tag));
25884 + *p++ = htonl((u32) TAGINO_GID(tag,
25885 + cred->uc_gid, cred->uc_tag));
25887 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
25888 *p++ = htonl((u32) cred->uc_gids[i]);
25889 diff -NurpP --minimal linux-3.2.5/net/sunrpc/clnt.c linux-3.2.5-vs2.3.2.6/net/sunrpc/clnt.c
25890 --- linux-3.2.5/net/sunrpc/clnt.c 2012-01-09 16:15:04.000000000 +0100
25891 +++ linux-3.2.5-vs2.3.2.6/net/sunrpc/clnt.c 2011-12-05 19:33:02.000000000 +0100
25893 #include <linux/in.h>
25894 #include <linux/in6.h>
25895 #include <linux/un.h>
25896 +#include <linux/vs_cvirt.h>
25898 #include <linux/sunrpc/clnt.h>
25899 #include <linux/sunrpc/rpc_pipe_fs.h>
25900 @@ -361,6 +362,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
25901 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
25902 clnt->cl_chatty = 1;
25904 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
25905 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
25906 + clnt->cl_tag = 1; */
25909 EXPORT_SYMBOL_GPL(rpc_create);
25910 diff -NurpP --minimal linux-3.2.5/net/unix/af_unix.c linux-3.2.5-vs2.3.2.6/net/unix/af_unix.c
25911 --- linux-3.2.5/net/unix/af_unix.c 2012-02-07 01:57:55.000000000 +0100
25912 +++ linux-3.2.5-vs2.3.2.6/net/unix/af_unix.c 2012-02-07 03:14:01.000000000 +0100
25913 @@ -114,6 +114,8 @@
25914 #include <linux/mount.h>
25915 #include <net/checksum.h>
25916 #include <linux/security.h>
25917 +#include <linux/vs_context.h>
25918 +#include <linux/vs_limit.h>
25920 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
25921 static DEFINE_SPINLOCK(unix_table_lock);
25922 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
25923 if (!net_eq(sock_net(s), net))
25926 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25928 if (u->addr->len == len &&
25929 !memcmp(u->addr->name, sunname, len))
25931 @@ -2219,6 +2223,8 @@ static struct sock *unix_seq_idx(struct
25932 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
25933 if (sock_net(s) != seq_file_net(seq))
25935 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25940 @@ -2243,7 +2249,8 @@ static void *unix_seq_next(struct seq_fi
25941 sk = first_unix_socket(&iter->i);
25943 sk = next_unix_socket(&iter->i, sk);
25944 - while (sk && (sock_net(sk) != seq_file_net(seq)))
25945 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
25946 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
25947 sk = next_unix_socket(&iter->i, sk);
25950 diff -NurpP --minimal linux-3.2.5/scripts/checksyscalls.sh linux-3.2.5-vs2.3.2.6/scripts/checksyscalls.sh
25951 --- linux-3.2.5/scripts/checksyscalls.sh 2011-03-15 18:07:46.000000000 +0100
25952 +++ linux-3.2.5-vs2.3.2.6/scripts/checksyscalls.sh 2011-12-05 19:33:02.000000000 +0100
25953 @@ -193,7 +193,6 @@ cat << EOF
25954 #define __IGNORE_afs_syscall
25955 #define __IGNORE_getpmsg
25956 #define __IGNORE_putpmsg
25957 -#define __IGNORE_vserver
25961 diff -NurpP --minimal linux-3.2.5/security/commoncap.c linux-3.2.5-vs2.3.2.6/security/commoncap.c
25962 --- linux-3.2.5/security/commoncap.c 2012-01-09 16:15:05.000000000 +0100
25963 +++ linux-3.2.5-vs2.3.2.6/security/commoncap.c 2011-12-05 19:33:02.000000000 +0100
25964 @@ -62,6 +62,7 @@ int cap_netlink_recv(struct sk_buff *skb
25969 EXPORT_SYMBOL(cap_netlink_recv);
25972 @@ -83,14 +84,20 @@ EXPORT_SYMBOL(cap_netlink_recv);
25973 int cap_capable(struct task_struct *tsk, const struct cred *cred,
25974 struct user_namespace *targ_ns, int cap, int audit)
25976 + struct vx_info *vxi = tsk->vx_info;
25979 /* The creator of the user namespace has all caps. */
25980 if (targ_ns != &init_user_ns && targ_ns->creator == cred->user)
25983 /* Do we have the necessary capabilities? */
25984 - if (targ_ns == cred->user->user_ns)
25985 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
25986 + if (targ_ns == cred->user->user_ns) {
25987 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
25988 + cap_raised(cred->cap_effective, cap))
25990 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
25993 /* Have we tried all of the parent namespaces? */
25994 if (targ_ns == &init_user_ns)
25995 @@ -615,7 +622,7 @@ int cap_inode_setxattr(struct dentry *de
25997 if (!strncmp(name, XATTR_SECURITY_PREFIX,
25998 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
25999 - !capable(CAP_SYS_ADMIN))
26000 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26004 @@ -641,7 +648,7 @@ int cap_inode_removexattr(struct dentry
26006 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26007 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26008 - !capable(CAP_SYS_ADMIN))
26009 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26013 diff -NurpP --minimal linux-3.2.5/security/selinux/hooks.c linux-3.2.5-vs2.3.2.6/security/selinux/hooks.c
26014 --- linux-3.2.5/security/selinux/hooks.c 2012-01-09 16:15:05.000000000 +0100
26015 +++ linux-3.2.5-vs2.3.2.6/security/selinux/hooks.c 2011-12-05 19:33:02.000000000 +0100
26017 #include <linux/dccp.h>
26018 #include <linux/quota.h>
26019 #include <linux/un.h> /* for Unix socket types */
26020 -#include <net/af_unix.h> /* for Unix socket types */
26021 #include <linux/parser.h>
26022 #include <linux/nfs_mount.h>
26023 #include <net/ipv6.h>