1 diff -NurpP --minimal linux-3.1.1/Documentation/vserver/debug.txt linux-3.1.1-vs2.3.2/Documentation/vserver/debug.txt
2 --- linux-3.1.1/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.1.1-vs2.3.2/Documentation/vserver/debug.txt 2011-10-24 18:53:33.000000000 +0200
8 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
9 + "vx_rmap_tgid: %p/%llx: %d -> %d"
13 + 0 1 "ALLOC (%p,#%d)%c inode (%d)"
14 + "FREE (%p,#%d)%c inode"
15 + 1 2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
16 + "FREE (%p,#%d)%c %lld bytes"
17 + 2 4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
18 + 3 8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
19 + "ext3_has_free_blocks(%p): free=%lu, root=%lu"
20 + "rcu_free_dl_info(%p)"
21 + 4 10 "alloc_dl_info(%p,%d) = %p"
22 + "dealloc_dl_info(%p)"
23 + "get_dl_info(%p[#%d.%d])"
24 + "put_dl_info(%p[#%d.%d])"
25 + 5 20 "alloc_dl_info(%p,%d)*"
26 + 6 40 "__hash_dl_info: %p[#%d]"
27 + "__unhash_dl_info: %p[#%d]"
28 + 7 80 "locate_dl_info(%p,#%d) = %p"
32 + 0 1 "destroy_dqhash: %p [#0x%08x] c=%d"
33 + "new_dqhash: %p [#0x%08x]"
34 + "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
35 + "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
36 + "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
37 + "vroot_get_real_bdev not set"
38 + 1 2 "cow_break_link(»%s«)"
40 + 2 4 "dentry_open(new): %p"
41 + "dentry_open(old): %p"
42 + "lookup_create(new): %p"
44 + "path_lookup(old): %d"
45 + "vfs_create(new): %d"
48 + 3 8 "fput(new_file=%p[#%d])"
49 + "fput(old_file=%p[#%d])"
50 + 4 10 "vx_info_kill(%p[#%d],%d,%d) = %d"
51 + "vx_info_kill(%p[#%d],%d,%d)*"
52 + 5 20 "vs_reboot(%p[#%d],%d)"
53 + 6 40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
57 + 2 4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
58 + 3 8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
59 + "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
60 + 4 10 "ip_route_connect(%p) %p,%p;%lx"
61 + 5 20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
62 + 6 40 "sk,egf: %p [#%d] (from %d)"
63 + "sk,egn: %p [#%d] (from %d)"
64 + "sk,req: %p [#%d] (from %d)"
65 + "sk: %p [#%d] (from %d)"
66 + "tw: %p [#%d] (from %d)"
67 + 7 80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
68 + "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
72 + 0 1 "__lookup_nx_info(#%u): %p[#%u]"
73 + "alloc_nx_info(%d) = %p"
74 + "create_nx_info(%d) (dynamic rejected)"
75 + "create_nx_info(%d) = %p (already there)"
76 + "create_nx_info(%d) = %p (new)"
77 + "dealloc_nx_info(%p)"
78 + 1 2 "alloc_nx_info(%d)*"
79 + "create_nx_info(%d)*"
80 + 2 4 "get_nx_info(%p[#%d.%d])"
81 + "put_nx_info(%p[#%d.%d])"
82 + 3 8 "claim_nx_info(%p[#%d.%d.%d]) %p"
83 + "clr_nx_info(%p[#%d.%d])"
84 + "init_nx_info(%p[#%d.%d])"
85 + "release_nx_info(%p[#%d.%d.%d]) %p"
86 + "set_nx_info(%p[#%d.%d])"
87 + 4 10 "__hash_nx_info: %p[#%d]"
88 + "__nx_dynamic_id: [#%d]"
89 + "__unhash_nx_info: %p[#%d.%d.%d]"
90 + 5 20 "moved task %p into nxi:%p[#%d]"
91 + "nx_migrate_task(%p,%p[#%d.%d.%d])"
92 + "task_get_nx_info(%p)"
93 + 6 40 "nx_clear_persistent(%p[#%d])"
97 + 0 1 "quota_sync_dqh(%p,%d) discard inode %p"
98 + 1 2 "quota_sync_dqh(%p,%d)"
99 + "sync_dquots(%p,%d)"
100 + "sync_dquots_dqh(%p,%d)"
101 + 3 8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
105 + 0 1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
106 + 1 2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
107 + 4 10 "%s: (%s %s) returned %s with %d"
111 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
112 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
116 + 0 1 "__lookup_vx_info(#%u): %p[#%u]"
117 + "alloc_vx_info(%d) = %p"
118 + "alloc_vx_info(%d)*"
119 + "create_vx_info(%d) (dynamic rejected)"
120 + "create_vx_info(%d) = %p (already there)"
121 + "create_vx_info(%d) = %p (new)"
122 + "dealloc_vx_info(%p)"
123 + "loc_vx_info(%d) = %p (found)"
124 + "loc_vx_info(%d) = %p (new)"
125 + "loc_vx_info(%d) = %p (not available)"
126 + 1 2 "create_vx_info(%d)*"
128 + 2 4 "get_vx_info(%p[#%d.%d])"
129 + "put_vx_info(%p[#%d.%d])"
130 + 3 8 "claim_vx_info(%p[#%d.%d.%d]) %p"
131 + "clr_vx_info(%p[#%d.%d])"
132 + "init_vx_info(%p[#%d.%d])"
133 + "release_vx_info(%p[#%d.%d.%d]) %p"
134 + "set_vx_info(%p[#%d.%d])"
135 + 4 10 "__hash_vx_info: %p[#%d]"
136 + "__unhash_vx_info: %p[#%d.%d.%d]"
137 + "__vx_dynamic_id: [#%d]"
138 + 5 20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
139 + "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
140 + "moved task %p into vxi:%p[#%d]"
141 + "task_get_vx_info(%p)"
142 + "vx_migrate_task(%p,%p[#%d.%d])"
143 + 6 40 "vx_clear_persistent(%p[#%d])"
144 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
145 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
146 + "vx_set_persistent(%p[#%d])"
147 + "vx_set_reaper(%p[#%d],%p[#%d,%d])"
148 + 7 80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
153 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
154 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
156 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
157 + "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
158 + "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
159 diff -NurpP --minimal linux-3.1.1/arch/alpha/Kconfig linux-3.1.1-vs2.3.2/arch/alpha/Kconfig
160 --- linux-3.1.1/arch/alpha/Kconfig 2011-10-24 18:44:54.000000000 +0200
161 +++ linux-3.1.1-vs2.3.2/arch/alpha/Kconfig 2011-10-24 18:53:33.000000000 +0200
162 @@ -670,6 +670,8 @@ config DUMMY_CONSOLE
166 +source "kernel/vserver/Kconfig"
168 source "security/Kconfig"
170 source "crypto/Kconfig"
171 diff -NurpP --minimal linux-3.1.1/arch/alpha/kernel/entry.S linux-3.1.1-vs2.3.2/arch/alpha/kernel/entry.S
172 --- linux-3.1.1/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
173 +++ linux-3.1.1-vs2.3.2/arch/alpha/kernel/entry.S 2011-10-24 18:53:33.000000000 +0200
174 @@ -860,24 +860,15 @@ sys_getxgid:
181 - ldq $2, TI_TASK($8)
183 - /* See linux/kernel/timer.c sys_getppid for discussion
184 - about this loop. */
185 - ldq $3, TASK_GROUP_LEADER($2)
186 - ldq $4, TASK_REAL_PARENT($3)
187 - ldl $0, TASK_TGID($2)
188 -1: ldl $1, TASK_TGID($4)
192 - ldq $3, TASK_GROUP_LEADER($2)
193 - ldq $4, TASK_REAL_PARENT($3)
199 + jsr $26, do_getxpid
206 diff -NurpP --minimal linux-3.1.1/arch/alpha/kernel/ptrace.c linux-3.1.1-vs2.3.2/arch/alpha/kernel/ptrace.c
207 --- linux-3.1.1/arch/alpha/kernel/ptrace.c 2011-01-05 21:48:40.000000000 +0100
208 +++ linux-3.1.1-vs2.3.2/arch/alpha/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
210 #include <linux/user.h>
211 #include <linux/security.h>
212 #include <linux/signal.h>
213 +#include <linux/vs_base.h>
215 #include <asm/uaccess.h>
216 #include <asm/pgtable.h>
217 diff -NurpP --minimal linux-3.1.1/arch/alpha/kernel/systbls.S linux-3.1.1-vs2.3.2/arch/alpha/kernel/systbls.S
218 --- linux-3.1.1/arch/alpha/kernel/systbls.S 2011-10-24 18:44:54.000000000 +0200
219 +++ linux-3.1.1-vs2.3.2/arch/alpha/kernel/systbls.S 2011-10-24 18:53:33.000000000 +0200
220 @@ -446,7 +446,7 @@ sys_call_table:
221 .quad sys_stat64 /* 425 */
224 - .quad sys_ni_syscall /* sys_vserver */
225 + .quad sys_vserver /* sys_vserver */
226 .quad sys_ni_syscall /* sys_mbind */
227 .quad sys_ni_syscall /* sys_get_mempolicy */
228 .quad sys_ni_syscall /* sys_set_mempolicy */
229 diff -NurpP --minimal linux-3.1.1/arch/alpha/kernel/traps.c linux-3.1.1-vs2.3.2/arch/alpha/kernel/traps.c
230 --- linux-3.1.1/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
231 +++ linux-3.1.1-vs2.3.2/arch/alpha/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
232 @@ -183,7 +183,8 @@ die_if_kernel(char * str, struct pt_regs
234 printk("CPU %d ", hard_smp_processor_id());
236 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
237 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
238 + task_pid_nr(current), current->xid, str, err);
239 dik_show_regs(regs, r9_15);
240 add_taint(TAINT_DIE);
241 dik_show_trace((unsigned long *)(regs+1));
242 diff -NurpP --minimal linux-3.1.1/arch/arm/Kconfig linux-3.1.1-vs2.3.2/arch/arm/Kconfig
243 --- linux-3.1.1/arch/arm/Kconfig 2011-10-24 18:44:54.000000000 +0200
244 +++ linux-3.1.1-vs2.3.2/arch/arm/Kconfig 2011-10-24 18:53:33.000000000 +0200
245 @@ -2111,6 +2111,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.1.1/arch/arm/kernel/calls.S linux-3.1.1-vs2.3.2/arch/arm/kernel/calls.S
255 --- linux-3.1.1/arch/arm/kernel/calls.S 2011-10-24 18:44:54.000000000 +0200
256 +++ linux-3.1.1-vs2.3.2/arch/arm/kernel/calls.S 2011-10-24 18:53:33.000000000 +0200
258 /* 310 */ CALL(sys_request_key)
260 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
261 -/* vserver */ CALL(sys_ni_syscall)
264 /* 315 */ CALL(sys_ioprio_get)
265 CALL(sys_inotify_init)
266 diff -NurpP --minimal linux-3.1.1/arch/arm/kernel/process.c linux-3.1.1-vs2.3.2/arch/arm/kernel/process.c
267 --- linux-3.1.1/arch/arm/kernel/process.c 2011-10-24 18:44:54.000000000 +0200
268 +++ linux-3.1.1-vs2.3.2/arch/arm/kernel/process.c 2011-10-24 18:53:33.000000000 +0200
269 @@ -317,7 +317,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.1.1/arch/arm/kernel/traps.c linux-3.1.1-vs2.3.2/arch/arm/kernel/traps.c
280 --- linux-3.1.1/arch/arm/kernel/traps.c 2011-10-24 18:44:54.000000000 +0200
281 +++ linux-3.1.1-vs2.3.2/arch/arm/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
282 @@ -242,8 +242,8 @@ static int __die(const char *str, int er
286 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
287 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
288 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
289 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
291 if (!user_mode(regs) || in_interrupt()) {
292 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
293 diff -NurpP --minimal linux-3.1.1/arch/cris/Kconfig linux-3.1.1-vs2.3.2/arch/cris/Kconfig
294 --- linux-3.1.1/arch/cris/Kconfig 2011-07-22 11:17:35.000000000 +0200
295 +++ linux-3.1.1-vs2.3.2/arch/cris/Kconfig 2011-10-24 18:53:33.000000000 +0200
296 @@ -678,6 +678,8 @@ source "drivers/staging/Kconfig"
298 source "arch/cris/Kconfig.debug"
300 +source "kernel/vserver/Kconfig"
302 source "security/Kconfig"
304 source "crypto/Kconfig"
305 diff -NurpP --minimal linux-3.1.1/arch/frv/kernel/kernel_thread.S linux-3.1.1-vs2.3.2/arch/frv/kernel/kernel_thread.S
306 --- linux-3.1.1/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
307 +++ linux-3.1.1-vs2.3.2/arch/frv/kernel/kernel_thread.S 2011-10-24 18:53:33.000000000 +0200
308 @@ -37,7 +37,7 @@ kernel_thread:
310 # start by forking the current process, but with shared VM
311 setlos.p #__NR_clone,gr7 ; syscall number
312 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
313 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
314 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
316 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
317 diff -NurpP --minimal linux-3.1.1/arch/h8300/Kconfig linux-3.1.1-vs2.3.2/arch/h8300/Kconfig
318 --- linux-3.1.1/arch/h8300/Kconfig 2011-07-22 11:17:35.000000000 +0200
319 +++ linux-3.1.1-vs2.3.2/arch/h8300/Kconfig 2011-10-24 18:53:33.000000000 +0200
320 @@ -213,6 +213,8 @@ source "fs/Kconfig"
322 source "arch/h8300/Kconfig.debug"
324 +source "kernel/vserver/Kconfig"
326 source "security/Kconfig"
328 source "crypto/Kconfig"
329 diff -NurpP --minimal linux-3.1.1/arch/ia64/Kconfig linux-3.1.1-vs2.3.2/arch/ia64/Kconfig
330 --- linux-3.1.1/arch/ia64/Kconfig 2011-10-24 18:44:58.000000000 +0200
331 +++ linux-3.1.1-vs2.3.2/arch/ia64/Kconfig 2011-10-24 18:53:33.000000000 +0200
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.1.1/arch/ia64/include/asm/tlb.h linux-3.1.1-vs2.3.2/arch/ia64/include/asm/tlb.h
342 --- linux-3.1.1/arch/ia64/include/asm/tlb.h 2011-07-22 11:17:35.000000000 +0200
343 +++ linux-3.1.1-vs2.3.2/arch/ia64/include/asm/tlb.h 2011-10-24 18:53:33.000000000 +0200
345 #include <linux/mm.h>
346 #include <linux/pagemap.h>
347 #include <linux/swap.h>
348 +#include <linux/vs_memory.h>
350 #include <asm/pgalloc.h>
351 #include <asm/processor.h>
352 diff -NurpP --minimal linux-3.1.1/arch/ia64/kernel/entry.S linux-3.1.1-vs2.3.2/arch/ia64/kernel/entry.S
353 --- linux-3.1.1/arch/ia64/kernel/entry.S 2011-10-24 18:44:58.000000000 +0200
354 +++ linux-3.1.1-vs2.3.2/arch/ia64/kernel/entry.S 2011-10-24 18:53:33.000000000 +0200
355 @@ -1714,7 +1714,7 @@ sys_call_table:
357 data8 sys_mq_getsetattr
359 - data8 sys_ni_syscall // reserved for vserver
361 data8 sys_waitid // 1270
363 data8 sys_request_key
364 diff -NurpP --minimal linux-3.1.1/arch/ia64/kernel/perfmon.c linux-3.1.1-vs2.3.2/arch/ia64/kernel/perfmon.c
365 --- linux-3.1.1/arch/ia64/kernel/perfmon.c 2011-03-15 18:06:39.000000000 +0100
366 +++ linux-3.1.1-vs2.3.2/arch/ia64/kernel/perfmon.c 2011-10-24 18:53:33.000000000 +0200
368 #include <linux/completion.h>
369 #include <linux/tracehook.h>
370 #include <linux/slab.h>
371 +#include <linux/vs_memory.h>
373 #include <asm/errno.h>
374 #include <asm/intrinsics.h>
375 diff -NurpP --minimal linux-3.1.1/arch/ia64/kernel/process.c linux-3.1.1-vs2.3.2/arch/ia64/kernel/process.c
376 --- linux-3.1.1/arch/ia64/kernel/process.c 2011-03-15 18:06:39.000000000 +0100
377 +++ linux-3.1.1-vs2.3.2/arch/ia64/kernel/process.c 2011-10-24 18:53:33.000000000 +0200
378 @@ -109,8 +109,8 @@ show_regs (struct pt_regs *regs)
379 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
382 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
383 - smp_processor_id(), current->comm);
384 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
385 + current->xid, smp_processor_id(), current->comm);
386 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
387 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
388 init_utsname()->release);
389 diff -NurpP --minimal linux-3.1.1/arch/ia64/kernel/ptrace.c linux-3.1.1-vs2.3.2/arch/ia64/kernel/ptrace.c
390 --- linux-3.1.1/arch/ia64/kernel/ptrace.c 2011-01-05 21:48:59.000000000 +0100
391 +++ linux-3.1.1-vs2.3.2/arch/ia64/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
393 #include <linux/regset.h>
394 #include <linux/elf.h>
395 #include <linux/tracehook.h>
396 +#include <linux/vs_base.h>
398 #include <asm/pgtable.h>
399 #include <asm/processor.h>
400 diff -NurpP --minimal linux-3.1.1/arch/ia64/kernel/traps.c linux-3.1.1-vs2.3.2/arch/ia64/kernel/traps.c
401 --- linux-3.1.1/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
402 +++ linux-3.1.1-vs2.3.2/arch/ia64/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
403 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
406 if (++die.lock_owner_depth < 3) {
407 - printk("%s[%d]: %s %ld [%d]\n",
408 - current->comm, task_pid_nr(current), str, err, ++die_counter);
409 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
410 + current->comm, task_pid_nr(current), current->xid,
411 + str, err, ++die_counter);
412 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
415 @@ -323,8 +324,9 @@ handle_fpu_swa (int fp_fault, struct pt_
416 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
417 last.time = current_jiffies + 5 * HZ;
419 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
420 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
421 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
422 + current->comm, task_pid_nr(current), current->xid,
423 + regs->cr_iip + ia64_psr(regs)->ri, isr);
427 diff -NurpP --minimal linux-3.1.1/arch/ia64/mm/fault.c linux-3.1.1-vs2.3.2/arch/ia64/mm/fault.c
428 --- linux-3.1.1/arch/ia64/mm/fault.c 2011-07-22 11:17:35.000000000 +0200
429 +++ linux-3.1.1-vs2.3.2/arch/ia64/mm/fault.c 2011-10-24 18:53:33.000000000 +0200
431 #include <linux/kprobes.h>
432 #include <linux/kdebug.h>
433 #include <linux/prefetch.h>
434 +#include <linux/vs_memory.h>
436 #include <asm/pgtable.h>
437 #include <asm/processor.h>
438 diff -NurpP --minimal linux-3.1.1/arch/m32r/kernel/traps.c linux-3.1.1-vs2.3.2/arch/m32r/kernel/traps.c
439 --- linux-3.1.1/arch/m32r/kernel/traps.c 2011-10-24 18:44:58.000000000 +0200
440 +++ linux-3.1.1-vs2.3.2/arch/m32r/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
441 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
443 printk("SPI: %08lx\n", sp);
445 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
446 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
447 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
448 + current->comm, task_pid_nr(current), current->xid,
449 + 0xffff & i, 4096+(unsigned long)current);
452 * When in-kernel, we also print out the stack and code at the
453 diff -NurpP --minimal linux-3.1.1/arch/m68k/Kconfig linux-3.1.1-vs2.3.2/arch/m68k/Kconfig
454 --- linux-3.1.1/arch/m68k/Kconfig 2011-10-24 18:44:58.000000000 +0200
455 +++ linux-3.1.1-vs2.3.2/arch/m68k/Kconfig 2011-10-24 18:53:33.000000000 +0200
456 @@ -246,6 +246,8 @@ source "fs/Kconfig"
458 source "arch/m68k/Kconfig.debug"
460 +source "kernel/vserver/Kconfig"
462 source "security/Kconfig"
464 source "crypto/Kconfig"
465 diff -NurpP --minimal linux-3.1.1/arch/mips/Kconfig linux-3.1.1-vs2.3.2/arch/mips/Kconfig
466 --- linux-3.1.1/arch/mips/Kconfig 2011-10-24 18:44:59.000000000 +0200
467 +++ linux-3.1.1-vs2.3.2/arch/mips/Kconfig 2011-10-24 18:53:33.000000000 +0200
468 @@ -2495,6 +2495,8 @@ source "fs/Kconfig"
470 source "arch/mips/Kconfig.debug"
472 +source "kernel/vserver/Kconfig"
474 source "security/Kconfig"
476 source "crypto/Kconfig"
477 diff -NurpP --minimal linux-3.1.1/arch/mips/kernel/ptrace.c linux-3.1.1-vs2.3.2/arch/mips/kernel/ptrace.c
478 --- linux-3.1.1/arch/mips/kernel/ptrace.c 2011-07-22 11:17:36.000000000 +0200
479 +++ linux-3.1.1-vs2.3.2/arch/mips/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
481 #include <linux/security.h>
482 #include <linux/audit.h>
483 #include <linux/seccomp.h>
484 +#include <linux/vs_base.h>
486 #include <asm/byteorder.h>
488 @@ -263,6 +264,9 @@ long arch_ptrace(struct task_struct *chi
489 void __user *datavp = (void __user *) data;
490 unsigned long __user *datalp = (void __user *) data;
492 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
496 /* when I and D space are separate, these will need to be fixed. */
497 case PTRACE_PEEKTEXT: /* read word at location addr. */
498 diff -NurpP --minimal linux-3.1.1/arch/mips/kernel/scall32-o32.S linux-3.1.1-vs2.3.2/arch/mips/kernel/scall32-o32.S
499 --- linux-3.1.1/arch/mips/kernel/scall32-o32.S 2011-10-24 18:44:59.000000000 +0200
500 +++ linux-3.1.1-vs2.3.2/arch/mips/kernel/scall32-o32.S 2011-10-24 18:53:33.000000000 +0200
501 @@ -523,7 +523,7 @@ einval: li v0, -ENOSYS
502 sys sys_mq_timedreceive 5
503 sys sys_mq_notify 2 /* 4275 */
504 sys sys_mq_getsetattr 3
505 - sys sys_ni_syscall 0 /* sys_vserver */
508 sys sys_ni_syscall 0 /* available, was setaltroot */
509 sys sys_add_key 5 /* 4280 */
510 diff -NurpP --minimal linux-3.1.1/arch/mips/kernel/scall64-64.S linux-3.1.1-vs2.3.2/arch/mips/kernel/scall64-64.S
511 --- linux-3.1.1/arch/mips/kernel/scall64-64.S 2011-10-24 18:44:59.000000000 +0200
512 +++ linux-3.1.1-vs2.3.2/arch/mips/kernel/scall64-64.S 2011-10-24 18:53:33.000000000 +0200
513 @@ -362,7 +362,7 @@ sys_call_table:
514 PTR sys_mq_timedreceive
516 PTR sys_mq_getsetattr /* 5235 */
517 - PTR sys_ni_syscall /* sys_vserver */
520 PTR sys_ni_syscall /* available, was setaltroot */
522 diff -NurpP --minimal linux-3.1.1/arch/mips/kernel/scall64-n32.S linux-3.1.1-vs2.3.2/arch/mips/kernel/scall64-n32.S
523 --- linux-3.1.1/arch/mips/kernel/scall64-n32.S 2011-10-24 18:44:59.000000000 +0200
524 +++ linux-3.1.1-vs2.3.2/arch/mips/kernel/scall64-n32.S 2011-10-24 18:53:33.000000000 +0200
525 @@ -361,7 +361,7 @@ EXPORT(sysn32_call_table)
526 PTR compat_sys_mq_timedreceive
527 PTR compat_sys_mq_notify
528 PTR compat_sys_mq_getsetattr
529 - PTR sys_ni_syscall /* 6240, sys_vserver */
530 + PTR sys32_vserver /* 6240 */
531 PTR compat_sys_waitid
532 PTR sys_ni_syscall /* available, was setaltroot */
534 diff -NurpP --minimal linux-3.1.1/arch/mips/kernel/scall64-o32.S linux-3.1.1-vs2.3.2/arch/mips/kernel/scall64-o32.S
535 --- linux-3.1.1/arch/mips/kernel/scall64-o32.S 2011-10-24 18:44:59.000000000 +0200
536 +++ linux-3.1.1-vs2.3.2/arch/mips/kernel/scall64-o32.S 2011-10-24 18:53:33.000000000 +0200
537 @@ -480,7 +480,7 @@ sys_call_table:
538 PTR compat_sys_mq_timedreceive
539 PTR compat_sys_mq_notify /* 4275 */
540 PTR compat_sys_mq_getsetattr
541 - PTR sys_ni_syscall /* sys_vserver */
544 PTR sys_ni_syscall /* available, was setaltroot */
545 PTR sys_add_key /* 4280 */
546 diff -NurpP --minimal linux-3.1.1/arch/mips/kernel/traps.c linux-3.1.1-vs2.3.2/arch/mips/kernel/traps.c
547 --- linux-3.1.1/arch/mips/kernel/traps.c 2011-10-24 18:44:59.000000000 +0200
548 +++ linux-3.1.1-vs2.3.2/arch/mips/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
549 @@ -344,9 +344,10 @@ void show_registers(struct pt_regs *regs
553 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
554 - current->comm, current->pid, current_thread_info(), current,
555 - field, current_thread_info()->tp_value);
556 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
557 + current->comm, task_pid_nr(current), current->xid,
558 + current_thread_info(), current,
559 + field, current_thread_info()->tp_value);
560 if (cpu_has_userlocal) {
563 diff -NurpP --minimal linux-3.1.1/arch/parisc/Kconfig linux-3.1.1-vs2.3.2/arch/parisc/Kconfig
564 --- linux-3.1.1/arch/parisc/Kconfig 2011-10-24 18:44:59.000000000 +0200
565 +++ linux-3.1.1-vs2.3.2/arch/parisc/Kconfig 2011-10-24 18:53:33.000000000 +0200
566 @@ -280,6 +280,8 @@ source "fs/Kconfig"
568 source "arch/parisc/Kconfig.debug"
570 +source "kernel/vserver/Kconfig"
572 source "security/Kconfig"
574 source "crypto/Kconfig"
575 diff -NurpP --minimal linux-3.1.1/arch/parisc/kernel/syscall_table.S linux-3.1.1-vs2.3.2/arch/parisc/kernel/syscall_table.S
576 --- linux-3.1.1/arch/parisc/kernel/syscall_table.S 2011-10-24 18:45:00.000000000 +0200
577 +++ linux-3.1.1-vs2.3.2/arch/parisc/kernel/syscall_table.S 2011-10-24 18:53:33.000000000 +0200
579 ENTRY_COMP(mbind) /* 260 */
580 ENTRY_COMP(get_mempolicy)
581 ENTRY_COMP(set_mempolicy)
582 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
583 + ENTRY_DIFF(vserver)
585 ENTRY_SAME(request_key) /* 265 */
587 diff -NurpP --minimal linux-3.1.1/arch/parisc/kernel/traps.c linux-3.1.1-vs2.3.2/arch/parisc/kernel/traps.c
588 --- linux-3.1.1/arch/parisc/kernel/traps.c 2011-10-24 18:45:00.000000000 +0200
589 +++ linux-3.1.1-vs2.3.2/arch/parisc/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
590 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
594 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
595 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
596 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
597 + current->comm, task_pid_nr(current), current->xid,
598 + str, err, regs->iaoq[0]);
599 #ifdef PRINT_USER_FAULTS
600 /* XXX for debugging only */
602 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
603 pdc_console_restart();
606 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
607 - current->comm, task_pid_nr(current), str, err);
608 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
609 + current->comm, task_pid_nr(current), current->xid, str, err);
611 /* Wot's wrong wif bein' racy? */
612 if (current->thread.flags & PARISC_KERNEL_DEATH) {
613 diff -NurpP --minimal linux-3.1.1/arch/parisc/mm/fault.c linux-3.1.1-vs2.3.2/arch/parisc/mm/fault.c
614 --- linux-3.1.1/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
615 +++ linux-3.1.1-vs2.3.2/arch/parisc/mm/fault.c 2011-10-24 18:53:33.000000000 +0200
616 @@ -237,8 +237,9 @@ bad_area:
618 #ifdef PRINT_USER_FAULTS
619 printk(KERN_DEBUG "\n");
620 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
621 - task_pid_nr(tsk), tsk->comm, code, address);
622 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
623 + "command='%s' type=%lu address=0x%08lx\n",
624 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
626 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
627 vma->vm_start, vma->vm_end);
628 diff -NurpP --minimal linux-3.1.1/arch/powerpc/Kconfig linux-3.1.1-vs2.3.2/arch/powerpc/Kconfig
629 --- linux-3.1.1/arch/powerpc/Kconfig 2011-10-24 18:45:00.000000000 +0200
630 +++ linux-3.1.1-vs2.3.2/arch/powerpc/Kconfig 2011-10-24 18:53:33.000000000 +0200
631 @@ -981,6 +981,8 @@ source "lib/Kconfig"
633 source "arch/powerpc/Kconfig.debug"
635 +source "kernel/vserver/Kconfig"
637 source "security/Kconfig"
640 diff -NurpP --minimal linux-3.1.1/arch/powerpc/include/asm/unistd.h linux-3.1.1-vs2.3.2/arch/powerpc/include/asm/unistd.h
641 --- linux-3.1.1/arch/powerpc/include/asm/unistd.h 2011-07-22 11:17:40.000000000 +0200
642 +++ linux-3.1.1-vs2.3.2/arch/powerpc/include/asm/unistd.h 2011-10-24 18:53:33.000000000 +0200
645 #define __NR_rtas 255
646 #define __NR_sys_debug_setcontext 256
647 -/* Number 257 is reserved for vserver */
648 +#define __NR_vserver 257
649 #define __NR_migrate_pages 258
650 #define __NR_mbind 259
651 #define __NR_get_mempolicy 260
652 diff -NurpP --minimal linux-3.1.1/arch/powerpc/kernel/process.c linux-3.1.1-vs2.3.2/arch/powerpc/kernel/process.c
653 --- linux-3.1.1/arch/powerpc/kernel/process.c 2011-10-24 18:45:00.000000000 +0200
654 +++ linux-3.1.1-vs2.3.2/arch/powerpc/kernel/process.c 2011-10-24 18:53:33.000000000 +0200
655 @@ -662,8 +662,9 @@ void show_regs(struct pt_regs * regs)
657 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
659 - printk("TASK = %p[%d] '%s' THREAD: %p",
660 - current, task_pid_nr(current), current->comm, task_thread_info(current));
661 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
662 + current, task_pid_nr(current), current->xid,
663 + current->comm, task_thread_info(current));
666 printk(" CPU: %d", raw_smp_processor_id());
667 diff -NurpP --minimal linux-3.1.1/arch/powerpc/kernel/traps.c linux-3.1.1-vs2.3.2/arch/powerpc/kernel/traps.c
668 --- linux-3.1.1/arch/powerpc/kernel/traps.c 2011-10-24 18:45:00.000000000 +0200
669 +++ linux-3.1.1-vs2.3.2/arch/powerpc/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
670 @@ -1075,8 +1075,9 @@ void nonrecoverable_exception(struct pt_
672 void trace_syscall(struct pt_regs *regs)
674 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
675 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
676 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
677 + current, task_pid_nr(current), current->xid,
678 + regs->nip, regs->link, regs->gpr[0],
679 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
682 diff -NurpP --minimal linux-3.1.1/arch/powerpc/kernel/vdso.c linux-3.1.1-vs2.3.2/arch/powerpc/kernel/vdso.c
683 --- linux-3.1.1/arch/powerpc/kernel/vdso.c 2011-05-22 16:17:02.000000000 +0200
684 +++ linux-3.1.1-vs2.3.2/arch/powerpc/kernel/vdso.c 2011-10-24 18:53:33.000000000 +0200
686 #include <linux/security.h>
687 #include <linux/bootmem.h>
688 #include <linux/memblock.h>
689 +#include <linux/vs_memory.h>
691 #include <asm/pgtable.h>
692 #include <asm/system.h>
693 diff -NurpP --minimal linux-3.1.1/arch/s390/Kconfig linux-3.1.1-vs2.3.2/arch/s390/Kconfig
694 --- linux-3.1.1/arch/s390/Kconfig 2011-10-24 18:45:01.000000000 +0200
695 +++ linux-3.1.1-vs2.3.2/arch/s390/Kconfig 2011-10-24 18:53:33.000000000 +0200
696 @@ -629,6 +629,8 @@ source "fs/Kconfig"
698 source "arch/s390/Kconfig.debug"
700 +source "kernel/vserver/Kconfig"
702 source "security/Kconfig"
704 source "crypto/Kconfig"
705 diff -NurpP --minimal linux-3.1.1/arch/s390/include/asm/tlb.h linux-3.1.1-vs2.3.2/arch/s390/include/asm/tlb.h
706 --- linux-3.1.1/arch/s390/include/asm/tlb.h 2011-07-22 11:17:41.000000000 +0200
707 +++ linux-3.1.1-vs2.3.2/arch/s390/include/asm/tlb.h 2011-10-24 18:53:33.000000000 +0200
709 #include <linux/mm.h>
710 #include <linux/pagemap.h>
711 #include <linux/swap.h>
712 +#include <linux/vs_memory.h>
714 #include <asm/processor.h>
715 #include <asm/pgalloc.h>
716 #include <asm/tlbflush.h>
717 diff -NurpP --minimal linux-3.1.1/arch/s390/include/asm/unistd.h linux-3.1.1-vs2.3.2/arch/s390/include/asm/unistd.h
718 --- linux-3.1.1/arch/s390/include/asm/unistd.h 2011-07-22 11:17:41.000000000 +0200
719 +++ linux-3.1.1-vs2.3.2/arch/s390/include/asm/unistd.h 2011-10-24 18:53:33.000000000 +0200
721 #define __NR_clock_gettime (__NR_timer_create+6)
722 #define __NR_clock_getres (__NR_timer_create+7)
723 #define __NR_clock_nanosleep (__NR_timer_create+8)
724 -/* Number 263 is reserved for vserver */
725 +#define __NR_vserver 263
726 #define __NR_statfs64 265
727 #define __NR_fstatfs64 266
728 #define __NR_remap_file_pages 267
729 diff -NurpP --minimal linux-3.1.1/arch/s390/kernel/ptrace.c linux-3.1.1-vs2.3.2/arch/s390/kernel/ptrace.c
730 --- linux-3.1.1/arch/s390/kernel/ptrace.c 2011-11-15 16:44:51.000000000 +0100
731 +++ linux-3.1.1-vs2.3.2/arch/s390/kernel/ptrace.c 2011-11-15 17:08:44.000000000 +0100
733 #include <linux/regset.h>
734 #include <linux/tracehook.h>
735 #include <linux/seccomp.h>
736 +#include <linux/vs_base.h>
737 #include <trace/syscall.h>
738 #include <asm/compat.h>
739 #include <asm/segment.h>
740 diff -NurpP --minimal linux-3.1.1/arch/s390/kernel/syscalls.S linux-3.1.1-vs2.3.2/arch/s390/kernel/syscalls.S
741 --- linux-3.1.1/arch/s390/kernel/syscalls.S 2011-10-24 18:45:01.000000000 +0200
742 +++ linux-3.1.1-vs2.3.2/arch/s390/kernel/syscalls.S 2011-10-24 18:53:33.000000000 +0200
743 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
744 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
745 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
746 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
747 -NI_SYSCALL /* reserved for vserver */
748 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
749 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
750 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
751 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
752 diff -NurpP --minimal linux-3.1.1/arch/sh/Kconfig linux-3.1.1-vs2.3.2/arch/sh/Kconfig
753 --- linux-3.1.1/arch/sh/Kconfig 2011-10-24 18:45:01.000000000 +0200
754 +++ linux-3.1.1-vs2.3.2/arch/sh/Kconfig 2011-10-24 18:53:33.000000000 +0200
755 @@ -894,6 +894,8 @@ source "fs/Kconfig"
757 source "arch/sh/Kconfig.debug"
759 +source "kernel/vserver/Kconfig"
761 source "security/Kconfig"
763 source "crypto/Kconfig"
764 diff -NurpP --minimal linux-3.1.1/arch/sh/kernel/irq.c linux-3.1.1-vs2.3.2/arch/sh/kernel/irq.c
765 --- linux-3.1.1/arch/sh/kernel/irq.c 2011-07-22 11:17:41.000000000 +0200
766 +++ linux-3.1.1-vs2.3.2/arch/sh/kernel/irq.c 2011-10-24 18:53:33.000000000 +0200
768 #include <linux/ftrace.h>
769 #include <linux/delay.h>
770 #include <linux/ratelimit.h>
771 +// #include <linux/vs_context.h>
772 #include <asm/processor.h>
773 #include <asm/machvec.h>
774 #include <asm/uaccess.h>
775 diff -NurpP --minimal linux-3.1.1/arch/sh/kernel/vsyscall/vsyscall.c linux-3.1.1-vs2.3.2/arch/sh/kernel/vsyscall/vsyscall.c
776 --- linux-3.1.1/arch/sh/kernel/vsyscall/vsyscall.c 2011-05-22 16:17:07.000000000 +0200
777 +++ linux-3.1.1-vs2.3.2/arch/sh/kernel/vsyscall/vsyscall.c 2011-10-24 18:53:33.000000000 +0200
779 #include <linux/elf.h>
780 #include <linux/sched.h>
781 #include <linux/err.h>
782 +#include <linux/vs_memory.h>
785 * Should the kernel map a VDSO page into processes and pass its
786 diff -NurpP --minimal linux-3.1.1/arch/sparc/Kconfig linux-3.1.1-vs2.3.2/arch/sparc/Kconfig
787 --- linux-3.1.1/arch/sparc/Kconfig 2011-10-24 18:45:02.000000000 +0200
788 +++ linux-3.1.1-vs2.3.2/arch/sparc/Kconfig 2011-10-24 18:53:33.000000000 +0200
789 @@ -600,6 +600,8 @@ source "fs/Kconfig"
791 source "arch/sparc/Kconfig.debug"
793 +source "kernel/vserver/Kconfig"
795 source "security/Kconfig"
797 source "crypto/Kconfig"
798 diff -NurpP --minimal linux-3.1.1/arch/sparc/include/asm/tlb_64.h linux-3.1.1-vs2.3.2/arch/sparc/include/asm/tlb_64.h
799 --- linux-3.1.1/arch/sparc/include/asm/tlb_64.h 2011-07-22 11:17:42.000000000 +0200
800 +++ linux-3.1.1-vs2.3.2/arch/sparc/include/asm/tlb_64.h 2011-10-24 18:53:33.000000000 +0200
803 #include <linux/swap.h>
804 #include <linux/pagemap.h>
805 +#include <linux/vs_memory.h>
806 #include <asm/pgalloc.h>
807 #include <asm/tlbflush.h>
808 #include <asm/mmu_context.h>
809 diff -NurpP --minimal linux-3.1.1/arch/sparc/include/asm/unistd.h linux-3.1.1-vs2.3.2/arch/sparc/include/asm/unistd.h
810 --- linux-3.1.1/arch/sparc/include/asm/unistd.h 2011-07-22 11:17:42.000000000 +0200
811 +++ linux-3.1.1-vs2.3.2/arch/sparc/include/asm/unistd.h 2011-10-24 18:53:33.000000000 +0200
813 #define __NR_timer_getoverrun 264
814 #define __NR_timer_delete 265
815 #define __NR_timer_create 266
816 -/* #define __NR_vserver 267 Reserved for VSERVER */
817 +#define __NR_vserver 267
818 #define __NR_io_setup 268
819 #define __NR_io_destroy 269
820 #define __NR_io_submit 270
821 diff -NurpP --minimal linux-3.1.1/arch/sparc/kernel/systbls_32.S linux-3.1.1-vs2.3.2/arch/sparc/kernel/systbls_32.S
822 --- linux-3.1.1/arch/sparc/kernel/systbls_32.S 2011-10-24 18:45:02.000000000 +0200
823 +++ linux-3.1.1-vs2.3.2/arch/sparc/kernel/systbls_32.S 2011-10-24 18:53:33.000000000 +0200
824 @@ -70,7 +70,7 @@ sys_call_table:
825 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_ni_syscall
826 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
827 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
828 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
829 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
830 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
831 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
832 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
833 diff -NurpP --minimal linux-3.1.1/arch/sparc/kernel/systbls_64.S linux-3.1.1-vs2.3.2/arch/sparc/kernel/systbls_64.S
834 --- linux-3.1.1/arch/sparc/kernel/systbls_64.S 2011-10-24 18:45:02.000000000 +0200
835 +++ linux-3.1.1-vs2.3.2/arch/sparc/kernel/systbls_64.S 2011-10-24 18:53:33.000000000 +0200
836 @@ -71,7 +71,7 @@ sys_call_table32:
837 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys_nis_syscall
838 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
839 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
840 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
841 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
842 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
843 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
844 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
845 @@ -148,7 +148,7 @@ sys_call_table:
846 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nis_syscall
847 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
848 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
849 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
850 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
851 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
852 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
853 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
854 diff -NurpP --minimal linux-3.1.1/arch/um/Kconfig.rest linux-3.1.1-vs2.3.2/arch/um/Kconfig.rest
855 --- linux-3.1.1/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
856 +++ linux-3.1.1-vs2.3.2/arch/um/Kconfig.rest 2011-10-24 18:53:33.000000000 +0200
857 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
861 +source "kernel/vserver/Kconfig"
863 source "security/Kconfig"
865 source "crypto/Kconfig"
866 diff -NurpP --minimal linux-3.1.1/arch/um/include/asm/tlb.h linux-3.1.1-vs2.3.2/arch/um/include/asm/tlb.h
867 --- linux-3.1.1/arch/um/include/asm/tlb.h 2011-07-22 11:17:42.000000000 +0200
868 +++ linux-3.1.1-vs2.3.2/arch/um/include/asm/tlb.h 2011-10-24 18:53:33.000000000 +0200
871 #include <linux/pagemap.h>
872 #include <linux/swap.h>
873 +#include <linux/vs_memory.h>
874 #include <asm/percpu.h>
875 #include <asm/pgalloc.h>
876 #include <asm/tlbflush.h>
877 diff -NurpP --minimal linux-3.1.1/arch/um/include/shared/kern_constants.h linux-3.1.1-vs2.3.2/arch/um/include/shared/kern_constants.h
878 --- linux-3.1.1/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
879 +++ linux-3.1.1-vs2.3.2/arch/um/include/shared/kern_constants.h 2011-10-24 18:53:33.000000000 +0200
881 +#include "../../../../include/generated/asm-offsets.h"
882 diff -NurpP --minimal linux-3.1.1/arch/um/include/shared/user_constants.h linux-3.1.1-vs2.3.2/arch/um/include/shared/user_constants.h
883 --- linux-3.1.1/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
884 +++ linux-3.1.1-vs2.3.2/arch/um/include/shared/user_constants.h 2011-10-24 18:53:33.000000000 +0200
889 + * This file was generated by arch/um/Makefile
893 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2) # */
894 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err) # */
895 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno) # */
896 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long) # */
897 +#define HOST_RBX 5 /* RBX # */
898 +#define HOST_RCX 11 /* RCX # */
899 +#define HOST_RDI 14 /* RDI # */
900 +#define HOST_RSI 13 /* RSI # */
901 +#define HOST_RDX 12 /* RDX # */
902 +#define HOST_RBP 4 /* RBP # */
903 +#define HOST_RAX 10 /* RAX # */
904 +#define HOST_R8 9 /* R8 # */
905 +#define HOST_R9 8 /* R9 # */
906 +#define HOST_R10 7 /* R10 # */
907 +#define HOST_R11 6 /* R11 # */
908 +#define HOST_R12 3 /* R12 # */
909 +#define HOST_R13 2 /* R13 # */
910 +#define HOST_R14 1 /* R14 # */
911 +#define HOST_R15 0 /* R15 # */
912 +#define HOST_ORIG_RAX 15 /* ORIG_RAX # */
913 +#define HOST_CS 17 /* CS # */
914 +#define HOST_SS 20 /* SS # */
915 +#define HOST_EFLAGS 18 /* EFLAGS # */
916 +#define HOST_IP 16 /* RIP # */
917 +#define HOST_SP 19 /* RSP # */
918 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct) # */
919 +#define UM_POLLIN 1 /* POLLIN # */
920 +#define UM_POLLPRI 2 /* POLLPRI # */
921 +#define UM_POLLOUT 4 /* POLLOUT # */
922 +#define UM_PROT_READ 1 /* PROT_READ # */
923 +#define UM_PROT_WRITE 2 /* PROT_WRITE # */
924 +#define UM_PROT_EXEC 4 /* PROT_EXEC # */
926 diff -NurpP --minimal linux-3.1.1/arch/x86/Kconfig linux-3.1.1-vs2.3.2/arch/x86/Kconfig
927 --- linux-3.1.1/arch/x86/Kconfig 2011-10-24 18:45:06.000000000 +0200
928 +++ linux-3.1.1-vs2.3.2/arch/x86/Kconfig 2011-10-24 18:53:33.000000000 +0200
929 @@ -2144,6 +2144,8 @@ source "fs/Kconfig"
931 source "arch/x86/Kconfig.debug"
933 +source "kernel/vserver/Kconfig"
935 source "security/Kconfig"
937 source "crypto/Kconfig"
938 diff -NurpP --minimal linux-3.1.1/arch/x86/ia32/ia32entry.S linux-3.1.1-vs2.3.2/arch/x86/ia32/ia32entry.S
939 --- linux-3.1.1/arch/x86/ia32/ia32entry.S 2011-10-24 18:45:06.000000000 +0200
940 +++ linux-3.1.1-vs2.3.2/arch/x86/ia32/ia32entry.S 2011-10-24 18:53:33.000000000 +0200
941 @@ -776,7 +776,7 @@ ia32_sys_call_table:
942 .quad sys_tgkill /* 270 */
943 .quad compat_sys_utimes
944 .quad sys32_fadvise64_64
945 - .quad quiet_ni_syscall /* sys_vserver */
946 + .quad sys32_vserver
948 .quad compat_sys_get_mempolicy /* 275 */
949 .quad sys_set_mempolicy
950 diff -NurpP --minimal linux-3.1.1/arch/x86/include/asm/unistd_64.h linux-3.1.1-vs2.3.2/arch/x86/include/asm/unistd_64.h
951 --- linux-3.1.1/arch/x86/include/asm/unistd_64.h 2011-10-24 18:45:07.000000000 +0200
952 +++ linux-3.1.1-vs2.3.2/arch/x86/include/asm/unistd_64.h 2011-10-24 18:53:33.000000000 +0200
953 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
954 #define __NR_utimes 235
955 __SYSCALL(__NR_utimes, sys_utimes)
956 #define __NR_vserver 236
957 -__SYSCALL(__NR_vserver, sys_ni_syscall)
958 +__SYSCALL(__NR_vserver, sys_vserver)
959 #define __NR_mbind 237
960 __SYSCALL(__NR_mbind, sys_mbind)
961 #define __NR_set_mempolicy 238
962 diff -NurpP --minimal linux-3.1.1/arch/x86/kernel/syscall_table_32.S linux-3.1.1-vs2.3.2/arch/x86/kernel/syscall_table_32.S
963 --- linux-3.1.1/arch/x86/kernel/syscall_table_32.S 2011-10-24 18:45:07.000000000 +0200
964 +++ linux-3.1.1-vs2.3.2/arch/x86/kernel/syscall_table_32.S 2011-10-24 18:53:33.000000000 +0200
965 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
966 .long sys_tgkill /* 270 */
968 .long sys_fadvise64_64
969 - .long sys_ni_syscall /* sys_vserver */
972 .long sys_get_mempolicy
973 .long sys_set_mempolicy
974 diff -NurpP --minimal linux-3.1.1/drivers/block/Kconfig linux-3.1.1-vs2.3.2/drivers/block/Kconfig
975 --- linux-3.1.1/drivers/block/Kconfig 2011-10-24 18:45:08.000000000 +0200
976 +++ linux-3.1.1-vs2.3.2/drivers/block/Kconfig 2011-10-24 18:53:33.000000000 +0200
977 @@ -288,6 +288,13 @@ config BLK_DEV_CRYPTOLOOP
979 source "drivers/block/drbd/Kconfig"
981 +config BLK_DEV_VROOT
982 + tristate "Virtual Root device support"
983 + depends on QUOTACTL
985 + Saying Y here will allow you to use quota/fs ioctls on a shared
986 + partition within a virtual server without compromising security.
989 tristate "Network block device support"
991 diff -NurpP --minimal linux-3.1.1/drivers/block/Makefile linux-3.1.1-vs2.3.2/drivers/block/Makefile
992 --- linux-3.1.1/drivers/block/Makefile 2011-07-22 11:17:44.000000000 +0200
993 +++ linux-3.1.1-vs2.3.2/drivers/block/Makefile 2011-10-24 18:53:33.000000000 +0200
994 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
995 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
996 obj-$(CONFIG_BLK_DEV_UB) += ub.o
997 obj-$(CONFIG_BLK_DEV_HD) += hd.o
998 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
1000 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
1001 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
1002 diff -NurpP --minimal linux-3.1.1/drivers/block/loop.c linux-3.1.1-vs2.3.2/drivers/block/loop.c
1003 --- linux-3.1.1/drivers/block/loop.c 2011-10-24 18:45:08.000000000 +0200
1004 +++ linux-3.1.1-vs2.3.2/drivers/block/loop.c 2011-10-24 18:53:33.000000000 +0200
1006 #include <linux/splice.h>
1007 #include <linux/sysfs.h>
1008 #include <linux/miscdevice.h>
1009 +#include <linux/vs_context.h>
1010 #include <asm/uaccess.h>
1012 static DEFINE_IDR(loop_index_idr);
1013 @@ -884,6 +885,7 @@ static int loop_set_fd(struct loop_devic
1014 lo->lo_blocksize = lo_blocksize;
1015 lo->lo_device = bdev;
1016 lo->lo_flags = lo_flags;
1017 + lo->lo_xid = vx_current_xid();
1018 lo->lo_backing_file = file;
1019 lo->transfer = transfer_none;
1021 @@ -1014,6 +1016,7 @@ static int loop_clr_fd(struct loop_devic
1022 lo->lo_encrypt_key_size = 0;
1024 lo->lo_thread = NULL;
1026 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
1027 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
1028 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
1029 @@ -1052,7 +1055,7 @@ loop_set_status(struct loop_device *lo,
1031 if (lo->lo_encrypt_key_size &&
1032 lo->lo_key_owner != uid &&
1033 - !capable(CAP_SYS_ADMIN))
1034 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
1036 if (lo->lo_state != Lo_bound)
1038 @@ -1136,7 +1139,8 @@ loop_get_status(struct loop_device *lo,
1039 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
1040 info->lo_encrypt_type =
1041 lo->lo_encryption ? lo->lo_encryption->number : 0;
1042 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
1043 + if (lo->lo_encrypt_key_size &&
1044 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
1045 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
1046 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
1047 lo->lo_encrypt_key_size);
1048 @@ -1490,6 +1494,9 @@ static int lo_open(struct block_device *
1052 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
1055 mutex_lock(&lo->lo_ctl_mutex);
1057 mutex_unlock(&lo->lo_ctl_mutex);
1058 diff -NurpP --minimal linux-3.1.1/drivers/block/vroot.c linux-3.1.1-vs2.3.2/drivers/block/vroot.c
1059 --- linux-3.1.1/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
1060 +++ linux-3.1.1-vs2.3.2/drivers/block/vroot.c 2011-10-24 18:53:33.000000000 +0200
1063 + * linux/drivers/block/vroot.c
1065 + * written by Herbert Pötzl, 9/11/2002
1066 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
1068 + * based on the loop.c code by Theodore Ts'o.
1070 + * Copyright (C) 2002-2007 by Herbert Pötzl.
1071 + * Redistribution of this file is permitted under the
1072 + * GNU General Public License.
1076 +#include <linux/module.h>
1077 +#include <linux/moduleparam.h>
1078 +#include <linux/file.h>
1079 +#include <linux/major.h>
1080 +#include <linux/blkdev.h>
1081 +#include <linux/slab.h>
1083 +#include <linux/vroot.h>
1084 +#include <linux/vs_context.h>
1087 +static int max_vroot = 8;
1089 +static struct vroot_device *vroot_dev;
1090 +static struct gendisk **disks;
1093 +static int vroot_set_dev(
1094 + struct vroot_device *vr,
1095 + struct block_device *bdev,
1098 + struct block_device *real_bdev;
1099 + struct file *file;
1100 + struct inode *inode;
1104 + if (vr->vr_state != Vr_unbound)
1113 + inode = file->f_dentry->d_inode;
1116 + if (S_ISBLK(inode->i_mode)) {
1117 + real_bdev = inode->i_bdev;
1118 + vr->vr_device = real_bdev;
1119 + __iget(real_bdev->bd_inode);
1123 + vxdprintk(VXD_CBIT(misc, 0),
1124 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1125 + vr->vr_number, VXD_DEV(real_bdev));
1127 + vr->vr_state = Vr_bound;
1136 +static int vroot_clr_dev(
1137 + struct vroot_device *vr,
1138 + struct block_device *bdev)
1140 + struct block_device *real_bdev;
1142 + if (vr->vr_state != Vr_bound)
1144 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1147 + real_bdev = vr->vr_device;
1149 + vxdprintk(VXD_CBIT(misc, 0),
1150 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1151 + vr->vr_number, VXD_DEV(real_bdev));
1154 + vr->vr_state = Vr_unbound;
1155 + vr->vr_device = NULL;
1160 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1161 + unsigned int cmd, unsigned long arg)
1163 + struct vroot_device *vr = bdev->bd_disk->private_data;
1166 + down(&vr->vr_ctl_mutex);
1168 + case VROOT_SET_DEV:
1169 + err = vroot_set_dev(vr, bdev, arg);
1171 + case VROOT_CLR_DEV:
1172 + err = vroot_clr_dev(vr, bdev);
1178 + up(&vr->vr_ctl_mutex);
1182 +static int vr_open(struct block_device *bdev, fmode_t mode)
1184 + struct vroot_device *vr = bdev->bd_disk->private_data;
1186 + down(&vr->vr_ctl_mutex);
1188 + up(&vr->vr_ctl_mutex);
1192 +static int vr_release(struct gendisk *disk, fmode_t mode)
1194 + struct vroot_device *vr = disk->private_data;
1196 + down(&vr->vr_ctl_mutex);
1198 + up(&vr->vr_ctl_mutex);
1202 +static struct block_device_operations vr_fops = {
1203 + .owner = THIS_MODULE,
1205 + .release = vr_release,
1206 + .ioctl = vr_ioctl,
1209 +static int vroot_make_request(struct request_queue *q, struct bio *bio)
1211 + printk("vroot_make_request %p, %p\n", q, bio);
1212 + bio_io_error(bio);
1216 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1218 + struct inode *inode = bdev->bd_inode;
1219 + struct vroot_device *vr;
1220 + struct block_device *real_bdev;
1221 + int minor = iminor(inode);
1223 + vr = &vroot_dev[minor];
1224 + real_bdev = vr->vr_device;
1226 + vxdprintk(VXD_CBIT(misc, 0),
1227 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1228 + vr->vr_number, VXD_DEV(real_bdev));
1230 + if (vr->vr_state != Vr_bound)
1231 + return ERR_PTR(-ENXIO);
1233 + __iget(real_bdev->bd_inode);
1240 + * And now the modules code and kernel interface.
1243 +module_param(max_vroot, int, 0);
1245 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1246 +MODULE_LICENSE("GPL");
1247 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1249 +MODULE_AUTHOR ("Herbert Pötzl");
1250 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1253 +int __init vroot_init(void)
1257 + if (max_vroot < 1 || max_vroot > 256) {
1258 + max_vroot = MAX_VROOT_DEFAULT;
1259 + printk(KERN_WARNING "vroot: invalid max_vroot "
1260 + "(must be between 1 and 256), "
1261 + "using default (%d)\n", max_vroot);
1264 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1268 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1271 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1273 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1277 + for (i = 0; i < max_vroot; i++) {
1278 + disks[i] = alloc_disk(1);
1281 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1282 + if (!disks[i]->queue)
1284 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1287 + for (i = 0; i < max_vroot; i++) {
1288 + struct vroot_device *vr = &vroot_dev[i];
1289 + struct gendisk *disk = disks[i];
1291 + memset(vr, 0, sizeof(*vr));
1292 + sema_init(&vr->vr_ctl_mutex, 1);
1293 + vr->vr_number = i;
1294 + disk->major = VROOT_MAJOR;
1295 + disk->first_minor = i;
1296 + disk->fops = &vr_fops;
1297 + sprintf(disk->disk_name, "vroot%d", i);
1298 + disk->private_data = vr;
1301 + err = register_vroot_grb(&__vroot_get_real_bdev);
1305 + for (i = 0; i < max_vroot; i++)
1306 + add_disk(disks[i]);
1307 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1312 + put_disk(disks[i]);
1317 + unregister_blkdev(VROOT_MAJOR, "vroot");
1318 + printk(KERN_ERR "vroot: ran out of memory\n");
1322 +void vroot_exit(void)
1326 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1327 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1329 + for (i = 0; i < max_vroot; i++) {
1330 + del_gendisk(disks[i]);
1331 + put_disk(disks[i]);
1333 + unregister_blkdev(VROOT_MAJOR, "vroot");
1339 +module_init(vroot_init);
1340 +module_exit(vroot_exit);
1344 +static int __init max_vroot_setup(char *str)
1346 + max_vroot = simple_strtol(str, NULL, 0);
1350 +__setup("max_vroot=", max_vroot_setup);
1354 diff -NurpP --minimal linux-3.1.1/drivers/infiniband/core/addr.c linux-3.1.1-vs2.3.2/drivers/infiniband/core/addr.c
1355 --- linux-3.1.1/drivers/infiniband/core/addr.c 2011-10-24 18:45:09.000000000 +0200
1356 +++ linux-3.1.1-vs2.3.2/drivers/infiniband/core/addr.c 2011-10-24 18:53:33.000000000 +0200
1357 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
1359 if (ipv6_addr_any(&fl6.saddr)) {
1360 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1361 - &fl6.daddr, 0, &fl6.saddr);
1362 + &fl6.daddr, 0, &fl6.saddr, NULL);
1366 diff -NurpP --minimal linux-3.1.1/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-3.1.1-vs2.3.2/drivers/infiniband/hw/ipath/ipath_user_pages.c
1367 --- linux-3.1.1/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-05-22 16:17:16.000000000 +0200
1368 +++ linux-3.1.1-vs2.3.2/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-10-24 18:53:33.000000000 +0200
1370 #include <linux/device.h>
1371 #include <linux/slab.h>
1372 #include <linux/sched.h>
1373 +#include <linux/vs_memory.h>
1375 #include "ipath_kernel.h"
1377 diff -NurpP --minimal linux-3.1.1/drivers/md/dm-ioctl.c linux-3.1.1-vs2.3.2/drivers/md/dm-ioctl.c
1378 --- linux-3.1.1/drivers/md/dm-ioctl.c 2011-10-24 18:45:10.000000000 +0200
1379 +++ linux-3.1.1-vs2.3.2/drivers/md/dm-ioctl.c 2011-10-24 18:53:33.000000000 +0200
1381 #include <linux/dm-ioctl.h>
1382 #include <linux/hdreg.h>
1383 #include <linux/compat.h>
1384 +#include <linux/vs_context.h>
1386 #include <asm/uaccess.h>
1388 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1389 unsigned int h = hash_str(str);
1391 list_for_each_entry (hc, _name_buckets + h, name_list)
1392 - if (!strcmp(hc->name, str)) {
1393 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1394 + !strcmp(hc->name, str)) {
1398 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1399 unsigned int h = hash_str(str);
1401 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1402 - if (!strcmp(hc->uuid, str)) {
1403 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1404 + !strcmp(hc->uuid, str)) {
1408 @@ -131,13 +134,15 @@ static struct hash_cell *__get_uuid_cell
1409 static struct hash_cell *__get_dev_cell(uint64_t dev)
1411 struct mapped_device *md;
1412 - struct hash_cell *hc;
1413 + struct hash_cell *hc = NULL;
1415 md = dm_get_md(huge_decode_dev(dev));
1419 - hc = dm_get_mdptr(md);
1420 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1421 + hc = dm_get_mdptr(md);
1426 @@ -445,6 +450,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1428 static int remove_all(struct dm_ioctl *param, size_t param_size)
1430 + if (!vx_check(0, VS_ADMIN))
1433 dm_hash_remove_all(1);
1434 param->data_size = 0;
1436 @@ -492,6 +500,8 @@ static int list_devices(struct dm_ioctl
1438 for (i = 0; i < NUM_BUCKETS; i++) {
1439 list_for_each_entry (hc, _name_buckets + i, name_list) {
1440 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1442 needed += sizeof(struct dm_name_list);
1443 needed += strlen(hc->name) + 1;
1444 needed += ALIGN_MASK;
1445 @@ -515,6 +525,8 @@ static int list_devices(struct dm_ioctl
1447 for (i = 0; i < NUM_BUCKETS; i++) {
1448 list_for_each_entry (hc, _name_buckets + i, name_list) {
1449 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1452 old_nl->next = (uint32_t) ((void *) nl -
1454 @@ -1604,8 +1616,8 @@ static int ctl_ioctl(uint command, struc
1456 size_t input_param_size;
1458 - /* only root can play with this */
1459 - if (!capable(CAP_SYS_ADMIN))
1460 + /* only root and certain contexts can play with this */
1461 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1464 if (_IOC_TYPE(command) != DM_IOCTL)
1465 diff -NurpP --minimal linux-3.1.1/drivers/md/dm.c linux-3.1.1-vs2.3.2/drivers/md/dm.c
1466 --- linux-3.1.1/drivers/md/dm.c 2011-10-24 18:45:10.000000000 +0200
1467 +++ linux-3.1.1-vs2.3.2/drivers/md/dm.c 2011-10-24 18:53:33.000000000 +0200
1469 #include <linux/idr.h>
1470 #include <linux/hdreg.h>
1471 #include <linux/delay.h>
1472 +#include <linux/vs_base.h>
1474 #include <trace/events/block.h>
1476 @@ -122,6 +123,7 @@ struct mapped_device {
1479 atomic_t open_count;
1482 unsigned long flags;
1484 @@ -335,6 +337,7 @@ int dm_deleting_md(struct mapped_device
1485 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1487 struct mapped_device *md;
1490 spin_lock(&_minor_lock);
1492 @@ -343,18 +346,19 @@ static int dm_blk_open(struct block_devi
1495 if (test_bit(DMF_FREEING, &md->flags) ||
1496 - dm_deleting_md(md)) {
1498 + dm_deleting_md(md))
1502 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1507 atomic_inc(&md->open_count);
1511 spin_unlock(&_minor_lock);
1513 - return md ? 0 : -ENXIO;
1517 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1518 @@ -575,6 +579,14 @@ int dm_set_geometry(struct mapped_device
1523 + * Get the xid associated with a dm device
1525 +xid_t dm_get_xid(struct mapped_device *md)
1530 /*-----------------------------------------------------------------
1532 * A more elegant soln is in the works that uses the queue
1533 @@ -1848,6 +1860,7 @@ static struct mapped_device *alloc_dev(i
1534 INIT_LIST_HEAD(&md->uevent_list);
1535 spin_lock_init(&md->uevent_lock);
1537 + md->xid = vx_current_xid();
1538 md->queue = blk_alloc_queue(GFP_KERNEL);
1541 diff -NurpP --minimal linux-3.1.1/drivers/md/dm.h linux-3.1.1-vs2.3.2/drivers/md/dm.h
1542 --- linux-3.1.1/drivers/md/dm.h 2011-10-24 18:45:10.000000000 +0200
1543 +++ linux-3.1.1-vs2.3.2/drivers/md/dm.h 2011-10-24 18:53:33.000000000 +0200
1544 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1546 struct dm_md_mempools;
1548 +xid_t dm_get_xid(struct mapped_device *md);
1550 /*-----------------------------------------------------------------
1551 * Internal table functions.
1552 *---------------------------------------------------------------*/
1553 diff -NurpP --minimal linux-3.1.1/drivers/net/tun.c linux-3.1.1-vs2.3.2/drivers/net/tun.c
1554 --- linux-3.1.1/drivers/net/tun.c 2011-10-24 18:45:17.000000000 +0200
1555 +++ linux-3.1.1-vs2.3.2/drivers/net/tun.c 2011-10-24 18:53:33.000000000 +0200
1557 #include <linux/nsproxy.h>
1558 #include <linux/virtio_net.h>
1559 #include <linux/rcupdate.h>
1560 +#include <linux/vs_network.h>
1561 #include <net/net_namespace.h>
1562 #include <net/netns/generic.h>
1563 #include <net/rtnetlink.h>
1564 @@ -121,6 +122,7 @@ struct tun_struct {
1570 struct net_device *dev;
1572 @@ -909,6 +911,7 @@ static void tun_setup(struct net_device
1576 + tun->nid = current->nid;
1578 dev->ethtool_ops = &tun_ethtool_ops;
1579 dev->destructor = tun_free_netdev;
1580 @@ -1059,7 +1062,7 @@ static int tun_set_iff(struct net *net,
1582 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1583 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1584 - !capable(CAP_NET_ADMIN))
1585 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1587 err = security_tun_dev_attach(tun->socket.sk);
1589 @@ -1073,7 +1076,7 @@ static int tun_set_iff(struct net *net,
1591 unsigned long flags = 0;
1593 - if (!capable(CAP_NET_ADMIN))
1594 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1596 err = security_tun_dev_create();
1598 @@ -1141,6 +1144,9 @@ static int tun_set_iff(struct net *net,
1600 sk->sk_destruct = tun_sock_destruct;
1602 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1605 err = tun_attach(tun, file);
1608 @@ -1322,6 +1328,16 @@ static long __tun_chr_ioctl(struct file
1609 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
1613 + if (!capable(CAP_CONTEXT))
1616 + /* Set nid owner of the device */
1617 + tun->nid = (nid_t) arg;
1619 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1623 /* Only allow setting the type when the interface is down */
1624 if (tun->dev->flags & IFF_UP) {
1625 diff -NurpP --minimal linux-3.1.1/drivers/tty/sysrq.c linux-3.1.1-vs2.3.2/drivers/tty/sysrq.c
1626 --- linux-3.1.1/drivers/tty/sysrq.c 2011-05-22 16:17:44.000000000 +0200
1627 +++ linux-3.1.1-vs2.3.2/drivers/tty/sysrq.c 2011-10-24 18:53:33.000000000 +0200
1629 #include <linux/oom.h>
1630 #include <linux/slab.h>
1631 #include <linux/input.h>
1632 +#include <linux/vserver/debug.h>
1634 #include <asm/ptrace.h>
1635 #include <asm/irq_regs.h>
1636 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
1637 .enable_mask = SYSRQ_ENABLE_RTNICE,
1641 +#ifdef CONFIG_VSERVER_DEBUG
1642 +static void sysrq_handle_vxinfo(int key)
1644 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1647 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1648 + .handler = sysrq_handle_vxinfo,
1649 + .help_msg = "conteXt",
1650 + .action_msg = "Show Context Info",
1651 + .enable_mask = SYSRQ_ENABLE_DUMP,
1655 /* Key Operations table and lock */
1656 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1658 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
1660 &sysrq_showstate_blocked_op, /* w */
1661 /* x: May be registered on ppc/powerpc for xmon */
1662 +#ifdef CONFIG_VSERVER_DEBUG
1663 + &sysrq_showvxinfo_op, /* x */
1667 /* y: May be registered on sparc64 for global register dump */
1669 &sysrq_ftrace_dump_op, /* z */
1670 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
1672 else if ((key >= 'a') && (key <= 'z'))
1673 retval = key + 10 - 'a';
1674 + else if ((key >= 'A') && (key <= 'Z'))
1675 + retval = key + 10 - 'A';
1679 diff -NurpP --minimal linux-3.1.1/drivers/tty/tty_io.c linux-3.1.1-vs2.3.2/drivers/tty/tty_io.c
1680 --- linux-3.1.1/drivers/tty/tty_io.c 2011-11-15 16:44:51.000000000 +0100
1681 +++ linux-3.1.1-vs2.3.2/drivers/tty/tty_io.c 2011-11-15 17:08:44.000000000 +0100
1684 #include <linux/kmod.h>
1685 #include <linux/nsproxy.h>
1686 +#include <linux/vs_pid.h>
1688 #undef TTY_DEBUG_HANGUP
1690 @@ -2080,7 +2081,8 @@ static int tiocsti(struct tty_struct *tt
1692 struct tty_ldisc *ld;
1694 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1695 + if (((current->signal->tty != tty) &&
1696 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1698 if (get_user(ch, p))
1700 @@ -2368,6 +2370,7 @@ static int tiocspgrp(struct tty_struct *
1702 if (get_user(pgrp_nr, p))
1704 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1708 diff -NurpP --minimal linux-3.1.1/fs/attr.c linux-3.1.1-vs2.3.2/fs/attr.c
1709 --- linux-3.1.1/fs/attr.c 2011-10-24 18:45:26.000000000 +0200
1710 +++ linux-3.1.1-vs2.3.2/fs/attr.c 2011-10-24 18:53:33.000000000 +0200
1712 #include <linux/fsnotify.h>
1713 #include <linux/fcntl.h>
1714 #include <linux/security.h>
1715 +#include <linux/proc_fs.h>
1716 +#include <linux/devpts_fs.h>
1717 +#include <linux/vs_tag.h>
1720 * inode_change_ok - check if attribute changes to an inode are allowed
1721 @@ -73,6 +76,10 @@ int inode_change_ok(const struct inode *
1725 + /* check for inode tag permission */
1726 + if (dx_permission(inode, MAY_WRITE))
1731 EXPORT_SYMBOL(inode_change_ok);
1732 @@ -143,6 +150,8 @@ void setattr_copy(struct inode *inode, c
1733 inode->i_uid = attr->ia_uid;
1734 if (ia_valid & ATTR_GID)
1735 inode->i_gid = attr->ia_gid;
1736 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1737 + inode->i_tag = attr->ia_tag;
1738 if (ia_valid & ATTR_ATIME)
1739 inode->i_atime = timespec_trunc(attr->ia_atime,
1740 inode->i_sb->s_time_gran);
1741 @@ -170,7 +179,8 @@ int notify_change(struct dentry * dentry
1742 struct timespec now;
1743 unsigned int ia_valid = attr->ia_valid;
1745 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1746 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1747 + ATTR_TAG | ATTR_TIMES_SET)) {
1748 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1751 diff -NurpP --minimal linux-3.1.1/fs/binfmt_aout.c linux-3.1.1-vs2.3.2/fs/binfmt_aout.c
1752 --- linux-3.1.1/fs/binfmt_aout.c 2010-10-21 13:07:47.000000000 +0200
1753 +++ linux-3.1.1-vs2.3.2/fs/binfmt_aout.c 2011-10-24 18:53:33.000000000 +0200
1755 #include <linux/init.h>
1756 #include <linux/coredump.h>
1757 #include <linux/slab.h>
1758 +#include <linux/vs_memory.h>
1760 #include <asm/system.h>
1761 #include <asm/uaccess.h>
1762 diff -NurpP --minimal linux-3.1.1/fs/binfmt_elf.c linux-3.1.1-vs2.3.2/fs/binfmt_elf.c
1763 --- linux-3.1.1/fs/binfmt_elf.c 2011-11-15 16:44:51.000000000 +0100
1764 +++ linux-3.1.1-vs2.3.2/fs/binfmt_elf.c 2011-11-15 17:08:44.000000000 +0100
1766 #include <linux/elf.h>
1767 #include <linux/utsname.h>
1768 #include <linux/coredump.h>
1769 +#include <linux/vs_memory.h>
1770 #include <asm/uaccess.h>
1771 #include <asm/param.h>
1772 #include <asm/page.h>
1773 diff -NurpP --minimal linux-3.1.1/fs/binfmt_flat.c linux-3.1.1-vs2.3.2/fs/binfmt_flat.c
1774 --- linux-3.1.1/fs/binfmt_flat.c 2011-07-22 11:18:05.000000000 +0200
1775 +++ linux-3.1.1-vs2.3.2/fs/binfmt_flat.c 2011-10-24 18:53:33.000000000 +0200
1777 #include <linux/init.h>
1778 #include <linux/flat.h>
1779 #include <linux/syscalls.h>
1780 +#include <linux/vs_memory.h>
1782 #include <asm/byteorder.h>
1783 #include <asm/system.h>
1784 diff -NurpP --minimal linux-3.1.1/fs/binfmt_som.c linux-3.1.1-vs2.3.2/fs/binfmt_som.c
1785 --- linux-3.1.1/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
1786 +++ linux-3.1.1-vs2.3.2/fs/binfmt_som.c 2011-10-24 18:53:33.000000000 +0200
1788 #include <linux/shm.h>
1789 #include <linux/personality.h>
1790 #include <linux/init.h>
1791 +#include <linux/vs_memory.h>
1793 #include <asm/uaccess.h>
1794 #include <asm/pgtable.h>
1795 diff -NurpP --minimal linux-3.1.1/fs/block_dev.c linux-3.1.1-vs2.3.2/fs/block_dev.c
1796 --- linux-3.1.1/fs/block_dev.c 2011-11-15 16:44:51.000000000 +0100
1797 +++ linux-3.1.1-vs2.3.2/fs/block_dev.c 2011-11-15 17:08:44.000000000 +0100
1799 #include <linux/namei.h>
1800 #include <linux/log2.h>
1801 #include <linux/kmemleak.h>
1802 +#include <linux/vs_device.h>
1803 #include <asm/uaccess.h>
1804 #include "internal.h"
1806 @@ -563,6 +564,7 @@ struct block_device *bdget(dev_t dev)
1807 bdev->bd_invalidated = 0;
1808 inode->i_mode = S_IFBLK;
1809 inode->i_rdev = dev;
1810 + inode->i_mdev = dev;
1811 inode->i_bdev = bdev;
1812 inode->i_data.a_ops = &def_blk_aops;
1813 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1814 @@ -609,6 +611,11 @@ EXPORT_SYMBOL(bdput);
1815 static struct block_device *bd_acquire(struct inode *inode)
1817 struct block_device *bdev;
1820 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1822 + inode->i_mdev = mdev;
1824 spin_lock(&bdev_lock);
1825 bdev = inode->i_bdev;
1826 @@ -619,7 +626,7 @@ static struct block_device *bd_acquire(s
1828 spin_unlock(&bdev_lock);
1830 - bdev = bdget(inode->i_rdev);
1831 + bdev = bdget(mdev);
1833 spin_lock(&bdev_lock);
1834 if (!inode->i_bdev) {
1835 diff -NurpP --minimal linux-3.1.1/fs/btrfs/ctree.h linux-3.1.1-vs2.3.2/fs/btrfs/ctree.h
1836 --- linux-3.1.1/fs/btrfs/ctree.h 2011-10-24 18:45:26.000000000 +0200
1837 +++ linux-3.1.1-vs2.3.2/fs/btrfs/ctree.h 2011-10-24 18:53:33.000000000 +0200
1838 @@ -600,11 +600,14 @@ struct btrfs_inode_item {
1839 /* modification sequence number for NFS */
1844 * a little future expansion, for more than this we can
1845 * just grow the inode item and version it
1847 - __le64 reserved[4];
1848 + __le16 reserved16;
1849 + __le32 reserved32;
1850 + __le64 reserved[3];
1851 struct btrfs_timespec atime;
1852 struct btrfs_timespec ctime;
1853 struct btrfs_timespec mtime;
1854 @@ -1364,6 +1367,8 @@ struct btrfs_ioctl_defrag_range_args {
1855 #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16)
1856 #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17)
1858 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1860 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1861 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1862 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
1863 @@ -1571,6 +1576,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1864 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1865 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1866 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1867 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1868 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1869 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1870 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1871 @@ -1624,6 +1630,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1873 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1875 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1876 +#define BTRFS_INODE_BARRIER (1 << 25)
1877 +#define BTRFS_INODE_COW (1 << 26)
1880 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1882 @@ -2603,6 +2613,7 @@ extern const struct dentry_operations bt
1883 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1884 void btrfs_update_iflags(struct inode *inode);
1885 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1886 +int btrfs_sync_flags(struct inode *inode, int, int);
1887 int btrfs_defrag_file(struct inode *inode, struct file *file,
1888 struct btrfs_ioctl_defrag_range_args *range,
1889 u64 newer_than, unsigned long max_pages);
1890 diff -NurpP --minimal linux-3.1.1/fs/btrfs/disk-io.c linux-3.1.1-vs2.3.2/fs/btrfs/disk-io.c
1891 --- linux-3.1.1/fs/btrfs/disk-io.c 2011-10-24 18:45:26.000000000 +0200
1892 +++ linux-3.1.1-vs2.3.2/fs/btrfs/disk-io.c 2011-10-24 18:53:33.000000000 +0200
1893 @@ -1794,6 +1794,9 @@ struct btrfs_root *open_ctree(struct sup
1897 + if (btrfs_test_opt(tree_root, TAGGED))
1898 + sb->s_flags |= MS_TAGGED;
1900 features = btrfs_super_incompat_flags(disk_super) &
1901 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1903 diff -NurpP --minimal linux-3.1.1/fs/btrfs/inode.c linux-3.1.1-vs2.3.2/fs/btrfs/inode.c
1904 --- linux-3.1.1/fs/btrfs/inode.c 2011-10-24 18:45:26.000000000 +0200
1905 +++ linux-3.1.1-vs2.3.2/fs/btrfs/inode.c 2011-10-24 18:53:33.000000000 +0200
1907 #include <linux/falloc.h>
1908 #include <linux/slab.h>
1909 #include <linux/ratelimit.h>
1910 +#include <linux/vs_tag.h>
1913 #include "disk-io.h"
1914 @@ -2508,6 +2509,8 @@ static void btrfs_read_locked_inode(stru
1915 struct btrfs_key location;
1921 bool filled = false;
1923 @@ -2535,8 +2538,13 @@ static void btrfs_read_locked_inode(stru
1924 struct btrfs_inode_item);
1925 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1926 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
1927 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
1928 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
1930 + uid = btrfs_inode_uid(leaf, inode_item);
1931 + gid = btrfs_inode_gid(leaf, inode_item);
1932 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
1933 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
1934 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
1935 + btrfs_inode_tag(leaf, inode_item));
1936 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1938 tspec = btrfs_inode_atime(inode_item);
1939 @@ -2614,8 +2622,14 @@ static void fill_inode_item(struct btrfs
1940 struct btrfs_inode_item *item,
1941 struct inode *inode)
1943 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
1944 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
1945 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
1946 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
1948 + btrfs_set_inode_uid(leaf, item, uid);
1949 + btrfs_set_inode_gid(leaf, item, gid);
1950 +#ifdef CONFIG_TAGGING_INTERN
1951 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
1953 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
1954 btrfs_set_inode_mode(leaf, item, inode->i_mode);
1955 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
1956 @@ -7393,11 +7407,13 @@ static const struct inode_operations btr
1957 .listxattr = btrfs_listxattr,
1958 .removexattr = btrfs_removexattr,
1959 .permission = btrfs_permission,
1960 + .sync_flags = btrfs_sync_flags,
1961 .get_acl = btrfs_get_acl,
1963 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1964 .lookup = btrfs_lookup,
1965 .permission = btrfs_permission,
1966 + .sync_flags = btrfs_sync_flags,
1967 .get_acl = btrfs_get_acl,
1970 diff -NurpP --minimal linux-3.1.1/fs/btrfs/ioctl.c linux-3.1.1-vs2.3.2/fs/btrfs/ioctl.c
1971 --- linux-3.1.1/fs/btrfs/ioctl.c 2011-10-24 18:45:26.000000000 +0200
1972 +++ linux-3.1.1-vs2.3.2/fs/btrfs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
1973 @@ -70,10 +70,13 @@ static unsigned int btrfs_flags_to_ioctl
1975 unsigned int iflags = 0;
1977 - if (flags & BTRFS_INODE_SYNC)
1978 - iflags |= FS_SYNC_FL;
1979 if (flags & BTRFS_INODE_IMMUTABLE)
1980 iflags |= FS_IMMUTABLE_FL;
1981 + if (flags & BTRFS_INODE_IXUNLINK)
1982 + iflags |= FS_IXUNLINK_FL;
1984 + if (flags & BTRFS_INODE_SYNC)
1985 + iflags |= FS_SYNC_FL;
1986 if (flags & BTRFS_INODE_APPEND)
1987 iflags |= FS_APPEND_FL;
1988 if (flags & BTRFS_INODE_NODUMP)
1989 @@ -90,28 +93,78 @@ static unsigned int btrfs_flags_to_ioctl
1990 else if (flags & BTRFS_INODE_NOCOMPRESS)
1991 iflags |= FS_NOCOMP_FL;
1993 + if (flags & BTRFS_INODE_BARRIER)
1994 + iflags |= FS_BARRIER_FL;
1995 + if (flags & BTRFS_INODE_COW)
1996 + iflags |= FS_COW_FL;
2001 - * Update inode->i_flags based on the btrfs internal flags.
2002 + * Update inode->i_(v)flags based on the btrfs internal flags.
2004 void btrfs_update_iflags(struct inode *inode)
2006 struct btrfs_inode *ip = BTRFS_I(inode);
2008 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2009 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2010 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2012 - if (ip->flags & BTRFS_INODE_SYNC)
2013 - inode->i_flags |= S_SYNC;
2014 if (ip->flags & BTRFS_INODE_IMMUTABLE)
2015 inode->i_flags |= S_IMMUTABLE;
2016 + if (ip->flags & BTRFS_INODE_IXUNLINK)
2017 + inode->i_flags |= S_IXUNLINK;
2019 + if (ip->flags & BTRFS_INODE_SYNC)
2020 + inode->i_flags |= S_SYNC;
2021 if (ip->flags & BTRFS_INODE_APPEND)
2022 inode->i_flags |= S_APPEND;
2023 if (ip->flags & BTRFS_INODE_NOATIME)
2024 inode->i_flags |= S_NOATIME;
2025 if (ip->flags & BTRFS_INODE_DIRSYNC)
2026 inode->i_flags |= S_DIRSYNC;
2028 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2030 + if (ip->flags & BTRFS_INODE_BARRIER)
2031 + inode->i_vflags |= V_BARRIER;
2032 + if (ip->flags & BTRFS_INODE_COW)
2033 + inode->i_vflags |= V_COW;
2037 + * Update btrfs internal flags from inode->i_(v)flags.
2039 +void btrfs_update_flags(struct inode *inode)
2041 + struct btrfs_inode *ip = BTRFS_I(inode);
2043 + unsigned int flags = inode->i_flags;
2044 + unsigned int vflags = inode->i_vflags;
2046 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
2047 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
2048 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
2049 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
2051 + if (flags & S_IMMUTABLE)
2052 + ip->flags |= BTRFS_INODE_IMMUTABLE;
2053 + if (flags & S_IXUNLINK)
2054 + ip->flags |= BTRFS_INODE_IXUNLINK;
2056 + if (flags & S_SYNC)
2057 + ip->flags |= BTRFS_INODE_SYNC;
2058 + if (flags & S_APPEND)
2059 + ip->flags |= BTRFS_INODE_APPEND;
2060 + if (flags & S_NOATIME)
2061 + ip->flags |= BTRFS_INODE_NOATIME;
2062 + if (flags & S_DIRSYNC)
2063 + ip->flags |= BTRFS_INODE_DIRSYNC;
2065 + if (vflags & V_BARRIER)
2066 + ip->flags |= BTRFS_INODE_BARRIER;
2067 + if (vflags & V_COW)
2068 + ip->flags |= BTRFS_INODE_COW;
2072 @@ -129,7 +182,7 @@ void btrfs_inherit_iflags(struct inode *
2073 flags = BTRFS_I(dir)->flags;
2075 if (S_ISREG(inode->i_mode))
2076 - flags &= ~BTRFS_INODE_DIRSYNC;
2077 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
2078 else if (!S_ISDIR(inode->i_mode))
2079 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
2081 @@ -137,6 +190,30 @@ void btrfs_inherit_iflags(struct inode *
2082 btrfs_update_iflags(inode);
2085 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
2087 + struct btrfs_inode *ip = BTRFS_I(inode);
2088 + struct btrfs_root *root = ip->root;
2089 + struct btrfs_trans_handle *trans;
2092 + trans = btrfs_join_transaction(root);
2095 + inode->i_flags = flags;
2096 + inode->i_vflags = vflags;
2097 + btrfs_update_flags(inode);
2099 + ret = btrfs_update_inode(trans, root, inode);
2102 + btrfs_update_iflags(inode);
2103 + inode->i_ctime = CURRENT_TIME;
2104 + btrfs_end_transaction(trans, root);
2109 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
2111 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
2112 @@ -188,7 +265,8 @@ static int btrfs_ioctl_setflags(struct f
2114 flags = btrfs_mask_flags(inode->i_mode, flags);
2115 oldflags = btrfs_flags_to_ioctl(ip->flags);
2116 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
2117 + if ((flags ^ oldflags) & (FS_APPEND_FL |
2118 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
2119 if (!capable(CAP_LINUX_IMMUTABLE)) {
2122 @@ -199,14 +277,19 @@ static int btrfs_ioctl_setflags(struct f
2126 - if (flags & FS_SYNC_FL)
2127 - ip->flags |= BTRFS_INODE_SYNC;
2129 - ip->flags &= ~BTRFS_INODE_SYNC;
2130 if (flags & FS_IMMUTABLE_FL)
2131 ip->flags |= BTRFS_INODE_IMMUTABLE;
2133 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2134 + if (flags & FS_IXUNLINK_FL)
2135 + ip->flags |= BTRFS_INODE_IXUNLINK;
2137 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2139 + if (flags & FS_SYNC_FL)
2140 + ip->flags |= BTRFS_INODE_SYNC;
2142 + ip->flags &= ~BTRFS_INODE_SYNC;
2143 if (flags & FS_APPEND_FL)
2144 ip->flags |= BTRFS_INODE_APPEND;
2146 diff -NurpP --minimal linux-3.1.1/fs/btrfs/super.c linux-3.1.1-vs2.3.2/fs/btrfs/super.c
2147 --- linux-3.1.1/fs/btrfs/super.c 2011-07-22 11:18:05.000000000 +0200
2148 +++ linux-3.1.1-vs2.3.2/fs/btrfs/super.c 2011-10-24 18:53:33.000000000 +0200
2149 @@ -162,7 +162,7 @@ enum {
2150 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
2151 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
2152 Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,
2153 - Opt_inode_cache, Opt_err,
2154 + Opt_inode_cache, Opt_tag, Opt_notag, Opt_tagid, Opt_err,
2157 static match_table_t tokens = {
2158 @@ -195,6 +195,9 @@ static match_table_t tokens = {
2159 {Opt_subvolrootid, "subvolrootid=%d"},
2160 {Opt_defrag, "autodefrag"},
2161 {Opt_inode_cache, "inode_cache"},
2163 + {Opt_notag, "notag"},
2164 + {Opt_tagid, "tagid=%u"},
2168 @@ -381,6 +384,22 @@ int btrfs_parse_options(struct btrfs_roo
2169 printk(KERN_INFO "btrfs: enabling auto defrag");
2170 btrfs_set_opt(info->mount_opt, AUTO_DEFRAG);
2172 +#ifndef CONFIG_TAGGING_NONE
2174 + printk(KERN_INFO "btrfs: use tagging\n");
2175 + btrfs_set_opt(info->mount_opt, TAGGED);
2178 + printk(KERN_INFO "btrfs: disabled tagging\n");
2179 + btrfs_clear_opt(info->mount_opt, TAGGED);
2182 +#ifdef CONFIG_PROPAGATE
2185 + btrfs_set_opt(info->mount_opt, TAGGED);
2189 printk(KERN_INFO "btrfs: unrecognized mount option "
2191 @@ -907,6 +926,12 @@ static int btrfs_remount(struct super_bl
2195 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2196 + printk("btrfs: %s: tagging not permitted on remount.\n",
2201 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2204 diff -NurpP --minimal linux-3.1.1/fs/char_dev.c linux-3.1.1-vs2.3.2/fs/char_dev.c
2205 --- linux-3.1.1/fs/char_dev.c 2011-03-15 18:07:31.000000000 +0100
2206 +++ linux-3.1.1-vs2.3.2/fs/char_dev.c 2011-10-24 18:53:33.000000000 +0200
2208 #include <linux/mutex.h>
2209 #include <linux/backing-dev.h>
2210 #include <linux/tty.h>
2211 +#include <linux/vs_context.h>
2212 +#include <linux/vs_device.h>
2214 #include "internal.h"
2216 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2218 struct cdev *new = NULL;
2222 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2224 + inode->i_mdev = mdev;
2226 spin_lock(&cdev_lock);
2229 struct kobject *kobj;
2232 spin_unlock(&cdev_lock);
2233 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2235 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2238 new = container_of(kobj, struct cdev, kobj);
2239 diff -NurpP --minimal linux-3.1.1/fs/dcache.c linux-3.1.1-vs2.3.2/fs/dcache.c
2240 --- linux-3.1.1/fs/dcache.c 2011-10-24 18:45:26.000000000 +0200
2241 +++ linux-3.1.1-vs2.3.2/fs/dcache.c 2011-10-24 18:53:33.000000000 +0200
2243 #include <linux/bit_spinlock.h>
2244 #include <linux/rculist_bl.h>
2245 #include <linux/prefetch.h>
2246 +#include <linux/vs_limit.h>
2247 #include "internal.h"
2250 @@ -513,6 +514,8 @@ int d_invalidate(struct dentry * dentry)
2251 spin_lock(&dentry->d_lock);
2254 + vx_dentry_dec(dentry);
2257 * Somebody else still using it?
2259 @@ -540,6 +543,7 @@ EXPORT_SYMBOL(d_invalidate);
2260 static inline void __dget_dlock(struct dentry *dentry)
2263 + vx_dentry_inc(dentry);
2266 static inline void __dget(struct dentry *dentry)
2267 @@ -1175,6 +1179,9 @@ struct dentry *__d_alloc(struct super_bl
2268 struct dentry *dentry;
2271 + if (!vx_dentry_avail(1))
2274 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2277 @@ -1197,6 +1204,7 @@ struct dentry *__d_alloc(struct super_bl
2279 dentry->d_count = 1;
2280 dentry->d_flags = 0;
2281 + vx_dentry_inc(dentry);
2282 spin_lock_init(&dentry->d_lock);
2283 seqcount_init(&dentry->d_seq);
2284 dentry->d_inode = NULL;
2285 @@ -1853,6 +1861,7 @@ struct dentry *__d_lookup(struct dentry
2289 + vx_dentry_inc(dentry);
2291 spin_unlock(&dentry->d_lock);
2293 diff -NurpP --minimal linux-3.1.1/fs/devpts/inode.c linux-3.1.1-vs2.3.2/fs/devpts/inode.c
2294 --- linux-3.1.1/fs/devpts/inode.c 2011-05-22 16:17:50.000000000 +0200
2295 +++ linux-3.1.1-vs2.3.2/fs/devpts/inode.c 2011-10-24 18:53:33.000000000 +0200
2297 #include <linux/parser.h>
2298 #include <linux/fsnotify.h>
2299 #include <linux/seq_file.h>
2300 +#include <linux/vs_base.h>
2302 #define DEVPTS_DEFAULT_MODE 0600
2305 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2306 #define PTMX_MINOR 2
2308 +static int devpts_permission(struct inode *inode, int mask)
2310 + int ret = -EACCES;
2312 + /* devpts is xid tagged */
2313 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2314 + ret = generic_permission(inode, mask);
2318 +static struct inode_operations devpts_file_inode_operations = {
2319 + .permission = devpts_permission,
2322 extern int pty_limit; /* Config limit on Unix98 ptys */
2323 static DEFINE_MUTEX(allocated_ptys_lock);
2325 @@ -263,6 +278,34 @@ static int devpts_show_options(struct se
2329 +static int devpts_filter(struct dentry *de)
2333 + /* devpts is xid tagged */
2334 + if (de && de->d_inode)
2335 + xid = (xid_t)de->d_inode->i_tag;
2336 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2338 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2339 + de->d_name.len, de->d_name.name);
2341 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2344 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2346 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2349 +static struct file_operations devpts_dir_operations = {
2350 + .open = dcache_dir_open,
2351 + .release = dcache_dir_close,
2352 + .llseek = dcache_dir_lseek,
2353 + .read = generic_read_dir,
2354 + .readdir = devpts_readdir,
2357 static const struct super_operations devpts_sops = {
2358 .statfs = simple_statfs,
2359 .remount_fs = devpts_remount,
2360 @@ -302,12 +345,15 @@ devpts_fill_super(struct super_block *s,
2361 inode = new_inode(s);
2366 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2367 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2368 inode->i_op = &simple_dir_inode_operations;
2369 - inode->i_fop = &simple_dir_operations;
2370 + inode->i_fop = &devpts_dir_operations;
2372 + /* devpts is xid tagged */
2373 + inode->i_tag = (tag_t)vx_current_xid();
2375 s->s_root = d_alloc_root(inode);
2377 @@ -494,6 +540,9 @@ int devpts_pty_new(struct inode *ptmx_in
2378 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2379 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2380 init_special_inode(inode, S_IFCHR|opts->mode, device);
2381 + /* devpts is xid tagged */
2382 + inode->i_tag = (tag_t)vx_current_xid();
2383 + inode->i_op = &devpts_file_inode_operations;
2384 inode->i_private = tty;
2385 tty->driver_data = inode;
2387 diff -NurpP --minimal linux-3.1.1/fs/ext2/balloc.c linux-3.1.1-vs2.3.2/fs/ext2/balloc.c
2388 --- linux-3.1.1/fs/ext2/balloc.c 2011-05-22 16:17:51.000000000 +0200
2389 +++ linux-3.1.1-vs2.3.2/fs/ext2/balloc.c 2011-10-24 18:53:33.000000000 +0200
2390 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2392 end = EXT2_BLOCKS_PER_GROUP(sb);
2395 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2398 diff -NurpP --minimal linux-3.1.1/fs/ext2/ext2.h linux-3.1.1-vs2.3.2/fs/ext2/ext2.h
2399 --- linux-3.1.1/fs/ext2/ext2.h 2011-10-24 18:45:27.000000000 +0200
2400 +++ linux-3.1.1-vs2.3.2/fs/ext2/ext2.h 2011-10-24 18:53:33.000000000 +0200
2401 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct
2402 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2403 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2404 u64 start, u64 len);
2405 +extern int ext2_sync_flags(struct inode *, int, int);
2408 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2409 diff -NurpP --minimal linux-3.1.1/fs/ext2/file.c linux-3.1.1-vs2.3.2/fs/ext2/file.c
2410 --- linux-3.1.1/fs/ext2/file.c 2011-10-24 18:45:27.000000000 +0200
2411 +++ linux-3.1.1-vs2.3.2/fs/ext2/file.c 2011-10-24 18:53:33.000000000 +0200
2412 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2413 .setattr = ext2_setattr,
2414 .get_acl = ext2_get_acl,
2415 .fiemap = ext2_fiemap,
2416 + .sync_flags = ext2_sync_flags,
2418 diff -NurpP --minimal linux-3.1.1/fs/ext2/ialloc.c linux-3.1.1-vs2.3.2/fs/ext2/ialloc.c
2419 --- linux-3.1.1/fs/ext2/ialloc.c 2011-05-22 16:17:51.000000000 +0200
2420 +++ linux-3.1.1-vs2.3.2/fs/ext2/ialloc.c 2011-10-24 18:53:33.000000000 +0200
2422 #include <linux/backing-dev.h>
2423 #include <linux/buffer_head.h>
2424 #include <linux/random.h>
2425 +#include <linux/vs_tag.h>
2429 @@ -549,6 +550,7 @@ got:
2430 inode->i_mode = mode;
2431 inode->i_uid = current_fsuid();
2432 inode->i_gid = dir->i_gid;
2433 + inode->i_tag = dx_current_fstag(sb);
2435 inode_init_owner(inode, dir, mode);
2437 diff -NurpP --minimal linux-3.1.1/fs/ext2/inode.c linux-3.1.1-vs2.3.2/fs/ext2/inode.c
2438 --- linux-3.1.1/fs/ext2/inode.c 2011-10-24 18:45:27.000000000 +0200
2439 +++ linux-3.1.1-vs2.3.2/fs/ext2/inode.c 2011-10-24 18:53:33.000000000 +0200
2441 #include <linux/mpage.h>
2442 #include <linux/fiemap.h>
2443 #include <linux/namei.h>
2444 +#include <linux/vs_tag.h>
2448 @@ -1167,7 +1168,7 @@ static void ext2_truncate_blocks(struct
2450 if (ext2_inode_is_fast_symlink(inode))
2452 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2453 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2455 __ext2_truncate_blocks(inode, offset);
2457 @@ -1258,36 +1259,61 @@ void ext2_set_inode_flags(struct inode *
2459 unsigned int flags = EXT2_I(inode)->i_flags;
2461 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2462 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2463 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2466 + if (flags & EXT2_IMMUTABLE_FL)
2467 + inode->i_flags |= S_IMMUTABLE;
2468 + if (flags & EXT2_IXUNLINK_FL)
2469 + inode->i_flags |= S_IXUNLINK;
2471 if (flags & EXT2_SYNC_FL)
2472 inode->i_flags |= S_SYNC;
2473 if (flags & EXT2_APPEND_FL)
2474 inode->i_flags |= S_APPEND;
2475 - if (flags & EXT2_IMMUTABLE_FL)
2476 - inode->i_flags |= S_IMMUTABLE;
2477 if (flags & EXT2_NOATIME_FL)
2478 inode->i_flags |= S_NOATIME;
2479 if (flags & EXT2_DIRSYNC_FL)
2480 inode->i_flags |= S_DIRSYNC;
2482 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2484 + if (flags & EXT2_BARRIER_FL)
2485 + inode->i_vflags |= V_BARRIER;
2486 + if (flags & EXT2_COW_FL)
2487 + inode->i_vflags |= V_COW;
2490 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2491 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2493 unsigned int flags = ei->vfs_inode.i_flags;
2494 + unsigned int vflags = ei->vfs_inode.i_vflags;
2496 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2497 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2498 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2499 + EXT2_BARRIER_FL | EXT2_COW_FL);
2501 + if (flags & S_IMMUTABLE)
2502 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2503 + if (flags & S_IXUNLINK)
2504 + ei->i_flags |= EXT2_IXUNLINK_FL;
2506 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2507 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2509 ei->i_flags |= EXT2_SYNC_FL;
2510 if (flags & S_APPEND)
2511 ei->i_flags |= EXT2_APPEND_FL;
2512 - if (flags & S_IMMUTABLE)
2513 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2514 if (flags & S_NOATIME)
2515 ei->i_flags |= EXT2_NOATIME_FL;
2516 if (flags & S_DIRSYNC)
2517 ei->i_flags |= EXT2_DIRSYNC_FL;
2519 + if (vflags & V_BARRIER)
2520 + ei->i_flags |= EXT2_BARRIER_FL;
2521 + if (vflags & V_COW)
2522 + ei->i_flags |= EXT2_COW_FL;
2525 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2526 @@ -1297,6 +1323,8 @@ struct inode *ext2_iget (struct super_bl
2527 struct ext2_inode *raw_inode;
2528 struct inode *inode;
2534 inode = iget_locked(sb, ino);
2535 @@ -1315,12 +1343,17 @@ struct inode *ext2_iget (struct super_bl
2538 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2539 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2540 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2541 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2542 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2543 if (!(test_opt (inode->i_sb, NO_UID32))) {
2544 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2545 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2546 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2547 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2549 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2550 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2551 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2552 + le16_to_cpu(raw_inode->i_raw_tag));
2554 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2555 inode->i_size = le32_to_cpu(raw_inode->i_size);
2556 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2557 @@ -1418,8 +1451,8 @@ static int __ext2_write_inode(struct ino
2558 struct ext2_inode_info *ei = EXT2_I(inode);
2559 struct super_block *sb = inode->i_sb;
2560 ino_t ino = inode->i_ino;
2561 - uid_t uid = inode->i_uid;
2562 - gid_t gid = inode->i_gid;
2563 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2564 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2565 struct buffer_head * bh;
2566 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2568 @@ -1455,6 +1488,9 @@ static int __ext2_write_inode(struct ino
2569 raw_inode->i_uid_high = 0;
2570 raw_inode->i_gid_high = 0;
2572 +#ifdef CONFIG_TAGGING_INTERN
2573 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2575 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2576 raw_inode->i_size = cpu_to_le32(inode->i_size);
2577 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2578 @@ -1535,7 +1571,8 @@ int ext2_setattr(struct dentry *dentry,
2579 if (is_quota_modification(inode, iattr))
2580 dquot_initialize(inode);
2581 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2582 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2583 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2584 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2585 error = dquot_transfer(inode, iattr);
2588 diff -NurpP --minimal linux-3.1.1/fs/ext2/ioctl.c linux-3.1.1-vs2.3.2/fs/ext2/ioctl.c
2589 --- linux-3.1.1/fs/ext2/ioctl.c 2011-05-22 16:17:51.000000000 +0200
2590 +++ linux-3.1.1-vs2.3.2/fs/ext2/ioctl.c 2011-10-24 18:53:33.000000000 +0200
2592 #include <asm/uaccess.h>
2595 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2597 + inode->i_flags = flags;
2598 + inode->i_vflags = vflags;
2599 + ext2_get_inode_flags(EXT2_I(inode));
2600 + inode->i_ctime = CURRENT_TIME_SEC;
2601 + mark_inode_dirty(inode);
2605 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2607 struct inode *inode = filp->f_dentry->d_inode;
2608 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2610 flags = ext2_mask_flags(inode->i_mode, flags);
2612 + if (IS_BARRIER(inode)) {
2613 + vxwprintk_task(1, "messing with the barrier.");
2617 mutex_lock(&inode->i_mutex);
2618 /* Is it quota file? Do not allow user to mess with it */
2619 if (IS_NOQUOTA(inode)) {
2620 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2622 * This test looks nicer. Thanks to Pauline Middelink
2624 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2625 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2626 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2627 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2628 if (!capable(CAP_LINUX_IMMUTABLE)) {
2629 mutex_unlock(&inode->i_mutex);
2631 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2635 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2636 + flags &= EXT2_FL_USER_MODIFIABLE;
2637 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2638 ei->i_flags = flags;
2639 mutex_unlock(&inode->i_mutex);
2640 diff -NurpP --minimal linux-3.1.1/fs/ext2/namei.c linux-3.1.1-vs2.3.2/fs/ext2/namei.c
2641 --- linux-3.1.1/fs/ext2/namei.c 2011-10-24 18:45:27.000000000 +0200
2642 +++ linux-3.1.1-vs2.3.2/fs/ext2/namei.c 2011-10-24 18:53:33.000000000 +0200
2645 #include <linux/pagemap.h>
2646 #include <linux/quotaops.h>
2647 +#include <linux/vs_tag.h>
2651 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
2652 (unsigned long) ino);
2653 return ERR_PTR(-EIO);
2655 + dx_propagate_tag(nd, inode);
2657 return d_splice_alias(inode, dentry);
2659 @@ -408,6 +410,7 @@ const struct inode_operations ext2_dir_i
2660 .removexattr = generic_removexattr,
2662 .setattr = ext2_setattr,
2663 + .sync_flags = ext2_sync_flags,
2664 .get_acl = ext2_get_acl,
2667 diff -NurpP --minimal linux-3.1.1/fs/ext2/super.c linux-3.1.1-vs2.3.2/fs/ext2/super.c
2668 --- linux-3.1.1/fs/ext2/super.c 2011-07-22 11:18:05.000000000 +0200
2669 +++ linux-3.1.1-vs2.3.2/fs/ext2/super.c 2011-10-24 18:53:33.000000000 +0200
2670 @@ -394,7 +394,8 @@ enum {
2671 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2672 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2673 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2674 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2675 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2676 + Opt_tag, Opt_notag, Opt_tagid
2679 static const match_table_t tokens = {
2680 @@ -422,6 +423,9 @@ static const match_table_t tokens = {
2682 {Opt_noacl, "noacl"},
2685 + {Opt_notag, "notag"},
2686 + {Opt_tagid, "tagid=%u"},
2687 {Opt_grpquota, "grpquota"},
2688 {Opt_ignore, "noquota"},
2689 {Opt_quota, "quota"},
2690 @@ -492,6 +496,20 @@ static int parse_options(char *options,
2692 set_opt (sbi->s_mount_opt, NO_UID32);
2694 +#ifndef CONFIG_TAGGING_NONE
2696 + set_opt (sbi->s_mount_opt, TAGGED);
2699 + clear_opt (sbi->s_mount_opt, TAGGED);
2702 +#ifdef CONFIG_PROPAGATE
2705 + set_opt (sbi->s_mount_opt, TAGGED);
2709 clear_opt (sbi->s_mount_opt, CHECK);
2711 @@ -850,6 +868,8 @@ static int ext2_fill_super(struct super_
2712 if (!parse_options((char *) data, sb))
2715 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2716 + sb->s_flags |= MS_TAGGED;
2717 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2718 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2720 @@ -1224,6 +1244,14 @@ static int ext2_remount (struct super_bl
2724 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2725 + !(sb->s_flags & MS_TAGGED)) {
2726 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2729 + goto restore_opts;
2732 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2733 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2735 diff -NurpP --minimal linux-3.1.1/fs/ext3/file.c linux-3.1.1-vs2.3.2/fs/ext3/file.c
2736 --- linux-3.1.1/fs/ext3/file.c 2011-10-24 18:45:27.000000000 +0200
2737 +++ linux-3.1.1-vs2.3.2/fs/ext3/file.c 2011-10-24 18:53:33.000000000 +0200
2738 @@ -80,5 +80,6 @@ const struct inode_operations ext3_file_
2740 .get_acl = ext3_get_acl,
2741 .fiemap = ext3_fiemap,
2742 + .sync_flags = ext3_sync_flags,
2745 diff -NurpP --minimal linux-3.1.1/fs/ext3/ialloc.c linux-3.1.1-vs2.3.2/fs/ext3/ialloc.c
2746 --- linux-3.1.1/fs/ext3/ialloc.c 2011-10-24 18:45:27.000000000 +0200
2747 +++ linux-3.1.1-vs2.3.2/fs/ext3/ialloc.c 2011-10-24 18:53:33.000000000 +0200
2749 #include <linux/buffer_head.h>
2750 #include <linux/random.h>
2751 #include <linux/bitops.h>
2752 +#include <linux/vs_tag.h>
2753 #include <trace/events/ext3.h>
2755 #include <asm/byteorder.h>
2756 @@ -535,6 +536,7 @@ got:
2757 inode->i_mode = mode;
2758 inode->i_uid = current_fsuid();
2759 inode->i_gid = dir->i_gid;
2760 + inode->i_tag = dx_current_fstag(sb);
2762 inode_init_owner(inode, dir, mode);
2764 diff -NurpP --minimal linux-3.1.1/fs/ext3/inode.c linux-3.1.1-vs2.3.2/fs/ext3/inode.c
2765 --- linux-3.1.1/fs/ext3/inode.c 2011-10-24 18:45:27.000000000 +0200
2766 +++ linux-3.1.1-vs2.3.2/fs/ext3/inode.c 2011-10-24 18:53:33.000000000 +0200
2768 #include <linux/bio.h>
2769 #include <linux/fiemap.h>
2770 #include <linux/namei.h>
2771 +#include <linux/vs_tag.h>
2772 #include <trace/events/ext3.h>
2775 @@ -2834,36 +2835,60 @@ void ext3_set_inode_flags(struct inode *
2777 unsigned int flags = EXT3_I(inode)->i_flags;
2779 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2780 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2781 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2783 + if (flags & EXT3_IMMUTABLE_FL)
2784 + inode->i_flags |= S_IMMUTABLE;
2785 + if (flags & EXT3_IXUNLINK_FL)
2786 + inode->i_flags |= S_IXUNLINK;
2788 if (flags & EXT3_SYNC_FL)
2789 inode->i_flags |= S_SYNC;
2790 if (flags & EXT3_APPEND_FL)
2791 inode->i_flags |= S_APPEND;
2792 - if (flags & EXT3_IMMUTABLE_FL)
2793 - inode->i_flags |= S_IMMUTABLE;
2794 if (flags & EXT3_NOATIME_FL)
2795 inode->i_flags |= S_NOATIME;
2796 if (flags & EXT3_DIRSYNC_FL)
2797 inode->i_flags |= S_DIRSYNC;
2799 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2801 + if (flags & EXT3_BARRIER_FL)
2802 + inode->i_vflags |= V_BARRIER;
2803 + if (flags & EXT3_COW_FL)
2804 + inode->i_vflags |= V_COW;
2807 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2808 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2810 unsigned int flags = ei->vfs_inode.i_flags;
2811 + unsigned int vflags = ei->vfs_inode.i_vflags;
2813 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2814 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2815 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2816 + EXT3_BARRIER_FL | EXT3_COW_FL);
2818 + if (flags & S_IMMUTABLE)
2819 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2820 + if (flags & S_IXUNLINK)
2821 + ei->i_flags |= EXT3_IXUNLINK_FL;
2823 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2824 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2826 ei->i_flags |= EXT3_SYNC_FL;
2827 if (flags & S_APPEND)
2828 ei->i_flags |= EXT3_APPEND_FL;
2829 - if (flags & S_IMMUTABLE)
2830 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2831 if (flags & S_NOATIME)
2832 ei->i_flags |= EXT3_NOATIME_FL;
2833 if (flags & S_DIRSYNC)
2834 ei->i_flags |= EXT3_DIRSYNC_FL;
2836 + if (vflags & V_BARRIER)
2837 + ei->i_flags |= EXT3_BARRIER_FL;
2838 + if (vflags & V_COW)
2839 + ei->i_flags |= EXT3_COW_FL;
2842 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2843 @@ -2877,6 +2902,8 @@ struct inode *ext3_iget(struct super_blo
2844 transaction_t *transaction;
2850 inode = iget_locked(sb, ino);
2852 @@ -2893,12 +2920,17 @@ struct inode *ext3_iget(struct super_blo
2854 raw_inode = ext3_raw_inode(&iloc);
2855 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2856 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2857 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2858 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2859 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2860 if(!(test_opt (inode->i_sb, NO_UID32))) {
2861 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2862 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2863 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2864 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2866 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2867 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2868 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2869 + le16_to_cpu(raw_inode->i_raw_tag));
2871 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2872 inode->i_size = le32_to_cpu(raw_inode->i_size);
2873 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2874 @@ -3053,6 +3085,8 @@ static int ext3_do_update_inode(handle_t
2875 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
2876 struct ext3_inode_info *ei = EXT3_I(inode);
2877 struct buffer_head *bh = iloc->bh;
2878 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2879 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2880 int err = 0, rc, block;
2883 @@ -3067,29 +3101,32 @@ again:
2884 ext3_get_inode_flags(ei);
2885 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2886 if(!(test_opt(inode->i_sb, NO_UID32))) {
2887 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
2888 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
2889 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
2890 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
2892 * Fix up interoperability with old kernels. Otherwise, old inodes get
2893 * re-used with the upper 16 bits of the uid/gid intact
2896 raw_inode->i_uid_high =
2897 - cpu_to_le16(high_16_bits(inode->i_uid));
2898 + cpu_to_le16(high_16_bits(uid));
2899 raw_inode->i_gid_high =
2900 - cpu_to_le16(high_16_bits(inode->i_gid));
2901 + cpu_to_le16(high_16_bits(gid));
2903 raw_inode->i_uid_high = 0;
2904 raw_inode->i_gid_high = 0;
2907 raw_inode->i_uid_low =
2908 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
2909 + cpu_to_le16(fs_high2lowuid(uid));
2910 raw_inode->i_gid_low =
2911 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
2912 + cpu_to_le16(fs_high2lowgid(gid));
2913 raw_inode->i_uid_high = 0;
2914 raw_inode->i_gid_high = 0;
2916 +#ifdef CONFIG_TAGGING_INTERN
2917 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2919 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2920 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
2921 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2922 @@ -3249,7 +3286,8 @@ int ext3_setattr(struct dentry *dentry,
2923 if (is_quota_modification(inode, attr))
2924 dquot_initialize(inode);
2925 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2926 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
2927 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2928 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
2931 /* (user+group)*(old+new) structure, inode write (sb,
2932 @@ -3271,6 +3309,8 @@ int ext3_setattr(struct dentry *dentry,
2933 inode->i_uid = attr->ia_uid;
2934 if (attr->ia_valid & ATTR_GID)
2935 inode->i_gid = attr->ia_gid;
2936 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2937 + inode->i_tag = attr->ia_tag;
2938 error = ext3_mark_inode_dirty(handle, inode);
2939 ext3_journal_stop(handle);
2941 diff -NurpP --minimal linux-3.1.1/fs/ext3/ioctl.c linux-3.1.1-vs2.3.2/fs/ext3/ioctl.c
2942 --- linux-3.1.1/fs/ext3/ioctl.c 2011-10-24 18:45:27.000000000 +0200
2943 +++ linux-3.1.1-vs2.3.2/fs/ext3/ioctl.c 2011-10-24 18:53:33.000000000 +0200
2947 #include <linux/fs.h>
2948 +#include <linux/mount.h>
2949 #include <linux/jbd.h>
2950 #include <linux/capability.h>
2951 #include <linux/ext3_fs.h>
2953 #include <linux/compat.h>
2954 #include <asm/uaccess.h>
2957 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2959 + handle_t *handle = NULL;
2960 + struct ext3_iloc iloc;
2963 + handle = ext3_journal_start(inode, 1);
2964 + if (IS_ERR(handle))
2965 + return PTR_ERR(handle);
2967 + if (IS_SYNC(inode))
2968 + handle->h_sync = 1;
2969 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2973 + inode->i_flags = flags;
2974 + inode->i_vflags = vflags;
2975 + ext3_get_inode_flags(EXT3_I(inode));
2976 + inode->i_ctime = CURRENT_TIME_SEC;
2978 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2980 + ext3_journal_stop(handle);
2984 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2986 struct inode *inode = filp->f_dentry->d_inode;
2987 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
2989 flags = ext3_mask_flags(inode->i_mode, flags);
2991 + if (IS_BARRIER(inode)) {
2992 + vxwprintk_task(1, "messing with the barrier.");
2996 mutex_lock(&inode->i_mutex);
2998 /* Is it quota file? Do not allow user to mess with it */
2999 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
3001 * This test looks nicer. Thanks to Pauline Middelink
3003 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
3004 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
3005 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
3006 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
3007 if (!capable(CAP_LINUX_IMMUTABLE))
3010 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
3014 - flags = flags & EXT3_FL_USER_MODIFIABLE;
3015 + flags &= EXT3_FL_USER_MODIFIABLE;
3016 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
3017 ei->i_flags = flags;
3019 diff -NurpP --minimal linux-3.1.1/fs/ext3/namei.c linux-3.1.1-vs2.3.2/fs/ext3/namei.c
3020 --- linux-3.1.1/fs/ext3/namei.c 2011-10-24 18:45:27.000000000 +0200
3021 +++ linux-3.1.1-vs2.3.2/fs/ext3/namei.c 2011-10-24 18:53:33.000000000 +0200
3023 #include <linux/quotaops.h>
3024 #include <linux/buffer_head.h>
3025 #include <linux/bio.h>
3026 +#include <linux/vs_tag.h>
3027 #include <trace/events/ext3.h>
3030 @@ -925,6 +926,7 @@ restart:
3031 ll_rw_block(READ | REQ_META | REQ_PRIO,
3034 + dx_propagate_tag(nd, inode);
3036 if ((bh = bh_use[ra_ptr++]) == NULL)
3038 @@ -2535,6 +2537,7 @@ const struct inode_operations ext3_dir_i
3039 .listxattr = ext3_listxattr,
3040 .removexattr = generic_removexattr,
3042 + .sync_flags = ext3_sync_flags,
3043 .get_acl = ext3_get_acl,
3046 diff -NurpP --minimal linux-3.1.1/fs/ext3/super.c linux-3.1.1-vs2.3.2/fs/ext3/super.c
3047 --- linux-3.1.1/fs/ext3/super.c 2011-10-24 18:45:27.000000000 +0200
3048 +++ linux-3.1.1-vs2.3.2/fs/ext3/super.c 2011-10-24 18:53:33.000000000 +0200
3049 @@ -833,7 +833,8 @@ enum {
3050 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
3051 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
3052 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
3053 - Opt_resize, Opt_usrquota, Opt_grpquota
3054 + Opt_resize, Opt_usrquota, Opt_grpquota,
3055 + Opt_tag, Opt_notag, Opt_tagid
3058 static const match_table_t tokens = {
3059 @@ -890,6 +891,9 @@ static const match_table_t tokens = {
3060 {Opt_barrier, "barrier"},
3061 {Opt_nobarrier, "nobarrier"},
3062 {Opt_resize, "resize"},
3064 + {Opt_notag, "notag"},
3065 + {Opt_tagid, "tagid=%u"},
3069 @@ -1042,6 +1046,20 @@ static int parse_options (char *options,
3071 set_opt (sbi->s_mount_opt, NO_UID32);
3073 +#ifndef CONFIG_TAGGING_NONE
3075 + set_opt (sbi->s_mount_opt, TAGGED);
3078 + clear_opt (sbi->s_mount_opt, TAGGED);
3081 +#ifdef CONFIG_PROPAGATE
3084 + set_opt (sbi->s_mount_opt, TAGGED);
3088 clear_opt (sbi->s_mount_opt, CHECK);
3090 @@ -1738,6 +1756,9 @@ static int ext3_fill_super (struct super
3094 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
3095 + sb->s_flags |= MS_TAGGED;
3097 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3098 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3100 @@ -2619,6 +2640,14 @@ static int ext3_remount (struct super_bl
3101 if (test_opt(sb, ABORT))
3102 ext3_abort(sb, __func__, "Abort forced by user");
3104 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3105 + !(sb->s_flags & MS_TAGGED)) {
3106 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3109 + goto restore_opts;
3112 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3113 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3115 diff -NurpP --minimal linux-3.1.1/fs/ext4/ext4.h linux-3.1.1-vs2.3.2/fs/ext4/ext4.h
3116 --- linux-3.1.1/fs/ext4/ext4.h 2011-11-15 16:44:52.000000000 +0100
3117 +++ linux-3.1.1-vs2.3.2/fs/ext4/ext4.h 2011-11-15 17:08:44.000000000 +0100
3118 @@ -351,8 +351,12 @@ struct flex_groups {
3119 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3120 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3121 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3122 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3123 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3125 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3126 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3128 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3129 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3131 @@ -609,7 +613,8 @@ struct ext4_inode {
3132 __le16 l_i_file_acl_high;
3133 __le16 l_i_uid_high; /* these 2 fields */
3134 __le16 l_i_gid_high; /* were reserved2[0] */
3135 - __u32 l_i_reserved2;
3136 + __le16 l_i_tag; /* Context Tag */
3137 + __u16 l_i_reserved2;
3140 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3141 @@ -727,6 +732,7 @@ do { \
3142 #define i_gid_low i_gid
3143 #define i_uid_high osd2.linux2.l_i_uid_high
3144 #define i_gid_high osd2.linux2.l_i_gid_high
3145 +#define i_raw_tag osd2.linux2.l_i_tag
3146 #define i_reserved2 osd2.linux2.l_i_reserved2
3148 #elif defined(__GNU__)
3149 @@ -903,6 +909,7 @@ struct ext4_inode_info {
3150 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3151 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3152 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3153 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3154 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3155 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3156 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3157 @@ -2217,6 +2224,7 @@ extern int ext4_map_blocks(handle_t *han
3158 struct ext4_map_blocks *map, int flags);
3159 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3160 __u64 start, __u64 len);
3161 +extern int ext4_sync_flags(struct inode *, int, int);
3163 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3164 __u64 start_orig, __u64 start_donor,
3165 diff -NurpP --minimal linux-3.1.1/fs/ext4/file.c linux-3.1.1-vs2.3.2/fs/ext4/file.c
3166 --- linux-3.1.1/fs/ext4/file.c 2011-10-24 18:45:27.000000000 +0200
3167 +++ linux-3.1.1-vs2.3.2/fs/ext4/file.c 2011-10-24 18:53:33.000000000 +0200
3168 @@ -303,5 +303,6 @@ const struct inode_operations ext4_file_
3170 .get_acl = ext4_get_acl,
3171 .fiemap = ext4_fiemap,
3172 + .sync_flags = ext4_sync_flags,
3175 diff -NurpP --minimal linux-3.1.1/fs/ext4/ialloc.c linux-3.1.1-vs2.3.2/fs/ext4/ialloc.c
3176 --- linux-3.1.1/fs/ext4/ialloc.c 2011-10-24 18:45:27.000000000 +0200
3177 +++ linux-3.1.1-vs2.3.2/fs/ext4/ialloc.c 2011-10-24 18:53:33.000000000 +0200
3179 #include <linux/random.h>
3180 #include <linux/bitops.h>
3181 #include <linux/blkdev.h>
3182 +#include <linux/vs_tag.h>
3183 #include <asm/byteorder.h>
3186 @@ -992,6 +993,7 @@ got:
3187 inode->i_mode = mode;
3188 inode->i_uid = current_fsuid();
3189 inode->i_gid = dir->i_gid;
3190 + inode->i_tag = dx_current_fstag(sb);
3192 inode_init_owner(inode, dir, mode);
3194 diff -NurpP --minimal linux-3.1.1/fs/ext4/inode.c linux-3.1.1-vs2.3.2/fs/ext4/inode.c
3195 --- linux-3.1.1/fs/ext4/inode.c 2011-11-15 16:44:52.000000000 +0100
3196 +++ linux-3.1.1-vs2.3.2/fs/ext4/inode.c 2011-11-15 17:08:44.000000000 +0100
3198 #include <linux/printk.h>
3199 #include <linux/slab.h>
3200 #include <linux/ratelimit.h>
3201 +#include <linux/vs_tag.h>
3203 #include "ext4_jbd2.h"
3205 @@ -3323,41 +3324,64 @@ void ext4_set_inode_flags(struct inode *
3207 unsigned int flags = EXT4_I(inode)->i_flags;
3209 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3210 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3211 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3213 + if (flags & EXT4_IMMUTABLE_FL)
3214 + inode->i_flags |= S_IMMUTABLE;
3215 + if (flags & EXT4_IXUNLINK_FL)
3216 + inode->i_flags |= S_IXUNLINK;
3218 if (flags & EXT4_SYNC_FL)
3219 inode->i_flags |= S_SYNC;
3220 if (flags & EXT4_APPEND_FL)
3221 inode->i_flags |= S_APPEND;
3222 - if (flags & EXT4_IMMUTABLE_FL)
3223 - inode->i_flags |= S_IMMUTABLE;
3224 if (flags & EXT4_NOATIME_FL)
3225 inode->i_flags |= S_NOATIME;
3226 if (flags & EXT4_DIRSYNC_FL)
3227 inode->i_flags |= S_DIRSYNC;
3229 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3231 + if (flags & EXT4_BARRIER_FL)
3232 + inode->i_vflags |= V_BARRIER;
3233 + if (flags & EXT4_COW_FL)
3234 + inode->i_vflags |= V_COW;
3237 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3238 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3240 - unsigned int vfs_fl;
3241 + unsigned int vfs_fl, vfs_vf;
3242 unsigned long old_fl, new_fl;
3245 vfs_fl = ei->vfs_inode.i_flags;
3246 + vfs_vf = ei->vfs_inode.i_vflags;
3247 old_fl = ei->i_flags;
3248 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3249 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3251 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3254 + if (vfs_fl & S_IMMUTABLE)
3255 + new_fl |= EXT4_IMMUTABLE_FL;
3256 + if (vfs_fl & S_IXUNLINK)
3257 + new_fl |= EXT4_IXUNLINK_FL;
3259 if (vfs_fl & S_SYNC)
3260 new_fl |= EXT4_SYNC_FL;
3261 if (vfs_fl & S_APPEND)
3262 new_fl |= EXT4_APPEND_FL;
3263 - if (vfs_fl & S_IMMUTABLE)
3264 - new_fl |= EXT4_IMMUTABLE_FL;
3265 if (vfs_fl & S_NOATIME)
3266 new_fl |= EXT4_NOATIME_FL;
3267 if (vfs_fl & S_DIRSYNC)
3268 new_fl |= EXT4_DIRSYNC_FL;
3270 + if (vfs_vf & V_BARRIER)
3271 + new_fl |= EXT4_BARRIER_FL;
3272 + if (vfs_vf & V_COW)
3273 + new_fl |= EXT4_COW_FL;
3274 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3277 @@ -3393,6 +3417,8 @@ struct inode *ext4_iget(struct super_blo
3278 journal_t *journal = EXT4_SB(sb)->s_journal;
3284 inode = iget_locked(sb, ino);
3286 @@ -3408,12 +3434,16 @@ struct inode *ext4_iget(struct super_blo
3288 raw_inode = ext4_raw_inode(&iloc);
3289 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3290 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3291 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3292 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3293 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3294 if (!(test_opt(inode->i_sb, NO_UID32))) {
3295 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3296 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3297 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3298 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3300 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3301 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3302 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3303 + le16_to_cpu(raw_inode->i_raw_tag));
3304 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3306 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3307 @@ -3632,6 +3662,8 @@ static int ext4_do_update_inode(handle_t
3308 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3309 struct ext4_inode_info *ei = EXT4_I(inode);
3310 struct buffer_head *bh = iloc->bh;
3311 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3312 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3313 int err = 0, rc, block;
3315 /* For fields not not tracking in the in-memory inode,
3316 @@ -3642,29 +3674,32 @@ static int ext4_do_update_inode(handle_t
3317 ext4_get_inode_flags(ei);
3318 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3319 if (!(test_opt(inode->i_sb, NO_UID32))) {
3320 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3321 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3322 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3323 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3325 * Fix up interoperability with old kernels. Otherwise, old inodes get
3326 * re-used with the upper 16 bits of the uid/gid intact
3329 raw_inode->i_uid_high =
3330 - cpu_to_le16(high_16_bits(inode->i_uid));
3331 + cpu_to_le16(high_16_bits(uid));
3332 raw_inode->i_gid_high =
3333 - cpu_to_le16(high_16_bits(inode->i_gid));
3334 + cpu_to_le16(high_16_bits(gid));
3336 raw_inode->i_uid_high = 0;
3337 raw_inode->i_gid_high = 0;
3340 raw_inode->i_uid_low =
3341 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3342 + cpu_to_le16(fs_high2lowuid(uid));
3343 raw_inode->i_gid_low =
3344 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3345 + cpu_to_le16(fs_high2lowgid(gid));
3346 raw_inode->i_uid_high = 0;
3347 raw_inode->i_gid_high = 0;
3349 +#ifdef CONFIG_TAGGING_INTERN
3350 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3352 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3354 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3355 @@ -3850,7 +3885,8 @@ int ext4_setattr(struct dentry *dentry,
3356 if (is_quota_modification(inode, attr))
3357 dquot_initialize(inode);
3358 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3359 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3360 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3361 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3364 /* (user+group)*(old+new) structure, inode write (sb,
3365 @@ -3872,6 +3908,8 @@ int ext4_setattr(struct dentry *dentry,
3366 inode->i_uid = attr->ia_uid;
3367 if (attr->ia_valid & ATTR_GID)
3368 inode->i_gid = attr->ia_gid;
3369 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3370 + inode->i_tag = attr->ia_tag;
3371 error = ext4_mark_inode_dirty(handle, inode);
3372 ext4_journal_stop(handle);
3374 diff -NurpP --minimal linux-3.1.1/fs/ext4/ioctl.c linux-3.1.1-vs2.3.2/fs/ext4/ioctl.c
3375 --- linux-3.1.1/fs/ext4/ioctl.c 2011-10-24 18:45:27.000000000 +0200
3376 +++ linux-3.1.1-vs2.3.2/fs/ext4/ioctl.c 2011-10-24 18:53:33.000000000 +0200
3378 #include <linux/compat.h>
3379 #include <linux/mount.h>
3380 #include <linux/file.h>
3381 +#include <linux/vs_tag.h>
3382 #include <asm/uaccess.h>
3383 #include "ext4_jbd2.h"
3387 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3389 + handle_t *handle = NULL;
3390 + struct ext4_iloc iloc;
3393 + handle = ext4_journal_start(inode, 1);
3394 + if (IS_ERR(handle))
3395 + return PTR_ERR(handle);
3397 + if (IS_SYNC(inode))
3398 + ext4_handle_sync(handle);
3399 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3403 + inode->i_flags = flags;
3404 + inode->i_vflags = vflags;
3405 + ext4_get_inode_flags(EXT4_I(inode));
3406 + inode->i_ctime = ext4_current_time(inode);
3408 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3410 + ext4_journal_stop(handle);
3414 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3416 struct inode *inode = filp->f_dentry->d_inode;
3417 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3419 flags = ext4_mask_flags(inode->i_mode, flags);
3421 + if (IS_BARRIER(inode)) {
3422 + vxwprintk_task(1, "messing with the barrier.");
3427 mutex_lock(&inode->i_mutex);
3428 /* Is it quota file? Do not allow user to mess with it */
3429 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3431 * This test looks nicer. Thanks to Pauline Middelink
3433 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3434 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3435 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3436 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3437 if (!capable(CAP_LINUX_IMMUTABLE))
3440 diff -NurpP --minimal linux-3.1.1/fs/ext4/namei.c linux-3.1.1-vs2.3.2/fs/ext4/namei.c
3441 --- linux-3.1.1/fs/ext4/namei.c 2011-11-15 16:44:52.000000000 +0100
3442 +++ linux-3.1.1-vs2.3.2/fs/ext4/namei.c 2011-11-15 17:08:44.000000000 +0100
3444 #include <linux/quotaops.h>
3445 #include <linux/buffer_head.h>
3446 #include <linux/bio.h>
3447 +#include <linux/vs_tag.h>
3449 #include "ext4_jbd2.h"
3451 @@ -925,6 +926,7 @@ restart:
3452 ll_rw_block(READ | REQ_META | REQ_PRIO,
3455 + dx_propagate_tag(nd, inode);
3457 if ((bh = bh_use[ra_ptr++]) == NULL)
3459 @@ -2588,6 +2590,7 @@ const struct inode_operations ext4_dir_i
3461 .get_acl = ext4_get_acl,
3462 .fiemap = ext4_fiemap,
3463 + .sync_flags = ext4_sync_flags,
3466 const struct inode_operations ext4_special_inode_operations = {
3467 diff -NurpP --minimal linux-3.1.1/fs/ext4/super.c linux-3.1.1-vs2.3.2/fs/ext4/super.c
3468 --- linux-3.1.1/fs/ext4/super.c 2011-10-24 18:45:27.000000000 +0200
3469 +++ linux-3.1.1-vs2.3.2/fs/ext4/super.c 2011-10-24 18:53:33.000000000 +0200
3470 @@ -1320,6 +1320,7 @@ enum {
3471 Opt_dioread_nolock, Opt_dioread_lock,
3472 Opt_discard, Opt_nodiscard,
3473 Opt_init_inode_table, Opt_noinit_inode_table,
3474 + Opt_tag, Opt_notag, Opt_tagid
3477 static const match_table_t tokens = {
3478 @@ -1395,6 +1396,9 @@ static const match_table_t tokens = {
3479 {Opt_init_inode_table, "init_itable=%u"},
3480 {Opt_init_inode_table, "init_itable"},
3481 {Opt_noinit_inode_table, "noinit_itable"},
3483 + {Opt_notag, "notag"},
3484 + {Opt_tagid, "tagid=%u"},
3488 @@ -1563,6 +1567,20 @@ static int parse_options(char *options,
3490 set_opt(sb, NO_UID32);
3492 +#ifndef CONFIG_TAGGING_NONE
3494 + set_opt(sb, TAGGED);
3497 + clear_opt(sb, TAGGED);
3500 +#ifdef CONFIG_PROPAGATE
3503 + set_opt(sb, TAGGED);
3509 @@ -3224,6 +3242,9 @@ static int ext4_fill_super(struct super_
3510 &journal_ioprio, NULL, 0))
3513 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3514 + sb->s_flags |= MS_TAGGED;
3516 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3517 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3519 @@ -4351,6 +4372,14 @@ static int ext4_remount(struct super_blo
3520 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3521 ext4_abort(sb, "Abort forced by user");
3523 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3524 + !(sb->s_flags & MS_TAGGED)) {
3525 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3528 + goto restore_opts;
3531 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3532 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3534 diff -NurpP --minimal linux-3.1.1/fs/fcntl.c linux-3.1.1-vs2.3.2/fs/fcntl.c
3535 --- linux-3.1.1/fs/fcntl.c 2011-05-22 16:17:52.000000000 +0200
3536 +++ linux-3.1.1-vs2.3.2/fs/fcntl.c 2011-10-24 18:53:33.000000000 +0200
3538 #include <linux/signal.h>
3539 #include <linux/rcupdate.h>
3540 #include <linux/pid_namespace.h>
3541 +#include <linux/vs_limit.h>
3543 #include <asm/poll.h>
3544 #include <asm/siginfo.h>
3545 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3548 filp_close(tofree, files);
3550 + vx_openfd_inc(newfd); /* fd was unused */
3554 @@ -447,6 +450,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3555 filp = fget_raw(fd);
3558 + if (!vx_files_avail(1))
3561 if (unlikely(filp->f_mode & FMODE_PATH)) {
3562 if (!check_fcntl_cmd(cmd)) {
3563 diff -NurpP --minimal linux-3.1.1/fs/file.c linux-3.1.1-vs2.3.2/fs/file.c
3564 --- linux-3.1.1/fs/file.c 2011-05-22 16:17:52.000000000 +0200
3565 +++ linux-3.1.1-vs2.3.2/fs/file.c 2011-10-24 18:53:33.000000000 +0200
3567 #include <linux/spinlock.h>
3568 #include <linux/rcupdate.h>
3569 #include <linux/workqueue.h>
3570 +#include <linux/vs_limit.h>
3572 struct fdtable_defer {
3574 @@ -359,6 +360,8 @@ struct files_struct *dup_fd(struct files
3575 struct file *f = *old_fds++;
3578 + /* TODO: sum it first for check and performance */
3579 + vx_openfd_inc(open_files - i);
3582 * The fd may be claimed in the fd bitmap but not yet
3583 @@ -466,6 +469,7 @@ repeat:
3585 FD_CLR(fd, fdt->close_on_exec);
3587 + vx_openfd_inc(fd);
3590 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3591 diff -NurpP --minimal linux-3.1.1/fs/file_table.c linux-3.1.1-vs2.3.2/fs/file_table.c
3592 --- linux-3.1.1/fs/file_table.c 2011-10-24 18:45:27.000000000 +0200
3593 +++ linux-3.1.1-vs2.3.2/fs/file_table.c 2011-10-24 18:53:33.000000000 +0200
3595 #include <linux/percpu_counter.h>
3596 #include <linux/percpu.h>
3597 #include <linux/ima.h>
3598 +#include <linux/vs_limit.h>
3599 +#include <linux/vs_context.h>
3601 #include <linux/atomic.h>
3603 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
3604 spin_lock_init(&f->f_lock);
3605 eventpoll_init_file(f);
3606 /* f->f_version: 0 */
3607 + f->f_xid = vx_current_xid();
3612 @@ -253,6 +257,8 @@ static void __fput(struct file *file)
3614 fops_put(file->f_op);
3615 put_pid(file->f_owner.pid);
3616 + vx_files_dec(file);
3618 file_sb_list_del(file);
3619 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
3620 i_readcount_dec(inode);
3621 @@ -383,6 +389,8 @@ void put_filp(struct file *file)
3623 if (atomic_long_dec_and_test(&file->f_count)) {
3624 security_file_free(file);
3625 + vx_files_dec(file);
3627 file_sb_list_del(file);
3630 diff -NurpP --minimal linux-3.1.1/fs/fs_struct.c linux-3.1.1-vs2.3.2/fs/fs_struct.c
3631 --- linux-3.1.1/fs/fs_struct.c 2011-03-15 18:07:31.000000000 +0100
3632 +++ linux-3.1.1-vs2.3.2/fs/fs_struct.c 2011-10-24 18:53:33.000000000 +0200
3634 #include <linux/path.h>
3635 #include <linux/slab.h>
3636 #include <linux/fs_struct.h>
3637 +#include <linux/vserver/global.h>
3638 #include "internal.h"
3640 static inline void path_get_longterm(struct path *path)
3641 @@ -96,6 +97,7 @@ void free_fs_struct(struct fs_struct *fs
3643 path_put_longterm(&fs->root);
3644 path_put_longterm(&fs->pwd);
3645 + atomic_dec(&vs_global_fs);
3646 kmem_cache_free(fs_cachep, fs);
3649 @@ -135,6 +137,7 @@ struct fs_struct *copy_fs_struct(struct
3651 path_get_longterm(&fs->pwd);
3652 spin_unlock(&old->lock);
3653 + atomic_inc(&vs_global_fs);
3657 diff -NurpP --minimal linux-3.1.1/fs/gfs2/file.c linux-3.1.1-vs2.3.2/fs/gfs2/file.c
3658 --- linux-3.1.1/fs/gfs2/file.c 2011-10-24 18:45:27.000000000 +0200
3659 +++ linux-3.1.1-vs2.3.2/fs/gfs2/file.c 2011-10-24 18:53:33.000000000 +0200
3660 @@ -134,6 +134,9 @@ static const u32 fsflags_to_gfs2[32] = {
3661 [7] = GFS2_DIF_NOATIME,
3662 [12] = GFS2_DIF_EXHASH,
3663 [14] = GFS2_DIF_INHERIT_JDATA,
3664 + [27] = GFS2_DIF_IXUNLINK,
3665 + [26] = GFS2_DIF_BARRIER,
3666 + [29] = GFS2_DIF_COW,
3669 static const u32 gfs2_to_fsflags[32] = {
3670 @@ -143,6 +146,9 @@ static const u32 gfs2_to_fsflags[32] = {
3671 [gfs2fl_NoAtime] = FS_NOATIME_FL,
3672 [gfs2fl_ExHash] = FS_INDEX_FL,
3673 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3674 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3675 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3676 + [gfs2fl_Cow] = FS_COW_FL,
3679 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3680 @@ -173,12 +179,18 @@ void gfs2_set_inode_flags(struct inode *
3682 struct gfs2_inode *ip = GFS2_I(inode);
3683 unsigned int flags = inode->i_flags;
3684 + unsigned int vflags = inode->i_vflags;
3686 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3687 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
3689 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
3690 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
3691 inode->i_flags |= S_NOSEC;
3692 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3693 flags |= S_IMMUTABLE;
3694 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3695 + flags |= S_IXUNLINK;
3697 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3699 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3700 @@ -186,6 +198,43 @@ void gfs2_set_inode_flags(struct inode *
3701 if (ip->i_diskflags & GFS2_DIF_SYNC)
3703 inode->i_flags = flags;
3705 + vflags &= ~(V_BARRIER | V_COW);
3707 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3708 + vflags |= V_BARRIER;
3709 + if (ip->i_diskflags & GFS2_DIF_COW)
3711 + inode->i_vflags = vflags;
3714 +void gfs2_get_inode_flags(struct inode *inode)
3716 + struct gfs2_inode *ip = GFS2_I(inode);
3717 + unsigned int flags = inode->i_flags;
3718 + unsigned int vflags = inode->i_vflags;
3720 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3721 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3722 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3723 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3725 + if (flags & S_IMMUTABLE)
3726 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3727 + if (flags & S_IXUNLINK)
3728 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3730 + if (flags & S_APPEND)
3731 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3732 + if (flags & S_NOATIME)
3733 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3734 + if (flags & S_SYNC)
3735 + ip->i_diskflags |= GFS2_DIF_SYNC;
3737 + if (vflags & V_BARRIER)
3738 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3739 + if (vflags & V_COW)
3740 + ip->i_diskflags |= GFS2_DIF_COW;
3743 /* Flags that can be set by user space */
3744 @@ -297,6 +346,37 @@ static int gfs2_set_flags(struct file *f
3745 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3748 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3750 + struct gfs2_inode *ip = GFS2_I(inode);
3751 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3752 + struct buffer_head *bh;
3753 + struct gfs2_holder gh;
3756 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3759 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3762 + error = gfs2_meta_inode_buffer(ip, &bh);
3764 + goto out_trans_end;
3765 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
3766 + inode->i_flags = flags;
3767 + inode->i_vflags = vflags;
3768 + gfs2_get_inode_flags(inode);
3769 + gfs2_dinode_out(ip, bh->b_data);
3771 + gfs2_set_aops(inode);
3773 + gfs2_trans_end(sdp);
3775 + gfs2_glock_dq_uninit(&gh);
3779 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3782 diff -NurpP --minimal linux-3.1.1/fs/gfs2/inode.h linux-3.1.1-vs2.3.2/fs/gfs2/inode.h
3783 --- linux-3.1.1/fs/gfs2/inode.h 2011-10-24 18:45:27.000000000 +0200
3784 +++ linux-3.1.1-vs2.3.2/fs/gfs2/inode.h 2011-10-24 18:53:33.000000000 +0200
3785 @@ -120,6 +120,7 @@ extern const struct file_operations gfs2
3786 extern const struct file_operations gfs2_dir_fops_nolock;
3788 extern void gfs2_set_inode_flags(struct inode *inode);
3789 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3791 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3792 extern const struct file_operations gfs2_file_fops;
3793 diff -NurpP --minimal linux-3.1.1/fs/inode.c linux-3.1.1-vs2.3.2/fs/inode.c
3794 --- linux-3.1.1/fs/inode.c 2011-10-24 18:45:27.000000000 +0200
3795 +++ linux-3.1.1-vs2.3.2/fs/inode.c 2011-10-24 18:53:33.000000000 +0200
3797 #include <linux/ima.h>
3798 #include <linux/cred.h>
3799 #include <linux/buffer_head.h> /* for inode_has_buffers */
3800 +#include <linux/vs_tag.h>
3801 #include "internal.h"
3804 @@ -137,6 +138,9 @@ int inode_init_always(struct super_block
3805 struct address_space *const mapping = &inode->i_data;
3809 + /* essential because of inode slab reuse */
3811 inode->i_blkbits = sb->s_blocksize_bits;
3813 atomic_set(&inode->i_count, 1);
3814 @@ -158,6 +162,7 @@ int inode_init_always(struct super_block
3815 inode->i_bdev = NULL;
3816 inode->i_cdev = NULL;
3818 + inode->i_mdev = 0;
3819 inode->dirtied_when = 0;
3821 if (security_inode_alloc(inode))
3822 @@ -399,6 +404,8 @@ void __insert_inode_hash(struct inode *i
3824 EXPORT_SYMBOL(__insert_inode_hash);
3826 +EXPORT_SYMBOL_GPL(__iget);
3829 * __remove_inode_hash - remove an inode from the hash
3830 * @inode: inode to unhash
3831 @@ -1626,9 +1633,11 @@ void init_special_inode(struct inode *in
3832 if (S_ISCHR(mode)) {
3833 inode->i_fop = &def_chr_fops;
3834 inode->i_rdev = rdev;
3835 + inode->i_mdev = rdev;
3836 } else if (S_ISBLK(mode)) {
3837 inode->i_fop = &def_blk_fops;
3838 inode->i_rdev = rdev;
3839 + inode->i_mdev = rdev;
3840 } else if (S_ISFIFO(mode))
3841 inode->i_fop = &def_fifo_fops;
3842 else if (S_ISSOCK(mode))
3843 @@ -1657,6 +1666,7 @@ void inode_init_owner(struct inode *inod
3845 inode->i_gid = current_fsgid();
3846 inode->i_mode = mode;
3847 + inode->i_tag = dx_current_fstag(inode->i_sb);
3849 EXPORT_SYMBOL(inode_init_owner);
3851 diff -NurpP --minimal linux-3.1.1/fs/ioctl.c linux-3.1.1-vs2.3.2/fs/ioctl.c
3852 --- linux-3.1.1/fs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3853 +++ linux-3.1.1-vs2.3.2/fs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
3855 #include <linux/writeback.h>
3856 #include <linux/buffer_head.h>
3857 #include <linux/falloc.h>
3858 +#include <linux/proc_fs.h>
3859 +#include <linux/vserver/inode.h>
3860 +#include <linux/vs_tag.h>
3862 #include <asm/ioctls.h>
3864 diff -NurpP --minimal linux-3.1.1/fs/ioprio.c linux-3.1.1-vs2.3.2/fs/ioprio.c
3865 --- linux-3.1.1/fs/ioprio.c 2011-01-05 21:50:24.000000000 +0100
3866 +++ linux-3.1.1-vs2.3.2/fs/ioprio.c 2011-10-24 18:53:33.000000000 +0200
3868 #include <linux/syscalls.h>
3869 #include <linux/security.h>
3870 #include <linux/pid_namespace.h>
3871 +#include <linux/vs_base.h>
3873 int set_task_ioprio(struct task_struct *task, int ioprio)
3875 @@ -119,6 +120,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3877 pgrp = find_vpid(who);
3878 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3879 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3881 ret = set_task_ioprio(p, ioprio);
3884 @@ -208,6 +211,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3886 pgrp = find_vpid(who);
3887 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3888 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3890 tmpio = get_task_ioprio(p);
3893 diff -NurpP --minimal linux-3.1.1/fs/jfs/file.c linux-3.1.1-vs2.3.2/fs/jfs/file.c
3894 --- linux-3.1.1/fs/jfs/file.c 2011-10-24 18:45:27.000000000 +0200
3895 +++ linux-3.1.1-vs2.3.2/fs/jfs/file.c 2011-10-24 18:53:33.000000000 +0200
3896 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
3897 if (is_quota_modification(inode, iattr))
3898 dquot_initialize(inode);
3899 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3900 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3901 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3902 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3903 rc = dquot_transfer(inode, iattr);
3906 @@ -142,6 +143,7 @@ const struct inode_operations jfs_file_i
3907 #ifdef CONFIG_JFS_POSIX_ACL
3908 .get_acl = jfs_get_acl,
3910 + .sync_flags = jfs_sync_flags,
3913 const struct file_operations jfs_file_operations = {
3914 diff -NurpP --minimal linux-3.1.1/fs/jfs/ioctl.c linux-3.1.1-vs2.3.2/fs/jfs/ioctl.c
3915 --- linux-3.1.1/fs/jfs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3916 +++ linux-3.1.1-vs2.3.2/fs/jfs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
3918 #include <linux/mount.h>
3919 #include <linux/time.h>
3920 #include <linux/sched.h>
3921 +#include <linux/mount.h>
3922 #include <asm/current.h>
3923 #include <asm/uaccess.h>
3925 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
3929 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3931 + inode->i_flags = flags;
3932 + inode->i_vflags = vflags;
3933 + jfs_get_inode_flags(JFS_IP(inode));
3934 + inode->i_ctime = CURRENT_TIME_SEC;
3935 + mark_inode_dirty(inode);
3939 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3941 struct inode *inode = filp->f_dentry->d_inode;
3942 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
3943 if (!S_ISDIR(inode->i_mode))
3944 flags &= ~JFS_DIRSYNC_FL;
3946 + if (IS_BARRIER(inode)) {
3947 + vxwprintk_task(1, "messing with the barrier.");
3951 /* Is it quota file? Do not allow user to mess with it */
3952 if (IS_NOQUOTA(inode)) {
3954 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
3955 * the relevant capability.
3957 if ((oldflags & JFS_IMMUTABLE_FL) ||
3958 - ((flags ^ oldflags) &
3959 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3960 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3961 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3962 if (!capable(CAP_LINUX_IMMUTABLE)) {
3963 mutex_unlock(&inode->i_mutex);
3965 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
3969 - flags = flags & JFS_FL_USER_MODIFIABLE;
3970 + flags &= JFS_FL_USER_MODIFIABLE;
3971 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3972 jfs_inode->mode2 = flags;
3974 diff -NurpP --minimal linux-3.1.1/fs/jfs/jfs_dinode.h linux-3.1.1-vs2.3.2/fs/jfs/jfs_dinode.h
3975 --- linux-3.1.1/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
3976 +++ linux-3.1.1-vs2.3.2/fs/jfs/jfs_dinode.h 2011-10-24 18:53:33.000000000 +0200
3977 @@ -161,9 +161,13 @@ struct dinode {
3979 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3980 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3981 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3983 -#define JFS_FL_USER_VISIBLE 0x03F80000
3984 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3985 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3986 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3988 +#define JFS_FL_USER_VISIBLE 0x07F80000
3989 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3990 #define JFS_FL_INHERIT 0x03C80000
3992 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3993 diff -NurpP --minimal linux-3.1.1/fs/jfs/jfs_filsys.h linux-3.1.1-vs2.3.2/fs/jfs/jfs_filsys.h
3994 --- linux-3.1.1/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
3995 +++ linux-3.1.1-vs2.3.2/fs/jfs/jfs_filsys.h 2011-10-24 18:53:33.000000000 +0200
3997 #define JFS_NAME_MAX 255
3998 #define JFS_PATH_MAX BPSIZE
4000 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
4003 * file system state (superblock state)
4004 diff -NurpP --minimal linux-3.1.1/fs/jfs/jfs_imap.c linux-3.1.1-vs2.3.2/fs/jfs/jfs_imap.c
4005 --- linux-3.1.1/fs/jfs/jfs_imap.c 2011-07-22 11:18:05.000000000 +0200
4006 +++ linux-3.1.1-vs2.3.2/fs/jfs/jfs_imap.c 2011-10-24 18:53:33.000000000 +0200
4008 #include <linux/pagemap.h>
4009 #include <linux/quotaops.h>
4010 #include <linux/slab.h>
4011 +#include <linux/vs_tag.h>
4013 #include "jfs_incore.h"
4014 #include "jfs_inode.h"
4015 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
4017 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
4018 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
4022 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
4023 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
4024 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
4026 ip->i_nlink = le32_to_cpu(dip->di_nlink);
4028 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
4029 + uid = le32_to_cpu(dip->di_uid);
4030 + gid = le32_to_cpu(dip->di_gid);
4031 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
4033 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
4035 ip->i_uid = jfs_ip->saved_uid;
4037 ip->i_uid = sbi->uid;
4040 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
4041 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
4043 ip->i_gid = jfs_ip->saved_gid;
4045 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
4046 dip->di_size = cpu_to_le64(ip->i_size);
4047 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
4048 dip->di_nlink = cpu_to_le32(ip->i_nlink);
4049 - if (sbi->uid == -1)
4050 - dip->di_uid = cpu_to_le32(ip->i_uid);
4052 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
4053 - if (sbi->gid == -1)
4054 - dip->di_gid = cpu_to_le32(ip->i_gid);
4056 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
4058 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
4059 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
4060 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
4061 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
4063 jfs_get_inode_flags(jfs_ip);
4065 * mode2 is only needed for storing the higher order bits.
4066 diff -NurpP --minimal linux-3.1.1/fs/jfs/jfs_inode.c linux-3.1.1-vs2.3.2/fs/jfs/jfs_inode.c
4067 --- linux-3.1.1/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
4068 +++ linux-3.1.1-vs2.3.2/fs/jfs/jfs_inode.c 2011-10-24 18:53:33.000000000 +0200
4071 #include <linux/fs.h>
4072 #include <linux/quotaops.h>
4073 +#include <linux/vs_tag.h>
4074 #include "jfs_incore.h"
4075 #include "jfs_inode.h"
4076 #include "jfs_filsys.h"
4077 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
4079 unsigned int flags = JFS_IP(inode)->mode2;
4081 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
4082 - S_NOATIME | S_DIRSYNC | S_SYNC);
4083 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4084 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4086 if (flags & JFS_IMMUTABLE_FL)
4087 inode->i_flags |= S_IMMUTABLE;
4088 + if (flags & JFS_IXUNLINK_FL)
4089 + inode->i_flags |= S_IXUNLINK;
4091 + if (flags & JFS_SYNC_FL)
4092 + inode->i_flags |= S_SYNC;
4093 if (flags & JFS_APPEND_FL)
4094 inode->i_flags |= S_APPEND;
4095 if (flags & JFS_NOATIME_FL)
4096 inode->i_flags |= S_NOATIME;
4097 if (flags & JFS_DIRSYNC_FL)
4098 inode->i_flags |= S_DIRSYNC;
4099 - if (flags & JFS_SYNC_FL)
4100 - inode->i_flags |= S_SYNC;
4102 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4104 + if (flags & JFS_BARRIER_FL)
4105 + inode->i_vflags |= V_BARRIER;
4106 + if (flags & JFS_COW_FL)
4107 + inode->i_vflags |= V_COW;
4110 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4112 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4113 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4115 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4116 + JFS_APPEND_FL | JFS_NOATIME_FL |
4117 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4118 + JFS_BARRIER_FL | JFS_COW_FL);
4120 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4121 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4122 if (flags & S_IMMUTABLE)
4123 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4124 + if (flags & S_IXUNLINK)
4125 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4127 if (flags & S_APPEND)
4128 jfs_ip->mode2 |= JFS_APPEND_FL;
4129 if (flags & S_NOATIME)
4130 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4131 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4133 jfs_ip->mode2 |= JFS_SYNC_FL;
4135 + if (vflags & V_BARRIER)
4136 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4137 + if (vflags & V_COW)
4138 + jfs_ip->mode2 |= JFS_COW_FL;
4142 diff -NurpP --minimal linux-3.1.1/fs/jfs/jfs_inode.h linux-3.1.1-vs2.3.2/fs/jfs/jfs_inode.h
4143 --- linux-3.1.1/fs/jfs/jfs_inode.h 2011-10-24 18:45:27.000000000 +0200
4144 +++ linux-3.1.1-vs2.3.2/fs/jfs/jfs_inode.h 2011-10-24 18:53:33.000000000 +0200
4145 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4146 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4147 int fh_len, int fh_type);
4148 extern void jfs_set_inode_flags(struct inode *);
4149 +extern int jfs_sync_flags(struct inode *, int, int);
4150 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4151 extern int jfs_setattr(struct dentry *, struct iattr *);
4153 diff -NurpP --minimal linux-3.1.1/fs/jfs/namei.c linux-3.1.1-vs2.3.2/fs/jfs/namei.c
4154 --- linux-3.1.1/fs/jfs/namei.c 2011-10-24 18:45:27.000000000 +0200
4155 +++ linux-3.1.1-vs2.3.2/fs/jfs/namei.c 2011-10-24 18:53:33.000000000 +0200
4157 #include <linux/ctype.h>
4158 #include <linux/quotaops.h>
4159 #include <linux/exportfs.h>
4160 +#include <linux/vs_tag.h>
4161 #include "jfs_incore.h"
4162 #include "jfs_superblock.h"
4163 #include "jfs_inode.h"
4164 @@ -1474,6 +1475,7 @@ static struct dentry *jfs_lookup(struct
4165 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
4168 + dx_propagate_tag(nd, ip);
4169 return d_splice_alias(ip, dentry);
4172 @@ -1538,6 +1540,7 @@ const struct inode_operations jfs_dir_in
4173 #ifdef CONFIG_JFS_POSIX_ACL
4174 .get_acl = jfs_get_acl,
4176 + .sync_flags = jfs_sync_flags,
4179 const struct file_operations jfs_dir_operations = {
4180 diff -NurpP --minimal linux-3.1.1/fs/jfs/super.c linux-3.1.1-vs2.3.2/fs/jfs/super.c
4181 --- linux-3.1.1/fs/jfs/super.c 2011-05-22 16:17:53.000000000 +0200
4182 +++ linux-3.1.1-vs2.3.2/fs/jfs/super.c 2011-10-24 18:53:33.000000000 +0200
4183 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
4185 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4186 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4187 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4188 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4189 + Opt_tag, Opt_notag, Opt_tagid
4192 static const match_table_t tokens = {
4193 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
4194 {Opt_resize, "resize=%u"},
4195 {Opt_resize_nosize, "resize"},
4196 {Opt_errors, "errors=%s"},
4198 + {Opt_notag, "notag"},
4199 + {Opt_tagid, "tagid=%u"},
4200 + {Opt_tag, "tagxid"},
4201 {Opt_ignore, "noquota"},
4202 {Opt_ignore, "quota"},
4203 {Opt_usrquota, "usrquota"},
4204 @@ -342,6 +347,20 @@ static int parse_options(char *options,
4208 +#ifndef CONFIG_TAGGING_NONE
4210 + *flag |= JFS_TAGGED;
4213 + *flag &= JFS_TAGGED;
4216 +#ifdef CONFIG_PROPAGATE
4219 + *flag |= JFS_TAGGED;
4223 printk("jfs: Unrecognized mount option \"%s\" "
4224 " or missing value\n", p);
4225 @@ -373,6 +392,12 @@ static int jfs_remount(struct super_bloc
4229 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4230 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4236 if (sb->s_flags & MS_RDONLY) {
4238 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4239 #ifdef CONFIG_JFS_POSIX_ACL
4240 sb->s_flags |= MS_POSIXACL;
4242 + /* map mount option tagxid */
4243 + if (sbi->flag & JFS_TAGGED)
4244 + sb->s_flags |= MS_TAGGED;
4247 printk(KERN_ERR "resize option for remount only\n");
4248 diff -NurpP --minimal linux-3.1.1/fs/libfs.c linux-3.1.1-vs2.3.2/fs/libfs.c
4249 --- linux-3.1.1/fs/libfs.c 2011-10-24 18:45:27.000000000 +0200
4250 +++ linux-3.1.1-vs2.3.2/fs/libfs.c 2011-10-24 18:53:33.000000000 +0200
4251 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
4252 * both impossible due to the lock on directory.
4255 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4256 +static inline int do_dcache_readdir_filter(struct file *filp,
4257 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4259 struct dentry *dentry = filp->f_path.dentry;
4260 struct dentry *cursor = filp->private_data;
4261 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
4262 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4263 struct dentry *next;
4264 next = list_entry(p, struct dentry, d_u.d_child);
4265 + if (filter && !filter(next))
4267 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4268 if (!simple_positive(next)) {
4269 spin_unlock(&next->d_lock);
4270 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
4274 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4276 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4279 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4280 + int (*filter)(struct dentry *))
4282 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4285 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4288 @@ -975,6 +989,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4289 EXPORT_SYMBOL(dcache_dir_lseek);
4290 EXPORT_SYMBOL(dcache_dir_open);
4291 EXPORT_SYMBOL(dcache_readdir);
4292 +EXPORT_SYMBOL(dcache_readdir_filter);
4293 EXPORT_SYMBOL(generic_read_dir);
4294 EXPORT_SYMBOL(mount_pseudo);
4295 EXPORT_SYMBOL(simple_write_begin);
4296 diff -NurpP --minimal linux-3.1.1/fs/locks.c linux-3.1.1-vs2.3.2/fs/locks.c
4297 --- linux-3.1.1/fs/locks.c 2011-10-24 18:45:27.000000000 +0200
4298 +++ linux-3.1.1-vs2.3.2/fs/locks.c 2011-10-24 18:53:33.000000000 +0200
4300 #include <linux/time.h>
4301 #include <linux/rcupdate.h>
4302 #include <linux/pid_namespace.h>
4303 +#include <linux/vs_base.h>
4304 +#include <linux/vs_limit.h>
4306 #include <asm/uaccess.h>
4308 @@ -170,11 +172,17 @@ static void locks_init_lock_heads(struct
4309 /* Allocate an empty lock structure. */
4310 struct file_lock *locks_alloc_lock(void)
4312 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4313 + struct file_lock *fl;
4316 - locks_init_lock_heads(fl);
4317 + if (!vx_locks_avail(1))
4320 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4323 + locks_init_lock_heads(fl);
4328 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4329 @@ -202,6 +210,7 @@ void locks_free_lock(struct file_lock *f
4330 BUG_ON(!list_empty(&fl->fl_block));
4331 BUG_ON(!list_empty(&fl->fl_link));
4334 locks_release_private(fl);
4335 kmem_cache_free(filelock_cache, fl);
4337 @@ -211,6 +220,7 @@ void locks_init_lock(struct file_lock *f
4339 memset(fl, 0, sizeof(struct file_lock));
4340 locks_init_lock_heads(fl);
4344 EXPORT_SYMBOL(locks_init_lock);
4345 @@ -251,6 +261,7 @@ void locks_copy_lock(struct file_lock *n
4346 new->fl_file = fl->fl_file;
4347 new->fl_ops = fl->fl_ops;
4348 new->fl_lmops = fl->fl_lmops;
4349 + new->fl_xid = fl->fl_xid;
4351 locks_copy_private(new, fl);
4353 @@ -289,6 +300,11 @@ static int flock_make_lock(struct file *
4354 fl->fl_flags = FL_FLOCK;
4356 fl->fl_end = OFFSET_MAX;
4358 + vxd_assert(filp->f_xid == vx_current_xid(),
4359 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4360 + fl->fl_xid = filp->f_xid;
4365 @@ -438,6 +454,7 @@ static int lease_init(struct file *filp,
4367 fl->fl_owner = current->files;
4368 fl->fl_pid = current->tgid;
4369 + fl->fl_xid = vx_current_xid();
4372 fl->fl_flags = FL_LEASE;
4373 @@ -457,6 +474,11 @@ static struct file_lock *lease_alloc(str
4375 return ERR_PTR(error);
4377 + fl->fl_xid = vx_current_xid();
4379 + vxd_assert(filp->f_xid == fl->fl_xid,
4380 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4382 error = lease_init(filp, type, fl);
4384 locks_free_lock(fl);
4385 @@ -758,6 +780,7 @@ static int flock_lock_file(struct file *
4389 + new_fl->fl_xid = -1;
4391 for_each_lock(inode, before) {
4392 struct file_lock *fl = *before;
4393 @@ -778,6 +801,7 @@ find_conflict:
4395 locks_copy_lock(new_fl, request);
4396 locks_insert_lock(before, new_fl);
4397 + vx_locks_inc(new_fl);
4401 @@ -788,7 +812,8 @@ out:
4405 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4406 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4407 + struct file_lock *conflock, xid_t xid)
4409 struct file_lock *fl;
4410 struct file_lock *new_fl = NULL;
4411 @@ -798,6 +823,8 @@ static int __posix_lock_file(struct inod
4412 struct file_lock **before;
4413 int error, added = 0;
4415 + vxd_assert(xid == vx_current_xid(),
4416 + "xid(%d) == current(%d)", xid, vx_current_xid());
4418 * We may need two file_lock structures for this operation,
4419 * so we get them in advance to avoid races.
4420 @@ -808,7 +835,11 @@ static int __posix_lock_file(struct inod
4421 (request->fl_type != F_UNLCK ||
4422 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4423 new_fl = locks_alloc_lock();
4424 + new_fl->fl_xid = xid;
4425 + vx_locks_inc(new_fl);
4426 new_fl2 = locks_alloc_lock();
4427 + new_fl2->fl_xid = xid;
4428 + vx_locks_inc(new_fl2);
4432 @@ -1007,7 +1038,8 @@ static int __posix_lock_file(struct inod
4433 int posix_lock_file(struct file *filp, struct file_lock *fl,
4434 struct file_lock *conflock)
4436 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4437 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4438 + fl, conflock, filp->f_xid);
4440 EXPORT_SYMBOL(posix_lock_file);
4442 @@ -1097,7 +1129,7 @@ int locks_mandatory_area(int read_write,
4443 fl.fl_end = offset + count - 1;
4446 - error = __posix_lock_file(inode, &fl, NULL);
4447 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4448 if (error != FILE_LOCK_DEFERRED)
4450 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4451 @@ -1410,6 +1442,7 @@ int generic_setlease(struct file *filp,
4454 locks_insert_lock(before, lease);
4455 + vx_locks_inc(lease);
4459 @@ -1794,6 +1827,11 @@ int fcntl_setlk(unsigned int fd, struct
4460 if (file_lock == NULL)
4463 + vxd_assert(filp->f_xid == vx_current_xid(),
4464 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4465 + file_lock->fl_xid = filp->f_xid;
4466 + vx_locks_inc(file_lock);
4469 * This might block, so we do it before checking the inode.
4471 @@ -1912,6 +1950,11 @@ int fcntl_setlk64(unsigned int fd, struc
4472 if (file_lock == NULL)
4475 + vxd_assert(filp->f_xid == vx_current_xid(),
4476 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4477 + file_lock->fl_xid = filp->f_xid;
4478 + vx_locks_inc(file_lock);
4481 * This might block, so we do it before checking the inode.
4483 @@ -2177,8 +2220,11 @@ static int locks_show(struct seq_file *f
4485 lock_get_status(f, fl, *((loff_t *)f->private), "");
4487 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4488 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4489 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4491 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4496 diff -NurpP --minimal linux-3.1.1/fs/namei.c linux-3.1.1-vs2.3.2/fs/namei.c
4497 --- linux-3.1.1/fs/namei.c 2011-11-15 16:44:52.000000000 +0100
4498 +++ linux-3.1.1-vs2.3.2/fs/namei.c 2011-11-16 14:28:54.000000000 +0100
4500 #include <linux/device_cgroup.h>
4501 #include <linux/fs_struct.h>
4502 #include <linux/posix_acl.h>
4503 +#include <linux/proc_fs.h>
4504 +#include <linux/vserver/inode.h>
4505 +#include <linux/vs_base.h>
4506 +#include <linux/vs_tag.h>
4507 +#include <linux/vs_cowbl.h>
4508 +#include <linux/vs_device.h>
4509 +#include <linux/vs_context.h>
4510 +#include <linux/pid_namespace.h>
4511 #include <asm/uaccess.h>
4513 #include "internal.h"
4514 @@ -222,6 +230,89 @@ static int check_acl(struct inode *inode
4518 +static inline int dx_barrier(const struct inode *inode)
4520 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4521 + vxwprintk_task(1, "did hit the barrier.");
4527 +static int __dx_permission(const struct inode *inode, int mask)
4529 + if (dx_barrier(inode))
4532 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4533 + /* devpts is xid tagged */
4534 + if (S_ISDIR(inode->i_mode) ||
4535 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4538 + /* just pretend we didn't find anything */
4541 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4542 + struct proc_dir_entry *de = PDE(inode);
4544 + if (de && !vx_hide_check(0, de->vx_flags))
4547 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4549 + struct task_struct *tsk;
4551 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4552 + vx_flags(VXF_STATE_SETUP, 0))
4555 + pid = PROC_I(inode)->pid;
4560 + tsk = pid_task(pid, PIDTYPE_PID);
4561 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4562 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4564 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4565 + rcu_read_unlock();
4568 + rcu_read_unlock();
4571 + /* FIXME: Should we block some entries here? */
4576 + if (dx_notagcheck(inode->i_sb) ||
4577 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4586 +int dx_permission(const struct inode *inode, int mask)
4588 + int ret = __dx_permission(inode, mask);
4589 + if (unlikely(ret)) {
4590 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4591 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4594 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4595 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4602 * This does basic POSIX ACL permission checking
4604 @@ -357,10 +448,14 @@ int inode_permission(struct inode *inode
4606 * Nobody gets write access to an immutable file.
4608 - if (IS_IMMUTABLE(inode))
4609 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4613 + retval = dx_permission(inode, mask);
4617 retval = do_inode_permission(inode, mask);
4620 @@ -1037,7 +1132,8 @@ static void follow_dotdot(struct nameida
4622 if (nd->path.dentry == nd->root.dentry &&
4623 nd->path.mnt == nd->root.mnt) {
4625 + /* for sane '/' avoid follow_mount() */
4628 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4629 /* rare case of legitimate dget_parent()... */
4630 @@ -1146,6 +1242,9 @@ static int do_lookup(struct nameidata *n
4632 if (unlikely(d_need_lookup(dentry)))
4635 + /* FIXME: check dx permission */
4638 path->dentry = dentry;
4639 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4640 @@ -1207,6 +1306,8 @@ retry:
4644 + /* FIXME: check dx permission */
4647 path->dentry = dentry;
4648 err = follow_managed(path, nd->flags);
4649 @@ -1901,7 +2002,7 @@ static int may_delete(struct inode *dir,
4652 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4653 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4654 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4657 if (!S_ISDIR(victim->d_inode->i_mode))
4658 @@ -1981,19 +2082,25 @@ int vfs_create(struct inode *dir, struct
4660 int error = may_create(dir, dentry);
4664 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
4668 if (!dir->i_op->create)
4669 return -EACCES; /* shouldn't it be ENOSYS? */
4672 error = security_inode_create(dir, dentry, mode);
4675 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
4678 error = dir->i_op->create(dir, dentry, mode, nd);
4680 fsnotify_create(dir, dentry);
4682 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
4686 @@ -2028,6 +2135,15 @@ static int may_open(struct path *path, i
4690 +#ifdef CONFIG_VSERVER_COWBL
4691 + if (IS_COW(inode) &&
4692 + ((flag & O_ACCMODE) != O_RDONLY)) {
4693 + if (IS_COW_LINK(inode))
4695 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4696 + mark_inode_dirty(inode);
4699 error = inode_permission(inode, acc_mode);
4702 @@ -2255,6 +2371,16 @@ ok:
4705 error = may_open(&nd->path, acc_mode, open_flag);
4706 +#ifdef CONFIG_VSERVER_COWBL
4707 + if (error == -EMLINK) {
4708 + struct dentry *dentry;
4709 + dentry = cow_break_link(pathname);
4710 + if (IS_ERR(dentry))
4711 + error = PTR_ERR(dentry);
4718 filp = nameidata_to_filp(nd);
4719 @@ -2297,6 +2423,7 @@ static struct file *path_openat(int dfd,
4724 filp = get_empty_filp();
4726 return ERR_PTR(-ENFILE);
4727 @@ -2334,6 +2461,17 @@ static struct file *path_openat(int dfd,
4728 filp = do_last(nd, &path, op, pathname);
4729 put_link(nd, &link, cookie);
4732 +#ifdef CONFIG_VSERVER_COWBL
4733 + if (filp == ERR_PTR(-EMLINK)) {
4734 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4735 + path_put(&nd->root);
4738 + release_open_intent(nd);
4743 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4744 path_put(&nd->root);
4745 @@ -2423,6 +2561,11 @@ struct dentry *kern_path_create(int dfd,
4749 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
4750 + path->dentry, path->dentry->d_name.len,
4751 + path->dentry->d_name.name, dentry,
4752 + dentry->d_name.len, dentry->d_name.name,
4753 + path->dentry->d_inode);
4757 @@ -2904,7 +3047,7 @@ int vfs_link(struct dentry *old_dentry,
4759 * A link to an append-only or immutable file cannot be created.
4761 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4762 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4764 if (!dir->i_op->link)
4766 @@ -3285,6 +3428,227 @@ int vfs_follow_link(struct nameidata *nd
4767 return __vfs_follow_link(nd, link);
4771 +#ifdef CONFIG_VSERVER_COWBL
4774 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4778 + return do_splice_direct(in, &ppos, out, len, 0);
4781 +struct dentry *cow_break_link(const char *pathname)
4783 + int ret, mode, pathlen, redo = 0;
4784 + struct nameidata old_nd, dir_nd;
4785 + struct path old_path, dir_path;
4786 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4787 + struct file *old_file;
4788 + struct file *new_file;
4789 + char *to, *path, pad='\251';
4792 + vxdprintk(VXD_CBIT(misc, 1),
4793 + "cow_break_link(" VS_Q("%s") ")", pathname);
4794 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4799 + /* old_nd will have refs to dentry and mnt */
4800 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4801 + vxdprintk(VXD_CBIT(misc, 2),
4802 + "do_path_lookup(old): %d [r=%d]",
4803 + ret, mnt_get_count(old_nd.path.mnt));
4805 + goto out_free_path;
4807 + old_path = old_nd.path;
4808 + old_dentry = old_path.dentry;
4809 + mode = old_dentry->d_inode->i_mode;
4811 + to = d_path(&old_path, path, PATH_MAX-2);
4812 + pathlen = strlen(to);
4813 + vxdprintk(VXD_CBIT(misc, 2),
4814 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4816 + old_dentry->d_name.len, old_dentry->d_name.name,
4817 + old_dentry->d_name.len);
4819 + to[pathlen + 1] = 0;
4821 + new_dentry = NULL;
4822 + to[pathlen] = pad--;
4824 + if (pad <= '\240')
4827 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4828 + /* dir_nd will have refs to dentry and mnt */
4829 + ret = do_path_lookup(AT_FDCWD, to,
4830 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4831 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4835 + /* this puppy downs the dir inode mutex if successful */
4836 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
4837 + if (!new_dentry || IS_ERR(new_dentry)) {
4838 + path_put(&dir_nd.path);
4839 + vxdprintk(VXD_CBIT(misc, 2),
4840 + "kern_path_create(new) failed with %ld",
4841 + PTR_ERR(new_dentry));
4844 + path_put(&dir_path);
4845 + vxdprintk(VXD_CBIT(misc, 2),
4846 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
4848 + new_dentry->d_name.len, new_dentry->d_name.name,
4849 + new_dentry->d_name.len);
4851 + dir = dir_nd.path.dentry;
4853 + ret = vfs_create(dir->d_inode, new_dentry, mode, &dir_nd);
4854 + vxdprintk(VXD_CBIT(misc, 2),
4855 + "vfs_create(new): %d", ret);
4856 + if (ret == -EEXIST) {
4857 + mutex_unlock(&dir->d_inode->i_mutex);
4858 + path_put(&dir_nd.path);
4863 + goto out_unlock_new;
4865 + /* drop out early, ret passes ENOENT */
4867 + if ((redo = d_unhashed(old_dentry)))
4868 + goto out_unlock_new;
4870 + path_get(&old_path);
4871 + /* this one cleans up the dentry/mnt in case of failure */
4872 + old_file = dentry_open(old_dentry, old_path.mnt,
4873 + O_RDONLY, current_cred());
4874 + vxdprintk(VXD_CBIT(misc, 2),
4875 + "dentry_open(old): %p", old_file);
4876 + if (IS_ERR(old_file)) {
4877 + ret = PTR_ERR(old_file);
4878 + goto out_unlock_new;
4882 + mntget(old_path.mnt);
4883 + /* this one cleans up the dentry/mnt in case of failure */
4884 + new_file = dentry_open(new_dentry, old_path.mnt,
4885 + O_WRONLY, current_cred());
4886 + vxdprintk(VXD_CBIT(misc, 2),
4887 + "dentry_open(new): %p", new_file);
4888 + if (IS_ERR(new_file)) {
4889 + ret = PTR_ERR(new_file);
4890 + goto out_fput_old;
4893 + size = i_size_read(old_file->f_dentry->d_inode);
4894 + ret = do_cow_splice(old_file, new_file, size);
4895 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4897 + goto out_fput_both;
4898 + } else if (ret < size) {
4900 + goto out_fput_both;
4902 + struct inode *old_inode = old_dentry->d_inode;
4903 + struct inode *new_inode = new_dentry->d_inode;
4904 + struct iattr attr = {
4905 + .ia_uid = old_inode->i_uid,
4906 + .ia_gid = old_inode->i_gid,
4907 + .ia_valid = ATTR_UID | ATTR_GID
4910 + setattr_copy(new_inode, &attr);
4911 + mark_inode_dirty(new_inode);
4914 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4916 + /* drop out late */
4918 + if ((redo = d_unhashed(old_dentry)))
4921 + vxdprintk(VXD_CBIT(misc, 2),
4922 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4923 + new_dentry->d_name.len, new_dentry->d_name.name,
4924 + new_dentry->d_name.len,
4925 + old_dentry->d_name.len, old_dentry->d_name.name,
4926 + old_dentry->d_name.len);
4927 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4928 + old_dentry->d_parent->d_inode, old_dentry);
4929 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4932 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4935 + vxdprintk(VXD_CBIT(misc, 3),
4936 + "fput(new_file=%p[#%ld])", new_file,
4937 + atomic_long_read(&new_file->f_count));
4941 + vxdprintk(VXD_CBIT(misc, 3),
4942 + "fput(old_file=%p[#%ld])", old_file,
4943 + atomic_long_read(&old_file->f_count));
4947 + mutex_unlock(&dir->d_inode->i_mutex);
4951 + /* error path cleanup */
4952 + vfs_unlink(dir->d_inode, new_dentry);
4956 + goto out_rel_both;
4957 + /* lookup dentry once again */
4958 + /* old_nd.path is freed as old_path in out_rel_old */
4959 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4961 + goto out_rel_both;
4964 + new_dentry = old_nd.path.dentry;
4965 + vxdprintk(VXD_CBIT(misc, 2),
4966 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4968 + new_dentry->d_name.len, new_dentry->d_name.name,
4969 + new_dentry->d_name.len);
4973 + path_put(&dir_nd.path);
4975 + path_put(&old_path);
4981 + new_dentry = ERR_PTR(ret);
4983 + vxdprintk(VXD_CBIT(misc, 3),
4984 + "cow_break_link returning with %p [r=%d]",
4985 + new_dentry, mnt_get_count(old_nd.path.mnt));
4986 + return new_dentry;
4991 /* get the link contents into pagecache */
4992 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4994 diff -NurpP --minimal linux-3.1.1/fs/namespace.c linux-3.1.1-vs2.3.2/fs/namespace.c
4995 --- linux-3.1.1/fs/namespace.c 2011-11-15 16:44:52.000000000 +0100
4996 +++ linux-3.1.1-vs2.3.2/fs/namespace.c 2011-11-15 17:13:06.000000000 +0100
4998 #include <linux/idr.h>
4999 #include <linux/fs_struct.h>
5000 #include <linux/fsnotify.h>
5001 +#include <linux/vs_base.h>
5002 +#include <linux/vs_context.h>
5003 +#include <linux/vs_tag.h>
5004 +#include <linux/vserver/space.h>
5005 +#include <linux/vserver/global.h>
5006 #include <asm/uaccess.h>
5007 #include <asm/unistd.h>
5009 @@ -679,6 +684,10 @@ vfs_kern_mount(struct file_system_type *
5011 return ERR_PTR(-ENODEV);
5013 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
5014 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
5015 + return ERR_PTR(-EPERM);
5017 mnt = alloc_vfsmnt(name);
5019 return ERR_PTR(-ENOMEM);
5020 @@ -724,6 +733,7 @@ static struct vfsmount *clone_mnt(struct
5021 mnt->mnt_root = dget(root);
5022 mnt->mnt_mountpoint = mnt->mnt_root;
5023 mnt->mnt_parent = mnt;
5024 + mnt->mnt_tag = old->mnt_tag;
5026 if (flag & CL_SLAVE) {
5027 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
5028 @@ -852,6 +862,31 @@ static inline void mangle(struct seq_fil
5029 seq_escape(m, s, " \t\n\\");
5032 +static int mnt_is_reachable(struct vfsmount *mnt)
5035 + struct dentry *point;
5038 + if (mnt == mnt->mnt_ns->root)
5041 + br_read_lock(vfsmount_lock);
5042 + root = current->fs->root;
5043 + point = root.dentry;
5045 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
5046 + point = mnt->mnt_mountpoint;
5047 + mnt = mnt->mnt_parent;
5050 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
5052 + br_read_unlock(vfsmount_lock);
5058 * Simple .show_options callback for filesystems which don't want to
5059 * implement more complex mount option showing.
5060 @@ -954,6 +989,8 @@ static int show_sb_opts(struct seq_file
5061 { MS_SYNCHRONOUS, ",sync" },
5062 { MS_DIRSYNC, ",dirsync" },
5063 { MS_MANDLOCK, ",mand" },
5064 + { MS_TAGGED, ",tag" },
5065 + { MS_NOTAGCHECK, ",notagcheck" },
5068 const struct proc_fs_info *fs_infop;
5069 @@ -1000,16 +1037,26 @@ static int show_vfsmnt(struct seq_file *
5071 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5073 - if (mnt->mnt_sb->s_op->show_devname) {
5074 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5077 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5079 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5082 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5083 + mnt == current->fs->root.mnt) {
5084 + seq_puts(m, "/dev/root / ");
5086 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5087 + if (mnt->mnt_sb->s_op->show_devname) {
5088 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5092 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
5095 + seq_path(m, &mnt_path, " \t\n\\");
5099 - seq_path(m, &mnt_path, " \t\n\\");
5101 show_type(m, mnt->mnt_sb);
5102 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
5103 err = show_sb_opts(m, mnt->mnt_sb);
5104 @@ -1039,6 +1086,11 @@ static int show_mountinfo(struct seq_fil
5105 struct path root = p->root;
5108 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5110 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5113 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
5114 MAJOR(sb->s_dev), MINOR(sb->s_dev));
5115 if (sb->s_op->show_path)
5116 @@ -1107,22 +1159,32 @@ static int show_vfsstat(struct seq_file
5117 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
5121 - if (mnt->mnt_sb->s_op->show_devname) {
5122 - seq_puts(m, "device ");
5123 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5124 + if (vx_flags(VXF_HIDE_MOUNT, 0))
5126 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
5129 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
5130 + mnt == current->fs->root.mnt) {
5131 + seq_puts(m, "device /dev/root mounted on / ");
5133 - if (mnt->mnt_devname) {
5135 + if (mnt->mnt_sb->s_op->show_devname) {
5136 seq_puts(m, "device ");
5137 - mangle(m, mnt->mnt_devname);
5139 - seq_puts(m, "no device");
5141 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5143 + if (mnt->mnt_devname) {
5144 + seq_puts(m, "device ");
5145 + mangle(m, mnt->mnt_devname);
5147 + seq_puts(m, "no device");
5151 - seq_puts(m, " mounted on ");
5152 - seq_path(m, &mnt_path, " \t\n\\");
5155 + seq_puts(m, " mounted on ");
5156 + seq_path(m, &mnt_path, " \t\n\\");
5160 /* file system type */
5161 seq_puts(m, "with fstype ");
5162 @@ -1381,7 +1443,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5166 - if (!capable(CAP_SYS_ADMIN))
5167 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5170 retval = do_umount(path.mnt, flags);
5171 @@ -1407,7 +1469,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5173 static int mount_is_safe(struct path *path)
5175 - if (capable(CAP_SYS_ADMIN))
5176 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5180 @@ -1717,7 +1779,7 @@ static int do_change_type(struct path *p
5184 - if (!capable(CAP_SYS_ADMIN))
5185 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5188 if (path->dentry != path->mnt->mnt_root)
5189 @@ -1733,6 +1795,7 @@ static int do_change_type(struct path *p
5193 + // mnt->mnt_flags = mnt_flags;
5195 br_write_lock(vfsmount_lock);
5196 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
5197 @@ -1748,12 +1811,14 @@ static int do_change_type(struct path *p
5198 * do loopback mount.
5200 static int do_loopback(struct path *path, char *old_name,
5202 + tag_t tag, unsigned long flags, int mnt_flags)
5204 LIST_HEAD(umount_list);
5205 struct path old_path;
5206 struct vfsmount *mnt = NULL;
5207 int err = mount_is_safe(path);
5208 + int recurse = flags & MS_REC;
5212 if (!old_name || !*old_name)
5213 @@ -1819,12 +1884,12 @@ static int change_mount_flags(struct vfs
5214 * on it - tough luck.
5216 static int do_remount(struct path *path, int flags, int mnt_flags,
5218 + void *data, xid_t xid)
5221 struct super_block *sb = path->mnt->mnt_sb;
5223 - if (!capable(CAP_SYS_ADMIN))
5224 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5227 if (!check_mnt(path->mnt))
5228 @@ -1872,7 +1937,7 @@ static int do_move_mount(struct path *pa
5229 struct path old_path, parent_path;
5232 - if (!capable(CAP_SYS_ADMIN))
5233 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5235 if (!old_name || !*old_name)
5237 @@ -2023,7 +2088,7 @@ static int do_new_mount(struct path *pat
5240 /* we need capabilities... */
5241 - if (!capable(CAP_SYS_ADMIN))
5242 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5245 mnt = do_kern_mount(type, flags, name, data);
5246 @@ -2292,6 +2357,7 @@ long do_mount(char *dev_name, char *dir_
5253 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5254 @@ -2319,6 +2385,12 @@ long do_mount(char *dev_name, char *dir_
5255 if (!(flags & MS_NOATIME))
5256 mnt_flags |= MNT_RELATIME;
5258 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5259 + /* FIXME: bind and re-mounts get the tag flag? */
5260 + if (flags & (MS_BIND|MS_REMOUNT))
5261 + flags |= MS_TAGID;
5264 /* Separate the per-mountpoint flags */
5265 if (flags & MS_NOSUID)
5266 mnt_flags |= MNT_NOSUID;
5267 @@ -2335,15 +2407,17 @@ long do_mount(char *dev_name, char *dir_
5268 if (flags & MS_RDONLY)
5269 mnt_flags |= MNT_READONLY;
5271 + if (!capable(CAP_SYS_ADMIN))
5272 + mnt_flags |= MNT_NODEV;
5273 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5274 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5277 if (flags & MS_REMOUNT)
5278 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5281 else if (flags & MS_BIND)
5282 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5283 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5284 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5285 retval = do_change_type(&path, flags);
5286 else if (flags & MS_MOVE)
5287 @@ -2443,6 +2517,7 @@ static struct mnt_namespace *dup_mnt_ns(
5288 q = next_mnt(q, new_ns->root);
5290 up_write(&namespace_sem);
5291 + atomic_inc(&vs_global_mnt_ns);
5295 @@ -2582,9 +2657,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5299 - if (IS_MNT_SHARED(old.mnt) ||
5300 + if ((IS_MNT_SHARED(old.mnt) ||
5301 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5302 - IS_MNT_SHARED(root.mnt->mnt_parent))
5303 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5304 + !vx_flags(VXF_STATE_SETUP, 0))
5306 if (!check_mnt(root.mnt) || !check_mnt(new.mnt))
5308 @@ -2716,6 +2792,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5309 br_write_unlock(vfsmount_lock);
5310 up_write(&namespace_sem);
5311 release_mounts(&umount_list);
5312 + atomic_dec(&vs_global_mnt_ns);
5315 EXPORT_SYMBOL(put_mnt_ns);
5316 diff -NurpP --minimal linux-3.1.1/fs/nfs/client.c linux-3.1.1-vs2.3.2/fs/nfs/client.c
5317 --- linux-3.1.1/fs/nfs/client.c 2011-10-24 18:45:27.000000000 +0200
5318 +++ linux-3.1.1-vs2.3.2/fs/nfs/client.c 2011-10-24 18:53:33.000000000 +0200
5319 @@ -778,6 +778,9 @@ static int nfs_init_server_rpcclient(str
5320 if (server->flags & NFS_MOUNT_SOFT)
5321 server->client->cl_softrtry = 1;
5323 + server->client->cl_tag = 0;
5324 + if (server->flags & NFS_MOUNT_TAGGED)
5325 + server->client->cl_tag = 1;
5329 @@ -952,6 +955,10 @@ static void nfs_server_set_fsinfo(struct
5330 server->acdirmin = server->acdirmax = 0;
5333 + /* FIXME: needs fsinfo
5334 + if (server->flags & NFS_MOUNT_TAGGED)
5335 + sb->s_flags |= MS_TAGGED; */
5337 server->maxfilesize = fsinfo->maxfilesize;
5339 server->time_delta = fsinfo->time_delta;
5340 diff -NurpP --minimal linux-3.1.1/fs/nfs/dir.c linux-3.1.1-vs2.3.2/fs/nfs/dir.c
5341 --- linux-3.1.1/fs/nfs/dir.c 2011-10-24 18:45:27.000000000 +0200
5342 +++ linux-3.1.1-vs2.3.2/fs/nfs/dir.c 2011-10-24 18:53:33.000000000 +0200
5344 #include <linux/sched.h>
5345 #include <linux/kmemleak.h>
5346 #include <linux/xattr.h>
5347 +#include <linux/vs_tag.h>
5349 #include "delegation.h"
5351 @@ -1311,6 +1312,7 @@ static struct dentry *nfs_lookup(struct
5353 goto out_unblock_sillyrename;
5355 + dx_propagate_tag(nd, inode);
5357 res = d_materialise_unique(dentry, inode);
5359 diff -NurpP --minimal linux-3.1.1/fs/nfs/inode.c linux-3.1.1-vs2.3.2/fs/nfs/inode.c
5360 --- linux-3.1.1/fs/nfs/inode.c 2011-10-24 18:45:27.000000000 +0200
5361 +++ linux-3.1.1-vs2.3.2/fs/nfs/inode.c 2011-10-24 18:53:33.000000000 +0200
5363 #include <linux/nfs_xdr.h>
5364 #include <linux/slab.h>
5365 #include <linux/compat.h>
5366 +#include <linux/vs_tag.h>
5368 #include <asm/system.h>
5369 #include <asm/uaccess.h>
5370 @@ -273,6 +274,8 @@ nfs_fhget(struct super_block *sb, struct
5371 if (inode->i_state & I_NEW) {
5372 struct nfs_inode *nfsi = NFS_I(inode);
5373 unsigned long now = jiffies;
5377 /* We set i_ino for the few things that still rely on it,
5378 * such as stat(2) */
5379 @@ -321,8 +324,8 @@ nfs_fhget(struct super_block *sb, struct
5380 nfsi->change_attr = 0;
5383 - inode->i_uid = -2;
5384 - inode->i_gid = -2;
5387 inode->i_blocks = 0;
5388 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5390 @@ -359,13 +362,13 @@ nfs_fhget(struct super_block *sb, struct
5391 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5392 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5393 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5394 - inode->i_uid = fattr->uid;
5396 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5397 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5398 | NFS_INO_INVALID_ACCESS
5399 | NFS_INO_INVALID_ACL;
5400 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5401 - inode->i_gid = fattr->gid;
5403 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5404 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5405 | NFS_INO_INVALID_ACCESS
5406 @@ -378,6 +381,11 @@ nfs_fhget(struct super_block *sb, struct
5408 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5410 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5411 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5412 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5413 + /* maybe fattr->xid someday */
5415 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5416 nfsi->attrtimeo_timestamp = now;
5417 nfsi->access_cache = RB_ROOT;
5418 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
5419 inode->i_uid = attr->ia_uid;
5420 if ((attr->ia_valid & ATTR_GID) != 0)
5421 inode->i_gid = attr->ia_gid;
5422 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5423 + inode->i_tag = attr->ia_tag;
5424 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5425 spin_unlock(&inode->i_lock);
5427 @@ -943,6 +953,9 @@ static int nfs_check_inode_attributes(st
5428 struct nfs_inode *nfsi = NFS_I(inode);
5429 loff_t cur_size, new_isize;
5430 unsigned long invalid = 0;
5436 /* Has the inode gone and changed behind our back? */
5437 @@ -966,13 +979,18 @@ static int nfs_check_inode_attributes(st
5438 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5441 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5442 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5443 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5445 /* Have any file permissions changed? */
5446 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5447 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5448 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5449 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5450 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5451 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5452 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5453 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5454 + /* maybe check for tag too? */
5456 /* Has the link count changed? */
5457 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5458 @@ -1207,6 +1225,9 @@ static int nfs_update_inode(struct inode
5459 unsigned long invalid = 0;
5460 unsigned long now = jiffies;
5461 unsigned long save_cache_validity;
5466 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5467 __func__, inode->i_sb->s_id, inode->i_ino,
5468 @@ -1314,6 +1335,9 @@ static int nfs_update_inode(struct inode
5469 | NFS_INO_REVAL_PAGECACHE
5470 | NFS_INO_REVAL_FORCED);
5472 + uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5473 + gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5474 + tag = inode->i_tag;
5476 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5477 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5478 @@ -1335,9 +1359,9 @@ static int nfs_update_inode(struct inode
5479 | NFS_INO_REVAL_FORCED);
5481 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5482 - if (inode->i_uid != fattr->uid) {
5483 + if (uid != fattr->uid) {
5484 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5485 - inode->i_uid = fattr->uid;
5488 } else if (server->caps & NFS_CAP_OWNER)
5489 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5490 @@ -1346,9 +1370,9 @@ static int nfs_update_inode(struct inode
5491 | NFS_INO_REVAL_FORCED);
5493 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5494 - if (inode->i_gid != fattr->gid) {
5495 + if (gid != fattr->gid) {
5496 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5497 - inode->i_gid = fattr->gid;
5500 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5501 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5502 @@ -1356,6 +1380,10 @@ static int nfs_update_inode(struct inode
5503 | NFS_INO_INVALID_ACL
5504 | NFS_INO_REVAL_FORCED);
5506 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5507 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5508 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
5510 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5511 if (inode->i_nlink != fattr->nlink) {
5512 invalid |= NFS_INO_INVALID_ATTR;
5513 diff -NurpP --minimal linux-3.1.1/fs/nfs/nfs3xdr.c linux-3.1.1-vs2.3.2/fs/nfs/nfs3xdr.c
5514 --- linux-3.1.1/fs/nfs/nfs3xdr.c 2011-03-15 18:07:32.000000000 +0100
5515 +++ linux-3.1.1-vs2.3.2/fs/nfs/nfs3xdr.c 2011-10-24 18:53:33.000000000 +0200
5517 #include <linux/nfs3.h>
5518 #include <linux/nfs_fs.h>
5519 #include <linux/nfsacl.h>
5520 +#include <linux/vs_tag.h>
5521 #include "internal.h"
5523 #define NFSDBG_FACILITY NFSDBG_XDR
5524 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5528 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5529 +static void encode_sattr3(struct xdr_stream *xdr,
5530 + const struct iattr *attr, int tag)
5534 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
5538 - if (attr->ia_valid & ATTR_UID) {
5539 + if (attr->ia_valid & ATTR_UID ||
5540 + (tag && (attr->ia_valid & ATTR_TAG))) {
5542 - *p++ = cpu_to_be32(attr->ia_uid);
5543 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5544 + attr->ia_uid, attr->ia_tag));
5548 - if (attr->ia_valid & ATTR_GID) {
5549 + if (attr->ia_valid & ATTR_GID ||
5550 + (tag && (attr->ia_valid & ATTR_TAG))) {
5552 - *p++ = cpu_to_be32(attr->ia_gid);
5553 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5554 + attr->ia_gid, attr->ia_tag));
5558 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
5559 const struct nfs3_sattrargs *args)
5561 encode_nfs_fh3(xdr, args->fh);
5562 - encode_sattr3(xdr, args->sattr);
5563 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5564 encode_sattrguard3(xdr, args);
5567 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
5570 static void encode_createhow3(struct xdr_stream *xdr,
5571 - const struct nfs3_createargs *args)
5572 + const struct nfs3_createargs *args, int tag)
5574 encode_uint32(xdr, args->createmode);
5575 switch (args->createmode) {
5576 case NFS3_CREATE_UNCHECKED:
5577 case NFS3_CREATE_GUARDED:
5578 - encode_sattr3(xdr, args->sattr);
5579 + encode_sattr3(xdr, args->sattr, tag);
5581 case NFS3_CREATE_EXCLUSIVE:
5582 encode_createverf3(xdr, args->verifier);
5583 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
5584 const struct nfs3_createargs *args)
5586 encode_diropargs3(xdr, args->fh, args->name, args->len);
5587 - encode_createhow3(xdr, args);
5588 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5592 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5593 const struct nfs3_mkdirargs *args)
5595 encode_diropargs3(xdr, args->fh, args->name, args->len);
5596 - encode_sattr3(xdr, args->sattr);
5597 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5601 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5604 static void encode_symlinkdata3(struct xdr_stream *xdr,
5605 - const struct nfs3_symlinkargs *args)
5606 + const struct nfs3_symlinkargs *args, int tag)
5608 - encode_sattr3(xdr, args->sattr);
5609 + encode_sattr3(xdr, args->sattr, tag);
5610 encode_nfspath3(xdr, args->pages, args->pathlen);
5613 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
5614 const struct nfs3_symlinkargs *args)
5616 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5617 - encode_symlinkdata3(xdr, args);
5618 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5622 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
5625 static void encode_devicedata3(struct xdr_stream *xdr,
5626 - const struct nfs3_mknodargs *args)
5627 + const struct nfs3_mknodargs *args, int tag)
5629 - encode_sattr3(xdr, args->sattr);
5630 + encode_sattr3(xdr, args->sattr, tag);
5631 encode_specdata3(xdr, args->rdev);
5634 static void encode_mknoddata3(struct xdr_stream *xdr,
5635 - const struct nfs3_mknodargs *args)
5636 + const struct nfs3_mknodargs *args, int tag)
5638 encode_ftype3(xdr, args->type);
5639 switch (args->type) {
5642 - encode_devicedata3(xdr, args);
5643 + encode_devicedata3(xdr, args, tag);
5647 - encode_sattr3(xdr, args->sattr);
5648 + encode_sattr3(xdr, args->sattr, tag);
5652 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5653 const struct nfs3_mknodargs *args)
5655 encode_diropargs3(xdr, args->fh, args->name, args->len);
5656 - encode_mknoddata3(xdr, args);
5657 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5661 diff -NurpP --minimal linux-3.1.1/fs/nfs/super.c linux-3.1.1-vs2.3.2/fs/nfs/super.c
5662 --- linux-3.1.1/fs/nfs/super.c 2011-10-24 18:45:27.000000000 +0200
5663 +++ linux-3.1.1-vs2.3.2/fs/nfs/super.c 2011-10-24 18:53:33.000000000 +0200
5665 #include <linux/nfs_xdr.h>
5666 #include <linux/magic.h>
5667 #include <linux/parser.h>
5668 +#include <linux/vs_tag.h>
5670 #include <asm/system.h>
5671 #include <asm/uaccess.h>
5672 @@ -87,6 +88,7 @@ enum {
5673 Opt_sharecache, Opt_nosharecache,
5674 Opt_resvport, Opt_noresvport,
5675 Opt_fscache, Opt_nofscache,
5676 + Opt_tag, Opt_notag,
5678 /* Mount options that take integer arguments */
5680 @@ -100,6 +102,7 @@ enum {
5686 /* Mount options that take string arguments */
5687 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
5688 @@ -180,6 +183,10 @@ static const match_table_t nfs_mount_opt
5689 { Opt_fscache_uniq, "fsc=%s" },
5690 { Opt_local_lock, "local_lock=%s" },
5692 + { Opt_tag, "tag" },
5693 + { Opt_notag, "notag" },
5694 + { Opt_tagid, "tagid=%u" },
5699 @@ -650,6 +657,7 @@ static void nfs_show_mount_options(struc
5700 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5701 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5702 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5703 + { NFS_MOUNT_TAGGED, ",tag", "" },
5706 const struct proc_nfs_info *nfs_infop;
5707 @@ -1198,6 +1206,14 @@ static int nfs_parse_mount_options(char
5708 kfree(mnt->fscache_uniq);
5709 mnt->fscache_uniq = NULL;
5711 +#ifndef CONFIG_TAGGING_NONE
5713 + mnt->flags |= NFS_MOUNT_TAGGED;
5716 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5721 * options that take numeric values
5722 @@ -1304,6 +1320,12 @@ static int nfs_parse_mount_options(char
5723 goto out_invalid_value;
5724 mnt->minorversion = option;
5726 +#ifdef CONFIG_PROPAGATE
5729 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5734 * options that take text values
5735 diff -NurpP --minimal linux-3.1.1/fs/nfsd/auth.c linux-3.1.1-vs2.3.2/fs/nfsd/auth.c
5736 --- linux-3.1.1/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
5737 +++ linux-3.1.1-vs2.3.2/fs/nfsd/auth.c 2011-10-24 18:53:33.000000000 +0200
5739 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
5741 #include <linux/sched.h>
5742 +#include <linux/vs_tag.h>
5746 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5748 new->fsuid = rqstp->rq_cred.cr_uid;
5749 new->fsgid = rqstp->rq_cred.cr_gid;
5750 + /* FIXME: this desperately needs a tag :)
5751 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5754 rqgi = rqstp->rq_cred.cr_group_info;
5756 diff -NurpP --minimal linux-3.1.1/fs/nfsd/nfs3xdr.c linux-3.1.1-vs2.3.2/fs/nfsd/nfs3xdr.c
5757 --- linux-3.1.1/fs/nfsd/nfs3xdr.c 2011-07-22 11:18:05.000000000 +0200
5758 +++ linux-3.1.1-vs2.3.2/fs/nfsd/nfs3xdr.c 2011-10-24 18:53:33.000000000 +0200
5762 #include <linux/namei.h>
5763 +#include <linux/vs_tag.h>
5767 @@ -95,6 +96,8 @@ static __be32 *
5768 decode_sattr3(__be32 *p, struct iattr *iap)
5776 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
5779 iap->ia_valid |= ATTR_UID;
5780 - iap->ia_uid = ntohl(*p++);
5781 + uid = ntohl(*p++);
5784 iap->ia_valid |= ATTR_GID;
5785 - iap->ia_gid = ntohl(*p++);
5786 + gid = ntohl(*p++);
5788 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5789 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5790 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5794 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5795 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5796 *p++ = htonl((u32) stat->mode);
5797 *p++ = htonl((u32) stat->nlink);
5798 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5799 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5800 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5801 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5802 + stat->uid, stat->tag)));
5803 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5804 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5805 + stat->gid, stat->tag)));
5806 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5807 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5809 diff -NurpP --minimal linux-3.1.1/fs/nfsd/nfs4xdr.c linux-3.1.1-vs2.3.2/fs/nfsd/nfs4xdr.c
5810 --- linux-3.1.1/fs/nfsd/nfs4xdr.c 2011-11-15 16:44:52.000000000 +0100
5811 +++ linux-3.1.1-vs2.3.2/fs/nfsd/nfs4xdr.c 2011-11-15 17:08:44.000000000 +0100
5813 #include <linux/utsname.h>
5814 #include <linux/pagemap.h>
5815 #include <linux/sunrpc/svcauth_gss.h>
5816 +#include <linux/vs_tag.h>
5820 @@ -2177,14 +2178,18 @@ out_acl:
5821 WRITE32(stat.nlink);
5823 if (bmval1 & FATTR4_WORD1_OWNER) {
5824 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5825 + status = nfsd4_encode_user(rqstp,
5826 + TAGINO_UID(DX_TAG(dentry->d_inode),
5827 + stat.uid, stat.tag), &p, &buflen);
5828 if (status == nfserr_resource)
5833 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5834 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5835 + status = nfsd4_encode_group(rqstp,
5836 + TAGINO_GID(DX_TAG(dentry->d_inode),
5837 + stat.gid, stat.tag), &p, &buflen);
5838 if (status == nfserr_resource)
5841 diff -NurpP --minimal linux-3.1.1/fs/nfsd/nfsxdr.c linux-3.1.1-vs2.3.2/fs/nfsd/nfsxdr.c
5842 --- linux-3.1.1/fs/nfsd/nfsxdr.c 2011-05-22 16:17:53.000000000 +0200
5843 +++ linux-3.1.1-vs2.3.2/fs/nfsd/nfsxdr.c 2011-10-24 18:53:33.000000000 +0200
5848 +#include <linux/vs_tag.h>
5850 #define NFSDDBG_FACILITY NFSDDBG_XDR
5852 @@ -88,6 +89,8 @@ static __be32 *
5853 decode_sattr(__be32 *p, struct iattr *iap)
5861 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
5863 if ((tmp = ntohl(*p++)) != (u32)-1) {
5864 iap->ia_valid |= ATTR_UID;
5865 - iap->ia_uid = tmp;
5868 if ((tmp = ntohl(*p++)) != (u32)-1) {
5869 iap->ia_valid |= ATTR_GID;
5870 - iap->ia_gid = tmp;
5873 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5874 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5875 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5876 if ((tmp = ntohl(*p++)) != (u32)-1) {
5877 iap->ia_valid |= ATTR_SIZE;
5879 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5880 *p++ = htonl(nfs_ftypes[type >> 12]);
5881 *p++ = htonl((u32) stat->mode);
5882 *p++ = htonl((u32) stat->nlink);
5883 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5884 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5885 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5886 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5887 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5888 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5890 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5891 *p++ = htonl(NFS_MAXPATHLEN);
5892 diff -NurpP --minimal linux-3.1.1/fs/ocfs2/dlmglue.c linux-3.1.1-vs2.3.2/fs/ocfs2/dlmglue.c
5893 --- linux-3.1.1/fs/ocfs2/dlmglue.c 2011-05-22 16:17:53.000000000 +0200
5894 +++ linux-3.1.1-vs2.3.2/fs/ocfs2/dlmglue.c 2011-10-24 18:53:33.000000000 +0200
5895 @@ -2041,6 +2041,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5896 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5897 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
5898 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
5899 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
5900 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5901 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5902 lvb->lvb_iatime_packed =
5903 @@ -2091,6 +2092,7 @@ static void ocfs2_refresh_inode_from_lvb
5905 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
5906 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
5907 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
5908 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5909 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
5910 ocfs2_unpack_timespec(&inode->i_atime,
5911 diff -NurpP --minimal linux-3.1.1/fs/ocfs2/dlmglue.h linux-3.1.1-vs2.3.2/fs/ocfs2/dlmglue.h
5912 --- linux-3.1.1/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
5913 +++ linux-3.1.1-vs2.3.2/fs/ocfs2/dlmglue.h 2011-10-24 18:53:33.000000000 +0200
5914 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5917 __be32 lvb_igeneration;
5918 - __be32 lvb_reserved2;
5920 + __be16 lvb_reserved2;
5923 #define OCFS2_QINFO_LVB_VERSION 1
5924 diff -NurpP --minimal linux-3.1.1/fs/ocfs2/file.c linux-3.1.1-vs2.3.2/fs/ocfs2/file.c
5925 --- linux-3.1.1/fs/ocfs2/file.c 2011-10-24 18:45:27.000000000 +0200
5926 +++ linux-3.1.1-vs2.3.2/fs/ocfs2/file.c 2011-10-24 18:53:33.000000000 +0200
5927 @@ -1123,7 +1123,7 @@ int ocfs2_setattr(struct dentry *dentry,
5928 attr->ia_valid &= ~ATTR_SIZE;
5930 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5931 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5932 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5933 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5936 diff -NurpP --minimal linux-3.1.1/fs/ocfs2/inode.c linux-3.1.1-vs2.3.2/fs/ocfs2/inode.c
5937 --- linux-3.1.1/fs/ocfs2/inode.c 2011-05-22 16:17:53.000000000 +0200
5938 +++ linux-3.1.1-vs2.3.2/fs/ocfs2/inode.c 2011-10-24 18:53:33.000000000 +0200
5940 #include <linux/highmem.h>
5941 #include <linux/pagemap.h>
5942 #include <linux/quotaops.h>
5943 +#include <linux/vs_tag.h>
5945 #include <asm/byteorder.h>
5947 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5949 unsigned int flags = OCFS2_I(inode)->ip_attr;
5951 - inode->i_flags &= ~(S_IMMUTABLE |
5952 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5953 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5955 if (flags & OCFS2_IMMUTABLE_FL)
5956 inode->i_flags |= S_IMMUTABLE;
5957 + if (flags & OCFS2_IXUNLINK_FL)
5958 + inode->i_flags |= S_IXUNLINK;
5960 if (flags & OCFS2_SYNC_FL)
5961 inode->i_flags |= S_SYNC;
5962 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5963 inode->i_flags |= S_NOATIME;
5964 if (flags & OCFS2_DIRSYNC_FL)
5965 inode->i_flags |= S_DIRSYNC;
5967 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5969 + if (flags & OCFS2_BARRIER_FL)
5970 + inode->i_vflags |= V_BARRIER;
5971 + if (flags & OCFS2_COW_FL)
5972 + inode->i_vflags |= V_COW;
5975 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5976 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5978 unsigned int flags = oi->vfs_inode.i_flags;
5979 + unsigned int vflags = oi->vfs_inode.i_vflags;
5981 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5982 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5983 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5984 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5986 + if (flags & S_IMMUTABLE)
5987 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5988 + if (flags & S_IXUNLINK)
5989 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5991 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5992 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5994 oi->ip_attr |= OCFS2_SYNC_FL;
5995 if (flags & S_APPEND)
5996 oi->ip_attr |= OCFS2_APPEND_FL;
5997 - if (flags & S_IMMUTABLE)
5998 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5999 if (flags & S_NOATIME)
6000 oi->ip_attr |= OCFS2_NOATIME_FL;
6001 if (flags & S_DIRSYNC)
6002 oi->ip_attr |= OCFS2_DIRSYNC_FL;
6004 + if (vflags & V_BARRIER)
6005 + oi->ip_attr |= OCFS2_BARRIER_FL;
6006 + if (vflags & V_COW)
6007 + oi->ip_attr |= OCFS2_COW_FL;
6010 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
6011 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
6012 struct super_block *sb;
6013 struct ocfs2_super *osb;
6020 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
6021 inode->i_generation = le32_to_cpu(fe->i_generation);
6022 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
6023 inode->i_mode = le16_to_cpu(fe->i_mode);
6024 - inode->i_uid = le32_to_cpu(fe->i_uid);
6025 - inode->i_gid = le32_to_cpu(fe->i_gid);
6026 + uid = le32_to_cpu(fe->i_uid);
6027 + gid = le32_to_cpu(fe->i_gid);
6028 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6029 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6030 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
6031 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
6033 /* Fast symlinks will have i_size but no allocated clusters. */
6034 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
6035 diff -NurpP --minimal linux-3.1.1/fs/ocfs2/inode.h linux-3.1.1-vs2.3.2/fs/ocfs2/inode.h
6036 --- linux-3.1.1/fs/ocfs2/inode.h 2011-01-05 21:50:26.000000000 +0100
6037 +++ linux-3.1.1-vs2.3.2/fs/ocfs2/inode.h 2011-10-24 18:53:33.000000000 +0200
6038 @@ -151,6 +151,7 @@ struct buffer_head *ocfs2_bread(struct i
6040 void ocfs2_set_inode_flags(struct inode *inode);
6041 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
6042 +int ocfs2_sync_flags(struct inode *inode, int, int);
6044 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
6046 diff -NurpP --minimal linux-3.1.1/fs/ocfs2/ioctl.c linux-3.1.1-vs2.3.2/fs/ocfs2/ioctl.c
6047 --- linux-3.1.1/fs/ocfs2/ioctl.c 2011-07-22 11:18:06.000000000 +0200
6048 +++ linux-3.1.1-vs2.3.2/fs/ocfs2/ioctl.c 2011-10-24 18:53:33.000000000 +0200
6049 @@ -78,7 +78,41 @@ static int ocfs2_get_inode_attr(struct i
6053 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6054 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
6056 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6057 + struct buffer_head *bh = NULL;
6058 + handle_t *handle = NULL;
6061 + status = ocfs2_inode_lock(inode, &bh, 1);
6063 + mlog_errno(status);
6066 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6067 + if (IS_ERR(handle)) {
6068 + status = PTR_ERR(handle);
6069 + mlog_errno(status);
6073 + inode->i_flags = flags;
6074 + inode->i_vflags = vflags;
6075 + ocfs2_get_inode_flags(OCFS2_I(inode));
6077 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
6079 + mlog_errno(status);
6081 + ocfs2_commit_trans(osb, handle);
6083 + ocfs2_inode_unlock(inode, 1);
6088 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
6091 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
6092 @@ -103,6 +137,11 @@ static int ocfs2_set_inode_attr(struct i
6093 if (!S_ISDIR(inode->i_mode))
6094 flags &= ~OCFS2_DIRSYNC_FL;
6096 + if (IS_BARRIER(inode)) {
6097 + vxwprintk_task(1, "messing with the barrier.");
6101 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
6102 if (IS_ERR(handle)) {
6103 status = PTR_ERR(handle);
6104 @@ -880,6 +919,7 @@ bail:
6109 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
6111 struct inode *inode = filp->f_path.dentry->d_inode;
6112 diff -NurpP --minimal linux-3.1.1/fs/ocfs2/namei.c linux-3.1.1-vs2.3.2/fs/ocfs2/namei.c
6113 --- linux-3.1.1/fs/ocfs2/namei.c 2011-10-24 18:45:27.000000000 +0200
6114 +++ linux-3.1.1-vs2.3.2/fs/ocfs2/namei.c 2011-10-24 18:53:33.000000000 +0200
6116 #include <linux/slab.h>
6117 #include <linux/highmem.h>
6118 #include <linux/quotaops.h>
6119 +#include <linux/vs_tag.h>
6121 #include <cluster/masklog.h>
6123 @@ -477,6 +478,7 @@ static int __ocfs2_mknod_locked(struct i
6124 struct ocfs2_dinode *fe = NULL;
6125 struct ocfs2_extent_list *fel;
6131 @@ -514,8 +516,11 @@ static int __ocfs2_mknod_locked(struct i
6132 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
6133 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6134 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6135 - fe->i_uid = cpu_to_le32(inode->i_uid);
6136 - fe->i_gid = cpu_to_le32(inode->i_gid);
6138 + tag = dx_current_fstag(osb->sb);
6139 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6140 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6141 + inode->i_tag = tag;
6142 fe->i_mode = cpu_to_le16(inode->i_mode);
6143 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6144 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6145 diff -NurpP --minimal linux-3.1.1/fs/ocfs2/ocfs2.h linux-3.1.1-vs2.3.2/fs/ocfs2/ocfs2.h
6146 --- linux-3.1.1/fs/ocfs2/ocfs2.h 2011-05-22 16:17:53.000000000 +0200
6147 +++ linux-3.1.1-vs2.3.2/fs/ocfs2/ocfs2.h 2011-10-24 18:53:33.000000000 +0200
6148 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
6150 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
6151 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
6152 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
6155 #define OCFS2_OSB_SOFT_RO 0x0001
6156 diff -NurpP --minimal linux-3.1.1/fs/ocfs2/ocfs2_fs.h linux-3.1.1-vs2.3.2/fs/ocfs2/ocfs2_fs.h
6157 --- linux-3.1.1/fs/ocfs2/ocfs2_fs.h 2011-05-22 16:17:53.000000000 +0200
6158 +++ linux-3.1.1-vs2.3.2/fs/ocfs2/ocfs2_fs.h 2011-10-24 18:53:33.000000000 +0200
6159 @@ -266,6 +266,11 @@
6160 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
6161 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
6163 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6165 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6166 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6168 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
6169 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
6171 diff -NurpP --minimal linux-3.1.1/fs/ocfs2/super.c linux-3.1.1-vs2.3.2/fs/ocfs2/super.c
6172 --- linux-3.1.1/fs/ocfs2/super.c 2011-07-22 11:18:06.000000000 +0200
6173 +++ linux-3.1.1-vs2.3.2/fs/ocfs2/super.c 2011-10-24 18:53:33.000000000 +0200
6174 @@ -184,6 +184,7 @@ enum {
6178 + Opt_tag, Opt_notag, Opt_tagid,
6182 @@ -215,6 +216,9 @@ static const match_table_t tokens = {
6183 {Opt_coherency_full, "coherency=full"},
6184 {Opt_resv_level, "resv_level=%u"},
6185 {Opt_dir_resv_level, "dir_resv_level=%u"},
6187 + {Opt_notag, "notag"},
6188 + {Opt_tagid, "tagid=%u"},
6192 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
6196 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6197 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6199 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6203 /* We're going to/from readonly mode. */
6204 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
6205 /* Disable quota accounting before remounting RO */
6206 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
6208 ocfs2_complete_mount_recovery(osb);
6210 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6211 + sb->s_flags |= MS_TAGGED;
6213 if (ocfs2_mount_local(osb))
6214 snprintf(nodestr, sizeof(nodestr), "local");
6216 @@ -1506,6 +1520,20 @@ static int ocfs2_parse_options(struct su
6217 option < OCFS2_MAX_RESV_LEVEL)
6218 mopt->dir_resv_level = option;
6220 +#ifndef CONFIG_TAGGING_NONE
6222 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6225 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6228 +#ifdef CONFIG_PROPAGATE
6231 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6236 "Unrecognized mount option \"%s\" "
6237 diff -NurpP --minimal linux-3.1.1/fs/open.c linux-3.1.1-vs2.3.2/fs/open.c
6238 --- linux-3.1.1/fs/open.c 2011-10-24 18:45:27.000000000 +0200
6239 +++ linux-3.1.1-vs2.3.2/fs/open.c 2011-10-30 02:06:37.000000000 +0100
6241 #include <linux/fs_struct.h>
6242 #include <linux/ima.h>
6243 #include <linux/dnotify.h>
6244 +#include <linux/vs_base.h>
6245 +#include <linux/vs_limit.h>
6246 +#include <linux/vs_tag.h>
6247 +#include <linux/vs_cowbl.h>
6248 +#include <linux/vserver/dlimit.h>
6250 #include "internal.h"
6252 @@ -74,6 +79,12 @@ static long do_sys_truncate(const char _
6253 error = user_path(pathname, &path);
6257 +#ifdef CONFIG_VSERVER_COWBL
6258 + error = cow_check_and_break(&path);
6260 + goto dput_and_out;
6262 inode = path.dentry->d_inode;
6264 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
6265 @@ -489,6 +500,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6267 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6269 +#ifdef CONFIG_VSERVER_COWBL
6270 + error = cow_check_and_break(&path);
6273 error = chmod_common(&path, mode);
6276 @@ -509,11 +524,11 @@ static int chown_common(struct path *pat
6277 newattrs.ia_valid = ATTR_CTIME;
6278 if (user != (uid_t) -1) {
6279 newattrs.ia_valid |= ATTR_UID;
6280 - newattrs.ia_uid = user;
6281 + newattrs.ia_uid = dx_map_uid(user);
6283 if (group != (gid_t) -1) {
6284 newattrs.ia_valid |= ATTR_GID;
6285 - newattrs.ia_gid = group;
6286 + newattrs.ia_gid = dx_map_gid(group);
6288 if (!S_ISDIR(inode->i_mode))
6289 newattrs.ia_valid |=
6290 @@ -538,6 +553,10 @@ SYSCALL_DEFINE3(chown, const char __user
6291 error = mnt_want_write(path.mnt);
6294 +#ifdef CONFIG_VSERVER_COWBL
6295 + error = cow_check_and_break(&path);
6298 error = chown_common(&path, user, group);
6299 mnt_drop_write(path.mnt);
6301 @@ -565,6 +584,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6302 error = mnt_want_write(path.mnt);
6305 +#ifdef CONFIG_VSERVER_COWBL
6306 + error = cow_check_and_break(&path);
6309 error = chown_common(&path, user, group);
6310 mnt_drop_write(path.mnt);
6312 @@ -584,6 +607,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6313 error = mnt_want_write(path.mnt);
6316 +#ifdef CONFIG_VSERVER_COWBL
6317 + error = cow_check_and_break(&path);
6320 error = chown_common(&path, user, group);
6321 mnt_drop_write(path.mnt);
6323 @@ -835,6 +862,7 @@ static void __put_unused_fd(struct files
6324 __FD_CLR(fd, fdt->open_fds);
6325 if (fd < files->next_fd)
6326 files->next_fd = fd;
6327 + vx_openfd_dec(fd);
6330 void put_unused_fd(unsigned int fd)
6331 diff -NurpP --minimal linux-3.1.1/fs/proc/array.c linux-3.1.1-vs2.3.2/fs/proc/array.c
6332 --- linux-3.1.1/fs/proc/array.c 2011-10-24 18:45:27.000000000 +0200
6333 +++ linux-3.1.1-vs2.3.2/fs/proc/array.c 2011-10-24 18:53:33.000000000 +0200
6335 #include <linux/pid_namespace.h>
6336 #include <linux/ptrace.h>
6337 #include <linux/tracehook.h>
6338 +#include <linux/vs_context.h>
6339 +#include <linux/vs_network.h>
6341 #include <asm/pgtable.h>
6342 #include <asm/processor.h>
6343 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6345 ppid = pid_alive(p) ?
6346 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6347 + if (unlikely(vx_current_initpid(p->pid)))
6352 struct task_struct *tracer = ptrace_parent(p);
6353 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6356 static void render_cap_t(struct seq_file *m, const char *header,
6358 + struct vx_info *vxi, kernel_cap_t *a)
6362 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6363 cap_bset = cred->cap_bset;
6366 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6367 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6368 - render_cap_t(m, "CapEff:\t", &cap_effective);
6369 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6370 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6371 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6372 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6373 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6374 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6377 static inline void task_context_switch_counts(struct seq_file *m,
6378 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6382 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6383 + struct pid *pid, struct task_struct *task)
6385 + seq_printf(m, "Proxy:\t%p(%c)\n"
6393 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6394 + atomic_read(&task->nsproxy->count),
6395 + task->nsproxy->uts_ns,
6396 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6397 + task->nsproxy->ipc_ns,
6398 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6399 + task->nsproxy->mnt_ns,
6400 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6401 + task->nsproxy->pid_ns,
6402 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6403 + task->nsproxy->net_ns,
6404 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6408 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6410 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6413 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6414 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6418 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6419 struct pid *pid, struct task_struct *task)
6421 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6423 task_cpus_allowed(m, task);
6424 cpuset_task_status_allowed(m, task);
6425 + task_vs_id(m, task);
6426 task_context_switch_counts(m, task);
6429 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file
6430 /* convert nsec -> ticks */
6431 start_time = nsec_to_clock_t(start_time);
6433 + /* fixup start time for virt uptime */
6434 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6435 + unsigned long long bias =
6436 + current->vx_info->cvirt.bias_clock;
6438 + if (start_time > bias)
6439 + start_time -= bias;
6444 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6445 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6446 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6447 diff -NurpP --minimal linux-3.1.1/fs/proc/base.c linux-3.1.1-vs2.3.2/fs/proc/base.c
6448 --- linux-3.1.1/fs/proc/base.c 2011-10-24 18:45:27.000000000 +0200
6449 +++ linux-3.1.1-vs2.3.2/fs/proc/base.c 2011-10-24 18:53:33.000000000 +0200
6451 #include <linux/pid_namespace.h>
6452 #include <linux/fs_struct.h>
6453 #include <linux/slab.h>
6454 +#include <linux/vs_context.h>
6455 +#include <linux/vs_network.h>
6456 #ifdef CONFIG_HARDWALL
6457 #include <asm/hardwall.h>
6459 @@ -1102,11 +1104,16 @@ static ssize_t oom_adjust_write(struct f
6463 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6464 + if (oom_adjust < task->signal->oom_adj &&
6465 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6470 + /* prevent guest processes from circumventing the oom killer */
6471 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6472 + oom_adjust = OOM_ADJUST_MIN;
6474 if (oom_adjust != task->signal->oom_adj) {
6475 if (oom_adjust == OOM_DISABLE)
6476 atomic_inc(&task->mm->oom_disable_count);
6477 @@ -1274,7 +1281,7 @@ static ssize_t proc_loginuid_write(struc
6481 - if (!capable(CAP_AUDIT_CONTROL))
6482 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6486 @@ -1721,6 +1728,8 @@ struct inode *proc_pid_make_inode(struct
6487 inode->i_gid = cred->egid;
6490 + /* procfs is xid tagged */
6491 + inode->i_tag = (tag_t)vx_task_xid(task);
6492 security_task_to_inode(task, inode);
6495 @@ -1757,6 +1766,8 @@ int pid_getattr(struct vfsmount *mnt, st
6499 +static unsigned name_to_int(struct dentry *dentry);
6502 * Exceptional case: normally we are not allowed to unhash a busy
6503 * directory. In this case, however, we can do it - no aliasing problems
6504 @@ -1785,6 +1796,12 @@ int pid_revalidate(struct dentry *dentry
6505 task = get_proc_task(inode);
6508 + unsigned pid = name_to_int(dentry);
6510 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6511 + put_task_struct(task);
6514 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6515 task_dumpable(task)) {
6517 @@ -1801,6 +1818,7 @@ int pid_revalidate(struct dentry *dentry
6518 put_task_struct(task);
6525 @@ -2290,6 +2308,13 @@ static struct dentry *proc_pident_lookup
6529 + /* TODO: maybe we can come up with a generic approach? */
6530 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6531 + (dentry->d_name.len == 5) &&
6532 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6533 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6537 * Yes, it does not scale. And it should not. Don't add
6538 * new entries into /proc/<tgid>/ without very good reasons.
6539 @@ -2675,7 +2700,7 @@ out_iput:
6540 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6542 struct dentry *error;
6543 - struct task_struct *task = get_proc_task(dir);
6544 + struct task_struct *task = get_proc_task_real(dir);
6545 const struct pid_entry *p, *last;
6547 error = ERR_PTR(-ENOENT);
6548 @@ -2782,6 +2807,9 @@ static int proc_pid_personality(struct s
6549 static const struct file_operations proc_task_operations;
6550 static const struct inode_operations proc_task_inode_operations;
6552 +extern int proc_pid_vx_info(struct task_struct *, char *);
6553 +extern int proc_pid_nx_info(struct task_struct *, char *);
6555 static const struct pid_entry tgid_base_stuff[] = {
6556 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6557 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6558 @@ -2845,6 +2873,8 @@ static const struct pid_entry tgid_base_
6559 #ifdef CONFIG_CGROUPS
6560 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6562 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6563 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6564 INF("oom_score", S_IRUGO, proc_oom_score),
6565 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6566 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6567 @@ -2864,6 +2894,7 @@ static const struct pid_entry tgid_base_
6568 #ifdef CONFIG_HARDWALL
6569 INF("hardwall", S_IRUGO, proc_pid_hardwall),
6571 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6574 static int proc_tgid_base_readdir(struct file * filp,
6575 @@ -3056,7 +3087,7 @@ retry:
6577 pid = find_ge_pid(iter.tgid, ns);
6579 - iter.tgid = pid_nr_ns(pid, ns);
6580 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6581 iter.task = pid_task(pid, PIDTYPE_PID);
6582 /* What we to know is if the pid we have find is the
6583 * pid of a thread_group_leader. Testing for task
6584 @@ -3086,7 +3117,7 @@ static int proc_pid_fill_cache(struct fi
6585 struct tgid_iter iter)
6587 char name[PROC_NUMBUF];
6588 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6589 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6590 return proc_fill_cache(filp, dirent, filldir, name, len,
6591 proc_pid_instantiate, iter.task, NULL);
6593 @@ -3103,7 +3134,7 @@ int proc_pid_readdir(struct file * filp,
6595 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6597 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
6598 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6602 @@ -3120,6 +3151,8 @@ int proc_pid_readdir(struct file * filp,
6604 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6605 filp->f_pos = iter.tgid + TGID_OFFSET;
6606 + if (!vx_proc_task_visible(iter.task))
6608 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6609 put_task_struct(iter.task);
6611 @@ -3273,6 +3306,8 @@ static struct dentry *proc_task_lookup(s
6612 tid = name_to_int(dentry);
6615 + if (vx_current_initpid(tid))
6618 ns = dentry->d_sb->s_fs_info;
6620 diff -NurpP --minimal linux-3.1.1/fs/proc/generic.c linux-3.1.1-vs2.3.2/fs/proc/generic.c
6621 --- linux-3.1.1/fs/proc/generic.c 2011-10-24 18:45:27.000000000 +0200
6622 +++ linux-3.1.1-vs2.3.2/fs/proc/generic.c 2011-10-24 18:53:33.000000000 +0200
6624 #include <linux/bitops.h>
6625 #include <linux/spinlock.h>
6626 #include <linux/completion.h>
6627 +#include <linux/vserver/inode.h>
6628 #include <asm/uaccess.h>
6630 #include "internal.h"
6631 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
6632 for (de = de->subdir; de ; de = de->next) {
6633 if (de->namelen != dentry->d_name.len)
6635 + if (!vx_hide_check(0, de->vx_flags))
6637 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6639 spin_unlock(&proc_subdir_lock);
6641 inode = proc_get_inode(dir->i_sb, de);
6642 + /* generic proc entries belong to the host */
6647 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
6649 /* filldir passes info to user space */
6651 + if (!vx_hide_check(0, de->vx_flags))
6653 spin_unlock(&proc_subdir_lock);
6654 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6655 de->low_ino, de->mode >> 12) < 0) {
6656 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
6659 spin_lock(&proc_subdir_lock);
6664 @@ -626,6 +634,7 @@ static struct proc_dir_entry *__proc_cre
6666 atomic_set(&ent->count, 1);
6668 + ent->vx_flags = IATTR_PROC_DEFAULT;
6669 spin_lock_init(&ent->pde_unload_lock);
6670 ent->pde_unload_completion = NULL;
6671 INIT_LIST_HEAD(&ent->pde_openers);
6672 @@ -649,7 +658,8 @@ struct proc_dir_entry *proc_symlink(cons
6678 + ent->vx_flags = IATTR_PROC_SYMLINK;
6682 diff -NurpP --minimal linux-3.1.1/fs/proc/inode.c linux-3.1.1-vs2.3.2/fs/proc/inode.c
6683 --- linux-3.1.1/fs/proc/inode.c 2011-10-24 18:45:27.000000000 +0200
6684 +++ linux-3.1.1-vs2.3.2/fs/proc/inode.c 2011-10-24 18:53:33.000000000 +0200
6685 @@ -442,6 +442,8 @@ struct inode *proc_get_inode(struct supe
6686 inode->i_uid = de->uid;
6687 inode->i_gid = de->gid;
6690 + PROC_I(inode)->vx_flags = de->vx_flags;
6692 inode->i_size = de->size;
6694 diff -NurpP --minimal linux-3.1.1/fs/proc/internal.h linux-3.1.1-vs2.3.2/fs/proc/internal.h
6695 --- linux-3.1.1/fs/proc/internal.h 2011-07-22 11:18:06.000000000 +0200
6696 +++ linux-3.1.1-vs2.3.2/fs/proc/internal.h 2011-10-24 18:53:33.000000000 +0200
6700 #include <linux/proc_fs.h>
6701 +#include <linux/vs_pid.h>
6703 extern struct proc_dir_entry proc_root;
6704 #ifdef CONFIG_PROC_SYSCTL
6705 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
6706 struct pid *pid, struct task_struct *task);
6707 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6708 struct pid *pid, struct task_struct *task);
6709 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6710 + struct pid *pid, struct task_struct *task);
6712 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6714 extern const struct file_operations proc_maps_operations;
6715 @@ -76,11 +80,16 @@ static inline struct pid *proc_pid(struc
6716 return PROC_I(inode)->pid;
6719 -static inline struct task_struct *get_proc_task(struct inode *inode)
6720 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6722 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6725 +static inline struct task_struct *get_proc_task(struct inode *inode)
6727 + return vx_get_proc_task(inode, proc_pid(inode));
6730 static inline int proc_fd(struct inode *inode)
6732 return PROC_I(inode)->fd;
6733 diff -NurpP --minimal linux-3.1.1/fs/proc/loadavg.c linux-3.1.1-vs2.3.2/fs/proc/loadavg.c
6734 --- linux-3.1.1/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
6735 +++ linux-3.1.1-vs2.3.2/fs/proc/loadavg.c 2011-10-24 18:53:33.000000000 +0200
6738 static int loadavg_proc_show(struct seq_file *m, void *v)
6740 + unsigned long running;
6741 + unsigned int threads;
6742 unsigned long avnrun[3];
6744 get_avenrun(avnrun, FIXED_1/200, 0);
6746 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6747 + struct vx_info *vxi = current_vx_info();
6749 + running = atomic_read(&vxi->cvirt.nr_running);
6750 + threads = atomic_read(&vxi->cvirt.nr_threads);
6752 + running = nr_running();
6753 + threads = nr_threads;
6756 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6757 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6758 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6759 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6760 - nr_running(), nr_threads,
6762 task_active_pid_ns(current)->last_pid);
6765 diff -NurpP --minimal linux-3.1.1/fs/proc/meminfo.c linux-3.1.1-vs2.3.2/fs/proc/meminfo.c
6766 --- linux-3.1.1/fs/proc/meminfo.c 2011-10-24 18:45:27.000000000 +0200
6767 +++ linux-3.1.1-vs2.3.2/fs/proc/meminfo.c 2011-10-24 18:53:33.000000000 +0200
6768 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6769 allowed = ((totalram_pages - hugetlb_total_pages())
6770 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6772 - cached = global_page_state(NR_FILE_PAGES) -
6773 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6774 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6775 total_swapcache_pages - i.bufferram;
6778 diff -NurpP --minimal linux-3.1.1/fs/proc/root.c linux-3.1.1-vs2.3.2/fs/proc/root.c
6779 --- linux-3.1.1/fs/proc/root.c 2011-10-24 18:45:27.000000000 +0200
6780 +++ linux-3.1.1-vs2.3.2/fs/proc/root.c 2011-10-24 18:53:33.000000000 +0200
6782 #include <linux/bitops.h>
6783 #include <linux/mount.h>
6784 #include <linux/pid_namespace.h>
6785 +#include <linux/vserver/inode.h>
6787 #include "internal.h"
6789 +struct proc_dir_entry *proc_virtual;
6791 +extern void proc_vx_init(void);
6793 static int proc_test_super(struct super_block *sb, void *data)
6795 return sb->s_fs_info == data;
6796 @@ -125,6 +130,7 @@ void __init proc_root_init(void)
6798 proc_mkdir("bus", NULL);
6803 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6804 @@ -192,6 +198,7 @@ struct proc_dir_entry proc_root = {
6805 .proc_iops = &proc_root_inode_operations,
6806 .proc_fops = &proc_root_operations,
6807 .parent = &proc_root,
6808 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6812 diff -NurpP --minimal linux-3.1.1/fs/proc/uptime.c linux-3.1.1-vs2.3.2/fs/proc/uptime.c
6813 --- linux-3.1.1/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
6814 +++ linux-3.1.1-vs2.3.2/fs/proc/uptime.c 2011-10-24 18:53:33.000000000 +0200
6816 #include <linux/sched.h>
6817 #include <linux/seq_file.h>
6818 #include <linux/time.h>
6819 -#include <linux/kernel_stat.h>
6820 +#include <linux/vserver/cvirt.h>
6821 #include <asm/cputime.h>
6823 static int uptime_proc_show(struct seq_file *m, void *v)
6825 struct timespec uptime;
6826 struct timespec idle;
6828 - cputime_t idletime = cputime_zero;
6830 - for_each_possible_cpu(i)
6831 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
6832 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
6834 do_posix_clock_monotonic_gettime(&uptime);
6835 monotonic_to_bootbased(&uptime);
6836 cputime_to_timespec(idletime, &idle);
6838 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6839 + vx_vsi_uptime(&uptime, &idle);
6841 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6842 (unsigned long) uptime.tv_sec,
6843 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6844 diff -NurpP --minimal linux-3.1.1/fs/quota/dquot.c linux-3.1.1-vs2.3.2/fs/quota/dquot.c
6845 --- linux-3.1.1/fs/quota/dquot.c 2011-07-22 11:18:06.000000000 +0200
6846 +++ linux-3.1.1-vs2.3.2/fs/quota/dquot.c 2011-10-24 18:53:33.000000000 +0200
6847 @@ -1548,6 +1548,9 @@ int __dquot_alloc_space(struct inode *in
6848 int reserve = flags & DQUOT_SPACE_RESERVE;
6849 int nofail = flags & DQUOT_SPACE_NOFAIL;
6851 + if ((ret = dl_alloc_space(inode, number)))
6855 * First test before acquiring mutex - solves deadlocks when we
6856 * re-enter the quota code and are already holding the mutex
6857 @@ -1602,6 +1605,9 @@ int dquot_alloc_inode(const struct inode
6859 char warntype[MAXQUOTAS];
6861 + if ((ret = dl_alloc_inode(inode)))
6864 /* First test before acquiring mutex - solves deadlocks when we
6865 * re-enter the quota code and are already holding the mutex */
6866 if (!dquot_active(inode))
6867 @@ -1672,6 +1678,8 @@ void __dquot_free_space(struct inode *in
6868 char warntype[MAXQUOTAS];
6869 int reserve = flags & DQUOT_SPACE_RESERVE;
6871 + dl_free_space(inode, number);
6873 /* First test before acquiring mutex - solves deadlocks when we
6874 * re-enter the quota code and are already holding the mutex */
6875 if (!dquot_active(inode)) {
6876 @@ -1710,6 +1718,8 @@ void dquot_free_inode(const struct inode
6878 char warntype[MAXQUOTAS];
6880 + dl_free_inode(inode);
6882 /* First test before acquiring mutex - solves deadlocks when we
6883 * re-enter the quota code and are already holding the mutex */
6884 if (!dquot_active(inode))
6885 diff -NurpP --minimal linux-3.1.1/fs/quota/quota.c linux-3.1.1-vs2.3.2/fs/quota/quota.c
6886 --- linux-3.1.1/fs/quota/quota.c 2011-10-24 18:45:27.000000000 +0200
6887 +++ linux-3.1.1-vs2.3.2/fs/quota/quota.c 2011-10-24 18:53:33.000000000 +0200
6889 #include <linux/fs.h>
6890 #include <linux/namei.h>
6891 #include <linux/slab.h>
6892 +#include <linux/vs_context.h>
6893 #include <asm/current.h>
6894 #include <asm/uaccess.h>
6895 #include <linux/kernel.h>
6896 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
6900 - if (!capable(CAP_SYS_ADMIN))
6901 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6905 @@ -293,6 +294,46 @@ static int do_quotactl(struct super_bloc
6909 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6911 +#include <linux/vroot.h>
6912 +#include <linux/major.h>
6913 +#include <linux/module.h>
6914 +#include <linux/kallsyms.h>
6915 +#include <linux/vserver/debug.h>
6917 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6919 +static DEFINE_SPINLOCK(vroot_grb_lock);
6921 +int register_vroot_grb(vroot_grb_func *func) {
6924 + spin_lock(&vroot_grb_lock);
6925 + if (!vroot_get_real_bdev) {
6926 + vroot_get_real_bdev = func;
6929 + spin_unlock(&vroot_grb_lock);
6932 +EXPORT_SYMBOL(register_vroot_grb);
6934 +int unregister_vroot_grb(vroot_grb_func *func) {
6935 + int ret = -EINVAL;
6937 + spin_lock(&vroot_grb_lock);
6938 + if (vroot_get_real_bdev) {
6939 + vroot_get_real_bdev = NULL;
6942 + spin_unlock(&vroot_grb_lock);
6945 +EXPORT_SYMBOL(unregister_vroot_grb);
6950 * look up a superblock on which quota ops will be performed
6951 * - use the name of a block device to find the superblock thereon
6952 @@ -310,6 +351,22 @@ static struct super_block *quotactl_bloc
6955 return ERR_CAST(bdev);
6956 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6957 + if (bdev && bdev->bd_inode &&
6958 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6959 + struct block_device *bdnew = (void *)-EINVAL;
6961 + if (vroot_get_real_bdev)
6962 + bdnew = vroot_get_real_bdev(bdev);
6964 + vxdprintk(VXD_CBIT(misc, 0),
6965 + "vroot_get_real_bdev not set");
6967 + if (IS_ERR(bdnew))
6968 + return ERR_PTR(PTR_ERR(bdnew));
6972 sb = get_super(bdev);
6975 diff -NurpP --minimal linux-3.1.1/fs/reiserfs/file.c linux-3.1.1-vs2.3.2/fs/reiserfs/file.c
6976 --- linux-3.1.1/fs/reiserfs/file.c 2011-10-24 18:45:27.000000000 +0200
6977 +++ linux-3.1.1-vs2.3.2/fs/reiserfs/file.c 2011-10-24 18:53:33.000000000 +0200
6978 @@ -319,5 +319,6 @@ const struct inode_operations reiserfs_f
6979 .listxattr = reiserfs_listxattr,
6980 .removexattr = reiserfs_removexattr,
6981 .permission = reiserfs_permission,
6982 + .sync_flags = reiserfs_sync_flags,
6983 .get_acl = reiserfs_get_acl,
6985 diff -NurpP --minimal linux-3.1.1/fs/reiserfs/inode.c linux-3.1.1-vs2.3.2/fs/reiserfs/inode.c
6986 --- linux-3.1.1/fs/reiserfs/inode.c 2011-10-24 18:45:27.000000000 +0200
6987 +++ linux-3.1.1-vs2.3.2/fs/reiserfs/inode.c 2011-10-24 18:53:33.000000000 +0200
6989 #include <linux/writeback.h>
6990 #include <linux/quotaops.h>
6991 #include <linux/swap.h>
6992 +#include <linux/vs_tag.h>
6994 int reiserfs_commit_write(struct file *f, struct page *page,
6995 unsigned from, unsigned to);
6996 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
6997 struct buffer_head *bh;
6998 struct item_head *ih;
7002 //int version = ITEM_VERSION_1;
7004 bh = PATH_PLAST_BUFFER(path);
7005 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
7006 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
7007 unsigned long blocks;
7009 + uid = sd_v1_uid(sd);
7010 + gid = sd_v1_gid(sd);
7012 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
7013 set_inode_sd_version(inode, STAT_DATA_V1);
7014 inode->i_mode = sd_v1_mode(sd);
7015 inode->i_nlink = sd_v1_nlink(sd);
7016 - inode->i_uid = sd_v1_uid(sd);
7017 - inode->i_gid = sd_v1_gid(sd);
7018 inode->i_size = sd_v1_size(sd);
7019 inode->i_atime.tv_sec = sd_v1_atime(sd);
7020 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
7021 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
7022 // (directories and symlinks)
7023 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
7025 + uid = sd_v2_uid(sd);
7026 + gid = sd_v2_gid(sd);
7028 inode->i_mode = sd_v2_mode(sd);
7029 inode->i_nlink = sd_v2_nlink(sd);
7030 - inode->i_uid = sd_v2_uid(sd);
7031 inode->i_size = sd_v2_size(sd);
7032 - inode->i_gid = sd_v2_gid(sd);
7033 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
7034 inode->i_atime.tv_sec = sd_v2_atime(sd);
7035 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
7036 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
7037 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
7040 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7041 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7042 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7045 if (S_ISREG(inode->i_mode)) {
7046 inode->i_op = &reiserfs_file_inode_operations;
7047 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
7048 static void inode2sd(void *sd, struct inode *inode, loff_t size)
7050 struct stat_data *sd_v2 = (struct stat_data *)sd;
7051 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7052 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7055 + set_sd_v2_uid(sd_v2, uid);
7056 + set_sd_v2_gid(sd_v2, gid);
7057 set_sd_v2_mode(sd_v2, inode->i_mode);
7058 set_sd_v2_nlink(sd_v2, inode->i_nlink);
7059 - set_sd_v2_uid(sd_v2, inode->i_uid);
7060 set_sd_v2_size(sd_v2, size);
7061 - set_sd_v2_gid(sd_v2, inode->i_gid);
7062 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
7063 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
7064 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
7065 @@ -2868,14 +2879,19 @@ int reiserfs_commit_write(struct file *f
7066 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
7068 if (reiserfs_attrs(inode->i_sb)) {
7069 - if (sd_attrs & REISERFS_SYNC_FL)
7070 - inode->i_flags |= S_SYNC;
7072 - inode->i_flags &= ~S_SYNC;
7073 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7074 inode->i_flags |= S_IMMUTABLE;
7076 inode->i_flags &= ~S_IMMUTABLE;
7077 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7078 + inode->i_flags |= S_IXUNLINK;
7080 + inode->i_flags &= ~S_IXUNLINK;
7082 + if (sd_attrs & REISERFS_SYNC_FL)
7083 + inode->i_flags |= S_SYNC;
7085 + inode->i_flags &= ~S_SYNC;
7086 if (sd_attrs & REISERFS_APPEND_FL)
7087 inode->i_flags |= S_APPEND;
7089 @@ -2888,6 +2904,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7090 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7092 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7094 + if (sd_attrs & REISERFS_BARRIER_FL)
7095 + inode->i_vflags |= V_BARRIER;
7097 + inode->i_vflags &= ~V_BARRIER;
7098 + if (sd_attrs & REISERFS_COW_FL)
7099 + inode->i_vflags |= V_COW;
7101 + inode->i_vflags &= ~V_COW;
7105 @@ -2898,6 +2923,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7106 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7108 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7109 + if (inode->i_flags & S_IXUNLINK)
7110 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7112 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7114 if (inode->i_flags & S_SYNC)
7115 *sd_attrs |= REISERFS_SYNC_FL;
7117 @@ -2910,6 +2940,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7118 *sd_attrs |= REISERFS_NOTAIL_FL;
7120 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7122 + if (inode->i_vflags & V_BARRIER)
7123 + *sd_attrs |= REISERFS_BARRIER_FL;
7125 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7126 + if (inode->i_vflags & V_COW)
7127 + *sd_attrs |= REISERFS_COW_FL;
7129 + *sd_attrs &= ~REISERFS_COW_FL;
7133 @@ -3155,7 +3194,8 @@ int reiserfs_setattr(struct dentry *dent
7136 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7137 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7138 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7139 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7140 struct reiserfs_transaction_handle th;
7143 @@ -3184,6 +3224,9 @@ int reiserfs_setattr(struct dentry *dent
7144 inode->i_uid = attr->ia_uid;
7145 if (attr->ia_valid & ATTR_GID)
7146 inode->i_gid = attr->ia_gid;
7147 + if ((attr->ia_valid & ATTR_TAG) &&
7149 + inode->i_tag = attr->ia_tag;
7150 mark_inode_dirty(inode);
7151 error = journal_end(&th, inode->i_sb, jbegin_count);
7153 diff -NurpP --minimal linux-3.1.1/fs/reiserfs/ioctl.c linux-3.1.1-vs2.3.2/fs/reiserfs/ioctl.c
7154 --- linux-3.1.1/fs/reiserfs/ioctl.c 2011-05-22 16:17:53.000000000 +0200
7155 +++ linux-3.1.1-vs2.3.2/fs/reiserfs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
7157 #include <linux/pagemap.h>
7158 #include <linux/compat.h>
7161 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7163 + __u16 sd_attrs = 0;
7165 + inode->i_flags = flags;
7166 + inode->i_vflags = vflags;
7168 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7169 + REISERFS_I(inode)->i_attrs = sd_attrs;
7170 + inode->i_ctime = CURRENT_TIME_SEC;
7171 + mark_inode_dirty(inode);
7176 * reiserfs_ioctl - handler for ioctl for inode
7177 * supported commands:
7179 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7181 struct inode *inode = filp->f_path.dentry->d_inode;
7182 - unsigned int flags;
7183 + unsigned int flags, oldflags;
7186 reiserfs_write_lock(inode->i_sb);
7187 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7189 flags = REISERFS_I(inode)->i_attrs;
7190 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7191 + flags &= REISERFS_FL_USER_VISIBLE;
7192 err = put_user(flags, (int __user *)arg);
7194 case REISERFS_IOC_SETFLAGS:{
7195 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7199 + if (IS_BARRIER(inode)) {
7200 + vxwprintk_task(1, "messing with the barrier.");
7204 * Is it quota file? Do not allow user to mess with it
7206 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7211 + oldflags = REISERFS_I(inode)->i_attrs;
7212 + flags &= REISERFS_FL_USER_MODIFIABLE;
7213 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7214 sd_attrs_to_i_attrs(flags, inode);
7215 REISERFS_I(inode)->i_attrs = flags;
7216 inode->i_ctime = CURRENT_TIME_SEC;
7217 diff -NurpP --minimal linux-3.1.1/fs/reiserfs/namei.c linux-3.1.1-vs2.3.2/fs/reiserfs/namei.c
7218 --- linux-3.1.1/fs/reiserfs/namei.c 2011-10-24 18:45:27.000000000 +0200
7219 +++ linux-3.1.1-vs2.3.2/fs/reiserfs/namei.c 2011-10-24 18:53:33.000000000 +0200
7221 #include <linux/reiserfs_acl.h>
7222 #include <linux/reiserfs_xattr.h>
7223 #include <linux/quotaops.h>
7224 +#include <linux/vs_tag.h>
7226 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; }
7227 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7228 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7229 if (retval == IO_ERROR) {
7230 return ERR_PTR(-EIO);
7232 + dx_propagate_tag(nd, inode);
7234 return d_splice_alias(inode, dentry);
7236 diff -NurpP --minimal linux-3.1.1/fs/reiserfs/super.c linux-3.1.1-vs2.3.2/fs/reiserfs/super.c
7237 --- linux-3.1.1/fs/reiserfs/super.c 2011-10-24 18:45:27.000000000 +0200
7238 +++ linux-3.1.1-vs2.3.2/fs/reiserfs/super.c 2011-10-24 18:53:33.000000000 +0200
7239 @@ -899,6 +899,14 @@ static int reiserfs_parse_options(struct
7240 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7241 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7243 +#ifndef CONFIG_TAGGING_NONE
7244 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7245 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7246 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7248 +#ifdef CONFIG_PROPAGATE
7249 + {"tag",.arg_required = 'T',.values = NULL},
7251 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7252 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7253 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7254 @@ -1208,6 +1216,14 @@ static int reiserfs_remount(struct super
7255 handle_quota_files(s, qf_names, &qfmt);
7258 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7259 + !(s->s_flags & MS_TAGGED)) {
7260 + reiserfs_warning(s, "super-vs01",
7261 + "reiserfs: tagging not permitted on remount.");
7268 /* Add options that are safe here */
7269 @@ -1691,6 +1707,10 @@ static int reiserfs_fill_super(struct su
7273 + /* map mount option tagxid */
7274 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7275 + s->s_flags |= MS_TAGGED;
7277 rs = SB_DISK_SUPER_BLOCK(s);
7278 /* Let's do basic sanity check to verify that underlying device is not
7279 smaller than the filesystem. If the check fails then abort and scream,
7280 diff -NurpP --minimal linux-3.1.1/fs/reiserfs/xattr.c linux-3.1.1-vs2.3.2/fs/reiserfs/xattr.c
7281 --- linux-3.1.1/fs/reiserfs/xattr.c 2011-10-24 18:45:27.000000000 +0200
7282 +++ linux-3.1.1-vs2.3.2/fs/reiserfs/xattr.c 2011-10-24 18:53:33.000000000 +0200
7284 #include <linux/errno.h>
7285 #include <linux/gfp.h>
7286 #include <linux/fs.h>
7287 +#include <linux/mount.h>
7288 #include <linux/file.h>
7289 #include <linux/pagemap.h>
7290 #include <linux/xattr.h>
7291 diff -NurpP --minimal linux-3.1.1/fs/stat.c linux-3.1.1-vs2.3.2/fs/stat.c
7292 --- linux-3.1.1/fs/stat.c 2011-11-15 16:44:52.000000000 +0100
7293 +++ linux-3.1.1-vs2.3.2/fs/stat.c 2011-11-15 17:08:44.000000000 +0100
7294 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7295 stat->nlink = inode->i_nlink;
7296 stat->uid = inode->i_uid;
7297 stat->gid = inode->i_gid;
7298 + stat->tag = inode->i_tag;
7299 stat->rdev = inode->i_rdev;
7300 stat->size = i_size_read(inode);
7301 stat->atime = inode->i_atime;
7302 diff -NurpP --minimal linux-3.1.1/fs/statfs.c linux-3.1.1-vs2.3.2/fs/statfs.c
7303 --- linux-3.1.1/fs/statfs.c 2011-11-15 16:44:52.000000000 +0100
7304 +++ linux-3.1.1-vs2.3.2/fs/statfs.c 2011-11-15 17:08:44.000000000 +0100
7306 #include <linux/statfs.h>
7307 #include <linux/security.h>
7308 #include <linux/uaccess.h>
7309 +#include <linux/vs_base.h>
7310 +#include <linux/vs_dlimit.h>
7312 static int flags_by_mnt(int mnt_flags)
7314 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
7315 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7316 if (retval == 0 && buf->f_frsize == 0)
7317 buf->f_frsize = buf->f_bsize;
7318 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7319 + vx_vsi_statfs(dentry->d_sb, buf);
7323 diff -NurpP --minimal linux-3.1.1/fs/super.c linux-3.1.1-vs2.3.2/fs/super.c
7324 --- linux-3.1.1/fs/super.c 2011-10-24 18:45:27.000000000 +0200
7325 +++ linux-3.1.1-vs2.3.2/fs/super.c 2011-10-24 18:53:33.000000000 +0200
7327 #include <linux/backing-dev.h>
7328 #include <linux/rculist_bl.h>
7329 #include <linux/cleancache.h>
7330 +#include <linux/devpts_fs.h>
7331 +#include <linux/proc_fs.h>
7332 +#include <linux/vs_context.h>
7333 #include "internal.h"
7336 @@ -1095,6 +1098,13 @@ mount_fs(struct file_system_type *type,
7337 WARN_ON(sb->s_bdi == &default_backing_dev_info);
7338 sb->s_flags |= MS_BORN;
7341 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
7343 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7344 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7347 error = security_sb_kern_mount(sb, flags, secdata);
7350 diff -NurpP --minimal linux-3.1.1/fs/sysfs/mount.c linux-3.1.1-vs2.3.2/fs/sysfs/mount.c
7351 --- linux-3.1.1/fs/sysfs/mount.c 2011-07-22 11:18:06.000000000 +0200
7352 +++ linux-3.1.1-vs2.3.2/fs/sysfs/mount.c 2011-10-24 18:53:33.000000000 +0200
7353 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7355 sb->s_blocksize = PAGE_CACHE_SIZE;
7356 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7357 - sb->s_magic = SYSFS_MAGIC;
7358 + sb->s_magic = SYSFS_SUPER_MAGIC;
7359 sb->s_op = &sysfs_ops;
7360 sb->s_time_gran = 1;
7362 diff -NurpP --minimal linux-3.1.1/fs/utimes.c linux-3.1.1-vs2.3.2/fs/utimes.c
7363 --- linux-3.1.1/fs/utimes.c 2011-05-22 16:17:54.000000000 +0200
7364 +++ linux-3.1.1-vs2.3.2/fs/utimes.c 2011-10-24 18:53:33.000000000 +0200
7366 #include <linux/stat.h>
7367 #include <linux/utime.h>
7368 #include <linux/syscalls.h>
7369 +#include <linux/mount.h>
7370 +#include <linux/vs_cowbl.h>
7371 #include <asm/uaccess.h>
7372 #include <asm/unistd.h>
7374 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7377 struct iattr newattrs;
7378 - struct inode *inode = path->dentry->d_inode;
7379 + struct inode *inode;
7381 error = mnt_want_write(path->mnt);
7385 + error = cow_check_and_break(path);
7387 + goto mnt_drop_write_and_out;
7389 + inode = path->dentry->d_inode;
7391 if (times && times[0].tv_nsec == UTIME_NOW &&
7392 times[1].tv_nsec == UTIME_NOW)
7394 diff -NurpP --minimal linux-3.1.1/fs/xattr.c linux-3.1.1-vs2.3.2/fs/xattr.c
7395 --- linux-3.1.1/fs/xattr.c 2011-07-22 11:18:09.000000000 +0200
7396 +++ linux-3.1.1-vs2.3.2/fs/xattr.c 2011-10-24 18:53:33.000000000 +0200
7398 #include <linux/module.h>
7399 #include <linux/fsnotify.h>
7400 #include <linux/audit.h>
7401 +#include <linux/mount.h>
7402 #include <asm/uaccess.h>
7405 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7406 * The trusted.* namespace can only be accessed by privileged users.
7408 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
7409 - if (!capable(CAP_SYS_ADMIN))
7410 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
7411 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
7414 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_dinode.h linux-3.1.1-vs2.3.2/fs/xfs/xfs_dinode.h
7415 --- linux-3.1.1/fs/xfs/xfs_dinode.h 2011-10-24 18:45:31.000000000 +0200
7416 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_dinode.h 2011-10-24 18:53:33.000000000 +0200
7417 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
7418 __be32 di_nlink; /* number of links to file */
7419 __be16 di_projid_lo; /* lower part of owner's project id */
7420 __be16 di_projid_hi; /* higher part owner's project id */
7421 - __u8 di_pad[6]; /* unused, zeroed space */
7422 + __u8 di_pad[2]; /* unused, zeroed space */
7423 + __be16 di_tag; /* context tagging */
7424 + __be16 di_vflags; /* vserver specific flags */
7425 __be16 di_flushiter; /* incremented on flush */
7426 xfs_timestamp_t di_atime; /* time last accessed */
7427 xfs_timestamp_t di_mtime; /* time last modified */
7428 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
7429 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7430 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7431 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7432 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7434 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7435 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7436 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7437 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
7438 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7439 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7440 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7441 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7443 #ifdef CONFIG_XFS_RT
7444 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7445 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
7446 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7447 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7448 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7449 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7450 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7451 + XFS_DIFLAG_IXUNLINK)
7453 +#define XFS_DIVFLAG_BARRIER 0x01
7454 +#define XFS_DIVFLAG_COW 0x02
7456 #endif /* __XFS_DINODE_H__ */
7457 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_fs.h linux-3.1.1-vs2.3.2/fs/xfs/xfs_fs.h
7458 --- linux-3.1.1/fs/xfs/xfs_fs.h 2011-10-24 18:45:31.000000000 +0200
7459 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_fs.h 2011-10-24 18:53:33.000000000 +0200
7460 @@ -67,6 +67,9 @@ struct fsxattr {
7461 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
7462 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
7463 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
7464 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
7465 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
7466 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
7467 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
7470 @@ -302,7 +305,8 @@ typedef struct xfs_bstat {
7471 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
7472 __u16 bs_forkoff; /* inode fork offset in bytes */
7473 __u16 bs_projid_hi; /* higher part of project id */
7474 - unsigned char bs_pad[10]; /* pad space, unused */
7475 + unsigned char bs_pad[8]; /* pad space, unused */
7476 + __u16 bs_tag; /* context tagging */
7477 __u32 bs_dmevmask; /* DMIG event mask */
7478 __u16 bs_dmstate; /* DMIG state info */
7479 __u16 bs_aextents; /* attribute number of extents */
7480 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_ialloc.c linux-3.1.1-vs2.3.2/fs/xfs/xfs_ialloc.c
7481 --- linux-3.1.1/fs/xfs/xfs_ialloc.c 2011-10-24 18:45:31.000000000 +0200
7482 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_ialloc.c 2011-10-24 18:53:33.000000000 +0200
7484 #include "xfs_error.h"
7485 #include "xfs_bmap.h"
7489 * Allocation group level functions.
7491 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_inode.c linux-3.1.1-vs2.3.2/fs/xfs/xfs_inode.c
7492 --- linux-3.1.1/fs/xfs/xfs_inode.c 2011-10-24 18:45:31.000000000 +0200
7493 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_inode.c 2011-10-24 18:53:33.000000000 +0200
7494 @@ -242,6 +242,7 @@ xfs_inotobp(
7498 +#include <linux/vs_tag.h>
7501 * This routine is called to map an inode to the buffer containing
7502 @@ -640,15 +641,25 @@ xfs_iformat_btree(
7504 xfs_dinode_from_disk(
7506 - xfs_dinode_t *from)
7507 + xfs_dinode_t *from,
7510 + uint32_t uid, gid, tag;
7512 to->di_magic = be16_to_cpu(from->di_magic);
7513 to->di_mode = be16_to_cpu(from->di_mode);
7514 to->di_version = from ->di_version;
7515 to->di_format = from->di_format;
7516 to->di_onlink = be16_to_cpu(from->di_onlink);
7517 - to->di_uid = be32_to_cpu(from->di_uid);
7518 - to->di_gid = be32_to_cpu(from->di_gid);
7520 + uid = be32_to_cpu(from->di_uid);
7521 + gid = be32_to_cpu(from->di_gid);
7522 + tag = be16_to_cpu(from->di_tag);
7524 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7525 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7526 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7528 to->di_nlink = be32_to_cpu(from->di_nlink);
7529 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7530 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7531 @@ -670,21 +681,26 @@ xfs_dinode_from_disk(
7532 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7533 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7534 to->di_flags = be16_to_cpu(from->di_flags);
7535 + to->di_vflags = be16_to_cpu(from->di_vflags);
7536 to->di_gen = be32_to_cpu(from->di_gen);
7542 - xfs_icdinode_t *from)
7543 + xfs_icdinode_t *from,
7546 to->di_magic = cpu_to_be16(from->di_magic);
7547 to->di_mode = cpu_to_be16(from->di_mode);
7548 to->di_version = from ->di_version;
7549 to->di_format = from->di_format;
7550 to->di_onlink = cpu_to_be16(from->di_onlink);
7551 - to->di_uid = cpu_to_be32(from->di_uid);
7552 - to->di_gid = cpu_to_be32(from->di_gid);
7554 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
7555 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
7556 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
7558 to->di_nlink = cpu_to_be32(from->di_nlink);
7559 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
7560 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
7561 @@ -706,12 +722,14 @@ xfs_dinode_to_disk(
7562 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
7563 to->di_dmstate = cpu_to_be16(from->di_dmstate);
7564 to->di_flags = cpu_to_be16(from->di_flags);
7565 + to->di_vflags = cpu_to_be16(from->di_vflags);
7566 to->di_gen = cpu_to_be32(from->di_gen);
7571 - __uint16_t di_flags)
7572 + __uint16_t di_flags,
7573 + __uint16_t di_vflags)
7577 @@ -722,6 +740,8 @@ _xfs_dic2xflags(
7578 flags |= XFS_XFLAG_PREALLOC;
7579 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7580 flags |= XFS_XFLAG_IMMUTABLE;
7581 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7582 + flags |= XFS_XFLAG_IXUNLINK;
7583 if (di_flags & XFS_DIFLAG_APPEND)
7584 flags |= XFS_XFLAG_APPEND;
7585 if (di_flags & XFS_DIFLAG_SYNC)
7586 @@ -746,6 +766,10 @@ _xfs_dic2xflags(
7587 flags |= XFS_XFLAG_FILESTREAM;
7590 + if (di_vflags & XFS_DIVFLAG_BARRIER)
7591 + flags |= FS_BARRIER_FL;
7592 + if (di_vflags & XFS_DIVFLAG_COW)
7593 + flags |= FS_COW_FL;
7597 @@ -755,7 +779,7 @@ xfs_ip2xflags(
7599 xfs_icdinode_t *dic = &ip->i_d;
7601 - return _xfs_dic2xflags(dic->di_flags) |
7602 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
7603 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
7606 @@ -763,7 +787,8 @@ uint
7610 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
7611 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
7612 + be16_to_cpu(dip->di_vflags)) |
7613 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
7616 @@ -796,7 +821,6 @@ xfs_iread(
7619 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
7622 * If we got something that isn't an inode it means someone
7623 * (nfs or dmi) has a stale handle.
7624 @@ -819,7 +843,8 @@ xfs_iread(
7625 * Otherwise, just get the truly permanent information.
7628 - xfs_dinode_from_disk(&ip->i_d, dip);
7629 + xfs_dinode_from_disk(&ip->i_d, dip,
7630 + mp->m_flags & XFS_MOUNT_TAGGED);
7631 error = xfs_iformat(ip, dip);
7634 @@ -1014,6 +1039,7 @@ xfs_ialloc(
7635 ASSERT(ip->i_d.di_nlink == nlink);
7636 ip->i_d.di_uid = current_fsuid();
7637 ip->i_d.di_gid = current_fsgid();
7638 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
7639 xfs_set_projid(ip, prid);
7640 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
7642 @@ -1074,6 +1100,7 @@ xfs_ialloc(
7643 ip->i_d.di_dmevmask = 0;
7644 ip->i_d.di_dmstate = 0;
7645 ip->i_d.di_flags = 0;
7646 + ip->i_d.di_vflags = 0;
7647 flags = XFS_ILOG_CORE;
7648 switch (mode & S_IFMT) {
7650 @@ -1845,6 +1872,7 @@ xfs_ifree(
7652 ip->i_d.di_mode = 0; /* mark incore inode as free */
7653 ip->i_d.di_flags = 0;
7654 + ip->i_d.di_vflags = 0;
7655 ip->i_d.di_dmevmask = 0;
7656 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
7657 ip->i_df.if_ext_max =
7658 @@ -2724,7 +2752,8 @@ xfs_iflush_int(
7659 * because if the inode is dirty at all the core must
7662 - xfs_dinode_to_disk(dip, &ip->i_d);
7663 + xfs_dinode_to_disk(dip, &ip->i_d,
7664 + mp->m_flags & XFS_MOUNT_TAGGED);
7666 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7667 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7668 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_inode.h linux-3.1.1-vs2.3.2/fs/xfs/xfs_inode.h
7669 --- linux-3.1.1/fs/xfs/xfs_inode.h 2011-10-24 18:45:31.000000000 +0200
7670 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_inode.h 2011-10-24 18:53:33.000000000 +0200
7671 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
7672 __uint32_t di_nlink; /* number of links to file */
7673 __uint16_t di_projid_lo; /* lower part of owner's project id */
7674 __uint16_t di_projid_hi; /* higher part of owner's project id */
7675 - __uint8_t di_pad[6]; /* unused, zeroed space */
7676 + __uint8_t di_pad[2]; /* unused, zeroed space */
7677 + __uint16_t di_tag; /* context tagging */
7678 + __uint16_t di_vflags; /* vserver specific flags */
7679 __uint16_t di_flushiter; /* incremented on flush */
7680 xfs_ictimestamp_t di_atime; /* time last accessed */
7681 xfs_ictimestamp_t di_mtime; /* time last modified */
7682 @@ -536,7 +538,7 @@ int xfs_itobp(struct xfs_mount *, struc
7683 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
7684 struct xfs_inode *, uint);
7685 void xfs_dinode_to_disk(struct xfs_dinode *,
7686 - struct xfs_icdinode *);
7687 + struct xfs_icdinode *, int);
7688 void xfs_idestroy_fork(struct xfs_inode *, int);
7689 void xfs_idata_realloc(struct xfs_inode *, int, int);
7690 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7691 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_ioctl.c linux-3.1.1-vs2.3.2/fs/xfs/xfs_ioctl.c
7692 --- linux-3.1.1/fs/xfs/xfs_ioctl.c 2011-10-24 18:45:31.000000000 +0200
7693 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_ioctl.c 2011-10-24 18:53:33.000000000 +0200
7695 #include "xfs_bmap_btree.h"
7696 #include "xfs_dinode.h"
7697 #include "xfs_inode.h"
7698 -#include "xfs_ioctl.h"
7699 +// #include "xfs_ioctl.h"
7700 #include "xfs_rtalloc.h"
7701 #include "xfs_itable.h"
7702 #include "xfs_error.h"
7703 @@ -748,6 +748,10 @@ xfs_merge_ioc_xflags(
7704 xflags |= XFS_XFLAG_IMMUTABLE;
7706 xflags &= ~XFS_XFLAG_IMMUTABLE;
7707 + if (flags & FS_IXUNLINK_FL)
7708 + xflags |= XFS_XFLAG_IXUNLINK;
7710 + xflags &= ~XFS_XFLAG_IXUNLINK;
7711 if (flags & FS_APPEND_FL)
7712 xflags |= XFS_XFLAG_APPEND;
7714 @@ -776,6 +780,8 @@ xfs_di2lxflags(
7716 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7717 flags |= FS_IMMUTABLE_FL;
7718 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7719 + flags |= FS_IXUNLINK_FL;
7720 if (di_flags & XFS_DIFLAG_APPEND)
7721 flags |= FS_APPEND_FL;
7722 if (di_flags & XFS_DIFLAG_SYNC)
7723 @@ -836,6 +842,8 @@ xfs_set_diflags(
7724 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7725 if (xflags & XFS_XFLAG_IMMUTABLE)
7726 di_flags |= XFS_DIFLAG_IMMUTABLE;
7727 + if (xflags & XFS_XFLAG_IXUNLINK)
7728 + di_flags |= XFS_DIFLAG_IXUNLINK;
7729 if (xflags & XFS_XFLAG_APPEND)
7730 di_flags |= XFS_DIFLAG_APPEND;
7731 if (xflags & XFS_XFLAG_SYNC)
7732 @@ -878,6 +886,10 @@ xfs_diflags_to_linux(
7733 inode->i_flags |= S_IMMUTABLE;
7735 inode->i_flags &= ~S_IMMUTABLE;
7736 + if (xflags & XFS_XFLAG_IXUNLINK)
7737 + inode->i_flags |= S_IXUNLINK;
7739 + inode->i_flags &= ~S_IXUNLINK;
7740 if (xflags & XFS_XFLAG_APPEND)
7741 inode->i_flags |= S_APPEND;
7743 @@ -1370,10 +1382,18 @@ xfs_file_ioctl(
7744 case XFS_IOC_FSGETXATTRA:
7745 return xfs_ioc_fsgetxattr(ip, 1, arg);
7746 case XFS_IOC_FSSETXATTR:
7747 + if (IS_BARRIER(inode)) {
7748 + vxwprintk_task(1, "messing with the barrier.");
7749 + return -XFS_ERROR(EACCES);
7751 return xfs_ioc_fssetxattr(ip, filp, arg);
7752 case XFS_IOC_GETXFLAGS:
7753 return xfs_ioc_getxflags(ip, arg);
7754 case XFS_IOC_SETXFLAGS:
7755 + if (IS_BARRIER(inode)) {
7756 + vxwprintk_task(1, "messing with the barrier.");
7757 + return -XFS_ERROR(EACCES);
7759 return xfs_ioc_setxflags(ip, filp, arg);
7761 case XFS_IOC_FSSETDM: {
7762 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_ioctl.h linux-3.1.1-vs2.3.2/fs/xfs/xfs_ioctl.h
7763 --- linux-3.1.1/fs/xfs/xfs_ioctl.h 2011-10-24 18:45:31.000000000 +0200
7764 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_ioctl.h 2011-10-24 18:53:33.000000000 +0200
7765 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7766 void __user *uhandle,
7771 + struct inode *inode,
7778 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_iops.c linux-3.1.1-vs2.3.2/fs/xfs/xfs_iops.c
7779 --- linux-3.1.1/fs/xfs/xfs_iops.c 2011-10-24 18:45:31.000000000 +0200
7780 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_iops.c 2011-10-24 18:53:33.000000000 +0200
7782 #include "xfs_bmap_btree.h"
7783 #include "xfs_dinode.h"
7784 #include "xfs_inode.h"
7785 +#include "xfs_ioctl.h"
7786 #include "xfs_bmap.h"
7787 #include "xfs_rtalloc.h"
7788 #include "xfs_error.h"
7790 #include <linux/security.h>
7791 #include <linux/fiemap.h>
7792 #include <linux/slab.h>
7793 +#include <linux/vs_tag.h>
7796 * Bring the timestamps in the XFS inode uptodate.
7797 @@ -473,6 +475,7 @@ xfs_vn_getattr(
7798 stat->nlink = ip->i_d.di_nlink;
7799 stat->uid = ip->i_d.di_uid;
7800 stat->gid = ip->i_d.di_gid;
7801 + stat->tag = ip->i_d.di_tag;
7802 stat->ino = ip->i_ino;
7803 stat->atime = inode->i_atime;
7804 stat->mtime = inode->i_mtime;
7805 @@ -1038,6 +1041,7 @@ static const struct inode_operations xfs
7806 .removexattr = generic_removexattr,
7807 .listxattr = xfs_vn_listxattr,
7808 .fiemap = xfs_vn_fiemap,
7809 + .sync_flags = xfs_sync_flags,
7812 static const struct inode_operations xfs_dir_inode_operations = {
7813 @@ -1063,6 +1067,7 @@ static const struct inode_operations xfs
7814 .getxattr = generic_getxattr,
7815 .removexattr = generic_removexattr,
7816 .listxattr = xfs_vn_listxattr,
7817 + .sync_flags = xfs_sync_flags,
7820 static const struct inode_operations xfs_dir_ci_inode_operations = {
7821 @@ -1112,6 +1117,10 @@ xfs_diflags_to_iflags(
7822 inode->i_flags |= S_IMMUTABLE;
7824 inode->i_flags &= ~S_IMMUTABLE;
7825 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7826 + inode->i_flags |= S_IXUNLINK;
7828 + inode->i_flags &= ~S_IXUNLINK;
7829 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7830 inode->i_flags |= S_APPEND;
7832 @@ -1124,6 +1133,15 @@ xfs_diflags_to_iflags(
7833 inode->i_flags |= S_NOATIME;
7835 inode->i_flags &= ~S_NOATIME;
7837 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7838 + inode->i_vflags |= V_BARRIER;
7840 + inode->i_vflags &= ~V_BARRIER;
7841 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7842 + inode->i_vflags |= V_COW;
7844 + inode->i_vflags &= ~V_COW;
7848 @@ -1155,6 +1173,7 @@ xfs_setup_inode(
7849 inode->i_nlink = ip->i_d.di_nlink;
7850 inode->i_uid = ip->i_d.di_uid;
7851 inode->i_gid = ip->i_d.di_gid;
7852 + inode->i_tag = ip->i_d.di_tag;
7854 switch (inode->i_mode & S_IFMT) {
7856 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_itable.c linux-3.1.1-vs2.3.2/fs/xfs/xfs_itable.c
7857 --- linux-3.1.1/fs/xfs/xfs_itable.c 2011-05-22 16:17:54.000000000 +0200
7858 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_itable.c 2011-10-24 18:53:33.000000000 +0200
7859 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
7860 buf->bs_mode = dic->di_mode;
7861 buf->bs_uid = dic->di_uid;
7862 buf->bs_gid = dic->di_gid;
7863 + buf->bs_tag = dic->di_tag;
7864 buf->bs_size = dic->di_size;
7867 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_linux.h linux-3.1.1-vs2.3.2/fs/xfs/xfs_linux.h
7868 --- linux-3.1.1/fs/xfs/xfs_linux.h 2011-10-24 18:45:31.000000000 +0200
7869 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_linux.h 2011-10-24 18:53:33.000000000 +0200
7872 #define current_cpu() (raw_smp_processor_id())
7873 #define current_pid() (current->pid)
7874 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7875 #define current_test_flags(f) (current->flags & (f))
7876 #define current_set_flags_nested(sp, f) \
7877 (*(sp) = current->flags, current->flags |= (f))
7878 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_log_recover.c linux-3.1.1-vs2.3.2/fs/xfs/xfs_log_recover.c
7879 --- linux-3.1.1/fs/xfs/xfs_log_recover.c 2011-10-24 18:45:31.000000000 +0200
7880 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_log_recover.c 2011-10-24 18:53:33.000000000 +0200
7881 @@ -2347,7 +2347,8 @@ xlog_recover_inode_pass2(
7884 /* The core is in in-core format */
7885 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
7886 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
7887 + mp->m_flags & XFS_MOUNT_TAGGED);
7889 /* the rest is in on-disk format */
7890 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
7891 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_mount.h linux-3.1.1-vs2.3.2/fs/xfs/xfs_mount.h
7892 --- linux-3.1.1/fs/xfs/xfs_mount.h 2011-10-24 18:45:31.000000000 +0200
7893 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_mount.h 2011-10-24 18:53:33.000000000 +0200
7894 @@ -249,6 +249,7 @@ typedef struct xfs_mount {
7896 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7898 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7901 * Default minimum read and write sizes.
7902 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_super.c linux-3.1.1-vs2.3.2/fs/xfs/xfs_super.c
7903 --- linux-3.1.1/fs/xfs/xfs_super.c 2011-10-24 18:45:31.000000000 +0200
7904 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_super.c 2011-10-24 18:53:33.000000000 +0200
7905 @@ -113,6 +113,9 @@ mempool_t *xfs_ioend_pool;
7906 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7907 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7908 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7909 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7910 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7911 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7914 * Table driven mount option parser.
7915 @@ -121,10 +124,14 @@ mempool_t *xfs_ioend_pool;
7916 * in the future, too.
7919 + Opt_tag, Opt_notag,
7920 Opt_barrier, Opt_nobarrier, Opt_err
7923 static const match_table_t tokens = {
7924 + {Opt_tag, "tagxid"},
7926 + {Opt_notag, "notag"},
7927 {Opt_barrier, "barrier"},
7928 {Opt_nobarrier, "nobarrier"},
7930 @@ -374,6 +381,19 @@ xfs_parseargs(
7931 } else if (!strcmp(this_char, "irixsgid")) {
7933 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7934 +#ifndef CONFIG_TAGGING_NONE
7935 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7936 + mp->m_flags |= XFS_MOUNT_TAGGED;
7937 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7938 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7939 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7940 + mp->m_flags |= XFS_MOUNT_TAGGED;
7942 +#ifdef CONFIG_PROPAGATE
7943 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7945 + mp->m_flags |= XFS_MOUNT_TAGGED;
7948 xfs_warn(mp, "unknown mount option [%s].", this_char);
7950 @@ -1162,6 +1182,16 @@ xfs_fs_remount(
7952 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7955 + if (!(sb->s_flags & MS_TAGGED)) {
7957 + "XFS: %s: tagging not permitted on remount.\n",
7966 * Logically we would return an error here to prevent
7967 @@ -1377,6 +1407,9 @@ xfs_fs_fill_super(
7971 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7972 + sb->s_flags |= MS_TAGGED;
7975 * we must configure the block size in the superblock before we run the
7976 * full mount process as the mount process can lookup and cache inodes.
7977 diff -NurpP --minimal linux-3.1.1/fs/xfs/xfs_vnodeops.c linux-3.1.1-vs2.3.2/fs/xfs/xfs_vnodeops.c
7978 --- linux-3.1.1/fs/xfs/xfs_vnodeops.c 2011-10-24 18:45:31.000000000 +0200
7979 +++ linux-3.1.1-vs2.3.2/fs/xfs/xfs_vnodeops.c 2011-10-24 18:53:33.000000000 +0200
7980 @@ -107,6 +107,78 @@ xfs_readlink_bmap(
7986 +xfs_get_inode_flags(
7989 + struct inode *inode = VFS_I(ip);
7990 + unsigned int flags = inode->i_flags;
7991 + unsigned int vflags = inode->i_vflags;
7993 + if (flags & S_IMMUTABLE)
7994 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7996 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7997 + if (flags & S_IXUNLINK)
7998 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
8000 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
8002 + if (vflags & V_BARRIER)
8003 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
8005 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
8006 + if (vflags & V_COW)
8007 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
8009 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
8014 + struct inode *inode,
8018 + struct xfs_inode *ip = XFS_I(inode);
8019 + struct xfs_mount *mp = ip->i_mount;
8020 + struct xfs_trans *tp;
8021 + unsigned int lock_flags = 0;
8024 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
8025 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
8029 + xfs_ilock(ip, XFS_ILOCK_EXCL);
8031 + xfs_trans_ijoin(tp, ip);
8033 + inode->i_flags = flags;
8034 + inode->i_vflags = vflags;
8035 + xfs_get_inode_flags(ip);
8037 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8038 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
8040 + XFS_STATS_INC(xs_ig_attrchg);
8042 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8043 + xfs_trans_set_sync(tp);
8044 + code = xfs_trans_commit(tp, 0);
8045 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8049 + xfs_trans_cancel(tp, 0);
8051 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8059 diff -NurpP --minimal linux-3.1.1/include/asm-generic/tlb.h linux-3.1.1-vs2.3.2/include/asm-generic/tlb.h
8060 --- linux-3.1.1/include/asm-generic/tlb.h 2011-07-22 11:18:10.000000000 +0200
8061 +++ linux-3.1.1-vs2.3.2/include/asm-generic/tlb.h 2011-10-24 18:53:33.000000000 +0200
8063 #define _ASM_GENERIC__TLB_H
8065 #include <linux/swap.h>
8066 +#include <linux/vs_memory.h>
8067 #include <asm/pgalloc.h>
8068 #include <asm/tlbflush.h>
8070 diff -NurpP --minimal linux-3.1.1/include/linux/Kbuild linux-3.1.1-vs2.3.2/include/linux/Kbuild
8071 --- linux-3.1.1/include/linux/Kbuild 2011-10-24 18:45:31.000000000 +0200
8072 +++ linux-3.1.1-vs2.3.2/include/linux/Kbuild 2011-10-24 18:53:33.000000000 +0200
8073 @@ -17,6 +17,7 @@ header-y += netfilter_bridge/
8074 header-y += netfilter_ipv4/
8075 header-y += netfilter_ipv6/
8077 +header-y += vserver/
8080 objhdr-y += version.h
8081 diff -NurpP --minimal linux-3.1.1/include/linux/capability.h linux-3.1.1-vs2.3.2/include/linux/capability.h
8082 --- linux-3.1.1/include/linux/capability.h 2011-07-22 11:18:10.000000000 +0200
8083 +++ linux-3.1.1-vs2.3.2/include/linux/capability.h 2011-10-24 18:53:33.000000000 +0200
8084 @@ -279,6 +279,7 @@ struct cpu_vfs_cap_data {
8085 arbitrary SCSI commands */
8086 /* Allow setting encryption key on loopback filesystem */
8087 /* Allow setting zone reclaim policy */
8088 +/* Allow the selection of a security context */
8090 #define CAP_SYS_ADMIN 21
8092 @@ -362,7 +363,12 @@ struct cpu_vfs_cap_data {
8094 #define CAP_LAST_CAP CAP_WAKE_ALARM
8096 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8097 +/* Allow context manipulations */
8098 +/* Allow changing context info on files */
8100 +#define CAP_CONTEXT 63
8102 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
8105 * Bit location of each capability (used by user-space library and kernel)
8106 diff -NurpP --minimal linux-3.1.1/include/linux/cred.h linux-3.1.1-vs2.3.2/include/linux/cred.h
8107 --- linux-3.1.1/include/linux/cred.h 2011-10-24 18:45:31.000000000 +0200
8108 +++ linux-3.1.1-vs2.3.2/include/linux/cred.h 2011-10-24 18:53:33.000000000 +0200
8109 @@ -156,6 +156,7 @@ extern void exit_creds(struct task_struc
8110 extern int copy_creds(struct task_struct *, unsigned long);
8111 extern const struct cred *get_task_cred(struct task_struct *);
8112 extern struct cred *cred_alloc_blank(void);
8113 +extern struct cred *__prepare_creds(const struct cred *);
8114 extern struct cred *prepare_creds(void);
8115 extern struct cred *prepare_exec_creds(void);
8116 extern int commit_creds(struct cred *);
8117 @@ -209,6 +210,31 @@ static inline void validate_process_cred
8121 +static inline void set_cred_subscribers(struct cred *cred, int n)
8123 +#ifdef CONFIG_DEBUG_CREDENTIALS
8124 + atomic_set(&cred->subscribers, n);
8128 +static inline int read_cred_subscribers(const struct cred *cred)
8130 +#ifdef CONFIG_DEBUG_CREDENTIALS
8131 + return atomic_read(&cred->subscribers);
8137 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
8139 +#ifdef CONFIG_DEBUG_CREDENTIALS
8140 + struct cred *cred = (struct cred *) _cred;
8142 + atomic_add(n, &cred->subscribers);
8147 * get_new_cred - Get a reference on a new set of credentials
8148 * @cred: The new credentials to reference
8149 diff -NurpP --minimal linux-3.1.1/include/linux/devpts_fs.h linux-3.1.1-vs2.3.2/include/linux/devpts_fs.h
8150 --- linux-3.1.1/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8151 +++ linux-3.1.1-vs2.3.2/include/linux/devpts_fs.h 2011-10-24 18:53:33.000000000 +0200
8152 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8157 #endif /* _LINUX_DEVPTS_FS_H */
8158 diff -NurpP --minimal linux-3.1.1/include/linux/ext2_fs.h linux-3.1.1-vs2.3.2/include/linux/ext2_fs.h
8159 --- linux-3.1.1/include/linux/ext2_fs.h 2011-11-15 16:44:52.000000000 +0100
8160 +++ linux-3.1.1-vs2.3.2/include/linux/ext2_fs.h 2011-11-15 17:08:44.000000000 +0100
8161 @@ -190,8 +190,12 @@ struct ext2_group_desc
8162 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8163 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8164 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8165 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8166 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8168 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8169 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8171 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8172 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8174 @@ -275,7 +279,8 @@ struct ext2_inode {
8176 __le16 l_i_uid_high; /* these 2 fields */
8177 __le16 l_i_gid_high; /* were reserved2[0] */
8178 - __u32 l_i_reserved2;
8179 + __le16 l_i_tag; /* Context Tag */
8180 + __u16 l_i_reserved2;
8183 __u8 h_i_frag; /* Fragment number */
8184 @@ -304,6 +309,7 @@ struct ext2_inode {
8185 #define i_gid_low i_gid
8186 #define i_uid_high osd2.linux2.l_i_uid_high
8187 #define i_gid_high osd2.linux2.l_i_gid_high
8188 +#define i_raw_tag osd2.linux2.l_i_tag
8189 #define i_reserved2 osd2.linux2.l_i_reserved2
8192 @@ -348,6 +354,7 @@ struct ext2_inode {
8193 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8194 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8195 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8196 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8199 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8200 diff -NurpP --minimal linux-3.1.1/include/linux/ext3_fs.h linux-3.1.1-vs2.3.2/include/linux/ext3_fs.h
8201 --- linux-3.1.1/include/linux/ext3_fs.h 2011-11-15 16:44:52.000000000 +0100
8202 +++ linux-3.1.1-vs2.3.2/include/linux/ext3_fs.h 2011-11-15 17:08:44.000000000 +0100
8203 @@ -173,10 +173,14 @@ struct ext3_group_desc
8204 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8205 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8206 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8207 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8208 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8210 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8211 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8212 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8213 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8215 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8216 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8218 /* Flags that should be inherited by new inodes from their parent. */
8219 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8220 @@ -312,7 +316,8 @@ struct ext3_inode {
8222 __le16 l_i_uid_high; /* these 2 fields */
8223 __le16 l_i_gid_high; /* were reserved2[0] */
8224 - __u32 l_i_reserved2;
8225 + __le16 l_i_tag; /* Context Tag */
8226 + __u16 l_i_reserved2;
8229 __u8 h_i_frag; /* Fragment number */
8230 @@ -343,6 +348,7 @@ struct ext3_inode {
8231 #define i_gid_low i_gid
8232 #define i_uid_high osd2.linux2.l_i_uid_high
8233 #define i_gid_high osd2.linux2.l_i_gid_high
8234 +#define i_raw_tag osd2.linux2.l_i_tag
8235 #define i_reserved2 osd2.linux2.l_i_reserved2
8237 #elif defined(__GNU__)
8238 @@ -405,6 +411,7 @@ struct ext3_inode {
8239 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8240 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8241 * error in ordered mode */
8242 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8244 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8245 #ifndef _LINUX_EXT2_FS_H
8246 @@ -918,6 +925,7 @@ extern void ext3_get_inode_flags(struct
8247 extern void ext3_set_aops(struct inode *inode);
8248 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8249 u64 start, u64 len);
8250 +extern int ext3_sync_flags(struct inode *, int, int);
8253 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8254 diff -NurpP --minimal linux-3.1.1/include/linux/fs.h linux-3.1.1-vs2.3.2/include/linux/fs.h
8255 --- linux-3.1.1/include/linux/fs.h 2011-10-24 18:45:32.000000000 +0200
8256 +++ linux-3.1.1-vs2.3.2/include/linux/fs.h 2011-10-24 18:53:33.000000000 +0200
8257 @@ -209,6 +209,9 @@ struct inodes_stat_t {
8258 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8259 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8260 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8261 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8262 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8263 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8264 #define MS_NOSEC (1<<28)
8265 #define MS_BORN (1<<29)
8266 #define MS_ACTIVE (1<<30)
8267 @@ -240,6 +243,14 @@ struct inodes_stat_t {
8268 #define S_IMA 1024 /* Inode has an associated IMA struct */
8269 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
8270 #define S_NOSEC 4096 /* no suid or xattr security attributes */
8271 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
8273 +/* Linux-VServer related Inode flags */
8277 +#define V_BARRIER 4 /* Barrier for chroot() */
8278 +#define V_COW 8 /* Copy on Write */
8281 * Note that nosuid etc flags are inode-specific: setting some file-system
8282 @@ -262,12 +273,15 @@ struct inodes_stat_t {
8283 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8284 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8285 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8286 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8287 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8288 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8289 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8290 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8292 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8293 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8294 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8295 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8296 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8297 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8299 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8300 @@ -278,6 +292,16 @@ struct inodes_stat_t {
8301 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
8302 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
8304 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8306 +#ifdef CONFIG_VSERVER_COWBL
8307 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8308 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8310 +# define IS_COW(inode) (0)
8311 +# define IS_COW_LINK(inode) (0)
8314 /* the read-only stuff doesn't really belong here, but any other place is
8315 probably as bad and I don't want to create yet another include file. */
8317 @@ -363,11 +387,14 @@ struct inodes_stat_t {
8318 #define FS_EXTENT_FL 0x00080000 /* Extents */
8319 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8320 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
8321 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8322 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8324 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8325 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8326 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8327 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8329 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8330 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8332 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8333 #define SYNC_FILE_RANGE_WRITE 2
8334 @@ -448,6 +475,7 @@ typedef void (dio_iodone_t)(struct kiocb
8335 #define ATTR_KILL_PRIV (1 << 14)
8336 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8337 #define ATTR_TIMES_SET (1 << 16)
8338 +#define ATTR_TAG (1 << 17)
8341 * This is the Inode Attributes structure, used for notify_change(). It
8342 @@ -463,6 +491,7 @@ struct iattr {
8348 struct timespec ia_atime;
8349 struct timespec ia_mtime;
8350 @@ -476,6 +505,9 @@ struct iattr {
8351 struct file *ia_file;
8354 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8355 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8358 * Includes for diskquotas.
8360 @@ -750,7 +782,9 @@ struct inode {
8361 unsigned short i_opflags;
8364 - unsigned int i_flags;
8366 + unsigned short i_flags;
8367 + unsigned short i_vflags;
8369 #ifdef CONFIG_FS_POSIX_ACL
8370 struct posix_acl *i_acl;
8371 @@ -769,6 +803,7 @@ struct inode {
8372 unsigned long i_ino;
8373 unsigned int i_nlink;
8377 struct timespec i_atime;
8378 struct timespec i_mtime;
8379 @@ -906,12 +941,12 @@ static inline void i_size_write(struct i
8381 static inline unsigned iminor(const struct inode *inode)
8383 - return MINOR(inode->i_rdev);
8384 + return MINOR(inode->i_mdev);
8387 static inline unsigned imajor(const struct inode *inode)
8389 - return MAJOR(inode->i_rdev);
8390 + return MAJOR(inode->i_mdev);
8393 extern struct block_device *I_BDEV(struct inode *inode);
8394 @@ -973,6 +1008,7 @@ struct file {
8396 struct fown_struct f_owner;
8397 const struct cred *f_cred;
8399 struct file_ra_state f_ra;
8402 @@ -1117,6 +1153,7 @@ struct file_lock {
8403 struct file *fl_file;
8408 struct fasync_struct * fl_fasync; /* for lease break notifications */
8409 unsigned long fl_break_time; /* for nonblocking lease breaks */
8410 @@ -1615,6 +1652,7 @@ struct inode_operations {
8411 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8412 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8413 int (*removexattr) (struct dentry *, const char *);
8414 + int (*sync_flags) (struct inode *, int, int);
8415 void (*truncate_range)(struct inode *, loff_t, loff_t);
8416 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8418 @@ -1633,6 +1671,7 @@ extern ssize_t vfs_readv(struct file *,
8419 unsigned long, loff_t *);
8420 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8421 unsigned long, loff_t *);
8422 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8424 struct super_operations {
8425 struct inode *(*alloc_inode)(struct super_block *sb);
8426 @@ -2505,6 +2544,7 @@ extern int dcache_dir_open(struct inode
8427 extern int dcache_dir_close(struct inode *, struct file *);
8428 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8429 extern int dcache_readdir(struct file *, void *, filldir_t);
8430 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8431 extern int simple_setattr(struct dentry *, struct iattr *);
8432 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8433 extern int simple_statfs(struct dentry *, struct kstatfs *);
8434 diff -NurpP --minimal linux-3.1.1/include/linux/gfs2_ondisk.h linux-3.1.1-vs2.3.2/include/linux/gfs2_ondisk.h
8435 --- linux-3.1.1/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8436 +++ linux-3.1.1-vs2.3.2/include/linux/gfs2_ondisk.h 2011-10-24 18:53:33.000000000 +0200
8437 @@ -211,6 +211,9 @@ enum {
8441 + gfs2fl_IXUnlink = 16,
8442 + gfs2fl_Barrier = 17,
8444 gfs2fl_TruncInProg = 29,
8445 gfs2fl_InheritDirectio = 30,
8446 gfs2fl_InheritJdata = 31,
8447 @@ -227,6 +230,9 @@ enum {
8448 #define GFS2_DIF_NOATIME 0x00000080
8449 #define GFS2_DIF_SYNC 0x00000100
8450 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8451 +#define GFS2_DIF_IXUNLINK 0x00010000
8452 +#define GFS2_DIF_BARRIER 0x00020000
8453 +#define GFS2_DIF_COW 0x00040000
8454 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8455 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8456 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8457 diff -NurpP --minimal linux-3.1.1/include/linux/if_tun.h linux-3.1.1-vs2.3.2/include/linux/if_tun.h
8458 --- linux-3.1.1/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8459 +++ linux-3.1.1-vs2.3.2/include/linux/if_tun.h 2011-10-24 18:53:33.000000000 +0200
8461 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8462 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8463 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8464 +#define TUNSETNID _IOW('T', 217, int)
8466 /* TUNSETIFF ifr flags */
8467 #define IFF_TUN 0x0001
8468 diff -NurpP --minimal linux-3.1.1/include/linux/init_task.h linux-3.1.1-vs2.3.2/include/linux/init_task.h
8469 --- linux-3.1.1/include/linux/init_task.h 2011-10-24 18:45:32.000000000 +0200
8470 +++ linux-3.1.1-vs2.3.2/include/linux/init_task.h 2011-10-24 18:53:33.000000000 +0200
8471 @@ -192,6 +192,10 @@ extern struct cred init_cred;
8473 INIT_TRACE_RECURSION \
8474 INIT_TASK_RCU_PREEMPT(tsk) \
8476 + .vx_info = NULL, \
8478 + .nx_info = NULL, \
8482 diff -NurpP --minimal linux-3.1.1/include/linux/ipc.h linux-3.1.1-vs2.3.2/include/linux/ipc.h
8483 --- linux-3.1.1/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8484 +++ linux-3.1.1-vs2.3.2/include/linux/ipc.h 2011-10-24 18:53:33.000000000 +0200
8485 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8493 diff -NurpP --minimal linux-3.1.1/include/linux/ipc_namespace.h linux-3.1.1-vs2.3.2/include/linux/ipc_namespace.h
8494 --- linux-3.1.1/include/linux/ipc_namespace.h 2011-10-24 18:45:32.000000000 +0200
8495 +++ linux-3.1.1-vs2.3.2/include/linux/ipc_namespace.h 2011-10-24 18:53:33.000000000 +0200
8496 @@ -101,7 +101,8 @@ static inline int mq_init_ns(struct ipc_
8498 #if defined(CONFIG_IPC_NS)
8499 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
8500 - struct task_struct *tsk);
8501 + struct ipc_namespace *old_ns,
8502 + struct user_namespace *user_ns);
8503 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8506 @@ -112,12 +113,13 @@ static inline struct ipc_namespace *get_
8507 extern void put_ipc_ns(struct ipc_namespace *ns);
8509 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
8510 - struct task_struct *tsk)
8511 + struct ipc_namespace *old_ns,
8512 + struct user_namespace *user_ns)
8514 if (flags & CLONE_NEWIPC)
8515 return ERR_PTR(-EINVAL);
8517 - return tsk->nsproxy->ipc_ns;
8521 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8522 diff -NurpP --minimal linux-3.1.1/include/linux/loop.h linux-3.1.1-vs2.3.2/include/linux/loop.h
8523 --- linux-3.1.1/include/linux/loop.h 2011-10-24 18:45:32.000000000 +0200
8524 +++ linux-3.1.1-vs2.3.2/include/linux/loop.h 2011-10-24 18:53:33.000000000 +0200
8525 @@ -45,6 +45,7 @@ struct loop_device {
8526 struct loop_func_table *lo_encryption;
8528 uid_t lo_key_owner; /* Who set the key */
8530 int (*ioctl)(struct loop_device *, int cmd,
8533 diff -NurpP --minimal linux-3.1.1/include/linux/magic.h linux-3.1.1-vs2.3.2/include/linux/magic.h
8534 --- linux-3.1.1/include/linux/magic.h 2011-05-22 16:17:55.000000000 +0200
8535 +++ linux-3.1.1-vs2.3.2/include/linux/magic.h 2011-10-24 18:53:33.000000000 +0200
8538 #define ADFS_SUPER_MAGIC 0xadf5
8539 #define AFFS_SUPER_MAGIC 0xadff
8540 -#define AFS_SUPER_MAGIC 0x5346414F
8541 +#define AFS_SUPER_MAGIC 0x5346414F
8542 #define AUTOFS_SUPER_MAGIC 0x0187
8543 #define CODA_SUPER_MAGIC 0x73757245
8544 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8546 #define NFS_SUPER_MAGIC 0x6969
8547 #define OPENPROM_SUPER_MAGIC 0x9fa1
8548 #define PROC_SUPER_MAGIC 0x9fa0
8549 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8550 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8552 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8553 diff -NurpP --minimal linux-3.1.1/include/linux/major.h linux-3.1.1-vs2.3.2/include/linux/major.h
8554 --- linux-3.1.1/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8555 +++ linux-3.1.1-vs2.3.2/include/linux/major.h 2011-10-24 18:53:33.000000000 +0200
8557 #define HD_MAJOR IDE0_MAJOR
8558 #define PTY_SLAVE_MAJOR 3
8560 +#define VROOT_MAJOR 4
8561 #define TTYAUX_MAJOR 5
8564 diff -NurpP --minimal linux-3.1.1/include/linux/memcontrol.h linux-3.1.1-vs2.3.2/include/linux/memcontrol.h
8565 --- linux-3.1.1/include/linux/memcontrol.h 2011-10-24 18:45:32.000000000 +0200
8566 +++ linux-3.1.1-vs2.3.2/include/linux/memcontrol.h 2011-10-24 18:53:33.000000000 +0200
8567 @@ -84,6 +84,13 @@ extern struct mem_cgroup *try_get_mem_cg
8568 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8569 extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
8571 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8572 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8574 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8575 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8576 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8579 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8581 diff -NurpP --minimal linux-3.1.1/include/linux/mm_types.h linux-3.1.1-vs2.3.2/include/linux/mm_types.h
8582 --- linux-3.1.1/include/linux/mm_types.h 2011-11-15 16:44:52.000000000 +0100
8583 +++ linux-3.1.1-vs2.3.2/include/linux/mm_types.h 2011-11-15 17:08:44.000000000 +0100
8584 @@ -314,6 +314,7 @@ struct mm_struct {
8586 /* Architecture-specific MM context */
8587 mm_context_t context;
8588 + struct vx_info *mm_vx_info;
8590 /* Swap token stuff */
8592 diff -NurpP --minimal linux-3.1.1/include/linux/mmzone.h linux-3.1.1-vs2.3.2/include/linux/mmzone.h
8593 --- linux-3.1.1/include/linux/mmzone.h 2011-10-24 18:45:32.000000000 +0200
8594 +++ linux-3.1.1-vs2.3.2/include/linux/mmzone.h 2011-10-24 18:53:33.000000000 +0200
8595 @@ -660,6 +660,13 @@ typedef struct pglist_data {
8596 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8599 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
8601 +#define node_end_pfn(nid) ({\
8602 + pg_data_t *__pgdat = NODE_DATA(nid);\
8603 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8606 #include <linux/memory_hotplug.h>
8608 extern struct mutex zonelists_mutex;
8609 diff -NurpP --minimal linux-3.1.1/include/linux/mount.h linux-3.1.1-vs2.3.2/include/linux/mount.h
8610 --- linux-3.1.1/include/linux/mount.h 2011-10-24 18:45:32.000000000 +0200
8611 +++ linux-3.1.1-vs2.3.2/include/linux/mount.h 2011-10-24 18:53:33.000000000 +0200
8612 @@ -52,6 +52,9 @@ struct mnt_pcp {
8616 +#define MNT_TAGID 0x10000
8617 +#define MNT_NOTAG 0x20000
8620 struct list_head mnt_hash;
8621 struct vfsmount *mnt_parent; /* fs we are mounted on */
8622 @@ -86,6 +89,7 @@ struct vfsmount {
8623 int mnt_expiry_mark; /* true if marked for expiry */
8626 + tag_t mnt_tag; /* tagging used for vfsmount */
8629 struct file; /* forward dec */
8630 diff -NurpP --minimal linux-3.1.1/include/linux/net.h linux-3.1.1-vs2.3.2/include/linux/net.h
8631 --- linux-3.1.1/include/linux/net.h 2011-07-22 11:18:11.000000000 +0200
8632 +++ linux-3.1.1-vs2.3.2/include/linux/net.h 2011-10-24 18:53:33.000000000 +0200
8633 @@ -72,6 +72,7 @@ struct net;
8634 #define SOCK_NOSPACE 2
8635 #define SOCK_PASSCRED 3
8636 #define SOCK_PASSSEC 4
8637 +#define SOCK_USER_SOCKET 5
8639 #ifndef ARCH_HAS_SOCKET_TYPES
8641 diff -NurpP --minimal linux-3.1.1/include/linux/netdevice.h linux-3.1.1-vs2.3.2/include/linux/netdevice.h
8642 --- linux-3.1.1/include/linux/netdevice.h 2011-10-24 18:45:32.000000000 +0200
8643 +++ linux-3.1.1-vs2.3.2/include/linux/netdevice.h 2011-10-24 18:53:33.000000000 +0200
8644 @@ -1641,6 +1641,7 @@ extern void netdev_resync_ops(struct ne
8646 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
8647 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
8648 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
8649 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
8650 extern int dev_restart(struct net_device *dev);
8651 #ifdef CONFIG_NETPOLL_TRAP
8652 diff -NurpP --minimal linux-3.1.1/include/linux/nfs_mount.h linux-3.1.1-vs2.3.2/include/linux/nfs_mount.h
8653 --- linux-3.1.1/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
8654 +++ linux-3.1.1-vs2.3.2/include/linux/nfs_mount.h 2011-10-24 18:53:33.000000000 +0200
8655 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8656 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8657 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8658 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8659 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8660 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8661 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8663 /* The following are for internal use only */
8664 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8665 diff -NurpP --minimal linux-3.1.1/include/linux/nsproxy.h linux-3.1.1-vs2.3.2/include/linux/nsproxy.h
8666 --- linux-3.1.1/include/linux/nsproxy.h 2011-10-24 18:45:32.000000000 +0200
8667 +++ linux-3.1.1-vs2.3.2/include/linux/nsproxy.h 2011-10-24 18:53:33.000000000 +0200
8670 #include <linux/spinlock.h>
8671 #include <linux/sched.h>
8672 +#include <linux/vserver/debug.h>
8674 struct mnt_namespace;
8675 struct uts_namespace;
8676 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
8679 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8680 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8681 void exit_task_namespaces(struct task_struct *tsk);
8682 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8683 void free_nsproxy(struct nsproxy *ns);
8684 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
8685 struct fs_struct *);
8686 int __init nsproxy_cache_init(void);
8688 -static inline void put_nsproxy(struct nsproxy *ns)
8689 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8691 +static inline void __get_nsproxy(struct nsproxy *ns,
8692 + const char *_file, int _line)
8694 - if (atomic_dec_and_test(&ns->count)) {
8697 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8698 + ns, atomic_read(&ns->count), _file, _line);
8699 + atomic_inc(&ns->count);
8702 -static inline void get_nsproxy(struct nsproxy *ns)
8703 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8705 +static inline void __put_nsproxy(struct nsproxy *ns,
8706 + const char *_file, int _line)
8708 - atomic_inc(&ns->count);
8709 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8710 + ns, atomic_read(&ns->count), _file, _line);
8711 + if (atomic_dec_and_test(&ns->count)) {
8717 diff -NurpP --minimal linux-3.1.1/include/linux/pid.h linux-3.1.1-vs2.3.2/include/linux/pid.h
8718 --- linux-3.1.1/include/linux/pid.h 2011-07-22 11:18:11.000000000 +0200
8719 +++ linux-3.1.1-vs2.3.2/include/linux/pid.h 2011-10-24 18:53:33.000000000 +0200
8720 @@ -8,7 +8,8 @@ enum pid_type
8730 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
8733 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8734 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8735 pid_t pid_vnr(struct pid *pid);
8737 #define do_each_pid_task(pid, type, task) \
8738 diff -NurpP --minimal linux-3.1.1/include/linux/proc_fs.h linux-3.1.1-vs2.3.2/include/linux/proc_fs.h
8739 --- linux-3.1.1/include/linux/proc_fs.h 2011-10-24 18:45:32.000000000 +0200
8740 +++ linux-3.1.1-vs2.3.2/include/linux/proc_fs.h 2011-10-24 18:53:33.000000000 +0200
8741 @@ -54,6 +54,7 @@ struct proc_dir_entry {
8747 const struct inode_operations *proc_iops;
8749 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
8750 extern const struct proc_ns_operations utsns_operations;
8751 extern const struct proc_ns_operations ipcns_operations;
8757 int (*proc_get_link)(struct inode *, struct path *);
8758 int (*proc_read)(struct task_struct *task, char *page);
8759 int (*proc_show)(struct seq_file *m,
8760 struct pid_namespace *ns, struct pid *pid,
8761 struct task_struct *task);
8762 + int (*proc_vs_read)(char *page);
8763 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8764 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8767 struct ctl_table_header;
8768 @@ -265,6 +272,7 @@ struct ctl_table;
8775 struct proc_dir_entry *pde;
8776 diff -NurpP --minimal linux-3.1.1/include/linux/quotaops.h linux-3.1.1-vs2.3.2/include/linux/quotaops.h
8777 --- linux-3.1.1/include/linux/quotaops.h 2011-05-22 16:17:57.000000000 +0200
8778 +++ linux-3.1.1-vs2.3.2/include/linux/quotaops.h 2011-10-24 18:53:33.000000000 +0200
8780 #define _LINUX_QUOTAOPS_
8782 #include <linux/fs.h>
8783 +#include <linux/vs_dlimit.h>
8785 #define DQUOT_SPACE_WARN 0x1
8786 #define DQUOT_SPACE_RESERVE 0x2
8787 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
8789 static inline int dquot_alloc_inode(const struct inode *inode)
8792 + return dl_alloc_inode(inode);
8795 static inline void dquot_free_inode(const struct inode *inode)
8797 + dl_free_inode(inode);
8800 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
8801 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct
8802 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
8807 + if ((ret = dl_alloc_space(inode, number)))
8809 if (!(flags & DQUOT_SPACE_RESERVE))
8810 inode_add_bytes(inode, number);
8812 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
8814 if (!(flags & DQUOT_SPACE_RESERVE))
8815 inode_sub_bytes(inode, number);
8816 + dl_free_space(inode, number);
8819 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
8820 diff -NurpP --minimal linux-3.1.1/include/linux/reboot.h linux-3.1.1-vs2.3.2/include/linux/reboot.h
8821 --- linux-3.1.1/include/linux/reboot.h 2011-10-24 18:45:32.000000000 +0200
8822 +++ linux-3.1.1-vs2.3.2/include/linux/reboot.h 2011-10-24 18:53:33.000000000 +0200
8824 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
8825 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
8826 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
8827 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
8831 diff -NurpP --minimal linux-3.1.1/include/linux/reiserfs_fs.h linux-3.1.1-vs2.3.2/include/linux/reiserfs_fs.h
8832 --- linux-3.1.1/include/linux/reiserfs_fs.h 2011-10-24 18:45:32.000000000 +0200
8833 +++ linux-3.1.1-vs2.3.2/include/linux/reiserfs_fs.h 2011-10-24 18:53:33.000000000 +0200
8834 @@ -976,6 +976,11 @@ struct stat_data_v1 {
8835 #define REISERFS_COMPR_FL FS_COMPR_FL
8836 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
8838 +/* unfortunately reiserfs sdattr is only 16 bit */
8839 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
8840 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
8841 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
8843 /* persistent flags that file inherits from the parent directory */
8844 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
8845 REISERFS_SYNC_FL | \
8846 @@ -985,6 +990,9 @@ struct stat_data_v1 {
8847 REISERFS_COMPR_FL | \
8848 REISERFS_NOTAIL_FL )
8850 +#define REISERFS_FL_USER_VISIBLE 0x80FF
8851 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
8853 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
8856 @@ -2073,6 +2081,7 @@ static inline void reiserfs_update_sd(st
8857 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
8858 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
8859 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
8860 +int reiserfs_sync_flags(struct inode *inode, int, int);
8862 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
8864 diff -NurpP --minimal linux-3.1.1/include/linux/reiserfs_fs_sb.h linux-3.1.1-vs2.3.2/include/linux/reiserfs_fs_sb.h
8865 --- linux-3.1.1/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
8866 +++ linux-3.1.1-vs2.3.2/include/linux/reiserfs_fs_sb.h 2011-10-24 18:53:33.000000000 +0200
8867 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
8868 REISERFS_EXPOSE_PRIVROOT,
8869 REISERFS_BARRIER_NONE,
8870 REISERFS_BARRIER_FLUSH,
8873 /* Actions on error */
8874 REISERFS_ERROR_PANIC,
8875 diff -NurpP --minimal linux-3.1.1/include/linux/sched.h linux-3.1.1-vs2.3.2/include/linux/sched.h
8876 --- linux-3.1.1/include/linux/sched.h 2011-10-24 18:45:32.000000000 +0200
8877 +++ linux-3.1.1-vs2.3.2/include/linux/sched.h 2011-10-24 18:53:33.000000000 +0200
8878 @@ -1406,6 +1406,14 @@ struct task_struct {
8882 +/* vserver context data */
8883 + struct vx_info *vx_info;
8884 + struct nx_info *nx_info;
8890 /* Thread group tracking */
8893 @@ -1648,6 +1656,11 @@ struct pid_namespace;
8894 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
8895 struct pid_namespace *ns);
8897 +#include <linux/vserver/base.h>
8898 +#include <linux/vserver/context.h>
8899 +#include <linux/vserver/debug.h>
8900 +#include <linux/vserver/pid.h>
8902 static inline pid_t task_pid_nr(struct task_struct *tsk)
8905 @@ -1661,7 +1674,8 @@ static inline pid_t task_pid_nr_ns(struc
8907 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8909 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8910 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8911 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8915 @@ -1674,7 +1688,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8917 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8919 - return pid_vnr(task_tgid(tsk));
8920 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8924 diff -NurpP --minimal linux-3.1.1/include/linux/shmem_fs.h linux-3.1.1-vs2.3.2/include/linux/shmem_fs.h
8925 --- linux-3.1.1/include/linux/shmem_fs.h 2011-10-24 18:45:32.000000000 +0200
8926 +++ linux-3.1.1-vs2.3.2/include/linux/shmem_fs.h 2011-10-24 18:53:33.000000000 +0200
8929 /* inode in-kernel data */
8931 +#define TMPFS_SUPER_MAGIC 0x01021994
8934 struct shmem_inode_info {
8936 unsigned long flags;
8937 diff -NurpP --minimal linux-3.1.1/include/linux/stat.h linux-3.1.1-vs2.3.2/include/linux/stat.h
8938 --- linux-3.1.1/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
8939 +++ linux-3.1.1-vs2.3.2/include/linux/stat.h 2011-10-24 18:53:33.000000000 +0200
8940 @@ -66,6 +66,7 @@ struct kstat {
8947 struct timespec atime;
8948 diff -NurpP --minimal linux-3.1.1/include/linux/sunrpc/auth.h linux-3.1.1-vs2.3.2/include/linux/sunrpc/auth.h
8949 --- linux-3.1.1/include/linux/sunrpc/auth.h 2011-10-24 18:45:32.000000000 +0200
8950 +++ linux-3.1.1-vs2.3.2/include/linux/sunrpc/auth.h 2011-10-24 18:53:33.000000000 +0200
8956 struct group_info *group_info;
8957 unsigned char machine_cred : 1;
8959 diff -NurpP --minimal linux-3.1.1/include/linux/sunrpc/clnt.h linux-3.1.1-vs2.3.2/include/linux/sunrpc/clnt.h
8960 --- linux-3.1.1/include/linux/sunrpc/clnt.h 2011-05-22 16:17:58.000000000 +0200
8961 +++ linux-3.1.1-vs2.3.2/include/linux/sunrpc/clnt.h 2011-10-24 18:53:33.000000000 +0200
8962 @@ -49,7 +49,8 @@ struct rpc_clnt {
8963 unsigned int cl_softrtry : 1,/* soft timeouts */
8964 cl_discrtry : 1,/* disconnect before retry */
8965 cl_autobind : 1,/* use getport() */
8966 - cl_chatty : 1;/* be verbose */
8967 + cl_chatty : 1,/* be verbose */
8968 + cl_tag : 1;/* context tagging */
8970 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8971 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8972 diff -NurpP --minimal linux-3.1.1/include/linux/syscalls.h linux-3.1.1-vs2.3.2/include/linux/syscalls.h
8973 --- linux-3.1.1/include/linux/syscalls.h 2011-10-24 18:45:32.000000000 +0200
8974 +++ linux-3.1.1-vs2.3.2/include/linux/syscalls.h 2011-10-24 18:53:33.000000000 +0200
8975 @@ -483,6 +483,8 @@ asmlinkage long sys_symlink(const char _
8976 asmlinkage long sys_unlink(const char __user *pathname);
8977 asmlinkage long sys_rename(const char __user *oldname,
8978 const char __user *newname);
8979 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
8981 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
8982 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
8984 diff -NurpP --minimal linux-3.1.1/include/linux/sysctl.h linux-3.1.1-vs2.3.2/include/linux/sysctl.h
8985 --- linux-3.1.1/include/linux/sysctl.h 2011-03-15 18:07:40.000000000 +0100
8986 +++ linux-3.1.1-vs2.3.2/include/linux/sysctl.h 2011-10-24 18:53:33.000000000 +0200
8987 @@ -60,6 +60,7 @@ enum
8988 CTL_ABI=9, /* Binary emulation */
8989 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
8990 CTL_ARLAN=254, /* arlan wireless driver */
8991 + CTL_VSERVER=4242, /* Linux-VServer debug */
8992 CTL_S390DBF=5677, /* s390 debug */
8993 CTL_SUNRPC=7249, /* sunrpc debug */
8994 CTL_PM=9899, /* frv power management */
8995 @@ -94,6 +95,7 @@ enum
8997 KERN_PANIC=15, /* int: panic timeout */
8998 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
8999 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
9001 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
9002 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
9003 diff -NurpP --minimal linux-3.1.1/include/linux/sysfs.h linux-3.1.1-vs2.3.2/include/linux/sysfs.h
9004 --- linux-3.1.1/include/linux/sysfs.h 2011-10-24 18:45:32.000000000 +0200
9005 +++ linux-3.1.1-vs2.3.2/include/linux/sysfs.h 2011-10-24 18:53:33.000000000 +0200
9007 #include <linux/kobject_ns.h>
9008 #include <linux/atomic.h>
9010 +#define SYSFS_SUPER_MAGIC 0x62656572
9015 diff -NurpP --minimal linux-3.1.1/include/linux/time.h linux-3.1.1-vs2.3.2/include/linux/time.h
9016 --- linux-3.1.1/include/linux/time.h 2011-07-22 11:18:11.000000000 +0200
9017 +++ linux-3.1.1-vs2.3.2/include/linux/time.h 2011-10-24 18:53:33.000000000 +0200
9018 @@ -256,6 +256,9 @@ static __always_inline void timespec_add
9019 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
9023 +#include <linux/vs_time.h>
9025 #endif /* __KERNEL__ */
9027 #define NFDBITS __NFDBITS
9028 diff -NurpP --minimal linux-3.1.1/include/linux/types.h linux-3.1.1-vs2.3.2/include/linux/types.h
9029 --- linux-3.1.1/include/linux/types.h 2011-05-22 16:17:58.000000000 +0200
9030 +++ linux-3.1.1-vs2.3.2/include/linux/types.h 2011-10-24 18:53:33.000000000 +0200
9031 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
9032 typedef __kernel_gid32_t gid_t;
9033 typedef __kernel_uid16_t uid16_t;
9034 typedef __kernel_gid16_t gid16_t;
9035 +typedef unsigned int xid_t;
9036 +typedef unsigned int nid_t;
9037 +typedef unsigned int tag_t;
9039 typedef unsigned long uintptr_t;
9041 diff -NurpP --minimal linux-3.1.1/include/linux/utsname.h linux-3.1.1-vs2.3.2/include/linux/utsname.h
9042 --- linux-3.1.1/include/linux/utsname.h 2011-05-22 16:17:58.000000000 +0200
9043 +++ linux-3.1.1-vs2.3.2/include/linux/utsname.h 2011-10-24 18:53:33.000000000 +0200
9044 @@ -54,7 +54,8 @@ static inline void get_uts_ns(struct uts
9047 extern struct uts_namespace *copy_utsname(unsigned long flags,
9048 - struct task_struct *tsk);
9049 + struct uts_namespace *old_ns,
9050 + struct user_namespace *user_ns);
9051 extern void free_uts_ns(struct kref *kref);
9053 static inline void put_uts_ns(struct uts_namespace *ns)
9054 @@ -71,12 +72,13 @@ static inline void put_uts_ns(struct uts
9057 static inline struct uts_namespace *copy_utsname(unsigned long flags,
9058 - struct task_struct *tsk)
9059 + struct uts_namespace *old_ns,
9060 + struct user_namespace *user_ns)
9062 if (flags & CLONE_NEWUTS)
9063 return ERR_PTR(-EINVAL);
9065 - return tsk->nsproxy->uts_ns;
9070 diff -NurpP --minimal linux-3.1.1/include/linux/vroot.h linux-3.1.1-vs2.3.2/include/linux/vroot.h
9071 --- linux-3.1.1/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
9072 +++ linux-3.1.1-vs2.3.2/include/linux/vroot.h 2011-10-24 18:53:33.000000000 +0200
9076 + * include/linux/vroot.h
9078 + * written by Herbert Pötzl, 9/11/2002
9079 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
9081 + * Copyright (C) 2002-2007 by Herbert Pötzl.
9082 + * Redistribution of this file is permitted under the
9083 + * GNU General Public License.
9086 +#ifndef _LINUX_VROOT_H
9087 +#define _LINUX_VROOT_H
9092 +/* Possible states of device */
9098 +struct vroot_device {
9102 + struct semaphore vr_ctl_mutex;
9103 + struct block_device *vr_device;
9108 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
9110 +extern int register_vroot_grb(vroot_grb_func *);
9111 +extern int unregister_vroot_grb(vroot_grb_func *);
9113 +#endif /* __KERNEL__ */
9115 +#define MAX_VROOT_DEFAULT 8
9118 + * IOCTL commands --- we will commandeer 0x56 ('V')
9121 +#define VROOT_SET_DEV 0x5600
9122 +#define VROOT_CLR_DEV 0x5601
9124 +#endif /* _LINUX_VROOT_H */
9125 diff -NurpP --minimal linux-3.1.1/include/linux/vs_base.h linux-3.1.1-vs2.3.2/include/linux/vs_base.h
9126 --- linux-3.1.1/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
9127 +++ linux-3.1.1-vs2.3.2/include/linux/vs_base.h 2011-10-24 18:53:33.000000000 +0200
9132 +#include "vserver/base.h"
9133 +#include "vserver/check.h"
9134 +#include "vserver/debug.h"
9137 +#warning duplicate inclusion
9139 diff -NurpP --minimal linux-3.1.1/include/linux/vs_context.h linux-3.1.1-vs2.3.2/include/linux/vs_context.h
9140 --- linux-3.1.1/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
9141 +++ linux-3.1.1-vs2.3.2/include/linux/vs_context.h 2011-10-24 18:53:33.000000000 +0200
9143 +#ifndef _VS_CONTEXT_H
9144 +#define _VS_CONTEXT_H
9146 +#include "vserver/base.h"
9147 +#include "vserver/check.h"
9148 +#include "vserver/context.h"
9149 +#include "vserver/history.h"
9150 +#include "vserver/debug.h"
9152 +#include <linux/sched.h>
9155 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9157 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9158 + const char *_file, int _line, void *_here)
9163 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9164 + vxi, vxi ? vxi->vx_id : 0,
9165 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9167 + __vxh_get_vx_info(vxi, _here);
9169 + atomic_inc(&vxi->vx_usecnt);
9174 +extern void free_vx_info(struct vx_info *);
9176 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9178 +static inline void __put_vx_info(struct vx_info *vxi,
9179 + const char *_file, int _line, void *_here)
9184 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9185 + vxi, vxi ? vxi->vx_id : 0,
9186 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9188 + __vxh_put_vx_info(vxi, _here);
9190 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9191 + free_vx_info(vxi);
9195 +#define init_vx_info(p, i) \
9196 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9198 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9199 + const char *_file, int _line, void *_here)
9202 + vxlprintk(VXD_CBIT(xid, 3),
9203 + "init_vx_info(%p[#%d.%d])",
9204 + vxi, vxi ? vxi->vx_id : 0,
9205 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9207 + __vxh_init_vx_info(vxi, vxp, _here);
9209 + atomic_inc(&vxi->vx_usecnt);
9215 +#define set_vx_info(p, i) \
9216 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9218 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9219 + const char *_file, int _line, void *_here)
9221 + struct vx_info *vxo;
9226 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9227 + vxi, vxi ? vxi->vx_id : 0,
9228 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9230 + __vxh_set_vx_info(vxi, vxp, _here);
9232 + atomic_inc(&vxi->vx_usecnt);
9233 + vxo = xchg(vxp, vxi);
9238 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9240 +static inline void __clr_vx_info(struct vx_info **vxp,
9241 + const char *_file, int _line, void *_here)
9243 + struct vx_info *vxo;
9245 + vxo = xchg(vxp, NULL);
9249 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9250 + vxo, vxo ? vxo->vx_id : 0,
9251 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9253 + __vxh_clr_vx_info(vxo, vxp, _here);
9255 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9256 + free_vx_info(vxo);
9260 +#define claim_vx_info(v, p) \
9261 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9263 +static inline void __claim_vx_info(struct vx_info *vxi,
9264 + struct task_struct *task,
9265 + const char *_file, int _line, void *_here)
9267 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9268 + vxi, vxi ? vxi->vx_id : 0,
9269 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9270 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9271 + task, _file, _line);
9272 + __vxh_claim_vx_info(vxi, task, _here);
9274 + atomic_inc(&vxi->vx_tasks);
9278 +extern void unhash_vx_info(struct vx_info *);
9280 +#define release_vx_info(v, p) \
9281 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9283 +static inline void __release_vx_info(struct vx_info *vxi,
9284 + struct task_struct *task,
9285 + const char *_file, int _line, void *_here)
9287 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9288 + vxi, vxi ? vxi->vx_id : 0,
9289 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9290 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9291 + task, _file, _line);
9292 + __vxh_release_vx_info(vxi, task, _here);
9296 + if (atomic_dec_and_test(&vxi->vx_tasks))
9297 + unhash_vx_info(vxi);
9301 +#define task_get_vx_info(p) \
9302 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9304 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9305 + const char *_file, int _line, void *_here)
9307 + struct vx_info *vxi;
9310 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9312 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9318 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9320 + if (waitqueue_active(&vxi->vx_wait))
9321 + wake_up_interruptible(&vxi->vx_wait);
9325 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9327 +static inline void __enter_vx_info(struct vx_info *vxi,
9328 + struct vx_info_save *vxis, const char *_file, int _line)
9330 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9331 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9332 + current->xid, current->vx_info, _file, _line);
9333 + vxis->vxi = xchg(¤t->vx_info, vxi);
9334 + vxis->xid = current->xid;
9335 + current->xid = vxi ? vxi->vx_id : 0;
9338 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9340 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9341 + const char *_file, int _line)
9343 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9344 + vxis, vxis->xid, vxis->vxi, current,
9345 + current->xid, current->vx_info, _file, _line);
9346 + (void)xchg(¤t->vx_info, vxis->vxi);
9347 + current->xid = vxis->xid;
9351 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9353 + vxis->vxi = xchg(¤t->vx_info, NULL);
9354 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9357 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9359 + (void)xchg(¤t->xid, vxis->xid);
9360 + (void)xchg(¤t->vx_info, vxis->vxi);
9363 +#define task_is_init(p) \
9364 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9366 +static inline int __task_is_init(struct task_struct *p,
9367 + const char *_file, int _line, void *_here)
9369 + int is_init = is_global_init(p);
9373 + is_init = p->vx_info->vx_initpid == p->pid;
9378 +extern void exit_vx_info(struct task_struct *, int);
9379 +extern void exit_vx_info_early(struct task_struct *, int);
9383 +#warning duplicate inclusion
9385 diff -NurpP --minimal linux-3.1.1/include/linux/vs_cowbl.h linux-3.1.1-vs2.3.2/include/linux/vs_cowbl.h
9386 --- linux-3.1.1/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9387 +++ linux-3.1.1-vs2.3.2/include/linux/vs_cowbl.h 2011-10-24 18:53:33.000000000 +0200
9389 +#ifndef _VS_COWBL_H
9390 +#define _VS_COWBL_H
9392 +#include <linux/fs.h>
9393 +#include <linux/dcache.h>
9394 +#include <linux/namei.h>
9395 +#include <linux/slab.h>
9397 +extern struct dentry *cow_break_link(const char *pathname);
9399 +static inline int cow_check_and_break(struct path *path)
9401 + struct inode *inode = path->dentry->d_inode;
9404 + /* do we need this check? */
9405 + if (IS_RDONLY(inode))
9408 + if (IS_COW(inode)) {
9409 + if (IS_COW_LINK(inode)) {
9410 + struct dentry *new_dentry, *old_dentry = path->dentry;
9413 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9417 + pp = d_path(path, buf, PATH_MAX);
9418 + new_dentry = cow_break_link(pp);
9420 + if (!IS_ERR(new_dentry)) {
9421 + path->dentry = new_dentry;
9424 + error = PTR_ERR(new_dentry);
9426 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9427 + inode->i_ctime = CURRENT_TIME;
9428 + mark_inode_dirty(inode);
9435 +#warning duplicate inclusion
9437 diff -NurpP --minimal linux-3.1.1/include/linux/vs_cvirt.h linux-3.1.1-vs2.3.2/include/linux/vs_cvirt.h
9438 --- linux-3.1.1/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9439 +++ linux-3.1.1-vs2.3.2/include/linux/vs_cvirt.h 2011-10-24 18:53:33.000000000 +0200
9441 +#ifndef _VS_CVIRT_H
9442 +#define _VS_CVIRT_H
9444 +#include "vserver/cvirt.h"
9445 +#include "vserver/context.h"
9446 +#include "vserver/base.h"
9447 +#include "vserver/check.h"
9448 +#include "vserver/debug.h"
9451 +static inline void vx_activate_task(struct task_struct *p)
9453 + struct vx_info *vxi;
9455 + if ((vxi = p->vx_info)) {
9456 + vx_update_load(vxi);
9457 + atomic_inc(&vxi->cvirt.nr_running);
9461 +static inline void vx_deactivate_task(struct task_struct *p)
9463 + struct vx_info *vxi;
9465 + if ((vxi = p->vx_info)) {
9466 + vx_update_load(vxi);
9467 + atomic_dec(&vxi->cvirt.nr_running);
9471 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9473 + struct vx_info *vxi;
9475 + if ((vxi = p->vx_info))
9476 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9479 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9481 + struct vx_info *vxi;
9483 + if ((vxi = p->vx_info))
9484 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9489 +#warning duplicate inclusion
9491 diff -NurpP --minimal linux-3.1.1/include/linux/vs_device.h linux-3.1.1-vs2.3.2/include/linux/vs_device.h
9492 --- linux-3.1.1/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9493 +++ linux-3.1.1-vs2.3.2/include/linux/vs_device.h 2011-10-24 18:53:33.000000000 +0200
9495 +#ifndef _VS_DEVICE_H
9496 +#define _VS_DEVICE_H
9498 +#include "vserver/base.h"
9499 +#include "vserver/device.h"
9500 +#include "vserver/debug.h"
9503 +#ifdef CONFIG_VSERVER_DEVICE
9505 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9507 +#define vs_device_perm(v, d, m, p) \
9508 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9513 +int vs_map_device(struct vx_info *vxi,
9514 + dev_t device, dev_t *target, umode_t mode)
9521 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9526 +#define vs_map_chrdev(d, t, p) \
9527 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9528 +#define vs_map_blkdev(d, t, p) \
9529 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9531 +#define vs_chrdev_perm(d, p) \
9532 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9533 +#define vs_blkdev_perm(d, p) \
9534 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9538 +#warning duplicate inclusion
9540 diff -NurpP --minimal linux-3.1.1/include/linux/vs_dlimit.h linux-3.1.1-vs2.3.2/include/linux/vs_dlimit.h
9541 --- linux-3.1.1/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9542 +++ linux-3.1.1-vs2.3.2/include/linux/vs_dlimit.h 2011-10-24 18:53:33.000000000 +0200
9544 +#ifndef _VS_DLIMIT_H
9545 +#define _VS_DLIMIT_H
9547 +#include <linux/fs.h>
9549 +#include "vserver/dlimit.h"
9550 +#include "vserver/base.h"
9551 +#include "vserver/debug.h"
9554 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9556 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9557 + const char *_file, int _line)
9561 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9562 + dli, dli ? dli->dl_tag : 0,
9563 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9565 + atomic_inc(&dli->dl_usecnt);
9570 +#define free_dl_info(i) \
9571 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9573 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9575 +static inline void __put_dl_info(struct dl_info *dli,
9576 + const char *_file, int _line)
9580 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9581 + dli, dli ? dli->dl_tag : 0,
9582 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9584 + if (atomic_dec_and_test(&dli->dl_usecnt))
9585 + free_dl_info(dli);
9589 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9591 +static inline int __dl_alloc_space(struct super_block *sb,
9592 + tag_t tag, dlsize_t nr, const char *file, int line)
9594 + struct dl_info *dli = NULL;
9599 + dli = locate_dl_info(sb, tag);
9603 + spin_lock(&dli->dl_lock);
9604 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9606 + dli->dl_space_used += nr;
9607 + spin_unlock(&dli->dl_lock);
9610 + vxlprintk(VXD_CBIT(dlim, 1),
9611 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9612 + sb, tag, __dlimit_char(dli), (long long)nr,
9614 + return ret ? -ENOSPC : 0;
9617 +static inline void __dl_free_space(struct super_block *sb,
9618 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9620 + struct dl_info *dli = NULL;
9624 + dli = locate_dl_info(sb, tag);
9628 + spin_lock(&dli->dl_lock);
9629 + if (dli->dl_space_used > nr)
9630 + dli->dl_space_used -= nr;
9632 + dli->dl_space_used = 0;
9633 + spin_unlock(&dli->dl_lock);
9636 + vxlprintk(VXD_CBIT(dlim, 1),
9637 + "FREE (%p,#%d)%c %lld bytes",
9638 + sb, tag, __dlimit_char(dli), (long long)nr,
9642 +static inline int __dl_alloc_inode(struct super_block *sb,
9643 + tag_t tag, const char *_file, int _line)
9645 + struct dl_info *dli;
9648 + dli = locate_dl_info(sb, tag);
9652 + spin_lock(&dli->dl_lock);
9653 + dli->dl_inodes_used++;
9654 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9655 + spin_unlock(&dli->dl_lock);
9658 + vxlprintk(VXD_CBIT(dlim, 0),
9659 + "ALLOC (%p,#%d)%c inode (%d)",
9660 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9661 + return ret ? -ENOSPC : 0;
9664 +static inline void __dl_free_inode(struct super_block *sb,
9665 + tag_t tag, const char *_file, int _line)
9667 + struct dl_info *dli;
9669 + dli = locate_dl_info(sb, tag);
9673 + spin_lock(&dli->dl_lock);
9674 + if (dli->dl_inodes_used > 1)
9675 + dli->dl_inodes_used--;
9677 + dli->dl_inodes_used = 0;
9678 + spin_unlock(&dli->dl_lock);
9681 + vxlprintk(VXD_CBIT(dlim, 0),
9682 + "FREE (%p,#%d)%c inode",
9683 + sb, tag, __dlimit_char(dli), _file, _line);
9686 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
9687 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9688 + const char *_file, int _line)
9690 + struct dl_info *dli;
9691 + uint64_t broot, bfree;
9693 + dli = locate_dl_info(sb, tag);
9697 + spin_lock(&dli->dl_lock);
9698 + broot = (dli->dl_space_total -
9699 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
9700 + >> sb->s_blocksize_bits;
9701 + bfree = (dli->dl_space_total - dli->dl_space_used)
9702 + >> sb->s_blocksize_bits;
9703 + spin_unlock(&dli->dl_lock);
9705 + vxlprintk(VXD_CBIT(dlim, 2),
9706 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
9707 + (long long)bfree, (long long)broot,
9708 + *free_blocks, *root_blocks, dli->dl_nrlmult,
9710 + if (free_blocks) {
9711 + if (*free_blocks > bfree)
9712 + *free_blocks = bfree;
9714 + if (root_blocks) {
9715 + if (*root_blocks > broot)
9716 + *root_blocks = broot;
9721 +#define dl_prealloc_space(in, bytes) \
9722 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9723 + __FILE__, __LINE__ )
9725 +#define dl_alloc_space(in, bytes) \
9726 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9727 + __FILE__, __LINE__ )
9729 +#define dl_reserve_space(in, bytes) \
9730 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9731 + __FILE__, __LINE__ )
9733 +#define dl_claim_space(in, bytes) (0)
9735 +#define dl_release_space(in, bytes) \
9736 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9737 + __FILE__, __LINE__ )
9739 +#define dl_free_space(in, bytes) \
9740 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9741 + __FILE__, __LINE__ )
9745 +#define dl_alloc_inode(in) \
9746 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9748 +#define dl_free_inode(in) \
9749 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9752 +#define dl_adjust_block(sb, tag, fb, rb) \
9753 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
9757 +#warning duplicate inclusion
9759 diff -NurpP --minimal linux-3.1.1/include/linux/vs_inet.h linux-3.1.1-vs2.3.2/include/linux/vs_inet.h
9760 --- linux-3.1.1/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
9761 +++ linux-3.1.1-vs2.3.2/include/linux/vs_inet.h 2011-10-24 18:53:33.000000000 +0200
9766 +#include "vserver/base.h"
9767 +#include "vserver/network.h"
9768 +#include "vserver/debug.h"
9770 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
9772 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
9773 + NIPQUAD((a)->mask), (a)->type
9774 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
9776 +#define NIPQUAD(addr) \
9777 + ((unsigned char *)&addr)[0], \
9778 + ((unsigned char *)&addr)[1], \
9779 + ((unsigned char *)&addr)[2], \
9780 + ((unsigned char *)&addr)[3]
9782 +#define NIPQUAD_FMT "%u.%u.%u.%u"
9786 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
9788 + __be32 ip = nxa->ip[0].s_addr;
9789 + __be32 mask = nxa->mask.s_addr;
9790 + __be32 bcast = ip | ~mask;
9793 + switch (nxa->type & tmask) {
9794 + case NXA_TYPE_MASK:
9795 + ret = (ip == (addr & mask));
9797 + case NXA_TYPE_ADDR:
9801 + /* fall through to broadcast */
9802 + case NXA_MOD_BCAST:
9803 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
9805 + case NXA_TYPE_RANGE:
9806 + ret = ((nxa->ip[0].s_addr <= addr) &&
9807 + (nxa->ip[1].s_addr > addr));
9809 + case NXA_TYPE_ANY:
9814 + vxdprintk(VXD_CBIT(net, 0),
9815 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
9816 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
9821 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
9823 + struct nx_addr_v4 *nxa;
9830 + /* allow 127.0.0.1 when remapping lback */
9831 + if ((tmask & NXA_LOOPBACK) &&
9832 + (addr == IPI_LOOPBACK) &&
9833 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9836 + /* check for lback address */
9837 + if ((tmask & NXA_MOD_LBACK) &&
9838 + (nxi->v4_lback.s_addr == addr))
9841 + /* check for broadcast address */
9842 + if ((tmask & NXA_MOD_BCAST) &&
9843 + (nxi->v4_bcast.s_addr == addr))
9846 + /* check for v4 addresses */
9847 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9848 + if (v4_addr_match(nxa, addr, tmask))
9852 + vxdprintk(VXD_CBIT(net, 0),
9853 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9854 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9859 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9861 + /* FIXME: needs full range checks */
9862 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9866 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9868 + struct nx_addr_v4 *ptr;
9870 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9871 + if (v4_nx_addr_match(ptr, nxa, mask))
9876 +#include <net/inet_sock.h>
9879 + * Check if a given address matches for a socket
9881 + * nxi: the socket's nx_info if any
9882 + * addr: to be verified address
9885 +int v4_sock_addr_match (
9886 + struct nx_info *nxi,
9887 + struct inet_sock *inet,
9890 + __be32 saddr = inet->inet_rcv_saddr;
9891 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9893 + if (addr && (saddr == addr || bcast == addr))
9896 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9901 +/* inet related checks and helpers */
9910 +#include <linux/netdevice.h>
9911 +#include <linux/inetdevice.h>
9912 +#include <net/inet_sock.h>
9913 +#include <net/inet_timewait_sock.h>
9916 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9917 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9918 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9922 + * check if address is covered by socket
9924 + * sk: the socket to check against
9925 + * addr: the address in question (must be != 0)
9929 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9931 + struct nx_info *nxi = sk->sk_nx_info;
9932 + __be32 saddr = sk_rcv_saddr(sk);
9934 + vxdprintk(VXD_CBIT(net, 5),
9935 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9936 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9937 + (sk->sk_socket?sk->sk_socket->flags:0));
9939 + if (saddr) { /* direct address match */
9940 + return v4_addr_match(nxa, saddr, -1);
9941 + } else if (nxi) { /* match against nx_info */
9942 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9943 + } else { /* unrestricted any socket */
9951 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9953 + vxdprintk(VXD_CBIT(net, 1),
9954 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9955 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9956 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9958 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9960 + if (dev_in_nx_info(dev, nxi))
9967 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9973 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9977 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
9979 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
9980 + nxi, nxi ? nxi->nx_id : 0, ifa,
9981 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
9983 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9985 + if (v4_ifa_in_nx_info(ifa, nxi))
9991 +struct nx_v4_sock_addr {
9992 + __be32 saddr; /* Address used for validation */
9993 + __be32 baddr; /* Address used for socket bind */
9997 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
9998 + struct nx_v4_sock_addr *nsa)
10000 + struct sock *sk = &inet->sk;
10001 + struct nx_info *nxi = sk->sk_nx_info;
10002 + __be32 saddr = addr->sin_addr.s_addr;
10003 + __be32 baddr = saddr;
10005 + vxdprintk(VXD_CBIT(net, 3),
10006 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
10007 + sk, sk->sk_nx_info, sk->sk_socket,
10008 + (sk->sk_socket ? sk->sk_socket->flags : 0),
10012 + if (saddr == INADDR_ANY) {
10013 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
10014 + baddr = nxi->v4.ip[0].s_addr;
10015 + } else if (saddr == IPI_LOOPBACK) {
10016 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10017 + baddr = nxi->v4_lback.s_addr;
10018 + } else if (!ipv4_is_multicast(saddr) ||
10019 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
10020 + /* normal address bind */
10021 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
10022 + return -EADDRNOTAVAIL;
10026 + vxdprintk(VXD_CBIT(net, 3),
10027 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
10028 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
10030 + nsa->saddr = saddr;
10031 + nsa->baddr = baddr;
10036 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
10038 + inet->inet_saddr = nsa->baddr;
10039 + inet->inet_rcv_saddr = nsa->baddr;
10044 + * helper to simplify inet_lookup_listener
10046 + * nxi: the socket's nx_info if any
10047 + * addr: to be verified address
10048 + * saddr: socket address
10050 +static inline int v4_inet_addr_match (
10051 + struct nx_info *nxi,
10055 + if (addr && (saddr == addr))
10058 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
10062 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
10064 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
10065 + (addr == nxi->v4_lback.s_addr))
10066 + return IPI_LOOPBACK;
10071 +int nx_info_has_v4(struct nx_info *nxi)
10075 + if (NX_IPV4(nxi))
10077 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
10082 +#else /* CONFIG_INET */
10085 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
10091 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10097 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10103 +int nx_info_has_v4(struct nx_info *nxi)
10108 +#endif /* CONFIG_INET */
10110 +#define current_nx_info_has_v4() \
10111 + nx_info_has_v4(current_nx_info())
10114 +// #warning duplicate inclusion
10116 diff -NurpP --minimal linux-3.1.1/include/linux/vs_inet6.h linux-3.1.1-vs2.3.2/include/linux/vs_inet6.h
10117 --- linux-3.1.1/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
10118 +++ linux-3.1.1-vs2.3.2/include/linux/vs_inet6.h 2011-10-24 18:53:33.000000000 +0200
10120 +#ifndef _VS_INET6_H
10121 +#define _VS_INET6_H
10123 +#include "vserver/base.h"
10124 +#include "vserver/network.h"
10125 +#include "vserver/debug.h"
10127 +#include <net/ipv6.h>
10129 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
10130 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
10133 +#ifdef CONFIG_IPV6
10136 +int v6_addr_match(struct nx_addr_v6 *nxa,
10137 + const struct in6_addr *addr, uint16_t mask)
10141 + switch (nxa->type & mask) {
10142 + case NXA_TYPE_MASK:
10143 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
10145 + case NXA_TYPE_ADDR:
10146 + ret = ipv6_addr_equal(&nxa->ip, addr);
10148 + case NXA_TYPE_ANY:
10152 + vxdprintk(VXD_CBIT(net, 0),
10153 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
10154 + nxa, NXAV6(nxa), addr, mask, ret);
10159 +int v6_addr_in_nx_info(struct nx_info *nxi,
10160 + const struct in6_addr *addr, uint16_t mask)
10162 + struct nx_addr_v6 *nxa;
10167 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
10168 + if (v6_addr_match(nxa, addr, mask))
10172 + vxdprintk(VXD_CBIT(net, 0),
10173 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
10174 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
10179 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
10181 + /* FIXME: needs full range checks */
10182 + return v6_addr_match(nxa, &addr->ip, mask);
10186 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
10188 + struct nx_addr_v6 *ptr;
10190 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
10191 + if (v6_nx_addr_match(ptr, nxa, mask))
10198 + * Check if a given address matches for a socket
10200 + * nxi: the socket's nx_info if any
10201 + * addr: to be verified address
10204 +int v6_sock_addr_match (
10205 + struct nx_info *nxi,
10206 + struct inet_sock *inet,
10207 + struct in6_addr *addr)
10209 + struct sock *sk = &inet->sk;
10210 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10212 + if (!ipv6_addr_any(addr) &&
10213 + ipv6_addr_equal(saddr, addr))
10215 + if (ipv6_addr_any(saddr))
10216 + return v6_addr_in_nx_info(nxi, addr, -1);
10221 + * check if address is covered by socket
10223 + * sk: the socket to check against
10224 + * addr: the address in question (must be != 0)
10228 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
10230 + struct nx_info *nxi = sk->sk_nx_info;
10231 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10233 + vxdprintk(VXD_CBIT(net, 5),
10234 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
10235 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
10236 + (sk->sk_socket?sk->sk_socket->flags:0));
10238 + if (!ipv6_addr_any(saddr)) { /* direct address match */
10239 + return v6_addr_match(nxa, saddr, -1);
10240 + } else if (nxi) { /* match against nx_info */
10241 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
10242 + } else { /* unrestricted any socket */
10248 +/* inet related checks and helpers */
10252 +struct net_device;
10256 +#include <linux/netdevice.h>
10257 +#include <linux/inetdevice.h>
10258 +#include <net/inet_timewait_sock.h>
10261 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10262 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10263 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10268 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10274 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10278 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10280 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10281 + nxi, nxi ? nxi->nx_id : 0, ifa,
10282 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10284 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10286 + if (v6_ifa_in_nx_info(ifa, nxi))
10292 +struct nx_v6_sock_addr {
10293 + struct in6_addr saddr; /* Address used for validation */
10294 + struct in6_addr baddr; /* Address used for socket bind */
10298 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10299 + struct nx_v6_sock_addr *nsa)
10301 + // struct sock *sk = &inet->sk;
10302 + // struct nx_info *nxi = sk->sk_nx_info;
10303 + struct in6_addr saddr = addr->sin6_addr;
10304 + struct in6_addr baddr = saddr;
10306 + nsa->saddr = saddr;
10307 + nsa->baddr = baddr;
10312 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10314 + // struct sock *sk = &inet->sk;
10315 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10317 + // *saddr = nsa->baddr;
10318 + // inet->inet_saddr = nsa->baddr;
10322 +int nx_info_has_v6(struct nx_info *nxi)
10326 + if (NX_IPV6(nxi))
10331 +#else /* CONFIG_IPV6 */
10334 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10341 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10347 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10353 +int nx_info_has_v6(struct nx_info *nxi)
10358 +#endif /* CONFIG_IPV6 */
10360 +#define current_nx_info_has_v6() \
10361 + nx_info_has_v6(current_nx_info())
10364 +#warning duplicate inclusion
10366 diff -NurpP --minimal linux-3.1.1/include/linux/vs_limit.h linux-3.1.1-vs2.3.2/include/linux/vs_limit.h
10367 --- linux-3.1.1/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10368 +++ linux-3.1.1-vs2.3.2/include/linux/vs_limit.h 2011-10-24 18:53:33.000000000 +0200
10370 +#ifndef _VS_LIMIT_H
10371 +#define _VS_LIMIT_H
10373 +#include "vserver/limit.h"
10374 +#include "vserver/base.h"
10375 +#include "vserver/context.h"
10376 +#include "vserver/debug.h"
10377 +#include "vserver/context.h"
10378 +#include "vserver/limit_int.h"
10381 +#define vx_acc_cres(v, d, p, r) \
10382 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10384 +#define vx_acc_cres_cond(x, d, p, r) \
10385 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10386 + r, d, p, __FILE__, __LINE__)
10389 +#define vx_add_cres(v, a, p, r) \
10390 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10391 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10393 +#define vx_add_cres_cond(x, a, p, r) \
10394 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10395 + r, a, p, __FILE__, __LINE__)
10396 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10399 +/* process and file limits */
10401 +#define vx_nproc_inc(p) \
10402 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10404 +#define vx_nproc_dec(p) \
10405 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10407 +#define vx_files_inc(f) \
10408 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10410 +#define vx_files_dec(f) \
10411 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10413 +#define vx_locks_inc(l) \
10414 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10416 +#define vx_locks_dec(l) \
10417 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10419 +#define vx_openfd_inc(f) \
10420 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10422 +#define vx_openfd_dec(f) \
10423 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10426 +#define vx_cres_avail(v, n, r) \
10427 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10430 +#define vx_nproc_avail(n) \
10431 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10433 +#define vx_files_avail(n) \
10434 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10436 +#define vx_locks_avail(n) \
10437 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10439 +#define vx_openfd_avail(n) \
10440 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10443 +/* dentry limits */
10445 +#define vx_dentry_inc(d) do { \
10446 + if ((d)->d_count == 1) \
10447 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10450 +#define vx_dentry_dec(d) do { \
10451 + if ((d)->d_count == 0) \
10452 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10455 +#define vx_dentry_avail(n) \
10456 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10459 +/* socket limits */
10461 +#define vx_sock_inc(s) \
10462 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10464 +#define vx_sock_dec(s) \
10465 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10467 +#define vx_sock_avail(n) \
10468 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10471 +/* ipc resource limits */
10473 +#define vx_ipcmsg_add(v, u, a) \
10474 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10476 +#define vx_ipcmsg_sub(v, u, a) \
10477 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10479 +#define vx_ipcmsg_avail(v, a) \
10480 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10483 +#define vx_ipcshm_add(v, k, a) \
10484 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10486 +#define vx_ipcshm_sub(v, k, a) \
10487 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10489 +#define vx_ipcshm_avail(v, a) \
10490 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10493 +#define vx_semary_inc(a) \
10494 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10496 +#define vx_semary_dec(a) \
10497 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10500 +#define vx_nsems_add(a,n) \
10501 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10503 +#define vx_nsems_sub(a,n) \
10504 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10508 +#warning duplicate inclusion
10510 diff -NurpP --minimal linux-3.1.1/include/linux/vs_memory.h linux-3.1.1-vs2.3.2/include/linux/vs_memory.h
10511 --- linux-3.1.1/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
10512 +++ linux-3.1.1-vs2.3.2/include/linux/vs_memory.h 2011-10-24 18:53:33.000000000 +0200
10514 +#ifndef _VS_MEMORY_H
10515 +#define _VS_MEMORY_H
10517 +#include "vserver/limit.h"
10518 +#include "vserver/base.h"
10519 +#include "vserver/context.h"
10520 +#include "vserver/debug.h"
10521 +#include "vserver/context.h"
10522 +#include "vserver/limit_int.h"
10525 + VXPT_UNKNOWN = 0,
10534 +#define vx_page_fault(mm, vma, type, ret)
10538 +void __vx_page_fault(struct mm_struct *mm,
10539 + struct vm_area_struct *vma, int type, int ret)
10541 + struct vx_info *vxi = mm->mm_vx_info;
10544 + static char *page_type[6] =
10545 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
10546 + static char *page_what[4] =
10547 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
10553 + what = (ret & 0x3);
10555 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
10556 + type, what, ret, page_type[type], page_what[what]);
10558 + if (ret & VM_FAULT_WRITE)
10560 + atomic_inc(&vxi->cacct.page[type][what]);
10563 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
10567 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
10570 +#warning duplicate inclusion
10572 diff -NurpP --minimal linux-3.1.1/include/linux/vs_network.h linux-3.1.1-vs2.3.2/include/linux/vs_network.h
10573 --- linux-3.1.1/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
10574 +++ linux-3.1.1-vs2.3.2/include/linux/vs_network.h 2011-10-24 18:53:33.000000000 +0200
10576 +#ifndef _NX_VS_NETWORK_H
10577 +#define _NX_VS_NETWORK_H
10579 +#include "vserver/context.h"
10580 +#include "vserver/network.h"
10581 +#include "vserver/base.h"
10582 +#include "vserver/check.h"
10583 +#include "vserver/debug.h"
10585 +#include <linux/sched.h>
10588 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
10590 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
10591 + const char *_file, int _line)
10596 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
10597 + nxi, nxi ? nxi->nx_id : 0,
10598 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10601 + atomic_inc(&nxi->nx_usecnt);
10606 +extern void free_nx_info(struct nx_info *);
10608 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
10610 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
10615 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
10616 + nxi, nxi ? nxi->nx_id : 0,
10617 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10620 + if (atomic_dec_and_test(&nxi->nx_usecnt))
10621 + free_nx_info(nxi);
10625 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
10627 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10628 + const char *_file, int _line)
10631 + vxlprintk(VXD_CBIT(nid, 3),
10632 + "init_nx_info(%p[#%d.%d])",
10633 + nxi, nxi ? nxi->nx_id : 0,
10634 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10637 + atomic_inc(&nxi->nx_usecnt);
10643 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
10645 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10646 + const char *_file, int _line)
10648 + struct nx_info *nxo;
10653 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
10654 + nxi, nxi ? nxi->nx_id : 0,
10655 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10658 + atomic_inc(&nxi->nx_usecnt);
10659 + nxo = xchg(nxp, nxi);
10663 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
10665 +static inline void __clr_nx_info(struct nx_info **nxp,
10666 + const char *_file, int _line)
10668 + struct nx_info *nxo;
10670 + nxo = xchg(nxp, NULL);
10674 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
10675 + nxo, nxo ? nxo->nx_id : 0,
10676 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
10679 + if (atomic_dec_and_test(&nxo->nx_usecnt))
10680 + free_nx_info(nxo);
10684 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
10686 +static inline void __claim_nx_info(struct nx_info *nxi,
10687 + struct task_struct *task, const char *_file, int _line)
10689 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
10690 + nxi, nxi ? nxi->nx_id : 0,
10691 + nxi?atomic_read(&nxi->nx_usecnt):0,
10692 + nxi?atomic_read(&nxi->nx_tasks):0,
10693 + task, _file, _line);
10695 + atomic_inc(&nxi->nx_tasks);
10699 +extern void unhash_nx_info(struct nx_info *);
10701 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
10703 +static inline void __release_nx_info(struct nx_info *nxi,
10704 + struct task_struct *task, const char *_file, int _line)
10706 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
10707 + nxi, nxi ? nxi->nx_id : 0,
10708 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10709 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
10710 + task, _file, _line);
10714 + if (atomic_dec_and_test(&nxi->nx_tasks))
10715 + unhash_nx_info(nxi);
10719 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
10721 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
10722 + const char *_file, int _line)
10724 + struct nx_info *nxi;
10727 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
10728 + p, _file, _line);
10729 + nxi = __get_nx_info(p->nx_info, _file, _line);
10735 +static inline void exit_nx_info(struct task_struct *p)
10738 + release_nx_info(p->nx_info, p);
10743 +#warning duplicate inclusion
10745 diff -NurpP --minimal linux-3.1.1/include/linux/vs_pid.h linux-3.1.1-vs2.3.2/include/linux/vs_pid.h
10746 --- linux-3.1.1/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
10747 +++ linux-3.1.1-vs2.3.2/include/linux/vs_pid.h 2011-10-24 18:53:33.000000000 +0200
10752 +#include "vserver/base.h"
10753 +#include "vserver/check.h"
10754 +#include "vserver/context.h"
10755 +#include "vserver/debug.h"
10756 +#include "vserver/pid.h"
10757 +#include <linux/pid_namespace.h>
10760 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
10763 +int vx_proc_task_visible(struct task_struct *task)
10765 + if ((task->pid == 1) &&
10766 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
10767 + /* show a blend through init */
10769 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
10776 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
10780 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
10782 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
10784 + if (task && !vx_proc_task_visible(task)) {
10785 + vxdprintk(VXD_CBIT(misc, 6),
10786 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
10787 + task, task->xid, task->pid,
10788 + current, current->xid, current->pid);
10789 + put_task_struct(task);
10797 +#warning duplicate inclusion
10799 diff -NurpP --minimal linux-3.1.1/include/linux/vs_sched.h linux-3.1.1-vs2.3.2/include/linux/vs_sched.h
10800 --- linux-3.1.1/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
10801 +++ linux-3.1.1-vs2.3.2/include/linux/vs_sched.h 2011-10-24 18:53:33.000000000 +0200
10803 +#ifndef _VS_SCHED_H
10804 +#define _VS_SCHED_H
10806 +#include "vserver/base.h"
10807 +#include "vserver/context.h"
10808 +#include "vserver/sched.h"
10811 +#define MAX_PRIO_BIAS 20
10812 +#define MIN_PRIO_BIAS -20
10815 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
10817 + struct vx_info *vxi = p->vx_info;
10820 + prio += vx_cpu(vxi, sched_pc).prio_bias;
10824 +static inline void vx_account_user(struct vx_info *vxi,
10825 + cputime_t cputime, int nice)
10829 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
10832 +static inline void vx_account_system(struct vx_info *vxi,
10833 + cputime_t cputime, int idle)
10837 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
10841 +#warning duplicate inclusion
10843 diff -NurpP --minimal linux-3.1.1/include/linux/vs_socket.h linux-3.1.1-vs2.3.2/include/linux/vs_socket.h
10844 --- linux-3.1.1/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
10845 +++ linux-3.1.1-vs2.3.2/include/linux/vs_socket.h 2011-10-24 18:53:33.000000000 +0200
10847 +#ifndef _VS_SOCKET_H
10848 +#define _VS_SOCKET_H
10850 +#include "vserver/debug.h"
10851 +#include "vserver/base.h"
10852 +#include "vserver/cacct.h"
10853 +#include "vserver/context.h"
10854 +#include "vserver/tag.h"
10857 +/* socket accounting */
10859 +#include <linux/socket.h>
10861 +static inline int vx_sock_type(int family)
10863 + switch (family) {
10865 + return VXA_SOCK_UNSPEC;
10867 + return VXA_SOCK_UNIX;
10869 + return VXA_SOCK_INET;
10871 + return VXA_SOCK_INET6;
10873 + return VXA_SOCK_PACKET;
10875 + return VXA_SOCK_OTHER;
10879 +#define vx_acc_sock(v, f, p, s) \
10880 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
10882 +static inline void __vx_acc_sock(struct vx_info *vxi,
10883 + int family, int pos, int size, char *file, int line)
10886 + int type = vx_sock_type(family);
10888 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10889 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10893 +#define vx_sock_recv(sk, s) \
10894 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10895 +#define vx_sock_send(sk, s) \
10896 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10897 +#define vx_sock_fail(sk, s) \
10898 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10901 +#define sock_vx_init(s) do { \
10902 + (s)->sk_xid = 0; \
10903 + (s)->sk_vx_info = NULL; \
10906 +#define sock_nx_init(s) do { \
10907 + (s)->sk_nid = 0; \
10908 + (s)->sk_nx_info = NULL; \
10912 +#warning duplicate inclusion
10914 diff -NurpP --minimal linux-3.1.1/include/linux/vs_tag.h linux-3.1.1-vs2.3.2/include/linux/vs_tag.h
10915 --- linux-3.1.1/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
10916 +++ linux-3.1.1-vs2.3.2/include/linux/vs_tag.h 2011-10-24 18:53:33.000000000 +0200
10921 +#include <linux/vserver/tag.h>
10923 +/* check conditions */
10925 +#define DX_ADMIN 0x0001
10926 +#define DX_WATCH 0x0002
10927 +#define DX_HOSTID 0x0008
10929 +#define DX_IDENT 0x0010
10931 +#define DX_ARG_MASK 0x0010
10934 +#define dx_task_tag(t) ((t)->tag)
10936 +#define dx_current_tag() dx_task_tag(current)
10938 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10940 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10944 + * check current context for ADMIN/WATCH and
10945 + * optionally against supplied argument
10947 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
10949 + if (mode & DX_ARG_MASK) {
10950 + if ((mode & DX_IDENT) && (id == cid))
10953 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10954 + ((mode & DX_WATCH) && (cid == 1)) ||
10955 + ((mode & DX_HOSTID) && (id == 0)));
10959 +int dx_permission(const struct inode *inode, int mask);
10963 +#warning duplicate inclusion
10965 diff -NurpP --minimal linux-3.1.1/include/linux/vs_time.h linux-3.1.1-vs2.3.2/include/linux/vs_time.h
10966 --- linux-3.1.1/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
10967 +++ linux-3.1.1-vs2.3.2/include/linux/vs_time.h 2011-10-24 18:53:33.000000000 +0200
10969 +#ifndef _VS_TIME_H
10970 +#define _VS_TIME_H
10973 +/* time faking stuff */
10975 +#ifdef CONFIG_VSERVER_VTIME
10977 +extern void vx_adjust_timespec(struct timespec *ts);
10978 +extern int vx_settimeofday(const struct timespec *ts);
10981 +#define vx_adjust_timespec(t) do { } while (0)
10982 +#define vx_settimeofday(t) do_settimeofday(t)
10986 +#warning duplicate inclusion
10988 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/Kbuild linux-3.1.1-vs2.3.2/include/linux/vserver/Kbuild
10989 --- linux-3.1.1/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
10990 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/Kbuild 2011-10-24 18:53:33.000000000 +0200
10993 +header-y += context_cmd.h network_cmd.h space_cmd.h \
10994 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
10995 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
10996 + debug_cmd.h device_cmd.h
10998 +header-y += switch.h network.h monitor.h inode.h device.h
11000 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/base.h linux-3.1.1-vs2.3.2/include/linux/vserver/base.h
11001 --- linux-3.1.1/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
11002 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/base.h 2011-10-24 18:53:33.000000000 +0200
11004 +#ifndef _VX_BASE_H
11005 +#define _VX_BASE_H
11008 +/* context state changes */
11020 +#define vx_task_xid(t) ((t)->xid)
11022 +#define vx_current_xid() vx_task_xid(current)
11024 +#define current_vx_info() (current->vx_info)
11027 +#define nx_task_nid(t) ((t)->nid)
11029 +#define nx_current_nid() nx_task_nid(current)
11031 +#define current_nx_info() (current->nx_info)
11034 +/* generic flag merging */
11036 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
11038 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
11040 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
11042 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
11045 +/* context flags */
11047 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
11049 +#define vx_current_flags() __vx_flags(current_vx_info())
11051 +#define vx_info_flags(v, m, f) \
11052 + vs_check_flags(__vx_flags(v), m, f)
11054 +#define task_vx_flags(t, m, f) \
11055 + ((t) && vx_info_flags((t)->vx_info, m, f))
11057 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
11060 +/* context caps */
11062 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
11064 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
11066 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
11068 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
11072 +/* network flags */
11074 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
11076 +#define nx_current_flags() __nx_flags(current_nx_info())
11078 +#define nx_info_flags(n, m, f) \
11079 + vs_check_flags(__nx_flags(n), m, f)
11081 +#define task_nx_flags(t, m, f) \
11082 + ((t) && nx_info_flags((t)->nx_info, m, f))
11084 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
11087 +/* network caps */
11089 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
11091 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
11093 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
11095 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
11098 +/* context mask capabilities */
11100 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
11102 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
11104 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
11107 +/* context bcap mask */
11109 +#define __vx_bcaps(v) ((v)->vx_bcaps)
11111 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
11114 +/* mask given bcaps */
11116 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
11118 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
11121 +/* masked cap_bset */
11123 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
11125 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
11128 +#define vx_info_mbcap(v, b) \
11129 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
11130 + vx_info_bcaps(v, b) : (b))
11132 +#define task_vx_mbcap(t, b) \
11133 + vx_info_mbcap((t)->vx_info, (t)->b)
11135 +#define vx_mbcap(b) task_vx_mbcap(current, b)
11138 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
11140 +#define vx_capable(b, c) (capable(b) || \
11141 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
11143 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
11144 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
11146 +#define nx_capable(b, c) (capable(b) || \
11147 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
11149 +#define vx_task_initpid(t, n) \
11150 + ((t)->vx_info && \
11151 + ((t)->vx_info->vx_initpid == (n)))
11153 +#define vx_current_initpid(n) vx_task_initpid(current, n)
11156 +/* context unshare mask */
11158 +#define __vx_umask(v) ((v)->vx_umask)
11160 +#define vx_current_umask() __vx_umask(current_vx_info())
11162 +#define vx_can_unshare(b, f) (capable(b) || \
11163 + (cap_raised(current_cap(), b) && \
11164 + !((f) & ~vx_current_umask())))
11167 +#define __vx_wmask(v) ((v)->vx_wmask)
11169 +#define vx_current_wmask() __vx_wmask(current_vx_info())
11172 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
11174 +#define vx_info_state(v, m) (__vx_state(v) & (m))
11177 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
11179 +#define nx_info_state(n, m) (__nx_state(n) & (m))
11182 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/cacct.h linux-3.1.1-vs2.3.2/include/linux/vserver/cacct.h
11183 --- linux-3.1.1/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
11184 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/cacct.h 2011-10-24 18:53:33.000000000 +0200
11186 +#ifndef _VX_CACCT_H
11187 +#define _VX_CACCT_H
11190 +enum sock_acc_field {
11191 + VXA_SOCK_UNSPEC = 0,
11197 + VXA_SOCK_SIZE /* array size */
11200 +#endif /* _VX_CACCT_H */
11201 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/cacct_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/cacct_cmd.h
11202 --- linux-3.1.1/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
11203 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/cacct_cmd.h 2011-10-24 18:53:33.000000000 +0200
11205 +#ifndef _VX_CACCT_CMD_H
11206 +#define _VX_CACCT_CMD_H
11209 +/* virtual host info name commands */
11211 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
11213 +struct vcmd_sock_stat_v0 {
11215 + uint32_t count[3];
11216 + uint64_t total[3];
11222 +#include <linux/compiler.h>
11224 +extern int vc_sock_stat(struct vx_info *, void __user *);
11226 +#endif /* __KERNEL__ */
11227 +#endif /* _VX_CACCT_CMD_H */
11228 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/cacct_def.h linux-3.1.1-vs2.3.2/include/linux/vserver/cacct_def.h
11229 --- linux-3.1.1/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
11230 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/cacct_def.h 2011-10-24 18:53:33.000000000 +0200
11232 +#ifndef _VX_CACCT_DEF_H
11233 +#define _VX_CACCT_DEF_H
11235 +#include <asm/atomic.h>
11236 +#include <linux/vserver/cacct.h>
11239 +struct _vx_sock_acc {
11240 + atomic_long_t count;
11241 + atomic_long_t total;
11244 +/* context sub struct */
11246 +struct _vx_cacct {
11247 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11248 + atomic_t slab[8];
11249 + atomic_t page[6][8];
11252 +#ifdef CONFIG_VSERVER_DEBUG
11254 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11258 + printk("\t_vx_cacct:");
11259 + for (i = 0; i < 6; i++) {
11260 + struct _vx_sock_acc *ptr = cacct->sock[i];
11262 + printk("\t [%d] =", i);
11263 + for (j = 0; j < 3; j++) {
11264 + printk(" [%d] = %8lu, %8lu", j,
11265 + atomic_long_read(&ptr[j].count),
11266 + atomic_long_read(&ptr[j].total));
11274 +#endif /* _VX_CACCT_DEF_H */
11275 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/cacct_int.h linux-3.1.1-vs2.3.2/include/linux/vserver/cacct_int.h
11276 --- linux-3.1.1/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
11277 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/cacct_int.h 2011-10-24 18:53:33.000000000 +0200
11279 +#ifndef _VX_CACCT_INT_H
11280 +#define _VX_CACCT_INT_H
11286 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11288 + return atomic_long_read(&cacct->sock[type][pos].count);
11293 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11295 + return atomic_long_read(&cacct->sock[type][pos].total);
11298 +#endif /* __KERNEL__ */
11299 +#endif /* _VX_CACCT_INT_H */
11300 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/check.h linux-3.1.1-vs2.3.2/include/linux/vserver/check.h
11301 --- linux-3.1.1/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
11302 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/check.h 2011-10-24 18:53:33.000000000 +0200
11304 +#ifndef _VS_CHECK_H
11305 +#define _VS_CHECK_H
11308 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11310 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11311 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11313 +#define MIN_D_CONTEXT 65536
11316 +/* check conditions */
11318 +#define VS_ADMIN 0x0001
11319 +#define VS_WATCH 0x0002
11320 +#define VS_HIDE 0x0004
11321 +#define VS_HOSTID 0x0008
11323 +#define VS_IDENT 0x0010
11324 +#define VS_EQUIV 0x0020
11325 +#define VS_PARENT 0x0040
11326 +#define VS_CHILD 0x0080
11328 +#define VS_ARG_MASK 0x00F0
11330 +#define VS_DYNAMIC 0x0100
11331 +#define VS_STATIC 0x0200
11333 +#define VS_ATR_MASK 0x0F00
11335 +#ifdef CONFIG_VSERVER_PRIVACY
11336 +#define VS_ADMIN_P (0)
11337 +#define VS_WATCH_P (0)
11339 +#define VS_ADMIN_P VS_ADMIN
11340 +#define VS_WATCH_P VS_WATCH
11343 +#define VS_HARDIRQ 0x1000
11344 +#define VS_SOFTIRQ 0x2000
11345 +#define VS_IRQ 0x4000
11347 +#define VS_IRQ_MASK 0xF000
11349 +#include <linux/hardirq.h>
11352 + * check current context for ADMIN/WATCH and
11353 + * optionally against supplied argument
11355 +static inline int __vs_check(int cid, int id, unsigned int mode)
11357 + if (mode & VS_ARG_MASK) {
11358 + if ((mode & VS_IDENT) && (id == cid))
11361 + if (mode & VS_ATR_MASK) {
11362 + if ((mode & VS_DYNAMIC) &&
11363 + (id >= MIN_D_CONTEXT) &&
11364 + (id <= MAX_S_CONTEXT))
11366 + if ((mode & VS_STATIC) &&
11367 + (id > 1) && (id < MIN_D_CONTEXT))
11370 + if (mode & VS_IRQ_MASK) {
11371 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11373 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11375 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11378 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11379 + ((mode & VS_WATCH) && (cid == 1)) ||
11380 + ((mode & VS_HOSTID) && (id == 0)));
11383 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11385 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11388 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11390 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11393 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/context.h linux-3.1.1-vs2.3.2/include/linux/vserver/context.h
11394 --- linux-3.1.1/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11395 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/context.h 2011-10-24 18:53:33.000000000 +0200
11397 +#ifndef _VX_CONTEXT_H
11398 +#define _VX_CONTEXT_H
11400 +#include <linux/types.h>
11401 +#include <linux/capability.h>
11404 +/* context flags */
11406 +#define VXF_INFO_SCHED 0x00000002
11407 +#define VXF_INFO_NPROC 0x00000004
11408 +#define VXF_INFO_PRIVATE 0x00000008
11410 +#define VXF_INFO_INIT 0x00000010
11411 +#define VXF_INFO_HIDE 0x00000020
11412 +#define VXF_INFO_ULIMIT 0x00000040
11413 +#define VXF_INFO_NSPACE 0x00000080
11415 +#define VXF_SCHED_HARD 0x00000100
11416 +#define VXF_SCHED_PRIO 0x00000200
11417 +#define VXF_SCHED_PAUSE 0x00000400
11419 +#define VXF_VIRT_MEM 0x00010000
11420 +#define VXF_VIRT_UPTIME 0x00020000
11421 +#define VXF_VIRT_CPU 0x00040000
11422 +#define VXF_VIRT_LOAD 0x00080000
11423 +#define VXF_VIRT_TIME 0x00100000
11425 +#define VXF_HIDE_MOUNT 0x01000000
11426 +/* was VXF_HIDE_NETIF 0x02000000 */
11427 +#define VXF_HIDE_VINFO 0x04000000
11429 +#define VXF_STATE_SETUP (1ULL << 32)
11430 +#define VXF_STATE_INIT (1ULL << 33)
11431 +#define VXF_STATE_ADMIN (1ULL << 34)
11433 +#define VXF_SC_HELPER (1ULL << 36)
11434 +#define VXF_REBOOT_KILL (1ULL << 37)
11435 +#define VXF_PERSISTENT (1ULL << 38)
11437 +#define VXF_FORK_RSS (1ULL << 48)
11438 +#define VXF_PROLIFIC (1ULL << 49)
11440 +#define VXF_IGNEG_NICE (1ULL << 52)
11442 +#define VXF_ONE_TIME (0x0007ULL << 32)
11444 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11447 +/* context migration */
11449 +#define VXM_SET_INIT 0x00000001
11450 +#define VXM_SET_REAPER 0x00000002
11452 +/* context caps */
11454 +#define VXC_CAP_MASK 0x00000000
11456 +#define VXC_SET_UTSNAME 0x00000001
11457 +#define VXC_SET_RLIMIT 0x00000002
11458 +#define VXC_FS_SECURITY 0x00000004
11459 +#define VXC_FS_TRUSTED 0x00000008
11460 +#define VXC_TIOCSTI 0x00000010
11462 +/* was VXC_RAW_ICMP 0x00000100 */
11463 +#define VXC_SYSLOG 0x00001000
11464 +#define VXC_OOM_ADJUST 0x00002000
11465 +#define VXC_AUDIT_CONTROL 0x00004000
11467 +#define VXC_SECURE_MOUNT 0x00010000
11468 +#define VXC_SECURE_REMOUNT 0x00020000
11469 +#define VXC_BINARY_MOUNT 0x00040000
11471 +#define VXC_QUOTA_CTL 0x00100000
11472 +#define VXC_ADMIN_MAPPER 0x00200000
11473 +#define VXC_ADMIN_CLOOP 0x00400000
11475 +#define VXC_KTHREAD 0x01000000
11476 +#define VXC_NAMESPACE 0x02000000
11481 +#include <linux/list.h>
11482 +#include <linux/spinlock.h>
11483 +#include <linux/rcupdate.h>
11485 +#include "limit_def.h"
11486 +#include "sched_def.h"
11487 +#include "cvirt_def.h"
11488 +#include "cacct_def.h"
11489 +#include "device_def.h"
11491 +#define VX_SPACES 2
11493 +struct _vx_info_pc {
11494 + struct _vx_sched_pc sched_pc;
11495 + struct _vx_cvirt_pc cvirt_pc;
11498 +struct _vx_space {
11499 + unsigned long vx_nsmask; /* assignment mask */
11500 + struct nsproxy *vx_nsproxy; /* private namespaces */
11501 + struct fs_struct *vx_fs; /* private namespace fs */
11502 + const struct cred *vx_cred; /* task credentials */
11506 + struct hlist_node vx_hlist; /* linked list of contexts */
11507 + xid_t vx_id; /* context id */
11508 + atomic_t vx_usecnt; /* usage count */
11509 + atomic_t vx_tasks; /* tasks count */
11510 + struct vx_info *vx_parent; /* parent context */
11511 + int vx_state; /* context state */
11513 + struct _vx_space space[VX_SPACES]; /* namespace store */
11515 + uint64_t vx_flags; /* context flags */
11516 + uint64_t vx_ccaps; /* context caps (vserver) */
11517 + uint64_t vx_umask; /* unshare mask (guest) */
11518 + uint64_t vx_wmask; /* warn mask (guest) */
11519 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11521 + struct task_struct *vx_reaper; /* guest reaper process */
11522 + pid_t vx_initpid; /* PID of guest init */
11523 + int64_t vx_badness_bias; /* OOM points bias */
11525 + struct _vx_limit limit; /* vserver limits */
11526 + struct _vx_sched sched; /* vserver scheduler */
11527 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11528 + struct _vx_cacct cacct; /* context accounting */
11530 + struct _vx_device dmap; /* default device map targets */
11532 +#ifndef CONFIG_SMP
11533 + struct _vx_info_pc info_pc; /* per cpu data */
11535 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11538 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11539 + int reboot_cmd; /* last sys_reboot() cmd */
11540 + int exit_code; /* last process exit code */
11542 + char vx_name[65]; /* vserver name */
11545 +#ifndef CONFIG_SMP
11546 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11547 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11549 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11550 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11553 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11556 +struct vx_info_save {
11557 + struct vx_info *vxi;
11562 +/* status flags */
11564 +#define VXS_HASHED 0x0001
11565 +#define VXS_PAUSED 0x0010
11566 +#define VXS_SHUTDOWN 0x0100
11567 +#define VXS_HELPER 0x1000
11568 +#define VXS_RELEASED 0x8000
11571 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11572 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11574 +extern struct vx_info *lookup_vx_info(int);
11575 +extern struct vx_info *lookup_or_create_vx_info(int);
11577 +extern int get_xid_list(int, unsigned int *, int);
11578 +extern int xid_is_hashed(xid_t);
11580 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11582 +extern long vs_state_change(struct vx_info *, unsigned int);
11585 +#endif /* __KERNEL__ */
11586 +#endif /* _VX_CONTEXT_H */
11587 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/context_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/context_cmd.h
11588 --- linux-3.1.1/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
11589 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/context_cmd.h 2011-10-24 18:53:33.000000000 +0200
11591 +#ifndef _VX_CONTEXT_CMD_H
11592 +#define _VX_CONTEXT_CMD_H
11595 +/* vinfo commands */
11597 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11600 +extern int vc_task_xid(uint32_t);
11602 +#endif /* __KERNEL__ */
11604 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11606 +struct vcmd_vx_info_v0 {
11608 + uint32_t initpid;
11609 + /* more to come */
11613 +extern int vc_vx_info(struct vx_info *, void __user *);
11615 +#endif /* __KERNEL__ */
11617 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11619 +struct vcmd_ctx_stat_v0 {
11622 + /* more to come */
11626 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11628 +#endif /* __KERNEL__ */
11630 +/* context commands */
11632 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11633 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11635 +struct vcmd_ctx_create {
11636 + uint64_t flagword;
11639 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11640 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11642 +struct vcmd_ctx_migrate {
11643 + uint64_t flagword;
11647 +extern int vc_ctx_create(uint32_t, void __user *);
11648 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11650 +#endif /* __KERNEL__ */
11653 +/* flag commands */
11655 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11656 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11658 +struct vcmd_ctx_flags_v0 {
11659 + uint64_t flagword;
11664 +extern int vc_get_cflags(struct vx_info *, void __user *);
11665 +extern int vc_set_cflags(struct vx_info *, void __user *);
11667 +#endif /* __KERNEL__ */
11670 +/* context caps commands */
11672 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
11673 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
11675 +struct vcmd_ctx_caps_v1 {
11681 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11682 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11684 +#endif /* __KERNEL__ */
11687 +/* bcaps commands */
11689 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
11690 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
11692 +struct vcmd_bcaps {
11698 +extern int vc_get_bcaps(struct vx_info *, void __user *);
11699 +extern int vc_set_bcaps(struct vx_info *, void __user *);
11701 +#endif /* __KERNEL__ */
11704 +/* umask commands */
11706 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
11707 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
11709 +struct vcmd_umask {
11715 +extern int vc_get_umask(struct vx_info *, void __user *);
11716 +extern int vc_set_umask(struct vx_info *, void __user *);
11718 +#endif /* __KERNEL__ */
11721 +/* wmask commands */
11723 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
11724 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
11726 +struct vcmd_wmask {
11732 +extern int vc_get_wmask(struct vx_info *, void __user *);
11733 +extern int vc_set_wmask(struct vx_info *, void __user *);
11735 +#endif /* __KERNEL__ */
11740 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
11741 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
11743 +struct vcmd_badness_v0 {
11748 +extern int vc_get_badness(struct vx_info *, void __user *);
11749 +extern int vc_set_badness(struct vx_info *, void __user *);
11751 +#endif /* __KERNEL__ */
11752 +#endif /* _VX_CONTEXT_CMD_H */
11753 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/cvirt.h linux-3.1.1-vs2.3.2/include/linux/vserver/cvirt.h
11754 --- linux-3.1.1/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11755 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/cvirt.h 2011-10-24 18:53:33.000000000 +0200
11757 +#ifndef _VX_CVIRT_H
11758 +#define _VX_CVIRT_H
11765 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11770 +void vx_update_load(struct vx_info *);
11773 +int vx_do_syslog(int, char __user *, int);
11775 +#endif /* __KERNEL__ */
11776 +#endif /* _VX_CVIRT_H */
11777 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/cvirt_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/cvirt_cmd.h
11778 --- linux-3.1.1/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11779 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/cvirt_cmd.h 2011-10-24 18:53:33.000000000 +0200
11781 +#ifndef _VX_CVIRT_CMD_H
11782 +#define _VX_CVIRT_CMD_H
11785 +/* virtual host info name commands */
11787 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11788 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11790 +struct vcmd_vhi_name_v0 {
11796 +enum vhi_name_field {
11797 + VHIN_CONTEXT = 0,
11809 +#include <linux/compiler.h>
11811 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11812 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11814 +#endif /* __KERNEL__ */
11816 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11818 +struct vcmd_virt_stat_v0 {
11821 + uint32_t nr_threads;
11822 + uint32_t nr_running;
11823 + uint32_t nr_uninterruptible;
11824 + uint32_t nr_onhold;
11825 + uint32_t nr_forks;
11826 + uint32_t load[3];
11830 +extern int vc_virt_stat(struct vx_info *, void __user *);
11832 +#endif /* __KERNEL__ */
11833 +#endif /* _VX_CVIRT_CMD_H */
11834 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/cvirt_def.h linux-3.1.1-vs2.3.2/include/linux/vserver/cvirt_def.h
11835 --- linux-3.1.1/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11836 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/cvirt_def.h 2011-10-24 18:53:33.000000000 +0200
11838 +#ifndef _VX_CVIRT_DEF_H
11839 +#define _VX_CVIRT_DEF_H
11841 +#include <linux/jiffies.h>
11842 +#include <linux/spinlock.h>
11843 +#include <linux/wait.h>
11844 +#include <linux/time.h>
11845 +#include <asm/atomic.h>
11848 +struct _vx_usage_stat {
11852 + uint64_t softirq;
11858 +struct _vx_syslog {
11859 + wait_queue_head_t log_wait;
11860 + spinlock_t logbuf_lock; /* lock for the log buffer */
11862 + unsigned long log_start; /* next char to be read by syslog() */
11863 + unsigned long con_start; /* next char to be sent to consoles */
11864 + unsigned long log_end; /* most-recently-written-char + 1 */
11865 + unsigned long logged_chars; /* #chars since last read+clear operation */
11867 + char log_buf[1024];
11871 +/* context sub struct */
11873 +struct _vx_cvirt {
11874 + atomic_t nr_threads; /* number of current threads */
11875 + atomic_t nr_running; /* number of running threads */
11876 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11878 + atomic_t nr_onhold; /* processes on hold */
11879 + uint32_t onhold_last; /* jiffies when put on hold */
11881 + struct timespec bias_ts; /* time offset to the host */
11882 + struct timespec bias_idle;
11883 + struct timespec bias_uptime; /* context creation point */
11884 + uint64_t bias_clock; /* offset in clock_t */
11886 + spinlock_t load_lock; /* lock for the load averages */
11887 + atomic_t load_updates; /* nr of load updates done so far */
11888 + uint32_t load_last; /* last time load was calculated */
11889 + uint32_t load[3]; /* load averages 1,5,15 */
11891 + atomic_t total_forks; /* number of forks so far */
11893 + struct _vx_syslog syslog;
11896 +struct _vx_cvirt_pc {
11897 + struct _vx_usage_stat cpustat;
11901 +#ifdef CONFIG_VSERVER_DEBUG
11903 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11905 + printk("\t_vx_cvirt:\n");
11906 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11907 + atomic_read(&cvirt->nr_threads),
11908 + atomic_read(&cvirt->nr_running),
11909 + atomic_read(&cvirt->nr_uninterruptible),
11910 + atomic_read(&cvirt->nr_onhold));
11911 + /* add rest here */
11912 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11917 +#endif /* _VX_CVIRT_DEF_H */
11918 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/debug.h linux-3.1.1-vs2.3.2/include/linux/vserver/debug.h
11919 --- linux-3.1.1/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11920 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/debug.h 2011-10-24 18:53:33.000000000 +0200
11922 +#ifndef _VX_DEBUG_H
11923 +#define _VX_DEBUG_H
11926 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
11927 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
11928 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
11930 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11931 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11932 +#define VXF_DEV "%p[%lu,%d:%d]"
11934 +#if defined(CONFIG_QUOTES_UTF8)
11935 +#define VS_Q_LQM "\xc2\xbb"
11936 +#define VS_Q_RQM "\xc2\xab"
11937 +#elif defined(CONFIG_QUOTES_ASCII)
11938 +#define VS_Q_LQM "\x27"
11939 +#define VS_Q_RQM "\x27"
11941 +#define VS_Q_LQM "\xbb"
11942 +#define VS_Q_RQM "\xab"
11945 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
11948 +#define vxd_path(p) \
11949 + ({ static char _buffer[PATH_MAX]; \
11950 + d_path(p, _buffer, sizeof(_buffer)); })
11952 +#define vxd_cond_path(n) \
11953 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11956 +#ifdef CONFIG_VSERVER_DEBUG
11958 +extern unsigned int vx_debug_switch;
11959 +extern unsigned int vx_debug_xid;
11960 +extern unsigned int vx_debug_nid;
11961 +extern unsigned int vx_debug_tag;
11962 +extern unsigned int vx_debug_net;
11963 +extern unsigned int vx_debug_limit;
11964 +extern unsigned int vx_debug_cres;
11965 +extern unsigned int vx_debug_dlim;
11966 +extern unsigned int vx_debug_quota;
11967 +extern unsigned int vx_debug_cvirt;
11968 +extern unsigned int vx_debug_space;
11969 +extern unsigned int vx_debug_misc;
11972 +#define VX_LOGLEVEL "vxD: "
11973 +#define VX_PROC_FMT "%p: "
11974 +#define VX_PROCESS current
11976 +#define vxdprintk(c, f, x...) \
11979 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11980 + VX_PROCESS , ##x); \
11983 +#define vxlprintk(c, f, x...) \
11986 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11989 +#define vxfprintk(c, f, x...) \
11992 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11998 +void dump_vx_info(struct vx_info *, int);
11999 +void dump_vx_info_inactive(int);
12001 +#else /* CONFIG_VSERVER_DEBUG */
12003 +#define vx_debug_switch 0
12004 +#define vx_debug_xid 0
12005 +#define vx_debug_nid 0
12006 +#define vx_debug_tag 0
12007 +#define vx_debug_net 0
12008 +#define vx_debug_limit 0
12009 +#define vx_debug_cres 0
12010 +#define vx_debug_dlim 0
12011 +#define vx_debug_cvirt 0
12013 +#define vxdprintk(x...) do { } while (0)
12014 +#define vxlprintk(x...) do { } while (0)
12015 +#define vxfprintk(x...) do { } while (0)
12017 +#endif /* CONFIG_VSERVER_DEBUG */
12020 +#ifdef CONFIG_VSERVER_WARN
12022 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
12023 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
12024 +#define VX_WARN_XID "[xid #%u] "
12025 +#define VX_WARN_NID "[nid #%u] "
12026 +#define VX_WARN_TAG "[tag #%u] "
12028 +#define vxwprintk(c, f, x...) \
12031 + printk(VX_WARNLEVEL f "\n", ##x); \
12034 +#else /* CONFIG_VSERVER_WARN */
12036 +#define vxwprintk(x...) do { } while (0)
12038 +#endif /* CONFIG_VSERVER_WARN */
12040 +#define vxwprintk_task(c, f, x...) \
12041 + vxwprintk(c, VX_WARN_TASK f, \
12042 + current->comm, current->pid, \
12043 + current->xid, current->nid, current->tag, ##x)
12044 +#define vxwprintk_xid(c, f, x...) \
12045 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
12046 +#define vxwprintk_nid(c, f, x...) \
12047 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
12048 +#define vxwprintk_tag(c, f, x...) \
12049 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
12051 +#ifdef CONFIG_VSERVER_DEBUG
12052 +#define vxd_assert_lock(l) assert_spin_locked(l)
12053 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
12054 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
12056 +#define vxd_assert_lock(l) do { } while (0)
12057 +#define vxd_assert(c, f, x...) do { } while (0)
12061 +#endif /* _VX_DEBUG_H */
12062 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/debug_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/debug_cmd.h
12063 --- linux-3.1.1/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
12064 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/debug_cmd.h 2011-10-24 18:53:33.000000000 +0200
12066 +#ifndef _VX_DEBUG_CMD_H
12067 +#define _VX_DEBUG_CMD_H
12070 +/* debug commands */
12072 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
12074 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
12075 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
12077 +struct vcmd_read_history_v0 {
12080 + char __user *data;
12083 +struct vcmd_read_monitor_v0 {
12086 + char __user *data;
12092 +#ifdef CONFIG_COMPAT
12094 +#include <asm/compat.h>
12096 +struct vcmd_read_history_v0_x32 {
12099 + compat_uptr_t data_ptr;
12102 +struct vcmd_read_monitor_v0_x32 {
12105 + compat_uptr_t data_ptr;
12108 +#endif /* CONFIG_COMPAT */
12110 +extern int vc_dump_history(uint32_t);
12112 +extern int vc_read_history(uint32_t, void __user *);
12113 +extern int vc_read_monitor(uint32_t, void __user *);
12115 +#ifdef CONFIG_COMPAT
12117 +extern int vc_read_history_x32(uint32_t, void __user *);
12118 +extern int vc_read_monitor_x32(uint32_t, void __user *);
12120 +#endif /* CONFIG_COMPAT */
12122 +#endif /* __KERNEL__ */
12123 +#endif /* _VX_DEBUG_CMD_H */
12124 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/device.h linux-3.1.1-vs2.3.2/include/linux/vserver/device.h
12125 --- linux-3.1.1/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
12126 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/device.h 2011-10-24 18:53:33.000000000 +0200
12128 +#ifndef _VX_DEVICE_H
12129 +#define _VX_DEVICE_H
12132 +#define DATTR_CREATE 0x00000001
12133 +#define DATTR_OPEN 0x00000002
12135 +#define DATTR_REMAP 0x00000010
12137 +#define DATTR_MASK 0x00000013
12140 +#else /* _VX_DEVICE_H */
12141 +#warning duplicate inclusion
12142 +#endif /* _VX_DEVICE_H */
12143 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/device_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/device_cmd.h
12144 --- linux-3.1.1/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
12145 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/device_cmd.h 2011-10-24 18:53:33.000000000 +0200
12147 +#ifndef _VX_DEVICE_CMD_H
12148 +#define _VX_DEVICE_CMD_H
12151 +/* device vserver commands */
12153 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
12154 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
12156 +struct vcmd_set_mapping_v0 {
12157 + const char __user *device;
12158 + const char __user *target;
12165 +#ifdef CONFIG_COMPAT
12167 +#include <asm/compat.h>
12169 +struct vcmd_set_mapping_v0_x32 {
12170 + compat_uptr_t device_ptr;
12171 + compat_uptr_t target_ptr;
12175 +#endif /* CONFIG_COMPAT */
12177 +#include <linux/compiler.h>
12179 +extern int vc_set_mapping(struct vx_info *, void __user *);
12180 +extern int vc_unset_mapping(struct vx_info *, void __user *);
12182 +#ifdef CONFIG_COMPAT
12184 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
12185 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
12187 +#endif /* CONFIG_COMPAT */
12189 +#endif /* __KERNEL__ */
12190 +#endif /* _VX_DEVICE_CMD_H */
12191 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/device_def.h linux-3.1.1-vs2.3.2/include/linux/vserver/device_def.h
12192 --- linux-3.1.1/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
12193 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/device_def.h 2011-10-24 18:53:33.000000000 +0200
12195 +#ifndef _VX_DEVICE_DEF_H
12196 +#define _VX_DEVICE_DEF_H
12198 +#include <linux/types.h>
12200 +struct vx_dmap_target {
12205 +struct _vx_device {
12206 +#ifdef CONFIG_VSERVER_DEVICE
12207 + struct vx_dmap_target targets[2];
12211 +#endif /* _VX_DEVICE_DEF_H */
12212 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/dlimit.h linux-3.1.1-vs2.3.2/include/linux/vserver/dlimit.h
12213 --- linux-3.1.1/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12214 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/dlimit.h 2011-10-24 18:53:33.000000000 +0200
12216 +#ifndef _VX_DLIMIT_H
12217 +#define _VX_DLIMIT_H
12219 +#include "switch.h"
12224 +/* keep in sync with CDLIM_INFINITY */
12226 +#define DLIM_INFINITY (~0ULL)
12228 +#include <linux/spinlock.h>
12229 +#include <linux/rcupdate.h>
12231 +struct super_block;
12234 + struct hlist_node dl_hlist; /* linked list of contexts */
12235 + struct rcu_head dl_rcu; /* the rcu head */
12236 + tag_t dl_tag; /* context tag */
12237 + atomic_t dl_usecnt; /* usage count */
12238 + atomic_t dl_refcnt; /* reference count */
12240 + struct super_block *dl_sb; /* associated superblock */
12242 + spinlock_t dl_lock; /* protect the values */
12244 + unsigned long long dl_space_used; /* used space in bytes */
12245 + unsigned long long dl_space_total; /* maximum space in bytes */
12246 + unsigned long dl_inodes_used; /* used inodes */
12247 + unsigned long dl_inodes_total; /* maximum inodes */
12249 + unsigned int dl_nrlmult; /* non root limit mult */
12254 +extern void rcu_free_dl_info(struct rcu_head *);
12255 +extern void unhash_dl_info(struct dl_info *);
12257 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12262 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12264 +typedef uint64_t dlsize_t;
12266 +#endif /* __KERNEL__ */
12267 +#else /* _VX_DLIMIT_H */
12268 +#warning duplicate inclusion
12269 +#endif /* _VX_DLIMIT_H */
12270 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/dlimit_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/dlimit_cmd.h
12271 --- linux-3.1.1/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12272 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/dlimit_cmd.h 2011-10-24 18:53:33.000000000 +0200
12274 +#ifndef _VX_DLIMIT_CMD_H
12275 +#define _VX_DLIMIT_CMD_H
12278 +/* dlimit vserver commands */
12280 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12281 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12283 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12284 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12286 +struct vcmd_ctx_dlimit_base_v0 {
12287 + const char __user *name;
12291 +struct vcmd_ctx_dlimit_v0 {
12292 + const char __user *name;
12293 + uint32_t space_used; /* used space in kbytes */
12294 + uint32_t space_total; /* maximum space in kbytes */
12295 + uint32_t inodes_used; /* used inodes */
12296 + uint32_t inodes_total; /* maximum inodes */
12297 + uint32_t reserved; /* reserved for root in % */
12301 +#define CDLIM_UNSET ((uint32_t)0UL)
12302 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12303 +#define CDLIM_KEEP ((uint32_t)~1UL)
12305 +#define DLIME_UNIT 0
12306 +#define DLIME_KILO 1
12307 +#define DLIME_MEGA 2
12308 +#define DLIME_GIGA 3
12310 +#define DLIMF_SHIFT 0x10
12312 +#define DLIMS_USED 0
12313 +#define DLIMS_TOTAL 2
12316 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12318 + int exp = (flags & DLIMF_SHIFT) ?
12319 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12320 + return ((uint64_t)val) << (10 * exp);
12324 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12328 + if (*flags & DLIMF_SHIFT) {
12329 + while (val > (1LL << 32) && (exp < 3)) {
12333 + *flags &= ~(DLIME_GIGA << shift);
12334 + *flags |= exp << shift;
12342 +#ifdef CONFIG_COMPAT
12344 +#include <asm/compat.h>
12346 +struct vcmd_ctx_dlimit_base_v0_x32 {
12347 + compat_uptr_t name_ptr;
12351 +struct vcmd_ctx_dlimit_v0_x32 {
12352 + compat_uptr_t name_ptr;
12353 + uint32_t space_used; /* used space in kbytes */
12354 + uint32_t space_total; /* maximum space in kbytes */
12355 + uint32_t inodes_used; /* used inodes */
12356 + uint32_t inodes_total; /* maximum inodes */
12357 + uint32_t reserved; /* reserved for root in % */
12361 +#endif /* CONFIG_COMPAT */
12363 +#include <linux/compiler.h>
12365 +extern int vc_add_dlimit(uint32_t, void __user *);
12366 +extern int vc_rem_dlimit(uint32_t, void __user *);
12368 +extern int vc_set_dlimit(uint32_t, void __user *);
12369 +extern int vc_get_dlimit(uint32_t, void __user *);
12371 +#ifdef CONFIG_COMPAT
12373 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12374 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12376 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12377 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12379 +#endif /* CONFIG_COMPAT */
12381 +#endif /* __KERNEL__ */
12382 +#endif /* _VX_DLIMIT_CMD_H */
12383 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/global.h linux-3.1.1-vs2.3.2/include/linux/vserver/global.h
12384 --- linux-3.1.1/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12385 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/global.h 2011-10-24 18:53:33.000000000 +0200
12387 +#ifndef _VX_GLOBAL_H
12388 +#define _VX_GLOBAL_H
12391 +extern atomic_t vx_global_ctotal;
12392 +extern atomic_t vx_global_cactive;
12394 +extern atomic_t nx_global_ctotal;
12395 +extern atomic_t nx_global_cactive;
12397 +extern atomic_t vs_global_nsproxy;
12398 +extern atomic_t vs_global_fs;
12399 +extern atomic_t vs_global_mnt_ns;
12400 +extern atomic_t vs_global_uts_ns;
12401 +extern atomic_t vs_global_user_ns;
12402 +extern atomic_t vs_global_pid_ns;
12405 +#endif /* _VX_GLOBAL_H */
12406 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/history.h linux-3.1.1-vs2.3.2/include/linux/vserver/history.h
12407 --- linux-3.1.1/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12408 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/history.h 2011-10-24 18:53:33.000000000 +0200
12410 +#ifndef _VX_HISTORY_H
12411 +#define _VX_HISTORY_H
12416 + VXH_THROW_OOPS = 1,
12420 + VXH_INIT_VX_INFO,
12423 + VXH_CLAIM_VX_INFO,
12424 + VXH_RELEASE_VX_INFO,
12425 + VXH_ALLOC_VX_INFO,
12426 + VXH_DEALLOC_VX_INFO,
12427 + VXH_HASH_VX_INFO,
12428 + VXH_UNHASH_VX_INFO,
12430 + VXH_LOOKUP_VX_INFO,
12431 + VXH_CREATE_VX_INFO,
12434 +struct _vxhe_vxi {
12435 + struct vx_info *ptr;
12441 +struct _vxhe_set_clr {
12445 +struct _vxhe_loc_lookup {
12449 +struct _vx_hist_entry {
12451 + unsigned short seq;
12452 + unsigned short type;
12453 + struct _vxhe_vxi vxi;
12455 + struct _vxhe_set_clr sc;
12456 + struct _vxhe_loc_lookup ll;
12460 +#ifdef CONFIG_VSERVER_HISTORY
12462 +extern unsigned volatile int vxh_active;
12464 +struct _vx_hist_entry *vxh_advance(void *loc);
12468 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12470 + entry->vxi.ptr = vxi;
12472 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12473 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12474 + entry->vxi.xid = vxi->vx_id;
12479 +#define __HERE__ current_text_addr()
12481 +#define __VXH_BODY(__type, __data, __here) \
12482 + struct _vx_hist_entry *entry; \
12484 + preempt_disable(); \
12485 + entry = vxh_advance(__here); \
12487 + entry->type = __type; \
12488 + preempt_enable();
12491 + /* pass vxi only */
12493 +#define __VXH_SMPL \
12494 + __vxh_copy_vxi(entry, vxi)
12497 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12499 + __VXH_BODY(__type, __VXH_SMPL, __here)
12502 + /* pass vxi and data (void *) */
12504 +#define __VXH_DATA \
12505 + __vxh_copy_vxi(entry, vxi); \
12506 + entry->sc.data = data
12509 +void __vxh_data(struct vx_info *vxi, void *data,
12510 + int __type, void *__here)
12512 + __VXH_BODY(__type, __VXH_DATA, __here)
12515 + /* pass vxi and arg (long) */
12517 +#define __VXH_LONG \
12518 + __vxh_copy_vxi(entry, vxi); \
12519 + entry->ll.arg = arg
12522 +void __vxh_long(struct vx_info *vxi, long arg,
12523 + int __type, void *__here)
12525 + __VXH_BODY(__type, __VXH_LONG, __here)
12530 +void __vxh_throw_oops(void *__here)
12532 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12533 + /* prevent further acquisition */
12538 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12540 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12541 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12543 +#define __vxh_init_vx_info(v, d, h) \
12544 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12545 +#define __vxh_set_vx_info(v, d, h) \
12546 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12547 +#define __vxh_clr_vx_info(v, d, h) \
12548 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12550 +#define __vxh_claim_vx_info(v, d, h) \
12551 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12552 +#define __vxh_release_vx_info(v, d, h) \
12553 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12555 +#define vxh_alloc_vx_info(v) \
12556 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12557 +#define vxh_dealloc_vx_info(v) \
12558 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12560 +#define vxh_hash_vx_info(v) \
12561 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12562 +#define vxh_unhash_vx_info(v) \
12563 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12565 +#define vxh_loc_vx_info(v, l) \
12566 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12567 +#define vxh_lookup_vx_info(v, l) \
12568 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12569 +#define vxh_create_vx_info(v, l) \
12570 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12572 +extern void vxh_dump_history(void);
12575 +#else /* CONFIG_VSERVER_HISTORY */
12577 +#define __HERE__ 0
12579 +#define vxh_throw_oops() do { } while (0)
12581 +#define __vxh_get_vx_info(v, h) do { } while (0)
12582 +#define __vxh_put_vx_info(v, h) do { } while (0)
12584 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12585 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12586 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12588 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12589 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12591 +#define vxh_alloc_vx_info(v) do { } while (0)
12592 +#define vxh_dealloc_vx_info(v) do { } while (0)
12594 +#define vxh_hash_vx_info(v) do { } while (0)
12595 +#define vxh_unhash_vx_info(v) do { } while (0)
12597 +#define vxh_loc_vx_info(v, l) do { } while (0)
12598 +#define vxh_lookup_vx_info(v, l) do { } while (0)
12599 +#define vxh_create_vx_info(v, l) do { } while (0)
12601 +#define vxh_dump_history() do { } while (0)
12604 +#endif /* CONFIG_VSERVER_HISTORY */
12606 +#endif /* _VX_HISTORY_H */
12607 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/inode.h linux-3.1.1-vs2.3.2/include/linux/vserver/inode.h
12608 --- linux-3.1.1/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
12609 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/inode.h 2011-10-24 18:53:33.000000000 +0200
12611 +#ifndef _VX_INODE_H
12612 +#define _VX_INODE_H
12615 +#define IATTR_TAG 0x01000000
12617 +#define IATTR_ADMIN 0x00000001
12618 +#define IATTR_WATCH 0x00000002
12619 +#define IATTR_HIDE 0x00000004
12620 +#define IATTR_FLAGS 0x00000007
12622 +#define IATTR_BARRIER 0x00010000
12623 +#define IATTR_IXUNLINK 0x00020000
12624 +#define IATTR_IMMUTABLE 0x00040000
12625 +#define IATTR_COW 0x00080000
12630 +#ifdef CONFIG_VSERVER_PROC_SECURE
12631 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12632 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12634 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12635 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12638 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12640 +#endif /* __KERNEL__ */
12642 +/* inode ioctls */
12644 +#define FIOC_GETXFLG _IOR('x', 5, long)
12645 +#define FIOC_SETXFLG _IOW('x', 6, long)
12647 +#else /* _VX_INODE_H */
12648 +#warning duplicate inclusion
12649 +#endif /* _VX_INODE_H */
12650 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/inode_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/inode_cmd.h
12651 --- linux-3.1.1/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
12652 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/inode_cmd.h 2011-10-24 18:53:33.000000000 +0200
12654 +#ifndef _VX_INODE_CMD_H
12655 +#define _VX_INODE_CMD_H
12658 +/* inode vserver commands */
12660 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12661 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12663 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12664 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12666 +struct vcmd_ctx_iattr_v1 {
12667 + const char __user *name;
12673 +struct vcmd_ctx_fiattr_v0 {
12683 +#ifdef CONFIG_COMPAT
12685 +#include <asm/compat.h>
12687 +struct vcmd_ctx_iattr_v1_x32 {
12688 + compat_uptr_t name_ptr;
12694 +#endif /* CONFIG_COMPAT */
12696 +#include <linux/compiler.h>
12698 +extern int vc_get_iattr(void __user *);
12699 +extern int vc_set_iattr(void __user *);
12701 +extern int vc_fget_iattr(uint32_t, void __user *);
12702 +extern int vc_fset_iattr(uint32_t, void __user *);
12704 +#ifdef CONFIG_COMPAT
12706 +extern int vc_get_iattr_x32(void __user *);
12707 +extern int vc_set_iattr_x32(void __user *);
12709 +#endif /* CONFIG_COMPAT */
12711 +#endif /* __KERNEL__ */
12712 +#endif /* _VX_INODE_CMD_H */
12713 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/limit.h linux-3.1.1-vs2.3.2/include/linux/vserver/limit.h
12714 --- linux-3.1.1/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12715 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/limit.h 2011-10-24 18:53:33.000000000 +0200
12717 +#ifndef _VX_LIMIT_H
12718 +#define _VX_LIMIT_H
12720 +#define VLIMIT_NSOCK 16
12721 +#define VLIMIT_OPENFD 17
12722 +#define VLIMIT_ANON 18
12723 +#define VLIMIT_SHMEM 19
12724 +#define VLIMIT_SEMARY 20
12725 +#define VLIMIT_NSEMS 21
12726 +#define VLIMIT_DENTRY 22
12727 +#define VLIMIT_MAPPED 23
12732 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12734 +/* keep in sync with CRLIM_INFINITY */
12736 +#define VLIM_INFINITY (~0ULL)
12738 +#include <asm/atomic.h>
12739 +#include <asm/resource.h>
12741 +#ifndef RLIM_INFINITY
12742 +#warning RLIM_INFINITY is undefined
12745 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12747 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12748 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12750 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12751 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12752 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12754 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12755 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12757 +typedef atomic_long_t rlim_atomic_t;
12758 +typedef unsigned long rlim_t;
12760 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12761 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12762 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12763 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12764 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12765 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12768 +#if (RLIM_INFINITY == VLIM_INFINITY)
12769 +#define VX_VLIM(r) ((long long)(long)(r))
12770 +#define VX_RLIM(v) ((rlim_t)(v))
12772 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12773 + ? VLIM_INFINITY : (long long)(r))
12774 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12775 + ? RLIM_INFINITY : (rlim_t)(v))
12780 +void vx_vsi_meminfo(struct sysinfo *);
12781 +void vx_vsi_swapinfo(struct sysinfo *);
12782 +long vx_vsi_cached(struct sysinfo *);
12784 +#define NUM_LIMITS 24
12786 +#endif /* __KERNEL__ */
12787 +#endif /* _VX_LIMIT_H */
12788 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/limit_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/limit_cmd.h
12789 --- linux-3.1.1/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12790 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/limit_cmd.h 2011-10-24 18:53:33.000000000 +0200
12792 +#ifndef _VX_LIMIT_CMD_H
12793 +#define _VX_LIMIT_CMD_H
12796 +/* rlimit vserver commands */
12798 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12799 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12800 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12801 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
12802 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12804 +struct vcmd_ctx_rlimit_v0 {
12806 + uint64_t minimum;
12807 + uint64_t softlimit;
12808 + uint64_t maximum;
12811 +struct vcmd_ctx_rlimit_mask_v0 {
12812 + uint32_t minimum;
12813 + uint32_t softlimit;
12814 + uint32_t maximum;
12817 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12819 +struct vcmd_rlimit_stat_v0 {
12823 + uint64_t minimum;
12824 + uint64_t maximum;
12827 +#define CRLIM_UNSET (0ULL)
12828 +#define CRLIM_INFINITY (~0ULL)
12829 +#define CRLIM_KEEP (~1ULL)
12833 +#ifdef CONFIG_IA32_EMULATION
12835 +struct vcmd_ctx_rlimit_v0_x32 {
12837 + uint64_t minimum;
12838 + uint64_t softlimit;
12839 + uint64_t maximum;
12840 +} __attribute__ ((packed));
12842 +#endif /* CONFIG_IA32_EMULATION */
12844 +#include <linux/compiler.h>
12846 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12847 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12848 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12849 +extern int vc_reset_hits(struct vx_info *, void __user *);
12850 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12852 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12854 +#ifdef CONFIG_IA32_EMULATION
12856 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12857 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12859 +#endif /* CONFIG_IA32_EMULATION */
12861 +#endif /* __KERNEL__ */
12862 +#endif /* _VX_LIMIT_CMD_H */
12863 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/limit_def.h linux-3.1.1-vs2.3.2/include/linux/vserver/limit_def.h
12864 --- linux-3.1.1/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12865 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/limit_def.h 2011-10-24 18:53:33.000000000 +0200
12867 +#ifndef _VX_LIMIT_DEF_H
12868 +#define _VX_LIMIT_DEF_H
12870 +#include <asm/atomic.h>
12871 +#include <asm/resource.h>
12873 +#include "limit.h"
12876 +struct _vx_res_limit {
12877 + rlim_t soft; /* Context soft limit */
12878 + rlim_t hard; /* Context hard limit */
12880 + rlim_atomic_t rcur; /* Current value */
12881 + rlim_t rmin; /* Context minimum */
12882 + rlim_t rmax; /* Context maximum */
12884 + atomic_t lhit; /* Limit hits */
12887 +/* context sub struct */
12889 +struct _vx_limit {
12890 + struct _vx_res_limit res[NUM_LIMITS];
12893 +#ifdef CONFIG_VSERVER_DEBUG
12895 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12899 + printk("\t_vx_limit:");
12900 + for (i = 0; i < NUM_LIMITS; i++) {
12901 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12902 + i, (unsigned long)__rlim_get(limit, i),
12903 + (unsigned long)__rlim_rmin(limit, i),
12904 + (unsigned long)__rlim_rmax(limit, i),
12905 + (long)__rlim_soft(limit, i),
12906 + (long)__rlim_hard(limit, i),
12907 + atomic_read(&__rlim_lhit(limit, i)));
12913 +#endif /* _VX_LIMIT_DEF_H */
12914 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/limit_int.h linux-3.1.1-vs2.3.2/include/linux/vserver/limit_int.h
12915 --- linux-3.1.1/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12916 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/limit_int.h 2011-10-24 18:53:33.000000000 +0200
12918 +#ifndef _VX_LIMIT_INT_H
12919 +#define _VX_LIMIT_INT_H
12921 +#include "context.h"
12925 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12926 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12928 +extern const char *vlimit_name[NUM_LIMITS];
12930 +static inline void __vx_acc_cres(struct vx_info *vxi,
12931 + int res, int dir, void *_data, char *_file, int _line)
12933 + if (VXD_RCRES_COND(res))
12934 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12935 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12936 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12937 + (dir > 0) ? "++" : "--", _data, _file, _line);
12942 + __rlim_inc(&vxi->limit, res);
12944 + __rlim_dec(&vxi->limit, res);
12947 +static inline void __vx_add_cres(struct vx_info *vxi,
12948 + int res, int amount, void *_data, char *_file, int _line)
12950 + if (VXD_RCRES_COND(res))
12951 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12952 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12953 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12954 + amount, _data, _file, _line);
12959 + __rlim_add(&vxi->limit, res, amount);
12963 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12965 + int cond = (value > __rlim_rmax(limit, res));
12968 + __rlim_rmax(limit, res) = value;
12973 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12975 + int cond = (value < __rlim_rmin(limit, res));
12978 + __rlim_rmin(limit, res) = value;
12983 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12985 + if (!__vx_cres_adjust_max(limit, res, value))
12986 + __vx_cres_adjust_min(limit, res, value);
12991 + +1 ... no limit hit
12992 + -1 ... over soft limit
12993 + 0 ... over hard limit */
12995 +static inline int __vx_cres_avail(struct vx_info *vxi,
12996 + int res, int num, char *_file, int _line)
12998 + struct _vx_limit *limit;
13001 + if (VXD_RLIMIT_COND(res))
13002 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
13003 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
13004 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
13005 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
13006 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
13007 + num, _file, _line);
13011 + limit = &vxi->limit;
13012 + value = __rlim_get(limit, res);
13014 + if (!__vx_cres_adjust_max(limit, res, value))
13015 + __vx_cres_adjust_min(limit, res, value);
13020 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
13022 + if (value + num <= __rlim_soft(limit, res))
13025 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
13027 + if (value + num <= __rlim_hard(limit, res))
13030 + __rlim_hit(limit, res);
13035 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
13038 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
13040 + rlim_t value, sum = 0;
13043 + while ((res = *array++)) {
13044 + value = __rlim_get(limit, res);
13045 + __vx_cres_fixup(limit, res, value);
13052 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
13054 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
13055 + int res = *array;
13057 + if (value == __rlim_get(limit, res))
13060 + __rlim_set(limit, res, value);
13061 + /* now adjust min/max */
13062 + if (!__vx_cres_adjust_max(limit, res, value))
13063 + __vx_cres_adjust_min(limit, res, value);
13068 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
13069 + const int *array, int num, char *_file, int _line)
13071 + struct _vx_limit *limit;
13072 + rlim_t value = 0;
13080 + limit = &vxi->limit;
13082 + value = __vx_cres_array_sum(limit, array + 1);
13084 + __rlim_set(limit, res, value);
13085 + __vx_cres_fixup(limit, res, value);
13087 + return __vx_cres_avail(vxi, res, num, _file, _line);
13091 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
13096 + /* complex resources first */
13097 + if ((id < 0) || (id == RLIMIT_RSS))
13098 + __vx_cres_array_fixup(limit, VLA_RSS);
13100 + for (res = 0; res < NUM_LIMITS; res++) {
13101 + if ((id > 0) && (res != id))
13104 + value = __rlim_get(limit, res);
13105 + __vx_cres_fixup(limit, res, value);
13107 + /* not supposed to happen, maybe warn? */
13108 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
13109 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
13114 +#endif /* __KERNEL__ */
13115 +#endif /* _VX_LIMIT_INT_H */
13116 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/monitor.h linux-3.1.1-vs2.3.2/include/linux/vserver/monitor.h
13117 --- linux-3.1.1/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
13118 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/monitor.h 2011-10-24 18:53:33.000000000 +0200
13120 +#ifndef _VX_MONITOR_H
13121 +#define _VX_MONITOR_H
13123 +#include <linux/types.h>
13130 + VXM_UPDATE = 0x20,
13134 + VXM_RQINFO_1 = 0x24,
13137 + VXM_ACTIVATE = 0x40,
13144 + VXM_MIGRATE = 0x48,
13147 + /* all other bits are flags */
13148 + VXM_SCHED = 0x80,
13151 +struct _vxm_update_1 {
13152 + uint32_t tokens_max;
13153 + uint32_t fill_rate;
13154 + uint32_t interval;
13157 +struct _vxm_update_2 {
13158 + uint32_t tokens_min;
13159 + uint32_t fill_rate;
13160 + uint32_t interval;
13163 +struct _vxm_rqinfo_1 {
13164 + uint16_t running;
13168 + uint32_t idle_tokens;
13171 +struct _vxm_rqinfo_2 {
13172 + uint32_t norm_time;
13173 + uint32_t idle_time;
13174 + uint32_t idle_skip;
13177 +struct _vxm_sched {
13179 + uint32_t norm_time;
13180 + uint32_t idle_time;
13183 +struct _vxm_task {
13188 +struct _vxm_event {
13197 + struct _vxm_task tsk;
13201 +struct _vx_mon_entry {
13205 + struct _vxm_event ev;
13206 + struct _vxm_sched sd;
13207 + struct _vxm_update_1 u1;
13208 + struct _vxm_update_2 u2;
13209 + struct _vxm_rqinfo_1 q1;
13210 + struct _vxm_rqinfo_2 q2;
13215 +#endif /* _VX_MONITOR_H */
13216 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/network.h linux-3.1.1-vs2.3.2/include/linux/vserver/network.h
13217 --- linux-3.1.1/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
13218 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/network.h 2011-10-24 18:53:33.000000000 +0200
13220 +#ifndef _VX_NETWORK_H
13221 +#define _VX_NETWORK_H
13223 +#include <linux/types.h>
13226 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13229 +/* network flags */
13231 +#define NXF_INFO_PRIVATE 0x00000008
13233 +#define NXF_SINGLE_IP 0x00000100
13234 +#define NXF_LBACK_REMAP 0x00000200
13235 +#define NXF_LBACK_ALLOW 0x00000400
13237 +#define NXF_HIDE_NETIF 0x02000000
13238 +#define NXF_HIDE_LBACK 0x04000000
13240 +#define NXF_STATE_SETUP (1ULL << 32)
13241 +#define NXF_STATE_ADMIN (1ULL << 34)
13243 +#define NXF_SC_HELPER (1ULL << 36)
13244 +#define NXF_PERSISTENT (1ULL << 38)
13246 +#define NXF_ONE_TIME (0x0005ULL << 32)
13249 +#define NXF_INIT_SET (__nxf_init_set())
13251 +static inline uint64_t __nxf_init_set(void) {
13252 + return NXF_STATE_ADMIN
13253 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13254 + | NXF_LBACK_REMAP
13257 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13260 + | NXF_HIDE_NETIF;
13264 +/* network caps */
13266 +#define NXC_TUN_CREATE 0x00000001
13268 +#define NXC_RAW_ICMP 0x00000100
13270 +#define NXC_MULTICAST 0x00001000
13273 +/* address types */
13275 +#define NXA_TYPE_IPV4 0x0001
13276 +#define NXA_TYPE_IPV6 0x0002
13278 +#define NXA_TYPE_NONE 0x0000
13279 +#define NXA_TYPE_ANY 0x00FF
13281 +#define NXA_TYPE_ADDR 0x0010
13282 +#define NXA_TYPE_MASK 0x0020
13283 +#define NXA_TYPE_RANGE 0x0040
13285 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13287 +#define NXA_MOD_BCAST 0x0100
13288 +#define NXA_MOD_LBACK 0x0200
13290 +#define NXA_LOOPBACK 0x1000
13292 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13293 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13297 +#include <linux/list.h>
13298 +#include <linux/spinlock.h>
13299 +#include <linux/rcupdate.h>
13300 +#include <linux/in.h>
13301 +#include <linux/in6.h>
13302 +#include <asm/atomic.h>
13304 +struct nx_addr_v4 {
13305 + struct nx_addr_v4 *next;
13306 + struct in_addr ip[2];
13307 + struct in_addr mask;
13312 +struct nx_addr_v6 {
13313 + struct nx_addr_v6 *next;
13314 + struct in6_addr ip;
13315 + struct in6_addr mask;
13322 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13323 + nid_t nx_id; /* vnet id */
13324 + atomic_t nx_usecnt; /* usage count */
13325 + atomic_t nx_tasks; /* tasks count */
13326 + int nx_state; /* context state */
13328 + uint64_t nx_flags; /* network flag word */
13329 + uint64_t nx_ncaps; /* network capabilities */
13331 + struct in_addr v4_lback; /* Loopback address */
13332 + struct in_addr v4_bcast; /* Broadcast address */
13333 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13334 +#ifdef CONFIG_IPV6
13335 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13337 + char nx_name[65]; /* network context name */
13341 +/* status flags */
13343 +#define NXS_HASHED 0x0001
13344 +#define NXS_SHUTDOWN 0x0100
13345 +#define NXS_RELEASED 0x8000
13347 +extern struct nx_info *lookup_nx_info(int);
13349 +extern int get_nid_list(int, unsigned int *, int);
13350 +extern int nid_is_hashed(nid_t);
13352 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13354 +extern long vs_net_change(struct nx_info *, unsigned int);
13359 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13360 +#ifdef CONFIG_IPV6
13361 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13363 +#define NX_IPV6(n) (0)
13366 +#endif /* __KERNEL__ */
13367 +#endif /* _VX_NETWORK_H */
13368 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/network_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/network_cmd.h
13369 --- linux-3.1.1/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13370 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/network_cmd.h 2011-10-24 18:53:33.000000000 +0200
13372 +#ifndef _VX_NETWORK_CMD_H
13373 +#define _VX_NETWORK_CMD_H
13376 +/* vinfo commands */
13378 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13381 +extern int vc_task_nid(uint32_t);
13383 +#endif /* __KERNEL__ */
13385 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13387 +struct vcmd_nx_info_v0 {
13389 + /* more to come */
13393 +extern int vc_nx_info(struct nx_info *, void __user *);
13395 +#endif /* __KERNEL__ */
13397 +#include <linux/in.h>
13398 +#include <linux/in6.h>
13400 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13401 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13403 +struct vcmd_net_create {
13404 + uint64_t flagword;
13407 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13409 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13410 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13412 +struct vcmd_net_addr_v0 {
13415 + struct in_addr ip[4];
13416 + struct in_addr mask[4];
13419 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13420 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13422 +struct vcmd_net_addr_ipv4_v1 {
13425 + struct in_addr ip;
13426 + struct in_addr mask;
13429 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13430 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13432 +struct vcmd_net_addr_ipv4_v2 {
13435 + struct in_addr ip;
13436 + struct in_addr ip2;
13437 + struct in_addr mask;
13440 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13441 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13443 +struct vcmd_net_addr_ipv6_v1 {
13447 + struct in6_addr ip;
13448 + struct in6_addr mask;
13451 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13452 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13454 +struct vcmd_match_ipv4_v0 {
13459 + struct in_addr ip;
13460 + struct in_addr ip2;
13461 + struct in_addr mask;
13464 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13465 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13467 +struct vcmd_match_ipv6_v0 {
13472 + struct in6_addr ip;
13473 + struct in6_addr ip2;
13474 + struct in6_addr mask;
13479 +extern int vc_net_create(uint32_t, void __user *);
13480 +extern int vc_net_migrate(struct nx_info *, void __user *);
13482 +extern int vc_net_add(struct nx_info *, void __user *);
13483 +extern int vc_net_remove(struct nx_info *, void __user *);
13485 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
13486 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13488 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
13489 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
13491 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13492 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13494 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13495 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13497 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13498 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13500 +#endif /* __KERNEL__ */
13503 +/* flag commands */
13505 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13506 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13508 +struct vcmd_net_flags_v0 {
13509 + uint64_t flagword;
13514 +extern int vc_get_nflags(struct nx_info *, void __user *);
13515 +extern int vc_set_nflags(struct nx_info *, void __user *);
13517 +#endif /* __KERNEL__ */
13520 +/* network caps commands */
13522 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13523 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13525 +struct vcmd_net_caps_v0 {
13531 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13532 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13534 +#endif /* __KERNEL__ */
13535 +#endif /* _VX_CONTEXT_CMD_H */
13536 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/percpu.h linux-3.1.1-vs2.3.2/include/linux/vserver/percpu.h
13537 --- linux-3.1.1/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13538 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/percpu.h 2011-10-24 18:53:33.000000000 +0200
13540 +#ifndef _VX_PERCPU_H
13541 +#define _VX_PERCPU_H
13543 +#include "cvirt_def.h"
13544 +#include "sched_def.h"
13546 +struct _vx_percpu {
13547 + struct _vx_cvirt_pc cvirt;
13548 + struct _vx_sched_pc sched;
13551 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13553 +#endif /* _VX_PERCPU_H */
13554 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/pid.h linux-3.1.1-vs2.3.2/include/linux/vserver/pid.h
13555 --- linux-3.1.1/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13556 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/pid.h 2011-10-24 18:53:33.000000000 +0200
13558 +#ifndef _VSERVER_PID_H
13559 +#define _VSERVER_PID_H
13561 +/* pid faking stuff */
13563 +#define vx_info_map_pid(v, p) \
13564 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13565 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13566 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13567 +#define vx_map_tgid(p) vx_map_pid(p)
13569 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13570 + const char *func, const char *file, int line)
13572 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13573 + vxfprintk(VXD_CBIT(cvirt, 2),
13574 + "vx_map_tgid: %p/%llx: %d -> %d",
13575 + vxi, (long long)vxi->vx_flags, pid,
13576 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13577 + func, file, line);
13580 + if (pid == vxi->vx_initpid)
13586 +#define vx_info_rmap_pid(v, p) \
13587 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13588 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13589 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13591 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13592 + const char *func, const char *file, int line)
13594 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13595 + vxfprintk(VXD_CBIT(cvirt, 2),
13596 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13597 + vxi, (long long)vxi->vx_flags, pid,
13598 + (pid == 1) ? vxi->vx_initpid : pid,
13599 + func, file, line);
13600 + if ((pid == 1) && vxi->vx_initpid)
13601 + return vxi->vx_initpid;
13602 + if (pid == vxi->vx_initpid)
13609 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/sched.h linux-3.1.1-vs2.3.2/include/linux/vserver/sched.h
13610 --- linux-3.1.1/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13611 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/sched.h 2011-10-24 18:53:33.000000000 +0200
13613 +#ifndef _VX_SCHED_H
13614 +#define _VX_SCHED_H
13621 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13626 +void vx_update_load(struct vx_info *);
13629 +void vx_update_sched_param(struct _vx_sched *sched,
13630 + struct _vx_sched_pc *sched_pc);
13632 +#endif /* __KERNEL__ */
13633 +#else /* _VX_SCHED_H */
13634 +#warning duplicate inclusion
13635 +#endif /* _VX_SCHED_H */
13636 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/sched_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/sched_cmd.h
13637 --- linux-3.1.1/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
13638 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/sched_cmd.h 2011-10-24 18:53:33.000000000 +0200
13640 +#ifndef _VX_SCHED_CMD_H
13641 +#define _VX_SCHED_CMD_H
13644 +struct vcmd_prio_bias {
13646 + int32_t prio_bias;
13649 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13650 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13654 +#include <linux/compiler.h>
13656 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
13657 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
13659 +#endif /* __KERNEL__ */
13660 +#endif /* _VX_SCHED_CMD_H */
13661 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/sched_def.h linux-3.1.1-vs2.3.2/include/linux/vserver/sched_def.h
13662 --- linux-3.1.1/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13663 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/sched_def.h 2011-10-24 18:53:33.000000000 +0200
13665 +#ifndef _VX_SCHED_DEF_H
13666 +#define _VX_SCHED_DEF_H
13668 +#include <linux/spinlock.h>
13669 +#include <linux/jiffies.h>
13670 +#include <linux/cpumask.h>
13671 +#include <asm/atomic.h>
13672 +#include <asm/param.h>
13675 +/* context sub struct */
13677 +struct _vx_sched {
13678 + int prio_bias; /* bias offset for priority */
13680 + cpumask_t update; /* CPUs which should update */
13683 +struct _vx_sched_pc {
13684 + int prio_bias; /* bias offset for priority */
13686 + uint64_t user_ticks; /* token tick events */
13687 + uint64_t sys_ticks; /* token tick events */
13688 + uint64_t hold_ticks; /* token ticks paused */
13692 +#ifdef CONFIG_VSERVER_DEBUG
13694 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13696 + printk("\t_vx_sched:\n");
13697 + printk("\t priority = %4d\n", sched->prio_bias);
13702 +#endif /* _VX_SCHED_DEF_H */
13703 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/signal.h linux-3.1.1-vs2.3.2/include/linux/vserver/signal.h
13704 --- linux-3.1.1/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13705 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/signal.h 2011-10-24 18:53:33.000000000 +0200
13707 +#ifndef _VX_SIGNAL_H
13708 +#define _VX_SIGNAL_H
13715 +int vx_info_kill(struct vx_info *, int, int);
13717 +#endif /* __KERNEL__ */
13718 +#else /* _VX_SIGNAL_H */
13719 +#warning duplicate inclusion
13720 +#endif /* _VX_SIGNAL_H */
13721 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/signal_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/signal_cmd.h
13722 --- linux-3.1.1/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13723 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/signal_cmd.h 2011-10-24 18:53:33.000000000 +0200
13725 +#ifndef _VX_SIGNAL_CMD_H
13726 +#define _VX_SIGNAL_CMD_H
13729 +/* signalling vserver commands */
13731 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13732 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13734 +struct vcmd_ctx_kill_v0 {
13739 +struct vcmd_wait_exit_v0 {
13740 + int32_t reboot_cmd;
13741 + int32_t exit_code;
13746 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13747 +extern int vc_wait_exit(struct vx_info *, void __user *);
13749 +#endif /* __KERNEL__ */
13751 +/* process alteration commands */
13753 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13754 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13756 +struct vcmd_pflags_v0 {
13757 + uint32_t flagword;
13763 +extern int vc_get_pflags(uint32_t pid, void __user *);
13764 +extern int vc_set_pflags(uint32_t pid, void __user *);
13766 +#endif /* __KERNEL__ */
13767 +#endif /* _VX_SIGNAL_CMD_H */
13768 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/space.h linux-3.1.1-vs2.3.2/include/linux/vserver/space.h
13769 --- linux-3.1.1/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13770 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/space.h 2011-10-24 18:53:33.000000000 +0200
13772 +#ifndef _VX_SPACE_H
13773 +#define _VX_SPACE_H
13775 +#include <linux/types.h>
13779 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13781 +#else /* _VX_SPACE_H */
13782 +#warning duplicate inclusion
13783 +#endif /* _VX_SPACE_H */
13784 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/space_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/space_cmd.h
13785 --- linux-3.1.1/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13786 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/space_cmd.h 2011-10-24 18:53:33.000000000 +0200
13788 +#ifndef _VX_SPACE_CMD_H
13789 +#define _VX_SPACE_CMD_H
13792 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13793 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13794 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13796 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13797 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13798 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13800 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13802 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13803 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13806 +struct vcmd_space_mask_v1 {
13810 +struct vcmd_space_mask_v2 {
13818 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13819 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13820 +extern int vc_enter_space(struct vx_info *, void __user *);
13821 +extern int vc_set_space(struct vx_info *, void __user *);
13822 +extern int vc_get_space_mask(void __user *, int);
13824 +#endif /* __KERNEL__ */
13825 +#endif /* _VX_SPACE_CMD_H */
13826 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/switch.h linux-3.1.1-vs2.3.2/include/linux/vserver/switch.h
13827 --- linux-3.1.1/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13828 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/switch.h 2011-10-24 18:53:33.000000000 +0200
13830 +#ifndef _VX_SWITCH_H
13831 +#define _VX_SWITCH_H
13833 +#include <linux/types.h>
13836 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13837 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13838 +#define VC_VERSION(c) ((c) & 0xFFF)
13840 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13841 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13845 + Syscall Matrix V2.8
13847 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13848 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13849 + |INFO |SETUP | |MOVE | | | | | |
13850 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13851 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13852 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13853 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13854 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13855 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13856 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13857 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13858 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13859 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13860 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13861 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13862 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13863 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13864 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13865 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13866 + OTHER |VSTAT | | | | | | |VINFO | |
13867 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13868 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13869 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13870 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13871 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13872 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13873 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13874 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13878 +#define VC_CAT_VERSION 0
13880 +#define VC_CAT_VSETUP 1
13881 +#define VC_CAT_VHOST 2
13883 +#define VC_CAT_DEVICE 6
13885 +#define VC_CAT_VPROC 9
13886 +#define VC_CAT_PROCALT 10
13887 +#define VC_CAT_PROCMIG 11
13888 +#define VC_CAT_PROCTRL 12
13890 +#define VC_CAT_SCHED 14
13891 +#define VC_CAT_MEMCTRL 20
13893 +#define VC_CAT_VNET 25
13894 +#define VC_CAT_NETALT 26
13895 +#define VC_CAT_NETMIG 27
13896 +#define VC_CAT_NETCTRL 28
13898 +#define VC_CAT_TAGMIG 35
13899 +#define VC_CAT_DLIMIT 36
13900 +#define VC_CAT_INODE 38
13902 +#define VC_CAT_VSTAT 40
13903 +#define VC_CAT_VINFO 46
13904 +#define VC_CAT_EVENT 48
13906 +#define VC_CAT_FLAGS 52
13907 +#define VC_CAT_VSPACE 54
13908 +#define VC_CAT_DEBUG 56
13909 +#define VC_CAT_RLIMIT 60
13911 +#define VC_CAT_SYSTEST 61
13912 +#define VC_CAT_COMPAT 63
13914 +/* query version */
13916 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13917 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13922 +#include <linux/errno.h>
13924 +#endif /* __KERNEL__ */
13926 +#endif /* _VX_SWITCH_H */
13928 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/tag.h linux-3.1.1-vs2.3.2/include/linux/vserver/tag.h
13929 --- linux-3.1.1/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13930 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/tag.h 2011-10-24 18:53:33.000000000 +0200
13935 +#include <linux/types.h>
13938 +#define DX_TAG(in) (IS_TAGGED(in))
13941 +#ifdef CONFIG_TAG_NFSD
13942 +#define DX_TAG_NFSD 1
13944 +#define DX_TAG_NFSD 0
13948 +#ifdef CONFIG_TAGGING_NONE
13950 +#define MAX_UID 0xFFFFFFFF
13951 +#define MAX_GID 0xFFFFFFFF
13953 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13955 +#define TAGINO_UID(cond, uid, tag) (uid)
13956 +#define TAGINO_GID(cond, gid, tag) (gid)
13961 +#ifdef CONFIG_TAGGING_GID16
13963 +#define MAX_UID 0xFFFFFFFF
13964 +#define MAX_GID 0x0000FFFF
13966 +#define INOTAG_TAG(cond, uid, gid, tag) \
13967 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13969 +#define TAGINO_UID(cond, uid, tag) (uid)
13970 +#define TAGINO_GID(cond, gid, tag) \
13971 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13976 +#ifdef CONFIG_TAGGING_ID24
13978 +#define MAX_UID 0x00FFFFFF
13979 +#define MAX_GID 0x00FFFFFF
13981 +#define INOTAG_TAG(cond, uid, gid, tag) \
13982 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13984 +#define TAGINO_UID(cond, uid, tag) \
13985 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13986 +#define TAGINO_GID(cond, gid, tag) \
13987 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13992 +#ifdef CONFIG_TAGGING_UID16
13994 +#define MAX_UID 0x0000FFFF
13995 +#define MAX_GID 0xFFFFFFFF
13997 +#define INOTAG_TAG(cond, uid, gid, tag) \
13998 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
14000 +#define TAGINO_UID(cond, uid, tag) \
14001 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
14002 +#define TAGINO_GID(cond, gid, tag) (gid)
14007 +#ifdef CONFIG_TAGGING_INTERN
14009 +#define MAX_UID 0xFFFFFFFF
14010 +#define MAX_GID 0xFFFFFFFF
14012 +#define INOTAG_TAG(cond, uid, gid, tag) \
14013 + ((cond) ? (tag) : 0)
14015 +#define TAGINO_UID(cond, uid, tag) (uid)
14016 +#define TAGINO_GID(cond, gid, tag) (gid)
14021 +#ifndef CONFIG_TAGGING_NONE
14022 +#define dx_current_fstag(sb) \
14023 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
14025 +#define dx_current_fstag(sb) (0)
14028 +#ifndef CONFIG_TAGGING_INTERN
14029 +#define TAGINO_TAG(cond, tag) (0)
14031 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
14034 +#define INOTAG_UID(cond, uid, gid) \
14035 + ((cond) ? ((uid) & MAX_UID) : (uid))
14036 +#define INOTAG_GID(cond, uid, gid) \
14037 + ((cond) ? ((gid) & MAX_GID) : (gid))
14040 +static inline uid_t dx_map_uid(uid_t uid)
14042 + if ((uid > MAX_UID) && (uid != -1))
14044 + return (uid & MAX_UID);
14047 +static inline gid_t dx_map_gid(gid_t gid)
14049 + if ((gid > MAX_GID) && (gid != -1))
14051 + return (gid & MAX_GID);
14059 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
14061 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
14062 + unsigned long *flags);
14064 +#ifdef CONFIG_PROPAGATE
14066 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
14068 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
14071 +#define dx_propagate_tag(n, i) do { } while (0)
14074 +#endif /* _DX_TAG_H */
14075 diff -NurpP --minimal linux-3.1.1/include/linux/vserver/tag_cmd.h linux-3.1.1-vs2.3.2/include/linux/vserver/tag_cmd.h
14076 --- linux-3.1.1/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
14077 +++ linux-3.1.1-vs2.3.2/include/linux/vserver/tag_cmd.h 2011-10-24 18:53:33.000000000 +0200
14079 +#ifndef _VX_TAG_CMD_H
14080 +#define _VX_TAG_CMD_H
14083 +/* vinfo commands */
14085 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
14088 +extern int vc_task_tag(uint32_t);
14090 +#endif /* __KERNEL__ */
14092 +/* context commands */
14094 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
14097 +extern int vc_tag_migrate(uint32_t);
14099 +#endif /* __KERNEL__ */
14100 +#endif /* _VX_TAG_CMD_H */
14101 diff -NurpP --minimal linux-3.1.1/include/net/addrconf.h linux-3.1.1-vs2.3.2/include/net/addrconf.h
14102 --- linux-3.1.1/include/net/addrconf.h 2011-07-22 11:18:11.000000000 +0200
14103 +++ linux-3.1.1-vs2.3.2/include/net/addrconf.h 2011-10-24 18:53:33.000000000 +0200
14104 @@ -80,7 +80,8 @@ extern int ipv6_dev_get_saddr(struct n
14105 struct net_device *dev,
14106 const struct in6_addr *daddr,
14107 unsigned int srcprefs,
14108 - struct in6_addr *saddr);
14109 + struct in6_addr *saddr,
14110 + struct nx_info *nxi);
14111 extern int ipv6_get_lladdr(struct net_device *dev,
14112 struct in6_addr *addr,
14113 unsigned char banned_flags);
14114 diff -NurpP --minimal linux-3.1.1/include/net/af_unix.h linux-3.1.1-vs2.3.2/include/net/af_unix.h
14115 --- linux-3.1.1/include/net/af_unix.h 2011-07-22 11:18:11.000000000 +0200
14116 +++ linux-3.1.1-vs2.3.2/include/net/af_unix.h 2011-10-24 18:53:33.000000000 +0200
14118 #include <linux/socket.h>
14119 #include <linux/un.h>
14120 #include <linux/mutex.h>
14121 +#include <linux/vs_base.h>
14122 #include <net/sock.h>
14124 extern void unix_inflight(struct file *fp);
14125 diff -NurpP --minimal linux-3.1.1/include/net/inet_timewait_sock.h linux-3.1.1-vs2.3.2/include/net/inet_timewait_sock.h
14126 --- linux-3.1.1/include/net/inet_timewait_sock.h 2011-10-24 18:45:32.000000000 +0200
14127 +++ linux-3.1.1-vs2.3.2/include/net/inet_timewait_sock.h 2011-10-24 18:53:33.000000000 +0200
14128 @@ -113,6 +113,10 @@ struct inet_timewait_sock {
14129 #define tw_net __tw_common.skc_net
14130 #define tw_daddr __tw_common.skc_daddr
14131 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
14132 +#define tw_xid __tw_common.skc_xid
14133 +#define tw_vx_info __tw_common.skc_vx_info
14134 +#define tw_nid __tw_common.skc_nid
14135 +#define tw_nx_info __tw_common.skc_nx_info
14137 volatile unsigned char tw_substate;
14138 unsigned char tw_rcv_wscale;
14139 diff -NurpP --minimal linux-3.1.1/include/net/ip6_route.h linux-3.1.1-vs2.3.2/include/net/ip6_route.h
14140 --- linux-3.1.1/include/net/ip6_route.h 2011-07-22 11:18:11.000000000 +0200
14141 +++ linux-3.1.1-vs2.3.2/include/net/ip6_route.h 2011-10-24 18:53:33.000000000 +0200
14142 @@ -86,7 +86,8 @@ extern int ip6_route_get_saddr(struct
14143 struct rt6_info *rt,
14144 const struct in6_addr *daddr,
14145 unsigned int prefs,
14146 - struct in6_addr *saddr);
14147 + struct in6_addr *saddr,
14148 + struct nx_info *nxi);
14150 extern struct rt6_info *rt6_lookup(struct net *net,
14151 const struct in6_addr *daddr,
14152 diff -NurpP --minimal linux-3.1.1/include/net/route.h linux-3.1.1-vs2.3.2/include/net/route.h
14153 --- linux-3.1.1/include/net/route.h 2011-07-22 11:18:11.000000000 +0200
14154 +++ linux-3.1.1-vs2.3.2/include/net/route.h 2011-10-24 18:53:33.000000000 +0200
14155 @@ -202,6 +202,9 @@ static inline void ip_rt_put(struct rtab
14156 dst_release(&rt->dst);
14159 +#include <linux/vs_base.h>
14160 +#include <linux/vs_inet.h>
14162 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
14164 extern const __u8 ip_tos2prio[16];
14165 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
14166 protocol, flow_flags, dst, src, dport, sport);
14169 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
14170 + struct flowi4 *);
14172 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
14173 __be32 dst, __be32 src, u32 tos,
14174 int oif, u8 protocol,
14175 @@ -261,11 +267,25 @@ static inline struct rtable *ip_route_co
14177 struct net *net = sock_net(sk);
14179 + struct nx_info *nx_info = current_nx_info();
14181 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
14182 sport, dport, sk, can_sleep);
14184 - if (!dst || !src) {
14186 + nx_info = sk->sk_nx_info;
14188 + vxdprintk(VXD_CBIT(net, 4),
14189 + "ip_route_connect(%p) %p,%p;%lx",
14190 + sk, nx_info, sk->sk_socket,
14191 + (sk->sk_socket?sk->sk_socket->flags:0));
14193 + rt = ip_v4_find_src(net, nx_info, fl4);
14198 + if (!fl4->daddr || !fl4->saddr) {
14199 rt = __ip_route_output_key(net, fl4);
14202 diff -NurpP --minimal linux-3.1.1/include/net/sock.h linux-3.1.1-vs2.3.2/include/net/sock.h
14203 --- linux-3.1.1/include/net/sock.h 2011-10-24 18:45:32.000000000 +0200
14204 +++ linux-3.1.1-vs2.3.2/include/net/sock.h 2011-10-24 18:53:33.000000000 +0200
14205 @@ -150,6 +150,10 @@ struct sock_common {
14206 #ifdef CONFIG_NET_NS
14207 struct net *skc_net;
14210 + struct vx_info *skc_vx_info;
14212 + struct nx_info *skc_nx_info;
14214 * fields between dontcopy_begin/dontcopy_end
14215 * are not copied in sock_copy()
14216 @@ -257,6 +261,10 @@ struct sock {
14217 #define sk_bind_node __sk_common.skc_bind_node
14218 #define sk_prot __sk_common.skc_prot
14219 #define sk_net __sk_common.skc_net
14220 +#define sk_xid __sk_common.skc_xid
14221 +#define sk_vx_info __sk_common.skc_vx_info
14222 +#define sk_nid __sk_common.skc_nid
14223 +#define sk_nx_info __sk_common.skc_nx_info
14224 socket_lock_t sk_lock;
14225 struct sk_buff_head sk_receive_queue;
14227 diff -NurpP --minimal linux-3.1.1/init/Kconfig linux-3.1.1-vs2.3.2/init/Kconfig
14228 --- linux-3.1.1/init/Kconfig 2011-10-24 18:45:33.000000000 +0200
14229 +++ linux-3.1.1-vs2.3.2/init/Kconfig 2011-10-24 18:53:33.000000000 +0200
14230 @@ -574,6 +574,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14232 boolean "Control Group support"
14236 This option adds support for grouping sets of processes together, for
14237 use with process control subsystems such as Cpusets, CFS, memory
14238 @@ -790,6 +791,7 @@ config IPC_NS
14240 bool "User namespace (EXPERIMENTAL)"
14241 depends on EXPERIMENTAL
14242 + depends on VSERVER_DISABLED
14245 This allows containers, i.e. vservers, to use user namespaces
14246 diff -NurpP --minimal linux-3.1.1/init/main.c linux-3.1.1-vs2.3.2/init/main.c
14247 --- linux-3.1.1/init/main.c 2011-10-24 18:45:33.000000000 +0200
14248 +++ linux-3.1.1-vs2.3.2/init/main.c 2011-10-24 18:53:33.000000000 +0200
14250 #include <linux/shmem_fs.h>
14251 #include <linux/slab.h>
14252 #include <linux/perf_event.h>
14253 +#include <linux/vserver/percpu.h>
14255 #include <asm/io.h>
14256 #include <asm/bugs.h>
14257 diff -NurpP --minimal linux-3.1.1/ipc/mqueue.c linux-3.1.1-vs2.3.2/ipc/mqueue.c
14258 --- linux-3.1.1/ipc/mqueue.c 2011-10-24 18:45:33.000000000 +0200
14259 +++ linux-3.1.1-vs2.3.2/ipc/mqueue.c 2011-10-24 18:53:33.000000000 +0200
14261 #include <linux/pid.h>
14262 #include <linux/ipc_namespace.h>
14263 #include <linux/slab.h>
14264 +#include <linux/vs_context.h>
14265 +#include <linux/vs_limit.h>
14267 #include <net/sock.h>
14269 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14270 struct sigevent notify;
14271 struct pid* notify_owner;
14272 struct user_struct *user; /* user who created, for accounting */
14273 + struct vx_info *vxi;
14274 struct sock *notify_sock;
14275 struct sk_buff *notify_cookie;
14277 @@ -128,6 +131,7 @@ static struct inode *mqueue_get_inode(st
14278 if (S_ISREG(mode)) {
14279 struct mqueue_inode_info *info;
14280 struct task_struct *p = current;
14281 + struct vx_info *vxi = p->vx_info;
14282 unsigned long mq_bytes, mq_msg_tblsz;
14284 inode->i_fop = &mqueue_file_operations;
14285 @@ -141,6 +145,7 @@ static struct inode *mqueue_get_inode(st
14286 info->notify_owner = NULL;
14288 info->user = NULL; /* set when all is ok */
14289 + info->vxi = NULL;
14290 memset(&info->attr, 0, sizeof(info->attr));
14291 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14292 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14293 @@ -158,17 +163,20 @@ static struct inode *mqueue_get_inode(st
14295 spin_lock(&mq_lock);
14296 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14297 - u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) {
14298 + u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE) ||
14299 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14300 spin_unlock(&mq_lock);
14301 /* mqueue_evict_inode() releases info->messages */
14305 u->mq_bytes += mq_bytes;
14306 + vx_ipcmsg_add(vxi, u, mq_bytes);
14307 spin_unlock(&mq_lock);
14310 info->user = get_uid(u);
14311 + info->vxi = get_vx_info(vxi);
14312 } else if (S_ISDIR(mode)) {
14314 /* Some things misbehave if size == 0 on a directory */
14315 @@ -278,8 +286,11 @@ static void mqueue_evict_inode(struct in
14316 + info->attr.mq_msgsize);
14319 + struct vx_info *vxi = info->vxi;
14321 spin_lock(&mq_lock);
14322 user->mq_bytes -= mq_bytes;
14323 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14325 * get_ns_from_inode() ensures that the
14326 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14327 @@ -289,6 +300,7 @@ static void mqueue_evict_inode(struct in
14329 ipc_ns->mq_queues_count--;
14330 spin_unlock(&mq_lock);
14331 + put_vx_info(vxi);
14335 diff -NurpP --minimal linux-3.1.1/ipc/msg.c linux-3.1.1-vs2.3.2/ipc/msg.c
14336 --- linux-3.1.1/ipc/msg.c 2011-05-22 16:17:59.000000000 +0200
14337 +++ linux-3.1.1-vs2.3.2/ipc/msg.c 2011-10-24 18:53:33.000000000 +0200
14339 #include <linux/rwsem.h>
14340 #include <linux/nsproxy.h>
14341 #include <linux/ipc_namespace.h>
14342 +#include <linux/vs_base.h>
14344 #include <asm/current.h>
14345 #include <asm/uaccess.h>
14346 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14348 msq->q_perm.mode = msgflg & S_IRWXUGO;
14349 msq->q_perm.key = key;
14350 + msq->q_perm.xid = vx_current_xid();
14352 msq->q_perm.security = NULL;
14353 retval = security_msg_queue_alloc(msq);
14354 diff -NurpP --minimal linux-3.1.1/ipc/namespace.c linux-3.1.1-vs2.3.2/ipc/namespace.c
14355 --- linux-3.1.1/ipc/namespace.c 2011-07-22 11:18:12.000000000 +0200
14356 +++ linux-3.1.1-vs2.3.2/ipc/namespace.c 2011-10-24 18:53:33.000000000 +0200
14357 @@ -13,11 +13,12 @@
14358 #include <linux/mount.h>
14359 #include <linux/user_namespace.h>
14360 #include <linux/proc_fs.h>
14361 +#include <linux/vs_base.h>
14362 +#include <linux/vserver/global.h>
14366 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
14367 - struct ipc_namespace *old_ns)
14368 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
14370 struct ipc_namespace *ns;
14372 @@ -46,19 +47,18 @@ static struct ipc_namespace *create_ipc_
14373 ipcns_notify(IPCNS_CREATED);
14374 register_ipcns_notifier(ns);
14376 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
14377 + ns->user_ns = get_user_ns(user_ns);
14382 struct ipc_namespace *copy_ipcs(unsigned long flags,
14383 - struct task_struct *tsk)
14384 + struct ipc_namespace *old_ns,
14385 + struct user_namespace *user_ns)
14387 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
14389 if (!(flags & CLONE_NEWIPC))
14390 - return get_ipc_ns(ns);
14391 - return create_ipc_ns(tsk, ns);
14392 + return get_ipc_ns(old_ns);
14393 + return create_ipc_ns(user_ns);
14397 diff -NurpP --minimal linux-3.1.1/ipc/sem.c linux-3.1.1-vs2.3.2/ipc/sem.c
14398 --- linux-3.1.1/ipc/sem.c 2011-10-24 18:45:33.000000000 +0200
14399 +++ linux-3.1.1-vs2.3.2/ipc/sem.c 2011-10-24 18:53:33.000000000 +0200
14401 #include <linux/rwsem.h>
14402 #include <linux/nsproxy.h>
14403 #include <linux/ipc_namespace.h>
14404 +#include <linux/vs_base.h>
14405 +#include <linux/vs_limit.h>
14407 #include <asm/uaccess.h>
14409 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
14411 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14412 sma->sem_perm.key = key;
14413 + sma->sem_perm.xid = vx_current_xid();
14415 sma->sem_perm.security = NULL;
14416 retval = security_sem_alloc(sma);
14417 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
14420 ns->used_sems += nsems;
14421 + /* FIXME: obsoleted? */
14422 + vx_semary_inc(sma);
14423 + vx_nsems_add(sma, nsems);
14425 sma->sem_base = (struct sem *) &sma[1];
14427 @@ -724,6 +730,9 @@ static void freeary(struct ipc_namespace
14429 wake_up_sem_queue_do(&tasks);
14430 ns->used_sems -= sma->sem_nsems;
14431 + /* FIXME: obsoleted? */
14432 + vx_nsems_sub(sma, sma->sem_nsems);
14433 + vx_semary_dec(sma);
14434 security_sem_free(sma);
14435 ipc_rcu_putref(sma);
14437 diff -NurpP --minimal linux-3.1.1/ipc/shm.c linux-3.1.1-vs2.3.2/ipc/shm.c
14438 --- linux-3.1.1/ipc/shm.c 2011-10-24 18:45:33.000000000 +0200
14439 +++ linux-3.1.1-vs2.3.2/ipc/shm.c 2011-10-24 18:53:33.000000000 +0200
14441 #include <linux/nsproxy.h>
14442 #include <linux/mount.h>
14443 #include <linux/ipc_namespace.h>
14444 +#include <linux/vs_context.h>
14445 +#include <linux/vs_limit.h>
14447 #include <asm/uaccess.h>
14449 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
14451 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14453 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14454 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14455 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14457 + vx_ipcshm_sub(vxi, shp, numpages);
14458 + ns->shm_tot -= numpages;
14462 if (!is_file_hugepages(shp->shm_file))
14463 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
14465 fput (shp->shm_file);
14466 security_shm_free(shp);
14467 + put_vx_info(vxi);
14468 ipc_rcu_putref(shp);
14471 @@ -462,11 +470,15 @@ static int newseg(struct ipc_namespace *
14472 if (ns->shm_tot + numpages > ns->shm_ctlall)
14475 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14478 shp = ipc_rcu_alloc(sizeof(*shp));
14482 shp->shm_perm.key = key;
14483 + shp->shm_perm.xid = vx_current_xid();
14484 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14485 shp->mlock_user = NULL;
14487 @@ -521,6 +533,7 @@ static int newseg(struct ipc_namespace *
14488 ns->shm_tot += numpages;
14489 error = shp->shm_perm.id;
14491 + vx_ipcshm_add(current_vx_info(), key, numpages);
14495 diff -NurpP --minimal linux-3.1.1/kernel/Makefile linux-3.1.1-vs2.3.2/kernel/Makefile
14496 --- linux-3.1.1/kernel/Makefile 2011-10-24 18:45:33.000000000 +0200
14497 +++ linux-3.1.1-vs2.3.2/kernel/Makefile 2011-10-24 18:53:33.000000000 +0200
14498 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
14499 CFLAGS_REMOVE_irq_work.o = -pg
14503 obj-$(CONFIG_FREEZER) += freezer.o
14504 obj-$(CONFIG_PROFILING) += profile.o
14505 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
14506 diff -NurpP --minimal linux-3.1.1/kernel/capability.c linux-3.1.1-vs2.3.2/kernel/capability.c
14507 --- linux-3.1.1/kernel/capability.c 2011-07-22 11:18:12.000000000 +0200
14508 +++ linux-3.1.1-vs2.3.2/kernel/capability.c 2011-10-24 18:53:33.000000000 +0200
14510 #include <linux/syscalls.h>
14511 #include <linux/pid_namespace.h>
14512 #include <linux/user_namespace.h>
14513 +#include <linux/vs_context.h>
14514 #include <asm/uaccess.h>
14517 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
14523 * The only thing that can change the capabilities of the current
14524 * process is the current process. As such, we can't be in this code
14525 @@ -340,6 +342,8 @@ bool has_capability_noaudit(struct task_
14529 +#include <linux/vserver/base.h>
14532 * capable - Determine if the current task has a superior capability in effect
14533 * @cap: The capability to be tested for
14534 @@ -374,6 +378,9 @@ bool ns_capable(struct user_namespace *n
14538 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
14541 if (security_capable(ns, current_cred(), cap) == 0) {
14542 current->flags |= PF_SUPERPRIV;
14544 diff -NurpP --minimal linux-3.1.1/kernel/compat.c linux-3.1.1-vs2.3.2/kernel/compat.c
14545 --- linux-3.1.1/kernel/compat.c 2011-10-24 18:45:33.000000000 +0200
14546 +++ linux-3.1.1-vs2.3.2/kernel/compat.c 2011-10-24 18:53:33.000000000 +0200
14547 @@ -972,7 +972,7 @@ asmlinkage long compat_sys_stime(compat_
14551 - do_settimeofday(&tv);
14552 + vx_settimeofday(&tv);
14556 diff -NurpP --minimal linux-3.1.1/kernel/cred.c linux-3.1.1-vs2.3.2/kernel/cred.c
14557 --- linux-3.1.1/kernel/cred.c 2011-10-24 18:45:33.000000000 +0200
14558 +++ linux-3.1.1-vs2.3.2/kernel/cred.c 2011-10-24 18:53:33.000000000 +0200
14559 @@ -61,31 +61,6 @@ struct cred init_cred = {
14563 -static inline void set_cred_subscribers(struct cred *cred, int n)
14565 -#ifdef CONFIG_DEBUG_CREDENTIALS
14566 - atomic_set(&cred->subscribers, n);
14570 -static inline int read_cred_subscribers(const struct cred *cred)
14572 -#ifdef CONFIG_DEBUG_CREDENTIALS
14573 - return atomic_read(&cred->subscribers);
14579 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14581 -#ifdef CONFIG_DEBUG_CREDENTIALS
14582 - struct cred *cred = (struct cred *) _cred;
14584 - atomic_add(n, &cred->subscribers);
14589 * Dispose of the shared task group credentials
14591 @@ -281,21 +256,16 @@ error:
14593 * Call commit_creds() or abort_creds() to clean up.
14595 -struct cred *prepare_creds(void)
14596 +struct cred *__prepare_creds(const struct cred *old)
14598 - struct task_struct *task = current;
14599 - const struct cred *old;
14602 - validate_process_creds();
14604 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14608 kdebug("prepare_creds() alloc %p", new);
14610 - old = task->cred;
14611 memcpy(new, old, sizeof(struct cred));
14613 atomic_set(&new->usage, 1);
14614 @@ -322,6 +292,13 @@ error:
14619 +struct cred *prepare_creds(void)
14621 + validate_process_creds();
14623 + return __prepare_creds(current->cred);
14625 EXPORT_SYMBOL(prepare_creds);
14628 diff -NurpP --minimal linux-3.1.1/kernel/exit.c linux-3.1.1-vs2.3.2/kernel/exit.c
14629 --- linux-3.1.1/kernel/exit.c 2011-10-24 18:45:33.000000000 +0200
14630 +++ linux-3.1.1-vs2.3.2/kernel/exit.c 2011-10-24 18:53:33.000000000 +0200
14632 #include <linux/fs_struct.h>
14633 #include <linux/init_task.h>
14634 #include <linux/perf_event.h>
14635 +#include <linux/vs_limit.h>
14636 +#include <linux/vs_context.h>
14637 +#include <linux/vs_network.h>
14638 +#include <linux/vs_pid.h>
14639 #include <trace/events/sched.h>
14640 #include <linux/hw_breakpoint.h>
14641 #include <linux/oom.h>
14642 @@ -480,9 +484,11 @@ static void close_files(struct files_str
14643 filp_close(file, files);
14646 + vx_openfd_dec(i);
14654 @@ -1038,11 +1044,16 @@ NORET_TYPE void do_exit(long code)
14656 validate_creds_for_do_exit(tsk);
14658 + /* needs to stay after exit_notify() */
14659 + exit_vx_info(tsk, code);
14660 + exit_nx_info(tsk);
14664 /* causes final put_task_struct in finish_task_switch(). */
14665 tsk->state = TASK_DEAD;
14667 + printk("bad task: %p [%lx]\n", current, current->state);
14669 /* Avoid "noreturn function does return". */
14671 diff -NurpP --minimal linux-3.1.1/kernel/fork.c linux-3.1.1-vs2.3.2/kernel/fork.c
14672 --- linux-3.1.1/kernel/fork.c 2011-10-24 18:45:33.000000000 +0200
14673 +++ linux-3.1.1-vs2.3.2/kernel/fork.c 2011-10-24 18:53:33.000000000 +0200
14675 #include <linux/user-return-notifier.h>
14676 #include <linux/oom.h>
14677 #include <linux/khugepaged.h>
14678 +#include <linux/vs_context.h>
14679 +#include <linux/vs_network.h>
14680 +#include <linux/vs_limit.h>
14681 +#include <linux/vs_memory.h>
14683 #include <asm/pgtable.h>
14684 #include <asm/pgalloc.h>
14685 @@ -166,6 +170,8 @@ void free_task(struct task_struct *tsk)
14686 account_kernel_stack(tsk->stack, -1);
14687 free_thread_info(tsk->stack);
14688 rt_mutex_debug_task_free(tsk);
14689 + clr_vx_info(&tsk->vx_info);
14690 + clr_nx_info(&tsk->nx_info);
14691 ftrace_graph_exit_task(tsk);
14692 free_task_struct(tsk);
14694 @@ -506,6 +512,7 @@ static struct mm_struct *mm_init(struct
14695 if (likely(!mm_alloc_pgd(mm))) {
14697 mmu_notifier_mm_init(mm);
14698 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14702 @@ -543,6 +550,7 @@ void __mmdrop(struct mm_struct *mm)
14703 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14704 VM_BUG_ON(mm->pmd_huge_pte);
14706 + clr_vx_info(&mm->mm_vx_info);
14709 EXPORT_SYMBOL_GPL(__mmdrop);
14710 @@ -730,6 +738,7 @@ struct mm_struct *dup_mm(struct task_str
14713 memcpy(mm, oldmm, sizeof(*mm));
14714 + mm->mm_vx_info = NULL;
14715 mm_init_cpumask(mm);
14717 /* Initializing for Swap token stuff */
14718 @@ -773,6 +782,7 @@ fail_nocontext:
14719 * If init_new_context() failed, we cannot use mmput() to free the mm
14720 * because it calls destroy_context()
14722 + clr_vx_info(&mm->mm_vx_info);
14726 @@ -1058,6 +1068,8 @@ static struct task_struct *copy_process(
14728 struct task_struct *p;
14729 int cgroup_callbacks_done = 0;
14730 + struct vx_info *vxi;
14731 + struct nx_info *nxi;
14733 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14734 return ERR_PTR(-EINVAL);
14735 @@ -1104,7 +1116,12 @@ static struct task_struct *copy_process(
14736 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14737 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14739 + init_vx_info(&p->vx_info, current_vx_info());
14740 + init_nx_info(&p->nx_info, current_nx_info());
14743 + if (!vx_nproc_avail(1))
14744 + goto bad_fork_free;
14745 if (atomic_read(&p->real_cred->user->processes) >=
14746 task_rlimit(p, RLIMIT_NPROC)) {
14747 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14748 @@ -1374,6 +1391,18 @@ static struct task_struct *copy_process(
14751 spin_unlock(¤t->sighand->siglock);
14753 + /* p is copy of current */
14754 + vxi = p->vx_info;
14756 + claim_vx_info(vxi, p);
14757 + atomic_inc(&vxi->cvirt.nr_threads);
14758 + atomic_inc(&vxi->cvirt.total_forks);
14761 + nxi = p->nx_info;
14763 + claim_nx_info(nxi, p);
14764 write_unlock_irq(&tasklist_lock);
14765 proc_fork_connector(p);
14766 cgroup_post_fork(p);
14767 diff -NurpP --minimal linux-3.1.1/kernel/kthread.c linux-3.1.1-vs2.3.2/kernel/kthread.c
14768 --- linux-3.1.1/kernel/kthread.c 2011-07-22 11:18:12.000000000 +0200
14769 +++ linux-3.1.1-vs2.3.2/kernel/kthread.c 2011-10-24 18:53:33.000000000 +0200
14771 #include <linux/mutex.h>
14772 #include <linux/slab.h>
14773 #include <linux/freezer.h>
14774 +#include <linux/vs_pid.h>
14775 #include <trace/events/sched.h>
14777 static DEFINE_SPINLOCK(kthread_create_lock);
14778 diff -NurpP --minimal linux-3.1.1/kernel/nsproxy.c linux-3.1.1-vs2.3.2/kernel/nsproxy.c
14779 --- linux-3.1.1/kernel/nsproxy.c 2011-10-24 18:45:33.000000000 +0200
14780 +++ linux-3.1.1-vs2.3.2/kernel/nsproxy.c 2011-10-24 18:53:33.000000000 +0200
14782 #include <linux/mnt_namespace.h>
14783 #include <linux/utsname.h>
14784 #include <linux/pid_namespace.h>
14785 +#include <linux/vserver/global.h>
14786 +#include <linux/vserver/debug.h>
14787 #include <net/net_namespace.h>
14788 #include <linux/ipc_namespace.h>
14789 #include <linux/proc_fs.h>
14790 @@ -46,8 +48,11 @@ static inline struct nsproxy *create_nsp
14791 struct nsproxy *nsproxy;
14793 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14796 atomic_set(&nsproxy->count, 1);
14797 + atomic_inc(&vs_global_nsproxy);
14799 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14803 @@ -56,8 +61,11 @@ static inline struct nsproxy *create_nsp
14804 * Return the newly created nsproxy. Do not attach this to the task,
14805 * leave it to the caller to do proper locking and attach it to task.
14807 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14808 - struct task_struct *tsk, struct fs_struct *new_fs)
14809 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14810 + struct nsproxy *orig,
14811 + struct fs_struct *new_fs,
14812 + struct user_namespace *new_user,
14813 + struct pid_namespace *new_pid)
14815 struct nsproxy *new_nsp;
14817 @@ -66,31 +74,31 @@ static struct nsproxy *create_new_namesp
14819 return ERR_PTR(-ENOMEM);
14821 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
14822 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
14823 if (IS_ERR(new_nsp->mnt_ns)) {
14824 err = PTR_ERR(new_nsp->mnt_ns);
14828 - new_nsp->uts_ns = copy_utsname(flags, tsk);
14829 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
14830 if (IS_ERR(new_nsp->uts_ns)) {
14831 err = PTR_ERR(new_nsp->uts_ns);
14835 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
14836 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
14837 if (IS_ERR(new_nsp->ipc_ns)) {
14838 err = PTR_ERR(new_nsp->ipc_ns);
14842 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
14843 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
14844 if (IS_ERR(new_nsp->pid_ns)) {
14845 err = PTR_ERR(new_nsp->pid_ns);
14849 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
14850 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
14851 if (IS_ERR(new_nsp->net_ns)) {
14852 err = PTR_ERR(new_nsp->net_ns);
14854 @@ -115,6 +123,40 @@ out_ns:
14855 return ERR_PTR(err);
14858 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14859 + struct task_struct *tsk, struct fs_struct *new_fs)
14861 + return unshare_namespaces(flags, tsk->nsproxy,
14862 + new_fs, task_cred_xxx(tsk, user)->user_ns,
14863 + task_active_pid_ns(tsk));
14867 + * copies the nsproxy, setting refcount to 1, and grabbing a
14868 + * reference to all contained namespaces.
14870 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14872 + struct nsproxy *ns = create_nsproxy();
14875 + memcpy(ns, orig, sizeof(struct nsproxy));
14876 + atomic_set(&ns->count, 1);
14879 + get_mnt_ns(ns->mnt_ns);
14881 + get_uts_ns(ns->uts_ns);
14883 + get_ipc_ns(ns->ipc_ns);
14885 + get_pid_ns(ns->pid_ns);
14887 + get_net(ns->net_ns);
14893 * called from clone. This now handles copy for nsproxy and all
14894 * namespaces therein.
14895 @@ -122,9 +164,12 @@ out_ns:
14896 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
14898 struct nsproxy *old_ns = tsk->nsproxy;
14899 - struct nsproxy *new_ns;
14900 + struct nsproxy *new_ns = NULL;
14903 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14904 + flags, tsk, old_ns);
14909 @@ -134,7 +179,7 @@ int copy_namespaces(unsigned long flags,
14910 CLONE_NEWPID | CLONE_NEWNET)))
14913 - if (!capable(CAP_SYS_ADMIN)) {
14914 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
14918 @@ -161,6 +206,9 @@ int copy_namespaces(unsigned long flags,
14921 put_nsproxy(old_ns);
14922 + vxdprintk(VXD_CBIT(space, 3),
14923 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14924 + flags, tsk, old_ns, err, new_ns);
14928 @@ -174,7 +222,9 @@ void free_nsproxy(struct nsproxy *ns)
14929 put_ipc_ns(ns->ipc_ns);
14931 put_pid_ns(ns->pid_ns);
14932 - put_net(ns->net_ns);
14934 + put_net(ns->net_ns);
14935 + atomic_dec(&vs_global_nsproxy);
14936 kmem_cache_free(nsproxy_cachep, ns);
14939 @@ -187,11 +237,15 @@ int unshare_nsproxy_namespaces(unsigned
14943 + vxdprintk(VXD_CBIT(space, 4),
14944 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14945 + unshare_flags, current->nsproxy);
14947 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14951 - if (!capable(CAP_SYS_ADMIN))
14952 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
14955 *new_nsp = create_new_namespaces(unshare_flags, current,
14956 diff -NurpP --minimal linux-3.1.1/kernel/pid.c linux-3.1.1-vs2.3.2/kernel/pid.c
14957 --- linux-3.1.1/kernel/pid.c 2011-10-24 18:45:33.000000000 +0200
14958 +++ linux-3.1.1-vs2.3.2/kernel/pid.c 2011-10-24 18:53:33.000000000 +0200
14960 #include <linux/pid_namespace.h>
14961 #include <linux/init_task.h>
14962 #include <linux/syscalls.h>
14963 +#include <linux/vs_pid.h>
14965 #define pid_hashfn(nr, ns) \
14966 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14967 @@ -342,7 +343,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14969 struct pid *find_vpid(int nr)
14971 - return find_pid_ns(nr, current->nsproxy->pid_ns);
14972 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
14974 EXPORT_SYMBOL_GPL(find_vpid);
14976 @@ -402,6 +403,9 @@ void transfer_pid(struct task_struct *ol
14977 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14979 struct task_struct *result = NULL;
14981 + if (type == PIDTYPE_REALPID)
14982 + type = PIDTYPE_PID;
14984 struct hlist_node *first;
14985 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
14986 @@ -419,7 +423,7 @@ EXPORT_SYMBOL(pid_task);
14987 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
14989 rcu_lockdep_assert(rcu_read_lock_held());
14990 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
14991 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
14994 struct task_struct *find_task_by_vpid(pid_t vnr)
14995 @@ -463,7 +467,7 @@ struct pid *find_get_pid(pid_t nr)
14997 EXPORT_SYMBOL_GPL(find_get_pid);
14999 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15000 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
15004 @@ -476,6 +480,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
15008 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
15010 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
15013 pid_t pid_vnr(struct pid *pid)
15015 return pid_nr_ns(pid, current->nsproxy->pid_ns);
15016 diff -NurpP --minimal linux-3.1.1/kernel/pid_namespace.c linux-3.1.1-vs2.3.2/kernel/pid_namespace.c
15017 --- linux-3.1.1/kernel/pid_namespace.c 2011-05-22 16:17:59.000000000 +0200
15018 +++ linux-3.1.1-vs2.3.2/kernel/pid_namespace.c 2011-10-24 18:53:33.000000000 +0200
15020 #include <linux/acct.h>
15021 #include <linux/slab.h>
15022 #include <linux/proc_fs.h>
15023 +#include <linux/vserver/global.h>
15025 #define BITS_PER_PAGE (PAGE_SIZE*8)
15027 @@ -88,6 +89,7 @@ static struct pid_namespace *create_pid_
15030 kref_init(&ns->kref);
15031 + atomic_inc(&vs_global_pid_ns);
15033 ns->parent = get_pid_ns(parent_pid_ns);
15035 @@ -119,6 +121,7 @@ static void destroy_pid_namespace(struct
15037 for (i = 0; i < PIDMAP_ENTRIES; i++)
15038 kfree(ns->pidmap[i].page);
15039 + atomic_dec(&vs_global_pid_ns);
15040 kmem_cache_free(pid_ns_cachep, ns);
15043 diff -NurpP --minimal linux-3.1.1/kernel/posix-timers.c linux-3.1.1-vs2.3.2/kernel/posix-timers.c
15044 --- linux-3.1.1/kernel/posix-timers.c 2011-07-22 11:18:12.000000000 +0200
15045 +++ linux-3.1.1-vs2.3.2/kernel/posix-timers.c 2011-10-24 18:53:33.000000000 +0200
15047 #include <linux/wait.h>
15048 #include <linux/workqueue.h>
15049 #include <linux/module.h>
15050 +#include <linux/vs_context.h>
15053 * Management arrays for POSIX timers. Timers are kept in slab memory
15054 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
15056 struct task_struct *task;
15057 int shared, ret = -1;
15060 * FIXME: if ->sigq is queued we can race with
15061 * dequeue_signal()->do_schedule_next_timer().
15062 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
15064 task = pid_task(timr->it_pid, PIDTYPE_PID);
15066 + struct vx_info_save vxis;
15067 + struct vx_info *vxi;
15069 + vxi = get_vx_info(task->vx_info);
15070 + enter_vx_info(vxi, &vxis);
15071 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
15072 ret = send_sigqueue(timr->sigq, task, shared);
15073 + leave_vx_info(&vxis);
15074 + put_vx_info(vxi);
15078 /* If we failed to send the signal the timer stops. */
15081 diff -NurpP --minimal linux-3.1.1/kernel/printk.c linux-3.1.1-vs2.3.2/kernel/printk.c
15082 --- linux-3.1.1/kernel/printk.c 2011-10-24 18:45:33.000000000 +0200
15083 +++ linux-3.1.1-vs2.3.2/kernel/printk.c 2011-10-24 18:53:33.000000000 +0200
15085 #include <linux/cpu.h>
15086 #include <linux/notifier.h>
15087 #include <linux/rculist.h>
15088 +#include <linux/vs_cvirt.h>
15090 #include <asm/uaccess.h>
15092 @@ -314,7 +315,7 @@ static int check_syslog_permissions(int
15095 if (syslog_action_restricted(type)) {
15096 - if (capable(CAP_SYSLOG))
15097 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
15099 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
15100 if (capable(CAP_SYS_ADMIN)) {
15101 @@ -344,12 +345,9 @@ int do_syslog(int type, char __user *buf
15106 - case SYSLOG_ACTION_CLOSE: /* Close log */
15108 - case SYSLOG_ACTION_OPEN: /* Open log */
15110 - case SYSLOG_ACTION_READ: /* Read from log */
15111 + if ((type == SYSLOG_ACTION_READ) ||
15112 + (type == SYSLOG_ACTION_READ_ALL) ||
15113 + (type == SYSLOG_ACTION_READ_CLEAR)) {
15115 if (!buf || len < 0)
15117 @@ -360,6 +358,16 @@ int do_syslog(int type, char __user *buf
15122 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15123 + return vx_do_syslog(type, buf, len);
15126 + case SYSLOG_ACTION_CLOSE: /* Close log */
15128 + case SYSLOG_ACTION_OPEN: /* Open log */
15130 + case SYSLOG_ACTION_READ: /* Read from log */
15131 error = wait_event_interruptible(log_wait,
15132 (log_start - log_end));
15134 @@ -386,16 +394,6 @@ int do_syslog(int type, char __user *buf
15136 /* Read last kernel messages */
15137 case SYSLOG_ACTION_READ_ALL:
15139 - if (!buf || len < 0)
15144 - if (!access_ok(VERIFY_WRITE, buf, len)) {
15149 if (count > log_buf_len)
15150 count = log_buf_len;
15151 diff -NurpP --minimal linux-3.1.1/kernel/ptrace.c linux-3.1.1-vs2.3.2/kernel/ptrace.c
15152 --- linux-3.1.1/kernel/ptrace.c 2011-10-24 18:45:33.000000000 +0200
15153 +++ linux-3.1.1-vs2.3.2/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
15155 #include <linux/syscalls.h>
15156 #include <linux/uaccess.h>
15157 #include <linux/regset.h>
15158 +#include <linux/vs_context.h>
15159 #include <linux/hw_breakpoint.h>
15160 #include <linux/cn_proc.h>
15162 @@ -198,6 +199,11 @@ ok:
15163 dumpable = get_dumpable(task->mm);
15164 if (!dumpable && !task_ns_capable(task, CAP_SYS_PTRACE))
15166 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
15168 + if (!vx_check(task->xid, VS_IDENT) &&
15169 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
15172 return security_ptrace_access_check(task, mode);
15174 diff -NurpP --minimal linux-3.1.1/kernel/sched.c linux-3.1.1-vs2.3.2/kernel/sched.c
15175 --- linux-3.1.1/kernel/sched.c 2011-10-24 18:45:33.000000000 +0200
15176 +++ linux-3.1.1-vs2.3.2/kernel/sched.c 2011-10-24 18:53:33.000000000 +0200
15178 #include <linux/ctype.h>
15179 #include <linux/ftrace.h>
15180 #include <linux/slab.h>
15181 +#include <linux/vs_sched.h>
15182 +#include <linux/vs_cvirt.h>
15184 #include <asm/tlb.h>
15185 #include <asm/irq_regs.h>
15186 @@ -3473,9 +3475,17 @@ static void calc_global_nohz(unsigned lo
15188 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
15190 - loads[0] = (avenrun[0] + offset) << shift;
15191 - loads[1] = (avenrun[1] + offset) << shift;
15192 - loads[2] = (avenrun[2] + offset) << shift;
15193 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
15194 + struct vx_info *vxi = current_vx_info();
15196 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15197 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15198 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15200 + loads[0] = (avenrun[0] + offset) << shift;
15201 + loads[1] = (avenrun[1] + offset) << shift;
15202 + loads[2] = (avenrun[2] + offset) << shift;
15207 @@ -3734,16 +3744,19 @@ void account_user_time(struct task_struc
15208 cputime_t cputime_scaled)
15210 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
15211 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15213 + int nice = (TASK_NICE(p) > 0);
15215 /* Add user time to process. */
15216 p->utime = cputime_add(p->utime, cputime);
15217 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15218 + vx_account_user(vxi, cputime, nice);
15219 account_group_user_time(p, cputime);
15221 /* Add user time to cpustat. */
15222 tmp = cputime_to_cputime64(cputime);
15223 - if (TASK_NICE(p) > 0)
15225 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15227 cpustat->user = cputime64_add(cpustat->user, tmp);
15228 @@ -3795,10 +3808,12 @@ void __account_system_time(struct task_s
15229 cputime_t cputime_scaled, cputime64_t *target_cputime64)
15231 cputime64_t tmp = cputime_to_cputime64(cputime);
15232 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15234 /* Add system time to process. */
15235 p->stime = cputime_add(p->stime, cputime);
15236 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15237 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15238 account_group_system_time(p, cputime);
15240 /* Add system time to cpustat. */
15241 @@ -4984,7 +4999,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15244 if (increment < 0 && !can_nice(current, nice))
15246 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15248 retval = security_task_setnice(current, nice);
15250 diff -NurpP --minimal linux-3.1.1/kernel/sched_fair.c linux-3.1.1-vs2.3.2/kernel/sched_fair.c
15251 --- linux-3.1.1/kernel/sched_fair.c 2011-10-24 18:45:33.000000000 +0200
15252 +++ linux-3.1.1-vs2.3.2/kernel/sched_fair.c 2011-10-24 18:53:33.000000000 +0200
15253 @@ -979,6 +979,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15254 __enqueue_entity(cfs_rq, se);
15257 + if (entity_is_task(se))
15258 + vx_activate_task(task_of(se));
15259 if (cfs_rq->nr_running == 1)
15260 list_add_leaf_cfs_rq(cfs_rq);
15262 @@ -1055,6 +1057,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15263 if (se != cfs_rq->curr)
15264 __dequeue_entity(cfs_rq, se);
15266 + if (entity_is_task(se))
15267 + vx_deactivate_task(task_of(se));
15268 update_cfs_load(cfs_rq, 0);
15269 account_entity_dequeue(cfs_rq, se);
15271 diff -NurpP --minimal linux-3.1.1/kernel/signal.c linux-3.1.1-vs2.3.2/kernel/signal.c
15272 --- linux-3.1.1/kernel/signal.c 2011-10-24 18:45:33.000000000 +0200
15273 +++ linux-3.1.1-vs2.3.2/kernel/signal.c 2011-10-24 18:53:33.000000000 +0200
15275 #include <linux/freezer.h>
15276 #include <linux/pid_namespace.h>
15277 #include <linux/nsproxy.h>
15278 +#include <linux/vs_context.h>
15279 +#include <linux/vs_pid.h>
15280 #define CREATE_TRACE_POINTS
15281 #include <trace/events/signal.h>
15283 @@ -789,9 +791,18 @@ static int check_kill_permission(int sig
15287 + vxdprintk(VXD_CBIT(misc, 7),
15288 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15289 + sig, info, t, vx_task_xid(t), t->pid);
15291 if (!valid_signal(sig))
15294 +/* FIXME: needed? if so, why?
15295 + if ((info != SEND_SIG_NOINFO) &&
15296 + (is_si_special(info) || !si_fromuser(info)))
15299 if (!si_fromuser(info))
15302 @@ -815,6 +826,20 @@ static int check_kill_permission(int sig
15307 + if (t->pid == 1 && current->xid)
15311 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15312 + loops, maybe ENOENT or EACCES? */
15313 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15314 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15315 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15316 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15320 return security_task_kill(t, info, sig, 0);
15323 @@ -1319,7 +1344,7 @@ int kill_pid_info(int sig, struct siginf
15326 p = pid_task(pid, PIDTYPE_PID);
15328 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15329 error = group_send_sig_info(sig, info, p);
15330 if (unlikely(error == -ESRCH))
15332 @@ -1358,7 +1383,7 @@ int kill_pid_info_as_uid(int sig, struct
15335 p = pid_task(pid, PIDTYPE_PID);
15337 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15341 @@ -1413,8 +1438,10 @@ static int kill_something_info(int sig,
15342 struct task_struct * p;
15344 for_each_process(p) {
15345 - if (task_pid_vnr(p) > 1 &&
15346 - !same_thread_group(p, current)) {
15347 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15348 + task_pid_vnr(p) > 1 &&
15349 + !same_thread_group(p, current) &&
15350 + !vx_current_initpid(p->pid)) {
15351 int err = group_send_sig_info(sig, info, p);
15354 @@ -2249,6 +2276,11 @@ relock:
15355 !sig_kernel_only(signr))
15358 + /* virtual init is protected against user signals */
15359 + if ((info->si_code == SI_USER) &&
15360 + vx_current_initpid(current->pid))
15363 if (sig_kernel_stop(signr)) {
15365 * The default action is to stop all threads in
15366 diff -NurpP --minimal linux-3.1.1/kernel/softirq.c linux-3.1.1-vs2.3.2/kernel/softirq.c
15367 --- linux-3.1.1/kernel/softirq.c 2011-07-22 11:18:12.000000000 +0200
15368 +++ linux-3.1.1-vs2.3.2/kernel/softirq.c 2011-10-24 18:53:33.000000000 +0200
15370 #include <linux/ftrace.h>
15371 #include <linux/smp.h>
15372 #include <linux/tick.h>
15373 +#include <linux/vs_context.h>
15375 #define CREATE_TRACE_POINTS
15376 #include <trace/events/irq.h>
15377 diff -NurpP --minimal linux-3.1.1/kernel/sys.c linux-3.1.1-vs2.3.2/kernel/sys.c
15378 --- linux-3.1.1/kernel/sys.c 2011-10-24 18:45:33.000000000 +0200
15379 +++ linux-3.1.1-vs2.3.2/kernel/sys.c 2011-10-24 18:53:33.000000000 +0200
15381 #include <linux/syscalls.h>
15382 #include <linux/kprobes.h>
15383 #include <linux/user_namespace.h>
15384 +#include <linux/vs_pid.h>
15386 #include <linux/kmsg_dump.h>
15387 /* Move somewhere else to avoid recompiling? */
15388 @@ -154,7 +155,10 @@ static int set_one_prio(struct task_stru
15391 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15393 + if (vx_flags(VXF_IGNEG_NICE, 0))
15399 no_nice = security_task_setnice(p, niceval);
15400 @@ -204,6 +208,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15402 pgrp = task_pgrp(current);
15403 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15404 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15406 error = set_one_prio(p, niceval, error);
15407 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15409 @@ -267,6 +273,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15411 pgrp = task_pgrp(current);
15412 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15413 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15415 niceval = 20 - task_nice(p);
15416 if (niceval > retval)
15418 @@ -417,6 +425,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15420 static DEFINE_MUTEX(reboot_mutex);
15422 +long vs_reboot(unsigned int, void __user *);
15425 * Reboot system call: for obvious reasons only root may call it,
15426 * and even root needs to set up some magic numbers in the registers
15427 @@ -449,6 +459,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15428 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15429 cmd = LINUX_REBOOT_CMD_HALT;
15431 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15432 + return vs_reboot(cmd, arg);
15434 mutex_lock(&reboot_mutex);
15436 case LINUX_REBOOT_CMD_RESTART:
15437 @@ -1272,7 +1285,8 @@ SYSCALL_DEFINE2(sethostname, char __user
15439 char tmp[__NEW_UTS_LEN];
15441 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15442 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15443 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15446 if (len < 0 || len > __NEW_UTS_LEN)
15447 @@ -1322,7 +1336,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
15449 char tmp[__NEW_UTS_LEN];
15451 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15452 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15453 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15455 if (len < 0 || len > __NEW_UTS_LEN)
15457 @@ -1440,7 +1455,7 @@ int do_prlimit(struct task_struct *tsk,
15458 /* Keep the capable check against init_user_ns until
15459 cgroups can contain all limits */
15460 if (new_rlim->rlim_max > rlim->rlim_max &&
15461 - !capable(CAP_SYS_RESOURCE))
15462 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15465 retval = security_task_setrlimit(tsk->group_leader,
15466 @@ -1494,7 +1509,8 @@ static int check_prlimit_permission(stru
15467 cred->gid == tcred->sgid &&
15468 cred->gid == tcred->gid))
15470 - if (ns_capable(tcred->user->user_ns, CAP_SYS_RESOURCE))
15471 + if (vx_ns_capable(tcred->user->user_ns,
15472 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15476 diff -NurpP --minimal linux-3.1.1/kernel/sysctl.c linux-3.1.1-vs2.3.2/kernel/sysctl.c
15477 --- linux-3.1.1/kernel/sysctl.c 2011-10-24 18:45:33.000000000 +0200
15478 +++ linux-3.1.1-vs2.3.2/kernel/sysctl.c 2011-10-24 18:53:33.000000000 +0200
15480 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15481 #include <linux/lockdep.h>
15483 +extern char vshelper_path[];
15484 #ifdef CONFIG_CHR_DEV_SG
15485 #include <scsi/sg.h>
15487 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
15488 .proc_handler = proc_dostring,
15492 + .procname = "vshelper",
15493 + .data = &vshelper_path,
15496 + .proc_handler = &proc_dostring,
15498 #ifdef CONFIG_CHR_DEV_SG
15500 .procname = "sg-big-buff",
15501 diff -NurpP --minimal linux-3.1.1/kernel/sysctl_binary.c linux-3.1.1-vs2.3.2/kernel/sysctl_binary.c
15502 --- linux-3.1.1/kernel/sysctl_binary.c 2011-10-24 18:45:33.000000000 +0200
15503 +++ linux-3.1.1-vs2.3.2/kernel/sysctl_binary.c 2011-10-24 18:53:33.000000000 +0200
15504 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15506 { CTL_INT, KERN_PANIC, "panic" },
15507 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15508 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15510 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15511 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15512 diff -NurpP --minimal linux-3.1.1/kernel/time/timekeeping.c linux-3.1.1-vs2.3.2/kernel/time/timekeeping.c
15513 --- linux-3.1.1/kernel/time/timekeeping.c 2011-10-24 18:45:33.000000000 +0200
15514 +++ linux-3.1.1-vs2.3.2/kernel/time/timekeeping.c 2011-10-24 18:53:33.000000000 +0200
15515 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
15516 } while (read_seqretry(&xtime_lock, seq));
15518 timespec_add_ns(ts, nsecs);
15519 + vx_adjust_timespec(ts);
15522 EXPORT_SYMBOL(getnstimeofday);
15523 diff -NurpP --minimal linux-3.1.1/kernel/time.c linux-3.1.1-vs2.3.2/kernel/time.c
15524 --- linux-3.1.1/kernel/time.c 2011-11-15 16:44:52.000000000 +0100
15525 +++ linux-3.1.1-vs2.3.2/kernel/time.c 2011-11-15 17:08:44.000000000 +0100
15526 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15530 - do_settimeofday(&tv);
15531 + vx_settimeofday(&tv);
15535 @@ -177,7 +177,7 @@ int do_sys_settimeofday(const struct tim
15536 /* SMP safe, again the code in arch/foo/time.c should
15537 * globally block out interrupts when it runs.
15539 - return do_settimeofday(tv);
15540 + return vx_settimeofday(tv);
15544 diff -NurpP --minimal linux-3.1.1/kernel/timer.c linux-3.1.1-vs2.3.2/kernel/timer.c
15545 --- linux-3.1.1/kernel/timer.c 2011-07-22 11:18:12.000000000 +0200
15546 +++ linux-3.1.1-vs2.3.2/kernel/timer.c 2011-10-24 18:53:33.000000000 +0200
15548 #include <linux/irq_work.h>
15549 #include <linux/sched.h>
15550 #include <linux/slab.h>
15551 +#include <linux/vs_base.h>
15552 +#include <linux/vs_cvirt.h>
15553 +#include <linux/vs_pid.h>
15554 +#include <linux/vserver/sched.h>
15556 #include <asm/uaccess.h>
15557 #include <asm/unistd.h>
15558 @@ -1336,12 +1340,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15565 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15566 - * should be moved into arch/i386 instead?
15570 * sys_getpid - return the thread group id of the current process
15571 @@ -1370,10 +1368,23 @@ SYSCALL_DEFINE0(getppid)
15573 pid = task_tgid_vnr(current->real_parent);
15575 + return vx_map_pid(pid);
15582 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15585 +asmlinkage long do_getxpid(long *ppid)
15587 + *ppid = sys_getppid();
15588 + return sys_getpid();
15591 +#else /* _alpha_ */
15593 SYSCALL_DEFINE0(getuid)
15595 /* Only we change this so SMP safe */
15596 diff -NurpP --minimal linux-3.1.1/kernel/user_namespace.c linux-3.1.1-vs2.3.2/kernel/user_namespace.c
15597 --- linux-3.1.1/kernel/user_namespace.c 2011-03-15 18:07:42.000000000 +0100
15598 +++ linux-3.1.1-vs2.3.2/kernel/user_namespace.c 2011-10-24 18:53:33.000000000 +0200
15600 #include <linux/user_namespace.h>
15601 #include <linux/highuid.h>
15602 #include <linux/cred.h>
15603 +#include <linux/vserver/global.h>
15605 static struct kmem_cache *user_ns_cachep __read_mostly;
15607 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
15610 kref_init(&ns->kref);
15611 + atomic_inc(&vs_global_user_ns);
15613 for (n = 0; n < UIDHASH_SZ; ++n)
15614 INIT_HLIST_HEAD(ns->uidhash_table + n);
15615 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
15616 struct user_namespace *ns =
15617 container_of(kref, struct user_namespace, kref);
15619 + /* FIXME: maybe move into destroyer? */
15620 + atomic_dec(&vs_global_user_ns);
15621 INIT_WORK(&ns->destroyer, free_user_ns_work);
15622 schedule_work(&ns->destroyer);
15624 diff -NurpP --minimal linux-3.1.1/kernel/utsname.c linux-3.1.1-vs2.3.2/kernel/utsname.c
15625 --- linux-3.1.1/kernel/utsname.c 2011-07-22 11:18:12.000000000 +0200
15626 +++ linux-3.1.1-vs2.3.2/kernel/utsname.c 2011-10-24 18:53:33.000000000 +0200
15627 @@ -16,14 +16,17 @@
15628 #include <linux/slab.h>
15629 #include <linux/user_namespace.h>
15630 #include <linux/proc_fs.h>
15631 +#include <linux/vserver/global.h>
15633 static struct uts_namespace *create_uts_ns(void)
15635 struct uts_namespace *uts_ns;
15637 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15640 kref_init(&uts_ns->kref);
15641 + atomic_inc(&vs_global_uts_ns);
15646 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
15647 * @old_ns: namespace to clone
15648 * Return NULL on error (failure to kmalloc), new ns otherwise
15650 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
15651 - struct uts_namespace *old_ns)
15652 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
15653 + struct user_namespace *old_user)
15655 struct uts_namespace *ns;
15657 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
15659 down_read(&uts_sem);
15660 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
15661 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
15662 + ns->user_ns = get_user_ns(old_user);
15666 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
15669 struct uts_namespace *copy_utsname(unsigned long flags,
15670 - struct task_struct *tsk)
15671 + struct uts_namespace *old_ns,
15672 + struct user_namespace *user_ns)
15674 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
15675 struct uts_namespace *new_ns;
15678 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
15679 if (!(flags & CLONE_NEWUTS))
15682 - new_ns = clone_uts_ns(tsk, old_ns);
15683 + new_ns = clone_uts_ns(old_ns, user_ns);
15685 put_uts_ns(old_ns);
15687 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
15689 ns = container_of(kref, struct uts_namespace, kref);
15690 put_user_ns(ns->user_ns);
15691 + atomic_dec(&vs_global_uts_ns);
15695 diff -NurpP --minimal linux-3.1.1/kernel/vserver/Kconfig linux-3.1.1-vs2.3.2/kernel/vserver/Kconfig
15696 --- linux-3.1.1/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
15697 +++ linux-3.1.1-vs2.3.2/kernel/vserver/Kconfig 2011-10-24 18:53:33.000000000 +0200
15700 +# Linux VServer configuration
15703 +menu "Linux VServer"
15705 +config VSERVER_AUTO_LBACK
15706 + bool "Automatically Assign Loopback IP"
15709 + Automatically assign a guest specific loopback
15710 + IP and add it to the kernel network stack on
15713 +config VSERVER_AUTO_SINGLE
15714 + bool "Automatic Single IP Special Casing"
15715 + depends on EXPERIMENTAL
15718 + This allows network contexts with a single IP to
15719 + automatically remap 0.0.0.0 bindings to that IP,
15720 + avoiding further network checks and improving
15723 + (note: such guests do not allow to change the ip
15724 + on the fly and do not show loopback addresses)
15726 +config VSERVER_COWBL
15727 + bool "Enable COW Immutable Link Breaking"
15730 + This enables the COW (Copy-On-Write) link break code.
15731 + It allows you to treat unified files like normal files
15732 + when writing to them (which will implicitely break the
15733 + link and create a copy of the unified file)
15735 +config VSERVER_VTIME
15736 + bool "Enable Virtualized Guest Time"
15737 + depends on EXPERIMENTAL
15740 + This enables per guest time offsets to allow for
15741 + adjusting the system clock individually per guest.
15742 + this adds some overhead to the time functions and
15743 + therefore should not be enabled without good reason.
15745 +config VSERVER_DEVICE
15746 + bool "Enable Guest Device Mapping"
15747 + depends on EXPERIMENTAL
15750 + This enables generic device remapping.
15752 +config VSERVER_PROC_SECURE
15753 + bool "Enable Proc Security"
15754 + depends on PROC_FS
15757 + This configures ProcFS security to initially hide
15758 + non-process entries for all contexts except the main and
15759 + spectator context (i.e. for all guests), which is a secure
15762 + (note: on 1.2x the entries were visible by default)
15765 + prompt "Persistent Inode Tagging"
15766 + default TAGGING_ID24
15768 + This adds persistent context information to filesystems
15769 + mounted with the tagxid option. Tagging is a requirement
15770 + for per-context disk limits and per-context quota.
15773 +config TAGGING_NONE
15776 + do not store per-context information in inodes.
15778 +config TAGGING_UID16
15779 + bool "UID16/GID32"
15781 + reduces UID to 16 bit, but leaves GID at 32 bit.
15783 +config TAGGING_GID16
15784 + bool "UID32/GID16"
15786 + reduces GID to 16 bit, but leaves UID at 32 bit.
15788 +config TAGGING_ID24
15789 + bool "UID24/GID24"
15791 + uses the upper 8bit from UID and GID for XID tagging
15792 + which leaves 24bit for UID/GID each, which should be
15793 + more than sufficient for normal use.
15795 +config TAGGING_INTERN
15796 + bool "UID32/GID32"
15798 + this uses otherwise reserved inode fields in the on
15799 + disk representation, which limits the use to a few
15800 + filesystems (currently ext2 and ext3)
15805 + bool "Tag NFSD User Auth and Files"
15808 + Enable this if you do want the in-kernel NFS
15809 + Server to use the tagging specified above.
15810 + (will require patched clients too)
15812 +config VSERVER_PRIVACY
15813 + bool "Honor Privacy Aspects of Guests"
15816 + When enabled, most context checks will disallow
15817 + access to structures assigned to a specific context,
15818 + like ptys or loop devices.
15820 +config VSERVER_CONTEXTS
15821 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15823 + default "768" if 64BIT
15826 + This setting will optimize certain data structures
15827 + and memory allocations according to the expected
15830 + note: this is not a strict upper limit.
15832 +config VSERVER_WARN
15833 + bool "VServer Warnings"
15836 + This enables various runtime warnings, which will
15837 + notify about potential manipulation attempts or
15838 + resource shortage. It is generally considered to
15839 + be a good idea to have that enabled.
15841 +config VSERVER_WARN_DEVPTS
15842 + bool "VServer DevPTS Warnings"
15843 + depends on VSERVER_WARN
15846 + This enables DevPTS related warnings, issued when a
15847 + process inside a context tries to lookup or access
15848 + a dynamic pts from the host or a different context.
15850 +config VSERVER_DEBUG
15851 + bool "VServer Debugging Code"
15854 + Set this to yes if you want to be able to activate
15855 + debugging output at runtime. It adds a very small
15856 + overhead to all vserver related functions and
15857 + increases the kernel size by about 20k.
15859 +config VSERVER_HISTORY
15860 + bool "VServer History Tracing"
15861 + depends on VSERVER_DEBUG
15864 + Set this to yes if you want to record the history of
15865 + linux-vserver activities, so they can be replayed in
15866 + the event of a kernel panic or oops.
15868 +config VSERVER_HISTORY_SIZE
15869 + int "Per-CPU History Size (32-65536)"
15870 + depends on VSERVER_HISTORY
15874 + This allows you to specify the number of entries in
15875 + the per-CPU history buffer.
15877 +config VSERVER_LEGACY_MEM
15878 + bool "Legacy Memory Limits"
15881 + This provides fake memory limits to keep
15882 + older tools happy in the face of memory
15886 + prompt "Quotes used in debug and warn messages"
15887 + default QUOTES_ISO8859
15889 +config QUOTES_ISO8859
15890 + bool "Extended ASCII (ISO 8859) angle quotes"
15892 + This uses the extended ASCII characters \xbb
15893 + and \xab for quoting file and process names.
15895 +config QUOTES_UTF8
15896 + bool "UTF-8 angle quotes"
15898 + This uses the the UTF-8 sequences for angle
15899 + quotes to quote file and process names.
15901 +config QUOTES_ASCII
15902 + bool "ASCII single quotes"
15904 + This uses the ASCII single quote character
15905 + (\x27) to quote file and process names.
15915 + select NAMESPACES
15921 +config VSERVER_SECURITY
15923 + depends on SECURITY
15925 + select SECURITY_CAPABILITIES
15927 +config VSERVER_DISABLED
15931 diff -NurpP --minimal linux-3.1.1/kernel/vserver/Makefile linux-3.1.1-vs2.3.2/kernel/vserver/Makefile
15932 --- linux-3.1.1/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
15933 +++ linux-3.1.1-vs2.3.2/kernel/vserver/Makefile 2011-10-24 18:53:33.000000000 +0200
15936 +# Makefile for the Linux vserver routines.
15940 +obj-y += vserver.o
15942 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15943 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15946 +vserver-$(CONFIG_INET) += inet.o
15947 +vserver-$(CONFIG_PROC_FS) += proc.o
15948 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15949 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15950 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15951 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
15953 diff -NurpP --minimal linux-3.1.1/kernel/vserver/cacct.c linux-3.1.1-vs2.3.2/kernel/vserver/cacct.c
15954 --- linux-3.1.1/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
15955 +++ linux-3.1.1-vs2.3.2/kernel/vserver/cacct.c 2011-10-24 18:53:33.000000000 +0200
15958 + * linux/kernel/vserver/cacct.c
15960 + * Virtual Server: Context Accounting
15962 + * Copyright (C) 2006-2007 Herbert Pötzl
15964 + * V0.01 added accounting stats
15968 +#include <linux/types.h>
15969 +#include <linux/vs_context.h>
15970 +#include <linux/vserver/cacct_cmd.h>
15971 +#include <linux/vserver/cacct_int.h>
15973 +#include <asm/errno.h>
15974 +#include <asm/uaccess.h>
15977 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15979 + struct vcmd_sock_stat_v0 vc_data;
15982 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15985 + field = vc_data.field;
15986 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15989 + for (j = 0; j < 3; j++) {
15990 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15991 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15994 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15999 diff -NurpP --minimal linux-3.1.1/kernel/vserver/cacct_init.h linux-3.1.1-vs2.3.2/kernel/vserver/cacct_init.h
16000 --- linux-3.1.1/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
16001 +++ linux-3.1.1-vs2.3.2/kernel/vserver/cacct_init.h 2011-10-24 18:53:33.000000000 +0200
16005 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
16010 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16011 + for (j = 0; j < 3; j++) {
16012 + atomic_long_set(&cacct->sock[i][j].count, 0);
16013 + atomic_long_set(&cacct->sock[i][j].total, 0);
16016 + for (i = 0; i < 8; i++)
16017 + atomic_set(&cacct->slab[i], 0);
16018 + for (i = 0; i < 5; i++)
16019 + for (j = 0; j < 4; j++)
16020 + atomic_set(&cacct->page[i][j], 0);
16023 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
16028 diff -NurpP --minimal linux-3.1.1/kernel/vserver/cacct_proc.h linux-3.1.1-vs2.3.2/kernel/vserver/cacct_proc.h
16029 --- linux-3.1.1/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
16030 +++ linux-3.1.1-vs2.3.2/kernel/vserver/cacct_proc.h 2011-10-24 18:53:33.000000000 +0200
16032 +#ifndef _VX_CACCT_PROC_H
16033 +#define _VX_CACCT_PROC_H
16035 +#include <linux/vserver/cacct_int.h>
16038 +#define VX_SOCKA_TOP \
16039 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
16041 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
16043 + int i, j, length = 0;
16044 + static char *type[VXA_SOCK_SIZE] = {
16045 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
16048 + length += sprintf(buffer + length, VX_SOCKA_TOP);
16049 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
16050 + length += sprintf(buffer + length, "%s:", type[i]);
16051 + for (j = 0; j < 3; j++) {
16052 + length += sprintf(buffer + length,
16053 + "\t%10lu/%-10lu",
16054 + vx_sock_count(cacct, i, j),
16055 + vx_sock_total(cacct, i, j));
16057 + buffer[length++] = '\n';
16060 + length += sprintf(buffer + length, "\n");
16061 + length += sprintf(buffer + length,
16062 + "slab:\t %8u %8u %8u %8u\n",
16063 + atomic_read(&cacct->slab[1]),
16064 + atomic_read(&cacct->slab[4]),
16065 + atomic_read(&cacct->slab[0]),
16066 + atomic_read(&cacct->slab[2]));
16068 + length += sprintf(buffer + length, "\n");
16069 + for (i = 0; i < 5; i++) {
16070 + length += sprintf(buffer + length,
16071 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
16072 + atomic_read(&cacct->page[i][0]),
16073 + atomic_read(&cacct->page[i][1]),
16074 + atomic_read(&cacct->page[i][2]),
16075 + atomic_read(&cacct->page[i][3]),
16076 + atomic_read(&cacct->page[i][4]),
16077 + atomic_read(&cacct->page[i][5]),
16078 + atomic_read(&cacct->page[i][6]),
16079 + atomic_read(&cacct->page[i][7]));
16084 +#endif /* _VX_CACCT_PROC_H */
16085 diff -NurpP --minimal linux-3.1.1/kernel/vserver/context.c linux-3.1.1-vs2.3.2/kernel/vserver/context.c
16086 --- linux-3.1.1/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
16087 +++ linux-3.1.1-vs2.3.2/kernel/vserver/context.c 2011-10-24 18:53:33.000000000 +0200
16090 + * linux/kernel/vserver/context.c
16092 + * Virtual Server: Context Support
16094 + * Copyright (C) 2003-2011 Herbert Pötzl
16096 + * V0.01 context helper
16097 + * V0.02 vx_ctx_kill syscall command
16098 + * V0.03 replaced context_info calls
16099 + * V0.04 redesign of struct (de)alloc
16100 + * V0.05 rlimit basic implementation
16101 + * V0.06 task_xid and info commands
16102 + * V0.07 context flags and caps
16103 + * V0.08 switch to RCU based hash
16104 + * V0.09 revert to non RCU for now
16105 + * V0.10 and back to working RCU hash
16106 + * V0.11 and back to locking again
16107 + * V0.12 referenced context store
16108 + * V0.13 separate per cpu data
16109 + * V0.14 changed vcmds to vxi arg
16110 + * V0.15 added context stat
16111 + * V0.16 have __create claim() the vxi
16112 + * V0.17 removed older and legacy stuff
16113 + * V0.18 added user credentials
16114 + * V0.19 added warn mask
16118 +#include <linux/slab.h>
16119 +#include <linux/types.h>
16120 +#include <linux/security.h>
16121 +#include <linux/pid_namespace.h>
16122 +#include <linux/capability.h>
16124 +#include <linux/vserver/context.h>
16125 +#include <linux/vserver/network.h>
16126 +#include <linux/vserver/debug.h>
16127 +#include <linux/vserver/limit.h>
16128 +#include <linux/vserver/limit_int.h>
16129 +#include <linux/vserver/space.h>
16130 +#include <linux/init_task.h>
16131 +#include <linux/fs_struct.h>
16132 +#include <linux/cred.h>
16134 +#include <linux/vs_context.h>
16135 +#include <linux/vs_limit.h>
16136 +#include <linux/vs_pid.h>
16137 +#include <linux/vserver/context_cmd.h>
16139 +#include "cvirt_init.h"
16140 +#include "cacct_init.h"
16141 +#include "limit_init.h"
16142 +#include "sched_init.h"
16145 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
16146 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
16149 +/* now inactive context structures */
16151 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
16153 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
16156 +/* __alloc_vx_info()
16158 + * allocate an initialized vx_info struct
16159 + * doesn't make it visible (hash) */
16161 +static struct vx_info *__alloc_vx_info(xid_t xid)
16163 + struct vx_info *new = NULL;
16166 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
16168 + /* would this benefit from a slab cache? */
16169 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
16173 + memset(new, 0, sizeof(struct vx_info));
16175 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
16176 + if (!new->ptr_pc)
16179 + new->vx_id = xid;
16180 + INIT_HLIST_NODE(&new->vx_hlist);
16181 + atomic_set(&new->vx_usecnt, 0);
16182 + atomic_set(&new->vx_tasks, 0);
16183 + new->vx_parent = NULL;
16184 + new->vx_state = 0;
16185 + init_waitqueue_head(&new->vx_wait);
16187 + /* prepare reaper */
16188 + get_task_struct(init_pid_ns.child_reaper);
16189 + new->vx_reaper = init_pid_ns.child_reaper;
16190 + new->vx_badness_bias = 0;
16192 + /* rest of init goes here */
16193 + vx_info_init_limit(&new->limit);
16194 + vx_info_init_sched(&new->sched);
16195 + vx_info_init_cvirt(&new->cvirt);
16196 + vx_info_init_cacct(&new->cacct);
16198 + /* per cpu data structures */
16199 + for_each_possible_cpu(cpu) {
16200 + vx_info_init_sched_pc(
16201 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16202 + vx_info_init_cvirt_pc(
16203 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16206 + new->vx_flags = VXF_INIT_SET;
16207 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
16208 + new->vx_ccaps = 0;
16209 + new->vx_umask = 0;
16210 + new->vx_wmask = 0;
16212 + new->reboot_cmd = 0;
16213 + new->exit_code = 0;
16215 + // preconfig spaces
16216 + for (index = 0; index < VX_SPACES; index++) {
16217 + struct _vx_space *space = &new->space[index];
16220 + spin_lock(&init_fs.lock);
16222 + spin_unlock(&init_fs.lock);
16223 + space->vx_fs = &init_fs;
16225 + /* FIXME: do we want defaults? */
16226 + // space->vx_real_cred = 0;
16227 + // space->vx_cred = 0;
16231 + vxdprintk(VXD_CBIT(xid, 0),
16232 + "alloc_vx_info(%d) = %p", xid, new);
16233 + vxh_alloc_vx_info(new);
16234 + atomic_inc(&vx_global_ctotal);
16243 +/* __dealloc_vx_info()
16245 + * final disposal of vx_info */
16247 +static void __dealloc_vx_info(struct vx_info *vxi)
16249 +#ifdef CONFIG_VSERVER_WARN
16250 + struct vx_info_save vxis;
16253 + vxdprintk(VXD_CBIT(xid, 0),
16254 + "dealloc_vx_info(%p)", vxi);
16255 + vxh_dealloc_vx_info(vxi);
16257 +#ifdef CONFIG_VSERVER_WARN
16258 + enter_vx_info(vxi, &vxis);
16259 + vx_info_exit_limit(&vxi->limit);
16260 + vx_info_exit_sched(&vxi->sched);
16261 + vx_info_exit_cvirt(&vxi->cvirt);
16262 + vx_info_exit_cacct(&vxi->cacct);
16264 + for_each_possible_cpu(cpu) {
16265 + vx_info_exit_sched_pc(
16266 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16267 + vx_info_exit_cvirt_pc(
16268 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16270 + leave_vx_info(&vxis);
16274 + vxi->vx_state |= VXS_RELEASED;
16277 + free_percpu(vxi->ptr_pc);
16280 + atomic_dec(&vx_global_ctotal);
16283 +static void __shutdown_vx_info(struct vx_info *vxi)
16285 + struct nsproxy *nsproxy;
16286 + struct fs_struct *fs;
16287 + struct cred *cred;
16292 + vxi->vx_state |= VXS_SHUTDOWN;
16293 + vs_state_change(vxi, VSC_SHUTDOWN);
16295 + for (index = 0; index < VX_SPACES; index++) {
16296 + struct _vx_space *space = &vxi->space[index];
16298 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16300 + put_nsproxy(nsproxy);
16302 + fs = xchg(&space->vx_fs, NULL);
16303 + spin_lock(&fs->lock);
16304 + kill = !--fs->users;
16305 + spin_unlock(&fs->lock);
16307 + free_fs_struct(fs);
16309 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16311 + abort_creds(cred);
16315 +/* exported stuff */
16317 +void free_vx_info(struct vx_info *vxi)
16319 + unsigned long flags;
16322 + /* check for reference counts first */
16323 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16324 + BUG_ON(atomic_read(&vxi->vx_tasks));
16326 + /* context must not be hashed */
16327 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16329 + /* context shutdown is mandatory */
16330 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16332 + /* spaces check */
16333 + for (index = 0; index < VX_SPACES; index++) {
16334 + struct _vx_space *space = &vxi->space[index];
16336 + BUG_ON(space->vx_nsproxy);
16337 + BUG_ON(space->vx_fs);
16338 + // BUG_ON(space->vx_real_cred);
16339 + // BUG_ON(space->vx_cred);
16342 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16343 + hlist_del(&vxi->vx_hlist);
16344 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16346 + __dealloc_vx_info(vxi);
16350 +/* hash table for vx_info hash */
16352 +#define VX_HASH_SIZE 13
16354 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16355 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16357 +static DEFINE_SPINLOCK(vx_info_hash_lock);
16360 +static inline unsigned int __hashval(xid_t xid)
16362 + return (xid % VX_HASH_SIZE);
16367 +/* __hash_vx_info()
16369 + * add the vxi to the global hash table
16370 + * requires the hash_lock to be held */
16372 +static inline void __hash_vx_info(struct vx_info *vxi)
16374 + struct hlist_head *head;
16376 + vxd_assert_lock(&vx_info_hash_lock);
16377 + vxdprintk(VXD_CBIT(xid, 4),
16378 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16379 + vxh_hash_vx_info(vxi);
16381 + /* context must not be hashed */
16382 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16384 + vxi->vx_state |= VXS_HASHED;
16385 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16386 + hlist_add_head(&vxi->vx_hlist, head);
16387 + atomic_inc(&vx_global_cactive);
16390 +/* __unhash_vx_info()
16392 + * remove the vxi from the global hash table
16393 + * requires the hash_lock to be held */
16395 +static inline void __unhash_vx_info(struct vx_info *vxi)
16397 + unsigned long flags;
16399 + vxd_assert_lock(&vx_info_hash_lock);
16400 + vxdprintk(VXD_CBIT(xid, 4),
16401 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16402 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16403 + vxh_unhash_vx_info(vxi);
16405 + /* context must be hashed */
16406 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16407 + /* but without tasks */
16408 + BUG_ON(atomic_read(&vxi->vx_tasks));
16410 + vxi->vx_state &= ~VXS_HASHED;
16411 + hlist_del_init(&vxi->vx_hlist);
16412 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16413 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16414 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16415 + atomic_dec(&vx_global_cactive);
16419 +/* __lookup_vx_info()
16421 + * requires the hash_lock to be held
16422 + * doesn't increment the vx_refcnt */
16424 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16426 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16427 + struct hlist_node *pos;
16428 + struct vx_info *vxi;
16430 + vxd_assert_lock(&vx_info_hash_lock);
16431 + hlist_for_each(pos, head) {
16432 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16434 + if (vxi->vx_id == xid)
16439 + vxdprintk(VXD_CBIT(xid, 0),
16440 + "__lookup_vx_info(#%u): %p[#%u]",
16441 + xid, vxi, vxi ? vxi->vx_id : 0);
16442 + vxh_lookup_vx_info(vxi, xid);
16447 +/* __create_vx_info()
16449 + * create the requested context
16450 + * get(), claim() and hash it */
16452 +static struct vx_info *__create_vx_info(int id)
16454 + struct vx_info *new, *vxi = NULL;
16456 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16458 + if (!(new = __alloc_vx_info(id)))
16459 + return ERR_PTR(-ENOMEM);
16461 + /* required to make dynamic xids unique */
16462 + spin_lock(&vx_info_hash_lock);
16464 + /* static context requested */
16465 + if ((vxi = __lookup_vx_info(id))) {
16466 + vxdprintk(VXD_CBIT(xid, 0),
16467 + "create_vx_info(%d) = %p (already there)", id, vxi);
16468 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16469 + vxi = ERR_PTR(-EBUSY);
16471 + vxi = ERR_PTR(-EEXIST);
16474 + /* new context */
16475 + vxdprintk(VXD_CBIT(xid, 0),
16476 + "create_vx_info(%d) = %p (new)", id, new);
16477 + claim_vx_info(new, NULL);
16478 + __hash_vx_info(get_vx_info(new));
16479 + vxi = new, new = NULL;
16482 + spin_unlock(&vx_info_hash_lock);
16483 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16485 + __dealloc_vx_info(new);
16490 +/* exported stuff */
16493 +void unhash_vx_info(struct vx_info *vxi)
16495 + spin_lock(&vx_info_hash_lock);
16496 + __unhash_vx_info(vxi);
16497 + spin_unlock(&vx_info_hash_lock);
16498 + __shutdown_vx_info(vxi);
16499 + __wakeup_vx_info(vxi);
16503 +/* lookup_vx_info()
16505 + * search for a vx_info and get() it
16506 + * negative id means current */
16508 +struct vx_info *lookup_vx_info(int id)
16510 + struct vx_info *vxi = NULL;
16513 + vxi = get_vx_info(current_vx_info());
16514 + } else if (id > 1) {
16515 + spin_lock(&vx_info_hash_lock);
16516 + vxi = get_vx_info(__lookup_vx_info(id));
16517 + spin_unlock(&vx_info_hash_lock);
16522 +/* xid_is_hashed()
16524 + * verify that xid is still hashed */
16526 +int xid_is_hashed(xid_t xid)
16530 + spin_lock(&vx_info_hash_lock);
16531 + hashed = (__lookup_vx_info(xid) != NULL);
16532 + spin_unlock(&vx_info_hash_lock);
16536 +#ifdef CONFIG_PROC_FS
16540 + * get a subset of hashed xids for proc
16541 + * assumes size is at least one */
16543 +int get_xid_list(int index, unsigned int *xids, int size)
16545 + int hindex, nr_xids = 0;
16547 + /* only show current and children */
16548 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16551 + xids[nr_xids] = vx_current_xid();
16555 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16556 + struct hlist_head *head = &vx_info_hash[hindex];
16557 + struct hlist_node *pos;
16559 + spin_lock(&vx_info_hash_lock);
16560 + hlist_for_each(pos, head) {
16561 + struct vx_info *vxi;
16566 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16567 + xids[nr_xids] = vxi->vx_id;
16568 + if (++nr_xids >= size) {
16569 + spin_unlock(&vx_info_hash_lock);
16573 + /* keep the lock time short */
16574 + spin_unlock(&vx_info_hash_lock);
16581 +#ifdef CONFIG_VSERVER_DEBUG
16583 +void dump_vx_info_inactive(int level)
16585 + struct hlist_node *entry, *next;
16587 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16588 + struct vx_info *vxi =
16589 + list_entry(entry, struct vx_info, vx_hlist);
16591 + dump_vx_info(vxi, level);
16598 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16600 + struct user_struct *new_user, *old_user;
16605 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16608 + new_user = alloc_uid(vxi->vx_id, p->uid);
16612 + old_user = p->user;
16613 + if (new_user != old_user) {
16614 + atomic_inc(&new_user->processes);
16615 + atomic_dec(&old_user->processes);
16616 + p->user = new_user;
16618 + free_uid(old_user);
16624 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16626 + // p->cap_effective &= vxi->vx_cap_bset;
16627 + p->cap_effective =
16628 + cap_intersect(p->cap_effective, vxi->cap_bset);
16629 + // p->cap_inheritable &= vxi->vx_cap_bset;
16630 + p->cap_inheritable =
16631 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16632 + // p->cap_permitted &= vxi->vx_cap_bset;
16633 + p->cap_permitted =
16634 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16639 +#include <linux/file.h>
16640 +#include <linux/fdtable.h>
16642 +static int vx_openfd_task(struct task_struct *tsk)
16644 + struct files_struct *files = tsk->files;
16645 + struct fdtable *fdt;
16646 + const unsigned long *bptr;
16647 + int count, total;
16649 + /* no rcu_read_lock() because of spin_lock() */
16650 + spin_lock(&files->file_lock);
16651 + fdt = files_fdtable(files);
16652 + bptr = fdt->open_fds->fds_bits;
16653 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16654 + for (total = 0; count > 0; count--) {
16656 + total += hweight_long(*bptr);
16659 + spin_unlock(&files->file_lock);
16664 +/* for *space compatibility */
16666 +asmlinkage long sys_unshare(unsigned long);
16669 + * migrate task to new context
16670 + * gets vxi, puts old_vxi on change
16671 + * optionally unshares namespaces (hack)
16674 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16676 + struct vx_info *old_vxi;
16682 + vxdprintk(VXD_CBIT(xid, 5),
16683 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16684 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16686 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16687 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16690 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16693 + old_vxi = task_get_vx_info(p);
16694 + if (old_vxi == vxi)
16697 +// if (!(ret = vx_migrate_user(p, vxi))) {
16702 + openfd = vx_openfd_task(p);
16705 + atomic_dec(&old_vxi->cvirt.nr_threads);
16706 + atomic_dec(&old_vxi->cvirt.nr_running);
16707 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16708 + /* FIXME: what about the struct files here? */
16709 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16710 + /* account for the executable */
16711 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16713 + atomic_inc(&vxi->cvirt.nr_threads);
16714 + atomic_inc(&vxi->cvirt.nr_running);
16715 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16716 + /* FIXME: what about the struct files here? */
16717 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16718 + /* account for the executable */
16719 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16722 + release_vx_info(old_vxi, p);
16723 + clr_vx_info(&p->vx_info);
16725 + claim_vx_info(vxi, p);
16726 + set_vx_info(&p->vx_info, vxi);
16727 + p->xid = vxi->vx_id;
16729 + vxdprintk(VXD_CBIT(xid, 5),
16730 + "moved task %p into vxi:%p[#%d]",
16731 + p, vxi, vxi->vx_id);
16733 + // vx_mask_cap_bset(vxi, p);
16736 + /* hack for *spaces to provide compatibility */
16738 + struct nsproxy *old_nsp, *new_nsp;
16740 + ret = unshare_nsproxy_namespaces(
16741 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16746 + old_nsp = xchg(&p->nsproxy, new_nsp);
16747 + vx_set_space(vxi,
16748 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16749 + put_nsproxy(old_nsp);
16753 + put_vx_info(old_vxi);
16757 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16759 + struct task_struct *old_reaper;
16764 + vxdprintk(VXD_CBIT(xid, 6),
16765 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16766 + vxi, vxi->vx_id, p, p->xid, p->pid);
16768 + old_reaper = vxi->vx_reaper;
16769 + if (old_reaper == p)
16772 + /* set new child reaper */
16773 + get_task_struct(p);
16774 + vxi->vx_reaper = p;
16775 + put_task_struct(old_reaper);
16779 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16784 + vxdprintk(VXD_CBIT(xid, 6),
16785 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16786 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16788 + vxi->vx_flags &= ~VXF_STATE_INIT;
16789 + // vxi->vx_initpid = p->tgid;
16790 + vxi->vx_initpid = p->pid;
16794 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16796 + vxdprintk(VXD_CBIT(xid, 6),
16797 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16798 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16800 + vxi->exit_code = code;
16801 + vxi->vx_initpid = 0;
16805 +void vx_set_persistent(struct vx_info *vxi)
16807 + vxdprintk(VXD_CBIT(xid, 6),
16808 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16810 + get_vx_info(vxi);
16811 + claim_vx_info(vxi, NULL);
16814 +void vx_clear_persistent(struct vx_info *vxi)
16816 + vxdprintk(VXD_CBIT(xid, 6),
16817 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16819 + release_vx_info(vxi, NULL);
16820 + put_vx_info(vxi);
16823 +void vx_update_persistent(struct vx_info *vxi)
16825 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16826 + vx_set_persistent(vxi);
16828 + vx_clear_persistent(vxi);
16832 +/* task must be current or locked */
16834 +void exit_vx_info(struct task_struct *p, int code)
16836 + struct vx_info *vxi = p->vx_info;
16839 + atomic_dec(&vxi->cvirt.nr_threads);
16842 + vxi->exit_code = code;
16843 + release_vx_info(vxi, p);
16847 +void exit_vx_info_early(struct task_struct *p, int code)
16849 + struct vx_info *vxi = p->vx_info;
16852 + if (vxi->vx_initpid == p->pid)
16853 + vx_exit_init(vxi, p, code);
16854 + if (vxi->vx_reaper == p)
16855 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16860 +/* vserver syscall commands below here */
16862 +/* taks xid and vx_info functions */
16864 +#include <asm/uaccess.h>
16867 +int vc_task_xid(uint32_t id)
16872 + struct task_struct *tsk;
16875 + tsk = find_task_by_real_pid(id);
16876 + xid = (tsk) ? tsk->xid : -ESRCH;
16877 + rcu_read_unlock();
16879 + xid = vx_current_xid();
16884 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16886 + struct vcmd_vx_info_v0 vc_data;
16888 + vc_data.xid = vxi->vx_id;
16889 + vc_data.initpid = vxi->vx_initpid;
16891 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16897 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16899 + struct vcmd_ctx_stat_v0 vc_data;
16901 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16902 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16904 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16910 +/* context functions */
16912 +int vc_ctx_create(uint32_t xid, void __user *data)
16914 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16915 + struct vx_info *new_vxi;
16918 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16921 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16924 + new_vxi = __create_vx_info(xid);
16925 + if (IS_ERR(new_vxi))
16926 + return PTR_ERR(new_vxi);
16928 + /* initial flags */
16929 + new_vxi->vx_flags = vc_data.flagword;
16932 + if (vs_state_change(new_vxi, VSC_STARTUP))
16935 + ret = vx_migrate_task(current, new_vxi, (!data));
16939 + /* return context id on success */
16940 + ret = new_vxi->vx_id;
16942 + /* get a reference for persistent contexts */
16943 + if ((vc_data.flagword & VXF_PERSISTENT))
16944 + vx_set_persistent(new_vxi);
16946 + release_vx_info(new_vxi, NULL);
16947 + put_vx_info(new_vxi);
16952 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16954 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16957 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16960 + ret = vx_migrate_task(current, vxi, 0);
16963 + if (vc_data.flagword & VXM_SET_INIT)
16964 + ret = vx_set_init(vxi, current);
16967 + if (vc_data.flagword & VXM_SET_REAPER)
16968 + ret = vx_set_reaper(vxi, current);
16973 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16975 + struct vcmd_ctx_flags_v0 vc_data;
16977 + vc_data.flagword = vxi->vx_flags;
16979 + /* special STATE flag handling */
16980 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16982 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16987 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16989 + struct vcmd_ctx_flags_v0 vc_data;
16990 + uint64_t mask, trigger;
16992 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16995 + /* special STATE flag handling */
16996 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16997 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16999 + if (vxi == current_vx_info()) {
17000 + /* if (trigger & VXF_STATE_SETUP)
17001 + vx_mask_cap_bset(vxi, current); */
17002 + if (trigger & VXF_STATE_INIT) {
17005 + ret = vx_set_init(vxi, current);
17008 + ret = vx_set_reaper(vxi, current);
17014 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
17015 + vc_data.flagword, mask);
17016 + if (trigger & VXF_PERSISTENT)
17017 + vx_update_persistent(vxi);
17023 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
17025 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
17027 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
17031 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
17033 + kernel_cap_t c = __cap_empty_set;
17035 + c.cap[0] = v & 0xFFFFFFFF;
17036 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
17038 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
17043 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
17046 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
17048 + *ccaps = vxi->vx_ccaps;
17053 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
17055 + struct vcmd_ctx_caps_v1 vc_data;
17058 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
17061 + vc_data.cmask = ~0ULL;
17063 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17068 +static int do_set_caps(struct vx_info *vxi,
17069 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
17071 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
17074 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
17075 + bcaps, bmask, ccaps, cmask);
17077 + vxi->vx_bcaps = cap_t_from_caps(
17078 + vs_mask_flags(bcold, bcaps, bmask));
17079 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
17084 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
17086 + struct vcmd_ctx_caps_v1 vc_data;
17088 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17091 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
17094 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
17096 + struct vcmd_bcaps vc_data;
17099 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
17102 + vc_data.bmask = ~0ULL;
17104 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17109 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
17111 + struct vcmd_bcaps vc_data;
17113 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17116 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
17120 +int vc_get_umask(struct vx_info *vxi, void __user *data)
17122 + struct vcmd_umask vc_data;
17124 + vc_data.umask = vxi->vx_umask;
17125 + vc_data.mask = ~0ULL;
17127 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17132 +int vc_set_umask(struct vx_info *vxi, void __user *data)
17134 + struct vcmd_umask vc_data;
17136 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17139 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
17140 + vc_data.umask, vc_data.mask);
17145 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
17147 + struct vcmd_wmask vc_data;
17149 + vc_data.wmask = vxi->vx_wmask;
17150 + vc_data.mask = ~0ULL;
17152 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17157 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
17159 + struct vcmd_wmask vc_data;
17161 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17164 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
17165 + vc_data.wmask, vc_data.mask);
17170 +int vc_get_badness(struct vx_info *vxi, void __user *data)
17172 + struct vcmd_badness_v0 vc_data;
17174 + vc_data.bias = vxi->vx_badness_bias;
17176 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17181 +int vc_set_badness(struct vx_info *vxi, void __user *data)
17183 + struct vcmd_badness_v0 vc_data;
17185 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17188 + vxi->vx_badness_bias = vc_data.bias;
17192 +#include <linux/module.h>
17194 +EXPORT_SYMBOL_GPL(free_vx_info);
17196 diff -NurpP --minimal linux-3.1.1/kernel/vserver/cvirt.c linux-3.1.1-vs2.3.2/kernel/vserver/cvirt.c
17197 --- linux-3.1.1/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
17198 +++ linux-3.1.1-vs2.3.2/kernel/vserver/cvirt.c 2011-10-24 18:53:33.000000000 +0200
17201 + * linux/kernel/vserver/cvirt.c
17203 + * Virtual Server: Context Virtualization
17205 + * Copyright (C) 2004-2007 Herbert Pötzl
17207 + * V0.01 broken out from limit.c
17208 + * V0.02 added utsname stuff
17209 + * V0.03 changed vcmds to vxi arg
17213 +#include <linux/types.h>
17214 +#include <linux/utsname.h>
17215 +#include <linux/vs_cvirt.h>
17216 +#include <linux/vserver/switch.h>
17217 +#include <linux/vserver/cvirt_cmd.h>
17219 +#include <asm/uaccess.h>
17222 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17224 + struct vx_info *vxi = current_vx_info();
17226 + set_normalized_timespec(uptime,
17227 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17228 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17231 + set_normalized_timespec(idle,
17232 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17233 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17237 +uint64_t vx_idle_jiffies(void)
17239 + return init_task.utime + init_task.stime;
17244 +static inline uint32_t __update_loadavg(uint32_t load,
17245 + int wsize, int delta, int n)
17247 + unsigned long long calc, prev;
17249 + /* just set it to n */
17250 + if (unlikely(delta >= wsize))
17251 + return (n << FSHIFT);
17253 + calc = delta * n;
17255 + prev = (wsize - delta);
17258 + do_div(calc, wsize);
17263 +void vx_update_load(struct vx_info *vxi)
17265 + uint32_t now, last, delta;
17266 + unsigned int nr_running, nr_uninterruptible;
17267 + unsigned int total;
17268 + unsigned long flags;
17270 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17273 + last = vxi->cvirt.load_last;
17274 + delta = now - last;
17276 + if (delta < 5*HZ)
17279 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17280 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17281 + total = nr_running + nr_uninterruptible;
17283 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17284 + 60*HZ, delta, total);
17285 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17286 + 5*60*HZ, delta, total);
17287 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17288 + 15*60*HZ, delta, total);
17290 + vxi->cvirt.load_last = now;
17292 + atomic_inc(&vxi->cvirt.load_updates);
17293 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17298 + * Commands to do_syslog:
17300 + * 0 -- Close the log. Currently a NOP.
17301 + * 1 -- Open the log. Currently a NOP.
17302 + * 2 -- Read from the log.
17303 + * 3 -- Read all messages remaining in the ring buffer.
17304 + * 4 -- Read and clear all messages remaining in the ring buffer
17305 + * 5 -- Clear ring buffer.
17306 + * 6 -- Disable printk's to console
17307 + * 7 -- Enable printk's to console
17308 + * 8 -- Set level of messages printed to console
17309 + * 9 -- Return number of unread characters in the log buffer
17310 + * 10 -- Return size of the log buffer
17312 +int vx_do_syslog(int type, char __user *buf, int len)
17315 + int do_clear = 0;
17316 + struct vx_info *vxi = current_vx_info();
17317 + struct _vx_syslog *log;
17321 + log = &vxi->cvirt.syslog;
17324 + case 0: /* Close log */
17325 + case 1: /* Open log */
17327 + case 2: /* Read from log */
17328 + error = wait_event_interruptible(log->log_wait,
17329 + (log->log_start - log->log_end));
17332 + spin_lock_irq(&log->logbuf_lock);
17333 + spin_unlock_irq(&log->logbuf_lock);
17335 + case 4: /* Read/clear last kernel messages */
17337 + /* fall through */
17338 + case 3: /* Read last kernel messages */
17341 + case 5: /* Clear ring buffer */
17344 + case 6: /* Disable logging to console */
17345 + case 7: /* Enable logging to console */
17346 + case 8: /* Set level of messages printed to console */
17349 + case 9: /* Number of chars in the log buffer */
17351 + case 10: /* Size of the log buffer */
17361 +/* virtual host info names */
17363 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17365 + struct nsproxy *nsproxy;
17366 + struct uts_namespace *uts;
17368 + if (id == VHIN_CONTEXT)
17369 + return vxi->vx_name;
17371 + nsproxy = vxi->space[0].vx_nsproxy;
17375 + uts = nsproxy->uts_ns;
17380 + case VHIN_SYSNAME:
17381 + return uts->name.sysname;
17382 + case VHIN_NODENAME:
17383 + return uts->name.nodename;
17384 + case VHIN_RELEASE:
17385 + return uts->name.release;
17386 + case VHIN_VERSION:
17387 + return uts->name.version;
17388 + case VHIN_MACHINE:
17389 + return uts->name.machine;
17390 + case VHIN_DOMAINNAME:
17391 + return uts->name.domainname;
17398 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17400 + struct vcmd_vhi_name_v0 vc_data;
17403 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17406 + name = vx_vhi_name(vxi, vc_data.field);
17410 + memcpy(name, vc_data.name, 65);
17414 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17416 + struct vcmd_vhi_name_v0 vc_data;
17419 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17422 + name = vx_vhi_name(vxi, vc_data.field);
17426 + memcpy(vc_data.name, name, 65);
17427 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17433 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17435 + struct vcmd_virt_stat_v0 vc_data;
17436 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17437 + struct timespec uptime;
17439 + do_posix_clock_monotonic_gettime(&uptime);
17440 + set_normalized_timespec(&uptime,
17441 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17442 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17444 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17445 + vc_data.uptime = timespec_to_ns(&uptime);
17446 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17447 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17448 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17449 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17450 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17451 + vc_data.load[0] = cvirt->load[0];
17452 + vc_data.load[1] = cvirt->load[1];
17453 + vc_data.load[2] = cvirt->load[2];
17455 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17461 +#ifdef CONFIG_VSERVER_VTIME
17463 +/* virtualized time base */
17465 +void vx_adjust_timespec(struct timespec *ts)
17467 + struct vx_info *vxi;
17469 + if (!vx_flags(VXF_VIRT_TIME, 0))
17472 + vxi = current_vx_info();
17473 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17474 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17476 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17478 + ts->tv_nsec -= NSEC_PER_SEC;
17479 + } else if (ts->tv_nsec < 0) {
17481 + ts->tv_nsec += NSEC_PER_SEC;
17485 +int vx_settimeofday(const struct timespec *ts)
17487 + struct timespec ats, delta;
17488 + struct vx_info *vxi;
17490 + if (!vx_flags(VXF_VIRT_TIME, 0))
17491 + return do_settimeofday(ts);
17493 + getnstimeofday(&ats);
17494 + delta = timespec_sub(*ts, ats);
17496 + vxi = current_vx_info();
17497 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17503 diff -NurpP --minimal linux-3.1.1/kernel/vserver/cvirt_init.h linux-3.1.1-vs2.3.2/kernel/vserver/cvirt_init.h
17504 --- linux-3.1.1/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17505 +++ linux-3.1.1-vs2.3.2/kernel/vserver/cvirt_init.h 2011-10-24 18:53:33.000000000 +0200
17509 +extern uint64_t vx_idle_jiffies(void);
17511 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17513 + uint64_t idle_jiffies = vx_idle_jiffies();
17514 + uint64_t nsuptime;
17516 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17517 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17518 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17519 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17520 + cvirt->bias_ts.tv_sec = 0;
17521 + cvirt->bias_ts.tv_nsec = 0;
17523 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17524 + atomic_set(&cvirt->nr_threads, 0);
17525 + atomic_set(&cvirt->nr_running, 0);
17526 + atomic_set(&cvirt->nr_uninterruptible, 0);
17527 + atomic_set(&cvirt->nr_onhold, 0);
17529 + spin_lock_init(&cvirt->load_lock);
17530 + cvirt->load_last = jiffies;
17531 + atomic_set(&cvirt->load_updates, 0);
17532 + cvirt->load[0] = 0;
17533 + cvirt->load[1] = 0;
17534 + cvirt->load[2] = 0;
17535 + atomic_set(&cvirt->total_forks, 0);
17537 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17538 + init_waitqueue_head(&cvirt->syslog.log_wait);
17539 + cvirt->syslog.log_start = 0;
17540 + cvirt->syslog.log_end = 0;
17541 + cvirt->syslog.con_start = 0;
17542 + cvirt->syslog.logged_chars = 0;
17546 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17548 + // cvirt_pc->cpustat = { 0 };
17551 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17553 +#ifdef CONFIG_VSERVER_WARN
17556 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17557 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17559 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17560 + "!!! cvirt: %p[nr_running] = %d on exit.",
17562 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17563 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17565 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17566 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17572 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17577 diff -NurpP --minimal linux-3.1.1/kernel/vserver/cvirt_proc.h linux-3.1.1-vs2.3.2/kernel/vserver/cvirt_proc.h
17578 --- linux-3.1.1/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17579 +++ linux-3.1.1-vs2.3.2/kernel/vserver/cvirt_proc.h 2011-10-24 18:53:33.000000000 +0200
17581 +#ifndef _VX_CVIRT_PROC_H
17582 +#define _VX_CVIRT_PROC_H
17584 +#include <linux/nsproxy.h>
17585 +#include <linux/mnt_namespace.h>
17586 +#include <linux/ipc_namespace.h>
17587 +#include <linux/utsname.h>
17588 +#include <linux/ipc.h>
17592 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17594 + struct mnt_namespace *ns;
17595 + struct uts_namespace *uts;
17596 + struct ipc_namespace *ipc;
17597 + struct path path;
17598 + char *pstr, *root;
17604 + length += sprintf(buffer + length,
17605 + "NSProxy:\t%p [%p,%p,%p]\n",
17606 + nsproxy, nsproxy->mnt_ns,
17607 + nsproxy->uts_ns, nsproxy->ipc_ns);
17609 + ns = nsproxy->mnt_ns;
17613 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17617 + path.mnt = ns->root;
17618 + path.dentry = ns->root->mnt_root;
17619 + root = d_path(&path, pstr, PATH_MAX - 2);
17620 + length += sprintf(buffer + length,
17621 + "Namespace:\t%p [#%u]\n"
17622 + "RootPath:\t%s\n",
17623 + ns, atomic_read(&ns->count),
17628 + uts = nsproxy->uts_ns;
17632 + length += sprintf(buffer + length,
17633 + "SysName:\t%.*s\n"
17634 + "NodeName:\t%.*s\n"
17635 + "Release:\t%.*s\n"
17636 + "Version:\t%.*s\n"
17637 + "Machine:\t%.*s\n"
17638 + "DomainName:\t%.*s\n",
17639 + __NEW_UTS_LEN, uts->name.sysname,
17640 + __NEW_UTS_LEN, uts->name.nodename,
17641 + __NEW_UTS_LEN, uts->name.release,
17642 + __NEW_UTS_LEN, uts->name.version,
17643 + __NEW_UTS_LEN, uts->name.machine,
17644 + __NEW_UTS_LEN, uts->name.domainname);
17647 + ipc = nsproxy->ipc_ns;
17651 + length += sprintf(buffer + length,
17652 + "SEMS:\t\t%d %d %d %d %d\n"
17653 + "MSG:\t\t%d %d %d\n"
17654 + "SHM:\t\t%lu %lu %d %d\n",
17655 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17656 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17658 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17659 + (unsigned long)ipc->shm_ctlmax,
17660 + (unsigned long)ipc->shm_ctlall,
17661 + ipc->shm_ctlmni, ipc->shm_tot);
17668 +#include <linux/sched.h>
17670 +#define LOAD_INT(x) ((x) >> FSHIFT)
17671 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17674 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17679 + length += sprintf(buffer + length,
17680 + "BiasUptime:\t%lu.%02lu\n",
17681 + (unsigned long)cvirt->bias_uptime.tv_sec,
17682 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17684 + a = cvirt->load[0] + (FIXED_1 / 200);
17685 + b = cvirt->load[1] + (FIXED_1 / 200);
17686 + c = cvirt->load[2] + (FIXED_1 / 200);
17687 + length += sprintf(buffer + length,
17688 + "nr_threads:\t%d\n"
17689 + "nr_running:\t%d\n"
17690 + "nr_unintr:\t%d\n"
17691 + "nr_onhold:\t%d\n"
17692 + "load_updates:\t%d\n"
17693 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17694 + "total_forks:\t%d\n",
17695 + atomic_read(&cvirt->nr_threads),
17696 + atomic_read(&cvirt->nr_running),
17697 + atomic_read(&cvirt->nr_uninterruptible),
17698 + atomic_read(&cvirt->nr_onhold),
17699 + atomic_read(&cvirt->load_updates),
17700 + LOAD_INT(a), LOAD_FRAC(a),
17701 + LOAD_INT(b), LOAD_FRAC(b),
17702 + LOAD_INT(c), LOAD_FRAC(c),
17703 + atomic_read(&cvirt->total_forks));
17708 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17709 + char *buffer, int cpu)
17715 +#endif /* _VX_CVIRT_PROC_H */
17716 diff -NurpP --minimal linux-3.1.1/kernel/vserver/debug.c linux-3.1.1-vs2.3.2/kernel/vserver/debug.c
17717 --- linux-3.1.1/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17718 +++ linux-3.1.1-vs2.3.2/kernel/vserver/debug.c 2011-10-24 18:53:33.000000000 +0200
17721 + * kernel/vserver/debug.c
17723 + * Copyright (C) 2005-2007 Herbert Pötzl
17725 + * V0.01 vx_info dump support
17729 +#include <linux/module.h>
17731 +#include <linux/vserver/context.h>
17734 +void dump_vx_info(struct vx_info *vxi, int level)
17736 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17737 + atomic_read(&vxi->vx_usecnt),
17738 + atomic_read(&vxi->vx_tasks),
17741 + __dump_vx_limit(&vxi->limit);
17742 + __dump_vx_sched(&vxi->sched);
17743 + __dump_vx_cvirt(&vxi->cvirt);
17744 + __dump_vx_cacct(&vxi->cacct);
17750 +EXPORT_SYMBOL_GPL(dump_vx_info);
17752 diff -NurpP --minimal linux-3.1.1/kernel/vserver/device.c linux-3.1.1-vs2.3.2/kernel/vserver/device.c
17753 --- linux-3.1.1/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17754 +++ linux-3.1.1-vs2.3.2/kernel/vserver/device.c 2011-10-24 18:53:33.000000000 +0200
17757 + * linux/kernel/vserver/device.c
17759 + * Linux-VServer: Device Support
17761 + * Copyright (C) 2006 Herbert Pötzl
17762 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17764 + * V0.01 device mapping basics
17765 + * V0.02 added defaults
17769 +#include <linux/slab.h>
17770 +#include <linux/rcupdate.h>
17771 +#include <linux/fs.h>
17772 +#include <linux/namei.h>
17773 +#include <linux/hash.h>
17775 +#include <asm/errno.h>
17776 +#include <asm/uaccess.h>
17777 +#include <linux/vserver/base.h>
17778 +#include <linux/vserver/debug.h>
17779 +#include <linux/vserver/context.h>
17780 +#include <linux/vserver/device.h>
17781 +#include <linux/vserver/device_cmd.h>
17784 +#define DMAP_HASH_BITS 4
17787 +struct vs_mapping {
17789 + struct hlist_node hlist;
17790 + struct list_head list;
17792 +#define dm_hlist u.hlist
17793 +#define dm_list u.list
17796 + struct vx_dmap_target target;
17800 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17802 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17804 +static struct vx_dmap_target dmap_defaults[2] = {
17805 + { .flags = DATTR_OPEN },
17806 + { .flags = DATTR_OPEN },
17810 +struct kmem_cache *dmap_cachep __read_mostly;
17812 +int __init dmap_cache_init(void)
17814 + dmap_cachep = kmem_cache_create("dmap_cache",
17815 + sizeof(struct vs_mapping), 0,
17816 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17820 +__initcall(dmap_cache_init);
17823 +static inline unsigned int __hashval(dev_t dev, int bits)
17825 + return hash_long((unsigned long)dev, bits);
17829 +/* __hash_mapping()
17830 + * add the mapping to the hash table
17832 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17834 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17835 + struct hlist_head *head, *hash = dmap_main_hash;
17836 + int device = vdm->device;
17838 + spin_lock(hash_lock);
17839 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17840 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17842 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17843 + hlist_add_head(&vdm->dm_hlist, head);
17844 + spin_unlock(hash_lock);
17848 +static inline int __mode_to_default(umode_t mode)
17861 +/* __set_default()
17864 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17865 + struct vx_dmap_target *vdmt)
17867 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17868 + spin_lock(hash_lock);
17871 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17873 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17876 + spin_unlock(hash_lock);
17878 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17879 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17883 +/* __remove_default()
17884 + * remove a default
17886 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17888 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17889 + spin_lock(hash_lock);
17892 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17893 + else /* remove == reset */
17894 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17896 + spin_unlock(hash_lock);
17901 +/* __find_mapping()
17902 + * find a mapping in the hash table
17904 + * caller must hold hash_lock
17906 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17907 + struct vs_mapping **local, struct vs_mapping **global)
17909 + struct hlist_head *hash = dmap_main_hash;
17910 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17911 + struct hlist_node *pos;
17912 + struct vs_mapping *vdm;
17918 + hlist_for_each(pos, head) {
17919 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17921 + if ((vdm->device == device) &&
17922 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17923 + if (vdm->xid == xid) {
17926 + } else if (global && vdm->xid == 0)
17931 + if (global && *global)
17938 +/* __lookup_mapping()
17939 + * find a mapping and store the result in target and flags
17941 +static inline int __lookup_mapping(struct vx_info *vxi,
17942 + dev_t device, dev_t *target, int *flags, umode_t mode)
17944 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17945 + struct vs_mapping *vdm, *global;
17946 + struct vx_dmap_target *vdmt;
17948 + xid_t xid = vxi->vx_id;
17951 + spin_lock(hash_lock);
17952 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17954 + vdmt = &vdm->target;
17958 + index = __mode_to_default(mode);
17959 + if (vxi && vxi->dmap.targets[index].flags) {
17961 + vdmt = &vxi->dmap.targets[index];
17962 + } else if (global) {
17964 + vdmt = &global->target;
17968 + vdmt = &dmap_defaults[index];
17972 + if (target && (vdmt->flags & DATTR_REMAP))
17973 + *target = vdmt->target;
17975 + *target = device;
17977 + *flags = vdmt->flags;
17979 + spin_unlock(hash_lock);
17985 +/* __remove_mapping()
17986 + * remove a mapping from the hash table
17988 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17991 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17992 + struct vs_mapping *vdm = NULL;
17995 + spin_lock(hash_lock);
17997 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17999 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
18000 + vxi, vxi ? vxi->vx_id : 0, device, mode);
18003 + hlist_del(&vdm->dm_hlist);
18006 + spin_unlock(hash_lock);
18008 + kmem_cache_free(dmap_cachep, vdm);
18014 +int vs_map_device(struct vx_info *vxi,
18015 + dev_t device, dev_t *target, umode_t mode)
18017 + int ret, flags = DATTR_MASK;
18021 + *target = device;
18024 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
18025 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
18026 + device, target ? *target : 0, flags, mode, ret);
18028 + return (flags & DATTR_MASK);
18033 +static int do_set_mapping(struct vx_info *vxi,
18034 + dev_t device, dev_t target, int flags, umode_t mode)
18037 + struct vs_mapping *new;
18039 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
18043 + INIT_HLIST_NODE(&new->dm_hlist);
18044 + new->device = device;
18045 + new->target.target = target;
18046 + new->target.flags = flags | mode;
18047 + new->xid = (vxi ? vxi->vx_id : 0);
18049 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
18050 + __hash_mapping(vxi, new);
18052 + struct vx_dmap_target new = {
18053 + .target = target,
18054 + .flags = flags | mode,
18056 + __set_default(vxi, mode, &new);
18062 +static int do_unset_mapping(struct vx_info *vxi,
18063 + dev_t device, dev_t target, int flags, umode_t mode)
18065 + int ret = -EINVAL;
18068 + ret = __remove_mapping(vxi, device, mode);
18072 + ret = __remove_default(vxi, mode);
18082 +static inline int __user_device(const char __user *name, dev_t *dev,
18085 + struct nameidata nd;
18092 + ret = user_lpath(name, &nd.path);
18095 + if (nd.path.dentry->d_inode) {
18096 + *dev = nd.path.dentry->d_inode->i_rdev;
18097 + *mode = nd.path.dentry->d_inode->i_mode;
18099 + path_put(&nd.path);
18103 +static inline int __mapping_mode(dev_t device, dev_t target,
18104 + umode_t device_mode, umode_t target_mode, umode_t *mode)
18107 + *mode = device_mode & S_IFMT;
18109 + *mode = target_mode & S_IFMT;
18113 + /* if both given, device and target mode have to match */
18114 + if (device && target &&
18115 + ((device_mode ^ target_mode) & S_IFMT))
18121 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
18122 + const char __user *target_path, int flags, int set)
18124 + dev_t device = ~0, target = ~0;
18125 + umode_t device_mode = 0, target_mode = 0, mode;
18128 + ret = __user_device(device_path, &device, &device_mode);
18131 + ret = __user_device(target_path, &target, &target_mode);
18135 + ret = __mapping_mode(device, target,
18136 + device_mode, target_mode, &mode);
18141 + return do_set_mapping(vxi, device, target,
18144 + return do_unset_mapping(vxi, device, target,
18149 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
18151 + struct vcmd_set_mapping_v0 vc_data;
18153 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18156 + return do_mapping(vxi, vc_data.device, vc_data.target,
18157 + vc_data.flags, 1);
18160 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
18162 + struct vcmd_set_mapping_v0 vc_data;
18164 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18167 + return do_mapping(vxi, vc_data.device, vc_data.target,
18168 + vc_data.flags, 0);
18172 +#ifdef CONFIG_COMPAT
18174 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
18176 + struct vcmd_set_mapping_v0_x32 vc_data;
18178 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18181 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18182 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
18185 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18187 + struct vcmd_set_mapping_v0_x32 vc_data;
18189 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18192 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18193 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18196 +#endif /* CONFIG_COMPAT */
18199 diff -NurpP --minimal linux-3.1.1/kernel/vserver/dlimit.c linux-3.1.1-vs2.3.2/kernel/vserver/dlimit.c
18200 --- linux-3.1.1/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
18201 +++ linux-3.1.1-vs2.3.2/kernel/vserver/dlimit.c 2011-10-24 18:53:33.000000000 +0200
18204 + * linux/kernel/vserver/dlimit.c
18206 + * Virtual Server: Context Disk Limits
18208 + * Copyright (C) 2004-2009 Herbert Pötzl
18210 + * V0.01 initial version
18211 + * V0.02 compat32 splitup
18212 + * V0.03 extended interface
18216 +#include <linux/statfs.h>
18217 +#include <linux/sched.h>
18218 +#include <linux/namei.h>
18219 +#include <linux/vs_tag.h>
18220 +#include <linux/vs_dlimit.h>
18221 +#include <linux/vserver/dlimit_cmd.h>
18222 +#include <linux/slab.h>
18223 +// #include <linux/gfp.h>
18225 +#include <asm/uaccess.h>
18227 +/* __alloc_dl_info()
18229 + * allocate an initialized dl_info struct
18230 + * doesn't make it visible (hash) */
18232 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18234 + struct dl_info *new = NULL;
18236 + vxdprintk(VXD_CBIT(dlim, 5),
18237 + "alloc_dl_info(%p,%d)*", sb, tag);
18239 + /* would this benefit from a slab cache? */
18240 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18244 + memset(new, 0, sizeof(struct dl_info));
18245 + new->dl_tag = tag;
18247 + // INIT_RCU_HEAD(&new->dl_rcu);
18248 + INIT_HLIST_NODE(&new->dl_hlist);
18249 + spin_lock_init(&new->dl_lock);
18250 + atomic_set(&new->dl_refcnt, 0);
18251 + atomic_set(&new->dl_usecnt, 0);
18253 + /* rest of init goes here */
18255 + vxdprintk(VXD_CBIT(dlim, 4),
18256 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18260 +/* __dealloc_dl_info()
18262 + * final disposal of dl_info */
18264 +static void __dealloc_dl_info(struct dl_info *dli)
18266 + vxdprintk(VXD_CBIT(dlim, 4),
18267 + "dealloc_dl_info(%p)", dli);
18269 + dli->dl_hlist.next = LIST_POISON1;
18270 + dli->dl_tag = -1;
18273 + BUG_ON(atomic_read(&dli->dl_usecnt));
18274 + BUG_ON(atomic_read(&dli->dl_refcnt));
18280 +/* hash table for dl_info hash */
18282 +#define DL_HASH_SIZE 13
18284 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18286 +static DEFINE_SPINLOCK(dl_info_hash_lock);
18289 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18291 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18296 +/* __hash_dl_info()
18298 + * add the dli to the global hash table
18299 + * requires the hash_lock to be held */
18301 +static inline void __hash_dl_info(struct dl_info *dli)
18303 + struct hlist_head *head;
18305 + vxdprintk(VXD_CBIT(dlim, 6),
18306 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18307 + get_dl_info(dli);
18308 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18309 + hlist_add_head_rcu(&dli->dl_hlist, head);
18312 +/* __unhash_dl_info()
18314 + * remove the dli from the global hash table
18315 + * requires the hash_lock to be held */
18317 +static inline void __unhash_dl_info(struct dl_info *dli)
18319 + vxdprintk(VXD_CBIT(dlim, 6),
18320 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18321 + hlist_del_rcu(&dli->dl_hlist);
18322 + put_dl_info(dli);
18326 +/* __lookup_dl_info()
18328 + * requires the rcu_read_lock()
18329 + * doesn't increment the dl_refcnt */
18331 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18333 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18334 + struct hlist_node *pos;
18335 + struct dl_info *dli;
18337 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18339 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18347 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18349 + struct dl_info *dli;
18352 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18353 + vxdprintk(VXD_CBIT(dlim, 7),
18354 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18355 + rcu_read_unlock();
18359 +void rcu_free_dl_info(struct rcu_head *head)
18361 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18362 + int usecnt, refcnt;
18364 + BUG_ON(!dli || !head);
18366 + usecnt = atomic_read(&dli->dl_usecnt);
18367 + BUG_ON(usecnt < 0);
18369 + refcnt = atomic_read(&dli->dl_refcnt);
18370 + BUG_ON(refcnt < 0);
18372 + vxdprintk(VXD_CBIT(dlim, 3),
18373 + "rcu_free_dl_info(%p)", dli);
18375 + __dealloc_dl_info(dli);
18377 + printk("!!! rcu didn't free\n");
18383 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18384 + uint32_t flags, int add)
18386 + struct path path;
18389 + ret = user_lpath(name, &path);
18391 + struct super_block *sb;
18392 + struct dl_info *dli;
18395 + if (!path.dentry->d_inode)
18396 + goto out_release;
18397 + if (!(sb = path.dentry->d_inode->i_sb))
18398 + goto out_release;
18401 + dli = __alloc_dl_info(sb, id);
18402 + spin_lock(&dl_info_hash_lock);
18405 + if (__lookup_dl_info(sb, id))
18407 + __hash_dl_info(dli);
18410 + spin_lock(&dl_info_hash_lock);
18411 + dli = __lookup_dl_info(sb, id);
18416 + __unhash_dl_info(dli);
18420 + spin_unlock(&dl_info_hash_lock);
18422 + __dealloc_dl_info(dli);
18429 +int vc_add_dlimit(uint32_t id, void __user *data)
18431 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18433 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18436 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18439 +int vc_rem_dlimit(uint32_t id, void __user *data)
18441 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18443 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18446 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18449 +#ifdef CONFIG_COMPAT
18451 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18453 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18455 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18458 + return do_addrem_dlimit(id,
18459 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18462 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18464 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18466 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18469 + return do_addrem_dlimit(id,
18470 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18473 +#endif /* CONFIG_COMPAT */
18477 +int do_set_dlimit(uint32_t id, const char __user *name,
18478 + uint32_t space_used, uint32_t space_total,
18479 + uint32_t inodes_used, uint32_t inodes_total,
18480 + uint32_t reserved, uint32_t flags)
18482 + struct path path;
18485 + ret = user_lpath(name, &path);
18487 + struct super_block *sb;
18488 + struct dl_info *dli;
18491 + if (!path.dentry->d_inode)
18492 + goto out_release;
18493 + if (!(sb = path.dentry->d_inode->i_sb))
18494 + goto out_release;
18496 + /* sanity checks */
18497 + if ((reserved != CDLIM_KEEP &&
18498 + reserved > 100) ||
18499 + (inodes_used != CDLIM_KEEP &&
18500 + inodes_used > inodes_total) ||
18501 + (space_used != CDLIM_KEEP &&
18502 + space_used > space_total))
18503 + goto out_release;
18506 + dli = locate_dl_info(sb, id);
18508 + goto out_release;
18510 + spin_lock(&dli->dl_lock);
18512 + if (inodes_used != CDLIM_KEEP)
18513 + dli->dl_inodes_used = inodes_used;
18514 + if (inodes_total != CDLIM_KEEP)
18515 + dli->dl_inodes_total = inodes_total;
18516 + if (space_used != CDLIM_KEEP)
18517 + dli->dl_space_used = dlimit_space_32to64(
18518 + space_used, flags, DLIMS_USED);
18520 + if (space_total == CDLIM_INFINITY)
18521 + dli->dl_space_total = DLIM_INFINITY;
18522 + else if (space_total != CDLIM_KEEP)
18523 + dli->dl_space_total = dlimit_space_32to64(
18524 + space_total, flags, DLIMS_TOTAL);
18526 + if (reserved != CDLIM_KEEP)
18527 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18529 + spin_unlock(&dli->dl_lock);
18531 + put_dl_info(dli);
18540 +int vc_set_dlimit(uint32_t id, void __user *data)
18542 + struct vcmd_ctx_dlimit_v0 vc_data;
18544 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18547 + return do_set_dlimit(id, vc_data.name,
18548 + vc_data.space_used, vc_data.space_total,
18549 + vc_data.inodes_used, vc_data.inodes_total,
18550 + vc_data.reserved, vc_data.flags);
18553 +#ifdef CONFIG_COMPAT
18555 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18557 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18559 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18562 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18563 + vc_data.space_used, vc_data.space_total,
18564 + vc_data.inodes_used, vc_data.inodes_total,
18565 + vc_data.reserved, vc_data.flags);
18568 +#endif /* CONFIG_COMPAT */
18572 +int do_get_dlimit(uint32_t id, const char __user *name,
18573 + uint32_t *space_used, uint32_t *space_total,
18574 + uint32_t *inodes_used, uint32_t *inodes_total,
18575 + uint32_t *reserved, uint32_t *flags)
18577 + struct path path;
18580 + ret = user_lpath(name, &path);
18582 + struct super_block *sb;
18583 + struct dl_info *dli;
18586 + if (!path.dentry->d_inode)
18587 + goto out_release;
18588 + if (!(sb = path.dentry->d_inode->i_sb))
18589 + goto out_release;
18592 + dli = locate_dl_info(sb, id);
18594 + goto out_release;
18596 + spin_lock(&dli->dl_lock);
18597 + *inodes_used = dli->dl_inodes_used;
18598 + *inodes_total = dli->dl_inodes_total;
18600 + *space_used = dlimit_space_64to32(
18601 + dli->dl_space_used, flags, DLIMS_USED);
18603 + if (dli->dl_space_total == DLIM_INFINITY)
18604 + *space_total = CDLIM_INFINITY;
18606 + *space_total = dlimit_space_64to32(
18607 + dli->dl_space_total, flags, DLIMS_TOTAL);
18609 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18610 + spin_unlock(&dli->dl_lock);
18612 + put_dl_info(dli);
18623 +int vc_get_dlimit(uint32_t id, void __user *data)
18625 + struct vcmd_ctx_dlimit_v0 vc_data;
18628 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18631 + ret = do_get_dlimit(id, vc_data.name,
18632 + &vc_data.space_used, &vc_data.space_total,
18633 + &vc_data.inodes_used, &vc_data.inodes_total,
18634 + &vc_data.reserved, &vc_data.flags);
18638 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18643 +#ifdef CONFIG_COMPAT
18645 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18647 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18650 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18653 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18654 + &vc_data.space_used, &vc_data.space_total,
18655 + &vc_data.inodes_used, &vc_data.inodes_total,
18656 + &vc_data.reserved, &vc_data.flags);
18660 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18665 +#endif /* CONFIG_COMPAT */
18668 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18670 + struct dl_info *dli;
18671 + __u64 blimit, bfree, bavail;
18674 + dli = locate_dl_info(sb, dx_current_tag());
18678 + spin_lock(&dli->dl_lock);
18679 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18682 + /* reduce max inodes available to limit */
18683 + if (buf->f_files > dli->dl_inodes_total)
18684 + buf->f_files = dli->dl_inodes_total;
18686 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18687 + /* reduce free inodes to min */
18688 + if (ifree < buf->f_ffree)
18689 + buf->f_ffree = ifree;
18692 + if (dli->dl_space_total == DLIM_INFINITY)
18695 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18697 + if (dli->dl_space_total < dli->dl_space_used)
18700 + bfree = (dli->dl_space_total - dli->dl_space_used)
18701 + >> sb->s_blocksize_bits;
18703 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18704 + if (bavail < dli->dl_space_used)
18707 + bavail = (bavail - dli->dl_space_used)
18708 + >> sb->s_blocksize_bits;
18710 + /* reduce max space available to limit */
18711 + if (buf->f_blocks > blimit)
18712 + buf->f_blocks = blimit;
18714 + /* reduce free space to min */
18715 + if (bfree < buf->f_bfree)
18716 + buf->f_bfree = bfree;
18718 + /* reduce avail space to min */
18719 + if (bavail < buf->f_bavail)
18720 + buf->f_bavail = bavail;
18723 + spin_unlock(&dli->dl_lock);
18724 + put_dl_info(dli);
18729 +#include <linux/module.h>
18731 +EXPORT_SYMBOL_GPL(locate_dl_info);
18732 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18734 diff -NurpP --minimal linux-3.1.1/kernel/vserver/helper.c linux-3.1.1-vs2.3.2/kernel/vserver/helper.c
18735 --- linux-3.1.1/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18736 +++ linux-3.1.1-vs2.3.2/kernel/vserver/helper.c 2011-10-24 18:53:33.000000000 +0200
18739 + * linux/kernel/vserver/helper.c
18741 + * Virtual Context Support
18743 + * Copyright (C) 2004-2007 Herbert Pötzl
18745 + * V0.01 basic helper
18749 +#include <linux/kmod.h>
18750 +#include <linux/reboot.h>
18751 +#include <linux/vs_context.h>
18752 +#include <linux/vs_network.h>
18753 +#include <linux/vserver/signal.h>
18756 +char vshelper_path[255] = "/sbin/vshelper";
18759 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18763 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
18764 + printk( KERN_WARNING
18765 + "%s: (%s %s) returned %s with %d\n",
18766 + name, argv[1], argv[2],
18767 + sync ? "sync" : "async", ret);
18769 + vxdprintk(VXD_CBIT(switch, 4),
18770 + "%s: (%s %s) returned %s with %d",
18771 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18776 + * vshelper path is set via /proc/sys
18777 + * invoked by vserver sys_reboot(), with
18778 + * the following arguments
18780 + * argv [0] = vshelper_path;
18781 + * argv [1] = action: "restart", "halt", "poweroff", ...
18782 + * argv [2] = context identifier
18784 + * envp [*] = type-specific parameters
18787 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18789 + char id_buf[8], cmd_buf[16];
18790 + char uid_buf[16], pid_buf[16];
18793 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18794 + char *envp[] = {"HOME=/", "TERM=linux",
18795 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18796 + uid_buf, pid_buf, cmd_buf, 0};
18798 + if (vx_info_state(vxi, VXS_HELPER))
18800 + vxi->vx_state |= VXS_HELPER;
18802 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18804 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18805 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
18806 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
18809 + case LINUX_REBOOT_CMD_RESTART:
18810 + argv[1] = "restart";
18813 + case LINUX_REBOOT_CMD_HALT:
18814 + argv[1] = "halt";
18817 + case LINUX_REBOOT_CMD_POWER_OFF:
18818 + argv[1] = "poweroff";
18821 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18822 + argv[1] = "swsusp";
18825 + case LINUX_REBOOT_CMD_OOM:
18830 + vxi->vx_state &= ~VXS_HELPER;
18834 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18835 + vxi->vx_state &= ~VXS_HELPER;
18836 + __wakeup_vx_info(vxi);
18837 + return (ret) ? -EPERM : 0;
18841 +long vs_reboot(unsigned int cmd, void __user *arg)
18843 + struct vx_info *vxi = current_vx_info();
18846 + vxdprintk(VXD_CBIT(misc, 5),
18847 + "vs_reboot(%p[#%d],%u)",
18848 + vxi, vxi ? vxi->vx_id : 0, cmd);
18850 + ret = vs_reboot_helper(vxi, cmd, arg);
18854 + vxi->reboot_cmd = cmd;
18855 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18857 + case LINUX_REBOOT_CMD_RESTART:
18858 + case LINUX_REBOOT_CMD_HALT:
18859 + case LINUX_REBOOT_CMD_POWER_OFF:
18860 + vx_info_kill(vxi, 0, SIGKILL);
18861 + vx_info_kill(vxi, 1, SIGKILL);
18869 +long vs_oom_action(unsigned int cmd)
18871 + struct vx_info *vxi = current_vx_info();
18874 + vxdprintk(VXD_CBIT(misc, 5),
18875 + "vs_oom_action(%p[#%d],%u)",
18876 + vxi, vxi ? vxi->vx_id : 0, cmd);
18878 + ret = vs_reboot_helper(vxi, cmd, NULL);
18882 + vxi->reboot_cmd = cmd;
18883 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18884 + vx_info_kill(vxi, 0, SIGKILL);
18885 + vx_info_kill(vxi, 1, SIGKILL);
18891 + * argv [0] = vshelper_path;
18892 + * argv [1] = action: "startup", "shutdown"
18893 + * argv [2] = context identifier
18895 + * envp [*] = type-specific parameters
18898 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18900 + char id_buf[8], cmd_buf[16];
18901 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18902 + char *envp[] = {"HOME=/", "TERM=linux",
18903 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18905 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18908 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18909 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18912 + case VSC_STARTUP:
18913 + argv[1] = "startup";
18915 + case VSC_SHUTDOWN:
18916 + argv[1] = "shutdown";
18922 + return do_vshelper(vshelper_path, argv, envp, 1);
18927 + * argv [0] = vshelper_path;
18928 + * argv [1] = action: "netup", "netdown"
18929 + * argv [2] = context identifier
18931 + * envp [*] = type-specific parameters
18934 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18936 + char id_buf[8], cmd_buf[16];
18937 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18938 + char *envp[] = {"HOME=/", "TERM=linux",
18939 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18941 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18944 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
18945 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18949 + argv[1] = "netup";
18951 + case VSC_NETDOWN:
18952 + argv[1] = "netdown";
18958 + return do_vshelper(vshelper_path, argv, envp, 1);
18961 diff -NurpP --minimal linux-3.1.1/kernel/vserver/history.c linux-3.1.1-vs2.3.2/kernel/vserver/history.c
18962 --- linux-3.1.1/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
18963 +++ linux-3.1.1-vs2.3.2/kernel/vserver/history.c 2011-10-24 18:53:33.000000000 +0200
18966 + * kernel/vserver/history.c
18968 + * Virtual Context History Backtrace
18970 + * Copyright (C) 2004-2007 Herbert Pötzl
18972 + * V0.01 basic structure
18973 + * V0.02 hash/unhash and trace
18974 + * V0.03 preemption fixes
18978 +#include <linux/module.h>
18979 +#include <asm/uaccess.h>
18981 +#include <linux/vserver/context.h>
18982 +#include <linux/vserver/debug.h>
18983 +#include <linux/vserver/debug_cmd.h>
18984 +#include <linux/vserver/history.h>
18987 +#ifdef CONFIG_VSERVER_HISTORY
18988 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18990 +#define VXH_SIZE 64
18993 +struct _vx_history {
18994 + unsigned int counter;
18996 + struct _vx_hist_entry entry[VXH_SIZE + 1];
19000 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
19002 +unsigned volatile int vxh_active = 1;
19004 +static atomic_t sequence = ATOMIC_INIT(0);
19009 + * requires disabled preemption */
19011 +struct _vx_hist_entry *vxh_advance(void *loc)
19013 + unsigned int cpu = smp_processor_id();
19014 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19015 + struct _vx_hist_entry *entry;
19016 + unsigned int index;
19018 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
19019 + entry = &hist->entry[index];
19021 + entry->seq = atomic_inc_return(&sequence);
19022 + entry->loc = loc;
19026 +EXPORT_SYMBOL_GPL(vxh_advance);
19029 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
19031 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
19034 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
19036 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
19037 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
19038 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
19039 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
19041 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
19043 + switch (e->type) {
19044 + case VXH_THROW_OOPS:
19045 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
19048 + case VXH_GET_VX_INFO:
19049 + case VXH_PUT_VX_INFO:
19050 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19052 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
19053 + VXH_VXI_ARGS(e));
19056 + case VXH_INIT_VX_INFO:
19057 + case VXH_SET_VX_INFO:
19058 + case VXH_CLR_VX_INFO:
19059 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19061 + (e->type == VXH_INIT_VX_INFO) ? "init" :
19062 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
19063 + VXH_VXI_ARGS(e), e->sc.data);
19066 + case VXH_CLAIM_VX_INFO:
19067 + case VXH_RELEASE_VX_INFO:
19068 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
19070 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
19071 + VXH_VXI_ARGS(e), e->sc.data);
19074 + case VXH_ALLOC_VX_INFO:
19075 + case VXH_DEALLOC_VX_INFO:
19076 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
19078 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
19079 + VXH_VXI_ARGS(e));
19082 + case VXH_HASH_VX_INFO:
19083 + case VXH_UNHASH_VX_INFO:
19084 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
19086 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
19087 + VXH_VXI_ARGS(e));
19090 + case VXH_LOC_VX_INFO:
19091 + case VXH_LOOKUP_VX_INFO:
19092 + case VXH_CREATE_VX_INFO:
19093 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
19095 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
19096 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
19097 + e->ll.arg, VXH_VXI_ARGS(e));
19102 +static void __vxh_dump_history(void)
19104 + unsigned int i, cpu;
19106 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
19107 + atomic_read(&sequence), NR_CPUS);
19109 + for (i = 0; i < VXH_SIZE; i++) {
19110 + for_each_online_cpu(cpu) {
19111 + struct _vx_history *hist =
19112 + &per_cpu(vx_history_buffer, cpu);
19113 + unsigned int index = (hist->counter - i) % VXH_SIZE;
19114 + struct _vx_hist_entry *entry = &hist->entry[index];
19116 + vxh_dump_entry(entry, cpu);
19121 +void vxh_dump_history(void)
19125 + local_irq_enable();
19127 + local_irq_disable();
19129 + __vxh_dump_history();
19133 +/* vserver syscall commands below here */
19136 +int vc_dump_history(uint32_t id)
19139 + __vxh_dump_history();
19146 +int do_read_history(struct __user _vx_hist_entry *data,
19147 + int cpu, uint32_t *index, uint32_t *count)
19149 + int pos, ret = 0;
19150 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
19151 + int end = hist->counter;
19152 + int start = end - VXH_SIZE + 2;
19153 + int idx = *index;
19155 + /* special case: get current pos */
19161 + /* have we lost some data? */
19165 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
19166 + struct _vx_hist_entry *entry =
19167 + &hist->entry[idx % VXH_SIZE];
19169 + /* send entry to userspace */
19170 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
19174 + /* save new index and count */
19177 + return ret ? ret : (*index < end);
19180 +int vc_read_history(uint32_t id, void __user *data)
19182 + struct vcmd_read_history_v0 vc_data;
19185 + if (id >= NR_CPUS)
19188 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19191 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19192 + id, &vc_data.index, &vc_data.count);
19194 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19199 +#ifdef CONFIG_COMPAT
19201 +int vc_read_history_x32(uint32_t id, void __user *data)
19203 + struct vcmd_read_history_v0_x32 vc_data;
19206 + if (id >= NR_CPUS)
19209 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19212 + ret = do_read_history((struct __user _vx_hist_entry *)
19213 + compat_ptr(vc_data.data_ptr),
19214 + id, &vc_data.index, &vc_data.count);
19216 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19221 +#endif /* CONFIG_COMPAT */
19223 diff -NurpP --minimal linux-3.1.1/kernel/vserver/inet.c linux-3.1.1-vs2.3.2/kernel/vserver/inet.c
19224 --- linux-3.1.1/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19225 +++ linux-3.1.1-vs2.3.2/kernel/vserver/inet.c 2011-10-24 18:53:33.000000000 +0200
19228 +#include <linux/in.h>
19229 +#include <linux/inetdevice.h>
19230 +#include <linux/vs_inet.h>
19231 +#include <linux/vs_inet6.h>
19232 +#include <linux/vserver/debug.h>
19233 +#include <net/route.h>
19234 +#include <net/addrconf.h>
19237 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19241 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19244 + struct nx_addr_v4 *ptr;
19246 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19247 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19254 + vxdprintk(VXD_CBIT(net, 2),
19255 + "nx_v4_addr_conflict(%p,%p): %d",
19256 + nxi1, nxi2, ret);
19262 +#ifdef CONFIG_IPV6
19264 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19268 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19271 + struct nx_addr_v6 *ptr;
19273 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19274 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19281 + vxdprintk(VXD_CBIT(net, 2),
19282 + "nx_v6_addr_conflict(%p,%p): %d",
19283 + nxi1, nxi2, ret);
19290 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19292 + struct in_device *in_dev;
19293 + struct in_ifaddr **ifap;
19294 + struct in_ifaddr *ifa;
19299 + in_dev = in_dev_get(dev);
19303 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19304 + ifap = &ifa->ifa_next) {
19305 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19310 + in_dev_put(in_dev);
19316 +#ifdef CONFIG_IPV6
19318 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19320 + struct inet6_dev *in_dev;
19321 + struct inet6_ifaddr *ifa;
19326 + in_dev = in6_dev_get(dev);
19330 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19331 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19332 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19337 + in6_dev_put(in_dev);
19344 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19350 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19352 +#ifdef CONFIG_IPV6
19354 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19359 + vxdprintk(VXD_CBIT(net, 3),
19360 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19361 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19365 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
19366 + struct flowi4 *fl4)
19368 + struct rtable *rt;
19373 + /* FIXME: handle lback only case */
19374 + if (!NX_IPV4(nxi))
19375 + return ERR_PTR(-EPERM);
19377 + vxdprintk(VXD_CBIT(net, 4),
19378 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19379 + nxi, nxi ? nxi->nx_id : 0,
19380 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
19382 + /* single IP is unconditional */
19383 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19384 + (fl4->saddr == INADDR_ANY))
19385 + fl4->saddr = nxi->v4.ip[0].s_addr;
19387 + if (fl4->saddr == INADDR_ANY) {
19388 + struct nx_addr_v4 *ptr;
19389 + __be32 found = 0;
19391 + rt = __ip_route_output_key(net, fl4);
19392 + if (!IS_ERR(rt)) {
19393 + found = fl4->saddr;
19395 + vxdprintk(VXD_CBIT(net, 4),
19396 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19397 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
19398 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19402 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19403 + __be32 primary = ptr->ip[0].s_addr;
19404 + __be32 mask = ptr->mask.s_addr;
19405 + __be32 neta = primary & mask;
19407 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19408 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19409 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19410 + NIPQUAD(mask), NIPQUAD(neta));
19411 + if ((found & mask) != neta)
19414 + fl4->saddr = primary;
19415 + rt = __ip_route_output_key(net, fl4);
19416 + vxdprintk(VXD_CBIT(net, 4),
19417 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19418 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
19419 + if (!IS_ERR(rt)) {
19420 + found = fl4->saddr;
19422 + if (found == primary)
19426 + /* still no source ip? */
19427 + found = ipv4_is_loopback(fl4->daddr)
19428 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19430 + /* assign src ip to flow */
19431 + fl4->saddr = found;
19434 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
19435 + return ERR_PTR(-EPERM);
19438 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19439 + if (ipv4_is_loopback(fl4->daddr))
19440 + fl4->daddr = nxi->v4_lback.s_addr;
19441 + if (ipv4_is_loopback(fl4->saddr))
19442 + fl4->saddr = nxi->v4_lback.s_addr;
19443 + } else if (ipv4_is_loopback(fl4->daddr) &&
19444 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19445 + return ERR_PTR(-EPERM);
19450 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19452 diff -NurpP --minimal linux-3.1.1/kernel/vserver/init.c linux-3.1.1-vs2.3.2/kernel/vserver/init.c
19453 --- linux-3.1.1/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19454 +++ linux-3.1.1-vs2.3.2/kernel/vserver/init.c 2011-10-24 18:53:33.000000000 +0200
19457 + * linux/kernel/init.c
19459 + * Virtual Server Init
19461 + * Copyright (C) 2004-2007 Herbert Pötzl
19463 + * V0.01 basic structure
19467 +#include <linux/init.h>
19469 +int vserver_register_sysctl(void);
19470 +void vserver_unregister_sysctl(void);
19473 +static int __init init_vserver(void)
19477 +#ifdef CONFIG_VSERVER_DEBUG
19478 + vserver_register_sysctl();
19484 +static void __exit exit_vserver(void)
19487 +#ifdef CONFIG_VSERVER_DEBUG
19488 + vserver_unregister_sysctl();
19493 +/* FIXME: GFP_ZONETYPES gone
19494 +long vx_slab[GFP_ZONETYPES]; */
19498 +module_init(init_vserver);
19499 +module_exit(exit_vserver);
19501 diff -NurpP --minimal linux-3.1.1/kernel/vserver/inode.c linux-3.1.1-vs2.3.2/kernel/vserver/inode.c
19502 --- linux-3.1.1/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19503 +++ linux-3.1.1-vs2.3.2/kernel/vserver/inode.c 2011-10-24 18:53:33.000000000 +0200
19506 + * linux/kernel/vserver/inode.c
19508 + * Virtual Server: File System Support
19510 + * Copyright (C) 2004-2007 Herbert Pötzl
19512 + * V0.01 separated from vcontext V0.05
19513 + * V0.02 moved to tag (instead of xid)
19517 +#include <linux/tty.h>
19518 +#include <linux/proc_fs.h>
19519 +#include <linux/devpts_fs.h>
19520 +#include <linux/fs.h>
19521 +#include <linux/file.h>
19522 +#include <linux/mount.h>
19523 +#include <linux/parser.h>
19524 +#include <linux/namei.h>
19525 +#include <linux/vserver/inode.h>
19526 +#include <linux/vserver/inode_cmd.h>
19527 +#include <linux/vs_base.h>
19528 +#include <linux/vs_tag.h>
19530 +#include <asm/uaccess.h>
19533 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19535 + struct proc_dir_entry *entry;
19537 + if (!in || !in->i_sb)
19540 + *flags = IATTR_TAG
19541 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19542 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19543 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19544 + | (IS_COW(in) ? IATTR_COW : 0);
19545 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19547 + if (S_ISDIR(in->i_mode))
19548 + *mask |= IATTR_BARRIER;
19550 + if (IS_TAGGED(in)) {
19551 + *tag = in->i_tag;
19552 + *mask |= IATTR_TAG;
19555 + switch (in->i_sb->s_magic) {
19556 + case PROC_SUPER_MAGIC:
19557 + entry = PROC_I(in)->pde;
19559 + /* check for specific inodes? */
19561 + *mask |= IATTR_FLAGS;
19563 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19565 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19568 + case DEVPTS_SUPER_MAGIC:
19569 + *tag = in->i_tag;
19570 + *mask |= IATTR_TAG;
19579 +int vc_get_iattr(void __user *data)
19581 + struct path path;
19582 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19585 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19588 + ret = user_lpath(vc_data.name, &path);
19590 + ret = __vc_get_iattr(path.dentry->d_inode,
19591 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19597 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19602 +#ifdef CONFIG_COMPAT
19604 +int vc_get_iattr_x32(void __user *data)
19606 + struct path path;
19607 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19610 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19613 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19615 + ret = __vc_get_iattr(path.dentry->d_inode,
19616 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19622 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19627 +#endif /* CONFIG_COMPAT */
19630 +int vc_fget_iattr(uint32_t fd, void __user *data)
19632 + struct file *filp;
19633 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19636 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19640 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19643 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19644 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19648 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19654 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19656 + struct inode *in = de->d_inode;
19657 + int error = 0, is_proc = 0, has_tag = 0;
19658 + struct iattr attr = { 0 };
19660 + if (!in || !in->i_sb)
19663 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19664 + if ((*mask & IATTR_FLAGS) && !is_proc)
19667 + has_tag = IS_TAGGED(in) ||
19668 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19669 + if ((*mask & IATTR_TAG) && !has_tag)
19672 + mutex_lock(&in->i_mutex);
19673 + if (*mask & IATTR_TAG) {
19674 + attr.ia_tag = *tag;
19675 + attr.ia_valid |= ATTR_TAG;
19678 + if (*mask & IATTR_FLAGS) {
19679 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19680 + unsigned int iflags = PROC_I(in)->vx_flags;
19682 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19683 + | (*flags & IATTR_FLAGS);
19684 + PROC_I(in)->vx_flags = iflags;
19686 + entry->vx_flags = iflags;
19689 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19690 + IATTR_BARRIER | IATTR_COW)) {
19691 + int iflags = in->i_flags;
19692 + int vflags = in->i_vflags;
19694 + if (*mask & IATTR_IMMUTABLE) {
19695 + if (*flags & IATTR_IMMUTABLE)
19696 + iflags |= S_IMMUTABLE;
19698 + iflags &= ~S_IMMUTABLE;
19700 + if (*mask & IATTR_IXUNLINK) {
19701 + if (*flags & IATTR_IXUNLINK)
19702 + iflags |= S_IXUNLINK;
19704 + iflags &= ~S_IXUNLINK;
19706 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19707 + if (*flags & IATTR_BARRIER)
19708 + vflags |= V_BARRIER;
19710 + vflags &= ~V_BARRIER;
19712 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19713 + if (*flags & IATTR_COW)
19716 + vflags &= ~V_COW;
19718 + if (in->i_op && in->i_op->sync_flags) {
19719 + error = in->i_op->sync_flags(in, iflags, vflags);
19725 + if (attr.ia_valid) {
19726 + if (in->i_op && in->i_op->setattr)
19727 + error = in->i_op->setattr(de, &attr);
19729 + error = inode_change_ok(in, &attr);
19731 + setattr_copy(in, &attr);
19732 + mark_inode_dirty(in);
19738 + mutex_unlock(&in->i_mutex);
19742 +int vc_set_iattr(void __user *data)
19744 + struct path path;
19745 + struct vcmd_ctx_iattr_v1 vc_data;
19748 + if (!capable(CAP_LINUX_IMMUTABLE))
19750 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19753 + ret = user_lpath(vc_data.name, &path);
19755 + ret = __vc_set_iattr(path.dentry,
19756 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19760 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19765 +#ifdef CONFIG_COMPAT
19767 +int vc_set_iattr_x32(void __user *data)
19769 + struct path path;
19770 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19773 + if (!capable(CAP_LINUX_IMMUTABLE))
19775 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19778 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19780 + ret = __vc_set_iattr(path.dentry,
19781 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19785 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19790 +#endif /* CONFIG_COMPAT */
19792 +int vc_fset_iattr(uint32_t fd, void __user *data)
19794 + struct file *filp;
19795 + struct vcmd_ctx_fiattr_v0 vc_data;
19798 + if (!capable(CAP_LINUX_IMMUTABLE))
19800 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19804 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19807 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19808 + &vc_data.flags, &vc_data.mask);
19812 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19818 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19820 +static match_table_t tokens = {
19821 + {Opt_notagcheck, "notagcheck"},
19822 +#ifdef CONFIG_PROPAGATE
19823 + {Opt_notag, "notag"},
19824 + {Opt_tag, "tag"},
19825 + {Opt_tagid, "tagid=%u"},
19831 +static void __dx_parse_remove(char *string, char *opt)
19833 + char *p = strstr(string, opt);
19837 + while (*q != '\0' && *q != ',')
19846 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19847 + unsigned long *flags)
19850 + substring_t args[MAX_OPT_ARGS];
19852 + char *s, *p, *opts;
19853 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_WARN)
19859 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19864 + while ((p = strsep(&opts, ",")) != NULL) {
19865 + token = match_token(p, tokens, args);
19868 +#ifdef CONFIG_PROPAGATE
19873 + __dx_parse_remove(s, "tag");
19874 + *mnt_flags |= MNT_TAGID;
19875 + set |= MNT_TAGID;
19879 + __dx_parse_remove(s, "notag");
19880 + *mnt_flags |= MNT_NOTAG;
19881 + set |= MNT_NOTAG;
19884 + if (tag && !match_int(args, &option))
19887 + __dx_parse_remove(s, "tagid");
19888 + *mnt_flags |= MNT_TAGID;
19889 + set |= MNT_TAGID;
19892 + case Opt_notagcheck:
19894 + __dx_parse_remove(s, "notagcheck");
19895 + *flags |= MS_NOTAGCHECK;
19896 + set |= MS_NOTAGCHECK;
19899 + vxdprintk(VXD_CBIT(tag, 7),
19900 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19901 + p, token, option);
19904 + strcpy(string, s);
19909 +#ifdef CONFIG_PROPAGATE
19911 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19913 + tag_t new_tag = 0;
19914 + struct vfsmount *mnt;
19919 + mnt = nd->path.mnt;
19923 + propagate = (mnt->mnt_flags & MNT_TAGID);
19925 + new_tag = mnt->mnt_tag;
19927 + vxdprintk(VXD_CBIT(tag, 7),
19928 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19929 + inode, inode->i_ino, inode->i_tag,
19930 + new_tag, (propagate) ? 1 : 0);
19933 + inode->i_tag = new_tag;
19936 +#include <linux/module.h>
19938 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19940 +#endif /* CONFIG_PROPAGATE */
19942 diff -NurpP --minimal linux-3.1.1/kernel/vserver/limit.c linux-3.1.1-vs2.3.2/kernel/vserver/limit.c
19943 --- linux-3.1.1/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
19944 +++ linux-3.1.1-vs2.3.2/kernel/vserver/limit.c 2011-10-24 18:53:33.000000000 +0200
19947 + * linux/kernel/vserver/limit.c
19949 + * Virtual Server: Context Limits
19951 + * Copyright (C) 2004-2010 Herbert Pötzl
19953 + * V0.01 broken out from vcontext V0.05
19954 + * V0.02 changed vcmds to vxi arg
19955 + * V0.03 added memory cgroup support
19959 +#include <linux/sched.h>
19960 +#include <linux/module.h>
19961 +#include <linux/memcontrol.h>
19962 +#include <linux/res_counter.h>
19963 +#include <linux/vs_limit.h>
19964 +#include <linux/vserver/limit.h>
19965 +#include <linux/vserver/limit_cmd.h>
19967 +#include <asm/uaccess.h>
19970 +const char *vlimit_name[NUM_LIMITS] = {
19971 +#ifdef CONFIG_VSERVER_LEGACY_MEM
19972 + [RLIMIT_RSS] = "RSS",
19973 + [RLIMIT_AS] = "VM",
19974 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
19975 + [RLIMIT_CPU] = "CPU",
19976 + [RLIMIT_NPROC] = "NPROC",
19977 + [RLIMIT_NOFILE] = "NOFILE",
19978 + [RLIMIT_LOCKS] = "LOCKS",
19979 + [RLIMIT_SIGPENDING] = "SIGP",
19980 + [RLIMIT_MSGQUEUE] = "MSGQ",
19982 + [VLIMIT_NSOCK] = "NSOCK",
19983 + [VLIMIT_OPENFD] = "OPENFD",
19984 + [VLIMIT_SHMEM] = "SHMEM",
19985 + [VLIMIT_DENTRY] = "DENTRY",
19988 +EXPORT_SYMBOL_GPL(vlimit_name);
19990 +#define MASK_ENTRY(x) (1 << (x))
19992 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
19995 + , /* softlimit */
19996 +#ifdef CONFIG_VSERVER_LEGACY_MEM
19997 + MASK_ENTRY( RLIMIT_RSS ) |
19998 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20001 +#ifdef CONFIG_VSERVER_LEGACY_MEM
20002 + MASK_ENTRY( RLIMIT_RSS ) |
20003 + MASK_ENTRY( RLIMIT_AS ) |
20004 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
20005 + MASK_ENTRY( RLIMIT_NPROC ) |
20006 + MASK_ENTRY( RLIMIT_NOFILE ) |
20007 + MASK_ENTRY( RLIMIT_LOCKS ) |
20008 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
20010 + MASK_ENTRY( VLIMIT_NSOCK ) |
20011 + MASK_ENTRY( VLIMIT_OPENFD ) |
20012 + MASK_ENTRY( VLIMIT_SHMEM ) |
20013 + MASK_ENTRY( VLIMIT_DENTRY ) |
20016 + /* accounting only */
20017 +uint32_t account_mask =
20018 + MASK_ENTRY( VLIMIT_SEMARY ) |
20019 + MASK_ENTRY( VLIMIT_NSEMS ) |
20020 + MASK_ENTRY( VLIMIT_MAPPED ) |
20024 +static int is_valid_vlimit(int id)
20026 + uint32_t mask = vlimit_mask.minimum |
20027 + vlimit_mask.softlimit | vlimit_mask.maximum;
20028 + return mask & (1 << id);
20031 +static int is_accounted_vlimit(int id)
20033 + if (is_valid_vlimit(id))
20035 + return account_mask & (1 << id);
20039 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
20041 + rlim_t limit = __rlim_soft(&vxi->limit, id);
20042 + return VX_VLIM(limit);
20045 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
20047 + rlim_t limit = __rlim_hard(&vxi->limit, id);
20048 + return VX_VLIM(limit);
20051 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
20052 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
20054 + if (!is_valid_vlimit(id))
20058 + *minimum = CRLIM_UNSET;
20060 + *softlimit = vc_get_soft(vxi, id);
20062 + *maximum = vc_get_hard(vxi, id);
20066 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
20068 + struct vcmd_ctx_rlimit_v0 vc_data;
20071 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20074 + ret = do_get_rlimit(vxi, vc_data.id,
20075 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20079 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20084 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
20085 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
20087 + if (!is_valid_vlimit(id))
20090 + if (maximum != CRLIM_KEEP)
20091 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
20092 + if (softlimit != CRLIM_KEEP)
20093 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
20095 + /* clamp soft limit */
20096 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
20097 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
20102 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
20104 + struct vcmd_ctx_rlimit_v0 vc_data;
20106 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20109 + return do_set_rlimit(vxi, vc_data.id,
20110 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20113 +#ifdef CONFIG_IA32_EMULATION
20115 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
20117 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20119 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20122 + return do_set_rlimit(vxi, vc_data.id,
20123 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
20126 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
20128 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
20131 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20134 + ret = do_get_rlimit(vxi, vc_data.id,
20135 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
20139 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20144 +#endif /* CONFIG_IA32_EMULATION */
20147 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
20149 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
20155 +static inline void vx_reset_hits(struct _vx_limit *limit)
20159 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20160 + atomic_set(&__rlim_lhit(limit, lim), 0);
20164 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
20166 + vx_reset_hits(&vxi->limit);
20170 +static inline void vx_reset_minmax(struct _vx_limit *limit)
20175 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20176 + value = __rlim_get(limit, lim);
20177 + __rlim_rmax(limit, lim) = value;
20178 + __rlim_rmin(limit, lim) = value;
20182 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
20184 + vx_reset_minmax(&vxi->limit);
20189 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20191 + struct vcmd_rlimit_stat_v0 vc_data;
20192 + struct _vx_limit *limit = &vxi->limit;
20195 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20199 + if (!is_accounted_vlimit(id))
20202 + vx_limit_fixup(limit, id);
20203 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20204 + vc_data.value = __rlim_get(limit, id);
20205 + vc_data.minimum = __rlim_rmin(limit, id);
20206 + vc_data.maximum = __rlim_rmax(limit, id);
20208 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20214 +void vx_vsi_meminfo(struct sysinfo *val)
20216 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20217 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20218 + u64 res_limit, res_usage;
20223 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20224 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20226 + if (res_limit != RESOURCE_MAX)
20227 + val->totalram = (res_limit >> PAGE_SHIFT);
20228 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20229 + val->bufferram = 0;
20230 + val->totalhigh = 0;
20231 + val->freehigh = 0;
20232 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20236 +void vx_vsi_swapinfo(struct sysinfo *val)
20238 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20239 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20240 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20241 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20242 + s64 swap_limit, swap_usage;
20247 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20248 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20249 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20250 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20252 + /* memory unlimited */
20253 + if (res_limit == RESOURCE_MAX)
20256 + swap_limit = memsw_limit - res_limit;
20257 + /* we have a swap limit? */
20258 + if (memsw_limit != RESOURCE_MAX)
20259 + val->totalswap = swap_limit >> PAGE_SHIFT;
20261 + /* calculate swap part */
20262 + swap_usage = (memsw_usage > res_usage) ?
20263 + memsw_usage - res_usage : 0;
20265 + /* total shown minus usage gives free swap */
20266 + val->freeswap = (swap_usage < swap_limit) ?
20267 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20268 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20269 + val->totalswap = 0;
20270 + val->freeswap = 0;
20271 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20272 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20276 +long vx_vsi_cached(struct sysinfo *val)
20278 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20279 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20281 + return mem_cgroup_stat_read_cache(mcg);
20288 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
20290 + struct vx_info *vxi = mm->mm_vx_info;
20291 + unsigned long points;
20297 + points = vxi->vx_badness_bias;
20299 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
20300 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
20301 + points += (v > w) ? (v - w) : 0;
20306 diff -NurpP --minimal linux-3.1.1/kernel/vserver/limit_init.h linux-3.1.1-vs2.3.2/kernel/vserver/limit_init.h
20307 --- linux-3.1.1/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20308 +++ linux-3.1.1-vs2.3.2/kernel/vserver/limit_init.h 2011-10-24 18:53:33.000000000 +0200
20312 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20316 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20317 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20318 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20319 + __rlim_set(limit, lim, 0);
20320 + atomic_set(&__rlim_lhit(limit, lim), 0);
20321 + __rlim_rmin(limit, lim) = 0;
20322 + __rlim_rmax(limit, lim) = 0;
20326 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20331 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20332 + if ((1 << lim) & VLIM_NOCHECK)
20334 + value = __rlim_get(limit, lim);
20335 + vxwprintk_xid(value,
20336 + "!!! limit: %p[%s,%d] = %ld on exit.",
20337 + limit, vlimit_name[lim], lim, (long)value);
20341 diff -NurpP --minimal linux-3.1.1/kernel/vserver/limit_proc.h linux-3.1.1-vs2.3.2/kernel/vserver/limit_proc.h
20342 --- linux-3.1.1/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20343 +++ linux-3.1.1-vs2.3.2/kernel/vserver/limit_proc.h 2011-10-24 18:53:33.000000000 +0200
20345 +#ifndef _VX_LIMIT_PROC_H
20346 +#define _VX_LIMIT_PROC_H
20348 +#include <linux/vserver/limit_int.h>
20351 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20352 +#define VX_LIMIT_TOP \
20353 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20355 +#define VX_LIMIT_ARG(r) \
20356 + (unsigned long)__rlim_get(limit, r), \
20357 + (unsigned long)__rlim_rmin(limit, r), \
20358 + (unsigned long)__rlim_rmax(limit, r), \
20359 + VX_VLIM(__rlim_soft(limit, r)), \
20360 + VX_VLIM(__rlim_hard(limit, r)), \
20361 + atomic_read(&__rlim_lhit(limit, r))
20363 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20365 + vx_limit_fixup(limit, -1);
20366 + return sprintf(buffer, VX_LIMIT_TOP
20367 + "PROC" VX_LIMIT_FMT
20368 + "VM" VX_LIMIT_FMT
20369 + "VML" VX_LIMIT_FMT
20370 + "RSS" VX_LIMIT_FMT
20371 + "ANON" VX_LIMIT_FMT
20372 + "RMAP" VX_LIMIT_FMT
20373 + "FILES" VX_LIMIT_FMT
20374 + "OFD" VX_LIMIT_FMT
20375 + "LOCKS" VX_LIMIT_FMT
20376 + "SOCK" VX_LIMIT_FMT
20377 + "MSGQ" VX_LIMIT_FMT
20378 + "SHM" VX_LIMIT_FMT
20379 + "SEMA" VX_LIMIT_FMT
20380 + "SEMS" VX_LIMIT_FMT
20381 + "DENT" VX_LIMIT_FMT,
20382 + VX_LIMIT_ARG(RLIMIT_NPROC),
20383 + VX_LIMIT_ARG(RLIMIT_AS),
20384 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20385 + VX_LIMIT_ARG(RLIMIT_RSS),
20386 + VX_LIMIT_ARG(VLIMIT_ANON),
20387 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20388 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20389 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20390 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20391 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20392 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20393 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20394 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20395 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20396 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20399 +#endif /* _VX_LIMIT_PROC_H */
20402 diff -NurpP --minimal linux-3.1.1/kernel/vserver/network.c linux-3.1.1-vs2.3.2/kernel/vserver/network.c
20403 --- linux-3.1.1/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20404 +++ linux-3.1.1-vs2.3.2/kernel/vserver/network.c 2011-10-24 18:53:33.000000000 +0200
20407 + * linux/kernel/vserver/network.c
20409 + * Virtual Server: Network Support
20411 + * Copyright (C) 2003-2007 Herbert Pötzl
20413 + * V0.01 broken out from vcontext V0.05
20414 + * V0.02 cleaned up implementation
20415 + * V0.03 added equiv nx commands
20416 + * V0.04 switch to RCU based hash
20417 + * V0.05 and back to locking again
20418 + * V0.06 changed vcmds to nxi arg
20419 + * V0.07 have __create claim() the nxi
20423 +#include <linux/err.h>
20424 +#include <linux/slab.h>
20425 +#include <linux/rcupdate.h>
20427 +#include <linux/vs_network.h>
20428 +#include <linux/vs_pid.h>
20429 +#include <linux/vserver/network_cmd.h>
20432 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20433 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20435 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20436 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20439 +static int __init init_network(void)
20441 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20442 + sizeof(struct nx_addr_v4), 0,
20443 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20444 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20445 + sizeof(struct nx_addr_v6), 0,
20446 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20451 +/* __alloc_nx_addr_v4() */
20453 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20455 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20456 + nx_addr_v4_cachep, GFP_KERNEL);
20458 + if (!IS_ERR(nxa))
20459 + memset(nxa, 0, sizeof(*nxa));
20463 +/* __dealloc_nx_addr_v4() */
20465 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20467 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20470 +/* __dealloc_nx_addr_v4_all() */
20472 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20475 + struct nx_addr_v4 *next = nxa->next;
20477 + __dealloc_nx_addr_v4(nxa);
20483 +#ifdef CONFIG_IPV6
20485 +/* __alloc_nx_addr_v6() */
20487 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20489 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20490 + nx_addr_v6_cachep, GFP_KERNEL);
20492 + if (!IS_ERR(nxa))
20493 + memset(nxa, 0, sizeof(*nxa));
20497 +/* __dealloc_nx_addr_v6() */
20499 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20501 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20504 +/* __dealloc_nx_addr_v6_all() */
20506 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20509 + struct nx_addr_v6 *next = nxa->next;
20511 + __dealloc_nx_addr_v6(nxa);
20516 +#endif /* CONFIG_IPV6 */
20518 +/* __alloc_nx_info()
20520 + * allocate an initialized nx_info struct
20521 + * doesn't make it visible (hash) */
20523 +static struct nx_info *__alloc_nx_info(nid_t nid)
20525 + struct nx_info *new = NULL;
20527 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20529 + /* would this benefit from a slab cache? */
20530 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20534 + memset(new, 0, sizeof(struct nx_info));
20535 + new->nx_id = nid;
20536 + INIT_HLIST_NODE(&new->nx_hlist);
20537 + atomic_set(&new->nx_usecnt, 0);
20538 + atomic_set(&new->nx_tasks, 0);
20539 + new->nx_state = 0;
20541 + new->nx_flags = NXF_INIT_SET;
20543 + /* rest of init goes here */
20545 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20546 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20548 + vxdprintk(VXD_CBIT(nid, 0),
20549 + "alloc_nx_info(%d) = %p", nid, new);
20550 + atomic_inc(&nx_global_ctotal);
20554 +/* __dealloc_nx_info()
20556 + * final disposal of nx_info */
20558 +static void __dealloc_nx_info(struct nx_info *nxi)
20560 + vxdprintk(VXD_CBIT(nid, 0),
20561 + "dealloc_nx_info(%p)", nxi);
20563 + nxi->nx_hlist.next = LIST_POISON1;
20566 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20567 + BUG_ON(atomic_read(&nxi->nx_tasks));
20569 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20571 + nxi->nx_state |= NXS_RELEASED;
20573 + atomic_dec(&nx_global_ctotal);
20576 +static void __shutdown_nx_info(struct nx_info *nxi)
20578 + nxi->nx_state |= NXS_SHUTDOWN;
20579 + vs_net_change(nxi, VSC_NETDOWN);
20582 +/* exported stuff */
20584 +void free_nx_info(struct nx_info *nxi)
20586 + /* context shutdown is mandatory */
20587 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20589 + /* context must not be hashed */
20590 + BUG_ON(nxi->nx_state & NXS_HASHED);
20592 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20593 + BUG_ON(atomic_read(&nxi->nx_tasks));
20595 + __dealloc_nx_info(nxi);
20599 +void __nx_set_lback(struct nx_info *nxi)
20601 + int nid = nxi->nx_id;
20602 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20604 + nxi->v4_lback.s_addr = lback;
20607 +extern int __nx_inet_add_lback(__be32 addr);
20608 +extern int __nx_inet_del_lback(__be32 addr);
20611 +/* hash table for nx_info hash */
20613 +#define NX_HASH_SIZE 13
20615 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20617 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20620 +static inline unsigned int __hashval(nid_t nid)
20622 + return (nid % NX_HASH_SIZE);
20627 +/* __hash_nx_info()
20629 + * add the nxi to the global hash table
20630 + * requires the hash_lock to be held */
20632 +static inline void __hash_nx_info(struct nx_info *nxi)
20634 + struct hlist_head *head;
20636 + vxd_assert_lock(&nx_info_hash_lock);
20637 + vxdprintk(VXD_CBIT(nid, 4),
20638 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20640 + /* context must not be hashed */
20641 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20643 + nxi->nx_state |= NXS_HASHED;
20644 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20645 + hlist_add_head(&nxi->nx_hlist, head);
20646 + atomic_inc(&nx_global_cactive);
20649 +/* __unhash_nx_info()
20651 + * remove the nxi from the global hash table
20652 + * requires the hash_lock to be held */
20654 +static inline void __unhash_nx_info(struct nx_info *nxi)
20656 + vxd_assert_lock(&nx_info_hash_lock);
20657 + vxdprintk(VXD_CBIT(nid, 4),
20658 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20659 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20661 + /* context must be hashed */
20662 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20663 + /* but without tasks */
20664 + BUG_ON(atomic_read(&nxi->nx_tasks));
20666 + nxi->nx_state &= ~NXS_HASHED;
20667 + hlist_del(&nxi->nx_hlist);
20668 + atomic_dec(&nx_global_cactive);
20672 +/* __lookup_nx_info()
20674 + * requires the hash_lock to be held
20675 + * doesn't increment the nx_refcnt */
20677 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20679 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20680 + struct hlist_node *pos;
20681 + struct nx_info *nxi;
20683 + vxd_assert_lock(&nx_info_hash_lock);
20684 + hlist_for_each(pos, head) {
20685 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20687 + if (nxi->nx_id == nid)
20692 + vxdprintk(VXD_CBIT(nid, 0),
20693 + "__lookup_nx_info(#%u): %p[#%u]",
20694 + nid, nxi, nxi ? nxi->nx_id : 0);
20699 +/* __create_nx_info()
20701 + * create the requested context
20702 + * get(), claim() and hash it */
20704 +static struct nx_info *__create_nx_info(int id)
20706 + struct nx_info *new, *nxi = NULL;
20708 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20710 + if (!(new = __alloc_nx_info(id)))
20711 + return ERR_PTR(-ENOMEM);
20713 + /* required to make dynamic xids unique */
20714 + spin_lock(&nx_info_hash_lock);
20716 + /* static context requested */
20717 + if ((nxi = __lookup_nx_info(id))) {
20718 + vxdprintk(VXD_CBIT(nid, 0),
20719 + "create_nx_info(%d) = %p (already there)", id, nxi);
20720 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20721 + nxi = ERR_PTR(-EBUSY);
20723 + nxi = ERR_PTR(-EEXIST);
20726 + /* new context */
20727 + vxdprintk(VXD_CBIT(nid, 0),
20728 + "create_nx_info(%d) = %p (new)", id, new);
20729 + claim_nx_info(new, NULL);
20730 + __nx_set_lback(new);
20731 + __hash_nx_info(get_nx_info(new));
20732 + nxi = new, new = NULL;
20735 + spin_unlock(&nx_info_hash_lock);
20737 + __dealloc_nx_info(new);
20743 +/* exported stuff */
20746 +void unhash_nx_info(struct nx_info *nxi)
20748 + __shutdown_nx_info(nxi);
20749 + spin_lock(&nx_info_hash_lock);
20750 + __unhash_nx_info(nxi);
20751 + spin_unlock(&nx_info_hash_lock);
20754 +/* lookup_nx_info()
20756 + * search for a nx_info and get() it
20757 + * negative id means current */
20759 +struct nx_info *lookup_nx_info(int id)
20761 + struct nx_info *nxi = NULL;
20764 + nxi = get_nx_info(current_nx_info());
20765 + } else if (id > 1) {
20766 + spin_lock(&nx_info_hash_lock);
20767 + nxi = get_nx_info(__lookup_nx_info(id));
20768 + spin_unlock(&nx_info_hash_lock);
20773 +/* nid_is_hashed()
20775 + * verify that nid is still hashed */
20777 +int nid_is_hashed(nid_t nid)
20781 + spin_lock(&nx_info_hash_lock);
20782 + hashed = (__lookup_nx_info(nid) != NULL);
20783 + spin_unlock(&nx_info_hash_lock);
20788 +#ifdef CONFIG_PROC_FS
20792 + * get a subset of hashed nids for proc
20793 + * assumes size is at least one */
20795 +int get_nid_list(int index, unsigned int *nids, int size)
20797 + int hindex, nr_nids = 0;
20799 + /* only show current and children */
20800 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20803 + nids[nr_nids] = nx_current_nid();
20807 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20808 + struct hlist_head *head = &nx_info_hash[hindex];
20809 + struct hlist_node *pos;
20811 + spin_lock(&nx_info_hash_lock);
20812 + hlist_for_each(pos, head) {
20813 + struct nx_info *nxi;
20818 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20819 + nids[nr_nids] = nxi->nx_id;
20820 + if (++nr_nids >= size) {
20821 + spin_unlock(&nx_info_hash_lock);
20825 + /* keep the lock time short */
20826 + spin_unlock(&nx_info_hash_lock);
20835 + * migrate task to new network
20836 + * gets nxi, puts old_nxi on change
20839 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20841 + struct nx_info *old_nxi;
20847 + vxdprintk(VXD_CBIT(nid, 5),
20848 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20849 + p, nxi, nxi->nx_id,
20850 + atomic_read(&nxi->nx_usecnt),
20851 + atomic_read(&nxi->nx_tasks));
20853 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20854 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20857 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20860 + /* maybe disallow this completely? */
20861 + old_nxi = task_get_nx_info(p);
20862 + if (old_nxi == nxi)
20867 + clr_nx_info(&p->nx_info);
20868 + claim_nx_info(nxi, p);
20869 + set_nx_info(&p->nx_info, nxi);
20870 + p->nid = nxi->nx_id;
20873 + vxdprintk(VXD_CBIT(nid, 5),
20874 + "moved task %p into nxi:%p[#%d]",
20875 + p, nxi, nxi->nx_id);
20878 + release_nx_info(old_nxi, p);
20881 + put_nx_info(old_nxi);
20886 +void nx_set_persistent(struct nx_info *nxi)
20888 + vxdprintk(VXD_CBIT(nid, 6),
20889 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20891 + get_nx_info(nxi);
20892 + claim_nx_info(nxi, NULL);
20895 +void nx_clear_persistent(struct nx_info *nxi)
20897 + vxdprintk(VXD_CBIT(nid, 6),
20898 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20900 + release_nx_info(nxi, NULL);
20901 + put_nx_info(nxi);
20904 +void nx_update_persistent(struct nx_info *nxi)
20906 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20907 + nx_set_persistent(nxi);
20909 + nx_clear_persistent(nxi);
20912 +/* vserver syscall commands below here */
20914 +/* taks nid and nx_info functions */
20916 +#include <asm/uaccess.h>
20919 +int vc_task_nid(uint32_t id)
20924 + struct task_struct *tsk;
20927 + tsk = find_task_by_real_pid(id);
20928 + nid = (tsk) ? tsk->nid : -ESRCH;
20929 + rcu_read_unlock();
20931 + nid = nx_current_nid();
20936 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20938 + struct vcmd_nx_info_v0 vc_data;
20940 + vc_data.nid = nxi->nx_id;
20942 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20948 +/* network functions */
20950 +int vc_net_create(uint32_t nid, void __user *data)
20952 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
20953 + struct nx_info *new_nxi;
20956 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20959 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
20962 + new_nxi = __create_nx_info(nid);
20963 + if (IS_ERR(new_nxi))
20964 + return PTR_ERR(new_nxi);
20966 + /* initial flags */
20967 + new_nxi->nx_flags = vc_data.flagword;
20970 + if (vs_net_change(new_nxi, VSC_NETUP))
20973 + ret = nx_migrate_task(current, new_nxi);
20977 + /* return context id on success */
20978 + ret = new_nxi->nx_id;
20980 + /* get a reference for persistent contexts */
20981 + if ((vc_data.flagword & NXF_PERSISTENT))
20982 + nx_set_persistent(new_nxi);
20984 + release_nx_info(new_nxi, NULL);
20985 + put_nx_info(new_nxi);
20990 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
20992 + return nx_migrate_task(current, nxi);
20997 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20998 + uint16_t type, uint16_t flags)
21000 + struct nx_addr_v4 *nxa = &nxi->v4;
21002 + if (NX_IPV4(nxi)) {
21003 + /* locate last entry */
21004 + for (; nxa->next; nxa = nxa->next);
21005 + nxa->next = __alloc_nx_addr_v4();
21009 + return PTR_ERR(nxa);
21012 + if (nxi->v4.next)
21013 + /* remove single ip for ip list */
21014 + nxi->nx_flags &= ~NXF_SINGLE_IP;
21016 + nxa->ip[0].s_addr = ip;
21017 + nxa->ip[1].s_addr = ip2;
21018 + nxa->mask.s_addr = mask;
21019 + nxa->type = type;
21020 + nxa->flags = flags;
21024 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
21025 + uint16_t type, uint16_t flags)
21027 + struct nx_addr_v4 *nxa = &nxi->v4;
21030 +/* case NXA_TYPE_ADDR:
21033 + case NXA_TYPE_ANY:
21034 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
21035 + memset(nxa, 0, sizeof(*nxa));
21045 +int vc_net_add(struct nx_info *nxi, void __user *data)
21047 + struct vcmd_net_addr_v0 vc_data;
21048 + int index, ret = 0;
21050 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21053 + switch (vc_data.type) {
21054 + case NXA_TYPE_IPV4:
21055 + if ((vc_data.count < 1) || (vc_data.count > 4))
21059 + while (index < vc_data.count) {
21060 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
21061 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
21069 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
21070 + nxi->v4_bcast = vc_data.ip[0];
21074 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
21075 + nxi->v4_lback = vc_data.ip[0];
21086 +int vc_net_remove(struct nx_info *nxi, void __user *data)
21088 + struct vcmd_net_addr_v0 vc_data;
21090 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21093 + switch (vc_data.type) {
21094 + case NXA_TYPE_ANY:
21095 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
21096 + memset(&nxi->v4, 0, sizeof(nxi->v4));
21106 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
21108 + struct vcmd_net_addr_ipv4_v1 vc_data;
21110 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21113 + switch (vc_data.type) {
21114 + case NXA_TYPE_ADDR:
21115 + case NXA_TYPE_MASK:
21116 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
21117 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21119 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21120 + nxi->v4_bcast = vc_data.ip;
21123 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21124 + nxi->v4_lback = vc_data.ip;
21133 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
21135 + struct vcmd_net_addr_ipv4_v2 vc_data;
21137 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21140 + switch (vc_data.type) {
21141 + case NXA_TYPE_ADDR:
21142 + case NXA_TYPE_MASK:
21143 + case NXA_TYPE_RANGE:
21144 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
21145 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21147 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
21148 + nxi->v4_bcast = vc_data.ip;
21151 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
21152 + nxi->v4_lback = vc_data.ip;
21161 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
21163 + struct vcmd_net_addr_ipv4_v1 vc_data;
21165 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21168 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
21169 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21172 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
21174 + struct vcmd_net_addr_ipv4_v2 vc_data;
21176 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21179 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
21180 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
21183 +#ifdef CONFIG_IPV6
21185 +int do_add_v6_addr(struct nx_info *nxi,
21186 + struct in6_addr *ip, struct in6_addr *mask,
21187 + uint32_t prefix, uint16_t type, uint16_t flags)
21189 + struct nx_addr_v6 *nxa = &nxi->v6;
21191 + if (NX_IPV6(nxi)) {
21192 + /* locate last entry */
21193 + for (; nxa->next; nxa = nxa->next);
21194 + nxa->next = __alloc_nx_addr_v6();
21198 + return PTR_ERR(nxa);
21202 + nxa->mask = *mask;
21203 + nxa->prefix = prefix;
21204 + nxa->type = type;
21205 + nxa->flags = flags;
21210 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21212 + struct vcmd_net_addr_ipv6_v1 vc_data;
21214 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21217 + switch (vc_data.type) {
21218 + case NXA_TYPE_ADDR:
21219 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
21220 + /* fallthrough */
21221 + case NXA_TYPE_MASK:
21222 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21223 + vc_data.prefix, vc_data.type, vc_data.flags);
21230 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21232 + struct vcmd_net_addr_ipv6_v1 vc_data;
21234 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21237 + switch (vc_data.type) {
21238 + case NXA_TYPE_ANY:
21239 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21240 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21249 +#endif /* CONFIG_IPV6 */
21252 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21254 + struct vcmd_net_flags_v0 vc_data;
21256 + vc_data.flagword = nxi->nx_flags;
21258 + /* special STATE flag handling */
21259 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21261 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21266 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21268 + struct vcmd_net_flags_v0 vc_data;
21269 + uint64_t mask, trigger;
21271 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21274 + /* special STATE flag handling */
21275 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21276 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21278 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21279 + vc_data.flagword, mask);
21280 + if (trigger & NXF_PERSISTENT)
21281 + nx_update_persistent(nxi);
21286 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21288 + struct vcmd_net_caps_v0 vc_data;
21290 + vc_data.ncaps = nxi->nx_ncaps;
21291 + vc_data.cmask = ~0ULL;
21293 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21298 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21300 + struct vcmd_net_caps_v0 vc_data;
21302 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21305 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21306 + vc_data.ncaps, vc_data.cmask);
21311 +#include <linux/module.h>
21313 +module_init(init_network);
21315 +EXPORT_SYMBOL_GPL(free_nx_info);
21316 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21318 diff -NurpP --minimal linux-3.1.1/kernel/vserver/proc.c linux-3.1.1-vs2.3.2/kernel/vserver/proc.c
21319 --- linux-3.1.1/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21320 +++ linux-3.1.1-vs2.3.2/kernel/vserver/proc.c 2011-10-24 18:53:33.000000000 +0200
21323 + * linux/kernel/vserver/proc.c
21325 + * Virtual Context Support
21327 + * Copyright (C) 2003-2011 Herbert Pötzl
21329 + * V0.01 basic structure
21330 + * V0.02 adaptation vs1.3.0
21331 + * V0.03 proc permissions
21332 + * V0.04 locking/generic
21333 + * V0.05 next generation procfs
21334 + * V0.06 inode validation
21335 + * V0.07 generic rewrite vid
21336 + * V0.08 remove inode type
21337 + * V0.09 added u/wmask info
21341 +#include <linux/proc_fs.h>
21342 +#include <linux/fs_struct.h>
21343 +#include <linux/mount.h>
21344 +#include <asm/unistd.h>
21346 +#include <linux/vs_context.h>
21347 +#include <linux/vs_network.h>
21348 +#include <linux/vs_cvirt.h>
21350 +#include <linux/in.h>
21351 +#include <linux/inetdevice.h>
21352 +#include <linux/vs_inet.h>
21353 +#include <linux/vs_inet6.h>
21355 +#include <linux/vserver/global.h>
21357 +#include "cvirt_proc.h"
21358 +#include "cacct_proc.h"
21359 +#include "limit_proc.h"
21360 +#include "sched_proc.h"
21361 +#include "vci_config.h"
21364 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21368 + CAP_FOR_EACH_U32(__capi) {
21369 + buffer += sprintf(buffer, "%08x",
21370 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21376 +static struct proc_dir_entry *proc_virtual;
21378 +static struct proc_dir_entry *proc_virtnet;
21381 +/* first the actual feeds */
21384 +static int proc_vci(char *buffer)
21386 + return sprintf(buffer,
21387 + "VCIVersion:\t%04x:%04x\n"
21388 + "VCISyscall:\t%d\n"
21389 + "VCIKernel:\t%08x\n",
21390 + VCI_VERSION >> 16,
21391 + VCI_VERSION & 0xFFFF,
21393 + vci_kernel_config());
21396 +static int proc_virtual_info(char *buffer)
21398 + return proc_vci(buffer);
21401 +static int proc_virtual_status(char *buffer)
21403 + return sprintf(buffer,
21405 + "#CActive:\t%d\n"
21406 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21407 + "#InitTask:\t%d\t%d %d\n",
21408 + atomic_read(&vx_global_ctotal),
21409 + atomic_read(&vx_global_cactive),
21410 + atomic_read(&vs_global_nsproxy),
21411 + atomic_read(&vs_global_fs),
21412 + atomic_read(&vs_global_mnt_ns),
21413 + atomic_read(&vs_global_uts_ns),
21414 + atomic_read(&nr_ipc_ns),
21415 + atomic_read(&vs_global_user_ns),
21416 + atomic_read(&vs_global_pid_ns),
21417 + atomic_read(&init_task.usage),
21418 + atomic_read(&init_task.nsproxy->count),
21419 + init_task.fs->users);
21423 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21427 + length = sprintf(buffer,
21435 + vxi->vx_badness_bias);
21439 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21441 + char *orig = buffer;
21443 + buffer += sprintf(buffer,
21446 + "Flags:\t%016llx\n",
21447 + atomic_read(&vxi->vx_usecnt),
21448 + atomic_read(&vxi->vx_tasks),
21449 + (unsigned long long)vxi->vx_flags);
21451 + buffer += sprintf(buffer, "BCaps:\t");
21452 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21453 + buffer += sprintf(buffer, "\n");
21455 + buffer += sprintf(buffer,
21456 + "CCaps:\t%016llx\n"
21457 + "Umask:\t%16llx\n"
21458 + "Wmask:\t%16llx\n"
21459 + "Spaces:\t%08lx %08lx\n",
21460 + (unsigned long long)vxi->vx_ccaps,
21461 + (unsigned long long)vxi->vx_umask,
21462 + (unsigned long long)vxi->vx_wmask,
21463 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21464 + return buffer - orig;
21467 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21469 + return vx_info_proc_limit(&vxi->limit, buffer);
21472 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21476 + length = vx_info_proc_sched(&vxi->sched, buffer);
21477 + for_each_online_cpu(cpu) {
21478 + length += vx_info_proc_sched_pc(
21479 + &vx_per_cpu(vxi, sched_pc, cpu),
21480 + buffer + length, cpu);
21485 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21487 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21490 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21492 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21495 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21499 + vx_update_load(vxi);
21500 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21501 + for_each_online_cpu(cpu) {
21502 + length += vx_info_proc_cvirt_pc(
21503 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21504 + buffer + length, cpu);
21509 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21511 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21515 +static int proc_virtnet_info(char *buffer)
21517 + return proc_vci(buffer);
21520 +static int proc_virtnet_status(char *buffer)
21522 + return sprintf(buffer,
21524 + "#CActive:\t%d\n",
21525 + atomic_read(&nx_global_ctotal),
21526 + atomic_read(&nx_global_cactive));
21529 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21531 + struct nx_addr_v4 *v4a;
21532 +#ifdef CONFIG_IPV6
21533 + struct nx_addr_v6 *v6a;
21537 + length = sprintf(buffer,
21540 + "Bcast:\t" NIPQUAD_FMT "\n"
21541 + "Lback:\t" NIPQUAD_FMT "\n",
21544 + NIPQUAD(nxi->v4_bcast.s_addr),
21545 + NIPQUAD(nxi->v4_lback.s_addr));
21547 + if (!NX_IPV4(nxi))
21549 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21550 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21553 +#ifdef CONFIG_IPV6
21554 + if (!NX_IPV6(nxi))
21556 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21557 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21564 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21568 + length = sprintf(buffer,
21571 + "Flags:\t%016llx\n"
21572 + "NCaps:\t%016llx\n",
21573 + atomic_read(&nxi->nx_usecnt),
21574 + atomic_read(&nxi->nx_tasks),
21575 + (unsigned long long)nxi->nx_flags,
21576 + (unsigned long long)nxi->nx_ncaps);
21582 +/* here the inode helpers */
21588 + struct inode_operations *iop;
21589 + struct file_operations *fop;
21590 + union proc_op op;
21593 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21595 + struct inode *inode = new_inode(sb);
21600 + inode->i_mode = p->mode;
21602 + inode->i_op = p->iop;
21604 + inode->i_fop = p->fop;
21606 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
21607 + inode->i_flags |= S_IMMUTABLE;
21609 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21611 + inode->i_uid = 0;
21612 + inode->i_gid = 0;
21613 + inode->i_tag = 0;
21618 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21619 + struct dentry *dentry, int id, void *ptr)
21621 + struct vs_entry *p = ptr;
21622 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21623 + struct dentry *error = ERR_PTR(-EINVAL);
21628 + PROC_I(inode)->op = p->op;
21629 + PROC_I(inode)->fd = id;
21630 + d_add(dentry, inode);
21638 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21641 + * Fill a directory entry.
21643 + * If possible create the dcache entry and derive our inode number and
21644 + * file type from dcache entry.
21646 + * Since all of the proc inode numbers are dynamically generated, the inode
21647 + * numbers do not exist until the inode is cache. This means creating the
21648 + * the dcache entry in readdir is necessary to keep the inode numbers
21649 + * reported by readdir in sync with the inode numbers reported
21652 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21653 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21655 + struct dentry *child, *dir = filp->f_dentry;
21656 + struct inode *inode;
21657 + struct qstr qname;
21659 + unsigned type = DT_UNKNOWN;
21661 + qname.name = name;
21663 + qname.hash = full_name_hash(name, len);
21665 + child = d_lookup(dir, &qname);
21667 + struct dentry *new;
21668 + new = d_alloc(dir, &qname);
21670 + child = instantiate(dir->d_inode, new, id, ptr);
21677 + if (!child || IS_ERR(child) || !child->d_inode)
21678 + goto end_instantiate;
21679 + inode = child->d_inode;
21681 + ino = inode->i_ino;
21682 + type = inode->i_mode >> 12;
21687 + ino = find_inode_number(dir, &qname);
21690 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21695 +/* get and revalidate vx_info/xid */
21698 +struct vx_info *get_proc_vx_info(struct inode *inode)
21700 + return lookup_vx_info(PROC_I(inode)->fd);
21703 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21705 + struct inode *inode = dentry->d_inode;
21706 + xid_t xid = PROC_I(inode)->fd;
21708 + if (!xid || xid_is_hashed(xid))
21715 +/* get and revalidate nx_info/nid */
21717 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21719 + struct inode *inode = dentry->d_inode;
21720 + nid_t nid = PROC_I(inode)->fd;
21722 + if (!nid || nid_is_hashed(nid))
21730 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21732 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21733 + size_t count, loff_t *ppos)
21735 + struct inode *inode = file->f_dentry->d_inode;
21736 + unsigned long page;
21737 + ssize_t length = 0;
21739 + if (count > PROC_BLOCK_SIZE)
21740 + count = PROC_BLOCK_SIZE;
21742 + /* fade that out as soon as stable */
21743 + WARN_ON(PROC_I(inode)->fd);
21745 + if (!(page = __get_free_page(GFP_KERNEL)))
21748 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21749 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21752 + length = simple_read_from_buffer(buf, count, ppos,
21753 + (char *)page, length);
21759 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21760 + size_t count, loff_t *ppos)
21762 + struct inode *inode = file->f_dentry->d_inode;
21763 + struct vx_info *vxi = NULL;
21764 + xid_t xid = PROC_I(inode)->fd;
21765 + unsigned long page;
21766 + ssize_t length = 0;
21768 + if (count > PROC_BLOCK_SIZE)
21769 + count = PROC_BLOCK_SIZE;
21771 + /* fade that out as soon as stable */
21773 + vxi = lookup_vx_info(xid);
21777 + length = -ENOMEM;
21778 + if (!(page = __get_free_page(GFP_KERNEL)))
21781 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21782 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21785 + length = simple_read_from_buffer(buf, count, ppos,
21786 + (char *)page, length);
21790 + put_vx_info(vxi);
21795 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21796 + size_t count, loff_t *ppos)
21798 + struct inode *inode = file->f_dentry->d_inode;
21799 + struct nx_info *nxi = NULL;
21800 + nid_t nid = PROC_I(inode)->fd;
21801 + unsigned long page;
21802 + ssize_t length = 0;
21804 + if (count > PROC_BLOCK_SIZE)
21805 + count = PROC_BLOCK_SIZE;
21807 + /* fade that out as soon as stable */
21809 + nxi = lookup_nx_info(nid);
21813 + length = -ENOMEM;
21814 + if (!(page = __get_free_page(GFP_KERNEL)))
21817 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21818 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21821 + length = simple_read_from_buffer(buf, count, ppos,
21822 + (char *)page, length);
21826 + put_nx_info(nxi);
21833 +/* here comes the lower level */
21836 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21837 + .len = sizeof(NAME) - 1, \
21838 + .name = (NAME), \
21846 +#define DIR(NAME, MODE, OTYPE) \
21847 + NOD(NAME, (S_IFDIR | (MODE)), \
21848 + &proc_ ## OTYPE ## _inode_operations, \
21849 + &proc_ ## OTYPE ## _file_operations, { } )
21851 +#define INF(NAME, MODE, OTYPE) \
21852 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21853 + &proc_vs_info_file_operations, \
21854 + { .proc_vs_read = &proc_##OTYPE } )
21856 +#define VINF(NAME, MODE, OTYPE) \
21857 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21858 + &proc_vx_info_file_operations, \
21859 + { .proc_vxi_read = &proc_##OTYPE } )
21861 +#define NINF(NAME, MODE, OTYPE) \
21862 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21863 + &proc_nx_info_file_operations, \
21864 + { .proc_nxi_read = &proc_##OTYPE } )
21867 +static struct file_operations proc_vs_info_file_operations = {
21868 + .read = proc_vs_info_read,
21871 +static struct file_operations proc_vx_info_file_operations = {
21872 + .read = proc_vx_info_read,
21875 +static struct dentry_operations proc_xid_dentry_operations = {
21876 + .d_revalidate = proc_xid_revalidate,
21879 +static struct vs_entry vx_base_stuff[] = {
21880 + VINF("info", S_IRUGO, vxi_info),
21881 + VINF("status", S_IRUGO, vxi_status),
21882 + VINF("limit", S_IRUGO, vxi_limit),
21883 + VINF("sched", S_IRUGO, vxi_sched),
21884 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21885 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21886 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21887 + VINF("cacct", S_IRUGO, vxi_cacct),
21894 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21895 + struct dentry *dentry, int id, void *ptr)
21897 + dentry->d_op = &proc_xid_dentry_operations;
21898 + return vs_proc_instantiate(dir, dentry, id, ptr);
21901 +static struct dentry *proc_xid_lookup(struct inode *dir,
21902 + struct dentry *dentry, struct nameidata *nd)
21904 + struct vs_entry *p = vx_base_stuff;
21905 + struct dentry *error = ERR_PTR(-ENOENT);
21907 + for (; p->name; p++) {
21908 + if (p->len != dentry->d_name.len)
21910 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21916 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21921 +static int proc_xid_readdir(struct file *filp,
21922 + void *dirent, filldir_t filldir)
21924 + struct dentry *dentry = filp->f_dentry;
21925 + struct inode *inode = dentry->d_inode;
21926 + struct vs_entry *p = vx_base_stuff;
21927 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21931 + pos = filp->f_pos;
21934 + ino = inode->i_ino;
21935 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21938 + /* fall through */
21940 + ino = parent_ino(dentry);
21941 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21944 + /* fall through */
21947 + if (index >= size)
21949 + for (p += index; p->name; p++) {
21950 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21951 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21957 + filp->f_pos = pos;
21963 +static struct file_operations proc_nx_info_file_operations = {
21964 + .read = proc_nx_info_read,
21967 +static struct dentry_operations proc_nid_dentry_operations = {
21968 + .d_revalidate = proc_nid_revalidate,
21971 +static struct vs_entry nx_base_stuff[] = {
21972 + NINF("info", S_IRUGO, nxi_info),
21973 + NINF("status", S_IRUGO, nxi_status),
21978 +static struct dentry *proc_nid_instantiate(struct inode *dir,
21979 + struct dentry *dentry, int id, void *ptr)
21981 + dentry->d_op = &proc_nid_dentry_operations;
21982 + return vs_proc_instantiate(dir, dentry, id, ptr);
21985 +static struct dentry *proc_nid_lookup(struct inode *dir,
21986 + struct dentry *dentry, struct nameidata *nd)
21988 + struct vs_entry *p = nx_base_stuff;
21989 + struct dentry *error = ERR_PTR(-ENOENT);
21991 + for (; p->name; p++) {
21992 + if (p->len != dentry->d_name.len)
21994 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22000 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
22005 +static int proc_nid_readdir(struct file *filp,
22006 + void *dirent, filldir_t filldir)
22008 + struct dentry *dentry = filp->f_dentry;
22009 + struct inode *inode = dentry->d_inode;
22010 + struct vs_entry *p = nx_base_stuff;
22011 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
22015 + pos = filp->f_pos;
22018 + ino = inode->i_ino;
22019 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22022 + /* fall through */
22024 + ino = parent_ino(dentry);
22025 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22028 + /* fall through */
22031 + if (index >= size)
22033 + for (p += index; p->name; p++) {
22034 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22035 + vs_proc_instantiate, PROC_I(inode)->fd, p))
22041 + filp->f_pos = pos;
22046 +#define MAX_MULBY10 ((~0U - 9) / 10)
22048 +static inline int atovid(const char *str, int len)
22053 + while (len-- > 0) {
22058 + if (vid >= MAX_MULBY10)
22068 +/* now the upper level (virtual) */
22071 +static struct file_operations proc_xid_file_operations = {
22072 + .read = generic_read_dir,
22073 + .readdir = proc_xid_readdir,
22076 +static struct inode_operations proc_xid_inode_operations = {
22077 + .lookup = proc_xid_lookup,
22080 +static struct vs_entry vx_virtual_stuff[] = {
22081 + INF("info", S_IRUGO, virtual_info),
22082 + INF("status", S_IRUGO, virtual_status),
22083 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
22087 +static struct dentry *proc_virtual_lookup(struct inode *dir,
22088 + struct dentry *dentry, struct nameidata *nd)
22090 + struct vs_entry *p = vx_virtual_stuff;
22091 + struct dentry *error = ERR_PTR(-ENOENT);
22094 + for (; p->name; p++) {
22095 + if (p->len != dentry->d_name.len)
22097 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22101 + goto instantiate;
22103 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22104 + if ((id < 0) || !xid_is_hashed(id))
22108 + error = proc_xid_instantiate(dir, dentry, id, p);
22113 +static struct file_operations proc_nid_file_operations = {
22114 + .read = generic_read_dir,
22115 + .readdir = proc_nid_readdir,
22118 +static struct inode_operations proc_nid_inode_operations = {
22119 + .lookup = proc_nid_lookup,
22122 +static struct vs_entry nx_virtnet_stuff[] = {
22123 + INF("info", S_IRUGO, virtnet_info),
22124 + INF("status", S_IRUGO, virtnet_status),
22125 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
22129 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
22130 + struct dentry *dentry, struct nameidata *nd)
22132 + struct vs_entry *p = nx_virtnet_stuff;
22133 + struct dentry *error = ERR_PTR(-ENOENT);
22136 + for (; p->name; p++) {
22137 + if (p->len != dentry->d_name.len)
22139 + if (!memcmp(dentry->d_name.name, p->name, p->len))
22143 + goto instantiate;
22145 + id = atovid(dentry->d_name.name, dentry->d_name.len);
22146 + if ((id < 0) || !nid_is_hashed(id))
22150 + error = proc_nid_instantiate(dir, dentry, id, p);
22156 +#define PROC_MAXVIDS 32
22158 +int proc_virtual_readdir(struct file *filp,
22159 + void *dirent, filldir_t filldir)
22161 + struct dentry *dentry = filp->f_dentry;
22162 + struct inode *inode = dentry->d_inode;
22163 + struct vs_entry *p = vx_virtual_stuff;
22164 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
22166 + unsigned int xid_array[PROC_MAXVIDS];
22167 + char buf[PROC_NUMBUF];
22168 + unsigned int nr_xids, i;
22171 + pos = filp->f_pos;
22174 + ino = inode->i_ino;
22175 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22178 + /* fall through */
22180 + ino = parent_ino(dentry);
22181 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22184 + /* fall through */
22187 + if (index >= size)
22189 + for (p += index; p->name; p++) {
22190 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22191 + vs_proc_instantiate, 0, p))
22196 + index = pos - size;
22197 + p = &vx_virtual_stuff[size - 1];
22198 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22199 + for (i = 0; i < nr_xids; i++) {
22200 + int n, xid = xid_array[i];
22201 + unsigned int j = PROC_NUMBUF;
22205 + buf[--j] = '0' + (n % 10);
22208 + if (proc_fill_cache(filp, dirent, filldir,
22209 + buf + j, PROC_NUMBUF - j,
22210 + vs_proc_instantiate, xid, p))
22216 + filp->f_pos = pos;
22220 +static int proc_virtual_getattr(struct vfsmount *mnt,
22221 + struct dentry *dentry, struct kstat *stat)
22223 + struct inode *inode = dentry->d_inode;
22225 + generic_fillattr(inode, stat);
22226 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22230 +static struct file_operations proc_virtual_dir_operations = {
22231 + .read = generic_read_dir,
22232 + .readdir = proc_virtual_readdir,
22235 +static struct inode_operations proc_virtual_dir_inode_operations = {
22236 + .getattr = proc_virtual_getattr,
22237 + .lookup = proc_virtual_lookup,
22244 +int proc_virtnet_readdir(struct file *filp,
22245 + void *dirent, filldir_t filldir)
22247 + struct dentry *dentry = filp->f_dentry;
22248 + struct inode *inode = dentry->d_inode;
22249 + struct vs_entry *p = nx_virtnet_stuff;
22250 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22252 + unsigned int nid_array[PROC_MAXVIDS];
22253 + char buf[PROC_NUMBUF];
22254 + unsigned int nr_nids, i;
22257 + pos = filp->f_pos;
22260 + ino = inode->i_ino;
22261 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22264 + /* fall through */
22266 + ino = parent_ino(dentry);
22267 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22270 + /* fall through */
22273 + if (index >= size)
22275 + for (p += index; p->name; p++) {
22276 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22277 + vs_proc_instantiate, 0, p))
22282 + index = pos - size;
22283 + p = &nx_virtnet_stuff[size - 1];
22284 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22285 + for (i = 0; i < nr_nids; i++) {
22286 + int n, nid = nid_array[i];
22287 + unsigned int j = PROC_NUMBUF;
22291 + buf[--j] = '0' + (n % 10);
22294 + if (proc_fill_cache(filp, dirent, filldir,
22295 + buf + j, PROC_NUMBUF - j,
22296 + vs_proc_instantiate, nid, p))
22302 + filp->f_pos = pos;
22306 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22307 + struct dentry *dentry, struct kstat *stat)
22309 + struct inode *inode = dentry->d_inode;
22311 + generic_fillattr(inode, stat);
22312 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22316 +static struct file_operations proc_virtnet_dir_operations = {
22317 + .read = generic_read_dir,
22318 + .readdir = proc_virtnet_readdir,
22321 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22322 + .getattr = proc_virtnet_getattr,
22323 + .lookup = proc_virtnet_lookup,
22328 +void proc_vx_init(void)
22330 + struct proc_dir_entry *ent;
22332 + ent = proc_mkdir("virtual", 0);
22334 + ent->proc_fops = &proc_virtual_dir_operations;
22335 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22337 + proc_virtual = ent;
22339 + ent = proc_mkdir("virtnet", 0);
22341 + ent->proc_fops = &proc_virtnet_dir_operations;
22342 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22344 + proc_virtnet = ent;
22350 +/* per pid info */
22353 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22355 + struct vx_info *vxi;
22356 + char *orig = buffer;
22358 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22360 + vxi = task_get_vx_info(p);
22364 + buffer += sprintf(buffer, "BCaps:\t");
22365 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22366 + buffer += sprintf(buffer, "\n");
22367 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22368 + (unsigned long long)vxi->vx_ccaps);
22369 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22370 + (unsigned long long)vxi->vx_flags);
22371 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22373 + put_vx_info(vxi);
22375 + return buffer - orig;
22379 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22381 + struct nx_info *nxi;
22382 + struct nx_addr_v4 *v4a;
22383 +#ifdef CONFIG_IPV6
22384 + struct nx_addr_v6 *v6a;
22386 + char *orig = buffer;
22389 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22391 + nxi = task_get_nx_info(p);
22395 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22396 + (unsigned long long)nxi->nx_ncaps);
22397 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22398 + (unsigned long long)nxi->nx_flags);
22400 + buffer += sprintf(buffer,
22401 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22402 + NIPQUAD(nxi->v4_bcast.s_addr));
22403 + buffer += sprintf (buffer,
22404 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22405 + NIPQUAD(nxi->v4_lback.s_addr));
22406 + if (!NX_IPV4(nxi))
22408 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22409 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22412 +#ifdef CONFIG_IPV6
22413 + if (!NX_IPV6(nxi))
22415 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22416 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22420 + put_nx_info(nxi);
22422 + return buffer - orig;
22425 diff -NurpP --minimal linux-3.1.1/kernel/vserver/sched.c linux-3.1.1-vs2.3.2/kernel/vserver/sched.c
22426 --- linux-3.1.1/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22427 +++ linux-3.1.1-vs2.3.2/kernel/vserver/sched.c 2011-10-24 18:53:33.000000000 +0200
22430 + * linux/kernel/vserver/sched.c
22432 + * Virtual Server: Scheduler Support
22434 + * Copyright (C) 2004-2010 Herbert Pötzl
22436 + * V0.01 adapted Sam Vilains version to 2.6.3
22437 + * V0.02 removed legacy interface
22438 + * V0.03 changed vcmds to vxi arg
22439 + * V0.04 removed older and legacy interfaces
22440 + * V0.05 removed scheduler code/commands
22444 +#include <linux/vs_context.h>
22445 +#include <linux/vs_sched.h>
22446 +#include <linux/vserver/sched_cmd.h>
22448 +#include <asm/uaccess.h>
22451 +void vx_update_sched_param(struct _vx_sched *sched,
22452 + struct _vx_sched_pc *sched_pc)
22454 + sched_pc->prio_bias = sched->prio_bias;
22457 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22461 + if (data->prio_bias > MAX_PRIO_BIAS)
22462 + data->prio_bias = MAX_PRIO_BIAS;
22463 + if (data->prio_bias < MIN_PRIO_BIAS)
22464 + data->prio_bias = MIN_PRIO_BIAS;
22466 + if (data->cpu_id != ~0) {
22467 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22468 + cpus_and(vxi->sched.update, cpu_online_map,
22469 + vxi->sched.update);
22471 + vxi->sched.update = cpu_online_map;
22473 + for_each_cpu_mask(cpu, vxi->sched.update)
22474 + vx_update_sched_param(&vxi->sched,
22475 + &vx_per_cpu(vxi, sched_pc, cpu));
22479 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22481 + struct vcmd_prio_bias vc_data;
22483 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22486 + return do_set_prio_bias(vxi, &vc_data);
22489 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22491 + struct vcmd_prio_bias vc_data;
22492 + struct _vx_sched_pc *pcd;
22495 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22498 + cpu = vc_data.cpu_id;
22500 + if (!cpu_possible(cpu))
22503 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22504 + vc_data.prio_bias = pcd->prio_bias;
22506 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22511 diff -NurpP --minimal linux-3.1.1/kernel/vserver/sched_init.h linux-3.1.1-vs2.3.2/kernel/vserver/sched_init.h
22512 --- linux-3.1.1/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22513 +++ linux-3.1.1-vs2.3.2/kernel/vserver/sched_init.h 2011-10-24 18:53:33.000000000 +0200
22516 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22518 + /* scheduling; hard code starting values as constants */
22519 + sched->prio_bias = 0;
22523 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22525 + sched_pc->prio_bias = 0;
22527 + sched_pc->user_ticks = 0;
22528 + sched_pc->sys_ticks = 0;
22529 + sched_pc->hold_ticks = 0;
22532 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22538 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22542 diff -NurpP --minimal linux-3.1.1/kernel/vserver/sched_proc.h linux-3.1.1-vs2.3.2/kernel/vserver/sched_proc.h
22543 --- linux-3.1.1/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22544 +++ linux-3.1.1-vs2.3.2/kernel/vserver/sched_proc.h 2011-10-24 18:53:33.000000000 +0200
22546 +#ifndef _VX_SCHED_PROC_H
22547 +#define _VX_SCHED_PROC_H
22551 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22555 + length += sprintf(buffer,
22556 + "PrioBias:\t%8d\n",
22557 + sched->prio_bias);
22562 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22563 + char *buffer, int cpu)
22567 + length += sprintf(buffer + length,
22568 + "cpu %d: %lld %lld %lld", cpu,
22569 + (unsigned long long)sched_pc->user_ticks,
22570 + (unsigned long long)sched_pc->sys_ticks,
22571 + (unsigned long long)sched_pc->hold_ticks);
22572 + length += sprintf(buffer + length,
22573 + " %d\n", sched_pc->prio_bias);
22577 +#endif /* _VX_SCHED_PROC_H */
22578 diff -NurpP --minimal linux-3.1.1/kernel/vserver/signal.c linux-3.1.1-vs2.3.2/kernel/vserver/signal.c
22579 --- linux-3.1.1/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22580 +++ linux-3.1.1-vs2.3.2/kernel/vserver/signal.c 2011-10-24 18:53:33.000000000 +0200
22583 + * linux/kernel/vserver/signal.c
22585 + * Virtual Server: Signal Support
22587 + * Copyright (C) 2003-2007 Herbert Pötzl
22589 + * V0.01 broken out from vcontext V0.05
22590 + * V0.02 changed vcmds to vxi arg
22591 + * V0.03 adjusted siginfo for kill
22595 +#include <asm/uaccess.h>
22597 +#include <linux/vs_context.h>
22598 +#include <linux/vs_pid.h>
22599 +#include <linux/vserver/signal_cmd.h>
22602 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22604 + int retval, count = 0;
22605 + struct task_struct *p;
22606 + struct siginfo *sip = SEND_SIG_PRIV;
22609 + vxdprintk(VXD_CBIT(misc, 4),
22610 + "vx_info_kill(%p[#%d],%d,%d)*",
22611 + vxi, vxi->vx_id, pid, sig);
22612 + read_lock(&tasklist_lock);
22616 + for_each_process(p) {
22619 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22620 + (pid && vxi->vx_initpid == p->pid))
22623 + err = group_send_sig_info(sig, sip, p);
22625 + if (err != -EPERM)
22631 + if (vxi->vx_initpid) {
22632 + pid = vxi->vx_initpid;
22633 + /* for now, only SIGINT to private init ... */
22634 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22635 + /* ... as long as there are tasks left */
22636 + (atomic_read(&vxi->vx_tasks) > 1))
22639 + /* fallthrough */
22642 + p = find_task_by_real_pid(pid);
22643 + rcu_read_unlock();
22645 + if (vx_task_xid(p) == vxi->vx_id)
22646 + retval = group_send_sig_info(sig, sip, p);
22650 + read_unlock(&tasklist_lock);
22651 + vxdprintk(VXD_CBIT(misc, 4),
22652 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22653 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22657 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22659 + struct vcmd_ctx_kill_v0 vc_data;
22661 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22664 + /* special check to allow guest shutdown */
22665 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22666 + /* forbid killall pid=0 when init is present */
22667 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22668 + (vc_data.pid > 1)))
22671 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22675 +static int __wait_exit(struct vx_info *vxi)
22677 + DECLARE_WAITQUEUE(wait, current);
22680 + add_wait_queue(&vxi->vx_wait, &wait);
22681 + set_current_state(TASK_INTERRUPTIBLE);
22684 + if (vx_info_state(vxi,
22685 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22687 + if (signal_pending(current)) {
22688 + ret = -ERESTARTSYS;
22695 + set_current_state(TASK_RUNNING);
22696 + remove_wait_queue(&vxi->vx_wait, &wait);
22702 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22704 + struct vcmd_wait_exit_v0 vc_data;
22707 + ret = __wait_exit(vxi);
22708 + vc_data.reboot_cmd = vxi->reboot_cmd;
22709 + vc_data.exit_code = vxi->exit_code;
22711 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22716 diff -NurpP --minimal linux-3.1.1/kernel/vserver/space.c linux-3.1.1-vs2.3.2/kernel/vserver/space.c
22717 --- linux-3.1.1/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22718 +++ linux-3.1.1-vs2.3.2/kernel/vserver/space.c 2011-10-24 18:53:33.000000000 +0200
22721 + * linux/kernel/vserver/space.c
22723 + * Virtual Server: Context Space Support
22725 + * Copyright (C) 2003-2010 Herbert Pötzl
22727 + * V0.01 broken out from context.c 0.07
22728 + * V0.02 added task locking for namespace
22729 + * V0.03 broken out vx_enter_namespace
22730 + * V0.04 added *space support and commands
22731 + * V0.05 added credential support
22735 +#include <linux/utsname.h>
22736 +#include <linux/nsproxy.h>
22737 +#include <linux/err.h>
22738 +#include <linux/fs_struct.h>
22739 +#include <linux/cred.h>
22740 +#include <asm/uaccess.h>
22742 +#include <linux/vs_context.h>
22743 +#include <linux/vserver/space.h>
22744 +#include <linux/vserver/space_cmd.h>
22746 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22747 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22748 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22749 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22750 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22751 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22754 +/* namespace functions */
22756 +#include <linux/mnt_namespace.h>
22757 +#include <linux/user_namespace.h>
22758 +#include <linux/pid_namespace.h>
22759 +#include <linux/ipc_namespace.h>
22760 +#include <net/net_namespace.h>
22763 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22764 + .mask = CLONE_FS |
22766 +#ifdef CONFIG_UTS_NS
22769 +#ifdef CONFIG_IPC_NS
22772 +#ifdef CONFIG_USER_NS
22778 +static const struct vcmd_space_mask_v1 space_mask = {
22779 + .mask = CLONE_FS |
22781 +#ifdef CONFIG_UTS_NS
22784 +#ifdef CONFIG_IPC_NS
22787 +#ifdef CONFIG_USER_NS
22790 +#ifdef CONFIG_PID_NS
22793 +#ifdef CONFIG_NET_NS
22799 +static const struct vcmd_space_mask_v1 default_space_mask = {
22800 + .mask = CLONE_FS |
22802 +#ifdef CONFIG_UTS_NS
22805 +#ifdef CONFIG_IPC_NS
22808 +#ifdef CONFIG_USER_NS
22811 +#ifdef CONFIG_PID_NS
22818 + * build a new nsproxy mix
22819 + * assumes that both proxies are 'const'
22820 + * does not touch nsproxy refcounts
22821 + * will hold a reference on the result.
22824 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22825 + struct nsproxy *new_nsproxy, unsigned long mask)
22827 + struct mnt_namespace *old_ns;
22828 + struct uts_namespace *old_uts;
22829 + struct ipc_namespace *old_ipc;
22830 +#ifdef CONFIG_PID_NS
22831 + struct pid_namespace *old_pid;
22833 +#ifdef CONFIG_NET_NS
22834 + struct net *old_net;
22836 + struct nsproxy *nsproxy;
22838 + nsproxy = copy_nsproxy(old_nsproxy);
22842 + if (mask & CLONE_NEWNS) {
22843 + old_ns = nsproxy->mnt_ns;
22844 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22845 + if (nsproxy->mnt_ns)
22846 + get_mnt_ns(nsproxy->mnt_ns);
22850 + if (mask & CLONE_NEWUTS) {
22851 + old_uts = nsproxy->uts_ns;
22852 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22853 + if (nsproxy->uts_ns)
22854 + get_uts_ns(nsproxy->uts_ns);
22858 + if (mask & CLONE_NEWIPC) {
22859 + old_ipc = nsproxy->ipc_ns;
22860 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22861 + if (nsproxy->ipc_ns)
22862 + get_ipc_ns(nsproxy->ipc_ns);
22866 +#ifdef CONFIG_PID_NS
22867 + if (mask & CLONE_NEWPID) {
22868 + old_pid = nsproxy->pid_ns;
22869 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22870 + if (nsproxy->pid_ns)
22871 + get_pid_ns(nsproxy->pid_ns);
22875 +#ifdef CONFIG_NET_NS
22876 + if (mask & CLONE_NEWNET) {
22877 + old_net = nsproxy->net_ns;
22878 + nsproxy->net_ns = new_nsproxy->net_ns;
22879 + if (nsproxy->net_ns)
22880 + get_net(nsproxy->net_ns);
22885 + put_mnt_ns(old_ns);
22887 + put_uts_ns(old_uts);
22889 + put_ipc_ns(old_ipc);
22890 +#ifdef CONFIG_PID_NS
22892 + put_pid_ns(old_pid);
22894 +#ifdef CONFIG_NET_NS
22896 + put_net(old_net);
22904 + * merge two nsproxy structs into a new one.
22905 + * will hold a reference on the result.
22909 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22910 + struct nsproxy *proxy, unsigned long mask)
22912 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22918 + /* vs_mix_nsproxy returns with reference */
22919 + return vs_mix_nsproxy(old ? old : &null_proxy,
22922 + get_nsproxy(proxy);
22927 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22929 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22930 + struct fs_struct *fs_cur, *fs = NULL;
22931 + struct _vx_space *space;
22932 + int ret, kill = 0;
22934 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22935 + vxi, vxi->vx_id, mask, index);
22937 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22940 + if (index >= VX_SPACES)
22943 + space = &vxi->space[index];
22946 + mask = space->vx_nsmask;
22948 + if ((mask & space->vx_nsmask) != mask)
22951 + if (mask & CLONE_FS) {
22952 + fs = copy_fs_struct(space->vx_fs);
22956 + proxy = space->vx_nsproxy;
22958 + vxdprintk(VXD_CBIT(space, 9),
22959 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
22960 + vxi, vxi->vx_id, mask, index, proxy, fs);
22962 + task_lock(current);
22963 + fs_cur = current->fs;
22965 + if (mask & CLONE_FS) {
22966 + spin_lock(&fs_cur->lock);
22967 + current->fs = fs;
22968 + kill = !--fs_cur->users;
22969 + spin_unlock(&fs_cur->lock);
22972 + proxy_cur = current->nsproxy;
22973 + get_nsproxy(proxy_cur);
22974 + task_unlock(current);
22977 + free_fs_struct(fs_cur);
22979 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
22980 + if (IS_ERR(proxy_new)) {
22981 + ret = PTR_ERR(proxy_new);
22985 + proxy_new = xchg(¤t->nsproxy, proxy_new);
22987 + if (mask & CLONE_NEWUSER) {
22988 + struct cred *cred;
22990 + vxdprintk(VXD_CBIT(space, 10),
22991 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
22992 + vxi, vxi->vx_id, space->vx_cred,
22993 + current->real_cred, current->cred);
22995 + if (space->vx_cred) {
22996 + cred = __prepare_creds(space->vx_cred);
22998 + commit_creds(cred);
23005 + put_nsproxy(proxy_new);
23008 + put_nsproxy(proxy_cur);
23013 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
23015 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
23016 + struct fs_struct *fs_vxi, *fs;
23017 + struct _vx_space *space;
23018 + int ret, kill = 0;
23020 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
23021 + vxi, vxi->vx_id, mask, index);
23023 + if ((mask & space_mask.mask) != mask)
23026 + if (index >= VX_SPACES)
23029 + space = &vxi->space[index];
23031 + proxy_vxi = space->vx_nsproxy;
23032 + fs_vxi = space->vx_fs;
23034 + if (mask & CLONE_FS) {
23035 + fs = copy_fs_struct(current->fs);
23040 + task_lock(current);
23042 + if (mask & CLONE_FS) {
23043 + spin_lock(&fs_vxi->lock);
23044 + space->vx_fs = fs;
23045 + kill = !--fs_vxi->users;
23046 + spin_unlock(&fs_vxi->lock);
23049 + proxy_cur = current->nsproxy;
23050 + get_nsproxy(proxy_cur);
23051 + task_unlock(current);
23054 + free_fs_struct(fs_vxi);
23056 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
23057 + if (IS_ERR(proxy_new)) {
23058 + ret = PTR_ERR(proxy_new);
23062 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
23063 + space->vx_nsmask |= mask;
23065 + if (mask & CLONE_NEWUSER) {
23066 + struct cred *cred;
23068 + vxdprintk(VXD_CBIT(space, 10),
23069 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
23070 + vxi, vxi->vx_id, space->vx_cred,
23071 + current->real_cred, current->cred);
23073 + cred = prepare_creds();
23074 + cred = (struct cred *)xchg(&space->vx_cred, cred);
23076 + abort_creds(cred);
23082 + put_nsproxy(proxy_new);
23085 + put_nsproxy(proxy_cur);
23090 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
23092 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23094 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23097 + return vx_enter_space(vxi, vc_data.mask, 0);
23100 +int vc_enter_space(struct vx_info *vxi, void __user *data)
23102 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23104 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23107 + if (vc_data.index >= VX_SPACES)
23110 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
23113 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
23115 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
23117 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23120 + return vx_set_space(vxi, vc_data.mask, 0);
23123 +int vc_set_space(struct vx_info *vxi, void __user *data)
23125 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
23127 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23130 + if (vc_data.index >= VX_SPACES)
23133 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
23136 +int vc_get_space_mask(void __user *data, int type)
23138 + const struct vcmd_space_mask_v1 *mask;
23141 + mask = &space_mask_v0;
23142 + else if (type == 1)
23143 + mask = &space_mask;
23145 + mask = &default_space_mask;
23147 + vxdprintk(VXD_CBIT(space, 10),
23148 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
23150 + if (copy_to_user(data, mask, sizeof(*mask)))
23155 diff -NurpP --minimal linux-3.1.1/kernel/vserver/switch.c linux-3.1.1-vs2.3.2/kernel/vserver/switch.c
23156 --- linux-3.1.1/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
23157 +++ linux-3.1.1-vs2.3.2/kernel/vserver/switch.c 2011-10-24 18:53:33.000000000 +0200
23160 + * linux/kernel/vserver/switch.c
23162 + * Virtual Server: Syscall Switch
23164 + * Copyright (C) 2003-2011 Herbert Pötzl
23166 + * V0.01 syscall switch
23167 + * V0.02 added signal to context
23168 + * V0.03 added rlimit functions
23169 + * V0.04 added iattr, task/xid functions
23170 + * V0.05 added debug/history stuff
23171 + * V0.06 added compat32 layer
23172 + * V0.07 vcmd args and perms
23173 + * V0.08 added status commands
23174 + * V0.09 added tag commands
23175 + * V0.10 added oom bias
23176 + * V0.11 added device commands
23177 + * V0.12 added warn mask
23181 +#include <linux/vs_context.h>
23182 +#include <linux/vs_network.h>
23183 +#include <linux/vserver/switch.h>
23185 +#include "vci_config.h"
23189 +int vc_get_version(uint32_t id)
23191 + return VCI_VERSION;
23195 +int vc_get_vci(uint32_t id)
23197 + return vci_kernel_config();
23200 +#include <linux/vserver/context_cmd.h>
23201 +#include <linux/vserver/cvirt_cmd.h>
23202 +#include <linux/vserver/cacct_cmd.h>
23203 +#include <linux/vserver/limit_cmd.h>
23204 +#include <linux/vserver/network_cmd.h>
23205 +#include <linux/vserver/sched_cmd.h>
23206 +#include <linux/vserver/debug_cmd.h>
23207 +#include <linux/vserver/inode_cmd.h>
23208 +#include <linux/vserver/dlimit_cmd.h>
23209 +#include <linux/vserver/signal_cmd.h>
23210 +#include <linux/vserver/space_cmd.h>
23211 +#include <linux/vserver/tag_cmd.h>
23212 +#include <linux/vserver/device_cmd.h>
23214 +#include <linux/vserver/inode.h>
23215 +#include <linux/vserver/dlimit.h>
23218 +#ifdef CONFIG_COMPAT
23219 +#define __COMPAT(name, id, data, compat) \
23220 + (compat) ? name ## _x32(id, data) : name(id, data)
23221 +#define __COMPAT_NO_ID(name, data, compat) \
23222 + (compat) ? name ## _x32(data) : name(data)
23224 +#define __COMPAT(name, id, data, compat) \
23226 +#define __COMPAT_NO_ID(name, data, compat) \
23232 +long do_vcmd(uint32_t cmd, uint32_t id,
23233 + struct vx_info *vxi, struct nx_info *nxi,
23234 + void __user *data, int compat)
23238 + case VCMD_get_version:
23239 + return vc_get_version(id);
23240 + case VCMD_get_vci:
23241 + return vc_get_vci(id);
23243 + case VCMD_task_xid:
23244 + return vc_task_xid(id);
23245 + case VCMD_vx_info:
23246 + return vc_vx_info(vxi, data);
23248 + case VCMD_task_nid:
23249 + return vc_task_nid(id);
23250 + case VCMD_nx_info:
23251 + return vc_nx_info(nxi, data);
23253 + case VCMD_task_tag:
23254 + return vc_task_tag(id);
23256 + case VCMD_set_space_v1:
23257 + return vc_set_space_v1(vxi, data);
23258 + /* this is version 2 */
23259 + case VCMD_set_space:
23260 + return vc_set_space(vxi, data);
23262 + case VCMD_get_space_mask_v0:
23263 + return vc_get_space_mask(data, 0);
23264 + /* this is version 1 */
23265 + case VCMD_get_space_mask:
23266 + return vc_get_space_mask(data, 1);
23268 + case VCMD_get_space_default:
23269 + return vc_get_space_mask(data, -1);
23271 + case VCMD_set_umask:
23272 + return vc_set_umask(vxi, data);
23274 + case VCMD_get_umask:
23275 + return vc_get_umask(vxi, data);
23277 + case VCMD_set_wmask:
23278 + return vc_set_wmask(vxi, data);
23280 + case VCMD_get_wmask:
23281 + return vc_get_wmask(vxi, data);
23282 +#ifdef CONFIG_IA32_EMULATION
23283 + case VCMD_get_rlimit:
23284 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23285 + case VCMD_set_rlimit:
23286 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23288 + case VCMD_get_rlimit:
23289 + return vc_get_rlimit(vxi, data);
23290 + case VCMD_set_rlimit:
23291 + return vc_set_rlimit(vxi, data);
23293 + case VCMD_get_rlimit_mask:
23294 + return vc_get_rlimit_mask(id, data);
23295 + case VCMD_reset_hits:
23296 + return vc_reset_hits(vxi, data);
23297 + case VCMD_reset_minmax:
23298 + return vc_reset_minmax(vxi, data);
23300 + case VCMD_get_vhi_name:
23301 + return vc_get_vhi_name(vxi, data);
23302 + case VCMD_set_vhi_name:
23303 + return vc_set_vhi_name(vxi, data);
23305 + case VCMD_ctx_stat:
23306 + return vc_ctx_stat(vxi, data);
23307 + case VCMD_virt_stat:
23308 + return vc_virt_stat(vxi, data);
23309 + case VCMD_sock_stat:
23310 + return vc_sock_stat(vxi, data);
23311 + case VCMD_rlimit_stat:
23312 + return vc_rlimit_stat(vxi, data);
23314 + case VCMD_set_cflags:
23315 + return vc_set_cflags(vxi, data);
23316 + case VCMD_get_cflags:
23317 + return vc_get_cflags(vxi, data);
23319 + /* this is version 1 */
23320 + case VCMD_set_ccaps:
23321 + return vc_set_ccaps(vxi, data);
23322 + /* this is version 1 */
23323 + case VCMD_get_ccaps:
23324 + return vc_get_ccaps(vxi, data);
23325 + case VCMD_set_bcaps:
23326 + return vc_set_bcaps(vxi, data);
23327 + case VCMD_get_bcaps:
23328 + return vc_get_bcaps(vxi, data);
23330 + case VCMD_set_badness:
23331 + return vc_set_badness(vxi, data);
23332 + case VCMD_get_badness:
23333 + return vc_get_badness(vxi, data);
23335 + case VCMD_set_nflags:
23336 + return vc_set_nflags(nxi, data);
23337 + case VCMD_get_nflags:
23338 + return vc_get_nflags(nxi, data);
23340 + case VCMD_set_ncaps:
23341 + return vc_set_ncaps(nxi, data);
23342 + case VCMD_get_ncaps:
23343 + return vc_get_ncaps(nxi, data);
23345 + case VCMD_set_prio_bias:
23346 + return vc_set_prio_bias(vxi, data);
23347 + case VCMD_get_prio_bias:
23348 + return vc_get_prio_bias(vxi, data);
23349 + case VCMD_add_dlimit:
23350 + return __COMPAT(vc_add_dlimit, id, data, compat);
23351 + case VCMD_rem_dlimit:
23352 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23353 + case VCMD_set_dlimit:
23354 + return __COMPAT(vc_set_dlimit, id, data, compat);
23355 + case VCMD_get_dlimit:
23356 + return __COMPAT(vc_get_dlimit, id, data, compat);
23358 + case VCMD_ctx_kill:
23359 + return vc_ctx_kill(vxi, data);
23361 + case VCMD_wait_exit:
23362 + return vc_wait_exit(vxi, data);
23364 + case VCMD_get_iattr:
23365 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23366 + case VCMD_set_iattr:
23367 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23369 + case VCMD_fget_iattr:
23370 + return vc_fget_iattr(id, data);
23371 + case VCMD_fset_iattr:
23372 + return vc_fset_iattr(id, data);
23374 + case VCMD_enter_space_v0:
23375 + return vc_enter_space_v1(vxi, NULL);
23376 + case VCMD_enter_space_v1:
23377 + return vc_enter_space_v1(vxi, data);
23378 + /* this is version 2 */
23379 + case VCMD_enter_space:
23380 + return vc_enter_space(vxi, data);
23382 + case VCMD_ctx_create_v0:
23383 + return vc_ctx_create(id, NULL);
23384 + case VCMD_ctx_create:
23385 + return vc_ctx_create(id, data);
23386 + case VCMD_ctx_migrate_v0:
23387 + return vc_ctx_migrate(vxi, NULL);
23388 + case VCMD_ctx_migrate:
23389 + return vc_ctx_migrate(vxi, data);
23391 + case VCMD_net_create_v0:
23392 + return vc_net_create(id, NULL);
23393 + case VCMD_net_create:
23394 + return vc_net_create(id, data);
23395 + case VCMD_net_migrate:
23396 + return vc_net_migrate(nxi, data);
23398 + case VCMD_tag_migrate:
23399 + return vc_tag_migrate(id);
23401 + case VCMD_net_add:
23402 + return vc_net_add(nxi, data);
23403 + case VCMD_net_remove:
23404 + return vc_net_remove(nxi, data);
23406 + case VCMD_net_add_ipv4_v1:
23407 + return vc_net_add_ipv4_v1(nxi, data);
23408 + /* this is version 2 */
23409 + case VCMD_net_add_ipv4:
23410 + return vc_net_add_ipv4(nxi, data);
23412 + case VCMD_net_rem_ipv4_v1:
23413 + return vc_net_rem_ipv4_v1(nxi, data);
23414 + /* this is version 2 */
23415 + case VCMD_net_rem_ipv4:
23416 + return vc_net_rem_ipv4(nxi, data);
23417 +#ifdef CONFIG_IPV6
23418 + case VCMD_net_add_ipv6:
23419 + return vc_net_add_ipv6(nxi, data);
23420 + case VCMD_net_remove_ipv6:
23421 + return vc_net_remove_ipv6(nxi, data);
23423 +/* case VCMD_add_match_ipv4:
23424 + return vc_add_match_ipv4(nxi, data);
23425 + case VCMD_get_match_ipv4:
23426 + return vc_get_match_ipv4(nxi, data);
23427 +#ifdef CONFIG_IPV6
23428 + case VCMD_add_match_ipv6:
23429 + return vc_add_match_ipv6(nxi, data);
23430 + case VCMD_get_match_ipv6:
23431 + return vc_get_match_ipv6(nxi, data);
23434 +#ifdef CONFIG_VSERVER_DEVICE
23435 + case VCMD_set_mapping:
23436 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23437 + case VCMD_unset_mapping:
23438 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23440 +#ifdef CONFIG_VSERVER_HISTORY
23441 + case VCMD_dump_history:
23442 + return vc_dump_history(id);
23443 + case VCMD_read_history:
23444 + return __COMPAT(vc_read_history, id, data, compat);
23447 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23448 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23454 +#define __VCMD(vcmd, _perm, _args, _flags) \
23455 + case VCMD_ ## vcmd: perm = _perm; \
23456 + args = _args; flags = _flags; break
23459 +#define VCA_NONE 0x00
23460 +#define VCA_VXI 0x01
23461 +#define VCA_NXI 0x02
23463 +#define VCF_NONE 0x00
23464 +#define VCF_INFO 0x01
23465 +#define VCF_ADMIN 0x02
23466 +#define VCF_ARES 0x06 /* includes admin */
23467 +#define VCF_SETUP 0x08
23469 +#define VCF_ZIDOK 0x10 /* zero id okay */
23473 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23476 + int permit = -1, state = 0;
23477 + int perm = -1, args = 0, flags = 0;
23478 + struct vx_info *vxi = NULL;
23479 + struct nx_info *nxi = NULL;
23482 + /* unpriviledged commands */
23483 + __VCMD(get_version, 0, VCA_NONE, 0);
23484 + __VCMD(get_vci, 0, VCA_NONE, 0);
23485 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23486 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23487 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23488 + __VCMD(get_space_default,0, VCA_NONE, 0);
23490 + /* info commands */
23491 + __VCMD(task_xid, 2, VCA_NONE, 0);
23492 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23493 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23494 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23495 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23496 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23497 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23498 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23499 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23500 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23501 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23502 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23504 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23505 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23506 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23507 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23509 + __VCMD(task_nid, 2, VCA_NONE, 0);
23510 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23511 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23512 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23514 + __VCMD(task_tag, 2, VCA_NONE, 0);
23516 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23517 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23518 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23519 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23521 + /* lower admin commands */
23522 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23523 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23524 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23525 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23526 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23527 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23528 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23529 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23531 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23532 + __VCMD(net_create, 5, VCA_NONE, 0);
23533 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23535 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23537 + /* higher admin commands */
23538 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23539 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23540 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23542 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23543 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23544 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23545 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23546 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23547 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23549 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23550 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23551 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23553 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23554 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23555 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23556 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23557 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23558 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23559 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23560 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23561 +#ifdef CONFIG_IPV6
23562 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23563 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23565 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23566 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23567 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23568 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23569 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23571 +#ifdef CONFIG_VSERVER_DEVICE
23572 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23573 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23575 + /* debug level admin commands */
23576 +#ifdef CONFIG_VSERVER_HISTORY
23577 + __VCMD(dump_history, 9, VCA_NONE, 0);
23578 + __VCMD(read_history, 9, VCA_NONE, 0);
23585 + vxdprintk(VXD_CBIT(switch, 0),
23586 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23587 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23588 + VC_VERSION(cmd), id, data, compat,
23589 + perm, args, flags);
23596 + if (!capable(CAP_CONTEXT))
23600 + /* moved here from the individual commands */
23602 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23606 + /* vcmd involves resource management */
23608 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23612 + /* various legacy exceptions */
23614 + /* will go away when spectator is a cap */
23615 + case VCMD_ctx_migrate_v0:
23616 + case VCMD_ctx_migrate:
23618 + current->xid = 1;
23624 + /* will go away when spectator is a cap */
23625 + case VCMD_net_migrate:
23627 + current->nid = 1;
23634 + /* vcmds are fine by default */
23637 + /* admin type vcmds require admin ... */
23638 + if (flags & VCF_ADMIN)
23639 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23641 + /* ... but setup type vcmds override that */
23642 + if (!permit && (flags & VCF_SETUP))
23643 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23651 + if (!id && (flags & VCF_ZIDOK))
23655 + if (args & VCA_VXI) {
23656 + vxi = lookup_vx_info(id);
23660 + if ((flags & VCF_ADMIN) &&
23661 + /* special case kill for shutdown */
23662 + (cmd != VCMD_ctx_kill) &&
23663 + /* can context be administrated? */
23664 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23670 + if (args & VCA_NXI) {
23671 + nxi = lookup_nx_info(id);
23675 + if ((flags & VCF_ADMIN) &&
23676 + /* can context be administrated? */
23677 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23684 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23687 + if ((args & VCA_NXI) && nxi)
23688 + put_nx_info(nxi);
23690 + if ((args & VCA_VXI) && vxi)
23691 + put_vx_info(vxi);
23693 + vxdprintk(VXD_CBIT(switch, 1),
23694 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23695 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23696 + VC_VERSION(cmd), ret, ret, state, permit);
23701 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23703 + return do_vserver(cmd, id, data, 0);
23706 +#ifdef CONFIG_COMPAT
23709 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23711 + return do_vserver(cmd, id, data, 1);
23714 +#endif /* CONFIG_COMPAT */
23715 diff -NurpP --minimal linux-3.1.1/kernel/vserver/sysctl.c linux-3.1.1-vs2.3.2/kernel/vserver/sysctl.c
23716 --- linux-3.1.1/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23717 +++ linux-3.1.1-vs2.3.2/kernel/vserver/sysctl.c 2011-10-24 18:53:33.000000000 +0200
23720 + * kernel/vserver/sysctl.c
23722 + * Virtual Context Support
23724 + * Copyright (C) 2004-2007 Herbert Pötzl
23726 + * V0.01 basic structure
23730 +#include <linux/module.h>
23731 +#include <linux/ctype.h>
23732 +#include <linux/sysctl.h>
23733 +#include <linux/parser.h>
23734 +#include <asm/uaccess.h>
23737 + CTL_DEBUG_ERROR = 0,
23738 + CTL_DEBUG_SWITCH = 1,
23753 +unsigned int vx_debug_switch = 0;
23754 +unsigned int vx_debug_xid = 0;
23755 +unsigned int vx_debug_nid = 0;
23756 +unsigned int vx_debug_tag = 0;
23757 +unsigned int vx_debug_net = 0;
23758 +unsigned int vx_debug_limit = 0;
23759 +unsigned int vx_debug_cres = 0;
23760 +unsigned int vx_debug_dlim = 0;
23761 +unsigned int vx_debug_quota = 0;
23762 +unsigned int vx_debug_cvirt = 0;
23763 +unsigned int vx_debug_space = 0;
23764 +unsigned int vx_debug_misc = 0;
23767 +static struct ctl_table_header *vserver_table_header;
23768 +static ctl_table vserver_root_table[];
23771 +void vserver_register_sysctl(void)
23773 + if (!vserver_table_header) {
23774 + vserver_table_header = register_sysctl_table(vserver_root_table);
23779 +void vserver_unregister_sysctl(void)
23781 + if (vserver_table_header) {
23782 + unregister_sysctl_table(vserver_table_header);
23783 + vserver_table_header = NULL;
23788 +static int proc_dodebug(ctl_table *table, int write,
23789 + void __user *buffer, size_t *lenp, loff_t *ppos)
23791 + char tmpbuf[20], *p, c;
23792 + unsigned int value;
23793 + size_t left, len;
23795 + if ((*ppos && !write) || !*lenp) {
23803 + if (!access_ok(VERIFY_READ, buffer, left))
23805 + p = (char *)buffer;
23806 + while (left && __get_user(c, p) >= 0 && isspace(c))
23811 + if (left > sizeof(tmpbuf) - 1)
23813 + if (copy_from_user(tmpbuf, p, left))
23815 + tmpbuf[left] = '\0';
23817 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23818 + value = 10 * value + (*p - '0');
23819 + if (*p && !isspace(*p))
23821 + while (left && isspace(*p))
23823 + *(unsigned int *)table->data = value;
23825 + if (!access_ok(VERIFY_WRITE, buffer, left))
23827 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23830 + if (__copy_to_user(buffer, tmpbuf, len))
23832 + if ((left -= len) > 0) {
23833 + if (put_user('\n', (char *)buffer + len))
23847 +#define CTL_ENTRY(ctl, name) \
23849 + .procname = #name, \
23850 + .data = &vx_ ## name, \
23851 + .maxlen = sizeof(int), \
23853 + .proc_handler = &proc_dodebug, \
23854 + .extra1 = &zero, \
23855 + .extra2 = &zero, \
23858 +static ctl_table vserver_debug_table[] = {
23859 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23860 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23861 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23862 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23863 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23864 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23865 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23866 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23867 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23868 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23869 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23870 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23874 +static ctl_table vserver_root_table[] = {
23876 + .procname = "vserver",
23878 + .child = vserver_debug_table
23884 +static match_table_t tokens = {
23885 + { CTL_DEBUG_SWITCH, "switch=%x" },
23886 + { CTL_DEBUG_XID, "xid=%x" },
23887 + { CTL_DEBUG_NID, "nid=%x" },
23888 + { CTL_DEBUG_TAG, "tag=%x" },
23889 + { CTL_DEBUG_NET, "net=%x" },
23890 + { CTL_DEBUG_LIMIT, "limit=%x" },
23891 + { CTL_DEBUG_CRES, "cres=%x" },
23892 + { CTL_DEBUG_DLIM, "dlim=%x" },
23893 + { CTL_DEBUG_QUOTA, "quota=%x" },
23894 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23895 + { CTL_DEBUG_SPACE, "space=%x" },
23896 + { CTL_DEBUG_MISC, "misc=%x" },
23897 + { CTL_DEBUG_ERROR, NULL }
23900 +#define HANDLE_CASE(id, name, val) \
23901 + case CTL_DEBUG_ ## id: \
23902 + vx_debug_ ## name = val; \
23903 + printk("vs_debug_" #name "=0x%x\n", val); \
23907 +static int __init vs_debug_setup(char *str)
23912 + printk("vs_debug_setup(%s)\n", str);
23913 + while ((p = strsep(&str, ",")) != NULL) {
23914 + substring_t args[MAX_OPT_ARGS];
23915 + unsigned int value;
23920 + token = match_token(p, tokens, args);
23921 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23924 + HANDLE_CASE(SWITCH, switch, value);
23925 + HANDLE_CASE(XID, xid, value);
23926 + HANDLE_CASE(NID, nid, value);
23927 + HANDLE_CASE(TAG, tag, value);
23928 + HANDLE_CASE(NET, net, value);
23929 + HANDLE_CASE(LIMIT, limit, value);
23930 + HANDLE_CASE(CRES, cres, value);
23931 + HANDLE_CASE(DLIM, dlim, value);
23932 + HANDLE_CASE(QUOTA, quota, value);
23933 + HANDLE_CASE(CVIRT, cvirt, value);
23934 + HANDLE_CASE(SPACE, space, value);
23935 + HANDLE_CASE(MISC, misc, value);
23944 +__setup("vsdebug=", vs_debug_setup);
23948 +EXPORT_SYMBOL_GPL(vx_debug_switch);
23949 +EXPORT_SYMBOL_GPL(vx_debug_xid);
23950 +EXPORT_SYMBOL_GPL(vx_debug_nid);
23951 +EXPORT_SYMBOL_GPL(vx_debug_net);
23952 +EXPORT_SYMBOL_GPL(vx_debug_limit);
23953 +EXPORT_SYMBOL_GPL(vx_debug_cres);
23954 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
23955 +EXPORT_SYMBOL_GPL(vx_debug_quota);
23956 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
23957 +EXPORT_SYMBOL_GPL(vx_debug_space);
23958 +EXPORT_SYMBOL_GPL(vx_debug_misc);
23960 diff -NurpP --minimal linux-3.1.1/kernel/vserver/tag.c linux-3.1.1-vs2.3.2/kernel/vserver/tag.c
23961 --- linux-3.1.1/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
23962 +++ linux-3.1.1-vs2.3.2/kernel/vserver/tag.c 2011-10-24 18:53:33.000000000 +0200
23965 + * linux/kernel/vserver/tag.c
23967 + * Virtual Server: Shallow Tag Space
23969 + * Copyright (C) 2007 Herbert Pötzl
23971 + * V0.01 basic implementation
23975 +#include <linux/sched.h>
23976 +#include <linux/vserver/debug.h>
23977 +#include <linux/vs_pid.h>
23978 +#include <linux/vs_tag.h>
23980 +#include <linux/vserver/tag_cmd.h>
23983 +int dx_migrate_task(struct task_struct *p, tag_t tag)
23988 + vxdprintk(VXD_CBIT(tag, 5),
23989 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23995 + vxdprintk(VXD_CBIT(tag, 5),
23996 + "moved task %p into [#%d]", p, tag);
24000 +/* vserver syscall commands below here */
24002 +/* taks xid and vx_info functions */
24005 +int vc_task_tag(uint32_t id)
24010 + struct task_struct *tsk;
24012 + tsk = find_task_by_real_pid(id);
24013 + tag = (tsk) ? tsk->tag : -ESRCH;
24014 + rcu_read_unlock();
24016 + tag = dx_current_tag();
24021 +int vc_tag_migrate(uint32_t tag)
24023 + return dx_migrate_task(current, tag & 0xFFFF);
24027 diff -NurpP --minimal linux-3.1.1/kernel/vserver/vci_config.h linux-3.1.1-vs2.3.2/kernel/vserver/vci_config.h
24028 --- linux-3.1.1/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
24029 +++ linux-3.1.1-vs2.3.2/kernel/vserver/vci_config.h 2011-10-24 18:53:33.000000000 +0200
24032 +/* interface version */
24034 +#define VCI_VERSION 0x00020308
24038 + VCI_KCBIT_NO_DYNAMIC = 0,
24040 + VCI_KCBIT_PROC_SECURE = 4,
24041 + /* VCI_KCBIT_HARDCPU = 5, */
24042 + /* VCI_KCBIT_IDLELIMIT = 6, */
24043 + /* VCI_KCBIT_IDLETIME = 7, */
24045 + VCI_KCBIT_COWBL = 8,
24046 + VCI_KCBIT_FULLCOWBL = 9,
24047 + VCI_KCBIT_SPACES = 10,
24048 + VCI_KCBIT_NETV2 = 11,
24049 + VCI_KCBIT_MEMCG = 12,
24051 + VCI_KCBIT_DEBUG = 16,
24052 + VCI_KCBIT_HISTORY = 20,
24053 + VCI_KCBIT_TAGGED = 24,
24054 + VCI_KCBIT_PPTAG = 28,
24056 + VCI_KCBIT_MORE = 31,
24060 +static inline uint32_t vci_kernel_config(void)
24063 + (1 << VCI_KCBIT_NO_DYNAMIC) |
24065 + /* configured features */
24066 +#ifdef CONFIG_VSERVER_PROC_SECURE
24067 + (1 << VCI_KCBIT_PROC_SECURE) |
24069 +#ifdef CONFIG_VSERVER_COWBL
24070 + (1 << VCI_KCBIT_COWBL) |
24071 + (1 << VCI_KCBIT_FULLCOWBL) |
24073 + (1 << VCI_KCBIT_SPACES) |
24074 + (1 << VCI_KCBIT_NETV2) |
24075 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
24076 + (1 << VCI_KCBIT_MEMCG) |
24079 + /* debug options */
24080 +#ifdef CONFIG_VSERVER_DEBUG
24081 + (1 << VCI_KCBIT_DEBUG) |
24083 +#ifdef CONFIG_VSERVER_HISTORY
24084 + (1 << VCI_KCBIT_HISTORY) |
24087 + /* inode context tagging */
24088 +#if defined(CONFIG_TAGGING_NONE)
24089 + (0 << VCI_KCBIT_TAGGED) |
24090 +#elif defined(CONFIG_TAGGING_UID16)
24091 + (1 << VCI_KCBIT_TAGGED) |
24092 +#elif defined(CONFIG_TAGGING_GID16)
24093 + (2 << VCI_KCBIT_TAGGED) |
24094 +#elif defined(CONFIG_TAGGING_ID24)
24095 + (3 << VCI_KCBIT_TAGGED) |
24096 +#elif defined(CONFIG_TAGGING_INTERN)
24097 + (4 << VCI_KCBIT_TAGGED) |
24098 +#elif defined(CONFIG_TAGGING_RUNTIME)
24099 + (5 << VCI_KCBIT_TAGGED) |
24101 + (7 << VCI_KCBIT_TAGGED) |
24103 + (1 << VCI_KCBIT_PPTAG) |
24107 diff -NurpP --minimal linux-3.1.1/mm/filemap_xip.c linux-3.1.1-vs2.3.2/mm/filemap_xip.c
24108 --- linux-3.1.1/mm/filemap_xip.c 2011-07-22 11:18:12.000000000 +0200
24109 +++ linux-3.1.1-vs2.3.2/mm/filemap_xip.c 2011-10-24 18:53:33.000000000 +0200
24111 #include <linux/seqlock.h>
24112 #include <linux/mutex.h>
24113 #include <linux/gfp.h>
24114 +#include <linux/vs_memory.h>
24115 #include <asm/tlbflush.h>
24116 #include <asm/io.h>
24118 diff -NurpP --minimal linux-3.1.1/mm/fremap.c linux-3.1.1-vs2.3.2/mm/fremap.c
24119 --- linux-3.1.1/mm/fremap.c 2011-07-22 11:18:12.000000000 +0200
24120 +++ linux-3.1.1-vs2.3.2/mm/fremap.c 2011-10-24 18:53:33.000000000 +0200
24122 #include <linux/module.h>
24123 #include <linux/syscalls.h>
24124 #include <linux/mmu_notifier.h>
24125 +#include <linux/vs_memory.h>
24127 #include <asm/mmu_context.h>
24128 #include <asm/cacheflush.h>
24129 diff -NurpP --minimal linux-3.1.1/mm/hugetlb.c linux-3.1.1-vs2.3.2/mm/hugetlb.c
24130 --- linux-3.1.1/mm/hugetlb.c 2011-10-24 18:45:33.000000000 +0200
24131 +++ linux-3.1.1-vs2.3.2/mm/hugetlb.c 2011-10-24 18:53:33.000000000 +0200
24134 #include <linux/hugetlb.h>
24135 #include <linux/node.h>
24136 +#include <linux/vs_memory.h>
24137 #include "internal.h"
24139 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
24140 diff -NurpP --minimal linux-3.1.1/mm/memcontrol.c linux-3.1.1-vs2.3.2/mm/memcontrol.c
24141 --- linux-3.1.1/mm/memcontrol.c 2011-10-24 18:45:33.000000000 +0200
24142 +++ linux-3.1.1-vs2.3.2/mm/memcontrol.c 2011-10-24 18:53:33.000000000 +0200
24143 @@ -760,6 +760,31 @@ struct mem_cgroup *mem_cgroup_from_task(
24144 struct mem_cgroup, css);
24147 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
24149 + return res_counter_read_u64(&mem->res, member);
24152 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
24154 + return res_counter_read_u64(&mem->memsw, member);
24157 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
24159 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
24162 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
24164 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
24167 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
24169 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
24172 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
24174 struct mem_cgroup *mem = NULL;
24175 diff -NurpP --minimal linux-3.1.1/mm/memory.c linux-3.1.1-vs2.3.2/mm/memory.c
24176 --- linux-3.1.1/mm/memory.c 2011-11-15 16:44:52.000000000 +0100
24177 +++ linux-3.1.1-vs2.3.2/mm/memory.c 2011-11-15 17:08:44.000000000 +0100
24178 @@ -3389,6 +3389,7 @@ int handle_pte_fault(struct mm_struct *m
24182 + int ret = 0, type = VXPT_UNKNOWN;
24185 if (!pte_present(entry)) {
24186 @@ -3413,9 +3414,12 @@ int handle_pte_fault(struct mm_struct *m
24187 if (unlikely(!pte_same(*pte, entry)))
24189 if (flags & FAULT_FLAG_WRITE) {
24190 - if (!pte_write(entry))
24191 - return do_wp_page(mm, vma, address,
24192 + if (!pte_write(entry)) {
24193 + ret = do_wp_page(mm, vma, address,
24194 pte, pmd, ptl, entry);
24195 + type = VXPT_WRITE;
24198 entry = pte_mkdirty(entry);
24200 entry = pte_mkyoung(entry);
24201 @@ -3433,7 +3437,10 @@ int handle_pte_fault(struct mm_struct *m
24204 pte_unmap_unlock(pte, ptl);
24208 + vx_page_fault(mm, vma, type, ret);
24213 diff -NurpP --minimal linux-3.1.1/mm/mremap.c linux-3.1.1-vs2.3.2/mm/mremap.c
24214 --- linux-3.1.1/mm/mremap.c 2011-07-22 11:18:12.000000000 +0200
24215 +++ linux-3.1.1-vs2.3.2/mm/mremap.c 2011-10-24 18:53:33.000000000 +0200
24217 #include <linux/security.h>
24218 #include <linux/syscalls.h>
24219 #include <linux/mmu_notifier.h>
24220 +#include <linux/vs_memory.h>
24222 #include <asm/uaccess.h>
24223 #include <asm/cacheflush.h>
24224 diff -NurpP --minimal linux-3.1.1/mm/oom_kill.c linux-3.1.1-vs2.3.2/mm/oom_kill.c
24225 --- linux-3.1.1/mm/oom_kill.c 2011-10-24 18:45:33.000000000 +0200
24226 +++ linux-3.1.1-vs2.3.2/mm/oom_kill.c 2011-10-24 18:53:33.000000000 +0200
24228 #include <linux/mempolicy.h>
24229 #include <linux/security.h>
24230 #include <linux/ptrace.h>
24231 +#include <linux/reboot.h>
24232 +#include <linux/vs_memory.h>
24233 +#include <linux/vs_context.h>
24235 int sysctl_panic_on_oom;
24236 int sysctl_oom_kill_allocating_task;
24237 @@ -134,11 +137,18 @@ struct task_struct *find_lock_task_mm(st
24238 static bool oom_unkillable_task(struct task_struct *p,
24239 const struct mem_cgroup *mem, const nodemask_t *nodemask)
24241 - if (is_global_init(p))
24242 + unsigned xid = vx_current_xid();
24244 + /* skip the init task, global and per guest */
24245 + if (task_is_init(p))
24247 if (p->flags & PF_KTHREAD)
24250 + /* skip other guest and host processes if oom in guest */
24251 + if (xid && vx_task_xid(p) != xid)
24254 /* When mem_cgroup_out_of_memory() and p is not member of the group */
24255 if (mem && !task_in_mem_cgroup(p, mem))
24257 @@ -214,6 +224,18 @@ unsigned int oom_badness(struct task_str
24258 points += p->signal->oom_score_adj;
24261 + * add points for context badness and
24262 + * reduce badness for processes belonging to
24263 + * a different context
24266 + points += vx_badness(p, p->mm);
24268 + if ((vx_current_xid() > 1) &&
24269 + vx_current_xid() != vx_task_xid(p))
24273 * Never return 0 for an eligible task that may be killed since it's
24274 * possible that no single user task uses more than 0.1% of memory and
24275 * no single admin tasks uses more than 3.0%.
24276 @@ -428,8 +450,8 @@ static int oom_kill_task(struct task_str
24277 /* mm cannot be safely dereferenced after task_unlock(p) */
24280 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24281 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
24282 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24283 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
24284 K(get_mm_counter(p->mm, MM_ANONPAGES)),
24285 K(get_mm_counter(p->mm, MM_FILEPAGES)));
24287 @@ -483,8 +505,8 @@ static int oom_kill_process(struct task_
24291 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
24292 - message, task_pid_nr(p), p->comm, points);
24293 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
24294 + message, task_pid_nr(p), p->xid, p->comm, points);
24298 @@ -585,6 +607,8 @@ int unregister_oom_notifier(struct notif
24300 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
24302 +long vs_oom_action(unsigned int);
24305 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
24306 * if a parallel OOM killing is already taking place that includes a zone in
24307 @@ -743,7 +767,12 @@ retry:
24309 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
24310 read_unlock(&tasklist_lock);
24311 - panic("Out of memory and no killable processes...\n");
24313 + /* avoid panic for guest OOM */
24314 + if (current->xid)
24315 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
24317 + panic("Out of memory and no killable processes...\n");
24320 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
24321 diff -NurpP --minimal linux-3.1.1/mm/page_alloc.c linux-3.1.1-vs2.3.2/mm/page_alloc.c
24322 --- linux-3.1.1/mm/page_alloc.c 2011-10-24 18:45:33.000000000 +0200
24323 +++ linux-3.1.1-vs2.3.2/mm/page_alloc.c 2011-10-24 18:53:33.000000000 +0200
24325 #include <linux/ftrace_event.h>
24326 #include <linux/memcontrol.h>
24327 #include <linux/prefetch.h>
24328 +#include <linux/vs_base.h>
24329 +#include <linux/vs_limit.h>
24331 #include <asm/tlbflush.h>
24332 #include <asm/div64.h>
24333 @@ -2484,6 +2486,9 @@ void si_meminfo(struct sysinfo *val)
24334 val->totalhigh = totalhigh_pages;
24335 val->freehigh = nr_free_highpages();
24336 val->mem_unit = PAGE_SIZE;
24338 + if (vx_flags(VXF_VIRT_MEM, 0))
24339 + vx_vsi_meminfo(val);
24342 EXPORT_SYMBOL(si_meminfo);
24343 @@ -2504,6 +2509,9 @@ void si_meminfo_node(struct sysinfo *val
24346 val->mem_unit = PAGE_SIZE;
24348 + if (vx_flags(VXF_VIRT_MEM, 0))
24349 + vx_vsi_meminfo(val);
24353 diff -NurpP --minimal linux-3.1.1/mm/pgtable-generic.c linux-3.1.1-vs2.3.2/mm/pgtable-generic.c
24354 --- linux-3.1.1/mm/pgtable-generic.c 2011-03-15 18:07:42.000000000 +0100
24355 +++ linux-3.1.1-vs2.3.2/mm/pgtable-generic.c 2011-10-24 18:53:33.000000000 +0200
24357 * Copyright (C) 2010 Linus Torvalds
24360 +#include <linux/mm.h>
24362 #include <linux/pagemap.h>
24363 #include <asm/tlb.h>
24364 #include <asm-generic/pgtable.h>
24365 diff -NurpP --minimal linux-3.1.1/mm/rmap.c linux-3.1.1-vs2.3.2/mm/rmap.c
24366 --- linux-3.1.1/mm/rmap.c 2011-10-24 18:45:33.000000000 +0200
24367 +++ linux-3.1.1-vs2.3.2/mm/rmap.c 2011-10-24 18:53:33.000000000 +0200
24369 #include <linux/mmu_notifier.h>
24370 #include <linux/migrate.h>
24371 #include <linux/hugetlb.h>
24372 +#include <linux/vs_memory.h>
24374 #include <asm/tlbflush.h>
24376 diff -NurpP --minimal linux-3.1.1/mm/shmem.c linux-3.1.1-vs2.3.2/mm/shmem.c
24377 --- linux-3.1.1/mm/shmem.c 2011-10-24 18:45:33.000000000 +0200
24378 +++ linux-3.1.1-vs2.3.2/mm/shmem.c 2011-10-24 18:53:33.000000000 +0200
24379 @@ -1429,7 +1429,7 @@ static int shmem_statfs(struct dentry *d
24381 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24383 - buf->f_type = TMPFS_MAGIC;
24384 + buf->f_type = TMPFS_SUPER_MAGIC;
24385 buf->f_bsize = PAGE_CACHE_SIZE;
24386 buf->f_namelen = NAME_MAX;
24387 if (sbinfo->max_blocks) {
24388 @@ -2186,7 +2186,7 @@ int shmem_fill_super(struct super_block
24389 sb->s_maxbytes = MAX_LFS_FILESIZE;
24390 sb->s_blocksize = PAGE_CACHE_SIZE;
24391 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24392 - sb->s_magic = TMPFS_MAGIC;
24393 + sb->s_magic = TMPFS_SUPER_MAGIC;
24394 sb->s_op = &shmem_ops;
24395 sb->s_time_gran = 1;
24396 #ifdef CONFIG_TMPFS_XATTR
24397 diff -NurpP --minimal linux-3.1.1/mm/slab.c linux-3.1.1-vs2.3.2/mm/slab.c
24398 --- linux-3.1.1/mm/slab.c 2011-10-24 18:45:33.000000000 +0200
24399 +++ linux-3.1.1-vs2.3.2/mm/slab.c 2011-10-24 18:53:33.000000000 +0200
24400 @@ -411,6 +411,8 @@ static void kmem_list3_init(struct kmem_
24401 #define STATS_INC_FREEMISS(x) do { } while (0)
24404 +#include "slab_vs.h"
24409 @@ -3399,6 +3401,7 @@ retry:
24411 obj = slab_get_obj(cachep, slabp, nodeid);
24412 check_slabp(cachep, slabp);
24413 + vx_slab_alloc(cachep, flags);
24414 l3->free_objects--;
24415 /* move slabp to correct slabp list: */
24416 list_del(&slabp->list);
24417 @@ -3476,6 +3479,7 @@ __cache_alloc_node(struct kmem_cache *ca
24418 /* ___cache_alloc_node can fall back to other nodes */
24419 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24421 + vx_slab_alloc(cachep, flags);
24422 local_irq_restore(save_flags);
24423 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24424 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24425 @@ -3663,6 +3667,7 @@ static inline void __cache_free(struct k
24427 kmemleak_free_recursive(objp, cachep->flags);
24428 objp = cache_free_debugcheck(cachep, objp, caller);
24429 + vx_slab_free(cachep);
24431 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24433 diff -NurpP --minimal linux-3.1.1/mm/slab_vs.h linux-3.1.1-vs2.3.2/mm/slab_vs.h
24434 --- linux-3.1.1/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24435 +++ linux-3.1.1-vs2.3.2/mm/slab_vs.h 2011-10-24 18:53:33.000000000 +0200
24438 +#include <linux/vserver/context.h>
24440 +#include <linux/vs_context.h>
24443 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24445 + int what = gfp_zone(cachep->gfpflags);
24446 + struct vx_info *vxi = current_vx_info();
24451 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24455 +void vx_slab_free(struct kmem_cache *cachep)
24457 + int what = gfp_zone(cachep->gfpflags);
24458 + struct vx_info *vxi = current_vx_info();
24463 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24466 diff -NurpP --minimal linux-3.1.1/mm/swapfile.c linux-3.1.1-vs2.3.2/mm/swapfile.c
24467 --- linux-3.1.1/mm/swapfile.c 2011-10-24 18:45:33.000000000 +0200
24468 +++ linux-3.1.1-vs2.3.2/mm/swapfile.c 2011-10-24 18:53:33.000000000 +0200
24470 #include <asm/tlbflush.h>
24471 #include <linux/swapops.h>
24472 #include <linux/page_cgroup.h>
24473 +#include <linux/vs_base.h>
24474 +#include <linux/vs_memory.h>
24476 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24478 @@ -1754,6 +1756,16 @@ static int swap_show(struct seq_file *sw
24480 if (si == SEQ_START_TOKEN) {
24481 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24482 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24483 + struct sysinfo si;
24485 + vx_vsi_swapinfo(&si);
24486 + if (si.totalswap < (1 << 10))
24488 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24489 + "hdv0", "partition", si.totalswap >> 10,
24490 + (si.totalswap - si.freeswap) >> 10, -1);
24495 @@ -2177,6 +2189,8 @@ void si_swapinfo(struct sysinfo *val)
24496 val->freeswap = nr_swap_pages + nr_to_be_unused;
24497 val->totalswap = total_swap_pages + nr_to_be_unused;
24498 spin_unlock(&swap_lock);
24499 + if (vx_flags(VXF_VIRT_MEM, 0))
24500 + vx_vsi_swapinfo(val);
24504 diff -NurpP --minimal linux-3.1.1/net/bridge/br_multicast.c linux-3.1.1-vs2.3.2/net/bridge/br_multicast.c
24505 --- linux-3.1.1/net/bridge/br_multicast.c 2011-10-24 18:45:34.000000000 +0200
24506 +++ linux-3.1.1-vs2.3.2/net/bridge/br_multicast.c 2011-10-24 18:53:33.000000000 +0200
24507 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
24508 ip6h->hop_limit = 1;
24509 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24510 ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24512 + &ip6h->saddr, NULL);
24513 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
24515 hopopt = (u8 *)(ip6h + 1);
24516 diff -NurpP --minimal linux-3.1.1/net/core/dev.c linux-3.1.1-vs2.3.2/net/core/dev.c
24517 --- linux-3.1.1/net/core/dev.c 2011-11-15 16:44:52.000000000 +0100
24518 +++ linux-3.1.1-vs2.3.2/net/core/dev.c 2011-11-15 17:08:44.000000000 +0100
24519 @@ -127,6 +127,7 @@
24520 #include <linux/in.h>
24521 #include <linux/jhash.h>
24522 #include <linux/random.h>
24523 +#include <linux/vs_inet.h>
24524 #include <trace/events/napi.h>
24525 #include <trace/events/net.h>
24526 #include <trace/events/skb.h>
24527 @@ -619,7 +620,8 @@ struct net_device *__dev_get_by_name(str
24528 struct hlist_head *head = dev_name_hash(net, name);
24530 hlist_for_each_entry(dev, p, head, name_hlist)
24531 - if (!strncmp(dev->name, name, IFNAMSIZ))
24532 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24533 + nx_dev_visible(current_nx_info(), dev))
24537 @@ -645,7 +647,8 @@ struct net_device *dev_get_by_name_rcu(s
24538 struct hlist_head *head = dev_name_hash(net, name);
24540 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24541 - if (!strncmp(dev->name, name, IFNAMSIZ))
24542 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24543 + nx_dev_visible(current_nx_info(), dev))
24547 @@ -696,7 +699,8 @@ struct net_device *__dev_get_by_index(st
24548 struct hlist_head *head = dev_index_hash(net, ifindex);
24550 hlist_for_each_entry(dev, p, head, index_hlist)
24551 - if (dev->ifindex == ifindex)
24552 + if ((dev->ifindex == ifindex) &&
24553 + nx_dev_visible(current_nx_info(), dev))
24557 @@ -714,7 +718,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24558 * about locking. The caller must hold RCU lock.
24561 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24562 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24564 struct hlist_node *p;
24565 struct net_device *dev;
24566 @@ -726,6 +730,16 @@ struct net_device *dev_get_by_index_rcu(
24570 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24572 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24574 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24576 + if (nx_dev_visible(current_nx_info(), dev))
24580 EXPORT_SYMBOL(dev_get_by_index_rcu);
24583 @@ -774,7 +788,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24585 for_each_netdev_rcu(net, dev)
24586 if (dev->type == type &&
24587 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24588 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24589 + nx_dev_visible(current_nx_info(), dev))
24593 @@ -786,9 +801,11 @@ struct net_device *__dev_getfirstbyhwtyp
24594 struct net_device *dev;
24597 - for_each_netdev(net, dev)
24598 - if (dev->type == type)
24599 + for_each_netdev(net, dev) {
24600 + if ((dev->type == type) &&
24601 + nx_dev_visible(current_nx_info(), dev))
24607 @@ -906,6 +923,8 @@ static int __dev_alloc_name(struct net *
24609 if (i < 0 || i >= max_netdevices)
24611 + if (!nx_dev_visible(current_nx_info(), d))
24614 /* avoid cases where sscanf is not exact inverse of printf */
24615 snprintf(buf, IFNAMSIZ, name, i);
24616 @@ -3955,6 +3974,8 @@ static int dev_ifconf(struct net *net, c
24619 for_each_netdev(net, dev) {
24620 + if (!nx_dev_visible(current_nx_info(), dev))
24622 for (i = 0; i < NPROTO; i++) {
24623 if (gifconf_list[i]) {
24625 @@ -4029,6 +4050,10 @@ static void dev_seq_printf_stats(struct
24626 struct rtnl_link_stats64 temp;
24627 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24629 + /* device visible inside network context? */
24630 + if (!nx_dev_visible(current_nx_info(), dev))
24633 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24634 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24635 dev->name, stats->rx_bytes, stats->rx_packets,
24636 diff -NurpP --minimal linux-3.1.1/net/core/rtnetlink.c linux-3.1.1-vs2.3.2/net/core/rtnetlink.c
24637 --- linux-3.1.1/net/core/rtnetlink.c 2011-10-24 18:45:34.000000000 +0200
24638 +++ linux-3.1.1-vs2.3.2/net/core/rtnetlink.c 2011-10-24 18:53:33.000000000 +0200
24639 @@ -1040,6 +1040,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24640 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
24643 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24645 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24646 NETLINK_CB(cb->skb).pid,
24647 cb->nlh->nlmsg_seq, 0,
24648 @@ -1881,6 +1883,9 @@ void rtmsg_ifinfo(int type, struct net_d
24649 int err = -ENOBUFS;
24650 size_t if_info_size;
24652 + if (!nx_dev_visible(current_nx_info(), dev))
24655 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev)), GFP_KERNEL);
24658 diff -NurpP --minimal linux-3.1.1/net/core/sock.c linux-3.1.1-vs2.3.2/net/core/sock.c
24659 --- linux-3.1.1/net/core/sock.c 2011-11-15 16:44:52.000000000 +0100
24660 +++ linux-3.1.1-vs2.3.2/net/core/sock.c 2011-11-15 17:08:44.000000000 +0100
24661 @@ -127,6 +127,10 @@
24662 #include <net/cls_cgroup.h>
24664 #include <linux/filter.h>
24665 +#include <linux/vs_socket.h>
24666 +#include <linux/vs_limit.h>
24667 +#include <linux/vs_context.h>
24668 +#include <linux/vs_network.h>
24670 #include <trace/events/sock.h>
24672 @@ -1073,6 +1077,8 @@ static struct sock *sk_prot_alloc(struct
24674 sk_tx_queue_clear(sk);
24676 + sock_vx_init(sk);
24677 + sock_nx_init(sk);
24681 @@ -1172,6 +1178,11 @@ static void __sk_free(struct sock *sk)
24682 put_cred(sk->sk_peer_cred);
24683 put_pid(sk->sk_peer_pid);
24684 put_net(sock_net(sk));
24686 + clr_vx_info(&sk->sk_vx_info);
24688 + clr_nx_info(&sk->sk_nx_info);
24690 sk_prot_free(sk->sk_prot_creator, sk);
24693 @@ -1219,6 +1230,8 @@ struct sock *sk_clone(const struct sock
24696 get_net(sock_net(newsk));
24697 + sock_vx_init(newsk);
24698 + sock_nx_init(newsk);
24699 sk_node_init(&newsk->sk_node);
24700 sock_lock_init(newsk);
24701 bh_lock_sock(newsk);
24702 @@ -1275,6 +1288,12 @@ struct sock *sk_clone(const struct sock
24704 atomic_set(&newsk->sk_refcnt, 2);
24706 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24707 + newsk->sk_xid = sk->sk_xid;
24708 + vx_sock_inc(newsk);
24709 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24710 + newsk->sk_nid = sk->sk_nid;
24713 * Increment the counter in the same struct proto as the master
24714 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24715 @@ -2023,6 +2042,12 @@ void sock_init_data(struct socket *sock,
24717 sk->sk_stamp = ktime_set(-1L, 0);
24719 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24720 + sk->sk_xid = vx_current_xid();
24722 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24723 + sk->sk_nid = nx_current_nid();
24726 * Before updating sk_refcnt, we must commit prior changes to memory
24727 * (Documentation/RCU/rculist_nulls.txt for details)
24728 diff -NurpP --minimal linux-3.1.1/net/ipv4/af_inet.c linux-3.1.1-vs2.3.2/net/ipv4/af_inet.c
24729 --- linux-3.1.1/net/ipv4/af_inet.c 2011-10-24 18:45:34.000000000 +0200
24730 +++ linux-3.1.1-vs2.3.2/net/ipv4/af_inet.c 2011-10-24 18:53:33.000000000 +0200
24731 @@ -117,6 +117,7 @@
24732 #ifdef CONFIG_IP_MROUTE
24733 #include <linux/mroute.h>
24735 +#include <linux/vs_limit.h>
24738 /* The inetsw table contains everything that inet_create needs to
24739 @@ -326,9 +327,13 @@ lookup_protocol:
24743 + if ((protocol == IPPROTO_ICMP) &&
24744 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24747 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24748 goto out_rcu_unlock;
24751 err = -EAFNOSUPPORT;
24752 if (!inet_netns_ok(net, protocol))
24753 goto out_rcu_unlock;
24754 @@ -452,6 +457,7 @@ int inet_bind(struct socket *sock, struc
24755 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24756 struct sock *sk = sock->sk;
24757 struct inet_sock *inet = inet_sk(sk);
24758 + struct nx_v4_sock_addr nsa;
24759 unsigned short snum;
24762 @@ -475,7 +481,11 @@ int inet_bind(struct socket *sock, struc
24766 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24767 + err = v4_map_sock_addr(inet, addr, &nsa);
24771 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24773 /* Not specified by any standard per-se, however it breaks too
24774 * many applications when removed. It is unfortunate since
24775 @@ -487,7 +497,7 @@ int inet_bind(struct socket *sock, struc
24776 err = -EADDRNOTAVAIL;
24777 if (!sysctl_ip_nonlocal_bind &&
24778 !(inet->freebind || inet->transparent) &&
24779 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24780 + nsa.saddr != htonl(INADDR_ANY) &&
24781 chk_addr_ret != RTN_LOCAL &&
24782 chk_addr_ret != RTN_MULTICAST &&
24783 chk_addr_ret != RTN_BROADCAST)
24784 @@ -512,7 +522,7 @@ int inet_bind(struct socket *sock, struc
24785 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24786 goto out_release_sock;
24788 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24789 + v4_set_sock_addr(inet, &nsa);
24790 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24791 inet->inet_saddr = 0; /* Use device */
24793 @@ -715,11 +725,13 @@ int inet_getname(struct socket *sock, st
24796 sin->sin_port = inet->inet_dport;
24797 - sin->sin_addr.s_addr = inet->inet_daddr;
24798 + sin->sin_addr.s_addr =
24799 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24801 __be32 addr = inet->inet_rcv_saddr;
24803 addr = inet->inet_saddr;
24804 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24805 sin->sin_port = inet->inet_sport;
24806 sin->sin_addr.s_addr = addr;
24808 diff -NurpP --minimal linux-3.1.1/net/ipv4/arp.c linux-3.1.1-vs2.3.2/net/ipv4/arp.c
24809 --- linux-3.1.1/net/ipv4/arp.c 2011-10-24 18:45:34.000000000 +0200
24810 +++ linux-3.1.1-vs2.3.2/net/ipv4/arp.c 2011-10-24 18:53:33.000000000 +0200
24811 @@ -1332,6 +1332,7 @@ static void arp_format_neigh_entry(struc
24812 struct net_device *dev = n->dev;
24813 int hatype = dev->type;
24815 + /* FIXME: check for network context */
24816 read_lock(&n->lock);
24817 /* Convert hardware address to XX:XX:XX:XX ... form. */
24818 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
24819 @@ -1363,6 +1364,7 @@ static void arp_format_pneigh_entry(stru
24820 int hatype = dev ? dev->type : 0;
24823 + /* FIXME: check for network context */
24824 sprintf(tbuf, "%pI4", n->key);
24825 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24826 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24827 diff -NurpP --minimal linux-3.1.1/net/ipv4/devinet.c linux-3.1.1-vs2.3.2/net/ipv4/devinet.c
24828 --- linux-3.1.1/net/ipv4/devinet.c 2011-10-24 18:45:34.000000000 +0200
24829 +++ linux-3.1.1-vs2.3.2/net/ipv4/devinet.c 2011-10-24 18:53:33.000000000 +0200
24830 @@ -518,6 +518,7 @@ struct in_device *inetdev_by_index(struc
24832 EXPORT_SYMBOL(inetdev_by_index);
24835 /* Called only from RTNL semaphored context. No locks. */
24837 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24838 @@ -759,6 +760,8 @@ int devinet_ioctl(struct net *net, unsig
24840 in_dev = __in_dev_get_rtnl(dev);
24842 + struct nx_info *nxi = current_nx_info();
24844 if (tryaddrmatch) {
24845 /* Matthias Andree */
24846 /* compare label and address (4.4BSD style) */
24847 @@ -767,6 +770,8 @@ int devinet_ioctl(struct net *net, unsig
24848 This is checked above. */
24849 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24850 ifap = &ifa->ifa_next) {
24851 + if (!nx_v4_ifa_visible(nxi, ifa))
24853 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24854 sin_orig.sin_addr.s_addr ==
24856 @@ -779,9 +784,12 @@ int devinet_ioctl(struct net *net, unsig
24857 comparing just the label */
24859 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24860 - ifap = &ifa->ifa_next)
24861 + ifap = &ifa->ifa_next) {
24862 + if (!nx_v4_ifa_visible(nxi, ifa))
24864 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24870 @@ -934,6 +942,8 @@ static int inet_gifconf(struct net_devic
24873 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24874 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24877 done += sizeof(ifr);
24879 @@ -1294,6 +1304,7 @@ static int inet_dump_ifaddr(struct sk_bu
24880 struct net_device *dev;
24881 struct in_device *in_dev;
24882 struct in_ifaddr *ifa;
24883 + struct sock *sk = skb->sk;
24884 struct hlist_head *head;
24885 struct hlist_node *node;
24887 @@ -1316,6 +1327,8 @@ static int inet_dump_ifaddr(struct sk_bu
24889 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24890 ifa = ifa->ifa_next, ip_idx++) {
24891 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24893 if (ip_idx < s_ip_idx)
24895 if (inet_fill_ifaddr(skb, ifa,
24896 diff -NurpP --minimal linux-3.1.1/net/ipv4/fib_trie.c linux-3.1.1-vs2.3.2/net/ipv4/fib_trie.c
24897 --- linux-3.1.1/net/ipv4/fib_trie.c 2011-10-24 18:45:34.000000000 +0200
24898 +++ linux-3.1.1-vs2.3.2/net/ipv4/fib_trie.c 2011-10-24 18:53:33.000000000 +0200
24899 @@ -2554,6 +2554,7 @@ static int fib_route_seq_show(struct seq
24900 || fa->fa_type == RTN_MULTICAST)
24903 + /* FIXME: check for network context? */
24906 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24907 diff -NurpP --minimal linux-3.1.1/net/ipv4/inet_connection_sock.c linux-3.1.1-vs2.3.2/net/ipv4/inet_connection_sock.c
24908 --- linux-3.1.1/net/ipv4/inet_connection_sock.c 2011-07-22 11:18:13.000000000 +0200
24909 +++ linux-3.1.1-vs2.3.2/net/ipv4/inet_connection_sock.c 2011-10-24 18:53:33.000000000 +0200
24910 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
24912 EXPORT_SYMBOL(inet_get_local_port_range);
24914 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24916 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24917 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24919 + if (inet_v6_ipv6only(sk2))
24922 + if (sk1_rcv_saddr &&
24924 + sk1_rcv_saddr == sk2_rcv_saddr)
24927 + if (sk1_rcv_saddr &&
24928 + !sk2_rcv_saddr &&
24929 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24932 + if (sk2_rcv_saddr &&
24933 + !sk1_rcv_saddr &&
24934 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24937 + if (!sk1_rcv_saddr &&
24938 + !sk2_rcv_saddr &&
24939 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24945 int inet_csk_bind_conflict(const struct sock *sk,
24946 const struct inet_bind_bucket *tb)
24948 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
24949 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
24950 if (!reuse || !sk2->sk_reuse ||
24951 sk2->sk_state == TCP_LISTEN) {
24952 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24953 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24954 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24955 + if (ipv4_rcv_saddr_equal(sk, sk2))
24959 diff -NurpP --minimal linux-3.1.1/net/ipv4/inet_diag.c linux-3.1.1-vs2.3.2/net/ipv4/inet_diag.c
24960 --- linux-3.1.1/net/ipv4/inet_diag.c 2011-10-24 18:45:34.000000000 +0200
24961 +++ linux-3.1.1-vs2.3.2/net/ipv4/inet_diag.c 2011-10-24 18:53:33.000000000 +0200
24963 #include <linux/stddef.h>
24965 #include <linux/inet_diag.h>
24966 +#include <linux/vs_network.h>
24967 +#include <linux/vs_inet.h>
24969 static const struct inet_diag_handler **inet_diag_table;
24971 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
24973 r->id.idiag_sport = inet->inet_sport;
24974 r->id.idiag_dport = inet->inet_dport;
24975 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24976 - r->id.idiag_dst[0] = inet->inet_daddr;
24977 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24978 + inet->inet_rcv_saddr);
24979 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24980 + inet->inet_daddr);
24982 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
24983 if (r->idiag_family == AF_INET6) {
24984 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
24985 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
24986 r->id.idiag_sport = tw->tw_sport;
24987 r->id.idiag_dport = tw->tw_dport;
24988 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24989 - r->id.idiag_dst[0] = tw->tw_daddr;
24990 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24991 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24992 r->idiag_state = tw->tw_substate;
24993 r->idiag_timer = 3;
24994 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
24995 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
24998 if (req->idiag_family == AF_INET) {
24999 + /* TODO: lback */
25000 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
25001 req->id.idiag_dport, req->id.idiag_src[0],
25002 req->id.idiag_sport, req->id.idiag_if);
25003 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
25007 + /* TODO: lback */
25008 entry.saddr = &inet->inet_rcv_saddr;
25009 entry.daddr = &inet->inet_daddr;
25011 @@ -543,6 +549,7 @@ static int inet_twsk_diag_dump(struct in
25015 + /* TODO: lback */
25016 entry.saddr = &tw->tw_rcv_saddr;
25017 entry.daddr = &tw->tw_daddr;
25019 @@ -589,8 +596,8 @@ static int inet_diag_fill_req(struct sk_
25021 r->id.idiag_sport = inet->inet_sport;
25022 r->id.idiag_dport = ireq->rmt_port;
25023 - r->id.idiag_src[0] = ireq->loc_addr;
25024 - r->id.idiag_dst[0] = ireq->rmt_addr;
25025 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
25026 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
25027 r->idiag_expires = jiffies_to_msecs(tmo);
25028 r->idiag_rqueue = 0;
25029 r->idiag_wqueue = 0;
25030 @@ -661,6 +668,7 @@ static int inet_diag_dump_reqs(struct sk
25034 + /* TODO: lback */
25036 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
25037 (entry.family == AF_INET6) ?
25038 @@ -731,6 +739,8 @@ static int inet_diag_dump(struct sk_buff
25039 sk_nulls_for_each(sk, node, &ilb->head) {
25040 struct inet_sock *inet = inet_sk(sk);
25042 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25047 @@ -797,6 +807,8 @@ skip_listen_ht:
25048 sk_nulls_for_each(sk, node, &head->chain) {
25049 struct inet_sock *inet = inet_sk(sk);
25051 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25055 if (!(r->idiag_states & (1 << sk->sk_state)))
25056 @@ -821,6 +833,8 @@ next_normal:
25057 inet_twsk_for_each(tw, node,
25060 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25064 if (r->id.idiag_sport != tw->tw_sport &&
25065 diff -NurpP --minimal linux-3.1.1/net/ipv4/inet_hashtables.c linux-3.1.1-vs2.3.2/net/ipv4/inet_hashtables.c
25066 --- linux-3.1.1/net/ipv4/inet_hashtables.c 2011-10-24 18:45:34.000000000 +0200
25067 +++ linux-3.1.1-vs2.3.2/net/ipv4/inet_hashtables.c 2011-10-24 18:53:33.000000000 +0200
25069 #include <net/inet_connection_sock.h>
25070 #include <net/inet_hashtables.h>
25071 #include <net/secure_seq.h>
25072 +#include <net/route.h>
25073 #include <net/ip.h>
25076 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
25077 if (rcv_saddr != daddr)
25081 + /* block non nx_info ips */
25082 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25083 + daddr, NXA_MASK_BIND))
25086 if (sk->sk_bound_dev_if) {
25087 if (sk->sk_bound_dev_if != dif)
25088 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
25089 * wildcarded during the search since they can never be otherwise.
25093 struct sock *__inet_lookup_listener(struct net *net,
25094 struct inet_hashinfo *hashinfo,
25095 const __be32 daddr, const unsigned short hnum,
25096 @@ -196,6 +201,7 @@ begin:
25102 * if the nulls value we got at the end of this lookup is
25103 * not the expected one, we must restart lookup.
25104 diff -NurpP --minimal linux-3.1.1/net/ipv4/netfilter/nf_nat_helper.c linux-3.1.1-vs2.3.2/net/ipv4/netfilter/nf_nat_helper.c
25105 --- linux-3.1.1/net/ipv4/netfilter/nf_nat_helper.c 2011-07-22 11:18:13.000000000 +0200
25106 +++ linux-3.1.1-vs2.3.2/net/ipv4/netfilter/nf_nat_helper.c 2011-10-24 18:53:33.000000000 +0200
25108 #include <net/route.h>
25110 #include <linux/netfilter_ipv4.h>
25111 +#include <net/route.h>
25112 #include <net/netfilter/nf_conntrack.h>
25113 #include <net/netfilter/nf_conntrack_helper.h>
25114 #include <net/netfilter/nf_conntrack_ecache.h>
25115 diff -NurpP --minimal linux-3.1.1/net/ipv4/netfilter.c linux-3.1.1-vs2.3.2/net/ipv4/netfilter.c
25116 --- linux-3.1.1/net/ipv4/netfilter.c 2011-10-24 18:45:34.000000000 +0200
25117 +++ linux-3.1.1-vs2.3.2/net/ipv4/netfilter.c 2011-10-24 18:53:33.000000000 +0200
25119 #include <linux/ip.h>
25120 #include <linux/skbuff.h>
25121 #include <linux/gfp.h>
25122 -#include <net/route.h>
25123 +// #include <net/route.h>
25124 #include <net/xfrm.h>
25125 #include <net/ip.h>
25126 #include <net/netfilter/nf_queue.h>
25127 diff -NurpP --minimal linux-3.1.1/net/ipv4/raw.c linux-3.1.1-vs2.3.2/net/ipv4/raw.c
25128 --- linux-3.1.1/net/ipv4/raw.c 2011-10-24 18:45:34.000000000 +0200
25129 +++ linux-3.1.1-vs2.3.2/net/ipv4/raw.c 2011-10-24 18:53:33.000000000 +0200
25130 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
25132 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
25133 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
25134 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
25135 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
25136 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
25137 goto found; /* gotcha */
25139 @@ -385,6 +385,12 @@ static int raw_send_hdrinc(struct sock *
25140 icmp_out_count(net, ((struct icmphdr *)
25141 skb_transport_header(skb))->type);
25144 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
25145 + sk->sk_nx_info &&
25146 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
25149 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
25150 rt->dst.dev, dst_output);
25152 @@ -572,6 +578,16 @@ static int raw_sendmsg(struct kiocb *ioc
25156 + if (sk->sk_nx_info) {
25157 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
25158 + if (IS_ERR(rt)) {
25159 + err = PTR_ERR(rt);
25166 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
25167 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
25169 @@ -648,17 +664,19 @@ static int raw_bind(struct sock *sk, str
25171 struct inet_sock *inet = inet_sk(sk);
25172 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
25173 + struct nx_v4_sock_addr nsa = { 0 };
25177 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
25179 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
25180 + v4_map_sock_addr(inet, addr, &nsa);
25181 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
25182 ret = -EADDRNOTAVAIL;
25183 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
25184 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
25185 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
25187 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
25188 + v4_set_sock_addr(inet, &nsa);
25189 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
25190 inet->inet_saddr = 0; /* Use device */
25192 @@ -710,7 +728,8 @@ static int raw_recvmsg(struct kiocb *ioc
25193 /* Copy the address. */
25195 sin->sin_family = AF_INET;
25196 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25197 + sin->sin_addr.s_addr =
25198 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
25200 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
25202 @@ -906,7 +925,8 @@ static struct sock *raw_get_first(struct
25203 struct hlist_node *node;
25205 sk_for_each(sk, node, &state->h->ht[state->bucket])
25206 - if (sock_net(sk) == seq_file_net(seq))
25207 + if ((sock_net(sk) == seq_file_net(seq)) &&
25208 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25212 @@ -922,7 +942,8 @@ static struct sock *raw_get_next(struct
25216 - } while (sk && sock_net(sk) != seq_file_net(seq));
25217 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
25218 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25220 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
25221 sk = sk_head(&state->h->ht[state->bucket]);
25222 diff -NurpP --minimal linux-3.1.1/net/ipv4/route.c linux-3.1.1-vs2.3.2/net/ipv4/route.c
25223 --- linux-3.1.1/net/ipv4/route.c 2011-10-24 18:45:34.000000000 +0200
25224 +++ linux-3.1.1-vs2.3.2/net/ipv4/route.c 2011-10-24 18:53:33.000000000 +0200
25225 @@ -2562,7 +2562,7 @@ static struct rtable *ip_route_output_sl
25228 if (fl4->flowi4_oif) {
25229 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
25230 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
25231 rth = ERR_PTR(-ENODEV);
25232 if (dev_out == NULL)
25234 diff -NurpP --minimal linux-3.1.1/net/ipv4/tcp.c linux-3.1.1-vs2.3.2/net/ipv4/tcp.c
25235 --- linux-3.1.1/net/ipv4/tcp.c 2011-07-22 11:18:13.000000000 +0200
25236 +++ linux-3.1.1-vs2.3.2/net/ipv4/tcp.c 2011-10-24 18:53:33.000000000 +0200
25237 @@ -266,6 +266,7 @@
25238 #include <linux/crypto.h>
25239 #include <linux/time.h>
25240 #include <linux/slab.h>
25241 +#include <linux/in.h>
25243 #include <net/icmp.h>
25244 #include <net/tcp.h>
25245 diff -NurpP --minimal linux-3.1.1/net/ipv4/tcp_ipv4.c linux-3.1.1-vs2.3.2/net/ipv4/tcp_ipv4.c
25246 --- linux-3.1.1/net/ipv4/tcp_ipv4.c 2011-10-24 18:45:34.000000000 +0200
25247 +++ linux-3.1.1-vs2.3.2/net/ipv4/tcp_ipv4.c 2011-10-24 18:53:33.000000000 +0200
25248 @@ -2018,6 +2018,12 @@ static void *listening_get_next(struct s
25249 req = req->dl_next;
25252 + vxdprintk(VXD_CBIT(net, 6),
25253 + "sk,req: %p [#%d] (from %d)", req->sk,
25254 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
25256 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
25258 if (req->rsk_ops->family == st->family) {
25261 @@ -2042,6 +2048,10 @@ get_req:
25264 sk_nulls_for_each_from(sk, node) {
25265 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
25266 + sk, sk->sk_nid, nx_current_nid());
25267 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25269 if (!net_eq(sock_net(sk), net))
25271 if (sk->sk_family == st->family) {
25272 @@ -2118,6 +2128,11 @@ static void *established_get_first(struc
25274 spin_lock_bh(lock);
25275 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
25276 + vxdprintk(VXD_CBIT(net, 6),
25277 + "sk,egf: %p [#%d] (from %d)",
25278 + sk, sk->sk_nid, nx_current_nid());
25279 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25281 if (sk->sk_family != st->family ||
25282 !net_eq(sock_net(sk), net)) {
25284 @@ -2128,6 +2143,11 @@ static void *established_get_first(struc
25285 st->state = TCP_SEQ_STATE_TIME_WAIT;
25286 inet_twsk_for_each(tw, node,
25287 &tcp_hashinfo.ehash[st->bucket].twchain) {
25288 + vxdprintk(VXD_CBIT(net, 6),
25289 + "tw: %p [#%d] (from %d)",
25290 + tw, tw->tw_nid, nx_current_nid());
25291 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
25293 if (tw->tw_family != st->family ||
25294 !net_eq(twsk_net(tw), net)) {
25296 @@ -2157,7 +2177,9 @@ static void *established_get_next(struct
25300 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
25301 + while (tw && (tw->tw_family != st->family ||
25302 + !net_eq(twsk_net(tw), net) ||
25303 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
25307 @@ -2181,6 +2203,11 @@ get_tw:
25308 sk = sk_nulls_next(sk);
25310 sk_nulls_for_each_from(sk, node) {
25311 + vxdprintk(VXD_CBIT(net, 6),
25312 + "sk,egn: %p [#%d] (from %d)",
25313 + sk, sk->sk_nid, nx_current_nid());
25314 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25316 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
25319 @@ -2390,9 +2417,9 @@ static void get_openreq4(struct sock *sk
25320 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25321 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
25324 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
25325 ntohs(inet_sk(sk)->inet_sport),
25327 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
25328 ntohs(ireq->rmt_port),
25330 0, 0, /* could print option size, but that is af dependent. */
25331 @@ -2414,8 +2441,8 @@ static void get_tcp4_sock(struct sock *s
25332 struct tcp_sock *tp = tcp_sk(sk);
25333 const struct inet_connection_sock *icsk = inet_csk(sk);
25334 struct inet_sock *inet = inet_sk(sk);
25335 - __be32 dest = inet->inet_daddr;
25336 - __be32 src = inet->inet_rcv_saddr;
25337 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
25338 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
25339 __u16 destp = ntohs(inet->inet_dport);
25340 __u16 srcp = ntohs(inet->inet_sport);
25342 @@ -2472,8 +2499,8 @@ static void get_timewait4_sock(struct in
25346 - dest = tw->tw_daddr;
25347 - src = tw->tw_rcv_saddr;
25348 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
25349 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
25350 destp = ntohs(tw->tw_dport);
25351 srcp = ntohs(tw->tw_sport);
25353 diff -NurpP --minimal linux-3.1.1/net/ipv4/tcp_minisocks.c linux-3.1.1-vs2.3.2/net/ipv4/tcp_minisocks.c
25354 --- linux-3.1.1/net/ipv4/tcp_minisocks.c 2011-10-24 18:45:34.000000000 +0200
25355 +++ linux-3.1.1-vs2.3.2/net/ipv4/tcp_minisocks.c 2011-10-24 18:53:33.000000000 +0200
25357 #include <linux/slab.h>
25358 #include <linux/sysctl.h>
25359 #include <linux/workqueue.h>
25360 +#include <linux/vs_limit.h>
25361 +#include <linux/vs_socket.h>
25362 +#include <linux/vs_context.h>
25363 #include <net/tcp.h>
25364 #include <net/inet_common.h>
25365 #include <net/xfrm.h>
25366 @@ -336,6 +339,11 @@ void tcp_time_wait(struct sock *sk, int
25367 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25368 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25370 + tw->tw_xid = sk->sk_xid;
25371 + tw->tw_vx_info = NULL;
25372 + tw->tw_nid = sk->sk_nid;
25373 + tw->tw_nx_info = NULL;
25375 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25376 if (tw->tw_family == PF_INET6) {
25377 struct ipv6_pinfo *np = inet6_sk(sk);
25378 diff -NurpP --minimal linux-3.1.1/net/ipv4/udp.c linux-3.1.1-vs2.3.2/net/ipv4/udp.c
25379 --- linux-3.1.1/net/ipv4/udp.c 2011-10-24 18:45:34.000000000 +0200
25380 +++ linux-3.1.1-vs2.3.2/net/ipv4/udp.c 2011-10-24 18:53:33.000000000 +0200
25381 @@ -297,14 +297,7 @@ fail:
25383 EXPORT_SYMBOL(udp_lib_get_port);
25385 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25387 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25389 - return (!ipv6_only_sock(sk2) &&
25390 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25391 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25393 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25395 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25397 @@ -339,6 +332,11 @@ static inline int compute_score(struct s
25398 if (inet->inet_rcv_saddr != daddr)
25402 + /* block non nx_info ips */
25403 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25404 + daddr, NXA_MASK_BIND))
25407 if (inet->inet_daddr) {
25408 if (inet->inet_daddr != saddr)
25409 @@ -442,6 +440,7 @@ exact_match:
25414 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25415 * harder than this. -DaveM
25417 @@ -487,6 +486,11 @@ begin:
25418 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25419 score = compute_score(sk, net, saddr, hnum, sport,
25420 daddr, dport, dif);
25421 + /* FIXME: disabled?
25422 + if (score == 9) {
25426 if (score > badness) {
25429 @@ -500,6 +504,7 @@ begin:
25430 if (get_nulls_value(node) != slot)
25435 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25437 @@ -509,6 +514,7 @@ begin:
25445 @@ -551,8 +557,7 @@ static inline struct sock *udp_v4_mcast_
25446 udp_sk(s)->udp_port_hash != hnum ||
25447 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25448 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25449 - (inet->inet_rcv_saddr &&
25450 - inet->inet_rcv_saddr != loc_addr) ||
25451 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25452 ipv6_only_sock(s) ||
25453 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25455 @@ -930,6 +935,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
25456 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
25457 faddr, saddr, dport, inet->inet_sport);
25459 + if (sk->sk_nx_info) {
25460 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
25461 + if (IS_ERR(rt)) {
25462 + err = PTR_ERR(rt);
25469 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
25470 rt = ip_route_output_flow(net, fl4, sk);
25472 @@ -1227,7 +1242,8 @@ try_again:
25474 sin->sin_family = AF_INET;
25475 sin->sin_port = udp_hdr(skb)->source;
25476 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25477 + sin->sin_addr.s_addr = nx_map_sock_lback(
25478 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25479 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25481 if (inet->cmsg_flags)
25482 @@ -1972,6 +1988,8 @@ static struct sock *udp_get_first(struct
25483 sk_nulls_for_each(sk, node, &hslot->head) {
25484 if (!net_eq(sock_net(sk), net))
25486 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25488 if (sk->sk_family == state->family)
25491 @@ -1989,7 +2007,9 @@ static struct sock *udp_get_next(struct
25494 sk = sk_nulls_next(sk);
25495 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25496 + } while (sk && (!net_eq(sock_net(sk), net) ||
25497 + sk->sk_family != state->family ||
25498 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25501 if (state->bucket <= state->udp_table->mask)
25502 diff -NurpP --minimal linux-3.1.1/net/ipv6/Kconfig linux-3.1.1-vs2.3.2/net/ipv6/Kconfig
25503 --- linux-3.1.1/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25504 +++ linux-3.1.1-vs2.3.2/net/ipv6/Kconfig 2011-10-24 18:53:33.000000000 +0200
25507 # IPv6 as module will cause a CRASH if you try to unload it
25509 - tristate "The IPv6 protocol"
25511 + bool "The IPv6 protocol"
25514 This is complemental support for the IP version 6.
25515 You will still be able to do traditional IPv4 networking as well.
25516 diff -NurpP --minimal linux-3.1.1/net/ipv6/addrconf.c linux-3.1.1-vs2.3.2/net/ipv6/addrconf.c
25517 --- linux-3.1.1/net/ipv6/addrconf.c 2011-10-24 18:45:34.000000000 +0200
25518 +++ linux-3.1.1-vs2.3.2/net/ipv6/addrconf.c 2011-10-24 18:53:33.000000000 +0200
25521 #include <linux/proc_fs.h>
25522 #include <linux/seq_file.h>
25523 +#include <linux/vs_network.h>
25524 +#include <linux/vs_inet6.h>
25526 /* Set to 3 to get tracing... */
25527 #define ACONF_DEBUG 2
25528 @@ -1108,7 +1110,7 @@ out:
25530 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25531 const struct in6_addr *daddr, unsigned int prefs,
25532 - struct in6_addr *saddr)
25533 + struct in6_addr *saddr, struct nx_info *nxi)
25535 struct ipv6_saddr_score scores[2],
25536 *score = &scores[0], *hiscore = &scores[1];
25537 @@ -1180,6 +1182,8 @@ int ipv6_dev_get_saddr(struct net *net,
25541 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25545 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25546 @@ -3087,7 +3091,10 @@ static void if6_seq_stop(struct seq_file
25547 static int if6_seq_show(struct seq_file *seq, void *v)
25549 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25550 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25552 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25553 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25554 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25556 ifp->idev->dev->ifindex,
25558 @@ -3593,6 +3600,11 @@ static int in6_dump_addrs(struct inet6_d
25559 struct ifacaddr6 *ifaca;
25561 int ip_idx = *p_ip_idx;
25562 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25564 + /* disable ipv6 on non v6 guests */
25565 + if (nxi && !nx_info_has_v6(nxi))
25568 read_lock_bh(&idev->lock);
25570 @@ -3603,6 +3615,8 @@ static int in6_dump_addrs(struct inet6_d
25571 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25572 if (++ip_idx < s_ip_idx)
25574 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25576 err = inet6_fill_ifaddr(skb, ifa,
25577 NETLINK_CB(cb->skb).pid,
25578 cb->nlh->nlmsg_seq,
25579 @@ -3619,6 +3633,8 @@ static int in6_dump_addrs(struct inet6_d
25580 ifmca = ifmca->next, ip_idx++) {
25581 if (ip_idx < s_ip_idx)
25583 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25585 err = inet6_fill_ifmcaddr(skb, ifmca,
25586 NETLINK_CB(cb->skb).pid,
25587 cb->nlh->nlmsg_seq,
25588 @@ -3634,6 +3650,8 @@ static int in6_dump_addrs(struct inet6_d
25589 ifaca = ifaca->aca_next, ip_idx++) {
25590 if (ip_idx < s_ip_idx)
25592 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25594 err = inet6_fill_ifacaddr(skb, ifaca,
25595 NETLINK_CB(cb->skb).pid,
25596 cb->nlh->nlmsg_seq,
25597 @@ -4019,6 +4037,11 @@ static int inet6_dump_ifinfo(struct sk_b
25598 struct inet6_dev *idev;
25599 struct hlist_head *head;
25600 struct hlist_node *node;
25601 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25603 + /* FIXME: maybe disable ipv6 on non v6 guests?
25604 + if (skb->sk && skb->sk->sk_vx_info)
25605 + return skb->len; */
25608 s_idx = cb->args[1];
25609 @@ -4030,6 +4053,8 @@ static int inet6_dump_ifinfo(struct sk_b
25610 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25613 + if (!v6_dev_in_nx_info(dev, nxi))
25615 idev = __in6_dev_get(dev);
25618 diff -NurpP --minimal linux-3.1.1/net/ipv6/af_inet6.c linux-3.1.1-vs2.3.2/net/ipv6/af_inet6.c
25619 --- linux-3.1.1/net/ipv6/af_inet6.c 2011-10-24 18:45:34.000000000 +0200
25620 +++ linux-3.1.1-vs2.3.2/net/ipv6/af_inet6.c 2011-10-24 18:53:33.000000000 +0200
25622 #include <linux/netdevice.h>
25623 #include <linux/icmpv6.h>
25624 #include <linux/netfilter_ipv6.h>
25625 +#include <linux/vs_inet.h>
25626 +#include <linux/vs_inet6.h>
25628 #include <net/ip.h>
25629 #include <net/ipv6.h>
25630 @@ -160,9 +162,12 @@ lookup_protocol:
25634 + if ((protocol == IPPROTO_ICMPV6) &&
25635 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25637 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25638 goto out_rcu_unlock;
25641 sock->ops = answer->ops;
25642 answer_prot = answer->prot;
25643 answer_no_check = answer->no_check;
25644 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25645 struct inet_sock *inet = inet_sk(sk);
25646 struct ipv6_pinfo *np = inet6_sk(sk);
25647 struct net *net = sock_net(sk);
25648 + struct nx_v6_sock_addr nsa;
25650 unsigned short snum;
25652 @@ -276,6 +282,10 @@ int inet6_bind(struct socket *sock, stru
25653 if (addr->sin6_family != AF_INET6)
25654 return -EAFNOSUPPORT;
25656 + err = v6_map_sock_addr(inet, addr, &nsa);
25660 addr_type = ipv6_addr_type(&addr->sin6_addr);
25661 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25663 @@ -307,6 +317,7 @@ int inet6_bind(struct socket *sock, stru
25664 /* Reproduce AF_INET checks to make the bindings consistent */
25665 v4addr = addr->sin6_addr.s6_addr32[3];
25666 chk_addr_ret = inet_addr_type(net, v4addr);
25668 if (!sysctl_ip_nonlocal_bind &&
25669 !(inet->freebind || inet->transparent) &&
25670 v4addr != htonl(INADDR_ANY) &&
25671 @@ -316,6 +327,10 @@ int inet6_bind(struct socket *sock, stru
25672 err = -EADDRNOTAVAIL;
25675 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25676 + err = -EADDRNOTAVAIL;
25680 if (addr_type != IPV6_ADDR_ANY) {
25681 struct net_device *dev = NULL;
25682 @@ -342,6 +357,11 @@ int inet6_bind(struct socket *sock, stru
25686 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25687 + err = -EADDRNOTAVAIL;
25691 /* ipv4 addr of the socket is invalid. Only the
25692 * unspecified and mapped address have a v4 equivalent.
25694 @@ -358,6 +378,9 @@ int inet6_bind(struct socket *sock, stru
25698 + /* what's that for? */
25699 + v6_set_sock_addr(inet, &nsa);
25701 inet->inet_rcv_saddr = v4addr;
25702 inet->inet_saddr = v4addr;
25704 @@ -459,9 +482,11 @@ int inet6_getname(struct socket *sock, s
25706 sin->sin6_port = inet->inet_dport;
25707 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25708 + /* FIXME: remap lback? */
25710 sin->sin6_flowinfo = np->flow_label;
25712 + /* FIXME: remap lback? */
25713 if (ipv6_addr_any(&np->rcv_saddr))
25714 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25716 diff -NurpP --minimal linux-3.1.1/net/ipv6/datagram.c linux-3.1.1-vs2.3.2/net/ipv6/datagram.c
25717 --- linux-3.1.1/net/ipv6/datagram.c 2011-10-24 18:45:34.000000000 +0200
25718 +++ linux-3.1.1-vs2.3.2/net/ipv6/datagram.c 2011-10-24 18:53:33.000000000 +0200
25719 @@ -646,7 +646,7 @@ int datagram_send_ctl(struct net *net, s
25722 if (fl6->flowi6_oif) {
25723 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25724 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25728 diff -NurpP --minimal linux-3.1.1/net/ipv6/fib6_rules.c linux-3.1.1-vs2.3.2/net/ipv6/fib6_rules.c
25729 --- linux-3.1.1/net/ipv6/fib6_rules.c 2011-05-22 16:18:00.000000000 +0200
25730 +++ linux-3.1.1-vs2.3.2/net/ipv6/fib6_rules.c 2011-10-24 18:53:33.000000000 +0200
25731 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
25732 ip6_dst_idev(&rt->dst)->dev,
25734 rt6_flags2srcprefs(flags),
25738 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25740 diff -NurpP --minimal linux-3.1.1/net/ipv6/inet6_hashtables.c linux-3.1.1-vs2.3.2/net/ipv6/inet6_hashtables.c
25741 --- linux-3.1.1/net/ipv6/inet6_hashtables.c 2011-10-24 18:45:34.000000000 +0200
25742 +++ linux-3.1.1-vs2.3.2/net/ipv6/inet6_hashtables.c 2011-10-24 18:53:33.000000000 +0200
25745 #include <linux/module.h>
25746 #include <linux/random.h>
25747 +#include <linux/vs_inet6.h>
25749 #include <net/inet_connection_sock.h>
25750 #include <net/inet_hashtables.h>
25751 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25752 unsigned int slot = hash & hashinfo->ehash_mask;
25753 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25758 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25759 @@ -95,7 +95,7 @@ begin:
25767 if (get_nulls_value(node) != slot)
25768 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
25769 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25773 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25776 if (sk->sk_bound_dev_if) {
25777 if (sk->sk_bound_dev_if != dif)
25778 diff -NurpP --minimal linux-3.1.1/net/ipv6/ip6_output.c linux-3.1.1-vs2.3.2/net/ipv6/ip6_output.c
25779 --- linux-3.1.1/net/ipv6/ip6_output.c 2011-10-24 18:45:34.000000000 +0200
25780 +++ linux-3.1.1-vs2.3.2/net/ipv6/ip6_output.c 2011-10-24 18:53:33.000000000 +0200
25781 @@ -966,7 +966,8 @@ static int ip6_dst_lookup_tail(struct so
25782 struct rt6_info *rt = (struct rt6_info *) *dst;
25783 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25784 sk ? inet6_sk(sk)->srcprefs : 0,
25787 + sk ? sk->sk_nx_info : NULL);
25789 goto out_err_release;
25791 diff -NurpP --minimal linux-3.1.1/net/ipv6/ndisc.c linux-3.1.1-vs2.3.2/net/ipv6/ndisc.c
25792 --- linux-3.1.1/net/ipv6/ndisc.c 2011-10-24 18:45:34.000000000 +0200
25793 +++ linux-3.1.1-vs2.3.2/net/ipv6/ndisc.c 2011-10-24 18:53:33.000000000 +0200
25794 @@ -591,7 +591,7 @@ static void ndisc_send_na(struct net_dev
25796 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25797 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25801 src_addr = &tmpaddr;
25803 diff -NurpP --minimal linux-3.1.1/net/ipv6/raw.c linux-3.1.1-vs2.3.2/net/ipv6/raw.c
25804 --- linux-3.1.1/net/ipv6/raw.c 2011-10-24 18:45:34.000000000 +0200
25805 +++ linux-3.1.1-vs2.3.2/net/ipv6/raw.c 2011-10-24 18:53:33.000000000 +0200
25807 #include <linux/icmpv6.h>
25808 #include <linux/netfilter.h>
25809 #include <linux/netfilter_ipv6.h>
25810 +#include <linux/vs_inet6.h>
25811 #include <linux/skbuff.h>
25812 #include <linux/compat.h>
25813 #include <asm/uaccess.h>
25814 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
25818 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25819 + err = -EADDRNOTAVAIL;
25825 /* ipv4 addr of the socket is invalid. Only the
25826 * unspecified and mapped address have a v4 equivalent.
25828 diff -NurpP --minimal linux-3.1.1/net/ipv6/route.c linux-3.1.1-vs2.3.2/net/ipv6/route.c
25829 --- linux-3.1.1/net/ipv6/route.c 2011-11-15 16:44:52.000000000 +0100
25830 +++ linux-3.1.1-vs2.3.2/net/ipv6/route.c 2011-11-15 17:08:44.000000000 +0100
25832 #include <net/xfrm.h>
25833 #include <net/netevent.h>
25834 #include <net/netlink.h>
25835 +#include <linux/vs_inet6.h>
25837 #include <asm/uaccess.h>
25839 @@ -2085,15 +2086,17 @@ int ip6_route_get_saddr(struct net *net,
25840 struct rt6_info *rt,
25841 const struct in6_addr *daddr,
25842 unsigned int prefs,
25843 - struct in6_addr *saddr)
25844 + struct in6_addr *saddr,
25845 + struct nx_info *nxi)
25847 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25849 - if (rt->rt6i_prefsrc.plen)
25850 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25851 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25852 ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr);
25854 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25855 - daddr, prefs, saddr);
25856 + daddr, prefs, saddr, nxi);
25860 @@ -2423,7 +2426,8 @@ static int rt6_fill_node(struct net *net
25861 NLA_PUT_U32(skb, RTA_IIF, iif);
25863 struct in6_addr saddr_buf;
25864 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0)
25865 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25866 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25867 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25870 @@ -2626,6 +2630,7 @@ static int rt6_info_route(struct rt6_inf
25871 struct seq_file *m = p_arg;
25872 struct neighbour *n;
25874 + /* FIXME: check for network context? */
25875 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25877 #ifdef CONFIG_IPV6_SUBTREES
25878 diff -NurpP --minimal linux-3.1.1/net/ipv6/tcp_ipv6.c linux-3.1.1-vs2.3.2/net/ipv6/tcp_ipv6.c
25879 --- linux-3.1.1/net/ipv6/tcp_ipv6.c 2011-10-24 18:45:34.000000000 +0200
25880 +++ linux-3.1.1-vs2.3.2/net/ipv6/tcp_ipv6.c 2011-10-24 18:53:33.000000000 +0200
25883 #include <linux/crypto.h>
25884 #include <linux/scatterlist.h>
25885 +#include <linux/vs_inet6.h>
25887 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25888 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25889 @@ -162,8 +163,15 @@ static int tcp_v6_connect(struct sock *s
25890 * connect() to INADDR_ANY means loopback (BSD'ism).
25893 - if(ipv6_addr_any(&usin->sin6_addr))
25894 - usin->sin6_addr.s6_addr[15] = 0x1;
25895 + if(ipv6_addr_any(&usin->sin6_addr)) {
25896 + struct nx_info *nxi = sk->sk_nx_info;
25898 + if (nxi && nx_info_has_v6(nxi))
25899 + /* FIXME: remap lback? */
25900 + usin->sin6_addr = nxi->v6.ip;
25902 + usin->sin6_addr.s6_addr[15] = 0x1;
25905 addr_type = ipv6_addr_type(&usin->sin6_addr);
25907 diff -NurpP --minimal linux-3.1.1/net/ipv6/udp.c linux-3.1.1-vs2.3.2/net/ipv6/udp.c
25908 --- linux-3.1.1/net/ipv6/udp.c 2011-10-24 18:45:34.000000000 +0200
25909 +++ linux-3.1.1-vs2.3.2/net/ipv6/udp.c 2011-10-24 18:53:33.000000000 +0200
25910 @@ -45,41 +45,67 @@
25911 #include <net/tcp_states.h>
25912 #include <net/ip6_checksum.h>
25913 #include <net/xfrm.h>
25914 +#include <linux/vs_inet6.h>
25916 #include <linux/proc_fs.h>
25917 #include <linux/seq_file.h>
25918 #include "udp_impl.h"
25920 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25921 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25923 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25924 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25925 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25926 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25927 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25928 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25929 - int sk_ipv6only = ipv6_only_sock(sk);
25930 + int sk1_ipv6only = ipv6_only_sock(sk1);
25931 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25932 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25933 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25934 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25936 /* if both are mapped, treat as IPv4 */
25937 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25938 - return (!sk2_ipv6only &&
25939 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25940 + if (!sk2_ipv6only &&
25941 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25942 - sk1_rcv_saddr == sk2_rcv_saddr));
25943 + sk1_rcv_saddr == sk2_rcv_saddr))
25949 if (addr_type2 == IPV6_ADDR_ANY &&
25950 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25954 if (addr_type == IPV6_ADDR_ANY &&
25955 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25957 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25960 if (sk2_rcv_saddr6 &&
25961 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25963 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25969 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25970 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25971 + if (!sk2_rcv_saddr)
25972 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25973 + if (!sk1_rcv_saddr)
25974 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25977 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25978 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25979 + else if (addr_type2 == IPV6_ADDR_ANY)
25980 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25981 + else if (addr_type == IPV6_ADDR_ANY) {
25982 + if (addr_type2 == IPV6_ADDR_MAPPED)
25983 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25985 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25990 static unsigned int udp6_portaddr_hash(struct net *net,
25991 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
25992 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25996 + /* block non nx_info ips */
25997 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
26000 if (!ipv6_addr_any(&np->daddr)) {
26001 if (!ipv6_addr_equal(&np->daddr, saddr))
26002 diff -NurpP --minimal linux-3.1.1/net/ipv6/xfrm6_policy.c linux-3.1.1-vs2.3.2/net/ipv6/xfrm6_policy.c
26003 --- linux-3.1.1/net/ipv6/xfrm6_policy.c 2011-07-22 11:18:13.000000000 +0200
26004 +++ linux-3.1.1-vs2.3.2/net/ipv6/xfrm6_policy.c 2011-10-24 18:53:33.000000000 +0200
26005 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
26006 dev = ip6_dst_idev(dst)->dev;
26007 ipv6_dev_get_saddr(dev_net(dev), dev,
26008 (struct in6_addr *)&daddr->a6, 0,
26009 - (struct in6_addr *)&saddr->a6);
26010 + (struct in6_addr *)&saddr->a6, NULL);
26014 diff -NurpP --minimal linux-3.1.1/net/netfilter/ipvs/ip_vs_xmit.c linux-3.1.1-vs2.3.2/net/netfilter/ipvs/ip_vs_xmit.c
26015 --- linux-3.1.1/net/netfilter/ipvs/ip_vs_xmit.c 2011-07-22 11:18:13.000000000 +0200
26016 +++ linux-3.1.1-vs2.3.2/net/netfilter/ipvs/ip_vs_xmit.c 2011-10-24 18:53:33.000000000 +0200
26017 @@ -226,7 +226,7 @@ __ip_vs_route_output_v6(struct net *net,
26019 if (ipv6_addr_any(&fl6.saddr) &&
26020 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
26021 - &fl6.daddr, 0, &fl6.saddr) < 0)
26022 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
26025 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
26026 diff -NurpP --minimal linux-3.1.1/net/netlink/af_netlink.c linux-3.1.1-vs2.3.2/net/netlink/af_netlink.c
26027 --- linux-3.1.1/net/netlink/af_netlink.c 2011-10-24 18:45:34.000000000 +0200
26028 +++ linux-3.1.1-vs2.3.2/net/netlink/af_netlink.c 2011-10-24 18:53:33.000000000 +0200
26030 #include <linux/types.h>
26031 #include <linux/audit.h>
26032 #include <linux/mutex.h>
26033 +#include <linux/vs_context.h>
26034 +#include <linux/vs_network.h>
26035 +#include <linux/vs_limit.h>
26037 #include <net/net_namespace.h>
26038 #include <net/sock.h>
26039 @@ -1913,6 +1916,8 @@ static struct sock *netlink_seq_socket_i
26040 sk_for_each(s, node, &hash->table[j]) {
26041 if (sock_net(s) != seq_file_net(seq))
26043 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26047 iter->hash_idx = j;
26048 @@ -1947,7 +1952,8 @@ static void *netlink_seq_next(struct seq
26052 - } while (s && sock_net(s) != seq_file_net(seq));
26053 + } while (s && (sock_net(s) != seq_file_net(seq) ||
26054 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
26058 @@ -1959,7 +1965,8 @@ static void *netlink_seq_next(struct seq
26060 for (; j <= hash->mask; j++) {
26061 s = sk_head(&hash->table[j]);
26062 - while (s && sock_net(s) != seq_file_net(seq))
26063 + while (s && (sock_net(s) != seq_file_net(seq) ||
26064 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
26068 diff -NurpP --minimal linux-3.1.1/net/socket.c linux-3.1.1-vs2.3.2/net/socket.c
26069 --- linux-3.1.1/net/socket.c 2011-10-24 18:45:34.000000000 +0200
26070 +++ linux-3.1.1-vs2.3.2/net/socket.c 2011-10-24 18:53:33.000000000 +0200
26073 #include <net/sock.h>
26074 #include <linux/netfilter.h>
26075 +#include <linux/vs_base.h>
26076 +#include <linux/vs_socket.h>
26077 +#include <linux/vs_inet.h>
26078 +#include <linux/vs_inet6.h>
26080 #include <linux/if_tun.h>
26081 #include <linux/ipv6_route.h>
26082 @@ -546,6 +550,7 @@ static inline int __sock_sendmsg_nosec(s
26083 struct msghdr *msg, size_t size)
26085 struct sock_iocb *si = kiocb_to_siocb(iocb);
26088 sock_update_classid(sock->sk);
26090 @@ -554,7 +559,22 @@ static inline int __sock_sendmsg_nosec(s
26094 - return sock->ops->sendmsg(iocb, sock, msg, size);
26095 + len = sock->ops->sendmsg(iocb, sock, msg, size);
26098 + vx_sock_send(sock->sk, size);
26100 + vx_sock_fail(sock->sk, size);
26102 + vxdprintk(VXD_CBIT(net, 7),
26103 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
26105 + (sock->sk)?sock->sk->sk_nx_info:0,
26106 + (sock->sk)?sock->sk->sk_vx_info:0,
26107 + (sock->sk)?sock->sk->sk_xid:0,
26108 + (sock->sk)?sock->sk->sk_nid:0,
26109 + (unsigned int)size, len);
26113 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
26114 @@ -694,6 +714,7 @@ static inline int __sock_recvmsg_nosec(s
26115 struct msghdr *msg, size_t size, int flags)
26117 struct sock_iocb *si = kiocb_to_siocb(iocb);
26120 sock_update_classid(sock->sk);
26122 @@ -703,7 +724,18 @@ static inline int __sock_recvmsg_nosec(s
26126 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
26127 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
26128 + if ((len >= 0) && sock->sk)
26129 + vx_sock_recv(sock->sk, len);
26130 + vxdprintk(VXD_CBIT(net, 7),
26131 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
26133 + (sock->sk)?sock->sk->sk_nx_info:0,
26134 + (sock->sk)?sock->sk->sk_vx_info:0,
26135 + (sock->sk)?sock->sk->sk_xid:0,
26136 + (sock->sk)?sock->sk->sk_nid:0,
26137 + (unsigned int)size, len);
26141 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
26142 @@ -1188,6 +1220,13 @@ int __sock_create(struct net *net, int f
26143 if (type < 0 || type >= SOCK_MAX)
26146 + if (!nx_check(0, VS_ADMIN)) {
26147 + if (family == PF_INET && !current_nx_info_has_v4())
26148 + return -EAFNOSUPPORT;
26149 + if (family == PF_INET6 && !current_nx_info_has_v6())
26150 + return -EAFNOSUPPORT;
26155 This uglymoron is moved from INET layer to here to avoid
26156 @@ -1323,6 +1362,7 @@ SYSCALL_DEFINE3(socket, int, family, int
26160 + set_bit(SOCK_USER_SOCKET, &sock->flags);
26161 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
26164 @@ -1364,10 +1404,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
26165 err = sock_create(family, type, protocol, &sock1);
26168 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
26170 err = sock_create(family, type, protocol, &sock2);
26172 goto out_release_1;
26173 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
26175 err = sock1->ops->socketpair(sock1, sock2);
26177 diff -NurpP --minimal linux-3.1.1/net/sunrpc/auth.c linux-3.1.1-vs2.3.2/net/sunrpc/auth.c
26178 --- linux-3.1.1/net/sunrpc/auth.c 2011-10-24 18:45:34.000000000 +0200
26179 +++ linux-3.1.1-vs2.3.2/net/sunrpc/auth.c 2011-10-24 18:53:33.000000000 +0200
26181 #include <linux/hash.h>
26182 #include <linux/sunrpc/clnt.h>
26183 #include <linux/spinlock.h>
26184 +#include <linux/vs_tag.h>
26187 # define RPCDBG_FACILITY RPCDBG_AUTH
26188 @@ -427,6 +428,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
26189 memset(&acred, 0, sizeof(acred));
26190 acred.uid = cred->fsuid;
26191 acred.gid = cred->fsgid;
26192 + acred.tag = dx_current_tag();
26193 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
26195 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
26196 @@ -467,6 +469,7 @@ rpcauth_bind_root_cred(struct rpc_task *
26197 struct auth_cred acred = {
26200 + .tag = dx_current_tag(),
26203 dprintk("RPC: %5u looking up %s cred\n",
26204 diff -NurpP --minimal linux-3.1.1/net/sunrpc/auth_unix.c linux-3.1.1-vs2.3.2/net/sunrpc/auth_unix.c
26205 --- linux-3.1.1/net/sunrpc/auth_unix.c 2011-11-15 16:44:52.000000000 +0100
26206 +++ linux-3.1.1-vs2.3.2/net/sunrpc/auth_unix.c 2011-11-15 17:08:44.000000000 +0100
26207 @@ -12,12 +12,14 @@
26208 #include <linux/module.h>
26209 #include <linux/sunrpc/clnt.h>
26210 #include <linux/sunrpc/auth.h>
26211 +#include <linux/vs_tag.h>
26213 #define NFS_NGROUPS 16
26216 struct rpc_cred uc_base;
26219 gid_t uc_gids[NFS_NGROUPS];
26221 #define uc_uid uc_base.cr_uid
26222 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
26223 groups = NFS_NGROUPS;
26225 cred->uc_gid = acred->gid;
26226 + cred->uc_tag = acred->tag;
26227 for (i = 0; i < groups; i++)
26228 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
26229 if (i < NFS_NGROUPS)
26230 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
26234 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
26235 + if (cred->uc_uid != acred->uid ||
26236 + cred->uc_gid != acred->gid ||
26237 + cred->uc_tag != acred->tag)
26240 if (acred->group_info != NULL)
26241 @@ -145,7 +150,7 @@ unx_marshal(struct rpc_task *task, __be3
26242 struct rpc_clnt *clnt = task->tk_client;
26243 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
26244 __be32 *base, *hold;
26248 *p++ = htonl(RPC_AUTH_UNIX);
26250 @@ -155,9 +160,12 @@ unx_marshal(struct rpc_task *task, __be3
26251 * Copy the UTS nodename captured when the client was created.
26253 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
26254 + tag = task->tk_client->cl_tag;
26256 - *p++ = htonl((u32) cred->uc_uid);
26257 - *p++ = htonl((u32) cred->uc_gid);
26258 + *p++ = htonl((u32) TAGINO_UID(tag,
26259 + cred->uc_uid, cred->uc_tag));
26260 + *p++ = htonl((u32) TAGINO_GID(tag,
26261 + cred->uc_gid, cred->uc_tag));
26263 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
26264 *p++ = htonl((u32) cred->uc_gids[i]);
26265 diff -NurpP --minimal linux-3.1.1/net/sunrpc/clnt.c linux-3.1.1-vs2.3.2/net/sunrpc/clnt.c
26266 --- linux-3.1.1/net/sunrpc/clnt.c 2011-10-24 18:45:34.000000000 +0200
26267 +++ linux-3.1.1-vs2.3.2/net/sunrpc/clnt.c 2011-10-24 18:53:33.000000000 +0200
26269 #include <linux/in.h>
26270 #include <linux/in6.h>
26271 #include <linux/un.h>
26272 +#include <linux/vs_cvirt.h>
26274 #include <linux/sunrpc/clnt.h>
26275 #include <linux/sunrpc/rpc_pipe_fs.h>
26276 @@ -361,6 +362,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
26277 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
26278 clnt->cl_chatty = 1;
26280 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
26281 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
26282 + clnt->cl_tag = 1; */
26285 EXPORT_SYMBOL_GPL(rpc_create);
26286 diff -NurpP --minimal linux-3.1.1/net/unix/af_unix.c linux-3.1.1-vs2.3.2/net/unix/af_unix.c
26287 --- linux-3.1.1/net/unix/af_unix.c 2011-10-24 18:45:34.000000000 +0200
26288 +++ linux-3.1.1-vs2.3.2/net/unix/af_unix.c 2011-10-24 18:53:33.000000000 +0200
26289 @@ -114,6 +114,8 @@
26290 #include <linux/mount.h>
26291 #include <net/checksum.h>
26292 #include <linux/security.h>
26293 +#include <linux/vs_context.h>
26294 +#include <linux/vs_limit.h>
26296 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
26297 static DEFINE_SPINLOCK(unix_table_lock);
26298 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
26299 if (!net_eq(sock_net(s), net))
26302 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26304 if (u->addr->len == len &&
26305 !memcmp(u->addr->name, sunname, len))
26307 @@ -2204,6 +2208,8 @@ static struct sock *unix_seq_idx(struct
26308 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
26309 if (sock_net(s) != seq_file_net(seq))
26311 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26316 @@ -2228,7 +2234,8 @@ static void *unix_seq_next(struct seq_fi
26317 sk = first_unix_socket(&iter->i);
26319 sk = next_unix_socket(&iter->i, sk);
26320 - while (sk && (sock_net(sk) != seq_file_net(seq)))
26321 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
26322 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
26323 sk = next_unix_socket(&iter->i, sk);
26326 diff -NurpP --minimal linux-3.1.1/scripts/checksyscalls.sh linux-3.1.1-vs2.3.2/scripts/checksyscalls.sh
26327 --- linux-3.1.1/scripts/checksyscalls.sh 2011-03-15 18:07:46.000000000 +0100
26328 +++ linux-3.1.1-vs2.3.2/scripts/checksyscalls.sh 2011-10-24 18:53:33.000000000 +0200
26329 @@ -193,7 +193,6 @@ cat << EOF
26330 #define __IGNORE_afs_syscall
26331 #define __IGNORE_getpmsg
26332 #define __IGNORE_putpmsg
26333 -#define __IGNORE_vserver
26337 diff -NurpP --minimal linux-3.1.1/security/commoncap.c linux-3.1.1-vs2.3.2/security/commoncap.c
26338 --- linux-3.1.1/security/commoncap.c 2011-07-22 11:18:14.000000000 +0200
26339 +++ linux-3.1.1-vs2.3.2/security/commoncap.c 2011-10-24 18:53:33.000000000 +0200
26340 @@ -62,6 +62,7 @@ int cap_netlink_recv(struct sk_buff *skb
26345 EXPORT_SYMBOL(cap_netlink_recv);
26348 @@ -83,14 +84,20 @@ EXPORT_SYMBOL(cap_netlink_recv);
26349 int cap_capable(struct task_struct *tsk, const struct cred *cred,
26350 struct user_namespace *targ_ns, int cap, int audit)
26352 + struct vx_info *vxi = tsk->vx_info;
26355 /* The creator of the user namespace has all caps. */
26356 if (targ_ns != &init_user_ns && targ_ns->creator == cred->user)
26359 /* Do we have the necessary capabilities? */
26360 - if (targ_ns == cred->user->user_ns)
26361 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26362 + if (targ_ns == cred->user->user_ns) {
26363 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26364 + cap_raised(cred->cap_effective, cap))
26366 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26369 /* Have we tried all of the parent namespaces? */
26370 if (targ_ns == &init_user_ns)
26371 @@ -611,7 +618,7 @@ int cap_inode_setxattr(struct dentry *de
26373 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26374 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26375 - !capable(CAP_SYS_ADMIN))
26376 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26380 @@ -637,7 +644,7 @@ int cap_inode_removexattr(struct dentry
26382 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26383 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26384 - !capable(CAP_SYS_ADMIN))
26385 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26389 diff -NurpP --minimal linux-3.1.1/security/selinux/hooks.c linux-3.1.1-vs2.3.2/security/selinux/hooks.c
26390 --- linux-3.1.1/security/selinux/hooks.c 2011-10-24 18:45:35.000000000 +0200
26391 +++ linux-3.1.1-vs2.3.2/security/selinux/hooks.c 2011-10-24 18:53:33.000000000 +0200
26393 #include <linux/dccp.h>
26394 #include <linux/quota.h>
26395 #include <linux/un.h> /* for Unix socket types */
26396 -#include <net/af_unix.h> /* for Unix socket types */
26397 #include <linux/parser.h>
26398 #include <linux/nfs_mount.h>
26399 #include <net/ipv6.h>