1 diff -NurpP --minimal linux-3.2.8/Documentation/vserver/debug.txt linux-3.2.8-vs2.3.2.7/Documentation/vserver/debug.txt
2 --- linux-3.2.8/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/alpha/Kconfig linux-3.2.8-vs2.3.2.7/arch/alpha/Kconfig
160 --- linux-3.2.8/arch/alpha/Kconfig 2012-01-09 16:13:54.000000000 +0100
161 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/alpha/kernel/entry.S linux-3.2.8-vs2.3.2.7/arch/alpha/kernel/entry.S
172 --- linux-3.2.8/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
173 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/alpha/kernel/ptrace.c linux-3.2.8-vs2.3.2.7/arch/alpha/kernel/ptrace.c
207 --- linux-3.2.8/arch/alpha/kernel/ptrace.c 2011-01-05 21:48:40.000000000 +0100
208 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/alpha/kernel/systbls.S linux-3.2.8-vs2.3.2.7/arch/alpha/kernel/systbls.S
218 --- linux-3.2.8/arch/alpha/kernel/systbls.S 2012-01-09 16:13:54.000000000 +0100
219 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/alpha/kernel/traps.c linux-3.2.8-vs2.3.2.7/arch/alpha/kernel/traps.c
230 --- linux-3.2.8/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
231 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/arm/Kconfig linux-3.2.8-vs2.3.2.7/arch/arm/Kconfig
243 --- linux-3.2.8/arch/arm/Kconfig 2012-01-09 16:13:54.000000000 +0100
244 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/arm/kernel/calls.S linux-3.2.8-vs2.3.2.7/arch/arm/kernel/calls.S
255 --- linux-3.2.8/arch/arm/kernel/calls.S 2012-01-09 16:13:54.000000000 +0100
256 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/arm/kernel/process.c linux-3.2.8-vs2.3.2.7/arch/arm/kernel/process.c
267 --- linux-3.2.8/arch/arm/kernel/process.c 2012-01-09 16:13:54.000000000 +0100
268 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/arm/kernel/traps.c linux-3.2.8-vs2.3.2.7/arch/arm/kernel/traps.c
280 --- linux-3.2.8/arch/arm/kernel/traps.c 2012-01-09 16:13:54.000000000 +0100
281 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/cris/Kconfig linux-3.2.8-vs2.3.2.7/arch/cris/Kconfig
294 --- linux-3.2.8/arch/cris/Kconfig 2012-01-09 16:14:01.000000000 +0100
295 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/frv/kernel/kernel_thread.S linux-3.2.8-vs2.3.2.7/arch/frv/kernel/kernel_thread.S
306 --- linux-3.2.8/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
307 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/h8300/Kconfig linux-3.2.8-vs2.3.2.7/arch/h8300/Kconfig
318 --- linux-3.2.8/arch/h8300/Kconfig 2012-01-09 16:14:01.000000000 +0100
319 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/ia64/Kconfig linux-3.2.8-vs2.3.2.7/arch/ia64/Kconfig
330 --- linux-3.2.8/arch/ia64/Kconfig 2012-01-09 16:14:01.000000000 +0100
331 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/ia64/kernel/entry.S linux-3.2.8-vs2.3.2.7/arch/ia64/kernel/entry.S
342 --- linux-3.2.8/arch/ia64/kernel/entry.S 2012-01-09 16:14:02.000000000 +0100
343 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/ia64/kernel/process.c linux-3.2.8-vs2.3.2.7/arch/ia64/kernel/process.c
354 --- linux-3.2.8/arch/ia64/kernel/process.c 2011-03-15 18:06:39.000000000 +0100
355 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/ia64/kernel/ptrace.c linux-3.2.8-vs2.3.2.7/arch/ia64/kernel/ptrace.c
368 --- linux-3.2.8/arch/ia64/kernel/ptrace.c 2011-01-05 21:48:59.000000000 +0100
369 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/ia64/kernel/traps.c linux-3.2.8-vs2.3.2.7/arch/ia64/kernel/traps.c
379 --- linux-3.2.8/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
380 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/m32r/kernel/traps.c linux-3.2.8-vs2.3.2.7/arch/m32r/kernel/traps.c
406 --- linux-3.2.8/arch/m32r/kernel/traps.c 2011-10-24 18:44:58.000000000 +0200
407 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/m68k/Kconfig linux-3.2.8-vs2.3.2.7/arch/m68k/Kconfig
421 --- linux-3.2.8/arch/m68k/Kconfig 2012-01-09 16:14:03.000000000 +0100
422 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/mips/Kconfig linux-3.2.8-vs2.3.2.7/arch/mips/Kconfig
433 --- linux-3.2.8/arch/mips/Kconfig 2012-01-09 16:14:04.000000000 +0100
434 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/mips/kernel/ptrace.c linux-3.2.8-vs2.3.2.7/arch/mips/kernel/ptrace.c
445 --- linux-3.2.8/arch/mips/kernel/ptrace.c 2011-07-22 11:17:36.000000000 +0200
446 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/mips/kernel/scall32-o32.S linux-3.2.8-vs2.3.2.7/arch/mips/kernel/scall32-o32.S
466 --- linux-3.2.8/arch/mips/kernel/scall32-o32.S 2012-01-09 16:14:05.000000000 +0100
467 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/mips/kernel/scall64-64.S linux-3.2.8-vs2.3.2.7/arch/mips/kernel/scall64-64.S
478 --- linux-3.2.8/arch/mips/kernel/scall64-64.S 2012-01-09 16:14:05.000000000 +0100
479 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/mips/kernel/scall64-n32.S linux-3.2.8-vs2.3.2.7/arch/mips/kernel/scall64-n32.S
490 --- linux-3.2.8/arch/mips/kernel/scall64-n32.S 2012-01-09 16:14:05.000000000 +0100
491 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/mips/kernel/scall64-o32.S linux-3.2.8-vs2.3.2.7/arch/mips/kernel/scall64-o32.S
502 --- linux-3.2.8/arch/mips/kernel/scall64-o32.S 2012-01-09 16:14:05.000000000 +0100
503 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/mips/kernel/traps.c linux-3.2.8-vs2.3.2.7/arch/mips/kernel/traps.c
514 --- linux-3.2.8/arch/mips/kernel/traps.c 2012-01-09 16:14:05.000000000 +0100
515 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/parisc/Kconfig linux-3.2.8-vs2.3.2.7/arch/parisc/Kconfig
531 --- linux-3.2.8/arch/parisc/Kconfig 2012-01-09 16:14:05.000000000 +0100
532 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/parisc/kernel/syscall_table.S linux-3.2.8-vs2.3.2.7/arch/parisc/kernel/syscall_table.S
543 --- linux-3.2.8/arch/parisc/kernel/syscall_table.S 2011-10-24 18:45:00.000000000 +0200
544 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/parisc/kernel/traps.c linux-3.2.8-vs2.3.2.7/arch/parisc/kernel/traps.c
555 --- linux-3.2.8/arch/parisc/kernel/traps.c 2011-10-24 18:45:00.000000000 +0200
556 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/parisc/mm/fault.c linux-3.2.8-vs2.3.2.7/arch/parisc/mm/fault.c
581 --- linux-3.2.8/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
582 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/powerpc/Kconfig linux-3.2.8-vs2.3.2.7/arch/powerpc/Kconfig
596 --- linux-3.2.8/arch/powerpc/Kconfig 2012-01-09 16:14:05.000000000 +0100
597 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/powerpc/include/asm/unistd.h linux-3.2.8-vs2.3.2.7/arch/powerpc/include/asm/unistd.h
608 --- linux-3.2.8/arch/powerpc/include/asm/unistd.h 2012-01-09 16:14:05.000000000 +0100
609 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/powerpc/kernel/process.c linux-3.2.8-vs2.3.2.7/arch/powerpc/kernel/process.c
620 --- linux-3.2.8/arch/powerpc/kernel/process.c 2012-01-09 16:14:05.000000000 +0100
621 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/powerpc/kernel/traps.c linux-3.2.8-vs2.3.2.7/arch/powerpc/kernel/traps.c
635 --- linux-3.2.8/arch/powerpc/kernel/traps.c 2012-01-09 16:14:05.000000000 +0100
636 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/s390/Kconfig linux-3.2.8-vs2.3.2.7/arch/s390/Kconfig
650 --- linux-3.2.8/arch/s390/Kconfig 2012-01-09 16:14:06.000000000 +0100
651 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/s390/include/asm/tlb.h linux-3.2.8-vs2.3.2.7/arch/s390/include/asm/tlb.h
662 --- linux-3.2.8/arch/s390/include/asm/tlb.h 2011-07-22 11:17:41.000000000 +0200
663 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/s390/include/asm/unistd.h linux-3.2.8-vs2.3.2.7/arch/s390/include/asm/unistd.h
673 --- linux-3.2.8/arch/s390/include/asm/unistd.h 2012-01-09 16:14:06.000000000 +0100
674 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/s390/kernel/ptrace.c linux-3.2.8-vs2.3.2.7/arch/s390/kernel/ptrace.c
685 --- linux-3.2.8/arch/s390/kernel/ptrace.c 2012-01-09 16:14:06.000000000 +0100
686 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/s390/kernel/syscalls.S linux-3.2.8-vs2.3.2.7/arch/s390/kernel/syscalls.S
696 --- linux-3.2.8/arch/s390/kernel/syscalls.S 2012-01-09 16:14:06.000000000 +0100
697 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/sh/Kconfig linux-3.2.8-vs2.3.2.7/arch/sh/Kconfig
708 --- linux-3.2.8/arch/sh/Kconfig 2012-01-09 16:14:07.000000000 +0100
709 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/sh/kernel/irq.c linux-3.2.8-vs2.3.2.7/arch/sh/kernel/irq.c
720 --- linux-3.2.8/arch/sh/kernel/irq.c 2011-07-22 11:17:41.000000000 +0200
721 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/sparc/Kconfig linux-3.2.8-vs2.3.2.7/arch/sparc/Kconfig
731 --- linux-3.2.8/arch/sparc/Kconfig 2012-01-09 16:14:07.000000000 +0100
732 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/sparc/include/asm/unistd.h linux-3.2.8-vs2.3.2.7/arch/sparc/include/asm/unistd.h
743 --- linux-3.2.8/arch/sparc/include/asm/unistd.h 2012-01-09 16:14:07.000000000 +0100
744 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/sparc/kernel/systbls_32.S linux-3.2.8-vs2.3.2.7/arch/sparc/kernel/systbls_32.S
755 --- linux-3.2.8/arch/sparc/kernel/systbls_32.S 2012-01-09 16:14:09.000000000 +0100
756 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/sparc/kernel/systbls_64.S linux-3.2.8-vs2.3.2.7/arch/sparc/kernel/systbls_64.S
767 --- linux-3.2.8/arch/sparc/kernel/systbls_64.S 2012-01-09 16:14:09.000000000 +0100
768 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/um/Kconfig.rest linux-3.2.8-vs2.3.2.7/arch/um/Kconfig.rest
788 --- linux-3.2.8/arch/um/Kconfig.rest 2012-01-09 16:14:09.000000000 +0100
789 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/um/include/shared/kern_constants.h linux-3.2.8-vs2.3.2.7/arch/um/include/shared/kern_constants.h
800 --- linux-3.2.8/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
801 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/um/include/shared/user_constants.h linux-3.2.8-vs2.3.2.7/arch/um/include/shared/user_constants.h
805 --- linux-3.2.8/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
806 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/x86/Kconfig linux-3.2.8-vs2.3.2.7/arch/x86/Kconfig
849 --- linux-3.2.8/arch/x86/Kconfig 2012-01-09 16:14:10.000000000 +0100
850 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/x86/ia32/ia32entry.S linux-3.2.8-vs2.3.2.7/arch/x86/ia32/ia32entry.S
861 --- linux-3.2.8/arch/x86/ia32/ia32entry.S 2012-01-09 16:14:10.000000000 +0100
862 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/x86/include/asm/unistd_64.h linux-3.2.8-vs2.3.2.7/arch/x86/include/asm/unistd_64.h
873 --- linux-3.2.8/arch/x86/include/asm/unistd_64.h 2012-01-09 16:14:11.000000000 +0100
874 +++ linux-3.2.8-vs2.3.2.7/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.8/arch/x86/kernel/syscall_table_32.S linux-3.2.8-vs2.3.2.7/arch/x86/kernel/syscall_table_32.S
885 --- linux-3.2.8/arch/x86/kernel/syscall_table_32.S 2012-01-09 16:14:11.000000000 +0100
886 +++ linux-3.2.8-vs2.3.2.7/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.8/drivers/block/Kconfig linux-3.2.8-vs2.3.2.7/drivers/block/Kconfig
897 --- linux-3.2.8/drivers/block/Kconfig 2011-10-24 18:45:08.000000000 +0200
898 +++ linux-3.2.8-vs2.3.2.7/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.8/drivers/block/Makefile linux-3.2.8-vs2.3.2.7/drivers/block/Makefile
914 --- linux-3.2.8/drivers/block/Makefile 2011-07-22 11:17:44.000000000 +0200
915 +++ linux-3.2.8-vs2.3.2.7/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.8/drivers/block/loop.c linux-3.2.8-vs2.3.2.7/drivers/block/loop.c
925 --- linux-3.2.8/drivers/block/loop.c 2012-01-09 16:14:15.000000000 +0100
926 +++ linux-3.2.8-vs2.3.2.7/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.8/drivers/block/vroot.c linux-3.2.8-vs2.3.2.7/drivers/block/vroot.c
983 --- linux-3.2.8/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
984 +++ linux-3.2.8-vs2.3.2.7/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.8/drivers/infiniband/Kconfig linux-3.2.8-vs2.3.2.7/drivers/infiniband/Kconfig
1278 --- linux-3.2.8/drivers/infiniband/Kconfig 2011-07-22 11:17:45.000000000 +0200
1279 +++ linux-3.2.8-vs2.3.2.7/drivers/infiniband/Kconfig 2012-02-15 03:26:22.000000000 +0100
1280 @@ -39,7 +39,7 @@ config INFINIBAND_USER_MEM
1281 config INFINIBAND_ADDR_TRANS
1284 - depends on !(INFINIBAND = y && IPV6 = m)
1285 + depends on !(INFINIBAND = y && IPV6 = y)
1288 source "drivers/infiniband/hw/mthca/Kconfig"
1289 diff -NurpP --minimal linux-3.2.8/drivers/infiniband/core/addr.c linux-3.2.8-vs2.3.2.7/drivers/infiniband/core/addr.c
1290 --- linux-3.2.8/drivers/infiniband/core/addr.c 2012-01-09 16:14:19.000000000 +0100
1291 +++ linux-3.2.8-vs2.3.2.7/drivers/infiniband/core/addr.c 2011-12-05 19:33:02.000000000 +0100
1292 @@ -255,7 +255,7 @@ static int addr6_resolve(struct sockaddr
1294 if (ipv6_addr_any(&fl6.saddr)) {
1295 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1296 - &fl6.daddr, 0, &fl6.saddr);
1297 + &fl6.daddr, 0, &fl6.saddr, NULL);
1301 diff -NurpP --minimal linux-3.2.8/drivers/md/dm-ioctl.c linux-3.2.8-vs2.3.2.7/drivers/md/dm-ioctl.c
1302 --- linux-3.2.8/drivers/md/dm-ioctl.c 2012-01-09 16:14:20.000000000 +0100
1303 +++ linux-3.2.8-vs2.3.2.7/drivers/md/dm-ioctl.c 2011-12-05 19:33:02.000000000 +0100
1305 #include <linux/dm-ioctl.h>
1306 #include <linux/hdreg.h>
1307 #include <linux/compat.h>
1308 +#include <linux/vs_context.h>
1310 #include <asm/uaccess.h>
1312 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1313 unsigned int h = hash_str(str);
1315 list_for_each_entry (hc, _name_buckets + h, name_list)
1316 - if (!strcmp(hc->name, str)) {
1317 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1318 + !strcmp(hc->name, str)) {
1322 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1323 unsigned int h = hash_str(str);
1325 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1326 - if (!strcmp(hc->uuid, str)) {
1327 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1328 + !strcmp(hc->uuid, str)) {
1332 @@ -131,13 +134,15 @@ static struct hash_cell *__get_uuid_cell
1333 static struct hash_cell *__get_dev_cell(uint64_t dev)
1335 struct mapped_device *md;
1336 - struct hash_cell *hc;
1337 + struct hash_cell *hc = NULL;
1339 md = dm_get_md(huge_decode_dev(dev));
1343 - hc = dm_get_mdptr(md);
1344 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1345 + hc = dm_get_mdptr(md);
1350 @@ -445,6 +450,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1352 static int remove_all(struct dm_ioctl *param, size_t param_size)
1354 + if (!vx_check(0, VS_ADMIN))
1357 dm_hash_remove_all(1);
1358 param->data_size = 0;
1360 @@ -492,6 +500,8 @@ static int list_devices(struct dm_ioctl
1362 for (i = 0; i < NUM_BUCKETS; i++) {
1363 list_for_each_entry (hc, _name_buckets + i, name_list) {
1364 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1366 needed += sizeof(struct dm_name_list);
1367 needed += strlen(hc->name) + 1;
1368 needed += ALIGN_MASK;
1369 @@ -515,6 +525,8 @@ static int list_devices(struct dm_ioctl
1371 for (i = 0; i < NUM_BUCKETS; i++) {
1372 list_for_each_entry (hc, _name_buckets + i, name_list) {
1373 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1376 old_nl->next = (uint32_t) ((void *) nl -
1378 @@ -1615,8 +1627,8 @@ static int ctl_ioctl(uint command, struc
1380 size_t input_param_size;
1382 - /* only root can play with this */
1383 - if (!capable(CAP_SYS_ADMIN))
1384 + /* only root and certain contexts can play with this */
1385 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1388 if (_IOC_TYPE(command) != DM_IOCTL)
1389 diff -NurpP --minimal linux-3.2.8/drivers/md/dm.c linux-3.2.8-vs2.3.2.7/drivers/md/dm.c
1390 --- linux-3.2.8/drivers/md/dm.c 2012-01-09 16:14:21.000000000 +0100
1391 +++ linux-3.2.8-vs2.3.2.7/drivers/md/dm.c 2011-12-05 19:33:02.000000000 +0100
1393 #include <linux/idr.h>
1394 #include <linux/hdreg.h>
1395 #include <linux/delay.h>
1396 +#include <linux/vs_base.h>
1398 #include <trace/events/block.h>
1400 @@ -132,6 +133,7 @@ struct mapped_device {
1403 atomic_t open_count;
1406 unsigned long flags;
1408 @@ -344,6 +346,7 @@ int dm_deleting_md(struct mapped_device
1409 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1411 struct mapped_device *md;
1414 spin_lock(&_minor_lock);
1416 @@ -352,18 +355,19 @@ static int dm_blk_open(struct block_devi
1419 if (test_bit(DMF_FREEING, &md->flags) ||
1420 - dm_deleting_md(md)) {
1422 + dm_deleting_md(md))
1426 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1431 atomic_inc(&md->open_count);
1435 spin_unlock(&_minor_lock);
1437 - return md ? 0 : -ENXIO;
1441 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1442 @@ -584,6 +588,14 @@ int dm_set_geometry(struct mapped_device
1447 + * Get the xid associated with a dm device
1449 +xid_t dm_get_xid(struct mapped_device *md)
1454 /*-----------------------------------------------------------------
1456 * A more elegant soln is in the works that uses the queue
1457 @@ -1850,6 +1862,7 @@ static struct mapped_device *alloc_dev(i
1458 INIT_LIST_HEAD(&md->uevent_list);
1459 spin_lock_init(&md->uevent_lock);
1461 + md->xid = vx_current_xid();
1462 md->queue = blk_alloc_queue(GFP_KERNEL);
1465 diff -NurpP --minimal linux-3.2.8/drivers/md/dm.h linux-3.2.8-vs2.3.2.7/drivers/md/dm.h
1466 --- linux-3.2.8/drivers/md/dm.h 2012-01-09 16:14:21.000000000 +0100
1467 +++ linux-3.2.8-vs2.3.2.7/drivers/md/dm.h 2011-12-05 19:33:02.000000000 +0100
1468 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1470 struct dm_md_mempools;
1472 +xid_t dm_get_xid(struct mapped_device *md);
1474 /*-----------------------------------------------------------------
1475 * Internal table functions.
1476 *---------------------------------------------------------------*/
1477 diff -NurpP --minimal linux-3.2.8/drivers/net/tun.c linux-3.2.8-vs2.3.2.7/drivers/net/tun.c
1478 --- linux-3.2.8/drivers/net/tun.c 2012-01-09 16:14:35.000000000 +0100
1479 +++ linux-3.2.8-vs2.3.2.7/drivers/net/tun.c 2011-12-05 19:33:02.000000000 +0100
1481 #include <linux/nsproxy.h>
1482 #include <linux/virtio_net.h>
1483 #include <linux/rcupdate.h>
1484 +#include <linux/vs_network.h>
1485 #include <net/net_namespace.h>
1486 #include <net/netns/generic.h>
1487 #include <net/rtnetlink.h>
1488 @@ -121,6 +122,7 @@ struct tun_struct {
1494 struct net_device *dev;
1496 @@ -909,6 +911,7 @@ static void tun_setup(struct net_device
1500 + tun->nid = current->nid;
1502 dev->ethtool_ops = &tun_ethtool_ops;
1503 dev->destructor = tun_free_netdev;
1504 @@ -1059,7 +1062,7 @@ static int tun_set_iff(struct net *net,
1506 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1507 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1508 - !capable(CAP_NET_ADMIN))
1509 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1511 err = security_tun_dev_attach(tun->socket.sk);
1513 @@ -1073,7 +1076,7 @@ static int tun_set_iff(struct net *net,
1515 unsigned long flags = 0;
1517 - if (!capable(CAP_NET_ADMIN))
1518 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1520 err = security_tun_dev_create();
1522 @@ -1141,6 +1144,9 @@ static int tun_set_iff(struct net *net,
1524 sk->sk_destruct = tun_sock_destruct;
1526 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1529 err = tun_attach(tun, file);
1532 @@ -1322,6 +1328,16 @@ static long __tun_chr_ioctl(struct file
1533 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
1537 + if (!capable(CAP_CONTEXT))
1540 + /* Set nid owner of the device */
1541 + tun->nid = (nid_t) arg;
1543 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1547 /* Only allow setting the type when the interface is down */
1548 if (tun->dev->flags & IFF_UP) {
1549 diff -NurpP --minimal linux-3.2.8/drivers/tty/sysrq.c linux-3.2.8-vs2.3.2.7/drivers/tty/sysrq.c
1550 --- linux-3.2.8/drivers/tty/sysrq.c 2011-05-22 16:17:44.000000000 +0200
1551 +++ linux-3.2.8-vs2.3.2.7/drivers/tty/sysrq.c 2011-12-05 19:33:02.000000000 +0100
1553 #include <linux/oom.h>
1554 #include <linux/slab.h>
1555 #include <linux/input.h>
1556 +#include <linux/vserver/debug.h>
1558 #include <asm/ptrace.h>
1559 #include <asm/irq_regs.h>
1560 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
1561 .enable_mask = SYSRQ_ENABLE_RTNICE,
1565 +#ifdef CONFIG_VSERVER_DEBUG
1566 +static void sysrq_handle_vxinfo(int key)
1568 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1571 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1572 + .handler = sysrq_handle_vxinfo,
1573 + .help_msg = "conteXt",
1574 + .action_msg = "Show Context Info",
1575 + .enable_mask = SYSRQ_ENABLE_DUMP,
1579 /* Key Operations table and lock */
1580 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1582 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
1584 &sysrq_showstate_blocked_op, /* w */
1585 /* x: May be registered on ppc/powerpc for xmon */
1586 +#ifdef CONFIG_VSERVER_DEBUG
1587 + &sysrq_showvxinfo_op, /* x */
1591 /* y: May be registered on sparc64 for global register dump */
1593 &sysrq_ftrace_dump_op, /* z */
1594 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
1596 else if ((key >= 'a') && (key <= 'z'))
1597 retval = key + 10 - 'a';
1598 + else if ((key >= 'A') && (key <= 'Z'))
1599 + retval = key + 10 - 'A';
1603 diff -NurpP --minimal linux-3.2.8/drivers/tty/tty_io.c linux-3.2.8-vs2.3.2.7/drivers/tty/tty_io.c
1604 --- linux-3.2.8/drivers/tty/tty_io.c 2012-01-09 16:14:48.000000000 +0100
1605 +++ linux-3.2.8-vs2.3.2.7/drivers/tty/tty_io.c 2011-12-05 19:33:02.000000000 +0100
1608 #include <linux/kmod.h>
1609 #include <linux/nsproxy.h>
1610 +#include <linux/vs_pid.h>
1612 #undef TTY_DEBUG_HANGUP
1614 @@ -2080,7 +2081,8 @@ static int tiocsti(struct tty_struct *tt
1616 struct tty_ldisc *ld;
1618 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1619 + if (((current->signal->tty != tty) &&
1620 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1622 if (get_user(ch, p))
1624 @@ -2368,6 +2370,7 @@ static int tiocspgrp(struct tty_struct *
1626 if (get_user(pgrp_nr, p))
1628 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1632 diff -NurpP --minimal linux-3.2.8/fs/attr.c linux-3.2.8-vs2.3.2.7/fs/attr.c
1633 --- linux-3.2.8/fs/attr.c 2012-01-09 16:14:53.000000000 +0100
1634 +++ linux-3.2.8-vs2.3.2.7/fs/attr.c 2011-12-05 21:16:01.000000000 +0100
1636 #include <linux/fcntl.h>
1637 #include <linux/security.h>
1638 #include <linux/evm.h>
1639 +#include <linux/proc_fs.h>
1640 +#include <linux/devpts_fs.h>
1641 +#include <linux/vs_tag.h>
1644 * inode_change_ok - check if attribute changes to an inode are allowed
1645 @@ -74,6 +77,10 @@ int inode_change_ok(const struct inode *
1649 + /* check for inode tag permission */
1650 + if (dx_permission(inode, MAY_WRITE))
1655 EXPORT_SYMBOL(inode_change_ok);
1656 @@ -144,6 +151,8 @@ void setattr_copy(struct inode *inode, c
1657 inode->i_uid = attr->ia_uid;
1658 if (ia_valid & ATTR_GID)
1659 inode->i_gid = attr->ia_gid;
1660 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1661 + inode->i_tag = attr->ia_tag;
1662 if (ia_valid & ATTR_ATIME)
1663 inode->i_atime = timespec_trunc(attr->ia_atime,
1664 inode->i_sb->s_time_gran);
1665 @@ -171,7 +180,8 @@ int notify_change(struct dentry * dentry
1666 struct timespec now;
1667 unsigned int ia_valid = attr->ia_valid;
1669 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1670 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1671 + ATTR_TAG | ATTR_TIMES_SET)) {
1672 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1675 diff -NurpP --minimal linux-3.2.8/fs/block_dev.c linux-3.2.8-vs2.3.2.7/fs/block_dev.c
1676 --- linux-3.2.8/fs/block_dev.c 2012-01-09 16:14:53.000000000 +0100
1677 +++ linux-3.2.8-vs2.3.2.7/fs/block_dev.c 2011-12-05 19:33:02.000000000 +0100
1679 #include <linux/namei.h>
1680 #include <linux/log2.h>
1681 #include <linux/kmemleak.h>
1682 +#include <linux/vs_device.h>
1683 #include <asm/uaccess.h>
1684 #include "internal.h"
1686 @@ -563,6 +564,7 @@ struct block_device *bdget(dev_t dev)
1687 bdev->bd_invalidated = 0;
1688 inode->i_mode = S_IFBLK;
1689 inode->i_rdev = dev;
1690 + inode->i_mdev = dev;
1691 inode->i_bdev = bdev;
1692 inode->i_data.a_ops = &def_blk_aops;
1693 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1694 @@ -609,6 +611,11 @@ EXPORT_SYMBOL(bdput);
1695 static struct block_device *bd_acquire(struct inode *inode)
1697 struct block_device *bdev;
1700 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1702 + inode->i_mdev = mdev;
1704 spin_lock(&bdev_lock);
1705 bdev = inode->i_bdev;
1706 @@ -619,7 +626,7 @@ static struct block_device *bd_acquire(s
1708 spin_unlock(&bdev_lock);
1710 - bdev = bdget(inode->i_rdev);
1711 + bdev = bdget(mdev);
1713 spin_lock(&bdev_lock);
1714 if (!inode->i_bdev) {
1715 diff -NurpP --minimal linux-3.2.8/fs/btrfs/ctree.h linux-3.2.8-vs2.3.2.7/fs/btrfs/ctree.h
1716 --- linux-3.2.8/fs/btrfs/ctree.h 2012-01-09 16:14:53.000000000 +0100
1717 +++ linux-3.2.8-vs2.3.2.7/fs/btrfs/ctree.h 2012-01-09 16:19:31.000000000 +0100
1718 @@ -643,11 +643,14 @@ struct btrfs_inode_item {
1719 /* modification sequence number for NFS */
1724 * a little future expansion, for more than this we can
1725 * just grow the inode item and version it
1727 - __le64 reserved[4];
1728 + __le16 reserved16;
1729 + __le32 reserved32;
1730 + __le64 reserved[3];
1731 struct btrfs_timespec atime;
1732 struct btrfs_timespec ctime;
1733 struct btrfs_timespec mtime;
1734 @@ -1414,6 +1417,8 @@ struct btrfs_ioctl_defrag_range_args {
1735 #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17)
1736 #define BTRFS_MOUNT_RECOVERY (1 << 18)
1738 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1740 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1741 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1742 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
1743 @@ -1621,6 +1626,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1744 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1745 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1746 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1747 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1748 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1749 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1750 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1751 @@ -1674,6 +1680,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1753 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1755 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1756 +#define BTRFS_INODE_BARRIER (1 << 25)
1757 +#define BTRFS_INODE_COW (1 << 26)
1760 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1762 @@ -2730,6 +2740,7 @@ extern const struct dentry_operations bt
1763 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1764 void btrfs_update_iflags(struct inode *inode);
1765 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1766 +int btrfs_sync_flags(struct inode *inode, int, int);
1767 int btrfs_defrag_file(struct inode *inode, struct file *file,
1768 struct btrfs_ioctl_defrag_range_args *range,
1769 u64 newer_than, unsigned long max_pages);
1770 diff -NurpP --minimal linux-3.2.8/fs/btrfs/disk-io.c linux-3.2.8-vs2.3.2.7/fs/btrfs/disk-io.c
1771 --- linux-3.2.8/fs/btrfs/disk-io.c 2012-01-09 16:14:53.000000000 +0100
1772 +++ linux-3.2.8-vs2.3.2.7/fs/btrfs/disk-io.c 2012-01-09 16:19:31.000000000 +0100
1773 @@ -2103,6 +2103,9 @@ struct btrfs_root *open_ctree(struct sup
1777 + if (btrfs_test_opt(tree_root, TAGGED))
1778 + sb->s_flags |= MS_TAGGED;
1780 features = btrfs_super_incompat_flags(disk_super) &
1781 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1783 diff -NurpP --minimal linux-3.2.8/fs/btrfs/inode.c linux-3.2.8-vs2.3.2.7/fs/btrfs/inode.c
1784 --- linux-3.2.8/fs/btrfs/inode.c 2012-01-09 16:14:53.000000000 +0100
1785 +++ linux-3.2.8-vs2.3.2.7/fs/btrfs/inode.c 2012-01-09 16:19:51.000000000 +0100
1787 #include <linux/slab.h>
1788 #include <linux/ratelimit.h>
1789 #include <linux/mount.h>
1790 +#include <linux/vs_tag.h>
1793 #include "disk-io.h"
1794 @@ -2332,6 +2333,8 @@ static void btrfs_read_locked_inode(stru
1795 struct btrfs_key location;
1801 bool filled = false;
1803 @@ -2359,8 +2362,13 @@ static void btrfs_read_locked_inode(stru
1804 struct btrfs_inode_item);
1805 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1806 set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
1807 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
1808 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
1810 + uid = btrfs_inode_uid(leaf, inode_item);
1811 + gid = btrfs_inode_gid(leaf, inode_item);
1812 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
1813 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
1814 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
1815 + btrfs_inode_tag(leaf, inode_item));
1816 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1818 tspec = btrfs_inode_atime(inode_item);
1819 @@ -2438,8 +2446,14 @@ static void fill_inode_item(struct btrfs
1820 struct btrfs_inode_item *item,
1821 struct inode *inode)
1823 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
1824 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
1825 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
1826 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
1828 + btrfs_set_inode_uid(leaf, item, uid);
1829 + btrfs_set_inode_gid(leaf, item, gid);
1830 +#ifdef CONFIG_TAGGING_INTERN
1831 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
1833 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
1834 btrfs_set_inode_mode(leaf, item, inode->i_mode);
1835 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
1836 @@ -7377,11 +7391,13 @@ static const struct inode_operations btr
1837 .listxattr = btrfs_listxattr,
1838 .removexattr = btrfs_removexattr,
1839 .permission = btrfs_permission,
1840 + .sync_flags = btrfs_sync_flags,
1841 .get_acl = btrfs_get_acl,
1843 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1844 .lookup = btrfs_lookup,
1845 .permission = btrfs_permission,
1846 + .sync_flags = btrfs_sync_flags,
1847 .get_acl = btrfs_get_acl,
1850 diff -NurpP --minimal linux-3.2.8/fs/btrfs/ioctl.c linux-3.2.8-vs2.3.2.7/fs/btrfs/ioctl.c
1851 --- linux-3.2.8/fs/btrfs/ioctl.c 2012-01-09 16:14:53.000000000 +0100
1852 +++ linux-3.2.8-vs2.3.2.7/fs/btrfs/ioctl.c 2012-01-09 16:19:31.000000000 +0100
1853 @@ -71,10 +71,13 @@ static unsigned int btrfs_flags_to_ioctl
1855 unsigned int iflags = 0;
1857 - if (flags & BTRFS_INODE_SYNC)
1858 - iflags |= FS_SYNC_FL;
1859 if (flags & BTRFS_INODE_IMMUTABLE)
1860 iflags |= FS_IMMUTABLE_FL;
1861 + if (flags & BTRFS_INODE_IXUNLINK)
1862 + iflags |= FS_IXUNLINK_FL;
1864 + if (flags & BTRFS_INODE_SYNC)
1865 + iflags |= FS_SYNC_FL;
1866 if (flags & BTRFS_INODE_APPEND)
1867 iflags |= FS_APPEND_FL;
1868 if (flags & BTRFS_INODE_NODUMP)
1869 @@ -91,28 +94,78 @@ static unsigned int btrfs_flags_to_ioctl
1870 else if (flags & BTRFS_INODE_NOCOMPRESS)
1871 iflags |= FS_NOCOMP_FL;
1873 + if (flags & BTRFS_INODE_BARRIER)
1874 + iflags |= FS_BARRIER_FL;
1875 + if (flags & BTRFS_INODE_COW)
1876 + iflags |= FS_COW_FL;
1881 - * Update inode->i_flags based on the btrfs internal flags.
1882 + * Update inode->i_(v)flags based on the btrfs internal flags.
1884 void btrfs_update_iflags(struct inode *inode)
1886 struct btrfs_inode *ip = BTRFS_I(inode);
1888 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
1889 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
1890 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
1892 - if (ip->flags & BTRFS_INODE_SYNC)
1893 - inode->i_flags |= S_SYNC;
1894 if (ip->flags & BTRFS_INODE_IMMUTABLE)
1895 inode->i_flags |= S_IMMUTABLE;
1896 + if (ip->flags & BTRFS_INODE_IXUNLINK)
1897 + inode->i_flags |= S_IXUNLINK;
1899 + if (ip->flags & BTRFS_INODE_SYNC)
1900 + inode->i_flags |= S_SYNC;
1901 if (ip->flags & BTRFS_INODE_APPEND)
1902 inode->i_flags |= S_APPEND;
1903 if (ip->flags & BTRFS_INODE_NOATIME)
1904 inode->i_flags |= S_NOATIME;
1905 if (ip->flags & BTRFS_INODE_DIRSYNC)
1906 inode->i_flags |= S_DIRSYNC;
1908 + inode->i_vflags &= ~(V_BARRIER | V_COW);
1910 + if (ip->flags & BTRFS_INODE_BARRIER)
1911 + inode->i_vflags |= V_BARRIER;
1912 + if (ip->flags & BTRFS_INODE_COW)
1913 + inode->i_vflags |= V_COW;
1917 + * Update btrfs internal flags from inode->i_(v)flags.
1919 +void btrfs_update_flags(struct inode *inode)
1921 + struct btrfs_inode *ip = BTRFS_I(inode);
1923 + unsigned int flags = inode->i_flags;
1924 + unsigned int vflags = inode->i_vflags;
1926 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
1927 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
1928 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
1929 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
1931 + if (flags & S_IMMUTABLE)
1932 + ip->flags |= BTRFS_INODE_IMMUTABLE;
1933 + if (flags & S_IXUNLINK)
1934 + ip->flags |= BTRFS_INODE_IXUNLINK;
1936 + if (flags & S_SYNC)
1937 + ip->flags |= BTRFS_INODE_SYNC;
1938 + if (flags & S_APPEND)
1939 + ip->flags |= BTRFS_INODE_APPEND;
1940 + if (flags & S_NOATIME)
1941 + ip->flags |= BTRFS_INODE_NOATIME;
1942 + if (flags & S_DIRSYNC)
1943 + ip->flags |= BTRFS_INODE_DIRSYNC;
1945 + if (vflags & V_BARRIER)
1946 + ip->flags |= BTRFS_INODE_BARRIER;
1947 + if (vflags & V_COW)
1948 + ip->flags |= BTRFS_INODE_COW;
1952 @@ -128,6 +181,7 @@ void btrfs_inherit_iflags(struct inode *
1955 flags = BTRFS_I(dir)->flags;
1956 + flags &= ~BTRFS_INODE_BARRIER;
1958 if (flags & BTRFS_INODE_NOCOMPRESS) {
1959 BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
1960 @@ -143,6 +197,30 @@ void btrfs_inherit_iflags(struct inode *
1961 btrfs_update_iflags(inode);
1964 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
1966 + struct btrfs_inode *ip = BTRFS_I(inode);
1967 + struct btrfs_root *root = ip->root;
1968 + struct btrfs_trans_handle *trans;
1971 + trans = btrfs_join_transaction(root);
1974 + inode->i_flags = flags;
1975 + inode->i_vflags = vflags;
1976 + btrfs_update_flags(inode);
1978 + ret = btrfs_update_inode(trans, root, inode);
1981 + btrfs_update_iflags(inode);
1982 + inode->i_ctime = CURRENT_TIME;
1983 + btrfs_end_transaction(trans, root);
1988 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
1990 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
1991 @@ -194,7 +272,8 @@ static int btrfs_ioctl_setflags(struct f
1993 flags = btrfs_mask_flags(inode->i_mode, flags);
1994 oldflags = btrfs_flags_to_ioctl(ip->flags);
1995 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
1996 + if ((flags ^ oldflags) & (FS_APPEND_FL |
1997 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
1998 if (!capable(CAP_LINUX_IMMUTABLE)) {
2001 @@ -205,14 +284,19 @@ static int btrfs_ioctl_setflags(struct f
2005 - if (flags & FS_SYNC_FL)
2006 - ip->flags |= BTRFS_INODE_SYNC;
2008 - ip->flags &= ~BTRFS_INODE_SYNC;
2009 if (flags & FS_IMMUTABLE_FL)
2010 ip->flags |= BTRFS_INODE_IMMUTABLE;
2012 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2013 + if (flags & FS_IXUNLINK_FL)
2014 + ip->flags |= BTRFS_INODE_IXUNLINK;
2016 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2018 + if (flags & FS_SYNC_FL)
2019 + ip->flags |= BTRFS_INODE_SYNC;
2021 + ip->flags &= ~BTRFS_INODE_SYNC;
2022 if (flags & FS_APPEND_FL)
2023 ip->flags |= BTRFS_INODE_APPEND;
2025 diff -NurpP --minimal linux-3.2.8/fs/btrfs/super.c linux-3.2.8-vs2.3.2.7/fs/btrfs/super.c
2026 --- linux-3.2.8/fs/btrfs/super.c 2012-01-09 16:14:53.000000000 +0100
2027 +++ linux-3.2.8-vs2.3.2.7/fs/btrfs/super.c 2012-01-09 16:19:31.000000000 +0100
2028 @@ -165,7 +165,8 @@ enum {
2029 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
2030 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
2031 Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,
2032 - Opt_inode_cache, Opt_no_space_cache, Opt_recovery, Opt_err,
2033 + Opt_inode_cache, Opt_no_space_cache, Opt_recovery,
2034 + Opt_tag, Opt_notag, Opt_tagid, Opt_err,
2037 static match_table_t tokens = {
2038 @@ -200,6 +201,9 @@ static match_table_t tokens = {
2039 {Opt_inode_cache, "inode_cache"},
2040 {Opt_no_space_cache, "nospace_cache"},
2041 {Opt_recovery, "recovery"},
2043 + {Opt_notag, "notag"},
2044 + {Opt_tagid, "tagid=%u"},
2048 @@ -398,6 +402,22 @@ int btrfs_parse_options(struct btrfs_roo
2049 printk(KERN_INFO "btrfs: enabling auto recovery");
2050 btrfs_set_opt(info->mount_opt, RECOVERY);
2052 +#ifndef CONFIG_TAGGING_NONE
2054 + printk(KERN_INFO "btrfs: use tagging\n");
2055 + btrfs_set_opt(info->mount_opt, TAGGED);
2058 + printk(KERN_INFO "btrfs: disabled tagging\n");
2059 + btrfs_clear_opt(info->mount_opt, TAGGED);
2062 +#ifdef CONFIG_PROPAGATE
2065 + btrfs_set_opt(info->mount_opt, TAGGED);
2069 printk(KERN_INFO "btrfs: unrecognized mount option "
2071 @@ -985,6 +1005,12 @@ static int btrfs_remount(struct super_bl
2075 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2076 + printk("btrfs: %s: tagging not permitted on remount.\n",
2081 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2084 diff -NurpP --minimal linux-3.2.8/fs/char_dev.c linux-3.2.8-vs2.3.2.7/fs/char_dev.c
2085 --- linux-3.2.8/fs/char_dev.c 2011-03-15 18:07:31.000000000 +0100
2086 +++ linux-3.2.8-vs2.3.2.7/fs/char_dev.c 2011-12-05 19:33:02.000000000 +0100
2088 #include <linux/mutex.h>
2089 #include <linux/backing-dev.h>
2090 #include <linux/tty.h>
2091 +#include <linux/vs_context.h>
2092 +#include <linux/vs_device.h>
2094 #include "internal.h"
2096 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2098 struct cdev *new = NULL;
2102 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2104 + inode->i_mdev = mdev;
2106 spin_lock(&cdev_lock);
2109 struct kobject *kobj;
2112 spin_unlock(&cdev_lock);
2113 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2115 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2118 new = container_of(kobj, struct cdev, kobj);
2119 diff -NurpP --minimal linux-3.2.8/fs/dcache.c linux-3.2.8-vs2.3.2.7/fs/dcache.c
2120 --- linux-3.2.8/fs/dcache.c 2012-02-28 05:53:29.000000000 +0100
2121 +++ linux-3.2.8-vs2.3.2.7/fs/dcache.c 2012-01-26 08:52:10.000000000 +0100
2123 #include <linux/rculist_bl.h>
2124 #include <linux/prefetch.h>
2125 #include <linux/ratelimit.h>
2126 +#include <linux/vs_limit.h>
2127 #include "internal.h"
2130 @@ -539,6 +540,8 @@ int d_invalidate(struct dentry * dentry)
2131 spin_lock(&dentry->d_lock);
2134 + vx_dentry_dec(dentry);
2137 * Somebody else still using it?
2139 @@ -568,6 +571,7 @@ EXPORT_SYMBOL(d_invalidate);
2140 static inline void __dget_dlock(struct dentry *dentry)
2143 + vx_dentry_inc(dentry);
2146 static inline void __dget(struct dentry *dentry)
2147 @@ -1192,6 +1196,9 @@ struct dentry *__d_alloc(struct super_bl
2148 struct dentry *dentry;
2151 + if (!vx_dentry_avail(1))
2154 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2157 @@ -1214,6 +1221,7 @@ struct dentry *__d_alloc(struct super_bl
2159 dentry->d_count = 1;
2160 dentry->d_flags = 0;
2161 + vx_dentry_inc(dentry);
2162 spin_lock_init(&dentry->d_lock);
2163 seqcount_init(&dentry->d_seq);
2164 dentry->d_inode = NULL;
2165 @@ -1872,6 +1880,7 @@ struct dentry *__d_lookup(struct dentry
2169 + vx_dentry_inc(dentry);
2171 spin_unlock(&dentry->d_lock);
2173 diff -NurpP --minimal linux-3.2.8/fs/devpts/inode.c linux-3.2.8-vs2.3.2.7/fs/devpts/inode.c
2174 --- linux-3.2.8/fs/devpts/inode.c 2012-01-09 16:14:54.000000000 +0100
2175 +++ linux-3.2.8-vs2.3.2.7/fs/devpts/inode.c 2011-12-05 21:23:19.000000000 +0100
2177 #include <linux/parser.h>
2178 #include <linux/fsnotify.h>
2179 #include <linux/seq_file.h>
2180 +#include <linux/vs_base.h>
2182 #define DEVPTS_DEFAULT_MODE 0600
2185 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2186 #define PTMX_MINOR 2
2188 +static int devpts_permission(struct inode *inode, int mask)
2190 + int ret = -EACCES;
2192 + /* devpts is xid tagged */
2193 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2194 + ret = generic_permission(inode, mask);
2198 +static struct inode_operations devpts_file_inode_operations = {
2199 + .permission = devpts_permission,
2202 extern int pty_limit; /* Config limit on Unix98 ptys */
2203 static DEFINE_MUTEX(allocated_ptys_lock);
2205 @@ -263,6 +278,34 @@ static int devpts_show_options(struct se
2209 +static int devpts_filter(struct dentry *de)
2213 + /* devpts is xid tagged */
2214 + if (de && de->d_inode)
2215 + xid = (xid_t)de->d_inode->i_tag;
2216 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2218 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2219 + de->d_name.len, de->d_name.name);
2221 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2224 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2226 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2229 +static struct file_operations devpts_dir_operations = {
2230 + .open = dcache_dir_open,
2231 + .release = dcache_dir_close,
2232 + .llseek = dcache_dir_lseek,
2233 + .read = generic_read_dir,
2234 + .readdir = devpts_readdir,
2237 static const struct super_operations devpts_sops = {
2238 .statfs = simple_statfs,
2239 .remount_fs = devpts_remount,
2240 @@ -306,8 +349,10 @@ devpts_fill_super(struct super_block *s,
2241 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2242 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2243 inode->i_op = &simple_dir_inode_operations;
2244 - inode->i_fop = &simple_dir_operations;
2245 + inode->i_fop = &devpts_dir_operations;
2246 set_nlink(inode, 2);
2247 + /* devpts is xid tagged */
2248 + inode->i_tag = (tag_t)vx_current_xid();
2250 s->s_root = d_alloc_root(inode);
2252 @@ -494,6 +539,9 @@ int devpts_pty_new(struct inode *ptmx_in
2253 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2254 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2255 init_special_inode(inode, S_IFCHR|opts->mode, device);
2256 + /* devpts is xid tagged */
2257 + inode->i_tag = (tag_t)vx_current_xid();
2258 + inode->i_op = &devpts_file_inode_operations;
2259 inode->i_private = tty;
2260 tty->driver_data = inode;
2262 diff -NurpP --minimal linux-3.2.8/fs/ext2/balloc.c linux-3.2.8-vs2.3.2.7/fs/ext2/balloc.c
2263 --- linux-3.2.8/fs/ext2/balloc.c 2012-01-09 16:14:54.000000000 +0100
2264 +++ linux-3.2.8-vs2.3.2.7/fs/ext2/balloc.c 2011-12-05 19:33:02.000000000 +0100
2265 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2267 end = EXT2_BLOCKS_PER_GROUP(sb);
2270 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2273 diff -NurpP --minimal linux-3.2.8/fs/ext2/ext2.h linux-3.2.8-vs2.3.2.7/fs/ext2/ext2.h
2274 --- linux-3.2.8/fs/ext2/ext2.h 2012-01-09 16:14:54.000000000 +0100
2275 +++ linux-3.2.8-vs2.3.2.7/fs/ext2/ext2.h 2011-12-05 19:33:02.000000000 +0100
2276 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct
2277 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2278 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2279 u64 start, u64 len);
2280 +extern int ext2_sync_flags(struct inode *, int, int);
2283 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2284 diff -NurpP --minimal linux-3.2.8/fs/ext2/file.c linux-3.2.8-vs2.3.2.7/fs/ext2/file.c
2285 --- linux-3.2.8/fs/ext2/file.c 2011-10-24 18:45:27.000000000 +0200
2286 +++ linux-3.2.8-vs2.3.2.7/fs/ext2/file.c 2011-12-05 19:33:02.000000000 +0100
2287 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2288 .setattr = ext2_setattr,
2289 .get_acl = ext2_get_acl,
2290 .fiemap = ext2_fiemap,
2291 + .sync_flags = ext2_sync_flags,
2293 diff -NurpP --minimal linux-3.2.8/fs/ext2/ialloc.c linux-3.2.8-vs2.3.2.7/fs/ext2/ialloc.c
2294 --- linux-3.2.8/fs/ext2/ialloc.c 2012-01-09 16:14:54.000000000 +0100
2295 +++ linux-3.2.8-vs2.3.2.7/fs/ext2/ialloc.c 2011-12-05 19:33:02.000000000 +0100
2297 #include <linux/backing-dev.h>
2298 #include <linux/buffer_head.h>
2299 #include <linux/random.h>
2300 +#include <linux/vs_tag.h>
2304 @@ -549,6 +550,7 @@ got:
2305 inode->i_mode = mode;
2306 inode->i_uid = current_fsuid();
2307 inode->i_gid = dir->i_gid;
2308 + inode->i_tag = dx_current_fstag(sb);
2310 inode_init_owner(inode, dir, mode);
2312 diff -NurpP --minimal linux-3.2.8/fs/ext2/inode.c linux-3.2.8-vs2.3.2.7/fs/ext2/inode.c
2313 --- linux-3.2.8/fs/ext2/inode.c 2012-01-09 16:14:54.000000000 +0100
2314 +++ linux-3.2.8-vs2.3.2.7/fs/ext2/inode.c 2011-12-05 21:24:12.000000000 +0100
2316 #include <linux/mpage.h>
2317 #include <linux/fiemap.h>
2318 #include <linux/namei.h>
2319 +#include <linux/vs_tag.h>
2323 @@ -1167,7 +1168,7 @@ static void ext2_truncate_blocks(struct
2325 if (ext2_inode_is_fast_symlink(inode))
2327 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2328 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2330 __ext2_truncate_blocks(inode, offset);
2332 @@ -1258,36 +1259,61 @@ void ext2_set_inode_flags(struct inode *
2334 unsigned int flags = EXT2_I(inode)->i_flags;
2336 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2337 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2338 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2341 + if (flags & EXT2_IMMUTABLE_FL)
2342 + inode->i_flags |= S_IMMUTABLE;
2343 + if (flags & EXT2_IXUNLINK_FL)
2344 + inode->i_flags |= S_IXUNLINK;
2346 if (flags & EXT2_SYNC_FL)
2347 inode->i_flags |= S_SYNC;
2348 if (flags & EXT2_APPEND_FL)
2349 inode->i_flags |= S_APPEND;
2350 - if (flags & EXT2_IMMUTABLE_FL)
2351 - inode->i_flags |= S_IMMUTABLE;
2352 if (flags & EXT2_NOATIME_FL)
2353 inode->i_flags |= S_NOATIME;
2354 if (flags & EXT2_DIRSYNC_FL)
2355 inode->i_flags |= S_DIRSYNC;
2357 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2359 + if (flags & EXT2_BARRIER_FL)
2360 + inode->i_vflags |= V_BARRIER;
2361 + if (flags & EXT2_COW_FL)
2362 + inode->i_vflags |= V_COW;
2365 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2366 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2368 unsigned int flags = ei->vfs_inode.i_flags;
2369 + unsigned int vflags = ei->vfs_inode.i_vflags;
2371 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2372 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2373 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2374 + EXT2_BARRIER_FL | EXT2_COW_FL);
2376 + if (flags & S_IMMUTABLE)
2377 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2378 + if (flags & S_IXUNLINK)
2379 + ei->i_flags |= EXT2_IXUNLINK_FL;
2381 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2382 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2384 ei->i_flags |= EXT2_SYNC_FL;
2385 if (flags & S_APPEND)
2386 ei->i_flags |= EXT2_APPEND_FL;
2387 - if (flags & S_IMMUTABLE)
2388 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2389 if (flags & S_NOATIME)
2390 ei->i_flags |= EXT2_NOATIME_FL;
2391 if (flags & S_DIRSYNC)
2392 ei->i_flags |= EXT2_DIRSYNC_FL;
2394 + if (vflags & V_BARRIER)
2395 + ei->i_flags |= EXT2_BARRIER_FL;
2396 + if (vflags & V_COW)
2397 + ei->i_flags |= EXT2_COW_FL;
2400 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2401 @@ -1297,6 +1323,8 @@ struct inode *ext2_iget (struct super_bl
2402 struct ext2_inode *raw_inode;
2403 struct inode *inode;
2409 inode = iget_locked(sb, ino);
2410 @@ -1315,12 +1343,16 @@ struct inode *ext2_iget (struct super_bl
2413 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2414 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2415 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2416 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2417 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2418 if (!(test_opt (inode->i_sb, NO_UID32))) {
2419 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2420 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2421 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2422 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2424 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2425 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2426 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2427 + le16_to_cpu(raw_inode->i_raw_tag));
2428 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2429 inode->i_size = le32_to_cpu(raw_inode->i_size);
2430 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2431 @@ -1418,8 +1450,8 @@ static int __ext2_write_inode(struct ino
2432 struct ext2_inode_info *ei = EXT2_I(inode);
2433 struct super_block *sb = inode->i_sb;
2434 ino_t ino = inode->i_ino;
2435 - uid_t uid = inode->i_uid;
2436 - gid_t gid = inode->i_gid;
2437 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2438 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2439 struct buffer_head * bh;
2440 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2442 @@ -1455,6 +1487,9 @@ static int __ext2_write_inode(struct ino
2443 raw_inode->i_uid_high = 0;
2444 raw_inode->i_gid_high = 0;
2446 +#ifdef CONFIG_TAGGING_INTERN
2447 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2449 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2450 raw_inode->i_size = cpu_to_le32(inode->i_size);
2451 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2452 @@ -1535,7 +1570,8 @@ int ext2_setattr(struct dentry *dentry,
2453 if (is_quota_modification(inode, iattr))
2454 dquot_initialize(inode);
2455 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2456 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2457 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2458 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2459 error = dquot_transfer(inode, iattr);
2462 diff -NurpP --minimal linux-3.2.8/fs/ext2/ioctl.c linux-3.2.8-vs2.3.2.7/fs/ext2/ioctl.c
2463 --- linux-3.2.8/fs/ext2/ioctl.c 2011-05-22 16:17:51.000000000 +0200
2464 +++ linux-3.2.8-vs2.3.2.7/fs/ext2/ioctl.c 2011-12-05 19:33:02.000000000 +0100
2466 #include <asm/uaccess.h>
2469 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2471 + inode->i_flags = flags;
2472 + inode->i_vflags = vflags;
2473 + ext2_get_inode_flags(EXT2_I(inode));
2474 + inode->i_ctime = CURRENT_TIME_SEC;
2475 + mark_inode_dirty(inode);
2479 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2481 struct inode *inode = filp->f_dentry->d_inode;
2482 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2484 flags = ext2_mask_flags(inode->i_mode, flags);
2486 + if (IS_BARRIER(inode)) {
2487 + vxwprintk_task(1, "messing with the barrier.");
2491 mutex_lock(&inode->i_mutex);
2492 /* Is it quota file? Do not allow user to mess with it */
2493 if (IS_NOQUOTA(inode)) {
2494 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2496 * This test looks nicer. Thanks to Pauline Middelink
2498 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2499 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2500 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2501 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2502 if (!capable(CAP_LINUX_IMMUTABLE)) {
2503 mutex_unlock(&inode->i_mutex);
2505 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2509 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2510 + flags &= EXT2_FL_USER_MODIFIABLE;
2511 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2512 ei->i_flags = flags;
2513 mutex_unlock(&inode->i_mutex);
2514 diff -NurpP --minimal linux-3.2.8/fs/ext2/namei.c linux-3.2.8-vs2.3.2.7/fs/ext2/namei.c
2515 --- linux-3.2.8/fs/ext2/namei.c 2011-10-24 18:45:27.000000000 +0200
2516 +++ linux-3.2.8-vs2.3.2.7/fs/ext2/namei.c 2011-12-05 19:33:02.000000000 +0100
2519 #include <linux/pagemap.h>
2520 #include <linux/quotaops.h>
2521 +#include <linux/vs_tag.h>
2525 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
2526 (unsigned long) ino);
2527 return ERR_PTR(-EIO);
2529 + dx_propagate_tag(nd, inode);
2531 return d_splice_alias(inode, dentry);
2533 @@ -408,6 +410,7 @@ const struct inode_operations ext2_dir_i
2534 .removexattr = generic_removexattr,
2536 .setattr = ext2_setattr,
2537 + .sync_flags = ext2_sync_flags,
2538 .get_acl = ext2_get_acl,
2541 diff -NurpP --minimal linux-3.2.8/fs/ext2/super.c linux-3.2.8-vs2.3.2.7/fs/ext2/super.c
2542 --- linux-3.2.8/fs/ext2/super.c 2012-01-09 16:14:54.000000000 +0100
2543 +++ linux-3.2.8-vs2.3.2.7/fs/ext2/super.c 2011-12-05 19:33:02.000000000 +0100
2544 @@ -394,7 +394,8 @@ enum {
2545 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2546 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2547 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2548 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2549 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2550 + Opt_tag, Opt_notag, Opt_tagid
2553 static const match_table_t tokens = {
2554 @@ -422,6 +423,9 @@ static const match_table_t tokens = {
2556 {Opt_noacl, "noacl"},
2559 + {Opt_notag, "notag"},
2560 + {Opt_tagid, "tagid=%u"},
2561 {Opt_grpquota, "grpquota"},
2562 {Opt_ignore, "noquota"},
2563 {Opt_quota, "quota"},
2564 @@ -492,6 +496,20 @@ static int parse_options(char *options,
2566 set_opt (sbi->s_mount_opt, NO_UID32);
2568 +#ifndef CONFIG_TAGGING_NONE
2570 + set_opt (sbi->s_mount_opt, TAGGED);
2573 + clear_opt (sbi->s_mount_opt, TAGGED);
2576 +#ifdef CONFIG_PROPAGATE
2579 + set_opt (sbi->s_mount_opt, TAGGED);
2583 clear_opt (sbi->s_mount_opt, CHECK);
2585 @@ -850,6 +868,8 @@ static int ext2_fill_super(struct super_
2586 if (!parse_options((char *) data, sb))
2589 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2590 + sb->s_flags |= MS_TAGGED;
2591 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2592 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2594 @@ -1224,6 +1244,14 @@ static int ext2_remount (struct super_bl
2598 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2599 + !(sb->s_flags & MS_TAGGED)) {
2600 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2603 + goto restore_opts;
2606 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2607 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2609 diff -NurpP --minimal linux-3.2.8/fs/ext3/file.c linux-3.2.8-vs2.3.2.7/fs/ext3/file.c
2610 --- linux-3.2.8/fs/ext3/file.c 2011-10-24 18:45:27.000000000 +0200
2611 +++ linux-3.2.8-vs2.3.2.7/fs/ext3/file.c 2011-12-05 19:33:02.000000000 +0100
2612 @@ -80,5 +80,6 @@ const struct inode_operations ext3_file_
2614 .get_acl = ext3_get_acl,
2615 .fiemap = ext3_fiemap,
2616 + .sync_flags = ext3_sync_flags,
2619 diff -NurpP --minimal linux-3.2.8/fs/ext3/ialloc.c linux-3.2.8-vs2.3.2.7/fs/ext3/ialloc.c
2620 --- linux-3.2.8/fs/ext3/ialloc.c 2012-01-09 16:14:54.000000000 +0100
2621 +++ linux-3.2.8-vs2.3.2.7/fs/ext3/ialloc.c 2011-12-05 19:33:02.000000000 +0100
2623 #include <linux/buffer_head.h>
2624 #include <linux/random.h>
2625 #include <linux/bitops.h>
2626 +#include <linux/vs_tag.h>
2627 #include <trace/events/ext3.h>
2629 #include <asm/byteorder.h>
2630 @@ -496,6 +497,7 @@ got:
2631 inode->i_mode = mode;
2632 inode->i_uid = current_fsuid();
2633 inode->i_gid = dir->i_gid;
2634 + inode->i_tag = dx_current_fstag(sb);
2636 inode_init_owner(inode, dir, mode);
2638 diff -NurpP --minimal linux-3.2.8/fs/ext3/inode.c linux-3.2.8-vs2.3.2.7/fs/ext3/inode.c
2639 --- linux-3.2.8/fs/ext3/inode.c 2012-02-28 05:53:29.000000000 +0100
2640 +++ linux-3.2.8-vs2.3.2.7/fs/ext3/inode.c 2012-01-18 02:58:07.000000000 +0100
2642 #include <linux/bio.h>
2643 #include <linux/fiemap.h>
2644 #include <linux/namei.h>
2645 +#include <linux/vs_tag.h>
2646 #include <trace/events/ext3.h>
2649 @@ -2852,36 +2853,60 @@ void ext3_set_inode_flags(struct inode *
2651 unsigned int flags = EXT3_I(inode)->i_flags;
2653 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2654 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2655 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2657 + if (flags & EXT3_IMMUTABLE_FL)
2658 + inode->i_flags |= S_IMMUTABLE;
2659 + if (flags & EXT3_IXUNLINK_FL)
2660 + inode->i_flags |= S_IXUNLINK;
2662 if (flags & EXT3_SYNC_FL)
2663 inode->i_flags |= S_SYNC;
2664 if (flags & EXT3_APPEND_FL)
2665 inode->i_flags |= S_APPEND;
2666 - if (flags & EXT3_IMMUTABLE_FL)
2667 - inode->i_flags |= S_IMMUTABLE;
2668 if (flags & EXT3_NOATIME_FL)
2669 inode->i_flags |= S_NOATIME;
2670 if (flags & EXT3_DIRSYNC_FL)
2671 inode->i_flags |= S_DIRSYNC;
2673 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2675 + if (flags & EXT3_BARRIER_FL)
2676 + inode->i_vflags |= V_BARRIER;
2677 + if (flags & EXT3_COW_FL)
2678 + inode->i_vflags |= V_COW;
2681 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2682 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2684 unsigned int flags = ei->vfs_inode.i_flags;
2685 + unsigned int vflags = ei->vfs_inode.i_vflags;
2687 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2688 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2689 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2690 + EXT3_BARRIER_FL | EXT3_COW_FL);
2692 + if (flags & S_IMMUTABLE)
2693 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2694 + if (flags & S_IXUNLINK)
2695 + ei->i_flags |= EXT3_IXUNLINK_FL;
2697 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2698 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2700 ei->i_flags |= EXT3_SYNC_FL;
2701 if (flags & S_APPEND)
2702 ei->i_flags |= EXT3_APPEND_FL;
2703 - if (flags & S_IMMUTABLE)
2704 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2705 if (flags & S_NOATIME)
2706 ei->i_flags |= EXT3_NOATIME_FL;
2707 if (flags & S_DIRSYNC)
2708 ei->i_flags |= EXT3_DIRSYNC_FL;
2710 + if (vflags & V_BARRIER)
2711 + ei->i_flags |= EXT3_BARRIER_FL;
2712 + if (vflags & V_COW)
2713 + ei->i_flags |= EXT3_COW_FL;
2716 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2717 @@ -2895,6 +2920,8 @@ struct inode *ext3_iget(struct super_blo
2718 transaction_t *transaction;
2724 inode = iget_locked(sb, ino);
2726 @@ -2911,12 +2938,16 @@ struct inode *ext3_iget(struct super_blo
2728 raw_inode = ext3_raw_inode(&iloc);
2729 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2730 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2731 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2732 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2733 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2734 if(!(test_opt (inode->i_sb, NO_UID32))) {
2735 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2736 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2737 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2738 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2740 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2741 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2742 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2743 + le16_to_cpu(raw_inode->i_raw_tag));
2744 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2745 inode->i_size = le32_to_cpu(raw_inode->i_size);
2746 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2747 @@ -3071,6 +3102,8 @@ static int ext3_do_update_inode(handle_t
2748 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
2749 struct ext3_inode_info *ei = EXT3_I(inode);
2750 struct buffer_head *bh = iloc->bh;
2751 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2752 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2753 int err = 0, rc, block;
2756 @@ -3085,29 +3118,32 @@ again:
2757 ext3_get_inode_flags(ei);
2758 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2759 if(!(test_opt(inode->i_sb, NO_UID32))) {
2760 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
2761 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
2762 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
2763 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
2765 * Fix up interoperability with old kernels. Otherwise, old inodes get
2766 * re-used with the upper 16 bits of the uid/gid intact
2769 raw_inode->i_uid_high =
2770 - cpu_to_le16(high_16_bits(inode->i_uid));
2771 + cpu_to_le16(high_16_bits(uid));
2772 raw_inode->i_gid_high =
2773 - cpu_to_le16(high_16_bits(inode->i_gid));
2774 + cpu_to_le16(high_16_bits(gid));
2776 raw_inode->i_uid_high = 0;
2777 raw_inode->i_gid_high = 0;
2780 raw_inode->i_uid_low =
2781 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
2782 + cpu_to_le16(fs_high2lowuid(uid));
2783 raw_inode->i_gid_low =
2784 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
2785 + cpu_to_le16(fs_high2lowgid(gid));
2786 raw_inode->i_uid_high = 0;
2787 raw_inode->i_gid_high = 0;
2789 +#ifdef CONFIG_TAGGING_INTERN
2790 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2792 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2793 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
2794 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2795 @@ -3267,7 +3303,8 @@ int ext3_setattr(struct dentry *dentry,
2796 if (is_quota_modification(inode, attr))
2797 dquot_initialize(inode);
2798 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2799 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
2800 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2801 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
2804 /* (user+group)*(old+new) structure, inode write (sb,
2805 @@ -3289,6 +3326,8 @@ int ext3_setattr(struct dentry *dentry,
2806 inode->i_uid = attr->ia_uid;
2807 if (attr->ia_valid & ATTR_GID)
2808 inode->i_gid = attr->ia_gid;
2809 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2810 + inode->i_tag = attr->ia_tag;
2811 error = ext3_mark_inode_dirty(handle, inode);
2812 ext3_journal_stop(handle);
2814 diff -NurpP --minimal linux-3.2.8/fs/ext3/ioctl.c linux-3.2.8-vs2.3.2.7/fs/ext3/ioctl.c
2815 --- linux-3.2.8/fs/ext3/ioctl.c 2012-01-09 16:14:54.000000000 +0100
2816 +++ linux-3.2.8-vs2.3.2.7/fs/ext3/ioctl.c 2011-12-05 19:33:02.000000000 +0100
2820 #include <linux/fs.h>
2821 +#include <linux/mount.h>
2822 #include <linux/jbd.h>
2823 #include <linux/capability.h>
2824 #include <linux/ext3_fs.h>
2826 #include <linux/compat.h>
2827 #include <asm/uaccess.h>
2830 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2832 + handle_t *handle = NULL;
2833 + struct ext3_iloc iloc;
2836 + handle = ext3_journal_start(inode, 1);
2837 + if (IS_ERR(handle))
2838 + return PTR_ERR(handle);
2840 + if (IS_SYNC(inode))
2841 + handle->h_sync = 1;
2842 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2846 + inode->i_flags = flags;
2847 + inode->i_vflags = vflags;
2848 + ext3_get_inode_flags(EXT3_I(inode));
2849 + inode->i_ctime = CURRENT_TIME_SEC;
2851 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2853 + ext3_journal_stop(handle);
2857 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2859 struct inode *inode = filp->f_dentry->d_inode;
2860 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
2862 flags = ext3_mask_flags(inode->i_mode, flags);
2864 + if (IS_BARRIER(inode)) {
2865 + vxwprintk_task(1, "messing with the barrier.");
2869 mutex_lock(&inode->i_mutex);
2871 /* Is it quota file? Do not allow user to mess with it */
2872 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
2874 * This test looks nicer. Thanks to Pauline Middelink
2876 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2877 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2878 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2879 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2880 if (!capable(CAP_LINUX_IMMUTABLE))
2883 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
2887 - flags = flags & EXT3_FL_USER_MODIFIABLE;
2888 + flags &= EXT3_FL_USER_MODIFIABLE;
2889 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
2890 ei->i_flags = flags;
2892 diff -NurpP --minimal linux-3.2.8/fs/ext3/namei.c linux-3.2.8-vs2.3.2.7/fs/ext3/namei.c
2893 --- linux-3.2.8/fs/ext3/namei.c 2012-01-09 16:14:54.000000000 +0100
2894 +++ linux-3.2.8-vs2.3.2.7/fs/ext3/namei.c 2011-12-05 19:33:02.000000000 +0100
2896 #include <linux/quotaops.h>
2897 #include <linux/buffer_head.h>
2898 #include <linux/bio.h>
2899 +#include <linux/vs_tag.h>
2900 #include <trace/events/ext3.h>
2903 @@ -925,6 +926,7 @@ restart:
2904 ll_rw_block(READ | REQ_META | REQ_PRIO,
2907 + dx_propagate_tag(nd, inode);
2909 if ((bh = bh_use[ra_ptr++]) == NULL)
2911 @@ -2535,6 +2537,7 @@ const struct inode_operations ext3_dir_i
2912 .listxattr = ext3_listxattr,
2913 .removexattr = generic_removexattr,
2915 + .sync_flags = ext3_sync_flags,
2916 .get_acl = ext3_get_acl,
2919 diff -NurpP --minimal linux-3.2.8/fs/ext3/super.c linux-3.2.8-vs2.3.2.7/fs/ext3/super.c
2920 --- linux-3.2.8/fs/ext3/super.c 2012-01-09 16:14:54.000000000 +0100
2921 +++ linux-3.2.8-vs2.3.2.7/fs/ext3/super.c 2011-12-05 19:33:02.000000000 +0100
2922 @@ -831,7 +831,8 @@ enum {
2923 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2924 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
2925 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
2926 - Opt_resize, Opt_usrquota, Opt_grpquota
2927 + Opt_resize, Opt_usrquota, Opt_grpquota,
2928 + Opt_tag, Opt_notag, Opt_tagid
2931 static const match_table_t tokens = {
2932 @@ -888,6 +889,9 @@ static const match_table_t tokens = {
2933 {Opt_barrier, "barrier"},
2934 {Opt_nobarrier, "nobarrier"},
2935 {Opt_resize, "resize"},
2937 + {Opt_notag, "notag"},
2938 + {Opt_tagid, "tagid=%u"},
2942 @@ -1040,6 +1044,20 @@ static int parse_options (char *options,
2944 set_opt (sbi->s_mount_opt, NO_UID32);
2946 +#ifndef CONFIG_TAGGING_NONE
2948 + set_opt (sbi->s_mount_opt, TAGGED);
2951 + clear_opt (sbi->s_mount_opt, TAGGED);
2954 +#ifdef CONFIG_PROPAGATE
2957 + set_opt (sbi->s_mount_opt, TAGGED);
2961 clear_opt (sbi->s_mount_opt, CHECK);
2963 @@ -1738,6 +1756,9 @@ static int ext3_fill_super (struct super
2967 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
2968 + sb->s_flags |= MS_TAGGED;
2970 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2971 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2973 @@ -2619,6 +2640,14 @@ static int ext3_remount (struct super_bl
2974 if (test_opt(sb, ABORT))
2975 ext3_abort(sb, __func__, "Abort forced by user");
2977 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
2978 + !(sb->s_flags & MS_TAGGED)) {
2979 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
2982 + goto restore_opts;
2985 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2986 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2988 diff -NurpP --minimal linux-3.2.8/fs/ext4/ext4.h linux-3.2.8-vs2.3.2.7/fs/ext4/ext4.h
2989 --- linux-3.2.8/fs/ext4/ext4.h 2012-01-09 16:14:54.000000000 +0100
2990 +++ linux-3.2.8-vs2.3.2.7/fs/ext4/ext4.h 2011-12-05 19:33:02.000000000 +0100
2991 @@ -371,8 +371,12 @@ struct flex_groups {
2992 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
2993 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
2994 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
2995 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2996 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
2998 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2999 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3001 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3002 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3004 @@ -632,7 +636,8 @@ struct ext4_inode {
3005 __le16 l_i_file_acl_high;
3006 __le16 l_i_uid_high; /* these 2 fields */
3007 __le16 l_i_gid_high; /* were reserved2[0] */
3008 - __u32 l_i_reserved2;
3009 + __le16 l_i_tag; /* Context Tag */
3010 + __u16 l_i_reserved2;
3013 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3014 @@ -750,6 +755,7 @@ do { \
3015 #define i_gid_low i_gid
3016 #define i_uid_high osd2.linux2.l_i_uid_high
3017 #define i_gid_high osd2.linux2.l_i_gid_high
3018 +#define i_raw_tag osd2.linux2.l_i_tag
3019 #define i_reserved2 osd2.linux2.l_i_reserved2
3021 #elif defined(__GNU__)
3022 @@ -926,6 +932,7 @@ struct ext4_inode_info {
3023 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3024 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3025 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3026 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3027 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3028 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3029 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3030 @@ -2270,6 +2277,7 @@ extern int ext4_map_blocks(handle_t *han
3031 struct ext4_map_blocks *map, int flags);
3032 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3033 __u64 start, __u64 len);
3034 +extern int ext4_sync_flags(struct inode *, int, int);
3036 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3037 __u64 start_orig, __u64 start_donor,
3038 diff -NurpP --minimal linux-3.2.8/fs/ext4/file.c linux-3.2.8-vs2.3.2.7/fs/ext4/file.c
3039 --- linux-3.2.8/fs/ext4/file.c 2012-01-09 16:14:54.000000000 +0100
3040 +++ linux-3.2.8-vs2.3.2.7/fs/ext4/file.c 2011-12-05 19:33:02.000000000 +0100
3041 @@ -258,5 +258,6 @@ const struct inode_operations ext4_file_
3043 .get_acl = ext4_get_acl,
3044 .fiemap = ext4_fiemap,
3045 + .sync_flags = ext4_sync_flags,
3048 diff -NurpP --minimal linux-3.2.8/fs/ext4/ialloc.c linux-3.2.8-vs2.3.2.7/fs/ext4/ialloc.c
3049 --- linux-3.2.8/fs/ext4/ialloc.c 2012-01-09 16:14:54.000000000 +0100
3050 +++ linux-3.2.8-vs2.3.2.7/fs/ext4/ialloc.c 2011-12-05 19:33:02.000000000 +0100
3052 #include <linux/random.h>
3053 #include <linux/bitops.h>
3054 #include <linux/blkdev.h>
3055 +#include <linux/vs_tag.h>
3056 #include <asm/byteorder.h>
3059 @@ -860,6 +861,7 @@ got:
3060 inode->i_mode = mode;
3061 inode->i_uid = current_fsuid();
3062 inode->i_gid = dir->i_gid;
3063 + inode->i_tag = dx_current_fstag(sb);
3065 inode_init_owner(inode, dir, mode);
3067 diff -NurpP --minimal linux-3.2.8/fs/ext4/inode.c linux-3.2.8-vs2.3.2.7/fs/ext4/inode.c
3068 --- linux-3.2.8/fs/ext4/inode.c 2012-01-09 16:14:54.000000000 +0100
3069 +++ linux-3.2.8-vs2.3.2.7/fs/ext4/inode.c 2012-01-09 16:19:31.000000000 +0100
3071 #include <linux/printk.h>
3072 #include <linux/slab.h>
3073 #include <linux/ratelimit.h>
3074 +#include <linux/vs_tag.h>
3076 #include "ext4_jbd2.h"
3078 @@ -3667,41 +3668,64 @@ void ext4_set_inode_flags(struct inode *
3080 unsigned int flags = EXT4_I(inode)->i_flags;
3082 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3083 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3084 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3086 + if (flags & EXT4_IMMUTABLE_FL)
3087 + inode->i_flags |= S_IMMUTABLE;
3088 + if (flags & EXT4_IXUNLINK_FL)
3089 + inode->i_flags |= S_IXUNLINK;
3091 if (flags & EXT4_SYNC_FL)
3092 inode->i_flags |= S_SYNC;
3093 if (flags & EXT4_APPEND_FL)
3094 inode->i_flags |= S_APPEND;
3095 - if (flags & EXT4_IMMUTABLE_FL)
3096 - inode->i_flags |= S_IMMUTABLE;
3097 if (flags & EXT4_NOATIME_FL)
3098 inode->i_flags |= S_NOATIME;
3099 if (flags & EXT4_DIRSYNC_FL)
3100 inode->i_flags |= S_DIRSYNC;
3102 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3104 + if (flags & EXT4_BARRIER_FL)
3105 + inode->i_vflags |= V_BARRIER;
3106 + if (flags & EXT4_COW_FL)
3107 + inode->i_vflags |= V_COW;
3110 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3111 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3113 - unsigned int vfs_fl;
3114 + unsigned int vfs_fl, vfs_vf;
3115 unsigned long old_fl, new_fl;
3118 vfs_fl = ei->vfs_inode.i_flags;
3119 + vfs_vf = ei->vfs_inode.i_vflags;
3120 old_fl = ei->i_flags;
3121 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3122 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3124 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3127 + if (vfs_fl & S_IMMUTABLE)
3128 + new_fl |= EXT4_IMMUTABLE_FL;
3129 + if (vfs_fl & S_IXUNLINK)
3130 + new_fl |= EXT4_IXUNLINK_FL;
3132 if (vfs_fl & S_SYNC)
3133 new_fl |= EXT4_SYNC_FL;
3134 if (vfs_fl & S_APPEND)
3135 new_fl |= EXT4_APPEND_FL;
3136 - if (vfs_fl & S_IMMUTABLE)
3137 - new_fl |= EXT4_IMMUTABLE_FL;
3138 if (vfs_fl & S_NOATIME)
3139 new_fl |= EXT4_NOATIME_FL;
3140 if (vfs_fl & S_DIRSYNC)
3141 new_fl |= EXT4_DIRSYNC_FL;
3143 + if (vfs_vf & V_BARRIER)
3144 + new_fl |= EXT4_BARRIER_FL;
3145 + if (vfs_vf & V_COW)
3146 + new_fl |= EXT4_COW_FL;
3147 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3150 @@ -3737,6 +3761,8 @@ struct inode *ext4_iget(struct super_blo
3151 journal_t *journal = EXT4_SB(sb)->s_journal;
3157 inode = iget_locked(sb, ino);
3159 @@ -3752,12 +3778,16 @@ struct inode *ext4_iget(struct super_blo
3161 raw_inode = ext4_raw_inode(&iloc);
3162 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3163 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3164 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3165 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3166 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3167 if (!(test_opt(inode->i_sb, NO_UID32))) {
3168 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3169 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3170 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3171 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3173 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3174 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3175 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3176 + le16_to_cpu(raw_inode->i_raw_tag));
3177 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
3179 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3180 @@ -3976,6 +4006,8 @@ static int ext4_do_update_inode(handle_t
3181 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3182 struct ext4_inode_info *ei = EXT4_I(inode);
3183 struct buffer_head *bh = iloc->bh;
3184 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3185 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3186 int err = 0, rc, block;
3188 /* For fields not not tracking in the in-memory inode,
3189 @@ -3986,29 +4018,32 @@ static int ext4_do_update_inode(handle_t
3190 ext4_get_inode_flags(ei);
3191 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3192 if (!(test_opt(inode->i_sb, NO_UID32))) {
3193 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3194 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3195 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3196 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3198 * Fix up interoperability with old kernels. Otherwise, old inodes get
3199 * re-used with the upper 16 bits of the uid/gid intact
3202 raw_inode->i_uid_high =
3203 - cpu_to_le16(high_16_bits(inode->i_uid));
3204 + cpu_to_le16(high_16_bits(uid));
3205 raw_inode->i_gid_high =
3206 - cpu_to_le16(high_16_bits(inode->i_gid));
3207 + cpu_to_le16(high_16_bits(gid));
3209 raw_inode->i_uid_high = 0;
3210 raw_inode->i_gid_high = 0;
3213 raw_inode->i_uid_low =
3214 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3215 + cpu_to_le16(fs_high2lowuid(uid));
3216 raw_inode->i_gid_low =
3217 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3218 + cpu_to_le16(fs_high2lowgid(gid));
3219 raw_inode->i_uid_high = 0;
3220 raw_inode->i_gid_high = 0;
3222 +#ifdef CONFIG_TAGGING_INTERN
3223 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3225 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3227 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3228 @@ -4194,7 +4229,8 @@ int ext4_setattr(struct dentry *dentry,
3229 if (is_quota_modification(inode, attr))
3230 dquot_initialize(inode);
3231 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3232 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3233 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3234 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3237 /* (user+group)*(old+new) structure, inode write (sb,
3238 @@ -4216,6 +4252,8 @@ int ext4_setattr(struct dentry *dentry,
3239 inode->i_uid = attr->ia_uid;
3240 if (attr->ia_valid & ATTR_GID)
3241 inode->i_gid = attr->ia_gid;
3242 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3243 + inode->i_tag = attr->ia_tag;
3244 error = ext4_mark_inode_dirty(handle, inode);
3245 ext4_journal_stop(handle);
3247 diff -NurpP --minimal linux-3.2.8/fs/ext4/ioctl.c linux-3.2.8-vs2.3.2.7/fs/ext4/ioctl.c
3248 --- linux-3.2.8/fs/ext4/ioctl.c 2012-02-28 05:53:29.000000000 +0100
3249 +++ linux-3.2.8-vs2.3.2.7/fs/ext4/ioctl.c 2012-01-26 08:52:10.000000000 +0100
3251 #include <linux/compat.h>
3252 #include <linux/mount.h>
3253 #include <linux/file.h>
3254 +#include <linux/vs_tag.h>
3255 #include <asm/uaccess.h>
3256 #include "ext4_jbd2.h"
3260 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3262 + handle_t *handle = NULL;
3263 + struct ext4_iloc iloc;
3266 + handle = ext4_journal_start(inode, 1);
3267 + if (IS_ERR(handle))
3268 + return PTR_ERR(handle);
3270 + if (IS_SYNC(inode))
3271 + ext4_handle_sync(handle);
3272 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3276 + inode->i_flags = flags;
3277 + inode->i_vflags = vflags;
3278 + ext4_get_inode_flags(EXT4_I(inode));
3279 + inode->i_ctime = ext4_current_time(inode);
3281 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3283 + ext4_journal_stop(handle);
3287 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3289 struct inode *inode = filp->f_dentry->d_inode;
3290 @@ -51,6 +80,11 @@ long ext4_ioctl(struct file *filp, unsig
3292 flags = ext4_mask_flags(inode->i_mode, flags);
3294 + if (IS_BARRIER(inode)) {
3295 + vxwprintk_task(1, "messing with the barrier.");
3300 mutex_lock(&inode->i_mutex);
3301 /* Is it quota file? Do not allow user to mess with it */
3302 @@ -68,7 +102,9 @@ long ext4_ioctl(struct file *filp, unsig
3304 * This test looks nicer. Thanks to Pauline Middelink
3306 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3307 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3308 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3309 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3310 if (!capable(CAP_LINUX_IMMUTABLE))
3313 diff -NurpP --minimal linux-3.2.8/fs/ext4/namei.c linux-3.2.8-vs2.3.2.7/fs/ext4/namei.c
3314 --- linux-3.2.8/fs/ext4/namei.c 2012-01-09 16:14:54.000000000 +0100
3315 +++ linux-3.2.8-vs2.3.2.7/fs/ext4/namei.c 2011-12-05 19:33:02.000000000 +0100
3317 #include <linux/quotaops.h>
3318 #include <linux/buffer_head.h>
3319 #include <linux/bio.h>
3320 +#include <linux/vs_tag.h>
3322 #include "ext4_jbd2.h"
3324 @@ -925,6 +926,7 @@ restart:
3325 ll_rw_block(READ | REQ_META | REQ_PRIO,
3328 + dx_propagate_tag(nd, inode);
3330 if ((bh = bh_use[ra_ptr++]) == NULL)
3332 @@ -2587,6 +2589,7 @@ const struct inode_operations ext4_dir_i
3334 .get_acl = ext4_get_acl,
3335 .fiemap = ext4_fiemap,
3336 + .sync_flags = ext4_sync_flags,
3339 const struct inode_operations ext4_special_inode_operations = {
3340 diff -NurpP --minimal linux-3.2.8/fs/ext4/super.c linux-3.2.8-vs2.3.2.7/fs/ext4/super.c
3341 --- linux-3.2.8/fs/ext4/super.c 2012-02-28 05:53:29.000000000 +0100
3342 +++ linux-3.2.8-vs2.3.2.7/fs/ext4/super.c 2012-01-26 08:52:10.000000000 +0100
3343 @@ -1334,6 +1334,7 @@ enum {
3344 Opt_inode_readahead_blks, Opt_journal_ioprio,
3345 Opt_dioread_nolock, Opt_dioread_lock,
3346 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
3347 + Opt_tag, Opt_notag, Opt_tagid
3350 static const match_table_t tokens = {
3351 @@ -1409,6 +1410,9 @@ static const match_table_t tokens = {
3352 {Opt_init_itable, "init_itable=%u"},
3353 {Opt_init_itable, "init_itable"},
3354 {Opt_noinit_itable, "noinit_itable"},
3356 + {Opt_notag, "notag"},
3357 + {Opt_tagid, "tagid=%u"},
3361 @@ -1577,6 +1581,20 @@ static int parse_options(char *options,
3363 set_opt(sb, NO_UID32);
3365 +#ifndef CONFIG_TAGGING_NONE
3367 + set_opt(sb, TAGGED);
3370 + clear_opt(sb, TAGGED);
3373 +#ifdef CONFIG_PROPAGATE
3376 + set_opt(sb, TAGGED);
3382 @@ -3278,6 +3296,9 @@ static int ext4_fill_super(struct super_
3386 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3387 + sb->s_flags |= MS_TAGGED;
3389 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3390 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3392 @@ -4427,6 +4448,14 @@ static int ext4_remount(struct super_blo
3393 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3394 ext4_abort(sb, "Abort forced by user");
3396 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3397 + !(sb->s_flags & MS_TAGGED)) {
3398 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3401 + goto restore_opts;
3404 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3405 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3407 diff -NurpP --minimal linux-3.2.8/fs/fcntl.c linux-3.2.8-vs2.3.2.7/fs/fcntl.c
3408 --- linux-3.2.8/fs/fcntl.c 2011-05-22 16:17:52.000000000 +0200
3409 +++ linux-3.2.8-vs2.3.2.7/fs/fcntl.c 2011-12-05 19:33:02.000000000 +0100
3411 #include <linux/signal.h>
3412 #include <linux/rcupdate.h>
3413 #include <linux/pid_namespace.h>
3414 +#include <linux/vs_limit.h>
3416 #include <asm/poll.h>
3417 #include <asm/siginfo.h>
3418 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3421 filp_close(tofree, files);
3423 + vx_openfd_inc(newfd); /* fd was unused */
3427 @@ -447,6 +450,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3428 filp = fget_raw(fd);
3431 + if (!vx_files_avail(1))
3434 if (unlikely(filp->f_mode & FMODE_PATH)) {
3435 if (!check_fcntl_cmd(cmd)) {
3436 diff -NurpP --minimal linux-3.2.8/fs/file.c linux-3.2.8-vs2.3.2.7/fs/file.c
3437 --- linux-3.2.8/fs/file.c 2011-05-22 16:17:52.000000000 +0200
3438 +++ linux-3.2.8-vs2.3.2.7/fs/file.c 2011-12-05 19:33:02.000000000 +0100
3440 #include <linux/spinlock.h>
3441 #include <linux/rcupdate.h>
3442 #include <linux/workqueue.h>
3443 +#include <linux/vs_limit.h>
3445 struct fdtable_defer {
3447 @@ -359,6 +360,8 @@ struct files_struct *dup_fd(struct files
3448 struct file *f = *old_fds++;
3451 + /* TODO: sum it first for check and performance */
3452 + vx_openfd_inc(open_files - i);
3455 * The fd may be claimed in the fd bitmap but not yet
3456 @@ -466,6 +469,7 @@ repeat:
3458 FD_CLR(fd, fdt->close_on_exec);
3460 + vx_openfd_inc(fd);
3463 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3464 diff -NurpP --minimal linux-3.2.8/fs/file_table.c linux-3.2.8-vs2.3.2.7/fs/file_table.c
3465 --- linux-3.2.8/fs/file_table.c 2011-10-24 18:45:27.000000000 +0200
3466 +++ linux-3.2.8-vs2.3.2.7/fs/file_table.c 2011-12-05 19:33:02.000000000 +0100
3468 #include <linux/percpu_counter.h>
3469 #include <linux/percpu.h>
3470 #include <linux/ima.h>
3471 +#include <linux/vs_limit.h>
3472 +#include <linux/vs_context.h>
3474 #include <linux/atomic.h>
3476 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
3477 spin_lock_init(&f->f_lock);
3478 eventpoll_init_file(f);
3479 /* f->f_version: 0 */
3480 + f->f_xid = vx_current_xid();
3485 @@ -253,6 +257,8 @@ static void __fput(struct file *file)
3487 fops_put(file->f_op);
3488 put_pid(file->f_owner.pid);
3489 + vx_files_dec(file);
3491 file_sb_list_del(file);
3492 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
3493 i_readcount_dec(inode);
3494 @@ -383,6 +389,8 @@ void put_filp(struct file *file)
3496 if (atomic_long_dec_and_test(&file->f_count)) {
3497 security_file_free(file);
3498 + vx_files_dec(file);
3500 file_sb_list_del(file);
3503 diff -NurpP --minimal linux-3.2.8/fs/fs_struct.c linux-3.2.8-vs2.3.2.7/fs/fs_struct.c
3504 --- linux-3.2.8/fs/fs_struct.c 2011-03-15 18:07:31.000000000 +0100
3505 +++ linux-3.2.8-vs2.3.2.7/fs/fs_struct.c 2011-12-05 19:33:02.000000000 +0100
3507 #include <linux/path.h>
3508 #include <linux/slab.h>
3509 #include <linux/fs_struct.h>
3510 +#include <linux/vserver/global.h>
3511 #include "internal.h"
3513 static inline void path_get_longterm(struct path *path)
3514 @@ -96,6 +97,7 @@ void free_fs_struct(struct fs_struct *fs
3516 path_put_longterm(&fs->root);
3517 path_put_longterm(&fs->pwd);
3518 + atomic_dec(&vs_global_fs);
3519 kmem_cache_free(fs_cachep, fs);
3522 @@ -135,6 +137,7 @@ struct fs_struct *copy_fs_struct(struct
3524 path_get_longterm(&fs->pwd);
3525 spin_unlock(&old->lock);
3526 + atomic_inc(&vs_global_fs);
3530 diff -NurpP --minimal linux-3.2.8/fs/gfs2/file.c linux-3.2.8-vs2.3.2.7/fs/gfs2/file.c
3531 --- linux-3.2.8/fs/gfs2/file.c 2012-01-09 16:14:54.000000000 +0100
3532 +++ linux-3.2.8-vs2.3.2.7/fs/gfs2/file.c 2011-12-05 19:33:02.000000000 +0100
3533 @@ -143,6 +143,9 @@ static const u32 fsflags_to_gfs2[32] = {
3534 [7] = GFS2_DIF_NOATIME,
3535 [12] = GFS2_DIF_EXHASH,
3536 [14] = GFS2_DIF_INHERIT_JDATA,
3537 + [27] = GFS2_DIF_IXUNLINK,
3538 + [26] = GFS2_DIF_BARRIER,
3539 + [29] = GFS2_DIF_COW,
3542 static const u32 gfs2_to_fsflags[32] = {
3543 @@ -152,6 +155,9 @@ static const u32 gfs2_to_fsflags[32] = {
3544 [gfs2fl_NoAtime] = FS_NOATIME_FL,
3545 [gfs2fl_ExHash] = FS_INDEX_FL,
3546 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3547 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3548 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3549 + [gfs2fl_Cow] = FS_COW_FL,
3552 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3553 @@ -182,12 +188,18 @@ void gfs2_set_inode_flags(struct inode *
3555 struct gfs2_inode *ip = GFS2_I(inode);
3556 unsigned int flags = inode->i_flags;
3557 + unsigned int vflags = inode->i_vflags;
3559 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3560 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
3562 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
3563 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
3564 inode->i_flags |= S_NOSEC;
3565 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3566 flags |= S_IMMUTABLE;
3567 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3568 + flags |= S_IXUNLINK;
3570 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3572 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3573 @@ -195,6 +207,43 @@ void gfs2_set_inode_flags(struct inode *
3574 if (ip->i_diskflags & GFS2_DIF_SYNC)
3576 inode->i_flags = flags;
3578 + vflags &= ~(V_BARRIER | V_COW);
3580 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3581 + vflags |= V_BARRIER;
3582 + if (ip->i_diskflags & GFS2_DIF_COW)
3584 + inode->i_vflags = vflags;
3587 +void gfs2_get_inode_flags(struct inode *inode)
3589 + struct gfs2_inode *ip = GFS2_I(inode);
3590 + unsigned int flags = inode->i_flags;
3591 + unsigned int vflags = inode->i_vflags;
3593 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3594 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3595 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3596 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3598 + if (flags & S_IMMUTABLE)
3599 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3600 + if (flags & S_IXUNLINK)
3601 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3603 + if (flags & S_APPEND)
3604 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3605 + if (flags & S_NOATIME)
3606 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3607 + if (flags & S_SYNC)
3608 + ip->i_diskflags |= GFS2_DIF_SYNC;
3610 + if (vflags & V_BARRIER)
3611 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3612 + if (vflags & V_COW)
3613 + ip->i_diskflags |= GFS2_DIF_COW;
3616 /* Flags that can be set by user space */
3617 @@ -306,6 +355,37 @@ static int gfs2_set_flags(struct file *f
3618 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3621 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3623 + struct gfs2_inode *ip = GFS2_I(inode);
3624 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3625 + struct buffer_head *bh;
3626 + struct gfs2_holder gh;
3629 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3632 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3635 + error = gfs2_meta_inode_buffer(ip, &bh);
3637 + goto out_trans_end;
3638 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
3639 + inode->i_flags = flags;
3640 + inode->i_vflags = vflags;
3641 + gfs2_get_inode_flags(inode);
3642 + gfs2_dinode_out(ip, bh->b_data);
3644 + gfs2_set_aops(inode);
3646 + gfs2_trans_end(sdp);
3648 + gfs2_glock_dq_uninit(&gh);
3652 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3655 diff -NurpP --minimal linux-3.2.8/fs/gfs2/inode.h linux-3.2.8-vs2.3.2.7/fs/gfs2/inode.h
3656 --- linux-3.2.8/fs/gfs2/inode.h 2012-01-09 16:14:54.000000000 +0100
3657 +++ linux-3.2.8-vs2.3.2.7/fs/gfs2/inode.h 2011-12-05 19:33:02.000000000 +0100
3658 @@ -120,6 +120,7 @@ extern const struct file_operations gfs2
3659 extern const struct file_operations gfs2_dir_fops_nolock;
3661 extern void gfs2_set_inode_flags(struct inode *inode);
3662 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3664 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3665 extern const struct file_operations gfs2_file_fops;
3666 diff -NurpP --minimal linux-3.2.8/fs/inode.c linux-3.2.8-vs2.3.2.7/fs/inode.c
3667 --- linux-3.2.8/fs/inode.c 2012-01-09 16:14:54.000000000 +0100
3668 +++ linux-3.2.8-vs2.3.2.7/fs/inode.c 2011-12-05 19:33:02.000000000 +0100
3670 #include <linux/ima.h>
3671 #include <linux/cred.h>
3672 #include <linux/buffer_head.h> /* for inode_has_buffers */
3673 +#include <linux/vs_tag.h>
3674 #include "internal.h"
3677 @@ -137,6 +138,9 @@ int inode_init_always(struct super_block
3678 struct address_space *const mapping = &inode->i_data;
3682 + /* essential because of inode slab reuse */
3684 inode->i_blkbits = sb->s_blocksize_bits;
3686 atomic_set(&inode->i_count, 1);
3687 @@ -158,6 +162,7 @@ int inode_init_always(struct super_block
3688 inode->i_bdev = NULL;
3689 inode->i_cdev = NULL;
3691 + inode->i_mdev = 0;
3692 inode->dirtied_when = 0;
3694 if (security_inode_alloc(inode))
3695 @@ -399,6 +404,8 @@ void __insert_inode_hash(struct inode *i
3697 EXPORT_SYMBOL(__insert_inode_hash);
3699 +EXPORT_SYMBOL_GPL(__iget);
3702 * __remove_inode_hash - remove an inode from the hash
3703 * @inode: inode to unhash
3704 @@ -1626,9 +1633,11 @@ void init_special_inode(struct inode *in
3705 if (S_ISCHR(mode)) {
3706 inode->i_fop = &def_chr_fops;
3707 inode->i_rdev = rdev;
3708 + inode->i_mdev = rdev;
3709 } else if (S_ISBLK(mode)) {
3710 inode->i_fop = &def_blk_fops;
3711 inode->i_rdev = rdev;
3712 + inode->i_mdev = rdev;
3713 } else if (S_ISFIFO(mode))
3714 inode->i_fop = &def_fifo_fops;
3715 else if (S_ISSOCK(mode))
3716 @@ -1657,6 +1666,7 @@ void inode_init_owner(struct inode *inod
3718 inode->i_gid = current_fsgid();
3719 inode->i_mode = mode;
3720 + inode->i_tag = dx_current_fstag(inode->i_sb);
3722 EXPORT_SYMBOL(inode_init_owner);
3724 diff -NurpP --minimal linux-3.2.8/fs/ioctl.c linux-3.2.8-vs2.3.2.7/fs/ioctl.c
3725 --- linux-3.2.8/fs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3726 +++ linux-3.2.8-vs2.3.2.7/fs/ioctl.c 2011-12-05 19:33:02.000000000 +0100
3728 #include <linux/writeback.h>
3729 #include <linux/buffer_head.h>
3730 #include <linux/falloc.h>
3731 +#include <linux/proc_fs.h>
3732 +#include <linux/vserver/inode.h>
3733 +#include <linux/vs_tag.h>
3735 #include <asm/ioctls.h>
3737 diff -NurpP --minimal linux-3.2.8/fs/ioprio.c linux-3.2.8-vs2.3.2.7/fs/ioprio.c
3738 --- linux-3.2.8/fs/ioprio.c 2012-01-09 16:14:54.000000000 +0100
3739 +++ linux-3.2.8-vs2.3.2.7/fs/ioprio.c 2011-12-05 19:33:02.000000000 +0100
3741 #include <linux/syscalls.h>
3742 #include <linux/security.h>
3743 #include <linux/pid_namespace.h>
3744 +#include <linux/vs_base.h>
3746 int set_task_ioprio(struct task_struct *task, int ioprio)
3748 @@ -120,6 +121,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3750 pgrp = find_vpid(who);
3751 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3752 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3754 ret = set_task_ioprio(p, ioprio);
3757 @@ -209,6 +212,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3759 pgrp = find_vpid(who);
3760 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3761 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3763 tmpio = get_task_ioprio(p);
3766 diff -NurpP --minimal linux-3.2.8/fs/jfs/file.c linux-3.2.8-vs2.3.2.7/fs/jfs/file.c
3767 --- linux-3.2.8/fs/jfs/file.c 2011-10-24 18:45:27.000000000 +0200
3768 +++ linux-3.2.8-vs2.3.2.7/fs/jfs/file.c 2011-12-05 19:33:02.000000000 +0100
3769 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
3770 if (is_quota_modification(inode, iattr))
3771 dquot_initialize(inode);
3772 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3773 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3774 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3775 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3776 rc = dquot_transfer(inode, iattr);
3779 @@ -142,6 +143,7 @@ const struct inode_operations jfs_file_i
3780 #ifdef CONFIG_JFS_POSIX_ACL
3781 .get_acl = jfs_get_acl,
3783 + .sync_flags = jfs_sync_flags,
3786 const struct file_operations jfs_file_operations = {
3787 diff -NurpP --minimal linux-3.2.8/fs/jfs/ioctl.c linux-3.2.8-vs2.3.2.7/fs/jfs/ioctl.c
3788 --- linux-3.2.8/fs/jfs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3789 +++ linux-3.2.8-vs2.3.2.7/fs/jfs/ioctl.c 2011-12-05 19:33:02.000000000 +0100
3791 #include <linux/mount.h>
3792 #include <linux/time.h>
3793 #include <linux/sched.h>
3794 +#include <linux/mount.h>
3795 #include <asm/current.h>
3796 #include <asm/uaccess.h>
3798 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
3802 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3804 + inode->i_flags = flags;
3805 + inode->i_vflags = vflags;
3806 + jfs_get_inode_flags(JFS_IP(inode));
3807 + inode->i_ctime = CURRENT_TIME_SEC;
3808 + mark_inode_dirty(inode);
3812 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3814 struct inode *inode = filp->f_dentry->d_inode;
3815 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
3816 if (!S_ISDIR(inode->i_mode))
3817 flags &= ~JFS_DIRSYNC_FL;
3819 + if (IS_BARRIER(inode)) {
3820 + vxwprintk_task(1, "messing with the barrier.");
3824 /* Is it quota file? Do not allow user to mess with it */
3825 if (IS_NOQUOTA(inode)) {
3827 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
3828 * the relevant capability.
3830 if ((oldflags & JFS_IMMUTABLE_FL) ||
3831 - ((flags ^ oldflags) &
3832 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3833 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3834 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3835 if (!capable(CAP_LINUX_IMMUTABLE)) {
3836 mutex_unlock(&inode->i_mutex);
3838 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
3842 - flags = flags & JFS_FL_USER_MODIFIABLE;
3843 + flags &= JFS_FL_USER_MODIFIABLE;
3844 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3845 jfs_inode->mode2 = flags;
3847 diff -NurpP --minimal linux-3.2.8/fs/jfs/jfs_dinode.h linux-3.2.8-vs2.3.2.7/fs/jfs/jfs_dinode.h
3848 --- linux-3.2.8/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
3849 +++ linux-3.2.8-vs2.3.2.7/fs/jfs/jfs_dinode.h 2011-12-05 19:33:02.000000000 +0100
3850 @@ -161,9 +161,13 @@ struct dinode {
3852 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3853 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3854 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3856 -#define JFS_FL_USER_VISIBLE 0x03F80000
3857 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3858 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3859 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3861 +#define JFS_FL_USER_VISIBLE 0x07F80000
3862 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3863 #define JFS_FL_INHERIT 0x03C80000
3865 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3866 diff -NurpP --minimal linux-3.2.8/fs/jfs/jfs_filsys.h linux-3.2.8-vs2.3.2.7/fs/jfs/jfs_filsys.h
3867 --- linux-3.2.8/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
3868 +++ linux-3.2.8-vs2.3.2.7/fs/jfs/jfs_filsys.h 2011-12-05 19:33:02.000000000 +0100
3870 #define JFS_NAME_MAX 255
3871 #define JFS_PATH_MAX BPSIZE
3873 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
3876 * file system state (superblock state)
3877 diff -NurpP --minimal linux-3.2.8/fs/jfs/jfs_imap.c linux-3.2.8-vs2.3.2.7/fs/jfs/jfs_imap.c
3878 --- linux-3.2.8/fs/jfs/jfs_imap.c 2012-01-09 16:14:54.000000000 +0100
3879 +++ linux-3.2.8-vs2.3.2.7/fs/jfs/jfs_imap.c 2011-12-05 19:33:02.000000000 +0100
3881 #include <linux/pagemap.h>
3882 #include <linux/quotaops.h>
3883 #include <linux/slab.h>
3884 +#include <linux/vs_tag.h>
3886 #include "jfs_incore.h"
3887 #include "jfs_inode.h"
3888 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
3890 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3891 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
3895 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3896 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3897 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
3899 set_nlink(ip, le32_to_cpu(dip->di_nlink));
3901 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
3902 + uid = le32_to_cpu(dip->di_uid);
3903 + gid = le32_to_cpu(dip->di_gid);
3904 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
3906 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
3908 ip->i_uid = jfs_ip->saved_uid;
3910 ip->i_uid = sbi->uid;
3913 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
3914 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
3916 ip->i_gid = jfs_ip->saved_gid;
3918 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
3919 dip->di_size = cpu_to_le64(ip->i_size);
3920 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
3921 dip->di_nlink = cpu_to_le32(ip->i_nlink);
3922 - if (sbi->uid == -1)
3923 - dip->di_uid = cpu_to_le32(ip->i_uid);
3925 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
3926 - if (sbi->gid == -1)
3927 - dip->di_gid = cpu_to_le32(ip->i_gid);
3929 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
3931 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
3932 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
3933 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
3934 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
3936 jfs_get_inode_flags(jfs_ip);
3938 * mode2 is only needed for storing the higher order bits.
3939 diff -NurpP --minimal linux-3.2.8/fs/jfs/jfs_inode.c linux-3.2.8-vs2.3.2.7/fs/jfs/jfs_inode.c
3940 --- linux-3.2.8/fs/jfs/jfs_inode.c 2012-01-09 16:14:54.000000000 +0100
3941 +++ linux-3.2.8-vs2.3.2.7/fs/jfs/jfs_inode.c 2011-12-05 19:33:02.000000000 +0100
3944 #include <linux/fs.h>
3945 #include <linux/quotaops.h>
3946 +#include <linux/vs_tag.h>
3947 #include "jfs_incore.h"
3948 #include "jfs_inode.h"
3949 #include "jfs_filsys.h"
3950 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
3952 unsigned int flags = JFS_IP(inode)->mode2;
3954 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
3955 - S_NOATIME | S_DIRSYNC | S_SYNC);
3956 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3957 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3959 if (flags & JFS_IMMUTABLE_FL)
3960 inode->i_flags |= S_IMMUTABLE;
3961 + if (flags & JFS_IXUNLINK_FL)
3962 + inode->i_flags |= S_IXUNLINK;
3964 + if (flags & JFS_SYNC_FL)
3965 + inode->i_flags |= S_SYNC;
3966 if (flags & JFS_APPEND_FL)
3967 inode->i_flags |= S_APPEND;
3968 if (flags & JFS_NOATIME_FL)
3969 inode->i_flags |= S_NOATIME;
3970 if (flags & JFS_DIRSYNC_FL)
3971 inode->i_flags |= S_DIRSYNC;
3972 - if (flags & JFS_SYNC_FL)
3973 - inode->i_flags |= S_SYNC;
3975 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3977 + if (flags & JFS_BARRIER_FL)
3978 + inode->i_vflags |= V_BARRIER;
3979 + if (flags & JFS_COW_FL)
3980 + inode->i_vflags |= V_COW;
3983 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
3985 unsigned int flags = jfs_ip->vfs_inode.i_flags;
3986 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
3988 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
3989 + JFS_APPEND_FL | JFS_NOATIME_FL |
3990 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
3991 + JFS_BARRIER_FL | JFS_COW_FL);
3993 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
3994 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
3995 if (flags & S_IMMUTABLE)
3996 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
3997 + if (flags & S_IXUNLINK)
3998 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4000 if (flags & S_APPEND)
4001 jfs_ip->mode2 |= JFS_APPEND_FL;
4002 if (flags & S_NOATIME)
4003 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4004 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4006 jfs_ip->mode2 |= JFS_SYNC_FL;
4008 + if (vflags & V_BARRIER)
4009 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4010 + if (vflags & V_COW)
4011 + jfs_ip->mode2 |= JFS_COW_FL;
4015 diff -NurpP --minimal linux-3.2.8/fs/jfs/jfs_inode.h linux-3.2.8-vs2.3.2.7/fs/jfs/jfs_inode.h
4016 --- linux-3.2.8/fs/jfs/jfs_inode.h 2011-10-24 18:45:27.000000000 +0200
4017 +++ linux-3.2.8-vs2.3.2.7/fs/jfs/jfs_inode.h 2011-12-05 19:33:02.000000000 +0100
4018 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4019 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4020 int fh_len, int fh_type);
4021 extern void jfs_set_inode_flags(struct inode *);
4022 +extern int jfs_sync_flags(struct inode *, int, int);
4023 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4024 extern int jfs_setattr(struct dentry *, struct iattr *);
4026 diff -NurpP --minimal linux-3.2.8/fs/jfs/namei.c linux-3.2.8-vs2.3.2.7/fs/jfs/namei.c
4027 --- linux-3.2.8/fs/jfs/namei.c 2012-01-09 16:14:54.000000000 +0100
4028 +++ linux-3.2.8-vs2.3.2.7/fs/jfs/namei.c 2011-12-05 19:33:02.000000000 +0100
4030 #include <linux/ctype.h>
4031 #include <linux/quotaops.h>
4032 #include <linux/exportfs.h>
4033 +#include <linux/vs_tag.h>
4034 #include "jfs_incore.h"
4035 #include "jfs_superblock.h"
4036 #include "jfs_inode.h"
4037 @@ -1474,6 +1475,7 @@ static struct dentry *jfs_lookup(struct
4038 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
4041 + dx_propagate_tag(nd, ip);
4042 return d_splice_alias(ip, dentry);
4045 @@ -1538,6 +1540,7 @@ const struct inode_operations jfs_dir_in
4046 #ifdef CONFIG_JFS_POSIX_ACL
4047 .get_acl = jfs_get_acl,
4049 + .sync_flags = jfs_sync_flags,
4052 const struct file_operations jfs_dir_operations = {
4053 diff -NurpP --minimal linux-3.2.8/fs/jfs/super.c linux-3.2.8-vs2.3.2.7/fs/jfs/super.c
4054 --- linux-3.2.8/fs/jfs/super.c 2012-01-09 16:14:54.000000000 +0100
4055 +++ linux-3.2.8-vs2.3.2.7/fs/jfs/super.c 2011-12-05 19:33:02.000000000 +0100
4056 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
4058 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4059 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4060 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4061 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4062 + Opt_tag, Opt_notag, Opt_tagid
4065 static const match_table_t tokens = {
4066 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
4067 {Opt_resize, "resize=%u"},
4068 {Opt_resize_nosize, "resize"},
4069 {Opt_errors, "errors=%s"},
4071 + {Opt_notag, "notag"},
4072 + {Opt_tagid, "tagid=%u"},
4073 + {Opt_tag, "tagxid"},
4074 {Opt_ignore, "noquota"},
4075 {Opt_ignore, "quota"},
4076 {Opt_usrquota, "usrquota"},
4077 @@ -342,6 +347,20 @@ static int parse_options(char *options,
4081 +#ifndef CONFIG_TAGGING_NONE
4083 + *flag |= JFS_TAGGED;
4086 + *flag &= JFS_TAGGED;
4089 +#ifdef CONFIG_PROPAGATE
4092 + *flag |= JFS_TAGGED;
4096 printk("jfs: Unrecognized mount option \"%s\" "
4097 " or missing value\n", p);
4098 @@ -373,6 +392,12 @@ static int jfs_remount(struct super_bloc
4102 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4103 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4109 if (sb->s_flags & MS_RDONLY) {
4111 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4112 #ifdef CONFIG_JFS_POSIX_ACL
4113 sb->s_flags |= MS_POSIXACL;
4115 + /* map mount option tagxid */
4116 + if (sbi->flag & JFS_TAGGED)
4117 + sb->s_flags |= MS_TAGGED;
4120 printk(KERN_ERR "resize option for remount only\n");
4121 diff -NurpP --minimal linux-3.2.8/fs/libfs.c linux-3.2.8-vs2.3.2.7/fs/libfs.c
4122 --- linux-3.2.8/fs/libfs.c 2012-01-09 16:14:54.000000000 +0100
4123 +++ linux-3.2.8-vs2.3.2.7/fs/libfs.c 2011-12-05 19:33:02.000000000 +0100
4124 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
4125 * both impossible due to the lock on directory.
4128 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4129 +static inline int do_dcache_readdir_filter(struct file *filp,
4130 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4132 struct dentry *dentry = filp->f_path.dentry;
4133 struct dentry *cursor = filp->private_data;
4134 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
4135 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4136 struct dentry *next;
4137 next = list_entry(p, struct dentry, d_u.d_child);
4138 + if (filter && !filter(next))
4140 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4141 if (!simple_positive(next)) {
4142 spin_unlock(&next->d_lock);
4143 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
4147 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4149 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4152 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4153 + int (*filter)(struct dentry *))
4155 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4158 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4161 @@ -977,6 +991,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4162 EXPORT_SYMBOL(dcache_dir_lseek);
4163 EXPORT_SYMBOL(dcache_dir_open);
4164 EXPORT_SYMBOL(dcache_readdir);
4165 +EXPORT_SYMBOL(dcache_readdir_filter);
4166 EXPORT_SYMBOL(generic_read_dir);
4167 EXPORT_SYMBOL(mount_pseudo);
4168 EXPORT_SYMBOL(simple_write_begin);
4169 diff -NurpP --minimal linux-3.2.8/fs/locks.c linux-3.2.8-vs2.3.2.7/fs/locks.c
4170 --- linux-3.2.8/fs/locks.c 2012-01-09 16:14:54.000000000 +0100
4171 +++ linux-3.2.8-vs2.3.2.7/fs/locks.c 2012-01-09 16:19:31.000000000 +0100
4173 #include <linux/time.h>
4174 #include <linux/rcupdate.h>
4175 #include <linux/pid_namespace.h>
4176 +#include <linux/vs_base.h>
4177 +#include <linux/vs_limit.h>
4179 #include <asm/uaccess.h>
4181 @@ -184,11 +186,17 @@ static void locks_init_lock_heads(struct
4182 /* Allocate an empty lock structure. */
4183 struct file_lock *locks_alloc_lock(void)
4185 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4186 + struct file_lock *fl;
4189 - locks_init_lock_heads(fl);
4190 + if (!vx_locks_avail(1))
4193 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4196 + locks_init_lock_heads(fl);
4201 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4202 @@ -216,6 +224,7 @@ void locks_free_lock(struct file_lock *f
4203 BUG_ON(!list_empty(&fl->fl_block));
4204 BUG_ON(!list_empty(&fl->fl_link));
4207 locks_release_private(fl);
4208 kmem_cache_free(filelock_cache, fl);
4210 @@ -225,6 +234,7 @@ void locks_init_lock(struct file_lock *f
4212 memset(fl, 0, sizeof(struct file_lock));
4213 locks_init_lock_heads(fl);
4217 EXPORT_SYMBOL(locks_init_lock);
4218 @@ -265,6 +275,7 @@ void locks_copy_lock(struct file_lock *n
4219 new->fl_file = fl->fl_file;
4220 new->fl_ops = fl->fl_ops;
4221 new->fl_lmops = fl->fl_lmops;
4222 + new->fl_xid = fl->fl_xid;
4224 locks_copy_private(new, fl);
4226 @@ -303,6 +314,11 @@ static int flock_make_lock(struct file *
4227 fl->fl_flags = FL_FLOCK;
4229 fl->fl_end = OFFSET_MAX;
4231 + vxd_assert(filp->f_xid == vx_current_xid(),
4232 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4233 + fl->fl_xid = filp->f_xid;
4238 @@ -452,6 +468,7 @@ static int lease_init(struct file *filp,
4240 fl->fl_owner = current->files;
4241 fl->fl_pid = current->tgid;
4242 + fl->fl_xid = vx_current_xid();
4245 fl->fl_flags = FL_LEASE;
4246 @@ -471,6 +488,11 @@ static struct file_lock *lease_alloc(str
4248 return ERR_PTR(error);
4250 + fl->fl_xid = vx_current_xid();
4252 + vxd_assert(filp->f_xid == fl->fl_xid,
4253 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4255 error = lease_init(filp, type, fl);
4257 locks_free_lock(fl);
4258 @@ -772,6 +794,7 @@ static int flock_lock_file(struct file *
4262 + new_fl->fl_xid = -1;
4264 for_each_lock(inode, before) {
4265 struct file_lock *fl = *before;
4266 @@ -792,6 +815,7 @@ find_conflict:
4268 locks_copy_lock(new_fl, request);
4269 locks_insert_lock(before, new_fl);
4270 + vx_locks_inc(new_fl);
4274 @@ -802,7 +826,8 @@ out:
4278 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4279 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4280 + struct file_lock *conflock, xid_t xid)
4282 struct file_lock *fl;
4283 struct file_lock *new_fl = NULL;
4284 @@ -812,6 +837,8 @@ static int __posix_lock_file(struct inod
4285 struct file_lock **before;
4286 int error, added = 0;
4288 + vxd_assert(xid == vx_current_xid(),
4289 + "xid(%d) == current(%d)", xid, vx_current_xid());
4291 * We may need two file_lock structures for this operation,
4292 * so we get them in advance to avoid races.
4293 @@ -822,7 +849,11 @@ static int __posix_lock_file(struct inod
4294 (request->fl_type != F_UNLCK ||
4295 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4296 new_fl = locks_alloc_lock();
4297 + new_fl->fl_xid = xid;
4298 + vx_locks_inc(new_fl);
4299 new_fl2 = locks_alloc_lock();
4300 + new_fl2->fl_xid = xid;
4301 + vx_locks_inc(new_fl2);
4305 @@ -1021,7 +1052,8 @@ static int __posix_lock_file(struct inod
4306 int posix_lock_file(struct file *filp, struct file_lock *fl,
4307 struct file_lock *conflock)
4309 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4310 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4311 + fl, conflock, filp->f_xid);
4313 EXPORT_SYMBOL(posix_lock_file);
4315 @@ -1111,7 +1143,7 @@ int locks_mandatory_area(int read_write,
4316 fl.fl_end = offset + count - 1;
4319 - error = __posix_lock_file(inode, &fl, NULL);
4320 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4321 if (error != FILE_LOCK_DEFERRED)
4323 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4324 @@ -1406,6 +1438,7 @@ int generic_add_lease(struct file *filp,
4327 locks_insert_lock(before, lease);
4328 + vx_locks_inc(lease);
4332 @@ -1846,6 +1879,11 @@ int fcntl_setlk(unsigned int fd, struct
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 @@ -1964,6 +2002,11 @@ int fcntl_setlk64(unsigned int fd, struc
4345 if (file_lock == NULL)
4348 + vxd_assert(filp->f_xid == vx_current_xid(),
4349 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4350 + file_lock->fl_xid = filp->f_xid;
4351 + vx_locks_inc(file_lock);
4354 * This might block, so we do it before checking the inode.
4356 @@ -2229,8 +2272,11 @@ static int locks_show(struct seq_file *f
4358 lock_get_status(f, fl, *((loff_t *)f->private), "");
4360 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4361 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4362 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4364 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4369 diff -NurpP --minimal linux-3.2.8/fs/namei.c linux-3.2.8-vs2.3.2.7/fs/namei.c
4370 --- linux-3.2.8/fs/namei.c 2012-01-09 16:14:54.000000000 +0100
4371 +++ linux-3.2.8-vs2.3.2.7/fs/namei.c 2011-12-05 19:33:02.000000000 +0100
4373 #include <linux/device_cgroup.h>
4374 #include <linux/fs_struct.h>
4375 #include <linux/posix_acl.h>
4376 +#include <linux/proc_fs.h>
4377 +#include <linux/vserver/inode.h>
4378 +#include <linux/vs_base.h>
4379 +#include <linux/vs_tag.h>
4380 +#include <linux/vs_cowbl.h>
4381 +#include <linux/vs_device.h>
4382 +#include <linux/vs_context.h>
4383 +#include <linux/pid_namespace.h>
4384 #include <asm/uaccess.h>
4386 #include "internal.h"
4387 @@ -222,6 +230,89 @@ static int check_acl(struct inode *inode
4391 +static inline int dx_barrier(const struct inode *inode)
4393 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4394 + vxwprintk_task(1, "did hit the barrier.");
4400 +static int __dx_permission(const struct inode *inode, int mask)
4402 + if (dx_barrier(inode))
4405 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4406 + /* devpts is xid tagged */
4407 + if (S_ISDIR(inode->i_mode) ||
4408 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4411 + /* just pretend we didn't find anything */
4414 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4415 + struct proc_dir_entry *de = PDE(inode);
4417 + if (de && !vx_hide_check(0, de->vx_flags))
4420 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4422 + struct task_struct *tsk;
4424 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4425 + vx_flags(VXF_STATE_SETUP, 0))
4428 + pid = PROC_I(inode)->pid;
4433 + tsk = pid_task(pid, PIDTYPE_PID);
4434 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4435 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4437 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4438 + rcu_read_unlock();
4441 + rcu_read_unlock();
4444 + /* FIXME: Should we block some entries here? */
4449 + if (dx_notagcheck(inode->i_sb) ||
4450 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4459 +int dx_permission(const struct inode *inode, int mask)
4461 + int ret = __dx_permission(inode, mask);
4462 + if (unlikely(ret)) {
4463 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4464 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4467 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4468 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4475 * This does the basic permission checking
4477 @@ -357,10 +448,14 @@ int inode_permission(struct inode *inode
4479 * Nobody gets write access to an immutable file.
4481 - if (IS_IMMUTABLE(inode))
4482 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4486 + retval = dx_permission(inode, mask);
4490 retval = do_inode_permission(inode, mask);
4493 @@ -1037,7 +1132,8 @@ static void follow_dotdot(struct nameida
4495 if (nd->path.dentry == nd->root.dentry &&
4496 nd->path.mnt == nd->root.mnt) {
4498 + /* for sane '/' avoid follow_mount() */
4501 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4502 /* rare case of legitimate dget_parent()... */
4503 @@ -1146,6 +1242,9 @@ static int do_lookup(struct nameidata *n
4505 if (unlikely(d_need_lookup(dentry)))
4508 + /* FIXME: check dx permission */
4511 path->dentry = dentry;
4512 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4513 @@ -1207,6 +1306,8 @@ retry:
4517 + /* FIXME: check dx permission */
4520 path->dentry = dentry;
4521 err = follow_managed(path, nd->flags);
4522 @@ -1901,7 +2002,7 @@ static int may_delete(struct inode *dir,
4525 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4526 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4527 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4530 if (!S_ISDIR(victim->d_inode->i_mode))
4531 @@ -1981,19 +2082,25 @@ int vfs_create(struct inode *dir, struct
4533 int error = may_create(dir, dentry);
4537 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
4541 if (!dir->i_op->create)
4542 return -EACCES; /* shouldn't it be ENOSYS? */
4545 error = security_inode_create(dir, dentry, mode);
4548 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
4551 error = dir->i_op->create(dir, dentry, mode, nd);
4553 fsnotify_create(dir, dentry);
4555 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
4559 @@ -2028,6 +2135,15 @@ static int may_open(struct path *path, i
4563 +#ifdef CONFIG_VSERVER_COWBL
4564 + if (IS_COW(inode) &&
4565 + ((flag & O_ACCMODE) != O_RDONLY)) {
4566 + if (IS_COW_LINK(inode))
4568 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4569 + mark_inode_dirty(inode);
4572 error = inode_permission(inode, acc_mode);
4575 @@ -2252,6 +2368,16 @@ ok:
4578 error = may_open(&nd->path, acc_mode, open_flag);
4579 +#ifdef CONFIG_VSERVER_COWBL
4580 + if (error == -EMLINK) {
4581 + struct dentry *dentry;
4582 + dentry = cow_break_link(pathname);
4583 + if (IS_ERR(dentry))
4584 + error = PTR_ERR(dentry);
4591 filp = nameidata_to_filp(nd);
4592 @@ -2294,6 +2420,7 @@ static struct file *path_openat(int dfd,
4597 filp = get_empty_filp();
4599 return ERR_PTR(-ENFILE);
4600 @@ -2331,6 +2458,17 @@ static struct file *path_openat(int dfd,
4601 filp = do_last(nd, &path, op, pathname);
4602 put_link(nd, &link, cookie);
4605 +#ifdef CONFIG_VSERVER_COWBL
4606 + if (filp == ERR_PTR(-EMLINK)) {
4607 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4608 + path_put(&nd->root);
4611 + release_open_intent(nd);
4616 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4617 path_put(&nd->root);
4618 @@ -2420,6 +2558,11 @@ struct dentry *kern_path_create(int dfd,
4622 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
4623 + path->dentry, path->dentry->d_name.len,
4624 + path->dentry->d_name.name, dentry,
4625 + dentry->d_name.len, dentry->d_name.name,
4626 + path->dentry->d_inode);
4630 @@ -2901,7 +3044,7 @@ int vfs_link(struct dentry *old_dentry,
4632 * A link to an append-only or immutable file cannot be created.
4634 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4635 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4637 if (!dir->i_op->link)
4639 @@ -3282,6 +3425,227 @@ int vfs_follow_link(struct nameidata *nd
4640 return __vfs_follow_link(nd, link);
4644 +#ifdef CONFIG_VSERVER_COWBL
4647 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4651 + return do_splice_direct(in, &ppos, out, len, 0);
4654 +struct dentry *cow_break_link(const char *pathname)
4656 + int ret, mode, pathlen, redo = 0;
4657 + struct nameidata old_nd, dir_nd;
4658 + struct path old_path, dir_path;
4659 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4660 + struct file *old_file;
4661 + struct file *new_file;
4662 + char *to, *path, pad='\251';
4665 + vxdprintk(VXD_CBIT(misc, 1),
4666 + "cow_break_link(" VS_Q("%s") ")", pathname);
4667 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4672 + /* old_nd will have refs to dentry and mnt */
4673 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4674 + vxdprintk(VXD_CBIT(misc, 2),
4675 + "do_path_lookup(old): %d [r=%d]",
4676 + ret, mnt_get_count(old_nd.path.mnt));
4678 + goto out_free_path;
4680 + old_path = old_nd.path;
4681 + old_dentry = old_path.dentry;
4682 + mode = old_dentry->d_inode->i_mode;
4684 + to = d_path(&old_path, path, PATH_MAX-2);
4685 + pathlen = strlen(to);
4686 + vxdprintk(VXD_CBIT(misc, 2),
4687 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4689 + old_dentry->d_name.len, old_dentry->d_name.name,
4690 + old_dentry->d_name.len);
4692 + to[pathlen + 1] = 0;
4694 + new_dentry = NULL;
4695 + to[pathlen] = pad--;
4697 + if (pad <= '\240')
4700 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4701 + /* dir_nd will have refs to dentry and mnt */
4702 + ret = do_path_lookup(AT_FDCWD, to,
4703 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4704 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4708 + /* this puppy downs the dir inode mutex if successful */
4709 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
4710 + if (!new_dentry || IS_ERR(new_dentry)) {
4711 + path_put(&dir_nd.path);
4712 + vxdprintk(VXD_CBIT(misc, 2),
4713 + "kern_path_create(new) failed with %ld",
4714 + PTR_ERR(new_dentry));
4717 + path_put(&dir_path);
4718 + vxdprintk(VXD_CBIT(misc, 2),
4719 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
4721 + new_dentry->d_name.len, new_dentry->d_name.name,
4722 + new_dentry->d_name.len);
4724 + dir = dir_nd.path.dentry;
4726 + ret = vfs_create(dir->d_inode, new_dentry, mode, &dir_nd);
4727 + vxdprintk(VXD_CBIT(misc, 2),
4728 + "vfs_create(new): %d", ret);
4729 + if (ret == -EEXIST) {
4730 + mutex_unlock(&dir->d_inode->i_mutex);
4731 + path_put(&dir_nd.path);
4736 + goto out_unlock_new;
4738 + /* drop out early, ret passes ENOENT */
4740 + if ((redo = d_unhashed(old_dentry)))
4741 + goto out_unlock_new;
4743 + path_get(&old_path);
4744 + /* this one cleans up the dentry/mnt in case of failure */
4745 + old_file = dentry_open(old_dentry, old_path.mnt,
4746 + O_RDONLY, current_cred());
4747 + vxdprintk(VXD_CBIT(misc, 2),
4748 + "dentry_open(old): %p", old_file);
4749 + if (IS_ERR(old_file)) {
4750 + ret = PTR_ERR(old_file);
4751 + goto out_unlock_new;
4755 + mntget(old_path.mnt);
4756 + /* this one cleans up the dentry/mnt in case of failure */
4757 + new_file = dentry_open(new_dentry, old_path.mnt,
4758 + O_WRONLY, current_cred());
4759 + vxdprintk(VXD_CBIT(misc, 2),
4760 + "dentry_open(new): %p", new_file);
4761 + if (IS_ERR(new_file)) {
4762 + ret = PTR_ERR(new_file);
4763 + goto out_fput_old;
4766 + size = i_size_read(old_file->f_dentry->d_inode);
4767 + ret = do_cow_splice(old_file, new_file, size);
4768 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4770 + goto out_fput_both;
4771 + } else if (ret < size) {
4773 + goto out_fput_both;
4775 + struct inode *old_inode = old_dentry->d_inode;
4776 + struct inode *new_inode = new_dentry->d_inode;
4777 + struct iattr attr = {
4778 + .ia_uid = old_inode->i_uid,
4779 + .ia_gid = old_inode->i_gid,
4780 + .ia_valid = ATTR_UID | ATTR_GID
4783 + setattr_copy(new_inode, &attr);
4784 + mark_inode_dirty(new_inode);
4787 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4789 + /* drop out late */
4791 + if ((redo = d_unhashed(old_dentry)))
4794 + vxdprintk(VXD_CBIT(misc, 2),
4795 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4796 + new_dentry->d_name.len, new_dentry->d_name.name,
4797 + new_dentry->d_name.len,
4798 + old_dentry->d_name.len, old_dentry->d_name.name,
4799 + old_dentry->d_name.len);
4800 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4801 + old_dentry->d_parent->d_inode, old_dentry);
4802 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4805 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4808 + vxdprintk(VXD_CBIT(misc, 3),
4809 + "fput(new_file=%p[#%ld])", new_file,
4810 + atomic_long_read(&new_file->f_count));
4814 + vxdprintk(VXD_CBIT(misc, 3),
4815 + "fput(old_file=%p[#%ld])", old_file,
4816 + atomic_long_read(&old_file->f_count));
4820 + mutex_unlock(&dir->d_inode->i_mutex);
4824 + /* error path cleanup */
4825 + vfs_unlink(dir->d_inode, new_dentry);
4829 + goto out_rel_both;
4830 + /* lookup dentry once again */
4831 + /* old_nd.path is freed as old_path in out_rel_old */
4832 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4834 + goto out_rel_both;
4837 + new_dentry = old_nd.path.dentry;
4838 + vxdprintk(VXD_CBIT(misc, 2),
4839 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4841 + new_dentry->d_name.len, new_dentry->d_name.name,
4842 + new_dentry->d_name.len);
4846 + path_put(&dir_nd.path);
4848 + path_put(&old_path);
4854 + new_dentry = ERR_PTR(ret);
4856 + vxdprintk(VXD_CBIT(misc, 3),
4857 + "cow_break_link returning with %p [r=%d]",
4858 + new_dentry, mnt_get_count(old_nd.path.mnt));
4859 + return new_dentry;
4864 /* get the link contents into pagecache */
4865 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4867 diff -NurpP --minimal linux-3.2.8/fs/namespace.c linux-3.2.8-vs2.3.2.7/fs/namespace.c
4868 --- linux-3.2.8/fs/namespace.c 2012-01-09 16:14:54.000000000 +0100
4869 +++ linux-3.2.8-vs2.3.2.7/fs/namespace.c 2011-12-15 01:11:32.000000000 +0100
4871 #include <linux/idr.h>
4872 #include <linux/fs_struct.h>
4873 #include <linux/fsnotify.h>
4874 +#include <linux/vs_base.h>
4875 +#include <linux/vs_context.h>
4876 +#include <linux/vs_tag.h>
4877 +#include <linux/vserver/space.h>
4878 +#include <linux/vserver/global.h>
4879 #include <asm/uaccess.h>
4880 #include <asm/unistd.h>
4882 @@ -679,6 +684,10 @@ vfs_kern_mount(struct file_system_type *
4884 return ERR_PTR(-ENODEV);
4886 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
4887 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
4888 + return ERR_PTR(-EPERM);
4890 mnt = alloc_vfsmnt(name);
4892 return ERR_PTR(-ENOMEM);
4893 @@ -724,6 +733,7 @@ static struct vfsmount *clone_mnt(struct
4894 mnt->mnt_root = dget(root);
4895 mnt->mnt_mountpoint = mnt->mnt_root;
4896 mnt->mnt_parent = mnt;
4897 + mnt->mnt_tag = old->mnt_tag;
4899 if (flag & CL_SLAVE) {
4900 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
4901 @@ -852,6 +862,31 @@ static inline void mangle(struct seq_fil
4902 seq_escape(m, s, " \t\n\\");
4905 +static int mnt_is_reachable(struct vfsmount *mnt)
4908 + struct dentry *point;
4911 + if (mnt == mnt->mnt_ns->root)
4914 + br_read_lock(vfsmount_lock);
4915 + root = current->fs->root;
4916 + point = root.dentry;
4918 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
4919 + point = mnt->mnt_mountpoint;
4920 + mnt = mnt->mnt_parent;
4923 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
4925 + br_read_unlock(vfsmount_lock);
4931 * Simple .show_options callback for filesystems which don't want to
4932 * implement more complex mount option showing.
4933 @@ -954,6 +989,8 @@ static int show_sb_opts(struct seq_file
4934 { MS_SYNCHRONOUS, ",sync" },
4935 { MS_DIRSYNC, ",dirsync" },
4936 { MS_MANDLOCK, ",mand" },
4937 + { MS_TAGGED, ",tag" },
4938 + { MS_NOTAGCHECK, ",notagcheck" },
4941 const struct proc_fs_info *fs_infop;
4942 @@ -1000,16 +1037,26 @@ static int show_vfsmnt(struct seq_file *
4944 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
4946 - if (mnt->mnt_sb->s_op->show_devname) {
4947 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
4950 + if (vx_flags(VXF_HIDE_MOUNT, 0))
4952 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
4955 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
4956 + mnt == current->fs->root.mnt) {
4957 + seq_puts(m, "/dev/root / ");
4959 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
4960 + if (mnt->mnt_sb->s_op->show_devname) {
4961 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
4965 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
4968 + seq_path(m, &mnt_path, " \t\n\\");
4972 - seq_path(m, &mnt_path, " \t\n\\");
4974 show_type(m, mnt->mnt_sb);
4975 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
4976 err = show_sb_opts(m, mnt->mnt_sb);
4977 @@ -1039,6 +1086,11 @@ static int show_mountinfo(struct seq_fil
4978 struct path root = p->root;
4981 + if (vx_flags(VXF_HIDE_MOUNT, 0))
4983 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
4986 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
4987 MAJOR(sb->s_dev), MINOR(sb->s_dev));
4988 if (sb->s_op->show_path)
4989 @@ -1104,22 +1156,32 @@ static int show_vfsstat(struct seq_file
4990 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
4994 - if (mnt->mnt_sb->s_op->show_devname) {
4995 - seq_puts(m, "device ");
4996 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
4997 + if (vx_flags(VXF_HIDE_MOUNT, 0))
4999 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5002 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5003 + mnt == current->fs->root.mnt) {
5004 + seq_puts(m, "device /dev/root mounted on / ");
5006 - if (mnt->mnt_devname) {
5008 + if (mnt->mnt_sb->s_op->show_devname) {
5009 seq_puts(m, "device ");
5010 - mangle(m, mnt->mnt_devname);
5012 - seq_puts(m, "no device");
5014 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5016 + if (mnt->mnt_devname) {
5017 + seq_puts(m, "device ");
5018 + mangle(m, mnt->mnt_devname);
5020 + seq_puts(m, "no device");
5024 - seq_puts(m, " mounted on ");
5025 - seq_path(m, &mnt_path, " \t\n\\");
5028 + seq_puts(m, " mounted on ");
5029 + seq_path(m, &mnt_path, " \t\n\\");
5033 /* file system type */
5034 seq_puts(m, "with fstype ");
5035 @@ -1378,7 +1440,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5039 - if (!capable(CAP_SYS_ADMIN))
5040 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5043 retval = do_umount(path.mnt, flags);
5044 @@ -1404,7 +1466,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5046 static int mount_is_safe(struct path *path)
5048 - if (capable(CAP_SYS_ADMIN))
5049 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5053 @@ -1714,7 +1776,7 @@ static int do_change_type(struct path *p
5057 - if (!capable(CAP_SYS_ADMIN))
5058 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5061 if (path->dentry != path->mnt->mnt_root)
5062 @@ -1730,6 +1792,7 @@ static int do_change_type(struct path *p
5066 + // mnt->mnt_flags = mnt_flags;
5068 br_write_lock(vfsmount_lock);
5069 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
5070 @@ -1745,12 +1808,14 @@ static int do_change_type(struct path *p
5071 * do loopback mount.
5073 static int do_loopback(struct path *path, char *old_name,
5075 + tag_t tag, unsigned long flags, int mnt_flags)
5077 LIST_HEAD(umount_list);
5078 struct path old_path;
5079 struct vfsmount *mnt = NULL;
5080 int err = mount_is_safe(path);
5081 + int recurse = flags & MS_REC;
5085 if (!old_name || !*old_name)
5086 @@ -1816,12 +1881,12 @@ static int change_mount_flags(struct vfs
5087 * on it - tough luck.
5089 static int do_remount(struct path *path, int flags, int mnt_flags,
5091 + void *data, xid_t xid)
5094 struct super_block *sb = path->mnt->mnt_sb;
5096 - if (!capable(CAP_SYS_ADMIN))
5097 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5100 if (!check_mnt(path->mnt))
5101 @@ -1869,7 +1934,7 @@ static int do_move_mount(struct path *pa
5102 struct path old_path, parent_path;
5105 - if (!capable(CAP_SYS_ADMIN))
5106 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5108 if (!old_name || !*old_name)
5110 @@ -2020,7 +2085,7 @@ static int do_new_mount(struct path *pat
5113 /* we need capabilities... */
5114 - if (!capable(CAP_SYS_ADMIN))
5115 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5118 mnt = do_kern_mount(type, flags, name, data);
5119 @@ -2289,6 +2354,7 @@ long do_mount(char *dev_name, char *dir_
5126 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5127 @@ -2316,6 +2382,12 @@ long do_mount(char *dev_name, char *dir_
5128 if (!(flags & MS_NOATIME))
5129 mnt_flags |= MNT_RELATIME;
5131 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5132 + /* FIXME: bind and re-mounts get the tag flag? */
5133 + if (flags & (MS_BIND|MS_REMOUNT))
5134 + flags |= MS_TAGID;
5137 /* Separate the per-mountpoint flags */
5138 if (flags & MS_NOSUID)
5139 mnt_flags |= MNT_NOSUID;
5140 @@ -2332,15 +2404,17 @@ long do_mount(char *dev_name, char *dir_
5141 if (flags & MS_RDONLY)
5142 mnt_flags |= MNT_READONLY;
5144 + if (!capable(CAP_SYS_ADMIN))
5145 + mnt_flags |= MNT_NODEV;
5146 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5147 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5150 if (flags & MS_REMOUNT)
5151 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5154 else if (flags & MS_BIND)
5155 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5156 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5157 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5158 retval = do_change_type(&path, flags);
5159 else if (flags & MS_MOVE)
5160 @@ -2440,6 +2514,7 @@ static struct mnt_namespace *dup_mnt_ns(
5161 q = next_mnt(q, new_ns->root);
5163 up_write(&namespace_sem);
5164 + atomic_inc(&vs_global_mnt_ns);
5168 @@ -2611,9 +2686,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5172 - if (IS_MNT_SHARED(old.mnt) ||
5173 + if ((IS_MNT_SHARED(old.mnt) ||
5174 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5175 - IS_MNT_SHARED(root.mnt->mnt_parent))
5176 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5177 + !vx_flags(VXF_STATE_SETUP, 0))
5179 if (!check_mnt(root.mnt) || !check_mnt(new.mnt))
5181 @@ -2745,6 +2821,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5182 br_write_unlock(vfsmount_lock);
5183 up_write(&namespace_sem);
5184 release_mounts(&umount_list);
5185 + atomic_dec(&vs_global_mnt_ns);
5188 EXPORT_SYMBOL(put_mnt_ns);
5189 diff -NurpP --minimal linux-3.2.8/fs/nfs/client.c linux-3.2.8-vs2.3.2.7/fs/nfs/client.c
5190 --- linux-3.2.8/fs/nfs/client.c 2012-01-09 16:14:54.000000000 +0100
5191 +++ linux-3.2.8-vs2.3.2.7/fs/nfs/client.c 2011-12-05 19:33:02.000000000 +0100
5192 @@ -779,6 +779,9 @@ static int nfs_init_server_rpcclient(str
5193 if (server->flags & NFS_MOUNT_SOFT)
5194 server->client->cl_softrtry = 1;
5196 + server->client->cl_tag = 0;
5197 + if (server->flags & NFS_MOUNT_TAGGED)
5198 + server->client->cl_tag = 1;
5202 @@ -953,6 +956,10 @@ static void nfs_server_set_fsinfo(struct
5203 server->acdirmin = server->acdirmax = 0;
5206 + /* FIXME: needs fsinfo
5207 + if (server->flags & NFS_MOUNT_TAGGED)
5208 + sb->s_flags |= MS_TAGGED; */
5210 server->maxfilesize = fsinfo->maxfilesize;
5212 server->time_delta = fsinfo->time_delta;
5213 diff -NurpP --minimal linux-3.2.8/fs/nfs/dir.c linux-3.2.8-vs2.3.2.7/fs/nfs/dir.c
5214 --- linux-3.2.8/fs/nfs/dir.c 2012-01-09 16:14:54.000000000 +0100
5215 +++ linux-3.2.8-vs2.3.2.7/fs/nfs/dir.c 2011-12-05 19:33:02.000000000 +0100
5217 #include <linux/sched.h>
5218 #include <linux/kmemleak.h>
5219 #include <linux/xattr.h>
5220 +#include <linux/vs_tag.h>
5222 #include "delegation.h"
5224 @@ -1311,6 +1312,7 @@ static struct dentry *nfs_lookup(struct
5226 goto out_unblock_sillyrename;
5228 + dx_propagate_tag(nd, inode);
5230 res = d_materialise_unique(dentry, inode);
5232 diff -NurpP --minimal linux-3.2.8/fs/nfs/inode.c linux-3.2.8-vs2.3.2.7/fs/nfs/inode.c
5233 --- linux-3.2.8/fs/nfs/inode.c 2012-01-09 16:14:54.000000000 +0100
5234 +++ linux-3.2.8-vs2.3.2.7/fs/nfs/inode.c 2011-12-05 21:16:35.000000000 +0100
5236 #include <linux/nfs_xdr.h>
5237 #include <linux/slab.h>
5238 #include <linux/compat.h>
5239 +#include <linux/vs_tag.h>
5241 #include <asm/system.h>
5242 #include <asm/uaccess.h>
5243 @@ -273,6 +274,8 @@ nfs_fhget(struct super_block *sb, struct
5244 if (inode->i_state & I_NEW) {
5245 struct nfs_inode *nfsi = NFS_I(inode);
5246 unsigned long now = jiffies;
5250 /* We set i_ino for the few things that still rely on it,
5251 * such as stat(2) */
5252 @@ -321,8 +324,8 @@ nfs_fhget(struct super_block *sb, struct
5253 inode->i_version = 0;
5256 - inode->i_uid = -2;
5257 - inode->i_gid = -2;
5260 inode->i_blocks = 0;
5261 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5263 @@ -359,13 +362,13 @@ nfs_fhget(struct super_block *sb, struct
5264 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5265 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5266 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5267 - inode->i_uid = fattr->uid;
5269 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5270 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5271 | NFS_INO_INVALID_ACCESS
5272 | NFS_INO_INVALID_ACL;
5273 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5274 - inode->i_gid = fattr->gid;
5276 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5277 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5278 | NFS_INO_INVALID_ACCESS
5279 @@ -378,6 +381,11 @@ nfs_fhget(struct super_block *sb, struct
5281 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5283 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5284 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5285 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5286 + /* maybe fattr->xid someday */
5288 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5289 nfsi->attrtimeo_timestamp = now;
5290 nfsi->access_cache = RB_ROOT;
5291 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
5292 inode->i_uid = attr->ia_uid;
5293 if ((attr->ia_valid & ATTR_GID) != 0)
5294 inode->i_gid = attr->ia_gid;
5295 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5296 + inode->i_tag = attr->ia_tag;
5297 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5298 spin_unlock(&inode->i_lock);
5300 @@ -943,6 +953,9 @@ static int nfs_check_inode_attributes(st
5301 struct nfs_inode *nfsi = NFS_I(inode);
5302 loff_t cur_size, new_isize;
5303 unsigned long invalid = 0;
5309 /* Has the inode gone and changed behind our back? */
5310 @@ -966,13 +979,18 @@ static int nfs_check_inode_attributes(st
5311 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5314 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5315 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5316 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5318 /* Have any file permissions changed? */
5319 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5320 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5321 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5322 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5323 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5324 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5325 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5326 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5327 + /* maybe check for tag too? */
5329 /* Has the link count changed? */
5330 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5331 @@ -1207,6 +1225,9 @@ static int nfs_update_inode(struct inode
5332 unsigned long invalid = 0;
5333 unsigned long now = jiffies;
5334 unsigned long save_cache_validity;
5339 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5340 __func__, inode->i_sb->s_id, inode->i_ino,
5341 @@ -1314,6 +1335,9 @@ static int nfs_update_inode(struct inode
5342 | NFS_INO_REVAL_PAGECACHE
5343 | NFS_INO_REVAL_FORCED);
5345 + uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5346 + gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5347 + tag = inode->i_tag;
5349 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5350 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5351 @@ -1335,9 +1359,9 @@ static int nfs_update_inode(struct inode
5352 | NFS_INO_REVAL_FORCED);
5354 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5355 - if (inode->i_uid != fattr->uid) {
5356 + if (uid != fattr->uid) {
5357 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5358 - inode->i_uid = fattr->uid;
5361 } else if (server->caps & NFS_CAP_OWNER)
5362 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5363 @@ -1346,9 +1370,9 @@ static int nfs_update_inode(struct inode
5364 | NFS_INO_REVAL_FORCED);
5366 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5367 - if (inode->i_gid != fattr->gid) {
5368 + if (gid != fattr->gid) {
5369 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5370 - inode->i_gid = fattr->gid;
5373 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5374 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5375 @@ -1356,6 +1380,10 @@ static int nfs_update_inode(struct inode
5376 | NFS_INO_INVALID_ACL
5377 | NFS_INO_REVAL_FORCED);
5379 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5380 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5381 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
5383 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5384 if (inode->i_nlink != fattr->nlink) {
5385 invalid |= NFS_INO_INVALID_ATTR;
5386 diff -NurpP --minimal linux-3.2.8/fs/nfs/nfs3xdr.c linux-3.2.8-vs2.3.2.7/fs/nfs/nfs3xdr.c
5387 --- linux-3.2.8/fs/nfs/nfs3xdr.c 2011-03-15 18:07:32.000000000 +0100
5388 +++ linux-3.2.8-vs2.3.2.7/fs/nfs/nfs3xdr.c 2011-12-05 19:33:02.000000000 +0100
5390 #include <linux/nfs3.h>
5391 #include <linux/nfs_fs.h>
5392 #include <linux/nfsacl.h>
5393 +#include <linux/vs_tag.h>
5394 #include "internal.h"
5396 #define NFSDBG_FACILITY NFSDBG_XDR
5397 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5401 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5402 +static void encode_sattr3(struct xdr_stream *xdr,
5403 + const struct iattr *attr, int tag)
5407 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
5411 - if (attr->ia_valid & ATTR_UID) {
5412 + if (attr->ia_valid & ATTR_UID ||
5413 + (tag && (attr->ia_valid & ATTR_TAG))) {
5415 - *p++ = cpu_to_be32(attr->ia_uid);
5416 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5417 + attr->ia_uid, attr->ia_tag));
5421 - if (attr->ia_valid & ATTR_GID) {
5422 + if (attr->ia_valid & ATTR_GID ||
5423 + (tag && (attr->ia_valid & ATTR_TAG))) {
5425 - *p++ = cpu_to_be32(attr->ia_gid);
5426 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5427 + attr->ia_gid, attr->ia_tag));
5431 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
5432 const struct nfs3_sattrargs *args)
5434 encode_nfs_fh3(xdr, args->fh);
5435 - encode_sattr3(xdr, args->sattr);
5436 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5437 encode_sattrguard3(xdr, args);
5440 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
5443 static void encode_createhow3(struct xdr_stream *xdr,
5444 - const struct nfs3_createargs *args)
5445 + const struct nfs3_createargs *args, int tag)
5447 encode_uint32(xdr, args->createmode);
5448 switch (args->createmode) {
5449 case NFS3_CREATE_UNCHECKED:
5450 case NFS3_CREATE_GUARDED:
5451 - encode_sattr3(xdr, args->sattr);
5452 + encode_sattr3(xdr, args->sattr, tag);
5454 case NFS3_CREATE_EXCLUSIVE:
5455 encode_createverf3(xdr, args->verifier);
5456 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
5457 const struct nfs3_createargs *args)
5459 encode_diropargs3(xdr, args->fh, args->name, args->len);
5460 - encode_createhow3(xdr, args);
5461 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5465 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5466 const struct nfs3_mkdirargs *args)
5468 encode_diropargs3(xdr, args->fh, args->name, args->len);
5469 - encode_sattr3(xdr, args->sattr);
5470 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5474 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5477 static void encode_symlinkdata3(struct xdr_stream *xdr,
5478 - const struct nfs3_symlinkargs *args)
5479 + const struct nfs3_symlinkargs *args, int tag)
5481 - encode_sattr3(xdr, args->sattr);
5482 + encode_sattr3(xdr, args->sattr, tag);
5483 encode_nfspath3(xdr, args->pages, args->pathlen);
5486 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
5487 const struct nfs3_symlinkargs *args)
5489 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5490 - encode_symlinkdata3(xdr, args);
5491 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5495 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
5498 static void encode_devicedata3(struct xdr_stream *xdr,
5499 - const struct nfs3_mknodargs *args)
5500 + const struct nfs3_mknodargs *args, int tag)
5502 - encode_sattr3(xdr, args->sattr);
5503 + encode_sattr3(xdr, args->sattr, tag);
5504 encode_specdata3(xdr, args->rdev);
5507 static void encode_mknoddata3(struct xdr_stream *xdr,
5508 - const struct nfs3_mknodargs *args)
5509 + const struct nfs3_mknodargs *args, int tag)
5511 encode_ftype3(xdr, args->type);
5512 switch (args->type) {
5515 - encode_devicedata3(xdr, args);
5516 + encode_devicedata3(xdr, args, tag);
5520 - encode_sattr3(xdr, args->sattr);
5521 + encode_sattr3(xdr, args->sattr, tag);
5525 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5526 const struct nfs3_mknodargs *args)
5528 encode_diropargs3(xdr, args->fh, args->name, args->len);
5529 - encode_mknoddata3(xdr, args);
5530 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5534 diff -NurpP --minimal linux-3.2.8/fs/nfs/super.c linux-3.2.8-vs2.3.2.7/fs/nfs/super.c
5535 --- linux-3.2.8/fs/nfs/super.c 2012-02-28 05:53:29.000000000 +0100
5536 +++ linux-3.2.8-vs2.3.2.7/fs/nfs/super.c 2012-01-26 08:52:10.000000000 +0100
5538 #include <linux/nfs_xdr.h>
5539 #include <linux/magic.h>
5540 #include <linux/parser.h>
5541 +#include <linux/vs_tag.h>
5543 #include <asm/system.h>
5544 #include <asm/uaccess.h>
5545 @@ -87,6 +88,7 @@ enum {
5546 Opt_sharecache, Opt_nosharecache,
5547 Opt_resvport, Opt_noresvport,
5548 Opt_fscache, Opt_nofscache,
5549 + Opt_tag, Opt_notag,
5551 /* Mount options that take integer arguments */
5553 @@ -100,6 +102,7 @@ enum {
5559 /* Mount options that take string arguments */
5560 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
5561 @@ -180,6 +183,10 @@ static const match_table_t nfs_mount_opt
5562 { Opt_fscache_uniq, "fsc=%s" },
5563 { Opt_local_lock, "local_lock=%s" },
5565 + { Opt_tag, "tag" },
5566 + { Opt_notag, "notag" },
5567 + { Opt_tagid, "tagid=%u" },
5572 @@ -650,6 +657,7 @@ static void nfs_show_mount_options(struc
5573 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5574 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5575 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5576 + { NFS_MOUNT_TAGGED, ",tag", "" },
5579 const struct proc_nfs_info *nfs_infop;
5580 @@ -1217,6 +1225,14 @@ static int nfs_parse_mount_options(char
5581 kfree(mnt->fscache_uniq);
5582 mnt->fscache_uniq = NULL;
5584 +#ifndef CONFIG_TAGGING_NONE
5586 + mnt->flags |= NFS_MOUNT_TAGGED;
5589 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5594 * options that take numeric values
5595 @@ -1323,6 +1339,12 @@ static int nfs_parse_mount_options(char
5596 goto out_invalid_value;
5597 mnt->minorversion = option;
5599 +#ifdef CONFIG_PROPAGATE
5602 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5607 * options that take text values
5608 diff -NurpP --minimal linux-3.2.8/fs/nfsd/auth.c linux-3.2.8-vs2.3.2.7/fs/nfsd/auth.c
5609 --- linux-3.2.8/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
5610 +++ linux-3.2.8-vs2.3.2.7/fs/nfsd/auth.c 2011-12-05 19:33:02.000000000 +0100
5612 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
5614 #include <linux/sched.h>
5615 +#include <linux/vs_tag.h>
5619 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5621 new->fsuid = rqstp->rq_cred.cr_uid;
5622 new->fsgid = rqstp->rq_cred.cr_gid;
5623 + /* FIXME: this desperately needs a tag :)
5624 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5627 rqgi = rqstp->rq_cred.cr_group_info;
5629 diff -NurpP --minimal linux-3.2.8/fs/nfsd/nfs3xdr.c linux-3.2.8-vs2.3.2.7/fs/nfsd/nfs3xdr.c
5630 --- linux-3.2.8/fs/nfsd/nfs3xdr.c 2011-07-22 11:18:05.000000000 +0200
5631 +++ linux-3.2.8-vs2.3.2.7/fs/nfsd/nfs3xdr.c 2011-12-05 19:33:02.000000000 +0100
5635 #include <linux/namei.h>
5636 +#include <linux/vs_tag.h>
5640 @@ -95,6 +96,8 @@ static __be32 *
5641 decode_sattr3(__be32 *p, struct iattr *iap)
5649 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
5652 iap->ia_valid |= ATTR_UID;
5653 - iap->ia_uid = ntohl(*p++);
5654 + uid = ntohl(*p++);
5657 iap->ia_valid |= ATTR_GID;
5658 - iap->ia_gid = ntohl(*p++);
5659 + gid = ntohl(*p++);
5661 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5662 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5663 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5667 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5668 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5669 *p++ = htonl((u32) stat->mode);
5670 *p++ = htonl((u32) stat->nlink);
5671 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5672 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5673 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5674 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5675 + stat->uid, stat->tag)));
5676 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5677 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5678 + stat->gid, stat->tag)));
5679 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5680 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5682 diff -NurpP --minimal linux-3.2.8/fs/nfsd/nfs4xdr.c linux-3.2.8-vs2.3.2.7/fs/nfsd/nfs4xdr.c
5683 --- linux-3.2.8/fs/nfsd/nfs4xdr.c 2012-01-09 16:14:54.000000000 +0100
5684 +++ linux-3.2.8-vs2.3.2.7/fs/nfsd/nfs4xdr.c 2011-12-05 19:33:02.000000000 +0100
5686 #include <linux/utsname.h>
5687 #include <linux/pagemap.h>
5688 #include <linux/sunrpc/svcauth_gss.h>
5689 +#include <linux/vs_tag.h>
5693 @@ -2328,14 +2329,18 @@ out_acl:
5694 WRITE32(stat.nlink);
5696 if (bmval1 & FATTR4_WORD1_OWNER) {
5697 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5698 + status = nfsd4_encode_user(rqstp,
5699 + TAGINO_UID(DX_TAG(dentry->d_inode),
5700 + stat.uid, stat.tag), &p, &buflen);
5701 if (status == nfserr_resource)
5706 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5707 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5708 + status = nfsd4_encode_group(rqstp,
5709 + TAGINO_GID(DX_TAG(dentry->d_inode),
5710 + stat.gid, stat.tag), &p, &buflen);
5711 if (status == nfserr_resource)
5714 diff -NurpP --minimal linux-3.2.8/fs/nfsd/nfsxdr.c linux-3.2.8-vs2.3.2.7/fs/nfsd/nfsxdr.c
5715 --- linux-3.2.8/fs/nfsd/nfsxdr.c 2011-05-22 16:17:53.000000000 +0200
5716 +++ linux-3.2.8-vs2.3.2.7/fs/nfsd/nfsxdr.c 2011-12-05 19:33:02.000000000 +0100
5721 +#include <linux/vs_tag.h>
5723 #define NFSDDBG_FACILITY NFSDDBG_XDR
5725 @@ -88,6 +89,8 @@ static __be32 *
5726 decode_sattr(__be32 *p, struct iattr *iap)
5734 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
5736 if ((tmp = ntohl(*p++)) != (u32)-1) {
5737 iap->ia_valid |= ATTR_UID;
5738 - iap->ia_uid = tmp;
5741 if ((tmp = ntohl(*p++)) != (u32)-1) {
5742 iap->ia_valid |= ATTR_GID;
5743 - iap->ia_gid = tmp;
5746 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5747 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5748 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5749 if ((tmp = ntohl(*p++)) != (u32)-1) {
5750 iap->ia_valid |= ATTR_SIZE;
5752 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5753 *p++ = htonl(nfs_ftypes[type >> 12]);
5754 *p++ = htonl((u32) stat->mode);
5755 *p++ = htonl((u32) stat->nlink);
5756 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5757 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5758 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5759 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5760 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5761 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5763 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5764 *p++ = htonl(NFS_MAXPATHLEN);
5765 diff -NurpP --minimal linux-3.2.8/fs/ocfs2/dlmglue.c linux-3.2.8-vs2.3.2.7/fs/ocfs2/dlmglue.c
5766 --- linux-3.2.8/fs/ocfs2/dlmglue.c 2012-01-09 16:14:55.000000000 +0100
5767 +++ linux-3.2.8-vs2.3.2.7/fs/ocfs2/dlmglue.c 2011-12-05 19:33:02.000000000 +0100
5768 @@ -2047,6 +2047,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5769 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5770 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
5771 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
5772 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
5773 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5774 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5775 lvb->lvb_iatime_packed =
5776 @@ -2097,6 +2098,7 @@ static void ocfs2_refresh_inode_from_lvb
5778 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
5779 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
5780 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
5781 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5782 set_nlink(inode, be16_to_cpu(lvb->lvb_inlink));
5783 ocfs2_unpack_timespec(&inode->i_atime,
5784 diff -NurpP --minimal linux-3.2.8/fs/ocfs2/dlmglue.h linux-3.2.8-vs2.3.2.7/fs/ocfs2/dlmglue.h
5785 --- linux-3.2.8/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
5786 +++ linux-3.2.8-vs2.3.2.7/fs/ocfs2/dlmglue.h 2011-12-05 19:33:02.000000000 +0100
5787 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5790 __be32 lvb_igeneration;
5791 - __be32 lvb_reserved2;
5793 + __be16 lvb_reserved2;
5796 #define OCFS2_QINFO_LVB_VERSION 1
5797 diff -NurpP --minimal linux-3.2.8/fs/ocfs2/file.c linux-3.2.8-vs2.3.2.7/fs/ocfs2/file.c
5798 --- linux-3.2.8/fs/ocfs2/file.c 2012-01-09 16:14:55.000000000 +0100
5799 +++ linux-3.2.8-vs2.3.2.7/fs/ocfs2/file.c 2011-12-05 19:33:02.000000000 +0100
5800 @@ -1123,7 +1123,7 @@ int ocfs2_setattr(struct dentry *dentry,
5801 attr->ia_valid &= ~ATTR_SIZE;
5803 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5804 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5805 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5806 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5809 diff -NurpP --minimal linux-3.2.8/fs/ocfs2/inode.c linux-3.2.8-vs2.3.2.7/fs/ocfs2/inode.c
5810 --- linux-3.2.8/fs/ocfs2/inode.c 2012-01-09 16:14:55.000000000 +0100
5811 +++ linux-3.2.8-vs2.3.2.7/fs/ocfs2/inode.c 2011-12-05 19:33:02.000000000 +0100
5813 #include <linux/highmem.h>
5814 #include <linux/pagemap.h>
5815 #include <linux/quotaops.h>
5816 +#include <linux/vs_tag.h>
5818 #include <asm/byteorder.h>
5820 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5822 unsigned int flags = OCFS2_I(inode)->ip_attr;
5824 - inode->i_flags &= ~(S_IMMUTABLE |
5825 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5826 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5828 if (flags & OCFS2_IMMUTABLE_FL)
5829 inode->i_flags |= S_IMMUTABLE;
5830 + if (flags & OCFS2_IXUNLINK_FL)
5831 + inode->i_flags |= S_IXUNLINK;
5833 if (flags & OCFS2_SYNC_FL)
5834 inode->i_flags |= S_SYNC;
5835 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5836 inode->i_flags |= S_NOATIME;
5837 if (flags & OCFS2_DIRSYNC_FL)
5838 inode->i_flags |= S_DIRSYNC;
5840 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5842 + if (flags & OCFS2_BARRIER_FL)
5843 + inode->i_vflags |= V_BARRIER;
5844 + if (flags & OCFS2_COW_FL)
5845 + inode->i_vflags |= V_COW;
5848 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5849 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5851 unsigned int flags = oi->vfs_inode.i_flags;
5852 + unsigned int vflags = oi->vfs_inode.i_vflags;
5854 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5855 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5856 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5857 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5859 + if (flags & S_IMMUTABLE)
5860 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5861 + if (flags & S_IXUNLINK)
5862 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5864 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5865 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5867 oi->ip_attr |= OCFS2_SYNC_FL;
5868 if (flags & S_APPEND)
5869 oi->ip_attr |= OCFS2_APPEND_FL;
5870 - if (flags & S_IMMUTABLE)
5871 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5872 if (flags & S_NOATIME)
5873 oi->ip_attr |= OCFS2_NOATIME_FL;
5874 if (flags & S_DIRSYNC)
5875 oi->ip_attr |= OCFS2_DIRSYNC_FL;
5877 + if (vflags & V_BARRIER)
5878 + oi->ip_attr |= OCFS2_BARRIER_FL;
5879 + if (vflags & V_COW)
5880 + oi->ip_attr |= OCFS2_COW_FL;
5883 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
5884 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
5885 struct super_block *sb;
5886 struct ocfs2_super *osb;
5893 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
5894 inode->i_generation = le32_to_cpu(fe->i_generation);
5895 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
5896 inode->i_mode = le16_to_cpu(fe->i_mode);
5897 - inode->i_uid = le32_to_cpu(fe->i_uid);
5898 - inode->i_gid = le32_to_cpu(fe->i_gid);
5899 + uid = le32_to_cpu(fe->i_uid);
5900 + gid = le32_to_cpu(fe->i_gid);
5901 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5902 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5903 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5904 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
5906 /* Fast symlinks will have i_size but no allocated clusters. */
5907 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
5908 diff -NurpP --minimal linux-3.2.8/fs/ocfs2/inode.h linux-3.2.8-vs2.3.2.7/fs/ocfs2/inode.h
5909 --- linux-3.2.8/fs/ocfs2/inode.h 2012-01-09 16:14:55.000000000 +0100
5910 +++ linux-3.2.8-vs2.3.2.7/fs/ocfs2/inode.h 2011-12-05 19:33:02.000000000 +0100
5911 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
5913 void ocfs2_set_inode_flags(struct inode *inode);
5914 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
5915 +int ocfs2_sync_flags(struct inode *inode, int, int);
5917 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
5919 diff -NurpP --minimal linux-3.2.8/fs/ocfs2/ioctl.c linux-3.2.8-vs2.3.2.7/fs/ocfs2/ioctl.c
5920 --- linux-3.2.8/fs/ocfs2/ioctl.c 2012-01-09 16:14:55.000000000 +0100
5921 +++ linux-3.2.8-vs2.3.2.7/fs/ocfs2/ioctl.c 2011-12-05 19:33:02.000000000 +0100
5922 @@ -78,7 +78,41 @@ static int ocfs2_get_inode_attr(struct i
5926 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5927 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
5929 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5930 + struct buffer_head *bh = NULL;
5931 + handle_t *handle = NULL;
5934 + status = ocfs2_inode_lock(inode, &bh, 1);
5936 + mlog_errno(status);
5939 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5940 + if (IS_ERR(handle)) {
5941 + status = PTR_ERR(handle);
5942 + mlog_errno(status);
5946 + inode->i_flags = flags;
5947 + inode->i_vflags = vflags;
5948 + ocfs2_get_inode_flags(OCFS2_I(inode));
5950 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
5952 + mlog_errno(status);
5954 + ocfs2_commit_trans(osb, handle);
5956 + ocfs2_inode_unlock(inode, 1);
5961 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5964 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
5965 @@ -103,6 +137,11 @@ static int ocfs2_set_inode_attr(struct i
5966 if (!S_ISDIR(inode->i_mode))
5967 flags &= ~OCFS2_DIRSYNC_FL;
5969 + if (IS_BARRIER(inode)) {
5970 + vxwprintk_task(1, "messing with the barrier.");
5974 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5975 if (IS_ERR(handle)) {
5976 status = PTR_ERR(handle);
5977 @@ -881,6 +920,7 @@ bail:
5982 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5984 struct inode *inode = filp->f_path.dentry->d_inode;
5985 diff -NurpP --minimal linux-3.2.8/fs/ocfs2/namei.c linux-3.2.8-vs2.3.2.7/fs/ocfs2/namei.c
5986 --- linux-3.2.8/fs/ocfs2/namei.c 2012-01-09 16:14:55.000000000 +0100
5987 +++ linux-3.2.8-vs2.3.2.7/fs/ocfs2/namei.c 2011-12-05 19:33:02.000000000 +0100
5989 #include <linux/slab.h>
5990 #include <linux/highmem.h>
5991 #include <linux/quotaops.h>
5992 +#include <linux/vs_tag.h>
5994 #include <cluster/masklog.h>
5996 @@ -475,6 +476,7 @@ static int __ocfs2_mknod_locked(struct i
5997 struct ocfs2_dinode *fe = NULL;
5998 struct ocfs2_extent_list *fel;
6004 @@ -512,8 +514,11 @@ static int __ocfs2_mknod_locked(struct i
6005 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
6006 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6007 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6008 - fe->i_uid = cpu_to_le32(inode->i_uid);
6009 - fe->i_gid = cpu_to_le32(inode->i_gid);
6011 + tag = dx_current_fstag(osb->sb);
6012 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6013 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6014 + inode->i_tag = tag;
6015 fe->i_mode = cpu_to_le16(inode->i_mode);
6016 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6017 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6018 diff -NurpP --minimal linux-3.2.8/fs/ocfs2/ocfs2.h linux-3.2.8-vs2.3.2.7/fs/ocfs2/ocfs2.h
6019 --- linux-3.2.8/fs/ocfs2/ocfs2.h 2012-01-09 16:14:55.000000000 +0100
6020 +++ linux-3.2.8-vs2.3.2.7/fs/ocfs2/ocfs2.h 2011-12-05 19:33:02.000000000 +0100
6021 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
6023 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
6024 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
6025 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
6028 #define OCFS2_OSB_SOFT_RO 0x0001
6029 diff -NurpP --minimal linux-3.2.8/fs/ocfs2/ocfs2_fs.h linux-3.2.8-vs2.3.2.7/fs/ocfs2/ocfs2_fs.h
6030 --- linux-3.2.8/fs/ocfs2/ocfs2_fs.h 2011-05-22 16:17:53.000000000 +0200
6031 +++ linux-3.2.8-vs2.3.2.7/fs/ocfs2/ocfs2_fs.h 2011-12-05 19:33:02.000000000 +0100
6032 @@ -266,6 +266,11 @@
6033 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
6034 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
6036 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6038 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6039 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6041 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
6042 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
6044 diff -NurpP --minimal linux-3.2.8/fs/ocfs2/super.c linux-3.2.8-vs2.3.2.7/fs/ocfs2/super.c
6045 --- linux-3.2.8/fs/ocfs2/super.c 2012-01-09 16:14:55.000000000 +0100
6046 +++ linux-3.2.8-vs2.3.2.7/fs/ocfs2/super.c 2011-12-05 19:33:02.000000000 +0100
6047 @@ -185,6 +185,7 @@ enum {
6051 + Opt_tag, Opt_notag, Opt_tagid,
6055 @@ -216,6 +217,9 @@ static const match_table_t tokens = {
6056 {Opt_coherency_full, "coherency=full"},
6057 {Opt_resv_level, "resv_level=%u"},
6058 {Opt_dir_resv_level, "dir_resv_level=%u"},
6060 + {Opt_notag, "notag"},
6061 + {Opt_tagid, "tagid=%u"},
6065 @@ -663,6 +667,13 @@ static int ocfs2_remount(struct super_bl
6069 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6070 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6072 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6076 /* We're going to/from readonly mode. */
6077 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
6078 /* Disable quota accounting before remounting RO */
6079 @@ -1178,6 +1189,9 @@ static int ocfs2_fill_super(struct super
6081 ocfs2_complete_mount_recovery(osb);
6083 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6084 + sb->s_flags |= MS_TAGGED;
6086 if (ocfs2_mount_local(osb))
6087 snprintf(nodestr, sizeof(nodestr), "local");
6089 @@ -1507,6 +1521,20 @@ static int ocfs2_parse_options(struct su
6090 option < OCFS2_MAX_RESV_LEVEL)
6091 mopt->dir_resv_level = option;
6093 +#ifndef CONFIG_TAGGING_NONE
6095 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6098 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6101 +#ifdef CONFIG_PROPAGATE
6104 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6109 "Unrecognized mount option \"%s\" "
6110 diff -NurpP --minimal linux-3.2.8/fs/open.c linux-3.2.8-vs2.3.2.7/fs/open.c
6111 --- linux-3.2.8/fs/open.c 2012-01-09 16:14:55.000000000 +0100
6112 +++ linux-3.2.8-vs2.3.2.7/fs/open.c 2011-12-05 19:33:02.000000000 +0100
6114 #include <linux/fs_struct.h>
6115 #include <linux/ima.h>
6116 #include <linux/dnotify.h>
6117 +#include <linux/vs_base.h>
6118 +#include <linux/vs_limit.h>
6119 +#include <linux/vs_tag.h>
6120 +#include <linux/vs_cowbl.h>
6121 +#include <linux/vserver/dlimit.h>
6123 #include "internal.h"
6125 @@ -74,6 +79,12 @@ static long do_sys_truncate(const char _
6126 error = user_path(pathname, &path);
6130 +#ifdef CONFIG_VSERVER_COWBL
6131 + error = cow_check_and_break(&path);
6133 + goto dput_and_out;
6135 inode = path.dentry->d_inode;
6137 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
6138 @@ -489,6 +500,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6140 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6142 +#ifdef CONFIG_VSERVER_COWBL
6143 + error = cow_check_and_break(&path);
6146 error = chmod_common(&path, mode);
6149 @@ -509,11 +524,11 @@ static int chown_common(struct path *pat
6150 newattrs.ia_valid = ATTR_CTIME;
6151 if (user != (uid_t) -1) {
6152 newattrs.ia_valid |= ATTR_UID;
6153 - newattrs.ia_uid = user;
6154 + newattrs.ia_uid = dx_map_uid(user);
6156 if (group != (gid_t) -1) {
6157 newattrs.ia_valid |= ATTR_GID;
6158 - newattrs.ia_gid = group;
6159 + newattrs.ia_gid = dx_map_gid(group);
6161 if (!S_ISDIR(inode->i_mode))
6162 newattrs.ia_valid |=
6163 @@ -538,6 +553,10 @@ SYSCALL_DEFINE3(chown, const char __user
6164 error = mnt_want_write(path.mnt);
6167 +#ifdef CONFIG_VSERVER_COWBL
6168 + error = cow_check_and_break(&path);
6171 error = chown_common(&path, user, group);
6172 mnt_drop_write(path.mnt);
6174 @@ -565,6 +584,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6175 error = mnt_want_write(path.mnt);
6178 +#ifdef CONFIG_VSERVER_COWBL
6179 + error = cow_check_and_break(&path);
6182 error = chown_common(&path, user, group);
6183 mnt_drop_write(path.mnt);
6185 @@ -584,6 +607,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6186 error = mnt_want_write(path.mnt);
6189 +#ifdef CONFIG_VSERVER_COWBL
6190 + error = cow_check_and_break(&path);
6193 error = chown_common(&path, user, group);
6194 mnt_drop_write(path.mnt);
6196 @@ -839,6 +866,7 @@ static void __put_unused_fd(struct files
6197 __FD_CLR(fd, fdt->open_fds);
6198 if (fd < files->next_fd)
6199 files->next_fd = fd;
6200 + vx_openfd_dec(fd);
6203 void put_unused_fd(unsigned int fd)
6204 diff -NurpP --minimal linux-3.2.8/fs/proc/array.c linux-3.2.8-vs2.3.2.7/fs/proc/array.c
6205 --- linux-3.2.8/fs/proc/array.c 2011-10-24 18:45:27.000000000 +0200
6206 +++ linux-3.2.8-vs2.3.2.7/fs/proc/array.c 2011-12-05 19:33:02.000000000 +0100
6208 #include <linux/pid_namespace.h>
6209 #include <linux/ptrace.h>
6210 #include <linux/tracehook.h>
6211 +#include <linux/vs_context.h>
6212 +#include <linux/vs_network.h>
6214 #include <asm/pgtable.h>
6215 #include <asm/processor.h>
6216 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6218 ppid = pid_alive(p) ?
6219 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6220 + if (unlikely(vx_current_initpid(p->pid)))
6225 struct task_struct *tracer = ptrace_parent(p);
6226 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6229 static void render_cap_t(struct seq_file *m, const char *header,
6231 + struct vx_info *vxi, kernel_cap_t *a)
6235 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6236 cap_bset = cred->cap_bset;
6239 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6240 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6241 - render_cap_t(m, "CapEff:\t", &cap_effective);
6242 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6243 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6244 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6245 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6246 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6247 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6250 static inline void task_context_switch_counts(struct seq_file *m,
6251 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6255 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6256 + struct pid *pid, struct task_struct *task)
6258 + seq_printf(m, "Proxy:\t%p(%c)\n"
6266 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6267 + atomic_read(&task->nsproxy->count),
6268 + task->nsproxy->uts_ns,
6269 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6270 + task->nsproxy->ipc_ns,
6271 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6272 + task->nsproxy->mnt_ns,
6273 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6274 + task->nsproxy->pid_ns,
6275 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6276 + task->nsproxy->net_ns,
6277 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6281 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6283 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6286 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6287 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6291 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6292 struct pid *pid, struct task_struct *task)
6294 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6296 task_cpus_allowed(m, task);
6297 cpuset_task_status_allowed(m, task);
6298 + task_vs_id(m, task);
6299 task_context_switch_counts(m, task);
6302 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file
6303 /* convert nsec -> ticks */
6304 start_time = nsec_to_clock_t(start_time);
6306 + /* fixup start time for virt uptime */
6307 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6308 + unsigned long long bias =
6309 + current->vx_info->cvirt.bias_clock;
6311 + if (start_time > bias)
6312 + start_time -= bias;
6317 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6318 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6319 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6320 diff -NurpP --minimal linux-3.2.8/fs/proc/base.c linux-3.2.8-vs2.3.2.7/fs/proc/base.c
6321 --- linux-3.2.8/fs/proc/base.c 2012-02-28 05:53:29.000000000 +0100
6322 +++ linux-3.2.8-vs2.3.2.7/fs/proc/base.c 2012-02-15 03:26:56.000000000 +0100
6324 #include <linux/pid_namespace.h>
6325 #include <linux/fs_struct.h>
6326 #include <linux/slab.h>
6327 +#include <linux/vs_context.h>
6328 +#include <linux/vs_network.h>
6329 #ifdef CONFIG_HARDWALL
6330 #include <asm/hardwall.h>
6332 @@ -1021,11 +1023,16 @@ static ssize_t oom_adjust_write(struct f
6336 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6337 + if (oom_adjust < task->signal->oom_adj &&
6338 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6343 + /* prevent guest processes from circumventing the oom killer */
6344 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6345 + oom_adjust = OOM_ADJUST_MIN;
6348 * Warn that /proc/pid/oom_adj is deprecated, see
6349 * Documentation/feature-removal-schedule.txt.
6350 @@ -1180,7 +1187,7 @@ static ssize_t proc_loginuid_write(struc
6354 - if (!capable(CAP_AUDIT_CONTROL))
6355 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6359 @@ -1627,6 +1634,8 @@ struct inode *proc_pid_make_inode(struct
6360 inode->i_gid = cred->egid;
6363 + /* procfs is xid tagged */
6364 + inode->i_tag = (tag_t)vx_task_xid(task);
6365 security_task_to_inode(task, inode);
6368 @@ -1663,6 +1672,8 @@ int pid_getattr(struct vfsmount *mnt, st
6372 +static unsigned name_to_int(struct dentry *dentry);
6375 * Exceptional case: normally we are not allowed to unhash a busy
6376 * directory. In this case, however, we can do it - no aliasing problems
6377 @@ -1691,6 +1702,12 @@ int pid_revalidate(struct dentry *dentry
6378 task = get_proc_task(inode);
6381 + unsigned pid = name_to_int(dentry);
6383 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6384 + put_task_struct(task);
6387 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6388 task_dumpable(task)) {
6390 @@ -1707,6 +1724,7 @@ int pid_revalidate(struct dentry *dentry
6391 put_task_struct(task);
6398 @@ -2196,6 +2214,13 @@ static struct dentry *proc_pident_lookup
6402 + /* TODO: maybe we can come up with a generic approach? */
6403 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6404 + (dentry->d_name.len == 5) &&
6405 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6406 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6410 * Yes, it does not scale. And it should not. Don't add
6411 * new entries into /proc/<tgid>/ without very good reasons.
6412 @@ -2581,7 +2606,7 @@ out_iput:
6413 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6415 struct dentry *error;
6416 - struct task_struct *task = get_proc_task(dir);
6417 + struct task_struct *task = get_proc_task_real(dir);
6418 const struct pid_entry *p, *last;
6420 error = ERR_PTR(-ENOENT);
6421 @@ -2688,6 +2713,9 @@ static int proc_pid_personality(struct s
6422 static const struct file_operations proc_task_operations;
6423 static const struct inode_operations proc_task_inode_operations;
6425 +extern int proc_pid_vx_info(struct task_struct *, char *);
6426 +extern int proc_pid_nx_info(struct task_struct *, char *);
6428 static const struct pid_entry tgid_base_stuff[] = {
6429 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6430 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6431 @@ -2751,6 +2779,8 @@ static const struct pid_entry tgid_base_
6432 #ifdef CONFIG_CGROUPS
6433 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6435 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6436 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6437 INF("oom_score", S_IRUGO, proc_oom_score),
6438 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6439 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6440 @@ -2770,6 +2800,7 @@ static const struct pid_entry tgid_base_
6441 #ifdef CONFIG_HARDWALL
6442 INF("hardwall", S_IRUGO, proc_pid_hardwall),
6444 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6447 static int proc_tgid_base_readdir(struct file * filp,
6448 @@ -2962,7 +2993,7 @@ retry:
6450 pid = find_ge_pid(iter.tgid, ns);
6452 - iter.tgid = pid_nr_ns(pid, ns);
6453 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6454 iter.task = pid_task(pid, PIDTYPE_PID);
6455 /* What we to know is if the pid we have find is the
6456 * pid of a thread_group_leader. Testing for task
6457 @@ -2992,7 +3023,7 @@ static int proc_pid_fill_cache(struct fi
6458 struct tgid_iter iter)
6460 char name[PROC_NUMBUF];
6461 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6462 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6463 return proc_fill_cache(filp, dirent, filldir, name, len,
6464 proc_pid_instantiate, iter.task, NULL);
6466 @@ -3009,7 +3040,7 @@ int proc_pid_readdir(struct file * filp,
6468 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6470 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
6471 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6475 @@ -3026,6 +3057,8 @@ int proc_pid_readdir(struct file * filp,
6477 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6478 filp->f_pos = iter.tgid + TGID_OFFSET;
6479 + if (!vx_proc_task_visible(iter.task))
6481 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6482 put_task_struct(iter.task);
6484 @@ -3179,6 +3212,8 @@ static struct dentry *proc_task_lookup(s
6485 tid = name_to_int(dentry);
6488 + if (vx_current_initpid(tid))
6491 ns = dentry->d_sb->s_fs_info;
6493 diff -NurpP --minimal linux-3.2.8/fs/proc/generic.c linux-3.2.8-vs2.3.2.7/fs/proc/generic.c
6494 --- linux-3.2.8/fs/proc/generic.c 2012-01-09 16:14:55.000000000 +0100
6495 +++ linux-3.2.8-vs2.3.2.7/fs/proc/generic.c 2011-12-05 19:33:02.000000000 +0100
6497 #include <linux/bitops.h>
6498 #include <linux/spinlock.h>
6499 #include <linux/completion.h>
6500 +#include <linux/vserver/inode.h>
6501 #include <asm/uaccess.h>
6503 #include "internal.h"
6504 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
6505 for (de = de->subdir; de ; de = de->next) {
6506 if (de->namelen != dentry->d_name.len)
6508 + if (!vx_hide_check(0, de->vx_flags))
6510 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6512 spin_unlock(&proc_subdir_lock);
6514 inode = proc_get_inode(dir->i_sb, de);
6515 + /* generic proc entries belong to the host */
6520 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
6522 /* filldir passes info to user space */
6524 + if (!vx_hide_check(0, de->vx_flags))
6526 spin_unlock(&proc_subdir_lock);
6527 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6528 de->low_ino, de->mode >> 12) < 0) {
6529 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
6532 spin_lock(&proc_subdir_lock);
6537 @@ -626,6 +634,7 @@ static struct proc_dir_entry *__proc_cre
6539 atomic_set(&ent->count, 1);
6541 + ent->vx_flags = IATTR_PROC_DEFAULT;
6542 spin_lock_init(&ent->pde_unload_lock);
6543 ent->pde_unload_completion = NULL;
6544 INIT_LIST_HEAD(&ent->pde_openers);
6545 @@ -649,7 +658,8 @@ struct proc_dir_entry *proc_symlink(cons
6551 + ent->vx_flags = IATTR_PROC_SYMLINK;
6555 diff -NurpP --minimal linux-3.2.8/fs/proc/inode.c linux-3.2.8-vs2.3.2.7/fs/proc/inode.c
6556 --- linux-3.2.8/fs/proc/inode.c 2012-01-09 16:14:55.000000000 +0100
6557 +++ linux-3.2.8-vs2.3.2.7/fs/proc/inode.c 2011-12-05 19:33:02.000000000 +0100
6558 @@ -442,6 +442,8 @@ struct inode *proc_get_inode(struct supe
6559 inode->i_uid = de->uid;
6560 inode->i_gid = de->gid;
6563 + PROC_I(inode)->vx_flags = de->vx_flags;
6565 inode->i_size = de->size;
6567 diff -NurpP --minimal linux-3.2.8/fs/proc/internal.h linux-3.2.8-vs2.3.2.7/fs/proc/internal.h
6568 --- linux-3.2.8/fs/proc/internal.h 2011-07-22 11:18:06.000000000 +0200
6569 +++ linux-3.2.8-vs2.3.2.7/fs/proc/internal.h 2011-12-05 19:33:02.000000000 +0100
6573 #include <linux/proc_fs.h>
6574 +#include <linux/vs_pid.h>
6576 extern struct proc_dir_entry proc_root;
6577 #ifdef CONFIG_PROC_SYSCTL
6578 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
6579 struct pid *pid, struct task_struct *task);
6580 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6581 struct pid *pid, struct task_struct *task);
6582 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6583 + struct pid *pid, struct task_struct *task);
6585 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6587 extern const struct file_operations proc_maps_operations;
6588 @@ -76,11 +80,16 @@ static inline struct pid *proc_pid(struc
6589 return PROC_I(inode)->pid;
6592 -static inline struct task_struct *get_proc_task(struct inode *inode)
6593 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6595 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6598 +static inline struct task_struct *get_proc_task(struct inode *inode)
6600 + return vx_get_proc_task(inode, proc_pid(inode));
6603 static inline int proc_fd(struct inode *inode)
6605 return PROC_I(inode)->fd;
6606 diff -NurpP --minimal linux-3.2.8/fs/proc/loadavg.c linux-3.2.8-vs2.3.2.7/fs/proc/loadavg.c
6607 --- linux-3.2.8/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
6608 +++ linux-3.2.8-vs2.3.2.7/fs/proc/loadavg.c 2011-12-05 19:33:02.000000000 +0100
6611 static int loadavg_proc_show(struct seq_file *m, void *v)
6613 + unsigned long running;
6614 + unsigned int threads;
6615 unsigned long avnrun[3];
6617 get_avenrun(avnrun, FIXED_1/200, 0);
6619 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6620 + struct vx_info *vxi = current_vx_info();
6622 + running = atomic_read(&vxi->cvirt.nr_running);
6623 + threads = atomic_read(&vxi->cvirt.nr_threads);
6625 + running = nr_running();
6626 + threads = nr_threads;
6629 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6630 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6631 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6632 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6633 - nr_running(), nr_threads,
6635 task_active_pid_ns(current)->last_pid);
6638 diff -NurpP --minimal linux-3.2.8/fs/proc/meminfo.c linux-3.2.8-vs2.3.2.7/fs/proc/meminfo.c
6639 --- linux-3.2.8/fs/proc/meminfo.c 2012-01-09 16:14:55.000000000 +0100
6640 +++ linux-3.2.8-vs2.3.2.7/fs/proc/meminfo.c 2011-12-15 01:11:32.000000000 +0100
6641 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6642 allowed = ((totalram_pages - hugetlb_total_pages())
6643 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6645 - cached = global_page_state(NR_FILE_PAGES) -
6646 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6647 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6648 total_swapcache_pages - i.bufferram;
6651 diff -NurpP --minimal linux-3.2.8/fs/proc/root.c linux-3.2.8-vs2.3.2.7/fs/proc/root.c
6652 --- linux-3.2.8/fs/proc/root.c 2012-01-09 16:14:55.000000000 +0100
6653 +++ linux-3.2.8-vs2.3.2.7/fs/proc/root.c 2012-01-09 16:19:31.000000000 +0100
6655 #include <linux/bitops.h>
6656 #include <linux/mount.h>
6657 #include <linux/pid_namespace.h>
6658 +#include <linux/vserver/inode.h>
6660 #include "internal.h"
6662 +struct proc_dir_entry *proc_virtual;
6664 +extern void proc_vx_init(void);
6666 static int proc_test_super(struct super_block *sb, void *data)
6668 return sb->s_fs_info == data;
6669 @@ -123,6 +128,7 @@ void __init proc_root_init(void)
6671 proc_mkdir("bus", NULL);
6676 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6677 @@ -190,6 +196,7 @@ struct proc_dir_entry proc_root = {
6678 .proc_iops = &proc_root_inode_operations,
6679 .proc_fops = &proc_root_operations,
6680 .parent = &proc_root,
6681 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6685 diff -NurpP --minimal linux-3.2.8/fs/proc/uptime.c linux-3.2.8-vs2.3.2.7/fs/proc/uptime.c
6686 --- linux-3.2.8/fs/proc/uptime.c 2012-02-28 05:53:29.000000000 +0100
6687 +++ linux-3.2.8-vs2.3.2.7/fs/proc/uptime.c 2012-01-26 09:03:19.000000000 +0100
6689 #include <linux/seq_file.h>
6690 #include <linux/time.h>
6691 #include <linux/kernel_stat.h>
6692 +#include <linux/vserver/cvirt.h>
6693 #include <asm/cputime.h>
6695 static int uptime_proc_show(struct seq_file *m, void *v)
6696 @@ -25,6 +26,10 @@ static int uptime_proc_show(struct seq_f
6697 nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
6698 idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
6701 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6702 + vx_vsi_uptime(&uptime, &idle);
6704 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6705 (unsigned long) uptime.tv_sec,
6706 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6707 diff -NurpP --minimal linux-3.2.8/fs/quota/dquot.c linux-3.2.8-vs2.3.2.7/fs/quota/dquot.c
6708 --- linux-3.2.8/fs/quota/dquot.c 2011-07-22 11:18:06.000000000 +0200
6709 +++ linux-3.2.8-vs2.3.2.7/fs/quota/dquot.c 2011-12-05 19:33:02.000000000 +0100
6710 @@ -1548,6 +1548,9 @@ int __dquot_alloc_space(struct inode *in
6711 int reserve = flags & DQUOT_SPACE_RESERVE;
6712 int nofail = flags & DQUOT_SPACE_NOFAIL;
6714 + if ((ret = dl_alloc_space(inode, number)))
6718 * First test before acquiring mutex - solves deadlocks when we
6719 * re-enter the quota code and are already holding the mutex
6720 @@ -1602,6 +1605,9 @@ int dquot_alloc_inode(const struct inode
6722 char warntype[MAXQUOTAS];
6724 + if ((ret = dl_alloc_inode(inode)))
6727 /* First test before acquiring mutex - solves deadlocks when we
6728 * re-enter the quota code and are already holding the mutex */
6729 if (!dquot_active(inode))
6730 @@ -1672,6 +1678,8 @@ void __dquot_free_space(struct inode *in
6731 char warntype[MAXQUOTAS];
6732 int reserve = flags & DQUOT_SPACE_RESERVE;
6734 + dl_free_space(inode, number);
6736 /* First test before acquiring mutex - solves deadlocks when we
6737 * re-enter the quota code and are already holding the mutex */
6738 if (!dquot_active(inode)) {
6739 @@ -1710,6 +1718,8 @@ void dquot_free_inode(const struct inode
6741 char warntype[MAXQUOTAS];
6743 + dl_free_inode(inode);
6745 /* First test before acquiring mutex - solves deadlocks when we
6746 * re-enter the quota code and are already holding the mutex */
6747 if (!dquot_active(inode))
6748 diff -NurpP --minimal linux-3.2.8/fs/quota/quota.c linux-3.2.8-vs2.3.2.7/fs/quota/quota.c
6749 --- linux-3.2.8/fs/quota/quota.c 2012-01-09 16:14:55.000000000 +0100
6750 +++ linux-3.2.8-vs2.3.2.7/fs/quota/quota.c 2011-12-05 19:33:02.000000000 +0100
6752 #include <linux/fs.h>
6753 #include <linux/namei.h>
6754 #include <linux/slab.h>
6755 +#include <linux/vs_context.h>
6756 #include <asm/current.h>
6757 #include <asm/uaccess.h>
6758 #include <linux/kernel.h>
6759 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
6763 - if (!capable(CAP_SYS_ADMIN))
6764 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6768 @@ -293,6 +294,46 @@ static int do_quotactl(struct super_bloc
6772 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6774 +#include <linux/vroot.h>
6775 +#include <linux/major.h>
6776 +#include <linux/module.h>
6777 +#include <linux/kallsyms.h>
6778 +#include <linux/vserver/debug.h>
6780 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6782 +static DEFINE_SPINLOCK(vroot_grb_lock);
6784 +int register_vroot_grb(vroot_grb_func *func) {
6787 + spin_lock(&vroot_grb_lock);
6788 + if (!vroot_get_real_bdev) {
6789 + vroot_get_real_bdev = func;
6792 + spin_unlock(&vroot_grb_lock);
6795 +EXPORT_SYMBOL(register_vroot_grb);
6797 +int unregister_vroot_grb(vroot_grb_func *func) {
6798 + int ret = -EINVAL;
6800 + spin_lock(&vroot_grb_lock);
6801 + if (vroot_get_real_bdev) {
6802 + vroot_get_real_bdev = NULL;
6805 + spin_unlock(&vroot_grb_lock);
6808 +EXPORT_SYMBOL(unregister_vroot_grb);
6813 * look up a superblock on which quota ops will be performed
6814 * - use the name of a block device to find the superblock thereon
6815 @@ -310,6 +351,22 @@ static struct super_block *quotactl_bloc
6818 return ERR_CAST(bdev);
6819 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6820 + if (bdev && bdev->bd_inode &&
6821 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6822 + struct block_device *bdnew = (void *)-EINVAL;
6824 + if (vroot_get_real_bdev)
6825 + bdnew = vroot_get_real_bdev(bdev);
6827 + vxdprintk(VXD_CBIT(misc, 0),
6828 + "vroot_get_real_bdev not set");
6830 + if (IS_ERR(bdnew))
6831 + return ERR_PTR(PTR_ERR(bdnew));
6835 sb = get_super(bdev);
6838 diff -NurpP --minimal linux-3.2.8/fs/reiserfs/file.c linux-3.2.8-vs2.3.2.7/fs/reiserfs/file.c
6839 --- linux-3.2.8/fs/reiserfs/file.c 2011-10-24 18:45:27.000000000 +0200
6840 +++ linux-3.2.8-vs2.3.2.7/fs/reiserfs/file.c 2011-12-05 19:33:02.000000000 +0100
6841 @@ -319,5 +319,6 @@ const struct inode_operations reiserfs_f
6842 .listxattr = reiserfs_listxattr,
6843 .removexattr = reiserfs_removexattr,
6844 .permission = reiserfs_permission,
6845 + .sync_flags = reiserfs_sync_flags,
6846 .get_acl = reiserfs_get_acl,
6848 diff -NurpP --minimal linux-3.2.8/fs/reiserfs/inode.c linux-3.2.8-vs2.3.2.7/fs/reiserfs/inode.c
6849 --- linux-3.2.8/fs/reiserfs/inode.c 2012-01-09 16:14:55.000000000 +0100
6850 +++ linux-3.2.8-vs2.3.2.7/fs/reiserfs/inode.c 2011-12-05 21:18:16.000000000 +0100
6852 #include <linux/writeback.h>
6853 #include <linux/quotaops.h>
6854 #include <linux/swap.h>
6855 +#include <linux/vs_tag.h>
6857 int reiserfs_commit_write(struct file *f, struct page *page,
6858 unsigned from, unsigned to);
6859 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
6860 struct buffer_head *bh;
6861 struct item_head *ih;
6865 //int version = ITEM_VERSION_1;
6867 bh = PATH_PLAST_BUFFER(path);
6868 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
6869 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
6870 unsigned long blocks;
6872 + uid = sd_v1_uid(sd);
6873 + gid = sd_v1_gid(sd);
6875 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
6876 set_inode_sd_version(inode, STAT_DATA_V1);
6877 inode->i_mode = sd_v1_mode(sd);
6878 set_nlink(inode, sd_v1_nlink(sd));
6879 - inode->i_uid = sd_v1_uid(sd);
6880 - inode->i_gid = sd_v1_gid(sd);
6881 inode->i_size = sd_v1_size(sd);
6882 inode->i_atime.tv_sec = sd_v1_atime(sd);
6883 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
6884 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
6885 // (directories and symlinks)
6886 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
6888 + uid = sd_v2_uid(sd);
6889 + gid = sd_v2_gid(sd);
6891 inode->i_mode = sd_v2_mode(sd);
6892 set_nlink(inode, sd_v2_nlink(sd));
6893 - inode->i_uid = sd_v2_uid(sd);
6894 inode->i_size = sd_v2_size(sd);
6895 - inode->i_gid = sd_v2_gid(sd);
6896 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
6897 inode->i_atime.tv_sec = sd_v2_atime(sd);
6898 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
6899 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
6900 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
6903 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6904 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6905 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
6908 if (S_ISREG(inode->i_mode)) {
6909 inode->i_op = &reiserfs_file_inode_operations;
6910 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
6911 static void inode2sd(void *sd, struct inode *inode, loff_t size)
6913 struct stat_data *sd_v2 = (struct stat_data *)sd;
6914 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
6915 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
6918 + set_sd_v2_uid(sd_v2, uid);
6919 + set_sd_v2_gid(sd_v2, gid);
6920 set_sd_v2_mode(sd_v2, inode->i_mode);
6921 set_sd_v2_nlink(sd_v2, inode->i_nlink);
6922 - set_sd_v2_uid(sd_v2, inode->i_uid);
6923 set_sd_v2_size(sd_v2, size);
6924 - set_sd_v2_gid(sd_v2, inode->i_gid);
6925 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
6926 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
6927 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
6928 @@ -2868,14 +2879,19 @@ int reiserfs_commit_write(struct file *f
6929 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
6931 if (reiserfs_attrs(inode->i_sb)) {
6932 - if (sd_attrs & REISERFS_SYNC_FL)
6933 - inode->i_flags |= S_SYNC;
6935 - inode->i_flags &= ~S_SYNC;
6936 if (sd_attrs & REISERFS_IMMUTABLE_FL)
6937 inode->i_flags |= S_IMMUTABLE;
6939 inode->i_flags &= ~S_IMMUTABLE;
6940 + if (sd_attrs & REISERFS_IXUNLINK_FL)
6941 + inode->i_flags |= S_IXUNLINK;
6943 + inode->i_flags &= ~S_IXUNLINK;
6945 + if (sd_attrs & REISERFS_SYNC_FL)
6946 + inode->i_flags |= S_SYNC;
6948 + inode->i_flags &= ~S_SYNC;
6949 if (sd_attrs & REISERFS_APPEND_FL)
6950 inode->i_flags |= S_APPEND;
6952 @@ -2888,6 +2904,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
6953 REISERFS_I(inode)->i_flags |= i_nopack_mask;
6955 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
6957 + if (sd_attrs & REISERFS_BARRIER_FL)
6958 + inode->i_vflags |= V_BARRIER;
6960 + inode->i_vflags &= ~V_BARRIER;
6961 + if (sd_attrs & REISERFS_COW_FL)
6962 + inode->i_vflags |= V_COW;
6964 + inode->i_vflags &= ~V_COW;
6968 @@ -2898,6 +2923,11 @@ void i_attrs_to_sd_attrs(struct inode *i
6969 *sd_attrs |= REISERFS_IMMUTABLE_FL;
6971 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
6972 + if (inode->i_flags & S_IXUNLINK)
6973 + *sd_attrs |= REISERFS_IXUNLINK_FL;
6975 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
6977 if (inode->i_flags & S_SYNC)
6978 *sd_attrs |= REISERFS_SYNC_FL;
6980 @@ -2910,6 +2940,15 @@ void i_attrs_to_sd_attrs(struct inode *i
6981 *sd_attrs |= REISERFS_NOTAIL_FL;
6983 *sd_attrs &= ~REISERFS_NOTAIL_FL;
6985 + if (inode->i_vflags & V_BARRIER)
6986 + *sd_attrs |= REISERFS_BARRIER_FL;
6988 + *sd_attrs &= ~REISERFS_BARRIER_FL;
6989 + if (inode->i_vflags & V_COW)
6990 + *sd_attrs |= REISERFS_COW_FL;
6992 + *sd_attrs &= ~REISERFS_COW_FL;
6996 @@ -3155,7 +3194,8 @@ int reiserfs_setattr(struct dentry *dent
6999 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7000 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7001 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7002 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7003 struct reiserfs_transaction_handle th;
7006 @@ -3184,6 +3224,9 @@ int reiserfs_setattr(struct dentry *dent
7007 inode->i_uid = attr->ia_uid;
7008 if (attr->ia_valid & ATTR_GID)
7009 inode->i_gid = attr->ia_gid;
7010 + if ((attr->ia_valid & ATTR_TAG) &&
7012 + inode->i_tag = attr->ia_tag;
7013 mark_inode_dirty(inode);
7014 error = journal_end(&th, inode->i_sb, jbegin_count);
7016 diff -NurpP --minimal linux-3.2.8/fs/reiserfs/ioctl.c linux-3.2.8-vs2.3.2.7/fs/reiserfs/ioctl.c
7017 --- linux-3.2.8/fs/reiserfs/ioctl.c 2011-05-22 16:17:53.000000000 +0200
7018 +++ linux-3.2.8-vs2.3.2.7/fs/reiserfs/ioctl.c 2011-12-05 19:33:02.000000000 +0100
7020 #include <linux/pagemap.h>
7021 #include <linux/compat.h>
7024 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7026 + __u16 sd_attrs = 0;
7028 + inode->i_flags = flags;
7029 + inode->i_vflags = vflags;
7031 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7032 + REISERFS_I(inode)->i_attrs = sd_attrs;
7033 + inode->i_ctime = CURRENT_TIME_SEC;
7034 + mark_inode_dirty(inode);
7039 * reiserfs_ioctl - handler for ioctl for inode
7040 * supported commands:
7042 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7044 struct inode *inode = filp->f_path.dentry->d_inode;
7045 - unsigned int flags;
7046 + unsigned int flags, oldflags;
7049 reiserfs_write_lock(inode->i_sb);
7050 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7052 flags = REISERFS_I(inode)->i_attrs;
7053 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7054 + flags &= REISERFS_FL_USER_VISIBLE;
7055 err = put_user(flags, (int __user *)arg);
7057 case REISERFS_IOC_SETFLAGS:{
7058 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7062 + if (IS_BARRIER(inode)) {
7063 + vxwprintk_task(1, "messing with the barrier.");
7067 * Is it quota file? Do not allow user to mess with it
7069 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7074 + oldflags = REISERFS_I(inode)->i_attrs;
7075 + flags &= REISERFS_FL_USER_MODIFIABLE;
7076 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7077 sd_attrs_to_i_attrs(flags, inode);
7078 REISERFS_I(inode)->i_attrs = flags;
7079 inode->i_ctime = CURRENT_TIME_SEC;
7080 diff -NurpP --minimal linux-3.2.8/fs/reiserfs/namei.c linux-3.2.8-vs2.3.2.7/fs/reiserfs/namei.c
7081 --- linux-3.2.8/fs/reiserfs/namei.c 2012-01-09 16:14:55.000000000 +0100
7082 +++ linux-3.2.8-vs2.3.2.7/fs/reiserfs/namei.c 2011-12-05 19:33:02.000000000 +0100
7084 #include <linux/reiserfs_acl.h>
7085 #include <linux/reiserfs_xattr.h>
7086 #include <linux/quotaops.h>
7087 +#include <linux/vs_tag.h>
7089 #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); }
7090 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7091 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7092 if (retval == IO_ERROR) {
7093 return ERR_PTR(-EIO);
7095 + dx_propagate_tag(nd, inode);
7097 return d_splice_alias(inode, dentry);
7099 diff -NurpP --minimal linux-3.2.8/fs/reiserfs/super.c linux-3.2.8-vs2.3.2.7/fs/reiserfs/super.c
7100 --- linux-3.2.8/fs/reiserfs/super.c 2012-02-28 05:53:29.000000000 +0100
7101 +++ linux-3.2.8-vs2.3.2.7/fs/reiserfs/super.c 2012-01-18 02:58:07.000000000 +0100
7102 @@ -903,6 +903,14 @@ static int reiserfs_parse_options(struct
7103 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7104 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7106 +#ifndef CONFIG_TAGGING_NONE
7107 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7108 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7109 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7111 +#ifdef CONFIG_PROPAGATE
7112 + {"tag",.arg_required = 'T',.values = NULL},
7114 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7115 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7116 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7117 @@ -1213,6 +1221,14 @@ static int reiserfs_remount(struct super
7118 handle_quota_files(s, qf_names, &qfmt);
7121 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7122 + !(s->s_flags & MS_TAGGED)) {
7123 + reiserfs_warning(s, "super-vs01",
7124 + "reiserfs: tagging not permitted on remount.");
7131 /* Add options that are safe here */
7132 @@ -1696,6 +1712,10 @@ static int reiserfs_fill_super(struct su
7136 + /* map mount option tagxid */
7137 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7138 + s->s_flags |= MS_TAGGED;
7140 rs = SB_DISK_SUPER_BLOCK(s);
7141 /* Let's do basic sanity check to verify that underlying device is not
7142 smaller than the filesystem. If the check fails then abort and scream,
7143 diff -NurpP --minimal linux-3.2.8/fs/reiserfs/xattr.c linux-3.2.8-vs2.3.2.7/fs/reiserfs/xattr.c
7144 --- linux-3.2.8/fs/reiserfs/xattr.c 2011-10-24 18:45:27.000000000 +0200
7145 +++ linux-3.2.8-vs2.3.2.7/fs/reiserfs/xattr.c 2011-12-05 19:33:02.000000000 +0100
7147 #include <linux/errno.h>
7148 #include <linux/gfp.h>
7149 #include <linux/fs.h>
7150 +#include <linux/mount.h>
7151 #include <linux/file.h>
7152 #include <linux/pagemap.h>
7153 #include <linux/xattr.h>
7154 diff -NurpP --minimal linux-3.2.8/fs/stat.c linux-3.2.8-vs2.3.2.7/fs/stat.c
7155 --- linux-3.2.8/fs/stat.c 2012-01-09 16:14:55.000000000 +0100
7156 +++ linux-3.2.8-vs2.3.2.7/fs/stat.c 2011-12-05 19:33:02.000000000 +0100
7157 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7158 stat->nlink = inode->i_nlink;
7159 stat->uid = inode->i_uid;
7160 stat->gid = inode->i_gid;
7161 + stat->tag = inode->i_tag;
7162 stat->rdev = inode->i_rdev;
7163 stat->size = i_size_read(inode);
7164 stat->atime = inode->i_atime;
7165 diff -NurpP --minimal linux-3.2.8/fs/statfs.c linux-3.2.8-vs2.3.2.7/fs/statfs.c
7166 --- linux-3.2.8/fs/statfs.c 2012-01-09 16:14:55.000000000 +0100
7167 +++ linux-3.2.8-vs2.3.2.7/fs/statfs.c 2011-12-05 19:33:02.000000000 +0100
7169 #include <linux/statfs.h>
7170 #include <linux/security.h>
7171 #include <linux/uaccess.h>
7172 +#include <linux/vs_base.h>
7173 +#include <linux/vs_dlimit.h>
7175 static int flags_by_mnt(int mnt_flags)
7177 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
7178 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7179 if (retval == 0 && buf->f_frsize == 0)
7180 buf->f_frsize = buf->f_bsize;
7181 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7182 + vx_vsi_statfs(dentry->d_sb, buf);
7186 diff -NurpP --minimal linux-3.2.8/fs/super.c linux-3.2.8-vs2.3.2.7/fs/super.c
7187 --- linux-3.2.8/fs/super.c 2012-01-09 16:14:55.000000000 +0100
7188 +++ linux-3.2.8-vs2.3.2.7/fs/super.c 2011-12-05 19:33:02.000000000 +0100
7190 #include <linux/backing-dev.h>
7191 #include <linux/rculist_bl.h>
7192 #include <linux/cleancache.h>
7193 +#include <linux/devpts_fs.h>
7194 +#include <linux/proc_fs.h>
7195 +#include <linux/vs_context.h>
7196 #include "internal.h"
7199 @@ -1100,6 +1103,13 @@ mount_fs(struct file_system_type *type,
7200 WARN_ON(sb->s_bdi == &default_backing_dev_info);
7201 sb->s_flags |= MS_BORN;
7204 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
7206 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7207 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7210 error = security_sb_kern_mount(sb, flags, secdata);
7213 diff -NurpP --minimal linux-3.2.8/fs/sysfs/mount.c linux-3.2.8-vs2.3.2.7/fs/sysfs/mount.c
7214 --- linux-3.2.8/fs/sysfs/mount.c 2011-07-22 11:18:06.000000000 +0200
7215 +++ linux-3.2.8-vs2.3.2.7/fs/sysfs/mount.c 2011-12-05 19:33:02.000000000 +0100
7216 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7218 sb->s_blocksize = PAGE_CACHE_SIZE;
7219 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7220 - sb->s_magic = SYSFS_MAGIC;
7221 + sb->s_magic = SYSFS_SUPER_MAGIC;
7222 sb->s_op = &sysfs_ops;
7223 sb->s_time_gran = 1;
7225 diff -NurpP --minimal linux-3.2.8/fs/utimes.c linux-3.2.8-vs2.3.2.7/fs/utimes.c
7226 --- linux-3.2.8/fs/utimes.c 2011-05-22 16:17:54.000000000 +0200
7227 +++ linux-3.2.8-vs2.3.2.7/fs/utimes.c 2011-12-05 19:33:02.000000000 +0100
7229 #include <linux/stat.h>
7230 #include <linux/utime.h>
7231 #include <linux/syscalls.h>
7232 +#include <linux/mount.h>
7233 +#include <linux/vs_cowbl.h>
7234 #include <asm/uaccess.h>
7235 #include <asm/unistd.h>
7237 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7240 struct iattr newattrs;
7241 - struct inode *inode = path->dentry->d_inode;
7242 + struct inode *inode;
7244 error = mnt_want_write(path->mnt);
7248 + error = cow_check_and_break(path);
7250 + goto mnt_drop_write_and_out;
7252 + inode = path->dentry->d_inode;
7254 if (times && times[0].tv_nsec == UTIME_NOW &&
7255 times[1].tv_nsec == UTIME_NOW)
7257 diff -NurpP --minimal linux-3.2.8/fs/xattr.c linux-3.2.8-vs2.3.2.7/fs/xattr.c
7258 --- linux-3.2.8/fs/xattr.c 2012-01-09 16:14:55.000000000 +0100
7259 +++ linux-3.2.8-vs2.3.2.7/fs/xattr.c 2011-12-05 19:33:02.000000000 +0100
7261 #include <linux/module.h>
7262 #include <linux/fsnotify.h>
7263 #include <linux/audit.h>
7264 +#include <linux/mount.h>
7265 #include <asm/uaccess.h>
7268 @@ -50,7 +51,7 @@ xattr_permission(struct inode *inode, co
7269 * The trusted.* namespace can only be accessed by privileged users.
7271 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
7272 - if (!capable(CAP_SYS_ADMIN))
7273 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
7274 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
7277 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_dinode.h linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_dinode.h
7278 --- linux-3.2.8/fs/xfs/xfs_dinode.h 2011-10-24 18:45:31.000000000 +0200
7279 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_dinode.h 2011-12-05 19:33:02.000000000 +0100
7280 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
7281 __be32 di_nlink; /* number of links to file */
7282 __be16 di_projid_lo; /* lower part of owner's project id */
7283 __be16 di_projid_hi; /* higher part owner's project id */
7284 - __u8 di_pad[6]; /* unused, zeroed space */
7285 + __u8 di_pad[2]; /* unused, zeroed space */
7286 + __be16 di_tag; /* context tagging */
7287 + __be16 di_vflags; /* vserver specific flags */
7288 __be16 di_flushiter; /* incremented on flush */
7289 xfs_timestamp_t di_atime; /* time last accessed */
7290 xfs_timestamp_t di_mtime; /* time last modified */
7291 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
7292 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7293 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7294 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7295 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7297 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7298 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7299 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7300 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
7301 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7302 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7303 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7304 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7306 #ifdef CONFIG_XFS_RT
7307 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7308 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
7309 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7310 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7311 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7312 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7313 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7314 + XFS_DIFLAG_IXUNLINK)
7316 +#define XFS_DIVFLAG_BARRIER 0x01
7317 +#define XFS_DIVFLAG_COW 0x02
7319 #endif /* __XFS_DINODE_H__ */
7320 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_fs.h linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_fs.h
7321 --- linux-3.2.8/fs/xfs/xfs_fs.h 2011-10-24 18:45:31.000000000 +0200
7322 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_fs.h 2011-12-05 19:33:02.000000000 +0100
7323 @@ -67,6 +67,9 @@ struct fsxattr {
7324 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
7325 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
7326 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
7327 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
7328 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
7329 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
7330 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
7333 @@ -302,7 +305,8 @@ typedef struct xfs_bstat {
7334 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
7335 __u16 bs_forkoff; /* inode fork offset in bytes */
7336 __u16 bs_projid_hi; /* higher part of project id */
7337 - unsigned char bs_pad[10]; /* pad space, unused */
7338 + unsigned char bs_pad[8]; /* pad space, unused */
7339 + __u16 bs_tag; /* context tagging */
7340 __u32 bs_dmevmask; /* DMIG event mask */
7341 __u16 bs_dmstate; /* DMIG state info */
7342 __u16 bs_aextents; /* attribute number of extents */
7343 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_ialloc.c linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_ialloc.c
7344 --- linux-3.2.8/fs/xfs/xfs_ialloc.c 2012-01-09 16:14:55.000000000 +0100
7345 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_ialloc.c 2011-12-05 19:33:02.000000000 +0100
7347 #include "xfs_error.h"
7348 #include "xfs_bmap.h"
7352 * Allocation group level functions.
7354 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_inode.c linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_inode.c
7355 --- linux-3.2.8/fs/xfs/xfs_inode.c 2012-01-09 16:14:55.000000000 +0100
7356 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_inode.c 2011-12-15 01:11:32.000000000 +0100
7357 @@ -236,6 +236,7 @@ xfs_inotobp(
7361 +#include <linux/vs_tag.h>
7364 * This routine is called to map an inode to the buffer containing
7365 @@ -634,15 +635,25 @@ xfs_iformat_btree(
7367 xfs_dinode_from_disk(
7369 - xfs_dinode_t *from)
7370 + xfs_dinode_t *from,
7373 + uint32_t uid, gid, tag;
7375 to->di_magic = be16_to_cpu(from->di_magic);
7376 to->di_mode = be16_to_cpu(from->di_mode);
7377 to->di_version = from ->di_version;
7378 to->di_format = from->di_format;
7379 to->di_onlink = be16_to_cpu(from->di_onlink);
7380 - to->di_uid = be32_to_cpu(from->di_uid);
7381 - to->di_gid = be32_to_cpu(from->di_gid);
7383 + uid = be32_to_cpu(from->di_uid);
7384 + gid = be32_to_cpu(from->di_gid);
7385 + tag = be16_to_cpu(from->di_tag);
7387 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7388 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7389 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7391 to->di_nlink = be32_to_cpu(from->di_nlink);
7392 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7393 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7394 @@ -664,21 +675,26 @@ xfs_dinode_from_disk(
7395 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7396 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7397 to->di_flags = be16_to_cpu(from->di_flags);
7398 + to->di_vflags = be16_to_cpu(from->di_vflags);
7399 to->di_gen = be32_to_cpu(from->di_gen);
7405 - xfs_icdinode_t *from)
7406 + xfs_icdinode_t *from,
7409 to->di_magic = cpu_to_be16(from->di_magic);
7410 to->di_mode = cpu_to_be16(from->di_mode);
7411 to->di_version = from ->di_version;
7412 to->di_format = from->di_format;
7413 to->di_onlink = cpu_to_be16(from->di_onlink);
7414 - to->di_uid = cpu_to_be32(from->di_uid);
7415 - to->di_gid = cpu_to_be32(from->di_gid);
7417 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
7418 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
7419 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
7421 to->di_nlink = cpu_to_be32(from->di_nlink);
7422 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
7423 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
7424 @@ -700,12 +716,14 @@ xfs_dinode_to_disk(
7425 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
7426 to->di_dmstate = cpu_to_be16(from->di_dmstate);
7427 to->di_flags = cpu_to_be16(from->di_flags);
7428 + to->di_vflags = cpu_to_be16(from->di_vflags);
7429 to->di_gen = cpu_to_be32(from->di_gen);
7434 - __uint16_t di_flags)
7435 + __uint16_t di_flags,
7436 + __uint16_t di_vflags)
7440 @@ -716,6 +734,8 @@ _xfs_dic2xflags(
7441 flags |= XFS_XFLAG_PREALLOC;
7442 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7443 flags |= XFS_XFLAG_IMMUTABLE;
7444 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7445 + flags |= XFS_XFLAG_IXUNLINK;
7446 if (di_flags & XFS_DIFLAG_APPEND)
7447 flags |= XFS_XFLAG_APPEND;
7448 if (di_flags & XFS_DIFLAG_SYNC)
7449 @@ -740,6 +760,10 @@ _xfs_dic2xflags(
7450 flags |= XFS_XFLAG_FILESTREAM;
7453 + if (di_vflags & XFS_DIVFLAG_BARRIER)
7454 + flags |= FS_BARRIER_FL;
7455 + if (di_vflags & XFS_DIVFLAG_COW)
7456 + flags |= FS_COW_FL;
7460 @@ -749,7 +773,7 @@ xfs_ip2xflags(
7462 xfs_icdinode_t *dic = &ip->i_d;
7464 - return _xfs_dic2xflags(dic->di_flags) |
7465 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
7466 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
7469 @@ -757,7 +781,8 @@ uint
7473 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
7474 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
7475 + be16_to_cpu(dip->di_vflags)) |
7476 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
7479 @@ -790,7 +815,6 @@ xfs_iread(
7482 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
7485 * If we got something that isn't an inode it means someone
7486 * (nfs or dmi) has a stale handle.
7487 @@ -813,7 +837,8 @@ xfs_iread(
7488 * Otherwise, just get the truly permanent information.
7491 - xfs_dinode_from_disk(&ip->i_d, dip);
7492 + xfs_dinode_from_disk(&ip->i_d, dip,
7493 + mp->m_flags & XFS_MOUNT_TAGGED);
7494 error = xfs_iformat(ip, dip);
7497 @@ -1008,6 +1033,7 @@ xfs_ialloc(
7498 ASSERT(ip->i_d.di_nlink == nlink);
7499 ip->i_d.di_uid = current_fsuid();
7500 ip->i_d.di_gid = current_fsgid();
7501 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
7502 xfs_set_projid(ip, prid);
7503 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
7505 @@ -1068,6 +1094,7 @@ xfs_ialloc(
7506 ip->i_d.di_dmevmask = 0;
7507 ip->i_d.di_dmstate = 0;
7508 ip->i_d.di_flags = 0;
7509 + ip->i_d.di_vflags = 0;
7510 flags = XFS_ILOG_CORE;
7511 switch (mode & S_IFMT) {
7513 @@ -1842,6 +1869,7 @@ xfs_ifree(
7515 ip->i_d.di_mode = 0; /* mark incore inode as free */
7516 ip->i_d.di_flags = 0;
7517 + ip->i_d.di_vflags = 0;
7518 ip->i_d.di_dmevmask = 0;
7519 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
7520 ip->i_df.if_ext_max =
7521 @@ -2723,7 +2751,8 @@ xfs_iflush_int(
7522 * because if the inode is dirty at all the core must
7525 - xfs_dinode_to_disk(dip, &ip->i_d);
7526 + xfs_dinode_to_disk(dip, &ip->i_d,
7527 + mp->m_flags & XFS_MOUNT_TAGGED);
7529 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7530 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7531 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_inode.h linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_inode.h
7532 --- linux-3.2.8/fs/xfs/xfs_inode.h 2012-01-09 16:14:55.000000000 +0100
7533 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_inode.h 2011-12-15 01:11:32.000000000 +0100
7534 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
7535 __uint32_t di_nlink; /* number of links to file */
7536 __uint16_t di_projid_lo; /* lower part of owner's project id */
7537 __uint16_t di_projid_hi; /* higher part of owner's project id */
7538 - __uint8_t di_pad[6]; /* unused, zeroed space */
7539 + __uint8_t di_pad[2]; /* unused, zeroed space */
7540 + __uint16_t di_tag; /* context tagging */
7541 + __uint16_t di_vflags; /* vserver specific flags */
7542 __uint16_t di_flushiter; /* incremented on flush */
7543 xfs_ictimestamp_t di_atime; /* time last accessed */
7544 xfs_ictimestamp_t di_mtime; /* time last modified */
7545 @@ -536,7 +538,7 @@ int xfs_itobp(struct xfs_mount *, struc
7546 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
7547 struct xfs_inode *, uint);
7548 void xfs_dinode_to_disk(struct xfs_dinode *,
7549 - struct xfs_icdinode *);
7550 + struct xfs_icdinode *, int);
7551 void xfs_idestroy_fork(struct xfs_inode *, int);
7552 void xfs_idata_realloc(struct xfs_inode *, int, int);
7553 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7554 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_ioctl.c linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_ioctl.c
7555 --- linux-3.2.8/fs/xfs/xfs_ioctl.c 2012-01-09 16:14:55.000000000 +0100
7556 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_ioctl.c 2011-12-05 19:33:02.000000000 +0100
7558 #include "xfs_bmap_btree.h"
7559 #include "xfs_dinode.h"
7560 #include "xfs_inode.h"
7561 -#include "xfs_ioctl.h"
7562 +// #include "xfs_ioctl.h"
7563 #include "xfs_rtalloc.h"
7564 #include "xfs_itable.h"
7565 #include "xfs_error.h"
7566 @@ -748,6 +748,10 @@ xfs_merge_ioc_xflags(
7567 xflags |= XFS_XFLAG_IMMUTABLE;
7569 xflags &= ~XFS_XFLAG_IMMUTABLE;
7570 + if (flags & FS_IXUNLINK_FL)
7571 + xflags |= XFS_XFLAG_IXUNLINK;
7573 + xflags &= ~XFS_XFLAG_IXUNLINK;
7574 if (flags & FS_APPEND_FL)
7575 xflags |= XFS_XFLAG_APPEND;
7577 @@ -776,6 +780,8 @@ xfs_di2lxflags(
7579 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7580 flags |= FS_IMMUTABLE_FL;
7581 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7582 + flags |= FS_IXUNLINK_FL;
7583 if (di_flags & XFS_DIFLAG_APPEND)
7584 flags |= FS_APPEND_FL;
7585 if (di_flags & XFS_DIFLAG_SYNC)
7586 @@ -836,6 +842,8 @@ xfs_set_diflags(
7587 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7588 if (xflags & XFS_XFLAG_IMMUTABLE)
7589 di_flags |= XFS_DIFLAG_IMMUTABLE;
7590 + if (xflags & XFS_XFLAG_IXUNLINK)
7591 + di_flags |= XFS_DIFLAG_IXUNLINK;
7592 if (xflags & XFS_XFLAG_APPEND)
7593 di_flags |= XFS_DIFLAG_APPEND;
7594 if (xflags & XFS_XFLAG_SYNC)
7595 @@ -878,6 +886,10 @@ xfs_diflags_to_linux(
7596 inode->i_flags |= S_IMMUTABLE;
7598 inode->i_flags &= ~S_IMMUTABLE;
7599 + if (xflags & XFS_XFLAG_IXUNLINK)
7600 + inode->i_flags |= S_IXUNLINK;
7602 + inode->i_flags &= ~S_IXUNLINK;
7603 if (xflags & XFS_XFLAG_APPEND)
7604 inode->i_flags |= S_APPEND;
7606 @@ -1370,10 +1382,18 @@ xfs_file_ioctl(
7607 case XFS_IOC_FSGETXATTRA:
7608 return xfs_ioc_fsgetxattr(ip, 1, arg);
7609 case XFS_IOC_FSSETXATTR:
7610 + if (IS_BARRIER(inode)) {
7611 + vxwprintk_task(1, "messing with the barrier.");
7612 + return -XFS_ERROR(EACCES);
7614 return xfs_ioc_fssetxattr(ip, filp, arg);
7615 case XFS_IOC_GETXFLAGS:
7616 return xfs_ioc_getxflags(ip, arg);
7617 case XFS_IOC_SETXFLAGS:
7618 + if (IS_BARRIER(inode)) {
7619 + vxwprintk_task(1, "messing with the barrier.");
7620 + return -XFS_ERROR(EACCES);
7622 return xfs_ioc_setxflags(ip, filp, arg);
7624 case XFS_IOC_FSSETDM: {
7625 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_ioctl.h linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_ioctl.h
7626 --- linux-3.2.8/fs/xfs/xfs_ioctl.h 2011-10-24 18:45:31.000000000 +0200
7627 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_ioctl.h 2011-12-05 19:33:02.000000000 +0100
7628 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7629 void __user *uhandle,
7634 + struct inode *inode,
7641 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_iops.c linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_iops.c
7642 --- linux-3.2.8/fs/xfs/xfs_iops.c 2012-01-09 16:14:55.000000000 +0100
7643 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_iops.c 2011-12-05 19:33:02.000000000 +0100
7645 #include "xfs_bmap_btree.h"
7646 #include "xfs_dinode.h"
7647 #include "xfs_inode.h"
7648 +#include "xfs_ioctl.h"
7649 #include "xfs_bmap.h"
7650 #include "xfs_rtalloc.h"
7651 #include "xfs_error.h"
7653 #include <linux/security.h>
7654 #include <linux/fiemap.h>
7655 #include <linux/slab.h>
7656 +#include <linux/vs_tag.h>
7659 * Bring the timestamps in the XFS inode uptodate.
7660 @@ -474,6 +476,7 @@ xfs_vn_getattr(
7661 stat->nlink = ip->i_d.di_nlink;
7662 stat->uid = ip->i_d.di_uid;
7663 stat->gid = ip->i_d.di_gid;
7664 + stat->tag = ip->i_d.di_tag;
7665 stat->ino = ip->i_ino;
7666 stat->atime = inode->i_atime;
7667 stat->mtime = inode->i_mtime;
7668 @@ -1039,6 +1042,7 @@ static const struct inode_operations xfs
7669 .removexattr = generic_removexattr,
7670 .listxattr = xfs_vn_listxattr,
7671 .fiemap = xfs_vn_fiemap,
7672 + .sync_flags = xfs_sync_flags,
7675 static const struct inode_operations xfs_dir_inode_operations = {
7676 @@ -1064,6 +1068,7 @@ static const struct inode_operations xfs
7677 .getxattr = generic_getxattr,
7678 .removexattr = generic_removexattr,
7679 .listxattr = xfs_vn_listxattr,
7680 + .sync_flags = xfs_sync_flags,
7683 static const struct inode_operations xfs_dir_ci_inode_operations = {
7684 @@ -1113,6 +1118,10 @@ xfs_diflags_to_iflags(
7685 inode->i_flags |= S_IMMUTABLE;
7687 inode->i_flags &= ~S_IMMUTABLE;
7688 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7689 + inode->i_flags |= S_IXUNLINK;
7691 + inode->i_flags &= ~S_IXUNLINK;
7692 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7693 inode->i_flags |= S_APPEND;
7695 @@ -1125,6 +1134,15 @@ xfs_diflags_to_iflags(
7696 inode->i_flags |= S_NOATIME;
7698 inode->i_flags &= ~S_NOATIME;
7700 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7701 + inode->i_vflags |= V_BARRIER;
7703 + inode->i_vflags &= ~V_BARRIER;
7704 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7705 + inode->i_vflags |= V_COW;
7707 + inode->i_vflags &= ~V_COW;
7711 @@ -1156,6 +1174,7 @@ xfs_setup_inode(
7712 set_nlink(inode, ip->i_d.di_nlink);
7713 inode->i_uid = ip->i_d.di_uid;
7714 inode->i_gid = ip->i_d.di_gid;
7715 + inode->i_tag = ip->i_d.di_tag;
7717 switch (inode->i_mode & S_IFMT) {
7719 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_itable.c linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_itable.c
7720 --- linux-3.2.8/fs/xfs/xfs_itable.c 2011-05-22 16:17:54.000000000 +0200
7721 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_itable.c 2011-12-05 19:33:02.000000000 +0100
7722 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
7723 buf->bs_mode = dic->di_mode;
7724 buf->bs_uid = dic->di_uid;
7725 buf->bs_gid = dic->di_gid;
7726 + buf->bs_tag = dic->di_tag;
7727 buf->bs_size = dic->di_size;
7730 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_linux.h linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_linux.h
7731 --- linux-3.2.8/fs/xfs/xfs_linux.h 2011-10-24 18:45:31.000000000 +0200
7732 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_linux.h 2011-12-05 19:33:02.000000000 +0100
7735 #define current_cpu() (raw_smp_processor_id())
7736 #define current_pid() (current->pid)
7737 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7738 #define current_test_flags(f) (current->flags & (f))
7739 #define current_set_flags_nested(sp, f) \
7740 (*(sp) = current->flags, current->flags |= (f))
7741 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_log_recover.c linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_log_recover.c
7742 --- linux-3.2.8/fs/xfs/xfs_log_recover.c 2012-01-09 16:14:55.000000000 +0100
7743 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_log_recover.c 2011-12-05 19:33:02.000000000 +0100
7744 @@ -2344,7 +2344,8 @@ xlog_recover_inode_pass2(
7747 /* The core is in in-core format */
7748 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
7749 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
7750 + mp->m_flags & XFS_MOUNT_TAGGED);
7752 /* the rest is in on-disk format */
7753 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
7754 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_mount.h linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_mount.h
7755 --- linux-3.2.8/fs/xfs/xfs_mount.h 2011-10-24 18:45:31.000000000 +0200
7756 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_mount.h 2011-12-05 19:33:02.000000000 +0100
7757 @@ -249,6 +249,7 @@ typedef struct xfs_mount {
7759 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7761 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7764 * Default minimum read and write sizes.
7765 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_super.c linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_super.c
7766 --- linux-3.2.8/fs/xfs/xfs_super.c 2012-01-09 16:14:55.000000000 +0100
7767 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_super.c 2012-01-09 16:19:31.000000000 +0100
7768 @@ -113,6 +113,9 @@ mempool_t *xfs_ioend_pool;
7769 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7770 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7771 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7772 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7773 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7774 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7777 * Table driven mount option parser.
7778 @@ -121,10 +124,14 @@ mempool_t *xfs_ioend_pool;
7779 * in the future, too.
7782 + Opt_tag, Opt_notag,
7783 Opt_barrier, Opt_nobarrier, Opt_err
7786 static const match_table_t tokens = {
7787 + {Opt_tag, "tagxid"},
7789 + {Opt_notag, "notag"},
7790 {Opt_barrier, "barrier"},
7791 {Opt_nobarrier, "nobarrier"},
7793 @@ -374,6 +381,19 @@ xfs_parseargs(
7794 } else if (!strcmp(this_char, "irixsgid")) {
7796 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7797 +#ifndef CONFIG_TAGGING_NONE
7798 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7799 + mp->m_flags |= XFS_MOUNT_TAGGED;
7800 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7801 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7802 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7803 + mp->m_flags |= XFS_MOUNT_TAGGED;
7805 +#ifdef CONFIG_PROPAGATE
7806 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7808 + mp->m_flags |= XFS_MOUNT_TAGGED;
7811 xfs_warn(mp, "unknown mount option [%s].", this_char);
7813 @@ -1138,6 +1158,16 @@ xfs_fs_remount(
7815 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7818 + if (!(sb->s_flags & MS_TAGGED)) {
7820 + "XFS: %s: tagging not permitted on remount.\n",
7829 * Logically we would return an error here to prevent
7830 @@ -1353,6 +1383,9 @@ xfs_fs_fill_super(
7834 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7835 + sb->s_flags |= MS_TAGGED;
7838 * we must configure the block size in the superblock before we run the
7839 * full mount process as the mount process can lookup and cache inodes.
7840 diff -NurpP --minimal linux-3.2.8/fs/xfs/xfs_vnodeops.c linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_vnodeops.c
7841 --- linux-3.2.8/fs/xfs/xfs_vnodeops.c 2012-02-28 05:53:29.000000000 +0100
7842 +++ linux-3.2.8-vs2.3.2.7/fs/xfs/xfs_vnodeops.c 2012-02-07 03:14:01.000000000 +0100
7843 @@ -106,6 +106,77 @@ xfs_readlink_bmap(
7849 +xfs_get_inode_flags(
7852 + struct inode *inode = VFS_I(ip);
7853 + unsigned int flags = inode->i_flags;
7854 + unsigned int vflags = inode->i_vflags;
7856 + if (flags & S_IMMUTABLE)
7857 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7859 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7860 + if (flags & S_IXUNLINK)
7861 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
7863 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
7865 + if (vflags & V_BARRIER)
7866 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
7868 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
7869 + if (vflags & V_COW)
7870 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
7872 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
7877 + struct inode *inode,
7881 + struct xfs_inode *ip = XFS_I(inode);
7882 + struct xfs_mount *mp = ip->i_mount;
7883 + struct xfs_trans *tp;
7884 + unsigned int lock_flags = 0;
7887 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
7888 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
7892 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7893 + xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
7895 + inode->i_flags = flags;
7896 + inode->i_vflags = vflags;
7897 + xfs_get_inode_flags(ip);
7899 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
7900 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
7902 + XFS_STATS_INC(xs_ig_attrchg);
7904 + if (mp->m_flags & XFS_MOUNT_WSYNC)
7905 + xfs_trans_set_sync(tp);
7906 + code = xfs_trans_commit(tp, 0);
7907 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7911 + xfs_trans_cancel(tp, 0);
7913 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7921 diff -NurpP --minimal linux-3.2.8/include/linux/Kbuild linux-3.2.8-vs2.3.2.7/include/linux/Kbuild
7922 --- linux-3.2.8/include/linux/Kbuild 2011-10-24 18:45:31.000000000 +0200
7923 +++ linux-3.2.8-vs2.3.2.7/include/linux/Kbuild 2011-12-05 19:33:02.000000000 +0100
7924 @@ -17,6 +17,7 @@ header-y += netfilter_bridge/
7925 header-y += netfilter_ipv4/
7926 header-y += netfilter_ipv6/
7928 +header-y += vserver/
7931 objhdr-y += version.h
7932 diff -NurpP --minimal linux-3.2.8/include/linux/capability.h linux-3.2.8-vs2.3.2.7/include/linux/capability.h
7933 --- linux-3.2.8/include/linux/capability.h 2012-01-09 16:14:56.000000000 +0100
7934 +++ linux-3.2.8-vs2.3.2.7/include/linux/capability.h 2011-12-05 19:33:02.000000000 +0100
7935 @@ -280,6 +280,7 @@ struct cpu_vfs_cap_data {
7936 arbitrary SCSI commands */
7937 /* Allow setting encryption key on loopback filesystem */
7938 /* Allow setting zone reclaim policy */
7939 +/* Allow the selection of a security context */
7941 #define CAP_SYS_ADMIN 21
7943 @@ -363,7 +364,12 @@ struct cpu_vfs_cap_data {
7945 #define CAP_LAST_CAP CAP_WAKE_ALARM
7947 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
7948 +/* Allow context manipulations */
7949 +/* Allow changing context info on files */
7951 +#define CAP_CONTEXT 63
7953 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
7956 * Bit location of each capability (used by user-space library and kernel)
7957 diff -NurpP --minimal linux-3.2.8/include/linux/cred.h linux-3.2.8-vs2.3.2.7/include/linux/cred.h
7958 --- linux-3.2.8/include/linux/cred.h 2011-10-24 18:45:31.000000000 +0200
7959 +++ linux-3.2.8-vs2.3.2.7/include/linux/cred.h 2011-12-05 19:33:02.000000000 +0100
7960 @@ -156,6 +156,7 @@ extern void exit_creds(struct task_struc
7961 extern int copy_creds(struct task_struct *, unsigned long);
7962 extern const struct cred *get_task_cred(struct task_struct *);
7963 extern struct cred *cred_alloc_blank(void);
7964 +extern struct cred *__prepare_creds(const struct cred *);
7965 extern struct cred *prepare_creds(void);
7966 extern struct cred *prepare_exec_creds(void);
7967 extern int commit_creds(struct cred *);
7968 @@ -209,6 +210,31 @@ static inline void validate_process_cred
7972 +static inline void set_cred_subscribers(struct cred *cred, int n)
7974 +#ifdef CONFIG_DEBUG_CREDENTIALS
7975 + atomic_set(&cred->subscribers, n);
7979 +static inline int read_cred_subscribers(const struct cred *cred)
7981 +#ifdef CONFIG_DEBUG_CREDENTIALS
7982 + return atomic_read(&cred->subscribers);
7988 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
7990 +#ifdef CONFIG_DEBUG_CREDENTIALS
7991 + struct cred *cred = (struct cred *) _cred;
7993 + atomic_add(n, &cred->subscribers);
7998 * get_new_cred - Get a reference on a new set of credentials
7999 * @cred: The new credentials to reference
8000 diff -NurpP --minimal linux-3.2.8/include/linux/devpts_fs.h linux-3.2.8-vs2.3.2.7/include/linux/devpts_fs.h
8001 --- linux-3.2.8/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8002 +++ linux-3.2.8-vs2.3.2.7/include/linux/devpts_fs.h 2011-12-05 19:33:02.000000000 +0100
8003 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8008 #endif /* _LINUX_DEVPTS_FS_H */
8009 diff -NurpP --minimal linux-3.2.8/include/linux/ext2_fs.h linux-3.2.8-vs2.3.2.7/include/linux/ext2_fs.h
8010 --- linux-3.2.8/include/linux/ext2_fs.h 2012-01-09 16:14:56.000000000 +0100
8011 +++ linux-3.2.8-vs2.3.2.7/include/linux/ext2_fs.h 2011-12-05 19:33:02.000000000 +0100
8012 @@ -190,8 +190,12 @@ struct ext2_group_desc
8013 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8014 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8015 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8016 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8017 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8019 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8020 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8022 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8023 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8025 @@ -275,7 +279,8 @@ struct ext2_inode {
8027 __le16 l_i_uid_high; /* these 2 fields */
8028 __le16 l_i_gid_high; /* were reserved2[0] */
8029 - __u32 l_i_reserved2;
8030 + __le16 l_i_tag; /* Context Tag */
8031 + __u16 l_i_reserved2;
8034 __u8 h_i_frag; /* Fragment number */
8035 @@ -304,6 +309,7 @@ struct ext2_inode {
8036 #define i_gid_low i_gid
8037 #define i_uid_high osd2.linux2.l_i_uid_high
8038 #define i_gid_high osd2.linux2.l_i_gid_high
8039 +#define i_raw_tag osd2.linux2.l_i_tag
8040 #define i_reserved2 osd2.linux2.l_i_reserved2
8043 @@ -348,6 +354,7 @@ struct ext2_inode {
8044 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8045 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8046 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8047 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8050 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8051 diff -NurpP --minimal linux-3.2.8/include/linux/ext3_fs.h linux-3.2.8-vs2.3.2.7/include/linux/ext3_fs.h
8052 --- linux-3.2.8/include/linux/ext3_fs.h 2012-01-09 16:14:56.000000000 +0100
8053 +++ linux-3.2.8-vs2.3.2.7/include/linux/ext3_fs.h 2011-12-05 19:33:02.000000000 +0100
8054 @@ -173,10 +173,14 @@ struct ext3_group_desc
8055 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8056 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8057 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8058 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8059 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8061 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8062 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8063 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8064 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8066 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8067 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8069 /* Flags that should be inherited by new inodes from their parent. */
8070 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8071 @@ -312,7 +316,8 @@ struct ext3_inode {
8073 __le16 l_i_uid_high; /* these 2 fields */
8074 __le16 l_i_gid_high; /* were reserved2[0] */
8075 - __u32 l_i_reserved2;
8076 + __le16 l_i_tag; /* Context Tag */
8077 + __u16 l_i_reserved2;
8080 __u8 h_i_frag; /* Fragment number */
8081 @@ -343,6 +348,7 @@ struct ext3_inode {
8082 #define i_gid_low i_gid
8083 #define i_uid_high osd2.linux2.l_i_uid_high
8084 #define i_gid_high osd2.linux2.l_i_gid_high
8085 +#define i_raw_tag osd2.linux2.l_i_tag
8086 #define i_reserved2 osd2.linux2.l_i_reserved2
8088 #elif defined(__GNU__)
8089 @@ -405,6 +411,7 @@ struct ext3_inode {
8090 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8091 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8092 * error in ordered mode */
8093 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8095 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8096 #ifndef _LINUX_EXT2_FS_H
8097 @@ -918,6 +925,7 @@ extern void ext3_get_inode_flags(struct
8098 extern void ext3_set_aops(struct inode *inode);
8099 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8100 u64 start, u64 len);
8101 +extern int ext3_sync_flags(struct inode *, int, int);
8104 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8105 diff -NurpP --minimal linux-3.2.8/include/linux/fs.h linux-3.2.8-vs2.3.2.7/include/linux/fs.h
8106 --- linux-3.2.8/include/linux/fs.h 2012-01-09 16:14:57.000000000 +0100
8107 +++ linux-3.2.8-vs2.3.2.7/include/linux/fs.h 2011-12-15 01:11:32.000000000 +0100
8108 @@ -210,6 +210,9 @@ struct inodes_stat_t {
8109 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8110 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8111 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8112 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8113 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8114 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8115 #define MS_NOSEC (1<<28)
8116 #define MS_BORN (1<<29)
8117 #define MS_ACTIVE (1<<30)
8118 @@ -241,6 +244,14 @@ struct inodes_stat_t {
8119 #define S_IMA 1024 /* Inode has an associated IMA struct */
8120 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
8121 #define S_NOSEC 4096 /* no suid or xattr security attributes */
8122 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
8124 +/* Linux-VServer related Inode flags */
8128 +#define V_BARRIER 4 /* Barrier for chroot() */
8129 +#define V_COW 8 /* Copy on Write */
8132 * Note that nosuid etc flags are inode-specific: setting some file-system
8133 @@ -263,12 +274,15 @@ struct inodes_stat_t {
8134 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8135 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8136 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8137 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8138 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8139 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8140 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8141 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8143 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8144 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8145 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8146 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8147 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8148 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8150 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8151 @@ -279,6 +293,16 @@ struct inodes_stat_t {
8152 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
8153 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
8155 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8157 +#ifdef CONFIG_VSERVER_COWBL
8158 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8159 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8161 +# define IS_COW(inode) (0)
8162 +# define IS_COW_LINK(inode) (0)
8165 /* the read-only stuff doesn't really belong here, but any other place is
8166 probably as bad and I don't want to create yet another include file. */
8168 @@ -364,11 +388,14 @@ struct inodes_stat_t {
8169 #define FS_EXTENT_FL 0x00080000 /* Extents */
8170 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8171 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
8172 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8173 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8175 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8176 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8177 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8178 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8180 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8181 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8183 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8184 #define SYNC_FILE_RANGE_WRITE 2
8185 @@ -449,6 +476,7 @@ typedef void (dio_iodone_t)(struct kiocb
8186 #define ATTR_KILL_PRIV (1 << 14)
8187 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8188 #define ATTR_TIMES_SET (1 << 16)
8189 +#define ATTR_TAG (1 << 17)
8192 * This is the Inode Attributes structure, used for notify_change(). It
8193 @@ -464,6 +492,7 @@ struct iattr {
8199 struct timespec ia_atime;
8200 struct timespec ia_mtime;
8201 @@ -477,6 +506,9 @@ struct iattr {
8202 struct file *ia_file;
8205 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8206 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8209 * Includes for diskquotas.
8211 @@ -751,7 +783,9 @@ struct inode {
8212 unsigned short i_opflags;
8215 - unsigned int i_flags;
8217 + unsigned short i_flags;
8218 + unsigned short i_vflags;
8220 #ifdef CONFIG_FS_POSIX_ACL
8221 struct posix_acl *i_acl;
8222 @@ -780,6 +814,7 @@ struct inode {
8223 unsigned int __i_nlink;
8227 struct timespec i_atime;
8228 struct timespec i_mtime;
8229 struct timespec i_ctime;
8230 @@ -917,12 +952,12 @@ static inline void i_size_write(struct i
8232 static inline unsigned iminor(const struct inode *inode)
8234 - return MINOR(inode->i_rdev);
8235 + return MINOR(inode->i_mdev);
8238 static inline unsigned imajor(const struct inode *inode)
8240 - return MAJOR(inode->i_rdev);
8241 + return MAJOR(inode->i_mdev);
8244 extern struct block_device *I_BDEV(struct inode *inode);
8245 @@ -989,6 +1024,7 @@ struct file {
8247 struct fown_struct f_owner;
8248 const struct cred *f_cred;
8250 struct file_ra_state f_ra;
8253 @@ -1135,6 +1171,7 @@ struct file_lock {
8254 struct file *fl_file;
8259 struct fasync_struct * fl_fasync; /* for lease break notifications */
8260 /* for lease breaks: */
8261 @@ -1635,6 +1672,7 @@ struct inode_operations {
8262 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8263 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8264 int (*removexattr) (struct dentry *, const char *);
8265 + int (*sync_flags) (struct inode *, int, int);
8266 void (*truncate_range)(struct inode *, loff_t, loff_t);
8267 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8269 @@ -1654,6 +1692,7 @@ extern ssize_t vfs_readv(struct file *,
8270 unsigned long, loff_t *);
8271 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8272 unsigned long, loff_t *);
8273 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8275 struct super_operations {
8276 struct inode *(*alloc_inode)(struct super_block *sb);
8277 @@ -2541,6 +2580,7 @@ extern int dcache_dir_open(struct inode
8278 extern int dcache_dir_close(struct inode *, struct file *);
8279 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8280 extern int dcache_readdir(struct file *, void *, filldir_t);
8281 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8282 extern int simple_setattr(struct dentry *, struct iattr *);
8283 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8284 extern int simple_statfs(struct dentry *, struct kstatfs *);
8285 diff -NurpP --minimal linux-3.2.8/include/linux/gfs2_ondisk.h linux-3.2.8-vs2.3.2.7/include/linux/gfs2_ondisk.h
8286 --- linux-3.2.8/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8287 +++ linux-3.2.8-vs2.3.2.7/include/linux/gfs2_ondisk.h 2011-12-05 19:33:02.000000000 +0100
8288 @@ -211,6 +211,9 @@ enum {
8292 + gfs2fl_IXUnlink = 16,
8293 + gfs2fl_Barrier = 17,
8295 gfs2fl_TruncInProg = 29,
8296 gfs2fl_InheritDirectio = 30,
8297 gfs2fl_InheritJdata = 31,
8298 @@ -227,6 +230,9 @@ enum {
8299 #define GFS2_DIF_NOATIME 0x00000080
8300 #define GFS2_DIF_SYNC 0x00000100
8301 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8302 +#define GFS2_DIF_IXUNLINK 0x00010000
8303 +#define GFS2_DIF_BARRIER 0x00020000
8304 +#define GFS2_DIF_COW 0x00040000
8305 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8306 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8307 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8308 diff -NurpP --minimal linux-3.2.8/include/linux/if_tun.h linux-3.2.8-vs2.3.2.7/include/linux/if_tun.h
8309 --- linux-3.2.8/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8310 +++ linux-3.2.8-vs2.3.2.7/include/linux/if_tun.h 2011-12-05 19:33:02.000000000 +0100
8312 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8313 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8314 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8315 +#define TUNSETNID _IOW('T', 217, int)
8317 /* TUNSETIFF ifr flags */
8318 #define IFF_TUN 0x0001
8319 diff -NurpP --minimal linux-3.2.8/include/linux/init_task.h linux-3.2.8-vs2.3.2.7/include/linux/init_task.h
8320 --- linux-3.2.8/include/linux/init_task.h 2012-01-09 16:14:58.000000000 +0100
8321 +++ linux-3.2.8-vs2.3.2.7/include/linux/init_task.h 2011-12-15 01:11:32.000000000 +0100
8322 @@ -193,6 +193,10 @@ extern struct cred init_cred;
8324 INIT_TRACE_RECURSION \
8325 INIT_TASK_RCU_PREEMPT(tsk) \
8327 + .vx_info = NULL, \
8329 + .nx_info = NULL, \
8333 diff -NurpP --minimal linux-3.2.8/include/linux/ipc.h linux-3.2.8-vs2.3.2.7/include/linux/ipc.h
8334 --- linux-3.2.8/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8335 +++ linux-3.2.8-vs2.3.2.7/include/linux/ipc.h 2011-12-05 19:33:02.000000000 +0100
8336 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8344 diff -NurpP --minimal linux-3.2.8/include/linux/ipc_namespace.h linux-3.2.8-vs2.3.2.7/include/linux/ipc_namespace.h
8345 --- linux-3.2.8/include/linux/ipc_namespace.h 2011-10-24 18:45:32.000000000 +0200
8346 +++ linux-3.2.8-vs2.3.2.7/include/linux/ipc_namespace.h 2011-12-05 19:33:02.000000000 +0100
8347 @@ -101,7 +101,8 @@ static inline int mq_init_ns(struct ipc_
8349 #if defined(CONFIG_IPC_NS)
8350 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
8351 - struct task_struct *tsk);
8352 + struct ipc_namespace *old_ns,
8353 + struct user_namespace *user_ns);
8354 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8357 @@ -112,12 +113,13 @@ static inline struct ipc_namespace *get_
8358 extern void put_ipc_ns(struct ipc_namespace *ns);
8360 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
8361 - struct task_struct *tsk)
8362 + struct ipc_namespace *old_ns,
8363 + struct user_namespace *user_ns)
8365 if (flags & CLONE_NEWIPC)
8366 return ERR_PTR(-EINVAL);
8368 - return tsk->nsproxy->ipc_ns;
8372 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8373 diff -NurpP --minimal linux-3.2.8/include/linux/loop.h linux-3.2.8-vs2.3.2.7/include/linux/loop.h
8374 --- linux-3.2.8/include/linux/loop.h 2012-01-09 16:14:58.000000000 +0100
8375 +++ linux-3.2.8-vs2.3.2.7/include/linux/loop.h 2011-12-05 19:33:02.000000000 +0100
8376 @@ -45,6 +45,7 @@ struct loop_device {
8377 struct loop_func_table *lo_encryption;
8379 uid_t lo_key_owner; /* Who set the key */
8381 int (*ioctl)(struct loop_device *, int cmd,
8384 diff -NurpP --minimal linux-3.2.8/include/linux/magic.h linux-3.2.8-vs2.3.2.7/include/linux/magic.h
8385 --- linux-3.2.8/include/linux/magic.h 2012-01-09 16:14:58.000000000 +0100
8386 +++ linux-3.2.8-vs2.3.2.7/include/linux/magic.h 2011-12-05 19:33:02.000000000 +0100
8389 #define ADFS_SUPER_MAGIC 0xadf5
8390 #define AFFS_SUPER_MAGIC 0xadff
8391 -#define AFS_SUPER_MAGIC 0x5346414F
8392 +#define AFS_SUPER_MAGIC 0x5346414F
8393 #define AUTOFS_SUPER_MAGIC 0x0187
8394 #define CODA_SUPER_MAGIC 0x73757245
8395 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8397 #define NFS_SUPER_MAGIC 0x6969
8398 #define OPENPROM_SUPER_MAGIC 0x9fa1
8399 #define PROC_SUPER_MAGIC 0x9fa0
8400 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8401 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8403 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8404 diff -NurpP --minimal linux-3.2.8/include/linux/major.h linux-3.2.8-vs2.3.2.7/include/linux/major.h
8405 --- linux-3.2.8/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8406 +++ linux-3.2.8-vs2.3.2.7/include/linux/major.h 2011-12-05 19:33:02.000000000 +0100
8408 #define HD_MAJOR IDE0_MAJOR
8409 #define PTY_SLAVE_MAJOR 3
8411 +#define VROOT_MAJOR 4
8412 #define TTYAUX_MAJOR 5
8415 diff -NurpP --minimal linux-3.2.8/include/linux/memcontrol.h linux-3.2.8-vs2.3.2.7/include/linux/memcontrol.h
8416 --- linux-3.2.8/include/linux/memcontrol.h 2012-02-28 05:53:29.000000000 +0100
8417 +++ linux-3.2.8-vs2.3.2.7/include/linux/memcontrol.h 2012-01-26 08:52:10.000000000 +0100
8418 @@ -85,6 +85,13 @@ extern struct mem_cgroup *try_get_mem_cg
8419 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8420 extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
8422 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8423 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8425 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8426 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8427 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8430 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8432 diff -NurpP --minimal linux-3.2.8/include/linux/mm_types.h linux-3.2.8-vs2.3.2.7/include/linux/mm_types.h
8433 --- linux-3.2.8/include/linux/mm_types.h 2012-01-09 16:14:58.000000000 +0100
8434 +++ linux-3.2.8-vs2.3.2.7/include/linux/mm_types.h 2011-12-05 19:33:02.000000000 +0100
8435 @@ -344,6 +344,7 @@ struct mm_struct {
8437 /* Architecture-specific MM context */
8438 mm_context_t context;
8439 + struct vx_info *mm_vx_info;
8441 /* Swap token stuff */
8443 diff -NurpP --minimal linux-3.2.8/include/linux/mmzone.h linux-3.2.8-vs2.3.2.7/include/linux/mmzone.h
8444 --- linux-3.2.8/include/linux/mmzone.h 2012-01-09 16:14:58.000000000 +0100
8445 +++ linux-3.2.8-vs2.3.2.7/include/linux/mmzone.h 2011-12-05 19:33:02.000000000 +0100
8446 @@ -673,6 +673,13 @@ typedef struct pglist_data {
8447 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8450 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
8452 +#define node_end_pfn(nid) ({\
8453 + pg_data_t *__pgdat = NODE_DATA(nid);\
8454 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8457 #include <linux/memory_hotplug.h>
8459 extern struct mutex zonelists_mutex;
8460 diff -NurpP --minimal linux-3.2.8/include/linux/mount.h linux-3.2.8-vs2.3.2.7/include/linux/mount.h
8461 --- linux-3.2.8/include/linux/mount.h 2011-10-24 18:45:32.000000000 +0200
8462 +++ linux-3.2.8-vs2.3.2.7/include/linux/mount.h 2011-12-05 19:33:02.000000000 +0100
8463 @@ -52,6 +52,9 @@ struct mnt_pcp {
8467 +#define MNT_TAGID 0x10000
8468 +#define MNT_NOTAG 0x20000
8471 struct list_head mnt_hash;
8472 struct vfsmount *mnt_parent; /* fs we are mounted on */
8473 @@ -86,6 +89,7 @@ struct vfsmount {
8474 int mnt_expiry_mark; /* true if marked for expiry */
8477 + tag_t mnt_tag; /* tagging used for vfsmount */
8480 struct file; /* forward dec */
8481 diff -NurpP --minimal linux-3.2.8/include/linux/net.h linux-3.2.8-vs2.3.2.7/include/linux/net.h
8482 --- linux-3.2.8/include/linux/net.h 2011-07-22 11:18:11.000000000 +0200
8483 +++ linux-3.2.8-vs2.3.2.7/include/linux/net.h 2011-12-05 19:33:02.000000000 +0100
8484 @@ -72,6 +72,7 @@ struct net;
8485 #define SOCK_NOSPACE 2
8486 #define SOCK_PASSCRED 3
8487 #define SOCK_PASSSEC 4
8488 +#define SOCK_USER_SOCKET 5
8490 #ifndef ARCH_HAS_SOCKET_TYPES
8492 diff -NurpP --minimal linux-3.2.8/include/linux/netdevice.h linux-3.2.8-vs2.3.2.7/include/linux/netdevice.h
8493 --- linux-3.2.8/include/linux/netdevice.h 2012-01-09 16:14:58.000000000 +0100
8494 +++ linux-3.2.8-vs2.3.2.7/include/linux/netdevice.h 2011-12-15 01:11:33.000000000 +0100
8495 @@ -1646,6 +1646,7 @@ extern void netdev_resync_ops(struct ne
8497 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
8498 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
8499 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
8500 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
8501 extern int dev_restart(struct net_device *dev);
8502 #ifdef CONFIG_NETPOLL_TRAP
8503 diff -NurpP --minimal linux-3.2.8/include/linux/nfs_mount.h linux-3.2.8-vs2.3.2.7/include/linux/nfs_mount.h
8504 --- linux-3.2.8/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
8505 +++ linux-3.2.8-vs2.3.2.7/include/linux/nfs_mount.h 2011-12-05 19:33:02.000000000 +0100
8506 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8507 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8508 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8509 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8510 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8511 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8512 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8514 /* The following are for internal use only */
8515 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8516 diff -NurpP --minimal linux-3.2.8/include/linux/nsproxy.h linux-3.2.8-vs2.3.2.7/include/linux/nsproxy.h
8517 --- linux-3.2.8/include/linux/nsproxy.h 2011-10-24 18:45:32.000000000 +0200
8518 +++ linux-3.2.8-vs2.3.2.7/include/linux/nsproxy.h 2011-12-05 19:33:02.000000000 +0100
8521 #include <linux/spinlock.h>
8522 #include <linux/sched.h>
8523 +#include <linux/vserver/debug.h>
8525 struct mnt_namespace;
8526 struct uts_namespace;
8527 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
8530 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8531 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8532 void exit_task_namespaces(struct task_struct *tsk);
8533 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8534 void free_nsproxy(struct nsproxy *ns);
8535 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
8536 struct fs_struct *);
8537 int __init nsproxy_cache_init(void);
8539 -static inline void put_nsproxy(struct nsproxy *ns)
8540 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8542 +static inline void __get_nsproxy(struct nsproxy *ns,
8543 + const char *_file, int _line)
8545 - if (atomic_dec_and_test(&ns->count)) {
8548 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8549 + ns, atomic_read(&ns->count), _file, _line);
8550 + atomic_inc(&ns->count);
8553 -static inline void get_nsproxy(struct nsproxy *ns)
8554 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8556 +static inline void __put_nsproxy(struct nsproxy *ns,
8557 + const char *_file, int _line)
8559 - atomic_inc(&ns->count);
8560 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8561 + ns, atomic_read(&ns->count), _file, _line);
8562 + if (atomic_dec_and_test(&ns->count)) {
8568 diff -NurpP --minimal linux-3.2.8/include/linux/pid.h linux-3.2.8-vs2.3.2.7/include/linux/pid.h
8569 --- linux-3.2.8/include/linux/pid.h 2011-07-22 11:18:11.000000000 +0200
8570 +++ linux-3.2.8-vs2.3.2.7/include/linux/pid.h 2011-12-05 19:33:02.000000000 +0100
8571 @@ -8,7 +8,8 @@ enum pid_type
8581 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
8584 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8585 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8586 pid_t pid_vnr(struct pid *pid);
8588 #define do_each_pid_task(pid, type, task) \
8589 diff -NurpP --minimal linux-3.2.8/include/linux/proc_fs.h linux-3.2.8-vs2.3.2.7/include/linux/proc_fs.h
8590 --- linux-3.2.8/include/linux/proc_fs.h 2011-10-24 18:45:32.000000000 +0200
8591 +++ linux-3.2.8-vs2.3.2.7/include/linux/proc_fs.h 2011-12-05 19:33:02.000000000 +0100
8592 @@ -54,6 +54,7 @@ struct proc_dir_entry {
8598 const struct inode_operations *proc_iops;
8600 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
8601 extern const struct proc_ns_operations utsns_operations;
8602 extern const struct proc_ns_operations ipcns_operations;
8608 int (*proc_get_link)(struct inode *, struct path *);
8609 int (*proc_read)(struct task_struct *task, char *page);
8610 int (*proc_show)(struct seq_file *m,
8611 struct pid_namespace *ns, struct pid *pid,
8612 struct task_struct *task);
8613 + int (*proc_vs_read)(char *page);
8614 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8615 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8618 struct ctl_table_header;
8619 @@ -265,6 +272,7 @@ struct ctl_table;
8626 struct proc_dir_entry *pde;
8627 diff -NurpP --minimal linux-3.2.8/include/linux/quotaops.h linux-3.2.8-vs2.3.2.7/include/linux/quotaops.h
8628 --- linux-3.2.8/include/linux/quotaops.h 2012-01-09 16:14:58.000000000 +0100
8629 +++ linux-3.2.8-vs2.3.2.7/include/linux/quotaops.h 2011-12-05 19:33:02.000000000 +0100
8631 #define _LINUX_QUOTAOPS_
8633 #include <linux/fs.h>
8634 +#include <linux/vs_dlimit.h>
8636 #define DQUOT_SPACE_WARN 0x1
8637 #define DQUOT_SPACE_RESERVE 0x2
8638 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
8640 static inline int dquot_alloc_inode(const struct inode *inode)
8643 + return dl_alloc_inode(inode);
8646 static inline void dquot_free_inode(const struct inode *inode)
8648 + dl_free_inode(inode);
8651 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
8652 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct
8653 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
8658 + if ((ret = dl_alloc_space(inode, number)))
8660 if (!(flags & DQUOT_SPACE_RESERVE))
8661 inode_add_bytes(inode, number);
8663 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
8665 if (!(flags & DQUOT_SPACE_RESERVE))
8666 inode_sub_bytes(inode, number);
8667 + dl_free_space(inode, number);
8670 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
8671 diff -NurpP --minimal linux-3.2.8/include/linux/reboot.h linux-3.2.8-vs2.3.2.7/include/linux/reboot.h
8672 --- linux-3.2.8/include/linux/reboot.h 2011-10-24 18:45:32.000000000 +0200
8673 +++ linux-3.2.8-vs2.3.2.7/include/linux/reboot.h 2011-12-05 19:33:02.000000000 +0100
8675 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
8676 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
8677 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
8678 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
8682 diff -NurpP --minimal linux-3.2.8/include/linux/reiserfs_fs.h linux-3.2.8-vs2.3.2.7/include/linux/reiserfs_fs.h
8683 --- linux-3.2.8/include/linux/reiserfs_fs.h 2011-10-24 18:45:32.000000000 +0200
8684 +++ linux-3.2.8-vs2.3.2.7/include/linux/reiserfs_fs.h 2011-12-05 19:33:02.000000000 +0100
8685 @@ -976,6 +976,11 @@ struct stat_data_v1 {
8686 #define REISERFS_COMPR_FL FS_COMPR_FL
8687 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
8689 +/* unfortunately reiserfs sdattr is only 16 bit */
8690 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
8691 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
8692 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
8694 /* persistent flags that file inherits from the parent directory */
8695 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
8696 REISERFS_SYNC_FL | \
8697 @@ -985,6 +990,9 @@ struct stat_data_v1 {
8698 REISERFS_COMPR_FL | \
8699 REISERFS_NOTAIL_FL )
8701 +#define REISERFS_FL_USER_VISIBLE 0x80FF
8702 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
8704 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
8707 @@ -2073,6 +2081,7 @@ static inline void reiserfs_update_sd(st
8708 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
8709 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
8710 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
8711 +int reiserfs_sync_flags(struct inode *inode, int, int);
8713 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
8715 diff -NurpP --minimal linux-3.2.8/include/linux/reiserfs_fs_sb.h linux-3.2.8-vs2.3.2.7/include/linux/reiserfs_fs_sb.h
8716 --- linux-3.2.8/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
8717 +++ linux-3.2.8-vs2.3.2.7/include/linux/reiserfs_fs_sb.h 2011-12-05 19:33:02.000000000 +0100
8718 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
8719 REISERFS_EXPOSE_PRIVROOT,
8720 REISERFS_BARRIER_NONE,
8721 REISERFS_BARRIER_FLUSH,
8724 /* Actions on error */
8725 REISERFS_ERROR_PANIC,
8726 diff -NurpP --minimal linux-3.2.8/include/linux/sched.h linux-3.2.8-vs2.3.2.7/include/linux/sched.h
8727 --- linux-3.2.8/include/linux/sched.h 2012-01-09 16:14:58.000000000 +0100
8728 +++ linux-3.2.8-vs2.3.2.7/include/linux/sched.h 2011-12-05 19:33:02.000000000 +0100
8729 @@ -1403,6 +1403,14 @@ struct task_struct {
8733 +/* vserver context data */
8734 + struct vx_info *vx_info;
8735 + struct nx_info *nx_info;
8741 /* Thread group tracking */
8744 @@ -1651,6 +1659,11 @@ struct pid_namespace;
8745 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
8746 struct pid_namespace *ns);
8748 +#include <linux/vserver/base.h>
8749 +#include <linux/vserver/context.h>
8750 +#include <linux/vserver/debug.h>
8751 +#include <linux/vserver/pid.h>
8753 static inline pid_t task_pid_nr(struct task_struct *tsk)
8756 @@ -1664,7 +1677,8 @@ static inline pid_t task_pid_nr_ns(struc
8758 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8760 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8761 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8762 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8766 @@ -1677,7 +1691,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8768 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8770 - return pid_vnr(task_tgid(tsk));
8771 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8775 diff -NurpP --minimal linux-3.2.8/include/linux/shmem_fs.h linux-3.2.8-vs2.3.2.7/include/linux/shmem_fs.h
8776 --- linux-3.2.8/include/linux/shmem_fs.h 2012-02-28 05:53:29.000000000 +0100
8777 +++ linux-3.2.8-vs2.3.2.7/include/linux/shmem_fs.h 2012-01-26 08:52:10.000000000 +0100
8780 /* inode in-kernel data */
8782 +#define TMPFS_SUPER_MAGIC 0x01021994
8785 struct shmem_inode_info {
8787 unsigned long flags;
8788 diff -NurpP --minimal linux-3.2.8/include/linux/stat.h linux-3.2.8-vs2.3.2.7/include/linux/stat.h
8789 --- linux-3.2.8/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
8790 +++ linux-3.2.8-vs2.3.2.7/include/linux/stat.h 2011-12-05 19:33:02.000000000 +0100
8791 @@ -66,6 +66,7 @@ struct kstat {
8798 struct timespec atime;
8799 diff -NurpP --minimal linux-3.2.8/include/linux/sunrpc/auth.h linux-3.2.8-vs2.3.2.7/include/linux/sunrpc/auth.h
8800 --- linux-3.2.8/include/linux/sunrpc/auth.h 2011-10-24 18:45:32.000000000 +0200
8801 +++ linux-3.2.8-vs2.3.2.7/include/linux/sunrpc/auth.h 2011-12-05 19:33:02.000000000 +0100
8807 struct group_info *group_info;
8808 unsigned char machine_cred : 1;
8810 diff -NurpP --minimal linux-3.2.8/include/linux/sunrpc/clnt.h linux-3.2.8-vs2.3.2.7/include/linux/sunrpc/clnt.h
8811 --- linux-3.2.8/include/linux/sunrpc/clnt.h 2012-01-09 16:14:58.000000000 +0100
8812 +++ linux-3.2.8-vs2.3.2.7/include/linux/sunrpc/clnt.h 2011-12-05 19:33:02.000000000 +0100
8813 @@ -50,7 +50,8 @@ struct rpc_clnt {
8814 unsigned int cl_softrtry : 1,/* soft timeouts */
8815 cl_discrtry : 1,/* disconnect before retry */
8816 cl_autobind : 1,/* use getport() */
8817 - cl_chatty : 1;/* be verbose */
8818 + cl_chatty : 1,/* be verbose */
8819 + cl_tag : 1;/* context tagging */
8821 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8822 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8823 diff -NurpP --minimal linux-3.2.8/include/linux/syscalls.h linux-3.2.8-vs2.3.2.7/include/linux/syscalls.h
8824 --- linux-3.2.8/include/linux/syscalls.h 2012-01-09 16:14:58.000000000 +0100
8825 +++ linux-3.2.8-vs2.3.2.7/include/linux/syscalls.h 2011-12-05 19:33:02.000000000 +0100
8826 @@ -483,6 +483,8 @@ asmlinkage long sys_symlink(const char _
8827 asmlinkage long sys_unlink(const char __user *pathname);
8828 asmlinkage long sys_rename(const char __user *oldname,
8829 const char __user *newname);
8830 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
8832 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
8833 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
8835 diff -NurpP --minimal linux-3.2.8/include/linux/sysctl.h linux-3.2.8-vs2.3.2.7/include/linux/sysctl.h
8836 --- linux-3.2.8/include/linux/sysctl.h 2012-01-09 16:14:58.000000000 +0100
8837 +++ linux-3.2.8-vs2.3.2.7/include/linux/sysctl.h 2011-12-05 19:33:02.000000000 +0100
8838 @@ -60,6 +60,7 @@ enum
8839 CTL_ABI=9, /* Binary emulation */
8840 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
8841 CTL_ARLAN=254, /* arlan wireless driver */
8842 + CTL_VSERVER=4242, /* Linux-VServer debug */
8843 CTL_S390DBF=5677, /* s390 debug */
8844 CTL_SUNRPC=7249, /* sunrpc debug */
8845 CTL_PM=9899, /* frv power management */
8846 @@ -94,6 +95,7 @@ enum
8848 KERN_PANIC=15, /* int: panic timeout */
8849 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
8850 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
8852 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
8853 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
8854 diff -NurpP --minimal linux-3.2.8/include/linux/sysfs.h linux-3.2.8-vs2.3.2.7/include/linux/sysfs.h
8855 --- linux-3.2.8/include/linux/sysfs.h 2012-01-09 16:14:58.000000000 +0100
8856 +++ linux-3.2.8-vs2.3.2.7/include/linux/sysfs.h 2011-12-05 19:33:02.000000000 +0100
8858 #include <linux/kobject_ns.h>
8859 #include <linux/atomic.h>
8861 +#define SYSFS_SUPER_MAGIC 0x62656572
8866 diff -NurpP --minimal linux-3.2.8/include/linux/time.h linux-3.2.8-vs2.3.2.7/include/linux/time.h
8867 --- linux-3.2.8/include/linux/time.h 2011-07-22 11:18:11.000000000 +0200
8868 +++ linux-3.2.8-vs2.3.2.7/include/linux/time.h 2011-12-05 19:33:02.000000000 +0100
8869 @@ -256,6 +256,9 @@ static __always_inline void timespec_add
8870 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
8874 +#include <linux/vs_time.h>
8876 #endif /* __KERNEL__ */
8878 #define NFDBITS __NFDBITS
8879 diff -NurpP --minimal linux-3.2.8/include/linux/types.h linux-3.2.8-vs2.3.2.7/include/linux/types.h
8880 --- linux-3.2.8/include/linux/types.h 2012-01-09 16:14:59.000000000 +0100
8881 +++ linux-3.2.8-vs2.3.2.7/include/linux/types.h 2011-12-05 19:33:02.000000000 +0100
8882 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
8883 typedef __kernel_gid32_t gid_t;
8884 typedef __kernel_uid16_t uid16_t;
8885 typedef __kernel_gid16_t gid16_t;
8886 +typedef unsigned int xid_t;
8887 +typedef unsigned int nid_t;
8888 +typedef unsigned int tag_t;
8890 typedef unsigned long uintptr_t;
8892 diff -NurpP --minimal linux-3.2.8/include/linux/utsname.h linux-3.2.8-vs2.3.2.7/include/linux/utsname.h
8893 --- linux-3.2.8/include/linux/utsname.h 2012-01-09 16:14:59.000000000 +0100
8894 +++ linux-3.2.8-vs2.3.2.7/include/linux/utsname.h 2011-12-05 19:33:02.000000000 +0100
8895 @@ -62,7 +62,8 @@ static inline void get_uts_ns(struct uts
8898 extern struct uts_namespace *copy_utsname(unsigned long flags,
8899 - struct task_struct *tsk);
8900 + struct uts_namespace *old_ns,
8901 + struct user_namespace *user_ns);
8902 extern void free_uts_ns(struct kref *kref);
8904 static inline void put_uts_ns(struct uts_namespace *ns)
8905 @@ -79,12 +80,13 @@ static inline void put_uts_ns(struct uts
8908 static inline struct uts_namespace *copy_utsname(unsigned long flags,
8909 - struct task_struct *tsk)
8910 + struct uts_namespace *old_ns,
8911 + struct user_namespace *user_ns)
8913 if (flags & CLONE_NEWUTS)
8914 return ERR_PTR(-EINVAL);
8916 - return tsk->nsproxy->uts_ns;
8921 diff -NurpP --minimal linux-3.2.8/include/linux/vroot.h linux-3.2.8-vs2.3.2.7/include/linux/vroot.h
8922 --- linux-3.2.8/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
8923 +++ linux-3.2.8-vs2.3.2.7/include/linux/vroot.h 2011-12-05 19:33:02.000000000 +0100
8927 + * include/linux/vroot.h
8929 + * written by Herbert Pötzl, 9/11/2002
8930 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
8932 + * Copyright (C) 2002-2007 by Herbert Pötzl.
8933 + * Redistribution of this file is permitted under the
8934 + * GNU General Public License.
8937 +#ifndef _LINUX_VROOT_H
8938 +#define _LINUX_VROOT_H
8943 +/* Possible states of device */
8949 +struct vroot_device {
8953 + struct semaphore vr_ctl_mutex;
8954 + struct block_device *vr_device;
8959 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
8961 +extern int register_vroot_grb(vroot_grb_func *);
8962 +extern int unregister_vroot_grb(vroot_grb_func *);
8964 +#endif /* __KERNEL__ */
8966 +#define MAX_VROOT_DEFAULT 8
8969 + * IOCTL commands --- we will commandeer 0x56 ('V')
8972 +#define VROOT_SET_DEV 0x5600
8973 +#define VROOT_CLR_DEV 0x5601
8975 +#endif /* _LINUX_VROOT_H */
8976 diff -NurpP --minimal linux-3.2.8/include/linux/vs_base.h linux-3.2.8-vs2.3.2.7/include/linux/vs_base.h
8977 --- linux-3.2.8/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
8978 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_base.h 2011-12-05 19:33:02.000000000 +0100
8983 +#include "vserver/base.h"
8984 +#include "vserver/check.h"
8985 +#include "vserver/debug.h"
8988 +#warning duplicate inclusion
8990 diff -NurpP --minimal linux-3.2.8/include/linux/vs_context.h linux-3.2.8-vs2.3.2.7/include/linux/vs_context.h
8991 --- linux-3.2.8/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
8992 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_context.h 2011-12-05 19:33:02.000000000 +0100
8994 +#ifndef _VS_CONTEXT_H
8995 +#define _VS_CONTEXT_H
8997 +#include "vserver/base.h"
8998 +#include "vserver/check.h"
8999 +#include "vserver/context.h"
9000 +#include "vserver/history.h"
9001 +#include "vserver/debug.h"
9003 +#include <linux/sched.h>
9006 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9008 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9009 + const char *_file, int _line, void *_here)
9014 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9015 + vxi, vxi ? vxi->vx_id : 0,
9016 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9018 + __vxh_get_vx_info(vxi, _here);
9020 + atomic_inc(&vxi->vx_usecnt);
9025 +extern void free_vx_info(struct vx_info *);
9027 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9029 +static inline void __put_vx_info(struct vx_info *vxi,
9030 + const char *_file, int _line, void *_here)
9035 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9036 + vxi, vxi ? vxi->vx_id : 0,
9037 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9039 + __vxh_put_vx_info(vxi, _here);
9041 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9042 + free_vx_info(vxi);
9046 +#define init_vx_info(p, i) \
9047 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9049 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9050 + const char *_file, int _line, void *_here)
9053 + vxlprintk(VXD_CBIT(xid, 3),
9054 + "init_vx_info(%p[#%d.%d])",
9055 + vxi, vxi ? vxi->vx_id : 0,
9056 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9058 + __vxh_init_vx_info(vxi, vxp, _here);
9060 + atomic_inc(&vxi->vx_usecnt);
9066 +#define set_vx_info(p, i) \
9067 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9069 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9070 + const char *_file, int _line, void *_here)
9072 + struct vx_info *vxo;
9077 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9078 + vxi, vxi ? vxi->vx_id : 0,
9079 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9081 + __vxh_set_vx_info(vxi, vxp, _here);
9083 + atomic_inc(&vxi->vx_usecnt);
9084 + vxo = xchg(vxp, vxi);
9089 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9091 +static inline void __clr_vx_info(struct vx_info **vxp,
9092 + const char *_file, int _line, void *_here)
9094 + struct vx_info *vxo;
9096 + vxo = xchg(vxp, NULL);
9100 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9101 + vxo, vxo ? vxo->vx_id : 0,
9102 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9104 + __vxh_clr_vx_info(vxo, vxp, _here);
9106 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9107 + free_vx_info(vxo);
9111 +#define claim_vx_info(v, p) \
9112 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9114 +static inline void __claim_vx_info(struct vx_info *vxi,
9115 + struct task_struct *task,
9116 + const char *_file, int _line, void *_here)
9118 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9119 + vxi, vxi ? vxi->vx_id : 0,
9120 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9121 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9122 + task, _file, _line);
9123 + __vxh_claim_vx_info(vxi, task, _here);
9125 + atomic_inc(&vxi->vx_tasks);
9129 +extern void unhash_vx_info(struct vx_info *);
9131 +#define release_vx_info(v, p) \
9132 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9134 +static inline void __release_vx_info(struct vx_info *vxi,
9135 + struct task_struct *task,
9136 + const char *_file, int _line, void *_here)
9138 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9139 + vxi, vxi ? vxi->vx_id : 0,
9140 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9141 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9142 + task, _file, _line);
9143 + __vxh_release_vx_info(vxi, task, _here);
9147 + if (atomic_dec_and_test(&vxi->vx_tasks))
9148 + unhash_vx_info(vxi);
9152 +#define task_get_vx_info(p) \
9153 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9155 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9156 + const char *_file, int _line, void *_here)
9158 + struct vx_info *vxi;
9161 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9163 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9169 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9171 + if (waitqueue_active(&vxi->vx_wait))
9172 + wake_up_interruptible(&vxi->vx_wait);
9176 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9178 +static inline void __enter_vx_info(struct vx_info *vxi,
9179 + struct vx_info_save *vxis, const char *_file, int _line)
9181 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9182 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9183 + current->xid, current->vx_info, _file, _line);
9184 + vxis->vxi = xchg(¤t->vx_info, vxi);
9185 + vxis->xid = current->xid;
9186 + current->xid = vxi ? vxi->vx_id : 0;
9189 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9191 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9192 + const char *_file, int _line)
9194 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9195 + vxis, vxis->xid, vxis->vxi, current,
9196 + current->xid, current->vx_info, _file, _line);
9197 + (void)xchg(¤t->vx_info, vxis->vxi);
9198 + current->xid = vxis->xid;
9202 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9204 + vxis->vxi = xchg(¤t->vx_info, NULL);
9205 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9208 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9210 + (void)xchg(¤t->xid, vxis->xid);
9211 + (void)xchg(¤t->vx_info, vxis->vxi);
9214 +#define task_is_init(p) \
9215 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9217 +static inline int __task_is_init(struct task_struct *p,
9218 + const char *_file, int _line, void *_here)
9220 + int is_init = is_global_init(p);
9224 + is_init = p->vx_info->vx_initpid == p->pid;
9229 +extern void exit_vx_info(struct task_struct *, int);
9230 +extern void exit_vx_info_early(struct task_struct *, int);
9234 +#warning duplicate inclusion
9236 diff -NurpP --minimal linux-3.2.8/include/linux/vs_cowbl.h linux-3.2.8-vs2.3.2.7/include/linux/vs_cowbl.h
9237 --- linux-3.2.8/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9238 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_cowbl.h 2011-12-05 19:33:02.000000000 +0100
9240 +#ifndef _VS_COWBL_H
9241 +#define _VS_COWBL_H
9243 +#include <linux/fs.h>
9244 +#include <linux/dcache.h>
9245 +#include <linux/namei.h>
9246 +#include <linux/slab.h>
9248 +extern struct dentry *cow_break_link(const char *pathname);
9250 +static inline int cow_check_and_break(struct path *path)
9252 + struct inode *inode = path->dentry->d_inode;
9255 + /* do we need this check? */
9256 + if (IS_RDONLY(inode))
9259 + if (IS_COW(inode)) {
9260 + if (IS_COW_LINK(inode)) {
9261 + struct dentry *new_dentry, *old_dentry = path->dentry;
9264 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9268 + pp = d_path(path, buf, PATH_MAX);
9269 + new_dentry = cow_break_link(pp);
9271 + if (!IS_ERR(new_dentry)) {
9272 + path->dentry = new_dentry;
9275 + error = PTR_ERR(new_dentry);
9277 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9278 + inode->i_ctime = CURRENT_TIME;
9279 + mark_inode_dirty(inode);
9286 +#warning duplicate inclusion
9288 diff -NurpP --minimal linux-3.2.8/include/linux/vs_cvirt.h linux-3.2.8-vs2.3.2.7/include/linux/vs_cvirt.h
9289 --- linux-3.2.8/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9290 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_cvirt.h 2011-12-05 19:33:02.000000000 +0100
9292 +#ifndef _VS_CVIRT_H
9293 +#define _VS_CVIRT_H
9295 +#include "vserver/cvirt.h"
9296 +#include "vserver/context.h"
9297 +#include "vserver/base.h"
9298 +#include "vserver/check.h"
9299 +#include "vserver/debug.h"
9302 +static inline void vx_activate_task(struct task_struct *p)
9304 + struct vx_info *vxi;
9306 + if ((vxi = p->vx_info)) {
9307 + vx_update_load(vxi);
9308 + atomic_inc(&vxi->cvirt.nr_running);
9312 +static inline void vx_deactivate_task(struct task_struct *p)
9314 + struct vx_info *vxi;
9316 + if ((vxi = p->vx_info)) {
9317 + vx_update_load(vxi);
9318 + atomic_dec(&vxi->cvirt.nr_running);
9322 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9324 + struct vx_info *vxi;
9326 + if ((vxi = p->vx_info))
9327 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9330 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9332 + struct vx_info *vxi;
9334 + if ((vxi = p->vx_info))
9335 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9340 +#warning duplicate inclusion
9342 diff -NurpP --minimal linux-3.2.8/include/linux/vs_device.h linux-3.2.8-vs2.3.2.7/include/linux/vs_device.h
9343 --- linux-3.2.8/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9344 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_device.h 2011-12-05 19:33:02.000000000 +0100
9346 +#ifndef _VS_DEVICE_H
9347 +#define _VS_DEVICE_H
9349 +#include "vserver/base.h"
9350 +#include "vserver/device.h"
9351 +#include "vserver/debug.h"
9354 +#ifdef CONFIG_VSERVER_DEVICE
9356 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9358 +#define vs_device_perm(v, d, m, p) \
9359 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9364 +int vs_map_device(struct vx_info *vxi,
9365 + dev_t device, dev_t *target, umode_t mode)
9372 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9377 +#define vs_map_chrdev(d, t, p) \
9378 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9379 +#define vs_map_blkdev(d, t, p) \
9380 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9382 +#define vs_chrdev_perm(d, p) \
9383 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9384 +#define vs_blkdev_perm(d, p) \
9385 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9389 +#warning duplicate inclusion
9391 diff -NurpP --minimal linux-3.2.8/include/linux/vs_dlimit.h linux-3.2.8-vs2.3.2.7/include/linux/vs_dlimit.h
9392 --- linux-3.2.8/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9393 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_dlimit.h 2011-12-05 19:33:02.000000000 +0100
9395 +#ifndef _VS_DLIMIT_H
9396 +#define _VS_DLIMIT_H
9398 +#include <linux/fs.h>
9400 +#include "vserver/dlimit.h"
9401 +#include "vserver/base.h"
9402 +#include "vserver/debug.h"
9405 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9407 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9408 + const char *_file, int _line)
9412 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9413 + dli, dli ? dli->dl_tag : 0,
9414 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9416 + atomic_inc(&dli->dl_usecnt);
9421 +#define free_dl_info(i) \
9422 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9424 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9426 +static inline void __put_dl_info(struct dl_info *dli,
9427 + const char *_file, int _line)
9431 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9432 + dli, dli ? dli->dl_tag : 0,
9433 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9435 + if (atomic_dec_and_test(&dli->dl_usecnt))
9436 + free_dl_info(dli);
9440 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9442 +static inline int __dl_alloc_space(struct super_block *sb,
9443 + tag_t tag, dlsize_t nr, const char *file, int line)
9445 + struct dl_info *dli = NULL;
9450 + dli = locate_dl_info(sb, tag);
9454 + spin_lock(&dli->dl_lock);
9455 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9457 + dli->dl_space_used += nr;
9458 + spin_unlock(&dli->dl_lock);
9461 + vxlprintk(VXD_CBIT(dlim, 1),
9462 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9463 + sb, tag, __dlimit_char(dli), (long long)nr,
9465 + return ret ? -ENOSPC : 0;
9468 +static inline void __dl_free_space(struct super_block *sb,
9469 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9471 + struct dl_info *dli = NULL;
9475 + dli = locate_dl_info(sb, tag);
9479 + spin_lock(&dli->dl_lock);
9480 + if (dli->dl_space_used > nr)
9481 + dli->dl_space_used -= nr;
9483 + dli->dl_space_used = 0;
9484 + spin_unlock(&dli->dl_lock);
9487 + vxlprintk(VXD_CBIT(dlim, 1),
9488 + "FREE (%p,#%d)%c %lld bytes",
9489 + sb, tag, __dlimit_char(dli), (long long)nr,
9493 +static inline int __dl_alloc_inode(struct super_block *sb,
9494 + tag_t tag, const char *_file, int _line)
9496 + struct dl_info *dli;
9499 + dli = locate_dl_info(sb, tag);
9503 + spin_lock(&dli->dl_lock);
9504 + dli->dl_inodes_used++;
9505 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9506 + spin_unlock(&dli->dl_lock);
9509 + vxlprintk(VXD_CBIT(dlim, 0),
9510 + "ALLOC (%p,#%d)%c inode (%d)",
9511 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9512 + return ret ? -ENOSPC : 0;
9515 +static inline void __dl_free_inode(struct super_block *sb,
9516 + tag_t tag, const char *_file, int _line)
9518 + struct dl_info *dli;
9520 + dli = locate_dl_info(sb, tag);
9524 + spin_lock(&dli->dl_lock);
9525 + if (dli->dl_inodes_used > 1)
9526 + dli->dl_inodes_used--;
9528 + dli->dl_inodes_used = 0;
9529 + spin_unlock(&dli->dl_lock);
9532 + vxlprintk(VXD_CBIT(dlim, 0),
9533 + "FREE (%p,#%d)%c inode",
9534 + sb, tag, __dlimit_char(dli), _file, _line);
9537 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
9538 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9539 + const char *_file, int _line)
9541 + struct dl_info *dli;
9542 + uint64_t broot, bfree;
9544 + dli = locate_dl_info(sb, tag);
9548 + spin_lock(&dli->dl_lock);
9549 + broot = (dli->dl_space_total -
9550 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
9551 + >> sb->s_blocksize_bits;
9552 + bfree = (dli->dl_space_total - dli->dl_space_used)
9553 + >> sb->s_blocksize_bits;
9554 + spin_unlock(&dli->dl_lock);
9556 + vxlprintk(VXD_CBIT(dlim, 2),
9557 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
9558 + (long long)bfree, (long long)broot,
9559 + *free_blocks, *root_blocks, dli->dl_nrlmult,
9561 + if (free_blocks) {
9562 + if (*free_blocks > bfree)
9563 + *free_blocks = bfree;
9565 + if (root_blocks) {
9566 + if (*root_blocks > broot)
9567 + *root_blocks = broot;
9572 +#define dl_prealloc_space(in, bytes) \
9573 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9574 + __FILE__, __LINE__ )
9576 +#define dl_alloc_space(in, bytes) \
9577 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9578 + __FILE__, __LINE__ )
9580 +#define dl_reserve_space(in, bytes) \
9581 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9582 + __FILE__, __LINE__ )
9584 +#define dl_claim_space(in, bytes) (0)
9586 +#define dl_release_space(in, bytes) \
9587 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9588 + __FILE__, __LINE__ )
9590 +#define dl_free_space(in, bytes) \
9591 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9592 + __FILE__, __LINE__ )
9596 +#define dl_alloc_inode(in) \
9597 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9599 +#define dl_free_inode(in) \
9600 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9603 +#define dl_adjust_block(sb, tag, fb, rb) \
9604 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
9608 +#warning duplicate inclusion
9610 diff -NurpP --minimal linux-3.2.8/include/linux/vs_inet.h linux-3.2.8-vs2.3.2.7/include/linux/vs_inet.h
9611 --- linux-3.2.8/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
9612 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_inet.h 2012-02-15 03:03:53.000000000 +0100
9617 +#include "vserver/base.h"
9618 +#include "vserver/network.h"
9619 +#include "vserver/debug.h"
9621 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
9623 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
9624 + NIPQUAD((a)->mask), (a)->type
9625 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
9627 +#define NIPQUAD(addr) \
9628 + ((unsigned char *)&addr)[0], \
9629 + ((unsigned char *)&addr)[1], \
9630 + ((unsigned char *)&addr)[2], \
9631 + ((unsigned char *)&addr)[3]
9633 +#define NIPQUAD_FMT "%u.%u.%u.%u"
9637 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
9639 + __be32 ip = nxa->ip[0].s_addr;
9640 + __be32 mask = nxa->mask.s_addr;
9641 + __be32 bcast = ip | ~mask;
9644 + switch (nxa->type & tmask) {
9645 + case NXA_TYPE_MASK:
9646 + ret = (ip == (addr & mask));
9648 + case NXA_TYPE_ADDR:
9652 + /* fall through to broadcast */
9653 + case NXA_MOD_BCAST:
9654 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
9656 + case NXA_TYPE_RANGE:
9657 + ret = ((nxa->ip[0].s_addr <= addr) &&
9658 + (nxa->ip[1].s_addr > addr));
9660 + case NXA_TYPE_ANY:
9665 + vxdprintk(VXD_CBIT(net, 0),
9666 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
9667 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
9672 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
9674 + struct nx_addr_v4 *nxa;
9681 + /* allow 127.0.0.1 when remapping lback */
9682 + if ((tmask & NXA_LOOPBACK) &&
9683 + (addr == IPI_LOOPBACK) &&
9684 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9687 + /* check for lback address */
9688 + if ((tmask & NXA_MOD_LBACK) &&
9689 + (nxi->v4_lback.s_addr == addr))
9692 + /* check for broadcast address */
9693 + if ((tmask & NXA_MOD_BCAST) &&
9694 + (nxi->v4_bcast.s_addr == addr))
9697 + /* check for v4 addresses */
9698 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9699 + if (v4_addr_match(nxa, addr, tmask))
9703 + vxdprintk(VXD_CBIT(net, 0),
9704 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9705 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9710 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9712 + /* FIXME: needs full range checks */
9713 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9717 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9719 + struct nx_addr_v4 *ptr;
9721 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9722 + if (v4_nx_addr_match(ptr, nxa, mask))
9727 +#include <net/inet_sock.h>
9730 + * Check if a given address matches for a socket
9732 + * nxi: the socket's nx_info if any
9733 + * addr: to be verified address
9736 +int v4_sock_addr_match (
9737 + struct nx_info *nxi,
9738 + struct inet_sock *inet,
9741 + __be32 saddr = inet->inet_rcv_saddr;
9742 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9744 + if (addr && (saddr == addr || bcast == addr))
9747 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9752 +/* inet related checks and helpers */
9761 +#include <linux/netdevice.h>
9762 +#include <linux/inetdevice.h>
9763 +#include <net/inet_sock.h>
9764 +#include <net/inet_timewait_sock.h>
9767 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9768 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9769 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9773 + * check if address is covered by socket
9775 + * sk: the socket to check against
9776 + * addr: the address in question (must be != 0)
9780 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9782 + struct nx_info *nxi = sk->sk_nx_info;
9783 + __be32 saddr = sk_rcv_saddr(sk);
9785 + vxdprintk(VXD_CBIT(net, 5),
9786 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9787 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9788 + (sk->sk_socket?sk->sk_socket->flags:0));
9790 + if (saddr) { /* direct address match */
9791 + return v4_addr_match(nxa, saddr, -1);
9792 + } else if (nxi) { /* match against nx_info */
9793 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9794 + } else { /* unrestricted any socket */
9802 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9804 + vxdprintk(VXD_CBIT(net, 1),
9805 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9806 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9807 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9809 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9811 + if (dev_in_nx_info(dev, nxi))
9818 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9824 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9828 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
9830 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
9831 + nxi, nxi ? nxi->nx_id : 0, ifa,
9832 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
9834 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9836 + if (v4_ifa_in_nx_info(ifa, nxi))
9842 +struct nx_v4_sock_addr {
9843 + __be32 saddr; /* Address used for validation */
9844 + __be32 baddr; /* Address used for socket bind */
9848 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
9849 + struct nx_v4_sock_addr *nsa)
9851 + struct sock *sk = &inet->sk;
9852 + struct nx_info *nxi = sk->sk_nx_info;
9853 + __be32 saddr = addr->sin_addr.s_addr;
9854 + __be32 baddr = saddr;
9856 + vxdprintk(VXD_CBIT(net, 3),
9857 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
9858 + sk, sk->sk_nx_info, sk->sk_socket,
9859 + (sk->sk_socket ? sk->sk_socket->flags : 0),
9863 + if (saddr == INADDR_ANY) {
9864 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
9865 + baddr = nxi->v4.ip[0].s_addr;
9866 + } else if (saddr == IPI_LOOPBACK) {
9867 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9868 + baddr = nxi->v4_lback.s_addr;
9869 + } else if (!ipv4_is_multicast(saddr) ||
9870 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
9871 + /* normal address bind */
9872 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
9873 + return -EADDRNOTAVAIL;
9877 + vxdprintk(VXD_CBIT(net, 3),
9878 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
9879 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
9881 + nsa->saddr = saddr;
9882 + nsa->baddr = baddr;
9887 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
9889 + inet->inet_saddr = nsa->baddr;
9890 + inet->inet_rcv_saddr = nsa->baddr;
9895 + * helper to simplify inet_lookup_listener
9897 + * nxi: the socket's nx_info if any
9898 + * addr: to be verified address
9899 + * saddr: socket address
9901 +static inline int v4_inet_addr_match (
9902 + struct nx_info *nxi,
9906 + if (addr && (saddr == addr))
9909 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
9913 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
9915 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
9916 + (addr == nxi->v4_lback.s_addr))
9917 + return IPI_LOOPBACK;
9922 +int nx_info_has_v4(struct nx_info *nxi)
9928 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9933 +#else /* CONFIG_INET */
9936 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
9942 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9948 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9954 +int nx_info_has_v4(struct nx_info *nxi)
9959 +#endif /* CONFIG_INET */
9961 +#define current_nx_info_has_v4() \
9962 + nx_info_has_v4(current_nx_info())
9965 +// #warning duplicate inclusion
9967 diff -NurpP --minimal linux-3.2.8/include/linux/vs_inet6.h linux-3.2.8-vs2.3.2.7/include/linux/vs_inet6.h
9968 --- linux-3.2.8/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
9969 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_inet6.h 2011-12-05 19:33:02.000000000 +0100
9971 +#ifndef _VS_INET6_H
9972 +#define _VS_INET6_H
9974 +#include "vserver/base.h"
9975 +#include "vserver/network.h"
9976 +#include "vserver/debug.h"
9978 +#include <net/ipv6.h>
9980 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
9981 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
9987 +int v6_addr_match(struct nx_addr_v6 *nxa,
9988 + const struct in6_addr *addr, uint16_t mask)
9992 + switch (nxa->type & mask) {
9993 + case NXA_TYPE_MASK:
9994 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
9996 + case NXA_TYPE_ADDR:
9997 + ret = ipv6_addr_equal(&nxa->ip, addr);
9999 + case NXA_TYPE_ANY:
10003 + vxdprintk(VXD_CBIT(net, 0),
10004 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
10005 + nxa, NXAV6(nxa), addr, mask, ret);
10010 +int v6_addr_in_nx_info(struct nx_info *nxi,
10011 + const struct in6_addr *addr, uint16_t mask)
10013 + struct nx_addr_v6 *nxa;
10018 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
10019 + if (v6_addr_match(nxa, addr, mask))
10023 + vxdprintk(VXD_CBIT(net, 0),
10024 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
10025 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
10030 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
10032 + /* FIXME: needs full range checks */
10033 + return v6_addr_match(nxa, &addr->ip, mask);
10037 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
10039 + struct nx_addr_v6 *ptr;
10041 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
10042 + if (v6_nx_addr_match(ptr, nxa, mask))
10049 + * Check if a given address matches for a socket
10051 + * nxi: the socket's nx_info if any
10052 + * addr: to be verified address
10055 +int v6_sock_addr_match (
10056 + struct nx_info *nxi,
10057 + struct inet_sock *inet,
10058 + struct in6_addr *addr)
10060 + struct sock *sk = &inet->sk;
10061 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10063 + if (!ipv6_addr_any(addr) &&
10064 + ipv6_addr_equal(saddr, addr))
10066 + if (ipv6_addr_any(saddr))
10067 + return v6_addr_in_nx_info(nxi, addr, -1);
10072 + * check if address is covered by socket
10074 + * sk: the socket to check against
10075 + * addr: the address in question (must be != 0)
10079 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
10081 + struct nx_info *nxi = sk->sk_nx_info;
10082 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10084 + vxdprintk(VXD_CBIT(net, 5),
10085 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
10086 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
10087 + (sk->sk_socket?sk->sk_socket->flags:0));
10089 + if (!ipv6_addr_any(saddr)) { /* direct address match */
10090 + return v6_addr_match(nxa, saddr, -1);
10091 + } else if (nxi) { /* match against nx_info */
10092 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
10093 + } else { /* unrestricted any socket */
10099 +/* inet related checks and helpers */
10103 +struct net_device;
10107 +#include <linux/netdevice.h>
10108 +#include <linux/inetdevice.h>
10109 +#include <net/inet_timewait_sock.h>
10112 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10113 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10114 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10119 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10125 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10129 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10131 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10132 + nxi, nxi ? nxi->nx_id : 0, ifa,
10133 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10135 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10137 + if (v6_ifa_in_nx_info(ifa, nxi))
10143 +struct nx_v6_sock_addr {
10144 + struct in6_addr saddr; /* Address used for validation */
10145 + struct in6_addr baddr; /* Address used for socket bind */
10149 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10150 + struct nx_v6_sock_addr *nsa)
10152 + // struct sock *sk = &inet->sk;
10153 + // struct nx_info *nxi = sk->sk_nx_info;
10154 + struct in6_addr saddr = addr->sin6_addr;
10155 + struct in6_addr baddr = saddr;
10157 + nsa->saddr = saddr;
10158 + nsa->baddr = baddr;
10163 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10165 + // struct sock *sk = &inet->sk;
10166 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10168 + // *saddr = nsa->baddr;
10169 + // inet->inet_saddr = nsa->baddr;
10173 +int nx_info_has_v6(struct nx_info *nxi)
10177 + if (NX_IPV6(nxi))
10182 +#else /* CONFIG_IPV6 */
10185 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10192 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10198 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10204 +int nx_info_has_v6(struct nx_info *nxi)
10209 +#endif /* CONFIG_IPV6 */
10211 +#define current_nx_info_has_v6() \
10212 + nx_info_has_v6(current_nx_info())
10215 +#warning duplicate inclusion
10217 diff -NurpP --minimal linux-3.2.8/include/linux/vs_limit.h linux-3.2.8-vs2.3.2.7/include/linux/vs_limit.h
10218 --- linux-3.2.8/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10219 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_limit.h 2011-12-05 19:33:02.000000000 +0100
10221 +#ifndef _VS_LIMIT_H
10222 +#define _VS_LIMIT_H
10224 +#include "vserver/limit.h"
10225 +#include "vserver/base.h"
10226 +#include "vserver/context.h"
10227 +#include "vserver/debug.h"
10228 +#include "vserver/context.h"
10229 +#include "vserver/limit_int.h"
10232 +#define vx_acc_cres(v, d, p, r) \
10233 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10235 +#define vx_acc_cres_cond(x, d, p, r) \
10236 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10237 + r, d, p, __FILE__, __LINE__)
10240 +#define vx_add_cres(v, a, p, r) \
10241 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10242 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10244 +#define vx_add_cres_cond(x, a, p, r) \
10245 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10246 + r, a, p, __FILE__, __LINE__)
10247 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10250 +/* process and file limits */
10252 +#define vx_nproc_inc(p) \
10253 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10255 +#define vx_nproc_dec(p) \
10256 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10258 +#define vx_files_inc(f) \
10259 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10261 +#define vx_files_dec(f) \
10262 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10264 +#define vx_locks_inc(l) \
10265 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10267 +#define vx_locks_dec(l) \
10268 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10270 +#define vx_openfd_inc(f) \
10271 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10273 +#define vx_openfd_dec(f) \
10274 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10277 +#define vx_cres_avail(v, n, r) \
10278 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10281 +#define vx_nproc_avail(n) \
10282 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10284 +#define vx_files_avail(n) \
10285 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10287 +#define vx_locks_avail(n) \
10288 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10290 +#define vx_openfd_avail(n) \
10291 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10294 +/* dentry limits */
10296 +#define vx_dentry_inc(d) do { \
10297 + if ((d)->d_count == 1) \
10298 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10301 +#define vx_dentry_dec(d) do { \
10302 + if ((d)->d_count == 0) \
10303 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10306 +#define vx_dentry_avail(n) \
10307 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10310 +/* socket limits */
10312 +#define vx_sock_inc(s) \
10313 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10315 +#define vx_sock_dec(s) \
10316 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10318 +#define vx_sock_avail(n) \
10319 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10322 +/* ipc resource limits */
10324 +#define vx_ipcmsg_add(v, u, a) \
10325 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10327 +#define vx_ipcmsg_sub(v, u, a) \
10328 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10330 +#define vx_ipcmsg_avail(v, a) \
10331 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10334 +#define vx_ipcshm_add(v, k, a) \
10335 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10337 +#define vx_ipcshm_sub(v, k, a) \
10338 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10340 +#define vx_ipcshm_avail(v, a) \
10341 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10344 +#define vx_semary_inc(a) \
10345 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10347 +#define vx_semary_dec(a) \
10348 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10351 +#define vx_nsems_add(a,n) \
10352 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10354 +#define vx_nsems_sub(a,n) \
10355 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10359 +#warning duplicate inclusion
10361 diff -NurpP --minimal linux-3.2.8/include/linux/vs_network.h linux-3.2.8-vs2.3.2.7/include/linux/vs_network.h
10362 --- linux-3.2.8/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
10363 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_network.h 2011-12-05 19:33:02.000000000 +0100
10365 +#ifndef _NX_VS_NETWORK_H
10366 +#define _NX_VS_NETWORK_H
10368 +#include "vserver/context.h"
10369 +#include "vserver/network.h"
10370 +#include "vserver/base.h"
10371 +#include "vserver/check.h"
10372 +#include "vserver/debug.h"
10374 +#include <linux/sched.h>
10377 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
10379 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
10380 + const char *_file, int _line)
10385 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
10386 + nxi, nxi ? nxi->nx_id : 0,
10387 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10390 + atomic_inc(&nxi->nx_usecnt);
10395 +extern void free_nx_info(struct nx_info *);
10397 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
10399 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
10404 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
10405 + nxi, nxi ? nxi->nx_id : 0,
10406 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10409 + if (atomic_dec_and_test(&nxi->nx_usecnt))
10410 + free_nx_info(nxi);
10414 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
10416 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10417 + const char *_file, int _line)
10420 + vxlprintk(VXD_CBIT(nid, 3),
10421 + "init_nx_info(%p[#%d.%d])",
10422 + nxi, nxi ? nxi->nx_id : 0,
10423 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10426 + atomic_inc(&nxi->nx_usecnt);
10432 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
10434 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10435 + const char *_file, int _line)
10437 + struct nx_info *nxo;
10442 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
10443 + nxi, nxi ? nxi->nx_id : 0,
10444 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10447 + atomic_inc(&nxi->nx_usecnt);
10448 + nxo = xchg(nxp, nxi);
10452 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
10454 +static inline void __clr_nx_info(struct nx_info **nxp,
10455 + const char *_file, int _line)
10457 + struct nx_info *nxo;
10459 + nxo = xchg(nxp, NULL);
10463 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
10464 + nxo, nxo ? nxo->nx_id : 0,
10465 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
10468 + if (atomic_dec_and_test(&nxo->nx_usecnt))
10469 + free_nx_info(nxo);
10473 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
10475 +static inline void __claim_nx_info(struct nx_info *nxi,
10476 + struct task_struct *task, const char *_file, int _line)
10478 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
10479 + nxi, nxi ? nxi->nx_id : 0,
10480 + nxi?atomic_read(&nxi->nx_usecnt):0,
10481 + nxi?atomic_read(&nxi->nx_tasks):0,
10482 + task, _file, _line);
10484 + atomic_inc(&nxi->nx_tasks);
10488 +extern void unhash_nx_info(struct nx_info *);
10490 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
10492 +static inline void __release_nx_info(struct nx_info *nxi,
10493 + struct task_struct *task, const char *_file, int _line)
10495 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
10496 + nxi, nxi ? nxi->nx_id : 0,
10497 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10498 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
10499 + task, _file, _line);
10503 + if (atomic_dec_and_test(&nxi->nx_tasks))
10504 + unhash_nx_info(nxi);
10508 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
10510 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
10511 + const char *_file, int _line)
10513 + struct nx_info *nxi;
10516 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
10517 + p, _file, _line);
10518 + nxi = __get_nx_info(p->nx_info, _file, _line);
10524 +static inline void exit_nx_info(struct task_struct *p)
10527 + release_nx_info(p->nx_info, p);
10532 +#warning duplicate inclusion
10534 diff -NurpP --minimal linux-3.2.8/include/linux/vs_pid.h linux-3.2.8-vs2.3.2.7/include/linux/vs_pid.h
10535 --- linux-3.2.8/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
10536 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_pid.h 2011-12-05 19:33:02.000000000 +0100
10541 +#include "vserver/base.h"
10542 +#include "vserver/check.h"
10543 +#include "vserver/context.h"
10544 +#include "vserver/debug.h"
10545 +#include "vserver/pid.h"
10546 +#include <linux/pid_namespace.h>
10549 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
10552 +int vx_proc_task_visible(struct task_struct *task)
10554 + if ((task->pid == 1) &&
10555 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
10556 + /* show a blend through init */
10558 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
10565 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
10569 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
10571 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
10573 + if (task && !vx_proc_task_visible(task)) {
10574 + vxdprintk(VXD_CBIT(misc, 6),
10575 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
10576 + task, task->xid, task->pid,
10577 + current, current->xid, current->pid);
10578 + put_task_struct(task);
10586 +#warning duplicate inclusion
10588 diff -NurpP --minimal linux-3.2.8/include/linux/vs_sched.h linux-3.2.8-vs2.3.2.7/include/linux/vs_sched.h
10589 --- linux-3.2.8/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
10590 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_sched.h 2011-12-05 19:33:02.000000000 +0100
10592 +#ifndef _VS_SCHED_H
10593 +#define _VS_SCHED_H
10595 +#include "vserver/base.h"
10596 +#include "vserver/context.h"
10597 +#include "vserver/sched.h"
10600 +#define MAX_PRIO_BIAS 20
10601 +#define MIN_PRIO_BIAS -20
10604 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
10606 + struct vx_info *vxi = p->vx_info;
10609 + prio += vx_cpu(vxi, sched_pc).prio_bias;
10613 +static inline void vx_account_user(struct vx_info *vxi,
10614 + cputime_t cputime, int nice)
10618 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
10621 +static inline void vx_account_system(struct vx_info *vxi,
10622 + cputime_t cputime, int idle)
10626 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
10630 +#warning duplicate inclusion
10632 diff -NurpP --minimal linux-3.2.8/include/linux/vs_socket.h linux-3.2.8-vs2.3.2.7/include/linux/vs_socket.h
10633 --- linux-3.2.8/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
10634 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_socket.h 2011-12-05 19:33:02.000000000 +0100
10636 +#ifndef _VS_SOCKET_H
10637 +#define _VS_SOCKET_H
10639 +#include "vserver/debug.h"
10640 +#include "vserver/base.h"
10641 +#include "vserver/cacct.h"
10642 +#include "vserver/context.h"
10643 +#include "vserver/tag.h"
10646 +/* socket accounting */
10648 +#include <linux/socket.h>
10650 +static inline int vx_sock_type(int family)
10652 + switch (family) {
10654 + return VXA_SOCK_UNSPEC;
10656 + return VXA_SOCK_UNIX;
10658 + return VXA_SOCK_INET;
10660 + return VXA_SOCK_INET6;
10662 + return VXA_SOCK_PACKET;
10664 + return VXA_SOCK_OTHER;
10668 +#define vx_acc_sock(v, f, p, s) \
10669 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
10671 +static inline void __vx_acc_sock(struct vx_info *vxi,
10672 + int family, int pos, int size, char *file, int line)
10675 + int type = vx_sock_type(family);
10677 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10678 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10682 +#define vx_sock_recv(sk, s) \
10683 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10684 +#define vx_sock_send(sk, s) \
10685 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10686 +#define vx_sock_fail(sk, s) \
10687 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10690 +#define sock_vx_init(s) do { \
10691 + (s)->sk_xid = 0; \
10692 + (s)->sk_vx_info = NULL; \
10695 +#define sock_nx_init(s) do { \
10696 + (s)->sk_nid = 0; \
10697 + (s)->sk_nx_info = NULL; \
10701 +#warning duplicate inclusion
10703 diff -NurpP --minimal linux-3.2.8/include/linux/vs_tag.h linux-3.2.8-vs2.3.2.7/include/linux/vs_tag.h
10704 --- linux-3.2.8/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
10705 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_tag.h 2011-12-05 19:33:02.000000000 +0100
10710 +#include <linux/vserver/tag.h>
10712 +/* check conditions */
10714 +#define DX_ADMIN 0x0001
10715 +#define DX_WATCH 0x0002
10716 +#define DX_HOSTID 0x0008
10718 +#define DX_IDENT 0x0010
10720 +#define DX_ARG_MASK 0x0010
10723 +#define dx_task_tag(t) ((t)->tag)
10725 +#define dx_current_tag() dx_task_tag(current)
10727 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10729 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10733 + * check current context for ADMIN/WATCH and
10734 + * optionally against supplied argument
10736 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
10738 + if (mode & DX_ARG_MASK) {
10739 + if ((mode & DX_IDENT) && (id == cid))
10742 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10743 + ((mode & DX_WATCH) && (cid == 1)) ||
10744 + ((mode & DX_HOSTID) && (id == 0)));
10748 +int dx_permission(const struct inode *inode, int mask);
10752 +#warning duplicate inclusion
10754 diff -NurpP --minimal linux-3.2.8/include/linux/vs_time.h linux-3.2.8-vs2.3.2.7/include/linux/vs_time.h
10755 --- linux-3.2.8/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
10756 +++ linux-3.2.8-vs2.3.2.7/include/linux/vs_time.h 2011-12-05 19:33:02.000000000 +0100
10758 +#ifndef _VS_TIME_H
10759 +#define _VS_TIME_H
10762 +/* time faking stuff */
10764 +#ifdef CONFIG_VSERVER_VTIME
10766 +extern void vx_adjust_timespec(struct timespec *ts);
10767 +extern int vx_settimeofday(const struct timespec *ts);
10770 +#define vx_adjust_timespec(t) do { } while (0)
10771 +#define vx_settimeofday(t) do_settimeofday(t)
10775 +#warning duplicate inclusion
10777 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/Kbuild linux-3.2.8-vs2.3.2.7/include/linux/vserver/Kbuild
10778 --- linux-3.2.8/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
10779 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/Kbuild 2011-12-05 19:33:02.000000000 +0100
10782 +header-y += context_cmd.h network_cmd.h space_cmd.h \
10783 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
10784 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
10785 + debug_cmd.h device_cmd.h
10787 +header-y += switch.h network.h monitor.h inode.h device.h
10789 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/base.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/base.h
10790 --- linux-3.2.8/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10791 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/base.h 2011-12-05 19:33:02.000000000 +0100
10793 +#ifndef _VX_BASE_H
10794 +#define _VX_BASE_H
10797 +/* context state changes */
10809 +#define vx_task_xid(t) ((t)->xid)
10811 +#define vx_current_xid() vx_task_xid(current)
10813 +#define current_vx_info() (current->vx_info)
10816 +#define nx_task_nid(t) ((t)->nid)
10818 +#define nx_current_nid() nx_task_nid(current)
10820 +#define current_nx_info() (current->nx_info)
10823 +/* generic flag merging */
10825 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10827 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10829 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10831 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10834 +/* context flags */
10836 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10838 +#define vx_current_flags() __vx_flags(current_vx_info())
10840 +#define vx_info_flags(v, m, f) \
10841 + vs_check_flags(__vx_flags(v), m, f)
10843 +#define task_vx_flags(t, m, f) \
10844 + ((t) && vx_info_flags((t)->vx_info, m, f))
10846 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10849 +/* context caps */
10851 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10853 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10855 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10857 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10861 +/* network flags */
10863 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10865 +#define nx_current_flags() __nx_flags(current_nx_info())
10867 +#define nx_info_flags(n, m, f) \
10868 + vs_check_flags(__nx_flags(n), m, f)
10870 +#define task_nx_flags(t, m, f) \
10871 + ((t) && nx_info_flags((t)->nx_info, m, f))
10873 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10876 +/* network caps */
10878 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10880 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10882 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10884 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10887 +/* context mask capabilities */
10889 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10891 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10893 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10896 +/* context bcap mask */
10898 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10900 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10903 +/* mask given bcaps */
10905 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10907 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10910 +/* masked cap_bset */
10912 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10914 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10917 +#define vx_info_mbcap(v, b) \
10918 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10919 + vx_info_bcaps(v, b) : (b))
10921 +#define task_vx_mbcap(t, b) \
10922 + vx_info_mbcap((t)->vx_info, (t)->b)
10924 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10927 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10929 +#define vx_capable(b, c) (capable(b) || \
10930 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10932 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
10933 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10935 +#define nx_capable(b, c) (capable(b) || \
10936 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10938 +#define vx_task_initpid(t, n) \
10939 + ((t)->vx_info && \
10940 + ((t)->vx_info->vx_initpid == (n)))
10942 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10945 +/* context unshare mask */
10947 +#define __vx_umask(v) ((v)->vx_umask)
10949 +#define vx_current_umask() __vx_umask(current_vx_info())
10951 +#define vx_can_unshare(b, f) (capable(b) || \
10952 + (cap_raised(current_cap(), b) && \
10953 + !((f) & ~vx_current_umask())))
10956 +#define __vx_wmask(v) ((v)->vx_wmask)
10958 +#define vx_current_wmask() __vx_wmask(current_vx_info())
10961 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10963 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10966 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10968 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10971 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/cacct.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/cacct.h
10972 --- linux-3.2.8/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10973 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/cacct.h 2011-12-05 19:33:02.000000000 +0100
10975 +#ifndef _VX_CACCT_H
10976 +#define _VX_CACCT_H
10979 +enum sock_acc_field {
10980 + VXA_SOCK_UNSPEC = 0,
10986 + VXA_SOCK_SIZE /* array size */
10989 +#endif /* _VX_CACCT_H */
10990 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/cacct_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/cacct_cmd.h
10991 --- linux-3.2.8/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10992 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/cacct_cmd.h 2011-12-05 19:33:02.000000000 +0100
10994 +#ifndef _VX_CACCT_CMD_H
10995 +#define _VX_CACCT_CMD_H
10998 +/* virtual host info name commands */
11000 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
11002 +struct vcmd_sock_stat_v0 {
11004 + uint32_t count[3];
11005 + uint64_t total[3];
11011 +#include <linux/compiler.h>
11013 +extern int vc_sock_stat(struct vx_info *, void __user *);
11015 +#endif /* __KERNEL__ */
11016 +#endif /* _VX_CACCT_CMD_H */
11017 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/cacct_def.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/cacct_def.h
11018 --- linux-3.2.8/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
11019 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/cacct_def.h 2011-12-05 19:33:02.000000000 +0100
11021 +#ifndef _VX_CACCT_DEF_H
11022 +#define _VX_CACCT_DEF_H
11024 +#include <asm/atomic.h>
11025 +#include <linux/vserver/cacct.h>
11028 +struct _vx_sock_acc {
11029 + atomic_long_t count;
11030 + atomic_long_t total;
11033 +/* context sub struct */
11035 +struct _vx_cacct {
11036 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11037 + atomic_t slab[8];
11038 + atomic_t page[6][8];
11041 +#ifdef CONFIG_VSERVER_DEBUG
11043 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11047 + printk("\t_vx_cacct:");
11048 + for (i = 0; i < 6; i++) {
11049 + struct _vx_sock_acc *ptr = cacct->sock[i];
11051 + printk("\t [%d] =", i);
11052 + for (j = 0; j < 3; j++) {
11053 + printk(" [%d] = %8lu, %8lu", j,
11054 + atomic_long_read(&ptr[j].count),
11055 + atomic_long_read(&ptr[j].total));
11063 +#endif /* _VX_CACCT_DEF_H */
11064 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/cacct_int.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/cacct_int.h
11065 --- linux-3.2.8/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
11066 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/cacct_int.h 2011-12-05 19:33:02.000000000 +0100
11068 +#ifndef _VX_CACCT_INT_H
11069 +#define _VX_CACCT_INT_H
11075 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11077 + return atomic_long_read(&cacct->sock[type][pos].count);
11082 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11084 + return atomic_long_read(&cacct->sock[type][pos].total);
11087 +#endif /* __KERNEL__ */
11088 +#endif /* _VX_CACCT_INT_H */
11089 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/check.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/check.h
11090 --- linux-3.2.8/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
11091 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/check.h 2011-12-05 19:33:02.000000000 +0100
11093 +#ifndef _VS_CHECK_H
11094 +#define _VS_CHECK_H
11097 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11099 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11100 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11102 +#define MIN_D_CONTEXT 65536
11105 +/* check conditions */
11107 +#define VS_ADMIN 0x0001
11108 +#define VS_WATCH 0x0002
11109 +#define VS_HIDE 0x0004
11110 +#define VS_HOSTID 0x0008
11112 +#define VS_IDENT 0x0010
11113 +#define VS_EQUIV 0x0020
11114 +#define VS_PARENT 0x0040
11115 +#define VS_CHILD 0x0080
11117 +#define VS_ARG_MASK 0x00F0
11119 +#define VS_DYNAMIC 0x0100
11120 +#define VS_STATIC 0x0200
11122 +#define VS_ATR_MASK 0x0F00
11124 +#ifdef CONFIG_VSERVER_PRIVACY
11125 +#define VS_ADMIN_P (0)
11126 +#define VS_WATCH_P (0)
11128 +#define VS_ADMIN_P VS_ADMIN
11129 +#define VS_WATCH_P VS_WATCH
11132 +#define VS_HARDIRQ 0x1000
11133 +#define VS_SOFTIRQ 0x2000
11134 +#define VS_IRQ 0x4000
11136 +#define VS_IRQ_MASK 0xF000
11138 +#include <linux/hardirq.h>
11141 + * check current context for ADMIN/WATCH and
11142 + * optionally against supplied argument
11144 +static inline int __vs_check(int cid, int id, unsigned int mode)
11146 + if (mode & VS_ARG_MASK) {
11147 + if ((mode & VS_IDENT) && (id == cid))
11150 + if (mode & VS_ATR_MASK) {
11151 + if ((mode & VS_DYNAMIC) &&
11152 + (id >= MIN_D_CONTEXT) &&
11153 + (id <= MAX_S_CONTEXT))
11155 + if ((mode & VS_STATIC) &&
11156 + (id > 1) && (id < MIN_D_CONTEXT))
11159 + if (mode & VS_IRQ_MASK) {
11160 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11162 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11164 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11167 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11168 + ((mode & VS_WATCH) && (cid == 1)) ||
11169 + ((mode & VS_HOSTID) && (id == 0)));
11172 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11174 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11177 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11179 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11182 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/context.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/context.h
11183 --- linux-3.2.8/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11184 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/context.h 2011-12-05 19:33:02.000000000 +0100
11186 +#ifndef _VX_CONTEXT_H
11187 +#define _VX_CONTEXT_H
11189 +#include <linux/types.h>
11190 +#include <linux/capability.h>
11193 +/* context flags */
11195 +#define VXF_INFO_SCHED 0x00000002
11196 +#define VXF_INFO_NPROC 0x00000004
11197 +#define VXF_INFO_PRIVATE 0x00000008
11199 +#define VXF_INFO_INIT 0x00000010
11200 +#define VXF_INFO_HIDE 0x00000020
11201 +#define VXF_INFO_ULIMIT 0x00000040
11202 +#define VXF_INFO_NSPACE 0x00000080
11204 +#define VXF_SCHED_HARD 0x00000100
11205 +#define VXF_SCHED_PRIO 0x00000200
11206 +#define VXF_SCHED_PAUSE 0x00000400
11208 +#define VXF_VIRT_MEM 0x00010000
11209 +#define VXF_VIRT_UPTIME 0x00020000
11210 +#define VXF_VIRT_CPU 0x00040000
11211 +#define VXF_VIRT_LOAD 0x00080000
11212 +#define VXF_VIRT_TIME 0x00100000
11214 +#define VXF_HIDE_MOUNT 0x01000000
11215 +/* was VXF_HIDE_NETIF 0x02000000 */
11216 +#define VXF_HIDE_VINFO 0x04000000
11218 +#define VXF_STATE_SETUP (1ULL << 32)
11219 +#define VXF_STATE_INIT (1ULL << 33)
11220 +#define VXF_STATE_ADMIN (1ULL << 34)
11222 +#define VXF_SC_HELPER (1ULL << 36)
11223 +#define VXF_REBOOT_KILL (1ULL << 37)
11224 +#define VXF_PERSISTENT (1ULL << 38)
11226 +#define VXF_FORK_RSS (1ULL << 48)
11227 +#define VXF_PROLIFIC (1ULL << 49)
11229 +#define VXF_IGNEG_NICE (1ULL << 52)
11231 +#define VXF_ONE_TIME (0x0007ULL << 32)
11233 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11236 +/* context migration */
11238 +#define VXM_SET_INIT 0x00000001
11239 +#define VXM_SET_REAPER 0x00000002
11241 +/* context caps */
11243 +#define VXC_SET_UTSNAME 0x00000001
11244 +#define VXC_SET_RLIMIT 0x00000002
11245 +#define VXC_FS_SECURITY 0x00000004
11246 +#define VXC_FS_TRUSTED 0x00000008
11247 +#define VXC_TIOCSTI 0x00000010
11249 +/* was VXC_RAW_ICMP 0x00000100 */
11250 +#define VXC_SYSLOG 0x00001000
11251 +#define VXC_OOM_ADJUST 0x00002000
11252 +#define VXC_AUDIT_CONTROL 0x00004000
11254 +#define VXC_SECURE_MOUNT 0x00010000
11255 +#define VXC_SECURE_REMOUNT 0x00020000
11256 +#define VXC_BINARY_MOUNT 0x00040000
11258 +#define VXC_QUOTA_CTL 0x00100000
11259 +#define VXC_ADMIN_MAPPER 0x00200000
11260 +#define VXC_ADMIN_CLOOP 0x00400000
11262 +#define VXC_KTHREAD 0x01000000
11263 +#define VXC_NAMESPACE 0x02000000
11268 +#include <linux/list.h>
11269 +#include <linux/spinlock.h>
11270 +#include <linux/rcupdate.h>
11272 +#include "limit_def.h"
11273 +#include "sched_def.h"
11274 +#include "cvirt_def.h"
11275 +#include "cacct_def.h"
11276 +#include "device_def.h"
11278 +#define VX_SPACES 2
11280 +struct _vx_info_pc {
11281 + struct _vx_sched_pc sched_pc;
11282 + struct _vx_cvirt_pc cvirt_pc;
11285 +struct _vx_space {
11286 + unsigned long vx_nsmask; /* assignment mask */
11287 + struct nsproxy *vx_nsproxy; /* private namespaces */
11288 + struct fs_struct *vx_fs; /* private namespace fs */
11289 + const struct cred *vx_cred; /* task credentials */
11293 + struct hlist_node vx_hlist; /* linked list of contexts */
11294 + xid_t vx_id; /* context id */
11295 + atomic_t vx_usecnt; /* usage count */
11296 + atomic_t vx_tasks; /* tasks count */
11297 + struct vx_info *vx_parent; /* parent context */
11298 + int vx_state; /* context state */
11300 + struct _vx_space space[VX_SPACES]; /* namespace store */
11302 + uint64_t vx_flags; /* context flags */
11303 + uint64_t vx_ccaps; /* context caps (vserver) */
11304 + uint64_t vx_umask; /* unshare mask (guest) */
11305 + uint64_t vx_wmask; /* warn mask (guest) */
11306 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11308 + struct task_struct *vx_reaper; /* guest reaper process */
11309 + pid_t vx_initpid; /* PID of guest init */
11310 + int64_t vx_badness_bias; /* OOM points bias */
11312 + struct _vx_limit limit; /* vserver limits */
11313 + struct _vx_sched sched; /* vserver scheduler */
11314 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11315 + struct _vx_cacct cacct; /* context accounting */
11317 + struct _vx_device dmap; /* default device map targets */
11319 +#ifndef CONFIG_SMP
11320 + struct _vx_info_pc info_pc; /* per cpu data */
11322 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11325 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11326 + int reboot_cmd; /* last sys_reboot() cmd */
11327 + int exit_code; /* last process exit code */
11329 + char vx_name[65]; /* vserver name */
11332 +#ifndef CONFIG_SMP
11333 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11334 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11336 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11337 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11340 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11343 +struct vx_info_save {
11344 + struct vx_info *vxi;
11349 +/* status flags */
11351 +#define VXS_HASHED 0x0001
11352 +#define VXS_PAUSED 0x0010
11353 +#define VXS_SHUTDOWN 0x0100
11354 +#define VXS_HELPER 0x1000
11355 +#define VXS_RELEASED 0x8000
11358 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11359 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11361 +extern struct vx_info *lookup_vx_info(int);
11362 +extern struct vx_info *lookup_or_create_vx_info(int);
11364 +extern int get_xid_list(int, unsigned int *, int);
11365 +extern int xid_is_hashed(xid_t);
11367 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11369 +extern long vs_state_change(struct vx_info *, unsigned int);
11372 +#endif /* __KERNEL__ */
11373 +#endif /* _VX_CONTEXT_H */
11374 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/context_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/context_cmd.h
11375 --- linux-3.2.8/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
11376 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/context_cmd.h 2011-12-05 19:33:02.000000000 +0100
11378 +#ifndef _VX_CONTEXT_CMD_H
11379 +#define _VX_CONTEXT_CMD_H
11382 +/* vinfo commands */
11384 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11387 +extern int vc_task_xid(uint32_t);
11389 +#endif /* __KERNEL__ */
11391 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11393 +struct vcmd_vx_info_v0 {
11395 + uint32_t initpid;
11396 + /* more to come */
11400 +extern int vc_vx_info(struct vx_info *, void __user *);
11402 +#endif /* __KERNEL__ */
11404 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11406 +struct vcmd_ctx_stat_v0 {
11409 + /* more to come */
11413 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11415 +#endif /* __KERNEL__ */
11417 +/* context commands */
11419 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11420 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11422 +struct vcmd_ctx_create {
11423 + uint64_t flagword;
11426 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11427 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11429 +struct vcmd_ctx_migrate {
11430 + uint64_t flagword;
11434 +extern int vc_ctx_create(uint32_t, void __user *);
11435 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11437 +#endif /* __KERNEL__ */
11440 +/* flag commands */
11442 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11443 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11445 +struct vcmd_ctx_flags_v0 {
11446 + uint64_t flagword;
11451 +extern int vc_get_cflags(struct vx_info *, void __user *);
11452 +extern int vc_set_cflags(struct vx_info *, void __user *);
11454 +#endif /* __KERNEL__ */
11457 +/* context caps commands */
11459 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
11460 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
11462 +struct vcmd_ctx_caps_v1 {
11468 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11469 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11471 +#endif /* __KERNEL__ */
11474 +/* bcaps commands */
11476 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
11477 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
11479 +struct vcmd_bcaps {
11485 +extern int vc_get_bcaps(struct vx_info *, void __user *);
11486 +extern int vc_set_bcaps(struct vx_info *, void __user *);
11488 +#endif /* __KERNEL__ */
11491 +/* umask commands */
11493 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
11494 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
11496 +struct vcmd_umask {
11502 +extern int vc_get_umask(struct vx_info *, void __user *);
11503 +extern int vc_set_umask(struct vx_info *, void __user *);
11505 +#endif /* __KERNEL__ */
11508 +/* wmask commands */
11510 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
11511 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
11513 +struct vcmd_wmask {
11519 +extern int vc_get_wmask(struct vx_info *, void __user *);
11520 +extern int vc_set_wmask(struct vx_info *, void __user *);
11522 +#endif /* __KERNEL__ */
11527 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
11528 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
11530 +struct vcmd_badness_v0 {
11535 +extern int vc_get_badness(struct vx_info *, void __user *);
11536 +extern int vc_set_badness(struct vx_info *, void __user *);
11538 +#endif /* __KERNEL__ */
11539 +#endif /* _VX_CONTEXT_CMD_H */
11540 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/cvirt.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/cvirt.h
11541 --- linux-3.2.8/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11542 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/cvirt.h 2011-12-05 19:33:02.000000000 +0100
11544 +#ifndef _VX_CVIRT_H
11545 +#define _VX_CVIRT_H
11552 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11557 +void vx_update_load(struct vx_info *);
11560 +int vx_do_syslog(int, char __user *, int);
11562 +#endif /* __KERNEL__ */
11563 +#endif /* _VX_CVIRT_H */
11564 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/cvirt_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/cvirt_cmd.h
11565 --- linux-3.2.8/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11566 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/cvirt_cmd.h 2011-12-05 19:33:02.000000000 +0100
11568 +#ifndef _VX_CVIRT_CMD_H
11569 +#define _VX_CVIRT_CMD_H
11572 +/* virtual host info name commands */
11574 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11575 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11577 +struct vcmd_vhi_name_v0 {
11583 +enum vhi_name_field {
11584 + VHIN_CONTEXT = 0,
11596 +#include <linux/compiler.h>
11598 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11599 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11601 +#endif /* __KERNEL__ */
11603 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11605 +struct vcmd_virt_stat_v0 {
11608 + uint32_t nr_threads;
11609 + uint32_t nr_running;
11610 + uint32_t nr_uninterruptible;
11611 + uint32_t nr_onhold;
11612 + uint32_t nr_forks;
11613 + uint32_t load[3];
11617 +extern int vc_virt_stat(struct vx_info *, void __user *);
11619 +#endif /* __KERNEL__ */
11620 +#endif /* _VX_CVIRT_CMD_H */
11621 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/cvirt_def.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/cvirt_def.h
11622 --- linux-3.2.8/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11623 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/cvirt_def.h 2011-12-05 19:33:02.000000000 +0100
11625 +#ifndef _VX_CVIRT_DEF_H
11626 +#define _VX_CVIRT_DEF_H
11628 +#include <linux/jiffies.h>
11629 +#include <linux/spinlock.h>
11630 +#include <linux/wait.h>
11631 +#include <linux/time.h>
11632 +#include <asm/atomic.h>
11635 +struct _vx_usage_stat {
11639 + uint64_t softirq;
11645 +struct _vx_syslog {
11646 + wait_queue_head_t log_wait;
11647 + spinlock_t logbuf_lock; /* lock for the log buffer */
11649 + unsigned long log_start; /* next char to be read by syslog() */
11650 + unsigned long con_start; /* next char to be sent to consoles */
11651 + unsigned long log_end; /* most-recently-written-char + 1 */
11652 + unsigned long logged_chars; /* #chars since last read+clear operation */
11654 + char log_buf[1024];
11658 +/* context sub struct */
11660 +struct _vx_cvirt {
11661 + atomic_t nr_threads; /* number of current threads */
11662 + atomic_t nr_running; /* number of running threads */
11663 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11665 + atomic_t nr_onhold; /* processes on hold */
11666 + uint32_t onhold_last; /* jiffies when put on hold */
11668 + struct timespec bias_ts; /* time offset to the host */
11669 + struct timespec bias_idle;
11670 + struct timespec bias_uptime; /* context creation point */
11671 + uint64_t bias_clock; /* offset in clock_t */
11673 + spinlock_t load_lock; /* lock for the load averages */
11674 + atomic_t load_updates; /* nr of load updates done so far */
11675 + uint32_t load_last; /* last time load was calculated */
11676 + uint32_t load[3]; /* load averages 1,5,15 */
11678 + atomic_t total_forks; /* number of forks so far */
11680 + struct _vx_syslog syslog;
11683 +struct _vx_cvirt_pc {
11684 + struct _vx_usage_stat cpustat;
11688 +#ifdef CONFIG_VSERVER_DEBUG
11690 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11692 + printk("\t_vx_cvirt:\n");
11693 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11694 + atomic_read(&cvirt->nr_threads),
11695 + atomic_read(&cvirt->nr_running),
11696 + atomic_read(&cvirt->nr_uninterruptible),
11697 + atomic_read(&cvirt->nr_onhold));
11698 + /* add rest here */
11699 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11704 +#endif /* _VX_CVIRT_DEF_H */
11705 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/debug.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/debug.h
11706 --- linux-3.2.8/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11707 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/debug.h 2011-12-05 19:33:02.000000000 +0100
11709 +#ifndef _VX_DEBUG_H
11710 +#define _VX_DEBUG_H
11713 +#define VXD_CBIT(n, m) (vs_debug_ ## n & (1 << (m)))
11714 +#define VXD_CMIN(n, m) (vs_debug_ ## n > (m))
11715 +#define VXD_MASK(n, m) (vs_debug_ ## n & (m))
11717 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11718 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11719 +#define VXF_DEV "%p[%lu,%d:%d]"
11721 +#if defined(CONFIG_QUOTES_UTF8)
11722 +#define VS_Q_LQM "\xc2\xbb"
11723 +#define VS_Q_RQM "\xc2\xab"
11724 +#elif defined(CONFIG_QUOTES_ASCII)
11725 +#define VS_Q_LQM "\x27"
11726 +#define VS_Q_RQM "\x27"
11728 +#define VS_Q_LQM "\xbb"
11729 +#define VS_Q_RQM "\xab"
11732 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
11735 +#define vxd_path(p) \
11736 + ({ static char _buffer[PATH_MAX]; \
11737 + d_path(p, _buffer, sizeof(_buffer)); })
11739 +#define vxd_cond_path(n) \
11740 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11743 +#ifdef CONFIG_VSERVER_DEBUG
11745 +extern unsigned int vs_debug_switch;
11746 +extern unsigned int vs_debug_xid;
11747 +extern unsigned int vs_debug_nid;
11748 +extern unsigned int vs_debug_tag;
11749 +extern unsigned int vs_debug_net;
11750 +extern unsigned int vs_debug_limit;
11751 +extern unsigned int vs_debug_cres;
11752 +extern unsigned int vs_debug_dlim;
11753 +extern unsigned int vs_debug_quota;
11754 +extern unsigned int vs_debug_cvirt;
11755 +extern unsigned int vs_debug_space;
11756 +extern unsigned int vs_debug_perm;
11757 +extern unsigned int vs_debug_misc;
11760 +#define VX_LOGLEVEL "vxD: "
11761 +#define VX_PROC_FMT "%p: "
11762 +#define VX_PROCESS current
11764 +#define vxdprintk(c, f, x...) \
11767 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11768 + VX_PROCESS , ##x); \
11771 +#define vxlprintk(c, f, x...) \
11774 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11777 +#define vxfprintk(c, f, x...) \
11780 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11786 +void dump_vx_info(struct vx_info *, int);
11787 +void dump_vx_info_inactive(int);
11789 +#else /* CONFIG_VSERVER_DEBUG */
11791 +#define vs_debug_switch 0
11792 +#define vs_debug_xid 0
11793 +#define vs_debug_nid 0
11794 +#define vs_debug_tag 0
11795 +#define vs_debug_net 0
11796 +#define vs_debug_limit 0
11797 +#define vs_debug_cres 0
11798 +#define vs_debug_dlim 0
11799 +#define vs_debug_quota 0
11800 +#define vs_debug_cvirt 0
11801 +#define vs_debug_space 0
11802 +#define vs_debug_perm 0
11803 +#define vs_debug_misc 0
11805 +#define vxdprintk(x...) do { } while (0)
11806 +#define vxlprintk(x...) do { } while (0)
11807 +#define vxfprintk(x...) do { } while (0)
11809 +#endif /* CONFIG_VSERVER_DEBUG */
11812 +#ifdef CONFIG_VSERVER_WARN
11814 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11815 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
11816 +#define VX_WARN_XID "[xid #%u] "
11817 +#define VX_WARN_NID "[nid #%u] "
11818 +#define VX_WARN_TAG "[tag #%u] "
11820 +#define vxwprintk(c, f, x...) \
11823 + printk(VX_WARNLEVEL f "\n", ##x); \
11826 +#else /* CONFIG_VSERVER_WARN */
11828 +#define vxwprintk(x...) do { } while (0)
11830 +#endif /* CONFIG_VSERVER_WARN */
11832 +#define vxwprintk_task(c, f, x...) \
11833 + vxwprintk(c, VX_WARN_TASK f, \
11834 + current->comm, current->pid, \
11835 + current->xid, current->nid, current->tag, ##x)
11836 +#define vxwprintk_xid(c, f, x...) \
11837 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11838 +#define vxwprintk_nid(c, f, x...) \
11839 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11840 +#define vxwprintk_tag(c, f, x...) \
11841 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11843 +#ifdef CONFIG_VSERVER_DEBUG
11844 +#define vxd_assert_lock(l) assert_spin_locked(l)
11845 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11846 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11848 +#define vxd_assert_lock(l) do { } while (0)
11849 +#define vxd_assert(c, f, x...) do { } while (0)
11853 +#endif /* _VX_DEBUG_H */
11854 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/debug_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/debug_cmd.h
11855 --- linux-3.2.8/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11856 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/debug_cmd.h 2011-12-05 19:33:02.000000000 +0100
11858 +#ifndef _VX_DEBUG_CMD_H
11859 +#define _VX_DEBUG_CMD_H
11862 +/* debug commands */
11864 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11866 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11867 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11869 +struct vcmd_read_history_v0 {
11872 + char __user *data;
11875 +struct vcmd_read_monitor_v0 {
11878 + char __user *data;
11884 +#ifdef CONFIG_COMPAT
11886 +#include <asm/compat.h>
11888 +struct vcmd_read_history_v0_x32 {
11891 + compat_uptr_t data_ptr;
11894 +struct vcmd_read_monitor_v0_x32 {
11897 + compat_uptr_t data_ptr;
11900 +#endif /* CONFIG_COMPAT */
11902 +extern int vc_dump_history(uint32_t);
11904 +extern int vc_read_history(uint32_t, void __user *);
11905 +extern int vc_read_monitor(uint32_t, void __user *);
11907 +#ifdef CONFIG_COMPAT
11909 +extern int vc_read_history_x32(uint32_t, void __user *);
11910 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11912 +#endif /* CONFIG_COMPAT */
11914 +#endif /* __KERNEL__ */
11915 +#endif /* _VX_DEBUG_CMD_H */
11916 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/device.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/device.h
11917 --- linux-3.2.8/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11918 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/device.h 2011-12-05 19:33:02.000000000 +0100
11920 +#ifndef _VX_DEVICE_H
11921 +#define _VX_DEVICE_H
11924 +#define DATTR_CREATE 0x00000001
11925 +#define DATTR_OPEN 0x00000002
11927 +#define DATTR_REMAP 0x00000010
11929 +#define DATTR_MASK 0x00000013
11932 +#else /* _VX_DEVICE_H */
11933 +#warning duplicate inclusion
11934 +#endif /* _VX_DEVICE_H */
11935 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/device_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/device_cmd.h
11936 --- linux-3.2.8/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11937 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/device_cmd.h 2011-12-05 19:33:02.000000000 +0100
11939 +#ifndef _VX_DEVICE_CMD_H
11940 +#define _VX_DEVICE_CMD_H
11943 +/* device vserver commands */
11945 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11946 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11948 +struct vcmd_set_mapping_v0 {
11949 + const char __user *device;
11950 + const char __user *target;
11957 +#ifdef CONFIG_COMPAT
11959 +#include <asm/compat.h>
11961 +struct vcmd_set_mapping_v0_x32 {
11962 + compat_uptr_t device_ptr;
11963 + compat_uptr_t target_ptr;
11967 +#endif /* CONFIG_COMPAT */
11969 +#include <linux/compiler.h>
11971 +extern int vc_set_mapping(struct vx_info *, void __user *);
11972 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11974 +#ifdef CONFIG_COMPAT
11976 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11977 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11979 +#endif /* CONFIG_COMPAT */
11981 +#endif /* __KERNEL__ */
11982 +#endif /* _VX_DEVICE_CMD_H */
11983 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/device_def.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/device_def.h
11984 --- linux-3.2.8/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11985 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/device_def.h 2011-12-05 19:33:02.000000000 +0100
11987 +#ifndef _VX_DEVICE_DEF_H
11988 +#define _VX_DEVICE_DEF_H
11990 +#include <linux/types.h>
11992 +struct vx_dmap_target {
11997 +struct _vx_device {
11998 +#ifdef CONFIG_VSERVER_DEVICE
11999 + struct vx_dmap_target targets[2];
12003 +#endif /* _VX_DEVICE_DEF_H */
12004 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/dlimit.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/dlimit.h
12005 --- linux-3.2.8/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12006 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/dlimit.h 2011-12-05 19:33:02.000000000 +0100
12008 +#ifndef _VX_DLIMIT_H
12009 +#define _VX_DLIMIT_H
12011 +#include "switch.h"
12016 +/* keep in sync with CDLIM_INFINITY */
12018 +#define DLIM_INFINITY (~0ULL)
12020 +#include <linux/spinlock.h>
12021 +#include <linux/rcupdate.h>
12023 +struct super_block;
12026 + struct hlist_node dl_hlist; /* linked list of contexts */
12027 + struct rcu_head dl_rcu; /* the rcu head */
12028 + tag_t dl_tag; /* context tag */
12029 + atomic_t dl_usecnt; /* usage count */
12030 + atomic_t dl_refcnt; /* reference count */
12032 + struct super_block *dl_sb; /* associated superblock */
12034 + spinlock_t dl_lock; /* protect the values */
12036 + unsigned long long dl_space_used; /* used space in bytes */
12037 + unsigned long long dl_space_total; /* maximum space in bytes */
12038 + unsigned long dl_inodes_used; /* used inodes */
12039 + unsigned long dl_inodes_total; /* maximum inodes */
12041 + unsigned int dl_nrlmult; /* non root limit mult */
12046 +extern void rcu_free_dl_info(struct rcu_head *);
12047 +extern void unhash_dl_info(struct dl_info *);
12049 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12054 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12056 +typedef uint64_t dlsize_t;
12058 +#endif /* __KERNEL__ */
12059 +#else /* _VX_DLIMIT_H */
12060 +#warning duplicate inclusion
12061 +#endif /* _VX_DLIMIT_H */
12062 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/dlimit_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/dlimit_cmd.h
12063 --- linux-3.2.8/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12064 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/dlimit_cmd.h 2011-12-05 19:33:02.000000000 +0100
12066 +#ifndef _VX_DLIMIT_CMD_H
12067 +#define _VX_DLIMIT_CMD_H
12070 +/* dlimit vserver commands */
12072 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12073 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12075 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12076 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12078 +struct vcmd_ctx_dlimit_base_v0 {
12079 + const char __user *name;
12083 +struct vcmd_ctx_dlimit_v0 {
12084 + const char __user *name;
12085 + uint32_t space_used; /* used space in kbytes */
12086 + uint32_t space_total; /* maximum space in kbytes */
12087 + uint32_t inodes_used; /* used inodes */
12088 + uint32_t inodes_total; /* maximum inodes */
12089 + uint32_t reserved; /* reserved for root in % */
12093 +#define CDLIM_UNSET ((uint32_t)0UL)
12094 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12095 +#define CDLIM_KEEP ((uint32_t)~1UL)
12097 +#define DLIME_UNIT 0
12098 +#define DLIME_KILO 1
12099 +#define DLIME_MEGA 2
12100 +#define DLIME_GIGA 3
12102 +#define DLIMF_SHIFT 0x10
12104 +#define DLIMS_USED 0
12105 +#define DLIMS_TOTAL 2
12108 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12110 + int exp = (flags & DLIMF_SHIFT) ?
12111 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12112 + return ((uint64_t)val) << (10 * exp);
12116 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12120 + if (*flags & DLIMF_SHIFT) {
12121 + while (val > (1LL << 32) && (exp < 3)) {
12125 + *flags &= ~(DLIME_GIGA << shift);
12126 + *flags |= exp << shift;
12134 +#ifdef CONFIG_COMPAT
12136 +#include <asm/compat.h>
12138 +struct vcmd_ctx_dlimit_base_v0_x32 {
12139 + compat_uptr_t name_ptr;
12143 +struct vcmd_ctx_dlimit_v0_x32 {
12144 + compat_uptr_t name_ptr;
12145 + uint32_t space_used; /* used space in kbytes */
12146 + uint32_t space_total; /* maximum space in kbytes */
12147 + uint32_t inodes_used; /* used inodes */
12148 + uint32_t inodes_total; /* maximum inodes */
12149 + uint32_t reserved; /* reserved for root in % */
12153 +#endif /* CONFIG_COMPAT */
12155 +#include <linux/compiler.h>
12157 +extern int vc_add_dlimit(uint32_t, void __user *);
12158 +extern int vc_rem_dlimit(uint32_t, void __user *);
12160 +extern int vc_set_dlimit(uint32_t, void __user *);
12161 +extern int vc_get_dlimit(uint32_t, void __user *);
12163 +#ifdef CONFIG_COMPAT
12165 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12166 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12168 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12169 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12171 +#endif /* CONFIG_COMPAT */
12173 +#endif /* __KERNEL__ */
12174 +#endif /* _VX_DLIMIT_CMD_H */
12175 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/global.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/global.h
12176 --- linux-3.2.8/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12177 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/global.h 2011-12-05 19:33:02.000000000 +0100
12179 +#ifndef _VX_GLOBAL_H
12180 +#define _VX_GLOBAL_H
12183 +extern atomic_t vx_global_ctotal;
12184 +extern atomic_t vx_global_cactive;
12186 +extern atomic_t nx_global_ctotal;
12187 +extern atomic_t nx_global_cactive;
12189 +extern atomic_t vs_global_nsproxy;
12190 +extern atomic_t vs_global_fs;
12191 +extern atomic_t vs_global_mnt_ns;
12192 +extern atomic_t vs_global_uts_ns;
12193 +extern atomic_t vs_global_user_ns;
12194 +extern atomic_t vs_global_pid_ns;
12197 +#endif /* _VX_GLOBAL_H */
12198 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/history.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/history.h
12199 --- linux-3.2.8/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12200 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/history.h 2011-12-05 19:33:02.000000000 +0100
12202 +#ifndef _VX_HISTORY_H
12203 +#define _VX_HISTORY_H
12208 + VXH_THROW_OOPS = 1,
12212 + VXH_INIT_VX_INFO,
12215 + VXH_CLAIM_VX_INFO,
12216 + VXH_RELEASE_VX_INFO,
12217 + VXH_ALLOC_VX_INFO,
12218 + VXH_DEALLOC_VX_INFO,
12219 + VXH_HASH_VX_INFO,
12220 + VXH_UNHASH_VX_INFO,
12222 + VXH_LOOKUP_VX_INFO,
12223 + VXH_CREATE_VX_INFO,
12226 +struct _vxhe_vxi {
12227 + struct vx_info *ptr;
12233 +struct _vxhe_set_clr {
12237 +struct _vxhe_loc_lookup {
12241 +struct _vx_hist_entry {
12243 + unsigned short seq;
12244 + unsigned short type;
12245 + struct _vxhe_vxi vxi;
12247 + struct _vxhe_set_clr sc;
12248 + struct _vxhe_loc_lookup ll;
12252 +#ifdef CONFIG_VSERVER_HISTORY
12254 +extern unsigned volatile int vxh_active;
12256 +struct _vx_hist_entry *vxh_advance(void *loc);
12260 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12262 + entry->vxi.ptr = vxi;
12264 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12265 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12266 + entry->vxi.xid = vxi->vx_id;
12271 +#define __HERE__ current_text_addr()
12273 +#define __VXH_BODY(__type, __data, __here) \
12274 + struct _vx_hist_entry *entry; \
12276 + preempt_disable(); \
12277 + entry = vxh_advance(__here); \
12279 + entry->type = __type; \
12280 + preempt_enable();
12283 + /* pass vxi only */
12285 +#define __VXH_SMPL \
12286 + __vxh_copy_vxi(entry, vxi)
12289 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12291 + __VXH_BODY(__type, __VXH_SMPL, __here)
12294 + /* pass vxi and data (void *) */
12296 +#define __VXH_DATA \
12297 + __vxh_copy_vxi(entry, vxi); \
12298 + entry->sc.data = data
12301 +void __vxh_data(struct vx_info *vxi, void *data,
12302 + int __type, void *__here)
12304 + __VXH_BODY(__type, __VXH_DATA, __here)
12307 + /* pass vxi and arg (long) */
12309 +#define __VXH_LONG \
12310 + __vxh_copy_vxi(entry, vxi); \
12311 + entry->ll.arg = arg
12314 +void __vxh_long(struct vx_info *vxi, long arg,
12315 + int __type, void *__here)
12317 + __VXH_BODY(__type, __VXH_LONG, __here)
12322 +void __vxh_throw_oops(void *__here)
12324 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12325 + /* prevent further acquisition */
12330 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12332 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12333 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12335 +#define __vxh_init_vx_info(v, d, h) \
12336 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12337 +#define __vxh_set_vx_info(v, d, h) \
12338 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12339 +#define __vxh_clr_vx_info(v, d, h) \
12340 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12342 +#define __vxh_claim_vx_info(v, d, h) \
12343 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12344 +#define __vxh_release_vx_info(v, d, h) \
12345 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12347 +#define vxh_alloc_vx_info(v) \
12348 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12349 +#define vxh_dealloc_vx_info(v) \
12350 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12352 +#define vxh_hash_vx_info(v) \
12353 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12354 +#define vxh_unhash_vx_info(v) \
12355 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12357 +#define vxh_loc_vx_info(v, l) \
12358 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12359 +#define vxh_lookup_vx_info(v, l) \
12360 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12361 +#define vxh_create_vx_info(v, l) \
12362 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12364 +extern void vxh_dump_history(void);
12367 +#else /* CONFIG_VSERVER_HISTORY */
12369 +#define __HERE__ 0
12371 +#define vxh_throw_oops() do { } while (0)
12373 +#define __vxh_get_vx_info(v, h) do { } while (0)
12374 +#define __vxh_put_vx_info(v, h) do { } while (0)
12376 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12377 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12378 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12380 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12381 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12383 +#define vxh_alloc_vx_info(v) do { } while (0)
12384 +#define vxh_dealloc_vx_info(v) do { } while (0)
12386 +#define vxh_hash_vx_info(v) do { } while (0)
12387 +#define vxh_unhash_vx_info(v) do { } while (0)
12389 +#define vxh_loc_vx_info(v, l) do { } while (0)
12390 +#define vxh_lookup_vx_info(v, l) do { } while (0)
12391 +#define vxh_create_vx_info(v, l) do { } while (0)
12393 +#define vxh_dump_history() do { } while (0)
12396 +#endif /* CONFIG_VSERVER_HISTORY */
12398 +#endif /* _VX_HISTORY_H */
12399 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/inode.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/inode.h
12400 --- linux-3.2.8/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
12401 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/inode.h 2011-12-05 19:33:02.000000000 +0100
12403 +#ifndef _VX_INODE_H
12404 +#define _VX_INODE_H
12407 +#define IATTR_TAG 0x01000000
12409 +#define IATTR_ADMIN 0x00000001
12410 +#define IATTR_WATCH 0x00000002
12411 +#define IATTR_HIDE 0x00000004
12412 +#define IATTR_FLAGS 0x00000007
12414 +#define IATTR_BARRIER 0x00010000
12415 +#define IATTR_IXUNLINK 0x00020000
12416 +#define IATTR_IMMUTABLE 0x00040000
12417 +#define IATTR_COW 0x00080000
12422 +#ifdef CONFIG_VSERVER_PROC_SECURE
12423 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12424 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12426 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12427 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12430 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12432 +#endif /* __KERNEL__ */
12434 +/* inode ioctls */
12436 +#define FIOC_GETXFLG _IOR('x', 5, long)
12437 +#define FIOC_SETXFLG _IOW('x', 6, long)
12439 +#else /* _VX_INODE_H */
12440 +#warning duplicate inclusion
12441 +#endif /* _VX_INODE_H */
12442 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/inode_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/inode_cmd.h
12443 --- linux-3.2.8/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
12444 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/inode_cmd.h 2011-12-05 19:33:02.000000000 +0100
12446 +#ifndef _VX_INODE_CMD_H
12447 +#define _VX_INODE_CMD_H
12450 +/* inode vserver commands */
12452 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12453 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12455 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12456 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12458 +struct vcmd_ctx_iattr_v1 {
12459 + const char __user *name;
12465 +struct vcmd_ctx_fiattr_v0 {
12475 +#ifdef CONFIG_COMPAT
12477 +#include <asm/compat.h>
12479 +struct vcmd_ctx_iattr_v1_x32 {
12480 + compat_uptr_t name_ptr;
12486 +#endif /* CONFIG_COMPAT */
12488 +#include <linux/compiler.h>
12490 +extern int vc_get_iattr(void __user *);
12491 +extern int vc_set_iattr(void __user *);
12493 +extern int vc_fget_iattr(uint32_t, void __user *);
12494 +extern int vc_fset_iattr(uint32_t, void __user *);
12496 +#ifdef CONFIG_COMPAT
12498 +extern int vc_get_iattr_x32(void __user *);
12499 +extern int vc_set_iattr_x32(void __user *);
12501 +#endif /* CONFIG_COMPAT */
12503 +#endif /* __KERNEL__ */
12504 +#endif /* _VX_INODE_CMD_H */
12505 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/limit.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/limit.h
12506 --- linux-3.2.8/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12507 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/limit.h 2011-12-05 19:33:02.000000000 +0100
12509 +#ifndef _VX_LIMIT_H
12510 +#define _VX_LIMIT_H
12512 +#define VLIMIT_NSOCK 16
12513 +#define VLIMIT_OPENFD 17
12514 +#define VLIMIT_ANON 18
12515 +#define VLIMIT_SHMEM 19
12516 +#define VLIMIT_SEMARY 20
12517 +#define VLIMIT_NSEMS 21
12518 +#define VLIMIT_DENTRY 22
12519 +#define VLIMIT_MAPPED 23
12524 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12526 +/* keep in sync with CRLIM_INFINITY */
12528 +#define VLIM_INFINITY (~0ULL)
12530 +#include <asm/atomic.h>
12531 +#include <asm/resource.h>
12533 +#ifndef RLIM_INFINITY
12534 +#warning RLIM_INFINITY is undefined
12537 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12539 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12540 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12542 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12543 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12544 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12546 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12547 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12549 +typedef atomic_long_t rlim_atomic_t;
12550 +typedef unsigned long rlim_t;
12552 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12553 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12554 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12555 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12556 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12557 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12560 +#if (RLIM_INFINITY == VLIM_INFINITY)
12561 +#define VX_VLIM(r) ((long long)(long)(r))
12562 +#define VX_RLIM(v) ((rlim_t)(v))
12564 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12565 + ? VLIM_INFINITY : (long long)(r))
12566 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12567 + ? RLIM_INFINITY : (rlim_t)(v))
12572 +void vx_vsi_meminfo(struct sysinfo *);
12573 +void vx_vsi_swapinfo(struct sysinfo *);
12574 +long vx_vsi_cached(struct sysinfo *);
12576 +#define NUM_LIMITS 24
12578 +#endif /* __KERNEL__ */
12579 +#endif /* _VX_LIMIT_H */
12580 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/limit_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/limit_cmd.h
12581 --- linux-3.2.8/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12582 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/limit_cmd.h 2011-12-05 19:33:02.000000000 +0100
12584 +#ifndef _VX_LIMIT_CMD_H
12585 +#define _VX_LIMIT_CMD_H
12588 +/* rlimit vserver commands */
12590 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12591 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12592 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12593 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
12594 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12596 +struct vcmd_ctx_rlimit_v0 {
12598 + uint64_t minimum;
12599 + uint64_t softlimit;
12600 + uint64_t maximum;
12603 +struct vcmd_ctx_rlimit_mask_v0 {
12604 + uint32_t minimum;
12605 + uint32_t softlimit;
12606 + uint32_t maximum;
12609 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12611 +struct vcmd_rlimit_stat_v0 {
12615 + uint64_t minimum;
12616 + uint64_t maximum;
12619 +#define CRLIM_UNSET (0ULL)
12620 +#define CRLIM_INFINITY (~0ULL)
12621 +#define CRLIM_KEEP (~1ULL)
12625 +#ifdef CONFIG_IA32_EMULATION
12627 +struct vcmd_ctx_rlimit_v0_x32 {
12629 + uint64_t minimum;
12630 + uint64_t softlimit;
12631 + uint64_t maximum;
12632 +} __attribute__ ((packed));
12634 +#endif /* CONFIG_IA32_EMULATION */
12636 +#include <linux/compiler.h>
12638 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12639 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12640 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12641 +extern int vc_reset_hits(struct vx_info *, void __user *);
12642 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12644 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12646 +#ifdef CONFIG_IA32_EMULATION
12648 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12649 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12651 +#endif /* CONFIG_IA32_EMULATION */
12653 +#endif /* __KERNEL__ */
12654 +#endif /* _VX_LIMIT_CMD_H */
12655 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/limit_def.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/limit_def.h
12656 --- linux-3.2.8/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12657 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/limit_def.h 2011-12-05 19:33:02.000000000 +0100
12659 +#ifndef _VX_LIMIT_DEF_H
12660 +#define _VX_LIMIT_DEF_H
12662 +#include <asm/atomic.h>
12663 +#include <asm/resource.h>
12665 +#include "limit.h"
12668 +struct _vx_res_limit {
12669 + rlim_t soft; /* Context soft limit */
12670 + rlim_t hard; /* Context hard limit */
12672 + rlim_atomic_t rcur; /* Current value */
12673 + rlim_t rmin; /* Context minimum */
12674 + rlim_t rmax; /* Context maximum */
12676 + atomic_t lhit; /* Limit hits */
12679 +/* context sub struct */
12681 +struct _vx_limit {
12682 + struct _vx_res_limit res[NUM_LIMITS];
12685 +#ifdef CONFIG_VSERVER_DEBUG
12687 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12691 + printk("\t_vx_limit:");
12692 + for (i = 0; i < NUM_LIMITS; i++) {
12693 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12694 + i, (unsigned long)__rlim_get(limit, i),
12695 + (unsigned long)__rlim_rmin(limit, i),
12696 + (unsigned long)__rlim_rmax(limit, i),
12697 + (long)__rlim_soft(limit, i),
12698 + (long)__rlim_hard(limit, i),
12699 + atomic_read(&__rlim_lhit(limit, i)));
12705 +#endif /* _VX_LIMIT_DEF_H */
12706 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/limit_int.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/limit_int.h
12707 --- linux-3.2.8/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12708 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/limit_int.h 2011-12-05 19:33:02.000000000 +0100
12710 +#ifndef _VX_LIMIT_INT_H
12711 +#define _VX_LIMIT_INT_H
12713 +#include "context.h"
12717 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12718 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12720 +extern const char *vlimit_name[NUM_LIMITS];
12722 +static inline void __vx_acc_cres(struct vx_info *vxi,
12723 + int res, int dir, void *_data, char *_file, int _line)
12725 + if (VXD_RCRES_COND(res))
12726 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12727 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12728 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12729 + (dir > 0) ? "++" : "--", _data, _file, _line);
12734 + __rlim_inc(&vxi->limit, res);
12736 + __rlim_dec(&vxi->limit, res);
12739 +static inline void __vx_add_cres(struct vx_info *vxi,
12740 + int res, int amount, void *_data, char *_file, int _line)
12742 + if (VXD_RCRES_COND(res))
12743 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12744 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12745 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12746 + amount, _data, _file, _line);
12751 + __rlim_add(&vxi->limit, res, amount);
12755 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12757 + int cond = (value > __rlim_rmax(limit, res));
12760 + __rlim_rmax(limit, res) = value;
12765 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12767 + int cond = (value < __rlim_rmin(limit, res));
12770 + __rlim_rmin(limit, res) = value;
12775 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12777 + if (!__vx_cres_adjust_max(limit, res, value))
12778 + __vx_cres_adjust_min(limit, res, value);
12783 + +1 ... no limit hit
12784 + -1 ... over soft limit
12785 + 0 ... over hard limit */
12787 +static inline int __vx_cres_avail(struct vx_info *vxi,
12788 + int res, int num, char *_file, int _line)
12790 + struct _vx_limit *limit;
12793 + if (VXD_RLIMIT_COND(res))
12794 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12795 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12796 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12797 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12798 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12799 + num, _file, _line);
12803 + limit = &vxi->limit;
12804 + value = __rlim_get(limit, res);
12806 + if (!__vx_cres_adjust_max(limit, res, value))
12807 + __vx_cres_adjust_min(limit, res, value);
12812 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12814 + if (value + num <= __rlim_soft(limit, res))
12817 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12819 + if (value + num <= __rlim_hard(limit, res))
12822 + __rlim_hit(limit, res);
12827 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12830 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12832 + rlim_t value, sum = 0;
12835 + while ((res = *array++)) {
12836 + value = __rlim_get(limit, res);
12837 + __vx_cres_fixup(limit, res, value);
12844 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12846 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12847 + int res = *array;
12849 + if (value == __rlim_get(limit, res))
12852 + __rlim_set(limit, res, value);
12853 + /* now adjust min/max */
12854 + if (!__vx_cres_adjust_max(limit, res, value))
12855 + __vx_cres_adjust_min(limit, res, value);
12860 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12861 + const int *array, int num, char *_file, int _line)
12863 + struct _vx_limit *limit;
12864 + rlim_t value = 0;
12872 + limit = &vxi->limit;
12874 + value = __vx_cres_array_sum(limit, array + 1);
12876 + __rlim_set(limit, res, value);
12877 + __vx_cres_fixup(limit, res, value);
12879 + return __vx_cres_avail(vxi, res, num, _file, _line);
12883 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12888 + /* complex resources first */
12889 + if ((id < 0) || (id == RLIMIT_RSS))
12890 + __vx_cres_array_fixup(limit, VLA_RSS);
12892 + for (res = 0; res < NUM_LIMITS; res++) {
12893 + if ((id > 0) && (res != id))
12896 + value = __rlim_get(limit, res);
12897 + __vx_cres_fixup(limit, res, value);
12899 + /* not supposed to happen, maybe warn? */
12900 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12901 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12906 +#endif /* __KERNEL__ */
12907 +#endif /* _VX_LIMIT_INT_H */
12908 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/monitor.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/monitor.h
12909 --- linux-3.2.8/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12910 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/monitor.h 2011-12-05 19:33:02.000000000 +0100
12912 +#ifndef _VX_MONITOR_H
12913 +#define _VX_MONITOR_H
12915 +#include <linux/types.h>
12922 + VXM_UPDATE = 0x20,
12926 + VXM_RQINFO_1 = 0x24,
12929 + VXM_ACTIVATE = 0x40,
12936 + VXM_MIGRATE = 0x48,
12939 + /* all other bits are flags */
12940 + VXM_SCHED = 0x80,
12943 +struct _vxm_update_1 {
12944 + uint32_t tokens_max;
12945 + uint32_t fill_rate;
12946 + uint32_t interval;
12949 +struct _vxm_update_2 {
12950 + uint32_t tokens_min;
12951 + uint32_t fill_rate;
12952 + uint32_t interval;
12955 +struct _vxm_rqinfo_1 {
12956 + uint16_t running;
12960 + uint32_t idle_tokens;
12963 +struct _vxm_rqinfo_2 {
12964 + uint32_t norm_time;
12965 + uint32_t idle_time;
12966 + uint32_t idle_skip;
12969 +struct _vxm_sched {
12971 + uint32_t norm_time;
12972 + uint32_t idle_time;
12975 +struct _vxm_task {
12980 +struct _vxm_event {
12989 + struct _vxm_task tsk;
12993 +struct _vx_mon_entry {
12997 + struct _vxm_event ev;
12998 + struct _vxm_sched sd;
12999 + struct _vxm_update_1 u1;
13000 + struct _vxm_update_2 u2;
13001 + struct _vxm_rqinfo_1 q1;
13002 + struct _vxm_rqinfo_2 q2;
13007 +#endif /* _VX_MONITOR_H */
13008 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/network.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/network.h
13009 --- linux-3.2.8/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
13010 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/network.h 2011-12-05 19:33:02.000000000 +0100
13012 +#ifndef _VX_NETWORK_H
13013 +#define _VX_NETWORK_H
13015 +#include <linux/types.h>
13018 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13021 +/* network flags */
13023 +#define NXF_INFO_PRIVATE 0x00000008
13025 +#define NXF_SINGLE_IP 0x00000100
13026 +#define NXF_LBACK_REMAP 0x00000200
13027 +#define NXF_LBACK_ALLOW 0x00000400
13029 +#define NXF_HIDE_NETIF 0x02000000
13030 +#define NXF_HIDE_LBACK 0x04000000
13032 +#define NXF_STATE_SETUP (1ULL << 32)
13033 +#define NXF_STATE_ADMIN (1ULL << 34)
13035 +#define NXF_SC_HELPER (1ULL << 36)
13036 +#define NXF_PERSISTENT (1ULL << 38)
13038 +#define NXF_ONE_TIME (0x0005ULL << 32)
13041 +#define NXF_INIT_SET (__nxf_init_set())
13043 +static inline uint64_t __nxf_init_set(void) {
13044 + return NXF_STATE_ADMIN
13045 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13046 + | NXF_LBACK_REMAP
13049 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13052 + | NXF_HIDE_NETIF;
13056 +/* network caps */
13058 +#define NXC_TUN_CREATE 0x00000001
13060 +#define NXC_RAW_ICMP 0x00000100
13062 +#define NXC_MULTICAST 0x00001000
13065 +/* address types */
13067 +#define NXA_TYPE_IPV4 0x0001
13068 +#define NXA_TYPE_IPV6 0x0002
13070 +#define NXA_TYPE_NONE 0x0000
13071 +#define NXA_TYPE_ANY 0x00FF
13073 +#define NXA_TYPE_ADDR 0x0010
13074 +#define NXA_TYPE_MASK 0x0020
13075 +#define NXA_TYPE_RANGE 0x0040
13077 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13079 +#define NXA_MOD_BCAST 0x0100
13080 +#define NXA_MOD_LBACK 0x0200
13082 +#define NXA_LOOPBACK 0x1000
13084 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13085 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13089 +#include <linux/list.h>
13090 +#include <linux/spinlock.h>
13091 +#include <linux/rcupdate.h>
13092 +#include <linux/in.h>
13093 +#include <linux/in6.h>
13094 +#include <asm/atomic.h>
13096 +struct nx_addr_v4 {
13097 + struct nx_addr_v4 *next;
13098 + struct in_addr ip[2];
13099 + struct in_addr mask;
13104 +struct nx_addr_v6 {
13105 + struct nx_addr_v6 *next;
13106 + struct in6_addr ip;
13107 + struct in6_addr mask;
13114 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13115 + nid_t nx_id; /* vnet id */
13116 + atomic_t nx_usecnt; /* usage count */
13117 + atomic_t nx_tasks; /* tasks count */
13118 + int nx_state; /* context state */
13120 + uint64_t nx_flags; /* network flag word */
13121 + uint64_t nx_ncaps; /* network capabilities */
13123 + struct in_addr v4_lback; /* Loopback address */
13124 + struct in_addr v4_bcast; /* Broadcast address */
13125 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13126 +#ifdef CONFIG_IPV6
13127 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13129 + char nx_name[65]; /* network context name */
13133 +/* status flags */
13135 +#define NXS_HASHED 0x0001
13136 +#define NXS_SHUTDOWN 0x0100
13137 +#define NXS_RELEASED 0x8000
13139 +extern struct nx_info *lookup_nx_info(int);
13141 +extern int get_nid_list(int, unsigned int *, int);
13142 +extern int nid_is_hashed(nid_t);
13144 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13146 +extern long vs_net_change(struct nx_info *, unsigned int);
13151 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13152 +#ifdef CONFIG_IPV6
13153 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13155 +#define NX_IPV6(n) (0)
13158 +#endif /* __KERNEL__ */
13159 +#endif /* _VX_NETWORK_H */
13160 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/network_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/network_cmd.h
13161 --- linux-3.2.8/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13162 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/network_cmd.h 2011-12-05 19:33:02.000000000 +0100
13164 +#ifndef _VX_NETWORK_CMD_H
13165 +#define _VX_NETWORK_CMD_H
13168 +/* vinfo commands */
13170 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13173 +extern int vc_task_nid(uint32_t);
13175 +#endif /* __KERNEL__ */
13177 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13179 +struct vcmd_nx_info_v0 {
13181 + /* more to come */
13185 +extern int vc_nx_info(struct nx_info *, void __user *);
13187 +#endif /* __KERNEL__ */
13189 +#include <linux/in.h>
13190 +#include <linux/in6.h>
13192 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13193 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13195 +struct vcmd_net_create {
13196 + uint64_t flagword;
13199 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13201 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13202 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13204 +struct vcmd_net_addr_v0 {
13207 + struct in_addr ip[4];
13208 + struct in_addr mask[4];
13211 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13212 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13214 +struct vcmd_net_addr_ipv4_v1 {
13217 + struct in_addr ip;
13218 + struct in_addr mask;
13221 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13222 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13224 +struct vcmd_net_addr_ipv4_v2 {
13227 + struct in_addr ip;
13228 + struct in_addr ip2;
13229 + struct in_addr mask;
13232 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13233 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13235 +struct vcmd_net_addr_ipv6_v1 {
13239 + struct in6_addr ip;
13240 + struct in6_addr mask;
13243 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13244 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13246 +struct vcmd_match_ipv4_v0 {
13251 + struct in_addr ip;
13252 + struct in_addr ip2;
13253 + struct in_addr mask;
13256 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13257 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13259 +struct vcmd_match_ipv6_v0 {
13264 + struct in6_addr ip;
13265 + struct in6_addr ip2;
13266 + struct in6_addr mask;
13271 +extern int vc_net_create(uint32_t, void __user *);
13272 +extern int vc_net_migrate(struct nx_info *, void __user *);
13274 +extern int vc_net_add(struct nx_info *, void __user *);
13275 +extern int vc_net_remove(struct nx_info *, void __user *);
13277 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
13278 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13280 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
13281 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
13283 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13284 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13286 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13287 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13289 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13290 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13292 +#endif /* __KERNEL__ */
13295 +/* flag commands */
13297 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13298 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13300 +struct vcmd_net_flags_v0 {
13301 + uint64_t flagword;
13306 +extern int vc_get_nflags(struct nx_info *, void __user *);
13307 +extern int vc_set_nflags(struct nx_info *, void __user *);
13309 +#endif /* __KERNEL__ */
13312 +/* network caps commands */
13314 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13315 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13317 +struct vcmd_net_caps_v0 {
13323 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13324 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13326 +#endif /* __KERNEL__ */
13327 +#endif /* _VX_CONTEXT_CMD_H */
13328 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/percpu.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/percpu.h
13329 --- linux-3.2.8/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13330 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/percpu.h 2011-12-05 19:33:02.000000000 +0100
13332 +#ifndef _VX_PERCPU_H
13333 +#define _VX_PERCPU_H
13335 +#include "cvirt_def.h"
13336 +#include "sched_def.h"
13338 +struct _vx_percpu {
13339 + struct _vx_cvirt_pc cvirt;
13340 + struct _vx_sched_pc sched;
13343 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13345 +#endif /* _VX_PERCPU_H */
13346 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/pid.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/pid.h
13347 --- linux-3.2.8/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13348 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/pid.h 2011-12-05 19:33:02.000000000 +0100
13350 +#ifndef _VSERVER_PID_H
13351 +#define _VSERVER_PID_H
13353 +/* pid faking stuff */
13355 +#define vx_info_map_pid(v, p) \
13356 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13357 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13358 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13359 +#define vx_map_tgid(p) vx_map_pid(p)
13361 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13362 + const char *func, const char *file, int line)
13364 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13365 + vxfprintk(VXD_CBIT(cvirt, 2),
13366 + "vx_map_tgid: %p/%llx: %d -> %d",
13367 + vxi, (long long)vxi->vx_flags, pid,
13368 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13369 + func, file, line);
13372 + if (pid == vxi->vx_initpid)
13378 +#define vx_info_rmap_pid(v, p) \
13379 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13380 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13381 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13383 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13384 + const char *func, const char *file, int line)
13386 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13387 + vxfprintk(VXD_CBIT(cvirt, 2),
13388 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13389 + vxi, (long long)vxi->vx_flags, pid,
13390 + (pid == 1) ? vxi->vx_initpid : pid,
13391 + func, file, line);
13392 + if ((pid == 1) && vxi->vx_initpid)
13393 + return vxi->vx_initpid;
13394 + if (pid == vxi->vx_initpid)
13401 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/sched.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/sched.h
13402 --- linux-3.2.8/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13403 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/sched.h 2011-12-05 19:33:02.000000000 +0100
13405 +#ifndef _VX_SCHED_H
13406 +#define _VX_SCHED_H
13413 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13418 +void vx_update_load(struct vx_info *);
13421 +void vx_update_sched_param(struct _vx_sched *sched,
13422 + struct _vx_sched_pc *sched_pc);
13424 +#endif /* __KERNEL__ */
13425 +#else /* _VX_SCHED_H */
13426 +#warning duplicate inclusion
13427 +#endif /* _VX_SCHED_H */
13428 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/sched_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/sched_cmd.h
13429 --- linux-3.2.8/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
13430 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/sched_cmd.h 2011-12-05 19:33:02.000000000 +0100
13432 +#ifndef _VX_SCHED_CMD_H
13433 +#define _VX_SCHED_CMD_H
13436 +struct vcmd_prio_bias {
13438 + int32_t prio_bias;
13441 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13442 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13446 +#include <linux/compiler.h>
13448 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
13449 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
13451 +#endif /* __KERNEL__ */
13452 +#endif /* _VX_SCHED_CMD_H */
13453 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/sched_def.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/sched_def.h
13454 --- linux-3.2.8/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13455 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/sched_def.h 2011-12-05 19:33:02.000000000 +0100
13457 +#ifndef _VX_SCHED_DEF_H
13458 +#define _VX_SCHED_DEF_H
13460 +#include <linux/spinlock.h>
13461 +#include <linux/jiffies.h>
13462 +#include <linux/cpumask.h>
13463 +#include <asm/atomic.h>
13464 +#include <asm/param.h>
13467 +/* context sub struct */
13469 +struct _vx_sched {
13470 + int prio_bias; /* bias offset for priority */
13472 + cpumask_t update; /* CPUs which should update */
13475 +struct _vx_sched_pc {
13476 + int prio_bias; /* bias offset for priority */
13478 + uint64_t user_ticks; /* token tick events */
13479 + uint64_t sys_ticks; /* token tick events */
13480 + uint64_t hold_ticks; /* token ticks paused */
13484 +#ifdef CONFIG_VSERVER_DEBUG
13486 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13488 + printk("\t_vx_sched:\n");
13489 + printk("\t priority = %4d\n", sched->prio_bias);
13494 +#endif /* _VX_SCHED_DEF_H */
13495 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/signal.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/signal.h
13496 --- linux-3.2.8/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13497 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/signal.h 2011-12-05 19:33:02.000000000 +0100
13499 +#ifndef _VX_SIGNAL_H
13500 +#define _VX_SIGNAL_H
13507 +int vx_info_kill(struct vx_info *, int, int);
13509 +#endif /* __KERNEL__ */
13510 +#else /* _VX_SIGNAL_H */
13511 +#warning duplicate inclusion
13512 +#endif /* _VX_SIGNAL_H */
13513 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/signal_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/signal_cmd.h
13514 --- linux-3.2.8/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13515 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/signal_cmd.h 2011-12-05 19:33:02.000000000 +0100
13517 +#ifndef _VX_SIGNAL_CMD_H
13518 +#define _VX_SIGNAL_CMD_H
13521 +/* signalling vserver commands */
13523 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13524 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13526 +struct vcmd_ctx_kill_v0 {
13531 +struct vcmd_wait_exit_v0 {
13532 + int32_t reboot_cmd;
13533 + int32_t exit_code;
13538 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13539 +extern int vc_wait_exit(struct vx_info *, void __user *);
13541 +#endif /* __KERNEL__ */
13543 +/* process alteration commands */
13545 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13546 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13548 +struct vcmd_pflags_v0 {
13549 + uint32_t flagword;
13555 +extern int vc_get_pflags(uint32_t pid, void __user *);
13556 +extern int vc_set_pflags(uint32_t pid, void __user *);
13558 +#endif /* __KERNEL__ */
13559 +#endif /* _VX_SIGNAL_CMD_H */
13560 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/space.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/space.h
13561 --- linux-3.2.8/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13562 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/space.h 2011-12-05 19:33:02.000000000 +0100
13564 +#ifndef _VX_SPACE_H
13565 +#define _VX_SPACE_H
13567 +#include <linux/types.h>
13571 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13573 +#else /* _VX_SPACE_H */
13574 +#warning duplicate inclusion
13575 +#endif /* _VX_SPACE_H */
13576 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/space_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/space_cmd.h
13577 --- linux-3.2.8/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13578 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/space_cmd.h 2011-12-05 19:33:02.000000000 +0100
13580 +#ifndef _VX_SPACE_CMD_H
13581 +#define _VX_SPACE_CMD_H
13584 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13585 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13586 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13588 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13589 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13590 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13592 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13594 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13595 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13598 +struct vcmd_space_mask_v1 {
13602 +struct vcmd_space_mask_v2 {
13610 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13611 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13612 +extern int vc_enter_space(struct vx_info *, void __user *);
13613 +extern int vc_set_space(struct vx_info *, void __user *);
13614 +extern int vc_get_space_mask(void __user *, int);
13616 +#endif /* __KERNEL__ */
13617 +#endif /* _VX_SPACE_CMD_H */
13618 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/switch.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/switch.h
13619 --- linux-3.2.8/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13620 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/switch.h 2011-12-05 19:33:02.000000000 +0100
13622 +#ifndef _VX_SWITCH_H
13623 +#define _VX_SWITCH_H
13625 +#include <linux/types.h>
13628 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13629 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13630 +#define VC_VERSION(c) ((c) & 0xFFF)
13632 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13633 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13637 + Syscall Matrix V2.8
13639 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13640 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13641 + |INFO |SETUP | |MOVE | | | | | |
13642 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13643 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13644 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13645 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13646 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13647 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13648 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13649 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13650 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13651 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13652 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13653 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13654 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13655 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13656 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13657 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13658 + OTHER |VSTAT | | | | | | |VINFO | |
13659 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13660 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13661 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13662 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13663 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13664 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13665 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13666 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13670 +#define VC_CAT_VERSION 0
13672 +#define VC_CAT_VSETUP 1
13673 +#define VC_CAT_VHOST 2
13675 +#define VC_CAT_DEVICE 6
13677 +#define VC_CAT_VPROC 9
13678 +#define VC_CAT_PROCALT 10
13679 +#define VC_CAT_PROCMIG 11
13680 +#define VC_CAT_PROCTRL 12
13682 +#define VC_CAT_SCHED 14
13683 +#define VC_CAT_MEMCTRL 20
13685 +#define VC_CAT_VNET 25
13686 +#define VC_CAT_NETALT 26
13687 +#define VC_CAT_NETMIG 27
13688 +#define VC_CAT_NETCTRL 28
13690 +#define VC_CAT_TAGMIG 35
13691 +#define VC_CAT_DLIMIT 36
13692 +#define VC_CAT_INODE 38
13694 +#define VC_CAT_VSTAT 40
13695 +#define VC_CAT_VINFO 46
13696 +#define VC_CAT_EVENT 48
13698 +#define VC_CAT_FLAGS 52
13699 +#define VC_CAT_VSPACE 54
13700 +#define VC_CAT_DEBUG 56
13701 +#define VC_CAT_RLIMIT 60
13703 +#define VC_CAT_SYSTEST 61
13704 +#define VC_CAT_COMPAT 63
13706 +/* query version */
13708 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13709 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13714 +#include <linux/errno.h>
13716 +#endif /* __KERNEL__ */
13718 +#endif /* _VX_SWITCH_H */
13720 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/tag.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/tag.h
13721 --- linux-3.2.8/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13722 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/tag.h 2011-12-05 19:33:02.000000000 +0100
13727 +#include <linux/types.h>
13730 +#define DX_TAG(in) (IS_TAGGED(in))
13733 +#ifdef CONFIG_TAG_NFSD
13734 +#define DX_TAG_NFSD 1
13736 +#define DX_TAG_NFSD 0
13740 +#ifdef CONFIG_TAGGING_NONE
13742 +#define MAX_UID 0xFFFFFFFF
13743 +#define MAX_GID 0xFFFFFFFF
13745 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13747 +#define TAGINO_UID(cond, uid, tag) (uid)
13748 +#define TAGINO_GID(cond, gid, tag) (gid)
13753 +#ifdef CONFIG_TAGGING_GID16
13755 +#define MAX_UID 0xFFFFFFFF
13756 +#define MAX_GID 0x0000FFFF
13758 +#define INOTAG_TAG(cond, uid, gid, tag) \
13759 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13761 +#define TAGINO_UID(cond, uid, tag) (uid)
13762 +#define TAGINO_GID(cond, gid, tag) \
13763 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13768 +#ifdef CONFIG_TAGGING_ID24
13770 +#define MAX_UID 0x00FFFFFF
13771 +#define MAX_GID 0x00FFFFFF
13773 +#define INOTAG_TAG(cond, uid, gid, tag) \
13774 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13776 +#define TAGINO_UID(cond, uid, tag) \
13777 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13778 +#define TAGINO_GID(cond, gid, tag) \
13779 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13784 +#ifdef CONFIG_TAGGING_UID16
13786 +#define MAX_UID 0x0000FFFF
13787 +#define MAX_GID 0xFFFFFFFF
13789 +#define INOTAG_TAG(cond, uid, gid, tag) \
13790 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13792 +#define TAGINO_UID(cond, uid, tag) \
13793 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13794 +#define TAGINO_GID(cond, gid, tag) (gid)
13799 +#ifdef CONFIG_TAGGING_INTERN
13801 +#define MAX_UID 0xFFFFFFFF
13802 +#define MAX_GID 0xFFFFFFFF
13804 +#define INOTAG_TAG(cond, uid, gid, tag) \
13805 + ((cond) ? (tag) : 0)
13807 +#define TAGINO_UID(cond, uid, tag) (uid)
13808 +#define TAGINO_GID(cond, gid, tag) (gid)
13813 +#ifndef CONFIG_TAGGING_NONE
13814 +#define dx_current_fstag(sb) \
13815 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13817 +#define dx_current_fstag(sb) (0)
13820 +#ifndef CONFIG_TAGGING_INTERN
13821 +#define TAGINO_TAG(cond, tag) (0)
13823 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13826 +#define INOTAG_UID(cond, uid, gid) \
13827 + ((cond) ? ((uid) & MAX_UID) : (uid))
13828 +#define INOTAG_GID(cond, uid, gid) \
13829 + ((cond) ? ((gid) & MAX_GID) : (gid))
13832 +static inline uid_t dx_map_uid(uid_t uid)
13834 + if ((uid > MAX_UID) && (uid != -1))
13836 + return (uid & MAX_UID);
13839 +static inline gid_t dx_map_gid(gid_t gid)
13841 + if ((gid > MAX_GID) && (gid != -1))
13843 + return (gid & MAX_GID);
13851 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13853 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13854 + unsigned long *flags);
13856 +#ifdef CONFIG_PROPAGATE
13858 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13860 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13863 +#define dx_propagate_tag(n, i) do { } while (0)
13866 +#endif /* _DX_TAG_H */
13867 diff -NurpP --minimal linux-3.2.8/include/linux/vserver/tag_cmd.h linux-3.2.8-vs2.3.2.7/include/linux/vserver/tag_cmd.h
13868 --- linux-3.2.8/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13869 +++ linux-3.2.8-vs2.3.2.7/include/linux/vserver/tag_cmd.h 2011-12-05 19:33:02.000000000 +0100
13871 +#ifndef _VX_TAG_CMD_H
13872 +#define _VX_TAG_CMD_H
13875 +/* vinfo commands */
13877 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13880 +extern int vc_task_tag(uint32_t);
13882 +#endif /* __KERNEL__ */
13884 +/* context commands */
13886 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13889 +extern int vc_tag_migrate(uint32_t);
13891 +#endif /* __KERNEL__ */
13892 +#endif /* _VX_TAG_CMD_H */
13893 diff -NurpP --minimal linux-3.2.8/include/net/addrconf.h linux-3.2.8-vs2.3.2.7/include/net/addrconf.h
13894 --- linux-3.2.8/include/net/addrconf.h 2012-01-09 16:14:59.000000000 +0100
13895 +++ linux-3.2.8-vs2.3.2.7/include/net/addrconf.h 2011-12-05 19:33:02.000000000 +0100
13896 @@ -80,7 +80,8 @@ extern int ipv6_dev_get_saddr(struct n
13897 struct net_device *dev,
13898 const struct in6_addr *daddr,
13899 unsigned int srcprefs,
13900 - struct in6_addr *saddr);
13901 + struct in6_addr *saddr,
13902 + struct nx_info *nxi);
13903 extern int ipv6_get_lladdr(struct net_device *dev,
13904 struct in6_addr *addr,
13905 unsigned char banned_flags);
13906 diff -NurpP --minimal linux-3.2.8/include/net/af_unix.h linux-3.2.8-vs2.3.2.7/include/net/af_unix.h
13907 --- linux-3.2.8/include/net/af_unix.h 2011-07-22 11:18:11.000000000 +0200
13908 +++ linux-3.2.8-vs2.3.2.7/include/net/af_unix.h 2011-12-05 19:33:02.000000000 +0100
13910 #include <linux/socket.h>
13911 #include <linux/un.h>
13912 #include <linux/mutex.h>
13913 +#include <linux/vs_base.h>
13914 #include <net/sock.h>
13916 extern void unix_inflight(struct file *fp);
13917 diff -NurpP --minimal linux-3.2.8/include/net/inet_timewait_sock.h linux-3.2.8-vs2.3.2.7/include/net/inet_timewait_sock.h
13918 --- linux-3.2.8/include/net/inet_timewait_sock.h 2012-01-09 16:14:59.000000000 +0100
13919 +++ linux-3.2.8-vs2.3.2.7/include/net/inet_timewait_sock.h 2011-12-05 19:33:02.000000000 +0100
13920 @@ -112,6 +112,10 @@ struct inet_timewait_sock {
13921 #define tw_net __tw_common.skc_net
13922 #define tw_daddr __tw_common.skc_daddr
13923 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
13924 +#define tw_xid __tw_common.skc_xid
13925 +#define tw_vx_info __tw_common.skc_vx_info
13926 +#define tw_nid __tw_common.skc_nid
13927 +#define tw_nx_info __tw_common.skc_nx_info
13929 volatile unsigned char tw_substate;
13930 unsigned char tw_rcv_wscale;
13931 diff -NurpP --minimal linux-3.2.8/include/net/ip6_route.h linux-3.2.8-vs2.3.2.7/include/net/ip6_route.h
13932 --- linux-3.2.8/include/net/ip6_route.h 2011-07-22 11:18:11.000000000 +0200
13933 +++ linux-3.2.8-vs2.3.2.7/include/net/ip6_route.h 2011-12-05 19:33:02.000000000 +0100
13934 @@ -86,7 +86,8 @@ extern int ip6_route_get_saddr(struct
13935 struct rt6_info *rt,
13936 const struct in6_addr *daddr,
13937 unsigned int prefs,
13938 - struct in6_addr *saddr);
13939 + struct in6_addr *saddr,
13940 + struct nx_info *nxi);
13942 extern struct rt6_info *rt6_lookup(struct net *net,
13943 const struct in6_addr *daddr,
13944 diff -NurpP --minimal linux-3.2.8/include/net/route.h linux-3.2.8-vs2.3.2.7/include/net/route.h
13945 --- linux-3.2.8/include/net/route.h 2012-01-09 16:14:59.000000000 +0100
13946 +++ linux-3.2.8-vs2.3.2.7/include/net/route.h 2012-02-07 03:13:38.000000000 +0100
13947 @@ -202,6 +202,9 @@ static inline void ip_rt_put(struct rtab
13948 dst_release(&rt->dst);
13951 +#include <linux/vs_base.h>
13952 +#include <linux/vs_inet.h>
13954 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
13956 extern const __u8 ip_tos2prio[16];
13957 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
13958 protocol, flow_flags, dst, src, dport, sport);
13961 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
13962 + struct flowi4 *);
13964 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
13965 __be32 dst, __be32 src, u32 tos,
13966 int oif, u8 protocol,
13967 @@ -261,11 +267,25 @@ static inline struct rtable *ip_route_co
13969 struct net *net = sock_net(sk);
13971 + struct nx_info *nx_info = current_nx_info();
13973 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
13974 sport, dport, sk, can_sleep);
13976 - if (!dst || !src) {
13978 + nx_info = sk->sk_nx_info;
13980 + vxdprintk(VXD_CBIT(net, 4),
13981 + "ip_route_connect(%p) %p,%p;%lx",
13982 + sk, nx_info, sk->sk_socket,
13983 + (sk->sk_socket?sk->sk_socket->flags:0));
13985 + rt = ip_v4_find_src(net, nx_info, fl4);
13990 + if (!fl4->daddr || !fl4->saddr) {
13991 rt = __ip_route_output_key(net, fl4);
13994 diff -NurpP --minimal linux-3.2.8/include/net/sock.h linux-3.2.8-vs2.3.2.7/include/net/sock.h
13995 --- linux-3.2.8/include/net/sock.h 2012-01-09 16:14:59.000000000 +0100
13996 +++ linux-3.2.8-vs2.3.2.7/include/net/sock.h 2012-01-09 16:19:31.000000000 +0100
13997 @@ -149,6 +149,10 @@ struct sock_common {
13998 #ifdef CONFIG_NET_NS
13999 struct net *skc_net;
14002 + struct vx_info *skc_vx_info;
14004 + struct nx_info *skc_nx_info;
14006 * fields between dontcopy_begin/dontcopy_end
14007 * are not copied in sock_copy()
14008 @@ -256,6 +260,10 @@ struct sock {
14009 #define sk_bind_node __sk_common.skc_bind_node
14010 #define sk_prot __sk_common.skc_prot
14011 #define sk_net __sk_common.skc_net
14012 +#define sk_xid __sk_common.skc_xid
14013 +#define sk_vx_info __sk_common.skc_vx_info
14014 +#define sk_nid __sk_common.skc_nid
14015 +#define sk_nx_info __sk_common.skc_nx_info
14016 socket_lock_t sk_lock;
14017 struct sk_buff_head sk_receive_queue;
14019 diff -NurpP --minimal linux-3.2.8/init/Kconfig linux-3.2.8-vs2.3.2.7/init/Kconfig
14020 --- linux-3.2.8/init/Kconfig 2012-01-09 16:14:59.000000000 +0100
14021 +++ linux-3.2.8-vs2.3.2.7/init/Kconfig 2011-12-05 19:33:02.000000000 +0100
14022 @@ -574,6 +574,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14024 boolean "Control Group support"
14028 This option adds support for grouping sets of processes together, for
14029 use with process control subsystems such as Cpusets, CFS, memory
14030 @@ -802,6 +803,7 @@ config IPC_NS
14032 bool "User namespace (EXPERIMENTAL)"
14033 depends on EXPERIMENTAL
14034 + depends on VSERVER_DISABLED
14037 This allows containers, i.e. vservers, to use user namespaces
14038 diff -NurpP --minimal linux-3.2.8/init/main.c linux-3.2.8-vs2.3.2.7/init/main.c
14039 --- linux-3.2.8/init/main.c 2012-01-09 16:14:59.000000000 +0100
14040 +++ linux-3.2.8-vs2.3.2.7/init/main.c 2011-12-05 19:33:02.000000000 +0100
14042 #include <linux/shmem_fs.h>
14043 #include <linux/slab.h>
14044 #include <linux/perf_event.h>
14045 +#include <linux/vserver/percpu.h>
14047 #include <asm/io.h>
14048 #include <asm/bugs.h>
14049 diff -NurpP --minimal linux-3.2.8/ipc/mqueue.c linux-3.2.8-vs2.3.2.7/ipc/mqueue.c
14050 --- linux-3.2.8/ipc/mqueue.c 2012-01-09 16:14:59.000000000 +0100
14051 +++ linux-3.2.8-vs2.3.2.7/ipc/mqueue.c 2012-01-09 16:19:31.000000000 +0100
14053 #include <linux/pid.h>
14054 #include <linux/ipc_namespace.h>
14055 #include <linux/slab.h>
14056 +#include <linux/vs_context.h>
14057 +#include <linux/vs_limit.h>
14059 #include <net/sock.h>
14061 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14062 struct sigevent notify;
14063 struct pid* notify_owner;
14064 struct user_struct *user; /* user who created, for accounting */
14065 + struct vx_info *vxi;
14066 struct sock *notify_sock;
14067 struct sk_buff *notify_cookie;
14069 @@ -128,6 +131,7 @@ static struct inode *mqueue_get_inode(st
14070 if (S_ISREG(mode)) {
14071 struct mqueue_inode_info *info;
14072 struct task_struct *p = current;
14073 + struct vx_info *vxi = p->vx_info;
14074 unsigned long mq_bytes, mq_msg_tblsz;
14076 inode->i_fop = &mqueue_file_operations;
14077 @@ -141,6 +145,7 @@ static struct inode *mqueue_get_inode(st
14078 info->notify_owner = NULL;
14080 info->user = NULL; /* set when all is ok */
14081 + info->vxi = NULL;
14082 memset(&info->attr, 0, sizeof(info->attr));
14083 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14084 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14085 @@ -158,17 +163,20 @@ static struct inode *mqueue_get_inode(st
14087 spin_lock(&mq_lock);
14088 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14089 - u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) {
14090 + u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE) ||
14091 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14092 spin_unlock(&mq_lock);
14093 /* mqueue_evict_inode() releases info->messages */
14097 u->mq_bytes += mq_bytes;
14098 + vx_ipcmsg_add(vxi, u, mq_bytes);
14099 spin_unlock(&mq_lock);
14102 info->user = get_uid(u);
14103 + info->vxi = get_vx_info(vxi);
14104 } else if (S_ISDIR(mode)) {
14106 /* Some things misbehave if size == 0 on a directory */
14107 @@ -278,8 +286,11 @@ static void mqueue_evict_inode(struct in
14108 + info->attr.mq_msgsize);
14111 + struct vx_info *vxi = info->vxi;
14113 spin_lock(&mq_lock);
14114 user->mq_bytes -= mq_bytes;
14115 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14117 * get_ns_from_inode() ensures that the
14118 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14119 @@ -289,6 +300,7 @@ static void mqueue_evict_inode(struct in
14121 ipc_ns->mq_queues_count--;
14122 spin_unlock(&mq_lock);
14123 + put_vx_info(vxi);
14127 diff -NurpP --minimal linux-3.2.8/ipc/msg.c linux-3.2.8-vs2.3.2.7/ipc/msg.c
14128 --- linux-3.2.8/ipc/msg.c 2011-05-22 16:17:59.000000000 +0200
14129 +++ linux-3.2.8-vs2.3.2.7/ipc/msg.c 2011-12-05 19:33:02.000000000 +0100
14131 #include <linux/rwsem.h>
14132 #include <linux/nsproxy.h>
14133 #include <linux/ipc_namespace.h>
14134 +#include <linux/vs_base.h>
14136 #include <asm/current.h>
14137 #include <asm/uaccess.h>
14138 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14140 msq->q_perm.mode = msgflg & S_IRWXUGO;
14141 msq->q_perm.key = key;
14142 + msq->q_perm.xid = vx_current_xid();
14144 msq->q_perm.security = NULL;
14145 retval = security_msg_queue_alloc(msq);
14146 diff -NurpP --minimal linux-3.2.8/ipc/namespace.c linux-3.2.8-vs2.3.2.7/ipc/namespace.c
14147 --- linux-3.2.8/ipc/namespace.c 2011-07-22 11:18:12.000000000 +0200
14148 +++ linux-3.2.8-vs2.3.2.7/ipc/namespace.c 2011-12-05 19:33:02.000000000 +0100
14149 @@ -13,11 +13,12 @@
14150 #include <linux/mount.h>
14151 #include <linux/user_namespace.h>
14152 #include <linux/proc_fs.h>
14153 +#include <linux/vs_base.h>
14154 +#include <linux/vserver/global.h>
14158 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
14159 - struct ipc_namespace *old_ns)
14160 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
14162 struct ipc_namespace *ns;
14164 @@ -46,19 +47,18 @@ static struct ipc_namespace *create_ipc_
14165 ipcns_notify(IPCNS_CREATED);
14166 register_ipcns_notifier(ns);
14168 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
14169 + ns->user_ns = get_user_ns(user_ns);
14174 struct ipc_namespace *copy_ipcs(unsigned long flags,
14175 - struct task_struct *tsk)
14176 + struct ipc_namespace *old_ns,
14177 + struct user_namespace *user_ns)
14179 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
14181 if (!(flags & CLONE_NEWIPC))
14182 - return get_ipc_ns(ns);
14183 - return create_ipc_ns(tsk, ns);
14184 + return get_ipc_ns(old_ns);
14185 + return create_ipc_ns(user_ns);
14189 diff -NurpP --minimal linux-3.2.8/ipc/sem.c linux-3.2.8-vs2.3.2.7/ipc/sem.c
14190 --- linux-3.2.8/ipc/sem.c 2012-01-09 16:14:59.000000000 +0100
14191 +++ linux-3.2.8-vs2.3.2.7/ipc/sem.c 2011-12-05 19:33:02.000000000 +0100
14193 #include <linux/rwsem.h>
14194 #include <linux/nsproxy.h>
14195 #include <linux/ipc_namespace.h>
14196 +#include <linux/vs_base.h>
14197 +#include <linux/vs_limit.h>
14199 #include <asm/uaccess.h>
14201 @@ -306,6 +308,7 @@ static int newary(struct ipc_namespace *
14203 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14204 sma->sem_perm.key = key;
14205 + sma->sem_perm.xid = vx_current_xid();
14207 sma->sem_perm.security = NULL;
14208 retval = security_sem_alloc(sma);
14209 @@ -321,6 +324,9 @@ static int newary(struct ipc_namespace *
14212 ns->used_sems += nsems;
14213 + /* FIXME: obsoleted? */
14214 + vx_semary_inc(sma);
14215 + vx_nsems_add(sma, nsems);
14217 sma->sem_base = (struct sem *) &sma[1];
14219 @@ -770,6 +776,9 @@ static void freeary(struct ipc_namespace
14221 wake_up_sem_queue_do(&tasks);
14222 ns->used_sems -= sma->sem_nsems;
14223 + /* FIXME: obsoleted? */
14224 + vx_nsems_sub(sma, sma->sem_nsems);
14225 + vx_semary_dec(sma);
14226 security_sem_free(sma);
14227 ipc_rcu_putref(sma);
14229 diff -NurpP --minimal linux-3.2.8/ipc/shm.c linux-3.2.8-vs2.3.2.7/ipc/shm.c
14230 --- linux-3.2.8/ipc/shm.c 2012-02-28 05:53:29.000000000 +0100
14231 +++ linux-3.2.8-vs2.3.2.7/ipc/shm.c 2012-01-26 08:52:10.000000000 +0100
14233 #include <linux/nsproxy.h>
14234 #include <linux/mount.h>
14235 #include <linux/ipc_namespace.h>
14236 +#include <linux/vs_context.h>
14237 +#include <linux/vs_limit.h>
14239 #include <asm/uaccess.h>
14241 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
14243 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14245 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14246 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14247 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14249 + vx_ipcshm_sub(vxi, shp, numpages);
14250 + ns->shm_tot -= numpages;
14254 if (!is_file_hugepages(shp->shm_file))
14255 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
14257 fput (shp->shm_file);
14258 security_shm_free(shp);
14259 + put_vx_info(vxi);
14260 ipc_rcu_putref(shp);
14263 @@ -462,11 +470,15 @@ static int newseg(struct ipc_namespace *
14264 if (ns->shm_tot + numpages > ns->shm_ctlall)
14267 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14270 shp = ipc_rcu_alloc(sizeof(*shp));
14274 shp->shm_perm.key = key;
14275 + shp->shm_perm.xid = vx_current_xid();
14276 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14277 shp->mlock_user = NULL;
14279 @@ -521,6 +533,7 @@ static int newseg(struct ipc_namespace *
14280 ns->shm_tot += numpages;
14281 error = shp->shm_perm.id;
14283 + vx_ipcshm_add(current_vx_info(), key, numpages);
14287 diff -NurpP --minimal linux-3.2.8/kernel/Makefile linux-3.2.8-vs2.3.2.7/kernel/Makefile
14288 --- linux-3.2.8/kernel/Makefile 2012-01-09 16:14:59.000000000 +0100
14289 +++ linux-3.2.8-vs2.3.2.7/kernel/Makefile 2011-12-05 19:33:02.000000000 +0100
14290 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
14291 CFLAGS_REMOVE_irq_work.o = -pg
14295 obj-$(CONFIG_FREEZER) += freezer.o
14296 obj-$(CONFIG_PROFILING) += profile.o
14297 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
14298 diff -NurpP --minimal linux-3.2.8/kernel/capability.c linux-3.2.8-vs2.3.2.7/kernel/capability.c
14299 --- linux-3.2.8/kernel/capability.c 2012-01-09 16:14:59.000000000 +0100
14300 +++ linux-3.2.8-vs2.3.2.7/kernel/capability.c 2011-12-05 19:33:02.000000000 +0100
14302 #include <linux/syscalls.h>
14303 #include <linux/pid_namespace.h>
14304 #include <linux/user_namespace.h>
14305 +#include <linux/vs_context.h>
14306 #include <asm/uaccess.h>
14309 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
14315 * The only thing that can change the capabilities of the current
14316 * process is the current process. As such, we can't be in this code
14317 @@ -340,6 +342,8 @@ bool has_capability_noaudit(struct task_
14321 +#include <linux/vserver/base.h>
14324 * capable - Determine if the current task has a superior capability in effect
14325 * @cap: The capability to be tested for
14326 diff -NurpP --minimal linux-3.2.8/kernel/compat.c linux-3.2.8-vs2.3.2.7/kernel/compat.c
14327 --- linux-3.2.8/kernel/compat.c 2012-01-09 16:14:59.000000000 +0100
14328 +++ linux-3.2.8-vs2.3.2.7/kernel/compat.c 2011-12-05 19:33:02.000000000 +0100
14329 @@ -973,7 +973,7 @@ asmlinkage long compat_sys_stime(compat_
14333 - do_settimeofday(&tv);
14334 + vx_settimeofday(&tv);
14338 diff -NurpP --minimal linux-3.2.8/kernel/cred.c linux-3.2.8-vs2.3.2.7/kernel/cred.c
14339 --- linux-3.2.8/kernel/cred.c 2012-01-09 16:15:00.000000000 +0100
14340 +++ linux-3.2.8-vs2.3.2.7/kernel/cred.c 2011-12-05 19:33:02.000000000 +0100
14341 @@ -61,31 +61,6 @@ struct cred init_cred = {
14345 -static inline void set_cred_subscribers(struct cred *cred, int n)
14347 -#ifdef CONFIG_DEBUG_CREDENTIALS
14348 - atomic_set(&cred->subscribers, n);
14352 -static inline int read_cred_subscribers(const struct cred *cred)
14354 -#ifdef CONFIG_DEBUG_CREDENTIALS
14355 - return atomic_read(&cred->subscribers);
14361 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14363 -#ifdef CONFIG_DEBUG_CREDENTIALS
14364 - struct cred *cred = (struct cred *) _cred;
14366 - atomic_add(n, &cred->subscribers);
14371 * Dispose of the shared task group credentials
14373 @@ -281,21 +256,16 @@ error:
14375 * Call commit_creds() or abort_creds() to clean up.
14377 -struct cred *prepare_creds(void)
14378 +struct cred *__prepare_creds(const struct cred *old)
14380 - struct task_struct *task = current;
14381 - const struct cred *old;
14384 - validate_process_creds();
14386 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14390 kdebug("prepare_creds() alloc %p", new);
14392 - old = task->cred;
14393 memcpy(new, old, sizeof(struct cred));
14395 atomic_set(&new->usage, 1);
14396 @@ -322,6 +292,13 @@ error:
14401 +struct cred *prepare_creds(void)
14403 + validate_process_creds();
14405 + return __prepare_creds(current->cred);
14407 EXPORT_SYMBOL(prepare_creds);
14410 diff -NurpP --minimal linux-3.2.8/kernel/exit.c linux-3.2.8-vs2.3.2.7/kernel/exit.c
14411 --- linux-3.2.8/kernel/exit.c 2012-01-09 16:15:00.000000000 +0100
14412 +++ linux-3.2.8-vs2.3.2.7/kernel/exit.c 2012-01-09 16:19:31.000000000 +0100
14414 #include <linux/fs_struct.h>
14415 #include <linux/init_task.h>
14416 #include <linux/perf_event.h>
14417 +#include <linux/vs_limit.h>
14418 +#include <linux/vs_context.h>
14419 +#include <linux/vs_network.h>
14420 +#include <linux/vs_pid.h>
14421 #include <trace/events/sched.h>
14422 #include <linux/hw_breakpoint.h>
14423 #include <linux/oom.h>
14424 @@ -480,9 +484,11 @@ static void close_files(struct files_str
14425 filp_close(file, files);
14428 + vx_openfd_dec(i);
14436 @@ -1036,11 +1042,16 @@ NORET_TYPE void do_exit(long code)
14438 validate_creds_for_do_exit(tsk);
14440 + /* needs to stay after exit_notify() */
14441 + exit_vx_info(tsk, code);
14442 + exit_nx_info(tsk);
14446 /* causes final put_task_struct in finish_task_switch(). */
14447 tsk->state = TASK_DEAD;
14449 + printk("bad task: %p [%lx]\n", current, current->state);
14451 /* Avoid "noreturn function does return". */
14453 diff -NurpP --minimal linux-3.2.8/kernel/fork.c linux-3.2.8-vs2.3.2.7/kernel/fork.c
14454 --- linux-3.2.8/kernel/fork.c 2012-01-09 16:15:00.000000000 +0100
14455 +++ linux-3.2.8-vs2.3.2.7/kernel/fork.c 2011-12-15 01:52:28.000000000 +0100
14457 #include <linux/oom.h>
14458 #include <linux/khugepaged.h>
14459 #include <linux/signalfd.h>
14460 +#include <linux/vs_context.h>
14461 +#include <linux/vs_network.h>
14462 +#include <linux/vs_limit.h>
14464 #include <asm/pgtable.h>
14465 #include <asm/pgalloc.h>
14466 @@ -165,6 +168,8 @@ void free_task(struct task_struct *tsk)
14467 account_kernel_stack(tsk->stack, -1);
14468 free_thread_info(tsk->stack);
14469 rt_mutex_debug_task_free(tsk);
14470 + clr_vx_info(&tsk->vx_info);
14471 + clr_nx_info(&tsk->nx_info);
14472 ftrace_graph_exit_task(tsk);
14473 free_task_struct(tsk);
14475 @@ -500,6 +505,7 @@ static struct mm_struct *mm_init(struct
14476 if (likely(!mm_alloc_pgd(mm))) {
14478 mmu_notifier_mm_init(mm);
14479 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14483 @@ -537,6 +543,7 @@ void __mmdrop(struct mm_struct *mm)
14484 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14485 VM_BUG_ON(mm->pmd_huge_pte);
14487 + clr_vx_info(&mm->mm_vx_info);
14490 EXPORT_SYMBOL_GPL(__mmdrop);
14491 @@ -724,6 +731,7 @@ struct mm_struct *dup_mm(struct task_str
14494 memcpy(mm, oldmm, sizeof(*mm));
14495 + mm->mm_vx_info = NULL;
14496 mm_init_cpumask(mm);
14498 /* Initializing for Swap token stuff */
14499 @@ -767,6 +775,7 @@ fail_nocontext:
14500 * If init_new_context() failed, we cannot use mmput() to free the mm
14501 * because it calls destroy_context()
14503 + clr_vx_info(&mm->mm_vx_info);
14507 @@ -1050,6 +1059,8 @@ static struct task_struct *copy_process(
14509 struct task_struct *p;
14510 int cgroup_callbacks_done = 0;
14511 + struct vx_info *vxi;
14512 + struct nx_info *nxi;
14514 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14515 return ERR_PTR(-EINVAL);
14516 @@ -1096,7 +1107,12 @@ static struct task_struct *copy_process(
14517 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14518 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14520 + init_vx_info(&p->vx_info, current_vx_info());
14521 + init_nx_info(&p->nx_info, current_nx_info());
14524 + if (!vx_nproc_avail(1))
14525 + goto bad_fork_free;
14526 if (atomic_read(&p->real_cred->user->processes) >=
14527 task_rlimit(p, RLIMIT_NPROC)) {
14528 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14529 @@ -1369,6 +1385,18 @@ static struct task_struct *copy_process(
14532 spin_unlock(¤t->sighand->siglock);
14534 + /* p is copy of current */
14535 + vxi = p->vx_info;
14537 + claim_vx_info(vxi, p);
14538 + atomic_inc(&vxi->cvirt.nr_threads);
14539 + atomic_inc(&vxi->cvirt.total_forks);
14542 + nxi = p->nx_info;
14544 + claim_nx_info(nxi, p);
14545 write_unlock_irq(&tasklist_lock);
14546 proc_fork_connector(p);
14547 cgroup_post_fork(p);
14548 diff -NurpP --minimal linux-3.2.8/kernel/kthread.c linux-3.2.8-vs2.3.2.7/kernel/kthread.c
14549 --- linux-3.2.8/kernel/kthread.c 2012-01-09 16:15:00.000000000 +0100
14550 +++ linux-3.2.8-vs2.3.2.7/kernel/kthread.c 2011-12-05 19:33:02.000000000 +0100
14552 #include <linux/mutex.h>
14553 #include <linux/slab.h>
14554 #include <linux/freezer.h>
14555 +#include <linux/vs_pid.h>
14556 #include <trace/events/sched.h>
14558 static DEFINE_SPINLOCK(kthread_create_lock);
14559 diff -NurpP --minimal linux-3.2.8/kernel/nsproxy.c linux-3.2.8-vs2.3.2.7/kernel/nsproxy.c
14560 --- linux-3.2.8/kernel/nsproxy.c 2012-01-09 16:15:00.000000000 +0100
14561 +++ linux-3.2.8-vs2.3.2.7/kernel/nsproxy.c 2011-12-05 19:33:02.000000000 +0100
14563 #include <linux/mnt_namespace.h>
14564 #include <linux/utsname.h>
14565 #include <linux/pid_namespace.h>
14566 +#include <linux/vserver/global.h>
14567 +#include <linux/vserver/debug.h>
14568 #include <net/net_namespace.h>
14569 #include <linux/ipc_namespace.h>
14570 #include <linux/proc_fs.h>
14571 @@ -46,8 +48,11 @@ static inline struct nsproxy *create_nsp
14572 struct nsproxy *nsproxy;
14574 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14577 atomic_set(&nsproxy->count, 1);
14578 + atomic_inc(&vs_global_nsproxy);
14580 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14584 @@ -56,8 +61,11 @@ static inline struct nsproxy *create_nsp
14585 * Return the newly created nsproxy. Do not attach this to the task,
14586 * leave it to the caller to do proper locking and attach it to task.
14588 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14589 - struct task_struct *tsk, struct fs_struct *new_fs)
14590 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14591 + struct nsproxy *orig,
14592 + struct fs_struct *new_fs,
14593 + struct user_namespace *new_user,
14594 + struct pid_namespace *new_pid)
14596 struct nsproxy *new_nsp;
14598 @@ -66,31 +74,31 @@ static struct nsproxy *create_new_namesp
14600 return ERR_PTR(-ENOMEM);
14602 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
14603 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
14604 if (IS_ERR(new_nsp->mnt_ns)) {
14605 err = PTR_ERR(new_nsp->mnt_ns);
14609 - new_nsp->uts_ns = copy_utsname(flags, tsk);
14610 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
14611 if (IS_ERR(new_nsp->uts_ns)) {
14612 err = PTR_ERR(new_nsp->uts_ns);
14616 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
14617 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
14618 if (IS_ERR(new_nsp->ipc_ns)) {
14619 err = PTR_ERR(new_nsp->ipc_ns);
14623 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
14624 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
14625 if (IS_ERR(new_nsp->pid_ns)) {
14626 err = PTR_ERR(new_nsp->pid_ns);
14630 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
14631 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
14632 if (IS_ERR(new_nsp->net_ns)) {
14633 err = PTR_ERR(new_nsp->net_ns);
14635 @@ -115,6 +123,40 @@ out_ns:
14636 return ERR_PTR(err);
14639 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14640 + struct task_struct *tsk, struct fs_struct *new_fs)
14642 + return unshare_namespaces(flags, tsk->nsproxy,
14643 + new_fs, task_cred_xxx(tsk, user)->user_ns,
14644 + task_active_pid_ns(tsk));
14648 + * copies the nsproxy, setting refcount to 1, and grabbing a
14649 + * reference to all contained namespaces.
14651 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14653 + struct nsproxy *ns = create_nsproxy();
14656 + memcpy(ns, orig, sizeof(struct nsproxy));
14657 + atomic_set(&ns->count, 1);
14660 + get_mnt_ns(ns->mnt_ns);
14662 + get_uts_ns(ns->uts_ns);
14664 + get_ipc_ns(ns->ipc_ns);
14666 + get_pid_ns(ns->pid_ns);
14668 + get_net(ns->net_ns);
14674 * called from clone. This now handles copy for nsproxy and all
14675 * namespaces therein.
14676 @@ -122,9 +164,12 @@ out_ns:
14677 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
14679 struct nsproxy *old_ns = tsk->nsproxy;
14680 - struct nsproxy *new_ns;
14681 + struct nsproxy *new_ns = NULL;
14684 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14685 + flags, tsk, old_ns);
14690 @@ -134,7 +179,7 @@ int copy_namespaces(unsigned long flags,
14691 CLONE_NEWPID | CLONE_NEWNET)))
14694 - if (!capable(CAP_SYS_ADMIN)) {
14695 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
14699 @@ -161,6 +206,9 @@ int copy_namespaces(unsigned long flags,
14702 put_nsproxy(old_ns);
14703 + vxdprintk(VXD_CBIT(space, 3),
14704 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14705 + flags, tsk, old_ns, err, new_ns);
14709 @@ -174,7 +222,9 @@ void free_nsproxy(struct nsproxy *ns)
14710 put_ipc_ns(ns->ipc_ns);
14712 put_pid_ns(ns->pid_ns);
14713 - put_net(ns->net_ns);
14715 + put_net(ns->net_ns);
14716 + atomic_dec(&vs_global_nsproxy);
14717 kmem_cache_free(nsproxy_cachep, ns);
14720 @@ -187,11 +237,15 @@ int unshare_nsproxy_namespaces(unsigned
14724 + vxdprintk(VXD_CBIT(space, 4),
14725 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14726 + unshare_flags, current->nsproxy);
14728 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14732 - if (!capable(CAP_SYS_ADMIN))
14733 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
14736 *new_nsp = create_new_namespaces(unshare_flags, current,
14737 diff -NurpP --minimal linux-3.2.8/kernel/pid.c linux-3.2.8-vs2.3.2.7/kernel/pid.c
14738 --- linux-3.2.8/kernel/pid.c 2012-01-09 16:15:00.000000000 +0100
14739 +++ linux-3.2.8-vs2.3.2.7/kernel/pid.c 2011-12-05 19:43:14.000000000 +0100
14741 #include <linux/pid_namespace.h>
14742 #include <linux/init_task.h>
14743 #include <linux/syscalls.h>
14744 +#include <linux/vs_pid.h>
14746 #define pid_hashfn(nr, ns) \
14747 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14748 @@ -342,7 +343,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14750 struct pid *find_vpid(int nr)
14752 - return find_pid_ns(nr, current->nsproxy->pid_ns);
14753 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
14755 EXPORT_SYMBOL_GPL(find_vpid);
14757 @@ -402,6 +403,9 @@ void transfer_pid(struct task_struct *ol
14758 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14760 struct task_struct *result = NULL;
14762 + if (type == PIDTYPE_REALPID)
14763 + type = PIDTYPE_PID;
14765 struct hlist_node *first;
14766 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
14767 @@ -421,7 +425,7 @@ struct task_struct *find_task_by_pid_ns(
14768 rcu_lockdep_assert(rcu_read_lock_held(),
14769 "find_task_by_pid_ns() needs rcu_read_lock()"
14771 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
14772 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
14775 struct task_struct *find_task_by_vpid(pid_t vnr)
14776 @@ -465,7 +469,7 @@ struct pid *find_get_pid(pid_t nr)
14778 EXPORT_SYMBOL_GPL(find_get_pid);
14780 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14781 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
14785 @@ -478,6 +482,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
14789 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14791 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
14794 pid_t pid_vnr(struct pid *pid)
14796 return pid_nr_ns(pid, current->nsproxy->pid_ns);
14797 diff -NurpP --minimal linux-3.2.8/kernel/pid_namespace.c linux-3.2.8-vs2.3.2.7/kernel/pid_namespace.c
14798 --- linux-3.2.8/kernel/pid_namespace.c 2011-05-22 16:17:59.000000000 +0200
14799 +++ linux-3.2.8-vs2.3.2.7/kernel/pid_namespace.c 2011-12-05 19:33:02.000000000 +0100
14801 #include <linux/acct.h>
14802 #include <linux/slab.h>
14803 #include <linux/proc_fs.h>
14804 +#include <linux/vserver/global.h>
14806 #define BITS_PER_PAGE (PAGE_SIZE*8)
14808 @@ -88,6 +89,7 @@ static struct pid_namespace *create_pid_
14811 kref_init(&ns->kref);
14812 + atomic_inc(&vs_global_pid_ns);
14814 ns->parent = get_pid_ns(parent_pid_ns);
14816 @@ -119,6 +121,7 @@ static void destroy_pid_namespace(struct
14818 for (i = 0; i < PIDMAP_ENTRIES; i++)
14819 kfree(ns->pidmap[i].page);
14820 + atomic_dec(&vs_global_pid_ns);
14821 kmem_cache_free(pid_ns_cachep, ns);
14824 diff -NurpP --minimal linux-3.2.8/kernel/posix-timers.c linux-3.2.8-vs2.3.2.7/kernel/posix-timers.c
14825 --- linux-3.2.8/kernel/posix-timers.c 2012-01-09 16:15:00.000000000 +0100
14826 +++ linux-3.2.8-vs2.3.2.7/kernel/posix-timers.c 2011-12-05 19:44:00.000000000 +0100
14828 #include <linux/wait.h>
14829 #include <linux/workqueue.h>
14830 #include <linux/export.h>
14831 +#include <linux/vs_context.h>
14834 * Management arrays for POSIX timers. Timers are kept in slab memory
14835 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
14837 struct task_struct *task;
14838 int shared, ret = -1;
14841 * FIXME: if ->sigq is queued we can race with
14842 * dequeue_signal()->do_schedule_next_timer().
14843 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
14845 task = pid_task(timr->it_pid, PIDTYPE_PID);
14847 + struct vx_info_save vxis;
14848 + struct vx_info *vxi;
14850 + vxi = get_vx_info(task->vx_info);
14851 + enter_vx_info(vxi, &vxis);
14852 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
14853 ret = send_sigqueue(timr->sigq, task, shared);
14854 + leave_vx_info(&vxis);
14855 + put_vx_info(vxi);
14859 /* If we failed to send the signal the timer stops. */
14862 diff -NurpP --minimal linux-3.2.8/kernel/printk.c linux-3.2.8-vs2.3.2.7/kernel/printk.c
14863 --- linux-3.2.8/kernel/printk.c 2012-01-09 16:15:00.000000000 +0100
14864 +++ linux-3.2.8-vs2.3.2.7/kernel/printk.c 2011-12-15 01:11:33.000000000 +0100
14866 #include <linux/cpu.h>
14867 #include <linux/notifier.h>
14868 #include <linux/rculist.h>
14869 +#include <linux/vs_cvirt.h>
14871 #include <asm/uaccess.h>
14873 @@ -314,7 +315,7 @@ static int check_syslog_permissions(int
14876 if (syslog_action_restricted(type)) {
14877 - if (capable(CAP_SYSLOG))
14878 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
14880 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
14881 if (capable(CAP_SYS_ADMIN)) {
14882 @@ -344,12 +345,9 @@ int do_syslog(int type, char __user *buf
14887 - case SYSLOG_ACTION_CLOSE: /* Close log */
14889 - case SYSLOG_ACTION_OPEN: /* Open log */
14891 - case SYSLOG_ACTION_READ: /* Read from log */
14892 + if ((type == SYSLOG_ACTION_READ) ||
14893 + (type == SYSLOG_ACTION_READ_ALL) ||
14894 + (type == SYSLOG_ACTION_READ_CLEAR)) {
14896 if (!buf || len < 0)
14898 @@ -360,6 +358,16 @@ int do_syslog(int type, char __user *buf
14903 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14904 + return vx_do_syslog(type, buf, len);
14907 + case SYSLOG_ACTION_CLOSE: /* Close log */
14909 + case SYSLOG_ACTION_OPEN: /* Open log */
14911 + case SYSLOG_ACTION_READ: /* Read from log */
14912 error = wait_event_interruptible(log_wait,
14913 (log_start - log_end));
14915 @@ -386,16 +394,6 @@ int do_syslog(int type, char __user *buf
14917 /* Read last kernel messages */
14918 case SYSLOG_ACTION_READ_ALL:
14920 - if (!buf || len < 0)
14925 - if (!access_ok(VERIFY_WRITE, buf, len)) {
14930 if (count > log_buf_len)
14931 count = log_buf_len;
14932 diff -NurpP --minimal linux-3.2.8/kernel/ptrace.c linux-3.2.8-vs2.3.2.7/kernel/ptrace.c
14933 --- linux-3.2.8/kernel/ptrace.c 2012-01-09 16:15:00.000000000 +0100
14934 +++ linux-3.2.8-vs2.3.2.7/kernel/ptrace.c 2012-01-09 16:19:31.000000000 +0100
14936 #include <linux/syscalls.h>
14937 #include <linux/uaccess.h>
14938 #include <linux/regset.h>
14939 +#include <linux/vs_context.h>
14940 #include <linux/hw_breakpoint.h>
14941 #include <linux/cn_proc.h>
14943 @@ -209,6 +210,11 @@ ok:
14944 dumpable = get_dumpable(task->mm);
14945 if (!dumpable && !task_ns_capable(task, CAP_SYS_PTRACE))
14947 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
14949 + if (!vx_check(task->xid, VS_IDENT) &&
14950 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
14953 return security_ptrace_access_check(task, mode);
14955 diff -NurpP --minimal linux-3.2.8/kernel/sched.c linux-3.2.8-vs2.3.2.7/kernel/sched.c
14956 --- linux-3.2.8/kernel/sched.c 2012-01-09 16:15:00.000000000 +0100
14957 +++ linux-3.2.8-vs2.3.2.7/kernel/sched.c 2011-12-15 01:14:00.000000000 +0100
14959 #include <linux/ftrace.h>
14960 #include <linux/slab.h>
14961 #include <linux/init_task.h>
14962 +#include <linux/vs_sched.h>
14963 +#include <linux/vs_cvirt.h>
14965 #include <asm/tlb.h>
14966 #include <asm/irq_regs.h>
14967 @@ -3607,9 +3609,17 @@ static void calc_global_nohz(unsigned lo
14969 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
14971 - loads[0] = (avenrun[0] + offset) << shift;
14972 - loads[1] = (avenrun[1] + offset) << shift;
14973 - loads[2] = (avenrun[2] + offset) << shift;
14974 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
14975 + struct vx_info *vxi = current_vx_info();
14977 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
14978 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
14979 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
14981 + loads[0] = (avenrun[0] + offset) << shift;
14982 + loads[1] = (avenrun[1] + offset) << shift;
14983 + loads[2] = (avenrun[2] + offset) << shift;
14988 @@ -3868,16 +3878,19 @@ void account_user_time(struct task_struc
14989 cputime_t cputime_scaled)
14991 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
14992 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14994 + int nice = (TASK_NICE(p) > 0);
14996 /* Add user time to process. */
14997 p->utime = cputime_add(p->utime, cputime);
14998 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
14999 + vx_account_user(vxi, cputime, nice);
15000 account_group_user_time(p, cputime);
15002 /* Add user time to cpustat. */
15003 tmp = cputime_to_cputime64(cputime);
15004 - if (TASK_NICE(p) > 0)
15006 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15008 cpustat->user = cputime64_add(cpustat->user, tmp);
15009 @@ -3929,10 +3942,12 @@ void __account_system_time(struct task_s
15010 cputime_t cputime_scaled, cputime64_t *target_cputime64)
15012 cputime64_t tmp = cputime_to_cputime64(cputime);
15013 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15015 /* Add system time to process. */
15016 p->stime = cputime_add(p->stime, cputime);
15017 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15018 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15019 account_group_system_time(p, cputime);
15021 /* Add system time to cpustat. */
15022 @@ -5132,7 +5147,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15025 if (increment < 0 && !can_nice(current, nice))
15027 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15029 retval = security_task_setnice(current, nice);
15031 diff -NurpP --minimal linux-3.2.8/kernel/sched_fair.c linux-3.2.8-vs2.3.2.7/kernel/sched_fair.c
15032 --- linux-3.2.8/kernel/sched_fair.c 2012-01-09 16:15:00.000000000 +0100
15033 +++ linux-3.2.8-vs2.3.2.7/kernel/sched_fair.c 2012-01-09 16:19:31.000000000 +0100
15034 @@ -1014,6 +1014,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15035 __enqueue_entity(cfs_rq, se);
15038 + if (entity_is_task(se))
15039 + vx_activate_task(task_of(se));
15040 if (cfs_rq->nr_running == 1) {
15041 list_add_leaf_cfs_rq(cfs_rq);
15042 check_enqueue_throttle(cfs_rq);
15043 @@ -1094,6 +1096,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15044 if (se != cfs_rq->curr)
15045 __dequeue_entity(cfs_rq, se);
15047 + if (entity_is_task(se))
15048 + vx_deactivate_task(task_of(se));
15049 update_cfs_load(cfs_rq, 0);
15050 account_entity_dequeue(cfs_rq, se);
15052 diff -NurpP --minimal linux-3.2.8/kernel/signal.c linux-3.2.8-vs2.3.2.7/kernel/signal.c
15053 --- linux-3.2.8/kernel/signal.c 2012-01-09 16:15:00.000000000 +0100
15054 +++ linux-3.2.8-vs2.3.2.7/kernel/signal.c 2012-01-09 16:19:31.000000000 +0100
15056 #include <linux/freezer.h>
15057 #include <linux/pid_namespace.h>
15058 #include <linux/nsproxy.h>
15059 +#include <linux/vs_context.h>
15060 +#include <linux/vs_pid.h>
15061 #define CREATE_TRACE_POINTS
15062 #include <trace/events/signal.h>
15064 @@ -789,9 +791,18 @@ static int check_kill_permission(int sig
15068 + vxdprintk(VXD_CBIT(misc, 7),
15069 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15070 + sig, info, t, vx_task_xid(t), t->pid);
15072 if (!valid_signal(sig))
15075 +/* FIXME: needed? if so, why?
15076 + if ((info != SEND_SIG_NOINFO) &&
15077 + (is_si_special(info) || !si_fromuser(info)))
15080 if (!si_fromuser(info))
15083 @@ -815,6 +826,20 @@ static int check_kill_permission(int sig
15088 + if (t->pid == 1 && current->xid)
15092 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15093 + loops, maybe ENOENT or EACCES? */
15094 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15095 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15096 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15097 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15101 return security_task_kill(t, info, sig, 0);
15104 @@ -1319,7 +1344,7 @@ int kill_pid_info(int sig, struct siginf
15107 p = pid_task(pid, PIDTYPE_PID);
15109 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15110 error = group_send_sig_info(sig, info, p);
15111 if (unlikely(error == -ESRCH))
15113 @@ -1369,7 +1394,7 @@ int kill_pid_info_as_cred(int sig, struc
15116 p = pid_task(pid, PIDTYPE_PID);
15118 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15122 @@ -1421,8 +1446,10 @@ static int kill_something_info(int sig,
15123 struct task_struct * p;
15125 for_each_process(p) {
15126 - if (task_pid_vnr(p) > 1 &&
15127 - !same_thread_group(p, current)) {
15128 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15129 + task_pid_vnr(p) > 1 &&
15130 + !same_thread_group(p, current) &&
15131 + !vx_current_initpid(p->pid)) {
15132 int err = group_send_sig_info(sig, info, p);
15135 @@ -2255,6 +2282,11 @@ relock:
15136 !sig_kernel_only(signr))
15139 + /* virtual init is protected against user signals */
15140 + if ((info->si_code == SI_USER) &&
15141 + vx_current_initpid(current->pid))
15144 if (sig_kernel_stop(signr)) {
15146 * The default action is to stop all threads in
15147 diff -NurpP --minimal linux-3.2.8/kernel/softirq.c linux-3.2.8-vs2.3.2.7/kernel/softirq.c
15148 --- linux-3.2.8/kernel/softirq.c 2012-01-09 16:15:00.000000000 +0100
15149 +++ linux-3.2.8-vs2.3.2.7/kernel/softirq.c 2011-12-05 19:33:02.000000000 +0100
15151 #include <linux/ftrace.h>
15152 #include <linux/smp.h>
15153 #include <linux/tick.h>
15154 +#include <linux/vs_context.h>
15156 #define CREATE_TRACE_POINTS
15157 #include <trace/events/irq.h>
15158 diff -NurpP --minimal linux-3.2.8/kernel/sys.c linux-3.2.8-vs2.3.2.7/kernel/sys.c
15159 --- linux-3.2.8/kernel/sys.c 2012-01-09 16:15:00.000000000 +0100
15160 +++ linux-3.2.8-vs2.3.2.7/kernel/sys.c 2011-12-05 19:33:02.000000000 +0100
15162 #include <linux/syscalls.h>
15163 #include <linux/kprobes.h>
15164 #include <linux/user_namespace.h>
15165 +#include <linux/vs_pid.h>
15167 #include <linux/kmsg_dump.h>
15168 /* Move somewhere else to avoid recompiling? */
15169 @@ -155,7 +156,10 @@ static int set_one_prio(struct task_stru
15172 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15174 + if (vx_flags(VXF_IGNEG_NICE, 0))
15180 no_nice = security_task_setnice(p, niceval);
15181 @@ -205,6 +209,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15183 pgrp = task_pgrp(current);
15184 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15185 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15187 error = set_one_prio(p, niceval, error);
15188 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15190 @@ -268,6 +274,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15192 pgrp = task_pgrp(current);
15193 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15194 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15196 niceval = 20 - task_nice(p);
15197 if (niceval > retval)
15199 @@ -418,6 +426,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15201 static DEFINE_MUTEX(reboot_mutex);
15203 +long vs_reboot(unsigned int, void __user *);
15206 * Reboot system call: for obvious reasons only root may call it,
15207 * and even root needs to set up some magic numbers in the registers
15208 @@ -450,6 +460,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15209 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15210 cmd = LINUX_REBOOT_CMD_HALT;
15212 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15213 + return vs_reboot(cmd, arg);
15215 mutex_lock(&reboot_mutex);
15217 case LINUX_REBOOT_CMD_RESTART:
15218 @@ -1273,7 +1286,8 @@ SYSCALL_DEFINE2(sethostname, char __user
15220 char tmp[__NEW_UTS_LEN];
15222 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15223 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15224 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15227 if (len < 0 || len > __NEW_UTS_LEN)
15228 @@ -1324,7 +1338,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
15230 char tmp[__NEW_UTS_LEN];
15232 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15233 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15234 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15236 if (len < 0 || len > __NEW_UTS_LEN)
15238 @@ -1443,7 +1458,7 @@ int do_prlimit(struct task_struct *tsk,
15239 /* Keep the capable check against init_user_ns until
15240 cgroups can contain all limits */
15241 if (new_rlim->rlim_max > rlim->rlim_max &&
15242 - !capable(CAP_SYS_RESOURCE))
15243 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15246 retval = security_task_setrlimit(tsk->group_leader,
15247 @@ -1497,7 +1512,8 @@ static int check_prlimit_permission(stru
15248 cred->gid == tcred->sgid &&
15249 cred->gid == tcred->gid))
15251 - if (ns_capable(tcred->user->user_ns, CAP_SYS_RESOURCE))
15252 + if (vx_ns_capable(tcred->user->user_ns,
15253 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15257 diff -NurpP --minimal linux-3.2.8/kernel/sysctl.c linux-3.2.8-vs2.3.2.7/kernel/sysctl.c
15258 --- linux-3.2.8/kernel/sysctl.c 2012-01-09 16:15:00.000000000 +0100
15259 +++ linux-3.2.8-vs2.3.2.7/kernel/sysctl.c 2011-12-05 19:33:02.000000000 +0100
15261 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15262 #include <linux/lockdep.h>
15264 +extern char vshelper_path[];
15265 #ifdef CONFIG_CHR_DEV_SG
15266 #include <scsi/sg.h>
15268 @@ -572,6 +573,13 @@ static struct ctl_table kern_table[] = {
15269 .proc_handler = proc_dostring,
15273 + .procname = "vshelper",
15274 + .data = &vshelper_path,
15277 + .proc_handler = &proc_dostring,
15279 #ifdef CONFIG_CHR_DEV_SG
15281 .procname = "sg-big-buff",
15282 diff -NurpP --minimal linux-3.2.8/kernel/sysctl_binary.c linux-3.2.8-vs2.3.2.7/kernel/sysctl_binary.c
15283 --- linux-3.2.8/kernel/sysctl_binary.c 2012-01-09 16:15:00.000000000 +0100
15284 +++ linux-3.2.8-vs2.3.2.7/kernel/sysctl_binary.c 2012-01-09 16:19:31.000000000 +0100
15285 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15287 { CTL_INT, KERN_PANIC, "panic" },
15288 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15289 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15291 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15292 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15293 diff -NurpP --minimal linux-3.2.8/kernel/time/timekeeping.c linux-3.2.8-vs2.3.2.7/kernel/time/timekeeping.c
15294 --- linux-3.2.8/kernel/time/timekeeping.c 2012-01-09 16:15:00.000000000 +0100
15295 +++ linux-3.2.8-vs2.3.2.7/kernel/time/timekeeping.c 2011-12-05 19:33:02.000000000 +0100
15296 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
15297 } while (read_seqretry(&xtime_lock, seq));
15299 timespec_add_ns(ts, nsecs);
15300 + vx_adjust_timespec(ts);
15303 EXPORT_SYMBOL(getnstimeofday);
15304 diff -NurpP --minimal linux-3.2.8/kernel/time.c linux-3.2.8-vs2.3.2.7/kernel/time.c
15305 --- linux-3.2.8/kernel/time.c 2012-01-09 16:15:00.000000000 +0100
15306 +++ linux-3.2.8-vs2.3.2.7/kernel/time.c 2011-12-05 19:33:02.000000000 +0100
15307 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15311 - do_settimeofday(&tv);
15312 + vx_settimeofday(&tv);
15316 @@ -177,7 +177,7 @@ int do_sys_settimeofday(const struct tim
15317 /* SMP safe, again the code in arch/foo/time.c should
15318 * globally block out interrupts when it runs.
15320 - return do_settimeofday(tv);
15321 + return vx_settimeofday(tv);
15325 diff -NurpP --minimal linux-3.2.8/kernel/timer.c linux-3.2.8-vs2.3.2.7/kernel/timer.c
15326 --- linux-3.2.8/kernel/timer.c 2012-01-09 16:15:00.000000000 +0100
15327 +++ linux-3.2.8-vs2.3.2.7/kernel/timer.c 2011-12-15 01:11:33.000000000 +0100
15329 #include <linux/irq_work.h>
15330 #include <linux/sched.h>
15331 #include <linux/slab.h>
15332 +#include <linux/vs_base.h>
15333 +#include <linux/vs_cvirt.h>
15334 +#include <linux/vs_pid.h>
15335 +#include <linux/vserver/sched.h>
15337 #include <asm/uaccess.h>
15338 #include <asm/unistd.h>
15339 @@ -1336,12 +1340,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15346 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15347 - * should be moved into arch/i386 instead?
15351 * sys_getpid - return the thread group id of the current process
15352 @@ -1370,10 +1368,23 @@ SYSCALL_DEFINE0(getppid)
15354 pid = task_tgid_vnr(rcu_dereference(current->real_parent));
15356 + return vx_map_pid(pid);
15363 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15366 +asmlinkage long do_getxpid(long *ppid)
15368 + *ppid = sys_getppid();
15369 + return sys_getpid();
15372 +#else /* _alpha_ */
15374 SYSCALL_DEFINE0(getuid)
15376 /* Only we change this so SMP safe */
15377 diff -NurpP --minimal linux-3.2.8/kernel/user_namespace.c linux-3.2.8-vs2.3.2.7/kernel/user_namespace.c
15378 --- linux-3.2.8/kernel/user_namespace.c 2012-01-09 16:15:00.000000000 +0100
15379 +++ linux-3.2.8-vs2.3.2.7/kernel/user_namespace.c 2011-12-05 19:33:02.000000000 +0100
15381 #include <linux/user_namespace.h>
15382 #include <linux/highuid.h>
15383 #include <linux/cred.h>
15384 +#include <linux/vserver/global.h>
15386 static struct kmem_cache *user_ns_cachep __read_mostly;
15388 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
15391 kref_init(&ns->kref);
15392 + atomic_inc(&vs_global_user_ns);
15394 for (n = 0; n < UIDHASH_SZ; ++n)
15395 INIT_HLIST_HEAD(ns->uidhash_table + n);
15396 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
15397 struct user_namespace *ns =
15398 container_of(kref, struct user_namespace, kref);
15400 + /* FIXME: maybe move into destroyer? */
15401 + atomic_dec(&vs_global_user_ns);
15402 INIT_WORK(&ns->destroyer, free_user_ns_work);
15403 schedule_work(&ns->destroyer);
15405 diff -NurpP --minimal linux-3.2.8/kernel/utsname.c linux-3.2.8-vs2.3.2.7/kernel/utsname.c
15406 --- linux-3.2.8/kernel/utsname.c 2012-01-09 16:15:00.000000000 +0100
15407 +++ linux-3.2.8-vs2.3.2.7/kernel/utsname.c 2011-12-05 19:33:02.000000000 +0100
15408 @@ -16,14 +16,17 @@
15409 #include <linux/slab.h>
15410 #include <linux/user_namespace.h>
15411 #include <linux/proc_fs.h>
15412 +#include <linux/vserver/global.h>
15414 static struct uts_namespace *create_uts_ns(void)
15416 struct uts_namespace *uts_ns;
15418 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15421 kref_init(&uts_ns->kref);
15422 + atomic_inc(&vs_global_uts_ns);
15427 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
15428 * @old_ns: namespace to clone
15429 * Return NULL on error (failure to kmalloc), new ns otherwise
15431 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
15432 - struct uts_namespace *old_ns)
15433 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
15434 + struct user_namespace *old_user)
15436 struct uts_namespace *ns;
15438 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
15440 down_read(&uts_sem);
15441 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
15442 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
15443 + ns->user_ns = get_user_ns(old_user);
15447 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
15450 struct uts_namespace *copy_utsname(unsigned long flags,
15451 - struct task_struct *tsk)
15452 + struct uts_namespace *old_ns,
15453 + struct user_namespace *user_ns)
15455 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
15456 struct uts_namespace *new_ns;
15459 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
15460 if (!(flags & CLONE_NEWUTS))
15463 - new_ns = clone_uts_ns(tsk, old_ns);
15464 + new_ns = clone_uts_ns(old_ns, user_ns);
15466 put_uts_ns(old_ns);
15468 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
15470 ns = container_of(kref, struct uts_namespace, kref);
15471 put_user_ns(ns->user_ns);
15472 + atomic_dec(&vs_global_uts_ns);
15476 diff -NurpP --minimal linux-3.2.8/kernel/vserver/Kconfig linux-3.2.8-vs2.3.2.7/kernel/vserver/Kconfig
15477 --- linux-3.2.8/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
15478 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/Kconfig 2011-12-15 01:52:48.000000000 +0100
15481 +# Linux VServer configuration
15484 +menu "Linux VServer"
15486 +config VSERVER_AUTO_LBACK
15487 + bool "Automatically Assign Loopback IP"
15490 + Automatically assign a guest specific loopback
15491 + IP and add it to the kernel network stack on
15494 +config VSERVER_AUTO_SINGLE
15495 + bool "Automatic Single IP Special Casing"
15496 + depends on EXPERIMENTAL
15499 + This allows network contexts with a single IP to
15500 + automatically remap 0.0.0.0 bindings to that IP,
15501 + avoiding further network checks and improving
15504 + (note: such guests do not allow to change the ip
15505 + on the fly and do not show loopback addresses)
15507 +config VSERVER_COWBL
15508 + bool "Enable COW Immutable Link Breaking"
15511 + This enables the COW (Copy-On-Write) link break code.
15512 + It allows you to treat unified files like normal files
15513 + when writing to them (which will implicitely break the
15514 + link and create a copy of the unified file)
15516 +config VSERVER_VTIME
15517 + bool "Enable Virtualized Guest Time"
15518 + depends on EXPERIMENTAL
15521 + This enables per guest time offsets to allow for
15522 + adjusting the system clock individually per guest.
15523 + this adds some overhead to the time functions and
15524 + therefore should not be enabled without good reason.
15526 +config VSERVER_DEVICE
15527 + bool "Enable Guest Device Mapping"
15528 + depends on EXPERIMENTAL
15531 + This enables generic device remapping.
15533 +config VSERVER_PROC_SECURE
15534 + bool "Enable Proc Security"
15535 + depends on PROC_FS
15538 + This configures ProcFS security to initially hide
15539 + non-process entries for all contexts except the main and
15540 + spectator context (i.e. for all guests), which is a secure
15543 + (note: on 1.2x the entries were visible by default)
15546 + prompt "Persistent Inode Tagging"
15547 + default TAGGING_ID24
15549 + This adds persistent context information to filesystems
15550 + mounted with the tagxid option. Tagging is a requirement
15551 + for per-context disk limits and per-context quota.
15554 +config TAGGING_NONE
15557 + do not store per-context information in inodes.
15559 +config TAGGING_UID16
15560 + bool "UID16/GID32"
15562 + reduces UID to 16 bit, but leaves GID at 32 bit.
15564 +config TAGGING_GID16
15565 + bool "UID32/GID16"
15567 + reduces GID to 16 bit, but leaves UID at 32 bit.
15569 +config TAGGING_ID24
15570 + bool "UID24/GID24"
15572 + uses the upper 8bit from UID and GID for XID tagging
15573 + which leaves 24bit for UID/GID each, which should be
15574 + more than sufficient for normal use.
15576 +config TAGGING_INTERN
15577 + bool "UID32/GID32"
15579 + this uses otherwise reserved inode fields in the on
15580 + disk representation, which limits the use to a few
15581 + filesystems (currently ext2 and ext3)
15586 + bool "Tag NFSD User Auth and Files"
15589 + Enable this if you do want the in-kernel NFS
15590 + Server to use the tagging specified above.
15591 + (will require patched clients too)
15593 +config VSERVER_PRIVACY
15594 + bool "Honor Privacy Aspects of Guests"
15597 + When enabled, most context checks will disallow
15598 + access to structures assigned to a specific context,
15599 + like ptys or loop devices.
15601 +config VSERVER_CONTEXTS
15602 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15604 + default "768" if 64BIT
15607 + This setting will optimize certain data structures
15608 + and memory allocations according to the expected
15611 + note: this is not a strict upper limit.
15613 +config VSERVER_WARN
15614 + bool "VServer Warnings"
15617 + This enables various runtime warnings, which will
15618 + notify about potential manipulation attempts or
15619 + resource shortage. It is generally considered to
15620 + be a good idea to have that enabled.
15622 +config VSERVER_WARN_DEVPTS
15623 + bool "VServer DevPTS Warnings"
15624 + depends on VSERVER_WARN
15627 + This enables DevPTS related warnings, issued when a
15628 + process inside a context tries to lookup or access
15629 + a dynamic pts from the host or a different context.
15631 +config VSERVER_DEBUG
15632 + bool "VServer Debugging Code"
15635 + Set this to yes if you want to be able to activate
15636 + debugging output at runtime. It adds a very small
15637 + overhead to all vserver related functions and
15638 + increases the kernel size by about 20k.
15640 +config VSERVER_HISTORY
15641 + bool "VServer History Tracing"
15642 + depends on VSERVER_DEBUG
15645 + Set this to yes if you want to record the history of
15646 + linux-vserver activities, so they can be replayed in
15647 + the event of a kernel panic or oops.
15649 +config VSERVER_HISTORY_SIZE
15650 + int "Per-CPU History Size (32-65536)"
15651 + depends on VSERVER_HISTORY
15655 + This allows you to specify the number of entries in
15656 + the per-CPU history buffer.
15659 + prompt "Quotes used in debug and warn messages"
15660 + default QUOTES_ISO8859
15662 +config QUOTES_ISO8859
15663 + bool "Extended ASCII (ISO 8859) angle quotes"
15665 + This uses the extended ASCII characters \xbb
15666 + and \xab for quoting file and process names.
15668 +config QUOTES_UTF8
15669 + bool "UTF-8 angle quotes"
15671 + This uses the the UTF-8 sequences for angle
15672 + quotes to quote file and process names.
15674 +config QUOTES_ASCII
15675 + bool "ASCII single quotes"
15677 + This uses the ASCII single quote character
15678 + (\x27) to quote file and process names.
15688 + select NAMESPACES
15694 +config VSERVER_SECURITY
15696 + depends on SECURITY
15698 + select SECURITY_CAPABILITIES
15700 +config VSERVER_DISABLED
15704 diff -NurpP --minimal linux-3.2.8/kernel/vserver/Makefile linux-3.2.8-vs2.3.2.7/kernel/vserver/Makefile
15705 --- linux-3.2.8/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
15706 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/Makefile 2011-12-05 19:33:02.000000000 +0100
15709 +# Makefile for the Linux vserver routines.
15713 +obj-y += vserver.o
15715 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15716 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15719 +vserver-$(CONFIG_INET) += inet.o
15720 +vserver-$(CONFIG_PROC_FS) += proc.o
15721 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15722 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15723 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15724 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
15726 diff -NurpP --minimal linux-3.2.8/kernel/vserver/cacct.c linux-3.2.8-vs2.3.2.7/kernel/vserver/cacct.c
15727 --- linux-3.2.8/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
15728 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/cacct.c 2011-12-05 19:33:02.000000000 +0100
15731 + * linux/kernel/vserver/cacct.c
15733 + * Virtual Server: Context Accounting
15735 + * Copyright (C) 2006-2007 Herbert Pötzl
15737 + * V0.01 added accounting stats
15741 +#include <linux/types.h>
15742 +#include <linux/vs_context.h>
15743 +#include <linux/vserver/cacct_cmd.h>
15744 +#include <linux/vserver/cacct_int.h>
15746 +#include <asm/errno.h>
15747 +#include <asm/uaccess.h>
15750 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15752 + struct vcmd_sock_stat_v0 vc_data;
15755 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15758 + field = vc_data.field;
15759 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15762 + for (j = 0; j < 3; j++) {
15763 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15764 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15767 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15772 diff -NurpP --minimal linux-3.2.8/kernel/vserver/cacct_init.h linux-3.2.8-vs2.3.2.7/kernel/vserver/cacct_init.h
15773 --- linux-3.2.8/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
15774 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/cacct_init.h 2011-12-05 19:33:02.000000000 +0100
15778 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
15783 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15784 + for (j = 0; j < 3; j++) {
15785 + atomic_long_set(&cacct->sock[i][j].count, 0);
15786 + atomic_long_set(&cacct->sock[i][j].total, 0);
15789 + for (i = 0; i < 8; i++)
15790 + atomic_set(&cacct->slab[i], 0);
15791 + for (i = 0; i < 5; i++)
15792 + for (j = 0; j < 4; j++)
15793 + atomic_set(&cacct->page[i][j], 0);
15796 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
15801 diff -NurpP --minimal linux-3.2.8/kernel/vserver/cacct_proc.h linux-3.2.8-vs2.3.2.7/kernel/vserver/cacct_proc.h
15802 --- linux-3.2.8/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
15803 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/cacct_proc.h 2011-12-05 19:33:02.000000000 +0100
15805 +#ifndef _VX_CACCT_PROC_H
15806 +#define _VX_CACCT_PROC_H
15808 +#include <linux/vserver/cacct_int.h>
15811 +#define VX_SOCKA_TOP \
15812 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
15814 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
15816 + int i, j, length = 0;
15817 + static char *type[VXA_SOCK_SIZE] = {
15818 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
15821 + length += sprintf(buffer + length, VX_SOCKA_TOP);
15822 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15823 + length += sprintf(buffer + length, "%s:", type[i]);
15824 + for (j = 0; j < 3; j++) {
15825 + length += sprintf(buffer + length,
15826 + "\t%10lu/%-10lu",
15827 + vx_sock_count(cacct, i, j),
15828 + vx_sock_total(cacct, i, j));
15830 + buffer[length++] = '\n';
15833 + length += sprintf(buffer + length, "\n");
15834 + length += sprintf(buffer + length,
15835 + "slab:\t %8u %8u %8u %8u\n",
15836 + atomic_read(&cacct->slab[1]),
15837 + atomic_read(&cacct->slab[4]),
15838 + atomic_read(&cacct->slab[0]),
15839 + atomic_read(&cacct->slab[2]));
15841 + length += sprintf(buffer + length, "\n");
15842 + for (i = 0; i < 5; i++) {
15843 + length += sprintf(buffer + length,
15844 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
15845 + atomic_read(&cacct->page[i][0]),
15846 + atomic_read(&cacct->page[i][1]),
15847 + atomic_read(&cacct->page[i][2]),
15848 + atomic_read(&cacct->page[i][3]),
15849 + atomic_read(&cacct->page[i][4]),
15850 + atomic_read(&cacct->page[i][5]),
15851 + atomic_read(&cacct->page[i][6]),
15852 + atomic_read(&cacct->page[i][7]));
15857 +#endif /* _VX_CACCT_PROC_H */
15858 diff -NurpP --minimal linux-3.2.8/kernel/vserver/context.c linux-3.2.8-vs2.3.2.7/kernel/vserver/context.c
15859 --- linux-3.2.8/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
15860 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/context.c 2011-12-05 19:33:02.000000000 +0100
15863 + * linux/kernel/vserver/context.c
15865 + * Virtual Server: Context Support
15867 + * Copyright (C) 2003-2011 Herbert Pötzl
15869 + * V0.01 context helper
15870 + * V0.02 vx_ctx_kill syscall command
15871 + * V0.03 replaced context_info calls
15872 + * V0.04 redesign of struct (de)alloc
15873 + * V0.05 rlimit basic implementation
15874 + * V0.06 task_xid and info commands
15875 + * V0.07 context flags and caps
15876 + * V0.08 switch to RCU based hash
15877 + * V0.09 revert to non RCU for now
15878 + * V0.10 and back to working RCU hash
15879 + * V0.11 and back to locking again
15880 + * V0.12 referenced context store
15881 + * V0.13 separate per cpu data
15882 + * V0.14 changed vcmds to vxi arg
15883 + * V0.15 added context stat
15884 + * V0.16 have __create claim() the vxi
15885 + * V0.17 removed older and legacy stuff
15886 + * V0.18 added user credentials
15887 + * V0.19 added warn mask
15891 +#include <linux/slab.h>
15892 +#include <linux/types.h>
15893 +#include <linux/security.h>
15894 +#include <linux/pid_namespace.h>
15895 +#include <linux/capability.h>
15897 +#include <linux/vserver/context.h>
15898 +#include <linux/vserver/network.h>
15899 +#include <linux/vserver/debug.h>
15900 +#include <linux/vserver/limit.h>
15901 +#include <linux/vserver/limit_int.h>
15902 +#include <linux/vserver/space.h>
15903 +#include <linux/init_task.h>
15904 +#include <linux/fs_struct.h>
15905 +#include <linux/cred.h>
15907 +#include <linux/vs_context.h>
15908 +#include <linux/vs_limit.h>
15909 +#include <linux/vs_pid.h>
15910 +#include <linux/vserver/context_cmd.h>
15912 +#include "cvirt_init.h"
15913 +#include "cacct_init.h"
15914 +#include "limit_init.h"
15915 +#include "sched_init.h"
15918 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
15919 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
15922 +/* now inactive context structures */
15924 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
15926 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
15929 +/* __alloc_vx_info()
15931 + * allocate an initialized vx_info struct
15932 + * doesn't make it visible (hash) */
15934 +static struct vx_info *__alloc_vx_info(xid_t xid)
15936 + struct vx_info *new = NULL;
15939 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
15941 + /* would this benefit from a slab cache? */
15942 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
15946 + memset(new, 0, sizeof(struct vx_info));
15948 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
15949 + if (!new->ptr_pc)
15952 + new->vx_id = xid;
15953 + INIT_HLIST_NODE(&new->vx_hlist);
15954 + atomic_set(&new->vx_usecnt, 0);
15955 + atomic_set(&new->vx_tasks, 0);
15956 + new->vx_parent = NULL;
15957 + new->vx_state = 0;
15958 + init_waitqueue_head(&new->vx_wait);
15960 + /* prepare reaper */
15961 + get_task_struct(init_pid_ns.child_reaper);
15962 + new->vx_reaper = init_pid_ns.child_reaper;
15963 + new->vx_badness_bias = 0;
15965 + /* rest of init goes here */
15966 + vx_info_init_limit(&new->limit);
15967 + vx_info_init_sched(&new->sched);
15968 + vx_info_init_cvirt(&new->cvirt);
15969 + vx_info_init_cacct(&new->cacct);
15971 + /* per cpu data structures */
15972 + for_each_possible_cpu(cpu) {
15973 + vx_info_init_sched_pc(
15974 + &vx_per_cpu(new, sched_pc, cpu), cpu);
15975 + vx_info_init_cvirt_pc(
15976 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
15979 + new->vx_flags = VXF_INIT_SET;
15980 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
15981 + new->vx_ccaps = 0;
15982 + new->vx_umask = 0;
15983 + new->vx_wmask = 0;
15985 + new->reboot_cmd = 0;
15986 + new->exit_code = 0;
15988 + // preconfig spaces
15989 + for (index = 0; index < VX_SPACES; index++) {
15990 + struct _vx_space *space = &new->space[index];
15993 + spin_lock(&init_fs.lock);
15995 + spin_unlock(&init_fs.lock);
15996 + space->vx_fs = &init_fs;
15998 + /* FIXME: do we want defaults? */
15999 + // space->vx_real_cred = 0;
16000 + // space->vx_cred = 0;
16004 + vxdprintk(VXD_CBIT(xid, 0),
16005 + "alloc_vx_info(%d) = %p", xid, new);
16006 + vxh_alloc_vx_info(new);
16007 + atomic_inc(&vx_global_ctotal);
16016 +/* __dealloc_vx_info()
16018 + * final disposal of vx_info */
16020 +static void __dealloc_vx_info(struct vx_info *vxi)
16022 +#ifdef CONFIG_VSERVER_WARN
16023 + struct vx_info_save vxis;
16026 + vxdprintk(VXD_CBIT(xid, 0),
16027 + "dealloc_vx_info(%p)", vxi);
16028 + vxh_dealloc_vx_info(vxi);
16030 +#ifdef CONFIG_VSERVER_WARN
16031 + enter_vx_info(vxi, &vxis);
16032 + vx_info_exit_limit(&vxi->limit);
16033 + vx_info_exit_sched(&vxi->sched);
16034 + vx_info_exit_cvirt(&vxi->cvirt);
16035 + vx_info_exit_cacct(&vxi->cacct);
16037 + for_each_possible_cpu(cpu) {
16038 + vx_info_exit_sched_pc(
16039 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16040 + vx_info_exit_cvirt_pc(
16041 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16043 + leave_vx_info(&vxis);
16047 + vxi->vx_state |= VXS_RELEASED;
16050 + free_percpu(vxi->ptr_pc);
16053 + atomic_dec(&vx_global_ctotal);
16056 +static void __shutdown_vx_info(struct vx_info *vxi)
16058 + struct nsproxy *nsproxy;
16059 + struct fs_struct *fs;
16060 + struct cred *cred;
16065 + vxi->vx_state |= VXS_SHUTDOWN;
16066 + vs_state_change(vxi, VSC_SHUTDOWN);
16068 + for (index = 0; index < VX_SPACES; index++) {
16069 + struct _vx_space *space = &vxi->space[index];
16071 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16073 + put_nsproxy(nsproxy);
16075 + fs = xchg(&space->vx_fs, NULL);
16076 + spin_lock(&fs->lock);
16077 + kill = !--fs->users;
16078 + spin_unlock(&fs->lock);
16080 + free_fs_struct(fs);
16082 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16084 + abort_creds(cred);
16088 +/* exported stuff */
16090 +void free_vx_info(struct vx_info *vxi)
16092 + unsigned long flags;
16095 + /* check for reference counts first */
16096 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16097 + BUG_ON(atomic_read(&vxi->vx_tasks));
16099 + /* context must not be hashed */
16100 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16102 + /* context shutdown is mandatory */
16103 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16105 + /* spaces check */
16106 + for (index = 0; index < VX_SPACES; index++) {
16107 + struct _vx_space *space = &vxi->space[index];
16109 + BUG_ON(space->vx_nsproxy);
16110 + BUG_ON(space->vx_fs);
16111 + // BUG_ON(space->vx_real_cred);
16112 + // BUG_ON(space->vx_cred);
16115 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16116 + hlist_del(&vxi->vx_hlist);
16117 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16119 + __dealloc_vx_info(vxi);
16123 +/* hash table for vx_info hash */
16125 +#define VX_HASH_SIZE 13
16127 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16128 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16130 +static DEFINE_SPINLOCK(vx_info_hash_lock);
16133 +static inline unsigned int __hashval(xid_t xid)
16135 + return (xid % VX_HASH_SIZE);
16140 +/* __hash_vx_info()
16142 + * add the vxi to the global hash table
16143 + * requires the hash_lock to be held */
16145 +static inline void __hash_vx_info(struct vx_info *vxi)
16147 + struct hlist_head *head;
16149 + vxd_assert_lock(&vx_info_hash_lock);
16150 + vxdprintk(VXD_CBIT(xid, 4),
16151 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16152 + vxh_hash_vx_info(vxi);
16154 + /* context must not be hashed */
16155 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16157 + vxi->vx_state |= VXS_HASHED;
16158 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16159 + hlist_add_head(&vxi->vx_hlist, head);
16160 + atomic_inc(&vx_global_cactive);
16163 +/* __unhash_vx_info()
16165 + * remove the vxi from the global hash table
16166 + * requires the hash_lock to be held */
16168 +static inline void __unhash_vx_info(struct vx_info *vxi)
16170 + unsigned long flags;
16172 + vxd_assert_lock(&vx_info_hash_lock);
16173 + vxdprintk(VXD_CBIT(xid, 4),
16174 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16175 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16176 + vxh_unhash_vx_info(vxi);
16178 + /* context must be hashed */
16179 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16180 + /* but without tasks */
16181 + BUG_ON(atomic_read(&vxi->vx_tasks));
16183 + vxi->vx_state &= ~VXS_HASHED;
16184 + hlist_del_init(&vxi->vx_hlist);
16185 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16186 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16187 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16188 + atomic_dec(&vx_global_cactive);
16192 +/* __lookup_vx_info()
16194 + * requires the hash_lock to be held
16195 + * doesn't increment the vx_refcnt */
16197 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16199 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16200 + struct hlist_node *pos;
16201 + struct vx_info *vxi;
16203 + vxd_assert_lock(&vx_info_hash_lock);
16204 + hlist_for_each(pos, head) {
16205 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16207 + if (vxi->vx_id == xid)
16212 + vxdprintk(VXD_CBIT(xid, 0),
16213 + "__lookup_vx_info(#%u): %p[#%u]",
16214 + xid, vxi, vxi ? vxi->vx_id : 0);
16215 + vxh_lookup_vx_info(vxi, xid);
16220 +/* __create_vx_info()
16222 + * create the requested context
16223 + * get(), claim() and hash it */
16225 +static struct vx_info *__create_vx_info(int id)
16227 + struct vx_info *new, *vxi = NULL;
16229 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16231 + if (!(new = __alloc_vx_info(id)))
16232 + return ERR_PTR(-ENOMEM);
16234 + /* required to make dynamic xids unique */
16235 + spin_lock(&vx_info_hash_lock);
16237 + /* static context requested */
16238 + if ((vxi = __lookup_vx_info(id))) {
16239 + vxdprintk(VXD_CBIT(xid, 0),
16240 + "create_vx_info(%d) = %p (already there)", id, vxi);
16241 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16242 + vxi = ERR_PTR(-EBUSY);
16244 + vxi = ERR_PTR(-EEXIST);
16247 + /* new context */
16248 + vxdprintk(VXD_CBIT(xid, 0),
16249 + "create_vx_info(%d) = %p (new)", id, new);
16250 + claim_vx_info(new, NULL);
16251 + __hash_vx_info(get_vx_info(new));
16252 + vxi = new, new = NULL;
16255 + spin_unlock(&vx_info_hash_lock);
16256 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16258 + __dealloc_vx_info(new);
16263 +/* exported stuff */
16266 +void unhash_vx_info(struct vx_info *vxi)
16268 + spin_lock(&vx_info_hash_lock);
16269 + __unhash_vx_info(vxi);
16270 + spin_unlock(&vx_info_hash_lock);
16271 + __shutdown_vx_info(vxi);
16272 + __wakeup_vx_info(vxi);
16276 +/* lookup_vx_info()
16278 + * search for a vx_info and get() it
16279 + * negative id means current */
16281 +struct vx_info *lookup_vx_info(int id)
16283 + struct vx_info *vxi = NULL;
16286 + vxi = get_vx_info(current_vx_info());
16287 + } else if (id > 1) {
16288 + spin_lock(&vx_info_hash_lock);
16289 + vxi = get_vx_info(__lookup_vx_info(id));
16290 + spin_unlock(&vx_info_hash_lock);
16295 +/* xid_is_hashed()
16297 + * verify that xid is still hashed */
16299 +int xid_is_hashed(xid_t xid)
16303 + spin_lock(&vx_info_hash_lock);
16304 + hashed = (__lookup_vx_info(xid) != NULL);
16305 + spin_unlock(&vx_info_hash_lock);
16309 +#ifdef CONFIG_PROC_FS
16313 + * get a subset of hashed xids for proc
16314 + * assumes size is at least one */
16316 +int get_xid_list(int index, unsigned int *xids, int size)
16318 + int hindex, nr_xids = 0;
16320 + /* only show current and children */
16321 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16324 + xids[nr_xids] = vx_current_xid();
16328 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16329 + struct hlist_head *head = &vx_info_hash[hindex];
16330 + struct hlist_node *pos;
16332 + spin_lock(&vx_info_hash_lock);
16333 + hlist_for_each(pos, head) {
16334 + struct vx_info *vxi;
16339 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16340 + xids[nr_xids] = vxi->vx_id;
16341 + if (++nr_xids >= size) {
16342 + spin_unlock(&vx_info_hash_lock);
16346 + /* keep the lock time short */
16347 + spin_unlock(&vx_info_hash_lock);
16354 +#ifdef CONFIG_VSERVER_DEBUG
16356 +void dump_vx_info_inactive(int level)
16358 + struct hlist_node *entry, *next;
16360 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16361 + struct vx_info *vxi =
16362 + list_entry(entry, struct vx_info, vx_hlist);
16364 + dump_vx_info(vxi, level);
16371 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16373 + struct user_struct *new_user, *old_user;
16378 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16381 + new_user = alloc_uid(vxi->vx_id, p->uid);
16385 + old_user = p->user;
16386 + if (new_user != old_user) {
16387 + atomic_inc(&new_user->processes);
16388 + atomic_dec(&old_user->processes);
16389 + p->user = new_user;
16391 + free_uid(old_user);
16397 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16399 + // p->cap_effective &= vxi->vx_cap_bset;
16400 + p->cap_effective =
16401 + cap_intersect(p->cap_effective, vxi->cap_bset);
16402 + // p->cap_inheritable &= vxi->vx_cap_bset;
16403 + p->cap_inheritable =
16404 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16405 + // p->cap_permitted &= vxi->vx_cap_bset;
16406 + p->cap_permitted =
16407 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16412 +#include <linux/file.h>
16413 +#include <linux/fdtable.h>
16415 +static int vx_openfd_task(struct task_struct *tsk)
16417 + struct files_struct *files = tsk->files;
16418 + struct fdtable *fdt;
16419 + const unsigned long *bptr;
16420 + int count, total;
16422 + /* no rcu_read_lock() because of spin_lock() */
16423 + spin_lock(&files->file_lock);
16424 + fdt = files_fdtable(files);
16425 + bptr = fdt->open_fds->fds_bits;
16426 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16427 + for (total = 0; count > 0; count--) {
16429 + total += hweight_long(*bptr);
16432 + spin_unlock(&files->file_lock);
16437 +/* for *space compatibility */
16439 +asmlinkage long sys_unshare(unsigned long);
16442 + * migrate task to new context
16443 + * gets vxi, puts old_vxi on change
16444 + * optionally unshares namespaces (hack)
16447 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16449 + struct vx_info *old_vxi;
16455 + vxdprintk(VXD_CBIT(xid, 5),
16456 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16457 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16459 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16460 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16463 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16466 + old_vxi = task_get_vx_info(p);
16467 + if (old_vxi == vxi)
16470 +// if (!(ret = vx_migrate_user(p, vxi))) {
16475 + openfd = vx_openfd_task(p);
16478 + atomic_dec(&old_vxi->cvirt.nr_threads);
16479 + atomic_dec(&old_vxi->cvirt.nr_running);
16480 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16481 + /* FIXME: what about the struct files here? */
16482 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16483 + /* account for the executable */
16484 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16486 + atomic_inc(&vxi->cvirt.nr_threads);
16487 + atomic_inc(&vxi->cvirt.nr_running);
16488 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16489 + /* FIXME: what about the struct files here? */
16490 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16491 + /* account for the executable */
16492 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16495 + release_vx_info(old_vxi, p);
16496 + clr_vx_info(&p->vx_info);
16498 + claim_vx_info(vxi, p);
16499 + set_vx_info(&p->vx_info, vxi);
16500 + p->xid = vxi->vx_id;
16502 + vxdprintk(VXD_CBIT(xid, 5),
16503 + "moved task %p into vxi:%p[#%d]",
16504 + p, vxi, vxi->vx_id);
16506 + // vx_mask_cap_bset(vxi, p);
16509 + /* hack for *spaces to provide compatibility */
16511 + struct nsproxy *old_nsp, *new_nsp;
16513 + ret = unshare_nsproxy_namespaces(
16514 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16519 + old_nsp = xchg(&p->nsproxy, new_nsp);
16520 + vx_set_space(vxi,
16521 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16522 + put_nsproxy(old_nsp);
16526 + put_vx_info(old_vxi);
16530 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16532 + struct task_struct *old_reaper;
16537 + vxdprintk(VXD_CBIT(xid, 6),
16538 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16539 + vxi, vxi->vx_id, p, p->xid, p->pid);
16541 + old_reaper = vxi->vx_reaper;
16542 + if (old_reaper == p)
16545 + /* set new child reaper */
16546 + get_task_struct(p);
16547 + vxi->vx_reaper = p;
16548 + put_task_struct(old_reaper);
16552 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16557 + vxdprintk(VXD_CBIT(xid, 6),
16558 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16559 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16561 + vxi->vx_flags &= ~VXF_STATE_INIT;
16562 + // vxi->vx_initpid = p->tgid;
16563 + vxi->vx_initpid = p->pid;
16567 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16569 + vxdprintk(VXD_CBIT(xid, 6),
16570 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16571 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16573 + vxi->exit_code = code;
16574 + vxi->vx_initpid = 0;
16578 +void vx_set_persistent(struct vx_info *vxi)
16580 + vxdprintk(VXD_CBIT(xid, 6),
16581 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16583 + get_vx_info(vxi);
16584 + claim_vx_info(vxi, NULL);
16587 +void vx_clear_persistent(struct vx_info *vxi)
16589 + vxdprintk(VXD_CBIT(xid, 6),
16590 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16592 + release_vx_info(vxi, NULL);
16593 + put_vx_info(vxi);
16596 +void vx_update_persistent(struct vx_info *vxi)
16598 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16599 + vx_set_persistent(vxi);
16601 + vx_clear_persistent(vxi);
16605 +/* task must be current or locked */
16607 +void exit_vx_info(struct task_struct *p, int code)
16609 + struct vx_info *vxi = p->vx_info;
16612 + atomic_dec(&vxi->cvirt.nr_threads);
16615 + vxi->exit_code = code;
16616 + release_vx_info(vxi, p);
16620 +void exit_vx_info_early(struct task_struct *p, int code)
16622 + struct vx_info *vxi = p->vx_info;
16625 + if (vxi->vx_initpid == p->pid)
16626 + vx_exit_init(vxi, p, code);
16627 + if (vxi->vx_reaper == p)
16628 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16633 +/* vserver syscall commands below here */
16635 +/* taks xid and vx_info functions */
16637 +#include <asm/uaccess.h>
16640 +int vc_task_xid(uint32_t id)
16645 + struct task_struct *tsk;
16648 + tsk = find_task_by_real_pid(id);
16649 + xid = (tsk) ? tsk->xid : -ESRCH;
16650 + rcu_read_unlock();
16652 + xid = vx_current_xid();
16657 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16659 + struct vcmd_vx_info_v0 vc_data;
16661 + vc_data.xid = vxi->vx_id;
16662 + vc_data.initpid = vxi->vx_initpid;
16664 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16670 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16672 + struct vcmd_ctx_stat_v0 vc_data;
16674 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16675 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16677 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16683 +/* context functions */
16685 +int vc_ctx_create(uint32_t xid, void __user *data)
16687 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16688 + struct vx_info *new_vxi;
16691 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16694 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16697 + new_vxi = __create_vx_info(xid);
16698 + if (IS_ERR(new_vxi))
16699 + return PTR_ERR(new_vxi);
16701 + /* initial flags */
16702 + new_vxi->vx_flags = vc_data.flagword;
16705 + if (vs_state_change(new_vxi, VSC_STARTUP))
16708 + ret = vx_migrate_task(current, new_vxi, (!data));
16712 + /* return context id on success */
16713 + ret = new_vxi->vx_id;
16715 + /* get a reference for persistent contexts */
16716 + if ((vc_data.flagword & VXF_PERSISTENT))
16717 + vx_set_persistent(new_vxi);
16719 + release_vx_info(new_vxi, NULL);
16720 + put_vx_info(new_vxi);
16725 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16727 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16730 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16733 + ret = vx_migrate_task(current, vxi, 0);
16736 + if (vc_data.flagword & VXM_SET_INIT)
16737 + ret = vx_set_init(vxi, current);
16740 + if (vc_data.flagword & VXM_SET_REAPER)
16741 + ret = vx_set_reaper(vxi, current);
16746 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16748 + struct vcmd_ctx_flags_v0 vc_data;
16750 + vc_data.flagword = vxi->vx_flags;
16752 + /* special STATE flag handling */
16753 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16755 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16760 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16762 + struct vcmd_ctx_flags_v0 vc_data;
16763 + uint64_t mask, trigger;
16765 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16768 + /* special STATE flag handling */
16769 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16770 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16772 + if (vxi == current_vx_info()) {
16773 + /* if (trigger & VXF_STATE_SETUP)
16774 + vx_mask_cap_bset(vxi, current); */
16775 + if (trigger & VXF_STATE_INIT) {
16778 + ret = vx_set_init(vxi, current);
16781 + ret = vx_set_reaper(vxi, current);
16787 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
16788 + vc_data.flagword, mask);
16789 + if (trigger & VXF_PERSISTENT)
16790 + vx_update_persistent(vxi);
16796 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
16798 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
16800 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
16804 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
16806 + kernel_cap_t c = __cap_empty_set;
16808 + c.cap[0] = v & 0xFFFFFFFF;
16809 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
16811 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
16816 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
16819 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
16821 + *ccaps = vxi->vx_ccaps;
16826 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
16828 + struct vcmd_ctx_caps_v1 vc_data;
16831 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
16834 + vc_data.cmask = ~0ULL;
16836 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16841 +static int do_set_caps(struct vx_info *vxi,
16842 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
16844 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
16847 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
16848 + bcaps, bmask, ccaps, cmask);
16850 + vxi->vx_bcaps = cap_t_from_caps(
16851 + vs_mask_flags(bcold, bcaps, bmask));
16852 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
16857 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
16859 + struct vcmd_ctx_caps_v1 vc_data;
16861 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16864 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
16867 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
16869 + struct vcmd_bcaps vc_data;
16872 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
16875 + vc_data.bmask = ~0ULL;
16877 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16882 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
16884 + struct vcmd_bcaps vc_data;
16886 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16889 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
16893 +int vc_get_umask(struct vx_info *vxi, void __user *data)
16895 + struct vcmd_umask vc_data;
16897 + vc_data.umask = vxi->vx_umask;
16898 + vc_data.mask = ~0ULL;
16900 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16905 +int vc_set_umask(struct vx_info *vxi, void __user *data)
16907 + struct vcmd_umask vc_data;
16909 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16912 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
16913 + vc_data.umask, vc_data.mask);
16918 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
16920 + struct vcmd_wmask vc_data;
16922 + vc_data.wmask = vxi->vx_wmask;
16923 + vc_data.mask = ~0ULL;
16925 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16930 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
16932 + struct vcmd_wmask vc_data;
16934 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16937 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
16938 + vc_data.wmask, vc_data.mask);
16943 +int vc_get_badness(struct vx_info *vxi, void __user *data)
16945 + struct vcmd_badness_v0 vc_data;
16947 + vc_data.bias = vxi->vx_badness_bias;
16949 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16954 +int vc_set_badness(struct vx_info *vxi, void __user *data)
16956 + struct vcmd_badness_v0 vc_data;
16958 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16961 + vxi->vx_badness_bias = vc_data.bias;
16965 +#include <linux/module.h>
16967 +EXPORT_SYMBOL_GPL(free_vx_info);
16969 diff -NurpP --minimal linux-3.2.8/kernel/vserver/cvirt.c linux-3.2.8-vs2.3.2.7/kernel/vserver/cvirt.c
16970 --- linux-3.2.8/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
16971 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/cvirt.c 2011-12-05 19:33:02.000000000 +0100
16974 + * linux/kernel/vserver/cvirt.c
16976 + * Virtual Server: Context Virtualization
16978 + * Copyright (C) 2004-2007 Herbert Pötzl
16980 + * V0.01 broken out from limit.c
16981 + * V0.02 added utsname stuff
16982 + * V0.03 changed vcmds to vxi arg
16986 +#include <linux/types.h>
16987 +#include <linux/utsname.h>
16988 +#include <linux/vs_cvirt.h>
16989 +#include <linux/vserver/switch.h>
16990 +#include <linux/vserver/cvirt_cmd.h>
16992 +#include <asm/uaccess.h>
16995 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
16997 + struct vx_info *vxi = current_vx_info();
16999 + set_normalized_timespec(uptime,
17000 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17001 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17004 + set_normalized_timespec(idle,
17005 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17006 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17010 +uint64_t vx_idle_jiffies(void)
17012 + return init_task.utime + init_task.stime;
17017 +static inline uint32_t __update_loadavg(uint32_t load,
17018 + int wsize, int delta, int n)
17020 + unsigned long long calc, prev;
17022 + /* just set it to n */
17023 + if (unlikely(delta >= wsize))
17024 + return (n << FSHIFT);
17026 + calc = delta * n;
17028 + prev = (wsize - delta);
17031 + do_div(calc, wsize);
17036 +void vx_update_load(struct vx_info *vxi)
17038 + uint32_t now, last, delta;
17039 + unsigned int nr_running, nr_uninterruptible;
17040 + unsigned int total;
17041 + unsigned long flags;
17043 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17046 + last = vxi->cvirt.load_last;
17047 + delta = now - last;
17049 + if (delta < 5*HZ)
17052 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17053 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17054 + total = nr_running + nr_uninterruptible;
17056 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17057 + 60*HZ, delta, total);
17058 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17059 + 5*60*HZ, delta, total);
17060 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17061 + 15*60*HZ, delta, total);
17063 + vxi->cvirt.load_last = now;
17065 + atomic_inc(&vxi->cvirt.load_updates);
17066 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17071 + * Commands to do_syslog:
17073 + * 0 -- Close the log. Currently a NOP.
17074 + * 1 -- Open the log. Currently a NOP.
17075 + * 2 -- Read from the log.
17076 + * 3 -- Read all messages remaining in the ring buffer.
17077 + * 4 -- Read and clear all messages remaining in the ring buffer
17078 + * 5 -- Clear ring buffer.
17079 + * 6 -- Disable printk's to console
17080 + * 7 -- Enable printk's to console
17081 + * 8 -- Set level of messages printed to console
17082 + * 9 -- Return number of unread characters in the log buffer
17083 + * 10 -- Return size of the log buffer
17085 +int vx_do_syslog(int type, char __user *buf, int len)
17088 + int do_clear = 0;
17089 + struct vx_info *vxi = current_vx_info();
17090 + struct _vx_syslog *log;
17094 + log = &vxi->cvirt.syslog;
17097 + case 0: /* Close log */
17098 + case 1: /* Open log */
17100 + case 2: /* Read from log */
17101 + error = wait_event_interruptible(log->log_wait,
17102 + (log->log_start - log->log_end));
17105 + spin_lock_irq(&log->logbuf_lock);
17106 + spin_unlock_irq(&log->logbuf_lock);
17108 + case 4: /* Read/clear last kernel messages */
17110 + /* fall through */
17111 + case 3: /* Read last kernel messages */
17114 + case 5: /* Clear ring buffer */
17117 + case 6: /* Disable logging to console */
17118 + case 7: /* Enable logging to console */
17119 + case 8: /* Set level of messages printed to console */
17122 + case 9: /* Number of chars in the log buffer */
17124 + case 10: /* Size of the log buffer */
17134 +/* virtual host info names */
17136 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17138 + struct nsproxy *nsproxy;
17139 + struct uts_namespace *uts;
17141 + if (id == VHIN_CONTEXT)
17142 + return vxi->vx_name;
17144 + nsproxy = vxi->space[0].vx_nsproxy;
17148 + uts = nsproxy->uts_ns;
17153 + case VHIN_SYSNAME:
17154 + return uts->name.sysname;
17155 + case VHIN_NODENAME:
17156 + return uts->name.nodename;
17157 + case VHIN_RELEASE:
17158 + return uts->name.release;
17159 + case VHIN_VERSION:
17160 + return uts->name.version;
17161 + case VHIN_MACHINE:
17162 + return uts->name.machine;
17163 + case VHIN_DOMAINNAME:
17164 + return uts->name.domainname;
17171 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17173 + struct vcmd_vhi_name_v0 vc_data;
17176 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17179 + name = vx_vhi_name(vxi, vc_data.field);
17183 + memcpy(name, vc_data.name, 65);
17187 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17189 + struct vcmd_vhi_name_v0 vc_data;
17192 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17195 + name = vx_vhi_name(vxi, vc_data.field);
17199 + memcpy(vc_data.name, name, 65);
17200 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17206 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17208 + struct vcmd_virt_stat_v0 vc_data;
17209 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17210 + struct timespec uptime;
17212 + do_posix_clock_monotonic_gettime(&uptime);
17213 + set_normalized_timespec(&uptime,
17214 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17215 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17217 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17218 + vc_data.uptime = timespec_to_ns(&uptime);
17219 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17220 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17221 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17222 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17223 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17224 + vc_data.load[0] = cvirt->load[0];
17225 + vc_data.load[1] = cvirt->load[1];
17226 + vc_data.load[2] = cvirt->load[2];
17228 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17234 +#ifdef CONFIG_VSERVER_VTIME
17236 +/* virtualized time base */
17238 +void vx_adjust_timespec(struct timespec *ts)
17240 + struct vx_info *vxi;
17242 + if (!vx_flags(VXF_VIRT_TIME, 0))
17245 + vxi = current_vx_info();
17246 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17247 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17249 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17251 + ts->tv_nsec -= NSEC_PER_SEC;
17252 + } else if (ts->tv_nsec < 0) {
17254 + ts->tv_nsec += NSEC_PER_SEC;
17258 +int vx_settimeofday(const struct timespec *ts)
17260 + struct timespec ats, delta;
17261 + struct vx_info *vxi;
17263 + if (!vx_flags(VXF_VIRT_TIME, 0))
17264 + return do_settimeofday(ts);
17266 + getnstimeofday(&ats);
17267 + delta = timespec_sub(*ts, ats);
17269 + vxi = current_vx_info();
17270 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17276 diff -NurpP --minimal linux-3.2.8/kernel/vserver/cvirt_init.h linux-3.2.8-vs2.3.2.7/kernel/vserver/cvirt_init.h
17277 --- linux-3.2.8/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17278 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/cvirt_init.h 2011-12-05 19:33:02.000000000 +0100
17282 +extern uint64_t vx_idle_jiffies(void);
17284 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17286 + uint64_t idle_jiffies = vx_idle_jiffies();
17287 + uint64_t nsuptime;
17289 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17290 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17291 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17292 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17293 + cvirt->bias_ts.tv_sec = 0;
17294 + cvirt->bias_ts.tv_nsec = 0;
17296 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17297 + atomic_set(&cvirt->nr_threads, 0);
17298 + atomic_set(&cvirt->nr_running, 0);
17299 + atomic_set(&cvirt->nr_uninterruptible, 0);
17300 + atomic_set(&cvirt->nr_onhold, 0);
17302 + spin_lock_init(&cvirt->load_lock);
17303 + cvirt->load_last = jiffies;
17304 + atomic_set(&cvirt->load_updates, 0);
17305 + cvirt->load[0] = 0;
17306 + cvirt->load[1] = 0;
17307 + cvirt->load[2] = 0;
17308 + atomic_set(&cvirt->total_forks, 0);
17310 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17311 + init_waitqueue_head(&cvirt->syslog.log_wait);
17312 + cvirt->syslog.log_start = 0;
17313 + cvirt->syslog.log_end = 0;
17314 + cvirt->syslog.con_start = 0;
17315 + cvirt->syslog.logged_chars = 0;
17319 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17321 + // cvirt_pc->cpustat = { 0 };
17324 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17326 +#ifdef CONFIG_VSERVER_WARN
17329 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17330 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17332 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17333 + "!!! cvirt: %p[nr_running] = %d on exit.",
17335 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17336 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17338 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17339 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17345 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17350 diff -NurpP --minimal linux-3.2.8/kernel/vserver/cvirt_proc.h linux-3.2.8-vs2.3.2.7/kernel/vserver/cvirt_proc.h
17351 --- linux-3.2.8/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17352 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/cvirt_proc.h 2011-12-05 19:33:02.000000000 +0100
17354 +#ifndef _VX_CVIRT_PROC_H
17355 +#define _VX_CVIRT_PROC_H
17357 +#include <linux/nsproxy.h>
17358 +#include <linux/mnt_namespace.h>
17359 +#include <linux/ipc_namespace.h>
17360 +#include <linux/utsname.h>
17361 +#include <linux/ipc.h>
17365 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17367 + struct mnt_namespace *ns;
17368 + struct uts_namespace *uts;
17369 + struct ipc_namespace *ipc;
17370 + struct path path;
17371 + char *pstr, *root;
17377 + length += sprintf(buffer + length,
17378 + "NSProxy:\t%p [%p,%p,%p]\n",
17379 + nsproxy, nsproxy->mnt_ns,
17380 + nsproxy->uts_ns, nsproxy->ipc_ns);
17382 + ns = nsproxy->mnt_ns;
17386 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17390 + path.mnt = ns->root;
17391 + path.dentry = ns->root->mnt_root;
17392 + root = d_path(&path, pstr, PATH_MAX - 2);
17393 + length += sprintf(buffer + length,
17394 + "Namespace:\t%p [#%u]\n"
17395 + "RootPath:\t%s\n",
17396 + ns, atomic_read(&ns->count),
17401 + uts = nsproxy->uts_ns;
17405 + length += sprintf(buffer + length,
17406 + "SysName:\t%.*s\n"
17407 + "NodeName:\t%.*s\n"
17408 + "Release:\t%.*s\n"
17409 + "Version:\t%.*s\n"
17410 + "Machine:\t%.*s\n"
17411 + "DomainName:\t%.*s\n",
17412 + __NEW_UTS_LEN, uts->name.sysname,
17413 + __NEW_UTS_LEN, uts->name.nodename,
17414 + __NEW_UTS_LEN, uts->name.release,
17415 + __NEW_UTS_LEN, uts->name.version,
17416 + __NEW_UTS_LEN, uts->name.machine,
17417 + __NEW_UTS_LEN, uts->name.domainname);
17420 + ipc = nsproxy->ipc_ns;
17424 + length += sprintf(buffer + length,
17425 + "SEMS:\t\t%d %d %d %d %d\n"
17426 + "MSG:\t\t%d %d %d\n"
17427 + "SHM:\t\t%lu %lu %d %d\n",
17428 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17429 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17431 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17432 + (unsigned long)ipc->shm_ctlmax,
17433 + (unsigned long)ipc->shm_ctlall,
17434 + ipc->shm_ctlmni, ipc->shm_tot);
17441 +#include <linux/sched.h>
17443 +#define LOAD_INT(x) ((x) >> FSHIFT)
17444 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17447 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17452 + length += sprintf(buffer + length,
17453 + "BiasUptime:\t%lu.%02lu\n",
17454 + (unsigned long)cvirt->bias_uptime.tv_sec,
17455 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17457 + a = cvirt->load[0] + (FIXED_1 / 200);
17458 + b = cvirt->load[1] + (FIXED_1 / 200);
17459 + c = cvirt->load[2] + (FIXED_1 / 200);
17460 + length += sprintf(buffer + length,
17461 + "nr_threads:\t%d\n"
17462 + "nr_running:\t%d\n"
17463 + "nr_unintr:\t%d\n"
17464 + "nr_onhold:\t%d\n"
17465 + "load_updates:\t%d\n"
17466 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17467 + "total_forks:\t%d\n",
17468 + atomic_read(&cvirt->nr_threads),
17469 + atomic_read(&cvirt->nr_running),
17470 + atomic_read(&cvirt->nr_uninterruptible),
17471 + atomic_read(&cvirt->nr_onhold),
17472 + atomic_read(&cvirt->load_updates),
17473 + LOAD_INT(a), LOAD_FRAC(a),
17474 + LOAD_INT(b), LOAD_FRAC(b),
17475 + LOAD_INT(c), LOAD_FRAC(c),
17476 + atomic_read(&cvirt->total_forks));
17481 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17482 + char *buffer, int cpu)
17488 +#endif /* _VX_CVIRT_PROC_H */
17489 diff -NurpP --minimal linux-3.2.8/kernel/vserver/debug.c linux-3.2.8-vs2.3.2.7/kernel/vserver/debug.c
17490 --- linux-3.2.8/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17491 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/debug.c 2011-12-05 19:33:02.000000000 +0100
17494 + * kernel/vserver/debug.c
17496 + * Copyright (C) 2005-2007 Herbert Pötzl
17498 + * V0.01 vx_info dump support
17502 +#include <linux/module.h>
17504 +#include <linux/vserver/context.h>
17507 +void dump_vx_info(struct vx_info *vxi, int level)
17509 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17510 + atomic_read(&vxi->vx_usecnt),
17511 + atomic_read(&vxi->vx_tasks),
17514 + __dump_vx_limit(&vxi->limit);
17515 + __dump_vx_sched(&vxi->sched);
17516 + __dump_vx_cvirt(&vxi->cvirt);
17517 + __dump_vx_cacct(&vxi->cacct);
17523 +EXPORT_SYMBOL_GPL(dump_vx_info);
17525 diff -NurpP --minimal linux-3.2.8/kernel/vserver/device.c linux-3.2.8-vs2.3.2.7/kernel/vserver/device.c
17526 --- linux-3.2.8/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17527 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/device.c 2011-12-05 19:33:02.000000000 +0100
17530 + * linux/kernel/vserver/device.c
17532 + * Linux-VServer: Device Support
17534 + * Copyright (C) 2006 Herbert Pötzl
17535 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17537 + * V0.01 device mapping basics
17538 + * V0.02 added defaults
17542 +#include <linux/slab.h>
17543 +#include <linux/rcupdate.h>
17544 +#include <linux/fs.h>
17545 +#include <linux/namei.h>
17546 +#include <linux/hash.h>
17548 +#include <asm/errno.h>
17549 +#include <asm/uaccess.h>
17550 +#include <linux/vserver/base.h>
17551 +#include <linux/vserver/debug.h>
17552 +#include <linux/vserver/context.h>
17553 +#include <linux/vserver/device.h>
17554 +#include <linux/vserver/device_cmd.h>
17557 +#define DMAP_HASH_BITS 4
17560 +struct vs_mapping {
17562 + struct hlist_node hlist;
17563 + struct list_head list;
17565 +#define dm_hlist u.hlist
17566 +#define dm_list u.list
17569 + struct vx_dmap_target target;
17573 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17575 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17577 +static struct vx_dmap_target dmap_defaults[2] = {
17578 + { .flags = DATTR_OPEN },
17579 + { .flags = DATTR_OPEN },
17583 +struct kmem_cache *dmap_cachep __read_mostly;
17585 +int __init dmap_cache_init(void)
17587 + dmap_cachep = kmem_cache_create("dmap_cache",
17588 + sizeof(struct vs_mapping), 0,
17589 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17593 +__initcall(dmap_cache_init);
17596 +static inline unsigned int __hashval(dev_t dev, int bits)
17598 + return hash_long((unsigned long)dev, bits);
17602 +/* __hash_mapping()
17603 + * add the mapping to the hash table
17605 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17607 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17608 + struct hlist_head *head, *hash = dmap_main_hash;
17609 + int device = vdm->device;
17611 + spin_lock(hash_lock);
17612 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17613 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17615 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17616 + hlist_add_head(&vdm->dm_hlist, head);
17617 + spin_unlock(hash_lock);
17621 +static inline int __mode_to_default(umode_t mode)
17634 +/* __set_default()
17637 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17638 + struct vx_dmap_target *vdmt)
17640 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17641 + spin_lock(hash_lock);
17644 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17646 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17649 + spin_unlock(hash_lock);
17651 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17652 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17656 +/* __remove_default()
17657 + * remove a default
17659 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17661 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17662 + spin_lock(hash_lock);
17665 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17666 + else /* remove == reset */
17667 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17669 + spin_unlock(hash_lock);
17674 +/* __find_mapping()
17675 + * find a mapping in the hash table
17677 + * caller must hold hash_lock
17679 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17680 + struct vs_mapping **local, struct vs_mapping **global)
17682 + struct hlist_head *hash = dmap_main_hash;
17683 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17684 + struct hlist_node *pos;
17685 + struct vs_mapping *vdm;
17691 + hlist_for_each(pos, head) {
17692 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17694 + if ((vdm->device == device) &&
17695 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17696 + if (vdm->xid == xid) {
17699 + } else if (global && vdm->xid == 0)
17704 + if (global && *global)
17711 +/* __lookup_mapping()
17712 + * find a mapping and store the result in target and flags
17714 +static inline int __lookup_mapping(struct vx_info *vxi,
17715 + dev_t device, dev_t *target, int *flags, umode_t mode)
17717 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17718 + struct vs_mapping *vdm, *global;
17719 + struct vx_dmap_target *vdmt;
17721 + xid_t xid = vxi->vx_id;
17724 + spin_lock(hash_lock);
17725 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17727 + vdmt = &vdm->target;
17731 + index = __mode_to_default(mode);
17732 + if (vxi && vxi->dmap.targets[index].flags) {
17734 + vdmt = &vxi->dmap.targets[index];
17735 + } else if (global) {
17737 + vdmt = &global->target;
17741 + vdmt = &dmap_defaults[index];
17745 + if (target && (vdmt->flags & DATTR_REMAP))
17746 + *target = vdmt->target;
17748 + *target = device;
17750 + *flags = vdmt->flags;
17752 + spin_unlock(hash_lock);
17758 +/* __remove_mapping()
17759 + * remove a mapping from the hash table
17761 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17764 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17765 + struct vs_mapping *vdm = NULL;
17768 + spin_lock(hash_lock);
17770 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17772 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
17773 + vxi, vxi ? vxi->vx_id : 0, device, mode);
17776 + hlist_del(&vdm->dm_hlist);
17779 + spin_unlock(hash_lock);
17781 + kmem_cache_free(dmap_cachep, vdm);
17787 +int vs_map_device(struct vx_info *vxi,
17788 + dev_t device, dev_t *target, umode_t mode)
17790 + int ret, flags = DATTR_MASK;
17794 + *target = device;
17797 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
17798 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
17799 + device, target ? *target : 0, flags, mode, ret);
17801 + return (flags & DATTR_MASK);
17806 +static int do_set_mapping(struct vx_info *vxi,
17807 + dev_t device, dev_t target, int flags, umode_t mode)
17810 + struct vs_mapping *new;
17812 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
17816 + INIT_HLIST_NODE(&new->dm_hlist);
17817 + new->device = device;
17818 + new->target.target = target;
17819 + new->target.flags = flags | mode;
17820 + new->xid = (vxi ? vxi->vx_id : 0);
17822 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
17823 + __hash_mapping(vxi, new);
17825 + struct vx_dmap_target new = {
17826 + .target = target,
17827 + .flags = flags | mode,
17829 + __set_default(vxi, mode, &new);
17835 +static int do_unset_mapping(struct vx_info *vxi,
17836 + dev_t device, dev_t target, int flags, umode_t mode)
17838 + int ret = -EINVAL;
17841 + ret = __remove_mapping(vxi, device, mode);
17845 + ret = __remove_default(vxi, mode);
17855 +static inline int __user_device(const char __user *name, dev_t *dev,
17858 + struct nameidata nd;
17865 + ret = user_lpath(name, &nd.path);
17868 + if (nd.path.dentry->d_inode) {
17869 + *dev = nd.path.dentry->d_inode->i_rdev;
17870 + *mode = nd.path.dentry->d_inode->i_mode;
17872 + path_put(&nd.path);
17876 +static inline int __mapping_mode(dev_t device, dev_t target,
17877 + umode_t device_mode, umode_t target_mode, umode_t *mode)
17880 + *mode = device_mode & S_IFMT;
17882 + *mode = target_mode & S_IFMT;
17886 + /* if both given, device and target mode have to match */
17887 + if (device && target &&
17888 + ((device_mode ^ target_mode) & S_IFMT))
17894 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
17895 + const char __user *target_path, int flags, int set)
17897 + dev_t device = ~0, target = ~0;
17898 + umode_t device_mode = 0, target_mode = 0, mode;
17901 + ret = __user_device(device_path, &device, &device_mode);
17904 + ret = __user_device(target_path, &target, &target_mode);
17908 + ret = __mapping_mode(device, target,
17909 + device_mode, target_mode, &mode);
17914 + return do_set_mapping(vxi, device, target,
17917 + return do_unset_mapping(vxi, device, target,
17922 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
17924 + struct vcmd_set_mapping_v0 vc_data;
17926 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17929 + return do_mapping(vxi, vc_data.device, vc_data.target,
17930 + vc_data.flags, 1);
17933 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
17935 + struct vcmd_set_mapping_v0 vc_data;
17937 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17940 + return do_mapping(vxi, vc_data.device, vc_data.target,
17941 + vc_data.flags, 0);
17945 +#ifdef CONFIG_COMPAT
17947 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
17949 + struct vcmd_set_mapping_v0_x32 vc_data;
17951 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17954 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17955 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
17958 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
17960 + struct vcmd_set_mapping_v0_x32 vc_data;
17962 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17965 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17966 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
17969 +#endif /* CONFIG_COMPAT */
17972 diff -NurpP --minimal linux-3.2.8/kernel/vserver/dlimit.c linux-3.2.8-vs2.3.2.7/kernel/vserver/dlimit.c
17973 --- linux-3.2.8/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
17974 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/dlimit.c 2011-12-05 19:33:02.000000000 +0100
17977 + * linux/kernel/vserver/dlimit.c
17979 + * Virtual Server: Context Disk Limits
17981 + * Copyright (C) 2004-2009 Herbert Pötzl
17983 + * V0.01 initial version
17984 + * V0.02 compat32 splitup
17985 + * V0.03 extended interface
17989 +#include <linux/statfs.h>
17990 +#include <linux/sched.h>
17991 +#include <linux/namei.h>
17992 +#include <linux/vs_tag.h>
17993 +#include <linux/vs_dlimit.h>
17994 +#include <linux/vserver/dlimit_cmd.h>
17995 +#include <linux/slab.h>
17996 +// #include <linux/gfp.h>
17998 +#include <asm/uaccess.h>
18000 +/* __alloc_dl_info()
18002 + * allocate an initialized dl_info struct
18003 + * doesn't make it visible (hash) */
18005 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18007 + struct dl_info *new = NULL;
18009 + vxdprintk(VXD_CBIT(dlim, 5),
18010 + "alloc_dl_info(%p,%d)*", sb, tag);
18012 + /* would this benefit from a slab cache? */
18013 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18017 + memset(new, 0, sizeof(struct dl_info));
18018 + new->dl_tag = tag;
18020 + // INIT_RCU_HEAD(&new->dl_rcu);
18021 + INIT_HLIST_NODE(&new->dl_hlist);
18022 + spin_lock_init(&new->dl_lock);
18023 + atomic_set(&new->dl_refcnt, 0);
18024 + atomic_set(&new->dl_usecnt, 0);
18026 + /* rest of init goes here */
18028 + vxdprintk(VXD_CBIT(dlim, 4),
18029 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18033 +/* __dealloc_dl_info()
18035 + * final disposal of dl_info */
18037 +static void __dealloc_dl_info(struct dl_info *dli)
18039 + vxdprintk(VXD_CBIT(dlim, 4),
18040 + "dealloc_dl_info(%p)", dli);
18042 + dli->dl_hlist.next = LIST_POISON1;
18043 + dli->dl_tag = -1;
18046 + BUG_ON(atomic_read(&dli->dl_usecnt));
18047 + BUG_ON(atomic_read(&dli->dl_refcnt));
18053 +/* hash table for dl_info hash */
18055 +#define DL_HASH_SIZE 13
18057 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18059 +static DEFINE_SPINLOCK(dl_info_hash_lock);
18062 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18064 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18069 +/* __hash_dl_info()
18071 + * add the dli to the global hash table
18072 + * requires the hash_lock to be held */
18074 +static inline void __hash_dl_info(struct dl_info *dli)
18076 + struct hlist_head *head;
18078 + vxdprintk(VXD_CBIT(dlim, 6),
18079 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18080 + get_dl_info(dli);
18081 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18082 + hlist_add_head_rcu(&dli->dl_hlist, head);
18085 +/* __unhash_dl_info()
18087 + * remove the dli from the global hash table
18088 + * requires the hash_lock to be held */
18090 +static inline void __unhash_dl_info(struct dl_info *dli)
18092 + vxdprintk(VXD_CBIT(dlim, 6),
18093 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18094 + hlist_del_rcu(&dli->dl_hlist);
18095 + put_dl_info(dli);
18099 +/* __lookup_dl_info()
18101 + * requires the rcu_read_lock()
18102 + * doesn't increment the dl_refcnt */
18104 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18106 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18107 + struct hlist_node *pos;
18108 + struct dl_info *dli;
18110 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18112 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18120 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18122 + struct dl_info *dli;
18125 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18126 + vxdprintk(VXD_CBIT(dlim, 7),
18127 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18128 + rcu_read_unlock();
18132 +void rcu_free_dl_info(struct rcu_head *head)
18134 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18135 + int usecnt, refcnt;
18137 + BUG_ON(!dli || !head);
18139 + usecnt = atomic_read(&dli->dl_usecnt);
18140 + BUG_ON(usecnt < 0);
18142 + refcnt = atomic_read(&dli->dl_refcnt);
18143 + BUG_ON(refcnt < 0);
18145 + vxdprintk(VXD_CBIT(dlim, 3),
18146 + "rcu_free_dl_info(%p)", dli);
18148 + __dealloc_dl_info(dli);
18150 + printk("!!! rcu didn't free\n");
18156 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18157 + uint32_t flags, int add)
18159 + struct path path;
18162 + ret = user_lpath(name, &path);
18164 + struct super_block *sb;
18165 + struct dl_info *dli;
18168 + if (!path.dentry->d_inode)
18169 + goto out_release;
18170 + if (!(sb = path.dentry->d_inode->i_sb))
18171 + goto out_release;
18174 + dli = __alloc_dl_info(sb, id);
18175 + spin_lock(&dl_info_hash_lock);
18178 + if (__lookup_dl_info(sb, id))
18180 + __hash_dl_info(dli);
18183 + spin_lock(&dl_info_hash_lock);
18184 + dli = __lookup_dl_info(sb, id);
18189 + __unhash_dl_info(dli);
18193 + spin_unlock(&dl_info_hash_lock);
18195 + __dealloc_dl_info(dli);
18202 +int vc_add_dlimit(uint32_t id, void __user *data)
18204 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18206 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18209 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18212 +int vc_rem_dlimit(uint32_t id, void __user *data)
18214 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18216 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18219 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18222 +#ifdef CONFIG_COMPAT
18224 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18226 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18228 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18231 + return do_addrem_dlimit(id,
18232 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18235 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18237 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18239 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18242 + return do_addrem_dlimit(id,
18243 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18246 +#endif /* CONFIG_COMPAT */
18250 +int do_set_dlimit(uint32_t id, const char __user *name,
18251 + uint32_t space_used, uint32_t space_total,
18252 + uint32_t inodes_used, uint32_t inodes_total,
18253 + uint32_t reserved, uint32_t flags)
18255 + struct path path;
18258 + ret = user_lpath(name, &path);
18260 + struct super_block *sb;
18261 + struct dl_info *dli;
18264 + if (!path.dentry->d_inode)
18265 + goto out_release;
18266 + if (!(sb = path.dentry->d_inode->i_sb))
18267 + goto out_release;
18269 + /* sanity checks */
18270 + if ((reserved != CDLIM_KEEP &&
18271 + reserved > 100) ||
18272 + (inodes_used != CDLIM_KEEP &&
18273 + inodes_used > inodes_total) ||
18274 + (space_used != CDLIM_KEEP &&
18275 + space_used > space_total))
18276 + goto out_release;
18279 + dli = locate_dl_info(sb, id);
18281 + goto out_release;
18283 + spin_lock(&dli->dl_lock);
18285 + if (inodes_used != CDLIM_KEEP)
18286 + dli->dl_inodes_used = inodes_used;
18287 + if (inodes_total != CDLIM_KEEP)
18288 + dli->dl_inodes_total = inodes_total;
18289 + if (space_used != CDLIM_KEEP)
18290 + dli->dl_space_used = dlimit_space_32to64(
18291 + space_used, flags, DLIMS_USED);
18293 + if (space_total == CDLIM_INFINITY)
18294 + dli->dl_space_total = DLIM_INFINITY;
18295 + else if (space_total != CDLIM_KEEP)
18296 + dli->dl_space_total = dlimit_space_32to64(
18297 + space_total, flags, DLIMS_TOTAL);
18299 + if (reserved != CDLIM_KEEP)
18300 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18302 + spin_unlock(&dli->dl_lock);
18304 + put_dl_info(dli);
18313 +int vc_set_dlimit(uint32_t id, void __user *data)
18315 + struct vcmd_ctx_dlimit_v0 vc_data;
18317 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18320 + return do_set_dlimit(id, vc_data.name,
18321 + vc_data.space_used, vc_data.space_total,
18322 + vc_data.inodes_used, vc_data.inodes_total,
18323 + vc_data.reserved, vc_data.flags);
18326 +#ifdef CONFIG_COMPAT
18328 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18330 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18332 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18335 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18336 + vc_data.space_used, vc_data.space_total,
18337 + vc_data.inodes_used, vc_data.inodes_total,
18338 + vc_data.reserved, vc_data.flags);
18341 +#endif /* CONFIG_COMPAT */
18345 +int do_get_dlimit(uint32_t id, const char __user *name,
18346 + uint32_t *space_used, uint32_t *space_total,
18347 + uint32_t *inodes_used, uint32_t *inodes_total,
18348 + uint32_t *reserved, uint32_t *flags)
18350 + struct path path;
18353 + ret = user_lpath(name, &path);
18355 + struct super_block *sb;
18356 + struct dl_info *dli;
18359 + if (!path.dentry->d_inode)
18360 + goto out_release;
18361 + if (!(sb = path.dentry->d_inode->i_sb))
18362 + goto out_release;
18365 + dli = locate_dl_info(sb, id);
18367 + goto out_release;
18369 + spin_lock(&dli->dl_lock);
18370 + *inodes_used = dli->dl_inodes_used;
18371 + *inodes_total = dli->dl_inodes_total;
18373 + *space_used = dlimit_space_64to32(
18374 + dli->dl_space_used, flags, DLIMS_USED);
18376 + if (dli->dl_space_total == DLIM_INFINITY)
18377 + *space_total = CDLIM_INFINITY;
18379 + *space_total = dlimit_space_64to32(
18380 + dli->dl_space_total, flags, DLIMS_TOTAL);
18382 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18383 + spin_unlock(&dli->dl_lock);
18385 + put_dl_info(dli);
18396 +int vc_get_dlimit(uint32_t id, void __user *data)
18398 + struct vcmd_ctx_dlimit_v0 vc_data;
18401 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18404 + ret = do_get_dlimit(id, vc_data.name,
18405 + &vc_data.space_used, &vc_data.space_total,
18406 + &vc_data.inodes_used, &vc_data.inodes_total,
18407 + &vc_data.reserved, &vc_data.flags);
18411 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18416 +#ifdef CONFIG_COMPAT
18418 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18420 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18423 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18426 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18427 + &vc_data.space_used, &vc_data.space_total,
18428 + &vc_data.inodes_used, &vc_data.inodes_total,
18429 + &vc_data.reserved, &vc_data.flags);
18433 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18438 +#endif /* CONFIG_COMPAT */
18441 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18443 + struct dl_info *dli;
18444 + __u64 blimit, bfree, bavail;
18447 + dli = locate_dl_info(sb, dx_current_tag());
18451 + spin_lock(&dli->dl_lock);
18452 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18455 + /* reduce max inodes available to limit */
18456 + if (buf->f_files > dli->dl_inodes_total)
18457 + buf->f_files = dli->dl_inodes_total;
18459 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18460 + /* reduce free inodes to min */
18461 + if (ifree < buf->f_ffree)
18462 + buf->f_ffree = ifree;
18465 + if (dli->dl_space_total == DLIM_INFINITY)
18468 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18470 + if (dli->dl_space_total < dli->dl_space_used)
18473 + bfree = (dli->dl_space_total - dli->dl_space_used)
18474 + >> sb->s_blocksize_bits;
18476 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18477 + if (bavail < dli->dl_space_used)
18480 + bavail = (bavail - dli->dl_space_used)
18481 + >> sb->s_blocksize_bits;
18483 + /* reduce max space available to limit */
18484 + if (buf->f_blocks > blimit)
18485 + buf->f_blocks = blimit;
18487 + /* reduce free space to min */
18488 + if (bfree < buf->f_bfree)
18489 + buf->f_bfree = bfree;
18491 + /* reduce avail space to min */
18492 + if (bavail < buf->f_bavail)
18493 + buf->f_bavail = bavail;
18496 + spin_unlock(&dli->dl_lock);
18497 + put_dl_info(dli);
18502 +#include <linux/module.h>
18504 +EXPORT_SYMBOL_GPL(locate_dl_info);
18505 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18507 diff -NurpP --minimal linux-3.2.8/kernel/vserver/helper.c linux-3.2.8-vs2.3.2.7/kernel/vserver/helper.c
18508 --- linux-3.2.8/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18509 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/helper.c 2011-12-05 19:33:02.000000000 +0100
18512 + * linux/kernel/vserver/helper.c
18514 + * Virtual Context Support
18516 + * Copyright (C) 2004-2007 Herbert Pötzl
18518 + * V0.01 basic helper
18522 +#include <linux/kmod.h>
18523 +#include <linux/reboot.h>
18524 +#include <linux/vs_context.h>
18525 +#include <linux/vs_network.h>
18526 +#include <linux/vserver/signal.h>
18529 +char vshelper_path[255] = "/sbin/vshelper";
18532 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18536 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
18537 + printk( KERN_WARNING
18538 + "%s: (%s %s) returned %s with %d\n",
18539 + name, argv[1], argv[2],
18540 + sync ? "sync" : "async", ret);
18542 + vxdprintk(VXD_CBIT(switch, 4),
18543 + "%s: (%s %s) returned %s with %d",
18544 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18549 + * vshelper path is set via /proc/sys
18550 + * invoked by vserver sys_reboot(), with
18551 + * the following arguments
18553 + * argv [0] = vshelper_path;
18554 + * argv [1] = action: "restart", "halt", "poweroff", ...
18555 + * argv [2] = context identifier
18557 + * envp [*] = type-specific parameters
18560 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18562 + char id_buf[8], cmd_buf[16];
18563 + char uid_buf[16], pid_buf[16];
18566 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18567 + char *envp[] = {"HOME=/", "TERM=linux",
18568 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18569 + uid_buf, pid_buf, cmd_buf, 0};
18571 + if (vx_info_state(vxi, VXS_HELPER))
18573 + vxi->vx_state |= VXS_HELPER;
18575 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18577 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18578 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
18579 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
18582 + case LINUX_REBOOT_CMD_RESTART:
18583 + argv[1] = "restart";
18586 + case LINUX_REBOOT_CMD_HALT:
18587 + argv[1] = "halt";
18590 + case LINUX_REBOOT_CMD_POWER_OFF:
18591 + argv[1] = "poweroff";
18594 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18595 + argv[1] = "swsusp";
18598 + case LINUX_REBOOT_CMD_OOM:
18603 + vxi->vx_state &= ~VXS_HELPER;
18607 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18608 + vxi->vx_state &= ~VXS_HELPER;
18609 + __wakeup_vx_info(vxi);
18610 + return (ret) ? -EPERM : 0;
18614 +long vs_reboot(unsigned int cmd, void __user *arg)
18616 + struct vx_info *vxi = current_vx_info();
18619 + vxdprintk(VXD_CBIT(misc, 5),
18620 + "vs_reboot(%p[#%d],%u)",
18621 + vxi, vxi ? vxi->vx_id : 0, cmd);
18623 + ret = vs_reboot_helper(vxi, cmd, arg);
18627 + vxi->reboot_cmd = cmd;
18628 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18630 + case LINUX_REBOOT_CMD_RESTART:
18631 + case LINUX_REBOOT_CMD_HALT:
18632 + case LINUX_REBOOT_CMD_POWER_OFF:
18633 + vx_info_kill(vxi, 0, SIGKILL);
18634 + vx_info_kill(vxi, 1, SIGKILL);
18642 +long vs_oom_action(unsigned int cmd)
18644 + struct vx_info *vxi = current_vx_info();
18647 + vxdprintk(VXD_CBIT(misc, 5),
18648 + "vs_oom_action(%p[#%d],%u)",
18649 + vxi, vxi ? vxi->vx_id : 0, cmd);
18651 + ret = vs_reboot_helper(vxi, cmd, NULL);
18655 + vxi->reboot_cmd = cmd;
18656 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18657 + vx_info_kill(vxi, 0, SIGKILL);
18658 + vx_info_kill(vxi, 1, SIGKILL);
18664 + * argv [0] = vshelper_path;
18665 + * argv [1] = action: "startup", "shutdown"
18666 + * argv [2] = context identifier
18668 + * envp [*] = type-specific parameters
18671 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18673 + char id_buf[8], cmd_buf[16];
18674 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18675 + char *envp[] = {"HOME=/", "TERM=linux",
18676 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18678 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18681 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18682 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18685 + case VSC_STARTUP:
18686 + argv[1] = "startup";
18688 + case VSC_SHUTDOWN:
18689 + argv[1] = "shutdown";
18695 + return do_vshelper(vshelper_path, argv, envp, 1);
18700 + * argv [0] = vshelper_path;
18701 + * argv [1] = action: "netup", "netdown"
18702 + * argv [2] = context identifier
18704 + * envp [*] = type-specific parameters
18707 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18709 + char id_buf[8], cmd_buf[16];
18710 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18711 + char *envp[] = {"HOME=/", "TERM=linux",
18712 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18714 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18717 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
18718 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18722 + argv[1] = "netup";
18724 + case VSC_NETDOWN:
18725 + argv[1] = "netdown";
18731 + return do_vshelper(vshelper_path, argv, envp, 1);
18734 diff -NurpP --minimal linux-3.2.8/kernel/vserver/history.c linux-3.2.8-vs2.3.2.7/kernel/vserver/history.c
18735 --- linux-3.2.8/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
18736 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/history.c 2011-12-05 19:33:02.000000000 +0100
18739 + * kernel/vserver/history.c
18741 + * Virtual Context History Backtrace
18743 + * Copyright (C) 2004-2007 Herbert Pötzl
18745 + * V0.01 basic structure
18746 + * V0.02 hash/unhash and trace
18747 + * V0.03 preemption fixes
18751 +#include <linux/module.h>
18752 +#include <asm/uaccess.h>
18754 +#include <linux/vserver/context.h>
18755 +#include <linux/vserver/debug.h>
18756 +#include <linux/vserver/debug_cmd.h>
18757 +#include <linux/vserver/history.h>
18760 +#ifdef CONFIG_VSERVER_HISTORY
18761 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18763 +#define VXH_SIZE 64
18766 +struct _vx_history {
18767 + unsigned int counter;
18769 + struct _vx_hist_entry entry[VXH_SIZE + 1];
18773 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
18775 +unsigned volatile int vxh_active = 1;
18777 +static atomic_t sequence = ATOMIC_INIT(0);
18782 + * requires disabled preemption */
18784 +struct _vx_hist_entry *vxh_advance(void *loc)
18786 + unsigned int cpu = smp_processor_id();
18787 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18788 + struct _vx_hist_entry *entry;
18789 + unsigned int index;
18791 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
18792 + entry = &hist->entry[index];
18794 + entry->seq = atomic_inc_return(&sequence);
18795 + entry->loc = loc;
18799 +EXPORT_SYMBOL_GPL(vxh_advance);
18802 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
18804 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
18807 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
18809 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
18810 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
18811 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
18812 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
18814 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
18816 + switch (e->type) {
18817 + case VXH_THROW_OOPS:
18818 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
18821 + case VXH_GET_VX_INFO:
18822 + case VXH_PUT_VX_INFO:
18823 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18825 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
18826 + VXH_VXI_ARGS(e));
18829 + case VXH_INIT_VX_INFO:
18830 + case VXH_SET_VX_INFO:
18831 + case VXH_CLR_VX_INFO:
18832 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18834 + (e->type == VXH_INIT_VX_INFO) ? "init" :
18835 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
18836 + VXH_VXI_ARGS(e), e->sc.data);
18839 + case VXH_CLAIM_VX_INFO:
18840 + case VXH_RELEASE_VX_INFO:
18841 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18843 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
18844 + VXH_VXI_ARGS(e), e->sc.data);
18847 + case VXH_ALLOC_VX_INFO:
18848 + case VXH_DEALLOC_VX_INFO:
18849 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18851 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
18852 + VXH_VXI_ARGS(e));
18855 + case VXH_HASH_VX_INFO:
18856 + case VXH_UNHASH_VX_INFO:
18857 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
18859 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
18860 + VXH_VXI_ARGS(e));
18863 + case VXH_LOC_VX_INFO:
18864 + case VXH_LOOKUP_VX_INFO:
18865 + case VXH_CREATE_VX_INFO:
18866 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
18868 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
18869 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
18870 + e->ll.arg, VXH_VXI_ARGS(e));
18875 +static void __vxh_dump_history(void)
18877 + unsigned int i, cpu;
18879 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
18880 + atomic_read(&sequence), NR_CPUS);
18882 + for (i = 0; i < VXH_SIZE; i++) {
18883 + for_each_online_cpu(cpu) {
18884 + struct _vx_history *hist =
18885 + &per_cpu(vx_history_buffer, cpu);
18886 + unsigned int index = (hist->counter - i) % VXH_SIZE;
18887 + struct _vx_hist_entry *entry = &hist->entry[index];
18889 + vxh_dump_entry(entry, cpu);
18894 +void vxh_dump_history(void)
18898 + local_irq_enable();
18900 + local_irq_disable();
18902 + __vxh_dump_history();
18906 +/* vserver syscall commands below here */
18909 +int vc_dump_history(uint32_t id)
18912 + __vxh_dump_history();
18919 +int do_read_history(struct __user _vx_hist_entry *data,
18920 + int cpu, uint32_t *index, uint32_t *count)
18922 + int pos, ret = 0;
18923 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18924 + int end = hist->counter;
18925 + int start = end - VXH_SIZE + 2;
18926 + int idx = *index;
18928 + /* special case: get current pos */
18934 + /* have we lost some data? */
18938 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
18939 + struct _vx_hist_entry *entry =
18940 + &hist->entry[idx % VXH_SIZE];
18942 + /* send entry to userspace */
18943 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
18947 + /* save new index and count */
18950 + return ret ? ret : (*index < end);
18953 +int vc_read_history(uint32_t id, void __user *data)
18955 + struct vcmd_read_history_v0 vc_data;
18958 + if (id >= NR_CPUS)
18961 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18964 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
18965 + id, &vc_data.index, &vc_data.count);
18967 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18972 +#ifdef CONFIG_COMPAT
18974 +int vc_read_history_x32(uint32_t id, void __user *data)
18976 + struct vcmd_read_history_v0_x32 vc_data;
18979 + if (id >= NR_CPUS)
18982 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18985 + ret = do_read_history((struct __user _vx_hist_entry *)
18986 + compat_ptr(vc_data.data_ptr),
18987 + id, &vc_data.index, &vc_data.count);
18989 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18994 +#endif /* CONFIG_COMPAT */
18996 diff -NurpP --minimal linux-3.2.8/kernel/vserver/inet.c linux-3.2.8-vs2.3.2.7/kernel/vserver/inet.c
18997 --- linux-3.2.8/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
18998 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/inet.c 2011-12-15 01:33:09.000000000 +0100
19001 +#include <linux/in.h>
19002 +#include <linux/inetdevice.h>
19003 +#include <linux/export.h>
19004 +#include <linux/vs_inet.h>
19005 +#include <linux/vs_inet6.h>
19006 +#include <linux/vserver/debug.h>
19007 +#include <net/route.h>
19008 +#include <net/addrconf.h>
19011 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19015 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19018 + struct nx_addr_v4 *ptr;
19020 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19021 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19028 + vxdprintk(VXD_CBIT(net, 2),
19029 + "nx_v4_addr_conflict(%p,%p): %d",
19030 + nxi1, nxi2, ret);
19036 +#ifdef CONFIG_IPV6
19038 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19042 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19045 + struct nx_addr_v6 *ptr;
19047 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19048 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19055 + vxdprintk(VXD_CBIT(net, 2),
19056 + "nx_v6_addr_conflict(%p,%p): %d",
19057 + nxi1, nxi2, ret);
19064 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19066 + struct in_device *in_dev;
19067 + struct in_ifaddr **ifap;
19068 + struct in_ifaddr *ifa;
19073 + in_dev = in_dev_get(dev);
19077 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19078 + ifap = &ifa->ifa_next) {
19079 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19084 + in_dev_put(in_dev);
19090 +#ifdef CONFIG_IPV6
19092 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19094 + struct inet6_dev *in_dev;
19095 + struct inet6_ifaddr *ifa;
19100 + in_dev = in6_dev_get(dev);
19104 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19105 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19106 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19111 + in6_dev_put(in_dev);
19118 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19124 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19126 +#ifdef CONFIG_IPV6
19128 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19133 + vxdprintk(VXD_CBIT(net, 3),
19134 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19135 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19139 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
19140 + struct flowi4 *fl4)
19142 + struct rtable *rt;
19147 + /* FIXME: handle lback only case */
19148 + if (!NX_IPV4(nxi))
19149 + return ERR_PTR(-EPERM);
19151 + vxdprintk(VXD_CBIT(net, 4),
19152 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19153 + nxi, nxi ? nxi->nx_id : 0,
19154 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
19156 + /* single IP is unconditional */
19157 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19158 + (fl4->saddr == INADDR_ANY))
19159 + fl4->saddr = nxi->v4.ip[0].s_addr;
19161 + if (fl4->saddr == INADDR_ANY) {
19162 + struct nx_addr_v4 *ptr;
19163 + __be32 found = 0;
19165 + rt = __ip_route_output_key(net, fl4);
19166 + if (!IS_ERR(rt)) {
19167 + found = fl4->saddr;
19169 + vxdprintk(VXD_CBIT(net, 4),
19170 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19171 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
19172 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19176 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19177 + __be32 primary = ptr->ip[0].s_addr;
19178 + __be32 mask = ptr->mask.s_addr;
19179 + __be32 neta = primary & mask;
19181 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19182 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19183 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19184 + NIPQUAD(mask), NIPQUAD(neta));
19185 + if ((found & mask) != neta)
19188 + fl4->saddr = primary;
19189 + rt = __ip_route_output_key(net, fl4);
19190 + vxdprintk(VXD_CBIT(net, 4),
19191 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19192 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
19193 + if (!IS_ERR(rt)) {
19194 + found = fl4->saddr;
19196 + if (found == primary)
19200 + /* still no source ip? */
19201 + found = ipv4_is_loopback(fl4->daddr)
19202 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19204 + /* assign src ip to flow */
19205 + fl4->saddr = found;
19208 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
19209 + return ERR_PTR(-EPERM);
19212 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19213 + if (ipv4_is_loopback(fl4->daddr))
19214 + fl4->daddr = nxi->v4_lback.s_addr;
19215 + if (ipv4_is_loopback(fl4->saddr))
19216 + fl4->saddr = nxi->v4_lback.s_addr;
19217 + } else if (ipv4_is_loopback(fl4->daddr) &&
19218 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19219 + return ERR_PTR(-EPERM);
19224 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19226 diff -NurpP --minimal linux-3.2.8/kernel/vserver/init.c linux-3.2.8-vs2.3.2.7/kernel/vserver/init.c
19227 --- linux-3.2.8/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19228 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/init.c 2011-12-05 19:33:02.000000000 +0100
19231 + * linux/kernel/init.c
19233 + * Virtual Server Init
19235 + * Copyright (C) 2004-2007 Herbert Pötzl
19237 + * V0.01 basic structure
19241 +#include <linux/init.h>
19243 +int vserver_register_sysctl(void);
19244 +void vserver_unregister_sysctl(void);
19247 +static int __init init_vserver(void)
19251 +#ifdef CONFIG_VSERVER_DEBUG
19252 + vserver_register_sysctl();
19258 +static void __exit exit_vserver(void)
19261 +#ifdef CONFIG_VSERVER_DEBUG
19262 + vserver_unregister_sysctl();
19267 +/* FIXME: GFP_ZONETYPES gone
19268 +long vx_slab[GFP_ZONETYPES]; */
19272 +module_init(init_vserver);
19273 +module_exit(exit_vserver);
19275 diff -NurpP --minimal linux-3.2.8/kernel/vserver/inode.c linux-3.2.8-vs2.3.2.7/kernel/vserver/inode.c
19276 --- linux-3.2.8/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19277 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/inode.c 2011-12-06 23:56:11.000000000 +0100
19280 + * linux/kernel/vserver/inode.c
19282 + * Virtual Server: File System Support
19284 + * Copyright (C) 2004-2007 Herbert Pötzl
19286 + * V0.01 separated from vcontext V0.05
19287 + * V0.02 moved to tag (instead of xid)
19291 +#include <linux/tty.h>
19292 +#include <linux/proc_fs.h>
19293 +#include <linux/devpts_fs.h>
19294 +#include <linux/fs.h>
19295 +#include <linux/file.h>
19296 +#include <linux/mount.h>
19297 +#include <linux/parser.h>
19298 +#include <linux/namei.h>
19299 +#include <linux/vserver/inode.h>
19300 +#include <linux/vserver/inode_cmd.h>
19301 +#include <linux/vs_base.h>
19302 +#include <linux/vs_tag.h>
19304 +#include <asm/uaccess.h>
19307 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19309 + struct proc_dir_entry *entry;
19311 + if (!in || !in->i_sb)
19314 + *flags = IATTR_TAG
19315 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19316 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19317 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19318 + | (IS_COW(in) ? IATTR_COW : 0);
19319 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19321 + if (S_ISDIR(in->i_mode))
19322 + *mask |= IATTR_BARRIER;
19324 + if (IS_TAGGED(in)) {
19325 + *tag = in->i_tag;
19326 + *mask |= IATTR_TAG;
19329 + switch (in->i_sb->s_magic) {
19330 + case PROC_SUPER_MAGIC:
19331 + entry = PROC_I(in)->pde;
19333 + /* check for specific inodes? */
19335 + *mask |= IATTR_FLAGS;
19337 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19339 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19342 + case DEVPTS_SUPER_MAGIC:
19343 + *tag = in->i_tag;
19344 + *mask |= IATTR_TAG;
19353 +int vc_get_iattr(void __user *data)
19355 + struct path path;
19356 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19359 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19362 + ret = user_lpath(vc_data.name, &path);
19364 + ret = __vc_get_iattr(path.dentry->d_inode,
19365 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19371 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19376 +#ifdef CONFIG_COMPAT
19378 +int vc_get_iattr_x32(void __user *data)
19380 + struct path path;
19381 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19384 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19387 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19389 + ret = __vc_get_iattr(path.dentry->d_inode,
19390 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19396 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19401 +#endif /* CONFIG_COMPAT */
19404 +int vc_fget_iattr(uint32_t fd, void __user *data)
19406 + struct file *filp;
19407 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19410 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19414 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19417 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19418 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19422 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19428 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19430 + struct inode *in = de->d_inode;
19431 + int error = 0, is_proc = 0, has_tag = 0;
19432 + struct iattr attr = { 0 };
19434 + if (!in || !in->i_sb)
19437 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19438 + if ((*mask & IATTR_FLAGS) && !is_proc)
19441 + has_tag = IS_TAGGED(in) ||
19442 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19443 + if ((*mask & IATTR_TAG) && !has_tag)
19446 + mutex_lock(&in->i_mutex);
19447 + if (*mask & IATTR_TAG) {
19448 + attr.ia_tag = *tag;
19449 + attr.ia_valid |= ATTR_TAG;
19452 + if (*mask & IATTR_FLAGS) {
19453 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19454 + unsigned int iflags = PROC_I(in)->vx_flags;
19456 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19457 + | (*flags & IATTR_FLAGS);
19458 + PROC_I(in)->vx_flags = iflags;
19460 + entry->vx_flags = iflags;
19463 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19464 + IATTR_BARRIER | IATTR_COW)) {
19465 + int iflags = in->i_flags;
19466 + int vflags = in->i_vflags;
19468 + if (*mask & IATTR_IMMUTABLE) {
19469 + if (*flags & IATTR_IMMUTABLE)
19470 + iflags |= S_IMMUTABLE;
19472 + iflags &= ~S_IMMUTABLE;
19474 + if (*mask & IATTR_IXUNLINK) {
19475 + if (*flags & IATTR_IXUNLINK)
19476 + iflags |= S_IXUNLINK;
19478 + iflags &= ~S_IXUNLINK;
19480 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19481 + if (*flags & IATTR_BARRIER)
19482 + vflags |= V_BARRIER;
19484 + vflags &= ~V_BARRIER;
19486 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19487 + if (*flags & IATTR_COW)
19490 + vflags &= ~V_COW;
19492 + if (in->i_op && in->i_op->sync_flags) {
19493 + error = in->i_op->sync_flags(in, iflags, vflags);
19499 + if (attr.ia_valid) {
19500 + if (in->i_op && in->i_op->setattr)
19501 + error = in->i_op->setattr(de, &attr);
19503 + error = inode_change_ok(in, &attr);
19505 + setattr_copy(in, &attr);
19506 + mark_inode_dirty(in);
19512 + mutex_unlock(&in->i_mutex);
19516 +int vc_set_iattr(void __user *data)
19518 + struct path path;
19519 + struct vcmd_ctx_iattr_v1 vc_data;
19522 + if (!capable(CAP_LINUX_IMMUTABLE))
19524 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19527 + ret = user_lpath(vc_data.name, &path);
19529 + ret = __vc_set_iattr(path.dentry,
19530 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19534 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19539 +#ifdef CONFIG_COMPAT
19541 +int vc_set_iattr_x32(void __user *data)
19543 + struct path path;
19544 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19547 + if (!capable(CAP_LINUX_IMMUTABLE))
19549 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19552 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19554 + ret = __vc_set_iattr(path.dentry,
19555 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19559 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19564 +#endif /* CONFIG_COMPAT */
19566 +int vc_fset_iattr(uint32_t fd, void __user *data)
19568 + struct file *filp;
19569 + struct vcmd_ctx_fiattr_v0 vc_data;
19572 + if (!capable(CAP_LINUX_IMMUTABLE))
19574 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19578 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19581 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19582 + &vc_data.flags, &vc_data.mask);
19586 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19592 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19594 +static match_table_t tokens = {
19595 + {Opt_notagcheck, "notagcheck"},
19596 +#ifdef CONFIG_PROPAGATE
19597 + {Opt_notag, "notag"},
19598 + {Opt_tag, "tag"},
19599 + {Opt_tagid, "tagid=%u"},
19605 +static void __dx_parse_remove(char *string, char *opt)
19607 + char *p = strstr(string, opt);
19611 + while (*q != '\0' && *q != ',')
19620 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19621 + unsigned long *flags)
19624 + substring_t args[MAX_OPT_ARGS];
19626 + char *s, *p, *opts;
19627 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19633 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19638 + while ((p = strsep(&opts, ",")) != NULL) {
19639 + token = match_token(p, tokens, args);
19642 +#ifdef CONFIG_PROPAGATE
19647 + __dx_parse_remove(s, "tag");
19648 + *mnt_flags |= MNT_TAGID;
19649 + set |= MNT_TAGID;
19653 + __dx_parse_remove(s, "notag");
19654 + *mnt_flags |= MNT_NOTAG;
19655 + set |= MNT_NOTAG;
19658 + if (tag && !match_int(args, &option))
19661 + __dx_parse_remove(s, "tagid");
19662 + *mnt_flags |= MNT_TAGID;
19663 + set |= MNT_TAGID;
19665 +#endif /* CONFIG_PROPAGATE */
19666 + case Opt_notagcheck:
19668 + __dx_parse_remove(s, "notagcheck");
19669 + *flags |= MS_NOTAGCHECK;
19670 + set |= MS_NOTAGCHECK;
19673 + vxdprintk(VXD_CBIT(tag, 7),
19674 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19675 + p, token, option);
19678 + strcpy(string, s);
19683 +#ifdef CONFIG_PROPAGATE
19685 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19687 + tag_t new_tag = 0;
19688 + struct vfsmount *mnt;
19693 + mnt = nd->path.mnt;
19697 + propagate = (mnt->mnt_flags & MNT_TAGID);
19699 + new_tag = mnt->mnt_tag;
19701 + vxdprintk(VXD_CBIT(tag, 7),
19702 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19703 + inode, inode->i_ino, inode->i_tag,
19704 + new_tag, (propagate) ? 1 : 0);
19707 + inode->i_tag = new_tag;
19710 +#include <linux/module.h>
19712 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19714 +#endif /* CONFIG_PROPAGATE */
19716 diff -NurpP --minimal linux-3.2.8/kernel/vserver/limit.c linux-3.2.8-vs2.3.2.7/kernel/vserver/limit.c
19717 --- linux-3.2.8/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
19718 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/limit.c 2011-12-15 01:52:48.000000000 +0100
19721 + * linux/kernel/vserver/limit.c
19723 + * Virtual Server: Context Limits
19725 + * Copyright (C) 2004-2010 Herbert Pötzl
19727 + * V0.01 broken out from vcontext V0.05
19728 + * V0.02 changed vcmds to vxi arg
19729 + * V0.03 added memory cgroup support
19733 +#include <linux/sched.h>
19734 +#include <linux/module.h>
19735 +#include <linux/memcontrol.h>
19736 +#include <linux/res_counter.h>
19737 +#include <linux/vs_limit.h>
19738 +#include <linux/vserver/limit.h>
19739 +#include <linux/vserver/limit_cmd.h>
19741 +#include <asm/uaccess.h>
19744 +const char *vlimit_name[NUM_LIMITS] = {
19745 + [RLIMIT_CPU] = "CPU",
19746 + [RLIMIT_NPROC] = "NPROC",
19747 + [RLIMIT_NOFILE] = "NOFILE",
19748 + [RLIMIT_LOCKS] = "LOCKS",
19749 + [RLIMIT_SIGPENDING] = "SIGP",
19750 + [RLIMIT_MSGQUEUE] = "MSGQ",
19752 + [VLIMIT_NSOCK] = "NSOCK",
19753 + [VLIMIT_OPENFD] = "OPENFD",
19754 + [VLIMIT_SHMEM] = "SHMEM",
19755 + [VLIMIT_DENTRY] = "DENTRY",
19758 +EXPORT_SYMBOL_GPL(vlimit_name);
19760 +#define MASK_ENTRY(x) (1 << (x))
19762 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
19765 + , /* softlimit */
19768 + MASK_ENTRY( RLIMIT_NPROC ) |
19769 + MASK_ENTRY( RLIMIT_NOFILE ) |
19770 + MASK_ENTRY( RLIMIT_LOCKS ) |
19771 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
19773 + MASK_ENTRY( VLIMIT_NSOCK ) |
19774 + MASK_ENTRY( VLIMIT_OPENFD ) |
19775 + MASK_ENTRY( VLIMIT_SHMEM ) |
19776 + MASK_ENTRY( VLIMIT_DENTRY ) |
19779 + /* accounting only */
19780 +uint32_t account_mask =
19781 + MASK_ENTRY( VLIMIT_SEMARY ) |
19782 + MASK_ENTRY( VLIMIT_NSEMS ) |
19783 + MASK_ENTRY( VLIMIT_MAPPED ) |
19787 +static int is_valid_vlimit(int id)
19789 + uint32_t mask = vlimit_mask.minimum |
19790 + vlimit_mask.softlimit | vlimit_mask.maximum;
19791 + return mask & (1 << id);
19794 +static int is_accounted_vlimit(int id)
19796 + if (is_valid_vlimit(id))
19798 + return account_mask & (1 << id);
19802 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
19804 + rlim_t limit = __rlim_soft(&vxi->limit, id);
19805 + return VX_VLIM(limit);
19808 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
19810 + rlim_t limit = __rlim_hard(&vxi->limit, id);
19811 + return VX_VLIM(limit);
19814 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
19815 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
19817 + if (!is_valid_vlimit(id))
19821 + *minimum = CRLIM_UNSET;
19823 + *softlimit = vc_get_soft(vxi, id);
19825 + *maximum = vc_get_hard(vxi, id);
19829 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
19831 + struct vcmd_ctx_rlimit_v0 vc_data;
19834 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19837 + ret = do_get_rlimit(vxi, vc_data.id,
19838 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19842 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19847 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
19848 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
19850 + if (!is_valid_vlimit(id))
19853 + if (maximum != CRLIM_KEEP)
19854 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
19855 + if (softlimit != CRLIM_KEEP)
19856 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
19858 + /* clamp soft limit */
19859 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
19860 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
19865 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
19867 + struct vcmd_ctx_rlimit_v0 vc_data;
19869 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19872 + return do_set_rlimit(vxi, vc_data.id,
19873 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19876 +#ifdef CONFIG_IA32_EMULATION
19878 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
19880 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19882 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19885 + return do_set_rlimit(vxi, vc_data.id,
19886 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19889 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
19891 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19894 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19897 + ret = do_get_rlimit(vxi, vc_data.id,
19898 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19902 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19907 +#endif /* CONFIG_IA32_EMULATION */
19910 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
19912 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
19918 +static inline void vx_reset_hits(struct _vx_limit *limit)
19922 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19923 + atomic_set(&__rlim_lhit(limit, lim), 0);
19927 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
19929 + vx_reset_hits(&vxi->limit);
19933 +static inline void vx_reset_minmax(struct _vx_limit *limit)
19938 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19939 + value = __rlim_get(limit, lim);
19940 + __rlim_rmax(limit, lim) = value;
19941 + __rlim_rmin(limit, lim) = value;
19945 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
19947 + vx_reset_minmax(&vxi->limit);
19952 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
19954 + struct vcmd_rlimit_stat_v0 vc_data;
19955 + struct _vx_limit *limit = &vxi->limit;
19958 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19962 + if (!is_accounted_vlimit(id))
19965 + vx_limit_fixup(limit, id);
19966 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
19967 + vc_data.value = __rlim_get(limit, id);
19968 + vc_data.minimum = __rlim_rmin(limit, id);
19969 + vc_data.maximum = __rlim_rmax(limit, id);
19971 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19977 +void vx_vsi_meminfo(struct sysinfo *val)
19979 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19980 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
19981 + u64 res_limit, res_usage;
19986 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19987 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19989 + if (res_limit != RESOURCE_MAX)
19990 + val->totalram = (res_limit >> PAGE_SHIFT);
19991 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
19992 + val->bufferram = 0;
19993 + val->totalhigh = 0;
19994 + val->freehigh = 0;
19995 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
19999 +void vx_vsi_swapinfo(struct sysinfo *val)
20001 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20002 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20003 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20004 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20005 + s64 swap_limit, swap_usage;
20010 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20011 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20012 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20013 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20015 + /* memory unlimited */
20016 + if (res_limit == RESOURCE_MAX)
20019 + swap_limit = memsw_limit - res_limit;
20020 + /* we have a swap limit? */
20021 + if (memsw_limit != RESOURCE_MAX)
20022 + val->totalswap = swap_limit >> PAGE_SHIFT;
20024 + /* calculate swap part */
20025 + swap_usage = (memsw_usage > res_usage) ?
20026 + memsw_usage - res_usage : 0;
20028 + /* total shown minus usage gives free swap */
20029 + val->freeswap = (swap_usage < swap_limit) ?
20030 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20031 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20032 + val->totalswap = 0;
20033 + val->freeswap = 0;
20034 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20035 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20039 +long vx_vsi_cached(struct sysinfo *val)
20041 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20042 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20044 + return mem_cgroup_stat_read_cache(mcg);
20050 diff -NurpP --minimal linux-3.2.8/kernel/vserver/limit_init.h linux-3.2.8-vs2.3.2.7/kernel/vserver/limit_init.h
20051 --- linux-3.2.8/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20052 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/limit_init.h 2011-12-05 19:33:02.000000000 +0100
20056 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20060 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20061 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20062 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20063 + __rlim_set(limit, lim, 0);
20064 + atomic_set(&__rlim_lhit(limit, lim), 0);
20065 + __rlim_rmin(limit, lim) = 0;
20066 + __rlim_rmax(limit, lim) = 0;
20070 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20075 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20076 + if ((1 << lim) & VLIM_NOCHECK)
20078 + value = __rlim_get(limit, lim);
20079 + vxwprintk_xid(value,
20080 + "!!! limit: %p[%s,%d] = %ld on exit.",
20081 + limit, vlimit_name[lim], lim, (long)value);
20085 diff -NurpP --minimal linux-3.2.8/kernel/vserver/limit_proc.h linux-3.2.8-vs2.3.2.7/kernel/vserver/limit_proc.h
20086 --- linux-3.2.8/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20087 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/limit_proc.h 2011-12-05 19:33:02.000000000 +0100
20089 +#ifndef _VX_LIMIT_PROC_H
20090 +#define _VX_LIMIT_PROC_H
20092 +#include <linux/vserver/limit_int.h>
20095 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20096 +#define VX_LIMIT_TOP \
20097 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20099 +#define VX_LIMIT_ARG(r) \
20100 + (unsigned long)__rlim_get(limit, r), \
20101 + (unsigned long)__rlim_rmin(limit, r), \
20102 + (unsigned long)__rlim_rmax(limit, r), \
20103 + VX_VLIM(__rlim_soft(limit, r)), \
20104 + VX_VLIM(__rlim_hard(limit, r)), \
20105 + atomic_read(&__rlim_lhit(limit, r))
20107 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20109 + vx_limit_fixup(limit, -1);
20110 + return sprintf(buffer, VX_LIMIT_TOP
20111 + "PROC" VX_LIMIT_FMT
20112 + "VM" VX_LIMIT_FMT
20113 + "VML" VX_LIMIT_FMT
20114 + "RSS" VX_LIMIT_FMT
20115 + "ANON" VX_LIMIT_FMT
20116 + "RMAP" VX_LIMIT_FMT
20117 + "FILES" VX_LIMIT_FMT
20118 + "OFD" VX_LIMIT_FMT
20119 + "LOCKS" VX_LIMIT_FMT
20120 + "SOCK" VX_LIMIT_FMT
20121 + "MSGQ" VX_LIMIT_FMT
20122 + "SHM" VX_LIMIT_FMT
20123 + "SEMA" VX_LIMIT_FMT
20124 + "SEMS" VX_LIMIT_FMT
20125 + "DENT" VX_LIMIT_FMT,
20126 + VX_LIMIT_ARG(RLIMIT_NPROC),
20127 + VX_LIMIT_ARG(RLIMIT_AS),
20128 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20129 + VX_LIMIT_ARG(RLIMIT_RSS),
20130 + VX_LIMIT_ARG(VLIMIT_ANON),
20131 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20132 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20133 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20134 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20135 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20136 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20137 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20138 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20139 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20140 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20143 +#endif /* _VX_LIMIT_PROC_H */
20146 diff -NurpP --minimal linux-3.2.8/kernel/vserver/network.c linux-3.2.8-vs2.3.2.7/kernel/vserver/network.c
20147 --- linux-3.2.8/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20148 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/network.c 2011-12-05 19:33:02.000000000 +0100
20151 + * linux/kernel/vserver/network.c
20153 + * Virtual Server: Network Support
20155 + * Copyright (C) 2003-2007 Herbert Pötzl
20157 + * V0.01 broken out from vcontext V0.05
20158 + * V0.02 cleaned up implementation
20159 + * V0.03 added equiv nx commands
20160 + * V0.04 switch to RCU based hash
20161 + * V0.05 and back to locking again
20162 + * V0.06 changed vcmds to nxi arg
20163 + * V0.07 have __create claim() the nxi
20167 +#include <linux/err.h>
20168 +#include <linux/slab.h>
20169 +#include <linux/rcupdate.h>
20171 +#include <linux/vs_network.h>
20172 +#include <linux/vs_pid.h>
20173 +#include <linux/vserver/network_cmd.h>
20176 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20177 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20179 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20180 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20183 +static int __init init_network(void)
20185 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20186 + sizeof(struct nx_addr_v4), 0,
20187 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20188 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20189 + sizeof(struct nx_addr_v6), 0,
20190 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20195 +/* __alloc_nx_addr_v4() */
20197 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20199 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20200 + nx_addr_v4_cachep, GFP_KERNEL);
20202 + if (!IS_ERR(nxa))
20203 + memset(nxa, 0, sizeof(*nxa));
20207 +/* __dealloc_nx_addr_v4() */
20209 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20211 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20214 +/* __dealloc_nx_addr_v4_all() */
20216 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20219 + struct nx_addr_v4 *next = nxa->next;
20221 + __dealloc_nx_addr_v4(nxa);
20227 +#ifdef CONFIG_IPV6
20229 +/* __alloc_nx_addr_v6() */
20231 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20233 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20234 + nx_addr_v6_cachep, GFP_KERNEL);
20236 + if (!IS_ERR(nxa))
20237 + memset(nxa, 0, sizeof(*nxa));
20241 +/* __dealloc_nx_addr_v6() */
20243 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20245 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20248 +/* __dealloc_nx_addr_v6_all() */
20250 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20253 + struct nx_addr_v6 *next = nxa->next;
20255 + __dealloc_nx_addr_v6(nxa);
20260 +#endif /* CONFIG_IPV6 */
20262 +/* __alloc_nx_info()
20264 + * allocate an initialized nx_info struct
20265 + * doesn't make it visible (hash) */
20267 +static struct nx_info *__alloc_nx_info(nid_t nid)
20269 + struct nx_info *new = NULL;
20271 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20273 + /* would this benefit from a slab cache? */
20274 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20278 + memset(new, 0, sizeof(struct nx_info));
20279 + new->nx_id = nid;
20280 + INIT_HLIST_NODE(&new->nx_hlist);
20281 + atomic_set(&new->nx_usecnt, 0);
20282 + atomic_set(&new->nx_tasks, 0);
20283 + new->nx_state = 0;
20285 + new->nx_flags = NXF_INIT_SET;
20287 + /* rest of init goes here */
20289 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20290 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20292 + vxdprintk(VXD_CBIT(nid, 0),
20293 + "alloc_nx_info(%d) = %p", nid, new);
20294 + atomic_inc(&nx_global_ctotal);
20298 +/* __dealloc_nx_info()
20300 + * final disposal of nx_info */
20302 +static void __dealloc_nx_info(struct nx_info *nxi)
20304 + vxdprintk(VXD_CBIT(nid, 0),
20305 + "dealloc_nx_info(%p)", nxi);
20307 + nxi->nx_hlist.next = LIST_POISON1;
20310 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20311 + BUG_ON(atomic_read(&nxi->nx_tasks));
20313 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20315 + nxi->nx_state |= NXS_RELEASED;
20317 + atomic_dec(&nx_global_ctotal);
20320 +static void __shutdown_nx_info(struct nx_info *nxi)
20322 + nxi->nx_state |= NXS_SHUTDOWN;
20323 + vs_net_change(nxi, VSC_NETDOWN);
20326 +/* exported stuff */
20328 +void free_nx_info(struct nx_info *nxi)
20330 + /* context shutdown is mandatory */
20331 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20333 + /* context must not be hashed */
20334 + BUG_ON(nxi->nx_state & NXS_HASHED);
20336 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20337 + BUG_ON(atomic_read(&nxi->nx_tasks));
20339 + __dealloc_nx_info(nxi);
20343 +void __nx_set_lback(struct nx_info *nxi)
20345 + int nid = nxi->nx_id;
20346 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20348 + nxi->v4_lback.s_addr = lback;
20351 +extern int __nx_inet_add_lback(__be32 addr);
20352 +extern int __nx_inet_del_lback(__be32 addr);
20355 +/* hash table for nx_info hash */
20357 +#define NX_HASH_SIZE 13
20359 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20361 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20364 +static inline unsigned int __hashval(nid_t nid)
20366 + return (nid % NX_HASH_SIZE);
20371 +/* __hash_nx_info()
20373 + * add the nxi to the global hash table
20374 + * requires the hash_lock to be held */
20376 +static inline void __hash_nx_info(struct nx_info *nxi)
20378 + struct hlist_head *head;
20380 + vxd_assert_lock(&nx_info_hash_lock);
20381 + vxdprintk(VXD_CBIT(nid, 4),
20382 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20384 + /* context must not be hashed */
20385 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20387 + nxi->nx_state |= NXS_HASHED;
20388 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20389 + hlist_add_head(&nxi->nx_hlist, head);
20390 + atomic_inc(&nx_global_cactive);
20393 +/* __unhash_nx_info()
20395 + * remove the nxi from the global hash table
20396 + * requires the hash_lock to be held */
20398 +static inline void __unhash_nx_info(struct nx_info *nxi)
20400 + vxd_assert_lock(&nx_info_hash_lock);
20401 + vxdprintk(VXD_CBIT(nid, 4),
20402 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20403 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20405 + /* context must be hashed */
20406 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20407 + /* but without tasks */
20408 + BUG_ON(atomic_read(&nxi->nx_tasks));
20410 + nxi->nx_state &= ~NXS_HASHED;
20411 + hlist_del(&nxi->nx_hlist);
20412 + atomic_dec(&nx_global_cactive);
20416 +/* __lookup_nx_info()
20418 + * requires the hash_lock to be held
20419 + * doesn't increment the nx_refcnt */
20421 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20423 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20424 + struct hlist_node *pos;
20425 + struct nx_info *nxi;
20427 + vxd_assert_lock(&nx_info_hash_lock);
20428 + hlist_for_each(pos, head) {
20429 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20431 + if (nxi->nx_id == nid)
20436 + vxdprintk(VXD_CBIT(nid, 0),
20437 + "__lookup_nx_info(#%u): %p[#%u]",
20438 + nid, nxi, nxi ? nxi->nx_id : 0);
20443 +/* __create_nx_info()
20445 + * create the requested context
20446 + * get(), claim() and hash it */
20448 +static struct nx_info *__create_nx_info(int id)
20450 + struct nx_info *new, *nxi = NULL;
20452 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20454 + if (!(new = __alloc_nx_info(id)))
20455 + return ERR_PTR(-ENOMEM);
20457 + /* required to make dynamic xids unique */
20458 + spin_lock(&nx_info_hash_lock);
20460 + /* static context requested */
20461 + if ((nxi = __lookup_nx_info(id))) {
20462 + vxdprintk(VXD_CBIT(nid, 0),
20463 + "create_nx_info(%d) = %p (already there)", id, nxi);
20464 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20465 + nxi = ERR_PTR(-EBUSY);
20467 + nxi = ERR_PTR(-EEXIST);
20470 + /* new context */
20471 + vxdprintk(VXD_CBIT(nid, 0),
20472 + "create_nx_info(%d) = %p (new)", id, new);
20473 + claim_nx_info(new, NULL);
20474 + __nx_set_lback(new);
20475 + __hash_nx_info(get_nx_info(new));
20476 + nxi = new, new = NULL;
20479 + spin_unlock(&nx_info_hash_lock);
20481 + __dealloc_nx_info(new);
20487 +/* exported stuff */
20490 +void unhash_nx_info(struct nx_info *nxi)
20492 + __shutdown_nx_info(nxi);
20493 + spin_lock(&nx_info_hash_lock);
20494 + __unhash_nx_info(nxi);
20495 + spin_unlock(&nx_info_hash_lock);
20498 +/* lookup_nx_info()
20500 + * search for a nx_info and get() it
20501 + * negative id means current */
20503 +struct nx_info *lookup_nx_info(int id)
20505 + struct nx_info *nxi = NULL;
20508 + nxi = get_nx_info(current_nx_info());
20509 + } else if (id > 1) {
20510 + spin_lock(&nx_info_hash_lock);
20511 + nxi = get_nx_info(__lookup_nx_info(id));
20512 + spin_unlock(&nx_info_hash_lock);
20517 +/* nid_is_hashed()
20519 + * verify that nid is still hashed */
20521 +int nid_is_hashed(nid_t nid)
20525 + spin_lock(&nx_info_hash_lock);
20526 + hashed = (__lookup_nx_info(nid) != NULL);
20527 + spin_unlock(&nx_info_hash_lock);
20532 +#ifdef CONFIG_PROC_FS
20536 + * get a subset of hashed nids for proc
20537 + * assumes size is at least one */
20539 +int get_nid_list(int index, unsigned int *nids, int size)
20541 + int hindex, nr_nids = 0;
20543 + /* only show current and children */
20544 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20547 + nids[nr_nids] = nx_current_nid();
20551 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20552 + struct hlist_head *head = &nx_info_hash[hindex];
20553 + struct hlist_node *pos;
20555 + spin_lock(&nx_info_hash_lock);
20556 + hlist_for_each(pos, head) {
20557 + struct nx_info *nxi;
20562 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20563 + nids[nr_nids] = nxi->nx_id;
20564 + if (++nr_nids >= size) {
20565 + spin_unlock(&nx_info_hash_lock);
20569 + /* keep the lock time short */
20570 + spin_unlock(&nx_info_hash_lock);
20579 + * migrate task to new network
20580 + * gets nxi, puts old_nxi on change
20583 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20585 + struct nx_info *old_nxi;
20591 + vxdprintk(VXD_CBIT(nid, 5),
20592 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20593 + p, nxi, nxi->nx_id,
20594 + atomic_read(&nxi->nx_usecnt),
20595 + atomic_read(&nxi->nx_tasks));
20597 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20598 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20601 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20604 + /* maybe disallow this completely? */
20605 + old_nxi = task_get_nx_info(p);
20606 + if (old_nxi == nxi)
20611 + clr_nx_info(&p->nx_info);
20612 + claim_nx_info(nxi, p);
20613 + set_nx_info(&p->nx_info, nxi);
20614 + p->nid = nxi->nx_id;
20617 + vxdprintk(VXD_CBIT(nid, 5),
20618 + "moved task %p into nxi:%p[#%d]",
20619 + p, nxi, nxi->nx_id);
20622 + release_nx_info(old_nxi, p);
20625 + put_nx_info(old_nxi);
20630 +void nx_set_persistent(struct nx_info *nxi)
20632 + vxdprintk(VXD_CBIT(nid, 6),
20633 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20635 + get_nx_info(nxi);
20636 + claim_nx_info(nxi, NULL);
20639 +void nx_clear_persistent(struct nx_info *nxi)
20641 + vxdprintk(VXD_CBIT(nid, 6),
20642 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20644 + release_nx_info(nxi, NULL);
20645 + put_nx_info(nxi);
20648 +void nx_update_persistent(struct nx_info *nxi)
20650 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20651 + nx_set_persistent(nxi);
20653 + nx_clear_persistent(nxi);
20656 +/* vserver syscall commands below here */
20658 +/* taks nid and nx_info functions */
20660 +#include <asm/uaccess.h>
20663 +int vc_task_nid(uint32_t id)
20668 + struct task_struct *tsk;
20671 + tsk = find_task_by_real_pid(id);
20672 + nid = (tsk) ? tsk->nid : -ESRCH;
20673 + rcu_read_unlock();
20675 + nid = nx_current_nid();
20680 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20682 + struct vcmd_nx_info_v0 vc_data;
20684 + vc_data.nid = nxi->nx_id;
20686 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20692 +/* network functions */
20694 +int vc_net_create(uint32_t nid, void __user *data)
20696 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
20697 + struct nx_info *new_nxi;
20700 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20703 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
20706 + new_nxi = __create_nx_info(nid);
20707 + if (IS_ERR(new_nxi))
20708 + return PTR_ERR(new_nxi);
20710 + /* initial flags */
20711 + new_nxi->nx_flags = vc_data.flagword;
20714 + if (vs_net_change(new_nxi, VSC_NETUP))
20717 + ret = nx_migrate_task(current, new_nxi);
20721 + /* return context id on success */
20722 + ret = new_nxi->nx_id;
20724 + /* get a reference for persistent contexts */
20725 + if ((vc_data.flagword & NXF_PERSISTENT))
20726 + nx_set_persistent(new_nxi);
20728 + release_nx_info(new_nxi, NULL);
20729 + put_nx_info(new_nxi);
20734 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
20736 + return nx_migrate_task(current, nxi);
20741 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20742 + uint16_t type, uint16_t flags)
20744 + struct nx_addr_v4 *nxa = &nxi->v4;
20746 + if (NX_IPV4(nxi)) {
20747 + /* locate last entry */
20748 + for (; nxa->next; nxa = nxa->next);
20749 + nxa->next = __alloc_nx_addr_v4();
20753 + return PTR_ERR(nxa);
20756 + if (nxi->v4.next)
20757 + /* remove single ip for ip list */
20758 + nxi->nx_flags &= ~NXF_SINGLE_IP;
20760 + nxa->ip[0].s_addr = ip;
20761 + nxa->ip[1].s_addr = ip2;
20762 + nxa->mask.s_addr = mask;
20763 + nxa->type = type;
20764 + nxa->flags = flags;
20768 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20769 + uint16_t type, uint16_t flags)
20771 + struct nx_addr_v4 *nxa = &nxi->v4;
20774 +/* case NXA_TYPE_ADDR:
20777 + case NXA_TYPE_ANY:
20778 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
20779 + memset(nxa, 0, sizeof(*nxa));
20789 +int vc_net_add(struct nx_info *nxi, void __user *data)
20791 + struct vcmd_net_addr_v0 vc_data;
20792 + int index, ret = 0;
20794 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20797 + switch (vc_data.type) {
20798 + case NXA_TYPE_IPV4:
20799 + if ((vc_data.count < 1) || (vc_data.count > 4))
20803 + while (index < vc_data.count) {
20804 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
20805 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
20813 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
20814 + nxi->v4_bcast = vc_data.ip[0];
20818 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
20819 + nxi->v4_lback = vc_data.ip[0];
20830 +int vc_net_remove(struct nx_info *nxi, void __user *data)
20832 + struct vcmd_net_addr_v0 vc_data;
20834 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20837 + switch (vc_data.type) {
20838 + case NXA_TYPE_ANY:
20839 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
20840 + memset(&nxi->v4, 0, sizeof(nxi->v4));
20850 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
20852 + struct vcmd_net_addr_ipv4_v1 vc_data;
20854 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20857 + switch (vc_data.type) {
20858 + case NXA_TYPE_ADDR:
20859 + case NXA_TYPE_MASK:
20860 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
20861 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20863 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20864 + nxi->v4_bcast = vc_data.ip;
20867 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20868 + nxi->v4_lback = vc_data.ip;
20877 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
20879 + struct vcmd_net_addr_ipv4_v2 vc_data;
20881 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20884 + switch (vc_data.type) {
20885 + case NXA_TYPE_ADDR:
20886 + case NXA_TYPE_MASK:
20887 + case NXA_TYPE_RANGE:
20888 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20889 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20891 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20892 + nxi->v4_bcast = vc_data.ip;
20895 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20896 + nxi->v4_lback = vc_data.ip;
20905 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
20907 + struct vcmd_net_addr_ipv4_v1 vc_data;
20909 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20912 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
20913 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20916 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
20918 + struct vcmd_net_addr_ipv4_v2 vc_data;
20920 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20923 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20924 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20927 +#ifdef CONFIG_IPV6
20929 +int do_add_v6_addr(struct nx_info *nxi,
20930 + struct in6_addr *ip, struct in6_addr *mask,
20931 + uint32_t prefix, uint16_t type, uint16_t flags)
20933 + struct nx_addr_v6 *nxa = &nxi->v6;
20935 + if (NX_IPV6(nxi)) {
20936 + /* locate last entry */
20937 + for (; nxa->next; nxa = nxa->next);
20938 + nxa->next = __alloc_nx_addr_v6();
20942 + return PTR_ERR(nxa);
20946 + nxa->mask = *mask;
20947 + nxa->prefix = prefix;
20948 + nxa->type = type;
20949 + nxa->flags = flags;
20954 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
20956 + struct vcmd_net_addr_ipv6_v1 vc_data;
20958 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20961 + switch (vc_data.type) {
20962 + case NXA_TYPE_ADDR:
20963 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20964 + /* fallthrough */
20965 + case NXA_TYPE_MASK:
20966 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20967 + vc_data.prefix, vc_data.type, vc_data.flags);
20974 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
20976 + struct vcmd_net_addr_ipv6_v1 vc_data;
20978 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20981 + switch (vc_data.type) {
20982 + case NXA_TYPE_ANY:
20983 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
20984 + memset(&nxi->v6, 0, sizeof(nxi->v6));
20993 +#endif /* CONFIG_IPV6 */
20996 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
20998 + struct vcmd_net_flags_v0 vc_data;
21000 + vc_data.flagword = nxi->nx_flags;
21002 + /* special STATE flag handling */
21003 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21005 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21010 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21012 + struct vcmd_net_flags_v0 vc_data;
21013 + uint64_t mask, trigger;
21015 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21018 + /* special STATE flag handling */
21019 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21020 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21022 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21023 + vc_data.flagword, mask);
21024 + if (trigger & NXF_PERSISTENT)
21025 + nx_update_persistent(nxi);
21030 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21032 + struct vcmd_net_caps_v0 vc_data;
21034 + vc_data.ncaps = nxi->nx_ncaps;
21035 + vc_data.cmask = ~0ULL;
21037 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21042 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21044 + struct vcmd_net_caps_v0 vc_data;
21046 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21049 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21050 + vc_data.ncaps, vc_data.cmask);
21055 +#include <linux/module.h>
21057 +module_init(init_network);
21059 +EXPORT_SYMBOL_GPL(free_nx_info);
21060 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21062 diff -NurpP --minimal linux-3.2.8/kernel/vserver/proc.c linux-3.2.8-vs2.3.2.7/kernel/vserver/proc.c
21063 --- linux-3.2.8/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21064 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/proc.c 2011-12-06 23:19:52.000000000 +0100
21067 + * linux/kernel/vserver/proc.c
21069 + * Virtual Context Support
21071 + * Copyright (C) 2003-2011 Herbert Pötzl
21073 + * V0.01 basic structure
21074 + * V0.02 adaptation vs1.3.0
21075 + * V0.03 proc permissions
21076 + * V0.04 locking/generic
21077 + * V0.05 next generation procfs
21078 + * V0.06 inode validation
21079 + * V0.07 generic rewrite vid
21080 + * V0.08 remove inode type
21081 + * V0.09 added u/wmask info
21085 +#include <linux/proc_fs.h>
21086 +#include <linux/fs_struct.h>
21087 +#include <linux/mount.h>
21088 +#include <asm/unistd.h>
21090 +#include <linux/vs_context.h>
21091 +#include <linux/vs_network.h>
21092 +#include <linux/vs_cvirt.h>
21094 +#include <linux/in.h>
21095 +#include <linux/inetdevice.h>
21096 +#include <linux/vs_inet.h>
21097 +#include <linux/vs_inet6.h>
21099 +#include <linux/vserver/global.h>
21101 +#include "cvirt_proc.h"
21102 +#include "cacct_proc.h"
21103 +#include "limit_proc.h"
21104 +#include "sched_proc.h"
21105 +#include "vci_config.h"
21108 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21112 + CAP_FOR_EACH_U32(__capi) {
21113 + buffer += sprintf(buffer, "%08x",
21114 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21120 +static struct proc_dir_entry *proc_virtual;
21122 +static struct proc_dir_entry *proc_virtnet;
21125 +/* first the actual feeds */
21128 +static int proc_vci(char *buffer)
21130 + return sprintf(buffer,
21131 + "VCIVersion:\t%04x:%04x\n"
21132 + "VCISyscall:\t%d\n"
21133 + "VCIKernel:\t%08x\n",
21134 + VCI_VERSION >> 16,
21135 + VCI_VERSION & 0xFFFF,
21137 + vci_kernel_config());
21140 +static int proc_virtual_info(char *buffer)
21142 + return proc_vci(buffer);
21145 +static int proc_virtual_status(char *buffer)
21147 + return sprintf(buffer,
21149 + "#CActive:\t%d\n"
21150 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21151 + "#InitTask:\t%d\t%d %d\n",
21152 + atomic_read(&vx_global_ctotal),
21153 + atomic_read(&vx_global_cactive),
21154 + atomic_read(&vs_global_nsproxy),
21155 + atomic_read(&vs_global_fs),
21156 + atomic_read(&vs_global_mnt_ns),
21157 + atomic_read(&vs_global_uts_ns),
21158 + atomic_read(&nr_ipc_ns),
21159 + atomic_read(&vs_global_user_ns),
21160 + atomic_read(&vs_global_pid_ns),
21161 + atomic_read(&init_task.usage),
21162 + atomic_read(&init_task.nsproxy->count),
21163 + init_task.fs->users);
21167 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21171 + length = sprintf(buffer,
21179 + vxi->vx_badness_bias);
21183 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21185 + char *orig = buffer;
21187 + buffer += sprintf(buffer,
21190 + "Flags:\t%016llx\n",
21191 + atomic_read(&vxi->vx_usecnt),
21192 + atomic_read(&vxi->vx_tasks),
21193 + (unsigned long long)vxi->vx_flags);
21195 + buffer += sprintf(buffer, "BCaps:\t");
21196 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21197 + buffer += sprintf(buffer, "\n");
21199 + buffer += sprintf(buffer,
21200 + "CCaps:\t%016llx\n"
21201 + "Umask:\t%16llx\n"
21202 + "Wmask:\t%16llx\n"
21203 + "Spaces:\t%08lx %08lx\n",
21204 + (unsigned long long)vxi->vx_ccaps,
21205 + (unsigned long long)vxi->vx_umask,
21206 + (unsigned long long)vxi->vx_wmask,
21207 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21208 + return buffer - orig;
21211 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21213 + return vx_info_proc_limit(&vxi->limit, buffer);
21216 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21220 + length = vx_info_proc_sched(&vxi->sched, buffer);
21221 + for_each_online_cpu(cpu) {
21222 + length += vx_info_proc_sched_pc(
21223 + &vx_per_cpu(vxi, sched_pc, cpu),
21224 + buffer + length, cpu);
21229 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21231 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21234 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21236 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21239 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21243 + vx_update_load(vxi);
21244 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21245 + for_each_online_cpu(cpu) {
21246 + length += vx_info_proc_cvirt_pc(
21247 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21248 + buffer + length, cpu);
21253 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21255 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21259 +static int proc_virtnet_info(char *buffer)
21261 + return proc_vci(buffer);
21264 +static int proc_virtnet_status(char *buffer)
21266 + return sprintf(buffer,
21268 + "#CActive:\t%d\n",
21269 + atomic_read(&nx_global_ctotal),
21270 + atomic_read(&nx_global_cactive));
21273 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21275 + struct nx_addr_v4 *v4a;
21276 +#ifdef CONFIG_IPV6
21277 + struct nx_addr_v6 *v6a;
21281 + length = sprintf(buffer,
21284 + "Bcast:\t" NIPQUAD_FMT "\n"
21285 + "Lback:\t" NIPQUAD_FMT "\n",
21288 + NIPQUAD(nxi->v4_bcast.s_addr),
21289 + NIPQUAD(nxi->v4_lback.s_addr));
21291 + if (!NX_IPV4(nxi))
21293 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21294 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21297 +#ifdef CONFIG_IPV6
21298 + if (!NX_IPV6(nxi))
21300 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21301 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21308 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21312 + length = sprintf(buffer,
21315 + "Flags:\t%016llx\n"
21316 + "NCaps:\t%016llx\n",
21317 + atomic_read(&nxi->nx_usecnt),
21318 + atomic_read(&nxi->nx_tasks),
21319 + (unsigned long long)nxi->nx_flags,
21320 + (unsigned long long)nxi->nx_ncaps);
21326 +/* here the inode helpers */
21332 + struct inode_operations *iop;
21333 + struct file_operations *fop;
21334 + union proc_op op;
21337 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21339 + struct inode *inode = new_inode(sb);
21344 + inode->i_mode = p->mode;
21346 + inode->i_op = p->iop;
21348 + inode->i_fop = p->fop;
21350 + set_nlink(inode, (p->mode & S_IFDIR) ? 2 : 1);
21351 + inode->i_flags |= S_IMMUTABLE;
21353 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21355 + inode->i_uid = 0;
21356 + inode->i_gid = 0;
21357 + inode->i_tag = 0;
21362 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21363 + struct dentry *dentry, int id, void *ptr)
21365 + struct vs_entry *p = ptr;
21366 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21367 + struct dentry *error = ERR_PTR(-EINVAL);
21372 + PROC_I(inode)->op = p->op;
21373 + PROC_I(inode)->fd = id;
21374 + d_add(dentry, inode);
21382 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21385 + * Fill a directory entry.
21387 + * If possible create the dcache entry and derive our inode number and
21388 + * file type from dcache entry.
21390 + * Since all of the proc inode numbers are dynamically generated, the inode
21391 + * numbers do not exist until the inode is cache. This means creating the
21392 + * the dcache entry in readdir is necessary to keep the inode numbers
21393 + * reported by readdir in sync with the inode numbers reported
21396 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21397 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21399 + struct dentry *child, *dir = filp->f_dentry;
21400 + struct inode *inode;
21401 + struct qstr qname;
21403 + unsigned type = DT_UNKNOWN;
21405 + qname.name = name;
21407 + qname.hash = full_name_hash(name, len);
21409 + child = d_lookup(dir, &qname);
21411 + struct dentry *new;
21412 + new = d_alloc(dir, &qname);
21414 + child = instantiate(dir->d_inode, new, id, ptr);
21421 + if (!child || IS_ERR(child) || !child->d_inode)
21422 + goto end_instantiate;
21423 + inode = child->d_inode;
21425 + ino = inode->i_ino;
21426 + type = inode->i_mode >> 12;
21431 + ino = find_inode_number(dir, &qname);
21434 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21439 +/* get and revalidate vx_info/xid */
21442 +struct vx_info *get_proc_vx_info(struct inode *inode)
21444 + return lookup_vx_info(PROC_I(inode)->fd);
21447 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21449 + struct inode *inode = dentry->d_inode;
21450 + xid_t xid = PROC_I(inode)->fd;
21452 + if (!xid || xid_is_hashed(xid))
21459 +/* get and revalidate nx_info/nid */
21461 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21463 + struct inode *inode = dentry->d_inode;
21464 + nid_t nid = PROC_I(inode)->fd;
21466 + if (!nid || nid_is_hashed(nid))
21474 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21476 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21477 + size_t count, loff_t *ppos)
21479 + struct inode *inode = file->f_dentry->d_inode;
21480 + unsigned long page;
21481 + ssize_t length = 0;
21483 + if (count > PROC_BLOCK_SIZE)
21484 + count = PROC_BLOCK_SIZE;
21486 + /* fade that out as soon as stable */
21487 + WARN_ON(PROC_I(inode)->fd);
21489 + if (!(page = __get_free_page(GFP_KERNEL)))
21492 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21493 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21496 + length = simple_read_from_buffer(buf, count, ppos,
21497 + (char *)page, length);
21503 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21504 + size_t count, loff_t *ppos)
21506 + struct inode *inode = file->f_dentry->d_inode;
21507 + struct vx_info *vxi = NULL;
21508 + xid_t xid = PROC_I(inode)->fd;
21509 + unsigned long page;
21510 + ssize_t length = 0;
21512 + if (count > PROC_BLOCK_SIZE)
21513 + count = PROC_BLOCK_SIZE;
21515 + /* fade that out as soon as stable */
21517 + vxi = lookup_vx_info(xid);
21521 + length = -ENOMEM;
21522 + if (!(page = __get_free_page(GFP_KERNEL)))
21525 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21526 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21529 + length = simple_read_from_buffer(buf, count, ppos,
21530 + (char *)page, length);
21534 + put_vx_info(vxi);
21539 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21540 + size_t count, loff_t *ppos)
21542 + struct inode *inode = file->f_dentry->d_inode;
21543 + struct nx_info *nxi = NULL;
21544 + nid_t nid = PROC_I(inode)->fd;
21545 + unsigned long page;
21546 + ssize_t length = 0;
21548 + if (count > PROC_BLOCK_SIZE)
21549 + count = PROC_BLOCK_SIZE;
21551 + /* fade that out as soon as stable */
21553 + nxi = lookup_nx_info(nid);
21557 + length = -ENOMEM;
21558 + if (!(page = __get_free_page(GFP_KERNEL)))
21561 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21562 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21565 + length = simple_read_from_buffer(buf, count, ppos,
21566 + (char *)page, length);
21570 + put_nx_info(nxi);
21577 +/* here comes the lower level */
21580 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21581 + .len = sizeof(NAME) - 1, \
21582 + .name = (NAME), \
21590 +#define DIR(NAME, MODE, OTYPE) \
21591 + NOD(NAME, (S_IFDIR | (MODE)), \
21592 + &proc_ ## OTYPE ## _inode_operations, \
21593 + &proc_ ## OTYPE ## _file_operations, { } )
21595 +#define INF(NAME, MODE, OTYPE) \
21596 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21597 + &proc_vs_info_file_operations, \
21598 + { .proc_vs_read = &proc_##OTYPE } )
21600 +#define VINF(NAME, MODE, OTYPE) \
21601 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21602 + &proc_vx_info_file_operations, \
21603 + { .proc_vxi_read = &proc_##OTYPE } )
21605 +#define NINF(NAME, MODE, OTYPE) \
21606 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21607 + &proc_nx_info_file_operations, \
21608 + { .proc_nxi_read = &proc_##OTYPE } )
21611 +static struct file_operations proc_vs_info_file_operations = {
21612 + .read = proc_vs_info_read,
21615 +static struct file_operations proc_vx_info_file_operations = {
21616 + .read = proc_vx_info_read,
21619 +static struct dentry_operations proc_xid_dentry_operations = {
21620 + .d_revalidate = proc_xid_revalidate,
21623 +static struct vs_entry vx_base_stuff[] = {
21624 + VINF("info", S_IRUGO, vxi_info),
21625 + VINF("status", S_IRUGO, vxi_status),
21626 + VINF("limit", S_IRUGO, vxi_limit),
21627 + VINF("sched", S_IRUGO, vxi_sched),
21628 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21629 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21630 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21631 + VINF("cacct", S_IRUGO, vxi_cacct),
21638 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21639 + struct dentry *dentry, int id, void *ptr)
21641 + dentry->d_op = &proc_xid_dentry_operations;
21642 + return vs_proc_instantiate(dir, dentry, id, ptr);
21645 +static struct dentry *proc_xid_lookup(struct inode *dir,
21646 + struct dentry *dentry, struct nameidata *nd)
21648 + struct vs_entry *p = vx_base_stuff;
21649 + struct dentry *error = ERR_PTR(-ENOENT);
21651 + for (; p->name; p++) {
21652 + if (p->len != dentry->d_name.len)
21654 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21660 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21665 +static int proc_xid_readdir(struct file *filp,
21666 + void *dirent, filldir_t filldir)
21668 + struct dentry *dentry = filp->f_dentry;
21669 + struct inode *inode = dentry->d_inode;
21670 + struct vs_entry *p = vx_base_stuff;
21671 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21675 + pos = filp->f_pos;
21678 + ino = inode->i_ino;
21679 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21682 + /* fall through */
21684 + ino = parent_ino(dentry);
21685 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21688 + /* fall through */
21691 + if (index >= size)
21693 + for (p += index; p->name; p++) {
21694 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21695 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21701 + filp->f_pos = pos;
21707 +static struct file_operations proc_nx_info_file_operations = {
21708 + .read = proc_nx_info_read,
21711 +static struct dentry_operations proc_nid_dentry_operations = {
21712 + .d_revalidate = proc_nid_revalidate,
21715 +static struct vs_entry nx_base_stuff[] = {
21716 + NINF("info", S_IRUGO, nxi_info),
21717 + NINF("status", S_IRUGO, nxi_status),
21722 +static struct dentry *proc_nid_instantiate(struct inode *dir,
21723 + struct dentry *dentry, int id, void *ptr)
21725 + dentry->d_op = &proc_nid_dentry_operations;
21726 + return vs_proc_instantiate(dir, dentry, id, ptr);
21729 +static struct dentry *proc_nid_lookup(struct inode *dir,
21730 + struct dentry *dentry, struct nameidata *nd)
21732 + struct vs_entry *p = nx_base_stuff;
21733 + struct dentry *error = ERR_PTR(-ENOENT);
21735 + for (; p->name; p++) {
21736 + if (p->len != dentry->d_name.len)
21738 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21744 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21749 +static int proc_nid_readdir(struct file *filp,
21750 + void *dirent, filldir_t filldir)
21752 + struct dentry *dentry = filp->f_dentry;
21753 + struct inode *inode = dentry->d_inode;
21754 + struct vs_entry *p = nx_base_stuff;
21755 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
21759 + pos = filp->f_pos;
21762 + ino = inode->i_ino;
21763 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21766 + /* fall through */
21768 + ino = parent_ino(dentry);
21769 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21772 + /* fall through */
21775 + if (index >= size)
21777 + for (p += index; p->name; p++) {
21778 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21779 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21785 + filp->f_pos = pos;
21790 +#define MAX_MULBY10 ((~0U - 9) / 10)
21792 +static inline int atovid(const char *str, int len)
21797 + while (len-- > 0) {
21802 + if (vid >= MAX_MULBY10)
21812 +/* now the upper level (virtual) */
21815 +static struct file_operations proc_xid_file_operations = {
21816 + .read = generic_read_dir,
21817 + .readdir = proc_xid_readdir,
21820 +static struct inode_operations proc_xid_inode_operations = {
21821 + .lookup = proc_xid_lookup,
21824 +static struct vs_entry vx_virtual_stuff[] = {
21825 + INF("info", S_IRUGO, virtual_info),
21826 + INF("status", S_IRUGO, virtual_status),
21827 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
21831 +static struct dentry *proc_virtual_lookup(struct inode *dir,
21832 + struct dentry *dentry, struct nameidata *nd)
21834 + struct vs_entry *p = vx_virtual_stuff;
21835 + struct dentry *error = ERR_PTR(-ENOENT);
21838 + for (; p->name; p++) {
21839 + if (p->len != dentry->d_name.len)
21841 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21845 + goto instantiate;
21847 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21848 + if ((id < 0) || !xid_is_hashed(id))
21852 + error = proc_xid_instantiate(dir, dentry, id, p);
21857 +static struct file_operations proc_nid_file_operations = {
21858 + .read = generic_read_dir,
21859 + .readdir = proc_nid_readdir,
21862 +static struct inode_operations proc_nid_inode_operations = {
21863 + .lookup = proc_nid_lookup,
21866 +static struct vs_entry nx_virtnet_stuff[] = {
21867 + INF("info", S_IRUGO, virtnet_info),
21868 + INF("status", S_IRUGO, virtnet_status),
21869 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
21873 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
21874 + struct dentry *dentry, struct nameidata *nd)
21876 + struct vs_entry *p = nx_virtnet_stuff;
21877 + struct dentry *error = ERR_PTR(-ENOENT);
21880 + for (; p->name; p++) {
21881 + if (p->len != dentry->d_name.len)
21883 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21887 + goto instantiate;
21889 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21890 + if ((id < 0) || !nid_is_hashed(id))
21894 + error = proc_nid_instantiate(dir, dentry, id, p);
21900 +#define PROC_MAXVIDS 32
21902 +int proc_virtual_readdir(struct file *filp,
21903 + void *dirent, filldir_t filldir)
21905 + struct dentry *dentry = filp->f_dentry;
21906 + struct inode *inode = dentry->d_inode;
21907 + struct vs_entry *p = vx_virtual_stuff;
21908 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
21910 + unsigned int xid_array[PROC_MAXVIDS];
21911 + char buf[PROC_NUMBUF];
21912 + unsigned int nr_xids, i;
21915 + pos = filp->f_pos;
21918 + ino = inode->i_ino;
21919 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21922 + /* fall through */
21924 + ino = parent_ino(dentry);
21925 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21928 + /* fall through */
21931 + if (index >= size)
21933 + for (p += index; p->name; p++) {
21934 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21935 + vs_proc_instantiate, 0, p))
21940 + index = pos - size;
21941 + p = &vx_virtual_stuff[size - 1];
21942 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
21943 + for (i = 0; i < nr_xids; i++) {
21944 + int n, xid = xid_array[i];
21945 + unsigned int j = PROC_NUMBUF;
21949 + buf[--j] = '0' + (n % 10);
21952 + if (proc_fill_cache(filp, dirent, filldir,
21953 + buf + j, PROC_NUMBUF - j,
21954 + vs_proc_instantiate, xid, p))
21960 + filp->f_pos = pos;
21964 +static int proc_virtual_getattr(struct vfsmount *mnt,
21965 + struct dentry *dentry, struct kstat *stat)
21967 + struct inode *inode = dentry->d_inode;
21969 + generic_fillattr(inode, stat);
21970 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
21974 +static struct file_operations proc_virtual_dir_operations = {
21975 + .read = generic_read_dir,
21976 + .readdir = proc_virtual_readdir,
21979 +static struct inode_operations proc_virtual_dir_inode_operations = {
21980 + .getattr = proc_virtual_getattr,
21981 + .lookup = proc_virtual_lookup,
21988 +int proc_virtnet_readdir(struct file *filp,
21989 + void *dirent, filldir_t filldir)
21991 + struct dentry *dentry = filp->f_dentry;
21992 + struct inode *inode = dentry->d_inode;
21993 + struct vs_entry *p = nx_virtnet_stuff;
21994 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
21996 + unsigned int nid_array[PROC_MAXVIDS];
21997 + char buf[PROC_NUMBUF];
21998 + unsigned int nr_nids, i;
22001 + pos = filp->f_pos;
22004 + ino = inode->i_ino;
22005 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22008 + /* fall through */
22010 + ino = parent_ino(dentry);
22011 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22014 + /* fall through */
22017 + if (index >= size)
22019 + for (p += index; p->name; p++) {
22020 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22021 + vs_proc_instantiate, 0, p))
22026 + index = pos - size;
22027 + p = &nx_virtnet_stuff[size - 1];
22028 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22029 + for (i = 0; i < nr_nids; i++) {
22030 + int n, nid = nid_array[i];
22031 + unsigned int j = PROC_NUMBUF;
22035 + buf[--j] = '0' + (n % 10);
22038 + if (proc_fill_cache(filp, dirent, filldir,
22039 + buf + j, PROC_NUMBUF - j,
22040 + vs_proc_instantiate, nid, p))
22046 + filp->f_pos = pos;
22050 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22051 + struct dentry *dentry, struct kstat *stat)
22053 + struct inode *inode = dentry->d_inode;
22055 + generic_fillattr(inode, stat);
22056 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22060 +static struct file_operations proc_virtnet_dir_operations = {
22061 + .read = generic_read_dir,
22062 + .readdir = proc_virtnet_readdir,
22065 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22066 + .getattr = proc_virtnet_getattr,
22067 + .lookup = proc_virtnet_lookup,
22072 +void proc_vx_init(void)
22074 + struct proc_dir_entry *ent;
22076 + ent = proc_mkdir("virtual", 0);
22078 + ent->proc_fops = &proc_virtual_dir_operations;
22079 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22081 + proc_virtual = ent;
22083 + ent = proc_mkdir("virtnet", 0);
22085 + ent->proc_fops = &proc_virtnet_dir_operations;
22086 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22088 + proc_virtnet = ent;
22094 +/* per pid info */
22097 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22099 + struct vx_info *vxi;
22100 + char *orig = buffer;
22102 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22104 + vxi = task_get_vx_info(p);
22108 + buffer += sprintf(buffer, "BCaps:\t");
22109 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22110 + buffer += sprintf(buffer, "\n");
22111 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22112 + (unsigned long long)vxi->vx_ccaps);
22113 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22114 + (unsigned long long)vxi->vx_flags);
22115 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22117 + put_vx_info(vxi);
22119 + return buffer - orig;
22123 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22125 + struct nx_info *nxi;
22126 + struct nx_addr_v4 *v4a;
22127 +#ifdef CONFIG_IPV6
22128 + struct nx_addr_v6 *v6a;
22130 + char *orig = buffer;
22133 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22135 + nxi = task_get_nx_info(p);
22139 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22140 + (unsigned long long)nxi->nx_ncaps);
22141 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22142 + (unsigned long long)nxi->nx_flags);
22144 + buffer += sprintf(buffer,
22145 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22146 + NIPQUAD(nxi->v4_bcast.s_addr));
22147 + buffer += sprintf (buffer,
22148 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22149 + NIPQUAD(nxi->v4_lback.s_addr));
22150 + if (!NX_IPV4(nxi))
22152 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22153 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22156 +#ifdef CONFIG_IPV6
22157 + if (!NX_IPV6(nxi))
22159 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22160 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22164 + put_nx_info(nxi);
22166 + return buffer - orig;
22169 diff -NurpP --minimal linux-3.2.8/kernel/vserver/sched.c linux-3.2.8-vs2.3.2.7/kernel/vserver/sched.c
22170 --- linux-3.2.8/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22171 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/sched.c 2011-12-05 19:33:02.000000000 +0100
22174 + * linux/kernel/vserver/sched.c
22176 + * Virtual Server: Scheduler Support
22178 + * Copyright (C) 2004-2010 Herbert Pötzl
22180 + * V0.01 adapted Sam Vilains version to 2.6.3
22181 + * V0.02 removed legacy interface
22182 + * V0.03 changed vcmds to vxi arg
22183 + * V0.04 removed older and legacy interfaces
22184 + * V0.05 removed scheduler code/commands
22188 +#include <linux/vs_context.h>
22189 +#include <linux/vs_sched.h>
22190 +#include <linux/vserver/sched_cmd.h>
22192 +#include <asm/uaccess.h>
22195 +void vx_update_sched_param(struct _vx_sched *sched,
22196 + struct _vx_sched_pc *sched_pc)
22198 + sched_pc->prio_bias = sched->prio_bias;
22201 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22205 + if (data->prio_bias > MAX_PRIO_BIAS)
22206 + data->prio_bias = MAX_PRIO_BIAS;
22207 + if (data->prio_bias < MIN_PRIO_BIAS)
22208 + data->prio_bias = MIN_PRIO_BIAS;
22210 + if (data->cpu_id != ~0) {
22211 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22212 + cpus_and(vxi->sched.update, cpu_online_map,
22213 + vxi->sched.update);
22215 + vxi->sched.update = cpu_online_map;
22217 + for_each_cpu_mask(cpu, vxi->sched.update)
22218 + vx_update_sched_param(&vxi->sched,
22219 + &vx_per_cpu(vxi, sched_pc, cpu));
22223 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22225 + struct vcmd_prio_bias vc_data;
22227 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22230 + return do_set_prio_bias(vxi, &vc_data);
22233 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22235 + struct vcmd_prio_bias vc_data;
22236 + struct _vx_sched_pc *pcd;
22239 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22242 + cpu = vc_data.cpu_id;
22244 + if (!cpu_possible(cpu))
22247 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22248 + vc_data.prio_bias = pcd->prio_bias;
22250 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22255 diff -NurpP --minimal linux-3.2.8/kernel/vserver/sched_init.h linux-3.2.8-vs2.3.2.7/kernel/vserver/sched_init.h
22256 --- linux-3.2.8/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22257 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/sched_init.h 2011-12-05 19:33:02.000000000 +0100
22260 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22262 + /* scheduling; hard code starting values as constants */
22263 + sched->prio_bias = 0;
22267 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22269 + sched_pc->prio_bias = 0;
22271 + sched_pc->user_ticks = 0;
22272 + sched_pc->sys_ticks = 0;
22273 + sched_pc->hold_ticks = 0;
22276 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22282 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22286 diff -NurpP --minimal linux-3.2.8/kernel/vserver/sched_proc.h linux-3.2.8-vs2.3.2.7/kernel/vserver/sched_proc.h
22287 --- linux-3.2.8/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22288 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/sched_proc.h 2011-12-05 19:33:02.000000000 +0100
22290 +#ifndef _VX_SCHED_PROC_H
22291 +#define _VX_SCHED_PROC_H
22295 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22299 + length += sprintf(buffer,
22300 + "PrioBias:\t%8d\n",
22301 + sched->prio_bias);
22306 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22307 + char *buffer, int cpu)
22311 + length += sprintf(buffer + length,
22312 + "cpu %d: %lld %lld %lld", cpu,
22313 + (unsigned long long)sched_pc->user_ticks,
22314 + (unsigned long long)sched_pc->sys_ticks,
22315 + (unsigned long long)sched_pc->hold_ticks);
22316 + length += sprintf(buffer + length,
22317 + " %d\n", sched_pc->prio_bias);
22321 +#endif /* _VX_SCHED_PROC_H */
22322 diff -NurpP --minimal linux-3.2.8/kernel/vserver/signal.c linux-3.2.8-vs2.3.2.7/kernel/vserver/signal.c
22323 --- linux-3.2.8/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22324 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/signal.c 2011-12-05 19:33:02.000000000 +0100
22327 + * linux/kernel/vserver/signal.c
22329 + * Virtual Server: Signal Support
22331 + * Copyright (C) 2003-2007 Herbert Pötzl
22333 + * V0.01 broken out from vcontext V0.05
22334 + * V0.02 changed vcmds to vxi arg
22335 + * V0.03 adjusted siginfo for kill
22339 +#include <asm/uaccess.h>
22341 +#include <linux/vs_context.h>
22342 +#include <linux/vs_pid.h>
22343 +#include <linux/vserver/signal_cmd.h>
22346 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22348 + int retval, count = 0;
22349 + struct task_struct *p;
22350 + struct siginfo *sip = SEND_SIG_PRIV;
22353 + vxdprintk(VXD_CBIT(misc, 4),
22354 + "vx_info_kill(%p[#%d],%d,%d)*",
22355 + vxi, vxi->vx_id, pid, sig);
22356 + read_lock(&tasklist_lock);
22360 + for_each_process(p) {
22363 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22364 + (pid && vxi->vx_initpid == p->pid))
22367 + err = group_send_sig_info(sig, sip, p);
22369 + if (err != -EPERM)
22375 + if (vxi->vx_initpid) {
22376 + pid = vxi->vx_initpid;
22377 + /* for now, only SIGINT to private init ... */
22378 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22379 + /* ... as long as there are tasks left */
22380 + (atomic_read(&vxi->vx_tasks) > 1))
22383 + /* fallthrough */
22386 + p = find_task_by_real_pid(pid);
22387 + rcu_read_unlock();
22389 + if (vx_task_xid(p) == vxi->vx_id)
22390 + retval = group_send_sig_info(sig, sip, p);
22394 + read_unlock(&tasklist_lock);
22395 + vxdprintk(VXD_CBIT(misc, 4),
22396 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22397 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22401 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22403 + struct vcmd_ctx_kill_v0 vc_data;
22405 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22408 + /* special check to allow guest shutdown */
22409 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22410 + /* forbid killall pid=0 when init is present */
22411 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22412 + (vc_data.pid > 1)))
22415 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22419 +static int __wait_exit(struct vx_info *vxi)
22421 + DECLARE_WAITQUEUE(wait, current);
22424 + add_wait_queue(&vxi->vx_wait, &wait);
22425 + set_current_state(TASK_INTERRUPTIBLE);
22428 + if (vx_info_state(vxi,
22429 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22431 + if (signal_pending(current)) {
22432 + ret = -ERESTARTSYS;
22439 + set_current_state(TASK_RUNNING);
22440 + remove_wait_queue(&vxi->vx_wait, &wait);
22446 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22448 + struct vcmd_wait_exit_v0 vc_data;
22451 + ret = __wait_exit(vxi);
22452 + vc_data.reboot_cmd = vxi->reboot_cmd;
22453 + vc_data.exit_code = vxi->exit_code;
22455 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22460 diff -NurpP --minimal linux-3.2.8/kernel/vserver/space.c linux-3.2.8-vs2.3.2.7/kernel/vserver/space.c
22461 --- linux-3.2.8/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22462 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/space.c 2011-12-05 19:33:02.000000000 +0100
22465 + * linux/kernel/vserver/space.c
22467 + * Virtual Server: Context Space Support
22469 + * Copyright (C) 2003-2010 Herbert Pötzl
22471 + * V0.01 broken out from context.c 0.07
22472 + * V0.02 added task locking for namespace
22473 + * V0.03 broken out vx_enter_namespace
22474 + * V0.04 added *space support and commands
22475 + * V0.05 added credential support
22479 +#include <linux/utsname.h>
22480 +#include <linux/nsproxy.h>
22481 +#include <linux/err.h>
22482 +#include <linux/fs_struct.h>
22483 +#include <linux/cred.h>
22484 +#include <asm/uaccess.h>
22486 +#include <linux/vs_context.h>
22487 +#include <linux/vserver/space.h>
22488 +#include <linux/vserver/space_cmd.h>
22490 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22491 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22492 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22493 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22494 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22495 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22498 +/* namespace functions */
22500 +#include <linux/mnt_namespace.h>
22501 +#include <linux/user_namespace.h>
22502 +#include <linux/pid_namespace.h>
22503 +#include <linux/ipc_namespace.h>
22504 +#include <net/net_namespace.h>
22507 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22508 + .mask = CLONE_FS |
22510 +#ifdef CONFIG_UTS_NS
22513 +#ifdef CONFIG_IPC_NS
22516 +#ifdef CONFIG_USER_NS
22522 +static const struct vcmd_space_mask_v1 space_mask = {
22523 + .mask = CLONE_FS |
22525 +#ifdef CONFIG_UTS_NS
22528 +#ifdef CONFIG_IPC_NS
22531 +#ifdef CONFIG_USER_NS
22534 +#ifdef CONFIG_PID_NS
22537 +#ifdef CONFIG_NET_NS
22543 +static const struct vcmd_space_mask_v1 default_space_mask = {
22544 + .mask = CLONE_FS |
22546 +#ifdef CONFIG_UTS_NS
22549 +#ifdef CONFIG_IPC_NS
22552 +#ifdef CONFIG_USER_NS
22555 +#ifdef CONFIG_PID_NS
22562 + * build a new nsproxy mix
22563 + * assumes that both proxies are 'const'
22564 + * does not touch nsproxy refcounts
22565 + * will hold a reference on the result.
22568 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22569 + struct nsproxy *new_nsproxy, unsigned long mask)
22571 + struct mnt_namespace *old_ns;
22572 + struct uts_namespace *old_uts;
22573 + struct ipc_namespace *old_ipc;
22574 +#ifdef CONFIG_PID_NS
22575 + struct pid_namespace *old_pid;
22577 +#ifdef CONFIG_NET_NS
22578 + struct net *old_net;
22580 + struct nsproxy *nsproxy;
22582 + nsproxy = copy_nsproxy(old_nsproxy);
22586 + if (mask & CLONE_NEWNS) {
22587 + old_ns = nsproxy->mnt_ns;
22588 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22589 + if (nsproxy->mnt_ns)
22590 + get_mnt_ns(nsproxy->mnt_ns);
22594 + if (mask & CLONE_NEWUTS) {
22595 + old_uts = nsproxy->uts_ns;
22596 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22597 + if (nsproxy->uts_ns)
22598 + get_uts_ns(nsproxy->uts_ns);
22602 + if (mask & CLONE_NEWIPC) {
22603 + old_ipc = nsproxy->ipc_ns;
22604 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22605 + if (nsproxy->ipc_ns)
22606 + get_ipc_ns(nsproxy->ipc_ns);
22610 +#ifdef CONFIG_PID_NS
22611 + if (mask & CLONE_NEWPID) {
22612 + old_pid = nsproxy->pid_ns;
22613 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22614 + if (nsproxy->pid_ns)
22615 + get_pid_ns(nsproxy->pid_ns);
22619 +#ifdef CONFIG_NET_NS
22620 + if (mask & CLONE_NEWNET) {
22621 + old_net = nsproxy->net_ns;
22622 + nsproxy->net_ns = new_nsproxy->net_ns;
22623 + if (nsproxy->net_ns)
22624 + get_net(nsproxy->net_ns);
22629 + put_mnt_ns(old_ns);
22631 + put_uts_ns(old_uts);
22633 + put_ipc_ns(old_ipc);
22634 +#ifdef CONFIG_PID_NS
22636 + put_pid_ns(old_pid);
22638 +#ifdef CONFIG_NET_NS
22640 + put_net(old_net);
22648 + * merge two nsproxy structs into a new one.
22649 + * will hold a reference on the result.
22653 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22654 + struct nsproxy *proxy, unsigned long mask)
22656 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22662 + /* vs_mix_nsproxy returns with reference */
22663 + return vs_mix_nsproxy(old ? old : &null_proxy,
22666 + get_nsproxy(proxy);
22671 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22673 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22674 + struct fs_struct *fs_cur, *fs = NULL;
22675 + struct _vx_space *space;
22676 + int ret, kill = 0;
22678 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22679 + vxi, vxi->vx_id, mask, index);
22681 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22684 + if (index >= VX_SPACES)
22687 + space = &vxi->space[index];
22690 + mask = space->vx_nsmask;
22692 + if ((mask & space->vx_nsmask) != mask)
22695 + if (mask & CLONE_FS) {
22696 + fs = copy_fs_struct(space->vx_fs);
22700 + proxy = space->vx_nsproxy;
22702 + vxdprintk(VXD_CBIT(space, 9),
22703 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
22704 + vxi, vxi->vx_id, mask, index, proxy, fs);
22706 + task_lock(current);
22707 + fs_cur = current->fs;
22709 + if (mask & CLONE_FS) {
22710 + spin_lock(&fs_cur->lock);
22711 + current->fs = fs;
22712 + kill = !--fs_cur->users;
22713 + spin_unlock(&fs_cur->lock);
22716 + proxy_cur = current->nsproxy;
22717 + get_nsproxy(proxy_cur);
22718 + task_unlock(current);
22721 + free_fs_struct(fs_cur);
22723 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
22724 + if (IS_ERR(proxy_new)) {
22725 + ret = PTR_ERR(proxy_new);
22729 + proxy_new = xchg(¤t->nsproxy, proxy_new);
22731 + if (mask & CLONE_NEWUSER) {
22732 + struct cred *cred;
22734 + vxdprintk(VXD_CBIT(space, 10),
22735 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
22736 + vxi, vxi->vx_id, space->vx_cred,
22737 + current->real_cred, current->cred);
22739 + if (space->vx_cred) {
22740 + cred = __prepare_creds(space->vx_cred);
22742 + commit_creds(cred);
22749 + put_nsproxy(proxy_new);
22752 + put_nsproxy(proxy_cur);
22757 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22759 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
22760 + struct fs_struct *fs_vxi, *fs;
22761 + struct _vx_space *space;
22762 + int ret, kill = 0;
22764 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
22765 + vxi, vxi->vx_id, mask, index);
22767 + if ((mask & space_mask.mask) != mask)
22770 + if (index >= VX_SPACES)
22773 + space = &vxi->space[index];
22775 + proxy_vxi = space->vx_nsproxy;
22776 + fs_vxi = space->vx_fs;
22778 + if (mask & CLONE_FS) {
22779 + fs = copy_fs_struct(current->fs);
22784 + task_lock(current);
22786 + if (mask & CLONE_FS) {
22787 + spin_lock(&fs_vxi->lock);
22788 + space->vx_fs = fs;
22789 + kill = !--fs_vxi->users;
22790 + spin_unlock(&fs_vxi->lock);
22793 + proxy_cur = current->nsproxy;
22794 + get_nsproxy(proxy_cur);
22795 + task_unlock(current);
22798 + free_fs_struct(fs_vxi);
22800 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
22801 + if (IS_ERR(proxy_new)) {
22802 + ret = PTR_ERR(proxy_new);
22806 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
22807 + space->vx_nsmask |= mask;
22809 + if (mask & CLONE_NEWUSER) {
22810 + struct cred *cred;
22812 + vxdprintk(VXD_CBIT(space, 10),
22813 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
22814 + vxi, vxi->vx_id, space->vx_cred,
22815 + current->real_cred, current->cred);
22817 + cred = prepare_creds();
22818 + cred = (struct cred *)xchg(&space->vx_cred, cred);
22820 + abort_creds(cred);
22826 + put_nsproxy(proxy_new);
22829 + put_nsproxy(proxy_cur);
22834 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
22836 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22838 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22841 + return vx_enter_space(vxi, vc_data.mask, 0);
22844 +int vc_enter_space(struct vx_info *vxi, void __user *data)
22846 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22848 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22851 + if (vc_data.index >= VX_SPACES)
22854 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
22857 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
22859 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22861 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22864 + return vx_set_space(vxi, vc_data.mask, 0);
22867 +int vc_set_space(struct vx_info *vxi, void __user *data)
22869 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22871 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22874 + if (vc_data.index >= VX_SPACES)
22877 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
22880 +int vc_get_space_mask(void __user *data, int type)
22882 + const struct vcmd_space_mask_v1 *mask;
22885 + mask = &space_mask_v0;
22886 + else if (type == 1)
22887 + mask = &space_mask;
22889 + mask = &default_space_mask;
22891 + vxdprintk(VXD_CBIT(space, 10),
22892 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
22894 + if (copy_to_user(data, mask, sizeof(*mask)))
22899 diff -NurpP --minimal linux-3.2.8/kernel/vserver/switch.c linux-3.2.8-vs2.3.2.7/kernel/vserver/switch.c
22900 --- linux-3.2.8/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
22901 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/switch.c 2011-12-05 19:33:02.000000000 +0100
22904 + * linux/kernel/vserver/switch.c
22906 + * Virtual Server: Syscall Switch
22908 + * Copyright (C) 2003-2011 Herbert Pötzl
22910 + * V0.01 syscall switch
22911 + * V0.02 added signal to context
22912 + * V0.03 added rlimit functions
22913 + * V0.04 added iattr, task/xid functions
22914 + * V0.05 added debug/history stuff
22915 + * V0.06 added compat32 layer
22916 + * V0.07 vcmd args and perms
22917 + * V0.08 added status commands
22918 + * V0.09 added tag commands
22919 + * V0.10 added oom bias
22920 + * V0.11 added device commands
22921 + * V0.12 added warn mask
22925 +#include <linux/vs_context.h>
22926 +#include <linux/vs_network.h>
22927 +#include <linux/vserver/switch.h>
22929 +#include "vci_config.h"
22933 +int vc_get_version(uint32_t id)
22935 + return VCI_VERSION;
22939 +int vc_get_vci(uint32_t id)
22941 + return vci_kernel_config();
22944 +#include <linux/vserver/context_cmd.h>
22945 +#include <linux/vserver/cvirt_cmd.h>
22946 +#include <linux/vserver/cacct_cmd.h>
22947 +#include <linux/vserver/limit_cmd.h>
22948 +#include <linux/vserver/network_cmd.h>
22949 +#include <linux/vserver/sched_cmd.h>
22950 +#include <linux/vserver/debug_cmd.h>
22951 +#include <linux/vserver/inode_cmd.h>
22952 +#include <linux/vserver/dlimit_cmd.h>
22953 +#include <linux/vserver/signal_cmd.h>
22954 +#include <linux/vserver/space_cmd.h>
22955 +#include <linux/vserver/tag_cmd.h>
22956 +#include <linux/vserver/device_cmd.h>
22958 +#include <linux/vserver/inode.h>
22959 +#include <linux/vserver/dlimit.h>
22962 +#ifdef CONFIG_COMPAT
22963 +#define __COMPAT(name, id, data, compat) \
22964 + (compat) ? name ## _x32(id, data) : name(id, data)
22965 +#define __COMPAT_NO_ID(name, data, compat) \
22966 + (compat) ? name ## _x32(data) : name(data)
22968 +#define __COMPAT(name, id, data, compat) \
22970 +#define __COMPAT_NO_ID(name, data, compat) \
22976 +long do_vcmd(uint32_t cmd, uint32_t id,
22977 + struct vx_info *vxi, struct nx_info *nxi,
22978 + void __user *data, int compat)
22982 + case VCMD_get_version:
22983 + return vc_get_version(id);
22984 + case VCMD_get_vci:
22985 + return vc_get_vci(id);
22987 + case VCMD_task_xid:
22988 + return vc_task_xid(id);
22989 + case VCMD_vx_info:
22990 + return vc_vx_info(vxi, data);
22992 + case VCMD_task_nid:
22993 + return vc_task_nid(id);
22994 + case VCMD_nx_info:
22995 + return vc_nx_info(nxi, data);
22997 + case VCMD_task_tag:
22998 + return vc_task_tag(id);
23000 + case VCMD_set_space_v1:
23001 + return vc_set_space_v1(vxi, data);
23002 + /* this is version 2 */
23003 + case VCMD_set_space:
23004 + return vc_set_space(vxi, data);
23006 + case VCMD_get_space_mask_v0:
23007 + return vc_get_space_mask(data, 0);
23008 + /* this is version 1 */
23009 + case VCMD_get_space_mask:
23010 + return vc_get_space_mask(data, 1);
23012 + case VCMD_get_space_default:
23013 + return vc_get_space_mask(data, -1);
23015 + case VCMD_set_umask:
23016 + return vc_set_umask(vxi, data);
23018 + case VCMD_get_umask:
23019 + return vc_get_umask(vxi, data);
23021 + case VCMD_set_wmask:
23022 + return vc_set_wmask(vxi, data);
23024 + case VCMD_get_wmask:
23025 + return vc_get_wmask(vxi, data);
23026 +#ifdef CONFIG_IA32_EMULATION
23027 + case VCMD_get_rlimit:
23028 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23029 + case VCMD_set_rlimit:
23030 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23032 + case VCMD_get_rlimit:
23033 + return vc_get_rlimit(vxi, data);
23034 + case VCMD_set_rlimit:
23035 + return vc_set_rlimit(vxi, data);
23037 + case VCMD_get_rlimit_mask:
23038 + return vc_get_rlimit_mask(id, data);
23039 + case VCMD_reset_hits:
23040 + return vc_reset_hits(vxi, data);
23041 + case VCMD_reset_minmax:
23042 + return vc_reset_minmax(vxi, data);
23044 + case VCMD_get_vhi_name:
23045 + return vc_get_vhi_name(vxi, data);
23046 + case VCMD_set_vhi_name:
23047 + return vc_set_vhi_name(vxi, data);
23049 + case VCMD_ctx_stat:
23050 + return vc_ctx_stat(vxi, data);
23051 + case VCMD_virt_stat:
23052 + return vc_virt_stat(vxi, data);
23053 + case VCMD_sock_stat:
23054 + return vc_sock_stat(vxi, data);
23055 + case VCMD_rlimit_stat:
23056 + return vc_rlimit_stat(vxi, data);
23058 + case VCMD_set_cflags:
23059 + return vc_set_cflags(vxi, data);
23060 + case VCMD_get_cflags:
23061 + return vc_get_cflags(vxi, data);
23063 + /* this is version 1 */
23064 + case VCMD_set_ccaps:
23065 + return vc_set_ccaps(vxi, data);
23066 + /* this is version 1 */
23067 + case VCMD_get_ccaps:
23068 + return vc_get_ccaps(vxi, data);
23069 + case VCMD_set_bcaps:
23070 + return vc_set_bcaps(vxi, data);
23071 + case VCMD_get_bcaps:
23072 + return vc_get_bcaps(vxi, data);
23074 + case VCMD_set_badness:
23075 + return vc_set_badness(vxi, data);
23076 + case VCMD_get_badness:
23077 + return vc_get_badness(vxi, data);
23079 + case VCMD_set_nflags:
23080 + return vc_set_nflags(nxi, data);
23081 + case VCMD_get_nflags:
23082 + return vc_get_nflags(nxi, data);
23084 + case VCMD_set_ncaps:
23085 + return vc_set_ncaps(nxi, data);
23086 + case VCMD_get_ncaps:
23087 + return vc_get_ncaps(nxi, data);
23089 + case VCMD_set_prio_bias:
23090 + return vc_set_prio_bias(vxi, data);
23091 + case VCMD_get_prio_bias:
23092 + return vc_get_prio_bias(vxi, data);
23093 + case VCMD_add_dlimit:
23094 + return __COMPAT(vc_add_dlimit, id, data, compat);
23095 + case VCMD_rem_dlimit:
23096 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23097 + case VCMD_set_dlimit:
23098 + return __COMPAT(vc_set_dlimit, id, data, compat);
23099 + case VCMD_get_dlimit:
23100 + return __COMPAT(vc_get_dlimit, id, data, compat);
23102 + case VCMD_ctx_kill:
23103 + return vc_ctx_kill(vxi, data);
23105 + case VCMD_wait_exit:
23106 + return vc_wait_exit(vxi, data);
23108 + case VCMD_get_iattr:
23109 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23110 + case VCMD_set_iattr:
23111 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23113 + case VCMD_fget_iattr:
23114 + return vc_fget_iattr(id, data);
23115 + case VCMD_fset_iattr:
23116 + return vc_fset_iattr(id, data);
23118 + case VCMD_enter_space_v0:
23119 + return vc_enter_space_v1(vxi, NULL);
23120 + case VCMD_enter_space_v1:
23121 + return vc_enter_space_v1(vxi, data);
23122 + /* this is version 2 */
23123 + case VCMD_enter_space:
23124 + return vc_enter_space(vxi, data);
23126 + case VCMD_ctx_create_v0:
23127 + return vc_ctx_create(id, NULL);
23128 + case VCMD_ctx_create:
23129 + return vc_ctx_create(id, data);
23130 + case VCMD_ctx_migrate_v0:
23131 + return vc_ctx_migrate(vxi, NULL);
23132 + case VCMD_ctx_migrate:
23133 + return vc_ctx_migrate(vxi, data);
23135 + case VCMD_net_create_v0:
23136 + return vc_net_create(id, NULL);
23137 + case VCMD_net_create:
23138 + return vc_net_create(id, data);
23139 + case VCMD_net_migrate:
23140 + return vc_net_migrate(nxi, data);
23142 + case VCMD_tag_migrate:
23143 + return vc_tag_migrate(id);
23145 + case VCMD_net_add:
23146 + return vc_net_add(nxi, data);
23147 + case VCMD_net_remove:
23148 + return vc_net_remove(nxi, data);
23150 + case VCMD_net_add_ipv4_v1:
23151 + return vc_net_add_ipv4_v1(nxi, data);
23152 + /* this is version 2 */
23153 + case VCMD_net_add_ipv4:
23154 + return vc_net_add_ipv4(nxi, data);
23156 + case VCMD_net_rem_ipv4_v1:
23157 + return vc_net_rem_ipv4_v1(nxi, data);
23158 + /* this is version 2 */
23159 + case VCMD_net_rem_ipv4:
23160 + return vc_net_rem_ipv4(nxi, data);
23161 +#ifdef CONFIG_IPV6
23162 + case VCMD_net_add_ipv6:
23163 + return vc_net_add_ipv6(nxi, data);
23164 + case VCMD_net_remove_ipv6:
23165 + return vc_net_remove_ipv6(nxi, data);
23167 +/* case VCMD_add_match_ipv4:
23168 + return vc_add_match_ipv4(nxi, data);
23169 + case VCMD_get_match_ipv4:
23170 + return vc_get_match_ipv4(nxi, data);
23171 +#ifdef CONFIG_IPV6
23172 + case VCMD_add_match_ipv6:
23173 + return vc_add_match_ipv6(nxi, data);
23174 + case VCMD_get_match_ipv6:
23175 + return vc_get_match_ipv6(nxi, data);
23178 +#ifdef CONFIG_VSERVER_DEVICE
23179 + case VCMD_set_mapping:
23180 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23181 + case VCMD_unset_mapping:
23182 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23184 +#ifdef CONFIG_VSERVER_HISTORY
23185 + case VCMD_dump_history:
23186 + return vc_dump_history(id);
23187 + case VCMD_read_history:
23188 + return __COMPAT(vc_read_history, id, data, compat);
23191 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23192 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23198 +#define __VCMD(vcmd, _perm, _args, _flags) \
23199 + case VCMD_ ## vcmd: perm = _perm; \
23200 + args = _args; flags = _flags; break
23203 +#define VCA_NONE 0x00
23204 +#define VCA_VXI 0x01
23205 +#define VCA_NXI 0x02
23207 +#define VCF_NONE 0x00
23208 +#define VCF_INFO 0x01
23209 +#define VCF_ADMIN 0x02
23210 +#define VCF_ARES 0x06 /* includes admin */
23211 +#define VCF_SETUP 0x08
23213 +#define VCF_ZIDOK 0x10 /* zero id okay */
23217 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23220 + int permit = -1, state = 0;
23221 + int perm = -1, args = 0, flags = 0;
23222 + struct vx_info *vxi = NULL;
23223 + struct nx_info *nxi = NULL;
23226 + /* unpriviledged commands */
23227 + __VCMD(get_version, 0, VCA_NONE, 0);
23228 + __VCMD(get_vci, 0, VCA_NONE, 0);
23229 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23230 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23231 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23232 + __VCMD(get_space_default,0, VCA_NONE, 0);
23234 + /* info commands */
23235 + __VCMD(task_xid, 2, VCA_NONE, 0);
23236 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23237 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23238 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23239 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23240 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23241 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23242 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23243 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23244 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23245 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23246 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23248 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23249 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23250 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23251 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23253 + __VCMD(task_nid, 2, VCA_NONE, 0);
23254 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23255 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23256 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23258 + __VCMD(task_tag, 2, VCA_NONE, 0);
23260 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23261 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23262 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23263 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23265 + /* lower admin commands */
23266 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23267 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23268 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23269 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23270 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23271 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23272 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23273 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23275 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23276 + __VCMD(net_create, 5, VCA_NONE, 0);
23277 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23279 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23281 + /* higher admin commands */
23282 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23283 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23284 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23286 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23287 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23288 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23289 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23290 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23291 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23293 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23294 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23295 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23297 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23298 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23299 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23300 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23301 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23302 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23303 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23304 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23305 +#ifdef CONFIG_IPV6
23306 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23307 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23309 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23310 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23311 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23312 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23313 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23315 +#ifdef CONFIG_VSERVER_DEVICE
23316 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23317 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23319 + /* debug level admin commands */
23320 +#ifdef CONFIG_VSERVER_HISTORY
23321 + __VCMD(dump_history, 9, VCA_NONE, 0);
23322 + __VCMD(read_history, 9, VCA_NONE, 0);
23329 + vxdprintk(VXD_CBIT(switch, 0),
23330 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23331 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23332 + VC_VERSION(cmd), id, data, compat,
23333 + perm, args, flags);
23340 + if (!capable(CAP_CONTEXT))
23344 + /* moved here from the individual commands */
23346 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23350 + /* vcmd involves resource management */
23352 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23356 + /* various legacy exceptions */
23358 + /* will go away when spectator is a cap */
23359 + case VCMD_ctx_migrate_v0:
23360 + case VCMD_ctx_migrate:
23362 + current->xid = 1;
23368 + /* will go away when spectator is a cap */
23369 + case VCMD_net_migrate:
23371 + current->nid = 1;
23378 + /* vcmds are fine by default */
23381 + /* admin type vcmds require admin ... */
23382 + if (flags & VCF_ADMIN)
23383 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23385 + /* ... but setup type vcmds override that */
23386 + if (!permit && (flags & VCF_SETUP))
23387 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23395 + if (!id && (flags & VCF_ZIDOK))
23399 + if (args & VCA_VXI) {
23400 + vxi = lookup_vx_info(id);
23404 + if ((flags & VCF_ADMIN) &&
23405 + /* special case kill for shutdown */
23406 + (cmd != VCMD_ctx_kill) &&
23407 + /* can context be administrated? */
23408 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23414 + if (args & VCA_NXI) {
23415 + nxi = lookup_nx_info(id);
23419 + if ((flags & VCF_ADMIN) &&
23420 + /* can context be administrated? */
23421 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23428 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23431 + if ((args & VCA_NXI) && nxi)
23432 + put_nx_info(nxi);
23434 + if ((args & VCA_VXI) && vxi)
23435 + put_vx_info(vxi);
23437 + vxdprintk(VXD_CBIT(switch, 1),
23438 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23439 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23440 + VC_VERSION(cmd), ret, ret, state, permit);
23445 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23447 + return do_vserver(cmd, id, data, 0);
23450 +#ifdef CONFIG_COMPAT
23453 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23455 + return do_vserver(cmd, id, data, 1);
23458 +#endif /* CONFIG_COMPAT */
23459 diff -NurpP --minimal linux-3.2.8/kernel/vserver/sysctl.c linux-3.2.8-vs2.3.2.7/kernel/vserver/sysctl.c
23460 --- linux-3.2.8/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23461 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/sysctl.c 2011-12-05 19:33:02.000000000 +0100
23464 + * kernel/vserver/sysctl.c
23466 + * Virtual Context Support
23468 + * Copyright (C) 2004-2007 Herbert Pötzl
23470 + * V0.01 basic structure
23474 +#include <linux/module.h>
23475 +#include <linux/ctype.h>
23476 +#include <linux/sysctl.h>
23477 +#include <linux/parser.h>
23478 +#include <asm/uaccess.h>
23481 + CTL_DEBUG_ERROR = 0,
23482 + CTL_DEBUG_SWITCH = 1,
23498 +unsigned int vs_debug_switch = 0;
23499 +unsigned int vs_debug_xid = 0;
23500 +unsigned int vs_debug_nid = 0;
23501 +unsigned int vs_debug_tag = 0;
23502 +unsigned int vs_debug_net = 0;
23503 +unsigned int vs_debug_limit = 0;
23504 +unsigned int vs_debug_cres = 0;
23505 +unsigned int vs_debug_dlim = 0;
23506 +unsigned int vs_debug_quota = 0;
23507 +unsigned int vs_debug_cvirt = 0;
23508 +unsigned int vs_debug_space = 0;
23509 +unsigned int vs_debug_perm = 0;
23510 +unsigned int vs_debug_misc = 0;
23513 +static struct ctl_table_header *vserver_table_header;
23514 +static ctl_table vserver_root_table[];
23517 +void vserver_register_sysctl(void)
23519 + if (!vserver_table_header) {
23520 + vserver_table_header = register_sysctl_table(vserver_root_table);
23525 +void vserver_unregister_sysctl(void)
23527 + if (vserver_table_header) {
23528 + unregister_sysctl_table(vserver_table_header);
23529 + vserver_table_header = NULL;
23534 +static int proc_dodebug(ctl_table *table, int write,
23535 + void __user *buffer, size_t *lenp, loff_t *ppos)
23537 + char tmpbuf[20], *p, c;
23538 + unsigned int value;
23539 + size_t left, len;
23541 + if ((*ppos && !write) || !*lenp) {
23549 + if (!access_ok(VERIFY_READ, buffer, left))
23551 + p = (char *)buffer;
23552 + while (left && __get_user(c, p) >= 0 && isspace(c))
23557 + if (left > sizeof(tmpbuf) - 1)
23559 + if (copy_from_user(tmpbuf, p, left))
23561 + tmpbuf[left] = '\0';
23563 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23564 + value = 10 * value + (*p - '0');
23565 + if (*p && !isspace(*p))
23567 + while (left && isspace(*p))
23569 + *(unsigned int *)table->data = value;
23571 + if (!access_ok(VERIFY_WRITE, buffer, left))
23573 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23576 + if (__copy_to_user(buffer, tmpbuf, len))
23578 + if ((left -= len) > 0) {
23579 + if (put_user('\n', (char *)buffer + len))
23593 +#define CTL_ENTRY(ctl, name) \
23595 + .procname = #name, \
23596 + .data = &vs_ ## name, \
23597 + .maxlen = sizeof(int), \
23599 + .proc_handler = &proc_dodebug, \
23600 + .extra1 = &zero, \
23601 + .extra2 = &zero, \
23604 +static ctl_table vserver_debug_table[] = {
23605 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23606 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23607 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23608 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23609 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23610 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23611 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23612 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23613 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23614 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23615 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23616 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23617 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23621 +static ctl_table vserver_root_table[] = {
23623 + .procname = "vserver",
23625 + .child = vserver_debug_table
23631 +static match_table_t tokens = {
23632 + { CTL_DEBUG_SWITCH, "switch=%x" },
23633 + { CTL_DEBUG_XID, "xid=%x" },
23634 + { CTL_DEBUG_NID, "nid=%x" },
23635 + { CTL_DEBUG_TAG, "tag=%x" },
23636 + { CTL_DEBUG_NET, "net=%x" },
23637 + { CTL_DEBUG_LIMIT, "limit=%x" },
23638 + { CTL_DEBUG_CRES, "cres=%x" },
23639 + { CTL_DEBUG_DLIM, "dlim=%x" },
23640 + { CTL_DEBUG_QUOTA, "quota=%x" },
23641 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23642 + { CTL_DEBUG_SPACE, "space=%x" },
23643 + { CTL_DEBUG_PERM, "perm=%x" },
23644 + { CTL_DEBUG_MISC, "misc=%x" },
23645 + { CTL_DEBUG_ERROR, NULL }
23648 +#define HANDLE_CASE(id, name, val) \
23649 + case CTL_DEBUG_ ## id: \
23650 + vs_debug_ ## name = val; \
23651 + printk("vs_debug_" #name "=0x%x\n", val); \
23655 +static int __init vs_debug_setup(char *str)
23660 + printk("vs_debug_setup(%s)\n", str);
23661 + while ((p = strsep(&str, ",")) != NULL) {
23662 + substring_t args[MAX_OPT_ARGS];
23663 + unsigned int value;
23668 + token = match_token(p, tokens, args);
23669 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23672 + HANDLE_CASE(SWITCH, switch, value);
23673 + HANDLE_CASE(XID, xid, value);
23674 + HANDLE_CASE(NID, nid, value);
23675 + HANDLE_CASE(TAG, tag, value);
23676 + HANDLE_CASE(NET, net, value);
23677 + HANDLE_CASE(LIMIT, limit, value);
23678 + HANDLE_CASE(CRES, cres, value);
23679 + HANDLE_CASE(DLIM, dlim, value);
23680 + HANDLE_CASE(QUOTA, quota, value);
23681 + HANDLE_CASE(CVIRT, cvirt, value);
23682 + HANDLE_CASE(SPACE, space, value);
23683 + HANDLE_CASE(PERM, perm, value);
23684 + HANDLE_CASE(MISC, misc, value);
23693 +__setup("vsdebug=", vs_debug_setup);
23697 +EXPORT_SYMBOL_GPL(vs_debug_switch);
23698 +EXPORT_SYMBOL_GPL(vs_debug_xid);
23699 +EXPORT_SYMBOL_GPL(vs_debug_nid);
23700 +EXPORT_SYMBOL_GPL(vs_debug_net);
23701 +EXPORT_SYMBOL_GPL(vs_debug_limit);
23702 +EXPORT_SYMBOL_GPL(vs_debug_cres);
23703 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
23704 +EXPORT_SYMBOL_GPL(vs_debug_quota);
23705 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
23706 +EXPORT_SYMBOL_GPL(vs_debug_space);
23707 +EXPORT_SYMBOL_GPL(vs_debug_perm);
23708 +EXPORT_SYMBOL_GPL(vs_debug_misc);
23710 diff -NurpP --minimal linux-3.2.8/kernel/vserver/tag.c linux-3.2.8-vs2.3.2.7/kernel/vserver/tag.c
23711 --- linux-3.2.8/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
23712 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/tag.c 2011-12-05 19:33:02.000000000 +0100
23715 + * linux/kernel/vserver/tag.c
23717 + * Virtual Server: Shallow Tag Space
23719 + * Copyright (C) 2007 Herbert Pötzl
23721 + * V0.01 basic implementation
23725 +#include <linux/sched.h>
23726 +#include <linux/vserver/debug.h>
23727 +#include <linux/vs_pid.h>
23728 +#include <linux/vs_tag.h>
23730 +#include <linux/vserver/tag_cmd.h>
23733 +int dx_migrate_task(struct task_struct *p, tag_t tag)
23738 + vxdprintk(VXD_CBIT(tag, 5),
23739 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23745 + vxdprintk(VXD_CBIT(tag, 5),
23746 + "moved task %p into [#%d]", p, tag);
23750 +/* vserver syscall commands below here */
23752 +/* taks xid and vx_info functions */
23755 +int vc_task_tag(uint32_t id)
23760 + struct task_struct *tsk;
23762 + tsk = find_task_by_real_pid(id);
23763 + tag = (tsk) ? tsk->tag : -ESRCH;
23764 + rcu_read_unlock();
23766 + tag = dx_current_tag();
23771 +int vc_tag_migrate(uint32_t tag)
23773 + return dx_migrate_task(current, tag & 0xFFFF);
23777 diff -NurpP --minimal linux-3.2.8/kernel/vserver/vci_config.h linux-3.2.8-vs2.3.2.7/kernel/vserver/vci_config.h
23778 --- linux-3.2.8/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
23779 +++ linux-3.2.8-vs2.3.2.7/kernel/vserver/vci_config.h 2011-12-05 19:33:02.000000000 +0100
23782 +/* interface version */
23784 +#define VCI_VERSION 0x00020308
23788 + VCI_KCBIT_NO_DYNAMIC = 0,
23790 + VCI_KCBIT_PROC_SECURE = 4,
23791 + /* VCI_KCBIT_HARDCPU = 5, */
23792 + /* VCI_KCBIT_IDLELIMIT = 6, */
23793 + /* VCI_KCBIT_IDLETIME = 7, */
23795 + VCI_KCBIT_COWBL = 8,
23796 + VCI_KCBIT_FULLCOWBL = 9,
23797 + VCI_KCBIT_SPACES = 10,
23798 + VCI_KCBIT_NETV2 = 11,
23799 + VCI_KCBIT_MEMCG = 12,
23801 + VCI_KCBIT_DEBUG = 16,
23802 + VCI_KCBIT_HISTORY = 20,
23803 + VCI_KCBIT_TAGGED = 24,
23804 + VCI_KCBIT_PPTAG = 28,
23806 + VCI_KCBIT_MORE = 31,
23810 +static inline uint32_t vci_kernel_config(void)
23813 + (1 << VCI_KCBIT_NO_DYNAMIC) |
23815 + /* configured features */
23816 +#ifdef CONFIG_VSERVER_PROC_SECURE
23817 + (1 << VCI_KCBIT_PROC_SECURE) |
23819 +#ifdef CONFIG_VSERVER_COWBL
23820 + (1 << VCI_KCBIT_COWBL) |
23821 + (1 << VCI_KCBIT_FULLCOWBL) |
23823 + (1 << VCI_KCBIT_SPACES) |
23824 + (1 << VCI_KCBIT_NETV2) |
23825 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
23826 + (1 << VCI_KCBIT_MEMCG) |
23829 + /* debug options */
23830 +#ifdef CONFIG_VSERVER_DEBUG
23831 + (1 << VCI_KCBIT_DEBUG) |
23833 +#ifdef CONFIG_VSERVER_HISTORY
23834 + (1 << VCI_KCBIT_HISTORY) |
23837 + /* inode context tagging */
23838 +#if defined(CONFIG_TAGGING_NONE)
23839 + (0 << VCI_KCBIT_TAGGED) |
23840 +#elif defined(CONFIG_TAGGING_UID16)
23841 + (1 << VCI_KCBIT_TAGGED) |
23842 +#elif defined(CONFIG_TAGGING_GID16)
23843 + (2 << VCI_KCBIT_TAGGED) |
23844 +#elif defined(CONFIG_TAGGING_ID24)
23845 + (3 << VCI_KCBIT_TAGGED) |
23846 +#elif defined(CONFIG_TAGGING_INTERN)
23847 + (4 << VCI_KCBIT_TAGGED) |
23848 +#elif defined(CONFIG_TAGGING_RUNTIME)
23849 + (5 << VCI_KCBIT_TAGGED) |
23851 + (7 << VCI_KCBIT_TAGGED) |
23853 + (1 << VCI_KCBIT_PPTAG) |
23857 diff -NurpP --minimal linux-3.2.8/mm/memcontrol.c linux-3.2.8-vs2.3.2.7/mm/memcontrol.c
23858 --- linux-3.2.8/mm/memcontrol.c 2012-02-28 05:53:29.000000000 +0100
23859 +++ linux-3.2.8-vs2.3.2.7/mm/memcontrol.c 2012-01-26 08:52:10.000000000 +0100
23860 @@ -766,6 +766,31 @@ struct mem_cgroup *mem_cgroup_from_task(
23861 struct mem_cgroup, css);
23864 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
23866 + return res_counter_read_u64(&mem->res, member);
23869 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
23871 + return res_counter_read_u64(&mem->memsw, member);
23874 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
23876 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
23879 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
23881 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
23884 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
23886 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
23889 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
23891 struct mem_cgroup *memcg = NULL;
23892 diff -NurpP --minimal linux-3.2.8/mm/oom_kill.c linux-3.2.8-vs2.3.2.7/mm/oom_kill.c
23893 --- linux-3.2.8/mm/oom_kill.c 2012-01-09 16:15:00.000000000 +0100
23894 +++ linux-3.2.8-vs2.3.2.7/mm/oom_kill.c 2012-01-09 16:19:31.000000000 +0100
23896 #include <linux/security.h>
23897 #include <linux/ptrace.h>
23898 #include <linux/freezer.h>
23899 +#include <linux/reboot.h>
23900 +#include <linux/vs_context.h>
23902 int sysctl_panic_on_oom;
23903 int sysctl_oom_kill_allocating_task;
23904 @@ -148,11 +150,18 @@ struct task_struct *find_lock_task_mm(st
23905 static bool oom_unkillable_task(struct task_struct *p,
23906 const struct mem_cgroup *mem, const nodemask_t *nodemask)
23908 - if (is_global_init(p))
23909 + unsigned xid = vx_current_xid();
23911 + /* skip the init task, global and per guest */
23912 + if (task_is_init(p))
23914 if (p->flags & PF_KTHREAD)
23917 + /* skip other guest and host processes if oom in guest */
23918 + if (xid && vx_task_xid(p) != xid)
23921 /* When mem_cgroup_out_of_memory() and p is not member of the group */
23922 if (mem && !task_in_mem_cgroup(p, mem))
23924 @@ -440,8 +449,8 @@ static int oom_kill_task(struct task_str
23925 /* mm cannot be safely dereferenced after task_unlock(p) */
23928 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23929 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
23930 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23931 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
23932 K(get_mm_counter(p->mm, MM_ANONPAGES)),
23933 K(get_mm_counter(p->mm, MM_FILEPAGES)));
23935 @@ -499,8 +508,8 @@ static int oom_kill_process(struct task_
23939 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
23940 - message, task_pid_nr(p), p->comm, points);
23941 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
23942 + message, task_pid_nr(p), p->xid, p->comm, points);
23946 @@ -601,6 +610,8 @@ int unregister_oom_notifier(struct notif
23948 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
23950 +long vs_oom_action(unsigned int);
23953 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
23954 * if a parallel OOM killing is already taking place that includes a zone in
23955 @@ -759,7 +770,12 @@ retry:
23957 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
23958 read_unlock(&tasklist_lock);
23959 - panic("Out of memory and no killable processes...\n");
23961 + /* avoid panic for guest OOM */
23962 + if (current->xid)
23963 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
23965 + panic("Out of memory and no killable processes...\n");
23968 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
23969 diff -NurpP --minimal linux-3.2.8/mm/page_alloc.c linux-3.2.8-vs2.3.2.7/mm/page_alloc.c
23970 --- linux-3.2.8/mm/page_alloc.c 2012-02-28 05:53:29.000000000 +0100
23971 +++ linux-3.2.8-vs2.3.2.7/mm/page_alloc.c 2012-01-26 08:52:10.000000000 +0100
23973 #include <linux/ftrace_event.h>
23974 #include <linux/memcontrol.h>
23975 #include <linux/prefetch.h>
23976 +#include <linux/vs_base.h>
23977 +#include <linux/vs_limit.h>
23979 #include <asm/tlbflush.h>
23980 #include <asm/div64.h>
23981 @@ -2491,6 +2493,9 @@ void si_meminfo(struct sysinfo *val)
23982 val->totalhigh = totalhigh_pages;
23983 val->freehigh = nr_free_highpages();
23984 val->mem_unit = PAGE_SIZE;
23986 + if (vx_flags(VXF_VIRT_MEM, 0))
23987 + vx_vsi_meminfo(val);
23990 EXPORT_SYMBOL(si_meminfo);
23991 @@ -2511,6 +2516,9 @@ void si_meminfo_node(struct sysinfo *val
23994 val->mem_unit = PAGE_SIZE;
23996 + if (vx_flags(VXF_VIRT_MEM, 0))
23997 + vx_vsi_meminfo(val);
24001 diff -NurpP --minimal linux-3.2.8/mm/pgtable-generic.c linux-3.2.8-vs2.3.2.7/mm/pgtable-generic.c
24002 --- linux-3.2.8/mm/pgtable-generic.c 2011-03-15 18:07:42.000000000 +0100
24003 +++ linux-3.2.8-vs2.3.2.7/mm/pgtable-generic.c 2011-12-05 19:33:02.000000000 +0100
24005 * Copyright (C) 2010 Linus Torvalds
24008 +#include <linux/mm.h>
24010 #include <linux/pagemap.h>
24011 #include <asm/tlb.h>
24012 #include <asm-generic/pgtable.h>
24013 diff -NurpP --minimal linux-3.2.8/mm/shmem.c linux-3.2.8-vs2.3.2.7/mm/shmem.c
24014 --- linux-3.2.8/mm/shmem.c 2012-02-28 05:53:29.000000000 +0100
24015 +++ linux-3.2.8-vs2.3.2.7/mm/shmem.c 2012-01-26 08:52:10.000000000 +0100
24016 @@ -1460,7 +1460,7 @@ static int shmem_statfs(struct dentry *d
24018 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24020 - buf->f_type = TMPFS_MAGIC;
24021 + buf->f_type = TMPFS_SUPER_MAGIC;
24022 buf->f_bsize = PAGE_CACHE_SIZE;
24023 buf->f_namelen = NAME_MAX;
24024 if (sbinfo->max_blocks) {
24025 @@ -2217,7 +2217,7 @@ int shmem_fill_super(struct super_block
24026 sb->s_maxbytes = MAX_LFS_FILESIZE;
24027 sb->s_blocksize = PAGE_CACHE_SIZE;
24028 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24029 - sb->s_magic = TMPFS_MAGIC;
24030 + sb->s_magic = TMPFS_SUPER_MAGIC;
24031 sb->s_op = &shmem_ops;
24032 sb->s_time_gran = 1;
24033 #ifdef CONFIG_TMPFS_XATTR
24034 diff -NurpP --minimal linux-3.2.8/mm/slab.c linux-3.2.8-vs2.3.2.7/mm/slab.c
24035 --- linux-3.2.8/mm/slab.c 2012-01-09 16:15:00.000000000 +0100
24036 +++ linux-3.2.8-vs2.3.2.7/mm/slab.c 2011-12-15 01:11:34.000000000 +0100
24037 @@ -411,6 +411,8 @@ static void kmem_list3_init(struct kmem_
24038 #define STATS_INC_FREEMISS(x) do { } while (0)
24041 +#include "slab_vs.h"
24046 @@ -3397,6 +3399,7 @@ retry:
24048 obj = slab_get_obj(cachep, slabp, nodeid);
24049 check_slabp(cachep, slabp);
24050 + vx_slab_alloc(cachep, flags);
24051 l3->free_objects--;
24052 /* move slabp to correct slabp list: */
24053 list_del(&slabp->list);
24054 @@ -3474,6 +3477,7 @@ __cache_alloc_node(struct kmem_cache *ca
24055 /* ___cache_alloc_node can fall back to other nodes */
24056 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24058 + vx_slab_alloc(cachep, flags);
24059 local_irq_restore(save_flags);
24060 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24061 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24062 @@ -3661,6 +3665,7 @@ static inline void __cache_free(struct k
24064 kmemleak_free_recursive(objp, cachep->flags);
24065 objp = cache_free_debugcheck(cachep, objp, caller);
24066 + vx_slab_free(cachep);
24068 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24070 diff -NurpP --minimal linux-3.2.8/mm/slab_vs.h linux-3.2.8-vs2.3.2.7/mm/slab_vs.h
24071 --- linux-3.2.8/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24072 +++ linux-3.2.8-vs2.3.2.7/mm/slab_vs.h 2011-12-05 19:33:02.000000000 +0100
24075 +#include <linux/vserver/context.h>
24077 +#include <linux/vs_context.h>
24080 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24082 + int what = gfp_zone(cachep->gfpflags);
24083 + struct vx_info *vxi = current_vx_info();
24088 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24092 +void vx_slab_free(struct kmem_cache *cachep)
24094 + int what = gfp_zone(cachep->gfpflags);
24095 + struct vx_info *vxi = current_vx_info();
24100 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24103 diff -NurpP --minimal linux-3.2.8/mm/swapfile.c linux-3.2.8-vs2.3.2.7/mm/swapfile.c
24104 --- linux-3.2.8/mm/swapfile.c 2012-01-09 16:15:00.000000000 +0100
24105 +++ linux-3.2.8-vs2.3.2.7/mm/swapfile.c 2011-12-15 01:52:28.000000000 +0100
24107 #include <asm/tlbflush.h>
24108 #include <linux/swapops.h>
24109 #include <linux/page_cgroup.h>
24110 +#include <linux/vs_base.h>
24112 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24114 @@ -1753,6 +1754,16 @@ static int swap_show(struct seq_file *sw
24116 if (si == SEQ_START_TOKEN) {
24117 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24118 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24119 + struct sysinfo si;
24121 + vx_vsi_swapinfo(&si);
24122 + if (si.totalswap < (1 << 10))
24124 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24125 + "hdv0", "partition", si.totalswap >> 10,
24126 + (si.totalswap - si.freeswap) >> 10, -1);
24131 @@ -2176,6 +2187,8 @@ void si_swapinfo(struct sysinfo *val)
24132 val->freeswap = nr_swap_pages + nr_to_be_unused;
24133 val->totalswap = total_swap_pages + nr_to_be_unused;
24134 spin_unlock(&swap_lock);
24135 + if (vx_flags(VXF_VIRT_MEM, 0))
24136 + vx_vsi_swapinfo(val);
24140 diff -NurpP --minimal linux-3.2.8/net/bridge/br_multicast.c linux-3.2.8-vs2.3.2.7/net/bridge/br_multicast.c
24141 --- linux-3.2.8/net/bridge/br_multicast.c 2012-01-09 16:15:03.000000000 +0100
24142 +++ linux-3.2.8-vs2.3.2.7/net/bridge/br_multicast.c 2011-12-05 19:33:02.000000000 +0100
24143 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
24144 ip6h->hop_limit = 1;
24145 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24146 ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24148 + &ip6h->saddr, NULL);
24149 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
24151 hopopt = (u8 *)(ip6h + 1);
24152 diff -NurpP --minimal linux-3.2.8/net/core/dev.c linux-3.2.8-vs2.3.2.7/net/core/dev.c
24153 --- linux-3.2.8/net/core/dev.c 2012-01-09 16:15:03.000000000 +0100
24154 +++ linux-3.2.8-vs2.3.2.7/net/core/dev.c 2011-12-15 01:11:36.000000000 +0100
24155 @@ -127,6 +127,7 @@
24156 #include <linux/in.h>
24157 #include <linux/jhash.h>
24158 #include <linux/random.h>
24159 +#include <linux/vs_inet.h>
24160 #include <trace/events/napi.h>
24161 #include <trace/events/net.h>
24162 #include <trace/events/skb.h>
24163 @@ -623,7 +624,8 @@ struct net_device *__dev_get_by_name(str
24164 struct hlist_head *head = dev_name_hash(net, name);
24166 hlist_for_each_entry(dev, p, head, name_hlist)
24167 - if (!strncmp(dev->name, name, IFNAMSIZ))
24168 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24169 + nx_dev_visible(current_nx_info(), dev))
24173 @@ -649,7 +651,8 @@ struct net_device *dev_get_by_name_rcu(s
24174 struct hlist_head *head = dev_name_hash(net, name);
24176 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24177 - if (!strncmp(dev->name, name, IFNAMSIZ))
24178 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24179 + nx_dev_visible(current_nx_info(), dev))
24183 @@ -700,7 +703,8 @@ struct net_device *__dev_get_by_index(st
24184 struct hlist_head *head = dev_index_hash(net, ifindex);
24186 hlist_for_each_entry(dev, p, head, index_hlist)
24187 - if (dev->ifindex == ifindex)
24188 + if ((dev->ifindex == ifindex) &&
24189 + nx_dev_visible(current_nx_info(), dev))
24193 @@ -718,7 +722,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24194 * about locking. The caller must hold RCU lock.
24197 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24198 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24200 struct hlist_node *p;
24201 struct net_device *dev;
24202 @@ -730,6 +734,16 @@ struct net_device *dev_get_by_index_rcu(
24206 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24208 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24210 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24212 + if (nx_dev_visible(current_nx_info(), dev))
24216 EXPORT_SYMBOL(dev_get_by_index_rcu);
24219 @@ -778,7 +792,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24221 for_each_netdev_rcu(net, dev)
24222 if (dev->type == type &&
24223 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24224 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24225 + nx_dev_visible(current_nx_info(), dev))
24229 @@ -790,9 +805,11 @@ struct net_device *__dev_getfirstbyhwtyp
24230 struct net_device *dev;
24233 - for_each_netdev(net, dev)
24234 - if (dev->type == type)
24235 + for_each_netdev(net, dev) {
24236 + if ((dev->type == type) &&
24237 + nx_dev_visible(current_nx_info(), dev))
24243 @@ -910,6 +927,8 @@ static int __dev_alloc_name(struct net *
24245 if (i < 0 || i >= max_netdevices)
24247 + if (!nx_dev_visible(current_nx_info(), d))
24250 /* avoid cases where sscanf is not exact inverse of printf */
24251 snprintf(buf, IFNAMSIZ, name, i);
24252 @@ -4067,6 +4086,8 @@ static int dev_ifconf(struct net *net, c
24255 for_each_netdev(net, dev) {
24256 + if (!nx_dev_visible(current_nx_info(), dev))
24258 for (i = 0; i < NPROTO; i++) {
24259 if (gifconf_list[i]) {
24261 @@ -4195,6 +4216,10 @@ static void dev_seq_printf_stats(struct
24262 struct rtnl_link_stats64 temp;
24263 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24265 + /* device visible inside network context? */
24266 + if (!nx_dev_visible(current_nx_info(), dev))
24269 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24270 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24271 dev->name, stats->rx_bytes, stats->rx_packets,
24272 diff -NurpP --minimal linux-3.2.8/net/core/rtnetlink.c linux-3.2.8-vs2.3.2.7/net/core/rtnetlink.c
24273 --- linux-3.2.8/net/core/rtnetlink.c 2012-01-09 16:15:03.000000000 +0100
24274 +++ linux-3.2.8-vs2.3.2.7/net/core/rtnetlink.c 2011-12-05 19:33:02.000000000 +0100
24275 @@ -1058,6 +1058,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24276 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
24279 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24281 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24282 NETLINK_CB(cb->skb).pid,
24283 cb->nlh->nlmsg_seq, 0,
24284 @@ -1907,6 +1909,9 @@ void rtmsg_ifinfo(int type, struct net_d
24285 int err = -ENOBUFS;
24286 size_t if_info_size;
24288 + if (!nx_dev_visible(current_nx_info(), dev))
24291 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev)), GFP_KERNEL);
24294 diff -NurpP --minimal linux-3.2.8/net/core/sock.c linux-3.2.8-vs2.3.2.7/net/core/sock.c
24295 --- linux-3.2.8/net/core/sock.c 2012-01-09 16:15:03.000000000 +0100
24296 +++ linux-3.2.8-vs2.3.2.7/net/core/sock.c 2012-01-09 16:19:31.000000000 +0100
24297 @@ -127,6 +127,10 @@
24298 #include <net/cls_cgroup.h>
24300 #include <linux/filter.h>
24301 +#include <linux/vs_socket.h>
24302 +#include <linux/vs_limit.h>
24303 +#include <linux/vs_context.h>
24304 +#include <linux/vs_network.h>
24306 #include <trace/events/sock.h>
24308 @@ -1066,6 +1070,8 @@ static struct sock *sk_prot_alloc(struct
24310 sk_tx_queue_clear(sk);
24312 + sock_vx_init(sk);
24313 + sock_nx_init(sk);
24317 @@ -1165,6 +1171,11 @@ static void __sk_free(struct sock *sk)
24318 put_cred(sk->sk_peer_cred);
24319 put_pid(sk->sk_peer_pid);
24320 put_net(sock_net(sk));
24322 + clr_vx_info(&sk->sk_vx_info);
24324 + clr_nx_info(&sk->sk_nx_info);
24326 sk_prot_free(sk->sk_prot_creator, sk);
24329 @@ -1212,6 +1223,8 @@ struct sock *sk_clone(const struct sock
24332 get_net(sock_net(newsk));
24333 + sock_vx_init(newsk);
24334 + sock_nx_init(newsk);
24335 sk_node_init(&newsk->sk_node);
24336 sock_lock_init(newsk);
24337 bh_lock_sock(newsk);
24338 @@ -1268,6 +1281,12 @@ struct sock *sk_clone(const struct sock
24340 atomic_set(&newsk->sk_refcnt, 2);
24342 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24343 + newsk->sk_xid = sk->sk_xid;
24344 + vx_sock_inc(newsk);
24345 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24346 + newsk->sk_nid = sk->sk_nid;
24349 * Increment the counter in the same struct proto as the master
24350 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24351 @@ -2014,6 +2033,12 @@ void sock_init_data(struct socket *sock,
24353 sk->sk_stamp = ktime_set(-1L, 0);
24355 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24356 + sk->sk_xid = vx_current_xid();
24358 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24359 + sk->sk_nid = nx_current_nid();
24362 * Before updating sk_refcnt, we must commit prior changes to memory
24363 * (Documentation/RCU/rculist_nulls.txt for details)
24364 diff -NurpP --minimal linux-3.2.8/net/ipv4/af_inet.c linux-3.2.8-vs2.3.2.7/net/ipv4/af_inet.c
24365 --- linux-3.2.8/net/ipv4/af_inet.c 2012-01-09 16:15:03.000000000 +0100
24366 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/af_inet.c 2012-02-15 03:03:53.000000000 +0100
24367 @@ -117,6 +117,7 @@
24368 #ifdef CONFIG_IP_MROUTE
24369 #include <linux/mroute.h>
24371 +#include <linux/vs_limit.h>
24374 /* The inetsw table contains everything that inet_create needs to
24375 @@ -326,9 +327,13 @@ lookup_protocol:
24379 + if ((protocol == IPPROTO_ICMP) &&
24380 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24383 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24384 goto out_rcu_unlock;
24387 err = -EAFNOSUPPORT;
24388 if (!inet_netns_ok(net, protocol))
24389 goto out_rcu_unlock;
24390 @@ -452,6 +457,7 @@ int inet_bind(struct socket *sock, struc
24391 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24392 struct sock *sk = sock->sk;
24393 struct inet_sock *inet = inet_sk(sk);
24394 + struct nx_v4_sock_addr nsa;
24395 unsigned short snum;
24398 @@ -475,7 +481,11 @@ int inet_bind(struct socket *sock, struc
24402 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24403 + err = v4_map_sock_addr(inet, addr, &nsa);
24407 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24409 /* Not specified by any standard per-se, however it breaks too
24410 * many applications when removed. It is unfortunate since
24411 @@ -487,7 +497,7 @@ int inet_bind(struct socket *sock, struc
24412 err = -EADDRNOTAVAIL;
24413 if (!sysctl_ip_nonlocal_bind &&
24414 !(inet->freebind || inet->transparent) &&
24415 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24416 + nsa.saddr != htonl(INADDR_ANY) &&
24417 chk_addr_ret != RTN_LOCAL &&
24418 chk_addr_ret != RTN_MULTICAST &&
24419 chk_addr_ret != RTN_BROADCAST)
24420 @@ -512,7 +522,7 @@ int inet_bind(struct socket *sock, struc
24421 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24422 goto out_release_sock;
24424 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24425 + v4_set_sock_addr(inet, &nsa);
24426 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24427 inet->inet_saddr = 0; /* Use device */
24429 @@ -715,11 +725,13 @@ int inet_getname(struct socket *sock, st
24432 sin->sin_port = inet->inet_dport;
24433 - sin->sin_addr.s_addr = inet->inet_daddr;
24434 + sin->sin_addr.s_addr =
24435 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24437 __be32 addr = inet->inet_rcv_saddr;
24439 addr = inet->inet_saddr;
24440 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24441 sin->sin_port = inet->inet_sport;
24442 sin->sin_addr.s_addr = addr;
24444 diff -NurpP --minimal linux-3.2.8/net/ipv4/arp.c linux-3.2.8-vs2.3.2.7/net/ipv4/arp.c
24445 --- linux-3.2.8/net/ipv4/arp.c 2011-10-24 18:45:34.000000000 +0200
24446 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/arp.c 2012-02-07 03:13:38.000000000 +0100
24447 @@ -1332,6 +1332,7 @@ static void arp_format_neigh_entry(struc
24448 struct net_device *dev = n->dev;
24449 int hatype = dev->type;
24451 + /* FIXME: check for network context */
24452 read_lock(&n->lock);
24453 /* Convert hardware address to XX:XX:XX:XX ... form. */
24454 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
24455 @@ -1363,6 +1364,7 @@ static void arp_format_pneigh_entry(stru
24456 int hatype = dev ? dev->type : 0;
24459 + /* FIXME: check for network context */
24460 sprintf(tbuf, "%pI4", n->key);
24461 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24462 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24463 diff -NurpP --minimal linux-3.2.8/net/ipv4/devinet.c linux-3.2.8-vs2.3.2.7/net/ipv4/devinet.c
24464 --- linux-3.2.8/net/ipv4/devinet.c 2012-02-28 05:53:29.000000000 +0100
24465 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/devinet.c 2012-02-07 03:14:01.000000000 +0100
24466 @@ -518,6 +518,7 @@ struct in_device *inetdev_by_index(struc
24468 EXPORT_SYMBOL(inetdev_by_index);
24471 /* Called only from RTNL semaphored context. No locks. */
24473 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24474 @@ -759,6 +760,8 @@ int devinet_ioctl(struct net *net, unsig
24476 in_dev = __in_dev_get_rtnl(dev);
24478 + struct nx_info *nxi = current_nx_info();
24480 if (tryaddrmatch) {
24481 /* Matthias Andree */
24482 /* compare label and address (4.4BSD style) */
24483 @@ -767,6 +770,8 @@ int devinet_ioctl(struct net *net, unsig
24484 This is checked above. */
24485 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24486 ifap = &ifa->ifa_next) {
24487 + if (!nx_v4_ifa_visible(nxi, ifa))
24489 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24490 sin_orig.sin_addr.s_addr ==
24492 @@ -779,9 +784,12 @@ int devinet_ioctl(struct net *net, unsig
24493 comparing just the label */
24495 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24496 - ifap = &ifa->ifa_next)
24497 + ifap = &ifa->ifa_next) {
24498 + if (!nx_v4_ifa_visible(nxi, ifa))
24500 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24506 @@ -934,6 +942,8 @@ static int inet_gifconf(struct net_devic
24509 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24510 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24513 done += sizeof(ifr);
24515 @@ -1294,6 +1304,7 @@ static int inet_dump_ifaddr(struct sk_bu
24516 struct net_device *dev;
24517 struct in_device *in_dev;
24518 struct in_ifaddr *ifa;
24519 + struct sock *sk = skb->sk;
24520 struct hlist_head *head;
24521 struct hlist_node *node;
24523 @@ -1316,6 +1327,8 @@ static int inet_dump_ifaddr(struct sk_bu
24525 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24526 ifa = ifa->ifa_next, ip_idx++) {
24527 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24529 if (ip_idx < s_ip_idx)
24531 if (inet_fill_ifaddr(skb, ifa,
24532 diff -NurpP --minimal linux-3.2.8/net/ipv4/fib_trie.c linux-3.2.8-vs2.3.2.7/net/ipv4/fib_trie.c
24533 --- linux-3.2.8/net/ipv4/fib_trie.c 2012-02-28 05:53:29.000000000 +0100
24534 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/fib_trie.c 2012-02-07 03:14:01.000000000 +0100
24535 @@ -2555,6 +2555,7 @@ static int fib_route_seq_show(struct seq
24536 || fa->fa_type == RTN_MULTICAST)
24539 + /* FIXME: check for network context? */
24542 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24543 diff -NurpP --minimal linux-3.2.8/net/ipv4/inet_connection_sock.c linux-3.2.8-vs2.3.2.7/net/ipv4/inet_connection_sock.c
24544 --- linux-3.2.8/net/ipv4/inet_connection_sock.c 2011-07-22 11:18:13.000000000 +0200
24545 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/inet_connection_sock.c 2012-02-07 03:13:38.000000000 +0100
24546 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
24548 EXPORT_SYMBOL(inet_get_local_port_range);
24550 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24552 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24553 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24555 + if (inet_v6_ipv6only(sk2))
24558 + if (sk1_rcv_saddr &&
24560 + sk1_rcv_saddr == sk2_rcv_saddr)
24563 + if (sk1_rcv_saddr &&
24564 + !sk2_rcv_saddr &&
24565 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24568 + if (sk2_rcv_saddr &&
24569 + !sk1_rcv_saddr &&
24570 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24573 + if (!sk1_rcv_saddr &&
24574 + !sk2_rcv_saddr &&
24575 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24581 int inet_csk_bind_conflict(const struct sock *sk,
24582 const struct inet_bind_bucket *tb)
24584 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
24585 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
24586 if (!reuse || !sk2->sk_reuse ||
24587 sk2->sk_state == TCP_LISTEN) {
24588 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24589 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24590 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24591 + if (ipv4_rcv_saddr_equal(sk, sk2))
24595 diff -NurpP --minimal linux-3.2.8/net/ipv4/inet_diag.c linux-3.2.8-vs2.3.2.7/net/ipv4/inet_diag.c
24596 --- linux-3.2.8/net/ipv4/inet_diag.c 2012-01-09 16:15:03.000000000 +0100
24597 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/inet_diag.c 2012-02-15 03:03:53.000000000 +0100
24599 #include <linux/stddef.h>
24601 #include <linux/inet_diag.h>
24602 +#include <linux/vs_network.h>
24603 +#include <linux/vs_inet.h>
24605 static const struct inet_diag_handler **inet_diag_table;
24607 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
24609 r->id.idiag_sport = inet->inet_sport;
24610 r->id.idiag_dport = inet->inet_dport;
24611 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24612 - r->id.idiag_dst[0] = inet->inet_daddr;
24613 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24614 + inet->inet_rcv_saddr);
24615 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24616 + inet->inet_daddr);
24618 /* IPv6 dual-stack sockets use inet->tos for IPv4 connections,
24619 * hence this needs to be included regardless of socket family.
24620 @@ -214,8 +218,8 @@ static int inet_twsk_diag_fill(struct in
24621 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
24622 r->id.idiag_sport = tw->tw_sport;
24623 r->id.idiag_dport = tw->tw_dport;
24624 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24625 - r->id.idiag_dst[0] = tw->tw_daddr;
24626 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24627 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24628 r->idiag_state = tw->tw_substate;
24629 r->idiag_timer = 3;
24630 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
24631 @@ -272,6 +276,7 @@ static int inet_diag_get_exact(struct sk
24634 if (req->idiag_family == AF_INET) {
24635 + /* TODO: lback */
24636 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
24637 req->id.idiag_dport, req->id.idiag_src[0],
24638 req->id.idiag_sport, req->id.idiag_if);
24639 @@ -514,6 +519,7 @@ static int inet_csk_diag_dump(struct soc
24643 + /* TODO: lback */
24644 entry.saddr = &inet->inet_rcv_saddr;
24645 entry.daddr = &inet->inet_daddr;
24647 @@ -552,6 +558,7 @@ static int inet_twsk_diag_dump(struct in
24651 + /* TODO: lback */
24652 entry.saddr = &tw->tw_rcv_saddr;
24653 entry.daddr = &tw->tw_daddr;
24655 @@ -598,8 +605,8 @@ static int inet_diag_fill_req(struct sk_
24657 r->id.idiag_sport = inet->inet_sport;
24658 r->id.idiag_dport = ireq->rmt_port;
24659 - r->id.idiag_src[0] = ireq->loc_addr;
24660 - r->id.idiag_dst[0] = ireq->rmt_addr;
24661 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
24662 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
24663 r->idiag_expires = jiffies_to_msecs(tmo);
24664 r->idiag_rqueue = 0;
24665 r->idiag_wqueue = 0;
24666 @@ -670,6 +677,7 @@ static int inet_diag_dump_reqs(struct sk
24670 + /* TODO: lback */
24672 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
24673 (entry.family == AF_INET6) ?
24674 @@ -740,6 +748,8 @@ static int inet_diag_dump(struct sk_buff
24675 sk_nulls_for_each(sk, node, &ilb->head) {
24676 struct inet_sock *inet = inet_sk(sk);
24678 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24683 @@ -806,6 +816,8 @@ skip_listen_ht:
24684 sk_nulls_for_each(sk, node, &head->chain) {
24685 struct inet_sock *inet = inet_sk(sk);
24687 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24691 if (!(r->idiag_states & (1 << sk->sk_state)))
24692 @@ -830,6 +842,8 @@ next_normal:
24693 inet_twsk_for_each(tw, node,
24696 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24700 if (r->id.idiag_sport != tw->tw_sport &&
24701 diff -NurpP --minimal linux-3.2.8/net/ipv4/inet_hashtables.c linux-3.2.8-vs2.3.2.7/net/ipv4/inet_hashtables.c
24702 --- linux-3.2.8/net/ipv4/inet_hashtables.c 2011-10-24 18:45:34.000000000 +0200
24703 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/inet_hashtables.c 2011-12-05 19:33:02.000000000 +0100
24705 #include <net/inet_connection_sock.h>
24706 #include <net/inet_hashtables.h>
24707 #include <net/secure_seq.h>
24708 +#include <net/route.h>
24709 #include <net/ip.h>
24712 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
24713 if (rcv_saddr != daddr)
24717 + /* block non nx_info ips */
24718 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24719 + daddr, NXA_MASK_BIND))
24722 if (sk->sk_bound_dev_if) {
24723 if (sk->sk_bound_dev_if != dif)
24724 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
24725 * wildcarded during the search since they can never be otherwise.
24729 struct sock *__inet_lookup_listener(struct net *net,
24730 struct inet_hashinfo *hashinfo,
24731 const __be32 daddr, const unsigned short hnum,
24732 @@ -196,6 +201,7 @@ begin:
24738 * if the nulls value we got at the end of this lookup is
24739 * not the expected one, we must restart lookup.
24740 diff -NurpP --minimal linux-3.2.8/net/ipv4/netfilter/nf_nat_helper.c linux-3.2.8-vs2.3.2.7/net/ipv4/netfilter/nf_nat_helper.c
24741 --- linux-3.2.8/net/ipv4/netfilter/nf_nat_helper.c 2011-07-22 11:18:13.000000000 +0200
24742 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/netfilter/nf_nat_helper.c 2011-12-05 19:33:02.000000000 +0100
24744 #include <net/route.h>
24746 #include <linux/netfilter_ipv4.h>
24747 +#include <net/route.h>
24748 #include <net/netfilter/nf_conntrack.h>
24749 #include <net/netfilter/nf_conntrack_helper.h>
24750 #include <net/netfilter/nf_conntrack_ecache.h>
24751 diff -NurpP --minimal linux-3.2.8/net/ipv4/netfilter.c linux-3.2.8-vs2.3.2.7/net/ipv4/netfilter.c
24752 --- linux-3.2.8/net/ipv4/netfilter.c 2012-01-09 16:15:03.000000000 +0100
24753 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/netfilter.c 2012-02-07 03:13:38.000000000 +0100
24755 #include <linux/skbuff.h>
24756 #include <linux/gfp.h>
24757 #include <linux/export.h>
24758 -#include <net/route.h>
24759 +// #include <net/route.h>
24760 #include <net/xfrm.h>
24761 #include <net/ip.h>
24762 #include <net/netfilter/nf_queue.h>
24763 diff -NurpP --minimal linux-3.2.8/net/ipv4/raw.c linux-3.2.8-vs2.3.2.7/net/ipv4/raw.c
24764 --- linux-3.2.8/net/ipv4/raw.c 2012-01-09 16:15:04.000000000 +0100
24765 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/raw.c 2012-02-15 03:03:53.000000000 +0100
24766 @@ -118,7 +118,7 @@ static struct sock *__raw_v4_lookup(stru
24768 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
24769 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
24770 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
24771 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
24772 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
24773 goto found; /* gotcha */
24775 @@ -386,6 +386,12 @@ static int raw_send_hdrinc(struct sock *
24776 icmp_out_count(net, ((struct icmphdr *)
24777 skb_transport_header(skb))->type);
24780 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
24781 + sk->sk_nx_info &&
24782 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
24785 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
24786 rt->dst.dev, dst_output);
24788 @@ -573,6 +579,16 @@ static int raw_sendmsg(struct kiocb *ioc
24792 + if (sk->sk_nx_info) {
24793 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
24794 + if (IS_ERR(rt)) {
24795 + err = PTR_ERR(rt);
24802 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
24803 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
24805 @@ -649,17 +665,19 @@ static int raw_bind(struct sock *sk, str
24807 struct inet_sock *inet = inet_sk(sk);
24808 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
24809 + struct nx_v4_sock_addr nsa = { 0 };
24813 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
24815 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24816 + v4_map_sock_addr(inet, addr, &nsa);
24817 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24818 ret = -EADDRNOTAVAIL;
24819 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
24820 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
24821 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
24823 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24824 + v4_set_sock_addr(inet, &nsa);
24825 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24826 inet->inet_saddr = 0; /* Use device */
24828 @@ -711,7 +729,8 @@ static int raw_recvmsg(struct kiocb *ioc
24829 /* Copy the address. */
24831 sin->sin_family = AF_INET;
24832 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24833 + sin->sin_addr.s_addr =
24834 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
24836 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
24838 @@ -907,7 +926,8 @@ static struct sock *raw_get_first(struct
24839 struct hlist_node *node;
24841 sk_for_each(sk, node, &state->h->ht[state->bucket])
24842 - if (sock_net(sk) == seq_file_net(seq))
24843 + if ((sock_net(sk) == seq_file_net(seq)) &&
24844 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24848 @@ -923,7 +943,8 @@ static struct sock *raw_get_next(struct
24852 - } while (sk && sock_net(sk) != seq_file_net(seq));
24853 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
24854 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24856 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
24857 sk = sk_head(&state->h->ht[state->bucket]);
24858 diff -NurpP --minimal linux-3.2.8/net/ipv4/route.c linux-3.2.8-vs2.3.2.7/net/ipv4/route.c
24859 --- linux-3.2.8/net/ipv4/route.c 2012-01-09 16:15:04.000000000 +0100
24860 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/route.c 2012-02-07 03:13:38.000000000 +0100
24861 @@ -2709,7 +2709,7 @@ static struct rtable *ip_route_output_sl
24864 if (fl4->flowi4_oif) {
24865 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
24866 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
24867 rth = ERR_PTR(-ENODEV);
24868 if (dev_out == NULL)
24870 diff -NurpP --minimal linux-3.2.8/net/ipv4/tcp.c linux-3.2.8-vs2.3.2.7/net/ipv4/tcp.c
24871 --- linux-3.2.8/net/ipv4/tcp.c 2012-01-09 16:15:04.000000000 +0100
24872 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/tcp.c 2011-12-05 19:33:02.000000000 +0100
24873 @@ -266,6 +266,7 @@
24874 #include <linux/crypto.h>
24875 #include <linux/time.h>
24876 #include <linux/slab.h>
24877 +#include <linux/in.h>
24879 #include <net/icmp.h>
24880 #include <net/tcp.h>
24881 diff -NurpP --minimal linux-3.2.8/net/ipv4/tcp_ipv4.c linux-3.2.8-vs2.3.2.7/net/ipv4/tcp_ipv4.c
24882 --- linux-3.2.8/net/ipv4/tcp_ipv4.c 2012-02-28 05:53:29.000000000 +0100
24883 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/tcp_ipv4.c 2012-02-15 03:03:53.000000000 +0100
24884 @@ -2023,6 +2023,12 @@ static void *listening_get_next(struct s
24885 req = req->dl_next;
24888 + vxdprintk(VXD_CBIT(net, 6),
24889 + "sk,req: %p [#%d] (from %d)", req->sk,
24890 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
24892 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
24894 if (req->rsk_ops->family == st->family) {
24897 @@ -2047,6 +2053,10 @@ get_req:
24900 sk_nulls_for_each_from(sk, node) {
24901 + vxdprintk(VXD_CBIT(net, 6), "sk: %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 (!net_eq(sock_net(sk), net))
24907 if (sk->sk_family == st->family) {
24908 @@ -2123,6 +2133,11 @@ static void *established_get_first(struc
24910 spin_lock_bh(lock);
24911 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
24912 + vxdprintk(VXD_CBIT(net, 6),
24913 + "sk,egf: %p [#%d] (from %d)",
24914 + sk, sk->sk_nid, nx_current_nid());
24915 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24917 if (sk->sk_family != st->family ||
24918 !net_eq(sock_net(sk), net)) {
24920 @@ -2133,6 +2148,11 @@ static void *established_get_first(struc
24921 st->state = TCP_SEQ_STATE_TIME_WAIT;
24922 inet_twsk_for_each(tw, node,
24923 &tcp_hashinfo.ehash[st->bucket].twchain) {
24924 + vxdprintk(VXD_CBIT(net, 6),
24925 + "tw: %p [#%d] (from %d)",
24926 + tw, tw->tw_nid, nx_current_nid());
24927 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24929 if (tw->tw_family != st->family ||
24930 !net_eq(twsk_net(tw), net)) {
24932 @@ -2162,7 +2182,9 @@ static void *established_get_next(struct
24936 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
24937 + while (tw && (tw->tw_family != st->family ||
24938 + !net_eq(twsk_net(tw), net) ||
24939 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
24943 @@ -2186,6 +2208,11 @@ get_tw:
24944 sk = sk_nulls_next(sk);
24946 sk_nulls_for_each_from(sk, node) {
24947 + vxdprintk(VXD_CBIT(net, 6),
24948 + "sk,egn: %p [#%d] (from %d)",
24949 + sk, sk->sk_nid, nx_current_nid());
24950 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24952 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
24955 @@ -2391,9 +2418,9 @@ static void get_openreq4(const struct so
24956 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
24957 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
24960 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
24961 ntohs(inet_sk(sk)->inet_sport),
24963 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
24964 ntohs(ireq->rmt_port),
24966 0, 0, /* could print option size, but that is af dependent. */
24967 @@ -2415,8 +2442,8 @@ static void get_tcp4_sock(struct sock *s
24968 const struct tcp_sock *tp = tcp_sk(sk);
24969 const struct inet_connection_sock *icsk = inet_csk(sk);
24970 const struct inet_sock *inet = inet_sk(sk);
24971 - __be32 dest = inet->inet_daddr;
24972 - __be32 src = inet->inet_rcv_saddr;
24973 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
24974 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
24975 __u16 destp = ntohs(inet->inet_dport);
24976 __u16 srcp = ntohs(inet->inet_sport);
24978 @@ -2473,8 +2500,8 @@ static void get_timewait4_sock(const str
24982 - dest = tw->tw_daddr;
24983 - src = tw->tw_rcv_saddr;
24984 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
24985 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
24986 destp = ntohs(tw->tw_dport);
24987 srcp = ntohs(tw->tw_sport);
24989 diff -NurpP --minimal linux-3.2.8/net/ipv4/tcp_minisocks.c linux-3.2.8-vs2.3.2.7/net/ipv4/tcp_minisocks.c
24990 --- linux-3.2.8/net/ipv4/tcp_minisocks.c 2012-01-09 16:15:04.000000000 +0100
24991 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/tcp_minisocks.c 2011-12-05 19:33:02.000000000 +0100
24993 #include <linux/slab.h>
24994 #include <linux/sysctl.h>
24995 #include <linux/workqueue.h>
24996 +#include <linux/vs_limit.h>
24997 +#include <linux/vs_socket.h>
24998 +#include <linux/vs_context.h>
24999 #include <net/tcp.h>
25000 #include <net/inet_common.h>
25001 #include <net/xfrm.h>
25002 @@ -336,6 +339,11 @@ void tcp_time_wait(struct sock *sk, int
25003 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25004 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25006 + tw->tw_xid = sk->sk_xid;
25007 + tw->tw_vx_info = NULL;
25008 + tw->tw_nid = sk->sk_nid;
25009 + tw->tw_nx_info = NULL;
25011 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25012 if (tw->tw_family == PF_INET6) {
25013 struct ipv6_pinfo *np = inet6_sk(sk);
25014 diff -NurpP --minimal linux-3.2.8/net/ipv4/udp.c linux-3.2.8-vs2.3.2.7/net/ipv4/udp.c
25015 --- linux-3.2.8/net/ipv4/udp.c 2012-01-09 16:15:04.000000000 +0100
25016 +++ linux-3.2.8-vs2.3.2.7/net/ipv4/udp.c 2012-02-15 03:03:53.000000000 +0100
25017 @@ -297,14 +297,7 @@ fail:
25019 EXPORT_SYMBOL(udp_lib_get_port);
25021 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25023 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25025 - return (!ipv6_only_sock(sk2) &&
25026 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25027 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25029 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25031 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25033 @@ -339,6 +332,11 @@ static inline int compute_score(struct s
25034 if (inet->inet_rcv_saddr != daddr)
25038 + /* block non nx_info ips */
25039 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25040 + daddr, NXA_MASK_BIND))
25043 if (inet->inet_daddr) {
25044 if (inet->inet_daddr != saddr)
25045 @@ -442,6 +440,7 @@ exact_match:
25050 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25051 * harder than this. -DaveM
25053 @@ -487,6 +486,11 @@ begin:
25054 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25055 score = compute_score(sk, net, saddr, hnum, sport,
25056 daddr, dport, dif);
25057 + /* FIXME: disabled?
25058 + if (score == 9) {
25062 if (score > badness) {
25065 @@ -500,6 +504,7 @@ begin:
25066 if (get_nulls_value(node) != slot)
25071 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25073 @@ -509,6 +514,7 @@ begin:
25081 @@ -551,8 +557,7 @@ static inline struct sock *udp_v4_mcast_
25082 udp_sk(s)->udp_port_hash != hnum ||
25083 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25084 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25085 - (inet->inet_rcv_saddr &&
25086 - inet->inet_rcv_saddr != loc_addr) ||
25087 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25088 ipv6_only_sock(s) ||
25089 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25091 @@ -930,6 +935,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
25092 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
25093 faddr, saddr, dport, inet->inet_sport);
25095 + if (sk->sk_nx_info) {
25096 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
25097 + if (IS_ERR(rt)) {
25098 + err = PTR_ERR(rt);
25105 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
25106 rt = ip_route_output_flow(net, fl4, sk);
25108 @@ -1228,7 +1243,8 @@ try_again:
25110 sin->sin_family = AF_INET;
25111 sin->sin_port = udp_hdr(skb)->source;
25112 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25113 + sin->sin_addr.s_addr = nx_map_sock_lback(
25114 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25115 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25117 if (inet->cmsg_flags)
25118 @@ -1974,6 +1990,8 @@ static struct sock *udp_get_first(struct
25119 sk_nulls_for_each(sk, node, &hslot->head) {
25120 if (!net_eq(sock_net(sk), net))
25122 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25124 if (sk->sk_family == state->family)
25127 @@ -1991,7 +2009,9 @@ static struct sock *udp_get_next(struct
25130 sk = sk_nulls_next(sk);
25131 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25132 + } while (sk && (!net_eq(sock_net(sk), net) ||
25133 + sk->sk_family != state->family ||
25134 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25137 if (state->bucket <= state->udp_table->mask)
25138 diff -NurpP --minimal linux-3.2.8/net/ipv6/Kconfig linux-3.2.8-vs2.3.2.7/net/ipv6/Kconfig
25139 --- linux-3.2.8/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25140 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/Kconfig 2011-12-05 19:33:02.000000000 +0100
25143 # IPv6 as module will cause a CRASH if you try to unload it
25145 - tristate "The IPv6 protocol"
25147 + bool "The IPv6 protocol"
25150 This is complemental support for the IP version 6.
25151 You will still be able to do traditional IPv4 networking as well.
25152 diff -NurpP --minimal linux-3.2.8/net/ipv6/addrconf.c linux-3.2.8-vs2.3.2.7/net/ipv6/addrconf.c
25153 --- linux-3.2.8/net/ipv6/addrconf.c 2012-02-28 05:53:29.000000000 +0100
25154 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/addrconf.c 2012-02-07 03:14:01.000000000 +0100
25156 #include <linux/proc_fs.h>
25157 #include <linux/seq_file.h>
25158 #include <linux/export.h>
25159 +#include <linux/vs_network.h>
25160 +#include <linux/vs_inet6.h>
25162 /* Set to 3 to get tracing... */
25163 #define ACONF_DEBUG 2
25164 @@ -1109,7 +1111,7 @@ out:
25166 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25167 const struct in6_addr *daddr, unsigned int prefs,
25168 - struct in6_addr *saddr)
25169 + struct in6_addr *saddr, struct nx_info *nxi)
25171 struct ipv6_saddr_score scores[2],
25172 *score = &scores[0], *hiscore = &scores[1];
25173 @@ -1181,6 +1183,8 @@ int ipv6_dev_get_saddr(struct net *net,
25177 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25181 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25182 @@ -3153,7 +3157,10 @@ static void if6_seq_stop(struct seq_file
25183 static int if6_seq_show(struct seq_file *seq, void *v)
25185 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25186 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25188 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25189 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25190 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25192 ifp->idev->dev->ifindex,
25194 @@ -3659,6 +3666,11 @@ static int in6_dump_addrs(struct inet6_d
25195 struct ifacaddr6 *ifaca;
25197 int ip_idx = *p_ip_idx;
25198 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25200 + /* disable ipv6 on non v6 guests */
25201 + if (nxi && !nx_info_has_v6(nxi))
25204 read_lock_bh(&idev->lock);
25206 @@ -3669,6 +3681,8 @@ static int in6_dump_addrs(struct inet6_d
25207 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25208 if (++ip_idx < s_ip_idx)
25210 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25212 err = inet6_fill_ifaddr(skb, ifa,
25213 NETLINK_CB(cb->skb).pid,
25214 cb->nlh->nlmsg_seq,
25215 @@ -3685,6 +3699,8 @@ static int in6_dump_addrs(struct inet6_d
25216 ifmca = ifmca->next, ip_idx++) {
25217 if (ip_idx < s_ip_idx)
25219 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25221 err = inet6_fill_ifmcaddr(skb, ifmca,
25222 NETLINK_CB(cb->skb).pid,
25223 cb->nlh->nlmsg_seq,
25224 @@ -3700,6 +3716,8 @@ static int in6_dump_addrs(struct inet6_d
25225 ifaca = ifaca->aca_next, ip_idx++) {
25226 if (ip_idx < s_ip_idx)
25228 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25230 err = inet6_fill_ifacaddr(skb, ifaca,
25231 NETLINK_CB(cb->skb).pid,
25232 cb->nlh->nlmsg_seq,
25233 @@ -4085,6 +4103,11 @@ static int inet6_dump_ifinfo(struct sk_b
25234 struct inet6_dev *idev;
25235 struct hlist_head *head;
25236 struct hlist_node *node;
25237 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25239 + /* FIXME: maybe disable ipv6 on non v6 guests?
25240 + if (skb->sk && skb->sk->sk_vx_info)
25241 + return skb->len; */
25244 s_idx = cb->args[1];
25245 @@ -4096,6 +4119,8 @@ static int inet6_dump_ifinfo(struct sk_b
25246 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25249 + if (!v6_dev_in_nx_info(dev, nxi))
25251 idev = __in6_dev_get(dev);
25254 diff -NurpP --minimal linux-3.2.8/net/ipv6/af_inet6.c linux-3.2.8-vs2.3.2.7/net/ipv6/af_inet6.c
25255 --- linux-3.2.8/net/ipv6/af_inet6.c 2011-10-24 18:45:34.000000000 +0200
25256 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/af_inet6.c 2011-12-05 19:33:02.000000000 +0100
25258 #include <linux/netdevice.h>
25259 #include <linux/icmpv6.h>
25260 #include <linux/netfilter_ipv6.h>
25261 +#include <linux/vs_inet.h>
25262 +#include <linux/vs_inet6.h>
25264 #include <net/ip.h>
25265 #include <net/ipv6.h>
25266 @@ -160,9 +162,12 @@ lookup_protocol:
25270 + if ((protocol == IPPROTO_ICMPV6) &&
25271 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25273 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25274 goto out_rcu_unlock;
25277 sock->ops = answer->ops;
25278 answer_prot = answer->prot;
25279 answer_no_check = answer->no_check;
25280 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25281 struct inet_sock *inet = inet_sk(sk);
25282 struct ipv6_pinfo *np = inet6_sk(sk);
25283 struct net *net = sock_net(sk);
25284 + struct nx_v6_sock_addr nsa;
25286 unsigned short snum;
25288 @@ -276,6 +282,10 @@ int inet6_bind(struct socket *sock, stru
25289 if (addr->sin6_family != AF_INET6)
25290 return -EAFNOSUPPORT;
25292 + err = v6_map_sock_addr(inet, addr, &nsa);
25296 addr_type = ipv6_addr_type(&addr->sin6_addr);
25297 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25299 @@ -307,6 +317,7 @@ int inet6_bind(struct socket *sock, stru
25300 /* Reproduce AF_INET checks to make the bindings consistent */
25301 v4addr = addr->sin6_addr.s6_addr32[3];
25302 chk_addr_ret = inet_addr_type(net, v4addr);
25304 if (!sysctl_ip_nonlocal_bind &&
25305 !(inet->freebind || inet->transparent) &&
25306 v4addr != htonl(INADDR_ANY) &&
25307 @@ -316,6 +327,10 @@ int inet6_bind(struct socket *sock, stru
25308 err = -EADDRNOTAVAIL;
25311 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25312 + err = -EADDRNOTAVAIL;
25316 if (addr_type != IPV6_ADDR_ANY) {
25317 struct net_device *dev = NULL;
25318 @@ -342,6 +357,11 @@ int inet6_bind(struct socket *sock, stru
25322 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25323 + err = -EADDRNOTAVAIL;
25327 /* ipv4 addr of the socket is invalid. Only the
25328 * unspecified and mapped address have a v4 equivalent.
25330 @@ -358,6 +378,9 @@ int inet6_bind(struct socket *sock, stru
25334 + /* what's that for? */
25335 + v6_set_sock_addr(inet, &nsa);
25337 inet->inet_rcv_saddr = v4addr;
25338 inet->inet_saddr = v4addr;
25340 @@ -459,9 +482,11 @@ int inet6_getname(struct socket *sock, s
25342 sin->sin6_port = inet->inet_dport;
25343 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25344 + /* FIXME: remap lback? */
25346 sin->sin6_flowinfo = np->flow_label;
25348 + /* FIXME: remap lback? */
25349 if (ipv6_addr_any(&np->rcv_saddr))
25350 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25352 diff -NurpP --minimal linux-3.2.8/net/ipv6/datagram.c linux-3.2.8-vs2.3.2.7/net/ipv6/datagram.c
25353 --- linux-3.2.8/net/ipv6/datagram.c 2012-01-09 16:15:04.000000000 +0100
25354 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/datagram.c 2011-12-05 19:33:02.000000000 +0100
25355 @@ -642,7 +642,7 @@ int datagram_send_ctl(struct net *net, s
25358 if (fl6->flowi6_oif) {
25359 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25360 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25364 diff -NurpP --minimal linux-3.2.8/net/ipv6/fib6_rules.c linux-3.2.8-vs2.3.2.7/net/ipv6/fib6_rules.c
25365 --- linux-3.2.8/net/ipv6/fib6_rules.c 2012-01-09 16:15:04.000000000 +0100
25366 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/fib6_rules.c 2011-12-05 19:33:02.000000000 +0100
25367 @@ -91,7 +91,7 @@ static int fib6_rule_action(struct fib_r
25368 ip6_dst_idev(&rt->dst)->dev,
25370 rt6_flags2srcprefs(flags),
25374 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25376 diff -NurpP --minimal linux-3.2.8/net/ipv6/inet6_hashtables.c linux-3.2.8-vs2.3.2.7/net/ipv6/inet6_hashtables.c
25377 --- linux-3.2.8/net/ipv6/inet6_hashtables.c 2011-10-24 18:45:34.000000000 +0200
25378 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/inet6_hashtables.c 2011-12-05 19:33:02.000000000 +0100
25381 #include <linux/module.h>
25382 #include <linux/random.h>
25383 +#include <linux/vs_inet6.h>
25385 #include <net/inet_connection_sock.h>
25386 #include <net/inet_hashtables.h>
25387 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25388 unsigned int slot = hash & hashinfo->ehash_mask;
25389 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25394 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25395 @@ -95,7 +95,7 @@ begin:
25403 if (get_nulls_value(node) != slot)
25404 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
25405 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25409 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25412 if (sk->sk_bound_dev_if) {
25413 if (sk->sk_bound_dev_if != dif)
25414 diff -NurpP --minimal linux-3.2.8/net/ipv6/ip6_output.c linux-3.2.8-vs2.3.2.7/net/ipv6/ip6_output.c
25415 --- linux-3.2.8/net/ipv6/ip6_output.c 2012-01-09 16:15:04.000000000 +0100
25416 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/ip6_output.c 2012-01-09 16:19:31.000000000 +0100
25417 @@ -963,7 +963,8 @@ static int ip6_dst_lookup_tail(struct so
25418 struct rt6_info *rt = (struct rt6_info *) *dst;
25419 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25420 sk ? inet6_sk(sk)->srcprefs : 0,
25423 + sk ? sk->sk_nx_info : NULL);
25425 goto out_err_release;
25427 diff -NurpP --minimal linux-3.2.8/net/ipv6/ndisc.c linux-3.2.8-vs2.3.2.7/net/ipv6/ndisc.c
25428 --- linux-3.2.8/net/ipv6/ndisc.c 2012-01-09 16:15:04.000000000 +0100
25429 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/ndisc.c 2011-12-15 01:11:37.000000000 +0100
25430 @@ -588,7 +588,7 @@ static void ndisc_send_na(struct net_dev
25432 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25433 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25437 src_addr = &tmpaddr;
25439 diff -NurpP --minimal linux-3.2.8/net/ipv6/raw.c linux-3.2.8-vs2.3.2.7/net/ipv6/raw.c
25440 --- linux-3.2.8/net/ipv6/raw.c 2012-02-28 05:53:29.000000000 +0100
25441 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/raw.c 2012-02-07 03:14:01.000000000 +0100
25443 #include <linux/icmpv6.h>
25444 #include <linux/netfilter.h>
25445 #include <linux/netfilter_ipv6.h>
25446 +#include <linux/vs_inet6.h>
25447 #include <linux/skbuff.h>
25448 #include <linux/compat.h>
25449 #include <asm/uaccess.h>
25450 @@ -285,6 +286,13 @@ static int rawv6_bind(struct sock *sk, s
25454 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25455 + err = -EADDRNOTAVAIL;
25461 /* ipv4 addr of the socket is invalid. Only the
25462 * unspecified and mapped address have a v4 equivalent.
25464 diff -NurpP --minimal linux-3.2.8/net/ipv6/route.c linux-3.2.8-vs2.3.2.7/net/ipv6/route.c
25465 --- linux-3.2.8/net/ipv6/route.c 2012-01-09 16:15:04.000000000 +0100
25466 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/route.c 2012-01-09 16:19:31.000000000 +0100
25468 #include <net/xfrm.h>
25469 #include <net/netevent.h>
25470 #include <net/netlink.h>
25471 +#include <linux/vs_inet6.h>
25473 #include <asm/uaccess.h>
25475 @@ -2093,15 +2094,17 @@ int ip6_route_get_saddr(struct net *net,
25476 struct rt6_info *rt,
25477 const struct in6_addr *daddr,
25478 unsigned int prefs,
25479 - struct in6_addr *saddr)
25480 + struct in6_addr *saddr,
25481 + struct nx_info *nxi)
25483 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25485 - if (rt->rt6i_prefsrc.plen)
25486 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25487 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25488 ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr);
25490 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25491 - daddr, prefs, saddr);
25492 + daddr, prefs, saddr, nxi);
25496 @@ -2431,7 +2434,8 @@ static int rt6_fill_node(struct net *net
25497 NLA_PUT_U32(skb, RTA_IIF, iif);
25499 struct in6_addr saddr_buf;
25500 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0)
25501 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25502 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25503 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25506 @@ -2634,6 +2638,7 @@ static int rt6_info_route(struct rt6_inf
25507 struct seq_file *m = p_arg;
25508 struct neighbour *n;
25510 + /* FIXME: check for network context? */
25511 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25513 #ifdef CONFIG_IPV6_SUBTREES
25514 diff -NurpP --minimal linux-3.2.8/net/ipv6/tcp_ipv6.c linux-3.2.8-vs2.3.2.7/net/ipv6/tcp_ipv6.c
25515 --- linux-3.2.8/net/ipv6/tcp_ipv6.c 2012-02-28 05:53:29.000000000 +0100
25516 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/tcp_ipv6.c 2012-02-07 03:14:01.000000000 +0100
25519 #include <linux/crypto.h>
25520 #include <linux/scatterlist.h>
25521 +#include <linux/vs_inet6.h>
25523 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25524 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25525 @@ -162,8 +163,15 @@ static int tcp_v6_connect(struct sock *s
25526 * connect() to INADDR_ANY means loopback (BSD'ism).
25529 - if(ipv6_addr_any(&usin->sin6_addr))
25530 - usin->sin6_addr.s6_addr[15] = 0x1;
25531 + if(ipv6_addr_any(&usin->sin6_addr)) {
25532 + struct nx_info *nxi = sk->sk_nx_info;
25534 + if (nxi && nx_info_has_v6(nxi))
25535 + /* FIXME: remap lback? */
25536 + usin->sin6_addr = nxi->v6.ip;
25538 + usin->sin6_addr.s6_addr[15] = 0x1;
25541 addr_type = ipv6_addr_type(&usin->sin6_addr);
25543 diff -NurpP --minimal linux-3.2.8/net/ipv6/udp.c linux-3.2.8-vs2.3.2.7/net/ipv6/udp.c
25544 --- linux-3.2.8/net/ipv6/udp.c 2012-01-09 16:15:04.000000000 +0100
25545 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/udp.c 2011-12-15 01:11:37.000000000 +0100
25546 @@ -45,41 +45,67 @@
25547 #include <net/tcp_states.h>
25548 #include <net/ip6_checksum.h>
25549 #include <net/xfrm.h>
25550 +#include <linux/vs_inet6.h>
25552 #include <linux/proc_fs.h>
25553 #include <linux/seq_file.h>
25554 #include "udp_impl.h"
25556 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25557 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25559 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25560 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25561 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25562 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25563 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25564 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25565 - int sk_ipv6only = ipv6_only_sock(sk);
25566 + int sk1_ipv6only = ipv6_only_sock(sk1);
25567 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25568 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25569 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25570 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25572 /* if both are mapped, treat as IPv4 */
25573 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25574 - return (!sk2_ipv6only &&
25575 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25576 + if (!sk2_ipv6only &&
25577 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25578 - sk1_rcv_saddr == sk2_rcv_saddr));
25579 + sk1_rcv_saddr == sk2_rcv_saddr))
25585 if (addr_type2 == IPV6_ADDR_ANY &&
25586 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25590 if (addr_type == IPV6_ADDR_ANY &&
25591 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25593 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25596 if (sk2_rcv_saddr6 &&
25597 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25599 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25605 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25606 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25607 + if (!sk2_rcv_saddr)
25608 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25609 + if (!sk1_rcv_saddr)
25610 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25613 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25614 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25615 + else if (addr_type2 == IPV6_ADDR_ANY)
25616 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25617 + else if (addr_type == IPV6_ADDR_ANY) {
25618 + if (addr_type2 == IPV6_ADDR_MAPPED)
25619 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25621 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25626 static unsigned int udp6_portaddr_hash(struct net *net,
25627 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
25628 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25632 + /* block non nx_info ips */
25633 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25636 if (!ipv6_addr_any(&np->daddr)) {
25637 if (!ipv6_addr_equal(&np->daddr, saddr))
25638 diff -NurpP --minimal linux-3.2.8/net/ipv6/xfrm6_policy.c linux-3.2.8-vs2.3.2.7/net/ipv6/xfrm6_policy.c
25639 --- linux-3.2.8/net/ipv6/xfrm6_policy.c 2011-07-22 11:18:13.000000000 +0200
25640 +++ linux-3.2.8-vs2.3.2.7/net/ipv6/xfrm6_policy.c 2011-12-05 19:33:02.000000000 +0100
25641 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
25642 dev = ip6_dst_idev(dst)->dev;
25643 ipv6_dev_get_saddr(dev_net(dev), dev,
25644 (struct in6_addr *)&daddr->a6, 0,
25645 - (struct in6_addr *)&saddr->a6);
25646 + (struct in6_addr *)&saddr->a6, NULL);
25650 diff -NurpP --minimal linux-3.2.8/net/netfilter/ipvs/ip_vs_xmit.c linux-3.2.8-vs2.3.2.7/net/netfilter/ipvs/ip_vs_xmit.c
25651 --- linux-3.2.8/net/netfilter/ipvs/ip_vs_xmit.c 2012-01-09 16:15:04.000000000 +0100
25652 +++ linux-3.2.8-vs2.3.2.7/net/netfilter/ipvs/ip_vs_xmit.c 2012-02-07 03:13:38.000000000 +0100
25653 @@ -226,7 +226,7 @@ __ip_vs_route_output_v6(struct net *net,
25655 if (ipv6_addr_any(&fl6.saddr) &&
25656 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
25657 - &fl6.daddr, 0, &fl6.saddr) < 0)
25658 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
25661 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
25662 diff -NurpP --minimal linux-3.2.8/net/netlink/af_netlink.c linux-3.2.8-vs2.3.2.7/net/netlink/af_netlink.c
25663 --- linux-3.2.8/net/netlink/af_netlink.c 2012-01-09 16:15:04.000000000 +0100
25664 +++ linux-3.2.8-vs2.3.2.7/net/netlink/af_netlink.c 2011-12-05 19:33:02.000000000 +0100
25666 #include <linux/types.h>
25667 #include <linux/audit.h>
25668 #include <linux/mutex.h>
25669 +#include <linux/vs_context.h>
25670 +#include <linux/vs_network.h>
25671 +#include <linux/vs_limit.h>
25673 #include <net/net_namespace.h>
25674 #include <net/sock.h>
25675 @@ -1912,6 +1915,8 @@ static struct sock *netlink_seq_socket_i
25676 sk_for_each(s, node, &hash->table[j]) {
25677 if (sock_net(s) != seq_file_net(seq))
25679 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25683 iter->hash_idx = j;
25684 @@ -1946,7 +1951,8 @@ static void *netlink_seq_next(struct seq
25688 - } while (s && sock_net(s) != seq_file_net(seq));
25689 + } while (s && (sock_net(s) != seq_file_net(seq) ||
25690 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
25694 @@ -1958,7 +1964,8 @@ static void *netlink_seq_next(struct seq
25696 for (; j <= hash->mask; j++) {
25697 s = sk_head(&hash->table[j]);
25698 - while (s && sock_net(s) != seq_file_net(seq))
25699 + while (s && (sock_net(s) != seq_file_net(seq) ||
25700 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
25704 diff -NurpP --minimal linux-3.2.8/net/socket.c linux-3.2.8-vs2.3.2.7/net/socket.c
25705 --- linux-3.2.8/net/socket.c 2012-02-28 05:53:30.000000000 +0100
25706 +++ linux-3.2.8-vs2.3.2.7/net/socket.c 2012-02-07 03:14:01.000000000 +0100
25709 #include <net/sock.h>
25710 #include <linux/netfilter.h>
25711 +#include <linux/vs_base.h>
25712 +#include <linux/vs_socket.h>
25713 +#include <linux/vs_inet.h>
25714 +#include <linux/vs_inet6.h>
25716 #include <linux/if_tun.h>
25717 #include <linux/ipv6_route.h>
25718 @@ -546,6 +550,7 @@ static inline int __sock_sendmsg_nosec(s
25719 struct msghdr *msg, size_t size)
25721 struct sock_iocb *si = kiocb_to_siocb(iocb);
25724 sock_update_classid(sock->sk);
25726 @@ -554,7 +559,22 @@ static inline int __sock_sendmsg_nosec(s
25730 - return sock->ops->sendmsg(iocb, sock, msg, size);
25731 + len = sock->ops->sendmsg(iocb, sock, msg, size);
25734 + vx_sock_send(sock->sk, size);
25736 + vx_sock_fail(sock->sk, size);
25738 + vxdprintk(VXD_CBIT(net, 7),
25739 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
25741 + (sock->sk)?sock->sk->sk_nx_info:0,
25742 + (sock->sk)?sock->sk->sk_vx_info:0,
25743 + (sock->sk)?sock->sk->sk_xid:0,
25744 + (sock->sk)?sock->sk->sk_nid:0,
25745 + (unsigned int)size, len);
25749 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
25750 @@ -694,6 +714,7 @@ static inline int __sock_recvmsg_nosec(s
25751 struct msghdr *msg, size_t size, int flags)
25753 struct sock_iocb *si = kiocb_to_siocb(iocb);
25756 sock_update_classid(sock->sk);
25758 @@ -703,7 +724,18 @@ static inline int __sock_recvmsg_nosec(s
25762 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
25763 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
25764 + if ((len >= 0) && sock->sk)
25765 + vx_sock_recv(sock->sk, len);
25766 + vxdprintk(VXD_CBIT(net, 7),
25767 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
25769 + (sock->sk)?sock->sk->sk_nx_info:0,
25770 + (sock->sk)?sock->sk->sk_vx_info:0,
25771 + (sock->sk)?sock->sk->sk_xid:0,
25772 + (sock->sk)?sock->sk->sk_nid:0,
25773 + (unsigned int)size, len);
25777 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
25778 @@ -1188,6 +1220,13 @@ int __sock_create(struct net *net, int f
25779 if (type < 0 || type >= SOCK_MAX)
25782 + if (!nx_check(0, VS_ADMIN)) {
25783 + if (family == PF_INET && !current_nx_info_has_v4())
25784 + return -EAFNOSUPPORT;
25785 + if (family == PF_INET6 && !current_nx_info_has_v6())
25786 + return -EAFNOSUPPORT;
25791 This uglymoron is moved from INET layer to here to avoid
25792 @@ -1323,6 +1362,7 @@ SYSCALL_DEFINE3(socket, int, family, int
25796 + set_bit(SOCK_USER_SOCKET, &sock->flags);
25797 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
25800 @@ -1364,10 +1404,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
25801 err = sock_create(family, type, protocol, &sock1);
25804 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
25806 err = sock_create(family, type, protocol, &sock2);
25808 goto out_release_1;
25809 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
25811 err = sock1->ops->socketpair(sock1, sock2);
25813 diff -NurpP --minimal linux-3.2.8/net/sunrpc/auth.c linux-3.2.8-vs2.3.2.7/net/sunrpc/auth.c
25814 --- linux-3.2.8/net/sunrpc/auth.c 2011-10-24 18:45:34.000000000 +0200
25815 +++ linux-3.2.8-vs2.3.2.7/net/sunrpc/auth.c 2011-12-05 19:33:02.000000000 +0100
25817 #include <linux/hash.h>
25818 #include <linux/sunrpc/clnt.h>
25819 #include <linux/spinlock.h>
25820 +#include <linux/vs_tag.h>
25823 # define RPCDBG_FACILITY RPCDBG_AUTH
25824 @@ -427,6 +428,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
25825 memset(&acred, 0, sizeof(acred));
25826 acred.uid = cred->fsuid;
25827 acred.gid = cred->fsgid;
25828 + acred.tag = dx_current_tag();
25829 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
25831 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
25832 @@ -467,6 +469,7 @@ rpcauth_bind_root_cred(struct rpc_task *
25833 struct auth_cred acred = {
25836 + .tag = dx_current_tag(),
25839 dprintk("RPC: %5u looking up %s cred\n",
25840 diff -NurpP --minimal linux-3.2.8/net/sunrpc/auth_unix.c linux-3.2.8-vs2.3.2.7/net/sunrpc/auth_unix.c
25841 --- linux-3.2.8/net/sunrpc/auth_unix.c 2012-01-09 16:15:04.000000000 +0100
25842 +++ linux-3.2.8-vs2.3.2.7/net/sunrpc/auth_unix.c 2011-12-05 19:33:02.000000000 +0100
25843 @@ -12,12 +12,14 @@
25844 #include <linux/module.h>
25845 #include <linux/sunrpc/clnt.h>
25846 #include <linux/sunrpc/auth.h>
25847 +#include <linux/vs_tag.h>
25849 #define NFS_NGROUPS 16
25852 struct rpc_cred uc_base;
25855 gid_t uc_gids[NFS_NGROUPS];
25857 #define uc_uid uc_base.cr_uid
25858 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
25859 groups = NFS_NGROUPS;
25861 cred->uc_gid = acred->gid;
25862 + cred->uc_tag = acred->tag;
25863 for (i = 0; i < groups; i++)
25864 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
25865 if (i < NFS_NGROUPS)
25866 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
25870 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
25871 + if (cred->uc_uid != acred->uid ||
25872 + cred->uc_gid != acred->gid ||
25873 + cred->uc_tag != acred->tag)
25876 if (acred->group_info != NULL)
25877 @@ -145,7 +150,7 @@ unx_marshal(struct rpc_task *task, __be3
25878 struct rpc_clnt *clnt = task->tk_client;
25879 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
25880 __be32 *base, *hold;
25884 *p++ = htonl(RPC_AUTH_UNIX);
25886 @@ -155,9 +160,12 @@ unx_marshal(struct rpc_task *task, __be3
25887 * Copy the UTS nodename captured when the client was created.
25889 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
25890 + tag = task->tk_client->cl_tag;
25892 - *p++ = htonl((u32) cred->uc_uid);
25893 - *p++ = htonl((u32) cred->uc_gid);
25894 + *p++ = htonl((u32) TAGINO_UID(tag,
25895 + cred->uc_uid, cred->uc_tag));
25896 + *p++ = htonl((u32) TAGINO_GID(tag,
25897 + cred->uc_gid, cred->uc_tag));
25899 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
25900 *p++ = htonl((u32) cred->uc_gids[i]);
25901 diff -NurpP --minimal linux-3.2.8/net/sunrpc/clnt.c linux-3.2.8-vs2.3.2.7/net/sunrpc/clnt.c
25902 --- linux-3.2.8/net/sunrpc/clnt.c 2012-01-09 16:15:04.000000000 +0100
25903 +++ linux-3.2.8-vs2.3.2.7/net/sunrpc/clnt.c 2011-12-05 19:33:02.000000000 +0100
25905 #include <linux/in.h>
25906 #include <linux/in6.h>
25907 #include <linux/un.h>
25908 +#include <linux/vs_cvirt.h>
25910 #include <linux/sunrpc/clnt.h>
25911 #include <linux/sunrpc/rpc_pipe_fs.h>
25912 @@ -361,6 +362,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
25913 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
25914 clnt->cl_chatty = 1;
25916 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
25917 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
25918 + clnt->cl_tag = 1; */
25921 EXPORT_SYMBOL_GPL(rpc_create);
25922 diff -NurpP --minimal linux-3.2.8/net/unix/af_unix.c linux-3.2.8-vs2.3.2.7/net/unix/af_unix.c
25923 --- linux-3.2.8/net/unix/af_unix.c 2012-02-28 05:53:30.000000000 +0100
25924 +++ linux-3.2.8-vs2.3.2.7/net/unix/af_unix.c 2012-02-07 03:14:01.000000000 +0100
25925 @@ -114,6 +114,8 @@
25926 #include <linux/mount.h>
25927 #include <net/checksum.h>
25928 #include <linux/security.h>
25929 +#include <linux/vs_context.h>
25930 +#include <linux/vs_limit.h>
25932 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
25933 static DEFINE_SPINLOCK(unix_table_lock);
25934 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
25935 if (!net_eq(sock_net(s), net))
25938 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25940 if (u->addr->len == len &&
25941 !memcmp(u->addr->name, sunname, len))
25943 @@ -2219,6 +2223,8 @@ static struct sock *unix_seq_idx(struct
25944 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
25945 if (sock_net(s) != seq_file_net(seq))
25947 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25952 @@ -2243,7 +2249,8 @@ static void *unix_seq_next(struct seq_fi
25953 sk = first_unix_socket(&iter->i);
25955 sk = next_unix_socket(&iter->i, sk);
25956 - while (sk && (sock_net(sk) != seq_file_net(seq)))
25957 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
25958 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
25959 sk = next_unix_socket(&iter->i, sk);
25962 diff -NurpP --minimal linux-3.2.8/scripts/checksyscalls.sh linux-3.2.8-vs2.3.2.7/scripts/checksyscalls.sh
25963 --- linux-3.2.8/scripts/checksyscalls.sh 2011-03-15 18:07:46.000000000 +0100
25964 +++ linux-3.2.8-vs2.3.2.7/scripts/checksyscalls.sh 2011-12-05 19:33:02.000000000 +0100
25965 @@ -193,7 +193,6 @@ cat << EOF
25966 #define __IGNORE_afs_syscall
25967 #define __IGNORE_getpmsg
25968 #define __IGNORE_putpmsg
25969 -#define __IGNORE_vserver
25973 diff -NurpP --minimal linux-3.2.8/security/commoncap.c linux-3.2.8-vs2.3.2.7/security/commoncap.c
25974 --- linux-3.2.8/security/commoncap.c 2012-01-09 16:15:05.000000000 +0100
25975 +++ linux-3.2.8-vs2.3.2.7/security/commoncap.c 2011-12-05 19:33:02.000000000 +0100
25976 @@ -62,6 +62,7 @@ int cap_netlink_recv(struct sk_buff *skb
25981 EXPORT_SYMBOL(cap_netlink_recv);
25984 @@ -83,14 +84,20 @@ EXPORT_SYMBOL(cap_netlink_recv);
25985 int cap_capable(struct task_struct *tsk, const struct cred *cred,
25986 struct user_namespace *targ_ns, int cap, int audit)
25988 + struct vx_info *vxi = tsk->vx_info;
25991 /* The creator of the user namespace has all caps. */
25992 if (targ_ns != &init_user_ns && targ_ns->creator == cred->user)
25995 /* Do we have the necessary capabilities? */
25996 - if (targ_ns == cred->user->user_ns)
25997 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
25998 + if (targ_ns == cred->user->user_ns) {
25999 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26000 + cap_raised(cred->cap_effective, cap))
26002 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26005 /* Have we tried all of the parent namespaces? */
26006 if (targ_ns == &init_user_ns)
26007 @@ -615,7 +622,7 @@ int cap_inode_setxattr(struct dentry *de
26009 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26010 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26011 - !capable(CAP_SYS_ADMIN))
26012 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26016 @@ -641,7 +648,7 @@ int cap_inode_removexattr(struct dentry
26018 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26019 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26020 - !capable(CAP_SYS_ADMIN))
26021 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26025 diff -NurpP --minimal linux-3.2.8/security/selinux/hooks.c linux-3.2.8-vs2.3.2.7/security/selinux/hooks.c
26026 --- linux-3.2.8/security/selinux/hooks.c 2012-01-09 16:15:05.000000000 +0100
26027 +++ linux-3.2.8-vs2.3.2.7/security/selinux/hooks.c 2011-12-05 19:33:02.000000000 +0100
26029 #include <linux/dccp.h>
26030 #include <linux/quota.h>
26031 #include <linux/un.h> /* for Unix socket types */
26032 -#include <net/af_unix.h> /* for Unix socket types */
26033 #include <linux/parser.h>
26034 #include <linux/nfs_mount.h>
26035 #include <net/ipv6.h>